@sankhyalabs/sankhyablocks 8.16.0-dev.9 → 8.16.0-dev.90

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