@sankhyalabs/sankhyablocks 10.1.0-dev.51 → 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 (273) 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-293bc3d2.js → SnkMultiSelectionListDataSource-0bc94d36.js} +71 -24
  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 -229
  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 +16 -11
  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-b4ca3437.js → snk-guides-viewer-3054d541.js} +2 -2
  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-crud/subcomponents/snk-detail-view/snk-detail-view.css +4 -1
  41. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +6 -0
  42. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.css +1 -1
  43. package/dist/collection/components/snk-crud/utils/taskbarUtils.js +14 -0
  44. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +67 -20
  45. package/dist/collection/components/snk-dynaform/interfaces/PropsCustomEditor.js +1 -0
  46. package/dist/collection/components/snk-dynaform/interfaces/PropsCustomRender.js +1 -0
  47. package/dist/collection/components/snk-dynaform/snk-dynaform.css +64 -0
  48. package/dist/collection/components/snk-dynaform/snk-dynaform.js +1657 -0
  49. package/dist/collection/components/snk-dynaform/subcomponents/CardFormResizeObserver.js +26 -0
  50. package/dist/collection/components/snk-dynaform/subcomponents/GuideBuilder.js +51 -0
  51. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.css +112 -0
  52. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.js +992 -0
  53. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.css +64 -0
  54. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.js +588 -0
  55. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-guides-view/snk-dynaform-guides-view.css +98 -0
  56. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-guides-view/snk-dynaform-guides-view.js +1167 -0
  57. package/dist/collection/components/snk-dynaform-form-config/FormConfigHelper.js +325 -0
  58. package/dist/collection/components/snk-dynaform-form-config/SnkFormConfigManager.js +212 -0
  59. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-config-header.css +17 -0
  60. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-config-header.js +236 -0
  61. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-configs-button/snk-dynaform-configs-button.css +41 -0
  62. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-configs-button/snk-dynaform-configs-button.js +170 -0
  63. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-config/snk-dynaform-field-config.css +22 -0
  64. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-config/snk-dynaform-field-config.js +408 -0
  65. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-item.css +88 -0
  66. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-item.js +209 -0
  67. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-fields-layout/snk-dynaform-fields-layout.css +167 -0
  68. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-fields-layout/snk-dynaform-fields-layout.js +655 -0
  69. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-fields-selector/snk-dynaform-fields-selector.css +42 -0
  70. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-fields-selector/snk-dynaform-fields-selector.js +171 -0
  71. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-form-config.css +66 -0
  72. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-form-config.js +557 -0
  73. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-guides-configurator/snk-dynaform-guides-configurator.css +80 -0
  74. package/dist/collection/components/snk-dynaform-form-config/snk-dynaform-guides-configurator/snk-dynaform-guides-configurator.js +326 -0
  75. package/dist/collection/components/snk-grid/snk-grid.css +14 -7
  76. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +22 -4
  77. package/dist/components/ContinuousInsertUtils.js +67 -20
  78. package/dist/components/form-config-fetcher.js +22 -4
  79. package/dist/components/index.d.ts +12 -0
  80. package/dist/components/index.js +12 -0
  81. package/dist/components/snk-crud.js +1 -198
  82. package/dist/components/snk-detail-view2.js +8 -2
  83. package/dist/components/snk-dynaform-config-header.d.ts +11 -0
  84. package/dist/components/snk-dynaform-config-header.js +6 -0
  85. package/dist/components/snk-dynaform-config-header2.js +103 -0
  86. package/dist/components/snk-dynaform-configs-button.d.ts +11 -0
  87. package/dist/components/snk-dynaform-configs-button.js +6 -0
  88. package/dist/components/snk-dynaform-configs-button2.js +76 -0
  89. package/dist/components/snk-dynaform-detail-view.d.ts +11 -0
  90. package/dist/components/snk-dynaform-detail-view.js +6 -0
  91. package/dist/components/snk-dynaform-detail-view2.js +1835 -0
  92. package/dist/components/snk-dynaform-field-config.d.ts +11 -0
  93. package/dist/components/snk-dynaform-field-config.js +6 -0
  94. package/dist/components/snk-dynaform-field-config2.js +605 -0
  95. package/dist/components/snk-dynaform-field-item.d.ts +11 -0
  96. package/dist/components/snk-dynaform-field-item.js +6 -0
  97. package/dist/components/snk-dynaform-field-item2.js +96 -0
  98. package/dist/components/snk-dynaform-fields-layout.d.ts +11 -0
  99. package/dist/components/snk-dynaform-fields-layout.js +6 -0
  100. package/dist/components/snk-dynaform-fields-layout2.js +428 -0
  101. package/dist/components/snk-dynaform-fields-selector.d.ts +11 -0
  102. package/dist/components/snk-dynaform-fields-selector.js +6 -0
  103. package/dist/components/snk-dynaform-fields-selector2.js +104 -0
  104. package/dist/components/snk-dynaform-form-config.d.ts +11 -0
  105. package/dist/components/snk-dynaform-form-config.js +6 -0
  106. package/dist/components/snk-dynaform-form-config2.js +430 -0
  107. package/dist/components/snk-dynaform-form-view.d.ts +11 -0
  108. package/dist/components/snk-dynaform-form-view.js +6 -0
  109. package/dist/components/snk-dynaform-form-view2.js +270 -0
  110. package/dist/components/snk-dynaform-guides-configurator.d.ts +11 -0
  111. package/dist/components/snk-dynaform-guides-configurator.js +6 -0
  112. package/dist/components/snk-dynaform-guides-configurator2.js +173 -0
  113. package/dist/components/snk-dynaform-guides-view.d.ts +11 -0
  114. package/dist/components/snk-dynaform-guides-view.js +6 -0
  115. package/dist/components/snk-dynaform.d.ts +11 -0
  116. package/dist/components/snk-dynaform.js +1003 -0
  117. package/dist/components/snk-grid2.js +1 -1
  118. package/dist/components/taskbarUtils.js +224 -0
  119. package/dist/esm/{ConfigStorage-76872695.js → ConfigStorage-e834d1ea.js} +2 -2
  120. package/dist/esm/{DataFetcher-e60f8d53.js → DataFetcher-5ed0a377.js} +2830 -3
  121. package/dist/esm/FormConfigHelper-efc29480.js +328 -0
  122. package/dist/esm/{ISave-4929c071.js → ISave-5b46d691.js} +1 -1
  123. package/dist/esm/{PersonalizedFilterUtils-d2439a9a.js → PersonalizedFilterUtils-45b5803c.js} +49 -2
  124. package/dist/esm/{SnkFormConfigManager-83f6b22f.js → SnkFormConfigManager-bfd575c2.js} +2 -2
  125. package/dist/esm/{SnkMultiSelectionListDataSource-f6cabd15.js → SnkMultiSelectionListDataSource-9e9166ae.js} +71 -24
  126. package/dist/esm/{auth-fetcher-1a31c1e4.js → auth-fetcher-5283045d.js} +1 -1
  127. package/dist/esm/{dataunit-fetcher-c176e002.js → dataunit-fetcher-3b1ca96e.js} +1 -2
  128. package/dist/esm/{filter-type.enum-f6a8fe23.js → filter-type.enum-62b7fe88.js} +8 -1
  129. package/dist/esm/{form-config-fetcher-b44b2727.js → form-config-fetcher-db1bf140.js} +23 -5
  130. package/dist/esm/index-04f73a26.js +24 -36
  131. package/dist/esm/loader.js +1 -1
  132. package/dist/esm/pesquisa-grid_2.entry.js +4 -5
  133. package/dist/esm/sankhyablocks.js +1 -1
  134. package/dist/esm/snk-actions-button_9.entry.js +5 -6
  135. package/dist/esm/snk-application.entry.js +6 -7
  136. package/dist/esm/snk-attach_11.entry.js +2936 -0
  137. package/dist/esm/snk-crud.entry.js +6 -204
  138. package/dist/esm/snk-data-exporter.entry.js +5 -6
  139. package/dist/esm/{snk-data-unit-d8cfa950.js → snk-data-unit-dfde62cb.js} +2 -2
  140. package/dist/esm/snk-data-unit.entry.js +3 -4
  141. package/dist/esm/snk-detail-view.entry.js +14 -9
  142. package/dist/esm/snk-dynaform-config-header_5.entry.js +731 -0
  143. package/dist/esm/snk-dynaform-detail-view_2.entry.js +933 -0
  144. package/dist/esm/snk-dynaform-field-config_2.entry.js +322 -0
  145. package/dist/esm/snk-dynaform-guides-view-1f1455d6.js +744 -0
  146. package/dist/esm/snk-dynaform-guides-view.entry.js +15 -0
  147. package/dist/esm/snk-dynaform.entry.js +671 -0
  148. package/dist/esm/{snk-expression-group_2.entry.js → snk-expression-group_4.entry.js} +405 -4
  149. package/dist/esm/snk-filter-bar_4.entry.js +5 -8
  150. package/dist/esm/snk-form_2.entry.js +4 -5
  151. package/dist/esm/snk-grid.entry.js +7 -8
  152. package/dist/esm/{snk-guides-viewer-cc37535b.js → snk-guides-viewer-95fefcaa.js} +2 -2
  153. package/dist/esm/snk-guides-viewer.entry.js +5 -6
  154. package/dist/esm/snk-layout-form-config.entry.js +4 -5
  155. package/dist/esm/snk-pesquisa.entry.js +4 -5
  156. package/dist/esm/taskbarUtils-8501d09e.js +225 -0
  157. package/dist/sankhyablocks/p-0dbd53d9.js +1 -0
  158. package/dist/sankhyablocks/{p-f5ad0720.js → p-19d1ca14.js} +1 -1
  159. package/dist/sankhyablocks/{p-ab5e12fa.js → p-1cc4cf61.js} +1 -1
  160. package/dist/sankhyablocks/p-1edd6be6.entry.js +1 -0
  161. package/dist/sankhyablocks/p-22ddc1a5.entry.js +1 -0
  162. package/dist/sankhyablocks/p-24b059ee.entry.js +1 -0
  163. package/dist/sankhyablocks/p-2c00b93d.js +1 -0
  164. package/dist/sankhyablocks/p-3623fddf.entry.js +1 -0
  165. package/dist/sankhyablocks/p-43c94ba5.entry.js +1 -0
  166. package/dist/sankhyablocks/p-449dfe55.entry.js +1 -0
  167. package/dist/sankhyablocks/p-451b5bcc.entry.js +1 -0
  168. package/dist/sankhyablocks/p-46d7e2de.js +1 -0
  169. package/dist/sankhyablocks/{p-3c990841.js → p-51e853f2.js} +1 -1
  170. package/dist/sankhyablocks/p-58709cf9.js +1 -0
  171. package/dist/sankhyablocks/p-589016e2.entry.js +1 -0
  172. package/dist/sankhyablocks/p-5d02c032.js +1 -0
  173. package/dist/sankhyablocks/p-5d50f59a.entry.js +1 -0
  174. package/dist/sankhyablocks/p-61776b68.entry.js +1 -0
  175. package/dist/sankhyablocks/p-6b8a1ec3.js +1 -0
  176. package/dist/sankhyablocks/p-7038cf62.entry.js +1 -0
  177. package/dist/sankhyablocks/{p-771b137e.js → p-70c2ee5c.js} +1 -1
  178. package/dist/sankhyablocks/p-7628e04f.entry.js +1 -0
  179. package/dist/sankhyablocks/p-7798788b.entry.js +1 -0
  180. package/dist/sankhyablocks/p-77c26de0.js +1 -0
  181. package/dist/sankhyablocks/p-7c34a0f7.entry.js +1 -0
  182. package/dist/sankhyablocks/p-a4a0d9b7.entry.js +1 -0
  183. package/dist/sankhyablocks/{p-4f7adf97.js → p-b1bf9564.js} +1 -1
  184. package/dist/sankhyablocks/p-b4c2a99c.entry.js +1 -0
  185. package/dist/sankhyablocks/p-b75af274.entry.js +1 -0
  186. package/dist/sankhyablocks/p-c538bd6c.entry.js +1 -0
  187. package/dist/sankhyablocks/{p-3704bf1b.js → p-d5810110.js} +1 -1
  188. package/dist/sankhyablocks/p-d7fd447e.entry.js +1 -0
  189. package/dist/sankhyablocks/p-d88278f8.js +28 -0
  190. package/dist/sankhyablocks/p-f076d742.js +60 -0
  191. package/dist/sankhyablocks/{p-8fe740b7.entry.js → p-f1ef090f.entry.js} +2 -2
  192. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  193. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +1 -0
  194. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +8 -0
  195. package/dist/types/components/snk-dynaform/interfaces/PropsCustomEditor.d.ts +4 -0
  196. package/dist/types/components/snk-dynaform/interfaces/PropsCustomRender.d.ts +4 -0
  197. package/dist/types/components/snk-dynaform/subcomponents/CardFormResizeObserver.d.ts +1 -0
  198. package/dist/types/components/snk-dynaform/subcomponents/GuideBuilder.d.ts +14 -0
  199. package/dist/types/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.d.ts +158 -0
  200. package/dist/types/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.d.ts +107 -0
  201. package/dist/types/components/snk-dynaform-form-config/FormConfigHelper.d.ts +36 -0
  202. package/dist/types/components/snk-dynaform-form-config/SnkFormConfigManager.d.ts +35 -0
  203. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-config-header.d.ts +23 -0
  204. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-config-header/snk-dynaform-configs-button/snk-dynaform-configs-button.d.ts +19 -0
  205. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-field-item/snk-dynaform-field-config/snk-dynaform-field-config.d.ts +56 -0
  206. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-fields-layout/snk-dynaform-fields-layout.d.ts +74 -0
  207. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-fields-selector/snk-dynaform-fields-selector.d.ts +21 -0
  208. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-form-config.d.ts +95 -0
  209. package/dist/types/components/snk-dynaform-form-config/snk-dynaform-guides-configurator/snk-dynaform-guides-configurator.d.ts +35 -0
  210. package/dist/types/components.d.ts +2403 -1322
  211. package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +1 -0
  212. package/package.json +1 -1
  213. package/react/components.d.ts +12 -0
  214. package/react/components.js +12 -0
  215. package/react/components.js.map +1 -1
  216. package/dist/cjs/SnkMessageBuilder-a9300ebe.js +0 -2833
  217. package/dist/cjs/default-filters-a09bf82b.js +0 -8
  218. package/dist/cjs/index-62760a9c.js +0 -49
  219. package/dist/cjs/index-8d94b7e0.js +0 -7
  220. package/dist/cjs/snk-attach.cjs.entry.js +0 -948
  221. package/dist/cjs/snk-default-filter.cjs.entry.js +0 -77
  222. package/dist/cjs/snk-filter-advanced-mode_3.cjs.entry.js +0 -99
  223. package/dist/cjs/snk-filter-detail.cjs.entry.js +0 -198
  224. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +0 -408
  225. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +0 -109
  226. package/dist/cjs/snk-image-input.cjs.entry.js +0 -160
  227. package/dist/cjs/snk-personalized-filter.cjs.entry.js +0 -358
  228. package/dist/cjs/snk-simple-crud.cjs.entry.js +0 -865
  229. package/dist/esm/SnkMessageBuilder-1eb7a1af.js +0 -2831
  230. package/dist/esm/default-filters-50105e43.js +0 -8
  231. package/dist/esm/index-620ac460.js +0 -7
  232. package/dist/esm/index-8acbae97.js +0 -49
  233. package/dist/esm/snk-attach.entry.js +0 -944
  234. package/dist/esm/snk-default-filter.entry.js +0 -73
  235. package/dist/esm/snk-filter-advanced-mode_3.entry.js +0 -93
  236. package/dist/esm/snk-filter-detail.entry.js +0 -194
  237. package/dist/esm/snk-filter-field-search_2.entry.js +0 -403
  238. package/dist/esm/snk-filter-modal-item.entry.js +0 -105
  239. package/dist/esm/snk-image-input.entry.js +0 -156
  240. package/dist/esm/snk-personalized-filter.entry.js +0 -354
  241. package/dist/esm/snk-simple-crud.entry.js +0 -861
  242. package/dist/sankhyablocks/p-0afc64df.entry.js +0 -1
  243. package/dist/sankhyablocks/p-10f27dc6.entry.js +0 -1
  244. package/dist/sankhyablocks/p-134702f6.entry.js +0 -1
  245. package/dist/sankhyablocks/p-20f03230.entry.js +0 -1
  246. package/dist/sankhyablocks/p-2af8aca3.js +0 -1
  247. package/dist/sankhyablocks/p-33492640.entry.js +0 -1
  248. package/dist/sankhyablocks/p-3870748a.js +0 -28
  249. package/dist/sankhyablocks/p-438a225f.entry.js +0 -1
  250. package/dist/sankhyablocks/p-4d04bc75.entry.js +0 -1
  251. package/dist/sankhyablocks/p-554c0e54.js +0 -1
  252. package/dist/sankhyablocks/p-68c1a093.js +0 -1
  253. package/dist/sankhyablocks/p-6a4b21dd.js +0 -1
  254. package/dist/sankhyablocks/p-6ae7543b.entry.js +0 -1
  255. package/dist/sankhyablocks/p-6e278003.js +0 -60
  256. package/dist/sankhyablocks/p-82bcb4cf.entry.js +0 -1
  257. package/dist/sankhyablocks/p-84345e7a.js +0 -1
  258. package/dist/sankhyablocks/p-95af0bb1.entry.js +0 -1
  259. package/dist/sankhyablocks/p-95b36bd3.entry.js +0 -1
  260. package/dist/sankhyablocks/p-9e77e136.js +0 -1
  261. package/dist/sankhyablocks/p-a905712a.entry.js +0 -1
  262. package/dist/sankhyablocks/p-aff2d081.entry.js +0 -1
  263. package/dist/sankhyablocks/p-b0a357b4.entry.js +0 -1
  264. package/dist/sankhyablocks/p-b568c1d4.js +0 -1
  265. package/dist/sankhyablocks/p-bab4cde4.entry.js +0 -1
  266. package/dist/sankhyablocks/p-cc64239c.entry.js +0 -1
  267. package/dist/sankhyablocks/p-cd00a3d1.entry.js +0 -1
  268. package/dist/sankhyablocks/p-d9ec8c4b.entry.js +0 -1
  269. package/dist/sankhyablocks/p-e8df1dea.entry.js +0 -1
  270. package/dist/sankhyablocks/p-ef9343c3.entry.js +0 -1
  271. package/dist/sankhyablocks/p-f1bbf065.entry.js +0 -1
  272. package/dist/sankhyablocks/p-f4184ce7.js +0 -1
  273. package/dist/sankhyablocks/p-fec88660.entry.js +0 -1
