@sankhyalabs/ezui 3.0.4 → 3.1.1
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 +262 -8
- package/dist/cjs/ez-filter-input_4.cjs.entry.js +1 -1
- package/dist/cjs/ez-tabselector.cjs.entry.js +2 -12
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ez-breadcrumb/ez-breadcrumb.css +10 -1
- package/dist/collection/components/ez-breadcrumb/ez-breadcrumb.js +291 -9
- package/dist/collection/components/ez-breadcrumb/subcomponents/breadcrumb-item.js +31 -0
- package/dist/collection/components/ez-tabselector/ez-tabselector.css +3 -1
- package/dist/collection/components/ez-tabselector/ez-tabselector.js +1 -11
- package/dist/collection/components/ez-tree/ez-tree.js +2 -2
- package/dist/custom-elements/index.js +267 -23
- package/dist/esm/ez-breadcrumb.entry.js +264 -10
- package/dist/esm/ez-filter-input_4.entry.js +2 -2
- package/dist/esm/ez-tabselector.entry.js +2 -12
- 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-0e4ab096.entry.js +1 -0
- package/dist/ezui/p-38520b9c.entry.js +1 -0
- package/dist/ezui/p-51ecf138.entry.js +1 -0
- package/dist/types/components/ez-breadcrumb/ez-breadcrumb.d.ts +52 -2
- package/dist/types/components/ez-breadcrumb/subcomponents/breadcrumb-item.d.ts +13 -0
- package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +0 -2
- package/dist/types/components.d.ts +25 -1
- package/package.json +1 -1
- package/dist/ezui/p-0f76448d.entry.js +0 -1
- package/dist/ezui/p-2d16e8c2.entry.js +0 -1
- package/dist/ezui/p-83b92420.entry.js +0 -1
|
@@ -1,20 +1,231 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import { ElementIDUtils } from '@sankhyalabs/core';
|
|
2
|
+
import { ElementIDUtils, JSUtils } from '@sankhyalabs/core';
|
|
3
|
+
import { BreadcrumbItem } from './subcomponents/breadcrumb-item';
|
|
3
4
|
export class EzBreadcrumb {
|
|
4
5
|
constructor() {
|
|
6
|
+
this._ellipsesPositionedEnd = false;
|
|
7
|
+
this._renderSecond = false;
|
|
8
|
+
this.INDEX_ITEM_TO_REMOVE = 1; // sempre removemos o segundo item.
|
|
9
|
+
this.CHEVRON_SIZE = 28;
|
|
10
|
+
this.handleShowDropdown = (newState) => {
|
|
11
|
+
this.showDropdown = newState;
|
|
12
|
+
};
|
|
5
13
|
this.items = [];
|
|
14
|
+
this.fillMode = "auto";
|
|
15
|
+
this.maxItems = 4;
|
|
16
|
+
this.positionEllipsis = 1;
|
|
17
|
+
this.visibleItems = undefined;
|
|
18
|
+
this.hiddenItems = [];
|
|
19
|
+
this.showDropdown = false;
|
|
20
|
+
this.collapseConfigPosition = -1;
|
|
21
|
+
}
|
|
22
|
+
watchPropHandler() {
|
|
23
|
+
this.fillMode === "auto" && this.handleResize();
|
|
24
|
+
}
|
|
25
|
+
watchPropHiddenItems() {
|
|
26
|
+
if (this.fillMode === 'auto') {
|
|
27
|
+
this.collapseConfigPosition = this.hiddenItems.length > 0 ? 1 : -1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
componentDidUpdate() {
|
|
31
|
+
this.positionDropdown();
|
|
32
|
+
this.setEvents();
|
|
33
|
+
}
|
|
34
|
+
componentWillLoad() {
|
|
35
|
+
this.visibleItems = [...this.items];
|
|
36
|
+
if (this.fillMode === 'regular') {
|
|
37
|
+
this.configModeRegular();
|
|
38
|
+
}
|
|
39
|
+
else if (this.fillMode === 'auto') {
|
|
40
|
+
this.startResize();
|
|
41
|
+
}
|
|
42
|
+
this.setEvents();
|
|
43
|
+
}
|
|
44
|
+
closeDropdown(evt) {
|
|
45
|
+
const target = evt === null || evt === void 0 ? void 0 : evt.target;
|
|
46
|
+
if (target == undefined) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (target !== this._element.shadowRoot.querySelector(".ellipses__item")) {
|
|
50
|
+
this.showDropdown = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
setEvents() {
|
|
54
|
+
document.removeEventListener("click", this.closeDropdown.bind(this));
|
|
55
|
+
document.addEventListener("click", this.closeDropdown.bind(this));
|
|
56
|
+
document.removeEventListener("scroll", this.positionDropdown.bind(this));
|
|
57
|
+
document.addEventListener("scroll", this.positionDropdown.bind(this));
|
|
6
58
|
}
|
|
7
59
|
componentDidLoad() {
|
|
8
60
|
ElementIDUtils.addIDInfo(this._element);
|
|
9
61
|
}
|
|
10
|
-
|
|
11
|
-
this.
|
|
62
|
+
componentDidRender() {
|
|
63
|
+
if (this.fillMode === 'auto') {
|
|
64
|
+
this.configResize();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
configResize() {
|
|
68
|
+
if (this._resizeObserver != undefined) {
|
|
69
|
+
this._resizeObserver.unobserve(this._element.parentElement);
|
|
70
|
+
}
|
|
71
|
+
this._resizeObserver = new ResizeObserver(JSUtils.debounce(this.handleResize.bind(this), 200));
|
|
72
|
+
this._resizeObserver.observe(this._element.parentElement);
|
|
73
|
+
}
|
|
74
|
+
handleResize() {
|
|
75
|
+
const ELLIPSIS_SIZE = 39;
|
|
76
|
+
if (!this._renderSecond) {
|
|
77
|
+
this._renderSecond = true;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
let { offsetWidth } = this._element.parentElement;
|
|
81
|
+
let sumVisibleItems = 0;
|
|
82
|
+
this.visibleItems.forEach(item => sumVisibleItems += item.width);
|
|
83
|
+
//Se existe o ellipsis, devemos cconsidera-lo no calculo
|
|
84
|
+
const offset = this.collapseConfigPosition > -1 ? ELLIPSIS_SIZE : 0;
|
|
85
|
+
if (offsetWidth < sumVisibleItems + offset) {
|
|
86
|
+
this.handleCollapse(offsetWidth, sumVisibleItems);
|
|
87
|
+
}
|
|
88
|
+
else if (offsetWidth >= sumVisibleItems + offset) {
|
|
89
|
+
this.handleExpand(offsetWidth);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
handleCollapse(containerWidth, itemsWidth) {
|
|
93
|
+
const MIN_VISIBLE_ITEMS = 2;
|
|
94
|
+
if (this.visibleItems.length <= MIN_VISIBLE_ITEMS) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
let tmpVisibleItems = [...this.visibleItems];
|
|
98
|
+
let tmpHiddenItems = [...this.hiddenItems];
|
|
99
|
+
let secondItem = tmpVisibleItems[this.INDEX_ITEM_TO_REMOVE];
|
|
100
|
+
let hasChange = false;
|
|
101
|
+
while (tmpVisibleItems.length > MIN_VISIBLE_ITEMS &&
|
|
102
|
+
secondItem != undefined &&
|
|
103
|
+
itemsWidth > containerWidth) {
|
|
104
|
+
hasChange = true;
|
|
105
|
+
tmpVisibleItems = tmpVisibleItems.filter((_, index) => index !== this.INDEX_ITEM_TO_REMOVE);
|
|
106
|
+
tmpHiddenItems = [...tmpHiddenItems, secondItem];
|
|
107
|
+
itemsWidth -= secondItem.width;
|
|
108
|
+
secondItem = tmpVisibleItems[this.INDEX_ITEM_TO_REMOVE];
|
|
109
|
+
}
|
|
110
|
+
if (hasChange) {
|
|
111
|
+
this.visibleItems = tmpVisibleItems;
|
|
112
|
+
this.hiddenItems = tmpHiddenItems;
|
|
113
|
+
this.showDropdown = false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
handleExpand(containerWidth) {
|
|
117
|
+
if (!this.hiddenItems.length) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
let widthFreeZone = Math.abs(this._elBreadcrumbList.offsetWidth - containerWidth);
|
|
121
|
+
let tmpVisibleItems = [...this.visibleItems];
|
|
122
|
+
let tmpHiddenItems = [...this.hiddenItems];
|
|
123
|
+
let lastHiddenElement = tmpHiddenItems[tmpHiddenItems.length - 1];
|
|
124
|
+
let hasChange = false;
|
|
125
|
+
while (lastHiddenElement && widthFreeZone >= lastHiddenElement.width) {
|
|
126
|
+
widthFreeZone -= lastHiddenElement.width;
|
|
127
|
+
tmpHiddenItems.pop();
|
|
128
|
+
tmpVisibleItems.splice(this.INDEX_ITEM_TO_REMOVE, 0, lastHiddenElement);
|
|
129
|
+
lastHiddenElement = tmpHiddenItems[tmpHiddenItems.length - 1];
|
|
130
|
+
hasChange = true;
|
|
131
|
+
}
|
|
132
|
+
if (hasChange) {
|
|
133
|
+
this.visibleItems = tmpVisibleItems;
|
|
134
|
+
this.hiddenItems = tmpHiddenItems;
|
|
135
|
+
this.showDropdown = false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
configModeRegular() {
|
|
139
|
+
if (this.visibleItems.length > this.maxItems) {
|
|
140
|
+
const amountsItemsToHide = Math.abs(this.visibleItems.length - this.maxItems);
|
|
141
|
+
if (this.positionEllipsis === 0) {
|
|
142
|
+
const itemsToTransfer = this.visibleItems.slice(0, amountsItemsToHide);
|
|
143
|
+
this.hiddenItems.push(...itemsToTransfer);
|
|
144
|
+
this.visibleItems.splice(0, amountsItemsToHide);
|
|
145
|
+
}
|
|
146
|
+
else if (this.positionEllipsis >= this.maxItems) {
|
|
147
|
+
const itemsToTransfer = this.visibleItems.slice(this.maxItems);
|
|
148
|
+
this.hiddenItems.push(...itemsToTransfer);
|
|
149
|
+
this.visibleItems.splice(this.maxItems);
|
|
150
|
+
this._ellipsesPositionedEnd = true;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const removedItems = this.visibleItems.splice(this.positionEllipsis, amountsItemsToHide);
|
|
154
|
+
this.hiddenItems.push(...removedItems);
|
|
155
|
+
}
|
|
156
|
+
this.collapseConfigPosition = this.positionEllipsis;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
positionDropdown() {
|
|
160
|
+
var _a;
|
|
161
|
+
const bounding = (_a = this._element.shadowRoot.querySelector(".ellipses__item")) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
162
|
+
const elDropdown = this._element.shadowRoot.querySelector(".dropdown-ellipsis");
|
|
163
|
+
if (bounding == undefined || elDropdown == undefined) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
elDropdown.style.top = (bounding.y + bounding.height + 5) + "px";
|
|
167
|
+
elDropdown.style.left = bounding.x + "px";
|
|
168
|
+
}
|
|
169
|
+
;
|
|
170
|
+
async startResize() {
|
|
171
|
+
const areaAvailable = this._element.parentElement.offsetWidth;
|
|
172
|
+
const ELLIPSIS_SIZE = 10;
|
|
173
|
+
const measureItemSize = async (item, index) => {
|
|
174
|
+
item.width = await this.measureSizeHTMLElement(item);
|
|
175
|
+
/*
|
|
176
|
+
Se é o ultimo item, desconsideramos o icone CHEVRON
|
|
177
|
+
*/
|
|
178
|
+
if (index === this.visibleItems.length - 1) {
|
|
179
|
+
item.width -= this.CHEVRON_SIZE;
|
|
180
|
+
}
|
|
181
|
+
return item;
|
|
182
|
+
};
|
|
183
|
+
const measuredItems = await Promise.all(this.visibleItems.map(measureItemSize));
|
|
184
|
+
const sizeBreadcrumb = measuredItems.reduce((total, item) => total + item.width, 0);
|
|
185
|
+
if (sizeBreadcrumb > areaAvailable) {
|
|
186
|
+
const tempItemsVisible = [];
|
|
187
|
+
const tempItemsHidden = [...measuredItems];
|
|
188
|
+
const firstItem = tempItemsHidden.shift();
|
|
189
|
+
const lastItem = tempItemsHidden.pop();
|
|
190
|
+
lastItem.width += ELLIPSIS_SIZE;
|
|
191
|
+
tempItemsVisible.push(firstItem, lastItem);
|
|
192
|
+
let sizeTempItemsHiddenResult = tempItemsVisible.reduce((total, item) => total + item.width, 0);
|
|
193
|
+
let newAreaAvailable = Math.abs(sizeTempItemsHiddenResult - areaAvailable);
|
|
194
|
+
tempItemsHidden.reverse().forEach((item) => {
|
|
195
|
+
if (item.width < newAreaAvailable) {
|
|
196
|
+
const firstItemForListHidden = tempItemsHidden.shift();
|
|
197
|
+
tempItemsVisible.splice(1, 0, firstItemForListHidden);
|
|
198
|
+
sizeTempItemsHiddenResult = tempItemsVisible.reduce((total, item) => total + item.width, 0);
|
|
199
|
+
newAreaAvailable = Math.abs(sizeTempItemsHiddenResult - areaAvailable);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
this.visibleItems = [...tempItemsVisible];
|
|
203
|
+
this.hiddenItems = [...tempItemsHidden.reverse()];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
measureSizeHTMLElement(item) {
|
|
207
|
+
return new Promise((resolve) => {
|
|
208
|
+
const ICON_SIZE = 19;
|
|
209
|
+
this.waitFontLoad().then(() => {
|
|
210
|
+
if (this._textMesurement === undefined) {
|
|
211
|
+
this._textMesurement = this._element.shadowRoot.ownerDocument.createElement("canvas");
|
|
212
|
+
}
|
|
213
|
+
const context = this._textMesurement.getContext("2d");
|
|
214
|
+
context.font = "14px Roboto, Algerian";
|
|
215
|
+
resolve((item.iconName ? ICON_SIZE : 0) + this.CHEVRON_SIZE + context.measureText(item.label).width);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
waitFontLoad() {
|
|
220
|
+
return new Promise((resolve) => {
|
|
221
|
+
document.fonts.load("14px Roboto").then(() => resolve(), resolve());
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
getItemContent() {
|
|
225
|
+
return (h("nav", { class: "breadcrumb" }, h("ol", { class: "breadcrumb__list", ref: elem => this._elBreadcrumbList = elem }, h(BreadcrumbItem, { items: this.visibleItems, selectedItem: this.selectedItem, itemsHidden: this.hiddenItems, showDropdown: this.showDropdown, handleShowDropdown: this.handleShowDropdown, collapseConfigPosition: this.collapseConfigPosition, ellipsesPositionedEnd: this._ellipsesPositionedEnd }))));
|
|
12
226
|
}
|
|
13
227
|
render() {
|
|
14
|
-
return
|
|
15
|
-
const isLastItem = index === (this.items.length - 1);
|
|
16
|
-
return (h("li", Object.assign({ class: "breadcrumb__item", id: item.id }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(`ezBreadcrumbItem_${item.id}`) }), item.iconName && h("ez-icon", Object.assign({ class: `breadcrumb__item--icon ${isLastItem ? 'active-icon' : ''}`, size: "small", iconName: item.iconName }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo(`iconItem${item.id}`)}` })), h("p", { class: `breadcrumb__item--label ${isLastItem ? 'active' : ''}`, onClick: !isLastItem ? () => this.handleItemClick(item) : undefined }, item.label), !isLastItem && h("ez-icon", Object.assign({ class: "breadcrumb__item--chevron", size: "small", iconName: "chevron-right" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo(`iconPath${item.id}`)}` }))));
|
|
17
|
-
}))));
|
|
228
|
+
return this.getItemContent();
|
|
18
229
|
}
|
|
19
230
|
static get is() { return "ez-breadcrumb"; }
|
|
20
231
|
static get encapsulation() { return "shadow"; }
|
|
@@ -52,13 +263,75 @@ export class EzBreadcrumb {
|
|
|
52
263
|
"text": "Lista de itens do breadcrumb."
|
|
53
264
|
},
|
|
54
265
|
"defaultValue": "[]"
|
|
266
|
+
},
|
|
267
|
+
"fillMode": {
|
|
268
|
+
"type": "string",
|
|
269
|
+
"mutable": true,
|
|
270
|
+
"complexType": {
|
|
271
|
+
"original": "\"auto\" | \"regular\"",
|
|
272
|
+
"resolved": "\"auto\" | \"regular\"",
|
|
273
|
+
"references": {}
|
|
274
|
+
},
|
|
275
|
+
"required": false,
|
|
276
|
+
"optional": false,
|
|
277
|
+
"docs": {
|
|
278
|
+
"tags": [],
|
|
279
|
+
"text": "Define o modo de uso do Breadcrumb."
|
|
280
|
+
},
|
|
281
|
+
"attribute": "fill-mode",
|
|
282
|
+
"reflect": false,
|
|
283
|
+
"defaultValue": "\"auto\""
|
|
284
|
+
},
|
|
285
|
+
"maxItems": {
|
|
286
|
+
"type": "number",
|
|
287
|
+
"mutable": true,
|
|
288
|
+
"complexType": {
|
|
289
|
+
"original": "number",
|
|
290
|
+
"resolved": "number",
|
|
291
|
+
"references": {}
|
|
292
|
+
},
|
|
293
|
+
"required": false,
|
|
294
|
+
"optional": false,
|
|
295
|
+
"docs": {
|
|
296
|
+
"tags": [],
|
|
297
|
+
"text": "Define o limite m\u00E1ximo de itens a serem renderizados."
|
|
298
|
+
},
|
|
299
|
+
"attribute": "max-items",
|
|
300
|
+
"reflect": false,
|
|
301
|
+
"defaultValue": "4"
|
|
302
|
+
},
|
|
303
|
+
"positionEllipsis": {
|
|
304
|
+
"type": "number",
|
|
305
|
+
"mutable": true,
|
|
306
|
+
"complexType": {
|
|
307
|
+
"original": "number",
|
|
308
|
+
"resolved": "number",
|
|
309
|
+
"references": {}
|
|
310
|
+
},
|
|
311
|
+
"required": false,
|
|
312
|
+
"optional": false,
|
|
313
|
+
"docs": {
|
|
314
|
+
"tags": [],
|
|
315
|
+
"text": "Define a posi\u00E7\u00E3o do Ellipsis nos itens vis\u00EDveis do Breadcrumb."
|
|
316
|
+
},
|
|
317
|
+
"attribute": "position-ellipsis",
|
|
318
|
+
"reflect": false,
|
|
319
|
+
"defaultValue": "1"
|
|
55
320
|
}
|
|
56
321
|
};
|
|
57
322
|
}
|
|
323
|
+
static get states() {
|
|
324
|
+
return {
|
|
325
|
+
"visibleItems": {},
|
|
326
|
+
"hiddenItems": {},
|
|
327
|
+
"showDropdown": {},
|
|
328
|
+
"collapseConfigPosition": {}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
58
331
|
static get events() {
|
|
59
332
|
return [{
|
|
60
|
-
"method": "
|
|
61
|
-
"name": "
|
|
333
|
+
"method": "selectedItem",
|
|
334
|
+
"name": "selectedItem",
|
|
62
335
|
"bubbles": true,
|
|
63
336
|
"cancelable": true,
|
|
64
337
|
"composed": true,
|
|
@@ -78,4 +351,13 @@ export class EzBreadcrumb {
|
|
|
78
351
|
}];
|
|
79
352
|
}
|
|
80
353
|
static get elementRef() { return "_element"; }
|
|
354
|
+
static get watchers() {
|
|
355
|
+
return [{
|
|
356
|
+
"propName": "items",
|
|
357
|
+
"methodName": "watchPropHandler"
|
|
358
|
+
}, {
|
|
359
|
+
"propName": "hiddenItems",
|
|
360
|
+
"methodName": "watchPropHiddenItems"
|
|
361
|
+
}];
|
|
362
|
+
}
|
|
81
363
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { ElementIDUtils } from '@sankhyalabs/core';
|
|
3
|
+
export const BreadcrumbItem = (props) => {
|
|
4
|
+
const { items, selectedItem, itemsHidden, showDropdown, handleShowDropdown, collapseConfigPosition, ellipsesPositionedEnd } = props;
|
|
5
|
+
const formatDropdownItems = () => {
|
|
6
|
+
return itemsHidden.map((item) => ({
|
|
7
|
+
id: item.id,
|
|
8
|
+
label: item.label,
|
|
9
|
+
type: 'item',
|
|
10
|
+
children: null,
|
|
11
|
+
iconName: item.iconName || null,
|
|
12
|
+
subAction: null,
|
|
13
|
+
group: null
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
16
|
+
const onClickEllipsis = (evt) => {
|
|
17
|
+
evt.stopPropagation();
|
|
18
|
+
handleShowDropdown(!showDropdown);
|
|
19
|
+
};
|
|
20
|
+
const createEllipsis = (item) => {
|
|
21
|
+
return (h("li", Object.assign({ class: "breadcrumb__item", onClick: evt => onClickEllipsis(evt) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(`ezBreadcrumbItem_ellipsis`) }), ellipsesPositionedEnd && h("ez-icon", Object.assign({ class: "breadcrumb__item--chevron", size: "small", iconName: "chevron-right" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo(`iconPath${item.id}`)}` })), h("span", { class: "ellipses__item" }, "..."), ellipsesPositionedEnd || h("ez-icon", Object.assign({ class: "breadcrumb__item--chevron", size: "small", iconName: "chevron-right" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo(`iconPath${item.id}`)}` })), showDropdown &&
|
|
22
|
+
h("ez-dropdown", Object.assign({ class: "dropdown-ellipsis", items: formatDropdownItems(), onEzClick: (evt) => {
|
|
23
|
+
const { id, label, iconName } = evt.detail;
|
|
24
|
+
selectedItem.emit({ id, label, iconName });
|
|
25
|
+
} }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("dropdown")}` }))));
|
|
26
|
+
};
|
|
27
|
+
return (h("div", { class: "breadcrumb__items" }, items.map((item, index) => {
|
|
28
|
+
const isLastItem = index === (items.length - 1);
|
|
29
|
+
return (h("div", { class: "breadcrumb__group" }, collapseConfigPosition === index && createEllipsis(item), h("li", Object.assign({ class: "breadcrumb__item", id: item.id }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(`ezBreadcrumb_item_${item.id}_${item.label}`) }), item.iconName && h("ez-icon", Object.assign({ class: `breadcrumb__item--icon ${(isLastItem && !ellipsesPositionedEnd) ? 'active-icon' : ''}`, size: "small", iconName: item.iconName }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo(`iconItem${item.id}`)}` })), h("p", { class: `breadcrumb__item--label ${(isLastItem && !ellipsesPositionedEnd) ? 'active' : ''}`, onClick: (ellipsesPositionedEnd || !isLastItem) ? () => selectedItem.emit(item) : undefined }, item.label), !isLastItem && h("ez-icon", Object.assign({ class: "breadcrumb__item--chevron", size: "small", iconName: "chevron-right" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo(`iconPath${item.id}`)}` }))), (collapseConfigPosition - 1 === index && ellipsesPositionedEnd) && createEllipsis(item)));
|
|
30
|
+
})));
|
|
31
|
+
};
|
|
@@ -45,8 +45,9 @@
|
|
|
45
45
|
.tab {
|
|
46
46
|
display: flex;
|
|
47
47
|
border: none;
|
|
48
|
-
min-width: 100px;
|
|
49
48
|
background-color: unset;
|
|
49
|
+
min-width: 100px;
|
|
50
|
+
max-width: 260px;
|
|
50
51
|
cursor: pointer;
|
|
51
52
|
padding: 6px 12px;
|
|
52
53
|
align-items: center;
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
color: var(--text--primary, #626e82);
|
|
55
56
|
font-family: var(--font-pattern, "Roboto");
|
|
56
57
|
font-size: var(--title--small, 14px);
|
|
58
|
+
flex-shrink: 0;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
.tab:focus, .forward-button, .backward-button {
|
|
@@ -180,15 +180,6 @@ export class EzTabselector {
|
|
|
180
180
|
tabtoscroll.scrollIntoView();
|
|
181
181
|
}, 200);
|
|
182
182
|
}
|
|
183
|
-
getTextWidth(text) {
|
|
184
|
-
if (this._textMesurement === undefined) {
|
|
185
|
-
this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
|
|
186
|
-
}
|
|
187
|
-
const context = this._textMesurement.getContext("2d");
|
|
188
|
-
context.font = "14px Sora, Algerian";
|
|
189
|
-
return Math.min(220, 24 + context.measureText(text).width) + "px";
|
|
190
|
-
}
|
|
191
|
-
;
|
|
192
183
|
setFocusedBtn(visible, parameter) {
|
|
193
184
|
const tabsButtons = this._scrollContainer.querySelectorAll(".tab");
|
|
194
185
|
tabsButtons.forEach((el) => {
|
|
@@ -210,14 +201,13 @@ export class EzTabselector {
|
|
|
210
201
|
}
|
|
211
202
|
render() {
|
|
212
203
|
return (h(Host, null, h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }), h("div", { class: "scroll", ref: (el) => this._scrollContainer = el, onScroll: () => this.domScrollHandler(), onKeyDown: (ev) => this.setFocusedParam(ev) }, this._processedTabs.map((tab, index) => {
|
|
213
|
-
const labelStyle = { "min-width": this.getTextWidth(tab.label) };
|
|
214
204
|
const tabId = "tab" + index;
|
|
215
205
|
const isSelected = index === this.selectedIndex || (this.selectedTab && tab.tabKey === this.selectedTab);
|
|
216
206
|
if (isSelected) {
|
|
217
207
|
this.selectedTab = tab.tabKey;
|
|
218
208
|
this.selectedIndex = index;
|
|
219
209
|
}
|
|
220
|
-
return h("button", { id: tabId, name: "tab-button", class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab)
|
|
210
|
+
return h("button", { id: tabId, name: "tab-button", class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab) }, tab.leftIcon && h("ez-icon", { iconName: tab.leftIcon, class: "left-icon" }), h("span", { class: "tab-label", title: tab.label }, tab.label), tab.rightIcon && h("ez-icon", { iconName: tab.rightIcon, class: "right-icon" }), h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
|
|
221
211
|
})), h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
|
|
222
212
|
}
|
|
223
213
|
static get is() { return "ez-tabselector"; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementIDUtils } from '@sankhyalabs/core';
|
|
1
|
+
import { ElementIDUtils, ObjectUtils } from '@sankhyalabs/core';
|
|
2
2
|
import { forceUpdate, h, Host } from '@stencil/core';
|
|
3
3
|
import { defaultIconResolver, defaultTooltipResolver } from './subcomponents';
|
|
4
4
|
import { TreeItem } from './subcomponents/TreeItem';
|
|
@@ -81,7 +81,7 @@ export class EzTree {
|
|
|
81
81
|
this._tree.setFilterPattern(pattern);
|
|
82
82
|
}
|
|
83
83
|
observeItems(newValue, oldValue) {
|
|
84
|
-
if (newValue
|
|
84
|
+
if (ObjectUtils.objectToString(newValue) !== ObjectUtils.objectToString(oldValue)) {
|
|
85
85
|
this._tree.load(this.items || []);
|
|
86
86
|
}
|
|
87
87
|
}
|