native-document 1.0.138 → 1.0.140

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 (259) hide show
  1. package/components.js +1 -1
  2. package/devtools/ComponentRegistry.js +3 -2
  3. package/dist/native-document.components.min.css +1 -0
  4. package/dist/native-document.components.min.js +11506 -8566
  5. package/dist/native-document.dev.js +2645 -2166
  6. package/dist/native-document.dev.js.map +1 -1
  7. package/dist/native-document.min.js +1 -1
  8. package/index.js +1 -0
  9. package/package.json +5 -2
  10. package/rollup.config.js +5 -2
  11. package/src/components/$traits/has-draggable/HasDraggable.js +69 -0
  12. package/src/components/$traits/has-draggable/has-draggable.css +8 -0
  13. package/src/components/$traits/{HasItems.js → has-items/HasItems.js} +2 -11
  14. package/src/components/$traits/has-position/HasFullPosition.js +51 -0
  15. package/src/components/$traits/has-position/HasPosition.js +23 -0
  16. package/src/components/$traits/has-resizable/HasResizable.js +113 -0
  17. package/src/components/$traits/has-resizable/has-resizable.css +121 -0
  18. package/src/components/$traits/has-validation/HasValidation.js +86 -0
  19. package/src/components/BaseComponent.js +109 -4
  20. package/src/components/accordion/Accordion.js +37 -31
  21. package/src/components/accordion/AccordionItem.js +14 -21
  22. package/src/components/alert/Alert.js +48 -40
  23. package/src/components/avatar/Avatar.js +4 -3
  24. package/src/components/avatar/AvatarGroup.js +8 -2
  25. package/src/components/badge/Badge.js +7 -7
  26. package/src/components/base-component.css +0 -0
  27. package/src/components/breadcrumb/BreadCrumb.js +30 -21
  28. package/src/components/button/Button.js +3 -14
  29. package/src/components/context-menu/ContextMenu.js +49 -26
  30. package/src/components/dropdown/Dropdown.js +172 -34
  31. package/src/components/dropdown/DropdownDivider.js +4 -3
  32. package/src/components/dropdown/DropdownGroup.js +19 -19
  33. package/src/components/dropdown/DropdownItem.js +24 -18
  34. package/src/components/dropdown/helpers.js +52 -0
  35. package/src/components/form/FormControl.js +207 -108
  36. package/src/components/form/field/Field.js +106 -174
  37. package/src/components/form/field/FieldCollection.js +110 -203
  38. package/src/components/form/field/types/AutocompleteField.js +26 -5
  39. package/src/components/form/field/types/CheckboxField.js +4 -4
  40. package/src/components/form/field/types/CheckboxGroupField.js +11 -5
  41. package/src/components/form/field/types/ColorField.js +4 -4
  42. package/src/components/form/field/types/DateField.js +110 -18
  43. package/src/components/form/field/types/EmailField.js +2 -2
  44. package/src/components/form/field/types/FileField.js +87 -21
  45. package/src/components/form/field/types/HiddenField.js +4 -4
  46. package/src/components/form/field/types/ImageField.js +4 -4
  47. package/src/components/form/field/types/NumberField.js +5 -5
  48. package/src/components/form/field/types/PasswordField.js +28 -6
  49. package/src/components/form/field/types/RadioField.js +12 -8
  50. package/src/components/form/field/types/RangeField.js +29 -5
  51. package/src/components/form/field/types/SearchField.js +4 -4
  52. package/src/components/form/field/types/SelectField.js +75 -8
  53. package/src/components/form/field/types/StringField.js +4 -4
  54. package/src/components/form/field/types/TelField.js +4 -4
  55. package/src/components/form/field/types/TextAreaField.js +7 -5
  56. package/src/components/form/field/types/TimeField.js +52 -6
  57. package/src/components/form/field/types/UrlField.js +4 -5
  58. package/src/components/form/field/types/file-field-mode/FileAvatarMode.js +104 -0
  59. package/src/components/form/field/types/file-field-mode/FileDropzoneMode.js +59 -0
  60. package/src/components/form/field/types/file-field-mode/FileItemPreview.js +74 -0
  61. package/src/components/form/field/types/file-field-mode/FileNativeMode.js +21 -0
  62. package/src/components/form/field/types/file-field-mode/FileUploadButtonMode.js +59 -0
  63. package/src/components/form/field/types/file-field-mode/FileWallMode.js +53 -0
  64. package/src/components/form/index.js +14 -2
  65. package/src/components/form/validation/Validation.js +9 -0
  66. package/src/components/list/List.js +1 -1
  67. package/src/components/list/ListGroup.js +1 -1
  68. package/src/components/menu/HasMenuItem.js +133 -0
  69. package/src/components/menu/Menu.js +47 -56
  70. package/src/components/menu/MenuGroup.js +36 -8
  71. package/src/components/menu/MenuItem.js +24 -10
  72. package/src/components/menu/MenuLink.js +2 -0
  73. package/src/components/modal/Modal.js +153 -23
  74. package/src/components/pagination/Pagination.js +55 -21
  75. package/src/components/popover/Popover.js +127 -40
  76. package/src/components/progress/Progress.js +14 -24
  77. package/src/components/skeleton/Skeleton.js +36 -13
  78. package/src/components/slider/Slider.js +96 -70
  79. package/src/components/spinner/Spinner.js +4 -2
  80. package/src/components/splitter/Splitter.js +15 -8
  81. package/src/components/splitter/SplitterGutter.js +28 -7
  82. package/src/components/splitter/SplitterPanel.js +9 -15
  83. package/src/components/splitter/index.js +3 -1
  84. package/src/components/stacks/AbsoluteStack.js +33 -0
  85. package/src/components/stacks/FixedStack.js +33 -0
  86. package/src/components/stacks/PositionStack.js +146 -0
  87. package/src/components/stacks/RelativeStack.js +33 -0
  88. package/src/components/{layouts → stacks}/Stack.js +22 -3
  89. package/src/components/{layouts → stacks}/index.js +6 -4
  90. package/src/components/stepper/Stepper.js +159 -67
  91. package/src/components/stepper/StepperStep.js +49 -12
  92. package/src/components/switch/Switch.js +59 -29
  93. package/src/components/switch/index.js +6 -0
  94. package/src/components/table/Column.js +22 -26
  95. package/src/components/table/ColumnGroup.js +4 -13
  96. package/src/components/table/DataTable.js +388 -103
  97. package/src/components/table/SimpleTable.js +28 -143
  98. package/src/components/tabs/Tabs.js +142 -44
  99. package/src/components/toast/Toast.js +40 -35
  100. package/src/components/tooltip/Tooltip.js +152 -35
  101. package/src/core/data/ObservableArray.js +94 -30
  102. package/src/core/data/ObservableChecker.js +20 -75
  103. package/src/core/data/ObservableItem.js +35 -3
  104. package/src/core/data/observable-helpers/computed.js +2 -1
  105. package/src/core/data/observable-helpers/object.js +13 -8
  106. package/src/core/data/observable-helpers/observable.is-to.js +196 -0
  107. package/src/core/elements/anchor/anchor.js +3 -2
  108. package/src/core/elements/control/for-each-array.js +44 -30
  109. package/src/core/elements/control/for-each.js +6 -3
  110. package/src/core/elements/control/show-if.js +11 -6
  111. package/src/core/elements/control/switch.js +2 -1
  112. package/src/core/elements/index.js +1 -1
  113. package/src/core/elements/svg.js +61 -0
  114. package/src/core/utils/HasEventEmitter.js +6 -0
  115. package/src/core/utils/debug-manager.js +2 -5
  116. package/src/core/utils/filters/standard.js +2 -1
  117. package/src/core/utils/property-accumulator.js +35 -6
  118. package/src/core/utils/shortcut-manager.js +242 -0
  119. package/src/core/utils/validator.js +1 -1
  120. package/src/core/wrappers/AttributesWrapper.js +41 -4
  121. package/src/core/wrappers/DocumentObserver.js +0 -1
  122. package/src/core/wrappers/HtmlElementWrapper.js +1 -1
  123. package/src/core/wrappers/NDElement.js +15 -2
  124. package/src/core/wrappers/SvgElementWrapper.js +15 -0
  125. package/src/core/wrappers/prototypes/attributes-extensions.js +4 -1
  126. package/src/core/wrappers/prototypes/nd-element-extensions.js +8 -1
  127. package/src/router/Router.js +0 -1
  128. package/src/ui/components/accordion/AccordionItemRender.js +63 -0
  129. package/src/ui/components/accordion/AccordionRender.js +34 -0
  130. package/src/ui/components/accordion/accordion.css +121 -0
  131. package/src/ui/components/alert/AlertRender.js +80 -0
  132. package/src/ui/components/alert/alert.css +163 -0
  133. package/src/ui/components/avatar/avata-group/AvatarGroupRender.js +49 -0
  134. package/src/ui/components/avatar/avata-group/avatar-group.css +38 -0
  135. package/src/ui/components/avatar/avatar/AvatarRender.js +87 -0
  136. package/src/ui/components/avatar/avatar/avatar.css +189 -0
  137. package/src/ui/components/badge/BadgeRender.js +24 -0
  138. package/src/ui/components/badge/badge.css +168 -0
  139. package/src/ui/components/breadcrumb/BreadcrumbRender.js +43 -0
  140. package/src/ui/components/breadcrumb/breadcrumb.css +55 -0
  141. package/src/ui/components/button/ButtonRender.js +65 -0
  142. package/src/ui/components/button/button.css +288 -354
  143. package/src/ui/components/contextmenu/ContextmenuRender.js +70 -0
  144. package/src/ui/components/contextmenu/contextmenu.css +36 -0
  145. package/src/ui/components/divider/DividerRender.js +70 -0
  146. package/src/ui/components/divider/divider.css +70 -0
  147. package/src/ui/components/dropdown/DropdownRender.js +92 -0
  148. package/src/ui/components/dropdown/divider/DropdownDividerRender.js +9 -0
  149. package/src/ui/components/dropdown/divider/dropdown-divider.css +0 -0
  150. package/src/ui/components/dropdown/dropdown.css +179 -0
  151. package/src/ui/components/dropdown/group/DropdownGroupRender.js +23 -0
  152. package/src/ui/components/dropdown/group/dropdown-group.css +0 -0
  153. package/src/ui/components/dropdown/item/DropdownItemRender.js +29 -0
  154. package/src/ui/components/dropdown/item/dropdown-item.css +0 -0
  155. package/src/ui/components/form/FieldCollectionRender.js +110 -0
  156. package/src/ui/components/form/FormControlRender.js +84 -0
  157. package/src/ui/components/form/field-collection.css +55 -0
  158. package/src/ui/components/form/fields/AutocompleteFieldRender.js +143 -0
  159. package/src/ui/components/form/fields/CheckboxFieldRender.js +59 -0
  160. package/src/ui/components/form/fields/CheckboxGroupFieldRender.js +92 -0
  161. package/src/ui/components/form/fields/ColorFieldRender.js +30 -0
  162. package/src/ui/components/form/fields/DateFieldRender.js +154 -0
  163. package/src/ui/components/form/fields/EmailFieldRender.js +5 -0
  164. package/src/ui/components/form/fields/FieldRender.js +117 -0
  165. package/src/ui/components/form/fields/FileFieldRender.js +41 -0
  166. package/src/ui/components/form/fields/HiddenFieldRender.js +14 -0
  167. package/src/ui/components/form/fields/ImageFieldRender.js +0 -0
  168. package/src/ui/components/form/fields/NumberFieldRender.js +52 -0
  169. package/src/ui/components/form/fields/PasswordFieldRender.js +65 -0
  170. package/src/ui/components/form/fields/RadioFieldRender.js +77 -0
  171. package/src/ui/components/form/fields/RangeFieldRender.js +121 -0
  172. package/src/ui/components/form/fields/SelectFieldRender.js +248 -0
  173. package/src/ui/components/form/fields/SliderFieldRender.js +359 -0
  174. package/src/ui/components/form/fields/StringFieldRender.js +6 -0
  175. package/src/ui/components/form/fields/TelFieldRender.js +6 -0
  176. package/src/ui/components/form/fields/TextAreaFieldRender.js +96 -0
  177. package/src/ui/components/form/fields/TimeFieldRender.js +141 -0
  178. package/src/ui/components/form/fields/UrlFieldRender.js +6 -0
  179. package/src/ui/components/form/fields/date-field.css +32 -0
  180. package/src/ui/components/form/fields/field.css +402 -0
  181. package/src/ui/components/form/fields/file-field.css +79 -0
  182. package/src/ui/components/form/fields/password-field.css +50 -0
  183. package/src/ui/components/form/fields/range-field.css +120 -0
  184. package/src/ui/components/form/fields/slider.css +195 -0
  185. package/src/ui/components/form/file-upload-mode/FileAvatarModeRender.js +143 -0
  186. package/src/ui/components/form/file-upload-mode/FileDropzoneModeRender.js +108 -0
  187. package/src/ui/components/form/file-upload-mode/FileNativeModeRender.js +22 -0
  188. package/src/ui/components/form/file-upload-mode/FileUploadButtonModeRender.js +89 -0
  189. package/src/ui/components/form/file-upload-mode/FileWallModeRender.js +91 -0
  190. package/src/ui/components/form/file-upload-mode/file-avatar-mode.css +139 -0
  191. package/src/ui/components/form/file-upload-mode/file-dropzone-mode.css +88 -0
  192. package/src/ui/components/form/file-upload-mode/file-upload-button-mode.css +44 -0
  193. package/src/ui/components/form/file-upload-mode/file-wall-mode.css +88 -0
  194. package/src/ui/components/form/form-control.css +40 -0
  195. package/src/ui/components/form/helpers.js +112 -0
  196. package/src/ui/components/form/index.js +61 -0
  197. package/src/ui/components/menu/MenuDividerRender.js +12 -0
  198. package/src/ui/components/menu/MenuGroupRender.js +60 -0
  199. package/src/ui/components/menu/MenuItemRender.js +57 -0
  200. package/src/ui/components/menu/MenuLinkRender.js +55 -0
  201. package/src/ui/components/menu/MenuRender.js +21 -0
  202. package/src/ui/components/menu/helpers.js +121 -0
  203. package/src/ui/components/menu/menu.css +308 -0
  204. package/src/ui/components/modal/ModalRender.js +119 -0
  205. package/src/ui/components/modal/modal.css +156 -0
  206. package/src/ui/components/pagination/PaginationRender.js +112 -0
  207. package/src/ui/components/pagination/pagination.css +63 -0
  208. package/src/ui/components/popover/PopoverRender.js +234 -0
  209. package/src/ui/components/popover/popover.css +139 -0
  210. package/src/ui/components/progress/ProgressRender.js +168 -0
  211. package/src/ui/components/progress/progress.css +197 -0
  212. package/src/ui/components/skeleton/SkeletonRender.js +79 -0
  213. package/src/ui/components/skeleton/skeleton.css +154 -0
  214. package/src/ui/components/spinner/SpinnerRender.js +46 -0
  215. package/src/ui/components/spinner/spinner.css +152 -0
  216. package/src/ui/components/splitter/SplitterGutterRender.js +94 -0
  217. package/src/ui/components/splitter/SplitterPanelRender.js +38 -0
  218. package/src/ui/components/splitter/SplitterRender.js +74 -0
  219. package/src/ui/components/splitter/splitter.css +128 -0
  220. package/src/ui/components/stacks/PositionStackRender.js +38 -0
  221. package/src/ui/components/stacks/StackRender.js +42 -0
  222. package/src/ui/components/stacks/absolute-stack/AbsoluteStackRender.js +5 -0
  223. package/src/ui/components/stacks/fixed-stack/FixedStackRender.js +5 -0
  224. package/src/ui/components/stacks/h-stack/HStackRender.js +7 -0
  225. package/src/ui/components/stacks/h-stack/h-stack.css +4 -0
  226. package/src/ui/components/stacks/index.js +15 -0
  227. package/src/ui/components/stacks/position-stack.css +62 -0
  228. package/src/ui/components/stacks/relative-stack/RelativeStackRender.js +7 -0
  229. package/src/ui/components/stacks/relative-stack/relative-stack.css +3 -0
  230. package/src/ui/components/stacks/stack.css +78 -0
  231. package/src/ui/components/stacks/v-stack/VStackRender.js +5 -0
  232. package/src/ui/components/stacks/v-stack/v-stack.css +4 -0
  233. package/src/ui/components/stepper/StepperRender.js +70 -0
  234. package/src/ui/components/stepper/StepperStepRender.js +67 -0
  235. package/src/ui/components/stepper/stepper.css +359 -0
  236. package/src/ui/components/switch/SwitchRender.js +82 -0
  237. package/src/ui/components/switch/switch.css +143 -0
  238. package/src/ui/components/table/data-table/DataTableRender.js +49 -0
  239. package/src/ui/components/table/data-table/bulk-actions.js +35 -0
  240. package/src/ui/components/table/data-table/data-table.css +246 -0
  241. package/src/ui/components/table/data-table/pagination.js +56 -0
  242. package/src/ui/components/table/data-table/tables.js +363 -0
  243. package/src/ui/components/table/data-table/toolbar.js +67 -0
  244. package/src/ui/components/table/simple-table/SimpleTableRender.js +188 -0
  245. package/src/ui/components/table/simple-table/simple-table.css +50 -0
  246. package/src/ui/components/tabs/TabsRender.js +226 -0
  247. package/src/ui/components/tabs/tabs.css +253 -0
  248. package/src/ui/components/toast/ToastRender.js +98 -0
  249. package/src/ui/components/toast/toast.css +201 -0
  250. package/src/ui/components/tooltip/TooltipRender.js +8 -0
  251. package/src/ui/components/tooltip/tooltip.css +113 -0
  252. package/src/ui/index.js +82 -0
  253. package/src/ui/tokens/colors-dark.scss +2 -1
  254. package/src/ui/tokens/reset.scss +3 -0
  255. package/types/control-flow.d.ts +2 -2
  256. package/src/components/layouts/ZStack.js +0 -41
  257. package/src/ui/components/button/button.render.js +0 -63
  258. /package/src/components/{layouts → stacks}/HStack.js +0 -0
  259. /package/src/components/{layouts → stacks}/VStack.js +0 -0
