@sankhyalabs/sankhyablocks 1.3.31-beta.2 → 1.3.31-beta.20
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-7717f1e4.js +326 -0
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/css-shim-b8158822.js +6 -0
- package/dist/cjs/dom-36862b77.js +75 -0
- package/dist/cjs/filter-item-type.enum-e2e1bc5b.js +14 -0
- package/dist/cjs/index-02201bc9.js +2397 -0
- package/dist/cjs/index-b0b676c5.js +3298 -0
- package/dist/cjs/loader.cjs.js +19 -3
- package/dist/cjs/sankhyablocks.cjs.js +117 -5
- package/dist/cjs/shadow-css-346c0795.js +389 -0
- package/dist/cjs/snk-application.cjs.entry.js +1041 -177
- package/dist/cjs/snk-crud.cjs.entry.js +65 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +276 -0
- package/dist/cjs/snk-filter-bar.cjs.entry.js +265 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +47 -0
- package/dist/cjs/snk-filter-detail.cjs.entry.js +49 -0
- package/dist/cjs/snk-filter-item.cjs.entry.js +143 -0
- package/dist/cjs/snk-filter-list.cjs.entry.js +91 -0
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +23 -0
- package/dist/cjs/snk-filter-number.cjs.entry.js +24 -0
- package/dist/cjs/snk-filter-period.cjs.entry.js +26 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +44 -0
- package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
- package/dist/cjs/snk-form.cjs.entry.js +133 -0
- package/dist/cjs/snk-grid.cjs.entry.js +79 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +10 -7
- package/dist/cjs/snk-taskbar.cjs.entry.js +160 -0
- package/dist/cjs/taskbar-elements-283c737e.js +93 -0
- package/dist/cjs/taskbar-processor-6bd0d35c.js +47 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
- package/dist/collection/collection-manifest.json +17 -2
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +9 -2
- package/dist/collection/components/snk-application/snk-application.js +1061 -629
- package/dist/collection/components/snk-crud/snk-crud.css +6 -0
- package/dist/collection/components/snk-crud/snk-crud.js +176 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +540 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +88 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +64 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +65 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +69 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +118 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +10 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +118 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +244 -0
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +233 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +114 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +323 -0
- package/dist/collection/components/snk-form/snk-form.css +34 -0
- package/dist/collection/components/snk-form/snk-form.js +258 -0
- package/dist/collection/components/snk-grid/snk-grid.css +18 -0
- package/dist/collection/components/snk-grid/snk-grid.js +183 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +56 -13
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +81 -76
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +86 -0
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +43 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +307 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +38 -13
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +388 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +47 -0
- package/dist/collection/lib/index.js +1 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +121 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +23 -0
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +18 -0
- package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +17 -0
- package/dist/components/SnkMessageBuilder.js +303 -0
- package/dist/components/filter-item-type.enum.js +12 -0
- package/dist/components/index.d.ts +18 -5
- package/dist/components/index.js +22 -0
- package/dist/components/index2.js +2384 -0
- package/dist/components/snk-application2.js +1019 -148
- package/dist/components/snk-crud.d.ts +11 -0
- package/dist/components/snk-crud.js +127 -0
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +299 -0
- package/dist/components/snk-filter-bar.d.ts +11 -0
- package/dist/components/snk-filter-bar.js +6 -0
- package/dist/components/snk-filter-bar2.js +296 -0
- package/dist/components/snk-filter-binary-select.d.ts +11 -0
- package/dist/components/snk-filter-binary-select.js +63 -0
- package/dist/components/snk-filter-detail.d.ts +11 -0
- package/dist/components/snk-filter-detail.js +6 -0
- package/dist/components/snk-filter-detail2.js +63 -0
- package/dist/components/snk-filter-item.d.ts +11 -0
- package/dist/components/snk-filter-item.js +6 -0
- package/dist/components/snk-filter-item2.js +164 -0
- package/dist/components/snk-filter-list.d.ts +11 -0
- package/dist/components/snk-filter-list.js +6 -0
- package/dist/components/snk-filter-list2.js +111 -0
- package/dist/components/snk-filter-multi-select.d.ts +11 -0
- package/dist/components/snk-filter-multi-select.js +39 -0
- package/dist/components/snk-filter-number.d.ts +11 -0
- package/dist/components/snk-filter-number.js +40 -0
- package/dist/components/snk-filter-period.d.ts +11 -0
- package/dist/components/snk-filter-period.js +42 -0
- package/dist/components/snk-filter-search.d.ts +11 -0
- package/dist/components/snk-filter-search.js +62 -0
- package/dist/components/snk-filter-text.d.ts +11 -0
- package/dist/components/snk-filter-text.js +38 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +6 -0
- package/dist/components/snk-form2.js +159 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +6 -0
- package/dist/components/snk-grid2.js +126 -0
- package/dist/components/snk-pesquisa2.js +6 -3
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +264 -0
- package/dist/components/taskbar-processor.js +45 -0
- package/dist/components/teste-pesquisa.js +1 -1
- package/dist/esm/SnkMessageBuilder-a7da466b.js +303 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/css-shim-b3f2ee8d.js +4 -0
- package/dist/esm/dom-665d6011.js +73 -0
- package/dist/esm/filter-item-type.enum-61fbf80a.js +12 -0
- package/dist/esm/index-2b4d2d14.js +3262 -0
- package/dist/esm/index-e5b61043.js +2384 -0
- package/dist/esm/loader.js +19 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/sankhyablocks.js +117 -5
- package/dist/esm/shadow-css-b18e99d7.js +387 -0
- package/dist/esm/snk-application.entry.js +1013 -149
- package/dist/esm/snk-crud.entry.js +61 -0
- package/dist/esm/snk-data-unit.entry.js +272 -0
- package/dist/esm/snk-filter-bar.entry.js +261 -0
- package/dist/esm/snk-filter-binary-select.entry.js +43 -0
- package/dist/esm/snk-filter-detail.entry.js +45 -0
- package/dist/esm/snk-filter-item.entry.js +139 -0
- package/dist/esm/snk-filter-list.entry.js +87 -0
- package/dist/esm/snk-filter-multi-select.entry.js +19 -0
- package/dist/esm/snk-filter-number.entry.js +20 -0
- package/dist/esm/snk-filter-period.entry.js +22 -0
- package/dist/esm/snk-filter-search.entry.js +40 -0
- package/dist/esm/snk-filter-text.entry.js +18 -0
- package/dist/esm/snk-form.entry.js +129 -0
- package/dist/esm/snk-grid.entry.js +75 -0
- package/dist/esm/snk-pesquisa.entry.js +7 -4
- package/dist/esm/snk-taskbar.entry.js +156 -0
- package/dist/esm/taskbar-elements-35d64ff9.js +90 -0
- package/dist/esm/taskbar-processor-aa6772c9.js +45 -0
- package/dist/esm/teste-pesquisa.entry.js +2 -2
- package/dist/sankhyablocks/SnkMessageBuilder-a7da466b.js +303 -0
- package/dist/sankhyablocks/app-globals-0f993ce5.js +3 -0
- package/dist/sankhyablocks/css-shim-b3f2ee8d.js +4 -0
- package/dist/sankhyablocks/dom-665d6011.js +73 -0
- package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +12 -0
- package/dist/sankhyablocks/index-2b4d2d14.js +3262 -0
- package/dist/sankhyablocks/index-e5b61043.js +2384 -0
- package/dist/sankhyablocks/index.esm.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +129 -1
- package/dist/sankhyablocks/shadow-css-b18e99d7.js +387 -0
- package/dist/sankhyablocks/snk-application.entry.js +8452 -0
- package/dist/sankhyablocks/snk-crud.entry.js +61 -0
- package/dist/sankhyablocks/snk-data-unit.entry.js +272 -0
- package/dist/sankhyablocks/snk-filter-bar.entry.js +261 -0
- package/dist/sankhyablocks/snk-filter-binary-select.entry.js +43 -0
- package/dist/sankhyablocks/snk-filter-detail.entry.js +45 -0
- package/dist/sankhyablocks/snk-filter-item.entry.js +139 -0
- package/dist/sankhyablocks/snk-filter-list.entry.js +87 -0
- package/dist/sankhyablocks/snk-filter-multi-select.entry.js +19 -0
- package/dist/sankhyablocks/snk-filter-number.entry.js +20 -0
- package/dist/sankhyablocks/snk-filter-period.entry.js +22 -0
- package/dist/sankhyablocks/snk-filter-search.entry.js +40 -0
- package/dist/sankhyablocks/snk-filter-text.entry.js +18 -0
- package/dist/sankhyablocks/snk-form.entry.js +129 -0
- package/dist/sankhyablocks/snk-grid.entry.js +75 -0
- package/dist/sankhyablocks/snk-pesquisa.entry.js +311 -0
- package/dist/sankhyablocks/snk-taskbar.entry.js +156 -0
- package/dist/sankhyablocks/taskbar-elements-35d64ff9.js +90 -0
- package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +45 -0
- package/dist/sankhyablocks/teste-pesquisa.entry.js +33 -0
- package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
- package/dist/types/components/snk-application/snk-application.d.ts +141 -20
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +13 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +14 -0
- package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +40 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +46 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +29 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +12 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +84 -0
- package/dist/types/components.d.ts +662 -9
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +7 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +5 -0
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +3 -3
- package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +8 -0
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
- package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/loader/package.json +1 -0
- package/package.json +5 -5
- package/react/components.d.ts +0 -2
- package/react/components.js +0 -2
- package/react/components.js.map +1 -1
- package/dist/cjs/index-1133bc2a.js +0 -1235
- package/dist/esm/index-ffda6382.js +0 -1208
- package/dist/sankhyablocks/p-2a7b4cb3.entry.js +0 -1
- package/dist/sankhyablocks/p-d62412bb.entry.js +0 -1
- package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { b as DataType, t as toString, a as ApplicationContext, E as ErrorException, O as ObjectUtils } from './index2.js';
|
|
3
|
+
import { F as FilterItemType } from './filter-item-type.enum.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './snk-filter-detail2.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './snk-filter-item2.js';
|
|
6
|
+
import { d as defineCustomElement$1 } from './snk-filter-list2.js';
|
|
7
|
+
|
|
8
|
+
const snkFilterBarCss = ".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(--more-visible, 1);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;flex-grow:0}.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)}.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.preselected.sc-snk-filter-bar{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%}";
|
|
9
|
+
|
|
10
|
+
const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
|
|
11
|
+
const DEFAULT_FILTER = "DEFAULT_FILTER";
|
|
12
|
+
const CLEAR_ALL_FILTERS = "CLEAR_ALL_FILTERS";
|
|
13
|
+
const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.__registerHost();
|
|
17
|
+
this._updateSequence = [];
|
|
18
|
+
this._calculateSortIndex = (item) => {
|
|
19
|
+
let index = item.hardFixed ? 1000000 : 0;
|
|
20
|
+
//campos Hard Fixed não variam a ordem
|
|
21
|
+
if (!item.hardFixed) {
|
|
22
|
+
index += item.fixed ? 100000 : 0;
|
|
23
|
+
index += item.value == undefined ? 0 : 10000;
|
|
24
|
+
index += this._updateSequence.lastIndexOf(item.id) + 1;
|
|
25
|
+
}
|
|
26
|
+
return index;
|
|
27
|
+
};
|
|
28
|
+
this._filtersComparator = (a, b) => {
|
|
29
|
+
return this._calculateSortIndex(b) - this._calculateSortIndex(a);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
34
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
35
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
36
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
|
|
37
|
+
*/
|
|
38
|
+
getMessage(key, params) {
|
|
39
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
40
|
+
}
|
|
41
|
+
getFilter(_dataUnit) {
|
|
42
|
+
const filters = [];
|
|
43
|
+
this.filterConfig.filter(item => item.value).forEach(item => {
|
|
44
|
+
const filter = this.buildDUFilter(item);
|
|
45
|
+
if (filter) {
|
|
46
|
+
filters.push(filter);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return filters;
|
|
50
|
+
}
|
|
51
|
+
buildDUFilter(item) {
|
|
52
|
+
const { id, value, type, props, visible } = item;
|
|
53
|
+
if (value && visible) {
|
|
54
|
+
if (type === FilterItemType.BINARY_SELECT) {
|
|
55
|
+
const options = props.options;
|
|
56
|
+
const selectedOption = options.find(opt => opt.name === value);
|
|
57
|
+
//FIXME: ajustar o backend para não exigir parametros
|
|
58
|
+
return { name: id, expression: selectedOption.expression, params: [] };
|
|
59
|
+
}
|
|
60
|
+
if (type === FilterItemType.MULTI_SELECT) {
|
|
61
|
+
return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
|
|
62
|
+
}
|
|
63
|
+
if (type === FilterItemType.PERIOD) {
|
|
64
|
+
const { end, start } = value;
|
|
65
|
+
const params = [];
|
|
66
|
+
let expression;
|
|
67
|
+
if (end && start) {
|
|
68
|
+
expression = props.expression.fullfill;
|
|
69
|
+
params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
if (start) {
|
|
73
|
+
expression = props.expression.onlystart;
|
|
74
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
expression = props.expression.onlyend;
|
|
78
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { name: id, expression, params };
|
|
82
|
+
}
|
|
83
|
+
if (type === FilterItemType.SEARCH) {
|
|
84
|
+
const expression = props.expression;
|
|
85
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
|
|
86
|
+
}
|
|
87
|
+
if (type === FilterItemType.TEXT) {
|
|
88
|
+
const expression = props.expression;
|
|
89
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
|
|
90
|
+
}
|
|
91
|
+
if (type === FilterItemType.NUMBER) {
|
|
92
|
+
const expression = props.expression;
|
|
93
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
|
|
94
|
+
}
|
|
95
|
+
//No mapeamento dos outros tipos precisamos saber o tipo de dado.
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
componentWillLoad() {
|
|
100
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
101
|
+
if (this._application) {
|
|
102
|
+
this._application.getFilterBarConfig()
|
|
103
|
+
.then((filters) => {
|
|
104
|
+
this.filterConfig = filters;
|
|
105
|
+
})
|
|
106
|
+
.catch(reason => {
|
|
107
|
+
throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (this.dataUnit == undefined) {
|
|
111
|
+
let parent = this._element.parentElement;
|
|
112
|
+
while (parent) {
|
|
113
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
114
|
+
const snkDataUnit = parent;
|
|
115
|
+
this.dataUnit = snkDataUnit.dataUnit;
|
|
116
|
+
if (this.dataUnit) {
|
|
117
|
+
this.dataUnit.addFilterProvider(this);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
121
|
+
this.dataUnit = evt.detail;
|
|
122
|
+
this.dataUnit.addFilterProvider(this);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
parent = parent.parentElement;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
getFilterItems() {
|
|
132
|
+
const pinnedItems = [];
|
|
133
|
+
const unpinnedItems = [];
|
|
134
|
+
this.filterConfig
|
|
135
|
+
.filter(item => item.visible)
|
|
136
|
+
.sort((a, b) => this._filtersComparator(a, b))
|
|
137
|
+
.forEach((item, index) => {
|
|
138
|
+
const filterItem = (h("snk-filter-item", { id: `filter-${item.id}`, config: this.normalizeItem(item), class: index > 0 ? "ez-padding-left--medium" : "", getMessage: (key, props) => this.getMessage(key, props), key: item.id }));
|
|
139
|
+
if (item.fixed || item.hardFixed) {
|
|
140
|
+
pinnedItems.push(filterItem);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
unpinnedItems.push(filterItem);
|
|
144
|
+
}
|
|
145
|
+
return filterItem;
|
|
146
|
+
});
|
|
147
|
+
const elements = [];
|
|
148
|
+
elements.push(...pinnedItems);
|
|
149
|
+
if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
|
|
150
|
+
elements.push(h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
|
|
151
|
+
}
|
|
152
|
+
elements.push(...unpinnedItems);
|
|
153
|
+
return elements;
|
|
154
|
+
}
|
|
155
|
+
calculateUpdateSequence(item) {
|
|
156
|
+
if (item) {
|
|
157
|
+
this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
|
|
158
|
+
this._updateSequence.push(item.id);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
filterChangeListener(evt) {
|
|
162
|
+
this.updateFilter(evt.detail);
|
|
163
|
+
}
|
|
164
|
+
normalizeItem(item) {
|
|
165
|
+
const normalized = Object.assign({}, item);
|
|
166
|
+
const optionals = ["props", "value", "hardFixed", "fixed"];
|
|
167
|
+
optionals.forEach(prop => {
|
|
168
|
+
if (normalized[prop] == undefined) {
|
|
169
|
+
delete normalized[prop];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
if (item.value === "") {
|
|
173
|
+
delete item.value;
|
|
174
|
+
}
|
|
175
|
+
return normalized;
|
|
176
|
+
}
|
|
177
|
+
updateFilter(newItem, clear = false) {
|
|
178
|
+
let upToDate = false;
|
|
179
|
+
this.filterConfig = this.filterConfig.map(item => {
|
|
180
|
+
if (clear) {
|
|
181
|
+
if (item.value != undefined) {
|
|
182
|
+
this.calculateUpdateSequence(item);
|
|
183
|
+
upToDate = true;
|
|
184
|
+
}
|
|
185
|
+
return Object.assign(Object.assign({}, item), { value: undefined });
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
if (item.id === newItem.id) {
|
|
189
|
+
const normalizedOne = this.normalizeItem(item);
|
|
190
|
+
const normalizedTwo = this.normalizeItem(newItem);
|
|
191
|
+
if (ObjectUtils.objectToString(normalizedOne) != ObjectUtils.objectToString(normalizedTwo)) {
|
|
192
|
+
this.calculateUpdateSequence(item);
|
|
193
|
+
}
|
|
194
|
+
upToDate = ObjectUtils.objectToString(normalizedOne.value) !== ObjectUtils.objectToString(normalizedTwo.value);
|
|
195
|
+
return newItem;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return item;
|
|
199
|
+
});
|
|
200
|
+
if (upToDate) {
|
|
201
|
+
this.dataUnit.loadData();
|
|
202
|
+
}
|
|
203
|
+
return upToDate;
|
|
204
|
+
}
|
|
205
|
+
getAddListItems() {
|
|
206
|
+
const hiddenItems = this.filterConfig
|
|
207
|
+
.filter(item => !item.visible)
|
|
208
|
+
.sort(this._filtersComparator);
|
|
209
|
+
return hiddenItems.map(filter => {
|
|
210
|
+
return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
|
|
211
|
+
}).concat([
|
|
212
|
+
{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" },
|
|
213
|
+
{ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" }
|
|
214
|
+
]);
|
|
215
|
+
}
|
|
216
|
+
getActiveClass() {
|
|
217
|
+
const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
|
|
218
|
+
return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
|
|
219
|
+
}
|
|
220
|
+
getAppliedListItems() {
|
|
221
|
+
const appliedItems = this.filterConfig
|
|
222
|
+
.filter(item => item.value != undefined)
|
|
223
|
+
.sort(this._filtersComparator);
|
|
224
|
+
return appliedItems.map(filter => {
|
|
225
|
+
return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
|
|
226
|
+
}).concat([
|
|
227
|
+
{ name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
|
|
228
|
+
]);
|
|
229
|
+
}
|
|
230
|
+
addFilterHandler(itemName) {
|
|
231
|
+
const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
|
|
232
|
+
if (filterItem) {
|
|
233
|
+
this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
|
|
234
|
+
window.requestAnimationFrame(() => {
|
|
235
|
+
const itemElement = this._element.querySelector("#filter-" + itemName);
|
|
236
|
+
if (itemElement) {
|
|
237
|
+
itemElement.showUp();
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
appliedFilterHandler(itemName) {
|
|
243
|
+
if (itemName === CLEAR_ALL_FILTERS) {
|
|
244
|
+
if (this.updateFilter(null, true)) {
|
|
245
|
+
this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
const itemElement = this._element.querySelector("#filter-" + itemName);
|
|
250
|
+
if (itemElement) {
|
|
251
|
+
itemElement.showUp(true);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
render() {
|
|
256
|
+
if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
return (h(Host, null, h("ez-scroller", { direction: "horizontal" }, this.getFilterItems()), h("snk-filter-list", { items: this.getAppliedListItems(), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyAppliedFiltersList"), findFilterText: this.getMessage("snkFilterBar.findFilter"), iconName: "filter", class: "ez-padding-left--medium", buttonClass: this.getActiveClass(), onSnkItemSelected: evt => this.appliedFilterHandler(evt.detail) }), h("snk-filter-list", { items: this.getAddListItems(), label: this.getMessage("snkFilterBar.addFilter"), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyFiltersList"), findFilterText: this.getMessage("snkFilterBar.findField"), class: "ez-padding-left--medium", onSnkItemSelected: evt => this.addFilterHandler(evt.detail) }, h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
|
|
260
|
+
}
|
|
261
|
+
get _element() { return this; }
|
|
262
|
+
static get style() { return snkFilterBarCss; }
|
|
263
|
+
}, [2, "snk-filter-bar", {
|
|
264
|
+
"dataUnit": [1040],
|
|
265
|
+
"filterConfig": [1040]
|
|
266
|
+
}, [[0, "filterChange", "filterChangeListener"]]]);
|
|
267
|
+
function defineCustomElement() {
|
|
268
|
+
if (typeof customElements === "undefined") {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const components = ["snk-filter-bar", "snk-filter-detail", "snk-filter-item", "snk-filter-list"];
|
|
272
|
+
components.forEach(tagName => { switch (tagName) {
|
|
273
|
+
case "snk-filter-bar":
|
|
274
|
+
if (!customElements.get(tagName)) {
|
|
275
|
+
customElements.define(tagName, SnkFilterBar);
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
case "snk-filter-detail":
|
|
279
|
+
if (!customElements.get(tagName)) {
|
|
280
|
+
defineCustomElement$3();
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case "snk-filter-item":
|
|
284
|
+
if (!customElements.get(tagName)) {
|
|
285
|
+
defineCustomElement$2();
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
case "snk-filter-list":
|
|
289
|
+
if (!customElements.get(tagName)) {
|
|
290
|
+
defineCustomElement$1();
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
} });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export { SnkFilterBar as S, defineCustomElement as d };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkFilterBinarySelect extends Components.SnkFilterBinarySelect, HTMLElement {}
|
|
4
|
+
export const SnkFilterBinarySelect: {
|
|
5
|
+
prototype: SnkFilterBinarySelect;
|
|
6
|
+
new (): SnkFilterBinarySelect;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { F as FilterItemType } from './filter-item-type.enum.js';
|
|
3
|
+
|
|
4
|
+
const SnkFilterBinarySelect$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.__registerHost();
|
|
8
|
+
}
|
|
9
|
+
isSelected(option) {
|
|
10
|
+
return this.value == undefined || this.value === option;
|
|
11
|
+
}
|
|
12
|
+
ezChangeListener(evt) {
|
|
13
|
+
if (!evt.detail) {
|
|
14
|
+
this.assertCheckedOption(evt.target);
|
|
15
|
+
}
|
|
16
|
+
this.updateValue();
|
|
17
|
+
}
|
|
18
|
+
assertCheckedOption(updatingCheck) {
|
|
19
|
+
if (updatingCheck === this._checkOne) {
|
|
20
|
+
this._checkTwo.value = true;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this._checkOne.value = true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
updateValue() {
|
|
27
|
+
if (!this._checkOne.value || !this._checkTwo.value) {
|
|
28
|
+
const [optOne, optTwo] = this.config.props.options;
|
|
29
|
+
this.value = this._checkOne.value ? optOne.name : optTwo.name;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.value = undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
if (!this.config || this.config.type !== FilterItemType.BINARY_SELECT) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const [optOne, optTwo] = this.config.props.options;
|
|
40
|
+
return (h(Host, null, h("ez-check", { label: optOne.label, class: "sc-snk-filter-bar editor__ez-check", ref: (ref) => this._checkOne = ref, value: this.isSelected(optOne.name) }), h("ez-check", { label: optTwo.label, class: "sc-snk-filter-bar editor__ez-check", ref: (ref) => this._checkTwo = ref, value: this.isSelected(optTwo.name) })));
|
|
41
|
+
}
|
|
42
|
+
}, [0, "snk-filter-binary-select", {
|
|
43
|
+
"value": [1544],
|
|
44
|
+
"config": [16]
|
|
45
|
+
}, [[0, "ezChange", "ezChangeListener"]]]);
|
|
46
|
+
function defineCustomElement$1() {
|
|
47
|
+
if (typeof customElements === "undefined") {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const components = ["snk-filter-binary-select"];
|
|
51
|
+
components.forEach(tagName => { switch (tagName) {
|
|
52
|
+
case "snk-filter-binary-select":
|
|
53
|
+
if (!customElements.get(tagName)) {
|
|
54
|
+
customElements.define(tagName, SnkFilterBinarySelect$1);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
} });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const SnkFilterBinarySelect = SnkFilterBinarySelect$1;
|
|
61
|
+
const defineCustomElement = defineCustomElement$1;
|
|
62
|
+
|
|
63
|
+
export { SnkFilterBinarySelect, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkFilterDetail extends Components.SnkFilterDetail, HTMLElement {}
|
|
4
|
+
export const SnkFilterDetail: {
|
|
5
|
+
prototype: SnkFilterDetail;
|
|
6
|
+
new (): SnkFilterDetail;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { F as FilterItemType } from './filter-item-type.enum.js';
|
|
3
|
+
|
|
4
|
+
const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.__registerHost();
|
|
8
|
+
this.filterChange = createEvent(this, "filterChange", 7);
|
|
9
|
+
}
|
|
10
|
+
changeConfig(newConfig) {
|
|
11
|
+
this.filterChange.emit(newConfig);
|
|
12
|
+
}
|
|
13
|
+
getContentEditor() {
|
|
14
|
+
switch (this.config.type) {
|
|
15
|
+
case FilterItemType.BINARY_SELECT:
|
|
16
|
+
return "snk-filter-binary-select";
|
|
17
|
+
case FilterItemType.MULTI_SELECT:
|
|
18
|
+
return "snk-filter-multi-select";
|
|
19
|
+
case FilterItemType.PERIOD:
|
|
20
|
+
return "snk-filter-period";
|
|
21
|
+
case FilterItemType.SEARCH:
|
|
22
|
+
return "snk-filter-search";
|
|
23
|
+
case FilterItemType.NUMBER:
|
|
24
|
+
return "snk-filter-number";
|
|
25
|
+
}
|
|
26
|
+
return "snk-filter-text";
|
|
27
|
+
}
|
|
28
|
+
removeItem() {
|
|
29
|
+
this.changeConfig(Object.assign(Object.assign({}, this.config), { visible: false, fixed: false, value: undefined }));
|
|
30
|
+
}
|
|
31
|
+
getPopUpHeaderButtons() {
|
|
32
|
+
if (this.config.hardFixed) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return ([
|
|
36
|
+
h("ez-icon", { title: this.getMessage("snkFilterBar.removeFilter"), class: "sc-snk-filter-bar snk-filter-item__editor-header-button", iconName: "delete", onClick: () => this.removeItem() }),
|
|
37
|
+
h("ez-icon", { title: this.getMessage(this.config.fixed ? "snkFilterBar.unpinFilter" : "snkFilterBar.pinFilter"), class: "ez-margin-left--small sc-snk-filter-bar snk-filter-item__editor-header-button", iconName: this.config.fixed ? "un-pin" : "push-pin", onClick: () => this.changeConfig(Object.assign(Object.assign({}, this.config), { fixed: !this.config.fixed })) })
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
const ContentEditor = this.getContentEditor();
|
|
42
|
+
return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header" }, this.config.detailTitle), this.getPopUpHeaderButtons()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config, fix: () => this.keepOpened = true, unfix: () => this.keepOpened = false }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined })) }), h("ez-button", { label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.changeConfig(Object.assign(Object.assign({}, this.config), { value: this._editor["value"] })), class: "ez-button--primary ez-padding-left--medium" }))));
|
|
43
|
+
}
|
|
44
|
+
}, [0, "snk-filter-detail", {
|
|
45
|
+
"config": [1040],
|
|
46
|
+
"keepOpened": [1028, "keep-opened"],
|
|
47
|
+
"getMessage": [16]
|
|
48
|
+
}]);
|
|
49
|
+
function defineCustomElement() {
|
|
50
|
+
if (typeof customElements === "undefined") {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const components = ["snk-filter-detail"];
|
|
54
|
+
components.forEach(tagName => { switch (tagName) {
|
|
55
|
+
case "snk-filter-detail":
|
|
56
|
+
if (!customElements.get(tagName)) {
|
|
57
|
+
customElements.define(tagName, SnkFilterDetail);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
} });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { SnkFilterDetail as S, defineCustomElement as d };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkFilterItem extends Components.SnkFilterItem, HTMLElement {}
|
|
4
|
+
export const SnkFilterItem: {
|
|
5
|
+
prototype: SnkFilterItem;
|
|
6
|
+
new (): SnkFilterItem;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { F as FloatingManager } from './index2.js';
|
|
3
|
+
import { F as FilterItemType } from './filter-item-type.enum.js';
|
|
4
|
+
import { d as defineCustomElement$1 } from './snk-filter-detail2.js';
|
|
5
|
+
|
|
6
|
+
const SnkFilterItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
this.filterChange = createEvent(this, "filterChange", 7);
|
|
11
|
+
this.innerClickCheck = (floatingContainer, node) => {
|
|
12
|
+
if (this._popover.keepOpened) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (node && floatingContainer) {
|
|
16
|
+
if (!node.offsetParent) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
let current = node;
|
|
20
|
+
do {
|
|
21
|
+
if (current === floatingContainer) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
} while ((current = current.offsetParent) != null);
|
|
25
|
+
}
|
|
26
|
+
this.detailIsVisible = false;
|
|
27
|
+
return false;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async showUp(open = false) {
|
|
31
|
+
this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
|
|
32
|
+
if (open) {
|
|
33
|
+
window.requestAnimationFrame(() => {
|
|
34
|
+
this.showDetail();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
showDetail() {
|
|
39
|
+
this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck, left: this.getScrollOffset() });
|
|
40
|
+
this.detailIsVisible = true;
|
|
41
|
+
}
|
|
42
|
+
getScrollOffset() {
|
|
43
|
+
return `${this._filterItemElement.getBoundingClientRect().left + 12}px`;
|
|
44
|
+
}
|
|
45
|
+
hideDetail() {
|
|
46
|
+
if (this._floatingID != undefined) {
|
|
47
|
+
FloatingManager.close(this._floatingID);
|
|
48
|
+
}
|
|
49
|
+
this._floatingID = undefined;
|
|
50
|
+
this.detailIsVisible = false;
|
|
51
|
+
}
|
|
52
|
+
//---------------------------------------------
|
|
53
|
+
// Event handlers
|
|
54
|
+
//---------------------------------------------
|
|
55
|
+
clickListener(evt) {
|
|
56
|
+
if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
|
|
57
|
+
if (evt.target === this._rightIconElement && this.config.value != undefined) {
|
|
58
|
+
this.filterChange.emit(Object.assign(Object.assign({}, this.config), { value: undefined }));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (this.detailIsVisible) {
|
|
62
|
+
this.hideDetail();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.showDetail();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
evt.preventDefault();
|
|
69
|
+
evt.stopImmediatePropagation();
|
|
70
|
+
evt.stopPropagation();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
mouseDownListener(evt) {
|
|
74
|
+
if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
|
|
75
|
+
evt.preventDefault();
|
|
76
|
+
evt.stopImmediatePropagation();
|
|
77
|
+
evt.stopPropagation();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
getLabel() {
|
|
81
|
+
const { type, value, label, props } = this.config;
|
|
82
|
+
if (value) {
|
|
83
|
+
if (type === FilterItemType.BINARY_SELECT) {
|
|
84
|
+
const [optOne, optTwo] = props.options;
|
|
85
|
+
if (optOne.name === value) {
|
|
86
|
+
return optOne.label;
|
|
87
|
+
}
|
|
88
|
+
if (optTwo.name === value) {
|
|
89
|
+
return optTwo.label;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (type === FilterItemType.MULTI_SELECT) {
|
|
93
|
+
const opt = props.options.find(opt => opt.value === value);
|
|
94
|
+
return `${label}: ${opt.label}`;
|
|
95
|
+
}
|
|
96
|
+
if (type === FilterItemType.PERIOD) {
|
|
97
|
+
const period = value;
|
|
98
|
+
const dateFormater = new Intl.DateTimeFormat("pt-BR");
|
|
99
|
+
if (period.end && period.start) {
|
|
100
|
+
return `${label}: ${dateFormater.format(period.start)} a ${dateFormater.format(period.end)}`;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (period.start) {
|
|
104
|
+
return `${label}: A partir de ${dateFormater.format(period.start)}`;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return `${label}: Até ${dateFormater.format(period.end)}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (type === FilterItemType.SEARCH) {
|
|
112
|
+
return `${label}: ${value.value} - ${value.label}`;
|
|
113
|
+
}
|
|
114
|
+
return `${label}: ${value}`;
|
|
115
|
+
}
|
|
116
|
+
return label;
|
|
117
|
+
}
|
|
118
|
+
componentDidRender() {
|
|
119
|
+
if (this._floatingID == undefined) {
|
|
120
|
+
if (this._popover) {
|
|
121
|
+
this._popover.remove();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
filterChangeListener() {
|
|
126
|
+
this.hideDetail();
|
|
127
|
+
}
|
|
128
|
+
getIconName() {
|
|
129
|
+
if (this.config.value != undefined) {
|
|
130
|
+
return "close";
|
|
131
|
+
}
|
|
132
|
+
return this.detailIsVisible ? "chevron-up" : "chevron-down";
|
|
133
|
+
}
|
|
134
|
+
render() {
|
|
135
|
+
const leftIcon = this.config.type === FilterItemType.PERIOD ? "calendar" : undefined;
|
|
136
|
+
return (h(Host, null, h("ez-chip", { ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.config.value != undefined }, leftIcon ? h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" }) : undefined, h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getIconName(), class: "ez-padding-left--small", slot: "rightIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small", ref: elem => this._popover = elem, key: this.config.id }))));
|
|
137
|
+
}
|
|
138
|
+
get _filterItemElement() { return this; }
|
|
139
|
+
}, [0, "snk-filter-item", {
|
|
140
|
+
"config": [1040],
|
|
141
|
+
"getMessage": [16],
|
|
142
|
+
"detailIsVisible": [32],
|
|
143
|
+
"showUp": [64]
|
|
144
|
+
}, [[2, "click", "clickListener"], [2, "mousedown", "mouseDownListener"], [0, "filterChange", "filterChangeListener"]]]);
|
|
145
|
+
function defineCustomElement() {
|
|
146
|
+
if (typeof customElements === "undefined") {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const components = ["snk-filter-item", "snk-filter-detail"];
|
|
150
|
+
components.forEach(tagName => { switch (tagName) {
|
|
151
|
+
case "snk-filter-item":
|
|
152
|
+
if (!customElements.get(tagName)) {
|
|
153
|
+
customElements.define(tagName, SnkFilterItem);
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case "snk-filter-detail":
|
|
157
|
+
if (!customElements.get(tagName)) {
|
|
158
|
+
defineCustomElement$1();
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
} });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { SnkFilterItem as S, defineCustomElement as d };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkFilterList extends Components.SnkFilterList, HTMLElement {}
|
|
4
|
+
export const SnkFilterList: {
|
|
5
|
+
prototype: SnkFilterList;
|
|
6
|
+
new (): SnkFilterList;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|