@sankhyalabs/ezui 7.1.0-dev.6 → 7.1.0-dev.8
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-popup.cjs.entry.js +6 -6
- package/dist/cjs/ez-tree.cjs.entry.js +123 -13
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ez-popup/ez-popup.css +0 -1
- package/dist/collection/components/ez-popup/ez-popup.js +6 -6
- package/dist/collection/components/ez-tree/ez-tree.js +139 -14
- package/dist/collection/components/ez-tree/subcomponents/TreeItem.js +4 -1
- package/dist/collection/components/ez-tree/types/Node.js +7 -0
- package/dist/collection/components/ez-tree/types/Tree.js +17 -0
- package/dist/collection/components/ez-tree/types/UpdateItemConfig.js +1 -0
- package/dist/custom-elements/index.js +129 -19
- package/dist/esm/ez-popup.entry.js +6 -6
- package/dist/esm/ez-tree.entry.js +123 -13
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-294f54fe.entry.js +1 -0
- package/dist/ezui/p-ed642f02.entry.js +1 -0
- package/dist/types/components/ez-tree/ez-tree.d.ts +15 -1
- 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/ez-tree/types/UpdateItemConfig.d.ts +4 -0
- package/dist/types/components.d.ts +10 -1
- package/package.json +1 -1
- package/dist/ezui/p-6d8f5cb0.entry.js +0 -1
- package/dist/ezui/p-ce5d69da.entry.js +0 -1
|
@@ -83300,7 +83300,7 @@ const EzPopoverPlus$1 = class extends HTMLElement$1 {
|
|
|
83300
83300
|
static get style() { return ezPopoverPlusCss; }
|
|
83301
83301
|
};
|
|
83302
83302
|
|
|
83303
|
-
const ezPopupCss = ":host{display:flex;width:auto;--ez-popup-z-index:var(--elevation--24, 24);--ez-popup__container--color:var(--title--primary, #2b3a54);--ez-popup__container--padding:var(--space--24, 24px);--ez-popup__title--font-family:var(--font--pattern, \"Roboto\");--ez-popup__title--font-size:var(--font-size--xxlarge, 22px);--ez-popup__title--color:var(--title--primary, #00281D);--ez-popup__title--font-weight:var(--font-weight--regular, 400)}.overlay{position:fixed;display:flex;top:0px;z-index:var(--ez-popup-z-index, 24);left:0px;width:100%;align-items:center;justify-content:center;box-sizing:border-box;height:100vh;backdrop-filter:blur(4px);background:rgba(0, 4, 12, 0.4)}.popup__container{width:100%;max-height:90%;height:100%;display:flex;flex-direction:column;overflow:hidden;outline:none;background:#FFFF;color:var(--ez-popup__container--color);border-radius:12px;box-shadow:0px 0px 16px rgba(0, 38, 111, 0.122);box-sizing:border-box;padding:var(--ez-popup__container--padding);margin:0;border:none;position:unset;gap:var(--space--16, 16px)}.popup__container--auto{height:auto}.popup__overflow-y--auto{overflow-y:auto}.popup__content{box-sizing:border-box;height:100%;width:100%}.popup__expandable-content{
|
|
83303
|
+
const ezPopupCss = ":host{display:flex;width:auto;--ez-popup-z-index:var(--elevation--24, 24);--ez-popup__container--color:var(--title--primary, #2b3a54);--ez-popup__container--padding:var(--space--24, 24px);--ez-popup__title--font-family:var(--font--pattern, \"Roboto\");--ez-popup__title--font-size:var(--font-size--xxlarge, 22px);--ez-popup__title--color:var(--title--primary, #00281D);--ez-popup__title--font-weight:var(--font-weight--regular, 400)}.overlay{position:fixed;display:flex;top:0px;z-index:var(--ez-popup-z-index, 24);left:0px;width:100%;align-items:center;justify-content:center;box-sizing:border-box;height:100vh;backdrop-filter:blur(4px);background:rgba(0, 4, 12, 0.4)}.popup__container{width:100%;max-height:90%;height:100%;display:flex;flex-direction:column;overflow:hidden;outline:none;background:#FFFF;color:var(--ez-popup__container--color);border-radius:12px;box-shadow:0px 0px 16px rgba(0, 38, 111, 0.122);box-sizing:border-box;padding:var(--ez-popup__container--padding);margin:0;border:none;position:unset;gap:var(--space--16, 16px)}.popup__container--auto{height:auto}.popup__overflow-y--auto{overflow-y:auto}.popup__content{box-sizing:border-box;height:100%;width:100%}.popup__expandable-content{flex-grow:1;box-sizing:border-box;width:100%;font-family:var(--font--pattern, \"Roboto\");font-size:var(--font-size--default, 14px);color:var(--title--primary, #00281D);font-weight:var(--font-weight--regular, 400);line-height:var(--line-height--24, 24px)}.popup__header{flex-shrink:0;width:100%;display:flex;align-items:center}.popup__title{display:flex;margin:0;width:100%;font-family:var(--ez-popup__title--font-family);font-size:var(--ez-popup__title--font-size);font-weight:var(--ez-popup__title--font-weight);color:var(--ez-popup__title--color);line-height:var(--line-height--32, 32px)}.btn-close{justify-content:flex-end;align-self:flex-start;align-items:flex-start;display:flex;outline:none;border:none;background-color:unset;cursor:pointer}.btn-close--solo{width:100%}.popup__footer{flex-shrink:0;display:flex;width:100%;flex-direction:row-reverse;gap:var(--space--8, 8px)}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}.ez-popup__size-limit--x-small{min-width:350px;max-width:560px}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}";
|
|
83304
83304
|
|
|
83305
83305
|
const EzPopup$1 = class extends HTMLElement$1 {
|
|
83306
83306
|
constructor() {
|
|
@@ -83314,7 +83314,7 @@ const EzPopup$1 = class extends HTMLElement$1 {
|
|
|
83314
83314
|
this.useHeader = true;
|
|
83315
83315
|
this.heightMode = "full";
|
|
83316
83316
|
this.ezTitle = undefined;
|
|
83317
|
-
this.enabledScroll =
|
|
83317
|
+
this.enabledScroll = true;
|
|
83318
83318
|
this.autoClose = true;
|
|
83319
83319
|
this.footerButtons = [];
|
|
83320
83320
|
}
|
|
@@ -83384,9 +83384,6 @@ const EzPopup$1 = class extends HTMLElement$1 {
|
|
|
83384
83384
|
if (this.heightMode === 'auto') {
|
|
83385
83385
|
className += ' popup__container--auto';
|
|
83386
83386
|
}
|
|
83387
|
-
if (this.enabledScroll) {
|
|
83388
|
-
className += ' popup__overflow-y--auto';
|
|
83389
|
-
}
|
|
83390
83387
|
className += ` ${this.getGridSize()}`;
|
|
83391
83388
|
return className;
|
|
83392
83389
|
}
|
|
@@ -83452,7 +83449,10 @@ const EzPopup$1 = class extends HTMLElement$1 {
|
|
|
83452
83449
|
}
|
|
83453
83450
|
render() {
|
|
83454
83451
|
return (h(Host, null, this.opened && (h("div", { class: "overlay", tabIndex: -1, onClick: this.handleAutoClose.bind(this) }, h("dialog", { ref: ref => this._popupRef = ref, class: this.getDialogClass() }, this.useHeader &&
|
|
83455
|
-
h("header", { class: "popup__header" }, !!this.ezTitle && h("h1", { class: "popup__title" }, this.ezTitle), h("ez-button", { class: this.ezTitle ? "btn-close" : "btn-close btn-close--solo", variant: "tertiary", mode: "icon", iconName: "close", size: "small", onClick: this.closePopup.bind(this) })), h("main", { class:
|
|
83452
|
+
h("header", { class: "popup__header" }, !!this.ezTitle && h("h1", { class: "popup__title" }, this.ezTitle), h("ez-button", { class: this.ezTitle ? "btn-close" : "btn-close btn-close--solo", variant: "tertiary", mode: "icon", iconName: "close", size: "small", onClick: this.closePopup.bind(this) })), h("main", { class: {
|
|
83453
|
+
"popup__expandable-content": true,
|
|
83454
|
+
"popup__overflow-y--auto": this.enabledScroll
|
|
83455
|
+
} }, h("slot", null)), h("footer", { class: "popup__footer" }, this.footerButtons.length > 0 && (this.renderFooterButtons()), h("slot", { name: 'footer' })))))));
|
|
83456
83456
|
}
|
|
83457
83457
|
get _element() { return this; }
|
|
83458
83458
|
static get watchers() { return {
|
|
@@ -92301,6 +92301,9 @@ const TreeItem = (props) => {
|
|
|
92301
92301
|
iconClick(treeItem);
|
|
92302
92302
|
}
|
|
92303
92303
|
}
|
|
92304
|
+
function handleIconDoubleClick(event) {
|
|
92305
|
+
event.stopPropagation();
|
|
92306
|
+
}
|
|
92304
92307
|
return (h("ul", { class: level === 1 ? "first-level" : undefined },
|
|
92305
92308
|
h("li", Object.assign({ title: tooltipResolver(treeItem, !disabled, level), class: `tree-item ${treeItem.id !== selectedId ? "tree-item-error" : ""}`, onClick: () => available && itemClick(treeItem), onDblClick: () => available && itemDoubleClick(treeItem) }, {
|
|
92306
92309
|
disabled,
|
|
@@ -92309,7 +92312,7 @@ const TreeItem = (props) => {
|
|
|
92309
92312
|
}),
|
|
92310
92313
|
h("div", { class: "item-label-container" },
|
|
92311
92314
|
h("div", { class: "item-icon-box" }, expandable &&
|
|
92312
|
-
h("ez-icon", { id: treeItem.id, class: "item-icon", size: "small", iconName: iconResolver(treeItem, expanded, level), onClick: (event) => handleIconClick(event) })),
|
|
92315
|
+
h("ez-icon", { id: treeItem.id, class: "item-icon", size: "small", iconName: iconResolver(treeItem, expanded, level), onClick: (event) => handleIconClick(event), onDblClick: (event) => handleIconDoubleClick(event) })),
|
|
92313
92316
|
h("label", { class: `item-label ${treeItem.bold ? "item-label--bold" : ""}` }, treeItem.label)),
|
|
92314
92317
|
getBadgeElement(treeItem.id, treeItem.badge, treeItem.id === selectedId)),
|
|
92315
92318
|
expanded
|
|
@@ -92401,6 +92404,13 @@ class Node$1 {
|
|
|
92401
92404
|
this.children.set(item.id, new Node$1(tree, item, this));
|
|
92402
92405
|
}
|
|
92403
92406
|
}
|
|
92407
|
+
removeChild(id) {
|
|
92408
|
+
if (this.children.has(id)) {
|
|
92409
|
+
this.children.delete(id);
|
|
92410
|
+
return true;
|
|
92411
|
+
}
|
|
92412
|
+
return false;
|
|
92413
|
+
}
|
|
92404
92414
|
addPlaceHolder() {
|
|
92405
92415
|
this.children.clear();
|
|
92406
92416
|
const id = this.item.id;
|
|
@@ -92515,6 +92525,23 @@ class Tree extends Node$1 {
|
|
|
92515
92525
|
}
|
|
92516
92526
|
this._changeCallback();
|
|
92517
92527
|
}
|
|
92528
|
+
removeItem(id) {
|
|
92529
|
+
if (!id) {
|
|
92530
|
+
return;
|
|
92531
|
+
}
|
|
92532
|
+
const node = this.getNode(id);
|
|
92533
|
+
if (!node) {
|
|
92534
|
+
return;
|
|
92535
|
+
}
|
|
92536
|
+
if (node.parent) {
|
|
92537
|
+
node.parent.removeChild(id);
|
|
92538
|
+
}
|
|
92539
|
+
else {
|
|
92540
|
+
this.children.delete(id);
|
|
92541
|
+
}
|
|
92542
|
+
this._disabledValues.delete(id);
|
|
92543
|
+
this._changeCallback();
|
|
92544
|
+
}
|
|
92518
92545
|
async open(path) {
|
|
92519
92546
|
return new Promise(async (resolve) => {
|
|
92520
92547
|
await this.walkPath(this, path, node => node.item.expanded = true);
|
|
@@ -92648,6 +92675,7 @@ const EzTree$1 = class extends HTMLElement$1 {
|
|
|
92648
92675
|
this.ezChange = createEvent(this, "ezChange", 7);
|
|
92649
92676
|
this.ezOpenItem = createEvent(this, "ezOpenItem", 7);
|
|
92650
92677
|
this.ezDbClickItem = createEvent(this, "ezDbClickItem", 7);
|
|
92678
|
+
this.ezRemoveItem = createEvent(this, "ezRemoveItem", 7);
|
|
92651
92679
|
this._onItemClick = (item) => {
|
|
92652
92680
|
if (!this.selectable) {
|
|
92653
92681
|
this.openClose(item);
|
|
@@ -92751,12 +92779,48 @@ const EzTree$1 = class extends HTMLElement$1 {
|
|
|
92751
92779
|
/**
|
|
92752
92780
|
* Atualiza um item
|
|
92753
92781
|
*/
|
|
92754
|
-
async updateItem(item) {
|
|
92755
|
-
var _a;
|
|
92756
|
-
|
|
92782
|
+
async updateItem(item, config) {
|
|
92783
|
+
var _a, _b, _c;
|
|
92784
|
+
if (Array.isArray(item)) {
|
|
92785
|
+
item.forEach(i => this.updateItem(i, config));
|
|
92786
|
+
return;
|
|
92787
|
+
}
|
|
92788
|
+
if (config === null || config === void 0 ? void 0 : config.updatedBySelectedId) {
|
|
92789
|
+
Object.assign(item, { id: this.selectedId });
|
|
92790
|
+
}
|
|
92791
|
+
this._tree.updateItem((config === null || config === void 0 ? void 0 : config.forceDefaultValues) ? this.applyDefaultValues(item) : item);
|
|
92792
|
+
this.updateItemInIndexedList(item, config === null || config === void 0 ? void 0 : config.forceDefaultValues);
|
|
92757
92793
|
const node = (_a = this._tree) === null || _a === void 0 ? void 0 : _a.getNode(this.selectedId);
|
|
92758
92794
|
if (node == undefined) {
|
|
92759
92795
|
this.value = this._visibleItems ? this._visibleItems[0] : undefined;
|
|
92796
|
+
this._tree.collapseAll();
|
|
92797
|
+
}
|
|
92798
|
+
if (((_b = this.value) === null || _b === void 0 ? void 0 : _b.id) === item.id) {
|
|
92799
|
+
this.value = item;
|
|
92800
|
+
this.ezChange.emit(this.value);
|
|
92801
|
+
return;
|
|
92802
|
+
}
|
|
92803
|
+
const childSelected = this.getItemById((_c = this.value) === null || _c === void 0 ? void 0 : _c.id, [item]);
|
|
92804
|
+
if (childSelected) {
|
|
92805
|
+
this.value = childSelected;
|
|
92806
|
+
this.ezChange.emit(this.value);
|
|
92807
|
+
}
|
|
92808
|
+
}
|
|
92809
|
+
/**
|
|
92810
|
+
* Remove um item da árvore pelo seu ID.
|
|
92811
|
+
* Se o item removido estiver selecionado, a seleção será limpa.
|
|
92812
|
+
*/
|
|
92813
|
+
async removeItem(id) {
|
|
92814
|
+
var _a;
|
|
92815
|
+
id = id !== null && id !== void 0 ? id : this.selectedId;
|
|
92816
|
+
if (!id) {
|
|
92817
|
+
return;
|
|
92818
|
+
}
|
|
92819
|
+
this._tree.removeItem(id);
|
|
92820
|
+
this.removeItemFromIndexedList(id);
|
|
92821
|
+
this.ezRemoveItem.emit(id);
|
|
92822
|
+
if (((_a = this.value) === null || _a === void 0 ? void 0 : _a.id) === id) {
|
|
92823
|
+
this.value = undefined;
|
|
92760
92824
|
}
|
|
92761
92825
|
}
|
|
92762
92826
|
/**
|
|
@@ -92844,23 +92908,69 @@ const EzTree$1 = class extends HTMLElement$1 {
|
|
|
92844
92908
|
event.preventDefault();
|
|
92845
92909
|
}
|
|
92846
92910
|
}
|
|
92911
|
+
getItemById(id, items) {
|
|
92912
|
+
for (const treeItem of items) {
|
|
92913
|
+
if (treeItem.id === id) {
|
|
92914
|
+
return treeItem;
|
|
92915
|
+
}
|
|
92916
|
+
else if (treeItem.children && Array.isArray(treeItem.children)) {
|
|
92917
|
+
const itemFound = this.getItemById(id, treeItem.children);
|
|
92918
|
+
if (itemFound) {
|
|
92919
|
+
return itemFound;
|
|
92920
|
+
}
|
|
92921
|
+
}
|
|
92922
|
+
}
|
|
92923
|
+
return undefined;
|
|
92924
|
+
}
|
|
92847
92925
|
addItemInIndexedList(parentId, item, items) {
|
|
92848
92926
|
var _a, _b;
|
|
92849
92927
|
items = (_a = items !== null && items !== void 0 ? items : this.items) !== null && _a !== void 0 ? _a : [];
|
|
92850
92928
|
if (!parentId) {
|
|
92851
92929
|
items.push(item);
|
|
92930
|
+
}
|
|
92931
|
+
const itemFound = this.getItemById(parentId, items);
|
|
92932
|
+
itemFound.children = ((_b = itemFound.children) !== null && _b !== void 0 ? _b : []);
|
|
92933
|
+
itemFound.children.push(item);
|
|
92934
|
+
itemFound.childrenCount = itemFound.children.length;
|
|
92935
|
+
}
|
|
92936
|
+
applyDefaultValues(item) {
|
|
92937
|
+
if (item.disabled === undefined) {
|
|
92938
|
+
item.disabled = false;
|
|
92939
|
+
}
|
|
92940
|
+
if (item.expanded === undefined) {
|
|
92941
|
+
item.expanded = false;
|
|
92942
|
+
}
|
|
92943
|
+
return item;
|
|
92944
|
+
}
|
|
92945
|
+
updateItemInIndexedList(item, forceDefaultValues = false) {
|
|
92946
|
+
if (!item || !this.items) {
|
|
92947
|
+
return;
|
|
92948
|
+
}
|
|
92949
|
+
const itemFound = this.getItemById(item.id, this.items);
|
|
92950
|
+
if (itemFound) {
|
|
92951
|
+
Object.assign(itemFound, forceDefaultValues ? this.applyDefaultValues(item) : item);
|
|
92952
|
+
}
|
|
92953
|
+
}
|
|
92954
|
+
removeItemFromIndexedList(id, items) {
|
|
92955
|
+
var _a;
|
|
92956
|
+
items = (_a = items !== null && items !== void 0 ? items : this.items) !== null && _a !== void 0 ? _a : [];
|
|
92957
|
+
if (!id) {
|
|
92958
|
+
return false;
|
|
92959
|
+
}
|
|
92960
|
+
const rootIndex = items.findIndex(item => item.id === id);
|
|
92961
|
+
if (rootIndex !== -1) {
|
|
92962
|
+
items.splice(rootIndex, 1);
|
|
92852
92963
|
return true;
|
|
92853
92964
|
}
|
|
92854
92965
|
for (const treeItem of items) {
|
|
92855
|
-
if (treeItem.
|
|
92856
|
-
|
|
92857
|
-
|
|
92858
|
-
|
|
92859
|
-
|
|
92860
|
-
|
|
92861
|
-
|
|
92862
|
-
|
|
92863
|
-
if (result) {
|
|
92966
|
+
if (treeItem.children && Array.isArray(treeItem.children)) {
|
|
92967
|
+
const childIndex = treeItem.children.findIndex(child => child.id === id);
|
|
92968
|
+
if (childIndex !== -1) {
|
|
92969
|
+
treeItem.children.splice(childIndex, 1);
|
|
92970
|
+
treeItem.childrenCount = treeItem.children.length;
|
|
92971
|
+
return true;
|
|
92972
|
+
}
|
|
92973
|
+
if (this.removeItemFromIndexedList(id, treeItem.children)) {
|
|
92864
92974
|
return true;
|
|
92865
92975
|
}
|
|
92866
92976
|
}
|
|
@@ -2,7 +2,7 @@ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement
|
|
|
2
2
|
import { KeyboardManager, FloatingManager } from '@sankhyalabs/core';
|
|
3
3
|
import { i as initI18n } from './index-62fc771e.js';
|
|
4
4
|
|
|
5
|
-
const ezPopupCss = ":host{display:flex;width:auto;--ez-popup-z-index:var(--elevation--24, 24);--ez-popup__container--color:var(--title--primary, #2b3a54);--ez-popup__container--padding:var(--space--24, 24px);--ez-popup__title--font-family:var(--font--pattern, \"Roboto\");--ez-popup__title--font-size:var(--font-size--xxlarge, 22px);--ez-popup__title--color:var(--title--primary, #00281D);--ez-popup__title--font-weight:var(--font-weight--regular, 400)}.overlay{position:fixed;display:flex;top:0px;z-index:var(--ez-popup-z-index, 24);left:0px;width:100%;align-items:center;justify-content:center;box-sizing:border-box;height:100vh;backdrop-filter:blur(4px);background:rgba(0, 4, 12, 0.4)}.popup__container{width:100%;max-height:90%;height:100%;display:flex;flex-direction:column;overflow:hidden;outline:none;background:#FFFF;color:var(--ez-popup__container--color);border-radius:12px;box-shadow:0px 0px 16px rgba(0, 38, 111, 0.122);box-sizing:border-box;padding:var(--ez-popup__container--padding);margin:0;border:none;position:unset;gap:var(--space--16, 16px)}.popup__container--auto{height:auto}.popup__overflow-y--auto{overflow-y:auto}.popup__content{box-sizing:border-box;height:100%;width:100%}.popup__expandable-content{
|
|
5
|
+
const ezPopupCss = ":host{display:flex;width:auto;--ez-popup-z-index:var(--elevation--24, 24);--ez-popup__container--color:var(--title--primary, #2b3a54);--ez-popup__container--padding:var(--space--24, 24px);--ez-popup__title--font-family:var(--font--pattern, \"Roboto\");--ez-popup__title--font-size:var(--font-size--xxlarge, 22px);--ez-popup__title--color:var(--title--primary, #00281D);--ez-popup__title--font-weight:var(--font-weight--regular, 400)}.overlay{position:fixed;display:flex;top:0px;z-index:var(--ez-popup-z-index, 24);left:0px;width:100%;align-items:center;justify-content:center;box-sizing:border-box;height:100vh;backdrop-filter:blur(4px);background:rgba(0, 4, 12, 0.4)}.popup__container{width:100%;max-height:90%;height:100%;display:flex;flex-direction:column;overflow:hidden;outline:none;background:#FFFF;color:var(--ez-popup__container--color);border-radius:12px;box-shadow:0px 0px 16px rgba(0, 38, 111, 0.122);box-sizing:border-box;padding:var(--ez-popup__container--padding);margin:0;border:none;position:unset;gap:var(--space--16, 16px)}.popup__container--auto{height:auto}.popup__overflow-y--auto{overflow-y:auto}.popup__content{box-sizing:border-box;height:100%;width:100%}.popup__expandable-content{flex-grow:1;box-sizing:border-box;width:100%;font-family:var(--font--pattern, \"Roboto\");font-size:var(--font-size--default, 14px);color:var(--title--primary, #00281D);font-weight:var(--font-weight--regular, 400);line-height:var(--line-height--24, 24px)}.popup__header{flex-shrink:0;width:100%;display:flex;align-items:center}.popup__title{display:flex;margin:0;width:100%;font-family:var(--ez-popup__title--font-family);font-size:var(--ez-popup__title--font-size);font-weight:var(--ez-popup__title--font-weight);color:var(--ez-popup__title--color);line-height:var(--line-height--32, 32px)}.btn-close{justify-content:flex-end;align-self:flex-start;align-items:flex-start;display:flex;outline:none;border:none;background-color:unset;cursor:pointer}.btn-close--solo{width:100%}.popup__footer{flex-shrink:0;display:flex;width:100%;flex-direction:row-reverse;gap:var(--space--8, 8px)}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}.ez-popup__size-limit--x-small{min-width:350px;max-width:560px}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}";
|
|
6
6
|
|
|
7
7
|
const EzPopup = class {
|
|
8
8
|
constructor(hostRef) {
|
|
@@ -14,7 +14,7 @@ const EzPopup = class {
|
|
|
14
14
|
this.useHeader = true;
|
|
15
15
|
this.heightMode = "full";
|
|
16
16
|
this.ezTitle = undefined;
|
|
17
|
-
this.enabledScroll =
|
|
17
|
+
this.enabledScroll = true;
|
|
18
18
|
this.autoClose = true;
|
|
19
19
|
this.footerButtons = [];
|
|
20
20
|
}
|
|
@@ -84,9 +84,6 @@ const EzPopup = class {
|
|
|
84
84
|
if (this.heightMode === 'auto') {
|
|
85
85
|
className += ' popup__container--auto';
|
|
86
86
|
}
|
|
87
|
-
if (this.enabledScroll) {
|
|
88
|
-
className += ' popup__overflow-y--auto';
|
|
89
|
-
}
|
|
90
87
|
className += ` ${this.getGridSize()}`;
|
|
91
88
|
return className;
|
|
92
89
|
}
|
|
@@ -152,7 +149,10 @@ const EzPopup = class {
|
|
|
152
149
|
}
|
|
153
150
|
render() {
|
|
154
151
|
return (h(Host, null, this.opened && (h("div", { class: "overlay", tabIndex: -1, onClick: this.handleAutoClose.bind(this) }, h("dialog", { ref: ref => this._popupRef = ref, class: this.getDialogClass() }, this.useHeader &&
|
|
155
|
-
h("header", { class: "popup__header" }, !!this.ezTitle && h("h1", { class: "popup__title" }, this.ezTitle), h("ez-button", { class: this.ezTitle ? "btn-close" : "btn-close btn-close--solo", variant: "tertiary", mode: "icon", iconName: "close", size: "small", onClick: this.closePopup.bind(this) })), h("main", { class:
|
|
152
|
+
h("header", { class: "popup__header" }, !!this.ezTitle && h("h1", { class: "popup__title" }, this.ezTitle), h("ez-button", { class: this.ezTitle ? "btn-close" : "btn-close btn-close--solo", variant: "tertiary", mode: "icon", iconName: "close", size: "small", onClick: this.closePopup.bind(this) })), h("main", { class: {
|
|
153
|
+
"popup__expandable-content": true,
|
|
154
|
+
"popup__overflow-y--auto": this.enabledScroll
|
|
155
|
+
} }, h("slot", null)), h("footer", { class: "popup__footer" }, this.footerButtons.length > 0 && (this.renderFooterButtons()), h("slot", { name: 'footer' })))))));
|
|
156
156
|
}
|
|
157
157
|
get _element() { return getElement(this); }
|
|
158
158
|
static get watchers() { return {
|
|
@@ -35,6 +35,9 @@ const TreeItem = (props) => {
|
|
|
35
35
|
iconClick(treeItem);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
function handleIconDoubleClick(event) {
|
|
39
|
+
event.stopPropagation();
|
|
40
|
+
}
|
|
38
41
|
return (h("ul", { class: level === 1 ? "first-level" : undefined },
|
|
39
42
|
h("li", Object.assign({ title: tooltipResolver(treeItem, !disabled, level), class: `tree-item ${treeItem.id !== selectedId ? "tree-item-error" : ""}`, onClick: () => available && itemClick(treeItem), onDblClick: () => available && itemDoubleClick(treeItem) }, {
|
|
40
43
|
disabled,
|
|
@@ -43,7 +46,7 @@ const TreeItem = (props) => {
|
|
|
43
46
|
}),
|
|
44
47
|
h("div", { class: "item-label-container" },
|
|
45
48
|
h("div", { class: "item-icon-box" }, expandable &&
|
|
46
|
-
h("ez-icon", { id: treeItem.id, class: "item-icon", size: "small", iconName: iconResolver(treeItem, expanded, level), onClick: (event) => handleIconClick(event) })),
|
|
49
|
+
h("ez-icon", { id: treeItem.id, class: "item-icon", size: "small", iconName: iconResolver(treeItem, expanded, level), onClick: (event) => handleIconClick(event), onDblClick: (event) => handleIconDoubleClick(event) })),
|
|
47
50
|
h("label", { class: `item-label ${treeItem.bold ? "item-label--bold" : ""}` }, treeItem.label)),
|
|
48
51
|
getBadgeElement(treeItem.id, treeItem.badge, treeItem.id === selectedId)),
|
|
49
52
|
expanded
|
|
@@ -135,6 +138,13 @@ class Node {
|
|
|
135
138
|
this.children.set(item.id, new Node(tree, item, this));
|
|
136
139
|
}
|
|
137
140
|
}
|
|
141
|
+
removeChild(id) {
|
|
142
|
+
if (this.children.has(id)) {
|
|
143
|
+
this.children.delete(id);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
138
148
|
addPlaceHolder() {
|
|
139
149
|
this.children.clear();
|
|
140
150
|
const id = this.item.id;
|
|
@@ -249,6 +259,23 @@ class Tree extends Node {
|
|
|
249
259
|
}
|
|
250
260
|
this._changeCallback();
|
|
251
261
|
}
|
|
262
|
+
removeItem(id) {
|
|
263
|
+
if (!id) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const node = this.getNode(id);
|
|
267
|
+
if (!node) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (node.parent) {
|
|
271
|
+
node.parent.removeChild(id);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
this.children.delete(id);
|
|
275
|
+
}
|
|
276
|
+
this._disabledValues.delete(id);
|
|
277
|
+
this._changeCallback();
|
|
278
|
+
}
|
|
252
279
|
async open(path) {
|
|
253
280
|
return new Promise(async (resolve) => {
|
|
254
281
|
await this.walkPath(this, path, node => node.item.expanded = true);
|
|
@@ -380,6 +407,7 @@ const EzTree = class {
|
|
|
380
407
|
this.ezChange = createEvent(this, "ezChange", 7);
|
|
381
408
|
this.ezOpenItem = createEvent(this, "ezOpenItem", 7);
|
|
382
409
|
this.ezDbClickItem = createEvent(this, "ezDbClickItem", 7);
|
|
410
|
+
this.ezRemoveItem = createEvent(this, "ezRemoveItem", 7);
|
|
383
411
|
this._onItemClick = (item) => {
|
|
384
412
|
if (!this.selectable) {
|
|
385
413
|
this.openClose(item);
|
|
@@ -483,12 +511,48 @@ const EzTree = class {
|
|
|
483
511
|
/**
|
|
484
512
|
* Atualiza um item
|
|
485
513
|
*/
|
|
486
|
-
async updateItem(item) {
|
|
487
|
-
var _a;
|
|
488
|
-
|
|
514
|
+
async updateItem(item, config) {
|
|
515
|
+
var _a, _b, _c;
|
|
516
|
+
if (Array.isArray(item)) {
|
|
517
|
+
item.forEach(i => this.updateItem(i, config));
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (config === null || config === void 0 ? void 0 : config.updatedBySelectedId) {
|
|
521
|
+
Object.assign(item, { id: this.selectedId });
|
|
522
|
+
}
|
|
523
|
+
this._tree.updateItem((config === null || config === void 0 ? void 0 : config.forceDefaultValues) ? this.applyDefaultValues(item) : item);
|
|
524
|
+
this.updateItemInIndexedList(item, config === null || config === void 0 ? void 0 : config.forceDefaultValues);
|
|
489
525
|
const node = (_a = this._tree) === null || _a === void 0 ? void 0 : _a.getNode(this.selectedId);
|
|
490
526
|
if (node == undefined) {
|
|
491
527
|
this.value = this._visibleItems ? this._visibleItems[0] : undefined;
|
|
528
|
+
this._tree.collapseAll();
|
|
529
|
+
}
|
|
530
|
+
if (((_b = this.value) === null || _b === void 0 ? void 0 : _b.id) === item.id) {
|
|
531
|
+
this.value = item;
|
|
532
|
+
this.ezChange.emit(this.value);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const childSelected = this.getItemById((_c = this.value) === null || _c === void 0 ? void 0 : _c.id, [item]);
|
|
536
|
+
if (childSelected) {
|
|
537
|
+
this.value = childSelected;
|
|
538
|
+
this.ezChange.emit(this.value);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Remove um item da árvore pelo seu ID.
|
|
543
|
+
* Se o item removido estiver selecionado, a seleção será limpa.
|
|
544
|
+
*/
|
|
545
|
+
async removeItem(id) {
|
|
546
|
+
var _a;
|
|
547
|
+
id = id !== null && id !== void 0 ? id : this.selectedId;
|
|
548
|
+
if (!id) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
this._tree.removeItem(id);
|
|
552
|
+
this.removeItemFromIndexedList(id);
|
|
553
|
+
this.ezRemoveItem.emit(id);
|
|
554
|
+
if (((_a = this.value) === null || _a === void 0 ? void 0 : _a.id) === id) {
|
|
555
|
+
this.value = undefined;
|
|
492
556
|
}
|
|
493
557
|
}
|
|
494
558
|
/**
|
|
@@ -576,23 +640,69 @@ const EzTree = class {
|
|
|
576
640
|
event.preventDefault();
|
|
577
641
|
}
|
|
578
642
|
}
|
|
643
|
+
getItemById(id, items) {
|
|
644
|
+
for (const treeItem of items) {
|
|
645
|
+
if (treeItem.id === id) {
|
|
646
|
+
return treeItem;
|
|
647
|
+
}
|
|
648
|
+
else if (treeItem.children && Array.isArray(treeItem.children)) {
|
|
649
|
+
const itemFound = this.getItemById(id, treeItem.children);
|
|
650
|
+
if (itemFound) {
|
|
651
|
+
return itemFound;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return undefined;
|
|
656
|
+
}
|
|
579
657
|
addItemInIndexedList(parentId, item, items) {
|
|
580
658
|
var _a, _b;
|
|
581
659
|
items = (_a = items !== null && items !== void 0 ? items : this.items) !== null && _a !== void 0 ? _a : [];
|
|
582
660
|
if (!parentId) {
|
|
583
661
|
items.push(item);
|
|
662
|
+
}
|
|
663
|
+
const itemFound = this.getItemById(parentId, items);
|
|
664
|
+
itemFound.children = ((_b = itemFound.children) !== null && _b !== void 0 ? _b : []);
|
|
665
|
+
itemFound.children.push(item);
|
|
666
|
+
itemFound.childrenCount = itemFound.children.length;
|
|
667
|
+
}
|
|
668
|
+
applyDefaultValues(item) {
|
|
669
|
+
if (item.disabled === undefined) {
|
|
670
|
+
item.disabled = false;
|
|
671
|
+
}
|
|
672
|
+
if (item.expanded === undefined) {
|
|
673
|
+
item.expanded = false;
|
|
674
|
+
}
|
|
675
|
+
return item;
|
|
676
|
+
}
|
|
677
|
+
updateItemInIndexedList(item, forceDefaultValues = false) {
|
|
678
|
+
if (!item || !this.items) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
const itemFound = this.getItemById(item.id, this.items);
|
|
682
|
+
if (itemFound) {
|
|
683
|
+
Object.assign(itemFound, forceDefaultValues ? this.applyDefaultValues(item) : item);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
removeItemFromIndexedList(id, items) {
|
|
687
|
+
var _a;
|
|
688
|
+
items = (_a = items !== null && items !== void 0 ? items : this.items) !== null && _a !== void 0 ? _a : [];
|
|
689
|
+
if (!id) {
|
|
690
|
+
return false;
|
|
691
|
+
}
|
|
692
|
+
const rootIndex = items.findIndex(item => item.id === id);
|
|
693
|
+
if (rootIndex !== -1) {
|
|
694
|
+
items.splice(rootIndex, 1);
|
|
584
695
|
return true;
|
|
585
696
|
}
|
|
586
697
|
for (const treeItem of items) {
|
|
587
|
-
if (treeItem.
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
if (result) {
|
|
698
|
+
if (treeItem.children && Array.isArray(treeItem.children)) {
|
|
699
|
+
const childIndex = treeItem.children.findIndex(child => child.id === id);
|
|
700
|
+
if (childIndex !== -1) {
|
|
701
|
+
treeItem.children.splice(childIndex, 1);
|
|
702
|
+
treeItem.childrenCount = treeItem.children.length;
|
|
703
|
+
return true;
|
|
704
|
+
}
|
|
705
|
+
if (this.removeItemFromIndexedList(id, treeItem.children)) {
|
|
596
706
|
return true;
|
|
597
707
|
}
|
|
598
708
|
}
|