@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-57523.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 (186) hide show
  1. package/dist/cjs/{ConfigStorage-7df9d3bb.js → ConfigStorage-9a53a42c.js} +12 -11
  2. package/dist/cjs/{form-config-fetcher-3c4daeb5.js → DataFetcher-515bda03.js} +0 -251
  3. package/dist/cjs/{IExporterProvider-c307e2b1.js → IExporterProvider-e286ef6a.js} +55 -12
  4. package/dist/cjs/{SnkFormConfigManager-4259edbe.js → SnkFormConfigManager-7b222c78.js} +4 -4
  5. package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-4a95fe86.js} +6 -12
  6. package/dist/cjs/{auth-fetcher-e6112be7.js → auth-fetcher-5acb0335.js} +1 -1
  7. package/dist/cjs/{pesquisa-fetcher-cbdaba63.js → dataunit-fetcher-7a08e4dd.js} +74 -175
  8. package/dist/cjs/form-config-fetcher-3f430aee.js +256 -0
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/pesquisa-fetcher-916a935c.js +166 -0
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button_4.cjs.entry.js +10 -8
  13. package/dist/cjs/snk-application.cjs.entry.js +49 -39
  14. package/dist/cjs/snk-attach.cjs.entry.js +19 -17
  15. package/dist/cjs/snk-crud.cjs.entry.js +95 -10
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +11 -9
  17. package/dist/cjs/snk-data-unit-3718477f.js +670 -0
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +10 -2
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +48 -7
  20. package/dist/cjs/snk-filter-bar.cjs.entry.js +8 -3
  21. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -2
  22. package/dist/cjs/snk-form-config.cjs.entry.js +2 -1
  23. package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
  24. package/dist/cjs/snk-form.cjs.entry.js +53 -7
  25. package/dist/cjs/snk-grid.cjs.entry.js +103 -11
  26. package/dist/cjs/{snk-guides-viewer-b0c44e0c.js → snk-guides-viewer-66dd6949.js} +36 -7
  27. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
  28. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -2
  29. package/dist/cjs/snk-simple-crud.cjs.entry.js +153 -14
  30. package/dist/collection/collection-manifest.json +1 -1
  31. package/dist/collection/components/snk-application/snk-application.js +37 -17
  32. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  33. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  34. package/dist/collection/components/snk-crud/snk-crud.js +230 -7
  35. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
  36. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
  37. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +112 -5
  38. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +14 -8
  39. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +5 -0
  40. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +2 -2
  41. package/dist/collection/components/snk-data-unit/snk-data-unit.js +499 -176
  42. package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
  43. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
  44. package/dist/collection/components/snk-form/snk-form.js +101 -4
  45. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +2 -2
  46. package/dist/collection/components/snk-grid/snk-grid.js +219 -8
  47. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +283 -9
  48. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
  49. package/dist/collection/lib/dataUnit/InMemoryLoader.js +6 -2
  50. package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
  51. package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
  52. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
  53. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
  54. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +51 -1
  55. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
  56. package/dist/collection/lib/message/SnkMessageBuilder.js +25 -32
  57. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
  58. package/dist/components/ConfigStorage.js +2 -1
  59. package/dist/components/DataFetcher.js +7024 -0
  60. package/dist/components/IExporterProvider.js +54 -12
  61. package/dist/components/SnkFormConfigManager.js +2 -2
  62. package/dist/components/SnkMessageBuilder.js +6 -12
  63. package/dist/components/dataunit-fetcher.js +64 -166
  64. package/dist/components/form-config-fetcher.js +3 -7023
  65. package/dist/components/pesquisa-fetcher.js +164 -0
  66. package/dist/components/snk-actions-button2.js +4 -2
  67. package/dist/components/snk-application2.js +26 -17
  68. package/dist/components/snk-attach2.js +4 -2
  69. package/dist/components/snk-crud.js +101 -10
  70. package/dist/components/snk-data-exporter2.js +6 -4
  71. package/dist/components/snk-data-unit2.js +424 -177
  72. package/dist/components/snk-detail-view2.js +87 -9
  73. package/dist/components/snk-filter-bar2.js +6 -1
  74. package/dist/components/snk-form-config2.js +1 -1
  75. package/dist/components/snk-form-view2.js +72 -1
  76. package/dist/components/snk-form.js +52 -5
  77. package/dist/components/snk-grid2.js +109 -12
  78. package/dist/components/snk-simple-crud2.js +157 -11
  79. package/dist/esm/{ConfigStorage-928c3bf4.js → ConfigStorage-174101b9.js} +2 -1
  80. package/dist/esm/{form-config-fetcher-e3094014.js → DataFetcher-4b4b7beb.js} +1 -250
  81. package/dist/esm/{IExporterProvider-e2a1195d.js → IExporterProvider-cf5a56ee.js} +54 -12
  82. package/dist/esm/{SnkFormConfigManager-a87ade7a.js → SnkFormConfigManager-3bdb3e1f.js} +4 -4
  83. package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-3a767111.js} +6 -12
  84. package/dist/esm/{auth-fetcher-e1cb288f.js → auth-fetcher-9f86c346.js} +1 -1
  85. package/dist/esm/{pesquisa-fetcher-6d8e50bb.js → dataunit-fetcher-f3fa35b9.js} +63 -165
  86. package/dist/esm/form-config-fetcher-5d72aaf1.js +253 -0
  87. package/dist/esm/loader.js +1 -1
  88. package/dist/esm/pesquisa-fetcher-9cfab836.js +164 -0
  89. package/dist/esm/sankhyablocks.js +1 -1
  90. package/dist/esm/snk-actions-button_4.entry.js +5 -3
  91. package/dist/esm/snk-application.entry.js +30 -20
  92. package/dist/esm/snk-attach.entry.js +5 -3
  93. package/dist/esm/snk-crud.entry.js +95 -10
  94. package/dist/esm/snk-data-exporter.entry.js +8 -6
  95. package/dist/esm/snk-data-unit-8d6afa43.js +668 -0
  96. package/dist/esm/snk-data-unit.entry.js +10 -2
  97. package/dist/esm/snk-detail-view.entry.js +48 -7
  98. package/dist/esm/snk-filter-bar.entry.js +8 -3
  99. package/dist/esm/snk-filter-modal-item.entry.js +3 -2
  100. package/dist/esm/snk-form-config.entry.js +2 -1
  101. package/dist/esm/snk-form-view.entry.js +67 -0
  102. package/dist/esm/snk-form.entry.js +53 -7
  103. package/dist/esm/snk-grid.entry.js +104 -12
  104. package/dist/esm/{snk-guides-viewer-1fd41a25.js → snk-guides-viewer-11cf8dc7.js} +36 -7
  105. package/dist/esm/snk-guides-viewer.entry.js +8 -6
  106. package/dist/esm/snk-personalized-filter.entry.js +3 -2
  107. package/dist/esm/snk-simple-crud.entry.js +153 -14
  108. package/dist/sankhyablocks/p-010d475f.js +1 -0
  109. package/dist/sankhyablocks/p-0a28cb19.entry.js +1 -0
  110. package/dist/sankhyablocks/p-188e1432.entry.js +1 -0
  111. package/dist/sankhyablocks/p-1c6debe6.entry.js +1 -0
  112. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  113. package/dist/sankhyablocks/p-2a84e45b.entry.js +1 -0
  114. package/dist/sankhyablocks/p-2cc2d8fd.entry.js +1 -0
  115. package/dist/sankhyablocks/p-3e4c2cfe.entry.js +11 -0
  116. package/dist/sankhyablocks/p-4a8a149d.entry.js +1 -0
  117. package/dist/sankhyablocks/p-4ce73e88.js +1 -0
  118. package/dist/sankhyablocks/p-50e72d6c.js +1 -0
  119. package/dist/sankhyablocks/{p-e27496ed.js → p-566f5f50.js} +6 -6
  120. package/dist/sankhyablocks/p-59dccb7a.entry.js +1 -0
  121. package/dist/sankhyablocks/p-5bd78e4c.entry.js +1 -0
  122. package/dist/sankhyablocks/p-6b2be902.js +6 -0
  123. package/dist/sankhyablocks/p-8171e586.entry.js +1 -0
  124. package/dist/sankhyablocks/p-a6dfa396.js +1 -0
  125. package/dist/sankhyablocks/p-a97060b0.js +1 -0
  126. package/dist/sankhyablocks/p-aa854fa8.entry.js +1 -0
  127. package/dist/sankhyablocks/p-b27114c4.js +1 -0
  128. package/dist/sankhyablocks/p-b643f746.entry.js +1 -0
  129. package/dist/sankhyablocks/p-b68918fc.entry.js +1 -0
  130. package/dist/sankhyablocks/p-da7c81d6.entry.js +1 -0
  131. package/dist/sankhyablocks/p-e0c27486.js +26 -0
  132. package/dist/sankhyablocks/p-e238279a.entry.js +1 -0
  133. package/dist/sankhyablocks/p-eae66367.js +1 -0
  134. package/dist/sankhyablocks/p-fde91811.js +60 -0
  135. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  136. package/dist/types/components/snk-application/snk-application.d.ts +6 -2
  137. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  138. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  139. package/dist/types/components/snk-crud/snk-crud.d.ts +32 -1
  140. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  141. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +28 -3
  142. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +19 -0
  143. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +3 -0
  144. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +61 -2
  145. package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
  146. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  147. package/dist/types/components/snk-form/snk-form.d.ts +14 -0
  148. package/dist/types/components/snk-grid/snk-grid.d.ts +42 -3
  149. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +40 -2
  150. package/dist/types/components.d.ts +180 -4
  151. package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
  152. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
  153. package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
  154. package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
  155. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
  156. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
  157. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
  158. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
  159. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +2 -0
  160. package/package.json +1 -1
  161. package/dist/cjs/snk-data-unit-abd2113f.js +0 -427
  162. package/dist/esm/snk-data-unit-29eba11a.js +0 -425
  163. package/dist/sankhyablocks/p-029bfc09.js +0 -1
  164. package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
  165. package/dist/sankhyablocks/p-07825198.js +0 -1
  166. package/dist/sankhyablocks/p-0e8702f0.js +0 -1
  167. package/dist/sankhyablocks/p-13ea113d.entry.js +0 -1
  168. package/dist/sankhyablocks/p-314e2d1a.entry.js +0 -1
  169. package/dist/sankhyablocks/p-32556aa6.js +0 -1
  170. package/dist/sankhyablocks/p-3357af48.js +0 -1
  171. package/dist/sankhyablocks/p-3c2a1f4d.js +0 -65
  172. package/dist/sankhyablocks/p-3e7167dd.js +0 -1
  173. package/dist/sankhyablocks/p-536eeb16.js +0 -26
  174. package/dist/sankhyablocks/p-587f9dcf.entry.js +0 -1
  175. package/dist/sankhyablocks/p-61984566.entry.js +0 -1
  176. package/dist/sankhyablocks/p-61b6126e.entry.js +0 -1
  177. package/dist/sankhyablocks/p-65b6dba3.entry.js +0 -1
  178. package/dist/sankhyablocks/p-6a7bc5c8.entry.js +0 -1
  179. package/dist/sankhyablocks/p-6c9edfd8.entry.js +0 -1
  180. package/dist/sankhyablocks/p-89bde7d3.entry.js +0 -1
  181. package/dist/sankhyablocks/p-91dceecf.entry.js +0 -1
  182. package/dist/sankhyablocks/p-a40cbad8.entry.js +0 -1
  183. package/dist/sankhyablocks/p-b86ea293.entry.js +0 -1
  184. package/dist/sankhyablocks/p-d8ddb2a4.entry.js +0 -11
  185. package/dist/sankhyablocks/p-f92f1f5f.entry.js +0 -1
  186. package/dist/sankhyablocks/p-fa84e72f.entry.js +0 -1
