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
@@ -0,0 +1,39 @@
1
+ import BaseComponent from '../BaseComponent';
2
+
3
+ /**
4
+ * Visual separator between items in a List.
5
+ *
6
+ * @example
7
+ * List()
8
+ * .item('Dashboard')
9
+ * .divider()
10
+ * .item('Settings')
11
+ *
12
+ * ListDivider.use((description, instance) => {
13
+ * return Li({ class: 'list-divider', role: 'separator' });
14
+ * });
15
+ *
16
+ * @constructor
17
+ * @param {GlobalAttributes} [props={}]
18
+ */
19
+ export default function ListDivider(props = {}) {
20
+ if (!(this instanceof ListDivider)) {
21
+ return new ListDivider(props);
22
+ }
23
+
24
+ BaseComponent.call(this, props);
25
+
26
+ this.$description = { props };
27
+ }
28
+
29
+ BaseComponent.extends(ListDivider);
30
+
31
+ ListDivider.defaultTemplate = null;
32
+
33
+ /**
34
+ * Registers the render template for ListDivider.
35
+ * @param {(description: { props: GlobalAttributes }, instance: ListDivider) => NdChild} template
36
+ */
37
+ ListDivider.use = function(template) {
38
+ ListDivider.defaultTemplate = template;
39
+ };
@@ -1,54 +1,79 @@
1
1
  import BaseComponent from '../BaseComponent';
2
+ import HasEventEmitter from '../../core/utils/HasEventEmitter';
2
3
  import HasItems from '../$traits/has-items/HasItems';
4
+ import HasListItem from './HasListItem';
5
+ import { $ } from '../../core/data/Observable';
3
6
 
4
7
  /**
5
- * Groups ListItem instances under a header/footer inside a List.
6
- *
8
+ * A collapsible group of ListItems inside a List. Can hold items, dividers, and nested groups.
7
9
  *
8
10
  * @example
9
- * const group = new ListGroup(Span('Favourites'))
10
- * .inset(true)
11
- * .renderHeader((desc, instance) => H3(desc.header));
11
+ * ListGroup('Workspace')
12
+ * .icon(FolderIcon())
13
+ * .collapsable()
14
+ * .item('Dashboard', DashboardIcon())
15
+ * .item('Analytics', ChartIcon());
16
+ *
17
+ * // From data
18
+ * ListGroup('Reports')
19
+ * .from(reports, (report) =>
20
+ * ListItem().label(report.name).value(report.id)
21
+ * );
22
+ *
23
+ * ListGroup.use((description, instance) => {
24
+ * return Div({ class: 'list-group' });
25
+ * });
12
26
  *
13
27
  * @constructor
14
- * @param {NdChild} [label]
15
- * @param {GlobalAttributes} [config={}]
28
+ * @param {NdChild} label
29
+ * @param {GlobalAttributes} [props={}]
16
30
  */
