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,42 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import HasItems from "../$traits/HasItems";
|
|
3
|
+
import MenuDivider from "./MenuDivider";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default function MenuGroup(label, config) {
|
|
7
|
+
if(!(this instanceof MenuGroup)) {
|
|
8
|
+
return new MenuGroup(label, config);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
this.$description = {
|
|
12
|
+
label,
|
|
13
|
+
data: null,
|
|
14
|
+
items: [],
|
|
15
|
+
render: null,
|
|
16
|
+
...config
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
MenuGroup.defaultTemplate = null;
|
|
21
|
+
|
|
22
|
+
MenuGroup.use = function(template) {
|
|
23
|
+
MenuGroup.defaultTemplate = template.menuGroup;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
BaseComponent.extends(MenuGroup, HasItems);
|
|
27
|
+
|
|
28
|
+
MenuGroup.prototype.data = function(data) {
|
|
29
|
+
this.$description.data = data;
|
|
30
|
+
return this;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
MenuGroup.prototype.divider = function() {
|
|
35
|
+
return this.item(new MenuDivider());
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
MenuGroup.prototype.group = function(label, builder) {
|
|
39
|
+
const group = new MenuGroup(label);
|
|
40
|
+
builder && builder(group);
|
|
41
|
+
return this.item(group);
|
|
42
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import HasItems from "../$traits/HasItems";
|
|
3
|
+
import MenuDivider from "./MenuDivider";
|
|
4
|
+
import MenuGroup from "./MenuGroup";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default function MenuItem(config = {}) {
|
|
8
|
+
if(!(this instanceof MenuItem)) {
|
|
9
|
+
return new MenuItem(config);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
this.$description = {
|
|
13
|
+
items: [],
|
|
14
|
+
...config
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
MenuItem.defaultTemplate = null;
|
|
20
|
+
|
|
21
|
+
MenuItem.use = function(template) {
|
|
22
|
+
MenuItem.defaultTemplate = template.menuItem;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
BaseComponent.extends(MenuItem, HasItems);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
MenuItem.prototype.label = function(label) {
|
|
29
|
+
this.$description.label = label;
|
|
30
|
+
return this;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
MenuItem.prototype.icon = function(icon) {
|
|
34
|
+
this.$description.icon = icon;
|
|
35
|
+
return this;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
MenuItem.prototype.shortcut = function(shortcut) {
|
|
39
|
+
this.$description.shortcut = shortcut;
|
|
40
|
+
return this;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
MenuItem.prototype.disabled = function(disabled = true) {
|
|
44
|
+
this.$description.disabled = disabled;
|
|
45
|
+
return this;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
MenuItem.prototype.selected = function(selected = true) {
|
|
49
|
+
this.$description.selected = selected;
|
|
50
|
+
return this;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
MenuItem.prototype.value = function(value) {
|
|
54
|
+
this.$description.value = value;
|
|
55
|
+
return this;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
MenuItem.prototype.data = function(data) {
|
|
59
|
+
this.$description.data = data;
|
|
60
|
+
return this;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
MenuItem.prototype.divider = function() {
|
|
64
|
+
return this.item(new MenuDivider());
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
MenuItem.prototype.group = function(label, builder) {
|
|
68
|
+
const group = new MenuGroup(label);
|
|
69
|
+
builder && builder(group);
|
|
70
|
+
return this.item(group);
|
|
71
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default function Modal(config = {}) {
|
|
6
|
+
if(!(this instanceof Modal)) {
|
|
7
|
+
return new Modal(config);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
this.$description = {
|
|
11
|
+
centered: true,
|
|
12
|
+
scrollable: false,
|
|
13
|
+
title: null,
|
|
14
|
+
content: null,
|
|
15
|
+
footer: null,
|
|
16
|
+
size: null,
|
|
17
|
+
closeOnBackdrop: true,
|
|
18
|
+
closeOnEscape: true,
|
|
19
|
+
closable: true,
|
|
20
|
+
layout: null,
|
|
21
|
+
...config
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
BaseComponent.extends(Modal, EventEmitter);
|
|
26
|
+
|
|
27
|
+
// Theming
|
|
28
|
+
Modal.defaultLayout = null;
|
|
29
|
+
// Modal.defaultBackdrop = null;
|
|
30
|
+
Modal.defaultOverlay = null;
|
|
31
|
+
Modal.defaultHeaderTemplate = null;
|
|
32
|
+
Modal.defaultContentTemplate = null;
|
|
33
|
+
Modal.defaultFooterTemplate = null;
|
|
34
|
+
Modal.use = function(template) {};
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Modal.prototype.open = function() {};
|
|
38
|
+
Modal.prototype.close = function() {};
|
|
39
|
+
Modal.prototype.isOpen = function() {};
|
|
40
|
+
Modal.prototype.isClose = function() {};
|
|
41
|
+
|
|
42
|
+
// Configuration
|
|
43
|
+
Modal.prototype.title = function(title) {
|
|
44
|
+
this.$description.title = title;
|
|
45
|
+
return this;
|
|
46
|
+
};
|
|
47
|
+
Modal.prototype.content = function(content) {
|
|
48
|
+
this.$description.content = content;
|
|
49
|
+
return this;
|
|
50
|
+
};
|
|
51
|
+
Modal.prototype.footer = function(footer) {
|
|
52
|
+
this.$description.footer = footer;
|
|
53
|
+
return this;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
Modal.prototype.size = function(size) {
|
|
57
|
+
this.$description.size = size;
|
|
58
|
+
return this;
|
|
59
|
+
};
|
|
60
|
+
Modal.prototype.small = function() {
|
|
61
|
+
return this.size('small');
|
|
62
|
+
};
|
|
63
|
+
Modal.prototype.medium = function() {
|
|
64
|
+
return this.size('medium');
|
|
65
|
+
};
|
|
66
|
+
Modal.prototype.large = function() {
|
|
67
|
+
return this.size('large');
|
|
68
|
+
};
|
|
69
|
+
Modal.prototype.extraLarge = function() {
|
|
70
|
+
return this.size('extra-large');
|
|
71
|
+
};
|
|
72
|
+
Modal.prototype.fullscreen = function() {
|
|
73
|
+
return this.size('fullscreen');
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
Modal.prototype.centered = function() {
|
|
77
|
+
this.$description.centered = true;
|
|
78
|
+
return this;
|
|
79
|
+
};
|
|
80
|
+
Modal.prototype.scrollable = function() {
|
|
81
|
+
this.$description.scrollable = true;
|
|
82
|
+
return this;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
Modal.prototype.closeOnBackdrop = function(enabled = true) {
|
|
87
|
+
this.$description.closeOnBackdrop = enabled;
|
|
88
|
+
return this;
|
|
89
|
+
};
|
|
90
|
+
Modal.prototype.closeOnEscape = function(enabled = true) {
|
|
91
|
+
this.$description.closeOnEscape = enabled;
|
|
92
|
+
return this;
|
|
93
|
+
};
|
|
94
|
+
Modal.prototype.closable = function(enabled = true) {
|
|
95
|
+
this.$description.closable = enabled;
|
|
96
|
+
return this;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
Modal.prototype.onOpen = function(handler) {
|
|
101
|
+
this.on('open', handler);
|
|
102
|
+
return this;
|
|
103
|
+
};
|
|
104
|
+
Modal.prototype.onClose = function(handler) {
|
|
105
|
+
this.on('close', handler);
|
|
106
|
+
return this;
|
|
107
|
+
};
|
|
108
|
+
Modal.prototype.onBeforeOpen = function(handler) {
|
|
109
|
+
this.on('beforeOpen', handler);
|
|
110
|
+
return this;
|
|
111
|
+
};
|
|
112
|
+
Modal.prototype.onBeforeClose = function(handler) {
|
|
113
|
+
this.on('beforeClose', handler);
|
|
114
|
+
return this;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
Modal.prototype.renderHeader = function(renderFn) {
|
|
118
|
+
this.$description.renderHeader = renderFn
|
|
119
|
+
return this;
|
|
120
|
+
};
|
|
121
|
+
Modal.prototype.renderContent = function(renderFn) {
|
|
122
|
+
this.$description.renderContent = renderFn
|
|
123
|
+
return this;
|
|
124
|
+
};
|
|
125
|
+
Modal.prototype.renderFooter = function(renderFn) {
|
|
126
|
+
this.$description.renderFooter = renderFn
|
|
127
|
+
return this;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
Modal.prototype.layout = function(layoutFn) {
|
|
131
|
+
this.$description.layout = layoutFn;
|
|
132
|
+
return this;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
Modal.prototype.$buildHeader = function() {
|
|
136
|
+
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
Modal.prototype.$buildContent = function() {
|
|
140
|
+
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
Modal.prototype.$buildFooter = function() {
|
|
144
|
+
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
Modal.prototype.$build = function() {
|
|
148
|
+
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
Modal.prototype.toNdElement = function() {
|
|
152
|
+
|
|
153
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
|
+
|
|
4
|
+
export default function Pagination(config = {}) {
|
|
5
|
+
if(!(this instanceof Pagination)) {
|
|
6
|
+
return new Pagination(config);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
this.$description = {
|
|
10
|
+
currentPage: $(1),
|
|
11
|
+
pages: $.array([]),
|
|
12
|
+
totalPages: 1,
|
|
13
|
+
pageSize: 10,
|
|
14
|
+
totalItems: 0,
|
|
15
|
+
siblingCount: 1,
|
|
16
|
+
boundaryCount: 1,
|
|
17
|
+
showFirstLast: true,
|
|
18
|
+
showPreviousNext: true,
|
|
19
|
+
disabled: false,
|
|
20
|
+
data: null,
|
|
21
|
+
renderPage: null,
|
|
22
|
+
renderEllipsis: null,
|
|
23
|
+
renderPrevious: null,
|
|
24
|
+
renderNext: null,
|
|
25
|
+
renderFirst: null,
|
|
26
|
+
renderLast: null,
|
|
27
|
+
render: null,
|
|
28
|
+
...config
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
this.$element = null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
BaseComponent.extends(Pagination, EventEmitter);
|
|
35
|
+
|
|
36
|
+
Pagination.defaultTemplate = null;
|
|
37
|
+
|
|
38
|
+
Pagination.use = function(template) {
|
|
39
|
+
Pagination.defaultTemplate = template.pagination;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Pagination.prototype.currentPage = function(page) {
|
|
43
|
+
if (typeof page === 'number') {
|
|
44
|
+
this.$description.currentPage.set(page);
|
|
45
|
+
} else {
|
|
46
|
+
this.$description.currentPage = page;
|
|
47
|
+
}
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
Pagination.prototype.totalPages = function(total) {
|
|
52
|
+
this.$description.totalPages = total;
|
|
53
|
+
return this;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
Pagination.prototype.pageSize = function(size) {
|
|
57
|
+
this.$description.pageSize = size;
|
|
58
|
+
return this;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
Pagination.prototype.totalItems = function(total) {
|
|
62
|
+
this.$description.totalItems = total;
|
|
63
|
+
this.totalPages(Math.ceil(total / this.$description.pageSize));
|
|
64
|
+
return this;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Pagination.prototype.siblingCount = function(count) {
|
|
68
|
+
this.$description.siblingCount = count;
|
|
69
|
+
return this;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
Pagination.prototype.boundaryCount = function(count) {
|
|
73
|
+
this.$description.boundaryCount = count;
|
|
74
|
+
return this;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Pagination.prototype.showFirstLast = function(show = true) {
|
|
78
|
+
this.$description.showFirstLast = show;
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
Pagination.prototype.showPreviousNext = function(show = true) {
|
|
83
|
+
this.$description.showPreviousNext = show;
|
|
84
|
+
return this;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
Pagination.prototype.disabled = function(disabled = true) {
|
|
88
|
+
this.$description.disabled = disabled;
|
|
89
|
+
return this;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
Pagination.prototype.data = function(data) {
|
|
93
|
+
this.$description.data = data;
|
|
94
|
+
return this;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
Pagination.prototype.goToPage = function(page) {
|
|
98
|
+
if (page < 1 || page > this.$description.totalPages) {
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.$description.currentPage.set(page);
|
|
103
|
+
this.emit('pageChange', page);
|
|
104
|
+
return this;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
Pagination.prototype.next = function() {
|
|
108
|
+
const current = this.$description.currentPage.val();
|
|
109
|
+
return this.goToPage(current + 1);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
Pagination.prototype.previous = function() {
|
|
113
|
+
const current = this.$description.currentPage.val();
|
|
114
|
+
return this.goToPage(current - 1)
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
Pagination.prototype.first = function() {
|
|
118
|
+
return this.goToPage(1);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
Pagination.prototype.last = function() {
|
|
122
|
+
return this.goToPage(this.$description.totalPages);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
Pagination.prototype.hasNext = function() {
|
|
126
|
+
return this.$description.currentPage.val() < this.$description.totalPages;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
Pagination.prototype.hasPrevious = function() {
|
|
130
|
+
return this.$description.currentPage.val() > 1;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
Pagination.prototype.$updatePages = function() {
|
|
134
|
+
this.$description.pages.set(this.getPageNumbers());
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
Pagination.prototype.getPageNumbers = function() {
|
|
138
|
+
const current = this.$description.currentPage.val();
|
|
139
|
+
const total = this.$description.totalPages;
|
|
140
|
+
const siblings = this.$description.siblingCount;
|
|
141
|
+
const boundary = this.$description.boundaryCount;
|
|
142
|
+
|
|
143
|
+
const pages = [];
|
|
144
|
+
|
|
145
|
+
const leftSiblingIndex = Math.max(current - siblings, boundary + 1);
|
|
146
|
+
const rightSiblingIndex = Math.min(current + siblings, total - boundary);
|
|
147
|
+
|
|
148
|
+
const showLeftEllipsis = leftSiblingIndex > boundary + 2;
|
|
149
|
+
const showRightEllipsis = rightSiblingIndex < total - boundary - 1;
|
|
150
|
+
|
|
151
|
+
for (let i = 1; i <= boundary; i++) {
|
|
152
|
+
pages.push(i);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (showLeftEllipsis) {
|
|
156
|
+
pages.push('...');
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
for (let i = boundary + 1; i < leftSiblingIndex; i++) {
|
|
160
|
+
pages.push(i);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
for (let i = leftSiblingIndex; i <= rightSiblingIndex; i++) {
|
|
165
|
+
pages.push(i);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (showRightEllipsis) {
|
|
169
|
+
pages.push('...');
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
for (let i = rightSiblingIndex + 1; i < total - boundary + 1; i++) {
|
|
173
|
+
pages.push(i);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
for (let i = Math.max(total - boundary + 1, boundary + 1); i <= total; i++) {
|
|
178
|
+
if (!pages.includes(i)) {
|
|
179
|
+
pages.push(i);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return pages;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
Pagination.prototype.onPageChange = function(handler) {
|
|
187
|
+
this.on('pageChange', handler);
|
|
188
|
+
return this;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
Pagination.prototype.onChange = function(handler) {
|
|
192
|
+
this.on('pageChange', handler);
|
|
193
|
+
return this;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
Pagination.prototype.renderPage = function(renderFn) {
|
|
197
|
+
this.$description.renderPage = renderFn;
|
|
198
|
+
return this;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
Pagination.prototype.renderEllipsis = function(renderFn) {
|
|
202
|
+
this.$description.renderEllipsis = renderFn;
|
|
203
|
+
return this;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
Pagination.prototype.renderPrevious = function(renderFn) {
|
|
207
|
+
this.$description.renderPrevious = renderFn;
|
|
208
|
+
return this;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
Pagination.prototype.renderNext = function(renderFn) {
|
|
212
|
+
this.$description.renderNext = renderFn;
|
|
213
|
+
return this;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
Pagination.prototype.renderFirst = function(renderFn) {
|
|
217
|
+
this.$description.renderFirst = renderFn;
|
|
218
|
+
return this;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
Pagination.prototype.renderLast = function(renderFn) {
|
|
222
|
+
this.$description.renderLast = renderFn;
|
|
223
|
+
return this;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
Pagination.prototype.$build = function() {
|
|
227
|
+
|
|
228
|
+
return null;
|
|
229
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
|
+
|
|
4
|
+
export default function Popover(config = {}) {
|
|
5
|
+
if (!(this instanceof Popover)) {
|
|
6
|
+
return new Popover(config);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
this.$description = {
|
|
10
|
+
trigger: null,
|
|
11
|
+
content: null,
|
|
12
|
+
header: null,
|
|
13
|
+
footer: null,
|
|
14
|
+
isOpen: $(false),
|
|
15
|
+
defaultOpen: false,
|
|
16
|
+
modal: false,
|
|
17
|
+
closeOnEscape: true,
|
|
18
|
+
closeOnClickOutside: true,
|
|
19
|
+
focusTrap: true,
|
|
20
|
+
returnFocus: true,
|
|
21
|
+
position: 'bottom',
|
|
22
|
+
offset: [0, 8],
|
|
23
|
+
data: null,
|
|
24
|
+
renderContent: null,
|
|
25
|
+
renderHeader: null,
|
|
26
|
+
renderFooter: null,
|
|
27
|
+
render: null,
|
|
28
|
+
...config,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
this.$element = null;
|
|
32
|
+
|
|
33
|
+
if (this.$description.defaultOpen) {
|
|
34
|
+
this.$description.isOpen.set(true);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
BaseComponent.extends(Popover, EventEmitter);
|
|
39
|
+
|
|
40
|
+
Popover.defaultTemplate = null;
|
|
41
|
+
|
|
42
|
+
Popover.use = function(template) {
|
|
43
|
+
Popover.defaultTemplate = template.popover;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
Popover.prototype.trigger = function(trigger) {
|
|
47
|
+
if (trigger instanceof PopoverTrigger) {
|
|
48
|
+
this.$description.trigger = trigger.toJSON();
|
|
49
|
+
} else {
|
|
50
|
+
this.$description.trigger = trigger;
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
Popover.prototype.content = function(content) {
|
|
56
|
+
this.$description.content = content;
|
|
57
|
+
return this;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
Popover.prototype.header = function(header) {
|
|
61
|
+
this.$description.header = header;
|
|
62
|
+
return this;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
Popover.prototype.footer = function(footer) {
|
|
66
|
+
this.$description.footer = footer;
|
|
67
|
+
return this;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
Popover.prototype.closeOnEscape = function(closeOnEscape = true) {
|
|
71
|
+
this.$description.closeOnEscape = closeOnEscape;
|
|
72
|
+
return this;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
Popover.prototype.closeOnClickOutside = function(closeOnClickOutside = true) {
|
|
76
|
+
this.$description.closeOnClickOutside = closeOnClickOutside;
|
|
77
|
+
return this;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
Popover.prototype.focusTrap = function(trap = true) {
|
|
81
|
+
this.$description.focusTrap = trap;
|
|
82
|
+
return this;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Popover.prototype.returnFocus = function(returnFocus = true) {
|
|
86
|
+
this.$description.returnFocus = returnFocus;
|
|
87
|
+
return this;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
Popover.prototype.position = function(position) {
|
|
91
|
+
this.$description.position = position;
|
|
92
|
+
return this;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
Popover.prototype.atTop = function() {
|
|
96
|
+
return this.position('top');
|
|
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');
|
|
115
|
+
};
|
|
116
|
+
Popover.prototype.atBottomEnd = function() {
|
|
117
|
+
return this.position('bottom-end');
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
Popover.prototype.offset = function(skidding, distance) {
|
|
121
|
+
this.$description.offset = [skidding, distance];
|
|
122
|
+
return this;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
Popover.prototype.bindOpen = function(observable) {
|
|
126
|
+
this.$description.isOpen = observable;
|
|
127
|
+
return this;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
Popover.prototype.data = function(data) {
|
|
131
|
+
this.$description.data = data;
|
|
132
|
+
return this;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
Popover.prototype.open = function() {
|
|
136
|
+
this.$description.isOpen.set(true);
|
|
137
|
+
this.emit('open');
|
|
138
|
+
return this;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
Popover.prototype.close = function() {
|
|
142
|
+
this.$description.isOpen.set(false);
|
|
143
|
+
this.emit('close');
|
|
144
|
+
return this;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
Popover.prototype.toggle = function() {
|
|
148
|
+
this.$description.isOpen.val() ? this.close() : this.open();
|
|
149
|
+
return this;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
Popover.prototype.onOpen = function(handler) {
|
|
153
|
+
this.on('open', handler);
|
|
154
|
+
return this;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
Popover.prototype.onClose = function(handler) {
|
|
158
|
+
this.on('close', handler);
|
|
159
|
+
return this;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
Popover.prototype.renderTrigger = function(renderFn) {
|
|
163
|
+
this.$description.renderTrigger = renderFn;
|
|
164
|
+
return this;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
Popover.prototype.renderContent = function(renderFn) {
|
|
168
|
+
this.$description.renderContent = renderFn;
|
|
169
|
+
return this;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
Popover.prototype.renderHeader = function(renderFn) {
|
|
173
|
+
this.$description.renderHeader = renderFn;
|
|
174
|
+
return this;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
Popover.prototype.renderFooter = function(renderFn) {
|
|
178
|
+
this.$description.renderFooter = renderFn;
|
|
179
|
+
return this;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
Popover.prototype.render = function(renderFn) {
|
|
183
|
+
this.$description.render = renderFn;
|
|
184
|
+
return this;
|
|
185
|
+
};
|