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.
- package/.vitepress/config.js +166 -0
- package/CHANGELOG.md +187 -0
- package/components.js +4 -1
- package/dist/native-document.components.min.js +593 -300
- package/dist/native-document.dev.js +99 -75
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/docs/advanced-components.md +213 -608
- package/docs/anchor.md +173 -312
- package/docs/cache.md +95 -803
- package/docs/cli.md +179 -0
- package/docs/components/accordion.md +172 -0
- package/docs/components/alert.md +99 -0
- package/docs/components/avatar.md +160 -0
- package/docs/components/badge.md +102 -0
- package/docs/components/breadcrumb.md +89 -0
- package/docs/components/button.md +183 -0
- package/docs/components/card.md +69 -0
- package/docs/components/context-menu.md +118 -0
- package/docs/components/data-table.md +345 -0
- package/docs/components/dropdown.md +214 -0
- package/docs/components/form/autocomplete-field.md +81 -0
- package/docs/components/form/checkbox-field.md +41 -0
- package/docs/components/form/checkbox-group-field.md +54 -0
- package/docs/components/form/color-field.md +64 -0
- package/docs/components/form/date-field.md +92 -0
- package/docs/components/form/field-collection.md +63 -0
- package/docs/components/form/file-field.md +203 -0
- package/docs/components/form/form-control.md +87 -0
- package/docs/components/form/image-field.md +90 -0
- package/docs/components/form/index.md +115 -0
- package/docs/components/form/number-field.md +65 -0
- package/docs/components/form/radio-field.md +51 -0
- package/docs/components/form/select-field.md +123 -0
- package/docs/components/form/slider.md +136 -0
- package/docs/components/form/string-field.md +134 -0
- package/docs/components/form/textarea-field.md +65 -0
- package/docs/components/form-fields.md +372 -0
- package/docs/components/getting-started.md +264 -0
- package/docs/components/icons.md +321 -0
- package/docs/components/index.md +337 -0
- package/docs/components/layout.md +279 -0
- package/docs/components/list.md +73 -0
- package/docs/components/menu.md +215 -0
- package/docs/components/modal.md +156 -0
- package/docs/components/pagination.md +95 -0
- package/docs/components/popover.md +131 -0
- package/docs/components/progress.md +111 -0
- package/docs/components/shortcut-manager.md +221 -0
- package/docs/components/simple-table.md +107 -0
- package/docs/components/skeleton.md +155 -0
- package/docs/components/spinner.md +100 -0
- package/docs/components/splitter.md +133 -0
- package/docs/components/stepper.md +163 -0
- package/docs/components/switch.md +113 -0
- package/docs/components/tabs.md +153 -0
- package/docs/components/toast.md +119 -0
- package/docs/components/tooltip.md +151 -0
- package/docs/components/traits.md +261 -0
- package/docs/conditional-rendering.md +170 -588
- package/docs/contributing.md +300 -25
- package/docs/core-concepts.md +205 -374
- package/docs/elements.md +251 -367
- package/docs/extending-native-document-element.md +192 -207
- package/docs/filters.md +153 -1122
- package/docs/getting-started.md +193 -267
- package/docs/i18n.md +241 -0
- package/docs/index.md +76 -0
- package/docs/lifecycle-events.md +143 -75
- package/docs/list-rendering.md +227 -852
- package/docs/memory-management.md +134 -47
- package/docs/native-document-element.md +337 -186
- package/docs/native-fetch.md +99 -630
- package/docs/observable-resource.md +364 -0
- package/docs/observables.md +592 -526
- package/docs/routing.md +244 -653
- package/docs/state-management.md +134 -241
- package/docs/svg-elements.md +231 -0
- package/docs/theming.md +409 -0
- package/docs/tutorials/.gitkeep +0 -0
- package/docs/validation.md +95 -97
- package/docs/vitepress-conventions.md +219 -0
- package/package.json +34 -13
- package/readme.md +269 -89
- package/src/components/card/Card.js +93 -39
- package/src/components/card/index.js +1 -1
- package/src/components/form/field/types/FileField.js +3 -3
- package/src/components/icon/Icon.js +107 -0
- package/src/components/icon/icon-getters.js +142 -0
- package/src/components/icon/icons.js +171 -0
- package/src/components/icon/index.js +17 -0
- package/src/components/icon/types/Icon.d.ts +191 -0
- package/src/components/index.d.ts +6 -1
- package/src/components/list/HasListItem.js +171 -0
- package/src/components/list/List.js +41 -107
- package/src/components/list/ListDivider.js +39 -0
- package/src/components/list/ListGroup.js +76 -59
- package/src/components/list/ListItem.js +117 -69
- package/src/components/list/index.js +3 -1
- package/src/components/list/types/List.d.ts +45 -32
- package/src/components/list/types/ListDivider.ts +16 -0
- package/src/components/list/types/ListGroup.d.ts +51 -29
- package/src/components/list/types/ListItem.d.ts +40 -30
- package/src/components/spacer/Spacer.js +1 -1
- package/src/core/data/ObservableResource.js +5 -0
- package/src/core/data/observable-helpers/observable.prototypes.js +2 -0
- package/src/core/elements/content-formatter.js +16 -2
- package/src/core/elements/form.js +1 -1
- package/src/core/elements/img.js +1 -1
- package/src/core/elements/medias.js +2 -2
- package/src/core/elements/meta-data.js +1 -1
- package/src/core/wrappers/AttributesWrapper.js +37 -22
- package/src/core/wrappers/ElementCreator.js +9 -16
- package/src/core/wrappers/HtmlElementWrapper.js +26 -7
- package/src/core/wrappers/NDElement.js +12 -1
- package/src/core/wrappers/prototypes/attributes-extensions.js +24 -24
- package/src/core/wrappers/prototypes/nd-element-extensions.js +1 -8
- package/src/ui/components/card/CardRender.js +133 -0
- package/src/ui/components/card/card.css +169 -0
- package/src/ui/components/contextmenu/ContextmenuRender.js +1 -1
- package/src/ui/components/icon/material/MaterialIconRender.js +71 -0
- package/src/ui/components/icon/material/material.css +15 -0
- package/src/ui/components/icon/material/material.map.js +170 -0
- package/src/ui/components/icon/phosphor/PhosphorIconRender.js +71 -0
- package/src/ui/components/icon/phosphor/phosphor.css +17 -0
- package/src/ui/components/icon/phosphor/phosphor.map.js +165 -0
- package/src/ui/components/icon/tabler/TablerIconRender.js +59 -0
- package/src/ui/components/icon/tabler/tabler.css +14 -0
- package/src/ui/components/icon/tabler/tabler.map.js +165 -0
- package/src/ui/components/list/ListRender.js +18 -0
- package/src/ui/components/list/divider/ListDividerRender.js +10 -0
- package/src/ui/components/list/divider/list-divider.css +12 -0
- package/src/ui/components/list/group/ListGroupRender.js +61 -0
- package/src/ui/components/list/group/list-group.css +62 -0
- package/src/ui/components/list/item/ListItemRender.js +238 -0
- package/src/ui/components/list/item/list-item.css +191 -0
- package/src/ui/components/list/list.css +24 -0
- package/src/ui/components/spacer/SpacerRender.js +10 -0
- package/src/ui/index.js +13 -0
|
@@ -1,64 +1,81 @@
|
|
|
1
1
|
import BaseComponent from '../BaseComponent';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import HasEventEmitter from '../../core/utils/HasEventEmitter';
|
|
3
|
+
import HasListItem from './HasListItem';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* A single
|
|
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
|
-
*
|
|
11
|
-
* .
|
|
12
|
-
* .
|
|
13
|
-
* .
|
|
14
|
-
* .
|
|
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(
|
|
22
|
+
* return Li({ class: 'list-item' }, description.label);
|
|
18
23
|
* });
|
|
19
24
|
*
|
|
20
25
|
* @constructor
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {GlobalAttributes} [config={}]
|
|
26
|
+
* @param {GlobalAttributes} [props={}]
|
|
23
27
|
*/
|
|
24
|
-
export default function ListItem(
|
|
25
|
-
if(!(this instanceof ListItem)) {
|
|
26
|
-
return new ListItem(
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
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}
|
|
86
|
+
* @param {NdChild} label
|
|
70
87
|
* @returns {this}
|
|
71
88
|
*/
|
|
72
|
-
ListItem.prototype.
|
|
73
|
-
this.$description.
|
|
89
|
+
ListItem.prototype.label = function(label) {
|
|
90
|
+
this.$description.label = label;
|
|
74
91
|
return this;
|
|
75
92
|
};
|
|
76
93
|
|
|
77
94
|
/**
|
|
78
|
-
* @param {NdChild}
|
|
95
|
+
* @param {NdChild} subtitle
|
|
79
96
|
* @returns {this}
|
|
80
97
|
*/
|
|
81
|
-
ListItem.prototype.
|
|
82
|
-
this.$description.
|
|
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}
|
|
113
|
+
* @param {NdChild} trailing
|
|
97
114
|
* @returns {this}
|
|
98
115
|
*/
|
|
99
|
-
ListItem.prototype.
|
|
100
|
-
this.$description.
|
|
116
|
+
ListItem.prototype.trailing = function(trailing) {
|
|
117
|
+
this.$description.trailing = trailing;
|
|
101
118
|
return this;
|
|
102
119
|
};
|
|
103
120
|
|
|
104
121
|
/**
|
|
105
|
-
* @param {
|
|
122
|
+
* @param {*} value
|
|
106
123
|
* @returns {this}
|
|
107
124
|
*/
|
|
108
|
-
ListItem.prototype.
|
|
109
|
-
this.$description.
|
|
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.
|
|
127
|
-
this.$description.
|
|
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>}
|
|
167
|
+
* @param {boolean|Observable<boolean>} mode
|
|
137
168
|
* @returns {this}
|
|
138
169
|
*/
|
|
139
|
-
ListItem.prototype.
|
|
140
|
-
|
|
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
|
-
*
|
|
176
|
+
* Icon displayed when the item is selected (selectByClick mode).
|
|
177
|
+
* @param {NdChild} icon
|
|
150
178
|
* @returns {this}
|
|
151
179
|
*/
|
|
152
|
-
ListItem.prototype.
|
|
153
|
-
this.$description.
|
|
180
|
+
ListItem.prototype.isSelectedIcon = function(icon) {
|
|
181
|
+
this.$description.isSelectedIcon = icon;
|
|
154
182
|
return this;
|
|
155
183
|
};
|
|
156
184
|
|
|
157
185
|
/**
|
|
158
|
-
*
|
|
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.
|
|
162
|
-
this.$description.
|
|
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,43 +1,56 @@
|
|
|
1
|
-
import type { ValidChild }
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export interface ListInterface
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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(
|
|
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 }
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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 }
|
|
2
|
-
import type { ObservableItem }
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
@@ -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.
|