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.
- package/.vitepress/config.js +166 -0
- package/CHANGELOG.md +153 -0
- package/components.js +2 -1
- package/dist/native-document.components.min.js +495 -228
- package/dist/native-document.dev.js +7 -0
- 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/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/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/ListItem.d.ts +45 -34
- 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/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/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 +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
|
-
*
|
|
6
|
-
*
|
|
8
|
+
* A collapsible group of ListItems inside a List. Can hold items, dividers, and nested groups.
|
|
7
9
|
*
|
|
8
10
|
* @example
|
|
9
|
-
*
|
|
10
|
-
* .
|
|
11
|
-
* .
|
|
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}
|
|
15
|
-
* @param {GlobalAttributes} [
|
|
28
|
+
* @param {NdChild} label
|
|
29
|
+
* @param {GlobalAttributes} [props={}]
|
|
16
30
|
*/
|
|
17
|
-
export default function ListGroup(label,
|
|
18
|
-
if(!(this instanceof ListGroup)) {
|
|
19
|
-
return new ListGroup(label,
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* items:
|
|
46
|
-
*
|
|
47
|
-
* data:
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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}
|
|
84
|
+
* @param {NdChild} icon
|
|
60
85
|
* @returns {this}
|
|
61
86
|
*/
|
|
62
|
-
ListGroup.prototype.
|
|
63
|
-
this.$description.
|
|
87
|
+
ListGroup.prototype.icon = function(icon) {
|
|
88
|
+
this.$description.icon = icon;
|
|
64
89
|
return this;
|
|
65
90
|
};
|
|
66
91
|
|
|
67
92
|
/**
|
|
68
|
-
* @param {
|
|
93
|
+
* @param {boolean} [mode=true]
|
|
94
|
+
* @param {NdChild} [openedIcon]
|
|
95
|
+
* @param {NdChild} [closedIcon]
|
|
69
96
|
* @returns {this}
|
|
70
97
|
*/
|
|
71
|
-
ListGroup.prototype.
|
|
72
|
-
|
|
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 {
|
|
107
|
+
* @param {boolean} [mode=true]
|
|
77
108
|
* @returns {this}
|
|
78
109
|
*/
|
|
79
|
-
ListGroup.prototype.
|
|
80
|
-
this.$description.
|
|
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 {
|
|
120
|
+
* @param {boolean|Observable<boolean>} mode
|
|
86
121
|
* @returns {this}
|
|
87
122
|
*/
|
|
88
|
-
ListGroup.prototype.
|
|
89
|
-
this.$description.
|
|
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
|
|
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,42 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -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
|
|