@sankhyalabs/sankhyablocks 1.3.31-beta.14 → 1.3.31-beta.17

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 (182) hide show
  1. package/dist/cjs/{SnkMessageBuilder-bb55d4c4.js → SnkMessageBuilder-cb132e6d.js} +134 -1
  2. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  3. package/dist/cjs/css-shim-b8158822.js +6 -0
  4. package/dist/cjs/dom-36862b77.js +75 -0
  5. package/dist/cjs/filter-item-type.enum-e2e1bc5b.js +14 -0
  6. package/dist/cjs/index-02201bc9.js +2397 -0
  7. package/dist/cjs/index-b0b676c5.js +3298 -0
  8. package/dist/cjs/loader.cjs.js +19 -3
  9. package/dist/cjs/sankhyablocks.cjs.js +117 -5
  10. package/dist/cjs/shadow-css-346c0795.js +389 -0
  11. package/dist/cjs/snk-application.cjs.entry.js +542 -66
  12. package/dist/cjs/snk-crud.cjs.entry.js +1 -1
  13. package/dist/cjs/snk-data-unit.cjs.entry.js +23 -24
  14. package/dist/cjs/snk-filter-bar.cjs.entry.js +199 -0
  15. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +47 -0
  16. package/dist/cjs/snk-filter-detail.cjs.entry.js +44 -0
  17. package/dist/cjs/snk-filter-item.cjs.entry.js +131 -0
  18. package/dist/cjs/snk-filter-list.cjs.entry.js +91 -0
  19. package/dist/cjs/snk-filter-number.cjs.entry.js +23 -0
  20. package/dist/cjs/snk-filter-period.cjs.entry.js +26 -0
  21. package/dist/cjs/snk-filter-search.cjs.entry.js +44 -0
  22. package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
  23. package/dist/cjs/{snk-form_2.cjs.entry.js → snk-form.cjs.entry.js} +3 -65
  24. package/dist/cjs/snk-grid.cjs.entry.js +69 -0
  25. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  26. package/dist/cjs/snk-taskbar.cjs.entry.js +5 -4
  27. package/dist/cjs/{taskbar-elements-2888ceb6.js → taskbar-elements-efa44ff1.js} +1 -1
  28. package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
  29. package/dist/collection/collection-manifest.json +11 -2
  30. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +7 -0
  31. package/dist/collection/components/snk-application/snk-application.js +775 -695
  32. package/dist/collection/components/snk-crud/snk-crud.js +75 -73
  33. package/dist/collection/components/snk-data-unit/snk-data-unit.js +262 -250
  34. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +88 -0
  35. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +64 -0
  36. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +69 -0
  37. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +118 -0
  38. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
  39. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +10 -0
  40. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +113 -0
  41. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +209 -0
  42. package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +182 -0
  43. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +99 -0
  44. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +257 -0
  45. package/dist/collection/components/snk-form/snk-form.js +111 -111
  46. package/dist/collection/components/snk-grid/snk-grid.css +14 -1
  47. package/dist/collection/components/snk-grid/snk-grid.js +93 -92
  48. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +80 -79
  49. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +1 -2
  50. package/dist/collection/components/snk-taskbar/snk-taskbar.js +128 -116
  51. package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
  52. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +24 -2
  53. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +1 -1
  54. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +268 -0
  55. package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
  56. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
  57. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +14 -0
  58. package/dist/components/SnkMessageBuilder.js +134 -2
  59. package/dist/components/filter-item-type.enum.js +12 -0
  60. package/dist/components/index.d.ts +17 -5
  61. package/dist/components/index.js +21 -0
  62. package/dist/components/index2.js +2384 -0
  63. package/dist/components/snk-application2.js +508 -30
  64. package/dist/components/snk-crud.js +25 -1
  65. package/dist/components/snk-data-unit.js +3 -4
  66. package/dist/components/snk-filter-bar.d.ts +11 -0
  67. package/dist/components/snk-filter-bar.js +6 -0
  68. package/dist/components/snk-filter-bar2.js +230 -0
  69. package/dist/components/snk-filter-binary-select.d.ts +11 -0
  70. package/dist/components/snk-filter-binary-select.js +63 -0
  71. package/dist/components/snk-filter-detail.d.ts +11 -0
  72. package/dist/components/snk-filter-detail.js +6 -0
  73. package/dist/components/snk-filter-detail2.js +58 -0
  74. package/dist/components/snk-filter-item.d.ts +11 -0
  75. package/dist/components/snk-filter-item.js +6 -0
  76. package/dist/components/snk-filter-item2.js +151 -0
  77. package/dist/components/snk-filter-list.d.ts +11 -0
  78. package/dist/components/snk-filter-list.js +6 -0
  79. package/dist/components/snk-filter-list2.js +108 -0
  80. package/dist/components/snk-filter-number.d.ts +11 -0
  81. package/dist/components/snk-filter-number.js +39 -0
  82. package/dist/components/snk-filter-period.d.ts +11 -0
  83. package/dist/components/snk-filter-period.js +42 -0
  84. package/dist/components/snk-filter-search.d.ts +11 -0
  85. package/dist/components/snk-filter-search.js +62 -0
  86. package/dist/components/snk-filter-text.d.ts +11 -0
  87. package/dist/components/snk-filter-text.js +38 -0
  88. package/dist/components/snk-form2.js +1 -1
  89. package/dist/components/snk-grid2.js +28 -4
  90. package/dist/components/snk-pesquisa2.js +1 -1
  91. package/dist/components/snk-taskbar2.js +2 -1
  92. package/dist/components/teste-pesquisa.js +1 -1
  93. package/dist/esm/{SnkMessageBuilder-17d91b88.js → SnkMessageBuilder-cff80920.js} +134 -2
  94. package/dist/esm/app-globals-0f993ce5.js +3 -0
  95. package/dist/esm/css-shim-b3f2ee8d.js +4 -0
  96. package/dist/esm/dom-665d6011.js +73 -0
  97. package/dist/esm/filter-item-type.enum-61fbf80a.js +12 -0
  98. package/dist/esm/index-2b4d2d14.js +3262 -0
  99. package/dist/esm/index-e5b61043.js +2384 -0
  100. package/dist/esm/loader.js +19 -3
  101. package/dist/esm/polyfills/css-shim.js +1 -1
  102. package/dist/esm/sankhyablocks.js +117 -5
  103. package/dist/esm/shadow-css-b18e99d7.js +387 -0
  104. package/dist/esm/snk-application.entry.js +507 -31
  105. package/dist/esm/snk-crud.entry.js +1 -1
  106. package/dist/esm/snk-data-unit.entry.js +4 -5
  107. package/dist/esm/snk-filter-bar.entry.js +195 -0
  108. package/dist/esm/snk-filter-binary-select.entry.js +43 -0
  109. package/dist/esm/snk-filter-detail.entry.js +40 -0
  110. package/dist/esm/snk-filter-item.entry.js +127 -0
  111. package/dist/esm/snk-filter-list.entry.js +87 -0
  112. package/dist/esm/snk-filter-number.entry.js +19 -0
  113. package/dist/esm/snk-filter-period.entry.js +22 -0
  114. package/dist/esm/snk-filter-search.entry.js +40 -0
  115. package/dist/esm/snk-filter-text.entry.js +18 -0
  116. package/dist/esm/{snk-form_2.entry.js → snk-form.entry.js} +3 -64
  117. package/dist/esm/snk-grid.entry.js +65 -0
  118. package/dist/esm/snk-pesquisa.entry.js +2 -2
  119. package/dist/esm/snk-taskbar.entry.js +4 -3
  120. package/dist/esm/{taskbar-elements-5ea74223.js → taskbar-elements-c119510a.js} +1 -1
  121. package/dist/esm/teste-pesquisa.entry.js +2 -2
  122. package/dist/sankhyablocks/SnkMessageBuilder-cff80920.js +299 -0
  123. package/dist/sankhyablocks/app-globals-0f993ce5.js +3 -0
  124. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +4 -0
  125. package/dist/sankhyablocks/dom-665d6011.js +73 -0
  126. package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +12 -0
  127. package/dist/sankhyablocks/index-2b4d2d14.js +3262 -0
  128. package/dist/sankhyablocks/index-e5b61043.js +2384 -0
  129. package/dist/sankhyablocks/index.esm.js +1 -0
  130. package/dist/sankhyablocks/sankhyablocks.esm.js +129 -1
  131. package/dist/sankhyablocks/shadow-css-b18e99d7.js +387 -0
  132. package/dist/sankhyablocks/snk-application.entry.js +8306 -0
  133. package/dist/sankhyablocks/snk-crud.entry.js +60 -0
  134. package/dist/sankhyablocks/snk-data-unit.entry.js +272 -0
  135. package/dist/sankhyablocks/snk-filter-bar.entry.js +195 -0
  136. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +43 -0
  137. package/dist/sankhyablocks/snk-filter-detail.entry.js +40 -0
  138. package/dist/sankhyablocks/snk-filter-item.entry.js +127 -0
  139. package/dist/sankhyablocks/snk-filter-list.entry.js +87 -0
  140. package/dist/sankhyablocks/snk-filter-number.entry.js +19 -0
  141. package/dist/sankhyablocks/snk-filter-period.entry.js +22 -0
  142. package/dist/sankhyablocks/snk-filter-search.entry.js +40 -0
  143. package/dist/sankhyablocks/snk-filter-text.entry.js +18 -0
  144. package/dist/sankhyablocks/snk-form.entry.js +111 -0
  145. package/dist/sankhyablocks/snk-grid.entry.js +65 -0
  146. package/dist/sankhyablocks/snk-pesquisa.entry.js +311 -0
  147. package/dist/sankhyablocks/snk-taskbar.entry.js +153 -0
  148. package/dist/sankhyablocks/taskbar-elements-c119510a.js +72 -0
  149. package/dist/sankhyablocks/teste-pesquisa.entry.js +33 -0
  150. package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
  151. package/dist/types/components/snk-application/snk-application.d.ts +9 -0
  152. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
  153. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +7 -0
  154. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +13 -0
  155. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +12 -0
  156. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +7 -0
  157. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +9 -0
  158. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +13 -0
  159. package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +37 -0
  160. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +43 -0
  161. package/dist/types/components.d.ts +199 -0
  162. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
  163. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +5 -0
  164. package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
  165. package/dist/types/stencil-public-runtime.d.ts +15 -4
  166. package/loader/package.json +1 -0
  167. package/package.json +5 -5
  168. package/react/components.d.ts +0 -7
  169. package/react/components.js +0 -7
  170. package/react/components.js.map +1 -1
  171. package/dist/cjs/index-c6671817.js +0 -1642
  172. package/dist/esm/index-6a83ac96.js +0 -1614
  173. package/dist/sankhyablocks/p-4c7b32d6.entry.js +0 -1
  174. package/dist/sankhyablocks/p-56a32417.entry.js +0 -1
  175. package/dist/sankhyablocks/p-825d2c38.entry.js +0 -74
  176. package/dist/sankhyablocks/p-ab694dbc.js +0 -1
  177. package/dist/sankhyablocks/p-b559117b.js +0 -1
  178. package/dist/sankhyablocks/p-cd1dc099.js +0 -2
  179. package/dist/sankhyablocks/p-ce2d1214.entry.js +0 -1
  180. package/dist/sankhyablocks/p-d25637c9.entry.js +0 -1
  181. package/dist/sankhyablocks/p-d25803a1.entry.js +0 -1
  182. package/dist/sankhyablocks/p-edf81d2c.entry.js +0 -1
