native-document 1.0.76 → 1.0.77

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.
Files changed (184) hide show
  1. package/components.js +26 -1
  2. package/dist/native-document.components.min.js +6360 -1925
  3. package/dist/native-document.dev.js +122 -56
  4. package/dist/native-document.dev.js.map +1 -1
  5. package/dist/native-document.devtools.min.js +1 -1
  6. package/dist/native-document.min.js +1 -1
  7. package/jsconfig.json +15 -0
  8. package/package.json +1 -1
  9. package/rollup.config.js +4 -2
  10. package/src/components/$traits/HasItems.js +38 -0
  11. package/src/components/BaseComponent.js +70 -0
  12. package/src/components/accordion/Accordion.js +133 -0
  13. package/src/components/accordion/AccordionItem.js +119 -0
  14. package/src/components/accordion/index.js +7 -0
  15. package/src/components/alert/Alert.js +155 -0
  16. package/src/components/alert/index.js +6 -0
  17. package/src/components/avatar/Avatar.js +178 -0
  18. package/src/components/avatar/index.js +5 -0
  19. package/src/components/badge/Badge.js +103 -0
  20. package/src/components/badge/index.js +6 -0
  21. package/src/components/breadcrumb/BreadCrumb.js +70 -0
  22. package/src/components/breadcrumb/index.js +5 -0
  23. package/src/components/button/Button.js +174 -0
  24. package/src/components/button/index.js +5 -0
  25. package/src/components/card/Card.js +110 -0
  26. package/src/components/card/index.js +5 -0
  27. package/src/components/context-menu/ContextMenu.js +60 -0
  28. package/src/components/context-menu/ContextMenuGroup.js +16 -0
  29. package/src/components/context-menu/ContextMenuItem.js +16 -0
  30. package/src/components/context-menu/index.js +10 -0
  31. package/src/components/divider/Divider.js +126 -0
  32. package/src/components/divider/index.js +6 -0
  33. package/src/components/dropdown/Dropdown.js +170 -0
  34. package/src/components/dropdown/DropdownDivider.js +24 -0
  35. package/src/components/dropdown/DropdownGroup.js +44 -0
  36. package/src/components/dropdown/DropdownItem.js +71 -0
  37. package/src/components/dropdown/DropdownTrigger.js +64 -0
  38. package/src/components/dropdown/index.js +13 -0
  39. package/src/components/{fom-control → form}/FormControl.js +30 -22
  40. package/src/components/{fom-control → form}/field/DefaultRender.js +2 -16
  41. package/src/components/{fom-control → form}/field/Field.js +67 -140
  42. package/src/components/{fom-control → form}/field/FieldCollection.js +42 -22
  43. package/src/components/{fom-control → form}/field/types/AutocompleteField.js +11 -0
  44. package/src/components/form/field/types/CheckboxField.js +36 -0
  45. package/src/components/{fom-control → form}/field/types/CheckboxGroupField.js +10 -0
  46. package/src/components/{fom-control → form}/field/types/ColorField.js +11 -1
  47. package/src/components/{fom-control → form}/field/types/DateField.js +11 -1
  48. package/src/components/{fom-control → form}/field/types/EmailField.js +11 -1
  49. package/src/components/{fom-control → form}/field/types/FileField.js +11 -1
  50. package/src/components/form/field/types/HiddenField.js +18 -0
  51. package/src/components/{fom-control → form}/field/types/ImageField.js +11 -1
  52. package/src/components/{fom-control → form}/field/types/NumberField.js +11 -1
  53. package/src/components/{fom-control → form}/field/types/PasswordField.js +11 -1
  54. package/src/components/{fom-control → form}/field/types/RadioField.js +28 -2
  55. package/src/components/{fom-control → form}/field/types/RangeField.js +10 -0
  56. package/src/components/{fom-control → form}/field/types/SearchField.js +10 -0
  57. package/src/components/{fom-control → form}/field/types/SelectField.js +10 -0
  58. package/src/components/{fom-control → form}/field/types/StringField.js +11 -1
  59. package/src/components/{fom-control → form}/field/types/TelField.js +11 -2
  60. package/src/components/{fom-control → form}/field/types/TextAreaField.js +10 -0
  61. package/src/components/{fom-control → form}/field/types/TimeField.js +11 -2
  62. package/src/components/{fom-control → form}/field/types/UrlField.js +10 -2
  63. package/src/components/form/index.js +49 -0
  64. package/src/components/{fom-control → form}/validation/Validation.js +1 -1
  65. package/src/components/list/List.js +106 -0
  66. package/src/components/list/ListGroup.js +67 -0
  67. package/src/components/list/ListItem.js +103 -0
  68. package/src/components/list/index.js +10 -0
  69. package/src/components/menu/Menu.js +82 -0
  70. package/src/components/menu/MenuDivider.js +22 -0
  71. package/src/components/menu/MenuGroup.js +42 -0
  72. package/src/components/menu/MenuItem.js +71 -0
  73. package/src/components/menu/index.js +13 -0
  74. package/src/components/modal/Modal.js +153 -0
  75. package/src/components/modal/index.js +5 -0
  76. package/src/components/pagination/Pagination.js +229 -0
  77. package/src/components/pagination/index.js +5 -0
  78. package/src/components/popover/Popover.js +185 -0
  79. package/src/components/popover/PopoverFooter.js +37 -0
  80. package/src/components/popover/PopoverHeader.js +43 -0
  81. package/src/components/popover/index.js +10 -0
  82. package/src/components/progress/Progress.js +220 -0
  83. package/src/components/progress/index.js +6 -0
  84. package/src/components/skeleton/Skeleton.js +98 -0
  85. package/src/components/skeleton/SkeletonCard.js +0 -0
  86. package/src/components/skeleton/SkeletonList.js +0 -0
  87. package/src/components/skeleton/SkeletonParagraph.js +0 -0
  88. package/src/components/skeleton/SkeletonTable.js +0 -0
  89. package/src/components/skeleton/index.js +6 -0
  90. package/src/components/slider/Slider.js +183 -0
  91. package/src/components/slider/index.js +5 -0
  92. package/src/components/spinner/Spinner.js +160 -0
  93. package/src/components/spinner/index.js +5 -0
  94. package/src/components/splitter/Splitter.js +95 -0
  95. package/src/components/splitter/SplitterGutter.js +57 -0
  96. package/src/components/splitter/SplitterPanel.js +82 -0
  97. package/src/components/splitter/index.js +8 -0
  98. package/src/components/stepper/Stepper.js +229 -0
  99. package/src/components/stepper/StepperStep.js +103 -0
  100. package/src/components/stepper/index.js +8 -0
  101. package/src/components/switch/Switch.js +99 -0
  102. package/src/components/switch/index.js +0 -0
  103. package/src/components/table/ColumnGroup.js +1 -1
  104. package/src/components/table/DataTable.js +1 -1
  105. package/src/components/table/SimpleTable.js +36 -32
  106. package/src/components/tabs/Tabs.js +110 -0
  107. package/src/components/tabs/index.js +6 -0
  108. package/src/components/toast/Toast.js +129 -0
  109. package/src/components/toast/ToastError.js +0 -0
  110. package/src/components/toast/ToastInfo.js +0 -0
  111. package/src/components/toast/ToastSuccess.js +0 -0
  112. package/src/components/toast/ToastWarning.js +0 -0
  113. package/src/components/toast/index.js +5 -0
  114. package/src/components/tooltip/Tooltip.js +98 -0
  115. package/src/components/tooltip/index.js +5 -0
  116. package/src/components/tooltip/prototypes.js +6 -0
  117. package/src/core/data/MemoryManager.js +2 -2
  118. package/src/core/data/Observable.js +1 -1
  119. package/src/core/data/ObservableArray.js +14 -8
  120. package/src/core/data/ObservableItem.js +5 -5
  121. package/src/core/data/observable-helpers/array.js +2 -2
  122. package/src/core/data/observable-helpers/batch.js +2 -2
  123. package/src/core/data/observable-helpers/computed.js +6 -6
  124. package/src/core/data/observable-helpers/object.js +2 -2
  125. package/src/core/elements/anchor.js +3 -3
  126. package/src/core/elements/content-formatter.js +1 -1
  127. package/src/core/elements/control/for-each-array.js +42 -68
  128. package/src/core/elements/control/for-each.js +7 -7
  129. package/src/core/elements/control/show-if.js +5 -5
  130. package/src/core/elements/control/show-when.js +2 -2
  131. package/src/core/elements/control/switch.js +4 -4
  132. package/src/core/elements/description-list.js +1 -1
  133. package/src/core/elements/form.js +1 -1
  134. package/src/core/elements/html5-semantics.js +1 -1
  135. package/src/core/elements/img.js +3 -3
  136. package/src/core/elements/index.js +1 -1
  137. package/src/core/elements/interactive.js +1 -1
  138. package/src/core/elements/list.js +1 -1
  139. package/src/core/elements/medias.js +1 -1
  140. package/src/core/elements/meta-data.js +1 -1
  141. package/src/core/elements/table.js +1 -1
  142. package/src/core/utils/EventEmitter.js +1 -1
  143. package/src/core/utils/args-types.js +2 -2
  144. package/src/core/utils/events.js +68 -0
  145. package/src/core/utils/filters/standard.js +1 -1
  146. package/src/core/utils/filters/utils.js +1 -1
  147. package/src/core/utils/helpers.js +10 -7
  148. package/src/core/utils/prototypes.js +2 -2
  149. package/src/core/utils/validator.js +6 -5
  150. package/src/core/wrappers/AttributesWrapper.js +21 -38
  151. package/src/core/wrappers/DocumentObserver.js +1 -1
  152. package/src/core/wrappers/ElementCreator.js +9 -14
  153. package/src/core/wrappers/HtmlElementWrapper.js +2 -2
  154. package/src/core/wrappers/NDElement.js +3 -3
  155. package/src/core/wrappers/NdPrototype.js +24 -31
  156. package/src/core/wrappers/SingletonView.js +1 -1
  157. package/src/core/wrappers/TemplateCloner.js +60 -18
  158. package/src/core/wrappers/constants.js +32 -1
  159. package/src/core/wrappers/prototypes/attributes-extensions.js +18 -5
  160. package/src/core/wrappers/prototypes/bind-class-extensions.js +18 -0
  161. package/src/core/wrappers/prototypes/nd-element-extensions.js +6 -6
  162. package/src/devtools/app/App.js +2 -2
  163. package/src/devtools/hrm/ComponentRegistry.js +2 -2
  164. package/src/devtools/plugin.js +1 -1
  165. package/src/devtools/widget/DevToolsWidget.js +2 -2
  166. package/src/router/Route.js +1 -1
  167. package/src/router/RouteGroupHelper.js +1 -1
  168. package/src/router/Router.js +4 -4
  169. package/src/router/RouterComponent.js +1 -1
  170. package/src/router/link.js +3 -3
  171. package/src/router/modes/HistoryRouter.js +1 -2
  172. package/types/filters/dates.d.ts +1 -1
  173. package/types/filters/standard.d.ts +0 -1
  174. package/types/filters/types.d.ts +1 -1
  175. package/utils.js +3 -3
  176. package/src/components/fom-control/default/DefaultLayout.js +0 -8
  177. package/src/components/fom-control/default/collection/DefaultCollectionLayout.js +0 -12
  178. package/src/components/fom-control/default/collection/DefaultCollectionTemplate.js +0 -6
  179. package/src/components/fom-control/field/types/CheckboxField.js +0 -17
  180. package/src/components/fom-control/field/types/HiddenField.js +0 -8
  181. package/src/components/fom-control/index.js +0 -8
  182. /package/src/components/{fom-control → form}/field/FieldFactory.js +0 -0
  183. /package/src/components/{fom-control → form}/merge +0 -0
  184. /package/src/components/{fom-control → form}/utils.js +0 -0
