native-document 1.0.75 → 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 +6401 -1979
  3. package/dist/native-document.dev.js +138 -82
  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 +5 -8
  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 +22 -23
  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 +17 -36
  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,229 @@
1
+ import BaseComponent from "@components/BaseComponent";
2
+ import EventEmitter from "@src/core/utils/EventEmitter";
3
+ import {$, Validator} from "@core";
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
+ };
@@ -0,0 +1,103 @@
1
+ import BaseComponent from "@components/BaseComponent";
2
+ import { $ } from '@core';
3
+
4
+ export default function StepperStep(label, config = {}) {
5
+ if(!(this instanceof StepperStep)) {
6
+ return new StepperStep(label, config);
7
+ }
8
+
9
+ this.$description = {
10
+ icon: null,
11
+ label: label,
12
+ description: null,
13
+ content: null,
14
+ status: $('pending'),
15
+ optional: $(false),
16
+ disabled: $(false),
17
+ completed: $(false),
18
+ error: $(false),
19
+ data: null,
20
+ render: null,
21
+ validator: null,
22
+ key: null,
23
+ ...config
24
+ };
25
+ }
26
+
27
+ BaseComponent.extends(StepperStep);
28
+
29
+ StepperStep.defaultTemplate = null;
30
+
31
+ StepperStep.use = function(template) {
32
+ StepperStep.defaultTemplate = template.stepperStep;
33
+ };
34
+
35
+ StepperStep.prototype.icon = function(icon) {
36
+ this.$description.icon = icon;
37
+ return this;
38
+ };
39
+
40
+ StepperStep.prototype.label = function(label) {
41
+ this.$description.label = label;
42
+ return this;
43
+ };
44
+
45
+ StepperStep.prototype.description = function(description) {
46
+ this.$description.description = description;
47
+ return this;
48
+ };
49
+
50
+ StepperStep.prototype.content = function(content) {
51
+ this.$description.content = content;
52
+ return this;
53
+ };
54
+
55
+ StepperStep.prototype.status = function(status) {
56
+ this.$description.status.set(status);
57
+ return this;
58
+ };
59
+
60
+ StepperStep.prototype.optional = function(optional = true) {
61
+ this.$description.optional.set(optional);
62
+ return this;
63
+ };
64
+
65
+ StepperStep.prototype.disabled = function(disabled = true) {
66
+ this.$description.disabled.set(disabled);
67
+ return this;
68
+ };
69
+
70
+ StepperStep.prototype.completed = function(completed = true) {
71
+ this.$description.completed.set(completed);
72
+ this.$description.status.set(completed ? 'completed' : 'pending');
73
+ return this;
74
+ };
75
+
76
+ StepperStep.prototype.error = function(error = true) {
77
+ this.$description.error.set(error);
78
+ this.$description.status.set(error ? 'error' : 'pending');
79
+ return this;
80
+ };
81
+
82
+ StepperStep.prototype.data = function(data) {
83
+ this.$description.data = data;
84
+ return this;
85
+ };
86
+
87
+ StepperStep.prototype.key = function(key) {
88
+ this.$description.key = key;
89
+ return this;
90
+ };
91
+
92
+ StepperStep.prototype.getKey = function() {
93
+ return this.$description.key;
94
+ };
95
+
96
+ StepperStep.prototype.validator = function(validatorFn) {
97
+ this.$description.validator = validatorFn;
98
+ return this;
99
+ };
100
+
101
+ StepperStep.prototype.validate = function() {
102
+ return true;
103
+ };
@@ -0,0 +1,8 @@
1
+ import Stepper from "./Stepper";
2
+ import StepperStep from "./StepperStep";
3
+
4
+
5
+ export {
6
+ Stepper,
7
+ StepperStep
8
+ }
@@ -0,0 +1,99 @@
1
+ import BaseComponent from "@components/BaseComponent";
2
+ import EventEmitter from "@src/core/utils/EventEmitter";
3
+
4
+ function Switch(config = {}) {
5
+ if (!(this instanceof Switch)) {
6
+ return new Switch(config);
7
+ }
8
+
9
+ this.$description = {
10
+
11
+ };
12
+ }
13
+
14
+ BaseComponent.extends(Switch, EventEmitter);
15
+
16
+ // Theming
17
+ Switch.defaultTemplate = null;
18
+ Switch.use = function(template) {
19
+
20
+ };
21
+
22
+ Switch.prototype.model = function(value) {};
23
+ Switch.prototype.value = function() {};
24
+
25
+ Switch.prototype.label = function(label) {};
26
+ Switch.prototype.labelPosition = function(position) {};
27
+
28
+ Switch.prototype.variant = function(name) {
29
+ this.$description.variant = name;
30
+ return this;
31
+ };
32
+ Switch.prototype.primary = function() {
33
+ return this.variant('primary');
34
+ };
35
+ Switch.prototype.secondary = function() {
36
+ return this.variant('secondary');
37
+ };
38
+ Switch.prototype.danger = function() {
39
+ return this.variant('danger');
40
+ };
41
+ Switch.prototype.success = function() {
42
+ return this.variant('success');
43
+ };
44
+ Switch.prototype.warning = function() {
45
+ return this.variant('warning');
46
+ };
47
+ Switch.prototype.ghost = function() {
48
+ return this.variant('ghost');
49
+ };
50
+ Switch.prototype.link = function() {
51
+ return this.variant('link');
52
+ };
53
+ Switch.prototype.outline = function() {
54
+ this.$description.outline = true;
55
+ return this;
56
+ };
57
+
58
+ Switch.prototype.disabled = function(condition = true) {
59
+ this.$description.disabled = condition;
60
+ return this;
61
+ };
62
+ Switch.prototype.loading = function(isLoading = true) {
63
+ this.$description.loading = isLoading;
64
+ return this;
65
+ };
66
+ Switch.prototype.readonly = function(condition = true) {
67
+ this.$description.readonly = condition;
68
+ return this;
69
+ };
70
+
71
+ Switch.prototype.icon = function(onIcon, offIcon) {};
72
+
73
+ Switch.prototype.toggle = function() {};
74
+ Switch.prototype.on = function() {};
75
+ Switch.prototype.off = function() {};
76
+
77
+ Switch.prototype.onChange = function(handler) {
78
+ this.on('change', handler);
79
+ return this;
80
+ };
81
+ Switch.prototype.onOn = function(handler) {
82
+ this.on('on', handler);
83
+ return this;
84
+ };
85
+ Switch.prototype.onOff = function(handler) {
86
+ this.on('off', handler);
87
+ return this;
88
+ };
89
+
90
+ // Render
91
+ Switch.prototype.render = function(renderFn) {
92
+ this.$description.render = renderFn;
93
+ return this;
94
+ };
95
+
96
+ Switch.prototype.$build = function() {
97
+
98
+ };
99
+ Switch.prototype.toNdElement = function() {};
File without changes
@@ -1,5 +1,5 @@
1
1
  import Column from "./Column";
