@sankhyalabs/sankhyablocks 8.9.5 → 8.10.0-rc.1

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 (136) hide show
  1. package/dist/cjs/{ConfigStorage-90552fe8.js → ConfigStorage-49d4681c.js} +1 -1
  2. package/dist/cjs/{PersonalizedFilterUtils-2f7823fc.js → PersonalizedFilterUtils-0184ffbb.js} +1 -1
  3. package/dist/cjs/{SnkFormConfigManager-0561602d.js → SnkFormConfigManager-d4184bfa.js} +1 -1
  4. package/dist/cjs/{filter-item-type.enum-aa823a00.js → filter-item-type.enum-a7ffdaa6.js} +1 -0
  5. package/dist/cjs/index-f9e81701.js +4 -0
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  8. package/dist/cjs/snk-actions-button.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-application.cjs.entry.js +37 -2
  10. package/dist/cjs/snk-crud.cjs.entry.js +72 -8
  11. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
  12. package/dist/cjs/snk-filter-advanced-mode_2.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-filter-bar.cjs.entry.js +27 -4
  14. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  15. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +52 -0
  16. package/dist/cjs/snk-filter-detail.cjs.entry.js +9 -2
  17. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +2 -2
  18. package/dist/cjs/snk-filter-item.cjs.entry.js +25 -14
  19. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +5 -3
  20. package/dist/cjs/snk-filter-modal.cjs.entry.js +16 -5
  21. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
  23. package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
  24. package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
  25. package/dist/cjs/snk-form.cjs.entry.js +3 -3
  26. package/dist/cjs/snk-grid-config.cjs.entry.js +2 -2
  27. package/dist/cjs/snk-grid.cjs.entry.js +2 -2
  28. package/dist/cjs/{snk-guides-viewer-676dd526.js → snk-guides-viewer-0d5aad6b.js} +2 -2
  29. package/dist/cjs/snk-guides-viewer.cjs.entry.js +4 -4
  30. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
  31. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  32. package/dist/cjs/snk-simple-crud.cjs.entry.js +1 -1
  33. package/dist/collection/collection-manifest.json +1 -0
  34. package/dist/collection/components/snk-application/snk-application.js +47 -1
  35. package/dist/collection/components/snk-crud/snk-crud.js +71 -7
  36. package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +19 -0
  37. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +95 -0
  38. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +1 -0
  39. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +7 -0
  40. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +24 -13
  41. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +14 -3
  42. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +3 -1
  43. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +5 -1
  44. package/dist/collection/lib/workspace/workspace.js +12 -0
  45. package/dist/components/filter-item-type.enum.js +1 -0
  46. package/dist/components/index.d.ts +1 -0
  47. package/dist/components/index.js +1 -0
  48. package/dist/components/snk-application2.js +37 -1
  49. package/dist/components/snk-crud.js +71 -7
  50. package/dist/components/snk-filter-bar2.js +24 -1
  51. package/dist/components/snk-filter-checkbox-list.d.ts +11 -0
  52. package/dist/components/snk-filter-checkbox-list.js +68 -0
  53. package/dist/components/snk-filter-detail2.js +7 -0
  54. package/dist/components/snk-filter-item2.js +24 -13
  55. package/dist/components/snk-filter-modal-item2.js +3 -1
  56. package/dist/components/snk-filter-modal.js +14 -3
  57. package/dist/esm/{ConfigStorage-84abda58.js → ConfigStorage-9a086412.js} +1 -1
  58. package/dist/esm/{PersonalizedFilterUtils-49a5dcb7.js → PersonalizedFilterUtils-e2b38ef7.js} +1 -1
  59. package/dist/esm/{SnkFormConfigManager-655943d0.js → SnkFormConfigManager-709e68a2.js} +1 -1
  60. package/dist/esm/{filter-item-type.enum-5028ed3f.js → filter-item-type.enum-d45e026f.js} +1 -0
  61. package/dist/esm/index-a7d3d3f1.js +4 -0
  62. package/dist/esm/loader.js +1 -1
  63. package/dist/esm/sankhyablocks.js +1 -1
  64. package/dist/esm/snk-actions-button.entry.js +1 -1
  65. package/dist/esm/snk-application.entry.js +38 -3
  66. package/dist/esm/snk-crud.entry.js +72 -8
  67. package/dist/esm/snk-detail-view.entry.js +4 -4
  68. package/dist/esm/snk-filter-advanced-mode_2.entry.js +2 -2
  69. package/dist/esm/snk-filter-bar.entry.js +27 -4
  70. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  71. package/dist/esm/snk-filter-checkbox-list.entry.js +48 -0
  72. package/dist/esm/snk-filter-detail.entry.js +9 -2
  73. package/dist/esm/snk-filter-field-search_2.entry.js +2 -2
  74. package/dist/esm/snk-filter-item.entry.js +25 -14
  75. package/dist/esm/snk-filter-modal-item.entry.js +5 -3
  76. package/dist/esm/snk-filter-modal.entry.js +16 -5
  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-search.entry.js +1 -1
  81. package/dist/esm/snk-form.entry.js +3 -3
  82. package/dist/esm/snk-grid-config.entry.js +2 -2
  83. package/dist/esm/snk-grid.entry.js +2 -2
  84. package/dist/esm/{snk-guides-viewer-746e2547.js → snk-guides-viewer-9c50ebea.js} +2 -2
  85. package/dist/esm/snk-guides-viewer.entry.js +4 -4
  86. package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
  87. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  88. package/dist/esm/snk-simple-crud.entry.js +1 -1
  89. package/dist/sankhyablocks/{p-29529c8f.entry.js → p-01ba23cd.entry.js} +1 -1
  90. package/dist/sankhyablocks/{p-43b2aad5.js → p-057fad05.js} +1 -1
  91. package/dist/sankhyablocks/p-117b0848.entry.js +11 -0
  92. package/dist/sankhyablocks/{p-c6800fd4.entry.js → p-1626c58f.entry.js} +1 -1
  93. package/dist/sankhyablocks/{p-6e32de4b.entry.js → p-1b7105ae.entry.js} +1 -1
  94. package/dist/sankhyablocks/{p-cb37982f.entry.js → p-20726710.entry.js} +1 -1
  95. package/dist/sankhyablocks/{p-8f307ef2.entry.js → p-29ffb7d7.entry.js} +1 -1
  96. package/dist/sankhyablocks/{p-a3fbded7.entry.js → p-2e1a8609.entry.js} +1 -1
  97. package/dist/sankhyablocks/{p-c78a80ae.entry.js → p-3ab6df3d.entry.js} +1 -1
  98. package/dist/sankhyablocks/{p-5eb3ac18.js → p-3fd145ac.js} +1 -1
  99. package/dist/sankhyablocks/{p-eb636e15.entry.js → p-41f8bfa3.entry.js} +1 -1
  100. package/dist/sankhyablocks/{p-d7665a57.entry.js → p-57196255.entry.js} +1 -1
  101. package/dist/sankhyablocks/{p-a9b6acf1.js → p-5cff2f60.js} +1 -1
  102. package/dist/sankhyablocks/p-6977a26c.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-fc257290.entry.js → p-7e2ded86.entry.js} +1 -1
  104. package/dist/sankhyablocks/{p-c0931902.entry.js → p-8002dcd0.entry.js} +1 -1
  105. package/dist/sankhyablocks/p-84a53f61.entry.js +1 -0
  106. package/dist/sankhyablocks/p-a037f5b4.entry.js +1 -0
  107. package/dist/sankhyablocks/p-aaa3ee68.entry.js +1 -0
  108. package/dist/sankhyablocks/{p-26ad62b9.entry.js → p-c758265f.entry.js} +1 -1
  109. package/dist/sankhyablocks/{p-fe49067d.entry.js → p-c8622597.entry.js} +1 -1
  110. package/dist/sankhyablocks/p-d05d3e37.entry.js +1 -0
  111. package/dist/sankhyablocks/p-d6317851.entry.js +1 -0
  112. package/dist/sankhyablocks/{p-718ecd01.entry.js → p-df841828.entry.js} +1 -1
  113. package/dist/sankhyablocks/{p-a4401f5f.entry.js → p-e1aec599.entry.js} +1 -1
  114. package/dist/sankhyablocks/p-fab8339c.entry.js +1 -0
  115. package/dist/sankhyablocks/{p-b54e06ca.js → p-fad0a721.js} +1 -1
  116. package/dist/sankhyablocks/{p-584d7212.js → p-ff1990ad.js} +1 -1
  117. package/dist/sankhyablocks/{p-0d5e8a37.entry.js → p-ff90e0e6.entry.js} +1 -1
  118. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  119. package/dist/types/components/snk-application/snk-application.d.ts +10 -1
  120. package/dist/types/components/snk-crud/snk-crud.d.ts +6 -0
  121. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.d.ts +27 -0
  122. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +2 -1
  123. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +2 -0
  124. package/dist/types/components.d.ts +35 -1
  125. package/dist/types/lib/workspace/workspace.d.ts +3 -0
  126. package/package.json +1 -1
  127. package/react/components.d.ts +1 -0
  128. package/react/components.js +1 -0
  129. package/react/components.js.map +1 -1
  130. package/dist/sankhyablocks/p-1ae31937.entry.js +0 -1
  131. package/dist/sankhyablocks/p-25df73bf.entry.js +0 -1
  132. package/dist/sankhyablocks/p-2640ba03.entry.js +0 -1
  133. package/dist/sankhyablocks/p-993e27ad.entry.js +0 -1
  134. package/dist/sankhyablocks/p-c606c748.entry.js +0 -1
  135. package/dist/sankhyablocks/p-d4c72815.entry.js +0 -1
  136. package/dist/sankhyablocks/p-f3479d53.entry.js +0 -11
