@sankhyalabs/sankhyablocks 9.2.0-dev.17 → 9.2.0-dev.19

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 (189) hide show
  1. package/dist/cjs/{ConfigStorage-0ebc800f.js → ConfigStorage-52c38bb9.js} +2 -2
  2. package/dist/cjs/{DataFetcher-602cdc72.js → DataFetcher-9af55840.js} +15 -0
  3. package/dist/cjs/{ISave-18205d86.js → ISave-c4918000.js} +1 -1
  4. package/dist/cjs/{SnkFormConfigManager-4b651537.js → SnkFormConfigManager-cef663d1.js} +2 -2
  5. package/dist/cjs/{ClientSideExporterProvider-bb0b2273.js → SnkMultiSelectionListDataSource-58ded10c.js} +78 -78
  6. package/dist/cjs/{auth-fetcher-82317d4d.js → auth-fetcher-a3a3bb16.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-93077a2f.js → dataunit-fetcher-ae454648.js} +1 -1
  8. package/dist/cjs/filter-validate-6993f6f2.js +30 -0
  9. package/dist/cjs/{form-config-fetcher-05d210e7.js → form-config-fetcher-d7bb4f41.js} +1 -1
  10. package/dist/cjs/index-1cf293c1.js +8 -8
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +4 -4
  13. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  14. package/dist/cjs/snk-actions-button_8.cjs.entry.js +5 -5
  15. package/dist/cjs/snk-application.cjs.entry.js +6 -6
  16. package/dist/cjs/snk-attach.cjs.entry.js +5 -5
  17. package/dist/cjs/snk-crud.cjs.entry.js +5 -5
  18. package/dist/cjs/snk-data-exporter.cjs.entry.js +5 -5
  19. package/dist/cjs/{snk-data-unit-28d629e4.js → snk-data-unit-a59a7ade.js} +2 -2
  20. package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
  21. package/dist/cjs/snk-detail-view.cjs.entry.js +7 -7
  22. package/dist/cjs/snk-entity-list.cjs.entry.js +10 -3
  23. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +164 -100
  24. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +23 -2
  25. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +20 -2
  26. package/dist/cjs/snk-filter-detail.cjs.entry.js +25 -8
  27. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +9 -14
  28. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +16 -3
  29. package/dist/cjs/snk-filter-number.cjs.entry.js +34 -3
  30. package/dist/cjs/snk-filter-period.cjs.entry.js +59 -14
  31. package/dist/cjs/snk-filter-search.cjs.entry.js +14 -3
  32. package/dist/cjs/snk-filter-text.cjs.entry.js +18 -1
  33. package/dist/cjs/snk-form_2.cjs.entry.js +4 -4
  34. package/dist/cjs/snk-grid.cjs.entry.js +38 -21
  35. package/dist/cjs/{snk-guides-viewer-73d40f42.js → snk-guides-viewer-e7c08c71.js} +5 -5
  36. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
  37. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  38. package/dist/cjs/snk-pesquisa.cjs.entry.js +4 -4
  39. package/dist/cjs/snk-simple-crud.cjs.entry.js +13 -13
  40. package/dist/collection/components/snk-entity-list/snk-entity-list.js +28 -4
  41. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +72 -2
  42. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +73 -2
  43. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +51 -5
  44. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +83 -3
  45. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +118 -27
  46. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +49 -5
  47. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +71 -1
  48. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +62 -11
  49. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +70 -8
  50. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.css +0 -4
  51. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +112 -16
  52. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +8 -16
  53. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +106 -52
  54. package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +3 -1
  55. package/dist/collection/components/snk-filter-bar/utils/filter-validate.js +24 -0
  56. package/dist/collection/components/snk-grid/snk-grid.js +89 -11
  57. package/dist/collection/lib/message/resources/en-us/snk-filter-bar.msg.js +1 -0
  58. package/dist/collection/lib/message/resources/en-us/snk-grid.msg.js +4 -0
  59. package/dist/collection/lib/message/resources/es-es/snk-filter-bar.msg.js +1 -0
  60. package/dist/collection/lib/message/resources/es-es/snk-grid.msg.js +4 -0
  61. package/dist/collection/lib/message/resources/pt-br/snk-filter-bar.msg.js +1 -0
  62. package/dist/collection/lib/message/resources/pt-br/snk-grid.msg.js +4 -0
  63. package/dist/components/DataFetcher.js +15 -0
  64. package/dist/components/snk-crud.js +62 -44
  65. package/dist/components/snk-detail-view2.js +89 -56
  66. package/dist/components/snk-entity-list.js +11 -3
  67. package/dist/components/snk-filter-bar2.js +77 -93
  68. package/dist/components/snk-filter-binary-select.js +27 -3
  69. package/dist/components/snk-filter-checkbox-list.js +24 -3
  70. package/dist/components/snk-filter-detail2.js +28 -9
  71. package/dist/components/snk-filter-item2.js +70 -8
  72. package/dist/components/snk-filter-modal-item2.js +7 -12
  73. package/dist/components/snk-filter-modal.js +1 -325
  74. package/dist/components/snk-filter-modal2.js +391 -0
  75. package/dist/components/snk-filter-multi-select.js +19 -4
  76. package/dist/components/snk-filter-number.js +38 -4
  77. package/dist/components/snk-filter-period.js +64 -16
  78. package/dist/components/snk-filter-search.js +17 -4
  79. package/dist/components/snk-filter-text.js +22 -2
  80. package/dist/components/snk-grid2.js +65 -29
  81. package/dist/esm/{ConfigStorage-fc4e3a42.js → ConfigStorage-1e758486.js} +2 -2
  82. package/dist/esm/{DataFetcher-01ce1a4f.js → DataFetcher-2f7ba7ae.js} +15 -0
  83. package/dist/esm/{ISave-d36bade4.js → ISave-4c9742c1.js} +1 -1
  84. package/dist/esm/{SnkFormConfigManager-71dae34e.js → SnkFormConfigManager-d7031fcb.js} +2 -2
  85. package/dist/esm/{ClientSideExporterProvider-21a99af1.js → SnkMultiSelectionListDataSource-eace25fd.js} +83 -83
  86. package/dist/esm/{auth-fetcher-2e565c35.js → auth-fetcher-d8169b9c.js} +1 -1
  87. package/dist/esm/{dataunit-fetcher-14ba162b.js → dataunit-fetcher-1f7a73df.js} +1 -1
  88. package/dist/esm/filter-validate-d765d450.js +27 -0
  89. package/dist/esm/{form-config-fetcher-a1ccc944.js → form-config-fetcher-eb03ac08.js} +1 -1
  90. package/dist/esm/index-479e1293.js +8 -8
  91. package/dist/esm/loader.js +1 -1
  92. package/dist/esm/pesquisa-grid_2.entry.js +4 -4
  93. package/dist/esm/sankhyablocks.js +1 -1
  94. package/dist/esm/snk-actions-button_8.entry.js +5 -5
  95. package/dist/esm/snk-application.entry.js +6 -6
  96. package/dist/esm/snk-attach.entry.js +5 -5
  97. package/dist/esm/snk-crud.entry.js +5 -5
  98. package/dist/esm/snk-data-exporter.entry.js +5 -5
  99. package/dist/esm/{snk-data-unit-3977725e.js → snk-data-unit-a94dd52a.js} +2 -2
  100. package/dist/esm/snk-data-unit.entry.js +3 -3
  101. package/dist/esm/snk-detail-view.entry.js +7 -7
  102. package/dist/esm/snk-entity-list.entry.js +10 -3
  103. package/dist/esm/snk-filter-bar_4.entry.js +165 -101
  104. package/dist/esm/snk-filter-binary-select.entry.js +23 -2
  105. package/dist/esm/snk-filter-checkbox-list.entry.js +20 -2
  106. package/dist/esm/snk-filter-detail.entry.js +25 -8
  107. package/dist/esm/snk-filter-modal-item.entry.js +9 -14
  108. package/dist/esm/snk-filter-multi-select.entry.js +16 -3
  109. package/dist/esm/snk-filter-number.entry.js +34 -3
  110. package/dist/esm/snk-filter-period.entry.js +59 -14
  111. package/dist/esm/snk-filter-search.entry.js +14 -3
  112. package/dist/esm/snk-filter-text.entry.js +18 -1
  113. package/dist/esm/snk-form_2.entry.js +4 -4
  114. package/dist/esm/snk-grid.entry.js +31 -14
  115. package/dist/esm/{snk-guides-viewer-f800c9aa.js → snk-guides-viewer-e716659f.js} +5 -5
  116. package/dist/esm/snk-guides-viewer.entry.js +7 -7
  117. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  118. package/dist/esm/snk-pesquisa.entry.js +4 -4
  119. package/dist/esm/snk-simple-crud.entry.js +8 -8
  120. package/dist/sankhyablocks/p-093f58fa.entry.js +1 -0
  121. package/dist/sankhyablocks/{p-e63cc25f.js → p-0dc071de.js} +1 -1
  122. package/dist/sankhyablocks/{p-f4bf0517.entry.js → p-0f6f2a84.entry.js} +1 -1
  123. package/dist/sankhyablocks/{p-2b2c2718.js → p-1129ded7.js} +1 -1
  124. package/dist/sankhyablocks/p-12cba660.entry.js +1 -0
  125. package/dist/sankhyablocks/{p-51209229.js → p-12db5588.js} +1 -1
  126. package/dist/sankhyablocks/{p-65517fcf.js → p-3d4a3965.js} +1 -1
  127. package/dist/sankhyablocks/p-3ed04f0d.entry.js +1 -0
  128. package/dist/sankhyablocks/{p-b6b42620.entry.js → p-4033a6e3.entry.js} +1 -1
  129. package/dist/sankhyablocks/p-49ddc27a.entry.js +1 -0
  130. package/dist/sankhyablocks/{p-c3eea705.entry.js → p-4a42d004.entry.js} +1 -1
  131. package/dist/sankhyablocks/p-4c763b10.entry.js +1 -0
  132. package/dist/sankhyablocks/p-4eeb06fc.js +1 -0
  133. package/dist/sankhyablocks/{p-dc8bb41f.js → p-552bdfdc.js} +1 -1
  134. package/dist/sankhyablocks/{p-3cdfd7fb.js → p-66e6569e.js} +1 -1
  135. package/dist/sankhyablocks/p-6909c146.entry.js +1 -0
  136. package/dist/sankhyablocks/p-69d0afa4.js +1 -0
  137. package/dist/sankhyablocks/{p-c3bab5f4.js → p-75b80a92.js} +1 -1
  138. package/dist/sankhyablocks/p-7f7fe6c4.entry.js +1 -0
  139. package/dist/sankhyablocks/{p-e5571279.entry.js → p-86009ea5.entry.js} +1 -1
  140. package/dist/sankhyablocks/{p-7b97f9af.entry.js → p-864066bb.entry.js} +1 -1
  141. package/dist/sankhyablocks/p-96d45943.entry.js +1 -0
  142. package/dist/sankhyablocks/{p-34222890.entry.js → p-a0b4c940.entry.js} +1 -1
  143. package/dist/sankhyablocks/{p-a60028f1.entry.js → p-a4be272f.entry.js} +1 -1
  144. package/dist/sankhyablocks/p-ab2ba522.entry.js +1 -0
  145. package/dist/sankhyablocks/p-ac9488fd.entry.js +1 -0
  146. package/dist/sankhyablocks/{p-7a1d3cb6.entry.js → p-b1d8cbf7.entry.js} +1 -1
  147. package/dist/sankhyablocks/{p-7535d592.js → p-b393f1df.js} +1 -1
  148. package/dist/sankhyablocks/{p-dfbe4d7f.entry.js → p-c5d281ad.entry.js} +1 -1
  149. package/dist/sankhyablocks/{p-41e5a485.entry.js → p-c6d8c86b.entry.js} +1 -1
  150. package/dist/sankhyablocks/p-cb4343c4.entry.js +1 -0
  151. package/dist/sankhyablocks/p-d235314c.entry.js +1 -0
  152. package/dist/sankhyablocks/{p-dde9da7a.entry.js → p-d76f1aa5.entry.js} +1 -1
  153. package/dist/sankhyablocks/{p-aba06047.entry.js → p-de58a26f.entry.js} +1 -1
  154. package/dist/sankhyablocks/p-e258de96.entry.js +1 -0
  155. package/dist/sankhyablocks/p-fd8047b8.js +1 -0
  156. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  157. package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +8 -4
  158. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
  159. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.d.ts +12 -0
  160. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +12 -4
  161. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +16 -4
  162. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +17 -3
  163. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +10 -2
  164. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +12 -0
  165. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +8 -3
  166. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +27 -4
  167. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +17 -3
  168. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +2 -3
  169. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +15 -2
  170. package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +4 -2
  171. package/dist/types/components/snk-filter-bar/utils/filter-validate.d.ts +11 -0
  172. package/dist/types/components/snk-grid/snk-grid.d.ts +21 -8
  173. package/dist/types/components.d.ts +202 -17
  174. package/package.json +1 -1
  175. package/dist/sankhyablocks/p-07b14811.entry.js +0 -1
  176. package/dist/sankhyablocks/p-082e7ba8.entry.js +0 -1
  177. package/dist/sankhyablocks/p-25209340.entry.js +0 -1
  178. package/dist/sankhyablocks/p-295b83ae.entry.js +0 -1
  179. package/dist/sankhyablocks/p-3143bb44.entry.js +0 -1
  180. package/dist/sankhyablocks/p-353b4a74.js +0 -1
  181. package/dist/sankhyablocks/p-398cdd67.entry.js +0 -1
  182. package/dist/sankhyablocks/p-5bab470d.entry.js +0 -1
  183. package/dist/sankhyablocks/p-9fd87bfd.entry.js +0 -1
  184. package/dist/sankhyablocks/p-a76e6d51.entry.js +0 -1
  185. package/dist/sankhyablocks/p-ae2ebab7.js +0 -1
  186. package/dist/sankhyablocks/p-b21aa190.entry.js +0 -1
  187. package/dist/sankhyablocks/p-c6a8a8bc.entry.js +0 -1
  188. package/dist/sankhyablocks/p-c8932b14.entry.js +0 -1
  189. package/dist/sankhyablocks/p-dff65083.entry.js +0 -1
