@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-76362.0 → 0.0.0-bugfix-dev-KB-74224.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/cjs/{ConfigStorage-f079f5fd.js → ConfigStorage-ecc0ed20.js} +2 -2
  2. package/dist/cjs/{ContinuousInsertUtils-64e47516.js → ContinuousInsertUtils-29b65619.js} +20 -29
  3. package/dist/cjs/{DataFetcher-e059eb72.js → DataFetcher-cadeef8e.js} +5 -7
  4. package/dist/cjs/{SnkFormConfigManager-63369164.js → SnkFormConfigManager-f1c92f79.js} +2 -2
  5. package/dist/cjs/{SnkMessageBuilder-7691a2c1.js → SnkMessageBuilder-bae64d0d.js} +0 -10
  6. package/dist/cjs/{auth-fetcher-4f853233.js → auth-fetcher-d68841bc.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-228016f4.js → dataunit-fetcher-f89461c1.js} +3 -3
  8. package/dist/cjs/{form-config-fetcher-39397ac5.js → form-config-fetcher-ed497282.js} +1 -1
  9. package/dist/cjs/index-f9e81701.js +28 -16
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/{pesquisa-fetcher-a9bfeb22.js → pesquisa-fetcher-ca89181c.js} +2 -7
  12. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  13. package/dist/cjs/snk-actions-button_4.cjs.entry.js +30 -27
  14. package/dist/cjs/snk-application.cjs.entry.js +60 -102
  15. package/dist/cjs/snk-attach.cjs.entry.js +5 -5
  16. package/dist/cjs/snk-config-options.cjs.entry.js +239 -0
  17. package/dist/cjs/snk-crud.cjs.entry.js +5 -5
  18. package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
  19. package/dist/cjs/{snk-data-unit-7dbdad0e.js → snk-data-unit-668dc5e8.js} +2 -2
  20. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
  21. package/dist/cjs/snk-detail-view.cjs.entry.js +8 -8
  22. package/dist/cjs/{snk-filter-bar_4.cjs.entry.js → snk-filter-bar.cjs.entry.js} +3 -688
  23. package/dist/cjs/snk-filter-item.cjs.entry.js +312 -0
  24. package/dist/cjs/snk-filter-list.cjs.entry.js +152 -0
  25. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  26. package/dist/cjs/snk-filter-modal.cjs.entry.js +249 -0
  27. package/dist/cjs/{snk-config-options_3.cjs.entry.js → snk-form-config.cjs.entry.js} +3 -365
  28. package/dist/cjs/snk-form.cjs.entry.js +144 -0
  29. package/dist/cjs/snk-grid.cjs.entry.js +6 -6
  30. package/dist/cjs/{snk-guides-viewer-eee43c8b.js → snk-guides-viewer-4236cb9d.js} +5 -8
  31. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
  32. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  33. package/dist/cjs/snk-simple-crud.cjs.entry.js +14 -14
  34. package/dist/collection/collection-manifest.json +31 -14
  35. package/dist/collection/components/snk-actions-button/snk-actions-button.js +27 -26
  36. package/dist/collection/components/snk-application/snk-application.js +53 -3
  37. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +0 -3
  38. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +7 -7
  39. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +6 -8
  40. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +2 -2
  41. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +1 -6
  42. package/dist/collection/lib/message/SnkMessageBuilder.js +0 -2
  43. package/dist/collection/lib/utils/CrudUtils.js +16 -25
  44. package/dist/components/ContinuousInsertUtils.js +16 -25
  45. package/dist/components/DataFetcher.js +5 -7
  46. package/dist/components/SnkMessageBuilder.js +0 -10
  47. package/dist/components/dataunit-fetcher.js +2 -2
  48. package/dist/components/index.d.ts +0 -3
  49. package/dist/components/index.js +0 -3
  50. package/dist/components/pesquisa-fetcher.js +1 -6
  51. package/dist/components/snk-actions-button2.js +27 -26
  52. package/dist/components/snk-application2.js +53 -95
  53. package/dist/components/snk-detail-view2.js +0 -3
  54. package/dist/components/snk-simple-crud2.js +7 -7
  55. package/dist/esm/{ConfigStorage-6514d66e.js → ConfigStorage-7b36d041.js} +2 -2
  56. package/dist/esm/{ContinuousInsertUtils-b62906f9.js → ContinuousInsertUtils-30caa626.js} +20 -29
  57. package/dist/esm/{DataFetcher-5034df59.js → DataFetcher-a9c598f2.js} +5 -7
  58. package/dist/esm/{SnkFormConfigManager-b409c745.js → SnkFormConfigManager-139f09fa.js} +3 -3
  59. package/dist/esm/{SnkMessageBuilder-7ace6803.js → SnkMessageBuilder-6fff4a4c.js} +0 -10
  60. package/dist/esm/{auth-fetcher-ca5d3a49.js → auth-fetcher-749d880f.js} +1 -1
  61. package/dist/esm/{constants-7302ee87.js → constants-8457af36.js} +1 -1
  62. package/dist/esm/{dataunit-fetcher-56cb648b.js → dataunit-fetcher-c24c76c6.js} +3 -3
  63. package/dist/esm/{form-config-fetcher-a7d3e277.js → form-config-fetcher-adbe5d34.js} +1 -1
  64. package/dist/esm/index-a7d3d3f1.js +28 -16
  65. package/dist/esm/loader.js +1 -1
  66. package/dist/esm/{pesquisa-fetcher-6bc2e41a.js → pesquisa-fetcher-8edaa8cd.js} +2 -7
  67. package/dist/esm/sankhyablocks.js +1 -1
  68. package/dist/esm/snk-actions-button_4.entry.js +32 -29
  69. package/dist/esm/snk-application.entry.js +60 -102
  70. package/dist/esm/snk-attach.entry.js +6 -6
  71. package/dist/esm/snk-config-options.entry.js +235 -0
  72. package/dist/esm/snk-configurator.entry.js +1 -1
  73. package/dist/esm/snk-crud.entry.js +6 -6
  74. package/dist/esm/snk-data-exporter.entry.js +7 -7
  75. package/dist/esm/{snk-data-unit-7a579dbd.js → snk-data-unit-0fdfb6c2.js} +2 -2
  76. package/dist/esm/snk-data-unit.entry.js +4 -4
  77. package/dist/esm/snk-detail-view.entry.js +9 -9
  78. package/dist/esm/snk-field-config.entry.js +1 -1
  79. package/dist/esm/{snk-filter-bar_4.entry.js → snk-filter-bar.entry.js} +5 -687
  80. package/dist/esm/snk-filter-item.entry.js +308 -0
  81. package/dist/esm/snk-filter-list.entry.js +148 -0
  82. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  83. package/dist/esm/snk-filter-modal.entry.js +245 -0
  84. package/dist/esm/{snk-config-options_3.entry.js → snk-form-config.entry.js} +6 -366
  85. package/dist/esm/snk-form.entry.js +140 -0
  86. package/dist/esm/snk-grid.entry.js +6 -6
  87. package/dist/esm/{snk-guides-viewer-e8ca764a.js → snk-guides-viewer-8934c537.js} +6 -9
  88. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  89. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  90. package/dist/esm/snk-simple-crud.entry.js +15 -15
  91. package/dist/esm/snk-tab-config.entry.js +1 -1
  92. package/dist/sankhyablocks/p-01086ff7.entry.js +1 -0
  93. package/dist/sankhyablocks/{p-126c58ea.js → p-06421fdb.js} +1 -1
  94. package/dist/sankhyablocks/{p-e3a285a2.js → p-16869f77.js} +1 -1
  95. package/dist/sankhyablocks/p-17425c72.js +1 -0
  96. package/dist/sankhyablocks/{p-341465ce.js → p-1bf06cd3.js} +2 -2
  97. package/dist/sankhyablocks/{p-aa003d4e.entry.js → p-212213d9.entry.js} +1 -1
  98. package/dist/sankhyablocks/p-2923c1b5.js +1 -0
  99. package/dist/sankhyablocks/p-3b60db06.entry.js +1 -0
  100. package/dist/sankhyablocks/{p-00f9fe5c.entry.js → p-430e4d3c.entry.js} +1 -1
  101. package/dist/sankhyablocks/{p-9ffd9fc7.js → p-4d9549cf.js} +1 -1
  102. package/dist/sankhyablocks/p-4f35399c.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-c75fae8e.js → p-5dd8cf4f.js} +1 -1
  104. package/dist/sankhyablocks/p-60b29483.entry.js +1 -0
  105. package/dist/sankhyablocks/p-70a4af56.entry.js +1 -0
  106. package/dist/sankhyablocks/{p-41793e17.entry.js → p-7663f597.entry.js} +1 -1
  107. package/dist/sankhyablocks/{p-47d24ac8.js → p-7ac7932c.js} +2 -2
  108. package/dist/sankhyablocks/{p-2d3f9482.entry.js → p-8eb67fa4.entry.js} +1 -1
  109. package/dist/sankhyablocks/{p-f0aaad2b.entry.js → p-92eadb1c.entry.js} +1 -1
  110. package/dist/sankhyablocks/{p-8b4fc28f.entry.js → p-95df461f.entry.js} +1 -1
  111. package/dist/sankhyablocks/p-a42e7a1e.entry.js +11 -0
  112. package/dist/sankhyablocks/p-a724e798.entry.js +1 -0
  113. package/dist/sankhyablocks/{p-1dbd5c18.entry.js → p-a75d242d.entry.js} +1 -1
  114. package/dist/sankhyablocks/{p-0e206e62.js → p-afbb070d.js} +1 -1
  115. package/dist/sankhyablocks/{p-95ce311a.js → p-b0ef4383.js} +1 -1
  116. package/dist/sankhyablocks/p-b9679243.entry.js +1 -0
  117. package/dist/sankhyablocks/{p-f4e221b2.entry.js → p-b9c67e45.entry.js} +1 -1
  118. package/dist/sankhyablocks/{p-b389ed49.entry.js → p-be5d8fcb.entry.js} +1 -1
  119. package/dist/sankhyablocks/p-ca5ec380.js +1 -0
  120. package/dist/sankhyablocks/p-d3f53df2.entry.js +1 -0
  121. package/dist/sankhyablocks/{p-a2c790ac.entry.js → p-dcead955.entry.js} +1 -1
  122. package/dist/sankhyablocks/p-e8763234.entry.js +1 -0
  123. package/dist/sankhyablocks/{p-00278e07.js → p-f3434fc4.js} +1 -1
  124. package/dist/sankhyablocks/{p-fca0e5cc.entry.js → p-fb34e0cf.entry.js} +1 -1
  125. package/dist/sankhyablocks/p-feba9d4b.entry.js +1 -0
  126. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  127. package/dist/types/components/snk-actions-button/interfaces/index.d.ts +3 -0
  128. package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +3 -2
  129. package/dist/types/components/snk-application/snk-application.d.ts +12 -3
  130. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +1 -0
  131. package/dist/types/components.d.ts +1 -393
  132. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +0 -1
  133. package/dist/types/lib/utils/CrudUtils.d.ts +0 -1
  134. package/package.json +2 -3
  135. package/react/components.d.ts +0 -3
  136. package/react/components.js +0 -3
  137. package/react/components.js.map +1 -1
  138. package/dist/cjs/input-distinct-search_2.cjs.entry.js +0 -471
  139. package/dist/cjs/snk-distinct-search.cjs.entry.js +0 -123
  140. package/dist/collection/components/snk-application/request-listener/DebouncedRequestListener.js +0 -28
  141. package/dist/collection/components/snk-application/request-listener/RequestListenerFactory.js +0 -16
  142. package/dist/collection/components/snk-application/request-listener/RequestListenerLoadingBar.js +0 -52
  143. package/dist/collection/components/snk-distinct-search/snk-distinct-search.css +0 -4
  144. package/dist/collection/components/snk-distinct-search/snk-distinct-search.js +0 -372
  145. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.css +0 -110
  146. package/dist/collection/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.js +0 -544
  147. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.css +0 -28
  148. package/dist/collection/components/snk-distinct-search/subcomponents/search-modal/search-modal.js +0 -593
  149. package/dist/collection/components/snk-distinct-search/utils/filter-distinct-search.js +0 -15
  150. package/dist/collection/lib/http/data-fetcher/fetchers/distinct-search-fetcher.js +0 -25
  151. package/dist/collection/lib/message/resources/snk-distinct-search.msg.js +0 -9
  152. package/dist/collection/sw.js +0 -46
  153. package/dist/components/filter-distinct-search.js +0 -17
  154. package/dist/components/input-distinct-search.d.ts +0 -11
  155. package/dist/components/input-distinct-search.js +0 -6
  156. package/dist/components/input-distinct-search2.js +0 -264
  157. package/dist/components/search-modal.d.ts +0 -11
  158. package/dist/components/search-modal.js +0 -6
  159. package/dist/components/search-modal2.js +0 -264
  160. package/dist/components/snk-distinct-search.d.ts +0 -11
  161. package/dist/components/snk-distinct-search.js +0 -163
  162. package/dist/esm/input-distinct-search_2.entry.js +0 -466
  163. package/dist/esm/snk-distinct-search.entry.js +0 -119
  164. package/dist/sankhyablocks/p-0e250436.entry.js +0 -1
  165. package/dist/sankhyablocks/p-154aa2a6.entry.js +0 -11
  166. package/dist/sankhyablocks/p-18cb1acb.entry.js +0 -1
  167. package/dist/sankhyablocks/p-30ebcbe0.entry.js +0 -1
  168. package/dist/sankhyablocks/p-3755b46f.entry.js +0 -1
  169. package/dist/sankhyablocks/p-3858a2e4.entry.js +0 -1
  170. package/dist/sankhyablocks/p-42130213.entry.js +0 -1
  171. package/dist/sankhyablocks/p-563b7c28.entry.js +0 -1
  172. package/dist/sankhyablocks/p-aaf94476.js +0 -1
  173. package/dist/sankhyablocks/p-d8665750.js +0 -1
  174. package/dist/sankhyablocks/p-e4391e16.js +0 -1
  175. package/dist/types/components/snk-application/request-listener/DebouncedRequestListener.d.ts +0 -11
  176. package/dist/types/components/snk-application/request-listener/RequestListenerFactory.d.ts +0 -12
  177. package/dist/types/components/snk-application/request-listener/RequestListenerLoadingBar.d.ts +0 -13
  178. package/dist/types/components/snk-distinct-search/snk-distinct-search.d.ts +0 -83
  179. package/dist/types/components/snk-distinct-search/subcomponents/input-distinct-search/input-distinct-search.d.ts +0 -105
  180. package/dist/types/components/snk-distinct-search/subcomponents/search-modal/search-modal.d.ts +0 -127
  181. package/dist/types/components/snk-distinct-search/types/index.d.ts +0 -12
  182. package/dist/types/components/snk-distinct-search/utils/filter-distinct-search.d.ts +0 -4
  183. package/dist/types/lib/http/data-fetcher/fetchers/distinct-search-fetcher.d.ts +0 -6
  184. package/dist/types/lib/message/resources/snk-distinct-search.msg.d.ts +0 -2
  185. /package/dist/collection/components/{snk-distinct-search/types → snk-actions-button/interfaces}/index.js +0 -0
