@sankhyalabs/ezui 1.1.78 → 1.1.79

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 (150) hide show
  1. package/dist/cjs/{AssetsUtils-dd585fba.js → AssetsUtils-02db4f46.js} +1 -1
  2. package/dist/cjs/ez-action-chip.cjs.entry.js +1 -1
  3. package/dist/cjs/ez-application.cjs.entry.js +1 -1
  4. package/dist/cjs/ez-button_3.cjs.entry.js +520 -0
  5. package/dist/cjs/ez-calendar_13.cjs.entry.js +2417 -0
  6. package/dist/cjs/ez-date-time-input.cjs.entry.js +2 -2
  7. package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
  8. package/dist/cjs/{ez-button_11.cjs.entry.js → ez-grid.cjs.entry.js} +14 -1410
  9. package/dist/cjs/ez-icon.cjs.entry.js +30 -0
  10. package/dist/cjs/ez-label-chip.cjs.entry.js +1 -1
  11. package/dist/cjs/ez-modal_2.cjs.entry.js +370 -0
  12. package/dist/cjs/ez-popover.cjs.entry.js +2 -2
  13. package/dist/cjs/ez-popup.cjs.entry.js +1 -1
  14. package/dist/cjs/ez-time-input.cjs.entry.js +3 -3
  15. package/dist/cjs/ez-toast.cjs.entry.js +1 -1
  16. package/dist/cjs/ezui.cjs.js +2 -2
  17. package/dist/cjs/{index-4e4bae01.js → index-2003dec4.js} +0 -10
  18. package/dist/cjs/{index-40ebb2be.js → index-a2266984.js} +18 -23
  19. package/dist/cjs/loader.cjs.js +2 -2
  20. package/dist/collection/collection-manifest.json +0 -2
  21. package/dist/collection/components/ez-form/DataBinder.js +44 -0
  22. package/dist/collection/components/ez-form/ez-form.css +1 -15
  23. package/dist/collection/components/ez-form/ez-form.js +109 -428
  24. package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +45 -0
  25. package/dist/collection/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.js +11 -0
  26. package/dist/collection/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.js +14 -0
  27. package/dist/collection/components/ez-form/fieldbuilder/tpl/DateInput.tpl.js +5 -0
  28. package/dist/collection/components/ez-form/fieldbuilder/tpl/FileInput.tpl.js +5 -0
  29. package/dist/collection/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.js +13 -0
  30. package/dist/collection/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.js +5 -0
  31. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextArea.tpl.js +5 -0
  32. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextInput.tpl.js +5 -0
  33. package/dist/collection/components/ez-form/store/form.slice.js +38 -0
  34. package/dist/collection/components/ez-form/structure/FormItem.js +11 -0
  35. package/dist/collection/components/ez-form/structure/FormSheet.js +5 -0
  36. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +86 -0
  37. package/dist/collection/components/test-du/test-du.js +65 -23
  38. package/dist/custom-elements/index.d.ts +0 -12
  39. package/dist/custom-elements/index.js +380 -2065
  40. package/dist/esm/{AssetsUtils-3803e935.js → AssetsUtils-76ca41e1.js} +1 -1
  41. package/dist/esm/ez-action-chip.entry.js +1 -1
  42. package/dist/esm/ez-application.entry.js +1 -1
  43. package/dist/esm/ez-button_3.entry.js +514 -0
  44. package/dist/esm/ez-calendar_13.entry.js +2401 -0
  45. package/dist/esm/ez-date-time-input.entry.js +2 -2
  46. package/dist/esm/ez-dialog.entry.js +1 -1
  47. package/dist/esm/{ez-button_11.entry.js → ez-grid.entry.js} +4 -1390
  48. package/dist/esm/ez-icon.entry.js +26 -0
  49. package/dist/esm/ez-label-chip.entry.js +1 -1
  50. package/dist/esm/ez-modal_2.entry.js +365 -0
  51. package/dist/esm/ez-popover.entry.js +2 -2
  52. package/dist/esm/ez-popup.entry.js +1 -1
  53. package/dist/esm/ez-time-input.entry.js +3 -3
  54. package/dist/esm/ez-toast.entry.js +1 -1
  55. package/dist/esm/ezui.js +2 -2
  56. package/dist/esm/{index-1dacecd3.js → index-077c7fcf.js} +0 -10
  57. package/dist/esm/{index-ca8700cb.js → index-afe19542.js} +17 -21
  58. package/dist/esm/loader.js +2 -2
  59. package/dist/ezui/ezui.esm.js +1 -1
  60. package/dist/ezui/p-00b837e2.js +1 -0
  61. package/dist/ezui/{p-516d0e0f.entry.js → p-0a2056d9.entry.js} +1 -1
  62. package/dist/ezui/{p-a15093e3.entry.js → p-0d8368fc.entry.js} +1 -1
  63. package/dist/ezui/p-1e36e3ff.entry.js +1 -0
  64. package/dist/ezui/p-446ec85b.js +1 -0
  65. package/dist/ezui/{p-74f978db.entry.js → p-5509ee41.entry.js} +46 -46
  66. package/dist/ezui/{p-a18a2d7b.entry.js → p-57ea4b84.entry.js} +1 -1
  67. package/dist/ezui/{p-5a86e18a.entry.js → p-6d157776.entry.js} +1 -1
  68. package/dist/ezui/{p-f3c5f27e.entry.js → p-7a1f2e0e.entry.js} +1 -1
  69. package/dist/ezui/p-7de3c95d.js +1 -0
  70. package/dist/ezui/{p-8d6cdd3e.entry.js → p-857ead8e.entry.js} +1 -1
  71. package/dist/ezui/{p-c6d469fc.entry.js → p-920bb8c9.entry.js} +1 -1
  72. package/dist/ezui/p-9be02ecf.entry.js +1 -0
  73. package/dist/ezui/p-a4a39579.entry.js +1 -0
  74. package/dist/ezui/p-d5699f29.entry.js +1 -0
  75. package/dist/ezui/p-d64a3939.entry.js +1 -0
  76. package/dist/ezui/{p-5da66d3e.entry.js → p-da31cd21.entry.js} +1 -1
  77. package/dist/types/components/ez-form/DataBinder.d.ts +10 -0
  78. package/dist/types/components/ez-form/ez-form.d.ts +24 -32
  79. package/dist/types/components/ez-form/fieldbuilder/FieldBuilder.d.ts +2 -0
  80. package/dist/types/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.d.ts +3 -0
  81. package/dist/types/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.d.ts +4 -0
  82. package/dist/types/components/ez-form/fieldbuilder/tpl/DateInput.tpl.d.ts +4 -0
  83. package/dist/types/components/ez-form/fieldbuilder/tpl/FileInput.tpl.d.ts +4 -0
  84. package/dist/types/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.d.ts +8 -0
  85. package/dist/types/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.d.ts +4 -0
  86. package/dist/types/components/ez-form/fieldbuilder/tpl/TextArea.tpl.d.ts +4 -0
  87. package/dist/types/components/ez-form/fieldbuilder/tpl/TextInput.tpl.d.ts +4 -0
  88. package/dist/types/components/ez-form/store/form.slice.d.ts +24 -0
  89. package/dist/types/components/ez-form/structure/FormItem.d.ts +9 -0
  90. package/dist/types/components/ez-form/structure/FormSheet.d.ts +9 -0
  91. package/dist/types/components/ez-form/structure/FormSheetMetadata.d.ts +27 -0
  92. package/dist/types/components/test-du/test-du.d.ts +8 -2
  93. package/dist/types/components.d.ts +9 -63
  94. package/package.json +1 -1
  95. package/react/components.d.ts +0 -2
  96. package/react/components.js +0 -2
  97. package/react/components.js.map +1 -1
  98. package/dist/cjs/ApplicationUtils-d1c1db56.js +0 -35
  99. package/dist/cjs/DataUnit-fdd7c70e.js +0 -474
  100. package/dist/cjs/ez-calendar.cjs.entry.js +0 -217
  101. package/dist/cjs/ez-collapsible-box_6.cjs.entry.js +0 -634
  102. package/dist/cjs/ez-combo-box.cjs.entry.js +0 -254
  103. package/dist/cjs/ez-form.cjs.entry.js +0 -1838
  104. package/dist/cjs/ez-number-input.cjs.entry.js +0 -74
  105. package/dist/cjs/form-metadata.cjs.entry.js +0 -129
  106. package/dist/collection/components/ez-form/assets/trash-can-outline.svg +0 -3
  107. package/dist/collection/components/ez-form/store/Form.actions.js +0 -132
  108. package/dist/collection/components/ez-form/store/Form.reducer.js +0 -194
  109. package/dist/collection/components/ez-form/store/Form.selectors.js +0 -44
  110. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +0 -301
  111. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +0 -8
  112. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +0 -24
  113. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +0 -227
  114. package/dist/collection/components/ez-form/subcomponents/place-holder.js +0 -14
  115. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +0 -95
  116. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +0 -27
  117. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +0 -41
  118. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +0 -37
  119. package/dist/esm/ApplicationUtils-01280a9d.js +0 -33
  120. package/dist/esm/DataUnit-1cd45202.js +0 -464
  121. package/dist/esm/ez-calendar.entry.js +0 -213
  122. package/dist/esm/ez-collapsible-box_6.entry.js +0 -625
  123. package/dist/esm/ez-combo-box.entry.js +0 -250
  124. package/dist/esm/ez-form.entry.js +0 -1834
  125. package/dist/esm/ez-number-input.entry.js +0 -70
  126. package/dist/esm/form-metadata.entry.js +0 -125
  127. package/dist/ezui/assets/trash-can-outline.svg +0 -3
  128. package/dist/ezui/p-14bee38e.entry.js +0 -1
  129. package/dist/ezui/p-37a611ea.js +0 -1
  130. package/dist/ezui/p-3a09c678.entry.js +0 -1
  131. package/dist/ezui/p-43c15c94.entry.js +0 -1
  132. package/dist/ezui/p-7107d7ef.js +0 -1
  133. package/dist/ezui/p-72ff3c95.entry.js +0 -1
  134. package/dist/ezui/p-88f45a83.entry.js +0 -1
  135. package/dist/ezui/p-8f4851a6.js +0 -1
  136. package/dist/ezui/p-9dfd537e.js +0 -1
  137. package/dist/ezui/p-a0331955.entry.js +0 -1
  138. package/dist/ezui/p-a19f2af3.entry.js +0 -1
  139. package/dist/ezui/p-da929c01.js +0 -1
  140. package/dist/types/components/ez-form/store/Form.actions.d.ts +0 -111
  141. package/dist/types/components/ez-form/store/Form.reducer.d.ts +0 -20
  142. package/dist/types/components/ez-form/store/Form.selectors.d.ts +0 -14
  143. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +0 -91
  144. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +0 -24
  145. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +0 -16
  146. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +0 -3
  147. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +0 -11
  148. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +0 -13
  149. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +0 -14
  150. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +0 -19
@@ -1360,7 +1360,7 @@ function updateSavedIds(stateManager, savedRecords) {
1360
1360
  return currentSelection;
1361
1361
  }
1362
1362
 
