@umbraco-ui/uui-tabs 1.6.0-rc.3 → 1.6.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/custom-elements.json +4 -0
- package/lib/index.js +103 -51
- package/lib/uui-tab-group.element.d.ts +3 -5
- package/package.json +6 -6
package/custom-elements.json
CHANGED
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
{
|
|
49
49
|
"name": "--uui-tab-group-dropdown-background",
|
|
50
50
|
"description": "Define the background color of the dropdown"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "--uui-tab-group-gap",
|
|
54
|
+
"description": "Define the gap between elements dropdown. Only pixel values are valid"
|
|
51
55
|
}
|
|
52
56
|
]
|
|
53
57
|
},
|
package/lib/index.js
CHANGED
|
@@ -3,10 +3,8 @@ import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
|
|
|
3
3
|
import { LitElement, html, css } from 'lit';
|
|
4
4
|
import { property, query, queryAssignedElements } from 'lit/decorators.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
|
+
import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils';
|
|
6
7
|
import { repeat } from 'lit/directives/repeat.js';
|
|
7
|
-
import '@umbraco-ui/uui-button/lib';
|
|
8
|
-
import '@umbraco-ui/uui-popover-container/lib';
|
|
9
|
-
import '@umbraco-ui/uui-symbol-more/lib';
|
|
10
8
|
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
|
|
11
9
|
|
|
12
10
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -79,7 +77,7 @@ UUITabElement.styles = [
|
|
|
79
77
|
height: 100%;
|
|
80
78
|
min-height: var(--uui-size-12,36px);
|
|
81
79
|
min-width: 70px;
|
|
82
|
-
padding: var(--uui-size-
|
|
80
|
+
padding: var(--uui-size-3,9px)
|
|
83
81
|
var(--uui-tab-padding-horizontal, var(--uui-size-5,15px));
|
|
84
82
|
border: none;
|
|
85
83
|
font-size: inherit;
|
|
@@ -237,24 +235,27 @@ var __privateMethod = (obj, member, method) => {
|
|
|
237
235
|
__accessCheck(obj, member, "access private method");
|
|
238
236
|
return method;
|
|
239
237
|
};
|
|
240
|
-
var _tabElements, _hiddenTabElements, _hiddenTabElementsMap, _visibilityBreakpoints, _resizeObserver, _onResize, onResize_fn,
|
|
238
|
+
var _currentGap, _tabElements, _hiddenTabElements, _hiddenTabElementsMap, _visibilityBreakpoints, _resizeObserver, _tabResizeObservers, _breakPointCalculationInProgress, _onResize, onResize_fn, _cleanupTabs, cleanupTabs_fn, _onSlotChange, onSlotChange_fn, _onTabClicked, _calculateBreakPoints, calculateBreakPoints_fn, _setTabArray, setTabArray_fn, _updateCollapsibleTabs, updateCollapsibleTabs_fn, _isElementTabLike, isElementTabLike_fn;
|
|
241
239
|
let UUITabGroupElement = class extends LitElement {
|
|
242
240
|
constructor() {
|
|
243
241
|
super(...arguments);
|
|
244
242
|
__privateAdd(this, _onResize);
|
|
243
|
+
__privateAdd(this, _cleanupTabs);
|
|
245
244
|
__privateAdd(this, _onSlotChange);
|
|
246
|
-
__privateAdd(this, _updateCollapsibleTabs);
|
|
247
245
|
__privateAdd(this, _calculateBreakPoints);
|
|
248
246
|
__privateAdd(this, _setTabArray);
|
|
247
|
+
__privateAdd(this, _updateCollapsibleTabs);
|
|
249
248
|
__privateAdd(this, _isElementTabLike);
|
|
249
|
+
/** Stores the current gap used in the breakpoints */
|
|
250
|
+
__privateAdd(this, _currentGap, 0);
|
|
250
251
|
this.dropdownContentDirection = "vertical";
|
|
251
252
|
__privateAdd(this, _tabElements, []);
|
|
252
253
|
__privateAdd(this, _hiddenTabElements, []);
|
|
253
254
|
__privateAdd(this, _hiddenTabElementsMap, /* @__PURE__ */ new Map());
|
|
254
255
|
__privateAdd(this, _visibilityBreakpoints, []);
|
|
255
|
-
__privateAdd(this, _resizeObserver, new ResizeObserver(
|
|
256
|
-
|
|
257
|
-
)
|
|
256
|
+
__privateAdd(this, _resizeObserver, new ResizeObserver(__privateMethod(this, _onResize, onResize_fn).bind(this)));
|
|
257
|
+
__privateAdd(this, _tabResizeObservers, []);
|
|
258
|
+
__privateAdd(this, _breakPointCalculationInProgress, false);
|
|
258
259
|
__privateAdd(this, _onTabClicked, (e) => {
|
|
259
260
|
const selectedElement = e.currentTarget;
|
|
260
261
|
if (__privateMethod(this, _isElementTabLike, isElementTabLike_fn).call(this, selectedElement)) {
|
|
@@ -281,6 +282,9 @@ let UUITabGroupElement = class extends LitElement {
|
|
|
281
282
|
}
|
|
282
283
|
connectedCallback() {
|
|
283
284
|
super.connectedCallback();
|
|
285
|
+
demandCustomElement(this, "uui-button");
|
|
286
|
+
demandCustomElement(this, "uui-popover-container");
|
|
287
|
+
demandCustomElement(this, "uui-symbol-more");
|
|
284
288
|
__privateGet(this, _resizeObserver).observe(this);
|
|
285
289
|
if (!this.hasAttribute("role"))
|
|
286
290
|
this.setAttribute("role", "tablist");
|
|
@@ -288,18 +292,23 @@ let UUITabGroupElement = class extends LitElement {
|
|
|
288
292
|
disconnectedCallback() {
|
|
289
293
|
super.disconnectedCallback();
|
|
290
294
|
__privateGet(this, _resizeObserver).unobserve(this);
|
|
295
|
+
__privateMethod(this, _cleanupTabs, cleanupTabs_fn).call(this);
|
|
291
296
|
}
|
|
292
297
|
render() {
|
|
293
298
|
return html`
|
|
294
|
-
<
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
<div id="main">
|
|
300
|
+
<div id="grid">
|
|
301
|
+
<slot @slotchange=${__privateMethod(this, _onSlotChange, onSlotChange_fn)}></slot>
|
|
302
|
+
</div>
|
|
303
|
+
<uui-button
|
|
304
|
+
popovertarget="popover-container"
|
|
305
|
+
style="display: none"
|
|
306
|
+
id="more-button"
|
|
307
|
+
label="More"
|
|
308
|
+
compact>
|
|
309
|
+
<uui-symbol-more></uui-symbol-more>
|
|
310
|
+
</uui-button>
|
|
311
|
+
</div>
|
|
303
312
|
<uui-popover-container
|
|
304
313
|
id="popover-container"
|
|
305
314
|
popover
|
|
@@ -311,45 +320,94 @@ let UUITabGroupElement = class extends LitElement {
|
|
|
311
320
|
`;
|
|
312
321
|
}
|
|
313
322
|
};
|
|
323
|
+
_currentGap = new WeakMap();
|
|
314
324
|
_tabElements = new WeakMap();
|
|
315
325
|
_hiddenTabElements = new WeakMap();
|
|
316
326
|
_hiddenTabElementsMap = new WeakMap();
|
|
317
327
|
_visibilityBreakpoints = new WeakMap();
|
|
318
328
|
_resizeObserver = new WeakMap();
|
|
329
|
+
_tabResizeObservers = new WeakMap();
|
|
330
|
+
_breakPointCalculationInProgress = new WeakMap();
|
|
319
331
|
_onResize = new WeakSet();
|
|
320
332
|
onResize_fn = function(entries) {
|
|
321
|
-
|
|
333
|
+
const gapCSSVar = Number.parseFloat(
|
|
334
|
+
this.style.getPropertyValue("--uui-tab-group-gap")
|
|
335
|
+
);
|
|
336
|
+
const newGap = Number.isNaN(gapCSSVar) ? 0 : gapCSSVar;
|
|
337
|
+
if (newGap !== __privateGet(this, _currentGap)) {
|
|
338
|
+
__privateMethod(this, _calculateBreakPoints, calculateBreakPoints_fn).call(this);
|
|
339
|
+
} else {
|
|
340
|
+
__privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, entries[0].contentBoxSize[0].inlineSize);
|
|
341
|
+
}
|
|
322
342
|
};
|
|
323
|
-
|
|
324
|
-
|
|
343
|
+
_cleanupTabs = new WeakSet();
|
|
344
|
+
cleanupTabs_fn = function() {
|
|
325
345
|
__privateGet(this, _tabElements).forEach((el) => {
|
|
326
346
|
el.removeEventListener("click", __privateGet(this, _onTabClicked));
|
|
347
|
+
__privateGet(this, _tabResizeObservers).forEach((observer) => observer.disconnect());
|
|
327
348
|
});
|
|
349
|
+
__privateGet(this, _tabResizeObservers).length = 0;
|
|
350
|
+
};
|
|
351
|
+
_onSlotChange = new WeakSet();
|
|
352
|
+
onSlotChange_fn = function() {
|
|
353
|
+
__privateMethod(this, _cleanupTabs, cleanupTabs_fn).call(this);
|
|
328
354
|
__privateMethod(this, _setTabArray, setTabArray_fn).call(this);
|
|
329
355
|
__privateGet(this, _tabElements).forEach((el) => {
|
|
330
356
|
el.addEventListener("click", __privateGet(this, _onTabClicked));
|
|
357
|
+
const observer = new ResizeObserver(
|
|
358
|
+
__privateMethod(this, _calculateBreakPoints, calculateBreakPoints_fn).bind(this)
|
|
359
|
+
);
|
|
360
|
+
observer.observe(el);
|
|
361
|
+
__privateGet(this, _tabResizeObservers).push(observer);
|
|
331
362
|
});
|
|
332
363
|
};
|
|
333
364
|
_onTabClicked = new WeakMap();
|
|
365
|
+
_calculateBreakPoints = new WeakSet();
|
|
366
|
+
calculateBreakPoints_fn = async function() {
|
|
367
|
+
if (__privateGet(this, _breakPointCalculationInProgress))
|
|
368
|
+
return;
|
|
369
|
+
__privateSet(this, _breakPointCalculationInProgress, true);
|
|
370
|
+
requestAnimationFrame(() => {
|
|
371
|
+
__privateSet(this, _breakPointCalculationInProgress, false);
|
|
372
|
+
});
|
|
373
|
+
await this.updateComplete;
|
|
374
|
+
const gapCSSVar = Number.parseFloat(
|
|
375
|
+
this.style.getPropertyValue("--uui-tab-group-gap")
|
|
376
|
+
);
|
|
377
|
+
const gap = Number.isNaN(gapCSSVar) ? 0 : gapCSSVar;
|
|
378
|
+
__privateSet(this, _currentGap, gap);
|
|
379
|
+
let childrenWidth = 0;
|
|
380
|
+
for (let i = 0; i < __privateGet(this, _tabElements).length; i++) {
|
|
381
|
+
__privateGet(this, _tabElements)[i].style.display = "";
|
|
382
|
+
childrenWidth += __privateGet(this, _tabElements)[i].offsetWidth;
|
|
383
|
+
__privateGet(this, _visibilityBreakpoints)[i] = childrenWidth;
|
|
384
|
+
childrenWidth += gap;
|
|
385
|
+
}
|
|
386
|
+
const tolerance = 2;
|
|
387
|
+
this.style.maxWidth = childrenWidth - gap + tolerance + "px";
|
|
388
|
+
__privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, this.offsetWidth);
|
|
389
|
+
};
|
|
390
|
+
_setTabArray = new WeakSet();
|
|
391
|
+
setTabArray_fn = function() {
|
|
392
|
+
__privateSet(this, _tabElements, this._slottedNodes ? this._slottedNodes : []);
|
|
393
|
+
__privateMethod(this, _calculateBreakPoints, calculateBreakPoints_fn).call(this);
|
|
394
|
+
};
|
|
334
395
|
_updateCollapsibleTabs = new WeakSet();
|
|
335
396
|
updateCollapsibleTabs_fn = function(containerWidth) {
|
|
336
|
-
const
|
|
337
|
-
const
|
|
338
|
-
if (lastBreakpoint < containerWidth && __privateGet(this, _hiddenTabElements).length === 0)
|
|
339
|
-
return;
|
|
397
|
+
const moreButtonWidth = this._moreButtonElement.offsetWidth;
|
|
398
|
+
const containerWithoutButtonWidth = containerWidth - (moreButtonWidth ? moreButtonWidth : 0);
|
|
340
399
|
__privateGet(this, _hiddenTabElements).forEach((el) => {
|
|
341
400
|
el.removeEventListener("click", __privateGet(this, _onTabClicked));
|
|
342
401
|
});
|
|
343
402
|
__privateSet(this, _hiddenTabElements, []);
|
|
344
403
|
__privateGet(this, _hiddenTabElementsMap).clear();
|
|
345
404
|
let hasActiveTabInDropdown = false;
|
|
346
|
-
|
|
405
|
+
const len = __privateGet(this, _visibilityBreakpoints).length;
|
|
406
|
+
for (let i = 0; i < len; i++) {
|
|
347
407
|
const breakpoint = __privateGet(this, _visibilityBreakpoints)[i];
|
|
348
408
|
const tab = __privateGet(this, _tabElements)[i];
|
|
349
|
-
|
|
350
|
-
if (breakpoint < containerWidthButtonWidth) {
|
|
409
|
+
if (breakpoint <= (i === len - 1 ? containerWidth : containerWithoutButtonWidth)) {
|
|
351
410
|
tab.style.display = "";
|
|
352
|
-
this._moreButtonElement.style.display = "none";
|
|
353
411
|
} else {
|
|
354
412
|
const proxyTab = tab.cloneNode(true);
|
|
355
413
|
proxyTab.addEventListener("click", __privateGet(this, _onTabClicked));
|
|
@@ -360,50 +418,44 @@ updateCollapsibleTabs_fn = function(containerWidth) {
|
|
|
360
418
|
__privateGet(this, _hiddenTabElementsMap).set(tab, proxyTab);
|
|
361
419
|
__privateGet(this, _hiddenTabElements).push(proxyTab);
|
|
362
420
|
tab.style.display = "none";
|
|
363
|
-
this._moreButtonElement.style.display = "";
|
|
364
421
|
if (tab.active) {
|
|
365
422
|
hasActiveTabInDropdown = true;
|
|
366
423
|
}
|
|
367
424
|
}
|
|
368
425
|
}
|
|
369
426
|
if (__privateGet(this, _hiddenTabElements).length === 0) {
|
|
427
|
+
this._moreButtonElement.style.display = "none";
|
|
370
428
|
this._popoverContainerElement.hidePopover();
|
|
429
|
+
} else {
|
|
430
|
+
this._moreButtonElement.style.display = "";
|
|
371
431
|
}
|
|
372
432
|
hasActiveTabInDropdown ? this._moreButtonElement.classList.add("active-inside") : this._moreButtonElement.classList.remove("active-inside");
|
|
373
433
|
this.requestUpdate();
|
|
374
434
|
};
|
|
375
|
-
_calculateBreakPoints = new WeakSet();
|
|
376
|
-
calculateBreakPoints_fn = async function() {
|
|
377
|
-
await this.updateComplete;
|
|
378
|
-
let childrenWidth = 0;
|
|
379
|
-
for (let i = 0; i < __privateGet(this, _tabElements).length; i++) {
|
|
380
|
-
__privateGet(this, _tabElements)[i].style.display = "";
|
|
381
|
-
childrenWidth += __privateGet(this, _tabElements)[i].offsetWidth;
|
|
382
|
-
__privateGet(this, _visibilityBreakpoints)[i] = childrenWidth;
|
|
383
|
-
}
|
|
384
|
-
const tolerance = 2;
|
|
385
|
-
this.style.width = childrenWidth + tolerance + "px";
|
|
386
|
-
__privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, this.offsetWidth);
|
|
387
|
-
};
|
|
388
|
-
_setTabArray = new WeakSet();
|
|
389
|
-
setTabArray_fn = function() {
|
|
390
|
-
__privateSet(this, _tabElements, this._slottedNodes ? this._slottedNodes : []);
|
|
391
|
-
__privateMethod(this, _calculateBreakPoints, calculateBreakPoints_fn).call(this);
|
|
392
|
-
};
|
|
393
435
|
_isElementTabLike = new WeakSet();
|
|
394
436
|
isElementTabLike_fn = function(el) {
|
|
395
|
-
return el
|
|
437
|
+
return typeof el === "object" && "active" in el && typeof el.active === "boolean";
|
|
396
438
|
};
|
|
397
439
|
UUITabGroupElement.styles = [
|
|
398
440
|
css`
|
|
399
441
|
:host {
|
|
442
|
+
width: 100%;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
#main {
|
|
446
|
+
display: flex;
|
|
447
|
+
justify-content: space-between;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
#grid {
|
|
451
|
+
width: 1fr;
|
|
400
452
|
display: flex;
|
|
401
|
-
flex-wrap: nowrap;
|
|
402
|
-
color: var(--uui-tab-text);
|
|
403
453
|
height: 100%;
|
|
404
454
|
min-height: 48px;
|
|
405
455
|
overflow: hidden;
|
|
406
456
|
text-wrap: nowrap;
|
|
457
|
+
color: var(--uui-tab-text);
|
|
458
|
+
gap: var(--uui-tab-group-gap, 0);
|
|
407
459
|
}
|
|
408
460
|
|
|
409
461
|
#popover-container {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
import '@umbraco-ui/uui-button/lib';
|
|
3
|
-
import '@umbraco-ui/uui-popover-container/lib';
|
|
4
|
-
import '@umbraco-ui/uui-symbol-more/lib';
|
|
5
2
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* @element uui-tab-group
|
|
4
|
+
* @slot - Default slot for the tab group
|
|
8
5
|
* @cssprop --uui-tab-group-dropdown-tab-text - Define the tab text color in the dropdown
|
|
9
6
|
* @cssprop --uui-tab-group-dropdown-tab-text-hover - Define the tab text hover color in the dropdown
|
|
10
7
|
* @cssprop --uui-tab-group-dropdown-tab-text-active - Define the tab text active color in the dropdown
|
|
11
8
|
* @cssprop --uui-tab-group-dropdown-background - Define the background color of the dropdown
|
|
9
|
+
* @cssprop --uui-tab-group-gap - Define the gap between elements dropdown. Only pixel values are valid
|
|
12
10
|
*/
|
|
13
11
|
export declare class UUITabGroupElement extends LitElement {
|
|
14
12
|
#private;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-tabs",
|
|
3
|
-
"version": "1.6.0
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Umbraco",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"custom-elements.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@umbraco-ui/uui-base": "1.6.0
|
|
34
|
-
"@umbraco-ui/uui-button": "1.6.0
|
|
35
|
-
"@umbraco-ui/uui-popover-container": "1.6.0
|
|
36
|
-
"@umbraco-ui/uui-symbol-more": "1.6.0
|
|
33
|
+
"@umbraco-ui/uui-base": "1.6.0",
|
|
34
|
+
"@umbraco-ui/uui-button": "1.6.0",
|
|
35
|
+
"@umbraco-ui/uui-popover-container": "1.6.0",
|
|
36
|
+
"@umbraco-ui/uui-symbol-more": "1.6.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://uui.umbraco.com/?path=/story/uui-tabs",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "b06aebbb67ff67c9611a19927ec3ef484edcb1cc"
|
|
48
48
|
}
|