@sankhyalabs/ezui 5.21.4 → 5.22.0-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/cjs/ICustomRender-6fafffce.js +13 -0
  2. package/dist/cjs/ez-actions-button.cjs.entry.js +1 -0
  3. package/dist/cjs/ez-chart.cjs.entry.js +435 -0
  4. package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -0
  5. package/dist/cjs/ez-combo-box.cjs.entry.js +1 -0
  6. package/dist/cjs/{ez-text-edit.cjs.entry.js → ez-custom-form-input_2.cjs.entry.js} +99 -0
  7. package/dist/cjs/ez-form-view.cjs.entry.js +37 -5
  8. package/dist/cjs/ez-form.cjs.entry.js +81 -2
  9. package/dist/cjs/ez-grid.cjs.entry.js +312 -40
  10. package/dist/cjs/ez-list.cjs.entry.js +10 -2
  11. package/dist/cjs/ez-modal-container.cjs.entry.js +2 -1
  12. package/dist/cjs/ez-modal.cjs.entry.js +7 -1
  13. package/dist/cjs/ez-number-input.cjs.entry.js +37 -31
  14. package/dist/cjs/ez-scroller_2.cjs.entry.js +222 -0
  15. package/dist/cjs/ez-search.cjs.entry.js +40 -33
  16. package/dist/cjs/ez-sidebar-navigator.cjs.entry.js +92 -0
  17. package/dist/cjs/ez-split-item.cjs.entry.js +1 -0
  18. package/dist/cjs/ez-tabselector.cjs.entry.js +8 -2
  19. package/dist/cjs/{ez-scroller_3.cjs.entry.js → ez-tree.cjs.entry.js} +0 -215
  20. package/dist/cjs/ezui.cjs.js +1 -1
  21. package/dist/cjs/index-a7b0c73d.js +16 -4
  22. package/dist/cjs/loader.cjs.js +1 -1
  23. package/dist/collection/collection-manifest.json +3 -0
  24. package/dist/collection/components/ez-chart/components/BarChart.js +27 -0
  25. package/dist/collection/components/ez-chart/components/ColumnChart.js +27 -0
  26. package/dist/collection/components/ez-chart/components/DonutChart.js +42 -0
  27. package/dist/collection/components/ez-chart/components/LineChart.js +27 -0
  28. package/dist/collection/components/ez-chart/components/PieChart.js +45 -0
  29. package/dist/collection/components/ez-chart/components/index.js +5 -0
  30. package/dist/collection/components/ez-chart/ez-chart.css +5 -0
  31. package/dist/collection/components/ez-chart/ez-chart.js +286 -0
  32. package/dist/collection/components/ez-chart/interfaces/ChartAxis.js +1 -0
  33. package/dist/collection/components/ez-chart/interfaces/ChartContext.js +14 -0
  34. package/dist/collection/components/ez-chart/interfaces/ChartOptions.js +1 -0
  35. package/dist/collection/components/ez-chart/interfaces/ChartSerie.js +1 -0
  36. package/dist/collection/components/ez-chart/interfaces/ChartStrategies.js +1 -0
  37. package/dist/collection/components/ez-chart/interfaces/ChartType.js +8 -0
  38. package/dist/collection/components/ez-chart/interfaces/index.js +5 -0
  39. package/dist/collection/components/ez-chart/test/mock-chart.js +137 -0
  40. package/dist/collection/components/ez-chart/types/BaseHighChartsRender.js +146 -0
  41. package/dist/collection/components/ez-form/ez-form.js +130 -4
  42. package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +278 -0
  43. package/dist/collection/components/ez-form-view/ez-form-view.js +110 -1
  44. package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +3 -2
  45. package/dist/collection/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.js +3 -2
  46. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +51 -22
  47. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +6 -1
  48. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +36 -2
  49. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +59 -0
  50. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.js +40 -0
  51. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.js +11 -0
  52. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.js +11 -0
  53. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +10 -3
  54. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellRender.js +40 -0
  55. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IUICellRender.js +1 -0
  56. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +3 -2
  57. package/dist/collection/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.js +40 -0
  58. package/dist/collection/components/ez-grid/ez-grid.js +235 -12
  59. package/dist/collection/components/ez-grid/interfaces/ICustomFormatter.js +1 -0
  60. package/dist/collection/components/ez-grid/interfaces/index.js +1 -0
  61. package/dist/collection/components/ez-grid/test/resources/gridDataUnit.js +19 -0
  62. package/dist/collection/components/ez-list/ez-list.js +28 -2
  63. package/dist/collection/components/ez-modal/ez-modal.js +25 -1
  64. package/dist/collection/components/ez-modal-container/ez-modal-container.js +20 -1
  65. package/dist/collection/components/ez-number-input/ez-number-input.js +46 -31
  66. package/dist/collection/components/ez-search/ez-search.js +39 -33
  67. package/dist/collection/components/ez-sidebar-button/ez-sidebar-button.css +6 -2
  68. package/dist/collection/components/ez-sidebar-button/ez-sidebar-button.js +1 -1
  69. package/dist/collection/components/ez-sidebar-navigator/ez-sidebar-navigator.css +180 -0
  70. package/dist/collection/components/ez-sidebar-navigator/ez-sidebar-navigator.js +293 -0
  71. package/dist/collection/components/ez-sidebar-navigator/interfaces/ModeMenuEnum.js +5 -0
  72. package/dist/collection/components/ez-sidebar-navigator/interfaces/SizeMenuEnum.js +6 -0
  73. package/dist/collection/components/ez-sidebar-navigator/interfaces/TypeMenuEnum.js +6 -0
  74. package/dist/collection/components/ez-sidebar-navigator/interfaces/index.js +3 -0
  75. package/dist/collection/components/ez-sidebar-navigator/messages/constants.js +5 -0
  76. package/dist/collection/components/ez-tabselector/ez-tabselector.js +34 -2
  77. package/dist/collection/utils/customEditor/interfaces/ICustomEditor.js +5 -0
  78. package/dist/collection/utils/customEditor/interfaces/ICustomEditorInfo.js +1 -0
  79. package/dist/collection/utils/customRender/interfaces/ICustomRender.js +5 -0
  80. package/dist/collection/utils/customRender/interfaces/ICustomRenderInfo.js +1 -0
  81. package/dist/collection/utils/form/DataBinder.js +31 -1
  82. package/dist/collection/utils/form/test/DataBinder.test.js +41 -4
  83. package/dist/collection/utils/form/test/resources/metadataTest.js +15 -0
  84. package/dist/collection/utils/index.js +2 -0
  85. package/dist/custom-elements/index.d.ts +18 -0
  86. package/dist/custom-elements/index.js +1173 -127
  87. package/dist/esm/ICustomRender-875b5a40.js +13 -0
  88. package/dist/esm/ez-actions-button.entry.js +1 -0
  89. package/dist/esm/ez-chart.entry.js +431 -0
  90. package/dist/esm/ez-collapsible-box.entry.js +1 -0
  91. package/dist/esm/ez-combo-box.entry.js +1 -0
  92. package/dist/esm/{ez-text-edit.entry.js → ez-custom-form-input_2.entry.js} +101 -3
  93. package/dist/esm/ez-form-view.entry.js +37 -5
  94. package/dist/esm/ez-form.entry.js +82 -3
  95. package/dist/esm/ez-grid.entry.js +312 -40
  96. package/dist/esm/ez-list.entry.js +10 -2
  97. package/dist/esm/ez-modal-container.entry.js +2 -1
  98. package/dist/esm/ez-modal.entry.js +7 -1
  99. package/dist/esm/ez-number-input.entry.js +38 -32
  100. package/dist/esm/ez-scroller_2.entry.js +217 -0
  101. package/dist/esm/ez-search.entry.js +40 -33
  102. package/dist/esm/ez-sidebar-navigator.entry.js +88 -0
  103. package/dist/esm/ez-split-item.entry.js +1 -0
  104. package/dist/esm/ez-tabselector.entry.js +8 -2
  105. package/dist/esm/{ez-scroller_3.entry.js → ez-tree.entry.js} +3 -216
  106. package/dist/esm/ezui.js +1 -1
  107. package/dist/esm/index-baa5e267.js +16 -4
  108. package/dist/esm/loader.js +1 -1
  109. package/dist/ezui/ezui.esm.js +1 -1
  110. package/dist/ezui/p-2097d0cf.entry.js +1 -0
  111. package/dist/ezui/{p-9fbb0f01.entry.js → p-32e553e5.entry.js} +2 -2
  112. package/dist/ezui/p-34b6916c.entry.js +1 -0
  113. package/dist/ezui/p-3b4eeeb6.entry.js +1 -0
  114. package/dist/ezui/p-42533ea4.entry.js +1 -0
  115. package/dist/ezui/p-4607fb89.js +1 -0
  116. package/dist/ezui/p-4d5235f1.entry.js +1 -0
  117. package/dist/ezui/p-5b205c80.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-8888d9ed.entry.js +1 -0
  121. package/dist/ezui/p-922ac38b.entry.js +1 -0
  122. package/dist/ezui/p-a31b9c90.entry.js +1 -0
  123. package/dist/ezui/p-aba3da00.entry.js +1 -0
  124. package/dist/ezui/p-bcb53f27.entry.js +1 -0
  125. package/dist/ezui/p-c0d9c4f8.entry.js +1 -0
  126. package/dist/ezui/p-cdc472cc.entry.js +1 -0
  127. package/dist/ezui/p-ecc2c1ec.entry.js +1 -0
  128. package/dist/ezui/p-fcf0acce.entry.js +1 -0
  129. package/dist/types/components/ez-chart/components/BarChart.d.ts +9 -0
  130. package/dist/types/components/ez-chart/components/ColumnChart.d.ts +9 -0
  131. package/dist/types/components/ez-chart/components/DonutChart.d.ts +9 -0
  132. package/dist/types/components/ez-chart/components/LineChart.d.ts +9 -0
  133. package/dist/types/components/ez-chart/components/PieChart.d.ts +9 -0
  134. package/dist/types/components/ez-chart/components/index.d.ts +5 -0
  135. package/dist/types/components/ez-chart/ez-chart.d.ts +58 -0
  136. package/dist/types/components/ez-chart/interfaces/ChartAxis.d.ts +7 -0
  137. package/dist/types/components/ez-chart/interfaces/ChartContext.d.ts +11 -0
  138. package/dist/types/components/ez-chart/interfaces/ChartOptions.d.ts +10 -0
  139. package/dist/types/components/ez-chart/interfaces/ChartSerie.d.ts +20 -0
  140. package/dist/types/components/ez-chart/interfaces/ChartStrategies.d.ts +7 -0
  141. package/dist/types/components/ez-chart/interfaces/ChartType.d.ts +7 -0
  142. package/dist/types/components/ez-chart/interfaces/index.d.ts +5 -0
  143. package/dist/types/components/ez-chart/types/BaseHighChartsRender.d.ts +15 -0
  144. package/dist/types/components/ez-form/ez-form.d.ts +20 -1
  145. package/dist/types/components/ez-form-view/custom-input/ez-custom-form-input.d.ts +48 -0
  146. package/dist/types/components/ez-form-view/ez-form-view.d.ts +16 -1
  147. package/dist/types/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.d.ts +1 -1
  148. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +37 -0
  149. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +13 -4
  150. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +1 -0
  151. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +7 -1
  152. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +19 -0
  153. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +14 -0
  154. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.d.ts +11 -0
  155. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.d.ts +11 -0
  156. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +6 -0
  157. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +15 -0
  158. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellRender.d.ts +10 -0
  159. package/dist/types/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.d.ts +6 -0
  160. package/dist/types/components/ez-grid/ez-grid.d.ts +34 -1
  161. package/dist/types/components/ez-grid/interfaces/ICustomFormatter.d.ts +5 -0
  162. package/dist/types/components/ez-grid/interfaces/index.d.ts +1 -0
  163. package/dist/types/components/ez-grid/test/resources/gridDataUnit.d.ts +2 -0
  164. package/dist/types/components/ez-list/ez-list.d.ts +5 -0
  165. package/dist/types/components/ez-modal/ez-modal.d.ts +5 -0
  166. package/dist/types/components/ez-modal-container/ez-modal-container.d.ts +4 -0
  167. package/dist/types/components/ez-number-input/ez-number-input.d.ts +3 -0
  168. package/dist/types/components/ez-search/ez-search.d.ts +4 -2
  169. package/dist/types/components/ez-sidebar-navigator/ez-sidebar-navigator.d.ts +57 -0
  170. package/dist/types/components/ez-sidebar-navigator/interfaces/ModeMenuEnum.d.ts +4 -0
  171. package/dist/types/components/ez-sidebar-navigator/interfaces/SizeMenuEnum.d.ts +5 -0
  172. package/dist/types/components/ez-sidebar-navigator/interfaces/TypeMenuEnum.d.ts +5 -0
  173. package/dist/types/components/ez-sidebar-navigator/interfaces/index.d.ts +3 -0
  174. package/dist/types/components/ez-sidebar-navigator/messages/constants.d.ts +5 -0
  175. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +2 -1
  176. package/dist/types/components.d.ts +351 -5
  177. package/dist/types/utils/customEditor/interfaces/ICustomEditor.d.ts +31 -0
  178. package/dist/types/utils/customEditor/interfaces/ICustomEditorInfo.d.ts +5 -0
  179. package/dist/types/utils/customRender/interfaces/ICustomRender.d.ts +29 -0
  180. package/dist/types/utils/customRender/interfaces/ICustomRenderInfo.d.ts +5 -0
  181. package/dist/types/utils/form/DataBinder.d.ts +5 -0
  182. package/dist/types/utils/form/test/resources/metadataTest.d.ts +2 -0
  183. package/dist/types/utils/index.d.ts +2 -0
  184. package/package.json +2 -1
  185. package/react/components.d.ts +3 -0
  186. package/react/components.js +3 -0
  187. package/react/components.js.map +1 -1
  188. package/dist/ezui/p-0447d17c.entry.js +0 -1
  189. package/dist/ezui/p-20ec22c0.entry.js +0 -1
  190. package/dist/ezui/p-2a1a0e04.entry.js +0 -1
  191. package/dist/ezui/p-2dcb50d4.entry.js +0 -1
  192. package/dist/ezui/p-30775e7f.entry.js +0 -1
  193. package/dist/ezui/p-41ac6cd9.entry.js +0 -1
  194. package/dist/ezui/p-637f69f2.entry.js +0 -1
  195. package/dist/ezui/p-786559c5.entry.js +0 -1
  196. package/dist/ezui/p-91f626d3.entry.js +0 -1
  197. package/dist/ezui/p-99ead599.entry.js +0 -1
  198. package/dist/ezui/p-b567fa8c.entry.js +0 -1
  199. package/dist/ezui/p-bae3d0aa.entry.js +0 -1
  200. package/dist/ezui/p-db77a984.entry.js +0 -1
  201. package/dist/ezui/p-f3c526cc.entry.js +0 -1
