@sankhyalabs/ezui 5.10.8 → 5.11.0-dev.10

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 (168) hide show
  1. package/README.md +8 -11
  2. package/dist/cjs/{CSSVarsUtils-af809e73.js → CSSVarsUtils-b136a156.js} +5 -0
  3. package/dist/cjs/RecordValidationProcessor-edd23705.js +102 -0
  4. package/dist/cjs/ez-actions-button.cjs.entry.js +1 -1
  5. package/dist/cjs/ez-calendar.cjs.entry.js +34 -5
  6. package/dist/cjs/ez-card-item.cjs.entry.js +1 -1
  7. package/dist/cjs/ez-combo-box.cjs.entry.js +99 -16
  8. package/dist/cjs/ez-date-input.cjs.entry.js +53 -22
  9. package/dist/cjs/ez-date-time-input.cjs.entry.js +53 -19
  10. package/dist/cjs/ez-filter-input_2.cjs.entry.js +1 -1
  11. package/dist/cjs/ez-form-view.cjs.entry.js +42 -1
  12. package/dist/cjs/ez-form.cjs.entry.js +11 -84
  13. package/dist/cjs/ez-grid.cjs.entry.js +575 -44
  14. package/dist/cjs/ez-multi-selection-list.cjs.entry.js +3 -1
  15. package/dist/cjs/ez-number-input.cjs.entry.js +39 -15
  16. package/dist/cjs/ez-search.cjs.entry.js +13 -2
  17. package/dist/cjs/ez-text-area.cjs.entry.js +6 -2
  18. package/dist/cjs/ez-text-input.cjs.entry.js +7 -4
  19. package/dist/cjs/ez-time-input.cjs.entry.js +11 -7
  20. package/dist/cjs/ezui.cjs.js +1 -1
  21. package/dist/cjs/filter-column.cjs.entry.js +30 -7
  22. package/dist/cjs/loader.cjs.js +1 -1
  23. package/dist/collection/collection-manifest.json +2 -2
  24. package/dist/collection/components/ez-calendar/ez-calendar.js +63 -6
  25. package/dist/collection/components/ez-card-item/ez-card-item.css +1 -0
  26. package/dist/collection/components/ez-combo-box/ez-combo-box.css +6 -0
  27. package/dist/collection/components/ez-combo-box/ez-combo-box.js +168 -14
  28. package/dist/collection/components/ez-date-input/ez-date-input.js +71 -21
  29. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +71 -18
  30. package/dist/collection/components/ez-form/ez-form.js +20 -0
  31. package/dist/collection/components/ez-form-view/ez-form-view.js +23 -0
  32. package/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder.js +4 -1
  33. package/dist/collection/components/ez-form-view/structure/index.js +34 -0
  34. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +41 -8
  35. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +1 -0
  36. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +230 -0
  37. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.js +1 -1
  38. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +49 -0
  39. package/dist/collection/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.js +10 -0
  40. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.js +4 -0
  41. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +38 -0
  42. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +40 -0
  43. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +20 -0
  44. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +15 -0
  45. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +41 -0
  46. package/dist/collection/components/ez-grid/ez-grid.js +78 -39
  47. package/dist/collection/components/ez-grid/subcomponents/filter-column.js +50 -8
  48. package/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource.js +78 -0
  49. package/dist/collection/components/ez-multi-selection-list/ez-multi-selection-list.js +21 -1
  50. package/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
  51. package/dist/collection/components/ez-number-input/ez-number-input.js +62 -15
  52. package/dist/collection/components/ez-search/ez-search.css +1 -1
  53. package/dist/collection/components/ez-search/ez-search.js +84 -1
  54. package/dist/collection/components/ez-text-area/ez-text-area.css +4 -0
  55. package/dist/collection/components/ez-text-area/ez-text-area.js +23 -1
  56. package/dist/collection/components/ez-text-input/ez-text-input.css +8 -1
  57. package/dist/collection/components/ez-text-input/ez-text-input.js +14 -5
  58. package/dist/collection/components/ez-time-input/ez-time-input.css +4 -0
  59. package/dist/collection/components/ez-time-input/ez-time-input.js +18 -7
  60. package/dist/collection/utils/CSSVarsUtils.js +5 -0
  61. package/dist/collection/utils/form/DataBinder.js +8 -63
  62. package/dist/collection/utils/form/FormMetadata.js +3 -22
  63. package/dist/collection/utils/interfaces/AbstractFieldMetadata.js +21 -0
  64. package/dist/collection/utils/validators/recordvalidator/IValidationResult.js +1 -0
  65. package/dist/collection/utils/validators/recordvalidator/IValidationSource.js +1 -0
  66. package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +74 -0
  67. package/dist/custom-elements/index.js +1101 -256
  68. package/dist/esm/{CSSVarsUtils-00f67f32.js → CSSVarsUtils-a97cfa29.js} +5 -0
  69. package/dist/esm/RecordValidationProcessor-abc814af.js +99 -0
  70. package/dist/esm/ez-actions-button.entry.js +1 -1
  71. package/dist/esm/ez-calendar.entry.js +35 -6
  72. package/dist/esm/ez-card-item.entry.js +1 -1
  73. package/dist/esm/ez-combo-box.entry.js +99 -16
  74. package/dist/esm/ez-date-input.entry.js +53 -22
  75. package/dist/esm/ez-date-time-input.entry.js +53 -19
  76. package/dist/esm/ez-filter-input_2.entry.js +1 -1
  77. package/dist/esm/ez-form-view.entry.js +42 -1
  78. package/dist/esm/ez-form.entry.js +12 -85
  79. package/dist/esm/ez-grid.entry.js +576 -45
  80. package/dist/esm/ez-multi-selection-list.entry.js +3 -1
  81. package/dist/esm/ez-number-input.entry.js +39 -15
  82. package/dist/esm/ez-search.entry.js +13 -2
  83. package/dist/esm/ez-text-area.entry.js +6 -2
  84. package/dist/esm/ez-text-input.entry.js +7 -4
  85. package/dist/esm/ez-time-input.entry.js +11 -7
  86. package/dist/esm/ezui.js +1 -1
  87. package/dist/esm/filter-column.entry.js +30 -7
  88. package/dist/esm/loader.js +1 -1
  89. package/dist/ezui/ezui.esm.js +1 -1
  90. package/dist/ezui/p-028f264f.entry.js +1 -0
  91. package/dist/ezui/p-061f4d73.entry.js +1 -0
  92. package/dist/ezui/p-25562cf8.entry.js +1 -0
  93. package/dist/ezui/p-3078d25c.entry.js +1 -0
  94. package/dist/ezui/p-391de0e4.entry.js +1 -0
  95. package/dist/ezui/{p-68352e41.entry.js → p-47afb974.entry.js} +1 -1
  96. package/dist/ezui/p-5cef0264.entry.js +1 -0
  97. package/dist/ezui/p-5e55a42b.entry.js +1 -0
  98. package/dist/ezui/p-7526f2b6.entry.js +1 -0
  99. package/dist/ezui/p-7eb3e1a5.js +1 -0
  100. package/dist/ezui/p-86a2036d.js +1 -0
  101. package/dist/ezui/{p-12303d2e.entry.js → p-87e85160.entry.js} +1 -1
  102. package/dist/ezui/{p-c7a23be9.entry.js → p-964e5571.entry.js} +2 -2
  103. package/dist/ezui/p-ce035beb.entry.js +1 -0
  104. package/dist/ezui/p-d43b22f3.entry.js +1 -0
  105. package/dist/ezui/p-df93558d.entry.js +1 -0
  106. package/dist/ezui/p-e2dfd935.entry.js +1 -0
  107. package/dist/ezui/p-e67d0bd5.entry.js +1 -0
  108. package/dist/ezui/{p-f1a537e3.entry.js → p-ff82b176.entry.js} +1 -1
  109. package/dist/types/components/ez-calendar/ez-calendar.d.ts +9 -1
  110. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +23 -0
  111. package/dist/types/components/ez-date-input/ez-date-input.d.ts +4 -0
  112. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +4 -0
  113. package/dist/types/components/ez-form/ez-form.d.ts +5 -0
  114. package/dist/types/components/ez-form-view/ez-form-view.d.ts +5 -0
  115. package/dist/types/components/ez-form-view/interfaces/IFormViewField.d.ts +2 -14
  116. package/dist/types/components/ez-form-view/structure/index.d.ts +15 -0
  117. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +18 -0
  118. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
  119. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +38 -0
  120. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.d.ts +1 -1
  121. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +10 -0
  122. package/dist/types/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.d.ts +1 -0
  123. package/dist/types/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.d.ts +9 -0
  124. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +10 -0
  125. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.d.ts +4 -0
  126. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.d.ts +5 -0
  127. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.d.ts +4 -0
  128. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.d.ts +3 -0
  129. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.d.ts +4 -0
  130. package/dist/types/components/ez-grid/ez-grid.d.ts +16 -5
  131. package/dist/types/components/ez-grid/subcomponents/filter-column.d.ts +8 -0
  132. package/dist/types/components/ez-grid/utils/InMemoryFilterColumnDataSource.d.ts +16 -0
  133. package/dist/types/components/ez-multi-selection-list/ez-multi-selection-list.d.ts +4 -0
  134. package/dist/types/components/ez-number-input/ez-number-input.d.ts +5 -1
  135. package/dist/types/components/ez-search/ez-search.d.ts +14 -1
  136. package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -0
  137. package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -1
  138. package/dist/types/components/ez-time-input/ez-time-input.d.ts +2 -1
  139. package/dist/types/components.d.ts +116 -6
  140. package/dist/types/utils/form/DataBinder.d.ts +1 -3
  141. package/dist/types/utils/form/interfaces/IFormConfig.d.ts +1 -1
  142. package/dist/types/utils/form/interfaces/index.d.ts +4 -4
  143. package/dist/types/utils/interfaces/AbstractFieldMetadata.d.ts +17 -0
  144. package/dist/types/utils/{form/interfaces → interfaces}/IFieldConfig.d.ts +2 -2
  145. package/dist/types/utils/validators/recordvalidator/IValidationSource.d.ts +6 -0
  146. package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +13 -0
  147. package/package.json +3 -3
  148. package/dist/ezui/p-00c7c25d.entry.js +0 -1
  149. package/dist/ezui/p-0b160fec.entry.js +0 -1
  150. package/dist/ezui/p-0bd54a6f.entry.js +0 -1
  151. package/dist/ezui/p-2a0e1679.entry.js +0 -1
  152. package/dist/ezui/p-39153935.entry.js +0 -1
  153. package/dist/ezui/p-4a5e37a7.js +0 -1
  154. package/dist/ezui/p-4c8b029b.entry.js +0 -1
  155. package/dist/ezui/p-4e31b69b.entry.js +0 -1
  156. package/dist/ezui/p-5782443e.entry.js +0 -1
  157. package/dist/ezui/p-5d45e384.entry.js +0 -1
  158. package/dist/ezui/p-70ea4beb.entry.js +0 -1
  159. package/dist/ezui/p-78a6e049.entry.js +0 -1
  160. package/dist/ezui/p-8bcb197f.entry.js +0 -1
  161. package/dist/ezui/p-a4c9f3c4.entry.js +0 -1
  162. /package/dist/collection/{utils/form/interfaces/IFieldConfig.js → components/ez-grid/controller/ag-grid/editor/IUICellEditor.js} +0 -0
  163. /package/dist/collection/utils/{form/interfaces/IInvalidField.js → interfaces/IFieldConfig.js} +0 -0
  164. /package/dist/collection/utils/{form/interfaces/IRecordValidator.js → validators/recordvalidator/IInvalidField.js} +0 -0
  165. /package/dist/collection/utils/{form/interfaces/IValidationResult.js → validators/recordvalidator/IRecordValidator.js} +0 -0
  166. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IInvalidField.d.ts +0 -0
  167. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IRecordValidator.d.ts +0 -0
  168. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IValidationResult.d.ts +0 -0
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-1064511f.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const CSSVarsUtils = require('./CSSVarsUtils-af809e73.js');
7
+ const CSSVarsUtils = require('./CSSVarsUtils-b136a156.js');
8
8
 