2
- import { THeadCell } from "../../../elements";
2
+ import { THeadCell } from "@elements";
3
3
 
4
4
  export default function ColumnGroup(title, configs = {}) {
5
5
  this.$description = {
@@ -1,5 +1,5 @@
1
1
  import SimpleTable from "./SimpleTable";
2
- import { Observable as $ } from "../../../index";
2
+ import { Observable as $ } from "@core";
3
3
 
4
4
  export default function DataTable(name, configs) {
5
5
  SimpleTable.call(this, name, configs);
@@ -14,9 +14,9 @@ export default function DataTable(name, configs) {
14
14
  ...configs
15
15
  });
16
16
 
17
- this.$currentPage = null;
18
- this.$selectedRows = [];
19
- this.$expandedRows = [];
17
+ this.$currentPage = $(1);
18
+ this.$selectedRows = $.array();
19
+ this.$expandedRows = $.array();
20
20
  }
21
21
 
22
22
  DataTable.defaultToolbarTemplate = null;
@@ -35,9 +35,6 @@ DataTable.prototype.constructor = DataTable;
35
35
 
36
36
  DataTable.prototype.paginate = function(size) {
37
37
  this.$description.pageSize = size;
38
- if(size > 0) {
39
- this.$currentPage = $(1);
40
- }
41
38
  return this;
42
39
  };
43
40
 
@@ -107,7 +104,7 @@ DataTable.prototype.goToLastPage = function(page) {
107
104
  return this;
108
105
  };
109
106
 
110
- DataTable.prototype.goToFistPage = function(page) {
107
+ DataTable.prototype.goToFirstPage = function(page) {
111
108
  // TODO: implement this action
112
109
  return this;
113
110
  };
@@ -1,6 +1,6 @@
1
1
  import Column from "./Column";
2
2
  import ColumnGroup from "./ColumnGroup";
3
- import {Table, TFoot, TRow} from "../../../elements";
3
+ import { Table, TFoot, TRow } from "@elements";
4
4
  import DataTable from "./DataTable";
5
5
 
6
6
 
@@ -122,37 +122,6 @@ SimpleTable.prototype.buildTable = function(slots = {}) {
122
122
  ]);
123
123
  };
