@sankhyalabs/sankhyablocks 8.16.0-dev.8 → 8.16.0-dev.80

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. package/dist/cjs/{ConfigStorage-a343e418.js → ConfigStorage-d024aec8.js} +2 -2
  2. package/dist/cjs/{IExporterProvider-597949f9.js → ContinuousInsertUtils-c27b439e.js} +66 -23
  3. package/dist/cjs/{DataFetcher-313debd8.js → DataFetcher-65879b2c.js} +216 -76
  4. package/dist/cjs/{RecordIDUtils-3735135c.js → GetSelectedRecordsIDsInfo-bd50caf1.js} +10 -10
  5. package/dist/cjs/{SnkFormConfigManager-166cbd1f.js → SnkFormConfigManager-c11d8468.js} +75 -17
  6. package/dist/cjs/{SnkMessageBuilder-722b104e.js → SnkMessageBuilder-bae64d0d.js} +7 -3
  7. package/dist/cjs/{auth-fetcher-54f5ff9d.js → auth-fetcher-8480751c.js} +1 -1
  8. package/dist/cjs/{constants-35ddd366.js → constants-241934b3.js} +9 -0
  9. package/dist/cjs/{dataunit-fetcher-688d3f05.js → dataunit-fetcher-8291ac21.js} +239 -43
  10. package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
  11. package/dist/cjs/{form-config-fetcher-2dd00e5b.js → form-config-fetcher-90126e4c.js} +42 -2
  12. package/dist/cjs/index-f9e81701.js +16 -32
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/cjs/pesquisa-fetcher-5c583c93.js +365 -0
  15. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +156 -0
  16. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  17. package/dist/cjs/{snk-actions-button_4.cjs.entry.js → snk-actions-button_5.cjs.entry.js} +138 -42
  18. package/dist/cjs/snk-application.cjs.entry.js +293 -69
  19. package/dist/cjs/snk-attach.cjs.entry.js +47 -34
  20. package/dist/cjs/{snk-form-config.cjs.entry.js → snk-config-options_3.cjs.entry.js} +399 -13
  21. package/dist/cjs/snk-configurator.cjs.entry.js +2 -2
  22. package/dist/cjs/snk-crud.cjs.entry.js +23 -9
  23. package/dist/cjs/snk-data-exporter.cjs.entry.js +35 -23
  24. package/dist/cjs/{snk-data-unit-04df81bf.js → snk-data-unit-d75e6220.js} +54 -32
  25. package/dist/cjs/snk-data-unit.cjs.entry.js +5 -5
  26. package/dist/cjs/snk-detail-view.cjs.entry.js +13 -13
  27. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
  28. package/dist/cjs/snk-field-config.cjs.entry.js +1 -1
  29. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +1436 -0
  30. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  31. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
  32. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  33. package/dist/cjs/snk-filter-text.cjs.entry.js +2 -1
  34. package/dist/cjs/snk-grid.cjs.entry.js +89 -24
  35. package/dist/cjs/{snk-guides-viewer-bdc41281.js → snk-guides-viewer-bff0d27d.js} +30 -14
  36. package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -9
  37. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +4 -4
  38. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  39. package/dist/cjs/snk-pesquisa.cjs.entry.js +111 -31
  40. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  41. package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
  42. package/dist/cjs/snk-simple-crud.cjs.entry.js +102 -45
  43. package/dist/cjs/snk-tab-config.cjs.entry.js +1 -1
  44. package/dist/cjs/snk-taskbar.cjs.entry.js +70 -38
  45. package/dist/collection/collection-manifest.json +14 -31
  46. package/dist/collection/components/snk-actions-button/actions/index.js +16 -13
  47. package/dist/collection/components/snk-actions-button/interfaces/index.js +1 -0
  48. package/dist/collection/components/snk-actions-button/snk-actions-button.js +27 -26
  49. package/dist/collection/components/snk-application/request-listener/DebouncedRequestListener.js +29 -0
  50. package/dist/collection/components/snk-application/request-listener/RequestListenerFactory.js +16 -0
  51. package/dist/collection/components/snk-application/request-listener/RequestListenerLoadingBar.js +52 -0
  52. package/dist/collection/components/snk-application/snk-application.css +36 -0
  53. package/dist/collection/components/snk-application/snk-application.js +315 -64
  54. package/dist/collection/components/snk-attach/snk-attach.js +25 -16
  55. package/dist/collection/components/snk-attach/structure/builder/taskbar-builder.js +8 -4
  56. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -4
  57. package/dist/collection/components/snk-configurator/snk-configurator.css +1 -1
  58. package/dist/collection/components/snk-crud/snk-crud.js +122 -3
  59. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +3 -3
  60. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.css +6 -6
  61. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +72 -6
  62. package/dist/collection/components/snk-data-exporter/exporter-email-sender/options-step.js +1 -1
  63. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +13 -7
  64. package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +9 -2
  65. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +1 -1
  66. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
  67. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
  68. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +3 -5
  69. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +2 -2
  70. package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +4 -4
  71. package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +1 -1
  72. package/dist/collection/components/snk-data-unit/snk-data-unit.js +52 -30
  73. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +1 -1
  74. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +1 -1
  75. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +2 -1
  76. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.css +13 -0
  77. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.js +3 -3
  78. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type-mask.enum.js +8 -0
  79. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +5 -1
  80. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.css +1 -1
  81. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +3 -1
  82. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +1 -1
  83. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +118 -28
  84. package/dist/collection/components/snk-form/snk-form.js +2 -2
  85. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +73 -15
  86. package/dist/collection/components/snk-form-config/snk-form-config.css +8 -3
  87. package/dist/collection/components/snk-form-config/snk-form-config.js +49 -8
  88. package/dist/collection/components/snk-grid/snk-grid.css +2 -0
  89. package/dist/collection/components/snk-grid/snk-grid.js +170 -11
  90. package/dist/collection/components/snk-grid-config/snk-grid-config.css +1 -1
  91. package/dist/collection/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.css +9 -0
  92. package/dist/collection/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.js +226 -0
  93. package/dist/collection/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.css +28 -0
  94. package/dist/collection/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.js +208 -0
  95. package/dist/collection/components/snk-pesquisa/pesquisaHelper.js +99 -0
  96. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +35 -6
  97. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +174 -32
  98. package/dist/collection/components/snk-print-selector/snk-print-selector.js +1 -1
  99. package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +1 -1
  100. package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +1 -1
  101. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +164 -35
  102. package/dist/collection/components/snk-simple-form-config/snk-simple-form-config.css +22 -0
  103. package/dist/collection/components/snk-simple-form-config/snk-simple-form-config.js +181 -0
  104. package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
  105. package/dist/collection/components/snk-taskbar/snk-taskbar.js +112 -38
  106. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +3 -3
  107. package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -4
  108. package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
  109. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +29 -21
  110. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.js +7 -5
  111. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +59 -14
  112. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +21 -7
  113. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/helpers/DataUnitDataLoaderHelper.js +108 -0
  114. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +17 -9
  115. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +45 -5
  116. package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +7 -1
  117. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +107 -7
  118. package/dist/collection/lib/index.js +1 -0
  119. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -1
  120. package/dist/collection/lib/message/resources/snk-exporter.msg.js +1 -1
  121. package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
  122. package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
  123. package/dist/collection/lib/utils/CrudUtils.js +25 -16
  124. package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
  125. package/dist/collection/lib/utils/constants.js +9 -0
  126. package/dist/collection/sw.js +46 -0
  127. package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +67 -23
  128. package/dist/components/DataFetcher.js +217 -77
  129. package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
  130. package/dist/components/ISave.js +362 -1
  131. package/dist/components/SnkFormConfigManager.js +73 -15
  132. package/dist/components/SnkMessageBuilder.js +7 -3
  133. package/dist/components/constants.js +10 -1
  134. package/dist/components/dataunit-fetcher.js +238 -40
  135. package/dist/components/form-config-fetcher.js +41 -1
  136. package/dist/components/index.d.ts +3 -0
  137. package/dist/components/index.js +3 -0
  138. package/dist/components/pesquisa-grid.d.ts +11 -0
  139. package/dist/components/pesquisa-grid.js +6 -0
  140. package/dist/components/pesquisa-grid2.js +102 -0
  141. package/dist/components/pesquisa-tree.d.ts +11 -0
  142. package/dist/components/pesquisa-tree.js +6 -0
  143. package/dist/components/pesquisa-tree2.js +91 -0
  144. package/dist/components/snk-actions-button2.js +44 -40
  145. package/dist/components/snk-application2.js +312 -68
  146. package/dist/components/snk-attach2.js +54 -60
  147. package/dist/components/snk-config-options2.js +1 -1
  148. package/dist/components/snk-configurator2.js +1 -1
  149. package/dist/components/snk-crud.js +83 -59
  150. package/dist/components/snk-data-exporter2.js +28 -17
  151. package/dist/components/snk-data-unit2.js +55 -70
  152. package/dist/components/snk-detail-view2.js +115 -106
  153. package/dist/components/snk-exporter-email-sender2.js +1 -1
  154. package/dist/components/snk-filter-bar2.js +64 -30
  155. package/dist/components/snk-filter-binary-select.js +1 -1
  156. package/dist/components/snk-filter-checkbox-list.js +1 -1
  157. package/dist/components/snk-filter-item2.js +5 -1
  158. package/dist/components/snk-filter-modal.js +4 -2
  159. package/dist/components/snk-filter-text.js +2 -1
  160. package/dist/components/snk-form-config2.js +35 -10
  161. package/dist/components/snk-form.js +2 -2
  162. package/dist/components/snk-grid-config2.js +1 -1
  163. package/dist/components/snk-grid2.js +86 -16
  164. package/dist/components/snk-personalized-filter-editor.js +4 -4
  165. package/dist/components/snk-pesquisa2.js +125 -33
  166. package/dist/components/snk-print-selector.js +1 -1
  167. package/dist/components/snk-simple-bar2.js +1 -1
  168. package/dist/components/snk-simple-crud2.js +108 -65
  169. package/dist/components/snk-simple-form-config.d.ts +11 -0
  170. package/dist/components/snk-simple-form-config.js +6 -0
  171. package/dist/components/snk-simple-form-config2.js +121 -0
  172. package/dist/components/snk-tab-config2.js +1 -1
  173. package/dist/components/snk-taskbar2.js +72 -40
  174. package/dist/components/teste-pesquisa.js +13 -1
  175. package/dist/esm/{ConfigStorage-3806514e.js → ConfigStorage-373bb440.js} +2 -2
  176. package/dist/esm/{IExporterProvider-63a188b6.js → ContinuousInsertUtils-6bf78c5e.js} +67 -25
  177. package/dist/esm/{DataFetcher-c1baf61d.js → DataFetcher-5221b992.js} +217 -77
  178. package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
  179. package/dist/esm/{SnkFormConfigManager-31b24066.js → SnkFormConfigManager-5022f87f.js} +75 -17
  180. package/dist/esm/{SnkMessageBuilder-89925609.js → SnkMessageBuilder-6fff4a4c.js} +7 -3
  181. package/dist/esm/{auth-fetcher-039abba3.js → auth-fetcher-e32fe8a4.js} +1 -1
  182. package/dist/esm/{constants-8457af36.js → constants-75abb876.js} +10 -1
  183. package/dist/esm/{dataunit-fetcher-264191b2.js → dataunit-fetcher-5247a708.js} +239 -41
  184. package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
  185. package/dist/esm/{form-config-fetcher-30fb808f.js → form-config-fetcher-126e2471.js} +42 -2
  186. package/dist/esm/index-a7d3d3f1.js +16 -32
  187. package/dist/esm/loader.js +1 -1
  188. package/dist/esm/pesquisa-fetcher-4284f2a3.js +362 -0
  189. package/dist/esm/pesquisa-grid_2.entry.js +151 -0
  190. package/dist/esm/sankhyablocks.js +1 -1
  191. package/dist/esm/{snk-actions-button_4.entry.js → snk-actions-button_5.entry.js} +139 -44
  192. package/dist/esm/snk-application.entry.js +295 -71
  193. package/dist/esm/snk-attach.entry.js +47 -34
  194. package/dist/esm/{snk-form-config.entry.js → snk-config-options_3.entry.js} +399 -15
  195. package/dist/esm/snk-configurator.entry.js +2 -2
  196. package/dist/esm/snk-crud.entry.js +23 -9
  197. package/dist/esm/snk-data-exporter.entry.js +35 -23
  198. package/dist/esm/{snk-data-unit-8eec78bd.js → snk-data-unit-bfd10c71.js} +54 -32
  199. package/dist/esm/snk-data-unit.entry.js +5 -5
  200. package/dist/esm/snk-detail-view.entry.js +13 -13
  201. package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
  202. package/dist/esm/snk-field-config.entry.js +1 -1
  203. package/dist/esm/snk-filter-bar_4.entry.js +1429 -0
  204. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  205. package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
  206. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  207. package/dist/esm/snk-filter-text.entry.js +2 -1
  208. package/dist/esm/snk-grid.entry.js +84 -19
  209. package/dist/esm/{snk-guides-viewer-dda0fede.js → snk-guides-viewer-454ebc07.js} +30 -14
  210. package/dist/esm/snk-guides-viewer.entry.js +9 -9
  211. package/dist/esm/snk-personalized-filter-editor.entry.js +4 -4
  212. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  213. package/dist/esm/snk-pesquisa.entry.js +111 -31
  214. package/dist/esm/snk-print-selector.entry.js +1 -1
  215. package/dist/esm/snk-simple-bar.entry.js +1 -1
  216. package/dist/esm/snk-simple-crud.entry.js +99 -42
  217. package/dist/esm/snk-tab-config.entry.js +1 -1
  218. package/dist/esm/snk-taskbar.entry.js +71 -39
  219. package/dist/sankhyablocks/p-03e6825e.js +1 -0
  220. package/dist/sankhyablocks/p-1435701f.js +26 -0
  221. package/dist/sankhyablocks/p-16a1dd18.entry.js +1 -0
  222. package/dist/sankhyablocks/p-17425c72.js +1 -0
  223. package/dist/sankhyablocks/{p-52920496.js → p-19dc71e9.js} +1 -1
  224. package/dist/sankhyablocks/{p-47db7e88.entry.js → p-1cf39cfd.entry.js} +1 -1
  225. package/dist/sankhyablocks/{p-b0ef4383.js → p-1d19a5b0.js} +1 -1
  226. package/dist/sankhyablocks/p-23736d75.js +1 -0
  227. package/dist/sankhyablocks/{p-8eb67fa4.entry.js → p-23cd6abf.entry.js} +1 -1
  228. package/dist/sankhyablocks/p-28ca3908.entry.js +1 -0
  229. package/dist/sankhyablocks/{p-95df461f.entry.js → p-2953c481.entry.js} +1 -1
  230. package/dist/sankhyablocks/p-38179225.js +60 -0
  231. package/dist/sankhyablocks/p-3ba431c9.js +1 -0
  232. package/dist/sankhyablocks/p-41c3bee5.js +6 -0
  233. package/dist/sankhyablocks/{p-72fc257b.entry.js → p-434817f0.entry.js} +1 -1
  234. package/dist/sankhyablocks/p-47178038.entry.js +1 -0
  235. package/dist/sankhyablocks/p-478ab2b6.js +1 -0
  236. package/dist/sankhyablocks/{p-7663f597.entry.js → p-4c9adf1c.entry.js} +1 -1
  237. package/dist/sankhyablocks/p-50bf8dbc.entry.js +1 -0
  238. package/dist/sankhyablocks/{p-aaa3ee68.entry.js → p-5f157b09.entry.js} +1 -1
  239. package/dist/sankhyablocks/p-643b2aaa.entry.js +1 -0
  240. package/dist/sankhyablocks/p-655bdd60.js +1 -0
  241. package/dist/sankhyablocks/p-6fc8bfa2.entry.js +1 -0
  242. package/dist/sankhyablocks/p-73b037a8.entry.js +1 -0
  243. package/dist/sankhyablocks/p-7dd49d15.js +1 -0
  244. package/dist/sankhyablocks/{p-2c68b3ae.entry.js → p-82ee6dc3.entry.js} +1 -1
  245. package/dist/sankhyablocks/p-89c92727.entry.js +1 -0
  246. package/dist/sankhyablocks/p-8ad7c8bc.entry.js +1 -0
  247. package/dist/sankhyablocks/{p-41f8bfa3.entry.js → p-8c235d4c.entry.js} +1 -1
  248. package/dist/sankhyablocks/p-91e34755.entry.js +1 -0
  249. package/dist/sankhyablocks/p-9a99c67b.entry.js +1 -0
  250. package/dist/sankhyablocks/p-a04f38aa.entry.js +1 -0
  251. package/dist/sankhyablocks/p-ae26e8d0.entry.js +1 -0
  252. package/dist/sankhyablocks/p-bd234604.entry.js +1 -0
  253. package/dist/sankhyablocks/p-c021a3a9.entry.js +1 -0
  254. package/dist/sankhyablocks/p-c2e468c9.entry.js +1 -0
  255. package/dist/sankhyablocks/p-d62228fb.js +1 -0
  256. package/dist/sankhyablocks/p-d9bb48c4.entry.js +11 -0
  257. package/dist/sankhyablocks/p-edbe8e15.entry.js +1 -0
  258. package/dist/sankhyablocks/{p-913a9979.js → p-f0b9303b.js} +1 -1
  259. package/dist/sankhyablocks/p-f8db6795.entry.js +1 -0
  260. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  261. package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
  262. package/dist/types/components/snk-actions-button/interfaces/index.d.ts +3 -0
  263. package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +3 -2
  264. package/dist/types/components/snk-application/request-listener/DebouncedRequestListener.d.ts +11 -0
  265. package/dist/types/components/snk-application/request-listener/RequestListenerFactory.d.ts +12 -0
  266. package/dist/types/components/snk-application/request-listener/RequestListenerLoadingBar.d.ts +13 -0
  267. package/dist/types/components/snk-application/snk-application.d.ts +38 -14
  268. package/dist/types/components/snk-attach/snk-attach.d.ts +1 -0
  269. package/dist/types/components/snk-crud/snk-crud.d.ts +21 -0
  270. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +15 -0
  271. package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +1 -0
  272. package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +1 -0
  273. package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +3 -3
  274. package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +1 -1
  275. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +2 -0
  276. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type-mask.enum.d.ts +7 -0
  277. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +2 -0
  278. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +15 -1
  279. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +7 -2
  280. package/dist/types/components/snk-form-config/snk-form-config.d.ts +4 -0
  281. package/dist/types/components/snk-grid/snk-grid.d.ts +28 -0
  282. package/dist/types/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.d.ts +44 -0
  283. package/dist/types/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.d.ts +33 -0
  284. package/dist/types/components/snk-pesquisa/pesquisaHelper.d.ts +24 -0
  285. package/dist/types/components/snk-pesquisa/snk-pesquisa.d.ts +35 -1
  286. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +27 -3
  287. package/dist/types/components/snk-simple-form-config/snk-simple-form-config.d.ts +34 -0
  288. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
  289. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -0
  290. package/dist/types/components.d.ts +388 -14
  291. package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +12 -2
  292. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
  293. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.d.ts +3 -2
  294. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +9 -1
  295. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +4 -0
  296. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/helpers/DataUnitDataLoaderHelper.d.ts +6 -0
  297. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadingInfo.d.ts +4 -0
  298. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +3 -3
  299. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +1 -1
  300. package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +8 -2
  301. package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +1 -0
  302. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +17 -1
  303. package/dist/types/lib/index.d.ts +1 -0
  304. package/dist/types/lib/utils/ContinuousInsertUtils.d.ts +10 -0
  305. package/dist/types/lib/utils/CrudUtils.d.ts +1 -0
  306. package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
  307. package/dist/types/lib/utils/constants.d.ts +7 -0
  308. package/package.json +4 -3
  309. package/react/components.d.ts +3 -0
  310. package/react/components.js +3 -0
  311. package/react/components.js.map +1 -1
  312. package/dist/cjs/pesquisa-fetcher-680e198f.js +0 -166
  313. package/dist/cjs/snk-config-options.cjs.entry.js +0 -239
  314. package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -714
  315. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -312
  316. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -152
  317. package/dist/cjs/snk-filter-modal.cjs.entry.js +0 -249
  318. package/dist/cjs/snk-form.cjs.entry.js +0 -143
  319. package/dist/components/pesquisa-fetcher.js +0 -164
  320. package/dist/esm/pesquisa-fetcher-03c8f919.js +0 -164
  321. package/dist/esm/snk-config-options.entry.js +0 -235
  322. package/dist/esm/snk-filter-bar.entry.js +0 -710
  323. package/dist/esm/snk-filter-item.entry.js +0 -308
  324. package/dist/esm/snk-filter-list.entry.js +0 -148
  325. package/dist/esm/snk-filter-modal.entry.js +0 -245
  326. package/dist/esm/snk-form.entry.js +0 -139
  327. package/dist/sankhyablocks/p-045eae4d.entry.js +0 -11
  328. package/dist/sankhyablocks/p-219f888d.entry.js +0 -1
  329. package/dist/sankhyablocks/p-2a408684.js +0 -1
  330. package/dist/sankhyablocks/p-3a212712.js +0 -1
  331. package/dist/sankhyablocks/p-3b60db06.entry.js +0 -1
  332. package/dist/sankhyablocks/p-450c60e4.entry.js +0 -1
  333. package/dist/sankhyablocks/p-4e5e1313.entry.js +0 -1
  334. package/dist/sankhyablocks/p-547eeac8.entry.js +0 -1
  335. package/dist/sankhyablocks/p-62ba211a.entry.js +0 -1
  336. package/dist/sankhyablocks/p-70a4af56.entry.js +0 -1
  337. package/dist/sankhyablocks/p-7505da04.entry.js +0 -1
  338. package/dist/sankhyablocks/p-75e674ed.entry.js +0 -1
  339. package/dist/sankhyablocks/p-7a337364.js +0 -1
  340. package/dist/sankhyablocks/p-7a85fd49.entry.js +0 -1
  341. package/dist/sankhyablocks/p-7b08d0f8.entry.js +0 -1
  342. package/dist/sankhyablocks/p-80042dc6.entry.js +0 -1
  343. package/dist/sankhyablocks/p-88aa931b.entry.js +0 -1
  344. package/dist/sankhyablocks/p-96a89d58.entry.js +0 -1
  345. package/dist/sankhyablocks/p-9863d682.js +0 -1
  346. package/dist/sankhyablocks/p-af8efd95.js +0 -6
  347. package/dist/sankhyablocks/p-b05d8893.entry.js +0 -1
  348. package/dist/sankhyablocks/p-b11aa1e0.entry.js +0 -1
  349. package/dist/sankhyablocks/p-c1d57831.entry.js +0 -1
  350. package/dist/sankhyablocks/p-c2495304.js +0 -1
  351. package/dist/sankhyablocks/p-d1791da2.entry.js +0 -1
  352. package/dist/sankhyablocks/p-d3f53df2.entry.js +0 -1
  353. package/dist/sankhyablocks/p-d6e26ea8.entry.js +0 -1
  354. package/dist/sankhyablocks/p-dc7c9047.js +0 -1
  355. package/dist/sankhyablocks/p-df5451c7.js +0 -26
  356. package/dist/sankhyablocks/p-e549f7d1.js +0 -1
  357. package/dist/sankhyablocks/p-e8763234.entry.js +0 -1
  358. package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
  359. package/dist/sankhyablocks/p-fa4d8cb4.js +0 -1
  360. package/dist/sankhyablocks/p-fe79f83a.js +0 -60
  361. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -0,0 +1,1436 @@
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 (start && 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 (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 (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:8px}[data-mode=\"hidden\"].sc-snk-filter-bar-h{width:0px;height:0px}[data-mode=\"button\"].sc-snk-filter-bar-h{grid-template-columns:1fr;width:fit-content}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.filter-bar__personalized-filter.sc-snk-filter-bar{display:flex;flex-direction:column;position:fixed;top:0;left:0;width:100%;height:100%;overflow:auto;z-index:var(--snk-personalized-filter--z-index);background-color:var(--snk-personalized-filter--background-color)}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;background-color:transparent;border:none;padding:3px;outline-color:var(--color--primary)}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.snk-filter-bar__scroller.sc-snk-filter-bar{height:calc(100% + var(--space-extra-small, 3px))}.snk-filter-bar__filter-item-container.sc-snk-filter-bar{display:flex;align-items:start}.snk-filter-bar__scroller.sc-snk-filter-bar .sc-snk-filter-bar:first-child{margin-left:var(--space-extra-small, 3px)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px);border:none;background-color:transparent}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:focus-visible{outline:none;background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:\"\";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar{--modal-item-border-width:2px;display:flex;flex-direction:row;margin-left:var(--modal-item-border-width);border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7);border:none;width:100%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar:focus-visible{outline:var(--color--primary) solid var(--modal-item-border-width)}.snk-filter-bar__filter-modal-item__check.sc-snk-filter-bar{width:auto}.snk-filter-bar__filter-modal-item__label.sc-snk-filter-bar{font-weight:var(--text-weight--medium)}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:99%;height:100%}";
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", 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
+ window.requestAnimationFrame(() => {
776
+ this._floatingID = core.FloatingManager.float(this._popover, this._popoverContainer, this.getFloatOptions());
777
+ this._popover.show();
778
+ this.detailIsVisible = true;
779
+ });
780
+ }
781
+ });
782
+ }
783
+ updatePosition() {
784
+ if (this._floatingID == undefined) {
785
+ return;
786
+ }
787
+ core.FloatingManager.updateFloatPosition(this._popover, this._popoverContainer, this.getFloatOptions());
788
+ }
789
+ getFloatOptions() {
790
+ return {
791
+ autoClose: true,
792
+ innerClickTest: this.innerClickCheck,
793
+ backClickListener: () => this.onDetailCloseCallback(),
794
+ left: this.getOffsetLeft(),
795
+ top: this.getOffsetTop(),
796
+ useOverlay: true,
797
+ overlayClassName: 'ez-scrim ez-scrim--light',
798
+ isFixed: true
799
+ };
800
+ }
801
+ getOffsetLeft() {
802
+ const padding = getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");
803
+ const rect = this._filterItemElement.getBoundingClientRect();
804
+ // Width baseado no conteudo do snk-filter-detail. Nesse momento ele retorna 0px pois ainda não foi criado em tela.
805
+ const filterDetailWidth = 430;
806
+ const adjustRightPosition = filterDetailWidth - (document.body.clientWidth - rect.left);
807
+ return `calc(${rect.x}px + ${padding} - ${adjustRightPosition > 0 ? adjustRightPosition : 0}px)`;
808
+ }
809
+ getOffsetTop() {
810
+ const rect = this._filterItemElement.getBoundingClientRect();
811
+ return (rect.y + rect.height) + "px";
812
+ }
813
+ controlScrollPage() {
814
+ window.removeEventListener("scroll", this.updatePosition.bind(this));
815
+ window.addEventListener("scroll", this.updatePosition.bind(this));
816
+ }
817
+ getConfigChanges() {
818
+ var _a;
819
+ const configToBeCleared = this.config;
820
+ if (!!((_a = configToBeCleared.groupedItems) === null || _a === void 0 ? void 0 : _a.length)) {
821
+ configToBeCleared.visible = false;
822
+ configToBeCleared.groupedItems = configToBeCleared.groupedItems.map(item => (Object.assign(Object.assign({}, item), { visible: false })));
823
+ }
824
+ const hasMultiValues = configToBeCleared.type === filterItemType_enum.FilterItemType.MULTI_LIST && Array.isArray(configToBeCleared.value);
825
+ const newValue = hasMultiValues ? configToBeCleared.value.map((valueItem) => (Object.assign(Object.assign({}, valueItem), { check: false }))) : undefined;
826
+ return Object.assign(Object.assign({}, configToBeCleared), { value: newValue });
827
+ }
828
+ /**
829
+ * Oculta os detalhes de um item da lista.
830
+ */
831
+ async hideDetail() {
832
+ if (this.detailIsVisible) {
833
+ if (this._floatingID != undefined) {
834
+ core.FloatingManager.close(this._floatingID);
835
+ }
836
+ }
837
+ }
838
+ onDetailCloseCallback() {
839
+ this._floatingID = undefined;
840
+ this.detailIsVisible = false;
841
+ if (this._closeCallback) {
842
+ this._closeCallback();
843
+ this._closeCallback = undefined;
844
+ }
845
+ }
846
+ //---------------------------------------------
847
+ // Event handlers
848
+ //---------------------------------------------
849
+ clickListener(evt) {
850
+ if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
851
+ if (evt.target === this._rightIconElement && this.canClearFilter()) {
852
+ const configChanged = this.getConfigChanges();
853
+ this.filterChange.emit(configChanged);
854
+ }
855
+ else {
856
+ if (this.detailIsVisible) {
857
+ this.hideDetail();
858
+ }
859
+ else {
860
+ this.showUp(true);
861
+ }
862
+ }
863
+ evt.preventDefault();
864
+ evt.stopImmediatePropagation();
865
+ evt.stopPropagation();
866
+ }
867
+ }
868
+ mouseDownListener(evt) {
869
+ if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
870
+ evt.preventDefault();
871
+ evt.stopImmediatePropagation();
872
+ evt.stopPropagation();
873
+ }
874
+ }
875
+ getLabel(isTooltipLabel = false) {
876
+ var _a, _b;
877
+ const { type, value, label, props, groupedItems = [] } = this.config;
878
+ if (value || groupedItems.length) {
879
+ if (type === filterItemType_enum.FilterItemType.BINARY_SELECT) {
880
+ const [optOne, optTwo] = props.options;
881
+ const tooltip = this.getMessage('snkFilterBar.binarySelectTooltip');
882
+ if (optOne.name === value) {
883
+ return isTooltipLabel ? `${tooltip} ${String(optOne.label).toLowerCase()}` : optOne.label;
884
+ }
885
+ if (optTwo.name === value) {
886
+ return isTooltipLabel ? `${tooltip} ${String(optTwo.label).toLowerCase()}` : optTwo.label;
887
+ }
888
+ }
889
+ if (type === filterItemType_enum.FilterItemType.MULTI_SELECT) {
890
+ const opt = props.options.find(opt => opt.value === value);
891
+ return `${label}: ${opt.label}`;
892
+ }
893
+ if (type === filterItemType_enum.FilterItemType.PERIOD) {
894
+ let { end, start } = value;
895
+ if (typeof end === "string") {
896
+ end = new Date(end);
897
+ end.setMinutes(end.getMinutes() + end.getTimezoneOffset());
898
+ }
899
+ if (typeof start === "string") {
900
+ start = new Date(start);
901
+ start.setMinutes(start.getMinutes() + start.getTimezoneOffset());
902
+ }
903
+ const dateFormater = new Intl.DateTimeFormat("pt-BR");
904
+ if (end && start) {
905
+ const isSameYear = start.getFullYear() === end.getFullYear();
906
+ const formatOptions = Object.assign({ day: '2-digit', month: '2-digit' }, ((!isSameYear || isTooltipLabel) && { year: '2-digit' }));
907
+ const startLabel = core.DateUtils.formatDate(start, formatOptions);
908
+ const endLabel = core.DateUtils.formatDate(end, formatOptions);
909
+ if (isTooltipLabel) {
910
+ return this.getMessage('snkFilterBar.fullPeriodTooltip', { LABEL: label, START_LABEL: startLabel, END_LABEL: endLabel });
911
+ }
912
+ return `${label}: ${startLabel} \u2192 ${endLabel}`;
913
+ }
914
+ else {
915
+ if (start) {
916
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${dateFormater.format(start)}`;
917
+ }
918
+ else if (end) {
919
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${dateFormater.format(end)}`;
920
+ }
921
+ else {
922
+ return label;
923
+ }
924
+ }
925
+ }
926
+ if (type === filterItemType_enum.FilterItemType.SEARCH) {
927
+ return `${label}: ${value.value} - ${value.label}`;
928
+ }
929
+ if (type === filterItemType_enum.FilterItemType.PERSONALIZED) {
930
+ const activeCount = this.calculateActiveCount(groupedItems);
931
+ if (activeCount <= 0)
932
+ return label;
933
+ return `${label}: ${this.getMessage('snkFilterBar.personalizedCount', { activeCount })}`;
934
+ }
935
+ if (type === filterItemType_enum.FilterItemType.MULTI_LIST) {
936
+ const selectedOptions = ((_a = value.elements) !== null && _a !== void 0 ? _a : value).filter(item => item === null || item === void 0 ? void 0 : item.check);
937
+ return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
938
+ }
939
+ if (type === filterItemType_enum.FilterItemType.CHECK_BOX_LIST) {
940
+ const selectedValues = Object.entries(value !== null && value !== void 0 ? value : {})
941
+ .filter(([_, value]) => value === true)
942
+ .map(([key, _]) => key);
943
+ const options = (_b = props.options) !== null && _b !== void 0 ? _b : [];
944
+ const selectedOptions = options.filter(option => selectedValues.includes(option.name));
945
+ return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
946
+ }
947
+ if (type === filterItemType_enum.FilterItemType.NUMBER && props.variation === filterNumberVariation.FilterNumberVariation.INTERVAL) {
948
+ const { start, end } = value;
949
+ if (start && end) {
950
+ return this.getMessage('snkFilterBar.fullIntervalTooltip', { LABEL: label, START_LABEL: start, END_LABEL: end });
951
+ }
952
+ if (start) {
953
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${Number(start)}`;
954
+ }
955
+ if (end) {
956
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${Number(end)}`;
957
+ }
958
+ }
959
+ if (this.config.mask) {
960
+ const _maskFormatter = new core.MaskFormatter(this.config.mask);
961
+ return `${label}: ${_maskFormatter.format(value)}`;
962
+ }
963
+ return `${label}: ${value}`;
964
+ }
965
+ return label;
966
+ }
967
+ getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel) {
968
+ const checkedAmount = selectedOptions.length;
969
+ if (checkedAmount === 0) {
970
+ return `${label}`;
971
+ }
972
+ if (checkedAmount > 1) {
973
+ if (isTooltipLabel) {
974
+ const selectedOptionsDescrptions = selectedOptions.map(item => item.label);
975
+ return `${label}: ${selectedOptionsDescrptions.join(',')}`;
976
+ }
977
+ return `${label}: ${checkedAmount} ${this.getMessage('snkFilterBar.multiListToltip')}`;
978
+ }
979
+ return `${label}: ${selectedOptions[0].label}`;
980
+ }
981
+ calculateActiveCount(groupedItems) {
982
+ return groupedItems.reduce((total, item) => {
983
+ if (!!item.visible)
984
+ return total + 1;
985
+ return total;
986
+ }, 0);
987
+ }
988
+ componentDidLoad() {
989
+ if (this._filterItemElement) {
990
+ core.ElementIDUtils.addIDInfo(this._filterItemElement);
991
+ this._idSnkFilterDetail = `filterDetail_${this.config.id}`;
992
+ }
993
+ this.controlScrollPage();
994
+ }
995
+ componentDidRender() {
996
+ if (this._floatingID == undefined) {
997
+ if (this._popover) {
998
+ this._popover.remove();
999
+ }
1000
+ }
1001
+ }
1002
+ /**
1003
+ * Emitido quando o estado do filtro é alterado.
1004
+ */
1005
+ filterChangeListener() {
1006
+ this.hideDetail();
1007
+ }
1008
+ canClearFilter() {
1009
+ const { value, groupedItems = [] } = this.config;
1010
+ if (value != undefined && this.config.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
1011
+ return value.some((item) => item.check);
1012
+ }
1013
+ return value !== undefined || groupedItems.some(item => item.visible);
1014
+ }
1015
+ getRightIconName() {
1016
+ if (this.canClearFilter())
1017
+ return "close";
1018
+ return this.detailIsVisible ? "chevron-up" : "chevron-down";
1019
+ }
1020
+ getLeftIconName() {
1021
+ switch (this.config.type) {
1022
+ case filterItemType_enum.FilterItemType.PERIOD:
1023
+ return "calendar";
1024
+ case filterItemType_enum.FilterItemType.PERSONALIZED:
1025
+ return "tune";
1026
+ }
1027
+ return undefined;
1028
+ }
1029
+ hasActiveElements(value) {
1030
+ var _a, _b, _c;
1031
+ 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;
1032
+ }
1033
+ hasActiveValue(config) {
1034
+ return (config.type !== filterItemType_enum.FilterItemType.MULTI_LIST && config.value !== undefined) || this.hasActiveElements(config.value);
1035
+ }
1036
+ getEnabledChip() {
1037
+ if (this.config.type === filterItemType_enum.FilterItemType.PERSONALIZED) {
1038
+ const { groupedItems = [] } = this.config;
1039
+ return groupedItems.some(item => item.visible);
1040
+ }
1041
+ return this.hasActiveValue(this.config);
1042
+ }
1043
+ render() {
1044
+ const leftIcon = this.getLeftIconName();
1045
+ 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 }))));
1046
+ }
1047
+ get _filterItemElement() { return index$1.getElement(this); }
1048
+ static get watchers() { return {
1049
+ "detailIsVisible": ["observeDetailIsVisible"]
1050
+ }; }
1051
+ };
1052
+
1053
+ const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
1054
+ const MAX_FILTERS = 5;
1055
+ const SnkFilterList = class {
1056
+ constructor(hostRef) {
1057
+ index$1.registerInstance(this, hostRef);
1058
+ this.snkItemSelected = index$1.createEvent(this, "snkItemSelected", 7);
1059
+ this._preselection = -1;
1060
+ this.innerClickCheck = (_floatingContainer, node) => {
1061
+ if (node.id != core.FloatingManager.MODAL_ELEMENT_ID) {
1062
+ return true;
1063
+ }
1064
+ this._detailIsVisible = false;
1065
+ return false;
1066
+ };
1067
+ this._filterArgument = undefined;
1068
+ this._showAll = undefined;
1069
+ this.label = undefined;
1070
+ this.iconName = undefined;
1071
+ this.items = undefined;
1072
+ this.getMessage = undefined;
1073
+ this.emptyText = undefined;
1074
+ this.findFilterText = undefined;
1075
+ this.buttonClass = undefined;
1076
+ }
1077
+ showDetail() {
1078
+ this._preselection = -1;
1079
+ this._floatingID = core.FloatingManager.float(this._popover, this._popoverContainer, {
1080
+ autoClose: true,
1081
+ innerClickTest: this.innerClickCheck,
1082
+ backClickListener: () => this.onListCloseCallback(),
1083
+ useOverlay: true
1084
+ });
1085
+ this._detailIsVisible = true;
1086
+ this._showAll = false;
1087
+ this._filterArgument = "";
1088
+ this._filterInput.setFocus();
1089
+ }
1090
+ /**
1091
+ * Oculta os detalhes do componente snk-filter-list.
1092
+ */
1093
+ async hideDetail() {
1094
+ if (this._floatingID != undefined) {
1095
+ core.FloatingManager.close(this._floatingID);
1096
+ }
1097
+ }
1098
+ onListCloseCallback() {
1099
+ this._floatingID = undefined;
1100
+ this._detailIsVisible = false;
1101
+ }
1102
+ buttonClick() {
1103
+ if (this._detailIsVisible) {
1104
+ this.hideDetail();
1105
+ }
1106
+ else {
1107
+ this.showDetail();
1108
+ }
1109
+ }
1110
+ componentDidLoad() {
1111
+ if (this._element) {
1112
+ core.ElementIDUtils.addIDInfo(this._element);
1113
+ }
1114
+ }
1115
+ componentDidRender() {
1116
+ if (this._floatingID == undefined) {
1117
+ if (this._popover) {
1118
+ this._popover.remove();
1119
+ }
1120
+ }
1121
+ }
1122
+ buildIdElement(buttonElement, name) {
1123
+ if (!buttonElement)
1124
+ return;
1125
+ const dataElement = { id: name };
1126
+ buttonElement.removeAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
1127
+ core.ElementIDUtils.addIDInfoIfNotExists(buttonElement, "filterItemList", dataElement);
1128
+ }
1129
+ buildItemElement(item) {
1130
+ const itemId = ++this._selectableItemsCount;
1131
+ 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)));
1132
+ }
1133
+ itemSelected(itemName) {
1134
+ if (itemName === SHOW_MORE_ITEM_NAME) {
1135
+ this._showAll = true;
1136
+ }
1137
+ else {
1138
+ this.hideDetail();
1139
+ this.snkItemSelected.emit(itemName);
1140
+ }
1141
+ }
1142
+ getFilterItems() {
1143
+ const items = this.items ? core.ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
1144
+ if (items.length === 0) {
1145
+ 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);
1146
+ }
1147
+ const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
1148
+ if (hideItems) {
1149
+ items.splice(MAX_FILTERS);
1150
+ 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" });
1151
+ }
1152
+ this._selectableItemsCount = 0;
1153
+ return index$1.h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
1154
+ }
1155
+ getFooterItems() {
1156
+ return this.items.filter(item => item.kind === "FOOTER");
1157
+ }
1158
+ keyDownHandler(event) {
1159
+ switch (event.key) {
1160
+ case "ArrowDown":
1161
+ this.changePreselection(this._preselection + 1);
1162
+ //Paramos a propagação do evento para evitar scroll indesejado
1163
+ event.stopImmediatePropagation();
1164
+ event.stopPropagation();
1165
+ event.preventDefault();
1166
+ break;
1167
+ case "ArrowUp":
1168
+ this.changePreselection(this._preselection - 1);
1169
+ //Paramos a propagação do evento para evitar scroll indesejado
1170
+ event.stopImmediatePropagation();
1171
+ event.stopPropagation();
1172
+ event.preventDefault();
1173
+ break;
1174
+ }
1175
+ }
1176
+ changePreselection(newSelection) {
1177
+ if (newSelection < 0) {
1178
+ newSelection = this._selectableItemsCount;
1179
+ }
1180
+ this._preselection = newSelection > this._selectableItemsCount ? 0 : newSelection;
1181
+ if (this._preselection === 0) {
1182
+ this._filterInput.setFocus();
1183
+ }
1184
+ else {
1185
+ const item = this._element.querySelector(`#filter-item${this._preselection}`);
1186
+ if (item) {
1187
+ item.focus();
1188
+ }
1189
+ }
1190
+ }
1191
+ render() {
1192
+ 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))));
1193
+ }
1194
+ get _element() { return index$1.getElement(this); }
1195
+ };
1196
+
1197
+ 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)}";
1198
+
1199
+ const SnkFilterModal = class {
1200
+ constructor(hostRef) {
1201
+ index$1.registerInstance(this, hostRef);
1202
+ this.getMessage = undefined;
1203
+ this.configName = undefined;
1204
+ this.filters = undefined;
1205
+ this.applyFilters = undefined;
1206
+ this.closeModal = undefined;
1207
+ this.addPersonalizedFilter = undefined;
1208
+ this.editPersonalizedFilter = undefined;
1209
+ this.deletePersonalizedFilter = undefined;
1210
+ this.filtersToDelete = [];
1211
+ this.disablePersonalizedFilter = undefined;
1212
+ }
1213
+ /**
1214
+ * Emitido quando um filtro personalizado é deletado.
1215
+ */
1216
+ deletePersonalizedFilterListener(event) {
1217
+ this.filtersToDelete.push(event.detail);
1218
+ }
1219
+ getCustomMessage(key, params) {
1220
+ var _a;
1221
+ return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
1222
+ }
1223
+ //TODO: tratar clear all dos filtros personalizados
1224
+ handleClearAll() {
1225
+ const { customFilters, quickFilters, otherFilters, multiListFilters } = this.filters.reduce((acc, filter) => {
1226
+ if (filter.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
1227
+ acc.multiListFilters.push(filter);
1228
+ return acc;
1229
+ }
1230
+ if (filter.filterType === filterType_enum.FilterType.QUICK_FILTER) {
1231
+ acc.quickFilters.push(filter);
1232
+ return acc;
1233
+ }
1234
+ if (filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER) {
1235
+ acc.customFilters.push(filter);
1236
+ return acc;
1237
+ }
1238
+ if (filter.filterType === filterType_enum.FilterType.OTHER_FILTERS) {
1239
+ acc.otherFilters.push(filter);
1240
+ return acc;
1241
+ }
1242
+ return acc;
1243
+ }, { quickFilters: [], customFilters: [], otherFilters: [], multiListFilters: [] });
1244
+ this.handleClearFilterList(quickFilters);
1245
+ this.handleClearCustomFilters(customFilters);
1246
+ this.handleClearOthersFilters(otherFilters);
1247
+ multiListFilters.forEach(multiListFilter => this.handleClearSigleFilter(multiListFilter));
1248
+ }
1249
+ handleClearOthersFilters(otherFilters) {
1250
+ this.filters = this.filters.map(filter => otherFilters.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
1251
+ }
1252
+ handleClearCustomFilters(customFilters) {
1253
+ this.filters.forEach((filter, index) => {
1254
+ if (filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER)
1255
+ this.filters[index] = this.clearAllCustomFilter(customFilters).shift();
1256
+ });
1257
+ }
1258
+ clearAllCustomFilter(filterConfigSnapshot) {
1259
+ return filterConfigSnapshot.map(filterItem => {
1260
+ const copy = Object.assign({}, filterItem);
1261
+ delete copy.value;
1262
+ copy.visible = false;
1263
+ if (copy.groupedItems) {
1264
+ copy.groupedItems = this.clearAllCustomFilter(copy.groupedItems);
1265
+ }
1266
+ return copy;
1267
+ });
1268
+ }
1269
+ handleClose() {
1270
+ const hasChangesToSave = core.ObjectUtils.objectToString(this.filters) !== core.ObjectUtils.objectToString(this._originalFilterConfig);
1271
+ if (!hasChangesToSave) {
1272
+ this.closeModal();
1273
+ return;
1274
+ }
1275
+ return utils.ApplicationUtils.confirm(this.getCustomMessage('validations.notSaved.title'), this.getCustomMessage('validations.notSaved.message')).then((cancelAction) => {
1276
+ if (cancelAction)
1277
+ this.closeModal();
1278
+ });
1279
+ }
1280
+ handleApplyFilters() {
1281
+ const filterPersonalized = this.filters.find(filter => filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER);
1282
+ if (this.isValidCustomFilter(filterPersonalized)) {
1283
+ this.applyFilters(this.filters);
1284
+ }
1285
+ if (this.filtersToDelete.length > 0) {
1286
+ this.filtersToDelete.forEach(filter => {
1287
+ this.deletePersonalizedFilter(filter, this.configName);
1288
+ });
1289
+ this.filtersToDelete = [];
1290
+ }
1291
+ }
1292
+ isValidCustomFilter(filterPersonalized) {
1293
+ const isValid = PersonalizedFilterUtils.PersonalizedFilterUtils.validateVariableValues(filterPersonalized);
1294
+ if (!isValid) {
1295
+ utils.ApplicationUtils.alert(this.getCustomMessage('validations.notFullFilled.title'), this.getCustomMessage('validations.notFullFilled.message'));
1296
+ return false;
1297
+ }
1298
+ return true;
1299
+ }
1300
+ modalActionListener(evt) {
1301
+ const modalAction = evt.detail;
1302
+ switch (modalAction) {
1303
+ case ezModalContainer.ModalAction.CANCEL:
1304
+ this.handleClearAll();
1305
+ break;
1306
+ case ezModalContainer.ModalAction.OK:
1307
+ this.handleApplyFilters();
1308
+ break;
1309
+ case ezModalContainer.ModalAction.CLOSE:
1310
+ this.handleClose();
1311
+ break;
1312
+ }
1313
+ }
1314
+ handleFilterChange(filterConfig) {
1315
+ this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
1316
+ }
1317
+ handleClearFilterList(filterList) {
1318
+ this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
1319
+ }
1320
+ handleClearSigleFilter(filterItem) {
1321
+ if (filterItemType_enum.FilterItemType.MULTI_LIST === filterItem.type) {
1322
+ let filterItemCopy = core.ObjectUtils.copy(filterItem);
1323
+ this.uncheckFilterValues(filterItemCopy.value);
1324
+ const filterListCopy = core.ObjectUtils.copy(this.filters);
1325
+ const index = filterListCopy.findIndex(item => item.id === filterItem.id);
1326
+ filterListCopy.splice(index, 1, filterItemCopy);
1327
+ this.filters = core.ObjectUtils.copy(filterListCopy);
1328
+ return;
1329
+ }
1330
+ if (filterItemType_enum.FilterItemType.CHECK_BOX_LIST === filterItem.type) {
1331
+ const filterListCopy = core.ObjectUtils.copy(this.filters);
1332
+ filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
1333
+ this.filters = core.ObjectUtils.copy(filterListCopy);
1334
+ return;
1335
+ }
1336
+ const filter = this.filters.find(filter => filter.id === filterItem.id);
1337
+ filter.value = undefined;
1338
+ this.filters = core.ObjectUtils.copy(this.filters);
1339
+ }
1340
+ uncheckFilterValues(valueList) {
1341
+ valueList.forEach(value => {
1342
+ if (!!value) {
1343
+ value.check = false;
1344
+ }
1345
+ });
1346
+ return valueList;
1347
+ }
1348
+ renderFilterItem(filterItem, fullRow) {
1349
+ 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() }));
1350
+ }
1351
+ isDefaultFilterNumberVariation(filter) {
1352
+ var _a;
1353
+ return filter.type === filterItemType_enum.FilterItemType.NUMBER
1354
+ && (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === filterNumberVariation.FilterNumberVariation.DEFAULT);
1355
+ }
1356
+ mountFiltersLines(filters) {
1357
+ const MAX_LINE_LENGTH = 2;
1358
+ let currentLine = 0;
1359
+ let forceAddCurrent = false;
1360
+ const filtersLines = {};
1361
+ for (let curr = 0; curr < filters.length; curr++) {
1362
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
1363
+ const item = filters[curr];
1364
+ const isLast = curr === filters.length - 1;
1365
+ const currentItemMatch = item.type === filterItemType_enum.FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
1366
+ const nextItemMatch = isLast ? false : filters[curr + 1].type === filterItemType_enum.FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
1367
+ if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
1368
+ filtersLines[currentLine].push(item);
1369
+ forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
1370
+ if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
1371
+ ++currentLine;
1372
+ continue;
1373
+ }
1374
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
1375
+ filtersLines[currentLine].push(item);
1376
+ ++currentLine;
1377
+ }
1378
+ return Object.values(filtersLines);
1379
+ }
1380
+ renderFilterLine(filters) {
1381
+ const fullLine = filters.length === 1;
1382
+ return filters.map((filter) => this.renderFilterItem(filter, fullLine));
1383
+ }
1384
+ getIformedFiltersCount(listItems) {
1385
+ let countInformedItens = 0;
1386
+ listItems.forEach(item => {
1387
+ var _a, _b, _c, _d, _e, _f;
1388
+ if (filterItemType_enum.FilterItemType.MULTI_LIST === item.type) {
1389
+ 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;
1390
+ return;
1391
+ }
1392
+ if (filterItemType_enum.FilterItemType.CHECK_BOX_LIST === item.type) {
1393
+ countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
1394
+ .filter(([_, value]) => value === true)
1395
+ .map(([key, _]) => key).length;
1396
+ return;
1397
+ }
1398
+ if (item.groupedItems != undefined) {
1399
+ countInformedItens = item.groupedItems.filter(item => item.visible).length;
1400
+ return;
1401
+ }
1402
+ if (!!item.value) {
1403
+ countInformedItens++;
1404
+ }
1405
+ });
1406
+ return countInformedItens;
1407
+ }
1408
+ renderCollapsibleFilterBox(label, listItems, isSingleItem, shouldRenderFooter = true) {
1409
+ if (!listItems.length)
1410
+ return null;
1411
+ const appliedFilters = this.getIformedFiltersCount(listItems);
1412
+ const lines = this.mountFiltersLines(listItems);
1413
+ 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) })))));
1414
+ }
1415
+ componentWillRender() {
1416
+ this._modalTitle = this.getCustomMessage('title');
1417
+ this._okButtonLabel = this.getCustomMessage('okButtonLabel');
1418
+ this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
1419
+ }
1420
+ componentDidLoad() {
1421
+ if (!this._originalFilterConfig)
1422
+ this._originalFilterConfig = this.filters;
1423
+ }
1424
+ render() {
1425
+ const customFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER);
1426
+ const quickFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.QUICK_FILTER);
1427
+ const otherFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.OTHER_FILTERS);
1428
+ 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)))));
1429
+ }
1430
+ };
1431
+ SnkFilterModal.style = snkFilterModalCss;
1432
+
1433
+ exports.snk_filter_bar = SnkFilterBar;
1434
+ exports.snk_filter_item = SnkFilterItem;
1435
+ exports.snk_filter_list = SnkFilterList;
1436
+ exports.snk_filter_modal = SnkFilterModal;