@@ -23,6 +23,8 @@ const buildFilter = (item) => {
23
23
  return buildNumber(item);
24
24
  case FilterItemType.PERSONALIZED:
25
25
  return buildPersonalized(item);
26
+ case FilterItemType.CHECK_BOX_LIST:
27
+ return buildCheckboxList(item);
26
28
  default:
27
29
  return undefined;
28
30
  }
@@ -56,6 +58,23 @@ function buildMultiList(item) {
56
58
  };
57
59
  }
58
60
  }
61
+ function buildCheckboxList(item) {
62
+ var _a;
63
+ const { id, value, props } = item;
64
+ const selectedOptionNames = Object.entries(value !== null && value !== void 0 ? value : {})
65
+ .filter(([_, valueChecked]) => valueChecked === true)
66
+ .map(([key, _]) => key);
67
+ const selectedOptionsObject = (_a = props.options) === null || _a === void 0 ? void 0 : _a.filter(option => selectedOptionNames.includes(option.name));
68
+ return { name: id, expression: buildCheckboxListExpression(selectedOptionsObject), params: [] };
69
+ }
70
+ function buildCheckboxListExpression(options) {
71
+ let expression = "";
72
+ options.forEach((option, index) => {
73
+ var _a;
74
+ expression += ` ${index > 0 ? ((_a = option.operand) !== null && _a !== void 0 ? _a : 'OR') : ''} ${option.expression}`;
75
+ });
76
+ return expression.trim();
77
+ }
59
78
  function parseMultiListValues(multiListValue) {
60
79
  var _a, _b;
61
80
  const value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
@@ -0,0 +1,95 @@
1
+ import { ElementIDUtils } from '@sankhyalabs/core';
2
+ import { h } from '@stencil/core';
3
+ import FilterItemType from '../filter-item-type.enum';
4
+ export class SnkFilterCheckboxList {
5
+ constructor() {
6
+ this.config = undefined;
7
+ this.optionsList = [];
8
+ }
9
+ componentDidLoad() {
10
+ if (this._element) {
11
+ ElementIDUtils.addIDInfo(this._element, 'filterContentEditor');
12
+ }
13
+ }
14
+ handleToggleCheck(itemChanged, checked) {
15
+ var _a, _b;
16
+ let configValueMap = (_a = this.config.value) !== null && _a !== void 0 ? _a : {};
17
+ configValueMap[itemChanged.name] = checked;
18
+ this.config = Object.assign(Object.assign({}, this.config), { value: configValueMap });
19
+ this.valueChanged.emit((_b = this.config) === null || _b === void 0 ? void 0 : _b.value);
20
+ }
21
+ renderOptions() {
22
+ return this.optionsList.map(option => (h("ez-check", { label: option.label, compact: true, onEzChange: (event) => this.handleToggleCheck(option, event.detail), value: !!this.isChecked(option.name) })));
23
+ }
24
+ isChecked(itemName) {
25
+ var _a;
26
+ return (_a = this.config.value) === null || _a === void 0 ? void 0 : _a[itemName];
27
+ }
28
+ buidOptions() {
29
+ var _a, _b, _c;
30
+ const propsOptions = (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.options) !== null && _c !== void 0 ? _c : [];
31
+ this.optionsList = [...propsOptions];
32
+ }
33
+ componentWillRender() {
34
+ this.buidOptions();
35
+ }
36
+ render() {
37
+ if (!this.config || this.config.type !== FilterItemType.CHECK_BOX_LIST) {
38
+ return undefined;
39
+ }
40
+ return (h("div", { class: 'ez-flex ez-flex--column' }, this.renderOptions()));
41
+ }
42
+ static get is() { return "snk-filter-checkbox-list"; }
43
+ static get properties() {
44
+ return {
45
+ "config": {
46
+ "type": "unknown",
47
+ "mutable": true,
48
+ "complexType": {
49
+ "original": "SnkFilterItemConfig",
50
+ "resolved": "SnkFilterItemConfig",
51
+ "references": {
52
+ "SnkFilterItemConfig": {
53
+ "location": "import",
54
+ "path": "../snk-filter-item"
55
+ }
56
+ }
57
+ },
58
+ "required": false,
59
+ "optional": false,
60
+ "docs": {
61
+ "tags": [],
62
+ "text": "Define as configura\u00E7\u00F5es do componente snk-filter-multi-select"
63
+ }
64
+ }
65
+ };
66
+ }
67
+ static get states() {
68
+ return {
69
+ "optionsList": {}
70
+ };
71
+ }
72
+ static get events() {
73
+ return [{
74
+ "method": "valueChanged",
75
+ "name": "valueChanged",
76
+ "bubbles": true,
77
+ "cancelable": true,
78
+ "composed": true,
79
+ "docs": {
80
+ "tags": [],
81
+ "text": "Emite um evento customizado ao realizar altera\u00E7\u00E3o nos valores do componente"
82
+ },
83
+ "complexType": {
84
+ "original": "CustomEvent",
85
+ "resolved": "CustomEvent<any>",
86
+ "references": {
87
+ "CustomEvent": {
88
+ "location": "global"
89
+ }
90
+ }
91
+ }
92
+ }];
93
+ }
94
+ static get elementRef() { return "_element"; }
95
+ }
@@ -9,5 +9,6 @@ var FilterItemType;
9
9
  FilterItemType["DEFAULT_FILTER"] = "DEFAULT_FILTER";
10
10
  FilterItemType["PERSONALIZED"] = "PERSONALIZED";
11
11
  FilterItemType["MULTI_LIST"] = "MULTI_LIST";
12
+ FilterItemType["CHECK_BOX_LIST"] = "CHECK_BOX_LIST";
12
13
  })(FilterItemType || (FilterItemType = {}));