124
124
 
125
- SimpleTable.prototype.build = function() {
126
- const header = [];
127
- if(this.$description.hasGroups) {
128
- const firstRow = [];
129
- const secondRow = [];
130
-
131
- this.$description.header.forEach(columnOrGroup => {
132
- if(columnOrGroup.isGroup) {
133
- const columns = columnOrGroup.columns();
134
- firstRow.push(columnOrGroup.buildHeader());
135
- secondRow.push(columns.map(column => THeadCell({}, column.buildHeader())));
136
- } else {
137
- firstRow.push(columnOrGroup.buildHeader(2));
138
- }
139
- });
140
-
141
- header.push(TRow(firstRow));
142
- header.push(TRow(secondRow));
143
- } else {
144
- header.push(TRow(
145
- this.$description.columns.map(column => column.buildHeader())
146
- ));
147
- }
148
-
149
- return this.buildTable({ headerRows: header });
150
- };
151
-
152
- SimpleTable.prototype.toNdElement = function() {
153
- return this.build();
154
- };
155
-
156
125
  SimpleTable.prototype.onClick = function(callback) {
157
126
  this.$description.onClick = callback;
158
127
  };
@@ -182,3 +151,38 @@ DataTable.prototype.isRowExpanded = function(row) {
182
151
  // TODO: implement this action
183
152
  return this;
184
153
  };
