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
@@ -1287,6 +1287,20 @@ var NativeDocument = (function (exports) {
1287
1287
  setInterval(() => MemoryManager.cleanObservables(threshold), interval);
1288
1288
  };
1289
1289
 
1290
+ ObservableItem.prototype.bindNdClass = function(element, className) {
1291
+ element.classes.toggle(className, this.val());
1292
+ this.subscribe(toggleElementClass.bind(null, element, className));
1293
+ };
1294
+
1295
+ ObservableWhen.prototype.bindNdClass = function(element, className) {
1296
+ element.classes.toggle(className, this.isMath());
1297
+ this.subscribe(toggleElementClass.bind(null, element, className));
1298
+ };
1299
+
1300
+ TemplateBinding.prototype.bindNdClass = function(element, className) {
1301
+ this.$hydrate(element, className);
1302
+ };
1303
+
1290
1304
  function toggleElementClass(element, className, shouldAdd) {
1291
1305
  element.classes.toggle(className, shouldAdd);
1292
1306
  }
@@ -1319,18 +1333,8 @@ var NativeDocument = (function (exports) {
1319
1333
  function bindClassAttribute(element, data) {
1320
1334
  for(let className in data) {
1321
1335
  const value = data[className];
1322
- if(Validator.isObservable(value)) {
1323
- element.classes.toggle(className, value.val());
1324
- value.subscribe(toggleElementClass.bind(null, element, className));
1325
- continue;
1326
- }
1327
- if(Validator.isObservableWhenResult(value)) {
1328
- element.classes.toggle(className, value.isMath());
1329
- value.subscribe(toggleElementClass.bind(null, element, className));
1330
- continue;
1331
- }
1332
- if(value.$hydrate) {
1333
- value.$hydrate(element, className);
1336
+ if(value?.bindNdClass) {
1337
+ value.bindNdClass(element, className);
1334
1338
  continue;
1335
1339
  }
1336
1340
  element.classes.toggle(className, value);
@@ -1423,14 +1427,30 @@ var NativeDocument = (function (exports) {
1423
1427
  value.handleNdAttribute(element, attributeName, value);
1424
1428
  continue;
1425
1429
  }
1430
+ if(Validator.isString(value)) {
1431
+ element.setAttribute(attributeName, value);
1432
+ return;
1433
+ }
1434
+ if(attributeName === 'class' && Validator.isObject(value)) {
1435
+ bindClassAttribute(element, value);
1436
+ continue;
1437
+ }
1438
+ if(attributeName === 'style' && Validator.isObject(value)) {
1439
+ bindStyleAttribute(element, value);
1440
+ continue;
1441
+ }
1426
1442
  if(BOOLEAN_ATTRIBUTES.includes(attributeName)) {
1427
1443
  bindBooleanAttribute(element, attributeName, value);
1428
- return;
1444
+ continue;
1429
1445
  }
1430
1446
  if(Validator.isObservable(value)) {
1431
1447
  bindAttributeWithObservable(element, attributeName, value);
1432
1448
  continue;
1433
1449
  }
1450
+ if(value.$hydrate) {
1451
+ value.$hydrate(element, attributeName);
1452
+ continue;
1453
+ }
1434
1454
 
1435
1455
  element.setAttribute(attributeName, value);
1436
1456
 
@@ -1490,37 +1510,16 @@ var NativeDocument = (function (exports) {
1490
1510
  return ElementCreator.createHydratableNode(null, this);
1491
1511
  };
1492
1512
 
1493
- Object.prototype.handleNdAttribute = function(element, attributeName) {
1494
- if(attributeName === 'class') {
1495
- bindClassAttribute(element, this);
1496
- return;
1497
- }
1498
- if(attributeName === 'style') {
1499
- bindStyleAttribute(element, this);
1500
-
1501
- }
1502
- };
1503
-
1504
1513
  String.prototype.handleNdAttribute = function(element, attributeName) {
1505
- let value = this.resolveObservableTemplate ? this.resolveObservableTemplate() : this;
1506
- if(Validator.isString(value)) {
1507
- element.setAttribute(attributeName, value);
1508
- return;
1509
- }
1510
- const observables = value.filter(item => Validator.isObservable(item));
1511
- value = Observable.computed(() => {
1512
- return value.map(item => Validator.isObservable(item) ? item.val() : item).join(' ') || ' ';
1513
- }, observables);
1514
+ element.setAttribute(attributeName, this);
1515
+ };
1514
1516
 
1517
+ ObservableItem.prototype.handleNdAttribute = function(element, attributeName) {
1515
1518
  if(BOOLEAN_ATTRIBUTES.includes(attributeName)) {
1516
- bindBooleanAttribute(element, attributeName, value);
1519
+ bindBooleanAttribute(element, attributeName, this);
1517
1520
  return;
1518
1521
  }
1519
1522
 
1520
- bindAttributeWithObservable(element, attributeName, value);
1521
- };
1522
-
1523
- ObservableItem.prototype.handleNdAttribute = function(element, attributeName) {
1524
1523
  bindAttributeWithObservable(element, attributeName, this);
1525
1524
  };
1526
1525
 
@@ -1615,6 +1614,9 @@ var NativeDocument = (function (exports) {
1615
1614
  if(Validator.isElement(child)) {
1616
1615
  return child;
1617
1616
  }
1617
+ if(child == null) {
1618
+ return null;
1619
+ }
1618
1620
  } while (child.toNdElement);
1619
1621
  }
1620
1622
 
@@ -1725,22 +1727,85 @@ var NativeDocument = (function (exports) {
1725
1727
  "ContextMenu"
1726
1728
  ];
1727
1729
 
1728
- let createNdElementInstance = (target) => {
1729
- attachEventPrototypes && attachEventPrototypes();
1730
- attachEventPrototypes = null;
1731
- createNdElementInstance = (target) => new NDElement(target);
1732
- return new NDElement(target);
1733
- };
1730
+ const EVENTS_WITH_PREVENT = [
1731
+ "Click",
1732
+ "DblClick",
1733
+ "MouseDown",
1734
+ "MouseUp",
1735
+ "Wheel",
1736
+ "KeyDown",
1737
+ "KeyPress",
1738
+ "Invalid",
1739
+ "Reset",
1740
+ "Submit",
1741
+ "DragOver",
1742
+ "Drop",
1743
+ "BeforeUnload",
1744
+ "TouchCancel",
1745
+ "TouchEnd",
1746
+ "TouchMove",
1747
+ "TouchStart",
1748
+ "Copy",
1749
+ "Cut",
1750
+ "Paste",
1751
+ "ContextMenu"
1752
+ ];
1753
+
1754
+ const EVENTS_WITH_STOP = [
1755
+ "Click",
1756
+ "DblClick",
1757
+ "MouseDown",
1758
+ "MouseMove",
1759
+ "MouseOut",
1760
+ "MouseOver",
1761
+ "MouseUp",
1762
+ "Wheel",
1763
+ "KeyDown",
1764
+ "KeyPress",
1765
+ "KeyUp",
1766
+ "Change",
1767
+ "Input",
1768
+ "Invalid",
1769
+ "Reset",
1770
+ "Search",
1771
+ "Select",
1772
+ "Submit",
1773
+ "Drag",
1774
+ "DragEnd",
1775
+ "DragEnter",
1776
+ "DragLeave",
1777
+ "DragOver",
1778
+ "DragStart",
1779
+ "Drop",
1780
+ "BeforeUnload",
1781
+ "HashChange",
1782
+ "TouchCancel",
1783
+ "TouchEnd",
1784
+ "TouchMove",
1785
+ "TouchStart",
1786
+ "AnimationEnd",
1787
+ "AnimationIteration",
1788
+ "AnimationStart",
1789
+ "TransitionEnd",
1790
+ "Copy",
1791
+ "Cut",
1792
+ "Paste",
1793
+ "FocusIn",
1794
+ "FocusOut",
1795
+ "ContextMenu"
1796
+ ];
1797
+
1734
1798
  const property = {
1735
1799
  configurable: true,
1736
1800
  get() {
1737
- return createNdElementInstance(this);
1801
+ return new NDElement(this);
1738
1802
  }
1739
1803
  };
1740
1804
 
1741
1805
  Object.defineProperty(HTMLElement.prototype, 'nd', property);
1742
1806
 
1743
1807
  Object.defineProperty(DocumentFragment.prototype, 'nd', property);
1808
+
1744
1809
  Object.defineProperty(NDElement.prototype, 'nd', {
1745
1810
  configurable: true,
1746
1811
  get: function() {
@@ -1753,31 +1818,29 @@ var NativeDocument = (function (exports) {
1753
1818
  // ----------------------------------------------------------------
1754
1819
  // Events helpers
1755
1820
  // ----------------------------------------------------------------
1821
+ EVENTS.forEach(eventSourceName => {
1822
+ const eventName = eventSourceName.toLowerCase();
1823
+ NDElement.prototype['on'+eventSourceName] = function(callback = null) {
1824
+ this.$element.addEventListener(eventName, callback);
1825
+ return this;
1826
+ };
1827
+ });
1756
1828
 
1757
- let attachEventPrototypes = () => {
1758
- EVENTS.forEach(eventSourceName => {
1759
- const eventName = eventSourceName.toLowerCase();
1760
- NDElement.prototype['on'+eventSourceName] = function(callback) {
1761
- this.$element.addEventListener(eventName, callback);
1762
- return this;
1763
- };
1764
-
1765
- NDElement.prototype['onPrevent'+eventSourceName] = function(callback) {
1766
- _prevent(this.$element, eventName, callback);
1767
- return this;
1768
- };
1769
-
1770
- NDElement.prototype['onStop'+eventSourceName] = function(callback) {
1771
- _stop(this.$element, eventName, callback);
1772
- return this;
1773
- };
1829
+ EVENTS_WITH_STOP.forEach(eventSourceName => {
1830
+ const eventName = eventSourceName.toLowerCase();
1831
+ NDElement.prototype['onStop'+eventSourceName] = function(callback = null) {
1832
+ _stop(this.$element, eventName, callback);
1833
+ return this;
1834
+ };
1835
+ });
1774
1836
 
1775
- NDElement.prototype['onPreventStop'+eventSourceName] = function(callback) {
1776
- _preventStop(this.$element, eventName, callback);
1777
- return this;
1778
- };
1779
- });
1780
- };
1837
+ EVENTS_WITH_PREVENT.forEach(eventSourceName => {
1838
+ const eventName = eventSourceName.toLowerCase();
1839
+ NDElement.prototype['onPrevent'+eventSourceName] = function(callback = null) {
1840
+ _prevent(this.$element, eventName, callback);
1841
+ return this;
1842
+ };
1843
+ });
1781
1844
 
1782
1845
  NDElement.prototype.on = function(name, callback, options) {
1783
1846
  this.$element.addEventListener(name.toLowerCase(), callback, options);
@@ -1802,16 +1865,6 @@ var NativeDocument = (function (exports) {
1802
1865
  return this;
1803
1866
  };
1804
1867
 
1805
- const _preventStop = function(element, eventName, callback) {
1806
- const handler = (event) => {
1807
- event.stopPropagation();
1808
- event.preventDefault();
1809
- callback && callback.call(element, event);
1810
- };
1811
- element.addEventListener(eventName, handler);
1812
- return this;
1813
- };
1814
-
1815
1868
 
1816
1869
 
1817
1870
  // ----------------------------------------------------------------
@@ -2760,6 +2813,13 @@ var NativeDocument = (function (exports) {
2760
2813
  ObservableArray.prototype.constructor = ObservableArray;
2761
2814
  ObservableArray.prototype.__$isObservableArray = true;
2762
2815
 
2816
+
2817
+ Object.defineProperty(ObservableArray.prototype, 'length', {
2818
+ get() {
2819
+ return this.$currentValue.length;
2820
+ }
2821
+ });
2822
+
2763
2823
  mutationMethods.forEach((method) => {
2764
2824
  ObservableArray.prototype[method] = function(...values) {
2765
2825
  const result = this.$currentValue[method](...values);
@@ -2804,10 +2864,6 @@ var NativeDocument = (function (exports) {
2804
2864
  return count;
2805
2865
  };
2806
2866
 
2807
- ObservableArray.prototype.length = function() {
2808
- return this.$currentValue.length;
2809
- };
2810
-
2811
2867
  ObservableArray.prototype.swap = function(indexA, indexB) {
2812
2868
  const value = this.$currentValue;
2813
2869
  const length = value.length;