@sankhyalabs/sankhyablocks 1.4.0-beta.1 → 1.4.0-beta.3

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 (163) hide show
  1. package/dist/cjs/{SnkMessageBuilder-7717f1e4.js → SnkMessageBuilder-d8215915.js} +14 -119
  2. package/dist/cjs/{filter-item-type.enum-e2e1bc5b.js → filter-item-type.enum-3daf58d3.js} +2 -0
  3. package/dist/cjs/{index-b0b676c5.js → index-6fcf07f3.js} +159 -1515
  4. package/dist/cjs/loader.cjs.js +2 -18
  5. package/dist/cjs/sankhyablocks.cjs.js +4 -116
  6. package/dist/cjs/snk-application.cjs.entry.js +84 -230
  7. package/dist/cjs/snk-crud.cjs.entry.js +3 -3
  8. package/dist/cjs/snk-data-unit.cjs.entry.js +24 -32
  9. package/dist/cjs/snk-filter-bar_5.cjs.entry.js +902 -0
  10. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +2 -2
  11. package/dist/cjs/snk-filter-detail.cjs.entry.js +38 -3
  12. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-filter-number.cjs.entry.js +2 -2
  14. package/dist/cjs/snk-filter-period.cjs.entry.js +2 -2
  15. package/dist/cjs/snk-filter-personalized.cjs.entry.js +90 -0
  16. package/dist/cjs/snk-filter-search.cjs.entry.js +4 -4
  17. package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
  18. package/dist/cjs/{snk-form.cjs.entry.js → snk-form_2.cjs.entry.js} +119 -5
  19. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  20. package/dist/cjs/{taskbar-elements-283c737e.js → taskbar-elements-aedfeae6.js} +1 -1
  21. package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
  22. package/dist/collection/collection-manifest.json +2 -0
  23. package/dist/collection/components/snk-application/snk-application.js +54 -7
  24. package/dist/collection/components/snk-crud/snk-crud.js +2 -4
  25. package/dist/collection/components/snk-data-unit/snk-data-unit.js +0 -27
  26. package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +100 -0
  27. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +161 -0
  28. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +2 -0
  29. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +36 -1
  30. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +32 -9
  31. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +196 -0
  32. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +22 -0
  33. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +238 -139
  34. package/dist/collection/components/snk-grid/snk-grid.js +2 -4
  35. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +18 -10
  36. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +14 -2
  37. package/dist/components/SnkMessageBuilder.js +15 -119
  38. package/dist/components/filter-item-type.enum.js +2 -0
  39. package/dist/components/index.d.ts +2 -0
  40. package/dist/components/index.js +2 -4
  41. package/dist/components/snk-application2.js +47 -191
  42. package/dist/components/snk-crud.js +16 -10
  43. package/dist/components/snk-data-unit.js +3 -12
  44. package/dist/components/snk-filter-bar2.js +342 -146
  45. package/dist/components/snk-filter-detail2.js +36 -1
  46. package/dist/components/snk-filter-item2.js +33 -10
  47. package/dist/components/snk-filter-list2.js +1 -1
  48. package/dist/components/snk-filter-modal.d.ts +11 -0
  49. package/dist/components/snk-filter-modal.js +6 -0
  50. package/dist/components/snk-filter-modal2.js +58 -0
  51. package/dist/components/snk-filter-personalized.d.ts +11 -0
  52. package/dist/components/snk-filter-personalized.js +108 -0
  53. package/dist/components/snk-filter-search.js +1 -1
  54. package/dist/components/snk-form2.js +1 -1
  55. package/dist/components/snk-grid2.js +16 -10
  56. package/dist/components/snk-pesquisa2.js +1 -1
  57. package/dist/components/snk-taskbar2.js +1 -1
  58. package/dist/components/teste-pesquisa.js +1 -1
  59. package/dist/{sankhyablocks/SnkMessageBuilder-a7da466b.js → esm/SnkMessageBuilder-35a20271.js} +15 -119
  60. package/dist/esm/{filter-item-type.enum-61fbf80a.js → filter-item-type.enum-a79b2fa8.js} +2 -0
  61. package/dist/{sankhyablocks/index-2b4d2d14.js → esm/index-81dda3cf.js} +160 -1508
  62. package/dist/esm/loader.js +2 -18
  63. package/dist/esm/sankhyablocks.js +4 -116
  64. package/dist/esm/snk-application.entry.js +46 -192
  65. package/dist/esm/snk-crud.entry.js +2 -2
  66. package/dist/esm/snk-data-unit.entry.js +4 -12
  67. package/dist/esm/snk-filter-bar_5.entry.js +894 -0
  68. package/dist/esm/snk-filter-binary-select.entry.js +2 -2
  69. package/dist/esm/snk-filter-detail.entry.js +38 -3
  70. package/dist/esm/snk-filter-multi-select.entry.js +2 -2
  71. package/dist/esm/snk-filter-number.entry.js +2 -2
  72. package/dist/esm/snk-filter-period.entry.js +2 -2
  73. package/dist/esm/snk-filter-personalized.entry.js +86 -0
  74. package/dist/esm/snk-filter-search.entry.js +3 -3
  75. package/dist/esm/snk-filter-text.entry.js +1 -1
  76. package/dist/esm/{snk-form.entry.js → snk-form_2.entry.js} +117 -4
  77. package/dist/esm/snk-pesquisa.entry.js +2 -2
  78. package/dist/{sankhyablocks/taskbar-elements-35d64ff9.js → esm/taskbar-elements-38eb5d51.js} +1 -1
  79. package/dist/esm/teste-pesquisa.entry.js +2 -2
  80. package/dist/sankhyablocks/index.esm.js +0 -1
  81. package/dist/sankhyablocks/p-0352c0e2.entry.js +1 -0
  82. package/dist/sankhyablocks/p-07ebda01.entry.js +1 -0
  83. package/dist/sankhyablocks/p-322c0df2.entry.js +1 -0
  84. package/dist/sankhyablocks/p-46caa101.entry.js +1 -0
  85. package/dist/sankhyablocks/p-473cedf9.entry.js +1 -0
  86. package/dist/sankhyablocks/p-586e2522.js +1 -0
  87. package/dist/sankhyablocks/p-86f15ffe.js +1 -0
  88. package/dist/sankhyablocks/p-8f3c5709.entry.js +1 -0
  89. package/dist/sankhyablocks/p-97009a2c.entry.js +1 -0
  90. package/dist/sankhyablocks/p-9be74b46.entry.js +74 -0
  91. package/dist/sankhyablocks/p-9dd2b8cb.js +1 -0
  92. package/dist/sankhyablocks/p-a8b59c61.entry.js +1 -0
  93. package/dist/sankhyablocks/p-aecf3e0a.entry.js +1 -0
  94. package/dist/sankhyablocks/p-c1c3b5d8.entry.js +1 -0
  95. package/dist/sankhyablocks/p-c78cb79a.entry.js +1 -0
  96. package/dist/sankhyablocks/p-c9eec639.entry.js +1 -0
  97. package/dist/sankhyablocks/p-dc482a42.entry.js +1 -0
  98. package/dist/sankhyablocks/p-fac2b6a9.js +2 -0
  99. package/dist/sankhyablocks/p-fb705f81.entry.js +1 -0
  100. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -129
  101. package/dist/types/components/snk-application/snk-application.d.ts +4 -1
  102. package/dist/types/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.d.ts +4 -0
  103. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +23 -0
  104. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +3 -1
  105. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +2 -0
  106. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +23 -0
  107. package/dist/types/components.d.ts +56 -8
  108. package/package.json +3 -3
  109. package/react/components.d.ts +19 -0
  110. package/react/components.js +19 -0
  111. package/react/components.js.map +1 -1
  112. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  113. package/dist/cjs/css-shim-b8158822.js +0 -6
  114. package/dist/cjs/dom-36862b77.js +0 -75
  115. package/dist/cjs/index-02201bc9.js +0 -2397
  116. package/dist/cjs/shadow-css-346c0795.js +0 -389
  117. package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -278
  118. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -154
  119. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -91
  120. package/dist/cjs/snk-grid.cjs.entry.js +0 -79
  121. package/dist/cjs/snk-taskbar.cjs.entry.js +0 -160
  122. package/dist/cjs/taskbar-processor-6bd0d35c.js +0 -47
  123. package/dist/components/index2.js +0 -2384
  124. package/dist/esm/SnkMessageBuilder-a7da466b.js +0 -303
  125. package/dist/esm/app-globals-0f993ce5.js +0 -3
  126. package/dist/esm/css-shim-b3f2ee8d.js +0 -4
  127. package/dist/esm/dom-665d6011.js +0 -73
  128. package/dist/esm/index-2b4d2d14.js +0 -3262
  129. package/dist/esm/index-f1d3e4da.js +0 -2384
  130. package/dist/esm/shadow-css-b18e99d7.js +0 -387
  131. package/dist/esm/snk-filter-bar.entry.js +0 -274
  132. package/dist/esm/snk-filter-item.entry.js +0 -150
  133. package/dist/esm/snk-filter-list.entry.js +0 -87
  134. package/dist/esm/snk-grid.entry.js +0 -75
  135. package/dist/esm/snk-taskbar.entry.js +0 -156
  136. package/dist/esm/taskbar-elements-35d64ff9.js +0 -90
  137. package/dist/esm/taskbar-processor-aa6772c9.js +0 -45
  138. package/dist/sankhyablocks/app-globals-0f993ce5.js +0 -3
  139. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +0 -4
  140. package/dist/sankhyablocks/dom-665d6011.js +0 -73
  141. package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +0 -12
  142. package/dist/sankhyablocks/index-f1d3e4da.js +0 -2384
  143. package/dist/sankhyablocks/shadow-css-b18e99d7.js +0 -387
  144. package/dist/sankhyablocks/snk-application.entry.js +0 -8148
  145. package/dist/sankhyablocks/snk-crud.entry.js +0 -66
  146. package/dist/sankhyablocks/snk-data-unit.entry.js +0 -276
  147. package/dist/sankhyablocks/snk-filter-bar.entry.js +0 -274
  148. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +0 -43
  149. package/dist/sankhyablocks/snk-filter-detail.entry.js +0 -45
  150. package/dist/sankhyablocks/snk-filter-item.entry.js +0 -150
  151. package/dist/sankhyablocks/snk-filter-list.entry.js +0 -87
  152. package/dist/sankhyablocks/snk-filter-multi-select.entry.js +0 -19
  153. package/dist/sankhyablocks/snk-filter-number.entry.js +0 -20
  154. package/dist/sankhyablocks/snk-filter-period.entry.js +0 -33
  155. package/dist/sankhyablocks/snk-filter-search.entry.js +0 -40
  156. package/dist/sankhyablocks/snk-filter-text.entry.js +0 -18
  157. package/dist/sankhyablocks/snk-form.entry.js +0 -129
  158. package/dist/sankhyablocks/snk-grid.entry.js +0 -75
  159. package/dist/sankhyablocks/snk-pesquisa.entry.js +0 -311
  160. package/dist/sankhyablocks/snk-taskbar.entry.js +0 -156
  161. package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +0 -45
  162. package/dist/sankhyablocks/teste-pesquisa.entry.js +0 -33
  163. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -51
