@umbraco-ui/uui-tabs 1.6.0-rc.2 → 1.6.0-rc.4
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 +70 -49
- 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,24 @@ 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, _onSlotChange, onSlotChange_fn, _onTabClicked,
|
|
238
|
+
var _currentGap, _tabElements, _hiddenTabElements, _hiddenTabElementsMap, _visibilityBreakpoints, _resizeObserver, _onResize, onResize_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);
|
|
245
243
|
__privateAdd(this, _onSlotChange);
|
|
246
|
-
__privateAdd(this, _updateCollapsibleTabs);
|
|
247
244
|
__privateAdd(this, _calculateBreakPoints);
|
|
248
245
|
__privateAdd(this, _setTabArray);
|
|
246
|
+
__privateAdd(this, _updateCollapsibleTabs);
|
|
249
247
|
__privateAdd(this, _isElementTabLike);
|
|
248
|
+
/** Stores the current gap used in the breakpoints */
|
|
249
|
+
__privateAdd(this, _currentGap, 0);
|
|
250
250
|
this.dropdownContentDirection = "vertical";
|
|
251
251
|
__privateAdd(this, _tabElements, []);
|
|
252
252
|
__privateAdd(this, _hiddenTabElements, []);
|
|
253
253
|
__privateAdd(this, _hiddenTabElementsMap, /* @__PURE__ */ new Map());
|
|
254
254
|
__privateAdd(this, _visibilityBreakpoints, []);
|
|
255
|
-
__privateAdd(this, _resizeObserver, new ResizeObserver(
|
|
256
|
-
__privateMethod(this, _onResize, onResize_fn).bind(this)
|
|
257
|
-
));
|
|
255
|
+
__privateAdd(this, _resizeObserver, new ResizeObserver(__privateMethod(this, _onResize, onResize_fn).bind(this)));
|
|
258
256
|
__privateAdd(this, _onTabClicked, (e) => {
|
|
259
257
|
const selectedElement = e.currentTarget;
|
|
260
258
|
if (__privateMethod(this, _isElementTabLike, isElementTabLike_fn).call(this, selectedElement)) {
|
|
@@ -281,6 +279,9 @@ let UUITabGroupElement = class extends LitElement {
|
|
|
281
279
|
}
|
|
282
280
|
connectedCallback() {
|
|
283
281
|
super.connectedCallback();
|
|
282
|
+
demandCustomElement(this, "uui-button");
|
|
283
|
+
demandCustomElement(this, "uui-popover-container");
|
|
284
|
+
demandCustomElement(this, "uui-symbol-more");
|
|
284
285
|
__privateGet(this, _resizeObserver).observe(this);
|
|
285
286
|
if (!this.hasAttribute("role"))
|
|
286
287
|
this.setAttribute("role", "tablist");
|
|
@@ -291,15 +292,17 @@ let UUITabGroupElement = class extends LitElement {
|
|
|
291
292
|
}
|
|
292
293
|
render() {
|
|
293
294
|
return html`
|
|
294
|
-
<
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
295
|
+
<div id="main">
|
|
296
|
+
<slot @slotchange=${__privateMethod(this, _onSlotChange, onSlotChange_fn)}></slot>
|
|
297
|
+
<uui-button
|
|
298
|
+
popovertarget="popover-container"
|
|
299
|
+
style="display: none"
|
|
300
|
+
id="more-button"
|
|
301
|
+
label="More"
|
|
302
|
+
compact>
|
|
303
|
+
<uui-symbol-more></uui-symbol-more>
|
|
304
|
+
</uui-button>
|
|
305
|
+
</div>
|
|
303
306
|
<uui-popover-container
|
|
304
307
|
id="popover-container"
|
|
305
308
|
popover
|
|
@@ -311,6 +314,7 @@ let UUITabGroupElement = class extends LitElement {
|
|
|
311
314
|
`;
|
|
312
315
|
}
|
|
313
316
|
};
|
|
317
|
+
_currentGap = new WeakMap();
|
|
314
318
|
_tabElements = new WeakMap();
|
|
315
319
|
_hiddenTabElements = new WeakMap();
|
|
316
320
|
_hiddenTabElementsMap = new WeakMap();
|
|
@@ -318,7 +322,15 @@ _visibilityBreakpoints = new WeakMap();
|
|
|
318
322
|
_resizeObserver = new WeakMap();
|
|
319
323
|
_onResize = new WeakSet();
|
|
320
324
|
onResize_fn = function(entries) {
|
|
321
|
-
|
|
325
|
+
const gapCSSVar = Number.parseFloat(
|
|
326
|
+
this.style.getPropertyValue("--uui-tab-group-gap")
|
|
327
|
+
);
|
|
328
|
+
const newGap = Number.isNaN(gapCSSVar) ? 0 : gapCSSVar;
|
|
329
|
+
if (newGap !== __privateGet(this, _currentGap)) {
|
|
330
|
+
__privateMethod(this, _calculateBreakPoints, calculateBreakPoints_fn).call(this);
|
|
331
|
+
} else {
|
|
332
|
+
__privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, entries[0].contentBoxSize[0].inlineSize);
|
|
333
|
+
}
|
|
322
334
|
};
|
|
323
335
|
_onSlotChange = new WeakSet();
|
|
324
336
|
onSlotChange_fn = function() {
|
|
@@ -331,25 +343,46 @@ onSlotChange_fn = function() {
|
|
|
331
343
|
});
|
|
332
344
|
};
|
|
333
345
|
_onTabClicked = new WeakMap();
|
|
346
|
+
_calculateBreakPoints = new WeakSet();
|
|
347
|
+
calculateBreakPoints_fn = async function() {
|
|
348
|
+
await this.updateComplete;
|
|
349
|
+
const gapCSSVar = Number.parseFloat(
|
|
350
|
+
this.style.getPropertyValue("--uui-tab-group-gap")
|
|
351
|
+
);
|
|
352
|
+
const gap = Number.isNaN(gapCSSVar) ? 0 : gapCSSVar;
|
|
353
|
+
__privateSet(this, _currentGap, gap);
|
|
354
|
+
let childrenWidth = 0;
|
|
355
|
+
for (let i = 0; i < __privateGet(this, _tabElements).length; i++) {
|
|
356
|
+
__privateGet(this, _tabElements)[i].style.display = "";
|
|
357
|
+
childrenWidth += __privateGet(this, _tabElements)[i].offsetWidth;
|
|
358
|
+
__privateGet(this, _visibilityBreakpoints)[i] = childrenWidth;
|
|
359
|
+
childrenWidth += gap;
|
|
360
|
+
}
|
|
361
|
+
const tolerance = 2;
|
|
362
|
+
this.style.maxWidth = childrenWidth - gap + tolerance + "px";
|
|
363
|
+
__privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, this.offsetWidth);
|
|
364
|
+
};
|
|
365
|
+
_setTabArray = new WeakSet();
|
|
366
|
+
setTabArray_fn = function() {
|
|
367
|
+
__privateSet(this, _tabElements, this._slottedNodes ? this._slottedNodes : []);
|
|
368
|
+
__privateMethod(this, _calculateBreakPoints, calculateBreakPoints_fn).call(this);
|
|
369
|
+
};
|
|
334
370
|
_updateCollapsibleTabs = new WeakSet();
|
|
335
371
|
updateCollapsibleTabs_fn = function(containerWidth) {
|
|
336
|
-
const
|
|
337
|
-
const
|
|
338
|
-
if (lastBreakpoint < containerWidth && __privateGet(this, _hiddenTabElements).length === 0)
|
|
339
|
-
return;
|
|
372
|
+
const moreButtonWidth = this._moreButtonElement.offsetWidth;
|
|
373
|
+
const containerWithoutButtonWidth = containerWidth - (moreButtonWidth ? moreButtonWidth + __privateGet(this, _currentGap) : 0);
|
|
340
374
|
__privateGet(this, _hiddenTabElements).forEach((el) => {
|
|
341
375
|
el.removeEventListener("click", __privateGet(this, _onTabClicked));
|
|
342
376
|
});
|
|
343
377
|
__privateSet(this, _hiddenTabElements, []);
|
|
344
378
|
__privateGet(this, _hiddenTabElementsMap).clear();
|
|
345
379
|
let hasActiveTabInDropdown = false;
|
|
346
|
-
|
|
380
|
+
const len = __privateGet(this, _visibilityBreakpoints).length;
|
|
381
|
+
for (let i = 0; i < len; i++) {
|
|
347
382
|
const breakpoint = __privateGet(this, _visibilityBreakpoints)[i];
|
|
348
383
|
const tab = __privateGet(this, _tabElements)[i];
|
|
349
|
-
|
|
350
|
-
if (breakpoint < containerWidthButtonWidth) {
|
|
384
|
+
if (breakpoint <= (i === len - 1 ? containerWidth : containerWithoutButtonWidth)) {
|
|
351
385
|
tab.style.display = "";
|
|
352
|
-
this._moreButtonElement.style.display = "none";
|
|
353
386
|
} else {
|
|
354
387
|
const proxyTab = tab.cloneNode(true);
|
|
355
388
|
proxyTab.addEventListener("click", __privateGet(this, _onTabClicked));
|
|
@@ -360,50 +393,38 @@ updateCollapsibleTabs_fn = function(containerWidth) {
|
|
|
360
393
|
__privateGet(this, _hiddenTabElementsMap).set(tab, proxyTab);
|
|
361
394
|
__privateGet(this, _hiddenTabElements).push(proxyTab);
|
|
362
395
|
tab.style.display = "none";
|
|
363
|
-
this._moreButtonElement.style.display = "";
|
|
364
396
|
if (tab.active) {
|
|
365
397
|
hasActiveTabInDropdown = true;
|
|
366
398
|
}
|
|
367
399
|
}
|
|
368
400
|
}
|
|
369
401
|
if (__privateGet(this, _hiddenTabElements).length === 0) {
|
|
402
|
+
this._moreButtonElement.style.display = "none";
|
|
370
403
|
this._popoverContainerElement.hidePopover();
|
|
404
|
+
} else {
|
|
405
|
+
this._moreButtonElement.style.display = "";
|
|
371
406
|
}
|
|
372
407
|
hasActiveTabInDropdown ? this._moreButtonElement.classList.add("active-inside") : this._moreButtonElement.classList.remove("active-inside");
|
|
373
408
|
this.requestUpdate();
|
|
374
409
|
};
|
|
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
410
|
_isElementTabLike = new WeakSet();
|
|
394
411
|
isElementTabLike_fn = function(el) {
|
|
395
|
-
return el
|
|
412
|
+
return typeof el === "object" && "active" in el && typeof el.active === "boolean";
|
|
396
413
|
};
|
|
397
414
|
UUITabGroupElement.styles = [
|
|
398
415
|
css`
|
|
399
416
|
:host {
|
|
417
|
+
width: 100%;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
#main {
|
|
400
421
|
display: flex;
|
|
401
|
-
flex-wrap: nowrap;
|
|
402
|
-
color: var(--uui-tab-text);
|
|
403
422
|
height: 100%;
|
|
404
423
|
min-height: 48px;
|
|
405
424
|
overflow: hidden;
|
|
406
425
|
text-wrap: nowrap;
|
|
426
|
+
color: var(--uui-tab-text);
|
|
427
|
+
gap: var(--uui-tab-group-gap, 0);
|
|
407
428
|
}
|
|
408
429
|
|
|
409
430
|
#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-rc.
|
|
3
|
+
"version": "1.6.0-rc.4",
|
|
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-rc.
|
|
34
|
-
"@umbraco-ui/uui-button": "1.6.0-rc.
|
|
35
|
-
"@umbraco-ui/uui-popover-container": "1.6.0-rc.
|
|
36
|
-
"@umbraco-ui/uui-symbol-more": "1.6.0-rc.
|
|
33
|
+
"@umbraco-ui/uui-base": "1.6.0-rc.4",
|
|
34
|
+
"@umbraco-ui/uui-button": "1.6.0-rc.4",
|
|
35
|
+
"@umbraco-ui/uui-popover-container": "1.6.0-rc.4",
|
|
36
|
+
"@umbraco-ui/uui-symbol-more": "1.6.0-rc.4"
|
|
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": "ae00cf3a0d7be2827491b435c1a40f5d7649a504"
|
|
48
48
|
}
|