@fanvue/ui 3.42.0 → 3.42.2
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.
|
@@ -58,9 +58,17 @@ TabsOverflow.displayName = "TabsOverflow";
|
|
|
58
58
|
const OverflowMenu = React__namespace.forwardRef(({ items, label, children, className, onKeyDown, onMouseDown, ...props }, ref) => {
|
|
59
59
|
const { value } = React__namespace.useContext(Tabs.TabsValueContext);
|
|
60
60
|
const [open, setOpen] = React__namespace.useState(false);
|
|
61
|
+
const isOpen = React__namespace.useRef(false);
|
|
62
|
+
const [labelValue, setLabelValue] = React__namespace.useState(null);
|
|
61
63
|
const lastInput = React__namespace.useRef("keyboard");
|
|
62
64
|
const activeItem = items.find((item) => item.props.value === value);
|
|
63
|
-
|
|
65
|
+
const labelItem = labelValue ? items.find((item) => item.props.value === labelValue.value) : activeItem;
|
|
66
|
+
const handleOpenChange = (nextOpen) => {
|
|
67
|
+
if (nextOpen && !open) setLabelValue({ value });
|
|
68
|
+
isOpen.current = nextOpen;
|
|
69
|
+
setOpen(nextOpen);
|
|
70
|
+
};
|
|
71
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuRoot.DropdownMenu, { open, onOpenChange: handleOpenChange, children: [
|
|
64
72
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
65
73
|
TabsTrigger.TabsTrigger,
|
|
66
74
|
{
|
|
@@ -79,12 +87,12 @@ const OverflowMenu = React__namespace.forwardRef(({ items, label, children, clas
|
|
|
79
87
|
if (OPEN_KEYS.has(event.key)) {
|
|
80
88
|
lastInput.current = "keyboard";
|
|
81
89
|
event.preventDefault();
|
|
82
|
-
|
|
90
|
+
handleOpenChange(true);
|
|
83
91
|
}
|
|
84
92
|
},
|
|
85
93
|
...props,
|
|
86
94
|
children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRoot.DropdownMenuTrigger, { children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
|
|
87
|
-
|
|
95
|
+
labelItem ? labelItem.props.children : label,
|
|
88
96
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
89
97
|
ChevronDownIcon.ChevronDownIcon,
|
|
90
98
|
{
|
|
@@ -95,7 +103,7 @@ const OverflowMenu = React__namespace.forwardRef(({ items, label, children, clas
|
|
|
95
103
|
] }) })
|
|
96
104
|
}
|
|
97
105
|
),
|
|
98
|
-
/* @__PURE__ */ jsxRuntime.
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
99
107
|
DropdownMenuRoot.DropdownMenuContent,
|
|
100
108
|
{
|
|
101
109
|
align: "end",
|
|
@@ -112,12 +120,27 @@ const OverflowMenu = React__namespace.forwardRef(({ items, label, children, clas
|
|
|
112
120
|
onCloseAutoFocus: (event) => {
|
|
113
121
|
if (lastInput.current === "pointer") event.preventDefault();
|
|
114
122
|
},
|
|
115
|
-
children
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReleaseOnUnmount, { release: setLabelValue, isOpen }),
|
|
125
|
+
children
|
|
126
|
+
]
|
|
116
127
|
}
|
|
117
128
|
)
|
|
118
129
|
] });
|
|
119
130
|
});
|
|
120
131
|
OverflowMenu.displayName = "OverflowMenu";
|
|
132
|
+
function ReleaseOnUnmount({
|
|
133
|
+
release,
|
|
134
|
+
isOpen
|
|
135
|
+
}) {
|
|
136
|
+
React__namespace.useEffect(
|
|
137
|
+
() => () => {
|
|
138
|
+
if (!isOpen.current) release(null);
|
|
139
|
+
},
|
|
140
|
+
[release, isOpen]
|
|
141
|
+
);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
121
144
|
exports.TabsOverflow = TabsOverflow;
|
|
122
145
|
exports.TabsOverflowItem = TabsOverflowItem;
|
|
123
146
|
//# sourceMappingURL=TabsOverflow.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsOverflow.cjs","sources":["../../../../src/components/Tabs/TabsOverflow.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { DropdownMenuItem, type DropdownMenuItemProps } from \"../DropdownMenu/DropdownMenuItem\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from \"../DropdownMenu/DropdownMenuRoot\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { OVERFLOW_TAB_VALUE, TabsValueContext } from \"./Tabs\";\nimport { TabsTrigger, type TabsTriggerProps } from \"./TabsTrigger\";\n\nconst OPEN_KEYS = new Set([\"Enter\", \" \", \"ArrowDown\"]);\n\n/** Props for the {@link TabsOverflow} component. */\nexport interface TabsOverflowProps\n extends Omit<TabsTriggerProps, \"value\" | \"children\" | \"asChild\"> {\n /** Text shown on the tab while none of its items is active, e.g. \"More\". */\n label: React.ReactNode;\n /** {@link TabsOverflowItem} elements, one per tab that doesn't fit the row. */\n children?: React.ReactNode;\n}\n\n/** Props for the {@link TabsOverflowItem} component. */\nexport type TabsOverflowItemProps = Omit<DropdownMenuItemProps, \"selected\" | \"onSelect\"> & {\n /** The tab's value, as on a {@link TabsTrigger}. */\n value: string;\n};\n\n/**\n * A tab listed in a {@link TabsOverflow} menu. The active one takes the menu's\n * selected style and is announced as the checked option.\n */\nexport const TabsOverflowItem = React.forwardRef<HTMLDivElement, TabsOverflowItemProps>(\n ({ value, ...props }, ref) => {\n const selection = React.useContext(TabsValueContext);\n const isActive = selection.value === value;\n return (\n <DropdownMenuItem\n ref={ref}\n role=\"menuitemradio\"\n aria-checked={isActive}\n selected={isActive}\n onSelect={() => selection.select(value)}\n {...props}\n />\n );\n },\n);\n\nTabsOverflowItem.displayName = \"TabsOverflowItem\";\n\n/**\n * The last tab in a {@link TabsList}, opening a menu of the tabs that don't fit\n * the row. It sits in the row's arrow-key order, opens with click, Enter, Space\n * or ArrowDown, and never selects anything itself. While one of its items is\n * active it shows that item's label and is the selected tab.\n *\n * Reads and sets the value of the surrounding {@link Tabs}, controlled or not.\n * Renders nothing when it has no items.\n *\n * @example\n * ```tsx\n * <Tabs value={tab} onValueChange={setTab}>\n * <TabsList appearance=\"pill\">\n * <TabsTrigger value=\"all\">All</TabsTrigger>\n * <TabsOverflow label=\"More\">\n * <TabsOverflowItem value=\"tips\">Tips</TabsOverflowItem>\n * </TabsOverflow>\n * </TabsList>\n * </Tabs>\n * ```\n */\nexport const TabsOverflow = React.forwardRef<HTMLButtonElement, TabsOverflowProps>(\n ({ children, ...props }, ref) => {\n const items = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<TabsOverflowItemProps> => React.isValidElement(child),\n );\n if (items.length === 0) return null;\n return (\n <OverflowMenu ref={ref} items={items} {...props}>\n {children}\n </OverflowMenu>\n );\n },\n);\n\nTabsOverflow.displayName = \"TabsOverflow\";\n\nconst OverflowMenu = React.forwardRef<\n HTMLButtonElement,\n TabsOverflowProps & { items: React.ReactElement<TabsOverflowItemProps>[] }\n>(({ items, label, children, className, onKeyDown, onMouseDown, ...props }, ref) => {\n const { value } = React.useContext(TabsValueContext);\n const [open, setOpen] = React.useState(false);\n\n const lastInput = React.useRef<\"pointer\" | \"keyboard\">(\"keyboard\");\n\n const activeItem = items.find((item) => item.props.value === value);\n\n return (\n <DropdownMenu open={open} onOpenChange={
|
|
1
|
+
{"version":3,"file":"TabsOverflow.cjs","sources":["../../../../src/components/Tabs/TabsOverflow.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { DropdownMenuItem, type DropdownMenuItemProps } from \"../DropdownMenu/DropdownMenuItem\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from \"../DropdownMenu/DropdownMenuRoot\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { OVERFLOW_TAB_VALUE, TabsValueContext } from \"./Tabs\";\nimport { TabsTrigger, type TabsTriggerProps } from \"./TabsTrigger\";\n\nconst OPEN_KEYS = new Set([\"Enter\", \" \", \"ArrowDown\"]);\n\n/** Props for the {@link TabsOverflow} component. */\nexport interface TabsOverflowProps\n extends Omit<TabsTriggerProps, \"value\" | \"children\" | \"asChild\"> {\n /** Text shown on the tab while none of its items is active, e.g. \"More\". */\n label: React.ReactNode;\n /** {@link TabsOverflowItem} elements, one per tab that doesn't fit the row. */\n children?: React.ReactNode;\n}\n\n/** Props for the {@link TabsOverflowItem} component. */\nexport type TabsOverflowItemProps = Omit<DropdownMenuItemProps, \"selected\" | \"onSelect\"> & {\n /** The tab's value, as on a {@link TabsTrigger}. */\n value: string;\n};\n\n/**\n * A tab listed in a {@link TabsOverflow} menu. The active one takes the menu's\n * selected style and is announced as the checked option.\n */\nexport const TabsOverflowItem = React.forwardRef<HTMLDivElement, TabsOverflowItemProps>(\n ({ value, ...props }, ref) => {\n const selection = React.useContext(TabsValueContext);\n const isActive = selection.value === value;\n return (\n <DropdownMenuItem\n ref={ref}\n role=\"menuitemradio\"\n aria-checked={isActive}\n selected={isActive}\n onSelect={() => selection.select(value)}\n {...props}\n />\n );\n },\n);\n\nTabsOverflowItem.displayName = \"TabsOverflowItem\";\n\n/**\n * The last tab in a {@link TabsList}, opening a menu of the tabs that don't fit\n * the row. It sits in the row's arrow-key order, opens with click, Enter, Space\n * or ArrowDown, and never selects anything itself. While one of its items is\n * active it shows that item's label and is the selected tab.\n *\n * Reads and sets the value of the surrounding {@link Tabs}, controlled or not.\n * Renders nothing when it has no items.\n *\n * @example\n * ```tsx\n * <Tabs value={tab} onValueChange={setTab}>\n * <TabsList appearance=\"pill\">\n * <TabsTrigger value=\"all\">All</TabsTrigger>\n * <TabsOverflow label=\"More\">\n * <TabsOverflowItem value=\"tips\">Tips</TabsOverflowItem>\n * </TabsOverflow>\n * </TabsList>\n * </Tabs>\n * ```\n */\nexport const TabsOverflow = React.forwardRef<HTMLButtonElement, TabsOverflowProps>(\n ({ children, ...props }, ref) => {\n const items = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<TabsOverflowItemProps> => React.isValidElement(child),\n );\n if (items.length === 0) return null;\n return (\n <OverflowMenu ref={ref} items={items} {...props}>\n {children}\n </OverflowMenu>\n );\n },\n);\n\nTabsOverflow.displayName = \"TabsOverflow\";\n\nconst OverflowMenu = React.forwardRef<\n HTMLButtonElement,\n TabsOverflowProps & { items: React.ReactElement<TabsOverflowItemProps>[] }\n>(({ items, label, children, className, onKeyDown, onMouseDown, ...props }, ref) => {\n const { value } = React.useContext(TabsValueContext);\n const [open, setOpen] = React.useState(false);\n const isOpen = React.useRef(false);\n const [labelValue, setLabelValue] = React.useState<{ value: string | undefined } | null>(null);\n\n const lastInput = React.useRef<\"pointer\" | \"keyboard\">(\"keyboard\");\n\n const activeItem = items.find((item) => item.props.value === value);\n const labelItem = labelValue\n ? items.find((item) => item.props.value === labelValue.value)\n : activeItem;\n\n const handleOpenChange = (nextOpen: boolean) => {\n if (nextOpen && !open) setLabelValue({ value });\n isOpen.current = nextOpen;\n setOpen(nextOpen);\n };\n\n return (\n <DropdownMenu open={open} onOpenChange={handleOpenChange}>\n <TabsTrigger\n ref={ref}\n asChild\n value={activeItem ? activeItem.props.value : OVERFLOW_TAB_VALUE}\n {...(!activeItem && { \"aria-controls\": undefined })}\n className={className}\n onMouseDown={(event) => {\n onMouseDown?.(event);\n event.preventDefault();\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (OPEN_KEYS.has(event.key)) {\n lastInput.current = \"keyboard\";\n event.preventDefault();\n handleOpenChange(true);\n }\n }}\n {...props}\n >\n <DropdownMenuTrigger>\n <span className=\"flex items-center gap-2\">\n {labelItem ? labelItem.props.children : label}\n <ChevronDownIcon\n size={16}\n className={cn(\"motion-safe:transition-transform\", open && \"rotate-180\")}\n />\n </span>\n </DropdownMenuTrigger>\n </TabsTrigger>\n <DropdownMenuContent\n align=\"end\"\n aria-label={typeof label === \"string\" ? label : undefined}\n onPointerDownCapture={() => {\n lastInput.current = \"pointer\";\n }}\n onKeyDownCapture={() => {\n lastInput.current = \"keyboard\";\n }}\n onPointerDownOutside={() => {\n lastInput.current = \"pointer\";\n }}\n onCloseAutoFocus={(event) => {\n if (lastInput.current === \"pointer\") event.preventDefault();\n }}\n >\n <ReleaseOnUnmount release={setLabelValue} isOpen={isOpen} />\n {children}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n});\n\nOverflowMenu.displayName = \"OverflowMenu\";\n\n/**\n * Hands the trigger's label back to the live selection once the menu content\n * unmounts, which Radix delays until its exit animation has finished. Holding\n * the label until then keeps the trigger's width, so the closing menu, anchored\n * to it, doesn't shift as it fades. Only a closed menu releases it: StrictMode\n * also unmounts the content once while the menu is still open.\n */\nfunction ReleaseOnUnmount({\n release,\n isOpen,\n}: {\n release: React.Dispatch<React.SetStateAction<{ value: string | undefined } | null>>;\n isOpen: React.RefObject<boolean>;\n}) {\n React.useEffect(\n () => () => {\n if (!isOpen.current) release(null);\n },\n [release, isOpen],\n );\n return null;\n}\n"],"names":["React","TabsValueContext","jsx","DropdownMenuItem","jsxs","DropdownMenu","TabsTrigger","OVERFLOW_TAB_VALUE","DropdownMenuTrigger","ChevronDownIcon","cn","DropdownMenuContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,YAAY,oBAAI,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC;AAqB9C,MAAM,mBAAmBA,iBAAM;AAAA,EACpC,CAAC,EAAE,OAAO,GAAG,MAAA,GAAS,QAAQ;AAC5B,UAAM,YAAYA,iBAAM,WAAWC,qBAAgB;AACnD,UAAM,WAAW,UAAU,UAAU;AACrC,WACEC,2BAAAA;AAAAA,MAACC,iBAAAA;AAAAA,MAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL,gBAAc;AAAA,QACd,UAAU;AAAA,QACV,UAAU,MAAM,UAAU,OAAO,KAAK;AAAA,QACrC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AAEA,iBAAiB,cAAc;AAuBxB,MAAM,eA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ACA;AACF,GAGG;AACDF,mBAAM;AAAA,IACJ,MAAM,MAAM;AACV,UAAI,CAAC,OAAO,QAAS,SAAQ,IAAI;AAAA,IACnC;AAAA,IACA,CAAC,SAAS,MAAM;AAAA,EAAA;AAElB,SAAO;AACT;;;"}
|
|
@@ -39,9 +39,17 @@ TabsOverflow.displayName = "TabsOverflow";
|
|
|
39
39
|
const OverflowMenu = React.forwardRef(({ items, label, children, className, onKeyDown, onMouseDown, ...props }, ref) => {
|
|
40
40
|
const { value } = React.useContext(TabsValueContext);
|
|
41
41
|
const [open, setOpen] = React.useState(false);
|
|
42
|
+
const isOpen = React.useRef(false);
|
|
43
|
+
const [labelValue, setLabelValue] = React.useState(null);
|
|
42
44
|
const lastInput = React.useRef("keyboard");
|
|
43
45
|
const activeItem = items.find((item) => item.props.value === value);
|
|
44
|
-
|
|
46
|
+
const labelItem = labelValue ? items.find((item) => item.props.value === labelValue.value) : activeItem;
|
|
47
|
+
const handleOpenChange = (nextOpen) => {
|
|
48
|
+
if (nextOpen && !open) setLabelValue({ value });
|
|
49
|
+
isOpen.current = nextOpen;
|
|
50
|
+
setOpen(nextOpen);
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { open, onOpenChange: handleOpenChange, children: [
|
|
45
53
|
/* @__PURE__ */ jsx(
|
|
46
54
|
TabsTrigger,
|
|
47
55
|
{
|
|
@@ -60,12 +68,12 @@ const OverflowMenu = React.forwardRef(({ items, label, children, className, onKe
|
|
|
60
68
|
if (OPEN_KEYS.has(event.key)) {
|
|
61
69
|
lastInput.current = "keyboard";
|
|
62
70
|
event.preventDefault();
|
|
63
|
-
|
|
71
|
+
handleOpenChange(true);
|
|
64
72
|
}
|
|
65
73
|
},
|
|
66
74
|
...props,
|
|
67
75
|
children: /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
68
|
-
|
|
76
|
+
labelItem ? labelItem.props.children : label,
|
|
69
77
|
/* @__PURE__ */ jsx(
|
|
70
78
|
ChevronDownIcon,
|
|
71
79
|
{
|
|
@@ -76,7 +84,7 @@ const OverflowMenu = React.forwardRef(({ items, label, children, className, onKe
|
|
|
76
84
|
] }) })
|
|
77
85
|
}
|
|
78
86
|
),
|
|
79
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ jsxs(
|
|
80
88
|
DropdownMenuContent,
|
|
81
89
|
{
|
|
82
90
|
align: "end",
|
|
@@ -93,12 +101,27 @@ const OverflowMenu = React.forwardRef(({ items, label, children, className, onKe
|
|
|
93
101
|
onCloseAutoFocus: (event) => {
|
|
94
102
|
if (lastInput.current === "pointer") event.preventDefault();
|
|
95
103
|
},
|
|
96
|
-
children
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ jsx(ReleaseOnUnmount, { release: setLabelValue, isOpen }),
|
|
106
|
+
children
|
|
107
|
+
]
|
|
97
108
|
}
|
|
98
109
|
)
|
|
99
110
|
] });
|
|
100
111
|
});
|
|
101
112
|
OverflowMenu.displayName = "OverflowMenu";
|
|
113
|
+
function ReleaseOnUnmount({
|
|
114
|
+
release,
|
|
115
|
+
isOpen
|
|
116
|
+
}) {
|
|
117
|
+
React.useEffect(
|
|
118
|
+
() => () => {
|
|
119
|
+
if (!isOpen.current) release(null);
|
|
120
|
+
},
|
|
121
|
+
[release, isOpen]
|
|
122
|
+
);
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
102
125
|
export {
|
|
103
126
|
TabsOverflow,
|
|
104
127
|
TabsOverflowItem
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsOverflow.mjs","sources":["../../../src/components/Tabs/TabsOverflow.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { DropdownMenuItem, type DropdownMenuItemProps } from \"../DropdownMenu/DropdownMenuItem\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from \"../DropdownMenu/DropdownMenuRoot\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { OVERFLOW_TAB_VALUE, TabsValueContext } from \"./Tabs\";\nimport { TabsTrigger, type TabsTriggerProps } from \"./TabsTrigger\";\n\nconst OPEN_KEYS = new Set([\"Enter\", \" \", \"ArrowDown\"]);\n\n/** Props for the {@link TabsOverflow} component. */\nexport interface TabsOverflowProps\n extends Omit<TabsTriggerProps, \"value\" | \"children\" | \"asChild\"> {\n /** Text shown on the tab while none of its items is active, e.g. \"More\". */\n label: React.ReactNode;\n /** {@link TabsOverflowItem} elements, one per tab that doesn't fit the row. */\n children?: React.ReactNode;\n}\n\n/** Props for the {@link TabsOverflowItem} component. */\nexport type TabsOverflowItemProps = Omit<DropdownMenuItemProps, \"selected\" | \"onSelect\"> & {\n /** The tab's value, as on a {@link TabsTrigger}. */\n value: string;\n};\n\n/**\n * A tab listed in a {@link TabsOverflow} menu. The active one takes the menu's\n * selected style and is announced as the checked option.\n */\nexport const TabsOverflowItem = React.forwardRef<HTMLDivElement, TabsOverflowItemProps>(\n ({ value, ...props }, ref) => {\n const selection = React.useContext(TabsValueContext);\n const isActive = selection.value === value;\n return (\n <DropdownMenuItem\n ref={ref}\n role=\"menuitemradio\"\n aria-checked={isActive}\n selected={isActive}\n onSelect={() => selection.select(value)}\n {...props}\n />\n );\n },\n);\n\nTabsOverflowItem.displayName = \"TabsOverflowItem\";\n\n/**\n * The last tab in a {@link TabsList}, opening a menu of the tabs that don't fit\n * the row. It sits in the row's arrow-key order, opens with click, Enter, Space\n * or ArrowDown, and never selects anything itself. While one of its items is\n * active it shows that item's label and is the selected tab.\n *\n * Reads and sets the value of the surrounding {@link Tabs}, controlled or not.\n * Renders nothing when it has no items.\n *\n * @example\n * ```tsx\n * <Tabs value={tab} onValueChange={setTab}>\n * <TabsList appearance=\"pill\">\n * <TabsTrigger value=\"all\">All</TabsTrigger>\n * <TabsOverflow label=\"More\">\n * <TabsOverflowItem value=\"tips\">Tips</TabsOverflowItem>\n * </TabsOverflow>\n * </TabsList>\n * </Tabs>\n * ```\n */\nexport const TabsOverflow = React.forwardRef<HTMLButtonElement, TabsOverflowProps>(\n ({ children, ...props }, ref) => {\n const items = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<TabsOverflowItemProps> => React.isValidElement(child),\n );\n if (items.length === 0) return null;\n return (\n <OverflowMenu ref={ref} items={items} {...props}>\n {children}\n </OverflowMenu>\n );\n },\n);\n\nTabsOverflow.displayName = \"TabsOverflow\";\n\nconst OverflowMenu = React.forwardRef<\n HTMLButtonElement,\n TabsOverflowProps & { items: React.ReactElement<TabsOverflowItemProps>[] }\n>(({ items, label, children, className, onKeyDown, onMouseDown, ...props }, ref) => {\n const { value } = React.useContext(TabsValueContext);\n const [open, setOpen] = React.useState(false);\n\n const lastInput = React.useRef<\"pointer\" | \"keyboard\">(\"keyboard\");\n\n const activeItem = items.find((item) => item.props.value === value);\n\n return (\n <DropdownMenu open={open} onOpenChange={
|
|
1
|
+
{"version":3,"file":"TabsOverflow.mjs","sources":["../../../src/components/Tabs/TabsOverflow.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { DropdownMenuItem, type DropdownMenuItemProps } from \"../DropdownMenu/DropdownMenuItem\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from \"../DropdownMenu/DropdownMenuRoot\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { OVERFLOW_TAB_VALUE, TabsValueContext } from \"./Tabs\";\nimport { TabsTrigger, type TabsTriggerProps } from \"./TabsTrigger\";\n\nconst OPEN_KEYS = new Set([\"Enter\", \" \", \"ArrowDown\"]);\n\n/** Props for the {@link TabsOverflow} component. */\nexport interface TabsOverflowProps\n extends Omit<TabsTriggerProps, \"value\" | \"children\" | \"asChild\"> {\n /** Text shown on the tab while none of its items is active, e.g. \"More\". */\n label: React.ReactNode;\n /** {@link TabsOverflowItem} elements, one per tab that doesn't fit the row. */\n children?: React.ReactNode;\n}\n\n/** Props for the {@link TabsOverflowItem} component. */\nexport type TabsOverflowItemProps = Omit<DropdownMenuItemProps, \"selected\" | \"onSelect\"> & {\n /** The tab's value, as on a {@link TabsTrigger}. */\n value: string;\n};\n\n/**\n * A tab listed in a {@link TabsOverflow} menu. The active one takes the menu's\n * selected style and is announced as the checked option.\n */\nexport const TabsOverflowItem = React.forwardRef<HTMLDivElement, TabsOverflowItemProps>(\n ({ value, ...props }, ref) => {\n const selection = React.useContext(TabsValueContext);\n const isActive = selection.value === value;\n return (\n <DropdownMenuItem\n ref={ref}\n role=\"menuitemradio\"\n aria-checked={isActive}\n selected={isActive}\n onSelect={() => selection.select(value)}\n {...props}\n />\n );\n },\n);\n\nTabsOverflowItem.displayName = \"TabsOverflowItem\";\n\n/**\n * The last tab in a {@link TabsList}, opening a menu of the tabs that don't fit\n * the row. It sits in the row's arrow-key order, opens with click, Enter, Space\n * or ArrowDown, and never selects anything itself. While one of its items is\n * active it shows that item's label and is the selected tab.\n *\n * Reads and sets the value of the surrounding {@link Tabs}, controlled or not.\n * Renders nothing when it has no items.\n *\n * @example\n * ```tsx\n * <Tabs value={tab} onValueChange={setTab}>\n * <TabsList appearance=\"pill\">\n * <TabsTrigger value=\"all\">All</TabsTrigger>\n * <TabsOverflow label=\"More\">\n * <TabsOverflowItem value=\"tips\">Tips</TabsOverflowItem>\n * </TabsOverflow>\n * </TabsList>\n * </Tabs>\n * ```\n */\nexport const TabsOverflow = React.forwardRef<HTMLButtonElement, TabsOverflowProps>(\n ({ children, ...props }, ref) => {\n const items = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<TabsOverflowItemProps> => React.isValidElement(child),\n );\n if (items.length === 0) return null;\n return (\n <OverflowMenu ref={ref} items={items} {...props}>\n {children}\n </OverflowMenu>\n );\n },\n);\n\nTabsOverflow.displayName = \"TabsOverflow\";\n\nconst OverflowMenu = React.forwardRef<\n HTMLButtonElement,\n TabsOverflowProps & { items: React.ReactElement<TabsOverflowItemProps>[] }\n>(({ items, label, children, className, onKeyDown, onMouseDown, ...props }, ref) => {\n const { value } = React.useContext(TabsValueContext);\n const [open, setOpen] = React.useState(false);\n const isOpen = React.useRef(false);\n const [labelValue, setLabelValue] = React.useState<{ value: string | undefined } | null>(null);\n\n const lastInput = React.useRef<\"pointer\" | \"keyboard\">(\"keyboard\");\n\n const activeItem = items.find((item) => item.props.value === value);\n const labelItem = labelValue\n ? items.find((item) => item.props.value === labelValue.value)\n : activeItem;\n\n const handleOpenChange = (nextOpen: boolean) => {\n if (nextOpen && !open) setLabelValue({ value });\n isOpen.current = nextOpen;\n setOpen(nextOpen);\n };\n\n return (\n <DropdownMenu open={open} onOpenChange={handleOpenChange}>\n <TabsTrigger\n ref={ref}\n asChild\n value={activeItem ? activeItem.props.value : OVERFLOW_TAB_VALUE}\n {...(!activeItem && { \"aria-controls\": undefined })}\n className={className}\n onMouseDown={(event) => {\n onMouseDown?.(event);\n event.preventDefault();\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (OPEN_KEYS.has(event.key)) {\n lastInput.current = \"keyboard\";\n event.preventDefault();\n handleOpenChange(true);\n }\n }}\n {...props}\n >\n <DropdownMenuTrigger>\n <span className=\"flex items-center gap-2\">\n {labelItem ? labelItem.props.children : label}\n <ChevronDownIcon\n size={16}\n className={cn(\"motion-safe:transition-transform\", open && \"rotate-180\")}\n />\n </span>\n </DropdownMenuTrigger>\n </TabsTrigger>\n <DropdownMenuContent\n align=\"end\"\n aria-label={typeof label === \"string\" ? label : undefined}\n onPointerDownCapture={() => {\n lastInput.current = \"pointer\";\n }}\n onKeyDownCapture={() => {\n lastInput.current = \"keyboard\";\n }}\n onPointerDownOutside={() => {\n lastInput.current = \"pointer\";\n }}\n onCloseAutoFocus={(event) => {\n if (lastInput.current === \"pointer\") event.preventDefault();\n }}\n >\n <ReleaseOnUnmount release={setLabelValue} isOpen={isOpen} />\n {children}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n});\n\nOverflowMenu.displayName = \"OverflowMenu\";\n\n/**\n * Hands the trigger's label back to the live selection once the menu content\n * unmounts, which Radix delays until its exit animation has finished. Holding\n * the label until then keeps the trigger's width, so the closing menu, anchored\n * to it, doesn't shift as it fades. Only a closed menu releases it: StrictMode\n * also unmounts the content once while the menu is still open.\n */\nfunction ReleaseOnUnmount({\n release,\n isOpen,\n}: {\n release: React.Dispatch<React.SetStateAction<{ value: string | undefined } | null>>;\n isOpen: React.RefObject<boolean>;\n}) {\n React.useEffect(\n () => () => {\n if (!isOpen.current) release(null);\n },\n [release, isOpen],\n );\n return null;\n}\n"],"names":[],"mappings":";;;;;;;;;AAYA,MAAM,YAAY,oBAAI,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC;AAqB9C,MAAM,mBAAmB,MAAM;AAAA,EACpC,CAAC,EAAE,OAAO,GAAG,MAAA,GAAS,QAAQ;AAC5B,UAAM,YAAY,MAAM,WAAW,gBAAgB;AACnD,UAAM,WAAW,UAAU,UAAU;AACrC,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL,gBAAc;AAAA,QACd,UAAU;AAAA,QACV,UAAU,MAAM,UAAU,OAAO,KAAK;AAAA,QACrC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AAEA,iBAAiB,cAAc;AAuBxB,MAAM,eAAe,MAAM;AAAA,EAChC,CAAC,EAAE,UAAU,GAAG,MAAA,GAAS,QAAQ;AAC/B,UAAM,QAAQ,MAAM,SAAS,QAAQ,QAAQ,EAAE;AAAA,MAC7C,CAAC,UAA8D,MAAM,eAAe,KAAK;AAAA,IAAA;AAE3F,QAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,+BACG,cAAA,EAAa,KAAU,OAAe,GAAG,OACvC,UACH;AAAA,EAEJ;AACF;AAEA,aAAa,cAAc;AAE3B,MAAM,eAAe,MAAM,WAGzB,CAAC,EAAE,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C;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAM;AAAA,cACN,WAAW,GAAG,oCAAoC,QAAQ,YAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QACxE,EAAA,CACF,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,IAEF;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAM;AAAA,QACN,cAAY,OAAO,UAAU,WAAW,QAAQ;AAAA,QAChD,sBAAsB,MAAM;AAC1B,oBAAU,UAAU;AAAA,QACtB;AAAA,QACA,kBAAkB,MAAM;AACtB,oBAAU,UAAU;AAAA,QACtB;AAAA,QACA,sBAAsB,MAAM;AAC1B,oBAAU,UAAU;AAAA,QACtB;AAAA,QACA,kBAAkB,CAAC,UAAU;AAC3B,cAAI,UAAU,YAAY,UAAW,OAAM,eAAA;AAAA,QAC7C;AAAA,QAEA,UAAA;AAAA,UAAA,oBAAC,kBAAA,EAAiB,SAAS,eAAe,OAAA,CAAgB;AAAA,UACzD;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GACF;AAEJ,CAAC;AAED,aAAa,cAAc;AAS3B,SAAS,iBAAiB;AAAA,EACxB;AAAA,EACA;AACF,GAGG;AACD,QAAM;AAAA,IACJ,MAAM,MAAM;AACV,UAAI,CAAC,OAAO,QAAS,SAAQ,IAAI;AAAA,IACnC;AAAA,IACA,CAAC,SAAS,MAAM;AAAA,EAAA;AAElB,SAAO;AACT;"}
|
package/dist/styles/theme.css
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
--radius-full: 9999px;
|
|
34
34
|
|
|
35
35
|
--color-neutral-alphas-50: var(--primitives-color-blackalpha-50);
|
|
36
|
+
--color-neutral-alphas-75: var(--primitives-color-blackalpha-75);
|
|
36
37
|
--color-neutral-alphas-100: var(--primitives-color-blackalpha-100);
|
|
37
38
|
--color-neutral-alphas-150: #15151526;
|
|
38
39
|
--color-neutral-alphas-200: var(--primitives-color-blackalpha-200);
|
|
@@ -254,7 +255,7 @@
|
|
|
254
255
|
--color-messages-background-receiver: var(--primitives-color-gray-150);
|
|
255
256
|
--color-messages-background-sender-stroke: var(--primitives-color-green-200);
|
|
256
257
|
--color-messages-background-receiver-stroke: var(--primitives-color-gray-300);
|
|
257
|
-
--color-messages-reply-background: var(--color-neutral-alphas-
|
|
258
|
+
--color-messages-reply-background: var(--color-neutral-alphas-75);
|
|
258
259
|
--color-messages-reply-accent: var(--color-neutral-alphas-300);
|
|
259
260
|
--color-messages-read: var(--primitives-color-blue-600);
|
|
260
261
|
--color-messages-user-callout: var(--primitives-color-green-800);
|
|
@@ -458,6 +459,7 @@
|
|
|
458
459
|
--primitives-color-blue-950: #030e26ff;
|
|
459
460
|
--primitives-color-blackalpha-0: #15151500;
|
|
460
461
|
--primitives-color-blackalpha-50: #1515150d;
|
|
462
|
+
--primitives-color-blackalpha-75: #15151513;
|
|
461
463
|
--primitives-color-blackalpha-100: #1515151a;
|
|
462
464
|
--primitives-color-blackalpha-200: #15151533;
|
|
463
465
|
--primitives-color-blackalpha-300: #1515154d;
|
|
@@ -470,6 +472,7 @@
|
|
|
470
472
|
--primitives-color-blackalpha-950: #151515f2;
|
|
471
473
|
--primitives-color-whitealpha-0: #ffffff00;
|
|
472
474
|
--primitives-color-whitealpha-50: #ffffff0d;
|
|
475
|
+
--primitives-color-whitealpha-75: #ffffff13;
|
|
473
476
|
--primitives-color-whitealpha-100: #ffffff1a;
|
|
474
477
|
--primitives-color-whitealpha-200: #ffffff33;
|
|
475
478
|
--primitives-color-whitealpha-300: #ffffff4d;
|
|
@@ -507,6 +510,7 @@
|
|
|
507
510
|
/* Light-mode semantic tokens must also live in :root because @theme
|
|
508
511
|
cannot resolve var() references to :root primitives at build time. */
|
|
509
512
|
--color-neutral-alphas-50: var(--primitives-color-blackalpha-50);
|
|
513
|
+
--color-neutral-alphas-75: var(--primitives-color-blackalpha-75);
|
|
510
514
|
--color-neutral-alphas-100: var(--primitives-color-blackalpha-100);
|
|
511
515
|
--color-neutral-alphas-150: #15151526;
|
|
512
516
|
--color-neutral-alphas-200: var(--primitives-color-blackalpha-200);
|
|
@@ -728,7 +732,7 @@
|
|
|
728
732
|
--color-messages-background-receiver: var(--primitives-color-gray-150);
|
|
729
733
|
--color-messages-background-sender-stroke: var(--primitives-color-green-200);
|
|
730
734
|
--color-messages-background-receiver-stroke: var(--primitives-color-gray-300);
|
|
731
|
-
--color-messages-reply-background: var(--color-neutral-alphas-
|
|
735
|
+
--color-messages-reply-background: var(--color-neutral-alphas-75);
|
|
732
736
|
--color-messages-reply-accent: var(--color-neutral-alphas-300);
|
|
733
737
|
--color-messages-read: var(--primitives-color-blue-600);
|
|
734
738
|
--color-messages-user-callout: var(--primitives-color-green-800);
|
|
@@ -804,6 +808,7 @@
|
|
|
804
808
|
|
|
805
809
|
.dark {
|
|
806
810
|
--color-neutral-alphas-50: var(--primitives-color-whitealpha-100);
|
|
811
|
+
--color-neutral-alphas-75: var(--primitives-color-whitealpha-75);
|
|
807
812
|
--color-neutral-alphas-100: var(--primitives-color-whitealpha-100);
|
|
808
813
|
--color-neutral-alphas-150: #ffffffcc;
|
|
809
814
|
--color-neutral-alphas-200: var(--primitives-color-whitealpha-200);
|