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