@sankhyalabs/sankhyablocks 8.16.0-dev.7 → 8.16.0-dev.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. package/dist/cjs/{ConfigStorage-a343e418.js → ConfigStorage-d024aec8.js} +2 -2
  2. package/dist/cjs/{IExporterProvider-597949f9.js → ContinuousInsertUtils-54d44192.js} +65 -23
  3. package/dist/cjs/{DataFetcher-313debd8.js → DataFetcher-65879b2c.js} +216 -76
  4. package/dist/cjs/{RecordIDUtils-3735135c.js → GetSelectedRecordsIDsInfo-bd50caf1.js} +10 -10
  5. package/dist/cjs/{SnkFormConfigManager-166cbd1f.js → SnkFormConfigManager-07f747be.js} +75 -17
  6. package/dist/cjs/{SnkMessageBuilder-722b104e.js → SnkMessageBuilder-bae64d0d.js} +7 -3
  7. package/dist/cjs/{auth-fetcher-54f5ff9d.js → auth-fetcher-8480751c.js} +1 -1
  8. package/dist/cjs/{dataunit-fetcher-688d3f05.js → dataunit-fetcher-8ea97d88.js} +48 -20
  9. package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
  10. package/dist/cjs/{form-config-fetcher-2dd00e5b.js → form-config-fetcher-90126e4c.js} +42 -2
  11. package/dist/cjs/index-f9e81701.js +16 -32
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/cjs/{pesquisa-fetcher-680e198f.js → pesquisa-fetcher-f3454c23.js} +185 -2
  14. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +133 -0
  15. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  16. package/dist/cjs/{snk-actions-button_4.cjs.entry.js → snk-actions-button_5.cjs.entry.js} +136 -40
  17. package/dist/cjs/snk-application.cjs.entry.js +248 -69
  18. package/dist/cjs/snk-attach.cjs.entry.js +46 -33
  19. package/dist/cjs/{snk-form-config.cjs.entry.js → snk-config-options_3.cjs.entry.js} +398 -12
  20. package/dist/cjs/snk-crud.cjs.entry.js +22 -8
  21. package/dist/cjs/snk-data-exporter.cjs.entry.js +34 -22
  22. package/dist/cjs/{snk-data-unit-04df81bf.js → snk-data-unit-72ef8777.js} +54 -32
  23. package/dist/cjs/snk-data-unit.cjs.entry.js +5 -5
  24. package/dist/cjs/snk-detail-view.cjs.entry.js +12 -12
  25. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
  26. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +1436 -0
  27. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  28. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
  29. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  30. package/dist/cjs/snk-filter-text.cjs.entry.js +2 -1
  31. package/dist/cjs/snk-grid.cjs.entry.js +71 -21
  32. package/dist/cjs/{snk-guides-viewer-bdc41281.js → snk-guides-viewer-b20b0cfd.js} +29 -13
  33. package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -9
  34. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +4 -4
  35. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  36. package/dist/cjs/snk-pesquisa.cjs.entry.js +123 -31
  37. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  38. package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
  39. package/dist/cjs/snk-simple-crud.cjs.entry.js +101 -45
  40. package/dist/cjs/snk-taskbar.cjs.entry.js +64 -38
  41. package/dist/collection/collection-manifest.json +14 -31
  42. package/dist/collection/components/snk-actions-button/actions/index.js +16 -13
  43. package/dist/collection/components/snk-actions-button/interfaces/index.js +1 -0
  44. package/dist/collection/components/snk-actions-button/snk-actions-button.js +27 -26
  45. package/dist/collection/components/snk-application/request-listener/DebouncedRequestListener.js +29 -0
  46. package/dist/collection/components/snk-application/request-listener/RequestListenerFactory.js +16 -0
  47. package/dist/collection/components/snk-application/request-listener/RequestListenerLoadingBar.js +52 -0
  48. package/dist/collection/components/snk-application/snk-application.css +34 -0
  49. package/dist/collection/components/snk-application/snk-application.js +235 -64
  50. package/dist/collection/components/snk-attach/snk-attach.js +25 -16
  51. package/dist/collection/components/snk-attach/structure/builder/taskbar-builder.js +8 -4
  52. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -4
  53. package/dist/collection/components/snk-crud/snk-crud.js +122 -3
  54. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +3 -3
  55. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.css +6 -6
  56. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +72 -6
  57. package/dist/collection/components/snk-data-exporter/exporter-email-sender/options-step.js +1 -1
  58. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +13 -7
  59. package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +9 -2
  60. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +1 -1
  61. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
  62. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
  63. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +3 -5
  64. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +2 -2
  65. package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +4 -4
  66. package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +1 -1
  67. package/dist/collection/components/snk-data-unit/snk-data-unit.js +52 -30
  68. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +1 -1
  69. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +1 -1
  70. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +2 -1
  71. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.css +13 -0
  72. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.js +3 -3
  73. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type-mask.enum.js +8 -0
  74. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +5 -1
  75. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +3 -1
  76. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +1 -1
  77. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +118 -28
  78. package/dist/collection/components/snk-form/snk-form.js +2 -2
  79. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +73 -15
  80. package/dist/collection/components/snk-form-config/snk-form-config.css +8 -3
  81. package/dist/collection/components/snk-form-config/snk-form-config.js +49 -8
  82. package/dist/collection/components/snk-grid/snk-grid.css +2 -0
  83. package/dist/collection/components/snk-grid/snk-grid.js +153 -8
  84. package/dist/collection/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.css +10 -0
  85. package/dist/collection/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.js +190 -0
  86. package/dist/collection/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.css +25 -0
  87. package/dist/collection/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.js +179 -0
  88. package/dist/collection/components/snk-pesquisa/pesquisaHelper.js +89 -0
  89. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +24 -5
  90. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +186 -32
  91. package/dist/collection/components/snk-print-selector/snk-print-selector.js +1 -1
  92. package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +1 -1
  93. package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +1 -1
  94. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +160 -50
  95. package/dist/collection/components/snk-simple-form-config/snk-simple-form-config.css +22 -0
  96. package/dist/collection/components/snk-simple-form-config/snk-simple-form-config.js +181 -0
  97. package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
  98. package/dist/collection/components/snk-taskbar/snk-taskbar.js +106 -38
  99. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +3 -3
  100. package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -4
  101. package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
  102. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +29 -21
  103. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.js +7 -5
  104. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +2 -2
  105. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
  106. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +45 -5
  107. package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +7 -1
  108. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +98 -4
  109. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -1
  110. package/dist/collection/lib/message/resources/snk-exporter.msg.js +1 -1
  111. package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
  112. package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
  113. package/dist/collection/lib/utils/CrudUtils.js +25 -16
  114. package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
  115. package/dist/collection/sw.js +46 -0
  116. package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +66 -23
  117. package/dist/components/DataFetcher.js +217 -77
  118. package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
  119. package/dist/components/ISave.js +346 -1
  120. package/dist/components/SnkFormConfigManager.js +73 -15
  121. package/dist/components/SnkMessageBuilder.js +7 -3
  122. package/dist/components/dataunit-fetcher.js +47 -17
  123. package/dist/components/form-config-fetcher.js +41 -1
  124. package/dist/components/index.d.ts +3 -0
  125. package/dist/components/index.js +3 -0
  126. package/dist/components/pesquisa-grid.d.ts +11 -0
  127. package/dist/components/pesquisa-grid.js +6 -0
  128. package/dist/components/pesquisa-grid2.js +86 -0
  129. package/dist/components/pesquisa-tree.d.ts +11 -0
  130. package/dist/components/pesquisa-tree.js +6 -0
  131. package/dist/components/pesquisa-tree2.js +82 -0
  132. package/dist/components/snk-actions-button2.js +43 -40
  133. package/dist/components/snk-application2.js +264 -68
  134. package/dist/components/snk-attach2.js +54 -60
  135. package/dist/components/snk-crud.js +83 -59
  136. package/dist/components/snk-data-exporter2.js +28 -17
  137. package/dist/components/snk-data-unit2.js +55 -70
  138. package/dist/components/snk-detail-view2.js +114 -105
  139. package/dist/components/snk-exporter-email-sender2.js +1 -1
  140. package/dist/components/snk-filter-bar2.js +64 -30
  141. package/dist/components/snk-filter-binary-select.js +1 -1
  142. package/dist/components/snk-filter-checkbox-list.js +1 -1
  143. package/dist/components/snk-filter-item2.js +5 -1
  144. package/dist/components/snk-filter-modal.js +3 -1
  145. package/dist/components/snk-filter-text.js +2 -1
  146. package/dist/components/snk-form-config2.js +34 -9
  147. package/dist/components/snk-form.js +2 -2
  148. package/dist/components/snk-grid2.js +68 -13
  149. package/dist/components/snk-personalized-filter-editor.js +4 -4
  150. package/dist/components/snk-pesquisa2.js +136 -33
  151. package/dist/components/snk-print-selector.js +1 -1
  152. package/dist/components/snk-simple-bar2.js +1 -1
  153. package/dist/components/snk-simple-crud2.js +108 -66
  154. package/dist/components/snk-simple-form-config.d.ts +11 -0
  155. package/dist/components/snk-simple-form-config.js +6 -0
  156. package/dist/components/snk-simple-form-config2.js +120 -0
  157. package/dist/components/snk-taskbar2.js +66 -40
  158. package/dist/components/teste-pesquisa.js +13 -1
  159. package/dist/esm/{ConfigStorage-3806514e.js → ConfigStorage-373bb440.js} +2 -2
  160. package/dist/esm/{IExporterProvider-63a188b6.js → ContinuousInsertUtils-25e7bd9a.js} +66 -25
  161. package/dist/esm/{DataFetcher-c1baf61d.js → DataFetcher-5221b992.js} +217 -77
  162. package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
  163. package/dist/esm/{SnkFormConfigManager-31b24066.js → SnkFormConfigManager-1ff928fa.js} +75 -17
  164. package/dist/esm/{SnkMessageBuilder-89925609.js → SnkMessageBuilder-6fff4a4c.js} +7 -3
  165. package/dist/esm/{auth-fetcher-039abba3.js → auth-fetcher-e32fe8a4.js} +1 -1
  166. package/dist/esm/{constants-8457af36.js → constants-7302ee87.js} +1 -1
  167. package/dist/esm/{dataunit-fetcher-264191b2.js → dataunit-fetcher-8dd93d8b.js} +48 -18
  168. package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
  169. package/dist/esm/{form-config-fetcher-30fb808f.js → form-config-fetcher-126e2471.js} +42 -2
  170. package/dist/esm/index-a7d3d3f1.js +16 -32
  171. package/dist/esm/loader.js +1 -1
  172. package/dist/{components/pesquisa-fetcher.js → esm/pesquisa-fetcher-0af41f09.js} +186 -4
  173. package/dist/esm/pesquisa-grid_2.entry.js +128 -0
  174. package/dist/esm/sankhyablocks.js +1 -1
  175. package/dist/esm/{snk-actions-button_4.entry.js → snk-actions-button_5.entry.js} +138 -43
  176. package/dist/esm/snk-application.entry.js +250 -71
  177. package/dist/esm/snk-attach.entry.js +47 -34
  178. package/dist/esm/{snk-form-config.entry.js → snk-config-options_3.entry.js} +399 -15
  179. package/dist/esm/snk-configurator.entry.js +1 -1
  180. package/dist/esm/snk-crud.entry.js +23 -9
  181. package/dist/esm/snk-data-exporter.entry.js +35 -23
  182. package/dist/esm/{snk-data-unit-8eec78bd.js → snk-data-unit-11a49fc3.js} +54 -32
  183. package/dist/esm/snk-data-unit.entry.js +5 -5
  184. package/dist/esm/snk-detail-view.entry.js +13 -13
  185. package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
  186. package/dist/esm/snk-field-config.entry.js +1 -1
  187. package/dist/esm/snk-filter-bar_4.entry.js +1429 -0
  188. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  189. package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
  190. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  191. package/dist/esm/snk-filter-text.entry.js +2 -1
  192. package/dist/esm/snk-grid.entry.js +66 -16
  193. package/dist/esm/{snk-guides-viewer-dda0fede.js → snk-guides-viewer-94918cf7.js} +30 -14
  194. package/dist/esm/snk-guides-viewer.entry.js +9 -9
  195. package/dist/esm/snk-personalized-filter-editor.entry.js +4 -4
  196. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  197. package/dist/esm/snk-pesquisa.entry.js +123 -31
  198. package/dist/esm/snk-print-selector.entry.js +1 -1
  199. package/dist/esm/snk-simple-bar.entry.js +1 -1
  200. package/dist/esm/snk-simple-crud.entry.js +99 -43
  201. package/dist/esm/snk-tab-config.entry.js +1 -1
  202. package/dist/esm/snk-taskbar.entry.js +65 -39
  203. package/dist/sankhyablocks/p-09067bee.entry.js +1 -0
  204. package/dist/sankhyablocks/p-0d86c004.entry.js +1 -0
  205. package/dist/sankhyablocks/p-1435701f.js +26 -0
  206. package/dist/sankhyablocks/p-16a1dd18.entry.js +1 -0
  207. package/dist/sankhyablocks/p-16cc8640.entry.js +11 -0
  208. package/dist/sankhyablocks/p-17425c72.js +1 -0
  209. package/dist/sankhyablocks/{p-52920496.js → p-19dc71e9.js} +1 -1
  210. package/dist/sankhyablocks/p-1a91d1f3.entry.js +1 -0
  211. package/dist/sankhyablocks/{p-47db7e88.entry.js → p-1cf39cfd.entry.js} +1 -1
  212. package/dist/sankhyablocks/p-23736d75.js +1 -0
  213. package/dist/sankhyablocks/{p-8eb67fa4.entry.js → p-2d3f9482.entry.js} +1 -1
  214. package/dist/sankhyablocks/p-3150ad41.js +1 -0
  215. package/dist/sankhyablocks/{p-c1d57831.entry.js → p-3a3d4055.entry.js} +1 -1
  216. package/dist/sankhyablocks/{p-7663f597.entry.js → p-41793e17.entry.js} +1 -1
  217. package/dist/sankhyablocks/{p-72fc257b.entry.js → p-434817f0.entry.js} +1 -1
  218. package/dist/sankhyablocks/p-469384a2.entry.js +1 -0
  219. package/dist/sankhyablocks/p-47178038.entry.js +1 -0
  220. package/dist/sankhyablocks/p-471785a1.entry.js +1 -0
  221. package/dist/sankhyablocks/p-4ca8e061.entry.js +1 -0
  222. package/dist/sankhyablocks/{p-aaa3ee68.entry.js → p-5f157b09.entry.js} +1 -1
  223. package/dist/sankhyablocks/p-60e4db34.js +1 -0
  224. package/dist/sankhyablocks/p-618a29ed.entry.js +1 -0
  225. package/dist/sankhyablocks/p-619aeac8.entry.js +1 -0
  226. package/dist/sankhyablocks/p-68134a67.entry.js +1 -0
  227. package/dist/sankhyablocks/p-798386c7.js +6 -0
  228. package/dist/sankhyablocks/p-7dd49d15.js +1 -0
  229. package/dist/sankhyablocks/{p-2c68b3ae.entry.js → p-82ee6dc3.entry.js} +1 -1
  230. package/dist/sankhyablocks/p-89c92727.entry.js +1 -0
  231. package/dist/sankhyablocks/p-8a1ee5b5.js +1 -0
  232. package/dist/sankhyablocks/{p-95df461f.entry.js → p-8b4fc28f.entry.js} +1 -1
  233. package/dist/sankhyablocks/p-8bd86610.entry.js +1 -0
  234. package/dist/sankhyablocks/{p-41f8bfa3.entry.js → p-8c235d4c.entry.js} +1 -1
  235. package/dist/sankhyablocks/{p-b0ef4383.js → p-95ce311a.js} +1 -1
  236. package/dist/sankhyablocks/p-a3803d7c.entry.js +1 -0
  237. package/dist/sankhyablocks/p-aaef93e8.js +1 -0
  238. package/dist/sankhyablocks/p-c2e468c9.entry.js +1 -0
  239. package/dist/sankhyablocks/p-d62228fb.js +1 -0
  240. package/dist/sankhyablocks/p-d92d4f91.entry.js +1 -0
  241. package/dist/sankhyablocks/p-ddefbbc7.js +60 -0
  242. package/dist/sankhyablocks/p-e5430b29.entry.js +1 -0
  243. package/dist/sankhyablocks/{p-913a9979.js → p-f0b9303b.js} +1 -1
  244. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  245. package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
  246. package/dist/types/components/snk-actions-button/interfaces/index.d.ts +3 -0
  247. package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +3 -2
  248. package/dist/types/components/snk-application/request-listener/DebouncedRequestListener.d.ts +11 -0
  249. package/dist/types/components/snk-application/request-listener/RequestListenerFactory.d.ts +12 -0
  250. package/dist/types/components/snk-application/request-listener/RequestListenerLoadingBar.d.ts +13 -0
  251. package/dist/types/components/snk-application/snk-application.d.ts +28 -14
  252. package/dist/types/components/snk-attach/snk-attach.d.ts +1 -0
  253. package/dist/types/components/snk-crud/snk-crud.d.ts +21 -0
  254. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +15 -0
  255. package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +1 -0
  256. package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +1 -0
  257. package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +3 -3
  258. package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +1 -1
  259. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +2 -0
  260. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type-mask.enum.d.ts +7 -0
  261. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +2 -0
  262. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +15 -1
  263. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +7 -2
  264. package/dist/types/components/snk-form-config/snk-form-config.d.ts +4 -0
  265. package/dist/types/components/snk-grid/snk-grid.d.ts +26 -0
  266. package/dist/types/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.d.ts +38 -0
  267. package/dist/types/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.d.ts +29 -0
  268. package/dist/types/components/snk-pesquisa/pesquisaHelper.d.ts +19 -0
  269. package/dist/types/components/snk-pesquisa/snk-pesquisa.d.ts +36 -1
  270. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +27 -7
  271. package/dist/types/components/snk-simple-form-config/snk-simple-form-config.d.ts +34 -0
  272. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
  273. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -0
  274. package/dist/types/components.d.ts +372 -15
  275. package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +12 -2
  276. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
  277. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.d.ts +3 -2
  278. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +1 -1
  279. package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +8 -2
  280. package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +1 -0
  281. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +10 -1
  282. package/dist/types/lib/utils/ContinuousInsertUtils.d.ts +10 -0
  283. package/dist/types/lib/utils/CrudUtils.d.ts +1 -0
  284. package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
  285. package/package.json +4 -3
  286. package/react/components.d.ts +3 -0
  287. package/react/components.js +3 -0
  288. package/react/components.js.map +1 -1
  289. package/dist/cjs/snk-config-options.cjs.entry.js +0 -239
  290. package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -714
  291. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -312
  292. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -152
  293. package/dist/cjs/snk-filter-modal.cjs.entry.js +0 -249
  294. package/dist/cjs/snk-form.cjs.entry.js +0 -143
  295. package/dist/esm/pesquisa-fetcher-03c8f919.js +0 -164
  296. package/dist/esm/snk-config-options.entry.js +0 -235
  297. package/dist/esm/snk-filter-bar.entry.js +0 -710
  298. package/dist/esm/snk-filter-item.entry.js +0 -308
  299. package/dist/esm/snk-filter-list.entry.js +0 -148
  300. package/dist/esm/snk-filter-modal.entry.js +0 -245
  301. package/dist/esm/snk-form.entry.js +0 -139
  302. package/dist/sankhyablocks/p-045eae4d.entry.js +0 -11
  303. package/dist/sankhyablocks/p-219f888d.entry.js +0 -1
  304. package/dist/sankhyablocks/p-2a408684.js +0 -1
  305. package/dist/sankhyablocks/p-3a212712.js +0 -1
  306. package/dist/sankhyablocks/p-3b60db06.entry.js +0 -1
  307. package/dist/sankhyablocks/p-450c60e4.entry.js +0 -1
  308. package/dist/sankhyablocks/p-46d38387.entry.js +0 -1
  309. package/dist/sankhyablocks/p-4e5e1313.entry.js +0 -1
  310. package/dist/sankhyablocks/p-547eeac8.entry.js +0 -1
  311. package/dist/sankhyablocks/p-62ba211a.entry.js +0 -1
  312. package/dist/sankhyablocks/p-70a4af56.entry.js +0 -1
  313. package/dist/sankhyablocks/p-7505da04.entry.js +0 -1
  314. package/dist/sankhyablocks/p-75e674ed.entry.js +0 -1
  315. package/dist/sankhyablocks/p-7a337364.js +0 -1
  316. package/dist/sankhyablocks/p-7a85fd49.entry.js +0 -1
  317. package/dist/sankhyablocks/p-7b08d0f8.entry.js +0 -1
  318. package/dist/sankhyablocks/p-88aa931b.entry.js +0 -1
  319. package/dist/sankhyablocks/p-96a89d58.entry.js +0 -1
  320. package/dist/sankhyablocks/p-9863d682.js +0 -1
  321. package/dist/sankhyablocks/p-af8efd95.js +0 -6
  322. package/dist/sankhyablocks/p-b05d8893.entry.js +0 -1
  323. package/dist/sankhyablocks/p-b11aa1e0.entry.js +0 -1
  324. package/dist/sankhyablocks/p-c2495304.js +0 -1
  325. package/dist/sankhyablocks/p-d1791da2.entry.js +0 -1
  326. package/dist/sankhyablocks/p-d3f53df2.entry.js +0 -1
  327. package/dist/sankhyablocks/p-d6e26ea8.entry.js +0 -1
  328. package/dist/sankhyablocks/p-dc7c9047.js +0 -1
  329. package/dist/sankhyablocks/p-df5451c7.js +0 -26
  330. package/dist/sankhyablocks/p-e549f7d1.js +0 -1
  331. package/dist/sankhyablocks/p-e8763234.entry.js +0 -1
  332. package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
  333. package/dist/sankhyablocks/p-fa4d8cb4.js +0 -1
  334. package/dist/sankhyablocks/p-fe79f83a.js +0 -60
  335. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -0,0 +1,1429 @@
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
2
+ import { DataType, StringUtils, ObjectUtils, ElementIDUtils, ErrorException, ApplicationContext, LockManager, LockManagerOperation, FloatingManager, DateUtils, MaskFormatter, ArrayUtils } from '@sankhyalabs/core';
3
+ import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
4
+ import { C as ConfigStorage } from './ConfigStorage-373bb440.js';
5
+ import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
6
+ import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
7
+ import { F as FilterOperand } from './index-ae591a44.js';
8
+ import { F as FilterNumberVariation } from './filterNumberVariation-8cee02ea.js';
9
+ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
10
+ import { P as PersonalizedFilterUtils } from './PersonalizedFilterUtils-e2b38ef7.js';
11
+ import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
12
+ import { F as FilterType } from './filter-type.enum-a80c1b6b.js';
13
+ import './form-config-fetcher-126e2471.js';
14
+ import './DataFetcher-5221b992.js';
15
+ import './PrintUtils-3e4ff0f5.js';
16
+ import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
17
+
18
+ const buildFilter = (item) => {
19
+ switch (item.type) {
20
+ case FilterItemType.DEFAULT_FILTER:
21
+ return buildDefault(item);
22
+ case FilterItemType.BINARY_SELECT:
23
+ return buildBinary(item);
24
+ case FilterItemType.MULTI_SELECT:
25
+ return buildMultSelect(item);
26
+ case FilterItemType.MULTI_LIST:
27
+ return buildMultiList(item);
28
+ case FilterItemType.PERIOD:
29
+ return buildPeriod(item);
30
+ case FilterItemType.SEARCH:
31
+ return buildSearch(item);
32
+ case FilterItemType.TEXT:
33
+ return buildText(item);
34
+ case FilterItemType.NUMBER:
35
+ return buildNumber(item);
36
+ case FilterItemType.PERSONALIZED:
37
+ return buildPersonalized(item);
38
+ case FilterItemType.CHECK_BOX_LIST:
39
+ return buildCheckboxList(item);
40
+ default:
41
+ return undefined;
42
+ }
43
+ };
44
+ function buildDefault(item) {
45
+ return { name: item.id, expression: item.props.expression, params: [] };
46
+ }
47
+ function buildBinary(item) {
48
+ const { id, value, props } = item;
49
+ const options = props.options;
50
+ const selectedOption = options.find(opt => opt.name === value);
51
+ return { name: id, expression: selectedOption.expression, params: [] };
52
+ }
53
+ function buildMultSelect(item) {
54
+ const { id, value, props } = item;
55
+ return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
56
+ }
57
+ function buildMultiList(item) {
58
+ const { id, value, props } = item;
59
+ const parsedValues = parseMultiListValues(value);
60
+ if (parsedValues.length > 0) {
61
+ return {
62
+ name: id,
63
+ expression: props.expression,
64
+ params: [{
65
+ name: id,
66
+ dataType: DataType.TEXT,
67
+ value: JSON.stringify(parsedValues)
68
+ }]
69
+ };
70
+ }
71
+ }
72
+ function buildCheckboxList(item) {
73
+ var _a;
74
+ const { id, value, props } = item;
75
+ const selectedOptionNames = Object.entries(value !== null && value !== void 0 ? value : {})
76
+ .filter(([_, valueChecked]) => valueChecked === true)
77
+ .map(([key, _]) => key);
78
+ const selectedOptionsObject = (_a = props.options) === null || _a === void 0 ? void 0 : _a.filter(option => selectedOptionNames.includes(option.name));
79
+ return { name: id, expression: buildCheckboxListExpression(selectedOptionsObject), params: [] };
80
+ }
81
+ function buildCheckboxListExpression(options) {
82
+ let expression = "";
83
+ options.forEach((option, index) => {
84
+ var _a;
85
+ expression += ` ${index > 0 ? ((_a = option.operand) !== null && _a !== void 0 ? _a : 'OR') : ''} ${option.expression}`;
86
+ });
87
+ return expression.trim();
88
+ }
89
+ function parseMultiListValues(multiListValue) {
90
+ var _a, _b;
91
+ const value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
92
+ return value.filter(item => item === null || item === void 0 ? void 0 : item.check).map(({ id }) => Number.isNaN(+id) ? String(id) : Number(id));
93
+ }
94
+ function buildPeriod(item) {
95
+ const { id, value, props } = item;
96
+ let { end, start } = value;
97
+ if (typeof end === "string") {
98
+ end = new Date(end);
99
+ }
100
+ if (typeof start === "string") {
101
+ start = new Date(start);
102
+ }
103
+ const params = [];
104
+ let expression;
105
+ if (end && start) {
106
+ expression = props.expression.fullfill;
107
+ params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
108
+ }
109
+ else {
110
+ if (start) {
111
+ expression = props.expression.onlystart;
112
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
113
+ }
114
+ else {
115
+ expression = props.expression.onlyend;
116
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
117
+ }
118
+ }
119
+ return { name: id, expression, params };
120
+ }
121
+ function buildSearch(item) {
122
+ const { id, value, props } = item;
123
+ const expression = props.expression;
124
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
125
+ }
126
+ function buildText(item) {
127
+ let { id, value, props } = item;
128
+ const expression = props.expression;
129
+ if (!StringUtils.isEmpty(props.likeAs)) {
130
+ value = buildLikeValue(value, props.likeAs);
131
+ }
132
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
133
+ }
134
+ function buildNumber(item) {
135
+ const { id, value, props } = item;
136
+ const variation = props.variation;
137
+ if (variation === FilterNumberVariation.INTERVAL) {
138
+ const { start, end } = value !== null && value !== void 0 ? value : { start: 0, end: 0 };
139
+ if (start && end) {
140
+ return {
141
+ name: id,
142
+ expression: props.intervalExpression.fullfill,
143
+ params: [
144
+ { name: `${id}.START`, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, start) },
145
+ { name: `${id}.END`, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, end) }
146
+ ]
147
+ };
148
+ }
149
+ if (start) {
150
+ return {
151
+ name: id,
152
+ expression: props.intervalExpression.onlystart,
153
+ params: [
154
+ { name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, start) }
155
+ ]
156
+ };
157
+ }
158
+ if (end) {
159
+ return {
160
+ name: id,
161
+ expression: props.intervalExpression.onlyend,
162
+ params: [
163
+ { name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, end) }
164
+ ]
165
+ };
166
+ }
167
+ }
168
+ const expression = props.expression;
169
+ return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
170
+ }
171
+ function buildLikeValue(valueAsString, likeAs) {
172
+ if (likeAs === "CONTANIS") {
173
+ return `%${valueAsString}%`;
174
+ }
175
+ else if (likeAs === "STARTS_WITH") {
176
+ return `${valueAsString}%`;
177
+ }
178
+ else if (likeAs === "ENDS_WITH") {
179
+ return `%${valueAsString}`;
180
+ }
181
+ return valueAsString;
182
+ }
183
+ function buildPersonalized(item) {
184
+ const { id, groupedItems = [] } = item;
185
+ const activeFilters = groupedItems.filter(groupItem => !!groupItem.visible);
186
+ const filters = activeFilters.map(item => {
187
+ var _a;
188
+ const expression = item.props.expression;
189
+ const params = (((_a = item.props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
190
+ const valuesArray = Array.from(item.value || 0);
191
+ const dataType = param.dataType;
192
+ let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
193
+ if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
194
+ paramValue = paramValue["value"];
195
+ }
196
+ if (paramValue == undefined && dataType === DataType.BOOLEAN) {
197
+ paramValue = false;
198
+ }
199
+ return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : toString(dataType, paramValue) };
200
+ });
201
+ return { expression, name: item.id, params };
202
+ });
203
+ const expression = filters.map(filter => `(${filter.expression})`).join(` ${FilterOperand.AND} `);
204
+ const params = filters.flatMap(filter => filter.params);
205
+ return { name: id, expression, params };
206
+ }
207
+
208
+ class SnkFilterModalFactory {
209
+ constructor({ filterConfig, configName, onComplete, getMessage, disablePersonalizedFilter, onAddPersonalizedFilter, onEditPersonalizedFilter, onDeletePersonalizedFilter }) {
210
+ this._filterConfig = filterConfig;
211
+ this._configName = configName;
212
+ this._onComplete = onComplete;
213
+ this._getMessage = getMessage;
214
+ this._disablePersonalizedFilter = disablePersonalizedFilter;
215
+ this._addPersonalizedFilterFn = onAddPersonalizedFilter;
216
+ this._editPersonalizedFilterFn = onEditPersonalizedFilter;
217
+ this._onDeletePersonalizedFilter = onDeletePersonalizedFilter;
218
+ }
219
+ applyFilters(newFilterConfig) {
220
+ this._onComplete(newFilterConfig);
221
+ this._closeModal();
222
+ }
223
+ buildFilterModal() {
224
+ const filterModal = document.createElement("snk-filter-modal");
225
+ filterModal.className = "ez-size-height--full";
226
+ filterModal.filters = this._filterConfig;
227
+ filterModal.configName = this._configName;
228
+ filterModal.disablePersonalizedFilter = this._disablePersonalizedFilter;
229
+ filterModal.getMessage = this._getMessage.bind(this);
230
+ filterModal.applyFilters = this.applyFilters.bind(this);
231
+ filterModal.closeModal = () => this._closeModal();
232
+ filterModal.addPersonalizedFilter = () => this._addPersonalizedFilterFn();
233
+ filterModal.editPersonalizedFilter = (id) => this._editPersonalizedFilterFn(id);
234
+ filterModal.deletePersonalizedFilter = (filter, configName) => this._onDeletePersonalizedFilter(filter, configName);
235
+ return filterModal;
236
+ }
237
+ async showModal() {
238
+ const filterModal = this.buildFilterModal();
239
+ const modalProps = {
240
+ content: filterModal,
241
+ position: 'left',
242
+ heightMode: 'full',
243
+ closeOutsideClick: false,
244
+ useScrimLight: true
245
+ };
246
+ this._closeModal = await ApplicationUtils.showModal(modalProps);
247
+ }
248
+ async closeModal() {
249
+ this._closeModal();
250
+ }
251
+ }
252
+
253
+ const snkFilterBarCss = ".sc-snk-filter-bar-h{display:grid;grid-template-columns:1fr minmax(100px, 100%) 1fr 1fr;--snk-personalized-filter--z-index:var(--elevation--20, 20);--snk-personalized-filter--background-color:var(--background--xlight, #fff)}.snk-filter-bar__title.sc-snk-filter-bar{max-width:260px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:16px;font-family:var(--font-pattern, Arial);font-weight:var(--text-weight--large, 600);color:var(--color--title-primary, #2B3A54);margin-top:8px}[data-mode=\"hidden\"].sc-snk-filter-bar-h{width:0px;height:0px}[data-mode=\"button\"].sc-snk-filter-bar-h{grid-template-columns:1fr;width:fit-content}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.filter-bar__personalized-filter.sc-snk-filter-bar{display:flex;flex-direction:column;position:fixed;top:0;left:0;width:100%;height:100%;overflow:auto;z-index:var(--snk-personalized-filter--z-index);background-color:var(--snk-personalized-filter--background-color)}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;background-color:transparent;border:none;padding:3px;outline-color:var(--color--primary)}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.snk-filter-bar__scroller.sc-snk-filter-bar{height:calc(100% + var(--space-extra-small, 3px))}.snk-filter-bar__filter-item-container.sc-snk-filter-bar{display:flex;align-items:start}.snk-filter-bar__scroller.sc-snk-filter-bar .sc-snk-filter-bar:first-child{margin-left:var(--space-extra-small, 3px)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px);border:none;background-color:transparent}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:focus-visible{outline:none;background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:\"\";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar{--modal-item-border-width:2px;display:flex;flex-direction:row;margin-left:var(--modal-item-border-width);border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7);border:none;width:100%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar:focus-visible{outline:var(--color--primary) solid var(--modal-item-border-width)}.snk-filter-bar__filter-modal-item__check.sc-snk-filter-bar{width:auto}.snk-filter-bar__filter-modal-item__label.sc-snk-filter-bar{font-weight:var(--text-weight--medium)}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:99%;height:100%}";
254
+
255
+ const SnkFilterBar = class {
256
+ constructor(hostRef) {
257
+ registerInstance(this, hostRef);
258
+ this.configUpdated = createEvent(this, "configUpdated", 7);
259
+ this._updateSequence = [];
260
+ this._loadingPending = false;
261
+ this._configUpdated = false;
262
+ this._firstLoad = true;
263
+ this._pendingVariables = false;
264
+ this._customfiltersToBeUpdated = [];
265
+ this._resolveLoading = undefined;
266
+ this._calculateSortIndex = (item) => {
267
+ if (!item.visible)
268
+ return 0;
269
+ if (item.hardFixed)
270
+ return 1000000; //campos Hard Fixed não variam a ordem
271
+ let index = item.fixed ? 100000 : 0;
272
+ index += this.hasValidValue(item) ? 10000 : 0;
273
+ index += this._updateSequence.lastIndexOf(item.id) + 1;
274
+ return index;
275
+ };
276
+ this._filtersComparator = (a, b) => {
277
+ return this._calculateSortIndex(b) - this._calculateSortIndex(a);
278
+ };
279
+ this.enableLockManagerLoadingComp = false;
280
+ this.customFilterBarConfig = undefined;
281
+ this.dataUnit = undefined;
282
+ this.title = undefined;
283
+ this.configName = undefined;
284
+ this.resourceID = undefined;
285
+ this.mode = "regular";
286
+ this.filterConfig = undefined;
287
+ this.messagesBuilder = undefined;
288
+ this.disablePersonalizedFilter = undefined;
289
+ this.filterBarLegacyConfigName = undefined;
290
+ this.autoLoad = undefined;
291
+ this.afterApplyConfig = undefined;
292
+ this.allowDefault = undefined;
293
+ this.scrollerLocked = false;
294
+ this.showPersonalizedFilter = false;
295
+ this.personalizedFilterId = undefined;
296
+ }
297
+ hasValidValue(item) {
298
+ if (item.value === undefined || item.value === null)
299
+ return false;
300
+ if (!Array.isArray(item.value))
301
+ return true;
302
+ return item.value.some(filterItem => filterItem.check === true);
303
+ }
304
+ observeFilterConfig(newValue, oldValue) {
305
+ if (ObjectUtils.equals(newValue, oldValue))
306
+ return;
307
+ this.handleFilterConfigsChanged(oldValue, newValue);
308
+ }
309
+ handleFilterConfigsChanged(oldValue, newValue) {
310
+ if (oldValue != undefined && newValue == undefined) {
311
+ this._loadingPending = true;
312
+ this._configUpdated = true;
313
+ }
314
+ else {
315
+ const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
316
+ if (oldItems.size === 0 && newValue.length > 0) {
317
+ this._loadingPending = true;
318
+ this._configUpdated = false;
319
+ }
320
+ else {
321
+ newValue.forEach(newItem => {
322
+ const oldItem = oldItems.get(newItem.id);
323
+ if (oldItem != undefined) {
324
+ this._configUpdated = this._configUpdated || ObjectUtils.objectToString(oldItem) != ObjectUtils.objectToString(newItem);
325
+ this._loadingPending = this._loadingPending || ObjectUtils.objectToString(oldItem.value) !== ObjectUtils.objectToString(newItem.value);
326
+ if (!this._loadingPending) {
327
+ const groupedChanged = ObjectUtils.objectToString(oldItem.groupedItems) != ObjectUtils.objectToString(newItem.groupedItems);
328
+ this._configUpdated = this._configUpdated || groupedChanged;
329
+ this._loadingPending = this._loadingPending || groupedChanged;
330
+ }
331
+ }
332
+ else {
333
+ this._configUpdated = true;
334
+ this._loadingPending = this._loadingPending || newItem.value != undefined;
335
+ }
336
+ });
337
+ }
338
+ }
339
+ if (this._loadingPending || this._configUpdated)
340
+ this.configUpdated.emit(newValue);
341
+ this.processAfterUpdateConfig();
342
+ }
343
+ /**
344
+ * Faz o recarregamento da filterbar buscando o state no servidor.
345
+ */
346
+ async reload() {
347
+ this.loadConfigFromStorage(true);
348
+ }
349
+ /**
350
+ * Retorna um item de filtro pelo ID.
351
+ */
352
+ async getFilterItem(id) {
353
+ const item = this.filterConfig.find(item => item.id === id);
354
+ return Promise.resolve(ObjectUtils.copy(item));
355
+ }
356
+ /**
357
+ * Atualiza um item do filtro.
358
+ *
359
+ * @param filterItem - Item com as informações atualizadas, caso o item não seja encontrado no array ele mão será modificado
360
+ */
361
+ async updateFilterItem(newFilterItem) {
362
+ const itemIndex = this.filterConfig.findIndex(item => item.id === newFilterItem.id);
363
+ if (itemIndex == -1) {
364
+ console.warn("[SnkFilterBar.updateFilterItem] FilterItem não encontrado, o mesmo não será atualizado.");
365
+ return Promise.resolve();
366
+ }
367
+ this._loadingPending = true;
368
+ this.updateFilter(newFilterItem);
369
+ return Promise.resolve();
370
+ }
371
+ /**
372
+ * Adiciona um item de filtro.
373
+ *
374
+ * @param filterItem - Item a ser adicionado, caso o item já exista com o ID ele não será adicionado novamente
375
+ */
376
+ async addFilterItem(filterItem) {
377
+ const itemIndex = this.filterConfig.findIndex(item => item.id === filterItem.id);
378
+ if (itemIndex > -1) {
379
+ console.warn("[SnkFilterBar.addFilterItem] FilterItem já existe , o mesmo não será adicionado novamente.");
380
+ return Promise.resolve();
381
+ }
382
+ this.filterConfig.push(filterItem);
383
+ this._loadingPending = true;
384
+ this.updateFilter(filterItem);
385
+ return Promise.resolve();
386
+ }
387
+ /**
388
+ * Remove um item de filtro.
389
+ *
390
+ * @param filterID - ID do a ser adicionado
391
+ *
392
+ * @returns {Promise<SnkFilterItemConfig|undefined>} - Retorna o item de filtro removido, ou undefined caso não encontrado.
393
+ */
394
+ async removeFilterItem(filterID) {
395
+ const itemIndex = this.filterConfig.findIndex(item => item.id === filterID);
396
+ if (itemIndex == -1) {
397
+ console.warn("[SnkFilterBar.removeFilterItem] FilterItem não encontrado");
398
+ return Promise.resolve(undefined);
399
+ }
400
+ const itemToRemove = this.filterConfig[itemIndex];
401
+ this.filterConfig = this.filterConfig.filter(item => item.id !== filterID);
402
+ return Promise.resolve(itemToRemove);
403
+ }
404
+ componentDidLoad() {
405
+ if (this._element) {
406
+ const dataInfo = { dataUnit: this.dataUnit };
407
+ ElementIDUtils.addIDInfo(this._element, null, dataInfo);
408
+ }
409
+ }
410
+ processPendingFilter() {
411
+ if (this._pendingVariables) {
412
+ const popUp = this._element.querySelector("#filter-PERSONALIZED_FILTER_GROUP");
413
+ if (popUp) {
414
+ popUp.showUp(true).then(() => {
415
+ this.processAfterUpdateConfig();
416
+ });
417
+ }
418
+ }
419
+ else {
420
+ this.processAfterUpdateConfig();
421
+ }
422
+ }
423
+ getPersonalizedFilterItem() {
424
+ return this.filterConfig.find(item => item.type === FilterItemType.PERSONALIZED);
425
+ }
426
+ async processAfterUpdateConfig() {
427
+ var _a;
428
+ if (this._loadingPending) {
429
+ if (await this._application.isLoadedByPk() && !this._configUpdated)
430
+ return;
431
+ const personalizedFilter = this.getPersonalizedFilterItem();
432
+ this._pendingVariables = !PersonalizedFilterUtils.validateVariableValues(personalizedFilter);
433
+ if (this._pendingVariables) {
434
+ return;
435
+ }
436
+ this._loadingPending = false;
437
+ this.doLoadData(this.dataUnit.getLastLoadRequest() != undefined);
438
+ }
439
+ if (this._configUpdated) {
440
+ this._configUpdated = false;
441
+ ConfigStorage.saveFilterBarConfig(this.filterConfig, this.configName, this.resourceID);
442
+ (_a = this.afterApplyConfig) === null || _a === void 0 ? void 0 : _a.call(this);
443
+ }
444
+ }
445
+ async doLoadData(forceReload = false) {
446
+ try {
447
+ if (this._firstLoad && this.autoLoad === false) {
448
+ return;
449
+ }
450
+ if (this._firstLoad && !forceReload && this.autoLoad === undefined) {
451
+ let autoLoad = await this._application.getBooleanParam("global.carregar.registros.iniciar.tela");
452
+ if (!autoLoad) {
453
+ return;
454
+ }
455
+ }
456
+ this.dataUnit.loadData(undefined, undefined, true);
457
+ }
458
+ finally {
459
+ this._firstLoad = false;
460
+ }
461
+ }
462
+ /**
463
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
464
+ * através de um pequeno modulo na estrutura da aplicação:
465
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
466
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
467
+ */
468
+ getMessage(key, params, defaultValue) {
469
+ var _a;
470
+ if (this.messagesBuilder == undefined && this._application) {
471
+ this.messagesBuilder = this._application.messagesBuilder;
472
+ }
473
+ return ((_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, params)) || defaultValue;
474
+ }
475
+ getFilter(_dataUnit) {
476
+ var _a;
477
+ const filters = [];
478
+ (_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
479
+ const filter = buildFilter(item);
480
+ if (filter) {
481
+ filters.push(filter);
482
+ }
483
+ });
484
+ return filters;
485
+ }
486
+ isActiveFilter(item) {
487
+ /*
488
+ - O filtro padrão também deve sempre ser condiderado ativo, pois, sempre deve
489
+ ser aplicado.
490
+ */
491
+ if (item.type === FilterItemType.DEFAULT_FILTER) {
492
+ return true;
493
+ }
494
+ return this.filterActiveFilter(item) && (item.groupedItems || item.value != undefined);
495
+ }
496
+ registryFilterProvider() {
497
+ this.dataUnit.addFilterProvider(this);
498
+ if (this.filterConfig) {
499
+ this.doLoadData();
500
+ }
501
+ }
502
+ itemFocused(selectedItem) {
503
+ this._element.querySelectorAll("snk-filter-item,snk-filter-list").forEach(item => {
504
+ if (item.id === selectedItem) {
505
+ if (item.tagName.toLowerCase() === "snk-filter-item" && item.getClientRects()[0].x < 0) {
506
+ item.scrollIntoView({ behavior: "auto", inline: 'nearest' });
507
+ }
508
+ }
509
+ else {
510
+ item["hideDetail"]();
511
+ }
512
+ });
513
+ }
514
+ filterActiveFilter(item) {
515
+ return item.visible || item.removalBlocked;
516
+ }
517
+ filterPersonalizedItems(item) {
518
+ return item.type === FilterItemType.PERSONALIZED;
519
+ }
520
+ getPersonalizedFilterVariableItems() {
521
+ return this.filterConfig
522
+ .filter(this.filterPersonalizedItems)
523
+ .map(item => {
524
+ const itemId = `filter-${item.id}`;
525
+ return (h("snk-filter-item", { key: item.id, id: itemId, config: Object.assign({}, item), onFocusin: () => this.itemFocused(itemId), onVisibleChanged: (evt) => this.scrollerLocked = evt.detail, onFilterChange: (event) => this.updateFilter(event.detail), getMessage: (key, props) => this.getMessage(key, props), showChips: false }));
526
+ });
527
+ }
528
+ getFilterItems() {
529
+ const pinnedItems = [];
530
+ const unpinnedItems = [];
531
+ this.filterConfig.sort((a, b) => this._filtersComparator(a, b))
532
+ .filter(this.filterActiveFilter)
533
+ .forEach((item, index) => {
534
+ item = ObjectUtils.copy(item);
535
+ const itemId = `filter-${item.id}`;
536
+ const filterItem = (h("snk-filter-item", { onVisibleChanged: (evt) => this.scrollerLocked = evt.detail, onFilterChange: (event) => this.updateFilter(event.detail), onFocusin: () => this.itemFocused(itemId), id: itemId, config: item, class: index > 0 ? "ez-padding-left--medium" : "", getMessage: (key, props) => this.getMessage(key, props), key: item.id }));
537
+ if (item.fixed || item.hardFixed) {
538
+ pinnedItems.push(filterItem);
539
+ }
540
+ else {
541
+ unpinnedItems.push(filterItem);
542
+ }
543
+ return filterItem;
544
+ });
545
+ const elements = [];
546
+ elements.push(...pinnedItems);
547
+ if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
548
+ elements.push(h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
549
+ }
550
+ elements.push(...unpinnedItems);
551
+ return elements;
552
+ }
553
+ calculateUpdateSequence(item) {
554
+ if (item) {
555
+ this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
556
+ this._updateSequence.push(item.id);
557
+ }
558
+ }
559
+ normalizeItem(item) {
560
+ const normalized = Object.assign({}, item);
561
+ const optionals = ["props", "value", "hardFixed", "fixed"];
562
+ optionals.forEach(prop => {
563
+ if (normalized[prop] == undefined) {
564
+ delete normalized[prop];
565
+ }
566
+ });
567
+ if (item.value === "") {
568
+ delete item.value;
569
+ }
570
+ return normalized;
571
+ }
572
+ updateFilter(newItem) {
573
+ this.filterConfig = this.filterConfig.map(item => {
574
+ newItem = this.normalizeItem(newItem);
575
+ if (item.id === newItem.id) {
576
+ if (ObjectUtils.objectToString(item) != ObjectUtils.objectToString(newItem)) {
577
+ this.calculateUpdateSequence(newItem);
578
+ }
579
+ return newItem;
580
+ }
581
+ return item;
582
+ }).sort((a, b) => this._filtersComparator(a, b));
583
+ }
584
+ loadPermitions() {
585
+ this._application.isUserSup().then(value => this.allowDefault = value);
586
+ }
587
+ addFilterBarLegacyConfigName() {
588
+ if (this.filterBarLegacyConfigName && this.configName) {
589
+ ConfigStorage.addFilterBarLegacyConfig(this.configName, this.filterBarLegacyConfigName);
590
+ }
591
+ }
592
+ async loadConfigFromStorage(clearCache) {
593
+ try {
594
+ if (clearCache) {
595
+ await ConfigStorage.deleteFilterBarConfigCache(this.configName, this.resourceID);
596
+ }
597
+ let config;
598
+ if (this.customFilterBarConfig) {
599
+ config = await this.customFilterBarConfig(this.configName, this.resourceID, { contextURI: this.dataUnit.name });
600
+ }
601
+ else {
602
+ config = await ConfigStorage.loadFilterBarConfig(this.configName, this.resourceID, { contextURI: this.dataUnit.name });
603
+ }
604
+ this.filterConfig = config.map(item => this.normalizeItem(item));
605
+ this.filterConfig.sort((a, b) => this._filtersComparator(a, b));
606
+ }
607
+ catch (e) {
608
+ throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), e);
609
+ }
610
+ }
611
+ attachDataUnit() {
612
+ if (this.dataUnit == undefined) {
613
+ let parent = this._element.parentElement;
614
+ while (parent) {
615
+ if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
616
+ const snkDataUnit = parent;
617
+ this.dataUnit = snkDataUnit.dataUnit;
618
+ if (this.dataUnit) {
619
+ this.registryFilterProvider();
620
+ }
621
+ else {
622
+ snkDataUnit.addEventListener("dataUnitReady", (evt) => {
623
+ this.dataUnit = evt.detail;
624
+ this.registryFilterProvider();
625
+ });
626
+ }
627
+ break;
628
+ }
629
+ }
630
+ parent = parent.parentElement;
631
+ }
632
+ else {
633
+ this.registryFilterProvider();
634
+ }
635
+ }
636
+ /**
637
+ * Emitido quando acontece a alteração do estado do filtro.
638
+ */
639
+ filterChangeListener(evt) {
640
+ this.updateFilter(evt.detail);
641
+ }
642
+ /**
643
+ * Abre o modal de filtros
644
+ */
645
+ async showFilterModal() {
646
+ const callbackOnApplyFilter = (filters) => {
647
+ var _a;
648
+ this.filterConfig = filters.map(this.normalizeItem).sort((a, b) => this._filtersComparator(a, b));
649
+ (_a = this.afterApplyConfig) === null || _a === void 0 ? void 0 : _a.call(this);
650
+ };
651
+ let filtersConfigCopy = ObjectUtils.copy(this.filterConfig);
652
+ filtersConfigCopy = filtersConfigCopy.sort((itemA, itemB) => {
653
+ return itemA.originOrder - itemB.originOrder;
654
+ });
655
+ const factoryParams = {
656
+ filterConfig: filtersConfigCopy,
657
+ configName: this.configName,
658
+ onComplete: callbackOnApplyFilter,
659
+ disablePersonalizedFilter: this.disablePersonalizedFilter,
660
+ getMessage: (key, props) => this.getMessage(key, props),
661
+ onAddPersonalizedFilter: () => this.addPersonalizedFilter(),
662
+ onEditPersonalizedFilter: (id) => this.editPersonalizedFilter(id),
663
+ onDeletePersonalizedFilter: (filter, configName) => this.deletePersonalizedFilter(filter, FilterItemType.PERSONALIZED, configName),
664
+ };
665
+ this._filterModalFactory = new SnkFilterModalFactory(factoryParams);
666
+ await this._filterModalFactory.showModal();
667
+ }
668
+ addPersonalizedFilter() {
669
+ this._filterModalFactory.closeModal();
670
+ this.personalizedFilterId = undefined;
671
+ this.showPersonalizedFilter = true;
672
+ window.requestAnimationFrame(() => {
673
+ this._elPersonalizedFilter.createPersonalizedFilter();
674
+ });
675
+ }
676
+ editPersonalizedFilter(id) {
677
+ this._filterModalFactory.closeModal();
678
+ this.showPersonalizedFilter = true;
679
+ this.personalizedFilterId = id;
680
+ }
681
+ deletePersonalizedFilter(filter, filterItemType, configName) {
682
+ if (filterItemType === FilterItemType.PERSONALIZED) {
683
+ ConfigStorage.removePersonalizedFilter(filter, this.resourceID, configName);
684
+ }
685
+ }
686
+ handleHidePersonalizedFilter(reloadFilterBar) {
687
+ if (reloadFilterBar) {
688
+ this.loadConfigFromStorage().then(() => {
689
+ this.hidePersonalizedFilter();
690
+ });
691
+ }
692
+ else {
693
+ this.hidePersonalizedFilter();
694
+ }
695
+ }
696
+ hidePersonalizedFilter() {
697
+ this.personalizedFilterId = undefined;
698
+ this.showPersonalizedFilter = false;
699
+ }
700
+ async componentWillLoad() {
701
+ var _a;
702
+ try {
703
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
704
+ await this.attachDataUnit();
705
+ if (this._application) {
706
+ if (this._application.enableLockManagerLoadingApp && this.enableLockManagerLoadingComp) {
707
+ const appLoadLockerID = LockManager.addLockManagerCtxId(this._element);
708
+ this._resolveLoading = LockManager.lock(appLoadLockerID, LockManagerOperation.APP_LOADING);
709
+ }
710
+ await Promise.all([
711
+ this.loadPermitions(),
712
+ this.addFilterBarLegacyConfigName(),
713
+ this.loadConfigFromStorage(),
714
+ ]);
715
+ }
716
+ }
717
+ finally {
718
+ (_a = this._resolveLoading) === null || _a === void 0 ? void 0 : _a.call(this);
719
+ }
720
+ }
721
+ componentDidRender() {
722
+ this.processPendingFilter();
723
+ }
724
+ render() {
725
+ if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
726
+ return undefined;
727
+ }
728
+ if (this.showPersonalizedFilter) {
729
+ return h("snk-personalized-filter", { class: "filter-bar__personalized-filter", filterId: this.personalizedFilterId, ref: (el) => this._elPersonalizedFilter = el, onEzCancel: () => this.handleHidePersonalizedFilter(false), onEzAfterSave: () => this.handleHidePersonalizedFilter(true), entityUri: this.dataUnit.name, configName: this.configName, resourceID: this.resourceID });
730
+ }
731
+ if (this.mode !== "regular") {
732
+ return (h(Host, { "data-mode": this.mode }, this.getPersonalizedFilterVariableItems(), this.mode === 'button' && (h("ez-button", { class: "ez-margin-left--medium", size: "small", label: this.getMessage('snkFilterBar.filters', undefined, 'Filtros'), onClick: this.showFilterModal.bind(this) }))));
733
+ }
734
+ return (h(Host, null, h("div", null, h("span", { class: "snk-filter-bar__title", title: this.title, "data-tooltip": this.title, "data-flow": "bottom" }, this.title)), h("ez-scroller", { class: "snk-filter-bar__scroller", direction: EzScrollDirection.HORIZONTAL, activeShadow: true, locked: this.scrollerLocked }, h("section", { class: "snk-filter-bar__filter-item-container" }, this.getFilterItems())), h("ez-button", { class: "ez-padding-left--medium", size: "small", label: this.getMessage('snkFilterBar.filters', undefined, 'Filtros'), onClick: this.showFilterModal.bind(this) }, h("ez-icon", { slot: "leftIcon", iconName: "plus", class: "ez-padding-right--small" }))));
735
+ }
736
+ get _element() { return getElement(this); }
737
+ static get watchers() { return {
738
+ "filterConfig": ["observeFilterConfig"]
739
+ }; }
740
+ };
741
+ SnkFilterBar.style = snkFilterBarCss;
742
+
743
+ const SnkFilterItem = class {
744
+ constructor(hostRef) {
745
+ registerInstance(this, hostRef);
746
+ this.visibleChanged = createEvent(this, "visibleChanged", 7);
747
+ this.filterChange = createEvent(this, "filterChange", 3);
748
+ this.innerClickCheck = (_floatingContainer, node) => {
749
+ if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
750
+ return true;
751
+ }
752
+ this.detailIsVisible = false;
753
+ return false;
754
+ };
755
+ this.detailIsVisible = undefined;
756
+ this.config = undefined;
757
+ this.getMessage = undefined;
758
+ this.showChips = true;
759
+ }
760
+ observeDetailIsVisible(value) {
761
+ this.visibleChanged.emit(value);
762
+ }
763
+ /**
764
+ * Exibe os detalhes de um item da lista.
765
+ */
766
+ async showUp(open = false) {
767
+ return new Promise(resolve => {
768
+ this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
769
+ if (open) {
770
+ this._closeCallback = resolve;
771
+ window.requestAnimationFrame(() => {
772
+ this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, this.getFloatOptions());
773
+ this._popover.show();
774
+ this.detailIsVisible = true;
775
+ });
776
+ }
777
+ });
778
+ }
779
+ updatePosition() {
780
+ if (this._floatingID == undefined) {
781
+ return;
782
+ }
783
+ FloatingManager.updateFloatPosition(this._popover, this._popoverContainer, this.getFloatOptions());
784
+ }
785
+ getFloatOptions() {
786
+ return {
787
+ autoClose: true,
788
+ innerClickTest: this.innerClickCheck,
789
+ backClickListener: () => this.onDetailCloseCallback(),
790
+ left: this.getOffsetLeft(),
791
+ top: this.getOffsetTop(),
792
+ useOverlay: true,
793
+ overlayClassName: 'ez-scrim ez-scrim--light',
794
+ isFixed: true
795
+ };
796
+ }
797
+ getOffsetLeft() {
798
+ const padding = getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");
799
+ const rect = this._filterItemElement.getBoundingClientRect();
800
+ // Width baseado no conteudo do snk-filter-detail. Nesse momento ele retorna 0px pois ainda não foi criado em tela.
801
+ const filterDetailWidth = 430;
802
+ const adjustRightPosition = filterDetailWidth - (document.body.clientWidth - rect.left);
803
+ return `calc(${rect.x}px + ${padding} - ${adjustRightPosition > 0 ? adjustRightPosition : 0}px)`;
804
+ }
805
+ getOffsetTop() {
806
+ const rect = this._filterItemElement.getBoundingClientRect();
807
+ return (rect.y + rect.height) + "px";
808
+ }
809
+ controlScrollPage() {
810
+ window.removeEventListener("scroll", this.updatePosition.bind(this));
811
+ window.addEventListener("scroll", this.updatePosition.bind(this));
812
+ }
813
+ getConfigChanges() {
814
+ var _a;
815
+ const configToBeCleared = this.config;
816
+ if (!!((_a = configToBeCleared.groupedItems) === null || _a === void 0 ? void 0 : _a.length)) {
817
+ configToBeCleared.visible = false;
818
+ configToBeCleared.groupedItems = configToBeCleared.groupedItems.map(item => (Object.assign(Object.assign({}, item), { visible: false })));
819
+ }
820
+ const hasMultiValues = configToBeCleared.type === FilterItemType.MULTI_LIST && Array.isArray(configToBeCleared.value);
821
+ const newValue = hasMultiValues ? configToBeCleared.value.map((valueItem) => (Object.assign(Object.assign({}, valueItem), { check: false }))) : undefined;
822
+ return Object.assign(Object.assign({}, configToBeCleared), { value: newValue });
823
+ }
824
+ /**
825
+ * Oculta os detalhes de um item da lista.
826
+ */
827
+ async hideDetail() {
828
+ if (this.detailIsVisible) {
829
+ if (this._floatingID != undefined) {
830
+ FloatingManager.close(this._floatingID);
831
+ }
832
+ }
833
+ }
834
+ onDetailCloseCallback() {
835
+ this._floatingID = undefined;
836
+ this.detailIsVisible = false;
837
+ if (this._closeCallback) {
838
+ this._closeCallback();
839
+ this._closeCallback = undefined;
840
+ }
841
+ }
842
+ //---------------------------------------------
843
+ // Event handlers
844
+ //---------------------------------------------
845
+ clickListener(evt) {
846
+ if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
847
+ if (evt.target === this._rightIconElement && this.canClearFilter()) {
848
+ const configChanged = this.getConfigChanges();
849
+ this.filterChange.emit(configChanged);
850
+ }
851
+ else {
852
+ if (this.detailIsVisible) {
853
+ this.hideDetail();
854
+ }
855
+ else {
856
+ this.showUp(true);
857
+ }
858
+ }
859
+ evt.preventDefault();
860
+ evt.stopImmediatePropagation();
861
+ evt.stopPropagation();
862
+ }
863
+ }
864
+ mouseDownListener(evt) {
865
+ if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
866
+ evt.preventDefault();
867
+ evt.stopImmediatePropagation();
868
+ evt.stopPropagation();
869
+ }
870
+ }
871
+ getLabel(isTooltipLabel = false) {
872
+ var _a, _b;
873
+ const { type, value, label, props, groupedItems = [] } = this.config;
874
+ if (value || groupedItems.length) {
875
+ if (type === FilterItemType.BINARY_SELECT) {
876
+ const [optOne, optTwo] = props.options;
877
+ const tooltip = this.getMessage('snkFilterBar.binarySelectTooltip');
878
+ if (optOne.name === value) {
879
+ return isTooltipLabel ? `${tooltip} ${String(optOne.label).toLowerCase()}` : optOne.label;
880
+ }
881
+ if (optTwo.name === value) {
882
+ return isTooltipLabel ? `${tooltip} ${String(optTwo.label).toLowerCase()}` : optTwo.label;
883
+ }
884
+ }
885
+ if (type === FilterItemType.MULTI_SELECT) {
886
+ const opt = props.options.find(opt => opt.value === value);
887
+ return `${label}: ${opt.label}`;
888
+ }
889
+ if (type === FilterItemType.PERIOD) {
890
+ let { end, start } = value;
891
+ if (typeof end === "string") {
892
+ end = new Date(end);
893
+ end.setMinutes(end.getMinutes() + end.getTimezoneOffset());
894
+ }
895
+ if (typeof start === "string") {
896
+ start = new Date(start);
897
+ start.setMinutes(start.getMinutes() + start.getTimezoneOffset());
898
+ }
899
+ const dateFormater = new Intl.DateTimeFormat("pt-BR");
900
+ if (end && start) {
901
+ const isSameYear = start.getFullYear() === end.getFullYear();
902
+ const formatOptions = Object.assign({ day: '2-digit', month: '2-digit' }, ((!isSameYear || isTooltipLabel) && { year: '2-digit' }));
903
+ const startLabel = DateUtils.formatDate(start, formatOptions);
904
+ const endLabel = DateUtils.formatDate(end, formatOptions);
905
+ if (isTooltipLabel) {
906
+ return this.getMessage('snkFilterBar.fullPeriodTooltip', { LABEL: label, START_LABEL: startLabel, END_LABEL: endLabel });
907
+ }
908
+ return `${label}: ${startLabel} \u2192 ${endLabel}`;
909
+ }
910
+ else {
911
+ if (start) {
912
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${dateFormater.format(start)}`;
913
+ }
914
+ else if (end) {
915
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${dateFormater.format(end)}`;
916
+ }
917
+ else {
918
+ return label;
919
+ }
920
+ }
921
+ }
922
+ if (type === FilterItemType.SEARCH) {
923
+ return `${label}: ${value.value} - ${value.label}`;
924
+ }
925
+ if (type === FilterItemType.PERSONALIZED) {
926
+ const activeCount = this.calculateActiveCount(groupedItems);
927
+ if (activeCount <= 0)
928
+ return label;
929
+ return `${label}: ${this.getMessage('snkFilterBar.personalizedCount', { activeCount })}`;
930
+ }
931
+ if (type === FilterItemType.MULTI_LIST) {
932
+ const selectedOptions = ((_a = value.elements) !== null && _a !== void 0 ? _a : value).filter(item => item === null || item === void 0 ? void 0 : item.check);
933
+ return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
934
+ }
935
+ if (type === FilterItemType.CHECK_BOX_LIST) {
936
+ const selectedValues = Object.entries(value !== null && value !== void 0 ? value : {})
937
+ .filter(([_, value]) => value === true)
938
+ .map(([key, _]) => key);
939
+ const options = (_b = props.options) !== null && _b !== void 0 ? _b : [];
940
+ const selectedOptions = options.filter(option => selectedValues.includes(option.name));
941
+ return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
942
+ }
943
+ if (type === FilterItemType.NUMBER && props.variation === FilterNumberVariation.INTERVAL) {
944
+ const { start, end } = value;
945
+ if (start && end) {
946
+ return this.getMessage('snkFilterBar.fullIntervalTooltip', { LABEL: label, START_LABEL: start, END_LABEL: end });
947
+ }
948
+ if (start) {
949
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${Number(start)}`;
950
+ }
951
+ if (end) {
952
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${Number(end)}`;
953
+ }
954
+ }
955
+ if (this.config.mask) {
956
+ const _maskFormatter = new MaskFormatter(this.config.mask);
957
+ return `${label}: ${_maskFormatter.format(value)}`;
958
+ }
959
+ return `${label}: ${value}`;
960
+ }
961
+ return label;
962
+ }
963
+ getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel) {
964
+ const checkedAmount = selectedOptions.length;
965
+ if (checkedAmount === 0) {
966
+ return `${label}`;
967
+ }
968
+ if (checkedAmount > 1) {
969
+ if (isTooltipLabel) {
970
+ const selectedOptionsDescrptions = selectedOptions.map(item => item.label);
971
+ return `${label}: ${selectedOptionsDescrptions.join(',')}`;
972
+ }
973
+ return `${label}: ${checkedAmount} ${this.getMessage('snkFilterBar.multiListToltip')}`;
974
+ }
975
+ return `${label}: ${selectedOptions[0].label}`;
976
+ }
977
+ calculateActiveCount(groupedItems) {
978
+ return groupedItems.reduce((total, item) => {
979
+ if (!!item.visible)
980
+ return total + 1;
981
+ return total;
982
+ }, 0);
983
+ }
984
+ componentDidLoad() {
985
+ if (this._filterItemElement) {
986
+ ElementIDUtils.addIDInfo(this._filterItemElement);
987
+ this._idSnkFilterDetail = `filterDetail_${this.config.id}`;
988
+ }
989
+ this.controlScrollPage();
990
+ }
991
+ componentDidRender() {
992
+ if (this._floatingID == undefined) {
993
+ if (this._popover) {
994
+ this._popover.remove();
995
+ }
996
+ }
997
+ }
998
+ /**
999
+ * Emitido quando o estado do filtro é alterado.
1000
+ */
1001
+ filterChangeListener() {
1002
+ this.hideDetail();
1003
+ }
1004
+ canClearFilter() {
1005
+ const { value, groupedItems = [] } = this.config;
1006
+ if (value != undefined && this.config.type === FilterItemType.MULTI_LIST) {
1007
+ return value.some((item) => item.check);
1008
+ }
1009
+ return value !== undefined || groupedItems.some(item => item.visible);
1010
+ }
1011
+ getRightIconName() {
1012
+ if (this.canClearFilter())
1013
+ return "close";
1014
+ return this.detailIsVisible ? "chevron-up" : "chevron-down";
1015
+ }
1016
+ getLeftIconName() {
1017
+ switch (this.config.type) {
1018
+ case FilterItemType.PERIOD:
1019
+ return "calendar";
1020
+ case FilterItemType.PERSONALIZED:
1021
+ return "tune";
1022
+ }
1023
+ return undefined;
1024
+ }
1025
+ hasActiveElements(value) {
1026
+ var _a, _b, _c;
1027
+ return ((_c = (_b = ((_a = value === null || value === void 0 ? void 0 : value.elements) !== null && _a !== void 0 ? _a : value)) === null || _b === void 0 ? void 0 : _b.filter(val => val === null || val === void 0 ? void 0 : val.check)) === null || _c === void 0 ? void 0 : _c.length) > 0;
1028
+ }
1029
+ hasActiveValue(config) {
1030
+ return (config.type !== FilterItemType.MULTI_LIST && config.value !== undefined) || this.hasActiveElements(config.value);
1031
+ }
1032
+ getEnabledChip() {
1033
+ if (this.config.type === FilterItemType.PERSONALIZED) {
1034
+ const { groupedItems = [] } = this.config;
1035
+ return groupedItems.some(item => item.visible);
1036
+ }
1037
+ return this.hasActiveValue(this.config);
1038
+ }
1039
+ render() {
1040
+ const leftIcon = this.getLeftIconName();
1041
+ return (h(Host, null, this.showChips && (h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.getEnabledChip() }, leftIcon && (h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" })), h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon", id: "removeFilter" }))), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16", ref: elem => this._popover = elem, key: this.config.id, "data-element-id": this._idSnkFilterDetail, showHardFixed: this.showChips }))));
1042
+ }
1043
+ get _filterItemElement() { return getElement(this); }
1044
+ static get watchers() { return {
1045
+ "detailIsVisible": ["observeDetailIsVisible"]
1046
+ }; }
1047
+ };
1048
+
1049
+ const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
1050
+ const MAX_FILTERS = 5;
1051
+ const SnkFilterList = class {
1052
+ constructor(hostRef) {
1053
+ registerInstance(this, hostRef);
1054
+ this.snkItemSelected = createEvent(this, "snkItemSelected", 7);
1055
+ this._preselection = -1;
1056
+ this.innerClickCheck = (_floatingContainer, node) => {
1057
+ if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
1058
+ return true;
1059
+ }
1060
+ this._detailIsVisible = false;
1061
+ return false;
1062
+ };
1063
+ this._filterArgument = undefined;
1064
+ this._showAll = undefined;
1065
+ this.label = undefined;
1066
+ this.iconName = undefined;
1067
+ this.items = undefined;
1068
+ this.getMessage = undefined;
1069
+ this.emptyText = undefined;
1070
+ this.findFilterText = undefined;
1071
+ this.buttonClass = undefined;
1072
+ }
1073
+ showDetail() {
1074
+ this._preselection = -1;
1075
+ this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, {
1076
+ autoClose: true,
1077
+ innerClickTest: this.innerClickCheck,
1078
+ backClickListener: () => this.onListCloseCallback(),
1079
+ useOverlay: true
1080
+ });
1081
+ this._detailIsVisible = true;
1082
+ this._showAll = false;
1083
+ this._filterArgument = "";
1084
+ this._filterInput.setFocus();
1085
+ }
1086
+ /**
1087
+ * Oculta os detalhes do componente snk-filter-list.
1088
+ */
1089
+ async hideDetail() {
1090
+ if (this._floatingID != undefined) {
1091
+ FloatingManager.close(this._floatingID);
1092
+ }
1093
+ }
1094
+ onListCloseCallback() {
1095
+ this._floatingID = undefined;
1096
+ this._detailIsVisible = false;
1097
+ }
1098
+ buttonClick() {
1099
+ if (this._detailIsVisible) {
1100
+ this.hideDetail();
1101
+ }
1102
+ else {
1103
+ this.showDetail();
1104
+ }
1105
+ }
1106
+ componentDidLoad() {
1107
+ if (this._element) {
1108
+ ElementIDUtils.addIDInfo(this._element);
1109
+ }
1110
+ }
1111
+ componentDidRender() {
1112
+ if (this._floatingID == undefined) {
1113
+ if (this._popover) {
1114
+ this._popover.remove();
1115
+ }
1116
+ }
1117
+ }
1118
+ buildIdElement(buttonElement, name) {
1119
+ if (!buttonElement)
1120
+ return;
1121
+ const dataElement = { id: name };
1122
+ buttonElement.removeAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
1123
+ ElementIDUtils.addIDInfoIfNotExists(buttonElement, "filterItemList", dataElement);
1124
+ }
1125
+ buildItemElement(item) {
1126
+ const itemId = ++this._selectableItemsCount;
1127
+ return (h("button", { ref: elem => elem && this.buildIdElement(elem, item.label), id: `filter-item${itemId}`, onFocusin: () => this._preselection = itemId, class: `ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item`, onClick: () => this.itemSelected(item.name), name: item.label, key: itemId }, item.iconName ? h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, h("div", { class: `ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${item.labelClass || ""}` }, item.label)));
1128
+ }
1129
+ itemSelected(itemName) {
1130
+ if (itemName === SHOW_MORE_ITEM_NAME) {
1131
+ this._showAll = true;
1132
+ }
1133
+ else {
1134
+ this.hideDetail();
1135
+ this.snkItemSelected.emit(itemName);
1136
+ }
1137
+ }
1138
+ getFilterItems() {
1139
+ const items = this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
1140
+ if (items.length === 0) {
1141
+ return h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty" }, this.emptyText);
1142
+ }
1143
+ const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
1144
+ if (hideItems) {
1145
+ items.splice(MAX_FILTERS);
1146
+ items.push({ kind: "INTERNAL", label: "Mostrar mais", iconName: "dots-horizontal", name: SHOW_MORE_ITEM_NAME, iconClass: "snk-filter-bar__filter-list-item__icon--secondary", labelClass: "snk-filter-bar__filter-list-item__label--secondary" });
1147
+ }
1148
+ this._selectableItemsCount = 0;
1149
+ return h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
1150
+ }
1151
+ getFooterItems() {
1152
+ return this.items.filter(item => item.kind === "FOOTER");
1153
+ }
1154
+ keyDownHandler(event) {
1155
+ switch (event.key) {
1156
+ case "ArrowDown":
1157
+ this.changePreselection(this._preselection + 1);
1158
+ //Paramos a propagação do evento para evitar scroll indesejado
1159
+ event.stopImmediatePropagation();
1160
+ event.stopPropagation();
1161
+ event.preventDefault();
1162
+ break;
1163
+ case "ArrowUp":
1164
+ this.changePreselection(this._preselection - 1);
1165
+ //Paramos a propagação do evento para evitar scroll indesejado
1166
+ event.stopImmediatePropagation();
1167
+ event.stopPropagation();
1168
+ event.preventDefault();
1169
+ break;
1170
+ }
1171
+ }
1172
+ changePreselection(newSelection) {
1173
+ if (newSelection < 0) {
1174
+ newSelection = this._selectableItemsCount;
1175
+ }
1176
+ this._preselection = newSelection > this._selectableItemsCount ? 0 : newSelection;
1177
+ if (this._preselection === 0) {
1178
+ this._filterInput.setFocus();
1179
+ }
1180
+ else {
1181
+ const item = this._element.querySelector(`#filter-item${this._preselection}`);
1182
+ if (item) {
1183
+ item.focus();
1184
+ }
1185
+ }
1186
+ }
1187
+ render() {
1188
+ return (h(Host, { class: "ez-flex ez-flex--column" }, h("ez-button", { class: this.buttonClass, label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, h("slot", { name: "leftIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--4", ref: elem => this._popover = elem }, h("ez-filter-input", { ref: ref => this._filterInput = ref, "data-element-id": "serachFilters", mode: "slim", label: this.findFilterText, value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail, onFocus: () => this._preselection = 0 }), this.getFilterItems(), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
1189
+ }
1190
+ get _element() { return getElement(this); }
1191
+ };
1192
+
1193
+ const snkFilterModalCss = "ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{width:344px;max-width:344px;min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px;overflow-x:clip;overflow-y:auto}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";
1194
+
1195
+ const SnkFilterModal = class {
1196
+ constructor(hostRef) {
1197
+ registerInstance(this, hostRef);
1198
+ this.getMessage = undefined;
1199
+ this.configName = undefined;
1200
+ this.filters = undefined;
1201
+ this.applyFilters = undefined;
1202
+ this.closeModal = undefined;
1203
+ this.addPersonalizedFilter = undefined;
1204
+ this.editPersonalizedFilter = undefined;
1205
+ this.deletePersonalizedFilter = undefined;
1206
+ this.filtersToDelete = [];
1207
+ this.disablePersonalizedFilter = undefined;
1208
+ }
1209
+ /**
1210
+ * Emitido quando um filtro personalizado é deletado.
1211
+ */
1212
+ deletePersonalizedFilterListener(event) {
1213
+ this.filtersToDelete.push(event.detail);
1214
+ }
1215
+ getCustomMessage(key, params) {
1216
+ var _a;
1217
+ return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
1218
+ }
1219
+ //TODO: tratar clear all dos filtros personalizados
1220
+ handleClearAll() {
1221
+ const { customFilters, quickFilters, otherFilters, multiListFilters } = this.filters.reduce((acc, filter) => {
1222
+ if (filter.type === FilterItemType.MULTI_LIST) {
1223
+ acc.multiListFilters.push(filter);
1224
+ return acc;
1225
+ }
1226
+ if (filter.filterType === FilterType.QUICK_FILTER) {
1227
+ acc.quickFilters.push(filter);
1228
+ return acc;
1229
+ }
1230
+ if (filter.filterType === FilterType.CUSTOM_FILTER) {
1231
+ acc.customFilters.push(filter);
1232
+ return acc;
1233
+ }
1234
+ if (filter.filterType === FilterType.OTHER_FILTERS) {
1235
+ acc.otherFilters.push(filter);
1236
+ return acc;
1237
+ }
1238
+ return acc;
1239
+ }, { quickFilters: [], customFilters: [], otherFilters: [], multiListFilters: [] });
1240
+ this.handleClearFilterList(quickFilters);
1241
+ this.handleClearCustomFilters(customFilters);
1242
+ this.handleClearOthersFilters(otherFilters);
1243
+ multiListFilters.forEach(multiListFilter => this.handleClearSigleFilter(multiListFilter));
1244
+ }
1245
+ handleClearOthersFilters(otherFilters) {
1246
+ this.filters = this.filters.map(filter => otherFilters.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
1247
+ }
1248
+ handleClearCustomFilters(customFilters) {
1249
+ this.filters.forEach((filter, index) => {
1250
+ if (filter.filterType === FilterType.CUSTOM_FILTER)
1251
+ this.filters[index] = this.clearAllCustomFilter(customFilters).shift();
1252
+ });
1253
+ }
1254
+ clearAllCustomFilter(filterConfigSnapshot) {
1255
+ return filterConfigSnapshot.map(filterItem => {
1256
+ const copy = Object.assign({}, filterItem);
1257
+ delete copy.value;
1258
+ copy.visible = false;
1259
+ if (copy.groupedItems) {
1260
+ copy.groupedItems = this.clearAllCustomFilter(copy.groupedItems);
1261
+ }
1262
+ return copy;
1263
+ });
1264
+ }
1265
+ handleClose() {
1266
+ const hasChangesToSave = ObjectUtils.objectToString(this.filters) !== ObjectUtils.objectToString(this._originalFilterConfig);
1267
+ if (!hasChangesToSave) {
1268
+ this.closeModal();
1269
+ return;
1270
+ }
1271
+ return ApplicationUtils.confirm(this.getCustomMessage('validations.notSaved.title'), this.getCustomMessage('validations.notSaved.message')).then((cancelAction) => {
1272
+ if (cancelAction)
1273
+ this.closeModal();
1274
+ });
1275
+ }
1276
+ handleApplyFilters() {
1277
+ const filterPersonalized = this.filters.find(filter => filter.filterType === FilterType.CUSTOM_FILTER);
1278
+ if (this.isValidCustomFilter(filterPersonalized)) {
1279
+ this.applyFilters(this.filters);
1280
+ }
1281
+ if (this.filtersToDelete.length > 0) {
1282
+ this.filtersToDelete.forEach(filter => {
1283
+ this.deletePersonalizedFilter(filter, this.configName);
1284
+ });
1285
+ this.filtersToDelete = [];
1286
+ }
1287
+ }
1288
+ isValidCustomFilter(filterPersonalized) {
1289
+ const isValid = PersonalizedFilterUtils.validateVariableValues(filterPersonalized);
1290
+ if (!isValid) {
1291
+ ApplicationUtils.alert(this.getCustomMessage('validations.notFullFilled.title'), this.getCustomMessage('validations.notFullFilled.message'));
1292
+ return false;
1293
+ }
1294
+ return true;
1295
+ }
1296
+ modalActionListener(evt) {
1297
+ const modalAction = evt.detail;
1298
+ switch (modalAction) {
1299
+ case ModalAction.CANCEL:
1300
+ this.handleClearAll();
1301
+ break;
1302
+ case ModalAction.OK:
1303
+ this.handleApplyFilters();
1304
+ break;
1305
+ case ModalAction.CLOSE:
1306
+ this.handleClose();
1307
+ break;
1308
+ }
1309
+ }
1310
+ handleFilterChange(filterConfig) {
1311
+ this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
1312
+ }
1313
+ handleClearFilterList(filterList) {
1314
+ this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
1315
+ }
1316
+ handleClearSigleFilter(filterItem) {
1317
+ if (FilterItemType.MULTI_LIST === filterItem.type) {
1318
+ let filterItemCopy = ObjectUtils.copy(filterItem);
1319
+ this.uncheckFilterValues(filterItemCopy.value);
1320
+ const filterListCopy = ObjectUtils.copy(this.filters);
1321
+ const index = filterListCopy.findIndex(item => item.id === filterItem.id);
1322
+ filterListCopy.splice(index, 1, filterItemCopy);
1323
+ this.filters = ObjectUtils.copy(filterListCopy);
1324
+ return;
1325
+ }
1326
+ if (FilterItemType.CHECK_BOX_LIST === filterItem.type) {
1327
+ const filterListCopy = ObjectUtils.copy(this.filters);
1328
+ filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
1329
+ this.filters = ObjectUtils.copy(filterListCopy);
1330
+ return;
1331
+ }
1332
+ const filter = this.filters.find(filter => filter.id === filterItem.id);
1333
+ filter.value = undefined;
1334
+ this.filters = ObjectUtils.copy(this.filters);
1335
+ }
1336
+ uncheckFilterValues(valueList) {
1337
+ valueList.forEach(value => {
1338
+ if (!!value) {
1339
+ value.check = false;
1340
+ }
1341
+ });
1342
+ return valueList;
1343
+ }
1344
+ renderFilterItem(filterItem, fullRow) {
1345
+ return (h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event.detail), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
1346
+ }
1347
+ isDefaultFilterNumberVariation(filter) {
1348
+ var _a;
1349
+ return filter.type === FilterItemType.NUMBER
1350
+ && (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === FilterNumberVariation.DEFAULT);
1351
+ }
1352
+ mountFiltersLines(filters) {
1353
+ const MAX_LINE_LENGTH = 2;
1354
+ let currentLine = 0;
1355
+ let forceAddCurrent = false;
1356
+ const filtersLines = {};
1357
+ for (let curr = 0; curr < filters.length; curr++) {
1358
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
1359
+ const item = filters[curr];
1360
+ const isLast = curr === filters.length - 1;
1361
+ const currentItemMatch = item.type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
1362
+ const nextItemMatch = isLast ? false : filters[curr + 1].type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
1363
+ if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
1364
+ filtersLines[currentLine].push(item);
1365
+ forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
1366
+ if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
1367
+ ++currentLine;
1368
+ continue;
1369
+ }
1370
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
1371
+ filtersLines[currentLine].push(item);
1372
+ ++currentLine;
1373
+ }
1374
+ return Object.values(filtersLines);
1375
+ }
1376
+ renderFilterLine(filters) {
1377
+ const fullLine = filters.length === 1;
1378
+ return filters.map((filter) => this.renderFilterItem(filter, fullLine));
1379
+ }
1380
+ getIformedFiltersCount(listItems) {
1381
+ let countInformedItens = 0;
1382
+ listItems.forEach(item => {
1383
+ var _a, _b, _c, _d, _e, _f;
1384
+ if (FilterItemType.MULTI_LIST === item.type) {
1385
+ countInformedItens += (_e = (_d = (_c = ((_b = (_a = item.value) === null || _a === void 0 ? void 0 : _a.elements) !== null && _b !== void 0 ? _b : item.value)) === null || _c === void 0 ? void 0 : _c.filter(value => value === null || value === void 0 ? void 0 : value.check)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
1386
+ return;
1387
+ }
1388
+ if (FilterItemType.CHECK_BOX_LIST === item.type) {
1389
+ countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
1390
+ .filter(([_, value]) => value === true)
1391
+ .map(([key, _]) => key).length;
1392
+ return;
1393
+ }
1394
+ if (item.groupedItems != undefined) {
1395
+ countInformedItens = item.groupedItems.filter(item => item.visible).length;
1396
+ return;
1397
+ }
1398
+ if (!!item.value) {
1399
+ countInformedItens++;
1400
+ }
1401
+ });
1402
+ return countInformedItens;
1403
+ }
1404
+ renderCollapsibleFilterBox(label, listItems, isSingleItem, shouldRenderFooter = true) {
1405
+ if (!listItems.length)
1406
+ return null;
1407
+ const appliedFilters = this.getIformedFiltersCount(listItems);
1408
+ const lines = this.mountFiltersLines(listItems);
1409
+ return (h("ez-collapsible-box", { class: "snk-filter-modal__collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters && (h("ez-badge", { class: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toString() })), h("div", { class: "ez-row snk-filter-modal__rendered-items" }, lines.map(this.renderFilterLine.bind(this))), shouldRenderFooter && (h("div", { class: "ez-flex ez-flex--justify-end grow" }, h("ez-button", { class: "ez-button--tertiary", size: "medium", label: "Limpar", onClick: () => isSingleItem ? this.handleClearSigleFilter(listItems[0]) : this.handleClearFilterList(listItems) })))));
1410
+ }
1411
+ componentWillRender() {
1412
+ this._modalTitle = this.getCustomMessage('title');
1413
+ this._okButtonLabel = this.getCustomMessage('okButtonLabel');
1414
+ this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
1415
+ }
1416
+ componentDidLoad() {
1417
+ if (!this._originalFilterConfig)
1418
+ this._originalFilterConfig = this.filters;
1419
+ }
1420
+ render() {
1421
+ const customFilters = this.filters.filter(filter => filter.filterType === FilterType.CUSTOM_FILTER);
1422
+ const quickFilters = this.filters.filter(filter => filter.filterType === FilterType.QUICK_FILTER);
1423
+ const otherFilters = this.filters.filter(filter => filter.filterType === FilterType.OTHER_FILTERS);
1424
+ return (h("ez-modal-container", { class: "snk-filter-modal__container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, h("div", { class: "snk-filter-modal__content ez-col--sd-12" }, !this.disablePersonalizedFilter && this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters, false, false), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters, false), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter], true)))));
1425
+ }
1426
+ };
1427
+ SnkFilterModal.style = snkFilterModalCss;
1428
+
1429
+ export { SnkFilterBar as snk_filter_bar, SnkFilterItem as snk_filter_item, SnkFilterList as snk_filter_list, SnkFilterModal as snk_filter_modal };