native-document 1.0.166 → 1.0.169

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 (139) hide show
  1. package/.vitepress/config.js +166 -0
  2. package/CHANGELOG.md +187 -0
  3. package/components.js +4 -1
  4. package/dist/native-document.components.min.js +593 -300
  5. package/dist/native-document.dev.js +99 -75
  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/icons.md +321 -0
  41. package/docs/components/index.md +337 -0
  42. package/docs/components/layout.md +279 -0
  43. package/docs/components/list.md +73 -0
  44. package/docs/components/menu.md +215 -0
  45. package/docs/components/modal.md +156 -0
  46. package/docs/components/pagination.md +95 -0
  47. package/docs/components/popover.md +131 -0
  48. package/docs/components/progress.md +111 -0
  49. package/docs/components/shortcut-manager.md +221 -0
  50. package/docs/components/simple-table.md +107 -0
  51. package/docs/components/skeleton.md +155 -0
  52. package/docs/components/spinner.md +100 -0
  53. package/docs/components/splitter.md +133 -0
  54. package/docs/components/stepper.md +163 -0
  55. package/docs/components/switch.md +113 -0
  56. package/docs/components/tabs.md +153 -0
  57. package/docs/components/toast.md +119 -0
  58. package/docs/components/tooltip.md +151 -0
  59. package/docs/components/traits.md +261 -0
  60. package/docs/conditional-rendering.md +170 -588
  61. package/docs/contributing.md +300 -25
  62. package/docs/core-concepts.md +205 -374
  63. package/docs/elements.md +251 -367
  64. package/docs/extending-native-document-element.md +192 -207
  65. package/docs/filters.md +153 -1122
  66. package/docs/getting-started.md +193 -267
  67. package/docs/i18n.md +241 -0
  68. package/docs/index.md +76 -0
  69. package/docs/lifecycle-events.md +143 -75
  70. package/docs/list-rendering.md +227 -852
  71. package/docs/memory-management.md +134 -47
  72. package/docs/native-document-element.md +337 -186
  73. package/docs/native-fetch.md +99 -630
  74. package/docs/observable-resource.md +364 -0
  75. package/docs/observables.md +592 -526
  76. package/docs/routing.md +244 -653
  77. package/docs/state-management.md +134 -241
  78. package/docs/svg-elements.md +231 -0
  79. package/docs/theming.md +409 -0
  80. package/docs/tutorials/.gitkeep +0 -0
  81. package/docs/validation.md +95 -97
  82. package/docs/vitepress-conventions.md +219 -0
  83. package/package.json +34 -13
  84. package/readme.md +269 -89
  85. package/src/components/card/Card.js +93 -39
  86. package/src/components/card/index.js +1 -1
  87. package/src/components/form/field/types/FileField.js +3 -3
  88. package/src/components/icon/Icon.js +107 -0
  89. package/src/components/icon/icon-getters.js +142 -0
  90. package/src/components/icon/icons.js +171 -0
  91. package/src/components/icon/index.js +17 -0
  92. package/src/components/icon/types/Icon.d.ts +191 -0
  93. package/src/components/index.d.ts +6 -1
  94. package/src/components/list/HasListItem.js +171 -0
  95. package/src/components/list/List.js +41 -107
  96. package/src/components/list/ListDivider.js +39 -0
  97. package/src/components/list/ListGroup.js +76 -59
  98. package/src/components/list/ListItem.js +117 -69
  99. package/src/components/list/index.js +3 -1
  100. package/src/components/list/types/List.d.ts +45 -32
  101. package/src/components/list/types/ListDivider.ts +16 -0
  102. package/src/components/list/types/ListGroup.d.ts +51 -29
  103. package/src/components/list/types/ListItem.d.ts +40 -30
  104. package/src/components/spacer/Spacer.js +1 -1
  105. package/src/core/data/ObservableResource.js +5 -0
  106. package/src/core/data/observable-helpers/observable.prototypes.js +2 -0
  107. package/src/core/elements/content-formatter.js +16 -2
  108. package/src/core/elements/form.js +1 -1
  109. package/src/core/elements/img.js +1 -1
  110. package/src/core/elements/medias.js +2 -2
  111. package/src/core/elements/meta-data.js +1 -1
  112. package/src/core/wrappers/AttributesWrapper.js +37 -22
  113. package/src/core/wrappers/ElementCreator.js +9 -16
  114. package/src/core/wrappers/HtmlElementWrapper.js +26 -7
  115. package/src/core/wrappers/NDElement.js +12 -1
  116. package/src/core/wrappers/prototypes/attributes-extensions.js +24 -24
  117. package/src/core/wrappers/prototypes/nd-element-extensions.js +1 -8
  118. package/src/ui/components/card/CardRender.js +133 -0
  119. package/src/ui/components/card/card.css +169 -0
  120. package/src/ui/components/contextmenu/ContextmenuRender.js +1 -1
  121. package/src/ui/components/icon/material/MaterialIconRender.js +71 -0
  122. package/src/ui/components/icon/material/material.css +15 -0
  123. package/src/ui/components/icon/material/material.map.js +170 -0
  124. package/src/ui/components/icon/phosphor/PhosphorIconRender.js +71 -0
  125. package/src/ui/components/icon/phosphor/phosphor.css +17 -0
  126. package/src/ui/components/icon/phosphor/phosphor.map.js +165 -0
  127. package/src/ui/components/icon/tabler/TablerIconRender.js +59 -0
  128. package/src/ui/components/icon/tabler/tabler.css +14 -0
  129. package/src/ui/components/icon/tabler/tabler.map.js +165 -0
  130. package/src/ui/components/list/ListRender.js +18 -0
  131. package/src/ui/components/list/divider/ListDividerRender.js +10 -0
  132. package/src/ui/components/list/divider/list-divider.css +12 -0
  133. package/src/ui/components/list/group/ListGroupRender.js +61 -0
  134. package/src/ui/components/list/group/list-group.css +62 -0
  135. package/src/ui/components/list/item/ListItemRender.js +238 -0
  136. package/src/ui/components/list/item/list-item.css +191 -0
  137. package/src/ui/components/list/list.css +24 -0
  138. package/src/ui/components/spacer/SpacerRender.js +10 -0
  139. package/src/ui/index.js +13 -0