@@ -0,0 +1,391 @@
1
+ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
+ import { ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
3
+ import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
4
+ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
5
+ import { P as PersonalizedFilterUtils, D as DefaultFilter } from './PersonalizedFilterUtils.js';
6
+ import { F as FilterNumberVariation } from './filterNumberVariation.js';
7
+ import { F as FilterItemType } from './filter-item-type.enum.js';
8
+ import { A as ActionDefaultFilter, d as defineCustomElement$2 } from './snk-default-filter2.js';
9
+ import { F as FilterType, d as defineCustomElement$1 } from './snk-filter-modal-item2.js';
10
+
11
+ function hasActiveElements(value) {
12
+ var _a;
13
+ const list = Array.isArray(value) ? value : value === null || value === void 0 ? void 0 : value.elements;
14
+ return ((_a = list === null || list === void 0 ? void 0 : list.filter((val) => val === null || val === void 0 ? void 0 : val.check)) === null || _a === void 0 ? void 0 : _a.length) > 0;
15
+ }
16
+ function getInvalidFilters(filters) {
17
+ return filters.filter(item => {
18
+ if (!item.required) {
19
+ return false;
20
+ }
21
+ if (item.type === FilterItemType.MULTI_LIST) {
22
+ return !hasActiveElements(item.value);
23
+ }
24
+ return !item.value;
25
+ });
26
+ }
27
+ function validateFilters(filters) {
28
+ const notValidFilters = getInvalidFilters(filters);
29
+ if (notValidFilters.length === 0) {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+
35
+ const snkFilterModalCss = "ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{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}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";
36
+
37
+ const SnkFilterModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
38
+ constructor() {
39
+ super();
40
+ this.__registerHost();
41
+ this.filters = [];
42
+ this.filtersWithError = [];
43
+ this.getMessage = undefined;
44
+ this.configName = undefined;
45
+ this.filterConfig = undefined;
46
+ this.opened = false;
47
+ this.applyFilters = undefined;
48
+ this.closeModal = undefined;
49
+ this.addPersonalizedFilter = undefined;
50
+ this.editPersonalizedFilter = undefined;
51
+ this.deletePersonalizedFilter = undefined;
52
+ this.filtersToDelete = [];
53
+ this.filterDefaultToDelete = undefined;
54
+ this.disablePersonalizedFilter = undefined;
55
+ this.filterCustomConfigInterceptor = undefined;
56
+ }
57
+ filterConfigChangeHandler(newValue) {
58
+ this.filters = ObjectUtils.copy(newValue);
59
+ this.validateFilters();
60
+ }
61
+ /**
62
+ * Emitido quando um filtro personalizado é deletado.
63
+ */
64
+ deletePersonalizedFilterListener(event) {
65
+ this.filtersToDelete.push(event.detail);
66
+ }
67
+ getCustomMessage(key, params) {
68
+ var _a;
69
+ return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
70
+ }
71
+ //TODO: tratar clear all dos filtros personalizados
72
+ handleClearAll() {
73
+ const { customFilters, quickFilters, otherFilters, multiListFilters } = this.filters.reduce((acc, filter) => {
74
+ if (filter.type === FilterItemType.MULTI_LIST) {
75
+ acc.multiListFilters.push(filter);
76
+ return acc;
77
+ }
78
+ if (filter.filterType === FilterType.QUICK_FILTER) {
79
+ acc.quickFilters.push(filter);
80
+ return acc;
81
+ }
82
+ if (filter.filterType === FilterType.CUSTOM_FILTER) {
83
+ acc.customFilters.push(filter);
84
+ return acc;
85
+ }
86
+ if (filter.filterType === FilterType.OTHER_FILTERS) {
87
+ acc.otherFilters.push(filter);
88
+ return acc;
89
+ }
90
+ return acc;
91
+ }, { quickFilters: [], customFilters: [], otherFilters: [], multiListFilters: [] });
92
+ this.handleClearFilterList(quickFilters);
93
+ this.handleClearCustomFilters(customFilters);
94
+ this.handleClearOthersFilters(otherFilters);
95
+ multiListFilters.forEach(multiListFilter => this.handleClearSigleFilter(multiListFilter));
96
+ }
97
+ handleClearOthersFilters(otherFilters) {
98
+ this.filters = this.filters.map(filter => otherFilters.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
99
+ }
100
+ handleClearCustomFilters(customFilters) {
101
+ this.filters.forEach((filter, index) => {
102
+ if (filter.filterType === FilterType.CUSTOM_FILTER)
103
+ this.filters[index] = this.clearAllCustomFilter(customFilters).shift();
104
+ });
105
+ }
106
+ clearAllCustomFilter(filterConfigSnapshot) {
107
+ return filterConfigSnapshot.map(filterItem => {
108
+ const copy = Object.assign({}, filterItem);
109
+ delete copy.value;
110
+ copy.visible = false;
111
+ if (copy.groupedItems) {
112
+ copy.groupedItems = this.clearAllCustomFilter(copy.groupedItems);
113
+ }
114
+ return copy;
115
+ });
116
+ }
117
+ hasChangeToSave() {
118
+ const hasChangesPersonalizedFilters = ObjectUtils.objectToString(this.filters) !== ObjectUtils.objectToString(this.filters);
119
+ return hasChangesPersonalizedFilters;
120
+ }
121
+ handleClose() {
122
+ const hasChangesToSave = this.hasChangeToSave();
123
+ if (!hasChangesToSave) {
124
+ this.closeModal();
125
+ return;
126
+ }
127
+ return ApplicationUtils.confirm(this.getCustomMessage('validations.notSaved.title'), this.getCustomMessage('validations.notSaved.message')).then((cancelAction) => {
128
+ if (cancelAction)
129
+ this.closeModal();
130
+ });
131
+ }
132
+ handleApplyFilters() {
133
+ if (!this.validateFilters()) {
134
+ return;
135
+ }
136
+ const filterPersonalized = this.filters.find(filter => filter.filterType === FilterType.CUSTOM_FILTER || filter.filterType === FilterType.DEFAULT_FILTER);
137
+ if (this.isValidCustomFilter(filterPersonalized)) {
138
+ this.applyFilters(this.filters);
139
+ }
140
+ if (this.filtersToDelete.length > 0) {
141
+ this.filtersToDelete.forEach(filter => {
142
+ this.deletePersonalizedFilter(filter, this.configName);
143
+ });
144
+ this.filtersToDelete = [];
145
+ }
146
+ if (this.filterDefaultToDelete) {
147
+ this.deletePersonalizedFilter(this.filterDefaultToDelete, this.configName, true);
148
+ this._defaultFilter = undefined;
149
+ this.filterDefaultToDelete = undefined;
150
+ }
151
+ }
152
+ isValidCustomFilter(filterPersonalized) {
153
+ const isValid = PersonalizedFilterUtils.validateVariableValues(filterPersonalized);
154
+ if (!isValid) {
155
+ ApplicationUtils.alert(this.getCustomMessage('validations.notFullFilled.title'), this.getCustomMessage('validations.notFullFilled.message'));
156
+ return false;
157
+ }
158
+ return true;
159
+ }
160
+ modalActionListener(evt) {
161
+ const modalAction = evt.detail;
162
+ switch (modalAction) {
163
+ case ModalAction.CANCEL:
164
+ this.handleClearAll();
165
+ break;
166
+ case ModalAction.OK:
167
+ this.handleApplyFilters();
168
+ break;
169
+ case ModalAction.CLOSE:
170
+ this.handleClose();
171
+ break;
172
+ }
173
+ }
174
+ handleFilterChange(event) {
175
+ event.stopPropagation();
176
+ const filterConfig = event.detail;
177
+ let config = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
178
+ if (this.filterCustomConfigInterceptor) {
179
+ config = this.filterCustomConfigInterceptor(config);
180
+ }
181
+ this.filters = ObjectUtils.copy(config);
182
+ }
183
+ handleClearFilterList(filterList) {
184
+ this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
185
+ }
186
+ handleClearSigleFilter(filterItem) {
187
+ if (FilterItemType.MULTI_LIST === filterItem.type) {
188
+ let filterItemCopy = ObjectUtils.copy(filterItem);
189
+ this.uncheckFilterValues(filterItemCopy.value);
190
+ const filterListCopy = ObjectUtils.copy(this.filters);
191
+ const index = filterListCopy.findIndex(item => item.id === filterItem.id);
192
+ filterListCopy.splice(index, 1, filterItemCopy);
193
+ this.filters = ObjectUtils.copy(filterListCopy);
194
+ return;
195
+ }
196
+ if (FilterItemType.CHECK_BOX_LIST === filterItem.type) {
197
+ const filterListCopy = ObjectUtils.copy(this.filters);
198
+ filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
199
+ this.filters = ObjectUtils.copy(filterListCopy);
200
+ return;
201
+ }
202
+ const filter = this.filters.find(filter => filter.id === filterItem.id);
203
+ filter.value = undefined;
204
+ this.filters = ObjectUtils.copy(this.filters);
205
+ }
206
+ uncheckFilterValues(valueList) {
207
+ valueList.forEach(value => {
208
+ if (!!value) {
209
+ value.check = false;
210
+ }
211
+ });
212
+ return valueList;
213
+ }
214
+ validateFilters() {
215
+ const notValidFilters = getInvalidFilters(this.filters);
216
+ this.filtersWithError = notValidFilters.map(item => item.id);
217
+ if (notValidFilters.length === 0) {
218
+ return true;
219
+ }
220
+ notValidFilters.forEach(item => {
221
+ const filterItem = this._element.querySelector(`#filter-item-${item.id}`);
222
+ if (filterItem) {
223
+ filterItem["errorMessage"] = item.requiredMessage || this.getCustomMessage('validations.requiredFilter');
224
+ }
225
+ });
226
+ return false;
227
+ }
228
+ renderFilterItem(filterItem, fullRow) {
229
+ return (h("snk-filter-modal-item", { key: `modal-item-${filterItem.id}`, 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), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
230
+ }
231
+ isDefaultFilterNumberVariation(filter) {
232
+ var _a;
233
+ return filter.type === FilterItemType.NUMBER
234
+ && (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === FilterNumberVariation.DEFAULT);
235
+ }
236
+ mountFiltersLines(filters) {
237
+ const MAX_LINE_LENGTH = 2;
238
+ let currentLine = 0;
239
+ let forceAddCurrent = false;
240
+ const filtersLines = {};
241
+ for (let curr = 0; curr < filters.length; curr++) {
242
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
243
+ const item = filters[curr];
244
+ const isLast = curr === filters.length - 1;
245
+ const currentItemMatch = item.type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
246
+ const nextItemMatch = isLast ? false : filters[curr + 1].type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
247
+ if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
248
+ filtersLines[currentLine].push(item);
249
+ forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
250
+ if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
251
+ ++currentLine;
252
+ continue;
253
+ }
254
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
255
+ filtersLines[currentLine].push(item);
256
+ ++currentLine;
257
+ }
258
+ return Object.values(filtersLines);
259
+ }
260
+ renderFilterLine(filters) {
261
+ const fullLine = filters.length === 1;
262
+ return filters.map((filter) => this.renderFilterItem(filter, fullLine));
263
+ }
264
+ getIformedFiltersCount(listItems) {
265
+ let countInformedItens = 0;
266
+ listItems.forEach(localItem => {
267
+ var _a, _b, _c, _d, _e, _f;
268
+ const item = this.filterConfig.find(filter => filter.id === localItem.id);
269
+ if (FilterItemType.MULTI_LIST === item.type) {
270
+ 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;
271
+ return;
272
+ }
273
+ if (FilterItemType.CHECK_BOX_LIST === item.type) {
274
+ countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
275
+ .filter(([_, value]) => value === true)
276
+ .map(([key, _]) => key).length;
277
+ return;
278
+ }
279
+ if (item.groupedItems != undefined) {
280
+ countInformedItens = item.groupedItems.filter(item => item.visible).length;
281
+ return;
282
+ }
283
+ if (!!item.value) {
284
+ countInformedItens++;
285
+ }
286
+ });
287
+ return countInformedItens;
288
+ }
289
+ renderCollapsibleFilterBox(label, listItems, isSingleItem, shouldRenderFooter = true) {
290
+ if (!listItems.length)
291
+ return null;
292
+ const appliedFilters = this.getIformedFiltersCount(listItems);
293
+ const lines = this.mountFiltersLines(listItems);
294
+ const countFiltersWithError = this.filtersWithError.filter(item => listItems.some(filter => filter.id === item)).length;
295
+ return (h("ez-collapsible-box", { class: "snk-filter-modal__collapsible-box", headerSize: "medium", value: true, label: label }, h("div", { class: "ez-flex ez-flex--justify-end grow", slot: "rightSlot" }, !!appliedFilters && (h("ez-badge", { class: "ez-badge--primary-subtle", label: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toString() })), !!countFiltersWithError && (h("ez-badge", { class: "ez-badge--error-subtle", label: countFiltersWithError === null || countFiltersWithError === void 0 ? void 0 : countFiltersWithError.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: this.getCustomMessage("clearModal"), onClick: () => isSingleItem ? this.handleClearSigleFilter(listItems[0]) : this.handleClearFilterList(listItems) })))));
296
+ }
297
+ handleDeleteFilter() {
298
+ this._application.confirm(this.getMessage('snkPersonalizedFilter.deleteConfirm.title'), this.getMessage('snkPersonalizedFilter.info.deleteDefaultFilterConfirm'), "alert-circle-inverted", "critical").then((actionConfirmed) => {
299
+ if (!actionConfirmed) {
300
+ return;
301
+ }
302
+ this.filterDefaultToDelete = this._defaultFilter;
303
+ this.filters = this.filters.filter(filter => filter.id !== FilterType.DEFAULT_FILTER);
304
+ });
305
+ }
306
+ handleActionSelectedDefaultFilter({ detail: action }) {
307
+ switch (action) {
308
+ case ActionDefaultFilter.CREATE:
309
+ this.addPersonalizedFilter(true);
310
+ break;
311
+ case ActionDefaultFilter.EDIT:
312
+ this.editPersonalizedFilter(this._defaultFilter.id, true);
313
+ break;
314
+ case ActionDefaultFilter.REMOVE:
315
+ this.handleDeleteFilter();
316
+ break;
317
+ }
318
+ }
319
+ getCustomFilter(filters) {
320
+ const customFilters = filters.filter((filter) => filter.filterType === FilterType.CUSTOM_FILTER);
321
+ return customFilters;
322
+ }
323
+ getDefaultFilter(filters) {
324
+ const defaultFilter = filters.find((item) => item.id === DefaultFilter.id);
325
+ return defaultFilter;
326
+ }
327
+ componentWillLoad() {
328
+ this._application = ApplicationContext.getContextValue('__SNK__APPLICATION__');
329
+ this.filters = ObjectUtils.copy(this.filterConfig);
330
+ }
331
+ componentWillRender() {
332
+ this._modalTitle = this.getCustomMessage('title');
333
+ this._okButtonLabel = this.getCustomMessage('okButtonLabel');
334
+ this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
335
+ }
336
+ componentDidLoad() {
337
+ this.validateFilters();
338
+ }
339
+ render() {
340
+ this._defaultFilter = this.getDefaultFilter(this.filters);
341
+ const customFilters = this.getCustomFilter(this.filters);
342
+ const quickFilters = this.filters.filter(filter => filter.filterType === FilterType.QUICK_FILTER);
343
+ const otherFilters = this.filters.filter(filter => filter.filterType === FilterType.OTHER_FILTERS);
344
+ return (h("ez-modal", { opened: this.opened, modalSize: "col--sd-3", align: "right", heightMode: "full", closeEsc: true }, 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" }, h("snk-default-filter", { getMessage: this.getCustomMessage.bind(this), hasDefaultFilter: !!this._defaultFilter, onActionSelected: this.handleActionSelectedDefaultFilter.bind(this) }), !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))))));
345
+ }
346
+ get _element() { return this; }
347
+ static get watchers() { return {
348
+ "filterConfig": ["filterConfigChangeHandler"]
349
+ }; }
350
+ static get style() { return snkFilterModalCss; }
351
+ }, [0, "snk-filter-modal", {
352
+ "getMessage": [16],
353
+ "configName": [1025, "config-name"],
354
+ "filterConfig": [1040],
355
+ "opened": [4],
356
+ "applyFilters": [16],
357
+ "closeModal": [16],
358
+ "addPersonalizedFilter": [16],
359
+ "editPersonalizedFilter": [16],
360
+ "deletePersonalizedFilter": [16],
361
+ "filtersToDelete": [1040],
362
+ "filterDefaultToDelete": [1040],
363
+ "disablePersonalizedFilter": [4, "disable-personalized-filter"],
364
+ "filterCustomConfigInterceptor": [16],
365
+ "filtersWithError": [32]
366
+ }, [[0, "deleteFilter", "deletePersonalizedFilterListener"]]]);
367
+ function defineCustomElement() {
368
+ if (typeof customElements === "undefined") {
369
+ return;
370
+ }
371
+ const components = ["snk-filter-modal", "snk-default-filter", "snk-filter-modal-item"];
372
+ components.forEach(tagName => { switch (tagName) {
373
+ case "snk-filter-modal":
374
+ if (!customElements.get(tagName)) {
375
+ customElements.define(tagName, SnkFilterModal);
376
+ }
377
+ break;
378
+ case "snk-default-filter":
379
+ if (!customElements.get(tagName)) {
380
+ defineCustomElement$2();
381
+ }
382
+ break;
383
+ case "snk-filter-modal-item":
384
+ if (!customElements.get(tagName)) {
385
+ defineCustomElement$1();
386
+ }
387
+ break;
388
+ } });
389
+ }
390
+
391
+ export { SnkFilterModal as S, defineCustomElement as d, validateFilters as v };
@@ -9,21 +9,32 @@ const SnkFilterMultiSelect$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
9
9
  this.valueChanged = createEvent(this, "valueChanged", 7);
10
10
  this.value = undefined;
11
11
  this.config = undefined;
12
+ this.errorMessage = undefined;
12
13
  }
13
14
  /**
14
15
  * Emitido quando acontece a alteração de valor do componente snk-filter-multi-select
15
16
  */
16
17
  ezChangeListener(evt) {
17
18
  var _a;
19
+ this.errorMessage = undefined;
18
20
  this.value = (_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value;
19
21
  this.valueChanged.emit(this.value);
20
22
  }
21
23
  /**
22
- * Exibe o componente snk-filter-multi-select
24
+ * Define o foco no componente snk-filter-multi-select.
23
25
  */
24
- async show() {
26
+ async setFocus() {
25
27
  this._comboElement.setFocus();
26
28
  }
29
+ /**
30
+ * Limpa o valor do componente restaurando o valor original da configuração.
31
+ */
32
+ async clearValue() {
33
+ this.value = this.config.value;
34
+ if (this._comboElement) {
35
+ this._comboElement.value = this.config.value;
36
+ }
37
+ }
27
38
  componentDidLoad() {
28
39
  if (this._element) {
29
40
  ElementIDUtils.addIDInfo(this._element, 'filterContentEditor');
@@ -33,13 +44,17 @@ const SnkFilterMultiSelect$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
33
44
  if (!this.config || this.config.type !== FilterItemType.MULTI_SELECT) {
34
45
  return undefined;
35
46
  }
36
- return (h("ez-combo-box", { id: this.config.id, ref: ref => this._comboElement = ref, label: this.config.label, value: this.config.value, options: this.config.props.options }));
47
+ return (h("ez-tooltip", { active: this.config.enabled === false, message: this.config.disabledMessage, type: 'warning' }, h("ez-combo-box", { id: this.config.id, ref: ref => this._comboElement = ref, label: this.config.label, value: this.config.value, options: this.config.props.options, enabled: this.config.enabled, errorMessage: this.errorMessage, onEzVisibilityChange: (event) => {
48
+ event.stopPropagation();
49
+ } })));
37
50
  }
38
51
  get _element() { return this; }
39
52
  }, [0, "snk-filter-multi-select", {
40
53
  "value": [1544],
41
54
  "config": [16],
42
- "show": [64]
55
+ "errorMessage": [1537, "error-message"],
56
+ "setFocus": [64],
57
+ "clearValue": [64]
43
58
  }, [[0, "ezChange", "ezChangeListener"]]]);
44
59
  function defineCustomElement$1() {
45
60
  if (typeof customElements === "undefined") {
@@ -1,8 +1,8 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { F as FilterItemType } from './filter-item-type.enum.js';
4
- import { E as EPresentationMode } from './presentationMode.js';
5
4
  import { F as FilterNumberVariation } from './filterNumberVariation.js';
5
+ import { E as EPresentationMode } from './presentationMode.js';
6
6
 
7
7
  const SnkFilterPeriod = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
8
8
  constructor() {
@@ -16,11 +16,13 @@ const SnkFilterPeriod = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
16
16
  this.getMessage = undefined;
17
17
  this.value = undefined;
18
18
  this.presentationMode = EPresentationMode.CHIP;
19
+ this.errorMessage = undefined;
19
20
  }
20
21
  /**
21
22
  * Emitido quando acontece a alteração de valor do componente snk-filter-number
22
23
  */
23
24
  ezChangeListener(evt) {
25
+ this.errorMessage = undefined;
24
26
  if (this.getVariation() === FilterNumberVariation.INTERVAL) {
25
27
  const start = this._startInterval.value;
26
28
  const end = this._endInterval.value;
@@ -41,6 +43,35 @@ const SnkFilterPeriod = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
41
43
  }
42
44
  this._numberElement.setFocus();
43
45
  }
46
+ /**
47
+ * Define o foco no componente snk-filter-number
48
+ */
49
+ async setFocus() {
50
+ if (this.getVariation() === FilterNumberVariation.INTERVAL) {
51
+ await this._startInterval.setFocus();
52
+ return;
53
+ }
54
+ await this._numberElement.setFocus();
55
+ }
56
+ /**
57
+ * Limpa o valor do componente restaurando o valor original da configuração.
58
+ */
59
+ async clearValue() {
60
+ var _a, _b;
61
+ this.value = this.config.value;
62
+ if (this.getVariation() === FilterNumberVariation.INTERVAL) {
63
+ const intervalValue = this.config.value;
64
+ if (this._startInterval) {
65
+ this._startInterval.value = (_a = intervalValue === null || intervalValue === void 0 ? void 0 : intervalValue.start) !== null && _a !== void 0 ? _a : null;
66
+ }
67
+ if (this._endInterval) {
68
+ this._endInterval.value = (_b = intervalValue === null || intervalValue === void 0 ? void 0 : intervalValue.end) !== null && _b !== void 0 ? _b : null;
69
+ }
70
+ }
71
+ else if (this._numberElement) {
72
+ this._numberElement.value = this.config.value;
73
+ }
74
+ }
44
75
  getIntervalValue(prop) {
45
76
  const objValue = this.value ? this.value[prop] : null;
46
77
  return objValue !== null && objValue !== void 0 ? objValue : null;
@@ -72,9 +103,9 @@ const SnkFilterPeriod = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
72
103
  return undefined;
73
104
  }
74
105
  if (this.getVariation() === FilterNumberVariation.INTERVAL) {
75
- return (h("div", { class: "ez-col ez-col--nowrap" }, h("ez-number-input", { id: `${this.config.id}_start`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding--small' : '', label: this._startIntervalLabel, ref: ref => this._startInterval = ref, value: this.getIntervalValue("start"), precision: (_a = this.config.props) === null || _a === void 0 ? void 0 : _a.precision }), this.buildLabel(), h("ez-number-input", { id: `${this.config.id}_end`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding--small' : '', label: this._endIntervalLabel, ref: ref => this._endInterval = ref, value: this.getIntervalValue("end"), precision: (_b = this.config.props) === null || _b === void 0 ? void 0 : _b.precision })));
106
+ return (h("ez-tooltip", { active: this.config.enabled === false, message: this.config.disabledMessage, type: 'warning' }, h("div", { class: "ez-col ez-col--nowrap" }, h("ez-number-input", { id: `${this.config.id}_start`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding-right--medium' : '', label: this._startIntervalLabel, ref: ref => this._startInterval = ref, value: this.getIntervalValue("start"), enabled: this.config.enabled, precision: (_a = this.config.props) === null || _a === void 0 ? void 0 : _a.precision, errorMessage: this.errorMessage }), this.buildLabel(), h("ez-number-input", { id: `${this.config.id}_end`, label: this._endIntervalLabel, ref: ref => this._endInterval = ref, value: this.getIntervalValue("end"), enabled: this.config.enabled, precision: (_b = this.config.props) === null || _b === void 0 ? void 0 : _b.precision, errorMessage: this.errorMessage }))));
76
107
  }
77
- return (h("ez-number-input", { id: this.config.id, ref: ref => this._numberElement = ref, label: this.config.label, value: this.config.value, precision: (_c = this.config.props) === null || _c === void 0 ? void 0 : _c.precision }));
108
+ return (h("ez-tooltip", { active: this.config.enabled === false, message: this.config.disabledMessage, type: 'warning' }, h("ez-number-input", { id: this.config.id, ref: ref => this._numberElement = ref, value: this.config.value, precision: (_c = this.config.props) === null || _c === void 0 ? void 0 : _c.precision, enabled: this.config.enabled, errorMessage: this.errorMessage })));
78
109
  }
79
110
  get _element() { return this; }
80
111
  }, [0, "snk-filter-number", {
@@ -82,7 +113,10 @@ const SnkFilterPeriod = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
82
113
  "getMessage": [16],
83
114
  "value": [2],
84
115
  "presentationMode": [2, "presentation-mode"],
85
- "show": [64]
116
+ "errorMessage": [1537, "error-message"],
117
+ "show": [64],
118
+ "setFocus": [64],
119
+ "clearValue": [64]
86
120
  }, [[0, "ezChange", "ezChangeListener"]]]);
87
121
  function defineCustomElement$1() {
88
122
  if (typeof customElements === "undefined") {
@@ -11,37 +11,77 @@ const SnkFilterPeriod$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
11
11
  this._startDateLabel = 'Inicial';
12
12
  this._endDateLabel = 'Final';
13
13
  this._toLabel = 'até';
14
+ this.internalChange = {
15
+ start: false,
16
+ end: false
17
+ };
14
18
  this.config = undefined;
15
19
  this.getMessage = undefined;
16
- this.value = undefined;
20
+ this.value = {
21
+ start: null,
22
+ end: null
23
+ };
17
24
  this.presentationMode = EPresentationMode.CHIP;
25
+ this.errorMessage = undefined;
26
+ }
27
+ configChanged(newValue, oldValue) {
28
+ if (this.internalChange.end) {
29
+ this.internalChange.end = false;
30
+ return;
31
+ }
32
+ if (this.internalChange.start) {
33
+ this.internalChange.start = false;
34
+ return;
35
+ }
36
+ if (newValue && (newValue.start !== (oldValue === null || oldValue === void 0 ? void 0 : oldValue.start) || newValue.end !== (oldValue === null || oldValue === void 0 ? void 0 : oldValue.end))) {
37
+ this.valueStart = this.parseDate(newValue.start);
38
+ this.valueEnd = this.parseDate(newValue.end);
39
+ }
40
+ }
41
+ ezChangeListener(event, field) {
42
+ this.errorMessage = undefined;
43
+ this.internalChange[field] = true;
44
+ this.value = Object.assign(Object.assign({}, (this.value || {})), { [field]: event.detail ? this.parseDate(event.detail) : null });
45
+ this.valueChanged.emit(this.value);
18
46
  }
19
47
  /**
20
- * Emitido quando acontece a alteração de valor do componente snk-filter-period
48
+ * Define o foco no componente snk-filter-period.
21
49
  */
22
- ezChangeListener() {
23
- const start = this._startDate.value;
24
- const end = this._endDate.value;
25
- this.value = (start || end ? { start, end } : undefined);
26
- this.valueChanged.emit(this.value);
50
+ async setFocus() {
51
+ this._startDate.setFocus();
52
+ }
53
+ /**
54
+ * Limpa o valor do componente restaurando o valor original da configuração.
55
+ */
56
+ async clearValue() {
57
+ this.value = this.config.value;
58
+ this.valueStart = this.getDate("start");
59
+ this.valueEnd = this.getDate("end");
27
60
  }
28
61
  componentDidLoad() {
29
62
  if (this._element) {
30
63
  ElementIDUtils.addIDInfo(this._element, 'filterContentEditor');
64
+ this._element.querySelectorAll('ez-date-input').forEach(input => {
65
+ const textInput = input.shadowRoot.querySelector('ez-text-input');
66
+ textInput.style.setProperty('--ez-text-input__min-width', '120px');
67
+ });
31
68
  }
32
69
  }
33
- getDate(prop) {
34
- const objValue = this.value ? this.value[prop] : null;
35
- if (objValue instanceof Date) {
36
- return objValue;
70
+ parseDate(date) {
71
+ if (date instanceof Date) {
72
+ return date;
37
73
  }
38
- if (typeof objValue === "string") {
39
- let date = new Date(objValue);
74
+ if (typeof date === "string") {
75
+ date = new Date(date);
40
76
  date.setMinutes(date.getMinutes() + date.getTimezoneOffset());
41
77
  return date;
42
78
  }
43
79
  return null;
44
80
  }
81
+ getDate(prop) {
82
+ const objValue = this.value ? this.value[prop] : null;
83
+ return this.parseDate(objValue);
84
+ }
45
85
  /**
46
86
  * Exibe o componente snk-filter-period
47
87
  */
@@ -59,21 +99,29 @@ const SnkFilterPeriod$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
59
99
  this._endDateLabel = this.getMessage('snkFilterBar.labelEnd');
60
100
  this._toLabel = this.getMessage('snkFilterBar.labelTo');
61
101
  }
102
+ this.valueStart = this.getDate("start");
103
+ this.valueEnd = this.getDate("end");
62
104
  }
63
105
  render() {
64
106
  if (!this.config || this.config.type !== FilterItemType.PERIOD) {
65
107
  return undefined;
66
108
  }
67
- return (h("div", { class: "ez-col ez-col--nowrap" }, h("ez-date-input", { id: `${this.config.id}_start`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding--small' : '', label: this._startDateLabel, ref: ref => this._startDate = ref, value: this.getDate("start") }), this.buildLabel(), h("ez-date-input", { id: `${this.config.id}_end`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding--small' : '', label: this._endDateLabel, ref: ref => this._endDate = ref, value: this.getDate("end") })));
109
+ return (h("ez-tooltip", { active: this.config.enabled === false, message: this.config.disabledMessage, type: 'warning' }, h("div", { class: "ez-col ez-col--nowrap" }, h("ez-date-input", { id: `${this.config.id}_start`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding-right--medium' : '', label: this._startDateLabel, ref: ref => this._startDate = ref, enabled: this.config.enabled, value: this.valueStart, errorMessage: this.errorMessage, onEzChange: (event) => this.ezChangeListener(event, 'start') }), this.buildLabel(), h("ez-date-input", { id: `${this.config.id}_end`, label: this._endDateLabel, ref: ref => this._endDate = ref, enabled: this.config.enabled, value: this.valueEnd, errorMessage: this.errorMessage, onEzChange: (event) => this.ezChangeListener(event, 'end') }))));
68
110
  }
69
111
  get _element() { return this; }
112
+ static get watchers() { return {
113
+ "value": ["configChanged"]
114
+ }; }
70
115
  }, [0, "snk-filter-period", {
71
116
  "config": [16],
72
117
  "getMessage": [16],
73
- "value": [8],
118
+ "value": [1040],
74
119
  "presentationMode": [2, "presentation-mode"],
120
+ "errorMessage": [1537, "error-message"],
121
+ "setFocus": [64],
122
+ "clearValue": [64],
75
123
  "show": [64]
76
- }, [[0, "ezChange", "ezChangeListener"]]]);
124
+ }]);
77
125
  function defineCustomElement$1() {
78
126
  if (typeof customElements === "undefined") {
79
127
  return;