154
+
155
+
156
+ //
157
+
158
+
159
+ SimpleTable.prototype.$build = function() {
160
+ const header = [];
161
+ if(this.$description.hasGroups) {
162
+ const firstRow = [];
163
+ const secondRow = [];
164
+
165
+ this.$description.header.forEach(columnOrGroup => {
166
+ if(columnOrGroup.isGroup) {
167
+ const columns = columnOrGroup.columns();
168
+ firstRow.push(columnOrGroup.buildHeader());
169
+ secondRow.push(columns.map(column => THeadCell({}, column.buildHeader())));
170
+ } else {
171
+ firstRow.push(columnOrGroup.buildHeader(2));
172
+ }
173
+ });
174
+
175
+ header.push(TRow(firstRow));
176
+ header.push(TRow(secondRow));
177
+ } else {
178
+ header.push(TRow(
179
+ this.$description.columns.map(column => column.buildHeader())
180
+ ));
181
+ }
182
+
183
+ return this.buildTable({ headerRows: header });
184
+ };
185
+
186
+ SimpleTable.prototype.toNdElement = function() {
187
+ return this.$build();
188
+ };
@@ -0,0 +1,110 @@
1
+ import BaseComponent from "@components/BaseComponent";
2
+ import EventEmitter from "@src/core/utils/EventEmitter";
3
+
4
+
5
+ export default function Tabs(config = {}) {
6
+ if(!(this instanceof Tabs)) {
7
+ return new Tabs();
8
+ }
9
+ BaseComponent.apply(this);
10
+ this.$description = {
11
+ active: $(''),
12
+ tabs: {},
13
+ ...config,
14
+ };
15
+
16
+ this.tabsMap = {};
17
+ }
18
+
19
+ BaseComponent.extends(Tabs, EventEmitter);
20
+
21
+ Tabs.defaultTemplate = null;
22
+ Tabs.defaultTabTemplate = null;
23
+ Tabs.defaultNavigationBarTemplate = null;
24
+
25
+ Tabs.use = function(template) {};
26
+
27
+ Tabs.prototype.activateTab = function(key) {};
28
+ Tabs.prototype.closeTab = function(key) {};
29
+
30
+ Tabs.prototype.tab = function(label, content, key) {
31
+ this.$description.tabs[key] = { label, content };
32
+ this.tabsMap[key] = content;
33
+ return this;
34
+ };
35
+ Tabs.prototype.tabs = function(tabs) {
36
+ for(const item of tabs) {
37
+ this.tab(item.label, item.content, item.key);
38
+ }
39
+ return this;
40
+ };
41
+ Tabs.prototype.removeTab = function(key) {
42
+ delete this.$description.tabs[key];
43
+ delete this.tabsMap[key];
44
+ // Todo: remove tab from Match element
45
+ this.active(Object.keys(this.$description.tabs)[0]);
46
+ return this;
47
+ };
48
+
49
+ Tabs.prototype.active = function(key) {
50
+ this.$description.active.set(key);
51
+ };
52
+ Tabs.prototype.defaultActive = function(key) {};
53
+ Tabs.prototype.getActive = function() {};
54
+
55
+ Tabs.prototype.navigationBarPosition = function(position) {
56
+ this.$description.navigationBarPosition = position;
57
+ return this;
58
+ };
59
+ Tabs.prototype.navigationBarAtLeft = function() {
60
+ return this.navigationBarPosition('left');
61
+ };
62
+ Tabs.prototype.navigationBarAtRight = function() {
63
+ return this.navigationBarPosition('right');
64
+ };
65
+ Tabs.prototype.navigationBarAtTop = function() {
66
+ return this.navigationBarPosition('top');
67
+ }
68
+ Tabs.prototype.navigationBarAsDock = function() {
69
+ return this.navigationBarPosition('dock');
70
+ };
71
+
72
+ // Events
73
+ Tabs.prototype.onChange = function(handler) {
74
+ this.on('change', handler);
75
+ return this;
76
+ };
77
+ Tabs.prototype.onBeforeChange = function(handler) {
78
+ this.on('beforeChange', handler);
79
+ return this;
80
+ };
81
+ Tabs.prototype.onTabClick = function(handler) {
82
+ this.on('tabClick', handler);
83
+ return this;
84
+ };
85
+ Tabs.prototype.onTabClose = function(handler) {
86
+ this.on('tabClose', handler);
87
+ return this;
88
+ };
89
+
90
+
91
+ Tabs.prototype.renderTab = function(renderFn) {
92
+ this.$description.renderTab = renderFn;
93
+ return this;
94
+ };
95
+ Tabs.prototype.renderNavigationBar = function(renderFn) {
96
+ return this.$description.renderNavigationBar = renderFn;
97
+ };
98
+
99
+ Tabs.prototype.layout = function(layoutFn) {
100
+ this.$description.layout = layoutFn;
101
+ return this;
102
+ };
103
+
104
+ Tabs.prototype.$build = function() {
105
+
106
+ };
107
+
108
+ Tabs.prototype.toNdElement = function() {
109
+
110
+ };
@@ -0,0 +1,6 @@
1
+ import Tabs from './Tabs'
2
+
3
+
4
+ export {
5
+ Tabs
6
+ }