@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
@@ -5,15 +5,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index$1 = require('./index-f9e81701.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const EzScrollDirection = require('@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection');
8
- const ConfigStorage = require('./ConfigStorage-ecc0ed20.js');
8
+ const ConfigStorage = require('./ConfigStorage-f079f5fd.js');
9
9
  const DataType = require('@sankhyalabs/core/dist/dataunit/metadata/DataType');
10
10
  const filterItemType_enum = require('./filter-item-type.enum-a7ffdaa6.js');
11
11
  const index = require('./index-c5771aba.js');
12
12
  const filterNumberVariation = require('./filterNumberVariation-d65332da.js');
13
13
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
14
14
  const PersonalizedFilterUtils = require('./PersonalizedFilterUtils-0184ffbb.js');
15
- require('./form-config-fetcher-ed497282.js');
16
- require('./DataFetcher-cadeef8e.js');
15
+ const ezModalContainer = require('@sankhyalabs/ezui/dist/collection/components/ez-modal-container');
16
+ const filterType_enum = require('./filter-type.enum-b14ce507.js');
17
+ require('./form-config-fetcher-39397ac5.js');
18
+ require('./DataFetcher-e059eb72.js');
17
19
  require('./PrintUtils-bcaeb82f.js');
18
20
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
19
21
 
@@ -288,6 +290,7 @@ const SnkFilterBar = class {
288
290
  this.disablePersonalizedFilter = undefined;
289
291
  this.filterBarLegacyConfigName = undefined;
290
292
  this.autoLoad = undefined;
293
+ this.afterFilterModalApply = undefined;
291
294
  this.allowDefault = undefined;
292
295
  this.scrollerLocked = false;
293
296
  this.showPersonalizedFilter = false;
@@ -641,7 +644,9 @@ const SnkFilterBar = class {
641
644
  */
642
645
  async showFilterModal() {
643
646
  const callbackOnApplyFilter = (filters) => {
647
+ var _a;
644
648
  this.filterConfig = filters.map(this.normalizeItem).sort((a, b) => this._filtersComparator(a, b));
649
+ (_a = this.afterFilterModalApply) === null || _a === void 0 ? void 0 : _a.call(this);
645
650
  };
646
651
  let filtersConfigCopy = core.ObjectUtils.copy(this.filterConfig);
647
652
  filtersConfigCopy = filtersConfigCopy.sort((itemA, itemB) => {
@@ -723,4 +728,687 @@ const SnkFilterBar = class {
723
728
  };
724
729
  SnkFilterBar.style = snkFilterBarCss;
725
730
 
731
+ const SnkFilterItem = class {
732
+ constructor(hostRef) {
733
+ index$1.registerInstance(this, hostRef);
734
+ this.visibleChanged = index$1.createEvent(this, "visibleChanged", 7);
735
+ this.filterChange = index$1.createEvent(this, "filterChange", 3);
736
+ this.innerClickCheck = (_floatingContainer, node) => {
737
+ if (node.id != core.FloatingManager.MODAL_ELEMENT_ID) {
738
+ return true;
739
+ }
740
+ this.detailIsVisible = false;
741
+ return false;
742
+ };
743
+ this.detailIsVisible = undefined;
744
+ this.config = undefined;
745
+ this.getMessage = undefined;
746
+ this.showChips = true;
747
+ }
748
+ observeDetailIsVisible(value) {
749
+ this.visibleChanged.emit(value);
750
+ }
751
+ /**
752
+ * Exibe os detalhes de um item da lista.
753
+ */
754
+ async showUp(open = false) {
755
+ return new Promise(resolve => {
756
+ this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
757
+ if (open) {
758
+ this._closeCallback = resolve;
759
+ window.requestAnimationFrame(() => {
760
+ this._floatingID = core.FloatingManager.float(this._popover, this._popoverContainer, this.getFloatOptions());
761
+ this._popover.show();
762
+ this.detailIsVisible = true;
763
+ });
764
+ }
765
+ });
766
+ }
767
+ updatePosition() {
768
+ if (this._floatingID == undefined) {
769
+ return;
770
+ }
771
+ core.FloatingManager.updateFloatPosition(this._popover, this._popoverContainer, this.getFloatOptions());
772
+ }
773
+ getFloatOptions() {
774
+ return {
775
+ autoClose: true,
776
+ innerClickTest: this.innerClickCheck,
777
+ backClickListener: () => this.onDetailCloseCallback(),
778
+ left: this.getOffsetLeft(),
779
+ top: this.getOffsetTop(),
780
+ useOverlay: true,
781
+ overlayClassName: 'ez-scrim ez-scrim--light',
782
+ isFixed: true
783
+ };
784
+ }
785
+ getOffsetLeft() {
786
+ const padding = getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");
787
+ const rect = this._filterItemElement.getBoundingClientRect();
788
+ // Width baseado no conteudo do snk-filter-detail. Nesse momento ele retorna 0px pois ainda não foi criado em tela.
789
+ const filterDetailWidth = 430;
790
+ const adjustRightPosition = filterDetailWidth - (document.body.clientWidth - rect.left);
791
+ return `calc(${rect.x}px + ${padding} - ${adjustRightPosition > 0 ? adjustRightPosition : 0}px)`;
792
+ }
793
+ getOffsetTop() {
794
+ const rect = this._filterItemElement.getBoundingClientRect();
795
+ return (rect.y + rect.height) + "px";
796
+ }
797
+ controlScrollPage() {
798
+ window.removeEventListener("scroll", this.updatePosition.bind(this));
799
+ window.addEventListener("scroll", this.updatePosition.bind(this));
800
+ }
801
+ getConfigChanges() {
802
+ var _a;
803
+ const configToBeCleared = this.config;
804
+ if (!!((_a = configToBeCleared.groupedItems) === null || _a === void 0 ? void 0 : _a.length)) {
805
+ configToBeCleared.visible = false;
806
+ configToBeCleared.groupedItems = configToBeCleared.groupedItems.map(item => (Object.assign(Object.assign({}, item), { visible: false })));
807
+ }
808
+ const hasMultiValues = configToBeCleared.type === filterItemType_enum.FilterItemType.MULTI_LIST && Array.isArray(configToBeCleared.value);
809
+ const newValue = hasMultiValues ? configToBeCleared.value.map((valueItem) => (Object.assign(Object.assign({}, valueItem), { check: false }))) : undefined;
810
+ return Object.assign(Object.assign({}, configToBeCleared), { value: newValue });
811
+ }
812
+ /**
813
+ * Oculta os detalhes de um item da lista.
814
+ */
815
+ async hideDetail() {
816
+ if (this.detailIsVisible) {
817
+ if (this._floatingID != undefined) {
818
+ core.FloatingManager.close(this._floatingID);
819
+ }
820
+ }
821
+ }
822
+ onDetailCloseCallback() {
823
+ this._floatingID = undefined;
824
+ this.detailIsVisible = false;
825
+ if (this._closeCallback) {
826
+ this._closeCallback();
827
+ this._closeCallback = undefined;
828
+ }
829
+ }
830
+ //---------------------------------------------
831
+ // Event handlers
832
+ //---------------------------------------------
833
+ clickListener(evt) {
834
+ if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
835
+ if (evt.target === this._rightIconElement && this.canClearFilter()) {
836
+ const configChanged = this.getConfigChanges();
837
+ this.filterChange.emit(configChanged);
838
+ }
839
+ else {
840
+ if (this.detailIsVisible) {
841
+ this.hideDetail();
842
+ }
843
+ else {
844
+ this.showUp(true);
845
+ }
846
+ }
847
+ evt.preventDefault();
848
+ evt.stopImmediatePropagation();
849
+ evt.stopPropagation();
850
+ }
851
+ }
852
+ mouseDownListener(evt) {
853
+ if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
854
+ evt.preventDefault();
855
+ evt.stopImmediatePropagation();
856
+ evt.stopPropagation();
857
+ }
858
+ }
859
+ getLabel(isTooltipLabel = false) {
860
+ var _a, _b;
861
+ const { type, value, label, props, groupedItems = [] } = this.config;
862
+ if (value || groupedItems.length) {
863
+ if (type === filterItemType_enum.FilterItemType.BINARY_SELECT) {
864
+ const [optOne, optTwo] = props.options;
865
+ const tooltip = this.getMessage('snkFilterBar.binarySelectTooltip');
866
+ if (optOne.name === value) {
867
+ return isTooltipLabel ? `${tooltip} ${String(optOne.label).toLowerCase()}` : optOne.label;
868
+ }
869
+ if (optTwo.name === value) {
870
+ return isTooltipLabel ? `${tooltip} ${String(optTwo.label).toLowerCase()}` : optTwo.label;
871
+ }
872
+ }
873
+ if (type === filterItemType_enum.FilterItemType.MULTI_SELECT) {
874
+ const opt = props.options.find(opt => opt.value === value);
875
+ return `${label}: ${opt.label}`;
876
+ }
877
+ if (type === filterItemType_enum.FilterItemType.PERIOD) {
878
+ let { end, start } = value;
879
+ if (typeof end === "string") {
880
+ end = new Date(end);
881
+ end.setMinutes(end.getMinutes() + end.getTimezoneOffset());
882
+ }
883
+ if (typeof start === "string") {
884
+ start = new Date(start);
885
+ start.setMinutes(start.getMinutes() + start.getTimezoneOffset());
886
+ }
887
+ const dateFormater = new Intl.DateTimeFormat("pt-BR");
888
+ if (end && start) {
889
+ const isSameYear = start.getFullYear() === end.getFullYear();
890
+ const formatOptions = Object.assign({ day: '2-digit', month: '2-digit' }, ((!isSameYear || isTooltipLabel) && { year: '2-digit' }));
891
+ const startLabel = core.DateUtils.formatDate(start, formatOptions);
892
+ const endLabel = core.DateUtils.formatDate(end, formatOptions);
893
+ if (isTooltipLabel) {
894
+ return this.getMessage('snkFilterBar.fullPeriodTooltip', { LABEL: label, START_LABEL: startLabel, END_LABEL: endLabel });
895
+ }
896
+ return `${label}: ${startLabel} \u2192 ${endLabel}`;
897
+ }
898
+ else {
899
+ if (start) {
900
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${dateFormater.format(start)}`;
901
+ }
902
+ else if (end) {
903
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${dateFormater.format(end)}`;
904
+ }
905
+ else {
906
+ return label;
907
+ }
908
+ }
909
+ }
910
+ if (type === filterItemType_enum.FilterItemType.SEARCH) {
911
+ return `${label}: ${value.value} - ${value.label}`;
912
+ }
913
+ if (type === filterItemType_enum.FilterItemType.PERSONALIZED) {
914
+ const activeCount = this.calculateActiveCount(groupedItems);
915
+ if (activeCount <= 0)
916
+ return label;
917
+ return `${label}: ${this.getMessage('snkFilterBar.personalizedCount', { activeCount })}`;
918
+ }
919
+ if (type === filterItemType_enum.FilterItemType.MULTI_LIST) {
920
+ const selectedOptions = ((_a = value.elements) !== null && _a !== void 0 ? _a : value).filter(item => item === null || item === void 0 ? void 0 : item.check);
921
+ return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
922
+ }
923
+ if (type === filterItemType_enum.FilterItemType.CHECK_BOX_LIST) {
924
+ const selectedValues = Object.entries(value !== null && value !== void 0 ? value : {})
925
+ .filter(([_, value]) => value === true)
926
+ .map(([key, _]) => key);
927
+ const options = (_b = props.options) !== null && _b !== void 0 ? _b : [];
928
+ const selectedOptions = options.filter(option => selectedValues.includes(option.name));
929
+ return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
930
+ }
931
+ if (type === filterItemType_enum.FilterItemType.NUMBER && props.variation === filterNumberVariation.FilterNumberVariation.INTERVAL) {
932
+ const { start, end } = value;
933
+ if (start && end) {
934
+ return this.getMessage('snkFilterBar.fullIntervalTooltip', { LABEL: label, START_LABEL: start, END_LABEL: end });
935
+ }
936
+ if (start) {
937
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${Number(start)}`;
938
+ }
939
+ if (end) {
940
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${Number(end)}`;
941
+ }
942
+ }
943
+ return `${label}: ${value}`;
944
+ }
945
+ return label;
946
+ }
947
+ getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel) {
948
+ const checkedAmount = selectedOptions.length;
949
+ if (checkedAmount === 0) {
950
+ return `${label}`;
951
+ }
952
+ if (checkedAmount > 1) {
953
+ if (isTooltipLabel) {
954
+ const selectedOptionsDescrptions = selectedOptions.map(item => item.label);
955
+ return `${label}: ${selectedOptionsDescrptions.join(',')}`;
956
+ }
957
+ return `${label}: ${checkedAmount} ${this.getMessage('snkFilterBar.multiListToltip')}`;
958
+ }
959
+ return `${label}: ${selectedOptions[0].label}`;
960
+ }
961
+ calculateActiveCount(groupedItems) {
962
+ return groupedItems.reduce((total, item) => {
963
+ if (!!item.visible)
964
+ return total + 1;
965
+ return total;
966
+ }, 0);
967
+ }
968
+ componentDidLoad() {
969
+ if (this._filterItemElement) {
970
+ core.ElementIDUtils.addIDInfo(this._filterItemElement);
971
+ this._idSnkFilterDetail = `filterDetail_${this.config.id}`;
972
+ }
973
+ this.controlScrollPage();
974
+ }
975
+ componentDidRender() {
976
+ if (this._floatingID == undefined) {
977
+ if (this._popover) {
978
+ this._popover.remove();
979
+ }
980
+ }
981
+ }
982
+ /**
983
+ * Emitido quando o estado do filtro é alterado.
984
+ */
985
+ filterChangeListener() {
986
+ this.hideDetail();
987
+ }
988
+ canClearFilter() {
989
+ const { value, groupedItems = [] } = this.config;
990
+ if (value != undefined && this.config.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
991
+ return value.some((item) => item.check);
992
+ }
993
+ return value !== undefined || groupedItems.some(item => item.visible);
994
+ }
995
+ getRightIconName() {
996
+ if (this.canClearFilter())
997
+ return "close";
998
+ return this.detailIsVisible ? "chevron-up" : "chevron-down";
999
+ }
1000
+ getLeftIconName() {
1001
+ switch (this.config.type) {
1002
+ case filterItemType_enum.FilterItemType.PERIOD:
1003
+ return "calendar";
1004
+ case filterItemType_enum.FilterItemType.PERSONALIZED:
1005
+ return "tune";
1006
+ }
1007
+ return undefined;
1008
+ }
1009
+ hasActiveElements(value) {
1010
+ var _a, _b, _c;
1011
+ 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;
1012
+ }
1013
+ hasActiveValue(config) {
1014
+ return (config.type !== filterItemType_enum.FilterItemType.MULTI_LIST && config.value !== undefined) || this.hasActiveElements(config.value);
1015
+ }
1016
+ getEnabledChip() {
1017
+ if (this.config.type === filterItemType_enum.FilterItemType.PERSONALIZED) {
1018
+ const { groupedItems = [] } = this.config;
1019
+ return groupedItems.some(item => item.visible);
1020
+ }
1021
+ return this.hasActiveValue(this.config);
1022
+ }
1023
+ render() {
1024
+ const leftIcon = this.getLeftIconName();
1025
+ return (index$1.h(index$1.Host, null, this.showChips && (index$1.h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.getEnabledChip() }, leftIcon && (index$1.h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" })), index$1.h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon", id: "removeFilter" }))), index$1.h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, index$1.h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16", ref: elem => this._popover = elem, key: this.config.id, "data-element-id": this._idSnkFilterDetail, showHardFixed: this.showChips }))));
1026
+ }
1027
+ get _filterItemElement() { return index$1.getElement(this); }
1028
+ static get watchers() { return {
1029
+ "detailIsVisible": ["observeDetailIsVisible"]
1030
+ }; }
1031
+ };
1032
+
1033
+ const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
1034
+ const MAX_FILTERS = 5;
1035
+ const SnkFilterList = class {
1036
+ constructor(hostRef) {
1037
+ index$1.registerInstance(this, hostRef);
1038
+ this.snkItemSelected = index$1.createEvent(this, "snkItemSelected", 7);
1039
+ this._preselection = -1;
1040
+ this.innerClickCheck = (_floatingContainer, node) => {
1041
+ if (node.id != core.FloatingManager.MODAL_ELEMENT_ID) {
1042
+ return true;
1043
+ }
1044
+ this._detailIsVisible = false;
1045
+ return false;
1046
+ };
1047
+ this._filterArgument = undefined;
1048
+ this._showAll = undefined;
1049
+ this.label = undefined;
1050
+ this.iconName = undefined;
1051
+ this.items = undefined;
1052
+ this.getMessage = undefined;
1053
+ this.emptyText = undefined;
1054
+ this.findFilterText = undefined;
1055
+ this.buttonClass = undefined;
1056
+ }
1057
+ showDetail() {
1058
+ this._preselection = -1;
1059
+ this._floatingID = core.FloatingManager.float(this._popover, this._popoverContainer, {
1060
+ autoClose: true,
1061
+ innerClickTest: this.innerClickCheck,
1062
+ backClickListener: () => this.onListCloseCallback(),
1063
+ useOverlay: true
1064
+ });
1065
+ this._detailIsVisible = true;
1066
+ this._showAll = false;
1067
+ this._filterArgument = "";
1068
+ this._filterInput.setFocus();
1069
+ }
1070
+ /**
1071
+ * Oculta os detalhes do componente snk-filter-list.
1072
+ */
1073
+ async hideDetail() {
1074
+ if (this._floatingID != undefined) {
1075
+ core.FloatingManager.close(this._floatingID);
1076
+ }
1077
+ }
1078
+ onListCloseCallback() {
1079
+ this._floatingID = undefined;
1080
+ this._detailIsVisible = false;
1081
+ }
1082
+ buttonClick() {
1083
+ if (this._detailIsVisible) {
1084
+ this.hideDetail();
1085
+ }
1086
+ else {
1087
+ this.showDetail();
1088
+ }
1089
+ }
1090
+ componentDidLoad() {
1091
+ if (this._element) {
1092
+ core.ElementIDUtils.addIDInfo(this._element);
1093
+ }
1094
+ }
1095
+ componentDidRender() {
1096
+ if (this._floatingID == undefined) {
1097
+ if (this._popover) {
1098
+ this._popover.remove();
1099
+ }
1100
+ }
1101
+ }
1102
+ buildIdElement(buttonElement, name) {
1103
+ if (!buttonElement)
1104
+ return;
1105
+ const dataElement = { id: name };
1106
+ buttonElement.removeAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
1107
+ core.ElementIDUtils.addIDInfoIfNotExists(buttonElement, "filterItemList", dataElement);
1108
+ }
1109
+ buildItemElement(item) {
1110
+ const itemId = ++this._selectableItemsCount;
1111
+ return (index$1.h("button", { ref: elem => elem && this.buildIdElement(elem, item.label), id: `filter-item${itemId}`, onFocusin: () => this._preselection = itemId, class: `ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item`, onClick: () => this.itemSelected(item.name), name: item.label, key: itemId }, item.iconName ? index$1.h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, index$1.h("div", { class: `ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${item.labelClass || ""}` }, item.label)));
1112
+ }
1113
+ itemSelected(itemName) {
1114
+ if (itemName === SHOW_MORE_ITEM_NAME) {
1115
+ this._showAll = true;
1116
+ }
1117
+ else {
1118
+ this.hideDetail();
1119
+ this.snkItemSelected.emit(itemName);
1120
+ }
1121
+ }
1122
+ getFilterItems() {
1123
+ const items = this.items ? core.ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
1124
+ if (items.length === 0) {
1125
+ return index$1.h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty" }, this.emptyText);
1126
+ }
1127
+ const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
1128
+ if (hideItems) {
1129
+ items.splice(MAX_FILTERS);
1130
+ 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" });
1131
+ }
1132
+ this._selectableItemsCount = 0;
1133
+ return index$1.h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
1134
+ }
1135
+ getFooterItems() {
1136
+ return this.items.filter(item => item.kind === "FOOTER");
1137
+ }
1138
+ keyDownHandler(event) {
1139
+ switch (event.key) {
1140
+ case "ArrowDown":
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
+ case "ArrowUp":
1148
+ this.changePreselection(this._preselection - 1);
1149
+ //Paramos a propagação do evento para evitar scroll indesejado
1150
+ event.stopImmediatePropagation();
1151
+ event.stopPropagation();
1152
+ event.preventDefault();
1153
+ break;
1154
+ }
1155
+ }
1156
+ changePreselection(newSelection) {
1157
+ if (newSelection < 0) {
1158
+ newSelection = this._selectableItemsCount;
1159
+ }
1160
+ this._preselection = newSelection > this._selectableItemsCount ? 0 : newSelection;
1161
+ if (this._preselection === 0) {
1162
+ this._filterInput.setFocus();
1163
+ }
1164
+ else {
1165
+ const item = this._element.querySelector(`#filter-item${this._preselection}`);
1166
+ if (item) {
1167
+ item.focus();
1168
+ }
1169
+ }
1170
+ }
1171
+ render() {
1172
+ return (index$1.h(index$1.Host, { class: "ez-flex ez-flex--column" }, index$1.h("ez-button", { class: this.buttonClass, label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, index$1.h("slot", { name: "leftIcon" })), index$1.h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, index$1.h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--4", ref: elem => this._popover = elem }, index$1.h("ez-filter-input", { ref: ref => this._filterInput = ref, "data-element-id": "serachFilters", mode: "slim", label: this.findFilterText, value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail, onFocus: () => this._preselection = 0 }), this.getFilterItems(), index$1.h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
1173
+ }
1174
+ get _element() { return index$1.getElement(this); }
1175
+ };
1176
+
1177
+ 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)}";
1178
+
1179
+ const SnkFilterModal = class {
1180
+ constructor(hostRef) {
1181
+ index$1.registerInstance(this, hostRef);
1182
+ this.getMessage = undefined;
1183
+ this.configName = undefined;
1184
+ this.filters = undefined;
1185
+ this.applyFilters = undefined;
1186
+ this.closeModal = undefined;
1187
+ this.addPersonalizedFilter = undefined;
1188
+ this.editPersonalizedFilter = undefined;
1189
+ this.deletePersonalizedFilter = undefined;
1190
+ this.filtersToDelete = [];
1191
+ this.disablePersonalizedFilter = undefined;
1192
+ }
1193
+ /**
1194
+ * Emitido quando um filtro personalizado é deletado.
1195
+ */
1196
+ deletePersonalizedFilterListener(event) {
1197
+ this.filtersToDelete.push(event.detail);
1198
+ }
1199
+ getCustomMessage(key, params) {
1200
+ var _a;
1201
+ return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
1202
+ }
1203
+ //TODO: tratar clear all dos filtros personalizados
1204
+ handleClearAll() {
1205
+ const { customFilters, quickFilters, otherFilters, multiListFilters } = this.filters.reduce((acc, filter) => {
1206
+ if (filter.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
1207
+ acc.multiListFilters.push(filter);
1208
+ return acc;
1209
+ }
1210
+ if (filter.filterType === filterType_enum.FilterType.QUICK_FILTER) {
1211
+ acc.quickFilters.push(filter);
1212
+ return acc;
1213
+ }
1214
+ if (filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER) {
1215
+ acc.customFilters.push(filter);
1216
+ return acc;
1217
+ }
1218
+ if (filter.filterType === filterType_enum.FilterType.OTHER_FILTERS) {
1219
+ acc.otherFilters.push(filter);
1220
+ return acc;
1221
+ }
1222
+ return acc;
1223
+ }, { quickFilters: [], customFilters: [], otherFilters: [], multiListFilters: [] });
1224
+ this.handleClearFilterList(quickFilters);
1225
+ this.handleClearCustomFilters(customFilters);
1226
+ this.handleClearOthersFilters(otherFilters);
1227
+ multiListFilters.forEach(multiListFilter => this.handleClearSigleFilter(multiListFilter));
1228
+ }
1229
+ handleClearOthersFilters(otherFilters) {
1230
+ this.filters = this.filters.map(filter => otherFilters.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
1231
+ }
1232
+ handleClearCustomFilters(customFilters) {
1233
+ this.filters.forEach((filter, index) => {
1234
+ if (filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER)
1235
+ this.filters[index] = this.clearAllCustomFilter(customFilters).shift();
1236
+ });
1237
+ }
1238
+ clearAllCustomFilter(filterConfigSnapshot) {
1239
+ return filterConfigSnapshot.map(filterItem => {
1240
+ const copy = Object.assign({}, filterItem);
1241
+ delete copy.value;
1242
+ copy.visible = false;
1243
+ if (copy.groupedItems) {
1244
+ copy.groupedItems = this.clearAllCustomFilter(copy.groupedItems);
1245
+ }
1246
+ return copy;
1247
+ });
1248
+ }
1249
+ handleClose() {
1250
+ const hasChangesToSave = core.ObjectUtils.objectToString(this.filters) !== core.ObjectUtils.objectToString(this._originalFilterConfig);
1251
+ if (!hasChangesToSave) {
1252
+ this.closeModal();
1253
+ return;
1254
+ }
1255
+ return utils.ApplicationUtils.confirm(this.getCustomMessage('validations.notSaved.title'), this.getCustomMessage('validations.notSaved.message')).then((cancelAction) => {
1256
+ if (cancelAction)
1257
+ this.closeModal();
1258
+ });
1259
+ }
1260
+ handleApplyFilters() {
1261
+ const filterPersonalized = this.filters.find(filter => filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER);
1262
+ if (this.isValidCustomFilter(filterPersonalized)) {
1263
+ this.applyFilters(this.filters);
1264
+ }
1265
+ if (this.filtersToDelete.length > 0) {
1266
+ this.filtersToDelete.forEach(filter => {
1267
+ this.deletePersonalizedFilter(filter, this.configName);
1268
+ });
1269
+ this.filtersToDelete = [];
1270
+ }
1271
+ }
1272
+ isValidCustomFilter(filterPersonalized) {
1273
+ const isValid = PersonalizedFilterUtils.PersonalizedFilterUtils.validateVariableValues(filterPersonalized);
1274
+ if (!isValid) {
1275
+ utils.ApplicationUtils.alert(this.getCustomMessage('validations.notFullFilled.title'), this.getCustomMessage('validations.notFullFilled.message'));
1276
+ return false;
1277
+ }
1278
+ return true;
1279
+ }
1280
+ modalActionListener(evt) {
1281
+ const modalAction = evt.detail;
1282
+ switch (modalAction) {
1283
+ case ezModalContainer.ModalAction.CANCEL:
1284
+ this.handleClearAll();
1285
+ break;
1286
+ case ezModalContainer.ModalAction.OK:
1287
+ this.handleApplyFilters();
1288
+ break;
1289
+ case ezModalContainer.ModalAction.CLOSE:
1290
+ this.handleClose();
1291
+ break;
1292
+ }
1293
+ }
1294
+ handleFilterChange(filterConfig) {
1295
+ this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
1296
+ }
1297
+ handleClearFilterList(filterList) {
1298
+ this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
1299
+ }
1300
+ handleClearSigleFilter(filterItem) {
1301
+ if (filterItemType_enum.FilterItemType.MULTI_LIST === filterItem.type) {
1302
+ let filterItemCopy = core.ObjectUtils.copy(filterItem);
1303
+ this.uncheckFilterValues(filterItemCopy.value);
1304
+ const filterListCopy = core.ObjectUtils.copy(this.filters);
1305
+ const index = filterListCopy.findIndex(item => item.id === filterItem.id);
1306
+ filterListCopy.splice(index, 1, filterItemCopy);
1307
+ this.filters = core.ObjectUtils.copy(filterListCopy);
1308
+ return;
1309
+ }
1310
+ if (filterItemType_enum.FilterItemType.CHECK_BOX_LIST === filterItem.type) {
1311
+ const filterListCopy = core.ObjectUtils.copy(this.filters);
1312
+ filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
1313
+ this.filters = core.ObjectUtils.copy(filterListCopy);
1314
+ return;
1315
+ }
1316
+ this.filters.find(filter => filter.id === filterItem.id).value = undefined;
1317
+ }
1318
+ uncheckFilterValues(valueList) {
1319
+ valueList.forEach(value => {
1320
+ if (!!value) {
1321
+ value.check = false;
1322
+ }
1323
+ });
1324
+ return valueList;
1325
+ }
1326
+ renderFilterItem(filterItem, fullRow) {
1327
+ return (index$1.h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event.detail), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
1328
+ }
1329
+ isDefaultFilterNumberVariation(filter) {
1330
+ var _a;
1331
+ return filter.type === filterItemType_enum.FilterItemType.NUMBER
1332
+ && (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === filterNumberVariation.FilterNumberVariation.DEFAULT);
1333
+ }
1334
+ mountFiltersLines(filters) {
1335
+ const MAX_LINE_LENGTH = 2;
1336
+ let currentLine = 0;
1337
+ let forceAddCurrent = false;
1338
+ const filtersLines = {};
1339
+ for (let curr = 0; curr < filters.length; curr++) {
1340
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
1341
+ const item = filters[curr];
1342
+ const isLast = curr === filters.length - 1;
1343
+ const currentItemMatch = item.type === filterItemType_enum.FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
1344
+ const nextItemMatch = isLast ? false : filters[curr + 1].type === filterItemType_enum.FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
1345
+ if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
1346
+ filtersLines[currentLine].push(item);
1347
+ forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
1348
+ if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
1349
+ ++currentLine;
1350
+ continue;
1351
+ }
1352
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
1353
+ filtersLines[currentLine].push(item);
1354
+ ++currentLine;
1355
+ }
1356
+ return Object.values(filtersLines);
1357
+ }
1358
+ renderFilterLine(filters) {
1359
+ const fullLine = filters.length === 1;
1360
+ return filters.map((filter) => this.renderFilterItem(filter, fullLine));
1361
+ }
1362
+ getIformedFiltersCount(listItems) {
1363
+ let countInformedItens = 0;
1364
+ listItems.forEach(item => {
1365
+ var _a, _b, _c, _d, _e, _f;
1366
+ if (filterItemType_enum.FilterItemType.MULTI_LIST === item.type) {
1367
+ 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;
1368
+ return;
1369
+ }
1370
+ if (filterItemType_enum.FilterItemType.CHECK_BOX_LIST === item.type) {
1371
+ countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
1372
+ .filter(([_, value]) => value === true)
1373
+ .map(([key, _]) => key).length;
1374
+ return;
1375
+ }
1376
+ if (item.groupedItems != undefined) {
1377
+ countInformedItens = item.groupedItems.filter(item => item.visible).length;
1378
+ return;
1379
+ }
1380
+ if (!!item.value) {
1381
+ countInformedItens++;
1382
+ }
1383
+ });
1384
+ return countInformedItens;
1385
+ }
1386
+ renderCollapsibleFilterBox(label, listItems, isSingleItem, shouldRenderFooter = true) {
1387
+ if (!listItems.length)
1388
+ return null;
1389
+ const appliedFilters = this.getIformedFiltersCount(listItems);
1390
+ const lines = this.mountFiltersLines(listItems);
1391
+ return (index$1.h("ez-collapsible-box", { class: "snk-filter-modal__collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters && (index$1.h("ez-badge", { class: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toString() })), index$1.h("div", { class: "ez-row snk-filter-modal__rendered-items" }, lines.map(this.renderFilterLine.bind(this))), shouldRenderFooter && (index$1.h("div", { class: "ez-flex ez-flex--justify-end grow" }, index$1.h("ez-button", { class: "ez-button--tertiary", size: "medium", label: "Limpar", onClick: () => isSingleItem ? this.handleClearSigleFilter(listItems[0]) : this.handleClearFilterList(listItems) })))));
1392
+ }
1393
+ componentWillRender() {
1394
+ this._modalTitle = this.getCustomMessage('title');
1395
+ this._okButtonLabel = this.getCustomMessage('okButtonLabel');
1396
+ this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
1397
+ }
1398
+ componentDidLoad() {
1399
+ if (!this._originalFilterConfig)
1400
+ this._originalFilterConfig = this.filters;
1401
+ }
1402
+ render() {
1403
+ const customFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER);
1404
+ const quickFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.QUICK_FILTER);
1405
+ const otherFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.OTHER_FILTERS);
1406
+ return (index$1.h("ez-modal-container", { class: "snk-filter-modal__container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, index$1.h("div", { class: "snk-filter-modal__content ez-col--sd-12" }, !this.disablePersonalizedFilter && this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters, false, false), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters, false), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter], true)))));
1407
+ }
1408
+ };
1409
+ SnkFilterModal.style = snkFilterModalCss;
1410
+
726
1411
  exports.snk_filter_bar = SnkFilterBar;
1412
+ exports.snk_filter_item = SnkFilterItem;
1413
+ exports.snk_filter_list = SnkFilterList;
1414
+ exports.snk_filter_modal = SnkFilterModal;