@@ -4,11 +4,34 @@ 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;
9
+ this.selectedRecord = undefined;
8
10
  }
9
11
  async showUp() {
10
12
  this._element.scrollIntoView({ behavior: "smooth", block: "start" });
11
13
  }
14
+ /**
15
+ * Registra um editor customizado para campos da grade e formulário.
16
+ */
17
+ async addCustomEditor(fieldName, customEditor, detailContext) {
18
+ const newCustomEditors = new Map(this._customEditors);
19
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
20
+ this._customEditors = newCustomEditors;
21
+ }
22
+ /**
23
+ * Altera/adiciona uma propriedade nos metados do campo.
24
+ */
25
+ async setFieldProp(fieldName, propName, value) {
26
+ const fields = this.fields.map(field => {
27
+ if (field.name === fieldName && (value || value === 0)) {
28
+ field.props = field.props || {};
29
+ field.props[propName] = value;
30
+ }
31
+ return field;
32
+ });
33
+ this.fields = [...fields];
34
+ }
12
35
  groupFields(fields) {
13
36
  const result = new Map();
14
37
  fields.forEach(item => {
@@ -28,7 +51,8 @@ export class EzFormView {
28
51
  return result;
29
52
  }
30
53
  componentDidRender() {
31
- this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
54
+ this._formElements = Array.from(this._element.querySelectorAll("[data-field-name]"));
55
+ this.ezContentReady.emit(this._formElements);
32
56
  const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
33
57
  this.formItemsReady.emit(formItems);
34
58
  }
@@ -39,9 +63,15 @@ export class EzFormView {
39
63
  ].includes(userInterface);
40
64
  }
41
65
  buildFormItemElement(item, classItem = "") {
66
+ var _a;
42
67
  if (this.isItemFullWidth(item.userInterface)) {
43
68
  classItem += " input-full_width";
44
69
  }
70
+ if (this._customEditors.has(item.name)) {
71
+ 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;
72
+ const customEditor = this._customEditors.get(item.name).customEditor;
73
+ return h("div", { class: classItem }, h("ez-custom-form-input", { "data-field-name": item.name, customEditor: customEditor, formViewField: item, builderFallback: fieldBuilder, value: value, selectedRecord: this.selectedRecord }));
74
+ }
45
75
  return h("div", { class: classItem }, fieldBuilder(item));
46
76
  }
47
77
  render() {
@@ -99,9 +129,34 @@ export class EzFormView {
99
129
  "tags": [],
100
130
  "text": "Define a lista de metadados usada para criar os campos de user interface."
101
131
  }
132
+ },
133
+ "selectedRecord": {
134
+ "type": "unknown",
135
+ "mutable": false,
136
+ "complexType": {
137
+ "original": "Record",
138
+ "resolved": "Record",
139
+ "references": {
140
+ "Record": {
141
+ "location": "import",
142
+ "path": "@sankhyalabs/core"
143
+ }
144
+ }
145
+ },
146
+ "required": false,
147
+ "optional": false,
148
+ "docs": {
149
+ "tags": [],
150
+ "text": "Define os registros da linha selecionada."
151
+ }
102
152
  }
103
153
  };
104
154
  }
