Skip to content

Commit 9698116

Browse files
committed
upgrade native document to 1.0.32
1 parent ab76255 commit 9698116

File tree

6 files changed

+36
-34
lines changed

6 files changed

+36
-34
lines changed

frameworks/keyed/native-document/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link href="/css/currentStyle.css" rel="stylesheet" />
66
</head>
77
<body>
8-
<div id="main"></div>
8+
<div id="root"></div>
99
<script src="dist/main.js"></script>
1010
</body>
1111
</html>

frameworks/keyed/native-document/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/native-document/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dev": "vite"
1212
},
1313
"dependencies": {
14-
"native-document": "1.0.26",
14+
"native-document": "1.0.32",
1515
"vite": "^7.0.4"
1616
}
1717
}
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Link, Span } from "native-document/elements";
2-
import AppService from "../service";
32

4-
export default function RemoveIcon(itemId){
5-
return Link(
6-
Span({ class: 'glyphicon glyphicon-remove', 'aria-hidden': true })
7-
).nd.onClick(() => AppService.remove(itemId));
8-
};
3+
4+
export default (function RemoveIcon(attributes) {
5+
return Link(Span(attributes));
6+
}).cached({ class: 'glyphicon glyphicon-remove', 'aria-hidden': true });
Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
import { Tr, Td, ForEachArray, Link, Span, Div, Table, TBody } from "native-document/elements";
2-
import { Observable } from "native-document";
32

43
import Jumbotron from "./components/Jumbotron";
54
import RemoveIcon from "./components/RemoveIcon";
65

76
import AppService from "./service";
87

9-
const App = () => {
108

11-
return Div({ class: 'container' }, [
12-
Jumbotron(),
13-
Table({ class: 'table table-hover table-striped test-data' }, [
14-
TBody(
15-
ForEachArray(AppService.data, (item) => {
16-
return Tr( { class: { 'danger': AppService.selected.when(item.id) } }, [
17-
Td({ class: 'col-md-1' }, item.id),
18-
Td({ class: 'col-md-4' },
19-
Link(item.label)
20-
).nd.onClick(() => AppService.select(item.id)),
21-
Td({ class: 'col-md-1' }, RemoveIcon(item.id)),
22-
Td({ class: 'col-md-6'})
23-
]);
24-
},
25-
'id')
26-
),
27-
Span({ class: 'preloadicon glyphicon glyphicon-remove', 'aria-hidden': true })
28-
])
9+
const Attributes = {
10+
table: { class: 'table table-hover table-striped test-data' },
11+
cell_md_1: { class: 'col-md-1' },
12+
cell_md_4: { class: 'col-md-4' },
13+
};
14+
15+
const emptyCell = Td.cached({ class: 'col-md-6'});
16+
const TableRowBuilder = (item) => {
17+
return Tr( { class: { 'danger': AppService.selected.when(item.id) } }, [
18+
Td(Attributes.cell_md_1, item.id),
19+
Td(Attributes.cell_md_4, Link(item.label)).nd.onClick(() => AppService.select(item.id)),
20+
Td(Attributes.cell_md_1,
21+
RemoveIcon(item.id).nd.onClick(() => AppService.remove(item.id))
22+
),
23+
emptyCell
2924
]);
30-
}
25+
};
26+
27+
const App = Div({ class: 'container' }, [
28+
Jumbotron(),
29+
Table(Attributes.table,
30+
TBody(ForEachArray(AppService.data, TableRowBuilder, 'id', { isParentUniqueChild: true}))
31+
),
32+
Span({ class: 'preloadicon glyphicon glyphicon-remove', 'aria-hidden': true })
33+
]);
3134

32-
document.querySelector('#main').append(App());
35+
document.getElementById('root').appendChild(App);

frameworks/keyed/native-document/src/service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const selected = Observable(0);
88
const AppService = {
99
data,
1010
selected,
11+
clean: Observable(false),
1112
resetSelected() {
1213
selected.disconnectAll();
1314
selected.set(0);

0 commit comments

Comments
 (0)