@sankhyalabs/ezui 5.21.2 → 5.22.0-dev.1

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 (181) 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 +433 -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 +34 -3
  8. package/dist/cjs/ez-form.cjs.entry.js +77 -2
  9. package/dist/cjs/ez-grid.cjs.entry.js +313 -39
  10. package/dist/cjs/ez-list.cjs.entry.js +10 -2
  11. package/dist/cjs/ez-number-input.cjs.entry.js +37 -31
  12. package/dist/cjs/ez-scroller_2.cjs.entry.js +222 -0
  13. package/dist/cjs/ez-search.cjs.entry.js +39 -32
  14. package/dist/cjs/ez-sidebar-navigator.cjs.entry.js +92 -0
  15. package/dist/cjs/ez-split-item.cjs.entry.js +1 -0
  16. package/dist/cjs/{ez-scroller_3.cjs.entry.js → ez-tree.cjs.entry.js} +0 -215
  17. package/dist/cjs/ezui.cjs.js +1 -1
  18. package/dist/cjs/index-a7b0c73d.js +16 -4
  19. package/dist/cjs/loader.cjs.js +1 -1
  20. package/dist/collection/collection-manifest.json +3 -0
  21. package/dist/collection/components/ez-chart/components/BarChart.js +27 -0
  22. package/dist/collection/components/ez-chart/components/ColumnChart.js +27 -0
  23. package/dist/collection/components/ez-chart/components/DonutChart.js +42 -0
  24. package/dist/collection/components/ez-chart/components/LineChart.js +27 -0
  25. package/dist/collection/components/ez-chart/components/PieChart.js +45 -0
  26. package/dist/collection/components/ez-chart/components/index.js +5 -0
  27. package/dist/collection/components/ez-chart/ez-chart.css +5 -0
  28. package/dist/collection/components/ez-chart/ez-chart.js +284 -0
  29. package/dist/collection/components/ez-chart/interfaces/ChartAxis.js +1 -0
  30. package/dist/collection/components/ez-chart/interfaces/ChartContext.js +14 -0
  31. package/dist/collection/components/ez-chart/interfaces/ChartOptions.js +1 -0
  32. package/dist/collection/components/ez-chart/interfaces/ChartSerie.js +1 -0
  33. package/dist/collection/components/ez-chart/interfaces/ChartStrategies.js +1 -0
  34. package/dist/collection/components/ez-chart/interfaces/ChartType.js +8 -0
  35. package/dist/collection/components/ez-chart/interfaces/index.js +5 -0
  36. package/dist/collection/components/ez-chart/test/mock-chart.js +137 -0
  37. package/dist/collection/components/ez-chart/types/BaseHighChartsRender.js +146 -0
  38. package/dist/collection/components/ez-form/ez-form.js +130 -4
  39. package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +278 -0
  40. package/dist/collection/components/ez-form-view/ez-form-view.js +110 -1
  41. package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +3 -2
  42. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +51 -22
  43. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +6 -1
  44. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +35 -1
  45. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +59 -0
  46. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.js +40 -0
  47. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.js +11 -0
  48. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.js +11 -0
  49. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +10 -3
  50. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellRender.js +40 -0
  51. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IUICellRender.js +1 -0
  52. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +3 -2
  53. package/dist/collection/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.js +40 -0
  54. package/dist/collection/components/ez-grid/ez-grid.js +237 -12
  55. package/dist/collection/components/ez-grid/interfaces/ICustomFormatter.js +1 -0
  56. package/dist/collection/components/ez-grid/interfaces/index.js +1 -0
  57. package/dist/collection/components/ez-grid/test/resources/gridDataUnit.js +19 -0
  58. package/dist/collection/components/ez-list/ez-list.js +28 -2
  59. package/dist/collection/components/ez-number-input/ez-number-input.js +46 -31
  60. package/dist/collection/components/ez-search/ez-search.js +38 -32
  61. package/dist/collection/components/ez-sidebar-button/ez-sidebar-button.css +6 -2
  62. package/dist/collection/components/ez-sidebar-button/ez-sidebar-button.js +1 -1
  63. package/dist/collection/components/ez-sidebar-navigator/ez-sidebar-navigator.css +180 -0
  64. package/dist/collection/components/ez-sidebar-navigator/ez-sidebar-navigator.js +293 -0
  65. package/dist/collection/components/ez-sidebar-navigator/interfaces/ModeMenuEnum.js +5 -0
  66. package/dist/collection/components/ez-sidebar-navigator/interfaces/SizeMenuEnum.js +6 -0
  67. package/dist/collection/components/ez-sidebar-navigator/interfaces/TypeMenuEnum.js +6 -0
  68. package/dist/collection/components/ez-sidebar-navigator/interfaces/index.js +3 -0
  69. package/dist/collection/components/ez-sidebar-navigator/messages/constants.js +5 -0
  70. package/dist/collection/utils/customEditor/interfaces/ICustomEditor.js +5 -0
  71. package/dist/collection/utils/customEditor/interfaces/ICustomEditorInfo.js +1 -0
  72. package/dist/collection/utils/customRender/interfaces/ICustomRender.js +5 -0
  73. package/dist/collection/utils/customRender/interfaces/ICustomRenderInfo.js +1 -0
  74. package/dist/collection/utils/form/DataBinder.js +26 -0
  75. package/dist/collection/utils/form/test/DataBinder.test.js +41 -4
  76. package/dist/collection/utils/form/test/resources/metadataTest.js +15 -0
  77. package/dist/collection/utils/index.js +2 -0
  78. package/dist/custom-elements/index.d.ts +18 -0
  79. package/dist/custom-elements/index.js +1145 -117
  80. package/dist/esm/ICustomRender-875b5a40.js +13 -0
  81. package/dist/esm/ez-actions-button.entry.js +1 -0
  82. package/dist/esm/ez-chart.entry.js +429 -0
  83. package/dist/esm/ez-collapsible-box.entry.js +1 -0
  84. package/dist/esm/ez-combo-box.entry.js +1 -0
  85. package/dist/esm/{ez-text-edit.entry.js → ez-custom-form-input_2.entry.js} +101 -3
  86. package/dist/esm/ez-form-view.entry.js +34 -3
  87. package/dist/esm/ez-form.entry.js +78 -3
  88. package/dist/esm/ez-grid.entry.js +313 -39
  89. package/dist/esm/ez-list.entry.js +10 -2
  90. package/dist/esm/ez-number-input.entry.js +38 -32
  91. package/dist/esm/ez-scroller_2.entry.js +217 -0
  92. package/dist/esm/ez-search.entry.js +39 -32
  93. package/dist/esm/ez-sidebar-navigator.entry.js +88 -0
  94. package/dist/esm/ez-split-item.entry.js +1 -0
  95. package/dist/esm/{ez-scroller_3.entry.js → ez-tree.entry.js} +3 -216
  96. package/dist/esm/ezui.js +1 -1
  97. package/dist/esm/index-baa5e267.js +16 -4
  98. package/dist/esm/loader.js +1 -1
  99. package/dist/ezui/ezui.esm.js +1 -1
  100. package/dist/ezui/p-12ae1104.entry.js +1 -0
  101. package/dist/ezui/p-2097d0cf.entry.js +1 -0
  102. package/dist/ezui/p-3b4eeeb6.entry.js +1 -0
  103. package/dist/ezui/p-4607fb89.js +1 -0
  104. package/dist/ezui/p-4d5235f1.entry.js +1 -0
  105. package/dist/ezui/p-5056284a.entry.js +1 -0
  106. package/dist/ezui/p-7922142b.entry.js +1 -0
  107. package/dist/ezui/{p-fbee26ec.entry.js → p-816cece6.entry.js} +2 -2
  108. package/dist/ezui/p-84e439b9.entry.js +1 -0
  109. package/dist/ezui/p-8888d9ed.entry.js +1 -0
  110. package/dist/ezui/p-922ac38b.entry.js +1 -0
  111. package/dist/ezui/p-9ab22a07.entry.js +1 -0
  112. package/dist/ezui/p-a31b9c90.entry.js +1 -0
  113. package/dist/ezui/p-bcb53f27.entry.js +1 -0
  114. package/dist/ezui/p-ecc2c1ec.entry.js +1 -0
  115. package/dist/ezui/p-ffef392d.entry.js +1 -0
  116. package/dist/types/components/ez-chart/components/BarChart.d.ts +9 -0
  117. package/dist/types/components/ez-chart/components/ColumnChart.d.ts +9 -0
  118. package/dist/types/components/ez-chart/components/DonutChart.d.ts +9 -0
  119. package/dist/types/components/ez-chart/components/LineChart.d.ts +9 -0
  120. package/dist/types/components/ez-chart/components/PieChart.d.ts +9 -0
  121. package/dist/types/components/ez-chart/components/index.d.ts +5 -0
  122. package/dist/types/components/ez-chart/ez-chart.d.ts +58 -0
  123. package/dist/types/components/ez-chart/interfaces/ChartAxis.d.ts +7 -0
  124. package/dist/types/components/ez-chart/interfaces/ChartContext.d.ts +11 -0
  125. package/dist/types/components/ez-chart/interfaces/ChartOptions.d.ts +10 -0
  126. package/dist/types/components/ez-chart/interfaces/ChartSerie.d.ts +20 -0
  127. package/dist/types/components/ez-chart/interfaces/ChartStrategies.d.ts +7 -0
  128. package/dist/types/components/ez-chart/interfaces/ChartType.d.ts +7 -0
  129. package/dist/types/components/ez-chart/interfaces/index.d.ts +5 -0
  130. package/dist/types/components/ez-chart/types/BaseHighChartsRender.d.ts +15 -0
  131. package/dist/types/components/ez-form/ez-form.d.ts +20 -1
  132. package/dist/types/components/ez-form-view/custom-input/ez-custom-form-input.d.ts +48 -0
  133. package/dist/types/components/ez-form-view/ez-form-view.d.ts +16 -1
  134. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +37 -0
  135. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +13 -4
  136. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +1 -0
  137. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +7 -1
  138. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +19 -0
  139. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +14 -0
  140. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.d.ts +11 -0
  141. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.d.ts +11 -0
  142. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +6 -0
  143. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +15 -0
  144. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellRender.d.ts +10 -0
  145. package/dist/types/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.d.ts +6 -0
  146. package/dist/types/components/ez-grid/ez-grid.d.ts +35 -1
  147. package/dist/types/components/ez-grid/interfaces/ICustomFormatter.d.ts +5 -0
  148. package/dist/types/components/ez-grid/interfaces/index.d.ts +1 -0
  149. package/dist/types/components/ez-grid/test/resources/gridDataUnit.d.ts +2 -0
  150. package/dist/types/components/ez-list/ez-list.d.ts +5 -0
  151. package/dist/types/components/ez-number-input/ez-number-input.d.ts +3 -0
  152. package/dist/types/components/ez-search/ez-search.d.ts +4 -2
  153. package/dist/types/components/ez-sidebar-navigator/ez-sidebar-navigator.d.ts +57 -0
  154. package/dist/types/components/ez-sidebar-navigator/interfaces/ModeMenuEnum.d.ts +4 -0
  155. package/dist/types/components/ez-sidebar-navigator/interfaces/SizeMenuEnum.d.ts +5 -0
  156. package/dist/types/components/ez-sidebar-navigator/interfaces/TypeMenuEnum.d.ts +5 -0
  157. package/dist/types/components/ez-sidebar-navigator/interfaces/index.d.ts +3 -0
  158. package/dist/types/components/ez-sidebar-navigator/messages/constants.d.ts +5 -0
  159. package/dist/types/components.d.ts +334 -5
  160. package/dist/types/utils/customEditor/interfaces/ICustomEditor.d.ts +31 -0
  161. package/dist/types/utils/customEditor/interfaces/ICustomEditorInfo.d.ts +5 -0
  162. package/dist/types/utils/customRender/interfaces/ICustomRender.d.ts +29 -0
  163. package/dist/types/utils/customRender/interfaces/ICustomRenderInfo.d.ts +5 -0
  164. package/dist/types/utils/form/DataBinder.d.ts +3 -0
  165. package/dist/types/utils/form/test/resources/metadataTest.d.ts +2 -0
  166. package/dist/types/utils/index.d.ts +2 -0
  167. package/package.json +2 -1
  168. package/react/components.d.ts +3 -0
  169. package/react/components.js +3 -0
  170. package/react/components.js.map +1 -1
  171. package/dist/ezui/p-0447d17c.entry.js +0 -1
  172. package/dist/ezui/p-20ec22c0.entry.js +0 -1
  173. package/dist/ezui/p-2a1a0e04.entry.js +0 -1
  174. package/dist/ezui/p-637f69f2.entry.js +0 -1
  175. package/dist/ezui/p-786559c5.entry.js +0 -1
  176. package/dist/ezui/p-7c770f14.entry.js +0 -1
  177. package/dist/ezui/p-91f626d3.entry.js +0 -1
  178. package/dist/ezui/p-99ead599.entry.js +0 -1
  179. package/dist/ezui/p-b567fa8c.entry.js +0 -1
  180. package/dist/ezui/p-bae3d0aa.entry.js +0 -1
  181. package/dist/ezui/p-db77a984.entry.js +0 -1
