@fanvue/ui 3.51.0 → 3.53.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/Autocomplete/Autocomplete.cjs +34 -10
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/cjs/components/Autocomplete/AutocompleteOptionItem.cjs +13 -1
- package/dist/cjs/components/Autocomplete/AutocompleteOptionItem.cjs.map +1 -1
- package/dist/cjs/components/BottomNavigation/BottomNavigation.cjs +2 -2
- package/dist/cjs/components/BottomNavigation/BottomNavigation.cjs.map +1 -1
- package/dist/cjs/components/Card/Card.cjs +5 -2
- package/dist/cjs/components/Card/Card.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartCard.cjs +2 -1
- package/dist/cjs/components/Chart/ChartCard.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs +1 -1
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs.map +1 -1
- package/dist/cjs/components/ChatInput/ChatInput.cjs +2 -2
- package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
- package/dist/cjs/components/ChatMessage/ChatMessage.cjs +1 -1
- package/dist/cjs/components/ChatMessage/ChatMessage.cjs.map +1 -1
- package/dist/cjs/components/CreatorCard/CreatorCard.cjs +3 -5
- package/dist/cjs/components/CreatorCard/CreatorCard.cjs.map +1 -1
- package/dist/cjs/components/CreatorCover/CreatorCover.cjs +11 -7
- package/dist/cjs/components/CreatorCover/CreatorCover.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs +37 -16
- package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/cjs/components/Drawer/Drawer.cjs +11 -3
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +33 -10
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs +2 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +18 -13
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +56 -40
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.cjs +5 -2
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/Icons/MenuRowIcon.cjs +9 -2
- package/dist/cjs/components/Icons/MenuRowIcon.cjs.map +1 -1
- package/dist/cjs/components/Icons/VerifiedIcon.cjs +9 -15
- package/dist/cjs/components/Icons/VerifiedIcon.cjs.map +1 -1
- package/dist/cjs/components/InlineEmptyState/InlineEmptyState.cjs +42 -0
- package/dist/cjs/components/InlineEmptyState/InlineEmptyState.cjs.map +1 -0
- package/dist/cjs/components/Link/Link.cjs +30 -7
- package/dist/cjs/components/Link/Link.cjs.map +1 -1
- package/dist/cjs/components/PhoneField/PhoneField.cjs +21 -17
- package/dist/cjs/components/PhoneField/PhoneField.cjs.map +1 -1
- package/dist/cjs/components/Popover/Popover.cjs +69 -0
- package/dist/cjs/components/Popover/Popover.cjs.map +1 -0
- package/dist/cjs/components/SegmentedControl/SegmentedControl.cjs +6 -10
- package/dist/cjs/components/SegmentedControl/SegmentedControl.cjs.map +1 -1
- package/dist/cjs/components/SegmentedControl/segmentedControlClassNames.cjs +54 -0
- package/dist/cjs/components/SegmentedControl/segmentedControlClassNames.cjs.map +1 -0
- package/dist/cjs/components/Select/Select.cjs +40 -12
- package/dist/cjs/components/Select/Select.cjs.map +1 -1
- package/dist/cjs/components/Slider/SliderThumb.cjs +3 -2
- package/dist/cjs/components/Slider/SliderThumb.cjs.map +1 -1
- package/dist/cjs/components/Snackbar/Snackbar.cjs +1 -1
- package/dist/cjs/components/Snackbar/Snackbar.cjs.map +1 -1
- package/dist/cjs/components/Switch/Switch.cjs +1 -1
- package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
- package/dist/cjs/components/Table/Table.cjs +77 -7
- package/dist/cjs/components/Table/Table.cjs.map +1 -1
- package/dist/cjs/components/Table/TableRowLink.cjs +55 -0
- package/dist/cjs/components/Table/TableRowLink.cjs.map +1 -0
- package/dist/cjs/components/Tag/Tag.cjs +99 -0
- package/dist/cjs/components/Tag/Tag.cjs.map +1 -0
- package/dist/cjs/components/TextArea/TextArea.cjs +5 -4
- package/dist/cjs/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/cjs/components/TextField/TextField.cjs +30 -15
- package/dist/cjs/components/TextField/TextField.cjs.map +1 -1
- package/dist/cjs/index.cjs +12 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/utils/floatingContentSurface.cjs +8 -0
- package/dist/cjs/utils/floatingContentSurface.cjs.map +1 -0
- package/dist/cjs/utils/inputFieldClasses.cjs +8 -0
- package/dist/cjs/utils/inputFieldClasses.cjs.map +1 -0
- package/dist/cjs/utils/pointerCapture.cjs +20 -0
- package/dist/cjs/utils/pointerCapture.cjs.map +1 -0
- package/dist/cjs/utils/useDragToDismiss.cjs +3 -2
- package/dist/cjs/utils/useDragToDismiss.cjs.map +1 -1
- package/dist/cjs/utils/useSuppressClickAfterDrag.cjs +2 -1
- package/dist/cjs/utils/useSuppressClickAfterDrag.cjs.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.mjs +34 -10
- package/dist/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/dist/components/Autocomplete/AutocompleteOptionItem.mjs +13 -1
- package/dist/components/Autocomplete/AutocompleteOptionItem.mjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.mjs +2 -2
- package/dist/components/BottomNavigation/BottomNavigation.mjs.map +1 -1
- package/dist/components/Card/Card.mjs +5 -2
- package/dist/components/Card/Card.mjs.map +1 -1
- package/dist/components/Chart/ChartCard.mjs +2 -1
- package/dist/components/Chart/ChartCard.mjs.map +1 -1
- package/dist/components/Chart/ChartLoadingOverlay.mjs +1 -1
- package/dist/components/Chart/ChartLoadingOverlay.mjs.map +1 -1
- package/dist/components/ChatInput/ChatInput.mjs +2 -2
- package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
- package/dist/components/ChatMessage/ChatMessage.mjs +1 -1
- package/dist/components/ChatMessage/ChatMessage.mjs.map +1 -1
- package/dist/components/CreatorCard/CreatorCard.mjs +3 -5
- package/dist/components/CreatorCard/CreatorCard.mjs.map +1 -1
- package/dist/components/CreatorCover/CreatorCover.mjs +11 -7
- package/dist/components/CreatorCover/CreatorCover.mjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.mjs +39 -18
- package/dist/components/DatePicker/DatePicker.mjs.map +1 -1
- package/dist/components/Drawer/Drawer.mjs +11 -3
- package/dist/components/Drawer/Drawer.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs +33 -10
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs +2 -1
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +18 -13
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +56 -40
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -1
- package/dist/components/IconButton/IconButton.mjs +5 -2
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/Icons/MenuRowIcon.mjs +9 -2
- package/dist/components/Icons/MenuRowIcon.mjs.map +1 -1
- package/dist/components/Icons/VerifiedIcon.mjs +9 -15
- package/dist/components/Icons/VerifiedIcon.mjs.map +1 -1
- package/dist/components/InlineEmptyState/InlineEmptyState.mjs +25 -0
- package/dist/components/InlineEmptyState/InlineEmptyState.mjs.map +1 -0
- package/dist/components/Link/Link.mjs +31 -8
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/PhoneField/PhoneField.mjs +21 -17
- package/dist/components/PhoneField/PhoneField.mjs.map +1 -1
- package/dist/components/Popover/Popover.mjs +51 -0
- package/dist/components/Popover/Popover.mjs.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.mjs +6 -10
- package/dist/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/components/SegmentedControl/segmentedControlClassNames.mjs +54 -0
- package/dist/components/SegmentedControl/segmentedControlClassNames.mjs.map +1 -0
- package/dist/components/Select/Select.mjs +40 -12
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/Slider/SliderThumb.mjs +3 -2
- package/dist/components/Slider/SliderThumb.mjs.map +1 -1
- package/dist/components/Snackbar/Snackbar.mjs +1 -1
- package/dist/components/Snackbar/Snackbar.mjs.map +1 -1
- package/dist/components/Switch/Switch.mjs +1 -1
- package/dist/components/Switch/Switch.mjs.map +1 -1
- package/dist/components/Table/Table.mjs +77 -7
- package/dist/components/Table/Table.mjs.map +1 -1
- package/dist/components/Table/TableRowLink.mjs +38 -0
- package/dist/components/Table/TableRowLink.mjs.map +1 -0
- package/dist/components/Tag/Tag.mjs +82 -0
- package/dist/components/Tag/Tag.mjs.map +1 -0
- package/dist/components/TextArea/TextArea.mjs +5 -4
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/TextField/TextField.mjs +30 -15
- package/dist/components/TextField/TextField.mjs.map +1 -1
- package/dist/date-picker.d.ts +9 -0
- package/dist/index.d.ts +339 -30
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -1
- package/dist/styles/base.css +8 -4
- package/dist/styles/theme.css +1217 -1
- package/dist/utils/floatingContentSurface.mjs +8 -0
- package/dist/utils/floatingContentSurface.mjs.map +1 -0
- package/dist/utils/inputFieldClasses.mjs +8 -0
- package/dist/utils/inputFieldClasses.mjs.map +1 -0
- package/dist/utils/pointerCapture.mjs +20 -0
- package/dist/utils/pointerCapture.mjs.map +1 -0
- package/dist/utils/useDragToDismiss.mjs +3 -2
- package/dist/utils/useDragToDismiss.mjs.map +1 -1
- package/dist/utils/useSuppressClickAfterDrag.mjs +2 -1
- package/dist/utils/useSuppressClickAfterDrag.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -40,6 +40,8 @@ const MODAL_FULL_HEIGHT_CLASSES = {
|
|
|
40
40
|
bottom: "max-h-[calc(100%-1rem-env(safe-area-inset-bottom,0px))]",
|
|
41
41
|
top: "max-h-[calc(100%-1rem-env(safe-area-inset-top,0px))]"
|
|
42
42
|
};
|
|
43
|
+
const PAGE_CLASSES = "top-4 max-h-full w-auto overflow-hidden rounded-t-md border border-b-0 border-modal-stroke bg-background-primary shadow-lg";
|
|
44
|
+
const PAGE_MOTION_CLASSES = "data-[state=open]:duration-300 data-[state=open]:ease-[cubic-bezier(0.32,0.72,0,1)] data-[state=closed]:duration-200 data-[state=closed]:ease-[cubic-bezier(0.32,0,0.67,0)] motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none";
|
|
43
45
|
const DrawerContext = React__namespace.createContext({
|
|
44
46
|
overlay: true
|
|
45
47
|
});
|
|
@@ -78,7 +80,7 @@ const SLIDE_CLASSES = {
|
|
|
78
80
|
const DrawerContent = React__namespace.forwardRef(
|
|
79
81
|
({
|
|
80
82
|
className,
|
|
81
|
-
position
|
|
83
|
+
position: positionProp,
|
|
82
84
|
size = "sm",
|
|
83
85
|
variant = "panel",
|
|
84
86
|
overlay: overlayProp,
|
|
@@ -89,9 +91,13 @@ const DrawerContent = React__namespace.forwardRef(
|
|
|
89
91
|
}, ref) => {
|
|
90
92
|
const ctx = React__namespace.useContext(DrawerContext);
|
|
91
93
|
const overlay = overlayProp ?? ctx.overlay;
|
|
94
|
+
const position = variant === "page" ? "bottom" : positionProp ?? "right";
|
|
92
95
|
const closeRef = React__namespace.useRef(null);
|
|
93
96
|
const contentProps = useDragToDismiss.useDragToDismiss(
|
|
94
|
-
{
|
|
97
|
+
{
|
|
98
|
+
enabled: position === "bottom" && variant !== "page",
|
|
99
|
+
onDismiss: () => closeRef.current?.click()
|
|
100
|
+
},
|
|
95
101
|
props
|
|
96
102
|
);
|
|
97
103
|
const isHorizontal = position === "left" || position === "right";
|
|
@@ -113,6 +119,7 @@ const DrawerContent = React__namespace.forwardRef(
|
|
|
113
119
|
...overlayProps,
|
|
114
120
|
className: cn.cn(
|
|
115
121
|
variant === "modal" && "bg-background-overlay-heavy",
|
|
122
|
+
variant === "page" && PAGE_MOTION_CLASSES,
|
|
116
123
|
overlayProps?.className
|
|
117
124
|
)
|
|
118
125
|
}
|
|
@@ -132,7 +139,7 @@ const DrawerContent = React__namespace.forwardRef(
|
|
|
132
139
|
// utility, so it never deduped the two and `shadow-lg` won on stylesheet
|
|
133
140
|
// order — meaning the sheet and menu surfaces silently rendered `shadow-lg`
|
|
134
141
|
// instead of the menu shadow their tokens name.
|
|
135
|
-
variant === "panel" && "shadow-lg",
|
|
142
|
+
(variant === "panel" || variant === "page") && "shadow-lg",
|
|
136
143
|
"data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
137
144
|
"data-[state=closed]:duration-150 data-[state=closed]:ease-in",
|
|
138
145
|
"data-[state=open]:duration-200 data-[state=open]:ease-out",
|
|
@@ -145,6 +152,7 @@ const DrawerContent = React__namespace.forwardRef(
|
|
|
145
152
|
MODAL_POSITION_CLASSES[position],
|
|
146
153
|
size === "full" && MODAL_FULL_HEIGHT_CLASSES[position]
|
|
147
154
|
),
|
|
155
|
+
variant === "page" && cn.cn(PAGE_CLASSES, PAGE_MOTION_CLASSES),
|
|
148
156
|
className
|
|
149
157
|
),
|
|
150
158
|
...contentProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.cjs","sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useDragToDismiss } from \"../../utils/useDragToDismiss\";\nimport { useSuppressClickAfterDrag } from \"../../utils/useSuppressClickAfterDrag\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** The side from which the drawer slides in. */\nexport type DrawerPosition = \"left\" | \"right\" | \"top\" | \"bottom\";\n\n/** Size presets for the drawer panel. Maps to max-width (left/right) or max-height (top/bottom). */\nexport type DrawerSize = \"sm\" | \"md\" | \"lg\" | \"full\";\n\n/**\n * Visual treatment of the drawer panel.\n *\n * - `\"panel\"` (default) — the standard edge-anchored surface.\n * - `\"sheet\"` — a bottom-sheet treatment matching the modal surface: large\n * top-only radius (32px), modal background/stroke, and menu blur+shadow.\n * Intended for `position=\"bottom\"`.\n * - `\"menu\"` — a floating menu near the bottom edge rather than a sheet fixed to\n * it: inset from all three sides and rounded on every corner. Shares the modal\n * surface with `\"sheet\"`; only the shape differs. Intended for\n * `position=\"bottom\"`.\n * - `\"modal\"` — the V2 Modal: a card floating 8px clear of the viewport edges,\n * with the modal surface and stroke and a 32px radius, over the heavy overlay.\n * Beside the page (`position=\"left\"` or `\"right\"`) it is 440px wide with 24px\n * padding; from the top or bottom it is the mobile modal, with 16px padding.\n */\nexport type DrawerVariant = \"panel\" | \"sheet\" | \"menu\" | \"modal\";\n\n/**\n * Shared surface classes for the `\"sheet\"` variant. Mirrors the mobile sheet\n * treatment used by {@link Dialog} so bottom sheets are visually consistent.\n */\nconst SHEET_CLASSES =\n \"rounded-t-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Surface and inset for the `\"menu\"` variant. Same modal background and stroke as\n * a sheet — the design puts this panel on `background/secondary` with\n * `border/strong`, not on the lighter surface the trigger-anchored dropdown uses.\n * The 24px radius is the design's `rounded-lg`.\n *\n * The insets restate position on purpose — they override `SLIDE_CLASSES.bottom`,\n * which pins a sheet flush to the bottom edge at full width.\n */\nconst MENU_CLASSES =\n \"inset-x-4 bottom-4 w-auto rounded-lg border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Surface of the `\"modal\"` variant (the V2 Modal): the modal background and stroke,\n * floating 8px clear of the viewport edges with every corner rounded.\n */\nconst MODAL_CLASSES =\n \"rounded-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-xs\";\n\n/**\n * Shape of the `\"modal\"` variant per position. The insets restate position on\n * purpose — they override `SLIDE_CLASSES`, which pin a panel flush to its edge.\n * Beside the page it is the 440px desktop modal with 24px padding, which wins\n * over the `size` preset; from the top or bottom it is the mobile modal, 8px in\n * from both sides and its edge (clear of the safe area) with 16px padding, its\n * height left to `size`.\n */\nconst MODAL_POSITION_CLASSES: Record<DrawerPosition, string> = {\n right: \"inset-y-2 right-2 h-auto w-[calc(100%-1rem)] max-w-110 p-6\",\n left: \"inset-y-2 left-2 h-auto w-[calc(100%-1rem)] max-w-110 p-6\",\n bottom: \"inset-x-2 bottom-[calc(0.5rem+env(safe-area-inset-bottom,0px))] w-auto p-4\",\n top: \"inset-x-2 top-[calc(0.5rem+env(safe-area-inset-top,0px))] w-auto p-4\",\n};\n\n/**\n * A full-height top or bottom modal stops 8px short of the opposite edge too, and\n * its cap also gives up the safe area its own edge clears, so the inset on that\n * side never pushes it off the screen.\n */\nconst MODAL_FULL_HEIGHT_CLASSES: Partial<Record<DrawerPosition, string>> = {\n bottom: \"max-h-[calc(100%-1rem-env(safe-area-inset-bottom,0px))]\",\n top: \"max-h-[calc(100%-1rem-env(safe-area-inset-top,0px))]\",\n};\n\n/**\n * Props for the {@link Drawer} root component.\n *\n * Inherits `open`, `onOpenChange`, and `defaultOpen` from Radix Dialog.Root.\n *\n * The Radix `modal` prop (default `true`) can also be passed to create a\n * non-modal drawer — useful for persistent side navigation that does not\n * block interaction with the rest of the page.\n *\n * **`overlay` behaviour:** When `overlay` is `false`, the component\n * automatically sets `modal={false}` on the underlying Radix Dialog.Root.\n * A modal dialog without a visible overlay is confusing because focus is\n * still trapped and scroll is blocked even though the page appears\n * interactive. Passing `modal={true}` explicitly will override this.\n */\nexport interface DrawerProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root> {\n /**\n * Whether the default {@link DrawerOverlay} is rendered.\n * When `false`, `modal` is automatically set to `false` as well\n * (unless explicitly overridden) so focus-trap and scroll-lock are disabled.\n * @default true\n */\n overlay?: boolean;\n}\n\nconst DrawerContext = React.createContext<{ overlay: boolean }>({\n overlay: true,\n});\n\n/**\n * The open panel's variant, so {@link DrawerHeader} and {@link DrawerFooter} drop\n * their own padding inside a `\"modal\"`, whose panel already pads its content.\n */\nconst DrawerVariantContext = React.createContext<DrawerVariant>(\"panel\");\n\n/**\n * Root component that manages open/close state for a drawer.\n * Wraps Radix Dialog.Root.\n *\n * @example\n * ```tsx\n * <Drawer>\n * <DrawerTrigger>Open</DrawerTrigger>\n * <DrawerContent position=\"right\">\n * <DrawerHeader>\n * <DrawerTitle>Settings</DrawerTitle>\n * <DrawerDescription>Adjust your preferences.</DrawerDescription>\n * </DrawerHeader>\n * <p>Content goes here.</p>\n * <DrawerFooter>\n * <DrawerClose>Done</DrawerClose>\n * </DrawerFooter>\n * </DrawerContent>\n * </Drawer>\n * ```\n */\nexport function Drawer({ overlay = true, modal, children, ...props }: DrawerProps) {\n const resolvedModal = modal ?? (overlay ? undefined : false);\n return (\n <DrawerContext.Provider value={{ overlay }}>\n <DialogPrimitive.Root modal={resolvedModal} {...props}>\n {children}\n </DialogPrimitive.Root>\n </DrawerContext.Provider>\n );\n}\nDrawer.displayName = \"Drawer\";\n\n/** Props for the {@link DrawerTrigger} component. */\nexport type DrawerTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\n/**\n * The element that opens the drawer when clicked.\n *\n * On touch / pen, a press-and-release that crosses a small movement threshold\n * is treated as a drag and the resulting synthetic click is suppressed —\n * defends against Android Chrome opening the drawer on a scroll-drag-end.\n */\nexport const DrawerTrigger = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Trigger>,\n DrawerTriggerProps\n>((props, ref) => <DialogPrimitive.Trigger ref={ref} {...useSuppressClickAfterDrag(props)} />);\nDrawerTrigger.displayName = \"DrawerTrigger\";\n\n/** Props for the {@link DrawerClose} component. */\nexport type DrawerCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\n/** Closes the drawer when clicked. Can be placed anywhere inside the drawer. */\nexport const DrawerClose = DialogPrimitive.Close;\nDrawerClose.displayName = \"DrawerClose\";\n\n/** Props for the {@link DrawerOverlay} component. */\nexport interface DrawerOverlayProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> {}\n\n/**\n * A translucent backdrop rendered behind the drawer content.\n * Clicking the overlay closes the drawer by default.\n */\nexport const DrawerOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n DrawerOverlayProps\n>(({ className, style, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"fixed inset-0 bg-background-overlay-default\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:fade-in-0 data-[state=open]:duration-200 data-[state=open]:ease-out\",\n className,\n )}\n {...props}\n />\n));\nDrawerOverlay.displayName = \"DrawerOverlay\";\n\n/**\n * Slide-in animation classes keyed by position.\n * Uses Tailwind animate utilities (animate-in / animate-out).\n */\nconst SLIDE_CLASSES: Record<DrawerPosition, string> = {\n right:\n \"inset-y-0 right-0 h-full w-2/3 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right\",\n left: \"inset-y-0 left-0 h-full w-2/3 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left\",\n top: \"inset-x-0 top-0 w-full data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n bottom:\n \"inset-x-0 bottom-0 w-full rounded-t-xs data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n};\n\n/** Props for the {@link DrawerContent} component. */\nexport interface DrawerContentProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {\n /**\n * The edge from which the drawer slides in.\n *\n * Named `position` (rather than `side`) to avoid confusion with the CSS\n * `side` concept used by Radix Popover/Tooltip and to better convey the\n * spatial relationship of the drawer to the viewport.\n *\n * @default \"right\"\n */\n position?: DrawerPosition;\n /**\n * Controls the maximum extent of the drawer panel.\n * For left/right drawers this sets `max-width`; for top/bottom it sets `max-height`.\n * Ignored by a left/right `variant=\"modal\"`, which is always the 440px modal.\n * @default \"sm\"\n */\n size?: DrawerSize;\n /**\n * Visual treatment of the panel. Use `\"sheet\"` (with `position=\"bottom\"`) for\n * a bottom sheet with the modal surface treatment, `\"menu\"` for a floating\n * inset menu carrying the dropdown surface, or `\"modal\"` for the V2 Modal: beside\n * the page on desktop, from the bottom on mobile. @default \"panel\"\n */\n variant?: DrawerVariant;\n /**\n * Whether to render the default {@link DrawerOverlay} behind the content.\n * Set to `false` to provide your own overlay or omit it entirely.\n *\n * Prefer setting `overlay` on the {@link Drawer} root instead so that\n * `modal` is also adjusted automatically.\n *\n * @default true\n */\n overlay?: boolean;\n /** Props forwarded to the default {@link DrawerOverlay} when `overlay` is `true`. */\n overlayProps?: DrawerOverlayProps;\n}\n\n/**\n * The panel that slides in from the chosen edge. Renders inside a portal with\n * an overlay backdrop by default.\n *\n * Includes focus-trap, `aria-describedby`, and Escape-to-close from Radix Dialog.\n */\nexport const DrawerContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(\n (\n {\n className,\n position = \"right\",\n size = \"sm\",\n variant = \"panel\",\n overlay: overlayProp,\n overlayProps,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const ctx = React.useContext(DrawerContext);\n const overlay = overlayProp ?? ctx.overlay;\n const closeRef = React.useRef<HTMLButtonElement>(null);\n const contentProps = useDragToDismiss(\n { enabled: position === \"bottom\", onDismiss: () => closeRef.current?.click() },\n props,\n );\n const isHorizontal = position === \"left\" || position === \"right\";\n const sizeClass = isHorizontal\n ? (\n {\n sm: \"max-w-sm\",\n md: \"max-w-md\",\n lg: \"max-w-lg\",\n full: \"max-w-full\",\n } as const\n )[size]\n : (\n {\n sm: \"max-h-[24rem]\",\n md: \"max-h-[28rem]\",\n lg: \"max-h-[32rem]\",\n full: \"max-h-full\",\n } as const\n )[size];\n\n return (\n <DialogPrimitive.Portal>\n {overlay && (\n <DrawerOverlay\n {...overlayProps}\n className={cn(\n variant === \"modal\" && \"bg-background-overlay-heavy\",\n overlayProps?.className,\n )}\n />\n )}\n <DialogPrimitive.Content\n ref={ref}\n style={{\n zIndex: \"calc(var(--fanvue-ui-portal-z-index, 50) + 1)\",\n ...style,\n }}\n className={cn(\n \"fixed flex flex-col bg-surface-secondary outline-none backdrop-blur-lg\",\n // `shadow-lg` is scoped to `panel` rather than sitting in the base classes.\n // tailwind-merge does not recognise `shadow-blur-menu` as a box-shadow\n // utility, so it never deduped the two and `shadow-lg` won on stylesheet\n // order — meaning the sheet and menu surfaces silently rendered `shadow-lg`\n // instead of the menu shadow their tokens name.\n variant === \"panel\" && \"shadow-lg\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:duration-200 data-[state=open]:ease-out\",\n SLIDE_CLASSES[position],\n sizeClass,\n variant === \"sheet\" && SHEET_CLASSES,\n variant === \"menu\" && MENU_CLASSES,\n variant === \"modal\" &&\n cn(\n MODAL_CLASSES,\n MODAL_POSITION_CLASSES[position],\n size === \"full\" && MODAL_FULL_HEIGHT_CLASSES[position],\n ),\n className,\n )}\n {...contentProps}\n >\n <DialogPrimitive.Close ref={closeRef} hidden tabIndex={-1} aria-hidden=\"true\" />\n <DrawerVariantContext.Provider value={variant}>{children}</DrawerVariantContext.Provider>\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n );\n },\n);\nDrawerContent.displayName = \"DrawerContent\";\n\n/** Props for the {@link DrawerHeader} component. */\nexport interface DrawerHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether to show a built-in close (X) button. @default true */\n showClose?: boolean;\n /** Accessible label for the close button. @default \"Close drawer\" */\n closeLabel?: string;\n}\n\n/**\n * A semantic header area for the drawer, typically containing a title and description.\n * Renders a built-in close button by default. Inside a `\"modal\"` drawer it carries\n * no padding of its own, since the panel pads its content.\n */\nexport const DrawerHeader = React.forwardRef<HTMLDivElement, DrawerHeaderProps>(\n ({ className, showClose = true, closeLabel = \"Close drawer\", children, ...props }, ref) => {\n const variant = React.useContext(DrawerVariantContext);\n return (\n <div\n ref={ref}\n className={cn(\"flex items-center gap-2\", variant !== \"modal\" && \"p-4\", className)}\n {...props}\n >\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">{children}</div>\n {showClose && (\n <DialogPrimitive.Close asChild>\n <IconButton\n icon={<CloseIcon />}\n aria-label={closeLabel}\n variant=\"secondary\"\n size=\"32\"\n className=\"shrink-0\"\n />\n </DialogPrimitive.Close>\n )}\n </div>\n );\n },\n);\nDrawerHeader.displayName = \"DrawerHeader\";\n\n/** Props for the {@link DrawerFooter} component. */\nexport interface DrawerFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/**\n * A semantic footer area for the drawer, typically containing action buttons.\n * Inside a `\"modal\"` drawer it carries no padding of its own, since the panel pads\n * its content.\n */\nexport const DrawerFooter = React.forwardRef<HTMLDivElement, DrawerFooterProps>(\n ({ className, ...props }, ref) => {\n const variant = React.useContext(DrawerVariantContext);\n return (\n <div\n ref={ref}\n className={cn(\"flex flex-col gap-2\", variant !== \"modal\" && \"p-4\", className)}\n {...props}\n />\n );\n },\n);\nDrawerFooter.displayName = \"DrawerFooter\";\n\n/** Props for the {@link DrawerTitle} component. */\nexport interface DrawerTitleProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> {}\n\n/** An accessible title for the drawer. Required for screen readers. */\nexport const DrawerTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n DrawerTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"typography-body-default-16px-semibold truncate text-content-primary\", className)}\n {...props}\n />\n));\nDrawerTitle.displayName = \"DrawerTitle\";\n\n/** Props for the {@link DrawerDescription} component. */\nexport interface DrawerDescriptionProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> {}\n\n/** An accessible description for the drawer, providing supplementary context. */\nexport const DrawerDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n DrawerDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"typography-body-small-14px-regular text-content-secondary\", className)}\n {...props}\n />\n));\nDrawerDescription.displayName = \"DrawerDescription\";\n"],"names":["React","jsx","DialogPrimitive","useSuppressClickAfterDrag","cn","useDragToDismiss","jsxs","IconButton","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,gBACJ;AAWF,MAAM,eACJ;AAMF,MAAM,gBACJ;AAUF,MAAM,yBAAyD;AAAA,EAC7D,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,KAAK;AACP;AAOA,MAAM,4BAAqE;AAAA,EACzE,QAAQ;AAAA,EACR,KAAK;AACP;AA2BA,MAAM,gBAAgBA,iBAAM,cAAoC;AAAA,EAC9D,SAAS;AACX,CAAC;AAMD,MAAM,uBAAuBA,iBAAM,cAA6B,OAAO;AAuBhE,SAAS,OAAO,EAAE,UAAU,MAAM,OAAO,UAAU,GAAG,SAAsB;AACjF,QAAM,gBAAgB,UAAU,UAAU,SAAY;AACtD,wCACG,cAAc,UAAd,EAAuB,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A;AACN,CACD;AACD,YAAY,cAAc;AAOnB,MAAM,oBAAoBJ,iBAAM,WAGrC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWE,GAAAA,GAAG,6DAA6D,SAAS;AAAA,IACnF,GAAG;AAAA,EAAA;AACN,CACD;AACD,kBAAkB,cAAc;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Drawer.cjs","sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useDragToDismiss } from \"../../utils/useDragToDismiss\";\nimport { useSuppressClickAfterDrag } from \"../../utils/useSuppressClickAfterDrag\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** The side from which the drawer slides in. */\nexport type DrawerPosition = \"left\" | \"right\" | \"top\" | \"bottom\";\n\n/** Size presets for the drawer panel. Maps to max-width (left/right) or max-height (top/bottom). */\nexport type DrawerSize = \"sm\" | \"md\" | \"lg\" | \"full\";\n\n/**\n * Visual treatment of the drawer panel.\n *\n * - `\"panel\"` (default) — the standard edge-anchored surface.\n * - `\"sheet\"` — a bottom-sheet treatment matching the modal surface: large\n * top-only radius (32px), modal background/stroke, and menu blur+shadow.\n * Intended for `position=\"bottom\"`.\n * - `\"menu\"` — a floating menu near the bottom edge rather than a sheet fixed to\n * it: inset from all three sides and rounded on every corner. Shares the modal\n * surface with `\"sheet\"`; only the shape differs. Intended for\n * `position=\"bottom\"`.\n * - `\"modal\"` — the V2 Modal: a card floating 8px clear of the viewport edges,\n * with the modal surface and stroke and a 32px radius, over the heavy overlay.\n * Beside the page (`position=\"left\"` or `\"right\"`) it is 440px wide with 24px\n * padding; from the top or bottom it is the mobile modal, with 16px padding.\n * - `\"page\"` — a detail page that rises over the one behind it: the opaque page\n * background, a 16px top radius, a stroke on the top and sides, and a 16px gap\n * left above it so the page behind stays in view. It always runs to the bottom\n * edge, so `size` is ignored. Its rise is slower than its fall, and both are\n * dropped under reduced motion. It always rises from the bottom, so `position`\n * is ignored too. It cannot be dragged down to dismiss, and it clips what\n * overflows it, so give its body a scroll container (`min-h-0 flex-1\n * overflow-y-auto`). Meant for wide viewports; on a phone, use `\"sheet\"`.\n */\nexport type DrawerVariant = \"panel\" | \"sheet\" | \"menu\" | \"modal\" | \"page\";\n\n/**\n * Shared surface classes for the `\"sheet\"` variant. Mirrors the mobile sheet\n * treatment used by {@link Dialog} so bottom sheets are visually consistent.\n */\nconst SHEET_CLASSES =\n \"rounded-t-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Surface and inset for the `\"menu\"` variant. Same modal background and stroke as\n * a sheet — the design puts this panel on `background/secondary` with\n * `border/strong`, not on the lighter surface the trigger-anchored dropdown uses.\n * The 24px radius is the design's `rounded-lg`.\n *\n * The insets restate position on purpose — they override `SLIDE_CLASSES.bottom`,\n * which pins a sheet flush to the bottom edge at full width.\n */\nconst MENU_CLASSES =\n \"inset-x-4 bottom-4 w-auto rounded-lg border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Surface of the `\"modal\"` variant (the V2 Modal): the modal background and stroke,\n * floating 8px clear of the viewport edges with every corner rounded.\n */\nconst MODAL_CLASSES =\n \"rounded-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-xs\";\n\n/**\n * Shape of the `\"modal\"` variant per position. The insets restate position on\n * purpose — they override `SLIDE_CLASSES`, which pin a panel flush to its edge.\n * Beside the page it is the 440px desktop modal with 24px padding, which wins\n * over the `size` preset; from the top or bottom it is the mobile modal, 8px in\n * from both sides and its edge (clear of the safe area) with 16px padding, its\n * height left to `size`.\n */\nconst MODAL_POSITION_CLASSES: Record<DrawerPosition, string> = {\n right: \"inset-y-2 right-2 h-auto w-[calc(100%-1rem)] max-w-110 p-6\",\n left: \"inset-y-2 left-2 h-auto w-[calc(100%-1rem)] max-w-110 p-6\",\n bottom: \"inset-x-2 bottom-[calc(0.5rem+env(safe-area-inset-bottom,0px))] w-auto p-4\",\n top: \"inset-x-2 top-[calc(0.5rem+env(safe-area-inset-top,0px))] w-auto p-4\",\n};\n\n/**\n * A full-height top or bottom modal stops 8px short of the opposite edge too, and\n * its cap also gives up the safe area its own edge clears, so the inset on that\n * side never pushes it off the screen.\n */\nconst MODAL_FULL_HEIGHT_CLASSES: Partial<Record<DrawerPosition, string>> = {\n bottom: \"max-h-[calc(100%-1rem-env(safe-area-inset-bottom,0px))]\",\n top: \"max-h-[calc(100%-1rem-env(safe-area-inset-top,0px))]\",\n};\n\n/**\n * Surface and shape of the `\"page\"` variant. `top-4` and `max-h-full` restate\n * position and size on purpose — the panel always spans from 16px below the top\n * edge to the bottom one, whatever `size` asks for. It spans the full width unless\n * the caller insets it, through `style` or `className`, to sit over one column.\n */\nconst PAGE_CLASSES =\n \"top-4 max-h-full w-auto overflow-hidden rounded-t-md border border-b-0 border-modal-stroke bg-background-primary shadow-lg\";\n\n/**\n * Motion of the `\"page\"` variant, shared by its panel and overlay: a 300ms\n * decelerating rise and a 200ms accelerating fall, both dropped under reduced\n * motion. The reduced-motion classes carry the same `data-[state=…]` selector as\n * the `animate-in` and `animate-out` they cancel; a bare\n * `motion-reduce:animate-none` is less specific and loses to them.\n */\nconst PAGE_MOTION_CLASSES =\n \"data-[state=open]:duration-300 data-[state=open]:ease-[cubic-bezier(0.32,0.72,0,1)] data-[state=closed]:duration-200 data-[state=closed]:ease-[cubic-bezier(0.32,0,0.67,0)] motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none\";\n\n/**\n * Props for the {@link Drawer} root component.\n *\n * Inherits `open`, `onOpenChange`, and `defaultOpen` from Radix Dialog.Root.\n *\n * The Radix `modal` prop (default `true`) can also be passed to create a\n * non-modal drawer — useful for persistent side navigation that does not\n * block interaction with the rest of the page.\n *\n * **`overlay` behaviour:** When `overlay` is `false`, the component\n * automatically sets `modal={false}` on the underlying Radix Dialog.Root.\n * A modal dialog without a visible overlay is confusing because focus is\n * still trapped and scroll is blocked even though the page appears\n * interactive. Passing `modal={true}` explicitly will override this.\n */\nexport interface DrawerProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root> {\n /**\n * Whether the default {@link DrawerOverlay} is rendered.\n * When `false`, `modal` is automatically set to `false` as well\n * (unless explicitly overridden) so focus-trap and scroll-lock are disabled.\n * @default true\n */\n overlay?: boolean;\n}\n\nconst DrawerContext = React.createContext<{ overlay: boolean }>({\n overlay: true,\n});\n\n/**\n * The open panel's variant, so {@link DrawerHeader} and {@link DrawerFooter} drop\n * their own padding inside a `\"modal\"`, whose panel already pads its content.\n */\nconst DrawerVariantContext = React.createContext<DrawerVariant>(\"panel\");\n\n/**\n * Root component that manages open/close state for a drawer.\n * Wraps Radix Dialog.Root.\n *\n * @example\n * ```tsx\n * <Drawer>\n * <DrawerTrigger>Open</DrawerTrigger>\n * <DrawerContent position=\"right\">\n * <DrawerHeader>\n * <DrawerTitle>Settings</DrawerTitle>\n * <DrawerDescription>Adjust your preferences.</DrawerDescription>\n * </DrawerHeader>\n * <p>Content goes here.</p>\n * <DrawerFooter>\n * <DrawerClose>Done</DrawerClose>\n * </DrawerFooter>\n * </DrawerContent>\n * </Drawer>\n * ```\n */\nexport function Drawer({ overlay = true, modal, children, ...props }: DrawerProps) {\n const resolvedModal = modal ?? (overlay ? undefined : false);\n return (\n <DrawerContext.Provider value={{ overlay }}>\n <DialogPrimitive.Root modal={resolvedModal} {...props}>\n {children}\n </DialogPrimitive.Root>\n </DrawerContext.Provider>\n );\n}\nDrawer.displayName = \"Drawer\";\n\n/** Props for the {@link DrawerTrigger} component. */\nexport type DrawerTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\n/**\n * The element that opens the drawer when clicked.\n *\n * On touch / pen, a press-and-release that crosses a small movement threshold\n * is treated as a drag and the resulting synthetic click is suppressed —\n * defends against Android Chrome opening the drawer on a scroll-drag-end.\n */\nexport const DrawerTrigger = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Trigger>,\n DrawerTriggerProps\n>((props, ref) => <DialogPrimitive.Trigger ref={ref} {...useSuppressClickAfterDrag(props)} />);\nDrawerTrigger.displayName = \"DrawerTrigger\";\n\n/** Props for the {@link DrawerClose} component. */\nexport type DrawerCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\n/** Closes the drawer when clicked. Can be placed anywhere inside the drawer. */\nexport const DrawerClose = DialogPrimitive.Close;\nDrawerClose.displayName = \"DrawerClose\";\n\n/** Props for the {@link DrawerOverlay} component. */\nexport interface DrawerOverlayProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> {}\n\n/**\n * A translucent backdrop rendered behind the drawer content.\n * Clicking the overlay closes the drawer by default.\n */\nexport const DrawerOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n DrawerOverlayProps\n>(({ className, style, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"fixed inset-0 bg-background-overlay-default\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:fade-in-0 data-[state=open]:duration-200 data-[state=open]:ease-out\",\n className,\n )}\n {...props}\n />\n));\nDrawerOverlay.displayName = \"DrawerOverlay\";\n\n/**\n * Slide-in animation classes keyed by position.\n * Uses Tailwind animate utilities (animate-in / animate-out).\n */\nconst SLIDE_CLASSES: Record<DrawerPosition, string> = {\n right:\n \"inset-y-0 right-0 h-full w-2/3 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right\",\n left: \"inset-y-0 left-0 h-full w-2/3 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left\",\n top: \"inset-x-0 top-0 w-full data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n bottom:\n \"inset-x-0 bottom-0 w-full rounded-t-xs data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n};\n\n/** Props for the {@link DrawerContent} component. */\nexport interface DrawerContentProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {\n /**\n * The edge from which the drawer slides in.\n *\n * Named `position` (rather than `side`) to avoid confusion with the CSS\n * `side` concept used by Radix Popover/Tooltip and to better convey the\n * spatial relationship of the drawer to the viewport.\n *\n * Ignored by `variant=\"page\"`, which always rises from the bottom.\n *\n * @default \"right\"\n */\n position?: DrawerPosition;\n /**\n * Controls the maximum extent of the drawer panel.\n * For left/right drawers this sets `max-width`; for top/bottom it sets `max-height`.\n * Ignored by a left/right `variant=\"modal\"`, which is always the 440px modal,\n * and by `variant=\"page\"`, which always runs to the bottom edge.\n * @default \"sm\"\n */\n size?: DrawerSize;\n /**\n * Visual treatment of the panel. Use `\"sheet\"` (with `position=\"bottom\"`) for\n * a bottom sheet with the modal surface treatment, `\"menu\"` for a floating\n * inset menu carrying the dropdown surface, `\"modal\"` for the V2 Modal: beside\n * the page on desktop, from the bottom on mobile, or `\"page\"` for a detail page\n * that rises from the bottom over the one behind it.\n * @default \"panel\"\n */\n variant?: DrawerVariant;\n /**\n * Whether to render the default {@link DrawerOverlay} behind the content.\n * Set to `false` to provide your own overlay or omit it entirely.\n *\n * Prefer setting `overlay` on the {@link Drawer} root instead so that\n * `modal` is also adjusted automatically.\n *\n * @default true\n */\n overlay?: boolean;\n /** Props forwarded to the default {@link DrawerOverlay} when `overlay` is `true`. */\n overlayProps?: DrawerOverlayProps;\n}\n\n/**\n * The panel that slides in from the chosen edge. Renders inside a portal with\n * an overlay backdrop by default.\n *\n * Includes focus-trap, `aria-describedby`, and Escape-to-close from Radix Dialog.\n */\nexport const DrawerContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(\n (\n {\n className,\n position: positionProp,\n size = \"sm\",\n variant = \"panel\",\n overlay: overlayProp,\n overlayProps,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const ctx = React.useContext(DrawerContext);\n const overlay = overlayProp ?? ctx.overlay;\n const position = variant === \"page\" ? \"bottom\" : (positionProp ?? \"right\");\n const closeRef = React.useRef<HTMLButtonElement>(null);\n const contentProps = useDragToDismiss(\n {\n enabled: position === \"bottom\" && variant !== \"page\",\n onDismiss: () => closeRef.current?.click(),\n },\n props,\n );\n const isHorizontal = position === \"left\" || position === \"right\";\n const sizeClass = isHorizontal\n ? (\n {\n sm: \"max-w-sm\",\n md: \"max-w-md\",\n lg: \"max-w-lg\",\n full: \"max-w-full\",\n } as const\n )[size]\n : (\n {\n sm: \"max-h-[24rem]\",\n md: \"max-h-[28rem]\",\n lg: \"max-h-[32rem]\",\n full: \"max-h-full\",\n } as const\n )[size];\n\n return (\n <DialogPrimitive.Portal>\n {overlay && (\n <DrawerOverlay\n {...overlayProps}\n className={cn(\n variant === \"modal\" && \"bg-background-overlay-heavy\",\n variant === \"page\" && PAGE_MOTION_CLASSES,\n overlayProps?.className,\n )}\n />\n )}\n <DialogPrimitive.Content\n ref={ref}\n style={{\n zIndex: \"calc(var(--fanvue-ui-portal-z-index, 50) + 1)\",\n ...style,\n }}\n className={cn(\n \"fixed flex flex-col bg-surface-secondary outline-none backdrop-blur-lg\",\n // `shadow-lg` is scoped to `panel` rather than sitting in the base classes.\n // tailwind-merge does not recognise `shadow-blur-menu` as a box-shadow\n // utility, so it never deduped the two and `shadow-lg` won on stylesheet\n // order — meaning the sheet and menu surfaces silently rendered `shadow-lg`\n // instead of the menu shadow their tokens name.\n (variant === \"panel\" || variant === \"page\") && \"shadow-lg\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:duration-200 data-[state=open]:ease-out\",\n SLIDE_CLASSES[position],\n sizeClass,\n variant === \"sheet\" && SHEET_CLASSES,\n variant === \"menu\" && MENU_CLASSES,\n variant === \"modal\" &&\n cn(\n MODAL_CLASSES,\n MODAL_POSITION_CLASSES[position],\n size === \"full\" && MODAL_FULL_HEIGHT_CLASSES[position],\n ),\n variant === \"page\" && cn(PAGE_CLASSES, PAGE_MOTION_CLASSES),\n className,\n )}\n {...contentProps}\n >\n <DialogPrimitive.Close ref={closeRef} hidden tabIndex={-1} aria-hidden=\"true\" />\n <DrawerVariantContext.Provider value={variant}>{children}</DrawerVariantContext.Provider>\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n );\n },\n);\nDrawerContent.displayName = \"DrawerContent\";\n\n/** Props for the {@link DrawerHeader} component. */\nexport interface DrawerHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether to show a built-in close (X) button. @default true */\n showClose?: boolean;\n /** Accessible label for the close button. @default \"Close drawer\" */\n closeLabel?: string;\n}\n\n/**\n * A semantic header area for the drawer, typically containing a title and description.\n * Renders a built-in close button by default. Inside a `\"modal\"` drawer it carries\n * no padding of its own, since the panel pads its content.\n */\nexport const DrawerHeader = React.forwardRef<HTMLDivElement, DrawerHeaderProps>(\n ({ className, showClose = true, closeLabel = \"Close drawer\", children, ...props }, ref) => {\n const variant = React.useContext(DrawerVariantContext);\n return (\n <div\n ref={ref}\n className={cn(\"flex items-center gap-2\", variant !== \"modal\" && \"p-4\", className)}\n {...props}\n >\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">{children}</div>\n {showClose && (\n <DialogPrimitive.Close asChild>\n <IconButton\n icon={<CloseIcon />}\n aria-label={closeLabel}\n variant=\"secondary\"\n size=\"32\"\n className=\"shrink-0\"\n />\n </DialogPrimitive.Close>\n )}\n </div>\n );\n },\n);\nDrawerHeader.displayName = \"DrawerHeader\";\n\n/** Props for the {@link DrawerFooter} component. */\nexport interface DrawerFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/**\n * A semantic footer area for the drawer, typically containing action buttons.\n * Inside a `\"modal\"` drawer it carries no padding of its own, since the panel pads\n * its content.\n */\nexport const DrawerFooter = React.forwardRef<HTMLDivElement, DrawerFooterProps>(\n ({ className, ...props }, ref) => {\n const variant = React.useContext(DrawerVariantContext);\n return (\n <div\n ref={ref}\n className={cn(\"flex flex-col gap-2\", variant !== \"modal\" && \"p-4\", className)}\n {...props}\n />\n );\n },\n);\nDrawerFooter.displayName = \"DrawerFooter\";\n\n/** Props for the {@link DrawerTitle} component. */\nexport interface DrawerTitleProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> {}\n\n/** An accessible title for the drawer. Required for screen readers. */\nexport const DrawerTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n DrawerTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"typography-body-default-16px-semibold truncate text-content-primary\", className)}\n {...props}\n />\n));\nDrawerTitle.displayName = \"DrawerTitle\";\n\n/** Props for the {@link DrawerDescription} component. */\nexport interface DrawerDescriptionProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> {}\n\n/** An accessible description for the drawer, providing supplementary context. */\nexport const DrawerDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n DrawerDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"typography-body-small-14px-regular text-content-secondary\", className)}\n {...props}\n />\n));\nDrawerDescription.displayName = \"DrawerDescription\";\n"],"names":["React","jsx","DialogPrimitive","useSuppressClickAfterDrag","cn","useDragToDismiss","jsxs","IconButton","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAM,gBACJ;AAWF,MAAM,eACJ;AAMF,MAAM,gBACJ;AAUF,MAAM,yBAAyD;AAAA,EAC7D,OAAO;AAAA,EACP,MAA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AACA,aAAa,cAAc;AAUpB,MAAM,eAAeR,iBAAM;AAAA,EAChC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAAQ;AAChC,UAAM,UAAUA,iBAAM,WAAW,oBAAoB;AACrD,WACEC,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAWG,GAAAA,GAAG,uBAAuB,YAAY,WAAW,OAAO,SAAS;AAAA,QAC3E,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AACA,aAAa,cAAc;AAOpB,MAAM,cAAcJ,iBAAM,WAG/B,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWE,GAAAA,GAAG,uEAAuE,SAAS;AAAA,IAC7F,GAAG;AAAA,EAAA;AACN,CACD;AACD,YAAY,cAAc;AAOnB,MAAM,oBAAoBJ,iBAAM,WAGrC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWE,GAAAA,GAAG,6DAA6D,SAAS;AAAA,IACnF,GAAG;AAAA,EAAA;AACN,CACD;AACD,kBAAkB,cAAc;;;;;;;;;;"}
|
|
@@ -53,6 +53,9 @@ const ITEM_COUNT_TYPOGRAPHY = {
|
|
|
53
53
|
"40": "typography-body-small-14px-regular",
|
|
54
54
|
"32": "typography-body-small-14px-regular"
|
|
55
55
|
};
|
|
56
|
+
const SELECTED_V2_CLASSES = "theme-v2:text-content-primary-inverted theme-v2:data-[highlighted]:bg-menu-item-selected-hover";
|
|
57
|
+
const SELECTED_SECONDARY_V2_CLASSES = "theme-v2:group-data-[selected]:text-content-secondary-inverted theme-v2:group-data-[selected]:group-data-[highlighted]:text-menu-item-selected-hover-secondary";
|
|
58
|
+
const SELECTED_DISABLED_V2_CLASSES = "theme-v2:bg-transparent";
|
|
56
59
|
const DropdownMenuItem = React__namespace.forwardRef(
|
|
57
60
|
({
|
|
58
61
|
size = "40",
|
|
@@ -79,7 +82,7 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
79
82
|
const itemClassName = cn.cn(
|
|
80
83
|
// `text-start` because the sheet variant renders the row as a <button>,
|
|
81
84
|
// whose UA-centred text misaligned it from the popper variant's rows.
|
|
82
|
-
"group flex w-full cursor-pointer gap-2 rounded-sm px-3 text-start outline-none",
|
|
85
|
+
"group flex w-full shrink-0 cursor-pointer gap-2 rounded-sm px-3 text-start outline-none",
|
|
83
86
|
hasDescription ? "items-start" : "items-center",
|
|
84
87
|
// The sheet's header runs the full width of the panel, so its rows have to
|
|
85
88
|
// come in off the edge themselves — 4px here on the panel's own 4px gives the
|
|
@@ -98,9 +101,10 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
98
101
|
// data-disabled — neither selector above matches them.
|
|
99
102
|
"aria-disabled:cursor-not-allowed aria-disabled:text-content-disabled",
|
|
100
103
|
destructive && "text-error-content",
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
selected && [
|
|
105
|
+
"bg-menu-item-selected",
|
|
106
|
+
disabled ? SELECTED_DISABLED_V2_CLASSES : SELECTED_V2_CLASSES
|
|
107
|
+
],
|
|
104
108
|
className
|
|
105
109
|
);
|
|
106
110
|
const selectedProps = selected ? {
|
|
@@ -116,12 +120,22 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
116
120
|
iconAlignClassName,
|
|
117
121
|
ITEM_COUNT_TYPOGRAPHY[normalizedSize],
|
|
118
122
|
destructive ? "text-error-content" : "text-content-tertiary",
|
|
119
|
-
"group-data-[disabled]:text-content-disabled"
|
|
123
|
+
"group-data-[disabled]:text-content-disabled",
|
|
124
|
+
!disabled && SELECTED_SECONDARY_V2_CLASSES
|
|
120
125
|
),
|
|
121
126
|
children: count
|
|
122
127
|
}
|
|
123
128
|
);
|
|
124
|
-
const renderIcon = (icon, className2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
129
|
+
const renderIcon = (icon, className2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
130
|
+
MenuRowIcon.MenuRowIcon,
|
|
131
|
+
{
|
|
132
|
+
inheritColor: destructive,
|
|
133
|
+
alignToTitle: hasDescription,
|
|
134
|
+
invertWhenSelected: !disabled,
|
|
135
|
+
className: className2,
|
|
136
|
+
children: icon
|
|
137
|
+
}
|
|
138
|
+
);
|
|
125
139
|
const leadingNode = leadingIcon != null && renderIcon(leadingIcon);
|
|
126
140
|
const trailingNode = trailingIcon != null && renderIcon(trailingIcon, asChild ? "ms-auto" : void 0);
|
|
127
141
|
const trailingActionNode = trailingAction != null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -136,11 +150,20 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
136
150
|
}
|
|
137
151
|
);
|
|
138
152
|
const itemChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
139
|
-
avatar != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn("shrink-0", iconAlignClassName), children: avatar }) : leadingNode,
|
|
153
|
+
avatar != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn("shrink-0", iconAlignClassName, disabled && "theme-v2:opacity-60"), children: avatar }) : leadingNode,
|
|
140
154
|
hasDescription ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
141
155
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-small-14px-semibold truncate", children }),
|
|
142
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
143
|
-
|
|
156
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
157
|
+
"span",
|
|
158
|
+
{
|
|
159
|
+
className: cn.cn(
|
|
160
|
+
"typography-body-small-14px-regular truncate text-content-secondary",
|
|
161
|
+
disabled ? "theme-v2:text-content-disabled" : SELECTED_SECONDARY_V2_CLASSES
|
|
162
|
+
),
|
|
163
|
+
children: description
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn("min-w-0 flex-1 truncate", selected && "font-semibold"), children }),
|
|
144
167
|
countNode,
|
|
145
168
|
trailingNode,
|
|
146
169
|
trailingActionNode
|
|
@@ -215,7 +238,7 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
215
238
|
DropdownMenuItem.displayName = "DropdownMenuItem";
|
|
216
239
|
const DropdownMenuSeparator = React__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
217
240
|
const variant = React__namespace.useContext(context.DropdownMenuVariantContext);
|
|
218
|
-
const separatorClassName = cn.cn("my-
|
|
241
|
+
const separatorClassName = cn.cn("my-[5px] h-px border-0 bg-neutral-alphas-200", className);
|
|
219
242
|
if (variant === "sheet") {
|
|
220
243
|
return /* @__PURE__ */ jsxRuntime.jsx("hr", { ref, className: separatorClassName, ...props });
|
|
221
244
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuItem.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuItem.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { MenuRowIcon } from \"../Icons/MenuRowIcon\";\nimport { DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\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 const variant = React.useContext(DropdownMenuVariantContext);\n const labelClassName = cn(\n \"typography-description-12px-regular flex items-center px-3 text-content-secondary\",\n position === \"top\" ? \"py-2\" : \"pt-4 pb-2\",\n className,\n );\n\n // DropdownMenuPrimitive.Label requires Radix menu context, unavailable when\n // the sheet variant renders inside a Drawer (Dialog) instead.\n if (variant === \"sheet\") {\n return <div ref={ref} className={labelClassName} {...props} />;\n }\n\n return <DropdownMenuPrimitive.Label ref={ref} className={labelClassName} {...props} />;\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-body-small-14px-regular\",\n \"32\": \"min-h-8 py-[7px] typography-body-small-14px-regular\",\n};\n\n/*\n * 14px at both heights. `V2 Menu Item` draws the count as `Body Small 14px/Regular`\n * in `content-tertiary` (node `21542:8629`), and the 40 row previously stepped up to\n * 16px — which also put the count's line box at 24px against the two-line layout's\n * 18px title leading.\n *\n * Only the 40 row is drawn in Figma: the component set's variants are Type and State\n * with no size axis. The 32 row is ours, and 14px matches the body type it already\n * uses, so both entries agree by construction rather than by design reference.\n */\nconst ITEM_COUNT_TYPOGRAPHY: Record<\"40\" | \"32\", string> = {\n \"40\": \"typography-body-small-14px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\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 /**\n * Icon (or other node) rendered before the label. Ignored when {@link DropdownMenuItemProps.avatar} is set.\n * Icons sit in a 16px box in `Icons/Secondary`, and prop-based icons draw filled at 16px unless they set\n * `filled` or `size` themselves (`filled={false}` opts out). Legacy icons such as `TrashBinIcon` stay outlined.\n */\n leadingIcon?: React.ReactNode;\n /**\n * Leading avatar rendered in place of {@link DropdownMenuItemProps.leadingIcon},\n * for rows that represent a person or account. Pass an `Avatar` sized to `24`.\n * Takes precedence over `leadingIcon`.\n */\n avatar?: React.ReactNode;\n /**\n * Icon (or other node) rendered after the label. Treated like {@link DropdownMenuItemProps.leadingIcon}.\n */\n trailingIcon?: React.ReactNode;\n /** Trailing count or number (e.g. an unread total) rendered before {@link DropdownMenuItemProps.trailingIcon}. */\n count?: React.ReactNode;\n /**\n * A small action drawn at the row's end, after everything else — typically a 24px\n * `Button` rendered `asChild` as a span. The whole row performs the action through\n * `onSelect`, so pass a visual, never a second interactive control. Its text joins the\n * row's accessible name, so the label people see is also the one they can speak.\n * The row does not restyle it: when the row is `disabled`, disable the visual too\n * (or show its `loading` state) so it does not look live.\n */\n trailingAction?: React.ReactNode;\n /**\n * Optional secondary text rendered on a second line below the label. When\n * provided, the row switches to a two-line layout and the leading/trailing\n * icons align to the title line (top) rather than the row's vertical centre.\n */\n description?: 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 * // Feature-rich row with an avatar and a trailing count\n * <DropdownMenuItem avatar={<Avatar size={24} src={src} />} count=\"12\">\n * Jane Doe\n * </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 avatar,\n trailingIcon,\n count,\n trailingAction,\n description,\n selected,\n className,\n children,\n asChild,\n onSelect,\n disabled,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const normalizedSize = SIZE_NORMALIZED[size];\n const hasDescription = description != null;\n const hasAvatar = avatar != null;\n const itemClassName = cn(\n // `text-start` because the sheet variant renders the row as a <button>,\n // whose UA-centred text misaligned it from the popper variant's rows.\n \"group flex w-full cursor-pointer gap-2 rounded-sm px-3 text-start outline-none\",\n hasDescription ? \"items-start\" : \"items-center\",\n // The sheet's header runs the full width of the panel, so its rows have to\n // come in off the edge themselves — 4px here on the panel's own 4px gives the\n // same 8px inset as the popper panel. `w-auto` lets the column stretch them\n // to the space left over; `w-full` plus a margin would overflow.\n variant === \"sheet\" && \"mx-1 w-auto\",\n ITEM_SIZE_CLASSES[normalizedSize],\n // A 24px avatar or trailing action would push the compact 32px row past its\n // height with the default padding; tighten it so the row keeps the 32px contract.\n (hasAvatar || trailingAction != null) && !hasDescription && normalizedSize === \"32\" && \"py-1\",\n \"data-[highlighted]:bg-interaction-hover\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled\",\n \"disabled:cursor-not-allowed disabled:text-content-disabled\",\n // Sheet-variant asChild items are marked disabled via aria-disabled\n // (see below), not the native disabled attribute or Radix's\n // data-disabled — neither selector above matches them.\n \"aria-disabled:cursor-not-allowed aria-disabled:text-content-disabled\",\n destructive && \"text-error-content\",\n // Selected: the same `Interaction/Hover` fill as a highlighted row (library\n // node `23452:13432`), so the current value reads as the resting highlight.\n selected && \"bg-interaction-hover\",\n className,\n );\n // The selected row shares the hover fill, so it also carries the state in the\n // markup: `aria-current` for assistive tech and `data-selected` for styling.\n // A consumer that already exposes the state (e.g. `menuitemradio` with\n // `aria-checked`) keeps it, without a second `aria-current` on top.\n const selectedProps = selected\n ? {\n ...(props[\"aria-checked\"] === undefined && { \"aria-current\": \"true\" as const }),\n \"data-selected\": \"\",\n }\n : undefined;\n\n // In the two-line (description) layout everything beside the title sits on\n // the title's line, not the centre of the two-line block. A box the height of\n // that line centres each sibling on it whatever its own size — a 16px icon, a\n // 24px avatar, or the count's larger text box. The height is the title's, from\n // `typography-body-small-14px-semibold`; a `pt-*` nudge cannot do this because\n // the correct offset differs per sibling, and the previous `pt-1` was computed\n // against the single-line title's 24px leading, leaving all four 3px low.\n const iconAlignClassName = hasDescription ? \"flex h-4.5 shrink-0 items-center\" : null;\n\n const countNode = count != null && (\n <span\n className={cn(\n \"shrink-0 tabular-nums\",\n iconAlignClassName,\n ITEM_COUNT_TYPOGRAPHY[normalizedSize],\n destructive ? \"text-error-content\" : \"text-content-tertiary\",\n \"group-data-[disabled]:text-content-disabled\",\n )}\n >\n {count}\n </span>\n );\n\n // Destructive rows keep the row's error colour on their icons.\n const renderIcon = (icon: React.ReactNode, className?: string) => (\n <MenuRowIcon inheritColor={destructive} alignToTitle={hasDescription} className={className}>\n {icon}\n </MenuRowIcon>\n );\n const leadingNode = leadingIcon != null && renderIcon(leadingIcon);\n\n // In an asChild row the consumer's children have no flex-1 wrapper, so `ms-auto`\n // pushes the trailing icon to the row's end.\n const trailingNode =\n trailingIcon != null && renderIcon(trailingIcon, asChild ? \"ms-auto\" : undefined);\n const trailingActionNode = trailingAction != null && (\n <span\n className={cn(\n \"flex shrink-0 items-center\",\n iconAlignClassName,\n asChild && trailingIcon == null && \"ms-auto\",\n )}\n >\n {trailingAction}\n </span>\n );\n\n const itemChildren = (\n <>\n {avatar != null ? (\n <span className={cn(\"shrink-0\", iconAlignClassName)}>{avatar}</span>\n ) : (\n leadingNode\n )}\n {hasDescription ? (\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n {/*\n * The two-line row sets its own title type rather than inheriting the\n * row's: `V2 Menu Item` pairs a 14px semibold title with the 14px\n * regular description below it, where a single-line row's title is the\n * size's own 14px regular. It also settles the row's height — 18 + 2 +\n * 18 of text inside `py-2` is the design's 54px.\n */}\n <span className=\"typography-body-small-14px-semibold truncate\">{children}</span>\n <span className=\"typography-body-small-14px-regular truncate text-content-secondary\">\n {description}\n </span>\n </span>\n ) : (\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n )}\n {countNode}\n {trailingNode}\n {trailingActionNode}\n </>\n );\n\n // The sheet variant renders inside a Drawer (Dialog), not a Radix menu, so\n // DropdownMenuPrimitive.Item (which requires menu context) can't be used —\n // render a plain option element with equivalent selection semantics instead.\n // asChild goes through the same Slot primitive Radix's own Item uses\n // internally, so a custom element (e.g. a link) gets the option\n // role/handlers merged onto it without needing menu context.\n if (variant === \"sheet\") {\n const Comp = asChild ? Slot : \"button\";\n // Pull the consumer's onClick out of the passthrough spread so the\n // handler below can compose with it instead of the spread order\n // silently overwriting it (an explicit onClick after {...props} always\n // wins over the spread's).\n const { onClick: consumerOnClick, ...restProps } =\n props as React.ComponentPropsWithoutRef<\"button\">;\n const sheetSpecificProps = !asChild\n ? { type: \"button\" as const, disabled }\n : disabled\n ? { \"aria-disabled\": true }\n : {};\n return (\n <Comp\n ref={ref as React.Ref<HTMLButtonElement>}\n {...restProps}\n {...sheetSpecificProps}\n role=\"option\"\n aria-selected={selected}\n data-selected={selected ? \"\" : undefined}\n className={itemClassName}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {\n // A native <button disabled> already blocks its click event, but\n // asChild's element (e.g. a link) has no such enforcement — guard\n // explicitly, and prevent the click's default action (e.g. anchor\n // navigation) since aria-disabled alone doesn't stop it.\n if (disabled) {\n event.preventDefault();\n return;\n }\n consumerOnClick?.(event);\n if (event.defaultPrevented) return;\n // Pass the real native event through, not a fake partial shape —\n // handlers that call any Event API beyond preventDefault (e.g.\n // stopPropagation, composedPath) need it to actually exist. It's\n // still live (currentTarget/target are valid) since we're inside\n // the same synchronous click handler that produced it.\n onSelect?.(event.nativeEvent);\n if (!event.nativeEvent.defaultPrevented) toggleOpen?.(() => false);\n }}\n >\n {asChild\n ? [\n leadingNode,\n <Slottable key=\"children\">{children}</Slottable>,\n trailingNode,\n trailingActionNode,\n ]\n : itemChildren}\n </Comp>\n );\n }\n\n if (asChild) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n asChild\n className={itemClassName}\n disabled={disabled}\n onSelect={onSelect}\n {...selectedProps}\n {...props}\n >\n {/* The icons slot into the consumer's element (e.g. a link) around its own children. */}\n <Slot>\n {leadingNode}\n <Slottable>{children}</Slottable>\n {trailingNode}\n {trailingActionNode}\n </Slot>\n </DropdownMenuPrimitive.Item>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={itemClassName}\n disabled={disabled}\n onSelect={onSelect}\n {...selectedProps}\n {...props}\n >\n {itemChildren}\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 const variant = React.useContext(DropdownMenuVariantContext);\n // border-0 resets the currentColor border-top that preflight gives <hr>,\n // which would otherwise draw a second line on the sheet variant.\n const separatorClassName = cn(\"my-1 h-px border-0 bg-neutral-alphas-200\", className);\n\n // DropdownMenuPrimitive.Separator requires Radix menu context, unavailable\n // when the sheet variant renders inside a Drawer (Dialog) instead. <hr> is a\n // native separator, so it needs no ARIA role.\n if (variant === \"sheet\") {\n return <hr ref={ref as React.Ref<HTMLHRElement>} className={separatorClassName} {...props} />;\n }\n\n return <DropdownMenuPrimitive.Separator ref={ref} className={separatorClassName} {...props} />;\n});\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\";\n"],"names":["React","DropdownMenuVariantContext","cn","jsx","DropdownMenuPrimitive","ToggleOpenContext","className","MenuRowIcon","jsxs","Fragment","Slot","Slottable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,oBAAoBA,iBAAM,WAGrC,CAAC,EAAE,WAAW,WAAW,WAAW,GAAG,MAAA,GAAS,QAAQ;AACxD,QAAM,UAAUA,iBAAM,WAAWC,kCAA0B;AAC3D,QAAM,iBAAiBC,GAAAA;AAAAA,IACrB;AAAA,IACA,aAAa,QAAQ,SAAS;AAAA,IAC9B;AAAA,EAAA;AAKF,MAAI,YAAY,SAAS;AACvB,0CAAQ,OAAA,EAAI,KAAU,WAAW,gBAAiB,GAAG,OAAO;AAAA,EAC9D;AAEA,SAAOC,2BAAAA,IAACC,iCAAsB,OAAtB,EAA4B,KAAU,WAAW,gBAAiB,GAAG,OAAO;AACtF,CAAC;AACD,kBAAkB,cAAc;AAiBhC,MAAM,kBAA6D;AAAA,EACjE,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,IAAI;AACN;AAEA,MAAM,oBAAiD;AAAA,EACrD,MAAM;AAAA,EACN,MAAM;AACR;AAYA,MAAM,wBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AACR;A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,WAAW,oBAAqB,GAAG,OAAO;AAAA,EAC7F;AAEA,SAAOC,2BAAAA,IAACC,iCAAsB,WAAtB,EAAgC,KAAU,WAAW,oBAAqB,GAAG,OAAO;AAC9F,CAAC;AACD,sBAAsB,cAAc;;;;"}
|
|
1
|
+
{"version":3,"file":"DropdownMenuItem.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuItem.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { MenuRowIcon } from \"../Icons/MenuRowIcon\";\nimport { DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\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 const variant = React.useContext(DropdownMenuVariantContext);\n const labelClassName = cn(\n \"typography-description-12px-regular flex items-center px-3 text-content-secondary\",\n position === \"top\" ? \"py-2\" : \"pt-4 pb-2\",\n className,\n );\n\n // DropdownMenuPrimitive.Label requires Radix menu context, unavailable when\n // the sheet variant renders inside a Drawer (Dialog) instead.\n if (variant === \"sheet\") {\n return <div ref={ref} className={labelClassName} {...props} />;\n }\n\n return <DropdownMenuPrimitive.Label ref={ref} className={labelClassName} {...props} />;\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-body-small-14px-regular\",\n \"32\": \"min-h-8 py-[7px] typography-body-small-14px-regular\",\n};\n\n/*\n * 14px at both heights. `V2 Menu Item` draws the count as `Body Small 14px/Regular`\n * in `content-tertiary` (node `21542:8629`), and the 40 row previously stepped up to\n * 16px — which also put the count's line box at 24px against the two-line layout's\n * 18px title leading.\n *\n * Only the 40 row is drawn in Figma: the component set's variants are Type and State\n * with no size axis. The 32 row is ours, and 14px matches the body type it already\n * uses, so both entries agree by construction rather than by design reference.\n */\nconst ITEM_COUNT_TYPOGRAPHY: Record<\"40\" | \"32\", string> = {\n \"40\": \"typography-body-small-14px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\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 /**\n * Icon (or other node) rendered before the label. Ignored when {@link DropdownMenuItemProps.avatar} is set.\n * Icons sit in a 16px box in `Icons/Secondary`, and prop-based icons draw filled at 16px unless they set\n * `filled` or `size` themselves (`filled={false}` opts out). Legacy icons such as `TrashBinIcon` stay outlined.\n */\n leadingIcon?: React.ReactNode;\n /**\n * Leading avatar rendered in place of {@link DropdownMenuItemProps.leadingIcon},\n * for rows that represent a person or account. Pass an `Avatar` sized to `24`.\n * Takes precedence over `leadingIcon`.\n */\n avatar?: React.ReactNode;\n /**\n * Icon (or other node) rendered after the label. Treated like {@link DropdownMenuItemProps.leadingIcon}.\n */\n trailingIcon?: React.ReactNode;\n /** Trailing count or number (e.g. an unread total) rendered before {@link DropdownMenuItemProps.trailingIcon}. */\n count?: React.ReactNode;\n /**\n * A small action drawn at the row's end, after everything else — typically a 24px\n * `Button` rendered `asChild` as a span. The whole row performs the action through\n * `onSelect`, so pass a visual, never a second interactive control. Its text joins the\n * row's accessible name, so the label people see is also the one they can speak.\n * The row does not restyle it: when the row is `disabled`, disable the visual too\n * (or show its `loading` state) so it does not look live.\n */\n trailingAction?: React.ReactNode;\n /**\n * Optional secondary text rendered on a second line below the label. When\n * provided, the row switches to a two-line layout and the leading/trailing\n * icons align to the title line (top) rather than the row's vertical centre.\n */\n description?: React.ReactNode;\n /**\n * Marks the item as the current selection in a single-select menu. The row\n * rests on `Buttons/Navigation/Hover` with a semibold label; hover still shows\n * `Interaction/Hover`, because `data-[highlighted]` outranks the selected class.\n * Under the v2 palette that fill is inverted, with inverted content, and a\n * highlighted row moves to `Menu Item Selected Hover` so keyboard focus stays visible.\n * The row also gets `data-selected`, and `aria-current` unless the consumer\n * already sets `aria-checked`.\n * @default false\n */\n selected?: boolean;\n}\n\n/**\n * Under the v2 palette a selected row's `Menu Item Selected` fill is inverted, so its\n * content inverts too, and a highlighted row moves to `Menu Item Selected Hover`.\n */\nconst SELECTED_V2_CLASSES =\n \"theme-v2:text-content-primary-inverted theme-v2:data-[highlighted]:bg-menu-item-selected-hover\";\n\n/**\n * Secondary lines (description, count) on a selected row under the v2 palette: inverted,\n * and `Menu Item Selected Hover Secondary` while the row is highlighted, so they keep\n * contrast on the hover fill.\n */\nconst SELECTED_SECONDARY_V2_CLASSES =\n \"theme-v2:group-data-[selected]:text-content-secondary-inverted theme-v2:group-data-[selected]:group-data-[highlighted]:text-menu-item-selected-hover-secondary\";\n\n/** A disabled selected row takes the library's Disabled state under the v2 palette, which has no fill. */\nconst SELECTED_DISABLED_V2_CLASSES = \"theme-v2:bg-transparent\";\n\n/**\n * An individual item within a {@link DropdownMenuContent}.\n *\n * Rows do not shrink (`shrink-0`): the panel is a scrolling flex column capped at the\n * space available, and a row allowed to shrink would drop to its minimum height and\n * spill a second line.\n *\n * @example\n * ```tsx\n * <DropdownMenuItem>Edit profile</DropdownMenuItem>\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * <DropdownMenuItem leadingIcon={<EditIcon />}>Edit</DropdownMenuItem>\n *\n * // Feature-rich row with an avatar and a trailing count\n * <DropdownMenuItem avatar={<Avatar size={24} src={src} />} count=\"12\">\n * Jane Doe\n * </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 avatar,\n trailingIcon,\n count,\n trailingAction,\n description,\n selected,\n className,\n children,\n asChild,\n onSelect,\n disabled,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const normalizedSize = SIZE_NORMALIZED[size];\n const hasDescription = description != null;\n const hasAvatar = avatar != null;\n const itemClassName = cn(\n // `text-start` because the sheet variant renders the row as a <button>,\n // whose UA-centred text misaligned it from the popper variant's rows.\n \"group flex w-full shrink-0 cursor-pointer gap-2 rounded-sm px-3 text-start outline-none\",\n hasDescription ? \"items-start\" : \"items-center\",\n // The sheet's header runs the full width of the panel, so its rows have to\n // come in off the edge themselves — 4px here on the panel's own 4px gives the\n // same 8px inset as the popper panel. `w-auto` lets the column stretch them\n // to the space left over; `w-full` plus a margin would overflow.\n variant === \"sheet\" && \"mx-1 w-auto\",\n ITEM_SIZE_CLASSES[normalizedSize],\n // A 24px avatar or trailing action would push the compact 32px row past its\n // height with the default padding; tighten it so the row keeps the 32px contract.\n (hasAvatar || trailingAction != null) && !hasDescription && normalizedSize === \"32\" && \"py-1\",\n \"data-[highlighted]:bg-interaction-hover\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled\",\n \"disabled:cursor-not-allowed disabled:text-content-disabled\",\n // Sheet-variant asChild items are marked disabled via aria-disabled\n // (see below), not the native disabled attribute or Radix's\n // data-disabled — neither selector above matches them.\n \"aria-disabled:cursor-not-allowed aria-disabled:text-content-disabled\",\n destructive && \"text-error-content\",\n selected && [\n \"bg-menu-item-selected\",\n disabled ? SELECTED_DISABLED_V2_CLASSES : SELECTED_V2_CLASSES,\n ],\n className,\n );\n const selectedProps = selected\n ? {\n ...(props[\"aria-checked\"] === undefined && { \"aria-current\": \"true\" as const }),\n \"data-selected\": \"\",\n }\n : undefined;\n\n // In the two-line (description) layout everything beside the title sits on\n // the title's line, not the centre of the two-line block. A box the height of\n // that line centres each sibling on it whatever its own size — a 16px icon, a\n // 24px avatar, or the count's larger text box. The height is the title's, from\n // `typography-body-small-14px-semibold`; a `pt-*` nudge cannot do this because\n // the correct offset differs per sibling, and the previous `pt-1` was computed\n // against the single-line title's 24px leading, leaving all four 3px low.\n const iconAlignClassName = hasDescription ? \"flex h-4.5 shrink-0 items-center\" : null;\n\n const countNode = count != null && (\n <span\n className={cn(\n \"shrink-0 tabular-nums\",\n iconAlignClassName,\n ITEM_COUNT_TYPOGRAPHY[normalizedSize],\n destructive ? \"text-error-content\" : \"text-content-tertiary\",\n \"group-data-[disabled]:text-content-disabled\",\n !disabled && SELECTED_SECONDARY_V2_CLASSES,\n )}\n >\n {count}\n </span>\n );\n\n // Destructive rows keep the row's error colour on their icons.\n const renderIcon = (icon: React.ReactNode, className?: string) => (\n <MenuRowIcon\n inheritColor={destructive}\n alignToTitle={hasDescription}\n invertWhenSelected={!disabled}\n className={className}\n >\n {icon}\n </MenuRowIcon>\n );\n const leadingNode = leadingIcon != null && renderIcon(leadingIcon);\n\n // In an asChild row the consumer's children have no flex-1 wrapper, so `ms-auto`\n // pushes the trailing icon to the row's end.\n const trailingNode =\n trailingIcon != null && renderIcon(trailingIcon, asChild ? \"ms-auto\" : undefined);\n const trailingActionNode = trailingAction != null && (\n <span\n className={cn(\n \"flex shrink-0 items-center\",\n iconAlignClassName,\n asChild && trailingIcon == null && \"ms-auto\",\n )}\n >\n {trailingAction}\n </span>\n );\n\n const itemChildren = (\n <>\n {avatar != null ? (\n <span className={cn(\"shrink-0\", iconAlignClassName, disabled && \"theme-v2:opacity-60\")}>\n {avatar}\n </span>\n ) : (\n leadingNode\n )}\n {hasDescription ? (\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n {/*\n * The two-line row sets its own title type rather than inheriting the\n * row's: `V2 Menu Item` pairs a 14px semibold title with the 14px\n * regular description below it, where a single-line row's title is the\n * size's own 14px regular. It also settles the row's height — 18 + 2 +\n * 18 of text inside `py-2` is the design's 54px.\n */}\n <span className=\"typography-body-small-14px-semibold truncate\">{children}</span>\n <span\n className={cn(\n \"typography-body-small-14px-regular truncate text-content-secondary\",\n disabled ? \"theme-v2:text-content-disabled\" : SELECTED_SECONDARY_V2_CLASSES,\n )}\n >\n {description}\n </span>\n </span>\n ) : (\n <span className={cn(\"min-w-0 flex-1 truncate\", selected && \"font-semibold\")}>\n {children}\n </span>\n )}\n {countNode}\n {trailingNode}\n {trailingActionNode}\n </>\n );\n\n // The sheet variant renders inside a Drawer (Dialog), not a Radix menu, so\n // DropdownMenuPrimitive.Item (which requires menu context) can't be used —\n // render a plain option element with equivalent selection semantics instead.\n // asChild goes through the same Slot primitive Radix's own Item uses\n // internally, so a custom element (e.g. a link) gets the option\n // role/handlers merged onto it without needing menu context.\n if (variant === \"sheet\") {\n const Comp = asChild ? Slot : \"button\";\n // Pull the consumer's onClick out of the passthrough spread so the\n // handler below can compose with it instead of the spread order\n // silently overwriting it (an explicit onClick after {...props} always\n // wins over the spread's).\n const { onClick: consumerOnClick, ...restProps } =\n props as React.ComponentPropsWithoutRef<\"button\">;\n const sheetSpecificProps = !asChild\n ? { type: \"button\" as const, disabled }\n : disabled\n ? { \"aria-disabled\": true }\n : {};\n return (\n <Comp\n ref={ref as React.Ref<HTMLButtonElement>}\n {...restProps}\n {...sheetSpecificProps}\n role=\"option\"\n aria-selected={selected}\n data-selected={selected ? \"\" : undefined}\n className={itemClassName}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {\n // A native <button disabled> already blocks its click event, but\n // asChild's element (e.g. a link) has no such enforcement — guard\n // explicitly, and prevent the click's default action (e.g. anchor\n // navigation) since aria-disabled alone doesn't stop it.\n if (disabled) {\n event.preventDefault();\n return;\n }\n consumerOnClick?.(event);\n if (event.defaultPrevented) return;\n // Pass the real native event through, not a fake partial shape —\n // handlers that call any Event API beyond preventDefault (e.g.\n // stopPropagation, composedPath) need it to actually exist. It's\n // still live (currentTarget/target are valid) since we're inside\n // the same synchronous click handler that produced it.\n onSelect?.(event.nativeEvent);\n if (!event.nativeEvent.defaultPrevented) toggleOpen?.(() => false);\n }}\n >\n {asChild\n ? [\n leadingNode,\n <Slottable key=\"children\">{children}</Slottable>,\n trailingNode,\n trailingActionNode,\n ]\n : itemChildren}\n </Comp>\n );\n }\n\n if (asChild) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n asChild\n className={itemClassName}\n disabled={disabled}\n onSelect={onSelect}\n {...selectedProps}\n {...props}\n >\n {/* The icons slot into the consumer's element (e.g. a link) around its own children. */}\n <Slot>\n {leadingNode}\n <Slottable>{children}</Slottable>\n {trailingNode}\n {trailingActionNode}\n </Slot>\n </DropdownMenuPrimitive.Item>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={itemClassName}\n disabled={disabled}\n onSelect={onSelect}\n {...selectedProps}\n {...props}\n >\n {itemChildren}\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 const variant = React.useContext(DropdownMenuVariantContext);\n // border-0 resets the currentColor border-top that preflight gives <hr>,\n // which would otherwise draw a second line on the sheet variant.\n const separatorClassName = cn(\"my-[5px] h-px border-0 bg-neutral-alphas-200\", className);\n\n // DropdownMenuPrimitive.Separator requires Radix menu context, unavailable\n // when the sheet variant renders inside a Drawer (Dialog) instead. <hr> is a\n // native separator, so it needs no ARIA role.\n if (variant === \"sheet\") {\n return <hr ref={ref as React.Ref<HTMLHRElement>} className={separatorClassName} {...props} />;\n }\n\n return <DropdownMenuPrimitive.Separator ref={ref} className={separatorClassName} {...props} />;\n});\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\";\n"],"names":["React","DropdownMenuVariantContext","cn","jsx","DropdownMenuPrimitive","ToggleOpenContext","className","MenuRowIcon","jsxs","Fragment","Slot","Slottable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,oBAAoBA,iBAAM,WAGrC,CAAC,EAAE,WAAW,WAAW,WAAW,GAAG,MAAA,GAAS,QAAQ;AACxD,QAAM,UAAUA,iBAAM,WAAWC,kCAA0B;AAC3D,QAAM,iBAAiBC,GAAAA;AAAAA,IACrB;AAAA,IACA,aAAa,QAAQ,SAAS;AAAA,IAC9B;AAAA,EAAA;AAKF,MAAI,YAAY,SAAS;AACvB,0CAAQ,OAAA,EAAI,KAAU,WAAW,gBAAiB,GAAG,OAAO;A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WAAW;AAAA,UACX;AAAA,UACA;AAAA,UACC,GAAG;AAAA,UACH,GAAG;AAAA,UAGJ,0CAACM,gBAAA,EACE,UAAA;AAAA,YAAA;AAAA,YACDP,+BAACQ,UAAAA,aAAW,UAAS;AAAA,YACpB;AAAA,YACA;AAAA,UAAA,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN;AAEA,WACER,2BAAAA;AAAAA,MAACC,iCAAsB;AAAA,MAAtB;AAAA,QACC;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACH,GAAG;AAAA,QAEH,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AACA,iBAAiB,cAAc;AAOxB,MAAM,wBAAwBJ,iBAAM,WAGzC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAAQ;AAClC,QAAM,UAAUA,iBAAM,WAAWC,kCAA0B;AAG3D,QAAM,qBAAqBC,GAAAA,GAAG,gDAAgD,SAAS;AAKvF,MAAI,YAAY,SAAS;AACvB,0CAAQ,MAAA,EAAG,KAAsC,WAAW,oBAAqB,GAAG,OAAO;AAAA,EAC7F;AAEA,SAAOC,2BAAAA,IAACC,iCAAsB,WAAtB,EAAgC,KAAU,WAAW,oBAAqB,GAAG,OAAO;AAC9F,CAAC;AACD,sBAAsB,cAAc;;;;"}
|
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const reactDom = require("react-dom");
|
|
7
7
|
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const pointerCapture = require("../../utils/pointerCapture.cjs");
|
|
8
9
|
const MenuRowIcon = require("../Icons/MenuRowIcon.cjs");
|
|
9
10
|
const context = require("./context.cjs");
|
|
10
11
|
const reorderShared = require("./reorderShared.cjs");
|
|
@@ -137,7 +138,7 @@ const DropdownMenuReorderItem = React__namespace.forwardRef(
|
|
|
137
138
|
if (!canStartReorderDrag(event, handleRef.current)) return;
|
|
138
139
|
if (!actions.startDrag(value, event, element)) return;
|
|
139
140
|
event.preventDefault();
|
|
140
|
-
|
|
141
|
+
pointerCapture.capturePointer(element, event.pointerId);
|
|
141
142
|
},
|
|
142
143
|
onPointerMove: (event) => {
|
|
143
144
|
onPointerMove?.(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuReorderItem.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuReorderItem.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils/cn\";\nimport { MenuRowIcon } from \"../Icons/MenuRowIcon\";\nimport { DropdownMenuVariantContext } from \"./context\";\nimport {\n DragHandleDots,\n type ReorderActions,\n ReorderActionsContext,\n type ReorderLifted,\n ReorderLiftedContext,\n} from \"./reorderShared\";\n\nconst INTERACTIVE_CONTROL_SELECTOR = 'button, a[href], input, select, textarea, [role=\"button\"]';\n\n// A drag starts from a primary mouse button anywhere on the row — except on\n// another control inside it (a `trailing` action, say), which keeps its click\n// and focus — or from the drag handle only for touch/pen, so the rest of the\n// row still scrolls a long menu with a finger.\nfunction canStartReorderDrag(event: React.PointerEvent, handle: HTMLElement | null): boolean {\n if (event.defaultPrevented || !(event.target instanceof Element)) return false;\n const onHandle = handle?.contains(event.target) === true;\n if (event.pointerType !== \"mouse\") return onHandle;\n if (event.button !== 0) return false;\n return onHandle || event.target.closest(INTERACTIVE_CONTROL_SELECTOR) === null;\n}\n\n// pointerdown's preventDefault (needed to stop text selection) also suppresses\n// focus, so a plain click on the grip focuses it here — ArrowUp/Down then work.\nfunction focusHandleAfterClick(event: React.PointerEvent, handle: HTMLElement | null): void {\n if (handle !== null && event.target instanceof Node && handle.contains(event.target)) {\n handle.focus({ preventScroll: true });\n }\n}\n// Icon, label and trailing slot of a row — rendered once in the row itself and\n// again inside its floating copy while lifted.\nfunction ReorderRowContent({\n leadingIcon,\n trailing,\n children,\n}: Pick<DropdownMenuReorderItemProps, \"leadingIcon\" | \"trailing\" | \"children\">) {\n return (\n <>\n {leadingIcon != null && <MenuRowIcon>{leadingIcon}</MenuRowIcon>}\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n {trailing != null && <span className=\"shrink-0\">{trailing}</span>}\n </>\n );\n}\n\n// The floating copy of a lifted row. Anchored at the viewport origin and moved\n// with a transform (see the group's positionGhost) so each pointer move is\n// compositor work only.\nfunction ReorderGhost({\n lifted,\n registerGhost,\n container,\n children,\n}: {\n lifted: ReorderLifted;\n registerGhost: ReorderActions[\"registerGhost\"];\n container: Element;\n children: React.ReactNode;\n}) {\n return createPortal(\n <div\n aria-hidden=\"true\"\n data-reorder-ghost=\"\"\n ref={registerGhost}\n className=\"pointer-events-none fixed top-0 left-0 will-change-transform\"\n style={{ width: lifted.width, zIndex: lifted.zIndex }}\n >\n {/*\n * The design draws the floating copy as frosted glass — a translucent\n * surface with a heavy backdrop blur and no drop shadow (the same\n * treatment the panel itself gets) — so what the ghost passes over\n * smears through it.\n */}\n <div className=\"overflow-hidden rounded-sm bg-surface-primary/65 backdrop-blur-[20px]\">\n <div className=\"typography-body-small-14px-regular flex min-h-10 items-center gap-2 bg-neutral-alphas-100 py-2 pr-6 pl-3 text-content-primary\">\n <DragHandleDots className=\"size-4 shrink-0 text-icons-tertiary\" />\n {children}\n </div>\n </div>\n </div>,\n container,\n );\n}\n\n/** Props for the {@link DropdownMenuReorderItem} component. */\nexport interface DropdownMenuReorderItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Value identifying this item within the parent group's `values`. */\n value: string;\n /**\n * Plain-text name used in the group's screen-reader announcements and\n * reported in `onReorder`'s detail. Defaults to `children` when that is a\n * string or number, then to `value` — so pass it whenever `value` is an id.\n */\n label?: string;\n /** Icon (or other node) rendered between the drag handle and the label. */\n leadingIcon?: React.ReactNode;\n /** Content rendered at the end of the row, e.g. an item count. */\n trailing?: React.ReactNode;\n /** Accessible label for the drag handle button. @default \"Reorder\" */\n dragHandleLabel?: string;\n /** Disables dragging and keyboard reordering for this item. @default false */\n disabled?: boolean;\n}\n\n/**\n * A draggable row within a {@link DropdownMenuReorderGroup}. Shows the drag\n * handle grip, dims in place while its floating copy follows the pointer, and\n * supports ArrowUp/ArrowDown reordering when the handle has focus.\n */\nexport const DropdownMenuReorderItem = React.forwardRef<\n HTMLDivElement,\n DropdownMenuReorderItemProps\n>(\n (\n {\n value,\n label,\n leadingIcon,\n trailing,\n dragHandleLabel = \"Reorder\",\n disabled,\n className,\n children,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n ...props\n },\n ref,\n ) => {\n const actions = React.useContext(ReorderActionsContext);\n const lifted = React.useContext(ReorderLiftedContext);\n const variant = React.useContext(DropdownMenuVariantContext);\n const elementRef = React.useRef<HTMLDivElement | null>(null);\n const handleRef = React.useRef<HTMLButtonElement | null>(null);\n const liftedHere = lifted !== null && lifted.value === value ? lifted : null;\n const isLifted = liftedHere !== null;\n const resolvedLabel =\n label ??\n (typeof children === \"string\" || typeof children === \"number\" ? String(children) : value);\n const grabCursor = isLifted ? \"cursor-grabbing\" : \"cursor-grab\";\n // The design dims the lifted source row as a whole — 60% opacity over its\n // own colours — rather than swapping to the disabled tone.\n const rowStateClasses = disabled\n ? \"cursor-default text-content-disabled\"\n : cn(grabCursor, isLifted ? \"opacity-60\" : \"hover:bg-neutral-alphas-50\");\n const handleStateClasses = disabled\n ? \"cursor-not-allowed [&>svg]:text-content-disabled\"\n : grabCursor;\n\n const setElement = React.useCallback(\n (node: HTMLDivElement | null) => {\n elementRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n },\n [ref],\n );\n\n // Registered from an effect, not the ref callback, so re-renders don't\n // churn the group's registry with a delete + set per row.\n React.useLayoutEffect(() => {\n const element = elementRef.current;\n if (actions === null || element === null) return;\n actions.registerItem(value, { element, label: resolvedLabel });\n return () => actions.registerItem(value, null);\n }, [actions, value, resolvedLabel]);\n\n const rowContent = (\n <ReorderRowContent leadingIcon={leadingIcon} trailing={trailing}>\n {children}\n </ReorderRowContent>\n );\n\n return (\n <div\n ref={setElement}\n data-dragging={isLifted || undefined}\n className={cn(\n \"typography-body-small-14px-regular group relative flex min-h-10 w-full select-none items-center gap-2 rounded-sm px-3 py-2 text-content-primary\",\n variant === \"sheet\" && \"mx-1 w-auto\",\n rowStateClasses,\n className,\n )}\n {...props}\n onPointerDown={(event) => {\n onPointerDown?.(event);\n const element = elementRef.current;\n if (disabled || actions === null || element === null) return;\n if (!canStartReorderDrag(event, handleRef.current)) return;\n if (!actions.startDrag(value, event, element)) return;\n event.preventDefault();\n element.setPointerCapture?.(event.pointerId);\n }}\n onPointerMove={(event) => {\n onPointerMove?.(event);\n actions?.updateDrag(event);\n }}\n onPointerUp={(event) => {\n onPointerUp?.(event);\n actions?.endDrag(event.pointerId, true);\n if (!isLifted) focusHandleAfterClick(event, handleRef.current);\n }}\n onPointerCancel={(event) => {\n onPointerCancel?.(event);\n actions?.endDrag(event.pointerId, false);\n }}\n >\n <button\n ref={handleRef}\n type=\"button\"\n aria-label={dragHandleLabel}\n aria-describedby={actions?.instructionsId}\n disabled={disabled}\n className={cn(\n \"relative flex size-4 shrink-0 touch-none items-center justify-center rounded-2xs outline-none focus-visible:shadow-focus-ring\",\n // The grip draws at 16px but is the only touch drag affordance, so\n // its hit area extends 12px each way to the row's edges — a 40px\n // target — without changing the glyph.\n \"before:absolute before:-inset-3 before:content-['']\",\n handleStateClasses,\n )}\n onKeyDown={(event) => {\n if (event.key !== \"ArrowUp\" && event.key !== \"ArrowDown\") return;\n event.preventDefault();\n event.stopPropagation();\n actions?.moveItem(value, event.key === \"ArrowUp\" ? -1 : 1);\n }}\n >\n <DragHandleDots className=\"size-4 text-icons-tertiary\" />\n </button>\n {rowContent}\n {liftedHere !== null && actions !== null && (\n <ReorderGhost\n lifted={liftedHere}\n registerGhost={actions.registerGhost}\n container={elementRef.current?.ownerDocument.body ?? document.body}\n >\n {rowContent}\n </ReorderGhost>\n )}\n </div>\n );\n },\n);\nDropdownMenuReorderItem.displayName = \"DropdownMenuReorderItem\";\n"],"names":["jsxs","Fragment","jsx","MenuRowIcon","createPortal","DragHandleDots","React","ReorderActionsContext","ReorderLiftedContext","DropdownMenuVariantContext","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,+BAA+B;AAMrC,SAAS,oBAAoB,OAA2B,QAAqC;AAC3F,MAAI,MAAM,oBAAoB,EAAE,MAAM,kBAAkB,SAAU,QAAO;AACzE,QAAM,WAAW,QAAQ,SAAS,MAAM,MAAM,MAAM;AACpD,MAAI,MAAM,gBAAgB,QAAS,QAAO;AAC1C,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO,YAAY,MAAM,OAAO,QAAQ,4BAA4B,MAAM;AAC5E;AAIA,SAAS,sBAAsB,OAA2B,QAAkC;AAC1F,MAAI,WAAW,QAAQ,MAAM,kBAAkB,QAAQ,OAAO,SAAS,MAAM,MAAM,GAAG;AACpF,WAAO,MAAM,EAAE,eAAe,KAAA,CAAM;AAAA,EACtC;AACF;AAGA,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,GAAgF;AAC9E,SACEA,2BAAAA,KAAAC,qBAAA,EACG,UAAA;AAAA,IAAA,eAAe,QAAQC,2BAAAA,IAACC,YAAAA,aAAA,EAAa,UAAA,aAAY;AAAA,IAClDD,2BAAAA,IAAC,QAAA,EAAK,WAAU,2BAA2B,SAAA,CAAS;AAAA,IACnD,YAAY,QAAQA,2BAAAA,IAAC,QAAA,EAAK,WAAU,YAAY,UAAA,SAAA,CAAS;AAAA,EAAA,GAC5D;AAEJ;AAKA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,SAAOE,SAAAA;AAAAA,IACLF,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,eAAY;AAAA,QACZ,sBAAmB;A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,QAEA,UAAA;AAAA,UAAAR,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,MAAK;AAAA,cACL,cAAY;AAAA,cACZ,oBAAkB,SAAS;AAAA,cAC3B;AAAA,cACA,WAAWQ,GAAAA;AAAAA,gBACT;AAAA;AAAA;AAAA;AAAA,gBAIA;AAAA,gBACA;AAAA,cAAA;AAAA,cAEF,WAAW,CAAC,UAAU;AACpB,oBAAI,MAAM,QAAQ,aAAa,MAAM,QAAQ,YAAa;AAC1D,sBAAM,eAAA;AACN,sBAAM,gBAAA;AACN,yBAAS,SAAS,OAAO,MAAM,QAAQ,YAAY,KAAK,CAAC;AAAA,cAC3D;AAAA,cAEA,UAAAR,2BAAAA,IAACG,cAAAA,gBAAA,EAAe,WAAU,6BAAA,CAA6B;AAAA,YAAA;AAAA,UAAA;AAAA,UAExD;AAAA,UACA,eAAe,QAAQ,YAAY,QAClCH,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,QAAQ;AAAA,cACR,eAAe,QAAQ;AAAA,cACvB,WAAW,WAAW,SAAS,cAAc,QAAQ,SAAS;AAAA,cAE7D,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AACA,wBAAwB,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"DropdownMenuReorderItem.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuReorderItem.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils/cn\";\nimport { capturePointer } from \"../../utils/pointerCapture\";\nimport { MenuRowIcon } from \"../Icons/MenuRowIcon\";\nimport { DropdownMenuVariantContext } from \"./context\";\nimport {\n DragHandleDots,\n type ReorderActions,\n ReorderActionsContext,\n type ReorderLifted,\n ReorderLiftedContext,\n} from \"./reorderShared\";\n\nconst INTERACTIVE_CONTROL_SELECTOR = 'button, a[href], input, select, textarea, [role=\"button\"]';\n\n// A drag starts from a primary mouse button anywhere on the row — except on\n// another control inside it (a `trailing` action, say), which keeps its click\n// and focus — or from the drag handle only for touch/pen, so the rest of the\n// row still scrolls a long menu with a finger.\nfunction canStartReorderDrag(event: React.PointerEvent, handle: HTMLElement | null): boolean {\n if (event.defaultPrevented || !(event.target instanceof Element)) return false;\n const onHandle = handle?.contains(event.target) === true;\n if (event.pointerType !== \"mouse\") return onHandle;\n if (event.button !== 0) return false;\n return onHandle || event.target.closest(INTERACTIVE_CONTROL_SELECTOR) === null;\n}\n\n// pointerdown's preventDefault (needed to stop text selection) also suppresses\n// focus, so a plain click on the grip focuses it here — ArrowUp/Down then work.\nfunction focusHandleAfterClick(event: React.PointerEvent, handle: HTMLElement | null): void {\n if (handle !== null && event.target instanceof Node && handle.contains(event.target)) {\n handle.focus({ preventScroll: true });\n }\n}\n// Icon, label and trailing slot of a row — rendered once in the row itself and\n// again inside its floating copy while lifted.\nfunction ReorderRowContent({\n leadingIcon,\n trailing,\n children,\n}: Pick<DropdownMenuReorderItemProps, \"leadingIcon\" | \"trailing\" | \"children\">) {\n return (\n <>\n {leadingIcon != null && <MenuRowIcon>{leadingIcon}</MenuRowIcon>}\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n {trailing != null && <span className=\"shrink-0\">{trailing}</span>}\n </>\n );\n}\n\n// The floating copy of a lifted row. Anchored at the viewport origin and moved\n// with a transform (see the group's positionGhost) so each pointer move is\n// compositor work only.\nfunction ReorderGhost({\n lifted,\n registerGhost,\n container,\n children,\n}: {\n lifted: ReorderLifted;\n registerGhost: ReorderActions[\"registerGhost\"];\n container: Element;\n children: React.ReactNode;\n}) {\n return createPortal(\n <div\n aria-hidden=\"true\"\n data-reorder-ghost=\"\"\n ref={registerGhost}\n className=\"pointer-events-none fixed top-0 left-0 will-change-transform\"\n style={{ width: lifted.width, zIndex: lifted.zIndex }}\n >\n {/*\n * The design draws the floating copy as frosted glass — a translucent\n * surface with a heavy backdrop blur and no drop shadow (the same\n * treatment the panel itself gets) — so what the ghost passes over\n * smears through it.\n */}\n <div className=\"overflow-hidden rounded-sm bg-surface-primary/65 backdrop-blur-[20px]\">\n <div className=\"typography-body-small-14px-regular flex min-h-10 items-center gap-2 bg-neutral-alphas-100 py-2 pr-6 pl-3 text-content-primary\">\n <DragHandleDots className=\"size-4 shrink-0 text-icons-tertiary\" />\n {children}\n </div>\n </div>\n </div>,\n container,\n );\n}\n\n/** Props for the {@link DropdownMenuReorderItem} component. */\nexport interface DropdownMenuReorderItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Value identifying this item within the parent group's `values`. */\n value: string;\n /**\n * Plain-text name used in the group's screen-reader announcements and\n * reported in `onReorder`'s detail. Defaults to `children` when that is a\n * string or number, then to `value` — so pass it whenever `value` is an id.\n */\n label?: string;\n /** Icon (or other node) rendered between the drag handle and the label. */\n leadingIcon?: React.ReactNode;\n /** Content rendered at the end of the row, e.g. an item count. */\n trailing?: React.ReactNode;\n /** Accessible label for the drag handle button. @default \"Reorder\" */\n dragHandleLabel?: string;\n /** Disables dragging and keyboard reordering for this item. @default false */\n disabled?: boolean;\n}\n\n/**\n * A draggable row within a {@link DropdownMenuReorderGroup}. Shows the drag\n * handle grip, dims in place while its floating copy follows the pointer, and\n * supports ArrowUp/ArrowDown reordering when the handle has focus.\n */\nexport const DropdownMenuReorderItem = React.forwardRef<\n HTMLDivElement,\n DropdownMenuReorderItemProps\n>(\n (\n {\n value,\n label,\n leadingIcon,\n trailing,\n dragHandleLabel = \"Reorder\",\n disabled,\n className,\n children,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n ...props\n },\n ref,\n ) => {\n const actions = React.useContext(ReorderActionsContext);\n const lifted = React.useContext(ReorderLiftedContext);\n const variant = React.useContext(DropdownMenuVariantContext);\n const elementRef = React.useRef<HTMLDivElement | null>(null);\n const handleRef = React.useRef<HTMLButtonElement | null>(null);\n const liftedHere = lifted !== null && lifted.value === value ? lifted : null;\n const isLifted = liftedHere !== null;\n const resolvedLabel =\n label ??\n (typeof children === \"string\" || typeof children === \"number\" ? String(children) : value);\n const grabCursor = isLifted ? \"cursor-grabbing\" : \"cursor-grab\";\n // The design dims the lifted source row as a whole — 60% opacity over its\n // own colours — rather than swapping to the disabled tone.\n const rowStateClasses = disabled\n ? \"cursor-default text-content-disabled\"\n : cn(grabCursor, isLifted ? \"opacity-60\" : \"hover:bg-neutral-alphas-50\");\n const handleStateClasses = disabled\n ? \"cursor-not-allowed [&>svg]:text-content-disabled\"\n : grabCursor;\n\n const setElement = React.useCallback(\n (node: HTMLDivElement | null) => {\n elementRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n },\n [ref],\n );\n\n // Registered from an effect, not the ref callback, so re-renders don't\n // churn the group's registry with a delete + set per row.\n React.useLayoutEffect(() => {\n const element = elementRef.current;\n if (actions === null || element === null) return;\n actions.registerItem(value, { element, label: resolvedLabel });\n return () => actions.registerItem(value, null);\n }, [actions, value, resolvedLabel]);\n\n const rowContent = (\n <ReorderRowContent leadingIcon={leadingIcon} trailing={trailing}>\n {children}\n </ReorderRowContent>\n );\n\n return (\n <div\n ref={setElement}\n data-dragging={isLifted || undefined}\n className={cn(\n \"typography-body-small-14px-regular group relative flex min-h-10 w-full select-none items-center gap-2 rounded-sm px-3 py-2 text-content-primary\",\n variant === \"sheet\" && \"mx-1 w-auto\",\n rowStateClasses,\n className,\n )}\n {...props}\n onPointerDown={(event) => {\n onPointerDown?.(event);\n const element = elementRef.current;\n if (disabled || actions === null || element === null) return;\n if (!canStartReorderDrag(event, handleRef.current)) return;\n if (!actions.startDrag(value, event, element)) return;\n event.preventDefault();\n capturePointer(element, event.pointerId);\n }}\n onPointerMove={(event) => {\n onPointerMove?.(event);\n actions?.updateDrag(event);\n }}\n onPointerUp={(event) => {\n onPointerUp?.(event);\n actions?.endDrag(event.pointerId, true);\n if (!isLifted) focusHandleAfterClick(event, handleRef.current);\n }}\n onPointerCancel={(event) => {\n onPointerCancel?.(event);\n actions?.endDrag(event.pointerId, false);\n }}\n >\n <button\n ref={handleRef}\n type=\"button\"\n aria-label={dragHandleLabel}\n aria-describedby={actions?.instructionsId}\n disabled={disabled}\n className={cn(\n \"relative flex size-4 shrink-0 touch-none items-center justify-center rounded-2xs outline-none focus-visible:shadow-focus-ring\",\n // The grip draws at 16px but is the only touch drag affordance, so\n // its hit area extends 12px each way to the row's edges — a 40px\n // target — without changing the glyph.\n \"before:absolute before:-inset-3 before:content-['']\",\n handleStateClasses,\n )}\n onKeyDown={(event) => {\n if (event.key !== \"ArrowUp\" && event.key !== \"ArrowDown\") return;\n event.preventDefault();\n event.stopPropagation();\n actions?.moveItem(value, event.key === \"ArrowUp\" ? -1 : 1);\n }}\n >\n <DragHandleDots className=\"size-4 text-icons-tertiary\" />\n </button>\n {rowContent}\n {liftedHere !== null && actions !== null && (\n <ReorderGhost\n lifted={liftedHere}\n registerGhost={actions.registerGhost}\n container={elementRef.current?.ownerDocument.body ?? document.body}\n >\n {rowContent}\n </ReorderGhost>\n )}\n </div>\n );\n },\n);\nDropdownMenuReorderItem.displayName = \"DropdownMenuReorderItem\";\n"],"names":["jsxs","Fragment","jsx","MenuRowIcon","createPortal","DragHandleDots","React","ReorderActionsContext","ReorderLiftedContext","DropdownMenuVariantContext","cn","capturePointer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,+BAA+B;AAMrC,SAAS,oBAAoB,OAA2B,QAAqC;AAC3F,MAAI,MAAM,oBAAoB,EAAE,MAAM,kBAAkB,SAAU,QAAO;AACzE,QAAM,WAAW,QAAQ,SAAS,MAAM,MAAM,MAAM;AACpD,MAAI,MAAM,gBAAgB,QAAS,QAAO;AAC1C,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO,YAAY,MAAM,OAAO,QAAQ,4BAA4B,MAAM;AAC5E;AAIA,SAAS,sBAAsB,OAA2B,QAAkC;AAC1F,MAAI,WAAW,QAAQ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AAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,QAAQ;AAAA,cACR,eAAe,QAAQ;AAAA,cACvB,WAAW,WAAW,SAAS,cAAc,QAAQ,SAAS;AAAA,cAE7D,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AACA,wBAAwB,cAAc;;"}
|
|
@@ -7,6 +7,8 @@ const reactUseControllableState = require("@radix-ui/react-use-controllable-stat
|
|
|
7
7
|
const React = require("react");
|
|
8
8
|
const cn = require("../../utils/cn.cjs");
|
|
9
9
|
const floatingContentCollisionPadding = require("../../utils/floatingContentCollisionPadding.cjs");
|
|
10
|
+
const floatingContentSurface = require("../../utils/floatingContentSurface.cjs");
|
|
11
|
+
const pointerCapture = require("../../utils/pointerCapture.cjs");
|
|
10
12
|
const Drawer = require("../Drawer/Drawer.cjs");
|
|
11
13
|
const IconDefaults = require("../Icons/IconDefaults.cjs");
|
|
12
14
|
const context = require("./context.cjs");
|
|
@@ -89,7 +91,7 @@ const DropdownMenuTrigger = React__namespace.forwardRef((props, ref) => {
|
|
|
89
91
|
onPointerDown: (event) => {
|
|
90
92
|
props.onPointerDown?.(event);
|
|
91
93
|
if (event.pointerType === "mouse" || props.disabled) return;
|
|
92
|
-
event.currentTarget
|
|
94
|
+
pointerCapture.capturePointer(event.currentTarget, event.pointerId);
|
|
93
95
|
tapRef.current = {
|
|
94
96
|
pointerId: event.pointerId,
|
|
95
97
|
x: event.clientX,
|
|
@@ -156,7 +158,7 @@ const DropdownMenuContent = React__namespace.forwardRef(
|
|
|
156
158
|
position: "bottom",
|
|
157
159
|
variant: "menu",
|
|
158
160
|
overlayProps: { className: "backdrop-blur-[8px]" },
|
|
159
|
-
className: cn.cn("flex flex-col gap-
|
|
161
|
+
className: cn.cn("flex flex-col gap-[3px] p-1 pb-2", className),
|
|
160
162
|
style,
|
|
161
163
|
onPointerDownOutside,
|
|
162
164
|
onCloseAutoFocus,
|
|
@@ -186,15 +188,11 @@ const DropdownMenuContent = React__namespace.forwardRef(
|
|
|
186
188
|
sideOffset,
|
|
187
189
|
collisionPadding,
|
|
188
190
|
className: cn.cn(
|
|
189
|
-
//
|
|
190
|
-
// `
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// `backdrop-blur-xs` (4px) is the CSS equivalent of that effect's
|
|
195
|
-
// BACKGROUND_BLUR radius 8, which Figma halves on export. It is not a
|
|
196
|
-
// 4-against-8 mismatch.
|
|
197
|
-
"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-md border border-border-strong bg-background-secondary p-2 text-content-primary shadow-blur-menu backdrop-blur-xs",
|
|
191
|
+
// The surface is shared with Select and Popover. `V2 Menu Dropdown`
|
|
192
|
+
// (library node `17245:2317`) adds 8px of padding here. Rows inside it
|
|
193
|
+
// are 12px `rounded-sm`, the library's `V2 Menu Item` radius.
|
|
194
|
+
floatingContentSurface.FLOATING_CONTENT_SURFACE_CLASS,
|
|
195
|
+
"flex w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) flex-col gap-[3px] overflow-y-auto p-2",
|
|
198
196
|
"data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in",
|
|
199
197
|
"data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out",
|
|
200
198
|
"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2",
|
|
@@ -202,7 +200,7 @@ const DropdownMenuContent = React__namespace.forwardRef(
|
|
|
202
200
|
className
|
|
203
201
|
),
|
|
204
202
|
style: {
|
|
205
|
-
zIndex:
|
|
203
|
+
zIndex: floatingContentSurface.FLOATING_CONTENT_Z_INDEX,
|
|
206
204
|
maxHeight: "var(--radix-dropdown-menu-content-available-height)",
|
|
207
205
|
...style
|
|
208
206
|
},
|
|
@@ -213,7 +211,14 @@ const DropdownMenuContent = React__namespace.forwardRef(
|
|
|
213
211
|
}
|
|
214
212
|
);
|
|
215
213
|
DropdownMenuContent.displayName = "DropdownMenuContent";
|
|
216
|
-
const DropdownMenuGroup =
|
|
214
|
+
const DropdownMenuGroup = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
215
|
+
DropdownMenuPrimitive__namespace.Group,
|
|
216
|
+
{
|
|
217
|
+
ref,
|
|
218
|
+
className: cn.cn("flex flex-col gap-[3px]", className),
|
|
219
|
+
...props
|
|
220
|
+
}
|
|
221
|
+
));
|
|
217
222
|
DropdownMenuGroup.displayName = "DropdownMenuGroup";
|
|
218
223
|
exports.DropdownMenu = DropdownMenu;
|
|
219
224
|
exports.DropdownMenuContent = DropdownMenuContent;
|