@fanvue/ui 3.38.0 → 3.40.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/ChatEmbed/ChatEmbed.cjs +4 -1
- package/dist/cjs/components/ChatEmbed/ChatEmbed.cjs.map +1 -1
- package/dist/cjs/components/Checkbox/Checkbox.cjs +1 -1
- package/dist/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/cjs/components/Chip/Chip.cjs +2 -2
- package/dist/cjs/components/Chip/Chip.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.cjs +12 -1
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/Drawer/Drawer.cjs +12 -3
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuHeader.cjs +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuHeader.cjs.map +1 -1
- package/dist/cjs/components/SearchField/SearchField.cjs +5 -1
- package/dist/cjs/components/SearchField/SearchField.cjs.map +1 -1
- package/dist/cjs/components/TextField/TextField.cjs +16 -3
- package/dist/cjs/components/TextField/TextField.cjs.map +1 -1
- package/dist/cjs/utils/useDragToDismiss.cjs +145 -0
- package/dist/cjs/utils/useDragToDismiss.cjs.map +1 -0
- package/dist/components/ChatEmbed/ChatEmbed.mjs +4 -1
- package/dist/components/ChatEmbed/ChatEmbed.mjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.mjs +1 -1
- package/dist/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/components/Chip/Chip.mjs +2 -2
- package/dist/components/Chip/Chip.mjs.map +1 -1
- package/dist/components/Dialog/Dialog.mjs +12 -1
- package/dist/components/Dialog/Dialog.mjs.map +1 -1
- package/dist/components/Drawer/Drawer.mjs +12 -3
- package/dist/components/Drawer/Drawer.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuHeader.mjs +1 -1
- package/dist/components/DropdownMenu/DropdownMenuHeader.mjs.map +1 -1
- package/dist/components/SearchField/SearchField.mjs +5 -1
- package/dist/components/SearchField/SearchField.mjs.map +1 -1
- package/dist/components/TextField/TextField.mjs +16 -3
- package/dist/components/TextField/TextField.mjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/utils/useDragToDismiss.mjs +128 -0
- package/dist/utils/useDragToDismiss.mjs.map +1 -0
- package/package.json +2 -1
|
@@ -106,6 +106,7 @@ function Scrim({ experience }) {
|
|
|
106
106
|
}
|
|
107
107
|
function CreatorName({
|
|
108
108
|
verified,
|
|
109
|
+
verifiedLabel,
|
|
109
110
|
aiDisclosure,
|
|
110
111
|
aiDisclosureLabel,
|
|
111
112
|
nameId,
|
|
@@ -118,6 +119,7 @@ function CreatorName({
|
|
|
118
119
|
{
|
|
119
120
|
component: "p",
|
|
120
121
|
verified,
|
|
122
|
+
verifiedLabel,
|
|
121
123
|
className: cn.cn("m-0 [&>[role=img]]:ml-1 [&>span:empty+[role=img]]:ml-0", className),
|
|
122
124
|
children: children && /* @__PURE__ */ jsxRuntime.jsx("span", { id: nameId, children })
|
|
123
125
|
}
|
|
@@ -181,6 +183,7 @@ const ChatEmbed = React__namespace.forwardRef(
|
|
|
181
183
|
title,
|
|
182
184
|
subtitle,
|
|
183
185
|
verified = false,
|
|
186
|
+
verifiedLabel = "Verified",
|
|
184
187
|
aiDisclosure = false,
|
|
185
188
|
aiDisclosureLabel = "AI creator",
|
|
186
189
|
action,
|
|
@@ -198,7 +201,7 @@ const ChatEmbed = React__namespace.forwardRef(
|
|
|
198
201
|
const titleId = React__namespace.useId();
|
|
199
202
|
const isExperience = variant === "experience";
|
|
200
203
|
const hasTopRow = Boolean(badge || category || meta);
|
|
201
|
-
const badges = { verified, aiDisclosure, aiDisclosureLabel };
|
|
204
|
+
const badges = { verified, verifiedLabel, aiDisclosure, aiDisclosureLabel };
|
|
202
205
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
203
206
|
"div",
|
|
204
207
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatEmbed.cjs","sources":["../../../../src/components/ChatEmbed/ChatEmbed.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { AiDisclosureBadge } from \"../AiDisclosureBadge/AiDisclosureBadge\";\nimport { Avatar, type AvatarProps } from \"../Avatar/Avatar\";\nimport { Skeleton } from \"../Skeleton/Skeleton\";\nimport { UserDisplayName } from \"../UserDisplayName/UserDisplayName\";\n\n/** Layout of the embed: a creator profile card or a fan experience card. */\nexport type ChatEmbedVariant = \"creator\" | \"experience\";\n\n/** Overlapping avatars and copy showing who else is taking part. */\nexport interface ChatEmbedSocialProof {\n /** Avatars shown in the overlapping stack, left to right. */\n avatars: AvatarProps[];\n /** Name shown in bold before the label, truncated at 120px. */\n name?: React.ReactNode;\n /** Copy shown after the name, e.g. \"+2 watching\". */\n label: React.ReactNode;\n}\n\ninterface ChatEmbedBaseProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\" | \"onClick\"> {\n /** Media filling the card, typically an `img` or `video`, over a dark surface. */\n media?: React.ReactNode;\n /** Still image blurred behind `verticalMedia`, e.g. the same image or a video's poster frame. */\n mediaBackdrop?: React.ReactNode;\n /** Frame portrait media in a centred 9:16 column over `mediaBackdrop`. @default false */\n verticalMedia?: boolean;\n /** Avatar shown at the start of the profile row. */\n avatar?: AvatarProps;\n /** Primary line of the profile row: a display name or an experience title. */\n title: React.ReactNode;\n /** Secondary line under the title, e.g. a handle or \"Made by @jane_doe\". */\n subtitle?: React.ReactNode;\n /** Show the verified badge on the creator line. @default false */\n verified?: boolean;\n /** Show the EU AI-disclosure badge on the creator line. @default false */\n aiDisclosure?: boolean;\n /** Accessible label for the AI-disclosure badge. @default \"AI creator\" */\n aiDisclosureLabel?: string;\n /** Action at the end of the profile row, typically a `Button` with `variant=\"white\"` and `size=\"32\"`. */\n action?: React.ReactNode;\n /** Badge in the top-left corner, typically a {@link LiveStatus}. */\n badge?: React.ReactNode;\n /** Short category label shown as a tag after the badge, e.g. \"Game\" or \"Audio\". */\n category?: React.ReactNode;\n /** Short copy in a translucent pill in the top-right corner, e.g. \"2 hours ago\". */\n meta?: React.ReactNode;\n /** Renders the media in greyscale, e.g. once a live has ended. @default false */\n inactive?: boolean;\n}\n\ninterface ChatEmbedLinkProps {\n /** Makes the whole card a link to this URL, named by the title. */\n href: string;\n /** Where to open `href`; `\"_blank\"` adds `rel=\"noopener noreferrer\"`. */\n target?: React.HTMLAttributeAnchorTarget;\n /** Not available with `href`. */\n onOpen?: never;\n}\n\ninterface ChatEmbedButtonProps {\n /** Not available with `onOpen`. */\n href?: never;\n /** Not available with `onOpen`. */\n target?: never;\n /** Makes the whole card a button named by the title, e.g. to open a dialog. */\n onOpen?: () => void;\n}\n\ninterface ChatEmbedCreatorProps extends ChatEmbedBaseProps {\n /** Layout of the embed. @default \"creator\" */\n variant?: \"creator\";\n /** Only available on the `experience` variant. */\n socialProof?: never;\n}\n\ninterface ChatEmbedExperienceProps extends ChatEmbedBaseProps {\n /** Layout of the embed. */\n variant: \"experience\";\n /** Social proof row shown above the profile row. */\n socialProof?: ChatEmbedSocialProof;\n}\n\n/** Props for {@link ChatEmbed}. `socialProof` is only accepted on `experience`, and `href` and `onOpen` are exclusive. */\nexport type ChatEmbedProps = (ChatEmbedCreatorProps | ChatEmbedExperienceProps) &\n (ChatEmbedLinkProps | ChatEmbedButtonProps);\n\nexport interface ChatEmbedSkeletonProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Layout to match while the embed loads. @default \"creator\" */\n variant?: ChatEmbedVariant;\n /** Visually hidden text read by screen readers in place of the placeholder. @default \"Loading\" */\n label?: string;\n}\n\nexport interface ChatEmbedUnavailableProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Layout to match the embed it replaces. @default \"creator\" */\n variant?: ChatEmbedVariant;\n /** Icon shown above the message. */\n icon?: React.ReactNode;\n}\n\nconst FRAME =\n \"relative isolate flex w-full max-w-100 flex-col overflow-hidden rounded-sm after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-[inherit] after:border after:border-neutral-alphas-100\";\n\nconst HEIGHT: Record<ChatEmbedVariant, string> = {\n creator: \"h-40\",\n experience: \"h-[239px]\",\n};\n\nconst SCRIM_FADE =\n \"bg-linear-to-b from-transparent via-40% via-[color-mix(in_srgb,var(--color-content-always-black)_40%,transparent)] to-[color-mix(in_srgb,var(--color-content-always-black)_88%,transparent)]\";\n\nconst SCRIM_SOFT =\n \"bg-linear-to-b from-transparent via-40% via-[color-mix(in_srgb,var(--color-content-always-black)_24%,transparent)] to-[color-mix(in_srgb,var(--color-content-always-black)_40%,transparent)]\";\n\nconst PROGRESSIVE_BLUR = [\n \"backdrop-blur-[4px] [mask-image:linear-gradient(to_bottom,transparent_13%,black_42%)]\",\n \"backdrop-blur-[8px] [mask-image:linear-gradient(to_bottom,transparent_42%,black_71%)]\",\n \"backdrop-blur-[12px] [mask-image:linear-gradient(to_bottom,transparent_71%,black)]\",\n];\n\nconst MEDIA_FILL = \"*:size-full [&>img]:object-cover [&>video]:object-cover\";\n\nconst OVERLAY =\n \"absolute inset-0 z-[1] cursor-pointer rounded-[inherit] focus-visible:shadow-focus-ring focus-visible:outline-none\";\n\nconst DEFAULT_UNAVAILABLE: Record<ChatEmbedVariant, string> = {\n creator: \"This profile is no longer available\",\n experience: \"This experience is no longer available\",\n};\n\nfunction SocialProof({ avatars, name, label }: ChatEmbedSocialProof) {\n return (\n <div className=\"flex min-w-0 items-center gap-2\">\n <div className=\"flex shrink-0\">\n {avatars.map((avatar, index) => (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: avatars can share a src and the stack never reorders\n key={index}\n className={cn(\n \"flex\",\n index < avatars.length - 1 && \"-mr-2\",\n index > 0 &&\n \"[mask-image:radial-gradient(circle_at_-4px_50%,transparent_14px,black_14.5px)]\",\n )}\n >\n <Avatar size={24} {...avatar} />\n </span>\n ))}\n </div>\n <p className=\"m-0 flex min-w-0 items-center gap-1 whitespace-nowrap text-content-always-white\">\n {name && (\n <span className=\"typography-body-small-14px-semibold max-w-30 truncate\">{name}</span>\n )}\n <span className=\"typography-body-small-14px-regular shrink-0\">{label}</span>\n </p>\n </div>\n );\n}\n\nfunction Media({\n media,\n backdrop,\n vertical,\n greyscale,\n}: {\n media?: React.ReactNode;\n backdrop?: React.ReactNode;\n vertical: boolean;\n greyscale: boolean;\n}) {\n if (!media) return null;\n\n return (\n <div className=\"pointer-events-none absolute inset-0 select-none\">\n {vertical ? (\n <>\n <div\n aria-hidden=\"true\"\n className={cn(\n \"-translate-1/2 absolute top-1/2 left-1/2 h-[709px] w-[475px] blur-[20px]\",\n MEDIA_FILL,\n )}\n >\n {backdrop}\n </div>\n <div\n className={cn(\n \"absolute inset-y-0 left-1/2 aspect-9/16 -translate-x-1/2 shadow-md\",\n MEDIA_FILL,\n )}\n >\n {media}\n </div>\n </>\n ) : (\n <div className={cn(\"absolute inset-0\", MEDIA_FILL)}>{media}</div>\n )}\n {greyscale && (\n <div className=\"absolute inset-0 bg-content-always-black mix-blend-saturation\" />\n )}\n </div>\n );\n}\n\nfunction Scrim({ experience }: { experience: boolean }) {\n return (\n <>\n {PROGRESSIVE_BLUR.map((step) => (\n <div key={step} aria-hidden=\"true\" className={cn(\"absolute inset-0\", step)} />\n ))}\n <div aria-hidden=\"true\" className={cn(\"absolute inset-0 mix-blend-luminosity\", SCRIM_FADE)} />\n {experience && (\n <div aria-hidden=\"true\" className={cn(\"absolute inset-0 mix-blend-multiply\", SCRIM_SOFT)} />\n )}\n </>\n );\n}\n\nfunction CreatorName({\n verified,\n aiDisclosure,\n aiDisclosureLabel,\n nameId,\n className,\n children,\n}: {\n verified: boolean;\n aiDisclosure: boolean;\n aiDisclosureLabel: string;\n nameId?: string;\n className: string;\n children?: React.ReactNode;\n}) {\n return (\n <div className=\"flex min-w-0 items-center gap-1\">\n <UserDisplayName\n component=\"p\"\n verified={verified}\n className={cn(\"m-0 [&>[role=img]]:ml-1 [&>span:empty+[role=img]]:ml-0\", className)}\n >\n {children && <span id={nameId}>{children}</span>}\n </UserDisplayName>\n {aiDisclosure && (\n <AiDisclosureBadge\n tone=\"light\"\n role=\"img\"\n aria-hidden={false}\n aria-label={aiDisclosureLabel}\n className=\"shrink-0\"\n />\n )}\n </div>\n );\n}\n\nfunction TopRow({\n badge,\n category,\n meta,\n}: Pick<ChatEmbedBaseProps, \"badge\" | \"category\" | \"meta\">) {\n return (\n <div className=\"relative flex items-center justify-between gap-2 px-3 pt-3\">\n <div className=\"flex min-w-0 items-center gap-1\">\n {badge}\n {category && (\n <span className=\"typography-description-12px-semibold whitespace-nowrap rounded-xs bg-buttons-always-white-default px-2 py-1 text-content-always-black\">\n {category}\n </span>\n )}\n </div>\n {meta && (\n <span className=\"typography-description-12px-semibold whitespace-nowrap rounded-full bg-background-overlay-default px-2 py-1 text-center text-content-always-white backdrop-blur-[10px]\">\n {meta}\n </span>\n )}\n </div>\n );\n}\n\nfunction OpenOverlay({\n href,\n target,\n onOpen,\n labelledBy,\n}: {\n href?: string;\n target?: React.HTMLAttributeAnchorTarget;\n onOpen?: () => void;\n labelledBy: string;\n}) {\n if (href) {\n return (\n // biome-ignore lint/a11y/useAnchorContent: Named by the visible title via aria-labelledby\n <a\n href={href}\n target={target}\n rel={target === \"_blank\" ? \"noopener noreferrer\" : undefined}\n aria-labelledby={labelledBy}\n className={OVERLAY}\n />\n );\n }\n if (!onOpen) return null;\n return <button type=\"button\" onClick={onOpen} aria-labelledby={labelledBy} className={OVERLAY} />;\n}\n\n/**\n * A card embedded in a chat thread that links out to a creator profile or a fan\n * experience such as a live stream or game. Media fills the card and the profile\n * row sits on a blurred scrim along the bottom edge.\n *\n * The `creator` variant is 160px tall and the `experience` variant 239px; both\n * fill their container up to 400px wide. Pass `href` (or `onOpen`) to make the\n * whole card clickable; the `action` stays separately clickable above it. Use\n * {@link ChatEmbedSkeleton} while the embed's data loads and\n * {@link ChatEmbedUnavailable} when the shared item no longer exists.\n *\n * Give `media` meaningful alt text when it conveys content, or `alt=\"\"` when the\n * title already describes it. When `media` is a video with `verticalMedia`, pass\n * its poster frame as `mediaBackdrop` so the video is not decoded twice.\n * `socialProof` is shown to everyone in the chat, so prefer a count over naming\n * other fans.\n *\n * @example\n * ```tsx\n * <ChatEmbed\n * variant=\"experience\"\n * href=\"https://www.fanvue.com\"\n * badge={<LiveStatus variant=\"live\" />}\n * category=\"Audio\"\n * media={<img src=\"/stream.jpg\" alt=\"\" />}\n * avatar={{ src: \"/avatar.jpg\", fallback: \"JD\" }}\n * title=\"Friday night Q&A\"\n * subtitle=\"@jane_doe\"\n * action={<Button variant=\"white\" size=\"32\">Join</Button>}\n * />\n * ```\n */\nexport const ChatEmbed = React.forwardRef<HTMLDivElement, ChatEmbedProps>(\n (\n {\n variant = \"creator\",\n media,\n mediaBackdrop,\n verticalMedia = false,\n avatar,\n title,\n subtitle,\n verified = false,\n aiDisclosure = false,\n aiDisclosureLabel = \"AI creator\",\n action,\n badge,\n category,\n meta,\n inactive = false,\n href,\n target,\n onOpen,\n socialProof,\n className,\n ...props\n },\n ref,\n ) => {\n const titleId = React.useId();\n const isExperience = variant === \"experience\";\n const hasTopRow = Boolean(badge || category || meta);\n const badges = { verified, aiDisclosure, aiDisclosureLabel };\n\n return (\n <div\n ref={ref}\n className={cn(\n FRAME,\n HEIGHT[variant],\n \"bg-content-always-black\",\n hasTopRow ? \"justify-between\" : \"justify-end\",\n className,\n )}\n {...props}\n >\n <Media\n media={media}\n backdrop={mediaBackdrop}\n vertical={verticalMedia}\n greyscale={inactive}\n />\n <OpenOverlay href={href} target={target} onOpen={onOpen} labelledBy={titleId} />\n\n {hasTopRow && <TopRow badge={badge} category={category} meta={meta} />}\n\n <div\n className={cn(\"relative flex flex-col gap-2 px-3 pb-3\", isExperience ? \"pt-6\" : \"pt-3\")}\n >\n <Scrim experience={isExperience} />\n\n {isExperience && socialProof && (\n <div className=\"relative\">\n <SocialProof {...socialProof} />\n </div>\n )}\n\n <div className={cn(\"relative flex items-center\", isExperience ? \"gap-6\" : \"gap-2\")}>\n <div className=\"flex min-w-0 flex-1 items-center gap-3\">\n {avatar && <Avatar size={40} {...avatar} />}\n <div className=\"flex min-w-0 flex-col justify-center text-content-always-white\">\n {isExperience ? (\n <>\n <p id={titleId} className=\"typography-body-default-16px-semibold m-0 truncate\">\n {title}\n </p>\n {(subtitle || verified || aiDisclosure) && (\n <CreatorName {...badges} className=\"typography-body-small-14px-regular\">\n {subtitle}\n </CreatorName>\n )}\n </>\n ) : (\n <>\n <CreatorName\n {...badges}\n nameId={titleId}\n className=\"typography-body-default-16px-semibold\"\n >\n {title}\n </CreatorName>\n {subtitle && (\n <p className=\"typography-body-small-14px-regular m-0 truncate\">{subtitle}</p>\n )}\n </>\n )}\n </div>\n </div>\n {action && <div className=\"relative z-[2] shrink-0\">{action}</div>}\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatEmbed.displayName = \"ChatEmbed\";\n\n/**\n * Loading placeholder sized to match a {@link ChatEmbed}, shown while the data\n * for a shared link is being fetched.\n *\n * @example\n * ```tsx\n * <ChatEmbedSkeleton variant=\"experience\" />\n * ```\n */\nexport const ChatEmbedSkeleton = React.forwardRef<HTMLDivElement, ChatEmbedSkeletonProps>(\n ({ variant = \"creator\", label = \"Loading\", className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n aria-busy=\"true\"\n className={cn(FRAME, HEIGHT[variant], \"justify-end bg-surface-secondary\", className)}\n {...props}\n >\n <span className=\"sr-only\">{label}</span>\n <div className=\"relative flex items-center gap-3 p-3\">\n <Skeleton variant=\"circular\" width={40} height={40} className=\"shrink-0\" />\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <Skeleton width=\"50%\" height={16} />\n <Skeleton width=\"30%\" height={14} />\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatEmbedSkeleton.displayName = \"ChatEmbedSkeleton\";\n\n/**\n * Placeholder sized to match a {@link ChatEmbed}, shown in place of the card when\n * the shared profile or experience has been removed, hidden or unpublished.\n * Pass `children` to localise the message.\n *\n * @example\n * ```tsx\n * <ChatEmbedUnavailable variant=\"experience\" />\n * ```\n */\nexport const ChatEmbedUnavailable = React.forwardRef<HTMLDivElement, ChatEmbedUnavailableProps>(\n ({ variant = \"creator\", icon, className, children, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n FRAME,\n HEIGHT[variant],\n \"items-center justify-center gap-2 bg-surface-secondary px-6 text-center text-content-secondary\",\n className,\n )}\n {...props}\n >\n {icon && (\n <span aria-hidden=\"true\" className=\"flex\">\n {icon}\n </span>\n )}\n <p className=\"typography-body-small-14px-regular m-0\">\n {children ?? DEFAULT_UNAVAILABLE[variant]}\n </p>\n </div>\n );\n },\n);\n\nChatEmbedUnavailable.displayName = \"ChatEmbedUnavailable\";\n"],"names":["jsxs","jsx","cn","Avatar","Fragment","UserDisplayName","AiDisclosureBadge","React","Skeleton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,MAAM,QACJ;AAEF,MAAM,SAA2C;AAAA,EAC/C,SAAS;AAAA,EACT,YAAY;AACd;AAEA,MAAM,aACJ;AAEF,MAAM,aACJ;AAEF,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,aAAa;AAEnB,MAAM,UACJ;AAEF,MAAM,sBAAwD;AAAA,EAC5D,SAAS;AAAA,EACT,YAAY;AACd;AAEA,SAAS,YAAY,EAAE,SAAS,MAAM,SAA+B;AACnE,SACEA,2BAAAA,KAAC,OAAA,EAAI,WAAU,mCACb,UAAA;AAAA,IAAAC,2BAAAA,IAAC,SAAI,WAAU,iBACZ,kBAAQ,IAAI,CAAC,QAAQ,UACpBA,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QAGC,WAAWC,GAAAA;AAAAA,UACT;AAAA,UACA,QAAQ,QAAQ,SAAS,KAAK;AAAA,UAC9B,QAAQ,KACN;AAAA,Q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AAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAWE,GAAAA;AAAAA,UACT;AAAA,UACA,OAAO,OAAO;AAAA,UACd;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA,uCACE,QAAA,EAAK,eAAY,QAAO,WAAU,QAChC,UAAA,MACH;AAAA,yCAED,KAAA,EAAE,WAAU,0CACV,UAAA,YAAY,oBAAoB,OAAO,EAAA,CAC1C;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,qBAAqB,cAAc;;;;"}
|
|
1
|
+
{"version":3,"file":"ChatEmbed.cjs","sources":["../../../../src/components/ChatEmbed/ChatEmbed.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { AiDisclosureBadge } from \"../AiDisclosureBadge/AiDisclosureBadge\";\nimport { Avatar, type AvatarProps } from \"../Avatar/Avatar\";\nimport { Skeleton } from \"../Skeleton/Skeleton\";\nimport { UserDisplayName } from \"../UserDisplayName/UserDisplayName\";\n\n/** Layout of the embed: a creator profile card or a fan experience card. */\nexport type ChatEmbedVariant = \"creator\" | \"experience\";\n\n/** Overlapping avatars and copy showing who else is taking part. */\nexport interface ChatEmbedSocialProof {\n /** Avatars shown in the overlapping stack, left to right. */\n avatars: AvatarProps[];\n /** Name shown in bold before the label, truncated at 120px. */\n name?: React.ReactNode;\n /** Copy shown after the name, e.g. \"+2 watching\". */\n label: React.ReactNode;\n}\n\ninterface ChatEmbedBaseProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\" | \"onClick\"> {\n /** Media filling the card, typically an `img` or `video`, over a dark surface. */\n media?: React.ReactNode;\n /** Still image blurred behind `verticalMedia`, e.g. the same image or a video's poster frame. */\n mediaBackdrop?: React.ReactNode;\n /** Frame portrait media in a centred 9:16 column over `mediaBackdrop`. @default false */\n verticalMedia?: boolean;\n /** Avatar shown at the start of the profile row. */\n avatar?: AvatarProps;\n /** Primary line of the profile row: a display name or an experience title. */\n title: React.ReactNode;\n /** Secondary line under the title, e.g. a handle or \"Made by @jane_doe\". */\n subtitle?: React.ReactNode;\n /** Show the verified badge on the creator line. @default false */\n verified?: boolean;\n /** Accessible label for the verified badge. @default \"Verified\" */\n verifiedLabel?: string;\n /** Show the EU AI-disclosure badge on the creator line. @default false */\n aiDisclosure?: boolean;\n /** Accessible label for the AI-disclosure badge. @default \"AI creator\" */\n aiDisclosureLabel?: string;\n /** Action at the end of the profile row, typically a `Button` with `variant=\"white\"` and `size=\"32\"`. */\n action?: React.ReactNode;\n /** Badge in the top-left corner, typically a {@link LiveStatus}. */\n badge?: React.ReactNode;\n /** Short category label shown as a tag after the badge, e.g. \"Game\" or \"Audio\". */\n category?: React.ReactNode;\n /** Short copy in a translucent pill in the top-right corner, e.g. \"2 hours ago\". */\n meta?: React.ReactNode;\n /** Renders the media in greyscale, e.g. once a live has ended. @default false */\n inactive?: boolean;\n}\n\ninterface ChatEmbedLinkProps {\n /** Makes the whole card a link to this URL, named by the title. */\n href: string;\n /** Where to open `href`; `\"_blank\"` adds `rel=\"noopener noreferrer\"`. */\n target?: React.HTMLAttributeAnchorTarget;\n /** Not available with `href`. */\n onOpen?: never;\n}\n\ninterface ChatEmbedButtonProps {\n /** Not available with `onOpen`. */\n href?: never;\n /** Not available with `onOpen`. */\n target?: never;\n /** Makes the whole card a button named by the title, e.g. to open a dialog. */\n onOpen?: () => void;\n}\n\ninterface ChatEmbedCreatorProps extends ChatEmbedBaseProps {\n /** Layout of the embed. @default \"creator\" */\n variant?: \"creator\";\n /** Only available on the `experience` variant. */\n socialProof?: never;\n}\n\ninterface ChatEmbedExperienceProps extends ChatEmbedBaseProps {\n /** Layout of the embed. */\n variant: \"experience\";\n /** Social proof row shown above the profile row. */\n socialProof?: ChatEmbedSocialProof;\n}\n\n/** Props for {@link ChatEmbed}. `socialProof` is only accepted on `experience`, and `href` and `onOpen` are exclusive. */\nexport type ChatEmbedProps = (ChatEmbedCreatorProps | ChatEmbedExperienceProps) &\n (ChatEmbedLinkProps | ChatEmbedButtonProps);\n\nexport interface ChatEmbedSkeletonProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Layout to match while the embed loads. @default \"creator\" */\n variant?: ChatEmbedVariant;\n /** Visually hidden text read by screen readers in place of the placeholder. @default \"Loading\" */\n label?: string;\n}\n\nexport interface ChatEmbedUnavailableProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Layout to match the embed it replaces. @default \"creator\" */\n variant?: ChatEmbedVariant;\n /** Icon shown above the message. */\n icon?: React.ReactNode;\n}\n\nconst FRAME =\n \"relative isolate flex w-full max-w-100 flex-col overflow-hidden rounded-sm after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-[inherit] after:border after:border-neutral-alphas-100\";\n\nconst HEIGHT: Record<ChatEmbedVariant, string> = {\n creator: \"h-40\",\n experience: \"h-[239px]\",\n};\n\nconst SCRIM_FADE =\n \"bg-linear-to-b from-transparent via-40% via-[color-mix(in_srgb,var(--color-content-always-black)_40%,transparent)] to-[color-mix(in_srgb,var(--color-content-always-black)_88%,transparent)]\";\n\nconst SCRIM_SOFT =\n \"bg-linear-to-b from-transparent via-40% via-[color-mix(in_srgb,var(--color-content-always-black)_24%,transparent)] to-[color-mix(in_srgb,var(--color-content-always-black)_40%,transparent)]\";\n\nconst PROGRESSIVE_BLUR = [\n \"backdrop-blur-[4px] [mask-image:linear-gradient(to_bottom,transparent_13%,black_42%)]\",\n \"backdrop-blur-[8px] [mask-image:linear-gradient(to_bottom,transparent_42%,black_71%)]\",\n \"backdrop-blur-[12px] [mask-image:linear-gradient(to_bottom,transparent_71%,black)]\",\n];\n\nconst MEDIA_FILL = \"*:size-full [&>img]:object-cover [&>video]:object-cover\";\n\nconst OVERLAY =\n \"absolute inset-0 z-[1] cursor-pointer rounded-[inherit] focus-visible:shadow-focus-ring focus-visible:outline-none\";\n\nconst DEFAULT_UNAVAILABLE: Record<ChatEmbedVariant, string> = {\n creator: \"This profile is no longer available\",\n experience: \"This experience is no longer available\",\n};\n\nfunction SocialProof({ avatars, name, label }: ChatEmbedSocialProof) {\n return (\n <div className=\"flex min-w-0 items-center gap-2\">\n <div className=\"flex shrink-0\">\n {avatars.map((avatar, index) => (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: avatars can share a src and the stack never reorders\n key={index}\n className={cn(\n \"flex\",\n index < avatars.length - 1 && \"-mr-2\",\n index > 0 &&\n \"[mask-image:radial-gradient(circle_at_-4px_50%,transparent_14px,black_14.5px)]\",\n )}\n >\n <Avatar size={24} {...avatar} />\n </span>\n ))}\n </div>\n <p className=\"m-0 flex min-w-0 items-center gap-1 whitespace-nowrap text-content-always-white\">\n {name && (\n <span className=\"typography-body-small-14px-semibold max-w-30 truncate\">{name}</span>\n )}\n <span className=\"typography-body-small-14px-regular shrink-0\">{label}</span>\n </p>\n </div>\n );\n}\n\nfunction Media({\n media,\n backdrop,\n vertical,\n greyscale,\n}: {\n media?: React.ReactNode;\n backdrop?: React.ReactNode;\n vertical: boolean;\n greyscale: boolean;\n}) {\n if (!media) return null;\n\n return (\n <div className=\"pointer-events-none absolute inset-0 select-none\">\n {vertical ? (\n <>\n <div\n aria-hidden=\"true\"\n className={cn(\n \"-translate-1/2 absolute top-1/2 left-1/2 h-[709px] w-[475px] blur-[20px]\",\n MEDIA_FILL,\n )}\n >\n {backdrop}\n </div>\n <div\n className={cn(\n \"absolute inset-y-0 left-1/2 aspect-9/16 -translate-x-1/2 shadow-md\",\n MEDIA_FILL,\n )}\n >\n {media}\n </div>\n </>\n ) : (\n <div className={cn(\"absolute inset-0\", MEDIA_FILL)}>{media}</div>\n )}\n {greyscale && (\n <div className=\"absolute inset-0 bg-content-always-black mix-blend-saturation\" />\n )}\n </div>\n );\n}\n\nfunction Scrim({ experience }: { experience: boolean }) {\n return (\n <>\n {PROGRESSIVE_BLUR.map((step) => (\n <div key={step} aria-hidden=\"true\" className={cn(\"absolute inset-0\", step)} />\n ))}\n <div aria-hidden=\"true\" className={cn(\"absolute inset-0 mix-blend-luminosity\", SCRIM_FADE)} />\n {experience && (\n <div aria-hidden=\"true\" className={cn(\"absolute inset-0 mix-blend-multiply\", SCRIM_SOFT)} />\n )}\n </>\n );\n}\n\nfunction CreatorName({\n verified,\n verifiedLabel,\n aiDisclosure,\n aiDisclosureLabel,\n nameId,\n className,\n children,\n}: {\n verified: boolean;\n verifiedLabel: string;\n aiDisclosure: boolean;\n aiDisclosureLabel: string;\n nameId?: string;\n className: string;\n children?: React.ReactNode;\n}) {\n return (\n <div className=\"flex min-w-0 items-center gap-1\">\n <UserDisplayName\n component=\"p\"\n verified={verified}\n verifiedLabel={verifiedLabel}\n className={cn(\"m-0 [&>[role=img]]:ml-1 [&>span:empty+[role=img]]:ml-0\", className)}\n >\n {children && <span id={nameId}>{children}</span>}\n </UserDisplayName>\n {aiDisclosure && (\n <AiDisclosureBadge\n tone=\"light\"\n role=\"img\"\n aria-hidden={false}\n aria-label={aiDisclosureLabel}\n className=\"shrink-0\"\n />\n )}\n </div>\n );\n}\n\nfunction TopRow({\n badge,\n category,\n meta,\n}: Pick<ChatEmbedBaseProps, \"badge\" | \"category\" | \"meta\">) {\n return (\n <div className=\"relative flex items-center justify-between gap-2 px-3 pt-3\">\n <div className=\"flex min-w-0 items-center gap-1\">\n {badge}\n {category && (\n <span className=\"typography-description-12px-semibold whitespace-nowrap rounded-xs bg-buttons-always-white-default px-2 py-1 text-content-always-black\">\n {category}\n </span>\n )}\n </div>\n {meta && (\n <span className=\"typography-description-12px-semibold whitespace-nowrap rounded-full bg-background-overlay-default px-2 py-1 text-center text-content-always-white backdrop-blur-[10px]\">\n {meta}\n </span>\n )}\n </div>\n );\n}\n\nfunction OpenOverlay({\n href,\n target,\n onOpen,\n labelledBy,\n}: {\n href?: string;\n target?: React.HTMLAttributeAnchorTarget;\n onOpen?: () => void;\n labelledBy: string;\n}) {\n if (href) {\n return (\n // biome-ignore lint/a11y/useAnchorContent: Named by the visible title via aria-labelledby\n <a\n href={href}\n target={target}\n rel={target === \"_blank\" ? \"noopener noreferrer\" : undefined}\n aria-labelledby={labelledBy}\n className={OVERLAY}\n />\n );\n }\n if (!onOpen) return null;\n return <button type=\"button\" onClick={onOpen} aria-labelledby={labelledBy} className={OVERLAY} />;\n}\n\n/**\n * A card embedded in a chat thread that links out to a creator profile or a fan\n * experience such as a live stream or game. Media fills the card and the profile\n * row sits on a blurred scrim along the bottom edge.\n *\n * The `creator` variant is 160px tall and the `experience` variant 239px; both\n * fill their container up to 400px wide. Pass `href` (or `onOpen`) to make the\n * whole card clickable; the `action` stays separately clickable above it. Use\n * {@link ChatEmbedSkeleton} while the embed's data loads and\n * {@link ChatEmbedUnavailable} when the shared item no longer exists.\n *\n * Give `media` meaningful alt text when it conveys content, or `alt=\"\"` when the\n * title already describes it. When `media` is a video with `verticalMedia`, pass\n * its poster frame as `mediaBackdrop` so the video is not decoded twice.\n * `socialProof` is shown to everyone in the chat, so prefer a count over naming\n * other fans.\n *\n * @example\n * ```tsx\n * <ChatEmbed\n * variant=\"experience\"\n * href=\"https://www.fanvue.com\"\n * badge={<LiveStatus variant=\"live\" />}\n * category=\"Audio\"\n * media={<img src=\"/stream.jpg\" alt=\"\" />}\n * avatar={{ src: \"/avatar.jpg\", fallback: \"JD\" }}\n * title=\"Friday night Q&A\"\n * subtitle=\"@jane_doe\"\n * action={<Button variant=\"white\" size=\"32\">Join</Button>}\n * />\n * ```\n */\nexport const ChatEmbed = React.forwardRef<HTMLDivElement, ChatEmbedProps>(\n (\n {\n variant = \"creator\",\n media,\n mediaBackdrop,\n verticalMedia = false,\n avatar,\n title,\n subtitle,\n verified = false,\n verifiedLabel = \"Verified\",\n aiDisclosure = false,\n aiDisclosureLabel = \"AI creator\",\n action,\n badge,\n category,\n meta,\n inactive = false,\n href,\n target,\n onOpen,\n socialProof,\n className,\n ...props\n },\n ref,\n ) => {\n const titleId = React.useId();\n const isExperience = variant === \"experience\";\n const hasTopRow = Boolean(badge || category || meta);\n const badges = { verified, verifiedLabel, aiDisclosure, aiDisclosureLabel };\n\n return (\n <div\n ref={ref}\n className={cn(\n FRAME,\n HEIGHT[variant],\n \"bg-content-always-black\",\n hasTopRow ? \"justify-between\" : \"justify-end\",\n className,\n )}\n {...props}\n >\n <Media\n media={media}\n backdrop={mediaBackdrop}\n vertical={verticalMedia}\n greyscale={inactive}\n />\n <OpenOverlay href={href} target={target} onOpen={onOpen} labelledBy={titleId} />\n\n {hasTopRow && <TopRow badge={badge} category={category} meta={meta} />}\n\n <div\n className={cn(\"relative flex flex-col gap-2 px-3 pb-3\", isExperience ? \"pt-6\" : \"pt-3\")}\n >\n <Scrim experience={isExperience} />\n\n {isExperience && socialProof && (\n <div className=\"relative\">\n <SocialProof {...socialProof} />\n </div>\n )}\n\n <div className={cn(\"relative flex items-center\", isExperience ? \"gap-6\" : \"gap-2\")}>\n <div className=\"flex min-w-0 flex-1 items-center gap-3\">\n {avatar && <Avatar size={40} {...avatar} />}\n <div className=\"flex min-w-0 flex-col justify-center text-content-always-white\">\n {isExperience ? (\n <>\n <p id={titleId} className=\"typography-body-default-16px-semibold m-0 truncate\">\n {title}\n </p>\n {(subtitle || verified || aiDisclosure) && (\n <CreatorName {...badges} className=\"typography-body-small-14px-regular\">\n {subtitle}\n </CreatorName>\n )}\n </>\n ) : (\n <>\n <CreatorName\n {...badges}\n nameId={titleId}\n className=\"typography-body-default-16px-semibold\"\n >\n {title}\n </CreatorName>\n {subtitle && (\n <p className=\"typography-body-small-14px-regular m-0 truncate\">{subtitle}</p>\n )}\n </>\n )}\n </div>\n </div>\n {action && <div className=\"relative z-[2] shrink-0\">{action}</div>}\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatEmbed.displayName = \"ChatEmbed\";\n\n/**\n * Loading placeholder sized to match a {@link ChatEmbed}, shown while the data\n * for a shared link is being fetched.\n *\n * @example\n * ```tsx\n * <ChatEmbedSkeleton variant=\"experience\" />\n * ```\n */\nexport const ChatEmbedSkeleton = React.forwardRef<HTMLDivElement, ChatEmbedSkeletonProps>(\n ({ variant = \"creator\", label = \"Loading\", className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n aria-busy=\"true\"\n className={cn(FRAME, HEIGHT[variant], \"justify-end bg-surface-secondary\", className)}\n {...props}\n >\n <span className=\"sr-only\">{label}</span>\n <div className=\"relative flex items-center gap-3 p-3\">\n <Skeleton variant=\"circular\" width={40} height={40} className=\"shrink-0\" />\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <Skeleton width=\"50%\" height={16} />\n <Skeleton width=\"30%\" height={14} />\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatEmbedSkeleton.displayName = \"ChatEmbedSkeleton\";\n\n/**\n * Placeholder sized to match a {@link ChatEmbed}, shown in place of the card when\n * the shared profile or experience has been removed, hidden or unpublished.\n * Pass `children` to localise the message.\n *\n * @example\n * ```tsx\n * <ChatEmbedUnavailable variant=\"experience\" />\n * ```\n */\nexport const ChatEmbedUnavailable = React.forwardRef<HTMLDivElement, ChatEmbedUnavailableProps>(\n ({ variant = \"creator\", icon, className, children, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n FRAME,\n HEIGHT[variant],\n \"items-center justify-center gap-2 bg-surface-secondary px-6 text-center text-content-secondary\",\n className,\n )}\n {...props}\n >\n {icon && (\n <span aria-hidden=\"true\" className=\"flex\">\n {icon}\n </span>\n )}\n <p className=\"typography-body-small-14px-regular m-0\">\n {children ?? DEFAULT_UNAVAILABLE[variant]}\n </p>\n </div>\n );\n },\n);\n\nChatEmbedUnavailable.displayName = \"ChatEmbedUnavailable\";\n"],"names":["jsxs","jsx","cn","Avatar","Fragment","UserDisplayName","AiDisclosureBadge","React","Skeleton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA,MAAM,QACJ;AAEF,MAAM,SAA2C;AAAA,EAC/C,SAAS;AAAA,EACT,YAAY;AACd;AAEA,MAAM,aACJ;AAEF,MAAM,aACJ;AAEF,MAAM,m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AAQ,YAAW,OAAO,IAAI,QAAQ,IAAI,WAAU,WAAA,CAAW;AAAA,YACzER,2BAAAA,KAAC,OAAA,EAAI,WAAU,sCACb,UAAA;AAAA,cAAAC,2BAAAA,IAACO,SAAAA,UAAA,EAAS,OAAM,OAAM,QAAQ,IAAI;AAAA,cAClCP,2BAAAA,IAACO,SAAAA,UAAA,EAAS,OAAM,OAAM,QAAQ,GAAA,CAAI;AAAA,YAAA,EAAA,CACpC;AAAA,UAAA,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,kBAAkB,cAAc;AAYzB,MAAM,uBAAuBD,iBAAM;AAAA,EACxC,CAAC,EAAE,UAAU,WAAW,MAAM,WAAW,UAAU,GAAG,MAAA,GAAS,QAAQ;AACrE,WACEP,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAWE,GAAAA;AAAAA,UACT;AAAA,UACA,OAAO,OAAO;AAAA,UACd;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA,uCACE,QAAA,EAAK,eAAY,QAAO,WAAU,QAChC,UAAA,MACH;AAAA,yCAED,KAAA,EAAE,WAAU,0CACV,UAAA,YAAY,oBAAoB,OAAO,EAAA,CAC1C;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,qBAAqB,cAAc;;;;"}
|
|
@@ -91,7 +91,7 @@ const Checkbox = React__namespace.forwardRef(
|
|
|
91
91
|
onCheckedChange: handleCheckedChange,
|
|
92
92
|
className: cn.cn(
|
|
93
93
|
// Base styles
|
|
94
|
-
"flex items-center justify-center rounded border",
|
|
94
|
+
"flex items-center justify-center rounded-2xs border",
|
|
95
95
|
BOX_SIZE_CLASS[boxSize],
|
|
96
96
|
"transition-[border-color,background-color,color,box-shadow] duration-150",
|
|
97
97
|
// Default state
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CheckIcon } from \"../Icons/CheckIcon\";\nimport { MinusIcon } from \"../Icons/MinusIcon\";\n\n/**\n * Size variant for the checkbox.\n *\n * - `\"20\"` (default) — 20px box, body-lg label.\n * - `\"16\"` — 16px box, body-md label, used in compact contexts like data tables.\n * - `\"default\"` and `\"small\"` are legacy aliases retained for back-compat\n * (`\"default\"` → `\"20\"`, `\"small\"` → `\"20\"` with smaller label typography).\n */\nexport type CheckboxSize =\n | \"20\"\n | \"16\"\n /** @deprecated Use `\"20\"` instead. */\n | \"default\"\n /** @deprecated Use `\"20\"` (the smaller-typography variant remains via `\"small\"`). */\n | \"small\";\n\nconst BOX_SIZE_CLASS: Record<\"20\" | \"16\", string> = {\n \"20\": \"size-5\",\n \"16\": \"size-4\",\n};\n\nconst INDICATOR_SIZE_CLASS: Record<\"20\" | \"16\", string> = {\n \"20\": \"size-3\",\n \"16\": \"size-2.5\",\n};\n\nexport interface CheckboxProps\n extends Omit<React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, \"asChild\"> {\n /** Size variant. @default \"20\" */\n size?: CheckboxSize;\n /** Label text displayed next to the checkbox. */\n label?: string;\n /** Descriptive text displayed below the label. */\n helperText?: string;\n}\n\n/**\n * A checkbox input with optional label and helper text. Supports checked,\n * unchecked, and indeterminate states.\n *\n * The ref type is intentionally `HTMLInputElement` (not `HTMLButtonElement`) for\n * form-library compatibility — libraries like react-hook-form call `register()`\n * which expects an `HTMLInputElement` ref. A hidden `<input>` is synced to the\n * Radix checkbox state via `useImperativeHandle`.\n *\n * @example\n * ```tsx\n * <Checkbox label=\"Accept terms\" helperText=\"Required to continue\" />\n * ```\n */\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(\n ({ className, size = \"20\", label, helperText, disabled, name, ...props }, ref) => {\n const id = React.useId();\n const helperTextId = helperText ? `${id}-helper` : undefined;\n const hasLabel = Boolean(label || helperText);\n const boxSize: \"20\" | \"16\" = size === \"16\" ? \"16\" : \"20\";\n const useSmallLabelTypography = size === \"small\";\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n !label &&\n !props[\"aria-label\"] &&\n !props[\"aria-labelledby\"]\n ) {\n console.warn(\n \"Checkbox: No accessible name provided. Add a `label`, `aria-label`, or `aria-labelledby` prop so screen readers can announce this checkbox.\",\n );\n }\n\n // Hidden input for form library compatibility (e.g. react-hook-form register)\n const inputRef = React.useRef<HTMLInputElement>(null);\n React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement);\n\n const handleCheckedChange = (value: boolean | \"indeterminate\") => {\n const checked = value === true;\n if (inputRef.current) {\n inputRef.current.checked = checked;\n inputRef.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n props.onCheckedChange?.(value);\n };\n\n const checkboxElement = (\n <span\n className={cn(\n \"relative inline-flex shrink-0\",\n BOX_SIZE_CLASS[boxSize],\n // Alignment when used with label\n label && (helperText ? \"mt-1\" : \"mt-0.5\"),\n )}\n >\n <input\n ref={inputRef}\n type=\"checkbox\"\n name={name}\n disabled={disabled}\n aria-hidden\n tabIndex={-1}\n onChange={() => {}}\n className=\"pointer-events-none absolute size-px overflow-hidden opacity-0\"\n style={{ clip: \"rect(0,0,0,0)\" }}\n />\n <CheckboxPrimitive.Root\n id={id}\n disabled={disabled}\n aria-describedby={helperTextId}\n data-testid=\"checkbox\"\n {...props}\n onCheckedChange={handleCheckedChange}\n className={cn(\n // Base styles\n \"flex items-center justify-center rounded border\",\n BOX_SIZE_CLASS[boxSize],\n \"transition-[border-color,background-color,color,box-shadow] duration-150\",\n // Default state\n \"border-content-primary bg-transparent text-transparent\",\n // Checked state\n \"data-[state=checked]:border-content-primary data-[state=checked]:bg-content-primary data-[state=checked]:text-content-primary-inverted\",\n // Indeterminate state\n \"data-[state=indeterminate]:border-content-primary data-[state=indeterminate]:bg-content-primary data-[state=indeterminate]:text-content-primary-inverted\",\n // Hover & active state\n \"hover:ring-2 hover:ring-brand-primary-default group-hover:ring-2 group-hover:ring-brand-primary-default\",\n \"not-disabled:active:ring-2 not-disabled:active:ring-brand-primary-default\",\n // Focus state\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n // Disabled state\n \"disabled:cursor-not-allowed disabled:border-neutral-alphas-600 disabled:ring-0 disabled:group-hover:ring-0\",\n \"disabled:data-[state=checked]:border-neutral-alphas-600 disabled:data-[state=checked]:bg-neutral-alphas-600 disabled:data-[state=checked]:text-content-tertiary\",\n !hasLabel && className,\n )}\n >\n <CheckboxPrimitive.Indicator\n forceMount\n className={cn(\n \"flex items-center justify-center text-content-primary-inverted\",\n INDICATOR_SIZE_CLASS[boxSize],\n \"data-[state=unchecked]:invisible\",\n )}\n >\n {props.checked === \"indeterminate\" ? <MinusIcon /> : <CheckIcon />}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n </span>\n );\n\n if (!hasLabel) {\n return checkboxElement;\n }\n\n return (\n <div\n className={cn(\n \"inline-flex flex-col gap-0.5\",\n disabled && \"is-disabled cursor-not-allowed\",\n className,\n )}\n >\n <div className=\"group inline-flex items-start gap-2\">\n {checkboxElement}\n {label && (\n <label\n htmlFor={id}\n className={cn(\n \"cursor-pointer select-none text-content-primary\",\n \"group-has-disabled:cursor-not-allowed group-has-disabled:text-content-tertiary\",\n useSmallLabelTypography\n ? \"typography-body-small-14px-semibold\"\n : \"typography-body-default-16px-semibold\",\n )}\n >\n {label}\n </label>\n )}\n </div>\n {helperText && (\n <span\n id={helperTextId}\n className={cn(\n \"ml-7 text-content-secondary\",\n \"in-[.is-disabled]:cursor-not-allowed in-[.is-disabled]:text-content-tertiary\",\n useSmallLabelTypography\n ? \"typography-description-12px-regular\"\n : \"typography-body-small-14px-regular\",\n )}\n >\n {helperText}\n </span>\n )}\n </div>\n );\n },\n);\n\nCheckbox.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,YACA,SACCE,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAAS;AAAA,gBACT,WAAWD,GAAAA;AAAAA,kBACT;AAAA,kBACA;AAAA,kBACA,0BACI,wCACA;AAAA,gBAAA;AAAA,gBAGL,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,UACC,cACCC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI;AAAA,cACJ,WAAWD,GAAAA;AAAAA,gBACT;AAAA,gBACA;AAAA,gBACA,0BACI,wCACA;AAAA,cAAA;AAAA,cAGL,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,SAAS,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CheckIcon } from \"../Icons/CheckIcon\";\nimport { MinusIcon } from \"../Icons/MinusIcon\";\n\n/**\n * Size variant for the checkbox.\n *\n * - `\"20\"` (default) — 20px box, body-lg label.\n * - `\"16\"` — 16px box, body-md label, used in compact contexts like data tables.\n * - `\"default\"` and `\"small\"` are legacy aliases retained for back-compat\n * (`\"default\"` → `\"20\"`, `\"small\"` → `\"20\"` with smaller label typography).\n */\nexport type CheckboxSize =\n | \"20\"\n | \"16\"\n /** @deprecated Use `\"20\"` instead. */\n | \"default\"\n /** @deprecated Use `\"20\"` (the smaller-typography variant remains via `\"small\"`). */\n | \"small\";\n\nconst BOX_SIZE_CLASS: Record<\"20\" | \"16\", string> = {\n \"20\": \"size-5\",\n \"16\": \"size-4\",\n};\n\nconst INDICATOR_SIZE_CLASS: Record<\"20\" | \"16\", string> = {\n \"20\": \"size-3\",\n \"16\": \"size-2.5\",\n};\n\nexport interface CheckboxProps\n extends Omit<React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, \"asChild\"> {\n /** Size variant. @default \"20\" */\n size?: CheckboxSize;\n /** Label text displayed next to the checkbox. */\n label?: string;\n /** Descriptive text displayed below the label. */\n helperText?: string;\n}\n\n/**\n * A checkbox input with optional label and helper text. Supports checked,\n * unchecked, and indeterminate states.\n *\n * The ref type is intentionally `HTMLInputElement` (not `HTMLButtonElement`) for\n * form-library compatibility — libraries like react-hook-form call `register()`\n * which expects an `HTMLInputElement` ref. A hidden `<input>` is synced to the\n * Radix checkbox state via `useImperativeHandle`.\n *\n * @example\n * ```tsx\n * <Checkbox label=\"Accept terms\" helperText=\"Required to continue\" />\n * ```\n */\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(\n ({ className, size = \"20\", label, helperText, disabled, name, ...props }, ref) => {\n const id = React.useId();\n const helperTextId = helperText ? `${id}-helper` : undefined;\n const hasLabel = Boolean(label || helperText);\n const boxSize: \"20\" | \"16\" = size === \"16\" ? \"16\" : \"20\";\n const useSmallLabelTypography = size === \"small\";\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n !label &&\n !props[\"aria-label\"] &&\n !props[\"aria-labelledby\"]\n ) {\n console.warn(\n \"Checkbox: No accessible name provided. Add a `label`, `aria-label`, or `aria-labelledby` prop so screen readers can announce this checkbox.\",\n );\n }\n\n // Hidden input for form library compatibility (e.g. react-hook-form register)\n const inputRef = React.useRef<HTMLInputElement>(null);\n React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement);\n\n const handleCheckedChange = (value: boolean | \"indeterminate\") => {\n const checked = value === true;\n if (inputRef.current) {\n inputRef.current.checked = checked;\n inputRef.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n props.onCheckedChange?.(value);\n };\n\n const checkboxElement = (\n <span\n className={cn(\n \"relative inline-flex shrink-0\",\n BOX_SIZE_CLASS[boxSize],\n // Alignment when used with label\n label && (helperText ? \"mt-1\" : \"mt-0.5\"),\n )}\n >\n <input\n ref={inputRef}\n type=\"checkbox\"\n name={name}\n disabled={disabled}\n aria-hidden\n tabIndex={-1}\n onChange={() => {}}\n className=\"pointer-events-none absolute size-px overflow-hidden opacity-0\"\n style={{ clip: \"rect(0,0,0,0)\" }}\n />\n <CheckboxPrimitive.Root\n id={id}\n disabled={disabled}\n aria-describedby={helperTextId}\n data-testid=\"checkbox\"\n {...props}\n onCheckedChange={handleCheckedChange}\n className={cn(\n // Base styles\n \"flex items-center justify-center rounded-2xs border\",\n BOX_SIZE_CLASS[boxSize],\n \"transition-[border-color,background-color,color,box-shadow] duration-150\",\n // Default state\n \"border-content-primary bg-transparent text-transparent\",\n // Checked state\n \"data-[state=checked]:border-content-primary data-[state=checked]:bg-content-primary data-[state=checked]:text-content-primary-inverted\",\n // Indeterminate state\n \"data-[state=indeterminate]:border-content-primary data-[state=indeterminate]:bg-content-primary data-[state=indeterminate]:text-content-primary-inverted\",\n // Hover & active state\n \"hover:ring-2 hover:ring-brand-primary-default group-hover:ring-2 group-hover:ring-brand-primary-default\",\n \"not-disabled:active:ring-2 not-disabled:active:ring-brand-primary-default\",\n // Focus state\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n // Disabled state\n \"disabled:cursor-not-allowed disabled:border-neutral-alphas-600 disabled:ring-0 disabled:group-hover:ring-0\",\n \"disabled:data-[state=checked]:border-neutral-alphas-600 disabled:data-[state=checked]:bg-neutral-alphas-600 disabled:data-[state=checked]:text-content-tertiary\",\n !hasLabel && className,\n )}\n >\n <CheckboxPrimitive.Indicator\n forceMount\n className={cn(\n \"flex items-center justify-center text-content-primary-inverted\",\n INDICATOR_SIZE_CLASS[boxSize],\n \"data-[state=unchecked]:invisible\",\n )}\n >\n {props.checked === \"indeterminate\" ? <MinusIcon /> : <CheckIcon />}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n </span>\n );\n\n if (!hasLabel) {\n return checkboxElement;\n }\n\n return (\n <div\n className={cn(\n \"inline-flex flex-col gap-0.5\",\n disabled && \"is-disabled cursor-not-allowed\",\n className,\n )}\n >\n <div className=\"group inline-flex items-start gap-2\">\n {checkboxElement}\n {label && (\n <label\n htmlFor={id}\n className={cn(\n \"cursor-pointer select-none text-content-primary\",\n \"group-has-disabled:cursor-not-allowed group-has-disabled:text-content-tertiary\",\n useSmallLabelTypography\n ? \"typography-body-small-14px-semibold\"\n : \"typography-body-default-16px-semibold\",\n )}\n >\n {label}\n </label>\n )}\n </div>\n {helperText && (\n <span\n id={helperTextId}\n className={cn(\n \"ml-7 text-content-secondary\",\n \"in-[.is-disabled]:cursor-not-allowed in-[.is-disabled]:text-content-tertiary\",\n useSmallLabelTypography\n ? \"typography-description-12px-regular\"\n : \"typography-body-small-14px-regular\",\n )}\n >\n {helperText}\n </span>\n )}\n </div>\n );\n },\n);\n\nCheckbox.displayName = \"Checkbox\";\n"],"names":["React","jsxs","cn","jsx","CheckboxPrimitive","MinusIcon","CheckIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,iBAA8C;AAAA,EAClD,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,uBAAoD;AAAA,EACxD,MAAM;AAAA,EACN,MAAM;AACR;AA0BO,MAAM,WAAWA,iBAAM;AAAA,EAC5B,CAAC,EAAE,WAAW,OAAO,MAAM,OAAO,YAAY,UAAU,MAAM,GAAG,MAAA,GAAS,QAAQ;AAChF,UAAM,KAAKA,iBAAM,MAAA;AACjB,UAAM,eAAe,aAAa,GAAG,EAAE,YAAY;AACnD,UAAM,WAAW,QAAQ,SAAS,UAAU;AAC5C,UAAM,UAAuB,SAAS,OAAO,OAAO;AACpD,UAAM,0BAA0B,SAAS;AAEzC,QACE,QAAQ,IAAI,aAAa,gBACzB,CAAC,SACD,CAAC,MAAM,YAAY,KACnB,CAAC,MAAM,iBAAiB,GACxB;AACA,cAAQ;AAAA,QACN;AAAA,MAAA;AAAA,IAEJ;AAGA,UAAM,WAAWA,iBAAM,OAAyB,IAAI;AACp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AAA;AAAAA,oBACT;AAAA,oBACA,qBAAqB,OAAO;AAAA,oBAC5B;AAAA,kBAAA;AAAA,kBAGD,gBAAM,YAAY,iDAAmBG,UAAAA,WAAA,EAAU,mCAAMC,UAAAA,WAAA,CAAA,CAAU;AAAA,gBAAA;AAAA,cAAA;AAAA,YAClE;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAAA;AAIJ,QAAI,CAAC,UAAU;AACb,aAAO;AAAA,IACT;AAEA,WACEL,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWC,GAAAA;AAAAA,UACT;AAAA,UACA,YAAY;AAAA,UACZ;AAAA,QAAA;AAAA,QAGF,UAAA;AAAA,UAAAD,2BAAAA,KAAC,OAAA,EAAI,WAAU,uCACZ,UAAA;AAAA,YAAA;AAAA,YACA,SACCE,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAAS;AAAA,gBACT,WAAWD,GAAAA;AAAAA,kBACT;AAAA,kBACA;AAAA,kBACA,0BACI,wCACA;AAAA,gBAAA;AAAA,gBAGL,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,UACC,cACCC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI;AAAA,cACJ,WAAWD,GAAAA;AAAAA,gBACT;AAAA,gBACA;AAAA,gBACA,0BACI,wCACA;AAAA,cAAA;AAAA,cAGL,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,SAAS,cAAc;;"}
|
|
@@ -88,8 +88,8 @@ const Chip = React__namespace.forwardRef(
|
|
|
88
88
|
// Shape
|
|
89
89
|
variant === "square" ? "rounded-xs" : "rounded-full",
|
|
90
90
|
// Size (32px uses 12px text, 40px uses 14px text per the design spec)
|
|
91
|
-
size === "32" && "typography-description-12px-semibold h-8 py-1",
|
|
92
|
-
size === "40" && "typography-body-small-14px-semibold h-10 py-2.5",
|
|
91
|
+
size === "32" && "typography-description-12px-semibold h-8 min-w-12 py-1",
|
|
92
|
+
size === "40" && "typography-body-small-14px-semibold h-10 min-w-14 py-2.5",
|
|
93
93
|
// Variant colors
|
|
94
94
|
isDark && "bg-neutral-alphas-600 text-content-always-white",
|
|
95
95
|
(isSolid || isOutlined) && selected && "bg-buttons-chip-active text-content-primary-inverted",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.cjs","sources":["../../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Count, type CountVariant } from \"../Count/Count\";\n\n/** Visual variant of the chip. */\nexport type ChipVariant = \"rounded\" | \"square\" | \"dark\";\n/** Height of the chip in pixels. */\nexport type ChipSize = \"32\" | \"40\";\n\nexport interface ChipProps extends React.HTMLAttributes<HTMLElement> {\n /** Visual variant of the chip. @default \"rounded\" */\n variant?: ChipVariant;\n /** Height of the chip in pixels. @default \"32\" */\n size?: ChipSize;\n /** Whether the chip is in a selected (pressed) state. @default false */\n selected?: boolean;\n /** Whether the chip is disabled. @default false */\n disabled?: boolean;\n /** Whether to show a coloured status dot at the leading edge. @default false */\n leftDot?: boolean;\n /**\n * Whether the chip uses a dashed border for add/create affordances.\n * When `selected`, it becomes a subtle filled state with a solid border.\n * Has no effect when `variant=\"dark\"`.\n * @default false\n */\n dotted?: boolean;\n /**\n * Draws the unselected state as a 1px `buttons-chip-default` outline over a\n * transparent background instead of filling with that same token. This is the\n * Figma `V2 Insights Chips` treatment, used where chips sit over a chart and a\n * row of solid fills would compete with the plotted series. The selected state\n * is unaffected — it stays filled — as are the `dark` and `dotted` variants.\n * @default false\n */\n outlined?: boolean;\n /** Icon element displayed before the label. */\n leftIcon?: React.ReactNode;\n /** Icon element displayed after the label. */\n rightIcon?: React.ReactNode;\n /** Notification badge content (e.g. `\"99+\"`). Passed as a string for i18n support. */\n notificationLabel?: string;\n /** Numeric value for the notification badge. Uses the `Count` component for overflow formatting. Takes precedence over `notificationLabel` when both are provided. */\n notificationCount?: number;\n /** Maximum value before the badge shows overflow (e.g. `\"9+\"`). Only applies when `notificationCount` is set. @default 99 */\n notificationMax?: number;\n /** Colour variant of the notification badge. @default \"brand\" */\n notificationVariant?: CountVariant;\n /** Click handler — when provided, the chip renders as a `<button>` for accessibility. */\n onClick?: React.MouseEventHandler<HTMLElement>;\n /** Merge props onto a child element instead of rendering a wrapper. @default false */\n asChild?: boolean;\n}\n\n/**\n * A compact element for filters, tags, or toggleable actions. When an `onClick`\n * handler is provided, the chip renders as an interactive `<button>` with\n * `aria-pressed` support.\n *\n * @example\n * ```tsx\n * <Chip selected onClick={toggle}>Music</Chip>\n * ```\n */\nexport const Chip = React.forwardRef<HTMLButtonElement, ChipProps>(\n (\n {\n className,\n variant = \"rounded\",\n size = \"32\",\n selected = false,\n disabled = false,\n leftDot = false,\n dotted = false,\n outlined = false,\n leftIcon,\n rightIcon,\n notificationLabel,\n notificationCount,\n notificationMax,\n notificationVariant = \"brand\",\n onClick,\n asChild = false,\n children,\n ...props\n },\n ref,\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Variant-heavy UI component\n ) => {\n const isInteractive = !!onClick && !asChild;\n const Comp = asChild ? Slot : isInteractive ? \"button\" : \"span\";\n const isDark = variant === \"dark\";\n // Precedence between the three treatments, named once rather than re-derived per\n // rule: `dark` owns its own palette, `dotted` wins over `outlined`, and what is\n // left is the normal chip, either filled or outlined.\n const isDotted = !isDark && dotted;\n const isSolid = !isDark && !dotted && !outlined;\n const isOutlined = !isDark && !dotted && outlined;\n\n // The dashed border is drawn as an SVG so the dash length matches the design\n // spec (8/8 for the 40px square, 6/6 otherwise). CSS `border-dashed` only\n // renders browser-default dash lengths, which are too short. The stroke colour\n // is driven by `currentColor`, and `group-hover`/`group-active` react to the\n // chip's interactive states. Rendered only in the default (non-`asChild`) path.\n const showDottedBorder = isDotted && !selected && !asChild;\n const dottedBorder = showDottedBorder ? (\n <svg\n aria-hidden=\"true\"\n className={cn(\n // `-1px` spans the reserved transparent border rather than the padding box\n // inside it, so the dash lands on the same ring as the solid border it\n // becomes when selected.\n \"pointer-events-none absolute -top-px -left-px h-[calc(100%+2px)] w-[calc(100%+2px)] overflow-visible\",\n disabled ? \"text-buttons-chip-disabled\" : \"text-buttons-chip-dotted-default\",\n isInteractive &&\n !disabled &&\n \"group-hover:text-buttons-chip-dotted-hover-stroke group-active:text-buttons-chip-dotted-hover-stroke\",\n )}\n >\n <rect\n x=\"0.5\"\n y=\"0.5\"\n rx={variant === \"square\" ? 7.5 : size === \"40\" ? 19.5 : 15.5}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1\"\n strokeDasharray={variant === \"square\" && size === \"40\" ? \"8 8\" : \"6 6\"}\n style={{ width: \"calc(100% - 1px)\", height: \"calc(100% - 1px)\" }}\n />\n </svg>\n ) : null;\n\n return (\n <Comp\n ref={ref}\n data-testid=\"chip\"\n className={cn(\n \"relative inline-flex min-w-0 items-center justify-center whitespace-nowrap motion-safe:transition-colors motion-safe:duration-150\",\n // Shape\n variant === \"square\" ? \"rounded-xs\" : \"rounded-full\",\n // Size (32px uses 12px text, 40px uses 14px text per the design spec)\n size === \"32\" && \"typography-description-12px-semibold h-8 py-1\",\n size === \"40\" && \"typography-body-small-14px-semibold h-10 py-2.5\",\n // Variant colors\n isDark && \"bg-neutral-alphas-600 text-content-always-white\",\n (isSolid || isOutlined) &&\n selected &&\n \"bg-buttons-chip-active text-content-primary-inverted\",\n // Active + dotted is a subtle filled state with a solid (non-dashed) border.\n isDotted &&\n selected &&\n \"border border-border-primary border-solid bg-inputs-inputs-primary text-content-primary\",\n isSolid && !selected && \"bg-buttons-chip-default text-content-primary\",\n // Outlined: the same token as a 1px stroke rather than a fill. The border\n // is declared in BOTH states and only changes colour, going transparent\n // once selected. It cannot be dropped on selection: `border-box` constrains\n // only explicitly sized axes, and a chip's width is intrinsic, so losing the\n // border would narrow the chip by 2px and reflow the whole row on every\n // click. Height is safe either way because `h-8` is explicit.\n isOutlined && \"border border-solid\",\n isOutlined &&\n !selected &&\n \"border-buttons-chip-default bg-transparent text-content-primary\",\n isOutlined && selected && \"border-transparent\",\n // Dotted (non-selected): the dashed border is drawn via SVG (`dottedBorder`).\n // `group` lets that SVG react to hover/active. `asChild` keeps a CSS dashed\n // border fallback since the SVG is only rendered in the default path.\n isDotted && !selected && \"bg-transparent text-content-primary\",\n isDotted && !selected && !asChild && \"group\",\n // The SVG path draws no CSS border, so selecting one used to add 1px and\n // widen the chip by 2px, shifting the row on every toggle. Reserving a\n // transparent border also puts the dash on the same ring as the solid\n // border it becomes. The `asChild` path already has a real border below.\n isDotted && !selected && !asChild && \"border border-transparent border-solid\",\n isDotted &&\n !selected &&\n asChild &&\n (disabled\n ? \"border border-buttons-chip-disabled border-dashed\"\n : \"border border-buttons-chip-dotted-default border-dashed\"),\n // Interactive\n isInteractive && !disabled && \"cursor-pointer\",\n isInteractive && !disabled && isSolid && !selected && \"hover:bg-buttons-chip-hover\",\n // Outlined darkens its stroke rather than filling. `buttons-chip-hover` is\n // the one-step darkening for chips, but as a fill it is 20% over a 10%\n // stroke, so it swallows the outline the variant exists to show. Moved onto\n // the border, over `interaction-hover`, the atomic hover surface.\n isInteractive &&\n !disabled &&\n isOutlined &&\n !selected &&\n \"hover:border-buttons-chip-hover hover:bg-interaction-hover\",\n isInteractive &&\n !disabled &&\n isDotted &&\n !selected &&\n \"hover:bg-neutral-alphas-50 active:bg-neutral-alphas-50\",\n // Focus\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n // Disabled\n disabled && isDark && \"pointer-events-none opacity-50\",\n disabled && !isDark && \"pointer-events-none text-content-disabled\",\n // Solid (non-dotted) disabled chips get a muted fill; dotted ones stay\n // transparent with their dashed border (drawn via SVG).\n disabled && (isSolid || (isOutlined && selected)) && \"bg-buttons-chip-disabled\",\n // Unselected outlined greys only its stroke. Selected is already filled, so\n // it takes the muted fill above and keeps `border-transparent` for its width.\n disabled && isOutlined && !selected && \"border-buttons-chip-disabled\",\n className,\n )}\n {...(isInteractive && {\n type: \"button\" as const,\n disabled,\n \"aria-pressed\": selected,\n onClick,\n })}\n {...(!isInteractive && disabled && { \"aria-disabled\": true })}\n {...(selected && { \"data-selected\": \"\" })}\n {...props}\n >\n {asChild ? (\n <Slottable>{children}</Slottable>\n ) : (\n <>\n {dottedBorder}\n <span className=\"flex min-w-0 items-center gap-0.5 overflow-hidden px-3\">\n {leftDot && (\n <span className=\"size-2 shrink-0 rounded-full bg-current\" aria-hidden=\"true\" />\n )}\n {leftIcon && (\n <span className=\"flex shrink-0 items-center justify-center\" aria-hidden=\"true\">\n {leftIcon}\n </span>\n )}\n <span className=\"min-w-0 truncate\">{children}</span>\n {rightIcon && (\n <span\n className=\"flex size-5 shrink-0 items-center justify-center\"\n aria-hidden=\"true\"\n >\n {rightIcon}\n </span>\n )}\n </span>\n {(notificationCount != null || notificationLabel) && (\n <Count\n variant={notificationVariant}\n size=\"32\"\n className={cn(\n // V2 Notification Count: 20px high/min-width, caption 12,\n // 4px horizontal and 2px vertical padding, rounded-md.\n \"absolute top-[-4px] rounded-md px-1 py-0.5\",\n // Anchor the leading edge so wider values grow away from the label.\n size === \"40\" ? \"left-[calc(100%_-_16px)]\" : \"left-[calc(100%_-_11px)]\",\n )}\n value={notificationCount ?? 0}\n max={notificationMax}\n >\n {notificationCount == null ? notificationLabel : undefined}\n </Count>\n )}\n </>\n )}\n </Comp>\n );\n },\n);\n\nChip.displayName = \"Chip\";\n"],"names":["React","Slot","jsx","cn","Slottable","jsxs","Fragment","Count"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiEO,MAAM,OAAOA,iBAAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,IACP,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,SAAS;AAA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QAAA,EAAK,WAAU,2CAA0C,eAAY,QAAO;AAAA,YAE9E,YACCA,2BAAAA,IAAC,QAAA,EAAK,WAAU,6CAA4C,eAAY,QACrE,UAAA,UACH;AAAA,YAEFA,2BAAAA,IAAC,QAAA,EAAK,WAAU,oBAAoB,SAAA,CAAS;AAAA,YAC5C,aACCA,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,eAAY;AAAA,gBAEX,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,WACE,qBAAqB,QAAQ,sBAC7BA,2BAAAA;AAAAA,YAACK,MAAAA;AAAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,MAAK;AAAA,cACL,WAAWJ,GAAAA;AAAAA;AAAAA;AAAAA,gBAGT;AAAA;AAAA,gBAEA,SAAS,OAAO,6BAA6B;AAAA,cAAA;AAAA,cAE/C,OAAO,qBAAqB;AAAA,cAC5B,KAAK;AAAA,cAEJ,UAAA,qBAAqB,OAAO,oBAAoB;AAAA,YAAA;AAAA,UAAA;AAAA,QACnD,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,KAAK,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"Chip.cjs","sources":["../../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Count, type CountVariant } from \"../Count/Count\";\n\n/** Visual variant of the chip. */\nexport type ChipVariant = \"rounded\" | \"square\" | \"dark\";\n/** Height of the chip in pixels. */\nexport type ChipSize = \"32\" | \"40\";\n\nexport interface ChipProps extends React.HTMLAttributes<HTMLElement> {\n /** Visual variant of the chip. @default \"rounded\" */\n variant?: ChipVariant;\n /** Height of the chip in pixels. @default \"32\" */\n size?: ChipSize;\n /** Whether the chip is in a selected (pressed) state. @default false */\n selected?: boolean;\n /** Whether the chip is disabled. @default false */\n disabled?: boolean;\n /** Whether to show a coloured status dot at the leading edge. @default false */\n leftDot?: boolean;\n /**\n * Whether the chip uses a dashed border for add/create affordances.\n * When `selected`, it becomes a subtle filled state with a solid border.\n * Has no effect when `variant=\"dark\"`.\n * @default false\n */\n dotted?: boolean;\n /**\n * Draws the unselected state as a 1px `buttons-chip-default` outline over a\n * transparent background instead of filling with that same token. This is the\n * Figma `V2 Insights Chips` treatment, used where chips sit over a chart and a\n * row of solid fills would compete with the plotted series. The selected state\n * is unaffected — it stays filled — as are the `dark` and `dotted` variants.\n * @default false\n */\n outlined?: boolean;\n /** Icon element displayed before the label. */\n leftIcon?: React.ReactNode;\n /** Icon element displayed after the label. */\n rightIcon?: React.ReactNode;\n /** Notification badge content (e.g. `\"99+\"`). Passed as a string for i18n support. */\n notificationLabel?: string;\n /** Numeric value for the notification badge. Uses the `Count` component for overflow formatting. Takes precedence over `notificationLabel` when both are provided. */\n notificationCount?: number;\n /** Maximum value before the badge shows overflow (e.g. `\"9+\"`). Only applies when `notificationCount` is set. @default 99 */\n notificationMax?: number;\n /** Colour variant of the notification badge. @default \"brand\" */\n notificationVariant?: CountVariant;\n /** Click handler — when provided, the chip renders as a `<button>` for accessibility. */\n onClick?: React.MouseEventHandler<HTMLElement>;\n /** Merge props onto a child element instead of rendering a wrapper. @default false */\n asChild?: boolean;\n}\n\n/**\n * A compact element for filters, tags, or toggleable actions. When an `onClick`\n * handler is provided, the chip renders as an interactive `<button>` with\n * `aria-pressed` support.\n *\n * @example\n * ```tsx\n * <Chip selected onClick={toggle}>Music</Chip>\n * ```\n */\nexport const Chip = React.forwardRef<HTMLButtonElement, ChipProps>(\n (\n {\n className,\n variant = \"rounded\",\n size = \"32\",\n selected = false,\n disabled = false,\n leftDot = false,\n dotted = false,\n outlined = false,\n leftIcon,\n rightIcon,\n notificationLabel,\n notificationCount,\n notificationMax,\n notificationVariant = \"brand\",\n onClick,\n asChild = false,\n children,\n ...props\n },\n ref,\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Variant-heavy UI component\n ) => {\n const isInteractive = !!onClick && !asChild;\n const Comp = asChild ? Slot : isInteractive ? \"button\" : \"span\";\n const isDark = variant === \"dark\";\n // Precedence between the three treatments, named once rather than re-derived per\n // rule: `dark` owns its own palette, `dotted` wins over `outlined`, and what is\n // left is the normal chip, either filled or outlined.\n const isDotted = !isDark && dotted;\n const isSolid = !isDark && !dotted && !outlined;\n const isOutlined = !isDark && !dotted && outlined;\n\n // The dashed border is drawn as an SVG so the dash length matches the design\n // spec (8/8 for the 40px square, 6/6 otherwise). CSS `border-dashed` only\n // renders browser-default dash lengths, which are too short. The stroke colour\n // is driven by `currentColor`, and `group-hover`/`group-active` react to the\n // chip's interactive states. Rendered only in the default (non-`asChild`) path.\n const showDottedBorder = isDotted && !selected && !asChild;\n const dottedBorder = showDottedBorder ? (\n <svg\n aria-hidden=\"true\"\n className={cn(\n // `-1px` spans the reserved transparent border rather than the padding box\n // inside it, so the dash lands on the same ring as the solid border it\n // becomes when selected.\n \"pointer-events-none absolute -top-px -left-px h-[calc(100%+2px)] w-[calc(100%+2px)] overflow-visible\",\n disabled ? \"text-buttons-chip-disabled\" : \"text-buttons-chip-dotted-default\",\n isInteractive &&\n !disabled &&\n \"group-hover:text-buttons-chip-dotted-hover-stroke group-active:text-buttons-chip-dotted-hover-stroke\",\n )}\n >\n <rect\n x=\"0.5\"\n y=\"0.5\"\n rx={variant === \"square\" ? 7.5 : size === \"40\" ? 19.5 : 15.5}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1\"\n strokeDasharray={variant === \"square\" && size === \"40\" ? \"8 8\" : \"6 6\"}\n style={{ width: \"calc(100% - 1px)\", height: \"calc(100% - 1px)\" }}\n />\n </svg>\n ) : null;\n\n return (\n <Comp\n ref={ref}\n data-testid=\"chip\"\n className={cn(\n \"relative inline-flex min-w-0 items-center justify-center whitespace-nowrap motion-safe:transition-colors motion-safe:duration-150\",\n // Shape\n variant === \"square\" ? \"rounded-xs\" : \"rounded-full\",\n // Size (32px uses 12px text, 40px uses 14px text per the design spec)\n size === \"32\" && \"typography-description-12px-semibold h-8 min-w-12 py-1\",\n size === \"40\" && \"typography-body-small-14px-semibold h-10 min-w-14 py-2.5\",\n // Variant colors\n isDark && \"bg-neutral-alphas-600 text-content-always-white\",\n (isSolid || isOutlined) &&\n selected &&\n \"bg-buttons-chip-active text-content-primary-inverted\",\n // Active + dotted is a subtle filled state with a solid (non-dashed) border.\n isDotted &&\n selected &&\n \"border border-border-primary border-solid bg-inputs-inputs-primary text-content-primary\",\n isSolid && !selected && \"bg-buttons-chip-default text-content-primary\",\n // Outlined: the same token as a 1px stroke rather than a fill. The border\n // is declared in BOTH states and only changes colour, going transparent\n // once selected. It cannot be dropped on selection: `border-box` constrains\n // only explicitly sized axes, and a chip's width is intrinsic, so losing the\n // border would narrow the chip by 2px and reflow the whole row on every\n // click. Height is safe either way because `h-8` is explicit.\n isOutlined && \"border border-solid\",\n isOutlined &&\n !selected &&\n \"border-buttons-chip-default bg-transparent text-content-primary\",\n isOutlined && selected && \"border-transparent\",\n // Dotted (non-selected): the dashed border is drawn via SVG (`dottedBorder`).\n // `group` lets that SVG react to hover/active. `asChild` keeps a CSS dashed\n // border fallback since the SVG is only rendered in the default path.\n isDotted && !selected && \"bg-transparent text-content-primary\",\n isDotted && !selected && !asChild && \"group\",\n // The SVG path draws no CSS border, so selecting one used to add 1px and\n // widen the chip by 2px, shifting the row on every toggle. Reserving a\n // transparent border also puts the dash on the same ring as the solid\n // border it becomes. The `asChild` path already has a real border below.\n isDotted && !selected && !asChild && \"border border-transparent border-solid\",\n isDotted &&\n !selected &&\n asChild &&\n (disabled\n ? \"border border-buttons-chip-disabled border-dashed\"\n : \"border border-buttons-chip-dotted-default border-dashed\"),\n // Interactive\n isInteractive && !disabled && \"cursor-pointer\",\n isInteractive && !disabled && isSolid && !selected && \"hover:bg-buttons-chip-hover\",\n // Outlined darkens its stroke rather than filling. `buttons-chip-hover` is\n // the one-step darkening for chips, but as a fill it is 20% over a 10%\n // stroke, so it swallows the outline the variant exists to show. Moved onto\n // the border, over `interaction-hover`, the atomic hover surface.\n isInteractive &&\n !disabled &&\n isOutlined &&\n !selected &&\n \"hover:border-buttons-chip-hover hover:bg-interaction-hover\",\n isInteractive &&\n !disabled &&\n isDotted &&\n !selected &&\n \"hover:bg-neutral-alphas-50 active:bg-neutral-alphas-50\",\n // Focus\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n // Disabled\n disabled && isDark && \"pointer-events-none opacity-50\",\n disabled && !isDark && \"pointer-events-none text-content-disabled\",\n // Solid (non-dotted) disabled chips get a muted fill; dotted ones stay\n // transparent with their dashed border (drawn via SVG).\n disabled && (isSolid || (isOutlined && selected)) && \"bg-buttons-chip-disabled\",\n // Unselected outlined greys only its stroke. Selected is already filled, so\n // it takes the muted fill above and keeps `border-transparent` for its width.\n disabled && isOutlined && !selected && \"border-buttons-chip-disabled\",\n className,\n )}\n {...(isInteractive && {\n type: \"button\" as const,\n disabled,\n \"aria-pressed\": selected,\n onClick,\n })}\n {...(!isInteractive && disabled && { \"aria-disabled\": true })}\n {...(selected && { \"data-selected\": \"\" })}\n {...props}\n >\n {asChild ? (\n <Slottable>{children}</Slottable>\n ) : (\n <>\n {dottedBorder}\n <span className=\"flex min-w-0 items-center gap-0.5 overflow-hidden px-3\">\n {leftDot && (\n <span className=\"size-2 shrink-0 rounded-full bg-current\" aria-hidden=\"true\" />\n )}\n {leftIcon && (\n <span className=\"flex shrink-0 items-center justify-center\" aria-hidden=\"true\">\n {leftIcon}\n </span>\n )}\n <span className=\"min-w-0 truncate\">{children}</span>\n {rightIcon && (\n <span\n className=\"flex size-5 shrink-0 items-center justify-center\"\n aria-hidden=\"true\"\n >\n {rightIcon}\n </span>\n )}\n </span>\n {(notificationCount != null || notificationLabel) && (\n <Count\n variant={notificationVariant}\n size=\"32\"\n className={cn(\n // V2 Notification Count: 20px high/min-width, caption 12,\n // 4px horizontal and 2px vertical padding, rounded-md.\n \"absolute top-[-4px] rounded-md px-1 py-0.5\",\n // Anchor the leading edge so wider values grow away from the label.\n size === \"40\" ? \"left-[calc(100%_-_16px)]\" : \"left-[calc(100%_-_11px)]\",\n )}\n value={notificationCount ?? 0}\n max={notificationMax}\n >\n {notificationCount == null ? notificationLabel : undefined}\n </Count>\n )}\n </>\n )}\n </Comp>\n );\n },\n);\n\nChip.displayName = \"Chip\";\n"],"names":["React","Slot","jsx","cn","Slottable","jsxs","Fragment","Count"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiEO,MAAM,OAAOA,iBAAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,IACP,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAsB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QAEG;AACH,UAAM,gBAAgB,CAAC,CAAC,WAAW,CAAC;AACpC,UAAM,OAAO,UAAUC,UAAAA,OAAO,gBAAgB,WAAW;AACzD,UAAM,SAAS,YAAY;AAI3B,UAAM,WAAW,CAAC,UAAU;AAC5B,UAAM,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC;AACvC,UAAM,aAAa,CAAC,UAAU,CAAC,UAAU;AAOzC,UAAM,mBAAmB,YAAY,CAAC,YAAY,CAAC;AACnD,UAAM,eAAe,mBACnBC,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,eAAY;AAAA,QACZ,WAAWC,GAAAA;AAAAA;AAAAA;AAAAA;AAAAA,UAIT;AAAA,UACA,WAAW,+BAA+B;AAAA,UAC1C,iBACE,CAAC,YACD;AAAA,QAAA;AAAA,QAGJ,UAAAD,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,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AIR;AACF;AAEA,KAAK,cAAc;;"}
|
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const DialogPrimitive = require("@radix-ui/react-dialog");
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const useDragToDismiss = require("../../utils/useDragToDismiss.cjs");
|
|
8
9
|
const useSuppressClickAfterDrag = require("../../utils/useSuppressClickAfterDrag.cjs");
|
|
9
10
|
const IconButton = require("../IconButton/IconButton.cjs");
|
|
10
11
|
const ArrowLeftIcon = require("../Icons/ArrowLeftIcon.cjs");
|
|
@@ -63,6 +64,15 @@ const DialogContent = React__namespace.forwardRef(
|
|
|
63
64
|
onOpenAutoFocus,
|
|
64
65
|
...props
|
|
65
66
|
}, ref) => {
|
|
67
|
+
const closeRef = React__namespace.useRef(null);
|
|
68
|
+
const contentProps = useDragToDismiss.useDragToDismiss(
|
|
69
|
+
{
|
|
70
|
+
enabled: mobilePresentation === "sheet",
|
|
71
|
+
media: "(max-width: 639.98px)",
|
|
72
|
+
onDismiss: () => closeRef.current?.click()
|
|
73
|
+
},
|
|
74
|
+
props
|
|
75
|
+
);
|
|
66
76
|
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
67
77
|
overlay && /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, { ...overlayProps }),
|
|
68
78
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -105,8 +115,9 @@ const DialogContent = React__namespace.forwardRef(
|
|
|
105
115
|
SIZE_CLASSES[size],
|
|
106
116
|
className
|
|
107
117
|
),
|
|
108
|
-
...
|
|
118
|
+
...contentProps,
|
|
109
119
|
children: [
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { ref: closeRef, hidden: true, tabIndex: -1, "aria-hidden": "true" }),
|
|
110
121
|
showMobileHandle && mobilePresentation === "sheet" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
111
122
|
"div",
|
|
112
123
|
{
|
|
@@ -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 { 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 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 {...props}\n >\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","jsxs","Fragment","IconButton","ArrowLeftIcon","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,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,iBAA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ent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAM,SAASA,2BAAgB;AAY/B,MAAM,gBAAgBC,iBAAM,WAGjC,CAAC,OAAO,QAAQC,2BAAAA,IAACF,2BAAgB,SAAhB,EAAwB,KAAW,GAAGG,0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,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;;;;;;;;;;;"}
|
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const DialogPrimitive = require("@radix-ui/react-dialog");
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const useDragToDismiss = require("../../utils/useDragToDismiss.cjs");
|
|
8
9
|
const useSuppressClickAfterDrag = require("../../utils/useSuppressClickAfterDrag.cjs");
|
|
9
10
|
const IconButton = require("../IconButton/IconButton.cjs");
|
|
10
11
|
const CloseIcon = require("../Icons/CloseIcon.cjs");
|
|
@@ -76,6 +77,11 @@ const DrawerContent = React__namespace.forwardRef(
|
|
|
76
77
|
}, ref) => {
|
|
77
78
|
const ctx = React__namespace.useContext(DrawerContext);
|
|
78
79
|
const overlay = overlayProp ?? ctx.overlay;
|
|
80
|
+
const closeRef = React__namespace.useRef(null);
|
|
81
|
+
const contentProps = useDragToDismiss.useDragToDismiss(
|
|
82
|
+
{ enabled: position === "bottom", onDismiss: () => closeRef.current?.click() },
|
|
83
|
+
props
|
|
84
|
+
);
|
|
79
85
|
const isHorizontal = position === "left" || position === "right";
|
|
80
86
|
const sizeClass = isHorizontal ? {
|
|
81
87
|
sm: "max-w-sm",
|
|
@@ -90,7 +96,7 @@ const DrawerContent = React__namespace.forwardRef(
|
|
|
90
96
|
}[size];
|
|
91
97
|
return /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Portal, { children: [
|
|
92
98
|
overlay && /* @__PURE__ */ jsxRuntime.jsx(DrawerOverlay, { ...overlayProps }),
|
|
93
|
-
/* @__PURE__ */ jsxRuntime.
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
94
100
|
DialogPrimitive__namespace.Content,
|
|
95
101
|
{
|
|
96
102
|
ref,
|
|
@@ -115,8 +121,11 @@ const DrawerContent = React__namespace.forwardRef(
|
|
|
115
121
|
variant === "menu" && MENU_CLASSES,
|
|
116
122
|
className
|
|
117
123
|
),
|
|
118
|
-
...
|
|
119
|
-
children
|
|
124
|
+
...contentProps,
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { ref: closeRef, hidden: true, tabIndex: -1, "aria-hidden": "true" }),
|
|
127
|
+
children
|
|
128
|
+
]
|
|
120
129
|
}
|
|
121
130
|
)
|
|
122
131
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.cjs","sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useSuppressClickAfterDrag } from \"../../utils/useSuppressClickAfterDrag\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** The side from which the drawer slides in. */\nexport type DrawerPosition = \"left\" | \"right\" | \"top\" | \"bottom\";\n\n/** Size presets for the drawer panel. Maps to max-width (left/right) or max-height (top/bottom). */\nexport type DrawerSize = \"sm\" | \"md\" | \"lg\" | \"full\";\n\n/**\n * Visual treatment of the drawer panel.\n *\n * - `\"panel\"` (default) — the standard edge-anchored surface.\n * - `\"sheet\"` — a bottom-sheet treatment matching the modal surface: large\n * top-only radius (32px), modal background/stroke, and menu blur+shadow.\n * Intended for `position=\"bottom\"`.\n * - `\"menu\"` — a floating menu near the bottom edge rather than a sheet fixed to\n * it: inset from all three sides and rounded on every corner. Shares the modal\n * surface with `\"sheet\"`; only the shape differs. Intended for\n * `position=\"bottom\"`.\n */\nexport type DrawerVariant = \"panel\" | \"sheet\" | \"menu\";\n\n/**\n * Shared surface classes for the `\"sheet\"` variant. Mirrors the mobile sheet\n * treatment used by {@link Dialog} so bottom sheets are visually consistent.\n */\nconst SHEET_CLASSES =\n \"rounded-t-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Surface and inset for the `\"menu\"` variant. Same modal background and stroke as\n * a sheet — the design puts this panel on `background/secondary` with\n * `border/strong`, not on the lighter surface the trigger-anchored dropdown uses.\n * The 24px radius is the design's `rounded-lg`.\n *\n * The insets restate position on purpose — they override `SLIDE_CLASSES.bottom`,\n * which pins a sheet flush to the bottom edge at full width.\n */\nconst MENU_CLASSES =\n \"inset-x-4 bottom-4 w-auto rounded-lg border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Props for the {@link Drawer} root component.\n *\n * Inherits `open`, `onOpenChange`, and `defaultOpen` from Radix Dialog.Root.\n *\n * The Radix `modal` prop (default `true`) can also be passed to create a\n * non-modal drawer — useful for persistent side navigation that does not\n * block interaction with the rest of the page.\n *\n * **`overlay` behaviour:** When `overlay` is `false`, the component\n * automatically sets `modal={false}` on the underlying Radix Dialog.Root.\n * A modal dialog without a visible overlay is confusing because focus is\n * still trapped and scroll is blocked even though the page appears\n * interactive. Passing `modal={true}` explicitly will override this.\n */\nexport interface DrawerProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root> {\n /**\n * Whether the default {@link DrawerOverlay} is rendered.\n * When `false`, `modal` is automatically set to `false` as well\n * (unless explicitly overridden) so focus-trap and scroll-lock are disabled.\n * @default true\n */\n overlay?: boolean;\n}\n\nconst DrawerContext = React.createContext<{ overlay: boolean }>({\n overlay: true,\n});\n\n/**\n * Root component that manages open/close state for a drawer.\n * Wraps Radix Dialog.Root.\n *\n * @example\n * ```tsx\n * <Drawer>\n * <DrawerTrigger>Open</DrawerTrigger>\n * <DrawerContent position=\"right\">\n * <DrawerHeader>\n * <DrawerTitle>Settings</DrawerTitle>\n * <DrawerDescription>Adjust your preferences.</DrawerDescription>\n * </DrawerHeader>\n * <p>Content goes here.</p>\n * <DrawerFooter>\n * <DrawerClose>Done</DrawerClose>\n * </DrawerFooter>\n * </DrawerContent>\n * </Drawer>\n * ```\n */\nexport function Drawer({ overlay = true, modal, children, ...props }: DrawerProps) {\n const resolvedModal = modal ?? (overlay ? undefined : false);\n return (\n <DrawerContext.Provider value={{ overlay }}>\n <DialogPrimitive.Root modal={resolvedModal} {...props}>\n {children}\n </DialogPrimitive.Root>\n </DrawerContext.Provider>\n );\n}\nDrawer.displayName = \"Drawer\";\n\n/** Props for the {@link DrawerTrigger} component. */\nexport type DrawerTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\n/**\n * The element that opens the drawer when clicked.\n *\n * On touch / pen, a press-and-release that crosses a small movement threshold\n * is treated as a drag and the resulting synthetic click is suppressed —\n * defends against Android Chrome opening the drawer on a scroll-drag-end.\n */\nexport const DrawerTrigger = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Trigger>,\n DrawerTriggerProps\n>((props, ref) => <DialogPrimitive.Trigger ref={ref} {...useSuppressClickAfterDrag(props)} />);\nDrawerTrigger.displayName = \"DrawerTrigger\";\n\n/** Props for the {@link DrawerClose} component. */\nexport type DrawerCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\n/** Closes the drawer when clicked. Can be placed anywhere inside the drawer. */\nexport const DrawerClose = DialogPrimitive.Close;\nDrawerClose.displayName = \"DrawerClose\";\n\n/** Props for the {@link DrawerOverlay} component. */\nexport interface DrawerOverlayProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> {}\n\n/**\n * A translucent backdrop rendered behind the drawer content.\n * Clicking the overlay closes the drawer by default.\n */\nexport const DrawerOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n DrawerOverlayProps\n>(({ className, style, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"fixed inset-0 bg-background-overlay-default\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:fade-in-0 data-[state=open]:duration-200 data-[state=open]:ease-out\",\n className,\n )}\n {...props}\n />\n));\nDrawerOverlay.displayName = \"DrawerOverlay\";\n\n/**\n * Slide-in animation classes keyed by position.\n * Uses Tailwind animate utilities (animate-in / animate-out).\n */\nconst SLIDE_CLASSES: Record<DrawerPosition, string> = {\n right:\n \"inset-y-0 right-0 h-full w-2/3 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right\",\n left: \"inset-y-0 left-0 h-full w-2/3 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left\",\n top: \"inset-x-0 top-0 w-full data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n bottom:\n \"inset-x-0 bottom-0 w-full rounded-t-xs data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n};\n\n/** Props for the {@link DrawerContent} component. */\nexport interface DrawerContentProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {\n /**\n * The edge from which the drawer slides in.\n *\n * Named `position` (rather than `side`) to avoid confusion with the CSS\n * `side` concept used by Radix Popover/Tooltip and to better convey the\n * spatial relationship of the drawer to the viewport.\n *\n * @default \"right\"\n */\n position?: DrawerPosition;\n /**\n * Controls the maximum extent of the drawer panel.\n * For left/right drawers this sets `max-width`; for top/bottom it sets `max-height`.\n * @default \"sm\"\n */\n size?: DrawerSize;\n /**\n * Visual treatment of the panel. Use `\"sheet\"` (with `position=\"bottom\"`) for\n * a bottom sheet with the modal surface treatment, or `\"menu\"` for a floating\n * inset menu carrying the dropdown surface. @default \"panel\"\n */\n variant?: DrawerVariant;\n /**\n * Whether to render the default {@link DrawerOverlay} behind the content.\n * Set to `false` to provide your own overlay or omit it entirely.\n *\n * Prefer setting `overlay` on the {@link Drawer} root instead so that\n * `modal` is also adjusted automatically.\n *\n * @default true\n */\n overlay?: boolean;\n /** Props forwarded to the default {@link DrawerOverlay} when `overlay` is `true`. */\n overlayProps?: DrawerOverlayProps;\n}\n\n/**\n * The panel that slides in from the chosen edge. Renders inside a portal with\n * an overlay backdrop by default.\n *\n * Includes focus-trap, `aria-describedby`, and Escape-to-close from Radix Dialog.\n */\nexport const DrawerContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(\n (\n {\n className,\n position = \"right\",\n size = \"sm\",\n variant = \"panel\",\n overlay: overlayProp,\n overlayProps,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const ctx = React.useContext(DrawerContext);\n const overlay = overlayProp ?? ctx.overlay;\n const isHorizontal = position === \"left\" || position === \"right\";\n const sizeClass = isHorizontal\n ? (\n {\n sm: \"max-w-sm\",\n md: \"max-w-md\",\n lg: \"max-w-lg\",\n full: \"max-w-full\",\n } as const\n )[size]\n : (\n {\n sm: \"max-h-[24rem]\",\n md: \"max-h-[28rem]\",\n lg: \"max-h-[32rem]\",\n full: \"max-h-full\",\n } as const\n )[size];\n\n return (\n <DialogPrimitive.Portal>\n {overlay && <DrawerOverlay {...overlayProps} />}\n <DialogPrimitive.Content\n ref={ref}\n style={{\n zIndex: \"calc(var(--fanvue-ui-portal-z-index, 50) + 1)\",\n ...style,\n }}\n className={cn(\n \"fixed flex flex-col bg-surface-secondary outline-none backdrop-blur-lg\",\n // `shadow-lg` is scoped to `panel` rather than sitting in the base classes.\n // tailwind-merge does not recognise `shadow-blur-menu` as a box-shadow\n // utility, so it never deduped the two and `shadow-lg` won on stylesheet\n // order — meaning the sheet and menu surfaces silently rendered `shadow-lg`\n // instead of the menu shadow their tokens name.\n variant === \"panel\" && \"shadow-lg\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:duration-200 data-[state=open]:ease-out\",\n SLIDE_CLASSES[position],\n sizeClass,\n variant === \"sheet\" && SHEET_CLASSES,\n variant === \"menu\" && MENU_CLASSES,\n className,\n )}\n {...props}\n >\n {children}\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n );\n },\n);\nDrawerContent.displayName = \"DrawerContent\";\n\n/** Props for the {@link DrawerHeader} component. */\nexport interface DrawerHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether to show a built-in close (X) button. @default true */\n showClose?: boolean;\n /** Accessible label for the close button. @default \"Close drawer\" */\n closeLabel?: string;\n}\n\n/**\n * A semantic header area for the drawer, typically containing a title and description.\n * Renders a built-in close button by default.\n */\nexport const DrawerHeader = React.forwardRef<HTMLDivElement, DrawerHeaderProps>(\n ({ className, showClose = true, closeLabel = \"Close drawer\", children, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex items-center gap-2 p-4\", className)} {...props}>\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">{children}</div>\n {showClose && (\n <DialogPrimitive.Close asChild>\n <IconButton\n icon={<CloseIcon />}\n aria-label={closeLabel}\n variant=\"secondary\"\n size=\"32\"\n className=\"shrink-0\"\n />\n </DialogPrimitive.Close>\n )}\n </div>\n ),\n);\nDrawerHeader.displayName = \"DrawerHeader\";\n\n/** Props for the {@link DrawerFooter} component. */\nexport interface DrawerFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/** A semantic footer area for the drawer, typically containing action buttons. */\nexport const DrawerFooter = React.forwardRef<HTMLDivElement, DrawerFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex flex-col gap-2 p-4\", className)} {...props} />\n ),\n);\nDrawerFooter.displayName = \"DrawerFooter\";\n\n/** Props for the {@link DrawerTitle} component. */\nexport interface DrawerTitleProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> {}\n\n/** An accessible title for the drawer. Required for screen readers. */\nexport const DrawerTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n DrawerTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"typography-body-default-16px-semibold truncate text-content-primary\", className)}\n {...props}\n />\n));\nDrawerTitle.displayName = \"DrawerTitle\";\n\n/** Props for the {@link DrawerDescription} component. */\nexport interface DrawerDescriptionProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> {}\n\n/** An accessible description for the drawer, providing supplementary context. */\nexport const DrawerDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n DrawerDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"typography-body-small-14px-regular text-content-secondary\", className)}\n {...props}\n />\n));\nDrawerDescription.displayName = \"DrawerDescription\";\n"],"names":["React","jsx","DialogPrimitive","useSuppressClickAfterDrag","cn","jsxs","IconButton","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,gBACJ;AAWF,MAAM,eACJ;AA2BF,MAAM,gBAAgBA,iBAAM,cAAoC;AAAA,EAC9D,SAAS;AACX,CAAC;AAuBM,SAAS,OAAO,EAAE,UAAU,MAAM,OAAO,UAAU,GAAG,SAAsB;AACjF,QAAM,gBAAgB,UAAU,UAAU,SAAY;AACtD,wCACG,cAAc,UAAd,EAAuB,OAAO,EAAE,QAAA,GAC/B,UAAAC,2BAAAA,IAACC,2BAAgB,MAAhB,EAAqB,OAAO,eAAgB,GAAG,OAC7C,UACH,GACF;AAEJ;AACA,OAAO,cAAc;AAYd,MAAM,gBAAgBF,iBAAM,WAGjC,CAAC,OAAO,QAAQC,2BAAAA,IAACC,2BAAgB,SAAhB,EAAwB,KAAW,GA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AAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWE,GAAAA,GAAG,uEAAuE,SAAS;AAAA,IAC7F,GAAG;AAAA,EAAA;AACN,CACD;AACD,YAAY,cAAc;AAOnB,MAAM,oBAAoBJ,iBAAM,WAGrC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWE,GAAAA,GAAG,6DAA6D,SAAS;AAAA,IACnF,GAAG;AAAA,EAAA;AACN,CACD;AACD,kBAAkB,cAAc;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Drawer.cjs","sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useDragToDismiss } from \"../../utils/useDragToDismiss\";\nimport { useSuppressClickAfterDrag } from \"../../utils/useSuppressClickAfterDrag\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** The side from which the drawer slides in. */\nexport type DrawerPosition = \"left\" | \"right\" | \"top\" | \"bottom\";\n\n/** Size presets for the drawer panel. Maps to max-width (left/right) or max-height (top/bottom). */\nexport type DrawerSize = \"sm\" | \"md\" | \"lg\" | \"full\";\n\n/**\n * Visual treatment of the drawer panel.\n *\n * - `\"panel\"` (default) — the standard edge-anchored surface.\n * - `\"sheet\"` — a bottom-sheet treatment matching the modal surface: large\n * top-only radius (32px), modal background/stroke, and menu blur+shadow.\n * Intended for `position=\"bottom\"`.\n * - `\"menu\"` — a floating menu near the bottom edge rather than a sheet fixed to\n * it: inset from all three sides and rounded on every corner. Shares the modal\n * surface with `\"sheet\"`; only the shape differs. Intended for\n * `position=\"bottom\"`.\n */\nexport type DrawerVariant = \"panel\" | \"sheet\" | \"menu\";\n\n/**\n * Shared surface classes for the `\"sheet\"` variant. Mirrors the mobile sheet\n * treatment used by {@link Dialog} so bottom sheets are visually consistent.\n */\nconst SHEET_CLASSES =\n \"rounded-t-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Surface and inset for the `\"menu\"` variant. Same modal background and stroke as\n * a sheet — the design puts this panel on `background/secondary` with\n * `border/strong`, not on the lighter surface the trigger-anchored dropdown uses.\n * The 24px radius is the design's `rounded-lg`.\n *\n * The insets restate position on purpose — they override `SLIDE_CLASSES.bottom`,\n * which pins a sheet flush to the bottom edge at full width.\n */\nconst MENU_CLASSES =\n \"inset-x-4 bottom-4 w-auto rounded-lg border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Props for the {@link Drawer} root component.\n *\n * Inherits `open`, `onOpenChange`, and `defaultOpen` from Radix Dialog.Root.\n *\n * The Radix `modal` prop (default `true`) can also be passed to create a\n * non-modal drawer — useful for persistent side navigation that does not\n * block interaction with the rest of the page.\n *\n * **`overlay` behaviour:** When `overlay` is `false`, the component\n * automatically sets `modal={false}` on the underlying Radix Dialog.Root.\n * A modal dialog without a visible overlay is confusing because focus is\n * still trapped and scroll is blocked even though the page appears\n * interactive. Passing `modal={true}` explicitly will override this.\n */\nexport interface DrawerProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root> {\n /**\n * Whether the default {@link DrawerOverlay} is rendered.\n * When `false`, `modal` is automatically set to `false` as well\n * (unless explicitly overridden) so focus-trap and scroll-lock are disabled.\n * @default true\n */\n overlay?: boolean;\n}\n\nconst DrawerContext = React.createContext<{ overlay: boolean }>({\n overlay: true,\n});\n\n/**\n * Root component that manages open/close state for a drawer.\n * Wraps Radix Dialog.Root.\n *\n * @example\n * ```tsx\n * <Drawer>\n * <DrawerTrigger>Open</DrawerTrigger>\n * <DrawerContent position=\"right\">\n * <DrawerHeader>\n * <DrawerTitle>Settings</DrawerTitle>\n * <DrawerDescription>Adjust your preferences.</DrawerDescription>\n * </DrawerHeader>\n * <p>Content goes here.</p>\n * <DrawerFooter>\n * <DrawerClose>Done</DrawerClose>\n * </DrawerFooter>\n * </DrawerContent>\n * </Drawer>\n * ```\n */\nexport function Drawer({ overlay = true, modal, children, ...props }: DrawerProps) {\n const resolvedModal = modal ?? (overlay ? undefined : false);\n return (\n <DrawerContext.Provider value={{ overlay }}>\n <DialogPrimitive.Root modal={resolvedModal} {...props}>\n {children}\n </DialogPrimitive.Root>\n </DrawerContext.Provider>\n );\n}\nDrawer.displayName = \"Drawer\";\n\n/** Props for the {@link DrawerTrigger} component. */\nexport type DrawerTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\n/**\n * The element that opens the drawer when clicked.\n *\n * On touch / pen, a press-and-release that crosses a small movement threshold\n * is treated as a drag and the resulting synthetic click is suppressed —\n * defends against Android Chrome opening the drawer on a scroll-drag-end.\n */\nexport const DrawerTrigger = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Trigger>,\n DrawerTriggerProps\n>((props, ref) => <DialogPrimitive.Trigger ref={ref} {...useSuppressClickAfterDrag(props)} />);\nDrawerTrigger.displayName = \"DrawerTrigger\";\n\n/** Props for the {@link DrawerClose} component. */\nexport type DrawerCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\n/** Closes the drawer when clicked. Can be placed anywhere inside the drawer. */\nexport const DrawerClose = DialogPrimitive.Close;\nDrawerClose.displayName = \"DrawerClose\";\n\n/** Props for the {@link DrawerOverlay} component. */\nexport interface DrawerOverlayProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> {}\n\n/**\n * A translucent backdrop rendered behind the drawer content.\n * Clicking the overlay closes the drawer by default.\n */\nexport const DrawerOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n DrawerOverlayProps\n>(({ className, style, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"fixed inset-0 bg-background-overlay-default\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:fade-in-0 data-[state=open]:duration-200 data-[state=open]:ease-out\",\n className,\n )}\n {...props}\n />\n));\nDrawerOverlay.displayName = \"DrawerOverlay\";\n\n/**\n * Slide-in animation classes keyed by position.\n * Uses Tailwind animate utilities (animate-in / animate-out).\n */\nconst SLIDE_CLASSES: Record<DrawerPosition, string> = {\n right:\n \"inset-y-0 right-0 h-full w-2/3 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right\",\n left: \"inset-y-0 left-0 h-full w-2/3 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left\",\n top: \"inset-x-0 top-0 w-full data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n bottom:\n \"inset-x-0 bottom-0 w-full rounded-t-xs data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n};\n\n/** Props for the {@link DrawerContent} component. */\nexport interface DrawerContentProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {\n /**\n * The edge from which the drawer slides in.\n *\n * Named `position` (rather than `side`) to avoid confusion with the CSS\n * `side` concept used by Radix Popover/Tooltip and to better convey the\n * spatial relationship of the drawer to the viewport.\n *\n * @default \"right\"\n */\n position?: DrawerPosition;\n /**\n * Controls the maximum extent of the drawer panel.\n * For left/right drawers this sets `max-width`; for top/bottom it sets `max-height`.\n * @default \"sm\"\n */\n size?: DrawerSize;\n /**\n * Visual treatment of the panel. Use `\"sheet\"` (with `position=\"bottom\"`) for\n * a bottom sheet with the modal surface treatment, or `\"menu\"` for a floating\n * inset menu carrying the dropdown surface. @default \"panel\"\n */\n variant?: DrawerVariant;\n /**\n * Whether to render the default {@link DrawerOverlay} behind the content.\n * Set to `false` to provide your own overlay or omit it entirely.\n *\n * Prefer setting `overlay` on the {@link Drawer} root instead so that\n * `modal` is also adjusted automatically.\n *\n * @default true\n */\n overlay?: boolean;\n /** Props forwarded to the default {@link DrawerOverlay} when `overlay` is `true`. */\n overlayProps?: DrawerOverlayProps;\n}\n\n/**\n * The panel that slides in from the chosen edge. Renders inside a portal with\n * an overlay backdrop by default.\n *\n * Includes focus-trap, `aria-describedby`, and Escape-to-close from Radix Dialog.\n */\nexport const DrawerContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(\n (\n {\n className,\n position = \"right\",\n size = \"sm\",\n variant = \"panel\",\n overlay: overlayProp,\n overlayProps,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const ctx = React.useContext(DrawerContext);\n const overlay = overlayProp ?? ctx.overlay;\n const closeRef = React.useRef<HTMLButtonElement>(null);\n const contentProps = useDragToDismiss(\n { enabled: position === \"bottom\", onDismiss: () => closeRef.current?.click() },\n props,\n );\n const isHorizontal = position === \"left\" || position === \"right\";\n const sizeClass = isHorizontal\n ? (\n {\n sm: \"max-w-sm\",\n md: \"max-w-md\",\n lg: \"max-w-lg\",\n full: \"max-w-full\",\n } as const\n )[size]\n : (\n {\n sm: \"max-h-[24rem]\",\n md: \"max-h-[28rem]\",\n lg: \"max-h-[32rem]\",\n full: \"max-h-full\",\n } as const\n )[size];\n\n return (\n <DialogPrimitive.Portal>\n {overlay && <DrawerOverlay {...overlayProps} />}\n <DialogPrimitive.Content\n ref={ref}\n style={{\n zIndex: \"calc(var(--fanvue-ui-portal-z-index, 50) + 1)\",\n ...style,\n }}\n className={cn(\n \"fixed flex flex-col bg-surface-secondary outline-none backdrop-blur-lg\",\n // `shadow-lg` is scoped to `panel` rather than sitting in the base classes.\n // tailwind-merge does not recognise `shadow-blur-menu` as a box-shadow\n // utility, so it never deduped the two and `shadow-lg` won on stylesheet\n // order — meaning the sheet and menu surfaces silently rendered `shadow-lg`\n // instead of the menu shadow their tokens name.\n variant === \"panel\" && \"shadow-lg\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:duration-200 data-[state=open]:ease-out\",\n SLIDE_CLASSES[position],\n sizeClass,\n variant === \"sheet\" && SHEET_CLASSES,\n variant === \"menu\" && MENU_CLASSES,\n className,\n )}\n {...contentProps}\n >\n <DialogPrimitive.Close ref={closeRef} hidden tabIndex={-1} aria-hidden=\"true\" />\n {children}\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n );\n },\n);\nDrawerContent.displayName = \"DrawerContent\";\n\n/** Props for the {@link DrawerHeader} component. */\nexport interface DrawerHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether to show a built-in close (X) button. @default true */\n showClose?: boolean;\n /** Accessible label for the close button. @default \"Close drawer\" */\n closeLabel?: string;\n}\n\n/**\n * A semantic header area for the drawer, typically containing a title and description.\n * Renders a built-in close button by default.\n */\nexport const DrawerHeader = React.forwardRef<HTMLDivElement, DrawerHeaderProps>(\n ({ className, showClose = true, closeLabel = \"Close drawer\", children, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex items-center gap-2 p-4\", className)} {...props}>\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">{children}</div>\n {showClose && (\n <DialogPrimitive.Close asChild>\n <IconButton\n icon={<CloseIcon />}\n aria-label={closeLabel}\n variant=\"secondary\"\n size=\"32\"\n className=\"shrink-0\"\n />\n </DialogPrimitive.Close>\n )}\n </div>\n ),\n);\nDrawerHeader.displayName = \"DrawerHeader\";\n\n/** Props for the {@link DrawerFooter} component. */\nexport interface DrawerFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/** A semantic footer area for the drawer, typically containing action buttons. */\nexport const DrawerFooter = React.forwardRef<HTMLDivElement, DrawerFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex flex-col gap-2 p-4\", className)} {...props} />\n ),\n);\nDrawerFooter.displayName = \"DrawerFooter\";\n\n/** Props for the {@link DrawerTitle} component. */\nexport interface DrawerTitleProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> {}\n\n/** An accessible title for the drawer. Required for screen readers. */\nexport const DrawerTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n DrawerTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"typography-body-default-16px-semibold truncate text-content-primary\", className)}\n {...props}\n />\n));\nDrawerTitle.displayName = \"DrawerTitle\";\n\n/** Props for the {@link DrawerDescription} component. */\nexport interface DrawerDescriptionProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> {}\n\n/** An accessible description for the drawer, providing supplementary context. */\nexport const DrawerDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n DrawerDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"typography-body-small-14px-regular text-content-secondary\", className)}\n {...props}\n />\n));\nDrawerDescription.displayName = \"DrawerDescription\";\n"],"names":["React","jsx","DialogPrimitive","useSuppressClickAfterDrag","cn","useDragToDismiss","jsxs","IconButton","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,gBACJ;AAWF,MAAM,eACJ;AA2BF,MAAM,gBAAgBA,iBAAM,cAAoC;AAAA,EAC9D,SAAS;AACX,CAAC;AAuBM,SAAS,OAAO,EAAE,UAAU,MAAM,OAAO,UAAU,GAAG,SAAsB;AACjF,QAAM,gBAAgB,UAAU,UAAU,SAAY;AACtD,wCACG,cAAc,UAAd,EAAuB,OAAO,EAAE,QAAA,GAC/B,UAAAC,2BAAAA,IAACC,2BAAgB,MAAhB,EAAqB,OAAO,eAAgB,GAAG,OAC7C,UACH,GACF;AAEJ;AACA,OAAO,cAAc;AAYd,MAAM,gBAAgBF,iBAAM,WAGj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AAQ;AAAA,QACR,MAAK;AAAA,QACL,WAAU;AAAA,MAAA;AAAA,IAAA,EACZ,CACF;AAAA,EAAA,EAAA,CAEJ;AAEJ;AACA,aAAa,cAAc;AAMpB,MAAM,eAAeR,iBAAM;AAAA,EAChC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QACxBC,2BAAAA,IAAC,OAAA,EAAI,KAAU,WAAWG,GAAAA,GAAG,2BAA2B,SAAS,GAAI,GAAG,MAAA,CAAO;AAEnF;AACA,aAAa,cAAc;AAOpB,MAAM,cAAcJ,iBAAM,WAG/B,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWE,GAAAA,GAAG,uEAAuE,SAAS;AAAA,IAC7F,GAAG;AAAA,EAAA;AACN,CACD;AACD,YAAY,cAAc;AAOnB,MAAM,oBAAoBJ,iBAAM,WAGrC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWE,GAAAA,GAAG,6DAA6D,SAAS;AAAA,IACnF,GAAG;AAAA,EAAA;AACN,CACD;AACD,kBAAkB,cAAc;;;;;;;;;;"}
|
|
@@ -131,7 +131,7 @@ const DropdownMenuHeader = React__namespace.forwardRef(
|
|
|
131
131
|
]
|
|
132
132
|
}
|
|
133
133
|
),
|
|
134
|
-
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem.DropdownMenuSeparator, { className: "-mx-2 my-0 bg-border-
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem.DropdownMenuSeparator, { className: "-mx-2 my-0 bg-border-primary" })
|
|
135
135
|
]
|
|
136
136
|
}
|
|
137
137
|
);
|