@umbraco-ui/uui-tabs 1.6.0-rc.4 → 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.
Files changed (2) hide show
  1. package/lib/index.js +36 -5
  2. package/package.json +6 -6
package/lib/index.js CHANGED
@@ -235,11 +235,12 @@ 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, _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
242
  __privateAdd(this, _onResize);
243
+ __privateAdd(this, _cleanupTabs);
243
244
  __privateAdd(this, _onSlotChange);
244
245
  __privateAdd(this, _calculateBreakPoints);
245
246
  __privateAdd(this, _setTabArray);
@@ -253,6 +254,8 @@ let UUITabGroupElement = class extends LitElement {
253
254
  __privateAdd(this, _hiddenTabElementsMap, /* @__PURE__ */ new Map());
254
255
  __privateAdd(this, _visibilityBreakpoints, []);
255
256
  __privateAdd(this, _resizeObserver, new ResizeObserver(__privateMethod(this, _onResize, onResize_fn).bind(this)));
257
+ __privateAdd(this, _tabResizeObservers, []);
258
+ __privateAdd(this, _breakPointCalculationInProgress, false);
256
259
  __privateAdd(this, _onTabClicked, (e) => {
257
260
  const selectedElement = e.currentTarget;
258
261
  if (__privateMethod(this, _isElementTabLike, isElementTabLike_fn).call(this, selectedElement)) {
@@ -289,11 +292,14 @@ let UUITabGroupElement = class extends LitElement {
289
292
  disconnectedCallback() {
290
293
  super.disconnectedCallback();
291
294
  __privateGet(this, _resizeObserver).unobserve(this);
295
+ __privateMethod(this, _cleanupTabs, cleanupTabs_fn).call(this);
292
296
  }
293
297
  render() {
294
298
  return html`
295
299
  <div id="main">
296
- <slot @slotchange=${__privateMethod(this, _onSlotChange, onSlotChange_fn)}></slot>
300
+ <div id="grid">
301
+ <slot @slotchange=${__privateMethod(this, _onSlotChange, onSlotChange_fn)}></slot>
302
+ </div>
297
303
  <uui-button
298
304
  popovertarget="popover-container"
299
305
  style="display: none"
@@ -320,6 +326,8 @@ _hiddenTabElements = new WeakMap();
320
326
  _hiddenTabElementsMap = new WeakMap();
321
327
  _visibilityBreakpoints = new WeakMap();
322
328
  _resizeObserver = new WeakMap();
329
+ _tabResizeObservers = new WeakMap();
330
+ _breakPointCalculationInProgress = new WeakMap();
323
331
  _onResize = new WeakSet();
324
332
  onResize_fn = function(entries) {
325
333
  const gapCSSVar = Number.parseFloat(
@@ -332,19 +340,36 @@ onResize_fn = function(entries) {
332
340
  __privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, entries[0].contentBoxSize[0].inlineSize);
333
341
  }
334
342
  };
335
- _onSlotChange = new WeakSet();
336
- onSlotChange_fn = function() {
343
+ _cleanupTabs = new WeakSet();
344
+ cleanupTabs_fn = function() {
337
345
  __privateGet(this, _tabElements).forEach((el) => {
338
346
  el.removeEventListener("click", __privateGet(this, _onTabClicked));
347
+ __privateGet(this, _tabResizeObservers).forEach((observer) => observer.disconnect());
339
348
  });
349
+ __privateGet(this, _tabResizeObservers).length = 0;
350
+ };
351
+ _onSlotChange = new WeakSet();
352
+ onSlotChange_fn = function() {
353
+ __privateMethod(this, _cleanupTabs, cleanupTabs_fn).call(this);
340
354
  __privateMethod(this, _setTabArray, setTabArray_fn).call(this);
341
355
  __privateGet(this, _tabElements).forEach((el) => {
342
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);
343
362
  });
344
363
  };
345
364
  _onTabClicked = new WeakMap();
346
365
  _calculateBreakPoints = new WeakSet();
347
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
+ });
348
373
  await this.updateComplete;
349
374
  const gapCSSVar = Number.parseFloat(
350
375
  this.style.getPropertyValue("--uui-tab-group-gap")
@@ -370,7 +395,7 @@ setTabArray_fn = function() {
370
395
  _updateCollapsibleTabs = new WeakSet();
371
396
  updateCollapsibleTabs_fn = function(containerWidth) {
372
397
  const moreButtonWidth = this._moreButtonElement.offsetWidth;
373
- const containerWithoutButtonWidth = containerWidth - (moreButtonWidth ? moreButtonWidth + __privateGet(this, _currentGap) : 0);
398
+ const containerWithoutButtonWidth = containerWidth - (moreButtonWidth ? moreButtonWidth : 0);
374
399
  __privateGet(this, _hiddenTabElements).forEach((el) => {
375
400
  el.removeEventListener("click", __privateGet(this, _onTabClicked));
376
401
  });
@@ -418,6 +443,12 @@ UUITabGroupElement.styles = [
418
443
  }
419
444
 
420
445
  #main {
446
+ display: flex;
447
+ justify-content: space-between;
448
+ }
449
+
450
+ #grid {
451
+ width: 1fr;
421
452
  display: flex;
422
453
  height: 100%;
423
454
  min-height: 48px;
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.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-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": "b06aebbb67ff67c9611a19927ec3ef484edcb1cc"
48
48
  }