@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuHeader.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuHeader.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { ArrowLeftIcon } from \"../Icons/ArrowLeftIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { SearchIcon } from \"../Icons/SearchIcon\";\nimport { DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\nimport { DropdownMenuSeparator } from \"./DropdownMenuItem\";\n\n// Keys that the menu must keep handling even when focus is inside a child\n// input — arrows move the highlight into the list, Tab leaves the menu, and\n// Enter / Escape close it.\nconst NAVIGATION_KEYS = new Set([\n \"ArrowDown\",\n \"ArrowUp\",\n \"ArrowLeft\",\n \"ArrowRight\",\n \"Escape\",\n \"Tab\",\n \"Enter\",\n]);\n\n/** Header type. `\"default\"` shows a title; `\"search\"` shows a search input. */\nexport type DropdownMenuHeaderType = \"default\" | \"search\";\n\n/** Header height preset. Matches the menu item sizing scale. */\nexport type DropdownMenuHeaderSize = \"40\" | \"32\";\n\n/** Search-input configuration for {@link DropdownMenuHeader} when `type=\"search\"`. */\nexport interface DropdownMenuHeaderSearchProps {\n /** Controlled value of the search input. */\n value?: string;\n /** Uncontrolled default value. */\n defaultValue?: string;\n /** Fires when the input value changes. */\n onChange?: (value: string) => void;\n /** Placeholder text shown when the input is empty. @default \"Search…\" */\n placeholder?: string;\n /** Accessible label for the search input. @default \"Search\" */\n \"aria-label\"?: string;\n /**\n * Focus the input as soon as the menu opens, so typing filters immediately.\n * Radix parks initial focus on the content element (which is what drives its\n * typeahead), so without this the first keystrokes never reach the input.\n */\n autoFocus?: boolean;\n}\n\nexport interface DropdownMenuHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Visual type. `\"default\"` shows a title; `\"search\"` shows a search input. @default \"default\" */\n type?: DropdownMenuHeaderType;\n /** Height preset for the header row. @default \"40\" */\n size?: DropdownMenuHeaderSize;\n /** Title text shown when `type=\"default\"`. Ignored if `children` is provided. */\n title?: string;\n /** Configuration for the embedded search input when `type=\"search\"`. */\n searchProps?: DropdownMenuHeaderSearchProps;\n /**\n * Action elements rendered at the end of the header row, before the close\n * button — e.g. icon buttons for search/add, or a primary \"Done\" button that\n * commits a {@link DropdownMenuReorderGroup} reorder. An action that should\n * close the menu needs the menu's `open` state controlled (only the built-in\n * close button can dismiss an uncontrolled menu).\n */\n actions?: React.ReactNode;\n /** Whether to render the close icon button on the right. @default true */\n showClose?: boolean;\n /** Fires when the close icon button is activated. */\n onClose?: () => void;\n /** Accessible label for the close button. @default \"Close menu\" */\n closeLabel?: string;\n /**\n * Fires when the back icon button at the start of the row is activated.\n * Rendering it lets a menu step back from a sub-view — a `type=\"search\"`\n * header returning to its title, for instance — without closing the menu.\n */\n onBack?: () => void;\n /** Whether to render the back icon button. @default `onBack !== undefined` */\n showBack?: boolean;\n /** Accessible label for the back button. @default \"Back\" */\n backLabel?: string;\n}\n\n/**\n * Optional header rendered at the top of a {@link DropdownMenuContent}. Use\n * `type=\"default\"` to title the menu, or `type=\"search\"` to embed a search\n * input for filtering long lists.\n *\n * Renders an inset separator beneath the row so it slots cleanly above the\n * first group of items.\n *\n * @example\n * ```tsx\n * <DropdownMenuContent>\n * <DropdownMenuHeader title=\"Sort by\" onClose={() => setOpen(false)} />\n * <DropdownMenuItem>Newest</DropdownMenuItem>\n * <DropdownMenuItem>Oldest</DropdownMenuItem>\n * </DropdownMenuContent>\n * ```\n */\nexport const DropdownMenuHeader = React.forwardRef<HTMLDivElement, DropdownMenuHeaderProps>(\n (\n {\n type = \"default\",\n size = \"40\",\n title,\n searchProps,\n actions,\n showClose = true,\n onClose,\n closeLabel = \"Close menu\",\n onBack,\n showBack = onBack !== undefined,\n backLabel = \"Back\",\n className,\n children,\n ...props\n },\n ref,\n ) => {\n // Regular, not semibold: `V2 Menu Header` titles the menu at\n // `Body Default 16px/Regular`. The weight belongs to the rows' own titles,\n // which is where the two-line layout puts a semibold.\n const titleTypography =\n size === \"32\" ? \"typography-body-small-14px-regular\" : \"typography-body-default-16px-regular\";\n const toggleOpen = React.useContext(ToggleOpenContext);\n const variant = React.useContext(DropdownMenuVariantContext);\n\n const handleClose = () => {\n onClose?.();\n // Also dismiss the Radix menu when used in uncontrolled mode — otherwise\n // the close button would look broken to consumers that don't wire up\n // `open` / `onOpenChange` themselves.\n toggleOpen?.(() => false);\n };\n\n return (\n <div\n ref={ref}\n className={cn(\n \"mb-1 flex flex-col px-1 pt-1\",\n // Search needs an 8px gap between the input and the divider; the\n // default (title) variant uses 4px because the title baseline sits\n // closer to the divider naturally.\n type === \"search\" ? \"gap-2\" : \"gap-1\",\n // With action buttons the design draws a roomier header: 12px above\n // the 32px actions row (the panel's own 4px padding makes up the\n // difference), 8px between it and the divider, and 8px between the\n // divider and the first row.\n actions != null && \"mb-2 gap-2 pt-2\",\n // The sheet is a taller, roomier surface than a trigger-anchored panel:\n // the design sets 16px between the rule and the first row, which this\n // margin plus the panel's own 4px gap adds up to.\n variant === \"sheet\" && \"mb-3\",\n className,\n )}\n {...props}\n >\n {/*\n * The title is inset a further 8px so it clears the panel's rounded\n * corner; the search input is not, because the design runs it to the\n * header's own padding (`V2 Menu Dropdown` node `7393:62008`: the search\n * row is `flex gap-16 w-full` with no inset, so the field sits 8px from\n * the panel edge on both sides). Insetting it left-only left the field\n * 16px in on the left and 8px on the right.\n */}\n <div\n className={cn(\n \"flex items-center gap-4\",\n // With action buttons the title sits a further 4px in (20px from\n // the panel edge) than the close-only header's 16px. A back button\n // supplies its own inset.\n type === \"default\" && !showBack && (actions != null ? \"pl-3\" : \"pl-2\"),\n )}\n >\n {showBack && (\n <div data-dropdown-menu-tab-stops=\"\" className=\"flex shrink-0 items-center\">\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<ArrowLeftIcon />}\n onClick={onBack}\n aria-label={backLabel}\n />\n </div>\n )}\n {type === \"default\" ? (\n <div className={cn(\"min-w-0 flex-1 truncate text-content-primary\", titleTypography)}>\n {children ?? title}\n </div>\n ) : (\n <SearchInput {...searchProps} />\n )}\n {(actions != null || showClose) && (\n // The extra right margin only applies with action buttons: filled\n // actions like a \"Done\" pill sit 12px off the panel edge, while the\n // bare tertiary close icon keeps the header's own 8px inset.\n <div\n data-dropdown-menu-tab-stops=\"\"\n className={cn(\"flex shrink-0 items-center gap-1\", actions != null && \"mr-1\")}\n >\n {actions}\n {showClose && (\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<CloseIcon />}\n onClick={handleClose}\n aria-label={closeLabel}\n />\n )}\n </div>\n )}\n </div>\n {/*\n * Full-bleed, as the design draws it: the rule runs the panel's whole\n * width rather than stopping at the text. `-mx-2` cancels both insets it\n * sits inside — this header's own `px-1` and the content panel's `p-1`.\n *\n * `border-strong` is the colour the design gives this rule. The separator's\n * own default is `neutral-alphas-200`, which in the dark theme is a 20%\n * *white* alpha — as a hairline running the full width it reads as a white\n * line rather than a divider. Group separators between items keep the\n * alpha; this is the header's rule only.\n */}\n <DropdownMenuSeparator className=\"-mx-2 my-0 bg-border-strong\" />\n </div>\n );\n },\n);\nDropdownMenuHeader.displayName = \"DropdownMenuHeader\";\n\nfunction SearchInput({\n value,\n defaultValue,\n onChange,\n placeholder = \"Search\\u2026\",\n \"aria-label\": ariaLabel = \"Search\",\n autoFocus,\n}: DropdownMenuHeaderSearchProps = {}) {\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n // Focus after mount rather than via the `autoFocus` attribute, so the focus\n // move is explicit and only happens when the consumer asked for it.\n React.useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n return (\n <label\n data-dropdown-menu-tab-stops=\"\"\n className={cn(\n \"flex min-w-0 flex-1 items-center gap-2 rounded-xs border border-border-primary\",\n \"bg-inputs-inputs-primary px-3 py-1 text-content-primary\",\n \"focus-within:shadow-focus-ring focus-within:outline-none\",\n )}\n >\n <SearchIcon className=\"size-4 shrink-0 text-content-primary\" aria-hidden=\"true\" />\n <input\n type=\"search\"\n className={cn(\n \"typography-body-default-16px-regular min-w-0 flex-1 bg-transparent outline-none\",\n \"placeholder:text-content-tertiary\",\n )}\n ref={inputRef}\n value={value}\n defaultValue={defaultValue}\n placeholder={placeholder}\n aria-label={ariaLabel}\n onChange={(event) => onChange?.(event.target.value)}\n // Radix DropdownMenu listens for keystrokes on Content for its\n // typeahead (typing letters jumps focus to a matching item). That\n // listener steals focus from the input after the first letter, so we\n // stop character keys from bubbling. Navigation keys (arrows / Tab /\n // Escape / Enter) are still allowed through so the user can leave the\n // input for the list or close the menu. Pointer events are stopped so\n // clicking back into the input doesn't fight the menu's focus\n // management either.\n onKeyDown={(event) => {\n if (!NAVIGATION_KEYS.has(event.key)) event.stopPropagation();\n }}\n onPointerDown={(event) => event.stopPropagation()}\n onMouseDown={(event) => event.stopPropagation()}\n />\n </label>\n );\n}\n"],"names":["React","ToggleOpenContext","DropdownMenuVariantContext","jsxs","cn","jsx","IconButton","ArrowLeftIcon","CloseIcon","DropdownMenuSeparator","SearchIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,sCAAsB,IAAI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAgFM,MAAM,qBAAqBA,iBAAM;AAAA,EACtC,CACE;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA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AAA,YACL,WAAWD,GAAAA;AAAAA,cACT;AAAA,cACA;AAAA,YAAA;AAAA,YAEF,KAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA,cAAY;AAAA,YACZ,UAAU,CAAC,UAAU,WAAW,MAAM,OAAO,KAAK;AAAA,YASlD,WAAW,CAAC,UAAU;AACpB,kBAAI,CAAC,gBAAgB,IAAI,MAAM,GAAG,SAAS,gBAAA;AAAA,YAC7C;AAAA,YACA,eAAe,CAAC,UAAU,MAAM,gBAAA;AAAA,YAChC,aAAa,CAAC,UAAU,MAAM,gBAAA;AAAA,UAAgB;AAAA,QAAA;AAAA,MAChD;AAAA,IAAA;AAAA,EAAA;AAGN;;"}
|
|
1
|
+
{"version":3,"file":"DropdownMenuHeader.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuHeader.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { ArrowLeftIcon } from \"../Icons/ArrowLeftIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { SearchIcon } from \"../Icons/SearchIcon\";\nimport { DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\nimport { DropdownMenuSeparator } from \"./DropdownMenuItem\";\n\n// Keys that the menu must keep handling even when focus is inside a child\n// input — arrows move the highlight into the list, Tab leaves the menu, and\n// Enter / Escape close it.\nconst NAVIGATION_KEYS = new Set([\n \"ArrowDown\",\n \"ArrowUp\",\n \"ArrowLeft\",\n \"ArrowRight\",\n \"Escape\",\n \"Tab\",\n \"Enter\",\n]);\n\n/** Header type. `\"default\"` shows a title; `\"search\"` shows a search input. */\nexport type DropdownMenuHeaderType = \"default\" | \"search\";\n\n/** Header height preset. Matches the menu item sizing scale. */\nexport type DropdownMenuHeaderSize = \"40\" | \"32\";\n\n/** Search-input configuration for {@link DropdownMenuHeader} when `type=\"search\"`. */\nexport interface DropdownMenuHeaderSearchProps {\n /** Controlled value of the search input. */\n value?: string;\n /** Uncontrolled default value. */\n defaultValue?: string;\n /** Fires when the input value changes. */\n onChange?: (value: string) => void;\n /** Placeholder text shown when the input is empty. @default \"Search…\" */\n placeholder?: string;\n /** Accessible label for the search input. @default \"Search\" */\n \"aria-label\"?: string;\n /**\n * Focus the input as soon as the menu opens, so typing filters immediately.\n * Radix parks initial focus on the content element (which is what drives its\n * typeahead), so without this the first keystrokes never reach the input.\n */\n autoFocus?: boolean;\n}\n\nexport interface DropdownMenuHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Visual type. `\"default\"` shows a title; `\"search\"` shows a search input. @default \"default\" */\n type?: DropdownMenuHeaderType;\n /** Height preset for the header row. @default \"40\" */\n size?: DropdownMenuHeaderSize;\n /** Title text shown when `type=\"default\"`. Ignored if `children` is provided. */\n title?: string;\n /** Configuration for the embedded search input when `type=\"search\"`. */\n searchProps?: DropdownMenuHeaderSearchProps;\n /**\n * Action elements rendered at the end of the header row, before the close\n * button — e.g. icon buttons for search/add, or a primary \"Done\" button that\n * commits a {@link DropdownMenuReorderGroup} reorder. An action that should\n * close the menu needs the menu's `open` state controlled (only the built-in\n * close button can dismiss an uncontrolled menu).\n */\n actions?: React.ReactNode;\n /** Whether to render the close icon button on the right. @default true */\n showClose?: boolean;\n /** Fires when the close icon button is activated. */\n onClose?: () => void;\n /** Accessible label for the close button. @default \"Close menu\" */\n closeLabel?: string;\n /**\n * Fires when the back icon button at the start of the row is activated.\n * Rendering it lets a menu step back from a sub-view — a `type=\"search\"`\n * header returning to its title, for instance — without closing the menu.\n */\n onBack?: () => void;\n /** Whether to render the back icon button. @default `onBack !== undefined` */\n showBack?: boolean;\n /** Accessible label for the back button. @default \"Back\" */\n backLabel?: string;\n}\n\n/**\n * Optional header rendered at the top of a {@link DropdownMenuContent}. Use\n * `type=\"default\"` to title the menu, or `type=\"search\"` to embed a search\n * input for filtering long lists.\n *\n * Renders an inset separator beneath the row so it slots cleanly above the\n * first group of items.\n *\n * @example\n * ```tsx\n * <DropdownMenuContent>\n * <DropdownMenuHeader title=\"Sort by\" onClose={() => setOpen(false)} />\n * <DropdownMenuItem>Newest</DropdownMenuItem>\n * <DropdownMenuItem>Oldest</DropdownMenuItem>\n * </DropdownMenuContent>\n * ```\n */\nexport const DropdownMenuHeader = React.forwardRef<HTMLDivElement, DropdownMenuHeaderProps>(\n (\n {\n type = \"default\",\n size = \"40\",\n title,\n searchProps,\n actions,\n showClose = true,\n onClose,\n closeLabel = \"Close menu\",\n onBack,\n showBack = onBack !== undefined,\n backLabel = \"Back\",\n className,\n children,\n ...props\n },\n ref,\n ) => {\n // Regular, not semibold: `V2 Menu Header` titles the menu at\n // `Body Default 16px/Regular`. The weight belongs to the rows' own titles,\n // which is where the two-line layout puts a semibold.\n const titleTypography =\n size === \"32\" ? \"typography-body-small-14px-regular\" : \"typography-body-default-16px-regular\";\n const toggleOpen = React.useContext(ToggleOpenContext);\n const variant = React.useContext(DropdownMenuVariantContext);\n\n const handleClose = () => {\n onClose?.();\n // Also dismiss the Radix menu when used in uncontrolled mode — otherwise\n // the close button would look broken to consumers that don't wire up\n // `open` / `onOpenChange` themselves.\n toggleOpen?.(() => false);\n };\n\n return (\n <div\n ref={ref}\n className={cn(\n \"mb-1 flex flex-col px-1 pt-1\",\n // Search needs an 8px gap between the input and the divider; the\n // default (title) variant uses 4px because the title baseline sits\n // closer to the divider naturally.\n type === \"search\" ? \"gap-2\" : \"gap-1\",\n // With action buttons the design draws a roomier header: 12px above\n // the 32px actions row (the panel's own 4px padding makes up the\n // difference), 8px between it and the divider, and 8px between the\n // divider and the first row.\n actions != null && \"mb-2 gap-2 pt-2\",\n // The sheet is a taller, roomier surface than a trigger-anchored panel:\n // the design sets 16px between the rule and the first row, which this\n // margin plus the panel's own 4px gap adds up to.\n variant === \"sheet\" && \"mb-3\",\n className,\n )}\n {...props}\n >\n {/*\n * The title is inset a further 8px so it clears the panel's rounded\n * corner; the search input is not, because the design runs it to the\n * header's own padding (`V2 Menu Dropdown` node `7393:62008`: the search\n * row is `flex gap-16 w-full` with no inset, so the field sits 8px from\n * the panel edge on both sides). Insetting it left-only left the field\n * 16px in on the left and 8px on the right.\n */}\n <div\n className={cn(\n \"flex items-center gap-4\",\n // With action buttons the title sits a further 4px in (20px from\n // the panel edge) than the close-only header's 16px. A back button\n // supplies its own inset.\n type === \"default\" && !showBack && (actions != null ? \"pl-3\" : \"pl-2\"),\n )}\n >\n {showBack && (\n <div data-dropdown-menu-tab-stops=\"\" className=\"flex shrink-0 items-center\">\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<ArrowLeftIcon />}\n onClick={onBack}\n aria-label={backLabel}\n />\n </div>\n )}\n {type === \"default\" ? (\n <div className={cn(\"min-w-0 flex-1 truncate text-content-primary\", titleTypography)}>\n {children ?? title}\n </div>\n ) : (\n <SearchInput {...searchProps} />\n )}\n {(actions != null || showClose) && (\n // The extra right margin only applies with action buttons: filled\n // actions like a \"Done\" pill sit 12px off the panel edge, while the\n // bare tertiary close icon keeps the header's own 8px inset.\n <div\n data-dropdown-menu-tab-stops=\"\"\n className={cn(\"flex shrink-0 items-center gap-1\", actions != null && \"mr-1\")}\n >\n {actions}\n {showClose && (\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<CloseIcon />}\n onClick={handleClose}\n aria-label={closeLabel}\n />\n )}\n </div>\n )}\n </div>\n {/*\n * Full-bleed, as the design draws it: the rule runs the panel's whole\n * width rather than stopping at the text. `-mx-2` cancels both insets it\n * sits inside — this header's own `px-1` and the content panel's `p-1`.\n *\n * `Border/Primary` is the token the design binds to this rule. The\n * separator's own default is `neutral-alphas-200`, which in the dark theme\n * is a 20% *white* alpha — as a hairline running the full width it reads as\n * a white line rather than a divider. Group separators between items keep\n * the alpha; this is the header's rule only.\n */}\n <DropdownMenuSeparator className=\"-mx-2 my-0 bg-border-primary\" />\n </div>\n );\n },\n);\nDropdownMenuHeader.displayName = \"DropdownMenuHeader\";\n\nfunction SearchInput({\n value,\n defaultValue,\n onChange,\n placeholder = \"Search\\u2026\",\n \"aria-label\": ariaLabel = \"Search\",\n autoFocus,\n}: DropdownMenuHeaderSearchProps = {}) {\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n // Focus after mount rather than via the `autoFocus` attribute, so the focus\n // move is explicit and only happens when the consumer asked for it.\n React.useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n return (\n <label\n data-dropdown-menu-tab-stops=\"\"\n className={cn(\n \"flex min-w-0 flex-1 items-center gap-2 rounded-xs border border-border-primary\",\n \"bg-inputs-inputs-primary px-3 py-1 text-content-primary\",\n \"focus-within:shadow-focus-ring focus-within:outline-none\",\n )}\n >\n <SearchIcon className=\"size-4 shrink-0 text-content-primary\" aria-hidden=\"true\" />\n <input\n type=\"search\"\n className={cn(\n \"typography-body-default-16px-regular min-w-0 flex-1 bg-transparent outline-none\",\n \"placeholder:text-content-tertiary\",\n )}\n ref={inputRef}\n value={value}\n defaultValue={defaultValue}\n placeholder={placeholder}\n aria-label={ariaLabel}\n onChange={(event) => onChange?.(event.target.value)}\n // Radix DropdownMenu listens for keystrokes on Content for its\n // typeahead (typing letters jumps focus to a matching item). That\n // listener steals focus from the input after the first letter, so we\n // stop character keys from bubbling. Navigation keys (arrows / Tab /\n // Escape / Enter) are still allowed through so the user can leave the\n // input for the list or close the menu. Pointer events are stopped so\n // clicking back into the input doesn't fight the menu's focus\n // management either.\n onKeyDown={(event) => {\n if (!NAVIGATION_KEYS.has(event.key)) event.stopPropagation();\n }}\n onPointerDown={(event) => event.stopPropagation()}\n onMouseDown={(event) => event.stopPropagation()}\n />\n </label>\n );\n}\n"],"names":["React","ToggleOpenContext","DropdownMenuVariantContext","jsxs","cn","jsx","IconButton","ArrowLeftIcon","CloseIcon","DropdownMenuSeparator","SearchIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,sCAAsB,IAAI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAC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F,UAAA;AAAA,QAAAC,2BAAAA,IAACK,WAAAA,YAAA,EAAW,WAAU,wCAAuC,eAAY,QAAO;AAAA,QAChFL,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAWD,GAAAA;AAAAA,cACT;AAAA,cACA;AAAA,YAAA;AAAA,YAEF,KAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA,cAAY;AAAA,YACZ,UAAU,CAAC,UAAU,WAAW,MAAM,OAAO,KAAK;AAAA,YASlD,WAAW,CAAC,UAAU;AACpB,kBAAI,CAAC,gBAAgB,IAAI,MAAM,GAAG,SAAS,gBAAA;AAAA,YAC7C;AAAA,YACA,eAAe,CAAC,UAAU,MAAM,gBAAA;AAAA,YAChC,aAAa,CAAC,UAAU,MAAM,gBAAA;AAAA,UAAgB;AAAA,QAAA;AAAA,MAChD;AAAA,IAAA;AAAA,EAAA;AAGN;;"}
|
|
@@ -33,6 +33,7 @@ const SearchField = React__namespace.forwardRef(
|
|
|
33
33
|
minChars,
|
|
34
34
|
onChange,
|
|
35
35
|
clearAriaLabel = "Clear search",
|
|
36
|
+
size = "48",
|
|
36
37
|
...props
|
|
37
38
|
}, ref) => {
|
|
38
39
|
const [internalValue, setInternalValue] = React__namespace.useState(value ?? "");
|
|
@@ -73,7 +74,8 @@ const SearchField = React__namespace.forwardRef(
|
|
|
73
74
|
onClear?.();
|
|
74
75
|
}, [onClear]);
|
|
75
76
|
const displayValue = debounceMs || minChars ? internalValue : value;
|
|
76
|
-
const
|
|
77
|
+
const isCompact = size === "32";
|
|
78
|
+
const leftIcon = /* @__PURE__ */ jsxRuntime.jsx(SearchIcon.SearchIcon, { size: isCompact ? 16 : 24 });
|
|
77
79
|
const showClearButton = onClear && displayValue !== void 0 && displayValue !== "";
|
|
78
80
|
const rightIcon = showClearButton ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
79
81
|
IconButton.IconButton,
|
|
@@ -91,8 +93,10 @@ const SearchField = React__namespace.forwardRef(
|
|
|
91
93
|
{
|
|
92
94
|
ref,
|
|
93
95
|
type: "search",
|
|
96
|
+
size,
|
|
94
97
|
disabled,
|
|
95
98
|
leftIcon,
|
|
99
|
+
leftIconSize: isCompact ? "16" : "24",
|
|
96
100
|
rightIcon,
|
|
97
101
|
value: displayValue,
|
|
98
102
|
onChange: handleChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchField.cjs","sources":["../../../../src/components/SearchField/SearchField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { SearchIcon } from \"../Icons/SearchIcon\";\nimport { TextField, type TextFieldProps } from \"../TextField/TextField\";\n\nexport type SearchFieldSize = \"48\" | \"40\" | \"32\";\n\nexport interface SearchFieldProps
|
|
1
|
+
{"version":3,"file":"SearchField.cjs","sources":["../../../../src/components/SearchField/SearchField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { SearchIcon } from \"../Icons/SearchIcon\";\nimport { TextField, type TextFieldProps } from \"../TextField/TextField\";\n\nexport type SearchFieldSize = \"48\" | \"40\" | \"32\";\n\nexport interface SearchFieldProps\n extends Omit<TextFieldProps, \"type\" | \"leftIcon\" | \"leftIconSize\"> {\n /** Size variant of the search field. @default \"48\" */\n size?: SearchFieldSize;\n /** Callback fired when the clear button is clicked. If provided, a clear button appears when the field has a value. */\n onClear?: () => void;\n /** Debounce delay in milliseconds for the onChange callback. When set, the input maintains internal state for responsive typing while debouncing onChange to the parent. */\n debounceMs?: number;\n /** Minimum number of characters required before onChange fires. The input still updates visually, but onChange is suppressed until the threshold is met. Clearing always fires onClear regardless. */\n minChars?: number;\n /** Accessible name for the clear button. @default \"Clear search\" */\n clearAriaLabel?: string;\n}\n\n/**\n * A text input field with a search icon and optional clear button.\n *\n * @example\n * ```tsx\n * <SearchField\n * placeholder=\"Search...\"\n * value={query}\n * onChange={(e) => setQuery(e.target.value)}\n * onClear={() => setQuery(\"\")}\n * debounceMs={500}\n * minChars={3}\n * />\n * ```\n */\nexport const SearchField = React.forwardRef<HTMLInputElement, SearchFieldProps>(\n (\n {\n disabled,\n onClear,\n value,\n debounceMs,\n minChars,\n onChange,\n clearAriaLabel = \"Clear search\",\n size = \"48\",\n ...props\n },\n ref,\n ) => {\n const [internalValue, setInternalValue] = React.useState(value ?? \"\");\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n\n React.useEffect(() => {\n if (value !== undefined) {\n setInternalValue(value);\n }\n }, [value]);\n\n React.useEffect(() => {\n return () => {\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n };\n }, []);\n\n const shouldFireChange = React.useCallback(\n (val: string) => !minChars || val.length >= minChars,\n [minChars],\n );\n\n const handleChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const val = e.target.value;\n\n if (!debounceMs) {\n setInternalValue(val);\n if (shouldFireChange(val)) onChange?.(e);\n return;\n }\n\n setInternalValue(val);\n\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n\n timeoutRef.current = setTimeout(() => {\n if (shouldFireChange(val)) onChange?.(e);\n }, debounceMs);\n },\n [debounceMs, onChange, shouldFireChange],\n );\n\n const handleClear = React.useCallback(() => {\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n setInternalValue(\"\");\n onClear?.();\n }, [onClear]);\n\n const displayValue = debounceMs || minChars ? internalValue : value;\n const isCompact = size === \"32\";\n const leftIcon = <SearchIcon size={isCompact ? 16 : 24} />;\n\n const showClearButton = onClear && displayValue !== undefined && displayValue !== \"\";\n\n const rightIcon = showClearButton ? (\n <IconButton\n variant=\"tertiary\"\n size=\"24\"\n icon={<CloseIcon />}\n aria-label={clearAriaLabel}\n disabled={disabled}\n onClick={handleClear}\n />\n ) : undefined;\n\n return (\n <TextField\n ref={ref}\n type=\"search\"\n size={size}\n disabled={disabled}\n leftIcon={leftIcon}\n leftIconSize={isCompact ? \"16\" : \"24\"}\n rightIcon={rightIcon}\n value={displayValue}\n onChange={handleChange}\n aria-label={!props.label ? \"Search field\" : undefined}\n {...props}\n />\n );\n },\n);\n\nSearchField.displayName = \"SearchField\";\n"],"names":["React","jsx","SearchIcon","IconButton","CloseIcon","TextField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,cAAcA,iBAAM;AAAA,EAC/B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB,OAAO;AAAA,IACP,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,CAAC,eAAe,gBAAgB,IAAIA,iBAAM,SAAS,SAAS,EAAE;AACpE,UAAM,aAAaA,iBAAM,OAAsC,MAAS;AAExEA,qBAAM,UAAU,MAAM;AACpB,UAAI,UAAU,QAAW;AACvB,yBAAiB,KAAK;AAAA,MACxB;AAAA,IACF,GAAG,CAAC,KAAK,CAAC;AAEVA,qBAAM,UAAU,MAAM;AACpB,aAAO,MAAM;AACX,YAAI,WAAW,QAAS,cAAa,WAAW,OAAO;AAAA,MACzD;AAAA,IACF,GAAG,CAAA,CAAE;AAEL,UAAM,mBAAmBA,iBAAM;AAAA,MAC7B,CAAC,QAAgB,CAAC,YAAY,IAAI,UAAU;AAAA,MAC5C,CAAC,QAAQ;AAAA,IAAA;AAGX,UAAM,eAAeA,iBAAM;AAAA,MACzB,CAAC,MAA2C;AAC1C,cAAM,MAAM,EAAE,OAAO;AAErB,YAAI,CAAC,YAAY;AACf,2BAAiB,GAAG;AACpB,cAAI,iBAAiB,GAAG,EAAG,YAAW,CAAC;AACvC;AAAA,QACF;AAEA,yBAAiB,GAAG;AAEpB,YAAI,WAAW,QAAS,cAAa,WAAW,OAAO;AAEvD,mBAAW,UAAU,WAAW,MAAM;AACpC,cAAI,iBAAiB,GAAG,EAAG,YAAW,CAAC;AAAA,QACzC,GAAG,UAAU;AAAA,MACf;AAAA,MACA,CAAC,YAAY,UAAU,gBAAgB;AAAA,IAAA;AAGzC,UAAM,cAAcA,iBAAM,YAAY,MAAM;AAC1C,UAAI,WAAW,QAAS,cAAa,WAAW,OAAO;AACvD,uBAAiB,EAAE;AACnB,gBAAA;AAAA,IACF,GAAG,CAAC,OAAO,CAAC;AAEZ,UAAM,eAAe,cAAc,WAAW,gBAAgB;AAC9D,UAAM,YAAY,SAAS;AAC3B,UAAM,WAAWC,2BAAAA,IAACC,uBAAA,EAAW,MAAM,YAAY,KAAK,IAAI;AAExD,UAAM,kBAAkB,WAAW,iBAAiB,UAAa,iBAAiB;AAElF,UAAM,YAAY,kBAChBD,2BAAAA;AAAAA,MAACE,WAAAA;AAAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,qCAAOC,UAAAA,WAAA,EAAU;AAAA,QACjB,cAAY;AAAA,QACZ;AAAA,QACA,SAAS;AAAA,MAAA;AAAA,IAAA,IAET;AAEJ,WACEH,2BAAAA;AAAAA,MAACI,UAAAA;AAAAA,MAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,YAAY,OAAO;AAAA,QACjC;AAAA,QACA,OAAO;AAAA,QACP,UAAU;AAAA,QACV,cAAY,CAAC,MAAM,QAAQ,iBAAiB;AAAA,QAC3C,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AAEA,YAAY,cAAc;;"}
|
|
@@ -64,9 +64,21 @@ function getContainerClassName(size, error, disabled, hasAction) {
|
|
|
64
64
|
disabled && "opacity-50"
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
function LeadingIcon({
|
|
67
|
+
function LeadingIcon({
|
|
68
|
+
size = "16",
|
|
69
|
+
children
|
|
70
|
+
}) {
|
|
68
71
|
if (!children) return null;
|
|
69
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
72
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
73
|
+
"span",
|
|
74
|
+
{
|
|
75
|
+
className: cn.cn(
|
|
76
|
+
"pointer-events-none flex shrink-0 items-center justify-center text-content-secondary",
|
|
77
|
+
size === "24" ? "size-6" : "size-4"
|
|
78
|
+
),
|
|
79
|
+
children
|
|
80
|
+
}
|
|
81
|
+
);
|
|
70
82
|
}
|
|
71
83
|
function SideLabel({
|
|
72
84
|
id,
|
|
@@ -133,6 +145,7 @@ const TextField = React__namespace.forwardRef(
|
|
|
133
145
|
errorMessage,
|
|
134
146
|
validated = false,
|
|
135
147
|
leftIcon,
|
|
148
|
+
leftIconSize,
|
|
136
149
|
rightIcon,
|
|
137
150
|
leftLabel,
|
|
138
151
|
rightLabel,
|
|
@@ -193,7 +206,7 @@ const TextField = React__namespace.forwardRef(
|
|
|
193
206
|
className: getContainerClassName(size, error, disabled, action != null),
|
|
194
207
|
onMouseDown: handleContainerMouseDown,
|
|
195
208
|
children: [
|
|
196
|
-
/* @__PURE__ */ jsxRuntime.jsx(LeadingIcon, { children: leftIcon }),
|
|
209
|
+
/* @__PURE__ */ jsxRuntime.jsx(LeadingIcon, { size: leftIconSize, children: leftIcon }),
|
|
197
210
|
/* @__PURE__ */ jsxRuntime.jsx(SideLabel, { id: leftLabelId, size, align: "left", children: leftLabel }),
|
|
198
211
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
199
212
|
"input",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.cjs","sources":["../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { CheckOutlineIcon } from \"@/index\";\nimport { cn } from \"../../utils/cn\";\n\n/** Text field height in pixels. */\nexport type TextFieldSize = \"48\" | \"40\" | \"32\";\n\nexport interface TextFieldProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n /** Label text displayed above the input. Also used as the accessible name. */\n label?: string;\n /** Helper text displayed below the input. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Height of the text field in pixels. @default \"48\" */\n size?: TextFieldSize;\n /** Whether the text field is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the input. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Whether the text field is validated. @default false */\n validated?: boolean;\n /** Icon element displayed at the left side of the input. */\n leftIcon?: React.ReactNode;\n /** Icon element displayed at the right side of the input. */\n rightIcon?: React.ReactNode;\n /** Fixed, non-editable label pinned inside the left edge of the field — for a prefix such as a currency symbol or country code. */\n leftLabel?: React.ReactNode;\n /** Fixed, non-editable label pinned inside the right edge of the field — for a unit or suffix such as a currency code or domain. */\n rightLabel?: React.ReactNode;\n /**\n * Trailing interactive element pinned to the right edge — typically a `Chip`\n * or `Button` (the \"with button\" field type). Reduces the right padding so the\n * control sits flush, and clicks on it do not steal focus from the input.\n */\n action?: React.ReactNode;\n /** Whether the text field stretches to fill its container width. @default false */\n fullWidth?: boolean;\n}\n\nconst CONTAINER_HEIGHT: Record<TextFieldSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst CONTAINER_PADDING_X: Record<TextFieldSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst CONTAINER_PADDING_X_WITH_ACTION: Record<TextFieldSize, string> = {\n \"48\": \"pl-4 pr-2\",\n \"40\": \"pl-4 pr-2\",\n \"32\": \"pl-3 pr-2\",\n};\n\nconst CONTAINER_GAP: Record<TextFieldSize, string> = {\n \"48\": \"gap-2.5\",\n \"40\": \"gap-2.5\",\n \"32\": \"gap-2\",\n};\n\nconst INPUT_TYPOGRAPHY: Record<TextFieldSize, string> = {\n \"48\": \"typography-body-default-16px-regular autofill-body-lg\",\n \"40\": \"typography-body-default-16px-regular autofill-body-lg\",\n \"32\": \"typography-body-small-14px-regular autofill-body-md\",\n};\n\nconst SIDE_LABEL_TYPOGRAPHY: Record<TextFieldSize, string> = {\n \"48\": \"typography-body-default-16px-regular\",\n \"40\": \"typography-body-default-16px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nfunction getContainerClassName(\n size: TextFieldSize,\n error: boolean,\n disabled?: boolean,\n hasAction?: boolean,\n) {\n return cn(\n \"relative flex items-center overflow-hidden rounded-sm border bg-inputs-inputs-primary after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] has-focus-visible:outline-none has-focus-visible:after:shadow-focus-ring motion-safe:transition-colors\",\n hasAction ? CONTAINER_PADDING_X_WITH_ACTION[size] : CONTAINER_PADDING_X[size],\n CONTAINER_GAP[size],\n error ? \"border-error-content\" : \"border-border-primary\",\n !disabled && !error && \"hover:border-neutral-alphas-400\",\n CONTAINER_HEIGHT[size],\n disabled && \"opacity-50\",\n );\n}\n\nfunction LeadingIcon({ children }: { children?: React.ReactNode }) {\n if (!children) return null;\n return (\n <span className=\"pointer-events-none flex size-4 shrink-0 items-center justify-center text-content-secondary\">\n {children}\n </span>\n );\n}\n\nfunction SideLabel({\n id,\n size,\n align,\n children,\n}: {\n id?: string;\n size: TextFieldSize;\n align: \"left\" | \"right\";\n children?: React.ReactNode;\n}) {\n if (!children) return null;\n return (\n <span\n id={id}\n className={cn(\n \"shrink-0 select-none whitespace-nowrap text-content-tertiary\",\n align === \"right\" && \"text-right\",\n SIDE_LABEL_TYPOGRAPHY[size],\n )}\n >\n {children}\n </span>\n );\n}\n\nfunction TrailingAdornment({\n rightIcon,\n validated,\n}: {\n rightIcon?: React.ReactNode;\n validated: boolean;\n}) {\n if (!rightIcon && !validated) return null;\n return (\n <span className=\"flex shrink-0 items-center gap-2 text-content-secondary\">\n {rightIcon && (\n <span data-tf-interactive=\"\" className=\"flex size-4 shrink-0 items-center justify-center\">\n {rightIcon}\n </span>\n )}\n {validated && (\n <span className=\"pointer-events-none flex size-4 shrink-0 items-center justify-center\">\n <CheckOutlineIcon className=\"text-success-content\" />\n </span>\n )}\n </span>\n );\n}\n\nfunction TextFieldHelperText({\n id,\n error,\n children,\n}: {\n id: string;\n error: boolean;\n children: React.ReactNode;\n}) {\n return (\n <p\n id={id}\n className={cn(\n \"typography-description-12px-regular pt-2\",\n error ? \"text-error-content\" : \"text-content-tertiary\",\n )}\n >\n {children}\n </p>\n );\n}\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"TextField: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\n/**\n * A text input field with optional label, helper/error text, icon slots, and side labels.\n *\n * Use `leftLabel` / `rightLabel` for fixed unit or prefix affordances (currency symbol,\n * country code, domain suffix). Provide at least one of `label`, `aria-label`, or\n * `aria-labelledby` for accessibility — a console warning is emitted in development if none are set.\n *\n * @example\n * ```tsx\n * <TextField\n * label=\"Email\"\n * placeholder=\"you@example.com\"\n * error={!!emailError}\n * errorMessage={emailError}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <TextField label=\"Price\" leftLabel=\"$\" rightLabel=\"USD\" placeholder=\"0.00\" />\n * ```\n *\n * @example\n * ```tsx\n * <TextField\n * label=\"Promo code\"\n * placeholder=\"Enter code\"\n * action={<Chip size=\"32\" onClick={apply}>Apply</Chip>}\n * />\n * ```\n */\nexport const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n validated = false,\n leftIcon,\n rightIcon,\n leftLabel,\n rightLabel,\n action,\n className,\n id,\n disabled,\n fullWidth = false,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id || generatedId;\n const helperTextId = `${inputId}-helper`;\n const leftLabelId = `${inputId}-left-label`;\n const rightLabelId = `${inputId}-right-label`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n const describedBy =\n [\n leftLabel != null ? leftLabelId : null,\n rightLabel != null ? rightLabelId : null,\n bottomText ? helperTextId : null,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n const innerRef = React.useRef<HTMLInputElement>(null);\n const setRefs = React.useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n },\n [ref],\n );\n\n // Keep clicks on the non-interactive adornments (icons, side labels, padding)\n // focusing the input, matching the old absolute/pointer-events-none layout.\n const handleContainerMouseDown = (event: React.MouseEvent<HTMLDivElement>) => {\n if (disabled) return;\n const target = event.target as HTMLElement;\n if (target === innerRef.current) return;\n if (target.closest(\"[data-tf-interactive]\")) return;\n event.preventDefault();\n innerRef.current?.focus();\n };\n\n warnMissingAccessibleName(label, props[\"aria-label\"], props[\"aria-labelledby\"]);\n\n return (\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={inputId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n {/* biome-ignore lint/a11y/noStaticElementInteractions: focus bridge delegates pointer clicks on adornments to the input */}\n <div\n className={getContainerClassName(size, error, disabled, action != null)}\n onMouseDown={handleContainerMouseDown}\n >\n <LeadingIcon>{leftIcon}</LeadingIcon>\n <SideLabel id={leftLabelId} size={size} align=\"left\">\n {leftLabel}\n </SideLabel>\n\n <input\n ref={setRefs}\n id={inputId}\n disabled={disabled}\n aria-describedby={describedBy}\n aria-invalid={error || undefined}\n className={cn(\n \"h-full min-w-0 flex-1 bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed\",\n INPUT_TYPOGRAPHY[size],\n \"[&[type='search']::-webkit-search-cancel-button]:hidden [&[type='search']::-webkit-search-cancel-button]:appearance-none\",\n )}\n {...props}\n />\n\n <SideLabel id={rightLabelId} size={size} align=\"right\">\n {rightLabel}\n </SideLabel>\n <TrailingAdornment rightIcon={rightIcon} validated={validated} />\n {action != null && (\n <span data-tf-interactive=\"\" className=\"flex shrink-0 items-center\">\n {action}\n </span>\n )}\n </div>\n\n {bottomText && (\n <TextFieldHelperText id={helperTextId} error={error}>\n {bottomText}\n </TextFieldHelperText>\n )}\n </div>\n );\n },\n);\n\nTextField.displayName = \"TextField\";\n"],"names":["cn","jsx","jsxs","CheckOutlineIcon","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,mBAAkD;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,sBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,kCAAiE;AAAA,EACrE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,gBAA+C;AAAA,EACnD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,mBAAkD;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,wBAAuD;AAAA,EAC3D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,SAAS,sBACP,MACA,OACA,UACA,WACA;AACA,SAAOA,GAAAA;AAAAA,IACL;AAAA,IACA,YAAY,gCAAgC,IAAI,IAAI,oBAAoB,IAAI;AAAA,IAC5E,cAAc,IAAI;AAAA,IAClB,QAAQ,yBAAyB;AAAA,IACjC,CAAC,YAAY,CAAC,SAAS;AAAA,IACvB,iBAAiB,IAAI;AAAA,IACrB,YAAY;AAAA,EAAA;AAEhB;AAEA,SAAS,YAAY,EAAE,YAA4C;AACjE,MAAI,CAAC,SAAU,QAAO;AACtB,SACEC,2BAAAA,IAAC,QAAA,EAAK,WAAU,+FACb,SAAA,CACH;AAEJ;AA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SAAS;AAAA,cACT,WAAU;AAAA,cAET,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAKLC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,sBAAsB,MAAM,OAAO,UAAU,UAAU,IAAI;AAAA,cACtE,aAAa;AAAA,cAEb,UAAA;AAAA,gBAAAD,2BAAAA,IAAC,eAAa,UAAA,SAAA,CAAS;AAAA,+CACtB,WAAA,EAAU,IAAI,aAAa,MAAY,OAAM,QAC3C,UAAA,WACH;AAAA,gBAEAA,2BAAAA;AAAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,KAAK;AAAA,oBACL,IAAI;AAAA,oBACJ;AAAA,oBACA,oBAAkB;AAAA,oBAClB,gBAAc,SAAS;AAAA,oBACvB,WAAWD,GAAAA;AAAAA,sBACT;AAAA,sBACA,iBAAiB,IAAI;AAAA,sBACrB;AAAA,oBAAA;AAAA,oBAED,GAAG;AAAA,kBAAA;AAAA,gBAAA;AAAA,+CAGL,WAAA,EAAU,IAAI,cAAc,MAAY,OAAM,SAC5C,UAAA,YACH;AAAA,gBACAC,2BAAAA,IAAC,mBAAA,EAAkB,WAAsB,UAAA,CAAsB;AAAA,gBAC9D,UAAU,QACTA,+BAAC,QAAA,EAAK,uBAAoB,IAAG,WAAU,8BACpC,UAAA,OAAA,CACH;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAIH,cACCA,2BAAAA,IAAC,qBAAA,EAAoB,IAAI,cAAc,OACpC,UAAA,WAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,UAAU,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"TextField.cjs","sources":["../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { CheckOutlineIcon } from \"@/index\";\nimport { cn } from \"../../utils/cn\";\n\n/** Text field height in pixels. */\nexport type TextFieldSize = \"48\" | \"40\" | \"32\";\n\nexport interface TextFieldProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n /** Label text displayed above the input. Also used as the accessible name. */\n label?: string;\n /** Helper text displayed below the input. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Height of the text field in pixels. @default \"48\" */\n size?: TextFieldSize;\n /** Whether the text field is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the input. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Whether the text field is validated. @default false */\n validated?: boolean;\n /** Icon element displayed at the left side of the input. */\n leftIcon?: React.ReactNode;\n /** Size in pixels of the slot that holds `leftIcon`. @default \"16\" */\n leftIconSize?: \"16\" | \"24\";\n /** Icon element displayed at the right side of the input. */\n rightIcon?: React.ReactNode;\n /** Fixed, non-editable label pinned inside the left edge of the field — for a prefix such as a currency symbol or country code. */\n leftLabel?: React.ReactNode;\n /** Fixed, non-editable label pinned inside the right edge of the field — for a unit or suffix such as a currency code or domain. */\n rightLabel?: React.ReactNode;\n /**\n * Trailing interactive element pinned to the right edge — typically a `Chip`\n * or `Button` (the \"with button\" field type). Reduces the right padding so the\n * control sits flush, and clicks on it do not steal focus from the input.\n */\n action?: React.ReactNode;\n /** Whether the text field stretches to fill its container width. @default false */\n fullWidth?: boolean;\n}\n\nconst CONTAINER_HEIGHT: Record<TextFieldSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst CONTAINER_PADDING_X: Record<TextFieldSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst CONTAINER_PADDING_X_WITH_ACTION: Record<TextFieldSize, string> = {\n \"48\": \"pl-4 pr-2\",\n \"40\": \"pl-4 pr-2\",\n \"32\": \"pl-3 pr-2\",\n};\n\nconst CONTAINER_GAP: Record<TextFieldSize, string> = {\n \"48\": \"gap-2.5\",\n \"40\": \"gap-2.5\",\n \"32\": \"gap-2\",\n};\n\nconst INPUT_TYPOGRAPHY: Record<TextFieldSize, string> = {\n \"48\": \"typography-body-default-16px-regular autofill-body-lg\",\n \"40\": \"typography-body-default-16px-regular autofill-body-lg\",\n \"32\": \"typography-body-small-14px-regular autofill-body-md\",\n};\n\nconst SIDE_LABEL_TYPOGRAPHY: Record<TextFieldSize, string> = {\n \"48\": \"typography-body-default-16px-regular\",\n \"40\": \"typography-body-default-16px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nfunction getContainerClassName(\n size: TextFieldSize,\n error: boolean,\n disabled?: boolean,\n hasAction?: boolean,\n) {\n return cn(\n \"relative flex items-center overflow-hidden rounded-sm border bg-inputs-inputs-primary after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] has-focus-visible:outline-none has-focus-visible:after:shadow-focus-ring motion-safe:transition-colors\",\n hasAction ? CONTAINER_PADDING_X_WITH_ACTION[size] : CONTAINER_PADDING_X[size],\n CONTAINER_GAP[size],\n error ? \"border-error-content\" : \"border-border-primary\",\n !disabled && !error && \"hover:border-neutral-alphas-400\",\n CONTAINER_HEIGHT[size],\n disabled && \"opacity-50\",\n );\n}\n\nfunction LeadingIcon({\n size = \"16\",\n children,\n}: {\n size?: \"16\" | \"24\";\n children?: React.ReactNode;\n}) {\n if (!children) return null;\n return (\n <span\n className={cn(\n \"pointer-events-none flex shrink-0 items-center justify-center text-content-secondary\",\n size === \"24\" ? \"size-6\" : \"size-4\",\n )}\n >\n {children}\n </span>\n );\n}\n\nfunction SideLabel({\n id,\n size,\n align,\n children,\n}: {\n id?: string;\n size: TextFieldSize;\n align: \"left\" | \"right\";\n children?: React.ReactNode;\n}) {\n if (!children) return null;\n return (\n <span\n id={id}\n className={cn(\n \"shrink-0 select-none whitespace-nowrap text-content-tertiary\",\n align === \"right\" && \"text-right\",\n SIDE_LABEL_TYPOGRAPHY[size],\n )}\n >\n {children}\n </span>\n );\n}\n\nfunction TrailingAdornment({\n rightIcon,\n validated,\n}: {\n rightIcon?: React.ReactNode;\n validated: boolean;\n}) {\n if (!rightIcon && !validated) return null;\n return (\n <span className=\"flex shrink-0 items-center gap-2 text-content-secondary\">\n {rightIcon && (\n <span data-tf-interactive=\"\" className=\"flex size-4 shrink-0 items-center justify-center\">\n {rightIcon}\n </span>\n )}\n {validated && (\n <span className=\"pointer-events-none flex size-4 shrink-0 items-center justify-center\">\n <CheckOutlineIcon className=\"text-success-content\" />\n </span>\n )}\n </span>\n );\n}\n\nfunction TextFieldHelperText({\n id,\n error,\n children,\n}: {\n id: string;\n error: boolean;\n children: React.ReactNode;\n}) {\n return (\n <p\n id={id}\n className={cn(\n \"typography-description-12px-regular pt-2\",\n error ? \"text-error-content\" : \"text-content-tertiary\",\n )}\n >\n {children}\n </p>\n );\n}\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"TextField: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\n/**\n * A text input field with optional label, helper/error text, icon slots, and side labels.\n *\n * Use `leftLabel` / `rightLabel` for fixed unit or prefix affordances (currency symbol,\n * country code, domain suffix). Provide at least one of `label`, `aria-label`, or\n * `aria-labelledby` for accessibility — a console warning is emitted in development if none are set.\n *\n * @example\n * ```tsx\n * <TextField\n * label=\"Email\"\n * placeholder=\"you@example.com\"\n * error={!!emailError}\n * errorMessage={emailError}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <TextField label=\"Price\" leftLabel=\"$\" rightLabel=\"USD\" placeholder=\"0.00\" />\n * ```\n *\n * @example\n * ```tsx\n * <TextField\n * label=\"Promo code\"\n * placeholder=\"Enter code\"\n * action={<Chip size=\"32\" onClick={apply}>Apply</Chip>}\n * />\n * ```\n */\nexport const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n validated = false,\n leftIcon,\n leftIconSize,\n rightIcon,\n leftLabel,\n rightLabel,\n action,\n className,\n id,\n disabled,\n fullWidth = false,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id || generatedId;\n const helperTextId = `${inputId}-helper`;\n const leftLabelId = `${inputId}-left-label`;\n const rightLabelId = `${inputId}-right-label`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n const describedBy =\n [\n leftLabel != null ? leftLabelId : null,\n rightLabel != null ? rightLabelId : null,\n bottomText ? helperTextId : null,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n const innerRef = React.useRef<HTMLInputElement>(null);\n const setRefs = React.useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n },\n [ref],\n );\n\n // Keep clicks on the non-interactive adornments (icons, side labels, padding)\n // focusing the input, matching the old absolute/pointer-events-none layout.\n const handleContainerMouseDown = (event: React.MouseEvent<HTMLDivElement>) => {\n if (disabled) return;\n const target = event.target as HTMLElement;\n if (target === innerRef.current) return;\n if (target.closest(\"[data-tf-interactive]\")) return;\n event.preventDefault();\n innerRef.current?.focus();\n };\n\n warnMissingAccessibleName(label, props[\"aria-label\"], props[\"aria-labelledby\"]);\n\n return (\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={inputId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n {/* biome-ignore lint/a11y/noStaticElementInteractions: focus bridge delegates pointer clicks on adornments to the input */}\n <div\n className={getContainerClassName(size, error, disabled, action != null)}\n onMouseDown={handleContainerMouseDown}\n >\n <LeadingIcon size={leftIconSize}>{leftIcon}</LeadingIcon>\n <SideLabel id={leftLabelId} size={size} align=\"left\">\n {leftLabel}\n </SideLabel>\n\n <input\n ref={setRefs}\n id={inputId}\n disabled={disabled}\n aria-describedby={describedBy}\n aria-invalid={error || undefined}\n className={cn(\n \"h-full min-w-0 flex-1 bg-transparent text-content-primary no-underline placeholder:text-content-tertiary focus:outline-none disabled:cursor-not-allowed\",\n INPUT_TYPOGRAPHY[size],\n \"[&[type='search']::-webkit-search-cancel-button]:hidden [&[type='search']::-webkit-search-cancel-button]:appearance-none\",\n )}\n {...props}\n />\n\n <SideLabel id={rightLabelId} size={size} align=\"right\">\n {rightLabel}\n </SideLabel>\n <TrailingAdornment rightIcon={rightIcon} validated={validated} />\n {action != null && (\n <span data-tf-interactive=\"\" className=\"flex shrink-0 items-center\">\n {action}\n </span>\n )}\n </div>\n\n {bottomText && (\n <TextFieldHelperText id={helperTextId} error={error}>\n {bottomText}\n </TextFieldHelperText>\n )}\n </div>\n );\n },\n);\n\nTextField.displayName = \"TextField\";\n"],"names":["cn","jsx","jsxs","CheckOutlineIcon","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,mBAAkD;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,sBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,kCAAiE;AAAA,EACrE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,gBAA+C;AAAA,EACnD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,mBAAkD;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,wBAAuD;AAAA,EAC3D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,SAAS,sBACP,MACA,OACA,UACA,WACA;AACA,SAAOA,GAAAA;AAAAA,IACL;AAAA,IACA,YAAY,gCAAgC,IAAI,IAAI,oBAAoB,IAAI;AAAA,IAC5E,cAAc,IAAI;AAAA,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AA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAIH,cACCA,2BAAAA,IAAC,qBAAA,EAAoB,IAAI,cAAc,OACpC,UAAA,WAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,UAAU,cAAc;;"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const usePrefersReducedMotion = require("./usePrefersReducedMotion.cjs");
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
23
|
+
const DRAG_START_THRESHOLD_PX = 8;
|
|
24
|
+
const DISMISS_DISTANCE_RATIO = 0.25;
|
|
25
|
+
const DISMISS_VELOCITY_PX_PER_MS = 0.5;
|
|
26
|
+
const FLICK_WINDOW_MS = 100;
|
|
27
|
+
const SNAP_BACK_TRANSITION = "transform 200ms ease-out";
|
|
28
|
+
const NON_DRAGGABLE_TARGETS = "input, textarea, select, [contenteditable='true']";
|
|
29
|
+
function shouldDismissDrag({
|
|
30
|
+
offset,
|
|
31
|
+
height,
|
|
32
|
+
velocity
|
|
33
|
+
}) {
|
|
34
|
+
if (offset <= 0) return false;
|
|
35
|
+
return offset >= height * DISMISS_DISTANCE_RATIO || velocity >= DISMISS_VELOCITY_PX_PER_MS;
|
|
36
|
+
}
|
|
37
|
+
function isScrolledAwayFromTop(target, container) {
|
|
38
|
+
let node = target instanceof HTMLElement ? target : null;
|
|
39
|
+
while (node && node !== container) {
|
|
40
|
+
if (node.scrollTop > 0) return true;
|
|
41
|
+
node = node.parentElement;
|
|
42
|
+
}
|
|
43
|
+
return container.scrollTop > 0;
|
|
44
|
+
}
|
|
45
|
+
function blockTouchScrollWhileDragging(element, getDrag) {
|
|
46
|
+
const onTouchMove = (event) => {
|
|
47
|
+
const drag = getDrag();
|
|
48
|
+
const touch = event.touches[0];
|
|
49
|
+
if (!drag || !touch) return;
|
|
50
|
+
const offset = touch.clientY - drag.startY;
|
|
51
|
+
if (drag.dragging || offset > Math.abs(touch.clientX - drag.startX)) event.preventDefault();
|
|
52
|
+
};
|
|
53
|
+
element.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
54
|
+
return () => element.removeEventListener("touchmove", onTouchMove);
|
|
55
|
+
}
|
|
56
|
+
function useDragToDismiss({ enabled, onDismiss, media }, props) {
|
|
57
|
+
const dragRef = React__namespace.useRef(null);
|
|
58
|
+
const prefersReducedMotion = usePrefersReducedMotion.usePrefersReducedMotion();
|
|
59
|
+
const snapBack = (element) => {
|
|
60
|
+
element.style.transition = prefersReducedMotion ? "" : SNAP_BACK_TRANSITION;
|
|
61
|
+
element.style.transform = "";
|
|
62
|
+
};
|
|
63
|
+
const release = (drag, dismiss) => {
|
|
64
|
+
dragRef.current = null;
|
|
65
|
+
drag.stopBlockingTouchScroll();
|
|
66
|
+
drag.element.releasePointerCapture?.(drag.pointerId);
|
|
67
|
+
if (!drag.dragging) return;
|
|
68
|
+
if (!dismiss) {
|
|
69
|
+
snapBack(drag.element);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
onDismiss();
|
|
73
|
+
requestAnimationFrame(() => {
|
|
74
|
+
if (drag.element.isConnected && drag.element.dataset.state !== "closed") {
|
|
75
|
+
snapBack(drag.element);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
...props,
|
|
81
|
+
onPointerDown(event) {
|
|
82
|
+
props.onPointerDown?.(event);
|
|
83
|
+
if (!enabled || event.defaultPrevented || event.button !== 0) return;
|
|
84
|
+
if (media && typeof window.matchMedia === "function" && !window.matchMedia(media).matches)
|
|
85
|
+
return;
|
|
86
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
87
|
+
if (target?.closest(NON_DRAGGABLE_TARGETS)) return;
|
|
88
|
+
if (isScrolledAwayFromTop(event.target, event.currentTarget)) return;
|
|
89
|
+
const element = event.currentTarget;
|
|
90
|
+
dragRef.current = {
|
|
91
|
+
pointerId: event.pointerId,
|
|
92
|
+
element,
|
|
93
|
+
startY: event.clientY,
|
|
94
|
+
startX: event.clientX,
|
|
95
|
+
lastY: event.clientY,
|
|
96
|
+
lastTime: event.timeStamp,
|
|
97
|
+
velocity: 0,
|
|
98
|
+
dragging: false,
|
|
99
|
+
stopBlockingTouchScroll: blockTouchScrollWhileDragging(element, () => dragRef.current)
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
onPointerMove(event) {
|
|
103
|
+
props.onPointerMove?.(event);
|
|
104
|
+
const drag = dragRef.current;
|
|
105
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
106
|
+
const offset = event.clientY - drag.startY;
|
|
107
|
+
if (!drag.dragging) {
|
|
108
|
+
const dx = Math.abs(event.clientX - drag.startX);
|
|
109
|
+
if (Math.max(Math.abs(offset), dx) < DRAG_START_THRESHOLD_PX) return;
|
|
110
|
+
if (offset <= dx) {
|
|
111
|
+
release(drag, false);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
drag.dragging = true;
|
|
115
|
+
drag.element.setPointerCapture?.(event.pointerId);
|
|
116
|
+
drag.element.style.transition = "none";
|
|
117
|
+
}
|
|
118
|
+
const elapsed = event.timeStamp - drag.lastTime;
|
|
119
|
+
if (elapsed > 0) drag.velocity = (event.clientY - drag.lastY) / elapsed;
|
|
120
|
+
drag.lastY = event.clientY;
|
|
121
|
+
drag.lastTime = event.timeStamp;
|
|
122
|
+
drag.element.style.transform = `translate3d(0, ${Math.max(offset, 0)}px, 0)`;
|
|
123
|
+
},
|
|
124
|
+
onPointerUp(event) {
|
|
125
|
+
props.onPointerUp?.(event);
|
|
126
|
+
const drag = dragRef.current;
|
|
127
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
128
|
+
const dismiss = shouldDismissDrag({
|
|
129
|
+
offset: event.clientY - drag.startY,
|
|
130
|
+
height: drag.element.getBoundingClientRect().height,
|
|
131
|
+
velocity: event.timeStamp - drag.lastTime > FLICK_WINDOW_MS ? 0 : drag.velocity
|
|
132
|
+
});
|
|
133
|
+
release(drag, dismiss);
|
|
134
|
+
},
|
|
135
|
+
onPointerCancel(event) {
|
|
136
|
+
props.onPointerCancel?.(event);
|
|
137
|
+
const drag = dragRef.current;
|
|
138
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
139
|
+
release(drag, false);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
exports.shouldDismissDrag = shouldDismissDrag;
|
|
144
|
+
exports.useDragToDismiss = useDragToDismiss;
|
|
145
|
+
//# sourceMappingURL=useDragToDismiss.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDragToDismiss.cjs","sources":["../../../src/utils/useDragToDismiss.ts"],"sourcesContent":["import * as React from \"react\";\nimport { usePrefersReducedMotion } from \"./usePrefersReducedMotion\";\n\nconst DRAG_START_THRESHOLD_PX = 8;\nconst DISMISS_DISTANCE_RATIO = 0.25;\nconst DISMISS_VELOCITY_PX_PER_MS = 0.5;\nconst FLICK_WINDOW_MS = 100;\nconst SNAP_BACK_TRANSITION = \"transform 200ms ease-out\";\nconst NON_DRAGGABLE_TARGETS = \"input, textarea, select, [contenteditable='true']\";\n\n/**\n * Whether a released sheet drag should dismiss the sheet: past a quarter of\n * the sheet's height, or a fast downward flick at any distance.\n */\nexport function shouldDismissDrag({\n offset,\n height,\n velocity,\n}: {\n offset: number;\n height: number;\n velocity: number;\n}): boolean {\n if (offset <= 0) return false;\n return offset >= height * DISMISS_DISTANCE_RATIO || velocity >= DISMISS_VELOCITY_PX_PER_MS;\n}\n\ntype DragHandlers = {\n onPointerDown?: React.PointerEventHandler<HTMLDivElement>;\n onPointerMove?: React.PointerEventHandler<HTMLDivElement>;\n onPointerUp?: React.PointerEventHandler<HTMLDivElement>;\n onPointerCancel?: React.PointerEventHandler<HTMLDivElement>;\n};\n\ntype ActiveDrag = {\n pointerId: number;\n element: HTMLDivElement;\n startY: number;\n startX: number;\n lastY: number;\n lastTime: number;\n velocity: number;\n dragging: boolean;\n stopBlockingTouchScroll: () => void;\n};\n\nexport interface UseDragToDismissOptions {\n /** Whether dragging is active at all. */\n enabled: boolean;\n /** Called once a release passes the dismiss threshold. */\n onDismiss: () => void;\n /** Media query that must match for a drag to start, e.g. to limit it to mobile. */\n media?: string;\n}\n\nfunction isScrolledAwayFromTop(target: EventTarget | null, container: HTMLElement): boolean {\n let node = target instanceof HTMLElement ? target : null;\n while (node && node !== container) {\n if (node.scrollTop > 0) return true;\n node = node.parentElement;\n }\n return container.scrollTop > 0;\n}\n\nfunction blockTouchScrollWhileDragging(\n element: HTMLElement,\n getDrag: () => ActiveDrag | null,\n): () => void {\n const onTouchMove = (event: TouchEvent) => {\n const drag = getDrag();\n const touch = event.touches[0];\n if (!drag || !touch) return;\n const offset = touch.clientY - drag.startY;\n if (drag.dragging || offset > Math.abs(touch.clientX - drag.startX)) event.preventDefault();\n };\n element.addEventListener(\"touchmove\", onTouchMove, { passive: false });\n return () => element.removeEventListener(\"touchmove\", onTouchMove);\n}\n\n/**\n * Composes the consumer's pointer handlers with drag-down-to-dismiss for a\n * bottom sheet. The sheet follows the pointer downwards, and on release either\n * dismisses or snaps back. A drag never starts inside a form field or inside\n * scrollable content that is not scrolled to the top, so it does not fight\n * text selection or scrolling.\n */\nexport function useDragToDismiss<P extends DragHandlers>(\n { enabled, onDismiss, media }: UseDragToDismissOptions,\n props: P,\n): P & Required<DragHandlers> {\n const dragRef = React.useRef<ActiveDrag | null>(null);\n const prefersReducedMotion = usePrefersReducedMotion();\n\n const snapBack = (element: HTMLDivElement) => {\n element.style.transition = prefersReducedMotion ? \"\" : SNAP_BACK_TRANSITION;\n element.style.transform = \"\";\n };\n\n const release = (drag: ActiveDrag, dismiss: boolean) => {\n dragRef.current = null;\n drag.stopBlockingTouchScroll();\n drag.element.releasePointerCapture?.(drag.pointerId);\n if (!drag.dragging) return;\n if (!dismiss) {\n snapBack(drag.element);\n return;\n }\n onDismiss();\n requestAnimationFrame(() => {\n if (drag.element.isConnected && drag.element.dataset.state !== \"closed\") {\n snapBack(drag.element);\n }\n });\n };\n\n return {\n ...props,\n onPointerDown(event) {\n props.onPointerDown?.(event);\n if (!enabled || event.defaultPrevented || event.button !== 0) return;\n if (media && typeof window.matchMedia === \"function\" && !window.matchMedia(media).matches)\n return;\n const target = event.target instanceof Element ? event.target : null;\n if (target?.closest(NON_DRAGGABLE_TARGETS)) return;\n if (isScrolledAwayFromTop(event.target, event.currentTarget)) return;\n const element = event.currentTarget;\n dragRef.current = {\n pointerId: event.pointerId,\n element,\n startY: event.clientY,\n startX: event.clientX,\n lastY: event.clientY,\n lastTime: event.timeStamp,\n velocity: 0,\n dragging: false,\n stopBlockingTouchScroll: blockTouchScrollWhileDragging(element, () => dragRef.current),\n };\n },\n onPointerMove(event) {\n props.onPointerMove?.(event);\n const drag = dragRef.current;\n if (!drag || event.pointerId !== drag.pointerId) return;\n const offset = event.clientY - drag.startY;\n if (!drag.dragging) {\n const dx = Math.abs(event.clientX - drag.startX);\n if (Math.max(Math.abs(offset), dx) < DRAG_START_THRESHOLD_PX) return;\n if (offset <= dx) {\n release(drag, false);\n return;\n }\n drag.dragging = true;\n drag.element.setPointerCapture?.(event.pointerId);\n drag.element.style.transition = \"none\";\n }\n const elapsed = event.timeStamp - drag.lastTime;\n if (elapsed > 0) drag.velocity = (event.clientY - drag.lastY) / elapsed;\n drag.lastY = event.clientY;\n drag.lastTime = event.timeStamp;\n drag.element.style.transform = `translate3d(0, ${Math.max(offset, 0)}px, 0)`;\n },\n onPointerUp(event) {\n props.onPointerUp?.(event);\n const drag = dragRef.current;\n if (!drag || event.pointerId !== drag.pointerId) return;\n const dismiss = shouldDismissDrag({\n offset: event.clientY - drag.startY,\n height: drag.element.getBoundingClientRect().height,\n velocity: event.timeStamp - drag.lastTime > FLICK_WINDOW_MS ? 0 : drag.velocity,\n });\n release(drag, dismiss);\n },\n onPointerCancel(event) {\n props.onPointerCancel?.(event);\n const drag = dragRef.current;\n if (!drag || event.pointerId !== drag.pointerId) return;\n release(drag, false);\n },\n };\n}\n"],"names":["React","usePrefersReducedMotion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,0BAA0B;AAChC,MAAM,yBAAyB;AAC/B,MAAM,6BAA6B;AACnC,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;AAC7B,MAAM,wBAAwB;AAMvB,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,GAIY;AACV,MAAI,UAAU,EAAG,QAAO;AACxB,SAAO,UAAU,SAAS,0BAA0B,YAAY;AAClE;AA8BA,SAAS,sBAAsB,QAA4B,WAAiC;AAC1F,MAAI,OAAO,kBAAkB,cAAc,SAAS;AACpD,SAAO,QAAQ,SAAS,WAAW;AACjC,QAAI,KAAK,YAAY,EAAG,QAAO;AAC/B,WAAO,KAAK;AAAA,EACd;AACA,SAAO,UAAU,YAAY;AAC/B;AAEA,SAAS,8BACP,SACA,SACY;AACZ,QAAM,cAAc,CAAC,UAAsB;AACzC,UAAM,OAAO,QAAA;AACb,UAAM,QAAQ,MAAM,QAAQ,CAAC;AAC7B,QAAI,CAAC,QAAQ,CAAC,MAAO;AACr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AAY,KAAK,WAAW,kBAAkB,IAAI,KAAK;AAAA,MAAA,CACxE;AACD,cAAQ,MAAM,OAAO;AAAA,IACvB;AAAA,IACA,gBAAgB,OAAO;AACrB,YAAM,kBAAkB,KAAK;AAC7B,YAAM,OAAO,QAAQ;AACrB,UAAI,CAAC,QAAQ,MAAM,cAAc,KAAK,UAAW;AACjD,cAAQ,MAAM,KAAK;AAAA,IACrB;AAAA,EAAA;AAEJ;;;"}
|
|
@@ -87,6 +87,7 @@ function Scrim({ experience }) {
|
|
|
87
87
|
}
|
|
88
88
|
function CreatorName({
|
|
89
89
|
verified,
|
|
90
|
+
verifiedLabel,
|
|
90
91
|
aiDisclosure,
|
|
91
92
|
aiDisclosureLabel,
|
|
92
93
|
nameId,
|
|
@@ -99,6 +100,7 @@ function CreatorName({
|
|
|
99
100
|
{
|
|
100
101
|
component: "p",
|
|
101
102
|
verified,
|
|
103
|
+
verifiedLabel,
|
|
102
104
|
className: cn("m-0 [&>[role=img]]:ml-1 [&>span:empty+[role=img]]:ml-0", className),
|
|
103
105
|
children: children && /* @__PURE__ */ jsx("span", { id: nameId, children })
|
|
104
106
|
}
|
|
@@ -162,6 +164,7 @@ const ChatEmbed = React.forwardRef(
|
|
|
162
164
|
title,
|
|
163
165
|
subtitle,
|
|
164
166
|
verified = false,
|
|
167
|
+
verifiedLabel = "Verified",
|
|
165
168
|
aiDisclosure = false,
|
|
166
169
|
aiDisclosureLabel = "AI creator",
|
|
167
170
|
action,
|
|
@@ -179,7 +182,7 @@ const ChatEmbed = React.forwardRef(
|
|
|
179
182
|
const titleId = React.useId();
|
|
180
183
|
const isExperience = variant === "experience";
|
|
181
184
|
const hasTopRow = Boolean(badge || category || meta);
|
|
182
|
-
const badges = { verified, aiDisclosure, aiDisclosureLabel };
|
|
185
|
+
const badges = { verified, verifiedLabel, aiDisclosure, aiDisclosureLabel };
|
|
183
186
|
return /* @__PURE__ */ jsxs(
|
|
184
187
|
"div",
|
|
185
188
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatEmbed.mjs","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":[],"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,SACE,qBAAC,OAAA,EAAI,WAAU,mCACb,UAAA;AAAA,IAAA,oBAAC,SAAI,WAAU,iBACZ,kBAAQ,IAAI,CAAC,QAAQ,UACpB;AAAA,MAAC;AAAA,MAAA;AAAA,QAGC,WAAW;AAAA,UACT;AAAA,UACA,QAAQ,QAAQ,SAAS,KAAK;AAAA,UAC9B,QAAQ,KACN;AAAA,QAAA;AAAA,QAGJ,UAAA,oBAAC,QAAA,EAAO,MAAM,IAAK,GAAG,OAAA,CAAQ;AAAA,MAAA;AAAA,MARzB;AAAA,IAAA,CAUR,GACH;AAAA,IACA,qBAAC,KAAA,EAAE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AAA,UACjC,qBAAC,OAAA,EAAI,WAAU,wCACb,UAAA;AAAA,YAAA,oBAAC,UAAA,EAAS,SAAQ,YAAW,OAAO,IAAI,QAAQ,IAAI,WAAU,WAAA,CAAW;AAAA,YACzE,qBAAC,OAAA,EAAI,WAAU,sCACb,UAAA;AAAA,cAAA,oBAAC,UAAA,EAAS,OAAM,OAAM,QAAQ,IAAI;AAAA,cAClC,oBAAC,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,uBAAuB,MAAM;AAAA,EACxC,CAAC,EAAE,UAAU,WAAW,MAAM,WAAW,UAAU,GAAG,MAAA,GAAS,QAAQ;AACrE,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA,OAAO,OAAO;AAAA,UACd;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA,4BACE,QAAA,EAAK,eAAY,QAAO,WAAU,QAChC,UAAA,MACH;AAAA,8BAED,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.mjs","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":[],"mappings":";;;;;;;;AAwGA,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,SACE,qBAAC,OAAA,EAAI,WAAU,mCACb,UAAA;AAAA,IAAA,oBAAC,SAAI,WAAU,iBACZ,kBAAQ,IAAI,CAAC,QAAQ,UACpB;AAAA,MAAC;AAAA,MAAA;AAAA,QAGC,WAAW;AAAA,UACT;AAAA,UACA,QAAQ,QAAQ,SAAS,KAAK;AAAA,UAC9B,QAAQ,KACN;AAAA,QAAA;AAAA,QAGJ,UAAA,oBAAC,QAAA,EAAO,MAAM,IAAK,GAAG,OAAA,CAAQ;AAAA,MAAA;AAAA,MARzB;AAAA,IAAA,CAUR,GACH;AAAA,IACA,qBAAC,KAAA,EAAE,WAAU,mFACV,UAAA;AAAA,MAAA,QACC,oBAAC,QAAA,EAAK,WAAU,yDAAyD,UAAA,MAAK;AAAA,MAEhF,oBAAC,QAAA,EAAK,WAAU,+CAA+C,UAAA,MAAA,CAAM;AAAA,IAAA,EAAA,CACvE;AAAA,EAAA,GACF;AAEJ;AAEA,SA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AAA,EAAI,WAAU,sCACb,UAAA;AAAA,cAAA,oBAAC,UAAA,EAAS,OAAM,OAAM,QAAQ,IAAI;AAAA,cAClC,oBAAC,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,uBAAuB,MAAM;AAAA,EACxC,CAAC,EAAE,UAAU,WAAW,MAAM,WAAW,UAAU,GAAG,MAAA,GAAS,QAAQ;AACrE,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA,OAAO,OAAO;AAAA,UACd;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA,4BACE,QAAA,EAAK,eAAY,QAAO,WAAU,QAChC,UAAA,MACH;AAAA,8BAED,KAAA,EAAE,WAAU,0CACV,UAAA,YAAY,oBAAoB,OAAO,EAAA,CAC1C;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,qBAAqB,cAAc;"}
|
|
@@ -71,7 +71,7 @@ const Checkbox = React.forwardRef(
|
|
|
71
71
|
onCheckedChange: handleCheckedChange,
|
|
72
72
|
className: cn(
|
|
73
73
|
// Base styles
|
|
74
|
-
"flex items-center justify-center rounded border",
|
|
74
|
+
"flex items-center justify-center rounded-2xs border",
|
|
75
75
|
BOX_SIZE_CLASS[boxSize],
|
|
76
76
|
"transition-[border-color,background-color,color,box-shadow] duration-150",
|
|
77
77
|
// Default state
|