@@ -1,16 +1,18 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Fragment } from '@stencil/core/internal/client';
2
- import { ElementIDUtils, ApplicationContext, StringUtils } from '@sankhyalabs/core';
2
+ import { Action, ElementIDUtils, ApplicationContext, StringUtils } from '@sankhyalabs/core';
3
3
  import { d as defineCustomElement$2, T as TaskbarElement } from './snk-taskbar2.js';
4
4
  import { C as ConfigStorage } from './ConfigStorage.js';
5
5
  import { P as PresentationMode } from './ISave.js';
6
- import { C as CommonsExporter, T as TaskbarProcessor, S as SnkMultiSelectionListDataSource, o as openFieldSearch, a as CrudUtils, b as buildFieldSearch } from './IExporterProvider.js';
6
+ import { C as CommonsExporter, T as TaskbarProcessor, S as SnkMultiSelectionListDataSource, o as openFieldSearch, a as CrudUtils, R as RmPrecisionCustomValueFormatter, b as buildFieldSearch } from './IExporterProvider.js';
7
7
  import { s as store } from './index2.js';
8
8
  import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
9
- import './form-config-fetcher.js';
10
- import './dataunit-fetcher.js';
9
+ import './DataFetcher.js';
10
+ import './pesquisa-fetcher.js';
11
11
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
12
12
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
13
+ import './dataunit-fetcher.js';
13
14
  import './filter-item-type.enum.js';