@@ -0,0 +1,182 @@
1
+ import { ArrayUtils, FloatingManager } from '@sankhyalabs/core';
2
+ import { h, Host } from '@stencil/core';
3
+ const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
4
+ const MAX_FILTERS = 5;
5
+ export class SnkFilterList {
6
+ constructor() {
7
+ this.innerClickCheck = (floatingContainer, node) => {
8
+ if (node && floatingContainer) {
9
+ if (!node.offsetParent) {
10
+ return true;
11
+ }
12
+ let current = node;
13
+ do {
14
+ if (current === floatingContainer || current === this._element) {
15
+ return true;
16
+ }
17
+ } while ((current = current.offsetParent) != null);
18
+ }
19
+ this._detailIsVisible = false;
20
+ return false;
21
+ };
22
+ }
23
+ showList() {
24
+ this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck });
25
+ this._detailIsVisible = true;
26
+ this._showAll = false;
27
+ this._filterArgument = "";
28
+ }
29
+ hideList() {
30
+ if (this._floatingID != undefined) {
31
+ FloatingManager.close(this._floatingID);
32
+ }
33
+ this._floatingID = undefined;
34
+ this._detailIsVisible = false;
35
+ }
36
+ buttonClick() {
37
+ if (this._detailIsVisible) {
38
+ this.hideList();
39
+ }
40
+ else {
41
+ this.showList();
42
+ }
43
+ }
44
+ componentDidRender() {
45
+ if (this._floatingID == undefined) {
46
+ if (this._popover) {
47
+ this._popover.remove();
48
+ }
49
+ }
50
+ }
51
+ buildItemElement(item) {
52
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item", onClick: () => this.itemSelected(item.name) }, item.iconName ? h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, h("div", { class: `ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${item.labelClass || ""}` }, item.label)));
53
+ }
54
+ itemSelected(itemName) {
55
+ if (itemName === SHOW_MORE_ITEM_NAME) {
56
+ this._showAll = true;
57
+ }
58
+ else {
59
+ this.hideList();
60
+ this.snkItemSelected.emit(itemName);
61
+ }
62
+ }
63
+ getFilterItems() {
64
+ const items = this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
65
+ if (items.length === 0) {
66
+ return h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty" }, this.getMessage("snkFilterBar.emptyFilterList"));
67
+ }
68
+ const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
69
+ if (hideItems) {
70
+ items.splice(MAX_FILTERS);
71
+ items.push({ kind: "INTERNAL", label: "Mostrar mais", iconName: "dots-horizontal", name: SHOW_MORE_ITEM_NAME, iconClass: "snk-filter-bar__filter-list-item__icon--secondary", labelClass: "snk-filter-bar__filter-list-item__label--secondary" });
72
+ }
73
+ return h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
74
+ }
75
+ getFooterItems() {
76
+ return this.items.filter(item => item.kind === "FOOTER");
77
+ }
78
+ render() {
79
+ return (h(Host, { class: "ez-flex ez-flex--column" }, h("ez-button", { label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, h("slot", { name: "leftIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem }, h("ez-filter-input", { ref: ref => this._filterInput = ref, mode: "slim", label: this.getMessage("snkFilterBar.findFilter"), value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail }), this.getFilterItems(), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
80
+ }
81
+ static get is() { return "snk-filter-list"; }
82
+ static get properties() {
83
+ return {
84
+ "label": {
85
+ "type": "string",
86
+ "mutable": false,
87
+ "complexType": {
88
+ "original": "string",
89
+ "resolved": "string",
90
+ "references": {}
91
+ },
92
+ "required": false,
93
+ "optional": false,
94
+ "docs": {
95
+ "tags": [],
96
+ "text": ""
97
+ },
98
+ "attribute": "label",
99
+ "reflect": false
100
+ },
101
+ "iconName": {
102
+ "type": "string",
103
+ "mutable": false,
104
+ "complexType": {
105
+ "original": "string",
106
+ "resolved": "string",
107
+ "references": {}
108
+ },
109
+ "required": false,
110
+ "optional": false,
111
+ "docs": {
112
+ "tags": [],
113
+ "text": ""
114
+ },
115
+ "attribute": "icon-name",
116
+ "reflect": false
117
+ },
118
+ "items": {
119
+ "type": "unknown",
120
+ "mutable": false,
121
+ "complexType": {
122
+ "original": "Array<ListItem>",
123
+ "resolved": "ListItem[]",
124
+ "references": {
125
+ "Array": {
126
+ "location": "global"
127
+ },
128
+ "ListItem": {
129
+ "location": "local"
130
+ }
131
+ }
132
+ },
133
+ "required": false,
134
+ "optional": false,
135
+ "docs": {
136
+ "tags": [],
137
+ "text": ""
138
+ }
139
+ },
140
+ "getMessage": {
141
+ "type": "unknown",
142
+ "mutable": false,
143
+ "complexType": {
144
+ "original": "(key: string, props?: any) => string",
145
+ "resolved": "(key: string, props?: any) => string",
146
+ "references": {}
147
+ },
148
+ "required": false,
149
+ "optional": false,
150
+ "docs": {
151
+ "tags": [],
152
+ "text": ""
153
+ }
154
+ }
155
+ };
156
+ }
157
+ static get states() {
158
+ return {
159
+ "_filterArgument": {},
160
+ "_showAll": {}
161
+ };
162
+ }
163
+ static get events() {
164
+ return [{
165
+ "method": "snkItemSelected",
166
+ "name": "snkItemSelected",
167
+ "bubbles": true,
168
+ "cancelable": true,
169
+ "composed": true,
170
+ "docs": {
171
+ "tags": [],
172
+ "text": ""
173
+ },
174
+ "complexType": {
175
+ "original": "string",
176
+ "resolved": "string",
177
+ "references": {}
178
+ }
179
+ }];
180
+ }
181
+ static get elementRef() { return "_element"; }
182
+ }
@@ -0,0 +1,99 @@
1
+ :host {
2
+ display: grid;
3
+ grid-template-columns: minmax(100px, 100%) 1fr 1fr;
4
+ }
5
+
6
+ .snk-filter__popover-container{
7
+ /*private*/
8
+ display: flex;
9
+ cursor: auto;
10
+ }
11
+
12
+ .snk-filter__popover{
13
+ /*private*/
14
+ display: flex;
15
+ flex-direction: column;
16
+ position: absolute;
17
+ width: fit-content;
18
+ height: fit-content;
19
+ min-width: 265px;
20
+
21
+ /*public*/
22
+ z-index: var(--more-visible, 1);
23
+ background-color: var(--background--xlight, #fff);
24
+ border-radius: var(--border--radius-medium, 12px);
25
+ box-shadow: var(--shadow, 0px 0px 16px 0px #000);
26
+
27
+ }
28
+
29
+ .snk-filter-item__editor-header{
30
+ flex-grow: 1;
31
+ font-weight: var(--text-weight--medium, 400);
32
+ color: var(--color--title-primary, #2B3A54);
33
+ }
34
+
35
+ .snk-filter__popover-rule{
36
+ border-style: solid;
37
+ border-color: var(--color--disable-secondary, #F2F5F8);
38
+ border-radius: 1px;
39
+ border-width: 1px;
40
+ width: 100%;
41
+ }
42
+
43
+ .editor__ez-check{
44
+ --ez-check__label--padding-left: 0;
45
+ }
46
+
47
+ .snk-filter-item__editor-header-button{
48
+ cursor: pointer;
49
+ flex-grow: 0;
50
+ }
51
+
52
+ .snk-filter-bar__divider{
53
+ margin-bottom: var(--space--small);
54
+ }
55
+
56
+ .snk-filter-bar__filter-list-items-container{
57
+ overflow-y: auto;
58
+ max-height: 360px;
59
+ margin-top: var(--space--small, 6px);
60
+ }
61
+
62
+ .snk-filter-bar__filter-list-item{
63
+ cursor: pointer;
64
+ border-radius: var(--border--radius-small, 6px);
65
+ }
66
+
67
+ .snk-filter-bar__filter-list-item__label{
68
+ color: var(--title--primary);
69
+ }
70
+
71
+ .snk-filter-bar__filter-list-item__label--secondary{
72
+ color: var(--text--primary);
73
+ }
74
+
75
+ .snk-filter-bar__filter-list-item__icon{
76
+ --ez-icon--color: var(--title--primary);
77
+ }
78
+
79
+ .snk-filter-bar__filter-list-item__icon--secondary{
80
+ --ez-icon--color: var(--text--secondary);
81
+ }
82
+
83
+ .snk-filter-bar__filter-list-item.preselected {
84
+
85
+ background-color: var(--background--medium);
86
+ }
87
+
88
+ .snk-filter-bar__filter-list-item:hover{
89
+ background-color: var(--background--medium);
90
+ }
91
+
92
+ .snk-filter-bar__filter-list-items-container--empty{
93
+ width: 100%;
94
+ height: 100px;
95
+ display: flex;
96
+ justify-content: center;
97
+ align-self: center;
98
+ align-items: center;
99
+ }
@@ -0,0 +1,257 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { ApplicationContext, DataType, ErrorException, ObjectUtils } from '@sankhyalabs/core';
3
+ import FilterItemType from './filter-item/filter-item-type.enum';
4
+ import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
5
+ const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
6
+ const DEFAULT_FILTER = "DEFAULT_FILTER";
7
+ export class SnkFilterBar {
8
+ constructor() {
9
+ this._updateSequence = [];
10
+ this._calculateSortIndex = (item) => {
11
+ let index = item.hardFixed ? 1000000 : 0;
12
+ //campos Hard Fixed não variam a ordem
13
+ if (!item.hardFixed) {
14
+ index += item.fixed ? 100000 : 0;
15
+ index += item.value == undefined ? 0 : 10000;
16
+ index += this._updateSequence.lastIndexOf(item.id) + 1;
17
+ }
18
+ return index;
19
+ };
20
+ this._filtersComparator = (a, b) => {
21
+ return this._calculateSortIndex(b) - this._calculateSortIndex(a);
22
+ };
23
+ }
24
+ /**
25
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
26
+ * através de um pequeno modulo na estrutura da aplicação:
27
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
28
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
29
+ */
30
+ getMessage(key, params) {
31
+ return this._application.messagesBuilder.getMessage(key, params);
32
+ }
33
+ getFilter(_dataUnit) {
34
+ const filters = [];
35
+ this.filterConfig.filter(item => item.value).forEach(item => {
36
+ const filter = this.buildDUFilter(item);
37
+ if (filter) {
38
+ filters.push(filter);
39
+ }
40
+ });
41
+ return filters;
42
+ }
43
+ buildDUFilter(item) {
44
+ const { id, value, type, props, visible } = item;
45
+ if (value && visible) {
46
+ if (type === FilterItemType.BINARY_SELECT) {
47
+ const options = props.options;
48
+ const selectedOption = options.find(opt => opt.name === value);
49
+ //FIXME: ajustar o backend para não exigir parametros
50
+ return { name: id, expression: selectedOption.expression, params: [] };
51
+ }
52
+ if (type === FilterItemType.PERIOD) {
53
+ const { end, start } = value;
54
+ const params = [];
55
+ let expression;
56
+ if (end && start) {
57
+ expression = props.expression.fullfill;
58
+ params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
59
+ }
60
+ else {
61
+ if (start) {
62
+ expression = props.expression.onlystart;
63
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
64
+ }
65
+ else {
66
+ expression = props.expression.onlyend;
67
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
68
+ }
69
+ }
70
+ return { name: id, expression, params };
71
+ }
72
+ if (type === FilterItemType.SEARCH) {
73
+ const expression = props.expression;
74
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
75
+ }
76
+ if (type === FilterItemType.TEXT) {
77
+ const expression = props.expression;
78
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
79
+ }
80
+ if (type === FilterItemType.NUMBER) {
81
+ const expression = props.expression;
82
+ return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
83
+ }
84
+ //No mapeamento dos outros tipos precisamos saber o tipo de dado.
85
+ }
86
+ return undefined;
87
+ }
88
+ componentWillLoad() {
89
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
90
+ if (this._application) {
91
+ this._application.getFilterBarConfig()
92
+ .then((filters) => {
93
+ this.filterConfig = filters;
94
+ })
95
+ .catch(reason => {
96
+ throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
97
+ });
98
+ }
99
+ if (this.dataUnit == undefined) {
100
+ let parent = this._element.parentElement;
101
+ while (parent) {
102
+ if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
103
+ const snkDataUnit = parent;
104
+ this.dataUnit = snkDataUnit.dataUnit;
105
+ if (this.dataUnit) {
106
+ this.dataUnit.addFilterProvider(this);
107
+ }
108
+ else {
109
+ snkDataUnit.addEventListener("dataUnitReady", (evt) => {
110
+ this.dataUnit = evt.detail;
111
+ this.dataUnit.addFilterProvider(this);
112
+ });
113
+ }
114
+ break;
115
+ }
116
+ parent = parent.parentElement;
117
+ }
118
+ }
119
+ }
120
+ getFilterItems() {
121
+ const pinnedItems = [];
122
+ const unpinnedItems = [];
123
+ this._items = this.filterConfig
124
+ .filter(item => item.visible)
125
+ .sort((a, b) => this._filtersComparator(a, b))
126
+ .map((item, index) => {
127
+ const filterItem = (h("snk-filter-item", { config: item, class: index > 0 ? "ez-padding-left--medium" : "", getMessage: (key, props) => this.getMessage(key, props), key: item.id }));
128
+ if (item.fixed || item.hardFixed) {
129
+ pinnedItems.push(filterItem);
130
+ }
131
+ else {
132
+ unpinnedItems.push(filterItem);
133
+ }
134
+ return filterItem;
135
+ });
136
+ const elements = [];
137
+ elements.push(...pinnedItems);
138
+ if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
139
+ elements.push(h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
140
+ }
141
+ elements.push(...unpinnedItems);
142
+ return elements;
143
+ }
144
+ calculateUpdateSequence(item) {
145
+ this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
146
+ this._updateSequence.push(item.id);
147
+ }
148
+ filterChangeListener(evt) {
149
+ this.updateFilter(evt.detail);
150
+ }
151
+ updateFilter(newItem) {
152
+ this.calculateUpdateSequence(newItem);
153
+ let needRefresh = false;
154
+ this.filterConfig = this.filterConfig.map(item => {
155
+ if (item.id === newItem.id) {
156
+ needRefresh = ObjectUtils.objectToString(item.value) !== ObjectUtils.objectToString(newItem.value);
157
+ return newItem;
158
+ }
159
+ return item;
160
+ });
161
+ if (needRefresh) {
162
+ this.dataUnit.loadData();
163
+ }
164
+ }
165
+ getAddListItems() {
166
+ const hiddenItems = this.filterConfig
167
+ .filter(item => !item.visible)
168
+ .sort(this._filtersComparator);
169
+ return hiddenItems.map(filter => {
170
+ return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
171
+ }).concat([
172
+ { name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" },
173
+ { name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" }
174
+ ]);
175
+ }
176
+ addFilterHandler(itemName) {
177
+ const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
178
+ if (filterItem) {
179
+ this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
180
+ }
181
+ }
182
+ render() {
183
+ if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
184
+ return undefined;
185
+ }
186
+ return (h(Host, null, h("ez-scroller", { direction: "horizontal" }, this.getFilterItems()), h("ez-button", { mode: "icon", size: "small", iconName: "filter", class: "ez-padding-left--medium" }), h("snk-filter-list", { items: this.getAddListItems(), label: this.getMessage("snkFilterBar.addFilter"), getMessage: (key, params) => this.getMessage(key, params), class: "ez-padding-left--medium", onSnkItemSelected: evt => this.addFilterHandler(evt.detail) }, h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
187
+ }
188
+ static get is() { return "snk-filter-bar"; }
189
+ static get encapsulation() { return "scoped"; }
190
+ static get originalStyleUrls() {
191
+ return {
192
+ "$": ["snk-filter-bar.css"]
193
+ };
194
+ }
195
+ static get styleUrls() {
196
+ return {
197
+ "$": ["snk-filter-bar.css"]
198
+ };
199
+ }
200
+ static get properties() {
201
+ return {
202
+ "dataUnit": {
203
+ "type": "unknown",
204
+ "mutable": true,
205
+ "complexType": {
206
+ "original": "DataUnit",
207
+ "resolved": "DataUnit",
208
+ "references": {
209
+ "DataUnit": {
210
+ "location": "import",
211
+ "path": "@sankhyalabs/core"
212
+ }
213
+ }
214
+ },
215
+ "required": false,
216
+ "optional": false,
217
+ "docs": {
218
+ "tags": [],
219
+ "text": "Recebe o DataUnit do ambiente. Se n\u00E3o for informado, procura pela refer\u00EAncia\ndo SnkDataUnit. Necess\u00E1rio para se registrar como provedor de filtros."
220
+ }
221
+ },
222
+ "filterConfig": {
223
+ "type": "unknown",
224
+ "mutable": true,
225
+ "complexType": {
226
+ "original": "Array<SnkFilterItemConfig>",
227
+ "resolved": "SnkFilterItemConfig[]",
228
+ "references": {
229
+ "Array": {
230
+ "location": "global"
231
+ },
232
+ "SnkFilterItemConfig": {
233
+ "location": "import",
234
+ "path": "./filter-item/snk-filter-item"
235
+ }
236
+ }
237
+ },
238
+ "required": false,
239
+ "optional": false,
240
+ "docs": {
241
+ "tags": [],
242
+ "text": "Lista de todos os filtros dispon\u00EDveis ao usu\u00E1rio."
243
+ }
244
+ }
245
+ };
246
+ }
247
+ static get elementRef() { return "_element"; }
248
+ static get listeners() {
249
+ return [{
250
+ "name": "filterChange",
251
+ "method": "filterChangeListener",
252
+ "target": undefined,
253
+ "capture": false,
254
+ "passive": false
255
+ }];
256
+ }
257
+ }