native-document 1.0.166 → 1.0.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/.vitepress/config.js +166 -0
  2. package/CHANGELOG.md +153 -0
  3. package/components.js +2 -1
  4. package/dist/native-document.components.min.js +495 -228
  5. package/dist/native-document.dev.js +7 -0
  6. package/dist/native-document.dev.js.map +1 -1
  7. package/dist/native-document.min.js +1 -1
  8. package/docs/advanced-components.md +213 -608
  9. package/docs/anchor.md +173 -312
  10. package/docs/cache.md +95 -803
  11. package/docs/cli.md +179 -0
  12. package/docs/components/accordion.md +172 -0
  13. package/docs/components/alert.md +99 -0
  14. package/docs/components/avatar.md +160 -0
  15. package/docs/components/badge.md +102 -0
  16. package/docs/components/breadcrumb.md +89 -0
  17. package/docs/components/button.md +183 -0
  18. package/docs/components/card.md +69 -0
  19. package/docs/components/context-menu.md +118 -0
  20. package/docs/components/data-table.md +345 -0
  21. package/docs/components/dropdown.md +214 -0
  22. package/docs/components/form/autocomplete-field.md +81 -0
  23. package/docs/components/form/checkbox-field.md +41 -0
  24. package/docs/components/form/checkbox-group-field.md +54 -0
  25. package/docs/components/form/color-field.md +64 -0
  26. package/docs/components/form/date-field.md +92 -0
  27. package/docs/components/form/field-collection.md +63 -0
  28. package/docs/components/form/file-field.md +203 -0
  29. package/docs/components/form/form-control.md +87 -0
  30. package/docs/components/form/image-field.md +90 -0
  31. package/docs/components/form/index.md +115 -0
  32. package/docs/components/form/number-field.md +65 -0
  33. package/docs/components/form/radio-field.md +51 -0
  34. package/docs/components/form/select-field.md +123 -0
  35. package/docs/components/form/slider.md +136 -0
  36. package/docs/components/form/string-field.md +134 -0
  37. package/docs/components/form/textarea-field.md +65 -0
  38. package/docs/components/form-fields.md +372 -0
  39. package/docs/components/getting-started.md +264 -0
  40. package/docs/components/index.md +337 -0
  41. package/docs/components/layout.md +279 -0
  42. package/docs/components/list.md +73 -0
  43. package/docs/components/menu.md +215 -0
  44. package/docs/components/modal.md +156 -0
  45. package/docs/components/pagination.md +95 -0
  46. package/docs/components/popover.md +131 -0
  47. package/docs/components/progress.md +111 -0
  48. package/docs/components/shortcut-manager.md +221 -0
  49. package/docs/components/simple-table.md +107 -0
  50. package/docs/components/skeleton.md +155 -0
  51. package/docs/components/spinner.md +100 -0
  52. package/docs/components/splitter.md +133 -0
  53. package/docs/components/stepper.md +163 -0
  54. package/docs/components/switch.md +113 -0
  55. package/docs/components/tabs.md +153 -0
  56. package/docs/components/toast.md +119 -0
  57. package/docs/components/tooltip.md +151 -0
  58. package/docs/components/traits.md +261 -0
  59. package/docs/conditional-rendering.md +170 -588
  60. package/docs/contributing.md +300 -25
  61. package/docs/core-concepts.md +205 -374
  62. package/docs/elements.md +251 -367
  63. package/docs/extending-native-document-element.md +192 -207
  64. package/docs/filters.md +153 -1122
  65. package/docs/getting-started.md +193 -267
  66. package/docs/i18n.md +241 -0
  67. package/docs/index.md +76 -0
  68. package/docs/lifecycle-events.md +143 -75
  69. package/docs/list-rendering.md +227 -852
  70. package/docs/memory-management.md +134 -47
  71. package/docs/native-document-element.md +337 -186
  72. package/docs/native-fetch.md +99 -630
  73. package/docs/observable-resource.md +364 -0
  74. package/docs/observables.md +592 -526
  75. package/docs/routing.md +244 -653
  76. package/docs/state-management.md +134 -241
  77. package/docs/svg-elements.md +231 -0
  78. package/docs/theming.md +409 -0
  79. package/docs/tutorials/.gitkeep +0 -0
  80. package/docs/validation.md +95 -97
  81. package/docs/vitepress-conventions.md +219 -0
  82. package/package.json +34 -13
  83. package/readme.md +269 -89
  84. package/src/components/card/Card.js +93 -39
  85. package/src/components/card/index.js +1 -1
  86. package/src/components/list/HasListItem.js +171 -0
  87. package/src/components/list/List.js +41 -107
  88. package/src/components/list/ListDivider.js +39 -0
  89. package/src/components/list/ListGroup.js +76 -59
  90. package/src/components/list/ListItem.js +117 -69
  91. package/src/components/list/index.js +3 -1
  92. package/src/components/list/types/ListItem.d.ts +45 -34
  93. package/src/components/spacer/Spacer.js +1 -1
  94. package/src/core/data/ObservableResource.js +5 -0
  95. package/src/core/data/observable-helpers/observable.prototypes.js +2 -0
  96. package/src/ui/components/card/CardRender.js +133 -0
  97. package/src/ui/components/card/card.css +169 -0
  98. package/src/ui/components/contextmenu/ContextmenuRender.js +1 -1
  99. package/src/ui/components/list/ListRender.js +18 -0
  100. package/src/ui/components/list/divider/ListDividerRender.js +10 -0
  101. package/src/ui/components/list/divider/list-divider.css +12 -0
  102. package/src/ui/components/list/group/ListGroupRender.js +61 -0
  103. package/src/ui/components/list/group/list-group.css +62 -0
  104. package/src/ui/components/list/item/ListItemRender.js +238 -0
  105. package/src/ui/components/list/item/list-item.css +191 -0
  106. package/src/ui/components/list/list.css +24 -0
  107. package/src/ui/components/spacer/SpacerRender.js +10 -0
  108. package/src/ui/index.js +8 -0