@@ -0,0 +1,100 @@
1
+ import { DataType } from "@sankhyalabs/core";
2
+ import { toString } from "@sankhyalabs/core/dist/dataunit/metadata/DataType";
3
+ import FilterItemType from "../filter-item-type.enum";
4
+ const buildFilter = (item) => {
5
+ switch (item.type) {
6
+ case FilterItemType.DEFAULT_FILTER:
7
+ return buildDefault(item);
8
+ case FilterItemType.BINARY_SELECT:
9
+ return buildBinary(item);
10
+ case FilterItemType.MULTI_SELECT:
11
+ return buildMultSelect(item);
12
+ case FilterItemType.PERIOD:
13
+ return buildPeriod(item);
14
+ case FilterItemType.SEARCH:
15
+ return buildSearch(item);
16
+ case FilterItemType.TEXT:
17
+ return buildText(item);
18
+ case FilterItemType.NUMBER:
19
+ return buildNumber(item);
20
+ case FilterItemType.PERSONALIZED:
21
+ return buildPersonalized(item);
22
+ default:
23
+ return undefined;
24
+ }
25
+ };
26
+ export default buildFilter;
27
+ function buildDefault(item) {
28
+ return { name: item.id, expression: item.props.expression, params: [] };
29
+ }
30
+ function buildBinary(item) {
31
+ const { id, value, props } = item;
32
+ const options = props.options;
33
+ const selectedOption = options.find(opt => opt.name === value);
34
+ return { name: id, expression: selectedOption.expression, params: [] };
35
+ }
36
+ function buildMultSelect(item) {
37
+ const { id, value, props } = item;
38
+ return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
39
+ }
40
+ function buildPeriod(item) {
41
+ const { id, value, props } = item;
42
+ let { end, start } = value;
43
+ if (typeof end === "string") {
44
+ end = new Date(end);
45
+ }
46
+ if (typeof start === "string") {
47
+ start = new Date(start);
48
+ }
49
+ const params = [];
50
+ let expression;
51
+ if (end && start) {
52
+ expression = props.expression.fullfill;
53
+ params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
54
+ }
55
+ else {
56
+ if (start) {
57
+ expression = props.expression.onlystart;
58
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
59
+ }
60
+ else {
61
+ expression = props.expression.onlyend;
62
+ params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
63
+ }
64
+ }
65
+ return { name: id, expression, params };
66
+ }
67
+ function buildSearch(item) {
68
+ const { id, value, props } = item;
69
+ const expression = props.expression;
70
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
71
+ }
72
+ function buildText(item) {
73
+ const { id, value, props } = item;
74
+ const expression = props.expression;
75
+ return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
76
+ }
77
+ function buildNumber(item) {
78
+ const { id, value, props } = item;
79
+ const expression = props.expression;
80
+ return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
81
+ }
82
+ function buildPersonalized(item) {
83
+ var _a;
84
+ const { id, value, props } = item;
85
+ const expression = props.expression;
86
+ return {
87
+ name: id, expression, params: (((_a = props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
88
+ const valuesArray = Array.from(value);
89
+ const dataType = param.dataType;
90
+ let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
91
+ if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
92
+ paramValue = paramValue["value"];
93
+ }
94
+ if (paramValue == undefined && dataType === DataType.BOOLEAN) {
95
+ paramValue = false;
96
+ }
97
+ return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : toString(dataType, paramValue) };
98
+ })
99
+ };
100
+ }
@@ -0,0 +1,161 @@
1
+ import { ApplicationContext, UserInterface } from '@sankhyalabs/core';
2
+ import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
3
+ import { h, Host } from '@stencil/core';
4
+ import FilterItemType from '../filter-item-type.enum';
5
+ export class SnkFilterPersonalized {
6
+ getValue(param, index) {
7
+ if (this.value && index >= 0 && index < this.value.length) {
8
+ const rawValue = this.value[index];
9
+ if (param.type === UserInterface.SEARCH) {
10
+ return rawValue;
11
+ }
12
+ return convertType(param.dataType, rawValue);
13
+ }
14
+ return undefined;
15
+ }
16
+ setValue(index, value) {
17
+ if (this.value == undefined) {
18
+ this.value = Array(index).fill(null);
19
+ }
20
+ else {
21
+ this.value = [...this.value];
22
+ }
23
+ this.value[index] = value;
24
+ if (this.value.filter(item => item != undefined).length == 0) {
25
+ this.value = null;
26
+ }
27
+ }
28
+ doSearch(mode, argument, param) {
29
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
30
+ if (this.fix) {
31
+ this.fix();
32
+ }
33
+ return new Promise((resolve, reject) => {
34
+ application.executePreparedSearch(mode, argument, param.searchContext)
35
+ .then(result => {
36
+ resolve(result);
37
+ if (this.unfix) {
38
+ this.unfix();
39
+ }
40
+ }).catch(reason => {
41
+ reject(reason);
42
+ if (this.unfix) {
43
+ this.unfix();
44
+ }
45
+ });
46
+ });
47
+ }
48
+ getParamsInterface() {
49
+ var _a, _b, _c;
50
+ const params = (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.personalizedFilter) === null || _c === void 0 ? void 0 : _c.parameters;
51
+ return params.map((param, index) => {
52
+ var _a;
53
+ switch (param.type) {
54
+ case UserInterface.SEARCH:
55
+ return h("ez-search", { suppressEmptyOption: true, value: this.getValue(param, index), onEzChange: evt => this.setValue(index, evt.detail), label: param.label, optionLoader: ({ mode, argument }) => this.doSearch(mode, argument, param) });
56
+ case UserInterface.SWITCH:
57
+ case UserInterface.CHECKBOX:
58
+ const mode = UserInterface.SWITCH === param.type ? "switch" : "regular";
59
+ return h("ez-check", { class: "ez-padding-bottom--medium", mode: mode, value: this.getValue(param, index), label: param.label, onEzChange: evt => this.setValue(index, evt.detail) });
60
+ case UserInterface.DECIMALNUMBER:
61
+ case UserInterface.INTEGERNUMBER:
62
+ return h("ez-number-input", { label: param.label, value: this.getValue(param, index), precision: (_a = param.props) === null || _a === void 0 ? void 0 : _a.precision, onEzChange: evt => this.setValue(index, evt.detail) });
63
+ case UserInterface.OPTIONSELECTOR:
64
+ return h("ez-combo-box", { label: param.label, value: this.getValue(param, index), options: param.options, onEzChange: evt => { var _a; return this.setValue(index, (_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value); } });
65
+ case UserInterface.DATE:
66
+ return h("ez-date-input", { label: param.label, value: this.getValue(param, index), onEzChange: evt => this.setValue(index, evt.detail) });
67
+ case UserInterface.DATETIME:
68
+ return h("ez-date-time-input", { label: param.label, value: this.getValue(param, index), onEzChange: evt => this.setValue(index, evt.detail) });
69
+ default:
70
+ return h("ez-text-input", { label: param.label, value: this.getValue(param, index), onEzChange: evt => this.setValue(index, evt.detail) });
71
+ }
72
+ });
73
+ }
74
+ render() {
75
+ if (!this.config || this.config.type !== FilterItemType.PERSONALIZED) {
76
+ return undefined;
77
+ }
78
+ return (h(Host, null, this.getParamsInterface()));
79
+ }
80
+ static get is() { return "snk-filter-personalized"; }
81
+ static get properties() {
82
+ return {
83
+ "config": {
84
+ "type": "unknown",
85
+ "mutable": false,
86
+ "complexType": {
87
+ "original": "SnkFilterItemConfig",
88
+ "resolved": "SnkFilterItemConfig",
89
+ "references": {
90
+ "SnkFilterItemConfig": {
91
+ "location": "import",
92
+ "path": "../snk-filter-item"
93
+ }
94
+ }
95
+ },
96
+ "required": false,
97
+ "optional": false,
98
+ "docs": {
99
+ "tags": [],
100
+ "text": ""
101
+ }
102
+ },
103
+ "value": {
104
+ "type": "unknown",
105
+ "mutable": true,
106
+ "complexType": {
107
+ "original": "Array<Option|boolean|string|number|Date>",
108
+ "resolved": "(string | number | boolean | Date | Option)[]",
109
+ "references": {
110
+ "Array": {
111
+ "location": "global"
112
+ },
113
+ "Option": {
114
+ "location": "import",
115
+ "path": "@sankhyalabs/ezui/dist/types/components/ez-combo-box/ez-combo-box"
116
+ },
117
+ "Date": {
118
+ "location": "global"
119
+ }
120
+ }
121
+ },
122
+ "required": false,
123
+ "optional": false,
124
+ "docs": {
125
+ "tags": [],
126
+ "text": ""
127
+ }
128
+ },
129
+ "fix": {
130
+ "type": "unknown",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "()=>void",
134
+ "resolved": "() => void",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": ""
142
+ }
143
+ },
144
+ "unfix": {
145
+ "type": "unknown",
146
+ "mutable": false,
147
+ "complexType": {
148
+ "original": "()=>void",
149
+ "resolved": "() => void",
150
+ "references": {}
151
+ },
152
+ "required": false,
153
+ "optional": false,
154
+ "docs": {
155
+ "tags": [],
156
+ "text": ""
157
+ }
158
+ }
159
+ };
160
+ }
161
+ }
@@ -6,5 +6,7 @@ var FilterItemType;
6
6
  FilterItemType["SEARCH"] = "SEARCH";