9
9
  const ezDateTimeInputCss = ":host{display:block;width:100%;--ez-date-input__input--background-color:var(--background--medium, #e0e0e0);--ez-date-input__input--border-color:var(--ez-date-input__input--background-color);--ez-date-input__calendar-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"15px\"><path d=\"M 3.171875,5.25 C 2.6485088,5.25 2.21875,5.6797588 2.21875,6.203125 2.21875,6.7264912 2.6485088,7.15625 3.171875,7.15625 3.6952412,7.15625 4.125,6.7264912 4.125,6.203125 4.125,5.6797588 3.6952412,5.25 3.171875,5.25 Z m 2.875,0 C 5.5235088,5.25 5.09375,5.6797588 5.09375,6.203125 5.09375,6.7264912 5.5235088,7.15625 6.046875,7.15625 6.5702412,7.15625 7,6.7264912 7,6.203125 7,5.6797588 6.5702412,5.25 6.046875,5.25 Z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.9511719,-0.4297588 0.9511719,-0.953125 C 9.8730469,5.6797588 9.4452412,5.25 8.921875,5.25 Z m 2.873047,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.953125 0.953125,0.953125 0.523366,0 0.953125,-0.4297588 0.953125,-0.953125 C 12.748047,5.6797588 12.318288,5.25 11.794922,5.25 Z M 3.171875,8.1230469 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 0.5233662,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 C 6.5702412,10.029297 7,9.5995381 7,9.0761719 7,8.5528057 6.5702412,8.1230469 6.046875,8.1230469 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297587,0.9531251 0.953125,0.9531251 0.5233661,0 0.9531249,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.9531251 0.953125,0.9531251 0.523367,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.171875,10.998047 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 C 6.5702412,12.904297 7,12.474538 7,11.951172 7,11.427806 6.5702412,10.998047 6.046875,10.998047 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297587,0.953125 0.953125,0.953125 0.5233661,0 0.9531249,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.429759,0.953125 0.953125,0.953125 0.523367,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.5,0 c -0.554,0 -1,0.446 -1,1 v 0.050781 C 1.0853217,1.2909766 0,2.5186658 0,4 v 9 c 0,1.652487 1.3475134,3 3,3 h 9 c 1.652487,0 3,-1.347513 3,-3 V 4 C 15,2.5186658 13.914678,1.2909766 12.5,1.0507812 V 1 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 C 4.5,0.446 4.054,0 3.5,0 Z m 1,2.0996094 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -0.640625 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 V 2.1738281 C 13.311725,2.3905225 13.900391,3.11278 13.900391,4 v 9 c 0,1.062113 -0.838278,1.900391 -1.900391,1.900391 H 3 C 1.9378864,14.900391 1.0996094,14.062113 1.0996094,13 V 4 C 1.0996094,3.11278 1.6882747,2.3905225 2.5,2.1738281 v 0.5664063 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 z\"/></svg>')}.btn-open-cal{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-cal:disabled{cursor:unset}.btn-open-cal::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:15px;height:16px;-webkit-mask-image:var(--ez-date-input__calendar-image);mask-image:var(--ez-date-input__calendar-image)}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}ez-text-input{--text-input__input--background-color:var(--ez-date-input__input--background-color, #FFFFFF);--text-input__input--border-color:var(--ez-date-input__input--border-color, #DCE0E8)}";
