@sankhyalabs/sankhyablocks 8.9.0-dev.3 → 8.9.0-dev.4

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 (74) hide show
  1. package/dist/cjs/{SnkMessageBuilder-0202c090.js → SnkMessageBuilder-fbc33123.js} +5 -4
  2. package/dist/cjs/filterNumberVariation-d65332da.js +7 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  5. package/dist/cjs/snk-application.cjs.entry.js +1 -1
  6. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  7. package/dist/cjs/{snk-data-unit-bcfdd657.js → snk-data-unit-b949160d.js} +1 -1
  8. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  9. package/dist/cjs/snk-detail-view.cjs.entry.js +1 -1
  10. package/dist/cjs/snk-filter-bar.cjs.entry.js +71 -0
  11. package/dist/cjs/snk-filter-item.cjs.entry.js +15 -2
  12. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
  13. package/dist/cjs/snk-filter-modal.cjs.entry.js +8 -2
  14. package/dist/cjs/snk-filter-number.cjs.entry.js +41 -2
  15. package/dist/cjs/snk-filter-period.cjs.entry.js +2 -2
  16. package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +33 -0
  17. package/dist/collection/components/snk-filter-bar/filter-item/editors/enum/filterNumberVariation.js +5 -0
  18. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +93 -8
  19. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +2 -2
  20. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +15 -2
  21. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +8 -2
  22. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +1 -1
  23. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +116 -0
  24. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +5 -4
  25. package/dist/components/SnkMessageBuilder.js +5 -4
  26. package/dist/components/filterNumberVariation.js +7 -0
  27. package/dist/components/snk-filter-bar2.js +75 -1
  28. package/dist/components/snk-filter-item2.js +15 -2
  29. package/dist/components/snk-filter-modal-item2.js +1 -1
  30. package/dist/components/snk-filter-modal.js +8 -2
  31. package/dist/components/snk-filter-number.js +43 -2
  32. package/dist/components/snk-filter-period.js +2 -2
  33. package/dist/esm/{SnkMessageBuilder-ba5d04d3.js → SnkMessageBuilder-f60c5443.js} +5 -4
  34. package/dist/esm/filterNumberVariation-8cee02ea.js +7 -0
  35. package/dist/esm/loader.js +1 -1
  36. package/dist/esm/sankhyablocks.js +1 -1
  37. package/dist/esm/snk-application.entry.js +1 -1
  38. package/dist/esm/snk-data-exporter.entry.js +2 -2
  39. package/dist/esm/{snk-data-unit-ddd25458.js → snk-data-unit-ca945bf5.js} +1 -1
  40. package/dist/esm/snk-data-unit.entry.js +2 -2
  41. package/dist/esm/snk-detail-view.entry.js +1 -1
  42. package/dist/esm/snk-filter-bar.entry.js +71 -0
  43. package/dist/esm/snk-filter-item.entry.js +15 -2
  44. package/dist/esm/snk-filter-modal-item.entry.js +1 -1
  45. package/dist/esm/snk-filter-modal.entry.js +8 -2
  46. package/dist/esm/snk-filter-number.entry.js +41 -2
  47. package/dist/esm/snk-filter-period.entry.js +2 -2
  48. package/dist/sankhyablocks/{p-deeba96a.js → p-210b4794.js} +1 -1
  49. package/dist/sankhyablocks/p-2640ba03.entry.js +1 -0
  50. package/dist/sankhyablocks/p-29529c8f.entry.js +1 -0
  51. package/dist/sankhyablocks/p-94c532bb.entry.js +1 -0
  52. package/dist/sankhyablocks/p-aa3b0d19.js +1 -0
  53. package/dist/sankhyablocks/{p-9531cb90.entry.js → p-b2ce189a.entry.js} +1 -1
  54. package/dist/sankhyablocks/{p-e31d92cd.entry.js → p-bbcd3b4d.entry.js} +1 -1
  55. package/dist/sankhyablocks/p-cd024328.entry.js +1 -0
  56. package/dist/sankhyablocks/p-d4c72815.entry.js +1 -0
  57. package/dist/sankhyablocks/{p-e57c9958.entry.js → p-de84a3d5.entry.js} +2 -2
  58. package/dist/sankhyablocks/p-fa80e546.js +1 -0
  59. package/dist/sankhyablocks/{p-959e0835.entry.js → p-fc257290.entry.js} +1 -1
  60. package/dist/sankhyablocks/p-fda8c84c.entry.js +1 -0
  61. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  62. package/dist/types/components/snk-filter-bar/filter-item/editors/enum/filterNumberVariation.d.ts +4 -0
  63. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +24 -2
  64. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -0
  65. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +16 -0
  66. package/dist/types/components.d.ts +33 -3
  67. package/package.json +1 -1
  68. package/dist/sankhyablocks/p-3bf4df20.entry.js +0 -1
  69. package/dist/sankhyablocks/p-3ca9120f.entry.js +0 -1
  70. package/dist/sankhyablocks/p-b3dc25aa.entry.js +0 -1
  71. package/dist/sankhyablocks/p-c8f8391a.js +0 -1
  72. package/dist/sankhyablocks/p-e11c5038.entry.js +0 -1
  73. package/dist/sankhyablocks/p-e3a82e1c.entry.js +0 -1
  74. package/dist/sankhyablocks/p-fb83ea95.entry.js +0 -1