@@ -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,43 +1,56 @@
1
- import type { ValidChild } from '../../../../types/elements';
2
- import type { ObservableItem } from '../../../../types/observable';
3
- import type { BaseComponent } from '../../BaseComponent';
4
- import type { ListItemInterface } from './ListItem';
1
+ import type { ValidChild } from '../../../../types/elements';
2
+ import type { ObservableItem, ObservableArray } from '../../../../types/observable';
5
3
  import type { GlobalAttributes } from '../../../../types/globals';
4
+ import type { ListItemInterface } from './ListItem';
5
+ import type { ListGroupInterface } from './ListGroup';
6
+ import type { ListDividerInterface } from './ListDivider';
6
7
 
7
8
  export type ListDescription = {
8
- selectable: boolean;
9
- multiSelect: boolean;
10
- selectedValues: ObservableItem<unknown[]> | null;
11
- inset: boolean;
12
- divider: boolean;
13
- data: unknown | null;
14
- render: ((desc: ListDescription, instance: ListInterface) => ValidChild) | null;
15
- selectByCheckbox: boolean;
16
- selectByClick: boolean;
17
- loopOnKeyboard: boolean;
18
- props: GlobalAttributes;
19
- };
20
-
21
- export interface ListInterface extends BaseComponent {
22
- selectable(selectable?: boolean): this;
23
- selectByClick(): void;
24
- selectByCheckbox(): void;
25
- multiSelect(multi?: boolean): this;
26
- selectedValuesModel(observable: ObservableItem<unknown[]>): this;
27
- inset(inset?: boolean): this;
9
+ selectable: ObservableItem<boolean>;
10
+ multiSelect: ObservableItem<boolean>;
11
+ selectedValues: ObservableArray<unknown>;
12
+ inset: ObservableItem<number>;
13
+ divider: boolean;
14
+ items: ObservableArray<unknown>;
15
+ render: ((desc: ListDescription, instance: ListInterface) => ValidChild) | null;
16
+ selectByCheckbox: ObservableItem<boolean>;
17
+ selectByClick: ObservableItem<boolean>;
18
+ loopOnKeyboard: ObservableItem<boolean>;
19
+ props: GlobalAttributes;
20
+ };
21
+
22
+ export interface ListInterface {
23
+ $description: ListDescription;
24
+
25
+ // HasListItem
26
+ selectable(selectable?: boolean | ObservableItem<boolean>): this;
27
+ selectByClick(): this;
28
+ selectByCheckbox(): this;
29
+ multiSelect(multi?: boolean | ObservableItem<boolean>): this;
30
+ selectInto(list: ObservableArray<unknown> | unknown[]): this;
31
+ selectedValuesModel(observable: ObservableArray<unknown> | ObservableItem<unknown[]>): this;
32
+ loopOnKeyboard(loopOnKeyboard: boolean): this;
33
+ add(item: ListItemInterface | ListGroupInterface | ListDividerInterface): this;
34
+ item(label: ValidChild, iconOrBuilder?: ValidChild | ((item: ListItemInterface) => void), builder?: (item: ListItemInterface) => void): this;
35
+ group(label: ValidChild, iconOrBuilder?: ValidChild | ((group: ListGroupInterface) => void), builder?: (group: ListGroupInterface) => void): this;
36
+ divider(): this;
37
+ from(source: ObservableArray<unknown> | unknown[], builder: (item: unknown) => ListItemInterface | ListGroupInterface): this;
38
+
39
+ // Own methods
40
+ inset(inset?: number): this;
28
41
  withDivider(divider?: boolean): this;
29
42
  data(data: unknown): this;
30
43
  onItemClick(handler: (item: ListItemInterface, event: MouseEvent) => void): this;
31
44
  onItemSelect(handler: (item: ListItemInterface) => void): this;
32
- render(template: (description: ListDescription, instance: ListInterface) => ValidChild): this;
33
- }
34
45
 