10
10
 
@@ -14,7 +14,9 @@ const EzDateTimeInput = class {
14
14
  this.ezChange = index.createEvent(this, "ezChange", 7);
15
15
  this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
16
16
  this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
17
+ this._changePending = false;
17
18
  this._focused = false;
19
+ this._valuePromiseCallbacks = [];
18
20
  this.label = undefined;
19
21
  this.value = undefined;
20
22
  this.enabled = true;
@@ -53,6 +55,7 @@ const EzDateTimeInput = class {
53
55
  this.ezChange.emit(valueEmitted);
54
56
  }
55
57
  }
58
+ this._changePending = false;
56
59
  }
57
60
  /**
58
61
  * Aplica o foco no campo.
@@ -72,6 +75,18 @@ const EzDateTimeInput = class {
72
75
  async isInvalid() {
73
76
  return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
74
77
  }
78
+ /*
79
+ * Retorna uma promise com o valor da opção selecionada,
80
+ * que será resolvida quando o backend devolver este dado.
81
+ */
82
+ async getValueAsync() {
83
+ if (this._changePending) {
84
+ return new Promise(accept => {
85
+ this._valuePromiseCallbacks.push(accept);
86
+ });
87
+ }
88
+ return Promise.resolve(this.value);
89
+ }
75
90
  handleKeyDown(event) {
76
91
  const input = this._textInput.shadowRoot.querySelector('input');
77
92
  if (event.shiftKey && event.key === "Tab") {
@@ -116,7 +131,14 @@ const EzDateTimeInput = class {
116
131
  }
117
132
  }
118
133
  showCalendar() {
119
- const top = this.errorMessage || this.mode === "slim" ? 6 : -13;
134
+ let top;
135
+ if (this.isFixed()) {
136
+ top = 29;
137
+ this._calendar.fitHorizontal(0);
138
+ }
139
+ else {
140
+ top = this.errorMessage || this.mode === "slim" ? 6 : -13;
141
+ }
120
142
  this._calendar.fitVertical(top, this._elem.clientHeight);
121
143
  this._calendar.style.visibility = 'inherit';
122
144
  }
@@ -141,27 +163,35 @@ const EzDateTimeInput = class {
141
163
  }
142
164
  handleBlur() {
143
165
  var _a, _b;
144
- const strValue = ((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "";
145
- const newValue = this.getParsedDateTime();
146
- if (newValue || !strValue) {
147
- this.errorMessage = "";
148
- const currentValue = core.DateUtils.validateDate(this.value, true);
149
- const newValueValidated = core.DateUtils.validateDate(newValue, true);
150
- if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
151
- if (newValueValidated) {
152
- this._textInput.value = this.getTextValue(newValueValidated) || '';
153
- this._focused = false;
166
+ try {
167
+ const strValue = ((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "";
168
+ const newValue = this.getParsedDateTime();
169
+ if (newValue || !strValue) {
170
+ this.errorMessage = "";
171
+ const currentValue = core.DateUtils.validateDate(this.value, true);
172
+ const newValueValidated = core.DateUtils.validateDate(newValue, true);
173
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
174
+ if (newValueValidated) {
175
+ this._textInput.value = this.getTextValue(newValueValidated) || '';
176
+ this._focused = false;
177
+ }
178
+ this.ezCancelWaitingChange.emit();
179
+ }
180
+ else {
181
+ this.changeValue(newValueValidated);
154
182
  }
155
- this.ezCancelWaitingChange.emit();
156
183
  }
157
184
  else {
158
- this.changeValue(newValueValidated);
185
+ this.changeValue(undefined);
186
+ this.ezCancelWaitingChange.emit();
187
+ this.errorMessage = "O valor digitado não é uma data válida";
159
188
  }
160
189
  }
161
- else {
162
- this.changeValue(undefined);
163
- this.ezCancelWaitingChange.emit();
164
- this.errorMessage = "O valor digitado não é uma data válida";
190
+ finally {
191
+ for (const callback of this._valuePromiseCallbacks) {
192
+ callback(this.value);
193
+ }
194
+ this._valuePromiseCallbacks = [];
165
195
  }
166
196
  }
167
197
  getTextValue(date) {
@@ -175,6 +205,7 @@ const EzDateTimeInput = class {
175
205
  const currentValue = core.DateUtils.validateDate(this.value, true);
176
206
  const newValueValidated = core.DateUtils.validateDate(newValue, true);
177
207
  if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
208
+ this._changePending = true;
178
209
  this._focused = true;
179
210
  this.ezStartChange.emit({ waitmessage: "", blocking: false });
180
211
  }
@@ -188,13 +219,16 @@ const EzDateTimeInput = class {
188
219
  this._textInput.value = textValue;
189
220
  }
190
221
  }
222
+ isFixed() {
223
+ return this._elem.dataset.isFixed === "true";
224
+ }
191
225
  componentDidLoad() {
192
226
  CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
193
227
  this.setInputValue();
194
228
  }
195
229
  render() {
196
230
  core.ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
197
- return (index.h(index.Host, null, index.h("ez-text-input", { "data-element-id": core.ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), onFocus: () => this.handleFocus(), onClick: () => this.handleClick(), canShowError: this.canShowError }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { "data-element-id": core.ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
231
+ return (index.h(index.Host, null, index.h("ez-text-input", { "data-element-id": core.ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), onFocus: () => this.handleFocus(), onClick: () => this.handleClick(), canShowError: this.canShowError }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { ref: elem => this._calendar = elem, "data-element-id": core.ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, time: true, showSeconds: this.showSeconds, "data-is-fixed": this._elem.dataset.isFixed })));
198
232
  }
199
233
  get _elem() { return index.getElement(this); }
200
234
  static get watchers() { return {
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-1064511f.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const CSSVarsUtils = require('./CSSVarsUtils-af809e73.js');
7
+ const CSSVarsUtils = require('./CSSVarsUtils-b136a156.js');
8
8
 
9
9
  const ezFilterInputCss = ":host{display:block;width:100%}";
10
10
 
@@ -99,15 +99,54 @@ uiBuilders.set(core.UserInterface.LONGTEXT, buildTextArea);
99
99
  const fieldBuilder = (field) => {
100
100
  const builder = uiBuilders.get(field.userInterface) || buildTextInput;
101
101
  const label = field.required ? `${field.label}${constants.REQUIRED_INFO}` : field.label;
102
- return builder(Object.assign(Object.assign({}, field), { label }));
102
+ const builtElement = builder(Object.assign(Object.assign({}, field), { label }));
103
+ //@ts-ignore
104
+ builtElement.$attrs$['data-form-item'] = field.name;
105
+ return builtElement;
103
106
  };
104
107
 
108
+ class FormItem {
109
+ constructor(elem) {
110
+ this.elem = elem;
111
+ }
112
+ addRightElement(el) {
113
+ this.removeRightElement();
114
+ el.classList.add('ez-padding-left--small');
115
+ el.setAttribute('data-custom-item', 'true');
116
+ this.elem.classList.add('ez-col--nowrap');
117
+ this.elem.appendChild(el);
118
+ }
119
+ removeRightElement() {
120
+ Array.from(this.elem.querySelectorAll('[data-custom-item="true"]')).forEach(item => item.remove());
121
+ }
122
+ get fieldName() {
123
+ return this.elem.getAttribute('data-form-item');
124
+ }
125
+ }
126
+ class FormItems {
127
+ constructor(items, formId) {
128
+ this.items = new Map();
129
+ this.formId = formId;
130
+ items.forEach(item => {
131
+ const formItem = new FormItem(item);
132
+ this.items.set(formItem.fieldName, formItem);
133
+ });
134
+ }
135
+ getItem(name) {
136
+ return this.items.get(name);
137
+ }
138
+ get formName() {
139
+ return this.formId;
140
+ }
141
+ }
142
+
105
143
  const ezFormViewCss = ".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";
106
144
 
107
145
  const EzFormView = class {
108
146
  constructor(hostRef) {
109
147
  index.registerInstance(this, hostRef);
110
148
  this.ezContentReady = index.createEvent(this, "ezContentReady", 7);
149
+ this.formItemsReady = index.createEvent(this, "formItemsReady", 7);
111
150
  this.fields = undefined;
112
151
  }
113
152
  async showUp() {
@@ -133,6 +172,8 @@ const EzFormView = class {
133
172
  }
134
173
  componentDidRender() {
135
174
  this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
175
+ const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
176
+ this.formItemsReady.emit(formItems);
136
177
  }
137
178
  render() {
138
179
  core.ElementIDUtils.addIDInfoIfNotExists(this._element, 'ezFormView');
@@ -4,7 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-1064511f.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const ApplicationUtils = require('./ApplicationUtils-2e444734.js');
7
+ const RecordValidationProcessor = require('./RecordValidationProcessor-edd23705.js');
8
+ require('./ApplicationUtils-2e444734.js');
8
9
  require('./DialogType-2114c337.js');
9
10
 
10
11
  const DETAIL_PATTERN = /child\[([^\]]+)\]/;
@@ -108,7 +109,7 @@ const buildFormMetadata = (config, dataUnit, includeDetails = false) => {
108
109
  if (!sheets.has(tabConfig)) {
109
110
  sheets.set(tabConfig, []);
110
111
  }
111
- const formField = buildFormField(descriptor, field);
112
+ const formField = RecordValidationProcessor.buildFieldMetadata(descriptor, field);
112
113
  sheets.get(tabConfig).push(formField);
113
114
  if (formField.required) {
114
115
  requiredFields.push(field.name);
@@ -167,26 +168,6 @@ const buildFormMetadata = (config, dataUnit, includeDetails = false) => {
167
168
  metadata.addDefaultValues(defaultValues);
168
169
  return metadata;
169
170
  };
170
- const buildFormField = (descriptor, config) => {
171
- let { name, label, group } = Object.assign({}, config);
172
- let { readOnly, required } = Object.assign({}, config);
173
- let props;
174
- let userInterface;
175
- if (descriptor) {
176
- label = label || descriptor.label;
177
- name = name || descriptor.name;
178
- required = descriptor.required || (config === null || config === void 0 ? void 0 : config.required);
179
- readOnly = descriptor.readOnly || (config === null || config === void 0 ? void 0 : config.readOnly);
180
- props = descriptor.properties;
181
- userInterface = descriptor.userInterface;
182
- }
183
- return {
184
- name, label, group,
185
- readOnly, required,
186
- props,
187
- userInterface: userInterface || core.UserInterface.SHORTTEXT
188
- };
189
- };
190
171
  const getTabConfig = (tab, sheets) => {
191
172
  const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
192
173
  return tabConfig || { label: tab, visible: true };
@@ -257,7 +238,11 @@ class DataBinder {
257
238
  }
258
239
  });
259
240
  this._formMetadata = formMetadata;
260
- this._recordsValidator = recordsValidator;
241
+ this._recordValidatorProcessor = new RecordValidationProcessor.RecordValidationProcessor(this._dataUnit, {
242
+ getRequiredFields: () => this._formMetadata.getRequiredFields(),
243
+ markAsInvalid: field => this.markInvalid(field),
244
+ getMessageForField: field => this.getErrorMessage(field)
245
+ }, recordsValidator);
261
246
  }
262
247
  onDisconnectedCallback() {
263
248
  this._dataUnit.unsubscribe(this.onDataUnitEvent);
@@ -268,7 +253,6 @@ class DataBinder {
268
253
  return record === null || record === void 0 ? void 0 : record.__record__id__;
269
254
  }
270
255
  markInvalid(field) {
271
- this._dataUnit.setInvalidField(field.name, field.message, this.getCurrentRecordId());
272
256
  if (this._fields.has(field.name)) {
273
257
  const fieldElement = this._fields.get(field.name).field;
274
258
  this.updateErrorMessage(field.name, fieldElement, field.message);
@@ -297,65 +281,7 @@ class DataBinder {
297
281
  }
298
282
  }
299
283
  validate() {
300
- return new Promise((accept, reject) => {
301
- var _a;
302
- const records = this._dataUnit.getModifiedRecords();
303
- for (let i = 0; i < records.length; i++) {
304
- const record = records[i];
305
- const invalidResults = [];
306
- let validationResult = this.validateRequired(record);
307
- if (validationResult && !validationResult.isValid) {
308
- invalidResults.push(validationResult);
309
- }
310
- validationResult = (_a = this._recordsValidator) === null || _a === void 0 ? void 0 : _a.validateRecord(record);
311
- if (validationResult && !validationResult.isValid) {
312
- invalidResults.push(validationResult);
313
- }
314
- if (invalidResults.length > 0) {
315
- this.processValidationResult(invalidResults);
316
- reject();
317
- break;
318
- }
319
- }
320
- return accept();
321
- });
322
- }
323
- validateRequired(record) {
324
- const requiredFields = this._formMetadata.getRequiredFields();
325
- const invalidFields = [];
326
- new Set(requiredFields).forEach(field => {
327
- const value = record[field];
328
- if (value == undefined || value === "") {
329
- const errorMessage = this.getErrorMessage(field);
330
- if (errorMessage) {
331
- invalidFields.push({ name: field, message: errorMessage });
332
- }
333
- else {
334
- invalidFields.push({ name: field, message: "Essa informação é obrigatória" });
335
- }
336
- }
337
- });
338
- if (invalidFields.length > 0) {
339
- return { isValid: false, invalidFields, infoMessage: "Há pelo menos um campo obrigatório não preenchido." };
340
- }
341
- return undefined;
342
- }
343
- processValidationResult(validationResult) {
344
- validationResult.forEach(invalidResult => {
345
- const invalidFields = invalidResult.invalidFields;
346
- if (invalidFields) {
347
- invalidFields.forEach(field => {
348
- this.markInvalid(field);
349
- });
350
- }
351
- if (invalidResult.infoMessage) {
352
- ApplicationUtils.ApplicationUtils.info(invalidResult.infoMessage);
353
- }
354
- if (invalidResult.errorMessage) {
355
- const { errorTitle, errorMessage } = invalidResult;
356
- ApplicationUtils.ApplicationUtils.error(errorTitle, errorMessage);
357
- }
358
- });
284
+ return this._recordValidatorProcessor.validate();
359
285
  }
360
286
  updateErrorMessage(fieldName, field, message) {
361
287
  if (message == undefined) {
@@ -420,7 +346,7 @@ class DataBinder {
420
346
  this._dataUnit.addRecord();
421
347
  }
422
348
  this._dataUnit.clearInvalid(this.getCurrentRecordId(), fieldName);
423
- this._dataUnit.setFieldValue(fieldName, newValue);
349
+ this._dataUnit.setFieldValue(fieldName, newValue, [this.getCurrentRecordId()]);
424
350
  if (this._dataUnit.waitingForChange(fieldName)) {
425
351
  const bind = this._fields.get(fieldName);
426
352
  if (bind) {
@@ -909,6 +835,7 @@ const EzForm = class {
909
835
  constructor(hostRef) {
910
836
  index.registerInstance(this, hostRef);
911
837
  this.ezReady = index.createEvent(this, "ezReady", 7);
838
+ this.formItemsReady = index.createEvent(this, "formItemsReady", 7);
912
839
  this.onDataUnitAction = (action) => {
913
840
  if (action.type === core.Action.METADATA_LOADED) {
914
841
  this.processMetadata();