@fanvue/ui 3.51.0 → 3.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs +34 -10
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/cjs/components/Autocomplete/AutocompleteOptionItem.cjs +13 -1
- package/dist/cjs/components/Autocomplete/AutocompleteOptionItem.cjs.map +1 -1
- package/dist/cjs/components/BottomNavigation/BottomNavigation.cjs +2 -2
- package/dist/cjs/components/BottomNavigation/BottomNavigation.cjs.map +1 -1
- package/dist/cjs/components/Card/Card.cjs +5 -2
- package/dist/cjs/components/Card/Card.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartCard.cjs +2 -1
- package/dist/cjs/components/Chart/ChartCard.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs +1 -1
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs.map +1 -1
- package/dist/cjs/components/ChatInput/ChatInput.cjs +2 -2
- package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
- package/dist/cjs/components/ChatMessage/ChatMessage.cjs +1 -1
- package/dist/cjs/components/ChatMessage/ChatMessage.cjs.map +1 -1
- package/dist/cjs/components/CreatorCard/CreatorCard.cjs +3 -5
- package/dist/cjs/components/CreatorCard/CreatorCard.cjs.map +1 -1
- package/dist/cjs/components/CreatorCover/CreatorCover.cjs +11 -7
- package/dist/cjs/components/CreatorCover/CreatorCover.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs +37 -16
- package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/cjs/components/Drawer/Drawer.cjs +11 -3
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +33 -10
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs +2 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +18 -13
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +56 -40
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.cjs +5 -2
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/Icons/MenuRowIcon.cjs +9 -2
- package/dist/cjs/components/Icons/MenuRowIcon.cjs.map +1 -1
- package/dist/cjs/components/Icons/VerifiedIcon.cjs +9 -15
- package/dist/cjs/components/Icons/VerifiedIcon.cjs.map +1 -1
- package/dist/cjs/components/InlineEmptyState/InlineEmptyState.cjs +42 -0
- package/dist/cjs/components/InlineEmptyState/InlineEmptyState.cjs.map +1 -0
- package/dist/cjs/components/Link/Link.cjs +30 -7
- package/dist/cjs/components/Link/Link.cjs.map +1 -1
- package/dist/cjs/components/PhoneField/PhoneField.cjs +21 -17
- package/dist/cjs/components/PhoneField/PhoneField.cjs.map +1 -1
- package/dist/cjs/components/Popover/Popover.cjs +69 -0
- package/dist/cjs/components/Popover/Popover.cjs.map +1 -0
- package/dist/cjs/components/SegmentedControl/SegmentedControl.cjs +6 -10
- package/dist/cjs/components/SegmentedControl/SegmentedControl.cjs.map +1 -1
- package/dist/cjs/components/SegmentedControl/segmentedControlClassNames.cjs +54 -0
- package/dist/cjs/components/SegmentedControl/segmentedControlClassNames.cjs.map +1 -0
- package/dist/cjs/components/Select/Select.cjs +40 -12
- package/dist/cjs/components/Select/Select.cjs.map +1 -1
- package/dist/cjs/components/Slider/SliderThumb.cjs +3 -2
- package/dist/cjs/components/Slider/SliderThumb.cjs.map +1 -1
- package/dist/cjs/components/Snackbar/Snackbar.cjs +1 -1
- package/dist/cjs/components/Snackbar/Snackbar.cjs.map +1 -1
- package/dist/cjs/components/Switch/Switch.cjs +1 -1
- package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
- package/dist/cjs/components/Table/Table.cjs +77 -7
- package/dist/cjs/components/Table/Table.cjs.map +1 -1
- package/dist/cjs/components/Table/TableRowLink.cjs +55 -0
- package/dist/cjs/components/Table/TableRowLink.cjs.map +1 -0
- package/dist/cjs/components/Tag/Tag.cjs +99 -0
- package/dist/cjs/components/Tag/Tag.cjs.map +1 -0
- package/dist/cjs/components/TextArea/TextArea.cjs +5 -4
- package/dist/cjs/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/cjs/components/TextField/TextField.cjs +30 -15
- package/dist/cjs/components/TextField/TextField.cjs.map +1 -1
- package/dist/cjs/index.cjs +12 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/utils/floatingContentSurface.cjs +8 -0
- package/dist/cjs/utils/floatingContentSurface.cjs.map +1 -0
- package/dist/cjs/utils/inputFieldClasses.cjs +8 -0
- package/dist/cjs/utils/inputFieldClasses.cjs.map +1 -0
- package/dist/cjs/utils/pointerCapture.cjs +20 -0
- package/dist/cjs/utils/pointerCapture.cjs.map +1 -0
- package/dist/cjs/utils/useDragToDismiss.cjs +3 -2
- package/dist/cjs/utils/useDragToDismiss.cjs.map +1 -1
- package/dist/cjs/utils/useSuppressClickAfterDrag.cjs +2 -1
- package/dist/cjs/utils/useSuppressClickAfterDrag.cjs.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.mjs +34 -10
- package/dist/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/dist/components/Autocomplete/AutocompleteOptionItem.mjs +13 -1
- package/dist/components/Autocomplete/AutocompleteOptionItem.mjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.mjs +2 -2
- package/dist/components/BottomNavigation/BottomNavigation.mjs.map +1 -1
- package/dist/components/Card/Card.mjs +5 -2
- package/dist/components/Card/Card.mjs.map +1 -1
- package/dist/components/Chart/ChartCard.mjs +2 -1
- package/dist/components/Chart/ChartCard.mjs.map +1 -1
- package/dist/components/Chart/ChartLoadingOverlay.mjs +1 -1
- package/dist/components/Chart/ChartLoadingOverlay.mjs.map +1 -1
- package/dist/components/ChatInput/ChatInput.mjs +2 -2
- package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
- package/dist/components/ChatMessage/ChatMessage.mjs +1 -1
- package/dist/components/ChatMessage/ChatMessage.mjs.map +1 -1
- package/dist/components/CreatorCard/CreatorCard.mjs +3 -5
- package/dist/components/CreatorCard/CreatorCard.mjs.map +1 -1
- package/dist/components/CreatorCover/CreatorCover.mjs +11 -7
- package/dist/components/CreatorCover/CreatorCover.mjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.mjs +39 -18
- package/dist/components/DatePicker/DatePicker.mjs.map +1 -1
- package/dist/components/Drawer/Drawer.mjs +11 -3
- package/dist/components/Drawer/Drawer.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs +33 -10
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs +2 -1
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +18 -13
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +56 -40
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -1
- package/dist/components/IconButton/IconButton.mjs +5 -2
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/Icons/MenuRowIcon.mjs +9 -2
- package/dist/components/Icons/MenuRowIcon.mjs.map +1 -1
- package/dist/components/Icons/VerifiedIcon.mjs +9 -15
- package/dist/components/Icons/VerifiedIcon.mjs.map +1 -1
- package/dist/components/InlineEmptyState/InlineEmptyState.mjs +25 -0
- package/dist/components/InlineEmptyState/InlineEmptyState.mjs.map +1 -0
- package/dist/components/Link/Link.mjs +31 -8
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/PhoneField/PhoneField.mjs +21 -17
- package/dist/components/PhoneField/PhoneField.mjs.map +1 -1
- package/dist/components/Popover/Popover.mjs +51 -0
- package/dist/components/Popover/Popover.mjs.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.mjs +6 -10
- package/dist/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/components/SegmentedControl/segmentedControlClassNames.mjs +54 -0
- package/dist/components/SegmentedControl/segmentedControlClassNames.mjs.map +1 -0
- package/dist/components/Select/Select.mjs +40 -12
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/Slider/SliderThumb.mjs +3 -2
- package/dist/components/Slider/SliderThumb.mjs.map +1 -1
- package/dist/components/Snackbar/Snackbar.mjs +1 -1
- package/dist/components/Snackbar/Snackbar.mjs.map +1 -1
- package/dist/components/Switch/Switch.mjs +1 -1
- package/dist/components/Switch/Switch.mjs.map +1 -1
- package/dist/components/Table/Table.mjs +77 -7
- package/dist/components/Table/Table.mjs.map +1 -1
- package/dist/components/Table/TableRowLink.mjs +38 -0
- package/dist/components/Table/TableRowLink.mjs.map +1 -0
- package/dist/components/Tag/Tag.mjs +82 -0
- package/dist/components/Tag/Tag.mjs.map +1 -0
- package/dist/components/TextArea/TextArea.mjs +5 -4
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/TextField/TextField.mjs +30 -15
- package/dist/components/TextField/TextField.mjs.map +1 -1
- package/dist/date-picker.d.ts +9 -0
- package/dist/index.d.ts +339 -30
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -1
- package/dist/styles/base.css +8 -4
- package/dist/styles/theme.css +1217 -1
- package/dist/utils/floatingContentSurface.mjs +8 -0
- package/dist/utils/floatingContentSurface.mjs.map +1 -0
- package/dist/utils/inputFieldClasses.mjs +8 -0
- package/dist/utils/inputFieldClasses.mjs.map +1 -0
- package/dist/utils/pointerCapture.mjs +20 -0
- package/dist/utils/pointerCapture.mjs.map +1 -0
- package/dist/utils/useDragToDismiss.mjs +3 -2
- package/dist/utils/useDragToDismiss.mjs.map +1 -1
- package/dist/utils/useSuppressClickAfterDrag.mjs +2 -1
- package/dist/utils/useSuppressClickAfterDrag.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatMessage.mjs","sources":["../../../src/components/ChatMessage/ChatMessage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { Avatar } from \"../Avatar/Avatar\";\nimport { DoubleTickIcon } from \"../Icons/DoubleTickIcon\";\nimport { TrashIcon } from \"../Icons/TrashIcon\";\n\nexport type ChatMessageUser = \"sender\" | \"receiver\";\n\nexport type ChatMessageVariant = \"text\" | \"typing\" | \"audio\" | \"deleted\";\n\nexport type ChatMessageStatus = \"delivered\" | \"read\";\n\nexport interface ChatMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Who sent the message. `\"sender\"` is the current user (right-aligned, green\n * bubble, delivery tick). `\"receiver\"` is the other party (left-aligned, grey\n * bubble, with avatar). @default \"receiver\"\n */\n user?: ChatMessageUser;\n /** The kind of content the message carries. @default \"text\" */\n variant?: ChatMessageVariant;\n /** Message body for the `\"text\"` variant. Keep it to inline content. */\n message?: React.ReactNode;\n /** Timestamp shown with the message, e.g. `\"16:00\"`. */\n time?: string;\n /**\n * Delivery status shown on sender messages (a double tick). Ignored for\n * receiver messages. `\"read\"` renders the tick in the read colour. @default \"delivered\"\n */\n status?: ChatMessageStatus;\n /** Duration label for the `\"audio\"` variant, e.g. `\"0:05\"`. @default \"0:00\" */\n audioDuration?: string;\n /**\n * Relative bar heights (values `0`–`1`) for the `\"audio\"` waveform. Defaults\n * to a flat row of dots matching the unplayed design state.\n */\n waveform?: number[];\n /** Whether the audio is playing (controlled). Pairs with {@link onPlayingChange}. */\n playing?: boolean;\n /** Initial playing state when uncontrolled. @default false */\n defaultPlaying?: boolean;\n /** Fired when the audio play/pause button is pressed, with the next playing state. */\n onPlayingChange?: (playing: boolean) => void;\n /** Render the receiver avatar. Reserves the avatar space when `false` so grouped bubbles stay aligned. @default true */\n showAvatar?: boolean;\n /** Avatar image URL for receiver messages. */\n avatarSrc?: string;\n /** Avatar alt text. @default \"Avatar\" */\n avatarAlt?: string;\n /** Avatar fallback (initials or icon) shown before the image loads. */\n avatarFallback?: React.ReactNode;\n /** Show the online indicator on the receiver avatar. @default false */\n online?: boolean;\n /** Accessible label for the typing indicator. @default \"Typing\" */\n typingLabel?: string;\n /** Text shown for the `\"deleted\"` variant. @default \"Message deleted\" */\n deletedLabel?: string;\n /** Accessible label for the audio play button. @default \"Play\" */\n playLabel?: string;\n /** Accessible label for the audio pause button. @default \"Pause\" */\n pauseLabel?: string;\n}\n\nconst DEFAULT_WAVEFORM = Array.from({ length: 64 }, () => 0);\nconst WAVEFORM_MIN_HEIGHT = 4;\nconst WAVEFORM_MAX_HEIGHT = 24;\n\nconst bubbleColors: Record<ChatMessageUser, string> = {\n sender: \"bg-messages-background-sender border-messages-background-sender-stroke\",\n receiver: \"bg-messages-background-receiver border-messages-background-receiver-stroke\",\n};\n\nfunction ChatMessageMeta({\n time,\n showTick,\n status,\n className,\n}: {\n time?: string;\n showTick: boolean;\n status: ChatMessageStatus;\n className?: string;\n}) {\n return (\n <span\n className={cn(\n \"typography-description-12px-regular inline-flex items-center gap-1 whitespace-nowrap text-content-secondary leading-none\",\n className,\n )}\n >\n {time ? <time>{time}</time> : null}\n {showTick ? (\n // The 24px geometry (stroked) scaled to 16px — the icon's 16px variant\n // is filled and renders as a blob at this size.\n <DoubleTickIcon\n size={24}\n aria-hidden={false}\n role=\"img\"\n aria-label={status === \"read\" ? \"Read\" : \"Delivered\"}\n className={cn(\n \"size-4 shrink-0\",\n status === \"read\" ? \"text-messages-read\" : \"text-icons-disabled\",\n )}\n />\n ) : null}\n </span>\n );\n}\n\nfunction TypingIndicator({ label }: { label: string }) {\n const dot = \"size-2 shrink-0 rounded-full motion-safe:animate-bounce\";\n return (\n // biome-ignore lint/a11y/useSemanticElements: <output> is not appropriate for a typing indicator; role=\"status\" is the correct live-region pattern\n <span role=\"status\" aria-label={label} className=\"flex items-center gap-2 px-0.5 py-1\">\n <span className={cn(dot, \"bg-content-primary\")} />\n <span className={cn(dot, \"bg-neutral-alphas-700 [animation-delay:150ms]\")} />\n <span className={cn(dot, \"bg-neutral-alphas-400 [animation-delay:300ms]\")} />\n </span>\n );\n}\n\nfunction Waveform({ bars }: { bars: number[] }) {\n return (\n <span className=\"flex min-w-0 flex-1 items-center gap-1 overflow-hidden\" aria-hidden>\n {bars.map((amplitude, index) => {\n const clamped = Math.min(1, Math.max(0, amplitude));\n const height = WAVEFORM_MIN_HEIGHT + clamped * (WAVEFORM_MAX_HEIGHT - WAVEFORM_MIN_HEIGHT);\n return (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: bars are positional and have no stable id\n key={index}\n className=\"w-1 shrink-0 rounded-3xs bg-messages-waveform-default\"\n style={{ height }}\n />\n );\n })}\n </span>\n );\n}\n\nfunction PlayGlyph() {\n return (\n <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\" className=\"size-6\">\n <path d=\"M8 5.14v13.72a1 1 0 0 0 1.54.84l10.28-6.86a1 1 0 0 0 0-1.68L9.54 4.3A1 1 0 0 0 8 5.14Z\" />\n </svg>\n );\n}\n\nfunction PauseGlyph() {\n return (\n <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\" className=\"size-6\">\n <rect x=\"7\" y=\"5\" width=\"3.5\" height=\"14\" rx=\"1\" />\n <rect x=\"13.5\" y=\"5\" width=\"3.5\" height=\"14\" rx=\"1\" />\n </svg>\n );\n}\n\n/**\n * A single chat message rendered as a bubble. Sender messages sit on the right\n * with a green bubble and a delivery tick; receiver messages sit on the left\n * with a grey bubble and an avatar. Supports plain text, a typing indicator, a\n * voice message with waveform, and a deleted-message placeholder.\n *\n * Text bubbles place the timestamp inline after short messages and drop it to\n * the bottom-right corner once the text wraps, so no variant switch is needed\n * for short versus long content.\n *\n * @example\n * ```tsx\n * <ChatMessage user=\"sender\" message=\"On my way!\" time=\"16:00\" status=\"read\" />\n * <ChatMessage user=\"receiver\" message=\"See you soon\" time=\"16:01\" avatarSrc=\"/jane.jpg\" online />\n * <ChatMessage user=\"receiver\" variant=\"typing\" avatarSrc=\"/jane.jpg\" />\n * ```\n */\nexport const ChatMessage = React.forwardRef<HTMLDivElement, ChatMessageProps>(\n (\n {\n className,\n user = \"receiver\",\n variant = \"text\",\n message,\n time,\n status = \"delivered\",\n audioDuration = \"0:00\",\n waveform,\n playing,\n defaultPlaying = false,\n onPlayingChange,\n showAvatar = true,\n avatarSrc,\n avatarAlt,\n avatarFallback,\n online = false,\n typingLabel = \"Typing\",\n deletedLabel = \"Message deleted\",\n playLabel = \"Play\",\n pauseLabel = \"Pause\",\n ...props\n },\n ref,\n ) => {\n const isSender = user === \"sender\";\n const showTick = isSender;\n\n const [internalPlaying, setInternalPlaying] = React.useState(defaultPlaying);\n const isPlaying = playing ?? internalPlaying;\n const togglePlaying = () => {\n const next = !isPlaying;\n if (playing === undefined) setInternalPlaying(next);\n onPlayingChange?.(next);\n };\n\n const bubbleBase = cn(\n \"w-fit min-w-0 max-w-full rounded-md border border-solid\",\n bubbleColors[user],\n );\n const hasMeta = Boolean(time) || showTick;\n\n let bubble: React.ReactNode;\n\n if (variant === \"typing\") {\n bubble = (\n <div className={cn(bubbleBase, \"px-3 py-2\")}>\n <TypingIndicator label={typingLabel} />\n </div>\n );\n } else if (variant === \"deleted\") {\n bubble = (\n <div className={cn(bubbleBase, \"flex items-baseline gap-6 px-3 py-2 opacity-60\")}>\n <span className=\"flex items-center gap-2\">\n <TrashIcon size={16} className=\"shrink-0 text-content-primary\" />\n <span className=\"typography-body-default-16px-regular whitespace-nowrap text-content-primary\">\n {deletedLabel}\n </span>\n </span>\n {hasMeta ? <ChatMessageMeta time={time} showTick={showTick} status={status} /> : null}\n </div>\n );\n } else if (variant === \"audio\") {\n bubble = (\n <div className={cn(bubbleBase, \"flex w-full flex-col p-2\")}>\n <div className=\"flex w-full flex-col items-start gap-2 px-1\">\n <div className=\"flex w-full items-center gap-3 pt-1\">\n <button\n type=\"button\"\n onClick={togglePlaying}\n aria-pressed={isPlaying}\n aria-label={isPlaying ? pauseLabel : playLabel}\n className={cn(\n \"flex size-12 shrink-0 items-center justify-center rounded-full bg-buttons-secondary-default text-icons-primary\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none motion-safe:transition-colors motion-safe:duration-150\",\n )}\n >\n {isPlaying ? <PauseGlyph /> : <PlayGlyph />}\n </button>\n <Waveform bars={waveform ?? DEFAULT_WAVEFORM} />\n <span className=\"typography-body-small-14px-regular whitespace-nowrap text-content-primary\">\n {audioDuration}\n </span>\n </div>\n {hasMeta ? (\n <ChatMessageMeta\n time={time}\n showTick={showTick}\n status={status}\n className=\"self-end\"\n />\n ) : null}\n </div>\n </div>\n );\n } else {\n // \"text\": the message and timestamp share a wrapping row. A brief message\n // keeps the time inline (24px gap = the design's Short treatment); once the\n // text wraps, the time drops to its own line bottom-right (the Default\n // treatment). No length prop needed — the layout adapts to the content.\n bubble = (\n <div className={cn(bubbleBase, \"px-3 py-2\")}>\n <div className=\"flex flex-wrap items-baseline justify-end gap-x-6 gap-y-2\">\n <p className=\"typography-body-default-16px-regular m-0 min-w-0 break-words text-content-primary\">\n {message}\n </p>\n {hasMeta ? (\n <ChatMessageMeta\n time={time}\n showTick={showTick}\n status={status}\n className=\"shrink-0\"\n />\n ) : null}\n </div>\n </div>\n );\n }\n\n const alignItems = variant === \"typing\" || variant === \"deleted\" ? \"items-center\" : \"items-end\";\n\n return (\n <div\n ref={ref}\n className={cn(\n \"flex min-h-10 w-full gap-2\",\n alignItems,\n isSender ? \"justify-end\" : \"justify-start\",\n className,\n )}\n {...props}\n >\n {!isSender &&\n (showAvatar ? (\n <div className=\"relative flex shrink-0\">\n <Avatar size={40} src={avatarSrc} alt={avatarAlt} fallback={avatarFallback} />\n {online ? (\n <span\n aria-hidden=\"true\"\n className=\"absolute right-0 bottom-0 size-2.5 rounded-full border border-border-background bg-messages-status-active\"\n />\n ) : null}\n </div>\n ) : (\n <div aria-hidden=\"true\" className=\"w-10 shrink-0\" />\n ))}\n {bubble}\n </div>\n );\n },\n);\n\nChatMessage.displayName = \"ChatMessage\";\n"],"names":[],"mappings":";;;;;;;AA+DA,MAAM,mBAAmB,MAAM,KAAK,EAAE,QAAQ,GAAA,GAAM,MAAM,CAAC;AAC3D,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAE5B,MAAM,eAAgD;AAAA,EACpD,QAAQ;AAAA,EACR,UAAU;AACZ;AAEA,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MAAA;AAAA,MAGD,UAAA;AAAA,QAAA,OAAO,oBAAC,QAAA,EAAM,UAAA,KAAA,CAAK,IAAU;AAAA,QAC7B;AAAA;AAAA;AAAA,UAGC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAM;AAAA,cACN,eAAa;AAAA,cACb,MAAK;AAAA,cACL,cAAY,WAAW,SAAS,SAAS;AAAA,cACzC,WAAW;AAAA,gBACT;AAAA,gBACA,WAAW,SAAS,uBAAuB;AAAA,cAAA;AAAA,YAC7C;AAAA,UAAA;AAAA,YAEA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAAS,gBAAgB,EAAE,SAA4B;AACrD,QAAM,MAAM;AACZ;AAAA;AAAA,yBAEG,QAAA,EAAK,MAAK,UAAS,cAAY,OAAO,WAAU,uCAC/C,UAAA;AAAA,MAAA,oBAAC,QAAA,EAAK,WAAW,GAAG,KAAK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,KAAK,WAAW,KAAK,WAAW,UAAU,eAAA,CAAgB;AAAA,YAC3E,SACC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,eAAY;AAAA,gBACZ,WAAU;AAAA,cAAA;AAAA,YAAA,IAEV;AAAA,UAAA,GACN,IAEA,oBAAC,OAAA,EAAI,eAAY,QAAO,WAAU,gBAAA,CAAgB;AAAA,UAErD;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEA,YAAY,cAAc;"}
|
|
1
|
+
{"version":3,"file":"ChatMessage.mjs","sources":["../../../src/components/ChatMessage/ChatMessage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { Avatar } from \"../Avatar/Avatar\";\nimport { DoubleTickIcon } from \"../Icons/DoubleTickIcon\";\nimport { TrashIcon } from \"../Icons/TrashIcon\";\n\nexport type ChatMessageUser = \"sender\" | \"receiver\";\n\nexport type ChatMessageVariant = \"text\" | \"typing\" | \"audio\" | \"deleted\";\n\nexport type ChatMessageStatus = \"delivered\" | \"read\";\n\nexport interface ChatMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Who sent the message. `\"sender\"` is the current user (right-aligned, green\n * bubble, delivery tick). `\"receiver\"` is the other party (left-aligned, grey\n * bubble, with avatar). @default \"receiver\"\n */\n user?: ChatMessageUser;\n /** The kind of content the message carries. @default \"text\" */\n variant?: ChatMessageVariant;\n /** Message body for the `\"text\"` variant. Keep it to inline content. */\n message?: React.ReactNode;\n /** Timestamp shown with the message, e.g. `\"16:00\"`. */\n time?: string;\n /**\n * Delivery status shown on sender messages (a double tick). Ignored for\n * receiver messages. `\"read\"` renders the tick in the read colour. @default \"delivered\"\n */\n status?: ChatMessageStatus;\n /** Duration label for the `\"audio\"` variant, e.g. `\"0:05\"`. @default \"0:00\" */\n audioDuration?: string;\n /**\n * Relative bar heights (values `0`–`1`) for the `\"audio\"` waveform. Defaults\n * to a flat row of dots matching the unplayed design state.\n */\n waveform?: number[];\n /** Whether the audio is playing (controlled). Pairs with {@link onPlayingChange}. */\n playing?: boolean;\n /** Initial playing state when uncontrolled. @default false */\n defaultPlaying?: boolean;\n /** Fired when the audio play/pause button is pressed, with the next playing state. */\n onPlayingChange?: (playing: boolean) => void;\n /** Render the receiver avatar. Reserves the avatar space when `false` so grouped bubbles stay aligned. @default true */\n showAvatar?: boolean;\n /** Avatar image URL for receiver messages. */\n avatarSrc?: string;\n /** Avatar alt text. @default \"Avatar\" */\n avatarAlt?: string;\n /** Avatar fallback (initials or icon) shown before the image loads. */\n avatarFallback?: React.ReactNode;\n /** Show the online indicator on the receiver avatar. @default false */\n online?: boolean;\n /** Accessible label for the typing indicator. @default \"Typing\" */\n typingLabel?: string;\n /** Text shown for the `\"deleted\"` variant. @default \"Message deleted\" */\n deletedLabel?: string;\n /** Accessible label for the audio play button. @default \"Play\" */\n playLabel?: string;\n /** Accessible label for the audio pause button. @default \"Pause\" */\n pauseLabel?: string;\n}\n\nconst DEFAULT_WAVEFORM = Array.from({ length: 64 }, () => 0);\nconst WAVEFORM_MIN_HEIGHT = 4;\nconst WAVEFORM_MAX_HEIGHT = 24;\n\nconst bubbleColors: Record<ChatMessageUser, string> = {\n sender: \"bg-messages-background-sender border-messages-background-sender-stroke\",\n receiver: \"bg-messages-background-receiver border-messages-background-receiver-stroke\",\n};\n\nfunction ChatMessageMeta({\n time,\n showTick,\n status,\n className,\n}: {\n time?: string;\n showTick: boolean;\n status: ChatMessageStatus;\n className?: string;\n}) {\n return (\n <span\n className={cn(\n \"typography-description-12px-regular inline-flex items-center gap-1 whitespace-nowrap text-content-secondary leading-none\",\n className,\n )}\n >\n {time ? <time>{time}</time> : null}\n {showTick ? (\n // The 24px geometry (stroked) scaled to 16px — the icon's 16px variant\n // is filled and renders as a blob at this size.\n <DoubleTickIcon\n size={24}\n aria-hidden={false}\n role=\"img\"\n aria-label={status === \"read\" ? \"Read\" : \"Delivered\"}\n className={cn(\n \"size-4 shrink-0\",\n status === \"read\"\n ? \"text-messages-read\"\n : \"text-icons-disabled theme-v2:text-icons-secondary\",\n )}\n />\n ) : null}\n </span>\n );\n}\n\nfunction TypingIndicator({ label }: { label: string }) {\n const dot = \"size-2 shrink-0 rounded-full motion-safe:animate-bounce\";\n return (\n // biome-ignore lint/a11y/useSemanticElements: <output> is not appropriate for a typing indicator; role=\"status\" is the correct live-region pattern\n <span role=\"status\" aria-label={label} className=\"flex items-center gap-2 px-0.5 py-1\">\n <span className={cn(dot, \"bg-content-primary\")} />\n <span className={cn(dot, \"bg-neutral-alphas-700 [animation-delay:150ms]\")} />\n <span className={cn(dot, \"bg-neutral-alphas-400 [animation-delay:300ms]\")} />\n </span>\n );\n}\n\nfunction Waveform({ bars }: { bars: number[] }) {\n return (\n <span className=\"flex min-w-0 flex-1 items-center gap-1 overflow-hidden\" aria-hidden>\n {bars.map((amplitude, index) => {\n const clamped = Math.min(1, Math.max(0, amplitude));\n const height = WAVEFORM_MIN_HEIGHT + clamped * (WAVEFORM_MAX_HEIGHT - WAVEFORM_MIN_HEIGHT);\n return (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: bars are positional and have no stable id\n key={index}\n className=\"w-1 shrink-0 rounded-3xs bg-messages-waveform-default\"\n style={{ height }}\n />\n );\n })}\n </span>\n );\n}\n\nfunction PlayGlyph() {\n return (\n <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\" className=\"size-6\">\n <path d=\"M8 5.14v13.72a1 1 0 0 0 1.54.84l10.28-6.86a1 1 0 0 0 0-1.68L9.54 4.3A1 1 0 0 0 8 5.14Z\" />\n </svg>\n );\n}\n\nfunction PauseGlyph() {\n return (\n <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\" className=\"size-6\">\n <rect x=\"7\" y=\"5\" width=\"3.5\" height=\"14\" rx=\"1\" />\n <rect x=\"13.5\" y=\"5\" width=\"3.5\" height=\"14\" rx=\"1\" />\n </svg>\n );\n}\n\n/**\n * A single chat message rendered as a bubble. Sender messages sit on the right\n * with a green bubble and a delivery tick; receiver messages sit on the left\n * with a grey bubble and an avatar. Supports plain text, a typing indicator, a\n * voice message with waveform, and a deleted-message placeholder.\n *\n * Text bubbles place the timestamp inline after short messages and drop it to\n * the bottom-right corner once the text wraps, so no variant switch is needed\n * for short versus long content.\n *\n * @example\n * ```tsx\n * <ChatMessage user=\"sender\" message=\"On my way!\" time=\"16:00\" status=\"read\" />\n * <ChatMessage user=\"receiver\" message=\"See you soon\" time=\"16:01\" avatarSrc=\"/jane.jpg\" online />\n * <ChatMessage user=\"receiver\" variant=\"typing\" avatarSrc=\"/jane.jpg\" />\n * ```\n */\nexport const ChatMessage = React.forwardRef<HTMLDivElement, ChatMessageProps>(\n (\n {\n className,\n user = \"receiver\",\n variant = \"text\",\n message,\n time,\n status = \"delivered\",\n audioDuration = \"0:00\",\n waveform,\n playing,\n defaultPlaying = false,\n onPlayingChange,\n showAvatar = true,\n avatarSrc,\n avatarAlt,\n avatarFallback,\n online = false,\n typingLabel = \"Typing\",\n deletedLabel = \"Message deleted\",\n playLabel = \"Play\",\n pauseLabel = \"Pause\",\n ...props\n },\n ref,\n ) => {\n const isSender = user === \"sender\";\n const showTick = isSender;\n\n const [internalPlaying, setInternalPlaying] = React.useState(defaultPlaying);\n const isPlaying = playing ?? internalPlaying;\n const togglePlaying = () => {\n const next = !isPlaying;\n if (playing === undefined) setInternalPlaying(next);\n onPlayingChange?.(next);\n };\n\n const bubbleBase = cn(\n \"w-fit min-w-0 max-w-full rounded-md border border-solid\",\n bubbleColors[user],\n );\n const hasMeta = Boolean(time) || showTick;\n\n let bubble: React.ReactNode;\n\n if (variant === \"typing\") {\n bubble = (\n <div className={cn(bubbleBase, \"px-3 py-2\")}>\n <TypingIndicator label={typingLabel} />\n </div>\n );\n } else if (variant === \"deleted\") {\n bubble = (\n <div className={cn(bubbleBase, \"flex items-baseline gap-6 px-3 py-2 opacity-60\")}>\n <span className=\"flex items-center gap-2\">\n <TrashIcon size={16} className=\"shrink-0 text-content-primary\" />\n <span className=\"typography-body-default-16px-regular whitespace-nowrap text-content-primary\">\n {deletedLabel}\n </span>\n </span>\n {hasMeta ? <ChatMessageMeta time={time} showTick={showTick} status={status} /> : null}\n </div>\n );\n } else if (variant === \"audio\") {\n bubble = (\n <div className={cn(bubbleBase, \"flex w-full flex-col p-2\")}>\n <div className=\"flex w-full flex-col items-start gap-2 px-1\">\n <div className=\"flex w-full items-center gap-3 pt-1\">\n <button\n type=\"button\"\n onClick={togglePlaying}\n aria-pressed={isPlaying}\n aria-label={isPlaying ? pauseLabel : playLabel}\n className={cn(\n \"flex size-12 shrink-0 items-center justify-center rounded-full bg-buttons-secondary-default text-icons-primary\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none motion-safe:transition-colors motion-safe:duration-150\",\n )}\n >\n {isPlaying ? <PauseGlyph /> : <PlayGlyph />}\n </button>\n <Waveform bars={waveform ?? DEFAULT_WAVEFORM} />\n <span className=\"typography-body-small-14px-regular whitespace-nowrap text-content-primary\">\n {audioDuration}\n </span>\n </div>\n {hasMeta ? (\n <ChatMessageMeta\n time={time}\n showTick={showTick}\n status={status}\n className=\"self-end\"\n />\n ) : null}\n </div>\n </div>\n );\n } else {\n // \"text\": the message and timestamp share a wrapping row. A brief message\n // keeps the time inline (24px gap = the design's Short treatment); once the\n // text wraps, the time drops to its own line bottom-right (the Default\n // treatment). No length prop needed — the layout adapts to the content.\n bubble = (\n <div className={cn(bubbleBase, \"px-3 py-2\")}>\n <div className=\"flex flex-wrap items-baseline justify-end gap-x-6 gap-y-2\">\n <p className=\"typography-body-default-16px-regular m-0 min-w-0 break-words text-content-primary\">\n {message}\n </p>\n {hasMeta ? (\n <ChatMessageMeta\n time={time}\n showTick={showTick}\n status={status}\n className=\"shrink-0\"\n />\n ) : null}\n </div>\n </div>\n );\n }\n\n const alignItems = variant === \"typing\" || variant === \"deleted\" ? \"items-center\" : \"items-end\";\n\n return (\n <div\n ref={ref}\n className={cn(\n \"flex min-h-10 w-full gap-2\",\n alignItems,\n isSender ? \"justify-end\" : \"justify-start\",\n className,\n )}\n {...props}\n >\n {!isSender &&\n (showAvatar ? (\n <div className=\"relative flex shrink-0\">\n <Avatar size={40} src={avatarSrc} alt={avatarAlt} fallback={avatarFallback} />\n {online ? (\n <span\n aria-hidden=\"true\"\n className=\"absolute right-0 bottom-0 size-2.5 rounded-full border border-border-background bg-messages-status-active\"\n />\n ) : null}\n </div>\n ) : (\n <div aria-hidden=\"true\" className=\"w-10 shrink-0\" />\n ))}\n {bubble}\n </div>\n );\n },\n);\n\nChatMessage.displayName = \"ChatMessage\";\n"],"names":[],"mappings":";;;;;;;AA+DA,MAAM,mBAAmB,MAAM,KAAK,EAAE,QAAQ,GAAA,GAAM,MAAM,CAAC;AAC3D,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAE5B,MAAM,eAAgD;AAAA,EACpD,QAAQ;AAAA,EACR,UAAU;AACZ;AAEA,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MAAA;AAAA,MAGD,UAAA;AAAA,QAAA,OAAO,oBAAC,QAAA,EAAM,UAAA,KAAA,CAAK,IAAU;AAAA,QAC7B;AAAA;AAAA;AAAA,UAGC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAM;AAAA,cACN,eAAa;AAAA,cACb,MAAK;AAAA,cACL,cAAY,WAAW,SAAS,SAAS;AAAA,cACzC,WAAW;AAAA,gBACT;AAAA,gBACA,WAAW,SACP,uBACA;AAAA,cAAA;AAAA,YACN;AAAA,UAAA;AAAA,YAEA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAAS,gBAAgB,EAAE,SAA4B;AACrD,QAAM,MAAM;AACZ;AAAA;AAAA,yBAEG,QAAA,EAAK,MAAK,UAAS,cAAY,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C,OAAA,EAAI,WAAU,0BACb,UAAA;AAAA,YAAA,oBAAC,QAAA,EAAO,MAAM,IAAI,KAAK,WAAW,KAAK,WAAW,UAAU,eAAA,CAAgB;AAAA,YAC3E,SACC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,eAAY;AAAA,gBACZ,WAAU;AAAA,cAAA;AAAA,YAAA,IAEV;AAAA,UAAA,GACN,IAEA,oBAAC,OAAA,EAAI,eAAY,QAAO,WAAU,gBAAA,CAAgB;AAAA,UAErD;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEA,YAAY,cAAc;"}
|
|
@@ -42,16 +42,14 @@ const CreatorCard = React.forwardRef(
|
|
|
42
42
|
] }),
|
|
43
43
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-2.5 p-3", children: [
|
|
44
44
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
45
|
-
/* @__PURE__ */ jsx(
|
|
45
|
+
avatar ? /* @__PURE__ */ jsx(
|
|
46
46
|
Avatar,
|
|
47
47
|
{
|
|
48
48
|
size: 32,
|
|
49
|
-
|
|
50
|
-
alt: avatar?.alt ?? (typeof name === "string" ? name : void 0),
|
|
51
|
-
fallback: avatar?.fallback,
|
|
49
|
+
alt: avatar.alt ?? (typeof name === "string" ? name : void 0),
|
|
52
50
|
...avatar
|
|
53
51
|
}
|
|
54
|
-
),
|
|
52
|
+
) : null,
|
|
55
53
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
56
54
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [
|
|
57
55
|
/* @__PURE__ */ jsx("p", { className: "typography-body-small-14px-semibold m-0 truncate text-content-primary", children: name }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreatorCard.mjs","sources":["../../../src/components/CreatorCard/CreatorCard.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Avatar } from \"../Avatar/Avatar\";\nimport { VerifiedIcon } from \"../Icons/VerifiedIcon\";\nimport { Pill, type PillProps } from \"../Pill/Pill\";\n\nexport interface CreatorCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"content\"> {\n /** Decorative banner media rendered at the top of the card. */\n background: React.ReactNode;\n /**\n * Props forwarded to a {@link Pill} overlaid on the top-left of the banner.\n * Pass the label as `children`. Omit to hide the pill.\n */\n pill?: PillProps;\n
|
|
1
|
+
{"version":3,"file":"CreatorCard.mjs","sources":["../../../src/components/CreatorCard/CreatorCard.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Avatar } from \"../Avatar/Avatar\";\nimport { VerifiedIcon } from \"../Icons/VerifiedIcon\";\nimport { Pill, type PillProps } from \"../Pill/Pill\";\n\nexport interface CreatorCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"content\"> {\n /** Decorative banner media rendered at the top of the card. */\n background: React.ReactNode;\n /**\n * Props forwarded to a {@link Pill} overlaid on the top-left of the banner.\n * Pass the label as `children`. Omit to hide the pill.\n */\n pill?: PillProps;\n /**\n * Props forwarded to the inner {@link Avatar}. Omit to hide the avatar, so the\n * name and tagline align with the card's left edge.\n */\n avatar?: React.ComponentPropsWithoutRef<typeof Avatar>;\n /** Creator display name, shown next to the avatar when there is one. */\n name: React.ReactNode;\n /** When `true`, renders a verified badge after the name. @default false */\n verified?: boolean;\n /** Accessible label for the verified badge. @default \"Verified\" */\n verifiedLabel?: string;\n /** Optional secondary line shown under the name (e.g. post count). */\n tagline?: React.ReactNode;\n /**\n * Optional content shown under the creator details (e.g. the subscription\n * price). It wraps by default; pass a `truncate` element to keep it on one line.\n */\n content?: React.ReactNode;\n /**\n * Action element rendered full-width at the bottom of the card (e.g. a\n * `Button` with `fullWidth` for subscribing to the creator).\n */\n action?: React.ReactNode;\n}\n\n/**\n * A card suggesting a creator, with a banner image, an optional {@link Pill},\n * the creator's avatar, name and tagline, free-form content such as a price,\n * and an optional action.\n *\n * The card has no fixed width or corner radius: set both through `className`\n * (e.g. `className=\"w-40 rounded-md\"`). The banner keeps a 10:11 ratio at any\n * width.\n *\n * @example\n * ```tsx\n * <CreatorCard\n * className=\"w-40 rounded-md\"\n * background={<img src=\"/banner.jpg\" alt=\"\" />}\n * pill={{ variant: \"contrast\", children: \"Popular this week\" }}\n * avatar={{ src: \"/avatar.jpg\", fallback: \"JD\" }}\n * name=\"Jane Doe\"\n * verified\n * tagline=\"412 posts\"\n * content={<span className=\"block truncate\">$9.99 / month</span>}\n * action={<Button variant=\"primary\" size=\"32\" fullWidth>Subscribe</Button>}\n * />\n * ```\n */\nexport const CreatorCard = React.forwardRef<HTMLDivElement, CreatorCardProps>(\n (\n {\n className,\n background,\n pill,\n avatar,\n name,\n verified = false,\n verifiedLabel = \"Verified\",\n tagline,\n content,\n action,\n ...props\n },\n ref,\n ) => {\n return (\n <div\n ref={ref}\n className={cn(\n \"relative isolate flex flex-col overflow-hidden bg-surface-primary\",\n className,\n )}\n {...props}\n >\n <div className=\"relative aspect-10/11 w-full shrink-0 overflow-hidden\">\n <div className=\"pointer-events-none absolute inset-0 select-none *:h-full *:w-full [&>img]:object-cover [&>video]:object-cover\">\n {background}\n </div>\n {pill ? (\n <Pill\n variant=\"contrast\"\n {...pill}\n className={cn(\"absolute top-2 left-2 max-w-[calc(100%-1rem)]\", pill.className)}\n />\n ) : null}\n </div>\n <div className=\"flex min-w-0 flex-col gap-2.5 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n {avatar ? (\n <Avatar\n size={32}\n alt={avatar.alt ?? (typeof name === \"string\" ? name : undefined)}\n {...avatar}\n />\n ) : null}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <div className=\"flex min-w-0 items-center gap-1\">\n <p className=\"typography-body-small-14px-semibold m-0 truncate text-content-primary\">\n {name}\n </p>\n {verified ? (\n <span\n role=\"img\"\n aria-label={verifiedLabel}\n className=\"inline-flex shrink-0 text-content-primary\"\n >\n <VerifiedIcon size={16} filled />\n </span>\n ) : null}\n </div>\n {tagline ? (\n <p className=\"typography-body-small-14px-regular m-0 truncate text-content-secondary\">\n {tagline}\n </p>\n ) : null}\n </div>\n </div>\n {content ? (\n <div className=\"typography-body-small-14px-semibold min-w-0 text-content-primary\">\n {content}\n </div>\n ) : null}\n {action ? <div className=\"flex w-full\">{action}</div> : null}\n </div>\n </div>\n );\n },\n);\n\nCreatorCard.displayName = \"CreatorCard\";\n"],"names":[],"mappings":";;;;;;;AA+DO,MAAM,cAAc,MAAM;AAAA,EAC/B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAA,qBAAC,OAAA,EAAI,WAAU,yDACb,UAAA;AAAA,YAAA,oBAAC,OAAA,EAAI,WAAU,kHACZ,UAAA,YACH;AAAA,YACC,OACC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAAQ;AAAA,gBACP,GAAG;AAAA,gBACJ,WAAW,GAAG,iDAAiD,KAAK,SAAS;AAAA,cAAA;AAAA,YAAA,IAE7E;AAAA,UAAA,GACN;AAAA,UACA,qBAAC,OAAA,EAAI,WAAU,qCACb,UAAA;AAAA,YAAA,qBAAC,OAAA,EAAI,WAAU,mCACZ,UAAA;AAAA,cAAA,SACC;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,MAAM;AAAA,kBACN,KAAK,OAAO,QAAQ,OAAO,SAAS,WAAW,OAAO;AAAA,kBACrD,GAAG;AAAA,gBAAA;AAAA,cAAA,IAEJ;AAAA,cACJ,qBAAC,OAAA,EAAI,WAAU,gCACb,UAAA;AAAA,gBAAA,qBAAC,OAAA,EAAI,WAAU,mCACb,UAAA;AAAA,kBAAA,oBAAC,KAAA,EAAE,WAAU,yEACV,UAAA,MACH;AAAA,kBACC,WACC;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC,MAAK;AAAA,sBACL,cAAY;AAAA,sBACZ,WAAU;AAAA,sBAEV,UAAA,oBAAC,cAAA,EAAa,MAAM,IAAI,QAAM,KAAA,CAAC;AAAA,oBAAA;AAAA,kBAAA,IAE/B;AAAA,gBAAA,GACN;AAAA,gBACC,UACC,oBAAC,KAAA,EAAE,WAAU,0EACV,mBACH,IACE;AAAA,cAAA,EAAA,CACN;AAAA,YAAA,GACF;AAAA,YACC,UACC,oBAAC,OAAA,EAAI,WAAU,oEACZ,mBACH,IACE;AAAA,YACH,SAAS,oBAAC,OAAA,EAAI,WAAU,eAAe,kBAAO,IAAS;AAAA,UAAA,EAAA,CAC1D;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,YAAY,cAAc;"}
|
|
@@ -16,10 +16,7 @@ const CreatorCover = React.forwardRef(
|
|
|
16
16
|
ref,
|
|
17
17
|
"aria-labelledby": headingId,
|
|
18
18
|
"data-testid": "creator-cover",
|
|
19
|
-
className: cn(
|
|
20
|
-
"relative isolate w-full overflow-hidden bg-white dark:bg-background-primary",
|
|
21
|
-
className
|
|
22
|
-
),
|
|
19
|
+
className: cn("relative isolate w-full overflow-hidden bg-background-primary", className),
|
|
23
20
|
...props,
|
|
24
21
|
children: [
|
|
25
22
|
/* @__PURE__ */ jsxs("div", { className: "absolute inset-0 -z-10", children: [
|
|
@@ -32,8 +29,8 @@ const CreatorCover = React.forwardRef(
|
|
|
32
29
|
className: "size-full scale-110 object-cover blur-3xl"
|
|
33
30
|
}
|
|
34
31
|
),
|
|
35
|
-
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-linear-to-b from-
|
|
36
|
-
/* @__PURE__ */ jsx("div", { className: "absolute inset-x-0 bottom-0 h-1/3 bg-linear-to-b from-transparent to-
|
|
32
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-linear-to-b from-background-primary/30 to-background-primary/15" }),
|
|
33
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-x-0 bottom-0 h-1/3 bg-linear-to-b from-transparent to-background-primary" })
|
|
37
34
|
] }),
|
|
38
35
|
/* @__PURE__ */ jsxs("div", { className: cn("mx-auto flex max-w-90 flex-col items-center gap-4 px-4 pt-17 pb-16"), children: [
|
|
39
36
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
@@ -49,7 +46,14 @@ const CreatorCover = React.forwardRef(
|
|
|
49
46
|
renderedTag ? /* @__PURE__ */ jsx("div", { className: "absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2", children: renderedTag }) : null
|
|
50
47
|
] }),
|
|
51
48
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-1 pt-4 text-center", children: [
|
|
52
|
-
/* @__PURE__ */ jsx(
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
"h2",
|
|
51
|
+
{
|
|
52
|
+
id: headingId,
|
|
53
|
+
className: "typography-header-heading-md m-0 text-content-always-white",
|
|
54
|
+
children: name
|
|
55
|
+
}
|
|
56
|
+
),
|
|
53
57
|
tagline ? /* @__PURE__ */ jsx("p", { className: "typography-badge-badgecaps m-0 text-brand-primary-default uppercase", children: tagline }) : null
|
|
54
58
|
] }),
|
|
55
59
|
action ? /* @__PURE__ */ jsx("div", { className: "w-full pt-2", children: action }) : null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreatorCover.mjs","sources":["../../../src/components/CreatorCover/CreatorCover.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Pill } from \"../Pill/Pill\";\n\n/** Slot that accepts a string (rendered as default styling) or a node for full control. */\nexport type CreatorCoverSlot = string | React.ReactNode;\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0;\n}\n\nexport interface CreatorCoverProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n /** URL of the creator image displayed in the centre card. Also used as the blurred backdrop unless `backgroundSrc` is provided. */\n imageSrc: string;\n /** Alt text for the centre cover image. @default \"\" */\n imageAlt?: string;\n /** Override URL used for the blurred background image. @default `imageSrc` */\n backgroundSrc?: string;\n /** Creator's name, rendered as the heading. */\n name: string;\n /** Smaller subtitle below the name (e.g. \"GLOBAL POPSTAR\"). Rendered uppercase in the brand colour. */\n tagline?: string;\n /**\n * Status label rendered as a pill overlapping the bottom of the cover image (e.g. \"New Joiner\").\n * Strings render with default green pill styling; pass a node for custom markup.\n */\n tag?: CreatorCoverSlot;\n /**\n * Primary call to action displayed below the title.\n */\n action?: React.ReactNode;\n /** When `true`, fades the bottom of the component to transparent and increases bottom padding to 64px. @default false */\n fadeBottom?: boolean;\n}\n\n/**\n * A creator profile hero with a stylised blurred backdrop, central cover image,\n * status pill, name, tagline, and primary call to action.\n *\n * @example\n * ```tsx\n * <CreatorCover\n * imageSrc=\"/creator.jpg\"\n * imageAlt=\"Jane Doe\"\n * name=\"JANE DOE\"\n * tagline=\"GLOBAL POPSTAR\"\n * tag=\"New Joiner\"\n * action={<Button variant=\"brand\" size=\"48\" fullWidth>Join for free for 7 days</Button>}\n * />\n * ```\n */\nexport const CreatorCover = React.forwardRef<HTMLElement, CreatorCoverProps>(\n (\n { className, imageSrc, imageAlt = \"\", backgroundSrc, name, tagline, tag, action, ...props },\n ref,\n ) => {\n const headingId = React.useId();\n\n const renderedTag = isNonEmptyString(tag) ? <Pill variant=\"brand\">{tag}</Pill> : tag;\n\n return (\n <section\n ref={ref}\n aria-labelledby={headingId}\n data-testid=\"creator-cover\"\n className={cn(\
|
|
1
|
+
{"version":3,"file":"CreatorCover.mjs","sources":["../../../src/components/CreatorCover/CreatorCover.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Pill } from \"../Pill/Pill\";\n\n/** Slot that accepts a string (rendered as default styling) or a node for full control. */\nexport type CreatorCoverSlot = string | React.ReactNode;\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0;\n}\n\nexport interface CreatorCoverProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n /** URL of the creator image displayed in the centre card. Also used as the blurred backdrop unless `backgroundSrc` is provided. */\n imageSrc: string;\n /** Alt text for the centre cover image. @default \"\" */\n imageAlt?: string;\n /** Override URL used for the blurred background image. @default `imageSrc` */\n backgroundSrc?: string;\n /** Creator's name, rendered as the heading. */\n name: string;\n /** Smaller subtitle below the name (e.g. \"GLOBAL POPSTAR\"). Rendered uppercase in the brand colour. */\n tagline?: string;\n /**\n * Status label rendered as a pill overlapping the bottom of the cover image (e.g. \"New Joiner\").\n * Strings render with default green pill styling; pass a node for custom markup.\n */\n tag?: CreatorCoverSlot;\n /**\n * Primary call to action displayed below the title.\n */\n action?: React.ReactNode;\n /** When `true`, fades the bottom of the component to transparent and increases bottom padding to 64px. @default false */\n fadeBottom?: boolean;\n}\n\n/**\n * A creator profile hero with a stylised blurred backdrop, central cover image,\n * status pill, name, tagline, and primary call to action.\n *\n * @example\n * ```tsx\n * <CreatorCover\n * imageSrc=\"/creator.jpg\"\n * imageAlt=\"Jane Doe\"\n * name=\"JANE DOE\"\n * tagline=\"GLOBAL POPSTAR\"\n * tag=\"New Joiner\"\n * action={<Button variant=\"brand\" size=\"48\" fullWidth>Join for free for 7 days</Button>}\n * />\n * ```\n */\nexport const CreatorCover = React.forwardRef<HTMLElement, CreatorCoverProps>(\n (\n { className, imageSrc, imageAlt = \"\", backgroundSrc, name, tagline, tag, action, ...props },\n ref,\n ) => {\n const headingId = React.useId();\n\n const renderedTag = isNonEmptyString(tag) ? <Pill variant=\"brand\">{tag}</Pill> : tag;\n\n return (\n <section\n ref={ref}\n aria-labelledby={headingId}\n data-testid=\"creator-cover\"\n className={cn(\"relative isolate w-full overflow-hidden bg-background-primary\", className)}\n {...props}\n >\n <div className=\"absolute inset-0 -z-10\">\n <img\n src={backgroundSrc ?? imageSrc}\n alt=\"\"\n loading=\"lazy\"\n className=\"size-full scale-110 object-cover blur-3xl\"\n />\n <div className=\"absolute inset-0 bg-linear-to-b from-background-primary/30 to-background-primary/15\" />\n <div className=\"absolute inset-x-0 bottom-0 h-1/3 bg-linear-to-b from-transparent to-background-primary\" />\n </div>\n <div className={cn(\"mx-auto flex max-w-90 flex-col items-center gap-4 px-4 pt-17 pb-16\")}>\n <div className=\"relative\">\n <img\n src={imageSrc}\n alt={imageAlt}\n loading=\"lazy\"\n className=\"block h-55 w-37.5 rounded-lg object-cover\"\n />\n {renderedTag ? (\n <div className=\"absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2\">\n {renderedTag}\n </div>\n ) : null}\n </div>\n <div className=\"flex flex-col items-center gap-1 pt-4 text-center\">\n <h2\n id={headingId}\n className=\"typography-header-heading-md m-0 text-content-always-white\"\n >\n {name}\n </h2>\n {tagline ? (\n <p className=\"typography-badge-badgecaps m-0 text-brand-primary-default uppercase\">\n {tagline}\n </p>\n ) : null}\n </div>\n {action ? <div className=\"w-full pt-2\">{action}</div> : null}\n </div>\n </section>\n );\n },\n);\n\nCreatorCover.displayName = \"CreatorCover\";\n"],"names":[],"mappings":";;;;;AAOA,SAAS,iBAAiB,OAAiC;AACzD,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS;AACrD;AA0CO,MAAM,eAAe,MAAM;AAAA,EAChC,CACE,EAAE,WAAW,UAAU,WAAW,IAAI,eAAe,MAAM,SAAS,KAAK,QAAQ,GAAG,MAAA,GACpF,QACG;AACH,UAAM,YAAY,MAAM,MAAA;AAExB,UAAM,cAAc,iBAAiB,GAAG,wBAAK,MAAA,EAAK,SAAQ,SAAS,UAAA,IAAA,CAAI,IAAU;AAEjF,WACE;AAAA,M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|
|
2
|
-
import {
|
|
3
|
-
import { forwardRef, useRef, useEffect } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, createContext, useRef, useContext, useEffect } from "react";
|
|
4
4
|
import { DayPicker } from "react-day-picker";
|
|
5
5
|
import { cn } from "../../utils/cn.mjs";
|
|
6
6
|
import { Button } from "../Button/Button.mjs";
|
|
7
7
|
import { ChevronLeftIcon } from "../Icons/ChevronLeftIcon.mjs";
|
|
8
8
|
import { ChevronRightIcon } from "../Icons/ChevronRightIcon.mjs";
|
|
9
|
+
const DatePickerSizeContext = createContext("40");
|
|
9
10
|
function Day({ day, modifiers, className, ...divProps }) {
|
|
10
11
|
const { range_start, range_end, range_middle } = modifiers;
|
|
11
12
|
const isSingleDayRange = range_start && range_end;
|
|
@@ -15,9 +16,9 @@ function Day({ day, modifiers, className, ...divProps }) {
|
|
|
15
16
|
{
|
|
16
17
|
className: cn(
|
|
17
18
|
className,
|
|
18
|
-
inRange && "bg-inputs-calendar-range",
|
|
19
|
-
inRange && range_start && "rounded-l-sm",
|
|
20
|
-
inRange && range_end && "rounded-r-sm"
|
|
19
|
+
inRange && "before:absolute before:inset-x-0 before:inset-y-0.5 before:bg-inputs-calendar-range first:before:left-0.5 first:before:rounded-l-sm last:before:right-0.5 last:before:rounded-r-sm",
|
|
20
|
+
inRange && range_start && "before:left-0.5 before:rounded-l-sm",
|
|
21
|
+
inRange && range_end && "before:right-0.5 before:rounded-r-sm"
|
|
21
22
|
),
|
|
22
23
|
...divProps
|
|
23
24
|
}
|
|
@@ -25,6 +26,7 @@ function Day({ day, modifiers, className, ...divProps }) {
|
|
|
25
26
|
}
|
|
26
27
|
function DayButton({ day, modifiers, className, ...buttonProps }) {
|
|
27
28
|
const ref = useRef(null);
|
|
29
|
+
const size = useContext(DatePickerSizeContext);
|
|
28
30
|
useEffect(() => {
|
|
29
31
|
if (modifiers.focused) ref.current?.focus();
|
|
30
32
|
}, [modifiers.focused]);
|
|
@@ -35,11 +37,14 @@ function DayButton({ day, modifiers, className, ...buttonProps }) {
|
|
|
35
37
|
ref,
|
|
36
38
|
type: "button",
|
|
37
39
|
className: cn(
|
|
38
|
-
"relative z-10 inline-flex
|
|
40
|
+
"relative z-10 inline-flex cursor-pointer items-center justify-center rounded-sm text-content-primary",
|
|
39
41
|
"transition-colors hover:bg-inputs-calendar-range not-disabled:active:bg-inputs-calendar-range",
|
|
40
42
|
"focus-visible:shadow-focus-ring focus-visible:outline-none",
|
|
41
43
|
"disabled:cursor-not-allowed",
|
|
42
|
-
|
|
44
|
+
size === "40" && "size-10",
|
|
45
|
+
size === "32" && "size-8",
|
|
46
|
+
size === "40" && (isSelected ? "typography-body-small-14px-semibold" : "typography-body-small-14px-regular"),
|
|
47
|
+
size === "32" && (isSelected ? "typography-description-12px-semibold" : "typography-description-12px-regular"),
|
|
43
48
|
modifiers.today && !isSelected && "bg-inputs-calendar-today ring-1 ring-inputs-calendar-today-stroke hover:bg-inputs-calendar-today",
|
|
44
49
|
isSelected && "bg-inputs-calendar-selected text-content-primary-inverted hover:bg-inputs-calendar-selected",
|
|
45
50
|
modifiers.range_middle && "bg-transparent hover:bg-transparent",
|
|
@@ -53,6 +58,7 @@ function DayButton({ day, modifiers, className, ...buttonProps }) {
|
|
|
53
58
|
const DatePicker = forwardRef(
|
|
54
59
|
({
|
|
55
60
|
variant = "single",
|
|
61
|
+
size = "40",
|
|
56
62
|
onApply,
|
|
57
63
|
onCancel,
|
|
58
64
|
cancelLabel = "Cancel",
|
|
@@ -64,6 +70,11 @@ const DatePicker = forwardRef(
|
|
|
64
70
|
}, ref) => {
|
|
65
71
|
const numberOfMonths = variant === "double" ? 2 : 1;
|
|
66
72
|
const isMulti = numberOfMonths > 1;
|
|
73
|
+
const isCompact = size === "32";
|
|
74
|
+
const navButtonClassName = cn(
|
|
75
|
+
"pointer-events-auto inline-flex cursor-pointer items-center justify-center rounded-full bg-buttons-secondary-default text-content-primary transition-colors hover:bg-buttons-secondary-hover focus-visible:shadow-focus-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-buttons-disabled-default disabled:text-content-disabled [&>svg]:size-4",
|
|
76
|
+
isCompact ? "size-6" : "size-8"
|
|
77
|
+
);
|
|
67
78
|
const resolvedDayPickerProps = (() => {
|
|
68
79
|
if (dayPickerProps.mode !== "range") return dayPickerProps;
|
|
69
80
|
const { selected, onSelect } = dayPickerProps;
|
|
@@ -87,12 +98,13 @@ const DatePicker = forwardRef(
|
|
|
87
98
|
}
|
|
88
99
|
};
|
|
89
100
|
})();
|
|
90
|
-
return /* @__PURE__ */ jsxs(
|
|
101
|
+
return /* @__PURE__ */ jsx(DatePickerSizeContext.Provider, { value: size, children: /* @__PURE__ */ jsxs(
|
|
91
102
|
"div",
|
|
92
103
|
{
|
|
93
104
|
ref,
|
|
94
105
|
className: cn(
|
|
95
|
-
"inline-flex flex-col rounded-xl border border-modal-stroke bg-modal-background
|
|
106
|
+
"inline-flex flex-col rounded-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-sm",
|
|
107
|
+
isCompact ? "p-4" : "p-6",
|
|
96
108
|
className
|
|
97
109
|
),
|
|
98
110
|
children: [
|
|
@@ -109,14 +121,23 @@ const DatePicker = forwardRef(
|
|
|
109
121
|
root: "w-full",
|
|
110
122
|
months: cn("relative flex", isMulti && "gap-6"),
|
|
111
123
|
month: "flex flex-1 flex-col",
|
|
112
|
-
month_caption:
|
|
113
|
-
|
|
124
|
+
month_caption: cn(
|
|
125
|
+
"flex items-center justify-center",
|
|
126
|
+
isCompact ? "mb-2 h-6" : "mb-4 h-8"
|
|
127
|
+
),
|
|
128
|
+
caption_label: cn(
|
|
129
|
+
"text-content-primary",
|
|
130
|
+
isCompact ? "typography-body-small-14px-regular" : "typography-body-default-16px-regular"
|
|
131
|
+
),
|
|
114
132
|
nav: "absolute inset-x-0 top-0 z-20 flex justify-between",
|
|
115
|
-
button_previous:
|
|
116
|
-
button_next:
|
|
133
|
+
button_previous: navButtonClassName,
|
|
134
|
+
button_next: navButtonClassName,
|
|
117
135
|
month_grid: "w-full",
|
|
118
136
|
weekdays: "flex",
|
|
119
|
-
weekday:
|
|
137
|
+
weekday: cn(
|
|
138
|
+
"flex flex-1 items-center justify-center text-content-secondary",
|
|
139
|
+
isCompact ? "typography-description-12px-regular h-6 w-8" : "typography-body-small-14px-regular h-7.5 w-10"
|
|
140
|
+
),
|
|
120
141
|
week: "flex",
|
|
121
142
|
day: "relative flex flex-1 items-center justify-center p-0.5",
|
|
122
143
|
hidden: "hidden"
|
|
@@ -137,13 +158,13 @@ const DatePicker = forwardRef(
|
|
|
137
158
|
...resolvedDayPickerProps
|
|
138
159
|
}
|
|
139
160
|
),
|
|
140
|
-
showFooter && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 pt-6", children: [
|
|
141
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size
|
|
142
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", size
|
|
161
|
+
showFooter && /* @__PURE__ */ jsxs("div", { className: cn("flex gap-2", isCompact ? "pt-4" : "pt-6"), children: [
|
|
162
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size, className: "flex-1", onClick: onCancel, children: cancelLabel }),
|
|
163
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", size, className: "flex-1", onClick: onApply, children: applyLabel })
|
|
143
164
|
] })
|
|
144
165
|
]
|
|
145
166
|
}
|
|
146
|
-
);
|
|
167
|
+
) });
|
|
147
168
|
}
|
|
148
169
|
);
|
|
149
170
|
DatePicker.displayName = "DatePicker";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.mjs","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef } from \"react\";\nimport {\n type ChevronProps,\n type DateRange,\n type DayButtonProps,\n DayPicker,\n type DayPickerProps,\n type DayProps,\n type Modifiers,\n type MonthGridProps,\n type WeekdayProps,\n type WeekdaysProps,\n type WeekProps,\n type WeeksProps,\n} from \"react-day-picker\";\nimport { cn } from \"../../utils/cn\";\nimport type { OmitDistributed } from \"../../utils/types\";\nimport { Button } from \"../Button/Button\";\nimport { ChevronLeftIcon } from \"../Icons/ChevronLeftIcon\";\nimport { ChevronRightIcon } from \"../Icons/ChevronRightIcon\";\n\nexport type { DateRange }; // Needed by consumers when passing props\n\n/** Layout variant — single or side-by-side month display. */\nexport type DatePickerVariant = \"single\" | \"double\";\n\n/** Props specific to the DatePicker wrapper (not inherited from react-day-picker). */\nexport interface DatePickerOwnProps {\n /** Display one month or two side-by-side. @default \"single\" */\n variant?: DatePickerVariant;\n /** Callback fired when the Apply button is clicked. */\n onApply?: () => void;\n /** Callback fired when the Cancel button is clicked. */\n onCancel?: () => void;\n /** Label for the cancel button. @default \"Cancel\" */\n cancelLabel?: string;\n /** Label for the apply button. @default \"Apply\" */\n applyLabel?: string;\n /** Whether to render the cancel / apply footer buttons. @default true */\n showFooter?: boolean;\n /** Additional CSS class name for the outer container. */\n className?: string;\n}\n\nfunction Day({ day, modifiers, className, ...divProps }: DayProps) {\n const { range_start, range_end, range_middle } = modifiers;\n const isSingleDayRange = range_start && range_end;\n const inRange = (range_start || range_end || range_middle) && !isSingleDayRange;\n\n return (\n <div\n className={cn(\n className,\n inRange && \"bg-inputs-calendar-range\",\n inRange && range_start && \"rounded-l-sm\",\n inRange && range_end && \"rounded-r-sm\",\n )}\n {...divProps}\n />\n );\n}\n\nfunction DayButton({ day, modifiers, className, ...buttonProps }: DayButtonProps) {\n const ref = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n if (modifiers.focused) ref.current?.focus();\n }, [modifiers.focused]);\n\n const isSelected = modifiers.selected && !modifiers.range_middle;\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={cn(\n \"relative z-10 inline-flex size-10 cursor-pointer items-center justify-center rounded-sm text-content-primary\",\n \"transition-colors hover:bg-inputs-calendar-range not-disabled:active:bg-inputs-calendar-range\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n \"disabled:cursor-not-allowed\",\n isSelected ? \"typography-body-small-14px-semibold\" : \"typography-body-small-14px-regular\",\n modifiers.today &&\n !isSelected &&\n \"bg-inputs-calendar-today ring-1 ring-inputs-calendar-today-stroke hover:bg-inputs-calendar-today\",\n isSelected &&\n \"bg-inputs-calendar-selected text-content-primary-inverted hover:bg-inputs-calendar-selected\",\n modifiers.range_middle && \"bg-transparent hover:bg-transparent\",\n modifiers.disabled &&\n \"bg-inputs-calendar-disabled text-content-disabled hover:bg-inputs-calendar-disabled\",\n modifiers.outside && \"pointer-events-none text-content-disabled\",\n )}\n {...buttonProps}\n />\n );\n}\n\n/** Combined props — own DatePicker options plus all react-day-picker props (except `numberOfMonths`). */\nexport type DatePickerProps = DatePickerOwnProps &\n OmitDistributed<DayPickerProps, \"numberOfMonths\">;\n\n/**\n * A calendar date picker supporting single-date and date-range selection with\n * optional side-by-side month display and footer action buttons.\n *\n * Built on top of [react-day-picker](https://react-day-picker.js.org/) — all\n * `DayPickerProps` (except `numberOfMonths`) are forwarded.\n *\n * @example\n * ```tsx\n * <DatePicker\n * mode=\"range\"\n * variant=\"double\"\n * selected={range}\n * onSelect={setRange}\n * onApply={save}\n * onCancel={close}\n * />\n * ```\n */\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(\n (\n {\n variant = \"single\",\n onApply,\n onCancel,\n cancelLabel = \"Cancel\",\n applyLabel = \"Apply\",\n showFooter = true,\n className,\n formatters,\n ...dayPickerProps\n },\n ref,\n ) => {\n const numberOfMonths = variant === \"double\" ? 2 : 1;\n const isMulti = numberOfMonths > 1;\n\n // Wrap onSelect for range mode: when clicking inside a complete range,\n // move the nearest boundary instead of always resetting the end date.\n const resolvedDayPickerProps = (() => {\n if (dayPickerProps.mode !== \"range\") return dayPickerProps;\n\n const { selected, onSelect } = dayPickerProps as {\n selected?: DateRange;\n onSelect?: (\n range: DateRange | undefined,\n triggerDate: Date,\n modifiers: Modifiers,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => void;\n };\n\n if (!onSelect || !selected?.from || !selected?.to) return dayPickerProps;\n\n const { from, to } = selected;\n\n return {\n ...dayPickerProps,\n onSelect: (\n range: DateRange | undefined,\n triggerDate: Date,\n modifiers: Modifiers,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => {\n const clickedTime = triggerDate.getTime();\n const fromTime = from.getTime();\n const toTime = to.getTime();\n\n if (clickedTime > fromTime && clickedTime < toTime) {\n if (clickedTime - fromTime <= toTime - clickedTime) {\n onSelect({ from: triggerDate, to }, triggerDate, modifiers, e);\n } else {\n onSelect({ from, to: triggerDate }, triggerDate, modifiers, e);\n }\n return;\n }\n\n onSelect(range, triggerDate, modifiers, e);\n },\n } as typeof dayPickerProps;\n })();\n\n return (\n <div\n ref={ref}\n className={cn(\n \"inline-flex flex-col rounded-xl border border-modal-stroke bg-modal-background p-6 shadow-blur-menu backdrop-blur-sm\",\n className,\n )}\n >\n <DayPicker\n showOutsideDays\n numberOfMonths={numberOfMonths}\n formatters={{\n formatCaption: (date: Date) =>\n date.toLocaleDateString(\"en-US\", { month: \"long\", year: \"numeric\" }),\n ...formatters,\n }}\n classNames={{\n root: \"w-full\",\n months: cn(\"relative flex\", isMulti && \"gap-6\"),\n month: \"flex flex-1 flex-col\",\n month_caption: \"mb-4 flex h-8 items-center justify-center\",\n caption_label: \"typography-body-default-16px-regular text-content-primary\",\n nav: \"absolute inset-x-0 top-0 z-20 flex justify-between\",\n button_previous:\n \"pointer-events-auto inline-flex size-8 cursor-pointer items-center justify-center rounded-full bg-buttons-secondary-default text-content-primary transition-colors hover:bg-buttons-secondary-hover focus-visible:shadow-focus-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-buttons-disabled-default disabled:text-content-disabled [&>svg]:size-4\",\n button_next:\n \"pointer-events-auto inline-flex size-8 cursor-pointer items-center justify-center rounded-full bg-buttons-secondary-default text-content-primary transition-colors hover:bg-buttons-secondary-hover focus-visible:shadow-focus-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-buttons-disabled-default disabled:text-content-disabled [&>svg]:size-4\",\n month_grid: \"w-full\",\n weekdays: \"flex\",\n weekday:\n \"flex h-[30px] w-10 flex-1 items-center justify-center typography-body-small-14px-regular text-content-secondary\",\n week: \"flex\",\n day: \"relative flex flex-1 items-center justify-center p-0.5\",\n hidden: \"hidden\",\n }}\n components={{\n /**\n * !NOTE: We're unable to use semantic elements for the grid due to rdp, as such we've disabled the a11y lint rules for these elements in biome.json.\n */\n Chevron: ({ orientation }: ChevronProps) =>\n orientation === \"left\" ? <ChevronLeftIcon /> : <ChevronRightIcon />,\n MonthGrid: (props: MonthGridProps) => <div role=\"grid\" {...props} />,\n Weekdays: (props: WeekdaysProps) => <div role=\"row\" {...props} />,\n Weekday: (props: WeekdayProps) => <div role=\"columnheader\" {...props} />,\n Weeks: (props: WeeksProps) => <div role=\"rowgroup\" {...props} />,\n Week: ({ week, ...props }: WeekProps) => <div role=\"row\" {...props} />,\n Day,\n DayButton,\n }}\n {...resolvedDayPickerProps}\n />\n\n {showFooter && (\n <div className=\"flex gap-2 pt-6\">\n <Button variant=\"outline\" size=\"40\" className=\"flex-1\" onClick={onCancel}>\n {cancelLabel}\n </Button>\n <Button variant=\"primary\" size=\"40\" className=\"flex-1\" onClick={onApply}>\n {applyLabel}\n </Button>\n </div>\n )}\n </div>\n );\n },\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":[],"mappings":";;;;;;;;AA4CA,SAAS,IAAI,EAAE,KAAK,WAAW,WAAW,GAAG,YAAsB;AACjE,QAAM,EAAE,aAAa,WAAW,aAAA,IAAiB;AACjD,QAAM,mBAAmB,eAAe;AACxC,QAAM,WAAW,eAAe,aAAa,iBAAiB,CAAC;AAE/D,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,WAAW;AAAA,QACX,WAAW,eAAe;AAAA,QAC1B,WAAW,aAAa;AAAA,MAAA;AA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A,gBAC/D,SAAS,CAAC,UAAwB,oBAAC,SAAI,MAAK,gBAAgB,GAAG,OAAO;AAAA,gBACtE,OAAO,CAAC,UAAsB,oBAAC,SAAI,MAAK,YAAY,GAAG,OAAO;AAAA,gBAC9D,MAAM,CAAC,EAAE,MAAM,GAAG,MAAA,MAAuB,oBAAC,OAAA,EAAI,MAAK,OAAO,GAAG,MAAA,CAAO;AAAA,gBACpE;AAAA,gBACA;AAAA,cAAA;AAAA,cAED,GAAG;AAAA,YAAA;AAAA,UAAA;AAAA,UAGL,cACC,qBAAC,OAAA,EAAI,WAAU,mBACb,UAAA;AAAA,YAAA,oBAAC,QAAA,EAAO,SAAQ,WAAU,MAAK,MAAK,WAAU,UAAS,SAAS,UAC7D,UAAA,YAAA,CACH;AAAA,YACA,oBAAC,QAAA,EAAO,SAAQ,WAAU,MAAK,MAAK,WAAU,UAAS,SAAS,SAC7D,UAAA,WAAA,CACH;AAAA,UAAA,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,WAAW,cAAc;"}
|
|
1
|
+
{"version":3,"file":"DatePicker.mjs","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import { createContext, forwardRef, useContext, useEffect, useRef } from \"react\";\nimport {\n type ChevronProps,\n type DateRange,\n type DayButtonProps,\n DayPicker,\n type DayPickerProps,\n type DayProps,\n type Modifiers,\n type MonthGridProps,\n type WeekdayProps,\n type WeekdaysProps,\n type WeekProps,\n type WeeksProps,\n} from \"react-day-picker\";\nimport { cn } from \"../../utils/cn\";\nimport type { OmitDistributed } from \"../../utils/types\";\nimport { Button } from \"../Button/Button\";\nimport { ChevronLeftIcon } from \"../Icons/ChevronLeftIcon\";\nimport { ChevronRightIcon } from \"../Icons/ChevronRightIcon\";\n\nexport type { DateRange }; // Needed by consumers when passing props\n\n/** Layout variant — single or side-by-side month display. */\nexport type DatePickerVariant = \"single\" | \"double\";\n\n/** Day button size in pixels. It also scales the navigation, caption, padding and footer buttons. */\nexport type DatePickerSize = \"40\" | \"32\";\n\n/** Props specific to the DatePicker wrapper (not inherited from react-day-picker). */\nexport interface DatePickerOwnProps {\n /** Display one month or two side-by-side. @default \"single\" */\n variant?: DatePickerVariant;\n /**\n * Day button size in pixels. It also scales the navigation, caption, padding and footer buttons.\n * Use `\"32\"` for compact surfaces such as toolbar popovers.\n * @default \"40\"\n */\n size?: DatePickerSize;\n /** Callback fired when the Apply button is clicked. */\n onApply?: () => void;\n /** Callback fired when the Cancel button is clicked. */\n onCancel?: () => void;\n /** Label for the cancel button. @default \"Cancel\" */\n cancelLabel?: string;\n /** Label for the apply button. @default \"Apply\" */\n applyLabel?: string;\n /** Whether to render the cancel / apply footer buttons. @default true */\n showFooter?: boolean;\n /** Additional CSS class name for the outer container. */\n className?: string;\n}\n\nconst DatePickerSizeContext = createContext<DatePickerSize>(\"40\");\n\nfunction Day({ day, modifiers, className, ...divProps }: DayProps) {\n const { range_start, range_end, range_middle } = modifiers;\n const isSingleDayRange = range_start && range_end;\n const inRange = (range_start || range_end || range_middle) && !isSingleDayRange;\n\n return (\n <div\n className={cn(\n className,\n inRange &&\n \"before:absolute before:inset-x-0 before:inset-y-0.5 before:bg-inputs-calendar-range first:before:left-0.5 first:before:rounded-l-sm last:before:right-0.5 last:before:rounded-r-sm\",\n inRange && range_start && \"before:left-0.5 before:rounded-l-sm\",\n inRange && range_end && \"before:right-0.5 before:rounded-r-sm\",\n )}\n {...divProps}\n />\n );\n}\n\nfunction DayButton({ day, modifiers, className, ...buttonProps }: DayButtonProps) {\n const ref = useRef<HTMLButtonElement>(null);\n const size = useContext(DatePickerSizeContext);\n\n useEffect(() => {\n if (modifiers.focused) ref.current?.focus();\n }, [modifiers.focused]);\n\n const isSelected = modifiers.selected && !modifiers.range_middle;\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={cn(\n \"relative z-10 inline-flex cursor-pointer items-center justify-center rounded-sm text-content-primary\",\n \"transition-colors hover:bg-inputs-calendar-range not-disabled:active:bg-inputs-calendar-range\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n \"disabled:cursor-not-allowed\",\n size === \"40\" && \"size-10\",\n size === \"32\" && \"size-8\",\n size === \"40\" &&\n (isSelected\n ? \"typography-body-small-14px-semibold\"\n : \"typography-body-small-14px-regular\"),\n size === \"32\" &&\n (isSelected\n ? \"typography-description-12px-semibold\"\n : \"typography-description-12px-regular\"),\n modifiers.today &&\n !isSelected &&\n \"bg-inputs-calendar-today ring-1 ring-inputs-calendar-today-stroke hover:bg-inputs-calendar-today\",\n isSelected &&\n \"bg-inputs-calendar-selected text-content-primary-inverted hover:bg-inputs-calendar-selected\",\n modifiers.range_middle && \"bg-transparent hover:bg-transparent\",\n modifiers.disabled &&\n \"bg-inputs-calendar-disabled text-content-disabled hover:bg-inputs-calendar-disabled\",\n modifiers.outside && \"pointer-events-none text-content-disabled\",\n )}\n {...buttonProps}\n />\n );\n}\n\n/** Combined props — own DatePicker options plus all react-day-picker props (except `numberOfMonths`). */\nexport type DatePickerProps = DatePickerOwnProps &\n OmitDistributed<DayPickerProps, \"numberOfMonths\">;\n\n/**\n * A calendar date picker supporting single-date and date-range selection with\n * optional side-by-side month display and footer action buttons.\n *\n * Built on top of [react-day-picker](https://react-day-picker.js.org/) — all\n * `DayPickerProps` (except `numberOfMonths`) are forwarded.\n *\n * @example\n * ```tsx\n * <DatePicker\n * mode=\"range\"\n * variant=\"double\"\n * selected={range}\n * onSelect={setRange}\n * onApply={save}\n * onCancel={close}\n * />\n * ```\n */\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(\n (\n {\n variant = \"single\",\n size = \"40\",\n onApply,\n onCancel,\n cancelLabel = \"Cancel\",\n applyLabel = \"Apply\",\n showFooter = true,\n className,\n formatters,\n ...dayPickerProps\n },\n ref,\n ) => {\n const numberOfMonths = variant === \"double\" ? 2 : 1;\n const isMulti = numberOfMonths > 1;\n const isCompact = size === \"32\";\n const navButtonClassName = cn(\n \"pointer-events-auto inline-flex cursor-pointer items-center justify-center rounded-full bg-buttons-secondary-default text-content-primary transition-colors hover:bg-buttons-secondary-hover focus-visible:shadow-focus-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-buttons-disabled-default disabled:text-content-disabled [&>svg]:size-4\",\n isCompact ? \"size-6\" : \"size-8\",\n );\n\n // Wrap onSelect for range mode: when clicking inside a complete range,\n // move the nearest boundary instead of always resetting the end date.\n const resolvedDayPickerProps = (() => {\n if (dayPickerProps.mode !== \"range\") return dayPickerProps;\n\n const { selected, onSelect } = dayPickerProps as {\n selected?: DateRange;\n onSelect?: (\n range: DateRange | undefined,\n triggerDate: Date,\n modifiers: Modifiers,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => void;\n };\n\n if (!onSelect || !selected?.from || !selected?.to) return dayPickerProps;\n\n const { from, to } = selected;\n\n return {\n ...dayPickerProps,\n onSelect: (\n range: DateRange | undefined,\n triggerDate: Date,\n modifiers: Modifiers,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => {\n const clickedTime = triggerDate.getTime();\n const fromTime = from.getTime();\n const toTime = to.getTime();\n\n if (clickedTime > fromTime && clickedTime < toTime) {\n if (clickedTime - fromTime <= toTime - clickedTime) {\n onSelect({ from: triggerDate, to }, triggerDate, modifiers, e);\n } else {\n onSelect({ from, to: triggerDate }, triggerDate, modifiers, e);\n }\n return;\n }\n\n onSelect(range, triggerDate, modifiers, e);\n },\n } as typeof dayPickerProps;\n })();\n\n return (\n <DatePickerSizeContext.Provider value={size}>\n <div\n ref={ref}\n className={cn(\n \"inline-flex flex-col rounded-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-sm\",\n isCompact ? \"p-4\" : \"p-6\",\n className,\n )}\n >\n <DayPicker\n showOutsideDays\n numberOfMonths={numberOfMonths}\n formatters={{\n formatCaption: (date: Date) =>\n date.toLocaleDateString(\"en-US\", { month: \"long\", year: \"numeric\" }),\n ...formatters,\n }}\n classNames={{\n root: \"w-full\",\n months: cn(\"relative flex\", isMulti && \"gap-6\"),\n month: \"flex flex-1 flex-col\",\n month_caption: cn(\n \"flex items-center justify-center\",\n isCompact ? \"mb-2 h-6\" : \"mb-4 h-8\",\n ),\n caption_label: cn(\n \"text-content-primary\",\n isCompact\n ? \"typography-body-small-14px-regular\"\n : \"typography-body-default-16px-regular\",\n ),\n nav: \"absolute inset-x-0 top-0 z-20 flex justify-between\",\n button_previous: navButtonClassName,\n button_next: navButtonClassName,\n month_grid: \"w-full\",\n weekdays: \"flex\",\n weekday: cn(\n \"flex flex-1 items-center justify-center text-content-secondary\",\n isCompact\n ? \"typography-description-12px-regular h-6 w-8\"\n : \"typography-body-small-14px-regular h-7.5 w-10\",\n ),\n week: \"flex\",\n day: \"relative flex flex-1 items-center justify-center p-0.5\",\n hidden: \"hidden\",\n }}\n components={{\n /**\n * !NOTE: We're unable to use semantic elements for the grid due to rdp, as such we've disabled the a11y lint rules for these elements in biome.json.\n */\n Chevron: ({ orientation }: ChevronProps) =>\n orientation === \"left\" ? <ChevronLeftIcon /> : <ChevronRightIcon />,\n MonthGrid: (props: MonthGridProps) => <div role=\"grid\" {...props} />,\n Weekdays: (props: WeekdaysProps) => <div role=\"row\" {...props} />,\n Weekday: (props: WeekdayProps) => <div role=\"columnheader\" {...props} />,\n Weeks: (props: WeeksProps) => <div role=\"rowgroup\" {...props} />,\n Week: ({ week, ...props }: WeekProps) => <div role=\"row\" {...props} />,\n Day,\n DayButton,\n }}\n {...resolvedDayPickerProps}\n />\n\n {showFooter && (\n <div className={cn(\"flex gap-2\", isCompact ? \"pt-4\" : \"pt-6\")}>\n <Button variant=\"outline\" size={size} className=\"flex-1\" onClick={onCancel}>\n {cancelLabel}\n </Button>\n <Button variant=\"primary\" size={size} className=\"flex-1\" onClick={onApply}>\n {applyLabel}\n </Button>\n </div>\n )}\n </div>\n </DatePickerSizeContext.Provider>\n );\n },\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":[],"mappings":";;;;;;;;AAqDA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,EAAO,SAAQ,WAAU,MAAY,WAAU,UAAS,SAAS,UAC/D,UAAA,YAAA,CACH;AAAA,YACA,oBAAC,UAAO,SAAQ,WAAU,MAAY,WAAU,UAAS,SAAS,SAC/D,UAAA,WAAA,CACH;AAAA,UAAA,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,GAGN;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;"}
|
|
@@ -20,6 +20,8 @@ const MODAL_FULL_HEIGHT_CLASSES = {
|
|
|
20
20
|
bottom: "max-h-[calc(100%-1rem-env(safe-area-inset-bottom,0px))]",
|
|
21
21
|
top: "max-h-[calc(100%-1rem-env(safe-area-inset-top,0px))]"
|
|
22
22
|
};
|
|
23
|
+
const PAGE_CLASSES = "top-4 max-h-full w-auto overflow-hidden rounded-t-md border border-b-0 border-modal-stroke bg-background-primary shadow-lg";
|
|
24
|
+
const PAGE_MOTION_CLASSES = "data-[state=open]:duration-300 data-[state=open]:ease-[cubic-bezier(0.32,0.72,0,1)] data-[state=closed]:duration-200 data-[state=closed]:ease-[cubic-bezier(0.32,0,0.67,0)] motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none";
|
|
23
25
|
const DrawerContext = React.createContext({
|
|
24
26
|
overlay: true
|
|
25
27
|
});
|
|
@@ -58,7 +60,7 @@ const SLIDE_CLASSES = {
|
|
|
58
60
|
const DrawerContent = React.forwardRef(
|
|
59
61
|
({
|
|
60
62
|
className,
|
|
61
|
-
position
|
|
63
|
+
position: positionProp,
|
|
62
64
|
size = "sm",
|
|
63
65
|
variant = "panel",
|
|
64
66
|
overlay: overlayProp,
|
|
@@ -69,9 +71,13 @@ const DrawerContent = React.forwardRef(
|
|
|
69
71
|
}, ref) => {
|
|
70
72
|
const ctx = React.useContext(DrawerContext);
|
|
71
73
|
const overlay = overlayProp ?? ctx.overlay;
|
|
74
|
+
const position = variant === "page" ? "bottom" : positionProp ?? "right";
|
|
72
75
|
const closeRef = React.useRef(null);
|
|
73
76
|
const contentProps = useDragToDismiss(
|
|
74
|
-
{
|
|
77
|
+
{
|
|
78
|
+
enabled: position === "bottom" && variant !== "page",
|
|
79
|
+
onDismiss: () => closeRef.current?.click()
|
|
80
|
+
},
|
|
75
81
|
props
|
|
76
82
|
);
|
|
77
83
|
const isHorizontal = position === "left" || position === "right";
|
|
@@ -93,6 +99,7 @@ const DrawerContent = React.forwardRef(
|
|
|
93
99
|
...overlayProps,
|
|
94
100
|
className: cn(
|
|
95
101
|
variant === "modal" && "bg-background-overlay-heavy",
|
|
102
|
+
variant === "page" && PAGE_MOTION_CLASSES,
|
|
96
103
|
overlayProps?.className
|
|
97
104
|
)
|
|
98
105
|
}
|
|
@@ -112,7 +119,7 @@ const DrawerContent = React.forwardRef(
|
|
|
112
119
|
// utility, so it never deduped the two and `shadow-lg` won on stylesheet
|
|
113
120
|
// order — meaning the sheet and menu surfaces silently rendered `shadow-lg`
|
|
114
121
|
// instead of the menu shadow their tokens name.
|
|
115
|
-
variant === "panel" && "shadow-lg",
|
|
122
|
+
(variant === "panel" || variant === "page") && "shadow-lg",
|
|
116
123
|
"data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
117
124
|
"data-[state=closed]:duration-150 data-[state=closed]:ease-in",
|
|
118
125
|
"data-[state=open]:duration-200 data-[state=open]:ease-out",
|
|
@@ -125,6 +132,7 @@ const DrawerContent = React.forwardRef(
|
|
|
125
132
|
MODAL_POSITION_CLASSES[position],
|
|
126
133
|
size === "full" && MODAL_FULL_HEIGHT_CLASSES[position]
|
|
127
134
|
),
|
|
135
|
+
variant === "page" && cn(PAGE_CLASSES, PAGE_MOTION_CLASSES),
|
|
128
136
|
className
|
|
129
137
|
),
|
|
130
138
|
...contentProps,
|