17
- export default function ListGroup(label, config = {}) {
18
- if(!(this instanceof ListGroup)) {
19
- return new ListGroup(label, config);
31
+ export default function ListGroup(label, props = {}) {
32
+ if (!(this instanceof ListGroup)) {
33
+ return new ListGroup(label, props);
20
34
  }
21
35
 
36
+ BaseComponent.call(this, props);
37
+
22
38
  this.$description = {
23
- header: label || null,
24
- footer: null,
25
- items: [],
26
- inset: false,
27
- data: null,
28
- renderHeader: null,
29
- renderFooter: null,
30
- render: null,
31
- ...config,
39
+ selectable: $(false),
40
+ multiSelect: $(false),
41
+ selectedValues: $.array(),
42
+ label: label,
43
+ icon: null,
44
+ items: $.array(),
45
+ render: null,
46
+ collapsable: false,
47
+ collapsed: null,
48
+ visibility: $(true),
49
+ selectByCheckbox: $(false),
50
+ selectByClick: $(false),
51
+ loopOnKeyboard: $(false),
52
+ props,
32
53
  };
33
54
  }
34
55
 
35
56
  BaseComponent.extends(ListGroup);
36
- BaseComponent.use(ListGroup, HasItems);
57
+ BaseComponent.use(ListGroup, HasItems, HasEventEmitter, HasListItem);
58
+
59
+ HasListItem.components.ListGroup = ListGroup;
37
60
 
38
61
  ListGroup.defaultTemplate = null;
62
+ ListGroup.prototype.__$ListInstance = true;
39
63
 
40
64
  /**
41
65
  * Registers the render template for ListGroup.
42
66
  * @param {(description: {
43
- * header: NdChild|null,
44
- * footer: NdChild|null,
45
- * items: *[],
46
- * inset: boolean,
47
- * data: *|null,
48
- * renderHeader: ((desc: *, instance: ListGroup) => NdChild)|null,
49
- * renderFooter: ((desc: *, instance: ListGroup) => NdChild)|null,
50
- * render: ((desc: *, instance: ListGroup) => NdChild)|null,
51
- * props: GlobalAttributes,
67
+ * label: NdChild,
68
+ * icon: NdChild|null,
69
+ * items: ObservableArray<ListItem|ListGroup|ListDivider>,
70
+ * itemBuilder: (item: *) => ListItem|ListGroup|ListDivider,
71
+ * data: *|null,
72
+ * render: ((desc: *, instance: ListGroup) => NdChild)|null,
73
+ * collapsable: boolean,
74
+ * collapsed: ObservableItem<boolean>|null,
75
+ * visibility: ObservableItem<boolean>,
76
+ * props: GlobalAttributes,
52
77
  * }, instance: ListGroup) => NdChild} template
53
78
  */
54
79
  ListGroup.use = function(template) {
@@ -56,37 +81,47 @@ ListGroup.use = function(template) {
56
81
  };
57
82
 
58
83
  /**
59
- * @param {NdChild} header
84
+ * @param {NdChild} icon
60
85
  * @returns {this}
61
86
  */
62
- ListGroup.prototype.header = function(header) {
63
- this.$description.header = header;
87
+ ListGroup.prototype.icon = function(icon) {
88
+ this.$description.icon = icon;
64
89
  return this;
65
90
  };
66
91
 
67
92
  /**
68
- * @param {NdChild} title
93
+ * @param {boolean} [mode=true]
94
+ * @param {NdChild} [openedIcon]
95
+ * @param {NdChild} [closedIcon]
69
96
  * @returns {this}
70
97
  */
71
- ListGroup.prototype.title = function(title) {
72
- return this.header(title);
98
+ ListGroup.prototype.collapsable = function(mode = true, openedIcon, closedIcon) {
99
+ this.$description.collapsable = mode;
100
+ this.$description.collapsed = this.$description.collapsed || $(false);
101
+ this.$description.collapsableOpenedIcon = openedIcon || null;
102
+ this.$description.collapsableClosedIcon = closedIcon || null;
103
+ return this;
73
104
  };
74
105
 
75
106
  /**
76
- * @param {NdChild} footer
107
+ * @param {boolean} [mode=true]
77
108
  * @returns {this}
78
109
  */
79
- ListGroup.prototype.footer = function(footer) {
80
- this.$description.footer = footer;
110
+ ListGroup.prototype.collapsed = function(mode = true) {
111
+ if (!this.$description.collapsed) {
112
+ this.$description.collapsed = $(mode);
113
+ } else {
114
+ this.$description.collapsed.set(mode);
115
+ }
81
116
  return this;
82
117
  };
83
118
 
84
119
  /**
85
- * @param {number} [inset]
120
+ * @param {boolean|Observable<boolean>} mode
86
121
  * @returns {this}
87
122
  */
88
- ListGroup.prototype.inset = function(inset = true) {
89
- this.$description.inset = inset;
123
+ ListGroup.prototype.visibility = function(mode) {
124
+ this.$description.visibility = BaseComponent.obs(mode);
90
125
  return this;
91
126
  };
92
127
 
@@ -98,21 +133,3 @@ ListGroup.prototype.data = function(data) {
98
133
  this.$description.data = data;
99
134
  return this;
100
135
  };
101
-
102
- /**
103
- * @param {(desc: *, instance: *) => NdChild} renderFn
104
- * @returns {this}
105
- */
106
- ListGroup.prototype.renderHeader = function(renderFn) {
107
- this.$description.renderHeader = renderFn;
108
- return this;
109
- };
110
-
111
- /**
112
- * @param {(desc: *, instance: *) => NdChild} renderFn
113
- * @returns {this}
114
- */
115
- ListGroup.prototype.renderFooter = function(renderFn) {
116
- this.$description.renderFooter = renderFn;
117
- return this;
118
- };
@@ -1,64 +1,81 @@
1
1
  import BaseComponent from '../BaseComponent';
2
- import Validator from '../../core/utils/validator';
3
- import {$ } from '../../core/data/Observable';
2
+ import HasEventEmitter from '../../core/utils/HasEventEmitter';
3
+ import HasListItem from './HasListItem';
4
4
 
5
5
  /**
6
- * A single row inside a List. Supports leading/trailing slots, icon, selection, divider, and disabled state.
7
- *
6
+ * A single item in a List. Supports icon, label, subtitle, trailing slot,
7
+ * disabled/selected states, swipe actions (mobile), and custom render.
8
8
  *
9
9
  * @example
10
- * const item = new ListItem(Span('Item label'))
11
- * .icon(StarIcon())
12
- * .trailing(Span('chevron >'))
13
- * .selectable()
14
- * .divider(true);
10
+ * ListItem()
11
+ * .label('Dashboard')
12
+ * .icon(DashboardIcon())
13
+ * .subtitle('View your metrics')
14
+ * .trailing(Badge('New').primary())
15
+ * .value('dashboard')
16
+ * .selected(isActive)
17
+ * .swipeLeading([Button('Archive').success()])
18
+ * .swipeTrailing([Button('Delete').danger()])
19
+ * .onClick(() => navigate('/dashboard'));
15
20
  *
16
21
  * ListItem.use((description, instance) => {
17
- * return Li(description.leading, description.content, description.trailing);
22
+ * return Li({ class: 'list-item' }, description.label);
18
23
  * });
19
24
  *
20
25
  * @constructor
21
- * @param {NdChild} [content]
22
- * @param {GlobalAttributes} [config={}]
26
+ * @param {GlobalAttributes} [props={}]
23
27
  */
24
- export default function ListItem(content, config = {}) {
25
- if(!(this instanceof ListItem)) {
26
- return new ListItem(content, config);
28
+ export default function ListItem(props = {}) {
29
+ if (!(this instanceof ListItem)) {
30
+ return new ListItem(props);
27
31
  }
28
32
 
33
+ BaseComponent.call(this, props);
34
+
29
35
  this.$description = {
30
- content: content || null,
31
- icon: null,
32
- trailing: null,
33
- leading: null,
34
- disabled: false,
35
- selectable: false,
36
- selected: false,
37
- divider: false,
38
- data: null,
39
- render: null,
40
- ...config,
36
+ label: null,
37
+ subtitle: null,
38
+ icon: null,
39
+ trailing: null,
40
+ value: null,
41
+ data: null,
42
+ key: null,
43
+ disabled: null,
44
+ selected: null,
45
+ visibility: null,
46
+ isSelectedIcon: null,
47
+ swipeLeading: [],
48
+ swipeTrailing: [],
49
+ render: null,
50
+ props,
41
51
  };
42
52
  }
43
53
 
44
54
  BaseComponent.extends(ListItem);
55
+ BaseComponent.use(ListItem, HasEventEmitter);
56
+
57
+ HasListItem.components.ListItem = ListItem;
45
58
 
46
59
  ListItem.defaultTemplate = null;
47
60
 
48
61
  /**
49
62
  * Registers the render template for ListItem.
50
63
  * @param {(description: {
51
- * content: NdChild|null,
52
- * icon: NdChild|null,
53
- * trailing: NdChild|null,
54
- * leading: NdChild|null,
55
- * disabled: boolean,
56
- * selectable: boolean,
57
- * selected: boolean|Observable<boolean>,
58
- * divider: boolean,
59
- * data: *|null,
60
- * render: ((desc: *, instance: ListItem) => NdChild)|null,
61
- * props: GlobalAttributes,
64
+ * label: NdChild|null,
65
+ * subtitle: NdChild|null,
66
+ * icon: NdChild|null,
67
+ * trailing: NdChild|null,
68
+ * value: *,
69
+ * data: *|null,
70
+ * key: string|null,
71
+ * disabled: Observable<boolean>|null,
72
+ * selected: Observable<boolean>|null,
73
+ * visibility: Observable<boolean>|null,
74
+ * isSelectedIcon: NdChild|null,
75
+ * swipeLeading: NdChild[],
76
+ * swipeTrailing: NdChild[],
77
+ * render: ((desc: *, instance: ListItem) => NdChild)|null,
78
+ * props: GlobalAttributes,
62
79
  * }, instance: ListItem) => NdChild} template
63
80
  */
64
81
  ListItem.use = function(template) {
@@ -66,20 +83,20 @@ ListItem.use = function(template) {
66
83
  };
67
84
 
68
85
  /**
69
- * @param {NdChild} content
86
+ * @param {NdChild} label
70
87
  * @returns {this}
71
88
  */
72
- ListItem.prototype.content = function(content) {
73
- this.$description.content = content;
89
+ ListItem.prototype.label = function(label) {
90
+ this.$description.label = label;
74
91
  return this;
75
92
  };
76
93
 
77
94
  /**
78
- * @param {NdChild} label
95
+ * @param {NdChild} subtitle
79
96
  * @returns {this}
80
97
  */
81
- ListItem.prototype.label = function(label) {
82
- this.$description.content = label;
98
+ ListItem.prototype.subtitle = function(subtitle) {
99
+ this.$description.subtitle = subtitle;
83
100
  return this;
84
101
  };
85
102
 
@@ -93,72 +110,103 @@ ListItem.prototype.icon = function(icon) {
93
110
  };
94
111
 
95
112
  /**
96
- * @param {NdChild} leading
113
+ * @param {NdChild} trailing
97
114
  * @returns {this}
98
115
  */
99
- ListItem.prototype.leading = function(leading) {
100
- this.$description.leading = leading;
116
+ ListItem.prototype.trailing = function(trailing) {
117
+ this.$description.trailing = trailing;
101
118
  return this;
102
119
  };
103
120
 
104
121
  /**
105
- * @param {NdChild} trailing
122
+ * @param {*} value
106
123
  * @returns {this}
107
124
  */
108
- ListItem.prototype.trailing = function(trailing) {
109
- this.$description.trailing = trailing;
125
+ ListItem.prototype.value = function(value) {
126
+ this.$description.value = value;
110
127
  return this;
111
128
  };
112
129
 
130
+ /**
131
+ * @param {*} data
132
+ * @returns {this}
133
+ */
134
+ ListItem.prototype.data = function(data) {
135
+ this.$description.data = data;
136
+ return this;
137
+ };
138
+
139
+ /**
140
+ * @param {string} key
141
+ * @returns {this}
142
+ */
143
+ ListItem.prototype.key = function(key) {
144
+ this.$description.key = key;
145
+ return this;
146
+ };
113
147
 
114
148
  /**
115
149
  * @param {boolean|Observable<boolean>} [disabled=true]
116
150
  * @returns {this}
117
151
  */
118
152
  ListItem.prototype.disabled = function(disabled = true) {
119
- this.$description.disabled = disabled;
153
+ this.$description.disabled = BaseComponent.obs(disabled);
120
154
  return this;
121
155
  };
122
156
 
123
157
  /**
158
+ * @param {boolean|Observable<boolean>} [selected=true]
124
159
  * @returns {this}
125
160
  */
126
- ListItem.prototype.selectable = function() {
127
- this.$description.selectable = true;
128
- if(Validator.isObservable(this.$description.selected)) {
129
- return this;
130
- }
131
- this.$description.selected = $(false);
161
+ ListItem.prototype.selected = function(selected = true) {
162
+ this.$description.selected = BaseComponent.obs(selected);
132
163
  return this;
133
164
  };
134
165
 
135
166
  /**
136
- * @param {boolean|Observable<boolean>} [selected]
167
+ * @param {boolean|Observable<boolean>} mode
137
168
  * @returns {this}
138
169
  */
139
- ListItem.prototype.selected = function(selected = true) {
140
- if(Validator.isObservable(this.$description.selected)) {
141
- this.$description.selected.set(selected);
142
- return this;
143
- }
144
- this.$description.selected = selected;
170
+ ListItem.prototype.visibility = function(mode) {
171
+ this.$description.visibility = BaseComponent.obs(mode);
145
172
  return this;
146
173
  };
147
174
 
148
175
  /**
149
- * @param {NdChild} [show]
176
+ * Icon displayed when the item is selected (selectByClick mode).
177
+ * @param {NdChild} icon
150
178
  * @returns {this}
151
179
  */
152
- ListItem.prototype.divider = function(show = true) {
153
- this.$description.divider = show;
180
+ ListItem.prototype.isSelectedIcon = function(icon) {
181
+ this.$description.isSelectedIcon = icon;
154
182
  return this;
155
183
  };
156
184
 
157
185
  /**
158
- * @param {*} data
186
+ * Swipe actions revealed on the leading (left) side — mobile swipe gesture.
187
+ * @param {NdChild[]} actions
159
188
  * @returns {this}
160
189
  */
161
- ListItem.prototype.data = function(data) {
162
- this.$description.data = data;
190
+ ListItem.prototype.swipeLeading = function(actions) {
191
+ this.$description.swipeLeading = Array.isArray(actions) ? actions : [actions];
192
+ return this;
193
+ };
194
+
195
+ /**
196
+ * Swipe actions revealed on the trailing (right) side — mobile swipe gesture.
197
+ * @param {NdChild[]} actions
198
+ * @returns {this}
199
+ */
200
+ ListItem.prototype.swipeTrailing = function(actions) {
201
+ this.$description.swipeTrailing = Array.isArray(actions) ? actions : [actions];
202
+ return this;
203
+ };
204
+
205
+ /**
206
+ * @param {Function} handler
207
+ * @returns {this}
208
+ */
209
+ ListItem.prototype.onClick = function(handler) {
210
+ this.on('click', handler);
163
211
  return this;
164
212
  };
@@ -1,10 +1,12 @@
1
1
  import List from './List';
2
2
  import ListItem from './ListItem';
3
3
  import ListGroup from './ListGroup';
4
+ import ListDivider from './ListDivider';
4
5
 
5
6
 
6
- export default {
7
+ export {
7
8
  List,
8
9
  ListItem,
9
10
  ListGroup,
11
+ ListDivider,
10
12
  };
@@ -1,42 +1,53 @@
1
- import type { ValidChild } from '../../../../types/elements';
2
- import type { ObservableItem } from '../../../../types/observable';
3
- import type { BaseComponent } from '../../BaseComponent';
4
- import type { GlobalAttributes } from '../../../../types/globals';
1
+ import { GlobalAttributes, Observable } from '../../../../types/globals';
2
+ import { ValidChild } from '../../../../types/elements';
3
+ import { ObservableArray } from '../../../../types/observable';
4
+
5
+ export interface ListItemDescription {
6
+ label: ValidChild | null;
7
+ subtitle: ValidChild | null;
8
+ icon: ValidChild | null;
9
+ trailing: ValidChild | null;
10
+ value: unknown;
11
+ data: unknown | null;
12
+ key: string | null;
13
+ disabled: Observable<boolean> | null;
14
+ selected: Observable<boolean> | null;
15
+ visibility: Observable<boolean> | null;
16
+ isSelectedIcon: ValidChild | null;
17
+ swipeLeading: ValidChild[];
18
+ swipeTrailing: ValidChild[];
19
+ render: ((desc: ListItemDescription, instance: ListItem) => ValidChild) | null;
20
+ props: GlobalAttributes;
21
+ }
22
+
23
+ export declare class ListItem {
24
+ $description: ListItemDescription;
25
+ $parent: unknown;
26
+
27
+ constructor(props?: GlobalAttributes);
5
28
 
6
- export type ListItemDescription = {
7
- content: ValidChild | null;
8
- icon: ValidChild | null;
9
- trailing: ValidChild | null;
10
- leading: ValidChild | null;
11
- disabled: boolean;
12
- selectable: boolean;
13
- selected: boolean | ObservableItem<boolean>;
14
- divider: boolean;
15
- data: unknown | null;
16
- render: ((desc: ListItemDescription, instance: ListItemInterface) => ValidChild) | null;
17
- props: GlobalAttributes;
18
- };
29
+ static use(template: (description: ListItemDescription, instance: ListItem) => ValidChild): void;
30
+ static defaultTemplate: ((description: ListItemDescription, instance: ListItem) => ValidChild) | null;
19
31
 
20
- export interface ListItemInterface extends BaseComponent {
21
- content(content: ValidChild): this;
22
32
  label(label: ValidChild): this;
33
+ subtitle(subtitle: ValidChild): this;
23
34
  icon(icon: ValidChild): this;
24
- leading(leading: ValidChild): this;
25
35
  trailing(trailing: ValidChild): this;
26
- disabled(disabled?: boolean): this;
27
- selectable(): this;
28
- selected(selected?: boolean | ObservableItem<boolean>): this;
29
- divider(show?: boolean): this;
36
+ value(value: unknown): this;
30
37
  data(data: unknown): this;
31
- render(renderFn: (desc: ListItemDescription, instance: ListItemInterface) => ValidChild): this;
38
+ key(key: string): this;
39
+ disabled(disabled?: boolean | Observable<boolean>): this;
40
+ selected(selected?: boolean | Observable<boolean>): this;
41
+ visibility(mode: boolean | Observable<boolean>): this;
42
+ isSelectedIcon(icon: ValidChild): this;
43
+ swipeLeading(actions: ValidChild | ValidChild[]): this;
44
+ swipeTrailing(actions: ValidChild | ValidChild[]): this;
45
+ onClick(handler: (item: ListItem, event: MouseEvent) => void): this;
46
+
47
+ // HasEventEmitter
48
+ on(event: string, handler: (...args: unknown[]) => void): this;
49
+ emit(event: string, ...args: unknown[]): void;
50
+ hasListeners(event: string): boolean;
32
51
  }
33
52
 
34
-
35
- export declare function ListItem(content?: ValidChild, config?: Record<string, unknown>): ListItemInterface;
36
- export declare namespace ListItem {
37
-
38
-
39
- function use(template: (description: ListItemDescription, instance: ListItemInterface) => ValidChild): void;
40
-
41
-
42
- }
53
+ export declare function ListItem(props?: GlobalAttributes): ListItem;
@@ -1,6 +1,6 @@
1
1
  import BaseComponent from '../BaseComponent';
2
2
 
3
- export function Spacer(props = {}) {
3
+ export default function Spacer(props = {}) {
4
4
  if (!(this instanceof Spacer)) {
5
5
  return new Spacer(props);
6
6
  }
@@ -126,6 +126,11 @@ ObservableResource.prototype.$runWithoutAbortController = function(isRefetch = f
126
126
  });
127
127
  };
128
128
 
129
+ ObservableResource.prototype.into = function($observable) {
130
+ this.data = $observable;
131
+ return this;
132
+ };
133
+
129
134
  ObservableResource.prototype.$run = function(isRefetch = false) {
130
135
  const needsSignal = this.$fn.length > this.$dependencies.length;
131
136
  if(needsSignal) {
@@ -119,6 +119,8 @@ ObservableItem.prototype.select = ObservableItem.prototype.check;
119
119
  * // Reacts to locale changes automatically
120
120
  * Store.setLocale('en-US');
121
121
  */
122
+
123
+
122
124
  ObservableItem.prototype.format = function(type, options = {}) {
123
125
  const self = this;
124
126