@sankhyalabs/sankhyablocks 5.6.0 → 5.8.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 (146) hide show
  1. package/dist/cjs/{SnkMessageBuilder-e64dce7f.js → SnkMessageBuilder-1760d2c9.js} +16 -1
  2. package/dist/cjs/{filter-item-type.enum-3daf58d3.js → filter-item-type.enum-aa823a00.js} +1 -0
  3. package/dist/cjs/filter-type.enum-b14ce507.js +11 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/presentationMode-52ec3bdd.js +7 -0
  6. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  7. package/dist/cjs/snk-application.cjs.entry.js +1 -1
  8. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  9. package/dist/cjs/{snk-data-unit-85d6565e.js → snk-data-unit-f27603c9.js} +1 -1
  10. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  11. package/dist/cjs/snk-detail-view.cjs.entry.js +1 -1
  12. package/dist/cjs/snk-filter-bar.cjs.entry.js +52 -140
  13. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +26 -15
  14. package/dist/cjs/snk-filter-detail.cjs.entry.js +5 -10
  15. package/dist/cjs/snk-filter-item.cjs.entry.js +36 -8
  16. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +67 -0
  17. package/dist/cjs/snk-filter-modal.cjs.entry.js +72 -49
  18. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +3 -1
  19. package/dist/cjs/snk-filter-number.cjs.entry.js +3 -1
  20. package/dist/cjs/snk-filter-period.cjs.entry.js +18 -2
  21. package/dist/cjs/snk-filter-personalized.cjs.entry.js +3 -1
  22. package/dist/cjs/snk-filter-search.cjs.entry.js +3 -1
  23. package/dist/cjs/snk-filter-text.cjs.entry.js +2 -0
  24. package/dist/cjs/snk-grid.cjs.entry.js +8 -1
  25. package/dist/collection/collection-manifest.json +1 -0
  26. package/dist/collection/components/snk-filter-bar/filter-item/editors/enum/presentationMode.js +5 -0
  27. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +60 -29
  28. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +19 -0
  29. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +19 -0
  30. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +72 -1
  31. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +19 -0
  32. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +19 -0
  33. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +19 -0
  34. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +1 -0
  35. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +5 -10
  36. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +36 -8
  37. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.css +32 -2
  38. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +116 -156
  39. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.css +8 -0
  40. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +116 -0
  41. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +19 -142
  42. package/dist/collection/components/snk-filter-bar/types/filter-type.enum.js +7 -0
  43. package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +36 -0
  44. package/dist/collection/components/snk-filter-bar/utils/filters-mock.js +315 -0
  45. package/dist/collection/components/snk-grid/snk-grid.js +8 -1
  46. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +16 -1
  47. package/dist/components/SnkMessageBuilder.js +16 -1
  48. package/dist/components/filter-item-type.enum.js +1 -0
  49. package/dist/components/index.d.ts +1 -0
  50. package/dist/components/index.js +1 -0
  51. package/dist/components/presentationMode.js +7 -0
  52. package/dist/components/snk-crud.js +22 -34
  53. package/dist/components/snk-detail-view2.js +24 -46
  54. package/dist/components/snk-filter-bar2.js +57 -157
  55. package/dist/components/snk-filter-binary-select.js +27 -16
  56. package/dist/components/snk-filter-detail2.js +5 -10
  57. package/dist/components/snk-filter-item2.js +36 -8
  58. package/dist/components/snk-filter-list.js +171 -1
  59. package/dist/components/snk-filter-modal-item.d.ts +11 -0
  60. package/dist/components/snk-filter-modal-item.js +6 -0
  61. package/dist/components/snk-filter-modal-item2.js +86 -0
  62. package/dist/components/snk-filter-modal.js +118 -1
  63. package/dist/components/snk-filter-multi-select.js +3 -1
  64. package/dist/components/snk-filter-number.js +3 -1
  65. package/dist/components/snk-filter-period.js +20 -2
  66. package/dist/components/snk-filter-personalized.js +3 -1
  67. package/dist/components/snk-filter-search.js +3 -1
  68. package/dist/components/snk-filter-text.js +3 -1
  69. package/dist/components/snk-grid2.js +18 -23
  70. package/dist/esm/{SnkMessageBuilder-f3590f65.js → SnkMessageBuilder-4caf8b4f.js} +16 -1
  71. package/dist/esm/{filter-item-type.enum-a79b2fa8.js → filter-item-type.enum-5028ed3f.js} +1 -0
  72. package/dist/esm/filter-type.enum-a80c1b6b.js +9 -0
  73. package/dist/esm/loader.js +1 -1
  74. package/dist/esm/presentationMode-783bbf9d.js +7 -0
  75. package/dist/esm/sankhyablocks.js +1 -1
  76. package/dist/esm/snk-application.entry.js +1 -1
  77. package/dist/esm/snk-data-exporter.entry.js +2 -2
  78. package/dist/esm/{snk-data-unit-50b1660c.js → snk-data-unit-640399b3.js} +1 -1
  79. package/dist/esm/snk-data-unit.entry.js +2 -2
  80. package/dist/esm/snk-detail-view.entry.js +1 -1
  81. package/dist/esm/snk-filter-bar.entry.js +53 -141
  82. package/dist/esm/snk-filter-binary-select.entry.js +27 -16
  83. package/dist/esm/snk-filter-detail.entry.js +6 -11
  84. package/dist/esm/snk-filter-item.entry.js +37 -9
  85. package/dist/esm/snk-filter-modal-item.entry.js +63 -0
  86. package/dist/esm/snk-filter-modal.entry.js +73 -50
  87. package/dist/esm/snk-filter-multi-select.entry.js +4 -2
  88. package/dist/esm/snk-filter-number.entry.js +4 -2
  89. package/dist/esm/snk-filter-period.entry.js +19 -3
  90. package/dist/esm/snk-filter-personalized.entry.js +4 -2
  91. package/dist/esm/snk-filter-search.entry.js +4 -2
  92. package/dist/esm/snk-filter-text.entry.js +3 -1
  93. package/dist/esm/snk-grid.entry.js +8 -1
  94. package/dist/sankhyablocks/p-08779202.entry.js +1 -0
  95. package/dist/sankhyablocks/p-1465f132.entry.js +1 -0
  96. package/dist/sankhyablocks/p-1a68fb59.js +1 -0
  97. package/dist/sankhyablocks/{p-f344b811.entry.js → p-21c2b733.entry.js} +1 -1
  98. package/dist/sankhyablocks/p-29c1889f.js +1 -0
  99. package/dist/sankhyablocks/p-355e7ab0.entry.js +1 -0
  100. package/dist/sankhyablocks/p-3794686e.entry.js +1 -0
  101. package/dist/sankhyablocks/{p-c4417efb.entry.js → p-4181c36d.entry.js} +1 -1
  102. package/dist/sankhyablocks/p-4ce96831.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-3fbe2d69.entry.js → p-57b74971.entry.js} +1 -1
  104. package/dist/sankhyablocks/{p-9dd2b8cb.js → p-584d7212.js} +1 -1
  105. package/dist/sankhyablocks/p-59705471.entry.js +1 -0
  106. package/dist/sankhyablocks/{p-3d3263b4.js → p-6981c03e.js} +1 -1
  107. package/dist/sankhyablocks/p-786ae316.entry.js +1 -0
  108. package/dist/sankhyablocks/p-80e52e85.entry.js +1 -0
  109. package/dist/sankhyablocks/p-8efb0f47.entry.js +1 -0
  110. package/dist/sankhyablocks/p-9af04fc7.entry.js +1 -0
  111. package/dist/sankhyablocks/{p-df8f13b4.entry.js → p-9c3f0caf.entry.js} +1 -1
  112. package/dist/sankhyablocks/p-9cbc3925.entry.js +1 -0
  113. package/dist/sankhyablocks/p-b9fb86fe.entry.js +1 -0
  114. package/dist/sankhyablocks/p-d9804798.js +1 -0
  115. package/dist/sankhyablocks/p-e2bb9c9a.entry.js +1 -0
  116. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  117. package/dist/types/components/snk-filter-bar/filter-item/editors/enum/presentationMode.d.ts +4 -0
  118. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +5 -0
  119. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +2 -1
  120. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +11 -1
  121. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +37 -0
  122. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +17 -0
  123. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +2 -11
  124. package/dist/types/components/snk-filter-bar/types/filter-type.enum.d.ts +6 -0
  125. package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +20 -0
  126. package/dist/types/components/snk-filter-bar/utils/filters-mock.d.ts +186 -0
  127. package/dist/types/components.d.ts +119 -56
  128. package/package.json +1 -1
  129. package/react/components.d.ts +1 -0
  130. package/react/components.js +1 -0
  131. package/react/components.js.map +1 -1
  132. package/dist/components/snk-filter-list2.js +0 -173
  133. package/dist/components/snk-filter-modal2.js +0 -97
  134. package/dist/sankhyablocks/p-1dcfd32a.entry.js +0 -1
  135. package/dist/sankhyablocks/p-3a2ce158.entry.js +0 -1
  136. package/dist/sankhyablocks/p-5e62a17b.entry.js +0 -1
  137. package/dist/sankhyablocks/p-5fc55684.entry.js +0 -1
  138. package/dist/sankhyablocks/p-73e830cf.entry.js +0 -1
  139. package/dist/sankhyablocks/p-86d29b6f.entry.js +0 -1
  140. package/dist/sankhyablocks/p-ad51bf1c.entry.js +0 -1
  141. package/dist/sankhyablocks/p-afba9bbe.entry.js +0 -1
  142. package/dist/sankhyablocks/p-c336170d.entry.js +0 -1
  143. package/dist/sankhyablocks/p-c9477950.js +0 -1
  144. package/dist/sankhyablocks/p-d5c9c1f8.entry.js +0 -1
  145. package/dist/sankhyablocks/p-ee82c157.entry.js +0 -1
  146. package/dist/sankhyablocks/p-fac37198.entry.js +0 -1