155
+ static get states() {
156
+ return {
157
+ "_customEditors": {}
158
+ };
159
+ }
105
160
  static get events() {
106
161
  return [{
107
162
  "method": "ezContentReady",
@@ -164,6 +219,60 @@ export class EzFormView {
164
219
  "text": "",
165
220
  "tags": []
166
221
  }
222
+ },
223
+ "addCustomEditor": {
224
+ "complexType": {
225
+ "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
226
+ "parameters": [{
227
+ "tags": [],
228
+ "text": ""
229
+ }, {
230
+ "tags": [],
231
+ "text": ""
232
+ }, {
233
+ "tags": [],
234
+ "text": ""
235
+ }],
236
+ "references": {
237
+ "Promise": {
238
+ "location": "global"
239
+ },
240
+ "ICustomEditor": {
241
+ "location": "import",
242
+ "path": "../../utils/customEditor/interfaces/ICustomEditor"
243
+ }
244
+ },
245
+ "return": "Promise<void>"
246
+ },
247
+ "docs": {
248
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
249
+ "tags": []
250
+ }
251
+ },
252
+ "setFieldProp": {
253
+ "complexType": {
254
+ "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
255
+ "parameters": [{
256
+ "tags": [],
257
+ "text": ""
258
+ }, {
259
+ "tags": [],
260
+ "text": ""
261
+ }, {
262
+ "tags": [],
263
+ "text": ""
264
+ }],
265
+ "references": {
266
+ "Promise": {
267
+ "location": "global"
268
+ }
269
+ },
270
+ "return": "Promise<void>"
271
+ },
272
+ "docs": {
273
+ "text": "Altera/adiciona uma propriedade nos metados do campo.",
274
+ "tags": []
275
+ }
167
276
  }
168
277
  };
169
278
  }
