@sankhyalabs/ezui 2.7.5 → 2.8.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-date-time-input.cjs.entry.js +10 -3
- 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 +1 -0
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +10 -3
- 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 +6 -0
- package/dist/custom-elements/index.js +392 -14
- package/dist/esm/ez-date-time-input.entry.js +10 -3
- 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-37335c51.entry.js +1 -0
- package/dist/ezui/p-79e409c6.entry.js +1 -0
- package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +1 -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 +66 -0
- package/package.json +1 -1
- package/react/components.d.ts +1 -0
- package/react/components.js +1 -0
- package/react/components.js.map +1 -1
- package/dist/ezui/p-7b906805.entry.js +0 -1
|
@@ -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
|
+
}
|
|
@@ -206,6 +206,12 @@ export const EzToast: {
|
|
|
206
206
|
new (): EzToast;
|
|
207
207
|
};
|
|
208
208
|
|
|
209
|
+
interface EzTree extends Components.EzTree, HTMLElement {}
|
|
210
|
+
export const EzTree: {
|
|
211
|
+
prototype: EzTree;
|
|
212
|
+
new (): EzTree;
|
|
213
|
+
};
|
|
214
|
+
|
|
209
215
|
interface EzUpload extends Components.EzUpload, HTMLElement {}
|
|
210
216
|
export const EzUpload: {
|
|
211
217
|
prototype: EzUpload;
|
|
@@ -1810,6 +1810,10 @@ let EzDateTimeInput$1 = class extends HTMLElement$1 {
|
|
|
1810
1810
|
this._calendar.fitVertical(top, this._elem.clientHeight);
|
|
1811
1811
|
this._calendar.style.visibility = 'inherit';
|
|
1812
1812
|
}
|
|
1813
|
+
hideCalendar() {
|
|
1814
|
+
this.changeValue(this._calendar.value);
|
|
1815
|
+
this._calendar.hide();
|
|
1816
|
+
}
|
|
1813
1817
|
getParsedDateTime(strValue) {
|
|
1814
1818
|
var _a, _b;
|
|
1815
1819
|
if (strValue === void 0) {
|
|
@@ -1850,7 +1854,7 @@ let EzDateTimeInput$1 = class extends HTMLElement$1 {
|
|
|
1850
1854
|
this.errorMessage = "O valor digitado não é uma data válida";
|
|
1851
1855
|
}
|
|
1852
1856
|
}
|
|
1853
|
-
getTextValue(
|
|
1857
|
+
getTextValue(date) {
|
|
1854
1858
|
const options = {
|
|
1855
1859
|
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
1856
1860
|
hour: 'numeric', minute: 'numeric'
|
|
@@ -1859,7 +1863,10 @@ let EzDateTimeInput$1 = class extends HTMLElement$1 {
|
|
|
1859
1863
|
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
1860
1864
|
hour: 'numeric', minute: 'numeric', second: 'numeric'
|
|
1861
1865
|
};
|
|
1862
|
-
|
|
1866
|
+
if (!date)
|
|
1867
|
+
return;
|
|
1868
|
+
let formattedDate = new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(date);
|
|
1869
|
+
return formattedDate.replace(",", "");
|
|
1863
1870
|
}
|
|
1864
1871
|
handleInput(event) {
|
|
1865
1872
|
const newValue = this.getParsedDateTime();
|
|
@@ -1885,7 +1892,7 @@ let EzDateTimeInput$1 = class extends HTMLElement$1 {
|
|
|
1885
1892
|
}
|
|
1886
1893
|
render() {
|
|
1887
1894
|
ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
|
|
1888
|
-
return (h(Host, null, h("ez-text-input", { "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), onFocus: () => this.handleFocus(), onClick: () => this.handleClick() }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { "data-element-id": ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.
|
|
1895
|
+
return (h(Host, null, h("ez-text-input", { "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), onFocus: () => this.handleFocus(), onClick: () => this.handleClick() }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { "data-element-id": ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
|
|
1889
1896
|
}
|
|
1890
1897
|
get _elem() { return this; }
|
|
1891
1898
|
static get watchers() { return {
|
|
@@ -69104,7 +69111,7 @@ var zIndexChangedCallback = function (o) {
|
|
|
69104
69111
|
* Abstract scene graph node.
|
|
69105
69112
|
* Each node can have zero or one parent and belong to zero or one scene.
|
|
69106
69113
|
*/
|
|
69107
|
-
var Node$1 = /** @class */ (function (_super) {
|
|
69114
|
+
var Node$1$1 = /** @class */ (function (_super) {
|
|
69108
69115
|
__extends$2N(Node, _super);
|
|
69109
69116
|
function Node() {
|
|
69110
69117
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -69994,7 +70001,7 @@ var Shape$1 = /** @class */ (function (_super) {
|
|
|
69994
70001
|
SceneChangeDetection({ redraw: RedrawType.MINOR, checkDirtyOnAssignment: true })
|
|
69995
70002
|
], Shape.prototype, "fillShadow", void 0);
|
|
69996
70003
|
return Shape;
|
|
69997
|
-
}(Node$1));
|
|
70004
|
+
}(Node$1$1));
|
|
69998
70005
|
|
|
69999
70006
|
/**
|
|
70000
70007
|
* Wraps the native Canvas element and overrides its CanvasRenderingContext2D to
|
|
@@ -73613,7 +73620,7 @@ var Group$1 = /** @class */ (function (_super) {
|
|
|
73613
73620
|
})
|
|
73614
73621
|
], Group.prototype, "opacity", void 0);
|
|
73615
73622
|
return Group;
|
|
73616
|
-
}(Node$1));
|
|
73623
|
+
}(Node$1$1));
|
|
73617
73624
|
|
|
73618
73625
|
var __values$o = function(o) {
|
|
73619
73626
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
@@ -73642,7 +73649,7 @@ var EnterNode$1 = /** @class */ (function () {
|
|
|
73642
73649
|
if (this.next === null) {
|
|
73643
73650
|
return this.parent.insertBefore(node, null);
|
|
73644
73651
|
}
|
|
73645
|
-
if (!Node$1.isNode(this.next)) {
|
|
73652
|
+
if (!Node$1$1.isNode(this.next)) {
|
|
73646
73653
|
throw new Error(this.next + " is not a Node.");
|
|
73647
73654
|
}
|
|
73648
73655
|
return this.parent.insertBefore(node, this.next);
|
|
@@ -73716,7 +73723,7 @@ var Selection$1 = /** @class */ (function () {
|
|
|
73716
73723
|
*/
|
|
73717
73724
|
Selection.prototype.selectByClass = function (Class) {
|
|
73718
73725
|
return this.select(function (node) {
|
|
73719
|
-
if (Node$1.isNode(node)) {
|
|
73726
|
+
if (Node$1$1.isNode(node)) {
|
|
73720
73727
|
var children = node.children;
|
|
73721
73728
|
var n = children.length;
|
|
73722
73729
|
for (var i = 0; i < n; i++) {
|
|
@@ -73730,7 +73737,7 @@ var Selection$1 = /** @class */ (function () {
|
|
|
73730
73737
|
};
|
|
73731
73738
|
Selection.prototype.selectByTag = function (tag) {
|
|
73732
73739
|
return this.select(function (node) {
|
|
73733
|
-
if (Node$1.isNode(node)) {
|
|
73740
|
+
if (Node$1$1.isNode(node)) {
|
|
73734
73741
|
var children = node.children;
|
|
73735
73742
|
var n = children.length;
|
|
73736
73743
|
for (var i = 0; i < n; i++) {
|
|
@@ -73745,7 +73752,7 @@ var Selection$1 = /** @class */ (function () {
|
|
|
73745
73752
|
Selection.prototype.selectAllByClass = function (Class) {
|
|
73746
73753
|
return this.selectAll(function (node) {
|
|
73747
73754
|
var nodes = [];
|
|
73748
|
-
if (Node$1.isNode(node)) {
|
|
73755
|
+
if (Node$1$1.isNode(node)) {
|
|
73749
73756
|
var children = node.children;
|
|
73750
73757
|
var n = children.length;
|
|
73751
73758
|
for (var i = 0; i < n; i++) {
|
|
@@ -73761,7 +73768,7 @@ var Selection$1 = /** @class */ (function () {
|
|
|
73761
73768
|
Selection.prototype.selectAllByTag = function (tag) {
|
|
73762
73769
|
return this.selectAll(function (node) {
|
|
73763
73770
|
var nodes = [];
|
|
73764
|
-
if (Node$1.isNode(node)) {
|
|
73771
|
+
if (Node$1$1.isNode(node)) {
|
|
73765
73772
|
var children = node.children;
|
|
73766
73773
|
var n = children.length;
|
|
73767
73774
|
for (var i = 0; i < n; i++) {
|
|
@@ -73848,7 +73855,7 @@ var Selection$1 = /** @class */ (function () {
|
|
|
73848
73855
|
};
|
|
73849
73856
|
Selection.prototype.remove = function () {
|
|
73850
73857
|
return this.each(function (node) {
|
|
73851
|
-
if (Node$1.isNode(node)) {
|
|
73858
|
+
if (Node$1$1.isNode(node)) {
|
|
73852
73859
|
var parent_1 = node.parent;
|
|
73853
73860
|
if (parent_1) {
|
|
73854
73861
|
parent_1.removeChild(node);
|
|
@@ -82594,7 +82601,7 @@ var ClipRect = /** @class */ (function (_super) {
|
|
|
82594
82601
|
ScenePathChangeDetection()
|
|
82595
82602
|
], ClipRect.prototype, "height", void 0);
|
|
82596
82603
|
return ClipRect;
|
|
82597
|
-
}(Node$1));
|
|
82604
|
+
}(Node$1$1));
|
|
82598
82605
|
|
|
82599
82606
|
var __extends$2f = (function () {
|
|
82600
82607
|
var extendStatics = function (d, b) {
|
|
@@ -121051,6 +121058,375 @@ let EzToast$1 = class extends HTMLElement$1 {
|
|
|
121051
121058
|
static get style() { return ezToastCss; }
|
|
121052
121059
|
};
|
|
121053
121060
|
|
|
121061
|
+
const ICON_EXPANDED = "chevron-down";
|
|
121062
|
+
const ICON_COLAPSED = "chevron-right";
|
|
121063
|
+
const defaultIconResolver = (item, expanded, _level) => {
|
|
121064
|
+
if (expanded) {
|
|
121065
|
+
return item.iconExpanded || ICON_EXPANDED;
|
|
121066
|
+
}
|
|
121067
|
+
return item.iconContracted || ICON_COLAPSED;
|
|
121068
|
+
};
|
|
121069
|
+
|
|
121070
|
+
const TreeItem = (props) => {
|
|
121071
|
+
const { node, selectedId, itemClick, iconResolver, itemsList } = props;
|
|
121072
|
+
const treeItem = node.item;
|
|
121073
|
+
const level = props.level || 1;
|
|
121074
|
+
const disabled = node.isDisabled();
|
|
121075
|
+
const expanded = !disabled && treeItem.expanded;
|
|
121076
|
+
const expandable = node.isExpandable();
|
|
121077
|
+
const available = !disabled && !node.isPlaceHolder;
|
|
121078
|
+
if (available) {
|
|
121079
|
+
itemsList.push(treeItem);
|
|
121080
|
+
}
|
|
121081
|
+
return (h("ul", { title: treeItem.label, class: level === 1 ? "first-level" : undefined },
|
|
121082
|
+
h("li", Object.assign({ class: "tree-item", onClick: () => available && itemClick(treeItem) }, {
|
|
121083
|
+
disabled,
|
|
121084
|
+
selected: treeItem.id === selectedId,
|
|
121085
|
+
[ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(`ezTreeItem_${treeItem.id}`)
|
|
121086
|
+
}),
|
|
121087
|
+
h("div", { class: "item-icon-box" }, expandable &&
|
|
121088
|
+
h("ez-icon", { id: treeItem.id, class: "item-icon", size: "small", iconName: iconResolver(treeItem, expanded, level) })),
|
|
121089
|
+
h("label", { class: "item-label" }, treeItem.label)),
|
|
121090
|
+
expanded
|
|
121091
|
+
&& node.getChildren().map(child => h(TreeItem, { selectedId: selectedId, node: child, itemClick: itemClick, level: level + 1, iconResolver: iconResolver, itemsList: itemsList }))));
|
|
121092
|
+
};
|
|
121093
|
+
|
|
121094
|
+
class Node$1 {
|
|
121095
|
+
constructor(tree, item, parent, isPlaceHolder = false) {
|
|
121096
|
+
this.children = new Map();
|
|
121097
|
+
this.item = item;
|
|
121098
|
+
this.parent = parent;
|
|
121099
|
+
this._tree = tree;
|
|
121100
|
+
this.isPlaceHolder = isPlaceHolder;
|
|
121101
|
+
if (item && !isPlaceHolder) {
|
|
121102
|
+
this._isLazyLoad = typeof item.children === "function" || item.childrenCount > 0;
|
|
121103
|
+
if (Array.isArray(item.children)) {
|
|
121104
|
+
Array.from(item.children).forEach(item => this.addChild(this._tree, item));
|
|
121105
|
+
this._childrenLoaded = true;
|
|
121106
|
+
}
|
|
121107
|
+
}
|
|
121108
|
+
else {
|
|
121109
|
+
this._isLazyLoad = false;
|
|
121110
|
+
this._childrenLoaded = true;
|
|
121111
|
+
}
|
|
121112
|
+
}
|
|
121113
|
+
isDisabled() {
|
|
121114
|
+
if (this.isPlaceHolder) {
|
|
121115
|
+
return false;
|
|
121116
|
+
}
|
|
121117
|
+
return this._tree.isNodeDisabled(this.item.id, this.item.disabled);
|
|
121118
|
+
}
|
|
121119
|
+
updateChildren(children) {
|
|
121120
|
+
if (this.isPlaceHolder) {
|
|
121121
|
+
return;
|
|
121122
|
+
}
|
|
121123
|
+
this.item.children = children;
|
|
121124
|
+
this._childrenLoaded = true;
|
|
121125
|
+
this.children.clear();
|
|
121126
|
+
children.forEach(item => this.addChild(this._tree, Object.assign({}, item)));
|
|
121127
|
+
}
|
|
121128
|
+
addChild(tree, item) {
|
|
121129
|
+
if (!this.children.has(item.id)) {
|
|
121130
|
+
this.children.set(item.id, new Node$1(tree, item, this));
|
|
121131
|
+
}
|
|
121132
|
+
}
|
|
121133
|
+
addPlaceHolder() {
|
|
121134
|
+
this.children.clear();
|
|
121135
|
+
const id = this.item.id;
|
|
121136
|
+
this.children.set(id, new Node$1(undefined, { id: `placeholder_${id}`, label: "Carregando..." }, this, true));
|
|
121137
|
+
}
|
|
121138
|
+
getNode(id) {
|
|
121139
|
+
if (this.children.has(id)) {
|
|
121140
|
+
return this.children.get(id);
|
|
121141
|
+
}
|
|
121142
|
+
const childrenArray = Array.from(this.children.values());
|
|
121143
|
+
for (const child of childrenArray) {
|
|
121144
|
+
const result = child.getNode(id);
|
|
121145
|
+
if (result) {
|
|
121146
|
+
return result;
|
|
121147
|
+
}
|
|
121148
|
+
}
|
|
121149
|
+
}
|
|
121150
|
+
needLoad() {
|
|
121151
|
+
return this._isLazyLoad && !this._childrenLoaded;
|
|
121152
|
+
}
|
|
121153
|
+
isExpandable() {
|
|
121154
|
+
return this._isLazyLoad || this.children.size > 0 || Array.isArray(this.item.children);
|
|
121155
|
+
}
|
|
121156
|
+
getChildren() {
|
|
121157
|
+
if (this.isPlaceHolder) {
|
|
121158
|
+
return [];
|
|
121159
|
+
}
|
|
121160
|
+
if (this.needLoad()) {
|
|
121161
|
+
this._tree.loadChildren(this);
|
|
121162
|
+
}
|
|
121163
|
+
return Array.from(this.children.values());
|
|
121164
|
+
}
|
|
121165
|
+
}
|
|
121166
|
+
|
|
121167
|
+
class Tree extends Node$1 {
|
|
121168
|
+
constructor(changeCallback) {
|
|
121169
|
+
super(undefined);
|
|
121170
|
+
this._disabledValues = new Map();
|
|
121171
|
+
this._changeCallback = changeCallback;
|
|
121172
|
+
}
|
|
121173
|
+
async addChildAt(parentId, item) {
|
|
121174
|
+
const parent = this.getNode(parentId);
|
|
121175
|
+
if (parent == undefined) {
|
|
121176
|
+
return;
|
|
121177
|
+
}
|
|
121178
|
+
parent.addChild(this, item);
|
|
121179
|
+
this._changeCallback();
|
|
121180
|
+
}
|
|
121181
|
+
setDisabled(id, value) {
|
|
121182
|
+
this._disabledValues.set(id, value);
|
|
121183
|
+
this._changeCallback();
|
|
121184
|
+
}
|
|
121185
|
+
isNodeDisabled(id, defaultValue) {
|
|
121186
|
+
if (!this._disabledValues.has(id)) {
|
|
121187
|
+
return defaultValue;
|
|
121188
|
+
}
|
|
121189
|
+
return this._disabledValues.get(id);
|
|
121190
|
+
}
|
|
121191
|
+
load(items) {
|
|
121192
|
+
this.children.clear();
|
|
121193
|
+
items.forEach(item => this.addChild(this, Object.assign({}, item)));
|
|
121194
|
+
}
|
|
121195
|
+
async open(path) {
|
|
121196
|
+
return new Promise(async (resolve) => {
|
|
121197
|
+
await this.walk(this, path, node => node.item.expanded = true);
|
|
121198
|
+
resolve();
|
|
121199
|
+
});
|
|
121200
|
+
}
|
|
121201
|
+
async walk(parent, path, callback, currentLevel = 0) {
|
|
121202
|
+
return new Promise(async (resolve) => {
|
|
121203
|
+
const levels = path.split(">>").map(item => item.trim());
|
|
121204
|
+
if (levels.length > currentLevel) {
|
|
121205
|
+
const node = parent.getNode(levels[currentLevel]);
|
|
121206
|
+
if (node) {
|
|
121207
|
+
if (node.needLoad()) {
|
|
121208
|
+
await this.loadLevel(node);
|
|
121209
|
+
}
|
|
121210
|
+
callback(node);
|
|
121211
|
+
await this.walk(node, path, callback, currentLevel + 1);
|
|
121212
|
+
}
|
|
121213
|
+
}
|
|
121214
|
+
resolve();
|
|
121215
|
+
});
|
|
121216
|
+
}
|
|
121217
|
+
async loadChildren(node) {
|
|
121218
|
+
return new Promise(resolve => {
|
|
121219
|
+
this.loadLevel(node).then(() => {
|
|
121220
|
+
resolve();
|
|
121221
|
+
this._changeCallback();
|
|
121222
|
+
});
|
|
121223
|
+
});
|
|
121224
|
+
}
|
|
121225
|
+
async loadLevel(node) {
|
|
121226
|
+
return new Promise(resolve => {
|
|
121227
|
+
node.addPlaceHolder();
|
|
121228
|
+
const loader = node.item.children;
|
|
121229
|
+
loader(node.item).then(result => {
|
|
121230
|
+
node.updateChildren(result);
|
|
121231
|
+
resolve();
|
|
121232
|
+
});
|
|
121233
|
+
});
|
|
121234
|
+
}
|
|
121235
|
+
}
|
|
121236
|
+
|
|
121237
|
+
const ezTreeCss = ":host{--ez-tree--border-radius:var(--border--radius-small, 8px);--ez-tree--padding-inline-start:20px;--ez-tree--margin:var(--space--extra-small, 3px);--ez-tree--font-family:var(--font-pattern, Arial);--ez-tree--font-size:var(--text--medium, 14px);--ez-tree--selected--font-weight:var(--text-weight--large, 600);--ez-tree--font-weight:var(--text-weight--small, 400);--ez-tree--color:var(--title--primary, #2B3A54);--ez-tree--selected--color:var(--color--primary, #008561);--ez-tree--disabled--color:var(--text--disable, #AFB6C0);--ez-tree__tree-item--height:var(--size-medium, 18px);--ez-tree__tree-item--padding:var(--space--small, 6px);--ez-tree__tree-item--background-color:var(--background--xlight, #FFFFFF);--ez-tree__tree-item--selected--background-color:var(--color--primary-300, #E2F4EF);--ez-tree__tree-item--hover--background-color:var(--background--medium, #F0F3F7);--ez-tree__tree-item--disabled--background-color:var(--ez-tree__tree-Item--background-color);--ez-tree__item-icon-box--height:var(--ez-tree__tree-item--height);--ez-tree__item-icon-box--width:var(--size-medium, 18px);--ez-tree__item-icon-box--padding:var(--ez-tree__tree-item--padding);display:flex;flex-direction:column;margin:0 var(--ez-tree--margin) var(--ez-tree--margin) var(--ez-tree--margin);outline:none}ul{list-style-type:none;margin:0;padding-inline-start:var(--ez-tree--padding-inline-start)}ul.first-level{padding-inline-start:0}.tree-item{display:flex;align-items:center;margin-top:var(--ez-tree--margin);border-radius:var(--ez-tree--border-radius);height:var(--ez-tree__tree-item--height);padding:var(--ez-tree__tree-item--padding)}.tree-item[selected]{background-color:var(--ez-tree__tree-item--selected--background-color)}.tree-item:hover{cursor:pointer;background-color:var(--ez-tree__tree-item--hover--background-color)}.tree-item[disabled],.tree-item[disabled]:hover{cursor:unset;background-color:var(--ez-tree__tree-item--disabled--background-color)}.item-icon-box{display:flex;align-items:center;justify-content:center;width:var(--ez-tree__item-icon-box--width);height:var(--ez-tree__item-icon-box--height);padding:var(--ez-tree__item-icon-box--padding) var(--ez-tree__item-icon-box--padding) var(--ez-tree__item-icon-box--padding) 0}.item-icon{--ez-icon--color:var(--ez-tree--color)}.tree-item[selected] .item-icon{--ez-icon--color:var(--ez-tree--selected--color)}.tree-item[disabled] .item-icon{--ez-icon--color:var(--ez-tree--disabled--color)}.item-label{cursor:inherit;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-family:var(--ez-tree--font-family);font-size:var(--ez-tree--font-size);font-weight:var(--ez-tree--font-weight);color:var(--ez-tree--color)}.tree-item[selected] .item-label{color:var(--ez-tree--selected--color);font-weight:var(--ez-tree--selected--font-weight)}.tree-item[disabled] .item-label{color:var(--ez-tree--disabled--color)}";
|
|
121238
|
+
|
|
121239
|
+
let EzTree$1 = class extends HTMLElement$1 {
|
|
121240
|
+
constructor() {
|
|
121241
|
+
super();
|
|
121242
|
+
this.__registerHost();
|
|
121243
|
+
this.__attachShadow();
|
|
121244
|
+
this.ezChange = createEvent(this, "ezChange", 7);
|
|
121245
|
+
this.ezOpenItem = createEvent(this, "ezOpenItem", 7);
|
|
121246
|
+
this._tree = new Tree(() => forceUpdate(this));
|
|
121247
|
+
this._onItemClick = (item) => {
|
|
121248
|
+
this.openClose(item);
|
|
121249
|
+
this.value = item;
|
|
121250
|
+
};
|
|
121251
|
+
/**
|
|
121252
|
+
* Define os itens apresentados na árvore.
|
|
121253
|
+
*/
|
|
121254
|
+
this.items = [];
|
|
121255
|
+
/**
|
|
121256
|
+
* Define uma função que vai resolver o ícone daquele item. Retorna o nome do ícone da lib de icones do DS.
|
|
121257
|
+
*/
|
|
121258
|
+
this.iconResolver = defaultIconResolver;
|
|
121259
|
+
}
|
|
121260
|
+
/**
|
|
121261
|
+
* Efetua a seleção de um item.
|
|
121262
|
+
*/
|
|
121263
|
+
async selectItem(id) {
|
|
121264
|
+
const node = this._tree.getNode(id);
|
|
121265
|
+
if (node) {
|
|
121266
|
+
this.value = node.item;
|
|
121267
|
+
}
|
|
121268
|
+
else {
|
|
121269
|
+
this.value = undefined;
|
|
121270
|
+
}
|
|
121271
|
+
}
|
|
121272
|
+
/**
|
|
121273
|
+
* Realiza a abertura de um item, incluindo a hieraquia acima.
|
|
121274
|
+
* Observação para carga dinâmica (Lazyload): O item solicitado já deve
|
|
121275
|
+
* estar carregado na lista. Nos casos onde o item ainda não esteja
|
|
121276
|
+
* carregado o id pode ser uma string no formato "id1>>id2>>id3",
|
|
121277
|
+
* tornando possível a carga a partir de um ponto já carregado.
|
|
121278
|
+
*/
|
|
121279
|
+
async openItem(id) {
|
|
121280
|
+
this._waintingForLoad = true;
|
|
121281
|
+
await this._tree.open(id);
|
|
121282
|
+
this._waintingForLoad = false;
|
|
121283
|
+
}
|
|
121284
|
+
/**
|
|
121285
|
+
* Desabilita um ou mais itens.
|
|
121286
|
+
*/
|
|
121287
|
+
async disableItem(id) {
|
|
121288
|
+
[].concat(id).forEach(item => this._tree.setDisabled(item, true));
|
|
121289
|
+
}
|
|
121290
|
+
/**
|
|
121291
|
+
* Habilita um ou mais itens.
|
|
121292
|
+
*/
|
|
121293
|
+
async enableItem(id) {
|
|
121294
|
+
[].concat(id).forEach(item => this._tree.setDisabled(item, false));
|
|
121295
|
+
}
|
|
121296
|
+
/**
|
|
121297
|
+
* Adiciona um ou mais itens. Opcionalmente pode-se determinar a qual
|
|
121298
|
+
* item da árvore será anexado o item. Caso não informado parentId,
|
|
121299
|
+
* adiciona no item selecionado.
|
|
121300
|
+
* Observação para carga dinâmica (Lazyload): O parentId deve ser
|
|
121301
|
+
* um item carregado atualmente na árvore.
|
|
121302
|
+
*/
|
|
121303
|
+
async addChild(item, parentId) {
|
|
121304
|
+
var _a;
|
|
121305
|
+
if (parentId == undefined) {
|
|
121306
|
+
parentId = (_a = this.value) === null || _a === void 0 ? void 0 : _a.id;
|
|
121307
|
+
}
|
|
121308
|
+
this._tree.addChildAt(parentId, item);
|
|
121309
|
+
const node = this._tree.getNode(parentId);
|
|
121310
|
+
if (node) {
|
|
121311
|
+
node.item.expanded = true;
|
|
121312
|
+
}
|
|
121313
|
+
}
|
|
121314
|
+
observeItems() {
|
|
121315
|
+
this._tree.load(this.items);
|
|
121316
|
+
}
|
|
121317
|
+
observeValue() {
|
|
121318
|
+
this.ezChange.emit(this.value);
|
|
121319
|
+
}
|
|
121320
|
+
onKeyDownListener(event) {
|
|
121321
|
+
if (!this.value) {
|
|
121322
|
+
return;
|
|
121323
|
+
}
|
|
121324
|
+
let stop = false;
|
|
121325
|
+
switch (event.key) {
|
|
121326
|
+
case "ArrowUp":
|
|
121327
|
+
this.previousItem();
|
|
121328
|
+
stop = true;
|
|
121329
|
+
break;
|
|
121330
|
+
case "ArrowDown":
|
|
121331
|
+
this.nextItem();
|
|
121332
|
+
stop = true;
|
|
121333
|
+
break;
|
|
121334
|
+
case "ArrowLeft":
|
|
121335
|
+
this.previousLevel();
|
|
121336
|
+
stop = true;
|
|
121337
|
+
break;
|
|
121338
|
+
case "ArrowRight":
|
|
121339
|
+
this.nextLevel();
|
|
121340
|
+
stop = true;
|
|
121341
|
+
break;
|
|
121342
|
+
case " ":
|
|
121343
|
+
this.openClose(this.value);
|
|
121344
|
+
stop = true;
|
|
121345
|
+
break;
|
|
121346
|
+
}
|
|
121347
|
+
if (stop) {
|
|
121348
|
+
event.stopPropagation();
|
|
121349
|
+
event.preventDefault();
|
|
121350
|
+
}
|
|
121351
|
+
}
|
|
121352
|
+
openClose(item) {
|
|
121353
|
+
if (item == undefined) {
|
|
121354
|
+
return;
|
|
121355
|
+
}
|
|
121356
|
+
const expanded = !item.expanded;
|
|
121357
|
+
item.expanded = expanded;
|
|
121358
|
+
if (expanded) {
|
|
121359
|
+
this.ezOpenItem.emit(item);
|
|
121360
|
+
}
|
|
121361
|
+
forceUpdate(this);
|
|
121362
|
+
}
|
|
121363
|
+
previousLevel() {
|
|
121364
|
+
var _a;
|
|
121365
|
+
if (!this.value) {
|
|
121366
|
+
return;
|
|
121367
|
+
}
|
|
121368
|
+
if (this.value.expanded) {
|
|
121369
|
+
this.value.expanded = false;
|
|
121370
|
+
forceUpdate(this);
|
|
121371
|
+
}
|
|
121372
|
+
else {
|
|
121373
|
+
const node = this._tree.getNode(this.value.id);
|
|
121374
|
+
const parentItem = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.item;
|
|
121375
|
+
if (parentItem) {
|
|
121376
|
+
this.value = parentItem;
|
|
121377
|
+
}
|
|
121378
|
+
}
|
|
121379
|
+
}
|
|
121380
|
+
nextLevel() {
|
|
121381
|
+
if (!this.value) {
|
|
121382
|
+
return;
|
|
121383
|
+
}
|
|
121384
|
+
const node = this._tree.getNode(this.value.id);
|
|
121385
|
+
if (!node.isExpandable()) {
|
|
121386
|
+
return;
|
|
121387
|
+
}
|
|
121388
|
+
if (this.value.expanded) {
|
|
121389
|
+
this.nextItem();
|
|
121390
|
+
}
|
|
121391
|
+
else {
|
|
121392
|
+
this.value.expanded = true;
|
|
121393
|
+
forceUpdate(this);
|
|
121394
|
+
}
|
|
121395
|
+
}
|
|
121396
|
+
nextItem() {
|
|
121397
|
+
const nextIndex = this._visibleItems.indexOf(this.value) + 1;
|
|
121398
|
+
if (nextIndex < this._visibleItems.length) {
|
|
121399
|
+
this.value = this._visibleItems[nextIndex];
|
|
121400
|
+
}
|
|
121401
|
+
}
|
|
121402
|
+
previousItem() {
|
|
121403
|
+
const nextIndex = this._visibleItems.indexOf(this.value) - 1;
|
|
121404
|
+
if (nextIndex > -1) {
|
|
121405
|
+
this.value = this._visibleItems[nextIndex];
|
|
121406
|
+
}
|
|
121407
|
+
}
|
|
121408
|
+
render() {
|
|
121409
|
+
ElementIDUtils.addIDInfoIfNotExists(this._element, 'ezTree');
|
|
121410
|
+
if (this.items == undefined) {
|
|
121411
|
+
return;
|
|
121412
|
+
}
|
|
121413
|
+
this._visibleItems = [];
|
|
121414
|
+
return (h(Host, { tabindex: "-1" }, this._waintingForLoad ?
|
|
121415
|
+
h("label", null, "Carregando...")
|
|
121416
|
+
:
|
|
121417
|
+
this._tree.getChildren().map(node => {
|
|
121418
|
+
var _a;
|
|
121419
|
+
return h(TreeItem, { selectedId: (_a = this.value) === null || _a === void 0 ? void 0 : _a.id, node: node, itemClick: this._onItemClick, iconResolver: this.iconResolver, itemsList: this._visibleItems });
|
|
121420
|
+
})));
|
|
121421
|
+
}
|
|
121422
|
+
get _element() { return this; }
|
|
121423
|
+
static get watchers() { return {
|
|
121424
|
+
"items": ["observeItems"],
|
|
121425
|
+
"value": ["observeValue"]
|
|
121426
|
+
}; }
|
|
121427
|
+
static get style() { return ezTreeCss; }
|
|
121428
|
+
};
|
|
121429
|
+
|
|
121054
121430
|
class RemoteFile {
|
|
121055
121431
|
constructor(file) {
|
|
121056
121432
|
this.file = file;
|
|
@@ -121542,6 +121918,7 @@ const EzTextEdit = /*@__PURE__*/proxyCustomElement(EzTextEdit$1, [1,"ez-text-edi
|
|
|
121542
121918
|
const EzTextInput = /*@__PURE__*/proxyCustomElement(EzTextInput$1, [1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"noBorder":[516,"no-border"]}]);
|
|
121543
121919
|
const EzTimeInput = /*@__PURE__*/proxyCustomElement(EzTimeInput$1, [1,"ez-time-input",{"label":[513],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513]}]);
|
|
121544
121920
|
const EzToast = /*@__PURE__*/proxyCustomElement(EzToast$1, [1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"]}]);
|
|
121921
|
+
const EzTree = /*@__PURE__*/proxyCustomElement(EzTree$1, [1,"ez-tree",{"items":[16],"value":[1040],"iconResolver":[16],"_waintingForLoad":[32]},[[2,"keydown","onKeyDownListener"]]]);
|
|
121545
121922
|
const EzUpload = /*@__PURE__*/proxyCustomElement(EzUpload$1, [1,"ez-upload",{"label":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040]}]);
|
|
121546
121923
|
const EzViewStack = /*@__PURE__*/proxyCustomElement(EzViewStack$1, [0,"ez-view-stack"]);
|
|
121547
121924
|
const defineCustomElements = (opts) => {
|
|
@@ -121581,6 +121958,7 @@ const defineCustomElements = (opts) => {
|
|
|
121581
121958
|
EzTextInput,
|
|
121582
121959
|
EzTimeInput,
|
|
121583
121960
|
EzToast,
|
|
121961
|
+
EzTree,
|
|
121584
121962
|
EzUpload,
|
|
121585
121963
|
EzViewStack
|
|
121586
121964
|
].forEach(cmp => {
|
|
@@ -121591,4 +121969,4 @@ const defineCustomElements = (opts) => {
|
|
|
121591
121969
|
}
|
|
121592
121970
|
};
|
|
121593
121971
|
|
|
121594
|
-
export { EzActionsButton, EzAlert, EzApplication, EzButton, EzCalendar, EzCardItem, EzCheck, EzChip, EzCollapsibleBox, EzComboBox, EzDateInput, EzDateTimeInput, EzDialog, EzFileItem, EzFilterInput, EzForm, EzGrid, EzIcon, EzList, EzLoadingBar, EzModal, EzModalContainer, EzNumberInput, EzPopover, EzPopup, EzRadioButton, EzScroller, EzSearch, EzTabselector, EzTextArea, EzTextEdit, EzTextInput, EzTimeInput, EzToast, EzUpload, EzViewStack, defineCustomElements };
|
|
121972
|
+
export { EzActionsButton, EzAlert, EzApplication, EzButton, EzCalendar, EzCardItem, EzCheck, EzChip, EzCollapsibleBox, EzComboBox, EzDateInput, EzDateTimeInput, EzDialog, EzFileItem, EzFilterInput, EzForm, EzGrid, EzIcon, EzList, EzLoadingBar, EzModal, EzModalContainer, EzNumberInput, EzPopover, EzPopup, EzRadioButton, EzScroller, EzSearch, EzTabselector, EzTextArea, EzTextEdit, EzTextInput, EzTimeInput, EzToast, EzTree, EzUpload, EzViewStack, defineCustomElements };
|
|
@@ -121,6 +121,10 @@ let EzDateTimeInput = class {
|
|
|
121
121
|
this._calendar.fitVertical(top, this._elem.clientHeight);
|
|
122
122
|
this._calendar.style.visibility = 'inherit';
|
|
123
123
|
}
|
|
124
|
+
hideCalendar() {
|
|
125
|
+
this.changeValue(this._calendar.value);
|
|
126
|
+
this._calendar.hide();
|
|
127
|
+
}
|
|
124
128
|
getParsedDateTime(strValue) {
|
|
125
129
|
var _a, _b;
|
|
126
130
|
if (strValue === void 0) {
|
|
@@ -161,7 +165,7 @@ let EzDateTimeInput = class {
|
|
|
161
165
|
this.errorMessage = "O valor digitado não é uma data válida";
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
|
-
getTextValue(
|
|
168
|
+
getTextValue(date) {
|
|
165
169
|
const options = {
|
|
166
170
|
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
167
171
|
hour: 'numeric', minute: 'numeric'
|
|
@@ -170,7 +174,10 @@ let EzDateTimeInput = class {
|
|
|
170
174
|
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
171
175
|
hour: 'numeric', minute: 'numeric', second: 'numeric'
|
|
172
176
|
};
|
|
173
|
-
|
|
177
|
+
if (!date)
|
|
178
|
+
return;
|
|
179
|
+
let formattedDate = new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(date);
|
|
180
|
+
return formattedDate.replace(",", "");
|
|
174
181
|
}
|
|
175
182
|
handleInput(event) {
|
|
176
183
|
const newValue = this.getParsedDateTime();
|
|
@@ -196,7 +203,7 @@ let EzDateTimeInput = class {
|
|
|
196
203
|
}
|
|
197
204
|
render() {
|
|
198
205
|
ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
|
|
199
|
-
return (h(Host, null, h("ez-text-input", { "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), onFocus: () => this.handleFocus(), onClick: () => this.handleClick() }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { "data-element-id": ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.
|
|
206
|
+
return (h(Host, null, h("ez-text-input", { "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), onFocus: () => this.handleFocus(), onClick: () => this.handleClick() }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { "data-element-id": ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
|
|
200
207
|
}
|
|
201
208
|
get _elem() { return getElement(this); }
|
|
202
209
|
static get watchers() { return {
|