7
7
  FilterItemType["TEXT"] = "TEXT";
8
8
  FilterItemType["NUMBER"] = "NUMBER";
9
+ FilterItemType["DEFAULT_FILTER"] = "DEFAULT_FILTER";
10
+ FilterItemType["PERSONALIZED"] = "PERSONALIZED";
9
11
  })(FilterItemType || (FilterItemType = {}));
10
12
  export default FilterItemType;
@@ -1,4 +1,5 @@
1
1
  import { h, Host } from '@stencil/core';
2
+ import { ApplicationUtils } from "@sankhyalabs/ezui/dist/collection/utils";
2
3
  import FilterItemType from './filter-item-type.enum';
3
4
  export class SnkFilterDetail {
4
5
  changeConfig(newConfig) {
@@ -16,6 +17,8 @@ export class SnkFilterDetail {
16
17
  return "snk-filter-search";
17
18
  case FilterItemType.NUMBER:
18
19
  return "snk-filter-number";
20
+ case FilterItemType.PERSONALIZED:
21
+ return "snk-filter-personalized";
19
22
  }
20
23
  return "snk-filter-text";
21
24
  }
@@ -31,9 +34,41 @@ export class SnkFilterDetail {
31
34
  h("ez-icon", { title: this.getMessage(this.config.fixed ? "snkFilterBar.unpinFilter" : "snkFilterBar.pinFilter"), class: "ez-margin-left--small sc-snk-filter-bar snk-filter-item__editor-header-button", iconName: this.config.fixed ? "un-pin" : "push-pin", onClick: () => this.changeConfig(Object.assign(Object.assign({}, this.config), { fixed: !this.config.fixed })) })
32
35
  ]);
