@sankhyalabs/sankhyablocks 10.1.0-dev.52 → 10.1.0-dev.53

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 (263) hide show
  1. package/dist/cjs/{ConfigStorage-a1fab5ca.js → ConfigStorage-4201dd3d.js} +2 -2
  2. package/dist/cjs/{DataFetcher-384d2ce8.js → DataFetcher-b3a8075d.js} +2830 -2
  3. package/dist/cjs/FormConfigHelper-c5f5473a.js +342 -0
  4. package/dist/cjs/{ISave-ecbe9336.js → ISave-4674c283.js} +1 -1
  5. package/dist/cjs/{PersonalizedFilterUtils-eccb267a.js → PersonalizedFilterUtils-263e4d24.js} +52 -5
  6. package/dist/cjs/{SnkFormConfigManager-44386305.js → SnkFormConfigManager-c3a49038.js} +2 -2
  7. package/dist/cjs/{SnkMultiSelectionListDataSource-d341dd02.js → SnkMultiSelectionListDataSource-0bc94d36.js} +4 -4
  8. package/dist/cjs/{auth-fetcher-6b134ec4.js → auth-fetcher-0ecc53ff.js} +1 -1
  9. package/dist/cjs/{dataunit-fetcher-b9822794.js → dataunit-fetcher-bcbc38c0.js} +2 -3
  10. package/dist/cjs/{filter-type.enum-2bb46d2a.js → filter-type.enum-b3b388af.js} +7 -0
  11. package/dist/cjs/{form-config-fetcher-45d1964c.js → form-config-fetcher-f80dbc3b.js} +23 -5
  12. package/dist/cjs/index-1894343a.js +24 -36
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +4 -5
  15. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  16. package/dist/cjs/snk-actions-button_9.cjs.entry.js +5 -6
  17. package/dist/cjs/snk-application.cjs.entry.js +7 -8
  18. package/dist/cjs/snk-attach_11.cjs.entry.js +2950 -0
  19. package/dist/cjs/snk-crud.cjs.entry.js +31 -243
  20. package/dist/cjs/snk-data-exporter.cjs.entry.js +5 -6
  21. package/dist/cjs/{snk-data-unit-4b6dc396.js → snk-data-unit-3b94547d.js} +11 -11
  22. package/dist/cjs/snk-data-unit.cjs.entry.js +3 -4
  23. package/dist/cjs/snk-detail-view.cjs.entry.js +9 -10
  24. package/dist/cjs/snk-dynaform-config-header_5.cjs.entry.js +739 -0
  25. package/dist/cjs/snk-dynaform-detail-view_2.cjs.entry.js +938 -0
  26. package/dist/cjs/snk-dynaform-field-config_2.cjs.entry.js +327 -0
  27. package/dist/cjs/snk-dynaform-guides-view-e98f7f3a.js +747 -0
  28. package/dist/cjs/snk-dynaform-guides-view.cjs.entry.js +23 -0
  29. package/dist/cjs/snk-dynaform.cjs.entry.js +675 -0
  30. package/dist/cjs/{snk-expression-group_2.cjs.entry.js → snk-expression-group_4.cjs.entry.js} +421 -18
  31. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +41 -44
  32. package/dist/cjs/snk-form_2.cjs.entry.js +4 -5
  33. package/dist/cjs/snk-grid.cjs.entry.js +7 -8
  34. package/dist/cjs/{snk-guides-viewer-8e7a503b.js → snk-guides-viewer-3054d541.js} +1 -1
  35. package/dist/cjs/snk-guides-viewer.cjs.entry.js +5 -6
  36. package/dist/cjs/snk-layout-form-config.cjs.entry.js +4 -5
  37. package/dist/cjs/snk-pesquisa.cjs.entry.js +4 -5
  38. package/dist/cjs/taskbarUtils-38748460.js +231 -0
  39. package/dist/collection/collection-manifest.json +17 -0
  40. package/dist/collection/components/snk-dynaform/interfaces/PropsCustomEditor.js +1 -0
  41. package/dist/collection/components/snk-dynaform/interfaces/PropsCustomRender.js +1 -0
  42. package/dist/collection/components/snk-dynaform/snk-dynaform.css +64 -0
  43. package/dist/collection/components/snk-dynaform/snk-dynaform.js +1657 -0
  44. package/dist/collection/components/snk-dynaform/subcomponents/CardFormResizeObserver.js +26 -0
  45. package/dist/collection/components/snk-dynaform/subcomponents/GuideBuilder.js +51 -0
  46. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.css +112 -0
  47. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.js +992 -0
  48. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.css +64 -0
  49. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.js +588 -0
  50. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-guides-view/snk-dynaform-guides-view.css +98 -0
  51. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-guides-view/snk-dynaform-guides-view.js +1167 -0
  52. package/dist/collection/components/snk-dynaform-form-config/FormConfigHelper.js +325 -0
  53. package/dist/collection/components/snk-dynaform-form-config/SnkFormConfigManager.js +212 -0
  54. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-config-header.css +17 -0
  55. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-config-header.js +236 -0
  56. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-configs-button/snk-dynaform-configs-button.css +41 -0
  57. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-configs-button/snk-dynaform-configs-button.js +170 -0
  58. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-config/snk-dynaform-field-config.css +22 -0
  59. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-config/snk-dynaform-field-config.js +408 -0
  60. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-item.css +88 -0
  61. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-item.js +209 -0
  62. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-fields-layout/snk-dynaform-fields-layout.css +167 -0
  63. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-fields-layout/snk-dynaform-fields-layout.js +655 -0
  64. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-fields-selector/snk-dynaform-fields-selector.css +42 -0
  65. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-fields-selector/snk-dynaform-fields-selector.js +171 -0
  66. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-form-config.css +66 -0
  67. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-form-config.js +557 -0
  68. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-guides-configurator/snk-dynaform-guides-configurator.css +80 -0
  69. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-guides-configurator/snk-dynaform-guides-configurator.js +326 -0
  70. package/dist/collection/components/snk-grid/snk-grid.css +4 -2
  71. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +22 -4
  72. package/dist/components/form-config-fetcher.js +22 -4
  73. package/dist/components/index.d.ts +12 -0
  74. package/dist/components/index.js +12 -0
  75. package/dist/components/snk-crud.js +1 -212
  76. package/dist/components/snk-dynaform-config-header.d.ts +11 -0
  77. package/dist/components/snk-dynaform-config-header.js +6 -0
  78. package/dist/components/snk-dynaform-config-header2.js +103 -0
  79. package/dist/components/snk-dynaform-configs-button.d.ts +11 -0
  80. package/dist/components/snk-dynaform-configs-button.js +6 -0
  81. package/dist/components/snk-dynaform-configs-button2.js +76 -0
  82. package/dist/components/snk-dynaform-detail-view.d.ts +11 -0
  83. package/dist/components/snk-dynaform-detail-view.js +6 -0
  84. package/dist/components/snk-dynaform-detail-view2.js +1835 -0
  85. package/dist/components/snk-dynaform-field-config.d.ts +11 -0
  86. package/dist/components/snk-dynaform-field-config.js +6 -0
  87. package/dist/components/snk-dynaform-field-config2.js +605 -0
  88. package/dist/components/snk-dynaform-field-item.d.ts +11 -0
  89. package/dist/components/snk-dynaform-field-item.js +6 -0
  90. package/dist/components/snk-dynaform-field-item2.js +96 -0
  91. package/dist/components/snk-dynaform-fields-layout.d.ts +11 -0
  92. package/dist/components/snk-dynaform-fields-layout.js +6 -0
  93. package/dist/components/snk-dynaform-fields-layout2.js +428 -0
  94. package/dist/components/snk-dynaform-fields-selector.d.ts +11 -0
  95. package/dist/components/snk-dynaform-fields-selector.js +6 -0
  96. package/dist/components/snk-dynaform-fields-selector2.js +104 -0
  97. package/dist/components/snk-dynaform-form-config.d.ts +11 -0
  98. package/dist/components/snk-dynaform-form-config.js +6 -0
  99. package/dist/components/snk-dynaform-form-config2.js +430 -0
  100. package/dist/components/snk-dynaform-form-view.d.ts +11 -0
  101. package/dist/components/snk-dynaform-form-view.js +6 -0
  102. package/dist/components/snk-dynaform-form-view2.js +270 -0
  103. package/dist/components/snk-dynaform-guides-configurator.d.ts +11 -0
  104. package/dist/components/snk-dynaform-guides-configurator.js +6 -0
  105. package/dist/components/snk-dynaform-guides-configurator2.js +173 -0
  106. package/dist/components/snk-dynaform-guides-view.d.ts +11 -0
  107. package/dist/components/snk-dynaform-guides-view.js +6 -0
  108. package/dist/components/snk-dynaform.d.ts +11 -0
  109. package/dist/components/snk-dynaform.js +1003 -0
  110. package/dist/components/snk-grid2.js +1 -1
  111. package/dist/components/taskbarUtils.js +224 -0
  112. package/dist/esm/{ConfigStorage-76872695.js → ConfigStorage-e834d1ea.js} +2 -2
  113. package/dist/esm/{DataFetcher-e60f8d53.js → DataFetcher-5ed0a377.js} +2830 -3
  114. package/dist/esm/FormConfigHelper-efc29480.js +328 -0
  115. package/dist/esm/{ISave-4929c071.js → ISave-5b46d691.js} +1 -1
  116. package/dist/esm/{PersonalizedFilterUtils-d2439a9a.js → PersonalizedFilterUtils-45b5803c.js} +49 -2
  117. package/dist/esm/{SnkFormConfigManager-83f6b22f.js → SnkFormConfigManager-bfd575c2.js} +2 -2
  118. package/dist/esm/{SnkMultiSelectionListDataSource-18abafb1.js → SnkMultiSelectionListDataSource-9e9166ae.js} +4 -4
  119. package/dist/esm/{auth-fetcher-1a31c1e4.js → auth-fetcher-5283045d.js} +1 -1
  120. package/dist/esm/{dataunit-fetcher-c176e002.js → dataunit-fetcher-3b1ca96e.js} +1 -2
  121. package/dist/esm/{filter-type.enum-f6a8fe23.js → filter-type.enum-62b7fe88.js} +8 -1
  122. package/dist/esm/{form-config-fetcher-b44b2727.js → form-config-fetcher-db1bf140.js} +23 -5
  123. package/dist/esm/index-04f73a26.js +24 -36
  124. package/dist/esm/loader.js +1 -1
  125. package/dist/esm/pesquisa-grid_2.entry.js +4 -5
  126. package/dist/esm/sankhyablocks.js +1 -1
  127. package/dist/esm/snk-actions-button_9.entry.js +5 -6
  128. package/dist/esm/snk-application.entry.js +6 -7
  129. package/dist/esm/snk-attach_11.entry.js +2936 -0
  130. package/dist/esm/snk-crud.entry.js +6 -218
  131. package/dist/esm/snk-data-exporter.entry.js +5 -6
  132. package/dist/esm/{snk-data-unit-d8cfa950.js → snk-data-unit-dfde62cb.js} +2 -2
  133. package/dist/esm/snk-data-unit.entry.js +3 -4
  134. package/dist/esm/snk-detail-view.entry.js +7 -8
  135. package/dist/esm/snk-dynaform-config-header_5.entry.js +731 -0
  136. package/dist/esm/snk-dynaform-detail-view_2.entry.js +933 -0
  137. package/dist/esm/snk-dynaform-field-config_2.entry.js +322 -0
  138. package/dist/esm/snk-dynaform-guides-view-1f1455d6.js +744 -0
  139. package/dist/esm/snk-dynaform-guides-view.entry.js +15 -0
  140. package/dist/esm/snk-dynaform.entry.js +671 -0
  141. package/dist/esm/{snk-expression-group_2.entry.js → snk-expression-group_4.entry.js} +405 -4
  142. package/dist/esm/snk-filter-bar_4.entry.js +5 -8
  143. package/dist/esm/snk-form_2.entry.js +4 -5
  144. package/dist/esm/snk-grid.entry.js +7 -8
  145. package/dist/esm/{snk-guides-viewer-adf39ea2.js → snk-guides-viewer-95fefcaa.js} +1 -1
  146. package/dist/esm/snk-guides-viewer.entry.js +5 -6
  147. package/dist/esm/snk-layout-form-config.entry.js +4 -5
  148. package/dist/esm/snk-pesquisa.entry.js +4 -5
  149. package/dist/esm/taskbarUtils-8501d09e.js +225 -0
  150. package/dist/sankhyablocks/p-0dbd53d9.js +1 -0
  151. package/dist/sankhyablocks/{p-f5ad0720.js → p-19d1ca14.js} +1 -1
  152. package/dist/sankhyablocks/{p-ab5e12fa.js → p-1cc4cf61.js} +1 -1
  153. package/dist/sankhyablocks/p-1edd6be6.entry.js +1 -0
  154. package/dist/sankhyablocks/p-22ddc1a5.entry.js +1 -0
  155. package/dist/sankhyablocks/p-24b059ee.entry.js +1 -0
  156. package/dist/sankhyablocks/{p-5c250661.js → p-2c00b93d.js} +1 -1
  157. package/dist/sankhyablocks/p-3623fddf.entry.js +1 -0
  158. package/dist/sankhyablocks/p-43c94ba5.entry.js +1 -0
  159. package/dist/sankhyablocks/p-449dfe55.entry.js +1 -0
  160. package/dist/sankhyablocks/p-451b5bcc.entry.js +1 -0
  161. package/dist/sankhyablocks/p-46d7e2de.js +1 -0
  162. package/dist/sankhyablocks/{p-3c990841.js → p-51e853f2.js} +1 -1
  163. package/dist/sankhyablocks/p-58709cf9.js +1 -0
  164. package/dist/sankhyablocks/p-589016e2.entry.js +1 -0
  165. package/dist/sankhyablocks/p-5d02c032.js +1 -0
  166. package/dist/sankhyablocks/p-5d50f59a.entry.js +1 -0
  167. package/dist/sankhyablocks/p-61776b68.entry.js +1 -0
  168. package/dist/sankhyablocks/p-6b8a1ec3.js +1 -0
  169. package/dist/sankhyablocks/p-7038cf62.entry.js +1 -0
  170. package/dist/sankhyablocks/{p-b1bb4cf1.js → p-70c2ee5c.js} +1 -1
  171. package/dist/sankhyablocks/p-7628e04f.entry.js +1 -0
  172. package/dist/sankhyablocks/p-7798788b.entry.js +1 -0
  173. package/dist/sankhyablocks/p-77c26de0.js +1 -0
  174. package/dist/sankhyablocks/p-7c34a0f7.entry.js +1 -0
  175. package/dist/sankhyablocks/p-a4a0d9b7.entry.js +1 -0
  176. package/dist/sankhyablocks/{p-4f7adf97.js → p-b1bf9564.js} +1 -1
  177. package/dist/sankhyablocks/p-b4c2a99c.entry.js +1 -0
  178. package/dist/sankhyablocks/p-b75af274.entry.js +1 -0
  179. package/dist/sankhyablocks/p-c538bd6c.entry.js +1 -0
  180. package/dist/sankhyablocks/{p-3704bf1b.js → p-d5810110.js} +1 -1
  181. package/dist/sankhyablocks/p-d7fd447e.entry.js +1 -0
  182. package/dist/sankhyablocks/p-d88278f8.js +28 -0
  183. package/dist/sankhyablocks/p-f076d742.js +60 -0
  184. package/dist/sankhyablocks/{p-8fe740b7.entry.js → p-f1ef090f.entry.js} +2 -2
  185. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  186. package/dist/types/components/snk-dynaform/interfaces/PropsCustomEditor.d.ts +4 -0
  187. package/dist/types/components/snk-dynaform/interfaces/PropsCustomRender.d.ts +4 -0
  188. package/dist/types/components/snk-dynaform/subcomponents/CardFormResizeObserver.d.ts +1 -0
  189. package/dist/types/components/snk-dynaform/subcomponents/GuideBuilder.d.ts +14 -0
  190. package/dist/types/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.d.ts +158 -0
  191. package/dist/types/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.d.ts +107 -0
  192. package/dist/types/components/snk-dynaform-form-config/FormConfigHelper.d.ts +36 -0
  193. package/dist/types/components/snk-dynaform-form-config/SnkFormConfigManager.d.ts +35 -0
  194. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-config-header.d.ts +23 -0
  195. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-configs-button/snk-dynaform-configs-button.d.ts +19 -0
  196. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-config/snk-dynaform-field-config.d.ts +56 -0
  197. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-fields-layout/snk-dynaform-fields-layout.d.ts +74 -0
  198. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-fields-selector/snk-dynaform-fields-selector.d.ts +21 -0
  199. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-form-config.d.ts +95 -0
  200. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-guides-configurator/snk-dynaform-guides-configurator.d.ts +35 -0
  201. package/dist/types/components.d.ts +2403 -1322
  202. package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +1 -0
  203. package/package.json +1 -1
  204. package/react/components.d.ts +12 -0
  205. package/react/components.js +12 -0
  206. package/react/components.js.map +1 -1
  207. package/dist/cjs/SnkMessageBuilder-a9300ebe.js +0 -2833
  208. package/dist/cjs/default-filters-a09bf82b.js +0 -8
  209. package/dist/cjs/index-62760a9c.js +0 -49
  210. package/dist/cjs/index-8d94b7e0.js +0 -7
  211. package/dist/cjs/snk-attach.cjs.entry.js +0 -948
  212. package/dist/cjs/snk-default-filter.cjs.entry.js +0 -77
  213. package/dist/cjs/snk-filter-advanced-mode_3.cjs.entry.js +0 -99
  214. package/dist/cjs/snk-filter-detail.cjs.entry.js +0 -198
  215. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +0 -408
  216. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +0 -109
  217. package/dist/cjs/snk-image-input.cjs.entry.js +0 -160
  218. package/dist/cjs/snk-personalized-filter.cjs.entry.js +0 -358
  219. package/dist/cjs/snk-simple-crud.cjs.entry.js +0 -865
  220. package/dist/esm/SnkMessageBuilder-1eb7a1af.js +0 -2831
  221. package/dist/esm/default-filters-50105e43.js +0 -8
  222. package/dist/esm/index-620ac460.js +0 -7
  223. package/dist/esm/index-8acbae97.js +0 -49
  224. package/dist/esm/snk-attach.entry.js +0 -944
  225. package/dist/esm/snk-default-filter.entry.js +0 -73
  226. package/dist/esm/snk-filter-advanced-mode_3.entry.js +0 -93
  227. package/dist/esm/snk-filter-detail.entry.js +0 -194
  228. package/dist/esm/snk-filter-field-search_2.entry.js +0 -403
  229. package/dist/esm/snk-filter-modal-item.entry.js +0 -105
  230. package/dist/esm/snk-image-input.entry.js +0 -156
  231. package/dist/esm/snk-personalized-filter.entry.js +0 -354
  232. package/dist/esm/snk-simple-crud.entry.js +0 -861
  233. package/dist/sankhyablocks/p-0a4cdcde.entry.js +0 -1
  234. package/dist/sankhyablocks/p-0afc64df.entry.js +0 -1
  235. package/dist/sankhyablocks/p-10f27dc6.entry.js +0 -1
  236. package/dist/sankhyablocks/p-20f03230.entry.js +0 -1
  237. package/dist/sankhyablocks/p-2af8aca3.js +0 -1
  238. package/dist/sankhyablocks/p-3870748a.js +0 -28
  239. package/dist/sankhyablocks/p-3d294185.entry.js +0 -1
  240. package/dist/sankhyablocks/p-438a225f.entry.js +0 -1
  241. package/dist/sankhyablocks/p-4d04bc75.entry.js +0 -1
  242. package/dist/sankhyablocks/p-554c0e54.js +0 -1
  243. package/dist/sankhyablocks/p-57c184a2.entry.js +0 -1
  244. package/dist/sankhyablocks/p-68c1a093.js +0 -1
  245. package/dist/sankhyablocks/p-6a4b21dd.js +0 -1
  246. package/dist/sankhyablocks/p-6ae7543b.entry.js +0 -1
  247. package/dist/sankhyablocks/p-6e278003.js +0 -60
  248. package/dist/sankhyablocks/p-82bcb4cf.entry.js +0 -1
  249. package/dist/sankhyablocks/p-84345e7a.js +0 -1
  250. package/dist/sankhyablocks/p-95af0bb1.entry.js +0 -1
  251. package/dist/sankhyablocks/p-a905712a.entry.js +0 -1
  252. package/dist/sankhyablocks/p-aff2d081.entry.js +0 -1
  253. package/dist/sankhyablocks/p-b0a357b4.entry.js +0 -1
  254. package/dist/sankhyablocks/p-b568c1d4.js +0 -1
  255. package/dist/sankhyablocks/p-bab4cde4.entry.js +0 -1
  256. package/dist/sankhyablocks/p-bd3c1aaa.entry.js +0 -1
  257. package/dist/sankhyablocks/p-cc64239c.entry.js +0 -1
  258. package/dist/sankhyablocks/p-cd00a3d1.entry.js +0 -1
  259. package/dist/sankhyablocks/p-d9ec8c4b.entry.js +0 -1
  260. package/dist/sankhyablocks/p-dbdbb77a.entry.js +0 -1
  261. package/dist/sankhyablocks/p-e8df1dea.entry.js +0 -1
  262. package/dist/sankhyablocks/p-ef9343c3.entry.js +0 -1
  263. package/dist/sankhyablocks/p-f4184ce7.js +0 -1
