@rogieking/figui3 10.0.4 → 10.0.6

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/fig.js CHANGED
@@ -4566,6 +4566,7 @@ figDefineElement("fig-tab", FigTab);
4566
4566
  /**
4567
4567
  * A custom tabs container element.
4568
4568
  * @attr {string} name - Identifier for the tabs group
4569
+ * @attr {"buttons"|"fade"} overflow - Overflow treatment (default: buttons)
4569
4570
  */
4570
4571
  class FigTabs extends HTMLElement {
4571
4572
  #boundHandleClick;
@@ -4585,7 +4586,11 @@ class FigTabs extends HTMLElement {
4585
4586
  }
4586
4587
 
4587
4588
  static get observedAttributes() {
4588
- return ["value", "name", "disabled"];
4589
+ return ["value", "name", "disabled", "overflow"];
4590
+ }
4591
+
4592
+ get #overflowMode() {
4593
+ return this.getAttribute("overflow") === "fade" ? "fade" : "buttons";
4589
4594
  }
4590
4595
 
4591
4596
  connectedCallback() {
@@ -4596,7 +4601,7 @@ class FigTabs extends HTMLElement {
4596
4601
  this.addEventListener("click", this.#boundHandleClick);
4597
4602
  this.addEventListener("keydown", this.#boundHandleKeyDown);
4598
4603
  this.addEventListener("scroll", this.#boundSyncOverflow);
4599
- this.#createNavButtons();
4604
+ this.#applyOverflowMode();
4600
4605
  this.#startObserver();
4601
4606
  this.#startResizeObserver();
4602
4607
  figNextFrame(this, () => {
@@ -4715,10 +4720,18 @@ class FigTabs extends HTMLElement {
4715
4720
 
4716
4721
  #startObserver() {
4717
4722
  this.#mutationObserver?.disconnect();
4718
- this.#mutationObserver = new MutationObserver(() => {
4723
+ this.#mutationObserver = new MutationObserver((records) => {
4719
4724
  if (this.#isUnwrapping) return;
4725
+ const authoredChange = records.some((record) =>
4726
+ [...record.addedNodes, ...record.removedNodes].some(
4727
+ (node) =>
4728
+ !(node instanceof Element) ||
4729
+ !node.matches("[data-fig-tabs-nav]"),
4730
+ ),
4731
+ );
4732
+ if (!authoredChange) return;
4720
4733
  this.#removeLegacyScroller();
4721
- this.#createNavButtons();
4734
+ this.#applyOverflowMode();
4722
4735
  this.#syncTabIndexes();
4723
4736
  requestAnimationFrame(() => {
4724
4737
  this.#syncOverflow();
@@ -4736,6 +4749,17 @@ class FigTabs extends HTMLElement {
4736
4749
  this.classList.remove("overflow-start", "overflow-end");
4737
4750
  }
4738
4751
 
4752
+ #applyOverflowMode() {
4753
+ const fade = this.#overflowMode === "fade";
4754
+ this.classList.toggle("fig-overflow-fade", fade);
4755
+ this.classList.toggle("fig-overflow-fade-horizontal", fade);
4756
+ if (fade) {
4757
+ this.#removeNavButtons();
4758
+ } else {
4759
+ this.#createNavButtons();
4760
+ }
4761
+ }
4762
+
4739
4763
  #createNavButtons() {
4740
4764
  if (
4741
4765
  this.#navStart &&
@@ -4863,6 +4887,10 @@ class FigTabs extends HTMLElement {
4863
4887
  case "disabled":
4864
4888
  this.#applyDisabled(newValue !== null && newValue !== "false");
4865
4889
  break;
4890
+ case "overflow":
4891
+ this.#applyOverflowMode();
4892
+ requestAnimationFrame(() => this.#syncOverflow());
4893
+ break;
4866
4894
  }
4867
4895
  }
4868
4896
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "10.0.4",
3
+ "version": "10.0.6",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "SEE LICENSE IN LICENSE",