@fanvue/ui 3.41.0 → 3.42.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/Dialog/Dialog.cjs +63 -55
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/Tabs/Tabs.cjs +26 -1
- package/dist/cjs/components/Tabs/Tabs.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsList.cjs +163 -22
- package/dist/cjs/components/Tabs/TabsList.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsOverflow.cjs +123 -0
- package/dist/cjs/components/Tabs/TabsOverflow.cjs.map +1 -0
- package/dist/cjs/components/Tabs/TabsTrigger.cjs +27 -14
- package/dist/cjs/components/Tabs/TabsTrigger.cjs.map +1 -1
- package/dist/cjs/index.cjs +3 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/Dialog/Dialog.mjs +63 -55
- package/dist/components/Dialog/Dialog.mjs.map +1 -1
- package/dist/components/Tabs/Tabs.mjs +26 -2
- package/dist/components/Tabs/Tabs.mjs.map +1 -1
- package/dist/components/Tabs/TabsList.mjs +164 -23
- package/dist/components/Tabs/TabsList.mjs.map +1 -1
- package/dist/components/Tabs/TabsOverflow.mjs +106 -0
- package/dist/components/Tabs/TabsOverflow.mjs.map +1 -0
- package/dist/components/Tabs/TabsTrigger.mjs +27 -14
- package/dist/components/Tabs/TabsTrigger.mjs.map +1 -1
- package/dist/index.d.ts +90 -19
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -73,64 +73,72 @@ const DialogContent = React__namespace.forwardRef(
|
|
|
73
73
|
},
|
|
74
74
|
props
|
|
75
75
|
);
|
|
76
|
-
const content = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
77
|
+
DialogPrimitive__namespace.Content,
|
|
78
|
+
{
|
|
79
|
+
ref,
|
|
80
|
+
style: { zIndex: "var(--fanvue-ui-portal-z-index, 50)", ...style },
|
|
81
|
+
onOpenAutoFocus: (e) => {
|
|
82
|
+
if (onOpenAutoFocus) {
|
|
83
|
+
onOpenAutoFocus(e);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
e.currentTarget.focus();
|
|
88
|
+
},
|
|
89
|
+
className: cn.cn(
|
|
90
|
+
"fixed flex flex-col overflow-hidden border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px] focus:outline-none",
|
|
91
|
+
"data-[state=open]:fade-in-0 data-[state=open]:animate-in",
|
|
92
|
+
"data-[state=closed]:fade-out-0 data-[state=closed]:animate-out",
|
|
93
|
+
"data-[state=closed]:pointer-events-none!",
|
|
94
|
+
mobilePresentation === "card" ? (
|
|
95
|
+
// Floating confirmation card (v2-modal): 16px side margins, vertically centered, 32px radius
|
|
96
|
+
cn.cn(
|
|
97
|
+
"dialog-max-h-dynamic inset-x-4 top-1/2 -translate-y-1/2 rounded-xl p-6",
|
|
98
|
+
"data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95",
|
|
99
|
+
"sm:inset-x-auto"
|
|
100
|
+
)
|
|
101
|
+
) : (
|
|
102
|
+
// Bottom sheet pinned to the viewport bottom edge
|
|
103
|
+
cn.cn(
|
|
104
|
+
"dialog-max-h-dynamic inset-x-0 bottom-0 w-full rounded-t-xl p-4 pt-3",
|
|
105
|
+
"pb-[calc(1rem+env(safe-area-inset-bottom,0px))]",
|
|
106
|
+
"data-[state=open]:slide-in-from-bottom-full",
|
|
107
|
+
"data-[state=closed]:slide-out-to-bottom-full",
|
|
108
|
+
"sm:data-[state=open]:slide-in-from-bottom-0 sm:data-[state=open]:zoom-in-95",
|
|
109
|
+
"sm:data-[state=closed]:slide-out-to-bottom-0 sm:data-[state=closed]:zoom-out-95"
|
|
110
|
+
)
|
|
111
|
+
),
|
|
112
|
+
"sm:dialog-max-h-dynamic sm:inset-auto sm:top-1/2 sm:left-1/2 sm:w-full sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-lg sm:p-6",
|
|
113
|
+
"duration-200",
|
|
114
|
+
SIZE_CLASSES[size],
|
|
115
|
+
className
|
|
116
|
+
),
|
|
117
|
+
...contentProps,
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { ref: closeRef, hidden: true, tabIndex: -1, "aria-hidden": "true" }),
|
|
120
|
+
showMobileHandle && mobilePresentation === "sheet" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
className: "mb-3 h-1 w-8 shrink-0 self-center rounded-full bg-icons-tertiary sm:hidden"
|
|
87
125
|
}
|
|
88
|
-
e.preventDefault();
|
|
89
|
-
e.currentTarget.focus();
|
|
90
|
-
},
|
|
91
|
-
className: cn.cn(
|
|
92
|
-
"fixed flex flex-col overflow-hidden border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px] focus:outline-none",
|
|
93
|
-
"data-[state=open]:fade-in-0 data-[state=open]:animate-in",
|
|
94
|
-
"data-[state=closed]:fade-out-0 data-[state=closed]:animate-out",
|
|
95
|
-
mobilePresentation === "card" ? (
|
|
96
|
-
// Floating confirmation card (v2-modal): 16px side margins, vertically centered, 32px radius
|
|
97
|
-
cn.cn(
|
|
98
|
-
"dialog-max-h-dynamic inset-x-4 top-1/2 -translate-y-1/2 rounded-xl p-6",
|
|
99
|
-
"data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95",
|
|
100
|
-
"sm:inset-x-auto"
|
|
101
|
-
)
|
|
102
|
-
) : (
|
|
103
|
-
// Bottom sheet pinned to the viewport bottom edge
|
|
104
|
-
cn.cn(
|
|
105
|
-
"dialog-max-h-dynamic inset-x-0 bottom-0 w-full rounded-t-xl p-4 pt-3",
|
|
106
|
-
"pb-[calc(1rem+env(safe-area-inset-bottom,0px))]",
|
|
107
|
-
"data-[state=open]:slide-in-from-bottom-full",
|
|
108
|
-
"data-[state=closed]:slide-out-to-bottom-full",
|
|
109
|
-
"sm:data-[state=open]:slide-in-from-bottom-0 sm:data-[state=open]:zoom-in-95",
|
|
110
|
-
"sm:data-[state=closed]:slide-out-to-bottom-0 sm:data-[state=closed]:zoom-out-95"
|
|
111
|
-
)
|
|
112
|
-
),
|
|
113
|
-
"sm:dialog-max-h-dynamic sm:inset-auto sm:top-1/2 sm:left-1/2 sm:w-full sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-lg sm:p-6",
|
|
114
|
-
"duration-200",
|
|
115
|
-
SIZE_CLASSES[size],
|
|
116
|
-
className
|
|
117
126
|
),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
children
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
const overlayElement = overlay ? /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, { ...overlayProps }) : null;
|
|
132
|
+
if (!portal) {
|
|
133
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
134
|
+
overlayElement,
|
|
135
|
+
content
|
|
136
|
+
] });
|
|
137
|
+
}
|
|
138
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Portal, { children: [
|
|
139
|
+
overlayElement,
|
|
140
|
+
content
|
|
132
141
|
] });
|
|
133
|
-
return portal ? /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { children: content }) : content;
|
|
134
142
|
}
|
|
135
143
|
);
|
|
136
144
|
DialogContent.displayName = "DialogContent";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.cjs","sources":["../../../../src/components/Dialog/Dialog.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 { ArrowLeftIcon } from \"../Icons/ArrowLeftIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** Props for the {@link Dialog} root component. */\nexport interface DialogProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root> {\n /** Controlled open state. When provided, you must also supply `onOpenChange`. */\n open?: boolean;\n /** Called when the open state changes. Required when `open` is controlled. */\n onOpenChange?: (open: boolean) => void;\n /** The open state of the dialog when it is initially rendered (uncontrolled). */\n defaultOpen?: boolean;\n}\n\n/** Root component that manages open/close state for a dialog. */\nexport const Dialog = DialogPrimitive.Root;\n\n/** Props for the {@link DialogTrigger} component. */\nexport type DialogTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\n/**\n * The element that opens the dialog 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 dialog on a scroll-drag-end.\n */\nexport const DialogTrigger = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Trigger>,\n DialogTriggerProps\n>((props, ref) => <DialogPrimitive.Trigger ref={ref} {...useSuppressClickAfterDrag(props)} />);\nDialogTrigger.displayName = \"DialogTrigger\";\n\n/** Convenience alias for Radix `Dialog.Close`. Closes the dialog when clicked. */\nexport const DialogClose = DialogPrimitive.Close;\n\n/** Props for the {@link DialogClose} component. */\nexport type DialogCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\nexport interface DialogOverlayProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> {}\n\n/**\n * Semi-transparent backdrop rendered behind the dialog content.\n * Rendered by {@link DialogContent}; portaled to `document.body` when {@link DialogContent} `portal` is true.\n */\nexport const DialogOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n DialogOverlayProps\n>(({ className, style, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 fixed inset-0 bg-background-overlay-default data-[state=closed]:animate-out data-[state=open]:animate-in\",\n className,\n )}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n {...props}\n />\n));\nDialogOverlay.displayName = \"DialogOverlay\";\n\nexport interface DialogContentProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {\n /**\n * Width preset for the dialog.\n * - `\"sm\"` — 400px max-width (confirmations, simple forms)\n * - `\"md\"` — 440px max-width (default, standard dialogs)\n * - `\"lg\"` — 600px max-width (complex content, tables)\n *\n * @default \"md\"\n */\n size?: \"sm\" | \"md\" | \"lg\";\n /** When true, renders overlay automatically. @default true */\n overlay?: boolean;\n /**\n * When true, teleports overlay and panel to `document.body`.\n * When false, renders inline in the React tree (useful inside theme providers or scoped containers).\n * @default true\n */\n portal?: boolean;\n /** Show the v2 mobile sheet pull handle. Only rendered when `mobilePresentation` is `\"sheet\"`. @default true */\n showMobileHandle?: boolean;\n /**\n * How the dialog presents below the `sm` breakpoint.\n * - `\"sheet\"` — bottom sheet pinned to the viewport bottom edge (default)\n * - `\"card\"` — centered floating card per the v2-modal confirmation spec:\n * 16px side margins, 24px padding, 32px radius on all corners, no pull handle\n *\n * @default \"sheet\"\n */\n mobilePresentation?: \"sheet\" | \"card\";\n /** Props forwarded to the default {@link DialogOverlay} when `overlay` is `true`. */\n overlayProps?: DialogOverlayProps;\n}\n\nconst SIZE_CLASSES: Record<NonNullable<DialogContentProps[\"size\"]>, string> = {\n sm: \"sm:max-w-[400px]\",\n md: \"sm:max-w-[440px]\",\n lg: \"sm:max-w-[600px]\",\n};\n\n/**\n * The dialog panel. Includes the overlay by default and portals to `document.body` by default.\n *\n * Set `portal={false}` to keep overlay and content in the DOM subtree of the parent `Dialog`.\n * `fixed` positioning still applies; ancestors with `transform` or `overflow` may affect layout.\n *\n * On mobile viewports (<640px), the dialog slides up from the bottom as a sheet\n * with top-only border radius by default; pass `mobilePresentation=\"card\"` to\n * render a centered floating card instead (used for small confirmation dialogs).\n * On larger viewports it renders centered with full border radius.\n *\n * @example\n * ```tsx\n * <Dialog>\n * <DialogTrigger asChild>\n * <Button>Open</Button>\n * </DialogTrigger>\n * <DialogContent>\n * <DialogHeader>\n * <DialogTitle>Title</DialogTitle>\n * </DialogHeader>\n * <DialogBody>Content here</DialogBody>\n * <DialogFooter>\n * <DialogClose asChild>\n * <Button variant=\"secondary\">Cancel</Button>\n * </DialogClose>\n * <Button>Accept</Button>\n * </DialogFooter>\n * </DialogContent>\n * </Dialog>\n * ```\n */\nexport const DialogContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(\n (\n {\n className,\n children,\n size = \"md\",\n overlay = true,\n portal = true,\n showMobileHandle = true,\n mobilePresentation = \"sheet\",\n overlayProps,\n style,\n onOpenAutoFocus,\n ...props\n },\n ref,\n ) => {\n const closeRef = React.useRef<HTMLButtonElement>(null);\n const contentProps = useDragToDismiss(\n {\n enabled: mobilePresentation === \"sheet\",\n media: \"(max-width: 639.98px)\",\n onDismiss: () => closeRef.current?.click(),\n },\n props,\n );\n const content = (\n <>\n {overlay && <DialogOverlay {...overlayProps} />}\n <DialogPrimitive.Content\n ref={ref}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n onOpenAutoFocus={(e) => {\n if (onOpenAutoFocus) {\n onOpenAutoFocus(e);\n return;\n }\n e.preventDefault();\n (e.currentTarget as HTMLElement).focus();\n }}\n className={cn(\n \"fixed flex flex-col overflow-hidden border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px] focus:outline-none\",\n \"data-[state=open]:fade-in-0 data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:animate-out\",\n mobilePresentation === \"card\"\n ? // Floating confirmation card (v2-modal): 16px side margins, vertically centered, 32px radius\n cn(\n \"dialog-max-h-dynamic inset-x-4 top-1/2 -translate-y-1/2 rounded-xl p-6\",\n \"data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95\",\n \"sm:inset-x-auto\",\n )\n : // Bottom sheet pinned to the viewport bottom edge\n cn(\n \"dialog-max-h-dynamic inset-x-0 bottom-0 w-full rounded-t-xl p-4 pt-3\",\n \"pb-[calc(1rem+env(safe-area-inset-bottom,0px))]\",\n \"data-[state=open]:slide-in-from-bottom-full\",\n \"data-[state=closed]:slide-out-to-bottom-full\",\n \"sm:data-[state=open]:slide-in-from-bottom-0 sm:data-[state=open]:zoom-in-95\",\n \"sm:data-[state=closed]:slide-out-to-bottom-0 sm:data-[state=closed]:zoom-out-95\",\n ),\n \"sm:dialog-max-h-dynamic sm:inset-auto sm:top-1/2 sm:left-1/2 sm:w-full sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-lg sm:p-6\",\n \"duration-200\",\n SIZE_CLASSES[size],\n className,\n )}\n {...contentProps}\n >\n <DialogPrimitive.Close ref={closeRef} hidden tabIndex={-1} aria-hidden=\"true\" />\n {showMobileHandle && mobilePresentation === \"sheet\" && (\n <div\n aria-hidden=\"true\"\n className=\"mb-3 h-1 w-8 shrink-0 self-center rounded-full bg-icons-tertiary sm:hidden\"\n />\n )}\n {children}\n </DialogPrimitive.Content>\n </>\n );\n\n return portal ? <DialogPrimitive.Portal>{content}</DialogPrimitive.Portal> : content;\n },\n);\nDialogContent.displayName = \"DialogContent\";\n\nexport interface DialogHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Show the close (X) button in the header. @default true */\n showClose?: boolean;\n /** Show a back arrow button on the left side. Defaults to `true` when `onBack` is provided. */\n showBack?: boolean;\n /** Called when the back button is clicked. */\n onBack?: () => void;\n /** Accessible label for the back button. @default \"Go back\" */\n backLabel?: string;\n /** Accessible label for the close button. @default \"Close\" */\n closeLabel?: string;\n}\n\n/**\n * Header bar for the dialog. Renders the title with an optional back arrow\n * and close button.\n *\n * @example\n * ```tsx\n * <DialogHeader>\n * <DialogTitle>Settings</DialogTitle>\n * </DialogHeader>\n *\n * <DialogHeader showBack onBack={() => setStep(0)}>\n * <DialogTitle>Step 2</DialogTitle>\n * </DialogHeader>\n * ```\n */\nexport const DialogHeader = React.forwardRef<HTMLDivElement, DialogHeaderProps>(\n (\n {\n className,\n children,\n showClose = true,\n showBack,\n onBack,\n backLabel = \"Go back\",\n closeLabel = \"Close\",\n ...props\n },\n ref,\n ) => {\n const shouldShowBack = showBack ?? !!onBack;\n\n return (\n <div\n ref={ref}\n // items-start (not items-center) so the back/close buttons align to the\n // title's first line; otherwise they float to the vertical center of a\n // multi-line title + description column.\n className={cn(\"flex shrink-0 items-start justify-end gap-4\", className)}\n {...props}\n >\n {shouldShowBack && (\n <IconButton\n variant=\"secondary\"\n size=\"32\"\n icon={<ArrowLeftIcon size={16} />}\n onClick={onBack}\n disabled={!onBack}\n aria-label={backLabel}\n />\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 variant=\"secondary\"\n size=\"32\"\n icon={<CloseIcon size={16} />}\n aria-label={closeLabel}\n />\n </DialogPrimitive.Close>\n )}\n </div>\n );\n },\n);\nDialogHeader.displayName = \"DialogHeader\";\n\n/** Props for the {@link DialogTitle} component. */\nexport type DialogTitleProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>;\n\n/**\n * Accessible title for the dialog. Must be rendered inside {@link DialogHeader}\n * or directly within {@link DialogContent}.\n */\nexport const DialogTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n DialogTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"typography-header-heading-xs text-content-primary\", className)}\n {...props}\n />\n));\nDialogTitle.displayName = \"DialogTitle\";\n\n/** Props for the {@link DialogDescription} component. */\nexport type DialogDescriptionProps = React.ComponentPropsWithoutRef<\n typeof DialogPrimitive.Description\n>;\n\n/** Accessible description for the dialog. Rendered as secondary text. */\nexport const DialogDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n DialogDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"typography-body-default-16px-regular text-content-secondary\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = \"DialogDescription\";\n\nexport interface DialogBodyProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/**\n * Scrollable content area (slot) between the header and footer.\n * Grows to fill available space and scrolls when content overflows.\n */\nexport const DialogBody = React.forwardRef<HTMLDivElement, DialogBodyProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex-1 overflow-y-auto py-4\", className)} {...props} />\n ),\n);\nDialogBody.displayName = \"DialogBody\";\n\nexport interface DialogFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/**\n * Footer bar for the dialog. Typically contains action buttons.\n * Children are laid out in a horizontal row with equal flex-basis.\n */\nexport const DialogFooter = React.forwardRef<HTMLDivElement, DialogFooterProps>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\"flex shrink-0 items-center gap-2\", \"[&>*]:min-w-0 [&>*]:flex-1\", className)}\n {...props}\n />\n ),\n);\nDialogFooter.displayName = \"DialogFooter\";\n"],"names":["DialogPrimitive","React","jsx","useSuppressClickAfterDrag","cn","useDragToDismiss","jsxs","Fragment","IconButton","ArrowLeftIcon","CloseIcon"],"m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;AAAA,IACrF,GAAG;AAAA,EAAA;AACN,CACD;AACD,kBAAkB,cAAc;AAQzB,MAAM,aAAaH,iBAAM;AAAA,EAC9B,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QACxBC,2BAAAA,IAAC,OAAA,EAAI,KAAU,WAAWE,GAAAA,GAAG,+BAA+B,SAAS,GAAI,GAAG,MAAA,CAAO;AAEvF;AACA,WAAW,cAAc;AAQlB,MAAM,eAAeH,iBAAM;AAAA,EAChC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QACxBC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAWE,GAAAA,GAAG,oCAAoC,8BAA8B,SAAS;AAAA,MACxF,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;AACA,aAAa,cAAc;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Dialog.cjs","sources":["../../../../src/components/Dialog/Dialog.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 { ArrowLeftIcon } from \"../Icons/ArrowLeftIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** Props for the {@link Dialog} root component. */\nexport interface DialogProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root> {\n /** Controlled open state. When provided, you must also supply `onOpenChange`. */\n open?: boolean;\n /** Called when the open state changes. Required when `open` is controlled. */\n onOpenChange?: (open: boolean) => void;\n /** The open state of the dialog when it is initially rendered (uncontrolled). */\n defaultOpen?: boolean;\n}\n\n/** Root component that manages open/close state for a dialog. */\nexport const Dialog = DialogPrimitive.Root;\n\n/** Props for the {@link DialogTrigger} component. */\nexport type DialogTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\n/**\n * The element that opens the dialog 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 dialog on a scroll-drag-end.\n */\nexport const DialogTrigger = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Trigger>,\n DialogTriggerProps\n>((props, ref) => <DialogPrimitive.Trigger ref={ref} {...useSuppressClickAfterDrag(props)} />);\nDialogTrigger.displayName = \"DialogTrigger\";\n\n/** Convenience alias for Radix `Dialog.Close`. Closes the dialog when clicked. */\nexport const DialogClose = DialogPrimitive.Close;\n\n/** Props for the {@link DialogClose} component. */\nexport type DialogCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\nexport interface DialogOverlayProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> {}\n\n/**\n * Semi-transparent backdrop rendered behind the dialog content.\n * Rendered by {@link DialogContent}; portaled to `document.body` when {@link DialogContent} `portal` is true.\n */\nexport const DialogOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n DialogOverlayProps\n>(({ className, style, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 fixed inset-0 bg-background-overlay-default data-[state=closed]:animate-out data-[state=open]:animate-in\",\n className,\n )}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n {...props}\n />\n));\nDialogOverlay.displayName = \"DialogOverlay\";\n\nexport interface DialogContentProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {\n /**\n * Width preset for the dialog.\n * - `\"sm\"` — 400px max-width (confirmations, simple forms)\n * - `\"md\"` — 440px max-width (default, standard dialogs)\n * - `\"lg\"` — 600px max-width (complex content, tables)\n *\n * @default \"md\"\n */\n size?: \"sm\" | \"md\" | \"lg\";\n /** When true, renders overlay automatically. @default true */\n overlay?: boolean;\n /**\n * When true, teleports overlay and panel to `document.body`.\n * When false, renders inline in the React tree (useful inside theme providers or scoped containers).\n * @default true\n */\n portal?: boolean;\n /** Show the v2 mobile sheet pull handle. Only rendered when `mobilePresentation` is `\"sheet\"`. @default true */\n showMobileHandle?: boolean;\n /**\n * How the dialog presents below the `sm` breakpoint.\n * - `\"sheet\"` — bottom sheet pinned to the viewport bottom edge (default)\n * - `\"card\"` — centered floating card per the v2-modal confirmation spec:\n * 16px side margins, 24px padding, 32px radius on all corners, no pull handle\n *\n * @default \"sheet\"\n */\n mobilePresentation?: \"sheet\" | \"card\";\n /** Props forwarded to the default {@link DialogOverlay} when `overlay` is `true`. */\n overlayProps?: DialogOverlayProps;\n}\n\nconst SIZE_CLASSES: Record<NonNullable<DialogContentProps[\"size\"]>, string> = {\n sm: \"sm:max-w-[400px]\",\n md: \"sm:max-w-[440px]\",\n lg: \"sm:max-w-[600px]\",\n};\n\n/**\n * The dialog panel. Includes the overlay by default and portals to `document.body` by default.\n *\n * Set `portal={false}` to keep overlay and content in the DOM subtree of the parent `Dialog`.\n * `fixed` positioning still applies; ancestors with `transform` or `overflow` may affect layout.\n *\n * On mobile viewports (<640px), the dialog slides up from the bottom as a sheet\n * with top-only border radius by default; pass `mobilePresentation=\"card\"` to\n * render a centered floating card instead (used for small confirmation dialogs).\n * On larger viewports it renders centered with full border radius.\n *\n * It animates in and out. While the closing animation plays the panel stays\n * mounted but ignores pointer input, so a second click can't act on it.\n *\n * @example\n * ```tsx\n * <Dialog>\n * <DialogTrigger asChild>\n * <Button>Open</Button>\n * </DialogTrigger>\n * <DialogContent>\n * <DialogHeader>\n * <DialogTitle>Title</DialogTitle>\n * </DialogHeader>\n * <DialogBody>Content here</DialogBody>\n * <DialogFooter>\n * <DialogClose asChild>\n * <Button variant=\"secondary\">Cancel</Button>\n * </DialogClose>\n * <Button>Accept</Button>\n * </DialogFooter>\n * </DialogContent>\n * </Dialog>\n * ```\n */\nexport const DialogContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(\n (\n {\n className,\n children,\n size = \"md\",\n overlay = true,\n portal = true,\n showMobileHandle = true,\n mobilePresentation = \"sheet\",\n overlayProps,\n style,\n onOpenAutoFocus,\n ...props\n },\n ref,\n ) => {\n const closeRef = React.useRef<HTMLButtonElement>(null);\n const contentProps = useDragToDismiss(\n {\n enabled: mobilePresentation === \"sheet\",\n media: \"(max-width: 639.98px)\",\n onDismiss: () => closeRef.current?.click(),\n },\n props,\n );\n const content = (\n <DialogPrimitive.Content\n ref={ref}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n onOpenAutoFocus={(e) => {\n if (onOpenAutoFocus) {\n onOpenAutoFocus(e);\n return;\n }\n e.preventDefault();\n (e.currentTarget as HTMLElement).focus();\n }}\n className={cn(\n \"fixed flex flex-col overflow-hidden border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px] focus:outline-none\",\n \"data-[state=open]:fade-in-0 data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:animate-out\",\n \"data-[state=closed]:pointer-events-none!\",\n mobilePresentation === \"card\"\n ? // Floating confirmation card (v2-modal): 16px side margins, vertically centered, 32px radius\n cn(\n \"dialog-max-h-dynamic inset-x-4 top-1/2 -translate-y-1/2 rounded-xl p-6\",\n \"data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95\",\n \"sm:inset-x-auto\",\n )\n : // Bottom sheet pinned to the viewport bottom edge\n cn(\n \"dialog-max-h-dynamic inset-x-0 bottom-0 w-full rounded-t-xl p-4 pt-3\",\n \"pb-[calc(1rem+env(safe-area-inset-bottom,0px))]\",\n \"data-[state=open]:slide-in-from-bottom-full\",\n \"data-[state=closed]:slide-out-to-bottom-full\",\n \"sm:data-[state=open]:slide-in-from-bottom-0 sm:data-[state=open]:zoom-in-95\",\n \"sm:data-[state=closed]:slide-out-to-bottom-0 sm:data-[state=closed]:zoom-out-95\",\n ),\n \"sm:dialog-max-h-dynamic sm:inset-auto sm:top-1/2 sm:left-1/2 sm:w-full sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-lg sm:p-6\",\n \"duration-200\",\n SIZE_CLASSES[size],\n className,\n )}\n {...contentProps}\n >\n <DialogPrimitive.Close ref={closeRef} hidden tabIndex={-1} aria-hidden=\"true\" />\n {showMobileHandle && mobilePresentation === \"sheet\" && (\n <div\n aria-hidden=\"true\"\n className=\"mb-3 h-1 w-8 shrink-0 self-center rounded-full bg-icons-tertiary sm:hidden\"\n />\n )}\n {children}\n </DialogPrimitive.Content>\n );\n const overlayElement = overlay ? <DialogOverlay {...overlayProps} /> : null;\n\n if (!portal) {\n return (\n <>\n {overlayElement}\n {content}\n </>\n );\n }\n return (\n <DialogPrimitive.Portal>\n {overlayElement}\n {content}\n </DialogPrimitive.Portal>\n );\n },\n);\nDialogContent.displayName = \"DialogContent\";\n\nexport interface DialogHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Show the close (X) button in the header. @default true */\n showClose?: boolean;\n /** Show a back arrow button on the left side. Defaults to `true` when `onBack` is provided. */\n showBack?: boolean;\n /** Called when the back button is clicked. */\n onBack?: () => void;\n /** Accessible label for the back button. @default \"Go back\" */\n backLabel?: string;\n /** Accessible label for the close button. @default \"Close\" */\n closeLabel?: string;\n}\n\n/**\n * Header bar for the dialog. Renders the title with an optional back arrow\n * and close button.\n *\n * @example\n * ```tsx\n * <DialogHeader>\n * <DialogTitle>Settings</DialogTitle>\n * </DialogHeader>\n *\n * <DialogHeader showBack onBack={() => setStep(0)}>\n * <DialogTitle>Step 2</DialogTitle>\n * </DialogHeader>\n * ```\n */\nexport const DialogHeader = React.forwardRef<HTMLDivElement, DialogHeaderProps>(\n (\n {\n className,\n children,\n showClose = true,\n showBack,\n onBack,\n backLabel = \"Go back\",\n closeLabel = \"Close\",\n ...props\n },\n ref,\n ) => {\n const shouldShowBack = showBack ?? !!onBack;\n\n return (\n <div\n ref={ref}\n // items-start (not items-center) so the back/close buttons align to the\n // title's first line; otherwise they float to the vertical center of a\n // multi-line title + description column.\n className={cn(\"flex shrink-0 items-start justify-end gap-4\", className)}\n {...props}\n >\n {shouldShowBack && (\n <IconButton\n variant=\"secondary\"\n size=\"32\"\n icon={<ArrowLeftIcon size={16} />}\n onClick={onBack}\n disabled={!onBack}\n aria-label={backLabel}\n />\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 variant=\"secondary\"\n size=\"32\"\n icon={<CloseIcon size={16} />}\n aria-label={closeLabel}\n />\n </DialogPrimitive.Close>\n )}\n </div>\n );\n },\n);\nDialogHeader.displayName = \"DialogHeader\";\n\n/** Props for the {@link DialogTitle} component. */\nexport type DialogTitleProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>;\n\n/**\n * Accessible title for the dialog. Must be rendered inside {@link DialogHeader}\n * or directly within {@link DialogContent}.\n */\nexport const DialogTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n DialogTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"typography-header-heading-xs text-content-primary\", className)}\n {...props}\n />\n));\nDialogTitle.displayName = \"DialogTitle\";\n\n/** Props for the {@link DialogDescription} component. */\nexport type DialogDescriptionProps = React.ComponentPropsWithoutRef<\n typeof DialogPrimitive.Description\n>;\n\n/** Accessible description for the dialog. Rendered as secondary text. */\nexport const DialogDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n DialogDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"typography-body-default-16px-regular text-content-secondary\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = \"DialogDescription\";\n\nexport interface DialogBodyProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/**\n * Scrollable content area (slot) between the header and footer.\n * Grows to fill available space and scrolls when content overflows.\n */\nexport const DialogBody = React.forwardRef<HTMLDivElement, DialogBodyProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex-1 overflow-y-auto py-4\", className)} {...props} />\n ),\n);\nDialogBody.displayName = \"DialogBody\";\n\nexport interface DialogFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/**\n * Footer bar for the dialog. Typically contains action buttons.\n * Children are laid out in a horizontal row with equal flex-basis.\n */\nexport const DialogFooter = React.forwardRef<HTMLDivElement, DialogFooterProps>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\"flex shrink-0 items-center gap-2\", \"[&>*]:min-w-0 [&>*]:flex-1\", className)}\n {...props}\n />\n ),\n);\nDialogFooter.displayName = \"DialogFooter\";\n"],"names":["DialogPrimitive","React","jsx","useSuppressClickAfterDrag","cn","useDragToDismiss","jsxs","Fragment","IconButton","ArrowLeftIcon","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAM,SAASA,2BAAgB;AAY/B,MAAM,gBAAgBC,iBAAM,WAGjC,CAAC,OAAO,QAAQC,2BAAAA,IAACF,2BAAgB,SAAhB,EAAwB,KAAW,GAAGG,0BAAAA,0BAA0B,KAAK,GAAG,CAAE;AAC7F,cAAc,cAAc;AAGrB,MAAM,cAAcH,2BAAgB;AAYpC,MAAM,gBAAgBC,iBAAM,WAGjC,CAAC,EAAE,WAAW,OAAO,GAAG,SAAS,QACjCC,2BAAAA;AAAAA,EAACF,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWI,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAEF,OAAO,EAAE,QAAQ,uCAAuC,GAAG,MAAA;AAAA,IAC1D,GAAG;AAAA,EAAA;AACN,CACD;AACD,cAAc,cAAc;AAoC5B,MAAM,eAAwE;AAAA,EAC5E,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAqCO,MAAM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
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
5
|
const TabsPrimitive = require("@radix-ui/react-tabs");
|
|
6
|
+
const React = require("react");
|
|
5
7
|
function _interopNamespaceDefault(e) {
|
|
6
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
9
|
if (e) {
|
|
@@ -19,6 +21,29 @@ function _interopNamespaceDefault(e) {
|
|
|
19
21
|
return Object.freeze(n);
|
|
20
22
|
}
|
|
21
23
|
const TabsPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(TabsPrimitive);
|
|
22
|
-
const
|
|
24
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
25
|
+
const OVERFLOW_TAB_VALUE = "fanvue-ui-tabs-overflow";
|
|
26
|
+
const TabsValueContext = React__namespace.createContext({ value: void 0, select: () => {
|
|
27
|
+
} });
|
|
28
|
+
const Tabs = React__namespace.forwardRef(
|
|
29
|
+
({ value: valueProp, defaultValue, onValueChange, ...props }, ref) => {
|
|
30
|
+
const [uncontrolledValue, setUncontrolledValue] = React__namespace.useState(defaultValue);
|
|
31
|
+
const isControlled = valueProp !== void 0;
|
|
32
|
+
const value = isControlled ? valueProp : uncontrolledValue;
|
|
33
|
+
const select = React__namespace.useCallback(
|
|
34
|
+
(next) => {
|
|
35
|
+
if (next === OVERFLOW_TAB_VALUE) return;
|
|
36
|
+
if (!isControlled) setUncontrolledValue(next);
|
|
37
|
+
onValueChange?.(next);
|
|
38
|
+
},
|
|
39
|
+
[isControlled, onValueChange]
|
|
40
|
+
);
|
|
41
|
+
const context = React__namespace.useMemo(() => ({ value, select }), [value, select]);
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TabsValueContext.Provider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(TabsPrimitive__namespace.Root, { ref, value: value ?? "", onValueChange: select, ...props }) });
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
Tabs.displayName = "Tabs";
|
|
46
|
+
exports.OVERFLOW_TAB_VALUE = OVERFLOW_TAB_VALUE;
|
|
23
47
|
exports.Tabs = Tabs;
|
|
48
|
+
exports.TabsValueContext = TabsValueContext;
|
|
24
49
|
//# sourceMappingURL=Tabs.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.cjs","sources":["../../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport
|
|
1
|
+
{"version":3,"file":"Tabs.cjs","sources":["../../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport * as React from \"react\";\n\n/**\n * Value a {@link TabsOverflow} tab carries while none of its items is active.\n * {@link Tabs} never reports or stores it, so focusing More under automatic\n * activation selects nothing.\n */\nexport const OVERFLOW_TAB_VALUE = \"fanvue-ui-tabs-overflow\";\n\n/** Props for the {@link Tabs} root component. Extends Radix `Tabs.Root` props. */\nexport type TabsProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root>;\n\n/**\n * Root container for a tabbed interface. Manages the active tab state and\n * coordinates {@link TabsList}, {@link TabsTrigger}, and {@link TabsContent}.\n *\n * Built on Radix UI `Tabs`.\n *\n * @example\n * ```tsx\n * <Tabs defaultValue=\"tab1\">\n * <TabsList>\n * <TabsTrigger value=\"tab1\">Tab 1</TabsTrigger>\n * <TabsTrigger value=\"tab2\">Tab 2</TabsTrigger>\n * </TabsList>\n * <TabsContent value=\"tab1\">Content 1</TabsContent>\n * <TabsContent value=\"tab2\">Content 2</TabsContent>\n * </Tabs>\n * ```\n */\nexport const TabsValueContext = React.createContext<{\n value: string | undefined;\n select: (value: string) => void;\n}>({ value: undefined, select: () => {} });\n\nexport const Tabs = React.forwardRef<React.ComponentRef<typeof TabsPrimitive.Root>, TabsProps>(\n ({ value: valueProp, defaultValue, onValueChange, ...props }, ref) => {\n const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);\n const isControlled = valueProp !== undefined;\n const value = isControlled ? valueProp : uncontrolledValue;\n\n const select = React.useCallback(\n (next: string) => {\n if (next === OVERFLOW_TAB_VALUE) return;\n if (!isControlled) setUncontrolledValue(next);\n onValueChange?.(next);\n },\n [isControlled, onValueChange],\n );\n\n const context = React.useMemo(() => ({ value, select }), [value, select]);\n\n return (\n <TabsValueContext.Provider value={context}>\n <TabsPrimitive.Root ref={ref} value={value ?? \"\"} onValueChange={select} {...props} />\n </TabsValueContext.Provider>\n );\n },\n);\n\nTabs.displayName = \"Tabs\";\n"],"names":["React","TabsPrimitive"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM,qBAAqB;AAuB3B,MAAM,mBAAmBA,iBAAM,cAGnC,EAAE,OAAO,QAAW,QAAQ,MAAM;AAAC,EAAA,CAAG;AAElC,MAAM,OAAOA,iBAAM;AAAA,EACxB,CAAC,EAAE,OAAO,WAAW,cAAc,eAAe,GAAG,MAAA,GAAS,QAAQ;AACpE,UAAM,CAAC,mBAAmB,oBAAoB,IAAIA,iBAAM,SAAS,YAAY;AAC7E,UAAM,eAAe,cAAc;AACnC,UAAM,QAAQ,eAAe,YAAY;AAEzC,UAAM,SAASA,iBAAM;AAAA,MACnB,CAAC,SAAiB;AAChB,YAAI,SAAS,mBAAoB;AACjC,YAAI,CAAC,aAAc,sBAAqB,IAAI;AAC5C,wBAAgB,IAAI;AAAA,MACtB;AAAA,MACA,CAAC,cAAc,aAAa;AAAA,IAAA;AAG9B,UAAM,UAAUA,iBAAM,QAAQ,OAAO,EAAE,OAAO,OAAA,IAAW,CAAC,OAAO,MAAM,CAAC;AAExE,0CACG,iBAAiB,UAAjB,EAA0B,OAAO,SAChC,yCAACC,yBAAc,MAAd,EAAmB,KAAU,OAAO,SAAS,IAAI,eAAe,QAAS,GAAG,OAAO,GACtF;AAAA,EAEJ;AACF;AAEA,KAAK,cAAc;;;;"}
|
|
@@ -23,6 +23,61 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
}
|
|
24
24
|
const TabsPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(TabsPrimitive);
|
|
25
25
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
+
const TabsAppearanceContext = React__namespace.createContext({ appearance: "underline", size: "32" });
|
|
27
|
+
const PILL_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
28
|
+
const PILL_STEP_MS = 360;
|
|
29
|
+
const PILL_STEP_MS_TOUCH = 200;
|
|
30
|
+
const PILL_EXTRA_STEP_MS = 220;
|
|
31
|
+
const PILL_MAX_MS = 1e3;
|
|
32
|
+
const PILL_ARRIVAL_SHARE = 0.27;
|
|
33
|
+
function pillStepMs(canHover) {
|
|
34
|
+
return canHover ? PILL_STEP_MS : PILL_STEP_MS_TOUCH;
|
|
35
|
+
}
|
|
36
|
+
function pillSlideMs(distance, canHover) {
|
|
37
|
+
if (!canHover) return PILL_STEP_MS_TOUCH;
|
|
38
|
+
return Math.min(PILL_STEP_MS + Math.max(distance - 1, 0) * PILL_EXTRA_STEP_MS, PILL_MAX_MS);
|
|
39
|
+
}
|
|
40
|
+
const prefersReducedMotion = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
|
|
41
|
+
function pillTarget(list, hovered, activeTab) {
|
|
42
|
+
return list.querySelector('[role="tab"][aria-expanded="true"]') ?? (hovered?.isConnected ? hovered : activeTab);
|
|
43
|
+
}
|
|
44
|
+
function measureTabs(list, observer) {
|
|
45
|
+
const boxes = /* @__PURE__ */ new Map();
|
|
46
|
+
const order = /* @__PURE__ */ new Map();
|
|
47
|
+
for (const tab of list.querySelectorAll('[role="tab"]')) {
|
|
48
|
+
observer?.observe(tab);
|
|
49
|
+
order.set(tab, order.size);
|
|
50
|
+
boxes.set(tab, {
|
|
51
|
+
left: tab.offsetLeft,
|
|
52
|
+
top: tab.offsetTop,
|
|
53
|
+
width: tab.offsetWidth,
|
|
54
|
+
height: tab.offsetHeight
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return { boxes, order };
|
|
58
|
+
}
|
|
59
|
+
function slideFromPrevious(list, previous, next, durationMs) {
|
|
60
|
+
const moved = [];
|
|
61
|
+
for (const [tab, box] of next) {
|
|
62
|
+
const before = previous.get(tab);
|
|
63
|
+
if (!before || before.left === box.left || !(tab instanceof HTMLElement)) continue;
|
|
64
|
+
tab.style.transition = "none";
|
|
65
|
+
tab.style.transform = `translateX(${before.left - box.left}px)`;
|
|
66
|
+
moved.push(tab);
|
|
67
|
+
}
|
|
68
|
+
if (moved.length === 0) return;
|
|
69
|
+
list.getBoundingClientRect();
|
|
70
|
+
for (const tab of moved) {
|
|
71
|
+
tab.style.transition = `transform ${durationMs}ms var(--pill-ease)`;
|
|
72
|
+
tab.style.transform = "";
|
|
73
|
+
const settle = (event) => {
|
|
74
|
+
if (event.propertyName !== "transform") return;
|
|
75
|
+
tab.style.transition = "";
|
|
76
|
+
tab.removeEventListener("transitionend", settle);
|
|
77
|
+
};
|
|
78
|
+
tab.addEventListener("transitionend", settle);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
26
81
|
const alignLeftClasses = {
|
|
27
82
|
always: "[&>[role=tab]]:flex-initial",
|
|
28
83
|
sm: "[&>[role=tab]]:sm:flex-initial",
|
|
@@ -48,11 +103,61 @@ const TabsList = React__namespace.forwardRef(
|
|
|
48
103
|
variant,
|
|
49
104
|
flushLeft = false,
|
|
50
105
|
scrollable = false,
|
|
106
|
+
appearance = "underline",
|
|
107
|
+
size = "32",
|
|
108
|
+
followHover = false,
|
|
109
|
+
onPointerOver,
|
|
110
|
+
onPointerLeave,
|
|
111
|
+
style,
|
|
51
112
|
...props
|
|
52
113
|
}, ref) => {
|
|
53
114
|
const innerRef = React__namespace.useRef(null);
|
|
54
115
|
const indicatorRef = React__namespace.useRef(null);
|
|
55
116
|
React__namespace.useImperativeHandle(ref, () => innerRef.current);
|
|
117
|
+
const tabBoxes = React__namespace.useRef(/* @__PURE__ */ new Map());
|
|
118
|
+
const resizeObserverRef = React__namespace.useRef(null);
|
|
119
|
+
const listWidth = React__namespace.useRef(null);
|
|
120
|
+
const hoveredTab = React__namespace.useRef(null);
|
|
121
|
+
const pillTab = React__namespace.useRef(null);
|
|
122
|
+
const tabOrder = React__namespace.useRef(/* @__PURE__ */ new Map());
|
|
123
|
+
const canHover = React__namespace.useRef(false);
|
|
124
|
+
const placePill = React__namespace.useCallback((tab) => {
|
|
125
|
+
const list = innerRef.current;
|
|
126
|
+
const indicator = indicatorRef.current;
|
|
127
|
+
if (!list || !indicator) return;
|
|
128
|
+
const box = tabBoxes.current.get(tab);
|
|
129
|
+
if (!box) return;
|
|
130
|
+
const from = pillTab.current;
|
|
131
|
+
pillTab.current = tab;
|
|
132
|
+
const distance = from && from !== tab ? Math.abs((tabOrder.current.get(tab) ?? 0) - (tabOrder.current.get(from) ?? 0)) : 0;
|
|
133
|
+
const slideMs = pillSlideMs(distance, canHover.current);
|
|
134
|
+
list.style.setProperty("--pill-slide", `${slideMs}ms`);
|
|
135
|
+
list.style.setProperty("--pill-arrive", `${Math.round(slideMs * PILL_ARRIVAL_SHARE)}ms`);
|
|
136
|
+
indicator.style.width = `${box.width}px`;
|
|
137
|
+
indicator.style.height = `${box.height}px`;
|
|
138
|
+
indicator.style.transform = `translate(${box.left}px, ${box.top}px)`;
|
|
139
|
+
for (const marked of list.querySelectorAll("[data-pill]")) {
|
|
140
|
+
if (marked !== tab) marked.removeAttribute("data-pill");
|
|
141
|
+
}
|
|
142
|
+
tab.setAttribute("data-pill", "");
|
|
143
|
+
}, []);
|
|
144
|
+
const layoutPill = React__namespace.useCallback(
|
|
145
|
+
(list, indicator, activeTab) => {
|
|
146
|
+
indicator.style.background = "var(--color-content-primary)";
|
|
147
|
+
indicator.style.inset = "0 auto auto 0";
|
|
148
|
+
const previous = tabBoxes.current;
|
|
149
|
+
const rowResized = listWidth.current !== null && listWidth.current !== list.offsetWidth;
|
|
150
|
+
listWidth.current = list.offsetWidth;
|
|
151
|
+
const { boxes, order } = measureTabs(list, resizeObserverRef.current);
|
|
152
|
+
tabBoxes.current = boxes;
|
|
153
|
+
tabOrder.current = order;
|
|
154
|
+
if (!rowResized && previous.size > 0 && !prefersReducedMotion()) {
|
|
155
|
+
slideFromPrevious(list, previous, boxes, pillStepMs(canHover.current));
|
|
156
|
+
}
|
|
157
|
+
placePill(pillTarget(list, hoveredTab.current, activeTab));
|
|
158
|
+
},
|
|
159
|
+
[placePill]
|
|
160
|
+
);
|
|
56
161
|
const updateIndicator = React__namespace.useCallback(() => {
|
|
57
162
|
const list = innerRef.current;
|
|
58
163
|
const indicator = indicatorRef.current;
|
|
@@ -60,11 +165,14 @@ const TabsList = React__namespace.forwardRef(
|
|
|
60
165
|
const activeTab = list.querySelector('[data-state="active"]');
|
|
61
166
|
if (!activeTab) {
|
|
62
167
|
indicator.style.opacity = "0";
|
|
168
|
+
list.querySelector("[data-pill]")?.removeAttribute("data-pill");
|
|
63
169
|
return;
|
|
64
170
|
}
|
|
65
171
|
const isVertical = list.dataset.orientation === "vertical";
|
|
66
172
|
indicator.style.opacity = "1";
|
|
67
|
-
if (
|
|
173
|
+
if (appearance === "pill") {
|
|
174
|
+
layoutPill(list, indicator, activeTab);
|
|
175
|
+
} else if (isVertical) {
|
|
68
176
|
indicator.style.background = "linear-gradient(180deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)";
|
|
69
177
|
indicator.style.inset = `0 -1px auto auto`;
|
|
70
178
|
indicator.style.width = "1px";
|
|
@@ -77,19 +185,42 @@ const TabsList = React__namespace.forwardRef(
|
|
|
77
185
|
indicator.style.width = `${activeTab.offsetWidth}px`;
|
|
78
186
|
indicator.style.transform = `translateX(${activeTab.offsetLeft}px)`;
|
|
79
187
|
}
|
|
80
|
-
}, []);
|
|
188
|
+
}, [appearance, layoutPill]);
|
|
189
|
+
const followsHover = appearance === "pill" && followHover;
|
|
190
|
+
const handlePointerOver = (event) => {
|
|
191
|
+
onPointerOver?.(event);
|
|
192
|
+
if (!followsHover || event.pointerType !== "mouse") return;
|
|
193
|
+
if (prefersReducedMotion()) return;
|
|
194
|
+
const tab = event.target.closest('[role="tab"]');
|
|
195
|
+
if (!tab || tab === hoveredTab.current || !event.currentTarget.contains(tab)) return;
|
|
196
|
+
hoveredTab.current = tab;
|
|
197
|
+
placePill(pillTarget(event.currentTarget, tab, tab));
|
|
198
|
+
};
|
|
199
|
+
const handlePointerLeave = (event) => {
|
|
200
|
+
onPointerLeave?.(event);
|
|
201
|
+
if (!hoveredTab.current) return;
|
|
202
|
+
hoveredTab.current = null;
|
|
203
|
+
const list = innerRef.current;
|
|
204
|
+
const activeTab = list?.querySelector('[data-state="active"]');
|
|
205
|
+
if (list && activeTab) placePill(pillTarget(list, null, activeTab));
|
|
206
|
+
};
|
|
81
207
|
const revealActiveTab = React__namespace.useCallback(() => {
|
|
82
208
|
const list = innerRef.current;
|
|
83
|
-
|
|
209
|
+
const scrolls = scrollable || appearance === "pill";
|
|
210
|
+
if (!list || !scrolls || list.dataset.orientation === "vertical") return;
|
|
84
211
|
const activeTab = list.querySelector('[data-state="active"]');
|
|
85
212
|
if (!activeTab) return;
|
|
86
213
|
const overshoot = activeTab.offsetLeft + activeTab.offsetWidth - list.clientWidth;
|
|
87
214
|
if (overshoot > list.scrollLeft) list.scrollLeft = overshoot;
|
|
88
|
-
}, [scrollable]);
|
|
215
|
+
}, [scrollable, appearance]);
|
|
89
216
|
React__namespace.useLayoutEffect(() => {
|
|
90
217
|
const list = innerRef.current;
|
|
91
218
|
const indicator = indicatorRef.current;
|
|
92
219
|
if (!list || !indicator) return;
|
|
220
|
+
canHover.current = window.matchMedia?.("(hover: hover)").matches ?? false;
|
|
221
|
+
const resizeObserver = new ResizeObserver(updateIndicator);
|
|
222
|
+
resizeObserver.observe(list);
|
|
223
|
+
resizeObserverRef.current = resizeObserver;
|
|
93
224
|
indicator.style.transitionDuration = "0s";
|
|
94
225
|
updateIndicator();
|
|
95
226
|
indicator.getBoundingClientRect();
|
|
@@ -98,12 +229,10 @@ const TabsList = React__namespace.forwardRef(
|
|
|
98
229
|
const mutationObserver = new MutationObserver(updateIndicator);
|
|
99
230
|
mutationObserver.observe(list, {
|
|
100
231
|
attributes: true,
|
|
101
|
-
attributeFilter: ["data-state"],
|
|
232
|
+
attributeFilter: ["data-state", "aria-expanded"],
|
|
102
233
|
childList: true,
|
|
103
234
|
subtree: true
|
|
104
235
|
});
|
|
105
|
-
const resizeObserver = new ResizeObserver(updateIndicator);
|
|
106
|
-
resizeObserver.observe(list);
|
|
107
236
|
let cancelled = false;
|
|
108
237
|
if (document.fonts?.status !== "loaded") {
|
|
109
238
|
document.fonts?.ready.then(() => {
|
|
@@ -116,29 +245,37 @@ const TabsList = React__namespace.forwardRef(
|
|
|
116
245
|
cancelled = true;
|
|
117
246
|
mutationObserver.disconnect();
|
|
118
247
|
resizeObserver.disconnect();
|
|
248
|
+
resizeObserverRef.current = null;
|
|
119
249
|
};
|
|
120
250
|
}, [updateIndicator, revealActiveTab]);
|
|
121
|
-
|
|
251
|
+
const isPill = appearance === "pill";
|
|
252
|
+
const listStyle = isPill ? { "--pill-ease": PILL_EASE, ...style } : { ...style };
|
|
253
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TabsAppearanceContext.Provider, { value: { appearance, size }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
122
254
|
TabsPrimitive__namespace.List,
|
|
123
255
|
{
|
|
124
256
|
ref: innerRef,
|
|
257
|
+
onPointerOver: handlePointerOver,
|
|
258
|
+
onPointerLeave: handlePointerLeave,
|
|
259
|
+
style: listStyle,
|
|
125
260
|
className: cn.cn(
|
|
126
261
|
// `isolate` scopes the active indicator's `z-10` to a local stacking
|
|
127
262
|
// context. Without it, `relative` alone creates no stacking context, so
|
|
128
263
|
// the indicator escapes and paints above page chrome (e.g. the header).
|
|
129
264
|
"relative isolate",
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
265
|
+
isPill ? "inline-flex w-fit max-w-full items-center gap-1 overflow-x-auto rounded-full bg-background-secondary p-1 shadow-md [scrollbar-width:none] [&::-webkit-scrollbar]:hidden" : [
|
|
266
|
+
getLayoutClass(variant, fullWidth, alignLeft),
|
|
267
|
+
// Horizontal only: in the vertical orientation the leading padding is
|
|
268
|
+
// the row's left inset, not a label offset, so zeroing it would pull
|
|
269
|
+
// the first label out of line with the others.
|
|
270
|
+
flushLeft && "data-[orientation=horizontal]:[&>[role=tab]:first-child]:pl-0",
|
|
271
|
+
// `flex-none` is what stops the tabs compressing — without it they
|
|
272
|
+
// share the row and never overflow, so there is nothing to scroll.
|
|
273
|
+
// The scrollbar is hidden in both engines: Firefox reads
|
|
274
|
+
// `scrollbar-width`, WebKit and Blink the pseudo-element.
|
|
275
|
+
scrollable && "data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:[scrollbar-width:none] data-[orientation=horizontal]:[&::-webkit-scrollbar]:hidden data-[orientation=horizontal]:[&>[role=tab]]:flex-none",
|
|
276
|
+
"data-[orientation=horizontal]:items-center data-[orientation=horizontal]:shadow-[inset_0_-1px_0_0_var(--color-border-primary)]",
|
|
277
|
+
"data-[orientation=vertical]:flex-col data-[orientation=vertical]:shadow-[inset_-1px_0_0_0_var(--color-border-primary)]"
|
|
278
|
+
],
|
|
142
279
|
className
|
|
143
280
|
),
|
|
144
281
|
...props,
|
|
@@ -149,15 +286,19 @@ const TabsList = React__namespace.forwardRef(
|
|
|
149
286
|
{
|
|
150
287
|
ref: indicatorRef,
|
|
151
288
|
"aria-hidden": true,
|
|
152
|
-
className:
|
|
289
|
+
className: cn.cn(
|
|
290
|
+
"pointer-events-none absolute rounded-full motion-safe:transition-[transform,width,height]",
|
|
291
|
+
isPill ? "z-5 motion-safe:duration-(--pill-slide) motion-safe:ease-(--pill-ease)" : "z-10 motion-safe:duration-200 motion-safe:ease-in-out"
|
|
292
|
+
),
|
|
153
293
|
style: { opacity: 0 }
|
|
154
294
|
}
|
|
155
295
|
)
|
|
156
296
|
]
|
|
157
297
|
}
|
|
158
|
-
);
|
|
298
|
+
) });
|
|
159
299
|
}
|
|
160
300
|
);
|
|
161
301
|
TabsList.displayName = "TabsList";
|
|
302
|
+
exports.TabsAppearanceContext = TabsAppearanceContext;
|
|
162
303
|
exports.TabsList = TabsList;
|
|
163
304
|
//# sourceMappingURL=TabsList.cjs.map
|