@sankhyalabs/sankhyablocks 8.15.1 → 8.16.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/cjs/{SnkMultiSelectionListDataSource-303e85d1.js → IExporterProvider-c78cb1b8.js} +94 -4
  2. package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
  3. package/dist/cjs/{SnkFormConfigManager-f9dc0d28.js → SnkFormConfigManager-1b13bacd.js} +6 -3
  4. package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-722b104e.js} +8 -12
  5. package/dist/cjs/{pesquisa-fetcher-213797ec.js → dataunit-fetcher-620b29a1.js} +87 -180
  6. package/dist/cjs/{index-0922807b.js → index-1dfc7a6e.js} +5 -0
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/pesquisa-fetcher-680e198f.js +166 -0
  9. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  10. package/dist/cjs/snk-actions-button_4.cjs.entry.js +4 -2
  11. package/dist/cjs/snk-application.cjs.entry.js +34 -11
  12. package/dist/cjs/snk-attach.cjs.entry.js +71 -46
  13. package/dist/cjs/snk-crud.cjs.entry.js +96 -10
  14. package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
  15. package/dist/cjs/snk-data-unit-82dea87e.js +679 -0
  16. package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
  17. package/dist/cjs/snk-detail-view.cjs.entry.js +48 -7
  18. package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -1
  19. package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
  20. package/dist/cjs/snk-form.cjs.entry.js +51 -6
  21. package/dist/cjs/snk-grid.cjs.entry.js +164 -107
  22. package/dist/cjs/{snk-guides-viewer-4b6ecda8.js → snk-guides-viewer-05a1ba27.js} +36 -8
  23. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
  24. package/dist/cjs/snk-simple-crud.cjs.entry.js +264 -37
  25. package/dist/cjs/snk-taskbar.cjs.entry.js +4 -3
  26. package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-9ad1f9c0.js} +3 -3
  27. package/dist/collection/collection-manifest.json +1 -1
  28. package/dist/collection/components/snk-application/snk-application.js +35 -11
  29. package/dist/collection/components/snk-attach/snk-attach.js +67 -44
  30. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  31. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  32. package/dist/collection/components/snk-crud/snk-crud.js +249 -7
  33. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
  34. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
  35. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +112 -5
  36. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +97 -0
  37. package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +74 -0
  38. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +54 -1
  39. package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
  40. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +58 -0
  41. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
  42. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +59 -52
  43. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +62 -0
  44. package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
  45. package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +20 -0
  46. package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
  47. package/dist/collection/components/snk-data-unit/snk-data-unit.js +507 -214
  48. package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
  49. package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +18 -0
  50. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
  51. package/dist/collection/components/snk-form/snk-form.js +102 -5
  52. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +6 -3
  53. package/dist/collection/components/snk-grid/snk-grid.js +240 -101
  54. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +386 -18
  55. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
  56. package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -1
  57. package/dist/collection/lib/@types/index.js +5 -0
  58. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
  59. package/dist/collection/lib/dataUnit/InMemoryLoader.js +7 -3
  60. package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
  61. package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
  62. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +3 -0
  63. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
  64. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +11 -13
  65. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
  66. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
  67. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
  68. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +53 -4
  69. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
  70. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
  71. package/dist/collection/lib/message/SnkMessageBuilder.js +5 -12
  72. package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +2 -0
  73. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
  74. package/dist/components/{field-search.js → IExporterProvider.js} +93 -6
  75. package/dist/components/ISave.js +47 -0
  76. package/dist/components/SnkFormConfigManager.js +6 -3
  77. package/dist/components/SnkMessageBuilder.js +8 -12
  78. package/dist/components/dataunit-fetcher.js +84 -182
  79. package/dist/components/index2.js +198 -33
  80. package/dist/components/pesquisa-fetcher.js +164 -0
  81. package/dist/components/snk-actions-button2.js +4 -11
  82. package/dist/components/snk-application2.js +31 -9
  83. package/dist/components/snk-attach2.js +65 -41
  84. package/dist/components/snk-crud.js +103 -11
  85. package/dist/components/snk-data-exporter2.js +309 -85
  86. package/dist/components/snk-data-unit2.js +470 -212
  87. package/dist/components/snk-detail-view2.js +87 -10
  88. package/dist/components/snk-expression-item2.js +1 -1
  89. package/dist/components/snk-filter-bar2.js +6 -1
  90. package/dist/components/snk-form-view2.js +72 -1
  91. package/dist/components/snk-form.js +53 -6
  92. package/dist/components/snk-grid2.js +168 -106
  93. package/dist/components/snk-personalized-filter2.js +1 -1
  94. package/dist/components/snk-simple-crud2.js +259 -23
  95. package/dist/components/snk-taskbar2.js +6 -5
  96. package/dist/esm/{SnkMultiSelectionListDataSource-36918dbf.js → IExporterProvider-343272b3.js} +93 -5
  97. package/dist/esm/RecordIDUtils-87d02110.js +41 -0
  98. package/dist/esm/{SnkFormConfigManager-f53f9f87.js → SnkFormConfigManager-d4554df9.js} +6 -3
  99. package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-89925609.js} +8 -12
  100. package/dist/esm/{pesquisa-fetcher-fe6f3826.js → dataunit-fetcher-3fbf9d12.js} +83 -181
  101. package/dist/esm/{index-0ece87a6.js → index-3aa4977a.js} +6 -1
  102. package/dist/esm/loader.js +1 -1
  103. package/dist/esm/pesquisa-fetcher-03c8f919.js +164 -0
  104. package/dist/esm/sankhyablocks.js +1 -1
  105. package/dist/esm/snk-actions-button_4.entry.js +4 -2
  106. package/dist/esm/snk-application.entry.js +33 -10
  107. package/dist/esm/snk-attach.entry.js +66 -41
  108. package/dist/esm/snk-crud.entry.js +96 -10
  109. package/dist/esm/snk-data-exporter.entry.js +316 -86
  110. package/dist/esm/snk-data-unit-8f98b45f.js +677 -0
  111. package/dist/esm/snk-data-unit.entry.js +12 -2
  112. package/dist/esm/snk-detail-view.entry.js +48 -7
  113. package/dist/esm/snk-filter-bar.entry.js +5 -1
  114. package/dist/esm/snk-form-view.entry.js +67 -0
  115. package/dist/esm/snk-form.entry.js +51 -6
  116. package/dist/esm/snk-grid.entry.js +162 -105
  117. package/dist/esm/{snk-guides-viewer-113be3fd.js → snk-guides-viewer-aee2cafe.js} +36 -8
  118. package/dist/esm/snk-guides-viewer.entry.js +8 -6
  119. package/dist/esm/snk-simple-crud.entry.js +252 -25
  120. package/dist/esm/snk-taskbar.entry.js +4 -3
  121. package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-d59867f1.js} +3 -3
  122. package/dist/sankhyablocks/p-0d91b10f.entry.js +1 -0
  123. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  124. package/dist/sankhyablocks/p-26394a01.entry.js +1 -0
  125. package/dist/sankhyablocks/p-2d649237.entry.js +1 -0
  126. package/dist/sankhyablocks/p-30cf616e.js +1 -0
  127. package/dist/sankhyablocks/p-44767378.entry.js +1 -0
  128. package/dist/sankhyablocks/p-47b60deb.entry.js +1 -0
  129. package/dist/sankhyablocks/p-4f72727a.entry.js +1 -0
  130. package/dist/sankhyablocks/p-550fee49.entry.js +1 -0
  131. package/dist/sankhyablocks/p-5539ecb4.entry.js +1 -0
  132. package/dist/sankhyablocks/p-672302c3.js +60 -0
  133. package/dist/sankhyablocks/p-7a337364.js +1 -0
  134. package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
  135. package/dist/sankhyablocks/p-829d4045.js +1 -0
  136. package/dist/sankhyablocks/p-8a5910a7.entry.js +1 -0
  137. package/dist/sankhyablocks/p-8cc64963.entry.js +1 -0
  138. package/dist/sankhyablocks/p-8fc470e5.entry.js +1 -0
  139. package/dist/sankhyablocks/p-9863d682.js +1 -0
  140. package/dist/sankhyablocks/p-9e99a92a.js +1 -0
  141. package/dist/sankhyablocks/p-af8efd95.js +6 -0
  142. package/dist/sankhyablocks/p-be603a24.js +1 -0
  143. package/dist/sankhyablocks/p-d09feef1.js +1 -0
  144. package/dist/sankhyablocks/p-e95b3b93.entry.js +11 -0
  145. package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
  146. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  147. package/dist/types/components/snk-application/snk-application.d.ts +7 -3
  148. package/dist/types/components/snk-attach/snk-attach.d.ts +11 -9
  149. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  150. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  151. package/dist/types/components/snk-crud/snk-crud.d.ts +36 -1
  152. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  153. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +28 -3
  154. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +19 -0
  155. package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +14 -0
  156. package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +12 -0
  157. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +24 -4
  158. package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
  159. package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
  160. package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
  161. package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +4 -1
  162. package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +21 -0
  163. package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
  164. package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +4 -0
  165. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
  166. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +61 -2
  167. package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
  168. package/dist/types/components/snk-data-unit/test/resources/parentMetadataMock.d.ts +3 -0
  169. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  170. package/dist/types/components/snk-form/snk-form.d.ts +14 -0
  171. package/dist/types/components/snk-grid/snk-grid.d.ts +46 -6
  172. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +58 -4
  173. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
  174. package/dist/types/components.d.ts +220 -4
  175. package/dist/types/lib/@types/index.d.ts +5 -0
  176. package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
  177. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
  178. package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
  179. package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
  180. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +2 -1
  181. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
  182. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -0
  183. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
  184. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
  185. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
  186. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
  187. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +3 -0
  188. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -1
  189. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
  190. package/package.json +1 -1
  191. package/dist/cjs/snk-data-unit-41c29713.js +0 -462
  192. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
  193. package/dist/components/index3.js +0 -199
  194. package/dist/esm/snk-data-unit-de1d140d.js +0 -460
  195. package/dist/sankhyablocks/p-032fe52e.js +0 -1
  196. package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
  197. package/dist/sankhyablocks/p-07a61550.entry.js +0 -1
  198. package/dist/sankhyablocks/p-0899e0b5.entry.js +0 -1
  199. package/dist/sankhyablocks/p-154a7f33.entry.js +0 -1
  200. package/dist/sankhyablocks/p-15802c59.entry.js +0 -1
  201. package/dist/sankhyablocks/p-164666b1.js +0 -65
  202. package/dist/sankhyablocks/p-32556aa6.js +0 -1
  203. package/dist/sankhyablocks/p-328585d0.entry.js +0 -1
  204. package/dist/sankhyablocks/p-38289a55.js +0 -1
  205. package/dist/sankhyablocks/p-52c8e589.js +0 -1
  206. package/dist/sankhyablocks/p-5cb07080.js +0 -1
  207. package/dist/sankhyablocks/p-74d349c3.entry.js +0 -1
  208. package/dist/sankhyablocks/p-7fe120b8.entry.js +0 -11
  209. package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
  210. package/dist/sankhyablocks/p-af1ac81f.entry.js +0 -1
  211. package/dist/sankhyablocks/p-b4525fc0.entry.js +0 -1
  212. package/dist/sankhyablocks/p-cce0865d.js +0 -1
  213. package/dist/sankhyablocks/p-dec65f6c.entry.js +0 -1
  214. package/dist/sankhyablocks/p-ee9536bc.entry.js +0 -1
  215. package/dist/sankhyablocks/p-f13f7616.entry.js +0 -1
  216. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
