native-document 1.0.76 → 1.0.78
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/components.js +26 -1
- package/dist/native-document.components.min.js +6447 -1984
- package/dist/native-document.dev.js +309 -196
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.devtools.min.js +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/rollup.config.js +0 -14
- package/src/components/$traits/HasItems.js +38 -0
- package/src/components/BaseComponent.js +70 -0
- package/src/components/accordion/Accordion.js +133 -0
- package/src/components/accordion/AccordionItem.js +119 -0
- package/src/components/accordion/index.js +7 -0
- package/src/components/alert/Alert.js +155 -0
- package/src/components/alert/index.js +6 -0
- package/src/components/avatar/Avatar.js +178 -0
- package/src/components/avatar/index.js +5 -0
- package/src/components/badge/Badge.js +103 -0
- package/src/components/badge/index.js +6 -0
- package/src/components/breadcrumb/BreadCrumb.js +70 -0
- package/src/components/breadcrumb/index.js +5 -0
- package/src/components/button/Button.js +174 -0
- package/src/components/button/index.js +5 -0
- package/src/components/card/Card.js +110 -0
- package/src/components/card/index.js +5 -0
- package/src/components/context-menu/ContextMenu.js +60 -0
- package/src/components/context-menu/ContextMenuGroup.js +16 -0
- package/src/components/context-menu/ContextMenuItem.js +16 -0
- package/src/components/context-menu/index.js +10 -0
- package/src/components/divider/Divider.js +126 -0
- package/src/components/divider/index.js +6 -0
- package/src/components/dropdown/Dropdown.js +170 -0
- package/src/components/dropdown/DropdownDivider.js +24 -0
- package/src/components/dropdown/DropdownGroup.js +44 -0
- package/src/components/dropdown/DropdownItem.js +71 -0
- package/src/components/dropdown/DropdownTrigger.js +64 -0
- package/src/components/dropdown/index.js +13 -0
- package/src/components/{fom-control → form}/FormControl.js +28 -20
- package/src/components/{fom-control → form}/field/DefaultRender.js +1 -15
- package/src/components/{fom-control → form}/field/Field.js +64 -137
- package/src/components/{fom-control → form}/field/FieldCollection.js +39 -19
- package/src/components/{fom-control → form}/field/types/AutocompleteField.js +11 -0
- package/src/components/form/field/types/CheckboxField.js +36 -0
- package/src/components/{fom-control → form}/field/types/CheckboxGroupField.js +10 -0
- package/src/components/{fom-control → form}/field/types/ColorField.js +10 -0
- package/src/components/{fom-control → form}/field/types/DateField.js +10 -0
- package/src/components/{fom-control → form}/field/types/EmailField.js +10 -0
- package/src/components/{fom-control → form}/field/types/FileField.js +10 -0
- package/src/components/form/field/types/HiddenField.js +18 -0
- package/src/components/{fom-control → form}/field/types/ImageField.js +10 -0
- package/src/components/{fom-control → form}/field/types/NumberField.js +10 -0
- package/src/components/{fom-control → form}/field/types/PasswordField.js +10 -0
- package/src/components/{fom-control → form}/field/types/RadioField.js +28 -2
- package/src/components/{fom-control → form}/field/types/RangeField.js +10 -0
- package/src/components/{fom-control → form}/field/types/SearchField.js +10 -0
- package/src/components/{fom-control → form}/field/types/SelectField.js +10 -0
- package/src/components/{fom-control → form}/field/types/StringField.js +10 -0
- package/src/components/{fom-control → form}/field/types/TelField.js +10 -1
- package/src/components/{fom-control → form}/field/types/TextAreaField.js +10 -0
- package/src/components/{fom-control → form}/field/types/TimeField.js +10 -1
- package/src/components/{fom-control → form}/field/types/UrlField.js +9 -1
- package/src/components/form/index.js +49 -0
- package/src/components/list/List.js +106 -0
- package/src/components/list/ListGroup.js +67 -0
- package/src/components/list/ListItem.js +103 -0
- package/src/components/list/index.js +10 -0
- package/src/components/menu/Menu.js +82 -0
- package/src/components/menu/MenuDivider.js +22 -0
- package/src/components/menu/MenuGroup.js +42 -0
- package/src/components/menu/MenuItem.js +71 -0
- package/src/components/menu/index.js +13 -0
- package/src/components/modal/Modal.js +153 -0
- package/src/components/modal/index.js +5 -0
- package/src/components/pagination/Pagination.js +229 -0
- package/src/components/pagination/index.js +5 -0
- package/src/components/popover/Popover.js +185 -0
- package/src/components/popover/PopoverFooter.js +37 -0
- package/src/components/popover/PopoverHeader.js +43 -0
- package/src/components/popover/index.js +10 -0
- package/src/components/progress/Progress.js +220 -0
- package/src/components/progress/index.js +6 -0
- package/src/components/skeleton/Skeleton.js +98 -0
- package/src/components/skeleton/SkeletonCard.js +0 -0
- package/src/components/skeleton/SkeletonList.js +0 -0
- package/src/components/skeleton/SkeletonParagraph.js +0 -0
- package/src/components/skeleton/SkeletonTable.js +0 -0
- package/src/components/skeleton/index.js +6 -0
- package/src/components/slider/Slider.js +183 -0
- package/src/components/slider/index.js +5 -0
- package/src/components/spinner/Spinner.js +160 -0
- package/src/components/spinner/index.js +5 -0
- package/src/components/splitter/Splitter.js +94 -0
- package/src/components/splitter/SplitterGutter.js +57 -0
- package/src/components/splitter/SplitterPanel.js +82 -0
- package/src/components/splitter/index.js +8 -0
- package/src/components/stepper/Stepper.js +229 -0
- package/src/components/stepper/StepperStep.js +103 -0
- package/src/components/stepper/index.js +8 -0
- package/src/components/switch/Switch.js +99 -0
- package/src/components/switch/index.js +0 -0
- package/src/components/table/SimpleTable.js +36 -32
- package/src/components/tabs/Tabs.js +110 -0
- package/src/components/tabs/index.js +6 -0
- package/src/components/toast/Toast.js +129 -0
- package/src/components/toast/ToastError.js +0 -0
- package/src/components/toast/ToastInfo.js +0 -0
- package/src/components/toast/ToastSuccess.js +0 -0
- package/src/components/toast/ToastWarning.js +0 -0
- package/src/components/toast/index.js +5 -0
- package/src/components/tooltip/Tooltip.js +98 -0
- package/src/components/tooltip/index.js +5 -0
- package/src/components/tooltip/prototypes.js +6 -0
- package/src/core/data/MemoryManager.js +1 -2
- package/src/core/data/Observable.js +1 -1
- package/src/core/data/ObservableArray.js +10 -4
- package/src/core/data/ObservableItem.js +5 -5
- package/src/core/data/observable-helpers/array.js +1 -1
- package/src/core/data/observable-helpers/batch.js +1 -1
- package/src/core/data/observable-helpers/computed.js +1 -1
- package/src/core/elements/control/for-each-array.js +37 -64
- package/src/core/elements/control/for-each.js +1 -1
- package/src/core/elements/control/show-if.js +1 -1
- package/src/core/elements/control/switch.js +1 -1
- package/src/core/utils/events.js +68 -0
- package/src/core/utils/filters/standard.js +1 -1
- package/src/core/utils/filters/utils.js +1 -1
- package/src/core/utils/helpers.js +10 -7
- package/src/core/utils/validator.js +1 -0
- package/src/core/wrappers/AttributesWrapper.js +18 -35
- package/src/core/wrappers/DocumentObserver.js +0 -1
- package/src/core/wrappers/ElementCreator.js +6 -11
- package/src/core/wrappers/NdPrototype.js +24 -31
- package/src/core/wrappers/TemplateCloner.js +60 -18
- package/src/core/wrappers/constants.js +32 -1
- package/src/core/wrappers/prototypes/attributes-extensions.js +16 -3
- package/src/core/wrappers/prototypes/bind-class-extensions.js +18 -0
- package/src/devtools/app/App.js +1 -1
- package/src/devtools/hrm/ComponentRegistry.js +1 -1
- package/src/router/Router.js +1 -1
- package/src/router/link.js +4 -4
- package/src/router/modes/HistoryRouter.js +0 -1
- package/types/control-flow.d.ts +0 -1
- package/types/filters/standard.d.ts +0 -1
- package/src/components/fom-control/default/DefaultLayout.js +0 -8
- package/src/components/fom-control/default/collection/DefaultCollectionLayout.js +0 -12
- package/src/components/fom-control/default/collection/DefaultCollectionTemplate.js +0 -6
- package/src/components/fom-control/field/types/CheckboxField.js +0 -17
- package/src/components/fom-control/field/types/HiddenField.js +0 -8
- package/src/components/fom-control/index.js +0 -8
- /package/src/components/{fom-control → form}/field/FieldFactory.js +0 -0
- /package/src/components/{fom-control → form}/merge +0 -0
- /package/src/components/{fom-control → form}/utils.js +0 -0
- /package/src/components/{fom-control → form}/validation/Validation.js +0 -0
- /package/src/{core → router}/errors/RouterError.js +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
|
|
3
|
+
export default function Divider(config = {}) {
|
|
4
|
+
if(!(this instanceof Divider)) {
|
|
5
|
+
return new Divider(config);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
this.$description = {
|
|
9
|
+
orientation: 'horizontal',
|
|
10
|
+
variant: 'solid',
|
|
11
|
+
thickness: null,
|
|
12
|
+
spacing: null,
|
|
13
|
+
label: null,
|
|
14
|
+
labelPosition: 'center',
|
|
15
|
+
color: null,
|
|
16
|
+
render: null,
|
|
17
|
+
inset: null,
|
|
18
|
+
indent: null,
|
|
19
|
+
leading: null,
|
|
20
|
+
trailing: null,
|
|
21
|
+
...config
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
BaseComponent.extends(Divider);
|
|
26
|
+
|
|
27
|
+
Divider.defaultTemplate = null;
|
|
28
|
+
|
|
29
|
+
Divider.use = function(template) {
|
|
30
|
+
Divider.defaultTemplate = template.divider;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
Divider.prototype.orientation = function(orientation) {
|
|
34
|
+
this.$description.orientation = orientation;
|
|
35
|
+
return this;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Divider.prototype.horizontal = function() {
|
|
39
|
+
this.$description.orientation = 'horizontal';
|
|
40
|
+
return this;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Divider.prototype.vertical = function() {
|
|
44
|
+
this.$description.orientation = 'vertical';
|
|
45
|
+
return this;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Divider.prototype.variant = function(variant) {
|
|
49
|
+
this.$description.variant = variant;
|
|
50
|
+
return this;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Divider.prototype.solid = function() {
|
|
54
|
+
this.$description.variant = 'solid';
|
|
55
|
+
return this;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Divider.prototype.dashed = function() {
|
|
59
|
+
this.$description.variant = 'dashed';
|
|
60
|
+
return this;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
Divider.prototype.dotted = function() {
|
|
64
|
+
this.$description.variant = 'dotted';
|
|
65
|
+
return this;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
Divider.prototype.thickness = function(thickness) {
|
|
69
|
+
this.$description.thickness = thickness;
|
|
70
|
+
return this;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Divider.prototype.spacing = function(spacing) {
|
|
74
|
+
this.$description.spacing = spacing;
|
|
75
|
+
return this;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
Divider.prototype.inset = function(inset) {
|
|
79
|
+
this.$description.inset = inset;
|
|
80
|
+
return this;
|
|
81
|
+
};
|
|
82
|
+
Divider.prototype.leading = function(leading) {
|
|
83
|
+
this.$description.leading = leading;
|
|
84
|
+
return this;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
Divider.prototype.trailing = function(trailing) {
|
|
88
|
+
this.$description.trailing = trailing;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
Divider.prototype.indent = function(leading, trailing) {
|
|
93
|
+
this.leading(leading);
|
|
94
|
+
this.trailing(trailing);
|
|
95
|
+
return this;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
Divider.prototype.label = function(label) {
|
|
99
|
+
this.$description.label = label;
|
|
100
|
+
return this;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
Divider.prototype.labelPosition = function(position) {
|
|
104
|
+
this.$description.labelPosition = position;
|
|
105
|
+
return this;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
Divider.prototype.labelAtLeading = function() {
|
|
109
|
+
this.$description.labelPosition = 'leading';
|
|
110
|
+
return this;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
Divider.prototype.labelAtCenter = function() {
|
|
114
|
+
this.$description.labelPosition = 'center';
|
|
115
|
+
return this;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
Divider.prototype.labelAtTrailing = function() {
|
|
119
|
+
this.$description.labelPosition = 'trailing';
|
|
120
|
+
return this;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
Divider.prototype.color = function(color) {
|
|
124
|
+
this.$description.color = color;
|
|
125
|
+
return this;
|
|
126
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
|
+
import DropdownGroup from "./DropdownGroup";
|
|
4
|
+
import DropdownTrigger from "./DropdownTrigger";
|
|
5
|
+
import DropdownDivider from "./DropdownDivider";
|
|
6
|
+
|
|
7
|
+
export default function Dropdown(config = {}) {
|
|
8
|
+
if (!(this instanceof Dropdown)) {
|
|
9
|
+
return new Dropdown(config);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
this.$description = {
|
|
13
|
+
trigger: null,
|
|
14
|
+
items: [],
|
|
15
|
+
position: 'bottom-start',
|
|
16
|
+
offset: [0, 4],
|
|
17
|
+
disabled: false,
|
|
18
|
+
closeOnSelect: true,
|
|
19
|
+
closeOnClickOutside: true,
|
|
20
|
+
closeOnEscape: true,
|
|
21
|
+
isOpen: $(false),
|
|
22
|
+
maxHeight: null,
|
|
23
|
+
searchable: false,
|
|
24
|
+
searchPlaceholder: 'Search...',
|
|
25
|
+
loopOnKeyboard: true,
|
|
26
|
+
renderTrigger: null,
|
|
27
|
+
renderItem: null,
|
|
28
|
+
renderDivider: null,
|
|
29
|
+
renderHeader: null,
|
|
30
|
+
renderFooter: null,
|
|
31
|
+
render: null,
|
|
32
|
+
...config,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
this.$element = null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
BaseComponent.extends(Dropdown, EventEmitter);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Dropdown.defaultTemplate = null;
|
|
42
|
+
|
|
43
|
+
Dropdown.use = function(template) {
|
|
44
|
+
Dropdown.defaultTemplate = template.render;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
Dropdown.prototype.value = function(value) {
|
|
48
|
+
this.$description.value = value;
|
|
49
|
+
return this;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
Dropdown.prototype.placeholder = function(placeholder) {
|
|
53
|
+
this.$description.placeholder = placeholder;
|
|
54
|
+
return this;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
Dropdown.prototype.searchable = function(searchable, placeholder = null) {
|
|
58
|
+
this.$description.searchable = searchable;
|
|
59
|
+
if (placeholder) {
|
|
60
|
+
this.$description.searchPlaceholder = placeholder;
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
Dropdown.prototype.searchPlaceholder = function(placeholder) {
|
|
66
|
+
this.$description.searchPlaceholder = placeholder;
|
|
67
|
+
return this;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
Dropdown.prototype.closeOnClickOutside = function(closeOnClickOutside) {
|
|
71
|
+
this.$description.closeOnClickOutside = closeOnClickOutside;
|
|
72
|
+
return this;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
Dropdown.prototype.closeOnEscape = function(closeOnEscape) {
|
|
76
|
+
this.$description.closeOnEscape = closeOnEscape;
|
|
77
|
+
return this;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
Dropdown.prototype.closeOnSelect = function(closeOnSelect) {
|
|
81
|
+
this.$description.closeOnSelect = closeOnSelect;
|
|
82
|
+
return this;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Dropdown.prototype.maxHeight = function(maxHeight) {
|
|
86
|
+
this.$description.maxHeight = maxHeight;
|
|
87
|
+
return this;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
Dropdown.prototype.trigger = function(trigger) {
|
|
91
|
+
if (trigger instanceof DropdownTrigger) {
|
|
92
|
+
trigger.setIsOpen(this.$description.isOpen);
|
|
93
|
+
this.$description.trigger = trigger;
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.$description.trigger = trigger;
|
|
98
|
+
return this;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
Dropdown.prototype.add = function(item) {
|
|
102
|
+
this.$description.items.push(item);
|
|
103
|
+
return this;
|
|
104
|
+
};
|
|
105
|
+
Dropdown.prototype.item = Dropdown.prototype.add;
|
|
106
|
+
|
|
107
|
+
Dropdown.prototype.items = function(items) {
|
|
108
|
+
for(const item of items) {
|
|
109
|
+
this.add(item);
|
|
110
|
+
}
|
|
111
|
+
return this;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
Dropdown.prototype.group = function(groupBuilder) {
|
|
115
|
+
const group = new DropdownGroup();
|
|
116
|
+
groupBuilder && groupBuilder(group);
|
|
117
|
+
this.$description.items.push(group);
|
|
118
|
+
return this;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
Dropdown.prototype.divider = function() {
|
|
122
|
+
this.$description.items.push(new DropdownDivider());
|
|
123
|
+
return this;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
Dropdown.prototype.select = function(value) {
|
|
127
|
+
this.$description.value?.set(value);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
Dropdown.prototype.next = function() {
|
|
131
|
+
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
Dropdown.prototype.preview = function() {
|
|
135
|
+
|
|
136
|
+
};
|
|
137
|
+
Dropdown.prototype.loopOnKeyboard = function(loopOnKeyboard) {
|
|
138
|
+
this.$description.loopOnKeyboard = loopOnKeyboard;
|
|
139
|
+
return this;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
Dropdown.prototype.onChange= function(handler) {
|
|
143
|
+
this.on('change', handler);
|
|
144
|
+
return this;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
Dropdown.prototype.renderTrigger = function(renderFn) {
|
|
148
|
+
this.$description.renderTrigger = renderFn;
|
|
149
|
+
return this;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
Dropdown.prototype.renderSearch = function(renderFn) {
|
|
153
|
+
this.$description.renderSearch = renderFn;
|
|
154
|
+
return this;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
Dropdown.prototype.renderItem = function(renderFn) {
|
|
158
|
+
this.$description.renderItem = renderFn;
|
|
159
|
+
return this;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
Dropdown.prototype.renderMenu = function(renderFn) {
|
|
163
|
+
this.$description.renderMenu = renderFn;
|
|
164
|
+
return this;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
Dropdown.prototype.render = function(renderFn) {
|
|
168
|
+
this.$description.render = renderFn;
|
|
169
|
+
return this;
|
|
170
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
|
|
3
|
+
export default function DropdownDivider() {
|
|
4
|
+
if(!(this instanceof DropdownDivider)) {
|
|
5
|
+
return new DropdownDivider();
|
|
6
|
+
}
|
|
7
|
+
this.$description = {
|
|
8
|
+
type: 'divider'
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
BaseComponent.extends(DropdownDivider);
|
|
13
|
+
|
|
14
|
+
DropdownDivider.defaultTemplate = null;
|
|
15
|
+
|
|
16
|
+
DropdownDivider.use = function(template) {
|
|
17
|
+
DropdownDivider.defaultTemplate = template.divider;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
DropdownDivider.prototype.render = function(renderFn) {
|
|
22
|
+
this.$description.render = renderFn;
|
|
23
|
+
return this;
|
|
24
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import DropdownItem from "./DropdownItem";
|
|
2
|
+
import BaseComponent from "../BaseComponent";
|
|
3
|
+
import DropdownDivider from "./DropdownDivider";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default function DropdownGroup(config) {
|
|
7
|
+
if(!(this instanceof DropdownGroup)) {
|
|
8
|
+
return new DropdownGroup(config);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
DropdownItem.call(this, config);
|
|
12
|
+
|
|
13
|
+
Object.assign(this.$description, {
|
|
14
|
+
renderItem: config.renderItem || null,
|
|
15
|
+
items: config.items || []
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
BaseComponent.extends(DropdownGroup, DropdownItem);
|
|
20
|
+
|
|
21
|
+
DropdownGroup.prototype.group = function(groupBuilder) {
|
|
22
|
+
const item = new DropdownGroup();
|
|
23
|
+
groupBuilder && groupBuilder(item);
|
|
24
|
+
this.$description.items.push(item);
|
|
25
|
+
return this;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
DropdownGroup.prototype.divider = function() {
|
|
29
|
+
this.$description.items.push(new DropdownDivider());
|
|
30
|
+
return this;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
DropdownGroup.prototype.renderItem = function(renderFn) {
|
|
34
|
+
this.$description.renderItem = renderFn;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
DropdownGroup.prototype.render = function(renderFn) {
|
|
39
|
+
this.$description.render = renderFn;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
DropdownGroup.prototype.toNdElement = function() {
|
|
43
|
+
|
|
44
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default function DropdownItem(config = {}) {
|
|
5
|
+
if(!(this instanceof DropdownItem)) {
|
|
6
|
+
return new DropdownItem(config);
|
|
7
|
+
}
|
|
8
|
+
this.$description = {
|
|
9
|
+
icon: null,
|
|
10
|
+
content: null,
|
|
11
|
+
shortcuts: null,
|
|
12
|
+
value: null,
|
|
13
|
+
disabled: false,
|
|
14
|
+
data: null,
|
|
15
|
+
render: null,
|
|
16
|
+
...config
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
BaseComponent.extends(DropdownItem);
|
|
21
|
+
|
|
22
|
+
DropdownItem.prototype.value = function(value) {
|
|
23
|
+
this.$description.value = value;
|
|
24
|
+
return this;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
DropdownItem.prototype.getValue = function() {
|
|
28
|
+
return this.$description.value;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
DropdownItem.prototype.disabled = function(disabled = true) {
|
|
32
|
+
this.$description.disabled = disabled;
|
|
33
|
+
return this;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
DropdownItem.prototype.icon = function(icon) {
|
|
37
|
+
this.$description.icon = icon;
|
|
38
|
+
return this;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
DropdownItem.prototype.content = function(content) {
|
|
42
|
+
this.$description.content = content;
|
|
43
|
+
return this;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
DropdownItem.prototype.data = function(data) {
|
|
47
|
+
this.$description.data = data;
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
DropdownItem.prototype.getData = function() {
|
|
52
|
+
return this.$description.data;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
DropdownItem.prototype.shortcuts = function(shortcuts) {
|
|
56
|
+
this.$description.shortcuts = shortcuts;
|
|
57
|
+
return this;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
DropdownItem.prototype.render = function(renderFn) {
|
|
61
|
+
this.$description.render = renderFn;
|
|
62
|
+
return this;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
DropdownItem.prototype.$build = function() {
|
|
66
|
+
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
DropdownItem.prototype.toNdElement = function() {
|
|
70
|
+
|
|
71
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
|
|
3
|
+
export default function DropdownTrigger(config) {
|
|
4
|
+
if(!(this instanceof DropdownTrigger)) {
|
|
5
|
+
return new DropdownTrigger(config);
|
|
6
|
+
}
|
|
7
|
+
this.$description = {
|
|
8
|
+
icon: null,
|
|
9
|
+
content: null,
|
|
10
|
+
stateOpenIcon: null,
|
|
11
|
+
render: null,
|
|
12
|
+
isOpen: null,
|
|
13
|
+
...config
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
BaseComponent.extends(DropdownTrigger);
|
|
18
|
+
|
|
19
|
+
DropdownTrigger.defaultTemplate = null;
|
|
20
|
+
|
|
21
|
+
DropdownTrigger.use = function(template) {
|
|
22
|
+
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
DropdownTrigger.prototype.setIsOpen = function(isOpenObservable) {
|
|
26
|
+
this.$description.isOpen = isOpenObservable;
|
|
27
|
+
return this;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
DropdownTrigger.prototype.content = function(content) {
|
|
32
|
+
this.$description.content = content;
|
|
33
|
+
return this;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
DropdownTrigger.prototype.icon = function(icon) {
|
|
37
|
+
this.$description.icon = icon;
|
|
38
|
+
return this;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
DropdownTrigger.prototype.stateOpenIcon = function(openIcon) {
|
|
42
|
+
this.$description.stateOpenIcon = openIcon;
|
|
43
|
+
return this;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
DropdownTrigger.prototype.stateClosedIcon = function(closedIcon) {
|
|
47
|
+
this.$description.stateClosedIcon = closedIcon;
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
DropdownTrigger.prototype.render = function(renderFn) {
|
|
53
|
+
this.$description.render = renderFn;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
DropdownTrigger.prototype.$build = function() {
|
|
59
|
+
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
DropdownTrigger.prototype.toNdElement = function() {
|
|
63
|
+
|
|
64
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import DropdownDivider from "./DropdownDivider";
|
|
2
|
+
import Dropdown from "./Dropdown";
|
|
3
|
+
import DropdownGroup from "./DropdownGroup";
|
|
4
|
+
import DropdownItem from "./DropdownItem";
|
|
5
|
+
import DropdownTrigger from "./DropdownTrigger";
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
Dropdown,
|
|
9
|
+
DropdownDivider,
|
|
10
|
+
DropdownGroup,
|
|
11
|
+
DropdownItem,
|
|
12
|
+
DropdownTrigger
|
|
13
|
+
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import {debounce} from "../../core/utils/helpers";
|
|
2
|
-
import EventEmitter from "
|
|
2
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
3
|
import {Validator, Observable as $ } from "../../../index";
|
|
4
|
-
import NativeDocumentError from "
|
|
5
|
-
import
|
|
4
|
+
import NativeDocumentError from "../../../src/core/errors/NativeDocumentError";
|
|
5
|
+
import BaseComponent from "../BaseComponent";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @param { {data: Observable } } configs
|
|
9
9
|
* @constructor
|
|
10
10
|
*/
|
|
11
11
|
export default function FormControl(configs) {
|
|
12
|
+
if(!(this instanceof FormControl)) {
|
|
13
|
+
return new FormControl(configs);
|
|
14
|
+
}
|
|
12
15
|
EventEmitter.call(this);
|
|
13
16
|
|
|
14
17
|
this.$element = null;
|
|
@@ -20,12 +23,17 @@ export default function FormControl(configs) {
|
|
|
20
23
|
this.$isValid = $(false);
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
FormControl.defaultLayoutTemplate = null;
|
|
27
|
+
|
|
28
|
+
FormControl.use = function(template) {
|
|
29
|
+
FormControl.defaultLayoutTemplate = template.formControl;
|
|
30
|
+
};
|
|
31
|
+
|
|
23
32
|
FormControl.create = function (configs) {
|
|
24
33
|
return new FormControl(configs);
|
|
25
34
|
};
|
|
26
35
|
|
|
27
|
-
FormControl
|
|
28
|
-
FormControl.prototype.constructor = FormControl;
|
|
36
|
+
BaseComponent.extends(FormControl, EventEmitter);
|
|
29
37
|
|
|
30
38
|
Object.defineProperty(FormControl.prototype, 'isDirty', {
|
|
31
39
|
get() { return this.$isDirty; }
|
|
@@ -53,21 +61,21 @@ FormControl.prototype.field = function(field) {
|
|
|
53
61
|
this.$fields.set(name, field);
|
|
54
62
|
|
|
55
63
|
const dataSource = this.$configs?.data?.[name];
|
|
56
|
-
if(dataSource) {
|
|
57
|
-
|
|
58
|
-
field.checked(dataSource)
|
|
59
|
-
}
|
|
60
|
-
else field.value(dataSource);
|
|
64
|
+
if(!dataSource) {
|
|
65
|
+
return this;
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
value.subscribe(() => {
|
|
68
|
+
if(Validator.isObservable(dataSource)) {
|
|
69
|
+
field.model(dataSource);
|
|
70
|
+
dataSource.subscribe(() => {
|
|
67
71
|
this.$isDirty.set(true);
|
|
68
|
-
this.emit('change', name,
|
|
72
|
+
this.emit('change', name, dataSource, field);
|
|
69
73
|
});
|
|
74
|
+
return this;
|
|
70
75
|
}
|
|
76
|
+
|
|
77
|
+
field.value(dataSource);
|
|
78
|
+
|
|
71
79
|
return this;
|
|
72
80
|
};
|
|
73
81
|
|
|
@@ -145,7 +153,7 @@ FormControl.prototype.enable = function() {
|
|
|
145
153
|
FormControl.prototype.values = function() {
|
|
146
154
|
const values = {};
|
|
147
155
|
for(const [_, field] of this.$fields) {
|
|
148
|
-
values[field.$description.name] = field.
|
|
156
|
+
values[field.$description.name] = field.value();
|
|
149
157
|
}
|
|
150
158
|
return values;
|
|
151
159
|
};
|
|
@@ -223,13 +231,13 @@ FormControl.prototype.onValidationError = function(callback) {
|
|
|
223
231
|
};
|
|
224
232
|
|
|
225
233
|
|
|
226
|
-
FormControl.prototype
|
|
234
|
+
FormControl.prototype.$build = function() {
|
|
227
235
|
const fieldsObject = {};
|
|
228
236
|
for (const [name, field] of this.$fields) {
|
|
229
237
|
fieldsObject[name] = field;
|
|
230
238
|
}
|
|
231
239
|
|
|
232
|
-
const layoutFn = this.$layout ||
|
|
240
|
+
const layoutFn = this.$layout || FormControl.defaultLayoutTemplate;
|
|
233
241
|
|
|
234
242
|
const form = layoutFn({
|
|
235
243
|
fields: fieldsObject,
|
|
@@ -242,6 +250,6 @@ FormControl.prototype.toNdElement = function() {
|
|
|
242
250
|
form.nd.onSubmit(async function(event) {
|
|
243
251
|
return await self.$handleSubmit(event);
|
|
244
252
|
});
|
|
245
|
-
|
|
246
|
-
return
|
|
253
|
+
|
|
254
|
+
return form;
|
|
247
255
|
};
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import {Input, Label, Select
|
|
1
|
+
import {Input, Label, Select} from "../../../../elements";
|
|
2
2
|
import { $ } from "../../../../index";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
const ErrorDisplayer = (errors) => {
|
|
6
5
|
|
|
7
|
-
const shouldDisplayError = $.computed(() => {
|
|
8
|
-
const val = errors.val();
|
|
9
|
-
return (val && val.length > 0);
|
|
10
|
-
}, [errors]);
|
|
11
|
-
|
|
12
|
-
return ShowIf(shouldDisplayError, () => {
|
|
13
|
-
const val = errors.val();
|
|
14
|
-
if(typeof val === 'string') return Div({ class: 'form-control-error' }, val);
|
|
15
|
-
return Div({ class: 'form-control-error' },
|
|
16
|
-
val.map(error => Div({ class: 'form-control-error-item' }, error))
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
6
|
|
|
21
7
|
export default function DefaultRender(field) {
|
|
22
8
|
const description = field?.toJSON();
|