@sankhyalabs/sankhyablocks 5.5.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-26da04f7.js → SnkMessageBuilder-056d1c24.js} +23 -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/index-8d94b7e0.js +7 -0
- package/dist/cjs/index-de79181a.js +201 -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-attach.cjs.entry.js +2 -1
- package/dist/cjs/snk-crud.cjs.entry.js +2 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-c43df27b.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 +4 -3
- package/dist/cjs/snk-expression-item.cjs.entry.js +213 -0
- 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-field-search_2.cjs.entry.js +435 -0
- 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/cjs/snk-grid.cjs.entry.js +3 -2
- package/dist/cjs/{snk-guides-viewer-e6a65393.js → snk-guides-viewer-9784c527.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -2
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +126 -0
- package/dist/cjs/snk-simple-bar_2.cjs.entry.js +2 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
- package/dist/cjs/taskbar-elements-bc2598f9.js +118 -0
- package/dist/collection/collection-manifest.json +3 -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/components/snk-filter-field-search/snk-filter-field-search.js +62 -69
- package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.css +4 -0
- package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +87 -0
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/filter-operands/filter-operands.js +34 -0
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.css +97 -0
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.js +298 -0
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-filter-param-config/snk-filter-param-config.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.js +63 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +9 -1
- package/dist/collection/lib/message/resources/snk-personalized-filter.msg.js +12 -0
- package/dist/collection/lib/store/index.js +2 -1
- package/dist/components/SnkMessageBuilder.js +23 -1
- package/dist/components/filter-item-type.enum.js +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/index2.js +1 -1
- package/dist/components/index3.js +199 -0
- package/dist/components/presentationMode.js +7 -0
- package/dist/components/snk-crud.js +22 -34
- package/dist/components/snk-data-exporter2.js +1 -1
- package/dist/components/snk-detail-view2.js +24 -46
- package/dist/components/snk-expression-item.d.ts +11 -0
- package/dist/components/snk-expression-item.js +6 -0
- package/dist/components/snk-expression-item2.js +241 -0
- package/dist/components/snk-filter-bar2.js +57 -157
- package/dist/components/snk-filter-binary-select.js +9 -1
- package/dist/components/snk-filter-field-search.js +1 -200
- package/dist/{esm/snk-filter-field-search.entry.js → components/snk-filter-field-search2.js} +65 -38
- 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-param-config.js +1 -273
- package/dist/{esm/snk-filter-param-config.entry.js → components/snk-filter-param-config2.js} +35 -11
- 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 +12 -23
- package/dist/components/snk-personalized-filter.d.ts +11 -0
- package/dist/components/snk-personalized-filter.js +158 -0
- package/dist/components/snk-taskbar2.js +3 -197
- package/dist/esm/{SnkMessageBuilder-7a9392e6.js → SnkMessageBuilder-23272e07.js} +23 -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/{index-6519a79e.js → index-507e19ec.js} +1 -1
- package/dist/esm/index-620ac460.js +7 -0
- package/dist/esm/index-8efbf198.js +199 -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-attach.entry.js +3 -2
- package/dist/esm/snk-crud.entry.js +3 -2
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-f9e4c694.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 +5 -4
- package/dist/esm/snk-expression-item.entry.js +209 -0
- 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-field-search_2.entry.js +430 -0
- 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/esm/snk-grid.entry.js +3 -2
- package/dist/esm/{snk-guides-viewer-62a9f74d.js → snk-guides-viewer-4d12f268.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +4 -3
- package/dist/esm/snk-personalized-filter.entry.js +122 -0
- package/dist/esm/snk-simple-bar_2.entry.js +3 -2
- package/dist/esm/snk-taskbar.entry.js +3 -2
- package/dist/esm/taskbar-elements-e6af3e93.js +115 -0
- package/dist/sankhyablocks/p-0110b7da.entry.js +1 -0
- package/dist/sankhyablocks/p-1a68fb59.js +1 -0
- package/dist/sankhyablocks/p-27e264d9.entry.js +1 -0
- package/dist/sankhyablocks/p-343699ad.entry.js +1 -0
- package/dist/sankhyablocks/{p-f2223502.js → p-3db1d3de.js} +1 -1
- package/dist/sankhyablocks/p-433dfa63.entry.js +1 -0
- package/dist/sankhyablocks/p-45ee8b22.entry.js +1 -0
- package/dist/sankhyablocks/{p-f132e371.js → p-4c2015a9.js} +1 -1
- package/dist/sankhyablocks/p-4ce96831.entry.js +1 -0
- package/dist/sankhyablocks/p-4eefe631.entry.js +1 -0
- package/dist/sankhyablocks/{p-9dd2b8cb.js → p-584d7212.js} +1 -1
- package/dist/sankhyablocks/{p-a412992c.entry.js → p-64b03506.entry.js} +1 -1
- package/dist/sankhyablocks/p-6a02e236.js +1 -0
- 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-8bdf5e57.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-b2523981.entry.js → p-c1ab16d0.entry.js} +2 -2
- package/dist/sankhyablocks/{p-aeffd219.js → p-ccd26e3a.js} +1 -1
- package/dist/sankhyablocks/p-d410f45a.js +1 -0
- package/dist/sankhyablocks/p-d9804798.js +1 -0
- package/dist/sankhyablocks/p-df8f13b4.entry.js +1 -0
- package/dist/sankhyablocks/p-e2bb9c9a.entry.js +1 -0
- package/dist/sankhyablocks/p-e9f42525.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-f4184ce7.js +1 -0
- package/dist/sankhyablocks/p-f5f36fbb.js +1 -0
- package/dist/sankhyablocks/p-fd4ed40a.entry.js +1 -0
- package/dist/sankhyablocks/p-ff96b509.entry.js +27 -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/snk-filter-field-search/interfaces/index.d.ts +14 -4
- package/dist/types/components/snk-filter-field-search/snk-filter-field-search.d.ts +13 -10
- package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +20 -0
- package/dist/types/components/snk-personalized-filter/subcomponents/snk-expression-item/filter-operands/filter-operands.d.ts +9 -0
- package/dist/types/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.d.ts +54 -0
- package/dist/types/components/snk-personalized-filter/subcomponents/snk-filter-param-config/interfaces/IExpressionItem.d.ts +4 -2
- package/dist/types/components.d.ts +196 -63
- package/dist/types/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.d.ts +7 -0
- package/dist/types/lib/message/resources/snk-personalized-filter.msg.d.ts +1 -0
- package/dist/types/lib/store/index.d.ts +1 -0
- package/package.json +1 -1
- package/react/components.d.ts +3 -0
- package/react/components.js +3 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/snk-filter-field-search.cjs.entry.js +0 -185
- package/dist/cjs/snk-filter-param-config.cjs.entry.js +0 -256
- package/dist/cjs/taskbar-elements-80285601.js +0 -313
- package/dist/components/snk-filter-list2.js +0 -173
- package/dist/components/snk-filter-modal2.js +0 -97
- package/dist/esm/taskbar-elements-055ba1ad.js +0 -309
- package/dist/sankhyablocks/p-4512cc6c.entry.js +0 -1
- package/dist/sankhyablocks/p-5cbbe1f7.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-63d01871.entry.js +0 -1
- package/dist/sankhyablocks/p-73e830cf.entry.js +0 -1
- package/dist/sankhyablocks/p-741b00ef.entry.js +0 -1
- package/dist/sankhyablocks/p-79d22df0.entry.js +0 -1
- package/dist/sankhyablocks/p-86d29b6f.entry.js +0 -1
- package/dist/sankhyablocks/p-92a0fca4.js +0 -1
- package/dist/sankhyablocks/p-93d8fe00.entry.js +0 -1
- package/dist/sankhyablocks/p-999d1953.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-c3efd4eb.entry.js +0 -1
- package/dist/sankhyablocks/p-d5c9c1f8.entry.js +0 -1
- package/dist/sankhyablocks/p-ebe876f5.entry.js +0 -1
- package/dist/sankhyablocks/p-ed438690.js +0 -1
- package/dist/sankhyablocks/p-ee82c157.entry.js +0 -1
- package/dist/sankhyablocks/p-f3d0c744.entry.js +0 -1
- package/dist/sankhyablocks/p-fac37198.entry.js +0 -1
@@ -1,203 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import { UserInterface, JSUtils, ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
|
-
|
4
|
-
var SelectedItemType;
|
5
|
-
(function (SelectedItemType) {
|
6
|
-
SelectedItemType["LINK"] = "LINK";
|
7
|
-
SelectedItemType["FIELD"] = "FIELD";
|
8
|
-
})(SelectedItemType || (SelectedItemType = {}));
|
9
|
-
|
10
|
-
const ICON_MODES = {
|
11
|
-
[UserInterface.SHORTTEXT]: 'text',
|
12
|
-
[UserInterface.LONGTEXT]: 'text',
|
13
|
-
[UserInterface.INTEGERNUMBER]: 'number',
|
14
|
-
[UserInterface.DECIMALNUMBER]: 'number',
|
15
|
-
[UserInterface.DATE]: 'calendar',
|
16
|
-
[UserInterface.DATETIME]: 'calendar',
|
17
|
-
[UserInterface.SWITCH]: 'boolean',
|
18
|
-
[UserInterface.CHECKBOX]: 'check-circle-inverted',
|
19
|
-
[UserInterface.OPTIONSELECTOR]: 'list',
|
20
|
-
[UserInterface.SEARCH]: 'search',
|
21
|
-
[UserInterface.HTML]: 'tag_code',
|
22
|
-
[UserInterface.IMAGE]: 'png',
|
23
|
-
[UserInterface.FILE]: 'edit-file',
|
24
|
-
[UserInterface.TIME]: 'timer-outline',
|
25
|
-
[UserInterface.ELAPSEDTIME]: 'timer',
|
26
|
-
[UserInterface.MASKEDTEXT]: 'text',
|
27
|
-
[UserInterface.PASSWORD]: 'email',
|
28
|
-
};
|
29
|
-
const ListItem = ({ userInterface, description }) => {
|
30
|
-
return (h("ez-icon", { iconName: ICON_MODES[userInterface], className: "ez-padding-left--small", title: description }));
|
31
|
-
};
|
32
|
-
|
33
|
-
const snkFilterFieldSearchCss = ".sc-snk-filter-field-search-h{--snk-filter-field-search--container-width:468px;--snk-filter-field-search--container-height:322px}.snk-filter-field-search__container.sc-snk-filter-field-search{display:flex;flex-direction:column;padding:var(--space--medium);width:var(--snk-filter-field-search--container-width);height:var(--snk-filter-field-search--container-height)}.snk-filter-field-search__section.sc-snk-filter-field-search{display:grid;grid-template-columns:1fr 1fr;place-items:flex-start;overflow:hidden;gap:var(--space--small)}.snk-filter-field-search__input.sc-snk-filter-field-search{margin-bottom:var(--space--medium)}.snk-filter-field-search__list_container.sc-snk-filter-field-search{display:flex;flex-direction:column}.snk-filter-field-search__list.sc-snk-filter-field-search{overflow-y:auto}";
|
34
|
-
|
35
|
-
const SNK_CONTEXT_KEY = "__SNK__APPLICATION__";
|
36
|
-
const SnkFilterFieldSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
37
|
-
constructor() {
|
38
|
-
super();
|
39
|
-
this.__registerHost();
|
40
|
-
this.ezSelectFilterItem = createEvent(this, "ezSelectFilterItem", 7);
|
41
|
-
this._filterMetadataStorage = new Map();
|
42
|
-
this._dataSource = null;
|
43
|
-
this._filterText = "";
|
44
|
-
this._isLoading = false;
|
45
|
-
this.searchable = true;
|
46
|
-
this.breadcrumbItems = [];
|
47
|
-
this.linkItems = [];
|
48
|
-
this.fieldItems = [];
|
49
|
-
}
|
50
|
-
/**
|
51
|
-
* Define a fonte de dados do componente.
|
52
|
-
* @param {IFilterLink} currentLink - Link atual da entidade.
|
53
|
-
* @param {IFilterMetadata} fetchData - callback que executa a busca de dados.
|
54
|
-
* @throws {Error} - Quando os metadados não forem válidos.
|
55
|
-
* @throws {Error} - Quando o link atual não for do tipo link.
|
56
|
-
*/
|
57
|
-
async setDataSource(currentLink, fetchData) {
|
58
|
-
var _a;
|
59
|
-
this._isLoading = true;
|
60
|
-
let metadata = this._filterMetadataStorage.get(currentLink.uri);
|
61
|
-
if (!metadata) {
|
62
|
-
metadata = await fetchData(currentLink);
|
63
|
-
this._filterMetadataStorage.set(currentLink.uri, metadata);
|
64
|
-
}
|
65
|
-
const { fields, links } = metadata || {};
|
66
|
-
if (!Array.isArray(fields) || !Array.isArray(links))
|
67
|
-
throw new Error('Invalid metadata');
|
68
|
-
if (currentLink.type !== SelectedItemType.LINK)
|
69
|
-
throw new Error('The current link must be a link type');
|
70
|
-
this._dataSource = metadata;
|
71
|
-
this._currentLink = currentLink;
|
72
|
-
this.mapDataSourceToLinkItems();
|
73
|
-
this.mapDataSourceToFieldItems();
|
74
|
-
this._isLoading = false;
|
75
|
-
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.show();
|
76
|
-
this._ezFieldList.scrollToTop();
|
77
|
-
this._ezLinkList.scrollToTop();
|
78
|
-
}
|
79
|
-
/**
|
80
|
-
* Filtra a fonte de dados do componente.
|
81
|
-
* @param {string} filterText - Texto para filtrar a fonte de dados.
|
82
|
-
* @throws {Error} - Quando o componente estiver com a propriedade searchable como true.
|
83
|
-
*/
|
84
|
-
async filterDataSource(filterText) {
|
85
|
-
if (this.searchable)
|
86
|
-
throw new Error('This method is not available when searchable is true');
|
87
|
-
this.handleFilterChange(filterText);
|
88
|
-
}
|
89
|
-
mapDataSourceToLinkItems() {
|
90
|
-
var _a;
|
91
|
-
const { links } = this._dataSource;
|
92
|
-
const filterLinkLabelMessage = this.getMessage('snkFilterFieldSearch.linkLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
|
93
|
-
const items = links.map(link => (Object.assign({ label: link.description }, link)));
|
94
|
-
this.linkItems = [{
|
95
|
-
group: filterLinkLabelMessage,
|
96
|
-
items
|
97
|
-
}];
|
98
|
-
if (this.breadcrumbItems.length === 0) {
|
99
|
-
this.breadcrumbItems = [Object.assign({ id: JSUtils.generateUUID(), label: this._currentLink.description }, this._currentLink)];
|
100
|
-
}
|
101
|
-
}
|
102
|
-
mapDataSourceToFieldItems() {
|
103
|
-
var _a;
|
104
|
-
const { fields } = this._dataSource;
|
105
|
-
const filterFieldLabelMessage = this.getMessage('snkFilterFieldSearch.fieldLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
|
106
|
-
const filteredFields = fields.filter(field => {
|
107
|
-
if (!this._currentLink)
|
108
|
-
return true;
|
109
|
-
const searchableByDescription = field.description.toLowerCase().includes(this._filterText.toLowerCase());
|
110
|
-
const searchableByName = field.name.toLowerCase().includes(this._filterText.toLowerCase());
|
111
|
-
return searchableByDescription || searchableByName;
|
112
|
-
});
|
113
|
-
const items = filteredFields.map(field => (Object.assign({ label: field.description }, field)));
|
114
|
-
this.fieldItems = [{
|
115
|
-
group: filterFieldLabelMessage,
|
116
|
-
items
|
117
|
-
}];
|
118
|
-
}
|
119
|
-
handleFilterChange(filterText) {
|
120
|
-
if (this._isLoading)
|
121
|
-
return;
|
122
|
-
this._filterText = filterText;
|
123
|
-
this.mapDataSourceToFieldItems();
|
124
|
-
}
|
125
|
-
handleSelectLink({ detail: item }) {
|
126
|
-
if (this._isLoading)
|
127
|
-
return;
|
128
|
-
const breadcrumbByIndex = this.breadcrumbItems.findIndex(breadcrumbItem => breadcrumbItem.id === item.id);
|
129
|
-
item.cache = this._filterMetadataStorage.has(item.uri);
|
130
|
-
if (breadcrumbByIndex > -1) {
|
131
|
-
this.breadcrumbItems = this.breadcrumbItems.slice(0, (breadcrumbByIndex + 1));
|
132
|
-
}
|
133
|
-
else {
|
134
|
-
this.breadcrumbItems = [...this.breadcrumbItems, Object.assign({ id: JSUtils.generateUUID(), label: item.description }, item)];
|
135
|
-
}
|
136
|
-
this.ezSelectFilterItem.emit(Object.assign(Object.assign({}, item), { type: SelectedItemType.LINK }));
|
137
|
-
}
|
138
|
-
handleSelectField({ detail: item }) {
|
139
|
-
var _a;
|
140
|
-
const breadcrumbPath = this.breadcrumbItems.map(breadcrumbItem => breadcrumbItem.label).join('>>');
|
141
|
-
const selectedField = Object.assign(Object.assign({}, item), { type: SelectedItemType.FIELD, path: `${breadcrumbPath} >> ${item.description}` });
|
142
|
-
this.ezSelectFilterItem.emit(selectedField);
|
143
|
-
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.hide();
|
144
|
-
}
|
145
|
-
getElementID(sufix) {
|
146
|
-
return {
|
147
|
-
[ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
|
148
|
-
};
|
149
|
-
}
|
150
|
-
/**
|
151
|
-
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
152
|
-
* através de um pequeno modulo na estrutura da aplicação:
|
153
|
-
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
154
|
-
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-field-search.msg.ts"
|
155
|
-
*/
|
156
|
-
getMessage(key, params) {
|
157
|
-
var _a, _b, _c;
|
158
|
-
if (!this._application)
|
159
|
-
this._application = ApplicationContext.getContextValue(SNK_CONTEXT_KEY);
|
160
|
-
return (_c = (_b = (_a = this._application) === null || _a === void 0 ? void 0 : _a.messagesBuilder) === null || _b === void 0 ? void 0 : _b.getMessage) === null || _c === void 0 ? void 0 : _c.call(_b, key, params);
|
161
|
-
}
|
162
|
-
;
|
163
|
-
componentWillLoad() {
|
164
|
-
this._application = ApplicationContext.getContextValue(SNK_CONTEXT_KEY);
|
165
|
-
}
|
166
|
-
componentDidLoad() {
|
167
|
-
ElementIDUtils.addIDInfoIfNotExists(this._ezPopover, 'popover');
|
168
|
-
}
|
169
|
-
disconnectedCallback() {
|
170
|
-
var _a;
|
171
|
-
this._filterMetadataStorage.clear();
|
172
|
-
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.hide();
|
173
|
-
}
|
174
|
-
render() {
|
175
|
-
var _a;
|
176
|
-
const searchLabelMessage = this.getMessage('snkFilterFieldSearch.searchLabel');
|
177
|
-
return (h("ez-popover", Object.assign({ ref: (el) => this._ezPopover = el, role: "dialog", "aria-hidden": !((_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.opened) }, this.getElementID('EzPopover')), h("div", { class: "snk-filter-field-search__container" }, h("header", { class: "snk-filter-field-search__header" }, this.searchable && !!searchLabelMessage && (h("ez-filter-input", Object.assign({ class: "snk-filter-field-search__input", label: searchLabelMessage, asyncSearch: true, canShowError: false, onEzSearching: (event) => this.handleFilterChange.bind(this)(event.detail), "aria-label": searchLabelMessage, "aria-required": "false", "aria-invalid": "false" }, this.getElementID('EzFilterInput')))), this.breadcrumbItems.length > 0 && (h("ez-breadcrumb", Object.assign({ items: this.breadcrumbItems, onSelectedItem: this.handleSelectLink.bind(this), role: "navigation", "aria-current": "step" }, this.getElementID('EzBreadcrumb')))), h("hr", { class: "ez-divider-horizontal ez-margin-vertical--medium" })), h("section", { class: "snk-filter-field-search__section" }, h("ez-list", Object.assign({ ref: (el) => this._ezLinkList = el, class: "snk-filter-field-search__list", id: "filterLinkList", useGroups: true, dataSource: this.linkItems, onEzSelectItem: this.handleSelectLink.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ({ fieldCount }) => h("ez-badge", { label: fieldCount }), "aria-describedby": "filterLinkLabel" }, this.getElementID('EzListLinks'))), h("ez-list", Object.assign({ ref: (el) => this._ezFieldList = el, class: "snk-filter-field-search__list", id: "filterFieldList", useGroups: true, dataSource: this.fieldItems, onEzSelectItem: this.handleSelectField.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ListItem, "aria-describedby": "filterFieldLabel" }, this.getElementID('EzListFields')))))));
|
178
|
-
}
|
179
|
-
static get style() { return snkFilterFieldSearchCss; }
|
180
|
-
}, [2, "snk-filter-field-search", {
|
181
|
-
"searchable": [4],
|
182
|
-
"breadcrumbItems": [32],
|
183
|
-
"linkItems": [32],
|
184
|
-
"fieldItems": [32],
|
185
|
-
"setDataSource": [64],
|
186
|
-
"filterDataSource": [64]
|
187
|
-
}]);
|
188
|
-
function defineCustomElement$1() {
|
189
|
-
if (typeof customElements === "undefined") {
|
190
|
-
return;
|
191
|
-
}
|
192
|
-
const components = ["snk-filter-field-search"];
|
193
|
-
components.forEach(tagName => { switch (tagName) {
|
194
|
-
case "snk-filter-field-search":
|
195
|
-
if (!customElements.get(tagName)) {
|
196
|
-
customElements.define(tagName, SnkFilterFieldSearch$1);
|
197
|
-
}
|
198
|
-
break;
|
199
|
-
} });
|
200
|
-
}
|
1
|
+
import { S as SnkFilterFieldSearch$1, d as defineCustomElement$1 } from './snk-filter-field-search2.js';
|
201
2
|
|
202
3
|
const SnkFilterFieldSearch = SnkFilterFieldSearch$1;
|
203
4
|
const defineCustomElement = defineCustomElement$1;
|
package/dist/{esm/snk-filter-field-search.entry.js → components/snk-filter-field-search2.js}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { h,
|
1
|
+
import { h, proxyCustomElement, HTMLElement, createEvent } from '@stencil/core/internal/client';
|
2
2
|
import { UserInterface, JSUtils, ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
3
|
|
4
4
|
var SelectedItemType;
|
@@ -33,66 +33,69 @@ const ListItem = ({ userInterface, description }) => {
|
|
33
33
|
const snkFilterFieldSearchCss = ".sc-snk-filter-field-search-h{--snk-filter-field-search--container-width:468px;--snk-filter-field-search--container-height:322px}.snk-filter-field-search__container.sc-snk-filter-field-search{display:flex;flex-direction:column;padding:var(--space--medium);width:var(--snk-filter-field-search--container-width);height:var(--snk-filter-field-search--container-height)}.snk-filter-field-search__section.sc-snk-filter-field-search{display:grid;grid-template-columns:1fr 1fr;place-items:flex-start;overflow:hidden;gap:var(--space--small)}.snk-filter-field-search__input.sc-snk-filter-field-search{margin-bottom:var(--space--medium)}.snk-filter-field-search__list_container.sc-snk-filter-field-search{display:flex;flex-direction:column}.snk-filter-field-search__list.sc-snk-filter-field-search{overflow-y:auto}";
|
34
34
|
|
35
35
|
const SNK_CONTEXT_KEY = "__SNK__APPLICATION__";
|
36
|
-
const SnkFilterFieldSearch = class {
|
37
|
-
constructor(
|
38
|
-
|
36
|
+
const SnkFilterFieldSearch = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
37
|
+
constructor() {
|
38
|
+
super();
|
39
|
+
this.__registerHost();
|
39
40
|
this.ezSelectFilterItem = createEvent(this, "ezSelectFilterItem", 7);
|
40
41
|
this._filterMetadataStorage = new Map();
|
41
|
-
this.
|
42
|
+
this._currentMetadata = null;
|
42
43
|
this._filterText = "";
|
43
44
|
this._isLoading = false;
|
44
45
|
this.searchable = true;
|
46
|
+
this.fieldsDataSource = undefined;
|
45
47
|
this.breadcrumbItems = [];
|
46
48
|
this.linkItems = [];
|
47
49
|
this.fieldItems = [];
|
48
50
|
}
|
49
51
|
/**
|
50
|
-
*
|
51
|
-
*
|
52
|
-
*
|
53
|
-
|
54
|
-
* @throws {Error} - Quando o link atual não for do tipo link.
|
55
|
-
*/
|
56
|
-
async setDataSource(currentLink, fetchData) {
|
52
|
+
* Realiza a abertura do componente e faz a primeira carga
|
53
|
+
* de dados.
|
54
|
+
* */
|
55
|
+
async show() {
|
57
56
|
var _a;
|
57
|
+
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.show();
|
58
|
+
return this.loadData();
|
59
|
+
}
|
60
|
+
/**
|
61
|
+
* Filtra a fonte de dados do componente.
|
62
|
+
* @param {string} filterText - Texto para filtrar a fonte de dados.
|
63
|
+
* @throws {Error} - Quando o componente estiver com a propriedade searchable como true.
|
64
|
+
*/
|
65
|
+
async applyFilter(filterText) {
|
66
|
+
if (this.searchable)
|
67
|
+
throw new Error('This method is not available when searchable is true');
|
68
|
+
this.handleFilterChange(filterText);
|
69
|
+
}
|
70
|
+
async loadData() {
|
58
71
|
this._isLoading = true;
|
59
|
-
let metadata
|
72
|
+
let metadata;
|
73
|
+
if (this._currentLink != undefined) {
|
74
|
+
metadata = this._filterMetadataStorage.get(this._currentLink.uri);
|
75
|
+
}
|
60
76
|
if (!metadata) {
|
61
|
-
metadata = await fetchData(
|
62
|
-
this.
|
77
|
+
metadata = await this.fieldsDataSource.fetchData(this._currentLink);
|
78
|
+
this._currentLink = metadata.currentLink;
|
79
|
+
this._filterMetadataStorage.set(this._currentLink.uri, metadata);
|
63
80
|
}
|
64
81
|
const { fields, links } = metadata || {};
|
65
82
|
if (!Array.isArray(fields) || !Array.isArray(links))
|
66
83
|
throw new Error('Invalid metadata');
|
67
|
-
|
68
|
-
throw new Error('The current link must be a link type');
|
69
|
-
this._dataSource = metadata;
|
70
|
-
this._currentLink = currentLink;
|
84
|
+
this._currentMetadata = metadata;
|
71
85
|
this.mapDataSourceToLinkItems();
|
72
86
|
this.mapDataSourceToFieldItems();
|
73
87
|
this._isLoading = false;
|
74
|
-
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.show();
|
75
88
|
this._ezFieldList.scrollToTop();
|
76
89
|
this._ezLinkList.scrollToTop();
|
77
90
|
}
|
78
|
-
/**
|
79
|
-
* Filtra a fonte de dados do componente.
|
80
|
-
* @param {string} filterText - Texto para filtrar a fonte de dados.
|
81
|
-
* @throws {Error} - Quando o componente estiver com a propriedade searchable como true.
|
82
|
-
*/
|
83
|
-
async filterDataSource(filterText) {
|
84
|
-
if (this.searchable)
|
85
|
-
throw new Error('This method is not available when searchable is true');
|
86
|
-
this.handleFilterChange(filterText);
|
87
|
-
}
|
88
91
|
mapDataSourceToLinkItems() {
|
89
92
|
var _a;
|
90
|
-
const { links } = this.
|
93
|
+
const { links } = this._currentMetadata;
|
91
94
|
const filterLinkLabelMessage = this.getMessage('snkFilterFieldSearch.linkLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
|
92
95
|
const items = links.map(link => (Object.assign({ label: link.description }, link)));
|
93
96
|
this.linkItems = [{
|
94
97
|
group: filterLinkLabelMessage,
|
95
|
-
items
|
98
|
+
items,
|
96
99
|
}];
|
97
100
|
if (this.breadcrumbItems.length === 0) {
|
98
101
|
this.breadcrumbItems = [Object.assign({ id: JSUtils.generateUUID(), label: this._currentLink.description }, this._currentLink)];
|
@@ -100,7 +103,7 @@ const SnkFilterFieldSearch = class {
|
|
100
103
|
}
|
101
104
|
mapDataSourceToFieldItems() {
|
102
105
|
var _a;
|
103
|
-
const { fields } = this.
|
106
|
+
const { fields } = this._currentMetadata;
|
104
107
|
const filterFieldLabelMessage = this.getMessage('snkFilterFieldSearch.fieldLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
|
105
108
|
const filteredFields = fields.filter(field => {
|
106
109
|
if (!this._currentLink)
|
@@ -132,7 +135,10 @@ const SnkFilterFieldSearch = class {
|
|
132
135
|
else {
|
133
136
|
this.breadcrumbItems = [...this.breadcrumbItems, Object.assign({ id: JSUtils.generateUUID(), label: item.description }, item)];
|
134
137
|
}
|
135
|
-
|
138
|
+
const selectedItem = Object.assign(Object.assign({}, item), { type: SelectedItemType.LINK });
|
139
|
+
this._currentLink = selectedItem;
|
140
|
+
this.ezSelectFilterItem.emit(selectedItem);
|
141
|
+
this.loadData();
|
136
142
|
}
|
137
143
|
handleSelectField({ detail: item }) {
|
138
144
|
var _a;
|
@@ -173,9 +179,30 @@ const SnkFilterFieldSearch = class {
|
|
173
179
|
render() {
|
174
180
|
var _a;
|
175
181
|
const searchLabelMessage = this.getMessage('snkFilterFieldSearch.searchLabel');
|
176
|
-
return (h("ez-popover", Object.assign({ ref: (el) => this._ezPopover = el, role: "dialog", "aria-hidden": !((_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.opened) }, this.getElementID('EzPopover')), h("div", { class: "snk-filter-field-search__container" }, h("header", { class: "snk-filter-field-search__header" }, this.searchable && !!searchLabelMessage && (h("ez-filter-input", Object.assign({ class: "snk-filter-field-search__input", label: searchLabelMessage, asyncSearch: true, canShowError: false, onEzSearching: (event) => this.handleFilterChange.bind(this)(event.detail), "aria-label": searchLabelMessage, "aria-required": "false", "aria-invalid": "false" }, this.getElementID('EzFilterInput')))), this.breadcrumbItems.length > 0 && (h("ez-breadcrumb", Object.assign({ items: this.breadcrumbItems, onSelectedItem: this.handleSelectLink.bind(this), role: "navigation", "aria-current": "step" }, this.getElementID('EzBreadcrumb')))), h("hr", { class: "ez-divider-horizontal ez-margin-vertical--medium" })), h("section", { class: "snk-filter-field-search__section" }, h("ez-list", Object.assign({ ref: (el) => this._ezLinkList = el, class: "snk-filter-field-search__list", id: "filterLinkList", useGroups: true, dataSource: this.linkItems, onEzSelectItem: this.handleSelectLink.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ({ fieldCount }) => h("ez-badge", { label: fieldCount }), "aria-describedby": "filterLinkLabel" }, this.getElementID('EzListLinks'))), h("ez-list", Object.assign({ ref: (el) => this._ezFieldList = el, class: "snk-filter-field-search__list", id: "filterFieldList", useGroups: true, dataSource: this.fieldItems, onEzSelectItem: this.handleSelectField.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ListItem, "aria-describedby": "filterFieldLabel" }, this.getElementID('EzListFields')))))));
|
182
|
+
return (h("ez-popover", Object.assign({ ref: (el) => this._ezPopover = el, role: "dialog", overlayType: "none", "aria-hidden": !((_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.opened) }, this.getElementID('EzPopover')), h("div", { class: "snk-filter-field-search__container" }, h("header", { class: "snk-filter-field-search__header" }, this.searchable && !!searchLabelMessage && (h("ez-filter-input", Object.assign({ class: "snk-filter-field-search__input", label: searchLabelMessage, asyncSearch: true, canShowError: false, onEzSearching: (event) => this.handleFilterChange.bind(this)(event.detail), "aria-label": searchLabelMessage, "aria-required": "false", "aria-invalid": "false" }, this.getElementID('EzFilterInput')))), this.breadcrumbItems.length > 0 && (h("ez-breadcrumb", Object.assign({ items: this.breadcrumbItems, onSelectedItem: this.handleSelectLink.bind(this), role: "navigation", "aria-current": "step" }, this.getElementID('EzBreadcrumb')))), h("hr", { class: "ez-divider-horizontal ez-margin-vertical--medium" })), h("section", { class: "snk-filter-field-search__section" }, h("ez-list", Object.assign({ ref: (el) => this._ezLinkList = el, class: "snk-filter-field-search__list", id: "filterLinkList", useGroups: true, dataSource: this.linkItems, onEzSelectItem: this.handleSelectLink.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ({ fieldCount }) => h("ez-badge", { label: fieldCount }), "aria-describedby": "filterLinkLabel" }, this.getElementID('EzListLinks'))), h("ez-list", Object.assign({ ref: (el) => this._ezFieldList = el, class: "snk-filter-field-search__list", id: "filterFieldList", useGroups: true, dataSource: this.fieldItems, onEzSelectItem: this.handleSelectField.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ListItem, "aria-describedby": "filterFieldLabel" }, this.getElementID('EzListFields')))))));
|
177
183
|
}
|
178
|
-
}
|
179
|
-
|
184
|
+
static get style() { return snkFilterFieldSearchCss; }
|
185
|
+
}, [2, "snk-filter-field-search", {
|
186
|
+
"searchable": [4],
|
187
|
+
"fieldsDataSource": [16],
|
188
|
+
"breadcrumbItems": [32],
|
189
|
+
"linkItems": [32],
|
190
|
+
"fieldItems": [32],
|
191
|
+
"show": [64],
|
192
|
+
"applyFilter": [64]
|
193
|
+
}]);
|
194
|
+
function defineCustomElement() {
|
195
|
+
if (typeof customElements === "undefined") {
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
const components = ["snk-filter-field-search"];
|
199
|
+
components.forEach(tagName => { switch (tagName) {
|
200
|
+
case "snk-filter-field-search":
|
201
|
+
if (!customElements.get(tagName)) {
|
202
|
+
customElements.define(tagName, SnkFilterFieldSearch);
|
203
|
+
}
|
204
|
+
break;
|
205
|
+
} });
|
206
|
+
}
|
180
207
|
|
181
|
-
export { SnkFilterFieldSearch as
|
208
|
+
export { SnkFilterFieldSearch as S, SelectedItemType as a, defineCustomElement as d };
|
@@ -1,4 +1,174 @@
|
|
1
|
-
import {
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
2
|
+
import { FloatingManager, ElementIDUtils, ArrayUtils } from '@sankhyalabs/core';
|
3
|
+
|
4
|
+
const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
|
5
|
+
const MAX_FILTERS = 5;
|
6
|
+
const SnkFilterList$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
7
|
+
constructor() {
|
8
|
+
super();
|
9
|
+
this.__registerHost();
|
10
|
+
this.snkItemSelected = createEvent(this, "snkItemSelected", 7);
|
11
|
+
this._preselection = -1;
|
12
|
+
this.innerClickCheck = (_floatingContainer, node) => {
|
13
|
+
if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
|
14
|
+
return true;
|
15
|
+
}
|
16
|
+
this._detailIsVisible = false;
|
17
|
+
return false;
|
18
|
+
};
|
19
|
+
this._filterArgument = undefined;
|
20
|
+
this._showAll = undefined;
|
21
|
+
this.label = undefined;
|
22
|
+
this.iconName = undefined;
|
23
|
+
this.items = undefined;
|
24
|
+
this.getMessage = undefined;
|
25
|
+
this.emptyText = undefined;
|
26
|
+
this.findFilterText = undefined;
|
27
|
+
this.buttonClass = undefined;
|
28
|
+
}
|
29
|
+
showDetail() {
|
30
|
+
this._preselection = -1;
|
31
|
+
this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, {
|
32
|
+
autoClose: true,
|
33
|
+
innerClickTest: this.innerClickCheck,
|
34
|
+
backClickListener: () => this.onListCloseCallback(),
|
35
|
+
useOverlay: true
|
36
|
+
});
|
37
|
+
this._detailIsVisible = true;
|
38
|
+
this._showAll = false;
|
39
|
+
this._filterArgument = "";
|
40
|
+
this._filterInput.setFocus();
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Oculta os detalhes do componente snk-filter-list.
|
44
|
+
*/
|
45
|
+
async hideDetail() {
|
46
|
+
if (this._floatingID != undefined) {
|
47
|
+
FloatingManager.close(this._floatingID);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
onListCloseCallback() {
|
51
|
+
this._floatingID = undefined;
|
52
|
+
this._detailIsVisible = false;
|
53
|
+
}
|
54
|
+
buttonClick() {
|
55
|
+
if (this._detailIsVisible) {
|
56
|
+
this.hideDetail();
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
this.showDetail();
|
60
|
+
}
|
61
|
+
}
|
62
|
+
componentDidLoad() {
|
63
|
+
if (this._element) {
|
64
|
+
ElementIDUtils.addIDInfo(this._element);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
componentDidRender() {
|
68
|
+
if (this._floatingID == undefined) {
|
69
|
+
if (this._popover) {
|
70
|
+
this._popover.remove();
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
buildIdElement(buttonElement, name) {
|
75
|
+
if (!buttonElement)
|
76
|
+
return;
|
77
|
+
const dataElement = { id: name };
|
78
|
+
buttonElement.removeAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
|
79
|
+
ElementIDUtils.addIDInfoIfNotExists(buttonElement, "filterItemList", dataElement);
|
80
|
+
}
|
81
|
+
buildItemElement(item) {
|
82
|
+
const itemId = ++this._selectableItemsCount;
|
83
|
+
return (h("button", { ref: elem => elem && this.buildIdElement(elem, item.label), id: `filter-item${itemId}`, onFocusin: () => this._preselection = itemId, class: `ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item`, onClick: () => this.itemSelected(item.name), name: item.label, key: itemId }, item.iconName ? h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, h("div", { class: `ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${item.labelClass || ""}` }, item.label)));
|
84
|
+
}
|
85
|
+
itemSelected(itemName) {
|
86
|
+
if (itemName === SHOW_MORE_ITEM_NAME) {
|
87
|
+
this._showAll = true;
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
this.hideDetail();
|
91
|
+
this.snkItemSelected.emit(itemName);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
getFilterItems() {
|
95
|
+
const items = this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
|
96
|
+
if (items.length === 0) {
|
97
|
+
return h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty" }, this.emptyText);
|
98
|
+
}
|
99
|
+
const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
|
100
|
+
if (hideItems) {
|
101
|
+
items.splice(MAX_FILTERS);
|
102
|
+
items.push({ kind: "INTERNAL", label: "Mostrar mais", iconName: "dots-horizontal", name: SHOW_MORE_ITEM_NAME, iconClass: "snk-filter-bar__filter-list-item__icon--secondary", labelClass: "snk-filter-bar__filter-list-item__label--secondary" });
|
103
|
+
}
|
104
|
+
this._selectableItemsCount = 0;
|
105
|
+
return h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
|
106
|
+
}
|
107
|
+
getFooterItems() {
|
108
|
+
return this.items.filter(item => item.kind === "FOOTER");
|
109
|
+
}
|
110
|
+
keyDownHandler(event) {
|
111
|
+
switch (event.key) {
|
112
|
+
case "ArrowDown":
|
113
|
+
this.changePreselection(this._preselection + 1);
|
114
|
+
//Paramos a propagação do evento para evitar scroll indesejado
|
115
|
+
event.stopImmediatePropagation();
|
116
|
+
event.stopPropagation();
|
117
|
+
event.preventDefault();
|
118
|
+
break;
|
119
|
+
case "ArrowUp":
|
120
|
+
this.changePreselection(this._preselection - 1);
|
121
|
+
//Paramos a propagação do evento para evitar scroll indesejado
|
122
|
+
event.stopImmediatePropagation();
|
123
|
+
event.stopPropagation();
|
124
|
+
event.preventDefault();
|
125
|
+
break;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
changePreselection(newSelection) {
|
129
|
+
if (newSelection < 0) {
|
130
|
+
newSelection = this._selectableItemsCount;
|
131
|
+
}
|
132
|
+
this._preselection = newSelection > this._selectableItemsCount ? 0 : newSelection;
|
133
|
+
if (this._preselection === 0) {
|
134
|
+
this._filterInput.setFocus();
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
const item = this._element.querySelector(`#filter-item${this._preselection}`);
|
138
|
+
if (item) {
|
139
|
+
item.focus();
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
render() {
|
144
|
+
return (h(Host, { class: "ez-flex ez-flex--column" }, h("ez-button", { class: this.buttonClass, label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, h("slot", { name: "leftIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem }, h("ez-filter-input", { ref: ref => this._filterInput = ref, "data-element-id": "serachFilters", mode: "slim", label: this.findFilterText, value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail, onFocus: () => this._preselection = 0 }), this.getFilterItems(), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
|
145
|
+
}
|
146
|
+
get _element() { return this; }
|
147
|
+
}, [4, "snk-filter-list", {
|
148
|
+
"label": [1],
|
149
|
+
"iconName": [1, "icon-name"],
|
150
|
+
"items": [16],
|
151
|
+
"getMessage": [16],
|
152
|
+
"emptyText": [1, "empty-text"],
|
153
|
+
"findFilterText": [1, "find-filter-text"],
|
154
|
+
"buttonClass": [1, "button-class"],
|
155
|
+
"_filterArgument": [32],
|
156
|
+
"_showAll": [32],
|
157
|
+
"hideDetail": [64]
|
158
|
+
}, [[2, "keydown", "keyDownHandler"]]]);
|
159
|
+
function defineCustomElement$1() {
|
160
|
+
if (typeof customElements === "undefined") {
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
const components = ["snk-filter-list"];
|
164
|
+
components.forEach(tagName => { switch (tagName) {
|
165
|
+
case "snk-filter-list":
|
166
|
+
if (!customElements.get(tagName)) {
|
167
|
+
customElements.define(tagName, SnkFilterList$1);
|
168
|
+
}
|
169
|
+
break;
|
170
|
+
} });
|
171
|
+
}
|
2
172
|
|
3
173
|
const SnkFilterList = SnkFilterList$1;
|
4
174
|
const defineCustomElement = defineCustomElement$1;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
2
|
+
|
3
|
+
interface SnkFilterModalItem extends Components.SnkFilterModalItem, HTMLElement {}
|
4
|
+
export const SnkFilterModalItem: {
|
5
|
+
prototype: SnkFilterModalItem;
|
6
|
+
new (): SnkFilterModalItem;
|
7
|
+
};
|
8
|
+
/**
|
9
|
+
* Used to define this component and all nested components recursively.
|
10
|
+
*/
|
11
|
+
export const defineCustomElement: () => void;
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
2
|
+
import { ElementIDUtils } from '@sankhyalabs/core';
|
3
|
+
import { F as FilterItemType } from './filter-item-type.enum.js';
|
4
|
+
import { E as EPresentationMode } from './presentationMode.js';
|
5
|
+
|
6
|
+
var FilterType;
|
7
|
+
(function (FilterType) {
|
8
|
+
FilterType["QUICK_FILTER"] = "QUICK_FILTER";
|
9
|
+
FilterType["CUSTOM_FILTER"] = "CUSTOM_FILTER";
|
10
|
+
FilterType["OTHER_FILTERS"] = "OTHER_FILTERS";
|
11
|
+
})(FilterType || (FilterType = {}));
|
12
|
+
const FilterType$1 = FilterType;
|
13
|
+
|
14
|
+
const snkFilterModalItemCss = ".grow{flex-grow:1}";
|
15
|
+
|
16
|
+
const SnkFilterModalItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
17
|
+
constructor() {
|
18
|
+
super();
|
19
|
+
this.__registerHost();
|
20
|
+
this.filterChange = createEvent(this, "filterChange", 7);
|
21
|
+
this.filterItem = undefined;
|
22
|
+
}
|
23
|
+
observeFilterItem(newValue) {
|
24
|
+
this.filterChange.emit(newValue);
|
25
|
+
}
|
26
|
+
getContentEditorConfig() {
|
27
|
+
const variations = { presentationMode: EPresentationMode.MODAL };
|
28
|
+
switch (this.filterItem.type) {
|
29
|
+
case FilterItemType.BINARY_SELECT:
|
30
|
+
return { tag: "snk-filter-binary-select", variations };
|
31
|
+
case FilterItemType.MULTI_SELECT:
|
32
|
+
return { tag: "snk-filter-multi-select" };
|
33
|
+
case FilterItemType.PERIOD:
|
34
|
+
return { tag: "snk-filter-period", variations };
|
35
|
+
case FilterItemType.SEARCH:
|
36
|
+
return { tag: "snk-filter-search" };
|
37
|
+
case FilterItemType.NUMBER:
|
38
|
+
return { tag: "snk-filter-number" };
|
39
|
+
case FilterItemType.PERSONALIZED:
|
40
|
+
return { tag: "snk-filter-personalized" };
|
41
|
+
case FilterItemType.MULTI_LIST:
|
42
|
+
return { tag: "snk-entity-list" };
|
43
|
+
}
|
44
|
+
return { tag: "snk-filter-text" };
|
45
|
+
}
|
46
|
+
updateFilterValue(newValue) {
|
47
|
+
this.filterItem = Object.assign(Object.assign({}, this.filterItem), { value: newValue });
|
48
|
+
}
|
49
|
+
canShowDetailModal() {
|
50
|
+
return this.filterItem.filterType !== FilterType$1.OTHER_FILTERS && this.filterItem.type !== FilterItemType.BINARY_SELECT;
|
51
|
+
}
|
52
|
+
componentDidLoad() {
|
53
|
+
if (this._element) {
|
54
|
+
ElementIDUtils.addIDInfo(this._element);
|
55
|
+
const dataElementIdDoFilterItem = this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
|
56
|
+
this._idContentEditor = `${dataElementIdDoFilterItem}_${this.filterItem.id}`;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
render() {
|
60
|
+
const { tag: ContentEditor, variations } = this.getContentEditorConfig();
|
61
|
+
return (h(Host, null, h("div", { class: "ez-flex ez-flex--column grow" }, this.canShowDetailModal() && (h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header" }, this.filterItem.detailModal))), h(ContentEditor, Object.assign({ config: this.filterItem, value: this.filterItem.value, onValueChanged: (event) => this.updateFilterValue(event.detail), "data-element-id": this._idContentEditor }, variations)))));
|
62
|
+
}
|
63
|
+
get _element() { return this; }
|
64
|
+
static get watchers() { return {
|
65
|
+
"filterItem": ["observeFilterItem"]
|
66
|
+
}; }
|
67
|
+
static get style() { return snkFilterModalItemCss; }
|
68
|
+
}, [0, "snk-filter-modal-item", {
|
69
|
+
"filterItem": [1040]
|
70
|
+
}]);
|
71
|
+
function defineCustomElement() {
|
72
|
+
if (typeof customElements === "undefined") {
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
const components = ["snk-filter-modal-item"];
|
76
|
+
components.forEach(tagName => { switch (tagName) {
|
77
|
+
case "snk-filter-modal-item":
|
78
|
+
if (!customElements.get(tagName)) {
|
79
|
+
customElements.define(tagName, SnkFilterModalItem);
|
80
|
+
}
|
81
|
+
break;
|
82
|
+
} });
|
83
|
+
}
|
84
|
+
|
85
|
+
export { FilterType$1 as F, SnkFilterModalItem as S, defineCustomElement as d };
|