@@ -1,52 +1,37 @@
1
1
  import Column from "./Column";
2
2
  import ColumnGroup from "./ColumnGroup";
3
- import { Table, TFoot, TRow } from "../../../elements";
4
- import DataTable from "./DataTable";
3
+ import BaseComponent from "../BaseComponent";
5
4
 
5
+ export default function SimpleTable(props = {}) {
6
+ if(!(this instanceof SimpleTable)) {
7
+ return new SimpleTable(props);
8
+ }
9
+
10
+ BaseComponent.call(this, props);
6
11
 
7
- export default function SimpleTable(configs = {}) {
8
12
  this.$description = {
9
- header: [],
10
- columns: [],
11
- hasGroups: false,
12
- rowTemplate: null,
13
- tableTemplate: null,
14
- data: null,
15
- layout: null,
16
- expandable: false,
17
- ...configs
13
+ header: [],
14
+ columns: [],
15
+ hasGroups: false,
16
+ data: null,
17
+ empty: null,
18
+ onRowClick: null,
19
+ rowProps: null,
20
+ cellProps: null,
21
+ headerProps: null,
18
22
  };
19
-
20
- this.$element = null;
21
- this.$thead = null;
22
- this.$tbody = null;
23
- this.$tfoot = null;
24
23
  }
25
24
 
26
- SimpleTable.defaultTableTemplate = null;
27
- SimpleTable.defaultRowTemplate = null;
28
- SimpleTable.defaultEmptyTemplate = null;
25
+ BaseComponent.extends(SimpleTable);
26
+
27
+ SimpleTable.defaultTemplate = null;
29
28
 
30
- /**
31
- *
32
- * @param {{
33
- * column: { header: string|Function|null, render: string|Function|null },
34
- * columnGroup: { header: string|Function|null },
35
- * row: string|Function|null,
36
- * table: string|Function|null
37
- * empty: string|Function|null
38
- * }} template
39
- */
40
29
  SimpleTable.use = function(template) {
41
- Column.use(template.column || {});
42
- ColumnGroup.use(template.columnGroup || {});
43
- SimpleTable.defaultRowTemplate = template.row || SimpleTable.defaultRowTemplate;
44
- SimpleTable.defaultTableTemplate = template.table || SimpleTable.defaultTableTemplate;
45
- SimpleTable.defaultEmptyTemplate = template.empty || SimpleTable.defaultEmptyTemplate;
30
+ SimpleTable.defaultTemplate = template;
46
31
  };
47
32
 
48
- SimpleTable.create = function(configs) {
49
- return new SimpleTable(configs);
33
+ SimpleTable.create = function(props) {
34
+ return new SimpleTable(props);
50
35
  };
51
36
 
52
37
  SimpleTable.prototype.column = function(key, title, callback) {
@@ -67,122 +52,22 @@ SimpleTable.prototype.group = function(title, callback) {
67
52
  return this;
68
53
  };
69
54
 
70
- SimpleTable.prototype.columns = function(columnsArray) {
71
- columnsArray.forEach(column => this.column(column.key, column.title, column.callback));
72
- return this;
73
- };
74
-
75
55
  SimpleTable.prototype.data = function(data) {
76
56
  this.$description.data = data;
77
57
  return this;
78
58
  };
79
59
 
80
- DataTable.prototype.expandable = function() {
81
- this.$description.expandable = true
60
+ SimpleTable.prototype.empty = function(content) {
61
+ this.$description.empty = content;
82
62
  return this;
83
63
  };
84
64
 
85
- SimpleTable.prototype.renderRow = function(template) {
86
- this.$description.rowTemplate = template;
65
+ SimpleTable.prototype.onRowClick = function(handler) {
66
+ this.$description.onRowClick = handler;
87
67
  return this;
88
- }
89
-
90
- SimpleTable.prototype.buildRow = function(rowData) {
91
- const rowTemplate = this.$description.rowTemplate || SimpleTable.defaultRowTemplate;
92
-
93
- if(typeof rowTemplate === 'function') {
94
- return rowTemplate(rowData, this);
95
- }
96
-
97
- return TRow(this.$description.columns.map(
98
- column => TBodyCell({}, column.buildCell(rowData))
99
- ));
100
68
  };
101
69
 
102
- SimpleTable.prototype.renderTable = function(template) {
103
- this.$description.tableTemplate = template;
70
+ SimpleTable.prototype.rowProps = function(fn) {
71
+ this.$description.rowProps = fn;
104
72
  return this;
105
- };
106
-
107
- SimpleTable.prototype.buildTable = function(slots = {}) {
108
- const { headerRows } = slots;
109
-
110
- const tableTemplate = this.$description.tableTemplate || SimpleTable.defaultTableTemplate;
111
- if(typeof tableTemplate === 'function') {
112
- return tableTemplate(slots, this);
113
- }
114
-
115
- return Table({ border: 2 }, [
116
- THead(headerRows),
117
- TBody(
118
- ForEachArray(this.$description.data, rowData => {
119
- return this.buildRow(rowData, this);
120
- })
121
- )
122
- ]);
123
- };
124
-
125
- SimpleTable.prototype.onClick = function(callback) {
126
- this.$description.onClick = callback;
127
- };
128
-
129
-
130
-
131
- //-----------------------------------------------------------------
132
- // Expandable Actions
133
- //-----------------------------------------------------------------
134
-
135
- DataTable.prototype.expand = function(row) {
136
- // TODO: implement this action
137
- return this;
138
- };
139
-
140
- DataTable.prototype.collapse = function(row) {
141
- // TODO: implement this action
142
- return this;
143
- };
144
-
145
- DataTable.prototype.collapseAll = function() {
146
- // TODO: implement this action
147
- return this;
148
- };
149
-
150
- DataTable.prototype.isRowExpanded = function(row) {
151
- // TODO: implement this action
152
- return this;
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
73
  };
@@ -1,110 +1,208 @@
1
1
  import BaseComponent from "../BaseComponent";
2
2
  import HasEventEmitter from "../../core/utils/HasEventEmitter";
3
+ import { $ } from "../../../index";
3
4
 
4
5
 
5
- export default function Tabs(config = {}) {
6
+ export default function Tabs(props = {}) {
6
7
  if(!(this instanceof Tabs)) {
7
8
  return new Tabs();
8
9
  }
9
- BaseComponent.apply(this);
10
+ BaseComponent.apply(this, props);
10
11
  this.$description = {
11
12
  active: $(''),
12
13
  tabs: {},
13
- ...config,
14
+ sortable: false,
15
+ tabAppearance: 'segmented',
16
+ addPlusButton: null,
17
+ addPLusCallback: null,
18
+ stickyHeader: false,
19
+ overflow: 'scroll',
20
+ navigationBarPosition: 'top',
21
+ tabsAlignment: 'leading',
22
+ closable: false,
23
+ focusOnNewTab: false,
24
+ closeIcon: null,
25
+ renderCloseButton: null,
26
+ renderPlusButton: null,
27
+ props,
14
28
  };
15
-
16
- this.tabsMap = {};
17
29
  }
18
30
 
19
- BaseComponent.extends(Tabs, HasEventEmitter);
31
+ BaseComponent.extends(Tabs);
32
+ BaseComponent.use(Tabs, HasEventEmitter);
20
33
 
21
34
  Tabs.defaultTemplate = null;
22
- Tabs.defaultTabTemplate = null;
23
- Tabs.defaultNavigationBarTemplate = null;
24
35
 
25
- Tabs.use = function(template) {};
36
+ Tabs.use = function(template) {
37
+ Tabs.defaultTemplate = template;
38
+ };
26
39
 
27
- Tabs.prototype.activateTab = function(key) {};
28
- Tabs.prototype.closeTab = function(key) {};
40
+ Tabs.prototype.parentEmit = HasEventEmitter.prototype.emit;
41
+ Tabs.prototype.emit = function(eventName, ...args) {
42
+ this.parentEmit.call(this, eventName, ...args);
43
+ this.parentEmit.call(this, 'change');
44
+ };
29
45
 
30
- Tabs.prototype.tab = function(label, content, key) {
31
- this.$description.tabs[key] = { label, content };
32
- this.tabsMap[key] = content;
46
+ Tabs.prototype.sortable = function() {
47
+ this.$description.sortable = true;
48
+ return this;
49
+ };
50
+ Tabs.prototype.pills = function() {
51
+ this.$description.tabAppearance = 'pills';
52
+ return this;
53
+ };
54
+ Tabs.prototype.segmented = function() {
55
+ this.$description.tabAppearance = 'segmented';
56
+ return this;
57
+ };
58
+
59
+ Tabs.prototype.addPlusButton = function(callback) {
60
+ this.$description.addPlusButton = true;
61
+ this.$description.addPLusCallback = callback;
62
+ return this;
63
+ };
64
+
65
+ Tabs.prototype.closable = function(mode = true) {
66
+ this.$description.closable = mode;
67
+ return this;
68
+ };
69
+
70
+ Tabs.prototype.renderCloseButton = function(renderFn) {
71
+ this.$description.renderCloseButton = renderFn;
72
+ return this;
73
+ };
74
+
75
+ Tabs.prototype.renderPlusButton = function(renderFn) {
76
+ this.$description.renderPlusButton = renderFn;
77
+ return this;
78
+ };
79
+
80
+ Tabs.prototype.overflow = function(overflow) {
81
+ this.$description.overflow = overflow;
82
+ return this;
83
+ };
84
+
85
+ Tabs.prototype.scrollOnTabOverflow = function() {
86
+ this.$description.overflow = 'scroll';
87
+ return this;
88
+ };
89
+
90
+ Tabs.prototype.menuOnTabOverflow = function() {
91
+ this.$description.overflow = 'menu';
92
+ return this;
93
+ };
94
+
95
+ Tabs.prototype.focusOnNewTab = function(mode = true) {
96
+ this.$description.focusOnNewTab = mode;
97
+ return this;
98
+ };
99
+
100
+ Tabs.prototype.stickyHeader = function(mode = true) {
101
+ this.$description.stickyHeader = mode;
102
+ return this;
103
+ };
104
+
105
+ Tabs.prototype.addTab = function(icon, label, content, key) {
106
+ const tab = { icon, label, content, key };
107
+ this.$description.tabs[key] = tab;
108
+ this.emit('addTab', tab);
33
109
  return this;
34
110
  };
111
+
112
+ Tabs.prototype.tab = function(label, content, key) {
113
+ return this.addTab(null, label, content, key);
114
+ };
115
+
116
+ Tabs.prototype.tabWithIcon = function(icon, label, content, key) {
117
+ return this.addTab(icon, label, content, key);
118
+ };
119
+
35
120
  Tabs.prototype.tabs = function(tabs) {
36
121
  for(const item of tabs) {
37
- this.tab(item.label, item.content, item.key);
122
+ this.addTab(item.icon, item.label, item.content, item.key);
38
123
  }
39
124
  return this;
40
125
  };
41
- Tabs.prototype.removeTab = function(key) {
126
+ Tabs.prototype.closeTab = function(key) {
42
127
  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]);
128
+ this.emit('closeTab', key);
46
129
  return this;
47
130
  };
48
131
 
49
132
  Tabs.prototype.active = function(key) {
50
133
  this.$description.active.set(key);
134
+ return this;
51
135
  };
52
- Tabs.prototype.defaultActive = function(key) {};
53
- Tabs.prototype.getActive = function() {};
54
136
 
55
137
  Tabs.prototype.navigationBarPosition = function(position) {
56
138
  this.$description.navigationBarPosition = position;
57
139
  return this;
58
140
  };
59
141
  Tabs.prototype.navigationBarAtLeft = function() {
60
- return this.navigationBarPosition('left');
142
+ this.$description.navigationBarPosition = 'left';
143
+ return this;
61
144
  };
62
145
  Tabs.prototype.navigationBarAtRight = function() {
63
- return this.navigationBarPosition('right');
146
+ this.$description.navigationBarPosition = 'right';
147
+ return this;
64
148
  };
65
149
  Tabs.prototype.navigationBarAtTop = function() {
66
- return this.navigationBarPosition('top');
150
+ this.$description.navigationBarPosition = 'top';
151
+ return this;
67
152
  }
68
153
  Tabs.prototype.navigationBarAsDock = function() {
69
- return this.navigationBarPosition('dock');
154
+ this.$description.navigationBarPosition = 'dock';
155
+ return this;
70
156
  };
71
157
 
72
- // Events
73
- Tabs.prototype.onChange = function(handler) {
74
- this.on('change', handler);
158
+ Tabs.prototype.tabsAtLeading = function() {
159
+ this.$description.tabsAlignment = 'leading';
75
160
  return this;
76
161
  };
77
- Tabs.prototype.onBeforeChange = function(handler) {
78
- this.on('beforeChange', handler);
162
+
163
+ Tabs.prototype.tabsAtTrailing = function() {
164
+ this.$description.tabsAlignment = 'trailing';
79
165
  return this;
80
166
  };
81
- Tabs.prototype.onTabClick = function(handler) {
82
- this.on('tabClick', handler);
167
+ Tabs.prototype.tabsAtCenter = function() {
168
+ this.$description.tabsAlignment = 'center';
83
169
  return this;
84
170
  };
85
- Tabs.prototype.onTabClose = function(handler) {
86
- this.on('tabClose', handler);
171
+ Tabs.prototype.tabsJustified = function() {
172
+ this.$description.tabsAlignment = 'justified';
87
173
  return this;
88
174
  };
89
175
 
90
-
91
- Tabs.prototype.renderTab = function(renderFn) {
92
- this.$description.renderTab = renderFn;
176
+ // Events
177
+ Tabs.prototype.onChange = function(handler) {
178
+ this.on('change', handler);
93
179
  return this;
94
180
  };
95
- Tabs.prototype.renderNavigationBar = function(renderFn) {
96
- return this.$description.renderNavigationBar = renderFn;
181
+ Tabs.prototype.onBeforeTabClose = function(handler) {
182
+ this.on('beforeTabClose', handler);
183
+ return this;
97
184
  };
98
185
 
99
- Tabs.prototype.layout = function(layoutFn) {
100
- this.$description.layout = layoutFn;
186
+ Tabs.prototype.onClickTab = function(handler) {
187
+ this.on('clickTab', handler);
101
188
  return this;
102
189
  };
103
190
 
104
- Tabs.prototype.$build = function() {
191
+ Tabs.prototype.onCloseTab = function(handler) {
192
+ this.on('closeTab', handler);
193
+ return this;
194
+ };
105
195
 
196
+ Tabs.prototype.onAddTab = function(handler) {
197
+ this.on('addTab', handler);
198
+ return this;
106
199
  };
107
200
 
108
- Tabs.prototype.toNdElement = function() {
109
201
 
110
- };
202
+ Tabs.prototype.renderTab = function(renderFn) {
203
+ this.$description.renderTab = renderFn;
204
+ return this;
205
+ };
206
+ Tabs.prototype.renderNavigationBar = function(renderFn) {
207
+ return this.$description.renderNavigationBar = renderFn;
208
+ };
@@ -1,31 +1,38 @@
1
1
  import BaseComponent from "../BaseComponent";
2
2
  import HasEventEmitter from "../../core/utils/HasEventEmitter";
3
+ import {Observable} from "../../../index";
3
4
 
4
- export default function Toast(message, config = {}) {
5
+ export default function Toast(content, props = {}) {
5
6
  if (!(this instanceof Toast)) {
6
- return new Toast(message, config);
7
+ return new Toast(content, props);
7
8
  }
8
9
 
10
+ BaseComponent.call(this, props);
11
+
9
12
  this.$description = {
13
+ visibility: Observable(true),
10
14
  type: null,
11
15
  title: null,
12
- content: null,
16
+ content,
13
17
  icon: null,
14
18
  showIcon: true,
15
- duration: 3000,
19
+ duration: 5000,
16
20
  closable: true,
17
21
  pauseOnHover: true,
18
- position: 'top-right',
22
+ position: 'top-trailing',
19
23
  actions: [],
20
24
  render: null,
21
- ...config
25
+ props
22
26
  };
23
27
  }
24
28
 
25
- BaseComponent.extends(Toast, HasEventEmitter);
29
+ BaseComponent.extends(Toast);
30
+ BaseComponent.use(Toast, HasEventEmitter);
26
31
 
27
- Toast.use = function(template) {};
28
32
  Toast.defaultTemplate = null;
33
+ Toast.use = function(template) {
34
+ Toast.defaultTemplate = template;
35
+ };
29
36
 
30
37
  // Types
31
38
  Toast.prototype.type = function(type) {
@@ -33,16 +40,20 @@ Toast.prototype.type = function(type) {
33
40
  return this;
34
41
  };
35
42
  Toast.prototype.info = function() {
36
- return this.type('info');
43
+ this.$description.type = 'info';
44
+ return this;
37
45
  };
38
46
  Toast.prototype.success = function() {
39
- return this.type('success');
47
+ this.$description.type = 'success';
48
+ return this;
40
49
  };
41
50
  Toast.prototype.warning = function() {
42
- return this.type('warning');
51
+ this.$description.type = 'warning';
52
+ return this;
43
53
  };
44
54
  Toast.prototype.error = function() {
45
- return this.type('error');
55
+ this.$description.type = 'error';
56
+ return this;
46
57
  };
47
58
 
48
59
 
@@ -83,18 +94,19 @@ Toast.prototype.position = function(position) {
83
94
  this.$description.position = position;
84
95
  return this;
85
96
  };
86
- Toast.prototype.atTopStart = function() {
87
- return this.position('top-start');
97
+
98
+ Toast.prototype.atTopLeading = function() {
99
+ return this.position('top-leading');
88
100
  };
89
101
 
90
- Toast.prototype.atTopEnd = function() {
91
- return this.position('top-end');
102
+ Toast.prototype.atTopTrailing = function() {
103
+ return this.position('top-trailing');
92
104
  };
93
- Toast.prototype.atBottomStart = function() {
94
- return this.position('bottom-start');
105
+ Toast.prototype.atBottomLeading = function() {
106
+ return this.position('bottom-leading');
95
107
  };
96
- Toast.prototype.atBottomEnd = function() {
97
- return this.position('bottom-end');
108
+ Toast.prototype.atBottomTrailing = function() {
109
+ return this.position('bottom-trailing');
98
110
  };
99
111
  Toast.prototype.atTopCenter = function() {
100
112
  return this.position('top-center');
@@ -103,27 +115,20 @@ Toast.prototype.atBottomCenter = function() {
103
115
  return this.position('bottom-center');
104
116
  };
105
117
 
106
- Toast.prototype.clearActions = function() {
107
- this.$description.actions = [];
118
+ Toast.prototype.action = function(label, handler, variant = null) {
119
+ handler = handler || (() => this.close());
120
+ this.$description.actions.push({ label, handler, variant });
108
121
  return this;
109
122
  };
110
- Toast.prototype.action = function(label, handler) {
111
- this.$description.actions.push({ label, handler });
112
- return this;
123
+
124
+ Toast.prototype.close = function() {
125
+ this.$description.visibility?.set(false);
126
+ this.emit('close');
113
127
  };
114
128
 
115
- Toast.prototype.close = function() {};
116
129
  Toast.prototype.onClose = function(handler) {
117
130
  this.on('close', handler);
118
131
  return this;
119
132
  };
120
133
 
121
- Toast.prototype.render = function(renderFn) {
122
- this.$description.render = renderFn;
123
- return this;
124
- };
125
-
126
- Toast.prototype.$build = function() {
127
-
128
- };
129
- Toast.prototype.toNdElement = function() {};
134
+ Toast.prototype.show = BaseComponent.prototype.toNdElement;