@sankhyalabs/ezui 5.21.0-dev.3 → 5.21.0-dev.30

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 (188) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/ICustomRender-6fafffce.js +13 -0
  3. package/dist/cjs/ez-actions-button.cjs.entry.js +1 -0
  4. package/dist/cjs/ez-alert-list.cjs.entry.js +6 -4
  5. package/dist/cjs/ez-button.cjs.entry.js +2 -2
  6. package/dist/cjs/ez-chart.cjs.entry.js +433 -0
  7. package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -0
  8. package/dist/cjs/ez-combo-box.cjs.entry.js +1 -0
  9. package/dist/cjs/{ez-text-edit.cjs.entry.js → ez-custom-form-input_2.cjs.entry.js} +94 -0
  10. package/dist/cjs/ez-form-view.cjs.entry.js +33 -3
  11. package/dist/cjs/ez-form.cjs.entry.js +77 -2
  12. package/dist/cjs/ez-grid.cjs.entry.js +360 -34
  13. package/dist/cjs/ez-list.cjs.entry.js +11 -3
  14. package/dist/cjs/ez-modal-container.cjs.entry.js +2 -2
  15. package/dist/cjs/ez-number-input.cjs.entry.js +37 -31
  16. package/dist/cjs/ez-search.cjs.entry.js +26 -5
  17. package/dist/cjs/ez-split-item.cjs.entry.js +1 -0
  18. package/dist/cjs/ez-split-panel.cjs.entry.js +1 -1
  19. package/dist/cjs/ez-tabselector.cjs.entry.js +34 -29
  20. package/dist/cjs/ezui.cjs.js +1 -1
  21. package/dist/cjs/index-a7b0c73d.js +8 -4
  22. package/dist/cjs/loader.cjs.js +1 -1
  23. package/dist/collection/collection-manifest.json +2 -0
  24. package/dist/collection/components/ez-alert-list/ez-alert-list.js +6 -4
  25. package/dist/collection/components/ez-button/ez-button.css +7 -0
  26. package/dist/collection/components/ez-button/ez-button.js +1 -1
  27. package/dist/collection/components/ez-chart/components/BarChart.js +27 -0
  28. package/dist/collection/components/ez-chart/components/ColumnChart.js +27 -0
  29. package/dist/collection/components/ez-chart/components/DonutChart.js +42 -0
  30. package/dist/collection/components/ez-chart/components/LineChart.js +27 -0
  31. package/dist/collection/components/ez-chart/components/PieChart.js +45 -0
  32. package/dist/collection/components/ez-chart/components/index.js +5 -0
  33. package/dist/collection/components/ez-chart/ez-chart.css +5 -0
  34. package/dist/collection/components/ez-chart/ez-chart.js +284 -0
  35. package/dist/collection/components/ez-chart/interfaces/ChartAxis.js +1 -0
  36. package/dist/collection/components/ez-chart/interfaces/ChartContext.js +14 -0
  37. package/dist/collection/components/ez-chart/interfaces/ChartOptions.js +1 -0
  38. package/dist/collection/components/ez-chart/interfaces/ChartSerie.js +1 -0
  39. package/dist/collection/components/ez-chart/interfaces/ChartStrategies.js +1 -0
  40. package/dist/collection/components/ez-chart/interfaces/ChartType.js +8 -0
  41. package/dist/collection/components/ez-chart/interfaces/index.js +5 -0
  42. package/dist/collection/components/ez-chart/test/mock-chart.js +137 -0
  43. package/dist/collection/components/ez-chart/types/BaseHighChartsRender.js +146 -0
  44. package/dist/collection/components/ez-form/ez-form.js +130 -4
  45. package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +253 -0
  46. package/dist/collection/components/ez-form-view/ez-form-view.js +89 -1
  47. package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +3 -2
  48. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +62 -5
  49. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +9 -0
  50. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +35 -1
  51. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +58 -0
  52. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.js +40 -0
  53. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.js +11 -0
  54. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.js +11 -0
  55. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +6 -3
  56. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellRender.js +40 -0
  57. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IUICellRender.js +1 -0
  58. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +3 -2
  59. package/dist/collection/components/ez-grid/ez-grid.css +1 -0
  60. package/dist/collection/components/ez-grid/ez-grid.js +265 -13
  61. package/dist/collection/components/ez-grid/interfaces/ICustomFormatter.js +1 -0
  62. package/dist/collection/components/ez-grid/interfaces/index.js +1 -0
  63. package/dist/collection/components/ez-grid/subcomponents/selection-counter.js +3 -11
  64. package/dist/collection/components/ez-grid/subcomponents/utils/selectionCounterUtils.js +22 -0
  65. package/dist/collection/components/ez-grid/test/resources/gridDataUnit.js +19 -0
  66. package/dist/collection/components/ez-list/ez-list.css +6 -2
  67. package/dist/collection/components/ez-list/ez-list.js +28 -2
  68. package/dist/collection/components/ez-modal-container/ez-modal-container.css +4 -0
  69. package/dist/collection/components/ez-modal-container/ez-modal-container.js +1 -1
  70. package/dist/collection/components/ez-number-input/ez-number-input.js +46 -31
  71. package/dist/collection/components/ez-search/ez-search.js +25 -5
  72. package/dist/collection/components/ez-split-panel/ez-split-panel.css +1 -0
  73. package/dist/collection/components/ez-tabselector/ez-tabselector.js +34 -29
  74. package/dist/collection/utils/customEditor/interfaces/ICustomEditor.js +5 -0
  75. package/dist/collection/utils/customEditor/interfaces/ICustomEditorInfo.js +1 -0
  76. package/dist/collection/utils/customRender/interfaces/ICustomRender.js +5 -0
  77. package/dist/collection/utils/customRender/interfaces/ICustomRenderInfo.js +1 -0
  78. package/dist/collection/utils/form/DataBinder.js +26 -0
  79. package/dist/collection/utils/form/test/DataBinder.test.js +41 -4
  80. package/dist/collection/utils/form/test/resources/metadataTest.js +15 -0
  81. package/dist/collection/utils/index.js +2 -0
  82. package/dist/custom-elements/index.d.ts +12 -0
  83. package/dist/custom-elements/index.js +1130 -122
  84. package/dist/esm/ICustomRender-875b5a40.js +13 -0
  85. package/dist/esm/ez-actions-button.entry.js +1 -0
  86. package/dist/esm/ez-alert-list.entry.js +6 -4
  87. package/dist/esm/ez-button.entry.js +2 -2
  88. package/dist/esm/ez-chart.entry.js +429 -0
  89. package/dist/esm/ez-collapsible-box.entry.js +1 -0
  90. package/dist/esm/ez-combo-box.entry.js +1 -0
  91. package/dist/esm/{ez-text-edit.entry.js → ez-custom-form-input_2.entry.js} +96 -3
  92. package/dist/esm/ez-form-view.entry.js +33 -3
  93. package/dist/esm/ez-form.entry.js +78 -3
  94. package/dist/esm/ez-grid.entry.js +360 -34
  95. package/dist/esm/ez-list.entry.js +11 -3
  96. package/dist/esm/ez-modal-container.entry.js +2 -2
  97. package/dist/esm/ez-number-input.entry.js +38 -32
  98. package/dist/esm/ez-search.entry.js +26 -5
  99. package/dist/esm/ez-split-item.entry.js +1 -0
  100. package/dist/esm/ez-split-panel.entry.js +1 -1
  101. package/dist/esm/ez-tabselector.entry.js +34 -29
  102. package/dist/esm/ezui.js +1 -1
  103. package/dist/esm/index-baa5e267.js +8 -4
  104. package/dist/esm/loader.js +1 -1
  105. package/dist/ezui/ezui.esm.js +1 -1
  106. package/dist/ezui/p-09de35a2.entry.js +1 -0
  107. package/dist/ezui/{p-af2ecb1b.entry.js → p-1285c902.entry.js} +1 -1
  108. package/dist/ezui/p-13d2fe2d.entry.js +1 -0
  109. package/dist/ezui/p-1a35324b.entry.js +1 -0
  110. package/dist/ezui/p-1ee2479b.entry.js +1 -0
  111. package/dist/ezui/p-2097d0cf.entry.js +1 -0
  112. package/dist/ezui/p-2dcb50d4.entry.js +1 -0
  113. package/dist/ezui/p-30775e7f.entry.js +1 -0
  114. package/dist/ezui/p-3b4eeeb6.entry.js +1 -0
  115. package/dist/ezui/p-3b56d2ef.entry.js +1 -0
  116. package/dist/ezui/p-4607fb89.js +1 -0
  117. package/dist/ezui/p-6517c8c7.entry.js +1 -0
  118. package/dist/ezui/p-7922142b.entry.js +1 -0
  119. package/dist/ezui/p-84e439b9.entry.js +1 -0
  120. package/dist/ezui/p-922ac38b.entry.js +1 -0
  121. package/dist/ezui/{p-b44741b0.entry.js → p-97db197f.entry.js} +2 -2
  122. package/dist/ezui/p-bcb53f27.entry.js +1 -0
  123. package/dist/ezui/p-ffef392d.entry.js +1 -0
  124. package/dist/types/components/ez-alert-list/ez-alert-list.d.ts +2 -2
  125. package/dist/types/components/ez-chart/components/BarChart.d.ts +9 -0
  126. package/dist/types/components/ez-chart/components/ColumnChart.d.ts +9 -0
  127. package/dist/types/components/ez-chart/components/DonutChart.d.ts +9 -0
  128. package/dist/types/components/ez-chart/components/LineChart.d.ts +9 -0
  129. package/dist/types/components/ez-chart/components/PieChart.d.ts +9 -0
  130. package/dist/types/components/ez-chart/components/index.d.ts +5 -0
  131. package/dist/types/components/ez-chart/ez-chart.d.ts +58 -0
  132. package/dist/types/components/ez-chart/interfaces/ChartAxis.d.ts +7 -0
  133. package/dist/types/components/ez-chart/interfaces/ChartContext.d.ts +11 -0
  134. package/dist/types/components/ez-chart/interfaces/ChartOptions.d.ts +10 -0
  135. package/dist/types/components/ez-chart/interfaces/ChartSerie.d.ts +20 -0
  136. package/dist/types/components/ez-chart/interfaces/ChartStrategies.d.ts +7 -0
  137. package/dist/types/components/ez-chart/interfaces/ChartType.d.ts +7 -0
  138. package/dist/types/components/ez-chart/interfaces/index.d.ts +5 -0
  139. package/dist/types/components/ez-chart/types/BaseHighChartsRender.d.ts +15 -0
  140. package/dist/types/components/ez-form/ez-form.d.ts +20 -1
  141. package/dist/types/components/ez-form-view/custom-input/ez-custom-form-input.d.ts +43 -0
  142. package/dist/types/components/ez-form-view/ez-form-view.d.ts +11 -0
  143. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +42 -0
  144. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +15 -0
  145. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +2 -0
  146. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +7 -1
  147. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +19 -0
  148. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +14 -0
  149. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.d.ts +11 -0
  150. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.d.ts +11 -0
  151. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +3 -0
  152. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +15 -0
  153. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellRender.d.ts +10 -0
  154. package/dist/types/components/ez-grid/ez-grid.d.ts +39 -1
  155. package/dist/types/components/ez-grid/interfaces/ICustomFormatter.d.ts +5 -0
  156. package/dist/types/components/ez-grid/interfaces/index.d.ts +1 -0
  157. package/dist/types/components/ez-grid/subcomponents/utils/selectionCounterUtils.d.ts +4 -0
  158. package/dist/types/components/ez-grid/test/resources/gridDataUnit.d.ts +2 -0
  159. package/dist/types/components/ez-list/ez-list.d.ts +5 -0
  160. package/dist/types/components/ez-number-input/ez-number-input.d.ts +3 -0
  161. package/dist/types/components/ez-search/ez-search.d.ts +3 -1
  162. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +3 -2
  163. package/dist/types/components.d.ts +231 -4
  164. package/dist/types/utils/customEditor/interfaces/ICustomEditor.d.ts +29 -0
  165. package/dist/types/utils/customEditor/interfaces/ICustomEditorInfo.d.ts +5 -0
  166. package/dist/types/utils/customRender/interfaces/ICustomRender.d.ts +29 -0
  167. package/dist/types/utils/customRender/interfaces/ICustomRenderInfo.d.ts +5 -0
  168. package/dist/types/utils/form/DataBinder.d.ts +3 -0
  169. package/dist/types/utils/form/test/resources/metadataTest.d.ts +2 -0
  170. package/dist/types/utils/index.d.ts +2 -0
  171. package/package.json +2 -1
  172. package/react/components.d.ts +2 -0
  173. package/react/components.js +2 -0
  174. package/react/components.js.map +1 -1
  175. package/dist/ezui/p-0447d17c.entry.js +0 -1
  176. package/dist/ezui/p-20ec22c0.entry.js +0 -1
  177. package/dist/ezui/p-2a1a0e04.entry.js +0 -1
  178. package/dist/ezui/p-44c5b6a5.entry.js +0 -1
  179. package/dist/ezui/p-5ef056ce.entry.js +0 -1
  180. package/dist/ezui/p-637f69f2.entry.js +0 -1
  181. package/dist/ezui/p-8defa6d3.entry.js +0 -1
  182. package/dist/ezui/p-99ead599.entry.js +0 -1
  183. package/dist/ezui/p-9aefaa52.entry.js +0 -1
  184. package/dist/ezui/p-b041333c.entry.js +0 -1
  185. package/dist/ezui/p-b567fa8c.entry.js +0 -1
  186. package/dist/ezui/p-bae3d0aa.entry.js +0 -1
  187. package/dist/ezui/p-cc2dc4f4.entry.js +0 -1
  188. package/dist/ezui/p-db77a984.entry.js +0 -1