@@ -1,23 +1,25 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { StringUtils, ApplicationContext, ObjectUtils, DataType, UserInterface, JSUtils, FloatingManager, ElementIDUtils } from '@sankhyalabs/core';
2
+ import { UserInterface, StringUtils, ApplicationContext, ObjectUtils, DataType, JSUtils, FloatingManager, ElementIDUtils } from '@sankhyalabs/core';
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
6
  import './DataFetcher.js';
7
- import { I as InMemoryLoader } from './dataunit-fetcher.js';
8
- import { S as SnkMultiSelectionListDataSource, T as TaskbarProcessor, b as buildFieldSearch, o as openFieldSearch, C as CrudUtils } from './field-search.js';
9
- import { P as PresentationMode } from './index2.js';
10
- import { d as defineCustomElement$d } from './snk-actions-button2.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
+ import { D as DataExporterOption, P as PresentationMode } from './ISave.js';
11
10
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
12
11
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
12
+ import { I as InMemoryLoader } from './dataunit-fetcher.js';
13
13
  import './filter-item-type.enum.js';
14
14
  import { F as FormConfigFetcher } from './form-config-fetcher.js';
15
15
  import { C as ConfigStorage } from './ConfigStorage.js';
16
16
  import { S as SnkFormConfigManager } from './SnkFormConfigManager.js';