@@ -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,4 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
- export const buildSearch = ({ name, label, readOnly, required, contextName, canShowError, optionLoader }) => {
3
- return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" }, h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, "data-context-name": contextName, key: name, canShowError: canShowError, optionLoader: optionLoader })));
2
+ export const buildSearch = ({ name, label, readOnly, required, contextName, canShowError, optionLoader, props }) => {
3
+ var _a;
4
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" }, h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, "data-context-name": contextName, key: name, canShowError: canShowError, optionLoader: optionLoader, ignoreLimitCharsToSearch: (_a = props.ignoreLimitCharsToSearch) !== null && _a !== void 0 ? _a : false })));
4
5
  };
@@ -1,5 +1,5 @@
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';
@@ -34,14 +34,13 @@ export default class AgGridController {
34
34
  this.STATUS_COL_ID = 'statusColumn';
35
35
  this.RECORD_ARCHIVE_COL_ID = '__RECORD_ARCHIVE__';
36
36
  this.BLOCK_LOAD_DEBOUNCE = 100;
37
- this.DEFAULT_FONT_SIZE = 14;
38
- this.DEFAULT_ICON_SIZE = 12;
39
- this.DEFAULT_MAX_SIZE = 200;
37
+ this.DOC_WIDTH = 1150;
40
38
  this._menuItems = [];
41
39
  this._idAttribName = '__record__id__';
42
40
  this._gridConfig = [];
43
41
  this._filteredColumns = new Map();
44
42
  this._filterColumnleftPosition = 0;
43
+ this._customFormatters = new Map();
45
44
  this._enterprise = enterprise;
46
45
  }
47
46
  getGridConfig() {
@@ -127,7 +126,7 @@ export default class AgGridController {
127
126
  this._doubleClickCallBack = options.onDoubleClick;
128
127
  this._multipleSelection = options.allowMultipleSelection;
129
128
  this._dataUnit = options.dataUnit;
130
- this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled);
129
+ this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled, options.customEditors || this._customEditors, options.customRenders || this._customRenders);
131
130
  this._statusResolver = options.statusResolver;
132
131
  if (this._dataUnit) {
133
132
  this._dataUnit.sortingProvider = this;
@@ -185,6 +184,7 @@ export default class AgGridController {
185
184
  this.selectRows((selection === null || selection === void 0 ? void 0 : selection.recordIds) || [], true);
186
185
  }
187
186
  this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
187
+ this._customFormatters = options.customFormatters;
188
188
  }
189
189
  }
