@sankhyalabs/sankhyablocks 1.4.0-beta.1 → 1.4.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/dist/cjs/{SnkMessageBuilder-7717f1e4.js → SnkMessageBuilder-6c2f7bcd.js} +107 -131
  2. package/dist/cjs/_commonjsHelpers-537d719a.js +20 -0
  3. package/dist/cjs/configurableElementsStorage-93459c72.js +20 -0
  4. package/dist/cjs/constants-9056ca9e.js +84 -0
  5. package/dist/cjs/draggable.bundle-82a25c06.js +6886 -0
  6. package/dist/cjs/{filter-item-type.enum-e2e1bc5b.js → filter-item-type.enum-3daf58d3.js} +2 -0
  7. package/dist/cjs/form-config-fetcher-2de7c16a.js +6895 -0
  8. package/dist/cjs/{index-b0b676c5.js → index-20e8b68a.js} +165 -1473
  9. package/dist/cjs/loader.cjs.js +2 -18
  10. package/dist/cjs/sankhyablocks.cjs.js +4 -116
  11. package/dist/cjs/snk-application.cjs.entry.js +330 -7196
  12. package/dist/cjs/snk-config-modal.cjs.entry.js +62 -0
  13. package/dist/cjs/snk-config-options.cjs.entry.js +230 -0
  14. package/dist/cjs/snk-configurator_6.cjs.entry.js +1156 -0
  15. package/dist/cjs/snk-crud.cjs.entry.js +21 -13
  16. package/dist/cjs/snk-data-unit.cjs.entry.js +24 -32
  17. package/dist/cjs/snk-field-config_2.cjs.entry.js +135 -0
  18. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +5 -2
  19. package/dist/cjs/snk-filter-detail.cjs.entry.js +62 -5
  20. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +6 -3
  21. package/dist/cjs/snk-filter-number.cjs.entry.js +6 -3
  22. package/dist/cjs/snk-filter-period.cjs.entry.js +5 -2
  23. package/dist/cjs/snk-filter-personalized.cjs.entry.js +89 -0
  24. package/dist/cjs/snk-filter-search.cjs.entry.js +7 -13
  25. package/dist/cjs/snk-filter-text.cjs.entry.js +2 -2
  26. package/dist/cjs/snk-form-config.cjs.entry.js +957 -0
  27. package/dist/cjs/snk-form.cjs.entry.js +41 -28
  28. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  29. package/dist/cjs/snk-tab-config.cjs.entry.js +321 -0
  30. package/dist/cjs/{taskbar-elements-283c737e.js → taskbar-elements-9a4b1e19.js} +10 -6
  31. package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
  32. package/dist/collection/collection-manifest.json +29 -1
  33. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +1 -1
  34. package/dist/collection/components/snk-application/snk-application.js +236 -37
  35. package/dist/collection/components/snk-configurator/snk-configurator.js +261 -0
  36. package/dist/collection/components/snk-configurator/subcomponents/configModalProvider/configurableElementsStorage.js +16 -0
  37. package/dist/collection/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.css +122 -0
  38. package/dist/collection/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.js +137 -0
  39. package/dist/collection/components/snk-crud/snk-crud.js +46 -17
  40. package/dist/collection/components/snk-data-unit/snk-data-unit.js +1 -28
  41. package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +100 -0
  42. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +23 -0
  43. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +24 -1
  44. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +24 -1
  45. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +23 -0
  46. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +180 -0
  47. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +22 -38
  48. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +1 -1
  49. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +2 -0
  50. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +80 -20
  51. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +65 -31
  52. package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +85 -19
  53. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +222 -0
  54. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +39 -4
  55. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +250 -141
  56. package/dist/collection/components/snk-form/snk-form.css +4 -0
  57. package/dist/collection/components/snk-form/snk-form.js +108 -30
  58. package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.css +9 -0
  59. package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.js +315 -0
  60. package/dist/collection/components/snk-form/subcomponents/snk-field-config/snk-field-config.css +164 -0
  61. package/dist/collection/components/snk-form/subcomponents/snk-field-config/snk-field-config.js +140 -0
  62. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.css +185 -0
  63. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +1062 -0
  64. package/dist/collection/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.css +272 -0
  65. package/dist/collection/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.js +476 -0
  66. package/dist/collection/components/snk-grid/snk-grid.js +94 -26
  67. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +9 -5
  68. package/dist/collection/components/snk-taskbar/snk-taskbar.js +35 -3
  69. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +3 -3
  70. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +35 -0
  71. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +18 -10
  72. package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +106 -3
  73. package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +15 -15
  74. package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +9 -1
  75. package/dist/collection/lib/index.js +1 -0
  76. package/dist/collection/lib/message/SnkMessageBuilder.js +11 -2
  77. package/dist/collection/lib/message/resources/crud-utils.msg.js +4 -0
  78. package/dist/collection/lib/message/resources/snk-configurator.msg.js +11 -0
  79. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +14 -2
  80. package/dist/collection/lib/message/resources/snk-form.msg.js +59 -2
  81. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +1 -1
  82. package/dist/collection/lib/utils/CrudUtils.js +73 -0
  83. package/dist/collection/lib/utils/constants.js +72 -0
  84. package/dist/components/SnkMessageBuilder.js +108 -131
  85. package/dist/components/_commonjsHelpers.js +17 -0
  86. package/dist/components/constants.js +74 -0
  87. package/dist/components/filter-item-type.enum.js +2 -0
  88. package/dist/{sankhyablocks/snk-application.entry.js → components/form-config-fetcher.js} +88 -1347
  89. package/dist/components/index.d.ts +8 -0
  90. package/dist/components/index.js +8 -4
  91. package/dist/components/snk-application2.js +313 -7173
  92. package/dist/components/snk-config-modal.d.ts +11 -0
  93. package/dist/components/snk-config-modal.js +6 -0
  94. package/dist/components/snk-config-modal2.js +91 -0
  95. package/dist/components/snk-config-options.d.ts +11 -0
  96. package/dist/components/snk-config-options.js +6 -0
  97. package/dist/components/snk-config-options2.js +245 -0
  98. package/dist/components/snk-configurator.d.ts +11 -0
  99. package/dist/components/snk-configurator.js +6 -0
  100. package/dist/components/snk-configurator2.js +212 -0
  101. package/dist/components/snk-crud.js +76 -26
  102. package/dist/components/snk-data-unit.js +4 -13
  103. package/dist/components/snk-field-config.d.ts +11 -0
  104. package/dist/components/snk-field-config.js +6 -0
  105. package/dist/components/snk-field-config2.js +70 -0
  106. package/dist/components/snk-filter-bar2.js +354 -148
  107. package/dist/components/snk-filter-binary-select.js +5 -1
  108. package/dist/components/snk-filter-detail2.js +62 -5
  109. package/dist/components/snk-filter-item2.js +52 -33
  110. package/dist/components/snk-filter-list2.js +60 -22
  111. package/dist/components/snk-filter-modal.d.ts +11 -0
  112. package/dist/components/snk-filter-modal.js +6 -0
  113. package/dist/components/snk-filter-modal2.js +84 -0
  114. package/dist/components/snk-filter-multi-select.js +6 -2
  115. package/dist/components/snk-filter-number.js +6 -2
  116. package/dist/components/snk-filter-period.js +5 -1
  117. package/dist/components/snk-filter-personalized.d.ts +11 -0
  118. package/dist/components/snk-filter-personalized.js +108 -0
  119. package/dist/components/snk-filter-search.js +5 -12
  120. package/dist/components/snk-filter-text.js +1 -1
  121. package/dist/components/snk-form-config.d.ts +11 -0
  122. package/dist/components/snk-form-config.js +6 -0
  123. package/dist/components/snk-form-config2.js +996 -0
  124. package/dist/components/snk-form2.js +79 -29
  125. package/dist/components/snk-grid2.js +57 -32
  126. package/dist/components/snk-pesquisa2.js +1 -1
  127. package/dist/components/snk-tab-config.d.ts +11 -0
  128. package/dist/components/snk-tab-config.js +6 -0
  129. package/dist/components/snk-tab-config2.js +7220 -0
  130. package/dist/components/snk-taskbar2.js +28 -10
  131. package/dist/components/teste-pesquisa.js +1 -1
  132. package/dist/{sankhyablocks/SnkMessageBuilder-a7da466b.js → esm/SnkMessageBuilder-5792c260.js} +108 -131
  133. package/dist/esm/_commonjsHelpers-9943807e.js +17 -0
  134. package/dist/esm/configurableElementsStorage-cdc144b5.js +18 -0
  135. package/dist/esm/constants-c6039d3d.js +74 -0
  136. package/dist/esm/draggable.bundle-41d56f06.js +6884 -0
  137. package/dist/esm/{filter-item-type.enum-61fbf80a.js → filter-item-type.enum-a79b2fa8.js} +2 -0
  138. package/dist/esm/form-config-fetcher-96c6c2dc.js +6889 -0
  139. package/dist/{sankhyablocks/index-2b4d2d14.js → esm/index-e4121713.js} +165 -1466
  140. package/dist/esm/loader.js +2 -18
  141. package/dist/esm/sankhyablocks.js +4 -116
  142. package/dist/esm/snk-application.entry.js +308 -7174
  143. package/dist/esm/snk-config-modal.entry.js +58 -0
  144. package/dist/esm/snk-config-options.entry.js +226 -0
  145. package/dist/esm/snk-configurator_6.entry.js +1147 -0
  146. package/dist/esm/snk-crud.entry.js +20 -12
  147. package/dist/esm/snk-data-unit.entry.js +5 -13
  148. package/dist/esm/snk-field-config_2.entry.js +130 -0
  149. package/dist/esm/snk-filter-binary-select.entry.js +5 -2
  150. package/dist/esm/snk-filter-detail.entry.js +62 -5
  151. package/dist/esm/snk-filter-multi-select.entry.js +6 -3
  152. package/dist/esm/snk-filter-number.entry.js +6 -3
  153. package/dist/esm/snk-filter-period.entry.js +5 -2
  154. package/dist/esm/snk-filter-personalized.entry.js +85 -0
  155. package/dist/esm/snk-filter-search.entry.js +6 -12
  156. package/dist/esm/snk-filter-text.entry.js +2 -2
  157. package/dist/esm/snk-form-config.entry.js +953 -0
  158. package/dist/esm/snk-form.entry.js +40 -27
  159. package/dist/esm/snk-pesquisa.entry.js +2 -2
  160. package/dist/esm/snk-tab-config.entry.js +317 -0
  161. package/dist/{sankhyablocks/taskbar-elements-35d64ff9.js → esm/taskbar-elements-e2ed0536.js} +10 -6
  162. package/dist/esm/teste-pesquisa.entry.js +2 -2
  163. package/dist/sankhyablocks/index.esm.js +0 -1
  164. package/dist/sankhyablocks/p-029ae4e4.entry.js +1 -0
  165. package/dist/sankhyablocks/p-03f9c407.js +1 -0
  166. package/dist/sankhyablocks/p-112455b1.js +1 -0
  167. package/dist/sankhyablocks/p-12ad2a19.entry.js +1 -0
  168. package/dist/sankhyablocks/p-1feabfc7.entry.js +1 -0
  169. package/dist/sankhyablocks/p-21c8929b.js +1 -0
  170. package/dist/sankhyablocks/p-2284c850.entry.js +1 -0
  171. package/dist/sankhyablocks/p-2b891c4a.entry.js +1 -0
  172. package/dist/sankhyablocks/p-2dc76d79.entry.js +1 -0
  173. package/dist/sankhyablocks/p-361299e8.js +26 -0
  174. package/dist/sankhyablocks/p-3a276f3d.entry.js +1 -0
  175. package/dist/sankhyablocks/p-400cc777.entry.js +1 -0
  176. package/dist/sankhyablocks/p-44ce5b90.entry.js +1 -0
  177. package/dist/sankhyablocks/p-521c96f0.entry.js +1 -0
  178. package/dist/sankhyablocks/p-6988f4a6.entry.js +1 -0
  179. package/dist/sankhyablocks/p-776ff4d1.entry.js +1 -0
  180. package/dist/sankhyablocks/p-7b4a4a50.entry.js +1 -0
  181. package/dist/sankhyablocks/p-9ba3df4c.js +2 -0
  182. package/dist/sankhyablocks/p-9dc4426d.entry.js +1 -0
  183. package/dist/sankhyablocks/p-9dd2b8cb.js +1 -0
  184. package/dist/sankhyablocks/p-a17a4fca.entry.js +1 -0
  185. package/dist/sankhyablocks/p-a5b26df2.js +1 -0
  186. package/dist/sankhyablocks/p-b6d6b172.js +1 -0
  187. package/dist/sankhyablocks/p-cc4bef9f.entry.js +1 -0
  188. package/dist/sankhyablocks/p-d50651a3.js +1 -0
  189. package/dist/sankhyablocks/p-d690b6b5.entry.js +75 -0
  190. package/dist/sankhyablocks/p-d9fbb26f.js +1 -0
  191. package/dist/sankhyablocks/p-deb1f523.entry.js +1 -0
  192. package/dist/sankhyablocks/p-e871aa92.entry.js +1 -0
  193. package/dist/sankhyablocks/p-e9beab79.entry.js +1 -0
  194. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -129
  195. package/dist/types/components/snk-application/snk-application.d.ts +38 -16
  196. package/dist/types/components/snk-configurator/snk-configurator.d.ts +46 -0
  197. package/dist/types/components/snk-configurator/subcomponents/configModalProvider/configurableElementsStorage.d.ts +8 -0
  198. package/dist/types/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.d.ts +38 -0
  199. package/dist/types/components/snk-crud/snk-crud.d.ts +50 -0
  200. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +92 -0
  201. package/dist/types/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.d.ts +4 -0
  202. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +1 -0
  203. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +2 -0
  204. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +2 -0
  205. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +1 -0
  206. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +24 -0
  207. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +4 -5
  208. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +1 -0
  209. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +3 -1
  210. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +7 -1
  211. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +40 -0
  212. package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +8 -3
  213. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +26 -0
  214. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +31 -17
  215. package/dist/types/components/snk-form/snk-form.d.ts +71 -0
  216. package/dist/types/components/snk-form/subcomponents/snk-config-options/snk-config-options.d.ts +51 -0
  217. package/dist/types/components/snk-form/subcomponents/snk-field-config/snk-field-config.d.ts +32 -0
  218. package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +139 -0
  219. package/dist/types/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.d.ts +97 -0
  220. package/dist/types/components/snk-grid/snk-grid.d.ts +59 -0
  221. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +6 -5
  222. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -3
  223. package/dist/types/components.d.ts +424 -24
  224. package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +1 -0
  225. package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +21 -3
  226. package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +7 -7
  227. package/dist/types/lib/http/data-fetcher/fetchers/resource-fetcher.d.ts +1 -0
  228. package/dist/types/lib/index.d.ts +1 -0
  229. package/dist/types/lib/message/resources/crud-utils.msg.d.ts +2 -0
  230. package/dist/types/lib/message/resources/snk-configurator.msg.d.ts +2 -0
  231. package/dist/types/lib/message/resources/snk-form.msg.d.ts +5 -2
  232. package/dist/types/lib/utils/CrudUtils.d.ts +6 -0
  233. package/dist/types/lib/utils/constants.d.ts +76 -0
  234. package/dist/types/lib/utils/pesquisa.d.ts +2 -1
  235. package/package.json +4 -3
  236. package/react/components.d.ts +25 -0
  237. package/react/components.js +25 -0
  238. package/react/components.js.map +1 -1
  239. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  240. package/dist/cjs/css-shim-b8158822.js +0 -6
  241. package/dist/cjs/dom-36862b77.js +0 -75
  242. package/dist/cjs/index-02201bc9.js +0 -2397
  243. package/dist/cjs/shadow-css-346c0795.js +0 -389
  244. package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -278
  245. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -154
  246. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -91
  247. package/dist/cjs/snk-grid.cjs.entry.js +0 -79
  248. package/dist/cjs/snk-taskbar.cjs.entry.js +0 -160
  249. package/dist/components/index2.js +0 -2384
  250. package/dist/esm/SnkMessageBuilder-a7da466b.js +0 -303
  251. package/dist/esm/app-globals-0f993ce5.js +0 -3
  252. package/dist/esm/css-shim-b3f2ee8d.js +0 -4
  253. package/dist/esm/dom-665d6011.js +0 -73
  254. package/dist/esm/index-2b4d2d14.js +0 -3262
  255. package/dist/esm/index-f1d3e4da.js +0 -2384
  256. package/dist/esm/shadow-css-b18e99d7.js +0 -387
  257. package/dist/esm/snk-filter-bar.entry.js +0 -274
  258. package/dist/esm/snk-filter-item.entry.js +0 -150
  259. package/dist/esm/snk-filter-list.entry.js +0 -87
  260. package/dist/esm/snk-grid.entry.js +0 -75
  261. package/dist/esm/snk-taskbar.entry.js +0 -156
  262. package/dist/esm/taskbar-elements-35d64ff9.js +0 -90
  263. package/dist/sankhyablocks/app-globals-0f993ce5.js +0 -3
  264. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +0 -4
  265. package/dist/sankhyablocks/dom-665d6011.js +0 -73
  266. package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +0 -12
  267. package/dist/sankhyablocks/index-f1d3e4da.js +0 -2384
  268. package/dist/sankhyablocks/shadow-css-b18e99d7.js +0 -387
  269. package/dist/sankhyablocks/snk-crud.entry.js +0 -66
  270. package/dist/sankhyablocks/snk-data-unit.entry.js +0 -276
  271. package/dist/sankhyablocks/snk-filter-bar.entry.js +0 -274
  272. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +0 -43
  273. package/dist/sankhyablocks/snk-filter-detail.entry.js +0 -45
  274. package/dist/sankhyablocks/snk-filter-item.entry.js +0 -150
  275. package/dist/sankhyablocks/snk-filter-list.entry.js +0 -87
  276. package/dist/sankhyablocks/snk-filter-multi-select.entry.js +0 -19
  277. package/dist/sankhyablocks/snk-filter-number.entry.js +0 -20
  278. package/dist/sankhyablocks/snk-filter-period.entry.js +0 -33
  279. package/dist/sankhyablocks/snk-filter-search.entry.js +0 -40
  280. package/dist/sankhyablocks/snk-filter-text.entry.js +0 -18
  281. package/dist/sankhyablocks/snk-form.entry.js +0 -129
  282. package/dist/sankhyablocks/snk-grid.entry.js +0 -75
  283. package/dist/sankhyablocks/snk-pesquisa.entry.js +0 -311
  284. package/dist/sankhyablocks/snk-taskbar.entry.js +0 -156
  285. package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +0 -45
  286. package/dist/sankhyablocks/teste-pesquisa.entry.js +0 -33
