@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
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-296b8458.js';
2
2
  import { DateUtils, TimeFormatter, ElementIDUtils } from '@sankhyalabs/core';
3
- import { C as CSSVarsUtils } from './CSSVarsUtils-00f67f32.js';
3
+ import { C as CSSVarsUtils } from './CSSVarsUtils-a97cfa29.js';
4
4
 
5
5
  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)}";
6
6
 
@@ -10,7 +10,9 @@ const EzDateTimeInput = class {
10
10
  this.ezChange = createEvent(this, "ezChange", 7);
11
11
  this.ezStartChange = createEvent(this, "ezStartChange", 7);
12
12
  this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
13
+ this._changePending = false;
13
14
  this._focused = false;
15
+ this._valuePromiseCallbacks = [];
14
16
  this.label = undefined;
15
17
  this.value = undefined;
16
18
  this.enabled = true;
@@ -49,6 +51,7 @@ const EzDateTimeInput = class {
49
51
  this.ezChange.emit(valueEmitted);
50
52
  }
51
53
  }
54
+ this._changePending = false;
52
55
  }
53
56
  /**
54
57
  * Aplica o foco no campo.
@@ -68,6 +71,18 @@ const EzDateTimeInput = class {
68
71
  async isInvalid() {
69
72
  return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
70
73
  }
74
+ /*
75
+ * Retorna uma promise com o valor da opção selecionada,
76
+ * que será resolvida quando o backend devolver este dado.
77
+ */
78
+ async getValueAsync() {
79
+ if (this._changePending) {
80
+ return new Promise(accept => {
81
+ this._valuePromiseCallbacks.push(accept);
82
+ });
83
+ }
84
+ return Promise.resolve(this.value);
85
+ }
71
86
  handleKeyDown(event) {
72
87
  const input = this._textInput.shadowRoot.querySelector('input');
73
88
  if (event.shiftKey && event.key === "Tab") {
@@ -112,7 +127,14 @@ const EzDateTimeInput = class {
112
127
  }
113
128
  }
114
129
  showCalendar() {
115
- const top = this.errorMessage || this.mode === "slim" ? 6 : -13;
130
+ let top;
131
+ if (this.isFixed()) {
132
+ top = 29;
133
+ this._calendar.fitHorizontal(0);
134
+ }
135
+ else {
136
+ top = this.errorMessage || this.mode === "slim" ? 6 : -13;
137
+ }
116
138
  this._calendar.fitVertical(top, this._elem.clientHeight);
117
139
  this._calendar.style.visibility = 'inherit';
118
140
  }
@@ -137,27 +159,35 @@ const EzDateTimeInput = class {
137
159
  }
138
160
  handleBlur() {
139
161
  var _a, _b;
140
- const strValue = ((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "";
141
- const newValue = this.getParsedDateTime();
142
- if (newValue || !strValue) {
143
- this.errorMessage = "";
144
- const currentValue = DateUtils.validateDate(this.value, true);
145
- const newValueValidated = DateUtils.validateDate(newValue, true);
146
- if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
147
- if (newValueValidated) {
148
- this._textInput.value = this.getTextValue(newValueValidated) || '';
149
- this._focused = false;
162
+ try {
163
+ const strValue = ((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "";
164
+ const newValue = this.getParsedDateTime();
165
+ if (newValue || !strValue) {
166
+ this.errorMessage = "";
167
+ const currentValue = DateUtils.validateDate(this.value, true);
168
+ const newValueValidated = DateUtils.validateDate(newValue, true);
169
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
170
+ if (newValueValidated) {
171
+ this._textInput.value = this.getTextValue(newValueValidated) || '';
172
+ this._focused = false;
173
+ }
174
+ this.ezCancelWaitingChange.emit();
175
+ }
176
+ else {
177
+ this.changeValue(newValueValidated);
150
178
  }
151
- this.ezCancelWaitingChange.emit();
152
179
  }
153
180
  else {
154
- this.changeValue(newValueValidated);
181
+ this.changeValue(undefined);
182
+ this.ezCancelWaitingChange.emit();
183
+ this.errorMessage = "O valor digitado não é uma data válida";
155
184
  }
156
185
  }
157
- else {
158
- this.changeValue(undefined);
159
- this.ezCancelWaitingChange.emit();
160
- this.errorMessage = "O valor digitado não é uma data válida";
186
+ finally {
187
+ for (const callback of this._valuePromiseCallbacks) {
188
+ callback(this.value);
189
+ }
190
+ this._valuePromiseCallbacks = [];
161
191
  }
162
192
  }
163
193
  getTextValue(date) {
@@ -171,6 +201,7 @@ const EzDateTimeInput = class {
171
201
  const currentValue = DateUtils.validateDate(this.value, true);
172
202
  const newValueValidated = DateUtils.validateDate(newValue, true);
173
203
  if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
204
+ this._changePending = true;
174
205
  this._focused = true;
175
206
  this.ezStartChange.emit({ waitmessage: "", blocking: false });
176
207
  }
@@ -184,13 +215,16 @@ const EzDateTimeInput = class {
184
215
  this._textInput.value = textValue;
185
216
  }
186
217
  }
218
+ isFixed() {
219
+ return this._elem.dataset.isFixed === "true";
220
+ }
187
221
  componentDidLoad() {
188
222
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
189
223
  this.setInputValue();
190
224
  }
191
225
  render() {
192
226
  ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
193
- return (h(Host, null, h("ez-text-input", { "data-element-id": 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 }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { "data-element-id": ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
227
+ return (h(Host, null, h("ez-text-input", { "data-element-id": 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 }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { ref: elem => this._calendar = elem, "data-element-id": ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, time: true, showSeconds: this.showSeconds, "data-is-fixed": this._elem.dataset.isFixed })));
194
228
  }
195
229
  get _elem() { return getElement(this); }
196
230
  static get watchers() { return {
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-296b8458.js';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
- import { C as CSSVarsUtils } from './CSSVarsUtils-00f67f32.js';
3
+ import { C as CSSVarsUtils } from './CSSVarsUtils-a97cfa29.js';
4
4
 
5
5
  const ezFilterInputCss = ":host{display:block;width:100%}";
6
6
 
@@ -95,15 +95,54 @@ uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
95
95
  const fieldBuilder = (field) => {
96
96
  const builder = uiBuilders.get(field.userInterface) || buildTextInput;
97
97
  const label = field.required ? `${field.label}${REQUIRED_INFO}` : field.label;
98
- return builder(Object.assign(Object.assign({}, field), { label }));
98
+ const builtElement = builder(Object.assign(Object.assign({}, field), { label }));
99
+ //@ts-ignore
100
+ builtElement.$attrs$['data-form-item'] = field.name;
101
+ return builtElement;
99
102
  };
100
103
 
104
+ class FormItem {
105
+ constructor(elem) {
106
+ this.elem = elem;
107
+ }
108
+ addRightElement(el) {
109
+ this.removeRightElement();
110
+ el.classList.add('ez-padding-left--small');
111
+ el.setAttribute('data-custom-item', 'true');
112
+ this.elem.classList.add('ez-col--nowrap');
113
+ this.elem.appendChild(el);
114
+ }
115
+ removeRightElement() {
116
+ Array.from(this.elem.querySelectorAll('[data-custom-item="true"]')).forEach(item => item.remove());
117
+ }
118
+ get fieldName() {
119
+ return this.elem.getAttribute('data-form-item');
120
+ }
121
+ }
122
+ class FormItems {
123
+ constructor(items, formId) {
124
+ this.items = new Map();
125
+ this.formId = formId;
126
+ items.forEach(item => {
127
+ const formItem = new FormItem(item);
128
+ this.items.set(formItem.fieldName, formItem);
129
+ });
130
+ }
131
+ getItem(name) {
132
+ return this.items.get(name);
133
+ }
134
+ get formName() {
135
+ return this.formId;
136
+ }
137
+ }
138
+
101
139
  const ezFormViewCss = ".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";
102
140
 
103
141
  const EzFormView = class {
104
142
  constructor(hostRef) {
105
143
  registerInstance(this, hostRef);
106
144
  this.ezContentReady = createEvent(this, "ezContentReady", 7);
145
+ this.formItemsReady = createEvent(this, "formItemsReady", 7);
107
146
  this.fields = undefined;
108
147
  }
109
148
  async showUp() {
@@ -129,6 +168,8 @@ const EzFormView = class {
129
168
  }
130
169
  componentDidRender() {
131
170
  this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
171
+ const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
172
+ this.formItemsReady.emit(formItems);
132
173
  }
133
174
  render() {
134
175
  ElementIDUtils.addIDInfoIfNotExists(this._element, 'ezFormView');
@@ -1,6 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, f as forceUpdate, H as Host, g as getElement } from './index-296b8458.js';
2
- import { UserInterface, DateUtils, Action, WaitingChangeException, ApplicationContext, DataUnitAction, StringUtils, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
3
- import { A as ApplicationUtils } from './ApplicationUtils-d9a34a16.js';
2
+ import { DateUtils, Action, WaitingChangeException, ApplicationContext, DataUnitAction, StringUtils, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
3
+ import { b as buildFieldMetadata, R as RecordValidationProcessor } from './RecordValidationProcessor-abc814af.js';
4
+ import './ApplicationUtils-d9a34a16.js';
4
5
  import './DialogType-54a62731.js';
5
6
 
6
7
  const DETAIL_PATTERN = /child\[([^\]]+)\]/;
@@ -104,7 +105,7 @@ const buildFormMetadata = (config, dataUnit, includeDetails = false) => {
104
105
  if (!sheets.has(tabConfig)) {
105
106
  sheets.set(tabConfig, []);
106
107
  }
107
- const formField = buildFormField(descriptor, field);
108
+ const formField = buildFieldMetadata(descriptor, field);
108
109
  sheets.get(tabConfig).push(formField);
109
110
  if (formField.required) {
110
111
  requiredFields.push(field.name);
@@ -163,26 +164,6 @@ const buildFormMetadata = (config, dataUnit, includeDetails = false) => {
163
164
  metadata.addDefaultValues(defaultValues);
164
165
  return metadata;
165
166
  };
166
- const buildFormField = (descriptor, config) => {
167
- let { name, label, group } = Object.assign({}, config);
168
- let { readOnly, required } = Object.assign({}, config);
169
- let props;
170
- let userInterface;
171
- if (descriptor) {
172
- label = label || descriptor.label;
173
- name = name || descriptor.name;
174
- required = descriptor.required || (config === null || config === void 0 ? void 0 : config.required);
175
- readOnly = descriptor.readOnly || (config === null || config === void 0 ? void 0 : config.readOnly);
176
- props = descriptor.properties;
177
- userInterface = descriptor.userInterface;
178
- }
179
- return {
180
- name, label, group,
181
- readOnly, required,
182
- props,
183
- userInterface: userInterface || UserInterface.SHORTTEXT
184
- };
185
- };
186
167
  const getTabConfig = (tab, sheets) => {
187
168
  const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
188
169
  return tabConfig || { label: tab, visible: true };
@@ -253,7 +234,11 @@ class DataBinder {
253
234
  }
254
235
  });
255
236
  this._formMetadata = formMetadata;
256
- this._recordsValidator = recordsValidator;
237
+ this._recordValidatorProcessor = new RecordValidationProcessor(this._dataUnit, {
238
+ getRequiredFields: () => this._formMetadata.getRequiredFields(),
239
+ markAsInvalid: field => this.markInvalid(field),
240
+ getMessageForField: field => this.getErrorMessage(field)
241
+ }, recordsValidator);
257
242
  }
258
243
  onDisconnectedCallback() {
259
244
  this._dataUnit.unsubscribe(this.onDataUnitEvent);
@@ -264,7 +249,6 @@ class DataBinder {
264
249
  return record === null || record === void 0 ? void 0 : record.__record__id__;
265
250
  }
266
251
  markInvalid(field) {
267
- this._dataUnit.setInvalidField(field.name, field.message, this.getCurrentRecordId());
268
252
  if (this._fields.has(field.name)) {
269
253
  const fieldElement = this._fields.get(field.name).field;
270
254
  this.updateErrorMessage(field.name, fieldElement, field.message);
@@ -293,65 +277,7 @@ class DataBinder {
293
277
  }
294
278
  }
295
279
  validate() {
296
- return new Promise((accept, reject) => {
297
- var _a;
298
- const records = this._dataUnit.getModifiedRecords();
299
- for (let i = 0; i < records.length; i++) {
300
- const record = records[i];
301
- const invalidResults = [];
302
- let validationResult = this.validateRequired(record);
303
- if (validationResult && !validationResult.isValid) {
304
- invalidResults.push(validationResult);
305
- }
306
- validationResult = (_a = this._recordsValidator) === null || _a === void 0 ? void 0 : _a.validateRecord(record);
307
- if (validationResult && !validationResult.isValid) {
308
- invalidResults.push(validationResult);
309
- }
310
- if (invalidResults.length > 0) {
311
- this.processValidationResult(invalidResults);
312
- reject();
313
- break;
314
- }
315
- }
316
- return accept();
317
- });
318
- }
319
- validateRequired(record) {
320
- const requiredFields = this._formMetadata.getRequiredFields();
321
- const invalidFields = [];
322
- new Set(requiredFields).forEach(field => {
323
- const value = record[field];
324
- if (value == undefined || value === "") {
325
- const errorMessage = this.getErrorMessage(field);
326
- if (errorMessage) {
327
- invalidFields.push({ name: field, message: errorMessage });
328
- }
329
- else {
330
- invalidFields.push({ name: field, message: "Essa informação é obrigatória" });
331
- }
332
- }
333
- });
334
- if (invalidFields.length > 0) {
335
- return { isValid: false, invalidFields, infoMessage: "Há pelo menos um campo obrigatório não preenchido." };
336
- }
337
- return undefined;
338
- }
339
- processValidationResult(validationResult) {
340
- validationResult.forEach(invalidResult => {
341
- const invalidFields = invalidResult.invalidFields;
342
- if (invalidFields) {
343
- invalidFields.forEach(field => {
344
- this.markInvalid(field);
345
- });
346
- }
347
- if (invalidResult.infoMessage) {
348
- ApplicationUtils.info(invalidResult.infoMessage);
349
- }
350
- if (invalidResult.errorMessage) {
351
- const { errorTitle, errorMessage } = invalidResult;
352
- ApplicationUtils.error(errorTitle, errorMessage);
353
- }
354
- });
280
+ return this._recordValidatorProcessor.validate();
355
281
  }
356
282
  updateErrorMessage(fieldName, field, message) {
357
283
  if (message == undefined) {
@@ -416,7 +342,7 @@ class DataBinder {
416
342
  this._dataUnit.addRecord();
417
343
  }
418
344
  this._dataUnit.clearInvalid(this.getCurrentRecordId(), fieldName);
419
- this._dataUnit.setFieldValue(fieldName, newValue);
345
+ this._dataUnit.setFieldValue(fieldName, newValue, [this.getCurrentRecordId()]);
420
346
  if (this._dataUnit.waitingForChange(fieldName)) {
421
347
  const bind = this._fields.get(fieldName);
422
348
  if (bind) {
@@ -905,6 +831,7 @@ const EzForm = class {
905
831
  constructor(hostRef) {
906
832
  registerInstance(this, hostRef);
907
833
  this.ezReady = createEvent(this, "ezReady", 7);
834
+ this.formItemsReady = createEvent(this, "formItemsReady", 7);
908
835
  this.onDataUnitAction = (action) => {
909
836
  if (action.type === Action.METADATA_LOADED) {
910
837
  this.processMetadata();