33
36
  }
37
+ apply() {
38
+ var _a;
39
+ let isValid = true;
40
+ const value = this._editor["value"];
41
+ /* WARNING: Temporário. Isso só está sendo feito até desconsiderar os parametros não informados para PersonalizedFilter*/
42
+ if (value != undefined && this.config.type === FilterItemType.PERSONALIZED) {
43
+ const params = ((_a = this.config.props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || [];
44
+ if (params.length > 1) {
45
+ if (params.length > value.length) {
46
+ isValid = false;
47
+ }
48
+ else {
49
+ value.forEach(item => {
50
+ if (item == undefined) {
51
+ isValid = false;
52
+ }
53
+ });
54
+ }
55
+ }
56
+ if (!isValid) {
57
+ this.keepOpened = true;
58
+ ApplicationUtils.alert("Filtro parcialmente preenchido", "Favor completar todas as informações do filtro.").then(() => setTimeout(() => this.keepOpened = false, 1));
59
+ }
60
+ }
61
+ /* WARNING: Temporário.*/
62
+ if (isValid) {
63
+ this.changeConfig(Object.assign(Object.assign({}, this.config), { value: value }));
64
+ }
65
+ }
66
+ clear() {
67
+ this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
68
+ }
34
69
  render() {
35
70
  const ContentEditor = this.getContentEditor();
36
- return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header" }, this.config.detailTitle), this.getPopUpHeaderButtons()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config, fix: () => this.keepOpened = true, unfix: () => this.keepOpened = false }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined })) }), h("ez-button", { label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.changeConfig(Object.assign(Object.assign({}, this.config), { value: this._editor["value"] })), class: "ez-button--primary ez-padding-left--medium" }))));
71
+ return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header" }, this.config.detailTitle), this.getPopUpHeaderButtons()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config, fix: () => this.keepOpened = true, unfix: () => this.keepOpened = false }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.clear(), size: "small" }), h("ez-button", { label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
37
72
  }
38
73
  static get is() { return "snk-filter-detail"; }
39
74
  static get properties() {
@@ -19,16 +19,20 @@ export class SnkFilterItem {
19
19
  } while ((current = current.offsetParent) != null);
20
20
  }
21
21
  this.detailIsVisible = false;
22
+ this.executeCloseCallback();
22
23
  return false;
23
24
  };
24
25
  }
