@sankhyalabs/ezui 2.7.6 → 2.9.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-breadcrumb.cjs.entry.js +35 -0
- package/dist/cjs/ez-tree.cjs.entry.js +375 -0
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/ez-breadcrumb/ez-breadcrumb.css +53 -0
- package/dist/collection/components/ez-breadcrumb/ez-breadcrumb.js +80 -0
- package/dist/collection/components/ez-tree/ez-tree.css +154 -0
- package/dist/collection/components/ez-tree/ez-tree.js +428 -0
- package/dist/collection/components/ez-tree/interfaces/ITree.js +1 -0
- package/dist/collection/components/ez-tree/interfaces/ITreeItem.js +1 -0
- package/dist/collection/components/ez-tree/subcomponents/DefaultIconResolver.js +8 -0
- package/dist/collection/components/ez-tree/subcomponents/TreeItem.js +25 -0
- package/dist/collection/components/ez-tree/subcomponents/index.js +1 -0
- package/dist/collection/components/ez-tree/types/Node.js +72 -0
- package/dist/collection/components/ez-tree/types/Tree.js +70 -0
- package/dist/custom-elements/index.d.ts +12 -0
- package/dist/custom-elements/index.js +413 -11
- package/dist/esm/ez-breadcrumb.entry.js +31 -0
- package/dist/esm/ez-tree.entry.js +371 -0
- 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-171c3236.entry.js +1 -0
- package/dist/ezui/p-79e409c6.entry.js +1 -0
- package/dist/types/components/ez-breadcrumb/ez-breadcrumb.d.ts +20 -0
- package/dist/types/components/ez-tree/ez-tree.d.ts +66 -0
- package/dist/types/components/ez-tree/interfaces/ITree.d.ts +5 -0
- package/dist/types/components/ez-tree/interfaces/ITreeItem.d.ts +10 -0
- package/dist/types/components/ez-tree/subcomponents/DefaultIconResolver.d.ts +2 -0
- package/dist/types/components/ez-tree/subcomponents/TreeItem.d.ts +13 -0
- package/dist/types/components/ez-tree/subcomponents/index.d.ts +1 -0
- package/dist/types/components/ez-tree/types/Node.d.ts +20 -0
- package/dist/types/components/ez-tree/types/Tree.d.ts +16 -0
- package/dist/types/components.d.ts +92 -0
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultIconResolver } from "./DefaultIconResolver";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export class Node {
|
|
2
|
+
constructor(tree, item, parent, isPlaceHolder = false) {
|
|
3
|
+
this.children = new Map();
|
|
4
|
+
this.item = item;
|
|
5
|
+
this.parent = parent;
|
|
6
|
+
this._tree = tree;
|
|
7
|
+
this.isPlaceHolder = isPlaceHolder;
|
|
8
|
+
if (item && !isPlaceHolder) {
|
|
9
|
+
this._isLazyLoad = typeof item.children === "function" || item.childrenCount > 0;
|
|
10
|
+
if (Array.isArray(item.children)) {
|
|
11
|
+
Array.from(item.children).forEach(item => this.addChild(this._tree, item));
|
|
12
|
+
this._childrenLoaded = true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
this._isLazyLoad = false;
|
|
17
|
+
this._childrenLoaded = true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
isDisabled() {
|
|
21
|
+
if (this.isPlaceHolder) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return this._tree.isNodeDisabled(this.item.id, this.item.disabled);
|
|
25
|
+
}
|
|
26
|
+
updateChildren(children) {
|
|
27
|
+
if (this.isPlaceHolder) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.item.children = children;
|
|
31
|
+
this._childrenLoaded = true;
|
|
32
|
+
this.children.clear();
|
|
33
|
+
children.forEach(item => this.addChild(this._tree, Object.assign({}, item)));
|
|
34
|
+
}
|
|
35
|
+
addChild(tree, item) {
|
|
36
|
+
if (!this.children.has(item.id)) {
|
|
37
|
+
this.children.set(item.id, new Node(tree, item, this));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
addPlaceHolder() {
|
|
41
|
+
this.children.clear();
|
|
42
|
+
const id = this.item.id;
|
|
43
|
+
this.children.set(id, new Node(undefined, { id: `placeholder_${id}`, label: "Carregando..." }, this, true));
|
|
44
|
+
}
|
|
45
|
+
getNode(id) {
|
|
46
|
+
if (this.children.has(id)) {
|
|
47
|
+
return this.children.get(id);
|
|
48
|
+
}
|
|
49
|
+
const childrenArray = Array.from(this.children.values());
|
|
50
|
+
for (const child of childrenArray) {
|
|
51
|
+
const result = child.getNode(id);
|
|
52
|
+
if (result) {
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
needLoad() {
|
|
58
|
+
return this._isLazyLoad && !this._childrenLoaded;
|
|
59
|
+
}
|
|
60
|
+
isExpandable() {
|
|
61
|
+
return this._isLazyLoad || this.children.size > 0 || Array.isArray(this.item.children);
|
|
62
|
+
}
|
|
63
|
+
getChildren() {
|
|
64
|
+
if (this.isPlaceHolder) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
if (this.needLoad()) {
|
|
68
|
+
this._tree.loadChildren(this);
|
|
69
|
+
}
|
|
70
|
+
return Array.from(this.children.values());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Node } from "./Node";
|
|
2
|
+
export class Tree extends Node {
|
|
3
|
+
constructor(changeCallback) {
|
|
4
|
+
super(undefined);
|
|
5
|
+
this._disabledValues = new Map();
|
|
6
|
+
this._changeCallback = changeCallback;
|
|
7
|
+
}
|
|
8
|
+
async addChildAt(parentId, item) {
|
|
9
|
+
const parent = this.getNode(parentId);
|
|
10
|
+
if (parent == undefined) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
parent.addChild(this, item);
|
|
14
|
+
this._changeCallback();
|
|
15
|
+
}
|
|
16
|
+
setDisabled(id, value) {
|
|
17
|
+
this._disabledValues.set(id, value);
|
|
18
|
+
this._changeCallback();
|
|
19
|
+
}
|
|
20
|
+
isNodeDisabled(id, defaultValue) {
|
|
21
|
+
if (!this._disabledValues.has(id)) {
|
|
22
|
+
return defaultValue;
|
|
23
|
+
}
|
|
24
|
+
return this._disabledValues.get(id);
|
|
25
|
+
}
|
|
26
|
+
load(items) {
|
|
27
|
+
this.children.clear();
|
|
28
|
+
items.forEach(item => this.addChild(this, Object.assign({}, item)));
|
|
29
|
+
}
|
|
30
|
+
async open(path) {
|
|
31
|
+
return new Promise(async (resolve) => {
|
|
32
|
+
await this.walk(this, path, node => node.item.expanded = true);
|
|
33
|
+
resolve();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async walk(parent, path, callback, currentLevel = 0) {
|
|
37
|
+
return new Promise(async (resolve) => {
|
|
38
|
+
const levels = path.split(">>").map(item => item.trim());
|
|
39
|
+
if (levels.length > currentLevel) {
|
|
40
|
+
const node = parent.getNode(levels[currentLevel]);
|
|
41
|
+
if (node) {
|
|
42
|
+
if (node.needLoad()) {
|
|
43
|
+
await this.loadLevel(node);
|
|
44
|
+
}
|
|
45
|
+
callback(node);
|
|
46
|
+
await this.walk(node, path, callback, currentLevel + 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
resolve();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async loadChildren(node) {
|
|
53
|
+
return new Promise(resolve => {
|
|
54
|
+
this.loadLevel(node).then(() => {
|
|
55
|
+
resolve();
|
|
56
|
+
this._changeCallback();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async loadLevel(node) {
|
|
61
|
+
return new Promise(resolve => {
|
|
62
|
+
node.addPlaceHolder();
|
|
63
|
+
const loader = node.item.children;
|
|
64
|
+
loader(node.item).then(result => {
|
|
65
|
+
node.updateChildren(result);
|
|
66
|
+
resolve();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -20,6 +20,12 @@ export const EzApplication: {
|
|
|
20
20
|
new (): EzApplication;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
interface EzBreadcrumb extends Components.EzBreadcrumb, HTMLElement {}
|
|
24
|
+
export const EzBreadcrumb: {
|
|
25
|
+
prototype: EzBreadcrumb;
|
|
26
|
+
new (): EzBreadcrumb;
|
|
27
|
+
};
|
|
28
|
+
|
|
23
29
|
interface EzButton extends Components.EzButton, HTMLElement {}
|
|
24
30
|
export const EzButton: {
|
|
25
31
|
prototype: EzButton;
|
|
@@ -206,6 +212,12 @@ export const EzToast: {
|
|
|
206
212
|
new (): EzToast;
|
|
207
213
|
};
|
|
208
214
|
|
|
215
|
+
interface EzTree extends Components.EzTree, HTMLElement {}
|
|
216
|
+
export const EzTree: {
|
|
217
|
+
prototype: EzTree;
|
|
218
|
+
new (): EzTree;
|
|
219
|
+
};
|
|
220
|
+
|
|
209
221
|
interface EzUpload extends Components.EzUpload, HTMLElement {}
|
|
210
222
|
export const EzUpload: {
|
|
211
223
|
prototype: EzUpload;
|