@fanvue/ui 3.48.0 → 3.50.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/README.md +1 -1
- package/dist/animated-icons.d.ts +4 -1
- package/dist/charts.d.ts +37 -0
- package/dist/charts.mjs +2 -0
- package/dist/charts.mjs.map +1 -1
- package/dist/cjs/charts.cjs +2 -0
- package/dist/cjs/charts.cjs.map +1 -1
- package/dist/cjs/components/Alert/Alert.cjs +45 -36
- package/dist/cjs/components/Alert/Alert.cjs.map +1 -1
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs +7 -3
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs.map +1 -1
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/cjs/components/Autocomplete/AutocompleteDropdownContent.cjs +1 -1
- package/dist/cjs/components/Autocomplete/AutocompleteDropdownContent.cjs.map +1 -1
- package/dist/cjs/components/Button/Button.cjs +1 -1
- package/dist/cjs/components/Button/Button.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartGrid.cjs +40 -0
- package/dist/cjs/components/Chart/ChartGrid.cjs.map +1 -0
- package/dist/cjs/components/ChatInput/ChatInput.cjs +21 -11
- package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.cjs +29 -23
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +31 -34
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs +5 -4
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +10 -10
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +12 -7
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -1
- package/dist/cjs/components/EmptyState/EmptyState.cjs +9 -1
- package/dist/cjs/components/EmptyState/EmptyState.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.cjs +8 -2
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/Icons/BaseIcon.cjs +7 -2
- package/dist/cjs/components/Icons/BaseIcon.cjs.map +1 -1
- package/dist/cjs/components/Icons/IconDefaults.cjs +26 -0
- package/dist/cjs/components/Icons/IconDefaults.cjs.map +1 -0
- package/dist/cjs/components/Icons/MenuRowIcon.cjs +26 -0
- package/dist/cjs/components/Icons/MenuRowIcon.cjs.map +1 -0
- package/dist/cjs/components/Icons/SpinnerIcon.cjs +4 -2
- package/dist/cjs/components/Icons/SpinnerIcon.cjs.map +1 -1
- package/dist/cjs/components/Icons/iconSpinClass.cjs +6 -0
- package/dist/cjs/components/Icons/iconSpinClass.cjs.map +1 -0
- package/dist/cjs/components/Link/Link.cjs +7 -3
- package/dist/cjs/components/Link/Link.cjs.map +1 -1
- package/dist/cjs/components/Loader/Loader.cjs +1 -1
- package/dist/cjs/components/Loader/Loader.cjs.map +1 -1
- package/dist/cjs/components/MediaPlayChip/MediaPlayChip.cjs +56 -0
- package/dist/cjs/components/MediaPlayChip/MediaPlayChip.cjs.map +1 -0
- package/dist/cjs/components/Select/Select.cjs +13 -10
- package/dist/cjs/components/Select/Select.cjs.map +1 -1
- package/dist/cjs/components/Skeleton/Skeleton.cjs +17 -1
- package/dist/cjs/components/Skeleton/Skeleton.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsList.cjs +3 -1
- package/dist/cjs/components/Tabs/TabsList.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsListSkeleton.cjs +30 -0
- package/dist/cjs/components/Tabs/TabsListSkeleton.cjs.map +1 -0
- package/dist/cjs/components/UserItem/UserItem.cjs +6 -1
- package/dist/cjs/components/UserItem/UserItem.cjs.map +1 -1
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/Alert/Alert.mjs +45 -36
- package/dist/components/Alert/Alert.mjs.map +1 -1
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs +7 -3
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.mjs +1 -1
- package/dist/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/dist/components/Autocomplete/AutocompleteDropdownContent.mjs +1 -1
- package/dist/components/Autocomplete/AutocompleteDropdownContent.mjs.map +1 -1
- package/dist/components/Button/Button.mjs +1 -1
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/Chart/ChartGrid.mjs +40 -0
- package/dist/components/Chart/ChartGrid.mjs.map +1 -0
- package/dist/components/ChatInput/ChatInput.mjs +21 -11
- package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
- package/dist/components/Dialog/Dialog.mjs +29 -23
- package/dist/components/Dialog/Dialog.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs +32 -35
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs +5 -4
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +10 -10
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +12 -7
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -1
- package/dist/components/EmptyState/EmptyState.mjs +9 -1
- package/dist/components/EmptyState/EmptyState.mjs.map +1 -1
- package/dist/components/IconButton/IconButton.mjs +8 -2
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/Icons/BaseIcon.mjs +7 -2
- package/dist/components/Icons/BaseIcon.mjs.map +1 -1
- package/dist/components/Icons/IconDefaults.mjs +9 -0
- package/dist/components/Icons/IconDefaults.mjs.map +1 -0
- package/dist/components/Icons/MenuRowIcon.mjs +26 -0
- package/dist/components/Icons/MenuRowIcon.mjs.map +1 -0
- package/dist/components/Icons/SpinnerIcon.mjs +4 -2
- package/dist/components/Icons/SpinnerIcon.mjs.map +1 -1
- package/dist/components/Icons/iconSpinClass.mjs +6 -0
- package/dist/components/Icons/iconSpinClass.mjs.map +1 -0
- package/dist/components/Link/Link.mjs +7 -3
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/Loader/Loader.mjs +1 -1
- package/dist/components/Loader/Loader.mjs.map +1 -1
- package/dist/components/MediaPlayChip/MediaPlayChip.mjs +39 -0
- package/dist/components/MediaPlayChip/MediaPlayChip.mjs.map +1 -0
- package/dist/components/Select/Select.mjs +13 -10
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/Skeleton/Skeleton.mjs +17 -1
- package/dist/components/Skeleton/Skeleton.mjs.map +1 -1
- package/dist/components/Tabs/TabsList.mjs +3 -1
- package/dist/components/Tabs/TabsList.mjs.map +1 -1
- package/dist/components/Tabs/TabsListSkeleton.mjs +13 -0
- package/dist/components/Tabs/TabsListSkeleton.mjs.map +1 -0
- package/dist/components/UserItem/UserItem.mjs +6 -1
- package/dist/components/UserItem/UserItem.mjs.map +1 -1
- package/dist/index.d.ts +171 -18
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.mjs","sources":["../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Count, type CountSize } from \"../Count/Count\";\n\n/**\n * Visual style variant of the icon button.\n *\n * `primary`, `secondary`, `tertiary`, `outline`, `error`, `white` and `black`\n * use the shared button colour tokens and a size-driven shape (squared at the\n * `24` size, circular otherwise). Of these, `primary`, `secondary`, `tertiary`\n * and `outline` also honour the {@link IconButtonProps.negative} prop.\n *\n * `brand`, `contrast`, `messaging`, `navTray`, `tertiaryDestructive`, `stop` and\n * `microphone` are bespoke variants that stay circular at every size.\n */\nexport type IconButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"tertiary\"\n | \"outline\"\n | \"error\"\n | \"white\"\n | \"black\"\n | \"brand\"\n | \"contrast\"\n | \"messaging\"\n | \"navTray\"\n | \"tertiaryDestructive\"\n | \"stop\"\n | \"microphone\"\n | \"field\";\n\n/** Icon button size in pixels. */\nexport type IconButtonSize = \"24\" | \"32\" | \"40\" | \"48\" | \"52\" | \"72\";\n\nconst iconSizeVariants: Record<IconButtonSize, string> = {\n 24: \"[&>svg]:size-4\",\n 32: \"[&>svg]:size-4\",\n 40: \"[&>svg]:size-4\",\n 48: \"[&>svg]:size-6\",\n 52: \"[&>svg]:size-7\",\n 72: \"[&>svg]:size-8\",\n};\n\nconst sizeVariants: Record<IconButtonSize, string> = {\n 24: \"size-6 p-1\",\n 32: \"size-8 p-1.5\",\n 40: \"size-10 p-[10px]\",\n 48: \"size-12 p-3\",\n 52: \"size-[52px] p-2\",\n 72: \"size-[72px] p-4\",\n};\n\nconst countSizeMap: Record<IconButtonSize, CountSize> = {\n 24: \"16\",\n 32: \"24\",\n 40: \"32\",\n 48: \"32\",\n 52: \"32\",\n 72: \"32\",\n};\n\n/**\n * Variants whose corner radius is size-driven (see {@link IconButton}): the `24`\n * size is squared (`rounded-xs`), every larger size stays circular. All other\n * variants are circular at every size.\n */\nconst SIZE_DRIVEN_SHAPE_VARIANTS = new Set<IconButtonVariant>([\n \"primary\",\n \"secondary\",\n \"tertiary\",\n \"outline\",\n \"error\",\n \"white\",\n \"black\",\n]);\n\n/** Variants that honour the `negative` (dark-surface) treatment. */\nconst NEGATIVE_AWARE_VARIANTS = new Set<IconButtonVariant>([\n \"primary\",\n \"secondary\",\n \"tertiary\",\n \"outline\",\n]);\n\nconst DISABLED_FILL = \"disabled:bg-buttons-disabled-default disabled:text-content-disabled\";\nconst DISABLED_FILL_NEGATIVE =\n \"disabled:bg-buttons-disabled-negative disabled:text-content-disabled\";\nconst DISABLED_TRANSPARENT = \"disabled:text-content-disabled\";\nconst DISABLED_OPACITY = \"disabled:opacity-50\";\n\ntype VariantClasses = {\n default: string;\n disabled: string;\n negative?: string;\n negativeDisabled?: string;\n};\n\n/**\n * Icon button styling for every variant. The disabled treatment is expressed\n * with the CSS `disabled:` variant (not the `disabled` prop) so an ancestor\n * `<fieldset disabled>` is styled too; hover is guarded with `not-disabled:` so\n * it never fights the disabled state.\n */\nconst VARIANT_CLASSES: Record<IconButtonVariant, VariantClasses> = {\n primary: {\n default:\n \"bg-buttons-primary-default text-content-primary-inverted not-disabled:hover:bg-buttons-primary-hover not-disabled:active:bg-buttons-primary-hover\",\n disabled: DISABLED_FILL,\n negative:\n \"bg-buttons-primary-negative-default text-content-primary not-disabled:hover:bg-buttons-primary-negative-hover not-disabled:active:bg-buttons-primary-negative-hover\",\n negativeDisabled: DISABLED_FILL_NEGATIVE,\n },\n secondary: {\n default:\n \"bg-buttons-secondary-default text-content-primary not-disabled:hover:bg-buttons-secondary-hover not-disabled:active:bg-buttons-secondary-hover\",\n disabled: DISABLED_FILL,\n negative:\n \"bg-buttons-secondary-negative-default text-content-primary-inverted not-disabled:hover:bg-buttons-secondary-negative-hover not-disabled:active:bg-buttons-secondary-negative-hover\",\n negativeDisabled: DISABLED_FILL_NEGATIVE,\n },\n tertiary: {\n default:\n \"bg-transparent text-content-primary not-disabled:hover:bg-buttons-tertiary-hover not-disabled:active:bg-buttons-tertiary-hover\",\n disabled: DISABLED_TRANSPARENT,\n negative:\n \"bg-transparent text-content-primary-inverted not-disabled:hover:bg-buttons-tertiary-negative-hover not-disabled:active:bg-buttons-tertiary-negative-hover\",\n negativeDisabled: DISABLED_TRANSPARENT,\n },\n outline: {\n default:\n \"border border-buttons-outline-default bg-transparent text-content-primary not-disabled:hover:bg-buttons-outline-hover not-disabled:active:bg-buttons-outline-hover\",\n disabled: \"disabled:border-buttons-disabled-default disabled:text-content-disabled\",\n negative:\n \"border border-buttons-outline-negative-default bg-transparent text-content-primary-inverted not-disabled:hover:bg-buttons-outline-negative-hover not-disabled:active:bg-buttons-outline-negative-hover\",\n negativeDisabled: \"disabled:border-buttons-disabled-negative disabled:text-content-disabled\",\n },\n error: {\n default:\n \"bg-buttons-error-default text-content-always-white not-disabled:hover:bg-buttons-error-hover not-disabled:active:bg-buttons-error-hover\",\n disabled: DISABLED_FILL,\n },\n white: {\n default:\n \"bg-buttons-always-white-default text-content-always-black not-disabled:hover:bg-buttons-always-white-hover not-disabled:active:bg-buttons-always-white-hover\",\n disabled: DISABLED_FILL,\n },\n black: {\n default:\n \"bg-buttons-always-black-default text-content-always-white not-disabled:hover:bg-buttons-always-black-hover not-disabled:active:bg-buttons-always-black-hover\",\n disabled: DISABLED_FILL,\n },\n brand: {\n default:\n \"bg-content-always-black text-brand-primary-default hover:bg-brand-primary-default hover:text-content-always-black not-disabled:active:bg-brand-primary-default not-disabled:active:text-content-always-black\",\n disabled: DISABLED_OPACITY,\n },\n contrast: {\n default:\n \"bg-transparent text-content-always-white hover:bg-brand-primary-muted not-disabled:active:bg-brand-primary-muted\",\n disabled: DISABLED_OPACITY,\n },\n messaging: {\n default:\n \"bg-content-always-black text-brand-primary-default hover:bg-brand-primary-default hover:text-content-always-black not-disabled:active:bg-brand-primary-default not-disabled:active:text-content-always-black\",\n disabled: DISABLED_OPACITY,\n },\n navTray: {\n default:\n \"bg-transparent text-content-primary hover:bg-brand-primary-muted not-disabled:active:bg-brand-primary-muted\",\n disabled: DISABLED_OPACITY,\n },\n tertiaryDestructive: {\n default:\n \"bg-transparent text-error-content hover:bg-brand-primary-muted not-disabled:active:bg-brand-primary-muted\",\n disabled: DISABLED_OPACITY,\n },\n stop: {\n default:\n \"bg-buttons-primary-default text-content-primary-inverted hover:bg-buttons-brand-default hover:text-content-always-black not-disabled:active:bg-buttons-brand-default not-disabled:active:text-content-always-black\",\n disabled: DISABLED_OPACITY,\n },\n microphone: {\n default:\n \"bg-buttons-primary-default text-content-primary-inverted hover:bg-buttons-brand-default hover:text-content-always-black not-disabled:active:bg-buttons-brand-default not-disabled:active:text-content-always-black\",\n disabled: DISABLED_OPACITY,\n },\n // Carries the input surface rather than a button one, so an icon-only action can\n // sit flush in a row of fields (Figma draws these as a `V2 Input Fields` instance\n // with only an icon inside). Border and hover match the Select trigger it lines up\n // with, so the row reads as one control group.\n field: {\n default:\n \"border border-border-primary bg-inputs-inputs-primary text-content-primary not-disabled:hover:border-neutral-alphas-400\",\n disabled: DISABLED_TRANSPARENT,\n },\n};\n\nfunction getVariantClasses(variant: IconButtonVariant, negative: boolean): string {\n const classes = VARIANT_CLASSES[variant];\n const isNegative = NEGATIVE_AWARE_VARIANTS.has(variant) && negative;\n const base = (isNegative && classes.negative) || classes.default;\n const disabledClasses = (isNegative && classes.negativeDisabled) || classes.disabled;\n return cn(base, disabledClasses);\n}\n\nexport interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Visual style variant of the icon button. @default \"primary\" */\n variant?: IconButtonVariant;\n /** Size of the button in pixels. @default \"40\" */\n size?: IconButtonSize;\n /** Icon element to render inside the button. */\n icon: React.ReactNode;\n /**\n * Forces the dark-surface treatment regardless of theme. Only honoured on the\n * `primary`, `secondary`, `tertiary`, and `outline` variants. @default false\n */\n negative?: boolean;\n /** When provided, displays a {@link Count} badge at the top-right corner. */\n counterValue?: number;\n}\n\n/**\n * A button containing only an icon. Use when an action can be represented by an\n * icon alone (e.g. close, send). Always pair with an `aria-label` for\n * accessibility.\n *\n * Shape is size-driven for the standard variants: the `24` size is squared\n * (`rounded-xs`), every larger size is circular. Bespoke variants (`brand`,\n * `contrast`, `messaging`, `navTray`, `tertiaryDestructive`, `stop`,\n * `microphone`) stay circular at all sizes. `field` is the exception that is\n * never circular — it takes the inputs' `rounded-sm` so it matches the fields it\n * sits beside. Use it at `32`, `40` or `48`: those are the sizes `Select` offers,\n * and the variant only earns its surface when it lines up with one.\n *\n * @example\n * ```tsx\n * <IconButton icon={<CloseIcon />} aria-label=\"Close\" variant=\"tertiary\" />\n * ```\n */\nexport const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(\n (\n {\n className,\n variant = \"primary\",\n size = \"40\",\n icon,\n counterValue,\n negative = false,\n disabled = false,\n ...props\n },\n ref,\n ) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (!props[\"aria-label\"] && !props[\"aria-labelledby\"] && !props.title) {\n console.warn(\n \"IconButton: No accessible name provided. Add an `aria-label`, `aria-labelledby`, or `title` prop so screen readers can announce this button.\",\n );\n }\n }\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-testid=\"icon-button\"\n disabled={disabled}\n className={cn(\n \"relative inline-flex shrink-0 items-center justify-center focus-visible:outline-none\",\n \"cursor-pointer transition-all duration-150 ease-in-out disabled:cursor-default\",\n \"focus-visible:shadow-focus-ring\",\n // `field` takes the inputs' radius at every size so it lines up with the\n // fields around it; everything else keeps the existing size-driven shape.\n variant === \"field\"\n ? \"rounded-sm\"\n : SIZE_DRIVEN_SHAPE_VARIANTS.has(variant) && size === \"24\"\n ? \"rounded-xs\"\n : \"rounded-full\",\n sizeVariants[size],\n getVariantClasses(variant, negative),\n className,\n )}\n {...props}\n >\n <span\n className={cn(\"flex shrink-0 items-center justify-center\", iconSizeVariants[size])}\n aria-hidden=\"true\"\n >\n {icon}\n </span>\n\n {counterValue !== undefined && (\n <Count\n value={counterValue}\n variant=\"alert\"\n size={countSizeMap[size]}\n className=\"absolute -top-0.5 -right-0.5\"\n />\n )}\n </button>\n );\n },\n);\n\nIconButton.displayName = \"IconButton\";\n"],"names":[],"mappings":";;;;;AAmCA,MAAM,mBAAmD;AAAA,EACvD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,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,UACA;AAAA;AAAA;AAAA,UAGA,YAAY,UACR,eACA,2BAA2B,IAAI,OAAO,KAAK,SAAS,OAClD,eACA;AAAA,UACN,aAAa,IAAI;AAAA,UACjB,kBAAkB,SAAS,QAAQ;AAAA,UACnC;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,GAAG,6CAA6C,iBAAiB,IAAI,CAAC;AAAA,cACjF,eAAY;AAAA,cAEX,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGF,iBAAiB,UAChB;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,OAAO;AAAA,cACP,SAAQ;AAAA,cACR,MAAM,aAAa,IAAI;AAAA,cACvB,WAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QACZ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,WAAW,cAAc;"}
|
|
1
|
+
{"version":3,"file":"IconButton.mjs","sources":["../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Count, type CountSize } from \"../Count/Count\";\nimport { IconDefaultsContext, NO_ICON_DEFAULTS } from \"../Icons/IconDefaults\";\n\n/**\n * Visual style variant of the icon button.\n *\n * `primary`, `secondary`, `tertiary`, `outline`, `error`, `white` and `black`\n * use the shared button colour tokens and a size-driven shape (squared at the\n * `24` size, circular otherwise). Of these, `primary`, `secondary`, `tertiary`\n * and `outline` also honour the {@link IconButtonProps.negative} prop.\n *\n * `overlay` is a translucent dark fill with a backdrop blur, for buttons that sit\n * on photos or video. Its fill and icon look the same in light and dark themes, while\n * the keyboard focus ring still follows the theme. It takes the same size-driven\n * shape as the standard variants.\n *\n * `brand`, `contrast`, `messaging`, `navTray`, `tertiaryDestructive`, `stop` and\n * `microphone` are bespoke variants that stay circular at every size.\n */\nexport type IconButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"tertiary\"\n | \"outline\"\n | \"error\"\n | \"white\"\n | \"black\"\n | \"brand\"\n | \"contrast\"\n | \"messaging\"\n | \"navTray\"\n | \"tertiaryDestructive\"\n | \"stop\"\n | \"microphone\"\n | \"overlay\"\n | \"field\";\n\n/** Icon button size in pixels. */\nexport type IconButtonSize = \"24\" | \"32\" | \"40\" | \"48\" | \"52\" | \"72\";\n\nconst iconSizeVariants: Record<IconButtonSize, string> = {\n 24: \"[&>svg]:size-4\",\n 32: \"[&>svg]:size-4\",\n 40: \"[&>svg]:size-4\",\n 48: \"[&>svg]:size-6\",\n 52: \"[&>svg]:size-7\",\n 72: \"[&>svg]:size-8\",\n};\n\nconst sizeVariants: Record<IconButtonSize, string> = {\n 24: \"size-6 p-1\",\n 32: \"size-8 p-1.5\",\n 40: \"size-10 p-[10px]\",\n 48: \"size-12 p-3\",\n 52: \"size-[52px] p-2\",\n 72: \"size-[72px] p-4\",\n};\n\nconst countSizeMap: Record<IconButtonSize, CountSize> = {\n 24: \"16\",\n 32: \"24\",\n 40: \"32\",\n 48: \"32\",\n 52: \"32\",\n 72: \"32\",\n};\n\n/**\n * Variants whose corner radius is size-driven (see {@link IconButton}): the `24`\n * size is squared (`rounded-xs`), every larger size stays circular. All other\n * variants are circular at every size.\n */\nconst SIZE_DRIVEN_SHAPE_VARIANTS = new Set<IconButtonVariant>([\n \"primary\",\n \"secondary\",\n \"tertiary\",\n \"outline\",\n \"error\",\n \"white\",\n \"black\",\n \"overlay\",\n]);\n\n/** Variants that honour the `negative` (dark-surface) treatment. */\nconst NEGATIVE_AWARE_VARIANTS = new Set<IconButtonVariant>([\n \"primary\",\n \"secondary\",\n \"tertiary\",\n \"outline\",\n]);\n\nconst DISABLED_FILL = \"disabled:bg-buttons-disabled-default disabled:text-content-disabled\";\nconst DISABLED_FILL_NEGATIVE =\n \"disabled:bg-buttons-disabled-negative disabled:text-content-disabled\";\nconst DISABLED_TRANSPARENT = \"disabled:text-content-disabled\";\nconst DISABLED_OPACITY = \"disabled:opacity-50\";\n\ntype VariantClasses = {\n default: string;\n disabled: string;\n negative?: string;\n negativeDisabled?: string;\n};\n\n/**\n * Icon button styling for every variant. The disabled treatment is expressed\n * with the CSS `disabled:` variant (not the `disabled` prop) so an ancestor\n * `<fieldset disabled>` is styled too; hover is guarded with `not-disabled:` so\n * it never fights the disabled state.\n */\nconst VARIANT_CLASSES: Record<IconButtonVariant, VariantClasses> = {\n primary: {\n default:\n \"bg-buttons-primary-default text-content-primary-inverted not-disabled:hover:bg-buttons-primary-hover not-disabled:active:bg-buttons-primary-hover\",\n disabled: DISABLED_FILL,\n negative:\n \"bg-buttons-primary-negative-default text-content-primary not-disabled:hover:bg-buttons-primary-negative-hover not-disabled:active:bg-buttons-primary-negative-hover\",\n negativeDisabled: DISABLED_FILL_NEGATIVE,\n },\n secondary: {\n default:\n \"bg-buttons-secondary-default text-content-primary not-disabled:hover:bg-buttons-secondary-hover not-disabled:active:bg-buttons-secondary-hover\",\n disabled: DISABLED_FILL,\n negative:\n \"bg-buttons-secondary-negative-default text-content-primary-inverted not-disabled:hover:bg-buttons-secondary-negative-hover not-disabled:active:bg-buttons-secondary-negative-hover\",\n negativeDisabled: DISABLED_FILL_NEGATIVE,\n },\n tertiary: {\n default:\n \"bg-transparent text-content-primary not-disabled:hover:bg-buttons-tertiary-hover not-disabled:active:bg-buttons-tertiary-hover\",\n disabled: DISABLED_TRANSPARENT,\n negative:\n \"bg-transparent text-content-primary-inverted not-disabled:hover:bg-buttons-tertiary-negative-hover not-disabled:active:bg-buttons-tertiary-negative-hover\",\n negativeDisabled: DISABLED_TRANSPARENT,\n },\n outline: {\n default:\n \"border border-buttons-outline-default bg-transparent text-content-primary not-disabled:hover:bg-buttons-outline-hover not-disabled:active:bg-buttons-outline-hover\",\n disabled: \"disabled:border-buttons-disabled-default disabled:text-content-disabled\",\n negative:\n \"border border-buttons-outline-negative-default bg-transparent text-content-primary-inverted not-disabled:hover:bg-buttons-outline-negative-hover not-disabled:active:bg-buttons-outline-negative-hover\",\n negativeDisabled: \"disabled:border-buttons-disabled-negative disabled:text-content-disabled\",\n },\n error: {\n default:\n \"bg-buttons-error-default text-content-always-white not-disabled:hover:bg-buttons-error-hover not-disabled:active:bg-buttons-error-hover\",\n disabled: DISABLED_FILL,\n },\n white: {\n default:\n \"bg-buttons-always-white-default text-content-always-black not-disabled:hover:bg-buttons-always-white-hover not-disabled:active:bg-buttons-always-white-hover\",\n disabled: DISABLED_FILL,\n },\n black: {\n default:\n \"bg-buttons-always-black-default text-content-always-white not-disabled:hover:bg-buttons-always-black-hover not-disabled:active:bg-buttons-always-black-hover\",\n disabled: DISABLED_FILL,\n },\n brand: {\n default:\n \"bg-content-always-black text-brand-primary-default hover:bg-brand-primary-default hover:text-content-always-black not-disabled:active:bg-brand-primary-default not-disabled:active:text-content-always-black\",\n disabled: DISABLED_OPACITY,\n },\n contrast: {\n default:\n \"bg-transparent text-content-always-white hover:bg-brand-primary-muted not-disabled:active:bg-brand-primary-muted\",\n disabled: DISABLED_OPACITY,\n },\n messaging: {\n default:\n \"bg-content-always-black text-brand-primary-default hover:bg-brand-primary-default hover:text-content-always-black not-disabled:active:bg-brand-primary-default not-disabled:active:text-content-always-black\",\n disabled: DISABLED_OPACITY,\n },\n navTray: {\n default:\n \"bg-transparent text-content-primary hover:bg-brand-primary-muted not-disabled:active:bg-brand-primary-muted\",\n disabled: DISABLED_OPACITY,\n },\n tertiaryDestructive: {\n default:\n \"bg-transparent text-error-content hover:bg-brand-primary-muted not-disabled:active:bg-brand-primary-muted\",\n disabled: DISABLED_OPACITY,\n },\n stop: {\n default:\n \"bg-buttons-primary-default text-content-primary-inverted hover:bg-buttons-brand-default hover:text-content-always-black not-disabled:active:bg-buttons-brand-default not-disabled:active:text-content-always-black\",\n disabled: DISABLED_OPACITY,\n },\n microphone: {\n default:\n \"bg-buttons-primary-default text-content-primary-inverted hover:bg-buttons-brand-default hover:text-content-always-black not-disabled:active:bg-buttons-brand-default not-disabled:active:text-content-always-black\",\n disabled: DISABLED_OPACITY,\n },\n overlay: {\n default:\n \"bg-buttons-overlay-default text-content-always-white backdrop-blur-sm not-disabled:hover:bg-buttons-overlay-hover not-disabled:active:bg-buttons-overlay-hover\",\n disabled: DISABLED_OPACITY,\n },\n // Carries the input surface rather than a button one, so an icon-only action can\n // sit flush in a row of fields (Figma draws these as a `V2 Input Fields` instance\n // with only an icon inside). Border and hover match the Select trigger it lines up\n // with, so the row reads as one control group.\n field: {\n default:\n \"border border-border-primary bg-inputs-inputs-primary text-content-primary not-disabled:hover:border-neutral-alphas-400\",\n disabled: DISABLED_TRANSPARENT,\n },\n};\n\nfunction getVariantClasses(variant: IconButtonVariant, negative: boolean): string {\n const classes = VARIANT_CLASSES[variant];\n const isNegative = NEGATIVE_AWARE_VARIANTS.has(variant) && negative;\n const base = (isNegative && classes.negative) || classes.default;\n const disabledClasses = (isNegative && classes.negativeDisabled) || classes.disabled;\n return cn(base, disabledClasses);\n}\n\nexport interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Visual style variant of the icon button. @default \"primary\" */\n variant?: IconButtonVariant;\n /** Size of the button in pixels. @default \"40\" */\n size?: IconButtonSize;\n /** Icon element to render inside the button. */\n icon: React.ReactNode;\n /**\n * Forces the dark-surface treatment regardless of theme. Only honoured on the\n * `primary`, `secondary`, `tertiary`, and `outline` variants. @default false\n */\n negative?: boolean;\n /** When provided, displays a {@link Count} badge at the top-right corner. */\n counterValue?: number;\n}\n\n/**\n * A button containing only an icon. Use when an action can be represented by an\n * icon alone (e.g. close, send). Always pair with an `aria-label` for\n * accessibility.\n *\n * Shape is size-driven for the standard variants and `overlay`: the `24` size is\n * squared (`rounded-xs`), every larger size is circular. Bespoke variants (`brand`,\n * `contrast`, `messaging`, `navTray`, `tertiaryDestructive`, `stop`,\n * `microphone`) stay circular at all sizes. `field` is the exception that is\n * never circular — it takes the inputs' `rounded-sm` so it matches the fields it\n * sits beside. Use it at `32`, `40` or `48`: those are the sizes `Select` offers,\n * and the variant only earns its surface when it lines up with one.\n *\n * @example\n * ```tsx\n * <IconButton icon={<CloseIcon />} aria-label=\"Close\" variant=\"tertiary\" />\n * ```\n */\nexport const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(\n (\n {\n className,\n variant = \"primary\",\n size = \"40\",\n icon,\n counterValue,\n negative = false,\n disabled = false,\n ...props\n },\n ref,\n ) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (!props[\"aria-label\"] && !props[\"aria-labelledby\"] && !props.title) {\n console.warn(\n \"IconButton: No accessible name provided. Add an `aria-label`, `aria-labelledby`, or `title` prop so screen readers can announce this button.\",\n );\n }\n }\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-testid=\"icon-button\"\n disabled={disabled}\n className={cn(\n \"relative inline-flex shrink-0 items-center justify-center focus-visible:outline-none\",\n \"cursor-pointer transition-all duration-150 ease-in-out disabled:cursor-default\",\n \"focus-visible:shadow-focus-ring\",\n // `field` takes the inputs' radius at every size so it lines up with the\n // fields around it; everything else keeps the existing size-driven shape.\n variant === \"field\"\n ? \"rounded-sm\"\n : SIZE_DRIVEN_SHAPE_VARIANTS.has(variant) && size === \"24\"\n ? \"rounded-xs\"\n : \"rounded-full\",\n sizeVariants[size],\n getVariantClasses(variant, negative),\n className,\n )}\n {...props}\n >\n <span\n className={cn(\"flex shrink-0 items-center justify-center\", iconSizeVariants[size])}\n aria-hidden=\"true\"\n >\n {/* A button sizes its own icon, so a menu row's icon defaults stop here. */}\n <IconDefaultsContext.Provider value={NO_ICON_DEFAULTS}>\n {icon}\n </IconDefaultsContext.Provider>\n </span>\n\n {counterValue !== undefined && (\n <Count\n value={counterValue}\n variant=\"alert\"\n size={countSizeMap[size]}\n className=\"absolute -top-0.5 -right-0.5\"\n />\n )}\n </button>\n );\n },\n);\n\nIconButton.displayName = \"IconButton\";\n"],"names":[],"mappings":";;;;;;AA0CA,MAAM,mBAAmD;AAAA,EACvD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IA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A,MAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL,eAAY;AAAA,QACZ;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA;AAAA;AAAA,UAGA,YAAY,UACR,eACA,2BAA2B,IAAI,OAAO,KAAK,SAAS,OAClD,eACA;AAAA,UACN,aAAa,IAAI;AAAA,UACjB,kBAAkB,SAAS,QAAQ;AAAA,UACnC;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,GAAG,6CAA6C,iBAAiB,IAAI,CAAC;AAAA,cACjF,eAAY;AAAA,cAGZ,8BAAC,oBAAoB,UAApB,EAA6B,OAAO,kBAClC,UAAA,KAAA,CACH;AAAA,YAAA;AAAA,UAAA;AAAA,UAGD,iBAAiB,UAChB;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,OAAO;AAAA,cACP,SAAQ;AAAA,cACR,MAAM,aAAa,IAAI;AAAA,cACvB,WAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QACZ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,WAAW,cAAc;"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../../utils/cn.mjs";
|
|
5
|
+
import { IconDefaultsContext } from "./IconDefaults.mjs";
|
|
5
6
|
import { ICON_SIZE_CLASS } from "./iconSizeClass.mjs";
|
|
7
|
+
import { ICON_SPIN_CLASS } from "./iconSpinClass.mjs";
|
|
6
8
|
const LAYER_TRANSITION = "motion-safe:transition-opacity motion-safe:duration-150 motion-safe:ease-in-out";
|
|
7
9
|
const renderPath = (p) => p.sw !== void 0 ? /* @__PURE__ */ jsx(
|
|
8
10
|
"path",
|
|
@@ -25,7 +27,10 @@ const renderPath = (p) => p.sw !== void 0 ? /* @__PURE__ */ jsx(
|
|
|
25
27
|
p.d
|
|
26
28
|
);
|
|
27
29
|
const BaseIcon = React.forwardRef(
|
|
28
|
-
({ variants, size
|
|
30
|
+
({ variants, size: sizeProp, filled: filledProp, spin = false, className, ...props }, ref) => {
|
|
31
|
+
const defaults = React.useContext(IconDefaultsContext);
|
|
32
|
+
const size = sizeProp ?? (defaults.size !== void 0 && variants[defaults.size] ? defaults.size : 24);
|
|
33
|
+
const filled = filledProp ?? (defaults.filled && variants[size]?.filled ? true : void 0);
|
|
29
34
|
const v = variants[size];
|
|
30
35
|
const outlined = v?.outlined ?? [];
|
|
31
36
|
const filledPaths = v?.filled;
|
|
@@ -42,7 +47,7 @@ const BaseIcon = React.forwardRef(
|
|
|
42
47
|
viewBox: `0 0 ${size} ${size}`,
|
|
43
48
|
fill: "none",
|
|
44
49
|
"aria-hidden": "true",
|
|
45
|
-
className: cn(ICON_SIZE_CLASS[size], className),
|
|
50
|
+
className: cn(ICON_SIZE_CLASS[size], spin && ICON_SPIN_CLASS, className),
|
|
46
51
|
...props,
|
|
47
52
|
children: [
|
|
48
53
|
/* @__PURE__ */ jsx("g", { className: cn(LAYER_TRANSITION, showFilled ? "opacity-0" : "opacity-100"), children: outlined.map(renderPath) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseIcon.mjs","sources":["../../../src/components/Icons/BaseIcon.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { ICON_SIZE_CLASS } from \"./iconSizeClass\";\nimport type { BaseIconProps, IconPath, IconVariants } from \"./types\";\n\nconst LAYER_TRANSITION =\n \"motion-safe:transition-opacity motion-safe:duration-150 motion-safe:ease-in-out\";\n\ninterface InternalBaseIconProps extends BaseIconProps {\n variants: IconVariants;\n}\n\nconst renderPath = (p: IconPath) =>\n p.sw !== undefined ? (\n <path\n key={p.d}\n d={p.d}\n stroke=\"currentColor\"\n strokeWidth={p.sw}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n ) : (\n <path\n key={p.d}\n d={p.d}\n fill=\"currentColor\"\n fillRule={p.eo ? \"evenodd\" : undefined}\n clipRule={p.eo ? \"evenodd\" : undefined}\n />\n );\n\n/**\n * Internal renderer for prop-based icons. Each public icon (e.g. `HeartIcon`)\n * is a thin wrapper that supplies its own `variants` table and re-exports\n * {@link BaseIconProps} as `*IconProps`. Not exported from the package.\n *\n * When a `filled` variant exists, both layers are rendered simultaneously and\n * the `filled` prop crossfades between them. The same `<svg>` and `<g>` nodes\n * persist across toggles so the transition is visible rather than an instant\n * remount.\n */\nexport const BaseIcon = React.forwardRef<SVGSVGElement, InternalBaseIconProps>(\n ({ variants, size
|
|
1
|
+
{"version":3,"file":"BaseIcon.mjs","sources":["../../../src/components/Icons/BaseIcon.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { IconDefaultsContext } from \"./IconDefaults\";\nimport { ICON_SIZE_CLASS } from \"./iconSizeClass\";\nimport { ICON_SPIN_CLASS } from \"./iconSpinClass\";\nimport type { BaseIconProps, IconPath, IconVariants } from \"./types\";\n\nconst LAYER_TRANSITION =\n \"motion-safe:transition-opacity motion-safe:duration-150 motion-safe:ease-in-out\";\n\ninterface InternalBaseIconProps extends BaseIconProps {\n variants: IconVariants;\n}\n\nconst renderPath = (p: IconPath) =>\n p.sw !== undefined ? (\n <path\n key={p.d}\n d={p.d}\n stroke=\"currentColor\"\n strokeWidth={p.sw}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n ) : (\n <path\n key={p.d}\n d={p.d}\n fill=\"currentColor\"\n fillRule={p.eo ? \"evenodd\" : undefined}\n clipRule={p.eo ? \"evenodd\" : undefined}\n />\n );\n\n/**\n * Internal renderer for prop-based icons. Each public icon (e.g. `HeartIcon`)\n * is a thin wrapper that supplies its own `variants` table and re-exports\n * {@link BaseIconProps} as `*IconProps`. Not exported from the package.\n *\n * When a `filled` variant exists, both layers are rendered simultaneously and\n * the `filled` prop crossfades between them. The same `<svg>` and `<g>` nodes\n * persist across toggles so the transition is visible rather than an instant\n * remount.\n */\nexport const BaseIcon = React.forwardRef<SVGSVGElement, InternalBaseIconProps>(\n ({ variants, size: sizeProp, filled: filledProp, spin = false, className, ...props }, ref) => {\n const defaults = React.useContext(IconDefaultsContext);\n // A container default only applies when the icon has artwork for it, so an\n // icon drawn at 24/32 only, or without a filled 16, keeps its own look.\n const size =\n sizeProp ?? (defaults.size !== undefined && variants[defaults.size] ? defaults.size : 24);\n const filled = filledProp ?? (defaults.filled && variants[size]?.filled ? true : undefined);\n const v = variants[size];\n const outlined = v?.outlined ?? [];\n const filledPaths = v?.filled;\n const showFilled = !!(filled && filledPaths);\n\n if (filled && !filledPaths && v && process.env.NODE_ENV !== \"production\") {\n console.warn(\n `[fanvue/ui] Icon at size=${size} has no 'filled' variant; falling back to outlined.`,\n );\n }\n\n return (\n <svg\n ref={ref}\n viewBox={`0 0 ${size} ${size}`}\n fill=\"none\"\n aria-hidden=\"true\"\n className={cn(ICON_SIZE_CLASS[size], spin && ICON_SPIN_CLASS, className)}\n {...props}\n >\n <g className={cn(LAYER_TRANSITION, showFilled ? \"opacity-0\" : \"opacity-100\")}>\n {outlined.map(renderPath)}\n </g>\n {filledPaths && (\n <g className={cn(LAYER_TRANSITION, showFilled ? \"opacity-100\" : \"opacity-0\")}>\n {filledPaths.map(renderPath)}\n </g>\n )}\n </svg>\n );\n },\n);\n\nBaseIcon.displayName = \"BaseIcon\";\n"],"names":[],"mappings":";;;;;;;AAOA,MAAM,mBACJ;AAMF,MAAM,aAAa,CAAC,MAClB,EAAE,OAAO,SACP;AAAA,EAAC;AAAA,EAAA;AAAA,IAEC,GAAG,EAAE;AAAA,IACL,QAAO;AAAA,IACP,aAAa,EAAE;AAAA,IACf,eAAc;AAAA,IACd,gBAAe;AAAA,EAAA;AAAA,EALV,EAAE;AAMT,IAEA;AAAA,EAAC;AAAA,EAAA;AAAA,IAEC,GAAG,EAAE;AAAA,IACL,MAA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
|
1
|
+
{"version":3,"file":"IconDefaults.mjs","sources":["../../../src/components/Icons/IconDefaults.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { IconSize } from \"./types\";\n\n/**\n * Defaults a container applies to the prop-based icons inside it, such as a\n * menu row drawing its icons filled at 16px. An icon's own `filled` and `size`\n * props always win, and a default the icon has no artwork for is skipped.\n * Internal to the package.\n */\nexport type IconDefaults = { filled?: boolean; size?: IconSize };\n\n/** No defaults. Containers that host their own icons provide it to stop an outer default leaking in. */\nexport const NO_ICON_DEFAULTS: IconDefaults = {};\n\nexport const IconDefaultsContext = React.createContext<IconDefaults>(NO_ICON_DEFAULTS);\n"],"names":[],"mappings":";;AAYO,MAAM,mBAAiC,CAAA;AAEvC,MAAM,sBAAsB,MAAM,cAA4B,gBAAgB;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../utils/cn.mjs";
|
|
4
|
+
import { IconDefaultsContext } from "./IconDefaults.mjs";
|
|
5
|
+
const MENU_ROW_ICON_DEFAULTS = { filled: true, size: 16 };
|
|
6
|
+
function MenuRowIcon({ children, inheritColor, alignToTitle, className }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"span",
|
|
9
|
+
{
|
|
10
|
+
className: cn(
|
|
11
|
+
"flex shrink-0 items-center [&>svg]:size-4",
|
|
12
|
+
alignToTitle && "h-4.5",
|
|
13
|
+
!inheritColor && [
|
|
14
|
+
"text-icons-secondary",
|
|
15
|
+
"group-data-[disabled]:text-icons-disabled group-disabled:text-icons-disabled group-aria-disabled:text-icons-disabled"
|
|
16
|
+
],
|
|
17
|
+
className
|
|
18
|
+
),
|
|
19
|
+
children: /* @__PURE__ */ jsx(IconDefaultsContext.Provider, { value: MENU_ROW_ICON_DEFAULTS, children })
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
MenuRowIcon
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=MenuRowIcon.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuRowIcon.mjs","sources":["../../../src/components/Icons/MenuRowIcon.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { type IconDefaults, IconDefaultsContext } from \"./IconDefaults\";\n\nconst MENU_ROW_ICON_DEFAULTS: IconDefaults = { filled: true, size: 16 };\n\ninterface MenuRowIconProps {\n children: React.ReactNode;\n /** Keep the row's own colour (e.g. a destructive row's error red) instead of `Icons/Secondary`. */\n inheritColor?: boolean;\n /** Centre the icon on an 18px title line, for two-line rows aligned to their title. */\n alignToTitle?: boolean;\n className?: string;\n}\n\n/**\n * The icon slot of a menu or select row: a 16px box in `Icons/Secondary`, with\n * prop-based icons drawn filled at 16px unless they set their own `filled` or\n * `size`. The disabled variants cover every way a row is disabled: Radix's\n * `data-disabled`, a native `disabled` button and `aria-disabled`. Internal to\n * the package.\n */\nexport function MenuRowIcon({ children, inheritColor, alignToTitle, className }: MenuRowIconProps) {\n return (\n <span\n className={cn(\n \"flex shrink-0 items-center [&>svg]:size-4\",\n alignToTitle && \"h-4.5\",\n !inheritColor && [\n \"text-icons-secondary\",\n \"group-data-[disabled]:text-icons-disabled group-disabled:text-icons-disabled group-aria-disabled:text-icons-disabled\",\n ],\n className,\n )}\n >\n <IconDefaultsContext.Provider value={MENU_ROW_ICON_DEFAULTS}>\n {children}\n </IconDefaultsContext.Provider>\n </span>\n );\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,yBAAuC,EAAE,QAAQ,MAAM,MAAM,GAAA;AAkB5D,SAAS,YAAY,EAAE,UAAU,cAAc,cAAc,aAA+B;AACjG,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,gBAAgB;AAAA,QAChB,CAAC,gBAAgB;AAAA,UACf;AAAA,UACA;AAAA,QAAA;AAAA,QAEF;AAAA,MAAA;AAAA,MAGF,8BAAC,oBAAoB,UAApB,EAA6B,OAAO,wBAClC,SAAA,CACH;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../../utils/cn.mjs";
|
|
5
|
+
import { ICON_SIZE_CLASS } from "./iconSizeClass.mjs";
|
|
6
|
+
import { ICON_SPIN_CLASS } from "./iconSpinClass.mjs";
|
|
5
7
|
const SpinnerIcon = React.forwardRef(
|
|
6
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
8
|
+
({ className, size, spin = false, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
7
9
|
"svg",
|
|
8
10
|
{
|
|
9
11
|
ref,
|
|
10
12
|
viewBox: "0 0 20 20",
|
|
11
13
|
fill: "none",
|
|
12
14
|
"aria-hidden": "true",
|
|
13
|
-
className: cn("size-5", className),
|
|
15
|
+
className: cn(size ? ICON_SIZE_CLASS[size] : "size-5", spin && ICON_SPIN_CLASS, className),
|
|
14
16
|
...props,
|
|
15
17
|
children: [
|
|
16
18
|
/* @__PURE__ */ jsx("circle", { cx: "10", cy: "10", r: "8", stroke: "currentColor", strokeOpacity: ".25", strokeWidth: "2" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpinnerIcon.mjs","sources":["../../../src/components/Icons/SpinnerIcon.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport type { IconProps } from \"./types\";\n\n/** A circular spinner
|
|
1
|
+
{"version":3,"file":"SpinnerIcon.mjs","sources":["../../../src/components/Icons/SpinnerIcon.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { ICON_SIZE_CLASS } from \"./iconSizeClass\";\nimport { ICON_SPIN_CLASS } from \"./iconSpinClass\";\nimport type { BaseIconProps, IconProps, IconSize } from \"./types\";\n\n/** Props for {@link SpinnerIcon}. */\nexport interface SpinnerIconProps extends Omit<IconProps, \"size\">, Pick<BaseIconProps, \"spin\"> {\n /** Pixel size of the spinner. Defaults to 20px when omitted. */\n size?: IconSize;\n}\n\n/**\n * A circular spinner glyph for loading states. It is a plain icon: pass `spin`\n * to turn it, as with any other prop-based icon. Prefer `spin`: a raw `animate-spin`\n * class keeps rotating under reduced motion. Combining the two never doubles the\n * speed. For a full-area loading state use the `Loader` component.\n *\n * @example\n * ```tsx\n * <SpinnerIcon size={16} spin />\n * ```\n */\nexport const SpinnerIcon = React.forwardRef<SVGSVGElement, SpinnerIconProps>(\n ({ className, size, spin = false, ...props }, ref) => (\n <svg\n ref={ref}\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n aria-hidden=\"true\"\n className={cn(size ? ICON_SIZE_CLASS[size] : \"size-5\", spin && ICON_SPIN_CLASS, className)}\n {...props}\n >\n <circle cx=\"10\" cy=\"10\" r=\"8\" stroke=\"currentColor\" strokeOpacity=\".25\" strokeWidth=\"2\" />\n <path d=\"M10 2a8 8 0 0 1 8 8\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" />\n </svg>\n ),\n);\n\nSpinnerIcon.displayName = \"SpinnerIcon\";\n"],"names":[],"mappings":";;;;;;AAuBO,MAAM,cAAc,MAAM;AAAA,EAC/B,CAAC,EAAE,WAAW,MAAM,OAAO,OAAO,GAAG,MAAA,GAAS,QAC5C;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,eAAY;AAAA,MACZ,WAAW,GAAG,OAAO,gBAAgB,IAAI,IAAI,UAAU,QAAQ,iBAAiB,SAAS;AAAA,MACxF,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAA,oBAAC,UAAA,EAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KAAI,QAAO,gBAAe,eAAc,OAAM,aAAY,KAAI;AAAA,QACxF,oBAAC,UAAK,GAAE,uBAAsB,QAAO,gBAAe,aAAY,KAAI,eAAc,QAAA,CAAQ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhG;AAEA,YAAY,cAAc;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconSpinClass.mjs","sources":["../../../src/components/Icons/iconSpinClass.ts"],"sourcesContent":["/**\n * Classes behind the icon `spin` prop: a full turn per second when motion is\n * allowed, a pulse in place under `prefers-reduced-motion`. Uses the same\n * `spin` keyframes as Tailwind's `animate-spin`, so an icon that also carries\n * that class still turns at one speed.\n *\n * Internal — not exported from the package.\n */\nexport const ICON_SPIN_CLASS = \"motion-safe:animate-spin motion-reduce:animate-pulse\";\n"],"names":[],"mappings":";AAQO,MAAM,kBAAkB;"}
|
|
@@ -5,11 +5,13 @@ import * as React from "react";
|
|
|
5
5
|
import { cn } from "../../utils/cn.mjs";
|
|
6
6
|
const SIZE_CLASSES = {
|
|
7
7
|
"16": "typography-body-default-16px-semibold",
|
|
8
|
-
"14": "typography-body-small-14px-semibold"
|
|
8
|
+
"14": "typography-body-small-14px-semibold",
|
|
9
|
+
inherit: ""
|
|
9
10
|
};
|
|
10
11
|
const VARIANT_CLASSES = {
|
|
11
12
|
primary: "text-buttons-link-primary-default hover:text-buttons-link-primary-hover",
|
|
12
|
-
brand: "text-buttons-link-brand-default hover:text-buttons-link-brand-hover"
|
|
13
|
+
brand: "text-buttons-link-brand-default hover:text-buttons-link-brand-hover",
|
|
14
|
+
inherit: "text-inherit hover:opacity-80"
|
|
13
15
|
};
|
|
14
16
|
const ICON_WRAPPER = "flex shrink-0 items-center justify-center [&>svg]:size-4";
|
|
15
17
|
const Link = React.forwardRef(
|
|
@@ -43,7 +45,9 @@ const Link = React.forwardRef(
|
|
|
43
45
|
href: disabled ? void 0 : href,
|
|
44
46
|
onClick: handleClick,
|
|
45
47
|
className: cn(
|
|
46
|
-
"inline-flex items-center gap-2
|
|
48
|
+
size === "inherit" && !leftIcon && !rightIcon ? "inline" : "inline-flex items-center gap-2",
|
|
49
|
+
"rounded-2xs",
|
|
50
|
+
variant === "inherit" ? "transition-opacity" : "transition-colors",
|
|
47
51
|
"focus-visible:shadow-focus-ring focus-visible:outline-none",
|
|
48
52
|
disabled ? "pointer-events-none cursor-not-allowed text-content-disabled" : VARIANT_CLASSES[variant],
|
|
49
53
|
asChild && textClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.mjs","sources":["../../../src/components/Link/Link.tsx"],"sourcesContent":["import { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n
|
|
1
|
+
{"version":3,"file":"Link.mjs","sources":["../../../src/components/Link/Link.tsx"],"sourcesContent":["import { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/**\n * Visual style variant of the link. `inherit` takes the colour of the\n * surrounding text, for links inside tooltips, alerts and other copy that sets\n * its own colour.\n */\nexport type LinkVariant = \"primary\" | \"brand\" | \"inherit\";\n\n/**\n * Text size of the link in pixels. `inherit` keeps the font size and weight of\n * the surrounding text, for a link that sits inside a sentence. Without icons it\n * renders inline, so a long link wraps with the sentence.\n */\nexport type LinkSize = \"16\" | \"14\" | \"inherit\";\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /** Visual style variant of the link. @default \"primary\" */\n variant?: LinkVariant;\n /** Text size of the link in pixels. @default \"16\" */\n size?: LinkSize;\n /** When `true`, greys the link out and blocks interaction. @default false */\n disabled?: boolean;\n /** Icon element displayed before the label. */\n leftIcon?: React.ReactNode;\n /** Icon element displayed after the label. */\n rightIcon?: React.ReactNode;\n /** Merge props onto a child element instead of rendering an `<a>`. @default false */\n asChild?: boolean;\n}\n\nconst SIZE_CLASSES: Record<LinkSize, string> = {\n \"16\": \"typography-body-default-16px-semibold\",\n \"14\": \"typography-body-small-14px-semibold\",\n inherit: \"\",\n};\n\nconst VARIANT_CLASSES: Record<LinkVariant, string> = {\n primary: \"text-buttons-link-primary-default hover:text-buttons-link-primary-hover\",\n brand: \"text-buttons-link-brand-default hover:text-buttons-link-brand-hover\",\n inherit: \"text-inherit hover:opacity-80\",\n};\n\nconst ICON_WRAPPER = \"flex shrink-0 items-center justify-center [&>svg]:size-4\";\n\n/**\n * An inline text link for navigating to a related page or section without\n * using a button. Use `primary` for standard navigation and `brand` for the\n * Fanvue green accent on calls to action within content. Use `inherit` with\n * `size=\"inherit\"` for a link inside copy that sets its own colour and type,\n * such as a tooltip.\n *\n * Renders an underlined `<a>` by default. Pass `asChild` to compose with a\n * router link (e.g. Next.js `Link`). When rendering without a visible label,\n * provide an `aria-label`.\n *\n * @example\n * ```tsx\n * <Link href=\"/pricing\" variant=\"brand\">See our plans</Link>\n * ```\n */\nexport const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(\n (\n {\n className,\n variant = \"primary\",\n size = \"16\",\n disabled = false,\n leftIcon,\n rightIcon,\n asChild = false,\n children,\n href,\n onClick,\n ...props\n },\n ref,\n ) => {\n const Comp = asChild ? Slot : \"a\";\n\n const textClasses = cn(\n SIZE_CLASSES[size],\n \"underline decoration-from-font decoration-solid [text-underline-position:from-font]\",\n );\n\n const disabledProps = disabled ? { \"aria-disabled\": true, tabIndex: -1 } : {};\n\n // Radix Slot lets the child's own props win when merging, so a disabled\n // `asChild` link would keep the child's navigable href. Strip it from the\n // child (anchors only) and block default navigation to honor `disabled`.\n const slotChild =\n disabled && React.isValidElement<{ href?: string }>(children) && children.type === \"a\"\n ? React.cloneElement(children, { href: undefined })\n : children;\n\n const handleClick = disabled\n ? (event: React.MouseEvent<HTMLAnchorElement>) => event.preventDefault()\n : onClick;\n\n const leftIconNode = leftIcon && (\n <span className={ICON_WRAPPER} aria-hidden=\"true\">\n {leftIcon}\n </span>\n );\n const rightIconNode = rightIcon && (\n <span className={ICON_WRAPPER} aria-hidden=\"true\">\n {rightIcon}\n </span>\n );\n\n return (\n <Comp\n ref={ref}\n href={disabled ? undefined : href}\n onClick={handleClick}\n className={cn(\n size === \"inherit\" && !leftIcon && !rightIcon\n ? \"inline\"\n : \"inline-flex items-center gap-2\",\n \"rounded-2xs\",\n variant === \"inherit\" ? \"transition-opacity\" : \"transition-colors\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n disabled\n ? \"pointer-events-none cursor-not-allowed text-content-disabled\"\n : VARIANT_CLASSES[variant],\n asChild && textClasses,\n className,\n )}\n {...(asChild ? {} : { \"data-testid\": \"link\" })}\n {...disabledProps}\n {...props}\n >\n {leftIconNode}\n {asChild ? (\n <Slottable>{slotChild}</Slottable>\n ) : (\n <span className={textClasses}>{children}</span>\n )}\n {rightIconNode}\n </Comp>\n );\n },\n);\n\nLink.displayName = \"Link\";\n"],"names":[],"mappings":";;;;;AAiCA,MAAM,eAAyC;AAAA,EAC7C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACX;AAEA,MAAM,kBAA+C;AAAA,EACnD,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AACX;AAEA,MAAM,eAAe;AAkBd,MAAM,OAAO,MAAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,IACP,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,OAAO,UAAU,OAAO;AAE9B,UAAM,cAAc;AAAA,MAClB,aAAa,IAAI;AAAA,MACjB;AAAA,IAAA;AAGF,UAAM,gBAAgB,WAAW,EAAE,iBAAiB,MAAM,UAAU,GAAA,IAAO,CAAA;AAK3E,UAAM,YACJ,YAAY,MAAM,eAAkC,QAAQ,KAAK,SAAS,SAAS,MAC/E,MAAM,aAAa,UAAU,EAAE,MAAM,OAAA,CAAW,IAChD;AAEN,UAAM,cAAc,WAChB,CAAC,UAA+C,MAAM,mBACtD;AAEJ,UAAM,eAAe,YACnB,oBAAC,QAAA,EAAK,WAAW,cAAc,eAAY,QACxC,UAAA,SAAA,CACH;AAEF,UAAM,gBAAgB,aACpB,oBAAC,QAAA,EAAK,WAAW,cAAc,eAAY,QACxC,UAAA,UAAA,CACH;AAGF,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,MAAM,WAAW,SAAY;AAAA,QAC7B,SAAS;AAAA,QACT,WAAW;AAAA,UACT,SAAS,aAAa,CAAC,YAAY,CAAC,YAChC,WACA;AAAA,UACJ;AAAA,UACA,YAAY,YAAY,uBAAuB;AAAA,UAC/C;AAAA,UACA,WACI,iEACA,gBAAgB,OAAO;AAAA,UAC3B,WAAW;AAAA,UACX;AAAA,QAAA;AAAA,QAED,GAAI,UAAU,CAAA,IAAK,EAAE,eAAe,OAAA;AAAA,QACpC,GAAG;AAAA,QACH,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA;AAAA,UACA,8BACE,WAAA,EAAW,UAAA,UAAA,CAAU,IAEtB,oBAAC,QAAA,EAAK,WAAW,aAAc,SAAA,CAAS;AAAA,UAEzC;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEA,KAAK,cAAc;"}
|
|
@@ -28,7 +28,7 @@ const Loader = React.forwardRef(
|
|
|
28
28
|
shouldCenterY && "top-1/2 -translate-y-1/2"
|
|
29
29
|
),
|
|
30
30
|
"aria-label": ariaLabel ?? "loading",
|
|
31
|
-
children: /* @__PURE__ */ jsx(SpinnerIcon, { className: "size-9
|
|
31
|
+
children: /* @__PURE__ */ jsx(SpinnerIcon, { spin: true, className: "size-9 text-content-secondary" })
|
|
32
32
|
}
|
|
33
33
|
)
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Loader.mjs","sources":["../../../src/components/Loader/Loader.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { SpinnerIcon } from \"../Icons/SpinnerIcon\";\n\nexport interface LoaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether the loader is visible. When `false`, renders nothing. @default true */\n show?: boolean;\n /** Accessible label for the loading indicator. @default \"loading\" */\n ariaLabel?: string;\n /** Minimum height of the container. Numbers are treated as pixels. @default \"100%\" */\n minHeight?: number | string;\n /** Center the spinner horizontally. @default false */\n center?: boolean;\n /** Center the spinner horizontally. @default false */\n centerX?: boolean;\n /** Center the spinner vertically. @default false */\n centerY?: boolean;\n}\n\n/**\n * A layout-aware loading indicator that renders a centered `SpinnerIcon` inside\n * a relatively-positioned container. Drop-in replacement for the Olympus `Loader`.\n *\n * @example\n * ```tsx\n * <Loader show center />\n * <Loader show centerX minHeight={200} />\n * ```\n */\nexport const Loader = React.forwardRef<HTMLDivElement, LoaderProps>(\n (\n { show = true, ariaLabel, minHeight = \"100%\", center, centerX, centerY, className, ...props },\n ref,\n ) => {\n if (!show) {\n return null;\n }\n\n const shouldCenterX = center || centerX;\n const shouldCenterY = center || centerY;\n\n return (\n <div\n ref={ref}\n className={cn(\"relative\", className)}\n style={{\n minHeight: typeof minHeight === \"number\" ? `${minHeight}px` : minHeight,\n }}\n {...props}\n >\n <output\n className={cn(\n \"absolute flex size-[60px] items-center justify-center\",\n shouldCenterX && \"left-1/2 -translate-x-1/2\",\n shouldCenterY && \"top-1/2 -translate-y-1/2\",\n )}\n aria-label={ariaLabel ?? \"loading\"}\n >\n <SpinnerIcon className=\"size-9
|
|
1
|
+
{"version":3,"file":"Loader.mjs","sources":["../../../src/components/Loader/Loader.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { SpinnerIcon } from \"../Icons/SpinnerIcon\";\n\nexport interface LoaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether the loader is visible. When `false`, renders nothing. @default true */\n show?: boolean;\n /** Accessible label for the loading indicator. @default \"loading\" */\n ariaLabel?: string;\n /** Minimum height of the container. Numbers are treated as pixels. @default \"100%\" */\n minHeight?: number | string;\n /** Center the spinner horizontally. @default false */\n center?: boolean;\n /** Center the spinner horizontally. @default false */\n centerX?: boolean;\n /** Center the spinner vertically. @default false */\n centerY?: boolean;\n}\n\n/**\n * A layout-aware loading indicator that renders a centered `SpinnerIcon` inside\n * a relatively-positioned container. Drop-in replacement for the Olympus `Loader`.\n *\n * @example\n * ```tsx\n * <Loader show center />\n * <Loader show centerX minHeight={200} />\n * ```\n */\nexport const Loader = React.forwardRef<HTMLDivElement, LoaderProps>(\n (\n { show = true, ariaLabel, minHeight = \"100%\", center, centerX, centerY, className, ...props },\n ref,\n ) => {\n if (!show) {\n return null;\n }\n\n const shouldCenterX = center || centerX;\n const shouldCenterY = center || centerY;\n\n return (\n <div\n ref={ref}\n className={cn(\"relative\", className)}\n style={{\n minHeight: typeof minHeight === \"number\" ? `${minHeight}px` : minHeight,\n }}\n {...props}\n >\n <output\n className={cn(\n \"absolute flex size-[60px] items-center justify-center\",\n shouldCenterX && \"left-1/2 -translate-x-1/2\",\n shouldCenterY && \"top-1/2 -translate-y-1/2\",\n )}\n aria-label={ariaLabel ?? \"loading\"}\n >\n <SpinnerIcon spin className=\"size-9 text-content-secondary\" />\n </output>\n </div>\n );\n },\n);\n\nLoader.displayName = \"Loader\";\n"],"names":[],"mappings":";;;;;AA6BO,MAAM,SAAS,MAAM;AAAA,EAC1B,CACE,EAAE,OAAO,MAAM,WAAW,YAAY,QAAQ,QAAQ,SAAS,SAAS,WAAW,GAAG,MAAA,GACtF,QACG;AACH,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,UAAM,gBAAgB,UAAU;AAChC,UAAM,gBAAgB,UAAU;AAEhC,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW,GAAG,YAAY,SAAS;AAAA,QACnC,OAAO;AAAA,UACL,WAAW,OAAO,cAAc,WAAW,GAAG,SAAS,OAAO;AAAA,QAAA;AAAA,QAE/D,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA,iBAAiB;AAAA,cACjB,iBAAiB;AAAA,YAAA;AAAA,YAEnB,cAAY,aAAa;AAAA,YAEzB,UAAA,oBAAC,aAAA,EAAY,MAAI,MAAC,WAAU,gCAAA,CAAgC;AAAA,UAAA;AAAA,QAAA;AAAA,MAC9D;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,OAAO,cAAc;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../../utils/cn.mjs";
|
|
5
|
+
import { Play2Icon } from "../Icons/Play2Icon.mjs";
|
|
6
|
+
function formatPlayChipDuration(duration) {
|
|
7
|
+
if (duration === void 0 || !Number.isFinite(duration) || duration < 1) return void 0;
|
|
8
|
+
const total = Math.floor(duration);
|
|
9
|
+
const parts = [Math.floor(total / 3600), Math.floor(total % 3600 / 60), total % 60];
|
|
10
|
+
return (parts[0] ? parts : parts.slice(1)).map((part) => String(part).padStart(2, "0")).join(":");
|
|
11
|
+
}
|
|
12
|
+
const MediaPlayChip = React.forwardRef(
|
|
13
|
+
({ duration, className, ...props }, ref) => {
|
|
14
|
+
const length = formatPlayChipDuration(duration);
|
|
15
|
+
return /* @__PURE__ */ jsxs(
|
|
16
|
+
"span",
|
|
17
|
+
{
|
|
18
|
+
ref,
|
|
19
|
+
"aria-hidden": true,
|
|
20
|
+
className: cn(
|
|
21
|
+
"pointer-events-none inline-flex h-8 min-w-8 items-center justify-center gap-2 rounded-full bg-[var(--primitives-color-whitealpha-100)] text-icons-always-white backdrop-blur-[20px]",
|
|
22
|
+
length ? "px-3" : "w-8",
|
|
23
|
+
className
|
|
24
|
+
),
|
|
25
|
+
...props,
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Play2Icon, { size: 16, filled: true }),
|
|
28
|
+
length ? /* @__PURE__ */ jsx("span", { className: "typography-body-small-14px-semibold whitespace-nowrap tabular-nums", children: length }) : null
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
MediaPlayChip.displayName = "MediaPlayChip";
|
|
35
|
+
export {
|
|
36
|
+
MediaPlayChip,
|
|
37
|
+
formatPlayChipDuration
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=MediaPlayChip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaPlayChip.mjs","sources":["../../../src/components/MediaPlayChip/MediaPlayChip.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Play2Icon } from \"../Icons/Play2Icon\";\n\nexport interface MediaPlayChipProps\n extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /**\n * Length of the video in seconds, shown next to the icon as mm:ss, or\n * hh:mm:ss from an hour. Lengths under a second are not shown.\n */\n duration?: number;\n}\n\n/**\n * A video's length as the chip shows it: `mm:ss`, or `hh:mm:ss` from an hour.\n * Returns `undefined` for a missing, non-finite or sub-second length. Use it to\n * put the same length in the label of the tile the chip sits on.\n *\n * @example\n * ```ts\n * formatPlayChipDuration(42); // \"00:42\"\n * formatPlayChipDuration(3725); // \"01:02:05\"\n * ```\n */\nexport function formatPlayChipDuration(duration?: number): string | undefined {\n if (duration === undefined || !Number.isFinite(duration) || duration < 1) return undefined;\n const total = Math.floor(duration);\n const parts = [Math.floor(total / 3600), Math.floor((total % 3600) / 60), total % 60];\n return (parts[0] ? parts : parts.slice(1)).map((part) => String(part).padStart(2, \"0\")).join(\":\");\n}\n\n/**\n * Marks a video tile with a play icon and its length, or a 32px circle with the\n * icon alone when the length is unknown. The chip is decorative, so the tile it\n * sits on carries the label and the action. It is white on a translucent white\n * fill on every theme, as it sits over media rather than the page.\n *\n * The chip has no position of its own; the host places it, e.g. centred with\n * `absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2`.\n *\n * @example\n * ```tsx\n * <button\n * type=\"button\"\n * aria-label={[alt, formatPlayChipDuration(duration)].filter(Boolean).join(\", \")}\n * className=\"relative\"\n * >\n * <img src={poster} alt=\"\" />\n * <MediaPlayChip\n * duration={duration}\n * className=\"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2\"\n * />\n * </button>\n * ```\n */\nexport const MediaPlayChip = React.forwardRef<HTMLSpanElement, MediaPlayChipProps>(\n ({ duration, className, ...props }, ref) => {\n const length = formatPlayChipDuration(duration);\n\n return (\n <span\n ref={ref}\n aria-hidden\n className={cn(\n \"pointer-events-none inline-flex h-8 min-w-8 items-center justify-center gap-2 rounded-full bg-[var(--primitives-color-whitealpha-100)] text-icons-always-white backdrop-blur-[20px]\",\n length ? \"px-3\" : \"w-8\",\n className,\n )}\n {...props}\n >\n <Play2Icon size={16} filled />\n {length ? (\n <span className=\"typography-body-small-14px-semibold whitespace-nowrap tabular-nums\">\n {length}\n </span>\n ) : null}\n </span>\n );\n },\n);\n\nMediaPlayChip.displayName = \"MediaPlayChip\";\n"],"names":[],"mappings":";;;;;AAwBO,SAAS,uBAAuB,UAAuC;AAC5E,MAAI,aAAa,UAAa,CAAC,OAAO,SAAS,QAAQ,KAAK,WAAW,EAAG,QAAO;AACjF,QAAM,QAAQ,KAAK,MAAM,QAAQ;AACjC,QAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,IAAI,GAAG,KAAK,MAAO,QAAQ,OAAQ,EAAE,GAAG,QAAQ,EAAE;AACpF,UAAQ,MAAM,CAAC,IAAI,QAAQ,MAAM,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,OAAO,IAAI,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,GAAG;AAClG;AA0BO,MAAM,gBAAgB,MAAM;AAAA,EACjC,CAAC,EAAE,UAAU,WAAW,GAAG,MAAA,GAAS,QAAQ;AAC1C,UAAM,SAAS,uBAAuB,QAAQ;AAE9C,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,eAAW;AAAA,QACX,WAAW;AAAA,UACT;AAAA,UACA,SAAS,SAAS;AAAA,UAClB;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAA,oBAAC,WAAA,EAAU,MAAM,IAAI,QAAM,MAAC;AAAA,UAC3B,SACC,oBAAC,QAAA,EAAK,WAAU,sEACb,kBACH,IACE;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AAEA,cAAc,cAAc;"}
|
|
@@ -6,6 +6,8 @@ import { cn } from "../../utils/cn.mjs";
|
|
|
6
6
|
import { FLOATING_CONTENT_COLLISION_PADDING } from "../../utils/floatingContentCollisionPadding.mjs";
|
|
7
7
|
import { CheckIcon } from "../Icons/CheckIcon.mjs";
|
|
8
8
|
import { ChevronDownIcon } from "../Icons/ChevronDownIcon.mjs";
|
|
9
|
+
import { IconDefaultsContext, NO_ICON_DEFAULTS } from "../Icons/IconDefaults.mjs";
|
|
10
|
+
import { MenuRowIcon } from "../Icons/MenuRowIcon.mjs";
|
|
9
11
|
const SelectContext = React.createContext({
|
|
10
12
|
size: "48",
|
|
11
13
|
error: false
|
|
@@ -152,7 +154,7 @@ const SelectContent = React.forwardRef(
|
|
|
152
154
|
collisionPadding,
|
|
153
155
|
style: { zIndex: "var(--fanvue-ui-portal-z-index, 50)", ...style },
|
|
154
156
|
className: cn(
|
|
155
|
-
"relative w-max min-w-(--radix-select-trigger-width) max-w-(--radix-select-content-available-width) overflow-hidden rounded-
|
|
157
|
+
"relative w-max min-w-(--radix-select-trigger-width) max-w-(--radix-select-content-available-width) overflow-hidden rounded-md border border-border-strong bg-background-secondary text-content-primary shadow-blur-menu backdrop-blur-xs",
|
|
156
158
|
"data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
157
159
|
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
158
160
|
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
@@ -160,13 +162,13 @@ const SelectContent = React.forwardRef(
|
|
|
160
162
|
className
|
|
161
163
|
),
|
|
162
164
|
...props,
|
|
163
|
-
children: /* @__PURE__ */ jsx(SelectPrimitive.Viewport, { className: "max-h-[var(--radix-select-content-available-height)] overflow-y-auto p-
|
|
165
|
+
children: /* @__PURE__ */ jsx(SelectPrimitive.Viewport, { className: "max-h-[var(--radix-select-content-available-height)] overflow-y-auto p-2", children: /* @__PURE__ */ jsx(IconDefaultsContext.Provider, { value: NO_ICON_DEFAULTS, children }) })
|
|
164
166
|
}
|
|
165
167
|
) })
|
|
166
168
|
);
|
|
167
169
|
SelectContent.displayName = "SelectContent";
|
|
168
170
|
const ITEM_SIZE_CLASSES = {
|
|
169
|
-
"40": "min-h-10 py-2 typography-body-
|
|
171
|
+
"40": "min-h-10 py-2 typography-body-small-14px-regular",
|
|
170
172
|
"32": "min-h-8 py-[7px] typography-body-small-14px-regular"
|
|
171
173
|
};
|
|
172
174
|
const ITEM_DESCRIPTION_TYPOGRAPHY = {
|
|
@@ -187,19 +189,20 @@ const SelectItem = React.forwardRef(({ className, children, size, leadingIcon, a
|
|
|
187
189
|
{
|
|
188
190
|
ref,
|
|
189
191
|
className: cn(
|
|
190
|
-
"group relative flex w-full cursor-pointer select-none gap-2 rounded-
|
|
192
|
+
"group relative flex w-full cursor-pointer select-none gap-2 rounded-sm px-3 text-content-primary outline-none",
|
|
191
193
|
hasDescription ? "items-start" : "items-center",
|
|
192
194
|
ITEM_SIZE_CLASSES[itemSize],
|
|
193
195
|
hasAvatar && !hasDescription && itemSize === "32" && "py-1",
|
|
194
|
-
"focus:bg-
|
|
196
|
+
"focus:bg-interaction-hover data-highlighted:bg-interaction-hover",
|
|
195
197
|
"data-disabled:pointer-events-none data-disabled:text-content-disabled",
|
|
196
198
|
className
|
|
197
199
|
),
|
|
198
200
|
...props,
|
|
199
201
|
children: [
|
|
200
|
-
hasAvatar ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: avatar }) : hasLeadingIcon &&
|
|
202
|
+
hasAvatar ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: avatar }) : hasLeadingIcon && // In the two-line row the icon centres on the 18px title line, as in DropdownMenuItem.
|
|
203
|
+
/* @__PURE__ */ jsx(MenuRowIcon, { alignToTitle: hasDescription, children: leadingIcon }),
|
|
201
204
|
hasDescription ? /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
202
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children }) }),
|
|
205
|
+
/* @__PURE__ */ jsx("span", { className: "typography-body-small-14px-semibold truncate", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children }) }),
|
|
203
206
|
/* @__PURE__ */ jsx(
|
|
204
207
|
"span",
|
|
205
208
|
{
|
|
@@ -215,8 +218,8 @@ const SelectItem = React.forwardRef(({ className, children, size, leadingIcon, a
|
|
|
215
218
|
SelectPrimitive.ItemIndicator,
|
|
216
219
|
{
|
|
217
220
|
className: cn(
|
|
218
|
-
"ml-auto flex
|
|
219
|
-
hasDescription
|
|
221
|
+
"ml-auto flex w-4 shrink-0 items-center justify-center",
|
|
222
|
+
hasDescription ? "h-4.5 self-start" : "h-4"
|
|
220
223
|
),
|
|
221
224
|
children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4 text-content-primary group-data-[disabled]:text-content-disabled" })
|
|
222
225
|
}
|
|
@@ -244,7 +247,7 @@ const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
244
247
|
SelectPrimitive.Separator,
|
|
245
248
|
{
|
|
246
249
|
ref,
|
|
247
|
-
className: cn("
|
|
250
|
+
className: cn("my-1 h-px bg-neutral-alphas-200", className),
|
|
248
251
|
...props
|
|
249
252
|
}
|
|
250
253
|
));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.mjs","sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as SelectPrimitive from \"@radix-ui/react-select\";\nimport * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"@/utils/floatingContentCollisionPadding\";\nimport { CheckIcon } from \"../Icons/CheckIcon\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\n\n/** Select field height in pixels. */\nexport type SelectSize = \"48\" | \"40\" | \"32\";\n\n/**\n * Trigger surface. `\"default\"` is the bordered input field; `\"filled\"` is the\n * V2 Table Tab Actions pill: a `background-secondary` fill with no border and a\n * centred `content-tertiary` label, for filters that sit beside a table or chart.\n */\nexport type SelectVariant = \"default\" | \"filled\";\n\ntype SelectContextValue = {\n size: SelectSize;\n error: boolean;\n disabled?: boolean;\n};\n\nconst SelectContext = React.createContext<SelectContextValue>({\n size: \"48\",\n error: false,\n});\n\nconst TRIGGER_HEIGHT: Record<SelectSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst TRIGGER_PADDING_X: Record<SelectSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst TRIGGER_GAP: Record<SelectSize, string> = {\n \"48\": \"gap-3\",\n \"40\": \"gap-3\",\n \"32\": \"gap-2\",\n};\n\nconst TRIGGER_TYPOGRAPHY: Record<SelectSize, string> = {\n \"48\": \"typography-body-default-16px-regular\",\n \"40\": \"typography-body-default-16px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nexport interface SelectProps extends Omit<SelectPrimitive.SelectProps, \"dir\"> {\n /** Label text displayed above the trigger. Also used as the accessible name. */\n label?: string;\n /** Accessible name applied directly to the trigger button when no visible `label` is provided. */\n \"aria-label\"?: string;\n /** ID of an external element that labels the trigger button. */\n \"aria-labelledby\"?: string;\n /** Helper text displayed below the trigger. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Height of the select field in pixels. @default \"48\" */\n size?: SelectSize;\n /** Trigger surface. See {@link SelectVariant}. @default \"default\" */\n variant?: SelectVariant;\n /** Whether the field is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the trigger. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Placeholder shown when no value is selected. */\n placeholder?: string;\n /** Icon element displayed at the left side of the trigger. */\n leftIcon?: React.ReactNode;\n /** Whether the field stretches to fill its container width. @default false */\n fullWidth?: boolean;\n /** Wraps the `className` of the outermost container div. */\n className?: string;\n /** HTML `id` applied to the trigger button. Auto-generated if omitted. */\n id?: string;\n}\n\n/**\n * A select field with optional label, helper/error text, and an icon slot,\n * built on Radix UI Select for full accessibility and keyboard navigation.\n *\n * Pair with {@link SelectContent} and {@link SelectItem} to provide options.\n *\n * @example\n * ```tsx\n * <Select label=\"Country\" placeholder=\"Select a country\">\n * <SelectContent>\n * <SelectItem value=\"us\">United States</SelectItem>\n * <SelectItem value=\"uk\">United Kingdom</SelectItem>\n * </SelectContent>\n * </Select>\n * ```\n */\nexport const Select = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Trigger>,\n SelectProps\n>(\n (\n {\n label,\n helperText,\n size = \"48\",\n variant = \"default\",\n error = false,\n errorMessage,\n placeholder,\n leftIcon,\n fullWidth = false,\n className,\n id,\n disabled,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const triggerId = id ?? generatedId;\n const helperTextId = `${triggerId}-helper`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n const isFilled = variant === \"filled\";\n\n return (\n <SelectContext.Provider value={{ size, error, disabled }}>\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={triggerId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n <SelectPrimitive.Root disabled={disabled} {...props}>\n <SelectPrimitive.Trigger\n ref={ref}\n id={triggerId}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={bottomText ? helperTextId : undefined}\n aria-invalid={error || undefined}\n className={cn(\n \"flex w-full cursor-pointer items-center rounded-sm border outline-none focus-visible:shadow-focus-ring motion-safe:transition-colors\",\n TRIGGER_HEIGHT[size],\n isFilled ? \"px-2\" : TRIGGER_PADDING_X[size],\n TRIGGER_GAP[size],\n TRIGGER_TYPOGRAPHY[size],\n isFilled\n ? \"justify-center bg-background-secondary text-content-tertiary\"\n : \"justify-between bg-inputs-inputs-primary\",\n error\n ? \"border-error-content\"\n : isFilled\n ? \"border-transparent\"\n : \"border-border-primary\",\n !disabled &&\n !error &&\n (isFilled\n ? \"hover:bg-neutral-alphas-100 data-[state=open]:bg-neutral-alphas-100\"\n : \"hover:border-neutral-alphas-400 data-[state=open]:border-neutral-alphas-400\"),\n disabled && \"cursor-not-allowed opacity-50\",\n )}\n >\n <div className=\"flex min-w-0 items-center gap-2\">\n {leftIcon && (\n <span\n className=\"flex size-5 shrink-0 items-center justify-center text-content-secondary\"\n data-testid=\"left-icon\"\n >\n {leftIcon}\n </span>\n )}\n <span\n className={cn(\n \"min-w-0 flex-1 truncate [&>[data-placeholder]]:text-content-tertiary\",\n isFilled\n ? \"text-center text-content-tertiary\"\n : \"text-left text-content-primary\",\n )}\n >\n <SelectPrimitive.Value placeholder={placeholder} />\n </span>\n </div>\n\n <SelectPrimitive.Icon asChild>\n <ChevronDownIcon size={isFilled ? 16 : 24} className=\"shrink-0\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n\n {children}\n </SelectPrimitive.Root>\n\n {bottomText && (\n <p\n id={helperTextId}\n className={cn(\n \"typography-description-12px-regular px-2 pt-1 pb-0.5\",\n error ? \"text-error-content\" : \"text-content-secondary\",\n )}\n >\n {bottomText}\n </p>\n )}\n </div>\n </SelectContext.Provider>\n );\n },\n);\n\nSelect.displayName = \"Select\";\n\nexport interface SelectContentProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> {}\n\n/**\n * The dropdown panel rendered inside a portal. Place {@link SelectItem} elements\n * (and optionally {@link SelectGroup} / {@link SelectLabel}) as children.\n */\nexport const SelectContent = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Content>,\n SelectContentProps\n>(\n (\n {\n className,\n children,\n position = \"popper\",\n sideOffset = 4,\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n style,\n ...props\n },\n ref,\n ) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n position={position}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"relative w-max min-w-(--radix-select-trigger-width) max-w-(--radix-select-content-available-width) overflow-hidden rounded-sm border border-neutral-alphas-200 bg-background-primary text-content-primary shadow-[0_4px_16px_rgba(0,0,0,0.10)]\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.Viewport className=\"max-h-[var(--radix-select-content-available-height)] overflow-y-auto p-1\">\n {children}\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n ),\n);\n\nSelectContent.displayName = \"SelectContent\";\n\n/** Dropdown row height in pixels, matching the V2 Menu Item spec. */\nexport type SelectItemSize = \"40\" | \"32\";\n\nconst ITEM_SIZE_CLASSES: Record<SelectItemSize, string> = {\n \"40\": \"min-h-10 py-2 typography-body-default-16px-regular\",\n \"32\": \"min-h-8 py-[7px] typography-body-small-14px-regular\",\n};\n\nconst ITEM_DESCRIPTION_TYPOGRAPHY: Record<SelectItemSize, string> = {\n \"40\": \"typography-body-small-14px-regular\",\n \"32\": \"typography-description-12px-regular\",\n};\n\nexport interface SelectItemProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> {\n /** Row height. Defaults to the parent {@link Select} size (`48`/`40` → `40`, `32` → `32`). */\n size?: SelectItemSize;\n /** Icon (or other node) rendered before the label. Ignored when {@link SelectItemProps.avatar} is set. */\n leadingIcon?: React.ReactNode;\n /**\n * Leading avatar rendered in place of {@link SelectItemProps.leadingIcon}, for rows\n * representing a person or account. Pass an `Avatar` sized to `24`. Takes precedence over `leadingIcon`.\n */\n avatar?: React.ReactNode;\n /** Optional secondary text rendered on a second line below the label. */\n description?: React.ReactNode;\n}\n\n/**\n * Whether a `ReactNode` will actually render. Excludes `null`/`undefined` and\n * booleans so short-circuit props (e.g. `description={cond && \"…\"}`) don't flip\n * the item into a two-line/avatar layout when they resolve to `false`.\n */\nfunction isRenderableNode(node: React.ReactNode): boolean {\n return node !== null && node !== undefined && typeof node !== \"boolean\";\n}\n\n/**\n * An individual option inside {@link SelectContent}, following the V2 Menu Item spec.\n *\n * Supports a leading icon or avatar, an optional two-line layout via `description`,\n * and the standard hover / selected / disabled states. The selected row is marked\n * with a trailing check indicator.\n *\n * @example\n * ```tsx\n * <SelectItem value=\"jane\" avatar={<Avatar size={24} fallback=\"JD\" />} description=\"Product designer\">\n * Jane Doe\n * </SelectItem>\n * ```\n */\nexport const SelectItem = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Item>,\n SelectItemProps\n>(({ className, children, size, leadingIcon, avatar, description, ...props }, ref) => {\n const { size: triggerSize } = React.useContext(SelectContext);\n const itemSize: SelectItemSize = size ?? (triggerSize === \"32\" ? \"32\" : \"40\");\n const hasDescription = isRenderableNode(description);\n const hasAvatar = isRenderableNode(avatar);\n const hasLeadingIcon = isRenderableNode(leadingIcon);\n\n return (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n \"group relative flex w-full cursor-pointer select-none gap-2 rounded-xs px-3 text-content-primary outline-none\",\n hasDescription ? \"items-start\" : \"items-center\",\n ITEM_SIZE_CLASSES[itemSize],\n hasAvatar && !hasDescription && itemSize === \"32\" && \"py-1\",\n \"focus:bg-neutral-alphas-50 data-highlighted:bg-neutral-alphas-50\",\n \"data-disabled:pointer-events-none data-disabled:text-content-disabled\",\n className,\n )}\n {...props}\n >\n {hasAvatar ? (\n <span className=\"shrink-0\">{avatar}</span>\n ) : (\n hasLeadingIcon &&\n (hasDescription ? (\n <span className=\"flex shrink-0 items-center pt-0.5 [&>svg]:size-4\">{leadingIcon}</span>\n ) : (\n <span className=\"flex shrink-0 items-center [&>svg]:size-4\">{leadingIcon}</span>\n ))\n )}\n\n {hasDescription ? (\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <span className=\"truncate\">\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </span>\n <span\n className={cn(\n \"truncate text-content-secondary group-data-[disabled]:text-content-disabled\",\n ITEM_DESCRIPTION_TYPOGRAPHY[itemSize],\n )}\n >\n {description}\n </span>\n </span>\n ) : (\n <span className=\"min-w-0 flex-1 truncate\">\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </span>\n )}\n\n <SelectPrimitive.ItemIndicator\n className={cn(\n \"ml-auto flex size-4 shrink-0 items-center justify-center\",\n hasDescription && \"self-start\",\n )}\n >\n <CheckIcon className=\"size-4 text-content-primary group-data-[disabled]:text-content-disabled\" />\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n );\n});\n\nSelectItem.displayName = \"SelectItem\";\n\n/** Props for {@link SelectGroup}. */\nexport type SelectGroupProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Group>;\n\n/**\n * Groups related {@link SelectItem} elements under a {@link SelectLabel}.\n */\nexport const SelectGroup = SelectPrimitive.Group;\nSelectGroup.displayName = \"SelectGroup\";\n\nexport interface SelectLabelProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label> {}\n\n/**\n * A non-interactive label shown above a {@link SelectGroup}.\n */\nexport const SelectLabel = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Label>,\n SelectLabelProps\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn(\n \"typography-description-12px-semibold px-3 py-1.5 text-content-secondary\",\n className,\n )}\n {...props}\n />\n));\n\nSelectLabel.displayName = \"SelectLabel\";\n\nexport interface SelectSeparatorProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator> {}\n\n/** A horizontal rule that visually separates groups in {@link SelectContent}. */\nexport const SelectSeparator = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Separator>,\n SelectSeparatorProps\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 my-1 h-px bg-neutral-alphas-200\", className)}\n {...props}\n />\n));\n\nSelectSeparator.displayName = \"SelectSeparator\";\n"],"names":[],"mappings":";;;;;;;;AAuBA,MAAM,gBAAgB,MAAM,cAAkC;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AACT,CAAC;AAED,MAAM,iBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,oBAAgD;AAAA,EACpD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,cAA0C;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,qBAAiD;AAAA,EACrD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AA+CO,MAAM,SAAS,MAAM;AAAA,EAI1B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,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AS,EAAA,CACtC;AAAA,UACA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,4BAA4B,QAAQ;AAAA,cAAA;AAAA,cAGrC,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH,EAAA,CACF,IAEA,oBAAC,QAAA,EAAK,WAAU,2BACd,8BAAC,gBAAgB,UAAhB,EAA0B,SAAA,CAAS,EAAA,CACtC;AAAA,QAGF;AAAA,UAAC,gBAAgB;AAAA,UAAhB;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA,kBAAkB;AAAA,YAAA;AAAA,YAGpB,UAAA,oBAAC,WAAA,EAAU,WAAU,0EAAA,CAA0E;AAAA,UAAA;AAAA,QAAA;AAAA,MACjG;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;AAED,WAAW,cAAc;AAQlB,MAAM,cAAc,gBAAgB;AAC3C,YAAY,cAAc;AAQnB,MAAM,cAAc,MAAM,WAG/B,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1B;AAAA,EAAC,gBAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,EAAA;AACN,CACD;AAED,YAAY,cAAc;AAMnB,MAAM,kBAAkB,MAAM,WAGnC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1B;AAAA,EAAC,gBAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAW,GAAG,yCAAyC,SAAS;AAAA,IAC/D,GAAG;AAAA,EAAA;AACN,CACD;AAED,gBAAgB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Select.mjs","sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as SelectPrimitive from \"@radix-ui/react-select\";\nimport * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"@/utils/floatingContentCollisionPadding\";\nimport { CheckIcon } from \"../Icons/CheckIcon\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { IconDefaultsContext, NO_ICON_DEFAULTS } from \"../Icons/IconDefaults\";\nimport { MenuRowIcon } from \"../Icons/MenuRowIcon\";\n\n/** Select field height in pixels. */\nexport type SelectSize = \"48\" | \"40\" | \"32\";\n\n/**\n * Trigger surface. `\"default\"` is the bordered input field; `\"filled\"` is the\n * V2 Table Tab Actions pill: a `background-secondary` fill with no border and a\n * centred `content-tertiary` label, for filters that sit beside a table or chart.\n */\nexport type SelectVariant = \"default\" | \"filled\";\n\ntype SelectContextValue = {\n size: SelectSize;\n error: boolean;\n disabled?: boolean;\n};\n\nconst SelectContext = React.createContext<SelectContextValue>({\n size: \"48\",\n error: false,\n});\n\nconst TRIGGER_HEIGHT: Record<SelectSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst TRIGGER_PADDING_X: Record<SelectSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst TRIGGER_GAP: Record<SelectSize, string> = {\n \"48\": \"gap-3\",\n \"40\": \"gap-3\",\n \"32\": \"gap-2\",\n};\n\nconst TRIGGER_TYPOGRAPHY: Record<SelectSize, string> = {\n \"48\": \"typography-body-default-16px-regular\",\n \"40\": \"typography-body-default-16px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nexport interface SelectProps extends Omit<SelectPrimitive.SelectProps, \"dir\"> {\n /** Label text displayed above the trigger. Also used as the accessible name. */\n label?: string;\n /** Accessible name applied directly to the trigger button when no visible `label` is provided. */\n \"aria-label\"?: string;\n /** ID of an external element that labels the trigger button. */\n \"aria-labelledby\"?: string;\n /** Helper text displayed below the trigger. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Height of the select field in pixels. @default \"48\" */\n size?: SelectSize;\n /** Trigger surface. See {@link SelectVariant}. @default \"default\" */\n variant?: SelectVariant;\n /** Whether the field is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the trigger. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Placeholder shown when no value is selected. */\n placeholder?: string;\n /** Icon element displayed at the left side of the trigger. */\n leftIcon?: React.ReactNode;\n /** Whether the field stretches to fill its container width. @default false */\n fullWidth?: boolean;\n /** Wraps the `className` of the outermost container div. */\n className?: string;\n /** HTML `id` applied to the trigger button. Auto-generated if omitted. */\n id?: string;\n}\n\n/**\n * A select field with optional label, helper/error text, and an icon slot,\n * built on Radix UI Select for full accessibility and keyboard navigation.\n *\n * Pair with {@link SelectContent} and {@link SelectItem} to provide options.\n *\n * @example\n * ```tsx\n * <Select label=\"Country\" placeholder=\"Select a country\">\n * <SelectContent>\n * <SelectItem value=\"us\">United States</SelectItem>\n * <SelectItem value=\"uk\">United Kingdom</SelectItem>\n * </SelectContent>\n * </Select>\n * ```\n */\nexport const Select = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Trigger>,\n SelectProps\n>(\n (\n {\n label,\n helperText,\n size = \"48\",\n variant = \"default\",\n error = false,\n errorMessage,\n placeholder,\n leftIcon,\n fullWidth = false,\n className,\n id,\n disabled,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const triggerId = id ?? generatedId;\n const helperTextId = `${triggerId}-helper`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n const isFilled = variant === \"filled\";\n\n return (\n <SelectContext.Provider value={{ size, error, disabled }}>\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={triggerId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n <SelectPrimitive.Root disabled={disabled} {...props}>\n <SelectPrimitive.Trigger\n ref={ref}\n id={triggerId}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={bottomText ? helperTextId : undefined}\n aria-invalid={error || undefined}\n className={cn(\n \"flex w-full cursor-pointer items-center rounded-sm border outline-none focus-visible:shadow-focus-ring motion-safe:transition-colors\",\n TRIGGER_HEIGHT[size],\n isFilled ? \"px-2\" : TRIGGER_PADDING_X[size],\n TRIGGER_GAP[size],\n TRIGGER_TYPOGRAPHY[size],\n isFilled\n ? \"justify-center bg-background-secondary text-content-tertiary\"\n : \"justify-between bg-inputs-inputs-primary\",\n error\n ? \"border-error-content\"\n : isFilled\n ? \"border-transparent\"\n : \"border-border-primary\",\n !disabled &&\n !error &&\n (isFilled\n ? \"hover:bg-neutral-alphas-100 data-[state=open]:bg-neutral-alphas-100\"\n : \"hover:border-neutral-alphas-400 data-[state=open]:border-neutral-alphas-400\"),\n disabled && \"cursor-not-allowed opacity-50\",\n )}\n >\n <div className=\"flex min-w-0 items-center gap-2\">\n {leftIcon && (\n <span\n className=\"flex size-5 shrink-0 items-center justify-center text-content-secondary\"\n data-testid=\"left-icon\"\n >\n {leftIcon}\n </span>\n )}\n <span\n className={cn(\n \"min-w-0 flex-1 truncate [&>[data-placeholder]]:text-content-tertiary\",\n isFilled\n ? \"text-center text-content-tertiary\"\n : \"text-left text-content-primary\",\n )}\n >\n <SelectPrimitive.Value placeholder={placeholder} />\n </span>\n </div>\n\n <SelectPrimitive.Icon asChild>\n <ChevronDownIcon size={isFilled ? 16 : 24} className=\"shrink-0\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n\n {children}\n </SelectPrimitive.Root>\n\n {bottomText && (\n <p\n id={helperTextId}\n className={cn(\n \"typography-description-12px-regular px-2 pt-1 pb-0.5\",\n error ? \"text-error-content\" : \"text-content-secondary\",\n )}\n >\n {bottomText}\n </p>\n )}\n </div>\n </SelectContext.Provider>\n );\n },\n);\n\nSelect.displayName = \"Select\";\n\nexport interface SelectContentProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> {}\n\n/**\n * The dropdown panel rendered inside a portal. Place {@link SelectItem} elements\n * (and optionally {@link SelectGroup} / {@link SelectLabel}) as children.\n */\nexport const SelectContent = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Content>,\n SelectContentProps\n>(\n (\n {\n className,\n children,\n position = \"popper\",\n sideOffset = 4,\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n style,\n ...props\n },\n ref,\n ) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n position={position}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"relative w-max min-w-(--radix-select-trigger-width) max-w-(--radix-select-content-available-width) overflow-hidden rounded-md border border-border-strong bg-background-secondary text-content-primary shadow-blur-menu backdrop-blur-xs\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.Viewport className=\"max-h-[var(--radix-select-content-available-height)] overflow-y-auto p-2\">\n {/* A select opened from inside a menu row must not inherit that row's icon defaults. */}\n <IconDefaultsContext.Provider value={NO_ICON_DEFAULTS}>\n {children}\n </IconDefaultsContext.Provider>\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n ),\n);\n\nSelectContent.displayName = \"SelectContent\";\n\n/** Dropdown row height in pixels, matching the V2 Menu Item spec. */\nexport type SelectItemSize = \"40\" | \"32\";\n\nconst ITEM_SIZE_CLASSES: Record<SelectItemSize, string> = {\n \"40\": \"min-h-10 py-2 typography-body-small-14px-regular\",\n \"32\": \"min-h-8 py-[7px] typography-body-small-14px-regular\",\n};\n\nconst ITEM_DESCRIPTION_TYPOGRAPHY: Record<SelectItemSize, string> = {\n \"40\": \"typography-body-small-14px-regular\",\n \"32\": \"typography-description-12px-regular\",\n};\n\nexport interface SelectItemProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> {\n /** Row height. Defaults to the parent {@link Select} size (`48`/`40` → `40`, `32` → `32`). */\n size?: SelectItemSize;\n /**\n * Icon (or other node) rendered before the label. Ignored when {@link SelectItemProps.avatar} is set.\n * Treated like `DropdownMenuItem`'s icons: a 16px box in `Icons/Secondary`, prop-based icons filled at 16px\n * unless they set `filled` or `size` themselves.\n */\n leadingIcon?: React.ReactNode;\n /**\n * Leading avatar rendered in place of {@link SelectItemProps.leadingIcon}, for rows\n * representing a person or account. Pass an `Avatar` sized to `24`. Takes precedence over `leadingIcon`.\n */\n avatar?: React.ReactNode;\n /** Optional secondary text rendered on a second line below the label. */\n description?: React.ReactNode;\n}\n\n/**\n * Whether a `ReactNode` will actually render. Excludes `null`/`undefined` and\n * booleans so short-circuit props (e.g. `description={cond && \"…\"}`) don't flip\n * the item into a two-line/avatar layout when they resolve to `false`.\n */\nfunction isRenderableNode(node: React.ReactNode): boolean {\n return node !== null && node !== undefined && typeof node !== \"boolean\";\n}\n\n/**\n * An individual option inside {@link SelectContent}, following the V2 Menu Item spec.\n *\n * Supports a leading icon or avatar, an optional two-line layout via `description`,\n * and the standard hover / selected / disabled states. The selected row is marked\n * with a trailing check indicator.\n *\n * @example\n * ```tsx\n * <SelectItem value=\"jane\" avatar={<Avatar size={24} fallback=\"JD\" />} description=\"Product designer\">\n * Jane Doe\n * </SelectItem>\n * ```\n */\nexport const SelectItem = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Item>,\n SelectItemProps\n>(({ className, children, size, leadingIcon, avatar, description, ...props }, ref) => {\n const { size: triggerSize } = React.useContext(SelectContext);\n const itemSize: SelectItemSize = size ?? (triggerSize === \"32\" ? \"32\" : \"40\");\n const hasDescription = isRenderableNode(description);\n const hasAvatar = isRenderableNode(avatar);\n const hasLeadingIcon = isRenderableNode(leadingIcon);\n\n return (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n \"group relative flex w-full cursor-pointer select-none gap-2 rounded-sm px-3 text-content-primary outline-none\",\n hasDescription ? \"items-start\" : \"items-center\",\n ITEM_SIZE_CLASSES[itemSize],\n hasAvatar && !hasDescription && itemSize === \"32\" && \"py-1\",\n \"focus:bg-interaction-hover data-highlighted:bg-interaction-hover\",\n \"data-disabled:pointer-events-none data-disabled:text-content-disabled\",\n className,\n )}\n {...props}\n >\n {hasAvatar ? (\n <span className=\"shrink-0\">{avatar}</span>\n ) : (\n hasLeadingIcon && (\n // In the two-line row the icon centres on the 18px title line, as in DropdownMenuItem.\n <MenuRowIcon alignToTitle={hasDescription}>{leadingIcon}</MenuRowIcon>\n )\n )}\n\n {hasDescription ? (\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n {/* A 14px semibold title over the regular description, matching DropdownMenuItem's two-line row. */}\n <span className=\"typography-body-small-14px-semibold truncate\">\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </span>\n <span\n className={cn(\n \"truncate text-content-secondary group-data-[disabled]:text-content-disabled\",\n ITEM_DESCRIPTION_TYPOGRAPHY[itemSize],\n )}\n >\n {description}\n </span>\n </span>\n ) : (\n <span className=\"min-w-0 flex-1 truncate\">\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </span>\n )}\n\n <SelectPrimitive.ItemIndicator\n className={cn(\n \"ml-auto flex w-4 shrink-0 items-center justify-center\",\n hasDescription ? \"h-4.5 self-start\" : \"h-4\",\n )}\n >\n <CheckIcon className=\"size-4 text-content-primary group-data-[disabled]:text-content-disabled\" />\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n );\n});\n\nSelectItem.displayName = \"SelectItem\";\n\n/** Props for {@link SelectGroup}. */\nexport type SelectGroupProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Group>;\n\n/**\n * Groups related {@link SelectItem} elements under a {@link SelectLabel}.\n */\nexport const SelectGroup = SelectPrimitive.Group;\nSelectGroup.displayName = \"SelectGroup\";\n\nexport interface SelectLabelProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label> {}\n\n/**\n * A non-interactive label shown above a {@link SelectGroup}.\n */\nexport const SelectLabel = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Label>,\n SelectLabelProps\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn(\n \"typography-description-12px-semibold px-3 py-1.5 text-content-secondary\",\n className,\n )}\n {...props}\n />\n));\n\nSelectLabel.displayName = \"SelectLabel\";\n\nexport interface SelectSeparatorProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator> {}\n\n/** A horizontal rule that visually separates groups in {@link SelectContent}. */\nexport const SelectSeparator = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Separator>,\n SelectSeparatorProps\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn(\"my-1 h-px bg-neutral-alphas-200\", className)}\n {...props}\n />\n));\n\nSelectSeparator.displayName = \"SelectSeparator\";\n"],"names":[],"mappings":";;;;;;;;;;AAyBA,MAAM,gBAAgB,MAAM,cAAkC;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AACT,CAAC;AAED,MAAM,iBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,oBAAgD;AAAA,EACpD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,cAA0C;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,qBAAiD;AAAA,EACrD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AA+CO,MAAM,SAAS,MAAM;AAAA,EAI1B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO;AAAA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
|
+
sm: "rounded-sm",
|
|
13
|
+
md: "rounded-md",
|
|
14
|
+
lg: "rounded-lg"
|
|
15
|
+
};
|
|
11
16
|
const Skeleton = React.forwardRef(
|
|
12
|
-
({
|
|
17
|
+
({
|
|
18
|
+
className,
|
|
19
|
+
variant = "text",
|
|
20
|
+
radius,
|
|
21
|
+
animation = "pulse",
|
|
22
|
+
width,
|
|
23
|
+
height,
|
|
24
|
+
style,
|
|
25
|
+
children,
|
|
26
|
+
...props
|
|
27
|
+
}, ref) => {
|
|
13
28
|
const hasChildren = React.Children.count(children) > 0;
|
|
14
29
|
const sizeStyle = {
|
|
15
30
|
...style,
|
|
@@ -28,6 +43,7 @@ const Skeleton = React.forwardRef(
|
|
|
28
43
|
className: cn(
|
|
29
44
|
"block bg-[color-mix(in_srgb,var(--color-content-primary)_11%,var(--color-background-primary))]",
|
|
30
45
|
VARIANT_CLASSES[variant],
|
|
46
|
+
radius && RADIUS_CLASSES[radius],
|
|
31
47
|
variant === "text" && !height && !hasChildren && "h-[1em]",
|
|
32
48
|
animation === "pulse" && "animate-pulse",
|
|
33
49
|
animation === "wave" && "fv-skeleton-wave",
|