@@ -0,0 +1,253 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { CustomEditorSource } from '../../../utils/customEditor/interfaces/ICustomEditor';
3
+ import { HTMLBuilder, StringUtils } from '@sankhyalabs/core';
4
+ export class EzCustomFormInput {
5
+ constructor() {
6
+ this.gui = undefined;
7
+ this.customEditor = undefined;
8
+ this.formViewField = undefined;
9
+ this.value = undefined;
10
+ this.detailContext = undefined;
11
+ this.builderFallback = undefined;
12
+ }
13
+ /**
14
+ * Aplica foco no campo.
15
+ */
16
+ async setFocus() {
17
+ var _a, _b;
18
+ (_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["setFocus"]) === null || _b === void 0 ? void 0 : _b.call(_a);
19
+ }
20
+ /**
21
+ * Remove o foco do campo.
22
+ */
23
+ async setBlur() {
24
+ var _a, _b;
25
+ (_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["setBlur"]) === null || _b === void 0 ? void 0 : _b.call(_a);
26
+ }
27
+ /**
28
+ * Retorna se o conteúdo é inválido.
29
+ */
30
+ async isInvalid() {
31
+ var _a, _b;
32
+ return ((_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["isInvalid"]) === null || _b === void 0 ? void 0 : _b.call(_a)) || false;
33
+ }
34
+ getContent() {
35
+ var _a, _b;
36
+ const fieldProps = new Map();
37
+ for (const prop in this.formViewField.props) {
38
+ fieldProps.set(prop, this.formViewField.props[prop]);
39
+ }
40
+ const params = {
41
+ value: this.value,
42
+ name: this.formViewField.name,
43
+ currentEditor: this.builderFallback(this.formViewField),
44
+ setValue: (value) => this.setValue(value),
45
+ getValue: this.getValue,
46
+ editorMetadata: {
47
+ label: this.formViewField.label,
48
+ hidden: ((_a = this.formViewField.props) === null || _a === void 0 ? void 0 : _a.visible) === false,
49
+ userInterface: this.formViewField.userInterface,
50
+ options: (_b = this.formViewField.props) === null || _b === void 0 ? void 0 : _b.options,
51
+ props: this.formViewField.props ? fieldProps : undefined,
52
+ optionLoader: this.formViewField.optionLoader
53
+ },
54
+ source: CustomEditorSource.FORM,
55
+ detailContext: this.detailContext
56
+ };
57
+ let gui = this.customEditor.getEditorElement(params);
58
+ if (!gui) {
59
+ gui = this.builderFallback(this.formViewField);
60
+ this.handleValue(gui);
61
+ this.gui = gui;
62
+ return;
63
+ }
64
+ if (!(gui instanceof HTMLElement) && typeof gui !== 'string') {
65
+ this.handleValue(gui);
66
+ this.gui = gui;
67
+ return;
68
+ }
69
+ if (typeof gui === 'string') {
70
+ gui = HTMLBuilder.parseElement(gui);
71
+ }
72
+ gui.setAttribute('value', this.value);
73
+ this.gui = h("div", { key: StringUtils.generateUUID(), ref: el => el && el.appendChild(gui) });
74
+ }
75
+ setValue(value) {
76
+ this.value = value;
77
+ }
78
+ getValue() {
79
+ return this.value;
80
+ }
81
+ handleValue(gui) {
82
+ //@ts-ignore
83
+ gui.$children$.forEach((child) => {
84
+ child.$attrs$.value = this.value;
85
+ });
86
+ }
87
+ componentWillRender() {
88
+ this.getContent();
89
+ }
90
+ render() {
91
+ return (h(Host, null, this.gui));
92
+ }
93
+ static get is() { return "ez-custom-form-input"; }
94
+ static get encapsulation() { return "scoped"; }
95
+ static get properties() {
96
+ return {
97
+ "customEditor": {
98
+ "type": "unknown",
99
+ "mutable": false,
100
+ "complexType": {
101
+ "original": "ICustomEditor",
102
+ "resolved": "ICustomEditor",
103
+ "references": {
104
+ "ICustomEditor": {
105
+ "location": "import",
106
+ "path": "../../../utils/customEditor/interfaces/ICustomEditor"
107
+ }
108
+ }
109
+ },
110
+ "required": false,
111
+ "optional": false,
112
+ "docs": {
113
+ "tags": [],
114
+ "text": "Inst\u00E2ncia do editor customizado."
115
+ }
116
+ },
117
+ "formViewField": {
118
+ "type": "unknown",
119
+ "mutable": false,
120
+ "complexType": {
121
+ "original": "IFormViewField",
122
+ "resolved": "IFormViewField",
123
+ "references": {
124
+ "IFormViewField": {
125
+ "location": "import",
126
+ "path": "../interfaces"
127
+ }
128
+ }
129
+ },
130
+ "required": false,
131
+ "optional": false,
132
+ "docs": {
133
+ "tags": [],
134
+ "text": "Campo que o elemento customizado representa."
135
+ }
136
+ },
137
+ "value": {
138
+ "type": "any",
139
+ "mutable": true,
140
+ "complexType": {
141
+ "original": "any",
142
+ "resolved": "any",
143
+ "references": {}
144
+ },
145
+ "required": false,
146
+ "optional": false,
147
+ "docs": {
148
+ "tags": [],
149
+ "text": "Valores dos campos do formul\u00E1rio."
150
+ },
151
+ "attribute": "value",
152
+ "reflect": false
153
+ },
154
+ "detailContext": {
155
+ "type": "string",
156
+ "mutable": false,
157
+ "complexType": {
158
+ "original": "string",
159
+ "resolved": "string",
160
+ "references": {}
161
+ },
162
+ "required": false,
163
+ "optional": false,
164
+ "docs": {
165
+ "tags": [],
166
+ "text": "Define de qual contexto o editor est\u00E1 sendo acionado."
167
+ },
168
+ "attribute": "detail-context",
169
+ "reflect": false
170
+ },
171
+ "builderFallback": {
172
+ "type": "unknown",
173
+ "mutable": false,
174
+ "complexType": {
175
+ "original": "(field: IFormViewField) => HTMLElement",
176
+ "resolved": "(field: IFormViewField) => HTMLElement",
177
+ "references": {
178
+ "IFormViewField": {
179
+ "location": "import",
180
+ "path": "../interfaces"
181
+ },
182
+ "HTMLElement": {
183
+ "location": "global"
184
+ }
185
+ }
186
+ },
187
+ "required": false,
188
+ "optional": false,
189
+ "docs": {
190
+ "tags": [],
191
+ "text": "Builder original do FormView que ser\u00E1 chamado caso o custom n\u00E3o retorne nenhum valor."
192
+ }
193
+ }
194
+ };
195
+ }
196
+ static get states() {
197
+ return {
198
+ "gui": {}
199
+ };
200
+ }
201
+ static get methods() {
202
+ return {
203
+ "setFocus": {
204
+ "complexType": {
205
+ "signature": "() => Promise<void>",
206
+ "parameters": [],
207
+ "references": {
208
+ "Promise": {
209
+ "location": "global"
210
+ }
211
+ },
212
+ "return": "Promise<void>"
213
+ },
214
+ "docs": {
215
+ "text": "Aplica foco no campo.",
216
+ "tags": []
217
+ }
218
+ },
219
+ "setBlur": {
220
+ "complexType": {
221
+ "signature": "() => Promise<void>",
222
+ "parameters": [],
223
+ "references": {
224
+ "Promise": {
225
+ "location": "global"
226
+ }
227
+ },
228
+ "return": "Promise<void>"
229
+ },
230
+ "docs": {
231
+ "text": "Remove o foco do campo.",
232
+ "tags": []
233
+ }
234
+ },
235
+ "isInvalid": {
236
+ "complexType": {
237
+ "signature": "() => Promise<boolean>",
238
+ "parameters": [],
239
+ "references": {
240
+ "Promise": {
241
+ "location": "global"
242
+ }
243
+ },
244
+ "return": "Promise<boolean>"
245
+ },
246
+ "docs": {
247
+ "text": "Retorna se o conte\u00FAdo \u00E9 inv\u00E1lido.",
248
+ "tags": []
249
+ }
250
+ }
251
+ };
252
+ }
253
+ }
@@ -4,11 +4,33 @@ import { ElementIDUtils, UserInterface } from '@sankhyalabs/core';
4
4
  import { FormItems } from './structure';