@@ -0,0 +1,82 @@
1
+ import BaseComponent from "@components/BaseComponent";
2
+ import EventEmitter from "@src/core/utils/EventEmitter";
3
+ import HasItems from "@components/$traits/HasItems";
4
+ import MenuDivider from "./MenuDivider";
5
+ import MenuGroup from "./MenuGroup";
6
+
7
+ export default function Menu(config = {}) {
8
+
9
+ if(!(this instanceof Menu)) {
10
+ return new Menu(config)
11
+ }
12
+
13
+ this.$description = {
14
+ items: [],
15
+ render: null,
16
+ orientation: 'horizontal',
17
+ closeOnSelect: true,
18
+ keyboardLoop: true,
19
+ ...config
20
+ };
21
+
22
+ }
23
+
24
+ BaseComponent.extends(Menu, HasItems, EventEmitter);
25
+
26
+ Menu.defaultTemplate = null;
27
+
28
+ Menu.use = function(template) {
29
+ Menu.defaultTemplate = template.menu;
30
+ };
31
+
32
+ Menu.prototype.orientation = function(orientation) {
33
+ this.$description.orientation = orientation;
34
+ return this;
35
+ };
36
+
37
+ Menu.prototype.horizontal = function() {
38
+ this.$description.orientation = 'horizontal';
39
+ return this;
40
+ };
41
+
42
+ Menu.prototype.vertical = function() {
43
+ this.$description.orientation = 'vertical';
44
+ return this;
45
+ };
46
+
47
+ Menu.prototype.closeOnSelect = function(close = true) {
48
+ this.$description.closeOnSelect = close;
49
+ return this;
50
+ };
51
+
52
+ Menu.prototype.keyboardLoop = function(keyboardLoop = true) {
53
+ this.$description.keyboardLoop = keyboardLoop;
54
+ return this;
55
+ };
56
+
57
+ Menu.prototype.data = function(data) {
58
+ this.$description.data = data;
59
+ return this;
60
+ };
61
+
62
+ Menu.prototype.onItemClick = function(handler) {
63
+ this.on('itemClick', handler);
64
+ return this;
65
+ };
66
+
67
+ Menu.prototype.onItemSelect = function(handler) {
68
+ this.on('itemSelect', handler);
69
+ return this;
70
+ };
71
+
72
+
73
+
74
+ Menu.prototype.divider = function() {
75
+ return this.item(new MenuDivider());
76
+ };
77
+
78
+ Menu.prototype.group = function(label, builder) {
79
+ const group = new MenuGroup(label);
80
+ builder && builder(group);
81
+ return this.item(group);
82
+ };
@@ -0,0 +1,22 @@
1
+ import BaseComponent from "@components/BaseComponent";
2
+
3
+
4
+ export default function MenuDivider() {
5
+ if(!this instanceof MenuDivider) {
6
+ return new MenuDivider();
7
+ }
8
+
9
+ }
10
+
11
+ BaseComponent.extends(MenuDivider);
12
+
13
+
14
+ MenuDivider.defaultTemplate = null;
15
+
16
+ MenuDivider.use = function(template) {
17
+ MenuDivider.defaultTemplate = template.divider;
18
+ };
19
+
20
+ MenuDivider.prototype.$build = function() {
21
+
22
+ };
@@ -0,0 +1,42 @@
1
+ import BaseComponent from "@components/BaseComponent";
2
+ import HasItems from "@components/$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 "@components/BaseComponent";
2
+ import HasItems from "@components/$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,13 @@
1
+ import Menu from "./Menu";
2
+ import MenuItem from "./MenuItem";
3
+ import MenuGroup from "./MenuGroup";
4
+ import MenuDivider from "./MenuDivider";
5
+
6
+
7
+ export {
8
+ Menu,
9
+ MenuItem,
10
+ MenuGroup,
11
+ MenuDivider,
12
+ MenuInterface
13
+ };
@@ -0,0 +1,153 @@
1
+ import BaseComponent from "@components/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,5 @@
1
+ import Modal from './Modal'
2
+
3
+ export {
4
+ Modal
5
+ }
@@ -0,0 +1,229 @@
1
+ import BaseComponent from "@components/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,5 @@
1
+ import Pagination from "./Pagination";
2
+
3
+ export {
4
+ Pagination
5
+ }