15
+ import './form-config-fetcher.js';
14
16
  import { g as getSelectedIDs } from './snk-data-unit2.js';
15
17
  import { d as defineCustomElement$i } from './snk-actions-button2.js';
16
18
  import { d as defineCustomElement$h } from './snk-data-exporter2.js';
@@ -92,6 +94,8 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
92
94
  this.__registerHost();
93
95
  this.actionClick = createEvent(this, "actionClick", 7);
94
96
  this.gridDoubleClick = createEvent(this, "gridDoubleClick", 7);
97
+ this._customEditors = new Map();
98
+ this._customRenders = new Map();
95
99
  this._topTaskbarProcessor = new TaskbarProcessor({
96
100
  "snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
97
101
  "snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
@@ -111,6 +115,14 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
111
115
  "snkGridHeaderTaskbar.singleTaskbar.detail.selected": ["UPDATE", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "FORM_MODE", "CONFIGURATOR", "REFRESH"],
112
116
  "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE"]
113
117
  });
118
+ this.dataUnitInterceptor = {
119
+ interceptAction: async (action) => {
120
+ if (action.type === Action.METADATA_LOADED) {
121
+ return await this.interceptMetadataLoaded(action);
122
+ }
123
+ return action;
124
+ }
125
+ };
114
126
  this._dataUnit = undefined;
