@sankhyalabs/sankhyablocks 8.15.3 → 8.16.0-dev.10

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 (234) hide show
  1. package/dist/cjs/{ConfigStorage-942ce74b.js → ConfigStorage-a343e418.js} +1 -0
  2. package/dist/cjs/{SnkMultiSelectionListDataSource-3c08d25c.js → IExporterProvider-597949f9.js} +94 -4
  3. package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
  4. package/dist/cjs/{SnkFormConfigManager-f9dc0d28.js → SnkFormConfigManager-166cbd1f.js} +8 -7
  5. package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-897ffd08.js} +9 -13
  6. package/dist/cjs/{pesquisa-fetcher-562d281f.js → dataunit-fetcher-688d3f05.js} +87 -180
  7. package/dist/cjs/{index-0922807b.js → index-1dfc7a6e.js} +5 -0
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/pesquisa-fetcher-680e198f.js +166 -0
  10. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  11. package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -3
  12. package/dist/cjs/snk-application.cjs.entry.js +35 -12
  13. package/dist/cjs/snk-attach.cjs.entry.js +71 -46
  14. package/dist/cjs/snk-crud.cjs.entry.js +101 -10
  15. package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
  16. package/dist/cjs/snk-data-unit-8fa7917a.js +689 -0
  17. package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
  18. package/dist/cjs/snk-detail-view.cjs.entry.js +50 -10
  19. package/dist/cjs/snk-filter-bar.cjs.entry.js +6 -2
  20. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
  21. package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
  23. package/dist/cjs/snk-form.cjs.entry.js +52 -7
  24. package/dist/cjs/snk-grid.cjs.entry.js +165 -108
  25. package/dist/cjs/{snk-guides-viewer-bb6087cd.js → snk-guides-viewer-9c682034.js} +43 -10
  26. package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -7
  27. package/dist/cjs/snk-personalized-filter.cjs.entry.js +1 -1
  28. package/dist/cjs/snk-simple-crud.cjs.entry.js +268 -40
  29. package/dist/cjs/snk-taskbar.cjs.entry.js +4 -3
  30. package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-9ad1f9c0.js} +3 -3
  31. package/dist/collection/collection-manifest.json +1 -1
  32. package/dist/collection/components/snk-application/snk-application.js +35 -11
  33. package/dist/collection/components/snk-attach/snk-attach.js +67 -44
  34. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  35. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  36. package/dist/collection/components/snk-crud/snk-crud.js +305 -7
  37. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +136 -2
  38. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
  39. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +134 -7
  40. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +97 -0
  41. package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +74 -0
  42. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +54 -1
  43. package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
  44. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +58 -0
  45. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
  46. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +59 -52
  47. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +62 -0
  48. package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
  49. package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +20 -0
  50. package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
  51. package/dist/collection/components/snk-data-unit/snk-data-unit.js +538 -218
  52. package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
  53. package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +18 -0
  54. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
  55. package/dist/collection/components/snk-form/snk-form.js +102 -5
  56. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +7 -6
  57. package/dist/collection/components/snk-form-config/snk-form-config.js +1 -1
  58. package/dist/collection/components/snk-grid/snk-grid.js +240 -101
  59. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +406 -20
  60. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
  61. package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -1
  62. package/dist/collection/lib/@types/index.js +5 -0
  63. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
  64. package/dist/collection/lib/configs/ConfigStorage.js +1 -0
  65. package/dist/collection/lib/dataUnit/InMemoryLoader.js +7 -3
  66. package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
  67. package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
  68. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +3 -0
  69. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
  70. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +11 -13
  71. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
  72. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
  73. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
  74. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +53 -4
  75. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
  76. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
  77. package/dist/collection/lib/message/SnkMessageBuilder.js +5 -12
  78. package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +2 -0
  79. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +2 -1
  80. package/dist/components/ConfigStorage.js +1 -0
  81. package/dist/components/{field-search.js → IExporterProvider.js} +93 -6
  82. package/dist/components/ISave.js +47 -0
  83. package/dist/components/SnkFormConfigManager.js +7 -6
  84. package/dist/components/SnkMessageBuilder.js +9 -13
  85. package/dist/components/dataunit-fetcher.js +84 -182
  86. package/dist/components/index2.js +198 -33
  87. package/dist/components/pesquisa-fetcher.js +164 -0
  88. package/dist/components/snk-actions-button2.js +4 -11
  89. package/dist/components/snk-application2.js +31 -9
  90. package/dist/components/snk-attach2.js +65 -41
  91. package/dist/components/snk-crud.js +110 -11
  92. package/dist/components/snk-data-exporter2.js +309 -85
  93. package/dist/components/snk-data-unit2.js +485 -216
  94. package/dist/components/snk-detail-view2.js +96 -14
  95. package/dist/components/snk-expression-item2.js +1 -1
  96. package/dist/components/snk-filter-bar2.js +6 -1
  97. package/dist/components/snk-form-config2.js +1 -1
  98. package/dist/components/snk-form-view2.js +72 -1
  99. package/dist/components/snk-form.js +53 -6
  100. package/dist/components/snk-grid2.js +168 -106
  101. package/dist/components/snk-personalized-filter2.js +1 -1
  102. package/dist/components/snk-simple-crud2.js +263 -25
  103. package/dist/components/snk-taskbar2.js +6 -5
  104. package/dist/esm/{ConfigStorage-86187da3.js → ConfigStorage-3806514e.js} +1 -0
  105. package/dist/esm/{SnkMultiSelectionListDataSource-6a879955.js → IExporterProvider-63a188b6.js} +93 -5
  106. package/dist/esm/RecordIDUtils-87d02110.js +41 -0
  107. package/dist/esm/{SnkFormConfigManager-f53f9f87.js → SnkFormConfigManager-31b24066.js} +8 -7
  108. package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-571462fb.js} +9 -13
  109. package/dist/esm/{pesquisa-fetcher-c7ce8ee7.js → dataunit-fetcher-264191b2.js} +83 -181
  110. package/dist/esm/{index-0ece87a6.js → index-3aa4977a.js} +6 -1
  111. package/dist/esm/loader.js +1 -1
  112. package/dist/esm/pesquisa-fetcher-03c8f919.js +164 -0
  113. package/dist/esm/sankhyablocks.js +1 -1
  114. package/dist/esm/snk-actions-button_4.entry.js +5 -3
  115. package/dist/esm/snk-application.entry.js +34 -11
  116. package/dist/esm/snk-attach.entry.js +66 -41
  117. package/dist/esm/snk-crud.entry.js +101 -10
  118. package/dist/esm/snk-data-exporter.entry.js +316 -86
  119. package/dist/esm/snk-data-unit-f5cbe64b.js +687 -0
  120. package/dist/esm/snk-data-unit.entry.js +12 -2
  121. package/dist/esm/snk-detail-view.entry.js +50 -10
  122. package/dist/esm/snk-filter-bar.entry.js +6 -2
  123. package/dist/esm/snk-filter-modal-item.entry.js +1 -1
  124. package/dist/esm/snk-form-config.entry.js +1 -1
  125. package/dist/esm/snk-form-view.entry.js +67 -0
  126. package/dist/esm/snk-form.entry.js +52 -7
  127. package/dist/esm/snk-grid.entry.js +163 -106
  128. package/dist/esm/{snk-guides-viewer-1d95ebf2.js → snk-guides-viewer-8f6960a2.js} +43 -10
  129. package/dist/esm/snk-guides-viewer.entry.js +9 -7
  130. package/dist/esm/snk-personalized-filter.entry.js +1 -1
  131. package/dist/esm/snk-simple-crud.entry.js +256 -28
  132. package/dist/esm/snk-taskbar.entry.js +4 -3
  133. package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-d59867f1.js} +3 -3
  134. package/dist/sankhyablocks/p-17def7cd.js +1 -0
  135. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  136. package/dist/sankhyablocks/p-28ee0972.js +1 -0
  137. package/dist/sankhyablocks/p-2a408684.js +1 -0
  138. package/dist/sankhyablocks/{p-eae7a817.entry.js → p-2c68b3ae.entry.js} +1 -1
  139. package/dist/sankhyablocks/p-30cf616e.js +1 -0
  140. package/dist/sankhyablocks/p-3a212712.js +1 -0
  141. package/dist/sankhyablocks/p-450c60e4.entry.js +1 -0
  142. package/dist/sankhyablocks/{p-a1d72395.entry.js → p-47db7e88.entry.js} +1 -1
  143. package/dist/sankhyablocks/p-4e5e1313.entry.js +1 -0
  144. package/dist/sankhyablocks/{p-aff76a53.js → p-52920496.js} +1 -1
  145. package/dist/sankhyablocks/p-62ba211a.entry.js +1 -0
  146. package/dist/sankhyablocks/p-6bb2f3e9.entry.js +1 -0
  147. package/dist/sankhyablocks/p-7505da04.entry.js +1 -0
  148. package/dist/sankhyablocks/p-7619bdb1.entry.js +11 -0
  149. package/dist/sankhyablocks/p-7a85fd49.entry.js +1 -0
  150. package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
  151. package/dist/sankhyablocks/p-7ef9c55c.js +1 -0
  152. package/dist/sankhyablocks/p-80042dc6.entry.js +1 -0
  153. package/dist/sankhyablocks/p-8c59edd7.entry.js +1 -0
  154. package/dist/sankhyablocks/p-9606509c.entry.js +1 -0
  155. package/dist/sankhyablocks/p-9863d682.js +1 -0
  156. package/dist/sankhyablocks/p-ae93d46a.entry.js +1 -0
  157. package/dist/sankhyablocks/p-af8efd95.js +6 -0
  158. package/dist/sankhyablocks/p-d6e26ea8.entry.js +1 -0
  159. package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
  160. package/dist/sankhyablocks/p-f4450320.entry.js +1 -0
  161. package/dist/sankhyablocks/p-fe79f83a.js +60 -0
  162. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  163. package/dist/types/components/snk-application/snk-application.d.ts +7 -3
  164. package/dist/types/components/snk-attach/snk-attach.d.ts +11 -9
  165. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  166. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  167. package/dist/types/components/snk-crud/snk-crud.d.ts +45 -1
  168. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  169. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +28 -3
  170. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +24 -0
  171. package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +14 -0
  172. package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +12 -0
  173. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +24 -4
  174. package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
  175. package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
  176. package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
  177. package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +4 -1
  178. package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +21 -0
  179. package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
  180. package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +4 -0
  181. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
  182. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +66 -2
  183. package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
  184. package/dist/types/components/snk-data-unit/test/resources/parentMetadataMock.d.ts +3 -0
  185. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  186. package/dist/types/components/snk-form/snk-form.d.ts +14 -0
  187. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +2 -2
  188. package/dist/types/components/snk-grid/snk-grid.d.ts +46 -6
  189. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +62 -4
  190. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
  191. package/dist/types/components.d.ts +261 -4
  192. package/dist/types/lib/@types/index.d.ts +5 -0
  193. package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
  194. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
  195. package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
  196. package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
  197. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +2 -1
  198. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
  199. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -0
  200. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
  201. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
  202. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
  203. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
  204. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +3 -0
  205. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -1
  206. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
  207. package/package.json +1 -1
  208. package/dist/cjs/snk-data-unit-41c29713.js +0 -462
  209. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
  210. package/dist/components/index3.js +0 -199
  211. package/dist/esm/snk-data-unit-de1d140d.js +0 -460
  212. package/dist/sankhyablocks/p-032fe52e.js +0 -1
  213. package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
  214. package/dist/sankhyablocks/p-0594db5a.entry.js +0 -1
  215. package/dist/sankhyablocks/p-06e13db2.js +0 -1
  216. package/dist/sankhyablocks/p-07a61550.entry.js +0 -1
  217. package/dist/sankhyablocks/p-1403a4b6.entry.js +0 -1
  218. package/dist/sankhyablocks/p-14a08904.entry.js +0 -1
  219. package/dist/sankhyablocks/p-15802c59.entry.js +0 -1
  220. package/dist/sankhyablocks/p-235dc7b1.js +0 -65
  221. package/dist/sankhyablocks/p-32556aa6.js +0 -1
  222. package/dist/sankhyablocks/p-38289a55.js +0 -1
  223. package/dist/sankhyablocks/p-3c632d48.js +0 -1
  224. package/dist/sankhyablocks/p-3f833983.entry.js +0 -1
  225. package/dist/sankhyablocks/p-52c8e589.js +0 -1
  226. package/dist/sankhyablocks/p-5e1502b6.entry.js +0 -11
  227. package/dist/sankhyablocks/p-74d349c3.entry.js +0 -1
  228. package/dist/sankhyablocks/p-93167e28.entry.js +0 -1
  229. package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
  230. package/dist/sankhyablocks/p-bd47dd16.entry.js +0 -1
  231. package/dist/sankhyablocks/p-c1f88236.entry.js +0 -1
  232. package/dist/sankhyablocks/p-ccdd5332.entry.js +0 -1
  233. package/dist/sankhyablocks/p-ee9536bc.entry.js +0 -1
  234. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
