@fanvue/ui 3.23.0 → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.d.ts +94 -4
- package/dist/charts.mjs +4 -0
- package/dist/charts.mjs.map +1 -1
- package/dist/cjs/charts.cjs +4 -0
- package/dist/cjs/charts.cjs.map +1 -1
- package/dist/cjs/components/AiButton/AiButton.cjs +170 -0
- package/dist/cjs/components/AiButton/AiButton.cjs.map +1 -0
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs +170 -0
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs +24 -2
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartMetricTrend.cjs +71 -0
- package/dist/cjs/components/Chart/ChartMetricTrend.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartSkeleton.cjs +95 -0
- package/dist/cjs/components/Chart/ChartSkeleton.cjs.map +1 -0
- package/dist/cjs/components/Chip/Chip.cjs +40 -11
- package/dist/cjs/components/Chip/Chip.cjs.map +1 -1
- package/dist/cjs/components/CountryFlag/CountryFlag.cjs +91 -0
- package/dist/cjs/components/CountryFlag/CountryFlag.cjs.map +1 -0
- package/dist/cjs/components/CountryFlag/flagShapes.cjs +3358 -0
- package/dist/cjs/components/CountryFlag/flagShapes.cjs.map +1 -0
- package/dist/cjs/components/CyclingText/CyclingText.cjs +9 -26
- package/dist/cjs/components/CyclingText/CyclingText.cjs.map +1 -1
- package/dist/cjs/components/CyclingText/useCyclingMotion.cjs +53 -0
- package/dist/cjs/components/CyclingText/useCyclingMotion.cjs.map +1 -0
- package/dist/cjs/components/Demographics/Demographics.cjs +39 -0
- package/dist/cjs/components/Demographics/Demographics.cjs.map +1 -0
- package/dist/cjs/components/Drawer/Drawer.cjs +9 -1
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs +122 -16
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.cjs +11 -1
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/ProgressBar/ProgressBar.cjs +9 -1
- package/dist/cjs/components/ProgressBar/ProgressBar.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsList.cjs +123 -91
- package/dist/cjs/components/Tabs/TabsList.cjs.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs +36 -25
- package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/cjs/components/Tooltip/TooltipLabel.cjs +71 -0
- package/dist/cjs/components/Tooltip/TooltipLabel.cjs.map +1 -0
- package/dist/cjs/components/TrendPill/TrendPill.cjs +46 -0
- package/dist/cjs/components/TrendPill/TrendPill.cjs.map +1 -0
- package/dist/cjs/components/UserItem/UserItem.cjs +7 -2
- package/dist/cjs/components/UserItem/UserItem.cjs.map +1 -1
- package/dist/cjs/components/UserItem/UserItemTrailing.cjs +34 -0
- package/dist/cjs/components/UserItem/UserItemTrailing.cjs.map +1 -0
- package/dist/cjs/flags.cjs +6 -0
- package/dist/cjs/flags.cjs.map +1 -0
- package/dist/cjs/index.cjs +13 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/{components/CyclingText → utils}/usePrefersReducedMotion.cjs +14 -14
- package/dist/cjs/utils/usePrefersReducedMotion.cjs.map +1 -0
- package/dist/components/AiButton/AiButton.mjs +153 -0
- package/dist/components/AiButton/AiButton.mjs.map +1 -0
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs +153 -0
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs.map +1 -0
- package/dist/components/Chart/ChartLoadingOverlay.mjs +24 -2
- package/dist/components/Chart/ChartLoadingOverlay.mjs.map +1 -1
- package/dist/components/Chart/ChartMetricTrend.mjs +54 -0
- package/dist/components/Chart/ChartMetricTrend.mjs.map +1 -0
- package/dist/components/Chart/ChartSkeleton.mjs +78 -0
- package/dist/components/Chart/ChartSkeleton.mjs.map +1 -0
- package/dist/components/Chip/Chip.mjs +40 -11
- package/dist/components/Chip/Chip.mjs.map +1 -1
- package/dist/components/CountryFlag/CountryFlag.mjs +74 -0
- package/dist/components/CountryFlag/CountryFlag.mjs.map +1 -0
- package/dist/components/CountryFlag/flagShapes.mjs +3358 -0
- package/dist/components/CountryFlag/flagShapes.mjs.map +1 -0
- package/dist/components/CyclingText/CyclingText.mjs +9 -26
- package/dist/components/CyclingText/CyclingText.mjs.map +1 -1
- package/dist/components/CyclingText/useCyclingMotion.mjs +36 -0
- package/dist/components/CyclingText/useCyclingMotion.mjs.map +1 -0
- package/dist/components/Demographics/Demographics.mjs +22 -0
- package/dist/components/Demographics/Demographics.mjs.map +1 -0
- package/dist/components/Drawer/Drawer.mjs +9 -1
- package/dist/components/Drawer/Drawer.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.mjs +122 -16
- package/dist/components/DropdownMenu/DropdownMenu.mjs.map +1 -1
- package/dist/components/IconButton/IconButton.mjs +11 -1
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.mjs +9 -1
- package/dist/components/ProgressBar/ProgressBar.mjs.map +1 -1
- package/dist/components/Tabs/TabsList.mjs +123 -91
- package/dist/components/Tabs/TabsList.mjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.mjs +37 -26
- package/dist/components/Tooltip/Tooltip.mjs.map +1 -1
- package/dist/components/Tooltip/TooltipLabel.mjs +54 -0
- package/dist/components/Tooltip/TooltipLabel.mjs.map +1 -0
- package/dist/components/TrendPill/TrendPill.mjs +29 -0
- package/dist/components/TrendPill/TrendPill.mjs.map +1 -0
- package/dist/components/UserItem/UserItem.mjs +7 -2
- package/dist/components/UserItem/UserItem.mjs.map +1 -1
- package/dist/components/UserItem/UserItemTrailing.mjs +17 -0
- package/dist/components/UserItem/UserItemTrailing.mjs.map +1 -0
- package/dist/flags.d.ts +59 -0
- package/dist/flags.mjs +6 -0
- package/dist/flags.mjs.map +1 -0
- package/dist/index.d.ts +381 -11
- package/dist/index.mjs +14 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles/base.css +166 -0
- package/dist/styles/theme.css +12 -0
- package/dist/utils/usePrefersReducedMotion.mjs +22 -0
- package/dist/utils/usePrefersReducedMotion.mjs.map +1 -0
- package/package.json +13 -2
- package/dist/cjs/components/CyclingText/usePrefersReducedMotion.cjs.map +0 -1
- package/dist/components/CyclingText/usePrefersReducedMotion.mjs +0 -22
- package/dist/components/CyclingText/usePrefersReducedMotion.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.cjs","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\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};\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.\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 SIZE_DRIVEN_SHAPE_VARIANTS.has(variant) && size === \"24\" ? \"rounded-xs\" : \"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":["cn","React","jsxs","jsx","Count"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,mBAAmD;AAAA,EACvD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,eAA+C;AAAA,EACnD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,eAAkD;AAAA,EACtD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAOA,MAAM,iDAAiC,IAAuB;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGD,MAAM,8CAA8B,IAAuB;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,MAAM,gBAAgB;AACtB,MAAM,yBACJ;AACF,MAAM,uBAAuB;AAC7B,MAAM,mBAAmB;AAezB,MAAM,kBAA6D;AAAA,EACjE,SAAS;AAAA,IACP,SACE;AAAA,IACF,UAAU;AAAA,IACV,UACE;AAAA,IACF,kBAAkB;AAAA,EAAA;AAAA,EAEpB,WAAW;AAAA,IACT,SACE;AAAA,IACF,UAAU;AAAA,IACV,UACE;AAAA,IACF,kBAAkB;AAAA,EAAA;AAAA,EAEpB,UAAU;AAAA,IACR,SACE;AAAA,IACF,UAAU;AAAA,IACV,UACE;AAAA,IACF,kBAAkB;AAAA,EAAA;AAAA,EAEpB,SAAS;AAAA,IACP,SACE;AAAA,IAC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iB,KAAK,CAAC,MAAM,OAAO;AACrE,gBAAQ;AAAA,UACN;AAAA,QAAA;AAAA,MAEJ;AAAA,IACF;AAEA,WACEC,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL,eAAY;AAAA,QACZ;AAAA,QACA,WAAWF,GAAAA;AAAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA,2BAA2B,IAAI,OAAO,KAAK,SAAS,OAAO,eAAe;AAAA,UAC1E,aAAa,IAAI;AAAA,UACjB,kBAAkB,SAAS,QAAQ;AAAA,UACnC;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAAG,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWH,GAAAA,GAAG,6CAA6C,iBAAiB,IAAI,CAAC;AAAA,cACjF,eAAY;AAAA,cAEX,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGF,iBAAiB,UAChBG,2BAAAA;AAAAA,YAACC,MAAAA;AAAAA,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.cjs","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":["cn","React","jsxs","jsx","Count"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,mBAAmD;AAAA,EACvD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,eAA+C;AAAA,EACnD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA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S,OAClD,eACA;AAAA,UACN,aAAa,IAAI;AAAA,UACjB,kBAAkB,SAAS,QAAQ;AAAA,UACnC;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAAG,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWH,GAAAA,GAAG,6CAA6C,iBAAiB,IAAI,CAAC;AAAA,cACjF,eAAY;AAAA,cAEX,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGF,iBAAiB,UAChBG,2BAAAA;AAAAA,YAACC,MAAAA;AAAAA,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;;"}
|
|
@@ -23,10 +23,12 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
24
24
|
const TRACK_HEIGHT = {
|
|
25
25
|
default: "h-3",
|
|
26
|
+
medium: "h-2",
|
|
26
27
|
small: "h-1.5"
|
|
27
28
|
};
|
|
28
29
|
const GAP = {
|
|
29
30
|
default: "gap-3",
|
|
31
|
+
medium: "gap-2",
|
|
30
32
|
small: "gap-1"
|
|
31
33
|
};
|
|
32
34
|
function getDefaultBarColor(value) {
|
|
@@ -53,6 +55,12 @@ function resolveColors(variant, value) {
|
|
|
53
55
|
textColor: "text-content-primary",
|
|
54
56
|
trackColor: "bg-progress-bar-mono-inactive"
|
|
55
57
|
};
|
|
58
|
+
if (variant === "sky")
|
|
59
|
+
return {
|
|
60
|
+
barColor: "bg-special-chart-sky",
|
|
61
|
+
textColor: "text-content-primary",
|
|
62
|
+
trackColor: "bg-special-chart-muted-sky"
|
|
63
|
+
};
|
|
56
64
|
if (variant === "neutral")
|
|
57
65
|
return {
|
|
58
66
|
barColor: "bg-content-tertiary",
|
|
@@ -88,7 +96,7 @@ const ProgressBar = React__namespace.forwardRef(
|
|
|
88
96
|
...props
|
|
89
97
|
}, ref) => {
|
|
90
98
|
const clampedValue = Math.min(100, Math.max(0, value));
|
|
91
|
-
const isSmall = size
|
|
99
|
+
const isSmall = size !== "default";
|
|
92
100
|
const { barColor, textColor, trackColor } = resolveColors(variant, clampedValue);
|
|
93
101
|
const showHeader = title != null || showCompletion || stepsLabel != null;
|
|
94
102
|
const showFooter = leftIcon != null || helperLeft != null || helperRight != null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.cjs","sources":["../../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\n\n/** Track height — `\"default\"` (12px) or `\"small\"` (6px). */\nexport type ProgressBarSize = \"default\" | \"small\";\n/**\n * Colour mode.\n * - `\"brand\"` — V2 brand (green) fill on a tinted track.\n * - `\"mono\"` — V2 monochrome fill on a tinted track (theme-aware).\n * - `\"default\"` — legacy value-coded red/yellow/green.\n * - `\"generic\"` — legacy solid brand green on a neutral track.\n * - `\"neutral\"` — legacy theme-aware inverse colour on a neutral track.\n */\nexport type ProgressBarVariant = \"brand\" | \"mono\" | \"default\" | \"generic\" | \"neutral\";\n\nexport interface ProgressBarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** Current progress value, clamped to 0–100. */\n value: number;\n /** Track height — `\"default\"` (12px) or `\"small\"` (6px). @default \"default\" */\n size?: ProgressBarSize;\n /** Colour mode. Prefer `\"brand\"` or `\"mono\"` (V2); `\"default\"`/`\"generic\"`/`\"neutral\"` are legacy. @default \"default\" */\n variant?: ProgressBarVariant;\n /** Title content shown at the top-left of the bar. */\n title?: React.ReactNode;\n /** Whether to display the completion percentage above the track. @default false */\n showCompletion?: boolean;\n /** Steps label shown at the top-right (e.g. `\"2/8 steps\"`). */\n stepsLabel?: React.ReactNode;\n /** Helper content at the bottom-left of the bar. */\n helperLeft?: React.ReactNode;\n /** Helper content at the bottom-right of the bar. */\n helperRight?: React.ReactNode;\n /** Icon shown at the bottom-left before the helper text. */\n leftIcon?: React.ReactNode;\n /** Accessible label for the `progressbar` role. @default \"Progress\" */\n ariaLabel?: string;\n /** Human-readable text alternative for the current value (e.g. \"Step 3 of 5\"). */\n ariaValueText?: string;\n}\n\nconst TRACK_HEIGHT: Record<ProgressBarSize, string> = {\n default: \"h-3\",\n small: \"h-1.5\",\n};\n\nconst GAP: Record<ProgressBarSize, string> = {\n default: \"gap-3\",\n small: \"gap-1\",\n};\n\nfunction getDefaultBarColor(value: number): string {\n if (value >= 100) return \"bg-success-content\";\n if (value >= 40) return \"bg-warning-content\";\n return \"bg-error-content\";\n}\n\nfunction getDefaultTextColor(value: number): string {\n if (value >= 100) return \"text-success-content\";\n if (value >= 40) return \"text-warning-content\";\n return \"text-error-content\";\n}\n\nfunction resolveColors(\n variant: ProgressBarVariant,\n value: number,\n): { barColor: string; textColor: string; trackColor: string } {\n const neutralTrack = \"bg-neutral-alphas-50\";\n if (variant === \"brand\")\n return {\n barColor: \"bg-progress-bar-brand-active\",\n textColor: \"text-brand-primary-default\",\n trackColor: \"bg-progress-bar-brand-inactive\",\n };\n if (variant === \"mono\")\n return {\n barColor: \"bg-progress-bar-mono-active\",\n textColor: \"text-content-primary\",\n trackColor: \"bg-progress-bar-mono-inactive\",\n };\n if (variant === \"neutral\")\n return {\n barColor: \"bg-content-tertiary\",\n textColor: \"text-content-tertiary\",\n trackColor: neutralTrack,\n };\n if (variant === \"generic\")\n return {\n barColor: \"bg-brand-primary-default\",\n textColor: \"text-brand-primary-default\",\n trackColor: neutralTrack,\n };\n return {\n barColor: getDefaultBarColor(value),\n textColor: getDefaultTextColor(value),\n trackColor: neutralTrack,\n };\n}\n\n/**\n * A horizontal progress indicator with optional title, completion percentage,\n * step count, and helper text. The bar colour reflects progress when using the\n * `\"default\"` variant.\n *\n * @example\n * ```tsx\n * <ProgressBar value={65} title=\"Upload\" showCompletion />\n * ```\n */\nexport const ProgressBar = React.forwardRef<HTMLDivElement, ProgressBarProps>(\n (\n {\n value,\n size = \"default\",\n variant = \"default\",\n title,\n showCompletion = false,\n stepsLabel,\n helperLeft,\n helperRight,\n leftIcon,\n ariaLabel,\n ariaValueText,\n className,\n ...props\n },\n ref,\n ) => {\n const clampedValue = Math.min(100, Math.max(0, value));\n const isSmall = size === \"small\";\n const { barColor, textColor, trackColor } = resolveColors(variant, clampedValue);\n\n const showHeader = title != null || showCompletion || stepsLabel != null;\n const showFooter = leftIcon != null || helperLeft != null || helperRight != null;\n\n return (\n <div ref={ref} className={cn(\"flex w-full flex-col\", GAP[size], className)} {...props}>\n {showHeader && (\n <div className=\"flex w-full items-end justify-between\">\n {title != null && (\n <p className=\"typography-description-12px-semibold text-content-primary\">{title}</p>\n )}\n {showCompletion && (\n <span\n className={cn(\n textColor,\n isSmall ? \"typography-header-heading-sm\" : \"typography-header-heading-xl\",\n )}\n >\n {Math.round(clampedValue)}%\n </span>\n )}\n {stepsLabel != null && (\n <span className=\"typography-description-12px-regular text-content-primary\">\n {stepsLabel}\n </span>\n )}\n </div>\n )}\n\n <div\n role=\"progressbar\"\n aria-label={ariaLabel ?? \"Progress\"}\n aria-valuenow={clampedValue}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuetext={ariaValueText}\n className={cn(\"relative w-full rounded-full\", trackColor, TRACK_HEIGHT[size])}\n >\n <div\n className={cn(\n \"absolute inset-y-0 left-0 rounded-full transition-[width] duration-300 ease-in-out\",\n barColor,\n )}\n style={{ width: `${clampedValue}%` }}\n />\n </div>\n\n {showFooter && (\n <div className=\"flex w-full items-center justify-between\">\n <div className=\"flex items-center gap-1\">\n {leftIcon != null && (\n <span className=\"flex size-5 items-center justify-center\" aria-hidden=\"true\">\n {leftIcon}\n </span>\n )}\n {helperLeft != null && (\n <span className=\"typography-description-12px-regular text-content-primary\">\n {helperLeft}\n </span>\n )}\n </div>\n {helperRight != null && (\n <span className=\"typography-description-12px-regular text-content-primary\">\n {helperRight}\n </span>\n )}\n </div>\n )}\n </div>\n );\n },\n);\n\nProgressBar.displayName = \"ProgressBar\";\n"],"names":["React","jsxs","cn","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,eAAgD;AAAA,EACpD,SAAS;AAAA,EACT,OAAO;AACT;AAEA,MAAM,MAAuC;AAAA,EAC3C,SAAS;AAAA,EACT,OAAO;AACT;AAEA,SAAS,mBAAmB,OAAuB;AACjD,MAAI,SAAS,IAAK,QAAO;AACzB,MAAI,SAAS,GAAI,QAAO;AACxB,SAAO;AACT;AAEA,SAAS,oBAAoB,OAAuB;AAClD,MAAI,SAAS,IAAK,QAAO;AACzB,MAAI,SAAS,GAAI,QAAO;AACxB,SAAO;AACT;AAEA,SAAS,cACP,SACA,OAC6D;AAC7D,QAAM,eAAe;AACrB,MAAI,YAAY;AACd,WAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,IAAA;AAEhB,MAAI,YAAY;AACd,WAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,IAAA;AAEhB,MAAI,YAAY;AACd,WAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,IAAA;AAEhB,MAAI,YAAY;AACd,WAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,IAAA;AAEhB,SAAO;AAAA,IACL,UAAU,mBAAmB,KAAK;AAAA,IAClC,WAAW,oBAAoB,KAAK;AAAA,IACpC,YAAY;AAAA,EAAA;AAEhB;AAYO,MAAM,cAAcA,iBAAM;AAAA,EAC/B,CACE;AAAA,IACE;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;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EAAE,OAAO,GAAG,YAAY,IAAA;AAAA,YAAI;AAAA,UAAA;AAAA,QACrC;AAAA,MAAA;AAAA,MAGD,cACCD,2BAAAA,KAAC,OAAA,EAAI,WAAU,4CACb,UAAA;AAAA,QAAAA,2BAAAA,KAAC,OAAA,EAAI,WAAU,2BACZ,UAAA;AAAA,UAAA,YAAY,QACXE,+BAAC,QAAA,EAAK,WAAU,2CAA0C,eAAY,QACnE,UAAA,SAAA,CACH;AAAA,UAED,cAAc,QACbA,2BAAAA,IAAC,QAAA,EAAK,WAAU,4DACb,UAAA,WAAA,CACH;AAAA,QAAA,GAEJ;AAAA,QACC,eAAe,QACdA,2BAAAA,IAAC,QAAA,EAAK,WAAU,4DACb,UAAA,YAAA,CACH;AAAA,MAAA,EAAA,CAEJ;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"ProgressBar.cjs","sources":["../../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\n\n/** Track height — `\"default\"` (12px), `\"medium\"` (8px) or `\"small\"` (6px). */\nexport type ProgressBarSize = \"default\" | \"medium\" | \"small\";\n/**\n * Colour mode.\n * - `\"brand\"` — V2 brand (green) fill on a tinted track.\n * - `\"mono\"` — V2 monochrome fill on a tinted track (theme-aware).\n * - `\"default\"` — legacy value-coded red/yellow/green.\n * - `\"generic\"` — legacy solid brand green on a neutral track.\n * - `\"sky\"` — chart sky fill on the muted-sky track, for data bars such as the\n * demographics breakdown.\n * - `\"neutral\"` — legacy theme-aware inverse colour on a neutral track.\n */\nexport type ProgressBarVariant = \"brand\" | \"mono\" | \"sky\" | \"default\" | \"generic\" | \"neutral\";\n\nexport interface ProgressBarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** Current progress value, clamped to 0–100. */\n value: number;\n /** Track height — `\"default\"` (12px), `\"medium\"` (8px) or `\"small\"` (6px). @default \"default\" */\n size?: ProgressBarSize;\n /** Colour mode. Prefer `\"brand\"` or `\"mono\"` (V2); `\"default\"`/`\"generic\"`/`\"neutral\"` are legacy. @default \"default\" */\n variant?: ProgressBarVariant;\n /** Title content shown at the top-left of the bar. */\n title?: React.ReactNode;\n /** Whether to display the completion percentage above the track. @default false */\n showCompletion?: boolean;\n /** Steps label shown at the top-right (e.g. `\"2/8 steps\"`). */\n stepsLabel?: React.ReactNode;\n /** Helper content at the bottom-left of the bar. */\n helperLeft?: React.ReactNode;\n /** Helper content at the bottom-right of the bar. */\n helperRight?: React.ReactNode;\n /** Icon shown at the bottom-left before the helper text. */\n leftIcon?: React.ReactNode;\n /** Accessible label for the `progressbar` role. @default \"Progress\" */\n ariaLabel?: string;\n /** Human-readable text alternative for the current value (e.g. \"Step 3 of 5\"). */\n ariaValueText?: string;\n}\n\nconst TRACK_HEIGHT: Record<ProgressBarSize, string> = {\n default: \"h-3\",\n medium: \"h-2\",\n small: \"h-1.5\",\n};\n\nconst GAP: Record<ProgressBarSize, string> = {\n default: \"gap-3\",\n medium: \"gap-2\",\n small: \"gap-1\",\n};\n\nfunction getDefaultBarColor(value: number): string {\n if (value >= 100) return \"bg-success-content\";\n if (value >= 40) return \"bg-warning-content\";\n return \"bg-error-content\";\n}\n\nfunction getDefaultTextColor(value: number): string {\n if (value >= 100) return \"text-success-content\";\n if (value >= 40) return \"text-warning-content\";\n return \"text-error-content\";\n}\n\nfunction resolveColors(\n variant: ProgressBarVariant,\n value: number,\n): { barColor: string; textColor: string; trackColor: string } {\n const neutralTrack = \"bg-neutral-alphas-50\";\n if (variant === \"brand\")\n return {\n barColor: \"bg-progress-bar-brand-active\",\n textColor: \"text-brand-primary-default\",\n trackColor: \"bg-progress-bar-brand-inactive\",\n };\n if (variant === \"mono\")\n return {\n barColor: \"bg-progress-bar-mono-active\",\n textColor: \"text-content-primary\",\n trackColor: \"bg-progress-bar-mono-inactive\",\n };\n if (variant === \"sky\")\n return {\n barColor: \"bg-special-chart-sky\",\n textColor: \"text-content-primary\",\n trackColor: \"bg-special-chart-muted-sky\",\n };\n if (variant === \"neutral\")\n return {\n barColor: \"bg-content-tertiary\",\n textColor: \"text-content-tertiary\",\n trackColor: neutralTrack,\n };\n if (variant === \"generic\")\n return {\n barColor: \"bg-brand-primary-default\",\n textColor: \"text-brand-primary-default\",\n trackColor: neutralTrack,\n };\n return {\n barColor: getDefaultBarColor(value),\n textColor: getDefaultTextColor(value),\n trackColor: neutralTrack,\n };\n}\n\n/**\n * A horizontal progress indicator with optional title, completion percentage,\n * step count, and helper text. The bar colour reflects progress when using the\n * `\"default\"` variant.\n *\n * @example\n * ```tsx\n * <ProgressBar value={65} title=\"Upload\" showCompletion />\n * ```\n */\nexport const ProgressBar = React.forwardRef<HTMLDivElement, ProgressBarProps>(\n (\n {\n value,\n size = \"default\",\n variant = \"default\",\n title,\n showCompletion = false,\n stepsLabel,\n helperLeft,\n helperRight,\n leftIcon,\n ariaLabel,\n ariaValueText,\n className,\n ...props\n },\n ref,\n ) => {\n const clampedValue = Math.min(100, Math.max(0, value));\n // `medium` groups with `small`: both are compact bars, so the completion\n // figure uses the smaller heading rather than the display size.\n const isSmall = size !== \"default\";\n const { barColor, textColor, trackColor } = resolveColors(variant, clampedValue);\n\n const showHeader = title != null || showCompletion || stepsLabel != null;\n const showFooter = leftIcon != null || helperLeft != null || helperRight != null;\n\n return (\n <div ref={ref} className={cn(\"flex w-full flex-col\", GAP[size], className)} {...props}>\n {showHeader && (\n <div className=\"flex w-full items-end justify-between\">\n {title != null && (\n <p className=\"typography-description-12px-semibold text-content-primary\">{title}</p>\n )}\n {showCompletion && (\n <span\n className={cn(\n textColor,\n isSmall ? \"typography-header-heading-sm\" : \"typography-header-heading-xl\",\n )}\n >\n {Math.round(clampedValue)}%\n </span>\n )}\n {stepsLabel != null && (\n <span className=\"typography-description-12px-regular text-content-primary\">\n {stepsLabel}\n </span>\n )}\n </div>\n )}\n\n <div\n role=\"progressbar\"\n aria-label={ariaLabel ?? \"Progress\"}\n aria-valuenow={clampedValue}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuetext={ariaValueText}\n className={cn(\"relative w-full rounded-full\", trackColor, TRACK_HEIGHT[size])}\n >\n <div\n className={cn(\n \"absolute inset-y-0 left-0 rounded-full transition-[width] duration-300 ease-in-out\",\n barColor,\n )}\n style={{ width: `${clampedValue}%` }}\n />\n </div>\n\n {showFooter && (\n <div className=\"flex w-full items-center justify-between\">\n <div className=\"flex items-center gap-1\">\n {leftIcon != null && (\n <span className=\"flex size-5 items-center justify-center\" aria-hidden=\"true\">\n {leftIcon}\n </span>\n )}\n {helperLeft != null && (\n <span className=\"typography-description-12px-regular text-content-primary\">\n {helperLeft}\n </span>\n )}\n </div>\n {helperRight != null && (\n <span className=\"typography-description-12px-regular text-content-primary\">\n {helperRight}\n </span>\n )}\n </div>\n )}\n </div>\n );\n },\n);\n\nProgressBar.displayName = \"ProgressBar\";\n"],"names":["React","jsxs","cn","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,eAAgD;AAAA,EACpD,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AACT;AAEA,MAAM,MAAuC;AAAA,EAC3C,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AACT;AAEA,SAAS,mBAAmB,OAAuB;AACjD,MAAI,SAAS,IAAK,QAAO;AACzB,MAAI,SAAS,GAAI,QAAO;AACxB,SAAO;AACT;AAEA,SAAS,oBAAoB,OAAuB;AAClD,MAAI,SAAS,IAAK,QAAO;AACzB,MAAI,SAAS,GAAI,QAAO;AACxB,SAAO;AACT;AAEA,SAAS,cACP,SACA,OAC6D;AAC7D,QAAM,eAAe;AACrB,MAAI,YAAY;AACd,WAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,IAAA;AAEhB,MAAI,YAAY;AACd,WAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,YA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eft === "string") return `${base} ${alignLeftClasses[alignLeft]}`;
|
|
40
40
|
return base;
|
|
41
41
|
}
|
|
42
|
-
const TabsList = React__namespace.forwardRef(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
indicator
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
42
|
+
const TabsList = React__namespace.forwardRef(
|
|
43
|
+
({
|
|
44
|
+
className,
|
|
45
|
+
children,
|
|
46
|
+
fullWidth = true,
|
|
47
|
+
alignLeft,
|
|
48
|
+
variant,
|
|
49
|
+
flushLeft = false,
|
|
50
|
+
scrollable = false,
|
|
51
|
+
...props
|
|
52
|
+
}, ref) => {
|
|
53
|
+
const innerRef = React__namespace.useRef(null);
|
|
54
|
+
const indicatorRef = React__namespace.useRef(null);
|
|
55
|
+
React__namespace.useImperativeHandle(ref, () => innerRef.current);
|
|
56
|
+
const updateIndicator = React__namespace.useCallback(() => {
|
|
57
|
+
const list = innerRef.current;
|
|
58
|
+
const indicator = indicatorRef.current;
|
|
59
|
+
if (!list || !indicator) return;
|
|
60
|
+
const activeTab = list.querySelector('[data-state="active"]');
|
|
61
|
+
if (!activeTab) {
|
|
62
|
+
indicator.style.opacity = "0";
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const isVertical = list.dataset.orientation === "vertical";
|
|
66
|
+
indicator.style.opacity = "1";
|
|
67
|
+
if (isVertical) {
|
|
68
|
+
indicator.style.background = "linear-gradient(180deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)";
|
|
69
|
+
indicator.style.inset = `0 -1px auto auto`;
|
|
70
|
+
indicator.style.width = "1px";
|
|
71
|
+
indicator.style.height = `${activeTab.offsetHeight}px`;
|
|
72
|
+
indicator.style.transform = `translateY(${activeTab.offsetTop}px)`;
|
|
73
|
+
} else {
|
|
74
|
+
indicator.style.background = "linear-gradient(90deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)";
|
|
75
|
+
const textSpan = activeTab.querySelector("span");
|
|
76
|
+
const target = textSpan ?? activeTab;
|
|
77
|
+
const textWidth = target.getBoundingClientRect().width;
|
|
78
|
+
const textOffsetInTab = target === activeTab ? 0 : target.getBoundingClientRect().left - activeTab.getBoundingClientRect().left;
|
|
79
|
+
const indicatorLeft = activeTab.offsetLeft + textOffsetInTab;
|
|
80
|
+
indicator.style.inset = "auto auto 0 0";
|
|
81
|
+
indicator.style.height = "1px";
|
|
82
|
+
indicator.style.width = `${textWidth}px`;
|
|
83
|
+
indicator.style.transform = `translateX(${indicatorLeft}px)`;
|
|
84
|
+
}
|
|
85
|
+
}, []);
|
|
86
|
+
const revealActiveTab = React__namespace.useCallback(() => {
|
|
87
|
+
const list = innerRef.current;
|
|
88
|
+
if (!list || !scrollable || list.dataset.orientation === "vertical") return;
|
|
89
|
+
const activeTab = list.querySelector('[data-state="active"]');
|
|
90
|
+
if (!activeTab) return;
|
|
91
|
+
const overshoot = activeTab.offsetLeft + activeTab.offsetWidth - list.clientWidth;
|
|
92
|
+
if (overshoot > list.scrollLeft) list.scrollLeft = overshoot;
|
|
93
|
+
}, [scrollable]);
|
|
94
|
+
React__namespace.useLayoutEffect(() => {
|
|
95
|
+
const list = innerRef.current;
|
|
96
|
+
const indicator = indicatorRef.current;
|
|
97
|
+
if (!list || !indicator) return;
|
|
98
|
+
indicator.style.transitionDuration = "0s";
|
|
99
|
+
updateIndicator();
|
|
100
|
+
indicator.getBoundingClientRect();
|
|
101
|
+
indicator.style.transitionDuration = "";
|
|
102
|
+
revealActiveTab();
|
|
103
|
+
const mutationObserver = new MutationObserver(updateIndicator);
|
|
104
|
+
mutationObserver.observe(list, {
|
|
105
|
+
attributes: true,
|
|
106
|
+
attributeFilter: ["data-state"],
|
|
107
|
+
childList: true,
|
|
108
|
+
subtree: true
|
|
96
109
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
cancelled =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
110
|
+
const resizeObserver = new ResizeObserver(updateIndicator);
|
|
111
|
+
resizeObserver.observe(list);
|
|
112
|
+
let cancelled = false;
|
|
113
|
+
if (document.fonts?.status !== "loaded") {
|
|
114
|
+
document.fonts?.ready.then(() => {
|
|
115
|
+
if (cancelled) return;
|
|
116
|
+
updateIndicator();
|
|
117
|
+
revealActiveTab();
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return () => {
|
|
121
|
+
cancelled = true;
|
|
122
|
+
mutationObserver.disconnect();
|
|
123
|
+
resizeObserver.disconnect();
|
|
124
|
+
};
|
|
125
|
+
}, [updateIndicator, revealActiveTab]);
|
|
126
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
127
|
+
TabsPrimitive__namespace.List,
|
|
128
|
+
{
|
|
129
|
+
ref: innerRef,
|
|
130
|
+
className: cn.cn(
|
|
131
|
+
// `isolate` scopes the active indicator's `z-10` to a local stacking
|
|
132
|
+
// context. Without it, `relative` alone creates no stacking context, so
|
|
133
|
+
// the indicator escapes and paints above page chrome (e.g. the header).
|
|
134
|
+
"relative isolate",
|
|
135
|
+
getLayoutClass(variant, fullWidth, alignLeft),
|
|
136
|
+
// Horizontal only: in the vertical orientation the leading padding is
|
|
137
|
+
// the row's left inset, not a label offset, so zeroing it would pull
|
|
138
|
+
// the first label out of line with the others.
|
|
139
|
+
flushLeft && "data-[orientation=horizontal]:[&>[role=tab]:first-child]:pl-0",
|
|
140
|
+
// `flex-none` is what stops the tabs compressing — without it they
|
|
141
|
+
// share the row and never overflow, so there is nothing to scroll.
|
|
142
|
+
// The scrollbar is hidden in both engines: Firefox reads
|
|
143
|
+
// `scrollbar-width`, WebKit and Blink the pseudo-element.
|
|
144
|
+
scrollable && "data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:[scrollbar-width:none] data-[orientation=horizontal]:[&::-webkit-scrollbar]:hidden data-[orientation=horizontal]:[&>[role=tab]]:flex-none",
|
|
145
|
+
"data-[orientation=horizontal]:items-center data-[orientation=horizontal]:shadow-[inset_0_-1px_0_0_var(--color-border-primary)]",
|
|
146
|
+
"data-[orientation=vertical]:flex-col data-[orientation=vertical]:shadow-[inset_-1px_0_0_0_var(--color-border-primary)]",
|
|
147
|
+
className
|
|
148
|
+
),
|
|
149
|
+
...props,
|
|
150
|
+
children: [
|
|
151
|
+
children,
|
|
152
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
153
|
+
"span",
|
|
154
|
+
{
|
|
155
|
+
ref: indicatorRef,
|
|
156
|
+
"aria-hidden": true,
|
|
157
|
+
className: "pointer-events-none absolute z-10 rounded-full motion-safe:transition-[transform,width,height] motion-safe:duration-200 motion-safe:ease-in-out",
|
|
158
|
+
style: { opacity: 0 }
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
);
|
|
134
166
|
TabsList.displayName = "TabsList";
|
|
135
167
|
exports.TabsList = TabsList;
|
|
136
168
|
//# sourceMappingURL=TabsList.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsList.cjs","sources":["../../../../src/components/Tabs/TabsList.tsx"],"sourcesContent":["import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Breakpoint values for responsive props. */\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\";\n\nconst alignLeftClasses: Record<Breakpoint | \"always\", string> = {\n always: \"[&>[role=tab]]:flex-initial\",\n sm: \"[&>[role=tab]]:sm:flex-initial\",\n md: \"[&>[role=tab]]:md:flex-initial\",\n lg: \"[&>[role=tab]]:lg:flex-initial\",\n xl: \"[&>[role=tab]]:xl:flex-initial\",\n};\n\nfunction getLayoutClass(\n variant: \"fill\" | \"hug\" | undefined,\n fullWidth: boolean,\n alignLeft?: boolean | Breakpoint,\n): string {\n if (variant === \"hug\") return \"inline-flex\";\n if (variant === \"fill\") return \"flex w-full [&>[role=tab]]:flex-1\";\n\n if (!fullWidth) return \"inline-flex\";\n\n const base = \"flex w-full [&>[role=tab]]:flex-1\";\n if (alignLeft === true) return `${base} ${alignLeftClasses.always}`;\n if (typeof alignLeft === \"string\") return `${base} ${alignLeftClasses[alignLeft]}`;\n return base;\n}\n\n/** Props for the {@link TabsList} component. */\nexport type TabsListProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> & {\n /** When `true` (the default), the tab list spans the full width of its container and each tab grows equally. Set to `false` for inline sizing. */\n fullWidth?: boolean;\n /**\n * Controls tab alignment within a full-width container.\n * - `false` (default): tabs spread evenly\n * - `true`: tabs left-aligned, sized to content\n * - `\"md\"` (breakpoint): spread on mobile, left-aligned at breakpoint and up\n */\n alignLeft?: boolean | Breakpoint;\n /** Explicit layout variant. `\"hug\"` sizes the list to its content; `\"fill\"` stretches it full-width with equal-width tabs. Takes precedence over `fullWidth`/`alignLeft`. */\n variant?: \"fill\" | \"hug\";\n};\n\n/** Container for {@link TabsTrigger} elements. Renders a sliding active-tab indicator that animates between tabs. */\nexport const TabsList = React.forwardRef<\n React.ComponentRef<typeof TabsPrimitive.List>,\n TabsListProps\n>(({ className, children, fullWidth = true, alignLeft, variant, ...props }, ref) => {\n const innerRef = React.useRef<HTMLDivElement>(null);\n const indicatorRef = React.useRef<HTMLSpanElement>(null);\n\n React.useImperativeHandle(ref, () => innerRef.current as HTMLDivElement);\n\n const updateIndicator = React.useCallback(() => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n\n const activeTab = list.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (!activeTab) {\n indicator.style.opacity = \"0\";\n return;\n }\n\n const isVertical = list.dataset.orientation === \"vertical\";\n\n indicator.style.opacity = \"1\";\n\n if (isVertical) {\n indicator.style.background =\n \"linear-gradient(180deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)\";\n indicator.style.inset = `0 -1px auto auto`;\n indicator.style.width = \"1px\";\n indicator.style.height = `${activeTab.offsetHeight}px`;\n indicator.style.transform = `translateY(${activeTab.offsetTop}px)`;\n } else {\n indicator.style.background =\n \"linear-gradient(90deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)\";\n const textSpan = activeTab.querySelector(\"span\");\n const textWidth = (textSpan ?? activeTab).getBoundingClientRect().width;\n const tabCenter = activeTab.offsetLeft + activeTab.offsetWidth / 2;\n const indicatorLeft = tabCenter - textWidth / 2;\n indicator.style.inset = \"auto auto 0 0\";\n indicator.style.height = \"1px\";\n indicator.style.width = `${textWidth}px`;\n indicator.style.transform = `translateX(${indicatorLeft}px)`;\n }\n }, []);\n\n React.useLayoutEffect(() => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n\n indicator.style.transitionDuration = \"0s\";\n updateIndicator();\n indicator.getBoundingClientRect();\n indicator.style.transitionDuration = \"\";\n\n const mutationObserver = new MutationObserver(updateIndicator);\n mutationObserver.observe(list, {\n attributes: true,\n attributeFilter: [\"data-state\"],\n childList: true,\n subtree: true,\n });\n\n const resizeObserver = new ResizeObserver(updateIndicator);\n resizeObserver.observe(list);\n\n let cancelled = false;\n if (document.fonts?.status !== \"loaded\") {\n document.fonts?.ready.then(() => {\n if (!cancelled) updateIndicator();\n });\n }\n\n return () => {\n cancelled = true;\n mutationObserver.disconnect();\n resizeObserver.disconnect();\n };\n }, [updateIndicator]);\n\n return (\n <TabsPrimitive.List\n ref={innerRef}\n className={cn(\n // `isolate` scopes the active indicator's `z-10` to a local stacking\n // context. Without it, `relative` alone creates no stacking context, so\n // the indicator escapes and paints above page chrome (e.g. the header).\n \"relative isolate\",\n getLayoutClass(variant, fullWidth, alignLeft),\n \"data-[orientation=horizontal]:items-center data-[orientation=horizontal]:shadow-[inset_0_-1px_0_0_var(--color-border-primary)]\",\n \"data-[orientation=vertical]:flex-col data-[orientation=vertical]:shadow-[inset_-1px_0_0_0_var(--color-border-primary)]\",\n className,\n )}\n {...props}\n >\n {children}\n <span\n ref={indicatorRef}\n aria-hidden\n className=\"pointer-events-none absolute z-10 rounded-full motion-safe:transition-[transform,width,height] motion-safe:duration-200 motion-safe:ease-in-out\"\n style={{ opacity: 0 }}\n />\n </TabsPrimitive.List>\n );\n});\n\nTabsList.displayName = \"TabsList\";\n"],"names":["React","jsxs","TabsPrimitive","cn","jsx"],"m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,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA;AAAA,QACDC,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAK;AAAA,YACL,eAAW;AAAA,YACX,WAAU;AAAA,YACV,OAAO,EAAE,SAAS,EAAA;AAAA,UAAE;AAAA,QAAA;AAAA,MACtB;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;AAED,SAAS,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"TabsList.cjs","sources":["../../../../src/components/Tabs/TabsList.tsx"],"sourcesContent":["import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Breakpoint values for responsive props. */\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\";\n\nconst alignLeftClasses: Record<Breakpoint | \"always\", string> = {\n always: \"[&>[role=tab]]:flex-initial\",\n sm: \"[&>[role=tab]]:sm:flex-initial\",\n md: \"[&>[role=tab]]:md:flex-initial\",\n lg: \"[&>[role=tab]]:lg:flex-initial\",\n xl: \"[&>[role=tab]]:xl:flex-initial\",\n};\n\nfunction getLayoutClass(\n variant: \"fill\" | \"hug\" | undefined,\n fullWidth: boolean,\n alignLeft?: boolean | Breakpoint,\n): string {\n if (variant === \"hug\") return \"inline-flex\";\n if (variant === \"fill\") return \"flex w-full [&>[role=tab]]:flex-1\";\n\n if (!fullWidth) return \"inline-flex\";\n\n const base = \"flex w-full [&>[role=tab]]:flex-1\";\n if (alignLeft === true) return `${base} ${alignLeftClasses.always}`;\n if (typeof alignLeft === \"string\") return `${base} ${alignLeftClasses[alignLeft]}`;\n return base;\n}\n\n/** Props for the {@link TabsList} component. */\nexport type TabsListProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> & {\n /** When `true` (the default), the tab list spans the full width of its container and each tab grows equally. Set to `false` for inline sizing. */\n fullWidth?: boolean;\n /**\n * Controls tab alignment within a full-width container.\n * - `false` (default): tabs spread evenly\n * - `true`: tabs left-aligned, sized to content\n * - `\"md\"` (breakpoint): spread on mobile, left-aligned at breakpoint and up\n */\n alignLeft?: boolean | Breakpoint;\n /** Explicit layout variant. `\"hug\"` sizes the list to its content; `\"fill\"` stretches it full-width with equal-width tabs. Takes precedence over `fullWidth`/`alignLeft`. */\n variant?: \"fill\" | \"hug\";\n /**\n * Drops the leading padding on the first tab so its label sits flush with the\n * list's left edge, lining it up with page content above or below the bar\n * (a heading, for instance) rather than being indented by the tab's own\n * padding. Spacing between tabs is unaffected. Pair with `alignLeft` or\n * `variant=\"hug\"`. @default false\n */\n flushLeft?: boolean;\n /**\n * Scrolls the row horizontally when the tabs don't fit, instead of letting\n * them compress. By default a tab may shrink until its label ellipsises,\n * which on a narrow viewport can truncate every label at once; here each tab\n * keeps its natural width and the overflow scrolls. The scrollbar itself is\n * hidden — the clipped tab at the edge is the affordance.\n *\n * Because the tabs are content-sized, they no longer spread to fill the row:\n * a set that does fit sits left-aligned, as with `alignLeft`.\n *\n * Horizontal orientation only: a vertical list already grows downwards.\n * @default false\n */\n scrollable?: boolean;\n};\n\n/** Container for {@link TabsTrigger} elements. Renders a sliding active-tab indicator that animates between tabs. */\nexport const TabsList = React.forwardRef<\n React.ComponentRef<typeof TabsPrimitive.List>,\n TabsListProps\n>(\n (\n {\n className,\n children,\n fullWidth = true,\n alignLeft,\n variant,\n flushLeft = false,\n scrollable = false,\n ...props\n },\n ref,\n ) => {\n const innerRef = React.useRef<HTMLDivElement>(null);\n const indicatorRef = React.useRef<HTMLSpanElement>(null);\n\n React.useImperativeHandle(ref, () => innerRef.current as HTMLDivElement);\n\n const updateIndicator = React.useCallback(() => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n\n const activeTab = list.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (!activeTab) {\n indicator.style.opacity = \"0\";\n return;\n }\n\n const isVertical = list.dataset.orientation === \"vertical\";\n\n indicator.style.opacity = \"1\";\n\n if (isVertical) {\n indicator.style.background =\n \"linear-gradient(180deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)\";\n indicator.style.inset = `0 -1px auto auto`;\n indicator.style.width = \"1px\";\n indicator.style.height = `${activeTab.offsetHeight}px`;\n indicator.style.transform = `translateY(${activeTab.offsetTop}px)`;\n } else {\n indicator.style.background =\n \"linear-gradient(90deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)\";\n const textSpan = activeTab.querySelector(\"span\");\n const target = textSpan ?? activeTab;\n const textWidth = target.getBoundingClientRect().width;\n // Anchor to where the label actually sits, not to the tab's centre. The two\n // only coincide when the tab's horizontal padding is symmetric, which\n // `flushLeft` breaks by dropping `pl` on the first tab: the tab's centre then\n // sits `pr / 2` to the right of the label's. Measured as a difference of two\n // rects so it stays correct while a `scrollable` list is scrolled.\n const textOffsetInTab =\n target === activeTab\n ? 0\n : target.getBoundingClientRect().left - activeTab.getBoundingClientRect().left;\n const indicatorLeft = activeTab.offsetLeft + textOffsetInTab;\n indicator.style.inset = \"auto auto 0 0\";\n indicator.style.height = \"1px\";\n indicator.style.width = `${textWidth}px`;\n indicator.style.transform = `translateX(${indicatorLeft}px)`;\n }\n }, []);\n\n // Radix scrolls a tab into view when it takes focus, and mount is not focus, so\n // URL-driven state can land on a tab that is off to the right with nothing on\n // screen to say so: no indicator, and tab one showing as though it were active.\n // Assigns `scrollLeft` rather than calling `scrollIntoView`, which would also\n // scroll every ancestor and the page with it. Only ever scrolls further right, so\n // re-running it after the webfont settles corrects a short initial scroll without\n // yanking the row back from wherever the user has since dragged it.\n const revealActiveTab = React.useCallback(() => {\n const list = innerRef.current;\n if (!list || !scrollable || list.dataset.orientation === \"vertical\") return;\n const activeTab = list.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (!activeTab) return;\n const overshoot = activeTab.offsetLeft + activeTab.offsetWidth - list.clientWidth;\n if (overshoot > list.scrollLeft) list.scrollLeft = overshoot;\n }, [scrollable]);\n\n React.useLayoutEffect(() => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n\n indicator.style.transitionDuration = \"0s\";\n updateIndicator();\n indicator.getBoundingClientRect();\n indicator.style.transitionDuration = \"\";\n revealActiveTab();\n\n const mutationObserver = new MutationObserver(updateIndicator);\n mutationObserver.observe(list, {\n attributes: true,\n attributeFilter: [\"data-state\"],\n childList: true,\n subtree: true,\n });\n\n const resizeObserver = new ResizeObserver(updateIndicator);\n resizeObserver.observe(list);\n\n let cancelled = false;\n if (document.fonts?.status !== \"loaded\") {\n document.fonts?.ready.then(() => {\n if (cancelled) return;\n updateIndicator();\n // The tabs are wider once the real font is in, so the mount-time scroll can\n // fall short of the active tab. Recomputed here against the settled layout.\n revealActiveTab();\n });\n }\n\n return () => {\n cancelled = true;\n mutationObserver.disconnect();\n resizeObserver.disconnect();\n };\n }, [updateIndicator, revealActiveTab]);\n\n return (\n <TabsPrimitive.List\n ref={innerRef}\n className={cn(\n // `isolate` scopes the active indicator's `z-10` to a local stacking\n // context. Without it, `relative` alone creates no stacking context, so\n // the indicator escapes and paints above page chrome (e.g. the header).\n \"relative isolate\",\n getLayoutClass(variant, fullWidth, alignLeft),\n // Horizontal only: in the vertical orientation the leading padding is\n // the row's left inset, not a label offset, so zeroing it would pull\n // the first label out of line with the others.\n flushLeft && \"data-[orientation=horizontal]:[&>[role=tab]:first-child]:pl-0\",\n // `flex-none` is what stops the tabs compressing — without it they\n // share the row and never overflow, so there is nothing to scroll.\n // The scrollbar is hidden in both engines: Firefox reads\n // `scrollbar-width`, WebKit and Blink the pseudo-element.\n scrollable &&\n \"data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:[scrollbar-width:none] data-[orientation=horizontal]:[&::-webkit-scrollbar]:hidden data-[orientation=horizontal]:[&>[role=tab]]:flex-none\",\n \"data-[orientation=horizontal]:items-center data-[orientation=horizontal]:shadow-[inset_0_-1px_0_0_var(--color-border-primary)]\",\n \"data-[orientation=vertical]:flex-col data-[orientation=vertical]:shadow-[inset_-1px_0_0_0_var(--color-border-primary)]\",\n className,\n )}\n {...props}\n >\n {children}\n <span\n ref={indicatorRef}\n aria-hidden\n className=\"pointer-events-none absolute z-10 rounded-full motion-safe:transition-[transform,width,height] motion-safe:duration-200 motion-safe:ease-in-out\"\n style={{ opacity: 0 }}\n />\n </TabsPrimitive.List>\n );\n },\n);\n\nTabsList.displayName = \"TabsList\";\n"],"names":["React","jsxs","TabsPrimitive","cn","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,mBAA0D;AAAA,EAC9D,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,SAAS,eACP,SACA,WACA,WACQ;AACR,MAAI,YAAY,MAAO,QAAO;AAC9B,MAAI,YAAY,OAAQ,QAAO;AAE/B,MAAI,CAAC,UAAW,QAAO;AAEvB,QAAM,OAAO;AACb,MAAI,cAAc,KAAM,QAAO,GAAG,IAAI,IAAI,iBAAiB,MAAM;AACjE,MAAI,OAAO,cAAc,SAAU,QAAO,GAAG,IAAI,IAAI,iBAAiB,SAAS,CAAC;AAChF,SAAO;AACT;AAwCO,MAAM,WAAWA,iBAAM;AAAA,EAI5B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,WAAWA,iBAAM,OAAuB,IAAI;AAClD,UAAM,eAAeA,iBAAM,OAAwB,IAAI;AAEvDA,qBAAM,oBAAoB,KAAK,MAAM,SAAS,OAAyB;AAEvE,UAAM,kBAAkBA,iBAAM,YAAY,MAAM;AAC9C,YAAM,OAAO,SAAS;AACtB,YAAM,YAAY,aAAa;AAC/B,UAAI,CAAC,QAAQ,CAAC,UAAW;AAEzB,YAAM,YAAY,KA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ipPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(TooltipPrimitive);
|
|
25
25
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
-
const
|
|
26
|
+
const DEFAULT_DELAY_DURATION = 200;
|
|
27
|
+
const TooltipProvider = ({
|
|
28
|
+
delayDuration = DEFAULT_DELAY_DURATION,
|
|
29
|
+
...props
|
|
30
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Provider, { delayDuration, ...props });
|
|
31
|
+
TooltipProvider.displayName = "TooltipProvider";
|
|
27
32
|
const Tooltip = TooltipPrimitive__namespace.Root;
|
|
28
33
|
const TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|
|
29
|
-
const TooltipContent = React__namespace.forwardRef(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
-
TooltipPrimitive__namespace.Content,
|
|
39
|
-
{
|
|
40
|
-
ref,
|
|
41
|
-
side: resolvedSide,
|
|
42
|
-
align: resolvedAlign,
|
|
43
|
-
sideOffset,
|
|
44
|
-
collisionPadding: 8,
|
|
45
|
-
style: { zIndex: "var(--fanvue-ui-portal-z-index, 50)", ...style },
|
|
46
|
-
className: cn.cn(
|
|
47
|
-
"typography-description-12px-semibold max-w-[320px] rounded-sm bg-surface-primary-inverted px-4 py-2 text-content-primary-inverted shadow-[0px_1px_4px_0px_rgba(0,0,0,0.06),0px_1px_3px_0px_rgba(0,0,0,0.05)]",
|
|
48
|
-
className
|
|
49
|
-
),
|
|
50
|
-
...props
|
|
34
|
+
const TooltipContent = React__namespace.forwardRef(
|
|
35
|
+
({ className, sideOffset = 8, style, placement, side, align, title, children, ...props }, ref) => {
|
|
36
|
+
let resolvedSide = side;
|
|
37
|
+
let resolvedAlign = align ?? "center";
|
|
38
|
+
if (placement) {
|
|
39
|
+
const [parsedSide, parsedAlign] = placement.split("-");
|
|
40
|
+
resolvedSide = parsedSide;
|
|
41
|
+
resolvedAlign = parsedAlign ?? "center";
|
|
51
42
|
}
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
44
|
+
TooltipPrimitive__namespace.Content,
|
|
45
|
+
{
|
|
46
|
+
ref,
|
|
47
|
+
side: resolvedSide,
|
|
48
|
+
align: resolvedAlign,
|
|
49
|
+
sideOffset,
|
|
50
|
+
collisionPadding: 8,
|
|
51
|
+
style: { zIndex: "var(--fanvue-ui-portal-z-index, 50)", ...style },
|
|
52
|
+
className: cn.cn(
|
|
53
|
+
"typography-description-12px-semibold max-w-[320px] rounded-sm bg-surface-primary-inverted px-4 py-2 text-content-primary-inverted shadow-[0px_1px_4px_0px_rgba(0,0,0,0.06),0px_1px_3px_0px_rgba(0,0,0,0.05)]",
|
|
54
|
+
className
|
|
55
|
+
),
|
|
56
|
+
...props,
|
|
57
|
+
children: title ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-col gap-1", children: [
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: title }),
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-description-12px-regular", children })
|
|
60
|
+
] }) : children
|
|
61
|
+
}
|
|
62
|
+
) });
|
|
63
|
+
}
|
|
64
|
+
);
|
|
54
65
|
TooltipContent.displayName = "TooltipContent";
|
|
55
66
|
exports.Tooltip = Tooltip;
|
|
56
67
|
exports.TooltipContent = TooltipContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.cjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Props for the {@link TooltipProvider}. Wraps Radix `Tooltip.Provider`. */\nexport type TooltipProviderProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>;\n\n
|
|
1
|
+
{"version":3,"file":"Tooltip.cjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Props for the {@link TooltipProvider}. Wraps Radix `Tooltip.Provider`. */\nexport type TooltipProviderProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>;\n\nconst DEFAULT_DELAY_DURATION = 200;\n\n/**\n * Provides tooltip delay and skip-delay context. Wrap your app or a subtree.\n *\n * Defaults `delayDuration` to 200ms rather than inheriting Radix's 700ms, which\n * reads as unresponsive on the short hint labels this library uses tooltips for.\n * Pass `delayDuration` to override.\n *\n * Note that `TooltipLabel`, `ChartCard` and `SwitchField` each mount their own\n * provider internally, so they take this default but not an app-level override.\n */\nexport const TooltipProvider = ({\n delayDuration = DEFAULT_DELAY_DURATION,\n ...props\n}: TooltipProviderProps) => <TooltipPrimitive.Provider delayDuration={delayDuration} {...props} />;\nTooltipProvider.displayName = \"TooltipProvider\";\n\n/** Props for the {@link Tooltip} root component. */\nexport interface TooltipProps extends React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root> {\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n defaultOpen?: boolean;\n}\n\n/** Root component that manages open/close state for a single tooltip. */\nexport const Tooltip = TooltipPrimitive.Root;\n\n/** Props for the {@link TooltipTrigger} component. */\nexport type TooltipTriggerProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Trigger>;\n\n/** The element that triggers the tooltip on hover/focus. */\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\n/** Position of the tooltip relative to its trigger, combining side and alignment (MUI-style). */\nexport type TooltipPlacement =\n | \"top\"\n | \"top-start\"\n | \"top-end\"\n | \"bottom\"\n | \"bottom-start\"\n | \"bottom-end\"\n | \"left\"\n | \"left-start\"\n | \"left-end\"\n | \"right\"\n | \"right-start\"\n | \"right-end\";\n\nexport interface TooltipContentProps\n extends Omit<React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>, \"title\"> {\n /**\n * Position of the tooltip relative to the trigger. Takes precedence over `side` and `align`.\n * @default \"top\"\n */\n placement?: TooltipPlacement;\n /**\n * Optional heading above the body, for the two-row tooltip: a bold label\n * naming the thing, then a plain-weight description of it. Without it the\n * tooltip is a single bold line.\n */\n title?: React.ReactNode;\n}\n\nexport const TooltipContent = React.forwardRef<\n React.ComponentRef<typeof TooltipPrimitive.Content>,\n TooltipContentProps\n>(\n (\n { className, sideOffset = 8, style, placement, side, align, title, children, ...props },\n ref,\n ) => {\n let resolvedSide = side;\n let resolvedAlign: \"start\" | \"center\" | \"end\" = align ?? \"center\";\n if (placement) {\n const [parsedSide, parsedAlign] = placement.split(\"-\") as [\n \"top\" | \"right\" | \"bottom\" | \"left\",\n \"start\" | \"end\" | undefined,\n ];\n resolvedSide = parsedSide;\n resolvedAlign = parsedAlign ?? \"center\";\n }\n\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n ref={ref}\n side={resolvedSide}\n align={resolvedAlign}\n sideOffset={sideOffset}\n collisionPadding={8}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"typography-description-12px-semibold max-w-[320px] rounded-sm bg-surface-primary-inverted px-4 py-2 text-content-primary-inverted shadow-[0px_1px_4px_0px_rgba(0,0,0,0.06),0px_1px_3px_0px_rgba(0,0,0,0.05)]\",\n className,\n )}\n {...props}\n >\n {title ? (\n <span className=\"flex flex-col gap-1\">\n <span>{title}</span>\n <span className=\"typography-description-12px-regular\">{children}</span>\n </span>\n ) : (\n children\n )}\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n );\n },\n);\nTooltipCont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|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const cn = require("../../utils/cn.cjs");
|
|
7
|
+
const Tooltip = require("./Tooltip.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
25
|
+
const TooltipLabel = React__namespace.forwardRef(
|
|
26
|
+
({ tooltip, children, className, onClick, onPointerDown, onBlur, ...props }, ref) => {
|
|
27
|
+
const [open, setOpen] = React__namespace.useState(false);
|
|
28
|
+
const pointerTypeRef = React__namespace.useRef("");
|
|
29
|
+
const openAtTapStartRef = React__namespace.useRef(false);
|
|
30
|
+
const isTouch = () => pointerTypeRef.current === "touch";
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip.Tooltip, { open, onOpenChange: setOpen, children: [
|
|
32
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
33
|
+
"button",
|
|
34
|
+
{
|
|
35
|
+
ref,
|
|
36
|
+
type: "button",
|
|
37
|
+
className: cn.cn(
|
|
38
|
+
// `w-fit` keeps the trigger the size of its label. The button is
|
|
39
|
+
// block-level, so a column flex or grid cell would otherwise stretch it
|
|
40
|
+
// and the whole row would answer to hover with a help cursor, opening
|
|
41
|
+
// this label's tooltip from a long way away from the label.
|
|
42
|
+
"typography-body-small-14px-regular w-fit cursor-help rounded-2xs text-left text-content-secondary outline-none",
|
|
43
|
+
"hover:text-content-primary focus-visible:shadow-focus-ring",
|
|
44
|
+
className
|
|
45
|
+
),
|
|
46
|
+
onPointerDown: (event) => {
|
|
47
|
+
pointerTypeRef.current = event.pointerType;
|
|
48
|
+
openAtTapStartRef.current = open;
|
|
49
|
+
onPointerDown?.(event);
|
|
50
|
+
},
|
|
51
|
+
onClick: (event) => {
|
|
52
|
+
onClick?.(event);
|
|
53
|
+
if (!isTouch()) return;
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
setOpen(!openAtTapStartRef.current);
|
|
56
|
+
},
|
|
57
|
+
onBlur: (event) => {
|
|
58
|
+
pointerTypeRef.current = "";
|
|
59
|
+
onBlur?.(event);
|
|
60
|
+
},
|
|
61
|
+
...props,
|
|
62
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-[length:8px_1px] bg-[linear-gradient(to_right,var(--color-icons-tertiary)_0_4px,transparent_4px_8px)] bg-bottom-left bg-repeat-x", children })
|
|
63
|
+
}
|
|
64
|
+
) }),
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipContent, { title: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, children }), children: tooltip })
|
|
66
|
+
] }) });
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
TooltipLabel.displayName = "TooltipLabel";
|
|
70
|
+
exports.TooltipLabel = TooltipLabel;
|
|
71
|
+
//# sourceMappingURL=TooltipLabel.cjs.map
|