13
14
  export default FilterItemType;
@@ -51,6 +51,13 @@ export class SnkFilterDetail {
51
51
  }
52
52
  };
53
53
  return snkFilterPersonalizedProps;
54
+ case FilterItemType.CHECK_BOX_LIST:
55
+ return {
56
+ tag: "snk-filter-checkbox-list",
57
+ props: {
58
+ onValueChanged: evt => this.config = Object.assign(Object.assign({}, this.config), { value: evt.detail })
59
+ }
60
+ };
54
61
  case FilterItemType.MULTI_LIST:
55
62
  return {
56
63
  tag: "snk-entity-list",
@@ -124,7 +124,7 @@ export class SnkFilterItem {
124
124
  }
125
125
  }
126
126
  getLabel(isTooltipLabel = false) {
127
- var _a;
127
+ var _a, _b;
128
128
  const { type, value, label, props, groupedItems = [] } = this.config;
129
129
  if (value || groupedItems.length) {
130
130
  if (type === FilterItemType.BINARY_SELECT) {
@@ -185,18 +185,15 @@ export class SnkFilterItem {
185
185
  }
186
186
  if (type === FilterItemType.MULTI_LIST) {
187
187
  const selectedOptions = ((_a = value.elements) !== null && _a !== void 0 ? _a : value).filter(item => item === null || item === void 0 ? void 0 : item.check);
188
- const checkedAmount = selectedOptions.length;
189
- if (checkedAmount === 0) {
190
- return `${label}`;
191
- }
192
- if (checkedAmount > 1) {
193
- if (isTooltipLabel) {
194
- const selectedOptionsDescrptions = selectedOptions.map(item => item.label);
195
- return `${label}: ${selectedOptionsDescrptions.join(',')}`;
196
- }
197
- return `${label}: ${checkedAmount} ${this.getMessage('snkFilterBar.multiListToltip')}`;
198
- }
199
- return `${label}: ${selectedOptions[0].label}`;
188
+ return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
189
+ }
190
+ if (type === FilterItemType.CHECK_BOX_LIST) {
191
+ const selectedValues = Object.entries(value !== null && value !== void 0 ? value : {})
192
+ .filter(([_, value]) => value === true)
193
+ .map(([key, _]) => key);
194
+ const options = (_b = props.options) !== null && _b !== void 0 ? _b : [];
195
+ const selectedOptions = options.filter(option => selectedValues.includes(option.name));
196
+ return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
200
197
  }
201
198
  if (type === FilterItemType.NUMBER && props.variation === FilterNumberVariation.INTERVAL) {
202
199
  const { start, end } = value;
@@ -214,6 +211,20 @@ export class SnkFilterItem {
214
211
  }
215
212
  return label;
216
213
  }
214
+ getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel) {
215
+ const checkedAmount = selectedOptions.length;
216
+ if (checkedAmount === 0) {
217
+ return `${label}`;
218
+ }
219
+ if (checkedAmount > 1) {
220
+ if (isTooltipLabel) {
221
+ const selectedOptionsDescrptions = selectedOptions.map(item => item.label);
222
+ return `${label}: ${selectedOptionsDescrptions.join(',')}`;
223
+ }
224
+ return `${label}: ${checkedAmount} ${this.getMessage('snkFilterBar.multiListToltip')}`;
225
+ }
226
+ return `${label}: ${selectedOptions[0].label}`;
227
+ }
217
228
  calculateActiveCount(groupedItems) {
218
229
  return groupedItems.reduce((total, item) => {
219
230
  if (!!item.visible)
@@ -121,10 +121,15 @@ export class SnkFilterModal {
121
121
  const index = filterListCopy.findIndex(item => item.id === filterItem.id);
122
122
  filterListCopy.splice(index, 1, filterItemCopy);
123
123
  this.filters = ObjectUtils.copy(filterListCopy);
124
+ return;
124
125
  }
125
- else {
126
- this.filters.find(filter => filter.id === filterItem.id).value = undefined;
126
+ if (FilterItemType.CHECK_BOX_LIST === filterItem.type) {
127
+ const filterListCopy = ObjectUtils.copy(this.filters);
128
+ filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
129
+ this.filters = ObjectUtils.copy(filterListCopy);
130
+ return;
127
131
  }
132
+ this.filters.find(filter => filter.id === filterItem.id).value = undefined;
128
133
  }
129
134
  uncheckFilterValues(valueList) {
130
135
  valueList.forEach(value => {
@@ -173,11 +178,17 @@ export class SnkFilterModal {
173
178
  getIformedFiltersCount(listItems) {
174
179
  let countInformedItens = 0;
175
180
  listItems.forEach(item => {
176
- var _a, _b, _c, _d, _e;
181
+ var _a, _b, _c, _d, _e, _f;
177
182
  if (FilterItemType.MULTI_LIST === item.type) {
178
183
  countInformedItens += (_e = (_d = (_c = ((_b = (_a = item.value) === null || _a === void 0 ? void 0 : _a.elements) !== null && _b !== void 0 ? _b : item.value)) === null || _c === void 0 ? void 0 : _c.filter(value => value === null || value === void 0 ? void 0 : value.check)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
179
184
  return;
180
185
  }
186
+ if (FilterItemType.CHECK_BOX_LIST === item.type) {
187
+ countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
188
+ .filter(([_, value]) => value === true)
189
+ .map(([key, _]) => key).length;
190
+ return;
191
+ }
181
192
  if (item.groupedItems != undefined) {
182
193
  countInformedItens = item.groupedItems.filter(item => item.visible).length;
183
194
  return;
@@ -31,6 +31,8 @@ export class SnkFilterModalItem {
31
31
  return { tag: "snk-filter-number", props };
32
32
  case FilterItemType.PERSONALIZED:
33
33
  return this.buildSnkFilterPersonalizedProps();
34
+ case FilterItemType.CHECK_BOX_LIST:
35
+ return { tag: "snk-filter-checkbox-list", props };
34
36
  case FilterItemType.MULTI_LIST:
35
37
  return { tag: "snk-entity-list", props: { maxHeightList: "640px", rightListSlotBuilder: item => this.buildRightSlot(item) } };
36
38
  }
@@ -54,7 +56,7 @@ export class SnkFilterModalItem {
54
56
  this.filterItem = Object.assign(Object.assign({}, this.filterItem), { visible: newValue > 0, value: newValue, groupedItems: data.items });
55
57
  }
56
58
  else {
57
- this.filterItem = Object.assign(Object.assign({}, this.filterItem), { value: this.filterItem.type === FilterItemType.SEARCH ? data : newValue, visible: this.isVisible(newValue) });
59
+ this.filterItem = Object.assign(Object.assign({}, this.filterItem), { value: this.filterItem.type === (FilterItemType.SEARCH || FilterItemType.CHECK_BOX_LIST) ? data : newValue, visible: this.isVisible(newValue) });
58
60
  }
59
61
  }
60
62
  handleDeleteFilter(filter, filterItemType) {
@@ -311,8 +311,12 @@ export class SnkFilterBar {
311
311
  const callbackOnApplyFilter = (filters) => {
312
312
  this.filterConfig = filters.map(this.normalizeItem).sort((a, b) => this._filtersComparator(a, b));
313
313
  };
314
+ let filtersConfigCopy = ObjectUtils.copy(this.filterConfig);
315
+ filtersConfigCopy = filtersConfigCopy.sort((itemA, itemB) => {
316
+ return itemA.originOrder - itemB.originOrder;
317
+ });
314
318
  const factoryParams = {
315
- filterConfig: ObjectUtils.copy(this.filterConfig),
319
+ filterConfig: filtersConfigCopy,
316
320
  configName: this.configName,
317
321
  onComplete: callbackOnApplyFilter,
318
322
  getMessage: (key, props) => this.getMessage(key, props),
@@ -23,6 +23,18 @@ export default class Workspace {
23
23
  var _a;
24
24
  (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.setScreenToUseOldLayout();
25
25
  }
26
+ static showDesktop() {
27
+ var _a, _b;
28
+ (_b = (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.showDesktop) === null || _b === void 0 ? void 0 : _b.call(_a);
29
+ }
30
+ static searchApp() {
31
+ var _a, _b;
32
+ (_b = (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.searchApp) === null || _b === void 0 ? void 0 : _b.call(_a);
33
+ }
34
+ static openHelp() {
35
+ var _a, _b;
36
+ (_b = (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openHelp) === null || _b === void 0 ? void 0 : _b.call(_a);
37
+ }
26
38
  static applicationClick() {
27
39
  var _a, _b;
28
40
  if (!((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.applicationClick)) {
@@ -9,6 +9,7 @@ var FilterItemType;
9
9
  FilterItemType["DEFAULT_FILTER"] = "DEFAULT_FILTER";
10
10
  FilterItemType["PERSONALIZED"] = "PERSONALIZED";
11
11
  FilterItemType["MULTI_LIST"] = "MULTI_LIST";
12
+ FilterItemType["CHECK_BOX_LIST"] = "CHECK_BOX_LIST";
12
13
  })(FilterItemType || (FilterItemType = {}));
13
14
  const FilterItemType$1 = FilterItemType;
14
15
 
@@ -20,6 +20,7 @@ export { SnkFilterAdvancedMode as SnkFilterAdvancedMode } from '../types/compone
20
20
  export { SnkFilterAssistentMode as SnkFilterAssistentMode } from '../types/components/snk-personalized-filter/subcomponents/snk-filter-assistent-mode/snk-filter-assistent-mode';
21
21
  export { SnkFilterBar as SnkFilterBar } from '../types/components/snk-filter-bar/snk-filter-bar';
22
22
  export { SnkFilterBinarySelect as SnkFilterBinarySelect } from '../types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select';
23
+ export { SnkFilterCheckboxList as SnkFilterCheckboxList } from '../types/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list';
23
24
  export { SnkFilterDetail as SnkFilterDetail } from '../types/components/snk-filter-bar/filter-item/snk-filter-detail';
24
25
  export { SnkFilterFieldSearch as SnkFilterFieldSearch } from '../types/components/snk-filter-field-search/snk-filter-field-search';
25
26
  export { SnkFilterItem as SnkFilterItem } from '../types/components/snk-filter-bar/filter-item/snk-filter-item';
@@ -20,6 +20,7 @@ export { SnkFilterAdvancedMode, defineCustomElement as defineCustomElementSnkFil
20
20
  export { SnkFilterAssistentMode, defineCustomElement as defineCustomElementSnkFilterAssistentMode } from './snk-filter-assistent-mode.js';
21
21
  export { SnkFilterBar, defineCustomElement as defineCustomElementSnkFilterBar } from './snk-filter-bar.js';
22
22
  export { SnkFilterBinarySelect, defineCustomElement as defineCustomElementSnkFilterBinarySelect } from './snk-filter-binary-select.js';
23
+ export { SnkFilterCheckboxList, defineCustomElement as defineCustomElementSnkFilterCheckboxList } from './snk-filter-checkbox-list.js';
23
24
  export { SnkFilterDetail, defineCustomElement as defineCustomElementSnkFilterDetail } from './snk-filter-detail.js';
24
25
  export { SnkFilterFieldSearch, defineCustomElement as defineCustomElementSnkFilterFieldSearch } from './snk-filter-field-search.js';
25
26
  export { SnkFilterItem, defineCustomElement as defineCustomElementSnkFilterItem } from './snk-filter-item.js';
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { DateUtils, StringUtils, ObjectUtils, WaitingChangeException, WarningException, ErrorException, OnboardingUtils, DependencyType, ElementIDUtils, DataType, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
2
+ import { DateUtils, StringUtils, ObjectUtils, WaitingChangeException, WarningException, ErrorException, KeyboardManager, OnboardingUtils, DependencyType, ElementIDUtils, DataType, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { C as ConfigStorage } from './ConfigStorage.js';
5
5
  import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher.js';
@@ -170,6 +170,18 @@ class Workspace {
170
170
  var _a;
171
171
  (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.setScreenToUseOldLayout();
172
172
  }
173
+ static showDesktop() {
174
+ var _a, _b;
175
+ (_b = (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.showDesktop) === null || _b === void 0 ? void 0 : _b.call(_a);
176
+ }
177
+ static searchApp() {
178
+ var _a, _b;
179
+ (_b = (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.searchApp) === null || _b === void 0 ? void 0 : _b.call(_a);
180
+ }
181
+ static openHelp() {
182
+ var _a, _b;
183
+ (_b = (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openHelp) === null || _b === void 0 ? void 0 : _b.call(_a);
184
+ }
173
185
  static applicationClick() {
174
186
  var _a, _b;
175
187
  if (!((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.applicationClick)) {
@@ -250,6 +262,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
250
262
  this.applicationLoading = createEvent(this, "applicationLoading", 7);
251
263
  this.NEW_VERSION_POPUP_LOCKER = "NEW_VERSION_POPUP_LOCKER";
252
264
  this._authPromises = [];
265
+ this._keyboardManager = new KeyboardManager();
253
266
  this._duCache = new Map();
254
267
  this._duPromises = new Map();
255
268
  this._requestListener = new RequestListenerLoadingBar();
@@ -309,6 +322,14 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
309
322
  });
310
323
  }
311
324
  }
325
+ /**
326
+ * Obtém o controlador de teclado.
327
+ *
328
+ * @return {KeyboardManager} the keyboard manager
329
+ */
330
+ async getKeyboardManager() {
331
+ return Promise.resolve(this._keyboardManager);
332
+ }
312
333
  /**
313
334
  * Obtém `true` caso o usuário logado seja o SUP.
314
335
  */
@@ -1082,6 +1103,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1082
1103
  }
1083
1104
  disconnectedCallback() {
1084
1105
  DataFetcher.removeRequestListener(this._requestListener);
1106
+ this.removeShortcuts();
1085
1107
  }
1086
1108
  async componentDidLoad() {
1087
1109
  this.applicationLoading.emit(true);
@@ -1092,6 +1114,19 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1092
1114
  });
1093
1115
  ElementIDUtils.addIDInfo(this._element, `resource_${this.applicationResourceID}`);
1094
1116
  await this.handleShowNewVersionPopup();
1117
+ this.initKeyboardManager();
1118
+ }
1119
+ initKeyboardManager() {
1120
+ this._keyboardManager
1121
+ .bind("ctrl + g", Workspace.searchApp.bind(this), { description: "Pesquisar por telas" })
1122
+ .bind("ctrl + d", Workspace.showDesktop.bind(this), { description: "Mostrar o desktop" })
1123
+ .bind("F1", Workspace.openHelp.bind(this), { description: "Abrir ajuda" });
1124
+ }
1125
+ removeShortcuts() {
1126
+ this._keyboardManager
1127
+ .unbind("ctrl + g")
1128
+ .unbind("ctrl + d")
1129
+ .unbind("F1");
1095
1130
  }
1096
1131
  render() {
1097
1132
  return (h("div", null, h("ez-loading-bar", { ref: (ref) => this._requestListener.loadingBar = ref }), h("ez-popup", { opened: false, ref: (ref) => this._popUp = ref, onEzClosePopup: () => this.closePopUp() }), h("ez-modal", { opened: false, ref: (ref) => this._rightModal = ref, "modal-size": "small", closeOutsideClick: true, closeEsc: true })));
@@ -1102,6 +1137,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1102
1137
  "messagesBuilder": [1040],
1103
1138
  "configName": [1, "config-name"],
1104
1139
  "loadByPK": [16],
1140
+ "getKeyboardManager": [64],
1105
1141
  "isUserSup": [64],
1106
1142
  "addPendingAction": [64],
1107
1143
  "callServiceBroker": [64],
@@ -156,9 +156,11 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
156
156
  return joinedPrimaryKeys;
157
157
  }
158
158
  componentWillLoad() {
159
- const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
160
- application.hasAccess(AutorizationType.UPDATE, this._resourceID).then(canEdit => this._canEdit = canEdit);
159
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
161
160
  let parent = this._element.parentElement;
161
+ this._application
162
+ .hasAccess(AutorizationType.UPDATE, this._resourceID)
163
+ .then(canEdit => this._canEdit = canEdit);
162
164
  while (parent) {
163
165
  if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
164
166
  this._snkDataUnit = parent;
@@ -169,11 +171,11 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
169
171
  if (!this._dataUnit) {
170
172
  this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
171
173
  this._dataUnit = evt.detail;
172
- this.initDataUnit(application);
174
+ this.initDataUnit();
173
175
  });
174
176
  }
175
177
  else {
176
- this.initDataUnit(application);
178
+ this.initDataUnit();
177
179
  }
178
180
  this._snkDataUnit.addEventListener("dataStateChange", async ({ detail: dataState }) => {
179
181
  this._dataState = dataState;
@@ -186,10 +188,72 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
186
188
  parent = parent.parentElement;
187
189
  }
188
190
  if (!this.configName) {
189
- this.configName = application.configName;
191
+ this.configName = this._application.configName;
190
192
  }
191
193
  }
192
- async initDataUnit(application) {
194
+ componentDidLoad() {
195
+ this.initKeyboardManager();
196
+ }
197
+ disconnectedCallback() {
198
+ this.removeShortcuts();
199
+ }
200
+ async initKeyboardManager() {
201
+ const keyboardManager = await this._application.getKeyboardManager();
202
+ if (keyboardManager) {
203
+ const dataUnit = this._dataUnit || await this._snkDataUnit.getDataUnit();
204
+ keyboardManager
205
+ .bind("F6", this.toggleView.bind(this), { description: "Alterna entre modo formulário e grade." })
206
+ .bind("F7", dataUnit.saveData.bind(dataUnit), { description: "Salva os dados." })
207
+ .bind("ctrl + \\", dataUnit.saveData.bind(dataUnit), { description: "Salva os dados." })
208
+ .bind("F8", dataUnit.addRecord.bind(dataUnit), { description: "Adiciona um novo registro." })
209
+ .bind("F9", dataUnit.removeSelectedRecords.bind(dataUnit), { description: "Remove o registro selecionado." })
210
+ .bind("ctrl + F9", dataUnit.removeSelectedRecords.bind(dataUnit), { description: "Remove o registro selecionado." })
211
+ .bind("ctrl + .", () => {
212
+ if (dataUnit.getSelectionInfo().records.length === 0) {
213
+ return dataUnit.selectFirst();
214
+ }
215
+ return dataUnit.nextRecord();
216
+ }, {
217
+ description: "Avança para o próximo registro."
218
+ })
219
+ .bind("ctrl + ,", dataUnit.previousRecord.bind(dataUnit), { description: "Retorna ao registro anterior." })
220
+ .bind("F5", async () => {
221
+ const currentView = await this._viewStack.getSelectedIndex();
222
+ if (VIEW_MODE.GRID === currentView) {
223
+ dataUnit.loadData();
224
+ }
225
+ }, { description: "Atualiza os dados." })
226
+ .bind("Escape", () => {
227
+ if (dataUnit.isDirty()) {
228
+ dataUnit.cancelEdition();
229
+ }
230
+ }, {
231
+ debounceTime: 1000,
232
+ description: "Cancela uma ação."
233
+ });
234
+ }
235
+ }
236
+ async removeShortcuts() {
237
+ const keyboardManager = await this._application.getKeyboardManager();
238
+ if (keyboardManager) {
239
+ keyboardManager
240
+ .unbind("F6")
241
+ .unbind("F7")
242
+ .unbind("ctrl + \\")
243
+ .unbind("F8")
244
+ .unbind("F9")
245
+ .unbind("ctrl + F9")
246
+ .unbind("ctrl + .")
247
+ .unbind("ctrl + ,")
248
+ .unbind("F5")
249
+ .unbind("Escape");
250
+ }
251
+ }
252
+ async toggleView() {
253
+ const currentView = await this._viewStack.getSelectedIndex();
254
+ this.setViewMode(VIEW_MODE.GRID === currentView ? VIEW_MODE.FORM : VIEW_MODE.GRID);
255
+ }
256
+ async initDataUnit() {
193
257
  this.addDataElementID();
194
258
  if (!this.messagesBuilder) {
195
259
  this.messagesBuilder = this._snkDataUnit.messagesBuilder;
@@ -198,7 +262,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
198
262
  //Tenta pegar o resourceID do snkDataUnit;
199
263
  this._resourceID = this._snkDataUnit.resourceID;
200
264
  if (this._resourceID == undefined) {
201
- this._resourceID = await application.getResourceID();
265
+ this._resourceID = await this._application.getResourceID();
202
266
  }
203
267
  }
204
268
  }
@@ -38,6 +38,8 @@ const buildFilter = (item) => {
38
38
  return buildNumber(item);
39
39
  case FilterItemType.PERSONALIZED:
40
40
  return buildPersonalized(item);
41
+ case FilterItemType.CHECK_BOX_LIST:
42
+ return buildCheckboxList(item);
41
43
  default:
42
44
  return undefined;
43
45
  }
@@ -70,6 +72,23 @@ function buildMultiList(item) {
70
72
  };
71
73
  }
72
74
  }
75
+ function buildCheckboxList(item) {
76
+ var _a;
77
+ const { id, value, props } = item;
78
+ const selectedOptionNames = Object.entries(value !== null && value !== void 0 ? value : {})
79
+ .filter(([_, valueChecked]) => valueChecked === true)
80
+ .map(([key, _]) => key);
81
+ const selectedOptionsObject = (_a = props.options) === null || _a === void 0 ? void 0 : _a.filter(option => selectedOptionNames.includes(option.name));
82
+ return { name: id, expression: buildCheckboxListExpression(selectedOptionsObject), params: [] };
83
+ }
84
+ function buildCheckboxListExpression(options) {
85
+ let expression = "";
86
+ options.forEach((option, index) => {
87
+ var _a;
88
+ expression += ` ${index > 0 ? ((_a = option.operand) !== null && _a !== void 0 ? _a : 'OR') : ''} ${option.expression}`;
89
+ });
90
+ return expression.trim();
91
+ }
73
92
  function parseMultiListValues(multiListValue) {
74
93
  var _a, _b;
75
94
  const value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
@@ -540,8 +559,12 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
540
559
  const callbackOnApplyFilter = (filters) => {
541
560
  this.filterConfig = filters.map(this.normalizeItem).sort((a, b) => this._filtersComparator(a, b));
542
561
  };
562
+ let filtersConfigCopy = ObjectUtils.copy(this.filterConfig);
563
+ filtersConfigCopy = filtersConfigCopy.sort((itemA, itemB) => {
564
+ return itemA.originOrder - itemB.originOrder;
565
+ });
543
566
  const factoryParams = {
544
- filterConfig: ObjectUtils.copy(this.filterConfig),
567
+ filterConfig: filtersConfigCopy,
545
568
  configName: this.configName,
546
569
  onComplete: callbackOnApplyFilter,
547
570
  getMessage: (key, props) => this.getMessage(key, props),
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkFilterCheckboxList extends Components.SnkFilterCheckboxList, HTMLElement {}
4
+ export const SnkFilterCheckboxList: {
5
+ prototype: SnkFilterCheckboxList;
6
+ new (): SnkFilterCheckboxList;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,68 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { ElementIDUtils } from '@sankhyalabs/core';
3
+ import { F as FilterItemType } from './filter-item-type.enum.js';
4
+
5
+ const SnkFilterCheckboxList$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6
+ constructor() {
7
+ super();
8
+ this.__registerHost();
9
+ this.valueChanged = createEvent(this, "valueChanged", 7);
10
+ this.config = undefined;
11
+ this.optionsList = [];
12
+ }
13
+ componentDidLoad() {
14
+ if (this._element) {
15
+ ElementIDUtils.addIDInfo(this._element, 'filterContentEditor');
16
+ }
17
+ }
18
+ handleToggleCheck(itemChanged, checked) {
19
+ var _a, _b;
20
+ let configValueMap = (_a = this.config.value) !== null && _a !== void 0 ? _a : {};
21
+ configValueMap[itemChanged.name] = checked;
22
+ this.config = Object.assign(Object.assign({}, this.config), { value: configValueMap });
23
+ this.valueChanged.emit((_b = this.config) === null || _b === void 0 ? void 0 : _b.value);
24
+ }
25
+ renderOptions() {
26
+ return this.optionsList.map(option => (h("ez-check", { label: option.label, compact: true, onEzChange: (event) => this.handleToggleCheck(option, event.detail), value: !!this.isChecked(option.name) })));
27
+ }
28
+ isChecked(itemName) {
29
+ var _a;
30
+ return (_a = this.config.value) === null || _a === void 0 ? void 0 : _a[itemName];
31
+ }
32
+ buidOptions() {
33
+ var _a, _b, _c;
34
+ const propsOptions = (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.options) !== null && _c !== void 0 ? _c : [];
35
+ this.optionsList = [...propsOptions];
36
+ }
37
+ componentWillRender() {
38
+ this.buidOptions();
39
+ }
40
+ render() {
41
+ if (!this.config || this.config.type !== FilterItemType.CHECK_BOX_LIST) {
42
+ return undefined;
43
+ }
44
+ return (h("div", { class: 'ez-flex ez-flex--column' }, this.renderOptions()));
45
+ }
46
+ get _element() { return this; }
47
+ }, [0, "snk-filter-checkbox-list", {
48
+ "config": [1040],
49
+ "optionsList": [32]
50
+ }]);
51
+ function defineCustomElement$1() {
52
+ if (typeof customElements === "undefined") {
53
+ return;
54
+ }
55
+ const components = ["snk-filter-checkbox-list"];
56
+ components.forEach(tagName => { switch (tagName) {
57
+ case "snk-filter-checkbox-list":
58
+ if (!customElements.get(tagName)) {
59
+ customElements.define(tagName, SnkFilterCheckboxList$1);
60
+ }
61
+ break;
62
+ } });
63
+ }
64
+
65
+ const SnkFilterCheckboxList = SnkFilterCheckboxList$1;
66
+ const defineCustomElement = defineCustomElement$1;
67
+
68
+ export { SnkFilterCheckboxList, defineCustomElement };