46
+ // HasEventEmitter
47
+ on(event: string, handler: (...args: unknown[]) => void): this;
48
+ emit(event: string, ...args: unknown[]): void;
49
+ hasListeners(event: string): boolean;
50
+ }
35
51
 
36
- export declare function List(config?: Record<string, unknown>): ListInterface;
52
+ export declare function List(props?: GlobalAttributes): ListInterface;
37
53
  export declare namespace List {
38
-
39
-
40
54
  function use(template: (description: ListDescription, instance: ListInterface) => ValidChild): void;
41
-
42
-
43
- }
55
+ let defaultTemplate: ((description: ListDescription, instance: ListInterface) => ValidChild) | null;
56
+ }
@@ -0,0 +1,16 @@
1
+ import type { ValidChild } from '../../../../types/elements';
2
+ import type { GlobalAttributes } from '../../../../types/globals';
3
+
4
+ export type ListDividerDescription = {
5
+ props: GlobalAttributes;
6
+ };
7
+
8
+ export interface ListDividerInterface {
9
+ $description: ListDividerDescription;
10
+ }
11
+
12
+ export declare function ListDivider(props?: GlobalAttributes): ListDividerInterface;
13
+ export declare namespace ListDivider {
14
+ function use(template: (description: ListDividerDescription, instance: ListDividerInterface) => ValidChild): void;
15
+ let defaultTemplate: ((description: ListDividerDescription, instance: ListDividerInterface) => ValidChild) | null;
16
+ }
@@ -1,37 +1,59 @@
1
- import type { ValidChild } from '../../../../types/elements';
2
- import type { ObservableItem } from '../../../../types/observable';
3
- import type { BaseComponent } from '../../BaseComponent';
1
+ import type { ValidChild } from '../../../../types/elements';
2
+ import type { ObservableItem, ObservableArray } from '../../../../types/observable';
4
3
  import type { GlobalAttributes } from '../../../../types/globals';
4
+ import type { ListItemInterface } from './ListItem';
5
+ import type { ListDividerInterface } from './ListDivider';
5
6
 