@@ -0,0 +1,2950 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-1894343a.js');
6
+ const core = require('@sankhyalabs/core');
7
+ const DataFetcher = require('./DataFetcher-b3a8075d.js');
8
+ const ISave = require('./ISave-4674c283.js');
9
+ const index$2 = require('./index-e3e39724.js');
10
+ const dataunitFetcher = require('./dataunit-fetcher-bcbc38c0.js');
11
+ const filterItemType_enum = require('./filter-item-type.enum-a7ffdaa6.js');
12
+ const formConfigFetcher = require('./form-config-fetcher-f80dbc3b.js');
13
+ const constants = require('./constants-6d82e405.js');
14
+ const authFetcher = require('./auth-fetcher-0ecc53ff.js');
15
+ const taskbarElements = require('./taskbar-elements-80eddec8.js');
16
+ const filterType_enum = require('./filter-type.enum-b3b388af.js');
17
+ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
18
+ const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
19
+ const ImageUtils = require('./ImageUtils-d6139911.js');
20
+ const PersonalizedFilterUtils = require('./PersonalizedFilterUtils-263e4d24.js');
21
+ const presentationMode = require('./presentationMode-52ec3bdd.js');
22
+ const ConfigStorage = require('./ConfigStorage-4201dd3d.js');
23
+ const index$1 = require('./index-f0fe7e6e.js');
24
+ const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-0bc94d36.js');
25
+ require('@sankhyalabs/ezui/dist/collection/utils/constants');
26
+ require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
27
+ const SnkFormConfigManager = require('./SnkFormConfigManager-c3a49038.js');
28
+ const ContinuousInsertUtils = require('./ContinuousInsertUtils-1ae0c6ac.js');
29
+ require('./PrintUtils-bcaeb82f.js');
30
+ require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils');
31
+ require('@sankhyalabs/core/dist/utils/SortingUtils');
32
+ require('./ResourceIDUtils-5ff86aa7.js');
33
+ require('./GetSelectedRecordsIDsInfo-bd50caf1.js');
34
+ require('./IFetchDataExporterParams-e78ec415.js');
35
+ require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource');
36
+
37
+ const SERVICE$1 = {
38
+ save: "Attach.save",
39
+ delete: "Attach.remove",
40
+ view: "Attach.view",
41
+ repository: "RepositorioArquivoSP.abreArquivo"
42
+ };
43
+ class AttachFetcher {
44
+ constructor(dataUnitName) {
45
+ this.dataUnitName = dataUnitName;
46
+ }
47
+ async save({ dataUnit: dataUnitName, record, updatingFields: fields, operation }) {
48
+ var _a, _b;
49
+ const isInsert = operation == "INSERT";
50
+ const dataBody = isInsert ? fields : record;
51
+ if (!isInsert && (fields === null || fields === void 0 ? void 0 : fields.DESCRICAO) && (fields === null || fields === void 0 ? void 0 : fields.DESCRICAO) !== (record === null || record === void 0 ? void 0 : record.DESCRICAO)) {
52
+ throw new Error(ISave.SaveErrorsEnum.DESCRIPTION_CANNOT_BE_CHANGED);
53
+ }
54
+ const reqBody = {
55
+ "anexo": {
56
+ "codata": isInsert ? fields === null || fields === void 0 ? void 0 : fields.REGISTER_KEY : record === null || record === void 0 ? void 0 : record.CODATA,
57
+ "sequencia": (dataBody === null || dataBody === void 0 ? void 0 : dataBody.SEQUENCIA) || "0",
58
+ "tipo": (dataBody === null || dataBody === void 0 ? void 0 : dataBody.TIPO) || "N",
59
+ "descricao": dataBody === null || dataBody === void 0 ? void 0 : dataBody.DESCRICAO,
60
+ "arquivo": (_b = (_a = fields.CAMINHO_ARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name,
61
+ "ehInclusao": isInsert ? "S" : "N",
62
+ "ehArquivoRepositorio": "N"
63
+ }
64
+ };
65
+ return new Promise((resolve, reject) => {
66
+ DataFetcher.DataFetcher.get().callServiceBroker(SERVICE$1.save, JSON.stringify(reqBody))
67
+ .then(result => {
68
+ var _a;
69
+ return resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { __owner__dataunit__name__: (_a = this.dataUnitName) !== null && _a !== void 0 ? _a : dataUnitName })]);
70
+ })
71
+ .catch(error => reject(error));
72
+ });
73
+ }
74
+ async edit(change) {
75
+ throw new Error("Method not implemented.");
76
+ }
77
+ async delete(record) {
78
+ var request = {
79
+ anexo: {
80
+ codata: record.CODATA,
81
+ tipo: record.TIPO,
82
+ descricao: record.DESCRICAO,
83
+ }
84
+ };
85
+ const result = await DataFetcher.DataFetcher.get().callServiceBroker(SERVICE$1.delete, JSON.stringify(request));
86
+ return Promise.resolve(result);
87
+ }
88
+ async getDownloadKey(record) {
89
+ var _a, _b, _c;
90
+ if (record.EHARQUIVOREPOSITORIO == 'S') {
91
+ const request = {
92
+ config: {
93
+ path: record.ARQUIVO,
94
+ tipoconteudo: record.TIPOCONTEUDO
95
+ }
96
+ };
97
+ const result = await DataFetcher.DataFetcher.get().callServiceBroker(SERVICE$1.repository, JSON.stringify(request));
98
+ return Promise.resolve({
99
+ chave: {
100
+ valor: (_b = (_a = result === null || result === void 0 ? void 0 : result.responseBody) === null || _a === void 0 ? void 0 : _a.chave) === null || _b === void 0 ? void 0 : _b.valor
101
+ }
102
+ });
103
+ }
104
+ const criteria = {
105
+ anexo: {
106
+ codata: record.CODATA,
107
+ codemp: record.CODEMP,
108
+ sequencia: record.SEQUENCIA,
109
+ tipo: record.TIPO,
110
+ descricao: record.DESCRICAO,
111
+ tipoConteudo: record.TIPOCONTEUDO
112
+ }
113
+ };
114
+ const result = await DataFetcher.DataFetcher.get().callServiceBroker(SERVICE$1.view, JSON.stringify(criteria));
115
+ if (result === null || result === void 0 ? void 0 : result.chaveAnexo) {
116
+ return Promise.resolve({
117
+ chave: {
118
+ valor: (_c = result === null || result === void 0 ? void 0 : result.chaveAnexo) === null || _c === void 0 ? void 0 : _c.idChaveAnexo
119
+ }
120
+ });
121
+ }
122
+ return Promise.reject(new Error("File not found."));
123
+ }
124
+ }
125
+
126
+ const SERVICE = {
127
+ save: "AnexoSistemaSP.salvar",
128
+ delete: "AnexoSistemaSP.excluir",
129
+ download: "AnexoSistemaSP.baixar",
130
+ };
131
+ class AnexoSistemaFetcher {
132
+ constructor(entityName, dataUnitName) {
133
+ var _a;
134
+ this.entityName = entityName;
135
+ this.dataUnitName = dataUnitName;
136
+ this.validateFields = (fields) => {
137
+ if (!!fields.LINK && !!fields.NOMEARQUIVO)
138
+ throw new Error(ISave.SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME);
139
+ if (!fields.LINK && !fields.NOMEARQUIVO)
140
+ throw new Error(ISave.SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED);
141
+ if (!this._registerKey)
142
+ throw new Error('Register key can not be null');
143
+ };
144
+ this.resourceID = (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID));
145
+ }
146
+ set registerKey(registerKey) {
147
+ this._registerKey = registerKey;
148
+ }
149
+ async save(change) {
150
+ var _a, _b;
151
+ let { updatingFields: fields } = change;
152
+ fields = Object.assign(Object.assign({}, fields), { NOMEARQUIVO: (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0] });
153
+ try {
154
+ this.validateFields(fields);
155
+ const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
156
+ const reqBody = {
157
+ serviceName: SERVICE.save,
158
+ requestBody: {
159
+ params: {
160
+ resourceID: this.resourceID,
161
+ description: fields.DESCRICAO,
162
+ fileSelect: fileInfo ? 1 : 0,
163
+ keySession: (_b = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.properties) === null || _b === void 0 ? void 0 : _b.fileNameTmp,
164
+ nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
165
+ link: fields.LINK,
166
+ nameEntity: this.entityName,
167
+ pkEntity: this._registerKey,
168
+ typeAcess: fields.TIPOACESSO,
169
+ typeApres: fields.TIPOAPRES,
170
+ }
171
+ }
172
+ };
173
+ const result = await DataFetcher.DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody));
174
+ return Promise.resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { ARQUIVOOULINK: !!fields.LINK ? fields.LINK : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name, __owner__dataunit__name__: this.dataUnitName })]);
175
+ }
176
+ catch (error) {
177
+ return Promise.reject(error);
178
+ }
179
+ }
180
+ async edit(change) {
181
+ var _a, _b, _c;
182
+ let { updatingFields: fields, record } = change;
183
+ const getFieldValue = (fieldValue) => {
184
+ if (fields[fieldValue] !== undefined)
185
+ return fields[fieldValue];
186
+ return record[fieldValue];
187
+ };
188
+ const attachField = getFieldValue('NOMEARQUIVO');
189
+ const hasNewAttachment = (_b = (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.downloadURL;
190
+ fields = Object.assign(Object.assign({}, fields), { DESCRICAO: getFieldValue('DESCRICAO'), LINK: getFieldValue('LINK'), TIPOACESSO: getFieldValue('TIPOACESSO'), TIPOAPRES: getFieldValue('TIPOAPRES'), CHAVEARQUIVO: record.CHAVEARQUIVO, NOMEARQUIVO: attachField === null || attachField === void 0 ? void 0 : attachField[0] });
191
+ const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
192
+ try {
193
+ this.validateFields(fields);
194
+ const reqBody = {
195
+ serviceName: SERVICE.save,
196
+ requestBody: {
197
+ params: {
198
+ resourceID: this.resourceID,
199
+ nuAttach: record === null || record === void 0 ? void 0 : record.NUATTACH,
200
+ description: fields.DESCRICAO,
201
+ fileSelect: hasNewAttachment ? 1 : 0,
202
+ keySession: (_c = fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.properties) === null || _c === void 0 ? void 0 : _c.fileNameTmp,
203
+ keyAttach: fields.CHAVEARQUIVO,
204
+ nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
205
+ link: fields.LINK,
206
+ nameEntity: this.entityName,
207
+ pkEntity: this._registerKey,
208
+ typeAcess: fields.TIPOACESSO,
209
+ typeApres: fields.TIPOAPRES,
210
+ }
211
+ }
212
+ };
213
+ const result = await DataFetcher.DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody));
214
+ return Promise.resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { ARQUIVOOULINK: !!fields.LINK ? fields.LINK : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name, __owner__dataunit__name__: this.dataUnitName })]);
215
+ }
216
+ catch (error) {
217
+ return Promise.reject(error);
218
+ }
219
+ }
220
+ delete(record) {
221
+ var _a;
222
+ const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
223
+ const reqBody = {
224
+ serviceName: SERVICE.delete,
225
+ requestBody: {
226
+ paramsDelete: {
227
+ keyAttach: record.CHAVEARQUIVO,
228
+ nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
229
+ nameEntity: record.NOMEINSTANCIA,
230
+ nuAttach: record.NUATTACH,
231
+ pkEntity: record.PKREGISTRO
232
+ }
233
+ }
234
+ };
235
+ return new Promise((resolve, reject) => {
236
+ DataFetcher.DataFetcher.get().callServiceBroker(SERVICE.delete, JSON.stringify(reqBody))
237
+ .then(result => resolve(result))
238
+ .catch(error => reject(error));
239
+ });
240
+ }
241
+ getDownloadKey(record) {
242
+ var _a;
243
+ const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
244
+ const reqBody = {
245
+ serviceName: SERVICE.download,
246
+ requestBody: {
247
+ paramsDown: {
248
+ nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
249
+ nameEntity: record.NOMEINSTANCIA,
250
+ nuAttach: record.NUATTACH,
251
+ pkEntity: record.PKREGISTRO,
252
+ keyAttach: record.CHAVEARQUIVO,
253
+ }
254
+ }
255
+ };
256
+ return new Promise((resolve, reject) => {
257
+ DataFetcher.DataFetcher.get().callServiceBroker(SERVICE.download, JSON.stringify(reqBody))
258
+ .then(result => resolve(result))
259
+ .catch(error => reject(error));
260
+ });
261
+ }
262
+ }
263
+
264
+ class AnexoSistemaDataUnitFactory {
265
+ constructor(entityName, getMessage) {
266
+ this.entityName = entityName;
267
+ this.getMessage = getMessage;
268
+ this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
269
+ }
270
+ initLoaders(dataUnit, fetcher, onSuccess) {
271
+ if (!this.loader)
272
+ this.loader = dataUnit.dataLoader;
273
+ dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
274
+ dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, fetcher).then((recordIds) => {
275
+ if (recordIds.length)
276
+ onSuccess();
277
+ return recordIds;
278
+ });
279
+ dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, fetcher).then((recordIds) => {
280
+ if (recordIds.length)
281
+ onSuccess();
282
+ return recordIds;
283
+ });
284
+ }
285
+ metadataLoader(dataUnit) {
286
+ throw new Error("Method not implemented.");
287
+ }
288
+ dataLoader(dataUnit, request) {
289
+ return new Promise(resolve => {
290
+ this.loader(dataUnit, request).then(response => {
291
+ const records = ((response === null || response === void 0 ? void 0 : response.records) || []).map(record => {
292
+ let fileInfo;
293
+ if (!record.LINK)
294
+ fileInfo = [{
295
+ name: record.NOMEARQUIVO,
296
+ }];
297
+ return Object.assign(Object.assign({}, record), { ARQUIVOOULINK: !!record.LINK ? record.LINK : record.NOMEARQUIVO, NOMEARQUIVO: fileInfo });
298
+ });
299
+ resolve(Object.assign(Object.assign({}, response), { records }));
300
+ });
301
+ });
302
+ }
303
+ saveLoader(changes, fetcher) {
304
+ return new Promise((resolve) => {
305
+ var _a;
306
+ const change = Array.isArray(changes) ? changes[0] : {};
307
+ const savePromise = ((_a = change === null || change === void 0 ? void 0 : change.record) === null || _a === void 0 ? void 0 : _a.NUATTACH) >= 0 ? fetcher.edit.bind(fetcher) : fetcher.save.bind(fetcher);
308
+ savePromise(change).then((records) => {
309
+ resolve(records);
310
+ }).catch((error) => {
311
+ if (error.message === ISave.SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME) {
312
+ this._application.alert(this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.title'), this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.message'));
313
+ return resolve([]);
314
+ }
315
+ if (error.message === ISave.SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED) {
316
+ this._application.alert(this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.title'), this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.message'));
317
+ return resolve([]);
318
+ }
319
+ if (error.message) {
320
+ this._application.error((error.title || error.name), error.message);
321
+ return resolve([]);
322
+ }
323
+ resolve([]);
324
+ });
325
+ });
326
+ }
327
+ removeLoader(dataUnit, ids, fetcher) {
328
+ return new Promise((resolve) => {
329
+ const { records } = dataUnit.getSelectionInfo();
330
+ const recordToDelete = records[0];
331
+ fetcher.delete(recordToDelete).then(() => {
332
+ dataunitFetcher.PreloadManager.removeRecords(dataUnit, [recordToDelete]);
333
+ return resolve(ids);
334
+ });
335
+ });
336
+ }
337
+ getFilters(registerKey) {
338
+ return [
339
+ {
340
+ name: 'AttachmentsByPK',
341
+ expression: 'this.PKREGISTRO = :PKREGISTRO',
342
+ params: [{
343
+ name: "PKREGISTRO",
344
+ dataType: core.DataType.TEXT,
345
+ value: `${registerKey}_${this.entityName}`
346
+ }]
347
+ }
348
+ ];
349
+ }
350
+ getInterceptions(dataUnit, action, crudRef) {
351
+ return new Promise((resolve) => {
352
+ if (action.type === core.Action.EDITION_CANCELED) {
353
+ if (!dataUnit.isDirty())
354
+ return resolve(action);
355
+ return this._application.confirm(this.getMessage('snkAttach.cancelConfirmation.title'), this.getMessage('snkAttach.cancelConfirmation.message')).then((cancellationConfirmed) => {
356
+ if (cancellationConfirmed) {
357
+ crudRef.goToView(constants.VIEW_MODE.GRID);
358
+ return resolve(action);
359
+ }
360
+ return resolve(undefined);
361
+ });
362
+ }
363
+ if (action.type === core.Action.DATA_SAVED) {
364
+ dataUnit.loadData();
365
+ return resolve(action);
366
+ }
367
+ resolve(action);
368
+ });
369
+ }
370
+ }
371
+
372
+ let messageBuilderInstance;
373
+ const getMessage$1 = (key) => {
374
+ if (!messageBuilderInstance) {
375
+ messageBuilderInstance = new DataFetcher.SnkMessageBuilder();
376
+ }
377
+ return messageBuilderInstance.getMessage(key);
378
+ };
379
+ const attachCrudConfig = {
380
+ grid: {
381
+ columns: [
382
+ { name: "CODATA", orderIndex: 0, width: 0 },
383
+ { name: "DESCRICAO", orderIndex: 1, width: 0 },
384
+ { name: "ARQUIVO", orderIndex: 2, width: 0 },
385
+ { name: "DTALTER", orderIndex: 3, width: 0 },
386
+ { name: "USUARIO", orderIndex: 4, width: 0 },
387
+ ],
388
+ },
389
+ form: {
390
+ emptyConfig: false,
391
+ fields: [
392
+ {
393
+ name: "DESCRICAO",
394
+ label: getMessage$1("snkAttach.attachMetadata.lblDescription"),
395
+ visible: true,
396
+ readOnly: false,
397
+ required: true,
398
+ },
399
+ {
400
+ name: "CAMINHO_ARQUIVO",
401
+ label: getMessage$1("snkAttach.attachMetadata.lblFile"),
402
+ visible: true,
403
+ readOnly: false,
404
+ required: true,
405
+ },
406
+ ],
407
+ },
408
+ };
409
+ const attachFetcherMetadataBuilder = {
410
+ name: "Attach",
411
+ label: "Attach List",
412
+ fields: [
413
+ { name: "CODATA", label: getMessage$1("snkAttach.attachMetadata.lblCode"), dataType: core.DataType.TEXT },
414
+ { name: "DESCRICAO", label: getMessage$1("snkAttach.attachMetadata.lblDescription"), dataType: core.DataType.TEXT, readOnly: false },
415
+ { name: "ARQUIVO", label: getMessage$1("snkAttach.attachMetadata.lblFileOrLink"), dataType: core.DataType.TEXT },
416
+ { name: "USUARIO", label: getMessage$1("snkAttach.attachMetadata.lblUser"), dataType: core.DataType.TEXT },
417
+ { name: "DTALTER", label: getMessage$1("snkAttach.attachMetadata.lblDate"), dataType: core.DataType.TEXT },
418
+ {
419
+ name: "CAMINHO_ARQUIVO",
420
+ label: getMessage$1("snkAttach.attachMetadata.lblFileUpload"),
421
+ dataType: core.DataType.OBJECT,
422
+ userInterface: core.UserInterface.FILE,
423
+ readOnly: false,
424
+ required: true,
425
+ visible: true,
426
+ properties: {
427
+ subTitle: getMessage$1("snkAttach.attachMetadata.lblSubTitle"),
428
+ MAX_FILES: 1,
429
+ STORAGESTRATEGY: "SESSION",
430
+ INTERNAL_FILENAME: "Attach.upload",
431
+ }
432
+ },
433
+ ],
434
+ };
435
+
436
+ const SERVICE_LOAD = "Attach.load";
437
+ class AttachFetcherDataUnitFactory {
438
+ constructor(getMessage) {
439
+ this.getMessage = getMessage;
440
+ this._records = [];
441
+ this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
442
+ }
443
+ initLoaders(dataUnit, fetcher, onSuccess) {
444
+ dataUnit.metadataLoader = (dataUnit) => this.metadataLoader(dataUnit);
445
+ dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
446
+ dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, fetcher).then((recordIds) => {
447
+ if (recordIds.length)
448
+ onSuccess();
449
+ return recordIds;
450
+ });
451
+ dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, fetcher).then((recordIds) => {
452
+ if (recordIds.length)
453
+ onSuccess();
454
+ return recordIds;
455
+ });
456
+ }
457
+ metadataLoader(_) {
458
+ return Promise.resolve(attachFetcherMetadataBuilder);
459
+ }
460
+ async dataLoader(dataUnit, request) {
461
+ if (!request.source) {
462
+ return Promise.resolve({ records: this._records });
463
+ }
464
+ if (!Number.isNaN(Number(request.source))) {
465
+ const criteria = {
466
+ criteria: {
467
+ codata: request.source,
468
+ tipoAnexo: "N"
469
+ }
470
+ };
471
+ const applicationDataFetcher = await this._application.getDataFetcher();
472
+ const { anexos: { anexo = [] } } = await applicationDataFetcher.callServiceBroker(SERVICE_LOAD, JSON.stringify(criteria));
473
+ const records = [];
474
+ anexo.forEach((param) => {
475
+ records.push(Object.assign({ __record__id__: core.StringUtils.generateUUID(), CAMINHO_ARQUIVO: [{
476
+ name: param === null || param === void 0 ? void 0 : param.ARQUIVO,
477
+ }] }, param));
478
+ });
479
+ this._records = records;
480
+ }
481
+ return core.DataUnitLoaderUtils.buildLoadDataResponse(this._records, dataUnit, request);
482
+ }
483
+ saveLoader(changes, fetcher) {
484
+ return new Promise((resolve) => {
485
+ const change = Array.isArray(changes) ? changes[0] : {};
486
+ fetcher.save(change)
487
+ .then(resolve)
488
+ .catch((error) => {
489
+ if (error.message === ISave.SaveErrorsEnum.DESCRIPTION_CANNOT_BE_CHANGED) {
490
+ this._application.alert(this.getMessage('snkAttach.alertValidation.descriptionCannotBeChanged.title'), this.getMessage('snkAttach.alertValidation.descriptionCannotBeChanged.message'));
491
+ return resolve([]);
492
+ }
493
+ if (error.message === ISave.SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME) {
494
+ this._application.alert(this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.title'), this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.message'));
495
+ return resolve([]);
496
+ }
497
+ if (error.message === ISave.SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED) {
498
+ this._application.alert(this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.title'), this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.message'));
499
+ return resolve([]);
500
+ }
501
+ if (error.message) {
502
+ this._application.error((error.title || error.name), error.message);
503
+ return resolve([]);
504
+ }
505
+ resolve([]);
506
+ });
507
+ });
508
+ }
509
+ removeLoader(dataUnit, ids, fetcher) {
510
+ return new Promise((resolve) => {
511
+ dataUnit.getSelectionInfo().records.forEach(async (record) => {
512
+ this._application.hasAccess(authFetcher.AutorizationType.REMOVE)
513
+ .then(async (hasAccess) => {
514
+ if (hasAccess) {
515
+ await fetcher.delete(record);
516
+ resolve(ids);
517
+ }
518
+ });
519
+ });
520
+ });
521
+ }
522
+ getFilters() {
523
+ throw new Error('Method not implemented.');
524
+ }
525
+ getInterceptions(dataUnit, action, crudRef) {
526
+ return new Promise((resolve) => {
527
+ var _a, _b, _c, _d, _e, _f;
528
+ switch (action.type) {
529
+ case core.Action.EDITION_CANCELED:
530
+ if (!dataUnit.isDirty())
531
+ return resolve(action);
532
+ return this._application.confirm(this.getMessage('snkAttach.cancelConfirmation.title'), this.getMessage('snkAttach.cancelConfirmation.message')).then((cancellationConfirmed) => {
533
+ if (cancellationConfirmed) {
534
+ crudRef.goToView(constants.VIEW_MODE.GRID);
535
+ return resolve(action);
536
+ }
537
+ return resolve(undefined);
538
+ });
539
+ case core.Action.DATA_SAVED:
540
+ dataUnit.loadData(undefined, undefined, false, (_c = (_b = (_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.REGISTER_KEY);
541
+ return resolve(action);
542
+ case core.Action.RECORDS_REMOVED:
543
+ dataUnit.loadData(undefined, undefined, false, (_f = (_e = (_d = action === null || action === void 0 ? void 0 : action.payload) === null || _d === void 0 ? void 0 : _d.cachedRecords) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.CODATA);
544
+ return resolve(action);
545
+ }
546
+ resolve(action);
547
+ });
548
+ }
549
+ }
550
+
551
+ let messagesBuilder;
552
+ const getMessage = (key) => {
553
+ var _a;
554
+ if (!messagesBuilder) {
555
+ const application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
556
+ messagesBuilder = application === null || application === void 0 ? void 0 : application.messagesBuilder;
557
+ }
558
+ return (_a = messagesBuilder === null || messagesBuilder === void 0 ? void 0 : messagesBuilder.getMessage) === null || _a === void 0 ? void 0 : _a.call(messagesBuilder, key, null);
559
+ };
560
+ const TaskbarAttachButtons = {
561
+ DOWNLOAD: {
562
+ hint: getMessage("snkAttach.taskbar.titleDownload"),
563
+ name: "DOWNLOAD",
564
+ iconName: 'file-download'
565
+ },
566
+ LINK: {
567
+ hint: getMessage("snkAttach.taskbar.titleLink"),
568
+ name: "LINK",
569
+ iconName: "launch"
570
+ }
571
+ };
572
+ const buildTaskBarManager = () => {
573
+ const disabledButtonsWithoutSelection = [
574
+ taskbarElements.TaskbarElement.REMOVE,
575
+ "DOWNLOAD",
576
+ "LINK"
577
+ ];
578
+ return {
579
+ getButtons: (_, dataState, currentButtons) => {
580
+ const refreshBtnIndex = currentButtons.indexOf(taskbarElements.TaskbarElement.REFRESH);
581
+ if ((dataState === null || dataState === void 0 ? void 0 : dataState.insertionMode) || (dataState === null || dataState === void 0 ? void 0 : dataState.isDirty)) {
582
+ return currentButtons.reverse();
583
+ }
584
+ else if (refreshBtnIndex !== -1) {
585
+ currentButtons.splice(refreshBtnIndex, 1);
586
+ }
587
+ const { selectedRecord } = dataState || {};
588
+ const taskbarTobeAdded = !!(selectedRecord === null || selectedRecord === void 0 ? void 0 : selectedRecord.LINK) ? TaskbarAttachButtons.LINK : TaskbarAttachButtons.DOWNLOAD;
589
+ currentButtons.splice(currentButtons.indexOf(taskbarElements.TaskbarElement.DIVIDER) + 1, 0, taskbarElements.TaskbarElement.REMOVE, taskbarTobeAdded, taskbarElements.TaskbarElement.DIVIDER);
590
+ const buttonsToRemove = [taskbarElements.TaskbarElement.CLONE, taskbarElements.TaskbarElement.DATA_EXPORTER];
591
+ const updatedButtons = Array.from(new Set(currentButtons.filter((button) => !buttonsToRemove.includes(button))));
592
+ updatedButtons.splice(updatedButtons.indexOf(taskbarTobeAdded) + 1, 0, taskbarElements.TaskbarElement.DIVIDER);
593
+ return updatedButtons;
594
+ },
595
+ isEnabled: (_, dataState, currentButton) => {
596
+ const hasSelectedRecord = (dataState === null || dataState === void 0 ? void 0 : dataState.selectedRecord) !== undefined;
597
+ const disabledButton = disabledButtonsWithoutSelection.includes(currentButton);
598
+ if (disabledButton && !hasSelectedRecord)
599
+ return false;
600
+ return true;
601
+ }
602
+ };
603
+ };
604
+
605
+ const anexoSistemaCrudConfig = {
606
+ grid: {
607
+ columns: [
608
+ { name: "ARQUIVOOULINK", orderIndex: 0, width: 0 },
609
+ { name: "DESCRICAO", orderIndex: 1, width: 0 },
610
+ { name: "DHCAD", orderIndex: 2, width: 0 },
611
+ { name: "DHALTER", orderIndex: 3, width: 0 },
612
+ { name: "TIPOAPRES", orderIndex: 4, width: 0 },
613
+ { name: "TIPOACESSO", orderIndex: 5, width: 0 },
614
+ { name: "CODUSU", orderIndex: 6, width: 0 },
615
+ { name: "CODUSUALT", orderIndex: 7, width: 0 }
616
+ ]
617
+ },
618
+ form: {
619
+ emptyConfig: false,
620
+ fields: [
621
+ {
622
+ name: "DESCRICAO",
623
+ required: true
624
+ },
625
+ {
626
+ name: "TIPOAPRES",
627
+ required: true,
628
+ },
629
+ {
630
+ name: "TIPOACESSO",
631
+ required: true,
632
+ },
633
+ {
634
+ name: "LINK"
635
+ },
636
+ {
637
+ name: "NOMEARQUIVO"
638
+ }
639
+ ]
640
+ },
641
+ };
642
+
643
+ const snkAttachCss = ".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%}";
644
+
645
+ const RESOURCE_ID = 'AnexoSistema';
646
+ const DATA_UNIT_NAME = 'br.com.sankhya.core.v3.anexoSistema';
647
+ const GRID_LEGACY_CONFIG_NAME = 'GrdCfgHtml5:grdcfg.dynaform.anexo';
648
+ const LINKORFILE_COLUMN_NAME = "ARQUIVOOULINK";
649
+ const SnkAttach = class {
650
+ constructor(hostRef) {
651
+ index.registerInstance(this, hostRef);
652
+ this.ezClosePopup = index.createEvent(this, "ezClosePopup", 7);
653
+ this.handleTaskbarClick = async ({ detail: taskbar }) => {
654
+ if (["DOWNLOAD", "LINK"].includes(taskbar))
655
+ return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());
656
+ if (this.fetcherType === "Attach" && ["SAVE"].includes(taskbar) && this._currentDataUnit.isDirty()) {
657
+ await this._currentDataUnit.setFieldValue("REGISTER_KEY", this.registerKey);
658
+ }
659
+ };
660
+ this.handleBack = () => {
661
+ this._currentDataUnit.cancelEdition().then((cancelationConfirmed) => {
662
+ if (cancelationConfirmed)
663
+ this.close();
664
+ });
665
+ };
666
+ this.handleFinish = () => {
667
+ if (!this._currentDataUnit.isDirty())
668
+ return this.close();
669
+ if (!this.validateAnexoSistema()) {
670
+ return;
671
+ }
672
+ this._currentDataUnit.saveData().then(() => {
673
+ this.showFinishedToast();
674
+ this.close();
675
+ });
676
+ };
677
+ this._isOpen = false;
678
+ this.gridLegacyConfigName = undefined;
679
+ this.fetcherType = undefined;
680
+ this.fetcher = undefined;
681
+ this.dataUnit = undefined;
682
+ this.dataUnitBuilder = undefined;
683
+ this.registerKey = undefined;
684
+ this.entityName = undefined;
685
+ this.messagesBuilder = undefined;
686
+ this._currentFetcher = undefined;
687
+ this._currentDataUnit = undefined;
688
+ this.crudConfig = undefined;
689
+ this._appResourceID = undefined;
690
+ }
691
+ // Garante que o popup só abre via método open()
692
+ // Não há mais caminhos alternativos de abertura
693
+ /**
694
+ * Abre o popup do SnkAttach.
695
+ */
696
+ /**
697
+ * Abre o popup do SnkAttach.
698
+ * Inicializa o componente apenas na abertura.
699
+ */
700
+ async open() {
701
+ this._isOpen = true;
702
+ // Inicialização só ocorre na abertura
703
+ if (!this._currentDataUnit) {
704
+ await this.initAttach();
705
+ }
706
+ if (this._refPopup) {
707
+ this._refPopup.opened = true;
708
+ }
709
+ if (!this.fetcherType) {
710
+ this.fetcherType = "AnexoSistema";
711
+ }
712
+ if (this._currentDataUnit == null) {
713
+ this.loadAttachmentDataUnit();
714
+ }
715
+ }
716
+ /**
717
+ * Fecha o popup do SnkAttach.
718
+ */
719
+ async close() {
720
+ this._isOpen = false;
721
+ if (this._refPopup) {
722
+ this._refPopup.opened = false;
723
+ }
724
+ }
725
+ async registerKeyWatcher(newRegisterKey, oldRegisterKey) {
726
+ var _a;
727
+ if (this._currentDataUnit == null) {
728
+ this.loadAttachmentDataUnit();
729
+ }
730
+ if (oldRegisterKey !== newRegisterKey) {
731
+ if (this._currentFetcher instanceof AnexoSistemaFetcher) {
732
+ this._currentFetcher.registerKey = newRegisterKey;
733
+ }
734
+ await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadData());
735
+ }
736
+ }
737
+ getAnexoSistemaFetcherInstance() {
738
+ var _a;
739
+ const anexoSistemaFetcher = new AnexoSistemaFetcher(this.entityName, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
740
+ anexoSistemaFetcher.registerKey = this.registerKey;
741
+ return anexoSistemaFetcher;
742
+ }
743
+ async initAttach() {
744
+ var _a, _b, _c, _d, _e;
745
+ if (!this.fetcherType && !this.registerKey)
746
+ return;
747
+ if (!this.fetcherType) {
748
+ this.fetcherType = "AnexoSistema";
749
+ }
750
+ this.returnToGridMode();
751
+ if (this.fetcherType === "AnexoSistema") {
752
+ this._currentFetcher = this.getAnexoSistemaFetcherInstance();
753
+ (_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
754
+ await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData());
755
+ return;
756
+ }
757
+ if (this.fetcherType === "Attach") {
758
+ const hasMoreOneItem = ((_c = this.registerKey) === null || _c === void 0 ? void 0 : _c.split("_").length) > 1;
759
+ if (hasMoreOneItem)
760
+ return;
761
+ }
762
+ await ((_d = this._currentDataUnit) === null || _d === void 0 ? void 0 : _d.loadMetadata());
763
+ await ((_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadData(undefined, undefined, true, this.registerKey));
764
+ }
765
+ /**
766
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
767
+ * através de um pequeno modulo na estrutura da aplicação:
768
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
769
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-attach.msg.ts"
770
+ */
771
+ getMessage(key, params) {
772
+ if (this.messagesBuilder)
773
+ return this.messagesBuilder.getMessage(key, params);
774
+ }
775
+ showFinishedToast() {
776
+ this._application.info(this.getMessage('snkAttach.finishedMessage'), { iconName: "check" });
777
+ }
778
+ downloadAttachment(selectedRecord) {
779
+ if (!selectedRecord)
780
+ throw new Error(this.getMessage("snkAttach.alertValidation.noRecordSelected.message"));
781
+ if (selectedRecord.LINK) {
782
+ window.open(`${selectedRecord.LINK}`);
783
+ return;
784
+ }
785
+ this._currentFetcher
786
+ .getDownloadKey(selectedRecord)
787
+ .then(({ chave }) => {
788
+ var _a;
789
+ let forceDownload = false;
790
+ if (!((_a = selectedRecord === null || selectedRecord === void 0 ? void 0 : selectedRecord.ARQUIVO) === null || _a === void 0 ? void 0 : _a.endsWith(".pdf"))) {
791
+ forceDownload = true;
792
+ }
793
+ window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${chave.valor}${forceDownload ? "&forcarDownload=S" : ""}`);
794
+ });
795
+ }
796
+ returnToGridMode() {
797
+ var _a;
798
+ (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.clearSelection();
799
+ if (this._crudElement)
800
+ this._crudElement.goToView(constants.VIEW_MODE.GRID);
801
+ }
802
+ async loadAttachmentDataUnit() {
803
+ try {
804
+ switch (this.fetcherType) {
805
+ case "AnexoSistema":
806
+ await this.loadAnexoSistema();
807
+ break;
808
+ case "Attach":
809
+ await this.loadAttach();
810
+ break;
811
+ default:
812
+ this._currentFetcher = this.fetcher;
813
+ this._currentDataUnit = this.dataUnit;
814
+ this._currentDataUnitBuilder = this.dataUnitBuilder;
815
+ }
816
+ }
817
+ catch (error) {
818
+ throw new Error('There was an error while creating the data unit');
819
+ }
820
+ }
821
+ async loadAnexoSistema() {
822
+ var _a, _b;
823
+ this._currentDataUnit = new dataunitFetcher.DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
824
+ this._currentFetcher = this.getAnexoSistemaFetcherInstance();
825
+ let gridValidateForm;
826
+ if (!this._currentDataUnit.metadata) {
827
+ await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadMetadata());
828
+ this.crudConfig = this.entityName ? { form: anexoSistemaCrudConfig === null || anexoSistemaCrudConfig === void 0 ? void 0 : anexoSistemaCrudConfig.form } : Object.assign({}, anexoSistemaCrudConfig);
829
+ gridValidateForm = { grid: anexoSistemaCrudConfig === null || anexoSistemaCrudConfig === void 0 ? void 0 : anexoSistemaCrudConfig.grid };
830
+ }
831
+ this.initDataUnitLoaders();
832
+ this._currentDataUnit.addFilterProvider({
833
+ getFilter: () => this._currentDataUnitBuilder.getFilters(this.registerKey)
834
+ });
835
+ this._currentDataUnit.addInterceptor({
836
+ interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
837
+ });
838
+ await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData());
839
+ this.disableEditFieldsNotInForm(gridValidateForm);
840
+ }
841
+ async loadAttach() {
842
+ var _a, _b;
843
+ this._currentFetcher = new AttachFetcher();
844
+ this._currentDataUnit = new core.DataUnit(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
845
+ this._currentDataUnit.pageSize = 150;
846
+ let gridValidateForm;
847
+ this.initDataUnitLoaders();
848
+ this._currentDataUnit.addInterceptor({
849
+ interceptAction: (action) => {
850
+ var _a;
851
+ if (action.type === core.Action.METADATA_LOADED) {
852
+ this.crudConfig = this.entityName ? { form: attachCrudConfig === null || attachCrudConfig === void 0 ? void 0 : attachCrudConfig.form } : Object.assign({}, attachCrudConfig);
853
+ gridValidateForm = { grid: attachCrudConfig === null || attachCrudConfig === void 0 ? void 0 : attachCrudConfig.grid };
854
+ (_a = this._crudElement) === null || _a === void 0 ? void 0 : _a.updateConfig();
855
+ }
856
+ return this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement);
857
+ }
858
+ });
859
+ if (!this._currentDataUnit.metadata) {
860
+ await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadMetadata());
861
+ this.crudConfig = this.entityName ? { form: attachCrudConfig === null || attachCrudConfig === void 0 ? void 0 : attachCrudConfig.form } : Object.assign({}, attachCrudConfig);
862
+ gridValidateForm = { grid: attachCrudConfig === null || attachCrudConfig === void 0 ? void 0 : attachCrudConfig.grid };
863
+ await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData(undefined, undefined, true, this.registerKey));
864
+ this.disableEditFieldsNotInForm(gridValidateForm);
865
+ }
866
+ }
867
+ initDataUnitLoaders() {
868
+ var _a, _b;
869
+ if (this.fetcherType === "AnexoSistema") {
870
+ this._currentFetcher = this.getAnexoSistemaFetcherInstance();
871
+ this._currentDataUnitBuilder = new AnexoSistemaDataUnitFactory(this.entityName, this.getMessage.bind(this));
872
+ (_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
873
+ }
874
+ if (this.fetcherType === "Attach") {
875
+ this._currentFetcher = new AttachFetcher();
876
+ this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
877
+ (_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
878
+ this.returnToGridMode();
879
+ await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
880
+ });
881
+ }
882
+ }
883
+ disableEditFieldsNotInForm(gridValidateForm) {
884
+ var _a, _b, _c, _d, _e;
885
+ const gridColumns = ((_b = (_a = this._crudElement) === null || _a === void 0 ? void 0 : _a.gridConfig) === null || _b === void 0 ? void 0 : _b.columns) || ((_c = gridValidateForm === null || gridValidateForm === void 0 ? void 0 : gridValidateForm.grid) === null || _c === void 0 ? void 0 : _c.columns) || ((_e = (_d = this.crudConfig) === null || _d === void 0 ? void 0 : _d.grid) === null || _e === void 0 ? void 0 : _e.columns);
886
+ if (!!this.getGridLegacyConfigName()) {
887
+ this._currentDataUnit.disableField(LINKORFILE_COLUMN_NAME);
888
+ }
889
+ gridColumns === null || gridColumns === void 0 ? void 0 : gridColumns.forEach(column => {
890
+ var _a, _b;
891
+ const fieldName = column.name;
892
+ if (!((_b = (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.fields.some(field => (field === null || field === void 0 ? void 0 : field.name) === fieldName))) {
893
+ this._currentDataUnit.disableField(fieldName);
894
+ }
895
+ });
896
+ }
897
+ validateAnexoSistema() {
898
+ var _a;
899
+ if (this._currentFetcher instanceof AnexoSistemaFetcher) {
900
+ try {
901
+ let fields = this._currentDataUnit.getSelectedRecord();
902
+ fields = Object.assign(Object.assign({}, fields), { NOMEARQUIVO: (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0] });
903
+ this._currentFetcher.validateFields(fields);
904
+ }
905
+ catch (error) {
906
+ if (error.message === ISave.SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME) {
907
+ this._application.alert(this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.title'), this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.message'));
908
+ return false;
909
+ }
910
+ if (error.message === ISave.SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED) {
911
+ this._application.alert(this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.title'), this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.message'));
912
+ return false;
913
+ }
914
+ }
915
+ }
916
+ return true;
917
+ }
918
+ async componentWillLoad() {
919
+ this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
920
+ if (this._application) {
921
+ this._appResourceID = await this._application.getResourceID();
922
+ }
923
+ await this.initAttach();
924
+ }
925
+ // Removido: não inicializa DataUnit no ciclo de vida, apenas na abertura
926
+ async handleOnDataStateChange({ detail }) {
927
+ if (this.fetcherType !== 'Attach')
928
+ return;
929
+ if (!detail.insertionMode) {
930
+ this._currentDataUnit.disableField('DESCRICAO');
931
+ }
932
+ else {
933
+ this._currentDataUnit.enableField('DESCRICAO');
934
+ }
935
+ await this._currentDataUnit.loadMetadata();
936
+ }
937
+ ;
938
+ isScreenVariation() {
939
+ var _a;
940
+ return !!((_a = this._appResourceID) === null || _a === void 0 ? void 0 : _a.includes('__'));
941
+ }
942
+ getGridLegacyConfigName() {
943
+ if (this.isScreenVariation()) {
944
+ return undefined;
945
+ }
946
+ if (this.gridLegacyConfigName)
947
+ return this.gridLegacyConfigName;
948
+ return this.entityName ? GRID_LEGACY_CONFIG_NAME + "." + this.entityName : this.entityName;
949
+ }
950
+ render() {
951
+ var _a, _b;
952
+ return (index.h("ez-popup", { ref: (el) => this._refPopup = el, size: 'x-large', ezTitle: this.getMessage("snkAttach.title"), useHeader: false, autoClose: false, onEzClosePopup: () => this.close() }, this._isOpen && this._currentDataUnit && (index.h("main", { class: "snk-attach__main" }, index.h("header", { class: "snk-attach__header" }, index.h("section", null, index.h("ez-button", { class: "ez-padding-right--medium", title: this.getMessage('snkSimpleBar.backTitle'), mode: 'icon', iconName: "arrow_back", size: 'medium', onClick: () => this.handleBack() }), index.h("div", { class: "snk-attach__file-info" }, index.h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold" }, this.getMessage("snkAttach.title")), index.h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))), index.h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })), index.h("div", { class: "snk-attach__crud-section" }, index.h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this._currentDataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick, messagesBuilder: this.messagesBuilder, onDataStateChange: this.handleOnDataStateChange.bind(this), multipleSelection: true, configName: this.isScreenVariation() ? undefined : (this.entityName ? "AnexoSistema_" + this.entityName : undefined), ignoreReadOnlyFormFields: this.entityName ? true : false, gridLegacyConfigName: this.getGridLegacyConfigName(), outlineMode: true }))))));
953
+ }
954
+ static get watchers() { return {
955
+ "registerKey": ["registerKeyWatcher"]
956
+ }; }
957
+ };
958
+ SnkAttach.style = snkAttachCss;
959
+
960
+ const snkDefaultFilterCss = ".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)}";
961
+
962
+ const SnkDefaultFilter = class {
963
+ constructor(hostRef) {
964
+ index.registerInstance(this, hostRef);
965
+ this.actionSelected = index.createEvent(this, "actionSelected", 7);
966
+ this.OFFSET_HEIGHT = 5;
967
+ this.getMessage = undefined;
968
+ this.hasDefaultFilter = false;
969
+ this._opened = false;
970
+ }
971
+ repositionDropDown() {
972
+ if (!this._refIcon || !this._refDropdown) {
973
+ return;
974
+ }
975
+ const boundingIcon = this._refIcon.getBoundingClientRect();
976
+ const boundingDropDown = this._refDropdown.getBoundingClientRect();
977
+ this._refDropdown.style.top = (boundingIcon.y + boundingIcon.height + this.OFFSET_HEIGHT) + "px";
978
+ this._refDropdown.style.left = ((boundingIcon.x + (boundingIcon.width / 2)) - boundingDropDown.width) + "px";
979
+ }
980
+ toggleDropdown() {
981
+ this._opened = !this._opened;
982
+ }
983
+ closeDropdown(evt) {
984
+ const target = evt === null || evt === void 0 ? void 0 : evt.target;
985
+ if (!target) {
986
+ return;
987
+ }
988
+ if (!target.closest("#dropdown-parent-demo")) {
989
+ this._opened = false;
990
+ }
991
+ }
992
+ buildItems() {
993
+ return ([
994
+ {
995
+ id: filterType_enum.ActionDefaultFilter.EDIT,
996
+ label: this.getMessage('defaultFilter.edit'),
997
+ },
998
+ {
999
+ id: filterType_enum.ActionDefaultFilter.REMOVE,
1000
+ label: this.getMessage('defaultFilter.remove'),
1001
+ },
1002
+ ]);
1003
+ }
1004
+ onValueSelected({ detail: item }) {
1005
+ this._opened = false;
1006
+ this.actionSelected.emit(item.id);
1007
+ }
1008
+ openCreateNewFilter() {
1009
+ this.actionSelected.emit(filterType_enum.ActionDefaultFilter.CREATE);
1010
+ }
1011
+ componentDidRender() {
1012
+ this.repositionDropDown();
1013
+ }
1014
+ componentWillLoad() {
1015
+ this._items = this.buildItems();
1016
+ document.removeEventListener("scroll", this.repositionDropDown.bind(this));
1017
+ document.addEventListener("scroll", this.repositionDropDown.bind(this));
1018
+ }
1019
+ render() {
1020
+ if (!this.hasDefaultFilter) {
1021
+ return (index.h(index.Host, null, index.h("button", { class: "default_container new_filter", onClick: this.openCreateNewFilter.bind(this) }, index.h("span", null, this.getMessage('defaultFilter.create')))));
1022
+ }
1023
+ return (index.h(index.Host, null, index.h("button", { class: "default_container", onClick: this.toggleDropdown.bind(this) }, index.h("span", null, this.getMessage('defaultFilter.title')), index.h("ez-icon", { ref: (ref) => this._refIcon = ref, iconName: 'dots-vertical' })), this._opened &&
1024
+ index.h("ez-dropdown", { ref: (ref) => this._refDropdown = ref, items: this._items, onEzClick: this.onValueSelected.bind(this), onEzOutsideClick: this.closeDropdown.bind(this) })));
1025
+ }
1026
+ };
1027
+ SnkDefaultFilter.style = snkDefaultFilterCss;
1028
+
1029
+ const snkDynaformFormViewCss = ".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)}";
1030
+
1031
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
1032
+ var t = {};
1033
+ for (var p in s)
1034
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1035
+ t[p] = s[p];
1036
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1037
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1038
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1039
+ t[p[i]] = s[p[i]];
1040
+ }
1041
+ return t;
1042
+ };
1043
+ const SnkDynaformFormView = class {
1044
+ constructor(hostRef) {
1045
+ index.registerInstance(this, hostRef);
1046
+ this.snkContentCardChanged = index.createEvent(this, "snkContentCardChanged", 7);
1047
+ this.snkRequestClearFieldToFocus = index.createEvent(this, "snkRequestClearFieldToFocus", 7);
1048
+ this._customEditors = new Map();
1049
+ this._fieldProps = new Map();
1050
+ this.dataUnitObserver = async (action) => {
1051
+ var _a;
1052
+ if (action.type === core.Action.RECORDS_COPIED) {
1053
+ const sourcePK = this.buildSourceRecordPK(action);
1054
+ (_a = this.getImageField()) === null || _a === void 0 ? void 0 : _a.forEach(async (field) => {
1055
+ var _a;
1056
+ (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.setFieldValue(field.name, JSON.stringify(sourcePK));
1057
+ });
1058
+ }
1059
+ };
1060
+ this.customUiBuilders = new Map([
1061
+ [core.UserInterface.IMAGE, (_a) => {
1062
+ var { name } = _a, props = __rest(_a, ["name"]);
1063
+ return index.h("snk-image-input", Object.assign({ dataUnit: this.dataUnit, maxSize: Infinity, fieldName: name, entityName: this.entityPath }, props));
1064
+ }
1065
+ ]
1066
+ ]);
1067
+ this._singleColumn = false;
1068
+ this._currentFormLayout = undefined;
1069
+ this.fieldSearch = undefined;
1070
+ this.label = undefined;
1071
+ this.name = undefined;
1072
+ this.fields = undefined;
1073
+ this.formMetadata = undefined;
1074
+ this.dataUnit = undefined;
1075
+ this.recordsValidator = undefined;
1076
+ this.fieldToFocus = undefined;
1077
+ this.customEditors = undefined;
1078
+ this.fieldsProps = undefined;
1079
+ this.entityPath = undefined;
1080
+ }
1081
+ async showUp() {
1082
+ var _a, _b;
1083
+ if (this._formView) {
1084
+ (_b = (_a = this._formView).showUp) === null || _b === void 0 ? void 0 : _b.call(_a);
1085
+ }
1086
+ }
1087
+ /**
1088
+ * Registra um editor customizado para campos da grade e formulário
1089
+ */
1090
+ async addCustomEditor(fieldName, customEditor, detailContext) {
1091
+ var _a, _b;
1092
+ if (this._formView) {
1093
+ (_b = (_a = this._formView).addCustomEditor) === null || _b === void 0 ? void 0 : _b.call(_a, fieldName, customEditor, detailContext);
1094
+ return;
1095
+ }
1096
+ const newCustomEditors = new Map(this._customEditors);
1097
+ newCustomEditors.set(fieldName, { customEditor, detailContext: detailContext !== null && detailContext !== void 0 ? detailContext : "" });
1098
+ this._customEditors = newCustomEditors;
1099
+ }
1100
+ /**
1101
+ * Altera/adiciona uma propriedade nos metadados do campo.
1102
+ */
1103
+ async setFieldProp(fieldName, propName, value) {
1104
+ const props = this._fieldProps.get(fieldName) || [];
1105
+ this._fieldProps.set(fieldName, [...props, { propName, value }]);
1106
+ }
1107
+ /**
1108
+ * Exibe a busca de campos ancorada ao container de cabeçalho do snk-dynaform-form-view.
1109
+ */
1110
+ async showSearchField() {
1111
+ if (!this._headerContainer || !this._ezPopoverFieldColumn)
1112
+ return;
1113
+ const container = this._headerContainer.getBoundingClientRect();
1114
+ if (this.fieldSearch) {
1115
+ await utils.focusOnFieldSerch(this.fieldSearch);
1116
+ this._ezPopoverFieldColumn.showUnder(this._headerContainer, { horizontalGap: container.width - (utils.SEARCH_FIELD_FULL_WIDTH), verticalGap: container.height * -1 });
1117
+ }
1118
+ }
1119
+ observePropsCustomEditor(newValue) {
1120
+ for (const fieldName in newValue) {
1121
+ this.addCustomEditor(fieldName, newValue[fieldName]);
1122
+ }
1123
+ }
1124
+ async observeFieldsProps(newValue) {
1125
+ for (const field in newValue) {
1126
+ const fieldProps = newValue[field];
1127
+ const propNames = Object.keys(fieldProps);
1128
+ for (const propName of propNames) {
1129
+ await this.setFieldProp(field, propName, fieldProps[propName]);
1130
+ }
1131
+ }
1132
+ }
1133
+ async observeDataUnit(newValue, oldValue) {
1134
+ if (newValue !== oldValue && newValue) {
1135
+ newValue.subscribe(this.dataUnitObserver);
1136
+ }
1137
+ }
1138
+ bindFields(fields) {
1139
+ var _a;
1140
+ if (this._dataBinder == undefined && this.dataUnit != undefined) {
1141
+ this._dataBinder = new form.DataBinder(this.dataUnit);
1142
+ }
1143
+ if (this._dataBinder && this.dataUnit && this.formMetadata) {
1144
+ this._dataBinder.bind(fields, (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.dataUnitId, this.formMetadata, this.recordsValidator);
1145
+ }
1146
+ }
1147
+ disconnectedCallback() {
1148
+ if (this._dataBinder != undefined) {
1149
+ this._dataBinder.onDisconnectedCallback();
1150
+ }
1151
+ if (this.dataUnit) {
1152
+ this.dataUnit.unsubscribe(this.dataUnitObserver);
1153
+ }
1154
+ }
1155
+ componentDidLoad() {
1156
+ if (this.customEditors) {
1157
+ this.observePropsCustomEditor(this.customEditors);
1158
+ }
1159
+ if (this.fieldsProps) {
1160
+ this.observeFieldsProps(this.fieldsProps);
1161
+ }
1162
+ this.initLayoutFormConfig();
1163
+ }
1164
+ async initLayoutFormConfig() {
1165
+ const _application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
1166
+ const layoutFormConfig = await (_application === null || _application === void 0 ? void 0 : _application.getLayoutFormConfig());
1167
+ if (layoutFormConfig) {
1168
+ this.setSingleColumn(layoutFormConfig);
1169
+ this.registerNotifyListeners(layoutFormConfig);
1170
+ }
1171
+ }
1172
+ setSingleColumn(layoutFormConfig) {
1173
+ this._singleColumn = (layoutFormConfig === null || layoutFormConfig === void 0 ? void 0 : layoutFormConfig.config) === utils.FormLayout.CASCADE || (layoutFormConfig === null || layoutFormConfig === void 0 ? void 0 : layoutFormConfig.config) === utils.FormLayout.CLASSIC_CASCADE;
1174
+ this._currentFormLayout = layoutFormConfig === null || layoutFormConfig === void 0 ? void 0 : layoutFormConfig.config;
1175
+ }
1176
+ registerNotifyListeners(layoutFormConfig) {
1177
+ var _a;
1178
+ if (!layoutFormConfig)
1179
+ return;
1180
+ (_a = layoutFormConfig.onConfigChange) === null || _a === void 0 ? void 0 : _a.call(layoutFormConfig, (config) => {
1181
+ this._singleColumn = (config === utils.FormLayout.CASCADE || config === utils.FormLayout.CLASSIC_CASCADE);
1182
+ this._currentFormLayout = config;
1183
+ });
1184
+ }
1185
+ componentDidRender() {
1186
+ var _a;
1187
+ this.setCustomEditors();
1188
+ this.setFieldProps();
1189
+ if (!this.fieldToFocus) {
1190
+ return;
1191
+ }
1192
+ if (!((_a = this.fields) === null || _a === void 0 ? void 0 : _a.some(item => item.name === this.fieldToFocus))) {
1193
+ return;
1194
+ }
1195
+ requestAnimationFrame(() => {
1196
+ var _a, _b;
1197
+ (_a = this._dataBinder) === null || _a === void 0 ? void 0 : _a.setFocus(this.fieldToFocus);
1198
+ (_b = this.snkRequestClearFieldToFocus) === null || _b === void 0 ? void 0 : _b.emit();
1199
+ });
1200
+ }
1201
+ setCustomEditors() {
1202
+ var _a, _b;
1203
+ if (!this._formView) {
1204
+ return;
1205
+ }
1206
+ for (const [fieldName, customEditorProps] of this._customEditors) {
1207
+ (_b = (_a = this._formView).addCustomEditor) === null || _b === void 0 ? void 0 : _b.call(_a, fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
1208
+ this._customEditors.delete(fieldName);
1209
+ }
1210
+ }
1211
+ setFieldProps() {
1212
+ if (!this._formView) {
1213
+ return;
1214
+ }
1215
+ for (const [fieldName, propsToChange] of this._fieldProps) {
1216
+ propsToChange.forEach(prop => {
1217
+ var _a, _b;
1218
+ (_b = (_a = this._formView).setFieldProp) === null || _b === void 0 ? void 0 : _b.call(_a, fieldName, prop.propName, prop.value);
1219
+ this._fieldProps.delete(fieldName);
1220
+ });
1221
+ }
1222
+ }
1223
+ buildSourceRecordPK(action) {
1224
+ var _a, _b, _c;
1225
+ const currentRecord = ((_a = action.payload) === null || _a === void 0 ? void 0 : _a[0]) || {};
1226
+ const sourceBase64 = currentRecord["__record__source__id__"];
1227
+ const sourceRecord = JSON.parse(atob(sourceBase64 || ''));
1228
+ delete sourceRecord["__DATA_UNIT_NAME__"];
1229
+ if (!this.dataUnit) {
1230
+ return {};
1231
+ }
1232
+ const pks = (_b = ImageUtils.getPKs(this.dataUnit)) !== null && _b !== void 0 ? _b : {};
1233
+ const pkFields = Object.keys(pks);
1234
+ const filteredSourceRecord = {};
1235
+ for (const pkField of pkFields) {
1236
+ filteredSourceRecord[pkField] = (_c = sourceRecord[pkField]) === null || _c === void 0 ? void 0 : _c.value;
1237
+ }
1238
+ return filteredSourceRecord;
1239
+ }
1240
+ getImageField() {
1241
+ var _a;
1242
+ return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.metadata.fields.filter(field => field.userInterface === core.UserInterface.IMAGE);
1243
+ }
1244
+ render() {
1245
+ return (index.h(index.Host, null, index.h("slot", null), index.h("ez-form-view", { ref: (ref) => this._formView = ref, fields: this.fields, onEzContentReady: evt => this.bindFields(evt.detail), singleColumn: this._singleColumn, customUiBuilders: this.customUiBuilders, formLayout: this._currentFormLayout }), this.fieldSearch && index.h("ez-popover", { ref: elem => (this._ezPopoverFieldColumn = elem), overlayType: "none" }, this.fieldSearch)));
1246
+ }
1247
+ static get watchers() { return {
1248
+ "customEditors": ["observePropsCustomEditor"],
1249
+ "fieldsProps": ["observeFieldsProps"],
1250
+ "dataUnit": ["observeDataUnit"]
1251
+ }; }
1252
+ };
1253
+ SnkDynaformFormView.style = snkDynaformFormViewCss;
1254
+
1255
+ const snkFilterAdvancedModeCss = ".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)}";
1256
+
1257
+ const SnkFilterAdvancedMode = class {
1258
+ constructor(hostRef) {
1259
+ index.registerInstance(this, hostRef);
1260
+ this.ezExpressionChange = index.createEvent(this, "ezExpressionChange", 7);
1261
+ this.filterAssistent = undefined;
1262
+ this.application = undefined;
1263
+ }
1264
+ getMessage(key, params) {
1265
+ return this.application.messagesBuilder.getMessage(key, params);
1266
+ }
1267
+ render() {
1268
+ var _a;
1269
+ return (index.h(index.Host, null, index.h("span", { class: "ez-title ez-title--small ez-padding-bottom--small snk-filter-advanced-mode__title" }, this.getMessage("snkPersonalizedFilter.info.applyExpression")), index.h("ez-text-area", { rows: 9, label: this.getMessage("snkPersonalizedFilter.info.labelExpression"), value: (_a = this.filterAssistent) === null || _a === void 0 ? void 0 : _a.expression, onEzChange: (evt) => this.ezExpressionChange.emit(evt.detail) })));
1270
+ }
1271
+ };
1272
+ SnkFilterAdvancedMode.style = snkFilterAdvancedModeCss;
1273
+
1274
+ const snkFilterAssistentModeCss = ".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)}";
1275
+
1276
+ const SnkFilterAssistentMode = class {
1277
+ constructor(hostRef) {
1278
+ index.registerInstance(this, hostRef);
1279
+ this.ezChangeFilter = index.createEvent(this, "ezChangeFilter", 7);
1280
+ this.filterAssistent = undefined;
1281
+ this.messagesBuilder = undefined;
1282
+ this.filterId = undefined;
1283
+ this.entityUri = undefined;
1284
+ this.application = undefined;
1285
+ this.isDefaultFilter = false;
1286
+ }
1287
+ getMessage(key, params) {
1288
+ return this.application.messagesBuilder.getMessage(key, params);
1289
+ }
1290
+ async handleFilterGroupChange() {
1291
+ const assistent = await this._mainExpressionGroup.getExpressionGroup();
1292
+ this.filterAssistent = Object.assign(Object.assign({}, this.filterAssistent), { assistent });
1293
+ this.filterAssistent.parameters = PersonalizedFilterUtils.PersonalizedFilterUtils.buildVariableParameters(this.filterAssistent.assistent);
1294
+ this.filterAssistent.expression = PersonalizedFilterUtils.PersonalizedFilterUtils.buildGroupExpression(this.filterAssistent.assistent);
1295
+ this.ezChangeFilter.emit(this.filterAssistent);
1296
+ }
1297
+ render() {
1298
+ var _a, _b;
1299
+ return (index.h(index.Host, null, index.h("div", { class: "ez-padding-top--small snk-personalized-filter__group" }, index.h("snk-expression-group", { ref: (el) => this._mainExpressionGroup = el, group: (_a = this.filterAssistent) === null || _a === void 0 ? void 0 : _a.assistent, messagesBuilder: this.messagesBuilder, onEzFilterGroupChange: this.handleFilterGroupChange.bind(this), filterId: this.filterId, entityURI: this.entityUri, isDefaultFilter: this.isDefaultFilter })), index.h("div", { class: "ez-margin-top--auto" }, index.h("div", { class: "snk-personalized-filter__expression-input--line" }), index.h("ez-collapsible-box", { label: this.getMessage("snkPersonalizedFilter.info.titleCollapsible"), headerSize: "medium", value: true }, index.h("div", { class: "ez-box" }, index.h("div", { class: "ez-box__container--external" }, index.h("div", { class: "ez-box__container--internal" }, index.h("span", { class: "ez-box__container--title" }, this.getMessage("snkPersonalizedFilter.info.labelExpression")), index.h("span", { class: "ez-box__container--expression" }, (_b = this.filterAssistent) === null || _b === void 0 ? void 0 : _b.expression))))))));
1300
+ }
1301
+ };
1302
+ SnkFilterAssistentMode.style = snkFilterAssistentModeCss;
1303
+
1304
+ const SnkFilterDetail = class {
1305
+ constructor(hostRef) {
1306
+ index.registerInstance(this, hostRef);
1307
+ this.filterChange = index.createEvent(this, "filterChange", 7);
1308
+ this.config = undefined;
1309
+ this.getMessage = undefined;
1310
+ this.showHardFixed = true;
1311
+ this.removalBlocked = false;
1312
+ }
1313
+ /**
1314
+ * Define o foco no campo do editor.
1315
+ */
1316
+ async setFocusField() {
1317
+ var _a, _b, _c, _d;
1318
+ if (!this._editor) {
1319
+ return;
1320
+ }
1321
+ if (this._editor["setFocus"]) {
1322
+ (_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a["setFocus"]) === null || _b === void 0 ? void 0 : _b.call(_a);
1323
+ }
1324
+ else if (this._editor["focus"]) {
1325
+ (_d = (_c = this._editor) === null || _c === void 0 ? void 0 : _c["focus"]) === null || _d === void 0 ? void 0 : _d.call(_c);
1326
+ }
1327
+ }
1328
+ async clearValue() {
1329
+ if (!this._editor) {
1330
+ return;
1331
+ }
1332
+ if (this._editor["clearValue"]) {
1333
+ await this._editor["clearValue"]();
1334
+ }
1335
+ }
1336
+ observeConfig(newValue) {
1337
+ var _a, _b;
1338
+ this._editor && (this._editor["config"] = newValue);
1339
+ (_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a["reloadList"]) === null || _b === void 0 ? void 0 : _b.call(_a);
1340
+ this._customElementObject = this.getContentEditor();
1341
+ }
1342
+ componentDidLoad() {
1343
+ if (this._element) {
1344
+ core.ElementIDUtils.addIDInfo(this._element);
1345
+ const dataElementIdDoFilterItem = this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
1346
+ this._idContentEditor = `${dataElementIdDoFilterItem}_${this.config.id}`;
1347
+ }
1348
+ }
1349
+ changeConfig(newConfig) {
1350
+ this.filterChange.emit(newConfig);
1351
+ }
1352
+ getContentEditor() {
1353
+ switch (this.config.type) {
1354
+ case filterItemType_enum.FilterItemType.BINARY_SELECT:
1355
+ return { tag: "snk-filter-binary-select" };
1356
+ case filterItemType_enum.FilterItemType.MULTI_SELECT:
1357
+ return { tag: "snk-filter-multi-select" };
1358
+ case filterItemType_enum.FilterItemType.PERIOD:
1359
+ return { tag: "snk-filter-period" };
1360
+ case filterItemType_enum.FilterItemType.SEARCH:
1361
+ return { tag: "snk-filter-search" };
1362
+ case filterItemType_enum.FilterItemType.NUMBER:
1363
+ return { tag: "snk-filter-number" };
1364
+ case filterItemType_enum.FilterItemType.PERSONALIZED:
1365
+ const snkFilterPersonalizedProps = {
1366
+ tag: "snk-personalized-filter-editor", props: {
1367
+ presentationMode: presentationMode.EPresentationMode.CHIP,
1368
+ onValueChanged: evt => this.handleValueChanged(evt),
1369
+ }
1370
+ };
1371
+ return snkFilterPersonalizedProps;
1372
+ case filterItemType_enum.FilterItemType.CHECK_BOX_LIST:
1373
+ return {
1374
+ tag: "snk-filter-checkbox-list",
1375
+ props: {
1376
+ onValueChanged: evt => this.config = Object.assign(Object.assign({}, this.config), { value: evt.detail })
1377
+ }
1378
+ };
1379
+ case filterItemType_enum.FilterItemType.MULTI_LIST:
1380
+ return {
1381
+ tag: "snk-entity-list",
1382
+ props: {
1383
+ onValueChanged: evt => this.config = Object.assign(Object.assign({}, this.config), { value: evt.detail })
1384
+ }
1385
+ };
1386
+ }
1387
+ return { tag: "snk-filter-text" };
1388
+ }
1389
+ handleValueChanged({ detail }) {
1390
+ const groupedItems = (detail === null || detail === void 0 ? void 0 : detail.items) || this.config.groupedItems;
1391
+ this.config = Object.assign(Object.assign({}, this.config), { groupedItems, visible: (groupedItems || []).filter(item => item.visible).length > 0 });
1392
+ }
1393
+ removeItem() {
1394
+ const hasMultiValues = this.config.type === filterItemType_enum.FilterItemType.MULTI_LIST && Array.isArray(this.config.value);
1395
+ const newValue = hasMultiValues ? this.config.value.map((valueItem) => (Object.assign(Object.assign({}, valueItem), { check: false }))) : undefined;
1396
+ const removedConfig = Object.assign(Object.assign({}, this.config), { visible: false, fixed: false, value: newValue });
1397
+ if (removedConfig.groupedItems != undefined) {
1398
+ removedConfig.groupedItems = removedConfig.groupedItems.map(item => (Object.assign(Object.assign({}, item), { visible: false, fixed: false, value: undefined })));
1399
+ }
1400
+ this.changeConfig(removedConfig);
1401
+ }
1402
+ removeItemFromGroup(item) {
1403
+ return Object.assign(Object.assign({}, item), { visible: false, fixed: false, value: undefined });
1404
+ }
1405
+ getPopUpHeaderButtons() {
1406
+ return (index.h(index.Fragment, null, !this.removalBlocked && !this.config.removalBlocked &&
1407
+ this.buildIcon(this.getMessage("snkFilterBar.removeFilter"), "delete", () => this.removeItem()), this.showHardFixed && !this.config.hardFixed &&
1408
+ 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 })))));
1409
+ }
1410
+ buildIcon(title, iconName, action) {
1411
+ return (index.h("button", { onClick: () => action(), class: "sc-snk-filter-bar snk-filter-item__editor-header-button", ref: elem => elem && this.buildIdButton(elem, title) }, index.h("ez-icon", Object.assign({ title: title, iconName: iconName }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo(`_${title}`)}` }))));
1412
+ }
1413
+ buildIdButton(buttonElement, title) {
1414
+ if (!buttonElement)
1415
+ return;
1416
+ const dataElement = { id: title };
1417
+ buttonElement.removeAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
1418
+ core.ElementIDUtils.addIDInfoIfNotExists(buttonElement, "button", dataElement);
1419
+ }
1420
+ clearBinarySelectValues() {
1421
+ var _a;
1422
+ const editor = this._editor || {};
1423
+ (_a = editor.resetValues) === null || _a === void 0 ? void 0 : _a.call(editor);
1424
+ this.config = core.ObjectUtils.copy(this.originalConfig);
1425
+ this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
1426
+ }
1427
+ apply() {
1428
+ const isValid = PersonalizedFilterUtils.PersonalizedFilterUtils.validateVariableValues(this.config, this._editor["value"]);
1429
+ if (!isValid) {
1430
+ return utils.ApplicationUtils.alert(this.getMessage('snkFilterBar.filterModal.validations.notFullFilled.title'), this.getMessage('snkFilterBar.filterModal.validations.notFullFilled.message'));
1431
+ }
1432
+ const valuesArray = this._editor["value"] !== undefined ? this._editor["value"] : this.config.value;
1433
+ this.changeConfig(Object.assign(Object.assign({}, this.config), { visible: this.isVisible(), value: valuesArray }));
1434
+ }
1435
+ isVisible() {
1436
+ if (this.config.groupedItems && this.config.groupedItems.length > 0) {
1437
+ return this.config.groupedItems.filter(item => item.visible).length > 0;
1438
+ }
1439
+ return true;
1440
+ }
1441
+ clear() {
1442
+ var _a;
1443
+ if (this.config.type === filterItemType_enum.FilterItemType.BINARY_SELECT) {
1444
+ this.clearBinarySelectValues();
1445
+ return;
1446
+ }
1447
+ if (filterItemType_enum.FilterItemType.MULTI_LIST === this.config.type) {
1448
+ const configCopy = core.ObjectUtils.copy(this.config);
1449
+ (_a = configCopy.value) === null || _a === void 0 ? void 0 : _a.forEach(value => !!value && (value.check = false));
1450
+ this.config = core.ObjectUtils.copy(configCopy);
1451
+ return;
1452
+ }
1453
+ this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
1454
+ }
1455
+ filterCanBeCleared() {
1456
+ return this.config.type !== filterItemType_enum.FilterItemType.PERSONALIZED;
1457
+ }
1458
+ onKeyDonwListener(event) {
1459
+ if (event.key === "Enter") {
1460
+ this.apply();
1461
+ }
1462
+ }
1463
+ buildRightSlot(item) {
1464
+ return index.h("ez-icon", { iconName: "delete", onClick: () => this.removeValueFromConfig(item) });
1465
+ }
1466
+ removeValueFromConfig(item) {
1467
+ var _a, _b;
1468
+ if (this.config) {
1469
+ const configCopy = core.ObjectUtils.copy(this.config);
1470
+ const index = (_a = configCopy.value) === null || _a === void 0 ? void 0 : _a.findIndex(i => (i === null || i === void 0 ? void 0 : i.id) === item.id);
1471
+ (_b = configCopy.value) === null || _b === void 0 ? void 0 : _b.splice(index, 1);
1472
+ this.config = core.ObjectUtils.copy(configCopy);
1473
+ }
1474
+ }
1475
+ componentWillLoad() {
1476
+ this.originalConfig = core.ObjectUtils.copy(this.config);
1477
+ this._customElementObject = this.getContentEditor();
1478
+ }
1479
+ render() {
1480
+ const { tag: CustomElement, props } = this._customElementObject;
1481
+ return (index.h(index.Host, null, index.h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, index.h("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()), index.h(CustomElement, Object.assign({ maxHeightList: '240px', ref: ref => this._editor = ref, value: this.config.value, config: this.config, onKeyDown: evt => this.onKeyDonwListener(evt), "data-element-id": this._idContentEditor, getMessage: this.getMessage, rightListSlotBuilder: item => this.buildRightSlot(item) }, props)), index.h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), index.h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, this.filterCanBeCleared() && (index.h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.clear(), size: "small" })), index.h("ez-button", { ref: ref => this._applyButton = ref, label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
1482
+ }
1483
+ get _element() { return index.getElement(this); }
1484
+ static get watchers() { return {
1485
+ "config": ["observeConfig"]
1486
+ }; }
1487
+ };
1488
+
1489
+ const snkFilterModalItemCss = ".grow{flex-grow:1}.gap{gap:4px}";
1490
+
1491
+ const SnkFilterModalItem = class {
1492
+ constructor(hostRef) {
1493
+ index.registerInstance(this, hostRef);
1494
+ this.filterChange = index.createEvent(this, "filterChange", 7);
1495
+ this.editPersonalizedFilter = index.createEvent(this, "editPersonalizedFilter", 7);
1496
+ this.addPersonalizedFilter = index.createEvent(this, "addPersonalizedFilter", 7);
1497
+ this.filterItem = undefined;
1498
+ this.configName = undefined;
1499
+ this.resourceID = undefined;
1500
+ }
1501
+ getContentEditorConfig() {
1502
+ const props = { presentationMode: presentationMode.EPresentationMode.MODAL };
1503
+ switch (this.filterItem.type) {
1504
+ case filterItemType_enum.FilterItemType.BINARY_SELECT:
1505
+ return { tag: "snk-filter-binary-select", props };
1506
+ case filterItemType_enum.FilterItemType.MULTI_SELECT:
1507
+ return { tag: "snk-filter-multi-select" };
1508
+ case filterItemType_enum.FilterItemType.PERIOD:
1509
+ return { tag: "snk-filter-period", props };
1510
+ case filterItemType_enum.FilterItemType.SEARCH:
1511
+ return { tag: "snk-filter-search" };
1512
+ case filterItemType_enum.FilterItemType.NUMBER:
1513
+ return { tag: "snk-filter-number", props };
1514
+ case filterItemType_enum.FilterItemType.PERSONALIZED:
1515
+ return this.buildSnkFilterPersonalizedProps();
1516
+ case filterItemType_enum.FilterItemType.CHECK_BOX_LIST:
1517
+ return { tag: "snk-filter-checkbox-list", props };
1518
+ case filterItemType_enum.FilterItemType.MULTI_LIST:
1519
+ return { tag: "snk-entity-list", props: { maxHeightList: "640px", rightListSlotBuilder: item => this.buildRightSlot(item) } };
1520
+ }
1521
+ return { tag: "snk-filter-text" };
1522
+ }
1523
+ buildSnkFilterPersonalizedProps() {
1524
+ return {
1525
+ tag: "snk-personalized-filter-editor", props: {
1526
+ onEditFilter: (event) => this.editPersonalizedFilter.emit(event.detail),
1527
+ onAddFilter: () => this.addPersonalizedFilter.emit(),
1528
+ }
1529
+ };
1530
+ }
1531
+ isVisible(newValue) {
1532
+ return !this.filterItem.visible ? newValue !== undefined : true;
1533
+ }
1534
+ updateFilterValue(data) {
1535
+ var _a, _b;
1536
+ const newValue = (data === null || data === void 0 ? void 0 : data.value) !== undefined ? data.value : data;
1537
+ if (this.filterItem.groupedItems != undefined) {
1538
+ this.filterItem = Object.assign(Object.assign({}, this.filterItem), { visible: newValue > 0, value: newValue, groupedItems: data.items });
1539
+ }
1540
+ else {
1541
+ this.filterItem = Object.assign(Object.assign({}, this.filterItem), { value: this.filterItem.type === (filterItemType_enum.FilterItemType.SEARCH || filterItemType_enum.FilterItemType.CHECK_BOX_LIST) ? data : newValue, visible: this.isVisible(newValue) });
1542
+ }
1543
+ this._editor && (this._editor["config"] = this.filterItem);
1544
+ (_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a['reloadList']) === null || _b === void 0 ? void 0 : _b.call(_a);
1545
+ this.filterChange.emit(this.filterItem);
1546
+ }
1547
+ handleDeleteFilter(filter, filterItemType) {
1548
+ if (filterItemType === filterItemType_enum.FilterItemType.PERSONALIZED) {
1549
+ ConfigStorage.ConfigStorage.removePersonalizedFilter(filter, this.resourceID, this.configName);
1550
+ }
1551
+ }
1552
+ componentDidLoad() {
1553
+ if (this._element) {
1554
+ core.ElementIDUtils.addIDInfo(this._element);
1555
+ const dataElementIdDoFilterItem = this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
1556
+ this._idContentEditor = `${dataElementIdDoFilterItem}_${this.filterItem.id}`;
1557
+ }
1558
+ }
1559
+ buildRightSlot(item) {
1560
+ return (index.h("ez-icon", { iconName: "delete", onClick: () => this.removeValueFromConfig(item) }));
1561
+ }
1562
+ removeValueFromConfig(item) {
1563
+ var _a, _b, _c;
1564
+ const index = (_b = (_a = this.filterItem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.findIndex(({ id }) => id === item.id);
1565
+ const filterItemCopy = core.ObjectUtils.copy(this.filterItem);
1566
+ (_c = filterItemCopy === null || filterItemCopy === void 0 ? void 0 : filterItemCopy.value) === null || _c === void 0 ? void 0 : _c.splice(index, 1);
1567
+ this.updateFilterValue(filterItemCopy.value);
1568
+ }
1569
+ canShowDetailModal() {
1570
+ const { CUSTOM_FILTER, OTHER_FILTERS } = filterType_enum.FilterType;
1571
+ return ![CUSTOM_FILTER, OTHER_FILTERS].includes(this.filterItem.filterType) && this.filterItem.type !== filterItemType_enum.FilterItemType.BINARY_SELECT;
1572
+ }
1573
+ render() {
1574
+ const { tag: ContentEditor, props } = this.getContentEditorConfig();
1575
+ return (index.h(index.Host, null, index.h("div", { class: "ez-flex ez-flex--column grow" }, this.canShowDetailModal() && (index.h("label", { class: "ez-text ez-text--medium ez-text--primary ez-margin-bottom--extra-small", htmlFor: `filter-item-${this.filterItem.id}` }, this.filterItem.detailModal)), index.h(ContentEditor, Object.assign({ ref: ref => this._editor = ref, id: `filter-item-${this.filterItem.id}`, config: this.filterItem, value: this.filterItem.value, onValueChanged: (event) => this.updateFilterValue(event.detail), "data-element-id": this._idContentEditor }, props)))));
1576
+ }
1577
+ get _element() { return index.getElement(this); }
1578
+ };
1579
+ SnkFilterModalItem.style = snkFilterModalItemCss;
1580
+
1581
+ const snkImageInputCss = ":host{display:block}";
1582
+
1583
+ const SnkImageInput = class {
1584
+ constructor(hostRef) {
1585
+ index.registerInstance(this, hostRef);
1586
+ this.imageError = index.createEvent(this, "imageError", 7);
1587
+ this.dataUnitObserver = async (action) => {
1588
+ var _a;
1589
+ const actionsMoveSelection = [core.Action.NEXT_SELECTED, core.Action.PREVIOUS_SELECTED];
1590
+ if (actionsMoveSelection.includes(action.type)) {
1591
+ await this.loadImage();
1592
+ return;
1593
+ }
1594
+ const selection = ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.selection) || [];
1595
+ if (action.type === core.Action.SELECTION_CHANGED && selection.length > 0) {
1596
+ await this.loadImage();
1597
+ return;
1598
+ }
1599
+ if (action.type === core.Action.RECORDS_ADDED) {
1600
+ await this.clearImage();
1601
+ return;
1602
+ }
1603
+ if (action.type === core.Action.EDITION_CANCELED) {
1604
+ await this.loadImage();
1605
+ return;
1606
+ }
1607
+ };
1608
+ this.dataUnit = undefined;
1609
+ this.fieldName = undefined;
1610
+ this.entityName = undefined;
1611
+ this.enabled = true;
1612
+ this.acceptType = undefined;
1613
+ this.maxSize = undefined;
1614
+ this.label = undefined;
1615
+ this.imageValue = undefined;
1616
+ this.loading = true;
1617
+ }
1618
+ /**
1619
+ * Força o reload da imagem
1620
+ */
1621
+ async reloadImage(pks) {
1622
+ await this.loadImage(pks);
1623
+ }
1624
+ getMessage(key, params) {
1625
+ if (!this.messagesBuilder) {
1626
+ this.messagesBuilder = new DataFetcher.SnkMessageBuilder();
1627
+ }
1628
+ return this.messagesBuilder.getMessage(key, params);
1629
+ }
1630
+ async clearImage() {
1631
+ var _a;
1632
+ (_a = this._loadAbortController) === null || _a === void 0 ? void 0 : _a.abort();
1633
+ this.imageValue = undefined;
1634
+ }
1635
+ async handleImageChange(event) {
1636
+ const base64 = event.detail;
1637
+ if (!base64) {
1638
+ await this.clearImage();
1639
+ await this.updatedataUnitField(true);
1640
+ return;
1641
+ }
1642
+ const blob = await ImageUtils.base64ToBlob(base64);
1643
+ if (this.maxSize && blob.size > this.maxSize * 1024) {
1644
+ const errorMsg = this.getMessage('snkImageInput.errorImageSize') + this.maxSize + '(KB)';
1645
+ this.imageError.emit(errorMsg);
1646
+ if (this.application) {
1647
+ await this.application.error(this.getMessage('snkImageInput.errorTitle'), errorMsg);
1648
+ }
1649
+ return;
1650
+ }
1651
+ this.imageValue = base64;
1652
+ await ImageUtils.sessionFileUpload(blob, this.entityName, this.fieldName);
1653
+ await this.updatedataUnitField();
1654
+ }
1655
+ async updatedataUnitField(deleted = false) {
1656
+ if (!this.dataUnit || !this.dataUnit.getSelectedRecord()) {
1657
+ return;
1658
+ }
1659
+ if (deleted) {
1660
+ await this.dataUnit.setFieldValue(this.fieldName, 'deletado');
1661
+ }
1662
+ else {
1663
+ await this.dataUnit.setFieldValue(this.fieldName, `$file.session.key{${ImageUtils.buildFileKey(this.entityName, this.fieldName)}}`);
1664
+ }
1665
+ }
1666
+ async handleImageError(event) {
1667
+ this.imageError.emit(event.detail);
1668
+ if (this.application) {
1669
+ await this.application.error(this.getMessage('snkImageInput.errorTitle'), event.detail);
1670
+ }
1671
+ }
1672
+ getPksFromDataUnit() {
1673
+ if (!this.dataUnit) {
1674
+ return undefined;
1675
+ }
1676
+ const selectedRecord = this.dataUnit.getSelectedRecord();
1677
+ if (!selectedRecord) {
1678
+ return undefined;
1679
+ }
1680
+ const fieldValue = selectedRecord[this.fieldName];
1681
+ if (!fieldValue) {
1682
+ return undefined;
1683
+ }
1684
+ try {
1685
+ const pk = JSON.parse(fieldValue);
1686
+ return pk;
1687
+ }
1688
+ catch (error) {
1689
+ console.error('Error parsing PK from data unit field:', error);
1690
+ return undefined;
1691
+ }
1692
+ }
1693
+ async loadImage(pks) {
1694
+ var _a, _b;
1695
+ (_a = this._loadAbortController) === null || _a === void 0 ? void 0 : _a.abort();
1696
+ const controller = new AbortController();
1697
+ this._loadAbortController = controller;
1698
+ this.loading = true;
1699
+ if (this.dataUnit && this.entityName) {
1700
+ pks = (_b = pks !== null && pks !== void 0 ? pks : this.getPksFromDataUnit()) !== null && _b !== void 0 ? _b : ImageUtils.getPKs(this.dataUnit);
1701
+ const image = await ImageUtils.downloadImage(pks, this.fieldName, this.entityName, controller.signal);
1702
+ if (controller.signal.aborted)
1703
+ return;
1704
+ this.imageValue = image;
1705
+ }
1706
+ this.loading = false;
1707
+ }
1708
+ async componentWillLoad() {
1709
+ this.application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
1710
+ if (!this.messagesBuilder) {
1711
+ this.messagesBuilder = new DataFetcher.SnkMessageBuilder();
1712
+ }
1713
+ if (this.dataUnit) {
1714
+ this.dataUnit.subscribe(this.dataUnitObserver);
1715
+ }
1716
+ }
1717
+ disconnectedCallback() {
1718
+ if (this.dataUnit) {
1719
+ this.dataUnit.unsubscribe(this.dataUnitObserver);
1720
+ }
1721
+ }
1722
+ async componentDidLoad() {
1723
+ await this.loadImage();
1724
+ }
1725
+ render() {
1726
+ return (index.h(index.Host, null, index.h("ez-image-input", { enabled: this.enabled, label: this.label, name: this.fieldName, value: this.imageValue, maxFileSize: this.maxSize ? this.maxSize * 1024 : undefined, accept: this.acceptType || 'image/png,image/jpeg,image/gif', onEzChange: (e) => this.handleImageChange(e), onEzError: (e) => this.handleImageError(e), loading: this.loading })));
1727
+ }
1728
+ };
1729
+ SnkImageInput.style = snkImageInputCss;
1730
+
1731
+ const snkPersonalizedFilterCss = ".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}";
1732
+
1733
+ const SnkPersonalizedFilter = class {
1734
+ constructor(hostRef) {
1735
+ index.registerInstance(this, hostRef);
1736
+ this.ezCancel = index.createEvent(this, "ezCancel", 7);
1737
+ this.ezSave = index.createEvent(this, "ezSave", 7);
1738
+ this.ezAfterSave = index.createEvent(this, "ezAfterSave", 7);
1739
+ this._personalizedFilterFetcher = new ConfigStorage.PersonalizedFilterFetcher();
1740
+ this._filterMetadataStorage = new Map();
1741
+ this._dataSourceFetcher = {
1742
+ fetchData: async (entity) => {
1743
+ let entityURI = entity === null || entity === void 0 ? void 0 : entity.uri;
1744
+ if (core.StringUtils.isEmpty(entityURI)) {
1745
+ entityURI = this.entityUri;
1746
+ }
1747
+ if (!this._filterMetadataStorage.has(entityURI)) {
1748
+ const filterMetadata = await this._personalizedFilterFetcher.loadFields(entityURI);
1749
+ this._filterMetadataStorage.set(entityURI, filterMetadata);
1750
+ }
1751
+ return this._filterMetadataStorage.get(entityURI);
1752
+ }
1753
+ };
1754
+ this._filterAssistentMode = true;
1755
+ this._filterAssistent = undefined;
1756
+ this.messagesBuilder = undefined;
1757
+ this.entityUri = undefined;
1758
+ this.filterId = undefined;
1759
+ this.configName = undefined;
1760
+ this.resourceID = undefined;
1761
+ this.isDefaultFilter = false;
1762
+ }
1763
+ /**
1764
+ * Cria um novo filtro personalizado caso não exista nenhum.
1765
+ * @method
1766
+ * @returns {Promise<void>}
1767
+ */
1768
+ async createPersonalizedFilter() {
1769
+ const newPersonalizedFilter = {
1770
+ name: "",
1771
+ active: true,
1772
+ expression: "",
1773
+ parameters: [],
1774
+ assistent: {
1775
+ id: core.StringUtils.generateUUID(),
1776
+ items: [
1777
+ {
1778
+ id: core.StringUtils.generateUUID(),
1779
+ entityName: "",
1780
+ fieldName: "",
1781
+ description: "",
1782
+ fieldLabel: this.getMessage("snkPersonalizedFilter.info.labelDefaultValue"),
1783
+ type: undefined,
1784
+ expression: undefined,
1785
+ operand: undefined,
1786
+ paramVariable: false,
1787
+ value: undefined,
1788
+ systemConfig: null,
1789
+ userConfig: null
1790
+ }
1791
+ ],
1792
+ childrenGroups: [],
1793
+ operand: PersonalizedFilterUtils.FilterGroupCondition.AND
1794
+ }
1795
+ };
1796
+ if (this.isDefaultFilter) {
1797
+ this.buildDataDefaultFilter(newPersonalizedFilter);
1798
+ }
1799
+ this._originalFilterAssistent = core.ObjectUtils.copy(newPersonalizedFilter);
1800
+ this._filterAssistent = core.ObjectUtils.copy(newPersonalizedFilter);
1801
+ }
1802
+ /**
1803
+ * Carrega o filtro personalizado com base no identificador informado.
1804
+ * @watch filterId
1805
+ * @param newValue Novo valor do filtroId.
1806
+ * @param oldValue Valor anterior do filtroId.
1807
+ */
1808
+ loadFilter(newValue, oldValue) {
1809
+ if (newValue == null || oldValue == newValue || this.resourceID == undefined) {
1810
+ return;
1811
+ }
1812
+ if (newValue === PersonalizedFilterUtils.DefaultFilter.id) {
1813
+ ConfigStorage.ConfigStorage.loadDefaultFilter(newValue, this.resourceID, this.configName)
1814
+ .then((resp) => {
1815
+ const personalizedFilter = this.applyDefaultValues(resp);
1816
+ this._filterAssistent = personalizedFilter;
1817
+ this._originalFilterAssistent = core.ObjectUtils.copy(personalizedFilter);
1818
+ this._filterAssistentMode = this._filterAssistent.hasOwnProperty("assistent") && this._filterAssistent.assistent != undefined;
1819
+ });
1820
+ return;
1821
+ }
1822
+ ConfigStorage.ConfigStorage.loadPersonalizedFilter(newValue, this.resourceID, this.configName)
1823
+ .then((resp) => {
1824
+ const personalizedFilter = this.applyDefaultValues(resp);
1825
+ this._filterAssistent = personalizedFilter;
1826
+ this._originalFilterAssistent = core.ObjectUtils.copy(personalizedFilter);
1827
+ this._filterAssistentMode = this._filterAssistent.hasOwnProperty("assistent") && this._filterAssistent.assistent != undefined;
1828
+ });
1829
+ }
1830
+ componentWillLoad() {
1831
+ var _a;
1832
+ if (index$1.store.get(`filterFieldsDataSource.${this.entityUri}`) == undefined) {
1833
+ index$1.store.set(`filterFieldsDataSource.${this.entityUri}`, this._dataSourceFetcher);
1834
+ }
1835
+ if (!this.messagesBuilder) {
1836
+ this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
1837
+ this.messagesBuilder = (_a = this._application) === null || _a === void 0 ? void 0 : _a.messagesBuilder;
1838
+ }
1839
+ this.loadFilter(this.filterId, undefined);
1840
+ }
1841
+ componentDidRender() {
1842
+ var _a;
1843
+ (_a = this._viewStackRef) === null || _a === void 0 ? void 0 : _a.show(this._filterAssistentMode ? 0 : 1);
1844
+ if (this._elButtonMode) {
1845
+ this._elButtonMode.setAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME, core.ElementIDUtils.getInternalIDInfo(`${this._filterAssistentMode ? "advancedMode_ezButton" : "assistentMode_ezButton"}`));
1846
+ }
1847
+ }
1848
+ buildDataDefaultFilter(data) {
1849
+ data.name = PersonalizedFilterUtils.DefaultFilter.name;
1850
+ data.id = PersonalizedFilterUtils.DefaultFilter.id;
1851
+ }
1852
+ getMessage(key, params) {
1853
+ return this._application.messagesBuilder.getMessage(key, params);
1854
+ }
1855
+ async saveFilter() {
1856
+ let response;
1857
+ if (this.isDefaultFilter) {
1858
+ response = await ConfigStorage.ConfigStorage.saveDefaultFilter(this._filterAssistent, this.resourceID, this.configName);
1859
+ }
1860
+ else {
1861
+ response = await ConfigStorage.ConfigStorage.savePersonalizedFilter(this._filterAssistent, this.resourceID, this.configName);
1862
+ }
1863
+ this._elButtonSave.enabled = false;
1864
+ const messageToken = !!this._filterAssistent.id ? 'confirmEdit' : 'confirmSave';
1865
+ utils.ApplicationUtils.info(this.getMessage(`snkPersonalizedFilter.${messageToken}.title`), { iconName: "check" });
1866
+ const updatedFilterAssistent = Object.assign(Object.assign({}, response), this._filterAssistent);
1867
+ updatedFilterAssistent.parameters = PersonalizedFilterUtils.PersonalizedFilterUtils.buildVariableParameters(this._filterAssistent.assistent);
1868
+ this._originalFilterAssistent = core.ObjectUtils.copy(updatedFilterAssistent);
1869
+ this._filterAssistent = core.ObjectUtils.copy(updatedFilterAssistent);
1870
+ this.ezAfterSave.emit();
1871
+ }
1872
+ removeFilter() {
1873
+ ConfigStorage.ConfigStorage.removePersonalizedFilter(this._filterAssistent, this.resourceID, this.configName);
1874
+ }
1875
+ hasChangesToSave() {
1876
+ return JSON.stringify(this._filterAssistent) === JSON.stringify(this._originalFilterAssistent);
1877
+ }
1878
+ async handleSave() {
1879
+ if (this._filterAssistentMode) {
1880
+ const isValid = PersonalizedFilterUtils.PersonalizedFilterUtils.validateFields(this._filterAssistent.assistent);
1881
+ if (!isValid || !this._filterAssistent.name)
1882
+ return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"), this.getMessage("snkPersonalizedFilter.error.description"));
1883
+ this.saveAssistentMode();
1884
+ }
1885
+ else {
1886
+ if (!this._filterAssistent.expression || !this._filterAssistent.name)
1887
+ return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"), this.getMessage("snkPersonalizedFilter.error.description"));
1888
+ const isValidExpressionForAdvancedMode = await this.validateExpressionBeforeSaving();
1889
+ if (!isValidExpressionForAdvancedMode)
1890
+ return;
1891
+ this.saveAdvancedMode();
1892
+ }
1893
+ }
1894
+ saveAssistentMode() {
1895
+ const { assistent, expression } = this._filterAssistent;
1896
+ const expressionQuery = !!assistent ? PersonalizedFilterUtils.PersonalizedFilterUtils.buildGroupExpression(assistent) : expression;
1897
+ this._filterAssistent.expression = expressionQuery;
1898
+ this.ezSave.emit(expressionQuery);
1899
+ this.saveFilter();
1900
+ }
1901
+ saveAdvancedMode() {
1902
+ if (this._originalFilterAssistent.expression !== this._filterAssistent.expression && this._filterAssistent.assistent) {
1903
+ utils.ApplicationUtils.confirm(this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.title"), this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.description"))
1904
+ .then((confirm) => {
1905
+ if (!confirm)
1906
+ return;
1907
+ this.saveAndTransformToAdvancedMode();
1908
+ });
1909
+ }
1910
+ else if (!this._filterAssistent.assistent) {
1911
+ this.saveAndTransformToAdvancedMode();
1912
+ }
1913
+ else {
1914
+ this.saveAssistentMode();
1915
+ }
1916
+ }
1917
+ saveAndTransformToAdvancedMode() {
1918
+ this._filterAssistent.assistent = undefined;
1919
+ this.ezSave.emit(this._filterAssistent.expression);
1920
+ this.saveFilter();
1921
+ }
1922
+ async validateExpressionBeforeSaving() {
1923
+ const { valid, message = "" } = await this._personalizedFilterFetcher.validatePersonalizedFilter(this.entityUri, this._filterAssistent.expression);
1924
+ valid || this._application.error(this.getMessage("snkPersonalizedFilter.errorValidation.title"), message.replace(/.*Exception: /, ''));
1925
+ return valid;
1926
+ }
1927
+ handleCancel() {
1928
+ if (this.hasChangesToSave()) {
1929
+ return this.ezCancel.emit();
1930
+ }
1931
+ utils.ApplicationUtils.confirm(this.getMessage("snkPersonalizedFilter.confirmCancel.title"), this.getMessage("snkPersonalizedFilter.confirmCancel.description"))
1932
+ .then((canCancel) => {
1933
+ var _a;
1934
+ if (!canCancel)
1935
+ return;
1936
+ this._filterAssistent = core.ObjectUtils.copy((_a = this._originalFilterAssistent) !== null && _a !== void 0 ? _a : {});
1937
+ this.ezCancel.emit();
1938
+ this._elButtonSave.enabled = false;
1939
+ });
1940
+ }
1941
+ handleTitleChange(name) {
1942
+ this._filterAssistent = Object.assign(Object.assign({}, this._filterAssistent), { name });
1943
+ this._elButtonSave.enabled = !this.hasChangesToSave();
1944
+ }
1945
+ applyDefaultValues(personalizedFilter) {
1946
+ this.addLabelToItems(personalizedFilter);
1947
+ this.addFilterGroupCondition(personalizedFilter);
1948
+ return personalizedFilter;
1949
+ }
1950
+ addFilterGroupCondition(personalizedFilter) {
1951
+ if (personalizedFilter.assistent && !personalizedFilter.assistent.operand) {
1952
+ personalizedFilter.assistent.operand = PersonalizedFilterUtils.FilterGroupCondition.AND;
1953
+ }
1954
+ }
1955
+ ;
1956
+ addLabelToItems(personalizedFilter) {
1957
+ //Workaround: Alguns filtros foram salvos sem o fieldLabel. Para evitar transtornos
1958
+ //tentamos usar o fieldLabel que pode estar informado no parametro.
1959
+ if (personalizedFilter.assistent && personalizedFilter.assistent.items && personalizedFilter.assistent.items.length > 0) {
1960
+ personalizedFilter.assistent.items.forEach(item => {
1961
+ if (item.fieldLabel == undefined) {
1962
+ const param = (personalizedFilter.parameters || []).find(param => param.fieldName === item.fieldName);
1963
+ if (param) {
1964
+ item.fieldLabel = param.label;
1965
+ }
1966
+ }
1967
+ });
1968
+ }
1969
+ }
1970
+ handleExpressionChangeAdvancedMode(expression) {
1971
+ this._filterAssistent = Object.assign(Object.assign({}, this._filterAssistent), { expression });
1972
+ this._elButtonSave.enabled = !this.hasChangesToSave();
1973
+ }
1974
+ handleChangeFilterAssistentMode(filterAssistent) {
1975
+ this._elButtonSave.enabled = !this.hasChangesToSave();
1976
+ this._filterAssistent = Object.assign({}, filterAssistent);
1977
+ }
1978
+ selectField(fieldName) {
1979
+ if (!('name' in fieldName))
1980
+ return;
1981
+ const fieldExpression = this.buildExpression(fieldName.entityName, fieldName.name, fieldName.entityPath);
1982
+ const textAreaElement = this._elAdvancedMode.querySelector('ez-text-area');
1983
+ textAreaElement.appendTextToSelection(fieldExpression);
1984
+ }
1985
+ buildExpression(entityName, fieldName, entityPath) {
1986
+ if (entityPath.length > 0) {
1987
+ entityPath.shift();
1988
+ }
1989
+ return entityPath.length > 0 ? `${entityPath.join("->")}->${fieldName}` : `${entityName}.${fieldName}`;
1990
+ }
1991
+ onAddField(target) {
1992
+ const textAreaElement = this._elAdvancedMode.querySelector('ez-text-area');
1993
+ const options = { horizontalGap: 0, verticalGap: 12, fromRight: true };
1994
+ textAreaElement.setFocus();
1995
+ target.setBlur();
1996
+ if (this._elFilterFieldSearch)
1997
+ this._elFilterFieldSearch.show(target, options);
1998
+ }
1999
+ renderButtonAddField() {
2000
+ if (this._filterAssistentMode)
2001
+ return;
2002
+ return (index.h(index.Fragment, null, index.h("ez-button", { class: "snk-personalized-filter__button-mode", label: this.getMessage("snkPersonalizedFilter.info.addField"), enabled: true, onClick: (evt) => this.onAddField(evt.target) }, index.h("ez-icon", { class: "ez-padding-right--small", slot: "leftIcon", iconName: "plus" })), index.h("snk-filter-field-search", { class: "ez-padding-left--medium", ref: ref => this._elFilterFieldSearch = ref, onEzSelectFilterItem: (evt) => this.selectField(evt.detail), fieldsDataSource: this._dataSourceFetcher })));
2003
+ }
2004
+ buildContainerPersonalizedFilter() {
2005
+ return (index.h("ez-view-stack", { ref: (ref) => this._viewStackRef = ref }, index.h("stack-item", null, this._filterAssistentMode &&
2006
+ index.h("snk-filter-assistent-mode", { filterAssistent: this._filterAssistent, messagesBuilder: this.messagesBuilder, filterId: this.filterId, entityUri: this.entityUri, application: this._application, onEzChangeFilter: (ev) => this.handleChangeFilterAssistentMode(ev.detail), isDefaultFilter: this.isDefaultFilter })), index.h("stack-item", null, index.h("snk-filter-advanced-mode", { ref: (ref) => this._elAdvancedMode = ref, filterAssistent: this._filterAssistent, application: this._application, onEzExpressionChange: (ev) => this.handleExpressionChangeAdvancedMode(ev.detail) }))));
2007
+ }
2008
+ handleModeChange() {
2009
+ var _a, _b;
2010
+ if (this._filterAssistentMode) {
2011
+ utils.ApplicationUtils.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.title"), this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.description"))
2012
+ .then((canCancel) => {
2013
+ if (!canCancel)
2014
+ return;
2015
+ this._filterAssistentMode = !this._filterAssistentMode;
2016
+ if (!this.hasChangesToSave()) {
2017
+ const expression = PersonalizedFilterUtils.PersonalizedFilterUtils.buildGroupExpression(this._filterAssistent.assistent);
2018
+ this._filterAssistent.expression = expression;
2019
+ this._elButtonSave.enabled = !this.hasChangesToSave();
2020
+ }
2021
+ });
2022
+ }
2023
+ else {
2024
+ if (((_a = this._filterAssistent) === null || _a === void 0 ? void 0 : _a.expression) === ((_b = this._originalFilterAssistent) === null || _b === void 0 ? void 0 : _b.expression)) {
2025
+ this._filterAssistentMode = !this._filterAssistentMode;
2026
+ }
2027
+ else {
2028
+ const expressionBefore = this._filterAssistent.expression;
2029
+ const expression = PersonalizedFilterUtils.PersonalizedFilterUtils.buildGroupExpression(this._filterAssistent.assistent);
2030
+ if (expressionBefore !== expression) {
2031
+ utils.ApplicationUtils.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.title"), this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.description"))
2032
+ .then((canCancel) => {
2033
+ if (!canCancel)
2034
+ return;
2035
+ this._filterAssistent = Object.assign(Object.assign({}, this._filterAssistent), { expression });
2036
+ this._filterAssistentMode = !this._filterAssistentMode;
2037
+ });
2038
+ }
2039
+ else {
2040
+ this._filterAssistentMode = !this._filterAssistentMode;
2041
+ }
2042
+ }
2043
+ }
2044
+ }
2045
+ buildTitle() {
2046
+ if (this.isDefaultFilter && !this.filterId) {
2047
+ return this.getMessage("snkPersonalizedFilter.info.titleCreateDefault");
2048
+ }
2049
+ if (this.isDefaultFilter && this.filterId) {
2050
+ return this.getMessage("snkPersonalizedFilter.info.titleEditDefault");
2051
+ }
2052
+ if (this.filterId) {
2053
+ return this.getMessage("snkPersonalizedFilter.info.titleEdit");
2054
+ }
2055
+ return this.getMessage("snkPersonalizedFilter.info.titleAdd");
2056
+ }
2057
+ render() {
2058
+ var _a, _b, _c, _d;
2059
+ if (!((_a = this._filterAssistent) === null || _a === void 0 ? void 0 : _a.assistent) && this._filterAssistentMode) {
2060
+ return;
2061
+ }
2062
+ return (index.h(index.Host, null, index.h("div", { class: "snk-personalized-filter" }, index.h("div", null, index.h("snk-simple-bar", { label: this.buildTitle(), onExit: () => this.handleCancel() }, index.h("div", { class: "snk-personalized-filter__header-actions", slot: "rightSlot" }, index.h("ez-button", { label: this.getMessage("snkPersonalizedFilter.info.labelCancel"), onClick: () => this.handleCancel() }), index.h("ez-button", { ref: (el) => this._elButtonSave = el, enabled: false, class: "ez-button--primary", label: this.getMessage("snkPersonalizedFilter.info.labelSave"), onClick: this.handleSave.bind(this) })))), index.h("div", { class: "ez-box ez-margin-bottom--medium ez-box__main" }, index.h("div", { class: "ez-box__container" }, index.h("div", { class: "ez-flex ez-flex--column ez-size-width--full" }, index.h("div", { class: "ez-flex" }, index.h("ez-tooltip", { message: this.getMessage("snkPersonalizedFilter.info.textInputDisabled"), active: this.isDefaultFilter }, index.h("ez-text-input", { class: "ez-padding-right--medium", label: this.getMessage("snkPersonalizedFilter.info.labelNameFilter"), value: (_b = this._filterAssistent) === null || _b === void 0 ? void 0 : _b.name, onEzChange: (evt) => this.handleTitleChange(evt.detail), enabled: !this.isDefaultFilter })), this.renderButtonAddField(), index.h("ez-button", { ref: (el) => this._elButtonMode = el, class: "snk-personalized-filter__button-mode", label: this._filterAssistentMode ? this.getMessage("snkPersonalizedFilter.info.activeModeAdvanced") : this.getMessage("snkPersonalizedFilter.info.activeModeAssistent"), onClick: () => this.handleModeChange(), "data-tooltip": !(this._filterAssistentMode || ((_c = this._filterAssistent) === null || _c === void 0 ? void 0 : _c.assistent)) ? this.getMessage("snkPersonalizedFilter.info.tooltipDisabledAssistentMode") : undefined, "data-flow": "bottom", enabled: (!this._filterAssistent.name || Boolean(this._filterAssistentMode || ((_d = this._filterAssistent) === null || _d === void 0 ? void 0 : _d.assistent))) })), this.buildContainerPersonalizedFilter()))))));
2063
+ }
2064
+ static get watchers() { return {
2065
+ "filterId": ["loadFilter"]
2066
+ }; }
2067
+ };
2068
+ SnkPersonalizedFilter.style = snkPersonalizedFilterCss;
2069
+
2070
+ const snkSimpleBarCss = ".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}";
2071
+
2072
+ const SnkSimpleBar = class {
2073
+ constructor(hostRef) {
2074
+ index.registerInstance(this, hostRef);
2075
+ this.clickBreadcrumbItem = index.createEvent(this, "clickBreadcrumbItem", 3);
2076
+ this.exit = index.createEvent(this, "exit", 3);
2077
+ this.label = undefined;
2078
+ this.breadcrumbItens = undefined;
2079
+ this.messagesBuilder = undefined;
2080
+ }
2081
+ /**
2082
+ * Permite customizar as mensagens dos blocos de construção
2083
+ * através de um pequeno módulo na estrutura da aplicação:
2084
+ * - Crie um arquivo no seguinte caminho: /messages/appmessages.msg.js.
2085
+ * Para conhecer os detalhes do módulo, veja o arquivo neste projeto: "/src/lib/message/resources/snk-simple-bar.msg.ts"
2086
+ */
2087
+ getMessage(key, params) {
2088
+ var _a;
2089
+ if (this.messagesBuilder)
2090
+ return this.messagesBuilder.getMessage(key, params);
2091
+ if ((_a = this._application) === null || _a === void 0 ? void 0 : _a.messagesBuilder)
2092
+ return this._application.messagesBuilder.getMessage(key, params);
2093
+ }
2094
+ componentDidLoad() {
2095
+ if (!this._element)
2096
+ return;
2097
+ core.ElementIDUtils.addIDInfo(this._element);
2098
+ this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
2099
+ }
2100
+ render() {
2101
+ return (index.h("div", { class: "simple-bar__container ez-margin-vertical--small ez-padding--extra-small" }, index.h("div", { class: "simple-bar__left-slot" }, index.h("ez-button", { class: "ez-padding-right--medium", title: this.getMessage('snkSimpleBar.backTitle'), mode: 'icon', iconName: "arrow_back", size: 'medium', onClick: () => this.exit.emit() }), index.h("div", { class: "simple-bar__column" }, index.h("h1", { class: "ez-title ez-title--primary ez-title--extra-large" }, this.label), index.h("ez-breadcrumb", { items: this.breadcrumbItens, onSelectedItem: ({ detail }) => this.clickBreadcrumbItem.emit(detail) }))), index.h("div", { class: "simple-bar__right-slot" }, index.h("slot", { name: "rightSlot" }))));
2102
+ }
2103
+ get _element() { return index.getElement(this); }
2104
+ };
2105
+ SnkSimpleBar.style = snkSimpleBarCss;
2106
+
2107
+ const REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "MORE_OPTIONS"];
2108
+ const REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER", "MORE_OPTIONS"];
2109
+
2110
+ const snkSimpleCrudCss = ".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;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}";
2111
+
2112
+ const SnkSimpleCrud = class {
2113
+ constructor(hostRef) {
2114
+ index.registerInstance(this, hostRef);
2115
+ this.dataStateChange = index.createEvent(this, "dataStateChange", 3);
2116
+ this.dataUnitReady = index.createEvent(this, "dataUnitReady", 3);
2117
+ this.actionClick = index.createEvent(this, "actionClick", 7);
2118
+ this.formItemsReady = index.createEvent(this, "formItemsReady", 7);
2119
+ this.configuratorSave = index.createEvent(this, "configuratorSave", 7);
2120
+ this.configuratorCancel = index.createEvent(this, "configuratorCancel", 7);
2121
+ this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource.SnkMultiSelectionListDataSource();
2122
+ this._formConfigFetcher = new formConfigFetcher.FormConfigFetcher();
2123
+ this._customEditors = new Map();
2124
+ this._customRenders = new Map();
2125
+ this._container = undefined;
2126
+ this._showPopUpGridConfig = false;
2127
+ this._currentViewMode = constants.VIEW_MODE.GRID;
2128
+ this._config = undefined;
2129
+ this._fieldToGetFocus = undefined;
2130
+ this._customContainerId = `SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${core.StringUtils.generateUUID()}`;
2131
+ this.enableLockManagerLoadingComp = false;
2132
+ this.enableLockManagerTaskbarClick = false;
2133
+ this.dataState = undefined;
2134
+ this.dataUnit = undefined;
2135
+ this.entityName = undefined;
2136
+ this.mode = constants.SIMPLE_CRUD_MODE.SERVER;
2137
+ this.gridConfig = undefined;
2138
+ this.formConfig = undefined;
2139
+ this._formFields = [];
2140
+ this._fieldsProps = new Map();
2141
+ this.enableContinuousInsert = false;
2142
+ this.multipleSelection = undefined;
2143
+ this.useCancelConfirm = true;
2144
+ this.pageSize = 150;
2145
+ this.resourceID = undefined;
2146
+ this.enableGridInsert = false;
2147
+ this.paginationCounterMode = 'auto';
2148
+ this.taskbarManager = undefined;
2149
+ this.messagesBuilder = undefined;
2150
+ this.useEnterLikeTab = false;
2151
+ this.actionsList = undefined;
2152
+ this.configName = undefined;
2153
+ this.showConfiguratorButtons = false;
2154
+ this.gridLegacyConfigName = undefined;
2155
+ this.formLegacyConfigName = undefined;
2156
+ this.ignoreReadOnlyFormFields = false;
2157
+ this.autoFocus = true;
2158
+ this.domainMessagesBuilder = undefined;
2159
+ this.multipleEditionEnabled = true;
2160
+ this.layoutFormConfig = true;
2161
+ this.disableGridEdition = false;
2162
+ this.autoLoad = undefined;
2163
+ this.outlineMode = false;
2164
+ }
2165
+ /**
2166
+ * @description Registra um editor customizado para campos da grade e do formulário.
2167
+ * @param {string} fieldName - O nome do campo.
2168
+ * @param {ICustomEditor} customEditor - A instância do editor customizado.
2169
+ * @returns {Promise<void>}
2170
+ */
2171
+ async addCustomEditor(fieldName, customEditor) {
2172
+ if (this._grid && this._form) {
2173
+ this._grid.addCustomEditor(fieldName, customEditor);
2174
+ this._form.addCustomEditor(fieldName, customEditor);
2175
+ return;
2176
+ }
2177
+ const newCustomEditors = new Map(this._customEditors);
2178
+ newCustomEditors.set(fieldName, customEditor);
2179
+ this._customEditors = newCustomEditors;
2180
+ }
2181
+ /**
2182
+ * @description Registra um renderizador customizado para colunas da grade.
2183
+ * @param {string} fieldName - O nome do campo.
2184
+ * @param {ICustomRender} customRender - A instância do renderizador customizado.
2185
+ * @returns {Promise<void>}
2186
+ */
2187
+ async addGridCustomRender(fieldName, customRender) {
2188
+ if (this._grid) {
2189
+ this._grid.addGridCustomRender(fieldName, customRender);
2190
+ return;
2191
+ }
2192
+ const newCustomRenders = new Map(this._customRenders);
2193
+ newCustomRenders.set(fieldName, customRender);
2194
+ this._customRenders = newCustomRenders;
2195
+ }
2196
+ async handleResourceIDChanged(newValue, oldValue) {
2197
+ if (core.StringUtils.isEmpty(newValue)) {
2198
+ return;
2199
+ }
2200
+ if (newValue === oldValue) {
2201
+ return;
2202
+ }
2203
+ await this.loadFormConfig(true);
2204
+ await this.loadGridConfig(true);
2205
+ }
2206
+ /**
2207
+ * @description Registra um formatador de valores para uma coluna da grade.
2208
+ * @param {string} columnName - O nome da coluna.
2209
+ * @param {ICustomFormatter} customFormatter - A instância do formatador customizado.
2210
+ * @returns {Promise<void>}
2211
+ */
2212
+ async addCustomValueFormatter(columnName, customFormatter) {
2213
+ this._grid.addCustomValueFormatter(columnName, customFormatter);
2214
+ }
2215
+ /**
2216
+ * @description Remove o formatador de valores de uma coluna da grade.
2217
+ * @param {string} columnName - O nome da coluna.
2218
+ * @returns {Promise<void>}
2219
+ */
2220
+ async removeCustomValueFormatter(columnName) {
2221
+ this._grid.removeCustomValueFormatter(columnName);
2222
+ }
2223
+ /**
2224
+ * @description Altera/adiciona uma propriedade nos metadados do campo.
2225
+ * @param {string} fieldName - O nome do campo.
2226
+ * @param {string} propName - O nome da propriedade.
2227
+ * @param {any} value - O valor da propriedade.
2228
+ * @returns {Promise<void>}
2229
+ */
2230
+ async setFieldProp(fieldName, propName, value) {
2231
+ const newCustomFieldProps = new Map(this._fieldsProps);
2232
+ const currentProps = this._fieldsProps.get(fieldName);
2233
+ newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
2234
+ this._fieldsProps = newCustomFieldProps;
2235
+ }
2236
+ loadTaskbarProcessor() {
2237
+ const taskbarIDs = {};
2238
+ taskbarIDs[TASKBAR_ID.FORM_REGULAR] = this.getButtons(false, [taskbarElements.TaskbarElement.GRID_MODE], true);
2239
+ taskbarIDs[TASKBAR_ID.GRID_REGULAR] = this.getButtons(false, [taskbarElements.TaskbarElement.DATA_EXPORTER, taskbarElements.TaskbarElement.FORM_MODE]);
2240
+ taskbarIDs[TASKBAR_ID.FORM_SELECTED] = this.getButtons(true, [taskbarElements.TaskbarElement.GRID_MODE], true);
2241
+ taskbarIDs[TASKBAR_ID.GRID_SELECTED] = this.getGridSelectedButtonsCallBack.bind(this);
2242
+ taskbarIDs[TASKBAR_ID.FINISH_EDITION] = this.getFinishEditionButtonsCallback.bind(this);
2243
+ taskbarIDs[TASKBAR_ID.MULTIPLE_EDITION] = [taskbarElements.TaskbarElement.CANCEL];
2244
+ this._taskbarProcessor = new SnkMultiSelectionListDataSource.TaskbarProcessor(taskbarIDs);
2245
+ }
2246
+ getGridSelectedButtonsCallBack() {
2247
+ var _a, _b, _c;
2248
+ if (!this.multipleEditionEnabled || ((_c = (_b = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.selectionInfo) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length) === 1) {
2249
+ return this.getButtons(true, [taskbarElements.TaskbarElement.DATA_EXPORTER, taskbarElements.TaskbarElement.FORM_MODE]);
2250
+ }
2251
+ return this.getButtons(true, [taskbarElements.TaskbarElement.UPDATE_MULTIPLE, taskbarElements.TaskbarElement.DATA_EXPORTER, taskbarElements.TaskbarElement.FORM_MODE]);
2252
+ }
2253
+ getFinishEditionButtonsCallback() {
2254
+ const btns = [taskbarElements.TaskbarElement.CANCEL, taskbarElements.TaskbarElement.SAVE];
2255
+ if (this.enableGridInsert && this._currentViewMode !== constants.VIEW_MODE.ATTACHMENT) {
2256
+ btns.push(this._currentViewMode === constants.VIEW_MODE.GRID ? taskbarElements.TaskbarElement.FORM_MODE : taskbarElements.TaskbarElement.GRID_MODE);
2257
+ }
2258
+ return btns;
2259
+ }
2260
+ getButtons(selected, extraButtons, removeRefresh) {
2261
+ let btnList = selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS;
2262
+ if (removeRefresh || this.mode === constants.SIMPLE_CRUD_MODE.IN_MEMORY) {
2263
+ btnList = btnList.filter(item => item !== taskbarElements.TaskbarElement.REFRESH);
2264
+ }
2265
+ return this.addConfigButton(btnList.concat(extraButtons));
2266
+ }
2267
+ addConfigButton(buttons) {
2268
+ if (this.configName === undefined || (this.configName && this.gridLegacyConfigName)) {
2269
+ return buttons;
2270
+ }
2271
+ return buttons.concat(taskbarElements.TaskbarElement.CONFIGURATOR);
2272
+ }
2273
+ get application() {
2274
+ return core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
2275
+ }
2276
+ /**
2277
+ * @description Usado para alternar a visão entre GRID e FORM externamente.
2278
+ * @param {VIEW_MODE} view - A visão para a qual navegar.
2279
+ * @returns {Promise<void>}
2280
+ */
2281
+ async goToView(view) {
2282
+ this._currentViewMode = view;
2283
+ if (this._viewStack) {
2284
+ if (view === constants.VIEW_MODE.GRID)
2285
+ this.dataUnit.isMultipleEdition = false;
2286
+ this._viewStack.show(view);
2287
+ }
2288
+ if (view === constants.VIEW_MODE.GRID) {
2289
+ requestAnimationFrame(() => this.focusToGrid());
2290
+ }
2291
+ if (view === constants.VIEW_MODE.FORM) {
2292
+ requestAnimationFrame(() => this.focusToForm());
2293
+ }
2294
+ }
2295
+ actionClickListener(evt) {
2296
+ this.handleTaskbarAction(evt.detail);
2297
+ evt.stopPropagation();
2298
+ }
2299
+ handleTaskbarAction(action) {
2300
+ switch (action) {
2301
+ case taskbarElements.TaskbarElement.CONFIGURATOR:
2302
+ this._snkConfigurator.open();
2303
+ break;
2304
+ case taskbarElements.TaskbarElement.GRID_MODE:
2305
+ this.goToView(constants.VIEW_MODE.GRID);
2306
+ break;
2307
+ case taskbarElements.TaskbarElement.FORM_MODE:
2308
+ this.goToView(constants.VIEW_MODE.FORM);
2309
+ break;
2310
+ case taskbarElements.TaskbarElement.UPDATE_MULTIPLE:
2311
+ this.dataUnit.isMultipleEdition = true;
2312
+ this.goToView(constants.VIEW_MODE.FORM);
2313
+ break;
2314
+ }
2315
+ }
2316
+ async onChangeEntityName(newValue) {
2317
+ if (this.dataUnit)
2318
+ return;
2319
+ const application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
2320
+ this.dataUnit = await application.getDataUnit(newValue, null, null, this.configName);
2321
+ }
2322
+ onModeChange() {
2323
+ if (this.mode == constants.SIMPLE_CRUD_MODE.IN_MEMORY) {
2324
+ this.initInMemoryDataUnit();
2325
+ }
2326
+ }
2327
+ observeDataState(newValue, oldValue) {
2328
+ this.handleDataStateChange(newValue, oldValue);
2329
+ }
2330
+ async observeFormLegacy(newValue, oldValue) {
2331
+ await this.handleUpdateFormLegacyConfig(newValue, oldValue);
2332
+ }
2333
+ async observeGridLegacy(newValue, oldValue) {
2334
+ await this.handleUpdateGridLegacyConfig(newValue, oldValue);
2335
+ }
2336
+ async handleDataStateChange(newValue, oldValue) {
2337
+ if (core.ObjectUtils.objectToString(oldValue) != core.ObjectUtils.objectToString(newValue)) {
2338
+ this.dataStateChange.emit(newValue);
2339
+ }
2340
+ await this.processRmPrecision();
2341
+ }
2342
+ async processRmPrecision() {
2343
+ var _a, _b;
2344
+ const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
2345
+ for (const field of fieldsWithRmPrecision || []) {
2346
+ if (!field) {
2347
+ continue;
2348
+ }
2349
+ const rmPrecision = (_b = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata) === null || _b === void 0 ? void 0 : _b.getProp('rm_precision', field);
2350
+ if (!rmPrecision && rmPrecision !== 0) {
2351
+ continue;
2352
+ }
2353
+ await this.setFieldProp(field, 'precision', rmPrecision);
2354
+ await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
2355
+ }
2356
+ this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
2357
+ }
2358
+ async handleUpdateGridLegacyConfig(newValue, oldValue) {
2359
+ if (newValue == undefined || newValue == oldValue) {
2360
+ return;
2361
+ }
2362
+ if (!this._gridConfigAlreadyLoaded) {
2363
+ return;
2364
+ }
2365
+ await this.loadGridConfig(true);
2366
+ }
2367
+ async handleUpdateFormLegacyConfig(newValue, oldValue) {
2368
+ if (newValue == undefined || newValue == oldValue) {
2369
+ return;
2370
+ }
2371
+ if (!this._formConfigAlreadyLoaded) {
2372
+ return;
2373
+ }
2374
+ await this.loadFormConfig(true);
2375
+ }
2376
+ async openConfig(viewMode) {
2377
+ await this._snkConfigurator.close();
2378
+ if (viewMode === constants.VIEW_MODE.GRID) {
2379
+ await this.openGridConfig();
2380
+ }
2381
+ else if (viewMode === constants.VIEW_MODE.FORM) {
2382
+ await this.openFormConfig();
2383
+ }
2384
+ }
2385
+ async openGridConfig() {
2386
+ var _a, _b, _c, _d;
2387
+ const originalColumns = (_b = await ((_a = this._grid) === null || _a === void 0 ? void 0 : _a.getColumns())) !== null && _b !== void 0 ? _b : [];
2388
+ const gridColumns = (_d = await ((_c = this._grid) === null || _c === void 0 ? void 0 : _c.getColumnsState())) !== null && _d !== void 0 ? _d : [];
2389
+ this._snkGridConfig.columns = gridColumns.filter(c => c.name);
2390
+ this._snkGridConfig.originalColumns = originalColumns.filter(c => c.name);
2391
+ this._snkGridConfig.selectedIndex = 0;
2392
+ this._showPopUpGridConfig = true;
2393
+ }
2394
+ async openFormConfig() {
2395
+ if (this.formLegacyConfigName || this.configName) {
2396
+ await this._snkSimpleFormConfig.show();
2397
+ }
2398
+ }
2399
+ addGridLegacyConfigName() {
2400
+ if (this.gridLegacyConfigName && this.configName) {
2401
+ ConfigStorage.ConfigStorage.addGridLegacyConfig(this.configName, this.gridLegacyConfigName);
2402
+ }
2403
+ }
2404
+ loadGridConfig(forceUpdate) {
2405
+ if (this.configName === undefined) {
2406
+ return;
2407
+ }
2408
+ if ((this.gridConfig != undefined || this._gridConfigAlreadyLoaded) && !forceUpdate) {
2409
+ return;
2410
+ }
2411
+ this.addGridLegacyConfigName();
2412
+ this._gridConfigAlreadyLoaded = true;
2413
+ return new Promise((accept, reject) => {
2414
+ ConfigStorage.ConfigStorage.loadGridConfig(this.configName, this.resolveResourceID())
2415
+ .then(config => {
2416
+ this.setGridConfig(config);
2417
+ accept();
2418
+ })
2419
+ .catch(reason => {
2420
+ reject(reason);
2421
+ });
2422
+ });
2423
+ }
2424
+ formConfigIsLoaded() {
2425
+ return this.formConfig != undefined || this._formConfigAlreadyLoaded;
2426
+ }
2427
+ async loadFormConfig(forceLoad = false, forceSetNewConfig = false) {
2428
+ if (this.configName === undefined) {
2429
+ return;
2430
+ }
2431
+ if (this._formConfigManager == undefined) {
2432
+ this._formConfigManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resolveResourceID(), undefined, this.dataUnit);
2433
+ this._formConfigManager.setConfig(this.formConfig);
2434
+ }
2435
+ if (this.formConfigIsLoaded() && !forceLoad) {
2436
+ return;
2437
+ }
2438
+ this._formConfigAlreadyLoaded = true;
2439
+ let loadedLegacyConfig = await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);
2440
+ if (loadedLegacyConfig != undefined) {
2441
+ this._formConfigManager.setConfig(loadedLegacyConfig);
2442
+ this.setFormConfig(loadedLegacyConfig, forceSetNewConfig);
2443
+ return;
2444
+ }
2445
+ this.setFormConfig(await this._formConfigManager.loadConfig());
2446
+ }
2447
+ async componentWillRender() {
2448
+ this.loadTaskbarProcessor();
2449
+ this._resourceID = await this.application.getResourceID();
2450
+ this.dataExporterProviderStore();
2451
+ this.dataExporterProviderStore();
2452
+ this._taskbarProcessor.process(this.getTaskBarId(), this.taskbarManager, this.dataState, this.getTaskBarDisabledButtons());
2453
+ if (this.configName === undefined) {
2454
+ return;
2455
+ }
2456
+ if (this.gridConfig != undefined || this._gridConfigAlreadyLoaded) {
2457
+ return;
2458
+ }
2459
+ await this.addGridLegacyConfigName();
2460
+ await this.loadGridConfig();
2461
+ await this.loadFormConfig();
2462
+ }
2463
+ componentDidRender() {
2464
+ this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
2465
+ this.addGridCustomValueFormattters();
2466
+ this.setFieldsProps();
2467
+ this.setCustomRenders();
2468
+ this.setCustomEditors();
2469
+ }
2470
+ componentWillLoad() {
2471
+ this.processMetadata();
2472
+ this.onModeChange();
2473
+ this.configDatasource();
2474
+ this._rmPrecisionCustomValueFormatter = new SnkMultiSelectionListDataSource.RmPrecisionCustomValueFormatter();
2475
+ this._continuousInsertUtils = new ContinuousInsertUtils.ContinuousInsertUtils(this.application, this.resolveResourceID(), this.configName);
2476
+ if (this.enableGridInsert) {
2477
+ this._continuousInsertUtils.getConfig().then(value => this.enableContinuousInsert = value);
2478
+ }
2479
+ }
2480
+ componentDidLoad() {
2481
+ utils.CSSVarsUtils.applyVarsGrid(this._element, this._grid);
2482
+ this.initKeyboardManager();
2483
+ this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this));
2484
+ }
2485
+ async dataUnitActionHandler(action) {
2486
+ if (action.type === core.Action.EDITION_CANCELED || action.type === core.Action.DATA_SAVED) {
2487
+ if (this.dataUnit.isMultipleEdition) {
2488
+ this.goToView(constants.VIEW_MODE.GRID);
2489
+ }
2490
+ }
2491
+ }
2492
+ getMessage(key, params) {
2493
+ var _a;
2494
+ return (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, params);
2495
+ }
2496
+ disconnectedCallback() {
2497
+ var _a;
2498
+ (_a = this._keyboardManager) === null || _a === void 0 ? void 0 : _a.unbindAllShortcutKeys();
2499
+ }
2500
+ setCustomRenders() {
2501
+ if (!this._grid) {
2502
+ return;
2503
+ }
2504
+ for (const [fieldName, customRender] of this._customRenders) {
2505
+ this._grid.addGridCustomRender(fieldName, customRender);
2506
+ this._customRenders.delete(fieldName);
2507
+ }
2508
+ }
2509
+ setCustomEditors() {
2510
+ if (!this._grid || !this._form) {
2511
+ return;
2512
+ }
2513
+ for (const [fieldName, customEditor] of this._customEditors) {
2514
+ this._grid.addCustomEditor(fieldName, customEditor);
2515
+ this._form.addCustomEditor(fieldName, customEditor);
2516
+ this._customEditors.delete(fieldName);
2517
+ }
2518
+ }
2519
+ configDatasource() {
2520
+ this._multiSelectionListDataSource.setApplication(this.application);
2521
+ this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
2522
+ }
2523
+ setFieldsProps() {
2524
+ if (!this._form) {
2525
+ return;
2526
+ }
2527
+ for (const [fieldName, props] of this._fieldsProps) {
2528
+ for (const prop in props) {
2529
+ this._form.setFieldProp(fieldName, prop, props[prop]);
2530
+ }
2531
+ this._fieldsProps.delete(fieldName);
2532
+ }
2533
+ }
2534
+ getTaskBarId() {
2535
+ var _a, _b;
2536
+ if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
2537
+ return TASKBAR_ID.FINISH_EDITION;
2538
+ }
2539
+ if (this.dataUnit.isMultipleEdition) {
2540
+ return TASKBAR_ID.MULTIPLE_EDITION;
2541
+ }
2542
+ if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectionInfo) &&
2543
+ !this.dataState.selectionInfo.isAllRecords() &&
2544
+ this.dataState.selectionInfo.length > 0) {
2545
+ return this._currentViewMode === constants.VIEW_MODE.GRID ? TASKBAR_ID.GRID_SELECTED : TASKBAR_ID.FORM_SELECTED;
2546
+ }
2547
+ return this._currentViewMode === constants.VIEW_MODE.GRID ? TASKBAR_ID.GRID_REGULAR : TASKBAR_ID.FORM_REGULAR;
2548
+ }
2549
+ initInMemoryDataUnit() {
2550
+ this._inMemoryLoader = new dataunitFetcher.InMemoryLoader(this._metadata, undefined, { autoLoad: this.autoLoad });
2551
+ this.dataUnit = this._inMemoryLoader.dataUnit;
2552
+ this.dataUnitReady.emit(this.dataUnit);
2553
+ }
2554
+ /**
2555
+ * @description Define os metadados do DataUnit.
2556
+ * @param {UnitMetadata} metadata - Os metadados a serem definidos.
2557
+ * @returns {Promise<void>}
2558
+ */
2559
+ setMetadata(metadata) {
2560
+ if (this._inMemoryLoader) {
2561
+ this._inMemoryLoader.metadata = metadata;
2562
+ }
2563
+ else if (this.dataUnit) {
2564
+ this.dataUnit.metadata = metadata;
2565
+ }
2566
+ return Promise.resolve();
2567
+ }
2568
+ /**
2569
+ * @description Define os registros do DataUnit.
2570
+ * @param {Array<Record>} records - Os registros a serem definidos.
2571
+ * @returns {Promise<void>}
2572
+ */
2573
+ setRecords(records) {
2574
+ if (this._inMemoryLoader) {
2575
+ this._inMemoryLoader.records = records;
2576
+ }
2577
+ else if (this.dataUnit) {
2578
+ this.dataUnit.records = records;
2579
+ }
2580
+ return Promise.resolve();
2581
+ }
2582
+ /**
2583
+ * @description Obtém os registros do DataUnit.
2584
+ * @returns {Promise<Array<Record>>} Uma promessa que resolve com a lista de registros.
2585
+ */
2586
+ getRecords() {
2587
+ return Promise.resolve(this.dataUnit.records);
2588
+ }
2589
+ /**
2590
+ * @description Usado para abrir o configurador do CRUD.
2591
+ * @returns {Promise<void>}
2592
+ */
2593
+ async openConfigurator() {
2594
+ var _a;
2595
+ (_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.open();
2596
+ }
2597
+ /**
2598
+ * @description Usado para fechar o configurador do CRUD.
2599
+ * @returns {Promise<void>}
2600
+ */
2601
+ async closeConfigurator() {
2602
+ var _a;
2603
+ (_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.close();
2604
+ }
2605
+ /**
2606
+ * @description Atualiza a configuração do formulário.
2607
+ * @returns {Promise<void>}
2608
+ */
2609
+ async updateConfig() {
2610
+ if (this._formConfigManager == undefined) {
2611
+ this._formConfigManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resolveResourceID());
2612
+ }
2613
+ this._formConfigManager.setConfig(this.formConfig);
2614
+ }
2615
+ processMetadata() {
2616
+ const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
2617
+ const fieldMetadata = [];
2618
+ const formConfig = { fields: [], emptyConfig: false };
2619
+ fieldsMetadataElem.forEach(fieldElem => {
2620
+ const field = {
2621
+ name: fieldElem.getAttribute("name") || fieldElem.getAttribute("label"),
2622
+ label: fieldElem.getAttribute("label"),
2623
+ dataType: core.DataType[fieldElem.getAttribute("dataType")] || core.DataType.TEXT,
2624
+ userInterface: core.UserInterface[fieldElem.getAttribute("userInterface")] || core.UserInterface.SHORTTEXT,
2625
+ readOnly: fieldElem.getAttribute("readOnly") == "true",
2626
+ required: fieldElem.getAttribute("required") == "true",
2627
+ tab: fieldElem.getAttribute("tab") || undefined,
2628
+ visible: fieldElem.getAttribute("visible") != "false"
2629
+ };
2630
+ const fieldConfig = { name: field.name, tab: field.tab, visible: field.visible };
2631
+ formConfig.fields.push(fieldConfig);
2632
+ fieldMetadata.push(field);
2633
+ });
2634
+ if (fieldMetadata.length > 0) {
2635
+ if (!this.formConfig) {
2636
+ this.formConfig = formConfig;
2637
+ }
2638
+ this._metadata = {
2639
+ name: "SimpleCrud",
2640
+ label: "SimpleCrud",
2641
+ fields: fieldMetadata
2642
+ };
2643
+ }
2644
+ }
2645
+ addGridCustomValueFormattters() {
2646
+ var _a, _b, _c;
2647
+ const metadataFields = ((_a = this._metadata) === null || _a === void 0 ? void 0 : _a.fields) || ((_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.fields);
2648
+ if (!metadataFields) {
2649
+ return;
2650
+ }
2651
+ const fieldsWithRmPrecision = [];
2652
+ metadataFields.forEach((field) => {
2653
+ var _a;
2654
+ if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !fieldsWithRmPrecision.includes(field.name)) {
2655
+ fieldsWithRmPrecision.push(field.name);
2656
+ }
2657
+ });
2658
+ fieldsWithRmPrecision.forEach(field => {
2659
+ this.addCustomValueFormatter(field, this._rmPrecisionCustomValueFormatter);
2660
+ });
2661
+ }
2662
+ onDataStateChange(evt) {
2663
+ this.dataState = Object.assign({}, evt.detail);
2664
+ }
2665
+ getTaskBarDisabledButtons() {
2666
+ var _a, _b, _c, _d, _e, _f;
2667
+ const disabledButtons = [];
2668
+ if (!((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.hasNext)) {
2669
+ disabledButtons.push(taskbarElements.TaskbarElement.NEXT);
2670
+ }
2671
+ if (!((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.hasPrevious)) {
2672
+ disabledButtons.push(taskbarElements.TaskbarElement.PREVIOUS);
2673
+ }
2674
+ if ((_d = (_c = this.dataState) === null || _c === void 0 ? void 0 : _c.selectionInfo) === null || _d === void 0 ? void 0 : _d.isEmpty()) {
2675
+ disabledButtons.push(taskbarElements.TaskbarElement.FORM_MODE);
2676
+ }
2677
+ if (((_f = (_e = this.dataState) === null || _e === void 0 ? void 0 : _e.selectionInfo) === null || _f === void 0 ? void 0 : _f.length) > 1) {
2678
+ disabledButtons.push(taskbarElements.TaskbarElement.CLONE);
2679
+ }
2680
+ return disabledButtons;
2681
+ }
2682
+ handleCancelEdit() {
2683
+ var _a;
2684
+ if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.recordsIsEmpty) {
2685
+ this.goToView(constants.VIEW_MODE.GRID);
2686
+ this.dataUnit.clearSelection();
2687
+ }
2688
+ }
2689
+ handleConfiguratorEvent(evt, type) {
2690
+ evt.stopImmediatePropagation();
2691
+ if (type === 'SAVE') {
2692
+ this.configuratorSave.emit();
2693
+ return;
2694
+ }
2695
+ this.configuratorCancel.emit();
2696
+ }
2697
+ onSelectField(option) {
2698
+ if (option == undefined) {
2699
+ return;
2700
+ }
2701
+ this._fieldToGetFocus = option.value;
2702
+ }
2703
+ getFieldSearch(splitButton, item) {
2704
+ if (this._fieldSearch != undefined) {
2705
+ return this._fieldSearch;
2706
+ }
2707
+ this._splitButtonForm = splitButton;
2708
+ this._fieldSearch = utils.buildFieldSearch(item, ({ argument }) => this.fieldsOptionLoader(argument), (option) => this.onSelectField(option));
2709
+ return this._fieldSearch;
2710
+ }
2711
+ getFormFields() {
2712
+ var _a, _b;
2713
+ return (_b = (_a = this.formConfig) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : this._formFields;
2714
+ }
2715
+ handleFormSetFields(fields) {
2716
+ if (!core.ObjectUtils.equals(this._formFields, fields)) {
2717
+ this._formFields = fields !== null && fields !== void 0 ? fields : [];
2718
+ }
2719
+ }
2720
+ fieldsOptionLoader(argument) {
2721
+ const searchTerm = argument === null || argument === void 0 ? void 0 : argument.toLowerCase();
2722
+ const allFields = this.getFormFields().map(field => { var _a; return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field.name); });
2723
+ const filteredFields = allFields.filter(field => {
2724
+ var _a, _b;
2725
+ return ((_a = field.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTerm)) ||
2726
+ ((_b = field.label) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTerm));
2727
+ });
2728
+ const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
2729
+ return Promise.resolve(options);
2730
+ }
2731
+ isGridInsertActive() {
2732
+ return this.enableGridInsert && this.dataUnit.hasNewRecord();
2733
+ }
2734
+ getColumnSearch(splitButton, item) {
2735
+ if (this._columnSearch != undefined) {
2736
+ return this._columnSearch;
2737
+ }
2738
+ this._splitButton = splitButton;
2739
+ this._columnSearch = utils.buildFieldSearch(item, ({ argument }) => new Promise(accept => {
2740
+ this._grid.filterColumns(argument).then((columns) => {
2741
+ accept(columns
2742
+ .filter(column => !column.hidden)
2743
+ .map(column => ({ label: column.label, value: column.name })));
2744
+ });
2745
+ }), (option) => {
2746
+ if (option != undefined) {
2747
+ this._grid.locateColumn(option.value);
2748
+ }
2749
+ });
2750
+ return this._columnSearch;
2751
+ }
2752
+ getActionsList() {
2753
+ const hardList = [];
2754
+ if (this.enableGridInsert) {
2755
+ hardList.push(this._continuousInsertUtils.actionContinuousInsert(this.enableContinuousInsert, () => {
2756
+ this.enableContinuousInsert = !this.enableContinuousInsert;
2757
+ this._continuousInsertUtils.handleSaveConfig(this.enableContinuousInsert);
2758
+ }));
2759
+ }
2760
+ if (this.isGridInsertActive())
2761
+ return hardList;
2762
+ if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
2763
+ const taskbarID = this.getTopTaskBarId();
2764
+ return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this.dataState, this.actionsList));
2765
+ }
2766
+ return hardList.concat(this.actionsList);
2767
+ }
2768
+ getSettingsListGrid() {
2769
+ const hardList = [{
2770
+ value: core.StringUtils.generateUUID(),
2771
+ label: this.getMessage("snkSimpleCrud.findColumn"),
2772
+ disableCloseOnSelect: true,
2773
+ eagerInitialize: true,
2774
+ itemBuilder: (splitButton, item) => this.getColumnSearch(splitButton, item)
2775
+ }];
2776
+ return hardList;
2777
+ }
2778
+ getSettingsListForm() {
2779
+ const hardList = [{
2780
+ value: core.StringUtils.generateUUID(),
2781
+ label: this.getMessage("snkSimpleCrud.findFields"),
2782
+ disableCloseOnSelect: true,
2783
+ eagerInitialize: true,
2784
+ itemBuilder: (splitButton, item) => this.getFieldSearch(splitButton, item)
2785
+ }];
2786
+ return hardList;
2787
+ }
2788
+ getTopTaskBarId() {
2789
+ var _a;
2790
+ return ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? `snkGridTopTaskbar.finish_edition${index$2.PresentationMode.PRIMARY}` :
2791
+ `snkGridTopTaskbar.regular${index$2.PresentationMode.PRIMARY}`;
2792
+ }
2793
+ clearFieldToFocusHandler() {
2794
+ this._fieldToGetFocus = undefined;
2795
+ }
2796
+ gridConfigChangeHandler(evt) {
2797
+ evt.stopPropagation();
2798
+ if (!this.configName)
2799
+ return;
2800
+ const config = evt.detail;
2801
+ ConfigStorage.ConfigStorage.saveGridConfig(config, this.configName, this.resolveResourceID());
2802
+ }
2803
+ modalConfigChangeHandler(evt) {
2804
+ const config = evt.detail;
2805
+ this._grid.setColumnsState(config.columns)
2806
+ .then(() => {
2807
+ this.setGridConfig(config);
2808
+ this.closeGridConfig();
2809
+ this.dataExporterProviderStore();
2810
+ });
2811
+ evt.stopPropagation();
2812
+ }
2813
+ async dataExporterProviderStore() {
2814
+ if (this.dataUnit == undefined) {
2815
+ return;
2816
+ }
2817
+ if (this._grid == undefined) {
2818
+ return;
2819
+ }
2820
+ const dataExporterProvider = new SnkMultiSelectionListDataSource.ClientSideExporterProvider(this.dataUnit, this._grid);
2821
+ index$1.store.set("exporterProviders", Object.assign(Object.assign({}, index$1.store.get("exporterProviders")), { [this.getDataExporterStoreKey()]: dataExporterProvider }));
2822
+ }
2823
+ getDataExporterStoreKey() {
2824
+ return `SnkSimpleCrudDataExporter:${this.configName == undefined ? this.dataUnit.name : this.configName}`;
2825
+ }
2826
+ setGridConfig(config) {
2827
+ this.gridConfig = config;
2828
+ SnkMultiSelectionListDataSource.CrudUtils.assertDefaultSorting(this.gridConfig, this.dataUnit);
2829
+ }
2830
+ setFormConfig(config, forceUpdate) {
2831
+ if (this.formConfig && !forceUpdate)
2832
+ return;
2833
+ this.formConfig = config;
2834
+ }
2835
+ closeGridConfig() {
2836
+ this._showPopUpGridConfig = false;
2837
+ }
2838
+ getPageSize() {
2839
+ if (this.mode === constants.SIMPLE_CRUD_MODE.IN_MEMORY) {
2840
+ return 0;
2841
+ }
2842
+ if (this.pageSize == undefined) {
2843
+ return 150;
2844
+ }
2845
+ return this.pageSize;
2846
+ }
2847
+ resolveResourceID() {
2848
+ return core.StringUtils.isEmpty(this.resourceID) ? this._resourceID : this.resourceID;
2849
+ }
2850
+ getFormConfig() {
2851
+ var _a;
2852
+ const configFromManager = (_a = this._formConfigManager) === null || _a === void 0 ? void 0 : _a.getConfig(this.dataUnit, this.ignoreReadOnlyFormFields);
2853
+ if (!this.configName && !configFromManager) {
2854
+ return this.formConfig;
2855
+ }
2856
+ return configFromManager;
2857
+ }
2858
+ updateFormConfig() {
2859
+ let newConfig = this.formConfig;
2860
+ if (this.formLegacyConfigName == undefined) {
2861
+ newConfig = Object.assign(Object.assign({}, this.formConfig), { fields: this.dataUnit.metadata.fields });
2862
+ }
2863
+ this.setFormConfig(newConfig, true);
2864
+ if (this._formConfigManager == undefined) {
2865
+ this._formConfigManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resolveResourceID());
2866
+ }
2867
+ this._formConfigManager.setConfig(this.formConfig);
2868
+ }
2869
+ handleDataUnitOnInsertionMode() {
2870
+ if (this.enableGridInsert)
2871
+ return;
2872
+ this.goToView(constants.VIEW_MODE.FORM);
2873
+ }
2874
+ async initKeyboardManager() {
2875
+ var _a;
2876
+ this._keyboardManager = new core.KeyboardManager({ propagate: false, element: this._element });
2877
+ const dataUnit = this.dataUnit || await ((_a = this._snkDataUnit) === null || _a === void 0 ? void 0 : _a.getDataUnit());
2878
+ if (dataUnit == undefined) {
2879
+ return;
2880
+ }
2881
+ this._keyboardManager
2882
+ .bind("F7", () => dataUnit.saveData(), { description: this.getMessage("snkSimpleCrud.keyboardShortcuts.saveData"), element: this._element })
2883
+ .bind("F8", dataUnit.addRecord.bind(dataUnit), { description: this.getMessage("snkSimpleCrud.keyboardShortcuts.addRecord"), element: this._element })
2884
+ .bind("F9", dataUnit.removeSelectedRecords.bind(dataUnit), { description: this.getMessage("snkSimpleCrud.keyboardShortcuts.removeRecord"), element: this._element })
2885
+ .bind("Escape", () => {
2886
+ if (dataUnit.isDirty()) {
2887
+ dataUnit.cancelEdition();
2888
+ }
2889
+ }, {
2890
+ debounceTime: 1000,
2891
+ description: this.getMessage("snkSimpleCrud.keyboardShortcuts.cancelAction"), element: this._element
2892
+ });
2893
+ }
2894
+ async handleFormConfigSaved() {
2895
+ await this.loadFormConfig(true, true);
2896
+ }
2897
+ focusToGrid() {
2898
+ const gridElement = this._grid;
2899
+ gridElement.focus();
2900
+ }
2901
+ focusToForm() {
2902
+ const formElement = this._form;
2903
+ formElement.focus();
2904
+ }
2905
+ renderTaskbarContent(layout) {
2906
+ var _a;
2907
+ return (index.h("snk-taskbar", { class: `ez-box--no-outline ez-box ${this._currentViewMode === constants.VIEW_MODE.FORM ? (this.outlineMode ? 'ez-box--outline' : 'ez-box--shadow-xsmall') + ' ez-padding--small' : ''}`, dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), actionsSettingsList: layout === constants.VIEW_MODE.GRID ? this.getSettingsListGrid() : this.getSettingsListForm(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: index$2.PresentationMode.SECONDARY, tabindex: "0" }, index.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
2908
+ }
2909
+ /* istanbul ignore next */
2910
+ render() {
2911
+ var _a;
2912
+ if (this.dataUnit == undefined) {
2913
+ return;
2914
+ }
2915
+ return (index.h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: this.handleDataUnitOnInsertionMode.bind(this), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, index.h("header", null, index.h("slot", { name: "snkSimpleCrudHeader" })), index.h("section", { class: `ez-box ez-box--no-outline ${this.outlineMode ? 'ez-box--outline' : 'ez-box--shadow'} simple-crud__container-section`, ref: (ref) => this._container = ref, tabindex: "0" }, index.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index.h("stack-item", null, index.h("ez-grid", { class: "ez-margin-bottom--large ez-box--no-outline", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(constants.VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
2916
+ ? undefined
2917
+ : 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(constants.VIEW_MODE.GRID), index.h("div", { slot: "footer" }, index.h("slot", { name: "snkSimpleCrudFooter" })))), index.h("stack-item", null, this.renderTaskbarContent(constants.VIEW_MODE.FORM), index.h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ez-box--no-outline`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this), elementFocusSearchField: this._container, tabindex: "0" }), index.h("slot", { name: "snkSimpleCrudFormFooter" }), index.h("snk-simple-form-config", { ref: (ref) => this._snkSimpleFormConfig = ref, dataUnit: this.dataUnit, onSnkConfigSaved: this.handleFormConfigSaved.bind(this), configName: (_a = this.formLegacyConfigName) !== null && _a !== void 0 ? _a : this.configName, messagesBuilder: this.messagesBuilder })), this.messagesBuilder && index.h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId, layoutFormConfig: this.layoutFormConfig })), index.h("div", { id: `${this._customContainerId}` }, index.h("slot", { name: "SnkConfigContainerSlot" }))), index.h("ez-popup", { size: "medium", heightMode: "auto", useHeader: false, opened: this._showPopUpGridConfig, onEzClosePopup: () => this.closeGridConfig() }, index.h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
2918
+ }
2919
+ get _element() { return index.getElement(this); }
2920
+ static get watchers() { return {
2921
+ "resourceID": ["handleResourceIDChanged"],
2922
+ "entityName": ["onChangeEntityName"],
2923
+ "mode": ["onModeChange"],
2924
+ "dataState": ["observeDataState"],
2925
+ "formLegacyConfigName": ["observeFormLegacy"],
2926
+ "gridLegacyConfigName": ["observeGridLegacy"]
2927
+ }; }
2928
+ };
2929
+ var TASKBAR_ID;
2930
+ (function (TASKBAR_ID) {
2931
+ TASKBAR_ID["FORM_REGULAR"] = "snkSimpleCrudTaskbar.form_regular";
2932
+ TASKBAR_ID["GRID_REGULAR"] = "snkSimpleCrudTaskbar.grid_regular";
2933
+ TASKBAR_ID["FORM_SELECTED"] = "snkSimpleCrudTaskbar.form_selected";
2934
+ TASKBAR_ID["GRID_SELECTED"] = "snkSimpleCrudTaskbar.grid_selected";
2935
+ TASKBAR_ID["FINISH_EDITION"] = "snkSimpleCrudTaskbar.finish_edition";
2936
+ TASKBAR_ID["MULTIPLE_EDITION"] = "snkSimpleCrudTaskbar.multiple_edition";
2937
+ })(TASKBAR_ID || (TASKBAR_ID = {}));
2938
+ SnkSimpleCrud.style = snkSimpleCrudCss;
2939
+
2940
+ exports.snk_attach = SnkAttach;
2941
+ exports.snk_default_filter = SnkDefaultFilter;
2942
+ exports.snk_dynaform_form_view = SnkDynaformFormView;
2943
+ exports.snk_filter_advanced_mode = SnkFilterAdvancedMode;
2944
+ exports.snk_filter_assistent_mode = SnkFilterAssistentMode;
2945
+ exports.snk_filter_detail = SnkFilterDetail;
2946
+ exports.snk_filter_modal_item = SnkFilterModalItem;
2947
+ exports.snk_image_input = SnkImageInput;
2948
+ exports.snk_personalized_filter = SnkPersonalizedFilter;
2949
+ exports.snk_simple_bar = SnkSimpleBar;
2950
+ exports.snk_simple_crud = SnkSimpleCrud;