@sankhyalabs/sankhyablocks 5.6.0 → 5.7.0
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.
- package/dist/cjs/{SnkMessageBuilder-e64dce7f.js → SnkMessageBuilder-056d1c24.js} +9 -1
- package/dist/cjs/{filter-item-type.enum-3daf58d3.js → filter-item-type.enum-aa823a00.js} +1 -0
- package/dist/cjs/filter-type.enum-b14ce507.js +11 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/presentationMode-52ec3bdd.js +7 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-85d6565e.js → snk-data-unit-289081c4.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-bar.cjs.entry.js +52 -140
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +8 -1
- package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-item.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +66 -0
- package/dist/cjs/snk-filter-modal.cjs.entry.js +72 -49
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-number.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-period.cjs.entry.js +11 -2
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-search.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-text.cjs.entry.js +2 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/enum/presentationMode.js +5 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +47 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +19 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +19 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +50 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +19 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +19 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +19 -0
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +1 -0
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.css +31 -2
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +116 -156
- package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.css +4 -0
- package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +115 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +19 -142
- package/dist/collection/components/snk-filter-bar/types/filter-type.enum.js +7 -0
- package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +36 -0
- package/dist/collection/components/snk-filter-bar/utils/filters-mock.js +315 -0
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +9 -1
- package/dist/components/SnkMessageBuilder.js +9 -1
- package/dist/components/filter-item-type.enum.js +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/presentationMode.js +7 -0
- package/dist/components/snk-crud.js +22 -34
- package/dist/components/snk-detail-view2.js +24 -46
- package/dist/components/snk-filter-bar2.js +57 -157
- package/dist/components/snk-filter-binary-select.js +9 -1
- package/dist/components/snk-filter-list.js +171 -1
- package/dist/components/snk-filter-modal-item.d.ts +11 -0
- package/dist/components/snk-filter-modal-item.js +6 -0
- package/dist/components/snk-filter-modal-item2.js +85 -0
- package/dist/components/snk-filter-modal.js +118 -1
- package/dist/components/snk-filter-multi-select.js +3 -1
- package/dist/components/snk-filter-number.js +3 -1
- package/dist/components/snk-filter-period.js +12 -2
- package/dist/components/snk-filter-personalized.js +3 -1
- package/dist/components/snk-filter-search.js +3 -1
- package/dist/components/snk-filter-text.js +3 -1
- package/dist/components/snk-grid2.js +10 -22
- package/dist/esm/{SnkMessageBuilder-f3590f65.js → SnkMessageBuilder-23272e07.js} +9 -1
- package/dist/esm/{filter-item-type.enum-a79b2fa8.js → filter-item-type.enum-5028ed3f.js} +1 -0
- package/dist/esm/filter-type.enum-a80c1b6b.js +9 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/presentationMode-783bbf9d.js +7 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-50b1660c.js → snk-data-unit-34dc5371.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +1 -1
- package/dist/esm/snk-filter-bar.entry.js +53 -141
- package/dist/esm/snk-filter-binary-select.entry.js +9 -2
- package/dist/esm/snk-filter-detail.entry.js +1 -1
- package/dist/esm/snk-filter-item.entry.js +1 -1
- package/dist/esm/snk-filter-modal-item.entry.js +62 -0
- package/dist/esm/snk-filter-modal.entry.js +73 -50
- package/dist/esm/snk-filter-multi-select.entry.js +4 -2
- package/dist/esm/snk-filter-number.entry.js +4 -2
- package/dist/esm/snk-filter-period.entry.js +12 -3
- package/dist/esm/snk-filter-personalized.entry.js +4 -2
- package/dist/esm/snk-filter-search.entry.js +4 -2
- package/dist/esm/snk-filter-text.entry.js +3 -1
- package/dist/sankhyablocks/{p-f344b811.entry.js → p-0110b7da.entry.js} +1 -1
- package/dist/sankhyablocks/p-1a68fb59.js +1 -0
- package/dist/sankhyablocks/{p-3d3263b4.js → p-3db1d3de.js} +1 -1
- package/dist/sankhyablocks/p-45ee8b22.entry.js +1 -0
- package/dist/sankhyablocks/p-4ce96831.entry.js +1 -0
- package/dist/sankhyablocks/{p-9dd2b8cb.js → p-584d7212.js} +1 -1
- package/dist/sankhyablocks/{p-c4417efb.entry.js → p-64b03506.entry.js} +1 -1
- package/dist/sankhyablocks/p-7695c404.entry.js +1 -0
- package/dist/sankhyablocks/p-786ae316.entry.js +1 -0
- package/dist/sankhyablocks/p-82bc97da.entry.js +1 -0
- package/dist/sankhyablocks/p-8efb0f47.entry.js +1 -0
- package/dist/sankhyablocks/p-9af04fc7.entry.js +1 -0
- package/dist/sankhyablocks/{p-3a2ce158.entry.js → p-a1c58536.entry.js} +1 -1
- package/dist/sankhyablocks/{p-afba9bbe.entry.js → p-bdbb2672.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3fbe2d69.entry.js → p-c1ab16d0.entry.js} +2 -2
- package/dist/sankhyablocks/p-d9804798.js +1 -0
- package/dist/sankhyablocks/p-e2bb9c9a.entry.js +1 -0
- package/dist/sankhyablocks/p-ed3d6ab4.entry.js +1 -0
- package/dist/sankhyablocks/p-ee1381f4.entry.js +1 -0
- package/dist/sankhyablocks/p-f5f36fbb.js +1 -0
- package/dist/sankhyablocks/p-ffac37d5.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-filter-bar/filter-item/editors/enum/presentationMode.d.ts +4 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +5 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +2 -1
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +3 -0
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +37 -0
- package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +17 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +2 -11
- package/dist/types/components/snk-filter-bar/types/filter-type.enum.d.ts +6 -0
- package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +20 -0
- package/dist/types/components/snk-filter-bar/utils/filters-mock.d.ts +186 -0
- package/dist/types/components.d.ts +113 -54
- package/package.json +1 -1
- package/react/components.d.ts +1 -0
- package/react/components.js +1 -0
- package/react/components.js.map +1 -1
- package/dist/components/snk-filter-list2.js +0 -173
- package/dist/components/snk-filter-modal2.js +0 -97
- package/dist/sankhyablocks/p-1dcfd32a.entry.js +0 -1
- package/dist/sankhyablocks/p-5e62a17b.entry.js +0 -1
- package/dist/sankhyablocks/p-5fc55684.entry.js +0 -1
- package/dist/sankhyablocks/p-73e830cf.entry.js +0 -1
- package/dist/sankhyablocks/p-86d29b6f.entry.js +0 -1
- package/dist/sankhyablocks/p-ad51bf1c.entry.js +0 -1
- package/dist/sankhyablocks/p-c336170d.entry.js +0 -1
- package/dist/sankhyablocks/p-c9477950.js +0 -1
- package/dist/sankhyablocks/p-d5c9c1f8.entry.js +0 -1
- package/dist/sankhyablocks/p-ee82c157.entry.js +0 -1
- package/dist/sankhyablocks/p-fac37198.entry.js +0 -1
@@ -1,70 +1,93 @@
|
|
1
1
|
import { r as registerInstance, h } from './index-cfd4bb13.js';
|
2
|
-
import { ModalAction
|
3
|
-
import {
|
4
|
-
import {
|
2
|
+
import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
|
3
|
+
import { F as FilterType } from './filter-type.enum-a80c1b6b.js';
|
4
|
+
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
5
5
|
|
6
|
-
const snkFilterModalCss = ".snk-filter__modal-container{width:
|
6
|
+
const snkFilterModalCss = "ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter__modal-container{width:344px;max-width:344px;overflow:hidden}.snk-filter__modal-content{display:flex;flex-direction:column;gap:12px;max-height:760px;overflow-x:clip;overflow-y:auto;padding-right:4px}.snk-filter__modal-content::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}.snk-filter__modal-collapsible-box{border:1px solid #DCE0E8;border-radius:var(--border--radius-medium)}";
|
7
7
|
|
8
8
|
const SnkFilterModal = class {
|
9
9
|
constructor(hostRef) {
|
10
10
|
registerInstance(this, hostRef);
|
11
|
-
this._filterArgument = undefined;
|
12
11
|
this.getMessage = undefined;
|
13
|
-
this.
|
14
|
-
this.
|
15
|
-
this.
|
16
|
-
this.
|
17
|
-
this.okButtonLabel = undefined;
|
18
|
-
this.infoText = undefined;
|
19
|
-
this.useSearch = undefined;
|
20
|
-
this.processModalAction = undefined;
|
12
|
+
this.filters = undefined;
|
13
|
+
this.applyFilters = undefined;
|
14
|
+
this.clearAll = undefined;
|
15
|
+
this.closeModal = undefined;
|
21
16
|
}
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
30
|
-
return item;
|
31
|
-
});
|
17
|
+
getCustomMessage(key, params) {
|
18
|
+
var _a;
|
19
|
+
return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
|
20
|
+
}
|
21
|
+
handleClearAll() {
|
22
|
+
const cleanedFilters = this.clearAll(this.filters);
|
23
|
+
this.filters = cleanedFilters;
|
32
24
|
}
|
33
|
-
|
34
|
-
const
|
35
|
-
|
36
|
-
|
25
|
+
modalActionListener(evt) {
|
26
|
+
const modalAction = evt.detail;
|
27
|
+
switch (modalAction) {
|
28
|
+
case ModalAction.CANCEL:
|
29
|
+
this.handleClearAll();
|
30
|
+
break;
|
31
|
+
case ModalAction.OK:
|
32
|
+
this.applyFilters(this.filters);
|
33
|
+
case ModalAction.CLOSE:
|
34
|
+
this.closeModal();
|
37
35
|
}
|
38
|
-
return this.getMessage(activeFilters > 1 ? "snkFilterBar.activeFilters" : "snkFilterBar.activeFilter", { ACTIVE_FILTERS: activeFilters });
|
39
36
|
}
|
40
|
-
|
41
|
-
|
42
|
-
return (h("button", { onClick: () => this.updateValue(item.id), class: "ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small" }, h("ez-check", { id: `checkbox_${item.id}`, tabIndex: -1, 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: CheckMode.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)));
|
43
|
-
});
|
37
|
+
handleFilterChange(filterConfig) {
|
38
|
+
this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
|
44
39
|
}
|
45
|
-
|
46
|
-
|
47
|
-
this.updateValue(item.id);
|
48
|
-
}
|
40
|
+
handleClearFilters(filterList) {
|
41
|
+
this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
|
49
42
|
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
43
|
+
renderFilterItem(filterItem, fullRow) {
|
44
|
+
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, onFilterChange: (event) => this.handleFilterChange(event.detail) }));
|
45
|
+
}
|
46
|
+
mountFiltersLines(filters) {
|
47
|
+
const MAX_LINE_LENGTH = 2;
|
48
|
+
let currentLine = 0;
|
49
|
+
let forceAddCurrent = false;
|
50
|
+
const filtersLines = {};
|
51
|
+
for (let curr = 0; curr < filters.length; curr++) {
|
52
|
+
filtersLines[currentLine] = filtersLines[currentLine] || [];
|
53
|
+
const item = filters[curr];
|
54
|
+
const isLast = curr === filters.length - 1;
|
55
|
+
const currentItemMatch = [FilterItemType.TEXT, FilterItemType.NUMBER].includes(item.type);
|
56
|
+
const nextItemMatch = isLast ? false : [FilterItemType.TEXT, FilterItemType.NUMBER].includes(filters[curr + 1].type);
|
57
|
+
if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
|
58
|
+
filtersLines[currentLine].push(item);
|
59
|
+
forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
|
60
|
+
if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
|
61
|
+
++currentLine;
|
62
|
+
continue;
|
55
63
|
}
|
64
|
+
filtersLines[currentLine] = filtersLines[currentLine] || [];
|
65
|
+
filtersLines[currentLine].push(item);
|
66
|
+
++currentLine;
|
56
67
|
}
|
57
|
-
|
58
|
-
|
59
|
-
|
68
|
+
return Object.values(filtersLines);
|
69
|
+
}
|
70
|
+
renderFilterLine(filters) {
|
71
|
+
const fullLine = filters.length === 1;
|
72
|
+
return (h("div", { class: "ez-row" }, filters.map((filter) => this.renderFilterItem(filter, fullLine))));
|
73
|
+
}
|
74
|
+
renderCollapsibleFilterBox(label, listItems) {
|
75
|
+
if (!listItems.length)
|
76
|
+
return null;
|
77
|
+
const appliedFilters = listItems.filter(filterItem => !!filterItem.value).length;
|
78
|
+
const lines = this.mountFiltersLines(listItems);
|
79
|
+
return (h("ez-collapsible-box", { className: "snk-filter__modal-collapsible-box ez-padding--medium", headerSize: "medium", value: true, label: label }, !!appliedFilters && (h("ez-badge", { className: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters })), lines.map(this.renderFilterLine.bind(this)), h("div", { class: "ez-flex ez-flex--justify-end grow" }, h("ez-button", { className: "ez-button--tertiary", size: "medium", label: "Limpar", onClick: () => this.handleClearFilters(listItems) }))));
|
80
|
+
}
|
81
|
+
componentWillRender() {
|
82
|
+
this._modalTitle = this.getCustomMessage('title');
|
83
|
+
this._okButtonLabel = this.getCustomMessage('okButtonLabel');
|
84
|
+
this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
|
60
85
|
}
|
61
86
|
render() {
|
62
|
-
const
|
63
|
-
const
|
64
|
-
|
65
|
-
|
66
|
-
:
|
67
|
-
undefined), items.length > 0 ? h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding-bottom--small" }, this.getActiveFiltersMsg()) : undefined, h("div", null, this.buildItems(items)), h("div", { class: "ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large" }, this.infoText))));
|
87
|
+
const customFilters = this.filters.filter(filter => filter.filterType === FilterType.CUSTOM_FILTER);
|
88
|
+
const quickFilters = this.filters.filter(filter => filter.filterType === FilterType.QUICK_FILTER);
|
89
|
+
const otherFilters = this.filters.filter(filter => filter.filterType === FilterType.OTHER_FILTERS);
|
90
|
+
return (h("ez-modal-container", { class: "snk-filter__modal-container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, h("div", { class: "snk-filter__modal-content" }, this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter])))));
|
68
91
|
}
|
69
92
|
};
|
70
93
|
SnkFilterModal.style = snkFilterModalCss;
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import { r as registerInstance, h, g as getElement } from './index-cfd4bb13.js';
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
|
2
2
|
import { ElementIDUtils } from '@sankhyalabs/core';
|
3
|
-
import { F as FilterItemType } from './filter-item-type.enum-
|
3
|
+
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
4
4
|
|
5
5
|
const SnkFilterMultiSelect = class {
|
6
6
|
constructor(hostRef) {
|
7
7
|
registerInstance(this, hostRef);
|
8
|
+
this.valueChanged = createEvent(this, "valueChanged", 7);
|
8
9
|
this.value = undefined;
|
9
10
|
this.config = undefined;
|
10
11
|
}
|
@@ -13,6 +14,7 @@ const SnkFilterMultiSelect = class {
|
|
13
14
|
*/
|
14
15
|
ezChangeListener(evt) {
|
15
16
|
this.value = evt.detail.value;
|
17
|
+
this.valueChanged.emit(this.value);
|
16
18
|
}
|
17
19
|
/**
|
18
20
|
* Exibe o componente snk-filter-multi-select
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import { r as registerInstance, h, g as getElement } from './index-cfd4bb13.js';
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
|
2
2
|
import { ElementIDUtils } from '@sankhyalabs/core';
|
3
|
-
import { F as FilterItemType } from './filter-item-type.enum-
|
3
|
+
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
4
4
|
|
5
5
|
const SnkFilterPeriod = class {
|
6
6
|
constructor(hostRef) {
|
7
7
|
registerInstance(this, hostRef);
|
8
|
+
this.valueChanged = createEvent(this, "valueChanged", 7);
|
8
9
|
this.config = undefined;
|
9
10
|
this.value = undefined;
|
10
11
|
}
|
@@ -13,6 +14,7 @@ const SnkFilterPeriod = class {
|
|
13
14
|
*/
|
14
15
|
ezChangeListener(evt) {
|
15
16
|
this.value = evt.detail;
|
17
|
+
this.valueChanged.emit(this.value);
|
16
18
|
}
|
17
19
|
/**
|
18
20
|
* Exibe o componente snk-filter-number
|
@@ -1,12 +1,15 @@
|
|
1
|
-
import { r as registerInstance, h, g as getElement } from './index-cfd4bb13.js';
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
|
2
2
|
import { ElementIDUtils } from '@sankhyalabs/core';
|
3
|
-
import { F as FilterItemType } from './filter-item-type.enum-
|
3
|
+
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
4
|
+
import { E as EPresentationMode } from './presentationMode-783bbf9d.js';
|
4
5
|
|
5
6
|
const SnkFilterPeriod = class {
|
6
7
|
constructor(hostRef) {
|
7
8
|
registerInstance(this, hostRef);
|
9
|
+
this.valueChanged = createEvent(this, "valueChanged", 7);
|
8
10
|
this.config = undefined;
|
9
11
|
this.value = undefined;
|
12
|
+
this.presentationMode = EPresentationMode.CHIP;
|
10
13
|
}
|
11
14
|
/**
|
12
15
|
* Emitido quando acontece a alteração de valor do componente snk-filter-period
|
@@ -15,6 +18,7 @@ const SnkFilterPeriod = class {
|
|
15
18
|
const start = this._startDate.value;
|
16
19
|
const end = this._endDate.value;
|
17
20
|
this.value = (start || end ? { start, end } : undefined);
|
21
|
+
this.valueChanged.emit(this.value);
|
18
22
|
}
|
19
23
|
componentDidLoad() {
|
20
24
|
if (this._element) {
|
@@ -39,11 +43,16 @@ const SnkFilterPeriod = class {
|
|
39
43
|
async show() {
|
40
44
|
this._startDate.setFocus();
|
41
45
|
}
|
46
|
+
buildLabel() {
|
47
|
+
if (this.presentationMode === EPresentationMode.CHIP) {
|
48
|
+
return h("label", { class: "ez-text ez-text--medium ez-text--primary ez-margin--medium" }, "at\u00E9");
|
49
|
+
}
|
50
|
+
}
|
42
51
|
render() {
|
43
52
|
if (!this.config || this.config.type !== FilterItemType.PERIOD) {
|
44
53
|
return undefined;
|
45
54
|
}
|
46
|
-
return (h("div", { class: "ez-col ez-col--nowrap" }, h("ez-date-input", { id: `${this.config.id}_start`, label: this.config.label, ref: ref => this._startDate = ref, value: this.getDate("start") }),
|
55
|
+
return (h("div", { class: "ez-col ez-col--nowrap" }, h("ez-date-input", { id: `${this.config.id}_start`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding--small' : '', label: this.config.label, ref: ref => this._startDate = ref, value: this.getDate("start") }), this.buildLabel(), h("ez-date-input", { id: `${this.config.id}_end`, class: this.presentationMode === EPresentationMode.MODAL ? 'ez-padding--small' : '', label: this.config.label, ref: ref => this._endDate = ref, value: this.getDate("end") })));
|
47
56
|
}
|
48
57
|
get _element() { return getElement(this); }
|
49
58
|
};
|
@@ -1,12 +1,13 @@
|
|
1
|
-
import { r as registerInstance, h, H as Host, g as getElement } from './index-cfd4bb13.js';
|
1
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-cfd4bb13.js';
|
2
2
|
import { ElementIDUtils, UserInterface, ApplicationContext } from '@sankhyalabs/core';
|
3
3
|
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
4
4
|
import { CheckMode } from '@sankhyalabs/ezui/dist/collection/utils';
|
5
|
-
import { F as FilterItemType } from './filter-item-type.enum-
|
5
|
+
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
6
6
|
|
7
7
|
const SnkFilterPersonalized = class {
|
8
8
|
constructor(hostRef) {
|
9
9
|
registerInstance(this, hostRef);
|
10
|
+
this.valueChanged = createEvent(this, "valueChanged", 7);
|
10
11
|
this.config = undefined;
|
11
12
|
this.value = undefined;
|
12
13
|
this.fix = undefined;
|
@@ -38,6 +39,7 @@ const SnkFilterPersonalized = class {
|
|
38
39
|
if (this.value.filter(item => item != undefined).length == 0) {
|
39
40
|
this.value = null;
|
40
41
|
}
|
42
|
+
this.valueChanged.emit(this.value || []);
|
41
43
|
}
|
42
44
|
doSearch(mode, argument, param) {
|
43
45
|
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import { r as registerInstance, h, g as getElement } from './index-cfd4bb13.js';
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
|
2
2
|
import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
|
-
import { F as FilterItemType } from './filter-item-type.enum-
|
3
|
+
import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
|
4
4
|
|
5
5
|
const SnkFilterSearch = class {
|
6
6
|
constructor(hostRef) {
|
7
7
|
registerInstance(this, hostRef);
|
8
|
+
this.valueChanged = createEvent(this, "valueChanged", 7);
|
8
9
|
this.config = undefined;
|
9
10
|
this.value = undefined;
|
10
11
|
}
|
@@ -13,6 +14,7 @@ const SnkFilterSearch = class {
|
|
13
14
|
*/
|
14
15
|
ezChangeListener(_evt) {
|
15
16
|
this.value = this._searchInput.value;
|
17
|
+
this.valueChanged.emit(this.value);
|
16
18
|
}
|
17
19
|
componentDidLoad() {
|
18
20
|
if (this._element) {
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import { r as registerInstance, h, g as getElement } from './index-cfd4bb13.js';
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
|
2
2
|
import { ElementIDUtils } from '@sankhyalabs/core';
|
3
3
|
|
4
4
|
const SnkFilterText = class {
|
5
5
|
constructor(hostRef) {
|
6
6
|
registerInstance(this, hostRef);
|
7
|
+
this.valueChanged = createEvent(this, "valueChanged", 7);
|
7
8
|
this.config = undefined;
|
8
9
|
this.value = undefined;
|
9
10
|
}
|
@@ -12,6 +13,7 @@ const SnkFilterText = class {
|
|
12
13
|
*/
|
13
14
|
ezChangeListener(evt) {
|
14
15
|
this.value = evt.detail;
|
16
|
+
this.valueChanged.emit(this.value);
|
15
17
|
}
|
16
18
|
componentDidLoad() {
|
17
19
|
if (this._element) {
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as i,f as s,h as e,H as a}from"./p-b9667fbe.js";import{S as o}from"./p-e0aa5838.js";import{FormMetadata as h,buildFormMetadata as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-41d92871.js";import"./p-11028eba.js";import"@sankhyalabs/core";import{P as n}from"./p-4c2015a9.js";import{T as d}from"./p-d410f45a.js";import{c as l}from"./p-17375123.js";import{S as c}from"./p-ccd26e3a.js";import{S as u}from"./p-
|
1
|
+
import{r as t,c as i,f as s,h as e,H as a}from"./p-b9667fbe.js";import{S as o}from"./p-e0aa5838.js";import{FormMetadata as h,buildFormMetadata as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-41d92871.js";import"./p-11028eba.js";import"@sankhyalabs/core";import{P as n}from"./p-4c2015a9.js";import{T as d}from"./p-d410f45a.js";import{c as l}from"./p-17375123.js";import{S as c}from"./p-ccd26e3a.js";import{S as u}from"./p-f5f36fbb.js";import"./p-52ed2a18.js";import"./p-0d81236c.js";import"./p-112455b1.js";import"./p-6a02e236.js";import"./p-c2beb95c.js";class m{constructor(t,i,s){this._parentGuide=t,this._formMetadata=i,this._dataUnit=s}get id(){return this._parentGuide.id}buildGuideItem(t){const i=Object.assign({},this._parentGuide);delete i.expanded,delete i.children;const s=this._dataUnit.getSelectedRecord();if(!s)return i;const e=this._dataUnit.isNewRecord(s.__record__id__),a=Array.from(this._formMetadata.getAllSheets().values()).map((i=>{const{name:s,label:a}=i,o=null!=h.getDetailName(s.split("::").pop()),r=o&&e,n=this._parentGuide.id,d=o?`${n}::${s}`:`${n}__FORM:${s}`;return o&&t.has(d)&&!r?t.get(d).buildGuideItem(t):{id:d,label:a,disabled:r,tooltip:r?"Finalize o cadastro para ter acesso a esta guia.":void 0}})),o=a.shift();return o.label=e?"Novo Registro":s.__record__label__,o.children=a,i.children=[o],i}}const p=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this._disabledButtons=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.branchGuide=void 0}observerDataState(t,i){const s=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),e=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((s||e)&&this.loadMetadata(),null==this._formMetadata)return;const a=null==t?void 0:t.selectedRecord,o=null==i?void 0:i.selectedRecord;(null==a?void 0:a.__record__id__)!==(null==o?void 0:o.__record__id__)&&this.snkDetailGuidesChange.emit(new m(this.branchGuide,this._formMetadata,this.dataUnit)),s&&setTimeout((()=>{this.changeViewMode(l.FORM)}),0),e&&this.changeViewMode(l.GRID);const h=[];this.dataState.hasPrevious||h.push(d.PREVIOUS),this.dataState.hasNext||h.push(d.NEXT),this._disabledButtons=h}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}onContentCardChanged(t){c.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0}else this.label="",this._levelPath=void 0}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this.branchGuide.id)}__FORM:${t}`}stripFormPattern(t){return t.replace(p.REGEX_FORM_ID,"")}loadMetadata(){var t;if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const i=this.formConfigManager.getConfig(null===(t=this.dataState)||void 0===t?void 0:t.insertionMode,this.dataUnit);this._formMetadata=r(null==i||0===i.fields.length?void 0:i,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){t.show(this.selectedForm?1:0)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){const i=t===l.GRID?this.stripFormPattern(this.branchGuide.id):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}executeActionHandler(t){t.detail===d.GRID_MODE&&(this.emitSwitchEvent(l.GRID),t.stopPropagation()),t.detail===d.FORM_MODE&&(this.emitSwitchEvent(l.FORM),t.stopPropagation())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new o(this._configName,(()=>this.loadMetadata())),this.formConfigManager.loadConfig(),null==this.messagesBuilder&&(this.messagesBuilder=new u(this.entityName))}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:t=>this.dataState=t.detail,messagesBuilder:this.messagesBuilder},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-flex ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full ez-size-height--full",ref:t=>this._snkGrid=t,configName:this._configName,messagesBuilder:this.messagesBuilder,onGridDoubleClick:()=>this.emitSwitchEvent(l.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:n.SECONDARY,isDetail:!0}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),label:this.label,levelPath:this._levelPath},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,messagesBuilder:this.messagesBuilder,disabledButtons:this._disabledButtons,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:n.SECONDARY,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit}))))))}static get watchers(){return{dataState:["observerDataState"]}}};p.REGEX_FORM_ID=/__FORM:[^:]+/g,p.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px}.detail-header.sc-snk-detail-view{padding-bottom:0}";export{p as snk_detail_view}
|
@@ -0,0 +1 @@
|
|
1
|
+
var a;!function(a){a[a.CHIP=0]="CHIP",a[a.MODAL=1]="MODAL"}(a||(a={}));export{a as E}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as i,h as s,g as e,H as n}from"./p-b9667fbe.js";import{Action as a,ObjectUtils as o,JSUtils as h,ApplicationContext as r,DataType as l}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as v,S as u}from"./p-
|
1
|
+
import{r as t,c as i,h as s,g as e,H as n}from"./p-b9667fbe.js";import{Action as a,ObjectUtils as o,JSUtils as h,ApplicationContext as r,DataType as l}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as v,S as u}from"./p-f5f36fbb.js";const f=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._dataUnitObserver=t=>{var i,s;const e=this.buildDataState();if(this.dataState=e,t.type===a.DATA_SAVED){const i=this.getMessage("snkDataUnit.saveInfo",t.payload.records[0]);null!=i&&this.showSuccessMessage(i)}if(t.type!==a.RECORDS_ADDED&&t.type!==a.RECORDS_COPIED||this.insertionMode.emit(),t.type===a.EDITION_CANCELED&&this.cancelEdition.emit(),t.type===a.RECORDS_REMOVED){const e=t.payload.cachedRecords;let n;n=(null==e?void 0:e.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:e.length}):this.getMessage("snkDataUnit.removeInfo",t.payload.cachedRecords[0]),null!=n&&this.showSuccessMessage(n);const a=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,o=this.dataUnit.getPaginationInfo();o&&this.dataUnit.gotoPage(a>0||o.hasMore?o.currentPage:0)}this.messagesBuilder.currentOperation=this.getMessageOperation()},this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0,this.useCancelConfirm=!0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){o.objectToString(i)!=o.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){var t;const i=null===(t=this.dataUnit)||void 0===t?void 0:t.getSelectionInfo();if(null==i?void 0:i.isAllRecords())return[];const s=[],e=null==i?void 0:i.records;return(null==e?void 0:e.length)>0&&e.forEach((({__record__id__:t})=>{if(!this.dataUnit.isNewRecord(t)){if(!h.isBase64(t))return void s.push({name:"__record__id__",type:l.TEXT,value:t});const i=JSON.parse(window.atob(t));Object.entries(i).forEach((([t,i])=>{var e;const n=null===(e=this.dataUnit)||void 0===e?void 0:e.getField(t);null!=n&&s.push(Object.assign({name:t,type:n.dataType},i))}))}})),s}async interceptAction(t){return new Promise((i=>{var s,e;switch(t.type){case a.RECORDS_ADDED:this.isAllowed("INSERT")?i(t):d.info(this.getMessage("snkDataUnit.forbiddenInsert"));break;case a.RECORDS_COPIED:this.isAllowed("CLONE")?i(t):d.info(this.getMessage("snkDataUnit.forbiddenClone"));break;case a.DATA_CHANGED:case a.CHANGING_DATA:if(this.isAllowed("UPDATE"))return i(t);if(this._openedAlert)return this.dataUnit.cancelEdition();this._openedAlert=!0,this.dataUnit.cancelEdition(),d.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")).then((()=>{this._openedAlert=!1}));break;case a.SAVING_DATA:if(this.beforeSave){const s=this.beforeSave(this.dataUnit);s instanceof Promise?s.then((s=>i(s?t:void 0))):i(s?t:void 0)}else i(t);break;case a.DATA_SAVED:this.afterSave?this.afterSave(this.dataUnit):i(t);break;case a.EDITION_CANCELED:if(!this.useCancelConfirm)return i(t);if(this.dataState.hasDirtyRecords){const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null===(s=t.payload)||void 0===s?void 0:s.fromParent)return void i(t);if(null==e)this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),i(t);else{const s=this.getMessage("snkDataUnit.cancelConfirmationTitle");d.confirm(s,e).then((s=>{s&&this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),i(s?t:void 0)}))}}else i(t);break;case a.REMOVING_RECORDS:if(this.isAllowed("REMOVE")){let s=!1,n=this.getMessage("snkDataUnit.removeConfirmation");const a=null===(e=this.dataUnit)||void 0===e?void 0:e.getSelectionInfo();if((null==a?void 0:a.length)>1&&(n=this.getMessage("snkDataUnit.removeAllConfirmation",{size:a.length}),s=!0),null==n)i(t);else{const e={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(s?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(s?"yes":"delete")),btnConfirmDanger:!1},a=this.getMessage("snkDataUnit.removeConfirmationTitle");d.confirm(a,n,null,c.WARN,e).then((s=>i(s?t:void 0)))}}else d.info(this.getMessage("snkDataUnit.forbiddenRemove"));break;default:i(t)}}))}showSuccessMessage(t){d.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}buildDataState(){const t=this.dataUnit.getSelectionInfo(),i=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==t?void 0:t.isEmpty());return new m({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:i,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:t,selectedRecord:this.dataUnit.getSelectedRecord()})}getMessage(t,i){return i||(i=this.getMessageParams()),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?v.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?v.INSERT:this.dataState.isDirty?v.UPDATE:v.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit)):await this._application.getDataUnit(this.entityName,i)}async loadDataUnit(){if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){let t;for(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this._dataUnitObserver),this.dataState=this.buildDataState();t=this._onDataUnitResolve.pop();)t(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i;const s=Object.assign({},this.dataUnit.metadata);if(!this._parentDataUnit)return;const e=this._parentDataUnit.getChildInfo(this.entityName);if(!e)return;const n=null===(t=null==e?void 0:e.links)||void 0===t?void 0:t.map((t=>t.target));null===(i=null==s?void 0:s.fields)||void 0===i||i.forEach((t=>{(null==n?void 0:n.includes(t.name))&&(t.visible=!1)})),this.dataUnit.metadata=s}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess().then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),null==this.messagesBuilder&&(this.messagesBuilder=new u(this.entityName))}disconnectedCallback(){this.dataUnit&&(this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.removeInterceptor(this))}componentDidLoad(){this.loadDataUnit()}render(){return s(n,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class m{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord}get selectedRecords(){var t;if(console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`."),null===(t=this.selectionInfo)||void 0===t?void 0:t.isAllRecords())throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");return this.selectionInfo.records}}f.style=".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%;width:100%}";export{f as S}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as s,h as e,g as i}from"./p-b9667fbe.js";import{ElementIDUtils as a}from"@sankhyalabs/core";import{F as r}from"./p-584d7212.js";import{E as n}from"./p-1a68fb59.js";const h=class{constructor(e){t(this,e),this.valueChanged=s(this,"valueChanged",7),this.config=void 0,this.value=void 0,this.presentationMode=n.CHIP}ezChangeListener(){const t=this._startDate.value,s=this._endDate.value;this.value=t||s?{start:t,end:s}:void 0,this.valueChanged.emit(this.value)}componentDidLoad(){this._element&&a.addIDInfo(this._element,"filterContentEditor")}getDate(t){const s=this.value?this.value[t]:null;if(s instanceof Date)return s;if("string"==typeof s){let t=new Date(s);return t.setMinutes(t.getMinutes()+t.getTimezoneOffset()),t}return null}async show(){this._startDate.setFocus()}buildLabel(){if(this.presentationMode===n.CHIP)return e("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin--medium"},"até")}render(){if(this.config&&this.config.type===r.PERIOD)return e("div",{class:"ez-col ez-col--nowrap"},e("ez-date-input",{id:`${this.config.id}_start`,class:this.presentationMode===n.MODAL?"ez-padding--small":"",label:this.config.label,ref:t=>this._startDate=t,value:this.getDate("start")}),this.buildLabel(),e("ez-date-input",{id:`${this.config.id}_end`,class:this.presentationMode===n.MODAL?"ez-padding--small":"",label:this.config.label,ref:t=>this._endDate=t,value:this.getDate("end")}))}get _element(){return i(this)}};export{h as snk_filter_period}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as s,c as t,h as i,g as e}from"./p-b9667fbe.js";import{ElementIDUtils as r,ApplicationContext as h}from"@sankhyalabs/core";import{F as o}from"./p-584d7212.js";const n=class{constructor(i){s(this,i),this.valueChanged=t(this,"valueChanged",7),this.config=void 0,this.value=void 0}ezChangeListener(s){this.value=this._searchInput.value,this.valueChanged.emit(this.value)}componentDidLoad(){this._element&&r.addIDInfo(this._element,"filterContentEditor")}doSearch(s,t){const i=h.getContextValue("__SNK__APPLICATION__");return new Promise(((e,r)=>{i.executePreparedSearch(s,t,this.config.props.searchContext).then((s=>{e(s)})).catch((s=>{r(s)}))}))}async show(){this._searchInput.setFocus()}render(){if(this.config&&this.config.type===o.SEARCH)return i("ez-search",{id:this.config.id,suppressEmptyOption:!0,value:this.config.value,label:this.config.label,ref:s=>this._searchInput=s,optionLoader:({mode:s,argument:t})=>this.doSearch(s,t)})}get _element(){return e(this)}};export{n as snk_filter_search}
|
@@ -1 +1 @@
|
|
1
|
-
var E;!function(E){E.MULTI_SELECT="MULTI_SELECT",E.BINARY_SELECT="BINARY_SELECT",E.PERIOD="PERIOD",E.SEARCH="SEARCH",E.TEXT="TEXT",E.NUMBER="NUMBER",E.DEFAULT_FILTER="DEFAULT_FILTER",E.PERSONALIZED="PERSONALIZED"}(E||(E={}));const T=E;export{T as F}
|
1
|
+
var E;!function(E){E.MULTI_SELECT="MULTI_SELECT",E.BINARY_SELECT="BINARY_SELECT",E.PERIOD="PERIOD",E.SEARCH="SEARCH",E.TEXT="TEXT",E.NUMBER="NUMBER",E.DEFAULT_FILTER="DEFAULT_FILTER",E.PERSONALIZED="PERSONALIZED",E.MULTI_LIST="MULTI_LIST"}(E||(E={}));const T=E;export{T as F}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,h as e,H as i,g as s}from"./p-b9667fbe.js";import{ObjectUtils as o,ApplicationContext as r,ElementIDUtils as n}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as a}from"@sankhyalabs/ezui/dist/collection/utils";import{D as d,a as h,b as c}from"./p-4c2015a9.js";import{d as p,W as u,R as m}from"./p-17375123.js";import{D as v}from"./p-41d92871.js";import{S as x}from"./p-3d3263b4.js";import"./p-112455b1.js";import"./p-c9477950.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===d.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===d.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS];if(t===d.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===d.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===d.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===d.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===d.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportByEmail(t,e){t===d.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:d.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:d.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`,group:t}}getCurrentPage(){return{id:d.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:d.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:d.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:d.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function E(t){var{methodName:e}=t,i=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(t,["methodName"]);const s=`mgefin-bff@DataExporterSPBean.${e}`,r={serviceName:s,requestBody:i};return new Promise(((t,e)=>{v.get().callServiceBroker(s,o.objectToString(r)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return o.stringToObject(i)}(e)))).catch((t=>e(t)))}))}const b=5e3,k=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._items=[],this._showDropdown=!1,this._releasedToExport=[d.EXPORT_TO_PDF,d.EXPORT_TO_XLS,d.EXPORT_BY_EMAIL,d.EXPORT_PDF_TO_EMAIL,d.EXPORT_XLS_TO_EMAIL,d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS],this.provider=null,this.messagesBuilder=void 0}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=h[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:h.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,titleGrid:this._appLabel},(()=>{this._snkEmailSender.close(),l.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=x.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}resolveExporter(t,e){if(null==this.provider||null==t||null==e)return;const i=this.provider.getFilters(),s=this.provider.getColumnsMetadata(),o=this.provider.getOrders(),r=this.provider.getResourceURI(),n=this.provider.getSelectedIDs(),a=t.exportOption,h=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS];delete t.exportOption;let c=Object.assign({filters:i,columns:s,sort:o,resourceURI:r,selectedIDs:n.slice(0,b)},t);if(h.includes(a)||"page"==t.type){const t=this.provider.getOffset(),e=this.provider.getLimit();c=Object.assign(Object.assign({},c),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(c=Object.assign(Object.assign({},c),{offset:0,limit:b,selectedIDs:[]}));E(c).then((t=>e(t))).catch((t=>l.error(this.getMessage("snkDataExporter.message.exportError"),t?t.statusMessage:this.getMessage("snkDataExporter.message.exportError"))))}getOptionKey(t){return Object.keys(d).find((e=>d[e]===t))}dispatchExporter(t){var e;const i=this.getOptionKey(t),s=null!==(e=c[i])&&void 0!==e?e:c.EXPORT_TO_PDF,o=c[i]===c.EXPORT_TO_XLS;this.resolveExporter({methodName:d[`EXPORT_TO_${s}`],fileName:this._appLabel,titleGrid:this._appLabel,exportOption:t,limit:b},(t=>{!function({fileSessionKey:t,canPrint:e,canExport:i,useAppPrint:s,isDownload:o}){const n=r.getContextValue("__SNK__APPLICATION__");if(s&&!o)return function(t,e,i,s){null==s||s.webConnection(p,u.methods.PDF_VIEWER,{chaveArquivo:t,permiteImprimir:e?"S":"N",permiteExportar:i?"S":"N",contentType:"S"})}(t,e,i,n);window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${o?"&download=S":""}`),l.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(n),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:s,isDownload:o}))}))}async processExporter(t){var e,i,s,o;const r=null==t?void 0:t.detail,n=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS],h=null===(e=null==r?void 0:r.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==r?void 0:r.id)===d.EXPORT_CURRENT_PAGE)return;const c=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),p=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),u=null===(o=this.provider)||void 0===o?void 0:o.getLimit();let m=!1;if(n.includes(null==r?void 0:r.id)&&u<=b||h?m=!1:(null==c?void 0:c.length)?m=c.length>b:p>b&&(m=!0),m){const t=b.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await l.confirm(e.title,e.description,null,a.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(h)return this.openPersonalizedReports(r.id),void(this._showDropdown=!1);this._releasedToExport.includes(null==r?void 0:r.id)&&(r.id===d.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(r.id),this._showDropdown=!1)}loadItems(){const t=[];this._releasedToExport.forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e;const i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID();if(null==i)return void(this._items=t);const s=await function(t){const e="mgefin-bff@DataExporterSPBean.getPersonalizedReports",i={serviceName:e,requestBody:t};return new Promise(((t,s)=>v.get().callServiceBroker(e,o.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return o.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:i});null==s||s.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e;const i=[],s=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(e=this.provider)||void 0===e||e.getSelectedIDs().forEach((({name:t,type:e,value:s},o)=>{const r=[];r.fields=[],0===o&&(i[`PK_${t}`]={type:e,value:s},i.pks=[]),r.fields.push({nome:t,tipo:e,valor:s}),i.pks.push(r)})),this._application.openApp(`${m}${s}`,i)}loadDropdown(){var t,e;this._selectedNumber=(null===(e=null===(t=this.provider)||void 0===t?void 0:t.getSelectedIDs())||void 0===e?void 0:e.length)||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[n.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:n.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=r.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(n.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" snk-data-exporter--overlap":""}\n `},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",size:"small",mode:"icon",title:this.getMessage("snkDataExporter.group.export.title"),onClick:()=>this.controlDropdown()},this.getElementID("button"))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};k.style=".sc-snk-data-exporter-h{--snk-data-exporter--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter--overlap.sc-snk-data-exporter{z-index:var(--snk-data-exporter--z-index)}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{k as snk_data_exporter}
|
1
|
+
import{r as t,h as e,H as i,g as s}from"./p-b9667fbe.js";import{ObjectUtils as o,ApplicationContext as r,ElementIDUtils as n}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as a}from"@sankhyalabs/ezui/dist/collection/utils";import{D as d,a as h,b as c}from"./p-4c2015a9.js";import{d as p,W as u,R as m}from"./p-17375123.js";import{D as v}from"./p-41d92871.js";import{S as x}from"./p-3db1d3de.js";import"./p-112455b1.js";import"./p-f5f36fbb.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===d.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===d.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS];if(t===d.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===d.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===d.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===d.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===d.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportByEmail(t,e){t===d.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:d.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:d.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`,group:t}}getCurrentPage(){return{id:d.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:d.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:d.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:d.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function b(t){var{methodName:e}=t,i=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(t,["methodName"]);const s=`mgefin-bff@DataExporterSPBean.${e}`,r={serviceName:s,requestBody:i};return new Promise(((t,e)=>{v.get().callServiceBroker(s,o.objectToString(r)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return o.stringToObject(i)}(e)))).catch((t=>e(t)))}))}const E=5e3,k=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._items=[],this._showDropdown=!1,this._releasedToExport=[d.EXPORT_TO_PDF,d.EXPORT_TO_XLS,d.EXPORT_BY_EMAIL,d.EXPORT_PDF_TO_EMAIL,d.EXPORT_XLS_TO_EMAIL,d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS],this.provider=null,this.messagesBuilder=void 0}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=h[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:h.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,titleGrid:this._appLabel},(()=>{this._snkEmailSender.close(),l.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=x.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}resolveExporter(t,e){if(null==this.provider||null==t||null==e)return;const i=this.provider.getFilters(),s=this.provider.getColumnsMetadata(),o=this.provider.getOrders(),r=this.provider.getResourceURI(),n=this.provider.getSelectedIDs(),a=t.exportOption,h=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS];delete t.exportOption;let c=Object.assign({filters:i,columns:s,sort:o,resourceURI:r,selectedIDs:n.slice(0,E)},t);if(h.includes(a)||"page"==t.type){const t=this.provider.getOffset(),e=this.provider.getLimit();c=Object.assign(Object.assign({},c),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(c=Object.assign(Object.assign({},c),{offset:0,limit:E,selectedIDs:[]}));b(c).then((t=>e(t))).catch((t=>l.error(this.getMessage("snkDataExporter.message.exportError"),t?t.statusMessage:this.getMessage("snkDataExporter.message.exportError"))))}getOptionKey(t){return Object.keys(d).find((e=>d[e]===t))}dispatchExporter(t){var e;const i=this.getOptionKey(t),s=null!==(e=c[i])&&void 0!==e?e:c.EXPORT_TO_PDF,o=c[i]===c.EXPORT_TO_XLS;this.resolveExporter({methodName:d[`EXPORT_TO_${s}`],fileName:this._appLabel,titleGrid:this._appLabel,exportOption:t,limit:E},(t=>{!function({fileSessionKey:t,canPrint:e,canExport:i,useAppPrint:s,isDownload:o}){const n=r.getContextValue("__SNK__APPLICATION__");if(s&&!o)return function(t,e,i,s){null==s||s.webConnection(p,u.methods.PDF_VIEWER,{chaveArquivo:t,permiteImprimir:e?"S":"N",permiteExportar:i?"S":"N",contentType:"S"})}(t,e,i,n);window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${o?"&download=S":""}`),l.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(n),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:s,isDownload:o}))}))}async processExporter(t){var e,i,s,o;const r=null==t?void 0:t.detail,n=[d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS],h=null===(e=null==r?void 0:r.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==r?void 0:r.id)===d.EXPORT_CURRENT_PAGE)return;const c=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),p=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),u=null===(o=this.provider)||void 0===o?void 0:o.getLimit();let m=!1;if(n.includes(null==r?void 0:r.id)&&u<=E||h?m=!1:(null==c?void 0:c.length)?m=c.length>E:p>E&&(m=!0),m){const t=E.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await l.confirm(e.title,e.description,null,a.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(h)return this.openPersonalizedReports(r.id),void(this._showDropdown=!1);this._releasedToExport.includes(null==r?void 0:r.id)&&(r.id===d.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(r.id),this._showDropdown=!1)}loadItems(){const t=[];this._releasedToExport.forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e;const i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID();if(null==i)return void(this._items=t);const s=await function(t){const e="mgefin-bff@DataExporterSPBean.getPersonalizedReports",i={serviceName:e,requestBody:t};return new Promise(((t,s)=>v.get().callServiceBroker(e,o.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return o.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:i});null==s||s.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e;const i=[],s=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(e=this.provider)||void 0===e||e.getSelectedIDs().forEach((({name:t,type:e,value:s},o)=>{const r=[];r.fields=[],0===o&&(i[`PK_${t}`]={type:e,value:s},i.pks=[]),r.fields.push({nome:t,tipo:e,valor:s}),i.pks.push(r)})),this._application.openApp(`${m}${s}`,i)}loadDropdown(){var t,e;this._selectedNumber=(null===(e=null===(t=this.provider)||void 0===t?void 0:t.getSelectedIDs())||void 0===e?void 0:e.length)||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[n.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:n.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=r.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(n.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" snk-data-exporter--overlap":""}\n `},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",size:"small",mode:"icon",title:this.getMessage("snkDataExporter.group.export.title"),onClick:()=>this.controlDropdown()},this.getElementID("button"))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};k.style=".sc-snk-data-exporter-h{--snk-data-exporter--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter--overlap.sc-snk-data-exporter{z-index:var(--snk-data-exporter--z-index)}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{k as snk_data_exporter}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,h as e,H as i,g as r}from"./p-b9667fbe.js";import{DataType as s,ObjectUtils as a,ElementIDUtils as n,ErrorException as o,ApplicationContext as l}from"@sankhyalabs/core";import{EzScrollDirection as d}from"@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection";import{C as c}from"./p-52ed2a18.js";import{toString as h}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{F as f}from"./p-584d7212.js";import{ApplicationUtils as u}from"@sankhyalabs/ezui/dist/collection/utils";import"./p-0d81236c.js";import"./p-41d92871.js";import"./p-112455b1.js";class m{constructor({filterConfig:t,onComplete:e,getMessage:i}){this._filterConfig=t,this._onComplete=e,this._getMessage=i}applyFilters(t){this._onComplete(t),this._closeModal()}clearAll(t){return t.map((t=>Object.assign(Object.assign({},t),{value:void 0})))}buildFilterModal(){const t=document.createElement("snk-filter-modal");return t.filters=this._filterConfig,t.getMessage=this._getMessage.bind(this),t.applyFilters=this.applyFilters.bind(this),t.clearAll=this.clearAll.bind(this),t.closeModal=()=>this._closeModal(),t}async showModal(){const t={content:this.buildFilterModal(),position:"left",heightMode:"full",closeOutsideClick:!1,useScrimLight:!0};this._closeModal=await u.showModal(t)}}const p=class{constructor(e){t(this,e),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._pendingFilters=[],this._calculateSortIndex=t=>{let e=t.hardFixed?1e6:0;return t.hardFixed||(e+=t.fixed?1e5:0,e+=null==t.value?0:1e4,e+=this._updateSequence.lastIndexOf(t.id)+1),e},this._filtersComparator=(t,e)=>this._calculateSortIndex(e)-this._calculateSortIndex(t),this.dataUnit=void 0,this.configName=void 0,this.filterConfig=void 0,this.messagesBuilder=void 0,this.allowDefault=void 0,this.scrollerLocked=!1}observeFilterConfig(t,e){if(null!=e&&null==t)this._loadingPending=!0,this._configUpdated=!0;else{const i=new Map(e?e.map((t=>[t.id,t])):void 0);t.forEach((t=>{const e=i.get(t.id);null!=e?(this._configUpdated=this._configUpdated||a.objectToString(e)!=a.objectToString(t),this._loadingPending=this._loadingPending||a.objectToString(e.value)!==a.objectToString(t.value)):(this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value)}))}this.processAfterUpdateConfig()}componentDidLoad(){this._element&&n.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}processPendingFilter(){this._pendingFilters.length>0&&null==this._currentPendingFilter&&(this._currentPendingFilter=this._element.querySelector("#filter-"+this._pendingFilters.pop()),this._currentPendingFilter&&this._currentPendingFilter.showUp(!0).then((()=>{this._currentPendingFilter=void 0,this.processPendingFilter()}))),null==this._currentPendingFilter&&this.processAfterUpdateConfig()}processAfterUpdateConfig(){this._pendingFilters.length>0||(this._loadingPending&&(this._loadingPending=!1,this.dataUnit.loadData()),this._configUpdated&&(this._configUpdated=!1,c.saveFilterBarConfig(this.filterConfig,this.configName)))}getMessage(t,e,i){var r;return(null===(r=this.messagesBuilder)||void 0===r?void 0:r.getMessage(t,e))||i}getFilter(t){var e;const i=[];return null===(e=this.filterConfig)||void 0===e||e.filter((t=>this.isActiveFilter(t))).forEach((t=>{const e=(t=>{switch(t.type){case f.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case f.BINARY_SELECT:return function(t){const{id:e,value:i,props:r}=t;return{name:e,expression:r.options.find((t=>t.name===i)).expression,params:[]}}(t);case f.MULTI_SELECT:return function(t){const{id:e,value:i,props:r}=t;return{name:e,expression:r.expression,params:[{name:e,dataType:s.TEXT,value:i}]}}(t);case f.PERIOD:return function(t){const{id:e,value:i,props:r}=t;let{end:a,start:n}=i;"string"==typeof a&&(a=new Date(a)),"string"==typeof n&&(n=new Date(n));const o=[];let l;return a&&n?(l=r.expression.fullfill,o.push({name:`${e}.START`,dataType:s.DATE,value:h(s.DATE,n)},{name:`${e}.END`,dataType:s.DATE,value:h(s.DATE,a)})):n?(l=r.expression.onlystart,o.push({name:e,dataType:s.DATE,value:h(s.DATE,n)})):(l=r.expression.onlyend,o.push({name:e,dataType:s.DATE,value:h(s.DATE,a)})),{name:e,expression:l,params:o}}(t);case f.SEARCH:return function(t){const{id:e,value:i,props:r}=t;return{name:e,expression:r.expression,params:[{name:e,dataType:s.TEXT,value:h(s.TEXT,i.value)}]}}(t);case f.TEXT:return function(t){const{id:e,value:i,props:r}=t;return{name:e,expression:r.expression,params:[{name:e,dataType:s.TEXT,value:h(s.TEXT,i)}]}}(t);case f.NUMBER:return function(t){const{id:e,value:i,props:r}=t;return{name:e,expression:r.expression,params:[{name:e,dataType:s.NUMBER,value:h(s.NUMBER,i)}]}}(t);case f.PERSONALIZED:return function(t){var e;const{id:i,value:r,props:a}=t;return{name:i,expression:a.expression,params:((null===(e=a.personalizedFilter)||void 0===e?void 0:e.parameters)||[]).map(((t,e)=>{const i=Array.from(r),a=t.dataType;let n=e>=0&&e<i.length?i[e]:null;return null!=n&&"object"==typeof n&&"value"in n&&(n=n.value),null==n&&a===s.BOOLEAN&&(n=!1),{name:t.name,dataType:a,value:"string"==typeof n?n:h(a,n)}}))}}(t);default:return}})(t);e&&i.push(e)})),i}isActiveFilter(t){return t.visible&&null!=t.value||t.type===f.DEFAULT_FILTER}registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&this.dataUnit.loadData()}itemFocused(t){this._element.querySelectorAll("snk-filter-item,snk-filter-list").forEach((e=>{e.id===t?"snk-filter-item"===e.tagName.toLowerCase()&&e.getClientRects()[0].x<0&&e.scrollIntoView({behavior:"auto",inline:"nearest"}):e.hideDetail()}))}getFilterItems(){const t=[],i=[];this.filterConfig.filter((t=>t.visible)).forEach(((r,s)=>{const a=`filter-${r.id}`,n=e("snk-filter-item",{onVisibleChanged:t=>this.scrollerLocked=t.detail,onFocusin:()=>this.itemFocused(a),id:a,config:r,class:s>0?"ez-padding-left--medium":"",getMessage:(t,e)=>this.getMessage(t,e),key:r.id});return r.fixed||r.hardFixed?t.push(n):i.push(n),n}));const r=[];return r.push(...t),t.length>0&&i.length>0&&r.push(e("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider"})),r.push(...i),r}calculateUpdateSequence(t){t&&(this._updateSequence=this._updateSequence.filter((e=>t.id!==e)),this._updateSequence.push(t.id))}normalizeItem(t){const e=Object.assign({},t);return["props","value","hardFixed","fixed"].forEach((t=>{null==e[t]&&delete e[t]})),""===t.value&&delete t.value,e}updateFilter(t){this.filterConfig=this.filterConfig.map((e=>(t=this.normalizeItem(t),e.id===t.id?(a.objectToString(e)!=a.objectToString(t)&&this.calculateUpdateSequence(t),t):e))).sort(((t,e)=>this._filtersComparator(t,e)))}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}loadConfigFromStorage(){c.get().then((t=>{t.loadFilterBarConfig(this.configName).then((t=>{this.filterConfig=t.map((t=>this.normalizeItem(t))),this.dataUnit&&this.dataUnit.loadData(void 0,void 0,!0)})).catch((t=>{throw new o(this.getMessage("snkFilterBar.failToLoadConfig"),t)}))}))}attachDataUnit(){if(null==this.dataUnit){let t=this._element.parentElement;for(;t;)if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){const e=t;this.dataUnit=e.dataUnit,this.dataUnit?this.registryFilterProvider():e.addEventListener("dataUnitReady",(t=>{this.dataUnit=t.detail,this.registryFilterProvider()}));break}t=t.parentElement}else this.registryFilterProvider()}filterChangeListener(t){this.updateFilter(t.detail)}async showFilterModal(){const t=new m({filterConfig:this.filterConfig,onComplete:t=>{this.filterConfig=t.map(this.normalizeItem)},getMessage:(t,e)=>this.getMessage(t,e)});await t.showModal()}componentWillLoad(){this._application=l.getContextValue("__SNK__APPLICATION__"),this._application&&(this.loadPermitions(),this.loadConfigFromStorage()),this.attachDataUnit()}componentDidRender(){this.processPendingFilter()}render(){if(this.dataUnit&&this.filterConfig&&0!==this.filterConfig.length)return e(i,null,e("ez-scroller",{direction:d.HORIZONTAL,activeShadow:!0,locked:this.scrollerLocked},this.getFilterItems()),e("ez-button",{class:"ez-padding-left--medium",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,"Filtros"),onClick:this.showFilterModal.bind(this)},e("ez-icon",{slot:"leftIcon",iconName:"plus",class:"ez-padding-right--small"})))}get _element(){return r(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};p.style='.sc-snk-filter-bar-h{display:grid;grid-template-columns:minmax(100px, 100%) 1fr 1fr}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;z-index:var(--most-visible, 3);background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;background-color:transparent;border:none;padding:3px;outline-color:var(--color--primary)}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px);border:none;background-color:transparent}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:focus-visible{outline:none;background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:"";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar{--modal-item-border-width:2px;display:flex;flex-direction:row;margin-left:var(--modal-item-border-width);border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7);border:none;width:100%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar:focus-visible{outline:var(--color--primary) solid var(--modal-item-border-width)}.snk-filter-bar__filter-modal-item__check.sc-snk-filter-bar{width:auto}.snk-filter-bar__filter-modal-item__label.sc-snk-filter-bar{font-weight:var(--text-weight--medium)}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:99%;height:100%}';export{p as snk_filter_bar}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as s,h as i,g as e}from"./p-b9667fbe.js";import{ElementIDUtils as o}from"@sankhyalabs/core";import{F as h}from"./p-584d7212.js";const r=class{constructor(i){t(this,i),this.valueChanged=s(this,"valueChanged",7),this.value=void 0,this.config=void 0}ezChangeListener(t){this.value=t.detail.value,this.valueChanged.emit(this.value)}async show(){this._comboElement.setFocus()}componentDidLoad(){this._element&&o.addIDInfo(this._element,"filterContentEditor")}render(){if(this.config&&this.config.type===h.MULTI_SELECT)return i("ez-combo-box",{id:this.config.id,ref:t=>this._comboElement=t,label:this.config.label,value:this.config.value,options:this.config.props.options})}get _element(){return e(this)}};export{r as snk_filter_multi_select}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,h as e}from"./p-b9667fbe.js";import{ModalAction as i}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{F as s}from"./p-d9804798.js";import{F as l}from"./p-584d7212.js";const o=class{constructor(e){t(this,e),this.getMessage=void 0,this.filters=void 0,this.applyFilters=void 0,this.clearAll=void 0,this.closeModal=void 0}getCustomMessage(t,e){var i;return null===(i=this.getMessage)||void 0===i?void 0:i.call(this,`snkFilterBar.filterModal.${t}`,e)}handleClearAll(){const t=this.clearAll(this.filters);this.filters=t}modalActionListener(t){switch(t.detail){case i.CANCEL:this.handleClearAll();break;case i.OK:this.applyFilters(this.filters);case i.CLOSE:this.closeModal()}}handleFilterChange(t){this.filters=this.filters.map((e=>e.id===t.id?t:e))}handleClearFilters(t){this.filters=this.filters.map((e=>t.includes(e)?Object.assign(Object.assign({},e),{value:void 0}):e))}renderFilterItem(t,i){return e("snk-filter-modal-item",{class:i?"ez-col ez-col--sd-12":"ez-col ez-col--sd-6 ez-padding--small",filterItem:t,onFilterChange:t=>this.handleFilterChange(t.detail)})}mountFiltersLines(t){let e=0,i=!1;const s={};for(let o=0;o<t.length;o++){s[e]=s[e]||[];const a=t[o],r=o===t.length-1,n=[l.TEXT,l.NUMBER].includes(a.type),d=!r&&[l.TEXT,l.NUMBER].includes(t[o+1].type);n&&d||i?(s[e].push(a),i=s[e].length<2,2===s[e].length&&++e):(s[e]=s[e]||[],s[e].push(a),++e)}return Object.values(s)}renderFilterLine(t){const i=1===t.length;return e("div",{class:"ez-row"},t.map((t=>this.renderFilterItem(t,i))))}renderCollapsibleFilterBox(t,i){if(!i.length)return null;const s=i.filter((t=>!!t.value)).length,l=this.mountFiltersLines(i);return e("ez-collapsible-box",{className:"snk-filter__modal-collapsible-box ez-padding--medium",headerSize:"medium",value:!0,label:t},!!s&&e("ez-badge",{className:"ez-badge--primary-subtle",slot:"rightSlot",label:s}),l.map(this.renderFilterLine.bind(this)),e("div",{class:"ez-flex ez-flex--justify-end grow"},e("ez-button",{className:"ez-button--tertiary",size:"medium",label:"Limpar",onClick:()=>this.handleClearFilters(i)})))}componentWillRender(){this._modalTitle=this.getCustomMessage("title"),this._okButtonLabel=this.getCustomMessage("okButtonLabel"),this._cancelButtonLabel=this.getCustomMessage("cancelButtonLabel")}render(){const t=this.filters.filter((t=>t.filterType===s.CUSTOM_FILTER)),i=this.filters.filter((t=>t.filterType===s.QUICK_FILTER)),l=this.filters.filter((t=>t.filterType===s.OTHER_FILTERS));return e("ez-modal-container",{class:"snk-filter__modal-container",modalTitle:this._modalTitle,cancelButtonLabel:this._cancelButtonLabel,okButtonLabel:this._okButtonLabel,onEzModalAction:this.modalActionListener.bind(this)},e("div",{class:"snk-filter__modal-content"},this.renderCollapsibleFilterBox(this.getCustomMessage("customFilters"),t),this.renderCollapsibleFilterBox(this.getCustomMessage("quickFilters"),i),l.map((t=>this.renderCollapsibleFilterBox(t.label,[t])))))}};o.style="ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter__modal-container{width:344px;max-width:344px;overflow:hidden}.snk-filter__modal-content{display:flex;flex-direction:column;gap:12px;max-height:760px;overflow-x:clip;overflow-y:auto;padding-right:4px}.snk-filter__modal-content::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}.snk-filter__modal-collapsible-box{border:1px solid #DCE0E8;border-radius:var(--border--radius-medium)}";export{o as snk_filter_modal}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as e,h as i,H as s,g as a}from"./p-b9667fbe.js";import{ElementIDUtils as n,UserInterface as o,ApplicationContext as r}from"@sankhyalabs/core";import{convertType as l}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as h}from"@sankhyalabs/ezui/dist/collection/utils";import{F as u}from"./p-584d7212.js";const d=class{constructor(i){t(this,i),this.valueChanged=e(this,"valueChanged",7),this.config=void 0,this.value=void 0,this.fix=void 0,this.unfix=void 0}componentDidLoad(){this._element&&n.addIDInfo(this._element,"filterContentEditor")}getValue(t,e){if(this.value&&e>=0&&e<this.value.length){const i=this.value[e];return t.type===o.SEARCH?i:l(t.dataType,i)}}setValue(t,e){this.value=null==this.value?Array(t).fill(null):[...this.value],this.value[t]=e,0==this.value.filter((t=>null!=t)).length&&(this.value=null),this.valueChanged.emit(this.value||[])}doSearch(t,e,i){const s=r.getContextValue("__SNK__APPLICATION__");return new Promise(((a,n)=>{s.executePreparedSearch(t,e,i.searchContext).then((t=>{a(t)})).catch((t=>{n(t)}))}))}getParamsInterface(){var t,e,s;return(null===(s=null===(e=null===(t=this.config)||void 0===t?void 0:t.props)||void 0===e?void 0:e.personalizedFilter)||void 0===s?void 0:s.parameters).map(((t,e)=>{var s;const a="param_"+e;switch(t.type){case o.SEARCH:return i("ez-search",{id:a,suppressEmptyOption:!0,value:this.getValue(t,e),onEzChange:t=>this.setValue(e,t.detail),label:t.label,optionLoader:({mode:e,argument:i})=>this.doSearch(e,i,t)});case o.SWITCH:case o.CHECKBOX:return i("ez-check",{id:a,class:"ez-padding-bottom--medium",mode:o.SWITCH===t.type?h.SWITCH:h.REGULAR,value:this.getValue(t,e),label:t.label,onEzChange:t=>this.setValue(e,t.detail)});case o.DECIMALNUMBER:case o.INTEGERNUMBER:return i("ez-number-input",{id:a,label:t.label,value:this.getValue(t,e),precision:null===(s=t.props)||void 0===s?void 0:s.precision,onEzChange:t=>this.setValue(e,t.detail)});case o.OPTIONSELECTOR:return i("ez-combo-box",{id:a,label:t.label,value:this.getValue(t,e),options:t.options,onEzChange:t=>{var i;return this.setValue(e,null===(i=t.detail)||void 0===i?void 0:i.value)}});case o.DATE:return i("ez-date-input",{id:a,label:t.label,value:this.getValue(t,e),onEzChange:t=>this.setValue(e,t.detail)});case o.DATETIME:return i("ez-date-time-input",{id:a,label:t.label,value:this.getValue(t,e),onEzChange:t=>this.setValue(e,t.detail)});default:return i("ez-text-input",{id:a,label:t.label,value:this.getValue(t,e),onEzChange:t=>this.setValue(e,t.detail)})}}))}async show(){const t=document.querySelector("#param_0");t&&t.setFocus()}render(){if(this.config&&this.config.type===u.PERSONALIZED)return i(s,null,this.getParamsInterface())}get _element(){return a(this)}};export{d as snk_filter_personalized}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as s,h as i,g as e}from"./p-b9667fbe.js";import{ElementIDUtils as r}from"@sankhyalabs/core";const h=class{constructor(i){t(this,i),this.valueChanged=s(this,"valueChanged",7),this.config=void 0,this.value=void 0}ezChangeListener(t){this.value=t.detail,this.valueChanged.emit(this.value)}componentDidLoad(){this._element&&r.addIDInfo(this._element,"filterContentEditor")}render(){if(this.config)return i("ez-text-input",{id:this.config.id,ref:t=>this._textInputElement=t,label:this.config.label,value:this.config.value})}get _element(){return e(this)}};export{h as snk_filter_text}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as i,h as s,H as e,g as r}from"./p-b9667fbe.js";import{FloatingManager as h,ElementIDUtils as n}from"@sankhyalabs/core";import{F as l}from"./p-
|
1
|
+
import{r as t,c as i,h as s,H as e,g as r}from"./p-b9667fbe.js";import{FloatingManager as h,ElementIDUtils as n}from"@sankhyalabs/core";import{F as l}from"./p-584d7212.js";const o=class{constructor(s){t(this,s),this.visibleChanged=i(this,"visibleChanged",7),this.filterChange=i(this,"filterChange",7),this.innerClickCheck=(t,i)=>i.id!=h.MODAL_ELEMENT_ID||(this.detailIsVisible=!1,!1),this.detailIsVisible=void 0,this.config=void 0,this.getMessage=void 0}observeDetailIsVisible(t){this.visibleChanged.emit(t)}async showUp(t=!1){return new Promise((i=>{this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&(this._closeCallback=i,window.requestAnimationFrame((()=>{this._floatingID=h.float(this._popover,this._popoverContainer,this.getFloatOptions()),this._popover.show(),this.detailIsVisible=!0})))}))}updatePosition(){null!=this._floatingID&&h.updateFloatPosition(this._popover,this._popoverContainer,this.getFloatOptions())}getFloatOptions(){return{autoClose:!0,innerClickTest:this.innerClickCheck,backClickListener:()=>this.onDetailCloseCallback(),left:this.getScrollOffsetLeft(),top:this.getScrollOffsetTop(),useOverlay:!0,overlayClassName:"ez-scrim ez-scrim--light",isFixed:!0}}getScrollOffsetLeft(){const t=getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");return`calc(${this._filterItemElement.getBoundingClientRect().x}px + ${t})`}getScrollOffsetTop(){const t=this._filterItemElement.getBoundingClientRect();return t.y+t.height+"px"}controlScrollPage(){window.removeEventListener("scroll",this.updatePosition.bind(this)),window.addEventListener("scroll",this.updatePosition.bind(this))}async hideDetail(){this.detailIsVisible&&null!=this._floatingID&&h.close(this._floatingID)}onDetailCloseCallback(){this._floatingID=void 0,this.detailIsVisible=!1,this._closeCallback&&(this._closeCallback(),this._closeCallback=void 0)}clickListener(t){[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.target===this._rightIconElement&&null!=this.config.value?this.filterChange.emit(Object.assign(Object.assign({},this.config),{value:void 0})):this.detailIsVisible?this.hideDetail():this.showUp(!0),t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation())}mouseDownListener(t){this.detailIsVisible&&[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation())}getLabel(){const{type:t,value:i,label:s,props:e}=this.config;if(i){if(t===l.BINARY_SELECT){const[t,s]=e.options;if(t.name===i)return t.label;if(s.name===i)return s.label}if(t===l.MULTI_SELECT)return`${s}: ${e.options.find((t=>t.value===i)).label}`;if(t===l.PERIOD){let{end:t,start:e}=i;"string"==typeof t&&(t=new Date(t),t.setMinutes(t.getMinutes()+t.getTimezoneOffset())),"string"==typeof e&&(e=new Date(e),e.setMinutes(e.getMinutes()+e.getTimezoneOffset()));const r=new Intl.DateTimeFormat("pt-BR");return t&&e?`${s}: ${r.format(e)} a ${r.format(t)}`:e?`${s}: A partir de ${r.format(e)}`:t?`${s}: Até ${r.format(t)}`:s}return t===l.SEARCH?`${s}: ${i.value} - ${i.label}`:t===l.PERSONALIZED?s:`${s}: ${i}`}return s}componentDidLoad(){this._filterItemElement&&(n.addIDInfo(this._filterItemElement),this._idSnkFilterDetail=`filterDetail_${this.config.id}`),this.controlScrollPage()}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}filterChangeListener(){this.hideDetail()}getRightIconName(){return null!=this.config.value?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case l.PERIOD:return"calendar";case l.PERSONALIZED:return"tune"}}render(){const t=this.getLeftIconName();return s(e,null,s("ez-chip",{ref:t=>this._chipElement=t,label:this.getLabel(),value:null!=this.config.value,id:this.config.id},t?s("ez-icon",{ref:t=>this._leftIconElement=t,iconName:t,class:"ez-padding-right--small",slot:"leftIcon"}):void 0,s("ez-icon",{ref:t=>this._rightIconElement=t,iconName:this.getRightIconName(),class:"ez-padding-left--small",slot:"rightIcon",id:"removeFilter"})),s("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},s("snk-filter-detail",{config:this.config,getMessage:this.getMessage,class:"sc-snk-filter-bar snk-filter__popover ez-padding--small",ref:t=>this._popover=t,key:this.config.id,"data-element-id":this._idSnkFilterDetail})))}get _filterItemElement(){return r(this)}static get watchers(){return{detailIsVisible:["observeDetailIsVisible"]}}};export{o as snk_filter_item}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as e,h as i,H as s,g as r}from"./p-b9667fbe.js";import{ApplicationUtils as l}from"@sankhyalabs/ezui/dist/collection/utils";import{F as n}from"./p-
|
1
|
+
import{r as t,c as e,h as i,H as s,g as r}from"./p-b9667fbe.js";import{ApplicationUtils as l}from"@sankhyalabs/ezui/dist/collection/utils";import{F as n}from"./p-584d7212.js";import{ElementIDUtils as a,DataType as o}from"@sankhyalabs/core";const h=class{constructor(i){t(this,i),this.filterChange=e(this,"filterChange",7),this.config=void 0,this.getMessage=void 0}async show(){this._editor.show()}componentDidLoad(){if(this._element){a.addIDInfo(this._element);const t=this._element.getAttribute(a.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case n.BINARY_SELECT:return"snk-filter-binary-select";case n.MULTI_SELECT:return"snk-filter-multi-select";case n.PERIOD:return"snk-filter-period";case n.SEARCH:return"snk-filter-search";case n.NUMBER:return"snk-filter-number";case n.PERSONALIZED:return"snk-filter-personalized"}return"snk-filter-text"}removeItem(){this.changeConfig(Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:void 0}))}getPopUpHeaderButtons(){if(!this.config.hardFixed)return[this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed}))))]}buildIcon(t,e,s){return i("button",{onClick:()=>s(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button",ref:e=>e&&this.buildIdButton(e,t)},i("ez-icon",Object.assign({title:t,iconName:e},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo(`_${t}`)}`})))}buildIdButton(t,e){if(!t)return;const i={id:e};t.removeAttribute(a.DATA_ELEMENT_ID_ATTRIBUTE_NAME),a.addIDInfoIfNotExists(t,"button",i)}getNormalizedValue(t,e){return t.reduce(((t,e,i)=>(e.dataType!==o.BOOLEAN||null!=t&&null!=t[i]||((t=t||[])[i]=!1),t)),e)}apply(){var t;let e=this._editor.value,i=!0;if(this.config.type===n.PERSONALIZED){const s=(null===(t=this.config.props.personalizedFilter)||void 0===t?void 0:t.parameters)||[];e=this.getNormalizedValue(s,e);const r=s.length;0===r?e=[]:i=this.validateAllFilled(r,e)}i&&this.changeConfig(Object.assign(Object.assign({},this.config),{value:e}))}validateAllFilled(t,e){let i=!0;return null!=e&&t>1&&(t>e.length?i=!1:e.forEach((t=>{null==t&&(i=!1)}))),i||l.alert("Filtro parcialmente preenchido","Favor completar todas as informações do filtro."),i}clear(){this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}onKeyDonwListener(t){"Enter"===t.key&&this._applyButton.setFocus().then((()=>this.apply()))}render(){const t=this.getContentEditor();return i(s,null,i("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},i("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()),i(t,{ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor}),i("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),i("div",{class:"ez-col ez-col--sd-12 ez-align--right"},i("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),i("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return r(this)}};export{h as snk_filter_detail}
|