@@ -1,20 +1,23 @@
1
1
  import { Action, DataUnit, ElementIDUtils, StringUtils } from "@sankhyalabs/core";
2
2
  import { Host, forceUpdate, h } from "@stencil/core";
3
3
  import { createStore } from "redux";
4
- import { changeTab, formReducer, loadMetadata, selectCurrentSheet, selectFormMetadata } from "./store/form.slice";
5
- import { buildFormMetadata } from "../../utils/form/FormMetadata";
6
4
  import DataBinder from "../../utils/form/DataBinder";
5
+ import { buildFormMetadata } from "../../utils/form/FormMetadata";
6
+ import { changeTab, formReducer, loadMetadata, selectCurrentSheet, selectFormMetadata } from "./store/form.slice";
7
7
  export class EzForm {
8
8
  constructor() {
9
+ this._customEditors = new Map();
9
10
  this.onDataUnitAction = (action) => {
10
11
  if (action.type === Action.METADATA_LOADED) {
11
12
  this.processMetadata();
12
13
  }
13
14
  };
15
+ this._fieldsProps = new Map();
14
16
  this.dataUnit = undefined;
15
17
  this.config = undefined;
16
18
  this.recordsValidator = undefined;
17
19
  this.fieldToFocus = undefined;
20
+ this.onlyStaticFields = false;
18
21
  }
19
22
  /**
20
23
  * Realiza validação no conteúdo de todos os campos.
@@ -22,9 +25,30 @@ export class EzForm {
22
25
  validate() {
23
26
  return this._dataBinder.validate();
24
27
  }
28
+ /**
29
+ * Registra um editor customizado para campos da grade e formulário.
30
+ */
31
+ async addCustomEditor(fieldName, customEditor, detailContext) {
32
+ if (this._formView) {
33
+ this._formView.addCustomEditor(fieldName, customEditor, detailContext);
34
+ return;
35
+ }
36
+ const newCustomEditors = new Map(this._customEditors);
37
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
38
+ this._customEditors = newCustomEditors;
39
+ }
25
40
  observeConfig() {
26
41
  this.processMetadata();
27
42
  }
43
+ /**
44
+ * Altera/adiciona uma propriedade nos metadados do campo.
45
+ */
46
+ async setFieldProp(fieldName, propName, value) {
47
+ const newCustomFieldProps = new Map(this._fieldsProps);
48
+ const currentProps = this._fieldsProps.get(fieldName);
49
+ newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
50
+ this._fieldsProps = newCustomFieldProps;
51
+ }
28
52
  getDynamicContent() {
29
53
  var _a;
30
54
  const formMD = selectFormMetadata(this._store.getState());
@@ -51,10 +75,10 @@ export class EzForm {
51
75
  }
52
76
  this.ezFormSetFields.emit(fields);
53
77
  const idFormSheet = `${StringUtils.replaceAccentuatedChars(StringUtils.toCamelCase(currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.label), false)}_selectorContainer`;
54
- return (h("div", { class: "dynamic-content", "data-element-id": idFormSheet }, h("ez-form-view", { class: "ez-row ez-padding-vertical--small", fields: fields })));
78
+ return (h("div", { class: "dynamic-content", "data-element-id": idFormSheet }, h("ez-form-view", { ref: (element) => (this._formView = element), class: "ez-row ez-padding-vertical--small", fields: fields, selectedRecord: this.dataUnit.getSelectedRecord() })));
55
79
  }
56
80
  processMetadata() {
57
- if (!this.isStatic() && this.dataUnit && this._store) {
81
+ if (this.bindFields() && this.dataUnit && this._store) {
58
82
  const metadata = buildFormMetadata(this.config, this.dataUnit);
59
83
  this._store.dispatch(loadMetadata(metadata));
60
84
  }
@@ -63,6 +87,9 @@ export class EzForm {
63
87
  var _a;
64
88
  return ((_a = this._staticFields) === null || _a === void 0 ? void 0 : _a.length) > 0;
65
89
  }
90
+ bindFields() {
91
+ return !this.isStatic() || this.onlyStaticFields === false;
92
+ }
66
93
  componentWillLoad() {
67
94
  if (this.dataUnit === undefined) {
68
95
  this.dataUnit = new DataUnit("ez-form");
@@ -82,6 +109,17 @@ export class EzForm {
82
109
  this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")), this.dataUnit.dataUnitId, metadata, this.recordsValidator);
83
110
  this.ezReady.emit();
84
111
  this.handleFieldToFocus();
112
+ this.setCustomEditors();
113
+ this.setFieldsProps();
114
+ }
115
+ setCustomEditors() {
116
+ if (!this._formView) {
117
+ return;
118
+ }
119
+ for (const [fieldName, customEditorProps] of this._customEditors) {
120
+ this._formView.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
121
+ this._customEditors.delete(fieldName);
122
+ }
85
123
  }
86
124
  handleFieldToFocus() {
87
125
  var _a;
@@ -98,6 +136,17 @@ export class EzForm {
98
136
  this.ezFormRequestClearFieldToFocus.emit();
99
137
  });
100
138
  }
139
+ setFieldsProps() {
140
+ if (!this._formView) {
141
+ return;
142
+ }
143
+ for (const [fieldName, props] of this._fieldsProps) {
144
+ for (const prop in props) {
145
+ this._formView.setFieldProp(fieldName, prop, props[prop]);
146
+ }
147
+ this._fieldsProps.delete(fieldName);
148
+ }
149
+ }
101
150
  disconnectedCallback() {
102
151
  this.dataUnit.unsubscribe(this.onDataUnitAction);
103
152
  this._dataBinder.onDisconnectedCallback();
@@ -201,9 +250,32 @@ export class EzForm {
201
250
  },
202
251
  "attribute": "field-to-focus",
203
252
  "reflect": false
253
+ },
254
+ "onlyStaticFields": {
255
+ "type": "boolean",
256
+ "mutable": false,
257
+ "complexType": {
258
+ "original": "boolean",
259
+ "resolved": "boolean",
260
+ "references": {}
261
+ },
262
+ "required": false,
263
+ "optional": false,
264
+ "docs": {
265
+ "tags": [],
266
+ "text": "Define se os campos que ser\u00E3o apresentados s\u00E3o todos est\u00E1ticos. Quando verdadeira, ocorrer\u00E1 no DataBinder o bind dos campos com o DataUnit."
267
+ },
268
+ "attribute": "only-static-fields",
269
+ "reflect": false,
270
+ "defaultValue": "false"
204
271
  }
205
272
  };
206
273
  }
274
+ static get states() {
275
+ return {
276
+ "_fieldsProps": {}
277
+ };
278
+ }
207
279
  static get events() {
208
280
  return [{
209
281
  "method": "ezFormRequestClearFieldToFocus",
@@ -297,6 +369,60 @@ export class EzForm {
297
369
  "text": "Realiza valida\u00E7\u00E3o no conte\u00FAdo de todos os campos.",
298
370
  "tags": []
299
371
  }
372
+ },
373
+ "addCustomEditor": {
374
+ "complexType": {
375
+ "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
376
+ "parameters": [{
377
+ "tags": [],
378
+ "text": ""
379
+ }, {
380
+ "tags": [],
381
+ "text": ""
382
+ }, {
383
+ "tags": [],
384
+ "text": ""
385
+ }],
386
+ "references": {
387
+ "Promise": {
388
+ "location": "global"
389
+ },
390
+ "ICustomEditor": {
391
+ "location": "import",
392
+ "path": "../../utils/customEditor/interfaces/ICustomEditor"
393
+ }
394
+ },
395
+ "return": "Promise<void>"
396
+ },
397
+ "docs": {
398
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
399
+ "tags": []
400
+ }
401
+ },
402
+ "setFieldProp": {
403
+ "complexType": {
404
+ "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
405
+ "parameters": [{
406
+ "tags": [],
407
+ "text": ""
408
+ }, {
409
+ "tags": [],
410
+ "text": ""
411
+ }, {
412
+ "tags": [],
413
+ "text": ""
414
+ }],
415
+ "references": {
416
+ "Promise": {
417
+ "location": "global"
418
+ }
419
+ },
420
+ "return": "Promise<void>"
421
+ },
422
+ "docs": {
423
+ "text": "Altera/adiciona uma propriedade nos metadados do campo.",
424
+ "tags": []
425
+ }
300
426
  }
301
427
  };
302
428
  }
@@ -0,0 +1,278 @@
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
+ this.selectedRecord = undefined;
13
+ }
14
+ /**
15
+ * Aplica foco no campo.
16
+ */
17
+ async setFocus() {
18
+ var _a, _b;
19
+ (_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["setFocus"]) === null || _b === void 0 ? void 0 : _b.call(_a);
20
+ }
21
+ /**
22
+ * Remove o foco do campo.
23
+ */
24
+ async setBlur() {
25
+ var _a, _b;
26
+ (_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["setBlur"]) === null || _b === void 0 ? void 0 : _b.call(_a);
27
+ }
28
+ /**
29
+ * Retorna se o conteúdo é inválido.
30
+ */
31
+ async isInvalid() {
32
+ var _a, _b;
33
+ return ((_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["isInvalid"]) === null || _b === void 0 ? void 0 : _b.call(_a)) || false;
34
+ }
35
+ getContent() {
36
+ var _a, _b;
37
+ const fieldProps = new Map();
38
+ for (const prop in this.formViewField.props) {
39
+ fieldProps.set(prop, this.formViewField.props[prop]);
40
+ }
41
+ const params = {
42
+ value: this.value,
43
+ name: this.formViewField.name,
44
+ currentEditor: this.builderFallback(this.formViewField),
45
+ setValue: (value) => this.setValue(value),
46
+ getValue: this.getValue,
47
+ record: this.selectedRecord,
48
+ editorMetadata: {
49
+ label: this.formViewField.label,
50
+ hidden: ((_a = this.formViewField.props) === null || _a === void 0 ? void 0 : _a.visible) === false,
51
+ userInterface: this.formViewField.userInterface,
52
+ options: (_b = this.formViewField.props) === null || _b === void 0 ? void 0 : _b.options,
53
+ props: this.formViewField.props ? fieldProps : undefined,
54
+ optionLoader: this.formViewField.optionLoader
55
+ },
56
+ source: CustomEditorSource.FORM,
57
+ detailContext: this.detailContext
58
+ };
59
+ let gui = this.customEditor.getEditorElement(params);
60
+ if (!gui) {
61
+ gui = this.builderFallback(this.formViewField);
62
+ this.handleValue(gui);
63
+ this.gui = gui;
64
+ return;
65
+ }
66
+ if (!(gui instanceof HTMLElement) && typeof gui !== 'string') {
67
+ this.handleValue(gui);
68
+ this.gui = gui;
69
+ return;
70
+ }
71
+ if (typeof gui === 'string') {
72
+ gui = HTMLBuilder.parseElement(gui);
73
+ }
74
+ if (this.value) {
75
+ gui.setAttribute('value', typeof this.value === 'object' ? this.value.value : this.value);
76
+ }
77
+ this.gui = h("div", { key: StringUtils.generateUUID(), ref: el => el && el.appendChild(gui) });
78
+ }
79
+ setValue(value) {
80
+ this.value = value;
81
+ }
82
+ getValue() {
83
+ return this.value;
84
+ }
85
+ handleValue(gui) {
86
+ var _a;
87
+ //@ts-ignore
88
+ (_a = gui.$children$) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
89
+ child.$attrs$.value = this.value;
90
+ });
91
+ }
92
+ componentWillRender() {
93
+ this.getContent();
94
+ }
95
+ render() {
96
+ return (h(Host, null, this.gui));
97
+ }
98
+ static get is() { return "ez-custom-form-input"; }
99
+ static get encapsulation() { return "scoped"; }
100
+ static get properties() {
101
+ return {
102
+ "customEditor": {
103
+ "type": "unknown",
104
+ "mutable": false,
105
+ "complexType": {
106
+ "original": "ICustomEditor",
107
+ "resolved": "ICustomEditor",
108
+ "references": {
109
+ "ICustomEditor": {
110
+ "location": "import",
111
+ "path": "../../../utils/customEditor/interfaces/ICustomEditor"
112
+ }
113
+ }
114
+ },
115
+ "required": false,
116
+ "optional": false,
117
+ "docs": {
118
+ "tags": [],
119
+ "text": "Inst\u00E2ncia do editor customizado."
120
+ }
121
+ },
122
+ "formViewField": {
123
+ "type": "unknown",
124
+ "mutable": false,
125
+ "complexType": {
126
+ "original": "IFormViewField",
127
+ "resolved": "IFormViewField",
128
+ "references": {
129
+ "IFormViewField": {
130
+ "location": "import",
131
+ "path": "../interfaces"
132
+ }
133
+ }
134
+ },
135
+ "required": false,
136
+ "optional": false,
137
+ "docs": {
138
+ "tags": [],
139
+ "text": "Campo que o elemento customizado representa."
140
+ }
141
+ },
142
+ "value": {
143
+ "type": "any",
144
+ "mutable": true,
145
+ "complexType": {
146
+ "original": "any",
147
+ "resolved": "any",
148
+ "references": {}
149
+ },
150
+ "required": false,
151
+ "optional": false,
152
+ "docs": {
153
+ "tags": [],
154
+ "text": "Valores dos campos do formul\u00E1rio."
155
+ },
156
+ "attribute": "value",
157
+ "reflect": false
158
+ },
159
+ "detailContext": {
160
+ "type": "string",
161
+ "mutable": false,
162
+ "complexType": {
163
+ "original": "string",
164
+ "resolved": "string",
165
+ "references": {}
166
+ },
167
+ "required": false,
168
+ "optional": false,
169
+ "docs": {
170
+ "tags": [],
171
+ "text": "Define de qual contexto o editor est\u00E1 sendo acionado."
172
+ },
173
+ "attribute": "detail-context",
174
+ "reflect": false
175
+ },
176
+ "builderFallback": {
177
+ "type": "unknown",
178
+ "mutable": false,
179
+ "complexType": {
180
+ "original": "(field: IFormViewField) => HTMLElement",
181
+ "resolved": "(field: IFormViewField) => HTMLElement",
182
+ "references": {
183
+ "IFormViewField": {
184
+ "location": "import",
185
+ "path": "../interfaces"
186
+ },
187
+ "HTMLElement": {
188
+ "location": "global"
189
+ }
190
+ }
191
+ },
192
+ "required": false,
193
+ "optional": false,
194
+ "docs": {
195
+ "tags": [],
196
+ "text": "Builder original do FormView que ser\u00E1 chamado caso o custom n\u00E3o retorne nenhum valor."
197
+ }
198
+ },
199
+ "selectedRecord": {
200
+ "type": "unknown",
201
+ "mutable": false,
202
+ "complexType": {
203
+ "original": "Record",
204
+ "resolved": "Record",
205
+ "references": {
206
+ "Record": {
207
+ "location": "import",
208
+ "path": "@sankhyalabs/core"
209
+ }
210
+ }
211
+ },
212
+ "required": false,
213
+ "optional": false,
214
+ "docs": {
215
+ "tags": [],
216
+ "text": "Define os registros da linha selecionada."
217
+ }
218
+ }
219
+ };
220
+ }
221
+ static get states() {
222
+ return {
223
+ "gui": {}
224
+ };
225
+ }
226
+ static get methods() {
227
+ return {
228
+ "setFocus": {
229
+ "complexType": {
230
+ "signature": "() => Promise<void>",
231
+ "parameters": [],
232
+ "references": {
233
+ "Promise": {
234
+ "location": "global"
235
+ }
236
+ },
237
+ "return": "Promise<void>"
238
+ },
239
+ "docs": {
240
+ "text": "Aplica foco no campo.",
241
+ "tags": []
242
+ }
243
+ },
244
+ "setBlur": {
245
+ "complexType": {
246
+ "signature": "() => Promise<void>",
247
+ "parameters": [],
248
+ "references": {
249
+ "Promise": {
250
+ "location": "global"
251
+ }
252
+ },
253
+ "return": "Promise<void>"
254
+ },
255
+ "docs": {
256
+ "text": "Remove o foco do campo.",
257
+ "tags": []
258
+ }
259
+ },
260
+ "isInvalid": {
261
+ "complexType": {
262
+ "signature": "() => Promise<boolean>",
263
+ "parameters": [],
264
+ "references": {
265
+ "Promise": {
266
+ "location": "global"
267
+ }
268
+ },
269
+ "return": "Promise<boolean>"
270
+ },
271
+ "docs": {
272
+ "text": "Retorna se o conte\u00FAdo \u00E9 inv\u00E1lido.",
273
+ "tags": []
274
+ }
275
+ }
276
+ };
277
+ }
278
+ }
@@ -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 }) => {