@sankhyalabs/ezui 0.0.0-bugfix-dev-KB-50898.1 → 0.0.0-bugfix-dev-59880.0

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 (148) 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-alert-list.cjs.entry.js +11 -1
  4. package/dist/cjs/ez-button.cjs.entry.js +2 -2
  5. package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -0
  6. package/dist/cjs/ez-combo-box.cjs.entry.js +1 -0
  7. package/dist/cjs/{ez-text-edit.cjs.entry.js → ez-custom-form-input_2.cjs.entry.js} +86 -0
  8. package/dist/cjs/ez-date-input.cjs.entry.js +1 -0
  9. package/dist/cjs/ez-form-view.cjs.entry.js +36 -4
  10. package/dist/cjs/ez-form.cjs.entry.js +51 -2
  11. package/dist/cjs/ez-grid.cjs.entry.js +322 -19
  12. package/dist/cjs/ez-list.cjs.entry.js +1 -1
  13. package/dist/cjs/ez-modal-container.cjs.entry.js +15 -4
  14. package/dist/cjs/ez-modal.cjs.entry.js +7 -8
  15. package/dist/cjs/ez-number-input.cjs.entry.js +9 -2
  16. package/dist/cjs/ez-popup.cjs.entry.js +14 -8
  17. package/dist/cjs/ez-search.cjs.entry.js +6 -2
  18. package/dist/cjs/ez-split-item.cjs.entry.js +3 -2
  19. package/dist/cjs/ezui.cjs.js +1 -1
  20. package/dist/cjs/index-a7b0c73d.js +4 -4
  21. package/dist/cjs/loader.cjs.js +1 -1
  22. package/dist/collection/collection-manifest.json +1 -0
  23. package/dist/collection/components/ez-alert-list/ez-alert-list.js +11 -1
  24. package/dist/collection/components/ez-button/ez-button.css +7 -0
  25. package/dist/collection/components/ez-button/ez-button.js +1 -1
  26. package/dist/collection/components/ez-date-input/ez-date-input.js +1 -0
  27. package/dist/collection/components/ez-form/ez-form.js +130 -4
  28. package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +245 -0
  29. package/dist/collection/components/ez-form-view/ez-form-view.js +92 -2
  30. package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +3 -2
  31. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +62 -4
  32. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +35 -1
  33. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +58 -0
  34. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.js +40 -0
  35. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.js +11 -0
  36. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.js +11 -0
  37. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +6 -3
  38. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellRender.js +40 -0
  39. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IUICellRender.js +1 -0
  40. package/dist/collection/components/ez-grid/ez-grid.js +206 -2
  41. package/dist/collection/components/ez-grid/interfaces/ICustomFormatter.js +1 -0
  42. package/dist/collection/components/ez-grid/interfaces/index.js +1 -0
  43. package/dist/collection/components/ez-grid/subcomponents/selection-counter.js +3 -11
  44. package/dist/collection/components/ez-grid/subcomponents/utils/selectionCounterUtils.js +22 -0
  45. package/dist/collection/components/ez-grid/test/resources/gridDataUnit.js +19 -0
  46. package/dist/collection/components/ez-list/ez-list.css +6 -2
  47. package/dist/collection/components/ez-modal/ez-modal.js +22 -9
  48. package/dist/collection/components/ez-modal-container/ez-modal-container.css +4 -0
  49. package/dist/collection/components/ez-modal-container/ez-modal-container.js +23 -3
  50. package/dist/collection/components/ez-number-input/ez-number-input.js +12 -1
  51. package/dist/collection/components/ez-popup/ez-popup.js +14 -8
  52. package/dist/collection/components/ez-search/ez-search.js +5 -2
  53. package/dist/collection/components/ez-split-panel/structure/item/ez-split-item.css +0 -7
  54. package/dist/collection/components/ez-split-panel/structure/item/ez-split-item.js +1 -1
  55. package/dist/collection/utils/customEditor/interfaces/ICustomEditor.js +5 -0
  56. package/dist/collection/utils/customEditor/interfaces/ICustomEditorInfo.js +1 -0
  57. package/dist/collection/utils/customRender/interfaces/ICustomRender.js +5 -0
  58. package/dist/collection/utils/customRender/interfaces/ICustomRenderInfo.js +1 -0
  59. package/dist/collection/utils/index.js +2 -0
  60. package/dist/custom-elements/index.d.ts +6 -0
  61. package/dist/custom-elements/index.js +580 -61
  62. package/dist/esm/ICustomRender-875b5a40.js +13 -0
  63. package/dist/esm/ez-actions-button.entry.js +1 -0
  64. package/dist/esm/ez-alert-list.entry.js +11 -1
  65. package/dist/esm/ez-button.entry.js +2 -2
  66. package/dist/esm/ez-collapsible-box.entry.js +1 -0
  67. package/dist/esm/ez-combo-box.entry.js +1 -0
  68. package/dist/esm/{ez-text-edit.entry.js → ez-custom-form-input_2.entry.js} +88 -3
  69. package/dist/esm/ez-date-input.entry.js +1 -0
  70. package/dist/esm/ez-form-view.entry.js +36 -4
  71. package/dist/esm/ez-form.entry.js +51 -2
  72. package/dist/esm/ez-grid.entry.js +322 -19
  73. package/dist/esm/ez-list.entry.js +1 -1
  74. package/dist/esm/ez-modal-container.entry.js +16 -5
  75. package/dist/esm/ez-modal.entry.js +9 -10
  76. package/dist/esm/ez-number-input.entry.js +9 -2
  77. package/dist/esm/ez-popup.entry.js +15 -9
  78. package/dist/esm/ez-search.entry.js +6 -2
  79. package/dist/esm/ez-split-item.entry.js +3 -2
  80. package/dist/esm/ezui.js +1 -1
  81. package/dist/esm/index-baa5e267.js +4 -4
  82. package/dist/esm/loader.js +1 -1
  83. package/dist/ezui/ezui.esm.js +1 -1
  84. package/dist/ezui/p-09de35a2.entry.js +1 -0
  85. package/dist/ezui/p-13d2fe2d.entry.js +1 -0
  86. package/dist/ezui/{p-384247cd.entry.js → p-1f96ba9a.entry.js} +2 -2
  87. package/dist/ezui/p-204b1439.entry.js +1 -0
  88. package/dist/ezui/p-2b8da3a4.entry.js +1 -0
  89. package/dist/ezui/p-30775e7f.entry.js +1 -0
  90. package/dist/ezui/p-4607fb89.js +1 -0
  91. package/dist/ezui/{p-2a1a0e04.entry.js → p-77362d3a.entry.js} +1 -1
  92. package/dist/ezui/{p-8defa6d3.entry.js → p-786559c5.entry.js} +1 -1
  93. package/dist/ezui/p-7922142b.entry.js +1 -0
  94. package/dist/ezui/p-84e439b9.entry.js +1 -0
  95. package/dist/ezui/p-922ac38b.entry.js +1 -0
  96. package/dist/ezui/p-bae4e180.entry.js +1 -0
  97. package/dist/ezui/p-bcb53f27.entry.js +1 -0
  98. package/dist/ezui/p-c942e4a7.entry.js +1 -0
  99. package/dist/ezui/p-d9401ea0.entry.js +1 -0
  100. package/dist/ezui/p-e90dd4eb.entry.js +1 -0
  101. package/dist/ezui/p-f3c526cc.entry.js +1 -0
  102. package/dist/types/components/ez-alert-list/ez-alert-list.d.ts +5 -0
  103. package/dist/types/components/ez-form/ez-form.d.ts +20 -1
  104. package/dist/types/components/ez-form-view/custom-input/ez-custom-form-input.d.ts +41 -0
  105. package/dist/types/components/ez-form-view/ez-form-view.d.ts +11 -0
  106. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +29 -0
  107. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +11 -0
  108. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +7 -1
  109. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +19 -0
  110. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +14 -0
  111. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.d.ts +11 -0
  112. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.d.ts +11 -0
  113. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +3 -0
  114. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +15 -0
  115. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellRender.d.ts +10 -0
  116. package/dist/types/components/ez-grid/ez-grid.d.ts +30 -1
  117. package/dist/types/components/ez-grid/interfaces/ICustomFormatter.d.ts +5 -0
  118. package/dist/types/components/ez-grid/interfaces/index.d.ts +1 -0
  119. package/dist/types/components/ez-grid/subcomponents/utils/selectionCounterUtils.d.ts +4 -0
  120. package/dist/types/components/ez-grid/test/resources/gridDataUnit.d.ts +2 -0
  121. package/dist/types/components/ez-modal/ez-modal.d.ts +9 -1
  122. package/dist/types/components/ez-modal-container/ez-modal-container.d.ts +3 -0
  123. package/dist/types/components/ez-number-input/ez-number-input.d.ts +1 -0
  124. package/dist/types/components/ez-popup/ez-popup.d.ts +3 -3
  125. package/dist/types/components.d.ts +124 -4
  126. package/dist/types/utils/customEditor/interfaces/ICustomEditor.d.ts +29 -0
  127. package/dist/types/utils/customEditor/interfaces/ICustomEditorInfo.d.ts +5 -0
  128. package/dist/types/utils/customRender/interfaces/ICustomRender.d.ts +29 -0
  129. package/dist/types/utils/customRender/interfaces/ICustomRenderInfo.d.ts +5 -0
  130. package/dist/types/utils/index.d.ts +2 -0
  131. package/package.json +1 -1
  132. package/react/components.d.ts +1 -0
  133. package/react/components.js +1 -0
  134. package/react/components.js.map +1 -1
  135. package/dist/ezui/p-0447d17c.entry.js +0 -1
  136. package/dist/ezui/p-20ec22c0.entry.js +0 -1
  137. package/dist/ezui/p-5e1d036e.entry.js +0 -1
  138. package/dist/ezui/p-701231f0.entry.js +0 -1
  139. package/dist/ezui/p-7a636dfc.entry.js +0 -1
  140. package/dist/ezui/p-99ead599.entry.js +0 -1
  141. package/dist/ezui/p-9aefaa52.entry.js +0 -1
  142. package/dist/ezui/p-9f1e89c9.entry.js +0 -1
  143. package/dist/ezui/p-a1ec32ef.entry.js +0 -1
  144. package/dist/ezui/p-b041333c.entry.js +0 -1
  145. package/dist/ezui/p-b567fa8c.entry.js +0 -1
  146. package/dist/ezui/p-bae3d0aa.entry.js +0 -1
  147. package/dist/ezui/p-db77a984.entry.js +0 -1
  148. package/dist/ezui/p-e228ccb9.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 })));
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,245 @@
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
+ editorMetadata: {
45
+ label: this.formViewField.label,
46
+ hidden: ((_a = this.formViewField.props) === null || _a === void 0 ? void 0 : _a.visible) === false,
47
+ userInterface: this.formViewField.userInterface,
48
+ options: (_b = this.formViewField.props) === null || _b === void 0 ? void 0 : _b.options,
49
+ props: this.formViewField.props ? fieldProps : undefined,
50
+ optionLoader: this.formViewField.optionLoader
51
+ },
52
+ source: CustomEditorSource.FORM,
53
+ detailContext: this.detailContext
54
+ };
55
+ let gui = this.customEditor.getEditorElement(params);
56
+ if (!gui) {
57
+ gui = this.builderFallback(this.formViewField);
58
+ this.handleValue(gui);
59
+ this.gui = gui;
60
+ return;
61
+ }
62
+ if (!(gui instanceof HTMLElement) && typeof gui !== 'string') {
63
+ this.handleValue(gui);
64
+ this.gui = gui;
65
+ return;
66
+ }
67
+ if (typeof gui === 'string') {
68
+ gui = HTMLBuilder.parseElement(gui);
69
+ }
70
+ gui.setAttribute('value', this.value);
71
+ this.gui = h("div", { key: StringUtils.generateUUID(), ref: el => el && el.appendChild(gui) });
72
+ }
73
+ handleValue(gui) {
74
+ //@ts-ignore
75
+ gui.$children$.forEach((child) => {
76
+ child.$attrs$.value = this.value;
77
+ });
78
+ }
79
+ componentWillRender() {
80
+ this.getContent();
81
+ }
82
+ render() {
83
+ return (h(Host, null, this.gui));
84
+ }
85
+ static get is() { return "ez-custom-form-input"; }
86
+ static get encapsulation() { return "scoped"; }
87
+ static get properties() {
88
+ return {
89
+ "customEditor": {
90
+ "type": "unknown",
91
+ "mutable": false,
92
+ "complexType": {
93
+ "original": "ICustomEditor",
94
+ "resolved": "ICustomEditor",
95
+ "references": {
96
+ "ICustomEditor": {
97
+ "location": "import",
98
+ "path": "../../../utils/customEditor/interfaces/ICustomEditor"
99
+ }
100
+ }
101
+ },
102
+ "required": false,
103
+ "optional": false,
104
+ "docs": {
105
+ "tags": [],
106
+ "text": "Inst\u00E2ncia do editor customizado."
107
+ }
108
+ },
109
+ "formViewField": {
110
+ "type": "unknown",
111
+ "mutable": false,
112
+ "complexType": {
113
+ "original": "IFormViewField",
114
+ "resolved": "IFormViewField",
115
+ "references": {
116
+ "IFormViewField": {
117
+ "location": "import",
118
+ "path": "../interfaces"
119
+ }
120
+ }
121
+ },
122
+ "required": false,
123
+ "optional": false,
124
+ "docs": {
125
+ "tags": [],
126
+ "text": "Campo que o elemento customizado representa."
127
+ }
128
+ },
129
+ "value": {
130
+ "type": "any",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "any",
134
+ "resolved": "any",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": "Valores dos campos do formul\u00E1rio."
142
+ },
143
+ "attribute": "value",
144
+ "reflect": false
145
+ },
146
+ "detailContext": {
147
+ "type": "string",
148
+ "mutable": false,
149
+ "complexType": {
150
+ "original": "string",
151
+ "resolved": "string",
152
+ "references": {}
153
+ },
154
+ "required": false,
155
+ "optional": false,
156
+ "docs": {
157
+ "tags": [],
158
+ "text": "Define de qual contexto o editor est\u00E1 sendo acionado."
159
+ },
160
+ "attribute": "detail-context",
161
+ "reflect": false
162
+ },
163
+ "builderFallback": {
164
+ "type": "unknown",
165
+ "mutable": false,
166
+ "complexType": {
167
+ "original": "(field: IFormViewField) => HTMLElement",
168
+ "resolved": "(field: IFormViewField) => HTMLElement",
169
+ "references": {
170
+ "IFormViewField": {
171
+ "location": "import",
172
+ "path": "../interfaces"
173
+ },
174
+ "HTMLElement": {
175
+ "location": "global"
176
+ }
177
+ }
178
+ },
179
+ "required": false,
180
+ "optional": false,
181
+ "docs": {
182
+ "tags": [],
183
+ "text": "Builder original do FormView que ser\u00E1 chamado caso o custom n\u00E3o retorne nenhum valor."
184
+ }
185
+ }
186
+ };
187
+ }
188
+ static get states() {
189
+ return {
190
+ "gui": {}
191
+ };
192
+ }
193
+ static get methods() {
194
+ return {
195
+ "setFocus": {
196
+ "complexType": {
197
+ "signature": "() => Promise<void>",
198
+ "parameters": [],
199
+ "references": {
200
+ "Promise": {
201
+ "location": "global"
202
+ }
203
+ },
204
+ "return": "Promise<void>"
205
+ },
206
+ "docs": {
207
+ "text": "Aplica foco no campo.",
208
+ "tags": []
209
+ }
210
+ },
211
+ "setBlur": {
212
+ "complexType": {
213
+ "signature": "() => Promise<void>",
214
+ "parameters": [],
215
+ "references": {
216
+ "Promise": {
217
+ "location": "global"
218
+ }
219
+ },
220
+ "return": "Promise<void>"
221
+ },
222
+ "docs": {
223
+ "text": "Remove o foco do campo.",
224
+ "tags": []
225
+ }
226
+ },
227
+ "isInvalid": {
228
+ "complexType": {
229
+ "signature": "() => Promise<boolean>",
230
+ "parameters": [],
231
+ "references": {
232
+ "Promise": {
233
+ "location": "global"
234
+ }
235
+ },
236
+ "return": "Promise<boolean>"
237
+ },
238
+ "docs": {
239
+ "text": "Retorna se o conte\u00FAdo \u00E9 inv\u00E1lido.",
240
+ "tags": []
241
+ }
242
+ }
243
+ };
244
+ }
245
+ }
@@ -4,11 +4,35 @@ 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) {
27
+ field.props = field.props || {};
28
+ if (value || value === 0) {
29
+ field.props[propName] = value;
30
+ }
31
+ }
32
+ return field;
33
+ });
34
+ this.fields = [...fields];
35
+ }
12
36
  groupFields(fields) {
13
37
  const result = new Map();
14
38
  fields.forEach(item => {
@@ -28,8 +52,9 @@ export class EzFormView {
28
52
  return result;
29
53
  }
30
54
  componentDidRender() {
31
- this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
32
- const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
55
+ this._formElements = Array.from(this._element.querySelectorAll("[data-field-name]"));
56
+ this.ezContentReady.emit(this._formElements);
57
+ const formItems = new FormItems(this._formElements);
33
58
  this.formItemsReady.emit(formItems);
34
59
  }
35
60
  isItemFullWidth(userInterface) {
@@ -39,9 +64,15 @@ export class EzFormView {
39
64
  ].includes(userInterface);
40
65
  }
41
66
  buildFormItemElement(item, classItem = "") {
67
+ var _a;
42
68
  if (this.isItemFullWidth(item.userInterface)) {
43
69
  classItem += " input-full_width";
44
70
  }
71
+ if (this._customEditors.has(item.name)) {
72
+ 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;
73
+ const customEditor = this._customEditors.get(item.name).customEditor;
74
+ return h("div", { class: classItem }, h("ez-custom-form-input", { "data-field-name": item.name, customEditor: customEditor, formViewField: item, builderFallback: fieldBuilder, value: value }));
75
+ }
45
76
  return h("div", { class: classItem }, fieldBuilder(item));
46
77
  }
47
78
  render() {
@@ -102,6 +133,11 @@ export class EzFormView {
102
133
  }
103
134
  };
104
135
  }
136
+ static get states() {
137
+ return {
138
+ "_customEditors": {}
139
+ };
140
+ }
105
141
  static get events() {
106
142
  return [{
107
143
  "method": "ezContentReady",
@@ -164,6 +200,60 @@ export class EzFormView {
164
200
  "text": "",
165
201
  "tags": []
166
202
  }
203
+ },
204
+ "addCustomEditor": {
205
+ "complexType": {
206
+ "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
207
+ "parameters": [{
208
+ "tags": [],
209
+ "text": ""
210
+ }, {
211
+ "tags": [],
212
+ "text": ""
213
+ }, {
214
+ "tags": [],
215
+ "text": ""
216
+ }],
217
+ "references": {
218
+ "Promise": {
219
+ "location": "global"
220
+ },
221
+ "ICustomEditor": {
222
+ "location": "import",
223
+ "path": "../../utils/customEditor/interfaces/ICustomEditor"
224
+ }
225
+ },
226
+ "return": "Promise<void>"
227
+ },
228
+ "docs": {
229
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
230
+ "tags": []
231
+ }
232
+ },
233
+ "setFieldProp": {
234
+ "complexType": {
235
+ "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
236
+ "parameters": [{
237
+ "tags": [],
238
+ "text": ""
239
+ }, {
240
+ "tags": [],
241
+ "text": ""
242
+ }, {
243
+ "tags": [],
244
+ "text": ""
245
+ }],
246
+ "references": {
247
+ "Promise": {
248
+ "location": "global"
249
+ }
250
+ },
251
+ "return": "Promise<void>"
252
+ },
253
+ "docs": {
254
+ "text": "Altera/adiciona uma propriedade nos metados do campo.",
255
+ "tags": []
256
+ }
167
257
  }
168
258
  };
169
259
  }
@@ -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 }) => {