115
127
  this._dataState = undefined;
116
128
  this._gridConfig = undefined;
@@ -137,6 +149,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
137
149
  this.disablePersonalizedFilter = undefined;
138
150
  this.gridLegacyConfigName = undefined;
139
151
  this.filterBarLegacyConfigName = undefined;
152
+ this.autoLoad = undefined;
140
153
  }
141
154
  /**
142
155
  * Exibe a janela de configurações da grade.
@@ -181,6 +194,42 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
181
194
  async findColumn() {
182
195
  await openFieldSearch(this._moreOptions, this._columnSearch);
183
196
  }
197
+ /**
198
+ * Registra um editor customizado para campos da grade e formulário
199
+ */
200
+ async addCustomEditor(fieldName, customEditor, detailContext) {
201
+ if (this._grid) {
202
+ this._grid.addCustomEditor(fieldName, customEditor, detailContext);
203
+ return;
204
+ }
205
+ const newCustomEditors = new Map(this._customEditors);
206
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
207
+ this._customEditors = newCustomEditors;
208
+ }
209
+ /**
210
+ * Registra um render customizado para colunas da grid.
211
+ */
212
+ async addGridCustomRender(fieldName, customRender, detailContext) {
213
+ if (this._grid) {
214
+ this._grid.addGridCustomRender(fieldName, customRender, detailContext);
215
+ return;
216
+ }
217
+ const newCustomRenders = new Map(this._customRenders);
218
+ newCustomRenders.set(fieldName, { customRender, detailContext });
219
+ this._customRenders = newCustomRenders;
220
+ }
221
+ /**
222
+ * Registra um formatador de valores para uma coluna da grid.
223
+ */
224
+ async addCustomValueFormatter(columnName, customFormatter) {
225
+ this._grid.addCustomValueFormatter(columnName, customFormatter);
226
+ }
227
+ /**
228
+ * Remove o formatador de valores de uma coluna da grid.
229
+ */
230
+ async removeCustomValueFormatter(columnName) {
231
+ this._grid.removeCustomValueFormatter(columnName);
232
+ }
184
233
  async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
185
234
  if (!newLegacyConfig) {
186
235
  return;
@@ -243,7 +292,23 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
243
292
  const dataInfo = { dataUnit: this._dataUnit };
244
293
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
245
294
  }
