@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
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { DateUtils, MaskFormatter, ElementIDUtils } from '@sankhyalabs/core';
3
- import { F as FilterItemType } from './filter-item-type.enum.js';
2
+ import { DateUtils, MaskFormatter, ElementIDUtils, KeyboardManager } from '@sankhyalabs/core';
4
3
  import { F as FilterNumberVariation } from './filterNumberVariation.js';
4
+ import { F as FilterItemType } from './filter-item-type.enum.js';
5
5
  import { d as defineCustomElement$1 } from './snk-filter-detail2.js';
6
6
 
7
7
  const snkFilterItemCss = "ez-popover-core.sc-snk-filter-item{--ez-popover__box--z-index:var(--elevation--20, 20);--ez-popover__box--overlay-z-index:var(--elevation--16, 16)}";
@@ -12,6 +12,7 @@ const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
12
12
  this.__registerHost();
13
13
  this.visibleChanged = createEvent(this, "visibleChanged", 7);
14
14
  this.filterChange = createEvent(this, "filterChange", 3);
15
+ this._keyboardManager = undefined;
15
16
  this.detailIsVisible = undefined;
16
17
  this.config = undefined;
17
18
  this.getMessage = undefined;
@@ -35,13 +36,15 @@ const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
35
36
  if (open) {
36
37
  await ((_a = this._chipElement) === null || _a === void 0 ? void 0 : _a.setBlur());
37
38
  await this._popover.showUnder(this._chipElement);
39
+ await this._filterDetail.setFocusField();
38
40
  }
39
41
  }
40
42
  /**
41
43
  * Oculta os detalhes de um item da lista.
42
44
  */
43
45
  async hideDetail() {
44
- await this._popover.hide();
46
+ var _a;
47
+ await ((_a = this._popover) === null || _a === void 0 ? void 0 : _a.hide());
45
48
  }
46
49
  getConfigChanges() {
47
50
  var _a;
@@ -61,12 +64,15 @@ const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
61
64
  this.filterChange.emit(configChanged);
62
65
  }
63
66
  else {
64
- this.togglePopover();
67
+ this.togglePopover(event);
65
68
  }
66
69
  }
67
70
  async togglePopover(event) {
68
71
  event === null || event === void 0 ? void 0 : event.preventDefault();
69
72
  event === null || event === void 0 ? void 0 : event.stopPropagation();
73
+ if (this.config.enabled === false) {
74
+ return;
75
+ }
70
76
  if (this.detailIsVisible) {
71
77
  await this.hideDetail();
72
78
  }
@@ -215,8 +221,9 @@ const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
215
221
  return undefined;
216
222
  }
217
223
  hasActiveElements(value) {
218
- var _a, _b, _c;
219
- 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;
224
+ var _a;
225
+ const list = Array.isArray(value) ? value : value === null || value === void 0 ? void 0 : value.elements;
226
+ 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;
220
227
  }
221
228
  hasActiveValue(config) {
222
229
  return (config.type !== FilterItemType.MULTI_LIST && config.value !== undefined) || this.hasActiveElements(config.value);
@@ -231,12 +238,67 @@ const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
231
238
  }
232
239
  return this.hasActiveValue(this.config);
233
240
  }
