@haiilo/catalyst 12.0.0 → 12.2.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.
@@ -11286,7 +11286,7 @@ const CatTabs = class {
11286
11286
  }
11287
11287
  onActiveTabChange(id) {
11288
11288
  const index = this.tabs.findIndex(tab => tab.id === id);
11289
- this.catChange.emit({ id, index });
11289
+ this.catChange.emit({ id, index, fromDropdown: !!this.hiddenTabs.find(tab => tab.id === id) });
11290
11290
  }
11291
11291
  onKeydown(event) {
11292
11292
  if (['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft'].includes(event.key)) {
@@ -11326,7 +11326,7 @@ const CatTabs = class {
11326
11326
  }
11327
11327
  render() {
11328
11328
  this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;
11329
- return (index.h(index.Host, { key: '874b547102901311b51c66aace5a2f91f4d52bbb' }, index.h("div", { key: 'ab2ccbf398bdb5897c71762c9befe63f383a04db', role: "tablist", class: "cat-tab-list" }, this.tabs.map((tab, index$1) => {
11329
+ return (index.h(index.Host, { key: '7465fe19c1c67bd0f2c83ae15ed4d31e1e7610b7' }, index.h("div", { key: '3d0f4c19edd3549d3c9c8f83685b0c852770f594', role: "tablist", class: "cat-tab-list" }, this.tabs.map((tab, index$1) => {
11330
11330
  return (index.h("cat-button", { buttonId: tab.id, part: "tab", class: {
11331
11331
  'cat-tab': true,
11332
11332
  'cat-tab-active': tab.id === this.activeTab,
@@ -11365,17 +11365,18 @@ const CatTabs = class {
11365
11365
  if (this.moreButton) {
11366
11366
  this.moreButton.style.display = 'inline-flex';
11367
11367
  }
11368
- const MORE_WIDTH = this.moreButton?.offsetWidth || 0;
11368
+ const MORE_WIDTH = this.moreButton?.getBoundingClientRect().width || 0;
11369
11369
  const visibleTabsIndexes = [];
11370
+ const containerWidth = this.hostElement.clientWidth;
11370
11371
  let fittingWidth = 0;
11371
11372
  const stickyTabIndex = this.tabs.findIndex(tab => tab.sticky);
11372
- const stickyTabWidth = tabs.item(stickyTabIndex)?.scrollWidth || 0;
11373
- const stickyTabIsVisible = stickyTabIndex > -1 && stickyTabWidth <= this.hostElement.offsetWidth;
11373
+ const stickyTabWidth = tabs.item(stickyTabIndex)?.getBoundingClientRect().width || 0;
11374
+ const stickyTabIsVisible = stickyTabIndex > -1 && stickyTabWidth + MORE_WIDTH <= containerWidth;
11374
11375
  const activeTabIndex = this.tabs.findIndex(tab => tab.id === this.activeTab);
11375
- const activeTabWidth = tabs.item(activeTabIndex)?.scrollWidth || 0;
11376
+ const activeTabWidth = tabs.item(activeTabIndex)?.getBoundingClientRect().width || 0;
11376
11377
  const activeTabIsVisible = this.activeTabAlwaysVisible &&
11377
11378
  activeTabIndex > -1 &&
11378
- activeTabWidth + stickyTabWidth <= this.hostElement.offsetWidth;
11379
+ activeTabWidth + stickyTabWidth + MORE_WIDTH <= containerWidth;
11379
11380
  if (stickyTabIsVisible) {
11380
11381
  fittingWidth += stickyTabWidth;
11381
11382
  visibleTabsIndexes.push(stickyTabIndex.toString());
@@ -11388,12 +11389,13 @@ const CatTabs = class {
11388
11389
  if ((activeTabIsVisible && index === activeTabIndex) || (stickyTabIsVisible && index === stickyTabIndex)) {
11389
11390
  continue;
11390
11391
  }
11391
- if (fittingWidth + tab.scrollWidth <= this.hostElement.offsetWidth) {
11392
+ const tabWidth = tab.getBoundingClientRect().width;
11393
+ if (fittingWidth + tabWidth <= containerWidth) {
11392
11394
  // tab fits within tabs parent
11393
- fittingWidth += tab.scrollWidth;
11395
+ fittingWidth += tabWidth;
11394
11396
  visibleTabsIndexes.push(index.toString());
11395
11397
  }
11396
- else if (fittingWidth + MORE_WIDTH <= this.hostElement.offsetWidth) {
11398
+ else if (fittingWidth + MORE_WIDTH <= containerWidth) {
11397
11399
  // tab doesn't fit, but more button does
11398
11400
  break;
11399
11401
  }
@@ -11422,7 +11424,9 @@ const CatTabs = class {
11422
11424
  syncTabs() {
11423
11425
  this.tabs = Array.from(this.hostElement.querySelectorAll('cat-tab'));
11424
11426
  this.activeTab = this.activeTab || this.tabs.filter(tab => this.canActivate(tab) && !tab.noActive)[0]?.id;
11425
- this.adjustAdaptiveTabs();
11427
+ if (this.adaptive) {
11428
+ this.adjustAdaptiveTabs();
11429
+ }
11426
11430
  }
11427
11431
  click(tab) {
11428
11432
  if (this.canActivate(tab)) {
@@ -11439,7 +11443,9 @@ const CatTabs = class {
11439
11443
  else if (this.canActivate(tab)) {
11440
11444
  this.activeTab = tab.id;
11441
11445
  }
11442
- this.adjustAdaptiveTabs();
11446
+ if (this.adaptive) {
11447
+ this.adjustAdaptiveTabs();
11448
+ }
11443
11449
  }
11444
11450
  canActivate(tab) {
11445
11451
  return !tab.deactivated && !tab.url && tab.id !== this.activeTab;