5
5
  export class EzFormView {
6
6
  constructor() {
7
+ this._customEditors = new Map();
7
8
  this.fields = undefined;
8
9
  }
9
10
  async showUp() {
10
11
  this._element.scrollIntoView({ behavior: "smooth", block: "start" });
11
12
  }
13
+ /**
14
+ * Registra um editor customizado para campos da grade e formulário.
15
+ */
16
+ async addCustomEditor(fieldName, customEditor, detailContext) {
17
+ const newCustomEditors = new Map(this._customEditors);
18
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
19
+ this._customEditors = newCustomEditors;
20
+ }
21
+ /**
22
+ * Altera/adiciona uma propriedade nos metados do campo.
23
+ */
24
+ async setFieldProp(fieldName, propName, value) {
25
+ const fields = this.fields.map(field => {
26
+ if (field.name === fieldName && (value || value === 0)) {
27
+ field.props = field.props || {};
28
+ field.props[propName] = value;
29
+ }
30
+ return field;
31
+ });
32
+ this.fields = [...fields];
33
+ }
12
34
  groupFields(fields) {
13
35
  const result = new Map();
14
36
  fields.forEach(item => {
@@ -28,7 +50,8 @@ export class EzFormView {
28
50
  return result;
29
51
  }
30
52
  componentDidRender() {
31
- this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
53
+ this._formElements = Array.from(this._element.querySelectorAll("[data-field-name]"));
54
+ this.ezContentReady.emit(this._formElements);
32
55
  const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
33
56
  this.formItemsReady.emit(formItems);
34
57
  }
@@ -39,9 +62,15 @@ export class EzFormView {
39
62
  ].includes(userInterface);
40
63
  }
41
64
  buildFormItemElement(item, classItem = "") {
65
+ var _a;
42
66
  if (this.isItemFullWidth(item.userInterface)) {
43
67
  classItem += " input-full_width";
44
68
  }
69
+ if (this._customEditors.has(item.name)) {
70
+ const value = (_a = this._formElements.map(el => ({ name: el.dataset.fieldName, value: el['value'] })).find(field => field.name === item.name)) === null || _a === void 0 ? void 0 : _a.value;
71
+ const customEditor = this._customEditors.get(item.name).customEditor;
72
+ return h("div", { class: classItem }, h("ez-custom-form-input", { "data-field-name": item.name, customEditor: customEditor, formViewField: item, builderFallback: fieldBuilder, value: value }));
73
+ }
45
74
  return h("div", { class: classItem }, fieldBuilder(item));
46
75
  }
47
76
  render() {
@@ -102,6 +131,11 @@ export class EzFormView {
102
131
  }
103
132
  };
104
133
  }
134
+ static get states() {
135
+ return {
136
+ "_customEditors": {}
137
+ };
138
+ }
105
139
  static get events() {
106
140
  return [{
107
141
  "method": "ezContentReady",
@@ -164,6 +198,60 @@ export class EzFormView {
164
198
  "text": "",
165
199
  "tags": []
166
200
  }
201
+ },
202
+ "addCustomEditor": {
203
+ "complexType": {
204
+ "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
205
+ "parameters": [{
206
+ "tags": [],
207
+ "text": ""
208
+ }, {
209
+ "tags": [],
210
+ "text": ""
211
+ }, {
212
+ "tags": [],
213
+ "text": ""
214
+ }],
215
+ "references": {
216
+ "Promise": {
217
+ "location": "global"
218
+ },
219
+ "ICustomEditor": {
220
+ "location": "import",
221
+ "path": "../../utils/customEditor/interfaces/ICustomEditor"
222
+ }
223
+ },
224
+ "return": "Promise<void>"
225
+ },
226
+ "docs": {
227
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
228
+ "tags": []
229
+ }
230
+ },
231
+ "setFieldProp": {
232
+ "complexType": {
233
+ "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
234
+ "parameters": [{
235
+ "tags": [],
236
+ "text": ""
237
+ }, {
238
+ "tags": [],
239
+ "text": ""
240
+ }, {
241
+ "tags": [],
242
+ "text": ""
243
+ }],
244
+ "references": {
245
+ "Promise": {
246
+ "location": "global"
247
+ }
248
+ },
249
+ "return": "Promise<void>"
250
+ },
251
+ "docs": {
252
+ "text": "Altera/adiciona uma propriedade nos metados do campo.",
253
+ "tags": []
254
+ }
167
255
  }
168
256
  };
169
257
  }
@@ -1,7 +1,8 @@
1
1
  import { h } from "@stencil/core";
2
2
  export const buildDecimal = ({ name, label, readOnly, props, contextName, canShowError }) => {
3
- const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
4
- const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
3
+ var _a, _b;
4
+ const precision = Number((_a = props === null || props === void 0 ? void 0 : props.precision) !== null && _a !== void 0 ? _a : 2);
5
+ const prettyPrecision = Number((_b = props === null || props === void 0 ? void 0 : props.prettyPrecision) !== null && _b !== void 0 ? _b : precision);
5
6
  return buildNumeric(name, label, readOnly, precision, prettyPrecision, contextName, canShowError);
6
7
  };
7
8
  export const buildInteger = ({ name, label, readOnly, contextName, canShowError }) => {
@@ -1,11 +1,11 @@
1
1
  import { ApplicationContext, DataType, MaskFormatter, NumberUtils, SortMode, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
- import { Grid, } from 'ag-grid-community';
2
+ import { Grid } from 'ag-grid-community';
3
3
  import { Grid as EnterpriseGrid, LicenseManager } from 'ag-grid-enterprise';
4
4
  import DataSource from './DataSource';
5
5
  import { EzGridCustomHeader } from './components/EzGridCustomHeader';
6
6
  import { CellRendererStatus } from './components/cellRendererStatus';
7
7
  import SelectionHeader from './components/selectionHeader';
8
- import gridTerms from './i18n/pt-BR.js';
8
+ import gridTerms from './i18n/pt-BR';
9
9
  import { DISTINCT_FILTER_NAME_PREFIX, EZ_GRID_LOADING_SOURCE } from '../../../../utils/constants';
10
10
  import GridEditionManager from './GridEditionManager';
11
11
  export default class AgGridController {
@@ -42,6 +42,7 @@ export default class AgGridController {
42
42
  this._gridConfig = [];
43
43
  this._filteredColumns = new Map();
44
44
  this._filterColumnleftPosition = 0;
45
+ this._customFormatters = new Map();
45
46
  this._enterprise = enterprise;
46
47
  }
47
48
  getGridConfig() {
@@ -118,6 +119,8 @@ export default class AgGridController {
118
119
  }
119
120
  initDatagrid(container, options) {
120
121
  var _a;
122
+ this._options = options;
123
+ this._container = container;
121
124
  if (this._grid === undefined) {
122
125
  LicenseManager.setLicenseKey(ApplicationContext.getContextValue('__EZUI__GRID_LICENSE__'));
123
126
  this._columnStateChangeCallback = options.onColumnStateChange;
@@ -125,7 +128,7 @@ export default class AgGridController {
125
128
  this._doubleClickCallBack = options.onDoubleClick;
126
129
  this._multipleSelection = options.allowMultipleSelection;
127
130
  this._dataUnit = options.dataUnit;
128
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled);
131
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders);
129
132
  this._statusResolver = options.statusResolver;
130
133
  if (this._dataUnit) {
131
134
  this._dataUnit.sortingProvider = this;
@@ -187,6 +190,7 @@ export default class AgGridController {
187
190
  this.selectRows((selection === null || selection === void 0 ? void 0 : selection.recordIds) || [], true);
188
191
  }
189
192
  this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
193
+ this._customFormatters = options.customFormatters;
190
194
  }
191
195
  }
192
196
  processFormatterCellCallback(params) {
@@ -470,12 +474,33 @@ export default class AgGridController {
470
474
  throw new Error('Erro interno: Grid ainda não inicializado.');
471
475
  }
472
476
  this._gridOptions.api.refreshServerSide({ purge: true });
477
+ this._options.onRefresh();
478
+ }
479
+ focusOnGridContainer() {
480
+ this._container.setAttribute('tabindex', '-1');
481
+ this._container.focus();
482
+ }
483
+ setFocus() {
484
+ var _a, _b;
485
+ if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length) {
486
+ this.setFocusFirstRow();
487
+ }
488
+ else {
489
+ this.focusOnGridContainer();
490
+ }
491
+ }
492
+ setAutoFocus(autoFocus) {
493
+ var _a;
494
+ (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setAutoFocus(autoFocus);
473
495
  }
474
496
  setFocusFirstRow() {
475
497
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
476
498
  if (firstRow) {
477
499
  this.setFocusOnRow(firstRow.rowIndex);
478
500
  }
501
+ else {
502
+ this.focusOnGridContainer();
503
+ }
479
504
  }
480
505
  setFocusLastRow() {
481
506
  const lastRow = this._gridOptions.api.getDisplayedRowAtIndex(this._gridOptions.api.getLastDisplayedRow());
@@ -554,7 +579,7 @@ export default class AgGridController {
554
579
  //Como vamos reordenar, precisamos considerar o deslocamento provocado por elas.
555
580
  const columnsOffset = colDef.length - columns.length;
556
581
  let sort = [];
557
- state.forEach((cfgColumn, index) => {
582
+ state === null || state === void 0 ? void 0 : state.forEach((cfgColumn, index) => {
558
583
  const colWidth = this.getColumnWidth(cfgColumn);
559
584
  this._gridOptions.columnApi.moveColumn(cfgColumn.name, index + columnsOffset);
560
585
  this._gridOptions.columnApi.setColumnWidth(cfgColumn.name, colWidth);
@@ -651,12 +676,19 @@ export default class AgGridController {
651
676
  showColumnFilter: (leftPosition) => this.showFilterColumn({ columnName: source.name, columnLabel: source.label, leftPosition, filteredOptions: this._filteredColumns.get(source.name), fromIcon: true }),
652
677
  },
653
678
  valueFormatter: params => {
654
- if (params.value === undefined) {
679
+ if (params.value === undefined || params.value === null) {
655
680
  return "";
656
681
  }
657
682
  if (params.value instanceof Promise) {
658
683
  return "Carregando...";
659
684
  }
685
+ const customFormatter = this._customFormatters.get(source.name);
686
+ if (customFormatter) {
687
+ const formattedValue = customFormatter.format(params.value, source, params.data.__record__id__);
688
+ if (formattedValue) {
689
+ return formattedValue;
690
+ }
691
+ }
660
692
  if (this._dataUnit) {
661
693
  return this._dataUnit.getFormattedValue(source.name, params.value);
662
694
  }
@@ -665,6 +697,13 @@ export default class AgGridController {
665
697
  cellStyle: this.getStyleByColumn(source),
666
698
  });
667
699
  }
700
+ setCustomFormatters(customFormatters) {
701
+ this._customFormatters = customFormatters;
702
+ }
703
+ refreshSelectedRows() {
704
+ const selectedNodes = this._gridOptions.api.getSelectedNodes();
705
+ this._gridOptions.api.redrawRows({ rowNodes: selectedNodes });
706
+ }
668
707
  getInitCellStyle() {
669
708
  return {
670
709
  'line-height': this.getRowHeight() - 1 + 'px',
@@ -840,4 +879,22 @@ export default class AgGridController {
840
879
  const labelSize = (((_b = field === null || field === void 0 ? void 0 : field.label) === null || _b === void 0 ? void 0 : _b.length) || 0) * this.DEFAULT_FONT_SIZE + this.DEFAULT_ICON_SIZE;
841
880
  return labelSize > this.DEFAULT_MAX_SIZE ? this.DEFAULT_MAX_SIZE : labelSize;
842
881
  }
882
+ setCellEditors(customEditors) {
883
+ var _a;
884
+ if (!this._editionManager) {
885
+ this._customEditors = customEditors;
886
+ return;
887
+ }
888
+ this._editionManager.setCellEditors(customEditors);
889
+ (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
890
+ }
891
+ setCellRenders(customRenders) {
892
+ var _a;
893
+ if (!this._editionManager) {
894
+ this._customRenders = customRenders;
895
+ return;
896
+ }
897
+ this._editionManager.setCellRenders(customRenders);
898
+ (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
899
+ }
843
900
  }
@@ -10,6 +10,11 @@ export default class DataSource {
10
10
  });
11
11
  }
12
12
  }
13
+ handleFocusFirstRow() {
14
+ if (this._options.autoFocus) {
15
+ this._controller.setFocusFirstRow();
16
+ }
17
+ }
13
18
  isSilentChange(action) {
14
19
  //TODO: Provisorio p/ não atualizar a grade quando a alteração for apenas de campos transisntes
15
20
  var _a, _b;
@@ -41,6 +46,7 @@ export default class DataSource {
41
46
  this._options.onPaginationChange(this._dataUnit.getPaginationInfo(), action.payload.selectFirstRecord);
42
47
  }
43
48
  this.updateSelection();
49
+ this.handleFocusFirstRow();
44
50
  break;
45
51
  case Action.PAGINATION_UPDATED:
46
52
  if (this._options) {
@@ -83,6 +89,9 @@ export default class DataSource {
83
89
  this._controller.selectRows(selectionInfo.recordIds, true);
84
90
  }
85
91
  }
92
+ setAutoFocus(autoFocus) {
93
+ this._options.autoFocus = autoFocus;
94
+ }
86
95
  getRows(params) {
87
96
  if (this.needReload(params)) {
88
97
  this._lastLoadingParams = params;
@@ -2,8 +2,10 @@ import { UserInterface } from "@sankhyalabs/core";
2
2
  import { KeyCode } from "ag-grid-community";
3
3
  import { RecordValidationProcessor } from "../../../../utils/validators/recordvalidator/RecordValidationProcessor";
4
4
  import EzCellEditor from "./editor/EzCellEditor";
5
+ import EzGridCustomCellEditor from "./components/EzGridCustomCellEditor";
6
+ import EzGridCustomCellRender from "./components/EzGridCustomCellRender";
5
7
  export default class GridEditionManager {
6
- constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled) {
8
+ constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders) {
7
9
  this._dataUnit = dataUnit;
8
10
  this._recordValidationProcessor = new RecordValidationProcessor(this._dataUnit, {
9
11
  getRequiredFields: () => this.getRequiredFields(),
@@ -12,6 +14,8 @@ export default class GridEditionManager {
12
14
  }, recordsValidator);
13
15
  this._useEnterLikeTab = useEnterLikeTab;
14
16
  this._editionIsDisabled = editionIsDisabled;
17
+ this._customEditors = customEditors;
18
+ this._customRenders = customRenders;
15
19
  }
16
20
  configureGrid(options) {
17
21
  this._gridOptions = options;
@@ -78,6 +82,30 @@ export default class GridEditionManager {
78
82
  col.suppressKeyboardEvent = (params) => {
79
83
  return params.event.key === KeyCode.ENTER;
80
84
  };
85
+ col.cellEditorSelector = (params) => {
86
+ var _a;
87
+ if ((_a = this._customEditors) === null || _a === void 0 ? void 0 : _a.has(params.colDef.field)) {
88
+ const customEditor = this._customEditors.get(params.colDef.field);
89
+ return {
90
+ component: EzGridCustomCellEditor,
91
+ params: {
92
+ customEditorsInfo: customEditor,
93
+ }
94
+ };
95
+ }
96
+ };
97
+ col.cellRendererSelector = (params) => {
98
+ var _a;
99
+ if ((_a = this._customRenders) === null || _a === void 0 ? void 0 : _a.has(params.colDef.field)) {
100
+ const customRender = this._customRenders.get(params.colDef.field);
101
+ return {
102
+ component: EzGridCustomCellRender,
103
+ params: {
104
+ customRendersInfo: customRender,
105
+ }
106
+ };
107
+ }
108
+ };
81
109
  return col;
82
110
  }
83
111
  getRequiredFields() {
@@ -219,6 +247,12 @@ export default class GridEditionManager {
219
247
  this._lastCellEdited = { rowIndex: event.rowIndex, column: event.column, rowPinned: undefined };
220
248
  }
221
249
  }
250
+ setCellEditors(customEditors) {
251
+ this._customEditors = customEditors;
252
+ }
253
+ setCellRenders(customRenders) {
254
+ this._customRenders = customRenders;
255
+ }
222
256
  }
223
257
  class TargetEdition {
224
258
  constructor(rowIndex, column, backwards) {
@@ -0,0 +1,58 @@
1
+ import { HTMLBuilder } from "@sankhyalabs/core";
2
+ import { CustomEditorSource } from "../../../../../utils/customEditor/interfaces/ICustomEditor";
3
+ import EzCellEditor from "../editor/EzCellEditor";
4
+ export default class EzGridCustomCellEditor extends EzCellEditor {
5
+ init(params) {
6
+ var _a, _b;
7
+ this._value = params.value;
8
+ this._fieldName = params.column.getColId();
9
+ this._customEditorInstance = params.customEditorsInfo.customEditor;
10
+ super.init(params);
11
+ this._defaultGui = this.getDefaultGui();
12
+ const fieldMetadata = super.getFieldMetadata();
13
+ this._params = {
14
+ value: params.value,
15
+ charPress: params.charPress,
16
+ currentEditor: this._defaultGui,
17
+ name: this._fieldName,
18
+ source: CustomEditorSource.GRID,
19
+ detailContext: params.customEditorsInfo.detailContext,
20
+ setValue: (value) => this.setValue(value),
21
+ getValue: () => this.getValue(),
22
+ editorMetadata: {
23
+ hidden: ((_a = fieldMetadata.props) === null || _a === void 0 ? void 0 : _a.visible) === false,
24
+ label: fieldMetadata.label,
25
+ userInterface: fieldMetadata.userInterface,
26
+ props: fieldMetadata.props,
27
+ optionLoader: fieldMetadata.optionLoader,
28
+ options: ((_b = fieldMetadata.props) === null || _b === void 0 ? void 0 : _b.options) || {},
29
+ }
30
+ };
31
+ }
32
+ getDefaultGui() {
33
+ const gui = super.getGui();
34
+ gui.value = this._value;
35
+ gui.onkeyup = (event) => {
36
+ const value = event.target.value;
37
+ this.setValue(value);
38
+ };
39
+ return gui;
40
+ }
41
+ getGui() {
42
+ const editorElement = this._customEditorInstance.getEditorElement(this._params);
43
+ if (!editorElement) {
44
+ return this._defaultGui;
45
+ }
46
+ if (typeof editorElement === 'string') {
47
+ const element = HTMLBuilder.parseElement(editorElement);
48
+ return element;
49
+ }
50
+ return editorElement;
51
+ }
52
+ setValue(value) {
53
+ this._value = value;
54
+ }
55
+ getValue() {
56
+ return this._value;
57
+ }
58
+ }