@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-131882.2 → 0.0.0-bugfix-dev-KB-174860.0

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