@rogieking/figui3 10.0.5 → 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/CHANGELOG.md +25 -0
- package/README.md +7 -0
- package/components.css +22 -11
- package/dist/components.css +1 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig-editor.js +3 -3
- package/dist/fig.css +1 -1
- package/dist/fig.js +4 -4
- package/fig-editor.css +4 -74
- package/fig-editor.js +21 -1
- package/fig.js +36 -6
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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"])
|
|
918
|
-
&[aria-selected="true"]
|
|
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?.(
|
|
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
|
@@ -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.#
|
|
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.#
|
|
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
|
|
|
@@ -4879,9 +4907,11 @@ class FigTabs extends HTMLElement {
|
|
|
4879
4907
|
target.getAttribute("disabled") !== "false"
|
|
4880
4908
|
)
|
|
4881
4909
|
return;
|
|
4882
|
-
const previousTab = this.selectedTab;
|
|
4883
|
-
const previousValue = this.value;
|
|
4884
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);
|
|
4885
4915
|
for (const tab of tabs) {
|
|
4886
4916
|
if (tab === target) {
|
|
4887
4917
|
this.selectedTab = tab;
|
package/package.json
CHANGED