246
- finshLoading() {
295
+ loadGridCustomFormatters(fields) {
296
+ if (!fields || !this._grid) {
297
+ return;
298
+ }
299
+ fields.forEach((field) => {
300
+ var _a;
301
+ if ((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) {
302
+ this.addCustomValueFormatter(field.name, this._rmPrecisionCustomValueFormatter);
303
+ }
304
+ });
305
+ }
306
+ async interceptMetadataLoaded(action) {
307
+ this.loadGridCustomFormatters(action.payload.fields);
308
+ return action;
309
+ }
310
+ finishLoading() {
311
+ this._dataUnit.addInterceptor(this.dataUnitInterceptor);
247
312
  CrudUtils.assertDefaultSorting(this._gridConfig, this._dataUnit);
248
313
  this.addElementID();
249
314
  if (this.columnFilterDataSource != undefined) {
@@ -251,6 +316,24 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
251
316
  this.columnFilterDataSource.setDataUnit(this._dataUnit);
252
317
  }
253
318
  }
319
+ setCustomRenders() {
320
+ if (!this._grid) {
321
+ return;
322
+ }
323
+ for (const [fieldName, customRenderProps] of this._customRenders) {
324
+ this._grid.addGridCustomRender(fieldName, customRenderProps.customRender, customRenderProps.detailContext);
325
+ this._customRenders.delete(fieldName);
326
+ }
327
+ }
328
+ setCustomEditors() {
329
+ if (!this._grid) {
330
+ return;
331
+ }
332
+ for (const [fieldName, customEditorProps] of this._customEditors) {
333
+ this._grid.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
334
+ this._customEditors.delete(fieldName);
335
+ }
336
+ }
254
337
  componentWillLoad() {
255
338
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
256
339
  //TODO: substituir pelo metodo nativo closest
@@ -262,17 +345,15 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
262
345
  if (!this._dataUnit) {
263
346
  this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
264
347
  this._dataUnit = evt.detail;
265
- this.finshLoading();
348
+ this.finishLoading();
266
349
  });
267
350
  }
268
351
  else {
269
- this.finshLoading();
352
+ this.finishLoading();
270
353
  }
271
354
  if (!this.messagesBuilder)
272
355
  this.messagesBuilder = this._snkDataUnit.messagesBuilder;
273
- this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
274
- this._dataState = evt.detail;
275
- });
356
+ this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
276
357
  this._snkDataUnit.addEventListener("cancelEdition", () => {
277
358
  var _a;
278
359
  if ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.recordsIsEmpty) {
@@ -283,9 +364,20 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
283
364
  }
284
365
  parent = parent.parentElement;
285
366
  }
367
+ this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
286
368
  this.addGridLegacyConfigName();
287
369
  this.loadConfig();
288
370
  }
371
+ componentDidRender() {
372
+ this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
373
+ this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
374
+ this.setCustomRenders();
375
+ this.setCustomEditors();
376
+ }
377
+ async handleDataStateChange(evt) {
378
+ this._dataState = evt.detail;
379
+ this._rmPrecisionCustomValueFormatter.setDataState(this._dataState);
380
+ }
289
381
  getHeaderDisabledButtons() {
290
382
  var _a;
291
383
  const disabledButtons = [];
@@ -398,7 +490,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
398
490
  return undefined;
399
491
  }
400
492
  return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "snk-grid__header ez-margin-bottom--medium" }, this._showSnkFilterBar &&
401
- h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
493
+ h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
402
494
  }
403
495
  get _element() { return this; }
404
496
  static get watchers() { return {
@@ -427,6 +519,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
427
519
  "disablePersonalizedFilter": [4, "disable-personalized-filter"],
428
520
  "gridLegacyConfigName": [1, "grid-legacy-config-name"],
429
521
  "filterBarLegacyConfigName": [1, "filter-bar-legacy-config-name"],
522
+ "autoLoad": [4, "auto-load"],
430
523
  "_dataUnit": [32],
431
524
  "_dataState": [32],
432
525
  "_gridConfig": [32],
@@ -437,7 +530,11 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
437
530
  "setConfig": [64],
438
531
  "reloadFilterBar": [64],
439
532
  "getFilterBar": [64],
440
- "findColumn": [64]
533
+ "findColumn": [64],
534
+ "addCustomEditor": [64],
535
+ "addGridCustomRender": [64],
536
+ "addCustomValueFormatter": [64],
537
+ "removeCustomValueFormatter": [64]
441
538
  }]);
