native-document 1.0.138 → 1.0.140
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 +1 -1
- package/devtools/ComponentRegistry.js +3 -2
- package/dist/native-document.components.min.css +1 -0
- package/dist/native-document.components.min.js +11506 -8566
- package/dist/native-document.dev.js +2645 -2166
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/index.js +1 -0
- package/package.json +5 -2
- package/rollup.config.js +5 -2
- package/src/components/$traits/has-draggable/HasDraggable.js +69 -0
- package/src/components/$traits/has-draggable/has-draggable.css +8 -0
- package/src/components/$traits/{HasItems.js → has-items/HasItems.js} +2 -11
- package/src/components/$traits/has-position/HasFullPosition.js +51 -0
- package/src/components/$traits/has-position/HasPosition.js +23 -0
- package/src/components/$traits/has-resizable/HasResizable.js +113 -0
- package/src/components/$traits/has-resizable/has-resizable.css +121 -0
- package/src/components/$traits/has-validation/HasValidation.js +86 -0
- package/src/components/BaseComponent.js +109 -4
- package/src/components/accordion/Accordion.js +37 -31
- package/src/components/accordion/AccordionItem.js +14 -21
- package/src/components/alert/Alert.js +48 -40
- package/src/components/avatar/Avatar.js +4 -3
- package/src/components/avatar/AvatarGroup.js +8 -2
- package/src/components/badge/Badge.js +7 -7
- package/src/components/base-component.css +0 -0
- package/src/components/breadcrumb/BreadCrumb.js +30 -21
- package/src/components/button/Button.js +3 -14
- package/src/components/context-menu/ContextMenu.js +49 -26
- package/src/components/dropdown/Dropdown.js +172 -34
- package/src/components/dropdown/DropdownDivider.js +4 -3
- package/src/components/dropdown/DropdownGroup.js +19 -19
- package/src/components/dropdown/DropdownItem.js +24 -18
- package/src/components/dropdown/helpers.js +52 -0
- package/src/components/form/FormControl.js +207 -108
- package/src/components/form/field/Field.js +106 -174
- package/src/components/form/field/FieldCollection.js +110 -203
- package/src/components/form/field/types/AutocompleteField.js +26 -5
- package/src/components/form/field/types/CheckboxField.js +4 -4
- package/src/components/form/field/types/CheckboxGroupField.js +11 -5
- package/src/components/form/field/types/ColorField.js +4 -4
- package/src/components/form/field/types/DateField.js +110 -18
- package/src/components/form/field/types/EmailField.js +2 -2
- package/src/components/form/field/types/FileField.js +87 -21
- package/src/components/form/field/types/HiddenField.js +4 -4
- package/src/components/form/field/types/ImageField.js +4 -4
- package/src/components/form/field/types/NumberField.js +5 -5
- package/src/components/form/field/types/PasswordField.js +28 -6
- package/src/components/form/field/types/RadioField.js +12 -8
- package/src/components/form/field/types/RangeField.js +29 -5
- package/src/components/form/field/types/SearchField.js +4 -4
- package/src/components/form/field/types/SelectField.js +75 -8
- package/src/components/form/field/types/StringField.js +4 -4
- package/src/components/form/field/types/TelField.js +4 -4
- package/src/components/form/field/types/TextAreaField.js +7 -5
- package/src/components/form/field/types/TimeField.js +52 -6
- package/src/components/form/field/types/UrlField.js +4 -5
- package/src/components/form/field/types/file-field-mode/FileAvatarMode.js +104 -0
- package/src/components/form/field/types/file-field-mode/FileDropzoneMode.js +59 -0
- package/src/components/form/field/types/file-field-mode/FileItemPreview.js +74 -0
- package/src/components/form/field/types/file-field-mode/FileNativeMode.js +21 -0
- package/src/components/form/field/types/file-field-mode/FileUploadButtonMode.js +59 -0
- package/src/components/form/field/types/file-field-mode/FileWallMode.js +53 -0
- package/src/components/form/index.js +14 -2
- package/src/components/form/validation/Validation.js +9 -0
- package/src/components/list/List.js +1 -1
- package/src/components/list/ListGroup.js +1 -1
- package/src/components/menu/HasMenuItem.js +133 -0
- package/src/components/menu/Menu.js +47 -56
- package/src/components/menu/MenuGroup.js +36 -8
- package/src/components/menu/MenuItem.js +24 -10
- package/src/components/menu/MenuLink.js +2 -0
- package/src/components/modal/Modal.js +153 -23
- package/src/components/pagination/Pagination.js +55 -21
- package/src/components/popover/Popover.js +127 -40
- package/src/components/progress/Progress.js +14 -24
- package/src/components/skeleton/Skeleton.js +36 -13
- package/src/components/slider/Slider.js +96 -70
- package/src/components/spinner/Spinner.js +4 -2
- package/src/components/splitter/Splitter.js +15 -8
- package/src/components/splitter/SplitterGutter.js +28 -7
- package/src/components/splitter/SplitterPanel.js +9 -15
- package/src/components/splitter/index.js +3 -1
- package/src/components/stacks/AbsoluteStack.js +33 -0
- package/src/components/stacks/FixedStack.js +33 -0
- package/src/components/stacks/PositionStack.js +146 -0
- package/src/components/stacks/RelativeStack.js +33 -0
- package/src/components/{layouts → stacks}/Stack.js +22 -3
- package/src/components/{layouts → stacks}/index.js +6 -4
- package/src/components/stepper/Stepper.js +159 -67
- package/src/components/stepper/StepperStep.js +49 -12
- package/src/components/switch/Switch.js +59 -29
- package/src/components/switch/index.js +6 -0
- package/src/components/table/Column.js +22 -26
- package/src/components/table/ColumnGroup.js +4 -13
- package/src/components/table/DataTable.js +388 -103
- package/src/components/table/SimpleTable.js +28 -143
- package/src/components/tabs/Tabs.js +142 -44
- package/src/components/toast/Toast.js +40 -35
- package/src/components/tooltip/Tooltip.js +152 -35
- package/src/core/data/ObservableArray.js +94 -30
- package/src/core/data/ObservableChecker.js +20 -75
- package/src/core/data/ObservableItem.js +35 -3
- package/src/core/data/observable-helpers/computed.js +2 -1
- package/src/core/data/observable-helpers/object.js +13 -8
- package/src/core/data/observable-helpers/observable.is-to.js +196 -0
- package/src/core/elements/anchor/anchor.js +3 -2
- package/src/core/elements/control/for-each-array.js +44 -30
- package/src/core/elements/control/for-each.js +6 -3
- package/src/core/elements/control/show-if.js +11 -6
- package/src/core/elements/control/switch.js +2 -1
- package/src/core/elements/index.js +1 -1
- package/src/core/elements/svg.js +61 -0
- package/src/core/utils/HasEventEmitter.js +6 -0
- package/src/core/utils/debug-manager.js +2 -5
- package/src/core/utils/filters/standard.js +2 -1
- package/src/core/utils/property-accumulator.js +35 -6
- package/src/core/utils/shortcut-manager.js +242 -0
- package/src/core/utils/validator.js +1 -1
- package/src/core/wrappers/AttributesWrapper.js +41 -4
- package/src/core/wrappers/DocumentObserver.js +0 -1
- package/src/core/wrappers/HtmlElementWrapper.js +1 -1
- package/src/core/wrappers/NDElement.js +15 -2
- package/src/core/wrappers/SvgElementWrapper.js +15 -0
- package/src/core/wrappers/prototypes/attributes-extensions.js +4 -1
- package/src/core/wrappers/prototypes/nd-element-extensions.js +8 -1
- package/src/router/Router.js +0 -1
- package/src/ui/components/accordion/AccordionItemRender.js +63 -0
- package/src/ui/components/accordion/AccordionRender.js +34 -0
- package/src/ui/components/accordion/accordion.css +121 -0
- package/src/ui/components/alert/AlertRender.js +80 -0
- package/src/ui/components/alert/alert.css +163 -0
- package/src/ui/components/avatar/avata-group/AvatarGroupRender.js +49 -0
- package/src/ui/components/avatar/avata-group/avatar-group.css +38 -0
- package/src/ui/components/avatar/avatar/AvatarRender.js +87 -0
- package/src/ui/components/avatar/avatar/avatar.css +189 -0
- package/src/ui/components/badge/BadgeRender.js +24 -0
- package/src/ui/components/badge/badge.css +168 -0
- package/src/ui/components/breadcrumb/BreadcrumbRender.js +43 -0
- package/src/ui/components/breadcrumb/breadcrumb.css +55 -0
- package/src/ui/components/button/ButtonRender.js +65 -0
- package/src/ui/components/button/button.css +288 -354
- package/src/ui/components/contextmenu/ContextmenuRender.js +70 -0
- package/src/ui/components/contextmenu/contextmenu.css +36 -0
- package/src/ui/components/divider/DividerRender.js +70 -0
- package/src/ui/components/divider/divider.css +70 -0
- package/src/ui/components/dropdown/DropdownRender.js +92 -0
- package/src/ui/components/dropdown/divider/DropdownDividerRender.js +9 -0
- package/src/ui/components/dropdown/divider/dropdown-divider.css +0 -0
- package/src/ui/components/dropdown/dropdown.css +179 -0
- package/src/ui/components/dropdown/group/DropdownGroupRender.js +23 -0
- package/src/ui/components/dropdown/group/dropdown-group.css +0 -0
- package/src/ui/components/dropdown/item/DropdownItemRender.js +29 -0
- package/src/ui/components/dropdown/item/dropdown-item.css +0 -0
- package/src/ui/components/form/FieldCollectionRender.js +110 -0
- package/src/ui/components/form/FormControlRender.js +84 -0
- package/src/ui/components/form/field-collection.css +55 -0
- package/src/ui/components/form/fields/AutocompleteFieldRender.js +143 -0
- package/src/ui/components/form/fields/CheckboxFieldRender.js +59 -0
- package/src/ui/components/form/fields/CheckboxGroupFieldRender.js +92 -0
- package/src/ui/components/form/fields/ColorFieldRender.js +30 -0
- package/src/ui/components/form/fields/DateFieldRender.js +154 -0
- package/src/ui/components/form/fields/EmailFieldRender.js +5 -0
- package/src/ui/components/form/fields/FieldRender.js +117 -0
- package/src/ui/components/form/fields/FileFieldRender.js +41 -0
- package/src/ui/components/form/fields/HiddenFieldRender.js +14 -0
- package/src/ui/components/form/fields/ImageFieldRender.js +0 -0
- package/src/ui/components/form/fields/NumberFieldRender.js +52 -0
- package/src/ui/components/form/fields/PasswordFieldRender.js +65 -0
- package/src/ui/components/form/fields/RadioFieldRender.js +77 -0
- package/src/ui/components/form/fields/RangeFieldRender.js +121 -0
- package/src/ui/components/form/fields/SelectFieldRender.js +248 -0
- package/src/ui/components/form/fields/SliderFieldRender.js +359 -0
- package/src/ui/components/form/fields/StringFieldRender.js +6 -0
- package/src/ui/components/form/fields/TelFieldRender.js +6 -0
- package/src/ui/components/form/fields/TextAreaFieldRender.js +96 -0
- package/src/ui/components/form/fields/TimeFieldRender.js +141 -0
- package/src/ui/components/form/fields/UrlFieldRender.js +6 -0
- package/src/ui/components/form/fields/date-field.css +32 -0
- package/src/ui/components/form/fields/field.css +402 -0
- package/src/ui/components/form/fields/file-field.css +79 -0
- package/src/ui/components/form/fields/password-field.css +50 -0
- package/src/ui/components/form/fields/range-field.css +120 -0
- package/src/ui/components/form/fields/slider.css +195 -0
- package/src/ui/components/form/file-upload-mode/FileAvatarModeRender.js +143 -0
- package/src/ui/components/form/file-upload-mode/FileDropzoneModeRender.js +108 -0
- package/src/ui/components/form/file-upload-mode/FileNativeModeRender.js +22 -0
- package/src/ui/components/form/file-upload-mode/FileUploadButtonModeRender.js +89 -0
- package/src/ui/components/form/file-upload-mode/FileWallModeRender.js +91 -0
- package/src/ui/components/form/file-upload-mode/file-avatar-mode.css +139 -0
- package/src/ui/components/form/file-upload-mode/file-dropzone-mode.css +88 -0
- package/src/ui/components/form/file-upload-mode/file-upload-button-mode.css +44 -0
- package/src/ui/components/form/file-upload-mode/file-wall-mode.css +88 -0
- package/src/ui/components/form/form-control.css +40 -0
- package/src/ui/components/form/helpers.js +112 -0
- package/src/ui/components/form/index.js +61 -0
- package/src/ui/components/menu/MenuDividerRender.js +12 -0
- package/src/ui/components/menu/MenuGroupRender.js +60 -0
- package/src/ui/components/menu/MenuItemRender.js +57 -0
- package/src/ui/components/menu/MenuLinkRender.js +55 -0
- package/src/ui/components/menu/MenuRender.js +21 -0
- package/src/ui/components/menu/helpers.js +121 -0
- package/src/ui/components/menu/menu.css +308 -0
- package/src/ui/components/modal/ModalRender.js +119 -0
- package/src/ui/components/modal/modal.css +156 -0
- package/src/ui/components/pagination/PaginationRender.js +112 -0
- package/src/ui/components/pagination/pagination.css +63 -0
- package/src/ui/components/popover/PopoverRender.js +234 -0
- package/src/ui/components/popover/popover.css +139 -0
- package/src/ui/components/progress/ProgressRender.js +168 -0
- package/src/ui/components/progress/progress.css +197 -0
- package/src/ui/components/skeleton/SkeletonRender.js +79 -0
- package/src/ui/components/skeleton/skeleton.css +154 -0
- package/src/ui/components/spinner/SpinnerRender.js +46 -0
- package/src/ui/components/spinner/spinner.css +152 -0
- package/src/ui/components/splitter/SplitterGutterRender.js +94 -0
- package/src/ui/components/splitter/SplitterPanelRender.js +38 -0
- package/src/ui/components/splitter/SplitterRender.js +74 -0
- package/src/ui/components/splitter/splitter.css +128 -0
- package/src/ui/components/stacks/PositionStackRender.js +38 -0
- package/src/ui/components/stacks/StackRender.js +42 -0
- package/src/ui/components/stacks/absolute-stack/AbsoluteStackRender.js +5 -0
- package/src/ui/components/stacks/fixed-stack/FixedStackRender.js +5 -0
- package/src/ui/components/stacks/h-stack/HStackRender.js +7 -0
- package/src/ui/components/stacks/h-stack/h-stack.css +4 -0
- package/src/ui/components/stacks/index.js +15 -0
- package/src/ui/components/stacks/position-stack.css +62 -0
- package/src/ui/components/stacks/relative-stack/RelativeStackRender.js +7 -0
- package/src/ui/components/stacks/relative-stack/relative-stack.css +3 -0
- package/src/ui/components/stacks/stack.css +78 -0
- package/src/ui/components/stacks/v-stack/VStackRender.js +5 -0
- package/src/ui/components/stacks/v-stack/v-stack.css +4 -0
- package/src/ui/components/stepper/StepperRender.js +70 -0
- package/src/ui/components/stepper/StepperStepRender.js +67 -0
- package/src/ui/components/stepper/stepper.css +359 -0
- package/src/ui/components/switch/SwitchRender.js +82 -0
- package/src/ui/components/switch/switch.css +143 -0
- package/src/ui/components/table/data-table/DataTableRender.js +49 -0
- package/src/ui/components/table/data-table/bulk-actions.js +35 -0
- package/src/ui/components/table/data-table/data-table.css +246 -0
- package/src/ui/components/table/data-table/pagination.js +56 -0
- package/src/ui/components/table/data-table/tables.js +363 -0
- package/src/ui/components/table/data-table/toolbar.js +67 -0
- package/src/ui/components/table/simple-table/SimpleTableRender.js +188 -0
- package/src/ui/components/table/simple-table/simple-table.css +50 -0
- package/src/ui/components/tabs/TabsRender.js +226 -0
- package/src/ui/components/tabs/tabs.css +253 -0
- package/src/ui/components/toast/ToastRender.js +98 -0
- package/src/ui/components/toast/toast.css +201 -0
- package/src/ui/components/tooltip/TooltipRender.js +8 -0
- package/src/ui/components/tooltip/tooltip.css +113 -0
- package/src/ui/index.js +82 -0
- package/src/ui/tokens/colors-dark.scss +2 -1
- package/src/ui/tokens/reset.scss +3 -0
- package/types/control-flow.d.ts +2 -2
- package/src/components/layouts/ZStack.js +0 -41
- package/src/ui/components/button/button.render.js +0 -63
- /package/src/components/{layouts → stacks}/HStack.js +0 -0
- /package/src/components/{layouts → stacks}/VStack.js +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
|
|
3
|
+
export default function PositionStack(content, props = {}) {
|
|
4
|
+
if(!(this instanceof PositionStack)) {
|
|
5
|
+
return new PositionStack(content, props);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
BaseComponent.call(this, props);
|
|
9
|
+
|
|
10
|
+
this.$description = {
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
content: content,
|
|
13
|
+
top: null,
|
|
14
|
+
right: null,
|
|
15
|
+
bottom: null,
|
|
16
|
+
left: null,
|
|
17
|
+
width: null,
|
|
18
|
+
height: null,
|
|
19
|
+
zIndex: null,
|
|
20
|
+
anchor: null,
|
|
21
|
+
props
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
BaseComponent.extends(PositionStack);
|
|
26
|
+
|
|
27
|
+
PositionStack.defaultTemplate = null;
|
|
28
|
+
PositionStack.use = function(template) {
|
|
29
|
+
PositionStack.defaultTemplate = template;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
PositionStack.prototype.top = function(value) {
|
|
33
|
+
this.$description.top = value;
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
PositionStack.prototype.right = function(value) {
|
|
38
|
+
this.$description.right = value;
|
|
39
|
+
return this;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
PositionStack.prototype.bottom = function(value) {
|
|
43
|
+
this.$description.bottom = value;
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
PositionStack.prototype.left = function(value) {
|
|
48
|
+
this.$description.left = value;
|
|
49
|
+
return this;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
PositionStack.prototype.fill = function() {
|
|
53
|
+
this.$description.anchor = 'fill';
|
|
54
|
+
return this;
|
|
55
|
+
};
|
|
56
|
+
PositionStack.prototype.topLeading = function() {
|
|
57
|
+
this.$description.anchor = 'top-leading';
|
|
58
|
+
return this;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
PositionStack.prototype.atTopCenter = function() {
|
|
62
|
+
this.$description.anchor = 'top-center';
|
|
63
|
+
return this;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
PositionStack.prototype.atTopTrailing = function() {
|
|
67
|
+
this.$description.anchor = 'top-trailing';
|
|
68
|
+
return this;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
PositionStack.prototype.atCenterLeading = function() {
|
|
72
|
+
this.$description.anchor = 'center-leading';
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
PositionStack.prototype.atCenter = function() {
|
|
77
|
+
this.$description.anchor = 'center';
|
|
78
|
+
return this;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
PositionStack.prototype.atCenterTrailing = function() {
|
|
82
|
+
this.$description.anchor = 'center-trailing';
|
|
83
|
+
return this;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
PositionStack.prototype.atBottomLeading = function() {
|
|
87
|
+
this.$description.anchor = 'bottom-leading';
|
|
88
|
+
return this;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
PositionStack.prototype.atBottomCenter = function() {
|
|
92
|
+
this.$description.anchor = 'bottom-center';
|
|
93
|
+
return this;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
PositionStack.prototype.atBottomTrailing = function() {
|
|
97
|
+
this.$description.anchor = 'bottom-trailing';
|
|
98
|
+
return this;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
PositionStack.prototype.width = function(value) {
|
|
102
|
+
this.$description.width = value;
|
|
103
|
+
return this;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
PositionStack.prototype.height = function(value) {
|
|
107
|
+
this.$description.height = value;
|
|
108
|
+
return this;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
PositionStack.prototype.size = function(width, height) {
|
|
112
|
+
this.$description.width = width;
|
|
113
|
+
this.$description.height = height ?? width;
|
|
114
|
+
return this;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
PositionStack.prototype.fullWidth = function() {
|
|
118
|
+
this.$description.width = '100%';
|
|
119
|
+
return this;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
PositionStack.prototype.fullHeight = function() {
|
|
123
|
+
this.$description.height = '100%';
|
|
124
|
+
return this;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
PositionStack.prototype.fullSize = function() {
|
|
128
|
+
this.$description.width = '100%';
|
|
129
|
+
this.$description.height = '100%';
|
|
130
|
+
return this;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
PositionStack.prototype.zIndex = function(value) {
|
|
134
|
+
this.$description.zIndex = value;
|
|
135
|
+
return this;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
PositionStack.prototype.above = function(zIndex = 100) {
|
|
139
|
+
this.$description.zIndex = zIndex;
|
|
140
|
+
return this;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
PositionStack.prototype.below = function() {
|
|
144
|
+
this.$description.zIndex = -1;
|
|
145
|
+
return this;
|
|
146
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import PositionStack from "./PositionStack";
|
|
3
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
4
|
+
|
|
5
|
+
export default function RelativeStack(content, props = {}) {
|
|
6
|
+
if(!(this instanceof RelativeStack)) {
|
|
7
|
+
return new RelativeStack(content, props);
|
|
8
|
+
}
|
|
9
|
+
PositionStack.call(this, content, props);
|
|
10
|
+
this.$description.position = 'relative';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
BaseComponent.extends(RelativeStack, PositionStack);
|
|
14
|
+
|
|
15
|
+
RelativeStack.defaultTemplate = null;
|
|
16
|
+
|
|
17
|
+
RelativeStack.use = function(template) {
|
|
18
|
+
RelativeStack.defaultTemplate = template;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
RelativeStack.preset = function(name, callback) {
|
|
22
|
+
if(RelativeStack.prototype[name] || RelativeStack[name]) {
|
|
23
|
+
DebugManager.warn(`Warning: the ${name} method already exists in RelativeStack.`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
RelativeStack[name] = (content, props) => callback(new RelativeStack(content, props));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
RelativeStack.presets = function(presets) {
|
|
30
|
+
for(const name in presets) {
|
|
31
|
+
RelativeStack.preset(name, presets[name]);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -12,10 +12,14 @@ export default function Stack(content, props = {}) {
|
|
|
12
12
|
this.$description = {
|
|
13
13
|
orientation: 'horizontal',
|
|
14
14
|
content: content,
|
|
15
|
-
spacing:
|
|
15
|
+
spacing: null,
|
|
16
16
|
alignment: 'center',
|
|
17
|
-
justifyContent: '
|
|
18
|
-
|
|
17
|
+
justifyContent: 'between',
|
|
18
|
+
wrap: false,
|
|
19
|
+
grow: false,
|
|
20
|
+
shrink: false,
|
|
21
|
+
reverse: false,
|
|
22
|
+
props,
|
|
19
23
|
};
|
|
20
24
|
}
|
|
21
25
|
|
|
@@ -27,6 +31,21 @@ Stack.prototype.wrap = function(enabled = true) {
|
|
|
27
31
|
return this;
|
|
28
32
|
};
|
|
29
33
|
|
|
34
|
+
Stack.prototype.grow = function(enabled = true) {
|
|
35
|
+
this.$description.grow = enabled;
|
|
36
|
+
return this;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Stack.prototype.reverse = function(enabled = true) {
|
|
40
|
+
this.$description.reverse = enabled;
|
|
41
|
+
return this;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Stack.prototype.shrink = function(enabled = true) {
|
|
45
|
+
this.$description.shrink = enabled;
|
|
46
|
+
return this;
|
|
47
|
+
};
|
|
48
|
+
|
|
30
49
|
Stack.prototype.spacing = function(value) {
|
|
31
50
|
this.$description.spacing = value;
|
|
32
51
|
return this;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import Stack from "./Stack";
|
|
2
2
|
import VStack from "./VStack";
|
|
3
|
-
import
|
|
3
|
+
import FixedStack from "./FixedStack";
|
|
4
4
|
import HStack from "./HStack";
|
|
5
|
+
import AbsoluteStack from "./AbsoluteStack";
|
|
6
|
+
import RelativeStack from "./RelativeStack";
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
const Row = HStack;
|
|
8
10
|
const Col = VStack;
|
|
9
|
-
const Overlay = ZStack;
|
|
10
11
|
|
|
11
12
|
export {
|
|
12
13
|
Stack,
|
|
13
14
|
HStack,
|
|
14
15
|
VStack,
|
|
15
|
-
|
|
16
|
+
FixedStack,
|
|
17
|
+
RelativeStack,
|
|
18
|
+
AbsoluteStack,
|
|
16
19
|
Row,
|
|
17
20
|
Col,
|
|
18
|
-
Overlay
|
|
19
21
|
}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
2
|
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
3
3
|
import {$, Validator} from "../../../index";
|
|
4
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
5
|
+
import StepperStep from "./StepperStep";
|
|
4
6
|
|
|
5
|
-
export default function Stepper(
|
|
7
|
+
export default function Stepper(props = {}) {
|
|
6
8
|
if(!(this instanceof Stepper)) {
|
|
7
|
-
return new Stepper(
|
|
9
|
+
return new Stepper(props);
|
|
8
10
|
}
|
|
9
11
|
|
|
12
|
+
BaseComponent.call(this, props);
|
|
13
|
+
|
|
10
14
|
this.$description = {
|
|
11
|
-
steps:
|
|
15
|
+
steps: $.array(),
|
|
16
|
+
visibleSteps: $.array(),
|
|
12
17
|
currentStep: $(0),
|
|
13
18
|
orientation: 'horizontal',
|
|
14
19
|
linear: true,
|
|
15
20
|
alternativeLabel: false,
|
|
16
|
-
editable:
|
|
21
|
+
editable: $(true),
|
|
17
22
|
showNumbers: true,
|
|
18
23
|
showConnector: true,
|
|
19
24
|
data: null,
|
|
@@ -21,67 +26,102 @@ export default function Stepper(config = {}) {
|
|
|
21
26
|
renderStepIndicatorConnector: null,
|
|
22
27
|
renderContent: null,
|
|
23
28
|
render: null,
|
|
24
|
-
|
|
29
|
+
position: 'bottom',
|
|
30
|
+
props
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
this.$element = null;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
BaseComponent.extends(Stepper
|
|
36
|
+
BaseComponent.extends(Stepper);
|
|
37
|
+
BaseComponent.use(Stepper, HasEventEmitter);
|
|
31
38
|
|
|
32
39
|
Stepper.defaultTemplate = null;
|
|
33
|
-
Stepper.defaultStepTemplate = null;
|
|
34
|
-
Stepper.defaultStepConnectorTemplate = null;
|
|
35
|
-
Stepper.defaultContentTemplate = null;
|
|
36
40
|
|
|
37
41
|
Stepper.use = function(template) {
|
|
38
|
-
Stepper.defaultTemplate = template
|
|
39
|
-
Stepper.defaultStepIndicatorTemplate = template.stepperStepIndicator;
|
|
40
|
-
Stepper.defaultContentTemplate = template.stepperContent;
|
|
41
|
-
Stepper.defaultStepIndicatorConnectorTemplate = template.stepperStepIndicatorConnector;
|
|
42
|
+
Stepper.defaultTemplate = template;
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
Stepper.
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
Stepper.preset = function(name, callback) {
|
|
46
|
+
if (Stepper.prototype[name] || Stepper[name]) {
|
|
47
|
+
DebugManager.warn(`Warning: the ${name} method already exist in Stepper.`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
Stepper[name] = (props) => callback(new Stepper(props));
|
|
47
51
|
};
|
|
48
52
|
|
|
49
|
-
Stepper.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return this;
|
|
53
|
+
Stepper.presets = function(presets) {
|
|
54
|
+
for (const name in presets) {
|
|
55
|
+
Stepper.preset(name, presets[name]);
|
|
53
56
|
}
|
|
54
|
-
this.$description.steps.set(steps);
|
|
55
|
-
return this;
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
Stepper.prototype
|
|
59
|
-
this.$description.steps.push(step);
|
|
60
|
-
return this;
|
|
61
|
-
};
|
|
59
|
+
Stepper.prototype.$originalBuild = BaseComponent.prototype.$build;
|
|
62
60
|
|
|
63
|
-
Stepper.prototype
|
|
61
|
+
Stepper.prototype.$build = function() {
|
|
62
|
+
const visibleSteps = this.$description.visibleSteps;
|
|
64
63
|
const steps = this.$description.steps;
|
|
65
|
-
if (Array.isArray(steps)) {
|
|
66
|
-
steps.length = 0;
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
64
|
|
|
70
|
-
steps.
|
|
71
|
-
|
|
65
|
+
steps.forEach(step => {
|
|
66
|
+
if(!step.$description.visibility) {
|
|
67
|
+
visibleSteps.push(step);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if(step.$description.visibility.val()) {
|
|
71
|
+
visibleSteps.push(step);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
step.$description.visibility.subscribe((value) => {
|
|
75
|
+
if(!value) {
|
|
76
|
+
visibleSteps.removeItem(step);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const originalIndex = steps.indexOf(step);
|
|
80
|
+
let stepBefore = null;
|
|
81
|
+
|
|
82
|
+
for (let i = 0; i < visibleSteps.length; i++) {
|
|
83
|
+
const itemStep = visibleSteps.get(i);
|
|
84
|
+
if (steps.indexOf(itemStep) < originalIndex) {
|
|
85
|
+
stepBefore = itemStep
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if(!stepBefore) {
|
|
91
|
+
visibleSteps.push(step);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
visibleSteps.insertAfter(step, stepBefore);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const updateStateIndexes = () => {
|
|
99
|
+
this.$description.visibleSteps.forEach((step, index) => step.$setIndex(index));
|
|
100
|
+
};
|
|
101
|
+
this.$description.visibleSteps.subscribe(updateStateIndexes);
|
|
102
|
+
updateStateIndexes();
|
|
103
|
+
return this.$originalBuild();
|
|
72
104
|
};
|
|
73
105
|
|
|
74
|
-
Stepper.prototype.
|
|
75
|
-
|
|
106
|
+
Stepper.prototype.step = function(step) {
|
|
107
|
+
let finalStep = null;
|
|
108
|
+
if(typeof step === 'function') {
|
|
109
|
+
finalStep = new StepperStep(null);
|
|
110
|
+
step(finalStep, this);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
finalStep = (step instanceof StepperStep)
|
|
114
|
+
? step
|
|
115
|
+
: (new StepperStep(step.label)).setDescription(step);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.$description.steps.push(finalStep);
|
|
76
119
|
return this;
|
|
77
120
|
};
|
|
78
121
|
|
|
79
|
-
Stepper.prototype.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
this.$description.steps.splice(index, 1);
|
|
122
|
+
Stepper.prototype.clear = function() {
|
|
123
|
+
this.$description.steps.clear();
|
|
124
|
+
this.$description.visibleSteps.clear();
|
|
85
125
|
return this;
|
|
86
126
|
};
|
|
87
127
|
|
|
@@ -115,7 +155,7 @@ Stepper.prototype.nonLinear = function() {
|
|
|
115
155
|
};
|
|
116
156
|
|
|
117
157
|
Stepper.prototype.editable = function(editable = true) {
|
|
118
|
-
this.$description.editable
|
|
158
|
+
this.$description.editable.set(editable);
|
|
119
159
|
return this;
|
|
120
160
|
};
|
|
121
161
|
|
|
@@ -140,50 +180,76 @@ Stepper.prototype.data = function(data) {
|
|
|
140
180
|
return this;
|
|
141
181
|
};
|
|
142
182
|
|
|
143
|
-
Stepper.prototype.next = function() {
|
|
144
|
-
const
|
|
145
|
-
const total = this.$description.
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
183
|
+
Stepper.prototype.next = async function() {
|
|
184
|
+
const currentIdx = this.$description.currentStep.val();
|
|
185
|
+
const total = this.$description.visibleSteps.length;
|
|
186
|
+
|
|
187
|
+
if (currentIdx === total - 1) {
|
|
188
|
+
const lastStep = this.$description.visibleSteps.at(currentIdx);
|
|
189
|
+
const isValid = await lastStep.validate();
|
|
190
|
+
if (isValid) {
|
|
191
|
+
lastStep.completed(true);
|
|
192
|
+
this.emit('complete');
|
|
193
|
+
} else {
|
|
194
|
+
lastStep.error(true);
|
|
195
|
+
this.emit('stepError', currentIdx);
|
|
196
|
+
}
|
|
197
|
+
return this;
|
|
151
198
|
}
|
|
152
|
-
|
|
199
|
+
|
|
200
|
+
return this.goToStep(currentIdx + 1);
|
|
153
201
|
};
|
|
154
202
|
|
|
155
203
|
Stepper.prototype.previous = function() {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
const previousStep = current - 1;
|
|
159
|
-
this.$description.currentStep.set(previousStep);
|
|
160
|
-
this.emit('stepChange', previousStep);
|
|
161
|
-
}
|
|
162
|
-
return this;
|
|
204
|
+
const currentIdx = this.$description.currentStep.val();
|
|
205
|
+
return this.goToStep(currentIdx - 1);
|
|
163
206
|
};
|
|
164
207
|
|
|
165
|
-
Stepper.prototype.goToStep = function(index) {
|
|
166
|
-
const
|
|
167
|
-
const
|
|
208
|
+
Stepper.prototype.goToStep = async function(index) {
|
|
209
|
+
const visibleSteps = this.$description.visibleSteps;
|
|
210
|
+
const total = visibleSteps.length;
|
|
211
|
+
const currentIdx = this.$description.currentStep.val();
|
|
168
212
|
|
|
169
|
-
if (index < 0 || index >= total) {
|
|
213
|
+
if (index < 0 || index >= total || index === currentIdx) {
|
|
170
214
|
return this;
|
|
171
215
|
}
|
|
172
216
|
|
|
173
|
-
|
|
217
|
+
const currentStep = visibleSteps.at(currentIdx);
|
|
218
|
+
|
|
219
|
+
if (index < currentIdx) {
|
|
220
|
+
if (this.$description.editable.val()) {
|
|
221
|
+
this.$description.currentStep.set(index);
|
|
222
|
+
this.emit('stepChange', index);
|
|
223
|
+
}
|
|
174
224
|
return this;
|
|
175
225
|
}
|
|
176
|
-
if(this.$description.linear && !(index === current+1 || index === current-1)) {
|
|
177
|
-
return this;
|
|
178
226
|
|
|
227
|
+
if (index > currentIdx) {
|
|
228
|
+
if (this.$description.linear && index > currentIdx + 1) {
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const isValid = await currentStep.validate();
|
|
233
|
+
if (isValid) {
|
|
234
|
+
currentStep.completed(true);
|
|
235
|
+
this.$description.currentStep.set(index);
|
|
236
|
+
this.emit('stepChange', index);
|
|
237
|
+
} else {
|
|
238
|
+
currentStep.error(true);
|
|
239
|
+
this.emit('stepError', currentIdx);
|
|
240
|
+
}
|
|
179
241
|
}
|
|
180
|
-
|
|
181
|
-
this.emit('stepChange', index);
|
|
242
|
+
|
|
182
243
|
return this;
|
|
183
244
|
};
|
|
184
245
|
|
|
185
246
|
Stepper.prototype.reset = function() {
|
|
186
247
|
this.$description.currentStep.set(0);
|
|
248
|
+
|
|
249
|
+
this.$description.steps.forEach(step => {
|
|
250
|
+
step.reset();
|
|
251
|
+
});
|
|
252
|
+
|
|
187
253
|
this.emit('reset');
|
|
188
254
|
return this;
|
|
189
255
|
};
|
|
@@ -227,3 +293,29 @@ Stepper.prototype.renderContent = function(renderFn) {
|
|
|
227
293
|
this.$description.renderContent = renderFn;
|
|
228
294
|
return this;
|
|
229
295
|
};
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
Stepper.prototype.navigationAtLeading = function() {
|
|
299
|
+
this.$description.position = 'leading';
|
|
300
|
+
this.vertical();
|
|
301
|
+
return this;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
Stepper.prototype.navigationAtBottom = function() {
|
|
305
|
+
this.$description.position = 'bottom';
|
|
306
|
+
this.horizontal();
|
|
307
|
+
return this;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
Stepper.prototype.navigationAtTop = function() {
|
|
312
|
+
this.$description.position = 'top';
|
|
313
|
+
this.horizontal()
|
|
314
|
+
return this;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
Stepper.prototype.navigationAtTrailing = function() {
|
|
318
|
+
this.$description.position = 'trailing';
|
|
319
|
+
this.vertical();
|
|
320
|
+
return this;
|
|
321
|
+
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
2
|
import { $ } from '../../../index';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const NO_VALIDATION = () => true;
|
|
5
|
+
|
|
6
|
+
export default function StepperStep(label, props = {}) {
|
|
5
7
|
if(!(this instanceof StepperStep)) {
|
|
6
|
-
return new StepperStep(label,
|
|
8
|
+
return new StepperStep(label, props);
|
|
7
9
|
}
|
|
8
10
|
|
|
11
|
+
BaseComponent.call(this, props);
|
|
12
|
+
|
|
9
13
|
this.$description = {
|
|
10
14
|
icon: null,
|
|
11
|
-
label
|
|
15
|
+
label,
|
|
12
16
|
description: null,
|
|
13
17
|
content: null,
|
|
14
18
|
status: $('pending'),
|
|
@@ -18,9 +22,12 @@ export default function StepperStep(label, config = {}) {
|
|
|
18
22
|
error: $(false),
|
|
19
23
|
data: null,
|
|
20
24
|
render: null,
|
|
21
|
-
validator:
|
|
25
|
+
validator: NO_VALIDATION,
|
|
26
|
+
stepper: null,
|
|
22
27
|
key: null,
|
|
23
|
-
|
|
28
|
+
index: $(0),
|
|
29
|
+
isVisible: $(true),
|
|
30
|
+
props
|
|
24
31
|
};
|
|
25
32
|
}
|
|
26
33
|
|
|
@@ -29,9 +36,19 @@ BaseComponent.extends(StepperStep);
|
|
|
29
36
|
StepperStep.defaultTemplate = null;
|
|
30
37
|
|
|
31
38
|
StepperStep.use = function(template) {
|
|
32
|
-
StepperStep.defaultTemplate = template
|
|
39
|
+
StepperStep.defaultTemplate = template;
|
|
33
40
|
};
|
|
34
41
|
|
|
42
|
+
StepperStep.prototype.$setStepper = function(stepper) {
|
|
43
|
+
this.$description.stepper = stepper;
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
StepperStep.prototype.$setIndex = function(index) {
|
|
47
|
+
this.$description.index.set(index);
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
|
|
35
52
|
StepperStep.prototype.icon = function(icon) {
|
|
36
53
|
this.$description.icon = icon;
|
|
37
54
|
return this;
|
|
@@ -67,16 +84,26 @@ StepperStep.prototype.disabled = function(disabled = true) {
|
|
|
67
84
|
return this;
|
|
68
85
|
};
|
|
69
86
|
|
|
70
|
-
StepperStep.prototype.
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
StepperStep.prototype.updateStatus = function(status) {
|
|
88
|
+
const isCompleted = status === 'completed';
|
|
89
|
+
const isError = status === 'error';
|
|
90
|
+
|
|
91
|
+
this.$description.completed.set(isCompleted);
|
|
92
|
+
this.$description.error.set(isError);
|
|
93
|
+
this.$description.status.set(status);
|
|
73
94
|
return this;
|
|
74
95
|
};
|
|
75
96
|
|
|
97
|
+
StepperStep.prototype.completed = function(completed = true) {
|
|
98
|
+
return this.updateStatus(completed ? 'completed' : 'pending');
|
|
99
|
+
};
|
|
100
|
+
|
|
76
101
|
StepperStep.prototype.error = function(error = true) {
|
|
77
|
-
this
|
|
78
|
-
|
|
79
|
-
|
|
102
|
+
return this.updateStatus(error ? 'error' : 'pending');
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
StepperStep.prototype.reset = function() {
|
|
106
|
+
return this.updateStatus('pending');
|
|
80
107
|
};
|
|
81
108
|
|
|
82
109
|
StepperStep.prototype.data = function(data) {
|
|
@@ -93,11 +120,21 @@ StepperStep.prototype.getKey = function() {
|
|
|
93
120
|
return this.$description.key;
|
|
94
121
|
};
|
|
95
122
|
|
|
123
|
+
StepperStep.prototype.visibility = function(condition) {
|
|
124
|
+
this.$description.visibility = (typeof condition === 'function' ? condition() : condition);
|
|
125
|
+
return this;
|
|
126
|
+
};
|
|
127
|
+
|
|
96
128
|
StepperStep.prototype.validator = function(validatorFn) {
|
|
97
129
|
this.$description.validator = validatorFn;
|
|
98
130
|
return this;
|
|
99
131
|
};
|
|
100
132
|
|
|
101
133
|
StepperStep.prototype.validate = function() {
|
|
134
|
+
if (this.$description.validator) {
|
|
135
|
+
const isValid = this.$description.validator(this);
|
|
136
|
+
this.error(!isValid);
|
|
137
|
+
return isValid;
|
|
138
|
+
}
|
|
102
139
|
return true;
|
|
103
140
|
};
|