@sankhyalabs/ezui 2.10.1 → 2.12.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/ez-actions-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-alert.cjs.entry.js +1 -1
- package/dist/cjs/ez-application.cjs.entry.js +1 -1
- package/dist/cjs/ez-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/ez-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-calendar.cjs.entry.js +1 -1
- package/dist/cjs/ez-card-item.cjs.entry.js +1 -1
- package/dist/cjs/ez-check.cjs.entry.js +1 -1
- package/dist/cjs/ez-chip.cjs.entry.js +1 -1
- package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -1
- package/dist/cjs/ez-combo-box.cjs.entry.js +1 -1
- package/dist/cjs/ez-date-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-date-time-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
- package/dist/cjs/ez-dropdown.cjs.entry.js +503 -0
- package/dist/cjs/ez-file-item.cjs.entry.js +1 -1
- package/dist/cjs/ez-filter-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-form-view.cjs.entry.js +140 -0
- package/dist/cjs/ez-form.cjs.entry.js +228 -330
- package/dist/cjs/ez-grid.cjs.entry.js +1 -1
- package/dist/cjs/ez-icon.cjs.entry.js +1 -1
- package/dist/cjs/ez-list.cjs.entry.js +1 -1
- package/dist/cjs/ez-loading-bar.cjs.entry.js +1 -1
- package/dist/cjs/ez-modal-container.cjs.entry.js +1 -1
- package/dist/cjs/ez-modal.cjs.entry.js +1 -1
- package/dist/cjs/ez-number-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-popover.cjs.entry.js +1 -1
- package/dist/cjs/ez-popup.cjs.entry.js +1 -1
- package/dist/cjs/ez-radio-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-scroller.cjs.entry.js +1 -1
- package/dist/cjs/ez-search.cjs.entry.js +1 -1
- package/dist/cjs/ez-sidebar-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-tabselector.cjs.entry.js +6 -3
- package/dist/cjs/ez-text-area.cjs.entry.js +1 -1
- package/dist/cjs/ez-text-edit.cjs.entry.js +1 -1
- package/dist/cjs/ez-text-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-time-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-toast.cjs.entry.js +1 -1
- package/dist/cjs/ez-tree.cjs.entry.js +109 -22
- package/dist/cjs/ez-upload.cjs.entry.js +1 -1
- package/dist/cjs/ez-view-stack.cjs.entry.js +1 -1
- package/dist/cjs/ezui.cjs.js +2 -2
- package/dist/cjs/{index-8646c40d.js → index-5e208fa5.js} +11 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/ez-dropdown/ez-dropdown.css +349 -0
- package/dist/collection/components/ez-dropdown/ez-dropdown.js +339 -0
- package/dist/collection/components/ez-dropdown/structure/DropdownItem.js +33 -0
- package/dist/collection/components/ez-dropdown/structure/SubmenuControl.js +241 -0
- package/dist/collection/components/ez-form/{structure/FormSheetMetadata.js → FormMetadata.js} +39 -54
- package/dist/collection/components/ez-form/ez-form.css +7 -1
- package/dist/collection/components/ez-form/ez-form.js +128 -19
- package/dist/collection/components/ez-form/interfaces/IDefaultConfig.js +1 -0
- package/dist/collection/components/ez-form/interfaces/IFieldConfig.js +1 -0
- package/dist/collection/components/ez-form/interfaces/IFormConfig.js +1 -0
- package/dist/collection/components/ez-form/interfaces/IFormSheetMetadata.js +1 -0
- package/dist/collection/components/ez-form/interfaces/IInvalidField.js +1 -0
- package/dist/collection/components/ez-form/interfaces/IRecordValidator.js +1 -0
- package/dist/collection/components/ez-form/interfaces/ITabConfig.js +1 -0
- package/dist/collection/components/ez-form/interfaces/IValidationResult.js +1 -0
- package/dist/collection/components/ez-form/interfaces/index.js +1 -0
- package/dist/collection/components/ez-form/store/form.slice.js +6 -2
- package/dist/collection/components/ez-form-view/ez-form-view.css +6 -0
- package/dist/collection/components/ez-form-view/ez-form-view.js +71 -0
- package/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder.js +26 -0
- package/dist/collection/components/{ez-form/fieldbuilder/tpl → ez-form-view/fieldbuilder/templates}/CheckBox.tpl.js +4 -4
- package/dist/collection/components/{ez-form/fieldbuilder/tpl → ez-form-view/fieldbuilder/templates}/ComboBox.tpl.js +2 -2
- package/dist/collection/components/{ez-form/fieldbuilder/tpl → ez-form-view/fieldbuilder/templates}/DateInput.tpl.js +1 -1
- package/dist/collection/components/{ez-form/fieldbuilder/tpl → ez-form-view/fieldbuilder/templates}/NumberInput.tpl.js +3 -3
- package/dist/collection/components/ez-form-view/interfaces/IFormViewField.js +1 -0
- package/dist/collection/components/ez-form-view/interfaces/index.js +1 -0
- package/dist/collection/components/ez-tabselector/ez-tabselector.js +5 -2
- package/dist/collection/components/ez-tree/ez-tree.css +8 -6
- package/dist/collection/components/ez-tree/ez-tree.js +89 -11
- package/dist/collection/components/ez-tree/subcomponents/DefaultTooltipResolver.js +3 -0
- package/dist/collection/components/ez-tree/subcomponents/TreeItem.js +4 -4
- package/dist/collection/components/ez-tree/subcomponents/index.js +1 -0
- package/dist/collection/components/ez-tree/types/Node.js +26 -4
- package/dist/collection/components/ez-tree/types/Tree.js +23 -2
- package/dist/custom-elements/index.d.ts +12 -0
- package/dist/custom-elements/index.js +977 -355
- package/dist/esm/ez-actions-button.entry.js +1 -1
- package/dist/esm/ez-alert.entry.js +1 -1
- package/dist/esm/ez-application.entry.js +1 -1
- package/dist/esm/ez-breadcrumb.entry.js +1 -1
- package/dist/esm/ez-button.entry.js +1 -1
- package/dist/esm/ez-calendar.entry.js +1 -1
- package/dist/esm/ez-card-item.entry.js +1 -1
- package/dist/esm/ez-check.entry.js +1 -1
- package/dist/esm/ez-chip.entry.js +1 -1
- package/dist/esm/ez-collapsible-box.entry.js +1 -1
- package/dist/esm/ez-combo-box.entry.js +1 -1
- package/dist/esm/ez-date-input.entry.js +1 -1
- package/dist/esm/ez-date-time-input.entry.js +1 -1
- package/dist/esm/ez-dialog.entry.js +1 -1
- package/dist/esm/ez-dropdown.entry.js +499 -0
- package/dist/esm/ez-file-item.entry.js +1 -1
- package/dist/esm/ez-filter-input.entry.js +1 -1
- package/dist/esm/ez-form-view.entry.js +136 -0
- package/dist/esm/ez-form.entry.js +229 -331
- package/dist/esm/ez-grid.entry.js +1 -1
- package/dist/esm/ez-icon.entry.js +1 -1
- package/dist/esm/ez-list.entry.js +1 -1
- package/dist/esm/ez-loading-bar.entry.js +1 -1
- package/dist/esm/ez-modal-container.entry.js +1 -1
- package/dist/esm/ez-modal.entry.js +1 -1
- package/dist/esm/ez-number-input.entry.js +1 -1
- package/dist/esm/ez-popover.entry.js +1 -1
- package/dist/esm/ez-popup.entry.js +1 -1
- package/dist/esm/ez-radio-button.entry.js +1 -1
- package/dist/esm/ez-scroller.entry.js +1 -1
- package/dist/esm/ez-search.entry.js +1 -1
- package/dist/esm/ez-sidebar-button.entry.js +1 -1
- package/dist/esm/ez-tabselector.entry.js +6 -3
- package/dist/esm/ez-text-area.entry.js +1 -1
- package/dist/esm/ez-text-edit.entry.js +1 -1
- package/dist/esm/ez-text-input.entry.js +1 -1
- package/dist/esm/ez-time-input.entry.js +1 -1
- package/dist/esm/ez-toast.entry.js +1 -1
- package/dist/esm/ez-tree.entry.js +109 -22
- package/dist/esm/ez-upload.entry.js +1 -1
- package/dist/esm/ez-view-stack.entry.js +1 -1
- package/dist/esm/ezui.js +2 -2
- package/dist/esm/{index-7bc778b3.js → index-c5203f95.js} +11 -0
- package/dist/esm/loader.js +2 -2
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-739d60d1.entry.js → p-0c3f7bf2.entry.js} +1 -1
- package/dist/ezui/{p-171c3236.entry.js → p-0cd0545d.entry.js} +1 -1
- package/dist/ezui/{p-ad5fe50b.entry.js → p-1a27bb9f.entry.js} +1 -1
- package/dist/ezui/{p-3cfefc57.entry.js → p-1b94b9dc.entry.js} +1 -1
- package/dist/ezui/{p-f18f16e0.entry.js → p-20c01161.entry.js} +1 -1
- package/dist/ezui/{p-1634c851.entry.js → p-24717f87.entry.js} +1 -1
- package/dist/ezui/{p-7e496975.entry.js → p-3320768e.entry.js} +1 -1
- package/dist/ezui/{p-123a2bd5.entry.js → p-36ed5c45.entry.js} +1 -1
- package/dist/ezui/{p-25e83e46.entry.js → p-3b2091dd.entry.js} +1 -1
- package/dist/ezui/p-47bcc678.entry.js +1 -0
- package/dist/ezui/{p-9def6fd0.entry.js → p-47ca5e09.entry.js} +1 -1
- package/dist/ezui/{p-04fab1e9.entry.js → p-4c444816.entry.js} +1 -1
- package/dist/ezui/{p-9334a724.entry.js → p-608d13e8.entry.js} +1 -1
- package/dist/ezui/{p-50ae478a.entry.js → p-626b8940.entry.js} +1 -1
- package/dist/ezui/{p-14a04845.entry.js → p-6630eca2.entry.js} +1 -1
- package/dist/ezui/{p-9404f22b.entry.js → p-67b9a2cb.entry.js} +1 -1
- package/dist/ezui/{p-93bcc628.entry.js → p-6dec5cfa.entry.js} +1 -1
- package/dist/ezui/{p-5dc3af60.entry.js → p-6f9aba86.entry.js} +1 -1
- package/dist/ezui/p-7799666d.entry.js +1 -0
- package/dist/ezui/p-7b80df03.js +1 -0
- package/dist/ezui/{p-5c9ce8a7.entry.js → p-7d42065a.entry.js} +1 -1
- package/dist/ezui/{p-74c7f960.entry.js → p-81897c04.entry.js} +1 -1
- package/dist/ezui/p-91f8c816.entry.js +1 -0
- package/dist/ezui/p-97d2d2f6.entry.js +1 -0
- package/dist/ezui/{p-32f9f83a.entry.js → p-98c448c9.entry.js} +1 -1
- package/dist/ezui/{p-a86d00b3.entry.js → p-99aea44b.entry.js} +1 -1
- package/dist/ezui/p-a4b4645d.entry.js +1 -0
- package/dist/ezui/{p-e613d9bf.entry.js → p-ab5eee38.entry.js} +1 -1
- package/dist/ezui/{p-a2e55b33.entry.js → p-ad7151e0.entry.js} +1 -1
- package/dist/ezui/{p-f6111077.entry.js → p-ad8b7412.entry.js} +1 -1
- package/dist/ezui/{p-1a89d3ff.entry.js → p-b2e861cb.entry.js} +1 -1
- package/dist/ezui/{p-f2627de5.entry.js → p-b2efb22c.entry.js} +1 -1
- package/dist/ezui/{p-04a3b457.entry.js → p-b5557d33.entry.js} +1 -1
- package/dist/ezui/p-ba03ac61.entry.js +1 -0
- package/dist/ezui/{p-6fd5e142.entry.js → p-bc324ee8.entry.js} +1 -1
- package/dist/ezui/{p-cfcc23e6.entry.js → p-bd9792e2.entry.js} +1 -1
- package/dist/ezui/{p-7c227b86.entry.js → p-bf8a633d.entry.js} +1 -1
- package/dist/ezui/{p-ea877274.entry.js → p-c071db26.entry.js} +1 -1
- package/dist/ezui/{p-46113d5a.entry.js → p-c3529df3.entry.js} +1 -1
- package/dist/ezui/{p-b60fbad2.entry.js → p-ca7435a6.entry.js} +1 -1
- package/dist/ezui/{p-37335c51.entry.js → p-e203c89f.entry.js} +1 -1
- package/dist/ezui/{p-f2c4e811.entry.js → p-fc97f773.entry.js} +1 -1
- package/dist/types/components/ez-dropdown/ez-dropdown.d.ts +58 -0
- package/dist/types/components/ez-dropdown/structure/DropdownItem.d.ts +28 -0
- package/dist/types/components/ez-dropdown/structure/SubmenuControl.d.ts +78 -0
- package/dist/types/components/ez-form/DataBinder.d.ts +1 -1
- package/dist/types/components/ez-form/FormMetadata.d.ts +16 -0
- package/dist/types/components/ez-form/ez-form.d.ts +21 -43
- package/dist/types/components/ez-form/interfaces/IDefaultConfig.d.ts +5 -0
- package/dist/types/components/ez-form/interfaces/IFieldConfig.d.ts +13 -0
- package/dist/types/components/ez-form/interfaces/IFormConfig.d.ts +7 -0
- package/dist/types/components/ez-form/interfaces/IFormSheetMetadata.d.ts +9 -0
- package/dist/types/components/ez-form/interfaces/IInvalidField.d.ts +4 -0
- package/dist/types/components/ez-form/interfaces/IRecordValidator.d.ts +6 -0
- package/dist/types/components/ez-form/interfaces/ITabConfig.d.ts +5 -0
- package/dist/types/components/ez-form/interfaces/IValidationResult.d.ts +8 -0
- package/dist/types/components/ez-form/interfaces/index.d.ts +8 -0
- package/dist/types/components/ez-form/store/form.slice.d.ts +5 -3
- package/dist/types/components/ez-form-view/fieldbuilder/FieldBuilder.d.ts +2 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/CheckBox.tpl.d.ts +3 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/ComboBox.tpl.d.ts +2 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/DateInput.tpl.d.ts +4 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/FileInput.tpl.d.ts +2 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.d.ts +3 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.d.ts +2 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/TextArea.tpl.d.ts +2 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.d.ts +2 -0
- package/dist/types/components/ez-form-view/interfaces/IFormViewField.d.ts +10 -0
- package/dist/types/components/ez-form-view/interfaces/index.d.ts +1 -0
- package/dist/types/components/ez-tree/ez-tree.d.ts +13 -0
- package/dist/types/components/ez-tree/interfaces/ITreeItem.d.ts +1 -0
- package/dist/types/components/ez-tree/subcomponents/DefaultTooltipResolver.d.ts +2 -0
- package/dist/types/components/ez-tree/subcomponents/TreeItem.d.ts +2 -0
- package/dist/types/components/ez-tree/subcomponents/index.d.ts +1 -0
- package/dist/types/components/ez-tree/types/Node.d.ts +1 -0
- package/dist/types/components/ez-tree/types/Tree.d.ts +1 -0
- package/dist/types/components.d.ts +111 -2
- package/package.json +1 -1
- package/react/components.d.ts +2 -0
- package/react/components.js +2 -0
- package/react/components.js.map +1 -1
- package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +0 -48
- package/dist/collection/components/ez-form/structure/FormItem.js +0 -11
- package/dist/collection/components/ez-form/structure/FormSheet.js +0 -6
- package/dist/ezui/p-1cc11468.entry.js +0 -1
- package/dist/ezui/p-3c7ea91b.js +0 -1
- package/dist/ezui/p-79e409c6.entry.js +0 -1
- package/dist/ezui/p-941e9792.entry.js +0 -1
- package/dist/ezui/p-ddb1c350.entry.js +0 -1
- package/dist/types/components/ez-form/fieldbuilder/FieldBuilder.d.ts +0 -2
- package/dist/types/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.d.ts +0 -3
- package/dist/types/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.d.ts +0 -6
- package/dist/types/components/ez-form/fieldbuilder/tpl/DateInput.tpl.d.ts +0 -15
- package/dist/types/components/ez-form/fieldbuilder/tpl/FileInput.tpl.d.ts +0 -5
- package/dist/types/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.d.ts +0 -7
- package/dist/types/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.d.ts +0 -6
- package/dist/types/components/ez-form/fieldbuilder/tpl/TextArea.tpl.d.ts +0 -5
- package/dist/types/components/ez-form/fieldbuilder/tpl/TextInput.tpl.d.ts +0 -5
- package/dist/types/components/ez-form/structure/FormItem.d.ts +0 -9
- package/dist/types/components/ez-form/structure/FormSheet.d.ts +0 -10
- package/dist/types/components/ez-form/structure/FormSheetMetadata.d.ts +0 -35
- /package/dist/collection/components/{ez-form/fieldbuilder/tpl → ez-form-view/fieldbuilder/templates}/FileInput.tpl.js +0 -0
- /package/dist/collection/components/{ez-form/fieldbuilder/tpl → ez-form-view/fieldbuilder/templates}/SearchInput.tpl.js +0 -0
- /package/dist/collection/components/{ez-form/fieldbuilder/tpl → ez-form-view/fieldbuilder/templates}/TextArea.tpl.js +0 -0
- /package/dist/collection/components/{ez-form/fieldbuilder/tpl → ez-form-view/fieldbuilder/templates}/TextInput.tpl.js +0 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-5e208fa5.js');
|
|
6
|
+
const core = require('@sankhyalabs/core');
|
|
7
|
+
|
|
8
|
+
const DropdownItem = ({ item, hasIcon, hasChildren, isLockedLevels, onSubActionClick }) => {
|
|
9
|
+
return (index.h("div", { class: "ez-dropdown__item-wrapper", title: item.label },
|
|
10
|
+
getContentLeft(item, hasIcon),
|
|
11
|
+
index.h("span", { class: "ez-dropdown__item-label" }, item.label),
|
|
12
|
+
getContentRight(item, hasChildren, isLockedLevels, onSubActionClick)));
|
|
13
|
+
};
|
|
14
|
+
const getContentLeft = (item, hasIcon) => {
|
|
15
|
+
if (item == undefined || !hasIcon) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (item.iconName) {
|
|
19
|
+
return (index.h("ez-icon", Object.assign({ class: "ez-dropdown__icon-left", iconName: item.iconName, size: "medium" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${item.id}_ezDropdownItemIcon` })));
|
|
20
|
+
}
|
|
21
|
+
return (index.h("ez-icon", { class: "ez-dropdown__icon-left ez-dropdown__hidden", size: "medium" }));
|
|
22
|
+
};
|
|
23
|
+
const getContentRight = (item, hasChildren, isLockedLevels, onClick) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
if (item == undefined) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) && item.subAction != undefined && Object.keys(item.subAction).length > 0) {
|
|
29
|
+
return (index.h("span", Object.assign({ onClick: () => onClick(item), title: item.subAction.label, class: `ez-dropdown__link ez-dropdown__link--${item.subAction.type || "primary"}` }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${item.subAction.id}_ezDropdownItemSubAction` }), item.subAction.label));
|
|
30
|
+
}
|
|
31
|
+
if (isLockedLevels || !hasChildren) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (((_b = item.children) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
35
|
+
return (index.h("ez-icon", Object.assign({ class: "ez-dropdown__icon-right", iconName: "chevron-right", size: "medium" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${item.id}_ezDropdownIconOpenChildren` })));
|
|
36
|
+
}
|
|
37
|
+
return (index.h("ez-icon", { class: "ez-dropdown__icon-right ez-dropdown__hidden", size: "medium" }));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
class SubmenuControl {
|
|
41
|
+
constructor() { }
|
|
42
|
+
//---------------------------------------------
|
|
43
|
+
// Public methods
|
|
44
|
+
//---------------------------------------------
|
|
45
|
+
/**
|
|
46
|
+
* Método responsável por fechar submenus abertos e abrir o submenu desejado.
|
|
47
|
+
* @param menu - Item de menu selecionado para abrir o submenu.
|
|
48
|
+
*/
|
|
49
|
+
show(menu) {
|
|
50
|
+
const submenu = menu === null || menu === void 0 ? void 0 : menu.querySelector(".ez-dropdown__submenu");
|
|
51
|
+
if (menu == undefined || submenu == undefined) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
submenu.classList.remove("ez-dropdown__submenu--hide");
|
|
55
|
+
this.setPosition(menu);
|
|
56
|
+
this.setScrollContainer(menu);
|
|
57
|
+
this.setMaxHeight(submenu);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Método responsável por fechar um determinado submenu aberto.
|
|
61
|
+
* @param menu - Item de menu selecionado com o submenu aberto.
|
|
62
|
+
*/
|
|
63
|
+
hide(menu) {
|
|
64
|
+
if (menu == undefined) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const submenuSelector = ".ez-dropdown__submenu:not(.ez-dropdown__submenu--hide)";
|
|
68
|
+
const submenuElement = menu.querySelector(submenuSelector);
|
|
69
|
+
this.reset(submenuElement);
|
|
70
|
+
this.hideChild(submenuElement);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Método responsável por fechar todos os submenus filhos de um determinado submenu.
|
|
74
|
+
* @param submenu - Elemento HTML do submenu pai.
|
|
75
|
+
*/
|
|
76
|
+
hideChild(submenu) {
|
|
77
|
+
if (submenu == undefined) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
submenu.querySelectorAll(".ez-dropdown__submenu")
|
|
81
|
+
.forEach((child) => {
|
|
82
|
+
this.reset(child);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Método responsável por posicionar o submenu na tela.
|
|
87
|
+
* @param menu - Item da lista selecionado para abrir o submenu.
|
|
88
|
+
*/
|
|
89
|
+
setPosition(menu) {
|
|
90
|
+
const submenu = menu === null || menu === void 0 ? void 0 : menu.querySelector(".ez-dropdown__submenu");
|
|
91
|
+
const dropdown = menu === null || menu === void 0 ? void 0 : menu.closest(".ez-dropdown");
|
|
92
|
+
if (submenu == undefined || dropdown == undefined) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
submenu.style.top = this.getPositionTop(menu);
|
|
96
|
+
submenu.style.left = this.getPositionRight(dropdown);
|
|
97
|
+
const bounding = submenu === null || submenu === void 0 ? void 0 : submenu.getBoundingClientRect();
|
|
98
|
+
const docWidth = document.body.clientWidth;
|
|
99
|
+
if ((bounding === null || bounding === void 0 ? void 0 : bounding.right) > docWidth) {
|
|
100
|
+
this.updatePosition(dropdown, submenu);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Método responsável por controlar a altura máxima do dropdown.
|
|
105
|
+
* @param element - Elemento HTML pai do dropdown que será renderizado.
|
|
106
|
+
*/
|
|
107
|
+
setMaxHeight(element) {
|
|
108
|
+
var _a;
|
|
109
|
+
const parentElement = (element === null || element === void 0 ? void 0 : element.shadowRoot) || element;
|
|
110
|
+
const dropdown = parentElement === null || parentElement === void 0 ? void 0 : parentElement.querySelector(".ez-dropdown");
|
|
111
|
+
const docHeight = document.body.clientHeight;
|
|
112
|
+
let submenu;
|
|
113
|
+
let bounding;
|
|
114
|
+
if ((parentElement === null || parentElement === void 0 ? void 0 : parentElement["tagName"]) != undefined) {
|
|
115
|
+
submenu = parentElement;
|
|
116
|
+
bounding = submenu === null || submenu === void 0 ? void 0 : submenu.getBoundingClientRect();
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
bounding = dropdown === null || dropdown === void 0 ? void 0 : dropdown.getBoundingClientRect();
|
|
120
|
+
}
|
|
121
|
+
if (dropdown == undefined || bounding == undefined) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Menu aberto irá ultrapassar a altura da página?
|
|
126
|
+
*/
|
|
127
|
+
if ((bounding.y + bounding.height) > docHeight) {
|
|
128
|
+
/**
|
|
129
|
+
* Menu aberto é um submenu?
|
|
130
|
+
* Sim: realiza o calculo com base na altura do menu pai
|
|
131
|
+
* Não: recalcula a altura do menu para atualizar a barra de rolagem
|
|
132
|
+
*/
|
|
133
|
+
if (submenu != undefined) {
|
|
134
|
+
const dropdownParent = submenu.closest(".ez-dropdown");
|
|
135
|
+
const boundingParent = dropdownParent === null || dropdownParent === void 0 ? void 0 : dropdownParent.getBoundingClientRect();
|
|
136
|
+
const marginTop = parseFloat(((_a = getComputedStyle(submenu)) === null || _a === void 0 ? void 0 : _a.marginTop) || "0");
|
|
137
|
+
if (dropdownParent == undefined || boundingParent == undefined) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Submenu aberto ao ser reposicionado ficará acima da altura do menu pai?
|
|
142
|
+
* Sim: posiciona o submenu na altura do menu pai e recalcula a sua altura para atualizar a barra de rolagem
|
|
143
|
+
* Não: posiciona o submenu entre a altura do menu pai e o rodapé da página
|
|
144
|
+
*/
|
|
145
|
+
if ((boundingParent.y + bounding.height) > docHeight) {
|
|
146
|
+
submenu.style.top = (boundingParent.y - marginTop) + "px";
|
|
147
|
+
dropdown.style.maxHeight = (docHeight - boundingParent.y) + "px";
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
submenu.style.top = (docHeight - bounding.height - marginTop) + "px";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
let maxHeight = docHeight - bounding.y;
|
|
155
|
+
if (maxHeight < 0) {
|
|
156
|
+
maxHeight = bounding.height - docHeight;
|
|
157
|
+
}
|
|
158
|
+
dropdown.style.maxHeight = maxHeight + "px";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
this.setSpacerContainer(dropdown);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Método responsável por atribuir a classe de espaçamento entre o conteúdo e o scroll.
|
|
165
|
+
* @param dropdown - Elemento HTML pai do container que receberá a classe.
|
|
166
|
+
*/
|
|
167
|
+
setSpacerContainer(dropdown) {
|
|
168
|
+
const container = dropdown === null || dropdown === void 0 ? void 0 : dropdown.querySelector(".ez-dropdown__container");
|
|
169
|
+
if (container == undefined) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (container.scrollHeight > container.clientHeight) {
|
|
173
|
+
container.classList.add("ez-dropdown__container--spacer");
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
container.classList.remove("ez-dropdown__container--spacer");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Método responsável por resetar um determinado submenu aberto.
|
|
181
|
+
* @param submenu - Elemento HTML do submenu que será resetado.
|
|
182
|
+
*/
|
|
183
|
+
reset(submenu) {
|
|
184
|
+
if (submenu == undefined) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
submenu.classList.add("ez-dropdown__submenu--hide");
|
|
188
|
+
submenu.style.left = "";
|
|
189
|
+
submenu.style.top = "";
|
|
190
|
+
const dropdown = submenu.querySelector(".ez-dropdown");
|
|
191
|
+
this.resetDropdown(dropdown);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Método responsável por resetar um determinado dropdown renderizado.
|
|
195
|
+
* @param dropdown - Elemento HTML do dropdown que será resetado.
|
|
196
|
+
*/
|
|
197
|
+
resetDropdown(dropdown) {
|
|
198
|
+
if (dropdown == undefined) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
dropdown.style.maxHeight = "";
|
|
202
|
+
this.setSpacerContainer(dropdown);
|
|
203
|
+
}
|
|
204
|
+
//---------------------------------------------
|
|
205
|
+
// Private methods
|
|
206
|
+
//---------------------------------------------
|
|
207
|
+
/**
|
|
208
|
+
* Método responsável por controlar o scroll do container do submenu aberto.
|
|
209
|
+
* @param menu - Item da lista selecionado para abrir o submenu.
|
|
210
|
+
*/
|
|
211
|
+
setScrollContainer(menu) {
|
|
212
|
+
const container = menu === null || menu === void 0 ? void 0 : menu.closest(".ez-dropdown__container");
|
|
213
|
+
if (container == undefined) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
container.onscroll = this.onScrollContainer.bind(this);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Método responsável por fechar os submenus filhos ao movimentar o scroll.
|
|
220
|
+
* @param event - Evento de scroll disparado pelo Elemento HTML pai.
|
|
221
|
+
*/
|
|
222
|
+
onScrollContainer(event) {
|
|
223
|
+
const target = event === null || event === void 0 ? void 0 : event.target;
|
|
224
|
+
this.hideChild(target);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Método responsável por retornar a posição superior (top) de um elemento HTML na tela.
|
|
228
|
+
* @param hostElement - Elemento HTML que será capturado o valor de sua posição superior (top) na tela.
|
|
229
|
+
* @returns Valor da posição superior (top) de um determinado elemento HTML.
|
|
230
|
+
*/
|
|
231
|
+
getPositionTop(hostElement) {
|
|
232
|
+
const boundingHost = hostElement === null || hostElement === void 0 ? void 0 : hostElement.getBoundingClientRect();
|
|
233
|
+
if (boundingHost == undefined) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
return boundingHost.y + "px";
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Método responsável por retornar a posição direita (right) de um elemento HTML na tela.
|
|
240
|
+
* @param hostElement - Elemento HTML que será capturado o valor de sua posição direita (right) na tela.
|
|
241
|
+
* @returns Valor da posição direita (right) de um determinado elemento HTML.
|
|
242
|
+
*/
|
|
243
|
+
getPositionRight(hostElement) {
|
|
244
|
+
const boundingHost = hostElement === null || hostElement === void 0 ? void 0 : hostElement.getBoundingClientRect();
|
|
245
|
+
if (boundingHost == undefined) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
return (boundingHost.x + boundingHost.width) + "px";
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Método responsável por retornar a posição esquerda (left) de um elemento HTML desconsiderando a largura de outro elemento HTML.
|
|
252
|
+
* @param hostElement - Elemento HTML que será capturado o valor de sua posição esquerda (left) na tela.
|
|
253
|
+
* @param targetElement - Elemento HTML que será capturado o valor de sua largura (width).
|
|
254
|
+
* @returns Valor da posição esquerda (left) de um determinado elemento HTML desconsiderando a largura de outro elemento HTML.
|
|
255
|
+
*/
|
|
256
|
+
getPositionLeft(hostElement, targetElement) {
|
|
257
|
+
const boundingHost = hostElement === null || hostElement === void 0 ? void 0 : hostElement.getBoundingClientRect();
|
|
258
|
+
const boundingTarget = targetElement === null || targetElement === void 0 ? void 0 : targetElement.getBoundingClientRect();
|
|
259
|
+
if (boundingHost == undefined || boundingTarget == undefined) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
return (boundingHost.x - boundingTarget.width) + "px";
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Método responsável por atualizar a posição de um elemento HTML que renderizou fora da tela.
|
|
266
|
+
* @param hostElement - Elemento HTML que será a referência de posição dentro da tela.
|
|
267
|
+
* @param targetElement - Elemento HTML que será reposicionado na tela.
|
|
268
|
+
*/
|
|
269
|
+
updatePosition(hostElement, targetElement) {
|
|
270
|
+
const boundingHost = hostElement === null || hostElement === void 0 ? void 0 : hostElement.getBoundingClientRect();
|
|
271
|
+
const boundingTarget = targetElement === null || targetElement === void 0 ? void 0 : targetElement.getBoundingClientRect();
|
|
272
|
+
if (boundingHost == undefined || boundingTarget == undefined) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (boundingHost.x < boundingTarget.right) {
|
|
276
|
+
targetElement.style.left = this.getPositionLeft(hostElement, targetElement);
|
|
277
|
+
this.updatePosition(hostElement, targetElement);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const ezDropdownCss = ":host{--ez-dropdown--z-index:var(--more-visible, 2);--ez-dropdown--padding:var(--space--small, 6px);--ez-dropdown--box-shadow:var(--shadow--medium, 0px 8px 24px rgba(0, 38, 111, 0.1));--ez-dropdown--border-radius:var(--border--radius-medium, 12px);--ez-dropdown--background-color:var(--background--xlight, #fff);--ez-dropdown--font-family:var(--font-pattern, 'Roboto');--ez-dropdown--max-width:320px;--ez-dropdown--max-height:440px;--ez-dropdown__item--padding:var(--space--small, 6px);--ez-dropdown__item--gap:var(--space--small, 6px);--ez-dropdown__item--border-radius:var(--border--radius-small, 6px);--ez-dropdown__item--color:var(--title--primary, #2b3a54);--ez-dropdown__item--font-weight:var(--text-weight--medium, 400);--ez-dropdown__item--font-size:var(--text--medium, 14px);--ez-dropdown__item--line-height:calc(var(--ez-dropdown__item--font-size) + 4px);--ez-dropdown__item--background-color:var(--background--medium, #f0f3f7);--ez-dropdown__item--transition:var(--transition, .2s linear);--ez-dropdown__item-label--margin-right:var(--space--medium, 12px);--ez-dropdown__icon--size:var(--icon--medium, 18px);--ez-dropdown__divider--background-color:var(--color--disable-secondary, #f2f5f8);--ez-dropdown__divider--margin:var(--space--extra-small, 3px) 0;--ez-dropdown__group-label--color:var(--text--secondary, #A2ABB9);--ez-dropdown__group-label--font-weight:var(--text-weight--large, 600);--ez-dropdown__group-label--font-size:var(--text--small, 12px);--ez-dropdown__group-label--line-height:var(--text--medium, 14px);--ez-dropdown__group-label--padding:var(--space--small, 6px);--ez-dropdown__submenu--z-index:var(--most-visible, 3);--ez-dropdown__link--font-weight:var(--text-weight--large, 600);--ez-dropdown__link--primary--color:var(--color--primary, #008561);--ez-dropdown__link--critical--color:var(--color-alert--error-800, #BD0025);--ez-dropdown__scrollbar--color-default:var(--scrollbar--default, #626e82);--ez-dropdown__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--ez-dropdown__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--ez-dropdown__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--ez-dropdown__scrollbar--border-radius:var(--border--radius-small, 6px);--ez-dropdown__scrollbar--width:var(--space--small, 6px);--ez-dropdown__scrollbar--padding-right:var(--space--extra-small, 3px);display:flex;flex-direction:column;height:fit-content;user-select:none;box-sizing:border-box;position:fixed;z-index:var(--ez-dropdown--z-index)}:host *{box-sizing:border-box}.ez-dropdown{display:flex;padding:var(--ez-dropdown--padding);box-shadow:var(--ez-dropdown--box-shadow);border-radius:var(--ez-dropdown--border-radius);background-color:var(--ez-dropdown--background-color);max-width:var(--ez-dropdown--max-width);max-height:var(--ez-dropdown--max-height)}.ez-dropdown *{font-family:var(--ez-dropdown--font-family)}.ez-dropdown__container{display:flex;flex-direction:column;overflow-y:auto;scrollbar-width:thin;flex:auto;scrollbar-color:var(--ez-dropdown__scrollbar--color-clicked) var(--ez-dropdown__scrollbar--color-background)}.ez-dropdown__container::-webkit-scrollbar{background-color:var(--ez-dropdown__scrollbar--color-background);width:var(--ez-dropdown__scrollbar--width);max-width:var(--ez-dropdown__scrollbar--width);min-width:var(--ez-dropdown__scrollbar--width)}.ez-dropdown__container::-webkit-scrollbar-track{background-color:var(--ez-dropdown__scrollbar--color-background);border-radius:var(--ez-dropdown__scrollbar--border-radius)}.ez-dropdown__container::-webkit-scrollbar-thumb{background-color:var(--ez-dropdown__scrollbar--color-default);border-radius:var(--ez-dropdown__scrollbar--border-radius)}.ez-dropdown__container::-webkit-scrollbar-thumb:vertical:hover,.ez-dropdown__container::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--ez-dropdown__scrollbar--color-hover)}.ez-dropdown__container::-webkit-scrollbar-thumb:vertical:active,.ez-dropdown__container::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--ez-dropdown__scrollbar--color-clicked)}.ez-dropdown__container--spacer{padding-right:var(--ez-dropdown__scrollbar--padding-right)}.ez-dropdown__item{display:flex;align-items:center;background-color:transparent;border-radius:var(--ez-dropdown__item--border-radius);transition:var(--ez-dropdown__item--transition)}.ez-dropdown__item:hover{background-color:var(--ez-dropdown__item--background-color)}.ez-dropdown__item-wrapper{display:flex;align-items:center;position:relative;cursor:pointer;width:100%;margin:0;white-space:nowrap;gap:var(--ez-dropdown__item--gap);color:var(--ez-dropdown__item--color);font-weight:var(--ez-dropdown__item--font-weight);font-size:var(--ez-dropdown__item--font-size);line-height:var(--ez-dropdown__item--line-height);padding:var(--ez-dropdown__item--padding)}.ez-dropdown__item-wrapper ez-icon{display:flex;justify-content:center;align-items:center;width:var(--ez-dropdown__icon--size);height:var(--ez-dropdown__icon--size);min-width:var(--ez-dropdown__icon--size);min-height:var(--ez-dropdown__icon--size)}.ez-dropdown__item-content{display:flex;align-items:center;flex:auto;overflow:hidden;gap:var(--ez-dropdown__item--gap)}.ez-dropdown__item-label{text-align:left;text-overflow:ellipsis;overflow:hidden;flex:auto}.ez-dropdown__item-label:not(:last-child){margin-right:var(--ez-dropdown__item-label--margin-right)}.ez-dropdown__item-content+.ez-dropdown__link{margin-left:var(--ez-dropdown__item-label--margin-right);margin-right:var(--ez-dropdown__item--padding)}.ez-dropdown__item-builder{flex:auto}.ez-dropdown__divider{width:100%;height:2px;border-radius:1px;border:none;display:block;background-color:var(--ez-dropdown__divider--background-color);margin:var(--ez-dropdown__divider--margin)}.ez-dropdown__hidden{visibility:hidden}.ez-dropdown__group{display:flex;flex-direction:column}.ez-dropdown__group-label{display:block;width:100%;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ez-dropdown__group-label--color);font-weight:var(--ez-dropdown__group-label--font-weight);font-size:var(--ez-dropdown__group-label--font-size);line-height:var(--ez-dropdown__group-label--line-height);padding:var(--ez-dropdown__group-label--padding)}.ez-dropdown__icon-right{margin-left:auto}.ez-dropdown__submenu{position:fixed;z-index:var(--ez-dropdown__submenu--z-index);margin-top:calc(var(--ez-dropdown__item--padding) * -1)}.ez-dropdown__submenu--hide{display:none}.ez-dropdown__link{display:block;margin-left:auto;cursor:pointer;text-overflow:ellipsis;overflow:hidden;font-weight:var(--ez-dropdown__link--font-weight);max-width:calc(var(--ez-dropdown--max-width) * 0.43)}.ez-dropdown__link--primary{color:var(--ez-dropdown__link--primary--color)}.ez-dropdown__link--critical{color:var(--ez-dropdown__link--critical--color)}.ez-dropdown__link:hover{text-decoration:underline}";
|
|
283
|
+
|
|
284
|
+
let EzDropdown = class {
|
|
285
|
+
constructor(hostRef) {
|
|
286
|
+
index.registerInstance(this, hostRef);
|
|
287
|
+
this.ezClick = index.createEvent(this, "ezClick", 7);
|
|
288
|
+
this.ezSubActionClick = index.createEvent(this, "ezSubActionClick", 7);
|
|
289
|
+
this._itemList = {};
|
|
290
|
+
this._submenuList = [];
|
|
291
|
+
this._openedMenuList = {};
|
|
292
|
+
/**
|
|
293
|
+
* Limitador de níveis de menu + submenu.
|
|
294
|
+
* Valor 0, null ou undefined desativa o limitador.
|
|
295
|
+
*/
|
|
296
|
+
this._levelLimits = 3;
|
|
297
|
+
/**
|
|
298
|
+
* Lista de itens que vão ser apresentados no dropdown.
|
|
299
|
+
*/
|
|
300
|
+
this.items = [];
|
|
301
|
+
}
|
|
302
|
+
//---------------------------------------------
|
|
303
|
+
// Private methods
|
|
304
|
+
//---------------------------------------------
|
|
305
|
+
defaultItemBuilder(item, isLockedLevels, hasIcon, hasChildren) {
|
|
306
|
+
return (index.h(DropdownItem, { item: item, hasIcon: hasIcon, hasChildren: hasChildren, isLockedLevels: isLockedLevels, onSubActionClick: this.onSubActionClick.bind(this) }));
|
|
307
|
+
}
|
|
308
|
+
getMaxOrder(items) {
|
|
309
|
+
if (items == undefined || items.length === 0) {
|
|
310
|
+
return -1;
|
|
311
|
+
}
|
|
312
|
+
return Math.max(...items.map((item) => {
|
|
313
|
+
var _a;
|
|
314
|
+
const order = (_a = item.group) === null || _a === void 0 ? void 0 : _a["order"];
|
|
315
|
+
return order != undefined && order >= 0 ? order : -1;
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
hasIcon(items) {
|
|
319
|
+
return items === null || items === void 0 ? void 0 : items.some((item) => (item.iconName || "") !== "");
|
|
320
|
+
}
|
|
321
|
+
hasGroup(items) {
|
|
322
|
+
return items === null || items === void 0 ? void 0 : items.some((item) => (item.group || "") !== "");
|
|
323
|
+
}
|
|
324
|
+
hasChildren(items) {
|
|
325
|
+
return items === null || items === void 0 ? void 0 : items.some((item) => (item.children || []).length > 0);
|
|
326
|
+
}
|
|
327
|
+
isLockedLevels(level) {
|
|
328
|
+
if (!this._levelLimits) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
return level === (this._levelLimits + 1);
|
|
332
|
+
}
|
|
333
|
+
getItemsByGroup(items, level) {
|
|
334
|
+
let itemsByGroup = {};
|
|
335
|
+
const maxOrder = this.getMaxOrder(items);
|
|
336
|
+
items.forEach((item) => {
|
|
337
|
+
const label = item.group && item.group["label"] != undefined ? item.group["label"] || "noGroup" : item.group || "noGroup";
|
|
338
|
+
const order = item.group && item.group["order"] != undefined ? item.group["order"] : item.group ? (maxOrder + 1) : (maxOrder + 2);
|
|
339
|
+
let groupObj = itemsByGroup[label];
|
|
340
|
+
if (groupObj == undefined) {
|
|
341
|
+
groupObj = {
|
|
342
|
+
items: [],
|
|
343
|
+
order
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
this.validateItem(item, level);
|
|
347
|
+
groupObj.items.push(item);
|
|
348
|
+
itemsByGroup[label] = groupObj;
|
|
349
|
+
});
|
|
350
|
+
return core.ObjectUtils.sortByProperty(itemsByGroup, "order");
|
|
351
|
+
}
|
|
352
|
+
validateItem(item, level) {
|
|
353
|
+
if (this._itemList == undefined) {
|
|
354
|
+
this._itemList = {};
|
|
355
|
+
}
|
|
356
|
+
if (item.type == undefined) {
|
|
357
|
+
item.type = "item";
|
|
358
|
+
}
|
|
359
|
+
if (item.id == undefined) {
|
|
360
|
+
const itemId = `level_${level}_${item.type}`;
|
|
361
|
+
const counter = Object.keys(this._itemList).filter((key) => key.includes(itemId)).length;
|
|
362
|
+
item.id = `${itemId}_${counter + 1}`;
|
|
363
|
+
}
|
|
364
|
+
if (item.label == undefined) {
|
|
365
|
+
item.label = "";
|
|
366
|
+
}
|
|
367
|
+
if (item.subAction != undefined) {
|
|
368
|
+
if (item.subAction.id == undefined) {
|
|
369
|
+
const subId = `subAction_${item.id}`;
|
|
370
|
+
item.subAction.id = subId;
|
|
371
|
+
}
|
|
372
|
+
if (item.subAction.label == undefined) {
|
|
373
|
+
item.subAction.label = "";
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (this._itemList[item.id] == undefined) {
|
|
377
|
+
this._itemList[item.id] = {};
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
getItemsRender(groupItems, level, hasIcon, hasChildren) {
|
|
381
|
+
if (groupItems == undefined) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
let counterLevel = level;
|
|
385
|
+
let isLockedLevels = false;
|
|
386
|
+
if (hasChildren) {
|
|
387
|
+
counterLevel++;
|
|
388
|
+
isLockedLevels = this.isLockedLevels(counterLevel);
|
|
389
|
+
}
|
|
390
|
+
return groupItems.map((item) => {
|
|
391
|
+
var _a;
|
|
392
|
+
return (item.type !== "divider"
|
|
393
|
+
? index.h("div", Object.assign({ ref: (ref) => this._itemList[item.id] = ref, class: "ez-dropdown__item", "data-level": level }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: core.ElementIDUtils.getInternalIDInfo(`${item.id}_ezDropdownItem`) }), index.h("div", { class: "ez-dropdown__item-content", onClick: (evt) => this.onItemClick(evt, item), onMouseOver: (evt) => this.onShowSubmenu(evt, item) }, this.itemBuilder
|
|
394
|
+
? index.h("div", { class: "ez-dropdown__item-builder", innerHTML: this.itemBuilder(item, level) })
|
|
395
|
+
: this.defaultItemBuilder(item, isLockedLevels, hasIcon, hasChildren)), ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
396
|
+
!isLockedLevels &&
|
|
397
|
+
hasChildren &&
|
|
398
|
+
index.h("div", { ref: (ref) => this._submenuList.push(ref), class: "ez-dropdown__submenu ez-dropdown__submenu--hide" }, this.renderDropdown(item.children, counterLevel)))
|
|
399
|
+
: index.h("hr", Object.assign({ class: "ez-dropdown__divider" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${item.id}_ezDropdownDivider` })));
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
renderDropdown(branchItems = this.items, level = 1) {
|
|
403
|
+
if (branchItems == undefined || this.isLockedLevels(level)) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const itemsByGroup = this.getItemsByGroup(branchItems, level);
|
|
407
|
+
const hasGroup = this.hasGroup(branchItems);
|
|
408
|
+
const hasIcon = this.hasIcon(branchItems);
|
|
409
|
+
const hasChildren = this.hasChildren(branchItems);
|
|
410
|
+
return (index.h("div", { class: "ez-dropdown", "data-level": level }, index.h("div", { class: "ez-dropdown__container" }, Object.keys(itemsByGroup)
|
|
411
|
+
.map((groupLabel) => {
|
|
412
|
+
return (index.h("div", Object.assign({ class: "ez-dropdown__group" }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: core.ElementIDUtils.getInternalIDInfo(`${groupLabel}_ezDropdownGroup`) }), groupLabel !== "noGroup" &&
|
|
413
|
+
index.h("label", { class: "ez-dropdown__group-label", title: groupLabel }, groupLabel), hasGroup &&
|
|
414
|
+
groupLabel === "noGroup" &&
|
|
415
|
+
index.h("hr", { class: "ez-dropdown__divider" }), this.getItemsRender(itemsByGroup[groupLabel].items, level, hasIcon, hasChildren)));
|
|
416
|
+
}))));
|
|
417
|
+
}
|
|
418
|
+
hasOpenedSubmenu(level) {
|
|
419
|
+
const openedLevels = Object.keys(this._openedMenuList);
|
|
420
|
+
return openedLevels.includes(level.toString())
|
|
421
|
+
|| openedLevels.some((openedLevel) => Number(openedLevel) > level);
|
|
422
|
+
}
|
|
423
|
+
hasSubmenuOpened() {
|
|
424
|
+
var _a;
|
|
425
|
+
return (_a = this._submenuList) === null || _a === void 0 ? void 0 : _a.some((submenu) => !submenu.classList.contains("ez-dropdown__submenu--hide"));
|
|
426
|
+
}
|
|
427
|
+
setEvents() {
|
|
428
|
+
document.removeEventListener('click', this.onHideAllSubmenu.bind(this));
|
|
429
|
+
document.addEventListener('click', this.onHideAllSubmenu.bind(this));
|
|
430
|
+
document.removeEventListener('scroll', this.onSubmenuReposition.bind(this));
|
|
431
|
+
document.addEventListener('scroll', this.onSubmenuReposition.bind(this));
|
|
432
|
+
}
|
|
433
|
+
//---------------------------------------------
|
|
434
|
+
// Event handlers
|
|
435
|
+
//---------------------------------------------
|
|
436
|
+
onShowSubmenu(evt, item) {
|
|
437
|
+
var _a;
|
|
438
|
+
if (evt == undefined) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const menu = this._itemList[item.id];
|
|
442
|
+
if (!(menu === null || menu === void 0 ? void 0 : menu.classList.contains("ez-dropdown__item"))) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const level = Number(menu.dataset.level || "0");
|
|
446
|
+
if (this.hasOpenedSubmenu(level)) {
|
|
447
|
+
this._submenuControl.hide(this._openedMenuList[level]);
|
|
448
|
+
delete this._openedMenuList[level];
|
|
449
|
+
}
|
|
450
|
+
if (!((_a = item.children) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
this._openedMenuList[menu.dataset.level] = menu;
|
|
454
|
+
this._submenuControl.show(menu);
|
|
455
|
+
}
|
|
456
|
+
onItemClick(evt, item) {
|
|
457
|
+
const target = evt === null || evt === void 0 ? void 0 : evt.target;
|
|
458
|
+
if (target === null || target === void 0 ? void 0 : target.classList.contains("ez-dropdown__link")) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
this.value = item;
|
|
462
|
+
this.ezClick.emit(item);
|
|
463
|
+
}
|
|
464
|
+
onSubActionClick(item) {
|
|
465
|
+
this.ezSubActionClick.emit(item.subAction);
|
|
466
|
+
}
|
|
467
|
+
onHideAllSubmenu(evt = undefined) {
|
|
468
|
+
const target = evt === null || evt === void 0 ? void 0 : evt.target;
|
|
469
|
+
if (this.hasSubmenuOpened() && (target == undefined || (!target.closest(".ez-dropdown") && target.tagName !== "EZ-DROPDOWN"))) {
|
|
470
|
+
this._openedMenuList = {};
|
|
471
|
+
this._submenuList.forEach(this._submenuControl.reset.bind(this._submenuControl));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
onSubmenuReposition() {
|
|
475
|
+
if (this._openedMenuList != undefined) {
|
|
476
|
+
Object.keys(this._openedMenuList).forEach((key) => {
|
|
477
|
+
const menu = this._openedMenuList[key];
|
|
478
|
+
this._submenuControl.setPosition(menu);
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
//---------------------------------------------
|
|
483
|
+
// Lifecycle web component
|
|
484
|
+
//---------------------------------------------
|
|
485
|
+
componentDidLoad() {
|
|
486
|
+
core.ElementIDUtils.addIDInfo(this._element);
|
|
487
|
+
this._submenuControl = new SubmenuControl();
|
|
488
|
+
this._submenuControl.setMaxHeight(this._element);
|
|
489
|
+
}
|
|
490
|
+
componentDidUpdate() {
|
|
491
|
+
this._submenuControl.setMaxHeight(this._element);
|
|
492
|
+
}
|
|
493
|
+
componentDidRender() {
|
|
494
|
+
this.setEvents();
|
|
495
|
+
}
|
|
496
|
+
render() {
|
|
497
|
+
return (index.h(index.Host, null, this.renderDropdown()));
|
|
498
|
+
}
|
|
499
|
+
get _element() { return index.getElement(this); }
|
|
500
|
+
};
|
|
501
|
+
EzDropdown.style = ezDropdownCss;
|
|
502
|
+
|
|
503
|
+
exports.ez_dropdown = EzDropdown;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-5e208fa5.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
7
|
|
|
8
8
|
const ezFileItemCss = ":host{display:flex;width:100%;--ez-file-item--height:42px;--ez-file-item--padding:9px;--ez-file-item--border-radius:var(--border--radius-medium, 12px);--ez-file-item--border-color:var(--color--strokes, #DCE0E8);--ez-file-item--border-style:var(--border--small, 1px solid);--ez-file-item--font-family:var(--font-pattern, Arial);--ez-file-item--font-size:var(--text--medium, 14px);--ez-file-item--font-weight:var(--text-weight--medium, 400);--ez-file-item--color:var(--title--primary, #2B3A54);--ez-file-item__file-size--font-weight:var(--text-weight--large, 600);--ez-file-item__file-size--color:var(--color--primary, #008561);--ez-file-item__background-progress--color:var(--color--primary-300, E2F4EF);--ez-file-item--icon-color:var(--title--primary, #2B3A54)}.box{display:flex;box-sizing:border-box;position:relative;align-items:center;justify-content:space-between;width:100%;padding:var(--ez-file-item--padding);border:var(--ez-file-item--border-color) var(--ez-file-item--border-style);border-radius:var(--ez-file-item--border-radius);height:var(--ez-file-item--height)}.box::before{content:\"\";position:absolute;top:0;left:0;width:100%;height:100%;clip-path:inset(2px calc(var(--ez-file-item--upload-progress, 0%) + 2px) 2px 2px round calc(var(--ez-file-item--border-radius) - 4px));background-color:var(--ez-file-item__background-progress--color)}.content{display:flex;align-items:center;z-index:0;overflow:hidden}.file-name{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-family:var(--ez-file-item--font-family);font-size:var(--ez-file-item--font-size);font-weight:var(--ez-file-item--font-weight);color:var(--ez-file-item--color)}.file-type-icon{flex-shrink:0;--ez-icon--color:var(--ez-file-item--icon-color);padding-right:var(--ez-file-item--padding)}.file-size{padding-left:2px;overflow:hidden;flex-shrink:0;white-space:nowrap;font-family:var(--ez-file-item--font-family);font-size:var(--ez-file-item--font-size);font-weight:var(--ez-file-item__file-size--font-weight);color:var(--ez-file-item__file-size--color)}.btn-remove{cursor:pointer;flex-shrink:0;--ez-icon--color:var(--ez-file-item--icon-color)}";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-5e208fa5.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
7
|
const CSSVarsUtils = require('./CSSVarsUtils-af809e73.js');
|
|
8
8
|
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-5e208fa5.js');
|
|
6
|
+
const core = require('@sankhyalabs/core');
|
|
7
|
+
const CheckMode = require('./CheckMode-ecb90b87.js');
|
|
8
|
+
|
|
9
|
+
const buildSwitch = (field) => {
|
|
10
|
+
return buildField(field.name, field.label, field.readOnly, true);
|
|
11
|
+
};
|
|
12
|
+
const buildCheckBox = (field) => {
|
|
13
|
+
return buildField(field.name, field.label, field.readOnly, false);
|
|
14
|
+
};
|
|
15
|
+
function buildField(fieldName, fieldLabel, readOnly, switchMode = false) {
|
|
16
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large" },
|
|
17
|
+
index.h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? CheckMode.CheckMode.SWITCH : CheckMode.CheckMode.REGULAR, "data-field-name": fieldName, key: fieldName })));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const buildComboBox = ({ name, label, readOnly, required, props }) => {
|
|
21
|
+
const prop = props === null || props === void 0 ? void 0 : props.options;
|
|
22
|
+
let options;
|
|
23
|
+
if (typeof prop === "string") {
|
|
24
|
+
const parsed = JSON.parse(prop);
|
|
25
|
+
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
options = prop;
|
|
29
|
+
}
|
|
30
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
31
|
+
index.h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const buildDate = ({ name, label, readOnly }) => {
|
|
35
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
36
|
+
index.h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
37
|
+
};
|
|
38
|
+
const buildTime = ({ name, label, readOnly }) => {
|
|
39
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
40
|
+
index.h("ez-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
41
|
+
};
|
|
42
|
+
const buildDateTime = ({ name, label, readOnly }) => {
|
|
43
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
44
|
+
index.h("ez-date-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const buildFile = ({ name, label, readOnly }) => {
|
|
48
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
|
|
49
|
+
index.h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const buildDecimal = ({ name, label, readOnly, props }) => {
|
|
53
|
+
const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
|
|
54
|
+
const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
|
|
55
|
+
return buildNumeric(name, label, readOnly, precision, prettyPrecision);
|
|
56
|
+
};
|
|
57
|
+
const buildInteger = ({ name, label, readOnly }) => {
|
|
58
|
+
return buildNumeric(name, label, readOnly, 0, 0);
|
|
59
|
+
};
|
|
60
|
+
function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
|
|
61
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
62
|
+
index.h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const buildSearch = ({ name, label, readOnly, required }) => {
|
|
66
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
67
|
+
index.h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const buildTextArea = ({ name, label, readOnly }) => {
|
|
71
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
|
|
72
|
+
index.h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const buildTextInput = ({ name, label, readOnly }) => {
|
|
76
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
77
|
+
index.h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const uiBuilders = new Map();
|
|
81
|
+
uiBuilders.set(core.UserInterface.CHECKBOX, buildCheckBox);
|
|
82
|
+
uiBuilders.set(core.UserInterface.SWITCH, buildSwitch);
|
|
83
|
+
uiBuilders.set(core.UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
84
|
+
uiBuilders.set(core.UserInterface.DATE, buildDate);
|
|
85
|
+
uiBuilders.set(core.UserInterface.TIME, buildTime);
|
|
86
|
+
uiBuilders.set(core.UserInterface.DATETIME, buildDateTime);
|
|
87
|
+
uiBuilders.set(core.UserInterface.FILE, buildFile);
|
|
88
|
+
uiBuilders.set(core.UserInterface.DECIMALNUMBER, buildDecimal);
|
|
89
|
+
uiBuilders.set(core.UserInterface.INTEGERNUMBER, buildInteger);
|
|
90
|
+
uiBuilders.set(core.UserInterface.SEARCH, buildSearch);
|
|
91
|
+
uiBuilders.set(core.UserInterface.LONGTEXT, buildTextArea);
|
|
92
|
+
const fieldBuilder = (field) => {
|
|
93
|
+
const builder = uiBuilders.get(field.userInterface) || buildTextInput;
|
|
94
|
+
const label = field.required ? `${field.label} (obrigatório) *` : field.label;
|
|
95
|
+
return builder(Object.assign(Object.assign({}, field), { label }));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const ezFormViewCss = ".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";
|
|
99
|
+
|
|
100
|
+
let EzFormView = class {
|
|
101
|
+
constructor(hostRef) {
|
|
102
|
+
index.registerInstance(this, hostRef);
|
|
103
|
+
}
|
|
104
|
+
groupFields(fields) {
|
|
105
|
+
const result = new Map();
|
|
106
|
+
fields.forEach(item => {
|
|
107
|
+
const groupLabel = item.group;
|
|
108
|
+
if (groupLabel) {
|
|
109
|
+
let groupFields = result.get(groupLabel);
|
|
110
|
+
if (groupFields == undefined) {
|
|
111
|
+
groupFields = [];
|
|
112
|
+
result.set(groupLabel, groupFields);
|
|
113
|
+
}
|
|
114
|
+
groupFields.push(item);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
result.set(item.name, item);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
render() {
|
|
123
|
+
core.ElementIDUtils.addIDInfoIfNotExists(this._element, 'ezFormView');
|
|
124
|
+
if (this.fields == undefined) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
return (index.h(index.Host, null, Array.from(this.groupFields(this.fields).entries()).map(([label, value]) => {
|
|
128
|
+
if (Array.isArray(value)) {
|
|
129
|
+
return (index.h("ez-collapsible-box", { id: `group-${label}`, label: label, "header-size": "large", key: label }, value.map(fi => fieldBuilder(fi))));
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return fieldBuilder(value);
|
|
133
|
+
}
|
|
134
|
+
})));
|
|
135
|
+
}
|
|
136
|
+
get _element() { return index.getElement(this); }
|
|
137
|
+
};
|
|
138
|
+
EzFormView.style = ezFormViewCss;
|
|
139
|
+
|
|
140
|
+
exports.ez_form_view = EzFormView;
|