442
539
  function defineCustomElement() {
443
540
  if (typeof customElements === "undefined") {
@@ -3,13 +3,15 @@ import { UserInterface, StringUtils, ApplicationContext, ObjectUtils, DataType,
3
3
  import { CSSVarsUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { V as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants.js';
5
5
  import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
6
- import { F as FormConfigFetcher } from './form-config-fetcher.js';
7
- import { I as InMemoryLoader } from './dataunit-fetcher.js';
8
- import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, T as TaskbarProcessor, b as buildFieldSearch, o as openFieldSearch, a as CrudUtils } from './IExporterProvider.js';
6
+ import './DataFetcher.js';
7
+ import './pesquisa-fetcher.js';
8
+ import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, T as TaskbarProcessor, R as RmPrecisionCustomValueFormatter, b as buildFieldSearch, o as openFieldSearch, a as CrudUtils } from './IExporterProvider.js';
9
9
  import { D as DataExporterOption, P as PresentationMode } from './ISave.js';
10
10
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
11
11
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
12
+ import { I as InMemoryLoader } from './dataunit-fetcher.js';
12
13
  import './filter-item-type.enum.js';
14
+ import { F as FormConfigFetcher } from './form-config-fetcher.js';
13
15
  import { C as ConfigStorage } from './ConfigStorage.js';
14
16
  import { S as SnkFormConfigManager } from './SnkFormConfigManager.js';
15
17
  import { g as getSelectedIDs, d as defineCustomElement$9 } from './snk-data-unit2.js';
@@ -75,6 +77,11 @@ class ClientSideExporterProvider extends CommonsExporter {
75
77
  if (fieldDescriptor.userInterface === UserInterface.SEARCH) {
76
78
  return value.value;
77
79
  }
80
+ if (column.customFormatter) {
81
+ const ezGridColumn = this.getColumnsState().find(columnState => column.id === columnState.name);
82
+ const formattedValue = column.customFormatter.format(value, ezGridColumn, record.__record__id__);
83
+ return formattedValue;
84
+ }
78
85
  return this.dataUnit.getFormattedValue(id, value);
79
86
  }
80
87
  }
@@ -94,6 +101,8 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
94
101
  this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
95
102
  this._keyDownHandler = (event) => this.keyDownListener(event);
96
103
  this._formConfigFetcher = new FormConfigFetcher();
104
+ this._customEditors = new Map();
105
+ this._customRenders = new Map();
97
106
  this._taskbarProcessor = new TaskbarProcessor({
98
107
  "snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [TaskbarElement.GRID_MODE]),
99
108
  "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
@@ -114,6 +123,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
114
123
  this.gridConfig = undefined;
115
124
  this.formConfig = undefined;
116
125
  this._formFields = [];
126
+ this._fieldsProps = new Map();
117
127
  this.multipleSelection = undefined;
118
128
  this.useCancelConfirm = true;
119
129
  this.pageSize = 150;
@@ -127,6 +137,32 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
127
137
  this.gridLegacyConfigName = undefined;
128
138
  this.formLegacyConfigName = undefined;
129
139
  this.ignoreReadOnlyFormFields = false;
140
+ this.autoLoad = undefined;
141
+ }
142
+ /**
143
+ * Registra um editor customizado para campos da grade e formulário.
144
+ */
145
+ async addCustomEditor(fieldName, customEditor) {
146
+ if (this._grid && this._form) {
147
+ this._grid.addCustomEditor(fieldName, customEditor);
148
+ this._form.addCustomEditor(fieldName, customEditor);
149
+ return;
150
+ }
151
+ const newCustomEditors = new Map(this._customEditors);
152
+ newCustomEditors.set(fieldName, customEditor);
153
+ this._customEditors = newCustomEditors;
154
+ }
155
+ /**
156
+ * Registra um render customizado para colunas da grid.
157
+ */
158
+ async addGridCustomRender(fieldName, customRender) {
159
+ if (this._grid) {
160
+ this._grid.addGridCustomRender(fieldName, customRender);
161
+ return;
162
+ }
163
+ const newCustomRenders = new Map(this._customRenders);
164
+ newCustomRenders.set(fieldName, customRender);
165
+ this._customRenders = newCustomRenders;
130
166
  }
131
167
  handleResourceIDChanged(newValue, oldValue) {
132
168
  if (StringUtils.isEmpty(newValue)) {
@@ -138,6 +174,27 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
138
174
  this.loadFormConfig(true);
139
175
  this.loadGridConfig(true);
140
176
  }
177
+ /**
178
+ * Registra um formatador de valores para uma coluna da grid.
179
+ */
180
+ async addCustomValueFormatter(columnName, customFormatter) {
181
+ this._grid.addCustomValueFormatter(columnName, customFormatter);
182
+ }
183
+ /**
184
+ * Remove o formatador de valores de uma coluna da grid.
185
+ */
186
+ async removeCustomValueFormatter(columnName) {
187
+ this._grid.removeCustomValueFormatter(columnName);
188
+ }
189
+ /**
190
+ * Altera/adiciona uma propriedade nos metadados do campo.
191
+ */
192
+ async setFieldProp(fieldName, propName, value) {
193
+ const newCustomFieldProps = new Map(this._fieldsProps);
194
+ const currentProps = this._fieldsProps.get(fieldName);
195
+ newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
196
+ this._fieldsProps = newCustomFieldProps;
197
+ }
141
198
  getButtons(selected, extraButtons) {
142
199
  return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
143
200
  .concat(extraButtons));
@@ -192,9 +249,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
192
249
  }
193
250
  }
194
251
  observeDataState(newValue, oldValue) {
195
- if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
196
- this.dataStateChange.emit(newValue);
197
- }
252
+ this.handleDataStateChange(newValue, oldValue);
198
253
  }
199
254
  async observeFormLegacy(newValue, oldValue) {
200
255
  await this.handleUpdateFormLegacyConfig(newValue, oldValue);
@@ -202,6 +257,28 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
202
257
  async observeGridLegacy(newValue, oldValue) {
203
258
  await this.handleUpdateGridLegacyConfig(newValue, oldValue);
204
259
  }
260
+ async handleDataStateChange(newValue, oldValue) {
261
+ if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
262
+ this.dataStateChange.emit(newValue);
263
+ }
264
+ await this.processRmPrecision();
265
+ }
266
+ async processRmPrecision() {
267
+ var _a, _b;
268
+ const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
269
+ for (const field of fieldsWithRmPrecision || []) {
270
+ if (!field) {
271
+ continue;
272
+ }
273
+ const rmPrecision = (_b = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata) === null || _b === void 0 ? void 0 : _b.getProp('rm_precision', field);
274
+ if (!rmPrecision && rmPrecision !== 0) {
275
+ continue;
276
+ }
277
+ await this.setFieldProp(field, 'precision', rmPrecision);
278
+ await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
279
+ }
280
+ this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
281
+ }
205
282
  async handleUpdateGridLegacyConfig(newValue, oldValue) {
206
283
  if (newValue == undefined || newValue == oldValue) {
207
284
  return;
@@ -310,18 +387,56 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
310
387
  this.loadGridConfig();
311
388
  this.loadFormConfig();
312
389
  }
390
+ componentDidRender() {
391
+ this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
392
+ this.addGridCustomValueFormattters();
393
+ this.setFieldsProps();
394
+ this.setCustomRenders();
395
+ this.setCustomEditors();
396
+ }
313
397
  componentWillLoad() {
314
398
  this.processMetadata();
315
399
  this.onModeChange();
316
400
  this.configDatasource();
401
+ this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
317
402
  }
318
403
  componentDidLoad() {
319
404
  CSSVarsUtils.applyVarsGrid(this._element, this._grid);
320
405
  }
406
+ setCustomRenders() {
407
+ if (!this._grid) {
408
+ return;
409
+ }
410
+ for (const [fieldName, customRender] of this._customRenders) {
411
+ this._grid.addGridCustomRender(fieldName, customRender);
412
+ this._customRenders.delete(fieldName);
413
+ }
414
+ }
415
+ setCustomEditors() {
416
+ if (!this._grid || !this._form) {
417
+ return;
418
+ }
419
+ for (const [fieldName, customEditor] of this._customEditors) {
420
+ this._grid.addCustomEditor(fieldName, customEditor);
421
+ this._form.addCustomEditor(fieldName, customEditor);
422
+ this._customEditors.delete(fieldName);
423
+ }
424
+ }
321
425
  configDatasource() {
322
426
  this._multiSelectionListDataSource.setApplication(this.application);
323
427
  this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
324
428
  }
429
+ setFieldsProps() {
430
+ if (!this._form) {
431
+ return;
432
+ }
433
+ for (const [fieldName, props] of this._fieldsProps) {
434
+ for (const prop in props) {
435
+ this._form.setFieldProp(fieldName, prop, props[prop]);
436
+ }
437
+ this._fieldsProps.delete(fieldName);
438
+ }
439
+ }
325
440
  getTaskBarId() {
326
441
  var _a, _b;
327
442
  if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
@@ -335,7 +450,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
335
450
  return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
336
451
  }
337
452
  initInMemoryDataUnit() {
338
- this._inMemoryLoader = new InMemoryLoader(this._metadata);
453
+ this._inMemoryLoader = new InMemoryLoader(this._metadata, undefined, { autoLoad: this.autoLoad });
339
454
  this.dataUnit = this._inMemoryLoader.dataUnit;
340
455
  this.dataUnitReady.emit(this.dataUnit);
341
456
  }
@@ -374,12 +489,11 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
374
489
  var _a;
375
490
  (_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.close();
376
491
  }
377
- updateConfig() {
492
+ async updateConfig() {
378
493
  if (this._formConfigManager == undefined) {
379
494
  this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
380
495
  }
381
496
  this._formConfigManager.setConfig(this.formConfig);
382
- return;
383
497
  }
384
498
  processMetadata() {
385
499
  const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
@@ -411,6 +525,23 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
411
525
  };
412
526
  }
413
527
  }
528
+ addGridCustomValueFormattters() {
529
+ var _a, _b, _c;
530
+ const metadataFields = ((_a = this._metadata) === null || _a === void 0 ? void 0 : _a.fields) || ((_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.fields);
531
+ if (!metadataFields) {
532
+ return;
533
+ }
534
+ const fieldsWithRmPrecision = [];
535
+ metadataFields.forEach((field) => {
536
+ var _a;
537
+ if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !fieldsWithRmPrecision.includes(field.name)) {
538
+ fieldsWithRmPrecision.push(field.name);
539
+ }
540
+ });
541
+ fieldsWithRmPrecision.forEach(field => {
542
+ this.addCustomValueFormatter(field, this._rmPrecisionCustomValueFormatter);
543
+ });
544
+ }
414
545
  onDataStateChange(evt) {
415
546
  this.dataState = Object.assign({}, evt.detail);
416
547
  }
@@ -625,15 +756,23 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
625
756
  }