@@ -1,15 +1,28 @@
1
1
  import { ElementIDUtils } from '@sankhyalabs/core';
2
2
  import { h } from '@stencil/core';
3
3
  import FilterItemType from '../filter-item-type.enum';
4
+ import { EPresentationMode } from './enum/presentationMode';
5
+ import { FilterNumberVariation } from './enum/filterNumberVariation';
4
6
  export class SnkFilterPeriod {
5
7
  constructor() {
8
+ this._startIntervalLabel = 'Inicial';
9
+ this._endIntervalLabel = 'Final';
6
10
  this.config = undefined;
11
+ this.getMessage = undefined;
7
12
  this.value = undefined;
13
+ this.presentationMode = EPresentationMode.CHIP;
8
14
  }
9
15
  /**
10
16
  * Emitido quando acontece a alteração de valor do componente snk-filter-number
11
17
  */
12
18
  ezChangeListener(evt) {
19
+ if (this.getVariation() === FilterNumberVariation.INTERVAL) {
20
+ const start = this._startInterval.value;
21
+ const end = this._endInterval.value;
22
+ this.value = (start || end ? { start, end } : undefined);
23
+ this.valueChanged.emit(this.value);
24
+ return;
25
+ }
13
26
  this.value = evt.detail;
14
27
  this.valueChanged.emit(this.value);
15
28
  }
@@ -17,19 +30,45 @@ export class SnkFilterPeriod {
17
30
  * Exibe o componente snk-filter-number
18
31
  */
19
32
  async show() {
33
+ if (this.getVariation() === FilterNumberVariation.INTERVAL) {
34
+ this._startInterval.setFocus();
35
+ return;
36
+ }
20
37
  this._numberElement.setFocus();
21
38
  }
39
+ getIntervalValue(prop) {
40
+ const objValue = this.value ? this.value[prop] : null;
41
+ return objValue !== null && objValue !== void 0 ? objValue : null;
42
+ }
43
+ buildLabel() {
44
+ if (this.presentationMode === EPresentationMode.CHIP) {
45
+ return h("label", { class: "ez-text ez-text--medium ez-text--primary ez-margin--medium" }, "at\u00E9");
46
+ }
47
+ }
48
+ getVariation() {
49
+ var _a, _b;
50
+ return (_b = (_a = this.config.props) === null || _a === void 0 ? void 0 : _a.variation) !== null && _b !== void 0 ? _b : FilterNumberVariation.DEFAULT;
51
+ }
52
+ componentWillLoad() {
53
+ if (this.getMessage) {
54
+ this._startIntervalLabel = this.getMessage('snkFilterBar.labelStart');
55
+ this._endIntervalLabel = this.getMessage('snkFilterBar.labelEnd');
56
+ }
57
+ }
22
58
  componentDidLoad() {
23
59
  if (this._element) {
24
60
  ElementIDUtils.addIDInfo(this._element, 'filterContentEditor');
25
61
  }
26
62
  }
27
63
  render() {
28
- var _a;
64
+ var _a, _b, _c;
29
65
  if (!this.config || this.config.type !== FilterItemType.NUMBER) {
30
66
  return undefined;
31
67
  }
32
- return (h("ez-number-input", { id: this.config.id, ref: ref => this._numberElement = ref, label: this.config.label, value: this.config.value, precision: (_a = this.config.props) === null || _a === void 0 ? void 0 : _a.precision }));
68
+ if (this.getVariation() === FilterNumberVariation.INTERVAL) {
69
+ return (h("div", { class: "ez-col ez-col--nowrap" }, h("ez-number-input", { id: `${this.config.id}_start`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding--small' : '', label: this._startIntervalLabel, ref: ref => this._startInterval = ref, value: this.getIntervalValue("start"), precision: (_a = this.config.props) === null || _a === void 0 ? void 0 : _a.precision }), this.buildLabel(), h("ez-number-input", { id: `${this.config.id}_end`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding--small' : '', label: this._endIntervalLabel, ref: ref => this._endInterval = ref, value: this.getIntervalValue("end"), precision: (_b = this.config.props) === null || _b === void 0 ? void 0 : _b.precision })));
70
+ }
71
+ return (h("ez-number-input", { id: this.config.id, ref: ref => this._numberElement = ref, label: this.config.label, value: this.config.value, precision: (_c = this.config.props) === null || _c === void 0 ? void 0 : _c.precision }));
33
72
  }
34
73
  static get is() { return "snk-filter-number"; }
35
74
  static get properties() {
@@ -54,13 +93,32 @@ export class SnkFilterPeriod {
54
93
  "text": "Define as configura\u00E7\u00F5es do componente snk-filter-number"
55
94
  }
56
95
  },
96
+ "getMessage": {
97
+ "type": "unknown",
98
+ "mutable": false,
99
+ "complexType": {
100
+ "original": "(key: string, props?: any) => string",
101
+ "resolved": "(key: string, props?: any) => string",
102
+ "references": {}
103
+ },
104
+ "required": false,
105
+ "optional": false,
106
+ "docs": {
107
+ "tags": [],
108
+ "text": "Usado pra flexibilizar os verbetes e mensagens de acordo com o SnkMessageBuilder."
109
+ }
110
+ },
57
111
  "value": {
58
112
  "type": "number",
59
113
  "mutable": false,
60
114
  "complexType": {
61
- "original": "number",
62
- "resolved": "number",
63
- "references": {}
115
+ "original": "FilterNumberValueType",
116
+ "resolved": "number | { start: number; end: number; }",
117
+ "references": {
118
+ "FilterNumberValueType": {
119
+ "location": "global"
120
+ }
121
+ }
64
122
  },
65
123
  "required": false,
66
124
  "optional": false,
@@ -70,6 +128,29 @@ export class SnkFilterPeriod {
70
128
  },
71
129
  "attribute": "value",
72
130
  "reflect": false
131
+ },
132
+ "presentationMode": {
133
+ "type": "number",
134
+ "mutable": false,
135
+ "complexType": {
136
+ "original": "EPresentationMode",
137
+ "resolved": "EPresentationMode.CHIP | EPresentationMode.MODAL",
138
+ "references": {
139
+ "EPresentationMode": {
140
+ "location": "import",
141
+ "path": "./enum/presentationMode"
142
+ }
143
+ }
144
+ },
145
+ "required": false,
146
+ "optional": false,
147
+ "docs": {
148
+ "tags": [],
149
+ "text": "Define a varia\u00E7\u00E3o do componente"
150
+ },
151
+ "attribute": "presentation-mode",
152
+ "reflect": false,
153
+ "defaultValue": "EPresentationMode.CHIP"
73
154
  }
74
155
  };
75
156
  }