234
- handleVisibilityPopover(event) {
241
+ async handleVisibilityPopover(event) {
235
242
  this.detailIsVisible = event.detail;
243
+ if (!this.detailIsVisible) {
244
+ await this._filterDetail.clearValue();
245
+ }
246
+ }
247
+ getCustomMessage(key, params) {
248
+ var _a;
249
+ return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
250
+ }
251
+ hasValue() {
252
+ if (this.config.type === FilterItemType.MULTI_LIST) {
253
+ return this.hasActiveElements(this.config.value);
254
+ }
255
+ return this.config.value !== undefined && this.config.value !== null;
256
+ }
257
+ getTooltipMessage() {
258
+ var _a, _b;
259
+ if (this.config.required && !this.hasValue()) {
260
+ return {
261
+ message: (_a = this.config.requiredMessage) !== null && _a !== void 0 ? _a : this.getCustomMessage('validations.requiredFilter'),
262
+ type: 'error'
263
+ };
264
+ }
265
+ if (this.config.enabled === false && this.config.disabledMessage) {
266
+ return { message: this.config.disabledMessage, type: 'warning' };
267
+ }
268
+ return {
269
+ message: (_b = this.config.defaultMessage) !== null && _b !== void 0 ? _b : this.getLabel(true),
270
+ type: 'default'
271
+ };
272
+ }
273
+ getTypeChip(type) {
274
+ switch (type) {
275
+ case 'default':
276
+ return 'secondary';
277
+ case 'warning':
278
+ return 'warning-light';
279
+ case 'error':
280
+ return 'error-light';
281
+ case 'success':
282
+ return 'success-light';
283
+ default:
284
+ return type;
285
+ }
286
+ }
287
+ initKeyboardManager() {
288
+ this._keyboardManager = new KeyboardManager({ element: this._filterItemElement, propagate: true });
289
+ this._keyboardManager
290
+ .bind("Escape", () => this.hideDetail());
291
+ }
292
+ connectedCallback() {
293
+ this.initKeyboardManager();
294
+ }
295
+ disconnectedCallback() {
296
+ this._keyboardManager.unbindAllShortcutKeys();
236
297
  }
237
298
  render() {
238
299
  const leftIcon = this.getLeftIconName();
239
- return (h(Host, null, this.showChips && (h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.getEnabledChip(), onClick: (event) => this.togglePopover(event), disableAutoUpdateValue: true, type: "secondary" }, leftIcon && (h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, slot: "leftIcon" })), h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), slot: "rightIcon", id: "removeFilter", onClick: (event) => this.clearFilter(event) }))), h("ez-popover-core", { ref: elem => this._popover = elem, onEzVisibilityChange: (event) => this.handleVisibilityPopover(event) }, h("snk-filter-detail", { key: this.config.id, config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16", "data-element-id": this._idSnkFilterDetail, showHardFixed: this.showChips }))));
300
+ const { type, message } = this.getTooltipMessage();
301
+ return (h(Host, null, this.showChips && (h("ez-tooltip", { id: this.config.id, message: message, type: type, active: !this.detailIsVisible, strategy: "fixed" }, h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.getEnabledChip(), onClick: (event) => this.togglePopover(event), disableAutoUpdateValue: true, type: this.getTypeChip(type), enabled: this.config.enabled }, leftIcon && (h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, slot: "leftIcon" })), h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), slot: "rightIcon", id: "removeFilter", onClick: (event) => this.clearFilter(event) })))), h("ez-popover-core", { ref: elem => this._popover = elem, onEzVisibilityChange: (event) => this.handleVisibilityPopover(event) }, h("snk-filter-detail", { ref: ref => this._filterDetail = ref, key: this.config.id, config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16", "data-element-id": this._idSnkFilterDetail, showHardFixed: this.showChips && !this.config.required, removalBlocked: this.config.required }))));
240
302
  }
241
303
  get _filterItemElement() { return this; }
242
304
  static get watchers() { return {
@@ -1,8 +1,8 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { ElementIDUtils, ObjectUtils } from '@sankhyalabs/core';
3
- import { F as FilterItemType } from './filter-item-type.enum.js';
4
- import { E as EPresentationMode } from './presentationMode.js';
5
3
  import { C as ConfigStorage } from './ConfigStorage.js';
4
+ import { E as EPresentationMode } from './presentationMode.js';
5
+ import { F as FilterItemType } from './filter-item-type.enum.js';
6
6
 
7
7
  var FilterType;
8
8
  (function (FilterType) {
@@ -26,12 +26,6 @@ const SnkFilterModalItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
26
26
  this.configName = undefined;
27
27
  this.resourceID = undefined;
28
28
  }
29
- observeFilterItem(newValue) {
30
- var _a, _b;
31
- this._editor && (this._editor["config"] = newValue);
32
- (_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a['reloadList']) === null || _b === void 0 ? void 0 : _b.call(_a);
33
- this.filterChange.emit(newValue);
34
- }
35
29
  getContentEditorConfig() {
36
30
  const props = { presentationMode: EPresentationMode.MODAL };
37
31
  switch (this.filterItem.type) {
@@ -66,6 +60,7 @@ const SnkFilterModalItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
66
60
  return !this.filterItem.visible ? newValue !== undefined : true;
67
61
  }
68
62
  updateFilterValue(data) {
63
+ var _a, _b;
69
64
  const newValue = (data === null || data === void 0 ? void 0 : data.value) !== undefined ? data.value : data;
70
65
  if (this.filterItem.groupedItems != undefined) {
71
66
  this.filterItem = Object.assign(Object.assign({}, this.filterItem), { visible: newValue > 0, value: newValue, groupedItems: data.items });
@@ -73,6 +68,9 @@ const SnkFilterModalItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
73
68
  else {
74
69
  this.filterItem = Object.assign(Object.assign({}, this.filterItem), { value: this.filterItem.type === (FilterItemType.SEARCH || FilterItemType.CHECK_BOX_LIST) ? data : newValue, visible: this.isVisible(newValue) });
75
70
  }
71
+ this._editor && (this._editor["config"] = this.filterItem);
72
+ (_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a['reloadList']) === null || _b === void 0 ? void 0 : _b.call(_a);
73
+ this.filterChange.emit(this.filterItem);
76
74
  }
77
75
  handleDeleteFilter(filter, filterItemType) {
78
76
  if (filterItemType === FilterItemType.PERSONALIZED) {
@@ -102,12 +100,9 @@ const SnkFilterModalItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
102
100
  }
103
101
  render() {
104
102
  const { tag: ContentEditor, props } = this.getContentEditorConfig();
105
- return (h(Host, null, h("div", { class: "ez-flex ez-flex--column grow" }, this.canShowDetailModal() && (h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-title ez-title--small ez-title--primary grow" }, this.filterItem.detailModal))), h(ContentEditor, Object.assign({ ref: ref => this._editor = ref, config: this.filterItem, value: this.filterItem.value, onValueChanged: (event) => this.updateFilterValue(event.detail), "data-element-id": this._idContentEditor }, props)))));
103
+ return (h(Host, null, h("div", { class: "ez-flex ez-flex--column grow" }, this.canShowDetailModal() && (h("label", { class: "ez-text ez-text--medium ez-text--primary ez-margin-bottom--extra-small", htmlFor: `filter-item-${this.filterItem.id}` }, this.filterItem.detailModal)), h(ContentEditor, Object.assign({ ref: ref => this._editor = ref, id: `filter-item-${this.filterItem.id}`, config: this.filterItem, value: this.filterItem.value, onValueChanged: (event) => this.updateFilterValue(event.detail), "data-element-id": this._idContentEditor }, props)))));
106
104
  }
107
105
  get _element() { return this; }
108
- static get watchers() { return {
109
- "filterItem": ["observeFilterItem"]
110
- }; }
111
106
  static get style() { return snkFilterModalItemCss; }
112
107
  }, [0, "snk-filter-modal-item", {
113
108
  "filterItem": [1040],
@@ -1,328 +1,4 @@
1
- import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
- import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
3
- import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { F as FilterType, d as defineCustomElement$2 } from './snk-filter-modal-item2.js';
5
- import { F as FilterItemType } from './filter-item-type.enum.js';
6
- import { ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
7
- import { P as PersonalizedFilterUtils, D as DefaultFilter } from './PersonalizedFilterUtils.js';
8
- import { F as FilterNumberVariation } from './filterNumberVariation.js';
9
- import { A as ActionDefaultFilter, d as defineCustomElement$3 } from './snk-default-filter2.js';
10
-
11
- 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:hidden;overflow-y:auto}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";
12
-
13
- const SnkFilterModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14
- constructor() {
15
- super();
16
- this.__registerHost();
17
- this.getMessage = undefined;
18
- this.configName = undefined;
19
- this.filters = undefined;
20
- this.applyFilters = undefined;
21
- this.closeModal = undefined;
22
- this.addPersonalizedFilter = undefined;
23
- this.editPersonalizedFilter = undefined;
24
- this.deletePersonalizedFilter = undefined;
25
- this.filtersToDelete = [];
26
- this.filterDefaultToDelete = undefined;
27
- this.disablePersonalizedFilter = undefined;
28
- }
29
- /**
30
- * Emitido quando um filtro personalizado é deletado.
31
- */
32
- deletePersonalizedFilterListener(event) {
33
- this.filtersToDelete.push(event.detail);
34
- }
35
- getCustomMessage(key, params) {
36
- var _a;
37
- return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
38
- }
39
- //TODO: tratar clear all dos filtros personalizados
40
- handleClearAll() {
41
- const { customFilters, quickFilters, otherFilters, multiListFilters } = this.filters.reduce((acc, filter) => {
42
- if (filter.type === FilterItemType.MULTI_LIST) {
43
- acc.multiListFilters.push(filter);
44
- return acc;
45
- }
46
- if (filter.filterType === FilterType.QUICK_FILTER) {
47
- acc.quickFilters.push(filter);
48
- return acc;
49
- }
50
- if (filter.filterType === FilterType.CUSTOM_FILTER) {
51
- acc.customFilters.push(filter);
52
- return acc;
53
- }
54
- if (filter.filterType === FilterType.OTHER_FILTERS) {
55
- acc.otherFilters.push(filter);
56
- return acc;
57
- }
58
- return acc;
59
- }, { quickFilters: [], customFilters: [], otherFilters: [], multiListFilters: [] });
60
- this.handleClearFilterList(quickFilters);
61
- this.handleClearCustomFilters(customFilters);
62
- this.handleClearOthersFilters(otherFilters);
63
- multiListFilters.forEach(multiListFilter => this.handleClearSigleFilter(multiListFilter));
64
- }
65
- handleClearOthersFilters(otherFilters) {
66
- this.filters = this.filters.map(filter => otherFilters.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
67
- }
68
- handleClearCustomFilters(customFilters) {
69
- this.filters.forEach((filter, index) => {
70
- if (filter.filterType === FilterType.CUSTOM_FILTER)
71
- this.filters[index] = this.clearAllCustomFilter(customFilters).shift();
72
- });
73
- }
74
- clearAllCustomFilter(filterConfigSnapshot) {
75
- return filterConfigSnapshot.map(filterItem => {
76
- const copy = Object.assign({}, filterItem);
77
- delete copy.value;
78
- copy.visible = false;
79
- if (copy.groupedItems) {
80
- copy.groupedItems = this.clearAllCustomFilter(copy.groupedItems);
81
- }
82
- return copy;
83
- });
84
- }
85
- hasChangeToSave() {
86
- const hasChangesPersonalizedFilters = ObjectUtils.objectToString(this.filters) !== ObjectUtils.objectToString(this._originalFilterConfig);
87
- return hasChangesPersonalizedFilters;
88
- }
89
- handleClose() {
90
- const hasChangesToSave = this.hasChangeToSave();
91
- if (!hasChangesToSave) {
92
- this.closeModal();
93
- return;
94
- }
95
- return ApplicationUtils.confirm(this.getCustomMessage('validations.notSaved.title'), this.getCustomMessage('validations.notSaved.message')).then((cancelAction) => {
96
- if (cancelAction)
97
- this.closeModal();
98
- });
99
- }
100
- handleApplyFilters() {
101
- const filterPersonalized = this.filters.find(filter => filter.filterType === FilterType.CUSTOM_FILTER || filter.filterType === FilterType.DEFAULT_FILTER);
102
- if (this.isValidCustomFilter(filterPersonalized)) {
103
- this.applyFilters(this.filters);
104
- }
105
- if (this.filtersToDelete.length > 0) {
106
- this.filtersToDelete.forEach(filter => {
107
- this.deletePersonalizedFilter(filter, this.configName);
108
- });
109
- this.filtersToDelete = [];
110
- }
111
- if (this.filterDefaultToDelete) {
112
- this.deletePersonalizedFilter(this.filterDefaultToDelete, this.configName, true);
113
- this._defaultFilter = undefined;
114
- this.filterDefaultToDelete = undefined;
115
- }
116
- }
117
- isValidCustomFilter(filterPersonalized) {
118
- const isValid = PersonalizedFilterUtils.validateVariableValues(filterPersonalized);
119
- if (!isValid) {
120
- ApplicationUtils.alert(this.getCustomMessage('validations.notFullFilled.title'), this.getCustomMessage('validations.notFullFilled.message'));
121
- return false;
122
- }
123
- return true;
124
- }
125
- modalActionListener(evt) {
126
- const modalAction = evt.detail;
127
- switch (modalAction) {
128
- case ModalAction.CANCEL:
129
- this.handleClearAll();
130
- break;
131
- case ModalAction.OK:
132
- this.handleApplyFilters();
133
- break;
134
- case ModalAction.CLOSE:
135
- this.handleClose();
136
- break;
137
- }
138
- }
139
- handleFilterChange(filterConfig) {
140
- this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
141
- }
142
- handleClearFilterList(filterList) {
143
- this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
144
- }
145
- handleClearSigleFilter(filterItem) {
146
- if (FilterItemType.MULTI_LIST === filterItem.type) {
147
- let filterItemCopy = ObjectUtils.copy(filterItem);
148
- this.uncheckFilterValues(filterItemCopy.value);
149
- const filterListCopy = ObjectUtils.copy(this.filters);
150
- const index = filterListCopy.findIndex(item => item.id === filterItem.id);
151
- filterListCopy.splice(index, 1, filterItemCopy);
152
- this.filters = ObjectUtils.copy(filterListCopy);
153
- return;
154
- }
155
- if (FilterItemType.CHECK_BOX_LIST === filterItem.type) {
156
- const filterListCopy = ObjectUtils.copy(this.filters);
157
- filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
158
- this.filters = ObjectUtils.copy(filterListCopy);
159
- return;
160
- }
161
- const filter = this.filters.find(filter => filter.id === filterItem.id);
162
- filter.value = undefined;
163
- this.filters = ObjectUtils.copy(this.filters);
164
- }
165
- uncheckFilterValues(valueList) {
166
- valueList.forEach(value => {
167
- if (!!value) {
168
- value.check = false;
169
- }
170
- });
171
- return valueList;
172
- }
173
- renderFilterItem(filterItem, fullRow) {
174
- return (h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event.detail), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
175
- }
176
- isDefaultFilterNumberVariation(filter) {
177
- var _a;
178
- return filter.type === FilterItemType.NUMBER
179
- && (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === FilterNumberVariation.DEFAULT);
180
- }
181
- mountFiltersLines(filters) {
182
- const MAX_LINE_LENGTH = 2;
183
- let currentLine = 0;
184
- let forceAddCurrent = false;
185
- const filtersLines = {};
186
- for (let curr = 0; curr < filters.length; curr++) {
187
- filtersLines[currentLine] = filtersLines[currentLine] || [];
188
- const item = filters[curr];
189
- const isLast = curr === filters.length - 1;
190
- const currentItemMatch = item.type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
191
- const nextItemMatch = isLast ? false : filters[curr + 1].type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
192
- if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
193
- filtersLines[currentLine].push(item);
194
- forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
195
- if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
196
- ++currentLine;
197
- continue;
198
- }
199
- filtersLines[currentLine] = filtersLines[currentLine] || [];
200
- filtersLines[currentLine].push(item);
201
- ++currentLine;
202
- }
203
- return Object.values(filtersLines);
204
- }
205
- renderFilterLine(filters) {
206
- const fullLine = filters.length === 1;
207
- return filters.map((filter) => this.renderFilterItem(filter, fullLine));
208
- }
209
- getIformedFiltersCount(listItems) {
210
- let countInformedItens = 0;
211
- listItems.forEach(item => {
212
- var _a, _b, _c, _d, _e, _f;
213
- if (FilterItemType.MULTI_LIST === item.type) {
214
- 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;
215
- return;
216
- }
217
- if (FilterItemType.CHECK_BOX_LIST === item.type) {
218
- countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
219
- .filter(([_, value]) => value === true)
220
- .map(([key, _]) => key).length;
221
- return;
222
- }
223
- if (item.groupedItems != undefined) {
224
- countInformedItens = item.groupedItems.filter(item => item.visible).length;
225
- return;
226
- }
227
- if (!!item.value) {
228
- countInformedItens++;
229
- }
230
- });
231
- return countInformedItens;
232
- }
233
- renderCollapsibleFilterBox(label, listItems, isSingleItem, shouldRenderFooter = true) {
234
- if (!listItems.length)
235
- return null;
236
- const appliedFilters = this.getIformedFiltersCount(listItems);
237
- const lines = this.mountFiltersLines(listItems);
238
- return (h("ez-collapsible-box", { class: "snk-filter-modal__collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters && (h("ez-badge", { class: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toString() })), h("div", { class: "ez-row snk-filter-modal__rendered-items" }, lines.map(this.renderFilterLine.bind(this))), shouldRenderFooter && (h("div", { class: "ez-flex ez-flex--justify-end grow" }, h("ez-button", { class: "ez-button--tertiary", size: "medium", label: this.getCustomMessage("clearModal"), onClick: () => isSingleItem ? this.handleClearSigleFilter(listItems[0]) : this.handleClearFilterList(listItems) })))));
239
- }
240
- handleDeleteFilter() {
241
- this._application.confirm(this.getMessage('snkPersonalizedFilter.deleteConfirm.title'), this.getMessage('snkPersonalizedFilter.info.deleteDefaultFilterConfirm'), "alert-circle-inverted", "critical").then((actionConfirmed) => {
242
- if (!actionConfirmed) {
243
- return;
244
- }
245
- this.filterDefaultToDelete = this._defaultFilter;
246
- this.filters = this.filters.filter(filter => filter.id !== FilterType.DEFAULT_FILTER);
247
- });
248
- }
249
- handleActionSelectedDefaultFilter({ detail: action }) {
250
- switch (action) {
251
- case ActionDefaultFilter.CREATE:
252
- this.addPersonalizedFilter(true);
253
- break;
254
- case ActionDefaultFilter.EDIT:
255
- this.editPersonalizedFilter(this._defaultFilter.id, true);
256
- break;
257
- case ActionDefaultFilter.REMOVE:
258
- this.handleDeleteFilter();
259
- break;
260
- }
261
- }
262
- getCustomFilter(filters) {
263
- const customFilters = filters.filter((filter) => filter.filterType === FilterType.CUSTOM_FILTER);
264
- return customFilters;
265
- }
266
- getDefaultFilter(filters) {
267
- const defaultFilter = filters.find((item) => item.id === DefaultFilter.id);
268
- return defaultFilter;
269
- }
270
- componentWillLoad() {
271
- this._application = ApplicationContext.getContextValue('__SNK__APPLICATION__');
272
- }
273
- componentWillRender() {
274
- this._modalTitle = this.getCustomMessage('title');
275
- this._okButtonLabel = this.getCustomMessage('okButtonLabel');
276
- this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
277
- }
278
- componentDidLoad() {
279
- if (!this._originalFilterConfig)
280
- this._originalFilterConfig = this.filters;
281
- }
282
- render() {
283
- this._defaultFilter = this.getDefaultFilter(this.filters);
284
- const customFilters = this.getCustomFilter(this.filters);
285
- const quickFilters = this.filters.filter(filter => filter.filterType === FilterType.QUICK_FILTER);
286
- const otherFilters = this.filters.filter(filter => filter.filterType === FilterType.OTHER_FILTERS);
287
- return (h("ez-modal-container", { class: "snk-filter-modal__container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, h("div", { class: "snk-filter-modal__content ez-col--sd-12" }, 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)))));
288
- }
289
- static get style() { return snkFilterModalCss; }
290
- }, [0, "snk-filter-modal", {
291
- "getMessage": [16],
292
- "configName": [1025, "config-name"],
293
- "filters": [1040],
294
- "applyFilters": [16],
295
- "closeModal": [16],
296
- "addPersonalizedFilter": [16],
297
- "editPersonalizedFilter": [16],
298
- "deletePersonalizedFilter": [16],
299
- "filtersToDelete": [1040],
300
- "filterDefaultToDelete": [1040],
301
- "disablePersonalizedFilter": [4, "disable-personalized-filter"]
302
- }, [[0, "deleteFilter", "deletePersonalizedFilterListener"]]]);
303
- function defineCustomElement$1() {
304
- if (typeof customElements === "undefined") {
305
- return;
306
- }
307
- const components = ["snk-filter-modal", "snk-default-filter", "snk-filter-modal-item"];
308
- components.forEach(tagName => { switch (tagName) {
309
- case "snk-filter-modal":
310
- if (!customElements.get(tagName)) {
311
- customElements.define(tagName, SnkFilterModal$1);
312
- }
313
- break;
314
- case "snk-default-filter":
315
- if (!customElements.get(tagName)) {
316
- defineCustomElement$3();
317
- }
318
- break;
319
- case "snk-filter-modal-item":
320
- if (!customElements.get(tagName)) {
321
- defineCustomElement$2();
322
- }
323
- break;
324
- } });
325
- }
1
+ import { S as SnkFilterModal$1, d as defineCustomElement$1 } from './snk-filter-modal2.js';
326
2
 
327
3
  const SnkFilterModal = SnkFilterModal$1;
328
4
  const defineCustomElement = defineCustomElement$1;