@fanvue/ui 3.31.0 → 3.33.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/ChatInput/ChatInput.cjs +6 -5
- package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuHeader.cjs +190 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuHeader.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +213 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderGroup.cjs +438 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderGroup.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs +197 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +221 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +128 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/context.cjs +26 -0
- package/dist/cjs/components/DropdownMenu/context.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/reorderShared.cjs +38 -0
- package/dist/cjs/components/DropdownMenu/reorderShared.cjs.map +1 -0
- package/dist/cjs/components/Logo/Logo.cjs +27 -7
- package/dist/cjs/components/Logo/Logo.cjs.map +1 -1
- package/dist/cjs/components/Logo/Logo3dIcon.cjs +226 -0
- package/dist/cjs/components/Logo/Logo3dIcon.cjs.map +1 -0
- package/dist/cjs/index.cjs +19 -12
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/ChatInput/ChatInput.mjs +2 -1
- package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuHeader.mjs +173 -0
- package/dist/components/DropdownMenu/DropdownMenuHeader.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs +195 -0
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuReorderGroup.mjs +421 -0
- package/dist/components/DropdownMenu/DropdownMenuReorderGroup.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs +180 -0
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +203 -0
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +110 -0
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -0
- package/dist/components/DropdownMenu/context.mjs +9 -0
- package/dist/components/DropdownMenu/context.mjs.map +1 -0
- package/dist/components/DropdownMenu/reorderShared.mjs +21 -0
- package/dist/components/DropdownMenu/reorderShared.mjs.map +1 -0
- package/dist/components/Logo/Logo.mjs +27 -7
- package/dist/components/Logo/Logo.mjs.map +1 -1
- package/dist/components/Logo/Logo3dIcon.mjs +209 -0
- package/dist/components/Logo/Logo3dIcon.mjs.map +1 -0
- package/dist/index.d.ts +133 -7
- package/dist/index.mjs +8 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs +0 -598
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs.map +0 -1
- package/dist/components/DropdownMenu/DropdownMenu.mjs +0 -580
- package/dist/components/DropdownMenu/DropdownMenu.mjs.map +0 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { cn } from "../../utils/cn.mjs";
|
|
6
|
+
import { DropdownMenuVariantContext } from "./context.mjs";
|
|
7
|
+
import { ReorderActionsContext, ReorderLiftedContext, DragHandleDots } from "./reorderShared.mjs";
|
|
8
|
+
const INTERACTIVE_CONTROL_SELECTOR = 'button, a[href], input, select, textarea, [role="button"]';
|
|
9
|
+
function canStartReorderDrag(event, handle) {
|
|
10
|
+
if (event.defaultPrevented || !(event.target instanceof Element)) return false;
|
|
11
|
+
const onHandle = handle?.contains(event.target) === true;
|
|
12
|
+
if (event.pointerType !== "mouse") return onHandle;
|
|
13
|
+
if (event.button !== 0) return false;
|
|
14
|
+
return onHandle || event.target.closest(INTERACTIVE_CONTROL_SELECTOR) === null;
|
|
15
|
+
}
|
|
16
|
+
function focusHandleAfterClick(event, handle) {
|
|
17
|
+
if (handle !== null && event.target instanceof Node && handle.contains(event.target)) {
|
|
18
|
+
handle.focus({ preventScroll: true });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function ReorderRowContent({
|
|
22
|
+
leadingIcon,
|
|
23
|
+
trailing,
|
|
24
|
+
children
|
|
25
|
+
}) {
|
|
26
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
leadingIcon != null && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: leadingIcon }),
|
|
28
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children }),
|
|
29
|
+
trailing != null && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: trailing })
|
|
30
|
+
] });
|
|
31
|
+
}
|
|
32
|
+
function ReorderGhost({
|
|
33
|
+
lifted,
|
|
34
|
+
registerGhost,
|
|
35
|
+
container,
|
|
36
|
+
children
|
|
37
|
+
}) {
|
|
38
|
+
return createPortal(
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
"aria-hidden": "true",
|
|
43
|
+
"data-reorder-ghost": "",
|
|
44
|
+
ref: registerGhost,
|
|
45
|
+
className: "pointer-events-none fixed top-0 left-0 will-change-transform",
|
|
46
|
+
style: { width: lifted.width, zIndex: lifted.zIndex },
|
|
47
|
+
children: /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-sm bg-surface-primary/65 backdrop-blur-[20px]", children: /* @__PURE__ */ jsxs("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", children: [
|
|
48
|
+
/* @__PURE__ */ jsx(DragHandleDots, { className: "size-4 shrink-0 text-icons-tertiary" }),
|
|
49
|
+
children
|
|
50
|
+
] }) })
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
container
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const DropdownMenuReorderItem = React.forwardRef(
|
|
57
|
+
({
|
|
58
|
+
value,
|
|
59
|
+
label,
|
|
60
|
+
leadingIcon,
|
|
61
|
+
trailing,
|
|
62
|
+
dragHandleLabel = "Reorder",
|
|
63
|
+
disabled,
|
|
64
|
+
className,
|
|
65
|
+
children,
|
|
66
|
+
onPointerDown,
|
|
67
|
+
onPointerMove,
|
|
68
|
+
onPointerUp,
|
|
69
|
+
onPointerCancel,
|
|
70
|
+
...props
|
|
71
|
+
}, ref) => {
|
|
72
|
+
const actions = React.useContext(ReorderActionsContext);
|
|
73
|
+
const lifted = React.useContext(ReorderLiftedContext);
|
|
74
|
+
const variant = React.useContext(DropdownMenuVariantContext);
|
|
75
|
+
const elementRef = React.useRef(null);
|
|
76
|
+
const handleRef = React.useRef(null);
|
|
77
|
+
const liftedHere = lifted !== null && lifted.value === value ? lifted : null;
|
|
78
|
+
const isLifted = liftedHere !== null;
|
|
79
|
+
const resolvedLabel = label ?? (typeof children === "string" || typeof children === "number" ? String(children) : value);
|
|
80
|
+
const grabCursor = isLifted ? "cursor-grabbing" : "cursor-grab";
|
|
81
|
+
const rowStateClasses = disabled ? "cursor-default text-content-disabled" : cn(grabCursor, isLifted ? "opacity-60" : "hover:bg-neutral-alphas-50");
|
|
82
|
+
const handleStateClasses = disabled ? "cursor-not-allowed [&>svg]:text-content-disabled" : grabCursor;
|
|
83
|
+
const setElement = React.useCallback(
|
|
84
|
+
(node) => {
|
|
85
|
+
elementRef.current = node;
|
|
86
|
+
if (typeof ref === "function") {
|
|
87
|
+
ref(node);
|
|
88
|
+
} else if (ref) {
|
|
89
|
+
ref.current = node;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[ref]
|
|
93
|
+
);
|
|
94
|
+
React.useLayoutEffect(() => {
|
|
95
|
+
const element = elementRef.current;
|
|
96
|
+
if (actions === null || element === null) return;
|
|
97
|
+
actions.registerItem(value, { element, label: resolvedLabel });
|
|
98
|
+
return () => actions.registerItem(value, null);
|
|
99
|
+
}, [actions, value, resolvedLabel]);
|
|
100
|
+
const rowContent = /* @__PURE__ */ jsx(ReorderRowContent, { leadingIcon, trailing, children });
|
|
101
|
+
return /* @__PURE__ */ jsxs(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
ref: setElement,
|
|
105
|
+
"data-dragging": isLifted || void 0,
|
|
106
|
+
className: cn(
|
|
107
|
+
"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",
|
|
108
|
+
variant === "sheet" && "mx-3 w-auto",
|
|
109
|
+
rowStateClasses,
|
|
110
|
+
className
|
|
111
|
+
),
|
|
112
|
+
...props,
|
|
113
|
+
onPointerDown: (event) => {
|
|
114
|
+
onPointerDown?.(event);
|
|
115
|
+
const element = elementRef.current;
|
|
116
|
+
if (disabled || actions === null || element === null) return;
|
|
117
|
+
if (!canStartReorderDrag(event, handleRef.current)) return;
|
|
118
|
+
if (!actions.startDrag(value, event, element)) return;
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
element.setPointerCapture?.(event.pointerId);
|
|
121
|
+
},
|
|
122
|
+
onPointerMove: (event) => {
|
|
123
|
+
onPointerMove?.(event);
|
|
124
|
+
actions?.updateDrag(event);
|
|
125
|
+
},
|
|
126
|
+
onPointerUp: (event) => {
|
|
127
|
+
onPointerUp?.(event);
|
|
128
|
+
actions?.endDrag(event.pointerId, true);
|
|
129
|
+
if (!isLifted) focusHandleAfterClick(event, handleRef.current);
|
|
130
|
+
},
|
|
131
|
+
onPointerCancel: (event) => {
|
|
132
|
+
onPointerCancel?.(event);
|
|
133
|
+
actions?.endDrag(event.pointerId, false);
|
|
134
|
+
},
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ jsx(
|
|
137
|
+
"button",
|
|
138
|
+
{
|
|
139
|
+
ref: handleRef,
|
|
140
|
+
type: "button",
|
|
141
|
+
"aria-label": dragHandleLabel,
|
|
142
|
+
"aria-describedby": actions?.instructionsId,
|
|
143
|
+
disabled,
|
|
144
|
+
className: cn(
|
|
145
|
+
"relative flex size-4 shrink-0 touch-none items-center justify-center rounded-2xs outline-none focus-visible:shadow-focus-ring",
|
|
146
|
+
// The grip draws at 16px but is the only touch drag affordance, so
|
|
147
|
+
// its hit area extends 12px each way to the row's edges — a 40px
|
|
148
|
+
// target — without changing the glyph.
|
|
149
|
+
"before:absolute before:-inset-3 before:content-['']",
|
|
150
|
+
handleStateClasses
|
|
151
|
+
),
|
|
152
|
+
onKeyDown: (event) => {
|
|
153
|
+
if (event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
event.stopPropagation();
|
|
156
|
+
actions?.moveItem(value, event.key === "ArrowUp" ? -1 : 1);
|
|
157
|
+
},
|
|
158
|
+
children: /* @__PURE__ */ jsx(DragHandleDots, { className: "size-4 text-icons-tertiary" })
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
rowContent,
|
|
162
|
+
liftedHere !== null && actions !== null && /* @__PURE__ */ jsx(
|
|
163
|
+
ReorderGhost,
|
|
164
|
+
{
|
|
165
|
+
lifted: liftedHere,
|
|
166
|
+
registerGhost: actions.registerGhost,
|
|
167
|
+
container: elementRef.current?.ownerDocument.body ?? document.body,
|
|
168
|
+
children: rowContent
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
DropdownMenuReorderItem.displayName = "DropdownMenuReorderItem";
|
|
177
|
+
export {
|
|
178
|
+
DropdownMenuReorderItem
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=DropdownMenuReorderItem.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownMenuReorderItem.mjs","sources":["../../../src/components/DropdownMenu/DropdownMenuReorderItem.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils/cn\";\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 && <span className=\"shrink-0\">{leadingIcon}</span>}\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-3 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":[],"mappings":";;;;;;;AAYA,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,SACE,qBAAA,UAAA,EACG,UAAA;AAAA,IAAA,eAAe,QAAQ,oBAAC,QAAA,EAAK,WAAU,YAAY,UAAA,aAAY;AAAA,IAChE,oBAAC,QAAA,EAAK,WAAU,2BAA2B,SAAA,CAAS;AAAA,IACnD,YAAY,QAAQ,oBAAC,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,SAAO;AAAA,IACL;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,eAAY;AAAA,QACZ,sBAAmB;AAAA,QACnB,KAAK;AAAA,QACL,WAAU;AAAA,QACV,OAAO,EAAE,OAA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,cACA,WAAW;AAAA,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,UAAA,oBAAC,gBAAA,EAAe,WAAU,6BAAA,CAA6B;AAAA,YAAA;AAAA,UAAA;AAAA,UAExD;AAAA,UACA,eAAe,QAAQ,YAAY,QAClC;AAAA,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;"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
4
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn } from "../../utils/cn.mjs";
|
|
7
|
+
import { FLOATING_CONTENT_COLLISION_PADDING } from "../../utils/floatingContentCollisionPadding.mjs";
|
|
8
|
+
import { Drawer, DrawerContent, DrawerTrigger } from "../Drawer/Drawer.mjs";
|
|
9
|
+
import { DropdownMenuVariantContext, ToggleOpenContext } from "./context.mjs";
|
|
10
|
+
const TAP_MOVEMENT_THRESHOLD_PX = 10;
|
|
11
|
+
const TAB_STOPS_ATTRIBUTE = "data-dropdown-menu-tab-stops";
|
|
12
|
+
const FOCUSABLE_SELECTOR = "a[href], button, input, select, textarea, [tabindex]";
|
|
13
|
+
function getMenuTabStops(content) {
|
|
14
|
+
const stops = [];
|
|
15
|
+
for (const container of content.querySelectorAll(`[${TAB_STOPS_ATTRIBUTE}]`)) {
|
|
16
|
+
for (const element of container.querySelectorAll(FOCUSABLE_SELECTOR)) {
|
|
17
|
+
if (element.tabIndex < 0 || element.matches(":disabled") || element.hidden) continue;
|
|
18
|
+
stops.push(element);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return stops;
|
|
22
|
+
}
|
|
23
|
+
function cycleMenuTabStops(event) {
|
|
24
|
+
if (event.key !== "Tab" || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
25
|
+
const target = event.target;
|
|
26
|
+
if (target.closest("[data-radix-menu-content]") !== event.currentTarget) return;
|
|
27
|
+
const stops = getMenuTabStops(event.currentTarget);
|
|
28
|
+
if (stops.length === 0) return;
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
const index = stops.indexOf(target);
|
|
31
|
+
const last = stops.length - 1;
|
|
32
|
+
const next = event.shiftKey ? stops[index <= 0 ? last : index - 1] : stops[index === -1 || index === last ? 0 : index + 1];
|
|
33
|
+
next?.focus({ preventScroll: true });
|
|
34
|
+
}
|
|
35
|
+
function DropdownMenu({
|
|
36
|
+
open: openProp,
|
|
37
|
+
defaultOpen,
|
|
38
|
+
onOpenChange,
|
|
39
|
+
variant = "menu",
|
|
40
|
+
children,
|
|
41
|
+
...props
|
|
42
|
+
}) {
|
|
43
|
+
const [open = false, setOpen] = useControllableState({
|
|
44
|
+
prop: openProp,
|
|
45
|
+
defaultProp: defaultOpen ?? false,
|
|
46
|
+
onChange: onOpenChange
|
|
47
|
+
});
|
|
48
|
+
if (variant === "sheet") {
|
|
49
|
+
return /* @__PURE__ */ jsx(DropdownMenuVariantContext.Provider, { value: "sheet", children: /* @__PURE__ */ jsx(ToggleOpenContext.Provider, { value: setOpen, children: /* @__PURE__ */ jsx(Drawer, { open, onOpenChange: setOpen, children }) }) });
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ jsx(DropdownMenuVariantContext.Provider, { value: "menu", children: /* @__PURE__ */ jsx(ToggleOpenContext.Provider, { value: setOpen, children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { open, onOpenChange: setOpen, ...props, children }) }) });
|
|
52
|
+
}
|
|
53
|
+
const DropdownMenuTrigger = React.forwardRef((props, ref) => {
|
|
54
|
+
const variant = React.useContext(DropdownMenuVariantContext);
|
|
55
|
+
const toggleOpen = React.useContext(ToggleOpenContext);
|
|
56
|
+
const tapRef = React.useRef(null);
|
|
57
|
+
if (variant === "sheet") {
|
|
58
|
+
return /* @__PURE__ */ jsx(DrawerTrigger, { ...props, ref });
|
|
59
|
+
}
|
|
60
|
+
if (toggleOpen === null) {
|
|
61
|
+
return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Trigger, { ...props, ref });
|
|
62
|
+
}
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
DropdownMenuPrimitive.Trigger,
|
|
65
|
+
{
|
|
66
|
+
...props,
|
|
67
|
+
ref,
|
|
68
|
+
onPointerDown: (event) => {
|
|
69
|
+
props.onPointerDown?.(event);
|
|
70
|
+
if (event.pointerType === "mouse" || props.disabled) return;
|
|
71
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
72
|
+
tapRef.current = {
|
|
73
|
+
pointerId: event.pointerId,
|
|
74
|
+
x: event.clientX,
|
|
75
|
+
y: event.clientY,
|
|
76
|
+
movedPastThreshold: false
|
|
77
|
+
};
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
},
|
|
80
|
+
onPointerMove: (event) => {
|
|
81
|
+
props.onPointerMove?.(event);
|
|
82
|
+
const tap = tapRef.current;
|
|
83
|
+
if (tap === null || event.pointerId !== tap.pointerId || tap.movedPastThreshold) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const dx = event.clientX - tap.x;
|
|
87
|
+
const dy = event.clientY - tap.y;
|
|
88
|
+
if (Math.hypot(dx, dy) > TAP_MOVEMENT_THRESHOLD_PX) {
|
|
89
|
+
tap.movedPastThreshold = true;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
onPointerUp: (event) => {
|
|
93
|
+
props.onPointerUp?.(event);
|
|
94
|
+
const tap = tapRef.current;
|
|
95
|
+
if (tap === null || event.pointerId !== tap.pointerId) return;
|
|
96
|
+
const wasDrag = tap.movedPastThreshold;
|
|
97
|
+
tapRef.current = null;
|
|
98
|
+
if (!wasDrag && !props.disabled) {
|
|
99
|
+
toggleOpen((prev) => !prev);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
onPointerCancel: (event) => {
|
|
103
|
+
props.onPointerCancel?.(event);
|
|
104
|
+
const tap = tapRef.current;
|
|
105
|
+
if (tap !== null && event.pointerId === tap.pointerId) {
|
|
106
|
+
tapRef.current = null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
DropdownMenuTrigger.displayName = "DropdownMenuTrigger";
|
|
113
|
+
const DropdownMenuContent = React.forwardRef(
|
|
114
|
+
({
|
|
115
|
+
className,
|
|
116
|
+
style,
|
|
117
|
+
sideOffset = 4,
|
|
118
|
+
// Radix defaults `avoidCollisions` to true, so passing `collisionPadding`
|
|
119
|
+
// is enough to keep the menu flipping/shifting to stay on screen — no
|
|
120
|
+
// hand-rolled reposition logic needed.
|
|
121
|
+
collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,
|
|
122
|
+
onPointerDownOutside,
|
|
123
|
+
onCloseAutoFocus,
|
|
124
|
+
onKeyDown,
|
|
125
|
+
children,
|
|
126
|
+
...props
|
|
127
|
+
}, ref) => {
|
|
128
|
+
const variant = React.useContext(DropdownMenuVariantContext);
|
|
129
|
+
const dismissedByPointer = React.useRef(false);
|
|
130
|
+
if (variant === "sheet") {
|
|
131
|
+
return /* @__PURE__ */ jsx(
|
|
132
|
+
DrawerContent,
|
|
133
|
+
{
|
|
134
|
+
ref,
|
|
135
|
+
position: "bottom",
|
|
136
|
+
variant: "menu",
|
|
137
|
+
overlayProps: { className: "backdrop-blur-[8px]" },
|
|
138
|
+
className: cn("flex flex-col gap-1 p-1 pb-4", className),
|
|
139
|
+
style,
|
|
140
|
+
onPointerDownOutside,
|
|
141
|
+
onCloseAutoFocus,
|
|
142
|
+
onKeyDown,
|
|
143
|
+
...props,
|
|
144
|
+
children
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
149
|
+
DropdownMenuPrimitive.Content,
|
|
150
|
+
{
|
|
151
|
+
ref,
|
|
152
|
+
onPointerDownOutside: (event) => {
|
|
153
|
+
dismissedByPointer.current = true;
|
|
154
|
+
onPointerDownOutside?.(event);
|
|
155
|
+
},
|
|
156
|
+
onCloseAutoFocus: (event) => {
|
|
157
|
+
if (dismissedByPointer.current) event.preventDefault();
|
|
158
|
+
dismissedByPointer.current = false;
|
|
159
|
+
onCloseAutoFocus?.(event);
|
|
160
|
+
},
|
|
161
|
+
onKeyDown: (event) => {
|
|
162
|
+
onKeyDown?.(event);
|
|
163
|
+
if (!event.defaultPrevented) cycleMenuTabStops(event);
|
|
164
|
+
},
|
|
165
|
+
sideOffset,
|
|
166
|
+
collisionPadding,
|
|
167
|
+
className: cn(
|
|
168
|
+
// `rounded-sm` (12px) is the panel radius `V2 Menu Dropdown` carries
|
|
169
|
+
// (product file node `7393:62008`). The 8px `rounded-xs` belongs to the
|
|
170
|
+
// rows inside it, not the panel.
|
|
171
|
+
//
|
|
172
|
+
// The `sheet` variant is deliberately not 12px: it renders through
|
|
173
|
+
// `DrawerContent variant="menu"`, whose `MENU_CLASSES` is `rounded-lg`
|
|
174
|
+
// (24px). A bottom sheet is a full-width surface with its own radius,
|
|
175
|
+
// not a scaled-up popper, so the two are meant to differ.
|
|
176
|
+
"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-border-primary bg-surface-primary p-1 text-content-primary shadow-blur-menu backdrop-blur-[4px]",
|
|
177
|
+
"data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in",
|
|
178
|
+
"data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out",
|
|
179
|
+
"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2",
|
|
180
|
+
"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",
|
|
181
|
+
className
|
|
182
|
+
),
|
|
183
|
+
style: {
|
|
184
|
+
zIndex: "var(--fanvue-ui-portal-z-index, 50)",
|
|
185
|
+
maxHeight: "var(--radix-dropdown-menu-content-available-height)",
|
|
186
|
+
...style
|
|
187
|
+
},
|
|
188
|
+
...props,
|
|
189
|
+
children
|
|
190
|
+
}
|
|
191
|
+
) });
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
DropdownMenuContent.displayName = "DropdownMenuContent";
|
|
195
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
196
|
+
DropdownMenuGroup.displayName = "DropdownMenuGroup";
|
|
197
|
+
export {
|
|
198
|
+
DropdownMenu,
|
|
199
|
+
DropdownMenuContent,
|
|
200
|
+
DropdownMenuGroup,
|
|
201
|
+
DropdownMenuTrigger
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=DropdownMenuRoot.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownMenuRoot.mjs","sources":["../../../src/components/DropdownMenu/DropdownMenuRoot.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"../../utils/floatingContentCollisionPadding\";\nimport { Drawer, DrawerContent, DrawerTrigger } from \"../Drawer/Drawer\";\nimport { type DropdownMenuVariant, DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\n\n// Movement, in CSS px, above which a touch press-and-release counts as a drag.\nconst TAP_MOVEMENT_THRESHOLD_PX = 10;\n\n// Radix menus swallow Tab (a menu has no tab stops, only items), which strands\n// any non-item control rendered inside one — header actions, a search input,\n// reorder handles. Containers of such controls carry this attribute and\n// `DropdownMenuContent` cycles Tab through the focusable elements inside them.\nconst TAB_STOPS_ATTRIBUTE = \"data-dropdown-menu-tab-stops\";\nconst FOCUSABLE_SELECTOR = \"a[href], button, input, select, textarea, [tabindex]\";\n\nfunction getMenuTabStops(content: HTMLElement): HTMLElement[] {\n const stops: HTMLElement[] = [];\n for (const container of content.querySelectorAll<HTMLElement>(`[${TAB_STOPS_ATTRIBUTE}]`)) {\n for (const element of container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) {\n if (element.tabIndex < 0 || element.matches(\":disabled\") || element.hidden) continue;\n stops.push(element);\n }\n }\n return stops;\n}\n\n// Cycles focus through the menu's tab stops on Tab / Shift+Tab, skipping menu\n// items (which keep their arrow-key navigation). Returns without acting when\n// the key isn't a plain Tab, came from a nested menu, or there is nothing to\n// cycle through — Radix then swallows the key as it always has.\nfunction cycleMenuTabStops(event: React.KeyboardEvent<HTMLElement>): void {\n if (event.key !== \"Tab\" || event.altKey || event.ctrlKey || event.metaKey) return;\n // A nested menu's keydowns bubble here through React's portal tree; they are\n // the nested menu's to handle.\n const target = event.target as HTMLElement;\n if (target.closest(\"[data-radix-menu-content]\") !== event.currentTarget) return;\n const stops = getMenuTabStops(event.currentTarget);\n if (stops.length === 0) return;\n // Prevented here so Radix's own handler (which would swallow the key) is\n // skipped — Radix composes it after ours and checks `defaultPrevented`.\n event.preventDefault();\n const index = stops.indexOf(target);\n const last = stops.length - 1;\n const next = event.shiftKey\n ? stops[index <= 0 ? last : index - 1]\n : stops[index === -1 || index === last ? 0 : index + 1];\n // Radix's FocusScope also sees this Tab (after us, ignoring\n // `defaultPrevented`), but a menu's scope is trapped without `loop`, so it\n // only prevents the default — it never moves focus itself.\n next?.focus({ preventScroll: true });\n}\n\ntype ActiveTap = {\n pointerId: number;\n x: number;\n y: number;\n movedPastThreshold: boolean;\n};\n\n/** Props for the {@link DropdownMenu} root component. */\nexport interface DropdownMenuProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root> {\n /** How the menu presents its content. @default \"menu\" */\n variant?: DropdownMenuVariant;\n}\n\n/** Root component that manages open/close state for a dropdown menu. */\nexport function DropdownMenu({\n open: openProp,\n defaultOpen,\n onOpenChange,\n variant = \"menu\",\n children,\n ...props\n}: DropdownMenuProps) {\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n if (variant === \"sheet\") {\n return (\n <DropdownMenuVariantContext.Provider value=\"sheet\">\n <ToggleOpenContext.Provider value={setOpen}>\n <Drawer open={open} onOpenChange={setOpen}>\n {children}\n </Drawer>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n }\n\n return (\n <DropdownMenuVariantContext.Provider value=\"menu\">\n <ToggleOpenContext.Provider value={setOpen}>\n <DropdownMenuPrimitive.Root open={open} onOpenChange={setOpen} {...props}>\n {children}\n </DropdownMenuPrimitive.Root>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n}\n\n/** Props for the {@link DropdownMenuTrigger} component. */\nexport type DropdownMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Trigger\n>;\n\n/**\n * The element that toggles the dropdown menu when clicked.\n *\n * On touch devices, the menu only opens if the press-and-release stays within\n * a small movement threshold. A drag that incidentally ends over the trigger\n * (common when scrolling a feed on Android Chrome) is ignored. Mouse and\n * keyboard interactions are unchanged.\n */\nexport const DropdownMenuTrigger = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,\n DropdownMenuTriggerProps\n>((props, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const tapRef = React.useRef<ActiveTap | null>(null);\n\n // The sheet variant opens a Drawer (Dialog), which already suppresses\n // scroll-drag-end synthetic clicks itself — no need for the touch-tap gating below.\n if (variant === \"sheet\") {\n return <DrawerTrigger {...props} ref={ref} />;\n }\n\n // Used outside our DropdownMenu wrapper — fall through to Radix defaults.\n if (toggleOpen === null) {\n return <DropdownMenuPrimitive.Trigger {...props} ref={ref} />;\n }\n\n return (\n <DropdownMenuPrimitive.Trigger\n {...props}\n ref={ref}\n onPointerDown={(event) => {\n props.onPointerDown?.(event);\n if (event.pointerType === \"mouse\" || props.disabled) return;\n // Keep pointerup / pointercancel on this element if the finger drifts off.\n // Optional because jsdom (used in tests) doesn't implement it.\n event.currentTarget.setPointerCapture?.(event.pointerId);\n tapRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n movedPastThreshold: false,\n };\n // preventDefault stops Radix's pointerdown open path via composeEventHandlers.\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n props.onPointerMove?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId || tap.movedPastThreshold) {\n return;\n }\n const dx = event.clientX - tap.x;\n const dy = event.clientY - tap.y;\n if (Math.hypot(dx, dy) > TAP_MOVEMENT_THRESHOLD_PX) {\n tap.movedPastThreshold = true;\n }\n }}\n onPointerUp={(event) => {\n props.onPointerUp?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId) return;\n const wasDrag = tap.movedPastThreshold;\n tapRef.current = null;\n if (!wasDrag && !props.disabled) {\n toggleOpen((prev) => !prev);\n }\n }}\n onPointerCancel={(event) => {\n props.onPointerCancel?.(event);\n const tap = tapRef.current;\n if (tap !== null && event.pointerId === tap.pointerId) {\n tapRef.current = null;\n }\n }}\n />\n );\n});\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\";\n\n/** Props for the {@link DropdownMenuContent} component. */\nexport interface DropdownMenuContentProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {}\n\n/**\n * The positioned content panel rendered inside a portal.\n *\n * Override the portal z-index per-instance via `style={{ zIndex: 1500 }}` or\n * globally with the `--fanvue-ui-portal-z-index` CSS custom property.\n *\n * @example\n * ```tsx\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild>\n * <Button>Open</Button>\n * </DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Option 1</DropdownMenuItem>\n * <DropdownMenuItem>Option 2</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n * ```\n */\nexport const DropdownMenuContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Content>,\n DropdownMenuContentProps\n>(\n (\n {\n className,\n style,\n sideOffset = 4,\n // Radix defaults `avoidCollisions` to true, so passing `collisionPadding`\n // is enough to keep the menu flipping/shifting to stay on screen — no\n // hand-rolled reposition logic needed.\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n onPointerDownOutside,\n onCloseAutoFocus,\n onKeyDown,\n children,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n // Radix returns focus to the trigger when the menu closes. That is right for\n // the keyboard, but Chrome's :focus-visible heuristic also paints the ring on\n // that programmatic refocus, so dismissing with a click left a focus ring\n // sitting on the trigger. Track pointer dismissals and skip the restore for\n // them only — Escape and Tab still hand focus back with the ring.\n const dismissedByPointer = React.useRef(false);\n\n if (variant === \"sheet\") {\n return (\n <DrawerContent\n ref={ref}\n position=\"bottom\"\n // `\"sheet\"` sits flush to the bottom edge at full width; the design draws\n // this panel inset from all three sides and rounded on every corner, which\n // is `\"menu\"`. Both carry the same modal surface.\n variant=\"menu\"\n // The design's `blur + shadow/menu` effect is a background blur, and the\n // panel's own fill is opaque — so the blur has to go on the overlay to be\n // visible at all. Scoped here rather than on DrawerOverlay so only menus\n // shown this way blur the page behind them.\n overlayProps={{ className: \"backdrop-blur-[8px]\" }}\n // `pb-4` gives the design's 16px below the last row. The rows inset\n // themselves horizontally (see the item's `mx-3`) rather than the panel\n // padding doing it, so the header and its rule can still run full width.\n className={cn(\"flex flex-col gap-1 p-1 pb-4\", className)}\n style={style}\n // Both are destructured above for the popper branch's focus-ring\n // handling, which takes them out of `props` — so the sheet branch has\n // to re-attach them or they are silently dropped. `DrawerContent`\n // forwards them to its `DialogPrimitive.Content`, which supports both.\n // Consumers stack sheets on these (a nested sheet's `onCloseAutoFocus`\n // is the only point at which the parent knows the child has finished\n // animating out), so dropping them breaks the flow with no error.\n onPointerDownOutside={onPointerDownOutside}\n onCloseAutoFocus={onCloseAutoFocus}\n onKeyDown={onKeyDown}\n {...props}\n >\n {children}\n </DrawerContent>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n onPointerDownOutside={(event) => {\n dismissedByPointer.current = true;\n onPointerDownOutside?.(event);\n }}\n onCloseAutoFocus={(event) => {\n if (dismissedByPointer.current) event.preventDefault();\n dismissedByPointer.current = false;\n onCloseAutoFocus?.(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) cycleMenuTabStops(event);\n }}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\n // `rounded-sm` (12px) is the panel radius `V2 Menu Dropdown` carries\n // (product file node `7393:62008`). The 8px `rounded-xs` belongs to the\n // rows inside it, not the panel.\n //\n // The `sheet` variant is deliberately not 12px: it renders through\n // `DrawerContent variant=\"menu\"`, whose `MENU_CLASSES` is `rounded-lg`\n // (24px). A bottom sheet is a full-width surface with its own radius,\n // not a scaled-up popper, so the two are meant to differ.\n \"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-border-primary bg-surface-primary p-1 text-content-primary shadow-blur-menu backdrop-blur-[4px]\",\n \"data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out\",\n \"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2\",\n \"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2\",\n className,\n )}\n style={{\n zIndex: \"var(--fanvue-ui-portal-z-index, 50)\",\n maxHeight: \"var(--radix-dropdown-menu-content-available-height)\",\n ...style,\n }}\n {...props}\n >\n {children}\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\nDropdownMenuContent.displayName = \"DropdownMenuContent\";\n\n/** Props for the {@link DropdownMenuGroup} component. */\nexport type DropdownMenuGroupProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Group\n>;\n\n/**\n * Groups related menu items. Accepts an optional `DropdownMenuLabel`.\n *\n * Requires Radix menu context — not supported inside a `variant=\"sheet\"` menu.\n */\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\";\n"],"names":[],"mappings":";;;;;;;;;AASA,MAAM,4BAA4B;AAMlC,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAE3B,SAAS,gBAAgB,SAAqC;AAC5D,QAAM,QAAuB,CAAA;AAC7B,aAAW,aAAa,QAAQ,iBAA8B,IAAI,mBAAmB,GAAG,GAAG;AACzF,eAAW,WAAW,UAAU,iBAA8B,kBAAkB,GAAG;AACjF,UAAI,QAAQ,WAAW,KAAK,QAAQ,QAAQ,WAAW,KAAK,QAAQ,OAAQ;AAC5E,YAAM,KAAK,OAAO;AAAA,IACpB;AAAA,EACF;AACA,SAAO;AACT;AAMA,SAAS,kBAAkB,OAA+C;AACxE,MAAI,MAAM,QAAQ,SAAS,MAAM,UAAU,MAAM,WAAW,MAAM,QAAS;AAG3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AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,WAAW;AAAA,UACX,GAAG;AAAA,QAAA;AAAA,QAEJ,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;AACA,oBAAoB,cAAc;AAY3B,MAAM,oBAAoB,sBAAsB;AACvD,kBAAkB,cAAc;"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn } from "../../utils/cn.mjs";
|
|
6
|
+
import { TickIcon } from "../Icons/TickIcon.mjs";
|
|
7
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
8
|
+
const DropdownMenuRadioItem = React.forwardRef(({ className, children, helper, size: _size = "40", ...props }, ref) => {
|
|
9
|
+
return /* @__PURE__ */ jsxs(
|
|
10
|
+
DropdownMenuPrimitive.RadioItem,
|
|
11
|
+
{
|
|
12
|
+
ref,
|
|
13
|
+
className: cn(
|
|
14
|
+
// `px-3` (12px), not 16px: `V2 Menu Radio Item` is `px-[12px] py-[8px]`
|
|
15
|
+
// (node `7393:62008`), and at 16px a radio row indented 4px further than a
|
|
16
|
+
// `DropdownMenuCheckboxItem` in the same menu.
|
|
17
|
+
"group flex w-full cursor-pointer items-start gap-3 rounded-xs px-3 py-2 outline-none",
|
|
18
|
+
"data-[highlighted]:bg-neutral-alphas-50",
|
|
19
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled",
|
|
20
|
+
// See DropdownMenuItem above: bg-interaction-hover aliases to the same
|
|
21
|
+
// token as the plain hover background, so it can't distinguish the
|
|
22
|
+
// checked state from an unchecked-but-hovered row.
|
|
23
|
+
"data-[state=checked]:bg-neutral-alphas-100",
|
|
24
|
+
"data-[state=checked]:data-[highlighted]:bg-neutral-alphas-200",
|
|
25
|
+
className
|
|
26
|
+
),
|
|
27
|
+
...props,
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
"span",
|
|
31
|
+
{
|
|
32
|
+
className: cn(
|
|
33
|
+
"mt-1 flex size-4 shrink-0 items-center justify-center rounded-full border border-icons-primary",
|
|
34
|
+
"group-data-[disabled]:border-content-disabled"
|
|
35
|
+
),
|
|
36
|
+
"aria-hidden": "true",
|
|
37
|
+
children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "size-2 rounded-full bg-content-primary" }) })
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
41
|
+
/* @__PURE__ */ jsx("span", { className: "typography-body-default-16px-semibold truncate", children }),
|
|
42
|
+
helper && /* @__PURE__ */ jsx(
|
|
43
|
+
"span",
|
|
44
|
+
{
|
|
45
|
+
className: cn(
|
|
46
|
+
"typography-description-12px-regular text-content-secondary",
|
|
47
|
+
"group-data-[disabled]:text-content-disabled"
|
|
48
|
+
),
|
|
49
|
+
children: helper
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
] })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem";
|
|
58
|
+
const DropdownMenuCheckboxItem = React.forwardRef(({ className, children, helper, avatar, ...props }, ref) => {
|
|
59
|
+
return /* @__PURE__ */ jsxs(
|
|
60
|
+
DropdownMenuPrimitive.CheckboxItem,
|
|
61
|
+
{
|
|
62
|
+
ref,
|
|
63
|
+
className: cn(
|
|
64
|
+
"group flex w-full cursor-pointer items-center gap-3 rounded-xs px-3 py-2 outline-none",
|
|
65
|
+
// Checked state is carried by the tick alone. A background here would
|
|
66
|
+
// leave every selected row shaded, which reads as "all highlighted" on
|
|
67
|
+
// a menu that starts fully selected.
|
|
68
|
+
"data-[highlighted]:bg-neutral-alphas-50",
|
|
69
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled",
|
|
70
|
+
className
|
|
71
|
+
),
|
|
72
|
+
...props,
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ jsx(
|
|
75
|
+
"span",
|
|
76
|
+
{
|
|
77
|
+
className: cn(
|
|
78
|
+
"flex size-4 shrink-0 items-center justify-center rounded-2xs border border-icons-primary",
|
|
79
|
+
"group-data-[state=checked]:bg-icons-primary",
|
|
80
|
+
"group-data-[disabled]:border-content-disabled"
|
|
81
|
+
),
|
|
82
|
+
"aria-hidden": "true",
|
|
83
|
+
children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { asChild: true, children: /* @__PURE__ */ jsx(TickIcon, { className: "size-4 text-content-primary-inverted" }) })
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
avatar && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: avatar }),
|
|
87
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
88
|
+
/* @__PURE__ */ jsx("span", { className: "typography-body-default-16px-semibold truncate", children }),
|
|
89
|
+
helper && /* @__PURE__ */ jsx(
|
|
90
|
+
"span",
|
|
91
|
+
{
|
|
92
|
+
className: cn(
|
|
93
|
+
"typography-description-12px-regular text-content-secondary",
|
|
94
|
+
"group-data-[disabled]:text-content-disabled"
|
|
95
|
+
),
|
|
96
|
+
children: helper
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
] })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
DropdownMenuCheckboxItem.displayName = "DropdownMenuCheckboxItem";
|
|
105
|
+
export {
|
|
106
|
+
DropdownMenuCheckboxItem,
|
|
107
|
+
DropdownMenuRadioGroup,
|
|
108
|
+
DropdownMenuRadioItem
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=DropdownMenuSelectionItems.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownMenuSelectionItems.mjs","sources":["../../../src/components/DropdownMenu/DropdownMenuSelectionItems.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { TickIcon } from \"../Icons/TickIcon\";\n\n/** Props for the {@link DropdownMenuRadioGroup} component. */\nexport interface DropdownMenuRadioGroupProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioGroup> {}\n\n/**\n * Groups {@link DropdownMenuRadioItem} children so they behave as a\n * single-select set. Controlled via `value`/`onValueChange`.\n *\n * @example\n * ```tsx\n * <DropdownMenuRadioGroup value={sort} onValueChange={setSort}>\n * <DropdownMenuRadioItem value=\"newest\">Newest first</DropdownMenuRadioItem>\n * <DropdownMenuRadioItem value=\"oldest\">Oldest first</DropdownMenuRadioItem>\n * </DropdownMenuRadioGroup>\n * ```\n *\n * Requires Radix menu context — not supported inside a `variant=\"sheet\"` menu.\n */\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\n/** Height preset for a {@link DropdownMenuRadioItem}. */\nexport type DropdownMenuRadioItemSize = \"40\";\n\nexport interface DropdownMenuRadioItemProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem> {\n /** Optional secondary text shown below the title. */\n helper?: string;\n /** Height of the item row. @default \"40\" */\n size?: DropdownMenuRadioItemSize;\n}\n\n/**\n * A single radio-style choice within a {@link DropdownMenuRadioGroup}. Shows\n * a circular indicator that fills when selected, plus an optional helper line\n * underneath the title.\n */\nexport const DropdownMenuRadioItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,\n DropdownMenuRadioItemProps\n>(({ className, children, helper, size: _size = \"40\", ...props }, ref) => {\n return (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(\n // `px-3` (12px), not 16px: `V2 Menu Radio Item` is `px-[12px] py-[8px]`\n // (node `7393:62008`), and at 16px a radio row indented 4px further than a\n // `DropdownMenuCheckboxItem` in the same menu.\n \"group flex w-full cursor-pointer items-start gap-3 rounded-xs px-3 py-2 outline-none\",\n \"data-[highlighted]:bg-neutral-alphas-50\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled\",\n // See DropdownMenuItem above: bg-interaction-hover aliases to the same\n // token as the plain hover background, so it can't distinguish the\n // checked state from an unchecked-but-hovered row.\n \"data-[state=checked]:bg-neutral-alphas-100\",\n \"data-[state=checked]:data-[highlighted]:bg-neutral-alphas-200\",\n className,\n )}\n {...props}\n >\n <span\n className={cn(\n \"mt-1 flex size-4 shrink-0 items-center justify-center rounded-full border border-icons-primary\",\n \"group-data-[disabled]:border-content-disabled\",\n )}\n aria-hidden=\"true\"\n >\n <DropdownMenuPrimitive.ItemIndicator asChild>\n <span className=\"size-2 rounded-full bg-content-primary\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <span className=\"typography-body-default-16px-semibold truncate\">{children}</span>\n {helper && (\n <span\n className={cn(\n \"typography-description-12px-regular text-content-secondary\",\n \"group-data-[disabled]:text-content-disabled\",\n )}\n >\n {helper}\n </span>\n )}\n </span>\n </DropdownMenuPrimitive.RadioItem>\n );\n});\nDropdownMenuRadioItem.displayName = \"DropdownMenuRadioItem\";\n\nexport interface DropdownMenuCheckboxItemProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem> {\n /** Optional secondary text shown below the title. */\n helper?: string;\n /** Leading avatar rendered between the checkbox and the title. Render at 32px to match the design. */\n avatar?: React.ReactNode;\n}\n\n/**\n * A single multi-select choice within a dropdown menu. Shows a square indicator\n * that fills when checked, an optional leading avatar, and an optional helper\n * line underneath the title.\n *\n * Pair with {@link DropdownMenuHeader} at `type=\"search\"` for filterable menus.\n * Use {@link DropdownMenuRadioItem} instead when only one option may be active.\n *\n * @example\n * ```tsx\n * <DropdownMenuCheckboxItem\n * checked={selected.has(creator.id)}\n * onCheckedChange={() => toggle(creator.id)}\n * avatar={<Avatar size={32} src={creator.avatarUrl} />}\n * >\n * @sofiabloom\n * </DropdownMenuCheckboxItem>\n * ```\n */\nexport const DropdownMenuCheckboxItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n DropdownMenuCheckboxItemProps\n>(({ className, children, helper, avatar, ...props }, ref) => {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(\n \"group flex w-full cursor-pointer items-center gap-3 rounded-xs px-3 py-2 outline-none\",\n // Checked state is carried by the tick alone. A background here would\n // leave every selected row shaded, which reads as \"all highlighted\" on\n // a menu that starts fully selected.\n \"data-[highlighted]:bg-neutral-alphas-50\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled\",\n className,\n )}\n {...props}\n >\n <span\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center rounded-2xs border border-icons-primary\",\n \"group-data-[state=checked]:bg-icons-primary\",\n \"group-data-[disabled]:border-content-disabled\",\n )}\n aria-hidden=\"true\"\n >\n <DropdownMenuPrimitive.ItemIndicator asChild>\n <TickIcon className=\"size-4 text-content-primary-inverted\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {avatar && <span className=\"shrink-0\">{avatar}</span>}\n <span className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <span className=\"typography-body-default-16px-semibold truncate\">{children}</span>\n {helper && (\n <span\n className={cn(\n \"typography-description-12px-regular text-content-secondary\",\n \"group-data-[disabled]:text-content-disabled\",\n )}\n >\n {helper}\n </span>\n )}\n </span>\n </DropdownMenuPrimitive.CheckboxItem>\n );\n});\nDropdownMenu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QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA;AAAA,cACA;AAAA,YAAA;AAAA,YAEF,eAAY;AAAA,YAEZ,UAAA,oBAAC,sBAAsB,eAAtB,EAAoC,SAAO,MAC1C,UAAA,oBAAC,UAAA,EAAS,WAAU,uCAAA,CAAuC,EAAA,CAC7D;AAAA,UAAA;AAAA,QAAA;AAAA,QAED,UAAU,oBAAC,QAAA,EAAK,WAAU,YAAY,UAAA,QAAO;AAAA,QAC9C,qBAAC,QAAA,EAAK,WAAU,sCACd,UAAA;AAAA,UAAA,oBAAC,QAAA,EAAK,WAAU,kDAAkD,SAAA,CAAS;AAAA,UAC1E,UACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA;AAAA,cAAA;AAAA,cAGD,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;AACD,yBAAyB,cAAc;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
const ToggleOpenContext = React.createContext(null);
|
|
4
|
+
const DropdownMenuVariantContext = React.createContext("menu");
|
|
5
|
+
export {
|
|
6
|
+
DropdownMenuVariantContext,
|
|
7
|
+
ToggleOpenContext
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.mjs","sources":["../../../src/components/DropdownMenu/context.ts"],"sourcesContent":["import * as React from \"react\";\n\n// Lets DropdownMenuTrigger toggle the menu directly so it can gate on touch\n// movement — see radix-ui/primitives#1912.\nexport const ToggleOpenContext = React.createContext<\n ((updater: (prev: boolean) => boolean) => void) | null\n>(null);\n\n/**\n * How a {@link DropdownMenu} presents its content.\n * - `\"menu\"` (default) — a Radix-positioned panel anchored to the trigger.\n * - `\"sheet\"` — a bottom drawer (via {@link Drawer}), for mobile/touch viewports.\n *\n * The viewport decision belongs to the consumer (it owns the breakpoint\n * source of truth), so pass e.g. `variant={isDesktop ? \"menu\" : \"sheet\"}`.\n */\nexport type DropdownMenuVariant = \"menu\" | \"sheet\";\n\nexport const DropdownMenuVariantContext = React.createContext<DropdownMenuVariant>(\"menu\");\n"],"names":[],"mappings":";;AAIO,MAAM,oBAAoB,MAAM,cAErC,IAAI;AAYC,MAAM,6BAA6B,MAAM,cAAmC,MAAM;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
function DragHandleDots(props) {
|
|
5
|
+
return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", ...props, children: [
|
|
6
|
+
/* @__PURE__ */ jsx("circle", { cx: "5.333", cy: "2.667", r: "1.333" }),
|
|
7
|
+
/* @__PURE__ */ jsx("circle", { cx: "5.333", cy: "8", r: "1.333" }),
|
|
8
|
+
/* @__PURE__ */ jsx("circle", { cx: "5.333", cy: "13.333", r: "1.333" }),
|
|
9
|
+
/* @__PURE__ */ jsx("circle", { cx: "10.667", cy: "2.667", r: "1.333" }),
|
|
10
|
+
/* @__PURE__ */ jsx("circle", { cx: "10.667", cy: "8", r: "1.333" }),
|
|
11
|
+
/* @__PURE__ */ jsx("circle", { cx: "10.667", cy: "13.333", r: "1.333" })
|
|
12
|
+
] });
|
|
13
|
+
}
|
|
14
|
+
const ReorderActionsContext = React.createContext(null);
|
|
15
|
+
const ReorderLiftedContext = React.createContext(null);
|
|
16
|
+
export {
|
|
17
|
+
DragHandleDots,
|
|
18
|
+
ReorderActionsContext,
|
|
19
|
+
ReorderLiftedContext
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=reorderShared.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reorderShared.mjs","sources":["../../../src/components/DropdownMenu/reorderShared.tsx"],"sourcesContent":["import * as React from \"react\";\n\n// Types, contexts and the grip glyph shared by DropdownMenuReorderGroup and\n// DropdownMenuReorderItem. Internal to the DropdownMenu directory.\n// The `V2 Menu Item` drag handle glyph (2×3 dot grip). Inlined rather than\n// added to `src/components/Icons` because that directory is generated from\n// Figma exports and hand-written files there are overwritten by icons:sync.\nexport function DragHandleDots(props: React.SVGAttributes<SVGSVGElement>) {\n return (\n <svg viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\" {...props}>\n <circle cx=\"5.333\" cy=\"2.667\" r=\"1.333\" />\n <circle cx=\"5.333\" cy=\"8\" r=\"1.333\" />\n <circle cx=\"5.333\" cy=\"13.333\" r=\"1.333\" />\n <circle cx=\"10.667\" cy=\"2.667\" r=\"1.333\" />\n <circle cx=\"10.667\" cy=\"8\" r=\"1.333\" />\n <circle cx=\"10.667\" cy=\"13.333\" r=\"1.333\" />\n </svg>\n );\n}\n\n/** Describes a completed reorder: which item moved and where. */\nexport interface DropdownMenuReorderDetail {\n /** `value` of the item that moved. */\n value: string;\n /** Plain-text name of the item that moved (see `DropdownMenuReorderItem.label`). */\n label: string;\n /** Index the item moved from. */\n from: number;\n /** Index the item now occupies. */\n to: number;\n /** Number of items in the group. */\n total: number;\n}\n\nexport type RegisteredReorderItem = { element: HTMLDivElement; label: string };\n\n// Everything a drag needs between pointer events. It lives in a ref rather\n// than state: pointer moves mutate it and write the ghost's transform directly,\n// and only a lift, a drop-index change or the drop itself reach React.\nexport type ReorderDrag = {\n value: string;\n pointerId: number;\n element: HTMLDivElement;\n startX: number;\n startY: number;\n offsetX: number;\n offsetY: number;\n lifted: boolean;\n dropIndex: number;\n // Geometry captured once at lift. Rows never move during a drag — the source\n // row stays in flow, dimmed — so the only thing that shifts them is the\n // scroll container, tracked by comparing its scrollTop with the value here.\n /** Row vertical centres in viewport coordinates at measure time. */\n midpoints: number[];\n /** Row top edges plus the last row's bottom, relative to the group. */\n edges: number[];\n scrollTopAtMeasure: number;\n containerRect: DOMRect | null;\n};\n\nexport type ReorderLifted = { value: string; width: number; zIndex: string };\n\nexport type ReorderActions = {\n registerItem: (value: string, item: RegisteredReorderItem | null) => void;\n registerGhost: (element: HTMLDivElement | null) => void;\n /** Returns `false` when another pointer already owns a drag. */\n startDrag: (value: string, event: React.PointerEvent, element: HTMLDivElement) => boolean;\n updateDrag: (event: React.PointerEvent) => void;\n endDrag: (pointerId: number, commit: boolean) => void;\n moveItem: (value: string, delta: number) => void;\n instructionsId: string;\n};\n\nexport const ReorderActionsContext = React.createContext<ReorderActions | null>(null);\n// Separate from the actions so rows re-render only when a lift starts or ends,\n// not on every drop-index change (which only the group's indicator needs).\nexport const ReorderLiftedContext = React.createContext<ReorderLifted | null>(null);\n"],"names":[],"mappings":";;;AAOO,SAAS,eAAe,OAA2C;AACxE,SACE,qBAAC,SAAI,SAAQ,aAAY,MAAK,gBAAe,eAAY,QAAQ,GAAG,OAClE,UAAA;AAAA,IAAA,oBAAC,YAAO,IAAG,SAAQ,IAAG,SAAQ,GAAE,SAAQ;AAAA,wBACvC,UAAA,EAAO,IAAG,SAAQ,IAAG,KAAI,GAAE,SAAQ;AAAA,wBACnC,UAAA,EAAO,IAAG,SAAQ,IAAG,UAAS,GAAE,SAAQ;AAAA,wBACxC,UAAA,EAAO,IAAG,UAAS,IAAG,SAAQ,GAAE,SAAQ;AAAA,wBACxC,UAAA,EAAO,IAAG,UAAS,IAAG,KAAI,GAAE,SAAQ;AAAA,wBACpC,UAAA,EAAO,IAAG,UAAS,IAAG,UAAS,GAAE,QAAA,CAAQ;AAAA,EAAA,GAC5C;AAEJ;AAuDO,MAAM,wBAAwB,MAAM,cAAqC,IAAI;AAG7E,MAAM,uBAAuB,MAAM,cAAoC,IAAI;"}
|