6
7
  export type ListGroupDescription = {
7
- header: ValidChild | null;
8
- footer: ValidChild | null;
9
- items: unknown[];
10
- inset: boolean;
11
- data: unknown | null;
12
- renderHeader: ((desc: ListGroupDescription, instance: ListGroupInterface) => ValidChild) | null;
13
- renderFooter: ((desc: ListGroupDescription, instance: ListGroupInterface) => ValidChild) | null;
14
- render: ((desc: ListGroupDescription, instance: ListGroupInterface) => ValidChild) | null;
15
- props: GlobalAttributes;
16
- };
17
-
18
- export interface ListGroupInterface extends BaseComponent {
19
- header(header: ValidChild): this;
20
- title(title: ValidChild): this;
21
- footer(footer: ValidChild): this;
22
- inset(inset?: boolean): this;
8
+ label: ValidChild;
9
+ icon: ValidChild | null;
10
+ items: ObservableArray<unknown>;
11
+ render: ((desc: ListGroupDescription, instance: ListGroupInterface) => ValidChild) | null;
12
+ collapsable: boolean;
13
+ collapsed: ObservableItem<boolean> | null;
14
+ collapsableOpenedIcon: ValidChild | null;
15
+ collapsableClosedIcon: ValidChild | null;
16
+ visibility: ObservableItem<boolean>;
17
+ selectable: ObservableItem<boolean>;
18
+ multiSelect: ObservableItem<boolean>;
19
+ selectedValues: ObservableArray<unknown>;
20
+ selectByCheckbox: ObservableItem<boolean>;
21
+ selectByClick: ObservableItem<boolean>;
22
+ loopOnKeyboard: ObservableItem<boolean>;
23
+ props: GlobalAttributes;
24
+ };
25
+
26
+ export interface ListGroupInterface {
27
+ $description: ListGroupDescription;
28
+
29
+ // Own methods
30
+ icon(icon: ValidChild): this;
31
+ collapsable(mode?: boolean, openedIcon?: ValidChild, closedIcon?: ValidChild): this;
32
+ collapsed(mode?: boolean): this;
33
+ visibility(mode: boolean | ObservableItem<boolean>): this;
23
34
  data(data: unknown): this;
24
- renderHeader(renderFn: (desc: ListGroupDescription, instance: ListGroupInterface) => ValidChild): this;
25
- renderFooter(renderFn: (desc: ListGroupDescription, instance: ListGroupInterface) => ValidChild): this;
26
- render(renderFn: (desc: ListGroupDescription, instance: ListGroupInterface) => ValidChild): this;
27
- }
28
35
 
36
+ // HasListItem
37
+ selectable(selectable?: boolean | ObservableItem<boolean>): this;
38
+ selectByClick(): this;
39
+ selectByCheckbox(): this;
40
+ multiSelect(multi?: boolean | ObservableItem<boolean>): this;
41
+ selectInto(list: ObservableArray<unknown> | unknown[]): this;
42
+ loopOnKeyboard(loopOnKeyboard: boolean): this;
43
+ add(item: ListItemInterface | ListGroupInterface | ListDividerInterface): this;
44
+ item(label: ValidChild, iconOrBuilder?: ValidChild | ((item: ListItemInterface) => void), builder?: (item: ListItemInterface) => void): this;
45
+ group(label: ValidChild, iconOrBuilder?: ValidChild | ((group: ListGroupInterface) => void), builder?: (group: ListGroupInterface) => void): this;
46
+ divider(): this;
47
+ from(source: ObservableArray<unknown> | unknown[], builder: (item: unknown) => ListItemInterface | ListGroupInterface): this;
48
+
49
+ // HasEventEmitter
50
+ on(event: string, handler: (...args: unknown[]) => void): this;
51
+ emit(event: string, ...args: unknown[]): void;
52
+ hasListeners(event: string): boolean;
53
+ }
29
54
 
30
- export declare function ListGroup(label?: ValidChild, config?: Record<string, unknown>): ListGroupInterface;
55
+ export declare function ListGroup(label: ValidChild, props?: GlobalAttributes): ListGroupInterface;
31
56
  export declare namespace ListGroup {
32
-
33
-
34
57
  function use(template: (description: ListGroupDescription, instance: ListGroupInterface) => ValidChild): void;
35
-
36
-
37
- }
58
+ let defaultTemplate: ((description: ListGroupDescription, instance: ListGroupInterface) => ValidChild) | null;
59
+ }
@@ -1,42 +1,52 @@
1
- import type { ValidChild } from '../../../../types/elements';
2
- import type { ObservableItem } from '../../../../types/observable';
3
- import type { BaseComponent } from '../../BaseComponent';
1
+ import type { ValidChild } from '../../../../types/elements';
2
+ import type { ObservableItem } from '../../../../types/observable';
4
3
  import type { GlobalAttributes } from '../../../../types/globals';
5
4
 
6
5
  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