626
757
  return configFromManager;
627
758
  }
759
+ updateFormConfig() {
760
+ const newConfig = Object.assign(Object.assign({}, this.formConfig), { fields: this.dataUnit.metadata.fields });
761
+ this.setFormConfig(newConfig, true);
762
+ if (this._formConfigManager == undefined) {
763
+ this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
764
+ }
765
+ this._formConfigManager.setConfig(this.formConfig);
766
+ }
628
767
  /* istanbul ignore next */
629
768
  render() {
630
769
  var _a;
631
770
  if (this.dataUnit == undefined) {
632
771
  return;
633
772
  }
634
- return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
773
+ return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
635
774
  ? undefined
636
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
775
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
637
776
  }
638
777
  get _element() { return this; }
639
778
  static get watchers() { return {
@@ -665,6 +804,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
665
804
  "gridLegacyConfigName": [1, "grid-legacy-config-name"],
666
805
  "formLegacyConfigName": [1, "form-legacy-config-name"],
667
806
  "ignoreReadOnlyFormFields": [4, "ignore-read-only-form-fields"],
807
+ "autoLoad": [4, "auto-load"],
668
808
  "_showPopUpGridConfig": [32],
669
809
  "_showFormConfig": [32],
670
810
  "_currentViewMode": [32],
@@ -672,6 +812,12 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
672
812
  "_fieldToGetFocus": [32],
673
813
  "_customContainerId": [32],
674
814
  "_formFields": [32],
815
+ "_fieldsProps": [32],
816
+ "addCustomEditor": [64],
817
+ "addGridCustomRender": [64],
818
+ "addCustomValueFormatter": [64],
819
+ "removeCustomValueFormatter": [64],
820
+ "setFieldProp": [64],
675
821
  "goToView": [64],
676
822
  "setMetadata": [64],
677
823
  "setRecords": [64],
@@ -1,6 +1,7 @@
1
- import { R as ResourceFetcher, d as dist, D as DataFetcher, F as FormConfigFetcher } from './form-config-fetcher-e3094014.js';
1
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-5d72aaf1.js';
2
2
  import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
3
3
  import { ObjectUtils } from '@sankhyalabs/core';
4
+ import { d as dist, D as DataFetcher } from './DataFetcher-4b4b7beb.js';
4
5
 
5
6
  class GridConfigFetcher extends ResourceFetcher {
6
7
  constructor() {