@sankhyalabs/ezui 5.10.8 → 5.11.0-dev.2

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 (137) hide show
  1. package/README.md +0 -1
  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-combo-box.cjs.entry.js +89 -14
  7. package/dist/cjs/ez-date-input.cjs.entry.js +53 -22
  8. package/dist/cjs/ez-date-time-input.cjs.entry.js +53 -19
  9. package/dist/cjs/ez-filter-input_2.cjs.entry.js +1 -1
  10. package/dist/cjs/ez-form.cjs.entry.js +9 -83
  11. package/dist/cjs/ez-grid.cjs.entry.js +488 -6
  12. package/dist/cjs/ez-number-input.cjs.entry.js +39 -15
  13. package/dist/cjs/ez-search.cjs.entry.js +11 -2
  14. package/dist/cjs/ez-text-area.cjs.entry.js +6 -2
  15. package/dist/cjs/ez-text-input.cjs.entry.js +7 -4
  16. package/dist/cjs/ez-time-input.cjs.entry.js +11 -7
  17. package/dist/cjs/ezui.cjs.js +1 -1
  18. package/dist/cjs/loader.cjs.js +1 -1
  19. package/dist/collection/collection-manifest.json +2 -2
  20. package/dist/collection/components/ez-calendar/ez-calendar.js +63 -6
  21. package/dist/collection/components/ez-combo-box/ez-combo-box.css +6 -0
  22. package/dist/collection/components/ez-combo-box/ez-combo-box.js +122 -12
  23. package/dist/collection/components/ez-date-input/ez-date-input.js +71 -21
  24. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +71 -18
  25. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +40 -7
  26. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +1 -0
  27. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +230 -0
  28. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +49 -0
  29. package/dist/collection/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.js +10 -0
  30. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.js +4 -0
  31. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +38 -0
  32. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +40 -0
  33. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +20 -0
  34. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +15 -0
  35. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +41 -0
  36. package/dist/collection/components/ez-grid/ez-grid.js +67 -0
  37. package/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
  38. package/dist/collection/components/ez-number-input/ez-number-input.js +62 -15
  39. package/dist/collection/components/ez-search/ez-search.css +1 -1
  40. package/dist/collection/components/ez-search/ez-search.js +46 -1
  41. package/dist/collection/components/ez-text-area/ez-text-area.css +4 -0
  42. package/dist/collection/components/ez-text-area/ez-text-area.js +23 -1
  43. package/dist/collection/components/ez-text-input/ez-text-input.css +8 -1
  44. package/dist/collection/components/ez-text-input/ez-text-input.js +14 -5
  45. package/dist/collection/components/ez-time-input/ez-time-input.css +4 -0
  46. package/dist/collection/components/ez-time-input/ez-time-input.js +18 -7
  47. package/dist/collection/utils/CSSVarsUtils.js +5 -0
  48. package/dist/collection/utils/form/DataBinder.js +7 -62
  49. package/dist/collection/utils/form/FormMetadata.js +3 -22
  50. package/dist/collection/utils/interfaces/AbstractFieldMetadata.js +21 -0
  51. package/dist/collection/utils/validators/recordvalidator/IValidationResult.js +1 -0
  52. package/dist/collection/utils/validators/recordvalidator/IValidationSource.js +1 -0
  53. package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +74 -0
  54. package/dist/custom-elements/index.js +922 -203
  55. package/dist/esm/{CSSVarsUtils-00f67f32.js → CSSVarsUtils-a97cfa29.js} +5 -0
  56. package/dist/esm/RecordValidationProcessor-abc814af.js +99 -0
  57. package/dist/esm/ez-actions-button.entry.js +1 -1
  58. package/dist/esm/ez-calendar.entry.js +35 -6
  59. package/dist/esm/ez-combo-box.entry.js +89 -14
  60. package/dist/esm/ez-date-input.entry.js +53 -22
  61. package/dist/esm/ez-date-time-input.entry.js +53 -19
  62. package/dist/esm/ez-filter-input_2.entry.js +1 -1
  63. package/dist/esm/ez-form.entry.js +10 -84
  64. package/dist/esm/ez-grid.entry.js +489 -7
  65. package/dist/esm/ez-number-input.entry.js +39 -15
  66. package/dist/esm/ez-search.entry.js +11 -2
  67. package/dist/esm/ez-text-area.entry.js +6 -2
  68. package/dist/esm/ez-text-input.entry.js +7 -4
  69. package/dist/esm/ez-time-input.entry.js +11 -7
  70. package/dist/esm/ezui.js +1 -1
  71. package/dist/esm/loader.js +1 -1
  72. package/dist/ezui/ezui.esm.js +1 -1
  73. package/dist/ezui/p-028f264f.entry.js +1 -0
  74. package/dist/ezui/p-391de0e4.entry.js +1 -0
  75. package/dist/ezui/p-4535da17.entry.js +1 -0
  76. package/dist/ezui/p-5cef0264.entry.js +1 -0
  77. package/dist/ezui/p-7eb3e1a5.js +1 -0
  78. package/dist/ezui/p-86a2036d.js +1 -0
  79. package/dist/ezui/{p-12303d2e.entry.js → p-87e85160.entry.js} +1 -1
  80. package/dist/ezui/p-90fa4cb3.entry.js +1 -0
  81. package/dist/ezui/p-9f41b414.entry.js +1 -0
  82. package/dist/ezui/p-ce035beb.entry.js +1 -0
  83. package/dist/ezui/p-d43b22f3.entry.js +1 -0
  84. package/dist/ezui/p-e2dfd935.entry.js +1 -0
  85. package/dist/ezui/p-e67d0bd5.entry.js +1 -0
  86. package/dist/ezui/{p-c7a23be9.entry.js → p-fd54b5b4.entry.js} +2 -2
  87. package/dist/ezui/{p-f1a537e3.entry.js → p-ff82b176.entry.js} +1 -1
  88. package/dist/types/components/ez-calendar/ez-calendar.d.ts +9 -1
  89. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +14 -0
  90. package/dist/types/components/ez-date-input/ez-date-input.d.ts +4 -0
  91. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +4 -0
  92. package/dist/types/components/ez-form-view/interfaces/IFormViewField.d.ts +2 -14
  93. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +18 -0
  94. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
  95. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +38 -0
  96. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +10 -0
  97. package/dist/types/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.d.ts +1 -0
  98. package/dist/types/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.d.ts +9 -0
  99. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +10 -0
  100. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.d.ts +4 -0
  101. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.d.ts +5 -0
  102. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.d.ts +4 -0
  103. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.d.ts +3 -0
  104. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.d.ts +4 -0
  105. package/dist/types/components/ez-grid/ez-grid.d.ts +13 -0
  106. package/dist/types/components/ez-number-input/ez-number-input.d.ts +5 -1
  107. package/dist/types/components/ez-search/ez-search.d.ts +6 -1
  108. package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -0
  109. package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -1
  110. package/dist/types/components/ez-time-input/ez-time-input.d.ts +2 -1
  111. package/dist/types/components.d.ts +65 -6
  112. package/dist/types/utils/form/DataBinder.d.ts +1 -3
  113. package/dist/types/utils/form/interfaces/IFormConfig.d.ts +1 -1
  114. package/dist/types/utils/form/interfaces/index.d.ts +4 -4
  115. package/dist/types/utils/interfaces/AbstractFieldMetadata.d.ts +17 -0
  116. package/dist/types/utils/{form/interfaces → interfaces}/IFieldConfig.d.ts +2 -2
  117. package/dist/types/utils/validators/recordvalidator/IValidationSource.d.ts +6 -0
  118. package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +13 -0
  119. package/package.json +2 -2
  120. package/dist/ezui/p-00c7c25d.entry.js +0 -1
  121. package/dist/ezui/p-0b160fec.entry.js +0 -1
  122. package/dist/ezui/p-0bd54a6f.entry.js +0 -1
  123. package/dist/ezui/p-39153935.entry.js +0 -1
  124. package/dist/ezui/p-4a5e37a7.js +0 -1
  125. package/dist/ezui/p-5782443e.entry.js +0 -1
  126. package/dist/ezui/p-5d45e384.entry.js +0 -1
  127. package/dist/ezui/p-70ea4beb.entry.js +0 -1
  128. package/dist/ezui/p-78a6e049.entry.js +0 -1
  129. package/dist/ezui/p-8bcb197f.entry.js +0 -1
  130. package/dist/ezui/p-a4c9f3c4.entry.js +0 -1
  131. /package/dist/collection/{utils/form/interfaces/IFieldConfig.js → components/ez-grid/controller/ag-grid/editor/IUICellEditor.js} +0 -0
  132. /package/dist/collection/utils/{form/interfaces/IInvalidField.js → interfaces/IFieldConfig.js} +0 -0
  133. /package/dist/collection/utils/{form/interfaces/IRecordValidator.js → validators/recordvalidator/IInvalidField.js} +0 -0
  134. /package/dist/collection/utils/{form/interfaces/IValidationResult.js → validators/recordvalidator/IRecordValidator.js} +0 -0
  135. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IInvalidField.d.ts +0 -0
  136. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IRecordValidator.d.ts +0 -0
  137. /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
 
@@ -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) {