@@ -1,9 +1,9 @@
1
1
  import BaseComponent from '../BaseComponent';
2
+ import HasEventEmitter from '../../core/utils/HasEventEmitter';
2
3
 
3
4
  /**
4
5
  * Versatile content container with optional image, header, footer, actions. Supports clickable, hoverable, loading, and horizontal layouts.
5
6
  *
6
- *
7
7
  * @example
8
8
  * const card = new Card()
9
9
  * .title(Span('Card title'))
@@ -19,43 +19,80 @@ import BaseComponent from '../BaseComponent';
19
19
  * });
20
20
  *
21
21
  * @constructor
22
- * @param {GlobalAttributes} [config={}]
22
+ * @param {GlobalAttributes} [props={}]
23
23
  */
24
- export default function Card(config = {}) {
25
- if(!(this instanceof Card)) {
26
- return new Card(config);
24
+ export default function Card(props = {}) {
25
+ if (!(this instanceof Card)) {
26
+ return new Card(props);
27
27
  }
28
+
28
29
  this.$description = {
29
- ...config,
30
+ title: null,
31
+ subtitle: null,
32
+ image: null,
33
+ imagePosition: 'top',
34
+ content: null,
35
+ variant: null,
36
+ loading: null,
37
+ horizontal: false,
38
+ hoverable: false,
39
+ actions: [],
40
+ renderImage: null,
41
+ renderHeader: null,
42
+ renderContent: null,
43
+ renderFooter: null,
44
+ renderActions: null,
45
+ layout: null,
46
+ props,
30
47
  };
31
- };
48
+ }
32
49
 
33
50
  BaseComponent.extends(Card);
51
+ BaseComponent.use(Card, HasEventEmitter);
34
52
 
35
53
  Card.defaultTemplate = null;
36
54
 
37
55
  /**
38
56
  * Registers the render template for Card.
39
57
  * @param {(description: {
40
- * [key: string]: unknown,
58
+ * title: NdChild|null,
59
+ * subtitle: NdChild|null,
60
+ * image: string|null,
61
+ * imagePosition: 'top'|'bottom'|'left'|'right',
62
+ * content: NdChild|null,
63
+ * variant: 'elevated'|'outlined'|'flat'|string|null,
64
+ * loading: Observable<boolean>|null,
65
+ * horizontal: boolean,
66
+ * hoverable: boolean,
67
+ * actions: { label: NdChild, callback: () => void }[],
68
+ * renderImage: ((desc: *, instance: Card) => NdChild)|null,
69
+ * renderHeader: ((desc: *, instance: Card) => NdChild)|null,
70
+ * renderContent: ((desc: *, instance: Card) => NdChild)|null,
71
+ * renderFooter: ((desc: *, instance: Card) => NdChild)|null,
72
+ * renderActions: ((desc: *, instance: Card) => NdChild)|null,
73
+ * layout: ((slots: { header: NdChild, content: NdChild, footer: NdChild, image: NdChild, actions: NdChild }, instance: Card) => NdChild)|null,
41
74
  * props: GlobalAttributes,
42
75
  * }, instance: Card) => NdChild} template
43
76
  */
44
- Card.use = function(template) {};
77
+ Card.use = function(template) {
78
+ Card.defaultTemplate = template;
79
+ };
45
80
 
46
81
  /**
47
82
  * @param {NdChild} title
48
83
  * @returns {this}
49
84
  */
50
85
  Card.prototype.title = function(title) {
86
+ this.$description.title = title;
51
87
  return this;
52
88
  };
53
89
 
54
90
  /**
55
- * @param {NdChild} title
91
+ * @param {NdChild} subtitle
56
92
  * @returns {this}
57
93
  */
58
- Card.prototype.subtitle = function(title) {
94
+ Card.prototype.subtitle = function(subtitle) {
95
+ this.$description.subtitle = subtitle;
59
96
  return this;
60
97
  };
61
98
 
@@ -65,6 +102,8 @@ Card.prototype.subtitle = function(title) {
65
102
  * @returns {this}
66
103
  */
67
104
  Card.prototype.image = function(src, position = 'top') {
105
+ this.$description.image = src;
106
+ this.$description.imagePosition = position;
68
107
  return this;
69
108
  };
70
109
 
@@ -73,6 +112,7 @@ Card.prototype.image = function(src, position = 'top') {
73
112
  * @returns {this}
74
113
  */
75
114
  Card.prototype.content = function(content) {
115
+ this.$description.content = content;
76
116
  return this;
77
117
  };
78
118
 
@@ -83,51 +123,55 @@ Card.prototype.content = function(content) {
83
123
  * @returns {this}
84
124
  */
85
125
  Card.prototype.variant = function(name) {
126
+ this.$description.variant = name;
86
127
  return this;
87
128
  };
88
129
 
89
130
  /**
90
131
  * @returns {this}
91
132
  */
92
- Card.prototype.outlined = function() {
93
- return this;
133
+ Card.prototype.elevated = function() {
134
+ return this.variant('elevated');
94
135
  };
95
136
 
96
137
  /**
97
138
  * @returns {this}
98
139
  */
99
- Card.prototype.elevated = function() {
100
- return this;
140
+ Card.prototype.outlined = function() {
141
+ return this.variant('outlined');
101
142
  };
102
143
 
103
144
  /**
104
145
  * @returns {this}
105
146
  */
106
147
  Card.prototype.flat = function() {
107
- return this;
148
+ return this.variant('flat');
108
149
  };
109
150
 
110
151
  // Behavior
152
+
111
153
  /**
112
154
  * @param {Function} handler
113
155
  * @returns {this}
114
156
  */
115
157
  Card.prototype.clickable = function(handler) {
116
- return this;
158
+ return this.onClick(handler);
117
159
  };
118
160
 
119
161
  /**
120
162
  * @returns {this}
121
163
  */
122
164
  Card.prototype.hoverable = function() {
165
+ this.$description.hoverable = true;
123
166
  return this;
124
167
  };
125
168
 
126
169
  /**
127
- * @param {boolean|Observable<boolean>} [isLoading]
170
+ * @param {boolean|Observable<boolean>} [isLoading=true]
128
171
  * @returns {this}
129
172
  */
130
173
  Card.prototype.loading = function(isLoading = true) {
174
+ this.$description.loading = BaseComponent.obs(isLoading);
131
175
  return this;
132
176
  };
133
177
 
@@ -137,46 +181,54 @@ Card.prototype.loading = function(isLoading = true) {
137
181
  * @returns {this}
138
182
  */
139
183
  Card.prototype.horizontal = function() {
184
+ this.$description.horizontal = true;
140
185
  return this;
141
186
  };
142
187
 
143
- // Events
188
+ // Actions
189
+
144
190
  /**
145
- * @param {Function} handler
191
+ * @param {NdChild} label
192
+ * @param {() => void} callback
146
193
  * @returns {this}
147
194
  */
148
- Card.prototype.onClick = function(handler) {
195
+ Card.prototype.action = function(label, callback) {
196
+ this.$description.actions.push({ label, callback });
149
197
  return this;
150
198
  };
151
199
 
152
200
  /**
153
- * @param {Function} handler
154
201
  * @returns {this}
155
202
  */
156
- Card.prototype.onHover = function(handler) {
203
+ Card.prototype.clearActions = function() {
204
+ this.$description.actions = [];
157
205
  return this;
158
206
  };
159
207
 
208
+ // Events
209
+
160
210
  /**
211
+ * @param {Function} handler
161
212
  * @returns {this}
162
213
  */
163
- Card.prototype.clearActions = function() {
164
- this.$description.actions = [];
214
+ Card.prototype.onClick = function(handler) {
215
+ this.on('click', handler);
165
216
  return this;
166
217
  };
167
218
 
168
219
  /**
169
- * @param {NdChild} label
170
- * @param {() => void} callback
220
+ * @param {Function} handler
171
221
  * @returns {this}
172
222
  */
173
- Card.prototype.action = function(label, callback) {
174
- this.$description.actions.push({ label, callback });
223
+ Card.prototype.onHover = function(handler) {
224
+ this.on('hover', handler);
175
225
  return this;
176
226
  };
177
227
 
228
+ // Custom renderers
229
+
178
230
  /**
179
- * @param {(desc: *, instance: *) => NdChild} renderFn
231
+ * @param {(desc: *, instance: Card) => NdChild} renderFn
180
232
  * @returns {this}
181
233
  */
182
234
  Card.prototype.renderImage = function(renderFn) {
@@ -185,7 +237,7 @@ Card.prototype.renderImage = function(renderFn) {
185
237
  };
186
238
 
187
239
  /**
188
- * @param {(desc: *, instance: *) => NdChild} renderFn
240
+ * @param {(desc: *, instance: Card) => NdChild} renderFn
189
241
  * @returns {this}
190
242
  */
191
243
  Card.prototype.renderHeader = function(renderFn) {
@@ -194,7 +246,7 @@ Card.prototype.renderHeader = function(renderFn) {
194
246
  };
195
247
 
196
248
  /**
197
- * @param {(desc: *, instance: *) => NdChild} renderFn
249
+ * @param {(desc: *, instance: Card) => NdChild} renderFn
198
250
  * @returns {this}
199
251
  */
200
252
  Card.prototype.renderContent = function(renderFn) {
@@ -203,7 +255,7 @@ Card.prototype.renderContent = function(renderFn) {
203
255
  };
204
256
 
205
257
  /**
206
- * @param {(desc: *, instance: *) => NdChild} renderFn
258
+ * @param {(desc: *, instance: Card) => NdChild} renderFn
207
259
  * @returns {this}
208
260
  */
209
261
  Card.prototype.renderFooter = function(renderFn) {
@@ -212,17 +264,19 @@ Card.prototype.renderFooter = function(renderFn) {
212
264
  };
213
265
 
214
266
  /**
215
- * @param {(desc: *, instance: *) => NdChild} layoutFn
267
+ * @param {(desc: *, instance: Card) => NdChild} renderFn
216
268
  * @returns {this}
217
269
  */
218
- Card.prototype.layout = function(layoutFn) {
219
- this.$description.layout = layoutFn;
270
+ Card.prototype.renderActions = function(renderFn) {
271
+ this.$description.renderActions = renderFn;
220
272
  return this;
221
273
  };
222
274
 
223
275
  /**
224
- * @returns {HTMLElement|DocumentFragment}
276
+ * @param {(slots: { header: NdChild, content: NdChild, footer: NdChild, image: NdChild, actions: NdChild }, instance: Card) => NdChild} layoutFn
277
+ * @returns {this}
225
278
  */
226
- Card.prototype.toNdElement = function() {
279
+ Card.prototype.layout = function(layoutFn) {
280
+ this.$description.layout = layoutFn;
227
281
  return this;
228
- };
282
+ };
@@ -1,5 +1,5 @@
1
1
  import Card from './Card';
2
2
 
3
- export default {
3
+ export {
4
4
  Card,
5
5
  };
@@ -0,0 +1,171 @@
1
+ import ListDivider from './ListDivider';
2
+ import List from './List';
3
+ import BaseComponent from '../BaseComponent';
4
+
5
+ const EMPTY_OPTIONS = {};
6
+
7
+ /**
8
+ * Trait that adds item/group/divider management to List and ListGroup.
9
+ * Mirrors the HasMenuItem pattern.
10
+ *
11
+ * @constructor
12
+ */
13
+ export default function HasListItem() {}
14
+
15
+ HasListItem.components = {
16
+ ListItem: null,
17
+ ListGroup: null,
18
+ };
19
+
20
+
21
+ /**
22
+ * @param {ObservableArray<*>|*[]} list
23
+ * @returns {this}
24
+ */
25
+ HasListItem.prototype.selectInto = function(list) {
26
+ this.$description.selectedValues = list;
27
+ return this;
28
+ };
29
+
30
+ /**
31
+ * @param {boolean|Observable<boolean>} [selectable=true]
32
+ * @returns {this}
33
+ */
34
+ HasListItem.prototype.selectable = function(selectable = true) {
35
+ this.$description.selectable = BaseComponent.obs(selectable);
36
+ return this;
37
+ };
38
+
39
+ /**
40
+ * Select items on click. Mutually exclusive with selectByCheckbox.
41
+ * @returns {this}
42
+ */
43
+ HasListItem.prototype.selectByClick = function() {
44
+ this.$description.selectByClick.set(true);
45
+ this.$description.selectByCheckbox.set(false);
46
+ return this;
47
+ };
48
+
49
+ /**
50
+ * Select items via a checkbox. Mutually exclusive with selectByClick.
51
+ * @returns {this}
52
+ */
53
+ HasListItem.prototype.selectByCheckbox = function() {
54
+ this.$description.selectByClick.set(false);
55
+ this.$description.selectByCheckbox.set(true);
56
+ return this;
57
+ };
58
+
59
+ /**
60
+ * @param {boolean|Observable<boolean>} [multi=true]
61
+ * @returns {this}
62
+ */
63
+ HasListItem.prototype.multiSelect = function(multi = true) {
64
+ this.$description.multiSelect = BaseComponent.obs(multi);
65
+ this.$description.selectable.set(true);
66
+ return this;
67
+ };
68
+
69
+ /**
70
+ * @param {boolean} loopOnKeyboard
71
+ * @returns {this}
72
+ */
73
+ HasListItem.prototype.loopOnKeyboard = function(loopOnKeyboard) {
74
+ this.$description.loopOnKeyboard = loopOnKeyboard;
75
+ return this;
76
+ };
77
+
78
+ /**
79
+ * @param {ListItem|ListGroup|ListDivider} item
80
+ * @returns {this}
81
+ */
82
+ HasListItem.prototype.add = function(item) {
83
+ if (item === this) {
84
+ return this;
85
+ }
86
+ item.$parent = this;
87
+ this.$description.items.push(item);
88
+ return this;
89
+ };
90
+
91
+ /**
92
+ * @param {NdChild} label
93
+ * @param {NdChild|((item: ListItem) => void)} [iconOrBuilder]
94
+ * @param {((item: ListItem) => void)} [builder]
95
+ * @returns {this}
96
+ */
97
+ HasListItem.prototype.item = function(label, iconOrBuilder, builder) {
98
+ const ListItem = HasListItem.components.ListItem;
99
+ const item = new ListItem();
100
+ item.$parent = this;
101
+
102
+ item.label(label);
103
+
104
+ if (typeof iconOrBuilder === 'function') {
105
+ iconOrBuilder(item);
106
+ } else if (iconOrBuilder) {
107
+ item.icon(iconOrBuilder);
108
+ if (typeof builder === 'function') {
109
+ builder(item);
110
+ }
111
+ }
112
+
113
+ this.$description.items.push(item);
114
+ return this;
115
+ };
116
+
117
+ /**
118
+ * @param {NdChild} label
119
+ * @param {NdChild|((group: ListGroup) => void)} [iconOrBuilder]
120
+ * @param {((group: ListGroup) => void)} [builder]
121
+ * @returns {this}
122
+ */
123
+ HasListItem.prototype.group = function(label, iconOrBuilder, builder) {
124
+ const ListGroup = HasListItem.components.ListGroup;
125
+ const group = new ListGroup(label);
126
+ group.$parent = this;
127
+
128
+ if (typeof iconOrBuilder === 'function') {
129
+ iconOrBuilder(group);
130
+ } else if (iconOrBuilder) {
131
+ group.icon(iconOrBuilder);
132
+ if (typeof builder === 'function') {
133
+ builder(group);
134
+ }
135
+ }
136
+
137
+ this.$description.items.push(group);
138
+ return this;
139
+ };
140
+
141
+ /**
142
+ * @returns {this}
143
+ */
144
+ HasListItem.prototype.divider = function() {
145
+ const divider = new ListDivider();
146
+ divider.$parent = this;
147
+ this.$description.items.push(divider);
148
+ return this;
149
+ };
150
+
151
+
152
+ /**
153
+ * Populate items from a data source using a builder function.
154
+ * The builder receives each data item and must return a ListItem or ListGroup.
155
+ *
156
+ * @param {ObservableArray<*>|*[]} source
157
+ * @param {(item: *) => ListItem|ListGroup} builder
158
+ * @returns {this}
159
+ */
160
+ HasListItem.prototype.from = function(source, builder) {
161
+ this.$description.items = source;
162
+ this.$description.itemBuilder = (...args) => {
163
+ if(args[0].__$ListInstance) {
164
+ return args[0];
165
+ }
166
+ const item = builder(...args);
167
+ item.$parent = this;
168
+ return item;
169
+ };
170
+ return this;
171
+ };
@@ -1,12 +1,12 @@
1
-
2
1
  import BaseComponent from '../BaseComponent';
3
2
  import HasEventEmitter from '../../core/utils/HasEventEmitter';
4
3
  import HasItems from '../$traits/has-items/HasItems';
4
+ import { $ } from '../../core/data/Observable';
5
+ import HasListItem from './HasListItem';
5
6
 
6
7
  /**
7
8
  * Flexible list container supporting single/multi selection, checkbox or click-to-select modes, dividers, and inset styling.
8
9
  *
9
- *
10
10
  * @example
11
11
  * const list = new List()
12
12
  * .selectable(true)
@@ -20,27 +20,26 @@ import HasItems from '../$traits/has-items/HasItems';
20
20
  * });
21
21
  *
22
22
  * @constructor
23
- * @param {GlobalAttributes} [config]
23
+ * @param {GlobalAttributes} [props]
24
24
  */
25
- export default function List(config = {}) {
26
- if(!(this instanceof List)) {
27
- return new List(config);
25
+ export default function List(props = {}) {
26
+ if (!(this instanceof List)) {
27
+ return new List(props);
28
28
  }
29
29
 
30
30
  this.$description = {
31
- selectable: false,
32
- multiSelect: false,
33
- selectedValues: null,
34
- inset: false,
35
- divider: false,
36
- data: null,
37
- render: null,
38
- selectByCheckbox: false,
39
- selectByClick: false,
40
- loopOnKeyboard: true,
41
- ...config,
31
+ selectable: $(false),
32
+ multiSelect: $(false),
33
+ selectedValues: $.array(),
34
+ inset: $(0),
35
+ divider: false,
36
+ items: $.array(),
37
+ render: null,
38
+ selectByCheckbox: $(false),
39
+ selectByClick: $(false),
40
+ loopOnKeyboard: $(false),
41
+ props,
42
42
  };
43
-
44
43
  }
45
44
 
46
45
  List.defaultTemplate = null;
@@ -48,71 +47,30 @@ List.defaultTemplate = null;
48
47
  /**
49
48
  * Registers the render template for List.
50
49
  * @param {(description: {
51
- * selectable: boolean,
52
- * multiSelect: boolean,
53
- * selectedValues: Observable<*[]>|null,
54
- * inset: boolean,
55
- * divider: boolean,
56
- * data: *|null,
57
- * render: ((desc: *, instance: List) => NdChild)|null,
58
- * selectByCheckbox: boolean,
59
- * selectByClick: boolean,
60
- * loopOnKeyboard: boolean,
61
- * props: GlobalAttributes,
50
+ * selectable: ObservableItem<boolean>,
51
+ * multiSelect: ObservableItem<boolean>,
52
+ * selectedValues: ObservableArray<*>,
53
+ * inset: ObservableItem<number>,
54
+ * divider: boolean,
55
+ * data: *|null,
56
+ * render: ((desc: *, instance: List) => NdChild)|null,
57
+ * selectByCheckbox: ObservableItem<boolean>,
58
+ * selectByClick: ObservableItem<boolean>,
59
+ * loopOnKeyboard: ObservableItem<boolean>,
60
+ * items: ObservableArray<*>,
61
+ * props: GlobalAttributes,
62
62
  * }, instance: List) => NdChild} template
63
63
  */
64
64
  List.use = function(template) {
65
- List.defaultTemplate = template.list;
65
+ List.defaultTemplate = template;
66
66
  };
67
67
 
68
68
  BaseComponent.extends(List);
69
- BaseComponent.use(List, HasItems, HasEventEmitter);
70
-
71
- List.defaultTemplate = null;
72
-
73
- List.use = function(template) {
74
- List.defaultTemplate = template.list;
75
- };
76
-
77
- /**
78
- * @param {*} [selectable]
79
- * @returns {this}
80
- */
81
- List.prototype.selectable = function(selectable = true) {
82
- this.$description.selectable = selectable;
83
- return this;
84
- };
85
-
86
- /**
87
- * @returns {this}
88
- */
89
- List.prototype.selectByClick = function() {
90
- this.$description.selectByClick = true;
91
- this.$description.selectByCheckbox = false;
92
- return this;
93
- };
94
-
95
- /**
96
- * @returns {this}
97
- */
98
- List.prototype.selectByCheckbox = function() {
99
- this.$description.selectByClick = false;
100
- this.$description.selectByCheckbox = true;
101
- return this;
102
- };
69
+ BaseComponent.use(List, HasItems, HasEventEmitter, HasListItem);
103
70
 
104
- /**
105
- * @param {*} [multi]
106
- * @returns {this}
107
- */
108
- List.prototype.multiSelect = function(multi = true) {
109
- this.$description.multiSelect = multi;
110
- this.$description.selectable = true;
111
- return this;
112
- };
113
71
 
114
72
  /**
115
- * @param {Observable<*[]>} observable
73
+ * @param {ObservableArray<*>|Observable<*[]>} observable
116
74
  * @returns {this}
117
75
  */
118
76
  List.prototype.selectedValuesModel = function(observable) {
@@ -121,41 +79,17 @@ List.prototype.selectedValuesModel = function(observable) {
121
79
  };
122
80
 
123
81
  /**
124
- * @param {number} [inset]
82
+ * Inset padding in px applied to all items.
83
+ * @param {number} [inset=0]
125
84
  * @returns {this}
126
85
  */
127
- List.prototype.inset = function(inset = true) {
128
- this.$description.inset = inset;
86
+ List.prototype.inset = function(inset = 0) {
87
+ this.$description.inset.set(inset);
129
88
  return this;
130
89
  };
131
90
 
132
91
  /**
133
- * @returns {this}
134
- */
135
- List.prototype.next = function() {
136
- // TODO:
137
- return this;
138
- };
139
-
140
- /**
141
- * @returns {this}
142
- */
143
- List.prototype.preview = function() {
144
- // TODO:
145
- return this;
146
- };
147
-
148
- /**
149
- * @param {*} loopOnKeyboard
150
- * @returns {this}
151
- */
152
- List.prototype.loopOnKeyboard = function(loopOnKeyboard) {
153
- this.$description.loopOnKeyboard = loopOnKeyboard;
154
- return this;
155
- };
156
-
157
- /**
158
- * @param {*} [divider]
92
+ * @param {boolean} [divider=true]
159
93
  * @returns {this}
160
94
  */
161
95
  List.prototype.withDivider = function(divider = true) {
@@ -168,12 +102,12 @@ List.prototype.withDivider = function(divider = true) {
168
102
  * @returns {this}
169
103
  */
170
104
  List.prototype.data = function(data) {
171
- this.$description.data = data;
105
+ this.$description.items = data;
172
106
  return this;
173
107
  };
174
108
 
175
109
  /**
176
- * @param {(item: ListItem, event: MouseEvent) => void} handler
110
+ * @param {(item: *, event: MouseEvent) => void} handler
177
111
  * @returns {this}
178
112
  */
179
113
  List.prototype.onItemClick = function(handler) {
@@ -182,10 +116,10 @@ List.prototype.onItemClick = function(handler) {
182
116
  };
183
117
 
184
118
  /**
185
- * @param {(item: ListItem) => void} handler
119
+ * @param {(item: *) => void} handler
186
120
  * @returns {this}
187
121
  */
188
122
  List.prototype.onItemSelect = function(handler) {
189
123
  this.on('itemSelect', handler);
190
124
  return this;
191
- };
125
+ };