@rogieking/figui3 8.9.15 → 8.9.16

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
@@ -17337,7 +17337,7 @@ figDefineElement("fig-choice", FigChoice);
17337
17337
  * @attr {string} choice-element - CSS selector for child choices (default: "fig-choice")
17338
17338
  * @attr {string} layout - Layout mode: "vertical" (default), "horizontal", "grid"
17339
17339
  * @attr {number} columns - Number of columns when layout="grid" (default: 2)
17340
- * @attr {string} value - Value of the currently selected choice
17340
+ * @attr {string} value - Selected choice value. Omit to select the first choice; `value=""` means none.
17341
17341
  * @attr {boolean} disabled - Whether the chooser is disabled
17342
17342
  */
17343
17343
  class FigChooser extends HTMLElement {
@@ -17414,12 +17414,10 @@ class FigChooser extends HTMLElement {
17414
17414
  choice.removeAttribute("selected");
17415
17415
  }
17416
17416
  }
17417
- this.#selectedChoice = element;
17417
+ this.#selectedChoice = element ?? null;
17418
17418
  const val = element?.getAttribute("value") ?? "";
17419
17419
  if (this.getAttribute("value") !== val) {
17420
- if (val) {
17421
- this.setAttribute("value", val);
17422
- }
17420
+ this.setAttribute("value", val);
17423
17421
  }
17424
17422
  this.#scrollToChoice(element);
17425
17423
  }
@@ -17429,7 +17427,10 @@ class FigChooser extends HTMLElement {
17429
17427
  }
17430
17428
 
17431
17429
  set value(val) {
17432
- if (val === null || val === undefined || val === "") return;
17430
+ if (val === null || val === undefined || val === "") {
17431
+ this.setAttribute("value", "");
17432
+ return;
17433
+ }
17433
17434
  this.setAttribute("value", String(val));
17434
17435
  }
17435
17436
 
@@ -17495,8 +17496,14 @@ class FigChooser extends HTMLElement {
17495
17496
  }
17496
17497
 
17497
17498
  attributeChangedCallback(name, oldValue, newValue) {
17498
- if (name === "value" && newValue !== oldValue && newValue) {
17499
- this.#selectByValue(newValue);
17499
+ if (name === "value" && newValue !== oldValue) {
17500
+ if (newValue === "") {
17501
+ this.selectedChoice = null;
17502
+ } else if (newValue == null) {
17503
+ this.#syncSelection();
17504
+ } else {
17505
+ this.#selectByValue(newValue);
17506
+ }
17500
17507
  }
17501
17508
  if (name === "disabled") {
17502
17509
  this.#syncDisabledChoices();
@@ -17537,7 +17544,12 @@ class FigChooser extends HTMLElement {
17537
17544
  return;
17538
17545
  }
17539
17546
 
17547
+ const hasValueAttr = this.hasAttribute("value");
17540
17548
  const valueAttr = this.getAttribute("value");
17549
+ if (hasValueAttr && valueAttr === "") {
17550
+ this.selectedChoice = null;
17551
+ return;
17552
+ }
17541
17553
  if (valueAttr && this.#selectByValue(valueAttr)) return;
17542
17554
 
17543
17555
  const alreadySelected = choices.find((choice) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "8.9.15",
3
+ "version": "8.9.16",
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": "MIT",