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

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 (120) 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-84fe3b86.js +20 -0
  4. package/dist/cjs/index-93965c41.js +141 -0
  5. package/dist/cjs/{index-02201bc9.js → index-e90ae303.js} +11 -0
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  8. package/dist/cjs/snk-application.cjs.entry.js +43 -25
  9. package/dist/cjs/snk-crud.cjs.entry.js +1 -1
  10. package/dist/cjs/snk-data-unit.cjs.entry.js +10 -18
  11. package/dist/cjs/snk-filter-bar.cjs.entry.js +334 -146
  12. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  13. package/dist/cjs/snk-filter-detail.cjs.entry.js +37 -2
  14. package/dist/cjs/snk-filter-item.cjs.entry.js +34 -11
  15. package/dist/cjs/snk-filter-list.cjs.entry.js +1 -1
  16. package/dist/cjs/snk-filter-modal.cjs.entry.js +37 -0
  17. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
  18. package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
  20. package/dist/cjs/snk-filter-personalized.cjs.entry.js +89 -0
  21. package/dist/cjs/snk-filter-search.cjs.entry.js +2 -2
  22. package/dist/cjs/snk-form.cjs.entry.js +1 -1
  23. package/dist/cjs/snk-grid.cjs.entry.js +1 -1
  24. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  25. package/dist/cjs/snk-taskbar.cjs.entry.js +1 -1
  26. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  27. package/dist/collection/collection-manifest.json +2 -0
  28. package/dist/collection/components/snk-application/snk-application.js +54 -7
  29. package/dist/collection/components/snk-crud/snk-crud.js +2 -4
  30. package/dist/collection/components/snk-data-unit/snk-data-unit.js +0 -27
  31. package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +100 -0
  32. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +161 -0
  33. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +2 -0
  34. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +36 -1
  35. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +32 -9
  36. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +196 -0
  37. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +22 -0
  38. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +238 -139
  39. package/dist/collection/components/snk-grid/snk-grid.js +2 -4
  40. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +18 -10
  41. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +14 -2
  42. package/dist/components/SnkMessageBuilder.js +15 -119
  43. package/dist/components/filter-item-type.enum.js +2 -0
  44. package/dist/components/index.d.ts +2 -0
  45. package/dist/components/index.js +2 -0
  46. package/dist/components/index2.js +11 -1
  47. package/dist/components/index3.js +139 -0
  48. package/dist/components/snk-application2.js +39 -19
  49. package/dist/components/snk-crud.js +15 -9
  50. package/dist/components/snk-data-unit.js +2 -11
  51. package/dist/components/snk-filter-bar2.js +340 -146
  52. package/dist/components/snk-filter-detail2.js +36 -1
  53. package/dist/components/snk-filter-item2.js +32 -9
  54. package/dist/components/snk-filter-list2.js +1 -1
  55. package/dist/components/snk-filter-modal.d.ts +11 -0
  56. package/dist/components/snk-filter-modal.js +6 -0
  57. package/dist/components/snk-filter-modal2.js +73 -0
  58. package/dist/components/snk-filter-personalized.d.ts +11 -0
  59. package/dist/components/snk-filter-personalized.js +107 -0
  60. package/dist/components/snk-grid2.js +15 -9
  61. package/dist/{sankhyablocks/SnkMessageBuilder-a7da466b.js → esm/SnkMessageBuilder-35a20271.js} +15 -119
  62. package/dist/esm/{filter-item-type.enum-61fbf80a.js → filter-item-type.enum-a79b2fa8.js} +2 -0
  63. package/dist/esm/index-5992b7e6.js +139 -0
  64. package/dist/esm/{index-f1d3e4da.js → index-c683b2b0.js} +11 -1
  65. package/dist/esm/index-c71285cb.js +17 -0
  66. package/dist/esm/loader.js +1 -1
  67. package/dist/esm/sankhyablocks.js +1 -1
  68. package/dist/esm/snk-application.entry.js +37 -19
  69. package/dist/esm/snk-crud.entry.js +1 -1
  70. package/dist/esm/snk-data-unit.entry.js +3 -11
  71. package/dist/esm/snk-filter-bar.entry.js +328 -140
  72. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  73. package/dist/esm/snk-filter-detail.entry.js +37 -2
  74. package/dist/esm/snk-filter-item.entry.js +34 -11
  75. package/dist/esm/snk-filter-list.entry.js +1 -1
  76. package/dist/esm/snk-filter-modal.entry.js +33 -0
  77. package/dist/esm/snk-filter-multi-select.entry.js +1 -1
  78. package/dist/esm/snk-filter-number.entry.js +1 -1
  79. package/dist/esm/snk-filter-period.entry.js +1 -1
  80. package/dist/esm/snk-filter-personalized.entry.js +85 -0
  81. package/dist/esm/snk-filter-search.entry.js +2 -2
  82. package/dist/esm/snk-form.entry.js +1 -1
  83. package/dist/esm/snk-grid.entry.js +1 -1
  84. package/dist/esm/snk-pesquisa.entry.js +1 -1
  85. package/dist/esm/snk-taskbar.entry.js +1 -1
  86. package/dist/esm/teste-pesquisa.entry.js +1 -1
  87. package/dist/{esm/SnkMessageBuilder-a7da466b.js → sankhyablocks/SnkMessageBuilder-35a20271.js} +15 -119
  88. package/dist/sankhyablocks/{filter-item-type.enum-61fbf80a.js → filter-item-type.enum-a79b2fa8.js} +2 -0
  89. package/dist/sankhyablocks/index-5992b7e6.js +139 -0
  90. package/dist/sankhyablocks/{index-f1d3e4da.js → index-c683b2b0.js} +11 -1
  91. package/dist/sankhyablocks/index-c71285cb.js +17 -0
  92. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  93. package/dist/sankhyablocks/snk-application.entry.js +37 -19
  94. package/dist/sankhyablocks/snk-crud.entry.js +1 -1
  95. package/dist/sankhyablocks/snk-data-unit.entry.js +3 -11
  96. package/dist/sankhyablocks/snk-filter-bar.entry.js +328 -140
  97. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +1 -1
  98. package/dist/sankhyablocks/snk-filter-detail.entry.js +37 -2
  99. package/dist/sankhyablocks/snk-filter-item.entry.js +34 -11
  100. package/dist/sankhyablocks/snk-filter-list.entry.js +1 -1
  101. package/dist/sankhyablocks/snk-filter-modal.entry.js +33 -0
  102. package/dist/sankhyablocks/snk-filter-multi-select.entry.js +1 -1
  103. package/dist/sankhyablocks/snk-filter-number.entry.js +1 -1
  104. package/dist/sankhyablocks/snk-filter-period.entry.js +1 -1
  105. package/dist/sankhyablocks/snk-filter-personalized.entry.js +85 -0
  106. package/dist/sankhyablocks/snk-filter-search.entry.js +2 -2
  107. package/dist/sankhyablocks/snk-form.entry.js +1 -1
  108. package/dist/sankhyablocks/snk-grid.entry.js +1 -1
  109. package/dist/sankhyablocks/snk-pesquisa.entry.js +1 -1
  110. package/dist/sankhyablocks/snk-taskbar.entry.js +1 -1
  111. package/dist/sankhyablocks/teste-pesquisa.entry.js +1 -1
  112. package/dist/types/components/snk-application/snk-application.d.ts +4 -1
  113. package/dist/types/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.d.ts +4 -0
  114. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +23 -0
  115. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +3 -1
  116. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +2 -0
  117. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +23 -0
  118. package/dist/types/components.d.ts +56 -8
  119. package/package.json +3 -3
  120. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -51
@@ -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
  }