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,160 @@
|
|
|
1
|
+
|
|
2
|
+
export default function Spinner(config = {}) {
|
|
3
|
+
if (!(this instanceof Spinner)) {
|
|
4
|
+
return new Spinner(config);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
this.$description = {
|
|
8
|
+
type: 'circle',
|
|
9
|
+
variant: null,
|
|
10
|
+
color: null,
|
|
11
|
+
size: 'small',
|
|
12
|
+
label: null,
|
|
13
|
+
labelPosition: null,
|
|
14
|
+
overlay: null,
|
|
15
|
+
backdrop: null,
|
|
16
|
+
render: null,
|
|
17
|
+
loading: null,
|
|
18
|
+
speed: null,
|
|
19
|
+
...config
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Spinner.use = function(template) {};
|
|
24
|
+
Spinner.defaultTemplate = null;
|
|
25
|
+
|
|
26
|
+
Spinner.prototype.type = function(type) {
|
|
27
|
+
this.$description.type = type;
|
|
28
|
+
return this;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Spinner.prototype.circle = function() {
|
|
32
|
+
return this.type('circle');
|
|
33
|
+
};
|
|
34
|
+
Spinner.prototype.dots = function() {
|
|
35
|
+
return this.type('dots');
|
|
36
|
+
};
|
|
37
|
+
Spinner.prototype.bars = function() {
|
|
38
|
+
return this.type('bars');
|
|
39
|
+
};
|
|
40
|
+
Spinner.prototype.pulse = function() {
|
|
41
|
+
return this.type('pulse');
|
|
42
|
+
};
|
|
43
|
+
Spinner.prototype.ring = function() {
|
|
44
|
+
return this.type('ring');
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {string|int} size
|
|
49
|
+
* @returns {Spinner}
|
|
50
|
+
*/
|
|
51
|
+
Spinner.prototype.size = function(size) {
|
|
52
|
+
this.$description.size = size;
|
|
53
|
+
return this;
|
|
54
|
+
};
|
|
55
|
+
Spinner.prototype.extraSmall = function() {
|
|
56
|
+
return this.size('extra-small');
|
|
57
|
+
};
|
|
58
|
+
Spinner.prototype.small = function() {
|
|
59
|
+
return this.size('small');
|
|
60
|
+
};
|
|
61
|
+
Spinner.prototype.medium = function() {
|
|
62
|
+
return this.size('medium');
|
|
63
|
+
};
|
|
64
|
+
Spinner.prototype.large = function() {
|
|
65
|
+
return this.size('large');
|
|
66
|
+
};
|
|
67
|
+
Spinner.prototype.extraLarge = function() {
|
|
68
|
+
return this.size('extra-large');
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
Spinner.prototype.variant = function(name) {
|
|
72
|
+
this.$description.variant = name;
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
Spinner.prototype.primary = function() {
|
|
76
|
+
return this.variant('primary');
|
|
77
|
+
};
|
|
78
|
+
Spinner.prototype.secondary = function() {
|
|
79
|
+
return this.variant('secondary');
|
|
80
|
+
};
|
|
81
|
+
Spinner.prototype.success = function() {
|
|
82
|
+
return this.variant('success');
|
|
83
|
+
};
|
|
84
|
+
Spinner.prototype.danger = function() {
|
|
85
|
+
return this.variant('danger');
|
|
86
|
+
};
|
|
87
|
+
Spinner.prototype.warning = function() {
|
|
88
|
+
return this.variant('warning');
|
|
89
|
+
}
|
|
90
|
+
Spinner.prototype.color = function(color) {
|
|
91
|
+
this.$description.color = color;
|
|
92
|
+
return this;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
Spinner.prototype.label = function(label) {
|
|
96
|
+
this.$description.label = label;
|
|
97
|
+
return this;
|
|
98
|
+
};
|
|
99
|
+
Spinner.prototype.labelPosition = function(position) {
|
|
100
|
+
this.$description.labelPosition = position;
|
|
101
|
+
return this;
|
|
102
|
+
};
|
|
103
|
+
Spinner.prototype.labelAtTop = function() {
|
|
104
|
+
return this.labelPosition('top');
|
|
105
|
+
};
|
|
106
|
+
Spinner.prototype.labelAtBottom = function() {
|
|
107
|
+
return this.labelPosition('bottom');
|
|
108
|
+
};
|
|
109
|
+
Spinner.prototype.labelAtLeft = function() {
|
|
110
|
+
return this.labelPosition('left');
|
|
111
|
+
};
|
|
112
|
+
Spinner.prototype.labelAtRight = function() {
|
|
113
|
+
return this.labelPosition('right');
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Spinner.prototype.overlay = function(enabled = true) {
|
|
117
|
+
this.$description.overlay = enabled;
|
|
118
|
+
return this;
|
|
119
|
+
};
|
|
120
|
+
Spinner.prototype.fullscreen = function() {
|
|
121
|
+
return this.overlay(true);
|
|
122
|
+
};
|
|
123
|
+
Spinner.prototype.backdrop = function(enabled = true) {
|
|
124
|
+
this.$description.backdrop = enabled;
|
|
125
|
+
return this;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
* @param {string|int} speed
|
|
131
|
+
* @returns {Spinner}
|
|
132
|
+
*/
|
|
133
|
+
Spinner.prototype.speed = function(speed) {
|
|
134
|
+
this.$description.speed = speed;
|
|
135
|
+
return this;
|
|
136
|
+
};
|
|
137
|
+
Spinner.prototype.slow = function() {
|
|
138
|
+
return this.speed('slow');
|
|
139
|
+
};
|
|
140
|
+
Spinner.prototype.normal = function() {
|
|
141
|
+
return this.speed('normal');
|
|
142
|
+
};
|
|
143
|
+
Spinner.prototype.fast = function() {
|
|
144
|
+
return this.speed('fast');
|
|
145
|
+
};
|
|
146
|
+
Spinner.prototype.loading = function(isLoading) {
|
|
147
|
+
this.$description.loading = isLoading;
|
|
148
|
+
return this;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
Spinner.prototype.show = function() {};
|
|
152
|
+
Spinner.prototype.hide = function() {};
|
|
153
|
+
|
|
154
|
+
Spinner.prototype.render = function(renderFn) {
|
|
155
|
+
this.$description.render = renderFn;
|
|
156
|
+
return this;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
Spinner.prototype.$build = function() {};
|
|
160
|
+
Spinner.prototype.toNdElement = function() {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
|
+
import {Validator} from "../../../index";
|
|
4
|
+
|
|
5
|
+
export default function Splitter(config = {}) {
|
|
6
|
+
if(!(this instanceof Splitter)) {
|
|
7
|
+
return new Splitter(config);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
this.$description = {
|
|
11
|
+
orientation: 'horizontal',
|
|
12
|
+
panels: [],
|
|
13
|
+
gutterSize: 8,
|
|
14
|
+
render: null,
|
|
15
|
+
...config
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
this.$element = null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
BaseComponent.extends(Splitter, EventEmitter);
|
|
22
|
+
|
|
23
|
+
Splitter.defaultTemplate = null;
|
|
24
|
+
|
|
25
|
+
Splitter.use = function(template) {
|
|
26
|
+
Splitter.defaultTemplate = template.splitter;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
Splitter.prototype.dynamic = function(){
|
|
30
|
+
this.$description.panels = $.array([]);
|
|
31
|
+
return this;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Splitter.prototype.orientation = function(orientation) {
|
|
35
|
+
this.$description.orientation = orientation;
|
|
36
|
+
return this;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Splitter.prototype.horizontal = function() {
|
|
40
|
+
this.$description.orientation = 'horizontal';
|
|
41
|
+
return this;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Splitter.prototype.vertical = function() {
|
|
45
|
+
this.$description.orientation = 'vertical';
|
|
46
|
+
return this;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Splitter.prototype.gutterSize = function(gutterSize) {
|
|
50
|
+
this.$description.gutterSize = gutterSize;
|
|
51
|
+
return this;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
Splitter.prototype.panel = function(panel) {
|
|
55
|
+
this.$description.panels.push(panel);
|
|
56
|
+
return this;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Splitter.prototype.panels = function(panels) {
|
|
60
|
+
if(Validator.isObservable(this.$description.panels)) {
|
|
61
|
+
this.$description.panels.set(panels);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
this.$description.panels = [];
|
|
65
|
+
panels.forEach(panel => this.panel(panel));
|
|
66
|
+
return this;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
Splitter.prototype.removePanel = function(panel) {
|
|
71
|
+
this.$description.panels.remove(panel);
|
|
72
|
+
// TODO: remove the unnecessary gutter
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Splitter.prototype.onResize = function(handler) {
|
|
77
|
+
this.on('resize', handler);
|
|
78
|
+
return this;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
Splitter.prototype.onPanelAdd = function(handler) {
|
|
82
|
+
this.on('panelAdd', handler);
|
|
83
|
+
return this;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
Splitter.prototype.onPanelRemove = function(handler) {
|
|
87
|
+
this.on('panelRemove', handler);
|
|
88
|
+
return this;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
Splitter.prototype.render = function(renderFn) {
|
|
92
|
+
this.$description.render = renderFn;
|
|
93
|
+
return this;
|
|
94
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export default function SplitterGutter(leftPanel, rightPanel, config = {}) {
|
|
4
|
+
if(!(this instanceof SplitterGutter)) {
|
|
5
|
+
return new SplitterGutter(config);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
this.$description = {
|
|
9
|
+
leftPanel: leftPanel || null,
|
|
10
|
+
rightPanel: rightPanel || null,
|
|
11
|
+
orientation: config.orientation || 'horizontal',
|
|
12
|
+
cursor: config.orientation === 'vertical' ? 'row-resize' : 'col-resize',
|
|
13
|
+
size: 8,
|
|
14
|
+
isDragging: $(false)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
SplitterGutter.defaultTemplate = null;
|
|
19
|
+
|
|
20
|
+
SplitterGutter.use = function(template) {
|
|
21
|
+
SplitterGutter.defaultTemplate = template.splitterGutter;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
SplitterGutter.prototype.panels = function(leftPanel, rightPanel) {
|
|
25
|
+
this.$description.leftPanel = leftPanel;
|
|
26
|
+
this.$description.rightPanel = rightPanel;
|
|
27
|
+
return this;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
SplitterGutter.prototype.leftPanel = function(leftPanel) {
|
|
31
|
+
this.$description.leftPanel = leftPanel;
|
|
32
|
+
return this;
|
|
33
|
+
};
|
|
34
|
+
SplitterGutter.prototype.rightPanel = function(rightPanel) {
|
|
35
|
+
this.$description.rightPanel = rightPanel;
|
|
36
|
+
return this;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
SplitterGutter.prototype.size = function(size) {
|
|
40
|
+
this.$description.size = size;
|
|
41
|
+
return this;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
SplitterGutter.prototype.onDragStart = function(handler) {
|
|
45
|
+
this.on('dragStart', handler);
|
|
46
|
+
return this;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
SplitterGutter.prototype.onDrag = function(handler) {
|
|
50
|
+
this.on('drag', handler);
|
|
51
|
+
return this;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
SplitterGutter.prototype.onDragEnd = function(handler) {
|
|
55
|
+
this.on('dragEnd', handler);
|
|
56
|
+
return this;
|
|
57
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
|
|
3
|
+
export default function SplitterPanel(content, config = {}) {
|
|
4
|
+
if(!(this instanceof SplitterPanel)) {
|
|
5
|
+
return new SplitterPanel(content, config);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (typeof content === 'object' && !content.tagName) {
|
|
9
|
+
config = content;
|
|
10
|
+
content = config.content || null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
this.$description = {
|
|
14
|
+
content: content || null,
|
|
15
|
+
size: null,
|
|
16
|
+
minSize: null,
|
|
17
|
+
maxSize: null,
|
|
18
|
+
collapsible: false,
|
|
19
|
+
collapsed: false,
|
|
20
|
+
resizable: true,
|
|
21
|
+
data: null,
|
|
22
|
+
render: null,
|
|
23
|
+
...config
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
BaseComponent.extends(SplitterPanel, BaseComponent);
|
|
28
|
+
|
|
29
|
+
SplitterPanel.defaultTemplate = null;
|
|
30
|
+
|
|
31
|
+
SplitterPanel.use = function(template) {
|
|
32
|
+
SplitterPanel.defaultTemplate = template.splitterPanel;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
SplitterPanel.prototype.content = function(content) {
|
|
36
|
+
this.$description.content = content;
|
|
37
|
+
return this;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
SplitterPanel.prototype.size = function(size) {
|
|
41
|
+
this.$description.size = size;
|
|
42
|
+
return this;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
SplitterPanel.prototype.minSize = function(size) {
|
|
46
|
+
this.$description.minSize = size;
|
|
47
|
+
return this;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
SplitterPanel.prototype.maxSize = function(size) {
|
|
51
|
+
this.$description.maxSize = size;
|
|
52
|
+
return this;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
SplitterPanel.prototype.collapsible = function(collapsible = true) {
|
|
56
|
+
this.$description.collapsible = collapsible;
|
|
57
|
+
return this;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
SplitterPanel.prototype.collapsed = function(collapsed = true) {
|
|
61
|
+
this.$description.collapsed = collapsed;
|
|
62
|
+
return this;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
SplitterPanel.prototype.resizable = function(resizable = true) {
|
|
66
|
+
this.$description.resizable = resizable;
|
|
67
|
+
return this;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
SplitterPanel.prototype.fixed = function() {
|
|
71
|
+
return this.resizable(false);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
SplitterPanel.prototype.data = function(data) {
|
|
75
|
+
this.$description.data = data;
|
|
76
|
+
return this;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
SplitterPanel.prototype.render = function(renderFn) {
|
|
80
|
+
this.$description.render = renderFn;
|
|
81
|
+
return this;
|
|
82
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
|
+
import {$, Validator} from "../../../index";
|
|
4
|
+
|
|
5
|
+
export default function Stepper(config = {}) {
|
|
6
|
+
if(!(this instanceof Stepper)) {
|
|
7
|
+
return new Stepper(config);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
this.$description = {
|
|
11
|
+
steps: [],
|
|
12
|
+
currentStep: $(0),
|
|
13
|
+
orientation: 'horizontal',
|
|
14
|
+
linear: true,
|
|
15
|
+
alternativeLabel: false,
|
|
16
|
+
editable: false,
|
|
17
|
+
showNumbers: true,
|
|
18
|
+
showConnector: true,
|
|
19
|
+
data: null,
|
|
20
|
+
renderStepIndicator: null,
|
|
21
|
+
renderStepIndicatorConnector: null,
|
|
22
|
+
renderContent: null,
|
|
23
|
+
render: null,
|
|
24
|
+
...config
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
this.$element = null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
BaseComponent.extends(Stepper, EventEmitter);
|
|
31
|
+
|
|
32
|
+
Stepper.defaultTemplate = null;
|
|
33
|
+
Stepper.defaultStepTemplate = null;
|
|
34
|
+
Stepper.defaultStepConnectorTemplate = null;
|
|
35
|
+
Stepper.defaultContentTemplate = null;
|
|
36
|
+
|
|
37
|
+
Stepper.use = function(template) {
|
|
38
|
+
Stepper.defaultTemplate = template.stepper;
|
|
39
|
+
Stepper.defaultStepIndicatorTemplate = template.stepperStepIndicator;
|
|
40
|
+
Stepper.defaultContentTemplate = template.stepperContent;
|
|
41
|
+
Stepper.defaultStepIndicatorConnectorTemplate = template.stepperStepIndicatorConnector;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Stepper.prototype.dynamic = function(observableArray) {
|
|
45
|
+
this.$description.steps = observableArray || $.array([]);
|
|
46
|
+
return this;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Stepper.prototype.steps = function(steps) {
|
|
50
|
+
if(Validator.isObservable(steps)) {
|
|
51
|
+
this.$description.steps = steps;
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
this.$description.steps.set(steps);
|
|
55
|
+
return this;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Stepper.prototype.step = function(step) {
|
|
59
|
+
this.$description.steps.push(step);
|
|
60
|
+
return this;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
Stepper.prototype.clear = function() {
|
|
64
|
+
const steps = this.$description.steps;
|
|
65
|
+
if (Array.isArray(steps)) {
|
|
66
|
+
steps.length = 0;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
steps.clear();
|
|
71
|
+
return this;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
Stepper.prototype.removeStepByIndex = function(index) {
|
|
75
|
+
this.$description.steps.splice(index, 1);
|
|
76
|
+
return this;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
Stepper.prototype.removeStepByKey = function(key) {
|
|
80
|
+
const index = this.$description.steps.findIndex(step => step.getKey() === key);
|
|
81
|
+
if(index === -1) {
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
this.$description.steps.splice(index, 1);
|
|
85
|
+
return this;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
Stepper.prototype.currentStep = function(step) {
|
|
89
|
+
return this.$description.currentStep.val();
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
Stepper.prototype.orientation = function(orientation) {
|
|
93
|
+
this.$description.orientation = orientation;
|
|
94
|
+
return this;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
Stepper.prototype.horizontal = function() {
|
|
98
|
+
this.$description.orientation = 'horizontal';
|
|
99
|
+
return this;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
Stepper.prototype.vertical = function() {
|
|
103
|
+
this.$description.orientation = 'vertical';
|
|
104
|
+
return this;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
Stepper.prototype.linear = function() {
|
|
108
|
+
this.$description.linear = true;
|
|
109
|
+
return this;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
Stepper.prototype.nonLinear = function() {
|
|
113
|
+
this.$description.linear = false;
|
|
114
|
+
return this;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
Stepper.prototype.editable = function(editable = true) {
|
|
118
|
+
this.$description.editable = editable;
|
|
119
|
+
return this;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
Stepper.prototype.alternativeLabel = function(alternative = true) {
|
|
123
|
+
this.$description.alternativeLabel = alternative;
|
|
124
|
+
return this;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
Stepper.prototype.showNumbers = function(show = true) {
|
|
128
|
+
this.$description.showNumbers = show;
|
|
129
|
+
return this;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
Stepper.prototype.showConnector = function(show = true) {
|
|
133
|
+
this.$description.showConnector = show;
|
|
134
|
+
return this;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
Stepper.prototype.data = function(data) {
|
|
139
|
+
this.$description.data = data;
|
|
140
|
+
return this;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
Stepper.prototype.next = function() {
|
|
144
|
+
const current = this.$description.currentStep.val();
|
|
145
|
+
const total = this.$description.steps.length;
|
|
146
|
+
|
|
147
|
+
if (current < total - 1) {
|
|
148
|
+
const nextStep = current + 1;
|
|
149
|
+
this.$description.currentStep.set(nextStep);
|
|
150
|
+
this.emit('stepChange', nextStep);
|
|
151
|
+
}
|
|
152
|
+
return this;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
Stepper.prototype.previous = function() {
|
|
156
|
+
const current = this.$description.currentStep.val();
|
|
157
|
+
if (current > 0) {
|
|
158
|
+
const previousStep = current - 1;
|
|
159
|
+
this.$description.currentStep.set(previousStep);
|
|
160
|
+
this.emit('stepChange', previousStep);
|
|
161
|
+
}
|
|
162
|
+
return this;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
Stepper.prototype.goToStep = function(index) {
|
|
166
|
+
const total = this.$description.steps.length;
|
|
167
|
+
const current = this.$description.currentStep.val();
|
|
168
|
+
|
|
169
|
+
if (index < 0 || index >= total) {
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if(!this.$description.editable && index < current) {
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
if(this.$description.linear && !(index === current+1 || index === current-1)) {
|
|
177
|
+
return this;
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
this.$description.currentStep.set(index);
|
|
181
|
+
this.emit('stepChange', index);
|
|
182
|
+
return this;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
Stepper.prototype.reset = function() {
|
|
186
|
+
this.$description.currentStep.set(0);
|
|
187
|
+
this.emit('reset');
|
|
188
|
+
return this;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
Stepper.prototype.onStepChange = function(handler) {
|
|
192
|
+
this.on('stepChange', handler);
|
|
193
|
+
return this;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
Stepper.prototype.onNext = function(handler) {
|
|
197
|
+
this.on('next', handler);
|
|
198
|
+
return this;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
Stepper.prototype.onPrevious = function(handler) {
|
|
202
|
+
this.on('previous', handler);
|
|
203
|
+
return this;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
Stepper.prototype.onComplete = function(handler) {
|
|
207
|
+
this.on('complete', handler);
|
|
208
|
+
return this;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
Stepper.prototype.onReset = function(handler) {
|
|
212
|
+
this.on('reset', handler);
|
|
213
|
+
return this;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
Stepper.prototype.renderStepIndicator = function(renderFn) {
|
|
217
|
+
this.$description.renderStepIndicator = renderFn;
|
|
218
|
+
return this;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
Stepper.prototype.renderStepIndicatorConnector = function(renderFn) {
|
|
222
|
+
this.$description.renderStepIndicatorConnector = renderFn;
|
|
223
|
+
return this;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
Stepper.prototype.renderContent = function(renderFn) {
|
|
227
|
+
this.$description.renderContent = renderFn;
|
|
228
|
+
return this;
|
|
229
|
+
};
|