@rogieking/figui3 10.0.6 → 10.0.7

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
@@ -804,20 +804,8 @@ fig-select-options > :is(fig-separator, fig-menu-separator) {
804
804
  }
805
805
 
806
806
  fig-select-option {
807
- display: flex;
808
- align-items: center;
809
- gap: 0;
810
- position: relative;
811
- box-sizing: border-box;
812
- min-width: 0;
813
807
  max-width: 100%;
814
- min-height: var(--spacer-4);
815
- height: auto;
816
- padding: var(--spacer-1) var(--spacer-2);
817
- padding-right: var(--spacer-3);
818
- border-radius: var(--radius-medium);
819
808
  color: var(--figma-color-text-menu);
820
- cursor: default;
821
809
  user-select: none;
822
810
  overflow: hidden;
823
811
  text-overflow: ellipsis;
@@ -825,7 +813,6 @@ fig-select-option {
825
813
  text-align: left;
826
814
 
827
815
  h3{
828
- margin: 0 0 var(--spacer-1) 0;
829
816
  overflow: hidden;
830
817
  text-overflow: ellipsis;
831
818
  }
@@ -835,76 +822,25 @@ fig-select-option {
835
822
  text-overflow: ellipsis;
836
823
  }
837
824
 
838
- &::before {
839
- content: "";
840
- display: block;
841
- position: absolute;
842
- inset: 0 var(--spacer-2);
843
- border-radius: var(--radius-medium);
844
- z-index: -1;
845
- background-color: transparent;
846
- }
847
-
848
- &::after {
849
- content: "";
850
- display: block;
851
- float: left;
852
- flex: 0 0 1rem;
825
+ & > fig-icon[data-fig-select-checkmark] {
853
826
  order: -1;
854
- width: 1rem;
855
- height: 1rem;
856
- margin-left: var(--spacer-1);
857
- margin-right: var(--spacer-1);
858
- background-color: currentColor;
859
- -webkit-mask-image: var(--icon-16-checkmark);
860
- mask-image: var(--icon-16-checkmark);
861
- -webkit-mask-repeat: no-repeat;
862
- mask-repeat: no-repeat;
863
- -webkit-mask-position: center;
864
- mask-position: center;
865
- -webkit-mask-size: contain;
866
- mask-size: contain;
827
+ margin: 0 var(--spacer-1);
867
828
  visibility: hidden;
868
829
  }
869
830
 
870
- & > [slot="prepend"] {
871
- margin-top: calc(var(--spacer-1) * -1);
872
- margin-bottom: calc(var(--spacer-1) * -1);
873
- margin-right: var(--spacer-1);
874
- }
875
-
876
- &:not(:has(> :not([slot="prepend"]):not([slot="append"]))) > [slot="prepend"] {
877
- display: inline-flex;
878
- vertical-align: middle;
879
- }
880
-
881
831
  &:not(:has(> :not([slot="prepend"]):not([slot="append"]))) > [slot="append"] {
882
832
  float: right;
883
833
  }
884
834
 
885
835
  & > :not([slot="prepend"]):not([slot="append"]) {
886
- flex: 1 1 auto;
887
- min-width: 0;
888
836
  overflow: hidden;
889
837
  text-overflow: ellipsis;
890
838
  }
891
839
 
892
840
  & > [slot="append"] {
893
- flex: 0 0 auto;
894
- margin-inline-start: auto;
895
841
  color: var(--figma-color-text-tertiary);
896
842
  }
897
843
 
898
- &:hover,
899
- &:focus-visible {
900
- outline: none;
901
-
902
- &::before {
903
- background-color: var(--figma-color-bg-menu-hover);
904
- }
905
- }
906
-
907
- &[subtle]:not([subtle="false"]),
908
844
  fig-select[subtle]:not([subtle="false"]) &:not([subtle="false"]) {
909
845
  &:hover,
910
846
  &:focus-visible {
@@ -914,14 +850,8 @@ fig-select-option {
914
850
  }
915
851
  }
916
852
 
917
- &[selected]:not([selected="false"])::after,
918
- &[aria-selected="true"]::after {
853
+ &[selected]:not([selected="false"]) > fig-icon[data-fig-select-checkmark],
854
+ &[aria-selected="true"] > fig-icon[data-fig-select-checkmark] {
919
855
  visibility: visible;
920
856
  }
921
-
922
- &[disabled]:not([disabled="false"]),
923
- &[aria-disabled="true"] {
924
- opacity: 0.4;
925
- pointer-events: none;
926
- }
927
857
  }
package/fig-editor.js CHANGED
@@ -315,6 +315,22 @@ function figSelectOptionEntryLabel(opt) {
315
315
  return String(opt ?? "");
316
316
  }
317
317
 
318
+ function figSelectOptionEnsureCheckmark(option) {
319
+ let icon = option.querySelector(
320
+ ":scope > fig-icon[data-fig-select-checkmark]",
321
+ );
322
+ if (icon) return icon;
323
+ icon = figEditorCreateIcon("checkmark", {
324
+ size: "small",
325
+ className: "fig-select-option-checkmark",
326
+ });
327
+ icon.setAttribute("slot", "prepend");
328
+ icon.setAttribute("aria-hidden", "true");
329
+ icon.setAttribute("data-fig-select-checkmark", "");
330
+ option.append(icon);
331
+ return icon;
332
+ }
333
+
318
334
  /**
319
335
  * A selectable option for fig-select.
320
336
  * Supports light-DOM slots: `slot="prepend"` (leading) and `slot="append"` (trailing).
@@ -365,6 +381,7 @@ class FigSelectOption extends HTMLElement {
365
381
  connectedCallback() {
366
382
  if (!this.hasAttribute("role")) this.setAttribute("role", "option");
367
383
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "-1");
384
+ figSelectOptionEnsureCheckmark(this);
368
385
  this.#syncDisabled();
369
386
  }
370
387
 
@@ -1414,7 +1431,9 @@ class FigSelect extends HTMLElement {
1414
1431
  let triggerPrepend = this.querySelector(
1415
1432
  ':scope > [slot="prepend-trigger"]:not([data-fig-select-generated])',
1416
1433
  );
1417
- const source = option?.querySelector?.(':scope > [slot="prepend"]');
1434
+ const source = option?.querySelector?.(
1435
+ ':scope > [slot="prepend"]:not([data-fig-select-checkmark])',
1436
+ );
1418
1437
  this.#customTriggerSlot.hidden = !customTrigger;
1419
1438
  this.#labelEl.hidden = Boolean(customTrigger);
1420
1439
  this.#prependEl.hidden = Boolean(customTrigger);
@@ -1554,6 +1573,7 @@ class FigSelect extends HTMLElement {
1554
1573
  }
1555
1574
 
1556
1575
  for (const opt of options) {
1576
+ figSelectOptionEnsureCheckmark(opt);
1557
1577
  const selected = opt === match;
1558
1578
  opt.setAttribute("aria-selected", selected ? "true" : "false");
1559
1579
  if (selected) opt.setAttribute("selected", "");
package/fig.js CHANGED
@@ -4907,9 +4907,11 @@ class FigTabs extends HTMLElement {
4907
4907
  target.getAttribute("disabled") !== "false"
4908
4908
  )
4909
4909
  return;
4910
- const previousTab = this.selectedTab;
4911
- const previousValue = this.value;
4912
4910
  const tabs = this.querySelectorAll("fig-tab");
4911
+ const previousTab =
4912
+ Array.from(tabs).find((tab) => figBooleanAttribute(tab, "selected")) ||
4913
+ this.selectedTab;
4914
+ const previousValue = this.#resolveTabValue(previousTab);
4913
4915
  for (const tab of tabs) {
4914
4916
  if (tab === target) {
4915
4917
  this.selectedTab = tab;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "10.0.6",
3
+ "version": "10.0.7",
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",