@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
@@ -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
 
@@ -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) {