@@ -0,0 +1,1147 @@
1
+ import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-e4121713.js';
2
+ import { ObjectUtils, ApplicationContext, DataType, StringUtils, ErrorException, FloatingManager, ArrayUtils } from '@sankhyalabs/core';
3
+ import { ApplicationUtils, CheckMode } from '@sankhyalabs/ezui/dist/collection/utils';
4
+ import { C as CONFIG_EVENTS, c as VIEW_MODE } from './constants-c6039d3d.js';
5
+ import { C as ConfigurableElementsStorage } from './configurableElementsStorage-cdc144b5.js';
6
+ import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
7
+ import { ModalAction, ModalButtonStatus } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
8
+ import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
9
+ import { T as TaskbarElement, V as VisibleWhenForbidden, A as AuthorizationElements, b as buildElem, a as buildCustomButton } from './taskbar-elements-e2ed0536.js';
10
+
11
+ const GRID_MODE = VIEW_MODE.grid;
12
+ const FORM_MODE = VIEW_MODE.form;
13
+ const SnkConfigurator = class {
14
+ constructor(hostRef) {
15
+ registerInstance(this, hostRef);
16
+ this.changeViewMode = createEvent(this, "changeViewMode", 7);
17
+ /**
18
+ * Nome do componente que será vinculado ao `data-configurator-parent` para controlar o modal de configurações.
19
+ */
20
+ this.name = "snkConfigurator";
21
+ /**
22
+ * Define se o campo está habilitado.
23
+ */
24
+ this.enabled = true;
25
+ }
26
+ /**
27
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
28
+ * através de um pequeno modulo na estrutura da aplicação:
29
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
30
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-configurator.msg.ts"
31
+ */
32
+ getMessage(key) {
33
+ return this._application.messagesBuilder.getMessage(key, {});
34
+ }
35
+ controlConfigModal(opened) {
36
+ var _a;
37
+ if (this._modal != undefined) {
38
+ this._modal.opened = opened;
39
+ if (this._configModal != undefined) {
40
+ this._configModal.gridMode = ((_a = this._grid) === null || _a === void 0 ? void 0 : _a.offsetParent) != undefined;
41
+ }
42
+ }
43
+ }
44
+ changeConfigModal(evt) {
45
+ const data = evt === null || evt === void 0 ? void 0 : evt.detail;
46
+ if (data === null || data === void 0 ? void 0 : data.openConfig) {
47
+ this.controlConfigModal(false);
48
+ this.callShowConfig(data === null || data === void 0 ? void 0 : data.viewMode);
49
+ }
50
+ else if ((data === null || data === void 0 ? void 0 : data.viewMode) === GRID_MODE.index) {
51
+ this.changeViewMode.emit(GRID_MODE.name);
52
+ }
53
+ else if ((data === null || data === void 0 ? void 0 : data.viewMode) === FORM_MODE.index) {
54
+ this.changeViewMode.emit(FORM_MODE.name);
55
+ }
56
+ }
57
+ callShowConfig(viewMode) {
58
+ if (viewMode === GRID_MODE.index) {
59
+ if (this._grid == undefined) {
60
+ this.findGrid();
61
+ }
62
+ if (this._grid != undefined) {
63
+ this._grid.setShowGridConfig(true);
64
+ }
65
+ }
66
+ else if (viewMode === FORM_MODE.index) {
67
+ if (this._form == undefined) {
68
+ this.findForm();
69
+ }
70
+ if (this._form != undefined) {
71
+ this._form.setShowFormConfig(true);
72
+ }
73
+ }
74
+ }
75
+ getConfigModal() {
76
+ const modalContainer = document.createElement("ez-modal");
77
+ modalContainer.modalSize = "small";
78
+ modalContainer.opened = false;
79
+ modalContainer.closeEsc = false;
80
+ modalContainer.closeOutsideClick = false;
81
+ modalContainer.dataset.configuratorModal = this.name;
82
+ modalContainer.addEventListener(CONFIG_EVENTS.closeModal, () => {
83
+ this.controlConfigModal(false);
84
+ });
85
+ const modalContent = document.createElement("snk-config-modal");
86
+ modalContent.addEventListener(CONFIG_EVENTS.cancelConfig, () => {
87
+ this.controlConfigModal(false);
88
+ });
89
+ modalContent.addEventListener(CONFIG_EVENTS.changeConfig, (evt) => {
90
+ this.changeConfigModal(evt);
91
+ });
92
+ modalContent.configName = this.configName;
93
+ modalContainer.append(modalContent);
94
+ return modalContainer;
95
+ }
96
+ findConfigModal() {
97
+ let modalContainer = document.body.querySelector(`[data-configurator-modal="${this.name}"]`);
98
+ if (modalContainer == undefined) {
99
+ modalContainer = this.getConfigModal();
100
+ document.body.appendChild(modalContainer);
101
+ }
102
+ this._modal = modalContainer;
103
+ this._configModal = modalContainer.querySelector("snk-config-modal");
104
+ }
105
+ findGrid() {
106
+ if (this._grid != undefined) {
107
+ return;
108
+ }
109
+ this._grid = ConfigurableElementsStorage.getGrid(this.configName);
110
+ if (this._grid != undefined && this._grid.dataset.eventConfigChanged == undefined) {
111
+ this._grid.dataset.eventConfigChanged = "true";
112
+ this._grid.addEventListener(CONFIG_EVENTS.configChanged, (evt) => {
113
+ this.saveConfig(evt);
114
+ });
115
+ }
116
+ }
117
+ findForm() {
118
+ if (this._form != undefined) {
119
+ return;
120
+ }
121
+ this._form = ConfigurableElementsStorage.getForm(this.configName);
122
+ if (this._form != undefined && this._form.dataset.eventConfigChanged == undefined) {
123
+ this._form.dataset.eventConfigChanged = "true";
124
+ this._form.addEventListener(CONFIG_EVENTS.configChanged, (evt) => {
125
+ this.saveConfig(evt);
126
+ });
127
+ }
128
+ }
129
+ saveConfig(evt) {
130
+ const config = evt === null || evt === void 0 ? void 0 : evt.detail;
131
+ if (this._application != undefined && config != undefined) {
132
+ if ((config === null || config === void 0 ? void 0 : config.fields) != undefined) {
133
+ this._application.saveFormConfig(config, this.configName)
134
+ .then((response) => {
135
+ if ((response === null || response === void 0 ? void 0 : response.resource) != undefined) {
136
+ this.loadFormConfig(true);
137
+ }
138
+ });
139
+ }
140
+ else if ((config === null || config === void 0 ? void 0 : config.columns) != undefined) {
141
+ this._application.saveGridConfig(config)
142
+ .then((response) => {
143
+ if ((response === null || response === void 0 ? void 0 : response.resource) != undefined) {
144
+ this.setGridConfig(response.resource);
145
+ }
146
+ });
147
+ }
148
+ }
149
+ }
150
+ setGridConfig(strConfig) {
151
+ if (this._grid != undefined) {
152
+ const config = ObjectUtils.stringToObject(strConfig);
153
+ this._grid.setConfig(config).then(() => {
154
+ ApplicationUtils.info(this.getMessage("snkConfigurator.msgSaveSuccessfully"), { iconName: "check" });
155
+ });
156
+ }
157
+ }
158
+ loadGridConfig() {
159
+ if (this._application != undefined && this.configName != undefined && this._grid != undefined) {
160
+ this._application.loadGridConfig(this.configName).then((config) => {
161
+ this._grid.setConfig(config);
162
+ });
163
+ }
164
+ }
165
+ loadFormConfig(showInfoSuccess = false) {
166
+ if (this._application != undefined && this.configName != undefined && this._form != undefined) {
167
+ this._application.loadFormConfig(this.configName).then((config) => {
168
+ this._form.setConfig(config).then(() => {
169
+ if (showInfoSuccess) {
170
+ ApplicationUtils.info(this.getMessage("snkConfigurator.msgSaveSuccessfully"), { iconName: "check" });
171
+ }
172
+ });
173
+ });
174
+ }
175
+ }
176
+ loadConfig() {
177
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
178
+ this.loadGridConfig();
179
+ this.loadFormConfig();
180
+ }
181
+ componentDidLoad() {
182
+ this.findConfigModal();
183
+ this.findGrid();
184
+ this.findForm();
185
+ this.loadConfig();
186
+ }
187
+ render() {
188
+ return (h("ez-button", { mode: "icon", iconName: "settings-inverted", size: "small", enabled: this.enabled, onClick: () => this.controlConfigModal(true) }));
189
+ }
190
+ get _element() { return getElement(this); }
191
+ };
192
+
193
+ const buildFilter = (item) => {
194
+ switch (item.type) {
195
+ case FilterItemType.DEFAULT_FILTER:
196
+ return buildDefault(item);
197
+ case FilterItemType.BINARY_SELECT:
198
+ return buildBinary(item);
199
+ case FilterItemType.MULTI_SELECT:
200
+ return buildMultSelect(item);
201
+ case FilterItemType.PERIOD:
202
+ return buildPeriod(item);
203
+ case FilterItemType.SEARCH:
204
+ return buildSearch(item);
205
+ case FilterItemType.TEXT:
206
+ return buildText(item);
207
+ case FilterItemType.NUMBER:
208
+ return buildNumber(item);
209
+ case FilterItemType.PERSONALIZED:
210
+ return buildPersonalized(item);
211
+ default:
212
+ return undefined;
213
+ }
214
+ };
215
+ function buildDefault(item) {
216
+ return { name: item.id, expression: item.props.expression, params: [] };
217
+ }
218
+ function buildBinary(item) {
219
+ const { id, value, props } = item;
220
+ const options = props.options;
221
+ const selectedOption = options.find(opt => opt.name === value);
222
+ return { name: id, expression: selectedOption.expression, params: [] };
223
+ }
224
+ function buildMultSelect(item) {
225
+ const { id, value, props } = item;
226
+ return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
227
+ }
228
+ function buildPeriod(item) {
229
+ const { id, value, props } = item;
230
+ let { end, start } = value;
231
+ if (typeof end === "string") {
232
+ end = new Date(end);
233
+ }
234
+ if (typeof start === "string") {
235
+ start = new Date(start);
236
+ }
237
+ const params = [];
238
+ let expression;
239
+ if (end && start) {
240
+ expression = props.expression.fullfill;
241
+ params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
242
+ }
243
+ else {
244
+ if (start) {
245
+ expression = props.expression.onlystart;
246
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
247
+ }
248
+ else {
249
+ expression = props.expression.onlyend;
250
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
251
+ }
252
+ }
253
+ return { name: id, expression, params };
254
+ }
255
+ function buildSearch(item) {
256
+ const { id, value, props } = item;
257
+ const expression = props.expression;
258
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
259
+ }
260
+ function buildText(item) {
261
+ const { id, value, props } = item;
262
+ const expression = props.expression;
263
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
264
+ }
265
+ function buildNumber(item) {
266
+ const { id, value, props } = item;
267
+ const expression = props.expression;
268
+ return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
269
+ }
270
+ function buildPersonalized(item) {
271
+ var _a;
272
+ const { id, value, props } = item;
273
+ const expression = props.expression;
274
+ return {
275
+ name: id, expression, params: (((_a = props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
276
+ const valuesArray = Array.from(value);
277
+ const dataType = param.dataType;
278
+ let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
279
+ if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
280
+ paramValue = paramValue["value"];
281
+ }
282
+ if (paramValue == undefined && dataType === DataType.BOOLEAN) {
283
+ paramValue = false;
284
+ }
285
+ return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : toString(dataType, paramValue) };
286
+ })
287
+ };
288
+ }
289
+
290
+ const snkFilterBarCss = ".sc-snk-filter-bar-h{display:grid;grid-template-columns:minmax(100px, 100%) 1fr 1fr}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;z-index:var(--more-visible, 2);background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;background-color:transparent;border:none;padding:3px;outline-color:var(--color--primary)}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.snk-filter-bar__filter-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:100%;height:100%}";
291
+
292
+ const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
293
+ const DEFAULT_FILTER = "DEFAULT_FILTER";
294
+ const CLEAR_ALL_FILTERS = "CLEAR_ALL_FILTERS";
295
+ const ADD_FILTER = "ADD_FILTER";
296
+ const APPLIED_FILTERS = "APPLIED_FILTERS";
297
+ const SnkFilterBar = class {
298
+ constructor(hostRef) {
299
+ registerInstance(this, hostRef);
300
+ this._updateSequence = [];
301
+ this._loadingPending = false;
302
+ this._configUpdated = false;
303
+ this._pendingFilters = [];
304
+ this._calculateSortIndex = (item) => {
305
+ let index = item.hardFixed ? 1000000 : 0;
306
+ //campos Hard Fixed não variam a ordem
307
+ if (!item.hardFixed) {
308
+ index += item.fixed ? 100000 : 0;
309
+ index += item.value == undefined ? 0 : 10000;
310
+ index += this._updateSequence.lastIndexOf(item.id) + 1;
311
+ }
312
+ return index;
313
+ };
314
+ this._filtersComparator = (a, b) => {
315
+ return this._calculateSortIndex(b) - this._calculateSortIndex(a);
316
+ };
317
+ }
318
+ observeFilterConfig(newValue, oldValue) {
319
+ if (oldValue != undefined && newValue == undefined) {
320
+ this._loadingPending = true;
321
+ this._configUpdated = true;
322
+ }
323
+ else {
324
+ const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
325
+ newValue.forEach(newItem => {
326
+ const oldItem = oldItems.get(newItem.id);
327
+ if (oldItem != undefined) {
328
+ this._configUpdated = this._configUpdated || ObjectUtils.objectToString(oldItem) != ObjectUtils.objectToString(newItem);
329
+ this._loadingPending = this._loadingPending || ObjectUtils.objectToString(oldItem.value) !== ObjectUtils.objectToString(newItem.value);
330
+ }
331
+ else {
332
+ this._configUpdated = true;
333
+ this._loadingPending = this._loadingPending || newItem.value != undefined;
334
+ }
335
+ });
336
+ }
337
+ this.processAfterUpdateConfig();
338
+ }
339
+ processPendingFilter() {
340
+ if (this._pendingFilters.length > 0 && this._currentPendingFilter == undefined) {
341
+ this._currentPendingFilter = this._element.querySelector("#filter-" + this._pendingFilters.pop());
342
+ if (this._currentPendingFilter) {
343
+ this._currentPendingFilter.showUp(true).then(() => {
344
+ this._currentPendingFilter = undefined;
345
+ this.processPendingFilter();
346
+ });
347
+ }
348
+ }
349
+ if (this._currentPendingFilter == undefined) {
350
+ this.processAfterUpdateConfig();
351
+ }
352
+ }
353
+ processAfterUpdateConfig() {
354
+ if (this._pendingFilters.length > 0) {
355
+ return;
356
+ }
357
+ if (this._loadingPending) {
358
+ this._loadingPending = false;
359
+ this.dataUnit.loadData();
360
+ }
361
+ if (this._configUpdated) {
362
+ this._configUpdated = false;
363
+ this._application.saveFilterBarConfig(this.filterConfig, this.configName);
364
+ }
365
+ }
366
+ /**
367
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
368
+ * através de um pequeno modulo na estrutura da aplicação:
369
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
370
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
371
+ */
372
+ getMessage(key, params) {
373
+ return this._application.messagesBuilder.getMessage(key, params);
374
+ }
375
+ getFilter(_dataUnit) {
376
+ var _a;
377
+ const filters = [];
378
+ (_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
379
+ const filter = buildFilter(item);
380
+ if (filter) {
381
+ filters.push(filter);
382
+ }
383
+ });
384
+ return filters;
385
+ }
386
+ isActiveFilter(item) {
387
+ return (item.visible && item.value != undefined) || item.type === FilterItemType.DEFAULT_FILTER;
388
+ }
389
+ registryFilterProvider() {
390
+ this.dataUnit.addFilterProvider(this);
391
+ if (this.filterConfig) {
392
+ this.dataUnit.loadData();
393
+ }
394
+ }
395
+ itemFocused(selectedItem) {
396
+ this._element.querySelectorAll("snk-filter-item,snk-filter-list").forEach(item => {
397
+ if (item.id === selectedItem) {
398
+ if (item.tagName.toLowerCase() === "snk-filter-item" && item.getClientRects()[0].x < 0) {
399
+ item.scrollIntoView({ behavior: "auto", inline: 'nearest' });
400
+ }
401
+ }
402
+ else {
403
+ item["hideDetail"]();
404
+ }
405
+ });
406
+ }
407
+ getFilterItems() {
408
+ const pinnedItems = [];
409
+ const unpinnedItems = [];
410
+ this.filterConfig
411
+ .filter(item => item.visible)
412
+ .forEach((item, index) => {
413
+ const itemId = `filter-${item.id}`;
414
+ const filterItem = (h("snk-filter-item", { 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 }));
415
+ if (item.fixed || item.hardFixed) {
416
+ pinnedItems.push(filterItem);
417
+ }
418
+ else {
419
+ unpinnedItems.push(filterItem);
420
+ }
421
+ return filterItem;
422
+ });
423
+ const elements = [];
424
+ elements.push(...pinnedItems);
425
+ if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
426
+ elements.push(h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
427
+ }
428
+ elements.push(...unpinnedItems);
429
+ return elements;
430
+ }
431
+ calculateUpdateSequence(item) {
432
+ if (item) {
433
+ this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
434
+ this._updateSequence.push(item.id);
435
+ }
436
+ }
437
+ normalizeItem(item) {
438
+ const normalized = Object.assign({}, item);
439
+ const optionals = ["props", "value", "hardFixed", "fixed"];
440
+ optionals.forEach(prop => {
441
+ if (normalized[prop] == undefined) {
442
+ delete normalized[prop];
443
+ }
444
+ });
445
+ if (item.value === "") {
446
+ delete item.value;
447
+ }
448
+ return normalized;
449
+ }
450
+ updateFilter(newItem) {
451
+ this.filterConfig = this.filterConfig.map(item => {
452
+ newItem = this.normalizeItem(newItem);
453
+ if (item.id === newItem.id) {
454
+ if (ObjectUtils.objectToString(item) != ObjectUtils.objectToString(newItem)) {
455
+ this.calculateUpdateSequence(newItem);
456
+ }
457
+ return newItem;
458
+ }
459
+ return item;
460
+ }).sort((a, b) => this._filtersComparator(a, b));
461
+ }
462
+ getAddListItems() {
463
+ const hiddenItems = this.filterConfig
464
+ .filter(item => !item.visible && this.isListable(item));
465
+ const footerItems = [{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" }];
466
+ if (this.allowDefault) {
467
+ footerItems.push({ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" });
468
+ }
469
+ return hiddenItems.map(filter => { return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null }; })
470
+ .concat(footerItems);
471
+ }
472
+ getActiveClass() {
473
+ const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
474
+ return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
475
+ }
476
+ isListable(item, allowPersonalized = false) {
477
+ return item.type !== FilterItemType.DEFAULT_FILTER && (allowPersonalized || item.type !== FilterItemType.PERSONALIZED);
478
+ }
479
+ getAppliedListItems() {
480
+ const appliedItems = this.filterConfig
481
+ .filter(item => this.isActiveFilter(item) && this.isListable(item, true));
482
+ return appliedItems.map(filter => {
483
+ return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
484
+ }).concat([
485
+ { name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
486
+ ]);
487
+ }
488
+ addPersonalizedFilters(personalizedItems) {
489
+ const activeFilters = {};
490
+ personalizedItems.forEach(item => {
491
+ if (item.active) {
492
+ activeFilters[item.id] = true;
493
+ }
494
+ });
495
+ this.filterConfig = this.filterConfig.map(item => {
496
+ var _a, _b;
497
+ if (item.type === FilterItemType.PERSONALIZED) {
498
+ const visible = activeFilters[item.id];
499
+ if (!item.visible && visible) {
500
+ this.calculateUpdateSequence(item);
501
+ if (((_b = (_a = item.props) === null || _a === void 0 ? void 0 : _a.personalizedFilter) === null || _b === void 0 ? void 0 : _b.parameters) != undefined) {
502
+ this._pendingFilters.push(item.id);
503
+ }
504
+ }
505
+ return this.normalizeItem(visible ? Object.assign(Object.assign({}, item), { visible }) : Object.assign(Object.assign({}, item), { visible, value: undefined, fixed: undefined }));
506
+ }
507
+ return item;
508
+ }).sort((a, b) => this._filtersComparator(a, b));
509
+ }
510
+ openDefaultFilterModal() {
511
+ const filterModal = document.createElement("snk-filter-modal");
512
+ const defaultFilter = this.filterConfig.filter(item => item.type === FilterItemType.DEFAULT_FILTER);
513
+ filterModal.getMessage = (key, props) => this.getMessage(key, props);
514
+ filterModal.modalTitle = this.getMessage("snkFilterBar.modalDefaultFilterTitle");
515
+ filterModal.infoText = this.getMessage(defaultFilter.length == 0 ? "snkFilterBar.modalInfoTextCreateDefault" : "snkFilterBar.modalInfoTextEditDefault");
516
+ filterModal.items = defaultFilter.map(item => {
517
+ return { id: item.id, active: true, enabled: false, label: item.label };
518
+ });
519
+ filterModal.processModalAction = (_action) => {
520
+ this._application.closeModal();
521
+ };
522
+ this._application.showModal(filterModal);
523
+ }
524
+ openPersonalizedModal() {
525
+ const filterModal = document.createElement("snk-filter-modal");
526
+ const personalizedFilter = this.filterConfig
527
+ .filter(item => item.type === FilterItemType.PERSONALIZED)
528
+ .sort((itemA, itemB) => StringUtils.compare(itemA.label, itemB.label));
529
+ filterModal.getMessage = (key, props) => this.getMessage(key, props);
530
+ filterModal.modalTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterTitle");
531
+ filterModal.modalSubTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle");
532
+ filterModal.okButtonLabel = this.getMessage("snkFilterBar.modalOkButtonLabel");
533
+ filterModal.cancelButtonLabel = this.getMessage("snkFilterBar.modalCancelButtonLabel");
534
+ filterModal.infoText = this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized");
535
+ filterModal.useSearch = true;
536
+ filterModal.items = personalizedFilter.map(item => {
537
+ return { id: item.id, active: item.visible, enabled: true, label: item.label };
538
+ });
539
+ filterModal.processModalAction = (action) => {
540
+ if (action === ModalAction.CANCEL) {
541
+ // O Botão de cancelar, tem efeito específico:
542
+ // - Desmarcar todos os filtros personalizados.
543
+ filterModal.items = filterModal.items.map(item => {
544
+ return Object.assign(Object.assign({}, item), { active: false });
545
+ });
546
+ }
547
+ else {
548
+ if (action === ModalAction.OK) {
549
+ this.addPersonalizedFilters(filterModal.items);
550
+ }
551
+ this._application.closeModal();
552
+ }
553
+ };
554
+ this._application.showModal(filterModal);
555
+ }
556
+ clearFilters() {
557
+ let changed = false;
558
+ this.filterConfig = this.filterConfig.map(item => {
559
+ if (item.value != undefined) {
560
+ changed = true;
561
+ }
562
+ return Object.assign(Object.assign({}, item), { value: undefined });
563
+ }).sort((a, b) => this._filtersComparator(a, b));
564
+ return changed;
565
+ }
566
+ loadPermitions() {
567
+ this._application.isUserSup().then(value => this.allowDefault = value);
568
+ }
569
+ loadConfigFromApplication() {
570
+ this._application.getFilterBarConfig(this.configName)
571
+ .then((filters) => {
572
+ this.filterConfig = filters.map(item => this.normalizeItem(item));
573
+ if (this.dataUnit) {
574
+ this.dataUnit.loadData();
575
+ }
576
+ })
577
+ .catch(reason => {
578
+ throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
579
+ });
580
+ }
581
+ attachDataUnit() {
582
+ if (this.dataUnit == undefined) {
583
+ let parent = this._element.parentElement;
584
+ while (parent) {
585
+ if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
586
+ const snkDataUnit = parent;
587
+ this.dataUnit = snkDataUnit.dataUnit;
588
+ if (this.dataUnit) {
589
+ this.registryFilterProvider();
590
+ }
591
+ else {
592
+ snkDataUnit.addEventListener("dataUnitReady", (evt) => {
593
+ this.dataUnit = evt.detail;
594
+ this.registryFilterProvider();
595
+ });
596
+ }
597
+ break;
598
+ }
599
+ }
600
+ parent = parent.parentElement;
601
+ }
602
+ else {
603
+ this.registryFilterProvider();
604
+ }
605
+ }
606
+ filterChangeListener(evt) {
607
+ this.updateFilter(evt.detail);
608
+ }
609
+ addFilterHandler(itemName) {
610
+ const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
611
+ if (itemName === PERSONALIZED_FILTER) {
612
+ this.openPersonalizedModal();
613
+ }
614
+ else if (itemName === DEFAULT_FILTER) {
615
+ this.openDefaultFilterModal();
616
+ }
617
+ else if (filterItem) {
618
+ this._pendingFilters.push(itemName);
619
+ this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
620
+ }
621
+ }
622
+ appliedFilterHandler(itemName) {
623
+ if (itemName === CLEAR_ALL_FILTERS) {
624
+ if (this.clearFilters()) {
625
+ this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
626
+ }
627
+ }
628
+ else {
629
+ const filterItemElement = this._element.querySelector("#filter-" + itemName);
630
+ if (filterItemElement) {
631
+ filterItemElement.showUp(true);
632
+ }
633
+ }
634
+ }
635
+ componentWillLoad() {
636
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
637
+ if (this._application) {
638
+ this.loadPermitions();
639
+ this.loadConfigFromApplication();
640
+ }
641
+ this.attachDataUnit();
642
+ }
643
+ componentDidRender() {
644
+ this.processPendingFilter();
645
+ }
646
+ render() {
647
+ if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
648
+ return undefined;
649
+ }
650
+ return (h(Host, null, h("ez-scroller", { direction: "horizontal" }, this.getFilterItems()), h("snk-filter-list", { id: APPLIED_FILTERS, onFocusin: () => this.itemFocused(APPLIED_FILTERS), items: this.getAppliedListItems(), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyAppliedFiltersList"), findFilterText: this.getMessage("snkFilterBar.findFilter"), iconName: "filter", class: "ez-padding-left--medium", buttonClass: this.getActiveClass(), onSnkItemSelected: evt => this.appliedFilterHandler(evt.detail) }), h("snk-filter-list", { id: ADD_FILTER, onFocusin: () => this.itemFocused(ADD_FILTER), items: this.getAddListItems(), label: this.getMessage("snkFilterBar.addFilter"), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyFiltersList"), findFilterText: this.getMessage("snkFilterBar.findField"), class: "ez-padding-left--medium", onSnkItemSelected: evt => this.addFilterHandler(evt.detail) }, h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
651
+ }
652
+ get _element() { return getElement(this); }
653
+ static get watchers() { return {
654
+ "filterConfig": ["observeFilterConfig"]
655
+ }; }
656
+ };
657
+ SnkFilterBar.style = snkFilterBarCss;
658
+
659
+ const SnkFilterItem = class {
660
+ constructor(hostRef) {
661
+ registerInstance(this, hostRef);
662
+ this.filterChange = createEvent(this, "filterChange", 7);
663
+ this.innerClickCheck = (_floatingContainer, node) => {
664
+ if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
665
+ return true;
666
+ }
667
+ this.detailIsVisible = false;
668
+ return false;
669
+ };
670
+ }
671
+ async showUp(open = false) {
672
+ return new Promise(resolve => {
673
+ this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
674
+ if (open) {
675
+ this._closeCallback = resolve;
676
+ window.requestAnimationFrame(() => {
677
+ this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, {
678
+ autoClose: true,
679
+ innerClickTest: this.innerClickCheck,
680
+ backClickListener: () => this.onDetailCloseCallback(),
681
+ left: this.getScrollOffset(),
682
+ useOverlay: true
683
+ });
684
+ this._popover.show();
685
+ this.detailIsVisible = true;
686
+ });
687
+ }
688
+ });
689
+ }
690
+ getScrollOffset() {
691
+ const padding = getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");
692
+ const rect = this._filterItemElement.getBoundingClientRect();
693
+ return `calc(${rect.left}px + ${padding})`;
694
+ }
695
+ async hideDetail() {
696
+ if (this.detailIsVisible) {
697
+ if (this._floatingID != undefined) {
698
+ FloatingManager.close(this._floatingID);
699
+ }
700
+ }
701
+ }
702
+ onDetailCloseCallback() {
703
+ this._floatingID = undefined;
704
+ this.detailIsVisible = false;
705
+ if (this._closeCallback) {
706
+ this._closeCallback();
707
+ this._closeCallback = undefined;
708
+ }
709
+ }
710
+ //---------------------------------------------
711
+ // Event handlers
712
+ //---------------------------------------------
713
+ clickListener(evt) {
714
+ if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
715
+ if (evt.target === this._rightIconElement && this.config.value != undefined) {
716
+ this.filterChange.emit(Object.assign(Object.assign({}, this.config), { value: undefined }));
717
+ }
718
+ else {
719
+ if (this.detailIsVisible) {
720
+ this.hideDetail();
721
+ }
722
+ else {
723
+ this.showUp(true);
724
+ }
725
+ }
726
+ evt.preventDefault();
727
+ evt.stopImmediatePropagation();
728
+ evt.stopPropagation();
729
+ }
730
+ }
731
+ mouseDownListener(evt) {
732
+ if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
733
+ evt.preventDefault();
734
+ evt.stopImmediatePropagation();
735
+ evt.stopPropagation();
736
+ }
737
+ }
738
+ getLabel() {
739
+ const { type, value, label, props } = this.config;
740
+ if (value) {
741
+ if (type === FilterItemType.BINARY_SELECT) {
742
+ const [optOne, optTwo] = props.options;
743
+ if (optOne.name === value) {
744
+ return optOne.label;
745
+ }
746
+ if (optTwo.name === value) {
747
+ return optTwo.label;
748
+ }
749
+ }
750
+ if (type === FilterItemType.MULTI_SELECT) {
751
+ const opt = props.options.find(opt => opt.value === value);
752
+ return `${label}: ${opt.label}`;
753
+ }
754
+ if (type === FilterItemType.PERIOD) {
755
+ let { end, start } = value;
756
+ if (typeof end === "string") {
757
+ end = new Date(end);
758
+ end.setMinutes(end.getMinutes() + end.getTimezoneOffset());
759
+ }
760
+ if (typeof start === "string") {
761
+ start = new Date(start);
762
+ start.setMinutes(start.getMinutes() + start.getTimezoneOffset());
763
+ }
764
+ const dateFormater = new Intl.DateTimeFormat("pt-BR");
765
+ if (end && start) {
766
+ return `${label}: ${dateFormater.format(start)} a ${dateFormater.format(end)}`;
767
+ }
768
+ else {
769
+ if (start) {
770
+ return `${label}: A partir de ${dateFormater.format(start)}`;
771
+ }
772
+ else if (end) {
773
+ return `${label}: Até ${dateFormater.format(end)}`;
774
+ }
775
+ else {
776
+ return label;
777
+ }
778
+ }
779
+ }
780
+ if (type === FilterItemType.SEARCH) {
781
+ return `${label}: ${value.value} - ${value.label}`;
782
+ }
783
+ if (type === FilterItemType.PERSONALIZED) {
784
+ return label;
785
+ }
786
+ return `${label}: ${value}`;
787
+ }
788
+ return label;
789
+ }
790
+ componentDidRender() {
791
+ if (this._floatingID == undefined) {
792
+ if (this._popover) {
793
+ this._popover.remove();
794
+ }
795
+ }
796
+ }
797
+ filterChangeListener() {
798
+ this.hideDetail();
799
+ }
800
+ getRightIconName() {
801
+ if (this.config.value != undefined) {
802
+ return "close";
803
+ }
804
+ return this.detailIsVisible ? "chevron-up" : "chevron-down";
805
+ }
806
+ getLeftIconName() {
807
+ switch (this.config.type) {
808
+ case FilterItemType.PERIOD:
809
+ return "calendar";
810
+ case FilterItemType.PERSONALIZED:
811
+ return "tune";
812
+ }
813
+ return undefined;
814
+ }
815
+ render() {
816
+ const leftIcon = this.getLeftIconName();
817
+ return (h(Host, null, h("ez-chip", { ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.config.value != undefined }, leftIcon ? h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" }) : undefined, h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem, key: this.config.id }))));
818
+ }
819
+ get _filterItemElement() { return getElement(this); }
820
+ };
821
+
822
+ const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
823
+ const MAX_FILTERS = 5;
824
+ const SnkFilterList = class {
825
+ constructor(hostRef) {
826
+ registerInstance(this, hostRef);
827
+ this.snkItemSelected = createEvent(this, "snkItemSelected", 7);
828
+ this._preselection = -1;
829
+ this.innerClickCheck = (_floatingContainer, node) => {
830
+ if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
831
+ return true;
832
+ }
833
+ this._detailIsVisible = false;
834
+ return false;
835
+ };
836
+ }
837
+ showDetail() {
838
+ this._preselection = -1;
839
+ this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, {
840
+ autoClose: true,
841
+ innerClickTest: this.innerClickCheck,
842
+ backClickListener: () => this.onListCloseCallback(),
843
+ useOverlay: true
844
+ });
845
+ this._detailIsVisible = true;
846
+ this._showAll = false;
847
+ this._filterArgument = "";
848
+ this._filterInput.setFocus();
849
+ }
850
+ async hideDetail() {
851
+ if (this._floatingID != undefined) {
852
+ FloatingManager.close(this._floatingID);
853
+ }
854
+ }
855
+ onListCloseCallback() {
856
+ this._floatingID = undefined;
857
+ this._detailIsVisible = false;
858
+ }
859
+ buttonClick() {
860
+ if (this._detailIsVisible) {
861
+ this.hideDetail();
862
+ }
863
+ else {
864
+ this.showDetail();
865
+ }
866
+ }
867
+ componentDidRender() {
868
+ if (this._floatingID == undefined) {
869
+ if (this._popover) {
870
+ this._popover.remove();
871
+ }
872
+ }
873
+ }
874
+ buildItemElement(item) {
875
+ const itemId = ++this._selectableItemsCount;
876
+ return (h("button", { 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) }, item.iconName ? h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, h("div", { class: `ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${item.labelClass || ""}` }, item.label)));
877
+ }
878
+ itemSelected(itemName) {
879
+ if (itemName === SHOW_MORE_ITEM_NAME) {
880
+ this._showAll = true;
881
+ }
882
+ else {
883
+ this.hideDetail();
884
+ this.snkItemSelected.emit(itemName);
885
+ }
886
+ }
887
+ getFilterItems() {
888
+ const items = this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
889
+ if (items.length === 0) {
890
+ return h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty" }, this.emptyText);
891
+ }
892
+ const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
893
+ if (hideItems) {
894
+ items.splice(MAX_FILTERS);
895
+ 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" });
896
+ }
897
+ this._selectableItemsCount = 0;
898
+ return h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
899
+ }
900
+ getFooterItems() {
901
+ return this.items.filter(item => item.kind === "FOOTER");
902
+ }
903
+ keyDownHandler(event) {
904
+ switch (event.key) {
905
+ case "ArrowDown":
906
+ this.changePreselection(this._preselection + 1);
907
+ //Paramos a propagação do evento para evitar scroll indesejado
908
+ event.stopImmediatePropagation();
909
+ event.stopPropagation();
910
+ event.preventDefault();
911
+ break;
912
+ case "ArrowUp":
913
+ this.changePreselection(this._preselection - 1);
914
+ //Paramos a propagação do evento para evitar scroll indesejado
915
+ event.stopImmediatePropagation();
916
+ event.stopPropagation();
917
+ event.preventDefault();
918
+ break;
919
+ }
920
+ }
921
+ changePreselection(newSelection) {
922
+ if (newSelection < 0) {
923
+ newSelection = this._selectableItemsCount;
924
+ }
925
+ this._preselection = newSelection > this._selectableItemsCount ? 0 : newSelection;
926
+ if (this._preselection === 0) {
927
+ this._filterInput.setFocus();
928
+ }
929
+ else {
930
+ const item = this._element.querySelector(`#filter-item${this._preselection}`);
931
+ if (item) {
932
+ item.focus();
933
+ }
934
+ }
935
+ }
936
+ render() {
937
+ return (h(Host, { class: "ez-flex ez-flex--column" }, h("ez-button", { class: this.buttonClass, label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, h("slot", { name: "leftIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem }, h("ez-filter-input", { ref: ref => this._filterInput = ref, mode: "slim", label: this.findFilterText, value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail, onFocus: () => this._preselection = 0 }), this.getFilterItems(), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
938
+ }
939
+ get _element() { return getElement(this); }
940
+ };
941
+
942
+ const SnkFilterModal = class {
943
+ constructor(hostRef) {
944
+ registerInstance(this, hostRef);
945
+ }
946
+ updateValue(id, value = undefined) {
947
+ this.items = this.items.map(item => {
948
+ if (item.id === id && item.enabled) {
949
+ if (value == undefined) {
950
+ value = !item.active;
951
+ }
952
+ return Object.assign(Object.assign({}, item), { active: value });
953
+ }
954
+ return item;
955
+ });
956
+ }
957
+ getActiveFiltersMsg() {
958
+ const activeFilters = this.items.filter(item => item.active).length;
959
+ if (activeFilters === 0) {
960
+ return this.getMessage("snkFilterBar.noActiveFilters");
961
+ }
962
+ return this.getMessage(activeFilters > 1 ? "snkFilterBar.activeFilters" : "snkFilterBar.activeFilter", { ACTIVE_FILTERS: activeFilters });
963
+ }
964
+ buildItems(list) {
965
+ return list.map(item => {
966
+ return (h("button", { onClick: () => this.updateValue(item.id), class: "ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small" }, h("ez-check", { id: `checkbox_${item.id}`, tabIndex: "-1", class: "sc-snk-filter-bar snk-filter-bar__filter-modal-item__check", onEzChange: evt => this.updateValue(item.id, evt.detail), enabled: item.enabled, value: item.active, mode: CheckMode.SWITCH }), h("div", { class: "ez-text ez-title--primary ez-text--medium ez-margin-left--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item__label" }, item.label)));
967
+ });
968
+ }
969
+ itemKeyBoardSelect(event, item) {
970
+ if (event.key === "Enter" || event.key === " ") {
971
+ this.updateValue(item.id);
972
+ }
973
+ }
974
+ modalActionListener(evt) {
975
+ const modalAction = evt.detail;
976
+ if (modalAction === ModalAction.LOAD) {
977
+ if (this._filterInput) {
978
+ this._filterInput.setFocus();
979
+ }
980
+ }
981
+ else {
982
+ this.processModalAction(modalAction);
983
+ }
984
+ }
985
+ render() {
986
+ const allowCancel = this.items.filter(item => item.active).length > 0;
987
+ const items = (this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items) : []);
988
+ return (h("ez-modal-container", { modalTitle: this.modalTitle, modalSubTitle: this.modalSubTitle, cancelButtonLabel: this.cancelButtonLabel, okButtonLabel: this.okButtonLabel, onEzModalAction: evt => this.modalActionListener(evt), cancelButtonStatus: allowCancel ? ModalButtonStatus.ENABLED : ModalButtonStatus.DISABLED }, h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-modal-content" }, h("div", null, this.useSearch ?
989
+ h("ez-filter-input", { ref: ref => this._filterInput = ref, label: this.getMessage("snkFilterBar.modalFindFilter"), onEzChange: (evt) => this._filterArgument = evt.detail })
990
+ :
991
+ undefined), items.length > 0 ? h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding-bottom--small" }, this.getActiveFiltersMsg()) : undefined, h("div", null, this.buildItems(items)), h("div", { class: "ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large" }, this.infoText))));
992
+ }
993
+ };
994
+
995
+ const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex}";
996
+
997
+ const SnkTaskbar = class {
998
+ constructor(hostRef) {
999
+ registerInstance(this, hostRef);
1000
+ this.actionClick = createEvent(this, "actionClick", 7);
1001
+ this.actionChange = createEvent(this, "actionChange", 7);
1002
+ this._titleKeyByElement = {
1003
+ [TaskbarElement.UPDATE]: "snkTaskbar.titleUpdate",
1004
+ [TaskbarElement.PREVIOUS]: "snkTaskbar.titlePrevious",
1005
+ [TaskbarElement.NEXT]: "snkTaskbar.titleNext",
1006
+ [TaskbarElement.REFRESH]: "snkTaskbar.titleRefresh",
1007
+ [TaskbarElement.CLONE]: "snkTaskbar.titleClone",
1008
+ [TaskbarElement.REMOVE]: "snkTaskbar.titleRemove",
1009
+ [TaskbarElement.MORE_OPTIONS]: "snkTaskbar.titleMoreOptions",
1010
+ [TaskbarElement.INSERT]: "snkTaskbar.titleInsert",
1011
+ [TaskbarElement.CANCEL]: "snkTaskbar.titleCancel",
1012
+ [TaskbarElement.SAVE]: "snkTaskbar.titleSave",
1013
+ [TaskbarElement.GRID_MODE]: "snkTaskbar.titleGridMode",
1014
+ [TaskbarElement.FORM_MODE]: "snkTaskbar.titleFormMode",
1015
+ [TaskbarElement.CONFIGURATOR]: "snkTaskbar.titleConfigurator"
1016
+ };
1017
+ }
1018
+ observeButtons() {
1019
+ this._definitions = undefined;
1020
+ }
1021
+ // Internal methods
1022
+ elementsFromString(strButtons) {
1023
+ const elements = [];
1024
+ if (strButtons) {
1025
+ strButtons.split(",").forEach(buttonName => {
1026
+ buttonName = buttonName.trim();
1027
+ if (VisibleWhenForbidden[buttonName] || this.isAllowed(buttonName)) {
1028
+ elements.push(buttonName.trim());
1029
+ }
1030
+ });
1031
+ }
1032
+ return elements;
1033
+ }
1034
+ isAllowed(buttonName) {
1035
+ if (AuthorizationElements[buttonName]) {
1036
+ return this._permissions ? this._permissions.isSup || this._permissions[buttonName] : false;
1037
+ }
1038
+ return true;
1039
+ }
1040
+ /**
1041
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
1042
+ * através de um pequeno modulo na estrutura da aplicação:
1043
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
1044
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-taskbar.msg.ts"
1045
+ */
1046
+ getTitle(element) {
1047
+ let key;
1048
+ if (this.isAllowed(element)) {
1049
+ key = this._titleKeyByElement[element];
1050
+ }
1051
+ else {
1052
+ key = "snkTaskbar.forbidden";
1053
+ }
1054
+ return key ? this._application.messagesBuilder.getMessage(key, {}) : "";
1055
+ }
1056
+ elementClick(elem) {
1057
+ if (this.dataUnit) {
1058
+ switch (elem) {
1059
+ case TaskbarElement.PREVIOUS:
1060
+ this.dataUnit.previousRecord();
1061
+ break;
1062
+ case TaskbarElement.NEXT:
1063
+ this.dataUnit.nextRecord();
1064
+ break;
1065
+ case TaskbarElement.REFRESH:
1066
+ this.dataUnit.loadData();
1067
+ break;
1068
+ case TaskbarElement.CLONE:
1069
+ this.dataUnit.copySelected();
1070
+ break;
1071
+ case TaskbarElement.REMOVE:
1072
+ this.dataUnit.removeSelectedRecords();
1073
+ break;
1074
+ case TaskbarElement.INSERT:
1075
+ this.dataUnit.addRecord();
1076
+ break;
1077
+ case TaskbarElement.CANCEL:
1078
+ this.dataUnit.cancelEdition();
1079
+ break;
1080
+ case TaskbarElement.SAVE:
1081
+ this.dataUnit.saveData();
1082
+ break;
1083
+ }
1084
+ }
1085
+ this.actionClick.emit(elem);
1086
+ }
1087
+ isEnabled(elem) {
1088
+ if (!this.isAllowed(elem)) {
1089
+ return false;
1090
+ }
1091
+ return !(this.disabledButtons && this.disabledButtons.includes(elem));
1092
+ }
1093
+ getElement(index, def) {
1094
+ let className = def === this.primaryButton ? "ez-button--primary " : "";
1095
+ if (index > 1) {
1096
+ className += "ez-padding-left--medium";
1097
+ }
1098
+ if (TaskbarElement[def.toString()]) {
1099
+ return buildElem(def, className, elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.actionsList, this.configName);
1100
+ }
1101
+ else {
1102
+ return buildCustomButton(def, className, elem => this.elementClick(elem), elem => this.isEnabled(elem));
1103
+ }
1104
+ }
1105
+ // Lifecycle
1106
+ componentWillLoad() {
1107
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
1108
+ if (this._application) {
1109
+ this._application.getAllAccess().then(access => this._permissions = access);
1110
+ }
1111
+ else {
1112
+ this._permissions = {};
1113
+ }
1114
+ }
1115
+ componentWillRender() {
1116
+ if (this._definitions == undefined && this._permissions) {
1117
+ this._definitions = this.elementsFromString(this.buttons);
1118
+ }
1119
+ }
1120
+ render() {
1121
+ if (this._definitions === undefined) {
1122
+ return undefined;
1123
+ }
1124
+ let index = 0;
1125
+ return (h(Host, null, this._definitions.map((elem) => {
1126
+ if (elem === TaskbarElement.DIVIDER) {
1127
+ index = 0;
1128
+ }
1129
+ else {
1130
+ index++;
1131
+ }
1132
+ if (TaskbarElement[elem]) {
1133
+ return this.getElement(index, TaskbarElement[elem]);
1134
+ }
1135
+ if (this.customButtons.has(elem)) {
1136
+ return this.getElement(index, this.customButtons.get(elem));
1137
+ }
1138
+ return h("slot", { name: elem });
1139
+ })));
1140
+ }
1141
+ static get watchers() { return {
1142
+ "buttons": ["observeButtons"]
1143
+ }; }
1144
+ };
1145
+ SnkTaskbar.style = snkTaskbarCss;
1146
+
1147
+ export { SnkConfigurator as snk_configurator, SnkFilterBar as snk_filter_bar, SnkFilterItem as snk_filter_item, SnkFilterList as snk_filter_list, SnkFilterModal as snk_filter_modal, SnkTaskbar as snk_taskbar };