@rogieking/figui3 9.0.9 → 9.0.11
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/.cursor/skills/fig-editor/SKILL.md +1 -1
- package/.cursor/skills/fig-editor/components.md +1 -1
- package/.cursor/skills/fig-editor/reference.md +1 -1
- package/README.md +1 -1
- package/dist/fig-editor.js +2 -2
- package/dist/fig.js +1 -1
- package/fig-editor.js +18 -6
- package/fig.js +9 -0
- package/package.json +1 -1
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
|
-
|
|
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() {
|
package/fig.js
CHANGED
|
@@ -18464,6 +18464,12 @@ class FigChooser extends HTMLElement {
|
|
|
18464
18464
|
}
|
|
18465
18465
|
};
|
|
18466
18466
|
|
|
18467
|
+
const onDragStart = (e) => {
|
|
18468
|
+
if (this.#dragState?.active) {
|
|
18469
|
+
e.preventDefault();
|
|
18470
|
+
}
|
|
18471
|
+
};
|
|
18472
|
+
|
|
18467
18473
|
this.#dragState = {
|
|
18468
18474
|
active: false,
|
|
18469
18475
|
didDrag: false,
|
|
@@ -18478,6 +18484,7 @@ class FigChooser extends HTMLElement {
|
|
|
18478
18484
|
onPointerUp,
|
|
18479
18485
|
onClick,
|
|
18480
18486
|
onPointerUpCapture,
|
|
18487
|
+
onDragStart,
|
|
18481
18488
|
};
|
|
18482
18489
|
|
|
18483
18490
|
this.addEventListener("pointerdown", onPointerDown);
|
|
@@ -18485,6 +18492,7 @@ class FigChooser extends HTMLElement {
|
|
|
18485
18492
|
window.addEventListener("pointerup", onPointerUp);
|
|
18486
18493
|
this.addEventListener("pointerup", onPointerUpCapture, true);
|
|
18487
18494
|
this.addEventListener("click", onClick, true);
|
|
18495
|
+
this.addEventListener("dragstart", onDragStart);
|
|
18488
18496
|
}
|
|
18489
18497
|
|
|
18490
18498
|
#teardownDrag() {
|
|
@@ -18498,6 +18506,7 @@ class FigChooser extends HTMLElement {
|
|
|
18498
18506
|
true,
|
|
18499
18507
|
);
|
|
18500
18508
|
this.removeEventListener("click", this.#dragState.onClick, true);
|
|
18509
|
+
this.removeEventListener("dragstart", this.#dragState.onDragStart);
|
|
18501
18510
|
this.style.cursor = "";
|
|
18502
18511
|
this.style.userSelect = "";
|
|
18503
18512
|
this.#dragState = null;
|
package/package.json
CHANGED