@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-47941.0 → 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 (114) hide show
  1. package/dist/cjs/{IExporterProvider-d3a3ccd1.js → IExporterProvider-e286ef6a.js} +3 -3
  2. package/dist/cjs/{SnkFormConfigManager-dda10d75.js → SnkFormConfigManager-7b222c78.js} +2 -2
  3. package/dist/cjs/{dataunit-fetcher-e2109392.js → dataunit-fetcher-7a08e4dd.js} +6 -2
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/snk-actions-button_4.cjs.entry.js +1 -1
  7. package/dist/cjs/snk-application.cjs.entry.js +1 -1
  8. package/dist/cjs/snk-attach.cjs.entry.js +16 -21
  9. package/dist/cjs/snk-crud.cjs.entry.js +54 -3
  10. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  11. package/dist/cjs/{snk-data-unit-dee38ccd.js → snk-data-unit-3718477f.js} +79 -23
  12. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-detail-view.cjs.entry.js +43 -4
  14. package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -1
  15. package/dist/cjs/snk-form-view.cjs.entry.js +31 -0
  16. package/dist/cjs/snk-form.cjs.entry.js +28 -3
  17. package/dist/cjs/snk-grid.cjs.entry.js +50 -3
  18. package/dist/cjs/{snk-guides-viewer-af4a6ae5.js → snk-guides-viewer-66dd6949.js} +21 -5
  19. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
  20. package/dist/cjs/snk-simple-crud.cjs.entry.js +64 -7
  21. package/dist/collection/components/snk-attach/snk-attach.js +21 -29
  22. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  23. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  24. package/dist/collection/components/snk-crud/snk-crud.js +122 -2
  25. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
  26. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +82 -0
  27. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +73 -3
  28. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +1 -1
  29. package/dist/collection/components/snk-data-unit/snk-data-unit.js +98 -23
  30. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
  31. package/dist/collection/components/snk-form/snk-form.js +53 -2
  32. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +2 -2
  33. package/dist/collection/components/snk-grid/snk-grid.js +123 -1
  34. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +130 -4
  35. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +1 -1
  36. package/dist/collection/lib/dataUnit/InMemoryLoader.js +6 -2
  37. package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
  38. package/dist/components/IExporterProvider.js +2 -2
  39. package/dist/components/SnkFormConfigManager.js +2 -2
  40. package/dist/components/dataunit-fetcher.js +6 -2
  41. package/dist/components/snk-attach2.js +15 -20
  42. package/dist/components/snk-crud.js +56 -2
  43. package/dist/components/snk-data-unit2.js +80 -23
  44. package/dist/components/snk-detail-view2.js +68 -5
  45. package/dist/components/snk-filter-bar2.js +6 -1
  46. package/dist/components/snk-form-view2.js +33 -0
  47. package/dist/components/snk-form.js +28 -2
  48. package/dist/components/snk-grid2.js +51 -1
  49. package/dist/components/snk-simple-crud2.js +64 -4
  50. package/dist/esm/{IExporterProvider-640e1f6b.js → IExporterProvider-cf5a56ee.js} +3 -3
  51. package/dist/esm/{SnkFormConfigManager-87bd8082.js → SnkFormConfigManager-3bdb3e1f.js} +2 -2
  52. package/dist/esm/{dataunit-fetcher-87ecba4a.js → dataunit-fetcher-f3fa35b9.js} +6 -2
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/esm/sankhyablocks.js +1 -1
  55. package/dist/esm/snk-actions-button_4.entry.js +1 -1
  56. package/dist/esm/snk-application.entry.js +1 -1
  57. package/dist/esm/snk-attach.entry.js +16 -21
  58. package/dist/esm/snk-crud.entry.js +54 -3
  59. package/dist/esm/snk-data-exporter.entry.js +2 -2
  60. package/dist/esm/{snk-data-unit-1132e40b.js → snk-data-unit-8d6afa43.js} +80 -24
  61. package/dist/esm/snk-data-unit.entry.js +2 -2
  62. package/dist/esm/snk-detail-view.entry.js +43 -4
  63. package/dist/esm/snk-filter-bar.entry.js +5 -1
  64. package/dist/esm/snk-form-view.entry.js +31 -0
  65. package/dist/esm/snk-form.entry.js +28 -3
  66. package/dist/esm/snk-grid.entry.js +50 -3
  67. package/dist/esm/{snk-guides-viewer-359e39a7.js → snk-guides-viewer-11cf8dc7.js} +21 -5
  68. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  69. package/dist/esm/snk-simple-crud.entry.js +64 -7
  70. package/dist/sankhyablocks/p-0a28cb19.entry.js +1 -0
  71. package/dist/sankhyablocks/p-188e1432.entry.js +1 -0
  72. package/dist/sankhyablocks/p-1c6debe6.entry.js +1 -0
  73. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  74. package/dist/sankhyablocks/p-2cc2d8fd.entry.js +1 -0
  75. package/dist/sankhyablocks/{p-66a31d30.entry.js → p-3e4c2cfe.entry.js} +1 -1
  76. package/dist/sankhyablocks/{p-9c70f37e.entry.js → p-4a8a149d.entry.js} +1 -1
  77. package/dist/sankhyablocks/p-50e72d6c.js +1 -0
  78. package/dist/sankhyablocks/p-5bd78e4c.entry.js +1 -0
  79. package/dist/sankhyablocks/{p-b11921ca.entry.js → p-8171e586.entry.js} +1 -1
  80. package/dist/sankhyablocks/{p-d29a252c.js → p-a97060b0.js} +1 -1
  81. package/dist/sankhyablocks/p-b27114c4.js +1 -0
  82. package/dist/sankhyablocks/{p-83950924.entry.js → p-b643f746.entry.js} +1 -1
  83. package/dist/sankhyablocks/{p-d799aa7f.entry.js → p-b68918fc.entry.js} +1 -1
  84. package/dist/sankhyablocks/p-da7c81d6.entry.js +1 -0
  85. package/dist/sankhyablocks/{p-da6e3dcf.entry.js → p-e238279a.entry.js} +1 -1
  86. package/dist/sankhyablocks/p-eae66367.js +1 -0
  87. package/dist/sankhyablocks/{p-08fee6e8.js → p-fde91811.js} +1 -1
  88. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  89. package/dist/types/components/snk-attach/snk-attach.d.ts +9 -9
  90. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  91. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  92. package/dist/types/components/snk-crud/snk-crud.d.ts +18 -0
  93. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  94. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +15 -2
  95. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +13 -0
  96. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +16 -1
  97. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  98. package/dist/types/components/snk-form/snk-form.d.ts +8 -0
  99. package/dist/types/components/snk-grid/snk-grid.d.ts +23 -0
  100. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +18 -2
  101. package/dist/types/components.d.ts +112 -0
  102. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
  103. package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
  104. package/package.json +1 -1
  105. package/dist/sankhyablocks/p-0bcc6e83.js +0 -1
  106. package/dist/sankhyablocks/p-2eb90860.js +0 -1
  107. package/dist/sankhyablocks/p-33f695d6.entry.js +0 -1
  108. package/dist/sankhyablocks/p-3519a984.entry.js +0 -1
  109. package/dist/sankhyablocks/p-5c8a9e27.entry.js +0 -1
  110. package/dist/sankhyablocks/p-7ecaaea2.entry.js +0 -1
  111. package/dist/sankhyablocks/p-931343a1.entry.js +0 -1
  112. package/dist/sankhyablocks/p-cb91634d.js +0 -1
  113. package/dist/sankhyablocks/p-cf9d2d1e.entry.js +0 -1
  114. package/dist/sankhyablocks/p-f72e8835.entry.js +0 -1