@@ -85,9 +166,13 @@ export class SnkFilterPeriod {
85
166
  "text": "Emitido quando o valor do filtro \u00E9 alterado."
86
167
  },
87
168
  "complexType": {
88
- "original": "any",
89
- "resolved": "any",
90
- "references": {}
169
+ "original": "FilterNumberValueType",
170
+ "resolved": "number | { start: number; end: number; }",
171
+ "references": {
172
+ "FilterNumberValueType": {
173
+ "location": "global"
174
+ }
175
+ }
91
176
  }
92
177
  }];
93
178
  }
@@ -50,8 +50,8 @@ export class SnkFilterPeriod {
50
50
  }
51
51
  componentWillLoad() {
52
52
  if (this.getMessage) {
53
- this._startDateLabel = this.getMessage('snkFilterBar.labelStartDatePeriod');
54
- this._endDateLabel = this.getMessage('snkFilterBar.labelEndDatePeriod');
53
+ this._startDateLabel = this.getMessage('snkFilterBar.labelStart');
54
+ this._endDateLabel = this.getMessage('snkFilterBar.labelEnd');
55
55
  }
56
56
  }
57
57
  render() {
@@ -1,6 +1,7 @@
1
1
  import { ElementIDUtils, FloatingManager, DateUtils } from '@sankhyalabs/core';
2
2
  import { h, Host } from '@stencil/core';
3
3
  import FilterItemType from './filter-item-type.enum';
4
+ import { FilterNumberVariation } from './editors/enum/filterNumberVariation';
4
5
  export class SnkFilterItem {
5
6
  constructor() {
6
7
  this.innerClickCheck = (_floatingContainer, node) => {
@@ -163,10 +164,10 @@ export class SnkFilterItem {
163
164
  }
164
165
  else {
165
166
  if (start) {
166
- return `${label}: ${this.getMessage('snkFilterBar.onlyStartPeriodToltip')} ${dateFormater.format(start)}`;
167
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${dateFormater.format(start)}`;
167
168
  }
168
169
  else if (end) {
169
- return `${label}: ${this.getMessage('snkFilterBar.onlyEndPeriodToltip')} ${dateFormater.format(end)}`;
170
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${dateFormater.format(end)}`;
170
171
  }
171
172
  else {
172
173
  return label;
@@ -197,6 +198,18 @@ export class SnkFilterItem {
197
198
  }
198
199
  return `${label}: ${selectedOptions[0].label}`;
199
200
  }
201
+ if (type === FilterItemType.NUMBER && props.variation === FilterNumberVariation.INTERVAL) {
202
+ const { start, end } = value;
203
+ if (start && end) {
204
+ return this.getMessage('snkFilterBar.fullIntervalTooltip', { LABEL: label, START_LABEL: start, END_LABEL: end });
205
+ }
206
+ if (start) {
207
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${Number(start)}`;
208
+ }
209
+ if (end) {
210
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${Number(end)}`;
211
+ }
212
+ }
200
213
  return `${label}: ${value}`;
201
214
  }
202
215
  return label;
@@ -5,6 +5,7 @@ import FilterType from '../types/filter-type.enum';
5
5
  import FilterItemType from '../filter-item/filter-item-type.enum';
6
6
  import { ObjectUtils } from '@sankhyalabs/core';
7
7
  import { PersonalizedFilterUtils } from '../../snk-personalized-filter/subcomponents/snk-filter-param-config/utils/PersonalizedFilterUtils';
8
+ import { FilterNumberVariation } from '../filter-item/editors/enum/filterNumberVariation';
8
9
  export class SnkFilterModal {
9
10
  constructor() {
10
11
  this.getMessage = undefined;
@@ -136,6 +137,11 @@ export class SnkFilterModal {
136
137
  renderFilterItem(filterItem, fullRow) {
137
138
  return (h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event.detail), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
138
139
  }
140
+ isDefaultFilterNumberVariation(filter) {
141
+ var _a;
142
+ return filter.type === FilterItemType.NUMBER
143
+ && (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === FilterNumberVariation.DEFAULT);
144
+ }
139
145
  mountFiltersLines(filters) {
140
146
  const MAX_LINE_LENGTH = 2;
141
147
  let currentLine = 0;
@@ -145,8 +151,8 @@ export class SnkFilterModal {
145
151
  filtersLines[currentLine] = filtersLines[currentLine] || [];
146
152
  const item = filters[curr];
147
153
  const isLast = curr === filters.length - 1;
148
- const currentItemMatch = [FilterItemType.TEXT, FilterItemType.NUMBER].includes(item.type);
149
- const nextItemMatch = isLast ? false : [FilterItemType.TEXT, FilterItemType.NUMBER].includes(filters[curr + 1].type);
154
+ const currentItemMatch = item.type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
155
+ const nextItemMatch = isLast ? false : filters[curr + 1].type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
150
156
  if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
151
157
  filtersLines[currentLine].push(item);
152
158
  forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
@@ -28,7 +28,7 @@ export class SnkFilterModalItem {
28
28
  case FilterItemType.SEARCH:
29
29
  return { tag: "snk-filter-search" };
30
30
  case FilterItemType.NUMBER:
31
- return { tag: "snk-filter-number" };
31
+ return { tag: "snk-filter-number", props };
32
32
  case FilterItemType.PERSONALIZED:
33
33
  return this.buildSnkFilterPersonalizedProps();
34
34
  case FilterItemType.MULTI_LIST:
@@ -76,6 +76,44 @@ export class SnkFilterBar {
76
76
  async reload() {
77
77
  this.loadConfigFromStorage();
78
78
  }
79
+ /**
80
+ * Retorna um item de filtro pelo ID.
81
+ */
82
+ async getFilterItem(id) {
83
+ const item = this.filterConfig.find(item => item.id === id);
84
+ return Promise.resolve(ObjectUtils.copy(item));
85
+ }
86
+ /**
87
+ * Atualiza um item do filtro.
88
+ *
89
+ * @param filterItem - Item com as informações atualizadas, caso o item não seja encontrado no array ele mão será modificado
90
+ */
91
+ async updateFilterItem(newFilterItem) {
92
+ const itemIndex = this.filterConfig.findIndex(item => item.id === newFilterItem.id);
93
+ if (itemIndex == -1) {
94
+ console.warn("[SnkFilterBar.updateFilterItem] FilterItem não encontrado, o mesmo não será atualizado.");
95
+ return Promise.resolve();
96
+ }
97
+ this._loadingPending = true;
98
+ this.updateFilter(newFilterItem);
99
+ return Promise.resolve();
100
+ }
101
+ /**
102
+ * Adiciona um item de filtro.
103
+ *
104
+ * @param filterItem - Item a ser adicionado, caso o item já exista com o ID ele não será adicionado novamente
105
+ */
106
+ async addFilterItem(filterItem) {
107
+ const itemIndex = this.filterConfig.findIndex(item => item.id === filterItem.id);
108
+ if (itemIndex > -1) {
109
+ console.warn("[SnkFilterBar.addFilterItem] FilterItem já existe , o mesmo não será adicionado novamente.");
110
+ return Promise.resolve();
111
+ }
112
+ this.filterConfig.push(filterItem);
113
+ this._loadingPending = true;
114
+ this.updateFilter(filterItem);
115
+ return Promise.resolve();
116
+ }
79
117
  componentDidLoad() {
80
118
  if (this._element) {
81
119
  const dataInfo = { dataUnit: this.dataUnit };
@@ -492,6 +530,84 @@ export class SnkFilterBar {
492
530
  "text": "Faz o recarregamento da filterbar buscando o state no servidor.",
493
531
  "tags": []
494
532
  }
533
+ },
534
+ "getFilterItem": {
535
+ "complexType": {
536
+ "signature": "(id: string) => Promise<SnkFilterItemConfig | undefined>",
537
+ "parameters": [{
538
+ "tags": [],
539
+ "text": ""
540
+ }],
541
+ "references": {
542
+ "Promise": {
543
+ "location": "global"
544
+ },
545
+ "SnkFilterItemConfig": {
546
+ "location": "import",
547
+ "path": "./filter-item/snk-filter-item"
548
+ }
549
+ },
550
+ "return": "Promise<SnkFilterItemConfig>"
551
+ },
552
+ "docs": {
553
+ "text": "Retorna um item de filtro pelo ID.",
554
+ "tags": []
555
+ }
556
+ },
557
+ "updateFilterItem": {
558
+ "complexType": {
559
+ "signature": "(newFilterItem: SnkFilterItemConfig) => Promise<void>",
560
+ "parameters": [{
561
+ "tags": [],
562
+ "text": ""
563
+ }],
564
+ "references": {
565
+ "Promise": {
566
+ "location": "global"
567
+ },
568
+ "SnkFilterItemConfig": {
569
+ "location": "import",
570
+ "path": "./filter-item/snk-filter-item"
571
+ }
572
+ },
573
+ "return": "Promise<void>"
574
+ },
575
+ "docs": {
576
+ "text": "Atualiza um item do filtro.",
577
+ "tags": [{
578
+ "name": "param",
579
+ "text": "filterItem - Item com as informa\u00E7\u00F5es atualizadas, caso o item n\u00E3o seja encontrado no array ele m\u00E3o ser\u00E1 modificado"
580
+ }]
581
+ }
582
+ },
583
+ "addFilterItem": {
584
+ "complexType": {
585
+ "signature": "(filterItem: SnkFilterItemConfig) => Promise<void>",
586
+ "parameters": [{
587
+ "tags": [{
588
+ "name": "param",
589
+ "text": "filterItem - Item a ser adicionado, caso o item j\u00E1 exista com o ID ele n\u00E3o ser\u00E1 adicionado novamente"
590
+ }],
591
+ "text": "- Item a ser adicionado, caso o item j\u00E1 exista com o ID ele n\u00E3o ser\u00E1 adicionado novamente"
592
+ }],
593
+ "references": {
594
+ "Promise": {
595
+ "location": "global"
596
+ },
597
+ "SnkFilterItemConfig": {
598
+ "location": "import",
599
+ "path": "./filter-item/snk-filter-item"
600
+ }
601
+ },
602
+ "return": "Promise<void>"
603
+ },
604
+ "docs": {
605
+ "text": "Adiciona um item de filtro.",
606
+ "tags": [{
607
+ "name": "param",
608
+ "text": "filterItem - Item a ser adicionado, caso o item j\u00E1 exista com o ID ele n\u00E3o ser\u00E1 adicionado novamente"
609
+ }]
610
+ }
495
611
  }
496
612
  };
497
613
  }
@@ -30,11 +30,12 @@ const snkFilterBarMessages = {
30
30
  "modalCancelButtonLabel": "Limpar",
31
31
  "binarySelectTooltip": "Exibindo registros",
32
32
  "multiListToltip": "selecionado(a)s",
33
- "onlyStartPeriodToltip": "A partir de",
34
- "onlyEndPeriodToltip": "Até",
33
+ "onlyStartToltip": "A partir de",
34
+ "onlyEndToltip": "Até",
35
35
  "fullPeriodTooltip": "Data de {{LABEL}}: {{START_LABEL}} até {{END_LABEL}}",
36
- "labelStartDatePeriod": "Inicial",
37
- "labelEndDatePeriod": "Final",
36
+ "labelStart": "Inicial",
37
+ "labelEnd": "Final",
38
+ "fullIntervalTooltip": "{{LABEL}}: {{START_LABEL}} até {{END_LABEL}}",
38
39
  "filters": "Filtros",
39
40
  "personalizedCount": "{{activeCount}} selecionado(s)",
40
41
  "filterModal": {
@@ -63,11 +63,12 @@ const snkFilterBarMessages = {
63
63
  "modalCancelButtonLabel": "Limpar",
64
64
  "binarySelectTooltip": "Exibindo registros",
65
65
  "multiListToltip": "selecionado(a)s",
66
- "onlyStartPeriodToltip": "A partir de",
67
- "onlyEndPeriodToltip": "Até",
66
+ "onlyStartToltip": "A partir de",
67
+ "onlyEndToltip": "Até",
68
68
  "fullPeriodTooltip": "Data de {{LABEL}}: {{START_LABEL}} até {{END_LABEL}}",
69
- "labelStartDatePeriod": "Inicial",
70
- "labelEndDatePeriod": "Final",
69
+ "labelStart": "Inicial",
70
+ "labelEnd": "Final",
71
+ "fullIntervalTooltip": "{{LABEL}}: {{START_LABEL}} até {{END_LABEL}}",
71
72
  "filters": "Filtros",
72
73
  "personalizedCount": "{{activeCount}} selecionado(s)",
73
74
  "filterModal": {
@@ -0,0 +1,7 @@
1
+ var FilterNumberVariation;
2
+ (function (FilterNumberVariation) {
3
+ FilterNumberVariation["DEFAULT"] = "DEFAULT";
4
+ FilterNumberVariation["INTERVAL"] = "INTERVAL";
5
+ })(FilterNumberVariation || (FilterNumberVariation = {}));
6
+
7
+ export { FilterNumberVariation as F };
@@ -5,6 +5,7 @@ import { C as ConfigStorage } from './ConfigStorage.js';
5
5
  import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
6
6
  import { F as FilterItemType } from './filter-item-type.enum.js';
7
7
  import { a as FilterOperand, P as PersonalizedFilterUtils } from './PersonalizedFilterUtils.js';
8
+ import { F as FilterNumberVariation } from './filterNumberVariation.js';
8
9
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
9
10
  import { d as defineCustomElement$a } from './snk-expression-group2.js';
10
11
  import { d as defineCustomElement$9 } from './snk-expression-item2.js';
@@ -116,6 +117,38 @@ function buildText(item) {
116
117
  }
117
118
  function buildNumber(item) {
118
119
  const { id, value, props } = item;
120
+ const variation = props.variation;
121
+ if (variation === FilterNumberVariation.INTERVAL) {
122
+ const { start, end } = value !== null && value !== void 0 ? value : { start: 0, end: 0 };
123
+ if (start && end) {
124
+ return {
125
+ name: id,
126
+ expression: props.intervalExpression.fullfill,
127
+ params: [
128
+ { name: `${id}.START`, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, start) },
129
+ { name: `${id}.END`, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, end) }
130
+ ]
131
+ };
132
+ }
133
+ if (start) {
134
+ return {
135
+ name: id,
136
+ expression: props.intervalExpression.onlystart,
137
+ params: [
138
+ { name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, start) }
139
+ ]
140
+ };
141
+ }
142
+ if (end) {
143
+ return {
144
+ name: id,
145
+ expression: props.intervalExpression.onlyend,
146
+ params: [
147
+ { name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, end) }
148
+ ]
149
+ };
150
+ }
151
+ }
119
152
  const expression = props.expression;
120
153
  return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
121
154
  }
@@ -272,6 +305,44 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
272
305
  async reload() {
273
306
  this.loadConfigFromStorage();
274
307
  }
308
+ /**
309
+ * Retorna um item de filtro pelo ID.
310
+ */
311
+ async getFilterItem(id) {
312
+ const item = this.filterConfig.find(item => item.id === id);
313
+ return Promise.resolve(ObjectUtils.copy(item));
314
+ }
315
+ /**
316
+ * Atualiza um item do filtro.
317
+ *
318
+ * @param filterItem - Item com as informações atualizadas, caso o item não seja encontrado no array ele mão será modificado
319
+ */
320
+ async updateFilterItem(newFilterItem) {
321
+ const itemIndex = this.filterConfig.findIndex(item => item.id === newFilterItem.id);
322
+ if (itemIndex == -1) {
323
+ console.warn("[SnkFilterBar.updateFilterItem] FilterItem não encontrado, o mesmo não será atualizado.");
324
+ return Promise.resolve();
325
+ }
326
+ this._loadingPending = true;
327
+ this.updateFilter(newFilterItem);
328
+ return Promise.resolve();
329
+ }
330
+ /**
331
+ * Adiciona um item de filtro.
332
+ *
333
+ * @param filterItem - Item a ser adicionado, caso o item já exista com o ID ele não será adicionado novamente
334
+ */
335
+ async addFilterItem(filterItem) {
336
+ const itemIndex = this.filterConfig.findIndex(item => item.id === filterItem.id);
337
+ if (itemIndex > -1) {
338
+ console.warn("[SnkFilterBar.addFilterItem] FilterItem já existe , o mesmo não será adicionado novamente.");
339
+ return Promise.resolve();
340
+ }
341
+ this.filterConfig.push(filterItem);
342
+ this._loadingPending = true;
343
+ this.updateFilter(filterItem);
344
+ return Promise.resolve();
345
+ }
275
346
  componentDidLoad() {
276
347
  if (this._element) {
277
348
  const dataInfo = { dataUnit: this.dataUnit };
@@ -542,7 +613,10 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
542
613
  "scrollerLocked": [32],
543
614
  "showPersonalizedFilter": [32],
544
615
  "personalizedFilterId": [32],
545
- "reload": [64]
616
+ "reload": [64],
617
+ "getFilterItem": [64],
618
+ "updateFilterItem": [64],
619
+ "addFilterItem": [64]
546
620
  }, [[0, "filterChange", "filterChangeListener"]]]);
547
621
  function defineCustomElement() {
548
622
  if (typeof customElements === "undefined") {
@@ -1,6 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { FloatingManager, DateUtils, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { F as FilterItemType } from './filter-item-type.enum.js';
4
+ import { F as FilterNumberVariation } from './filterNumberVariation.js';
4
5
  import { d as defineCustomElement$1 } from './snk-filter-detail2.js';
5
6
 
6
7
  const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -169,10 +170,10 @@ const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
169
170
  }
170
171
  else {
171
172
  if (start) {
172
- return `${label}: ${this.getMessage('snkFilterBar.onlyStartPeriodToltip')} ${dateFormater.format(start)}`;
173
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${dateFormater.format(start)}`;
173
174
  }
174
175
  else if (end) {
175
- return `${label}: ${this.getMessage('snkFilterBar.onlyEndPeriodToltip')} ${dateFormater.format(end)}`;
176
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${dateFormater.format(end)}`;
176
177
  }
177
178
  else {
178
179
  return label;
@@ -203,6 +204,18 @@ const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
203
204
  }
204
205
  return `${label}: ${selectedOptions[0].label}`;
205
206
  }
207
+ if (type === FilterItemType.NUMBER && props.variation === FilterNumberVariation.INTERVAL) {
208
+ const { start, end } = value;
209
+ if (start && end) {
210
+ return this.getMessage('snkFilterBar.fullIntervalTooltip', { LABEL: label, START_LABEL: start, END_LABEL: end });
211
+ }
212
+ if (start) {
213
+ return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${Number(start)}`;
214
+ }
215
+ if (end) {
216
+ return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${Number(end)}`;
217
+ }
218
+ }
206
219
  return `${label}: ${value}`;
207
220
  }
208
221
  return label;
@@ -43,7 +43,7 @@ const SnkFilterModalItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
43
43
  case FilterItemType.SEARCH:
44
44
  return { tag: "snk-filter-search" };
45
45
  case FilterItemType.NUMBER:
46
- return { tag: "snk-filter-number" };
46
+ return { tag: "snk-filter-number", props };
47
47
  case FilterItemType.PERSONALIZED:
48
48
  return this.buildSnkFilterPersonalizedProps();
49
49
  case FilterItemType.MULTI_LIST:
@@ -5,6 +5,7 @@ import { F as FilterType, d as defineCustomElement$2 } from './snk-filter-modal-
5
5
  import { F as FilterItemType } from './filter-item-type.enum.js';
6
6
  import { ObjectUtils } from '@sankhyalabs/core';
7
7
  import { P as PersonalizedFilterUtils } from './PersonalizedFilterUtils.js';
8
+ import { F as FilterNumberVariation } from './filterNumberVariation.js';
8
9
 
9
10
  const snkFilterModalCss = "ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{width:344px;max-width:344px;min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px;overflow-x:clip;overflow-y:auto}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";
10
11
 
@@ -139,6 +140,11 @@ const SnkFilterModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
139
140
  renderFilterItem(filterItem, fullRow) {
140
141
  return (h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event.detail), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
141
142
  }
143
+ isDefaultFilterNumberVariation(filter) {
144
+ var _a;
145
+ return filter.type === FilterItemType.NUMBER
146
+ && (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === FilterNumberVariation.DEFAULT);
147
+ }
142
148
  mountFiltersLines(filters) {
143
149
  const MAX_LINE_LENGTH = 2;
144
150
  let currentLine = 0;
@@ -148,8 +154,8 @@ const SnkFilterModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
148
154
  filtersLines[currentLine] = filtersLines[currentLine] || [];
149
155
  const item = filters[curr];
150
156
  const isLast = curr === filters.length - 1;
151
- const currentItemMatch = [FilterItemType.TEXT, FilterItemType.NUMBER].includes(item.type);
152
- const nextItemMatch = isLast ? false : [FilterItemType.TEXT, FilterItemType.NUMBER].includes(filters[curr + 1].type);
157
+ const currentItemMatch = item.type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
158
+ const nextItemMatch = isLast ? false : filters[curr + 1].type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
153
159
  if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
154
160
  filtersLines[currentLine].push(item);
155
161
  forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;