@rogieking/figui3 9.0.8 → 9.0.10

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-editor.css CHANGED
@@ -318,7 +318,7 @@ fig-fill-picker {
318
318
  grid-template-columns: unset;
319
319
  grid-template-areas: unset;
320
320
  padding-right: var(--spacer-2);
321
- padding-left: var(--spacer-3);
321
+ padding-left: var(--spacer-2);
322
322
  gap: var(--spacer-2);
323
323
 
324
324
  > *:not(.fig-field-chevron):not(label) {
package/fig-editor.js CHANGED
@@ -495,6 +495,7 @@ figEditorDefineElement("fig-select-options", FigSelectOptions);
495
495
  * A dropdown-styled select.
496
496
  * @attr {string} variant - Visual style. Use `ghost` for a borderless control.
497
497
  * @attr {string} size - Control size. Use `large` for a 32px-tall control.
498
+ * @event optionfocus - Fires with the focused option value during open-menu keyboard navigation.
498
499
  */
499
500
  class FigSelect extends HTMLElement {
500
501
  #button = null;
@@ -1467,20 +1468,20 @@ class FigSelect extends HTMLElement {
1467
1468
  case "ArrowDown":
1468
1469
  e.preventDefault();
1469
1470
  this.#syncFocusedIndex();
1470
- this.#focusOptionAt(this.#focusedIndex + 1);
1471
+ this.#focusOptionAt(this.#focusedIndex + 1, true);
1471
1472
  break;
1472
1473
  case "ArrowUp":
1473
1474
  e.preventDefault();
1474
1475
  this.#syncFocusedIndex();
1475
- this.#focusOptionAt(this.#focusedIndex - 1);
1476
+ this.#focusOptionAt(this.#focusedIndex - 1, true);
1476
1477
  break;
1477
1478
  case "Home":
1478
1479
  e.preventDefault();
1479
- this.#focusOptionAt(0);
1480
+ this.#focusOptionAt(0, true);
1480
1481
  break;
1481
1482
  case "End":
1482
1483
  e.preventDefault();
1483
- this.#focusOptionAt(options.length - 1);
1484
+ this.#focusOptionAt(options.length - 1, true);
1484
1485
  break;
1485
1486
  case "Escape":
1486
1487
  e.preventDefault();
@@ -1529,12 +1530,23 @@ class FigSelect extends HTMLElement {
1529
1530
  this.#focusedIndex = index >= 0 ? index : this.#focusedIndex;
1530
1531
  }
1531
1532
 
1532
- #focusOptionAt(index) {
1533
+ #focusOptionAt(index, emitEvent = false) {
1533
1534
  const options = this.#getEnabledOptions();
1534
1535
  if (!options.length) return;
1535
1536
  const next = ((index % options.length) + options.length) % options.length;
1537
+ const option = options[next];
1538
+ const changed = document.activeElement !== option;
1536
1539
  this.#focusedIndex = next;
1537
- options[next]?.focus();
1540
+ option?.focus();
1541
+ if (emitEvent && changed) {
1542
+ this.dispatchEvent(
1543
+ new CustomEvent("optionfocus", {
1544
+ detail: this.#optionValue(option),
1545
+ bubbles: true,
1546
+ composed: true,
1547
+ }),
1548
+ );
1549
+ }
1538
1550
  }
1539
1551
 
1540
1552
  #syncPopupWidth() {
@@ -3505,6 +3517,7 @@ class FigFillPicker extends HTMLElement {
3505
3517
  className: "fig-fill-picker-gradient-type",
3506
3518
  label: "Gradient type",
3507
3519
  value: this.#gradient.type,
3520
+ variant: "ghost",
3508
3521
  },
3509
3522
  figEditorCreateElement(
3510
3523
  "fig-select-options",
@@ -3591,7 +3604,7 @@ class FigFillPicker extends HTMLElement {
3591
3604
  className: "fig-fill-picker-gradient-stops-header",
3592
3605
  borderless: true,
3593
3606
  },
3594
- [figEditorCreateElement("span", {}, "Stops"), addButton],
3607
+ [figEditorCreateElement("h3", {}, "Stops"), addButton],
3595
3608
  ),
3596
3609
  figEditorCreateElement(
3597
3610
  "div",
package/fig.js CHANGED
@@ -18978,6 +18978,7 @@ class FigHandle extends HTMLElement {
18978
18978
  this.#syncDrag();
18979
18979
  this.#syncHitArea();
18980
18980
  this.addEventListener("click", this.#handleSelect);
18981
+ this.addEventListener("blur", this.#handleBlur);
18981
18982
  document.addEventListener("pointerdown", this.#handleDeselect);
18982
18983
  document.addEventListener("keydown", this.#handleKeyDown);
18983
18984
  const initial = this.getAttribute("value");
@@ -18995,6 +18996,7 @@ class FigHandle extends HTMLElement {
18995
18996
  this.#hitAreaEl = null;
18996
18997
  }
18997
18998
  this.removeEventListener("click", this.#handleSelect);
18999
+ this.removeEventListener("blur", this.#handleBlur);
18998
19000
  document.removeEventListener("pointerdown", this.#handleDeselect);
18999
19001
  document.removeEventListener("keydown", this.#handleKeyDown);
19000
19002
  }
@@ -19029,7 +19031,12 @@ class FigHandle extends HTMLElement {
19029
19031
  this.deselect();
19030
19032
  };
19031
19033
 
19034
+ #handleBlur = () => {
19035
+ this.removeAttribute("data-fig-pointer-focus");
19036
+ };
19037
+
19032
19038
  #handleKeyDown = (e) => {
19039
+ this.removeAttribute("data-fig-pointer-focus");
19033
19040
  if (e.defaultPrevented) return;
19034
19041
  if (
19035
19042
  e.target === this &&
@@ -19215,6 +19222,7 @@ class FigHandle extends HTMLElement {
19215
19222
  #onPointerDown(e) {
19216
19223
  if (!this.#dragEnabled || figBooleanAttribute(this, "disabled")) return;
19217
19224
  e.preventDefault();
19225
+ this.setAttribute("data-fig-pointer-focus", "");
19218
19226
  this.focus();
19219
19227
  this.select();
19220
19228
  const container = this.#getContainer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "9.0.8",
3
+ "version": "9.0.10",
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",