- };
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: ObservableItem<boolean> | null;
14
+ selected: ObservableItem<boolean> | null;
15
+ visibility: ObservableItem<boolean> | null;
16
+ isSelectedIcon: ValidChild | null;
17
+ swipeLeading: ValidChild[];
18
+ swipeTrailing: ValidChild[];
19
+ render: ((desc: ListItemDescription, instance: ListItemInterface) => ValidChild) | null;
20
+ props: GlobalAttributes;
21
+ };
22
+
23
+ export interface ListItemInterface {
24
+ $description: ListItemDescription;
25
+ $parent: unknown;
19
26
 
20
- export interface ListItemInterface extends BaseComponent {
21
- content(content: ValidChild): this;
22
27
  label(label: ValidChild): this;
28
+ subtitle(subtitle: ValidChild): this;
23
29
  icon(icon: ValidChild): this;
24
- leading(leading: ValidChild): this;
25
30
  trailing(trailing: ValidChild): this;
26
- disabled(disabled?: boolean): this;
27
- selectable(): this;
28
- selected(selected?: boolean | ObservableItem<boolean>): this;
29
- divider(show?: boolean): this;
31
+ value(value: unknown): this;
30
32
  data(data: unknown): this;
31
- render(renderFn: (desc: ListItemDescription, instance: ListItemInterface) => ValidChild): this;
33
+ key(key: string): this;
34
+ disabled(disabled?: boolean | ObservableItem<boolean>): this;
35
+ selected(selected?: boolean | ObservableItem<boolean>): this;
36
+ visibility(mode: boolean | ObservableItem<boolean>): this;
37
+ isSelectedIcon(icon: ValidChild): this;
38
+ swipeLeading(actions: ValidChild | ValidChild[]): this;
39
+ swipeTrailing(actions: ValidChild | ValidChild[]): this;
40
+ onClick(handler: (item: ListItemInterface, event: MouseEvent) => void): this;
41
+
42
+ // HasEventEmitter
43
+ on(event: string, handler: (...args: unknown[]) => void): this;
44
+ emit(event: string, ...args: unknown[]): void;
45
+ hasListeners(event: string): boolean;
32
46
  }
33
47
 
34
-
35
- export declare function ListItem(content?: ValidChild, config?: Record<string, unknown>): ListItemInterface;
48
+ export declare function ListItem(props?: GlobalAttributes): ListItemInterface;
36
49
  export declare namespace ListItem {
37
-
38
-
39
50
  function use(template: (description: ListItemDescription, instance: ListItemInterface) => ValidChild): void;
40
-
41
-
42
- }
51
+ let defaultTemplate: ((description: ListItemDescription, instance: ListItemInterface) => ValidChild) | null;
52
+ }
@@ -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
 
@@ -30,12 +30,26 @@ export const P = HtmlElementWrapper('p');
30
30
  */
31
31
  export const Paragraph = P;
32
32
 
33
+ /**
34
+ * Creates a `<i>` element.
35
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
36
+ */
37
+ export const I = HtmlElementWrapper('i');
38
+ export const Italic = I;
39
+
33
40
  /**
34
41
  * Creates a `<strong>` element.
35
42
  * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
36
43
  */
37
44
  export const Strong = HtmlElementWrapper('strong');
38
45
 
46
+ /**
47
+ * Creates a `<strong>` element.
48
+ * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLElement}
49
+ */
50
+ export const B = HtmlElementWrapper('b');
51
+ export const Bold = B;
52
+
39
53
  /**
40
54
  * Creates a `<h1>` element.
41
55
  * @type {function(GlobalAttributes=, NdChild|NdChild[]=): HTMLHeadingElement}
@@ -76,7 +90,7 @@ export const H6 = HtmlElementWrapper('h6');
76
90
  * Creates a `<br>` element.
77
91
  * @type {function(GlobalAttributes=): HTMLBRElement}
78
92
  */
79
- export const Br = HtmlElementWrapper('br');
93
+ export const Br = HtmlElementWrapper('br', null, true);
80
94
 
81
95
  /**
82
96
  * Creates an `<a>` element.
@@ -106,7 +120,7 @@ export const Blockquote = HtmlElementWrapper('blockquote');
106
120
  * Creates an `<hr>` element.
107
121
  * @type {function(GlobalAttributes=): HTMLHRElement}
108
122
  */
109
- export const Hr = HtmlElementWrapper('hr');
123
+ export const Hr = HtmlElementWrapper('hr', null, true);
110
124
 
111
125
  /**
112
126
  * Creates an `<em>` element.
@@ -44,7 +44,7 @@ export const Form = HtmlElementWrapper('form', (el) => {
44
44
  * Creates an `<input>` element.
45
45
  * @type {function(InputAttributes=): HTMLInputElement}
46
46
  */
47
- export const Input = HtmlElementWrapper('input');
47
+ export const Input = HtmlElementWrapper('input', null, true);
48
48
 
49
49
  /**
50
50
  * Creates a `<textarea>` element.