@@ -1,199 +0,0 @@
1
- import { getRenderingRef, forceUpdate } from '@stencil/core/internal/client';
2
-
3
- const appendToMap = (map, propName, value) => {
4
- const items = map.get(propName);
5
- if (!items) {
6
- map.set(propName, [value]);
7
- }
8
- else if (!items.includes(value)) {
9
- items.push(value);
10
- }
11
- };
12
- const debounce = (fn, ms) => {
13
- let timeoutId;
14
- return (...args) => {
15
- if (timeoutId) {
16
- clearTimeout(timeoutId);
17
- }
18
- timeoutId = setTimeout(() => {
19
- timeoutId = 0;
20
- fn(...args);
21
- }, ms);
22
- };
23
- };
24
-
25
- /**
26
- * Check if a possible element isConnected.
27
- * The property might not be there, so we check for it.
28
- *
29
- * We want it to return true if isConnected is not a property,
30
- * otherwise we would remove these elements and would not update.
31
- *
32
- * Better leak in Edge than to be useless.
33
- */
34
- const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
35
- const cleanupElements = debounce((map) => {
36
- for (let key of map.keys()) {
37
- map.set(key, map.get(key).filter(isConnected));
38
- }
39
- }, 2000);
40
- const stencilSubscription = () => {
41
- if (typeof getRenderingRef !== 'function') {
42
- // If we are not in a stencil project, we do nothing.
43
- // This function is not really exported by @stencil/core.
44
- return {};
45
- }
46
- const elmsToUpdate = new Map();
47
- return {
48
- dispose: () => elmsToUpdate.clear(),
49
- get: (propName) => {
50
- const elm = getRenderingRef();
51
- if (elm) {
52
- appendToMap(elmsToUpdate, propName, elm);
53
- }
54
- },
55
- set: (propName) => {
56
- const elements = elmsToUpdate.get(propName);
57
- if (elements) {
58
- elmsToUpdate.set(propName, elements.filter(forceUpdate));
59
- }
60
- cleanupElements(elmsToUpdate);
61
- },
62
- reset: () => {
63
- elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
64
- cleanupElements(elmsToUpdate);
65
- },
66
- };
67
- };
68
-
69
- const unwrap = (val) => (typeof val === 'function' ? val() : val);
70
- const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
71
- const unwrappedState = unwrap(defaultState);
72
- let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
73
- const handlers = {
74
- dispose: [],
75
- get: [],
76
- set: [],
77
- reset: [],
78
- };
79
- const reset = () => {
80
- var _a;
81
- // When resetting the state, the default state may be a function - unwrap it to invoke it.
82
- // otherwise, the state won't be properly reset
83
- states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
84
- handlers.reset.forEach((cb) => cb());
85
- };
86
- const dispose = () => {
87
- // Call first dispose as resetting the state would
88
- // cause less updates ;)
89
- handlers.dispose.forEach((cb) => cb());
90
- reset();
91
- };
92
- const get = (propName) => {
93
- handlers.get.forEach((cb) => cb(propName));
94
- return states.get(propName);
95
- };
96
- const set = (propName, value) => {
97
- const oldValue = states.get(propName);
98
- if (shouldUpdate(value, oldValue, propName)) {
99
- states.set(propName, value);
100
- handlers.set.forEach((cb) => cb(propName, value, oldValue));
101
- }
102
- };
103
- const state = (typeof Proxy === 'undefined'
104
- ? {}
105
- : new Proxy(unwrappedState, {
106
- get(_, propName) {
107
- return get(propName);
108
- },
109
- ownKeys(_) {
110
- return Array.from(states.keys());
111
- },
112
- getOwnPropertyDescriptor() {
113
- return {
114
- enumerable: true,
115
- configurable: true,
116
- };
117
- },
118
- has(_, propName) {
119
- return states.has(propName);
120
- },
121
- set(_, propName, value) {
122
- set(propName, value);
123
- return true;
124
- },
125
- }));
126
- const on = (eventName, callback) => {
127
- handlers[eventName].push(callback);
128
- return () => {
129
- removeFromArray(handlers[eventName], callback);
130
- };
131
- };
132
- const onChange = (propName, cb) => {
133
- const unSet = on('set', (key, newValue) => {
134
- if (key === propName) {
135
- cb(newValue);
136
- }
137
- });
138
- // We need to unwrap the defaultState because it might be a function.
139
- // Otherwise we might not be sending the right reset value.
140
- const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
141
- return () => {
142
- unSet();
143
- unReset();
144
- };
145
- };
146
- const use = (...subscriptions) => {
147
- const unsubs = subscriptions.reduce((unsubs, subscription) => {
148
- if (subscription.set) {
149
- unsubs.push(on('set', subscription.set));
150
- }
151
- if (subscription.get) {
152
- unsubs.push(on('get', subscription.get));
153
- }
154
- if (subscription.reset) {
155
- unsubs.push(on('reset', subscription.reset));
156
- }
157
- if (subscription.dispose) {
158
- unsubs.push(on('dispose', subscription.dispose));
159
- }
160
- return unsubs;
161
- }, []);
162
- return () => unsubs.forEach((unsub) => unsub());
163
- };
164
- const forceUpdate = (key) => {
165
- const oldValue = states.get(key);
166
- handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
167
- };
168
- return {
169
- state,
170
- get,
171
- set,
172
- on,
173
- onChange,
174
- use,
175
- dispose,
176
- reset,
177
- forceUpdate,
178
- };
179
- };
180
- const removeFromArray = (array, item) => {
181
- const index = array.indexOf(item);
182
- if (index >= 0) {
183
- array[index] = array[array.length - 1];
184
- array.length--;
185
- }
186
- };
187
-
188
- const createStore = (defaultState, shouldUpdate) => {
189
- const map = createObservableMap(defaultState, shouldUpdate);
190
- map.use(stencilSubscription());
191
- return map;
192
- };
193
-
194
- const store = createStore({
195
- exporterProviders: {},
196
- filterFieldsDataSource: undefined
197
- });
198
-
199
- export { store as s };
@@ -1,460 +0,0 @@
1
- import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-a7d3d3f1.js';
2
- import { Action, ObjectUtils, JSUtils, DataUnitAction, ApplicationContext, DataType } from '@sankhyalabs/core';
3
- import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder-0a4becdd.js';
5
-
6
- const SnkDataUnit = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.dataStateChange = createEvent(this, "dataStateChange", 3);
10
- this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
11
- this.messagesBuilderUpdated = createEvent(this, "messagesBuilderUpdated", 3);
12
- this.insertionMode = createEvent(this, "insertionMode", 3);
13
- this.cancelEdition = createEvent(this, "cancelEdition", 3);
14
- this._onDataUnitResolve = [];
15
- this._openedAlert = false;
16
- this._dataUnitObserver = (action) => {
17
- var _a, _b;
18
- const duState = this.buildDataState();
19
- this.dataState = duState;
20
- if (action.type === Action.DATA_SAVED) {
21
- if (this.ignoreSaveMessage) {
22
- return;
23
- }
24
- const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
25
- if (msg != undefined) {
26
- this.showSuccessMessage(msg);
27
- }
28
- }
29
- if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
30
- this.insertionMode.emit();
31
- }
32
- if (action.type === Action.EDITION_CANCELED) {
33
- this.cancelEdition.emit();
34
- }
35
- if (action.type === Action.RECORDS_REMOVED) {
36
- const cachedRecords = action.payload.cachedRecords;
37
- let removeFinishMsg;
38
- if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
39
- removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
40
- }
41
- else {
42
- removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
43
- }
44
- if (removeFinishMsg != undefined) {
45
- this.showSuccessMessage(removeFinishMsg);
46
- }
47
- const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
48
- const paginationInfo = this.dataUnit.getPaginationInfo();
49
- if (paginationInfo) {
50
- if (recordsCount > 0 || paginationInfo.hasMore) {
51
- this.dataUnit.gotoPage(paginationInfo.currentPage);
52
- }
53
- else {
54
- this.dataUnit.gotoPage(0);
55
- }
56
- }
57
- }
58
- this.messagesBuilder.currentOperation = this.getMessageOperation();
59
- };
60
- this.dataState = undefined;
61
- this.messagesBuilder = undefined;
62
- this.dataUnitName = undefined;
63
- this.entityName = undefined;
64
- this.pageSize = 150;
65
- this.dataUnit = undefined;
66
- this.beforeSave = undefined;
67
- this.afterSave = undefined;
68
- this.useCancelConfirm = true;
69
- this.ignoreSaveMessage = undefined;
70
- this.configName = undefined;
71
- this.resourceID = undefined;
72
- }
73
- observePageSize() {
74
- if (this.dataUnit) {
75
- this.dataUnit.pageSize = this.pageSize;
76
- }
77
- }
78
- observeDataUnitName(newValue, oldValue) {
79
- if (oldValue != newValue) {
80
- if (this.dataUnit) {
81
- this._application.updateDataunitCache(oldValue, this.dataUnitName, this.dataUnit);
82
- }
83
- else {
84
- this.loadDataUnit();
85
- }
86
- }
87
- }
88
- observeEntityName(newValue, oldValue) {
89
- if (oldValue != newValue) {
90
- this.dataUnit = undefined;
91
- this.entityName = newValue;
92
- this.loadDataUnit();
93
- }
94
- }
95
- observeDataState(newValue, oldValue) {
96
- if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
97
- this.dataStateChange.emit(newValue);
98
- }
99
- }
100
- observeDataUnit() {
101
- this.handlerLinkFields();
102
- this.dataUnitReady.emit(this.dataUnit);
103
- }
104
- observeMessagesBuilder(newValue) {
105
- if (newValue) {
106
- this.messagesBuilderUpdated.emit(newValue);
107
- }
108
- }
109
- /**
110
- * Obtém o dataUnit.
111
- */
112
- async getDataUnit() {
113
- return new Promise((resolve) => {
114
- if (this.dataUnit) {
115
- resolve(this.dataUnit);
116
- }
117
- else {
118
- this._onDataUnitResolve.push(resolve);
119
- }
120
- });
121
- }
122
- /**
123
- * Método que retorna a lista de IDs dos registros selecionados.
124
- * @returns Retorna a lista de IDs dos registros selecionados.
125
- */
126
- async getSelectedRecordsIDsInfo() {
127
- var _a;
128
- const selectionInfo = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
129
- if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
130
- return [];
131
- }
132
- const selectedRecordsIDsInfo = [];
133
- const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.records;
134
- if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
135
- selectedRecords.forEach(({ __record__id__ }) => {
136
- if (!this.dataUnit.isNewRecord(__record__id__)) {
137
- /*
138
- Esse if foi necessário para tratar corretamente o ID
139
- do record quando está sendo utilizado no modo standAlone
140
- isso não faz a exportação da grid funcionar no modo standAlone
141
- mas deixa de causar erro nas oprações de CRUD.
142
- */
143
- if (!JSUtils.isBase64(__record__id__)) {
144
- selectedRecordsIDsInfo.push({
145
- name: "__record__id__",
146
- type: DataType.TEXT,
147
- value: __record__id__
148
- });
149
- return;
150
- }
151
- const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
152
- Object.entries(revertBase64ToObject).forEach(([name, value]) => {
153
- var _a;
154
- const metadataField = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
155
- if (metadataField == undefined) {
156
- return;
157
- }
158
- selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
159
- });
160
- }
161
- });
162
- }
163
- return selectedRecordsIDsInfo;
164
- }
165
- getCleanOnCopyFields() {
166
- var _a;
167
- return (_a = this.dataUnit.metadata) === null || _a === void 0 ? void 0 : _a.fields.filter(field => { var _a; return (_a = field.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy; }).map(field => field.name);
168
- }
169
- async interceptAction(action) {
170
- return new Promise(resolve => {
171
- var _a, _b, _c, _d, _e;
172
- switch (action.type) {
173
- case Action.RECORDS_ADDED:
174
- if (this.isAllowed("INSERT")) {
175
- resolve(action);
176
- }
177
- else {
178
- ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
179
- }
180
- break;
181
- case Action.RECORDS_COPIED:
182
- if (this.isAllowed("CLONE")) {
183
- const cleanFields = this.getCleanOnCopyFields();
184
- if (cleanFields.length > 0) {
185
- const records = action.payload;
186
- action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
187
- const newRecord = Object.assign({}, record);
188
- cleanFields.forEach(fieldName => delete newRecord[fieldName]);
189
- return newRecord;
190
- }));
191
- }
192
- resolve(action);
193
- }
194
- else {
195
- ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
196
- }
197
- break;
198
- case Action.DATA_CHANGED:
199
- case Action.CHANGING_DATA:
200
- if (this.isAllowed("UPDATE"))
201
- return resolve(action);
202
- if (this._openedAlert)
203
- return this.dataUnit.cancelEdition();
204
- this._openedAlert = true;
205
- this.dataUnit.cancelEdition();
206
- ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
207
- this._openedAlert = false;
208
- });
209
- break;
210
- case Action.SAVING_DATA:
211
- if (this.beforeSave) {
212
- const continueAction = this.beforeSave(this.dataUnit);
213
- if (continueAction instanceof Promise) {
214
- continueAction.then(result => resolve(result ? action : undefined));
215
- }
216
- else {
217
- resolve(continueAction ? action : undefined);
218
- }
219
- }
220
- else {
221
- resolve(action);
222
- }
223
- break;
224
- case Action.DATA_SAVED:
225
- if (this.afterSave) {
226
- this.afterSave(this.dataUnit);
227
- }
228
- else {
229
- resolve(action);
230
- }
231
- break;
232
- case Action.EDITION_CANCELED:
233
- if (!this.useCancelConfirm)
234
- return resolve(action);
235
- if (this.dataState.hasDirtyRecords) {
236
- const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
237
- if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
238
- resolve(action);
239
- return;
240
- }
241
- if (cancelConfirmation == undefined) {
242
- this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
243
- resolve(action);
244
- }
245
- else {
246
- const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
247
- ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
248
- .then((result) => {
249
- result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
250
- resolve(result ? action : undefined);
251
- });
252
- }
253
- }
254
- else {
255
- resolve(action);
256
- }
257
- break;
258
- case Action.REMOVING_RECORDS:
259
- if (this.isAllowed("REMOVE")) {
260
- let multipleSelection = false;
261
- let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
262
- const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
263
- if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
264
- removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
265
- multipleSelection = true;
266
- }
267
- if (!removeConfirmation) {
268
- resolve(action);
269
- }
270
- else {
271
- const options = {
272
- canClose: false,
273
- labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
274
- labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
275
- btnConfirmDanger: false
276
- };
277
- const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
278
- ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options)
279
- .then((result) => resolve(result ? action : undefined));
280
- }
281
- }
282
- else {
283
- ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
284
- }
285
- break;
286
- default:
287
- resolve(action);
288
- }
289
- });
290
- }
291
- showSuccessMessage(message) {
292
- ApplicationUtils.info(message, { iconName: "check" });
293
- }
294
- isAllowed(flag) {
295
- return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
296
- }
297
- buildDataState() {
298
- const selectionInfo = this.dataUnit.getSelectionInfo();
299
- const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
300
- return new DataStateImpl({
301
- insertionMode: this.dataUnit.hasNewRecord(),
302
- isStartingInsertionMode,
303
- hasNext: this.dataUnit.hasNext(),
304
- hasPrevious: this.dataUnit.hasPrevious(),
305
- copyMode: this.dataUnit.hasCopiedRecord(),
306
- isDirty: this.dataUnit.isDirty(),
307
- hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
308
- selectedRecords: undefined,
309
- selectionInfo,
310
- selectedRecord: this.dataUnit.getSelectedRecord(),
311
- recordsIsEmpty: this.dataUnit.records.length === 0
312
- });
313
- }
314
- /**
315
- * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
316
- * através de um pequeno modulo na estrutura da aplicação:
317
- * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
318
- * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
319
- */
320
- getMessage(key, params = undefined) {
321
- if (!params) {
322
- params = this.getMessageParams();
323
- }
324
- return this.messagesBuilder.getMessage(key, params);
325
- }
326
- getMessageParams() {
327
- //FIXME: Devido ao recurso de multiseleção do dataunit, precisaremos criar um mecanismo para
328
- //oferecer todos os registros selecionados para a mensagem, pois mensagens podem ficar incorretas.
329
- return this.dataState.selectedRecord;
330
- }
331
- getMessageOperation() {
332
- if (this.dataState.copyMode) {
333
- return OperationMap.CLONE;
334
- }
335
- if (this.dataState.insertionMode || this.dataState.isStartingInsertionMode) {
336
- return OperationMap.INSERT;
337
- }
338
- if (this.dataState.isDirty) {
339
- return OperationMap.UPDATE;
340
- }
341
- return OperationMap.CLEAN;
342
- }
343
- async getDataUnitParentOrChild() {
344
- var _a;
345
- const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
346
- if (this._parentSnkDataUnit) {
347
- this._parentDataUnit = await ((_a = this._parentSnkDataUnit) === null || _a === void 0 ? void 0 : _a.getDataUnit());
348
- return await this._application.getDataUnit(this.entityName, cacheName, this._parentDataUnit, this.configName, this.resourceID);
349
- }
350
- else {
351
- return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
352
- }
353
- }
354
- async loadDataUnit() {
355
- if (this.dataUnit == null && this._application && this.entityName) {
356
- this.dataUnit = await this.getDataUnitParentOrChild();
357
- }
358
- if (this.dataUnit) {
359
- this.dataUnit.pageSize = this.pageSize;
360
- this.dataUnit.unsubscribe(this._dataUnitObserver);
361
- this.dataUnit.addInterceptor(this);
362
- this.dataUnit.subscribe(this._dataUnitObserver);
363
- this.dataState = this.buildDataState();
364
- let resolver;
365
- while (resolver = this._onDataUnitResolve.pop()) {
366
- resolver(this.dataUnit);
367
- }
368
- }
369
- }
370
- getParentSnkDataUnit() {
371
- let currentElement = this.element;
372
- while (currentElement.parentNode) {
373
- if (currentElement.parentNode.nodeName === 'SNK-DATA-UNIT') {
374
- return currentElement.parentNode;
375
- }
376
- currentElement = currentElement.parentNode;
377
- }
378
- return;
379
- }
380
- handlerLinkFields() {
381
- var _a, _b;
382
- const metadata = Object.assign({}, this.dataUnit.metadata);
383
- if (!this._parentDataUnit)
384
- return;
385
- const child = this._parentDataUnit.getChildInfo(this.entityName);
386
- if (!child)
387
- return;
388
- const fieldsLink = (_a = child === null || child === void 0 ? void 0 : child.links) === null || _a === void 0 ? void 0 : _a.map(link => link.target);
389
- (_b = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
390
- if (fieldsLink === null || fieldsLink === void 0 ? void 0 : fieldsLink.includes(field.name)) {
391
- field.visible = false;
392
- }
393
- });
394
- this.dataUnit.metadata = metadata;
395
- }
396
- static getNearestInstance(element) {
397
- let parent = element.parentElement;
398
- while (parent) {
399
- if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
400
- return parent;
401
- }
402
- parent = parent.parentElement;
403
- }
404
- }
405
- //---------------------------------------------
406
- // Lifecycle web component
407
- //---------------------------------------------
408
- componentWillLoad() {
409
- this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
410
- this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
411
- this._parentSnkDataUnit = this.getParentSnkDataUnit();
412
- if (this.messagesBuilder == undefined) {
413
- this.messagesBuilder = new SnkMessageBuilder(this.entityName);
414
- }
415
- }
416
- disconnectedCallback() {
417
- if (this.dataUnit) {
418
- this.dataUnit.releaseCallbacks();
419
- }
420
- }
421
- componentDidLoad() {
422
- this.loadDataUnit();
423
- }
424
- render() {
425
- return (h(Host, null));
426
- }
427
- get element() { return getElement(this); }
428
- static get watchers() { return {
429
- "pageSize": ["observePageSize"],
430
- "dataUnitName": ["observeDataUnitName"],
431
- "entityName": ["observeEntityName"],
432
- "dataState": ["observeDataState"],
433
- "dataUnit": ["observeDataUnit"],
434
- "messagesBuilder": ["observeMessagesBuilder"]
435
- }; }
436
- };
437
- class DataStateImpl {
438
- constructor(datastate) {
439
- this.copyMode = datastate.copyMode;
440
- this.insertionMode = datastate.insertionMode;
441
- this.isStartingInsertionMode = datastate.isStartingInsertionMode;
442
- this.isDirty = datastate.isDirty;
443
- this.hasDirtyRecords = datastate.hasDirtyRecords;
444
- this.hasNext = datastate.hasNext;
445
- this.hasPrevious = datastate.hasPrevious;
446
- this.selectionInfo = datastate.selectionInfo;
447
- this.selectedRecord = datastate.selectedRecord;
448
- this.recordsIsEmpty = datastate.recordsIsEmpty;
449
- }
450
- get selectedRecords() {
451
- var _a;
452
- console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`.");
453
- if ((_a = this.selectionInfo) === null || _a === void 0 ? void 0 : _a.isAllRecords()) {
454
- throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");
455
- }
456
- return this.selectionInfo.records;
457
- }
458
- }
459
-
460
- export { SnkDataUnit as S };
@@ -1 +0,0 @@
1
- import{C as t}from"./p-aff76a53.js";import{ObjectUtils as e,StringUtils as s}from"@sankhyalabs/core";import{F as i}from"./p-df5451c7.js";class n{constructor(t,e,s){this._resourceID=e,this._configName=t,this._onConfigChange=s}addFormLegacyConfig(e){this._configName&&t.addFormLegacyConfig(this._configName,e)}async loadConfig(){return new Promise((e=>{t.loadFormConfig(this._configName,this._resourceID).then((t=>{this.setConfig(t),e(t)})).catch((t=>{console.warn(t)}))}))}saveConfig(s){const i=e.copy(s);return new Promise((e=>{t.saveFormConfig(s,this._configName,this._resourceID).then((t=>{this.setConfig(Object.assign(Object.assign({},i),t)),e(Object.assign(Object.assign({},i),t))}))}))}saveCardState(e,s,i){return new Promise((n=>{var r;const h=(null===(r=this._config)||void 0===r?void 0:r.cardsState)||new Map,a=h.get(e);h.set(e,"fixed"===i?this.updateFixSequence(Object.assign(Object.assign({},a),{fixed:s.fixed}),h):Object.assign(Object.assign({},a),{[i]:s[i]})),t.saveCardState(h,this._configName,this._resourceID).then((t=>{this._config=Object.assign(Object.assign({},this._config),{cardsState:h}),n(t)}))}))}updateFixSequence(t,e){let s=-1;return Array.from(e.values()).forEach((e=>{e.fixed||delete t.fixSequence,null!=e.fixSequence&&(s=Math.max(s,e.fixSequence))})),t.fixed?t.fixSequence=s+1:delete t.fixSequence,t}getFieldsList(t,e){var s;const i=null===(s=this._config)||void 0===s?void 0:s.fields;return null!=i&&i.length>0?i.map((({label:e,name:s,readOnly:i})=>null==e?t.getField(s):{name:s,label:e,readOnly:i})).filter((t=>this.isFieldVisible(t,e))):null!=t?t.metadata.fields.filter((t=>this.isFieldVisible(t,e))).map((({label:t,name:e,readOnly:s})=>({label:t,name:e,readOnly:s}))):[]}isFieldVisible(t,e){if(!1===t.visible)return!1;if(null==e)return!0;const i=s.replaceAccentuatedCharsLower((t.label||t.name).toLocaleLowerCase()),n=s.replaceAccentuatedCharsLower(e.toLocaleLowerCase());return i.includes(n)}getInsertionConfig(t,e){let s=this.getFieldsList(t);return e&&(s=s.filter((e=>{if(t){const s=t.getField(e.name);if(s&&s.readOnly)return!1}return!e.readOnly}))),Object.assign(Object.assign({},this._config),{fields:s})}setConfig(t){this.isLoaded=!0;const{cardsState:e,summary:s,defaultVars:i}=this._config||{};this._config=Object.assign({},t),e&&(this._config.cardsState=e),s&&(this._config.summary=s),i&&(this._config.defaultVars=i),this._onConfigChange&&this._onConfigChange(Object.assign({},this._config))}getConfig(t,e,s){return t?this.getInsertionConfig(e,null==s||s):Object.assign({},this._config)}getFormConfigFetcher(){return null==this._formConfigFetcher&&(this._formConfigFetcher=new i),this._formConfigFetcher}async fetchUserAvailableConfigs(){return null!=this._configName?Promise.resolve(void 0):this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName,this._resourceID)}async fetchLegacyConfig(){return this.getFormConfigFetcher().fetchLegacyConfig(this._configName,this._resourceID)}async fetchDefaultConfig(){return this.getFormConfigFetcher().fetchDefaultConfig(this._configName,this._resourceID)}}export{n as S}
@@ -1 +0,0 @@
1
- import{r as i,c as t,h as e,H as s}from"./p-d2d301a6.js";import{ElementIDUtils as r}from"@sankhyalabs/core";import{DataBinder as o}from"@sankhyalabs/ezui/dist/collection/utils/form";const a=class{constructor(e){i(this,e),this.snkContentCardChanged=t(this,"snkContentCardChanged",7),this.snkRequestClearFieldToFocus=t(this,"snkRequestClearFieldToFocus",7),this.formItemsReady=t(this,"formItemsReady",7),this.levelPath=void 0,this.label=void 0,this.name=void 0,this.fields=void 0,this.formMetadata=void 0,this.dataUnit=void 0,this.contracted=void 0,this.fixed=!1,this.summaryFields=void 0,this.canExpand=!0,this.canFix=!0,this.recordsValidator=void 0,this.fieldToFocus=void 0}async showUp(){this._formView&&this._formView.showUp()}changeFix(){this.fixed=!this.fixed,this.emitEvent("fixed")}changeContracted(){this.contracted=!this.contracted,this.emitEvent("presentation")}emitEvent(i){this.snkContentCardChanged.emit({formName:this.name,cardConfig:{fixed:this.fixed,presentation:this.contracted?"CONTRACTED":"EXPANDED"},propertyChanged:i})}getCardSummary(){const i={};return this.getSummaryFields().forEach((({field:t,label:e})=>{var s;const r=this.dataUnit.getFormattedValue(t);""!==r&&(null==e&&(e=null===(s=this.dataUnit.getField(t))||void 0===s?void 0:s.label),i[e]=r)})),i}getSummaryFields(){return null==this.summaryFields?this.fields.map((i=>{const t=this.dataUnit.getField(i.name);return{field:i.name,label:i.label||(null==t?void 0:t.label)}})):this.summaryFields}bindFields(i){null==this._dataBinder&&null!=this.dataUnit&&(this._dataBinder=new o(this.dataUnit)),this._dataBinder&&this._dataBinder.bind(i,this.dataUnit.dataUnitId,this.formMetadata,this.recordsValidator)}handleFormItemsReady(i){i.stopPropagation(),this.formItemsReady.emit(Object.assign(Object.assign({},i.detail),{formId:this.name}))}disconnectedCallback(){null!=this._dataBinder&&this._dataBinder.onDisconnectedCallback()}componentDidRender(){null!=this.fieldToFocus&&this.fields.some((i=>i.name===this.fieldToFocus))&&requestAnimationFrame((()=>{this._dataBinder.setFocus(this.fieldToFocus),this.snkRequestClearFieldToFocus.emit()}))}render(){return e(s,{class:"ez-box__container"},e("div",{class:"summary-header ez-flex ez-size-width--full"},e("div",{class:"ez-flex ez-text ez-title--primary ez-text--bold ez-flex--justify-start ez-flex--align-items-center ez-col--sd-9"},this.levelPath?e("span",{class:"level-path"},this.levelPath+" /"):void 0,this.label),e("div",{class:"ez-flex ez-flex--justify-end ez-col--sd-3"},this.canFix&&e("ez-button",{class:"ez-padding-left--medium",mode:"icon",size:"small",iconName:this.fixed?"un-pin":"push-pin","data-element-id":r.getInternalIDInfo("toggleFixed_ezFormCard"),onClick:()=>this.changeFix(),title:this.fixed?"Desafixar":"Fixar"}),this.canExpand&&e("ez-button",{class:"ez-padding-left--medium",mode:"icon",size:"small",iconName:this.contracted?"chevron-down":"chevron-up","data-element-id":r.getInternalIDInfo("toggleExpand_ezFormCard"),onClick:()=>this.changeContracted(),title:this.contracted?"Expandir":"Resumir"}))),e("slot",null),this.contracted?e("snk-form-summary",{summary:this.getCardSummary()}):e("ez-form-view",{ref:i=>this._formView=i,fields:this.fields,onEzContentReady:i=>this.bindFields(i.detail),onFormItemsReady:i=>this.handleFormItemsReady(i)}))}};a.style=".sc-snk-form-view-h{display:flex;width:100%;--ez-form-card-summary-field-content-weight:700}.level-path.sc-snk-form-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.summary-wrapper.sc-snk-form-view{display:flex;overflow:hidden}.summary-header.sc-snk-form-view{border-bottom:1px solid var(--color--strokes);margin-bottom:var(--space--medium);padding-bottom:var(--space--medium)}.summary-container.sc-snk-form-view{display:flex;flex-direction:column}.summary-container.sc-snk-form-view{padding-right:calc(var(--space--extra-large) / 1.5)}.summary-field.sc-snk-form-view{min-width:30px;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.summary-field__title.sc-snk-form-view{color:var(--text--primary, #626e82);font-size:var(--title--small);white-space:nowrap;font-weight:var(--text-weight--medium)}.summary-field__content.sc-snk-form-view{color:var(--title--primary, #2b3a54);font-size:var(--text--large);font-weight:var(--ez-form-card-summary-field-content-weight)}";export{a as snk_form_view}