@@ -1,66 +1,91 @@
1
1
  import { h } from '@stencil/core';
2
- import { ModalAction, ModalButtonStatus } from "@sankhyalabs/ezui/dist/collection/components/ez-modal-container";
3
- import { ArrayUtils } from '@sankhyalabs/core';
4
- import { CheckMode } from "@sankhyalabs/ezui/dist/collection/utils";
2
+ import { ModalAction } from "@sankhyalabs/ezui/dist/collection/components/ez-modal-container";
3
+ import FilterType from '../types/filter-type.enum';
4
+ import FilterItemType from '../filter-item/filter-item-type.enum';
5
5
  export class SnkFilterModal {
6
6
  constructor() {
7
- this._filterArgument = undefined;
8
7
  this.getMessage = undefined;
9
- this.items = undefined;
10
- this.modalTitle = undefined;
11
- this.modalSubTitle = undefined;
12
- this.cancelButtonLabel = undefined;
13
- this.okButtonLabel = undefined;
14
- this.infoText = undefined;
15
- this.useSearch = undefined;
16
- this.processModalAction = undefined;
8
+ this.filters = undefined;
9
+ this.applyFilters = undefined;
10
+ this.clearAll = undefined;
11
+ this.closeModal = undefined;
17
12
  }
18
- updateValue(id, value = undefined) {
19
- this.items = this.items.map(item => {
20
- if (item.id === id && item.enabled) {
21
- if (value == undefined) {
22
- value = !item.active;
23
- }
24
- return Object.assign(Object.assign({}, item), { active: value });
25
- }
26
- return item;
27
- });
13
+ getCustomMessage(key, params) {
14
+ var _a;
15
+ return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
16
+ }
17
+ handleClearAll() {
18
+ const cleanedFilters = this.clearAll(this.filters);
19
+ this.filters = cleanedFilters;
28
20
  }
29
- getActiveFiltersMsg() {
30
- const activeFilters = this.items.filter(item => item.active).length;
31
- if (activeFilters === 0) {
32
- return this.getMessage("snkFilterBar.noActiveFilters");
21
+ modalActionListener(evt) {
22
+ const modalAction = evt.detail;
23
+ switch (modalAction) {
24
+ case ModalAction.CANCEL:
25
+ this.handleClearAll();
26
+ break;
27
+ case ModalAction.OK:
28
+ this.applyFilters(this.filters);
29
+ case ModalAction.CLOSE:
30
+ this.closeModal();
31
+ default:
32
+ break;
33
33
  }
34
- return this.getMessage(activeFilters > 1 ? "snkFilterBar.activeFilters" : "snkFilterBar.activeFilter", { ACTIVE_FILTERS: activeFilters });
35
34
  }
36
- buildItems(list) {
37
- return list.map(item => {
38
- return (h("button", { onClick: () => this.updateValue(item.id), class: "ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small" }, h("ez-check", { id: `checkbox_${item.id}`, tabIndex: -1, class: "sc-snk-filter-bar snk-filter-bar__filter-modal-item__check", onEzChange: evt => this.updateValue(item.id, evt.detail), enabled: item.enabled, value: item.active, mode: CheckMode.SWITCH }), h("div", { class: "ez-text ez-title--primary ez-text--medium ez-margin-left--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item__label" }, item.label)));
39
- });
35
+ handleFilterChange(filterConfig) {
36
+ this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
40
37
  }
41
- itemKeyBoardSelect(event, item) {
42
- if (event.key === "Enter" || event.key === " ") {
43
- this.updateValue(item.id);
44
- }
38
+ handleClearFilters(filterList) {
39
+ this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
45
40
  }
46
- modalActionListener(evt) {
47
- const modalAction = evt.detail;
48
- if (modalAction === ModalAction.LOAD) {
49
- if (this._filterInput) {
50
- this._filterInput.setFocus();
41
+ renderFilterItem(filterItem, fullRow) {
42
+ 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, onFilterChange: (event) => this.handleFilterChange(event.detail) }));
43
+ }
44
+ mountFiltersLines(filters) {
45
+ const MAX_LINE_LENGTH = 2;
46
+ let currentLine = 0;
47
+ let forceAddCurrent = false;
48
+ const filtersLines = {};
49
+ for (let curr = 0; curr < filters.length; curr++) {
50
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
51
+ const item = filters[curr];
52
+ const isLast = curr === filters.length - 1;
53
+ const currentItemMatch = [FilterItemType.TEXT, FilterItemType.NUMBER].includes(item.type);
54
+ const nextItemMatch = isLast ? false : [FilterItemType.TEXT, FilterItemType.NUMBER].includes(filters[curr + 1].type);
55
+ if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
56
+ filtersLines[currentLine].push(item);
57
+ forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
58
+ if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
59
+ ++currentLine;
60
+ continue;
51
61
  }
62
+ filtersLines[currentLine] = filtersLines[currentLine] || [];
63
+ filtersLines[currentLine].push(item);
64
+ ++currentLine;
52
65
  }
53
- else {
54
- this.processModalAction(modalAction);
55
- }
66
+ return Object.values(filtersLines);
67
+ }
68
+ renderFilterLine(filters) {
69
+ const fullLine = filters.length === 1;
70
+ return (h("div", { class: "ez-row" }, filters.map((filter) => this.renderFilterItem(filter, fullLine))));
71
+ }
72
+ renderCollapsibleFilterBox(label, listItems) {
73
+ if (!listItems.length)
74
+ return null;
75
+ const appliedFilters = listItems.filter(filterItem => !!filterItem.value).length;
76
+ const lines = this.mountFiltersLines(listItems);
77
+ return (h("ez-collapsible-box", { className: "snk-filter__modal-collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters && (h("ez-badge", { className: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters })), lines.map(this.renderFilterLine.bind(this)), h("div", { class: "ez-flex ez-flex--justify-end grow" }, h("ez-button", { className: "ez-button--tertiary", size: "medium", label: "Limpar", onClick: () => this.handleClearFilters(listItems) }))));
78
+ }
79
+ componentWillRender() {
80
+ this._modalTitle = this.getCustomMessage('title');
81
+ this._okButtonLabel = this.getCustomMessage('okButtonLabel');
82
+ this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
56
83
  }
57
84
  render() {
58
- const allowCancel = this.items.filter(item => item.active).length > 0;
59
- const items = (this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items) : []);
60
- return (h("ez-modal-container", { class: "snk-filter__modal-container", modalTitle: this.modalTitle, modalSubTitle: this.modalSubTitle, cancelButtonLabel: this.cancelButtonLabel, okButtonLabel: this.okButtonLabel, onEzModalAction: evt => this.modalActionListener(evt), cancelButtonStatus: allowCancel ? ModalButtonStatus.ENABLED : ModalButtonStatus.DISABLED }, h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-modal-content" }, h("div", null, this.useSearch ?
61
- h("ez-filter-input", { ref: ref => this._filterInput = ref, label: this.getMessage("snkFilterBar.modalFindFilter"), onEzChange: (evt) => this._filterArgument = evt.detail })
62
- :
63
- undefined), items.length > 0 ? h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding-bottom--small" }, this.getActiveFiltersMsg()) : undefined, h("div", null, this.buildItems(items)), h("div", { class: "ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large" }, this.infoText))));
85
+ const customFilters = this.filters.filter(filter => filter.filterType === FilterType.CUSTOM_FILTER);
86
+ const quickFilters = this.filters.filter(filter => filter.filterType === FilterType.QUICK_FILTER);
87
+ const otherFilters = this.filters.filter(filter => filter.filterType === FilterType.OTHER_FILTERS);
88
+ 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" }, this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter])))));
64
89
  }
65
90
  static get is() { return "snk-filter-modal"; }
66
91
  static get originalStyleUrls() {
@@ -90,18 +115,19 @@ export class SnkFilterModal {
90
115
  "text": "Usado pra flexibilizar os verbetes e mensagens de acordo com o SnkMessageBuilder."
91
116
  }
92
117
  },
93
- "items": {
118
+ "filters": {
94
119
  "type": "unknown",
95
120
  "mutable": true,
96
121
  "complexType": {
97
- "original": "Array<ModalItem>",
98
- "resolved": "ModalItem[]",
122
+ "original": "Array<SnkFilterItemConfig>",
123
+ "resolved": "SnkFilterItemConfig[]",
99
124
  "references": {
100
125
  "Array": {
101
126
  "location": "global"
102
127
  },
103
- "ModalItem": {
104
- "location": "local"
128
+ "SnkFilterItemConfig": {
129
+ "location": "import",
130
+ "path": "../filter-item/snk-filter-item"
105
131
  }
106
132
  }
107
133
  },
@@ -109,136 +135,70 @@ export class SnkFilterModal {
109
135
  "optional": false,
110
136
  "docs": {
111
137
  "tags": [],
112
- "text": "Guarda a lista de filtros."
138
+ "text": "Filtros a serem apresentados"
113
139
  }
114
140
  },
115
- "modalTitle": {
116
- "type": "string",
117
- "mutable": false,
118
- "complexType": {
119
- "original": "string",
120
- "resolved": "string",
121
- "references": {}
122
- },
123
- "required": false,
124
- "optional": false,
125
- "docs": {
126
- "tags": [],
127
- "text": "Define o t\u00EDtulo do filtro."
128
- },
129
- "attribute": "modal-title",
130
- "reflect": false
131
- },
132
- "modalSubTitle": {
133
- "type": "string",
134
- "mutable": false,
135
- "complexType": {
136
- "original": "string",
137
- "resolved": "string",
138
- "references": {}
139
- },
140
- "required": false,
141
- "optional": false,
142
- "docs": {
143
- "tags": [],
144
- "text": "Define o subt\u00EDtulo do filtro."
145
- },
146
- "attribute": "modal-sub-title",
147
- "reflect": false
148
- },
149
- "cancelButtonLabel": {
150
- "type": "string",
151
- "mutable": false,
152
- "complexType": {
153
- "original": "string",
154
- "resolved": "string",
155
- "references": {}
156
- },
157
- "required": false,
158
- "optional": false,
159
- "docs": {
160
- "tags": [],
161
- "text": "Define o label do bot\u00E3o de cancelar."
162
- },
163
- "attribute": "cancel-button-label",
164
- "reflect": false
165
- },
166
- "okButtonLabel": {
167
- "type": "string",
168
- "mutable": false,
169
- "complexType": {
170
- "original": "string",
171
- "resolved": "string",
172
- "references": {}
173
- },
174
- "required": false,
175
- "optional": false,
176
- "docs": {
177
- "tags": [],
178
- "text": "Define o label do bot\u00E3o de confirmar."
179
- },
180
- "attribute": "ok-button-label",
181
- "reflect": false
182
- },
183
- "infoText": {
184
- "type": "string",
141
+ "applyFilters": {
142
+ "type": "unknown",
185
143
  "mutable": false,
186
144
  "complexType": {
187
- "original": "string",
188
- "resolved": "string",
189
- "references": {}
145
+ "original": "(updatedFilterConfig: Array<SnkFilterItemConfig>) => void",
146
+ "resolved": "(updatedFilterConfig: SnkFilterItemConfig[]) => void",
147
+ "references": {
148
+ "Array": {
149
+ "location": "global"
150
+ },
151
+ "SnkFilterItemConfig": {
152
+ "location": "import",
153
+ "path": "../filter-item/snk-filter-item"
154
+ }
155
+ }
190
156
  },
191
157
  "required": false,
192
158
  "optional": false,
193
159
  "docs": {
194
160
  "tags": [],
195
- "text": "Define a descri\u00E7\u00E3o do filtro."
196
- },
197
- "attribute": "info-text",
198
- "reflect": false
161
+ "text": "A\u00E7\u00E3o executada ao aplicar os filtros"
162
+ }
199
163
  },
200
- "useSearch": {
201
- "type": "boolean",
164
+ "clearAll": {
165
+ "type": "unknown",
202
166
  "mutable": false,
203
167
  "complexType": {
204
- "original": "boolean",
205
- "resolved": "boolean",
206
- "references": {}
168
+ "original": "(configSnapshot: SnkFilterItemConfig[]) => Array<SnkFilterItemConfig>",
169
+ "resolved": "(configSnapshot: SnkFilterItemConfig[]) => SnkFilterItemConfig[]",
170
+ "references": {
171
+ "SnkFilterItemConfig": {
172
+ "location": "import",
173
+ "path": "../filter-item/snk-filter-item"
174
+ },
175
+ "Array": {
176
+ "location": "global"
177
+ }
178
+ }
207
179
  },
208
180
  "required": false,
209
181
  "optional": false,
210
182
  "docs": {
211
183
  "tags": [],
212
- "text": "Se `true`, exibe a barra de pesquisa do filtro."
213
- },
214
- "attribute": "use-search",
215
- "reflect": false
184
+ "text": "A\u00E7\u00E3o executada ao limpar os filtros"
185
+ }
216
186
  },
217
- "processModalAction": {
187
+ "closeModal": {
218
188
  "type": "unknown",
219
189
  "mutable": false,
220
190
  "complexType": {
221
- "original": "(action: ModalAction) => void",
222
- "resolved": "(action: ModalAction) => void",
223
- "references": {
224
- "ModalAction": {
225
- "location": "import",
226
- "path": "@sankhyalabs/ezui/dist/collection/components/ez-modal-container"
227
- }
228
- }
191
+ "original": "() => void",
192
+ "resolved": "() => void",
193
+ "references": {}
229
194
  },
230
195
  "required": false,
231
196
  "optional": false,
232
197
  "docs": {
233
198
  "tags": [],
234
- "text": "\u00C9 disparado em qualquer intera\u00E7\u00E3o com o filtro."
199
+ "text": "A\u00E7\u00E3o disparada ao fechar o modal"
235
200
  }
236
201
  }
237
202
  };
238
203
  }
239
- static get states() {
240
- return {
241
- "_filterArgument": {}
242
- };
243
- }
244
204
  }
@@ -0,0 +1,116 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { ElementIDUtils } from '@sankhyalabs/core';
3
+ import FilterItemType from "../../filter-item/filter-item-type.enum";
4
+ import FilterType from '../../types/filter-type.enum';
5
+ import { EPresentationMode } from '../../filter-item/editors/enum/presentationMode';
6
+ export class SnkFilterModalItem {
7
+ constructor() {
8
+ this.filterItem = undefined;
9
+ }
10
+ observeFilterItem(newValue) {
11
+ this.filterChange.emit(newValue);
12
+ }
13
+ getContentEditorConfig() {
14
+ const variations = { presentationMode: EPresentationMode.MODAL };
15
+ switch (this.filterItem.type) {
16
+ case FilterItemType.BINARY_SELECT:
17
+ return { tag: "snk-filter-binary-select", variations };
18
+ case FilterItemType.MULTI_SELECT:
19
+ return { tag: "snk-filter-multi-select" };
20
+ case FilterItemType.PERIOD:
21
+ return { tag: "snk-filter-period", variations };
22
+ case FilterItemType.SEARCH:
23
+ return { tag: "snk-filter-search" };
24
+ case FilterItemType.NUMBER:
25
+ return { tag: "snk-filter-number" };
26
+ case FilterItemType.PERSONALIZED:
27
+ return { tag: "snk-filter-personalized" };
28
+ case FilterItemType.MULTI_LIST:
29
+ return { tag: "snk-entity-list" };
30
+ }
31
+ return { tag: "snk-filter-text" };
32
+ }
33
+ updateFilterValue(newValue) {
34
+ const isVisble = !this.filterItem.visible ? newValue !== undefined : true;
35
+ this.filterItem = Object.assign(Object.assign({}, this.filterItem), { value: newValue, visible: isVisble });
36
+ }
37
+ canShowDetailModal() {
38
+ return this.filterItem.filterType !== FilterType.OTHER_FILTERS && this.filterItem.type !== FilterItemType.BINARY_SELECT;
39
+ }
40
+ componentDidLoad() {
41
+ if (this._element) {
42
+ ElementIDUtils.addIDInfo(this._element);
43
+ const dataElementIdDoFilterItem = this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
44
+ this._idContentEditor = `${dataElementIdDoFilterItem}_${this.filterItem.id}`;
45
+ }
46
+ }
47
+ render() {
48
+ const { tag: ContentEditor, variations } = this.getContentEditorConfig();
49
+ 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({ config: this.filterItem, value: this.filterItem.value, onValueChanged: (event) => this.updateFilterValue(event.detail), "data-element-id": this._idContentEditor }, variations)))));
50
+ }
51
+ static get is() { return "snk-filter-modal-item"; }
52
+ static get originalStyleUrls() {
53
+ return {
54
+ "$": ["snk-filter-modal-item.css"]
55
+ };
56
+ }
57
+ static get styleUrls() {
58
+ return {
59
+ "$": ["snk-filter-modal-item.css"]
60
+ };
61
+ }
62
+ static get properties() {
63
+ return {
64
+ "filterItem": {
65
+ "type": "unknown",
66
+ "mutable": true,
67
+ "complexType": {
68
+ "original": "SnkFilterItemConfig",
69
+ "resolved": "SnkFilterItemConfig",
70
+ "references": {
71
+ "SnkFilterItemConfig": {
72
+ "location": "import",
73
+ "path": "../../filter-item/snk-filter-item"
74
+ }
75
+ }
76
+ },
77
+ "required": false,
78
+ "optional": false,
79
+ "docs": {
80
+ "tags": [],
81
+ "text": ""
82
+ }
83
+ }
84
+ };
85
+ }
86
+ static get events() {
87
+ return [{
88
+ "method": "filterChange",
89
+ "name": "filterChange",
90
+ "bubbles": true,
91
+ "cancelable": true,
92
+ "composed": true,
93
+ "docs": {
94
+ "tags": [],
95
+ "text": ""
96
+ },
97
+ "complexType": {
98
+ "original": "SnkFilterItemConfig",
99
+ "resolved": "SnkFilterItemConfig",
100
+ "references": {
101
+ "SnkFilterItemConfig": {
102
+ "location": "import",
103
+ "path": "../../filter-item/snk-filter-item"
104
+ }
105
+ }
106
+ }
107
+ }];
108
+ }
109
+ static get elementRef() { return "_element"; }
110
+ static get watchers() {
111
+ return [{
112
+ "propName": "filterItem",
113
+ "methodName": "observeFilterItem"
114
+ }];
115
+ }
116
+ }
@@ -1,15 +1,10 @@
1
- import { h, Host } from '@stencil/core';
2
- import { ApplicationContext, ElementIDUtils, ErrorException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
1
+ import { ApplicationContext, ElementIDUtils, ErrorException, ObjectUtils } from '@sankhyalabs/core';
3
2
  import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
4
- import FilterItemType from './filter-item/filter-item-type.enum';
5
- import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
6
- import buildFilter from './filter-item/dataunitfilter/data-unit-filter-builder';
3
+ import { h, Host } from '@stencil/core';
7
4
  import { ConfigStorage } from '../../lib/configs/ConfigStorage';
8
- const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
9
- const DEFAULT_FILTER = "DEFAULT_FILTER";
10
- const CLEAR_ALL_FILTERS = "CLEAR_ALL_FILTERS";
11
- const ADD_FILTER = "ADD_FILTER";
12
- const APPLIED_FILTERS = "APPLIED_FILTERS";
5
+ import buildFilter from './filter-item/dataunitfilter/data-unit-filter-builder';
6
+ import FilterItemType from './filter-item/filter-item-type.enum';
7
+ import SnkFilterModalFactory from './utils/SnkFilterModalFactory';
13
8
  export class SnkFilterBar {
14
9
  constructor() {
15
10
  this._updateSequence = [];
@@ -96,9 +91,9 @@ export class SnkFilterBar {
96
91
  * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
97
92
  * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
98
93
  */
99
- getMessage(key, params) {
94
+ getMessage(key, params, defaultValue) {
100
95
  var _a;
101
- return (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, params);
96
+ return ((_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, params)) || defaultValue;
102
97
  }
103
98
  getFilter(_dataUnit) {
104
99
  var _a;
@@ -187,110 +182,6 @@ export class SnkFilterBar {
187
182
  return item;
188
183
  }).sort((a, b) => this._filtersComparator(a, b));
189
184
  }
190
- getAddListItems() {
191
- const hiddenItems = this.filterConfig
192
- .filter(item => !item.visible && this.isListable(item));
193
- const footerItems = [{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" }];
194
- if (this.allowDefault) {
195
- footerItems.push({ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" });
196
- }
197
- return hiddenItems.map(filter => { return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null }; })
198
- .concat(footerItems);
199
- }
200
- getActiveClass() {
201
- const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
202
- return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
203
- }
204
- isListable(item, allowPersonalized = false) {
205
- return item.type !== FilterItemType.DEFAULT_FILTER && (allowPersonalized || item.type !== FilterItemType.PERSONALIZED);
206
- }
207
- getAppliedListItems() {
208
- const appliedItems = this.filterConfig
209
- .filter(item => this.isActiveFilter(item) && this.isListable(item, true));
210
- return appliedItems.map(filter => {
211
- return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
212
- }).concat([
213
- { name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
214
- ]);
215
- }
216
- addPersonalizedFilters(personalizedItems) {
217
- const activeFilters = {};
218
- personalizedItems.forEach(item => {
219
- if (item.active) {
220
- activeFilters[item.id] = true;
221
- }
222
- });
223
- this.filterConfig = this.filterConfig.map(item => {
224
- var _a, _b;
225
- if (item.type === FilterItemType.PERSONALIZED) {
226
- const visible = activeFilters[item.id];
227
- if (!item.visible && visible) {
228
- this.calculateUpdateSequence(item);
229
- if (((_b = (_a = item.props) === null || _a === void 0 ? void 0 : _a.personalizedFilter) === null || _b === void 0 ? void 0 : _b.parameters) != undefined) {
230
- this._pendingFilters.push(item.id);
231
- }
232
- }
233
- return this.normalizeItem(visible ? Object.assign(Object.assign({}, item), { visible }) : Object.assign(Object.assign({}, item), { visible, value: undefined, fixed: undefined }));
234
- }
235
- return item;
236
- }).sort((a, b) => this._filtersComparator(a, b));
237
- }
238
- openDefaultFilterModal() {
239
- const filterModal = document.createElement("snk-filter-modal");
240
- const defaultFilter = this.filterConfig.filter(item => item.type === FilterItemType.DEFAULT_FILTER);
241
- filterModal.getMessage = (key, props) => this.getMessage(key, props);
242
- filterModal.modalTitle = this.getMessage("snkFilterBar.modalDefaultFilterTitle");
243
- filterModal.infoText = this.getMessage(defaultFilter.length == 0 ? "snkFilterBar.modalInfoTextCreateDefault" : "snkFilterBar.modalInfoTextEditDefault");
244
- filterModal.items = defaultFilter.map(item => {
245
- return { id: item.id, active: true, enabled: false, label: item.label };
246
- });
247
- filterModal.processModalAction = (_action) => {
248
- this._application.closeModal();
249
- };
250
- this._application.showModal(filterModal);
251
- }
252
- openPersonalizedModal() {
253
- const filterModal = document.createElement("snk-filter-modal");
254
- const personalizedFilter = this.filterConfig
255
- .filter(item => item.type === FilterItemType.PERSONALIZED)
256
- .sort((itemA, itemB) => StringUtils.compare(itemA.label, itemB.label));
257
- filterModal.getMessage = (key, props) => this.getMessage(key, props);
258
- filterModal.modalTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterTitle");
259
- filterModal.modalSubTitle = this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle");
260
- filterModal.okButtonLabel = this.getMessage("snkFilterBar.modalOkButtonLabel");
261
- filterModal.cancelButtonLabel = this.getMessage("snkFilterBar.modalCancelButtonLabel");
262
- filterModal.infoText = this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized");
263
- filterModal.useSearch = true;
264
- filterModal.items = personalizedFilter.map(item => {
265
- return { id: item.id, active: item.visible, enabled: true, label: item.label };
266
- });
267
- filterModal.processModalAction = (action) => {
268
- if (action === ModalAction.CANCEL) {
269
- // O Botão de cancelar, tem efeito específico:
270
- // - Desmarcar todos os filtros personalizados.
271
- filterModal.items = filterModal.items.map(item => {
272
- return Object.assign(Object.assign({}, item), { active: false });
273
- });
274
- }
275
- else {
276
- if (action === ModalAction.OK) {
277
- this.addPersonalizedFilters(filterModal.items);
278
- }
279
- this._application.closeModal();
280
- }
281
- };
282
- this._application.showModal(filterModal);
283
- }
284
- clearFilters() {
285
- let changed = false;
286
- this.filterConfig = this.filterConfig.map(item => {
287
- if (item.value != undefined) {
288
- changed = true;
289
- }
290
- return Object.assign(Object.assign({}, item), { value: undefined });
291
- }).sort((a, b) => this._filtersComparator(a, b));
292
- return changed;
293
- }
294
185
  loadPermitions() {
295
186
  this._application.isUserSup().then(value => this.allowDefault = value);
296
187
  }
@@ -339,31 +230,17 @@ export class SnkFilterBar {
339
230
  filterChangeListener(evt) {
340
231
  this.updateFilter(evt.detail);
341
232
  }
342
- addFilterHandler(itemName) {
343
- const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
344
- if (itemName === PERSONALIZED_FILTER) {
345
- this.openPersonalizedModal();
346
- }
347
- else if (itemName === DEFAULT_FILTER) {
348
- this.openDefaultFilterModal();
349
- }
350
- else if (filterItem) {
351
- this._pendingFilters.push(itemName);
352
- this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
353
- }
354
- }
355
- appliedFilterHandler(itemName) {
356
- if (itemName === CLEAR_ALL_FILTERS) {
357
- if (this.clearFilters()) {
358
- this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
359
- }
360
- }
361
- else {
362
- const filterItemElement = this._element.querySelector("#filter-" + itemName);
363
- if (filterItemElement) {
364
- filterItemElement.showUp(true);
365
- }
366
- }
233
+ async showFilterModal() {
234
+ const callbackOnApplyFilter = (filters) => {
235
+ this.filterConfig = filters.map(this.normalizeItem).sort((a, b) => this._filtersComparator(a, b));
236
+ };
237
+ const factoryParams = {
238
+ filterConfig: this.filterConfig,
239
+ onComplete: callbackOnApplyFilter,
240
+ getMessage: (key, props) => this.getMessage(key, props)
241
+ };
242
+ const factory = new SnkFilterModalFactory(factoryParams);
243
+ await factory.showModal();
367
244
  }
368
245
  componentWillLoad() {
369
246
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
@@ -380,7 +257,7 @@ export class SnkFilterBar {
380
257
  if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
381
258
  return undefined;
382
259
  }
383
- return (h(Host, null, h("ez-scroller", { direction: EzScrollDirection.HORIZONTAL, activeShadow: true, locked: this.scrollerLocked }, this.getFilterItems()), h("snk-filter-list", { id: APPLIED_FILTERS, onFocusin: () => this.itemFocused(APPLIED_FILTERS), items: this.getAppliedListItems(), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyAppliedFiltersList"), findFilterText: this.getMessage("snkFilterBar.findFilter"), iconName: "filter", class: "ez-padding-left--medium", buttonClass: this.getActiveClass(), onSnkItemSelected: evt => this.appliedFilterHandler(evt.detail), "data-element-id": "apppliedFilters" }), h("snk-filter-list", { id: ADD_FILTER, onFocusin: () => this.itemFocused(ADD_FILTER), items: this.getAddListItems(), label: this.getMessage("snkFilterBar.addFilter"), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyFiltersList"), findFilterText: this.getMessage("snkFilterBar.findField"), class: "ez-padding-left--medium", onSnkItemSelected: evt => this.addFilterHandler(evt.detail), "data-element-id": "addFilters" }, h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
260
+ return (h(Host, null, h("ez-scroller", { direction: EzScrollDirection.HORIZONTAL, activeShadow: true, locked: this.scrollerLocked }, this.getFilterItems()), h("ez-button", { class: "ez-padding-left--medium", size: "small", label: this.getMessage('snkFilterBar.filters', undefined, 'Filtros'), onClick: this.showFilterModal.bind(this) }, h("ez-icon", { slot: "leftIcon", iconName: "plus", class: "ez-padding-right--small" }))));
384
261
  }
385
262
  static get is() { return "snk-filter-bar"; }
386
263
  static get encapsulation() { return "scoped"; }