@@ -1,17 +1,15 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
2
- import { DataType, StringUtils, ObjectUtils, ElementIDUtils, ErrorException, ApplicationContext, FloatingManager, DateUtils, ArrayUtils } from '@sankhyalabs/core';
2
+ import { DataType, StringUtils, ObjectUtils, ElementIDUtils, ErrorException, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
4
- import { C as ConfigStorage } from './ConfigStorage-6514d66e.js';
4
+ import { C as ConfigStorage } from './ConfigStorage-7b36d041.js';
5
5
  import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
6
6
  import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
7
7
  import { F as FilterOperand } from './index-ae591a44.js';
8
8
  import { F as FilterNumberVariation } from './filterNumberVariation-8cee02ea.js';
9
9
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
10
10
  import { P as PersonalizedFilterUtils } from './PersonalizedFilterUtils-e2b38ef7.js';
11
- import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
12
- import { F as FilterType } from './filter-type.enum-a80c1b6b.js';
13
- import './form-config-fetcher-a7d3e277.js';
14
- import './DataFetcher-5034df59.js';
11
+ import './form-config-fetcher-adbe5d34.js';
12
+ import './DataFetcher-a9c598f2.js';
15
13
  import './PrintUtils-3e4ff0f5.js';
16
14
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
17
15
 
@@ -721,684 +719,4 @@ const SnkFilterBar = class {
721
719
  };
722
720
  SnkFilterBar.style = snkFilterBarCss;
723
721
 
724
- const SnkFilterItem = class {
725
- constructor(hostRef) {
726
- registerInstance(this, hostRef);
727
- this.visibleChanged = createEvent(this, "visibleChanged", 7);
728
- this.filterChange = createEvent(this, "filterChange", 3);
729
- this.innerClickCheck = (_floatingContainer, node) => {
730
- if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
731
- return true;
732
- }
733
- this.detailIsVisible = false;
734
- return false;
735
- };
736
- this.detailIsVisible = undefined;
737
- this.config = undefined;
738
- this.getMessage = undefined;
739
- this.showChips = true;
740
- }
741
- observeDetailIsVisible(value) {
742
- this.visibleChanged.emit(value);
743
- }
744
- /**
745
- * Exibe os detalhes de um item da lista.
746
- */
747
- async showUp(open = false) {
748
- return new Promise(resolve => {
749
- this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
750
- if (open) {
751
- this._closeCallback = resolve;
752
- window.requestAnimationFrame(() => {
753
- this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, this.getFloatOptions());
754
- this._popover.show();
755
- this.detailIsVisible = true;
756
- });
757
- }
758
- });
759
- }
760
- updatePosition() {
761
- if (this._floatingID == undefined) {
762
- return;
763
- }
764
- FloatingManager.updateFloatPosition(this._popover, this._popoverContainer, this.getFloatOptions());
765
- }
766
- getFloatOptions() {
767
- return {
768
- autoClose: true,
769
- innerClickTest: this.innerClickCheck,
770
- backClickListener: () => this.onDetailCloseCallback(),
771
- left: this.getOffsetLeft(),
772
- top: this.getOffsetTop(),
773
- useOverlay: true,
774
- overlayClassName: 'ez-scrim ez-scrim--light',
775
- isFixed: true
776
- };
777
- }
778
- getOffsetLeft() {
779
- const padding = getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");
780
- const rect = this._filterItemElement.getBoundingClientRect();
781
- // Width baseado no conteudo do snk-filter-detail. Nesse momento ele retorna 0px pois ainda não foi criado em tela.
782
- const filterDetailWidth = 430;
783
- const adjustRightPosition = filterDetailWidth - (document.body.clientWidth - rect.left);
784
- return `calc(${rect.x}px + ${padding} - ${adjustRightPosition > 0 ? adjustRightPosition : 0}px)`;
785
- }
786
- getOffsetTop() {
787
- const rect = this._filterItemElement.getBoundingClientRect();
788
- return (rect.y + rect.height) + "px";
789
- }
790
- controlScrollPage() {
791
- window.removeEventListener("scroll", this.updatePosition.bind(this));
792
- window.addEventListener("scroll", this.updatePosition.bind(this));
793
- }
794
- getConfigChanges() {
795
- var _a;
796
- const configToBeCleared = this.config;
797
- if (!!((_a = configToBeCleared.groupedItems) === null || _a === void 0 ? void 0 : _a.length)) {
798
- configToBeCleared.visible = false;
799
- configToBeCleared.groupedItems = configToBeCleared.groupedItems.map(item => (Object.assign(Object.assign({}, item), { visible: false })));
800
- }
801
- const hasMultiValues = configToBeCleared.type === FilterItemType.MULTI_LIST && Array.isArray(configToBeCleared.value);
802
- const newValue = hasMultiValues ? configToBeCleared.value.map((valueItem) => (Object.assign(Object.assign({}, valueItem), { check: false }))) : undefined;
803
- return Object.assign(Object.assign({}, configToBeCleared), { value: newValue });
804
- }
805
- /**
806
- * Oculta os detalhes de um item da lista.
807
- */
808
- async hideDetail() {
809
- if (this.detailIsVisible) {
810
- if (this._floatingID != undefined) {
811
- FloatingManager.close(this._floatingID);
812
- }
813
- }
814
- }
815
- onDetailCloseCallback() {
816
- this._floatingID = undefined;
817
- this.detailIsVisible = false;
818
- if (this._closeCallback) {
819
- this._closeCallback();
820
- this._closeCallback = undefined;
821
- }
822
- }
823
- //---------------------------------------------
824
- // Event handlers
825
- //---------------------------------------------
826
- clickListener(evt) {
827
- if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
828
- if (evt.target === this._rightIconElement && this.canClearFilter()) {
829
- const configChanged = this.getConfigChanges();
830
- this.filterChange.emit(configChanged);
831
- }
832
- else {
833
- if (this.detailIsVisible) {
834
- this.hideDetail();
835
- }
836
- else {
837
- this.showUp(true);
838
- }
839
- }
840
- evt.preventDefault();
841
- evt.stopImmediatePropagation();
842
- evt.stopPropagation();
843
- }
844
- }
845
- mouseDownListener(evt) {
846
- if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
847
- evt.preventDefault();
848
- evt.stopImmediatePropagation();
849
- evt.stopPropagation();
850
- }
851
- }
852
- getLabel(isTooltipLabel = false) {
853
- var _a, _b;
854
- const { type, value, label, props, groupedItems = [] } = this.config;
855
- if (value || groupedItems.length) {
856
- if (type === FilterItemType.BINARY_SELECT) {
857
- const [optOne, optTwo] = props.options;
858
- const tooltip = this.getMessage('snkFilterBar.binarySelectTooltip');
859
- if (optOne.name === value) {
860
- return isTooltipLabel ? `${tooltip} ${String(optOne.label).toLowerCase()}` : optOne.label;
861
- }
862
- if (optTwo.name === value) {
863
- return isTooltipLabel ? `${tooltip} ${String(optTwo.label).toLowerCase()}` : optTwo.label;
864
- }
865
- }
866
- if (type === FilterItemType.MULTI_SELECT) {
867
- const opt = props.options.find(opt => opt.value === value);
868
- return `${label}: ${opt.label}`;
869
- }
870
- if (type === FilterItemType.PERIOD) {
871
- let { end, start } = value;
872
- if (typeof end === "string") {
873
- end = new Date(end);
874
- end.setMinutes(end.getMinutes() + end.getTimezoneOffset());
875
- }
876
- if (typeof start === "string") {
877
- start = new Date(start);
878
- start.setMinutes(start.getMinutes() + start.getTimezoneOffset());
879
- }
880
- const dateFormater = new Intl.DateTimeFormat("pt-BR");
881
- if (end && start) {
882
- const isSameYear = start.getFullYear() === end.getFullYear();
883
- const formatOptions = Object.assign({ day: '2-digit', month: '2-digit' }, ((!isSameYear || isTooltipLabel) && { year: '2-digit' }));
884
- const startLabel = DateUtils.formatDate(start, formatOptions);
885
- const endLabel = DateUtils.formatDate(end, formatOptions);
886
- if (isTooltipLabel) {
887
- return this.getMessage('snkFilterBar.fullPeriodTooltip', { LABEL: label, START_LABEL: startLabel, END_LABEL: endLabel });
888
- }
889
- return `${label}: ${startLabel} \u2192 ${endLabel}`;
890
- }
891
- else {
892
- if (start) {
893
- return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${dateFormater.format(start)}`;
894
- }
895
- else if (end) {
896
- return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${dateFormater.format(end)}`;
897
- }
898
- else {
899
- return label;
900
- }
901
- }
902
- }
903
- if (type === FilterItemType.SEARCH) {
904
- return `${label}: ${value.value} - ${value.label}`;
905
- }
906
- if (type === FilterItemType.PERSONALIZED) {
907
- const activeCount = this.calculateActiveCount(groupedItems);
908
- if (activeCount <= 0)
909
- return label;
910
- return `${label}: ${this.getMessage('snkFilterBar.personalizedCount', { activeCount })}`;
911
- }
912
- if (type === FilterItemType.MULTI_LIST) {
913
- const selectedOptions = ((_a = value.elements) !== null && _a !== void 0 ? _a : value).filter(item => item === null || item === void 0 ? void 0 : item.check);
914
- return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
915
- }
916
- if (type === FilterItemType.CHECK_BOX_LIST) {
917
- const selectedValues = Object.entries(value !== null && value !== void 0 ? value : {})
918
- .filter(([_, value]) => value === true)
919
- .map(([key, _]) => key);
920
- const options = (_b = props.options) !== null && _b !== void 0 ? _b : [];
921
- const selectedOptions = options.filter(option => selectedValues.includes(option.name));
922
- return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
923
- }
924
- if (type === FilterItemType.NUMBER && props.variation === FilterNumberVariation.INTERVAL) {
925
- const { start, end } = value;
926
- if (start && end) {
927
- return this.getMessage('snkFilterBar.fullIntervalTooltip', { LABEL: label, START_LABEL: start, END_LABEL: end });
928
- }
929
- if (start) {
930
- return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${Number(start)}`;
931
- }
932
- if (end) {
933
- return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${Number(end)}`;
934
- }
935
- }
936
- return `${label}: ${value}`;
937
- }
938
- return label;
939
- }
940
- getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel) {
941
- const checkedAmount = selectedOptions.length;
942
- if (checkedAmount === 0) {
943
- return `${label}`;
944
- }
945
- if (checkedAmount > 1) {
946
- if (isTooltipLabel) {
947
- const selectedOptionsDescrptions = selectedOptions.map(item => item.label);
948
- return `${label}: ${selectedOptionsDescrptions.join(',')}`;
949
- }
950
- return `${label}: ${checkedAmount} ${this.getMessage('snkFilterBar.multiListToltip')}`;
951
- }
952
- return `${label}: ${selectedOptions[0].label}`;
953
- }
954
- calculateActiveCount(groupedItems) {
955
- return groupedItems.reduce((total, item) => {
956
- if (!!item.visible)
957
- return total + 1;
958
- return total;
959
- }, 0);
960
- }
961
- componentDidLoad() {
962
- if (this._filterItemElement) {
963
- ElementIDUtils.addIDInfo(this._filterItemElement);
964
- this._idSnkFilterDetail = `filterDetail_${this.config.id}`;
965
- }
966
- this.controlScrollPage();
967
- }
968
- componentDidRender() {
969
- if (this._floatingID == undefined) {
970
- if (this._popover) {
971
- this._popover.remove();
972
- }
973
- }
974
- }
975
- /**
976
- * Emitido quando o estado do filtro é alterado.
977
- */
978
- filterChangeListener() {
979
- this.hideDetail();
980
- }
981
- canClearFilter() {
982
- const { value, groupedItems = [] } = this.config;
983
- if (value != undefined && this.config.type === FilterItemType.MULTI_LIST) {
984
- return value.some((item) => item.check);
985
- }
986
- return value !== undefined || groupedItems.some(item => item.visible);
987
- }
988
- getRightIconName() {
989
- if (this.canClearFilter())
990
- return "close";
991
- return this.detailIsVisible ? "chevron-up" : "chevron-down";
992
- }
993
- getLeftIconName() {
994
- switch (this.config.type) {
995
- case FilterItemType.PERIOD:
996
- return "calendar";
997
- case FilterItemType.PERSONALIZED:
998
- return "tune";
999
- }
1000
- return undefined;
1001
- }
1002
- hasActiveElements(value) {
1003
- var _a, _b, _c;
1004
- 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;
1005
- }
1006
- hasActiveValue(config) {
1007
- return (config.type !== FilterItemType.MULTI_LIST && config.value !== undefined) || this.hasActiveElements(config.value);
1008
- }
1009
- getEnabledChip() {
1010
- if (this.config.type === FilterItemType.PERSONALIZED) {
1011
- const { groupedItems = [] } = this.config;
1012
- return groupedItems.some(item => item.visible);
1013
- }
1014
- return this.hasActiveValue(this.config);
1015
- }
1016
- render() {
1017
- const leftIcon = this.getLeftIconName();
1018
- return (h(Host, null, this.showChips && (h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.getEnabledChip() }, leftIcon && (h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" })), h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon", id: "removeFilter" }))), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16", ref: elem => this._popover = elem, key: this.config.id, "data-element-id": this._idSnkFilterDetail, showHardFixed: this.showChips }))));
1019
- }
1020
- get _filterItemElement() { return getElement(this); }
1021
- static get watchers() { return {
1022
- "detailIsVisible": ["observeDetailIsVisible"]
1023
- }; }
1024
- };
1025
-
1026
- const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
1027
- const MAX_FILTERS = 5;
1028
- const SnkFilterList = class {
1029
- constructor(hostRef) {
1030
- registerInstance(this, hostRef);
1031
- this.snkItemSelected = createEvent(this, "snkItemSelected", 7);
1032
- this._preselection = -1;
1033
- this.innerClickCheck = (_floatingContainer, node) => {
1034
- if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
1035
- return true;
1036
- }
1037
- this._detailIsVisible = false;
1038
- return false;
1039
- };
1040
- this._filterArgument = undefined;
1041
- this._showAll = undefined;
1042
- this.label = undefined;
1043
- this.iconName = undefined;
1044
- this.items = undefined;
1045
- this.getMessage = undefined;
1046
- this.emptyText = undefined;
1047
- this.findFilterText = undefined;
1048
- this.buttonClass = undefined;
1049
- }
1050
- showDetail() {
1051
- this._preselection = -1;
1052
- this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, {
1053
- autoClose: true,
1054
- innerClickTest: this.innerClickCheck,
1055
- backClickListener: () => this.onListCloseCallback(),
1056
- useOverlay: true
1057
- });
1058
- this._detailIsVisible = true;
1059
- this._showAll = false;
1060
- this._filterArgument = "";
1061
- this._filterInput.setFocus();
1062
- }
1063
- /**
1064
- * Oculta os detalhes do componente snk-filter-list.
1065
- */
1066
- async hideDetail() {
1067
- if (this._floatingID != undefined) {
1068
- FloatingManager.close(this._floatingID);
1069
- }
1070
- }
1071
- onListCloseCallback() {
1072
- this._floatingID = undefined;
1073
- this._detailIsVisible = false;
1074
- }
1075
- buttonClick() {
1076
- if (this._detailIsVisible) {
1077
- this.hideDetail();
1078
- }
1079
- else {
1080
- this.showDetail();
1081
- }
1082
- }
1083
- componentDidLoad() {
1084
- if (this._element) {
1085
- ElementIDUtils.addIDInfo(this._element);
1086
- }
1087
- }
1088
- componentDidRender() {
1089
- if (this._floatingID == undefined) {
1090
- if (this._popover) {
1091
- this._popover.remove();
1092
- }
1093
- }
1094
- }
1095
- buildIdElement(buttonElement, name) {
1096
- if (!buttonElement)
1097
- return;
1098
- const dataElement = { id: name };
1099
- buttonElement.removeAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
1100
- ElementIDUtils.addIDInfoIfNotExists(buttonElement, "filterItemList", dataElement);
1101
- }
1102
- buildItemElement(item) {
1103
- const itemId = ++this._selectableItemsCount;
1104
- return (h("button", { ref: elem => elem && this.buildIdElement(elem, item.label), id: `filter-item${itemId}`, onFocusin: () => this._preselection = itemId, class: `ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item`, onClick: () => this.itemSelected(item.name), name: item.label, key: itemId }, item.iconName ? h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, h("div", { class: `ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${item.labelClass || ""}` }, item.label)));
1105
- }
1106
- itemSelected(itemName) {
1107
- if (itemName === SHOW_MORE_ITEM_NAME) {
1108
- this._showAll = true;
1109
- }
1110
- else {
1111
- this.hideDetail();
1112
- this.snkItemSelected.emit(itemName);
1113
- }
1114
- }
1115
- getFilterItems() {
1116
- const items = this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
1117
- if (items.length === 0) {
1118
- 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);
1119
- }
1120
- const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
1121
- if (hideItems) {
1122
- items.splice(MAX_FILTERS);
1123
- 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" });
1124
- }
1125
- this._selectableItemsCount = 0;
1126
- return h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
1127
- }
1128
- getFooterItems() {
1129
- return this.items.filter(item => item.kind === "FOOTER");
1130
- }
1131
- keyDownHandler(event) {
1132
- switch (event.key) {
1133
- case "ArrowDown":
1134
- this.changePreselection(this._preselection + 1);
1135
- //Paramos a propagação do evento para evitar scroll indesejado
1136
- event.stopImmediatePropagation();
1137
- event.stopPropagation();
1138
- event.preventDefault();
1139
- break;
1140
- case "ArrowUp":
1141
- this.changePreselection(this._preselection - 1);
1142
- //Paramos a propagação do evento para evitar scroll indesejado
1143
- event.stopImmediatePropagation();
1144
- event.stopPropagation();
1145
- event.preventDefault();
1146
- break;
1147
- }
1148
- }
1149
- changePreselection(newSelection) {
1150
- if (newSelection < 0) {
1151
- newSelection = this._selectableItemsCount;
1152
- }
1153
- this._preselection = newSelection > this._selectableItemsCount ? 0 : newSelection;
1154
- if (this._preselection === 0) {
1155
- this._filterInput.setFocus();
1156
- }
1157
- else {
1158
- const item = this._element.querySelector(`#filter-item${this._preselection}`);
1159
- if (item) {
1160
- item.focus();
1161
- }
1162
- }
1163
- }
1164
- render() {
1165
- return (h(Host, { class: "ez-flex ez-flex--column" }, h("ez-button", { class: this.buttonClass, label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, h("slot", { name: "leftIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--4", ref: elem => this._popover = elem }, h("ez-filter-input", { ref: ref => this._filterInput = ref, "data-element-id": "serachFilters", mode: "slim", label: this.findFilterText, value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail, onFocus: () => this._preselection = 0 }), this.getFilterItems(), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
1166
- }
1167
- get _element() { return getElement(this); }
1168
- };
1169
-
1170
- const snkFilterModalCss = "ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{width:344px;max-width:344px;min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px;overflow-x:clip;overflow-y:auto}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";
1171
-
1172
- const SnkFilterModal = class {
1173
- constructor(hostRef) {
1174
- registerInstance(this, hostRef);
1175
- this.getMessage = undefined;
1176
- this.configName = undefined;
1177
- this.filters = undefined;
1178
- this.applyFilters = undefined;
1179
- this.closeModal = undefined;
1180
- this.addPersonalizedFilter = undefined;
1181
- this.editPersonalizedFilter = undefined;
1182
- this.deletePersonalizedFilter = undefined;
1183
- this.filtersToDelete = [];
1184
- this.disablePersonalizedFilter = undefined;
1185
- }
1186
- /**
1187
- * Emitido quando um filtro personalizado é deletado.
1188
- */
1189
- deletePersonalizedFilterListener(event) {
1190
- this.filtersToDelete.push(event.detail);
1191
- }
1192
- getCustomMessage(key, params) {
1193
- var _a;
1194
- return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
1195
- }
1196
- //TODO: tratar clear all dos filtros personalizados
1197
- handleClearAll() {
1198
- const { customFilters, quickFilters, otherFilters, multiListFilters } = this.filters.reduce((acc, filter) => {
1199
- if (filter.type === FilterItemType.MULTI_LIST) {
1200
- acc.multiListFilters.push(filter);
1201
- return acc;
1202
- }
1203
- if (filter.filterType === FilterType.QUICK_FILTER) {
1204
- acc.quickFilters.push(filter);
1205
- return acc;
1206
- }
1207
- if (filter.filterType === FilterType.CUSTOM_FILTER) {
1208
- acc.customFilters.push(filter);
1209
- return acc;
1210
- }
1211
- if (filter.filterType === FilterType.OTHER_FILTERS) {
1212
- acc.otherFilters.push(filter);
1213
- return acc;
1214
- }
1215
- return acc;
1216
- }, { quickFilters: [], customFilters: [], otherFilters: [], multiListFilters: [] });
1217
- this.handleClearFilterList(quickFilters);
1218
- this.handleClearCustomFilters(customFilters);
1219
- this.handleClearOthersFilters(otherFilters);
1220
- multiListFilters.forEach(multiListFilter => this.handleClearSigleFilter(multiListFilter));
1221
- }
1222
- handleClearOthersFilters(otherFilters) {
1223
- this.filters = this.filters.map(filter => otherFilters.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
1224
- }
1225
- handleClearCustomFilters(customFilters) {
1226
- this.filters.forEach((filter, index) => {
1227
- if (filter.filterType === FilterType.CUSTOM_FILTER)
1228
- this.filters[index] = this.clearAllCustomFilter(customFilters).shift();
1229
- });
1230
- }
1231
- clearAllCustomFilter(filterConfigSnapshot) {
1232
- return filterConfigSnapshot.map(filterItem => {
1233
- const copy = Object.assign({}, filterItem);
1234
- delete copy.value;
1235
- copy.visible = false;
1236
- if (copy.groupedItems) {
1237
- copy.groupedItems = this.clearAllCustomFilter(copy.groupedItems);
1238
- }
1239
- return copy;
1240
- });
1241
- }
1242
- handleClose() {
1243
- const hasChangesToSave = ObjectUtils.objectToString(this.filters) !== ObjectUtils.objectToString(this._originalFilterConfig);
1244
- if (!hasChangesToSave) {
1245
- this.closeModal();
1246
- return;
1247
- }
1248
- return ApplicationUtils.confirm(this.getCustomMessage('validations.notSaved.title'), this.getCustomMessage('validations.notSaved.message')).then((cancelAction) => {
1249
- if (cancelAction)
1250
- this.closeModal();
1251
- });
1252
- }
1253
- handleApplyFilters() {
1254
- const filterPersonalized = this.filters.find(filter => filter.filterType === FilterType.CUSTOM_FILTER);
1255
- if (this.isValidCustomFilter(filterPersonalized)) {
1256
- this.applyFilters(this.filters);
1257
- }
1258
- if (this.filtersToDelete.length > 0) {
1259
- this.filtersToDelete.forEach(filter => {
1260
- this.deletePersonalizedFilter(filter, this.configName);
1261
- });
1262
- this.filtersToDelete = [];
1263
- }
1264
- }
1265
- isValidCustomFilter(filterPersonalized) {
1266
- const isValid = PersonalizedFilterUtils.validateVariableValues(filterPersonalized);
1267
- if (!isValid) {
1268
- ApplicationUtils.alert(this.getCustomMessage('validations.notFullFilled.title'), this.getCustomMessage('validations.notFullFilled.message'));
1269
- return false;
1270
- }
1271
- return true;
1272
- }
1273
- modalActionListener(evt) {
1274
- const modalAction = evt.detail;
1275
- switch (modalAction) {
1276
- case ModalAction.CANCEL:
1277
- this.handleClearAll();
1278
- break;
1279
- case ModalAction.OK:
1280
- this.handleApplyFilters();
1281
- break;
1282
- case ModalAction.CLOSE:
1283
- this.handleClose();
1284
- break;
1285
- }
1286
- }
1287
- handleFilterChange(filterConfig) {
1288
- this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
1289
- }
1290
- handleClearFilterList(filterList) {
1291
- this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
1292
- }
1293
- handleClearSigleFilter(filterItem) {
1294
- if (FilterItemType.MULTI_LIST === filterItem.type) {
1295
- let filterItemCopy = ObjectUtils.copy(filterItem);
1296
- this.uncheckFilterValues(filterItemCopy.value);
1297
- const filterListCopy = ObjectUtils.copy(this.filters);
1298
- const index = filterListCopy.findIndex(item => item.id === filterItem.id);
1299
- filterListCopy.splice(index, 1, filterItemCopy);
1300
- this.filters = ObjectUtils.copy(filterListCopy);
1301
- return;
1302
- }
1303
- if (FilterItemType.CHECK_BOX_LIST === filterItem.type) {
1304
- const filterListCopy = ObjectUtils.copy(this.filters);
1305
- filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
1306
- this.filters = ObjectUtils.copy(filterListCopy);
1307
- return;
1308
- }
1309
- this.filters.find(filter => filter.id === filterItem.id).value = undefined;
1310
- }
1311
- uncheckFilterValues(valueList) {
1312
- valueList.forEach(value => {
1313
- if (!!value) {
1314
- value.check = false;
1315
- }
1316
- });
1317
- return valueList;
1318
- }
1319
- renderFilterItem(filterItem, fullRow) {
1320
- return (h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event.detail), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
1321
- }
1322
- isDefaultFilterNumberVariation(filter) {
1323
- var _a;
1324
- return filter.type === FilterItemType.NUMBER
1325
- && (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === FilterNumberVariation.DEFAULT);
1326
- }
1327
- mountFiltersLines(filters) {
1328
- const MAX_LINE_LENGTH = 2;
1329
- let currentLine = 0;
1330
- let forceAddCurrent = false;
1331
- const filtersLines = {};
1332
- for (let curr = 0; curr < filters.length; curr++) {
1333
- filtersLines[currentLine] = filtersLines[currentLine] || [];
1334
- const item = filters[curr];
1335
- const isLast = curr === filters.length - 1;
1336
- const currentItemMatch = item.type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
1337
- const nextItemMatch = isLast ? false : filters[curr + 1].type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
1338
- if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
1339
- filtersLines[currentLine].push(item);
1340
- forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
1341
- if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
1342
- ++currentLine;
1343
- continue;
1344
- }
1345
- filtersLines[currentLine] = filtersLines[currentLine] || [];
1346
- filtersLines[currentLine].push(item);
1347
- ++currentLine;
1348
- }
1349
- return Object.values(filtersLines);
1350
- }
1351
- renderFilterLine(filters) {
1352
- const fullLine = filters.length === 1;
1353
- return filters.map((filter) => this.renderFilterItem(filter, fullLine));
1354
- }
1355
- getIformedFiltersCount(listItems) {
1356
- let countInformedItens = 0;
1357
- listItems.forEach(item => {
1358
- var _a, _b, _c, _d, _e, _f;
1359
- if (FilterItemType.MULTI_LIST === item.type) {
1360
- 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;
1361
- return;
1362
- }
1363
- if (FilterItemType.CHECK_BOX_LIST === item.type) {
1364
- countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
1365
- .filter(([_, value]) => value === true)
1366
- .map(([key, _]) => key).length;
1367
- return;
1368
- }
1369
- if (item.groupedItems != undefined) {
1370
- countInformedItens = item.groupedItems.filter(item => item.visible).length;
1371
- return;
1372
- }
1373
- if (!!item.value) {
1374
- countInformedItens++;
1375
- }
1376
- });
1377
- return countInformedItens;
1378
- }
1379
- renderCollapsibleFilterBox(label, listItems, isSingleItem, shouldRenderFooter = true) {
1380
- if (!listItems.length)
1381
- return null;
1382
- const appliedFilters = this.getIformedFiltersCount(listItems);
1383
- const lines = this.mountFiltersLines(listItems);
1384
- return (h("ez-collapsible-box", { class: "snk-filter-modal__collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters && (h("ez-badge", { class: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toString() })), h("div", { class: "ez-row snk-filter-modal__rendered-items" }, lines.map(this.renderFilterLine.bind(this))), shouldRenderFooter && (h("div", { class: "ez-flex ez-flex--justify-end grow" }, h("ez-button", { class: "ez-button--tertiary", size: "medium", label: "Limpar", onClick: () => isSingleItem ? this.handleClearSigleFilter(listItems[0]) : this.handleClearFilterList(listItems) })))));
1385
- }
1386
- componentWillRender() {
1387
- this._modalTitle = this.getCustomMessage('title');
1388
- this._okButtonLabel = this.getCustomMessage('okButtonLabel');
1389
- this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
1390
- }
1391
- componentDidLoad() {
1392
- if (!this._originalFilterConfig)
1393
- this._originalFilterConfig = this.filters;
1394
- }
1395
- render() {
1396
- const customFilters = this.filters.filter(filter => filter.filterType === FilterType.CUSTOM_FILTER);
1397
- const quickFilters = this.filters.filter(filter => filter.filterType === FilterType.QUICK_FILTER);
1398
- const otherFilters = this.filters.filter(filter => filter.filterType === FilterType.OTHER_FILTERS);
1399
- return (h("ez-modal-container", { class: "snk-filter-modal__container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, h("div", { class: "snk-filter-modal__content ez-col--sd-12" }, !this.disablePersonalizedFilter && this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters, false, false), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters, false), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter], true)))));
1400
- }
1401
- };
1402
- SnkFilterModal.style = snkFilterModalCss;
1403
-
1404
- export { SnkFilterBar as snk_filter_bar, SnkFilterItem as snk_filter_item, SnkFilterList as snk_filter_list, SnkFilterModal as snk_filter_modal };
722
+ export { SnkFilterBar as snk_filter_bar };