native-document 1.0.139 → 1.0.141
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 +11639 -8757
- 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 +82 -7
- 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 +26 -24
- package/src/components/table/ColumnGroup.js +4 -13
- package/src/components/table/DataTable.js +388 -103
- package/src/components/table/SimpleTable.js +31 -140
- 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 +367 -0
- package/src/ui/components/table/data-table/toolbar.js +67 -0
- package/src/ui/components/table/simple-table/SimpleTableRender.js +191 -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
|
@@ -1,43 +1,108 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
2
|
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
3
|
+
import { Observable } from "../../../index";
|
|
4
|
+
import {NDElement} from "../../core/wrappers/NDElement";
|
|
5
|
+
import HasDraggable from "../$traits/has-draggable/HasDraggable";
|
|
6
|
+
import HasResizable from "../$traits/has-resizable/HasResizable";
|
|
7
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
3
8
|
|
|
4
9
|
|
|
5
|
-
export default function Modal(
|
|
10
|
+
export default function Modal(content, props = {}) {
|
|
6
11
|
if(!(this instanceof Modal)) {
|
|
7
|
-
return new Modal(
|
|
12
|
+
return new Modal(content, props);
|
|
8
13
|
}
|
|
9
14
|
|
|
15
|
+
BaseComponent.call(this, props);
|
|
16
|
+
|
|
10
17
|
this.$description = {
|
|
11
18
|
centered: true,
|
|
12
19
|
scrollable: false,
|
|
13
20
|
title: null,
|
|
14
|
-
content
|
|
21
|
+
content,
|
|
15
22
|
footer: null,
|
|
16
23
|
size: null,
|
|
17
24
|
closeOnBackdrop: true,
|
|
18
25
|
closeOnEscape: true,
|
|
19
26
|
closable: true,
|
|
20
27
|
layout: null,
|
|
21
|
-
|
|
28
|
+
fullscreen: false,
|
|
29
|
+
draggable: false,
|
|
30
|
+
dragByHeader: true,
|
|
31
|
+
resizable: false,
|
|
32
|
+
resizableOptions: { size: {} },
|
|
33
|
+
focusTrap: true,
|
|
34
|
+
lockScroll: true,
|
|
35
|
+
isOpen: Observable(false),
|
|
36
|
+
variant: null,
|
|
37
|
+
props
|
|
22
38
|
};
|
|
23
39
|
}
|
|
24
40
|
|
|
25
|
-
BaseComponent.extends(Modal
|
|
41
|
+
BaseComponent.extends(Modal);
|
|
42
|
+
BaseComponent.use(Modal, HasEventEmitter, HasDraggable, HasResizable);
|
|
26
43
|
|
|
27
44
|
// Theming
|
|
28
|
-
Modal.
|
|
29
|
-
|
|
30
|
-
Modal.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
Modal.defaultTemplate = null;
|
|
46
|
+
Modal.use = function(template) {
|
|
47
|
+
Modal.defaultTemplate = template;
|
|
48
|
+
|
|
49
|
+
if(!NDElement.prototype.modal) {
|
|
50
|
+
NDElement.prototype.modal = function(content, props) {
|
|
51
|
+
const modal = (content instanceof Modal) ? content : Modal(content, props);
|
|
52
|
+
modal.toNdElement();
|
|
53
|
+
this.onClick(() => modal.open());
|
|
54
|
+
return this;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if(!BaseComponent.prototype.modal) {
|
|
58
|
+
BaseComponent.prototype.modal = function(content, props) {
|
|
59
|
+
this.postBuild(() => {
|
|
60
|
+
const modal = (content instanceof Modal) ? content : Modal(content, props);
|
|
61
|
+
modal.toNdElement();
|
|
62
|
+
this.nd.onClick(() => modal.open());
|
|
63
|
+
});
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
Modal.prototype.trigger = function(trigger) {
|
|
70
|
+
this.toNdElement();
|
|
71
|
+
trigger.nd.onClick(() => this.open());
|
|
72
|
+
return trigger;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
Modal.preset = function(name, callback) {
|
|
76
|
+
if (Modal.prototype[name] || Modal[name]) {
|
|
77
|
+
DebugManager.warn(`Warning: the ${name} method already exist in Modal.`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
Modal[name] = (content, props) => callback(new Modal(content, props));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
Modal.presets = function(presets) {
|
|
84
|
+
for (const name in presets) {
|
|
85
|
+
Modal.preset(name, presets[name]);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
35
88
|
|
|
36
89
|
|
|
37
|
-
Modal.prototype.open = function() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
90
|
+
Modal.prototype.open = function() {
|
|
91
|
+
this.emit('beforeOpen');
|
|
92
|
+
this.$description.isOpen.set(true);
|
|
93
|
+
this.emit('open');
|
|
94
|
+
};
|
|
95
|
+
Modal.prototype.close = function() {
|
|
96
|
+
this.emit('beforeClose');
|
|
97
|
+
this.$description.isOpen.set(false);
|
|
98
|
+
this.emit('close');
|
|
99
|
+
};
|
|
100
|
+
Modal.prototype.isOpen = function() {
|
|
101
|
+
return this.$description.isOpen.val();
|
|
102
|
+
};
|
|
103
|
+
Modal.prototype.isClose = function() {
|
|
104
|
+
return !this.isOpen();
|
|
105
|
+
};
|
|
41
106
|
|
|
42
107
|
// Configuration
|
|
43
108
|
Modal.prototype.title = function(title) {
|
|
@@ -77,8 +142,8 @@ Modal.prototype.centered = function() {
|
|
|
77
142
|
this.$description.centered = true;
|
|
78
143
|
return this;
|
|
79
144
|
};
|
|
80
|
-
Modal.prototype.scrollable = function() {
|
|
81
|
-
this.$description.scrollable =
|
|
145
|
+
Modal.prototype.scrollable = function(scrollable = true) {
|
|
146
|
+
this.$description.scrollable = scrollable;
|
|
82
147
|
return this;
|
|
83
148
|
};
|
|
84
149
|
|
|
@@ -132,22 +197,87 @@ Modal.prototype.layout = function(layoutFn) {
|
|
|
132
197
|
return this;
|
|
133
198
|
};
|
|
134
199
|
|
|
135
|
-
Modal.prototype
|
|
200
|
+
Modal.prototype.fullscreen = function(fullscreen = true) {
|
|
201
|
+
this.$description.fullscreen = fullscreen;
|
|
202
|
+
return this;
|
|
203
|
+
};
|
|
136
204
|
|
|
205
|
+
Modal.prototype.draggable = function() {
|
|
206
|
+
this.$description.draggable = true;
|
|
207
|
+
return this;
|
|
208
|
+
};
|
|
209
|
+
Modal.prototype.dragByHeader = function() {
|
|
210
|
+
this.$description.dragByHeader = true;
|
|
211
|
+
return this;
|
|
137
212
|
};
|
|
138
213
|
|
|
139
|
-
Modal.prototype
|
|
214
|
+
Modal.prototype.resizable = function(options = {}) {
|
|
215
|
+
this.$description.resizable = true;
|
|
216
|
+
for(const key in options) {
|
|
217
|
+
this.$description.resizableOptions[key] = options[key];
|
|
218
|
+
}
|
|
219
|
+
return this;
|
|
220
|
+
};
|
|
221
|
+
Modal.prototype.resizeDirections = function(directions) {
|
|
222
|
+
this.$description.resizableOptions.directions = directions;
|
|
223
|
+
return this;
|
|
224
|
+
};
|
|
140
225
|
|
|
226
|
+
Modal.prototype.minWidth = function(minWidth) {
|
|
227
|
+
this.$description.resizableOptions.size.minWidth = minWidth;
|
|
228
|
+
return this;
|
|
141
229
|
};
|
|
142
230
|
|
|
143
|
-
Modal.prototype
|
|
231
|
+
Modal.prototype.maxWidth = function(maxWidth) {
|
|
232
|
+
this.$description.resizableOptions.size.maxWidth = maxWidth;
|
|
233
|
+
return this;
|
|
234
|
+
};
|
|
144
235
|
|
|
236
|
+
Modal.prototype.minHeight = function(minHeight) {
|
|
237
|
+
this.$description.resizableOptions.size.minHeight = minHeight;
|
|
238
|
+
return this;
|
|
145
239
|
};
|
|
146
240
|
|
|
147
|
-
Modal.prototype
|
|
241
|
+
Modal.prototype.maxHeight = function(maxHeight) {
|
|
242
|
+
this.$description.resizableOptions.size.maxHeight = maxHeight;
|
|
243
|
+
return this;
|
|
244
|
+
};
|
|
148
245
|
|
|
246
|
+
Modal.prototype.focusTrap = function(focusTrap = true) {
|
|
247
|
+
this.$description.focusTrap = focusTrap;
|
|
248
|
+
return this;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
Modal.prototype.lockScroll = function(lockScroll = true) {
|
|
252
|
+
this.$description.lockScroll = lockScroll;
|
|
253
|
+
return this;
|
|
149
254
|
};
|
|
150
255
|
|
|
151
|
-
Modal.prototype.
|
|
256
|
+
Modal.prototype.onDragStart = function(handler) {
|
|
257
|
+
this.on('onDragStart', handler);
|
|
258
|
+
return this;
|
|
259
|
+
};
|
|
152
260
|
|
|
261
|
+
Modal.prototype.onDrag = function(handler) {
|
|
262
|
+
this.on('onDrag', handler);
|
|
263
|
+
return this;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
Modal.prototype.onDragEnd = function(handler) {
|
|
267
|
+
this.on('onDragEnd', handler);
|
|
268
|
+
return this;
|
|
269
|
+
};
|
|
270
|
+
Modal.prototype.onResizeStart = function(handler) {
|
|
271
|
+
this.on('onResizeStart', handler);
|
|
272
|
+
return this;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
Modal.prototype.onResize = function(handler) {
|
|
276
|
+
this.on('onResize', handler);
|
|
277
|
+
return this;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
Modal.prototype.onResizeEnd = function(handler) {
|
|
281
|
+
this.on('onResizeEnd', handler);
|
|
282
|
+
return this;
|
|
153
283
|
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import { $ } from "../../../index";
|
|
2
3
|
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
4
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
3
5
|
|
|
4
|
-
export default function Pagination(
|
|
6
|
+
export default function Pagination(props = {}) {
|
|
5
7
|
if(!(this instanceof Pagination)) {
|
|
6
|
-
return new Pagination(
|
|
8
|
+
return new Pagination(props);
|
|
7
9
|
}
|
|
8
10
|
|
|
11
|
+
BaseComponent.call(this, props);
|
|
12
|
+
|
|
9
13
|
this.$description = {
|
|
10
14
|
currentPage: $(1),
|
|
11
15
|
pages: $.array([]),
|
|
12
|
-
totalPages:
|
|
13
|
-
pageSize: 10,
|
|
14
|
-
totalItems: 0,
|
|
16
|
+
totalPages: $(2),
|
|
17
|
+
pageSize: $(10),
|
|
18
|
+
totalItems: $(0),
|
|
15
19
|
siblingCount: 1,
|
|
16
20
|
boundaryCount: 1,
|
|
17
21
|
showFirstLast: true,
|
|
@@ -25,20 +29,56 @@ export default function Pagination(config = {}) {
|
|
|
25
29
|
renderFirst: null,
|
|
26
30
|
renderLast: null,
|
|
27
31
|
render: null,
|
|
28
|
-
|
|
32
|
+
props
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
this.$element = null;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
BaseComponent.extends(Pagination
|
|
38
|
+
BaseComponent.extends(Pagination);
|
|
39
|
+
BaseComponent.use(Pagination, HasEventEmitter);
|
|
35
40
|
|
|
36
41
|
Pagination.defaultTemplate = null;
|
|
37
42
|
|
|
38
43
|
Pagination.use = function(template) {
|
|
39
|
-
Pagination.defaultTemplate = template
|
|
44
|
+
Pagination.defaultTemplate = template;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
Pagination.preset = function(name, callback) {
|
|
48
|
+
if (Pagination.prototype[name] || Pagination[name]) {
|
|
49
|
+
DebugManager.warn(`Warning: the ${name} method already exist in Pagination.`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
Pagination[name] = (props) => callback(new Pagination(props));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
Pagination.presets = function(presets) {
|
|
56
|
+
for (const name in presets) {
|
|
57
|
+
Pagination.preset(name, presets[name]);
|
|
58
|
+
}
|
|
40
59
|
};
|
|
41
60
|
|
|
61
|
+
Pagination.prototype.$originalBuild = BaseComponent.prototype.$build;
|
|
62
|
+
|
|
63
|
+
Pagination.prototype.$build = function() {
|
|
64
|
+
const $desc = this.$description;
|
|
65
|
+
|
|
66
|
+
const updatePages = () => {
|
|
67
|
+
$desc.totalPages.set(Math.ceil($desc.totalItems.val() / $desc.pageSize.val()));
|
|
68
|
+
this.$updatePages();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
$desc.pageSize.subscribe(updatePages);
|
|
72
|
+
$desc.currentPage.subscribe(updatePages);
|
|
73
|
+
$desc.totalItems.subscribe(updatePages);
|
|
74
|
+
$desc.totalPages.subscribe(() => this.$updatePages());
|
|
75
|
+
|
|
76
|
+
const totalPages = Math.ceil($desc.totalItems.val() / $desc.pageSize.val());
|
|
77
|
+
$desc.totalPages.set(totalPages);
|
|
78
|
+
this.$updatePages();
|
|
79
|
+
|
|
80
|
+
return this.$originalBuild();
|
|
81
|
+
};
|
|
42
82
|
Pagination.prototype.currentPage = function(page) {
|
|
43
83
|
if (typeof page === 'number') {
|
|
44
84
|
this.$description.currentPage.set(page);
|
|
@@ -49,18 +89,17 @@ Pagination.prototype.currentPage = function(page) {
|
|
|
49
89
|
};
|
|
50
90
|
|
|
51
91
|
Pagination.prototype.totalPages = function(total) {
|
|
52
|
-
this.$description.totalPages
|
|
92
|
+
this.$description.totalPages.set(total);
|
|
53
93
|
return this;
|
|
54
94
|
};
|
|
55
95
|
|
|
56
96
|
Pagination.prototype.pageSize = function(size) {
|
|
57
|
-
this.$description.pageSize = size;
|
|
97
|
+
this.$description.pageSize = BaseComponent.obs(size);
|
|
58
98
|
return this;
|
|
59
99
|
};
|
|
60
100
|
|
|
61
101
|
Pagination.prototype.totalItems = function(total) {
|
|
62
|
-
this.$description.totalItems = total;
|
|
63
|
-
this.totalPages(Math.ceil(total / this.$description.pageSize));
|
|
102
|
+
this.$description.totalItems = BaseComponent.obs(total);
|
|
64
103
|
return this;
|
|
65
104
|
};
|
|
66
105
|
|
|
@@ -95,7 +134,7 @@ Pagination.prototype.data = function(data) {
|
|
|
95
134
|
};
|
|
96
135
|
|
|
97
136
|
Pagination.prototype.goToPage = function(page) {
|
|
98
|
-
if (page < 1 || page > this.$description.totalPages) {
|
|
137
|
+
if (page < 1 || page > this.$description.totalPages.val()) {
|
|
99
138
|
return this;
|
|
100
139
|
}
|
|
101
140
|
|
|
@@ -119,11 +158,11 @@ Pagination.prototype.first = function() {
|
|
|
119
158
|
};
|
|
120
159
|
|
|
121
160
|
Pagination.prototype.last = function() {
|
|
122
|
-
return this.goToPage(this.$description.totalPages);
|
|
161
|
+
return this.goToPage(this.$description.totalPages.val());
|
|
123
162
|
};
|
|
124
163
|
|
|
125
164
|
Pagination.prototype.hasNext = function() {
|
|
126
|
-
return this.$description.currentPage.val() < this.$description.totalPages;
|
|
165
|
+
return this.$description.currentPage.val() < this.$description.totalPages.last();
|
|
127
166
|
};
|
|
128
167
|
|
|
129
168
|
Pagination.prototype.hasPrevious = function() {
|
|
@@ -136,7 +175,7 @@ Pagination.prototype.$updatePages = function() {
|
|
|
136
175
|
|
|
137
176
|
Pagination.prototype.getPageNumbers = function() {
|
|
138
177
|
const current = this.$description.currentPage.val();
|
|
139
|
-
const total = this.$description.totalPages;
|
|
178
|
+
const total = this.$description.totalPages.val();
|
|
140
179
|
const siblings = this.$description.siblingCount;
|
|
141
180
|
const boundary = this.$description.boundaryCount;
|
|
142
181
|
|
|
@@ -221,9 +260,4 @@ Pagination.prototype.renderFirst = function(renderFn) {
|
|
|
221
260
|
Pagination.prototype.renderLast = function(renderFn) {
|
|
222
261
|
this.$description.renderLast = renderFn;
|
|
223
262
|
return this;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
Pagination.prototype.$build = function() {
|
|
227
|
-
|
|
228
|
-
return null;
|
|
229
263
|
};
|
|
@@ -1,31 +1,46 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
2
|
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
3
|
+
import { Observable } from "../../../index";
|
|
4
|
+
import {ElementCreator} from "../../core/wrappers/ElementCreator";
|
|
5
|
+
import {NDElement} from "../../core/wrappers/NDElement";
|
|
6
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
7
|
+
import HasFullPosition from "../$traits/has-position/HasFullPosition";
|
|
3
8
|
|
|
4
|
-
export default function Popover(
|
|
9
|
+
export default function Popover(content, props = {}) {
|
|
5
10
|
if (!(this instanceof Popover)) {
|
|
6
|
-
return new Popover(
|
|
11
|
+
return new Popover(content, props);
|
|
7
12
|
}
|
|
8
13
|
|
|
14
|
+
BaseComponent.call(this, props);
|
|
15
|
+
|
|
9
16
|
this.$description = {
|
|
10
17
|
trigger: null,
|
|
11
|
-
|
|
18
|
+
interaction: 'click',
|
|
19
|
+
content,
|
|
12
20
|
header: null,
|
|
13
21
|
footer: null,
|
|
14
|
-
isOpen:
|
|
22
|
+
isOpen: Observable(false),
|
|
15
23
|
defaultOpen: false,
|
|
16
24
|
modal: false,
|
|
17
25
|
closeOnEscape: true,
|
|
18
26
|
closeOnClickOutside: true,
|
|
19
27
|
focusTrap: true,
|
|
20
28
|
returnFocus: true,
|
|
21
|
-
position: '
|
|
22
|
-
offset:
|
|
29
|
+
position: 'top',
|
|
30
|
+
offset: 8,
|
|
31
|
+
shift: {},
|
|
32
|
+
arrow: true,
|
|
23
33
|
data: null,
|
|
24
34
|
renderContent: null,
|
|
25
35
|
renderHeader: null,
|
|
26
36
|
renderFooter: null,
|
|
27
37
|
render: null,
|
|
28
|
-
|
|
38
|
+
variant: null,
|
|
39
|
+
matchTriggerWidth: null,
|
|
40
|
+
matchTargetWidth: null,
|
|
41
|
+
updatePositionOn: null,
|
|
42
|
+
includeTriggerIntoGhost: true,
|
|
43
|
+
props,
|
|
29
44
|
};
|
|
30
45
|
|
|
31
46
|
this.$element = null;
|
|
@@ -35,20 +50,74 @@ export default function Popover(config = {}) {
|
|
|
35
50
|
}
|
|
36
51
|
}
|
|
37
52
|
|
|
38
|
-
BaseComponent.extends(Popover
|
|
53
|
+
BaseComponent.extends(Popover);
|
|
54
|
+
BaseComponent.use(Popover, HasEventEmitter, HasFullPosition);
|
|
39
55
|
|
|
40
56
|
Popover.defaultTemplate = null;
|
|
41
57
|
|
|
42
58
|
Popover.use = function(template) {
|
|
43
|
-
Popover.defaultTemplate = template
|
|
59
|
+
Popover.defaultTemplate = template;
|
|
60
|
+
|
|
61
|
+
if(!NDElement.prototype.popover) {
|
|
62
|
+
NDElement.prototype.popover = function(content, props) {
|
|
63
|
+
this.ghostDom((content instanceof Popover)
|
|
64
|
+
? content.trigger(this.$element)
|
|
65
|
+
: Popover(content, props).trigger(this.$element));
|
|
66
|
+
return this;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if(!BaseComponent.prototype.popover) {
|
|
70
|
+
BaseComponent.prototype.popover = function(content, props) {
|
|
71
|
+
this.postBuild(() => {
|
|
72
|
+
if(content instanceof Popover) {
|
|
73
|
+
this.ghostDom(content.trigger(this.$element));
|
|
74
|
+
} else {
|
|
75
|
+
this.ghostDom(Popover(content, props).trigger(this.$element));
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
return this;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
44
82
|
};
|
|
45
83
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
Popover.preset = function(name, callback) {
|
|
87
|
+
if (Popover.prototype[name] || Popover[name]) {
|
|
88
|
+
DebugManager.warn(`Warning: the ${name} method already exist in Popover.`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
Popover[name] = (content, props) => callback(new Popover(content, props));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
Popover.presets = function(presets) {
|
|
95
|
+
for (const name in presets) {
|
|
96
|
+
Popover.preset(name, presets[name]);
|
|
51
97
|
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
Popover.prototype.trigger = function(trigger) {
|
|
101
|
+
this.$description.trigger = ElementCreator.getChild(trigger);
|
|
102
|
+
return this;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
Popover.prototype.interaction = function(interaction) {
|
|
106
|
+
this.$description.interaction = interaction;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
Popover.prototype.onClicked = function() {
|
|
110
|
+
this.$description.interaction = 'click';
|
|
111
|
+
return this;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
Popover.prototype.onHovered = function() {
|
|
115
|
+
this.$description.interaction = 'hover';
|
|
116
|
+
return this;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
Popover.prototype.onFocused = function() {
|
|
120
|
+
this.$description.interaction = 'focus';
|
|
52
121
|
return this;
|
|
53
122
|
};
|
|
54
123
|
|
|
@@ -92,33 +161,18 @@ Popover.prototype.position = function(position) {
|
|
|
92
161
|
return this;
|
|
93
162
|
};
|
|
94
163
|
|
|
95
|
-
Popover.prototype.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Popover.prototype.atBottom = function() {
|
|
99
|
-
return this.position('bottom');
|
|
100
|
-
};
|
|
101
|
-
Popover.prototype.atLeft = function() {
|
|
102
|
-
return this.position('left');
|
|
103
|
-
};
|
|
104
|
-
Popover.prototype.atRight = function() {
|
|
105
|
-
return this.position('right');
|
|
106
|
-
};
|
|
107
|
-
Popover.prototype.atTopStart = function() {
|
|
108
|
-
return this.position('top-start');
|
|
109
|
-
};
|
|
110
|
-
Popover.prototype.atTopEnd = function() {
|
|
111
|
-
return this.position('top-end');
|
|
112
|
-
};
|
|
113
|
-
Popover.prototype.atBottomStart = function() {
|
|
114
|
-
return this.position('bottom-start');
|
|
164
|
+
Popover.prototype.offset = function(offset) {
|
|
165
|
+
this.$description.offset = offset;
|
|
166
|
+
return this;
|
|
115
167
|
};
|
|
116
|
-
|
|
117
|
-
|
|
168
|
+
|
|
169
|
+
Popover.prototype.arrow = function(arrow = true) {
|
|
170
|
+
this.$description.arrow = arrow;
|
|
171
|
+
return this;
|
|
118
172
|
};
|
|
119
173
|
|
|
120
|
-
Popover.prototype.
|
|
121
|
-
this.$description.
|
|
174
|
+
Popover.prototype.shift = function(shift) {
|
|
175
|
+
this.$description.shift = shift;
|
|
122
176
|
return this;
|
|
123
177
|
};
|
|
124
178
|
|
|
@@ -179,7 +233,40 @@ Popover.prototype.renderFooter = function(renderFn) {
|
|
|
179
233
|
return this;
|
|
180
234
|
};
|
|
181
235
|
|
|
182
|
-
Popover.prototype.
|
|
183
|
-
this.$description.
|
|
236
|
+
Popover.prototype.variant = function(variant) {
|
|
237
|
+
this.$description.variant = variant;
|
|
238
|
+
return this;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
Popover.prototype.primary = function() {
|
|
242
|
+
this.$description.variant = 'primary';
|
|
243
|
+
return this;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
Popover.prototype.success = function() {
|
|
247
|
+
this.$description.variant = 'success';
|
|
248
|
+
return this;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
Popover.prototype.warning = function() {
|
|
252
|
+
this.$description.variant = 'warning';
|
|
253
|
+
return this;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
Popover.prototype.danger = function() {
|
|
257
|
+
this.$description.variant = 'danger';
|
|
258
|
+
return this;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
Popover.prototype.info = function() {
|
|
262
|
+
this.$description.variant = 'info';
|
|
263
|
+
return this;
|
|
264
|
+
};
|
|
265
|
+
Popover.prototype.matchTriggerWidth = function() {
|
|
266
|
+
this.$description.matchTriggerWidth = true;
|
|
267
|
+
return this;
|
|
268
|
+
};
|
|
269
|
+
Popover.prototype.updatePositionOn = function(updatePositionOn) {
|
|
270
|
+
this.$description.updatePositionOn = updatePositionOn;
|
|
184
271
|
return this;
|
|
185
272
|
};
|
|
@@ -16,6 +16,7 @@ export default function Progress(props = {}) {
|
|
|
16
16
|
variant: null,
|
|
17
17
|
max: 100,
|
|
18
18
|
size: null,
|
|
19
|
+
stroke: null,
|
|
19
20
|
height: null,
|
|
20
21
|
showValue: null,
|
|
21
22
|
showPercentage: null,
|
|
@@ -24,13 +25,13 @@ export default function Progress(props = {}) {
|
|
|
24
25
|
indeterminate: null,
|
|
25
26
|
striped: null,
|
|
26
27
|
animated: null,
|
|
27
|
-
render: null,
|
|
28
28
|
borderRadiusType: null,
|
|
29
29
|
props
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
BaseComponent.extends(Progress
|
|
33
|
+
BaseComponent.extends(Progress);
|
|
34
|
+
BaseComponent.use(Progress, HasEventEmitter);
|
|
34
35
|
|
|
35
36
|
Progress.defaultTemplate = null;
|
|
36
37
|
|
|
@@ -52,7 +53,6 @@ Progress.presets = function(presets) {
|
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
|
|
56
56
|
Progress.prototype.model = function(observable) {
|
|
57
57
|
this.$description.value = observable;
|
|
58
58
|
return this;
|
|
@@ -65,12 +65,9 @@ Progress.prototype.setCurrentStep = function(step) {
|
|
|
65
65
|
this.emit('change', step);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
Progress.prototype.value = function() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return value.val();
|
|
72
|
-
}
|
|
73
|
-
return value;
|
|
68
|
+
Progress.prototype.value = function(value) {
|
|
69
|
+
this.$description.value = BaseComponent.obs(value);
|
|
70
|
+
return this;
|
|
74
71
|
};
|
|
75
72
|
|
|
76
73
|
Progress.prototype.setValue = function(newValue) {
|
|
@@ -78,6 +75,10 @@ Progress.prototype.setValue = function(newValue) {
|
|
|
78
75
|
return this;
|
|
79
76
|
};
|
|
80
77
|
|
|
78
|
+
Progress.prototype.getCurrentValue = function() {
|
|
79
|
+
return this.$description.value?.get();
|
|
80
|
+
}
|
|
81
|
+
|
|
81
82
|
Progress.prototype.max = function(max) {
|
|
82
83
|
this.$description.max = max;
|
|
83
84
|
return this;
|
|
@@ -140,6 +141,10 @@ Progress.prototype.size = function(size) {
|
|
|
140
141
|
this.$description.size = size;
|
|
141
142
|
return this;
|
|
142
143
|
};
|
|
144
|
+
Progress.prototype.stroke = function(stroke) {
|
|
145
|
+
this.$description.stroke = stroke;
|
|
146
|
+
return this;
|
|
147
|
+
};
|
|
143
148
|
|
|
144
149
|
Progress.prototype.small = function() {
|
|
145
150
|
return this.size('small');
|
|
@@ -226,18 +231,3 @@ Progress.prototype.onReset = function(handler) {
|
|
|
226
231
|
this.on('reset', handler);
|
|
227
232
|
return this;
|
|
228
233
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
Progress.prototype.render = function(renderFn) {
|
|
232
|
-
this.$description.render = renderFn;
|
|
233
|
-
return this;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// Build & Render
|
|
237
|
-
Progress.prototype.$build = function() {
|
|
238
|
-
// TODO: Implementation
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
Progress.prototype.toNdElement = function() {
|
|
242
|
-
return this.$build();
|
|
243
|
-
};
|