25
26
  async showUp(open = false) {
26
- this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
27
- if (open) {
28
- window.requestAnimationFrame(() => {
29
- this.showDetail();
30
- });
31
- }
27
+ return new Promise(resolve => {
28
+ this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
29
+ if (open) {
30
+ window.requestAnimationFrame(() => {
31
+ this._closeCallback = resolve;
32
+ this.showDetail();
33
+ });
34
+ }
35
+ });
32
36
  }
33
37
  showDetail() {
34
38
  this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck, left: this.getScrollOffset() });
@@ -43,6 +47,13 @@ export class SnkFilterItem {
43
47
  }
44
48
  this._floatingID = undefined;
45
49
  this.detailIsVisible = false;
50
+ this.executeCloseCallback();
51
+ }
52
+ executeCloseCallback() {
53
+ if (this._closeCallback) {
54
+ this._closeCallback();
55
+ this._closeCallback = undefined;
56
+ }
46
57
  }
47
58
  //---------------------------------------------
48
59
  // Event handlers
@@ -117,6 +128,9 @@ export class SnkFilterItem {
117
128
  if (type === FilterItemType.SEARCH) {
118
129
  return `${label}: ${value.value} - ${value.label}`;
119
130
  }
131
+ if (type === FilterItemType.PERSONALIZED) {
132
+ return label;
133
+ }
120
134
  return `${label}: ${value}`;
121
135
  }