@@ -4,7 +4,7 @@ import { D as DataFetcher } from './DataFetcher-4b4b7beb.js';
4
4
  import './pesquisa-fetcher-9cfab836.js';
5
5
  import './index-0ece87a6.js';
6
6
  import { S as SaveErrorsEnum } from './ISave-d8c8bc59.js';
7
- import { P as PreloadManager, b as applyFilter, c as applySorting, d as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher-87ecba4a.js';
7
+ import { P as PreloadManager, b as applyFilter, c as applySorting, d as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher-f3fa35b9.js';
8
8
  import './filter-item-type.enum-d45e026f.js';
9
9
  import './form-config-fetcher-5d72aaf1.js';
10
10
  import { d as VIEW_MODE } from './constants-8457af36.js';
@@ -650,25 +650,22 @@ const SnkAttach = class {
650
650
  this._currentDataUnit = undefined;
651
651
  this.crudConfig = undefined;
652
652
  }
653
- registerKeyWatcher(newRegisterKey, oldRegisterKey) {
653
+ async initAttach() {
654
654
  var _a, _b, _c, _d, _e, _f;
655
- if (!this._currentDataUnit) {
656
- this.loadAttachmentDataUnit();
655
+ await this.loadAttachmentDataUnit();
656
+ this.returnToGridMode();
657
+ if (this.fetcherType === "AnexoSistema") {
658
+ this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
659
+ (_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
660
+ await ((_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData());
661
+ return;
657
662
  }
658
- if (oldRegisterKey !== newRegisterKey) {
659
- this.returnToGridMode();
660
- if (this.fetcherType === "AnexoSistema") {
661
- this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
662
- (_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
663
- return (_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData();
664
- }
665
- if (this.fetcherType === "Attach") {
666
- const hasMoreOneItem = ((_d = this.registerKey) === null || _d === void 0 ? void 0 : _d.split("_").length) > 1;
667
- if (hasMoreOneItem)
668
- return;
669
- }
670
- return (_f = (_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadMetadata()) === null || _f === void 0 ? void 0 : _f.then(this._currentDataUnit.loadData.bind(undefined, undefined, true, this.registerKey));
663
+ if (this.fetcherType === "Attach") {
664
+ const hasMoreOneItem = ((_d = this.registerKey) === null || _d === void 0 ? void 0 : _d.split("_").length) > 1;
665
+ if (hasMoreOneItem)
666
+ return;
671
667
  }
668
+ (_f = (_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadMetadata()) === null || _f === void 0 ? void 0 : _f.then(this._currentDataUnit.loadData.bind(undefined, undefined, true, this.registerKey));
672
669
  }
673
670
  /**
674
671
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
@@ -790,8 +787,9 @@ const SnkAttach = class {
790
787
  }
791
788
  });
792
789
  }
793
- componentWillLoad() {
790
+ async componentWillLoad() {
794
791
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
792
+ await this.initAttach();
795
793
  }
796
794
  componentWillRender() {
797
795
  if (!this.fetcherType) {
@@ -819,9 +817,6 @@ const SnkAttach = class {
819
817
  return null;
820
818
  return (h("main", { class: "snk-attach__main" }, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this._currentDataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick, messagesBuilder: this.messagesBuilder, onDataStateChange: this.handleOnDataStateChange.bind(this) }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
821
819
  }
822
- static get watchers() { return {
823
- "registerKey": ["registerKeyWatcher"]
824
- }; }
825
820
  };
826
821
  SnkAttach.style = snkAttachCss;
827
822
 
@@ -7,7 +7,7 @@ import { P as PresentationMode } from './index-0ece87a6.js';
7
7
  import './ISave-d8c8bc59.js';
8
8
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
9
9
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
10
- import './dataunit-fetcher-87ecba4a.js';
10
+ import './dataunit-fetcher-f3fa35b9.js';
11
11
  import './filter-item-type.enum-d45e026f.js';
12
12
  import './form-config-fetcher-5d72aaf1.js';
13
13
  import { d as VIEW_MODE } from './constants-8457af36.js';
@@ -29,6 +29,8 @@ const SnkCrud = class {
29
29
  this.formItemsReady = createEvent(this, "formItemsReady", 7);
30
30
  this._keyDownHandler = async (event) => this.keyDownListener(event);
31
31
  this._viewHistory = [];
32
+ this._customEditors = new Map();
33
+ this._customRenders = new Map();
32
34
  this._dataUnit = undefined;
33
35
  this._dataState = undefined;
34
36
  this.attachmentRegisterKey = undefined;
@@ -51,6 +53,7 @@ const SnkCrud = class {
51
53
  this.filterBarLegacyConfigName = undefined;
52
54
  this.formLegacyConfigName = undefined;
53
55
  this.disablePersonalizedFilter = undefined;
56
+ this.autoLoad = undefined;
54
57
  this.customContainerId = `SNK-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
55
58
  }
56
59
  /**
@@ -86,6 +89,31 @@ const SnkCrud = class {
86
89
  async getFilterBar() {
87
90
  return await this._snkGrid.getFilterBar();
88
91
  }
92
+ /**
93
+ * Registra um editor customizado para campos da grade e formulário.
94
+ */
95
+ async addCustomEditor(fieldName, customEditor) {
96
+ if (this._guidesViewer && this._snkGrid) {
97
+ this._guidesViewer.addCustomEditor(fieldName, customEditor);
98
+ this._snkGrid.addCustomEditor(fieldName, customEditor);
99
+ return;
100
+ }
101
+ const newCustomEditors = new Map(this._customEditors);
102
+ newCustomEditors.set(fieldName, customEditor);
103
+ this._customEditors = newCustomEditors;
104
+ }
105
+ /**
106
+ * Registra um render customizado para colunas da grid.
107
+ */
108
+ async addGridCustomRender(fieldName, customRender) {
109
+ if (this._snkGrid) {
110
+ this._snkGrid.addGridCustomRender(fieldName, customRender);
111
+ return;
112
+ }
113
+ const newCustomRenders = new Map(this._customRenders);
114
+ newCustomRenders.set(fieldName, customRender);
115
+ this._customRenders = newCustomRenders;
116
+ }
89
117
  /**
90
118
  * Registra um formatador de valores para uma coluna da grid.
91
119
  */
@@ -157,6 +185,29 @@ const SnkCrud = class {
157
185
  const joinedPrimaryKeys = recordCriteria.map(({ value }) => value).join('_');
158
186
  return joinedPrimaryKeys;
159
187
  }
188
+ setCustomRenders() {
189
+ if (!this._snkGrid) {
190
+ return;
191
+ }
192
+ for (const [fieldName, customRender] of this._customRenders) {
193
+ this._snkGrid.addGridCustomRender(fieldName, customRender);
194
+ this._customRenders.delete(fieldName);
195
+ }
196
+ }
197
+ setCustomEditors() {
198
+ if (!this._snkGrid || !this._guidesViewer) {
199
+ return;
200
+ }
201
+ for (const [fieldName, customEditor] of this._customEditors) {
202
+ this._guidesViewer.addCustomEditor(fieldName, customEditor);
203
+ this._snkGrid.addCustomEditor(fieldName, customEditor);
204
+ this._customEditors.delete(fieldName);
205
+ }
206
+ }
207
+ componentDidRender() {
208
+ this.setCustomRenders();
209
+ this.setCustomEditors();
210
+ }
160
211
  componentWillLoad() {
161
212
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
162
213
  let parent = this._element.parentElement;
@@ -207,7 +258,7 @@ const SnkCrud = class {
207
258
  continue;
208
259
  }
209
260
  const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
210
- if (!rmPrecision) {
261
+ if (!rmPrecision && rmPrecision !== 0) {
211
262
  continue;
212
263
  }
213
264
  await this.setFieldProp(field, 'precision', rmPrecision);
@@ -333,7 +384,7 @@ const SnkCrud = class {
333
384
  return;
334
385
  }
335
386
  this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
336
- return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName }, h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkFormTaskBar" }))), h("stack-item", null, h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.backView.bind(this) })), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.setViewMode(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showActionButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this._resourceID, customContainerId: this.customContainerId })), h("div", { id: `${this.customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }), h("slot", { name: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }))));
387
+ return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName }, h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkFormTaskBar" }))), h("stack-item", null, h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.backView.bind(this) })), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.setViewMode(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showActionButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this._resourceID, customContainerId: this.customContainerId })), h("div", { id: `${this.customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }), h("slot", { name: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }))));
337
388
  }
338
389
  get _element() { return getElement(this); }
339
390
  static get watchers() { return {
@@ -4,12 +4,12 @@ import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/
4
4
  import { D as DataExporterOption, a as DataExporterFormat, b as DataExporterType } from './index-0ece87a6.js';
5
5
  import { R as REPORT_LAUNCHER_RESOURCE_ID } from './constants-8457af36.js';
6
6
  import { D as DataFetcher } from './DataFetcher-4b4b7beb.js';
7
- import { S as SnkDataUnit } from './snk-data-unit-1132e40b.js';
7
+ import { S as SnkDataUnit } from './snk-data-unit-8d6afa43.js';
8
8
  import './pesquisa-fetcher-9cfab836.js';
9
9
  import './ISave-d8c8bc59.js';
10
10
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
11
11
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
12
- import './dataunit-fetcher-87ecba4a.js';
12
+ import './dataunit-fetcher-f3fa35b9.js';
13
13
  import './filter-item-type.enum-d45e026f.js';
14
14
  import './form-config-fetcher-5d72aaf1.js';
15
15
  import './PrintUtils-3e4ff0f5.js';
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-a7d3d3f1.js';
2
- import { Action, ObjectUtils, DataUnitAction, ApplicationContext } from '@sankhyalabs/core';
2
+ import { Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder-3a767111.js';
5
- import { g as getRecordValue, a as DatasetStrategy } from './dataunit-fetcher-87ecba4a.js';
5
+ import { g as getRecordValue, a as DatasetStrategy } from './dataunit-fetcher-f3fa35b9.js';
6
6
  import { g as getSelectedIDs } from './RecordIDUtils-87d02110.js';
7
7
 
8
8
  const SnkDataUnit = class {
@@ -11,6 +11,7 @@ const SnkDataUnit = class {
11
11
  this.dataStateChange = createEvent(this, "dataStateChange", 3);
12
12
  this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
13
13
  this.messagesBuilderUpdated = createEvent(this, "messagesBuilderUpdated", 3);
14
+ this.dataUnitFieldsHidded = createEvent(this, "dataUnitFieldsHidded", 7);
14
15
  this.insertionMode = createEvent(this, "insertionMode", 3);
15
16
  this.cancelEdition = createEvent(this, "cancelEdition", 3);
16
17
  this._onDataUnitResolve = [];
@@ -19,6 +20,7 @@ const SnkDataUnit = class {
19
20
  this._fieldsWithRmPrecision = [];
20
21
  this._metadataByRow = new Map();
21
22
  this._rowMetadataCache = new Map();
23
+ this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
22
24
  this._dataUnitObserver = async (action) => {
23
25
  const duState = this.buildDataState(action.type);
24
26
  this.dataState = duState;
@@ -39,6 +41,7 @@ const SnkDataUnit = class {
39
41
  break;
40
42
  }
41
43
  };
44
+ this.fieldsToLink = [];
42
45
  this.dataState = undefined;
43
46
  this.messagesBuilder = undefined;
44
47
  this.dataUnitName = undefined;
@@ -228,23 +231,14 @@ const SnkDataUnit = class {
228
231
  ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
229
232
  return;
230
233
  }
231
- return action;
234
+ return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
232
235
  }
233
236
  interceptRecordsCopied(action) {
234
237
  if (!this.isAllowed("CLONE")) {
235
238
  ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
236
239
  return;
237
240
  }
238
- const cleanFields = this.getCleanOnCopyFields();
239
- if (cleanFields.length > 0) {
240
- const records = action.payload;
241
- action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
242
- const newRecord = Object.assign({}, record);
243
- cleanFields.forEach(fieldName => delete newRecord[fieldName]);
244
- return newRecord;
245
- }));
246
- }
247
- return action;
241
+ return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
248
242
  }
249
243
  async interceptDataChange(action) {
250
244
  if (this.isAllowed("UPDATE")) {
@@ -326,7 +320,7 @@ const SnkDataUnit = class {
326
320
  interceptMetadataLoaded(action) {
327
321
  this.fillFieldsWithRmp(action.payload);
328
322
  this.fillFieldsWithRmPrecision(action.payload);
329
- return action;
323
+ return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
330
324
  }
331
325
  async interceptAction(action) {
332
326
  switch (action.type) {
@@ -385,6 +379,47 @@ const SnkDataUnit = class {
385
379
  return Object.assign({}, response._rmd);
386
380
  }
387
381
  }
382
+ handleDULinksOnMetadataLoaded(payload) {
383
+ const metadata = Object.assign({}, payload);
384
+ this.processLinks(metadata);
385
+ return metadata;
386
+ }
387
+ handleRecordsCopied(initialRecords) {
388
+ let records = [...initialRecords];
389
+ records = this.handleCleanOnCopy(records);
390
+ return this.handleLinksWithParent(records);
391
+ }
392
+ handleLinksWithParent(records) {
393
+ var _a, _b;
394
+ const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
395
+ if (!parentDataUnit)
396
+ return records;
397
+ const parentSelectedRecord = parentDataUnit.getSelectedRecord();
398
+ const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
399
+ const { links } = selfInfo;
400
+ if (!links || links.length === 0)
401
+ return records;
402
+ return records.map(record => {
403
+ return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
404
+ });
405
+ }
406
+ buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
407
+ const newRecord = Object.assign({}, record);
408
+ links.forEach(link => newRecord[link.target] = parentSelectedRecord[link.source]);
409
+ return newRecord;
410
+ }
411
+ handleCleanOnCopy(records) {
412
+ const cleanFields = this.getCleanOnCopyFields();
413
+ if (cleanFields.length > 0) {
414
+ records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
415
+ }
416
+ return records;
417
+ }
418
+ buildCopyWithCleanedFields(record, cleanFields) {
419
+ const newRecord = Object.assign({}, record);
420
+ cleanFields.forEach(fieldName => delete newRecord[fieldName]);
421
+ return newRecord;
422
+ }
388
423
  showSuccessMessage(message) {
389
424
  ApplicationUtils.info(message, { iconName: "check" });
390
425
  }
@@ -528,20 +563,40 @@ const SnkDataUnit = class {
528
563
  return;
529
564
  }
530
565
  handlerLinkFields() {
531
- var _a, _b;
532
- const metadata = Object.assign({}, this.dataUnit.metadata);
533
- if (!this._parentDataUnit)
566
+ var _a, _b, _c, _d;
567
+ const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
568
+ if (!parentDU)
534
569
  return;
535
- const child = this._parentDataUnit.getChildInfo(this.entityName);
570
+ const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
571
+ const child = parentDU.getChildInfo(childName);
536
572
  if (!child)
537
573
  return;
538
- const fieldsLink = (_a = child === null || child === void 0 ? void 0 : child.links) === null || _a === void 0 ? void 0 : _a.map(link => link.target);
539
- (_b = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
540
- if (fieldsLink === null || fieldsLink === void 0 ? void 0 : fieldsLink.includes(field.name)) {
574
+ const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
575
+ this.handleDUWithLinks(links);
576
+ }
577
+ handleDUWithLinks(fieldsToLink) {
578
+ this.fieldsToLink = fieldsToLink;
579
+ const metadata = Object.assign({}, this.dataUnit.metadata);
580
+ this.processLinks(metadata);
581
+ this.dataUnit.metadata = metadata;
582
+ this.dataUnitFieldsHidded.emit();
583
+ }
584
+ processLinks(metadata) {
585
+ var _a;
586
+ (_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
587
+ var _a;
588
+ if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
541
589
  field.visible = false;
542
590
  }
543
591
  });
544
- this.dataUnit.metadata = metadata;
592
+ }
593
+ getCleanDataUnitName() {
594
+ var _a;
595
+ const uri = this.dataUnit.name;
596
+ if (StringUtils.isEmpty(uri))
597
+ return uri;
598
+ const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
599
+ return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
545
600
  }
546
601
  static getNearestInstance(element) {
547
602
  let parent = element.parentElement;
@@ -568,8 +623,9 @@ const SnkDataUnit = class {
568
623
  this.dataUnit.releaseCallbacks();
569
624
  }
570
625
  }
571
- componentDidLoad() {
572
- this.loadDataUnit();
626
+ async componentDidLoad() {
627
+ await this.loadDataUnit();
628
+ this.handlerLinkFields();
573
629
  }
574
630
  render() {
575
631
  return (h(Host, null));
@@ -1,9 +1,9 @@
1
- export { S as snk_data_unit } from './snk-data-unit-1132e40b.js';
1
+ export { S as snk_data_unit } from './snk-data-unit-8d6afa43.js';
2
2
  import './index-a7d3d3f1.js';
3
3
  import '@sankhyalabs/core';
4
4
  import '@sankhyalabs/ezui/dist/collection/utils';
5
5
  import './SnkMessageBuilder-3a767111.js';
6
- import './dataunit-fetcher-87ecba4a.js';
6
+ import './dataunit-fetcher-f3fa35b9.js';
7
7
  import './DataFetcher-4b4b7beb.js';
8
8
  import './PrintUtils-3e4ff0f5.js';
9
9
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host } from './index-a7d3d3f1.js';
2
2
  import { Action } from '@sankhyalabs/core';
3
- import { S as SnkFormConfigManager } from './SnkFormConfigManager-87bd8082.js';
3
+ import { S as SnkFormConfigManager } from './SnkFormConfigManager-3bdb3e1f.js';
4
4
  import { FormMetadata, buildFormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
5
5
  import './DataFetcher-4b4b7beb.js';
6
6
  import './pesquisa-fetcher-9cfab836.js';
@@ -8,12 +8,12 @@ import { P as PresentationMode } from './index-0ece87a6.js';
8
8
  import './ISave-d8c8bc59.js';
9
9
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
10
10
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
11
- import './dataunit-fetcher-87ecba4a.js';
11
+ import './dataunit-fetcher-f3fa35b9.js';
12
12
  import './filter-item-type.enum-d45e026f.js';
13
13
  import './form-config-fetcher-5d72aaf1.js';
14
14
  import { T as TaskbarElement } from './taskbar-elements-ad766858.js';
15
15
  import { d as VIEW_MODE } from './constants-8457af36.js';
16
- import { S as SnkGuidesViewer } from './snk-guides-viewer-359e39a7.js';
16
+ import { S as SnkGuidesViewer } from './snk-guides-viewer-11cf8dc7.js';
17
17
  import { S as SnkMessageBuilder } from './SnkMessageBuilder-3a767111.js';
18
18
  import './ConfigStorage-174101b9.js';
19
19
  import './PrintUtils-3e4ff0f5.js';
@@ -91,6 +91,8 @@ const SnkDetailView = class {
91
91
  this.branchGuide = undefined;
92
92
  this.canEdit = true;
93
93
  this.taskbarCustomContainerId = undefined;
94
+ this.customEditors = undefined;
95
+ this.customRenders = undefined;
94
96
  }
95
97
  observeDataUnit(newDataUnit, oldDataUnit) {
96
98
  newDataUnit === null || newDataUnit === void 0 ? void 0 : newDataUnit.subscribe(this.dataUnitActionHandler.bind(this));
@@ -158,10 +160,38 @@ const SnkDetailView = class {
158
160
  this._snkGrid.scrollIntoView({ behavior: "smooth", block: "start" });
159
161
  }
160
162
  }
163
+ /**
164
+ * Registra um editor customizado para campos da grade e formulário.
165
+ */
166
+ async addCustomEditor(fieldName, customEditor) {
167
+ var _a;
168
+ const detailContext = this.normalizeBranchGuideId((_a = this.branchGuide) === null || _a === void 0 ? void 0 : _a.id);
169
+ this._snkGrid.addCustomEditor(fieldName, customEditor, detailContext);
170
+ this._snkFormView.addCustomEditor(fieldName, customEditor, detailContext);
171
+ }
172
+ async observerPropsCustomEditor(newValue) {
173
+ for (const fieldName in newValue) {
174
+ await this.addCustomEditor(fieldName, newValue[fieldName]);
175
+ }
176
+ }
177
+ /**
178
+ * Registra um render customizado para colunas da grid.
179
+ */
180
+ async addGridCustomRender(fieldName, customRender) {
181
+ var _a;
182
+ const detailContext = this.normalizeBranchGuideId((_a = this.branchGuide) === null || _a === void 0 ? void 0 : _a.id);
183
+ await this._snkGrid.addGridCustomRender(fieldName, customRender, detailContext);
184
+ }
161
185
  onContentCardChanged(evt) {
162
186
  SnkGuidesViewer.updateContentCard(evt.detail.formName, evt.detail.cardConfig, evt.detail.propertyChanged, this.formConfigManager).then(() => forceUpdate(this));
163
187
  evt.stopPropagation();
164
188
  }
189
+ async observeCustomRenders(newValue) {
190
+ for (const field in newValue) {
191
+ const customRender = newValue[field];
192
+ await this.addGridCustomRender(field, customRender);
193
+ }
194
+ }
165
195
  updateLabel() {
166
196
  const guideItemPathSize = this.guideItemPath ? this.guideItemPath.length : 0;
167
197
  if (guideItemPathSize > 0) {
@@ -264,6 +294,10 @@ const SnkDetailView = class {
264
294
  this.messagesBuilder = new SnkMessageBuilder(this.entityName);
265
295
  }
266
296
  }
297
+ async componentDidLoad() {
298
+ await this.observerPropsCustomEditor(this.customEditors);
299
+ await this.observeCustomRenders(this.customRenders);
300
+ }
267
301
  async dataUnitActionHandler(action) {
268
302
  if (action.type === Action.FIELD_INVALIDATED) {
269
303
  this.addErrorBadgeToBranchGuide();
@@ -273,6 +307,9 @@ const SnkDetailView = class {
273
307
  this.branchGuide = Object.assign(Object.assign({}, this.branchGuide), { badge: 'error' });
274
308
  this.snkDetailGuidesChange.emit(new GuideBuilder(this.branchGuide, this._formMetadata, this.dataUnit));
275
309
  }
310
+ normalizeBranchGuideId(id) {
311
+ return id === null || id === void 0 ? void 0 : id.replace(/child\[(.*?)\]/g, '$1').replace(/::/g, '>');
312
+ }
276
313
  render() {
277
314
  this.updateLabel();
278
315
  //const cardConfig: IFormCardConfig = this._cardsState?.get(this.selectedForm);
@@ -280,7 +317,9 @@ const SnkDetailView = class {
280
317
  }
281
318
  static get watchers() { return {
282
319
  "dataUnit": ["observeDataUnit"],
283
- "dataState": ["observerDataState"]
320
+ "dataState": ["observerDataState"],
321
+ "customEditors": ["observerPropsCustomEditor"],
322
+ "customRenders": ["observeCustomRenders"]
284
323
  }; }
285
324
  };
286
325
  SnkDetailView.REGEX_FORM_ID = /__FORM:[^:]+/g;
@@ -282,6 +282,7 @@ const SnkFilterBar = class {
282
282
  this.messagesBuilder = undefined;
283
283
  this.disablePersonalizedFilter = undefined;
284
284
  this.filterBarLegacyConfigName = undefined;
285
+ this.autoLoad = undefined;
285
286
  this.allowDefault = undefined;
286
287
  this.scrollerLocked = false;
287
288
  this.showPersonalizedFilter = false;
@@ -428,7 +429,10 @@ const SnkFilterBar = class {
428
429
  }
429
430
  async doLoadData(forceReload = false) {
430
431
  try {
431
- if (this._firstLoad && !forceReload) {
432
+ if (this._firstLoad && this.autoLoad === false) {
433
+ return;
434
+ }
435
+ if (this._firstLoad && !forceReload && this.autoLoad === undefined) {
432
436
  let autoLoad = await this._application.getBooleanParam("global.carregar.registros.iniciar.tela");
433
437
  if (!autoLoad) {
434
438
  return;
@@ -10,6 +10,7 @@ const SnkFormView = class {
10
10
  this.snkContentCardChanged = createEvent(this, "snkContentCardChanged", 7);
11
11
  this.snkRequestClearFieldToFocus = createEvent(this, "snkRequestClearFieldToFocus", 7);
12
12
  this.formItemsReady = createEvent(this, "formItemsReady", 7);
13
+ this._customEditors = new Map();
13
14
  this._fieldProps = new Map();
14
15
  this.levelPath = undefined;
15
16
  this.label = undefined;
@@ -24,6 +25,7 @@ const SnkFormView = class {
24
25
  this.canFix = true;
25
26
  this.recordsValidator = undefined;
26
27
  this.fieldToFocus = undefined;
28
+ this.customEditors = undefined;
27
29
  this.fieldsProps = undefined;
28
30
  }
29
31
  async showUp() {
@@ -31,6 +33,23 @@ const SnkFormView = class {
31
33
  this._formView.showUp();
32
34
  }
33
35
  }
36
+ /**
37
+ * Registra um editor customizado para campos da grade e formulário
38
+ */
39
+ async addCustomEditor(fieldName, customEditor, detailContext) {
40
+ if (this._formView) {
41
+ this._formView.addCustomEditor(fieldName, customEditor, detailContext);
42
+ return;
43
+ }
44
+ const newCustomEditors = new Map(this._customEditors);
45
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
46
+ this._customEditors = newCustomEditors;
47
+ }
48
+ observePropsCustomEditor(newValue) {
49
+ for (const fieldName in newValue) {
50
+ this.addCustomEditor(fieldName, newValue[fieldName]);
51
+ }
52
+ }
34
53
  /**
35
54
  * Altera/adiciona uma propriedade nos metadados do campo.
36
55
  */
@@ -106,9 +125,11 @@ const SnkFormView = class {
106
125
  }
107
126
  }
108
127
  componentDidLoad() {
128
+ this.observePropsCustomEditor(this.customEditors);
109
129
  this.observeFieldsProps(this.fieldsProps);
110
130
  }
111
131
  componentDidRender() {
132
+ this.setCustomEditors();
112
133
  this.setFieldProps();
113
134
  if (this.fieldToFocus == undefined) {
114
135
  return;
@@ -121,6 +142,15 @@ const SnkFormView = class {
121
142
  this.snkRequestClearFieldToFocus.emit();
122
143
  });
123
144
  }
145
+ setCustomEditors() {
146
+ if (!this._formView) {
147
+ return;
148
+ }
149
+ for (const [fieldName, customEditorProps] of this._customEditors) {
150
+ this._formView.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
151
+ this._customEditors.delete(fieldName);
152
+ }
153
+ }
124
154
  setFieldProps() {
125
155
  if (!this._formView) {
126
156
  return;
@@ -142,6 +172,7 @@ const SnkFormView = class {
142
172
  h("ez-form-view", { ref: ref => this._formView = ref, fields: this.fields, onEzContentReady: evt => this.bindFields(evt.detail), onFormItemsReady: (event) => this.handleFormItemsReady(event) })));
143
173
  }
144
174
  static get watchers() { return {
175
+ "customEditors": ["observePropsCustomEditor"],
145
176
  "fieldsProps": ["observeFieldsProps"]
146
177
  }; }
147
178
  };
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-a7d3d3f1.js';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
- import { S as SnkFormConfigManager } from './SnkFormConfigManager-87bd8082.js';
3
+ import { S as SnkFormConfigManager } from './SnkFormConfigManager-3bdb3e1f.js';
4
4
  import { R as ResourceIDUtils } from './ResourceIDUtils-a114189a.js';
5
5
  import './ConfigStorage-174101b9.js';
6
6
  import './form-config-fetcher-5d72aaf1.js';
@@ -17,6 +17,7 @@ const SnkForm = class {
17
17
  this.exit = createEvent(this, "exit", 7);
18
18
  this.actionClick = createEvent(this, "actionClick", 7);
19
19
  this.formItemsReady = createEvent(this, "formItemsReady", 7);
20
+ this._customEditors = new Map();
20
21
  this._dataUnit = undefined;
21
22
  this._dataState = undefined;
22
23
  this._showFormConfig = false;
@@ -39,6 +40,18 @@ const SnkForm = class {
39
40
  async hideConfig() {
40
41
  this._showFormConfig = false;
41
42
  }
43
+ /**
44
+ * Registra um editor customizado para campos da grade e formulário.
45
+ */
46
+ async addCustomEditor(fieldName, customEditor) {
47
+ if (this._form) {
48
+ this._form.addCustomEditor(fieldName, customEditor);
49
+ return;
50
+ }
51
+ const newCustomEditors = new Map(this._customEditors);
52
+ newCustomEditors.set(fieldName, customEditor);
53
+ this._customEditors = newCustomEditors;
54
+ }
42
55
  /**
43
56
  * Altera/adiciona uma propriedade nos metadados do campo.
44
57
  */
@@ -52,6 +65,18 @@ const SnkForm = class {
52
65
  const dataInfo = { dataUnit: this._dataUnit };
53
66
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
54
67
  }
68
+ setCustomEditors() {
69
+ if (!this._form) {
70
+ return;
71
+ }
72
+ for (const [fieldName, customEditor] of this._customEditors) {
73
+ this._form.addCustomEditor(fieldName, customEditor);
74
+ this._customEditors.delete(fieldName);
75
+ }
76
+ }
77
+ async componentDidRender() {
78
+ this.setCustomEditors();
79
+ }
55
80
  async componentWillLoad() {
56
81
  let parent = this._element.parentElement;
57
82
  while (parent) {
@@ -88,7 +113,7 @@ const SnkForm = class {
88
113
  continue;
89
114
  }
90
115
  const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
91
- if (!rmPrecision) {
116
+ if (!rmPrecision && rmPrecision !== 0) {
92
117
  continue;
93
118
  }
94
119
  await this.setFieldProp(field, 'precision', rmPrecision);
@@ -104,7 +129,7 @@ const SnkForm = class {
104
129
  if (!this._dataUnit || !this._dataState) {
105
130
  return undefined;
106
131
  }
107
- return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: ref => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
132
+ return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
108
133
  h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
109
134
  }
110
135
  get _element() { return getElement(this); }