1363
- class DataUnit$1 {
1363
+ class DataUnit {
1364
1364
  constructor(name) {
1365
1365
  this._name = name;
1366
1366
  this._stateManager = new StateManager([
@@ -1552,12 +1552,12 @@ var SortMode;
1552
1552
  SortMode["ASC"] = "ASC";
1553
1553
  SortMode["DESC"] = "DESC";
1554
1554
  })(SortMode || (SortMode = {}));
1555
- var DependencyType$1;
1555
+ var DependencyType;
1556
1556
  (function (DependencyType) {
1557
1557
  DependencyType["SEARCHING"] = "SEARCHING";
1558
1558
  DependencyType["REQUIREMENT"] = "REQUIREMENT";
1559
1559
  DependencyType["VISIBILITY"] = "REQUIREMENT";
1560
- })(DependencyType$1 || (DependencyType$1 = {}));
1560
+ })(DependencyType || (DependencyType = {}));
1561
1561
  var UserInterface;
1562
1562
  (function (UserInterface) {
1563
1563
  UserInterface["FILE"] = "FILE";
@@ -1591,10 +1591,6 @@ var LoadType;
1591
1591
 
1592
1592
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1593
1593
 
1594
- function getDefaultExportFromCjs (x) {
1595
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1596
- }
1597
-
1598
1594
  function createCommonjsModule(fn, basedir, module) {
1599
1595
  return module = {
1600
1596
  path: basedir,
@@ -8609,58 +8605,206 @@ let EzDialog$1 = class extends HTMLElement$1 {
8609
8605
  static get style() { return ezDialogCss; }
8610
8606
  };
8611
8607
 
8612
- function _defineProperty(obj, key, value) {
8613
- if (key in obj) {
8614
- Object.defineProperty(obj, key, {
8615
- value: value,
8616
- enumerable: true,
8617
- configurable: true,
8618
- writable: true
8619
- });
8620
- } else {
8621
- obj[key] = value;
8622
- }
8608
+ const buildTextArea = ({ name, label }) => {
8609
+ return (h("div", { class: "col col--sd-12 padding--small", key: name },
8610
+ h("ez-text-area", { label: label, "data-field-name": name })));
8611
+ };
8612
+
8613
+ const buildTextInput = ({ name, label }) => {
8614
+ return (h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
8615
+ h("ez-text-input", { label: label, "data-field-name": name, key: name })));
8616
+ };
8623
8617
 
8624
- return obj;
8618
+ const buildSwitch = (fieldConfig) => {
8619
+ return buildField$1(fieldConfig.name, fieldConfig.label, true);
8620
+ };
8621
+ const buildCheckBox = (fieldConfig) => {
8622
+ return buildField$1(fieldConfig.name, fieldConfig.label, false);
8623
+ };
8624
+ function buildField$1(fieldName, fieldLabel, switchMode = false) {
8625
+ return (h("div", { class: "col col--sd-12 col--tb-3 padding--small align--middle padding-bottom--large" },
8626
+ h("ez-check", { label: fieldLabel, mode: switchMode ? "switch" : "regular", "data-field-name": fieldName, key: fieldName })));
8625
8627
  }
8626
8628
 
8627
- function ownKeys(object, enumerableOnly) {
8628
- var keys = Object.keys(object);
8629
+ const buildComboBox = ({ name, label }, properties) => {
8630
+ const prop = properties === null || properties === void 0 ? void 0 : properties.options;
8631
+ let options;
8632
+ if (typeof prop === "string") {
8633
+ const parsed = JSON.parse(prop);
8634
+ options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
8635
+ }
8636
+ else {
8637
+ options = prop;
8638
+ }
8639
+ return (h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
8640
+ h("ez-combo-box", { label: label, "data-field-name": name, key: name, options: options })));
8641
+ };
8629
8642
 
8630
- if (Object.getOwnPropertySymbols) {
8631
- var symbols = Object.getOwnPropertySymbols(object);
8643
+ const buildSearch = ({ name, label }) => {
8644
+ return (h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
8645
+ h("ez-search", { label: label, optionLoader: (_argument) => { }, "data-field-name": name, key: name })));
8646
+ };
8632
8647
 
8633
- if (enumerableOnly) {
8634
- symbols = symbols.filter(function (sym) {
8635
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
8636
- });
8637
- }
8648
+ const buildFile = ({ name, label }) => {
8649
+ return (h("div", { class: "col col--sd-12 padding--small" },
8650
+ h("ez-upload", { label: label, urlUpload: "", requestHeaders: "", maxFiles: 10, "data-field-name": name, key: name })));
8651
+ };
8638
8652
 
8639
- keys.push.apply(keys, symbols);
8640
- }
8653
+ const buildDate = ({ name, label }) => {
8654
+ return (h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
8655
+ h("ez-date-input", { label: label, "data-field-name": name, key: name })));
8656
+ };
8641
8657
 
8642
- return keys;
8658
+ const buildDecimal = ({ name, label }, properties) => {
8659
+ const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
8660
+ const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
8661
+ return buildNumeric(name, label, precision, prettyPrecision);
8662
+ };
8663
+ const buildInteger = ({ name, label }) => {
8664
+ return buildNumeric(name, label, 0, 0);
8665
+ };
8666
+ function buildNumeric(fieldName, fieldLabel, precision, prettyPrecision) {
8667
+ return (h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
8668
+ h("ez-number-input", { label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
8643
8669
  }
8644
8670
 
8645
- function _objectSpread2(target) {
8646
- for (var i = 1; i < arguments.length; i++) {
8647
- var source = arguments[i] != null ? arguments[i] : {};
8648
-
8649
- if (i % 2) {
8650
- ownKeys(Object(source), true).forEach(function (key) {
8651
- _defineProperty(target, key, source[key]);
8652
- });
8653
- } else if (Object.getOwnPropertyDescriptors) {
8654
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8655
- } else {
8656
- ownKeys(Object(source)).forEach(function (key) {
8657
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8658
- });
8671
+ const uiBuilders = new Map();
8672
+ uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
8673
+ uiBuilders.set(UserInterface.CHECKBOX, buildCheckBox);
8674
+ uiBuilders.set(UserInterface.SWITCH, buildSwitch);
8675
+ uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
8676
+ uiBuilders.set(UserInterface.SEARCH, buildSearch);
8677
+ uiBuilders.set(UserInterface.FILE, buildFile);
8678
+ uiBuilders.set(UserInterface.DATE, buildDate);
8679
+ uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
8680
+ uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
8681
+ const buildField = (field) => {
8682
+ const descriptor = field.descriptor;
8683
+ const config = Object.assign({}, field.config);
8684
+ let builder;
8685
+ let props;
8686
+ if (descriptor) {
8687
+ builder = uiBuilders.get(descriptor.userInterface);
8688
+ if (!config.label) {
8689
+ config.label = descriptor.label;
8690
+ }
8691
+ if (!config.name) {
8692
+ config.name = descriptor.name;
8693
+ }
8694
+ if (config.required === undefined) {
8695
+ config.required = descriptor.required;
8659
8696
  }
8697
+ props = descriptor.properties;
8698
+ }
8699
+ if (config.required) {
8700
+ config.label = `* ${config.label} (obrigatório)`;
8701
+ }
8702
+ if (!builder) {
8703
+ builder = buildTextInput;
8704
+ }
8705
+ return builder(config, props);
8706
+ };
8707
+
8708
+ const FormItem = ({ source }) => {
8709
+ if ("items" in source) {
8710
+ const fieldSet = source;
8711
+ return h("ez-collapsible-box", { label: source.label }, fieldSet.items.map(fi => buildField(fi)));
8712
+ }
8713
+ else {
8714
+ return buildField(source);
8660
8715
  }
8716
+ };
8717
+
8718
+ const FormSheet = ({ store, source }) => {
8719
+ return (h("div", { class: "box__container" }, source.items.map(item => h(FormItem, { store: store, source: item }))));
8720
+ };
8661
8721
 
8662
- return target;
8722
+ class FormMetadata {
8723
+ constructor() {
8724
+ this._sheets = new Map();
8725
+ this._requiredFields = [];
8726
+ }
8727
+ getSheet(name) {
8728
+ return this._sheets.get(name);
8729
+ }
8730
+ getAllSheets() {
8731
+ return this._sheets;
8732
+ }
8733
+ addSheet(sheet) {
8734
+ this._sheets.set(sheet.name, sheet);
8735
+ this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
8736
+ }
8737
+ getRequiredFields() {
8738
+ return this._requiredFields;
8739
+ }
8663
8740
  }
8741
+ const buildFromDataUnit = (dataUnit) => {
8742
+ var _a;
8743
+ const unitMD = dataUnit.metadata;
8744
+ const metadata = new FormMetadata();
8745
+ if (unitMD) {
8746
+ const visibleFields = (_a = unitMD.fields) === null || _a === void 0 ? void 0 : _a.filter(descriptor => descriptor.visible !== false);
8747
+ metadata.addSheet({
8748
+ label: unitMD.label,
8749
+ name: unitMD.name,
8750
+ items: visibleFields.map(descriptor => { return { descriptor }; }),
8751
+ requiredFields: visibleFields
8752
+ .filter(descriptor => descriptor.required)
8753
+ .map(descriptor => descriptor.name)
8754
+ });
8755
+ }
8756
+ return metadata;
8757
+ };
8758
+ const buildFromConfig = (fields, dataUnit) => {
8759
+ const sheets = new Map();
8760
+ const requiredFields = [];
8761
+ fields.forEach(config => {
8762
+ if (config.visible !== false) {
8763
+ const tab = config.tab || "Geral";
8764
+ const descriptor = dataUnit.getField(config.name);
8765
+ if (!sheets.has(tab)) {
8766
+ sheets.set(tab, new Map());
8767
+ }
8768
+ let isRequired = false;
8769
+ if (config.required === undefined) {
8770
+ if (descriptor) {
8771
+ isRequired = descriptor.required;
8772
+ }
8773
+ }
8774
+ else {
8775
+ isRequired = config.required;
8776
+ }
8777
+ if (isRequired) {
8778
+ requiredFields.push(config.name);
8779
+ }
8780
+ const tabItens = sheets.get(tab);
8781
+ const fieldMD = { config, descriptor };
8782
+ const group = config.group;
8783
+ if (group) {
8784
+ const key = `group::${group}`;
8785
+ if (!tabItens.has(key)) {
8786
+ tabItens.set(key, { label: group, items: [fieldMD] });
8787
+ }
8788
+ else {
8789
+ tabItens.get(key).items.push(fieldMD);
8790
+ }
8791
+ }
8792
+ else {
8793
+ tabItens.set(config.name, fieldMD);
8794
+ }
8795
+ }
8796
+ });
8797
+ const metadata = new FormMetadata();
8798
+ sheets.forEach((value, key) => {
8799
+ metadata.addSheet({
8800
+ label: key,
8801
+ name: key,
8802
+ items: Array.from(value.values()),
8803
+ requiredFields
8804
+ });
8805
+ });
8806
+ return metadata;
8807
+ };
8664
8808
 
8665
8809
  /**
8666
8810
  * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
@@ -8985,1145 +9129,88 @@ function createStore(reducer, preloadedState, enhancer) {
8985
9129
  }, _ref2[$$observable] = observable, _ref2;
8986
9130
  }
8987
9131
 
8988
- function assertReducerShape(reducers) {
8989
- Object.keys(reducers).forEach(function (key) {
8990
- var reducer = reducers[key];
8991
- var initialState = reducer(undefined, {
8992
- type: ActionTypes.INIT
8993
- });
8994
-
8995
- if (typeof initialState === 'undefined') {
8996
- throw new Error(formatProdErrorMessage(12) );
8997
- }
8998
-
8999
- if (typeof reducer(undefined, {
9000
- type: ActionTypes.PROBE_UNKNOWN_ACTION()
9001
- }) === 'undefined') {
9002
- throw new Error(formatProdErrorMessage(13) );
9003
- }
9004
- });
9005
- }
9006
- /**
9007
- * Turns an object whose values are different reducer functions, into a single
9008
- * reducer function. It will call every child reducer, and gather their results
9009
- * into a single state object, whose keys correspond to the keys of the passed
9010
- * reducer functions.
9011
- *
9012
- * @param {Object} reducers An object whose values correspond to different
9013
- * reducer functions that need to be combined into one. One handy way to obtain
9014
- * it is to use ES6 `import * as reducers` syntax. The reducers may never return
9015
- * undefined for any action. Instead, they should return their initial state
9016
- * if the state passed to them was undefined, and the current state for any
9017
- * unrecognized action.
9018
- *
9019
- * @returns {Function} A reducer function that invokes every reducer inside the
9020
- * passed object, and builds a state object with the same shape.
9021
- */
9022
-
9023
-
9024
- function combineReducers(reducers) {
9025
- var reducerKeys = Object.keys(reducers);
9026
- var finalReducers = {};
9027
-
9028
- for (var i = 0; i < reducerKeys.length; i++) {
9029
- var key = reducerKeys[i];
9030
-
9031
- if (typeof reducers[key] === 'function') {
9032
- finalReducers[key] = reducers[key];
9033
- }
9034
- }
9035
-
9036
- var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
9037
-
9038
- var shapeAssertionError;
9039
-
9040
- try {
9041
- assertReducerShape(finalReducers);
9042
- } catch (e) {
9043
- shapeAssertionError = e;
9044
- }
9045
-
9046
- return function combination(state, action) {
9047
- if (state === void 0) {
9048
- state = {};
9049
- }
9050
-
9051
- if (shapeAssertionError) {
9052
- throw shapeAssertionError;
9053
- }
9054
-
9055
- var hasChanged = false;
9056
- var nextState = {};
9057
-
9058
- for (var _i = 0; _i < finalReducerKeys.length; _i++) {
9059
- var _key = finalReducerKeys[_i];
9060
- var reducer = finalReducers[_key];
9061
- var previousStateForKey = state[_key];
9062
- var nextStateForKey = reducer(previousStateForKey, action);
9063
-
9064
- if (typeof nextStateForKey === 'undefined') {
9065
- throw new Error(formatProdErrorMessage(14) );
9066
- }
9067
-
9068
- nextState[_key] = nextStateForKey;
9069
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
9070
- }
9071
-
9072
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
9073
- return hasChanged ? nextState : state;
9074
- };
9075
- }
9076
-
9077
- /**
9078
- * Composes single-argument functions from right to left. The rightmost
9079
- * function can take multiple arguments as it provides the signature for
9080
- * the resulting composite function.
9081
- *
9082
- * @param {...Function} funcs The functions to compose.
9083
- * @returns {Function} A function obtained by composing the argument functions
9084
- * from right to left. For example, compose(f, g, h) is identical to doing
9085
- * (...args) => f(g(h(...args))).
9086
- */
9087
- function compose() {
9088
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
9089
- funcs[_key] = arguments[_key];
9090
- }
9091
-
9092
- if (funcs.length === 0) {
9093
- return function (arg) {
9094
- return arg;
9095
- };
9096
- }
9097
-
9098
- if (funcs.length === 1) {
9099
- return funcs[0];
9100
- }
9101
-
9102
- return funcs.reduce(function (a, b) {
9103
- return function () {
9104
- return a(b.apply(void 0, arguments));
9105
- };
9106
- });
9107
- }
9108
-
9109
- /**
9110
- * Creates a store enhancer that applies middleware to the dispatch method
9111
- * of the Redux store. This is handy for a variety of tasks, such as expressing
9112
- * asynchronous actions in a concise manner, or logging every action payload.
9113
- *
9114
- * See `redux-thunk` package as an example of the Redux middleware.
9115
- *
9116
- * Because middleware is potentially asynchronous, this should be the first
9117
- * store enhancer in the composition chain.
9118
- *
9119
- * Note that each middleware will be given the `dispatch` and `getState` functions
9120
- * as named arguments.
9121
- *
9122
- * @param {...Function} middlewares The middleware chain to be applied.
9123
- * @returns {Function} A store enhancer applying the middleware.
9124
- */
9125
-
9126
- function applyMiddleware() {
9127
- for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
9128
- middlewares[_key] = arguments[_key];
9132
+ const inicialState = {};
9133
+ /////////////////////////////// REDUCERS ///////////////////////////////
9134
+ function formReducer(state = inicialState, action) {
9135
+ switch (action.type) {
9136
+ case FormActions.METADATA_LOADED:
9137
+ return Object.assign(Object.assign({}, state), { formMetadata: action.payload });
9138
+ case FormActions.CHANGE_TAB:
9139
+ return Object.assign(Object.assign({}, state), { currentSheet: action.payload });
9140
+ default:
9141
+ return state;
9129
9142
  }
9130
-
9131
- return function (createStore) {
9132
- return function () {
9133
- var store = createStore.apply(void 0, arguments);
9134
-
9135
- var _dispatch = function dispatch() {
9136
- throw new Error(formatProdErrorMessage(15) );
9137
- };
9138
-
9139
- var middlewareAPI = {
9140
- getState: store.getState,
9141
- dispatch: function dispatch() {
9142
- return _dispatch.apply(void 0, arguments);
9143
- }
9144
- };
9145
- var chain = middlewares.map(function (middleware) {
9146
- return middleware(middlewareAPI);
9147
- });
9148
- _dispatch = compose.apply(void 0, chain)(store.dispatch);
9149
- return _objectSpread2(_objectSpread2({}, store), {}, {
9150
- dispatch: _dispatch
9151
- });
9152
- };
9153
- };
9154
- }
9155
-
9156
- /** A function that accepts a potential "extra argument" value to be injected later,
9157
- * and returns an instance of the thunk middleware that uses that value
9158
- */
9159
- function createThunkMiddleware(extraArgument) {
9160
- // Standard Redux middleware definition pattern:
9161
- // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
9162
- var middleware = function middleware(_ref) {
9163
- var dispatch = _ref.dispatch,
9164
- getState = _ref.getState;
9165
- return function (next) {
9166
- return function (action) {
9167
- // The thunk middleware looks for any functions that were passed to `store.dispatch`.
9168
- // If this "action" is really a function, call it and return the result.
9169
- if (typeof action === 'function') {
9170
- // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
9171
- return action(dispatch, getState, extraArgument);
9172
- } // Otherwise, pass the action down the middleware chain as usual
9173
-
9174
-
9175
- return next(action);
9176
- };
9177
- };
9178
- };
9179
-
9180
- return middleware;
9181
- }
9182
-
9183
- var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
9184
- // with whatever "extra arg" they want to inject into their thunks
9185
-
9186
- thunk.withExtraArgument = createThunkMiddleware;
9187
-
9188
- function changeFieldValue$1(dataUnit, recordId, fieldName, value) {
9189
- return {
9190
- type: "FORM/CHANGEFIELD",
9191
- payload: { dataUnit, recordId, fieldName, value }
9192
- };
9193
- }
9194
- function changeTab$1(formId, index) {
9195
- return {
9196
- type: "FORM/CHANGETAB",
9197
- payload: { formId, index }
9198
- };
9199
- }
9200
- function clearEdition$1(dataUnit, recordsLimit) {
9201
- return {
9202
- type: "FORM/CLEAREDITION",
9203
- payload: {
9204
- dataUnit,
9205
- recordsLimit
9206
- }
9207
- };
9208
- }
9209
- function collapseExpandGroup(collapseId, collapsed) {
9210
- return {
9211
- type: "FORM/COLLAPSEGROUP",
9212
- payload: { collapseId, collapsed }
9213
- };
9214
- }
9215
- function previousRecord(dataUnit) {
9216
- return {
9217
- type: "FORM/NAVIGATE",
9218
- payload: {
9219
- dataUnit,
9220
- limit: 0,
9221
- backward: true
9222
- }
9223
- };
9224
9143
  }
9225
- function nextRecord(dataUnit, limit) {
9144
+ /////////////////////////////// ACTION CREATORS ///////////////////////////////
9145
+ function loadMetadata(formMetadata) {
9226
9146
  return {
9227
- type: "FORM/NAVIGATE",
9228
- payload: {
9229
- dataUnit,
9230
- limit,
9231
- backward: false
9232
- }
9147
+ type: FormActions.METADATA_LOADED,
9148
+ payload: formMetadata
9233
9149
  };
9234
9150
  }
9235
- function insertRecord$1(dataUnit, insertionIndex) {
9151
+ function changeTab(currentSheet) {
9236
9152
  return {
9237
- type: "FORM/INSERT",
9238
- payload: {
9239
- dataUnit,
9240
- insertionIndex
9241
- }
9153
+ type: FormActions.CHANGE_TAB,
9154
+ payload: currentSheet
9242
9155
  };
9243
9156
  }
9244
- function formLoad() {
9245
- return {
9246
- type: "FORM/LOAD"
9247
- };
9157
+ /////////////////////////////// SELECTORS ///////////////////////////////
9158
+ function selectFormMetadata(state) {
9159
+ return state.formMetadata;
9248
9160
  }
9249
- function dataLoading$1(dataUnit) {
9250
- return {
9251
- type: "FORM/DATALOADING",
9252
- payload: {
9253
- dataUnit
9254
- }
9255
- };
9256
- }
9257
- function savingChanges$1(dataUnit) {
9258
- return {
9259
- type: "FORM/SAVINGCHANGES",
9260
- payload: {
9261
- dataUnit
9262
- }
9263
- };
9264
- }
9265
- function dataLoaded$1(dataUnit) {
9266
- return {
9267
- type: "FORM/DATALOADED",
9268
- payload: {
9269
- dataUnit
9270
- }
9271
- };
9272
- }
9273
- function changesSaved$1(dataUnit) {
9274
- return {
9275
- type: "FORM/CHANGESSAVED",
9276
- payload: {
9277
- dataUnit
9278
- }
9279
- };
9161
+ function selectCurrentSheet(state) {
9162
+ return state.currentSheet ? state.formMetadata.getSheet(state.currentSheet) : Array.from(state.formMetadata.getAllSheets().values())[0];
9280
9163
  }
9281
- function removingRecord$1(dataUnit) {
9282
- return {
9283
- type: "FORM/REMOVINGRECORD",
9284
- payload: {
9285
- dataUnit
9286
- }
9287
- };
9288
- }
9289
- function recordRemoved$1(dataUnit) {
9290
- return {
9291
- type: "FORM/RECORDREMOVED",
9292
- payload: {
9293
- dataUnit
9294
- }
9295
- };
9296
- }
9297
- function invalidField$1(tabController, tabIndex, dataUnit, recordIndex, recordId, fieldName, errorMessage) {
9298
- return {
9299
- type: "FORM/INVALIDFIELD",
9300
- payload: {
9301
- tabController,
9302
- tabIndex,
9303
- dataUnit,
9304
- recordId,
9305
- recordIndex,
9306
- fieldName,
9307
- errorMessage
9308
- }
9309
- };
9310
- }
9311
- function showHideNavigationButtons(buttonName, status) {
9312
- return {
9313
- type: "FORM/SHOWHIDENAVBTN",
9314
- payload: {
9315
- buttonName,
9316
- status
9317
- }
9318
- };
9319
- }
9320
-
9321
- var actions = createCommonjsModule(function (module, exports) {
9164
+ /////////////////////////////// TYPES ///////////////////////////////
9165
+ var FormActions;
9166
+ (function (FormActions) {
9167
+ FormActions["METADATA_LOADED"] = "FORM/METADATA_LOADED";
9168
+ FormActions["CHANGE_TAB"] = "FORM/CHANGE_TAB";
9169
+ })(FormActions || (FormActions = {}));
9322
9170
 
9323
- Object.defineProperty(exports, "__esModule", {
9324
- value: true
9325
- });
9326
- exports.ActionCreators = exports.ActionTypes = void 0;
9327
- var ActionTypes = {
9328
- UNDO: '@@redux-undo/UNDO',
9329
- REDO: '@@redux-undo/REDO',
9330
- JUMP_TO_FUTURE: '@@redux-undo/JUMP_TO_FUTURE',
9331
- JUMP_TO_PAST: '@@redux-undo/JUMP_TO_PAST',
9332
- JUMP: '@@redux-undo/JUMP',
9333
- CLEAR_HISTORY: '@@redux-undo/CLEAR_HISTORY'
9334
- };
9335
- exports.ActionTypes = ActionTypes;
9336
- var ActionCreators = {
9337
- undo: function undo() {
9338
- return {
9339
- type: ActionTypes.UNDO
9340
- };
9341
- },
9342
- redo: function redo() {
9343
- return {
9344
- type: ActionTypes.REDO
9345
- };
9346
- },
9347
- jumpToFuture: function jumpToFuture(index) {
9348
- return {
9349
- type: ActionTypes.JUMP_TO_FUTURE,
9350
- index: index
9351
- };
9352
- },
9353
- jumpToPast: function jumpToPast(index) {
9354
- return {
9355
- type: ActionTypes.JUMP_TO_PAST,
9356
- index: index
9357
- };
9358
- },
9359
- jump: function jump(index) {
9360
- return {
9361
- type: ActionTypes.JUMP,
9362
- index: index
9363
- };
9364
- },
9365
- clearHistory: function clearHistory() {
9366
- return {
9367
- type: ActionTypes.CLEAR_HISTORY
9368
- };
9369
- }
9370
- };
9371
- exports.ActionCreators = ActionCreators;
9372
- });
9373
-
9374
- var helpers = createCommonjsModule(function (module, exports) {
9375
-
9376
- Object.defineProperty(exports, "__esModule", {
9377
- value: true
9378
- });
9379
- exports.parseActions = parseActions;
9380
- exports.isHistory = isHistory;
9381
- exports.includeAction = includeAction;
9382
- exports.excludeAction = excludeAction;
9383
- exports.combineFilters = combineFilters;
9384
- exports.groupByActionTypes = groupByActionTypes;
9385
- exports.newHistory = newHistory;
9386
-
9387
- // parseActions helper: takes a string (or array)
9388
- // and makes it an array if it isn't yet
9389
- function parseActions(rawActions) {
9390
- var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
9391
-
9392
- if (Array.isArray(rawActions)) {
9393
- return rawActions;
9394
- } else if (typeof rawActions === 'string') {
9395
- return [rawActions];
9396
- }
9397
-
9398
- return defaultValue;
9399
- } // isHistory helper: check for a valid history object
9400
-
9401
-
9402
- function isHistory(history) {
9403
- return typeof history.present !== 'undefined' && typeof history.future !== 'undefined' && typeof history.past !== 'undefined' && Array.isArray(history.future) && Array.isArray(history.past);
9404
- } // includeAction helper: whitelist actions to be added to the history
9405
-
9406
-
9407
- function includeAction(rawActions) {
9408
- var actions = parseActions(rawActions);
9409
- return function (action) {
9410
- return actions.indexOf(action.type) >= 0;
9411
- };
9412
- } // excludeAction helper: blacklist actions from being added to the history
9413
-
9414
-
9415
- function excludeAction(rawActions) {
9416
- var actions = parseActions(rawActions);
9417
- return function (action) {
9418
- return actions.indexOf(action.type) < 0;
9419
- };
9420
- } // combineFilters helper: combine multiple filters to one
9421
-
9422
-
9423
- function combineFilters() {
9424
- for (var _len = arguments.length, filters = new Array(_len), _key = 0; _key < _len; _key++) {
9425
- filters[_key] = arguments[_key];
9426
- }
9427
-
9428
- return filters.reduce(function (prev, curr) {
9429
- return function (action, currentState, previousHistory) {
9430
- return prev(action, currentState, previousHistory) && curr(action, currentState, previousHistory);
9431
- };
9432
- }, function () {
9433
- return true;
9434
- });
9435
- }
9436
-
9437
- function groupByActionTypes(rawActions) {
9438
- var actions = parseActions(rawActions);
9439
- return function (action) {
9440
- return actions.indexOf(action.type) >= 0 ? action.type : null;
9441
- };
9442
- }
9443
-
9444
- function newHistory(past, present, future) {
9445
- var group = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
9446
- return {
9447
- past: past,
9448
- present: present,
9449
- future: future,
9450
- group: group,
9451
- _latestUnfiltered: present,
9452
- index: past.length,
9453
- limit: past.length + future.length + 1
9454
- };
9455
- }
9456
- });
9457
-
9458
- var debug = createCommonjsModule(function (module, exports) {
9459
-
9460
- Object.defineProperty(exports, "__esModule", {
9461
- value: true
9462
- });
9463
- exports.set = set;
9464
- exports.start = start;
9465
- exports.end = end;
9466
- exports.log = log;
9467
-
9468
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
9469
-
9470
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
9471
-
9472
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
9473
-
9474
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
9475
-
9476
- var __DEBUG__;
9477
-
9478
- var displayBuffer;
9479
- var colors = {
9480
- prevState: '#9E9E9E',
9481
- action: '#03A9F4',
9482
- nextState: '#4CAF50'
9483
- };
9484
- /* istanbul ignore next: debug messaging is not tested */
9485
-
9486
- function initBuffer() {
9487
- displayBuffer = {
9488
- header: [],
9489
- prev: [],
9490
- action: [],
9491
- next: [],
9492
- msgs: []
9493
- };
9494
- }
9495
- /* istanbul ignore next: debug messaging is not tested */
9496
-
9497
-
9498
- function printBuffer() {
9499
- var _displayBuffer = displayBuffer,
9500
- header = _displayBuffer.header,
9501
- prev = _displayBuffer.prev,
9502
- next = _displayBuffer.next,
9503
- action = _displayBuffer.action,
9504
- msgs = _displayBuffer.msgs;
9505
-
9506
- if (console.group) {
9507
- var _console, _console2, _console3, _console4, _console5;
9508
-
9509
- (_console = console).groupCollapsed.apply(_console, _toConsumableArray(header));
9510
-
9511
- (_console2 = console).log.apply(_console2, _toConsumableArray(prev));
9512
-
9513
- (_console3 = console).log.apply(_console3, _toConsumableArray(action));
9514
-
9515
- (_console4 = console).log.apply(_console4, _toConsumableArray(next));
9516
-
9517
- (_console5 = console).log.apply(_console5, _toConsumableArray(msgs));
9518
-
9519
- console.groupEnd();
9520
- } else {
9521
- var _console6, _console7, _console8, _console9, _console10;
9522
-
9523
- (_console6 = console).log.apply(_console6, _toConsumableArray(header));
9524
-
9525
- (_console7 = console).log.apply(_console7, _toConsumableArray(prev));
9526
-
9527
- (_console8 = console).log.apply(_console8, _toConsumableArray(action));
9528
-
9529
- (_console9 = console).log.apply(_console9, _toConsumableArray(next));
9530
-
9531
- (_console10 = console).log.apply(_console10, _toConsumableArray(msgs));
9171
+ class DataBinder {
9172
+ constructor(dataUnit) {
9173
+ this._dataUnit = dataUnit;
9174
+ this._fields = new Map();
9532
9175
  }
9533
- }
9534
- /* istanbul ignore next: debug messaging is not tested */
9535
-
9536
-
9537
- function colorFormat(text, color, obj) {
9538
- return ["%c".concat(text), "color: ".concat(color, "; font-weight: bold"), obj];
9539
- }
9540
- /* istanbul ignore next: debug messaging is not tested */
9541
-
9542
-
9543
- function start(action, state) {
9544
- initBuffer();
9545
-
9546
- if (__DEBUG__) {
9547
- if (console.group) {
9548
- displayBuffer.header = ['%credux-undo', 'font-style: italic', 'action', action.type];
9549
- displayBuffer.action = colorFormat('action', colors.action, action);
9550
- displayBuffer.prev = colorFormat('prev history', colors.prevState, state);
9551
- } else {
9552
- displayBuffer.header = ['redux-undo action', action.type];
9553
- displayBuffer.action = ['action', action];
9554
- displayBuffer.prev = ['prev history', state];
9555
- }
9176
+ bind(fields) {
9177
+ fields.forEach(fieldElement => {
9178
+ const fieldName = fieldElement.dataset.fieldName;
9179
+ this.updateBind(fieldName, fieldElement);
9180
+ this.updateValue(fieldName, fieldElement);
9181
+ });
9556
9182
  }
9557
- }
9558
- /* istanbul ignore next: debug messaging is not tested */
9559
-
9560
-
9561
- function end(nextState) {
9562
- if (__DEBUG__) {
9563
- if (console.group) {
9564
- displayBuffer.next = colorFormat('next history', colors.nextState, nextState);
9565
- } else {
9566
- displayBuffer.next = ['next history', nextState];
9567
- }
9568
-
9569
- printBuffer();
9183
+ updateValue(fieldName, field) {
9184
+ field["value"] = this._dataUnit.getFieldValue(fieldName);
9570
9185
  }
9571
- }
9572
- /* istanbul ignore next: debug messaging is not tested */
9573
-
9574
-
9575
- function log() {
9576
- if (__DEBUG__) {
9577
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9578
- args[_key] = arguments[_key];
9186
+ updateBind(fieldName, field) {
9187
+ const oldBind = this._fields.get(fieldName);
9188
+ if (oldBind) {
9189
+ oldBind.destroy();
9579
9190
  }
9580
-
9581
- displayBuffer.msgs = displayBuffer.msgs.concat([].concat(args, ['\n']));
9582
- }
9583
- }
9584
- /* istanbul ignore next: debug messaging is not tested */
9585
-
9586
-
9587
- function set(debug) {
9588
- __DEBUG__ = debug;
9589
- }
9590
- });
9591
-
9592
- var reducer = createCommonjsModule(function (module, exports) {
9593
-
9594
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9595
-
9596
- Object.defineProperty(exports, "__esModule", {
9597
- value: true
9598
- });
9599
- exports["default"] = undoable;
9600
-
9601
- var debug$1 = _interopRequireWildcard(debug);
9602
-
9603
-
9604
-
9605
-
9606
-
9607
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
9608
-
9609
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9610
-
9611
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
9612
-
9613
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9614
-
9615
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9616
-
9617
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
9618
-
9619
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
9620
-
9621
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
9622
-
9623
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
9624
-
9625
- function createHistory(state, ignoreInitialState) {
9626
- // ignoreInitialState essentially prevents the user from undoing to the
9627
- // beginning, in the case that the undoable reducer handles initialization
9628
- // in a way that can't be redone simply
9629
- var history = (0, helpers.newHistory)([], state, []);
9630
-
9631
- if (ignoreInitialState) {
9632
- history._latestUnfiltered = null;
9191
+ this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
9633
9192
  }
9634
-
9635
- return history;
9636
- } // insert: insert `state` into history, which means adding the current state
9637
- // into `past`, setting the new `state` as `present` and erasing
9638
- // the `future`.
9639
-
9640
-
9641
- function insert(history, state, limit, group) {
9642
- var lengthWithoutFuture = history.past.length + 1;
9643
- debug$1.log('inserting', state);
9644
- debug$1.log('new free: ', limit - lengthWithoutFuture);
9645
- var past = history.past,
9646
- _latestUnfiltered = history._latestUnfiltered;
9647
- var isHistoryOverflow = limit && limit <= lengthWithoutFuture;
9648
- var pastSliced = past.slice(isHistoryOverflow ? 1 : 0);
9649
- var newPast = _latestUnfiltered != null ? [].concat(_toConsumableArray(pastSliced), [_latestUnfiltered]) : pastSliced;
9650
- return (0, helpers.newHistory)(newPast, state, [], group);
9651
- } // jumpToFuture: jump to requested index in future history
9652
-
9653
-
9654
- function jumpToFuture(history, index) {
9655
- if (index < 0 || index >= history.future.length) return history;
9656
- var past = history.past,
9657
- future = history.future,
9658
- _latestUnfiltered = history._latestUnfiltered;
9659
- var newPast = [].concat(_toConsumableArray(past), [_latestUnfiltered], _toConsumableArray(future.slice(0, index)));
9660
- var newPresent = future[index];
9661
- var newFuture = future.slice(index + 1);
9662
- return (0, helpers.newHistory)(newPast, newPresent, newFuture);
9663
- } // jumpToPast: jump to requested index in past history
9664
-
9665
-
9666
- function jumpToPast(history, index) {
9667
- if (index < 0 || index >= history.past.length) return history;
9668
- var past = history.past,
9669
- future = history.future,
9670
- _latestUnfiltered = history._latestUnfiltered;
9671
- var newPast = past.slice(0, index);
9672
- var newFuture = [].concat(_toConsumableArray(past.slice(index + 1)), [_latestUnfiltered], _toConsumableArray(future));
9673
- var newPresent = past[index];
9674
- return (0, helpers.newHistory)(newPast, newPresent, newFuture);
9675
- } // jump: jump n steps in the past or forward
9676
-
9677
-
9678
- function jump(history, n) {
9679
- if (n > 0) return jumpToFuture(history, n - 1);
9680
- if (n < 0) return jumpToPast(history, history.past.length + n);
9681
- return history;
9682
- } // helper to dynamically match in the reducer's switch-case
9683
-
9684
-
9685
- function actionTypeAmongClearHistoryType(actionType, clearHistoryType) {
9686
- return clearHistoryType.indexOf(actionType) > -1 ? actionType : !actionType;
9687
- } // redux-undo higher order reducer
9688
-
9689
-
9690
- function undoable(reducer) {
9691
- var rawConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9692
- debug$1.set(rawConfig.debug);
9693
-
9694
- var config = _objectSpread({
9695
- limit: undefined,
9696
- filter: function filter() {
9697
- return true;
9698
- },
9699
- groupBy: function groupBy() {
9700
- return null;
9701
- },
9702
- undoType: actions.ActionTypes.UNDO,
9703
- redoType: actions.ActionTypes.REDO,
9704
- jumpToPastType: actions.ActionTypes.JUMP_TO_PAST,
9705
- jumpToFutureType: actions.ActionTypes.JUMP_TO_FUTURE,
9706
- jumpType: actions.ActionTypes.JUMP,
9707
- neverSkipReducer: false,
9708
- ignoreInitialState: false,
9709
- syncFilter: false
9710
- }, rawConfig, {
9711
- initTypes: (0, helpers.parseActions)(rawConfig.initTypes, ['@@redux-undo/INIT']),
9712
- clearHistoryType: (0, helpers.parseActions)(rawConfig.clearHistoryType, [actions.ActionTypes.CLEAR_HISTORY])
9713
- }); // Allows the user to call the reducer with redux-undo specific actions
9714
-
9715
-
9716
- var skipReducer = config.neverSkipReducer ? function (res, action) {
9717
- for (var _len = arguments.length, slices = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
9718
- slices[_key - 2] = arguments[_key];
9719
- }
9720
-
9721
- return _objectSpread({}, res, {
9722
- present: reducer.apply(void 0, [res.present, action].concat(slices))
9723
- });
9724
- } : function (res) {
9725
- return res;
9726
- };
9727
- var initialState;
9728
- return function () {
9729
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
9730
- var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9731
- debug$1.start(action, state);
9732
- var history = state;
9733
-
9734
- for (var _len2 = arguments.length, slices = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
9735
- slices[_key2 - 2] = arguments[_key2];
9736
- }
9737
-
9738
- if (!initialState) {
9739
- debug$1.log('history is uninitialized');
9740
-
9741
- if (state === undefined) {
9742
- var createHistoryAction = {
9743
- type: '@@redux-undo/CREATE_HISTORY'
9744
- };
9745
- var start = reducer.apply(void 0, [state, createHistoryAction].concat(slices));
9746
- history = createHistory(start, config.ignoreInitialState);
9747
- debug$1.log('do not set initialState on probe actions');
9748
- debug$1.end(history);
9749
- return history;
9750
- } else if ((0, helpers.isHistory)(state)) {
9751
- history = initialState = config.ignoreInitialState ? state : (0, helpers.newHistory)(state.past, state.present, state.future);
9752
- debug$1.log('initialHistory initialized: initialState is a history', initialState);
9753
- } else {
9754
- history = initialState = createHistory(state, config.ignoreInitialState);
9755
- debug$1.log('initialHistory initialized: initialState is not a history', initialState);
9756
- }
9757
- }
9758
-
9759
- var res;
9760
-
9761
- switch (action.type) {
9762
- case undefined:
9763
- return history;
9764
-
9765
- case config.undoType:
9766
- res = jump(history, -1);
9767
- debug$1.log('perform undo');
9768
- debug$1.end(res);
9769
- return skipReducer.apply(void 0, [res, action].concat(slices));
9770
-
9771
- case config.redoType:
9772
- res = jump(history, 1);
9773
- debug$1.log('perform redo');
9774
- debug$1.end(res);
9775
- return skipReducer.apply(void 0, [res, action].concat(slices));
9776
-
9777
- case config.jumpToPastType:
9778
- res = jumpToPast(history, action.index);
9779
- debug$1.log("perform jumpToPast to ".concat(action.index));
9780
- debug$1.end(res);
9781
- return skipReducer.apply(void 0, [res, action].concat(slices));
9782
-
9783
- case config.jumpToFutureType:
9784
- res = jumpToFuture(history, action.index);
9785
- debug$1.log("perform jumpToFuture to ".concat(action.index));
9786
- debug$1.end(res);
9787
- return skipReducer.apply(void 0, [res, action].concat(slices));
9788
-
9789
- case config.jumpType:
9790
- res = jump(history, action.index);
9791
- debug$1.log("perform jump to ".concat(action.index));
9792
- debug$1.end(res);
9793
- return skipReducer.apply(void 0, [res, action].concat(slices));
9794
-
9795
- case actionTypeAmongClearHistoryType(action.type, config.clearHistoryType):
9796
- res = createHistory(history.present, config.ignoreInitialState);
9797
- debug$1.log('perform clearHistory');
9798
- debug$1.end(res);
9799
- return skipReducer.apply(void 0, [res, action].concat(slices));
9800
-
9801
- default:
9802
- res = reducer.apply(void 0, [history.present, action].concat(slices));
9803
-
9804
- if (config.initTypes.some(function (actionType) {
9805
- return actionType === action.type;
9806
- })) {
9807
- debug$1.log('reset history due to init action');
9808
- debug$1.end(initialState);
9809
- return initialState;
9810
- }
9811
-
9812
- if (history._latestUnfiltered === res) {
9813
- // Don't handle this action. Do not call debug.end here,
9814
- // because this action should not produce side effects to the console
9815
- return history;
9816
- }
9817
- /* eslint-disable-next-line no-case-declarations */
9818
-
9819
-
9820
- var filtered = typeof config.filter === 'function' && !config.filter(action, res, history);
9821
-
9822
- if (filtered) {
9823
- // if filtering an action, merely update the present
9824
- var filteredState = (0, helpers.newHistory)(history.past, res, history.future, history.group);
9825
-
9826
- if (!config.syncFilter) {
9827
- filteredState._latestUnfiltered = history._latestUnfiltered;
9828
- }
9829
-
9830
- debug$1.log('filter ignored action, not storing it in past');
9831
- debug$1.end(filteredState);
9832
- return filteredState;
9833
- }
9834
- /* eslint-disable-next-line no-case-declarations */
9835
-
9836
-
9837
- var group = config.groupBy(action, res, history);
9838
-
9839
- if (group != null && group === history.group) {
9840
- // if grouping with the previous action, only update the present
9841
- var groupedState = (0, helpers.newHistory)(history.past, res, history.future, history.group);
9842
- debug$1.log('groupBy grouped the action with the previous action');
9843
- debug$1.end(groupedState);
9844
- return groupedState;
9845
- } // If the action wasn't filtered or grouped, insert normally
9846
-
9847
-
9848
- history = insert(history, res, config.limit, group);
9849
- debug$1.log('inserted new state into history');
9850
- debug$1.end(history);
9851
- return history;
9193
+ setFieldValue(fieldName, newValue) {
9194
+ if (this._dataUnit.records.length === 0) {
9195
+ this._dataUnit.addRecord();
9852
9196
  }
9853
- };
9854
- }
9855
- });
9856
-
9857
- var lib = createCommonjsModule(function (module, exports) {
9858
-
9859
- Object.defineProperty(exports, "__esModule", {
9860
- value: true
9861
- });
9862
- Object.defineProperty(exports, "ActionTypes", {
9863
- enumerable: true,
9864
- get: function get() {
9865
- return actions.ActionTypes;
9866
- }
9867
- });
9868
- Object.defineProperty(exports, "ActionCreators", {
9869
- enumerable: true,
9870
- get: function get() {
9871
- return actions.ActionCreators;
9872
- }
9873
- });
9874
- Object.defineProperty(exports, "parseActions", {
9875
- enumerable: true,
9876
- get: function get() {
9877
- return helpers.parseActions;
9878
- }
9879
- });
9880
- Object.defineProperty(exports, "isHistory", {
9881
- enumerable: true,
9882
- get: function get() {
9883
- return helpers.isHistory;
9884
- }
9885
- });
9886
- Object.defineProperty(exports, "includeAction", {
9887
- enumerable: true,
9888
- get: function get() {
9889
- return helpers.includeAction;
9890
- }
9891
- });
9892
- Object.defineProperty(exports, "excludeAction", {
9893
- enumerable: true,
9894
- get: function get() {
9895
- return helpers.excludeAction;
9896
- }
9897
- });
9898
- Object.defineProperty(exports, "combineFilters", {
9899
- enumerable: true,
9900
- get: function get() {
9901
- return helpers.combineFilters;
9902
- }
9903
- });
9904
- Object.defineProperty(exports, "groupByActionTypes", {
9905
- enumerable: true,
9906
- get: function get() {
9907
- return helpers.groupByActionTypes;
9908
- }
9909
- });
9910
- Object.defineProperty(exports, "newHistory", {
9911
- enumerable: true,
9912
- get: function get() {
9913
- return helpers.newHistory;
9914
- }
9915
- });
9916
- Object.defineProperty(exports, "default", {
9917
- enumerable: true,
9918
- get: function get() {
9919
- return _reducer["default"];
9920
- }
9921
- });
9922
-
9923
-
9924
-
9925
-
9926
-
9927
- var _reducer = _interopRequireDefault(reducer);
9928
-
9929
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
9930
- });
9931
-
9932
- const undoable = /*@__PURE__*/getDefaultExportFromCjs(lib);
9933
-
9934
- const inicialHistState = {
9935
- currentTabIndex: {},
9936
- currentRecordIndex: {},
9937
- changes: {},
9938
- collapsedGroups: {},
9939
- newRecordIndex: {}
9940
- };
9941
- const inicialNonHistState = {
9942
- dataLoading: {},
9943
- invalidFields: {},
9944
- visibleButtons: {
9945
- previousVisible: true,
9946
- nextVisible: true,
9947
- addVisible: true,
9948
- removeVisible: true,
9949
- saveVisible: true,
9950
- cancelVisible: true,
9951
- reloadVisible: false
9952
- }
9953
- };
9954
- function formReducer(state = inicialHistState, action) {
9955
- switch (action.type) {
9956
- case "FORM/COLLAPSEGROUP":
9957
- return collapseGroup(state, action.payload);
9958
- case "FORM/CHANGETAB":
9959
- return changeTab(state, action.payload.formId, action.payload.index);
9960
- case "FORM/NAVIGATE":
9961
- return navigate(state, action.payload);
9962
- case "FORM/INSERT":
9963
- return insertRecord(state, action.payload);
9964
- case "FORM/CHANGEFIELD":
9965
- return changeFieldValue(state, action.payload);
9966
- case "FORM/CLEAREDITION":
9967
- return clearEdition(state, action.payload);
9968
- case "FORM/INVALIDFIELD":
9969
- return navigateToInvalid(state, action.payload);
9970
- default:
9971
- return state;
9197
+ this._dataUnit.setFieldValue(fieldName, newValue);
9972
9198
  }
9973
9199
  }
9974
- function formNonHistoricReducer(state = inicialNonHistState, action) {
9975
- switch (action.type) {
9976
- case "FORM/DATALOADING":
9977
- return dataLoading(state, action.payload);
9978
- case "FORM/DATALOADED":
9979
- return dataLoaded(state, action.payload);
9980
- case "FORM/SAVINGCHANGES":
9981
- return savingChanges(state, action.payload);
9982
- case "FORM/CHANGESSAVED":
9983
- return changesSaved(state, action.payload);
9984
- case "FORM/REMOVINGRECORD":
9985
- return removingRecord(state, action.payload);
9986
- case "FORM/RECORDREMOVED":
9987
- return recordRemoved(state, action.payload);
9988
- case "FORM/INVALIDFIELD":
9989
- return invalidField(state, action.payload);
9990
- case "FORM/CLEAREDITION":
9991
- return clearAllInvalidFields(state, action.payload);
9992
- case "FORM/CHANGEFIELD":
9993
- return clearInvalidField(state, action.payload);
9994
- case "FORM/SHOWHIDENAVBTN":
9995
- return showHideNavBtn(state, action.payload);
9996
- default:
9997
- return state;
9200
+ class Bind {
9201
+ destroy() {
9202
+ this.field.removeEventListener(this.eventName, this.eventListener);
9998
9203
  }
9999
- }
10000
- function collapseGroup(state, { collapseId, collapsed }) {
10001
- const currentCollapsed = Object.assign({}, state.collapsedGroups);
10002
- if (collapsed) {
10003
- currentCollapsed[collapseId] = true;
9204
+ static create(fieldName, field, callback) {
9205
+ const b = new Bind();
9206
+ b.fieldName = fieldName;
9207
+ b.field = field;
9208
+ //FIXME: Verificar se o field é um EzField
9209
+ b.eventListener = (evt) => { callback(fieldName, evt.detail); };
9210
+ b.eventName = "ezChange";
9211
+ b.field.addEventListener(b.eventName, b.eventListener);
9212
+ return b;
10004
9213
  }
10005
- else {
10006
- delete currentCollapsed[collapseId];
10007
- }
10008
- return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
10009
- }
10010
- function changeTab(state, formId, index) {
10011
- const currentTabIndex = Object.assign({}, state.currentTabIndex);
10012
- currentTabIndex[formId] = index;
10013
- return Object.assign(Object.assign({}, state), { currentTabIndex });
10014
- }
10015
- function navigate(state, { dataUnit, limit, backward }) {
10016
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
10017
- const recIndex = currentRecordIndex[dataUnit] || 0;
10018
- return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
10019
- }
10020
- function gotoIndex(state, dataUnit, index) {
10021
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
10022
- currentRecordIndex[dataUnit] = index;
10023
- return Object.assign(Object.assign({}, state), { currentRecordIndex });
10024
- }
10025
- function insertRecord(state, { dataUnit, insertionIndex }) {
10026
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
10027
- const newRecordIndex = Object.assign({}, state.newRecordIndex);
10028
- currentRecordIndex[dataUnit] = insertionIndex;
10029
- newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
10030
- return Object.assign(Object.assign({}, state), { currentRecordIndex,
10031
- newRecordIndex });
10032
- }
10033
- function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
10034
- const changes = Object.assign({}, state.changes);
10035
- const dataUnitChanges = Object.assign({}, changes[dataUnit]);
10036
- const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
10037
- recordChanges[fieldName] = value;
10038
- dataUnitChanges[recordId] = recordChanges;
10039
- changes[dataUnit] = dataUnitChanges;
10040
- const invalidFields = Object.assign({}, state.invalidFields);
10041
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
10042
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
10043
- delete errorMessages[fieldName];
10044
- dataUnitInvalidRecords[recordId] = errorMessages;
10045
- invalidFields[dataUnit] = dataUnitInvalidRecords;
10046
- return Object.assign(Object.assign({}, state), { changes,
10047
- invalidFields, invalidFieldSelected: undefined });
10048
- }
10049
- function clearEdition(state, { dataUnit, recordsLimit }) {
10050
- const changes = Object.assign({}, state.changes);
10051
- const newRecordIndex = Object.assign({}, state.newRecordIndex);
10052
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
10053
- delete changes[dataUnit];
10054
- delete newRecordIndex[dataUnit];
10055
- const recIndex = currentRecordIndex[dataUnit] || 0;
10056
- currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
10057
- return Object.assign(Object.assign({}, state), { changes,
10058
- newRecordIndex,
10059
- currentRecordIndex });
10060
- }
10061
- function navigateToInvalid(state, payload) {
10062
- let newState = Object.assign({}, state);
10063
- if (newState.invalidFieldSelected === undefined) {
10064
- newState.invalidFieldSelected = true;
10065
- newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
10066
- newState = changeTab(newState, payload.tabController, payload.tabIndex);
10067
- }
10068
- return newState;
10069
- }
10070
- function dataLoading(state, { dataUnit }) {
10071
- const dataLoading = Object.assign({}, state.dataLoading);
10072
- dataLoading[dataUnit] = true;
10073
- return Object.assign(Object.assign({}, state), { dataLoading });
10074
- }
10075
- function dataLoaded(state, { dataUnit }) {
10076
- const dataLoading = Object.assign({}, state.dataLoading);
10077
- delete dataLoading[dataUnit];
10078
- return Object.assign(Object.assign({}, state), { dataLoading });
10079
- }
10080
- function savingChanges(state, { dataUnit }) {
10081
- const dataLoading = Object.assign({}, state.dataLoading);
10082
- dataLoading[dataUnit] = true;
10083
- return Object.assign(Object.assign({}, state), { dataLoading });
10084
- }
10085
- function changesSaved(state, { dataUnit }) {
10086
- const dataLoading = Object.assign({}, state.dataLoading);
10087
- delete dataLoading[dataUnit];
10088
- return Object.assign(Object.assign({}, state), { dataLoading });
10089
- }
10090
- function removingRecord(state, { dataUnit }) {
10091
- const dataLoading = Object.assign({}, state.dataLoading);
10092
- dataLoading[dataUnit] = true;
10093
- return Object.assign(Object.assign({}, state), { dataLoading });
10094
- }
10095
- function recordRemoved(state, { dataUnit }) {
10096
- const dataLoading = Object.assign({}, state.dataLoading);
10097
- delete dataLoading[dataUnit];
10098
- return Object.assign(Object.assign({}, state), { dataLoading });
10099
- }
10100
- function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
10101
- const invalidFields = Object.assign({}, state.invalidFields);
10102
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
10103
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
10104
- errorMessages[fieldName] = errorMessage;
10105
- dataUnitInvalidRecords[recordId] = errorMessages;
10106
- invalidFields[dataUnit] = dataUnitInvalidRecords;
10107
- return Object.assign(Object.assign({}, state), { invalidFields });
10108
- }
10109
- function clearAllInvalidFields(state, { dataUnit }) {
10110
- const invalidFields = Object.assign({}, state.invalidFields);
10111
- delete invalidFields[dataUnit];
10112
- return Object.assign(Object.assign({}, state), { invalidFields });
10113
- }
10114
- function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
10115
- const invalidFields = Object.assign({}, state.invalidFields);
10116
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
10117
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
10118
- delete errorMessages[fieldName];
10119
- dataUnitInvalidRecords[recordId] = errorMessages;
10120
- invalidFields[dataUnit] = dataUnitInvalidRecords;
10121
- return Object.assign(Object.assign({}, state), { invalidFields });
10122
- }
10123
- function showHideNavBtn(state, { buttonName, status }) {
10124
- const visibleButtons = Object.assign({}, state.visibleButtons);
10125
- visibleButtons[buttonName] = status;
10126
- return Object.assign(Object.assign({}, state), { visibleButtons });
10127
9214
  }
10128
9215
 
10129
9216
  class ApplicationUtils {
@@ -10158,775 +9245,100 @@ class ApplicationUtils {
10158
9245
  }
10159
9246
  }
10160
9247
 
10161
- function removeHandler(dataUnit) {
10162
- ApplicationUtils.confirm("Exclusão de registro", "Tem certeza que deseja Remover?", null, true).then(ok => {
10163
- if (ok) {
10164
- dataUnit.remove();
10165
- }
10166
- });
10167
- }
10168
- function saveHandler(dataUnit) {
10169
- setTimeout(() => {
10170
- //Esse debouncing é necessário quando o usuário clica no botão de salvar
10171
- //sem ter tirado o foco o último campo alterado.
10172
- dataUnit.save();
10173
- }, 50);
10174
- }
10175
- const NavigationBar = ({ dataUnit: du, buttonProps, enabled }) => {
10176
- if (buttonProps.previousVisible
10177
- || buttonProps.nextVisible
10178
- || buttonProps.addVisible
10179
- || buttonProps.removeVisible
10180
- || buttonProps.saveVisible
10181
- || buttonProps.cancelVisible
10182
- || buttonProps.reloadVisible) {
10183
- return h("div", { class: "col col--sd-12 align--right" },
10184
- buttonProps.previousVisible ? h("ez-button", { key: du.name + "_previous", title: "Registro anterior", mode: "icon", enabled: enabled && du.hasPrevious(), onClick: () => du.previous(), image: "/themes/default/images/icons/actions-sprite.svg#previous-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
10185
- buttonProps.nextVisible ? h("ez-button", { key: du.name + "_next", title: "Pr\u00F3ximo registro", mode: "icon", enabled: enabled && du.hasNext(), onClick: () => du.next(), image: "/themes/default/images/icons/actions-sprite.svg#next-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
10186
- buttonProps.removeVisible ? h("ez-button", { key: du.name + "_remove", label: "Remover", enabled: enabled && du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
10187
- buttonProps.addVisible ? h("ez-button", { key: du.name + "_add", label: "Adicionar", enabled: enabled, onClick: () => du.insert(), class: "button--secondary margin-right--medium" }) : null,
10188
- buttonProps.reloadVisible ? h("ez-button", { key: du.name + "_reload", title: "Recarregar", enabled: enabled, mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }) : null,
10189
- buttonProps.cancelVisible ? h("ez-button", { key: du.name + "_cancel", label: "Cancelar", enabled: enabled && du.hasChanges(), onClick: () => du.cancel(), class: "button--secondary margin-right--medium" }) : null,
10190
- buttonProps.saveVisible ? h("ez-button", { key: du.name + "_save", label: "Salvar", enabled: enabled && du.hasChanges(), onClick: () => saveHandler(du), class: "button--primary margin-right--medium" }) : null);
10191
- }
10192
- else {
10193
- return null;
10194
- }
10195
- };
10196
-
10197
- //histórico
10198
- const selectCurrentTab = (state, formName) => {
10199
- const data = state.hist.present.currentTabIndex;
10200
- return data[formName] || 0;
10201
- };
10202
- const selectIsCollapsedFieldSet = (state, fieldSetName) => {
10203
- const data = state.hist.present.collapsedGroups;
10204
- return data[fieldSetName];
10205
- };
10206
- const selectRecordChanges = (state, dataUnit, recordId) => {
10207
- const data = selectDataUnitChanges(state, dataUnit);
10208
- return data ? data[recordId] : undefined;
10209
- };
10210
- const selectDataUnitChanges = (state, dataUnit) => {
10211
- const data = state.hist.present.changes;
10212
- return data[dataUnit];
10213
- };
10214
- const selectCurrentRecordIndex = (state, dataUnit) => {
10215
- const data = state.hist.present.currentRecordIndex;
10216
- return data[dataUnit] || 0;
10217
- };
10218
- const selectNewRecordIndex = (state, dataUnit) => {
10219
- const data = state.hist.present.newRecordIndex;
10220
- return data[dataUnit] || 0;
10221
- };
10222
- //não histórico
10223
- const selectLoadingData = (state, dataUnit) => {
10224
- const data = state.nonhist.dataLoading;
10225
- return data[dataUnit];
10226
- };
10227
- const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
10228
- const data = state.nonhist.invalidFields;
10229
- const dataUnitMessages = data[dataUnit] || {};
10230
- const recordMessages = dataUnitMessages[recordId] || {};
10231
- return recordMessages[fieldName] || "";
10232
- };
10233
- const selectVisibleButtons = state => state.nonhist.visibleButtons;
9248
+ const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}";
10234
9249
 
10235
- class DataUnit {
10236
- constructor(name, unitLabel, cardinality = "1", parentDU = null) {
10237
- this.name = name;
10238
- this.unitLabel = unitLabel;
10239
- this.cardinality = cardinality;
10240
- this._children = [];
10241
- this._fields = new Map();
10242
- this._requiredFields = [];
10243
- if (parentDU != null) {
10244
- parentDU._children.push(this);
10245
- this.parentDU = parentDU;
10246
- this.parentDUName = parentDU.name;
10247
- }
10248
- }
10249
- set store(store) {
10250
- this._store = store;
10251
- }
10252
- set fields(value) {
10253
- if (value) {
10254
- value.forEach(f => this.addFieldMetadata(f));
10255
- }
10256
- }
10257
- addFieldMetadata(field) {
10258
- this._fields.set(field.name, field);
10259
- if (field.required) {
10260
- this._requiredFields.push(field);
10261
- }
10262
- }
10263
- getFieldMetadata(name) {
10264
- if (this._fields) {
10265
- return this._fields.get(name);
10266
- }
10267
- return undefined;
10268
- }
10269
- get requiredFields() {
10270
- return this._requiredFields;
10271
- }
10272
- isLoading() {
10273
- return selectLoadingData(this._store.getState(), this.name);
10274
- }
10275
- hasChanges() {
10276
- const state = this._store.getState();
10277
- return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
10278
- }
10279
- hasNext() {
10280
- return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
10281
- }
10282
- hasPrevious() {
10283
- return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
10284
- }
10285
- hasCurrentRecord() {
10286
- return this.getCurrentRecord() != undefined;
10287
- }
10288
- previous() {
10289
- this._store.dispatch(previousRecord(this.name));
10290
- }
10291
- next() {
10292
- this._store.dispatch(nextRecord(this.name, this.records.length));
10293
- }
10294
- getValue(fieldName) {
10295
- const currentRecord = this.getCurrentRecord();
10296
- if (!currentRecord) {
10297
- return undefined;
10298
- }
10299
- const changes = this.getRecordChanges(currentRecord);
10300
- return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
10301
- }
10302
- getErrorMessage(fieldName) {
10303
- const currentRecord = this.getCurrentRecord();
10304
- return selectErrorMessage(this._store.getState(), this.name, currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.record__id, fieldName);
9250
+ let EzForm$1 = class extends HTMLElement$1 {
9251
+ constructor() {
9252
+ super();
9253
+ this.__registerHost();
10305
9254
  }
10306
- changeValue(fieldName, newValue) {
10307
- if (this.records.length == 0) {
10308
- this.insert();
10309
- }
10310
- if (this._changeDeboucing) {
10311
- window.clearTimeout(this._changeDeboucing);
10312
- }
10313
- this._changeDeboucing = window.setTimeout(() => {
10314
- const currentRecord = this.getCurrentRecord();
10315
- this._store.dispatch(changeFieldValue$1(this.name, currentRecord.record__id, fieldName, newValue));
10316
- }, 100);
9255
+ submit() {
9256
+ return Promise.resolve();
10317
9257
  }
10318
9258
  cancel() {
10319
- this.records = this.records.filter(r => !r.record__id.startsWith("NEW_"));
10320
- this._store.dispatch(clearEdition$1(this.name, this.records.length - 1));
10321
- }
10322
- insert() {
10323
- const insertionIndex = this.records.length;
10324
- const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
10325
- const newRecord = { record__id: "NEW_" + (newRecordIndex + 1) };
10326
- this.bindToParent(newRecord);
10327
- this.records.push(newRecord);
10328
- this._store.dispatch(insertRecord$1(this.name, insertionIndex));
10329
- }
10330
- buildChange(r) {
10331
- const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
10332
- let recordChanges;
10333
- if (duChanges) {
10334
- recordChanges = duChanges[r.record__id];
10335
- }
10336
- let subChanges = [];
10337
- this._children.forEach(duChild => {
10338
- subChanges = subChanges.concat(duChild.getSubChanges(r.record__id));
10339
- });
10340
- if (recordChanges || subChanges.length > 0) {
10341
- const change = {
10342
- "__data__unit": this.name,
10343
- "__record__id": r.record__id,
10344
- "__sub__changes": subChanges
10345
- };
10346
- if (recordChanges) {
10347
- Object.keys(recordChanges).forEach(fieldName => { });
10348
- }
10349
- return change;
10350
- }
10351
- return undefined;
10352
- }
10353
- getSubChanges(id) {
10354
- const result = [];
10355
- if (this._records) {
10356
- this._records.filter(r => r.parent__record__id === id).forEach(r => {
10357
- const c = this.buildChange(r);
10358
- if (c) {
10359
- result.push(c);
10360
- }
10361
- });
10362
- }
10363
- return result;
10364
- }
10365
- getChangesToSave() {
10366
- let result = [];
10367
- if (this._records) {
10368
- this._records.forEach(r => {
10369
- const change = this.buildChange(r);
10370
- if (change) {
10371
- result.push(change);
10372
- }
10373
- });
10374
- }
10375
- return result;
10376
- }
10377
- save() {
10378
- if (!this.validateRecords("SAVE")) {
10379
- return;
10380
- }
10381
- this._store.dispatch(savingChanges$1(this.name));
10382
- let saveResult;
10383
- if (this.saveExecutor) {
10384
- saveResult = this.saveExecutor(this.getChangesToSave());
10385
- }
10386
- if (saveResult instanceof Promise) {
10387
- saveResult
10388
- .then(r => this.processSaveResult(r))
10389
- .catch(e => {
10390
- this._store.dispatch(dataLoaded$1(this.name));
10391
- ApplicationUtils.error("Falha ao tentar salvar", e);
10392
- });
10393
- }
10394
- else {
10395
- this.processSaveResult(saveResult);
10396
- }
10397
- }
10398
- load() {
10399
- this._store.dispatch(dataLoading$1(this.name));
10400
- let result;
10401
- if (this.loadExecutor) {
10402
- result = this.loadExecutor({ dataUnit: this.name });
10403
- }
10404
- if (result instanceof Promise) {
10405
- result.then(r => this.processLoadResult(r));
10406
- }
10407
- else {
10408
- this.processLoadResult(result);
10409
- }
10410
- }
10411
- remove() {
10412
- const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
10413
- this._store.dispatch(removingRecord$1(this.name));
10414
- let removeResult;
10415
- if (this.removeExecutor) {
10416
- const record = this.getCurrentRecord();
10417
- removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
10418
- }
10419
- else {
10420
- removeResult = true;
10421
- }
10422
- if (removeResult) {
10423
- if (removeResult instanceof Promise) {
10424
- removeResult.then(r => this.processRemoveResult(r, currentIndex));
10425
- }
10426
- else {
10427
- this.processRemoveResult(removeResult, currentIndex);
10428
- }
10429
- }
10430
- }
10431
- processSaveResult(result) {
10432
- if (result) {
10433
- if (result instanceof Array) {
10434
- result.forEach(item => this.processSaveResult(item));
10435
- }
10436
- else {
10437
- if (result.__data__unit === this.name) {
10438
- if (this.cardinality === "1") {
10439
- this.records = [this.buildRecordFromSaveResult(this.records[0], result)];
10440
- }
9259
+ return Promise.resolve();
9260
+ }
9261
+ validate() {
9262
+ return new Promise((accept, reject) => {
9263
+ const metadata = selectFormMetadata(this._store.getState());
9264
+ const requiredFields = this._staticFields
9265
+ .filter(f => f.dataset.required)
9266
+ .map(f => f.dataset.fieldName)
9267
+ .concat(metadata.getRequiredFields());
9268
+ const records = this.dataUnit.records;
9269
+ for (let i = 0; i < records.length; i++) {
9270
+ if (!this.validateRequired(requiredFields, records[i])) {
9271
+ reject();
9272
+ break;
10441
9273
  }
10442
9274
  }
10443
- }
10444
- //FIXME: Isso está errado! tem que limpar todas as edições
10445
- this._store.dispatch(clearEdition$1(this.name, this.records.length - 1));
10446
- this._store.dispatch(changesSaved$1(this.name));
10447
- }
10448
- buildRecordFromSaveResult(baseRecord, saveResult) {
10449
- const newRecord = baseRecord ? Object.assign({}, baseRecord) : { record__id: "" };
10450
- Object.keys(saveResult).forEach(attrib => {
10451
- if (!attrib.startsWith("__")) {
10452
- newRecord[attrib] = saveResult[attrib];
10453
- }
9275
+ accept();
10454
9276
  });
10455
- return newRecord;
10456
9277
  }
10457
- processLoadResult(records) {
10458
- this.records = records;
10459
- this._store.dispatch(clearEdition$1(this.name, this.records.length - 1));
10460
- this._store.dispatch(dataLoaded$1(this.name));
10461
- }
10462
- processRemoveResult(removed, recordIndex) {
10463
- if (removed) {
10464
- this.records.splice(recordIndex, 1);
10465
- this._store.dispatch(clearEdition$1(this.name, this.records.length - 1));
10466
- }
10467
- this._store.dispatch(recordRemoved$1(this.name));
10468
- }
10469
- set records(records) {
10470
- this._records = records;
10471
- if (this.parentDU) {
10472
- this._records.forEach(r => this.bindToParent(r));
10473
- }
10474
- }
10475
- bindToParent(r) {
10476
- if (this.parentDU) {
10477
- const parentRecord = this.parentDU.getCurrentRecord();
10478
- if (parentRecord) {
10479
- r.parent__record__id = parentRecord.record__id;
9278
+ validateRequired(requiredFields, record) {
9279
+ const invalidFields = [];
9280
+ requiredFields.forEach(field => {
9281
+ const value = record[field];
9282
+ const fieldElem = this._element.querySelector(`[data-field-name=${field}]`);
9283
+ if (value === null || value === undefined || value === "") {
9284
+ invalidFields.push(field);
9285
+ fieldElem["errorMessage"] = "Essa informação é obrigatória";
10480
9286
  }
10481
- }
10482
- }
10483
- get records() {
10484
- if (!this._records) {
10485
- this._records = [];
10486
- }
10487
- return this._records;
10488
- }
10489
- getCurrentRecord() {
10490
- const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
10491
- return this.records[currentIndex];
10492
- }
10493
- getRecordChanges(currentRecord = undefined) {
10494
- if (currentRecord === undefined) {
10495
- currentRecord = this.getCurrentRecord();
10496
- }
10497
- return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
10498
- }
10499
- validateRecords(triggedBy = "UNKNOWN") {
10500
- if (!this.recordsValidator) {
10501
- return true;
10502
- }
10503
- const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
10504
- const recordsToValidate = [];
10505
- this.records.forEach((record, i) => {
10506
- const changes = duChanges ? duChanges[record.record__id] : undefined;
10507
- if (changes) {
10508
- recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
9287
+ else {
9288
+ fieldElem["errorMessage"] = "";
10509
9289
  }
10510
9290
  });
10511
- const result = this.recordsValidator.validateRecords(this, recordsToValidate, triggedBy);
10512
- if (result.message) {
10513
- ApplicationUtils.info(result.message);
10514
- }
10515
- return result.isValid;
10516
- }
10517
- }
10518
- var DependencyType;
10519
- (function (DependencyType) {
10520
- DependencyType["SEARCHING"] = "SEARCHING";
10521
- DependencyType["REQUIREMENT"] = "REQUIREMENT";
10522
- DependencyType["VISIBILITY"] = "REQUIREMENT";
10523
- })(DependencyType || (DependencyType = {}));
10524
-
10525
- function scrollToView(forceScroll, elem) {
10526
- if (forceScroll) {
10527
- window.requestAnimationFrame(() => elem.scrollIntoView());
10528
- }
10529
- }
10530
- const Field = ({ dataUnit, field, forceScroll, enabled }) => {
10531
- const { name, form } = field;
10532
- const { label, userInterface, properties, required, dependencies, readOnly } = dataUnit.getFieldMetadata(name);
10533
- const value = dataUnit.getValue(name) || null;
10534
- const loadingData = dataUnit.isLoading();
10535
- const formattedLabel = required ? `* ${label} (obrigatório)` : label;
10536
- const errorMessage = dataUnit.getErrorMessage(name);
10537
- const key = `${dataUnit.name}-${name}`;
10538
- const isEnabled = enabled && !readOnly;
10539
- const changeFieldHandler = (newValue) => {
10540
- dataUnit.changeValue(name, newValue);
10541
- };
10542
- switch (userInterface) {
10543
- case "LONGTEXT":
10544
- return h("div", { class: "col col--sd-12 padding--small" }, loadingData ? h("place-holder", null) :
10545
- h("ez-text-area", { value: value || "", label: formattedLabel, onEzChange: evt => changeFieldHandler(evt.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key, enabled: isEnabled }));
10546
- case "CHECKBOX":
10547
- case "SWITCH":
10548
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small align--middle padding-bottom--large" }, loadingData ? h("place-holder", null) :
10549
- h("ez-check", { value: value, label: label, enabled: isEnabled, mode: userInterface === "CHECKBOX" ? "regular" : "switch", onEzChange: (event) => changeFieldHandler(event.target["value"]), ref: elem => scrollToView(forceScroll, elem), key: key }));
10550
- case "OPTIONSELECTOR":
10551
- const optsObj = properties ? JSON.parse(getProp(properties, "options")) : {};
10552
- const normalized = Object.keys(optsObj).map(key => { return { value: key, label: optsObj[key] }; });
10553
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
10554
- h("ez-combo-box", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key, options: normalized }));
10555
- case "SEARCH":
10556
- const context = {
10557
- __MAIN_FORM: form,
10558
- __DATA_UNIT: dataUnit.name,
10559
- __FIELD_NAME: name
10560
- };
10561
- properties.forEach(({ name, value }) => {
10562
- context[name] = value;
10563
- });
10564
- let criteriaList = [];
10565
- dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
10566
- var _a;
10567
- if (dependency.type === DependencyType.SEARCHING) {
10568
- if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
10569
- let criteria = {
10570
- expression: dependency.expression,
10571
- paramNames: [...dependency.masterFields],
10572
- paramResolver: name => dataUnit.getValue(name)
10573
- };
10574
- criteriaList.push(criteria);
10575
- }
10576
- }
10577
- });
10578
- if (criteriaList.length > 0) {
10579
- context["CRITERIA"] = criteriaList;
10580
- }
10581
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
10582
- h("ez-search", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, optionLoader: (argument) => {
10583
- if (form) {
10584
- return form.loadSearch(argument, context);
10585
- }
10586
- }, ref: elem => scrollToView(forceScroll, elem), key: key }));
10587
- case "FILE":
10588
- const target = getProp(properties, "URL");
10589
- const strHeaders = getProp(properties, "HEADERS");
10590
- const headers = strHeaders ? JSON.parse(strHeaders) : {};
10591
- const maxfiles = Number(getProp(properties, "maxfiles") || 0);
10592
- return (h("div", { class: "col col--sd-12 padding--small" }, loadingData ? h("place-holder", null) :
10593
- h("ez-upload", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.detail), urlUpload: target, requestHeaders: headers, maxFiles: maxfiles })));
10594
- case "DATE":
10595
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
10596
- h("ez-date-input", { value: !value ? null : DateUtils.clearTime(value), label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
10597
- case "DECIMALNUMBER":
10598
- case "INTEGERNUMBER":
10599
- let precision = 0;
10600
- let prettyPrecision = 0;
10601
- if (userInterface === "DECIMALNUMBER") {
10602
- precision = Number(getProp(properties, "precision") || 2);
10603
- prettyPrecision = Number(getProp(properties, "prettyprecision") || precision);
10604
- }
10605
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
10606
- h("ez-numeric-input", { value: !value ? null : value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, precision: precision, prettyprecision: prettyPrecision, ref: elem => scrollToView(forceScroll, elem), key: key }));
10607
- //IMAGE, DATETIME, ELAPSEDTIME, PASSWORD, MASKEDTEXT, HTML
10608
- default:
10609
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
10610
- h("ez-text-input", { value: value, label: formattedLabel, enabled: isEnabled, loading: loadingData, onInput: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
10611
- }
10612
- };
10613
- function getProp(properties, name) {
10614
- var _a;
10615
- return properties ? (_a = properties.find(prop => prop.name === name)) === null || _a === void 0 ? void 0 : _a.value : null;
10616
- }
10617
-
10618
- const FieldSet = ({ store, formName, source, dataUnit, enabled }) => {
10619
- const { label, fields } = source;
10620
- const fieldSetName = formName + label;
10621
- let isCollapsed = selectIsCollapsedFieldSet(store.getState(), formName + label);
10622
- let fieldToScroll;
10623
- source.fields.forEach((field) => {
10624
- if (fieldToScroll === undefined) {
10625
- const fieldError = dataUnit.getErrorMessage(field.name);
10626
- if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
10627
- fieldToScroll = field.name;
10628
- }
10629
- }
10630
- });
10631
- if (fieldToScroll) {
10632
- isCollapsed = false;
10633
- }
10634
- return h("div", { class: "col col--sd-12 padding--small" },
10635
- h("div", { class: "row margin-top--large" },
10636
- h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
10637
- h("ez-collapsible-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(collapseExpandGroup(fieldSetName, !isCollapsed)) }),
10638
- isCollapsed ? null :
10639
- h("div", { class: "col col--sd-12" }, fields.map(field => h(Field, { enabled: enabled, field: field, dataUnit: dataUnit, forceScroll: fieldToScroll === field.name }))))));
10640
- };
10641
-
10642
- function buildFormItem(source, formName, store, dataUnit, enabled) {
10643
- if ("fields" in source) {
10644
- return h(FieldSet, { enabled: enabled, source: source, store: store, formName: formName, dataUnit: dataUnit });
10645
- }
10646
- const fieldName = source.name;
10647
- const errorMsg = dataUnit.getErrorMessage(fieldName);
10648
- const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
10649
- return h(Field, { enabled: enabled, field: source, dataUnit: dataUnit, forceScroll: forceScroll });
10650
- }
10651
- const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder, enabled }) => {
10652
- const selectedTab = selectCurrentTab(store.getState(), parentName);
10653
- const tabs = source.length > 1 ? source.map(form => h("ez-tab", { label: form.label, tabKey: form.name })) : null;
10654
- const { subForms, items, name } = source[selectedTab];
10655
- const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit, parentDataUnit);
10656
- source[selectedTab].dataUnit = dataUnit;
10657
- const hasSubForms = subForms && subForms.length > 0;
10658
- const changeTabHandler = (index) => {
10659
- store.dispatch(changeTab$1(parentName, index));
10660
- };
10661
- //todos os campos e subformulários precisam estar ligados a um DU
10662
- const currentDU = dataUnit || parentDataUnit;
10663
- let buttons = selectVisibleButtons(store.getState());
10664
- if (currentDU.cardinality === "1") {
10665
- buttons.addVisible = false;
10666
- buttons.removeVisible = false;
10667
- buttons.nextVisible = false;
10668
- buttons.previousVisible = false;
10669
- }
10670
- return h("div", { class: "form-sheet" },
10671
- tabs ? h("ez-tabselector", { selectedIndex: selectedTab, selectedTab: name, onEzChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
10672
- dataUnit ? h(NavigationBar, { enabled: enabled, dataUnit: dataUnit, buttonProps: buttons }) : null,
10673
- h("div", { class: "tab__container" },
10674
- items ? items.map(item => buildFormItem(item, name, store, currentDU, enabled)) : null,
10675
- hasSubForms ? h(FormSheet, { enabled: enabled, store: store, source: subForms, parentName: name, parentDataUnit: currentDU, dataUnitBuilder: dataUnitBuilder }) : null));
10676
- };
10677
-
10678
- const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}.form-sheet{display:flex;width:100%;flex-wrap:wrap;position:relative}.tab__container{display:flex;width:100%;flex-wrap:wrap;position:relative}";
10679
-
10680
- let EzForm$1 = class extends HTMLElement$1 {
10681
- constructor() {
10682
- super();
10683
- this.__registerHost();
10684
- this.enabled = true;
10685
- this.loading = false;
10686
- this._dataUnits = new Map();
10687
- this._duSources = new Map();
10688
- this._tabPositionByField = new Map();
10689
- this._duToLoad = [];
10690
- }
10691
- cleanPreparedMetadata() {
10692
- this._preparedMetadata = undefined;
10693
- }
10694
- async validate() {
10695
- const duSourcesNames = Array.from(this._duSources.keys());
10696
- for (let i = 0; i < this._duSources.size; i++) {
10697
- const duName = duSourcesNames[i];
10698
- let du = this._dataUnits.get(duName);
10699
- if (du === undefined) {
10700
- const source = this._duSources.get(duName);
10701
- du = this.buildDataUnit(source, source.parentDUName);
10702
- }
10703
- if (!du.validateRecords()) {
10704
- return false;
10705
- }
10706
- }
10707
- return true;
10708
- }
10709
- async getChanges() {
10710
- let allChanges = [];
10711
- const dataUnits = Array.from(this._dataUnits.values());
10712
- for (let i = 0; i < this._dataUnits.size; i++) {
10713
- const du = dataUnits[i];
10714
- //Só devemos buscar as alterações de DU raiz, pois os sub DUs serão enviados junto.
10715
- if (!du.parentDU) {
10716
- const duChanges = du.getChangesToSave();
10717
- if (duChanges) {
10718
- allChanges = allChanges.concat(duChanges);
10719
- }
10720
- }
10721
- }
10722
- return allChanges;
10723
- }
10724
- async changeFieldValue(dataUnit, fieldName, value) {
10725
- const du = this._dataUnits.get(dataUnit);
10726
- if (du) {
10727
- du.changeValue(fieldName, value);
9291
+ const isValid = invalidFields.length === 0;
9292
+ if (!isValid) {
9293
+ ApplicationUtils.info("Há pelo menos um campo obrigatório não preenchido.");
10728
9294
  }
9295
+ return isValid;
10729
9296
  }
10730
- validateRecords(dataUnit, records, triggedBy) {
10731
- const result = { isValid: true, message: "" };
10732
- if (this.ignoreSaveValidation && triggedBy === "SAVE") {
10733
- return result;
10734
- }
10735
- const validateField = (field) => {
10736
- if (field.readOnly) {
10737
- return false;
10738
- }
10739
- if (field.userInterface === "SWITCH" || field.userInterface === "CHECKBOX") {
10740
- return false;
10741
- }
10742
- return true;
10743
- };
10744
- const recordValidator = record => {
10745
- dataUnit.requiredFields.forEach(field => {
10746
- if (validateField(field)) {
10747
- const recordIndex = record["record__index"];
10748
- const fieldName = field.name;
10749
- const fieldValue = record[fieldName];
10750
- if (fieldValue === null || fieldValue === undefined || fieldValue === "") {
10751
- const tabPosition = this._tabPositionByField.get(dataUnit.name + field.name);
10752
- this._store.dispatch(invalidField$1(tabPosition.tabName, tabPosition.index, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
10753
- result.isValid = false;
10754
- result.message = "Há pelo menos um campo obrigatório não preenchido.";
10755
- }
10756
- }
10757
- });
10758
- };
10759
- if (dataUnit.records.length === 0) {
10760
- recordValidator({});
9297
+ getDynamicContent() {
9298
+ var _a;
9299
+ const formMD = selectFormMetadata(this._store.getState());
9300
+ if (!formMD)
9301
+ return null;
9302
+ const currentSheet = selectCurrentSheet((_a = this._store) === null || _a === void 0 ? void 0 : _a.getState());
9303
+ if (!currentSheet) {
9304
+ return null;
10761
9305
  }
10762
- else {
10763
- let validatedRecords = {};
10764
- records.forEach(r => {
10765
- recordValidator(r);
10766
- validatedRecords[r.record__id] = true;
10767
- });
10768
- dataUnit.records.forEach(r => {
10769
- if (!validatedRecords[r.record__id]) {
10770
- recordValidator(r);
10771
- }
10772
- });
9306
+ const allSheets = Array.from(formMD.getAllSheets().values());
9307
+ const result = [];
9308
+ if (allSheets.length > 1) {
9309
+ result.push(h("ez-tabselector", { onEzChange: (evt) => this._store.dispatch(changeTab(evt.detail)), selectedTab: currentSheet.name }, allSheets.map(s => h("ez-tab", { tabKey: s.name, label: s.label }))));
10773
9310
  }
9311
+ result.push(h(FormSheet, { store: this._store, source: currentSheet }));
10774
9312
  return result;
10775
9313
  }
10776
- loadMDFromExecutor(callBack) {
10777
- const loadMetadataFunction = this.parseExecutor(this.metadataExecutor);
10778
- if (loadMetadataFunction) {
10779
- const result = loadMetadataFunction();
10780
- if (result) {
10781
- if (result instanceof Promise) {
10782
- result.then(md => {
10783
- callBack(md);
10784
- });
10785
- }
10786
- else {
10787
- callBack(result);
10788
- }
10789
- }
10790
- }
10791
- }
10792
- loadMDFromElement(callBack) {
10793
- const metadata = [];
10794
- Array.from(this._host.children).forEach(elem => {
10795
- if (elem.tagName === "FORM-METADATA") {
10796
- const formMetadata = elem;
10797
- metadata.push(formMetadata.metadata);
10798
- }
10799
- });
10800
- callBack(metadata.length > 0 ? metadata : null);
10801
- }
10802
- updateMetadata(metadata) {
10803
- if (metadata) {
10804
- const processFields = (duName, form, tabController, tabIndex) => {
10805
- var _a;
10806
- form.items.forEach(item => {
10807
- if ("fields" in item) {
10808
- const fSet = item;
10809
- fSet.fields.forEach(f => {
10810
- f.form = this;
10811
- this._tabPositionByField.set(duName + f.name, { tabName: tabController, index: tabIndex });
10812
- });
10813
- }
10814
- else {
10815
- const f = item;
10816
- f.form = this;
10817
- this._tabPositionByField.set(duName + f.name, { tabName: tabController, index: tabIndex });
10818
- }
10819
- });
10820
- (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
10821
- const subDu = subForm.dataUnit;
10822
- if (subDu) {
10823
- this._duSources.set(subDu.name, subDu);
10824
- subDu.parentDUName = duName;
10825
- }
10826
- processFields(subDu ? subDu.name : duName, subForm, form.name, index);
10827
- });
10828
- };
10829
- this._preparedMetadata = metadata.map((form, index) => {
10830
- const du = form.dataUnit;
10831
- if (form.autoLoad) {
10832
- this._duToLoad.push(du);
10833
- }
10834
- this.decorateDU(du);
10835
- const duName = du.name;
10836
- this._duSources.set(duName, du);
10837
- processFields(duName, form, "__MAIN__FORM__", index);
10838
- return form;
10839
- });
10840
- this._store.dispatch(formLoad());
9314
+ processMetadata() {
9315
+ if (!this._staticFields || this._staticFields.length === 0) {
9316
+ const metadata = this.config && this.config.length > 0 ? buildFromConfig(this.config, this.dataUnit) : buildFromDataUnit(this.dataUnit);
9317
+ this._store.dispatch(loadMetadata(metadata));
10841
9318
  }
10842
9319
  }
10843
- parseExecutor(executor) {
10844
- if (executor) {
10845
- return executor instanceof Function ? executor : eval(executor);
10846
- }
10847
- return null;
10848
- }
10849
- componentWillRender() {
10850
- if (this._store === undefined) {
10851
- const rootReducer = combineReducers({
10852
- "hist": undoable(formReducer),
10853
- "nonhist": formNonHistoricReducer
10854
- });
10855
- this._store = createStore(rootReducer, applyMiddleware(thunk));
10856
- this._store.subscribe(() => { forceUpdate(this); });
10857
- if (this.slaveMode) {
10858
- this._store.dispatch(showHideNavigationButtons("saveVisible", false));
10859
- this._store.dispatch(showHideNavigationButtons("cancelVisible", false));
10860
- this._store.dispatch(showHideNavigationButtons("reloadVisible", false));
10861
- }
9320
+ componentWillLoad() {
9321
+ if (this.dataUnit === undefined) {
9322
+ this.dataUnit = new DataUnit("ez-form");
10862
9323
  }
10863
- if (this._preparedMetadata === undefined) {
10864
- if (this.metadata) {
10865
- this.updateMetadata(this.metadata);
9324
+ this.dataUnit.subscribe(action => {
9325
+ if (action.type === Action.METADATA_LOADED) {
9326
+ this.processMetadata();
10866
9327
  }
10867
- else {
10868
- this.loadMDFromElement((md) => this.updateMetadata(md));
10869
- if (!this._preparedMetadata) {
10870
- this.loadMDFromExecutor((md) => this.updateMetadata(md));
10871
- }
10872
- }
10873
- }
9328
+ });
9329
+ this._dataBinder = new DataBinder(this.dataUnit);
9330
+ this._store = createStore(formReducer);
9331
+ this._store.subscribe(() => forceUpdate(this));
9332
+ this._staticFields = Array.from(this._element.querySelectorAll("[data-field-name]"));
9333
+ this.processMetadata();
10874
9334
  }
10875
9335
  componentDidRender() {
10876
- this._duToLoad.forEach(du => du.load());
10877
- this._duToLoad = [];
10878
- }
10879
- loadSearch(argument, context) {
10880
- const fieldSearchExecutor = this.parseExecutor(this.fieldSearchExecutor);
10881
- if (fieldSearchExecutor) {
10882
- return fieldSearchExecutor(argument, context);
10883
- }
10884
- else {
10885
- return [{ value: 0, label: "Sem resultados" }];
10886
- }
10887
- }
10888
- buildDataUnit(dataUnit, parentDataUnit) {
10889
- if (dataUnit) {
10890
- const { name, unitLabel, records, cardinality, fields } = dataUnit;
10891
- if (!(dataUnit instanceof DataUnit)) {
10892
- let parent;
10893
- if (parentDataUnit instanceof DataUnit) {
10894
- parent = parentDataUnit;
10895
- }
10896
- else {
10897
- parent = this._dataUnits.get(parentDataUnit);
10898
- }
10899
- dataUnit = new DataUnit(name, unitLabel, cardinality, parent);
10900
- dataUnit.fields = fields;
10901
- this._dataUnits.set(dataUnit.name, dataUnit);
10902
- if (records) {
10903
- dataUnit.records = records;
10904
- }
10905
- }
10906
- this.decorateDU(dataUnit);
10907
- }
10908
- return dataUnit;
10909
- }
10910
- decorateDU(dataUnit) {
10911
- dataUnit.store = this._store;
10912
- dataUnit.loadExecutor = this.parseExecutor(this.loadExecutor);
10913
- dataUnit.saveExecutor = this.parseExecutor(this.saveExecutor);
10914
- dataUnit.removeExecutor = this.parseExecutor(this.removeExecutor);
10915
- dataUnit.recordsValidator = this;
9336
+ this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")));
10916
9337
  }
10917
9338
  render() {
10918
- if (this.loading) {
10919
- return h("place-holder", null);
10920
- }
10921
- else {
10922
- return this._preparedMetadata ? h(FormSheet, { enabled: this.enabled, store: this._store, source: this._preparedMetadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du, parentDataUnit) => this.buildDataUnit(du, parentDataUnit) }) : null;
10923
- }
9339
+ return (h(Host, null, this._staticFields.length > 0 ? null : this.getDynamicContent()));
10924
9340
  }
10925
- static get assetsDirs() { return ["assets"]; }
10926
- get _host() { return this; }
10927
- static get watchers() { return {
10928
- "metadata": ["cleanPreparedMetadata"]
10929
- }; }
9341
+ get _element() { return this; }
10930
9342
  static get style() { return ezFormCss; }
10931
9343
  };
10932
9344
 
@@ -123181,128 +121593,6 @@ let EzUpload$1 = class extends HTMLElement$1 {
123181
121593
  static get style() { return ezUploadCss; }
123182
121594
  };
123183
121595
 
123184
- let FormMetadata$1 = class extends HTMLElement$1 {
123185
- constructor() {
123186
- super();
123187
- this.__registerHost();
123188
- this.__attachShadow();
123189
- }
123190
- buildField(element) {
123191
- let label = element.getAttribute("label");
123192
- let name = element.getAttribute("name") || label;
123193
- let userInterface = element.getAttribute("ui") || "SHORTTEXT";
123194
- let properties = [];
123195
- if (userInterface === "OPTIONSELECTOR") {
123196
- if (!label) {
123197
- label = "Selecione uma das opções:";
123198
- }
123199
- const objOpts = {};
123200
- Array.from(element.getElementsByTagName("OPTION")).forEach((optElem, index) => {
123201
- const optValue = optElem.getAttribute("value") || index;
123202
- const optLabel = optElem.textContent;
123203
- objOpts[optValue] = optLabel;
123204
- });
123205
- properties.push({ name: "options", value: JSON.stringify(objOpts) });
123206
- }
123207
- else if (userInterface === "FILE") {
123208
- const urlElement = element.querySelector("URL");
123209
- const headersElement = element.querySelectorAll("HEADERS>HEADER");
123210
- if (urlElement) {
123211
- properties.push({ name: "URL", value: urlElement.textContent });
123212
- }
123213
- if (headersElement && headersElement.length > 0) {
123214
- const headers = {};
123215
- headersElement.forEach(header => {
123216
- headers[header.getAttribute("name")] = header.textContent;
123217
- });
123218
- properties.push({ name: "HEADERS", value: JSON.stringify(headers) });
123219
- }
123220
- this.addPropertyIfExists(properties, element, "maxfiles");
123221
- }
123222
- else {
123223
- if (!label) {
123224
- label = element.textContent;
123225
- }
123226
- this.addPropertyIfExists(properties, element, "precision");
123227
- this.addPropertyIfExists(properties, element, "prettyprecision");
123228
- }
123229
- const defaultValue = element.getAttribute("defaultValue");
123230
- const required = element.getAttribute("required") === "true";
123231
- const readOnly = element.getAttribute("readonly") === "true";
123232
- return { name, userInterface, label, defaultValue, required, readOnly, properties };
123233
- }
123234
- addPropertyIfExists(properties, element, name) {
123235
- const value = element.getAttribute(name);
123236
- if (value) {
123237
- properties.push({ name, value });
123238
- }
123239
- }
123240
- buildFieldSet(dataUnit, element) {
123241
- const label = element.getAttribute("label");
123242
- const fields = Array.from(element.getElementsByTagName("FIELD")).map(f => {
123243
- const field = this.buildField(f);
123244
- dataUnit.addFieldMetadata(field);
123245
- return { name: field.name };
123246
- });
123247
- return { label, fields };
123248
- }
123249
- fromElements(elements, label, name, dataUnit, autoLoad) {
123250
- const form = {
123251
- name: name || label,
123252
- dataUnit,
123253
- label,
123254
- autoLoad
123255
- };
123256
- Array.from(elements).forEach(child => {
123257
- const tagName = child.tagName.toUpperCase();
123258
- switch (tagName) {
123259
- case "FIELD":
123260
- if (!form.items) {
123261
- form.items = [];
123262
- }
123263
- const f = this.buildField(child);
123264
- dataUnit.addFieldMetadata(f);
123265
- form.items.push({ name: f.name });
123266
- break;
123267
- case "FIELD-SET":
123268
- if (!form.items) {
123269
- form.items = [];
123270
- }
123271
- form.items.push(this.buildFieldSet(dataUnit, child));
123272
- break;
123273
- case "SUB-FORM":
123274
- if (!form.subForms) {
123275
- form.subForms = [];
123276
- }
123277
- const label = child.getAttribute("label") || "Subform " + (form.subForms.length + 1);
123278
- const name = child.getAttribute("name") || label;
123279
- const subDuName = child.getAttribute("dataunit");
123280
- let subDu;
123281
- if (subDuName) {
123282
- subDu = new DataUnit(subDuName, "noname", child.hasAttribute("many") ? "N" : "1");
123283
- }
123284
- else {
123285
- subDu = dataUnit;
123286
- }
123287
- form.subForms.push(this.fromElements(child.children, label, name, subDu, child.getAttribute("autoload") === "true"));
123288
- break;
123289
- }
123290
- });
123291
- return form;
123292
- }
123293
- connectedCallback() {
123294
- if (!this.dataunit) {
123295
- this.dataunit = "dataunit_" + (this.name || this.label || new Date().getTime());
123296
- }
123297
- const du = new DataUnit(this.dataunit, "noname", this.many ? "N" : "1");
123298
- this.metadata = this.fromElements(this._host.children, this.label, this.name, du, this.autoload);
123299
- }
123300
- render() {
123301
- return h(Host, null);
123302
- }
123303
- get _host() { return this; }
123304
- };
123305
-
123306
121596
  const gridConfigCss = ":host{--ez-grid-config__footer--padding-top:var(--space--medium, 12px);--ez-grid-config__main--padding-right:var(--space--medium, 12px);--ez-grid-config__tabselector-container--padding:var(--space--medium, 12px);--ez-grid-config__button-close--padding-left:var(--space--medium, 12px);--ez-grid-config__subtitle--font-family:var(--font-pattern, \"Sora\");--ez-grid-config__title--font-family:var(--font-pattern, \"Sora\");--ez-grid-config__title--font-weight:var(--text-weight--large, 14px);--ez-grid-config__subtitle--font-size:var(--text--medium, 14px);--ez-grid-config__scrollbar--width:var(--space--medium, 12px);--ez-grid-config__main__scrollbar--background-color:var(--text--primary, #626e82);--ez-grid-config__main__scrollbar--border-radius:var(--border--radius-medium, 12px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}.padding-right--medium{padding-right:var(--space--medium)}ez-list{height:100%}.grid-config__footer{padding-top:var(--ez-grid-config__footer--padding-top);display:flex;justify-content:flex-end;width:100%}.hidden{display:none}.grid-config__main{padding-right:var(--ez-grid-config__main--padding-right);overflow-y:auto}.tabselector-container{padding:var(--ez-grid-config__tabselector-container--padding) 0}.button-close{padding-left:var(--ez-grid-config__button-close--padding-left)}.title-container{display:flex;justify-content:center;align-items:center}.subtitle{font-family:var(--ez-grid-config__subtitle--font-family);font-size:var(--ez-grid-config__subtitle--font-size)}.title{display:flex;font-family:var(--ez-grid-config__title--font-family);margin:0;font-weight:var(--ez-grid-config__title--font-weight);line-height:1.3}.grid-config__main::-webkit-scrollbar-track{background-color:#f0f2f5}.grid-config__main::-webkit-scrollbar-thumb{background-color:var(--ez-grid-config__main__scrollbar--background-color);border-radius:var(--ez-grid-config__main__scrollbar--border-radius)}.grid-config__main::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-grid-config__scrollbar--width);max-width:var(--ez-grid-config__scrollbar--width);min-width:var(--ez-grid-config__scrollbar--width)}";
123307
121597
 
123308
121598
  let GridConfig$1 = class extends HTMLElement$1 {
@@ -123553,20 +121843,6 @@ let GridConfig$1 = class extends HTMLElement$1 {
123553
121843
  static get style() { return gridConfigCss; }
123554
121844
  };
123555
121845
 
123556
- const placeHolderCss = ":host{display:flex;width:100%;height:42px;border-radius:12px;background:var(--background--medium);background-image:linear-gradient(to right, var(--background--medium) 0%, var(--background--strong) 20%, var(--background--medium) 40%, var(--background--medium) 100%);background-repeat:no-repeat;background-size:800px 1000px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:placeholderShimmer;animation-timing-function:linear}@keyframes placeholderShimmer{0%{background-position:-800px 0}100%{background-position:800px 0}}";
123557
-
123558
- let PlaceHolder$1 = class extends HTMLElement$1 {
123559
- constructor() {
123560
- super();
123561
- this.__registerHost();
123562
- this.__attachShadow();
123563
- }
123564
- render() {
123565
- return h(Host, null);
123566
- }
123567
- static get style() { return placeHolderCss; }
123568
- };
123569
-
123570
121846
  const selectBoxCss = "select{border:1px solid #DCE0E8;font-family:'Sora';border-radius:3px;outline:none;cursor:pointer}";
123571
121847
 
123572
121848
  let SelectBox$1 = class extends HTMLElement$1 {
@@ -123602,34 +121878,77 @@ let TestDu$1 = class extends HTMLElement$1 {
123602
121878
  constructor() {
123603
121879
  super();
123604
121880
  this.__registerHost();
123605
- this._dataUnit = new DataUnit$1("duteste");
123606
121881
  }
123607
- componentDidLoad() {
123608
- this._dataUnit.dataLoader = (_dataUnit, _sort, _filters) => {
123609
- return Promise.resolve([
123610
- { __record__id__: "registro1", CODPARC: 10, NOMEPARC: "Parceiro 10" },
123611
- { __record__id__: "registro2", CODPARC: 20, NOMEPARC: "Parceiro 20" }
123612
- ]);
123613
- };
123614
- this._dataUnit.metadata = {
123615
- name: "Parceiro",
121882
+ componentWillLoad() {
121883
+ this.dataUnit = new DataUnit("testes_com_formulario");
121884
+ this.dataUnit.metadata = {
121885
+ name: "dd://br.com.sankhya.fin.cad.movimentacaoFinanceira/Financeiro",
123616
121886
  label: "Parceiro",
123617
121887
  fields: [
123618
121888
  {
123619
121889
  name: "CODPARC",
123620
- label: "Cód. Parceiro",
123621
- dataType: DataType.NUMBER
121890
+ label: "Parceiro",
121891
+ dataType: DataType.NUMBER,
121892
+ userInterface: UserInterface.SEARCH,
121893
+ required: true,
121894
+ properties: {}
121895
+ },
121896
+ {
121897
+ name: "RECDESP",
121898
+ label: "Receita/Despesa",
121899
+ dataType: DataType.TEXT,
121900
+ userInterface: UserInterface.OPTIONSELECTOR,
121901
+ required: true,
121902
+ properties: { options: `{"-1": "Despesa", "1": "Receita"}` }
123622
121903
  },
123623
121904
  {
123624
- name: "NOMEPARC",
123625
- label: "Nome Parceiro",
123626
- dataType: DataType.TEXT
121905
+ name: "P",
121906
+ label: "pera",
121907
+ dataType: DataType.TEXT,
121908
+ userInterface: UserInterface.OPTIONSELECTOR,
121909
+ properties: { options: `{"M": "Madura", "V": "Verde", "P": "Passada"}` }
121910
+ },
121911
+ {
121912
+ name: "ME",
121913
+ label: "ME",
121914
+ dataType: DataType.NUMBER,
121915
+ userInterface: UserInterface.DECIMALNUMBER,
121916
+ properties: { precision: 4, prettyPrecision: 1 }
123627
121917
  }
123628
121918
  ]
123629
121919
  };
121920
+ this.formConfig = [
121921
+ { name: "CODPARC", label: "Parceiro" },
121922
+ { name: "NOMEPARC", label: "Mamão" },
121923
+ { name: "P", label: "Pêra", group: "Grupo 1" },
121924
+ { name: "ME", label: "Melancia", tab: "aba 1", group: "Grupo 2" },
121925
+ { name: "L", label: "Laranja", tab: "aba 1", group: "Grupo 1" },
121926
+ { name: "LI", label: "Limão", tab: "aba 1", group: "Grupo 2" }
121927
+ ];
121928
+ this.dataUnit.records = [
121929
+ {
121930
+ __record__id__: "1321321321321321",
121931
+ CODPARC: 10,
121932
+ NOMEPARC: "Parceiro 10",
121933
+ P: "M",
121934
+ L: "Bagaço",
121935
+ LI: "Azedo"
121936
+ }
121937
+ ];
123630
121938
  }
123631
121939
  render() {
123632
- return (h("section", { class: "padding--large" }, h("div", { class: "row margin-bottom--large" }, h("h1", { class: "title title--primary" }, "Formul\u00E1rios")), h("div", { class: "col col--sd-12", style: { height: "600px" } }, h("ez-grid", { dataUnit: this._dataUnit, "server-url": "https://www.ag-grid.com/example-assets/row-data.json", "multiple-selection": true, "page-size": "100" }))));
121940
+ //return this.conteudoEstatico();
121941
+ //return this.somenteDataUnit();
121942
+ return this.configurado();
121943
+ }
121944
+ conteudoEstatico() {
121945
+ return (h("div", null, h("button", { onClick: () => this.form.validate() }, "Validate"), h("ez-form", { ref: ref => this.form = ref }, h("div", null, h("ez-text-input", { label: "Nome (Label est\u00E1tico)", "data-field-name": "NOMEPARC", "data-required": "true" }), h("ez-text-input", { label: "C\u00F3d parc (Label est\u00E1tico)", "data-field-name": "CODPARC", "data-required": "true" })))));
121946
+ }
121947
+ somenteDataUnit() {
121948
+ return (h("ez-form", { dataUnit: this.dataUnit }));
121949
+ }
121950
+ configurado() {
121951
+ return (h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig, ref: ref => this.form = ref }));
123633
121952
  }
123634
121953
  static get style() { return testDuCss; }
123635
121954
  };
@@ -123644,7 +121963,7 @@ const EzComboBox = /*@__PURE__*/proxyCustomElement(EzComboBox$1, [1,"ez-combo-bo
123644
121963
  const EzDateInput = /*@__PURE__*/proxyCustomElement(EzDateInput$1, [1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"]}]);
123645
121964
  const EzDateTimeInput = /*@__PURE__*/proxyCustomElement(EzDateTimeInput$1, [1,"ez-date-time-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"]}]);
123646
121965
  const EzDialog = /*@__PURE__*/proxyCustomElement(EzDialog$1, [1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"]}]);
123647
- const EzForm = /*@__PURE__*/proxyCustomElement(EzForm$1, [0,"ez-form",{"metadataExecutor":[1,"metadata-executor"],"loadExecutor":[1,"load-executor"],"saveExecutor":[1,"save-executor"],"removeExecutor":[1,"remove-executor"],"fieldSearchExecutor":[1,"field-search-executor"],"ignoreSaveValidation":[4,"ignore-save-validation"],"metadata":[16],"slaveMode":[4,"slave-mode"],"enabled":[4],"loading":[1540]}]);
121966
+ const EzForm = /*@__PURE__*/proxyCustomElement(EzForm$1, [0,"ez-form",{"dataUnit":[1040],"config":[16]}]);
123648
121967
  const EzGrid = /*@__PURE__*/proxyCustomElement(EzGrid$1, [0,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"_popUpVisible":[32]}]);
123649
121968
  const EzIcon = /*@__PURE__*/proxyCustomElement(EzIcon$1, [1,"ez-icon",{"size":[513],"href":[513]}]);
123650
121969
  const EzLabelChip = /*@__PURE__*/proxyCustomElement(EzLabelChip$1, [1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540]}]);
@@ -123660,9 +121979,7 @@ const EzTextInput = /*@__PURE__*/proxyCustomElement(EzTextInput$1, [1,"ez-text-i
123660
121979
  const EzTimeInput = /*@__PURE__*/proxyCustomElement(EzTimeInput$1, [1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"]}]);
123661
121980
  const EzToast = /*@__PURE__*/proxyCustomElement(EzToast$1, [1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"]}]);
123662
121981
  const EzUpload = /*@__PURE__*/proxyCustomElement(EzUpload$1, [1,"ez-upload",{"label":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040]}]);
123663
- const FormMetadata = /*@__PURE__*/proxyCustomElement(FormMetadata$1, [1,"form-metadata",{"name":[1],"label":[1],"dataunit":[1025],"many":[4],"autoload":[4],"metadata":[1040]}]);
123664
121982
  const GridConfig = /*@__PURE__*/proxyCustomElement(GridConfig$1, [1,"grid-config",{"selectedTab":[1025,"selected-tab"],"columns":[1040]}]);
123665
- const PlaceHolder = /*@__PURE__*/proxyCustomElement(PlaceHolder$1, [1,"place-holder"]);
123666
121983
  const SelectBox = /*@__PURE__*/proxyCustomElement(SelectBox$1, [1,"select-box",{"selectedOption":[1,"selected-option"]}]);
123667
121984
  const TestDu = /*@__PURE__*/proxyCustomElement(TestDu$1, [0,"test-du"]);
123668
121985
  const defineCustomElements = (opts) => {
@@ -123694,9 +122011,7 @@ const defineCustomElements = (opts) => {
123694
122011
  EzTimeInput,
123695
122012
  EzToast,
123696
122013
  EzUpload,
123697
- FormMetadata,
123698
122014
  GridConfig,
123699
- PlaceHolder,
123700
122015
  SelectBox,
123701
122016
  TestDu
123702
122017
  ].forEach(cmp => {
@@ -123707,4 +122022,4 @@ const defineCustomElements = (opts) => {
123707
122022
  }
123708
122023
  };
123709
122024
 
123710
- export { EzActionChip, EzApplication, EzButton, EzCalendar, EzCheck, EzCollapsibleBox, EzComboBox, EzDateInput, EzDateTimeInput, EzDialog, EzForm, EzGrid, EzIcon, EzLabelChip, EzList, EzModal, EzNumberInput, EzPopover, EzPopup, EzSearch, EzTabselector, EzTextArea, EzTextInput, EzTimeInput, EzToast, EzUpload, FormMetadata, GridConfig, PlaceHolder, SelectBox, TestDu, defineCustomElements };
122025
+ export { EzActionChip, EzApplication, EzButton, EzCalendar, EzCheck, EzCollapsibleBox, EzComboBox, EzDateInput, EzDateTimeInput, EzDialog, EzForm, EzGrid, EzIcon, EzLabelChip, EzList, EzModal, EzNumberInput, EzPopover, EzPopup, EzSearch, EzTabselector, EzTextArea, EzTextInput, EzTimeInput, EzToast, EzUpload, GridConfig, SelectBox, TestDu, defineCustomElements };