17
+ import { g as getSelectedIDs, d as defineCustomElement$9 } from './snk-data-unit2.js';
18
+ import { s as store } from './index2.js';
19
+ import { d as defineCustomElement$d } from './snk-actions-button2.js';
17
20
  import { d as defineCustomElement$c } from './snk-config-options2.js';
18
21
  import { d as defineCustomElement$b } from './snk-configurator2.js';
19
22
  import { d as defineCustomElement$a } from './snk-data-exporter2.js';
20
- import { d as defineCustomElement$9 } from './snk-data-unit2.js';
21
23
  import { d as defineCustomElement$8 } from './snk-exporter-email-sender2.js';
22
24
  import { d as defineCustomElement$7 } from './snk-field-config2.js';
23
25
  import { d as defineCustomElement$6 } from './snk-form-config2.js';
@@ -29,6 +31,61 @@ import { d as defineCustomElement$1 } from './taskbar-actions-button2.js';
29
31
  const REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "MORE_OPTIONS"];
30
32
  const REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER", "MORE_OPTIONS"];
31
33
 
34
+ class ClientSideExporterProvider extends CommonsExporter {
35
+ getSelectedNumber() {
36
+ return this.dataUnit.getSelectionInfo().length;
37
+ }
38
+ getTotalRecords() {
39
+ var _a, _b, _c;
40
+ const { total } = ((_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo()) || {};
41
+ return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
42
+ }
43
+ getSelectedIDs() {
44
+ return getSelectedIDs(this.dataUnit);
45
+ }
46
+ getRecordID() {
47
+ var _a, _b, _c;
48
+ return (_c = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
49
+ }
50
+ async getRecords() {
51
+ if (this.dataUnit.records.length === 0) {
52
+ return Promise.resolve([]);
53
+ }
54
+ const selectionInfo = this.dataUnit.getSelectionInfo();
55
+ const records = selectionInfo.isEmpty() || selectionInfo.isAllRecords() ? await selectionInfo.getAllRecords() : selectionInfo.records;
56
+ return Promise.resolve(records == undefined ? [] : records);
57
+ }
58
+ getHiddenOptions() {
59
+ return [
60
+ DataExporterOption.EXPORT_BY_EMAIL,
61
+ DataExporterOption.EXPORT_PDF_TO_EMAIL,
62
+ DataExporterOption.EXPORT_XLS_TO_EMAIL,
63
+ DataExporterOption.EXPORT_PAGE_TO_PDF,
64
+ DataExporterOption.EXPORT_PAGE_TO_XLS
65
+ ];
66
+ }
67
+ formatValue(record, column) {
68
+ const { id, descriptionFrom } = column;
69
+ const value = record[descriptionFrom || id];
70
+ if (value == undefined) {
71
+ return "";
72
+ }
73
+ if (descriptionFrom != undefined) {
74
+ return value.label;
75
+ }
76
+ const fieldDescriptor = this.dataUnit.getField(id);
77
+ if (fieldDescriptor.userInterface === UserInterface.SEARCH) {
78
+ return value.value;
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
+ }
85
+ return this.dataUnit.getFormattedValue(id, value);
86
+ }
87
+ }
88
+
32
89
  const snkSimpleCrudCss = ".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;row-gap:12px;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";
33
90
 
34
91
  const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -44,11 +101,13 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
44
101
  this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
45
102
  this._keyDownHandler = (event) => this.keyDownListener(event);
46
103
  this._formConfigFetcher = new FormConfigFetcher();
104
+ this._customEditors = new Map();
105
+ this._customRenders = new Map();
47
106
  this._taskbarProcessor = new TaskbarProcessor({
48
- "snkSimpleCrudTaskbar.form_regular": this.getButtons(false, TaskbarElement.GRID_MODE),
49
- "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, TaskbarElement.FORM_MODE),
50
- "snkSimpleCrudTaskbar.form_selected": this.getButtons(true, TaskbarElement.GRID_MODE),
51
- "snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, TaskbarElement.FORM_MODE),
107
+ "snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [TaskbarElement.GRID_MODE]),
108
+ "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
109
+ "snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
110
+ "snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
52
111
  "snkSimpleCrudTaskbar.finish_edition": ["CANCEL", "SAVE"]
53
112
  });
54
113
  this._showPopUpGridConfig = false;
@@ -59,12 +118,15 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
59
118
  this._customContainerId = `SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
60
119
  this.dataState = undefined;
61
120
  this.dataUnit = undefined;
121
+ this.entityName = undefined;
62
122
  this.mode = SIMPLE_CRUD_MODE.SERVER;
63
123
  this.gridConfig = undefined;
64
124
  this.formConfig = undefined;
65
125
  this._formFields = [];
126
+ this._fieldsProps = new Map();
66
127
  this.multipleSelection = undefined;
67
128
  this.useCancelConfirm = true;
129
+ this.pageSize = 150;
68
130
  this.resourceID = undefined;
69
131
  this.taskbarManager = undefined;
70
132
  this.messagesBuilder = undefined;
@@ -75,6 +137,33 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
75
137
  this.gridLegacyConfigName = undefined;
76
138
  this.formLegacyConfigName = undefined;
77
139
  this.ignoreReadOnlyFormFields = false;
140
+ this.autoFocus = true;
141
+ this.autoLoad = undefined;
142
+ }
143
+ /**
144
+ * Registra um editor customizado para campos da grade e formulário.
145
+ */
146
+ async addCustomEditor(fieldName, customEditor) {
147
+ if (this._grid && this._form) {
148
+ this._grid.addCustomEditor(fieldName, customEditor);
149
+ this._form.addCustomEditor(fieldName, customEditor);
150
+ return;
151
+ }
152
+ const newCustomEditors = new Map(this._customEditors);
153
+ newCustomEditors.set(fieldName, customEditor);
154
+ this._customEditors = newCustomEditors;
155
+ }
156
+ /**
157
+ * Registra um render customizado para colunas da grid.
158
+ */
159
+ async addGridCustomRender(fieldName, customRender) {
160
+ if (this._grid) {
161
+ this._grid.addGridCustomRender(fieldName, customRender);
162
+ return;
163
+ }
164
+ const newCustomRenders = new Map(this._customRenders);
165
+ newCustomRenders.set(fieldName, customRender);
166
+ this._customRenders = newCustomRenders;
78
167
  }
79
168
  handleResourceIDChanged(newValue, oldValue) {
80
169
  if (StringUtils.isEmpty(newValue)) {
@@ -86,9 +175,30 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
86
175
  this.loadFormConfig(true);
87
176
  this.loadGridConfig(true);
88
177
  }
89
- getButtons(selected, changeModeBtn) {
178
+ /**
179
+ * Registra um formatador de valores para uma coluna da grid.
180
+ */
181
+ async addCustomValueFormatter(columnName, customFormatter) {
182
+ this._grid.addCustomValueFormatter(columnName, customFormatter);
183
+ }
184
+ /**
185
+ * Remove o formatador de valores de uma coluna da grid.
186
+ */
187
+ async removeCustomValueFormatter(columnName) {
188
+ this._grid.removeCustomValueFormatter(columnName);
189
+ }
190
+ /**
191
+ * Altera/adiciona uma propriedade nos metadados do campo.
192
+ */
193
+ async setFieldProp(fieldName, propName, value) {
194
+ const newCustomFieldProps = new Map(this._fieldsProps);
195
+ const currentProps = this._fieldsProps.get(fieldName);
196
+ newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
197
+ this._fieldsProps = newCustomFieldProps;
198
+ }
199
+ getButtons(selected, extraButtons) {
90
200
  return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
91
- .concat(changeModeBtn));
201
+ .concat(extraButtons));
92
202
  }
93
203
  addConfigButton(buttons) {
94
204
  if (this.configName === undefined) {
@@ -128,15 +238,19 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
128
238
  }
129
239
  evt.stopPropagation();
130
240
  }
241
+ async onChangeEntityName(newValue) {
242
+ if (this.dataUnit)
243
+ return;
244
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
245
+ this.dataUnit = await application.getDataUnit(newValue, null, null, this.configName);
246
+ }
131
247
  onModeChange() {
132
248
  if (this.mode == SIMPLE_CRUD_MODE.IN_MEMORY) {
133
249
  this.initInMemoryDataUnit();
134
250
  }
135
251
  }
136
252
  observeDataState(newValue, oldValue) {
137
- if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
138
- this.dataStateChange.emit(newValue);
139
- }
253
+ this.handleDataStateChange(newValue, oldValue);
140
254
  }
141
255
  async observeFormLegacy(newValue, oldValue) {
142
256
  await this.handleUpdateFormLegacyConfig(newValue, oldValue);
@@ -144,6 +258,28 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
144
258
  async observeGridLegacy(newValue, oldValue) {
145
259
  await this.handleUpdateGridLegacyConfig(newValue, oldValue);
146
260
  }
261
+ async handleDataStateChange(newValue, oldValue) {
262
+ if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
263
+ this.dataStateChange.emit(newValue);
264
+ }
265
+ await this.processRmPrecision();
266
+ }
267
+ async processRmPrecision() {
268
+ var _a, _b;
269
+ const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
270
+ for (const field of fieldsWithRmPrecision || []) {
271
+ if (!field) {
272
+ continue;
273
+ }
274
+ 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);
275
+ if (!rmPrecision && rmPrecision !== 0) {
276
+ continue;
277
+ }
278
+ await this.setFieldProp(field, 'precision', rmPrecision);
279
+ await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
280
+ }
281
+ this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
282
+ }
147
283
  async handleUpdateGridLegacyConfig(newValue, oldValue) {
148
284
  if (newValue == undefined || newValue == oldValue) {
149
285
  return;
@@ -240,6 +376,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
240
376
  }
241
377
  async componentWillRender() {
242
378
  this._resourceID = await this.application.getResourceID();
379
+ this.dataExporterProviderStore();
243
380
  this._taskbarProcessor.process(this.getTaskBarId(), this.taskbarManager, this.dataState, this.getTaskBarDisabledButtons());
244
381
  if (this.configName === undefined) {
245
382
  return;
@@ -251,32 +388,70 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
251
388
  this.loadGridConfig();
252
389
  this.loadFormConfig();
253
390
  }
391
+ componentDidRender() {
392
+ this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
393
+ this.addGridCustomValueFormattters();
394
+ this.setFieldsProps();
395
+ this.setCustomRenders();
396
+ this.setCustomEditors();
397
+ }
254
398
  componentWillLoad() {
255
399
  this.processMetadata();
256
400
  this.onModeChange();
257
401
  this.configDatasource();
402
+ this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
258
403
  }
259
404
  componentDidLoad() {
260
405
  CSSVarsUtils.applyVarsGrid(this._element, this._grid);
261
406
  }
407
+ setCustomRenders() {
408
+ if (!this._grid) {
409
+ return;
410
+ }
411
+ for (const [fieldName, customRender] of this._customRenders) {
412
+ this._grid.addGridCustomRender(fieldName, customRender);
413
+ this._customRenders.delete(fieldName);
414
+ }
415
+ }
416
+ setCustomEditors() {
417
+ if (!this._grid || !this._form) {
418
+ return;
419
+ }
420
+ for (const [fieldName, customEditor] of this._customEditors) {
421
+ this._grid.addCustomEditor(fieldName, customEditor);
422
+ this._form.addCustomEditor(fieldName, customEditor);
423
+ this._customEditors.delete(fieldName);
424
+ }
425
+ }
262
426
  configDatasource() {
263
427
  this._multiSelectionListDataSource.setApplication(this.application);
264
428
  this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
265
429
  }
430
+ setFieldsProps() {
431
+ if (!this._form) {
432
+ return;
433
+ }
434
+ for (const [fieldName, props] of this._fieldsProps) {
435
+ for (const prop in props) {
436
+ this._form.setFieldProp(fieldName, prop, props[prop]);
437
+ }
438
+ this._fieldsProps.delete(fieldName);
439
+ }
440
+ }
266
441
  getTaskBarId() {
267
- var _a, _b, _c;
442
+ var _a, _b;
268
443
  if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
269
444
  return "snkSimpleCrudTaskbar.finish_edition";
270
445
  }
271
446
  if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectionInfo) &&
272
447
  !this.dataState.selectionInfo.isAllRecords() &&
273
- ((_c = this.dataState.selectionInfo.records) === null || _c === void 0 ? void 0 : _c.length) > 0) {
448
+ this.dataState.selectionInfo.length > 0) {
274
449
  return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_selected" : "snkSimpleCrudTaskbar.form_selected";
275
450
  }
276
451
  return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
277
452
  }
278
453
  initInMemoryDataUnit() {
279
- this._inMemoryLoader = new InMemoryLoader(this._metadata);
454
+ this._inMemoryLoader = new InMemoryLoader(this._metadata, undefined, { autoLoad: this.autoLoad });
280
455
  this.dataUnit = this._inMemoryLoader.dataUnit;
281
456
  this.dataUnitReady.emit(this.dataUnit);
282
457
  }
@@ -315,12 +490,11 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
315
490
  var _a;
316
491
  (_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.close();
317
492
  }
318
- updateConfig() {
493
+ async updateConfig() {
319
494
  if (this._formConfigManager == undefined) {
320
495
  this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
321
496
  }
322
497
  this._formConfigManager.setConfig(this.formConfig);
323
- return;
324
498
  }
325
499
  processMetadata() {
326
500
  const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
@@ -352,11 +526,28 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
352
526
  };
353
527
  }
354
528
  }
529
+ addGridCustomValueFormattters() {
530
+ var _a, _b, _c;
531
+ 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);
532
+ if (!metadataFields) {
533
+ return;
534
+ }
535
+ const fieldsWithRmPrecision = [];
536
+ metadataFields.forEach((field) => {
537
+ var _a;
538
+ if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !fieldsWithRmPrecision.includes(field.name)) {
539
+ fieldsWithRmPrecision.push(field.name);
540
+ }
541
+ });
542
+ fieldsWithRmPrecision.forEach(field => {
543
+ this.addCustomValueFormatter(field, this._rmPrecisionCustomValueFormatter);
544
+ });
545
+ }
355
546
  onDataStateChange(evt) {
356
547
  this.dataState = Object.assign({}, evt.detail);
357
548
  }
358
549
  getTaskBarDisabledButtons() {
359
- var _a, _b, _c, _d;
550
+ var _a, _b, _c, _d, _e, _f;
360
551
  const disabledButtons = [];
361
552
  if (!((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.hasNext)) {
362
553
  disabledButtons.push(TaskbarElement.NEXT);
@@ -367,6 +558,9 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
367
558
  if ((_d = (_c = this.dataState) === null || _c === void 0 ? void 0 : _c.selectionInfo) === null || _d === void 0 ? void 0 : _d.isEmpty()) {
368
559
  disabledButtons.push(TaskbarElement.FORM_MODE);
369
560
  }
561
+ if (((_f = (_e = this.dataState) === null || _e === void 0 ? void 0 : _e.selectionInfo) === null || _f === void 0 ? void 0 : _f.length) > 1) {
562
+ disabledButtons.push(TaskbarElement.CLONE);
563
+ }
370
564
  return disabledButtons;
371
565
  }
372
566
  handleCancelEdit() {
@@ -510,9 +704,23 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
510
704
  .then(() => {
511
705
  this.setGridConfig(config);
512
706
  this.closeGridConfig();
707
+ this.dataExporterProviderStore();
513
708
  });
514
709
  evt.stopPropagation();
515
710
  }
711
+ async dataExporterProviderStore() {
712
+ if (this.dataUnit == undefined) {
713
+ return;
714
+ }
715
+ if (this._grid == undefined) {
716
+ return;
717
+ }
718
+ const dataExporterProvider = new ClientSideExporterProvider(this.dataUnit, this._grid);
719
+ store.set("exporterProviders", Object.assign(Object.assign({}, store.get("exporterProviders")), { [this.getDataExporterStoreKey()]: dataExporterProvider }));
720
+ }
721
+ getDataExporterStoreKey() {
722
+ return `SnkSimpleCrudDataExporter:${this.configName == undefined ? this.dataUnit.name : this.configName}`;
723
+ }
516
724
  setGridConfig(config) {
517
725
  this.gridConfig = config;
518
726
  CrudUtils.assertDefaultSorting(this.gridConfig, this.dataUnit);
@@ -528,6 +736,15 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
528
736
  closeFormConfig() {
529
737
  this._showFormConfig = false;
530
738
  }
739
+ getPageSize() {
740
+ if (this.mode === SIMPLE_CRUD_MODE.IN_MEMORY) {
741
+ return 0;
742
+ }
743
+ if (this.pageSize == undefined) {
744
+ return 150;
745
+ }
746
+ return this.pageSize;
747
+ }
531
748
  //No momento não daremos suporte para configuração de formulário quando houver formLegacyConfigName
532
749
  handleShowFormConfig() {
533
750
  return this._showFormConfig && !this.formLegacyConfigName;
@@ -543,19 +760,28 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
543
760
  }
544
761
  return configFromManager;
545
762
  }
763
+ updateFormConfig() {
764
+ const newConfig = Object.assign(Object.assign({}, this.formConfig), { fields: this.dataUnit.metadata.fields });
765
+ this.setFormConfig(newConfig, true);
766
+ if (this._formConfigManager == undefined) {
767
+ this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
768
+ }
769
+ this._formConfigManager.setConfig(this.formConfig);
770
+ }
546
771
  /* istanbul ignore next */
547
772
  render() {
548
773
  var _a;
549
774
  if (this.dataUnit == undefined) {
550
775
  return;
551
776
  }
552
- 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), 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, 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)
777
+ 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)
553
778
  ? undefined
554
- : 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() }))));
779
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus }, 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() }))));
555
780
  }
556
781
  get _element() { return this; }
557
782
  static get watchers() { return {
558
783
  "resourceID": ["handleResourceIDChanged"],
784
+ "entityName": ["onChangeEntityName"],
559
785
  "mode": ["onModeChange"],
560
786
  "dataState": ["observeDataState"],
561
787
  "formLegacyConfigName": ["observeFormLegacy"],
@@ -565,11 +791,13 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
565
791
  }, [6, "snk-simple-crud", {
566
792
  "dataState": [16],
567
793
  "dataUnit": [16],
794
+ "entityName": [1, "entity-name"],
568
795
  "mode": [2],
569
796
  "gridConfig": [1040],
570
797
  "formConfig": [1040],
571
798
  "multipleSelection": [4, "multiple-selection"],
572
799
  "useCancelConfirm": [4, "use-cancel-confirm"],
800
+ "pageSize": [2, "page-size"],
573
801
  "resourceID": [1, "resource-i-d"],
574
802
  "taskbarManager": [16],
575
803
  "messagesBuilder": [1040],
@@ -580,6 +808,8 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
580
808
  "gridLegacyConfigName": [1, "grid-legacy-config-name"],
581
809
  "formLegacyConfigName": [1, "form-legacy-config-name"],
582
810
  "ignoreReadOnlyFormFields": [4, "ignore-read-only-form-fields"],
811
+ "autoFocus": [4, "auto-focus"],
812
+ "autoLoad": [4, "auto-load"],
583
813
  "_showPopUpGridConfig": [32],
584
814
  "_showFormConfig": [32],
585
815
  "_currentViewMode": [32],
@@ -587,6 +817,12 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
587
817
  "_fieldToGetFocus": [32],
588
818
  "_customContainerId": [32],
589
819
  "_formFields": [32],
820
+ "_fieldsProps": [32],
821
+ "addCustomEditor": [64],
822
+ "addGridCustomRender": [64],
823
+ "addCustomValueFormatter": [64],
824
+ "removeCustomValueFormatter": [64],
825
+ "setFieldProp": [64],
590
826
  "goToView": [64],
591
827
  "setMetadata": [64],
592
828
  "setRecords": [64],
@@ -1,8 +1,8 @@
1
1
  import { h, proxyCustomElement, HTMLElement, createEvent, Host } from '@stencil/core/internal/client';
2
2
  import { Action, StringUtils, ApplicationContext, OVERFLOWED_CLASS_NAME, OverflowWatcher, OverflowDirection, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { A as AuthorizationConfig } from './AuthorizationConfig.js';
4
- import { P as PresentationMode } from './index2.js';
5
- import { s as store } from './index3.js';
4
+ import { P as PresentationMode } from './ISave.js';
5
+ import { s as store } from './index2.js';
6
6
  import { d as defineCustomElement$4 } from './snk-actions-button2.js';
7
7
  import { d as defineCustomElement$3 } from './snk-data-exporter2.js';
8
8
  import { d as defineCustomElement$2 } from './snk-exporter-email-sender2.js';
@@ -54,7 +54,7 @@ const buildCustomButton = (def, className, dataElementId, action, isEnabled) =>
54
54
  return textButton(def.name, className, dataElementId, text, hint, action, isEnabled);
55
55
  }
56
56
  };
57
- const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions, configName, presentationMode) => {
57
+ const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions, dataExporterStoreKey, presentationMode) => {
58
58
  var _a;
59
59
  const title = getTitle(element);
60
60
  switch (element) {
@@ -97,7 +97,7 @@ const buildElem = (element, className, dataElementId, getTitle, action, isEnable
97
97
  case TaskbarElement.DIVIDER:
98
98
  return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin--none ez-margin-left--medium", "data-taskbar-divider": true });
99
99
  case TaskbarElement.DATA_EXPORTER:
100
- const provider = (_a = store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[configName];
100
+ const provider = (_a = store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[dataExporterStoreKey];
101
101
  return h("snk-data-exporter", { class: className, provider: provider, "data-element-id": dataElementId, "data-taskbar-element": element });
102
102
  case TaskbarElement.ATTACH:
103
103
  return iconButton("anexo", element, className, dataElementId, title, action, isEnabled);
@@ -306,8 +306,9 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
306
306
  className += "ez-padding-left--medium";
307
307
  }
308
308
  const taskbarElement = TaskbarElement[def.toString()];
309
+ const dataExporterStoreKey = this._element.dataset.exporterStoreKey || this.configName;
309
310
  if (taskbarElement) {
310
- return buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.buildDynamicActionsList(), this.configName, this.presentationMode);
311
+ return buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.buildDynamicActionsList(), dataExporterStoreKey, this.presentationMode);
311
312
  }
312
313
  else {
313
314
  return buildCustomButton(def, className, this.getIdElemBtnCustom(def), elem => this.elementClick(elem), elem => this.isEnabled(elem));
@@ -1,10 +1,11 @@
1
1
  import { D as DataFetcher } from './DataFetcher-c1baf61d.js';
2
- import { a as PreloadManager } from './pesquisa-fetcher-fe6f3826.js';
3
- import { SortMode, ApplicationContext, UserInterface, DateUtils } from '@sankhyalabs/core';
4
- import './index-0ece87a6.js';
2
+ import './pesquisa-fetcher-03c8f919.js';
3
+ import { SortMode, ApplicationContext, UserInterface, DateUtils, ObjectUtils, NumberUtils, DataType } from '@sankhyalabs/core';
4
+ import './index-3aa4977a.js';
5
5
  import './ISave-d8c8bc59.js';
6
6
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
7
- import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
7
+ import { UserInterface as UserInterface$1 } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
8
+ import { P as PreloadManager } from './dataunit-fetcher-3fbf9d12.js';
8
9
  import './filter-item-type.enum-d45e026f.js';
9
10
  import './form-config-fetcher-30fb808f.js';
10
11
  import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
@@ -130,4 +131,91 @@ class SnkMultiSelectionListDataSource {
130
131
  }
131
132
  }
132
133
 
133
- export { CrudUtils as C, SnkMultiSelectionListDataSource as S };
134
+ class RmPrecisionCustomValueFormatter {
135
+ setGrid(grid) {
136
+ if (this._grid) {
137
+ return;
138
+ }
139
+ this._grid = grid;
140
+ this.refreshSelectedRows();
141
+ }
142
+ setDataState(dataState) {
143
+ if (ObjectUtils.objectToString(dataState) === ObjectUtils.objectToString(this._dataState)) {
144
+ return;
145
+ }
146
+ this._dataState = dataState;
147
+ this.refreshSelectedRows();
148
+ }
149
+ format(currentValue, column, recordId) {
150
+ var _a;
151
+ if (!currentValue) {
152
+ return currentValue;
153
+ }
154
+ const rowMetadata = (_a = this._dataState) === null || _a === void 0 ? void 0 : _a.metadataByRow.get(recordId);
155
+ const rmPrecision = rowMetadata === null || rowMetadata === void 0 ? void 0 : rowMetadata.getProp('rm_precision', column.name);
156
+ if (rmPrecision || rmPrecision === 0) {
157
+ return NumberUtils.format(currentValue, rmPrecision, rmPrecision);
158
+ }
159
+ else {
160
+ return currentValue;
161
+ }
162
+ }
163
+ refreshSelectedRows() {
164
+ var _a;
165
+ (_a = this._grid) === null || _a === void 0 ? void 0 : _a.refreshSelectedRows();
166
+ }
167
+ }
168
+
169
+ class CommonsExporter {
170
+ constructor(dataUnit, grid) {
171
+ this.dataUnit = dataUnit;
172
+ this.grid = grid;
173
+ }
174
+ async getColumnsMetadata() {
175
+ var _a;
176
+ this.columnsState = await ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getColumnsState()) || [];
177
+ return await this.buildColumnsMetadata(this.columnsState);
178
+ }
179
+ getColumnsState() {
180
+ return this.columnsState;
181
+ }
182
+ async buildColumnsMetadata(gridColumns) {
183
+ var _a, _b;
184
+ const columnsMetadata = [];
185
+ for (const column of gridColumns) {
186
+ /**
187
+ * TODO: Analisar e criar uma melhor forma de tratar essa validação do "RECDESP".
188
+ */
189
+ if (column.hidden && column.name !== "RECDESP") {
190
+ continue;
191
+ }
192
+ const fieldData = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(column.name);
193
+ const customFormatter = await this.grid.getCustomValueFormatter(column.name);
194
+ const columnData = {
195
+ label: column.label,
196
+ id: column.name,
197
+ width: column.width,
198
+ type: fieldData === null || fieldData === void 0 ? void 0 : fieldData.dataType,
199
+ userInterface: fieldData === null || fieldData === void 0 ? void 0 : fieldData.userInterface,
200
+ customFormatter
201
+ };
202
+ columnsMetadata.push(columnData);
203
+ if (((_b = fieldData === null || fieldData === void 0 ? void 0 : fieldData.properties) === null || _b === void 0 ? void 0 : _b.DESCRIPTIONFIELD) != undefined) {
204
+ const mergedFrom = fieldData.properties.mergedFrom;
205
+ const descriptionField = `${fieldData.properties.ENTITYNAME}.${fieldData.properties.DESCRIPTIONFIELD}`;
206
+ const descriptionColumn = {
207
+ label: fieldData.properties.DESCRIPTIONENTITY,
208
+ id: `${mergedFrom ? (mergedFrom + ".") : ""}${descriptionField}`,
209
+ width: column.width,
210
+ type: DataType.TEXT,
211
+ userInterface: UserInterface$1.LONGTEXT,
212
+ descriptionFrom: fieldData.name
213
+ };
214
+ columnsMetadata.push(descriptionColumn);
215
+ }
216
+ }
217
+ return columnsMetadata || [];
218
+ }
219
+ }
220
+
221
+ export { CommonsExporter as C, RmPrecisionCustomValueFormatter as R, SnkMultiSelectionListDataSource as S, CrudUtils as a };