@fanvue/ui 2.18.0 → 2.19.0
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/dist/cjs/components/Checkbox/Checkbox.cjs +19 -6
- package/dist/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs +189 -11
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
- package/dist/cjs/components/Table/Table.cjs +66 -46
- package/dist/cjs/components/Table/Table.cjs.map +1 -1
- package/dist/cjs/components/Table/TablePagination.cjs +7 -7
- package/dist/cjs/components/Table/TablePagination.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.mjs +19 -6
- package/dist/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.mjs +189 -11
- package/dist/components/DropdownMenu/DropdownMenu.mjs.map +1 -1
- package/dist/components/Table/Table.mjs +66 -46
- package/dist/components/Table/Table.mjs.map +1 -1
- package/dist/components/Table/TablePagination.mjs +7 -7
- package/dist/components/Table/TablePagination.mjs.map +1 -1
- package/dist/index.d.ts +224 -31
- package/dist/index.mjs +6 -2
- package/dist/styles/base.css +2 -0
- package/package.json +1 -1
|
@@ -5,7 +5,19 @@ import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { cn } from "../../utils/cn.mjs";
|
|
7
7
|
import { FLOATING_CONTENT_COLLISION_PADDING } from "../../utils/floatingContentCollisionPadding.mjs";
|
|
8
|
+
import { IconButton } from "../IconButton/IconButton.mjs";
|
|
9
|
+
import { CloseIcon } from "../Icons/CloseIcon.mjs";
|
|
10
|
+
import { SearchIcon } from "../Icons/SearchIcon.mjs";
|
|
8
11
|
const TAP_MOVEMENT_THRESHOLD_PX = 10;
|
|
12
|
+
const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
13
|
+
"ArrowDown",
|
|
14
|
+
"ArrowUp",
|
|
15
|
+
"ArrowLeft",
|
|
16
|
+
"ArrowRight",
|
|
17
|
+
"Escape",
|
|
18
|
+
"Tab",
|
|
19
|
+
"Enter"
|
|
20
|
+
]);
|
|
9
21
|
const ToggleOpenContext = React.createContext(null);
|
|
10
22
|
function DropdownMenu({
|
|
11
23
|
open: openProp,
|
|
@@ -91,7 +103,7 @@ const DropdownMenuContent = React.forwardRef(
|
|
|
91
103
|
sideOffset,
|
|
92
104
|
collisionPadding,
|
|
93
105
|
className: cn(
|
|
94
|
-
"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-
|
|
106
|
+
"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-neutral-alphas-200 bg-surface-primary p-1 text-content-primary shadow-lg",
|
|
95
107
|
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
96
108
|
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
97
109
|
"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2",
|
|
@@ -110,18 +122,36 @@ const DropdownMenuContent = React.forwardRef(
|
|
|
110
122
|
DropdownMenuContent.displayName = "DropdownMenuContent";
|
|
111
123
|
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
112
124
|
DropdownMenuGroup.displayName = "DropdownMenuGroup";
|
|
113
|
-
const DropdownMenuLabel = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
125
|
+
const DropdownMenuLabel = React.forwardRef(({ className, position = "default", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
114
126
|
DropdownMenuPrimitive.Label,
|
|
115
127
|
{
|
|
116
128
|
ref,
|
|
117
|
-
className: cn(
|
|
129
|
+
className: cn(
|
|
130
|
+
"typography-regular-body-sm flex items-center px-3 text-content-secondary",
|
|
131
|
+
position === "top" ? "py-2" : "pb-2 pt-4",
|
|
132
|
+
className
|
|
133
|
+
),
|
|
118
134
|
...props
|
|
119
135
|
}
|
|
120
136
|
));
|
|
121
137
|
DropdownMenuLabel.displayName = "DropdownMenuLabel";
|
|
138
|
+
const SIZE_NORMALIZED = {
|
|
139
|
+
"40": "40",
|
|
140
|
+
md: "40",
|
|
141
|
+
"32": "32",
|
|
142
|
+
sm: "32"
|
|
143
|
+
};
|
|
144
|
+
const ITEM_SIZE_CLASSES = {
|
|
145
|
+
"40": "min-h-10 py-2 typography-regular-body-lg",
|
|
146
|
+
"32": "min-h-8 py-[7px] typography-regular-body-md"
|
|
147
|
+
};
|
|
148
|
+
const ITEM_SELECTED_TYPOGRAPHY = {
|
|
149
|
+
"40": "typography-semibold-body-lg",
|
|
150
|
+
"32": "typography-semibold-body-md"
|
|
151
|
+
};
|
|
122
152
|
const DropdownMenuItem = React.forwardRef(
|
|
123
153
|
({
|
|
124
|
-
size = "
|
|
154
|
+
size = "40",
|
|
125
155
|
destructive,
|
|
126
156
|
leadingIcon,
|
|
127
157
|
trailingIcon,
|
|
@@ -131,14 +161,18 @@ const DropdownMenuItem = React.forwardRef(
|
|
|
131
161
|
asChild,
|
|
132
162
|
...props
|
|
133
163
|
}, ref) => {
|
|
164
|
+
const normalizedSize = SIZE_NORMALIZED[size];
|
|
134
165
|
const itemClassName = cn(
|
|
135
|
-
"flex w-full cursor-pointer items-center gap-
|
|
136
|
-
|
|
137
|
-
"data-[highlighted]:bg-neutral-alphas-
|
|
138
|
-
|
|
139
|
-
size === "sm" ? "typography-medium-body-sm" : "typography-medium-body-md",
|
|
166
|
+
"flex w-full cursor-pointer items-center gap-2 rounded-xs px-3 outline-none",
|
|
167
|
+
ITEM_SIZE_CLASSES[normalizedSize],
|
|
168
|
+
"data-[highlighted]:bg-neutral-alphas-50",
|
|
169
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled",
|
|
140
170
|
destructive && "text-error-content",
|
|
141
|
-
selected &&
|
|
171
|
+
selected && [
|
|
172
|
+
"bg-buttons-primary text-content-primary-inverted",
|
|
173
|
+
"data-[highlighted]:bg-buttons-primary",
|
|
174
|
+
ITEM_SELECTED_TYPOGRAPHY[normalizedSize]
|
|
175
|
+
],
|
|
142
176
|
className
|
|
143
177
|
);
|
|
144
178
|
if (asChild) {
|
|
@@ -146,7 +180,7 @@ const DropdownMenuItem = React.forwardRef(
|
|
|
146
180
|
}
|
|
147
181
|
return /* @__PURE__ */ jsxs(DropdownMenuPrimitive.Item, { ref, className: itemClassName, ...props, children: [
|
|
148
182
|
leadingIcon,
|
|
149
|
-
/* @__PURE__ */ jsx("span", { className: "flex-1", children }),
|
|
183
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children }),
|
|
150
184
|
trailingIcon
|
|
151
185
|
] });
|
|
152
186
|
}
|
|
@@ -161,12 +195,156 @@ const DropdownMenuSeparator = React.forwardRef(({ className, ...props }, ref) =>
|
|
|
161
195
|
}
|
|
162
196
|
));
|
|
163
197
|
DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
|
|
198
|
+
const DropdownMenuHeader = React.forwardRef(
|
|
199
|
+
({
|
|
200
|
+
type = "default",
|
|
201
|
+
size = "40",
|
|
202
|
+
title,
|
|
203
|
+
searchProps,
|
|
204
|
+
showClose = true,
|
|
205
|
+
onClose,
|
|
206
|
+
closeLabel = "Close menu",
|
|
207
|
+
className,
|
|
208
|
+
children,
|
|
209
|
+
...props
|
|
210
|
+
}, ref) => {
|
|
211
|
+
const titleTypography = size === "32" ? "typography-semibold-body-md" : "typography-semibold-body-lg";
|
|
212
|
+
const toggleOpen = React.useContext(ToggleOpenContext);
|
|
213
|
+
const handleClose = () => {
|
|
214
|
+
onClose?.();
|
|
215
|
+
toggleOpen?.(() => false);
|
|
216
|
+
};
|
|
217
|
+
return /* @__PURE__ */ jsxs(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
ref,
|
|
221
|
+
className: cn(
|
|
222
|
+
"flex flex-col px-1 pt-1 mb-1",
|
|
223
|
+
// Search needs an 8px gap between the input and the divider; the
|
|
224
|
+
// default (title) variant uses 4px because the title baseline sits
|
|
225
|
+
// closer to the divider naturally.
|
|
226
|
+
type === "search" ? "gap-2" : "gap-1",
|
|
227
|
+
className
|
|
228
|
+
),
|
|
229
|
+
...props,
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 pl-2", children: [
|
|
232
|
+
type === "default" ? /* @__PURE__ */ jsx("div", { className: cn("min-w-0 flex-1 truncate text-content-primary", titleTypography), children: children ?? title }) : /* @__PURE__ */ jsx(SearchInput, { ...searchProps }),
|
|
233
|
+
showClose && /* @__PURE__ */ jsx(
|
|
234
|
+
IconButton,
|
|
235
|
+
{
|
|
236
|
+
variant: "tertiary",
|
|
237
|
+
size: "32",
|
|
238
|
+
icon: /* @__PURE__ */ jsx(CloseIcon, {}),
|
|
239
|
+
onClick: handleClose,
|
|
240
|
+
"aria-label": closeLabel
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
] }),
|
|
244
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, { className: "my-0" })
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
DropdownMenuHeader.displayName = "DropdownMenuHeader";
|
|
251
|
+
function SearchInput({
|
|
252
|
+
value,
|
|
253
|
+
defaultValue,
|
|
254
|
+
onChange,
|
|
255
|
+
placeholder = "Search…",
|
|
256
|
+
"aria-label": ariaLabel = "Search"
|
|
257
|
+
} = {}) {
|
|
258
|
+
return /* @__PURE__ */ jsxs(
|
|
259
|
+
"label",
|
|
260
|
+
{
|
|
261
|
+
className: cn(
|
|
262
|
+
"flex min-w-0 flex-1 items-center gap-2 rounded-xs border border-border-primary",
|
|
263
|
+
"bg-neutral-alphas-50 px-3 py-1 text-content-primary",
|
|
264
|
+
"focus-within:shadow-focus-ring focus-within:outline-none"
|
|
265
|
+
),
|
|
266
|
+
children: [
|
|
267
|
+
/* @__PURE__ */ jsx(SearchIcon, { className: "size-4 shrink-0 text-content-tertiary", "aria-hidden": "true" }),
|
|
268
|
+
/* @__PURE__ */ jsx(
|
|
269
|
+
"input",
|
|
270
|
+
{
|
|
271
|
+
type: "search",
|
|
272
|
+
className: cn(
|
|
273
|
+
"typography-regular-body-lg min-w-0 flex-1 bg-transparent outline-none",
|
|
274
|
+
"placeholder:text-content-tertiary"
|
|
275
|
+
),
|
|
276
|
+
value,
|
|
277
|
+
defaultValue,
|
|
278
|
+
placeholder,
|
|
279
|
+
"aria-label": ariaLabel,
|
|
280
|
+
onChange: (event) => onChange?.(event.target.value),
|
|
281
|
+
onKeyDown: (event) => {
|
|
282
|
+
if (!NAVIGATION_KEYS.has(event.key)) event.stopPropagation();
|
|
283
|
+
},
|
|
284
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
285
|
+
onMouseDown: (event) => event.stopPropagation()
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
293
|
+
const DropdownMenuRadioItem = React.forwardRef(({ className, children, helper, size: _size = "40", ...props }, ref) => {
|
|
294
|
+
return /* @__PURE__ */ jsxs(
|
|
295
|
+
DropdownMenuPrimitive.RadioItem,
|
|
296
|
+
{
|
|
297
|
+
ref,
|
|
298
|
+
className: cn(
|
|
299
|
+
"group flex w-full cursor-pointer items-start gap-3 rounded-xs px-4 py-2 outline-none",
|
|
300
|
+
"data-[highlighted]:bg-neutral-alphas-50",
|
|
301
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled",
|
|
302
|
+
"data-[state=checked]:bg-buttons-primary data-[state=checked]:text-content-primary-inverted",
|
|
303
|
+
"data-[state=checked]:data-[highlighted]:bg-buttons-primary",
|
|
304
|
+
className
|
|
305
|
+
),
|
|
306
|
+
...props,
|
|
307
|
+
children: [
|
|
308
|
+
/* @__PURE__ */ jsx(
|
|
309
|
+
"span",
|
|
310
|
+
{
|
|
311
|
+
className: cn(
|
|
312
|
+
"mt-1 flex size-4 shrink-0 items-center justify-center rounded-full border border-icons-primary",
|
|
313
|
+
"group-data-[disabled]:border-content-disabled",
|
|
314
|
+
"group-data-[state=checked]:border-icons-primary-inverted"
|
|
315
|
+
),
|
|
316
|
+
"aria-hidden": "true",
|
|
317
|
+
children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "size-2 rounded-full bg-content-primary-inverted" }) })
|
|
318
|
+
}
|
|
319
|
+
),
|
|
320
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
321
|
+
/* @__PURE__ */ jsx("span", { className: "typography-semibold-body-lg truncate", children }),
|
|
322
|
+
helper && /* @__PURE__ */ jsx(
|
|
323
|
+
"span",
|
|
324
|
+
{
|
|
325
|
+
className: cn(
|
|
326
|
+
"typography-regular-body-sm text-content-secondary",
|
|
327
|
+
"group-data-[state=checked]:text-content-primary-inverted",
|
|
328
|
+
"group-data-[disabled]:text-content-disabled"
|
|
329
|
+
),
|
|
330
|
+
children: helper
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
] })
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem";
|
|
164
339
|
export {
|
|
165
340
|
DropdownMenu,
|
|
166
341
|
DropdownMenuContent,
|
|
167
342
|
DropdownMenuGroup,
|
|
343
|
+
DropdownMenuHeader,
|
|
168
344
|
DropdownMenuItem,
|
|
169
345
|
DropdownMenuLabel,
|
|
346
|
+
DropdownMenuRadioGroup,
|
|
347
|
+
DropdownMenuRadioItem,
|
|
170
348
|
DropdownMenuSeparator,
|
|
171
349
|
DropdownMenuTrigger
|
|
172
350
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.mjs","sources":["../../../src/components/DropdownMenu/DropdownMenu.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"../../utils/floatingContentCollisionPadding\";\n\n// Movement, in CSS px, above which a touch press-and-release counts as a drag.\nconst TAP_MOVEMENT_THRESHOLD_PX = 10;\n\ntype ActiveTap = {\n pointerId: number;\n x: number;\n y: number;\n movedPastThreshold: boolean;\n};\n\n// Lets DropdownMenuTrigger toggle the menu directly so it can gate on touch\n// movement — see radix-ui/primitives#1912.\nconst ToggleOpenContext = React.createContext<\n ((updater: (prev: boolean) => boolean) => void) | null\n>(null);\n\n/** Props for the {@link DropdownMenu} root component. */\nexport interface DropdownMenuProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root> {}\n\n/** Root component that manages open/close state for a dropdown menu. */\nexport function DropdownMenu({\n open: openProp,\n defaultOpen,\n onOpenChange,\n children,\n ...props\n}: DropdownMenuProps) {\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n return (\n <ToggleOpenContext.Provider value={setOpen}>\n <DropdownMenuPrimitive.Root open={open} onOpenChange={setOpen} {...props}>\n {children}\n </DropdownMenuPrimitive.Root>\n </ToggleOpenContext.Provider>\n );\n}\n\n/** Props for the {@link DropdownMenuTrigger} component. */\nexport type DropdownMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Trigger\n>;\n\n/**\n * The element that toggles the dropdown menu when clicked.\n *\n * On touch devices, the menu only opens if the press-and-release stays within\n * a small movement threshold. A drag that incidentally ends over the trigger\n * (common when scrolling a feed on Android Chrome) is ignored. Mouse and\n * keyboard interactions are unchanged.\n */\nexport const DropdownMenuTrigger = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,\n DropdownMenuTriggerProps\n>((props, ref) => {\n const toggleOpen = React.useContext(ToggleOpenContext);\n const tapRef = React.useRef<ActiveTap | null>(null);\n\n // Used outside our DropdownMenu wrapper — fall through to Radix defaults.\n if (toggleOpen === null) {\n return <DropdownMenuPrimitive.Trigger {...props} ref={ref} />;\n }\n\n return (\n <DropdownMenuPrimitive.Trigger\n {...props}\n ref={ref}\n onPointerDown={(event) => {\n props.onPointerDown?.(event);\n if (event.pointerType === \"mouse\" || props.disabled) return;\n // Keep pointerup / pointercancel on this element if the finger drifts off.\n // Optional because jsdom (used in tests) doesn't implement it.\n event.currentTarget.setPointerCapture?.(event.pointerId);\n tapRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n movedPastThreshold: false,\n };\n // preventDefault stops Radix's pointerdown open path via composeEventHandlers.\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n props.onPointerMove?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId || tap.movedPastThreshold) {\n return;\n }\n const dx = event.clientX - tap.x;\n const dy = event.clientY - tap.y;\n if (Math.hypot(dx, dy) > TAP_MOVEMENT_THRESHOLD_PX) {\n tap.movedPastThreshold = true;\n }\n }}\n onPointerUp={(event) => {\n props.onPointerUp?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId) return;\n const wasDrag = tap.movedPastThreshold;\n tapRef.current = null;\n if (!wasDrag && !props.disabled) {\n toggleOpen((prev) => !prev);\n }\n }}\n onPointerCancel={(event) => {\n props.onPointerCancel?.(event);\n const tap = tapRef.current;\n if (tap !== null && event.pointerId === tap.pointerId) {\n tapRef.current = null;\n }\n }}\n />\n );\n});\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\";\n\n/** Props for the {@link DropdownMenuContent} component. */\nexport interface DropdownMenuContentProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {}\n\n/**\n * The positioned content panel rendered inside a portal.\n *\n * Override the portal z-index per-instance via `style={{ zIndex: 1500 }}` or\n * globally with the `--fanvue-ui-portal-z-index` CSS custom property.\n *\n * @example\n * ```tsx\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild>\n * <Button>Open</Button>\n * </DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Option 1</DropdownMenuItem>\n * <DropdownMenuItem>Option 2</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n * ```\n */\nexport const DropdownMenuContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Content>,\n DropdownMenuContentProps\n>(\n (\n {\n className,\n style,\n sideOffset = 4,\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n ...props\n },\n ref,\n ) => (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\n \"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-xs border border-neutral-alphas-200 bg-bg-primary p-1 shadow-lg\",\n \"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95\",\n \"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95\",\n \"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2\",\n \"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2\",\n className,\n )}\n style={{\n zIndex: \"var(--fanvue-ui-portal-z-index, 50)\",\n maxHeight: \"var(--radix-dropdown-menu-content-available-height)\",\n ...style,\n }}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n ),\n);\nDropdownMenuContent.displayName = \"DropdownMenuContent\";\n\n/** Props for the {@link DropdownMenuGroup} component. */\nexport type DropdownMenuGroupProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Group\n>;\n\n/** Groups related menu items. Accepts an optional `DropdownMenuLabel`. */\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\";\n\n/** Props for the {@link DropdownMenuLabel} component. */\nexport interface DropdownMenuLabelProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> {}\n\n/** A label for a group of items. Not focusable or selectable. */\nexport const DropdownMenuLabel = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Label>,\n DropdownMenuLabelProps\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\"typography-medium-body-xs px-2 py-1.5 text-content-secondary\", className)}\n {...props}\n />\n));\nDropdownMenuLabel.displayName = \"DropdownMenuLabel\";\n\n/** Available sizes for a dropdown menu item. */\nexport type DropdownMenuItemSize = \"sm\" | \"md\";\n\nexport interface DropdownMenuItemProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> {\n /** Height of the menu item row. @default \"sm\" */\n size?: DropdownMenuItemSize;\n /** Whether the item uses destructive (error) styling. */\n destructive?: boolean;\n /** Icon rendered before the label. */\n leadingIcon?: React.ReactNode;\n /** Icon rendered after the label. */\n trailingIcon?: React.ReactNode;\n /** Whether the item is in a selected state. */\n selected?: boolean;\n}\n\n/**\n * An individual item within a {@link DropdownMenuContent}.\n *\n * @example\n * ```tsx\n * <DropdownMenuItem>Edit profile</DropdownMenuItem>\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * <DropdownMenuItem leadingIcon={<EditIcon />}>Edit</DropdownMenuItem>\n *\n * // As a link\n * <DropdownMenuItem asChild>\n * <a href=\"/settings\">Settings</a>\n * </DropdownMenuItem>\n * ```\n */\nexport const DropdownMenuItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Item>,\n DropdownMenuItemProps\n>(\n (\n {\n size = \"sm\",\n destructive,\n leadingIcon,\n trailingIcon,\n selected,\n className,\n children,\n asChild,\n ...props\n },\n ref,\n ) => {\n const itemClassName = cn(\n \"flex w-full cursor-pointer items-center gap-1 rounded px-2 outline-none\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n \"data-[highlighted]:bg-neutral-alphas-100\",\n size === \"sm\" ? \"min-h-[34px] py-1\" : \"min-h-[40px] py-1.5\",\n size === \"sm\" ? \"typography-medium-body-sm\" : \"typography-medium-body-md\",\n destructive && \"text-error-content\",\n selected && \"bg-success-surface\",\n className,\n );\n\n if (asChild) {\n return (\n <DropdownMenuPrimitive.Item ref={ref} asChild className={itemClassName} {...props}>\n {children}\n </DropdownMenuPrimitive.Item>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Item ref={ref} className={itemClassName} {...props}>\n {leadingIcon}\n <span className=\"flex-1\">{children}</span>\n {trailingIcon}\n </DropdownMenuPrimitive.Item>\n );\n },\n);\nDropdownMenuItem.displayName = \"DropdownMenuItem\";\n\n/** Props for the {@link DropdownMenuSeparator} component. */\nexport interface DropdownMenuSeparatorProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> {}\n\n/** Visual separator between groups of items. */\nexport const DropdownMenuSeparator = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n DropdownMenuSeparatorProps\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn(\"my-1 h-px bg-neutral-alphas-200\", className)}\n {...props}\n />\n));\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\";\n"],"names":[],"mappings":";;;;;;;AAOA,MAAM,4BAA4B;AAWlC,MAAM,oBAAoB,MAAM,cAE9B,IAAI;AAOC,SAAS,aAAa;AAAA,EAC3B,MAAM;A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F,GAAG;AAAA,EAAA;AACN,CACD;AACD,kBAAkB,cAAc;AAkCzB,MAAM,mBAAmB,MAAM;AAAA,EAIpC,CACE;AAAA,IACE,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,gBAAgB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,OAAO,sBAAsB;AAAA,MACtC,SAAS,OAAO,8BAA8B;AAAA,MAC9C,eAAe;AAAA,MACf,YAAY;AAAA,MACZ;AAAA,IAAA;AAGF,QAAI,SAAS;AACX,aACE,oBAAC,sBAAsB,MAAtB,EAA2B,KAAU,SAAO,MAAC,WAAW,eAAgB,GAAG,OACzE,SAAA,CACH;AAAA,IAEJ;AAEA,WACE,qBAAC,sBAAsB,MAAtB,EAA2B,KAAU,WAAW,eAAgB,GAAG,OACjE,UAAA;AAAA,MAAA;AAAA,MACD,oBAAC,QAAA,EAAK,WAAU,UAAU,SAAA,CAAS;AAAA,MAClC;AAAA,IAAA,GACH;AAAA,EAEJ;AACF;AACA,iBAAiB,cAAc;AAOxB,MAAM,wBAAwB,MAAM,WAGzC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1B;AAAA,EAAC,sBAAsB;AAAA,EAAtB;AAAA,IACC;AAAA,IACA,WAAW,GAAG,mCAAmC,SAAS;AAAA,IACzD,GAAG;AAAA,EAAA;AACN,CACD;AACD,sBAAsB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"DropdownMenu.mjs","sources":["../../../src/components/DropdownMenu/DropdownMenu.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"../../utils/floatingContentCollisionPadding\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { SearchIcon } from \"../Icons/SearchIcon\";\n\n// Movement, in CSS px, above which a touch press-and-release counts as a drag.\nconst TAP_MOVEMENT_THRESHOLD_PX = 10;\n\n// Keys that the menu must keep handling even when focus is inside a child\n// input — arrows move the highlight into the list, Tab leaves the menu, and\n// Enter / Escape close it.\nconst NAVIGATION_KEYS = new Set([\n \"ArrowDown\",\n \"ArrowUp\",\n \"ArrowLeft\",\n \"ArrowRight\",\n \"Escape\",\n \"Tab\",\n \"Enter\",\n]);\n\ntype ActiveTap = {\n pointerId: number;\n x: number;\n y: number;\n movedPastThreshold: boolean;\n};\n\n// Lets DropdownMenuTrigger toggle the menu directly so it can gate on touch\n// movement — see radix-ui/primitives#1912.\nconst ToggleOpenContext = React.createContext<\n ((updater: (prev: boolean) => boolean) => void) | null\n>(null);\n\n/** Props for the {@link DropdownMenu} root component. */\nexport interface DropdownMenuProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root> {}\n\n/** Root component that manages open/close state for a dropdown menu. */\nexport function DropdownMenu({\n open: openProp,\n defaultOpen,\n onOpenChange,\n children,\n ...props\n}: DropdownMenuProps) {\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n return (\n <ToggleOpenContext.Provider value={setOpen}>\n <DropdownMenuPrimitive.Root open={open} onOpenChange={setOpen} {...props}>\n {children}\n </DropdownMenuPrimitive.Root>\n </ToggleOpenContext.Provider>\n );\n}\n\n/** Props for the {@link DropdownMenuTrigger} component. */\nexport type DropdownMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Trigger\n>;\n\n/**\n * The element that toggles the dropdown menu when clicked.\n *\n * On touch devices, the menu only opens if the press-and-release stays within\n * a small movement threshold. A drag that incidentally ends over the trigger\n * (common when scrolling a feed on Android Chrome) is ignored. Mouse and\n * keyboard interactions are unchanged.\n */\nexport const DropdownMenuTrigger = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,\n DropdownMenuTriggerProps\n>((props, ref) => {\n const toggleOpen = React.useContext(ToggleOpenContext);\n const tapRef = React.useRef<ActiveTap | null>(null);\n\n // Used outside our DropdownMenu wrapper — fall through to Radix defaults.\n if (toggleOpen === null) {\n return <DropdownMenuPrimitive.Trigger {...props} ref={ref} />;\n }\n\n return (\n <DropdownMenuPrimitive.Trigger\n {...props}\n ref={ref}\n onPointerDown={(event) => {\n props.onPointerDown?.(event);\n if (event.pointerType === \"mouse\" || props.disabled) return;\n // Keep pointerup / pointercancel on this element if the finger drifts off.\n // Optional because jsdom (used in tests) doesn't implement it.\n event.currentTarget.setPointerCapture?.(event.pointerId);\n tapRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n movedPastThreshold: false,\n };\n // preventDefault stops Radix's pointerdown open path via composeEventHandlers.\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n props.onPointerMove?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId || tap.movedPastThreshold) {\n return;\n }\n const dx = event.clientX - tap.x;\n const dy = event.clientY - tap.y;\n if (Math.hypot(dx, dy) > TAP_MOVEMENT_THRESHOLD_PX) {\n tap.movedPastThreshold = true;\n }\n }}\n onPointerUp={(event) => {\n props.onPointerUp?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId) return;\n const wasDrag = tap.movedPastThreshold;\n tapRef.current = null;\n if (!wasDrag && !props.disabled) {\n toggleOpen((prev) => !prev);\n }\n }}\n onPointerCancel={(event) => {\n props.onPointerCancel?.(event);\n const tap = tapRef.current;\n if (tap !== null && event.pointerId === tap.pointerId) {\n tapRef.current = null;\n }\n }}\n />\n );\n});\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\";\n\n/** Props for the {@link DropdownMenuContent} component. */\nexport interface DropdownMenuContentProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {}\n\n/**\n * The positioned content panel rendered inside a portal.\n *\n * Override the portal z-index per-instance via `style={{ zIndex: 1500 }}` or\n * globally with the `--fanvue-ui-portal-z-index` CSS custom property.\n *\n * @example\n * ```tsx\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild>\n * <Button>Open</Button>\n * </DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Option 1</DropdownMenuItem>\n * <DropdownMenuItem>Option 2</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n * ```\n */\nexport const DropdownMenuContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Content>,\n DropdownMenuContentProps\n>(\n (\n {\n className,\n style,\n sideOffset = 4,\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n ...props\n },\n ref,\n ) => (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\n \"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-neutral-alphas-200 bg-surface-primary p-1 text-content-primary shadow-lg\",\n \"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95\",\n \"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95\",\n \"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2\",\n \"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2\",\n className,\n )}\n style={{\n zIndex: \"var(--fanvue-ui-portal-z-index, 50)\",\n maxHeight: \"var(--radix-dropdown-menu-content-available-height)\",\n ...style,\n }}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n ),\n);\nDropdownMenuContent.displayName = \"DropdownMenuContent\";\n\n/** Props for the {@link DropdownMenuGroup} component. */\nexport type DropdownMenuGroupProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Group\n>;\n\n/** Groups related menu items. Accepts an optional `DropdownMenuLabel`. */\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\";\n\n/** Vertical placement of a {@link DropdownMenuLabel} within its group. */\nexport type DropdownMenuLabelPosition = \"default\" | \"top\";\n\n/** Props for the {@link DropdownMenuLabel} component. */\nexport interface DropdownMenuLabelProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> {\n /**\n * Vertical placement within the surrounding group. `\"top\"` is used for the\n * first label directly under a header; `\"default\"` adds extra top padding to\n * separate it from preceding items. @default \"default\"\n */\n position?: DropdownMenuLabelPosition;\n}\n\n/** A non-interactive label that groups related items within a menu. */\nexport const DropdownMenuLabel = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Label>,\n DropdownMenuLabelProps\n>(({ className, position = \"default\", ...props }, ref) => (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\n \"typography-regular-body-sm flex items-center px-3 text-content-secondary\",\n position === \"top\" ? \"py-2\" : \"pb-2 pt-4\",\n className,\n )}\n {...props}\n />\n));\nDropdownMenuLabel.displayName = \"DropdownMenuLabel\";\n\n/**\n * Height preset for a dropdown menu item.\n *\n * `\"40\"` (default) and `\"32\"` are the v2 numeric tokens that mirror the Figma\n * design system. `\"sm\"` and `\"md\"` are deprecated aliases retained for\n * backwards compatibility — `\"sm\"` maps to `\"32\"`, `\"md\"` maps to `\"40\"`.\n */\nexport type DropdownMenuItemSize =\n | \"40\"\n | \"32\"\n /** @deprecated Use `\"32\"` instead. */\n | \"sm\"\n /** @deprecated Use `\"40\"` instead. */\n | \"md\";\n\nconst SIZE_NORMALIZED: Record<DropdownMenuItemSize, \"40\" | \"32\"> = {\n \"40\": \"40\",\n md: \"40\",\n \"32\": \"32\",\n sm: \"32\",\n};\n\nconst ITEM_SIZE_CLASSES: Record<\"40\" | \"32\", string> = {\n \"40\": \"min-h-10 py-2 typography-regular-body-lg\",\n \"32\": \"min-h-8 py-[7px] typography-regular-body-md\",\n};\n\nconst ITEM_SELECTED_TYPOGRAPHY: Record<\"40\" | \"32\", string> = {\n \"40\": \"typography-semibold-body-lg\",\n \"32\": \"typography-semibold-body-md\",\n};\n\nexport interface DropdownMenuItemProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> {\n /** Height of the menu item row. @default \"40\" */\n size?: DropdownMenuItemSize;\n /** Applies the destructive (error) treatment. Use for irreversible actions. @default false */\n destructive?: boolean;\n /** Icon (or other node) rendered before the label. */\n leadingIcon?: React.ReactNode;\n /** Icon (or other node) rendered after the label. */\n trailingIcon?: React.ReactNode;\n /** Marks the item as the current selection in a single-select menu. @default false */\n selected?: boolean;\n}\n\n/**\n * An individual item within a {@link DropdownMenuContent}.\n *\n * @example\n * ```tsx\n * <DropdownMenuItem>Edit profile</DropdownMenuItem>\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * <DropdownMenuItem leadingIcon={<EditIcon />}>Edit</DropdownMenuItem>\n *\n * // As a link\n * <DropdownMenuItem asChild>\n * <a href=\"/settings\">Settings</a>\n * </DropdownMenuItem>\n * ```\n */\nexport const DropdownMenuItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Item>,\n DropdownMenuItemProps\n>(\n (\n {\n size = \"40\",\n destructive,\n leadingIcon,\n trailingIcon,\n selected,\n className,\n children,\n asChild,\n ...props\n },\n ref,\n ) => {\n const normalizedSize = SIZE_NORMALIZED[size];\n const itemClassName = cn(\n \"flex w-full cursor-pointer items-center gap-2 rounded-xs px-3 outline-none\",\n ITEM_SIZE_CLASSES[normalizedSize],\n \"data-[highlighted]:bg-neutral-alphas-50\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled\",\n destructive && \"text-error-content\",\n selected && [\n \"bg-buttons-primary text-content-primary-inverted\",\n \"data-[highlighted]:bg-buttons-primary\",\n ITEM_SELECTED_TYPOGRAPHY[normalizedSize],\n ],\n className,\n );\n\n if (asChild) {\n return (\n <DropdownMenuPrimitive.Item ref={ref} asChild className={itemClassName} {...props}>\n {children}\n </DropdownMenuPrimitive.Item>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Item ref={ref} className={itemClassName} {...props}>\n {leadingIcon}\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n {trailingIcon}\n </DropdownMenuPrimitive.Item>\n );\n },\n);\nDropdownMenuItem.displayName = \"DropdownMenuItem\";\n\n/** Props for the {@link DropdownMenuSeparator} component. */\nexport interface DropdownMenuSeparatorProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> {}\n\n/** Visual separator between groups of items. */\nexport const DropdownMenuSeparator = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n DropdownMenuSeparatorProps\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn(\"my-1 h-px bg-neutral-alphas-200\", className)}\n {...props}\n />\n));\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\";\n\n/** Header type. `\"default\"` shows a title; `\"search\"` shows a search input. */\nexport type DropdownMenuHeaderType = \"default\" | \"search\";\n\n/** Header height preset. Matches the menu item sizing scale. */\nexport type DropdownMenuHeaderSize = \"40\" | \"32\";\n\n/** Search-input configuration for {@link DropdownMenuHeader} when `type=\"search\"`. */\nexport interface DropdownMenuHeaderSearchProps {\n /** Controlled value of the search input. */\n value?: string;\n /** Uncontrolled default value. */\n defaultValue?: string;\n /** Fires when the input value changes. */\n onChange?: (value: string) => void;\n /** Placeholder text shown when the input is empty. @default \"Search…\" */\n placeholder?: string;\n /** Accessible label for the search input. @default \"Search\" */\n \"aria-label\"?: string;\n}\n\nexport interface DropdownMenuHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Visual type. `\"default\"` shows a title; `\"search\"` shows a search input. @default \"default\" */\n type?: DropdownMenuHeaderType;\n /** Height preset for the header row. @default \"40\" */\n size?: DropdownMenuHeaderSize;\n /** Title text shown when `type=\"default\"`. Ignored if `children` is provided. */\n title?: string;\n /** Configuration for the embedded search input when `type=\"search\"`. */\n searchProps?: DropdownMenuHeaderSearchProps;\n /** Whether to render the close icon button on the right. @default true */\n showClose?: boolean;\n /** Fires when the close icon button is activated. */\n onClose?: () => void;\n /** Accessible label for the close button. @default \"Close menu\" */\n closeLabel?: string;\n}\n\n/**\n * Optional header rendered at the top of a {@link DropdownMenuContent}. Use\n * `type=\"default\"` to title the menu, or `type=\"search\"` to embed a search\n * input for filtering long lists.\n *\n * Renders an inset separator beneath the row so it slots cleanly above the\n * first group of items.\n *\n * @example\n * ```tsx\n * <DropdownMenuContent>\n * <DropdownMenuHeader title=\"Sort by\" onClose={() => setOpen(false)} />\n * <DropdownMenuItem>Newest</DropdownMenuItem>\n * <DropdownMenuItem>Oldest</DropdownMenuItem>\n * </DropdownMenuContent>\n * ```\n */\nexport const DropdownMenuHeader = React.forwardRef<HTMLDivElement, DropdownMenuHeaderProps>(\n (\n {\n type = \"default\",\n size = \"40\",\n title,\n searchProps,\n showClose = true,\n onClose,\n closeLabel = \"Close menu\",\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const titleTypography =\n size === \"32\" ? \"typography-semibold-body-md\" : \"typography-semibold-body-lg\";\n const toggleOpen = React.useContext(ToggleOpenContext);\n\n const handleClose = () => {\n onClose?.();\n // Also dismiss the Radix menu when used in uncontrolled mode — otherwise\n // the close button would look broken to consumers that don't wire up\n // `open` / `onOpenChange` themselves.\n toggleOpen?.(() => false);\n };\n\n return (\n <div\n ref={ref}\n className={cn(\n \"flex flex-col px-1 pt-1 mb-1\",\n // Search needs an 8px gap between the input and the divider; the\n // default (title) variant uses 4px because the title baseline sits\n // closer to the divider naturally.\n type === \"search\" ? \"gap-2\" : \"gap-1\",\n className,\n )}\n {...props}\n >\n <div className=\"flex items-center gap-4 pl-2\">\n {type === \"default\" ? (\n <div className={cn(\"min-w-0 flex-1 truncate text-content-primary\", titleTypography)}>\n {children ?? title}\n </div>\n ) : (\n <SearchInput {...searchProps} />\n )}\n {showClose && (\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<CloseIcon />}\n onClick={handleClose}\n aria-label={closeLabel}\n />\n )}\n </div>\n <DropdownMenuSeparator className=\"my-0\" />\n </div>\n );\n },\n);\nDropdownMenuHeader.displayName = \"DropdownMenuHeader\";\n\nfunction SearchInput({\n value,\n defaultValue,\n onChange,\n placeholder = \"Search\\u2026\",\n \"aria-label\": ariaLabel = \"Search\",\n}: DropdownMenuHeaderSearchProps = {}) {\n return (\n <label\n className={cn(\n \"flex min-w-0 flex-1 items-center gap-2 rounded-xs border border-border-primary\",\n \"bg-neutral-alphas-50 px-3 py-1 text-content-primary\",\n \"focus-within:shadow-focus-ring focus-within:outline-none\",\n )}\n >\n <SearchIcon className=\"size-4 shrink-0 text-content-tertiary\" aria-hidden=\"true\" />\n <input\n type=\"search\"\n className={cn(\n \"typography-regular-body-lg min-w-0 flex-1 bg-transparent outline-none\",\n \"placeholder:text-content-tertiary\",\n )}\n value={value}\n defaultValue={defaultValue}\n placeholder={placeholder}\n aria-label={ariaLabel}\n onChange={(event) => onChange?.(event.target.value)}\n // Radix DropdownMenu listens for keystrokes on Content for its\n // typeahead (typing letters jumps focus to a matching item). That\n // listener steals focus from the input after the first letter, so we\n // stop character keys from bubbling. Navigation keys (arrows / Tab /\n // Escape / Enter) are still allowed through so the user can leave the\n // input for the list or close the menu. Pointer events are stopped so\n // clicking back into the input doesn't fight the menu's focus\n // management either.\n onKeyDown={(event) => {\n if (!NAVIGATION_KEYS.has(event.key)) event.stopPropagation();\n }}\n onPointerDown={(event) => event.stopPropagation()}\n onMouseDown={(event) => event.stopPropagation()}\n />\n </label>\n );\n}\n\n/** Props for the {@link DropdownMenuRadioGroup} component. */\nexport interface DropdownMenuRadioGroupProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioGroup> {}\n\n/**\n * Groups {@link DropdownMenuRadioItem} children so they behave as a\n * single-select set. Controlled via `value`/`onValueChange`.\n *\n * @example\n * ```tsx\n * <DropdownMenuRadioGroup value={sort} onValueChange={setSort}>\n * <DropdownMenuRadioItem value=\"newest\">Newest first</DropdownMenuRadioItem>\n * <DropdownMenuRadioItem value=\"oldest\">Oldest first</DropdownMenuRadioItem>\n * </DropdownMenuRadioGroup>\n * ```\n */\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\n/** Height preset for a {@link DropdownMenuRadioItem}. */\nexport type DropdownMenuRadioItemSize = \"40\";\n\nexport interface DropdownMenuRadioItemProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem> {\n /** Optional secondary text shown below the title. */\n helper?: string;\n /** Height of the item row. @default \"40\" */\n size?: DropdownMenuRadioItemSize;\n}\n\n/**\n * A single radio-style choice within a {@link DropdownMenuRadioGroup}. Shows\n * a circular indicator that fills when selected, plus an optional helper line\n * underneath the title.\n */\nexport const DropdownMenuRadioItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,\n DropdownMenuRadioItemProps\n>(({ className, children, helper, size: _size = \"40\", ...props }, ref) => {\n return (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(\n \"group flex w-full cursor-pointer items-start gap-3 rounded-xs px-4 py-2 outline-none\",\n \"data-[highlighted]:bg-neutral-alphas-50\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled\",\n \"data-[state=checked]:bg-buttons-primary data-[state=checked]:text-content-primary-inverted\",\n \"data-[state=checked]:data-[highlighted]:bg-buttons-primary\",\n className,\n )}\n {...props}\n >\n <span\n className={cn(\n \"mt-1 flex size-4 shrink-0 items-center justify-center rounded-full border border-icons-primary\",\n \"group-data-[disabled]:border-content-disabled\",\n \"group-data-[state=checked]:border-icons-primary-inverted\",\n )}\n aria-hidden=\"true\"\n >\n <DropdownMenuPrimitive.ItemIndicator asChild>\n <span className=\"size-2 rounded-full bg-content-primary-inverted\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <span className=\"typography-semibold-body-lg truncate\">{children}</span>\n {helper && (\n <span\n className={cn(\n \"typography-regular-body-sm text-content-secondary\",\n \"group-data-[state=checked]:text-content-primary-inverted\",\n \"group-data-[disabled]:text-content-disabled\",\n )}\n >\n {helper}\n </span>\n )}\n </span>\n </DropdownMenuPrimitive.RadioItem>\n );\n});\nDropdownMenuRadioItem.displayName = \"DropdownMenuRadioItem\";\n"],"names":[],"mappings":";;;;;;;;;;AAUA,MAAM,4BAA4B;AAKlC,MAAM,sCAAsB,IAAI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAWD,MAAM,oBAAoB,MAAM,cAE9B,IAAI;AAOC,SAAS,aAAa;AAAA,EAC3B,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,CAAC,OAAO,OAAO,OAAO,IAAI,qBAAqB;AAAA,IACnD,MAAM;AAAA,IACN,aAAa,eAAe;AAAA,IAC5B,UAAU;AAAA,EAAA,CACX;AAED,6BACG,kBAAkB,UAAlB,EAA2B,OAAO,SACjC,UAAA,oBAAC,sBAAsB,MAAtB,EAA2B,MAAY,cAAc,SAAU,GAAG,OAChE,UACH,GACF;AAEJ;AAeO,MAAM,sBAAsB,MAAM,WAGvC,CAAC,OAAO,QAAQ;AAChB,QAAM,aAAa,MAAM,WAAW,iBAAiB;AACrD,QAAM,SAAS,MAAM,OAAyB,IAAI;AAGlD,MAAI,eAAe,MAAM;AACvB,+BAAQ,sBAAsB,SAAtB,EAA+B,GAAG,OAAO,KAAU;AAAA,EAC7D;AAEA,SACE;AAAA,IAAC,sBAAsB;AAAA,IAAtB;AAAA,MACE,GAAG;AA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;AAGN;AAkBO,MAAM,yBAAyB,sBAAsB;AAkBrD,MAAM,wBAAwB,MAAM,WAGzC,CAAC,EAAE,WAAW,UAAU,QAAQ,MAAM,QAAQ,MAAM,GAAG,MAAA,GAAS,QAAQ;AACxE,SACE;AAAA,IAAC,sBAAsB;AAAA,IAAtB;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA;AAAA,cACA;AAAA,YAAA;AAAA,YAEF,eAAY;AAAA,YAEZ,UAAA,oBAAC,sBAAsB,eAAtB,EAAoC,SAAO,MAC1C,UAAA,oBAAC,QAAA,EAAK,WAAU,kDAAA,CAAkD,EAAA,CACpE;AAAA,UAAA;AAAA,QAAA;AAAA,QAEF,qBAAC,QAAA,EAAK,WAAU,sCACd,UAAA;AAAA,UAAA,oBAAC,QAAA,EAAK,WAAU,wCAAwC,SAAA,CAAS;AAAA,UAChE,UACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA;AAAA,gBACA;AAAA,cAAA;AAAA,cAGD,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;AACD,sBAAsB,cAAc;"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../../utils/cn.mjs";
|
|
5
|
+
import { ArrowDownIcon } from "../Icons/ArrowDownIcon.mjs";
|
|
6
|
+
import { ArrowUpIcon } from "../Icons/ArrowUpIcon.mjs";
|
|
5
7
|
import { Select, SelectContent, SelectItem } from "../Select/Select.mjs";
|
|
6
8
|
const TableSizeContext = React.createContext("md");
|
|
7
9
|
function useTableSize() {
|
|
@@ -14,7 +16,7 @@ const TableCard = React.forwardRef(
|
|
|
14
16
|
{
|
|
15
17
|
ref,
|
|
16
18
|
className: cn(
|
|
17
|
-
"isolate flex flex-col gap-
|
|
19
|
+
"isolate flex flex-col gap-2 overflow-hidden rounded-3xl border border-border-strong px-3 py-1",
|
|
18
20
|
className
|
|
19
21
|
),
|
|
20
22
|
...props
|
|
@@ -29,10 +31,7 @@ const TableToolbar = React.forwardRef(
|
|
|
29
31
|
"div",
|
|
30
32
|
{
|
|
31
33
|
ref,
|
|
32
|
-
className: cn(
|
|
33
|
-
"flex flex-wrap items-center gap-4 rounded-t-md bg-bg-primary px-6",
|
|
34
|
-
className
|
|
35
|
-
),
|
|
34
|
+
className: cn("flex flex-wrap items-center gap-4 px-4 py-3", className),
|
|
36
35
|
...props
|
|
37
36
|
}
|
|
38
37
|
);
|
|
@@ -40,16 +39,12 @@ const TableToolbar = React.forwardRef(
|
|
|
40
39
|
);
|
|
41
40
|
TableToolbar.displayName = "TableToolbar";
|
|
42
41
|
const TableScrollArea = React.forwardRef(
|
|
43
|
-
({ className, roundTop
|
|
42
|
+
({ className, children, roundTop: _roundTop, ...props }, ref) => {
|
|
44
43
|
return /* @__PURE__ */ jsx(
|
|
45
44
|
"div",
|
|
46
45
|
{
|
|
47
46
|
ref,
|
|
48
|
-
className: cn(
|
|
49
|
-
"relative w-full min-w-0 overflow-hidden",
|
|
50
|
-
roundTop && "rounded-t-md",
|
|
51
|
-
className
|
|
52
|
-
),
|
|
47
|
+
className: cn("relative w-full min-w-0 overflow-hidden", className),
|
|
53
48
|
...props,
|
|
54
49
|
children: /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children })
|
|
55
50
|
}
|
|
@@ -75,23 +70,13 @@ const Table = React.forwardRef(
|
|
|
75
70
|
Table.displayName = "Table";
|
|
76
71
|
const TableHeader = React.forwardRef(
|
|
77
72
|
({ className, ...props }, ref) => {
|
|
78
|
-
return /* @__PURE__ */ jsx(
|
|
79
|
-
"thead",
|
|
80
|
-
{
|
|
81
|
-
ref,
|
|
82
|
-
className: cn(
|
|
83
|
-
"[&_tr:first-child_th:first-child]:rounded-tl-md [&_tr:first-child_th:last-child]:rounded-tr-md",
|
|
84
|
-
className
|
|
85
|
-
),
|
|
86
|
-
...props
|
|
87
|
-
}
|
|
88
|
-
);
|
|
73
|
+
return /* @__PURE__ */ jsx("thead", { ref, className: cn(className), ...props });
|
|
89
74
|
}
|
|
90
75
|
);
|
|
91
76
|
TableHeader.displayName = "TableHeader";
|
|
92
77
|
const TableBody = React.forwardRef(
|
|
93
78
|
({ className, ...props }, ref) => {
|
|
94
|
-
return /* @__PURE__ */ jsx("tbody", { ref, className: cn(className), ...props });
|
|
79
|
+
return /* @__PURE__ */ jsx("tbody", { ref, className: cn("[&_tr:last-child_td]:border-b-0", className), ...props });
|
|
95
80
|
}
|
|
96
81
|
);
|
|
97
82
|
TableBody.displayName = "TableBody";
|
|
@@ -109,7 +94,7 @@ const TableRow = React.forwardRef(
|
|
|
109
94
|
TableRow.displayName = "TableRow";
|
|
110
95
|
const HEAD_INTENT_CLASSES = {
|
|
111
96
|
default: "text-left",
|
|
112
|
-
checkbox: "w-
|
|
97
|
+
checkbox: "w-12 min-w-12 max-w-12 text-center",
|
|
113
98
|
sort: "text-right",
|
|
114
99
|
leading: "min-w-0 w-2/5 text-left"
|
|
115
100
|
};
|
|
@@ -121,7 +106,7 @@ const TableHead = React.forwardRef(
|
|
|
121
106
|
ref,
|
|
122
107
|
scope,
|
|
123
108
|
className: cn(
|
|
124
|
-
"typography-semibold-body-sm box-border
|
|
109
|
+
"typography-semibold-body-sm box-border min-h-12 border-b border-border-primary px-4 py-3 align-middle text-content-tertiary",
|
|
125
110
|
HEAD_INTENT_CLASSES[intent],
|
|
126
111
|
className
|
|
127
112
|
),
|
|
@@ -132,17 +117,18 @@ const TableHead = React.forwardRef(
|
|
|
132
117
|
);
|
|
133
118
|
TableHead.displayName = "TableHead";
|
|
134
119
|
const CELL_MIN_HEIGHT = {
|
|
135
|
-
md: "min-h-
|
|
136
|
-
|
|
120
|
+
md: "h-16 min-h-16",
|
|
121
|
+
default: "h-16 min-h-16",
|
|
122
|
+
lg: "h-20 min-h-20"
|
|
137
123
|
};
|
|
138
124
|
const CELL_VARIANT_CLASSES = {
|
|
139
|
-
default: "border-border-
|
|
140
|
-
chip: "border-border-
|
|
141
|
-
pillProgress: "border-border-
|
|
125
|
+
default: "border-b border-border-primary px-4 py-3",
|
|
126
|
+
chip: "border-b border-border-primary px-4 py-3",
|
|
127
|
+
pillProgress: "border-b border-border-primary px-4 py-3"
|
|
142
128
|
};
|
|
143
129
|
const CELL_INTENT_CLASSES = {
|
|
144
130
|
default: "",
|
|
145
|
-
checkbox: "text-center",
|
|
131
|
+
checkbox: "w-12 min-w-12 max-w-12 text-center",
|
|
146
132
|
stacked: "align-top",
|
|
147
133
|
multiline: "max-w-[240px]",
|
|
148
134
|
sideLabel: ""
|
|
@@ -150,7 +136,7 @@ const CELL_INTENT_CLASSES = {
|
|
|
150
136
|
const TableCell = React.forwardRef(
|
|
151
137
|
({ className, cellVariant = "default", intent = "default", ...props }, ref) => {
|
|
152
138
|
const size = useTableSize();
|
|
153
|
-
const typo = intent === "sideLabel" ? "typography-semibold-body-
|
|
139
|
+
const typo = intent === "sideLabel" ? "typography-semibold-body-sm" : "typography-regular-body-sm";
|
|
154
140
|
return /* @__PURE__ */ jsx(
|
|
155
141
|
"td",
|
|
156
142
|
{
|
|
@@ -171,14 +157,32 @@ const TableCell = React.forwardRef(
|
|
|
171
157
|
TableCell.displayName = "TableCell";
|
|
172
158
|
const TableCellGroup = React.forwardRef(
|
|
173
159
|
({ className, ...props }, ref) => {
|
|
174
|
-
return /* @__PURE__ */ jsx("div", { ref, className: cn("flex items-center gap-
|
|
160
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("flex items-center gap-1", className), ...props });
|
|
175
161
|
}
|
|
176
162
|
);
|
|
177
163
|
TableCellGroup.displayName = "TableCellGroup";
|
|
164
|
+
function TableCellContent({
|
|
165
|
+
primary,
|
|
166
|
+
secondary,
|
|
167
|
+
primaryAdornment,
|
|
168
|
+
secondaryAdornment,
|
|
169
|
+
className
|
|
170
|
+
}) {
|
|
171
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-0.5", className), children: [
|
|
172
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
173
|
+
/* @__PURE__ */ jsx("span", { className: "typography-semibold-body-sm text-content-primary", children: primary }),
|
|
174
|
+
primaryAdornment
|
|
175
|
+
] }),
|
|
176
|
+
(secondary != null || secondaryAdornment != null) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
177
|
+
secondary != null && /* @__PURE__ */ jsx("span", { className: "typography-regular-body-sm text-content-secondary", children: secondary }),
|
|
178
|
+
secondaryAdornment
|
|
179
|
+
] })
|
|
180
|
+
] });
|
|
181
|
+
}
|
|
182
|
+
TableCellContent.displayName = "TableCellContent";
|
|
178
183
|
const TableMediaThumbnail = React.forwardRef(
|
|
179
184
|
({ className, src, alt = "", blurred, align = "start", ...props }, ref) => {
|
|
180
|
-
const
|
|
181
|
-
const frame = tableSize === "lg" ? "h-[62px] w-11 overflow-hidden rounded-xs bg-neutral-alphas-200" : "h-10 w-[29px] overflow-hidden rounded-xs bg-neutral-alphas-200";
|
|
185
|
+
const frame = "size-12 overflow-hidden rounded-sm bg-neutral-alphas-200";
|
|
182
186
|
return /* @__PURE__ */ jsx(
|
|
183
187
|
"div",
|
|
184
188
|
{
|
|
@@ -242,26 +246,41 @@ const TablePillProgressLayout = React.forwardRef(({ className, ...props }, ref)
|
|
|
242
246
|
"div",
|
|
243
247
|
{
|
|
244
248
|
ref,
|
|
245
|
-
className: cn("flex min-w-[120px] flex-col items-
|
|
249
|
+
className: cn("flex min-w-[120px] flex-col items-start gap-2", className),
|
|
246
250
|
...props
|
|
247
251
|
}
|
|
248
252
|
);
|
|
249
253
|
});
|
|
250
254
|
TablePillProgressLayout.displayName = "TablePillProgressLayout";
|
|
251
255
|
const TableSortLabel = React.forwardRef(
|
|
252
|
-
({ className, children, ...props }, ref) => {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
256
|
+
({ className, children, direction = null, ...props }, ref) => {
|
|
257
|
+
const Icon = direction === "desc" ? ArrowDownIcon : ArrowUpIcon;
|
|
258
|
+
return /* @__PURE__ */ jsxs(
|
|
259
|
+
"span",
|
|
260
|
+
{
|
|
261
|
+
ref,
|
|
262
|
+
className: cn("inline-flex items-center gap-1 text-content-primary", className),
|
|
263
|
+
...props,
|
|
264
|
+
children: [
|
|
265
|
+
/* @__PURE__ */ jsx(
|
|
266
|
+
"span",
|
|
267
|
+
{
|
|
268
|
+
className: cn(
|
|
269
|
+
"typography-semibold-body-sm",
|
|
270
|
+
direction != null && "border-b border-content-primary pb-px"
|
|
271
|
+
),
|
|
272
|
+
children
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
direction != null && /* @__PURE__ */ jsx(Icon, { className: "size-4 shrink-0", "aria-hidden": true })
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
);
|
|
257
279
|
}
|
|
258
280
|
);
|
|
259
281
|
TableSortLabel.displayName = "TableSortLabel";
|
|
260
282
|
function TableStackedText({ title, subtitle }) {
|
|
261
|
-
return /* @__PURE__ */
|
|
262
|
-
/* @__PURE__ */ jsx("span", { className: "typography-semibold-body-md", children: title }),
|
|
263
|
-
/* @__PURE__ */ jsx("span", { className: "typography-regular-body-sm text-content-secondary", children: subtitle })
|
|
264
|
-
] });
|
|
283
|
+
return /* @__PURE__ */ jsx(TableCellContent, { primary: title, secondary: subtitle });
|
|
265
284
|
}
|
|
266
285
|
TableStackedText.displayName = "TableStackedText";
|
|
267
286
|
const TableLineClamp = React.forwardRef(
|
|
@@ -290,7 +309,7 @@ function TableRowsPerPageSelect(props) {
|
|
|
290
309
|
defaultValue: "10",
|
|
291
310
|
size: "32",
|
|
292
311
|
"aria-label": ariaLabel,
|
|
293
|
-
className: "w-[154px] [&_button]:rounded-
|
|
312
|
+
className: "w-[154px] [&_button]:rounded-sm [&_button]:border-transparent [&_button]:bg-surface-inputs",
|
|
294
313
|
id,
|
|
295
314
|
children: /* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
296
315
|
/* @__PURE__ */ jsx(SelectItem, { value: "10", children: "10 rows per page" }),
|
|
@@ -305,6 +324,7 @@ export {
|
|
|
305
324
|
TableBody,
|
|
306
325
|
TableCard,
|
|
307
326
|
TableCell,
|
|
327
|
+
TableCellContent,
|
|
308
328
|
TableCellGroup,
|
|
309
329
|
TableFooter,
|
|
310
330
|
TableHead,
|