@@ -1 +1 @@
1
- import{r as i,e,h as s,F as t,g as r}from"./p-2c9d0870.js";import{ObjectUtils as n,Action as a,KeyboardManager as d}from"@sankhyalabs/core";import{buildFieldSearch as o,SHORTCUT_SEARCH_FIELD as h}from"@sankhyalabs/ezui/dist/collection/utils";import{buildFormMetadata as l,FormMetadata as u}from"@sankhyalabs/ezui/dist/collection/utils/form";import{V as v}from"./p-9019a32f.js";import{S as c}from"./p-ab5e12fa.js";import{T as g}from"./p-3072136e.js";const m="__FORM:",f=class{constructor(s){i(this,s),this.snkShowGuide=e(this,"snkShowGuide",7),this.snkMasterFormConfigChange=e(this,"snkMasterFormConfigChange",7),this.formConfigVisibilityChanged=e(this,"formConfigVisibilityChanged",7),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this.formItemsReady=e(this,"formItemsReady",7),this._guideBuilders=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this.resourceID=void 0,this.detailTaskbarCustomContainerId=void 0,this.formLegacyConfigName=void 0,this.enableGridInsert=!1,this.ignoreReadOnlyFormFields=void 0,this.getCustomTitle=void 0,this.customGuidesConfig=[],this._hasToCreateFieldSearch=!0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0,this._fieldToGetFocus=void 0,this._customEditors=void 0,this._customRenders=void 0,this._fieldsProps={},this._mainForm=void 0}observeDataUnit(){this.loadGuides(!0)}async observeFormConfigManager(i){const e=!!i;await this._viewStack.show(e?k.CONFIG:k.GUIDES),this.formConfigVisibilityChanged.emit(e)}observeDataState(i,e){var s,t,r,a,d,o;const h=null!==(t=null===(s=null==i?void 0:i.selectionInfo)||void 0===s?void 0:s.recordIds)&&void 0!==t?t:null===(r=null==i?void 0:i.selectedRecord)||void 0===r?void 0:r.__record__id__,l=null!==(d=null===(a=null==e?void 0:e.selectionInfo)||void 0===a?void 0:a.recordIds)&&void 0!==d?d:null===(o=null==e?void 0:e.selectedRecord)||void 0===o?void 0:o.__record__id__;n.equals(h,l)||this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected()),this.snkMasterFormConfigChange.emit(this.masterFormConfig)}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}async addCustomEditor(i,e){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:e})}async addGridCustomRender(i,e){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:e})}async setFieldProp(i,e,s){const t={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[e]:s})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),t)}async setFocus(){var i;null===(i=this._container)||void 0===i||i.focus({preventScroll:!0})}async reloadGuides(){this.loadGuides(!1)}exitViewer(){!this.enableGridInsert&&this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===g.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){f.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){var e,s;if(this.dataUnit.isMultipleEdition){const i=null!==(s=null===(e=this.dataUnit.getSelectionInfo())||void 0===e?void 0:e.records)&&void 0!==s?s:[];return this.messagesBuilder.getMessage("snkCrud.multipleEdition.editing",{COUNT:i.length})}return this.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=l(this.masterFormConfig,this.dataUnit,!0,this.customGuidesConfig);const e=this._masterFormMetadata.getAllSheets(),s=this.dataUnit.getSelectedRecord(),t=this.hasToDisableDetails(s),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&t&&(e.tooltip=this.getMessage("snkCrud.detail.tooltip.needSingleSelection"),e.disabled=!0),i.isCustom&&i.ctxProps&&Object.entries(i.ctxProps).forEach((([i,s])=>{void 0!==s&&(e[i]=s)})),r.push(e)})),this._guides=r,this._guideNavigator&&this._guideNavigator.updateItem(this._guides),i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}hasToDisableDetails(i){return!i||this.dataUnit.isNewRecord(i.__record__id__)||this.dataUnit.isMultipleEdition}isDetail(i){return null!=u.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const e=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(e).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===e.id?Object.assign(Object.assign(Object.assign({},i),e),void 0!==e.children?{}:{children:void 0}):i)))}static updateContentCard(i,e,s,t){return t.saveCardState(i,e,s)}static buildFixedForms(i){var e;const r=null===(e=i.formConfig)||void 0===e?void 0:e.cardsState;if(null!=r)return s(t,null,Array.from(r.entries()).filter((([e,s])=>(null==s?void 0:s.fixed)&&e!=i.selectedForm)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([e,t])=>{var r,n;const a=i.formMetadata.getSheet(e);if(null!=a)return s("snk-form-view",{levelPath:i.levelPath,label:a.label,name:e,fields:a.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==t?void 0:t.presentation),fixed:null==t?void 0:t.fixed,summaryFields:null===(n=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(e),fieldToFocus:i.fieldToFocus,key:e,onSnkRequestClearFieldToFocus:()=>{var e;return null===(e=i.onRequestClearFieldToFocus)||void 0===e?void 0:e.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps,entityPath:i.entityPath})})))}wrapDetail(i,e){if(0===i.length)return e;const t=i.pop(),r=u.getDetailName(t);return r?this.wrapDetail(i,s("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const s=i.map((i=>u.getDetailName(i)));return`${this.entityPath}/${s.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){if(!this.selectedGuide)return void this.snkShowGuide.emit(void 0);const i=this.selectedGuide.id;if(this.snkShowGuide.emit(i),this.isCustomGuide(i))return s("slot",{name:i});const e=i.split("::"),t=e.pop(),r=u.getDetailName(t);let n=i;return this.isDetailGuide(r,e)?this.buildDetailGuideContent(i,n,e,r):this.buildFormViewGuideContent(i)}buildFormViewGuideContent(i){var e,t,r,n;const a=this._masterFormMetadata.getSheet(i);if(!a)return;const d=null===(t=null===(e=this.masterFormConfig)||void 0===e?void 0:e.cardsState)||void 0===t?void 0:t.get(i);return s("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==d?void 0:d.fixed,summaryFields:null===(n=null===(r=this.masterFormConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(i),name:i,label:a.label,fields:a.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,key:i,onSnkRequestClearFieldToFocus:()=>this.clearFieldToFocusHandler(),customEditors:this._customEditors,fieldsProps:this._fieldsProps,fieldSearch:this._fieldSearch,entityPath:this.entityPath})}isDetailGuide(i,e){return i||e.length>0}buildDetailGuideContent(i,e,t,r){var n;let a,d;if(i.includes(m)){[e,a]=i.split(m);const s=(null===(n=this._breadcrumbItems)||void 0===n?void 0:n.length)||0;d=s>1?this._breadcrumbItems[s-2]:this.selectedGuide}else d=this.selectedGuide;return this.wrapDetail(t,s("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(t,r),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:r,selectedForm:a,branchGuide:d,guideItemPath:this._breadcrumbItems,key:`detail${e}`,canEdit:this.canEdit,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail),resourceID:this.resourceID,taskbarCustomContainerId:this.detailTaskbarCustomContainerId,customEditors:this._customEditors,customRenders:this._customRenders,presentationMode:this.presentationMode}))}isCustomGuide(i){var e;return null===(e=this.customGuidesConfig)||void 0===e?void 0:e.map((i=>i.id)).includes(i)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var e;i&&(this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>this.canClearGuideBadge(e,i.id)?Object.assign(Object.assign({},e),{badge:null}):e))])}canClearGuideBadge(i,e){return i.id===e||this.isIncludedInChildrenList(i,e)}isIncludedInChildrenList(i,e){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(e)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return v.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===v.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}noGuideSelected(){var i;return void 0===this.selectedGuide||"__main"===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}addFormLegacyConfigName(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}setMasterFormConfig(i){this.masterFormConfig=i}componentWillLoad(){if(null==this.resourceID)throw new Error(this.getMessage("snkCrud.errors.resourceIDNotProvided"));this._configManager=new c(this.configName,this.resourceID,this.setMasterFormConfig.bind(this),this.dataUnit),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(window.scrollTo(0,0),this._guideHasChanged=!1)}async dataUnitActionHandler(i){var e;switch(i.type){case a.EDITION_CANCELED:case a.DATA_SAVED:this.dataUnit.isMultipleEdition&&(this.exitViewer(),this.dataUnit.isMultipleEdition=!1);break;case a.FIELD_INVALIDATED:const s=this.getGuideName(null===(e=i.payload)||void 0===e?void 0:e.fieldName);await this.addErrorBadgeToGuide(s),await this.openGuideNavigator(s);break;case a.METADATA_LOADED:case a.MULTIPLE_EDITION_CHANGED:this.loadGuides(this.noGuideSelected())}}async addErrorBadgeToGuide(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>Object.assign(Object.assign({},e),{badge:this.getBadge(e,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,e){var s;return this.selectedGuide.id===e?null:e===i.id?"error":null!==(s=i.badge)&&void 0!==s?s:null}getGuideName(i){var e;for(const s of this._masterFormMetadata.getAllSheets()){const t=null===(e=s[1])||void 0===e?void 0:e.fields;for(const e of t)if(e.name===i)return s[0]}return""}getCustomGuidesConfig(){return this._currentDetail?[]:this.customGuidesConfig}getFieldsSearch(){if(null==this._fieldSearch||this._hasToCreateFieldSearch){this._hasToCreateFieldSearch=!1;const i={label:this.getMessage("snkSimpleCrud.findFields"),value:"findFields"};this._fieldSearch=o(i,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))}return this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(i).map((i=>({value:i.name,label:i.label}))))}changeGuideHandler(i){var e;null===(e=this._guideNavigator)||void 0===e||e.selectGuide(i)}onSelectField(i){if(null==i)return;this._fieldToGetFocus=i.value;const e=this.getGuideName(i.value);e!==this.selectedGuide.id&&this.changeGuideHandler(e)}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this)),this.initKeyboardManager(),this.getFieldsSearch()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async initKeyboardManager(){this._keyboardManager=new d({propagate:!1,element:this._element}),this._keyboardManager.bind(h,(async()=>{this._mainForm&&await this._mainForm.showSearchField()}),{description:this.getMessage("snkSimpleCrud.findFields"),element:this._element})}renderFormConfig(){if(null!=this._formEditorConfigManager)return s("snk-form-config",{ref:i=>this._container=i,tabindex:-1,dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null,customGuidesConfig:this.getCustomGuidesConfig()})}renderGuidesNavigator(i){var e;return s("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabIndex:-1},s("div",{class:"snk-guides-viewer__container"},i?s("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzSelectionChange:i=>this.updateSelectedGuideHandler(i.detail)}):s("div",null),s("div",{class:"snk-guides-viewer__detail-container"},f.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(e=this.selectedGuide)||void 0===e?void 0:e.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps,entityPath:this.entityPath}),this.getContent())),s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail),resourceID:this.resourceID,layoutFormConfig:!1,disableNumberingConfig:!0}))}render(){if(this.dataUnit&&this._configManager.isLoaded)return s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"guides-viewer-stack"},s("stack-item",null,this.renderGuidesNavigator(this._guides&&this._guides.length>1)),s("stack-item",null,this.renderFormConfig()))}get _element(){return r(this)}static get watchers(){return{dataUnit:["observeDataUnit"],_formEditorConfigManager:["observeFormConfigManager"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};var k;!function(i){i[i.GUIDES=0]="GUIDES",i[i.CONFIG=1]="CONFIG"}(k||(k={})),f.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-small:var(--space--2xs, 8px);--snk-guides-viewer__header--min-height:132px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;--snk-workspace--header-height:40px;display:block;outline:none}ez-guide-navigator.sc-snk-guides-viewer{--ez-guide-navigator--border-radius:var(--space--12, 12px)}snk-form-view.sc-snk-guides-viewer{width:100%}stack-item.snk-guides-viewer.sc-snk-guides-viewer{display:grid}stack-item.sc-snk-guides-viewer.sc-snk-guides-viewer{display:grid;min-height:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding:0 var(--snk-guides-viewer--space-small);padding-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column;max-height:calc(100vh - var(--snk-guides-viewer__header--min-height));overflow-y:auto}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-small);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__header-breadcrumb.sc-snk-guides-viewer{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-guides-viewer{width:75%}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:var(--snk-guides-viewer--space-small);height:calc(100vh - var(--snk-guides-viewer__header--min-height))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{f as S}
1
+ import{r as i,e,h as s,F as t,g as r}from"./p-2c9d0870.js";import{ObjectUtils as n,Action as a,KeyboardManager as d}from"@sankhyalabs/core";import{buildFieldSearch as o,SHORTCUT_SEARCH_FIELD as h}from"@sankhyalabs/ezui/dist/collection/utils";import{buildFormMetadata as l,FormMetadata as u}from"@sankhyalabs/ezui/dist/collection/utils/form";import{V as v}from"./p-9019a32f.js";import{S as c}from"./p-1cc4cf61.js";import{T as g}from"./p-3072136e.js";const m="__FORM:",f=class{constructor(s){i(this,s),this.snkShowGuide=e(this,"snkShowGuide",7),this.snkMasterFormConfigChange=e(this,"snkMasterFormConfigChange",7),this.formConfigVisibilityChanged=e(this,"formConfigVisibilityChanged",7),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this.formItemsReady=e(this,"formItemsReady",7),this._guideBuilders=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this.resourceID=void 0,this.detailTaskbarCustomContainerId=void 0,this.formLegacyConfigName=void 0,this.enableGridInsert=!1,this.ignoreReadOnlyFormFields=void 0,this.getCustomTitle=void 0,this.customGuidesConfig=[],this._hasToCreateFieldSearch=!0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0,this._fieldToGetFocus=void 0,this._customEditors=void 0,this._customRenders=void 0,this._fieldsProps={},this._mainForm=void 0}observeDataUnit(){this.loadGuides(!0)}async observeFormConfigManager(i){const e=!!i;await this._viewStack.show(e?k.CONFIG:k.GUIDES),this.formConfigVisibilityChanged.emit(e)}observeDataState(i,e){var s,t,r,a,d,o;const h=null!==(t=null===(s=null==i?void 0:i.selectionInfo)||void 0===s?void 0:s.recordIds)&&void 0!==t?t:null===(r=null==i?void 0:i.selectedRecord)||void 0===r?void 0:r.__record__id__,l=null!==(d=null===(a=null==e?void 0:e.selectionInfo)||void 0===a?void 0:a.recordIds)&&void 0!==d?d:null===(o=null==e?void 0:e.selectedRecord)||void 0===o?void 0:o.__record__id__;n.equals(h,l)||this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected()),this.snkMasterFormConfigChange.emit(this.masterFormConfig)}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}async addCustomEditor(i,e){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:e})}async addGridCustomRender(i,e){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:e})}async setFieldProp(i,e,s){const t={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[e]:s})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),t)}async setFocus(){var i;null===(i=this._container)||void 0===i||i.focus({preventScroll:!0})}async reloadGuides(){this.loadGuides(!1)}exitViewer(){!this.enableGridInsert&&this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===g.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){f.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){var e,s;if(this.dataUnit.isMultipleEdition){const i=null!==(s=null===(e=this.dataUnit.getSelectionInfo())||void 0===e?void 0:e.records)&&void 0!==s?s:[];return this.messagesBuilder.getMessage("snkCrud.multipleEdition.editing",{COUNT:i.length})}return this.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=l(this.masterFormConfig,this.dataUnit,!0,this.customGuidesConfig);const e=this._masterFormMetadata.getAllSheets(),s=this.dataUnit.getSelectedRecord(),t=this.hasToDisableDetails(s),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&t&&(e.tooltip=this.getMessage("snkCrud.detail.tooltip.needSingleSelection"),e.disabled=!0),i.isCustom&&i.ctxProps&&Object.entries(i.ctxProps).forEach((([i,s])=>{void 0!==s&&(e[i]=s)})),r.push(e)})),this._guides=r,this._guideNavigator&&this._guideNavigator.updateItem(this._guides),i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}hasToDisableDetails(i){return!i||this.dataUnit.isNewRecord(i.__record__id__)||this.dataUnit.isMultipleEdition}isDetail(i){return null!=u.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const e=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(e).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===e.id?Object.assign(Object.assign(Object.assign({},i),e),void 0!==e.children?{}:{children:void 0}):i)))}static updateContentCard(i,e,s,t){return t.saveCardState(i,e,s)}static buildFixedForms(i){var e;const r=null===(e=i.formConfig)||void 0===e?void 0:e.cardsState;if(null!=r)return s(t,null,Array.from(r.entries()).filter((([e,s])=>(null==s?void 0:s.fixed)&&e!=i.selectedForm)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([e,t])=>{var r,n;const a=i.formMetadata.getSheet(e);if(null!=a)return s("snk-form-view",{levelPath:i.levelPath,label:a.label,name:e,fields:a.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==t?void 0:t.presentation),fixed:null==t?void 0:t.fixed,summaryFields:null===(n=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(e),fieldToFocus:i.fieldToFocus,key:e,onSnkRequestClearFieldToFocus:()=>{var e;return null===(e=i.onRequestClearFieldToFocus)||void 0===e?void 0:e.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps,entityPath:i.entityPath})})))}wrapDetail(i,e){if(0===i.length)return e;const t=i.pop(),r=u.getDetailName(t);return r?this.wrapDetail(i,s("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const s=i.map((i=>u.getDetailName(i)));return`${this.entityPath}/${s.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){if(!this.selectedGuide)return void this.snkShowGuide.emit(void 0);const i=this.selectedGuide.id;if(this.snkShowGuide.emit(i),this.isCustomGuide(i))return s("slot",{name:i});const e=i.split("::"),t=e.pop(),r=u.getDetailName(t);let n=i;return this.isDetailGuide(r,e)?this.buildDetailGuideContent(i,n,e,r):this.buildFormViewGuideContent(i)}buildFormViewGuideContent(i){var e,t,r,n;const a=this._masterFormMetadata.getSheet(i);if(!a)return;const d=null===(t=null===(e=this.masterFormConfig)||void 0===e?void 0:e.cardsState)||void 0===t?void 0:t.get(i);return s("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==d?void 0:d.fixed,summaryFields:null===(n=null===(r=this.masterFormConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(i),name:i,label:a.label,fields:a.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,key:i,onSnkRequestClearFieldToFocus:()=>this.clearFieldToFocusHandler(),customEditors:this._customEditors,fieldsProps:this._fieldsProps,fieldSearch:this._fieldSearch,entityPath:this.entityPath})}isDetailGuide(i,e){return i||e.length>0}buildDetailGuideContent(i,e,t,r){var n;let a,d;if(i.includes(m)){[e,a]=i.split(m);const s=(null===(n=this._breadcrumbItems)||void 0===n?void 0:n.length)||0;d=s>1?this._breadcrumbItems[s-2]:this.selectedGuide}else d=this.selectedGuide;return this.wrapDetail(t,s("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(t,r),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:r,selectedForm:a,branchGuide:d,guideItemPath:this._breadcrumbItems,key:`detail${e}`,canEdit:this.canEdit,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail),resourceID:this.resourceID,taskbarCustomContainerId:this.detailTaskbarCustomContainerId,customEditors:this._customEditors,customRenders:this._customRenders,presentationMode:this.presentationMode}))}isCustomGuide(i){var e;return null===(e=this.customGuidesConfig)||void 0===e?void 0:e.map((i=>i.id)).includes(i)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var e;i&&(this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>this.canClearGuideBadge(e,i.id)?Object.assign(Object.assign({},e),{badge:null}):e))])}canClearGuideBadge(i,e){return i.id===e||this.isIncludedInChildrenList(i,e)}isIncludedInChildrenList(i,e){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(e)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return v.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===v.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}noGuideSelected(){var i;return void 0===this.selectedGuide||"__main"===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}addFormLegacyConfigName(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}setMasterFormConfig(i){this.masterFormConfig=i}componentWillLoad(){if(null==this.resourceID)throw new Error(this.getMessage("snkCrud.errors.resourceIDNotProvided"));this._configManager=new c(this.configName,this.resourceID,this.setMasterFormConfig.bind(this),this.dataUnit),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(window.scrollTo(0,0),this._guideHasChanged=!1)}async dataUnitActionHandler(i){var e;switch(i.type){case a.EDITION_CANCELED:case a.DATA_SAVED:this.dataUnit.isMultipleEdition&&(this.exitViewer(),this.dataUnit.isMultipleEdition=!1);break;case a.FIELD_INVALIDATED:const s=this.getGuideName(null===(e=i.payload)||void 0===e?void 0:e.fieldName);await this.addErrorBadgeToGuide(s),await this.openGuideNavigator(s);break;case a.METADATA_LOADED:case a.MULTIPLE_EDITION_CHANGED:this.loadGuides(this.noGuideSelected())}}async addErrorBadgeToGuide(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>Object.assign(Object.assign({},e),{badge:this.getBadge(e,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,e){var s;return this.selectedGuide.id===e?null:e===i.id?"error":null!==(s=i.badge)&&void 0!==s?s:null}getGuideName(i){var e;for(const s of this._masterFormMetadata.getAllSheets()){const t=null===(e=s[1])||void 0===e?void 0:e.fields;for(const e of t)if(e.name===i)return s[0]}return""}getCustomGuidesConfig(){return this._currentDetail?[]:this.customGuidesConfig}getFieldsSearch(){if(null==this._fieldSearch||this._hasToCreateFieldSearch){this._hasToCreateFieldSearch=!1;const i={label:this.getMessage("snkSimpleCrud.findFields"),value:"findFields"};this._fieldSearch=o(i,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))}return this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(i).map((i=>({value:i.name,label:i.label}))))}changeGuideHandler(i){var e;null===(e=this._guideNavigator)||void 0===e||e.selectGuide(i)}onSelectField(i){if(null==i)return;this._fieldToGetFocus=i.value;const e=this.getGuideName(i.value);e!==this.selectedGuide.id&&this.changeGuideHandler(e)}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this)),this.initKeyboardManager(),this.getFieldsSearch()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async initKeyboardManager(){this._keyboardManager=new d({propagate:!1,element:this._element}),this._keyboardManager.bind(h,(async()=>{this._mainForm&&await this._mainForm.showSearchField()}),{description:this.getMessage("snkSimpleCrud.findFields"),element:this._element})}renderFormConfig(){if(null!=this._formEditorConfigManager)return s("snk-form-config",{ref:i=>this._container=i,tabindex:-1,dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null,customGuidesConfig:this.getCustomGuidesConfig()})}renderGuidesNavigator(i){var e;return s("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabIndex:-1},s("div",{class:"snk-guides-viewer__container"},i?s("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzSelectionChange:i=>this.updateSelectedGuideHandler(i.detail)}):s("div",null),s("div",{class:"snk-guides-viewer__detail-container"},f.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(e=this.selectedGuide)||void 0===e?void 0:e.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps,entityPath:this.entityPath}),this.getContent())),s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail),resourceID:this.resourceID,layoutFormConfig:!1,disableNumberingConfig:!0}))}render(){if(this.dataUnit&&this._configManager.isLoaded)return s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"guides-viewer-stack"},s("stack-item",null,this.renderGuidesNavigator(this._guides&&this._guides.length>1)),s("stack-item",null,this.renderFormConfig()))}get _element(){return r(this)}static get watchers(){return{dataUnit:["observeDataUnit"],_formEditorConfigManager:["observeFormConfigManager"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};var k;!function(i){i[i.GUIDES=0]="GUIDES",i[i.CONFIG=1]="CONFIG"}(k||(k={})),f.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-small:var(--space--2xs, 8px);--snk-guides-viewer__header--min-height:132px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;--snk-workspace--header-height:40px;display:block;outline:none}ez-guide-navigator.sc-snk-guides-viewer{--ez-guide-navigator--border-radius:var(--space--12, 12px)}snk-form-view.sc-snk-guides-viewer{width:100%}stack-item.snk-guides-viewer.sc-snk-guides-viewer{display:grid}stack-item.sc-snk-guides-viewer.sc-snk-guides-viewer{display:grid;min-height:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding:0 var(--snk-guides-viewer--space-small);padding-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column;max-height:calc(100vh - var(--snk-guides-viewer__header--min-height));overflow-y:auto}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-small);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__header-breadcrumb.sc-snk-guides-viewer{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-guides-viewer{width:75%}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:var(--snk-guides-viewer--space-small);height:calc(100vh - var(--snk-guides-viewer__header--min-height))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{f as S}
@@ -0,0 +1 @@
1
+ import{r as t,e as i,h as s,f as e,F as n,g as a}from"./p-2c9d0870.js";import{ApplicationContext as o,DataType as r,Action as l,UserInterface as h,StringUtils as d,DataUnitLoaderUtils as c,DataUnit as u,ElementIDUtils as v,ObjectUtils as m,KeyboardManager as f}from"@sankhyalabs/core";import{D as p,S as g}from"./p-5d02c032.js";import{S as b}from"./p-b1bf9564.js";import{P as k}from"./p-0f3698af.js";import{P as _,D as y,I as w}from"./p-f076d742.js";import{F as C}from"./p-ff1990ad.js";import{F as z}from"./p-d88278f8.js";import{V as A,S as x}from"./p-9019a32f.js";import{A as S}from"./p-d5810110.js";import{T as O}from"./p-3072136e.js";import{A as F,F as I}from"./p-0dbd53d9.js";import{focusOnFieldSerch as E,SEARCH_FIELD_FULL_WIDTH as P,FormLayout as N,ApplicationUtils as T,CSSVarsUtils as L,buildFieldSearch as D}from"@sankhyalabs/ezui/dist/collection/utils";import{DataBinder as j}from"@sankhyalabs/ezui/dist/collection/utils/form";import{g as R,b as M,s as U,a as V,d as B}from"./p-af673291.js";import{P as K,a as G,D as $}from"./p-58709cf9.js";import{E as q}from"./p-1a68fb59.js";import{C as H,P as Q}from"./p-51e853f2.js";import{s as J}from"./p-a73b6b00.js";import{S as W,T as X,R as Y,a as Z,b as tt}from"./p-2c00b93d.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{S as it}from"./p-1cc4cf61.js";import{C as st}from"./p-e5a3711f.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-7dd49d15.js";import"./p-8f3f2306.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";class et{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:s,operation:e}){var n,a;const o="INSERT"==e,r=o?s:i;if(!o&&(null==s?void 0:s.DESCRICAO)&&(null==s?void 0:s.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(b.DESCRIPTION_CANNOT_BE_CHANGED);const l={anexo:{codata:o?null==s?void 0:s.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(a=null===(n=s.CAMINHO_ARQUIVO)||void 0===n?void 0:n[0])||void 0===a?void 0:a.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,e)=>{p.get().callServiceBroker("Attach.save",JSON.stringify(l)).then((e=>{var n;return i([Object.assign(Object.assign(Object.assign({},e),s),{__owner__dataunit__name__:null!==(n=this.dataUnitName)&&void 0!==n?n:t})])})).catch((t=>e(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const s=await p.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(s)}async getDownloadKey(t){var i,s,e;if("S"==t.EHARQUIVOREPOSITORIO){const e={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},n=await p.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(e));return Promise.resolve({chave:{valor:null===(s=null===(i=null==n?void 0:n.responseBody)||void 0===i?void 0:i.chave)||void 0===s?void 0:s.valor}})}const n={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},a=await p.get().callServiceBroker("Attach.view",JSON.stringify(n));return(null==a?void 0:a.chaveAnexo)?Promise.resolve({chave:{valor:null===(e=null==a?void 0:a.chaveAnexo)||void 0===e?void 0:e.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const nt="AnexoSistemaSP.salvar",at="AnexoSistemaSP.excluir",ot="AnexoSistemaSP.baixar";class rt{constructor(t,i){var s;this.entityName=t,this.dataUnitName=i,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(b.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(b.ANY_LINK_OR_FILE_FILLED);if(!this._registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(s=window.workspace)||void 0===s?void 0:s.resourceID)}set registerKey(t){this._registerKey=t}async save(t){var i,s;let{updatingFields:e}=t;e=Object.assign(Object.assign({},e),{NOMEARQUIVO:null===(i=e.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(e);const t=e.LINK?null:e.NOMEARQUIVO,i={serviceName:nt,requestBody:{params:{resourceID:this.resourceID,description:e.DESCRICAO,fileSelect:t?1:0,keySession:null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.fileNameTmp,nameAttach:null==t?void 0:t.name,link:e.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:e.TIPOACESSO,typeApres:e.TIPOAPRES}}},n=await p.get().callServiceBroker(nt,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},n),e),{ARQUIVOOULINK:e.LINK?e.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,s,e;let{updatingFields:n,record:a}=t;const o=t=>void 0!==n[t]?n[t]:a[t],r=o("NOMEARQUIVO"),l=null===(s=null===(i=n.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===s?void 0:s.downloadURL;n=Object.assign(Object.assign({},n),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:a.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const h=n.LINK?null:n.NOMEARQUIVO;try{this.validateFields(n);const t={serviceName:nt,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==a?void 0:a.NUATTACH,description:n.DESCRICAO,fileSelect:l?1:0,keySession:null===(e=null==h?void 0:h.properties)||void 0===e?void 0:e.fileNameTmp,keyAttach:n.CHAVEARQUIVO,nameAttach:null==h?void 0:h.name,link:n.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:n.TIPOACESSO,typeApres:n.TIPOAPRES}}},i=await p.get().callServiceBroker(nt,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),n),{ARQUIVOOULINK:n.LINK?n.LINK:null==h?void 0:h.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const s=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},e={serviceName:at,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{p.get().callServiceBroker(at,JSON.stringify(e)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const s=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},e={serviceName:ot,requestBody:{paramsDown:{nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{p.get().callServiceBroker(ot,JSON.stringify(e)).then((i=>t(i))).catch((t=>i(t)))}))}}class lt{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=o.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,s){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,e)=>this.saveLoader(e,i).then((t=>(t.length&&s(),t))),t.removeLoader=(t,e)=>this.removeLoader(t,e,i).then((t=>(t.length&&s(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}dataLoader(t,i){return new Promise((s=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));s(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((s=>{var e;const n=Array.isArray(t)?t[0]:{};((null===(e=null==n?void 0:n.record)||void 0===e?void 0:e.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(n).then((t=>{s(t)})).catch((t=>t.message===b.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),s([])):t.message===b.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),s([])):t.message?(this._application.error(t.title||t.name,t.message),s([])):void s([])))}))}removeLoader(t,i,s){return new Promise((e=>{const{records:n}=t.getSelectionInfo(),a=n[0];s.delete(a).then((()=>(_.removeRecords(t,[a]),e(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:r.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,s){return new Promise((e=>i.type===l.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(s.goToView(A.GRID),e(i)):e(void 0))):e(i):i.type===l.DATA_SAVED?(t.loadData(),e(i)):void e(i)))}}let ht;const dt=t=>(ht||(ht=new g),ht.getMessage(t)),ct={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:dt("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:dt("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},ut={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:dt("snkAttach.attachMetadata.lblCode"),dataType:r.TEXT},{name:"DESCRICAO",label:dt("snkAttach.attachMetadata.lblDescription"),dataType:r.TEXT,readOnly:!1},{name:"ARQUIVO",label:dt("snkAttach.attachMetadata.lblFileOrLink"),dataType:r.TEXT},{name:"USUARIO",label:dt("snkAttach.attachMetadata.lblUser"),dataType:r.TEXT},{name:"DTALTER",label:dt("snkAttach.attachMetadata.lblDate"),dataType:r.TEXT},{name:"CAMINHO_ARQUIVO",label:dt("snkAttach.attachMetadata.lblFileUpload"),dataType:r.OBJECT,userInterface:h.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:dt("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class vt{constructor(t){this.getMessage=t,this._records=[],this._application=o.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,s){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,e)=>this.saveLoader(e,i).then((t=>(t.length&&s(),t))),t.removeLoader=(t,e)=>this.removeLoader(t,e,i).then((t=>(t.length&&s(),t)))}metadataLoader(t){return Promise.resolve(ut)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},s=await this._application.getDataFetcher(),{anexos:{anexo:e=[]}}=await s.callServiceBroker("Attach.load",JSON.stringify(t)),n=[];e.forEach((t=>{n.push(Object.assign({__record__id__:d.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=n}return c.buildLoadDataResponse(this._records,t,i)}saveLoader(t,i){return new Promise((s=>{const e=Array.isArray(t)?t[0]:{};i.save(e).then(s).catch((t=>t.message===b.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),s([])):t.message===b.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),s([])):t.message===b.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),s([])):t.message?(this._application.error(t.title||t.name,t.message),s([])):void s([])))}))}removeLoader(t,i,s){return new Promise((e=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(S.REMOVE).then((async n=>{n&&(await s.delete(t),e(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,s){return new Promise((e=>{var n,a,o,r,h,d;switch(i.type){case l.EDITION_CANCELED:return t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(s.goToView(A.GRID),e(i)):e(void 0))):e(i);case l.DATA_SAVED:return t.loadData(void 0,void 0,!1,null===(o=null===(a=null===(n=null==i?void 0:i.payload)||void 0===n?void 0:n.records)||void 0===a?void 0:a[0])||void 0===o?void 0:o.REGISTER_KEY),e(i);case l.RECORDS_REMOVED:return t.loadData(void 0,void 0,!1,null===(d=null===(h=null===(r=null==i?void 0:i.payload)||void 0===r?void 0:r.cachedRecords)||void 0===h?void 0:h[0])||void 0===d?void 0:d.CODATA),e(i)}e(i)}))}}let mt;const ft=t=>{var i;if(!mt){const t=o.getContextValue("__SNK__APPLICATION__");mt=null==t?void 0:t.messagesBuilder}return null===(i=null==mt?void 0:mt.getMessage)||void 0===i?void 0:i.call(mt,t,null)},pt={DOWNLOAD:{hint:ft("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:ft("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},gt=()=>{const t=[O.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,s)=>{const e=s.indexOf(O.REFRESH);if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return s.reverse();-1!==e&&s.splice(e,1);const{selectedRecord:n}=i||{},a=(null==n?void 0:n.LINK)?pt.LINK:pt.DOWNLOAD;s.splice(s.indexOf(O.DIVIDER)+1,0,O.REMOVE,a,O.DIVIDER);const o=[O.CLONE,O.DATA_EXPORTER],r=Array.from(new Set(s.filter((t=>!o.includes(t)))));return r.splice(r.indexOf(a)+1,0,O.DIVIDER),r},isEnabled:(i,s,e)=>{const n=void 0!==(null==s?void 0:s.selectedRecord);return!(t.includes(e)&&!n)}}},bt={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},kt=class{constructor(s){t(this,s),this.ezClosePopup=i(this,"ezClosePopup",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.close()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.close();this.validateAnexoSistema()&&this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.close()}))},this._isOpen=!1,this.gridLegacyConfigName=void 0,this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0,this._appResourceID=void 0}async open(){this._isOpen=!0,this._currentDataUnit||await this.initAttach(),this._refPopup&&(this._refPopup.opened=!0),this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async close(){this._isOpen=!1,this._refPopup&&(this._refPopup.opened=!1)}async registerKeyWatcher(t,i){var s;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&(this._currentFetcher instanceof rt&&(this._currentFetcher.registerKey=t),await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadData()))}getAnexoSistemaFetcherInstance(){var t;const i=new rt(this.entityName,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name);return i.registerKey=this.registerKey,i}async initAttach(){var t,i,s,e,n;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=this.getAnexoSistemaFetcherInstance(),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData());if("Attach"===this.fetcherType&&(null===(s=this.registerKey)||void 0===s?void 0:s.split("_").length)>1)return;await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadMetadata()),await(null===(n=this._currentDataUnit)||void 0===n?void 0:n.loadData(void 0,void 0,!0,this.registerKey))}}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error(this.getMessage("snkAttach.alertValidation.noRecordSelected.message"));t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var s;let e=!1;(null===(s=null==t?void 0:t.ARQUIVO)||void 0===s?void 0:s.endsWith(".pdf"))||(e=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${e?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(A.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i;let s;this._currentDataUnit=(new y).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=this.entityName?{form:null==bt?void 0:bt.form}:Object.assign({},bt),s={grid:null==bt?void 0:bt.grid}),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData()),this.disableEditFieldsNotInForm(s)}async loadAttach(){var t,i;let s;this._currentFetcher=new et,this._currentDataUnit=new u(w.IN_MEMORY_DATA_UNIT_NAME),this._currentDataUnit.pageSize=150,this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===l.METADATA_LOADED&&(this.crudConfig=this.entityName?{form:null==ct?void 0:ct.form}:Object.assign({},ct),s={grid:null==ct?void 0:ct.grid},null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=this.entityName?{form:null==ct?void 0:ct.form}:Object.assign({},ct),s={grid:null==ct?void 0:ct.grid},await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm(s))}initDataUnitLoaders(){var t,i;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnitBuilder=new lt(this.entityName,this.getMessage.bind(this)),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new et,this._currentDataUnitBuilder=new vt(this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(t){var i,s,e,n,a;const o=(null===(s=null===(i=this._crudElement)||void 0===i?void 0:i.gridConfig)||void 0===s?void 0:s.columns)||(null===(e=null==t?void 0:t.grid)||void 0===e?void 0:e.columns)||(null===(a=null===(n=this.crudConfig)||void 0===n?void 0:n.grid)||void 0===a?void 0:a.columns);this.getGridLegacyConfigName()&&this._currentDataUnit.disableField("ARQUIVOOULINK"),null==o||o.forEach((t=>{var i,s;const e=t.name;(null===(s=null===(i=this.crudConfig)||void 0===i?void 0:i.form)||void 0===s?void 0:s.fields.some((t=>(null==t?void 0:t.name)===e)))||this._currentDataUnit.disableField(e)}))}validateAnexoSistema(){var t;if(this._currentFetcher instanceof rt)try{let i=this._currentDataUnit.getSelectedRecord();i=Object.assign(Object.assign({},i),{NOMEARQUIVO:null===(t=i.NOMEARQUIVO)||void 0===t?void 0:t[0]}),this._currentFetcher.validateFields(i)}catch(t){if(t.message===b.LINK_AND_FILE_AT_THE_SAME_TIME)return this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),!1;if(t.message===b.ANY_LINK_OR_FILE_FILLED)return this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),!1}return!0}async componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__"),this._application&&(this._appResourceID=await this._application.getResourceID()),await this.initAttach()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}isScreenVariation(){var t;return!!(null===(t=this._appResourceID)||void 0===t?void 0:t.includes("__"))}getGridLegacyConfigName(){if(!this.isScreenVariation())return this.gridLegacyConfigName?this.gridLegacyConfigName:this.entityName?"GrdCfgHtml5:grdcfg.dynaform.anexo."+this.entityName:this.entityName}render(){var t,i;return s("ez-popup",{ref:t=>this._refPopup=t,size:"x-large",ezTitle:this.getMessage("snkAttach.title"),useHeader:!1,autoClose:!1,onEzClosePopup:()=>this.close()},this._isOpen&&this._currentDataUnit&&s("main",{class:"snk-attach__main"},s("header",{class:"snk-attach__header"},s("section",null,s("ez-button",{class:"ez-padding-right--medium",title:this.getMessage("snkSimpleBar.backTitle"),mode:"icon",iconName:"arrow_back",size:"medium",onClick:()=>this.handleBack()}),s("div",{class:"snk-attach__file-info"},s("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold"},this.getMessage("snkAttach.title")),s("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))),s("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})),s("div",{class:"snk-attach__crud-section"},s("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this._currentDataUnit,taskbarManager:gt(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick,messagesBuilder:this.messagesBuilder,onDataStateChange:this.handleOnDataStateChange.bind(this),multipleSelection:!0,configName:this.isScreenVariation()?void 0:this.entityName?"AnexoSistema_"+this.entityName:void 0,ignoreReadOnlyFormFields:!!this.entityName,gridLegacyConfigName:this.getGridLegacyConfigName(),outlineMode:!0}))))}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};kt.style=".snk-attach__header.sc-snk-attach{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--space--6, 6px)}.snk-attach__header.sc-snk-attach>section.sc-snk-attach{display:flex;align-items:center}.snk-attach__file-info.sc-snk-attach{display:flex;flex-direction:column;justify-content:center;gap:var(--space--8, 8px)}.snk-attach__main.sc-snk-attach{display:flex;flex-direction:column;height:100%}.ez-box__container.sc-snk-attach{height:100%}.snk-attach__crud-section.sc-snk-attach{padding:1px;display:flex;flex-direction:column;height:100%;width:100%}";const _t=class{constructor(s){t(this,s),this.actionSelected=i(this,"actionSelected",7),this.OFFSET_HEIGHT=5,this.getMessage=void 0,this.hasDefaultFilter=!1,this._opened=!1}repositionDropDown(){if(!this._refIcon||!this._refDropdown)return;const t=this._refIcon.getBoundingClientRect(),i=this._refDropdown.getBoundingClientRect();this._refDropdown.style.top=t.y+t.height+this.OFFSET_HEIGHT+"px",this._refDropdown.style.left=t.x+t.width/2-i.width+"px"}toggleDropdown(){this._opened=!this._opened}closeDropdown(t){const i=null==t?void 0:t.target;i&&(i.closest("#dropdown-parent-demo")||(this._opened=!1))}buildItems(){return[{id:F.EDIT,label:this.getMessage("defaultFilter.edit")},{id:F.REMOVE,label:this.getMessage("defaultFilter.remove")}]}onValueSelected({detail:t}){this._opened=!1,this.actionSelected.emit(t.id)}openCreateNewFilter(){this.actionSelected.emit(F.CREATE)}componentDidRender(){this.repositionDropDown()}componentWillLoad(){this._items=this.buildItems(),document.removeEventListener("scroll",this.repositionDropDown.bind(this)),document.addEventListener("scroll",this.repositionDropDown.bind(this))}render(){return this.hasDefaultFilter?s(e,null,s("button",{class:"default_container",onClick:this.toggleDropdown.bind(this)},s("span",null,this.getMessage("defaultFilter.title")),s("ez-icon",{ref:t=>this._refIcon=t,iconName:"dots-vertical"})),this._opened&&s("ez-dropdown",{ref:t=>this._refDropdown=t,items:this._items,onEzClick:this.onValueSelected.bind(this),onEzOutsideClick:this.closeDropdown.bind(this)})):s(e,null,s("button",{class:"default_container new_filter",onClick:this.openCreateNewFilter.bind(this)},s("span",null,this.getMessage("defaultFilter.create"))))}};_t.style=".sc-snk-default-filter-h{display:flex;justify-content:flex-end}.default_container.sc-snk-default-filter{border:none;background:none;display:flex;align-items:center;gap:var(--space--3xs, 4px);font-family:var(--font-pattern);color:var(--title--primary, #2b3a54);font-size:var(--text--medium, 14px);padding:0;outline:none}.default_container.sc-snk-default-filter ez-icon.sc-snk-default-filter{cursor:pointer}.default_container.sc-snk-default-filter ez-icon.sc-snk-default-filter:hover{color:var(--color--primary-600)}.new_filter.sc-snk-default-filter{cursor:pointer;margin:0 var(--space--3xs, 4px)}.new_filter.sc-snk-default-filter:hover{color:var(--color--primary-600)}";const yt=class{constructor(e){t(this,e),this.snkContentCardChanged=i(this,"snkContentCardChanged",7),this.snkRequestClearFieldToFocus=i(this,"snkRequestClearFieldToFocus",7),this._customEditors=new Map,this._fieldProps=new Map,this.dataUnitObserver=async t=>{var i;if(t.type===l.RECORDS_COPIED){const s=this.buildSourceRecordPK(t);null===(i=this.getImageField())||void 0===i||i.forEach((async t=>{var i;null===(i=this.dataUnit)||void 0===i||i.setFieldValue(t.name,JSON.stringify(s))}))}},this.customUiBuilders=new Map([[h.IMAGE,t=>{var{name:i}=t,e=function(t,i){var s={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0&&(s[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(e=Object.getOwnPropertySymbols(t);n<e.length;n++)i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n])&&(s[e[n]]=t[e[n]])}return s}(t,["name"]);return s("snk-image-input",Object.assign({dataUnit:this.dataUnit,maxSize:1/0,fieldName:i,entityName:this.entityPath},e))}]]),this._singleColumn=!1,this._currentFormLayout=void 0,this.fieldSearch=void 0,this.label=void 0,this.name=void 0,this.fields=void 0,this.formMetadata=void 0,this.dataUnit=void 0,this.recordsValidator=void 0,this.fieldToFocus=void 0,this.customEditors=void 0,this.fieldsProps=void 0,this.entityPath=void 0}async showUp(){var t,i;this._formView&&(null===(i=(t=this._formView).showUp)||void 0===i||i.call(t))}async addCustomEditor(t,i,s){var e,n;if(this._formView)return void(null===(n=(e=this._formView).addCustomEditor)||void 0===n||n.call(e,t,i,s));const a=new Map(this._customEditors);a.set(t,{customEditor:i,detailContext:null!=s?s:""}),this._customEditors=a}async setFieldProp(t,i,s){const e=this._fieldProps.get(t)||[];this._fieldProps.set(t,[...e,{propName:i,value:s}])}async showSearchField(){if(!this._headerContainer||!this._ezPopoverFieldColumn)return;const t=this._headerContainer.getBoundingClientRect();this.fieldSearch&&(await E(this.fieldSearch),this._ezPopoverFieldColumn.showUnder(this._headerContainer,{horizontalGap:t.width-P,verticalGap:-1*t.height}))}observePropsCustomEditor(t){for(const i in t)this.addCustomEditor(i,t[i])}async observeFieldsProps(t){for(const i in t){const s=t[i],e=Object.keys(s);for(const t of e)await this.setFieldProp(i,t,s[t])}}async observeDataUnit(t,i){t!==i&&t&&t.subscribe(this.dataUnitObserver)}bindFields(t){var i;null==this._dataBinder&&null!=this.dataUnit&&(this._dataBinder=new j(this.dataUnit)),this._dataBinder&&this.dataUnit&&this.formMetadata&&this._dataBinder.bind(t,null===(i=this.dataUnit)||void 0===i?void 0:i.dataUnitId,this.formMetadata,this.recordsValidator)}disconnectedCallback(){null!=this._dataBinder&&this._dataBinder.onDisconnectedCallback(),this.dataUnit&&this.dataUnit.unsubscribe(this.dataUnitObserver)}componentDidLoad(){this.customEditors&&this.observePropsCustomEditor(this.customEditors),this.fieldsProps&&this.observeFieldsProps(this.fieldsProps),this.initLayoutFormConfig()}async initLayoutFormConfig(){const t=o.getContextValue("__SNK__APPLICATION__"),i=await(null==t?void 0:t.getLayoutFormConfig());i&&(this.setSingleColumn(i),this.registerNotifyListeners(i))}setSingleColumn(t){this._singleColumn=(null==t?void 0:t.config)===N.CASCADE||(null==t?void 0:t.config)===N.CLASSIC_CASCADE,this._currentFormLayout=null==t?void 0:t.config}registerNotifyListeners(t){var i;t&&(null===(i=t.onConfigChange)||void 0===i||i.call(t,(t=>{this._singleColumn=t===N.CASCADE||t===N.CLASSIC_CASCADE,this._currentFormLayout=t})))}componentDidRender(){var t;this.setCustomEditors(),this.setFieldProps(),this.fieldToFocus&&(null===(t=this.fields)||void 0===t?void 0:t.some((t=>t.name===this.fieldToFocus)))&&requestAnimationFrame((()=>{var t,i;null===(t=this._dataBinder)||void 0===t||t.setFocus(this.fieldToFocus),null===(i=this.snkRequestClearFieldToFocus)||void 0===i||i.emit()}))}setCustomEditors(){var t,i;if(this._formView)for(const[s,e]of this._customEditors)null===(i=(t=this._formView).addCustomEditor)||void 0===i||i.call(t,s,e.customEditor,e.detailContext),this._customEditors.delete(s)}setFieldProps(){if(this._formView)for(const[t,i]of this._fieldProps)i.forEach((i=>{var s,e;null===(e=(s=this._formView).setFieldProp)||void 0===e||e.call(s,t,i.propName,i.value),this._fieldProps.delete(t)}))}buildSourceRecordPK(t){var i,s,e;const n=(null===(i=t.payload)||void 0===i?void 0:i[0])||{},a=JSON.parse(atob(n.__record__source__id__||""));if(delete a.__DATA_UNIT_NAME__,!this.dataUnit)return{};const o=null!==(s=R(this.dataUnit))&&void 0!==s?s:{},r=Object.keys(o),l={};for(const t of r)l[t]=null===(e=a[t])||void 0===e?void 0:e.value;return l}getImageField(){var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.metadata.fields.filter((t=>t.userInterface===h.IMAGE))}render(){return s(e,null,s("slot",null),s("ez-form-view",{ref:t=>this._formView=t,fields:this.fields,onEzContentReady:t=>this.bindFields(t.detail),singleColumn:this._singleColumn,customUiBuilders:this.customUiBuilders,formLayout:this._currentFormLayout}),this.fieldSearch&&s("ez-popover",{ref:t=>this._ezPopoverFieldColumn=t,overlayType:"none"},this.fieldSearch))}static get watchers(){return{customEditors:["observePropsCustomEditor"],fieldsProps:["observeFieldsProps"],dataUnit:["observeDataUnit"]}}};yt.style=".sc-snk-dynaform-form-view-h{display:flex;flex-direction:column;width:100%;flex-wrap:wrap;background-color:var(--background--xlight);padding:var(--space--12, 12px);border-radius:var(--border--radius-medium);border:1px solid var(--color--petroleum-100, #C8CCD3);--ez-form-card-summary-field-content-weight:700}ez-form-view.sc-snk-dynaform-form-view{padding:var(--space--6 ,6px) 0;--ez-form-view__item--padding:0}.level-path.sc-snk-dynaform-form-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.summary-wrapper.sc-snk-dynaform-form-view{display:flex;overflow:hidden}.summary-header.sc-snk-dynaform-form-view{border-bottom:1px solid var(--color--strokes);margin-bottom:var(--space--medium);padding-bottom:var(--space--medium)}.summary-container.sc-snk-dynaform-form-view{display:flex;flex-direction:column}.summary-container.sc-snk-dynaform-form-view{padding-right:calc(var(--space--extra-large) / 1.5)}.summary-field.sc-snk-dynaform-form-view{min-width:30px;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.summary-field__title.sc-snk-dynaform-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-dynaform-form-view{color:var(--title--primary, #2b3a54);font-size:var(--text--large);font-weight:var(--ez-form-card-summary-field-content-weight)}";const wt=class{constructor(s){t(this,s),this.ezExpressionChange=i(this,"ezExpressionChange",7),this.filterAssistent=void 0,this.application=void 0}getMessage(t,i){return this.application.messagesBuilder.getMessage(t,i)}render(){var t;return s(e,null,s("span",{class:"ez-title ez-title--small ez-padding-bottom--small snk-filter-advanced-mode__title"},this.getMessage("snkPersonalizedFilter.info.applyExpression")),s("ez-text-area",{rows:9,label:this.getMessage("snkPersonalizedFilter.info.labelExpression"),value:null===(t=this.filterAssistent)||void 0===t?void 0:t.expression,onEzChange:t=>this.ezExpressionChange.emit(t.detail)}))}};wt.style=".sc-snk-filter-advanced-mode-h{display:block;--snk-personalized-filter--title--color:var(--title--primary, #2B3A54)}.snk-filter-advanced-mode__title.sc-snk-filter-advanced-mode{color:var(--snk-personalized-filter--title--color)}";const Ct=class{constructor(s){t(this,s),this.ezChangeFilter=i(this,"ezChangeFilter",7),this.filterAssistent=void 0,this.messagesBuilder=void 0,this.filterId=void 0,this.entityUri=void 0,this.application=void 0,this.isDefaultFilter=!1}getMessage(t,i){return this.application.messagesBuilder.getMessage(t,i)}async handleFilterGroupChange(){const t=await this._mainExpressionGroup.getExpressionGroup();this.filterAssistent=Object.assign(Object.assign({},this.filterAssistent),{assistent:t}),this.filterAssistent.parameters=K.buildVariableParameters(this.filterAssistent.assistent),this.filterAssistent.expression=K.buildGroupExpression(this.filterAssistent.assistent),this.ezChangeFilter.emit(this.filterAssistent)}render(){var t,i;return s(e,null,s("div",{class:"ez-padding-top--small snk-personalized-filter__group"},s("snk-expression-group",{ref:t=>this._mainExpressionGroup=t,group:null===(t=this.filterAssistent)||void 0===t?void 0:t.assistent,messagesBuilder:this.messagesBuilder,onEzFilterGroupChange:this.handleFilterGroupChange.bind(this),filterId:this.filterId,entityURI:this.entityUri,isDefaultFilter:this.isDefaultFilter})),s("div",{class:"ez-margin-top--auto"},s("div",{class:"snk-personalized-filter__expression-input--line"}),s("ez-collapsible-box",{label:this.getMessage("snkPersonalizedFilter.info.titleCollapsible"),headerSize:"medium",value:!0},s("div",{class:"ez-box"},s("div",{class:"ez-box__container--external"},s("div",{class:"ez-box__container--internal"},s("span",{class:"ez-box__container--title"},this.getMessage("snkPersonalizedFilter.info.labelExpression")),s("span",{class:"ez-box__container--expression"},null===(i=this.filterAssistent)||void 0===i?void 0:i.expression)))))))}};Ct.style=".sc-snk-filter-assistent-mode-h{display:flex;flex-direction:column;height:100%;--text-area--font-family:var(--font-pattern, Arial);--text-area__label--floating--top:var(--space--small, 6px);--snk-filter-assistent-mode__container--border-radius:var(--border--radius-medium, 12px);--snk-filter-assistent-mode__container--background:var(--background--medium, #f0f3f7);--snk-filter-assistent-mode__container--margin:var(--space--small, 6px) var(--space--medium, 12px)}.ez-box__container--external.sc-snk-filter-assistent-mode{height:100px;width:100%;overflow-y:auto;background-color:var(--snk-filter-assistent-mode__container--background);border-radius:var(--snk-filter-assistent-mode__container--border-radius)}.ez-box__container--internal.sc-snk-filter-assistent-mode{margin:var(--snk-filter-assistent-mode__container--margin)}.ez-box__container--title.sc-snk-filter-assistent-mode{display:block;user-select:none;font-family:var(--text-area--font-family);font-size:var(--text--extra-small);color:var(--title--primary);top:var(--text-area__label--floating--top)}.ez-box__container--expression.sc-snk-filter-assistent-mode{display:block;font-family:var(--text-area--font-family);font-size:var(--text--medium);color:var(--title--primary);top:var(--text-area__label--floating--top)}.snk-personalized-filter__expression-input--line.sc-snk-filter-assistent-mode{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}";const zt=class{constructor(s){t(this,s),this.filterChange=i(this,"filterChange",7),this.config=void 0,this.getMessage=void 0,this.showHardFixed=!0,this.removalBlocked=!1}async setFocusField(){var t,i,s,e;this._editor&&(this._editor.setFocus?null===(i=null===(t=this._editor)||void 0===t?void 0:t.setFocus)||void 0===i||i.call(t):this._editor.focus&&(null===(e=null===(s=this._editor)||void 0===s?void 0:s.focus)||void 0===e||e.call(s)))}async clearValue(){this._editor&&this._editor.clearValue&&await this._editor.clearValue()}observeConfig(t){var i,s;this._editor&&(this._editor.config=t),null===(s=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===s||s.call(i),this._customElementObject=this.getContentEditor()}componentDidLoad(){if(this._element){v.addIDInfo(this._element);const t=this._element.getAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case C.BINARY_SELECT:return{tag:"snk-filter-binary-select"};case C.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case C.PERIOD:return{tag:"snk-filter-period"};case C.SEARCH:return{tag:"snk-filter-search"};case C.NUMBER:return{tag:"snk-filter-number"};case C.PERSONALIZED:return{tag:"snk-personalized-filter-editor",props:{presentationMode:q.CHIP,onValueChanged:t=>this.handleValueChanged(t)}};case C.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}};case C.MULTI_LIST:return{tag:"snk-entity-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}}}return{tag:"snk-filter-text"}}handleValueChanged({detail:t}){const i=(null==t?void 0:t.items)||this.config.groupedItems;this.config=Object.assign(Object.assign({},this.config),{groupedItems:i,visible:(i||[]).filter((t=>t.visible)).length>0})}removeItem(){const t=this.config.type===C.MULTI_LIST&&Array.isArray(this.config.value)?this.config.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0,i=Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:t});null!=i.groupedItems&&(i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})))),this.changeConfig(i)}removeItemFromGroup(t){return Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})}getPopUpHeaderButtons(){return s(n,null,!this.removalBlocked&&!this.config.removalBlocked&&this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),this.showHardFixed&&!this.config.hardFixed&&this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed})))))}buildIcon(t,i,e){return s("button",{onClick:()=>e(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button",ref:i=>i&&this.buildIdButton(i,t)},s("ez-icon",Object.assign({title:t,iconName:i},{[v.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${v.getInternalIDInfo(`_${t}`)}`})))}buildIdButton(t,i){if(!t)return;const s={id:i};t.removeAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME),v.addIDInfoIfNotExists(t,"button",s)}clearBinarySelectValues(){var t;const i=this._editor||{};null===(t=i.resetValues)||void 0===t||t.call(i),this.config=m.copy(this.originalConfig),this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}apply(){if(!K.validateVariableValues(this.config,this._editor.value))return T.alert(this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.title"),this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.message"));const t=void 0!==this._editor.value?this._editor.value:this.config.value;this.changeConfig(Object.assign(Object.assign({},this.config),{visible:this.isVisible(),value:t}))}isVisible(){return!(this.config.groupedItems&&this.config.groupedItems.length>0)||this.config.groupedItems.filter((t=>t.visible)).length>0}clear(){var t;if(this.config.type!==C.BINARY_SELECT){if(C.MULTI_LIST===this.config.type){const i=m.copy(this.config);return null===(t=i.value)||void 0===t||t.forEach((t=>!!t&&(t.check=!1))),void(this.config=m.copy(i))}this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}else this.clearBinarySelectValues()}filterCanBeCleared(){return this.config.type!==C.PERSONALIZED}onKeyDonwListener(t){"Enter"===t.key&&this.apply()}buildRightSlot(t){return s("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,s;if(this.config){const e=m.copy(this.config),n=null===(i=e.value)||void 0===i?void 0:i.findIndex((i=>(null==i?void 0:i.id)===t.id));null===(s=e.value)||void 0===s||s.splice(n,1),this.config=m.copy(e)}}componentWillLoad(){this.originalConfig=m.copy(this.config),this._customElementObject=this.getContentEditor()}render(){const{tag:t,props:i}=this._customElementObject;return s(e,null,s("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},s("div",{class:"ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header"},this.config.detailTitle),this.getPopUpHeaderButtons()),s(t,Object.assign({maxHeightList:"240px",ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor,getMessage:this.getMessage,rightListSlotBuilder:t=>this.buildRightSlot(t)},i)),s("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),s("div",{class:"ez-col ez-col--sd-12 ez-align--right"},this.filterCanBeCleared()&&s("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),s("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return a(this)}static get watchers(){return{config:["observeConfig"]}}},At=class{constructor(s){t(this,s),this.filterChange=i(this,"filterChange",7),this.editPersonalizedFilter=i(this,"editPersonalizedFilter",7),this.addPersonalizedFilter=i(this,"addPersonalizedFilter",7),this.filterItem=void 0,this.configName=void 0,this.resourceID=void 0}getContentEditorConfig(){const t={presentationMode:q.MODAL};switch(this.filterItem.type){case C.BINARY_SELECT:return{tag:"snk-filter-binary-select",props:t};case C.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case C.PERIOD:return{tag:"snk-filter-period",props:t};case C.SEARCH:return{tag:"snk-filter-search"};case C.NUMBER:return{tag:"snk-filter-number",props:t};case C.PERSONALIZED:return this.buildSnkFilterPersonalizedProps();case C.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:t};case C.MULTI_LIST:return{tag:"snk-entity-list",props:{maxHeightList:"640px",rightListSlotBuilder:t=>this.buildRightSlot(t)}}}return{tag:"snk-filter-text"}}buildSnkFilterPersonalizedProps(){return{tag:"snk-personalized-filter-editor",props:{onEditFilter:t=>this.editPersonalizedFilter.emit(t.detail),onAddFilter:()=>this.addPersonalizedFilter.emit()}}}isVisible(t){return!!this.filterItem.visible||void 0!==t}updateFilterValue(t){var i,s;const e=void 0!==(null==t?void 0:t.value)?t.value:t;this.filterItem=Object.assign(Object.assign({},this.filterItem),null!=this.filterItem.groupedItems?{visible:e>0,value:e,groupedItems:t.items}:{value:this.filterItem.type===(C.SEARCH||C.CHECK_BOX_LIST)?t:e,visible:this.isVisible(e)}),this._editor&&(this._editor.config=this.filterItem),null===(s=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===s||s.call(i),this.filterChange.emit(this.filterItem)}handleDeleteFilter(t,i){i===C.PERSONALIZED&&H.removePersonalizedFilter(t,this.resourceID,this.configName)}componentDidLoad(){if(this._element){v.addIDInfo(this._element);const t=this._element.getAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.filterItem.id}`}}buildRightSlot(t){return s("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,s,e;const n=null===(s=null===(i=this.filterItem)||void 0===i?void 0:i.value)||void 0===s?void 0:s.findIndex((({id:i})=>i===t.id)),a=m.copy(this.filterItem);null===(e=null==a?void 0:a.value)||void 0===e||e.splice(n,1),this.updateFilterValue(a.value)}canShowDetailModal(){const{CUSTOM_FILTER:t,OTHER_FILTERS:i}=I;return![t,i].includes(this.filterItem.filterType)&&this.filterItem.type!==C.BINARY_SELECT}render(){const{tag:t,props:i}=this.getContentEditorConfig();return s(e,null,s("div",{class:"ez-flex ez-flex--column grow"},this.canShowDetailModal()&&s("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin-bottom--extra-small",htmlFor:`filter-item-${this.filterItem.id}`},this.filterItem.detailModal),s(t,Object.assign({ref:t=>this._editor=t,id:`filter-item-${this.filterItem.id}`,config:this.filterItem,value:this.filterItem.value,onValueChanged:t=>this.updateFilterValue(t.detail),"data-element-id":this._idContentEditor},i))))}get _element(){return a(this)}};At.style=".grow{flex-grow:1}.gap{gap:4px}";const xt=class{constructor(s){t(this,s),this.imageError=i(this,"imageError",7),this.dataUnitObserver=async t=>{var i;if([l.NEXT_SELECTED,l.PREVIOUS_SELECTED].includes(t.type))return void await this.loadImage();const s=(null===(i=t.payload)||void 0===i?void 0:i.selection)||[];t.type===l.SELECTION_CHANGED&&s.length>0?await this.loadImage():t.type!==l.RECORDS_ADDED?t.type!==l.EDITION_CANCELED||await this.loadImage():await this.clearImage()},this.dataUnit=void 0,this.fieldName=void 0,this.entityName=void 0,this.enabled=!0,this.acceptType=void 0,this.maxSize=void 0,this.label=void 0,this.imageValue=void 0,this.loading=!0}async reloadImage(t){await this.loadImage(t)}getMessage(t,i){return this.messagesBuilder||(this.messagesBuilder=new g),this.messagesBuilder.getMessage(t,i)}async clearImage(){var t;null===(t=this._loadAbortController)||void 0===t||t.abort(),this.imageValue=void 0}async handleImageChange(t){const i=t.detail;if(!i)return await this.clearImage(),void await this.updatedataUnitField(!0);const s=await M(i);if(this.maxSize&&s.size>1024*this.maxSize){const t=this.getMessage("snkImageInput.errorImageSize")+this.maxSize+"(KB)";return this.imageError.emit(t),void(this.application&&await this.application.error(this.getMessage("snkImageInput.errorTitle"),t))}this.imageValue=i,await U(s,this.entityName,this.fieldName),await this.updatedataUnitField()}async updatedataUnitField(t=!1){this.dataUnit&&this.dataUnit.getSelectedRecord()&&(t?await this.dataUnit.setFieldValue(this.fieldName,"deletado"):await this.dataUnit.setFieldValue(this.fieldName,`$file.session.key{${V(this.entityName,this.fieldName)}}`))}async handleImageError(t){this.imageError.emit(t.detail),this.application&&await this.application.error(this.getMessage("snkImageInput.errorTitle"),t.detail)}getPksFromDataUnit(){if(!this.dataUnit)return;const t=this.dataUnit.getSelectedRecord();if(!t)return;const i=t[this.fieldName];if(i)try{return JSON.parse(i)}catch(t){return void console.error("Error parsing PK from data unit field:",t)}}async loadImage(t){var i,s;null===(i=this._loadAbortController)||void 0===i||i.abort();const e=new AbortController;if(this._loadAbortController=e,this.loading=!0,this.dataUnit&&this.entityName){t=null!==(s=null!=t?t:this.getPksFromDataUnit())&&void 0!==s?s:R(this.dataUnit);const i=await B(t,this.fieldName,this.entityName,e.signal);if(e.signal.aborted)return;this.imageValue=i}this.loading=!1}async componentWillLoad(){this.application=o.getContextValue("__SNK__APPLICATION__"),this.messagesBuilder||(this.messagesBuilder=new g),this.dataUnit&&this.dataUnit.subscribe(this.dataUnitObserver)}disconnectedCallback(){this.dataUnit&&this.dataUnit.unsubscribe(this.dataUnitObserver)}async componentDidLoad(){await this.loadImage()}render(){return s(e,null,s("ez-image-input",{enabled:this.enabled,label:this.label,name:this.fieldName,value:this.imageValue,maxFileSize:this.maxSize?1024*this.maxSize:void 0,accept:this.acceptType||"image/png,image/jpeg,image/gif",onEzChange:t=>this.handleImageChange(t),onEzError:t=>this.handleImageError(t),loading:this.loading}))}};xt.style=":host{display:block}";const St=class{constructor(s){t(this,s),this.ezCancel=i(this,"ezCancel",7),this.ezSave=i(this,"ezSave",7),this.ezAfterSave=i(this,"ezAfterSave",7),this._personalizedFilterFetcher=new Q,this._filterMetadataStorage=new Map,this._dataSourceFetcher={fetchData:async t=>{let i=null==t?void 0:t.uri;if(d.isEmpty(i)&&(i=this.entityUri),!this._filterMetadataStorage.has(i)){const t=await this._personalizedFilterFetcher.loadFields(i);this._filterMetadataStorage.set(i,t)}return this._filterMetadataStorage.get(i)}},this._filterAssistentMode=!0,this._filterAssistent=void 0,this.messagesBuilder=void 0,this.entityUri=void 0,this.filterId=void 0,this.configName=void 0,this.resourceID=void 0,this.isDefaultFilter=!1}async createPersonalizedFilter(){const t={name:"",active:!0,expression:"",parameters:[],assistent:{id:d.generateUUID(),items:[{id:d.generateUUID(),entityName:"",fieldName:"",description:"",fieldLabel:this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null}],childrenGroups:[],operand:G.AND}};this.isDefaultFilter&&this.buildDataDefaultFilter(t),this._originalFilterAssistent=m.copy(t),this._filterAssistent=m.copy(t)}loadFilter(t,i){null!=t&&i!=t&&null!=this.resourceID&&(t!==$.id?H.loadPersonalizedFilter(t,this.resourceID,this.configName).then((t=>{const i=this.applyDefaultValues(t);this._filterAssistent=i,this._originalFilterAssistent=m.copy(i),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent})):H.loadDefaultFilter(t,this.resourceID,this.configName).then((t=>{const i=this.applyDefaultValues(t);this._filterAssistent=i,this._originalFilterAssistent=m.copy(i),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent})))}componentWillLoad(){var t;null==J.get(`filterFieldsDataSource.${this.entityUri}`)&&J.set(`filterFieldsDataSource.${this.entityUri}`,this._dataSourceFetcher),this.messagesBuilder||(this._application=o.getContextValue("__SNK__APPLICATION__"),this.messagesBuilder=null===(t=this._application)||void 0===t?void 0:t.messagesBuilder),this.loadFilter(this.filterId,void 0)}componentDidRender(){var t;null===(t=this._viewStackRef)||void 0===t||t.show(this._filterAssistentMode?0:1),this._elButtonMode&&this._elButtonMode.setAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME,v.getInternalIDInfo(this._filterAssistentMode?"advancedMode_ezButton":"assistentMode_ezButton"))}buildDataDefaultFilter(t){t.name=$.name,t.id=$.id}getMessage(t,i){return this._application.messagesBuilder.getMessage(t,i)}async saveFilter(){let t;t=this.isDefaultFilter?await H.saveDefaultFilter(this._filterAssistent,this.resourceID,this.configName):await H.savePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName),this._elButtonSave.enabled=!1,T.info(this.getMessage(`snkPersonalizedFilter.${this._filterAssistent.id?"confirmEdit":"confirmSave"}.title`),{iconName:"check"});const i=Object.assign(Object.assign({},t),this._filterAssistent);i.parameters=K.buildVariableParameters(this._filterAssistent.assistent),this._originalFilterAssistent=m.copy(i),this._filterAssistent=m.copy(i),this.ezAfterSave.emit()}removeFilter(){H.removePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName)}hasChangesToSave(){return JSON.stringify(this._filterAssistent)===JSON.stringify(this._originalFilterAssistent)}async handleSave(){if(this._filterAssistentMode){if(!K.validateFields(this._filterAssistent.assistent)||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));this.saveAssistentMode()}else{if(!this._filterAssistent.expression||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));if(!await this.validateExpressionBeforeSaving())return;this.saveAdvancedMode()}}saveAssistentMode(){const{assistent:t,expression:i}=this._filterAssistent,s=t?K.buildGroupExpression(t):i;this._filterAssistent.expression=s,this.ezSave.emit(s),this.saveFilter()}saveAdvancedMode(){this._originalFilterAssistent.expression!==this._filterAssistent.expression&&this._filterAssistent.assistent?T.confirm(this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.description")).then((t=>{t&&this.saveAndTransformToAdvancedMode()})):this._filterAssistent.assistent?this.saveAssistentMode():this.saveAndTransformToAdvancedMode()}saveAndTransformToAdvancedMode(){this._filterAssistent.assistent=void 0,this.ezSave.emit(this._filterAssistent.expression),this.saveFilter()}async validateExpressionBeforeSaving(){const{valid:t,message:i=""}=await this._personalizedFilterFetcher.validatePersonalizedFilter(this.entityUri,this._filterAssistent.expression);return t||this._application.error(this.getMessage("snkPersonalizedFilter.errorValidation.title"),i.replace(/.*Exception: /,"")),t}handleCancel(){if(this.hasChangesToSave())return this.ezCancel.emit();T.confirm(this.getMessage("snkPersonalizedFilter.confirmCancel.title"),this.getMessage("snkPersonalizedFilter.confirmCancel.description")).then((t=>{var i;t&&(this._filterAssistent=m.copy(null!==(i=this._originalFilterAssistent)&&void 0!==i?i:{}),this.ezCancel.emit(),this._elButtonSave.enabled=!1)}))}handleTitleChange(t){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{name:t}),this._elButtonSave.enabled=!this.hasChangesToSave()}applyDefaultValues(t){return this.addLabelToItems(t),this.addFilterGroupCondition(t),t}addFilterGroupCondition(t){t.assistent&&!t.assistent.operand&&(t.assistent.operand=G.AND)}addLabelToItems(t){t.assistent&&t.assistent.items&&t.assistent.items.length>0&&t.assistent.items.forEach((i=>{if(null==i.fieldLabel){const s=(t.parameters||[]).find((t=>t.fieldName===i.fieldName));s&&(i.fieldLabel=s.label)}}))}handleExpressionChangeAdvancedMode(t){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:t}),this._elButtonSave.enabled=!this.hasChangesToSave()}handleChangeFilterAssistentMode(t){this._elButtonSave.enabled=!this.hasChangesToSave(),this._filterAssistent=Object.assign({},t)}selectField(t){if(!("name"in t))return;const i=this.buildExpression(t.entityName,t.name,t.entityPath);this._elAdvancedMode.querySelector("ez-text-area").appendTextToSelection(i)}buildExpression(t,i,s){return s.length>0&&s.shift(),s.length>0?`${s.join("->")}->${i}`:`${t}.${i}`}onAddField(t){this._elAdvancedMode.querySelector("ez-text-area").setFocus(),t.setBlur(),this._elFilterFieldSearch&&this._elFilterFieldSearch.show(t,{horizontalGap:0,verticalGap:12,fromRight:!0})}renderButtonAddField(){if(!this._filterAssistentMode)return s(n,null,s("ez-button",{class:"snk-personalized-filter__button-mode",label:this.getMessage("snkPersonalizedFilter.info.addField"),enabled:!0,onClick:t=>this.onAddField(t.target)},s("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:"plus"})),s("snk-filter-field-search",{class:"ez-padding-left--medium",ref:t=>this._elFilterFieldSearch=t,onEzSelectFilterItem:t=>this.selectField(t.detail),fieldsDataSource:this._dataSourceFetcher}))}buildContainerPersonalizedFilter(){return s("ez-view-stack",{ref:t=>this._viewStackRef=t},s("stack-item",null,this._filterAssistentMode&&s("snk-filter-assistent-mode",{filterAssistent:this._filterAssistent,messagesBuilder:this.messagesBuilder,filterId:this.filterId,entityUri:this.entityUri,application:this._application,onEzChangeFilter:t=>this.handleChangeFilterAssistentMode(t.detail),isDefaultFilter:this.isDefaultFilter})),s("stack-item",null,s("snk-filter-advanced-mode",{ref:t=>this._elAdvancedMode=t,filterAssistent:this._filterAssistent,application:this._application,onEzExpressionChange:t=>this.handleExpressionChangeAdvancedMode(t.detail)})))}handleModeChange(){var t,i;if(this._filterAssistentMode)T.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.description")).then((t=>{if(t&&(this._filterAssistentMode=!this._filterAssistentMode,!this.hasChangesToSave())){const t=K.buildGroupExpression(this._filterAssistent.assistent);this._filterAssistent.expression=t,this._elButtonSave.enabled=!this.hasChangesToSave()}}));else if((null===(t=this._filterAssistent)||void 0===t?void 0:t.expression)===(null===(i=this._originalFilterAssistent)||void 0===i?void 0:i.expression))this._filterAssistentMode=!this._filterAssistentMode;else{const t=this._filterAssistent.expression,i=K.buildGroupExpression(this._filterAssistent.assistent);t!==i?T.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.description")).then((t=>{t&&(this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:i}),this._filterAssistentMode=!this._filterAssistentMode)})):this._filterAssistentMode=!this._filterAssistentMode}}buildTitle(){return this.getMessage(this.isDefaultFilter&&!this.filterId?"snkPersonalizedFilter.info.titleCreateDefault":this.isDefaultFilter&&this.filterId?"snkPersonalizedFilter.info.titleEditDefault":this.filterId?"snkPersonalizedFilter.info.titleEdit":"snkPersonalizedFilter.info.titleAdd")}render(){var t,i,n,a;if((null===(t=this._filterAssistent)||void 0===t?void 0:t.assistent)||!this._filterAssistentMode)return s(e,null,s("div",{class:"snk-personalized-filter"},s("div",null,s("snk-simple-bar",{label:this.buildTitle(),onExit:()=>this.handleCancel()},s("div",{class:"snk-personalized-filter__header-actions",slot:"rightSlot"},s("ez-button",{label:this.getMessage("snkPersonalizedFilter.info.labelCancel"),onClick:()=>this.handleCancel()}),s("ez-button",{ref:t=>this._elButtonSave=t,enabled:!1,class:"ez-button--primary",label:this.getMessage("snkPersonalizedFilter.info.labelSave"),onClick:this.handleSave.bind(this)})))),s("div",{class:"ez-box ez-margin-bottom--medium ez-box__main"},s("div",{class:"ez-box__container"},s("div",{class:"ez-flex ez-flex--column ez-size-width--full"},s("div",{class:"ez-flex"},s("ez-tooltip",{message:this.getMessage("snkPersonalizedFilter.info.textInputDisabled"),active:this.isDefaultFilter},s("ez-text-input",{class:"ez-padding-right--medium",label:this.getMessage("snkPersonalizedFilter.info.labelNameFilter"),value:null===(i=this._filterAssistent)||void 0===i?void 0:i.name,onEzChange:t=>this.handleTitleChange(t.detail),enabled:!this.isDefaultFilter})),this.renderButtonAddField(),s("ez-button",{ref:t=>this._elButtonMode=t,class:"snk-personalized-filter__button-mode",label:this.getMessage(this._filterAssistentMode?"snkPersonalizedFilter.info.activeModeAdvanced":"snkPersonalizedFilter.info.activeModeAssistent"),onClick:()=>this.handleModeChange(),"data-tooltip":this._filterAssistentMode||(null===(n=this._filterAssistent)||void 0===n?void 0:n.assistent)?void 0:this.getMessage("snkPersonalizedFilter.info.tooltipDisabledAssistentMode"),"data-flow":"bottom",enabled:!this._filterAssistent.name||Boolean(this._filterAssistentMode||(null===(a=this._filterAssistent)||void 0===a?void 0:a.assistent))})),this.buildContainerPersonalizedFilter())))))}static get watchers(){return{filterId:["loadFilter"]}}};St.style=".sc-snk-personalized-filter-h{display:flex;height:100%;padding:var(--space--large, 24px);--snk-personalized-filter--width:100%;--snk-personalized-filter--height:100%;--snk-personalized-filter--background-color-line:var(--color--disable-secondary);--snk-personalized-filter--margin-line:var(--border--radius-medium, 12px)}.snk-personalized-filter.sc-snk-personalized-filter{height:var(--snk-personalized-filter--width);width:var(--snk-personalized-filter--height)}.snk-personalized-filter__header-actions.sc-snk-personalized-filter{display:flex;gap:var(--space--medium)}.snk-personalized-filter__group.sc-snk-personalized-filter{flex:1}.snk-personalized-filter__expression-input--line.sc-snk-personalized-filter{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}.ez-box__main.sc-snk-personalized-filter{height:90%}.snk-personalized-filter__button-mode.sc-snk-personalized-filter{height:35px}";const Ot=class{constructor(s){t(this,s),this.clickBreadcrumbItem=i(this,"clickBreadcrumbItem",3),this.exit=i(this,"exit",3),this.label=void 0,this.breadcrumbItens=void 0,this.messagesBuilder=void 0}getMessage(t,i){var s;return this.messagesBuilder?this.messagesBuilder.getMessage(t,i):(null===(s=this._application)||void 0===s?void 0:s.messagesBuilder)?this._application.messagesBuilder.getMessage(t,i):void 0}componentDidLoad(){this._element&&(v.addIDInfo(this._element),this._application=o.getContextValue("__SNK__APPLICATION__"))}render(){return s("div",{class:"simple-bar__container ez-margin-vertical--small ez-padding--extra-small"},s("div",{class:"simple-bar__left-slot"},s("ez-button",{class:"ez-padding-right--medium",title:this.getMessage("snkSimpleBar.backTitle"),mode:"icon",iconName:"arrow_back",size:"medium",onClick:()=>this.exit.emit()}),s("div",{class:"simple-bar__column"},s("h1",{class:"ez-title ez-title--primary ez-title--extra-large"},this.label),s("ez-breadcrumb",{items:this.breadcrumbItens,onSelectedItem:({detail:t})=>this.clickBreadcrumbItem.emit(t)}))),s("div",{class:"simple-bar__right-slot"},s("slot",{name:"rightSlot"})))}get _element(){return a(this)}};Ot.style=".sc-snk-simple-bar-h{display:flex;height:100%;width:100%}.simple-bar__container.sc-snk-simple-bar{flex:1;display:flex;align-items:stretch;gap:var(--space--small)}.simple-bar__left-slot.sc-snk-simple-bar{min-width:280px;flex:1;display:flex;align-items:center}.simple-bar__right-slot.sc-snk-simple-bar{flex:1;display:flex;align-items:center;justify-content:flex-end}.simple-bar__column.sc-snk-simple-bar{flex:1;display:flex;flex-direction:column}";const Ft=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],It=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"],Et=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.actionClick=i(this,"actionClick",7),this.formItemsReady=i(this,"formItemsReady",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this._multiSelectionListDataSource=new W,this._formConfigFetcher=new z,this._customEditors=new Map,this._customRenders=new Map,this._container=void 0,this._showPopUpGridConfig=!1,this._currentViewMode=A.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this._customContainerId=`SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${d.generateUUID()}`,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.dataState=void 0,this.dataUnit=void 0,this.entityName=void 0,this.mode=x.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this._fieldsProps=new Map,this.enableContinuousInsert=!1,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.pageSize=150,this.resourceID=void 0,this.enableGridInsert=!1,this.paginationCounterMode="auto",this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.actionsList=void 0,this.configName=void 0,this.showConfiguratorButtons=!1,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.ignoreReadOnlyFormFields=!1,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.multipleEditionEnabled=!0,this.layoutFormConfig=!0,this.disableGridEdition=!1,this.autoLoad=void 0,this.outlineMode=!1}async addCustomEditor(t,i){if(this._grid&&this._form)return this._grid.addCustomEditor(t,i),void this._form.addCustomEditor(t,i);const s=new Map(this._customEditors);s.set(t,i),this._customEditors=s}async addGridCustomRender(t,i){if(this._grid)return void this._grid.addGridCustomRender(t,i);const s=new Map(this._customRenders);s.set(t,i),this._customRenders=s}async handleResourceIDChanged(t,i){d.isEmpty(t)||t!==i&&(await this.loadFormConfig(!0),await this.loadGridConfig(!0))}async addCustomValueFormatter(t,i){this._grid.addCustomValueFormatter(t,i)}async removeCustomValueFormatter(t){this._grid.removeCustomValueFormatter(t)}async setFieldProp(t,i,s){const e=new Map(this._fieldsProps),n=this._fieldsProps.get(t);e.set(t,Object.assign(Object.assign({},n),{[i]:s})),this._fieldsProps=e}loadTaskbarProcessor(){const t={};t[Pt.FORM_REGULAR]=this.getButtons(!1,[O.GRID_MODE],!0),t[Pt.GRID_REGULAR]=this.getButtons(!1,[O.DATA_EXPORTER,O.FORM_MODE]),t[Pt.FORM_SELECTED]=this.getButtons(!0,[O.GRID_MODE],!0),t[Pt.GRID_SELECTED]=this.getGridSelectedButtonsCallBack.bind(this),t[Pt.FINISH_EDITION]=this.getFinishEditionButtonsCallback.bind(this),t[Pt.MULTIPLE_EDITION]=[O.CANCEL],this._taskbarProcessor=new X(t)}getGridSelectedButtonsCallBack(){var t,i,s;return this.multipleEditionEnabled&&1!==(null===(s=null===(i=null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)||void 0===i?void 0:i.records)||void 0===s?void 0:s.length)?this.getButtons(!0,[O.UPDATE_MULTIPLE,O.DATA_EXPORTER,O.FORM_MODE]):this.getButtons(!0,[O.DATA_EXPORTER,O.FORM_MODE])}getFinishEditionButtonsCallback(){const t=[O.CANCEL,O.SAVE];return this.enableGridInsert&&this._currentViewMode!==A.ATTACHMENT&&t.push(this._currentViewMode===A.GRID?O.FORM_MODE:O.GRID_MODE),t}getButtons(t,i,s){let e=t?It:Ft;return(s||this.mode===x.IN_MEMORY)&&(e=e.filter((t=>t!==O.REFRESH))),this.addConfigButton(e.concat(i))}addConfigButton(t){return void 0===this.configName||this.configName&&this.gridLegacyConfigName?t:t.concat(O.CONFIGURATOR)}get application(){return o.getContextValue("__SNK__APPLICATION__")}async goToView(t){this._currentViewMode=t,this._viewStack&&(t===A.GRID&&(this.dataUnit.isMultipleEdition=!1),this._viewStack.show(t)),t===A.GRID&&requestAnimationFrame((()=>this.focusToGrid())),t===A.FORM&&requestAnimationFrame((()=>this.focusToForm()))}actionClickListener(t){this.handleTaskbarAction(t.detail),t.stopPropagation()}handleTaskbarAction(t){switch(t){case O.CONFIGURATOR:this._snkConfigurator.open();break;case O.GRID_MODE:this.goToView(A.GRID);break;case O.FORM_MODE:this.goToView(A.FORM);break;case O.UPDATE_MULTIPLE:this.dataUnit.isMultipleEdition=!0,this.goToView(A.FORM)}}async onChangeEntityName(t){if(this.dataUnit)return;const i=o.getContextValue("__SNK__APPLICATION__");this.dataUnit=await i.getDataUnit(t,null,null,this.configName)}onModeChange(){this.mode==x.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(t,i){this.handleDataStateChange(t,i)}async observeFormLegacy(t,i){await this.handleUpdateFormLegacyConfig(t,i)}async observeGridLegacy(t,i){await this.handleUpdateGridLegacyConfig(t,i)}async handleDataStateChange(t,i){m.objectToString(i)!=m.objectToString(t)&&this.dataStateChange.emit(t),await this.processRmPrecision()}async processRmPrecision(){var t,i;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const e of s||[]){if(!e)continue;const s=null===(i=null===(t=this.dataState)||void 0===t?void 0:t.rowMetadata)||void 0===i?void 0:i.getProp("rm_precision",e);(s||0===s)&&(await this.setFieldProp(e,"precision",s),await this.setFieldProp(e,"prettyPrecision",s))}this._rmPrecisionCustomValueFormatter.setDataState(this.dataState)}async handleUpdateGridLegacyConfig(t,i){null!=t&&t!=i&&this._gridConfigAlreadyLoaded&&await this.loadGridConfig(!0)}async handleUpdateFormLegacyConfig(t,i){null!=t&&t!=i&&this._formConfigAlreadyLoaded&&await this.loadFormConfig(!0)}async openConfig(t){await this._snkConfigurator.close(),t===A.GRID?await this.openGridConfig():t===A.FORM&&await this.openFormConfig()}async openGridConfig(){var t,i,s,e;const n=null!==(i=await(null===(t=this._grid)||void 0===t?void 0:t.getColumns()))&&void 0!==i?i:[],a=null!==(e=await(null===(s=this._grid)||void 0===s?void 0:s.getColumnsState()))&&void 0!==e?e:[];this._snkGridConfig.columns=a.filter((t=>t.name)),this._snkGridConfig.originalColumns=n.filter((t=>t.name)),this._snkGridConfig.selectedIndex=0,this._showPopUpGridConfig=!0}async openFormConfig(){(this.formLegacyConfigName||this.configName)&&await this._snkSimpleFormConfig.show()}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&H.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}loadGridConfig(t){if(void 0!==this.configName&&(null==this.gridConfig&&!this._gridConfigAlreadyLoaded||t))return this.addGridLegacyConfigName(),this._gridConfigAlreadyLoaded=!0,new Promise(((t,i)=>{H.loadGridConfig(this.configName,this.resolveResourceID()).then((i=>{this.setGridConfig(i),t()})).catch((t=>{i(t)}))}))}formConfigIsLoaded(){return null!=this.formConfig||this._formConfigAlreadyLoaded}async loadFormConfig(t=!1,i=!1){if(void 0===this.configName)return;if(null==this._formConfigManager&&(this._formConfigManager=new it(this.configName,this.resolveResourceID(),void 0,this.dataUnit),this._formConfigManager.setConfig(this.formConfig)),this.formConfigIsLoaded()&&!t)return;this._formConfigAlreadyLoaded=!0;let s=await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);if(null!=s)return this._formConfigManager.setConfig(s),void this.setFormConfig(s,i);this.setFormConfig(await this._formConfigManager.loadConfig())}async componentWillRender(){this.loadTaskbarProcessor(),this._resourceID=await this.application.getResourceID(),this.dataExporterProviderStore(),this.dataExporterProviderStore(),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons()),void 0!==this.configName&&(null!=this.gridConfig||this._gridConfigAlreadyLoaded||(await this.addGridLegacyConfigName(),await this.loadGridConfig(),await this.loadFormConfig()))}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.addGridCustomValueFormattters(),this.setFieldsProps(),this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource(),this._rmPrecisionCustomValueFormatter=new Y,this._continuousInsertUtils=new st(this.application,this.resolveResourceID(),this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((t=>this.enableContinuousInsert=t))}componentDidLoad(){L.applyVarsGrid(this._element,this._grid),this.initKeyboardManager(),this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this))}async dataUnitActionHandler(t){t.type!==l.EDITION_CANCELED&&t.type!==l.DATA_SAVED||this.dataUnit.isMultipleEdition&&this.goToView(A.GRID)}getMessage(t,i){var s;return null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(t,i)}disconnectedCallback(){var t;null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}setCustomRenders(){if(this._grid)for(const[t,i]of this._customRenders)this._grid.addGridCustomRender(t,i),this._customRenders.delete(t)}setCustomEditors(){if(this._grid&&this._form)for(const[t,i]of this._customEditors)this._grid.addCustomEditor(t,i),this._form.addCustomEditor(t,i),this._customEditors.delete(t)}configDatasource(){this._multiSelectionListDataSource.setApplication(this.application),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}setFieldsProps(){if(this._form)for(const[t,i]of this._fieldsProps){for(const s in i)this._form.setFieldProp(t,s,i[s]);this._fieldsProps.delete(t)}}getTaskBarId(){var t,i;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?Pt.FINISH_EDITION:this.dataUnit.isMultipleEdition?Pt.MULTIPLE_EDITION:(null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&this.dataState.selectionInfo.length>0?this._currentViewMode===A.GRID?Pt.GRID_SELECTED:Pt.FORM_SELECTED:this._currentViewMode===A.GRID?Pt.GRID_REGULAR:Pt.FORM_REGULAR}initInMemoryDataUnit(){this._inMemoryLoader=new w(this._metadata,void 0,{autoLoad:this.autoLoad}),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async updateConfig(){null==this._formConfigManager&&(this._formConfigManager=new it(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),i=[],s={fields:[],emptyConfig:!1};t.forEach((t=>{const e={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:r[t.getAttribute("dataType")]||r.TEXT,userInterface:h[t.getAttribute("userInterface")]||h.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0,visible:"false"!=t.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),i.push(e)})),i.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:i})}addGridCustomValueFormattters(){var t,i,s;const e=(null===(t=this._metadata)||void 0===t?void 0:t.fields)||(null===(s=null===(i=this.dataUnit)||void 0===i?void 0:i.metadata)||void 0===s?void 0:s.fields);if(!e)return;const n=[];e.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!n.includes(t.name)&&n.push(t.name)})),n.forEach((t=>{this.addCustomValueFormatter(t,this._rmPrecisionCustomValueFormatter)}))}onDataStateChange(t){this.dataState=Object.assign({},t.detail)}getTaskBarDisabledButtons(){var t,i,s,e,n,a;const o=[];return(null===(t=this.dataState)||void 0===t?void 0:t.hasNext)||o.push(O.NEXT),(null===(i=this.dataState)||void 0===i?void 0:i.hasPrevious)||o.push(O.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&o.push(O.FORM_MODE),(null===(a=null===(n=this.dataState)||void 0===n?void 0:n.selectionInfo)||void 0===a?void 0:a.length)>1&&o.push(O.CLONE),o}handleCancelEdit(){var t;(null===(t=this.dataState)||void 0===t?void 0:t.recordsIsEmpty)&&(this.goToView(A.GRID),this.dataUnit.clearSelection())}handleConfiguratorEvent(t,i){t.stopImmediatePropagation(),"SAVE"!==i?this.configuratorCancel.emit():this.configuratorSave.emit()}onSelectField(t){null!=t&&(this._fieldToGetFocus=t.value)}getFieldSearch(t,i){return null!=this._fieldSearch||(this._splitButtonForm=t,this._fieldSearch=D(i,(({argument:t})=>this.fieldsOptionLoader(t)),(t=>this.onSelectField(t)))),this._fieldSearch}getFormFields(){var t,i;return null!==(i=null===(t=this.formConfig)||void 0===t?void 0:t.fields)&&void 0!==i?i:this._formFields}handleFormSetFields(t){m.equals(this._formFields,t)||(this._formFields=null!=t?t:[])}fieldsOptionLoader(t){const i=null==t?void 0:t.toLowerCase(),s=this.getFormFields().map((t=>{var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getField(t.name)})).filter((t=>{var s,e;return(null===(s=t.name)||void 0===s?void 0:s.toLowerCase().includes(i))||(null===(e=t.label)||void 0===e?void 0:e.toLowerCase().includes(i))})).map((t=>({value:t.name,label:t.label})));return Promise.resolve(s)}isGridInsertActive(){return this.enableGridInsert&&this.dataUnit.hasNewRecord()}getColumnSearch(t,i){return null!=this._columnSearch||(this._splitButton=t,this._columnSearch=D(i,(({argument:t})=>new Promise((i=>{this._grid.filterColumns(t).then((t=>{i(t.filter((t=>!t.hidden)).map((t=>({label:t.label,value:t.name}))))}))}))),(t=>{null!=t&&this._grid.locateColumn(t.value)}))),this._columnSearch}getActionsList(){const t=[];if(this.enableGridInsert&&t.push(this._continuousInsertUtils.actionContinuousInsert(this.enableContinuousInsert,(()=>{this.enableContinuousInsert=!this.enableContinuousInsert,this._continuousInsertUtils.handleSaveConfig(this.enableContinuousInsert)}))),this.isGridInsertActive())return t;if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const i=this.getTopTaskBarId();return t.concat(this.taskbarManager.getMoreOptions(i,this.configName,this.dataState,this.actionsList))}return t.concat(this.actionsList)}getSettingsListGrid(){return[{value:d.generateUUID(),label:this.getMessage("snkSimpleCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(t,i)=>this.getColumnSearch(t,i)}]}getSettingsListForm(){return[{value:d.generateUUID(),label:this.getMessage("snkSimpleCrud.findFields"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(t,i)=>this.getFieldSearch(t,i)}]}getTopTaskBarId(){var t;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?`snkGridTopTaskbar.finish_edition${k.PRIMARY}`:`snkGridTopTaskbar.regular${k.PRIMARY}`}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}gridConfigChangeHandler(t){t.stopPropagation(),this.configName&&H.saveGridConfig(t.detail,this.configName,this.resolveResourceID())}modalConfigChangeHandler(t){const i=t.detail;this._grid.setColumnsState(i.columns).then((()=>{this.setGridConfig(i),this.closeGridConfig(),this.dataExporterProviderStore()})),t.stopPropagation()}async dataExporterProviderStore(){if(null==this.dataUnit)return;if(null==this._grid)return;const t=new tt(this.dataUnit,this._grid);J.set("exporterProviders",Object.assign(Object.assign({},J.get("exporterProviders")),{[this.getDataExporterStoreKey()]:t}))}getDataExporterStoreKey(){return`SnkSimpleCrudDataExporter:${null==this.configName?this.dataUnit.name:this.configName}`}setGridConfig(t){this.gridConfig=t,Z.assertDefaultSorting(this.gridConfig,this.dataUnit)}setFormConfig(t,i){this.formConfig&&!i||(this.formConfig=t)}closeGridConfig(){this._showPopUpGridConfig=!1}getPageSize(){return this.mode===x.IN_MEMORY?0:null==this.pageSize?150:this.pageSize}resolveResourceID(){return d.isEmpty(this.resourceID)?this._resourceID:this.resourceID}getFormConfig(){var t;const i=null===(t=this._formConfigManager)||void 0===t?void 0:t.getConfig(this.dataUnit,this.ignoreReadOnlyFormFields);return this.configName||i?i:this.formConfig}updateFormConfig(){let t=this.formConfig;null==this.formLegacyConfigName&&(t=Object.assign(Object.assign({},this.formConfig),{fields:this.dataUnit.metadata.fields})),this.setFormConfig(t,!0),null==this._formConfigManager&&(this._formConfigManager=new it(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}handleDataUnitOnInsertionMode(){this.enableGridInsert||this.goToView(A.FORM)}async initKeyboardManager(){var t;this._keyboardManager=new f({propagate:!1,element:this._element});const i=this.dataUnit||await(null===(t=this._snkDataUnit)||void 0===t?void 0:t.getDataUnit());null!=i&&this._keyboardManager.bind("F7",(()=>i.saveData()),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.saveData"),element:this._element}).bind("F8",i.addRecord.bind(i),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.addRecord"),element:this._element}).bind("F9",i.removeSelectedRecords.bind(i),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.removeRecord"),element:this._element}).bind("Escape",(()=>{i.isDirty()&&i.cancelEdition()}),{debounceTime:1e3,description:this.getMessage("snkSimpleCrud.keyboardShortcuts.cancelAction"),element:this._element})}async handleFormConfigSaved(){await this.loadFormConfig(!0,!0)}focusToGrid(){this._grid.focus()}focusToForm(){this._form.focus()}renderTaskbarContent(t){var i;return s("snk-taskbar",{class:"ez-box--no-outline ez-box "+(this._currentViewMode===A.FORM?(this.outlineMode?"ez-box--outline":"ez-box--shadow-xsmall")+" ez-padding--small":""),dataUnit:this.dataUnit,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,actionsList:this.getActionsList(),actionsSettingsList:t===A.GRID?this.getSettingsListGrid():this.getSettingsListForm(),disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,"data-exporter-store-key":this.getDataExporterStoreKey(),slot:"leftButtons",presentationMode:k.SECONDARY,tabindex:"0"},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"}))}render(){var t;if(null!=this.dataUnit)return s("snk-data-unit",{ref:t=>this._snkDataUnit=t,class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:t=>this.onDataStateChange(t),onCancelEdition:this.handleCancelEdit.bind(this),pageSize:this.getPageSize(),onInsertionMode:this.handleDataUnitOnInsertionMode.bind(this),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail),onMessagesBuilderUpdated:t=>this.messagesBuilder=t.detail,onDataUnitFieldsHidded:this.updateFormConfig.bind(this),domainMessagesBuilder:this.domainMessagesBuilder},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:`ez-box ez-box--no-outline ${this.outlineMode?"ez-box--outline":"ez-box--shadow"} simple-crud__container-section`,ref:t=>this._container=t,tabindex:"0"},s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{class:"ez-margin-bottom--large ez-box--no-outline",ref:t=>this._grid=t,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(A.FORM),onConfigChange:t=>this.gridConfigChangeHandler(t),columnfilterDataSource:this.dataUnit.name&&this.dataUnit.name.includes(w.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableContinuousInsert:this.enableContinuousInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,outlineMode:this.outlineMode,tabindex:"0",paginationCounterMode:this.paginationCounterMode,canEdit:!this.disableGridEdition},this.renderTaskbarContent(A.GRID),s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,this.renderTaskbarContent(A.FORM),s("ez-form",{ref:t=>this._form=t,class:"ez-margin-top--large ez-box--no-outline",dataUnit:this.dataUnit,config:this.getFormConfig(),fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:t=>this.handleFormSetFields(t.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),elementFocusSearchField:this._container,tabindex:"0"}),s("slot",{name:"snkSimpleCrudFormFooter"}),s("snk-simple-form-config",{ref:t=>this._snkSimpleFormConfig=t,dataUnit:this.dataUnit,onSnkConfigSaved:this.handleFormConfigSaved.bind(this),configName:null!==(t=this.formLegacyConfigName)&&void 0!==t?t:this.configName,messagesBuilder:this.messagesBuilder})),this.messagesBuilder&&s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.goToView(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showConfiguratorButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL"),resourceID:this.resolveResourceID(),customContainerId:this._customContainerId,layoutFormConfig:this.layoutFormConfig})),s("div",{id:`${this._customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}))),s("ez-popup",{size:"medium",heightMode:"auto",useHeader:!1,opened:this._showPopUpGridConfig,onEzClosePopup:()=>this.closeGridConfig()},s("snk-grid-config",{ref:t=>this._snkGridConfig=t,config:this.gridConfig,"data-element-id":this._element.getAttribute(v.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:t=>this.modalConfigChangeHandler(t),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resolveResourceID()})))}get _element(){return a(this)}static get watchers(){return{resourceID:["handleResourceIDChanged"],entityName:["onChangeEntityName"],mode:["onModeChange"],dataState:["observeDataState"],formLegacyConfigName:["observeFormLegacy"],gridLegacyConfigName:["observeGridLegacy"]}}};var Pt;!function(t){t.FORM_REGULAR="snkSimpleCrudTaskbar.form_regular",t.GRID_REGULAR="snkSimpleCrudTaskbar.grid_regular",t.FORM_SELECTED="snkSimpleCrudTaskbar.form_selected",t.GRID_SELECTED="snkSimpleCrudTaskbar.grid_selected",t.FINISH_EDITION="snkSimpleCrudTaskbar.finish_edition",t.MULTIPLE_EDITION="snkSimpleCrudTaskbar.multiple_edition"}(Pt||(Pt={})),Et.style=".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;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__container--shadow--outline:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";export{kt as snk_attach,_t as snk_default_filter,yt as snk_dynaform_form_view,wt as snk_filter_advanced_mode,Ct as snk_filter_assistent_mode,zt as snk_filter_detail,At as snk_filter_modal_item,xt as snk_image_input,St as snk_personalized_filter,Ot as snk_simple_bar,Et as snk_simple_crud}
@@ -0,0 +1 @@
1
+ import{r as t,h as e,f as i,g as s}from"./p-2c9d0870.js";import{ApplicationContext as o,ObjectUtils as r,UserInterface as n,DataType as l,ElementIDUtils as a}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as h}from"@sankhyalabs/ezui/dist/collection/utils";import{I as c}from"./p-8f3f2306.js";import{D as u,a as p,b as m}from"./p-0f3698af.js";import{R as v}from"./p-9019a32f.js";import{D as x}from"./p-5d02c032.js";import{S as f}from"./p-19d1ca14.js";import"./p-b1bf9564.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-f076d742.js";import"./p-ff1990ad.js";import"./p-d88278f8.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/DataType";import"./p-7dd49d15.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class g{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===u.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===u.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this._selectedNumber>0&&this.setExportAllRecords(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];if(t===u.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===u.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportAllRecords(t,e){var i;const s=[u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS];if(t===u.EXPORT_ALL_RECORDS&&e.push(this.getAllRecords()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS));null==s&&(e.push(this.getAllRecords()),s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS))),(null===(i=s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_ALL_RECORDS_TO_PDF&&s.children.push(this.getExportAllRecordsToPDF()),t===u.EXPORT_ALL_RECORDS_TO_XLS&&s.children.push(this.getExportAllRecordsToXLS())}}setExportByEmail(t,e){t===u.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:u.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:u.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`,group:t}}getCurrentPage(){return{id:u.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getAllRecords(){return{id:u.EXPORT_ALL_RECORDS,label:this._getMessage("snkDataExporter.label.allRecords"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:u.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:u.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`}}getExportAllRecordsToPDF(){return{id:u.EXPORT_ALL_RECORDS_TO_PDF,label:"PDF (.pdf)"}}getExportAllRecordsToXLS(){return{id:u.EXPORT_ALL_RECORDS_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:u.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function b(t){const e=[];let i=0;for(const s of t){if(i+=s.width,i>=860)break;e.push(s)}return e}function E(t){return Object.keys(u).find((e=>u[e]===t))}class w{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async getColumns(t){var e;return(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata()}async getParams(t){var e,i,s,o,r,n;const l=null===(i=(e=this._provider).getFilters)||void 0===i?void 0:i.call(e),a=await this.getColumns(t),d=null===(o=(s=this._provider).getOrders)||void 0===o?void 0:o.call(s),h=null===(n=(r=this._provider).getResourceURI)||void 0===n?void 0:n.call(r),c=this._provider.getSelectedIDs(),p=t.exportOption,m=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];delete t.exportOption;let v=Object.assign({filters:l,columns:a,sort:d,resourceURI:h,selectedIDs:c.slice(0,this._provider.getExportLimit())},t);if(m.includes(p)||"page"==t.type){const t=this._provider.getOffset(),e=this._provider.getPageSize();v=Object.assign(Object.assign({},v),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(v=Object.assign(Object.assign({},v),{offset:0,limit:this._provider.getExportLimit(),selectedIDs:[]}));return Promise.resolve(v)}async executeExport(t){const e=await this.getParams(t),{methodName:i}=e,s=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(e,["methodName"]),n=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.${i}`,l={serviceName:n,requestBody:s};return new Promise(((t,e)=>{x.get().callServiceBroker(n,r.objectToString(l)).then((e=>t(this.getFormatResponse(e)))).catch((t=>e(t)))}))}getFormatResponse(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}}class D{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async executeExport(t){var e;const{methodName:i,gridTitle:s}=t,o=await this._provider.getRecords(t.type),r=(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),[n,l]=this.getExecutor(i),a={serviceName:n,requestBody:{grid:{gridTitle:s,columns:this.buildColumnsObject(r),rows:this.buildRowsObject(r,o),customOptions:{xlsxExtension:!1}}}};return new Promise(((t,e)=>{x.get().callServiceBroker(n,a).then((e=>t(l(e)))).catch((t=>e(t)))}))}getExecutor(t){return"exportToPDF"===t?["GridPDFBuilderSP.buildPDFFromJson",t=>({fileSessionKey:t.chavePDF.valor,canPrint:"S"===t.permiteImprimir.valor,canExport:"S"===t.permiteExportar.valor,canSendEmail:"S"===t.canSendEmail.valor,useAppPrint:!0})]:["GridXLSBuilderSP.buildXLSFromJson",t=>({fileSessionKey:t.chaveXLS.valor,canPrint:!0,canExport:!0,canSendEmail:!0,useAppPrint:!1})]}buildColumnsObject(t){return{column:t.map(((t,e)=>{const{label:i,id:s,width:o,userInterface:r}=t;return Object.assign({index:e+1,id:s,label:i,width:o,presentationType:"P"},k[r]||{type:"S",align:"left"})}))}}buildRowsObject(t,e){return{row:e.map((e=>{const i={};return t.forEach(((t,s)=>i["c"+(s+1)]={$:this.formatValue(e,t)})),i}))}}formatValue(t,e){return null!=this._provider.formatValue?this._provider.formatValue(t,e):t[e.id]||""}}const k={[n.DATE]:{type:"D",align:"center"},[n.DATETIME]:{type:"H",align:"center"},[n.TIME]:{type:"I",align:"right"},[n.ELAPSEDTIME]:{type:"I",align:"right"},[n.DECIMALNUMBER]:{type:"F",align:"right"},[n.INTEGERNUMBER]:{type:"I",align:"right"},[n.SEARCH]:{type:"S",align:"right"}},y=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._releasedToExport=[u.EXPORT_TO_PDF,u.EXPORT_TO_XLS,u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS,u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS],this._items=[],this._showDropdown=!1,this.provider=null,this.messagesBuilder=void 0,this.size="medium"}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=m[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:m.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,gridTitle:this._appLabel},(()=>{this._snkEmailSender.close(),d.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=f.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}async resolveExporter(t,e){null!=this.provider&&null!=t&&null!=e&&this.getExporterStrategy().executeExport(t).then((t=>e(t))).catch((t=>{console.error(t);let{title:e,message:i,statusMessage:s}=t||{};d.error(e||this.getMessage("snkDataExporter.message.exportError"),s||i||this.getMessage("snkDataExporter.message.unknownFailure"))}))}getExporterStrategy(){return null==this.provider.getRecords?new w(this.provider):new D(this.provider)}getOptionKey(t){return Object.keys(u).find((e=>u[e]===t))}getExportType(t){return t===u.EXPORT_ALL_RECORDS_TO_PDF||t===u.EXPORT_ALL_RECORDS_TO_XLS?c.ALL:t===u.EXPORT_PAGE_TO_PDF||t===u.EXPORT_PAGE_TO_XLS?c.PAGE:c.SELECTION}async dispatchExporter(t){var e,i,s;const r=this.getOptionKey(t),n=null!==(e=p[r])&&void 0!==e?e:p.EXPORT_TO_PDF,l={methodName:u[`EXPORT_TO_${n}`],fileName:this._appLabel,gridTitle:this._appLabel,exportOption:t,limit:null===(s=null===(i=this.provider)||void 0===i?void 0:i.getExportLimit)||void 0===s?void 0:s.call(i),type:this.getExportType(t)};await this.resolveExporter(l,(t=>{t.canExport||n===p.EXPORT_TO_PDF?function({fileSessionKey:t,isDownload:e}){const i=o.getContextValue("__SNK__APPLICATION__");window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${e?"&download=S":""}`),d.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(i),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:n})):d.error(this.getMessage("snkDataExporter.title.permission"),this.getMessage("snkDataExporter.message.exportPermission"))}))}async processExporter(t){var e,i,s,o,r,n,l;const a=null==t?void 0:t.detail,c=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS],p=null===(e=null==a?void 0:a.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==a?void 0:a.id)===u.EXPORT_CURRENT_PAGE)return;const m=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),v=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),x=null===(r=null===(o=this.provider)||void 0===o?void 0:o.getPageSize)||void 0===r?void 0:r.call(o),f=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let g=!1;if(c.includes(null==a?void 0:a.id)&&x<=f||p?g=!1:(null==m?void 0:m.length)?g=m.length>f:v>f&&(g=!0),g){const t=f.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await d.confirm(e.title,e.description,null,h.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(p)return this.openPersonalizedReports(a.id),void(this._showDropdown=!1);this.getFilteredReleasedToExport().includes(null==a?void 0:a.id)&&(a.id===u.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(a.id),this._showDropdown=!1)}getFilteredReleasedToExport(){var t,e;if(null==this.provider)return this._releasedToExport;const i=null===(e=(t=this.provider).getHiddenOptions)||void 0===e?void 0:e.call(t);return null==i?this._releasedToExport:this._releasedToExport.filter((t=>!i.includes(t)))}loadItems(){const t=[];this.getFilteredReleasedToExport().forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e,i;const s=null===(i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID)||void 0===i?void 0:i.call(e);if(null==s)return void(this._items=t);const n=await function(t){const e=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.getPersonalizedReports`,i={serviceName:e,requestBody:t};return new Promise(((t,s)=>x.get().callServiceBroker(e,r.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:s});null==n||n.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e,i;const s=[],o=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(i=null===(e=this.provider)||void 0===e?void 0:e.getSelectedIDs)||void 0===i||i.call(e).forEach((({name:t,type:e,value:i},o)=>{const r={fields:[]};0===o&&(s[`PK_${t}`]={type:this.parseDataType(e),value:i},s.pks=[]);const n={nome:`PK_${t}`,tipo:this.parseDataType(e),valor:i};r.fields.push(n),s.pks.push(r)})),this._application.openApp(`${v}${o}`,s)}parseDataType(t){switch(t){case l.NUMBER:return"I";case l.DATE:return"D";default:return"S"}}loadDropdown(){var t;this._selectedNumber=(null===(t=this.provider)||void 0===t?void 0:t.getSelectedNumber())||0,this._itemBuilder=new g(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:a.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=o.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(a.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},e("ez-tooltip",{message:this.getMessage("snkDataExporter.group.export.title")},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",mode:"icon",onClick:()=>this.controlDropdown(),size:this.size},this.getElementID("button")))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};y.style=".sc-snk-data-exporter-h{display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{y as snk_data_exporter}
@@ -0,0 +1 @@
1
+ import{r as i,e as t,h as e,F as s,g as n}from"./p-2c9d0870.js";import{ObjectUtils as o,StringUtils as r,Action as d,KeyboardManager as l,ElementIDUtils as a}from"@sankhyalabs/core";import{buildFieldSearch as h,SHORTCUT_SEARCH_FIELD as u}from"@sankhyalabs/ezui/dist/collection/utils";import{buildFormMetadata as v,FormMetadata as c}from"@sankhyalabs/ezui/dist/collection/utils/form";import{a as f,V as m}from"./p-9019a32f.js";import{C as g}from"./p-51e853f2.js";import{F as b}from"./p-d88278f8.js";import{T as k}from"./p-3072136e.js";class w{constructor(i,t,e,s){this._resourceID=t,this._configName=i,this._onConfigChange=e,this._dataUnit=s}addFormLegacyConfig(i){this._configName&&g.addFormLegacyConfig(this._configName,i)}async loadConfig(){return new Promise((i=>{g.loadFormConfig(this._configName,this._resourceID).then((t=>{t=this.buildFormMetadataUITabs(t),this.setConfig(t),i(t)})).catch((i=>{console.warn(i)}))}))}getEmptyConfig(){return this.buildFormMetadataUITabs({fields:[],emptyConfig:!0},!0)}saveConfig(i){const t=o.copy(i);return new Promise((e=>{g.saveFormConfig(i,this._configName,this._resourceID).then((i=>{this.setConfig(Object.assign(Object.assign({},t),i)),e(Object.assign(Object.assign({},t),i))}))}))}saveCardState(i,t,e){return new Promise((s=>{var n;const o=(null===(n=this._config)||void 0===n?void 0:n.cardsState)||new Map,r=o.get(i);o.set(i,"fixed"===e?this.updateFixSequence(Object.assign(Object.assign({},r),{fixed:t.fixed}),o):Object.assign(Object.assign({},r),{[e]:t[e]})),g.saveCardState(o,this._configName,this._resourceID).then((i=>{this._config=Object.assign(Object.assign({},this._config),{cardsState:o}),s(i)}))}))}updateFixSequence(i,t){let e=-1;return Array.from(t.values()).forEach((t=>{t.fixed||delete i.fixSequence,null!=t.fixSequence&&(e=Math.max(e,t.fixSequence))})),i.fixed?i.fixSequence=e+1:delete i.fixSequence,i}hasConfig(i){var t;const e=null!=i?i:this._config;return!(!e||!(null===(t=e.fields)||void 0===t?void 0:t.length))}getFieldsList(i,t=!1){var e,s;const n=null===(e=this._config)||void 0===e?void 0:e.fields;return this.hasConfig()&&!t?n.map((({label:i,name:t,readOnly:e,visible:s,required:n,tab:o,group:r})=>{var d;if(null==i){const i=null===(d=this._dataUnit)||void 0===d?void 0:d.getField(t);if(!i)return;return Object.assign(Object.assign({},i),{name:null!=t?t:i.name,readOnly:null!=e?e:i.readOnly,visible:null!=s?s:i.visible,required:null!=n?n:i.required,tab:o,group:r})}return{name:t,label:i,readOnly:e,visible:s,required:n,tab:o,group:r}})).filter((t=>this.isFieldVisible(t,i))):this._dataUnit&&(null===(s=this._dataUnit.metadata)||void 0===s?void 0:s.fields)?this._dataUnit.metadata.fields.filter((t=>this.isFieldVisible(t,i))).map((({label:i,name:t,readOnly:e,visible:s,required:n,properties:o})=>({label:i,name:t,readOnly:e,visible:s,required:n,tab:null==o?void 0:o.UITabName}))):[]}isFieldVisible(i,t){if(void 0===i||!1===i.visible)return!1;if(null==t)return!0;const e=r.replaceAccentuatedCharsLower((i.label||i.name).toLocaleLowerCase()),s=r.replaceAccentuatedCharsLower(t.toLocaleLowerCase());return e.includes(s)}getFormConfig(i,t,e=!1){let s=this.getFieldsList(void 0,e);return t&&(s=s.filter((t=>{if(i){const e=i.getField(t.name);if(e&&e.readOnly)return!1}return!t.readOnly}))),Object.assign(Object.assign({},this._config),{fields:s})}setConfig(i){this.isLoaded=!0;const{cardsState:t,summary:e,defaultVars:s}=this._config||{};this._config=Object.assign({},i),t&&(this._config.cardsState=t),e&&(this._config.summary=e),s&&(this._config.defaultVars=s),this._onConfigChange&&this._onConfigChange(Object.assign({},this._config))}getConfig(i,t){return this.getFormConfig(i,t)}getFormConfigFetcher(){return null==this._formConfigFetcher&&(this._formConfigFetcher=new b),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)}parseObjectList(i){return i?Array.isArray(i)?i:[i]:[]}buildFormMetadataUITabs(i,t=!1){var e,s,n;const o=this.hasConfig(i);if(!t&&(!this._dataUnit||o))return i;(i=this.getFormConfig(this._dataUnit,!1,!0)).tabs=this.parseObjectList(i.tabs),i.emptyConfig=!1,i.defaultConfiguration=!0;const r=null!==(s=null===(e=this._dataUnit.metadata)||void 0===e?void 0:e.fields)&&void 0!==s?s:[];for(const t of r){const e=i.fields.find((i=>i.name===t.name)),s=null===(n=t.properties)||void 0===n?void 0:n.UITabName;s&&s!==f.main&&(i.tabs.some((i=>i.label===s))||i.tabs.push({label:s,name:s,order:0,visible:!0}),e&&(e.tab=s))}return i}}const y=class{constructor(e){i(this,e),this.snkMasterFormConfigChange=t(this,"snkMasterFormConfigChange",7),this.formConfigVisibilityChanged=t(this,"formConfigVisibilityChanged",7),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this.resourceID=void 0,this.detailTaskbarCustomContainerId=void 0,this.formLegacyConfigName=void 0,this.enableGridInsert=!1,this.ignoreReadOnlyFormFields=void 0,this.getCustomTitle=void 0,this.customGuidesConfig=[],this._guides=[],this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0,this._fieldToGetFocus=void 0,this._customEditors={},this._customRenders={},this._fieldsProps={},this._mainForm=void 0,this._mainFormName=void 0,this._errorTabs=new Set,this._hasToCreateFieldSearch=!0}observeDataUnit(){this.loadGuides(!0)}async observeFormConfigManager(i){var t,e;const s=!!i;await(null===(t=this._viewStack)||void 0===t?void 0:t.show(s?p.CONFIG:p.GUIDES)),null===(e=this.formConfigVisibilityChanged)||void 0===e||e.emit(s)}observeDataState(i,t){var e,s,n,r,d,l;const a=null!==(s=null===(e=null==i?void 0:i.selectionInfo)||void 0===e?void 0:e.recordIds)&&void 0!==s?s:null===(n=null==i?void 0:i.selectedRecord)||void 0===n?void 0:n.__record__id__,h=null!==(d=null===(r=null==t?void 0:t.selectionInfo)||void 0===r?void 0:r.recordIds)&&void 0!==d?d:null===(l=null==t?void 0:t.selectedRecord)||void 0===l?void 0:l.__record__id__;o.equals(a,h)||this.loadGuides((null==t?void 0:t.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){var i;this.loadGuides(this.noGuideSelected()),null===(i=this.snkMasterFormConfigChange)||void 0===i||i.emit(this.masterFormConfig)}async showFormConfig(i=!1){var t,e;const s=!i||null==this._currentDetail;this._formEditorConfigManager=s?this._configManager:null===(t=this._currentDetail)||void 0===t?void 0:t.formConfigManager,this._formEditorDataUnit=s?this.dataUnit:null===(e=this._currentDetail)||void 0===e?void 0:e.dataUnit}async addCustomEditor(i,t){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:t})}async addGridCustomRender(i,t){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:t})}async setFieldProp(i,t,e){const s={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[t]:e})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),s)}async setFocus(){var i;null===(i=this._container)||void 0===i||i.focus({preventScroll:!0})}async reloadGuides(){this.loadGuides(!1)}exitViewer(){var i,t;!this.enableGridInsert&&(null===(i=this.dataUnit)||void 0===i?void 0:i.isDirty())?this.dataUnit.cancelEdition({after:()=>{var i;return null===(i=this.exit)||void 0===i?void 0:i.emit()}}):null===(t=this.exit)||void 0===t||t.emit()}onActionClick(i){var t;i.detail===k.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(null===(t=this._snkConfigurator)||void 0===t||t.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){this._configManager&&this.dataUnit&&y.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>{var i;return this.masterFormConfig=null===(i=this._configManager)||void 0===i?void 0:i.getConfig(this.dataUnit)}))}getMessage(i){var t,e,s,n,o,r;if(null===(t=this.dataUnit)||void 0===t?void 0:t.isMultipleEdition){const i=null!==(s=null===(e=this.dataUnit.getSelectionInfo())||void 0===e?void 0:e.records)&&void 0!==s?s:[];return null===(n=this.messagesBuilder)||void 0===n?void 0:n.getMessage("snkCrud.multipleEdition.editing",{COUNT:i.length})}return null===(o=this.messagesBuilder)||void 0===o?void 0:o.getMessage(i,null===(r=this.dataUnit)||void 0===r?void 0:r.getSelectedRecord())}loadGuides(i){var t;if(!this.dataUnit||!this._configManager)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=v(this.masterFormConfig,this.dataUnit,!0,this.customGuidesConfig);const e=null===(t=this._masterFormMetadata)||void 0===t?void 0:t.getAllSheets();if(!e)return;const s=this.dataUnit.getSelectedRecord(),n=this.hasToDisableDetails(s),o=[];let r;Array.from(e.values()).forEach((i=>{if((null==i?void 0:i.name)===f.main)return void(r=null==i?void 0:i.name);const t={id:null==i?void 0:i.name,label:null==i?void 0:i.label};this.isDetail(null==i?void 0:i.name)&&n&&(t.tooltip=this.getMessage("snkCrud.detail.tooltip.needSingleSelection"),t.disabled=!0),i.isCustom&&i.ctxProps&&Object.entries(i.ctxProps).forEach((([i,e])=>{void 0!==e&&(t[i]=e)})),t.props||(t.props={}),t.props.isAdditional=i.name.includes("AD_"),t.props.isCustom=!!i.isCustom,o.push(t)})),this._mainFormName=r,this._guides=o;const d=this.selectedGuide&&this._guides.some((i=>i.id===this.selectedGuide.id));!i&&d||(this.selectedGuide=this._guides&&this._guides.length>0?this._guides[0]:void 0)}hasToDisableDetails(i){return!i||!this.dataUnit||this.dataUnit.isNewRecord(i.__record__id__)||this.dataUnit.isMultipleEdition}isDetail(i){return null!=c.getDetailName(i)}buildTabItems(){return this._guides.map(((i,t)=>({tabKey:i.id,label:i.label,index:t,disabled:i.disabled,rightIcon:this._errorTabs.has(i.id)?"alert-circle-inverted":void 0,leftIcon:this.getTabLeftIcon(i)})))}getTabLeftIcon(i){var t,e;return i.icon?i.icon:(null===(t=i.props)||void 0===t?void 0:t.isCustom)||(null===(e=i.props)||void 0===e?void 0:e.isAdditional)?"puzzle-piece":void 0}isCustomGuide(i){var t;return!!i&&!!(null===(t=this.customGuidesConfig)||void 0===t?void 0:t.some((t=>t.id===i)))}onTabChange(i){const t=this._guides.find((t=>t.id===i.tabKey));t&&!t.disabled&&(this.selectedGuide=t)}static updateContentCard(i,t,e,s){return s.saveCardState(i,t,e)}static buildMainForm(i){if(null==i.formMetadata||null==i.mainFormName)return;const t=i.formMetadata.getSheet(i.mainFormName);return null!=t?e("snk-dynaform-form-view",{ref:t=>{var e;return null===(e=i.onMainFormRef)||void 0===e?void 0:e.call(i,t)},label:t.label,name:i.mainFormName,fields:t.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,fieldToFocus:i.fieldToFocus,key:i.mainFormName,onSnkRequestClearFieldToFocus:()=>{var t;return null===(t=i.onRequestClearFieldToFocus)||void 0===t?void 0:t.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps,entityPath:i.entityPath,fieldSearch:i.fieldSearch}):void 0}static buildFixedForms(i){var t;const n=null===(t=i.formConfig)||void 0===t?void 0:t.cardsState;if(null==n||null==i.formMetadata)return;const o=Array.from(n.entries()).filter((([t,e])=>(null==e?void 0:e.fixed)&&t!=i.selectedForm&&t!=i.mainFormName)).sort((([,i],[,t])=>((null==i?void 0:i.fixSequence)||0)-((null==t?void 0:t.fixSequence)||0)));return 0!==o.length?e(s,null,o.map((([t])=>{const s=i.formMetadata.getSheet(t);if(null!=s)return e("snk-dynaform-form-view",{label:s.label,name:t,fields:s.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,fieldToFocus:i.fieldToFocus,key:t,onSnkRequestClearFieldToFocus:()=>{var t;return null===(t=i.onRequestClearFieldToFocus)||void 0===t?void 0:t.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps,entityPath:i.entityPath})}))):void 0}getContent(){var i;if(!this.selectedGuide)return;const t=this.selectedGuide.id;if(this.isCustomGuide(t))return e("slot",{name:t});const s=c.getDetailName(t);if(s)return e("snk-dynaform-detail-view",{ref:i=>{i&&(this._currentDetail=i)},dataUnitName:`${this.entityPath}/${s}`,entityName:s,label:this.selectedGuide.label,key:`detail_${t}`,canEdit:this.canEdit,resourceID:this.resourceID,taskbarCustomContainerId:this.detailTaskbarCustomContainerId,customEditors:this._customEditors,customRenders:this._customRenders,presentationMode:this.presentationMode,messagesBuilder:this.messagesBuilder});if(t===this._mainFormName)return;const n=null===(i=this._masterFormMetadata)||void 0===i?void 0:i.getSheet(t);return n?e("snk-dynaform-form-view",{name:t,label:n.label,fields:n.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,key:t,onSnkRequestClearFieldToFocus:()=>this.clearFieldToFocusHandler(),customEditors:this._customEditors,fieldsProps:this._fieldsProps,fieldSearch:this._fieldSearch,entityPath:this.entityPath}):void 0}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}getConfigViewMode(){return m.GRID}changeConfigViewMode(i){var t,e;this._currentDetail&&(null===(e=(t=this._currentDetail).changeViewMode)||void 0===e||e.call(t,i))}openConfig(i){var t,e,s,n;null===(e=null===(t=this._snkConfigurator)||void 0===t?void 0:t.close)||void 0===e||e.call(t),this._currentDetail&&(i===m.FORM?this.showFormConfig(!0):null===(n=(s=this._currentDetail).configGrid)||void 0===n||n.call(s))}noGuideSelected(){var i;return void 0===this.selectedGuide||f.main===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}addFormLegacyConfigName(){var i;this.formLegacyConfigName&&(null===(i=this._configManager)||void 0===i||i.addFormLegacyConfig(this.formLegacyConfigName))}setMasterFormConfig(i){this.masterFormConfig=i}componentWillLoad(){var i;if(null==this.resourceID)throw new Error(null!==(i=this.getMessage("snkCrud.errors.resourceIDNotProvided"))&&void 0!==i?i:"");this._configManager=new w(this.configName,this.resourceID,this.setMasterFormConfig.bind(this),this.dataUnit),this.addFormLegacyConfigName(),this._configManager.loadConfig()}async dataUnitActionHandler(i){var t,e;switch(i.type){case d.EDITION_CANCELED:case d.DATA_SAVED:(null===(t=this.dataUnit)||void 0===t?void 0:t.isMultipleEdition)&&(this.exitViewer(),this.dataUnit&&(this.dataUnit.isMultipleEdition=!1));break;case d.FIELD_INVALIDATED:const s=this.getGuideName(null===(e=i.payload)||void 0===e?void 0:e.fieldName);s&&(this._errorTabs=new Set([...this._errorTabs,s]));break;case d.METADATA_LOADED:case d.MULTIPLE_EDITION_CHANGED:this.loadGuides(this.noGuideSelected())}}getGuideName(i){var t,e;const s=null===(t=this._masterFormMetadata)||void 0===t?void 0:t.getAllSheets();if(!s)return"";for(const t of s){const s=null===(e=t[1])||void 0===e?void 0:e.fields;if(s)for(const e of s)if(e.name===i)return t[0]}return""}getTitle(){var i,t,e;return null!==(e=null!==(t=null===(i=this.getCustomTitle)||void 0===i?void 0:i.call(this))&&void 0!==t?t:this.getMessage("snkCrud.title"))&&void 0!==e?e:""}getTitleTooltip(){var i;if(null===(i=this.dataUnit)||void 0===i?void 0:i.isMultipleEdition)return this.buildRecordIdsArray()}buildRecordIdsArray(){var i,t,e;const s=null!==(e=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.getSelectionInfo())||void 0===t?void 0:t.records)&&void 0!==e?e:[];if(0===s.length)return"[]";const n=s.map((i=>{var t;return null===(t=this.messagesBuilder)||void 0===t?void 0:t.getMessage("snkCrud.title",i)}));return`[${n.join(", ")}]`}getFieldsSearch(){var i;if(null==this._fieldSearch||this._hasToCreateFieldSearch){this._hasToCreateFieldSearch=!1;const t={label:null!==(i=this.getMessage("snkSimpleCrud.findFields"))&&void 0!==i?i:"Busca de campos",value:"findFields"};this._fieldSearch=h(t,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))}return this._fieldSearch}fieldsOptionLoader(i){var t,e;return Promise.resolve(null!==(e=null===(t=this._configManager)||void 0===t?void 0:t.getFieldsList(i).map((i=>({value:i.name,label:i.label}))))&&void 0!==e?e:[])}onSelectField(i){var t,e,s;if(null==i)return;this._fieldToGetFocus=i.value;const n=this.getGuideName(i.value);if(n)if(n!==this._mainFormName){if(n!==(null===(s=this.selectedGuide)||void 0===s?void 0:s.id)){const i=this._guides.find((i=>i.id===n));i&&!i.disabled&&(this.selectedGuide=i)}}else null===(e=null===(t=this._mainForm)||void 0===t?void 0:t.showUp)||void 0===e||e.call(t)}componentDidLoad(){var i;null===(i=this.dataUnit)||void 0===i||i.subscribe(this.dataUnitActionHandler.bind(this)),this.initKeyboardManager(),this.getFieldsSearch()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async initKeyboardManager(){this._keyboardManager=new l({propagate:!1,element:this._element}),this._keyboardManager&&this._keyboardManager.bind(u,(async()=>{var i,t;this._mainForm&&await(null===(t=(i=this._mainForm).showSearchField)||void 0===t?void 0:t.call(i))}),{description:this.getMessage("snkSimpleCrud.findFields"),element:this._element})}render(){var i,t,s;if(null!=this._formEditorConfigManager)return e("snk-dynaform-form-config",{ref:i=>{i&&(this._container=i)},tabindex:-1,dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=void 0});if(!this.dataUnit||!(null===(i=this._configManager)||void 0===i?void 0:i.isLoaded))return;const n=this._guides&&this._guides.length>0,o={formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(t=this.selectedGuide)||void 0===t?void 0:t.id,mainFormName:this._mainFormName,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps,entityPath:this.entityPath,fieldSearch:this._fieldSearch,onMainFormRef:i=>{this._mainForm=i}};return e("section",{class:"snk-guides-viewer",ref:i=>{i&&(this._container=i)},tabindex:-1},this.getTitle()&&e("div",{class:"ez-row snk-guides-viewer__header"},e("div",{class:"snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center",key:"header"},e("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},e("h1",{class:"ez-title ez-title--primary ez-title--xlarge",title:this.getTitleTooltip()},this.getTitle())))),e("div",{class:"snk-guides-viewer__container"},y.buildMainForm(o),n&&e("ez-tabselector",Object.assign({class:"snk-guides-viewer__tabselector",tabs:this.buildTabItems(),selectedTab:null===(s=this.selectedGuide)||void 0===s?void 0:s.id,onEzChange:i=>this.onTabChange(i.detail)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("tabselector")}`})),e("div",{class:"snk-guides-viewer__detail-container"},y.buildFixedForms(o),this.getContent())),e("snk-configurator",{ref:i=>{i&&(this._snkConfigurator=i)},viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail),resourceID:this.resourceID}))}get _element(){return n(this)}static get watchers(){return{dataUnit:["observeDataUnit"],_formEditorConfigManager:["observeFormConfigManager"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};var p;!function(i){i[i.GUIDES=0]="GUIDES",i[i.CONFIG=1]="CONFIG"}(p||(p={})),y.style=".sc-snk-dynaform-guides-view-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-small:var(--space--2xs, 8px);--snk-guides-viewer__header--min-height:68px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);display:block;height:100%;min-width:0;overflow-x:hidden}snk-dynaform-form-view.sc-snk-dynaform-guides-view{width:100%}.snk-guides-viewer.sc-snk-dynaform-guides-view{position:relative;display:flex;flex-direction:column;height:100%;overflow:hidden;padding:0px}.snk-guides-viewer__detail-container.sc-snk-dynaform-guides-view{display:flex;row-gap:24px;flex-direction:column;flex:1;max-height:none;min-height:0;overflow:hidden;margin-bottom:var(--space--12, 12px)}.snk-guides-viewer__container.sc-snk-dynaform-guides-view>snk-dynaform-form-view.sc-snk-dynaform-guides-view{max-height:300px;min-height:0;overflow-y:auto}.snk-guides-viewer__detail-container.sc-snk-dynaform-guides-view>snk-dynaform-form-view.sc-snk-dynaform-guides-view,.snk-guides-viewer__detail-container.sc-snk-dynaform-guides-view>snk-dynaform-detail-view.sc-snk-dynaform-guides-view{flex:1;min-height:0;overflow-y:auto}.snk-guides-viewer__header.sc-snk-dynaform-guides-view{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);padding:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__header-breadcrumb.sc-snk-dynaform-guides-view{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-dynaform-guides-view{width:75%}.snk-guides-viewer__container.sc-snk-dynaform-guides-view{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;overflow:hidden}.snk-guides-viewer__tabselector.sc-snk-dynaform-guides-view{width:100%;min-width:0;box-sizing:border-box;padding:0 var(--space--12, 12px);flex-shrink:0}";export{y as S,w as a}
@@ -0,0 +1 @@
1
+ import{r as i,i as t,h as s,f as e,g as o,e as a}from"./p-2c9d0870.js";import{Action as n,StringUtils as r,KeyboardManager as d,ObjectUtils as h,ApplicationContext as l}from"@sankhyalabs/core";import{S as c,a as u}from"./p-77c26de0.js";import{buildFormMetadata as v,FormMetadata as f,buildFormConfigFromDataUnit as m}from"@sankhyalabs/ezui/dist/collection/utils/form";import{S as g}from"./p-5d02c032.js";import"./p-b1bf9564.js";import{P as p}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-f076d742.js";import"./p-ff1990ad.js";import{U as b}from"./p-d88278f8.js";import{V as y,a as k,G as w}from"./p-9019a32f.js";import{T as C}from"./p-3072136e.js";import{buildFieldSearch as S,SHORTCUT_SEARCH_FIELD as x,ApplicationUtils as _}from"@sankhyalabs/ezui/dist/collection/utils";import{S as F,D as A,g as T}from"./p-6b8a1ec3.js";import{b as z,a as D,c as G,d as E,g as L,u as N,e as M}from"./p-46d7e2de.js";import"./p-51e853f2.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-a73b6b00.js";const I=class{constructor(t){i(this,t),this._taskbarProcessor=new F(A),this._currentView=0,this.attachmentRegisterKey=void 0,this._fieldToGetFocus=void 0,this._hasToCreateFieldSearch=!0,this._selectedSheet=void 0,this._internalErrorTabs=new Set,this._selectedRecordPKDisplay=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.resourceID=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.customEditors=void 0,this.customRenders=void 0,this.presentationMode=p.SECONDARY}observeDataUnit(i,t){null==i||i.subscribe(this.dataUnitActionHandler.bind(this)),null==t||t.unsubscribe(this.dataUnitActionHandler)}observerDataState(i,t){const s=!(null==t?void 0:t.insertionMode)&&(null==i?void 0:i.insertionMode),e=(null==t?void 0:t.insertionMode)&&!(null==i?void 0:i.insertionMode);(s||e)&&this.loadMetadata(),null!=this._formMetadata&&(this.selectedSheetIsDetail()||(s&&setTimeout((()=>{this.changeViewMode(y.FORM)}),0),e&&this.changeViewMode(y.GRID)))}async changeViewMode(i){this._viewStack&&(this._viewStack.show(i),this._currentView=i)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}async addCustomEditor(i,t){var s,e;const o=this.normalizeDataUnitName();null===(s=this._snkGrid)||void 0===s||s.addCustomEditor(i,t,o),null===(e=this._snkFormView)||void 0===e||e.addCustomEditor(i,t,o)}async observerPropsCustomEditor(i){for(const t in i)await this.addCustomEditor(t,i[t])}async addGridCustomRender(i,t){var s;const e=this.normalizeDataUnitName();await(null===(s=this._snkGrid)||void 0===s?void 0:s.addGridCustomRender(i,t,e))}onContentCardChanged(i){c.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this.formConfigManager).then((()=>t(this))),i.stopPropagation()}async observeCustomRenders(i){for(const t in i){const s=i[t];await this.addGridCustomRender(t,s)}}loadMetadata(){if(!this.dataUnit||!this.formConfigManager)return;if(!this.formConfigManager.isLoaded)return;const i=this.formConfigManager.getConfig(this.dataUnit);this._formMetadata=v(null==i||0===i.fields.length?void 0:i,this.dataUnit,!0),this.initSelectedSheet()}initSelectedSheet(){if(!this._formMetadata)return void(this._selectedSheet=void 0);const i=this._formMetadata.getAllSheets();if(i&&0!==i.size){if(this._selectedSheet&&this._selectedSheet.name!==I.MAIN_TAB){const t=i.get(this._selectedSheet.name);if(t)return void(this._selectedSheet=t)}this._selectedSheet=this.getFirstNonMainSheet(i)}else this._selectedSheet=void 0}getFirstNonMainSheet(i){for(const[t,s]of i)if(t!==I.MAIN_TAB)return s}dataUnitReadyHandler(i){this.dataUnit=i.detail,this.loadMetadata()}getFormFields(){var i,t,s;const e=null===(t=null===(i=this._formMetadata)||void 0===i?void 0:i.getAllSheets())||void 0===t?void 0:t.get(I.MAIN_TAB);return null!==(s=null==e?void 0:e.fields)&&void 0!==s?s:[]}hasNonMainSheets(){if(!this._formMetadata)return!1;for(const i of this._formMetadata.getAllSheets().keys())if(i!==I.MAIN_TAB)return!0;return!1}selectedSheetIsDetail(){return!!this._selectedSheet&&null!=f.getDetailName(this._selectedSheet.name)}isSheetDisabled(i){var t;if(null==f.getDetailName(i.name))return!1;const s=null===(t=this.dataUnit)||void 0===t?void 0:t.getSelectedRecord();return!s||!this.dataUnit||this.dataUnit.isNewRecord(s.__record__id__)||this.dataUnit.isMultipleEdition}buildInternalTabItems(){return this._formMetadata?Array.from(this._formMetadata.getAllSheets().values()).filter((i=>i.name!==I.MAIN_TAB)).map(((i,t)=>({tabKey:i.name,label:i.label,index:t,disabled:this.isSheetDisabled(i),rightIcon:this._internalErrorTabs.has(i.name)?"alert-circle-inverted":void 0}))):[]}onInternalTabChange(i){var t,s;if(i.tabKey===I.MAIN_TAB)return;const e=null===(s=null===(t=this._formMetadata)||void 0===t?void 0:t.getAllSheets())||void 0===s?void 0:s.get(i.tabKey);e&&!this.isSheetDisabled(e)&&(this._selectedSheet=e)}executeActionHandler(i){var t;i.detail===C.GRID_MODE&&(this.changeViewMode(y.GRID),i.stopPropagation()),i.detail===C.UPDATE_MULTIPLE&&this.dataUnit&&(this.dataUnit.isMultipleEdition=!0,this.changeViewMode(y.FORM),i.stopPropagation()),i.detail!==C.FORM_MODE&&i.detail!==C.UPDATE&&i.detail!==C.INSERT||(this.changeViewMode(y.FORM),i.stopPropagation()),i.detail===C.ATTACH&&(null===(t=this._snkAttach)||void 0===t||t.open(),i.stopPropagation())}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:i})=>i)).join("_")}async handleDataStateChange({detail:i}){var t;this.dataState=i,void 0!==i.selectedRecord&&this._snkDataUnit&&(this.attachmentRegisterKey=null!==(t=await this.getAttachmentRegisterKey())&&void 0!==t?t:void 0),this._selectedRecordPKDisplay=this.buildSelectedRecordPKDisplay()}buildSelectedRecordPKDisplay(){var i,t,s,e,o,a,n;if(!this.dataUnit)return;if(null===(i=this.dataState)||void 0===i?void 0:i.insertionMode){const i=null===(t=this.messagesBuilder)||void 0===t?void 0:t.getMessage("snkCrud.newRecord");return i?{message:i}:void 0}const r=this.dataUnit.getSelectedRecord();if(!r)return;const d=[],h=null!==(e=null===(s=this.dataUnit.metadata)||void 0===s?void 0:s.fields)&&void 0!==e?e:[];for(const i of h){if("true"!==(null===(o=i.properties)||void 0===o?void 0:o.isPrimaryKey))continue;const t=r[i.name],s=null!==(a=null==t?void 0:t.value)&&void 0!==a?a:t;null!=s&&""!==s&&d.push({label:null!==(n=i.label)&&void 0!==n?n:i.name,value:String(s)})}return d.length?{items:d}:void 0}renderSelectedRecordHeader(){var i;if(!this.label&&!this._selectedRecordPKDisplay)return;const t=this._selectedRecordPKDisplay;if(t){if(t.message)return s("div",{class:"selected-record-header selected-record-header--message"},s("span",{class:"selected-record-header__message"},t.message));if(null===(i=t.items)||void 0===i?void 0:i.length)return s("div",{class:"selected-record-header",role:"group"},t.items.map(((i,t)=>[t>0&&s("span",{class:"selected-record-header__separator","aria-hidden":"true"}),s("div",{class:"selected-record-header__chip"},s("span",{class:"selected-record-header__label"},i.label,":"),s("span",{class:"selected-record-header__value"},i.value))])))}}componentWillLoad(){var i;this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new u(this._configName,null!==(i=this.resourceID)&&void 0!==i?i:"",(()=>this.loadMetadata()),this.dataUnit),this.formConfigManager.loadConfig(),null==this.messagesBuilder&&(this.messagesBuilder=new g(this.entityName))}componentWillRender(){this.initializeTaskbarProcessor()}initializeTaskbarProcessor(){if(!this.dataState)return;const i=this.buildDetailTaskbarManager(),t=T(this.dataState,this.presentationMode);this._taskbarProcessor.process(t,i,this.dataState,[],[])}buildDetailTaskbarManager(){const i=[C.CANCEL,C.SAVE],t=this._currentView;return{getButtons:(s,e,o)=>{var a,n,r;if(!s)return[];if((null==e?void 0:e.insertionMode)||(null==e?void 0:e.isDirty))return i;let d=[...o];if(t===y.FORM){const i=d.indexOf(C.FORM_MODE);i>-1&&(d=[...d.slice(0,i),C.GRID_MODE,...d.slice(i+1)])}if((null!==(r=null===(n=null===(a=null==e?void 0:e.selectionInfo)||void 0===a?void 0:a.records)||void 0===n?void 0:n.length)&&void 0!==r?r:0)>1){const i=d.indexOf(C.UPDATE);i>-1&&(d=[...d.slice(0,i),C.UPDATE_MULTIPLE,...d.slice(i+1)])}return d},isEnabled:(i,t,s,e)=>t?!(void 0===t.selectedRecord&&[C.UPDATE,C.REMOVE,C.ATTACH,C.CLONE].includes(s))&&!(s===C.PREVIOUS&&!t.hasPrevious)&&!(s===C.NEXT&&!t.hasNext)&&(s!==C.INSERT||!t.insertionMode)&&e:e}}async componentDidLoad(){this.customEditors&&await this.observerPropsCustomEditor(this.customEditors),this.customRenders&&await this.observeCustomRenders(this.customRenders),this.initKeyboardManager()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async dataUnitActionHandler(i){var t;if(i.type===n.FIELD_INVALIDATED){const s=this.findSheetOfField(null===(t=i.payload)||void 0===t?void 0:t.fieldName);s&&(this._internalErrorTabs=new Set([...this._internalErrorTabs,s]))}}findSheetOfField(i){var t;if(!i||!this._formMetadata)return;const s=this._formMetadata.getAllSheets();for(const[e,o]of s)if(null===(t=o.fields)||void 0===t?void 0:t.some((t=>t.name===i)))return e}normalizeDataUnitName(){var i,t;return null!==(t=null===(i=this.dataUnitName)||void 0===i?void 0:i.replace(/\//g,">"))&&void 0!==t?t:""}getSettingsListForm(){var i,t;return[{value:r.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkCrud.findColumn",void 0))&&void 0!==t?t:"",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getFieldsSearch(t)}]}getFieldsSearch(i){var t;return(void 0===this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._fieldSearch=S(i,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))),null!==(t=this._fieldSearch)&&void 0!==t?t:document.createElement("div")}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;if(i)return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>{if(i)return{value:i.name,label:i.label}}));return Promise.resolve(s)}onSelectField(i){null!=i&&(this._fieldToGetFocus=i.value)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}getColumnSearch(i){var t;return void 0!==this._columnSearch?this._columnSearch:(this._columnSearch=S(i,(({argument:i})=>new Promise((t=>{var s;null===(s=this._snkGrid)||void 0===s||s.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(i=>{var t;null!=i&&(null===(t=this._snkGrid)||void 0===t||t.locateColumn(i.value))})),null!==(t=this._columnSearch)&&void 0!==t?t:document.createElement("div"))}buildTaskbarCustomActionsList(){return[this.buildSearchColumnTaskbarAction()]}buildSearchColumnTaskbarAction(){var i,t;return{value:r.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkGrid.findColumn",{}))&&void 0!==t?t:"",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>{var s;return null!==(s=this.getColumnSearch(t))&&void 0!==s?s:document.createElement("div")}}}async initKeyboardManager(){var i;this._keyboardManager=new d({propagate:!1,element:this._element}),this._keyboardManager.bind(x,(async()=>{var i;await(null===(i=this._snkFormView)||void 0===i?void 0:i.showSearchField())}),{description:null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.findFields"),element:this._element})}renderTabSelector(){if(!this.hasNonMainSheets())return;const i=this._selectedSheet&&this._selectedSheet.name!==I.MAIN_TAB?this._selectedSheet.name:void 0;return s("ez-tabselector",{class:"ez-tabselector-internal",tabs:this.buildInternalTabItems(),selectedTab:i,onEzChange:i=>this.onInternalTabChange(i.detail)})}renderSelectedSheetContent(){if(!this._selectedSheet||this._selectedSheet.name===I.MAIN_TAB)return;const i=f.getDetailName(this._selectedSheet.name);return i?s("snk-dynaform-detail-view",{key:`sub_${this.dataUnitName}_${this._selectedSheet.name}`,dataUnitName:`${this.dataUnitName}/${i}`,entityName:i,label:this._selectedSheet.label,resourceID:this.resourceID,canEdit:this.canEdit,messagesBuilder:this.messagesBuilder,customEditors:this.customEditors,customRenders:this.customRenders,presentationMode:this.presentationMode,taskbarCustomContainerId:this.taskbarCustomContainerId}):s("snk-dynaform-form-view",{key:`sheet_${this._selectedSheet.name}`,name:this._selectedSheet.name,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this._selectedSheet.fields,fieldToFocus:this._fieldToGetFocus,label:this._selectedSheet.label,onSnkRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),fieldSearch:this._fieldSearch})}renderViewStack(){var i,t;return s("ez-view-stack",{ref:i=>this._viewStack=i},s("stack-item",{class:"ez-size-width--full ez-size-height--full"},s("snk-grid",{class:"ez-size-width--full ez-size-height--full",ref:i=>{i&&(this._snkGrid=i)},configName:this._configName,messagesBuilder:this.messagesBuilder,onGridDoubleClick:()=>this.changeViewMode(y.FORM),onActionClick:i=>this.executeActionHandler(i),presentationMode:this.presentationMode,canEdit:this.canEdit,isDetail:!0,taskbarCustomContainerId:this.taskbarCustomContainerId,gridHeaderCustomSlotId:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS",topTaskbarCustomSlotId:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS",outlineMode:!0,enableGridInsert:!0,autoLoad:!0,multipleEditionEnabled:!0,multipleSelection:!0,hideHeader:!0,hideGridTaskbar:!0})),s("stack-item",{class:"ez-size-width--full ez-size-height--full grid-container"},s("div",{class:"form-and-detail-container"},s("snk-dynaform-form-view",{ref:i=>{i&&(this._snkFormView=i)},name:I.MAIN_TAB,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),fieldToFocus:this._fieldToGetFocus,label:this.label,onSnkRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),fieldSearch:this._fieldSearch},this.renderSelectedRecordHeader()),this.renderTabSelector(),this.renderSelectedSheetContent())),s("snk-attach",{ref:i=>this._snkAttach=i,registerKey:null!==(i=this.attachmentRegisterKey)&&void 0!==i?i:"",messagesBuilder:this.messagesBuilder,entityName:null!==(t=this.entityName)&&void 0!==t?t:""}))}render(){return s(e,null,s("snk-data-unit",{ref:i=>{i&&(this._snkDataUnit=i)},dataUnitName:`${this.dataUnitName}`,onDataUnitReady:i=>this.dataUnitReadyHandler(i),entityName:this.entityName,onDataStateChange:this.handleDataStateChange.bind(this),ignoreSaveMessage:this._currentView===y.GRID,messagesBuilder:this.messagesBuilder,configName:this._configName},s("snk-taskbar",{key:"detailViewTaskbar",class:"form-taskbar","data-element-id":"detail_top",configName:this._configName,messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,primaryButton:"INSERT",overflowStrategy:"hiddenItems",alignRigth:!0,sizeButtons:"small",presentationMode:this.presentationMode,onActionClick:i=>this.executeActionHandler(i),dataUnit:this.dataUnit,resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:"DETAIL_TASKBAR_CUSTOM_ELEMENTS",actionsSettingsList:this.getSettingsListForm(),customActionsList:this.buildTaskbarCustomActionsList()},s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})),this.renderViewStack()))}get _element(){return o(this)}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observerDataState"],customEditors:["observerPropsCustomEditor"],customRenders:["observeCustomRenders"]}}};I.MAIN_TAB="__main",I.style=".sc-snk-dynaform-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%;overflow:hidden}.level-path.sc-snk-dynaform-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.grid-container.sc-snk-dynaform-detail-view{min-height:100px;height:100%;width:100%;display:flex;flex-wrap:wrap;text-decoration:none;border-radius:var(--border--radius-medium);background-color:var(--color--gray-70, #FFFFFF);border:1px solid var(--color--petroleum-100, #C8CCD3)}.detail-header.sc-snk-dynaform-detail-view{padding-bottom:0}snk-data-unit.sc-snk-dynaform-detail-view{flex:1;gap:var(--space--12, 12px);display:flex;flex-direction:column}snk-grid.sc-snk-dynaform-detail-view{height:100%;--snk-grid-margin:0px;--snk-grid-box-shadow:none}.form-and-detail-container.sc-snk-dynaform-detail-view{display:flex;flex-direction:column;height:100%;width:100%;overflow:auto;padding:var(--space--12, 12px)}.ez-tabselector-internal.sc-snk-dynaform-detail-view{margin:var(--space--8, 8px) 0}.selected-record-header.sc-snk-dynaform-detail-view{display:flex;align-items:center;flex-wrap:wrap;gap:var(--space--8, 8px) var(--space--12, 12px);padding:var(--space--12, 12px) var(--space--16, 16px);margin-bottom:var(--space--12, 12px);background:var(--color--gray-80, #F9F9F9);border-radius:var(--border--radius-12, 12px);font-family:var(--font--pattern);border:1px solid var(--color--petroleum-100, #C8CCD3);border-left:4px solid var(--color--ocean-green-500, #00B07E)}.selected-record-header--message.sc-snk-dynaform-detail-view{border-left-color:var(--color--primary, #007EFF)}.selected-record-header__message.sc-snk-dynaform-detail-view{font-size:var(--font-size--default, 14px);font-weight:var(--font-weight--medium, 500);color:var(--color--title-primary, #2B3A54)}.selected-record-header__chip.sc-snk-dynaform-detail-view{display:inline-flex;flex-direction:row;align-items:center;gap:var(--space--4, 4px);min-width:0}.selected-record-header__label.sc-snk-dynaform-detail-view{font-size:var(--font-size--xs, 11px);font-weight:var(--font-weight--medium, 500);text-transform:uppercase;letter-spacing:0.04em;color:var(--color--text-secondary, #6E7A8A)}.selected-record-header__value.sc-snk-dynaform-detail-view{font-size:var(--font-size--md, 15px);font-weight:var(--font-weight--semibold, 600);color:var(--color--ocean-green-1000, #00281D);line-height:1.2;word-break:break-word}.selected-record-header__separator.sc-snk-dynaform-detail-view{display:inline-block;align-self:stretch;width:1px;background:var(--color--petroleum-100, #C8CCD3);margin:0 var(--space--4, 4px)}";const R=class{constructor(t){i(this,t),this.configClose=a(this,"configClose",7),this.configChange=a(this,"configChange",7),this.guidesMap=new Map,this.availableFields=[],this.guidesList=[],this.groupsList=[],this.mainGuide=void 0,this.mainGroupsList=[],this.selectedGuide=void 0,this._formConfig={},this.configOptions=[],this.originalConfigSelected=void 0,this.configSelected=void 0,this.hasChanges=!1,this.optionConfigChanged=!1,this.dataUnit=void 0,this.configManager=void 0,this.ignoreReadOnlyFormFields=void 0,this.messagesBuilder=void 0,this.customGuidesConfig=[]}handleFieldConfigChanged(){this.hasChanges=!0}async handleFormConfigOptionSelected({detail:i}){this.configSelected=i,this.selectedGuide=void 0,await this.loadConfigByUser(),this.optionConfigChanged=!h.equals(this.configSelected,this.originalConfigSelected),this.configSelected.origin===b.DEFAULT&&(this.hasChanges=!1)}async handleAddFieldToGuide({detail:i}){var t,s;const e=this.selectedGuide&&!this.selectedGuide.isCustom&&!this.selectedGuide.isDetail;e||!this.selectedGuide||!this.selectedGuide.isCustom&&!this.selectedGuide.isDetail?e||this.mainGuide?(this.availableFields=[...this.availableFields.filter((t=>t.name!==i.name))],e?await(null===(t=this.refFieldsLayout)||void 0===t?void 0:t.addFieldToLayout(i)):await(null===(s=this.refMainFieldsLayout)||void 0===s?void 0:s.addFieldToLayout(i))):this.showNoGuideSelectedDialog():this.showCanNotAddFieldToGuideDialog()}async handleSetFieldAsAvailable({detail:i}){this.availableFields.some((t=>t.name===i.name))||(this.availableFields=[...this.availableFields,i])}async handleRemoveFieldFromAvailable({detail:i}){this.availableFields=this.availableFields.filter((t=>t.name!==i.name))}observeSelectedGuide(i){var t,s;if((null==i?void 0:i.name)&&(null===(t=this.mainGuide)||void 0===t?void 0:t.name)&&i.name===this.mainGuide.name)return void(this.selectedGuide=void 0);const e=null!==(s=this.guidesMap.get(null==i?void 0:i.name))&&void 0!==s?s:[];this.groupsList=[...e]}observeConfigManager(){this.loadFormConfig()}showNoGuideSelectedDialog(){const i=this.getMessage("snkFormConfig.noGuideSelected.title"),t=this.getMessage("snkFormConfig.noGuideSelected.message");_.alert(i,t)}showCanNotAddFieldToGuideDialog(){const i=this.getMessage("snkFormConfig.canNotAddFieldToGuide.title"),t=this.getMessage("snkFormConfig.canNotAddFieldToGuide.message");_.alert(i,t)}getMessage(i,t){return this.messagesBuilder.getMessage(i,t)}async initializeUserConfig(){if(null!=this.configManager)try{const i=await this.configManager.fetchUserAvailableConfigs();this.configOptions=i;const t=null==this._formConfig||this._formConfig.defaultConfiguration?b.DEFAULT:b.USER;this.configSelected=null==i?void 0:i.find((i=>i.origin===t)),this.originalConfigSelected=null==i?void 0:i.find((i=>i.origin===t))}catch(i){console.error(this.getMessage("snkFormConfig.errors.failFetchUserConfig")),console.error(i)}}async loadConfigByUser(){this.configManager&&this.configSelected&&(this.isConfigDefaultSelected()?await this.handleLoadDefaultConfig():this.loadFormConfig())}async handleLoadDefaultConfig(){const i=await this.configManager.fetchDefaultConfig();if(i)return void this.loadFormConfig(i);const t=this.configManager.getEmptyConfig();t&&this.loadFormConfig(t)}isConfigDefaultSelected(){return this.configSelected.origin===b.DEFAULT}loadFormConfig(i){this._formConfig=i||this.getConfig(),this.loadGuides(),this.initializeAvailableFields()}initializeAvailableFields(){var i;if(null==(null===(i=this._formConfig)||void 0===i?void 0:i.fields))return;const t=[...this._formConfig.fields];this.availableFields=this.dataUnit.metadata.fields.filter((({name:i,visible:s,properties:e})=>{const o=t.some((({name:t})=>t===i));return o||!0!==e.visibleOnConfig||s?!0===s&&!1===o:e.visibleOnConfig}))}getInitialOrder(i){var t,s;return Array.isArray(null===(t=this._formConfig)||void 0===t?void 0:t.tabs)?null===(s=this._formConfig.tabs)||void 0===s?void 0:s.length:i.length>0?Math.max(...i.map((i=>i.order))):0}loadGuides(){var i,t,s,e;this.guidesList=[],this.guidesList.push(...z(this._formConfig,this.getMessage("snkFormConfig.form.mainArea"),this.dataUnit,k.general)),this.guidesList.push(...D(this.dataUnit,this.getInitialOrder(this.guidesList),this.guidesList)),this.guidesList.push(...G(this.customGuidesConfig,this.guidesList)),this.guidesMap=E(null===(i=this._formConfig)||void 0===i?void 0:i.fields,this.guidesList,this.dataUnit,k.general),this.mainGuide=this.guidesList.find((i=>i.name===k.main)),this.mainGroupsList=(null===(t=this.mainGuide)||void 0===t?void 0:t.name)?[...null!==(e=null===(s=this.guidesMap)||void 0===s?void 0:s.get(this.mainGuide.name))&&void 0!==e?e:[]]:[],this.ensureSelectedGuide()}ensureSelectedGuide(){if(this.selectedGuide&&this.guidesList.some((i=>i.name===this.selectedGuide.name)))return;const i=this.guidesList.filter((i=>{var t;return i.visible&&i.name!==(null===(t=this.mainGuide)||void 0===t?void 0:t.name)})).sort(((i,t)=>{var s,e;return(null!==(s=i.order)&&void 0!==s?s:Number.MAX_VALUE)-(null!==(e=t.order)&&void 0!==e?e:Number.MAX_VALUE)}))[0];this.selectedGuide=i}getConfig(){let i=this.configManager.getConfig(this.dataUnit,!1);return i.fields&&0===i.fields.length&&(i=void 0),null==i&&(i=m(this.dataUnit)),h.copy(i)}handleSelectGuide({detail:i}){this.selectedGuide=i}handleLayoutChanged({detail:i}){this.selectedGuide&&(this.hasChanges=!0,this.groupsList=[...i],this.guidesMap.set(this.selectedGuide.name,[...i]))}handleMainLayoutChanged({detail:i}){var t;(null===(t=this.mainGuide)||void 0===t?void 0:t.name)&&(this.hasChanges=!0,this.mainGroupsList=[...i],this.guidesMap.set(this.mainGuide.name,[...i]))}getIsDefaultConfig(){var i;return(null===(i=this.configSelected)||void 0===i?void 0:i.origin)===b.DEFAULT&&!0===this.optionConfigChanged&&!1===this.hasChanges}getTabsToSave(){return this.guidesList.map((i=>({name:i.name,label:i.name===k.main?i.name:i.label,order:i.name===k.main?0:i.order,visible:i.visible})))}async handleSaveConfig(){var i;const t=await this.configManager.saveConfig(this.buildConfigToSave());this.configSelected=null===(i=this.configOptions)||void 0===i?void 0:i.find((i=>i.origin===(this.hasChanges?b.USER:b.DEFAULT))),this.originalConfigSelected=this.configSelected,this.hasChanges=!1,this.optionConfigChanged=!1,_.info(this.getMessage("snkFormConfig.info.successfullyConfigSaved"),{iconName:"check"}),this.configChange.emit(t)}buildConfigToSave(){const i=h.copy(this._formConfig);return i.tabs=this.getTabsToSave(),i.fields=L(this.guidesMap),i.defaultConfiguration=this.getIsDefaultConfig(),i}handleAvailableFieldListChanged({detail:i}){this.availableFields=[...i]}handleSetFieldListAsAvailable({detail:i}){this.availableFields=[...this.availableFields,...i]}handleGuideDeleted({detail:i}){var t,s;const e=i.name,o=null!==(t=this.guidesMap.get(e))&&void 0!==t?t:[],a=[];o.forEach((i=>a.push(...i.fields))),this.availableFields=[...this.availableFields,...a],this.guidesList=[...this.guidesList.filter((i=>i.name!==e))],this.guidesMap.delete(e),(null===(s=this.selectedGuide)||void 0===s?void 0:s.name)===e&&(this.selectedGuide=void 0,this.ensureSelectedGuide()),this.hasChanges=!0}handleGuideListChanged({detail:i}){this.hasChanges=!0,this.guidesList=[...i]}handleGuideRenamed({detail:i}){var t;const s=this.selectedGuide;if(!(null==s?void 0:s.name))return;const e=s.name,o=null!==(t=this.guidesMap.get(e))&&void 0!==t?t:[],a=N(o,i);this.guidesMap.delete(e),this.guidesMap.set(i,a);const n={name:i,label:i,visible:s.visible,order:s.order};this.guidesList=[...this.guidesList.map((i=>i.name===e?n:i))],this.groupsList=[...a],this.selectedGuide=n,this.hasChanges=!0}handleCreateNewGuide(){const i=M(this.guidesList,this.getMessage.bind(this)),t={name:i,label:i,visible:!0,order:this.guidesList.length+1},s={name:w.noGroup,fields:[]};this.guidesList=[...this.guidesList,t],this.guidesMap.set(i,[s]),this.selectedGuide=t,this.hasChanges=!0}getGuideNames(){return[...this.guidesList.map((i=>i.name.toLowerCase())),this.getMessage("snkFormConfig.form.mainArea").toLowerCase()]}async componentWillRender(){if(null==this.messagesBuilder){const i=l.getContextValue("__SNK__APPLICATION__");this.messagesBuilder=i.messagesBuilder}}async componentWillLoad(){this.loadFormConfig(),await this.initializeUserConfig()}render(){var i;return s(e,null,s("snk-dynaform-config-header",{configOptions:this.configOptions,selectedConfig:this.configSelected,messagesBuilder:this.messagesBuilder,hasChanges:this.hasChanges,optionConfigChanged:this.optionConfigChanged,onConfigClose:()=>this.configClose.emit(),onSaveConfig:async()=>await this.handleSaveConfig()}),s("div",{class:"form-config-body"},s("div",{class:"form-config-layout"},s("snk-dynaform-fields-selector",{dataUnit:this.dataUnit,availableFields:this.availableFields,onFieldListChanged:this.handleAvailableFieldListChanged.bind(this),messagesBuilder:this.messagesBuilder}),s("div",{class:"main-editing-area"},this.mainGuide&&s("div",{class:"main-fields-section"},s("snk-dynaform-fields-layout",{ref:i=>this.refMainFieldsLayout=i,selectedGuide:this.mainGuide,guideNames:this.getGuideNames(),groupsList:this.mainGroupsList,messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,isMainSection:!0,onLayoutChanged:this.handleMainLayoutChanged.bind(this),onSetFieldListAsAvailable:this.handleSetFieldListAsAvailable.bind(this)})),s("snk-dynaform-guides-configurator",{messagesBuilder:this.messagesBuilder,guidesList:this.guidesList,selectedGuide:this.selectedGuide,mainGuideName:null===(i=this.mainGuide)||void 0===i?void 0:i.name,onGuideSelected:this.handleSelectGuide.bind(this),onGuideListChanged:this.handleGuideListChanged.bind(this),onCreateNewGuide:this.handleCreateNewGuide.bind(this),onGuideDeleted:this.handleGuideDeleted.bind(this)}),s("snk-dynaform-fields-layout",{ref:i=>this.refFieldsLayout=i,selectedGuide:this.selectedGuide,guideNames:this.getGuideNames(),groupsList:this.groupsList,messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,onGuideRenamed:this.handleGuideRenamed.bind(this),onLayoutChanged:this.handleLayoutChanged.bind(this),onSetFieldListAsAvailable:this.handleSetFieldListAsAvailable.bind(this)})))))}static get watchers(){return{selectedGuide:["observeSelectedGuide"],configManager:["observeConfigManager"]}}};R.style='.sc-snk-dynaform-form-config-h{display:flex;flex-direction:column;height:100vh;width:100%;font-family:var(--font-pattern, "Roboto");background:white;color:#2b3a54;--snk-form-config-container-height:calc(100vh - 95px);outline:none}.form-config-body.sc-snk-dynaform-form-config{height:var(--snk-form-config-container-height);overflow:hidden;padding-top:var(--space--12, 12px)}.form-config-layout.sc-snk-dynaform-form-config{display:flex;flex-direction:row;height:100%;gap:20px;align-items:stretch}.main-editing-area.sc-snk-dynaform-form-config{display:flex;flex-direction:column;flex:1;min-width:0;height:100%;overflow:hidden;gap:12px}.main-editing-area.sc-snk-dynaform-form-config>snk-dynaform-fields-layout.sc-snk-dynaform-form-config{flex:1 1 auto;min-height:0;overflow:auto;flex-direction:row}.main-editing-area.sc-snk-dynaform-form-config>snk-dynaform-guides-configurator.sc-snk-dynaform-form-config{flex:0 0 auto}.main-fields-section.sc-snk-dynaform-form-config{flex:0 0 40vh;display:flex;flex-direction:column;min-height:0;overflow:hidden}.guide-header.sc-snk-dynaform-form-config{display:flex;width:100%;padding-bottom:12px;border-bottom:1px solid #dce0e8;height:30px;font-weight:500;font-size:16px}';export{I as snk_dynaform_detail_view,R as snk_dynaform_form_config}
@@ -0,0 +1 @@
1
+ import{r as i,e as t,h as s,f as e,g as n}from"./p-2c9d0870.js";import{Action as o,DataUnitAction as a,StringUtils as h,ElementIDUtils as r,ApplicationContext as d,KeyboardManager as l}from"@sankhyalabs/core";import{buildFieldSearch as u}from"@sankhyalabs/ezui/dist/collection/utils";import"./p-5d02c032.js";import"./p-b1bf9564.js";import{P as c,E as v}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-f076d742.js";import"./p-ff1990ad.js";import"./p-d88278f8.js";import{V as m}from"./p-9019a32f.js";import{A as f}from"./p-d5810110.js";import{C as g}from"./p-e5a3711f.js";import{S as p,D as k,C as y,b as C,g as b,a as w}from"./p-6b8a1ec3.js";import{v as S}from"./p-76e66fd9.js";import{S as E}from"./p-cad964b5.js";import{T as _}from"./p-3072136e.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-a73b6b00.js";const T=class{constructor(s){i(this,s),this.snkShowGuide=t(this,"snkShowGuide",7),this.actionClick=t(this,"actionClick",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this.formItemsReady=t(this,"formItemsReady",7),this.viewModeChanged=t(this,"viewModeChanged",7),this.numberingConfigChanged=t(this,"numberingConfigChanged",7),this._viewHistory=[],this._customEditors=new Map,this._customRenders=new Map,this._taskbarProcessor=new p(k),this._taskbarCustomProcessor=new p([]),this.dataUnitInterceptor={interceptAction:async i=>{var t;switch(i.type){case o.DATA_SAVED:return this.interceptDataSaved(i);case o.LOADING_DATA:return null!==(t=await this.interceptLoadData(i))&&void 0!==t?t:new a(o.INVALIDATE_CLEAN);default:return i}}},this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=m.GRID,this._canEdit=void 0,this._resourceID=void 0,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${h.generateUUID()}`,this.numberingConfig=void 0,this._filterMode="regular",this._enableContinuousInsert=!1,this._headerVisible=!0,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.configName=void 0,this.filterBarTitle=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!0,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=c.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.gridLegacyConfigName=void 0,this.filterBarLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.disablePersonalizedFilter=void 0,this.autoLoad=void 0,this.autoFocus=!0,this.enableGridInsert=!1,this.domainMessagesBuilder=void 0,this.ignoreReadOnlyFormFields=void 0,this.setCustomFormTitle=void 0,this.strategyExporter=v.SERVER_SIDE,this.layoutFormConfig=!0,this.multipleEditionEnabled=!0,this.paginationCounterMode="auto",this.customGuidesConfig=[],this.showEntitySearch=!0,this.disableNumberingConfig=!1}handleActionClick(i){this.executeAction(i.detail)}async goToView(i){this.executeAction(i)}async openConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.open()}async closeConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.close()}async reloadFilterBar(){var i;null===(i=this._snkGrid)||void 0===i||i.reloadFilterBar()}async getFilterBar(){var i;return await(null===(i=this._snkGrid)||void 0===i?void 0:i.getFilterBar())}async addCustomEditor(i,t){if(this._guidesViewer&&this._snkGrid)return this._guidesViewer.addCustomEditor(i,t),void this._snkGrid.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async addGridCustomRender(i,t){if(this._snkGrid)return void this._snkGrid.addGridCustomRender(i,t);const s=new Map(this._customRenders);s.set(i,t),this._customRenders=s}async addCustomValueFormatter(i,t){var s;null===(s=this._snkGrid)||void 0===s||s.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){var t;null===(t=this._snkGrid)||void 0===t||t.removeCustomValueFormatter(i)}async setFieldProp(i,t,s){var e;await(null===(e=this._guidesViewer)||void 0===e?void 0:e.setFieldProp(i,t,s))}async getNumberingConfig(){return this.numberingConfig}async updateNumberingConfig(i){this.numberingConfig=i,this.applyNumberingConfigToFields()}currentViewModeWatcher(i){this._viewHistory=[...this._viewHistory.slice(-1),i]}async gridToForm(i=!1){var t;this._backToGrid=!i&&await(null===(t=this._viewStack)||void 0===t?void 0:t.getSelectedIndex())===m.GRID,this.setViewMode(m.FORM)}async executeAction(i){var t,s,e;switch(i){case _.GRID_MODE:return this.setViewMode(m.GRID);case _.FORM_MODE:case _.UPDATE:return this.gridToForm(i!==_.UPDATE);case _.UPDATE_MULTIPLE:return this._dataUnit&&(this._dataUnit.isMultipleEdition=!0),this.setViewMode(m.FORM);case _.CONFIGURATOR:return null===(t=this._snkConfigurator)||void 0===t?void 0:t.open();case _.ATTACH:return null===(s=this._snkAttach)||void 0===s?void 0:s.open();case y.FILTER:return null===(e=this._snkFilterBar)||void 0===e?void 0:e.showFilterModal();case y.ENTITY_SEARCH:return this.openSearchPopover()}}setViewMode(i){var t,s,e,n,o;null===(t=this._viewStack)||void 0===t||t.show(i),this._currentViewMode=i,i===m.GRID?(this._dataUnit&&(this._dataUnit.isMultipleEdition=!1),null===(s=this._snkGrid)||void 0===s||s.setFocus()):i===m.FORM&&(null===(n=null===(e=this._guidesViewer)||void 0===e?void 0:e.setFocus)||void 0===n||n.call(e)),null===(o=this.viewModeChanged)||void 0===o||o.emit(i)}openConfig(i){var t,s,e,n,o,a;null===(s=null===(t=this._snkConfigurator)||void 0===t?void 0:t.close)||void 0===s||s.call(t),i===m.GRID?null===(n=(e=this._snkGrid).showConfig)||void 0===n||n.call(e):i===m.FORM&&(null===(a=(o=this._guidesViewer).showFormConfig)||void 0===a||a.call(o))}addDataElementID(){this._element&&r.addIDInfo(this._element,void 0,{dataUnit:this._dataUnit})}insertionModeHandler(){this.enableGridInsert||this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(m.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:i})=>i)).join("_")}setCustomRenders(){if(this._snkGrid)for(const[i,t]of this._customRenders)this._snkGrid.addGridCustomRender(i,t),this._customRenders.delete(i)}setCustomEditors(){if(this._snkGrid&&this._guidesViewer)for(const[i,t]of this._customEditors)this._guidesViewer.addCustomEditor(i,t),this._snkGrid.addCustomEditor(i,t),this._customEditors.delete(i)}initializeTaskbarProcessor(){if(!this._dataState)return;const i=C(this._currentViewMode,this.taskbarManager,this.messagesBuilder),t=b(this._dataState,this.presentationMode);this._taskbarProcessor.process(t,i,this._dataState,void 0,[]);const s=w(this._dataState,this.presentationMode);this._taskbarCustomProcessor.process(s,this.taskbarManager,this._dataState,void 0,[])}componentWillRender(){this.initializeTaskbarProcessor()}componentDidRender(){this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){var i,t,s,e,n;this._application=d.getContextValue("__SNK__APPLICATION__");let o=null===(i=this._element)||void 0===i?void 0:i.parentElement;for(null===(t=this._application)||void 0===t||t.hasAccess(f.UPDATE,this._resourceID).then((i=>this._canEdit=i));o;){if("SNK-DATA-UNIT"===o.tagName.toUpperCase()){this._snkDataUnit=o,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._snkDataUnit&&this.domainMessagesBuilder&&(this._snkDataUnit.domainMessagesBuilder=this.domainMessagesBuilder),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit():null===(s=this._snkDataUnit)||void 0===s||s.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.initDataUnit()})),null===(e=this._snkDataUnit)||void 0===e||e.addEventListener("dataStateChange",(i=>this.handleDataStateChange(i)));break}o=o.parentElement}this.configName||(this.configName=null===(n=this._application)||void 0===n?void 0:n.configName),this.initContinuousInsertUtils()}componentDidLoad(){this.initKeyboardManager()}disconnectedCallback(){var i;this.removeShortcuts(),null===(i=this._dataUnit)||void 0===i||i.removeInterceptor(this.dataUnitInterceptor)}async handleDataStateChange(i){var t,s,e;this._dataState=i.detail,void 0!==this._dataState.selectedRecord&&(this.attachmentRegisterKey=null!==(t=await this.getAttachmentRegisterKey())&&void 0!==t?t:void 0);const n=await(null===(s=this._snkDataUnit)||void 0===s?void 0:s.getFieldsWithRmPrecision());for(const i of n||[]){if(!i)continue;const t=null===(e=this._dataState.rowMetadata)||void 0===e?void 0:e.getProp("rm_precision",i);(t||0===t)&&(await this.setFieldProp(i,"precision",t),await this.setFieldProp(i,"prettyPrecision",t))}}async initKeyboardManager(){var i,t,s,e,n,o,a,h,r,d;this._keyboardManager=new l({propagate:!1,element:this._element});const u=this._dataUnit||await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getDataUnit());async function c(){const i=document.activeElement,t=i==document.body;t||i.blur(),await(null==u?void 0:u.saveData()),t||null==i.setFocus?t||i.focus():i.setFocus()}this._keyboardManager&&this._keyboardManager.bind("F6",this.toggleView.bind(this),{description:null!==(t=this.getMessage("snkCrud.shortcuts.toggleView"))&&void 0!==t?t:"",element:this._element}).bind("F7",c.bind(this),{description:null!==(s=this.getMessage("snkCrud.shortcuts.saveData"))&&void 0!==s?s:"",element:this._element}).bind("ctrl + \\",c.bind(this),{description:null!==(e=this.getMessage("snkCrud.shortcuts.addRecord"))&&void 0!==e?e:"",element:this._element}).bind("F8",async function(){(null==u?void 0:u.hasNewRecord())||null==u||u.addRecord()}.bind(this),{description:null!==(n=this.getMessage("snkCrud.shortcuts.addRecord"))&&void 0!==n?n:"",element:this._element}).bind("F9",u?null===(o=u.removeSelectedRecords)||void 0===o?void 0:o.bind(u):()=>{},{description:null!==(a=this.getMessage("snkCrud.shortcuts.removeRecord"))&&void 0!==a?a:"",element:this._element}).bind("ctrl + F9",u?u.removeSelectedRecords.bind(u):()=>{},{description:null!==(h=this.getMessage("snkCrud.shortcuts.removeRecord"))&&void 0!==h?h:"",element:this._element}).bind("F5",(async()=>{var i;const t=await(null===(i=this._viewStack)||void 0===i?void 0:i.getSelectedIndex());m.GRID===t&&(null==u||u.loadData())}),{description:null!==(r=this.getMessage("snkCrud.shortcuts.refreshData"))&&void 0!==r?r:"",element:this._element}).bind("Escape",(()=>{(null==u?void 0:u.isDirty())&&(null==u||u.cancelEdition())}),{debounceTime:1e3,description:null!==(d=this.getMessage("snkCrud.shortcuts.cancelAction"))&&void 0!==d?d:"",element:this._element})}getMessage(i,t){if(this.messagesBuilder)return this.messagesBuilder.getMessage(i,t)}async removeShortcuts(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async toggleView(){var i;const t=await(null===(i=this._viewStack)||void 0===i?void 0:i.getSelectedIndex());this.setViewMode(m.GRID===t?m.FORM:m.GRID)}getLastRecordSaved(i){var t;return(null===(t=i.payload)||void 0===t?void 0:t.records.length)?i.payload.records[i.payload.records.length-1]:null}async saveNumberingConfig(){if(!this._snkDataUnit||!this.numberingConfig||!this._servicesNumberingConfig)return;const i={entityName:this._snkDataUnit.entityName,isAutoNum:this.numberingConfig.isAutoNumbering,numInicial:this.numberingConfig.initialNumber};await this._servicesNumberingConfig.saveConfig(i)}updateNumberingConfigAfterInsert(i){var t,s,e;if(!(null===(t=i.payload)||void 0===t?void 0:t.changes.length)||this.disableNumberingConfig||!(null===(s=this.numberingConfig)||void 0===s?void 0:s.isAutoNumbering)||!this._fieldAutoNum)return i;if(!i.payload.changes.some((i=>"INSERT"===i.operation||"COPY"===i.operation)))return i;const n=this.getLastRecordSaved(i);if(n&&n.hasOwnProperty(this._fieldAutoNum)){const i=Number(n[this._fieldAutoNum]);this.numberingConfig.initialNumber=i,this.saveNumberingConfig()}else this.numberingConfig.initialNumber=this.numberingConfig.initialNumber+1;return null===(e=this.numberingConfigChanged)||void 0===e||e.emit(this.numberingConfig),i}interceptDataSaved(i){return this.updateNumberingConfigAfterInsert(i),i}async interceptLoadData(i){var t,s,e,n,o,a,h;if(S(null!==(s=null===(t=this._snkFilterBar)||void 0===t?void 0:t.filterConfig)&&void 0!==s?s:[]))return i;{const i=null!==(n=null===(e=this.messagesBuilder)||void 0===e?void 0:e.getMessage("snkGrid.requiredFiltersNotFilled.title",{}))&&void 0!==n?n:"",t=null!==(a=null===(o=this.messagesBuilder)||void 0===o?void 0:o.getMessage("snkGrid.requiredFiltersNotFilled.message",{}))&&void 0!==a?a:"";await(null===(h=this._application)||void 0===h?void 0:h.error(i,t))}}onDataUnitReady(){var i;null===(i=this._dataUnit)||void 0===i||i.addInterceptor(this.dataUnitInterceptor),this.loadNumberingConfig()}async initDataUnit(){var i,t,s;this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=null===(i=this._snkDataUnit)||void 0===i?void 0:i.messagesBuilder),null==this._resourceID&&(this._resourceID=null===(t=this._snkDataUnit)||void 0===t?void 0:t.resourceID,null==this._resourceID&&(this._resourceID=await(null===(s=this._application)||void 0===s?void 0:s.getResourceID()))),this.onDataUnitReady()}initContinuousInsertUtils(){this._application&&this._resourceID&&(this._continuousInsertUtils=new g(this._application,this._resourceID,this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((i=>this._enableContinuousInsert=i)))}async loadNumberingConfig(){if(!this.numberingConfig&&this._snkDataUnit&&this._snkDataUnit.entityName&&!this.disableNumberingConfig&&this._application){this._servicesNumberingConfig||(this._servicesNumberingConfig=new E(this._application,this._resourceID));try{this.numberingConfig=await this._servicesNumberingConfig.getConfig(this._snkDataUnit.entityName),this.getFieldAutoNum(),this.applyNumberingConfigToFields()}catch(i){console.error("Error loading numbering config in snk-crud:",i),this.numberingConfig={isAutoNumbering:!1,initialNumber:NaN}}}}getFieldAutoNum(){var i;if(this._fieldAutoNum)return;const t=null===(i=this._dataUnit)||void 0===i?void 0:i.metadata.fields.find((i=>{var t;return"true"===(null===(t=i.properties)||void 0===t?void 0:t.isAutoNumField)}));this._fieldAutoNum=(null==t?void 0:t.name)||null}async applyNumberingConfigToFields(){var i;if(!this.numberingConfig||!this._snkDataUnit||!this._fieldAutoNum)return;const t=null===(i=this._dataUnit)||void 0===i?void 0:i.getField(this._fieldAutoNum);t&&(t.readOnly=this.numberingConfig.isAutoNumbering,t.required=!this.numberingConfig.isAutoNumbering)}handleConfiguratorEvent(i,t){var s,e,n;if(i.stopImmediatePropagation(),"SAVE"===t)return null===(s=this._guidesViewer)||void 0===s||s.reloadGuides(),void(null===(e=this.configuratorSave)||void 0===e||e.emit());null===(n=this.configuratorCancel)||void 0===n||n.emit()}renderCustomGuideSlots(){if(this.customGuidesConfig)return this.customGuidesConfig.map((i=>s("slot",{name:i.id})))}getColumnSearch(i){return null!=this._columnSearch||(this._columnSearch=u(i,(({argument:i})=>new Promise((t=>{var s;null===(s=this._snkGrid)||void 0===s||s.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(i=>{var t;null!=i&&(null===(t=this._snkGrid)||void 0===t||t.locateColumn(i.value))}))),this._columnSearch}buildTaskbarCustomActionsList(){return[this.buildSearchColumnTaskbarAction()]}buildSearchColumnTaskbarAction(){var i,t;return{value:h.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkGrid.findColumn",{}))&&void 0!==t?t:"",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>{var s;return null!==(s=this.getColumnSearch(t))&&void 0!==s?s:document.createElement("div")}}}isGridInsertActive(){var i;return this.enableGridInsert&&(null===(i=this._dataUnit)||void 0===i?void 0:i.hasNewRecord())}getActionsList(){var i,t;const s=[];if(this.enableGridInsert&&this._continuousInsertUtils&&s.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert,(()=>{var i;this._enableContinuousInsert=!this._enableContinuousInsert,null===(i=this._continuousInsertUtils)||void 0===i||i.handleSaveConfig(this._enableContinuousInsert)}))),this.isGridInsertActive())return s;if(this._dataState&&this.actionsList&&null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const t=b(this._dataState,this.presentationMode);return s.concat(this.taskbarManager.getMoreOptions(t,null!==(i=this.configName)&&void 0!==i?i:"",this._dataState,this.actionsList))}return s.concat(null!==(t=this.actionsList)&&void 0!==t?t:[])}async openSearchPopover(){var i;if(!this._popoverSearchEntity)return;const t=null===(i=this._element)||void 0===i?void 0:i.querySelector(`[data-taskbar-element="${y.ENTITY_SEARCH}"]`);await this._popoverSearchEntity.showUnder(t)}handleLoadedSearch(i){var t;1===i.detail.length&&(null===(t=this._dataUnit)||void 0===t||t.selectFirst(),this.gridToForm(!0))}renderDynamicSearch(){var i;if(this.showEntitySearch)return s("snk-entity-search",{ref:i=>this._popoverSearchEntity=i,dataUnit:this._dataUnit,entityName:null===(i=this._snkDataUnit)||void 0===i?void 0:i.entityName,messagesBuilder:this.messagesBuilder,onLoaded:i=>this.handleLoadedSearch(i)})}handleFilterConfigUpdated(i){i.length&&(1!==i.length||"PERSONALIZED_FILTER_GROUP"!==i[0].id||(this._filterMode=i[0].groupedItems.length>0?"regular":"button"))}render(){var i,t,n,o,a;if(null!=this._resourceID)return this._snkDataUnit&&(this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===m.GRID&&!this.enableGridInsert),s(e,null,s("header",{class:{"snk-crud--hidden":!this._headerVisible,"snk-crud__header":!0}},s("div",{class:"snk-crud__header-top"},s("snk-taskbar",{"data-element-id":"grid_top",key:"snkGridTopTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,resourceID:this._resourceID,primaryButton:"INSERT",overflowStrategy:"hiddenItems",alignRigth:!0,actionsList:this.getActionsList(),customActionsList:this.buildTaskbarCustomActionsList(),sizeButtons:"medium"})),s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,title:this.filterBarTitle,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:"snk-grid__filter-bar ez-align--top",configName:this.configName,messagesBuilder:this.messagesBuilder,resourceID:this._resourceID,onConfigUpdated:i=>this.handleFilterConfigUpdated(i.detail),disablePersonalizedFilter:this.disablePersonalizedFilter,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,mode:this._filterMode,hideFilterButton:!0,sizeChips:"default"})),s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"crud"},s("stack-item",{class:"snk-crud__grid-stack-item"},s("snk-grid",{ref:i=>this._snkGrid=i,class:"ez-flex ez-flex--column ez-size-height--full ez-size-width--full",filterBarTitle:this.filterBarTitle,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:i=>this.executeAction(i.detail),messagesBuilder:this.messagesBuilder,actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode,recordsValidator:this.recordsValidator,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,canEdit:this._canEdit,resourceID:this._resourceID,disablePersonalizedFilter:this.disablePersonalizedFilter,gridLegacyConfigName:this.gridLegacyConfigName,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,strategyExporter:this.strategyExporter,multipleEditionEnabled:this.multipleEditionEnabled,paginationCounterMode:this.paginationCounterMode,hideHeader:!0,hideGridTaskbar:!0},s("slot",{name:"GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-dynaform-guides-view",{ref:i=>this._guidesViewer=i,customGuidesConfig:this.customGuidesConfig,entityPath:null===(i=this._snkDataUnit)||void 0===i?void 0:i.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(m.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:i=>this.executeAction(i.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form",canEdit:this._canEdit,recordsValidator:this.recordsValidator,resourceID:this._resourceID,detailTaskbarCustomContainerId:this.customContainerId,formLegacyConfigName:this.formLegacyConfigName,enableGridInsert:this.enableGridInsert,getCustomTitle:this.setCustomFormTitle,ignoreReadOnlyFormFields:this.ignoreReadOnlyFormFields,onFormConfigVisibilityChanged:i=>this._headerVisible=!i.detail},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),this.renderCustomGuideSlots(),s("slot",{name:"SnkFormTaskBar"})))),s("snk-attach",{ref:i=>this._snkAttach=i,registerKey:null!==(t=this.attachmentRegisterKey)&&void 0!==t?t:"",messagesBuilder:this.messagesBuilder,entityName:null!==(o=null===(n=this._snkDataUnit)||void 0===n?void 0:n.entityName)&&void 0!==o?o:""}),s("snk-configurator",{ref:i=>this._snkConfigurator=i,entityName:null===(a=this._snkDataUnit)||void 0===a?void 0:a.entityName,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.setViewMode(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showActionButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId,layoutFormConfig:this.layoutFormConfig}),this.renderDynamicSearch(),s("div",{id:`${this.customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}),s("slot",{name:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))}get _element(){return n(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};T.style=".sc-snk-dynaform-h{display:flex;flex-direction:column;height:100%;width:100%;overflow:hidden;scrollbar-gutter:stable both-edges}snk-grid.sc-snk-dynaform{--snk-grid-padding:0 var(--space--6, 6px) var(--space--6, 6px) var(--space--6, 6px)}ez-view-stack.sc-snk-dynaform{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}stack-item.sc-snk-dynaform.sc-snk-dynaform{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}stack-item.sc-snk-dynaform.sc-snk-dynaform>snk-dynaform-guides-view.sc-snk-dynaform{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.snk-crud__header.sc-snk-dynaform{margin-bottom:var(--space--10, 10px)}.snk-crud__grid-stack-item.sc-snk-dynaform{display:flex;flex-direction:column;height:100%;width:100%;padding:0 var(--space--2, 2px)}.snk-crud__header-top.sc-snk-dynaform{display:flex;justify-content:space-between;align-items:center;padding:var(--space--8, 8px);padding-top:var(--space--12, 12px)}.snk-crud--hidden.sc-snk-dynaform{display:none !important}ez-record-navigation.sc-snk-dynaform,ez-grid-pagination.sc-snk-dynaform{margin-bottom:var(--space--8, 8px)}";export{T as snk_dynaform}
@@ -1,4 +1,4 @@
1
- import{UserInterface as e,DataType as t,ApplicationContext as n,ErrorException as i}from"@sankhyalabs/core";import{d as o,D as r}from"./p-2af8aca3.js";function a(e){const t=(n=e.fieldsMetadata)&&n.length?n.map((e=>({name:e.fieldName,label:e.description,dataType:u(e.type),userInterface:l(e),properties:s(e)}))):[];var n;return{label:e.entityDescription,name:e.descriptionField,fields:t}}function s(e){const t={};return t.options=function(e){const t=e.options;if(!t)return;const n=[];return Object.keys(t).forEach((e=>{n.push({label:e,value:t[e]})})),n}(e),t.mask=function(e){const t=e.uiType;return t?String(t).toLowerCase():void 0}(e),t}function l(t){const n=t.options;return n&&Object.keys(n).length>0?e.OPTIONSELECTOR:"D"===t.type?e.DATE:"H"===t.type?e.DATETIME:"T"===t.type?e.TIME:"I"===t.type?e.INTEGERNUMBER:void 0}function u(e){switch(e){case"F":case"I":return t.NUMBER;case"D":case"H":return t.DATE;case"B":return t.OBJECT;default:return t.TEXT}}function c(e){return Object.assign({id:e.codigo,label:`${e.caminho} - ${e.descricao}`,bold:"N"===e.analitico,props:{analitico:"S"===e.analitico}},e.no&&{children:e.no.map(c)})}var d,v,f;!function(e){e[e.GRID=0]="GRID",e[e.CARDS=1]="CARDS",e[e.TREE=2]="TREE"}(d||(d={}));class m{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this._searchListenersByDataUnit=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",o.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
1
+ import{UserInterface as e,DataType as t,ApplicationContext as n,ErrorException as i}from"@sankhyalabs/core";import{d as o,D as r}from"./p-5d02c032.js";function a(e){const t=(n=e.fieldsMetadata)&&n.length?n.map((e=>({name:e.fieldName,label:e.description,dataType:u(e.type),userInterface:l(e),properties:s(e)}))):[];var n;return{label:e.entityDescription,name:e.descriptionField,fields:t}}function s(e){const t={};return t.options=function(e){const t=e.options;if(!t)return;const n=[];return Object.keys(t).forEach((e=>{n.push({label:e,value:t[e]})})),n}(e),t.mask=function(e){const t=e.uiType;return t?String(t).toLowerCase():void 0}(e),t}function l(t){const n=t.options;return n&&Object.keys(n).length>0?e.OPTIONSELECTOR:"D"===t.type?e.DATE:"H"===t.type?e.DATETIME:"T"===t.type?e.TIME:"I"===t.type?e.INTEGERNUMBER:void 0}function u(e){switch(e){case"F":case"I":return t.NUMBER;case"D":case"H":return t.DATE;case"B":return t.OBJECT;default:return t.TEXT}}function c(e){return Object.assign({id:e.codigo,label:`${e.caminho} - ${e.descricao}`,bold:"N"===e.analitico,props:{analitico:"S"===e.analitico}},e.no&&{children:e.no.map(c)})}var d,v,f;!function(e){e[e.GRID=0]="GRID",e[e.CARDS=1]="CARDS",e[e.TREE=2]="TREE"}(d||(d={}));class m{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this._searchListenersByDataUnit=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",o.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
2
2
  $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
3
3
  value
4
4
  label