122
136
  return label;
@@ -131,15 +145,24 @@ export class SnkFilterItem {
131
145
  filterChangeListener() {
132
146
  this.hideDetail();
133
147
  }
134
- getIconName() {
148
+ getRightIconName() {
135
149
  if (this.config.value != undefined) {
136
150
  return "close";
137
151
  }
138
152
  return this.detailIsVisible ? "chevron-up" : "chevron-down";
139
153
  }
154
+ getLeftIconName() {
155
+ switch (this.config.type) {
156
+ case FilterItemType.PERIOD:
157
+ return "calendar";
158
+ case FilterItemType.PERSONALIZED:
159
+ return "tune";
160
+ }
161
+ return undefined;
162
+ }
140
163
  render() {
141
- const leftIcon = this.config.type === FilterItemType.PERIOD ? "calendar" : undefined;
142
- return (h(Host, null, h("ez-chip", { ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.config.value != undefined }, leftIcon ? h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" }) : undefined, h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getIconName(), class: "ez-padding-left--small", slot: "rightIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem, key: this.config.id }))));
164
+ const leftIcon = this.getLeftIconName();
165
+ return (h(Host, null, h("ez-chip", { ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.config.value != undefined }, leftIcon ? h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" }) : undefined, h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem, key: this.config.id }))));
143
166
  }
144
167
  static get is() { return "snk-filter-item"; }
145
168
  static get properties() {
@@ -0,0 +1,196 @@
1
+ import { h } from '@stencil/core';
2
+ import { ModalButtonStatus } from "@sankhyalabs/ezui/dist/collection/components/ez-modal-container";
3
+ import { ArrayUtils } from '@sankhyalabs/core';
4
+ export class SnkFilterModal {
5
+ updateValue(id, value) {
6
+ this.items = this.items.map(item => {
7
+ if (item.id === id) {
8
+ return Object.assign(Object.assign({}, item), { active: value });
9
+ }
10
+ return item;
11
+ });
12
+ }
13
+ getActiveFiltersMsg() {
14
+ const activeFilters = this.items.filter(item => item.active).length;
15
+ if (activeFilters === 0) {
16
+ return this.getMessage("snkFilterBar.noActiveFilters");
17
+ }
18
+ return this.getMessage(activeFilters > 1 ? "snkFilterBar.activeFilters" : "snkFilterBar.activeFilter", { ACTIVE_FILTERS: activeFilters });
19
+ }
20
+ getFilteredItems() {
21
+ return this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items) : [];
22
+ }
23
+ render() {
24
+ const allowCancel = this.items.filter(item => item.active).length > 0;
25
+ return (h("ez-modal-container", { modalTitle: this.modalTitle, modalSubTitle: this.modalSubTitle, cancelButtonLabel: this.cancelButtonLabel, okButtonLabel: this.okButtonLabel, onEzModalAction: evt => this.processModalAction(evt.detail), cancelButtonStatus: allowCancel ? ModalButtonStatus.ENABLED : ModalButtonStatus.DISABLED }, h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-modal-content" }, h("div", null, this.useSearch ? h("ez-filter-input", { label: this.getMessage("snkFilterBar.modalFindFilter"), onEzChange: (evt) => this._filterArgument = evt.detail }) : undefined), this.getFilteredItems().length > 0 ? h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding-bottom--small" }, this.getActiveFiltersMsg()) : undefined, h("div", null, this.getFilteredItems().map(item => h("div", { class: "ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small" }, h("ez-check", { 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: "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)))), h("div", { class: "ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large" }, this.infoText))));
26
+ }
27
+ static get is() { return "snk-filter-modal"; }
28
+ static get properties() {
29
+ return {
30
+ "getMessage": {
31
+ "type": "unknown",
32
+ "mutable": false,
33
+ "complexType": {
34
+ "original": "(key: string, props?: any) => string",
35
+ "resolved": "(key: string, props?: any) => string",
36
+ "references": {}
37
+ },
38
+ "required": false,
39
+ "optional": false,
40
+ "docs": {
41
+ "tags": [],
42
+ "text": ""
43
+ }
44
+ },
45
+ "items": {
46
+ "type": "unknown",
47
+ "mutable": true,
48
+ "complexType": {
49
+ "original": "Array<ModalItem>",
50
+ "resolved": "ModalItem[]",
51
+ "references": {
52
+ "Array": {
53
+ "location": "global"
54
+ },
55
+ "ModalItem": {
56
+ "location": "local"
57
+ }
58
+ }
59
+ },
60
+ "required": false,
61
+ "optional": false,
62
+ "docs": {
63
+ "tags": [],
64
+ "text": ""
65
+ }
66
+ },
67
+ "modalTitle": {
68
+ "type": "string",
69
+ "mutable": false,
70
+ "complexType": {
71
+ "original": "string",
72
+ "resolved": "string",
73
+ "references": {}
74
+ },
75
+ "required": false,
76
+ "optional": false,
77
+ "docs": {
78
+ "tags": [],
79
+ "text": ""
80
+ },
81
+ "attribute": "modal-title",
82
+ "reflect": false
83
+ },
84
+ "modalSubTitle": {
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": "modal-sub-title",
99
+ "reflect": false
100
+ },
101
+ "cancelButtonLabel": {
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": "cancel-button-label",
116
+ "reflect": false
117
+ },
118
+ "okButtonLabel": {
119
+ "type": "string",
120
+ "mutable": false,
121
+ "complexType": {
122
+ "original": "string",
123
+ "resolved": "string",
124
+ "references": {}
125
+ },
126
+ "required": false,
127
+ "optional": false,
128
+ "docs": {
129
+ "tags": [],
130
+ "text": ""
131
+ },
132
+ "attribute": "ok-button-label",
133
+ "reflect": false
134
+ },
135
+ "infoText": {
136
+ "type": "string",
137
+ "mutable": false,
138
+ "complexType": {
139
+ "original": "string",
140
+ "resolved": "string",
141
+ "references": {}
142
+ },
143
+ "required": false,
144
+ "optional": false,
145
+ "docs": {
146
+ "tags": [],
147
+ "text": ""
148
+ },
149
+ "attribute": "info-text",
150
+ "reflect": false
151
+ },
152
+ "useSearch": {
153
+ "type": "boolean",
154
+ "mutable": false,
155
+ "complexType": {
156
+ "original": "boolean",
157
+ "resolved": "boolean",
158
+ "references": {}
159
+ },
160
+ "required": false,
161
+ "optional": false,
162
+ "docs": {
163
+ "tags": [],
164
+ "text": ""
165
+ },
166
+ "attribute": "use-search",
167
+ "reflect": false
168
+ },
169
+ "processModalAction": {
170
+ "type": "unknown",
171
+ "mutable": false,
172
+ "complexType": {
173
+ "original": "(action: ModalAction) => void",
174
+ "resolved": "(action: ModalAction) => void",
175
+ "references": {
176
+ "ModalAction": {
177
+ "location": "import",
178
+ "path": "@sankhyalabs/ezui/dist/collection/components/ez-modal-container"
179
+ }
180
+ }
181
+ },
182
+ "required": false,
183
+ "optional": false,
184
+ "docs": {
185
+ "tags": [],
186
+ "text": ""
187
+ }
188
+ }
189
+ };
190
+ }
191
+ static get states() {
192
+ return {
193
+ "_filterArgument": {}
194
+ };
195
+ }
196
+ }
@@ -111,4 +111,26 @@
111
111
  left: 17px;
112
112
  background-color: var(--icon--alert--color, #008561);
113
113
  border-radius: 50%;
114
+ }
115
+
116
+ .snk-filter-bar__filter-modal-item{
117
+ display: flex;
118
+ flex-direction: row;
119
+ border-radius: var(--border--radius-medium, 12px);
120
+ background-color: var(--background--medium, #f0f3f7);
121
+ }
122
+
123
+ .snk-filter-bar__filter-modal-item__check{
124
+ width: auto;
125
+ }
126
+ .snk-filter-bar__filter-modal-item__label{
127
+ font-weight: var(--text-weight--medium);
128
+ width: 100%;
129
+ }
130
+
131
+ .snk-filter-bar__filter-modal-content{
132
+ display: grid;
133
+ grid-template-rows: auto auto 1fr auto;
134
+ width: 100%;
135
+ height: 100%;
114
136
  }