190
190
  processFormatterCellCallback(params) {
@@ -483,6 +483,10 @@ export default class AgGridController {
483
483
  this.focusOnGridContainer();
484
484
  }
485
485
  }
486
+ setAutoFocus(autoFocus) {
487
+ var _a;
488
+ (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.setAutoFocus(autoFocus);
489
+ }
486
490
  setFocusFirstRow() {
487
491
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
488
492
  if (firstRow) {
@@ -568,9 +572,11 @@ export default class AgGridController {
568
572
  //Existem colunas implícitas que não tem estado, essas colunas são sempre as primeiras.
569
573
  //Como vamos reordenar, precisamos considerar o deslocamento provocado por elas.
570
574
  const columnsOffset = colDef.length - columns.length;
575
+ this._gridConfig = state;
571
576
  let sort = [];
572
- state.forEach((cfgColumn, index) => {
573
- const colWidth = this.getColumnWidth(cfgColumn);
577
+ state === null || state === void 0 ? void 0 : state.forEach((cfgColumn, index) => {
578
+ var _a;
579
+ const colWidth = (_a = this._gridOptions.columnApi.getColumn(cfgColumn.name)) === null || _a === void 0 ? void 0 : _a.getActualWidth();
574
580
  this._gridOptions.columnApi.moveColumn(cfgColumn.name, index + columnsOffset);
575
581
  this._gridOptions.columnApi.setColumnWidth(cfgColumn.name, colWidth);
576
582
  visibleColumns.push(cfgColumn.name);
@@ -585,7 +591,11 @@ export default class AgGridController {
585
591
  state: sort,
586
592
  defaultState: { sort: null },
587
593
  });
588
- this._gridConfig = state;
594
+ }
595
+ getAdaptiveWidth(width) {
596
+ const widthGrid = this._container.clientWidth;
597
+ const adaptiveWidth = (this.DOC_WIDTH * width) / widthGrid;
598
+ return Math.round(adaptiveWidth);
589
599
  }
590
600
  getColumnsState() {
591
601
  if (this._grid === undefined) {
@@ -594,13 +604,15 @@ export default class AgGridController {
594
604
  const colState = this._gridOptions.columnApi.getColumnState();
595
605
  return colState
596
606
  .map(s => {
597
- const def = this._gridOptions.columnApi.getColumn(s.colId).getColDef();
607
+ const column = this._gridOptions.columnApi.getColumn(s.colId);
608
+ const def = column.getColDef();
609
+ const width = this.getAdaptiveWidth(column.getActualWidth());
598
610
  const label = def.headerName;
599
611
  const name = def.checkboxSelection ? '__SELECTION__' : s.colId;
600
612
  const colState = { label, name };
601
613
  this.conditionalSet(colState, 'sort', s.sort);
602
614
  this.conditionalSet(colState, 'sortIndex', s.sortIndex);
603
- this.conditionalSet(colState, 'width', s.width);
615
+ this.conditionalSet(colState, 'width', width);
604
616
  this.conditionalSet(colState, 'pinned', s.pinned !== null);
605
617
  this.conditionalSet(colState, 'hidden', s.hide);
606
618
  const props = new Map();
@@ -666,12 +678,19 @@ export default class AgGridController {
666
678
  showColumnFilter: (leftPosition) => this.showFilterColumn({ columnName: source.name, columnLabel: source.label, leftPosition, filteredOptions: this._filteredColumns.get(source.name), fromIcon: true }),
667
679
  },
668
680
  valueFormatter: params => {
669
- if (params.value === undefined) {
681
+ if (params.value === undefined || params.value === null) {
670
682
  return "";
671
683
  }
672
684
  if (params.value instanceof Promise) {
673
685
  return "Carregando...";
674
686
  }
687
+ const customFormatter = this._customFormatters.get(source.name);
688
+ if (customFormatter) {
689
+ const formattedValue = customFormatter.format(params.value, source, params.data.__record__id__);
690
+ if (formattedValue) {
691
+ return formattedValue;
692
+ }
693
+ }
675
694
  if (this._dataUnit) {
676
695
  return this._dataUnit.getFormattedValue(source.name, params.value);
677
696
  }
@@ -680,6 +699,13 @@ export default class AgGridController {
680
699
  cellStyle: this.getStyleByColumn(source),
681
700
  });
682
701
  }
702
+ setCustomFormatters(customFormatters) {
703
+ this._customFormatters = customFormatters;
704
+ }
705
+ refreshSelectedRows() {
706
+ const selectedNodes = this._gridOptions.api.getSelectedNodes();
707
+ this._gridOptions.api.redrawRows({ rowNodes: selectedNodes });
708
+ }
683
709
  getInitCellStyle() {
684
710
  return {
685
711
  'line-height': this.getRowHeight() - 1 + 'px',
@@ -840,19 +866,22 @@ export default class AgGridController {
840
866
  host[attribute] = value;
841
867
  }
842
868
  }
843
- getColumnWidth(cfgColumn) {
844
- var _a, _b;
845
- if (cfgColumn == undefined) {
869
+ setCellEditors(customEditors) {
870
+ var _a;
871
+ if (!this._editionManager) {
872
+ this._customEditors = customEditors;
846
873
  return;
847
874
  }
848
- if (cfgColumn.customWidth != undefined) {
849
- return cfgColumn.customWidth;
850
- }
851
- const field = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getField(cfgColumn.name);
852
- if ((field === null || field === void 0 ? void 0 : field.userInterface) === UserInterface.SEARCH) {
853
- return this.DEFAULT_MAX_SIZE;
875
+ this._editionManager.setCellEditors(customEditors);
876
+ (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
877
+ }
878
+ setCellRenders(customRenders) {
879
+ var _a;
880
+ if (!this._editionManager) {
881
+ this._customRenders = customRenders;
882
+ return;
854
883
  }
855
- 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;
856
- return labelSize > this.DEFAULT_MAX_SIZE ? this.DEFAULT_MAX_SIZE : labelSize;
884
+ this._editionManager.setCellRenders(customRenders);
885
+ (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.api.redrawRows();
857
886
  }
858
887
  }
@@ -11,7 +11,9 @@ export default class DataSource {
11
11
  }
12
12
  }
13
13
  handleFocusFirstRow() {
14
- this._controller.setFocusFirstRow();
14
+ if (this._options.autoFocus) {
15
+ this._controller.setFocusFirstRow();
16
+ }
15
17
  }
16
18
  isSilentChange(action) {
17
19
  //TODO: Provisorio p/ não atualizar a grade quando a alteração for apenas de campos transisntes
@@ -87,6 +89,9 @@ export default class DataSource {
87
89
  this._controller.selectRows(selectionInfo.recordIds, true);
88
90
  }
89
91
  }
92
+ setAutoFocus(autoFocus) {
93
+ this._options.autoFocus = autoFocus;
94
+ }
90
95
  getRows(params) {
91
96
  if (this.needReload(params)) {
92
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;
@@ -29,7 +33,7 @@ export default class GridEditionManager {
29
33
  this.saveSuccess();
30
34
  return;
31
35
  }
32
- if (!this._isGridEdition) {
36
+ if (!this._isGridEdition || this._dataUnit.hasNewRecord()) {
33
37
  return;
34
38
  }
35
39
  const currentRercord = this._dataUnit.getSelectedRecord();
@@ -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() {
@@ -223,6 +251,12 @@ export default class GridEditionManager {
223
251
  this._lastCellEdited = { rowIndex: event.rowIndex, column: event.column, rowPinned: undefined };
224
252
  }
225
253
  }
254
+ setCellEditors(customEditors) {
255
+ this._customEditors = customEditors;
256
+ }
257
+ setCellRenders(customRenders) {
258
+ this._customRenders = customRenders;
259
+ }
226
260
  }
227
261
  class TargetEdition {
228
262
  constructor(rowIndex, column, backwards) {
@@ -0,0 +1,59 @@
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
+ record: super.getRecord(),
23
+ editorMetadata: {
24
+ hidden: ((_a = fieldMetadata.props) === null || _a === void 0 ? void 0 : _a.visible) === false,
25
+ label: fieldMetadata.label,
26
+ userInterface: fieldMetadata.userInterface,
27
+ props: fieldMetadata.props,
28
+ optionLoader: fieldMetadata.optionLoader,
29
+ options: ((_b = fieldMetadata.props) === null || _b === void 0 ? void 0 : _b.options) || {},
30
+ },
31
+ };
32
+ }
33
+ getDefaultGui() {
34
+ const gui = super.getGui();
35
+ gui.value = this._value;
36
+ gui.onkeyup = (event) => {
37
+ const value = event.target.value;
38
+ this.setValue(value);
39
+ };
40
+ return gui;
41
+ }
42
+ getGui() {
43
+ const editorElement = this._customEditorInstance.getEditorElement(this._params);
44
+ if (!editorElement) {
45
+ return this._defaultGui;
46
+ }
47
+ if (typeof editorElement === 'string') {
48
+ const element = HTMLBuilder.parseElement(editorElement);
49
+ return element;
50
+ }
51
+ return editorElement;
52
+ }
53
+ setValue(value) {
54
+ this._value = value;
55
+ }
56
+ getValue() {
57
+ return this._value;
58
+ }
59
+ }
@@ -0,0 +1,40 @@
1
+ import EzCellRender from "../editor/EzCellRender";
2
+ import { HTMLBuilder } from "@sankhyalabs/core";
3
+ import { CustomRenderSource } from "../../../../../utils/customRender/interfaces/ICustomRender";
4
+ export default class EzGridCustomCellRender extends EzCellRender {
5
+ init(params) {
6
+ var _a, _b;
7
+ this._fieldName = params.column.getColId();
8
+ this._customRenderInstance = params.customRendersInfo.customRender;
9
+ super.init(params);
10
+ const fieldMetadata = super.getFieldMetadata();
11
+ this._params = {
12
+ value: params.value,
13
+ charPress: '',
14
+ currentRender: super.getGui(),
15
+ name: this._fieldName,
16
+ source: CustomRenderSource.GRID,
17
+ getValue: () => params.getValue(),
18
+ detailContext: params.customRendersInfo.detailContext,
19
+ renderMetadata: {
20
+ hidden: ((_a = fieldMetadata.props) === null || _a === void 0 ? void 0 : _a.visible) === false,
21
+ label: fieldMetadata.label,
22
+ userInterface: fieldMetadata.userInterface,
23
+ props: fieldMetadata.props,
24
+ optionLoader: fieldMetadata.optionLoader,
25
+ options: ((_b = fieldMetadata.props) === null || _b === void 0 ? void 0 : _b.options) || {},
26
+ }
27
+ };
28
+ }
29
+ getGui() {
30
+ const editorElement = this._customRenderInstance.getRenderElement(this._params);
31
+ if (!editorElement) {
32
+ return super.getGui();
33
+ }
34
+ if (typeof editorElement === 'string') {
35
+ const element = HTMLBuilder.parseElement(editorElement);
36
+ return element;
37
+ }
38
+ return editorElement;
39
+ }
40
+ }
@@ -0,0 +1,11 @@
1
+ import { DataType, UserInterface } from "@sankhyalabs/core";
2
+ export const metadata = {
3
+ name: 'metadatada',
4
+ label: 'metadatada',
5
+ fields: [{
6
+ name: 'FIELDNAME',
7
+ label: 'Test',
8
+ dataType: DataType.TEXT,
9
+ userInterface: UserInterface.SHORTTEXT,
10
+ }],
11
+ };
@@ -0,0 +1,11 @@
1
+ import { DataType, UserInterface } from "@sankhyalabs/core";
2
+ export const metadata = {
3
+ name: 'metadatada',
4
+ label: 'metadatada',
5
+ fields: [{
6
+ name: 'FIELDNAME',
7
+ label: 'Test',
8
+ dataType: DataType.TEXT,
9
+ userInterface: UserInterface.SHORTTEXT,
10
+ }],
11
+ };
@@ -18,11 +18,12 @@ uiBuilders.set(UserInterface.LONGTEXT, buildTextAreaInput);
18
18
  uiBuilders.set(UserInterface.SEARCH, buildSearch);
19
19
  export default class EzCellEditor {
20
20
  init(params) {
21
+ this._rowData = params.data;
21
22
  const fieldName = params.column.getColId();
22
23
  const dataUnit = params.context.dataUnit;
23
- const fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
24
- const builder = uiBuilders.get(fieldMetadata.userInterface) || buildTextInput;
25
- this._gui = builder(fieldMetadata);
24
+ this._fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
25
+ const builder = uiBuilders.get(this._fieldMetadata.userInterface) || buildTextInput;
26
+ this._gui = builder(this._fieldMetadata);
26
27
  if (this._gui.valueSetter != undefined) {
27
28
  this._gui.valueSetter(params.value);
28
29
  }
@@ -46,4 +47,10 @@ export default class EzCellEditor {
46
47
  isPopup() {
47
48
  return this._gui.isPopUp;
48
49
  }
50
+ getFieldMetadata() {
51
+ return this._fieldMetadata;
52
+ }
53
+ getRecord() {
54
+ return this._rowData;
55
+ }
49
56
  }
@@ -0,0 +1,40 @@
1
+ import { buildEditorMetadata } from "./IEditorMetadata";
2
+ export default class EzCellRender {
3
+ init(params) {
4
+ const span = document.createElement('span');
5
+ this._currentParams = params;
6
+ span.textContent = params.value;
7
+ const fieldName = params.column.getColId();
8
+ const dataUnit = params.context.dataUnit;
9
+ this._fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
10
+ this._gui = span;
11
+ }
12
+ refresh() {
13
+ try {
14
+ this._currentParams.refreshCell();
15
+ return true;
16
+ }
17
+ catch (_a) {
18
+ return false;
19
+ }
20
+ }
21
+ getGui() {
22
+ return this._gui;
23
+ }
24
+ afterGuiAttached() {
25
+ this.focusIn();
26
+ }
27
+ focusIn() {
28
+ this._gui.focus();
29
+ this._gui.setFocus({ selectText: true });
30
+ }
31
+ getValue() {
32
+ return this._currentParams.getValue();
33
+ }
34
+ isPopup() {
35
+ return this._gui.isPopUp;
36
+ }
37
+ getFieldMetadata() {
38
+ return this._fieldMetadata;
39
+ }
40
+ }
@@ -1,7 +1,8 @@
1
1
  import { HTMLBuilder } from "@sankhyalabs/core";
2
2
  export const buildDecimal = ({ readOnly, props }) => {
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(readOnly, precision, prettyPrecision);
6
7
  };
7
8
  export const buildInteger = ({ readOnly }) => {