@umbraco-ui/uui-tabs 1.6.0-rc.4 → 1.6.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/lib/index.js CHANGED
@@ -235,11 +235,13 @@ var __privateMethod = (obj, member, method) => {
235
235
  __accessCheck(obj, member, "access private method");
236
236
  return method;
237
237
  };
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;
238
+ var _currentGap, _tabElements, _hiddenTabElements, _hiddenTabElementsMap, _visibilityBreakpoints, _resizeObserver, _tabResizeObservers, _breakPointCalculationInProgress, _initialize, initialize_fn, _onResize, onResize_fn, _cleanupTabs, cleanupTabs_fn, _onSlotChange, onSlotChange_fn, _onTabClicked, _calculateBreakPoints, calculateBreakPoints_fn, _setTabArray, setTabArray_fn, _updateCollapsibleTabs, updateCollapsibleTabs_fn, _isElementTabLike, isElementTabLike_fn;
239
239
  let UUITabGroupElement = class extends LitElement {
240
240
  constructor() {
241
241
  super(...arguments);
242
+ __privateAdd(this, _initialize);
242
243
  __privateAdd(this, _onResize);
244
+ __privateAdd(this, _cleanupTabs);
243
245
  __privateAdd(this, _onSlotChange);
244
246
  __privateAdd(this, _calculateBreakPoints);
245
247
  __privateAdd(this, _setTabArray);
@@ -253,6 +255,8 @@ let UUITabGroupElement = class extends LitElement {
253
255
  __privateAdd(this, _hiddenTabElementsMap, /* @__PURE__ */ new Map());
254
256
  __privateAdd(this, _visibilityBreakpoints, []);
255
257
  __privateAdd(this, _resizeObserver, new ResizeObserver(__privateMethod(this, _onResize, onResize_fn).bind(this)));
258
+ __privateAdd(this, _tabResizeObservers, []);
259
+ __privateAdd(this, _breakPointCalculationInProgress, false);
256
260
  __privateAdd(this, _onTabClicked, (e) => {
257
261
  const selectedElement = e.currentTarget;
258
262
  if (__privateMethod(this, _isElementTabLike, isElementTabLike_fn).call(this, selectedElement)) {
@@ -279,21 +283,19 @@ let UUITabGroupElement = class extends LitElement {
279
283
  }
280
284
  connectedCallback() {
281
285
  super.connectedCallback();
282
- demandCustomElement(this, "uui-button");
283
- demandCustomElement(this, "uui-popover-container");
284
- demandCustomElement(this, "uui-symbol-more");
285
- __privateGet(this, _resizeObserver).observe(this);
286
- if (!this.hasAttribute("role"))
287
- this.setAttribute("role", "tablist");
286
+ __privateMethod(this, _initialize, initialize_fn).call(this);
288
287
  }
289
288
  disconnectedCallback() {
290
289
  super.disconnectedCallback();
291
290
  __privateGet(this, _resizeObserver).unobserve(this);
291
+ __privateMethod(this, _cleanupTabs, cleanupTabs_fn).call(this);
292
292
  }
293
293
  render() {
294
294
  return html`
295
295
  <div id="main">
296
- <slot @slotchange=${__privateMethod(this, _onSlotChange, onSlotChange_fn)}></slot>
296
+ <div id="grid">
297
+ <slot @slotchange=${__privateMethod(this, _onSlotChange, onSlotChange_fn)}></slot>
298
+ </div>
297
299
  <uui-button
298
300
  popovertarget="popover-container"
299
301
  style="display: none"
@@ -320,6 +322,18 @@ _hiddenTabElements = new WeakMap();
320
322
  _hiddenTabElementsMap = new WeakMap();
321
323
  _visibilityBreakpoints = new WeakMap();
322
324
  _resizeObserver = new WeakMap();
325
+ _tabResizeObservers = new WeakMap();
326
+ _breakPointCalculationInProgress = new WeakMap();
327
+ _initialize = new WeakSet();
328
+ initialize_fn = async function() {
329
+ demandCustomElement(this, "uui-button");
330
+ demandCustomElement(this, "uui-popover-container");
331
+ demandCustomElement(this, "uui-symbol-more");
332
+ if (!this.hasAttribute("role"))
333
+ this.setAttribute("role", "tablist");
334
+ await this.updateComplete;
335
+ __privateGet(this, _resizeObserver).observe(this._mainElement);
336
+ };
323
337
  _onResize = new WeakSet();
324
338
  onResize_fn = function(entries) {
325
339
  const gapCSSVar = Number.parseFloat(
@@ -332,19 +346,36 @@ onResize_fn = function(entries) {
332
346
  __privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, entries[0].contentBoxSize[0].inlineSize);
333
347
  }
334
348
  };
335
- _onSlotChange = new WeakSet();
336
- onSlotChange_fn = function() {
349
+ _cleanupTabs = new WeakSet();
350
+ cleanupTabs_fn = function() {
337
351
  __privateGet(this, _tabElements).forEach((el) => {
338
352
  el.removeEventListener("click", __privateGet(this, _onTabClicked));
353
+ __privateGet(this, _tabResizeObservers).forEach((observer) => observer.disconnect());
339
354
  });
355
+ __privateGet(this, _tabResizeObservers).length = 0;
356
+ };
357
+ _onSlotChange = new WeakSet();
358
+ onSlotChange_fn = function() {
359
+ __privateMethod(this, _cleanupTabs, cleanupTabs_fn).call(this);
340
360
  __privateMethod(this, _setTabArray, setTabArray_fn).call(this);
341
361
  __privateGet(this, _tabElements).forEach((el) => {
342
362
  el.addEventListener("click", __privateGet(this, _onTabClicked));
363
+ const observer = new ResizeObserver(
364
+ __privateMethod(this, _calculateBreakPoints, calculateBreakPoints_fn).bind(this)
365
+ );
366
+ observer.observe(el);
367
+ __privateGet(this, _tabResizeObservers).push(observer);
343
368
  });
344
369
  };
345
370
  _onTabClicked = new WeakMap();
346
371
  _calculateBreakPoints = new WeakSet();
347
372
  calculateBreakPoints_fn = async function() {
373
+ if (__privateGet(this, _breakPointCalculationInProgress))
374
+ return;
375
+ __privateSet(this, _breakPointCalculationInProgress, true);
376
+ requestAnimationFrame(() => {
377
+ __privateSet(this, _breakPointCalculationInProgress, false);
378
+ });
348
379
  await this.updateComplete;
349
380
  const gapCSSVar = Number.parseFloat(
350
381
  this.style.getPropertyValue("--uui-tab-group-gap")
@@ -359,8 +390,8 @@ calculateBreakPoints_fn = async function() {
359
390
  childrenWidth += gap;
360
391
  }
361
392
  const tolerance = 2;
362
- this.style.maxWidth = childrenWidth - gap + tolerance + "px";
363
- __privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, this.offsetWidth);
393
+ this._mainElement.style.width = childrenWidth - gap + tolerance + "px";
394
+ __privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, this._mainElement.offsetWidth);
364
395
  };
365
396
  _setTabArray = new WeakSet();
366
397
  setTabArray_fn = function() {
@@ -370,7 +401,7 @@ setTabArray_fn = function() {
370
401
  _updateCollapsibleTabs = new WeakSet();
371
402
  updateCollapsibleTabs_fn = function(containerWidth) {
372
403
  const moreButtonWidth = this._moreButtonElement.offsetWidth;
373
- const containerWithoutButtonWidth = containerWidth - (moreButtonWidth ? moreButtonWidth + __privateGet(this, _currentGap) : 0);
404
+ const containerWithoutButtonWidth = containerWidth - (moreButtonWidth ? moreButtonWidth : 0);
374
405
  __privateGet(this, _hiddenTabElements).forEach((el) => {
375
406
  el.removeEventListener("click", __privateGet(this, _onTabClicked));
376
407
  });
@@ -414,10 +445,19 @@ isElementTabLike_fn = function(el) {
414
445
  UUITabGroupElement.styles = [
415
446
  css`
416
447
  :host {
417
- width: 100%;
448
+ min-width: 0;
449
+ display: flex;
450
+ height: 100%;
418
451
  }
419
452
 
420
453
  #main {
454
+ display: flex;
455
+ justify-content: space-between;
456
+ overflow: hidden;
457
+ }
458
+
459
+ #grid {
460
+ width: 1fr;
421
461
  display: flex;
422
462
  height: 100%;
423
463
  min-height: 48px;
@@ -495,6 +535,9 @@ __decorateClass([
495
535
  __decorateClass([
496
536
  query("#popover-container")
497
537
  ], UUITabGroupElement.prototype, "_popoverContainerElement", 2);
538
+ __decorateClass([
539
+ query("#main")
540
+ ], UUITabGroupElement.prototype, "_mainElement", 2);
498
541
  __decorateClass([
499
542
  queryAssignedElements({
500
543
  flatten: true,
@@ -12,6 +12,7 @@ export declare class UUITabGroupElement extends LitElement {
12
12
  #private;
13
13
  private _moreButtonElement;
14
14
  private _popoverContainerElement;
15
+ private _mainElement;
15
16
  private _slottedNodes?;
16
17
  /**
17
18
  * Set the flex direction of the content of the dropdown.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-ui/uui-tabs",
3
- "version": "1.6.0-rc.4",
3
+ "version": "1.6.1",
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.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"
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": "ae00cf3a0d7be2827491b435c1a40f5d7649a504"
47
+ "gitHead": "a4ae7535264c89cf346311d3d5ec5c888577e256"
48
48
  }