@fanvue/ui 3.33.1 → 3.34.1

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.
@@ -6,11 +6,12 @@ const reactSlot = require("@radix-ui/react-slot");
6
6
  const React = require("react");
7
7
  const cn = require("../../utils/cn.cjs");
8
8
  const Button = require("../Button/Button.cjs");
9
- const CheckCircleIcon = require("../Icons/CheckCircleIcon.cjs");
10
- const CrossIcon = require("../Icons/CrossIcon.cjs");
11
- const ErrorCircleIcon = require("../Icons/ErrorCircleIcon.cjs");
12
- const InfoCircleIcon = require("../Icons/InfoCircleIcon.cjs");
13
- const WarningTriangleIcon = require("../Icons/WarningTriangleIcon.cjs");
9
+ const IconButton = require("../IconButton/IconButton.cjs");
10
+ const AlertIcon = require("../Icons/AlertIcon.cjs");
11
+ const CloseIcon = require("../Icons/CloseIcon.cjs");
12
+ const InfoIcon = require("../Icons/InfoIcon.cjs");
13
+ const TickCircleIcon = require("../Icons/TickCircleIcon.cjs");
14
+ const WarningIcon = require("../Icons/WarningIcon.cjs");
14
15
  function _interopNamespaceDefault(e) {
15
16
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
16
17
  if (e) {
@@ -29,26 +30,67 @@ function _interopNamespaceDefault(e) {
29
30
  }
30
31
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
31
32
  const DEFAULT_ICONS = {
32
- info: /* @__PURE__ */ jsxRuntime.jsx(InfoCircleIcon.InfoCircleIcon, {}),
33
- success: /* @__PURE__ */ jsxRuntime.jsx(CheckCircleIcon.CheckCircleIcon, {}),
34
- warning: /* @__PURE__ */ jsxRuntime.jsx(WarningTriangleIcon.WarningTriangleIcon, {}),
35
- error: /* @__PURE__ */ jsxRuntime.jsx(ErrorCircleIcon.ErrorCircleIcon, {}),
36
- neutral: /* @__PURE__ */ jsxRuntime.jsx(InfoCircleIcon.InfoCircleIcon, {})
33
+ info: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon.InfoIcon, { size: 16, filled: true }),
34
+ success: /* @__PURE__ */ jsxRuntime.jsx(TickCircleIcon.TickCircleIcon, { size: 16, filled: true }),
35
+ warning: /* @__PURE__ */ jsxRuntime.jsx(AlertIcon.AlertIcon, { size: 16, filled: true }),
36
+ error: /* @__PURE__ */ jsxRuntime.jsx(WarningIcon.WarningIcon, { size: 16, filled: true }),
37
+ neutral: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon.InfoIcon, { size: 16, filled: true })
37
38
  };
38
- const CLOSE_BUTTON_CLASSES = {
39
- info: "hover:bg-info-content/10 active:bg-info-content/20 text-info-content motion-safe:transition-colors motion-safe:duration-150",
40
- success: "hover:bg-success-content/10 active:bg-success-content/20 text-success-content motion-safe:transition-colors motion-safe:duration-150",
41
- warning: "hover:bg-warning-content/10 active:bg-warning-content/20 text-warning-content motion-safe:transition-colors motion-safe:duration-150",
42
- error: "hover:bg-error-content/10 active:bg-error-content/20 text-error-content motion-safe:transition-colors motion-safe:duration-150",
43
- neutral: "hover:bg-content-secondary/10 active:bg-content-secondary/20 text-content-secondary motion-safe:transition-colors motion-safe:duration-150"
44
- };
45
- const LINK_CLASSES = {
39
+ const MESSAGE_CLASSES = {
46
40
  info: "text-alerts-info-prompt-content-info",
47
41
  success: "text-alerts-info-prompt-content-success",
48
42
  warning: "text-alerts-info-prompt-content-warning",
49
43
  error: "text-alerts-info-prompt-content-error",
50
44
  neutral: "text-content-secondary"
51
45
  };
46
+ const SURFACE_CLASSES = {
47
+ info: "bg-alerts-info-prompt-background-info text-alerts-info-prompt-icon-info",
48
+ success: "bg-alerts-info-prompt-background-success text-alerts-info-prompt-icon-success",
49
+ warning: "bg-alerts-info-prompt-background-warning text-alerts-info-prompt-icon-warning",
50
+ error: "bg-alerts-info-prompt-background-error text-alerts-info-prompt-icon-error",
51
+ neutral: "bg-alerts-info-prompt-background-neutral text-alerts-info-prompt-icon-neutral"
52
+ };
53
+ const LINK_CLASSES = "text-buttons-link-primary-default hover:text-buttons-link-primary-hover";
54
+ function AlertCta({
55
+ action,
56
+ ctaLabel,
57
+ ctaProps,
58
+ isTrailing
59
+ }) {
60
+ if (action) {
61
+ return /* @__PURE__ */ jsxRuntime.jsx(
62
+ reactSlot.Slot,
63
+ {
64
+ className: cn.cn(
65
+ "typography-body-small-14px-semibold w-fit cursor-pointer underline underline-offset-2",
66
+ isTrailing && "shrink-0",
67
+ LINK_CLASSES
68
+ ),
69
+ children: action
70
+ }
71
+ );
72
+ }
73
+ if (ctaLabel === void 0 || ctaLabel === null || ctaLabel === false) {
74
+ return null;
75
+ }
76
+ return /* @__PURE__ */ jsxRuntime.jsx(
77
+ Button.Button,
78
+ {
79
+ variant: "secondary",
80
+ size: "32",
81
+ ...ctaProps,
82
+ className: cn.cn(
83
+ // Stacked, the CTA sits in a flex column, which would otherwise stretch
84
+ // it across the whole alert. Fill on mobile, where a full-width button
85
+ // is the easier target, and hug from `sm` (850px) up. Inline, it always
86
+ // hugs so the message keeps the remaining width.
87
+ isTrailing ? "shrink-0" : "w-full sm:w-fit",
88
+ ctaProps?.className
89
+ ),
90
+ children: ctaLabel
91
+ }
92
+ );
93
+ }
52
94
  const Alert = React__namespace.forwardRef(
53
95
  ({
54
96
  className,
@@ -59,57 +101,74 @@ const Alert = React__namespace.forwardRef(
59
101
  onClose,
60
102
  closeLabel = "Close alert",
61
103
  action,
104
+ layout = "under",
105
+ ctaLabel,
106
+ ctaProps,
62
107
  children,
63
108
  ...props
64
109
  }, ref) => {
65
110
  const resolvedIcon = icon === null ? null : icon ?? DEFAULT_ICONS[variant];
111
+ const isTrailing = layout === "trailing";
66
112
  return /* @__PURE__ */ jsxRuntime.jsxs(
67
113
  "div",
68
114
  {
69
115
  ref,
70
116
  "data-testid": "alert",
71
117
  className: cn.cn(
72
- "grid gap-x-3 rounded-xs p-4 text-sm leading-[18px]",
73
- resolvedIcon && closable && "grid-cols-[auto_1fr_auto]",
74
- resolvedIcon && !closable && "grid-cols-[auto_1fr]",
75
- !resolvedIcon && closable && "grid-cols-[1fr_auto]",
76
- !resolvedIcon && !closable && "grid-cols-[1fr]",
77
- title && children ? "items-start" : "items-center",
78
- variant === "info" && "bg-info-surface text-info-content",
79
- variant === "success" && "bg-success-surface text-success-content",
80
- variant === "warning" && "bg-warning-surface text-warning-content",
81
- variant === "error" && "bg-error-surface text-error-content",
82
- variant === "neutral" && "bg-alerts-info-prompt-background-neutral text-alerts-info-prompt-icon-neutral",
118
+ // Mirrors the Figma frame: 12px inset with a 16px left inset, 24px
119
+ // from the content row to the close button, `rounded-md` radius.
120
+ "flex items-start gap-6 rounded-md p-3 pl-4 text-sm leading-[18px]",
121
+ SURFACE_CLASSES[variant],
83
122
  className
84
123
  ),
85
124
  ...props,
86
125
  children: [
87
- resolvedIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-full shrink-0 items-start", "aria-hidden": "true", children: resolvedIcon }),
88
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [
89
- /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "alert", className: "flex flex-col gap-2", children: [
90
- title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "typography-body-small-14px-semibold text-content-primary", children: title }),
91
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "typography-body-small-14px-regular text-content-primary", children })
92
- ] }),
93
- action && /* @__PURE__ */ jsxRuntime.jsx(
94
- reactSlot.Slot,
126
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-3 py-1 pr-1", children: [
127
+ resolvedIcon && // The design's icon slot is 16px, but the default variant icons
128
+ // (InfoCircleIcon and friends) ship at `size-5`, so constrain the
129
+ // glyph here — the same way IconButton sizes its own icon. The 1px
130
+ // top nudge then lands it optically centred on the first 18px line,
131
+ // as in the design's icon-wrapper.
132
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex shrink-0 items-start pt-px [&>svg]:size-4", "aria-hidden": "true", children: resolvedIcon }),
133
+ /* @__PURE__ */ jsxRuntime.jsxs(
134
+ "div",
95
135
  {
96
136
  className: cn.cn(
97
- "typography-body-small-14px-semibold w-fit cursor-pointer underline underline-offset-2",
98
- LINK_CLASSES[variant]
137
+ "flex min-w-0 flex-1",
138
+ isTrailing ? "items-center gap-6" : "flex-col gap-3"
99
139
  ),
100
- children: action
140
+ children: [
141
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "alert", className: cn.cn("flex flex-col gap-1", isTrailing && "min-w-0 flex-1"), children: [
142
+ title && /* @__PURE__ */ jsxRuntime.jsx(
143
+ "div",
144
+ {
145
+ className: cn.cn("typography-body-small-14px-semibold", MESSAGE_CLASSES[variant]),
146
+ children: title
147
+ }
148
+ ),
149
+ children ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn.cn("typography-body-small-14px-regular", MESSAGE_CLASSES[variant]), children }) : null
150
+ ] }),
151
+ /* @__PURE__ */ jsxRuntime.jsx(
152
+ AlertCta,
153
+ {
154
+ action,
155
+ ctaLabel,
156
+ ctaProps,
157
+ isTrailing
158
+ }
159
+ )
160
+ ]
101
161
  }
102
162
  )
103
163
  ] }),
104
164
  closable && /* @__PURE__ */ jsxRuntime.jsx(
105
- Button.Button,
165
+ IconButton.IconButton,
106
166
  {
107
- variant: "tertiary",
167
+ variant: "secondary",
108
168
  size: "24",
109
169
  onClick: onClose,
110
- className: cn.cn("self-start px-0", CLOSE_BUTTON_CLASSES[variant]),
111
170
  "aria-label": closeLabel,
112
- children: /* @__PURE__ */ jsxRuntime.jsx(CrossIcon.CrossIcon, {})
171
+ icon: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon.CloseIcon, { size: 16 })
113
172
  }
114
173
  )
115
174
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.cjs","sources":["../../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button/Button\";\nimport { CheckCircleIcon } from \"../Icons/CheckCircleIcon\";\nimport { CrossIcon } from \"../Icons/CrossIcon\";\nimport { ErrorCircleIcon } from \"../Icons/ErrorCircleIcon\";\nimport { InfoCircleIcon } from \"../Icons/InfoCircleIcon\";\nimport { WarningTriangleIcon } from \"../Icons/WarningTriangleIcon\";\n\n/** Visual style variant of the alert. */\nexport type AlertVariant = \"info\" | \"success\" | \"warning\" | \"error\" | \"neutral\";\n\nconst DEFAULT_ICONS: Record<AlertVariant, React.ReactNode> = {\n info: <InfoCircleIcon />,\n success: <CheckCircleIcon />,\n warning: <WarningTriangleIcon />,\n error: <ErrorCircleIcon />,\n neutral: <InfoCircleIcon />,\n};\n\nexport interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Visual style variant of the alert. @default \"info\" */\n variant?: AlertVariant;\n /** Optional title text displayed in bold above the description. */\n title?: string;\n /** Custom icon override. Pass `null` to hide the icon entirely. Each variant shows a default icon when left `undefined`. */\n icon?: React.ReactNode | null;\n /** Whether to show the close button. @default false */\n closable?: boolean;\n /** Callback fired when the close button is clicked. */\n onClose?: () => void;\n /** Accessible label for the close button. @default \"Close alert\" */\n closeLabel?: string;\n /**\n * Composable action slot rendered beneath the description, outside the\n * `role=\"alert\"` live region. Pass your own element (an `<a>`, a `next/link`\n * `<Link>`, or a `<Button>`) and it receives the variant-appropriate link\n * styling via the Radix `Slot` pattern while remaining a real link/button.\n */\n action?: React.ReactNode;\n}\n\nconst CLOSE_BUTTON_CLASSES: Record<AlertVariant, string> = {\n info: \"hover:bg-info-content/10 active:bg-info-content/20 text-info-content motion-safe:transition-colors motion-safe:duration-150\",\n success:\n \"hover:bg-success-content/10 active:bg-success-content/20 text-success-content motion-safe:transition-colors motion-safe:duration-150\",\n warning:\n \"hover:bg-warning-content/10 active:bg-warning-content/20 text-warning-content motion-safe:transition-colors motion-safe:duration-150\",\n error:\n \"hover:bg-error-content/10 active:bg-error-content/20 text-error-content motion-safe:transition-colors motion-safe:duration-150\",\n neutral:\n \"hover:bg-content-secondary/10 active:bg-content-secondary/20 text-content-secondary motion-safe:transition-colors motion-safe:duration-150\",\n};\n\nconst LINK_CLASSES: Record<AlertVariant, string> = {\n info: \"text-alerts-info-prompt-content-info\",\n success: \"text-alerts-info-prompt-content-success\",\n warning: \"text-alerts-info-prompt-content-warning\",\n error: \"text-alerts-info-prompt-content-error\",\n neutral: \"text-content-secondary\",\n};\n\n/**\n * Displays a contextual feedback message to the user.\n *\n * Supports `info`, `success`, `warning`, `error`, and `neutral` variants with a\n * default icon per variant, optional title, description, dismiss button, and an\n * optional composable `action` slot.\n *\n * Each variant renders a default icon automatically. Pass a custom `icon` to\n * override, or `icon={null}` to hide the icon entirely.\n *\n * Only the title and description live inside the `role=\"alert\"` live region.\n * The icon, `action`, and close button are rendered outside it so interactive\n * controls are announced and navigated consistently by screen readers.\n *\n * @example\n * ```tsx\n * <Alert variant=\"success\" title=\"Saved\" closable onClose={handleClose}>\n * Your changes have been saved.\n * </Alert>\n * ```\n *\n * @example\n * ```tsx\n * <Alert variant=\"neutral\" title=\"Heads up\" action={<a href=\"/docs\">Learn more</a>}>\n * A general notice with no specific sentiment.\n * </Alert>\n * ```\n *\n * @example\n * ```tsx\n * import Link from \"next/link\";\n *\n * <Alert variant=\"info\" title=\"Update available\" action={<Link href=\"/changelog\">See what's new</Link>}>\n * A new version is ready to install.\n * </Alert>\n * ```\n */\nexport const Alert = React.forwardRef<HTMLDivElement, AlertProps>(\n (\n {\n className,\n variant = \"info\",\n title,\n icon,\n closable = false,\n onClose,\n closeLabel = \"Close alert\",\n action,\n children,\n ...props\n },\n ref,\n ) => {\n const resolvedIcon = icon === null ? null : (icon ?? DEFAULT_ICONS[variant]);\n\n return (\n <div\n ref={ref}\n data-testid=\"alert\"\n className={cn(\n \"grid gap-x-3 rounded-xs p-4 text-sm leading-[18px]\",\n resolvedIcon && closable && \"grid-cols-[auto_1fr_auto]\",\n resolvedIcon && !closable && \"grid-cols-[auto_1fr]\",\n !resolvedIcon && closable && \"grid-cols-[1fr_auto]\",\n !resolvedIcon && !closable && \"grid-cols-[1fr]\",\n title && children ? \"items-start\" : \"items-center\",\n variant === \"info\" && \"bg-info-surface text-info-content\",\n variant === \"success\" && \"bg-success-surface text-success-content\",\n variant === \"warning\" && \"bg-warning-surface text-warning-content\",\n variant === \"error\" && \"bg-error-surface text-error-content\",\n variant === \"neutral\" &&\n \"bg-alerts-info-prompt-background-neutral text-alerts-info-prompt-icon-neutral\",\n className,\n )}\n {...props}\n >\n {resolvedIcon && (\n <span className=\"flex h-full shrink-0 items-start\" aria-hidden=\"true\">\n {resolvedIcon}\n </span>\n )}\n\n <div className=\"flex min-w-0 flex-col gap-2\">\n <div role=\"alert\" className=\"flex flex-col gap-2\">\n {title && (\n <div className=\"typography-body-small-14px-semibold text-content-primary\">\n {title}\n </div>\n )}\n <div className=\"typography-body-small-14px-regular text-content-primary\">\n {children}\n </div>\n </div>\n {action && (\n <Slot\n className={cn(\n \"typography-body-small-14px-semibold w-fit cursor-pointer underline underline-offset-2\",\n LINK_CLASSES[variant],\n )}\n >\n {action}\n </Slot>\n )}\n </div>\n\n {closable && (\n <Button\n variant=\"tertiary\"\n size=\"24\"\n onClick={onClose}\n className={cn(\"self-start px-0\", CLOSE_BUTTON_CLASSES[variant])}\n aria-label={closeLabel}\n >\n <CrossIcon />\n </Button>\n )}\n </div>\n );\n },\n);\n\nAlert.displayName = \"Alert\";\n"],"names":["InfoCircleIcon","CheckCircleIcon","WarningTriangleIcon","ErrorCircleIcon","React","jsxs","cn","jsx","Slot","Button","CrossIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,gBAAuD;AAAA,EAC3D,qCAAOA,eAAAA,gBAAA,EAAe;AAAA,EACtB,wCAAUC,gBAAAA,iBAAA,EAAgB;AAAA,EAC1B,wCAAUC,oBAAAA,qBAAA,EAAoB;AAAA,EAC9B,sCAAQC,gBAAAA,iBAAA,EAAgB;AAAA,EACx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AA,OACH;AAAA,cAEFA,2BAAAA,IAAC,OAAA,EAAI,WAAU,2DACZ,SAAA,CACH;AAAA,YAAA,GACF;AAAA,YACC,UACCA,2BAAAA;AAAAA,cAACC,UAAAA;AAAAA,cAAA;AAAA,gBACC,WAAWF,GAAAA;AAAAA,kBACT;AAAA,kBACA,aAAa,OAAO;AAAA,gBAAA;AAAA,gBAGrB,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,UAEC,YACCC,2BAAAA;AAAAA,YAACE,OAAAA;AAAAA,YAAA;AAAA,cACC,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,SAAS;AAAA,cACT,WAAWH,GAAAA,GAAG,mBAAmB,qBAAqB,OAAO,CAAC;AAAA,cAC9D,cAAY;AAAA,cAEZ,yCAACI,UAAAA,WAAA,CAAA,CAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QACb;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,MAAM,cAAc;;"}
1
+ {"version":3,"file":"Alert.cjs","sources":["../../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button, type ButtonProps } from \"../Button/Button\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { AlertIcon } from \"../Icons/AlertIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { InfoIcon } from \"../Icons/InfoIcon\";\nimport { TickCircleIcon } from \"../Icons/TickCircleIcon\";\nimport { WarningIcon } from \"../Icons/WarningIcon\";\n\n/** Visual style variant of the alert. */\nexport type AlertVariant = \"info\" | \"success\" | \"warning\" | \"error\" | \"neutral\";\n\n/**\n * Placement of the call-to-action relative to the message.\n *\n * - `\"under\"` stacks the action beneath the description. Use it when the CTA\n * label is long or the alert is narrow.\n * - `\"trailing\"` keeps the action inline with the message, which keeps the\n * alert compact and works best with short labels.\n */\nexport type AlertLayout = \"under\" | \"trailing\";\n\n/**\n * Per-variant default icon, mapped to the Iconography components the design\n * uses at `Size=16, Fill=Yes`. Note the design's naming: its Error variant\n * takes `Iconography / Warning` and its Warning variant takes\n * `Iconography / Alert`, which reads backwards but is what the node specifies.\n *\n * These carry dedicated 16px geometry, unlike the `*CircleIcon` set they\n * replace, whose 20px art had to be scaled down.\n */\nconst DEFAULT_ICONS: Record<AlertVariant, React.ReactNode> = {\n info: <InfoIcon size={16} filled />,\n success: <TickCircleIcon size={16} filled />,\n warning: <AlertIcon size={16} filled />,\n error: <WarningIcon size={16} filled />,\n neutral: <InfoIcon size={16} filled />,\n};\n\nexport interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Visual style variant of the alert. @default \"info\" */\n variant?: AlertVariant;\n /** Optional title text displayed in bold above the description. */\n title?: string;\n /** Custom icon override. Pass `null` to hide the icon entirely. Each variant shows a default icon when left `undefined`. */\n icon?: React.ReactNode | null;\n /** Whether to show the close button. @default false */\n closable?: boolean;\n /** Callback fired when the close button is clicked. */\n onClose?: () => void;\n /** Accessible label for the close button. @default \"Close alert\" */\n closeLabel?: string;\n /**\n * Composable action slot rendered beneath the description, outside the\n * `role=\"alert\"` live region. Pass your own element (an `<a>`, a `next/link`\n * `<Link>`, or a `<Button>`) and it receives the variant-appropriate link\n * styling via the Radix `Slot` pattern while remaining a real link/button.\n */\n action?: React.ReactNode;\n /** Placement of the call-to-action relative to the message. @default \"under\" */\n layout?: AlertLayout;\n /**\n * Label for a built-in call-to-action button, the button form of the CTA.\n * Use it when the alert asks the user to do something specific — activating a\n * feature, or completing setup — rather than pointing at more detail. Ignored\n * when `action` is set.\n */\n ctaLabel?: React.ReactNode;\n /**\n * Props forwarded to the built-in call-to-action button (e.g. `onClick`).\n * `variant` and `size` default to `secondary`/`32` and can be overridden.\n *\n * The stacked CTA is `w-full sm:w-fit`. To override the width, match the\n * modifier chain — a bare `w-auto` replaces `w-full` but leaves `sm:w-fit`\n * in place, so pass `sm:` variants too.\n */\n ctaProps?: Omit<ButtonProps, \"children\" | \"asChild\">;\n}\n\n/**\n * Title and description colour. The design binds both to\n * `Color/Alerts/Info Prompt/Content/<variant>`, and Neutral to\n * `Color/Content/Secondary` — not to `content-primary`, which reads as plain\n * black on the tinted surface.\n */\nconst MESSAGE_CLASSES: Record<AlertVariant, string> = {\n info: \"text-alerts-info-prompt-content-info\",\n success: \"text-alerts-info-prompt-content-success\",\n warning: \"text-alerts-info-prompt-content-warning\",\n error: \"text-alerts-info-prompt-content-error\",\n neutral: \"text-content-secondary\",\n};\n\n/**\n * Surface fill and icon colour, both read from the component's own design\n * variables: `Color/Alerts/Info Prompt/Background/<variant>` and\n * `Color/Alerts/Info Prompt/Icon/<variant>`.\n *\n * The `text-*` here is inherited by the icon only — the message sets its own\n * colour via {@link MESSAGE_CLASSES}. It matters that this reads the dedicated\n * icon tokens rather than the generic `*-content` ones: those agree only for\n * info, and they carry no dark-mode inversion, where the alert tokens step\n * from `*-600` in light to `*-400` in dark as the design specifies.\n */\nconst SURFACE_CLASSES: Record<AlertVariant, string> = {\n info: \"bg-alerts-info-prompt-background-info text-alerts-info-prompt-icon-info\",\n success: \"bg-alerts-info-prompt-background-success text-alerts-info-prompt-icon-success\",\n warning: \"bg-alerts-info-prompt-background-warning text-alerts-info-prompt-icon-warning\",\n error: \"bg-alerts-info-prompt-background-error text-alerts-info-prompt-icon-error\",\n neutral: \"bg-alerts-info-prompt-background-neutral text-alerts-info-prompt-icon-neutral\",\n};\n\n/**\n * CTA link treatment. The node's CTA is a `V2 Link` instance whose text binds\n * `Color/Buttons/Link/Primary/Default`, with no per-variant override on any of\n * the five — so the link takes the standard link colour rather than the alert's\n * own content tint. These are the same tokens the {@link Link} component\n * applies, including the hover step.\n */\nconst LINK_CLASSES = \"text-buttons-link-primary-default hover:text-buttons-link-primary-hover\";\n\n/**\n * The alert's call-to-action. `action` is the link form: any element passed\n * through receives the variant-appropriate link styling via Radix `Slot` while\n * staying a real link or button. `ctaLabel` is the button form. `action` wins\n * when both are set.\n */\nfunction AlertCta({\n action,\n ctaLabel,\n ctaProps,\n isTrailing,\n}: {\n action: React.ReactNode;\n ctaLabel: React.ReactNode;\n ctaProps?: AlertProps[\"ctaProps\"];\n isTrailing: boolean;\n}) {\n if (action) {\n return (\n <Slot\n className={cn(\n \"typography-body-small-14px-semibold w-fit cursor-pointer underline underline-offset-2\",\n isTrailing && \"shrink-0\",\n LINK_CLASSES,\n )}\n >\n {action}\n </Slot>\n );\n }\n\n if (ctaLabel === undefined || ctaLabel === null || ctaLabel === false) {\n return null;\n }\n\n return (\n <Button\n variant=\"secondary\"\n size=\"32\"\n {...ctaProps}\n className={cn(\n // Stacked, the CTA sits in a flex column, which would otherwise stretch\n // it across the whole alert. Fill on mobile, where a full-width button\n // is the easier target, and hug from `sm` (850px) up. Inline, it always\n // hugs so the message keeps the remaining width.\n isTrailing ? \"shrink-0\" : \"w-full sm:w-fit\",\n ctaProps?.className,\n )}\n >\n {ctaLabel}\n </Button>\n );\n}\n\n/**\n * Displays a contextual feedback message to the user.\n *\n * Supports `info`, `success`, `warning`, `error`, and `neutral` variants with a\n * default icon per variant, optional title, description, dismiss button, and an\n * optional composable `action` slot.\n *\n * Each variant renders a default icon automatically. Pass a custom `icon` to\n * override, or `icon={null}` to hide the icon entirely.\n *\n * Only the title and description live inside the `role=\"alert\"` live region.\n * The icon, `action`, and close button are rendered outside it so interactive\n * controls are announced and navigated consistently by screen readers.\n *\n * @example\n * ```tsx\n * <Alert variant=\"success\" title=\"Saved\" closable onClose={handleClose}>\n * Your changes have been saved.\n * </Alert>\n * ```\n *\n * @example\n * ```tsx\n * <Alert variant=\"neutral\" title=\"Heads up\" action={<a href=\"/docs\">Learn more</a>}>\n * A general notice with no specific sentiment.\n * </Alert>\n * ```\n *\n * @example\n * ```tsx\n * import Link from \"next/link\";\n *\n * <Alert variant=\"info\" title=\"Update available\" action={<Link href=\"/changelog\">See what's new</Link>}>\n * A new version is ready to install.\n * </Alert>\n * ```\n *\n * @example\n * The CTA sits under the description by default. `layout=\"trailing\"` keeps it\n * inline with the message, which suits short labels and keeps the alert compact.\n * ```tsx\n * <Alert variant=\"info\" layout=\"trailing\" action={<a href=\"/docs\">Learn more</a>}>\n * Scheduled posts now publish in your local timezone.\n * </Alert>\n * ```\n *\n * @example\n * `ctaLabel` renders the button form of the CTA instead of a link — use it when\n * the alert asks the user to do something specific.\n * ```tsx\n * <Alert variant=\"warning\" title=\"Finish setup\" layout=\"trailing\" ctaLabel=\"Verify now\" ctaProps={{ onClick: verify }}>\n * Verify your identity to start receiving payouts.\n * </Alert>\n * ```\n */\nexport const Alert = React.forwardRef<HTMLDivElement, AlertProps>(\n (\n {\n className,\n variant = \"info\",\n title,\n icon,\n closable = false,\n onClose,\n closeLabel = \"Close alert\",\n action,\n layout = \"under\",\n ctaLabel,\n ctaProps,\n children,\n ...props\n },\n ref,\n ) => {\n const resolvedIcon = icon === null ? null : (icon ?? DEFAULT_ICONS[variant]);\n const isTrailing = layout === \"trailing\";\n\n return (\n <div\n ref={ref}\n data-testid=\"alert\"\n className={cn(\n // Mirrors the Figma frame: 12px inset with a 16px left inset, 24px\n // from the content row to the close button, `rounded-md` radius.\n \"flex items-start gap-6 rounded-md p-3 pl-4 text-sm leading-[18px]\",\n SURFACE_CLASSES[variant],\n className,\n )}\n {...props}\n >\n {/*\n Content row. Its 4px inset is what takes the container's 12px up to the\n 16px the design specifies around the message, while leaving the close\n button on the container's own 12px. It also puts 28px between the\n message and the close button (this 4px plus the container's 24px gap).\n */}\n <div className=\"flex min-w-0 flex-1 items-start gap-3 py-1 pr-1\">\n {resolvedIcon && (\n // The design's icon slot is 16px, but the default variant icons\n // (InfoCircleIcon and friends) ship at `size-5`, so constrain the\n // glyph here — the same way IconButton sizes its own icon. The 1px\n // top nudge then lands it optically centred on the first 18px line,\n // as in the design's icon-wrapper.\n <span className=\"flex shrink-0 items-start pt-px [&>svg]:size-4\" aria-hidden=\"true\">\n {resolvedIcon}\n </span>\n )}\n\n <div\n className={cn(\n \"flex min-w-0 flex-1\",\n isTrailing ? \"items-center gap-6\" : \"flex-col gap-3\",\n )}\n >\n <div role=\"alert\" className={cn(\"flex flex-col gap-1\", isTrailing && \"min-w-0 flex-1\")}>\n {title && (\n <div\n className={cn(\"typography-body-small-14px-semibold\", MESSAGE_CLASSES[variant])}\n >\n {title}\n </div>\n )}\n {children ? (\n <div className={cn(\"typography-body-small-14px-regular\", MESSAGE_CLASSES[variant])}>\n {children}\n </div>\n ) : null}\n </div>\n <AlertCta\n action={action}\n ctaLabel={ctaLabel}\n ctaProps={ctaProps}\n isTrailing={isTrailing}\n />\n </div>\n </div>\n\n {closable && (\n <IconButton\n variant=\"secondary\"\n size=\"24\"\n onClick={onClose}\n aria-label={closeLabel}\n icon={<CloseIcon size={16} />}\n />\n )}\n </div>\n );\n },\n);\n\nAlert.displayName = \"Alert\";\n"],"names":["jsx","InfoIcon","TickCircleIcon","AlertIcon","WarningIcon","Slot","cn","Button","React","jsxs","IconButton","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,gBAAuD;AAAA,EAC3D,MAAMA,2BAAAA,IAACC,mBAAA,EAAS,MAAM,IAAI,QAAM,MAAC;AAAA,EACjC,SAASD,2BAAAA,IAACE,+BAAA,EAAe,MAAM,IAAI,QAAM,MAAC;AAAA,EAC1C,SAASF,2BAAAA,IAACG,qBAAA,EAAU,MAAM,IAAI,QAAM,MAAC;AAAA,EACrC,OAAOH,2BAAAA,IAACI,yBAAA,EAAY,MAAM,IAAI,QAAM,MAAC;AAAA,EACrC,SAASJ,2BAAAA,IAACC,mBAAA,EAAS,MAAM,IAAI,QAAM,KAAA,CAAC;AACtC;AAgDA,MAAM,kBAAgD;AAAA,EACpD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AACX;AAaA,MAAM,kBAAgD;AAAA,EACpD,MAAM;AAAA,EACN,SAAS;AAAA,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set,
186
186
  collisionPadding,
187
187
  className: cn.cn(
188
- // `rounded-sm` (12px) is the panel radius `V2 Menu Dropdown` carries
189
- // (product file node `7393:62008`). The 8px `rounded-xs` belongs to the
190
- // rows inside it, not the panel.
188
+ // Panel tokens come from `V2 Menu Dropdown` (product file node
189
+ // `7393:62008`): `rounded-lg` (24px) over `Background/Secondary`, a
190
+ // `Border/Strong` stroke, and 8px of padding. The 12px `rounded-sm` is
191
+ // the row radius, not the panel's — the two were transposed here.
191
192
  //
192
- // The `sheet` variant is deliberately not 12px: it renders through
193
- // `DrawerContent variant="menu"`, whose `MENU_CLASSES` is `rounded-lg`
194
- // (24px). A bottom sheet is a full-width surface with its own radius,
195
- // not a scaled-up popper, so the two are meant to differ.
196
- "w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-border-primary bg-surface-primary p-1 text-content-primary shadow-blur-menu backdrop-blur-[4px]",
193
+ // `backdrop-blur-[4px]` is the CSS equivalent of that node's
194
+ // `blur + shadow/menu` BACKGROUND_BLUR radius 8, which Figma halves on
195
+ // export. It is not a 4-against-8 mismatch.
196
+ "w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-lg border border-border-strong bg-background-secondary p-2 text-content-primary shadow-blur-menu backdrop-blur-[4px]",
197
197
  "data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in",
198
198
  "data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out",
199
199
  "data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2",
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenuRoot.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuRoot.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"../../utils/floatingContentCollisionPadding\";\nimport { Drawer, DrawerContent, DrawerTrigger } from \"../Drawer/Drawer\";\nimport { type DropdownMenuVariant, DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\n\n// Movement, in CSS px, above which a touch press-and-release counts as a drag.\nconst TAP_MOVEMENT_THRESHOLD_PX = 10;\n\n// Radix menus swallow Tab (a menu has no tab stops, only items), which strands\n// any non-item control rendered inside one — header actions, a search input,\n// reorder handles. Containers of such controls carry this attribute and\n// `DropdownMenuContent` cycles Tab through the focusable elements inside them.\nconst TAB_STOPS_ATTRIBUTE = \"data-dropdown-menu-tab-stops\";\nconst FOCUSABLE_SELECTOR = \"a[href], button, input, select, textarea, [tabindex]\";\n\nfunction getMenuTabStops(content: HTMLElement): HTMLElement[] {\n const stops: HTMLElement[] = [];\n for (const container of content.querySelectorAll<HTMLElement>(`[${TAB_STOPS_ATTRIBUTE}]`)) {\n for (const element of container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) {\n if (element.tabIndex < 0 || element.matches(\":disabled\") || element.hidden) continue;\n stops.push(element);\n }\n }\n return stops;\n}\n\n// Cycles focus through the menu's tab stops on Tab / Shift+Tab, skipping menu\n// items (which keep their arrow-key navigation). Returns without acting when\n// the key isn't a plain Tab, came from a nested menu, or there is nothing to\n// cycle through — Radix then swallows the key as it always has.\nfunction cycleMenuTabStops(event: React.KeyboardEvent<HTMLElement>): void {\n if (event.key !== \"Tab\" || event.altKey || event.ctrlKey || event.metaKey) return;\n // A nested menu's keydowns bubble here through React's portal tree; they are\n // the nested menu's to handle.\n const target = event.target as HTMLElement;\n if (target.closest(\"[data-radix-menu-content]\") !== event.currentTarget) return;\n const stops = getMenuTabStops(event.currentTarget);\n if (stops.length === 0) return;\n // Prevented here so Radix's own handler (which would swallow the key) is\n // skipped — Radix composes it after ours and checks `defaultPrevented`.\n event.preventDefault();\n const index = stops.indexOf(target);\n const last = stops.length - 1;\n const next = event.shiftKey\n ? stops[index <= 0 ? last : index - 1]\n : stops[index === -1 || index === last ? 0 : index + 1];\n // Radix's FocusScope also sees this Tab (after us, ignoring\n // `defaultPrevented`), but a menu's scope is trapped without `loop`, so it\n // only prevents the default — it never moves focus itself.\n next?.focus({ preventScroll: true });\n}\n\ntype ActiveTap = {\n pointerId: number;\n x: number;\n y: number;\n movedPastThreshold: boolean;\n};\n\n/** Props for the {@link DropdownMenu} root component. */\nexport interface DropdownMenuProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root> {\n /** How the menu presents its content. @default \"menu\" */\n variant?: DropdownMenuVariant;\n}\n\n/** Root component that manages open/close state for a dropdown menu. */\nexport function DropdownMenu({\n open: openProp,\n defaultOpen,\n onOpenChange,\n variant = \"menu\",\n children,\n ...props\n}: DropdownMenuProps) {\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n if (variant === \"sheet\") {\n return (\n <DropdownMenuVariantContext.Provider value=\"sheet\">\n <ToggleOpenContext.Provider value={setOpen}>\n <Drawer open={open} onOpenChange={setOpen}>\n {children}\n </Drawer>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n }\n\n return (\n <DropdownMenuVariantContext.Provider value=\"menu\">\n <ToggleOpenContext.Provider value={setOpen}>\n <DropdownMenuPrimitive.Root open={open} onOpenChange={setOpen} {...props}>\n {children}\n </DropdownMenuPrimitive.Root>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n}\n\n/** Props for the {@link DropdownMenuTrigger} component. */\nexport type DropdownMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Trigger\n>;\n\n/**\n * The element that toggles the dropdown menu when clicked.\n *\n * On touch devices, the menu only opens if the press-and-release stays within\n * a small movement threshold. A drag that incidentally ends over the trigger\n * (common when scrolling a feed on Android Chrome) is ignored. Mouse and\n * keyboard interactions are unchanged.\n */\nexport const DropdownMenuTrigger = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,\n DropdownMenuTriggerProps\n>((props, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const tapRef = React.useRef<ActiveTap | null>(null);\n\n // The sheet variant opens a Drawer (Dialog), which already suppresses\n // scroll-drag-end synthetic clicks itself — no need for the touch-tap gating below.\n if (variant === \"sheet\") {\n return <DrawerTrigger {...props} ref={ref} />;\n }\n\n // Used outside our DropdownMenu wrapper — fall through to Radix defaults.\n if (toggleOpen === null) {\n return <DropdownMenuPrimitive.Trigger {...props} ref={ref} />;\n }\n\n return (\n <DropdownMenuPrimitive.Trigger\n {...props}\n ref={ref}\n onPointerDown={(event) => {\n props.onPointerDown?.(event);\n if (event.pointerType === \"mouse\" || props.disabled) return;\n // Keep pointerup / pointercancel on this element if the finger drifts off.\n // Optional because jsdom (used in tests) doesn't implement it.\n event.currentTarget.setPointerCapture?.(event.pointerId);\n tapRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n movedPastThreshold: false,\n };\n // preventDefault stops Radix's pointerdown open path via composeEventHandlers.\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n props.onPointerMove?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId || tap.movedPastThreshold) {\n return;\n }\n const dx = event.clientX - tap.x;\n const dy = event.clientY - tap.y;\n if (Math.hypot(dx, dy) > TAP_MOVEMENT_THRESHOLD_PX) {\n tap.movedPastThreshold = true;\n }\n }}\n onPointerUp={(event) => {\n props.onPointerUp?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId) return;\n const wasDrag = tap.movedPastThreshold;\n tapRef.current = null;\n if (!wasDrag && !props.disabled) {\n toggleOpen((prev) => !prev);\n }\n }}\n onPointerCancel={(event) => {\n props.onPointerCancel?.(event);\n const tap = tapRef.current;\n if (tap !== null && event.pointerId === tap.pointerId) {\n tapRef.current = null;\n }\n }}\n />\n );\n});\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\";\n\n/** Props for the {@link DropdownMenuContent} component. */\nexport interface DropdownMenuContentProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {}\n\n/**\n * The positioned content panel rendered inside a portal.\n *\n * Override the portal z-index per-instance via `style={{ zIndex: 1500 }}` or\n * globally with the `--fanvue-ui-portal-z-index` CSS custom property.\n *\n * @example\n * ```tsx\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild>\n * <Button>Open</Button>\n * </DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Option 1</DropdownMenuItem>\n * <DropdownMenuItem>Option 2</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n * ```\n */\nexport const DropdownMenuContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Content>,\n DropdownMenuContentProps\n>(\n (\n {\n className,\n style,\n sideOffset = 4,\n // Radix defaults `avoidCollisions` to true, so passing `collisionPadding`\n // is enough to keep the menu flipping/shifting to stay on screen — no\n // hand-rolled reposition logic needed.\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n onPointerDownOutside,\n onCloseAutoFocus,\n onKeyDown,\n children,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n // Radix returns focus to the trigger when the menu closes. That is right for\n // the keyboard, but Chrome's :focus-visible heuristic also paints the ring on\n // that programmatic refocus, so dismissing with a click left a focus ring\n // sitting on the trigger. Track pointer dismissals and skip the restore for\n // them only — Escape and Tab still hand focus back with the ring.\n const dismissedByPointer = React.useRef(false);\n\n if (variant === \"sheet\") {\n return (\n <DrawerContent\n ref={ref}\n position=\"bottom\"\n // `\"sheet\"` sits flush to the bottom edge at full width; the design draws\n // this panel inset from all three sides and rounded on every corner, which\n // is `\"menu\"`. Both carry the same modal surface.\n variant=\"menu\"\n // The design's `blur + shadow/menu` effect is a background blur, and the\n // panel's own fill is opaque — so the blur has to go on the overlay to be\n // visible at all. Scoped here rather than on DrawerOverlay so only menus\n // shown this way blur the page behind them.\n overlayProps={{ className: \"backdrop-blur-[8px]\" }}\n // `pb-4` gives the design's 16px below the last row. The rows inset\n // themselves horizontally (see the item's `mx-3`) rather than the panel\n // padding doing it, so the header and its rule can still run full width.\n className={cn(\"flex flex-col gap-1 p-1 pb-4\", className)}\n style={style}\n // Both are destructured above for the popper branch's focus-ring\n // handling, which takes them out of `props` — so the sheet branch has\n // to re-attach them or they are silently dropped. `DrawerContent`\n // forwards them to its `DialogPrimitive.Content`, which supports both.\n // Consumers stack sheets on these (a nested sheet's `onCloseAutoFocus`\n // is the only point at which the parent knows the child has finished\n // animating out), so dropping them breaks the flow with no error.\n onPointerDownOutside={onPointerDownOutside}\n onCloseAutoFocus={onCloseAutoFocus}\n onKeyDown={onKeyDown}\n {...props}\n >\n {children}\n </DrawerContent>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n onPointerDownOutside={(event) => {\n dismissedByPointer.current = true;\n onPointerDownOutside?.(event);\n }}\n onCloseAutoFocus={(event) => {\n if (dismissedByPointer.current) event.preventDefault();\n dismissedByPointer.current = false;\n onCloseAutoFocus?.(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) cycleMenuTabStops(event);\n }}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\n // `rounded-sm` (12px) is the panel radius `V2 Menu Dropdown` carries\n // (product file node `7393:62008`). The 8px `rounded-xs` belongs to the\n // rows inside it, not the panel.\n //\n // The `sheet` variant is deliberately not 12px: it renders through\n // `DrawerContent variant=\"menu\"`, whose `MENU_CLASSES` is `rounded-lg`\n // (24px). A bottom sheet is a full-width surface with its own radius,\n // not a scaled-up popper, so the two are meant to differ.\n \"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-border-primary bg-surface-primary p-1 text-content-primary shadow-blur-menu backdrop-blur-[4px]\",\n \"data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out\",\n \"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2\",\n \"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2\",\n className,\n )}\n style={{\n zIndex: \"var(--fanvue-ui-portal-z-index, 50)\",\n maxHeight: \"var(--radix-dropdown-menu-content-available-height)\",\n ...style,\n }}\n {...props}\n >\n {children}\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\nDropdownMenuContent.displayName = \"DropdownMenuContent\";\n\n/** Props for the {@link DropdownMenuGroup} component. */\nexport type DropdownMenuGroupProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Group\n>;\n\n/**\n * Groups related menu items. Accepts an optional `DropdownMenuLabel`.\n *\n * Requires Radix menu context — not supported inside a `variant=\"sheet\"` menu.\n */\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\";\n"],"names":["useControllableState","DropdownMenuVariantContext","ToggleOpenContext","Drawer","jsx","DropdownMenuPrimitive","React","DrawerTrigger","FLOATING_CONTENT_COLLISION_PADDING","DrawerContent","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,4BAA4B;AAMlC,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAE3B,SAAS,gBAAgB,SAAqC;AAC5D,QAAM,QAAuB,CAAA;AAC7B,aAAW,aAAa,QAAQ,iBAA8B,IAAI,mBAAmB,GAAG,GAAG;AACzF,eAAW,WAAW,UAAU,iBAA8B,kBAAkB,GAAG;AACjF,UA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B,KAAK;AAAA,QAC9B;AAAA,QACA,kBAAkB,CAAC,UAAU;AAC3B,cAAI,mBAAmB,QAAS,OAAM,eAAA;AACtC,6BAAmB,UAAU;AAC7B,6BAAmB,KAAK;AAAA,QAC1B;AAAA,QACA,WAAW,CAAC,UAAU;AACpB,sBAAY,KAAK;AACjB,cAAI,CAAC,MAAM,iBAAkB,mBAAkB,KAAK;AAAA,QACtD;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAWK,GAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,UAST;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,WAAW;AAAA,UACX,GAAG;AAAA,QAAA;AAAA,QAEJ,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;AACA,oBAAoB,cAAc;AAY3B,MAAM,oBAAoBL,iCAAsB;AACvD,kBAAkB,cAAc;;;;;"}
1
+ {"version":3,"file":"DropdownMenuRoot.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuRoot.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"../../utils/floatingContentCollisionPadding\";\nimport { Drawer, DrawerContent, DrawerTrigger } from \"../Drawer/Drawer\";\nimport { type DropdownMenuVariant, DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\n\n// Movement, in CSS px, above which a touch press-and-release counts as a drag.\nconst TAP_MOVEMENT_THRESHOLD_PX = 10;\n\n// Radix menus swallow Tab (a menu has no tab stops, only items), which strands\n// any non-item control rendered inside one — header actions, a search input,\n// reorder handles. Containers of such controls carry this attribute and\n// `DropdownMenuContent` cycles Tab through the focusable elements inside them.\nconst TAB_STOPS_ATTRIBUTE = \"data-dropdown-menu-tab-stops\";\nconst FOCUSABLE_SELECTOR = \"a[href], button, input, select, textarea, [tabindex]\";\n\nfunction getMenuTabStops(content: HTMLElement): HTMLElement[] {\n const stops: HTMLElement[] = [];\n for (const container of content.querySelectorAll<HTMLElement>(`[${TAB_STOPS_ATTRIBUTE}]`)) {\n for (const element of container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) {\n if (element.tabIndex < 0 || element.matches(\":disabled\") || element.hidden) continue;\n stops.push(element);\n }\n }\n return stops;\n}\n\n// Cycles focus through the menu's tab stops on Tab / Shift+Tab, skipping menu\n// items (which keep their arrow-key navigation). Returns without acting when\n// the key isn't a plain Tab, came from a nested menu, or there is nothing to\n// cycle through — Radix then swallows the key as it always has.\nfunction cycleMenuTabStops(event: React.KeyboardEvent<HTMLElement>): void {\n if (event.key !== \"Tab\" || event.altKey || event.ctrlKey || event.metaKey) return;\n // A nested menu's keydowns bubble here through React's portal tree; they are\n // the nested menu's to handle.\n const target = event.target as HTMLElement;\n if (target.closest(\"[data-radix-menu-content]\") !== event.currentTarget) return;\n const stops = getMenuTabStops(event.currentTarget);\n if (stops.length === 0) return;\n // Prevented here so Radix's own handler (which would swallow the key) is\n // skipped — Radix composes it after ours and checks `defaultPrevented`.\n event.preventDefault();\n const index = stops.indexOf(target);\n const last = stops.length - 1;\n const next = event.shiftKey\n ? stops[index <= 0 ? last : index - 1]\n : stops[index === -1 || index === last ? 0 : index + 1];\n // Radix's FocusScope also sees this Tab (after us, ignoring\n // `defaultPrevented`), but a menu's scope is trapped without `loop`, so it\n // only prevents the default — it never moves focus itself.\n next?.focus({ preventScroll: true });\n}\n\ntype ActiveTap = {\n pointerId: number;\n x: number;\n y: number;\n movedPastThreshold: boolean;\n};\n\n/** Props for the {@link DropdownMenu} root component. */\nexport interface DropdownMenuProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root> {\n /** How the menu presents its content. @default \"menu\" */\n variant?: DropdownMenuVariant;\n}\n\n/** Root component that manages open/close state for a dropdown menu. */\nexport function DropdownMenu({\n open: openProp,\n defaultOpen,\n onOpenChange,\n variant = \"menu\",\n children,\n ...props\n}: DropdownMenuProps) {\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n if (variant === \"sheet\") {\n return (\n <DropdownMenuVariantContext.Provider value=\"sheet\">\n <ToggleOpenContext.Provider value={setOpen}>\n <Drawer open={open} onOpenChange={setOpen}>\n {children}\n </Drawer>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n }\n\n return (\n <DropdownMenuVariantContext.Provider value=\"menu\">\n <ToggleOpenContext.Provider value={setOpen}>\n <DropdownMenuPrimitive.Root open={open} onOpenChange={setOpen} {...props}>\n {children}\n </DropdownMenuPrimitive.Root>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n}\n\n/** Props for the {@link DropdownMenuTrigger} component. */\nexport type DropdownMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Trigger\n>;\n\n/**\n * The element that toggles the dropdown menu when clicked.\n *\n * On touch devices, the menu only opens if the press-and-release stays within\n * a small movement threshold. A drag that incidentally ends over the trigger\n * (common when scrolling a feed on Android Chrome) is ignored. Mouse and\n * keyboard interactions are unchanged.\n */\nexport const DropdownMenuTrigger = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,\n DropdownMenuTriggerProps\n>((props, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const tapRef = React.useRef<ActiveTap | null>(null);\n\n // The sheet variant opens a Drawer (Dialog), which already suppresses\n // scroll-drag-end synthetic clicks itself — no need for the touch-tap gating below.\n if (variant === \"sheet\") {\n return <DrawerTrigger {...props} ref={ref} />;\n }\n\n // Used outside our DropdownMenu wrapper — fall through to Radix defaults.\n if (toggleOpen === null) {\n return <DropdownMenuPrimitive.Trigger {...props} ref={ref} />;\n }\n\n return (\n <DropdownMenuPrimitive.Trigger\n {...props}\n ref={ref}\n onPointerDown={(event) => {\n props.onPointerDown?.(event);\n if (event.pointerType === \"mouse\" || props.disabled) return;\n // Keep pointerup / pointercancel on this element if the finger drifts off.\n // Optional because jsdom (used in tests) doesn't implement it.\n event.currentTarget.setPointerCapture?.(event.pointerId);\n tapRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n movedPastThreshold: false,\n };\n // preventDefault stops Radix's pointerdown open path via composeEventHandlers.\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n props.onPointerMove?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId || tap.movedPastThreshold) {\n return;\n }\n const dx = event.clientX - tap.x;\n const dy = event.clientY - tap.y;\n if (Math.hypot(dx, dy) > TAP_MOVEMENT_THRESHOLD_PX) {\n tap.movedPastThreshold = true;\n }\n }}\n onPointerUp={(event) => {\n props.onPointerUp?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId) return;\n const wasDrag = tap.movedPastThreshold;\n tapRef.current = null;\n if (!wasDrag && !props.disabled) {\n toggleOpen((prev) => !prev);\n }\n }}\n onPointerCancel={(event) => {\n props.onPointerCancel?.(event);\n const tap = tapRef.current;\n if (tap !== null && event.pointerId === tap.pointerId) {\n tapRef.current = null;\n }\n }}\n />\n );\n});\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\";\n\n/** Props for the {@link DropdownMenuContent} component. */\nexport interface DropdownMenuContentProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {}\n\n/**\n * The positioned content panel rendered inside a portal.\n *\n * Override the portal z-index per-instance via `style={{ zIndex: 1500 }}` or\n * globally with the `--fanvue-ui-portal-z-index` CSS custom property.\n *\n * @example\n * ```tsx\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild>\n * <Button>Open</Button>\n * </DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Option 1</DropdownMenuItem>\n * <DropdownMenuItem>Option 2</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n * ```\n */\nexport const DropdownMenuContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Content>,\n DropdownMenuContentProps\n>(\n (\n {\n className,\n style,\n sideOffset = 4,\n // Radix defaults `avoidCollisions` to true, so passing `collisionPadding`\n // is enough to keep the menu flipping/shifting to stay on screen — no\n // hand-rolled reposition logic needed.\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n onPointerDownOutside,\n onCloseAutoFocus,\n onKeyDown,\n children,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n // Radix returns focus to the trigger when the menu closes. That is right for\n // the keyboard, but Chrome's :focus-visible heuristic also paints the ring on\n // that programmatic refocus, so dismissing with a click left a focus ring\n // sitting on the trigger. Track pointer dismissals and skip the restore for\n // them only — Escape and Tab still hand focus back with the ring.\n const dismissedByPointer = React.useRef(false);\n\n if (variant === \"sheet\") {\n return (\n <DrawerContent\n ref={ref}\n position=\"bottom\"\n // `\"sheet\"` sits flush to the bottom edge at full width; the design draws\n // this panel inset from all three sides and rounded on every corner, which\n // is `\"menu\"`. Both carry the same modal surface.\n variant=\"menu\"\n // The design's `blur + shadow/menu` effect is a background blur, and the\n // panel's own fill is opaque — so the blur has to go on the overlay to be\n // visible at all. Scoped here rather than on DrawerOverlay so only menus\n // shown this way blur the page behind them.\n overlayProps={{ className: \"backdrop-blur-[8px]\" }}\n // `pb-4` gives the design's 16px below the last row. The rows inset\n // themselves horizontally (see the item's `mx-3`) rather than the panel\n // padding doing it, so the header and its rule can still run full width.\n className={cn(\"flex flex-col gap-1 p-1 pb-4\", className)}\n style={style}\n // Both are destructured above for the popper branch's focus-ring\n // handling, which takes them out of `props` — so the sheet branch has\n // to re-attach them or they are silently dropped. `DrawerContent`\n // forwards them to its `DialogPrimitive.Content`, which supports both.\n // Consumers stack sheets on these (a nested sheet's `onCloseAutoFocus`\n // is the only point at which the parent knows the child has finished\n // animating out), so dropping them breaks the flow with no error.\n onPointerDownOutside={onPointerDownOutside}\n onCloseAutoFocus={onCloseAutoFocus}\n onKeyDown={onKeyDown}\n {...props}\n >\n {children}\n </DrawerContent>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n onPointerDownOutside={(event) => {\n dismissedByPointer.current = true;\n onPointerDownOutside?.(event);\n }}\n onCloseAutoFocus={(event) => {\n if (dismissedByPointer.current) event.preventDefault();\n dismissedByPointer.current = false;\n onCloseAutoFocus?.(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) cycleMenuTabStops(event);\n }}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\n // Panel tokens come from `V2 Menu Dropdown` (product file node\n // `7393:62008`): `rounded-lg` (24px) over `Background/Secondary`, a\n // `Border/Strong` stroke, and 8px of padding. The 12px `rounded-sm` is\n // the row radius, not the panel's — the two were transposed here.\n //\n // `backdrop-blur-[4px]` is the CSS equivalent of that node's\n // `blur + shadow/menu` BACKGROUND_BLUR radius 8, which Figma halves on\n // export. It is not a 4-against-8 mismatch.\n \"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-lg border border-border-strong bg-background-secondary p-2 text-content-primary shadow-blur-menu backdrop-blur-[4px]\",\n \"data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out\",\n \"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2\",\n \"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2\",\n className,\n )}\n style={{\n zIndex: \"var(--fanvue-ui-portal-z-index, 50)\",\n maxHeight: \"var(--radix-dropdown-menu-content-available-height)\",\n ...style,\n }}\n {...props}\n >\n {children}\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\nDropdownMenuContent.displayName = \"DropdownMenuContent\";\n\n/** Props for the {@link DropdownMenuGroup} component. */\nexport type DropdownMenuGroupProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Group\n>;\n\n/**\n * Groups related menu items. Accepts an optional `DropdownMenuLabel`.\n *\n * Requires Radix menu context — not supported inside a `variant=\"sheet\"` menu.\n */\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\";\n"],"names":["useControllableState","DropdownMenuVariantContext","ToggleOpenContext","Drawer","jsx","DropdownMenuPrimitive","React","DrawerTrigger","FLOATING_CONTENT_COLLISION_PADDING","DrawerContent","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,4BAA4B;AAMlC,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAE3B,SAAS,gBAAgB,SAAqC;AAC5D,QAAM,QAAuB,CAAA;AAC7B,aAAW,aAAa,QAAQ,iBAA8B,IAAI,mBAAmB,GAAG,GAAG;AACzF,eAAW,WAAW,UAAU,iBAA8B,kBAAkB,GAAG;AACjF,UAAI,QAAQ,WAAW,KAAK,QAAQ,QAAQ,WAAW,KAAK,QAAQ,OAAQ;AAC5E,YAAM,KAAK,OAAO;AAAA,IACpB;AAAA,EACF;AACA,SAAO;AACT;AAMA,SAAS,kBAAkB,OAA+C;AACxE,MAAI,MAAM,QAAQ,SAAS,MAAM,UAAU,MAAM,WAAW,MAAM,QAAS;AAG3E,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,QAAQ,2BAA2B,MAAM,MAAM,cAAe;AACzE,QAAM,QAAQ,gBAAgB,MAAM,aAAa;AACjD,MAAI,MAAM,WAAW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AAA,UAST;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,WAAW;AAAA,UACX,GAAG;AAAA,QAAA;AAAA,QAEJ,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;AACA,oBAAoB,cAAc;AAY3B,MAAM,oBAAoBL,iCAAsB;AACvD,kBAAkB,cAAc;;;;;"}
@@ -4,32 +4,74 @@ import { Slot } from "@radix-ui/react-slot";
4
4
  import * as React from "react";
5
5
  import { cn } from "../../utils/cn.mjs";
6
6
  import { Button } from "../Button/Button.mjs";
7
- import { CheckCircleIcon } from "../Icons/CheckCircleIcon.mjs";
8
- import { CrossIcon } from "../Icons/CrossIcon.mjs";
9
- import { ErrorCircleIcon } from "../Icons/ErrorCircleIcon.mjs";
10
- import { InfoCircleIcon } from "../Icons/InfoCircleIcon.mjs";
11
- import { WarningTriangleIcon } from "../Icons/WarningTriangleIcon.mjs";
7
+ import { IconButton } from "../IconButton/IconButton.mjs";
8
+ import { AlertIcon } from "../Icons/AlertIcon.mjs";
9
+ import { CloseIcon } from "../Icons/CloseIcon.mjs";
10
+ import { InfoIcon } from "../Icons/InfoIcon.mjs";
11
+ import { TickCircleIcon } from "../Icons/TickCircleIcon.mjs";
12
+ import { WarningIcon } from "../Icons/WarningIcon.mjs";
12
13
  const DEFAULT_ICONS = {
13
- info: /* @__PURE__ */ jsx(InfoCircleIcon, {}),
14
- success: /* @__PURE__ */ jsx(CheckCircleIcon, {}),
15
- warning: /* @__PURE__ */ jsx(WarningTriangleIcon, {}),
16
- error: /* @__PURE__ */ jsx(ErrorCircleIcon, {}),
17
- neutral: /* @__PURE__ */ jsx(InfoCircleIcon, {})
14
+ info: /* @__PURE__ */ jsx(InfoIcon, { size: 16, filled: true }),
15
+ success: /* @__PURE__ */ jsx(TickCircleIcon, { size: 16, filled: true }),
16
+ warning: /* @__PURE__ */ jsx(AlertIcon, { size: 16, filled: true }),
17
+ error: /* @__PURE__ */ jsx(WarningIcon, { size: 16, filled: true }),
18
+ neutral: /* @__PURE__ */ jsx(InfoIcon, { size: 16, filled: true })
18
19
  };
19
- const CLOSE_BUTTON_CLASSES = {
20
- info: "hover:bg-info-content/10 active:bg-info-content/20 text-info-content motion-safe:transition-colors motion-safe:duration-150",
21
- success: "hover:bg-success-content/10 active:bg-success-content/20 text-success-content motion-safe:transition-colors motion-safe:duration-150",
22
- warning: "hover:bg-warning-content/10 active:bg-warning-content/20 text-warning-content motion-safe:transition-colors motion-safe:duration-150",
23
- error: "hover:bg-error-content/10 active:bg-error-content/20 text-error-content motion-safe:transition-colors motion-safe:duration-150",
24
- neutral: "hover:bg-content-secondary/10 active:bg-content-secondary/20 text-content-secondary motion-safe:transition-colors motion-safe:duration-150"
25
- };
26
- const LINK_CLASSES = {
20
+ const MESSAGE_CLASSES = {
27
21
  info: "text-alerts-info-prompt-content-info",
28
22
  success: "text-alerts-info-prompt-content-success",
29
23
  warning: "text-alerts-info-prompt-content-warning",
30
24
  error: "text-alerts-info-prompt-content-error",
31
25
  neutral: "text-content-secondary"
32
26
  };
27
+ const SURFACE_CLASSES = {
28
+ info: "bg-alerts-info-prompt-background-info text-alerts-info-prompt-icon-info",
29
+ success: "bg-alerts-info-prompt-background-success text-alerts-info-prompt-icon-success",
30
+ warning: "bg-alerts-info-prompt-background-warning text-alerts-info-prompt-icon-warning",
31
+ error: "bg-alerts-info-prompt-background-error text-alerts-info-prompt-icon-error",
32
+ neutral: "bg-alerts-info-prompt-background-neutral text-alerts-info-prompt-icon-neutral"
33
+ };
34
+ const LINK_CLASSES = "text-buttons-link-primary-default hover:text-buttons-link-primary-hover";
35
+ function AlertCta({
36
+ action,
37
+ ctaLabel,
38
+ ctaProps,
39
+ isTrailing
40
+ }) {
41
+ if (action) {
42
+ return /* @__PURE__ */ jsx(
43
+ Slot,
44
+ {
45
+ className: cn(
46
+ "typography-body-small-14px-semibold w-fit cursor-pointer underline underline-offset-2",
47
+ isTrailing && "shrink-0",
48
+ LINK_CLASSES
49
+ ),
50
+ children: action
51
+ }
52
+ );
53
+ }
54
+ if (ctaLabel === void 0 || ctaLabel === null || ctaLabel === false) {
55
+ return null;
56
+ }
57
+ return /* @__PURE__ */ jsx(
58
+ Button,
59
+ {
60
+ variant: "secondary",
61
+ size: "32",
62
+ ...ctaProps,
63
+ className: cn(
64
+ // Stacked, the CTA sits in a flex column, which would otherwise stretch
65
+ // it across the whole alert. Fill on mobile, where a full-width button
66
+ // is the easier target, and hug from `sm` (850px) up. Inline, it always
67
+ // hugs so the message keeps the remaining width.
68
+ isTrailing ? "shrink-0" : "w-full sm:w-fit",
69
+ ctaProps?.className
70
+ ),
71
+ children: ctaLabel
72
+ }
73
+ );
74
+ }
33
75
  const Alert = React.forwardRef(
34
76
  ({
35
77
  className,
@@ -40,57 +82,74 @@ const Alert = React.forwardRef(
40
82
  onClose,
41
83
  closeLabel = "Close alert",
42
84
  action,
85
+ layout = "under",
86
+ ctaLabel,
87
+ ctaProps,
43
88
  children,
44
89
  ...props
45
90
  }, ref) => {
46
91
  const resolvedIcon = icon === null ? null : icon ?? DEFAULT_ICONS[variant];
92
+ const isTrailing = layout === "trailing";
47
93
  return /* @__PURE__ */ jsxs(
48
94
  "div",
49
95
  {
50
96
  ref,
51
97
  "data-testid": "alert",
52
98
  className: cn(
53
- "grid gap-x-3 rounded-xs p-4 text-sm leading-[18px]",
54
- resolvedIcon && closable && "grid-cols-[auto_1fr_auto]",
55
- resolvedIcon && !closable && "grid-cols-[auto_1fr]",
56
- !resolvedIcon && closable && "grid-cols-[1fr_auto]",
57
- !resolvedIcon && !closable && "grid-cols-[1fr]",
58
- title && children ? "items-start" : "items-center",
59
- variant === "info" && "bg-info-surface text-info-content",
60
- variant === "success" && "bg-success-surface text-success-content",
61
- variant === "warning" && "bg-warning-surface text-warning-content",
62
- variant === "error" && "bg-error-surface text-error-content",
63
- variant === "neutral" && "bg-alerts-info-prompt-background-neutral text-alerts-info-prompt-icon-neutral",
99
+ // Mirrors the Figma frame: 12px inset with a 16px left inset, 24px
100
+ // from the content row to the close button, `rounded-md` radius.
101
+ "flex items-start gap-6 rounded-md p-3 pl-4 text-sm leading-[18px]",
102
+ SURFACE_CLASSES[variant],
64
103
  className
65
104
  ),
66
105
  ...props,
67
106
  children: [
68
- resolvedIcon && /* @__PURE__ */ jsx("span", { className: "flex h-full shrink-0 items-start", "aria-hidden": "true", children: resolvedIcon }),
69
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [
70
- /* @__PURE__ */ jsxs("div", { role: "alert", className: "flex flex-col gap-2", children: [
71
- title && /* @__PURE__ */ jsx("div", { className: "typography-body-small-14px-semibold text-content-primary", children: title }),
72
- /* @__PURE__ */ jsx("div", { className: "typography-body-small-14px-regular text-content-primary", children })
73
- ] }),
74
- action && /* @__PURE__ */ jsx(
75
- Slot,
107
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-3 py-1 pr-1", children: [
108
+ resolvedIcon && // The design's icon slot is 16px, but the default variant icons
109
+ // (InfoCircleIcon and friends) ship at `size-5`, so constrain the
110
+ // glyph here — the same way IconButton sizes its own icon. The 1px
111
+ // top nudge then lands it optically centred on the first 18px line,
112
+ // as in the design's icon-wrapper.
113
+ /* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-start pt-px [&>svg]:size-4", "aria-hidden": "true", children: resolvedIcon }),
114
+ /* @__PURE__ */ jsxs(
115
+ "div",
76
116
  {
77
117
  className: cn(
78
- "typography-body-small-14px-semibold w-fit cursor-pointer underline underline-offset-2",
79
- LINK_CLASSES[variant]
118
+ "flex min-w-0 flex-1",
119
+ isTrailing ? "items-center gap-6" : "flex-col gap-3"
80
120
  ),
81
- children: action
121
+ children: [
122
+ /* @__PURE__ */ jsxs("div", { role: "alert", className: cn("flex flex-col gap-1", isTrailing && "min-w-0 flex-1"), children: [
123
+ title && /* @__PURE__ */ jsx(
124
+ "div",
125
+ {
126
+ className: cn("typography-body-small-14px-semibold", MESSAGE_CLASSES[variant]),
127
+ children: title
128
+ }
129
+ ),
130
+ children ? /* @__PURE__ */ jsx("div", { className: cn("typography-body-small-14px-regular", MESSAGE_CLASSES[variant]), children }) : null
131
+ ] }),
132
+ /* @__PURE__ */ jsx(
133
+ AlertCta,
134
+ {
135
+ action,
136
+ ctaLabel,
137
+ ctaProps,
138
+ isTrailing
139
+ }
140
+ )
141
+ ]
82
142
  }
83
143
  )
84
144
  ] }),
85
145
  closable && /* @__PURE__ */ jsx(
86
- Button,
146
+ IconButton,
87
147
  {
88
- variant: "tertiary",
148
+ variant: "secondary",
89
149
  size: "24",
90
150
  onClick: onClose,
91
- className: cn("self-start px-0", CLOSE_BUTTON_CLASSES[variant]),
92
151
  "aria-label": closeLabel,
93
- children: /* @__PURE__ */ jsx(CrossIcon, {})
152
+ icon: /* @__PURE__ */ jsx(CloseIcon, { size: 16 })
94
153
  }
95
154
  )
96
155
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.mjs","sources":["../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button/Button\";\nimport { CheckCircleIcon } from \"../Icons/CheckCircleIcon\";\nimport { CrossIcon } from \"../Icons/CrossIcon\";\nimport { ErrorCircleIcon } from \"../Icons/ErrorCircleIcon\";\nimport { InfoCircleIcon } from \"../Icons/InfoCircleIcon\";\nimport { WarningTriangleIcon } from \"../Icons/WarningTriangleIcon\";\n\n/** Visual style variant of the alert. */\nexport type AlertVariant = \"info\" | \"success\" | \"warning\" | \"error\" | \"neutral\";\n\nconst DEFAULT_ICONS: Record<AlertVariant, React.ReactNode> = {\n info: <InfoCircleIcon />,\n success: <CheckCircleIcon />,\n warning: <WarningTriangleIcon />,\n error: <ErrorCircleIcon />,\n neutral: <InfoCircleIcon />,\n};\n\nexport interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Visual style variant of the alert. @default \"info\" */\n variant?: AlertVariant;\n /** Optional title text displayed in bold above the description. */\n title?: string;\n /** Custom icon override. Pass `null` to hide the icon entirely. Each variant shows a default icon when left `undefined`. */\n icon?: React.ReactNode | null;\n /** Whether to show the close button. @default false */\n closable?: boolean;\n /** Callback fired when the close button is clicked. */\n onClose?: () => void;\n /** Accessible label for the close button. @default \"Close alert\" */\n closeLabel?: string;\n /**\n * Composable action slot rendered beneath the description, outside the\n * `role=\"alert\"` live region. Pass your own element (an `<a>`, a `next/link`\n * `<Link>`, or a `<Button>`) and it receives the variant-appropriate link\n * styling via the Radix `Slot` pattern while remaining a real link/button.\n */\n action?: React.ReactNode;\n}\n\nconst CLOSE_BUTTON_CLASSES: Record<AlertVariant, string> = {\n info: \"hover:bg-info-content/10 active:bg-info-content/20 text-info-content motion-safe:transition-colors motion-safe:duration-150\",\n success:\n \"hover:bg-success-content/10 active:bg-success-content/20 text-success-content motion-safe:transition-colors motion-safe:duration-150\",\n warning:\n \"hover:bg-warning-content/10 active:bg-warning-content/20 text-warning-content motion-safe:transition-colors motion-safe:duration-150\",\n error:\n \"hover:bg-error-content/10 active:bg-error-content/20 text-error-content motion-safe:transition-colors motion-safe:duration-150\",\n neutral:\n \"hover:bg-content-secondary/10 active:bg-content-secondary/20 text-content-secondary motion-safe:transition-colors motion-safe:duration-150\",\n};\n\nconst LINK_CLASSES: Record<AlertVariant, string> = {\n info: \"text-alerts-info-prompt-content-info\",\n success: \"text-alerts-info-prompt-content-success\",\n warning: \"text-alerts-info-prompt-content-warning\",\n error: \"text-alerts-info-prompt-content-error\",\n neutral: \"text-content-secondary\",\n};\n\n/**\n * Displays a contextual feedback message to the user.\n *\n * Supports `info`, `success`, `warning`, `error`, and `neutral` variants with a\n * default icon per variant, optional title, description, dismiss button, and an\n * optional composable `action` slot.\n *\n * Each variant renders a default icon automatically. Pass a custom `icon` to\n * override, or `icon={null}` to hide the icon entirely.\n *\n * Only the title and description live inside the `role=\"alert\"` live region.\n * The icon, `action`, and close button are rendered outside it so interactive\n * controls are announced and navigated consistently by screen readers.\n *\n * @example\n * ```tsx\n * <Alert variant=\"success\" title=\"Saved\" closable onClose={handleClose}>\n * Your changes have been saved.\n * </Alert>\n * ```\n *\n * @example\n * ```tsx\n * <Alert variant=\"neutral\" title=\"Heads up\" action={<a href=\"/docs\">Learn more</a>}>\n * A general notice with no specific sentiment.\n * </Alert>\n * ```\n *\n * @example\n * ```tsx\n * import Link from \"next/link\";\n *\n * <Alert variant=\"info\" title=\"Update available\" action={<Link href=\"/changelog\">See what's new</Link>}>\n * A new version is ready to install.\n * </Alert>\n * ```\n */\nexport const Alert = React.forwardRef<HTMLDivElement, AlertProps>(\n (\n {\n className,\n variant = \"info\",\n title,\n icon,\n closable = false,\n onClose,\n closeLabel = \"Close alert\",\n action,\n children,\n ...props\n },\n ref,\n ) => {\n const resolvedIcon = icon === null ? null : (icon ?? DEFAULT_ICONS[variant]);\n\n return (\n <div\n ref={ref}\n data-testid=\"alert\"\n className={cn(\n \"grid gap-x-3 rounded-xs p-4 text-sm leading-[18px]\",\n resolvedIcon && closable && \"grid-cols-[auto_1fr_auto]\",\n resolvedIcon && !closable && \"grid-cols-[auto_1fr]\",\n !resolvedIcon && closable && \"grid-cols-[1fr_auto]\",\n !resolvedIcon && !closable && \"grid-cols-[1fr]\",\n title && children ? \"items-start\" : \"items-center\",\n variant === \"info\" && \"bg-info-surface text-info-content\",\n variant === \"success\" && \"bg-success-surface text-success-content\",\n variant === \"warning\" && \"bg-warning-surface text-warning-content\",\n variant === \"error\" && \"bg-error-surface text-error-content\",\n variant === \"neutral\" &&\n \"bg-alerts-info-prompt-background-neutral text-alerts-info-prompt-icon-neutral\",\n className,\n )}\n {...props}\n >\n {resolvedIcon && (\n <span className=\"flex h-full shrink-0 items-start\" aria-hidden=\"true\">\n {resolvedIcon}\n </span>\n )}\n\n <div className=\"flex min-w-0 flex-col gap-2\">\n <div role=\"alert\" className=\"flex flex-col gap-2\">\n {title && (\n <div className=\"typography-body-small-14px-semibold text-content-primary\">\n {title}\n </div>\n )}\n <div className=\"typography-body-small-14px-regular text-content-primary\">\n {children}\n </div>\n </div>\n {action && (\n <Slot\n className={cn(\n \"typography-body-small-14px-semibold w-fit cursor-pointer underline underline-offset-2\",\n LINK_CLASSES[variant],\n )}\n >\n {action}\n </Slot>\n )}\n </div>\n\n {closable && (\n <Button\n variant=\"tertiary\"\n size=\"24\"\n onClick={onClose}\n className={cn(\"self-start px-0\", CLOSE_BUTTON_CLASSES[variant])}\n aria-label={closeLabel}\n >\n <CrossIcon />\n </Button>\n )}\n </div>\n );\n },\n);\n\nAlert.displayName = \"Alert\";\n"],"names":[],"mappings":";;;;;;;;;;;AAaA,MAAM,gBAAuD;AAAA,EAC3D,0BAAO,gBAAA,EAAe;AAAA,EACtB,6BAAU,iBAAA,EAAgB;AAAA,EAC1B,6BAAU,qBAAA,EAAoB;AAAA,EAC9B,2BAAQ,iBAAA,EAAgB;AAAA,EACxB,6BAAU,gBAAA,CAAA,CAAe;AAC3B;AAwBA,MAAM,uBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,SACE;AAAA,EACF,SACE;AAAA,EACF,OACE;AAAA,EACF,SACE;AACJ;AAEA,MAAM,eAA6C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AACX;AAuCO,MAAM,QAAQ,MAAM;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,eAAe,SAAS,OAAO,OAAQ,QAAQ,cAAc,OAAO;AAE1E,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,eAAY;A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radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button, type ButtonProps } from \"../Button/Button\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { AlertIcon } from \"../Icons/AlertIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { InfoIcon } from \"../Icons/InfoIcon\";\nimport { TickCircleIcon } from \"../Icons/TickCircleIcon\";\nimport { WarningIcon } from \"../Icons/WarningIcon\";\n\n/** Visual style variant of the alert. */\nexport type AlertVariant = \"info\" | \"success\" | \"warning\" | \"error\" | \"neutral\";\n\n/**\n * Placement of the call-to-action relative to the message.\n *\n * - `\"under\"` stacks the action beneath the description. Use it when the CTA\n * label is long or the alert is narrow.\n * - `\"trailing\"` keeps the action inline with the message, which keeps the\n * alert compact and works best with short labels.\n */\nexport type AlertLayout = \"under\" | \"trailing\";\n\n/**\n * Per-variant default icon, mapped to the Iconography components the design\n * uses at `Size=16, Fill=Yes`. Note the design's naming: its Error variant\n * takes `Iconography / Warning` and its Warning variant takes\n * `Iconography / Alert`, which reads backwards but is what the node specifies.\n *\n * These carry dedicated 16px geometry, unlike the `*CircleIcon` set they\n * replace, whose 20px art had to be scaled down.\n */\nconst DEFAULT_ICONS: Record<AlertVariant, React.ReactNode> = {\n info: <InfoIcon size={16} filled />,\n success: <TickCircleIcon size={16} filled />,\n warning: <AlertIcon size={16} filled />,\n error: <WarningIcon size={16} filled />,\n neutral: <InfoIcon size={16} filled />,\n};\n\nexport interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Visual style variant of the alert. @default \"info\" */\n variant?: AlertVariant;\n /** Optional title text displayed in bold above the description. */\n title?: string;\n /** Custom icon override. Pass `null` to hide the icon entirely. Each variant shows a default icon when left `undefined`. */\n icon?: React.ReactNode | null;\n /** Whether to show the close button. @default false */\n closable?: boolean;\n /** Callback fired when the close button is clicked. */\n onClose?: () => void;\n /** Accessible label for the close button. @default \"Close alert\" */\n closeLabel?: string;\n /**\n * Composable action slot rendered beneath the description, outside the\n * `role=\"alert\"` live region. Pass your own element (an `<a>`, a `next/link`\n * `<Link>`, or a `<Button>`) and it receives the variant-appropriate link\n * styling via the Radix `Slot` pattern while remaining a real link/button.\n */\n action?: React.ReactNode;\n /** Placement of the call-to-action relative to the message. @default \"under\" */\n layout?: AlertLayout;\n /**\n * Label for a built-in call-to-action button, the button form of the CTA.\n * Use it when the alert asks the user to do something specific — activating a\n * feature, or completing setup — rather than pointing at more detail. Ignored\n * when `action` is set.\n */\n ctaLabel?: React.ReactNode;\n /**\n * Props forwarded to the built-in call-to-action button (e.g. `onClick`).\n * `variant` and `size` default to `secondary`/`32` and can be overridden.\n *\n * The stacked CTA is `w-full sm:w-fit`. To override the width, match the\n * modifier chain — a bare `w-auto` replaces `w-full` but leaves `sm:w-fit`\n * in place, so pass `sm:` variants too.\n */\n ctaProps?: Omit<ButtonProps, \"children\" | \"asChild\">;\n}\n\n/**\n * Title and description colour. The design binds both to\n * `Color/Alerts/Info Prompt/Content/<variant>`, and Neutral to\n * `Color/Content/Secondary` — not to `content-primary`, which reads as plain\n * black on the tinted surface.\n */\nconst MESSAGE_CLASSES: Record<AlertVariant, string> = {\n info: \"text-alerts-info-prompt-content-info\",\n success: \"text-alerts-info-prompt-content-success\",\n warning: \"text-alerts-info-prompt-content-warning\",\n error: \"text-alerts-info-prompt-content-error\",\n neutral: \"text-content-secondary\",\n};\n\n/**\n * Surface fill and icon colour, both read from the component's own design\n * variables: `Color/Alerts/Info Prompt/Background/<variant>` and\n * `Color/Alerts/Info Prompt/Icon/<variant>`.\n *\n * The `text-*` here is inherited by the icon only — the message sets its own\n * colour via {@link MESSAGE_CLASSES}. It matters that this reads the dedicated\n * icon tokens rather than the generic `*-content` ones: those agree only for\n * info, and they carry no dark-mode inversion, where the alert tokens step\n * from `*-600` in light to `*-400` in dark as the design specifies.\n */\nconst SURFACE_CLASSES: Record<AlertVariant, string> = {\n info: \"bg-alerts-info-prompt-background-info text-alerts-info-prompt-icon-info\",\n success: \"bg-alerts-info-prompt-background-success text-alerts-info-prompt-icon-success\",\n warning: \"bg-alerts-info-prompt-background-warning text-alerts-info-prompt-icon-warning\",\n error: \"bg-alerts-info-prompt-background-error text-alerts-info-prompt-icon-error\",\n neutral: \"bg-alerts-info-prompt-background-neutral text-alerts-info-prompt-icon-neutral\",\n};\n\n/**\n * CTA link treatment. The node's CTA is a `V2 Link` instance whose text binds\n * `Color/Buttons/Link/Primary/Default`, with no per-variant override on any of\n * the five — so the link takes the standard link colour rather than the alert's\n * own content tint. These are the same tokens the {@link Link} component\n * applies, including the hover step.\n */\nconst LINK_CLASSES = \"text-buttons-link-primary-default hover:text-buttons-link-primary-hover\";\n\n/**\n * The alert's call-to-action. `action` is the link form: any element passed\n * through receives the variant-appropriate link styling via Radix `Slot` while\n * staying a real link or button. `ctaLabel` is the button form. `action` wins\n * when both are set.\n */\nfunction AlertCta({\n action,\n ctaLabel,\n ctaProps,\n isTrailing,\n}: {\n action: React.ReactNode;\n ctaLabel: React.ReactNode;\n ctaProps?: AlertProps[\"ctaProps\"];\n isTrailing: boolean;\n}) {\n if (action) {\n return (\n <Slot\n className={cn(\n \"typography-body-small-14px-semibold w-fit cursor-pointer underline underline-offset-2\",\n isTrailing && \"shrink-0\",\n LINK_CLASSES,\n )}\n >\n {action}\n </Slot>\n );\n }\n\n if (ctaLabel === undefined || ctaLabel === null || ctaLabel === false) {\n return null;\n }\n\n return (\n <Button\n variant=\"secondary\"\n size=\"32\"\n {...ctaProps}\n className={cn(\n // Stacked, the CTA sits in a flex column, which would otherwise stretch\n // it across the whole alert. Fill on mobile, where a full-width button\n // is the easier target, and hug from `sm` (850px) up. Inline, it always\n // hugs so the message keeps the remaining width.\n isTrailing ? \"shrink-0\" : \"w-full sm:w-fit\",\n ctaProps?.className,\n )}\n >\n {ctaLabel}\n </Button>\n );\n}\n\n/**\n * Displays a contextual feedback message to the user.\n *\n * Supports `info`, `success`, `warning`, `error`, and `neutral` variants with a\n * default icon per variant, optional title, description, dismiss button, and an\n * optional composable `action` slot.\n *\n * Each variant renders a default icon automatically. Pass a custom `icon` to\n * override, or `icon={null}` to hide the icon entirely.\n *\n * Only the title and description live inside the `role=\"alert\"` live region.\n * The icon, `action`, and close button are rendered outside it so interactive\n * controls are announced and navigated consistently by screen readers.\n *\n * @example\n * ```tsx\n * <Alert variant=\"success\" title=\"Saved\" closable onClose={handleClose}>\n * Your changes have been saved.\n * </Alert>\n * ```\n *\n * @example\n * ```tsx\n * <Alert variant=\"neutral\" title=\"Heads up\" action={<a href=\"/docs\">Learn more</a>}>\n * A general notice with no specific sentiment.\n * </Alert>\n * ```\n *\n * @example\n * ```tsx\n * import Link from \"next/link\";\n *\n * <Alert variant=\"info\" title=\"Update available\" action={<Link href=\"/changelog\">See what's new</Link>}>\n * A new version is ready to install.\n * </Alert>\n * ```\n *\n * @example\n * The CTA sits under the description by default. `layout=\"trailing\"` keeps it\n * inline with the message, which suits short labels and keeps the alert compact.\n * ```tsx\n * <Alert variant=\"info\" layout=\"trailing\" action={<a href=\"/docs\">Learn more</a>}>\n * Scheduled posts now publish in your local timezone.\n * </Alert>\n * ```\n *\n * @example\n * `ctaLabel` renders the button form of the CTA instead of a link — use it when\n * the alert asks the user to do something specific.\n * ```tsx\n * <Alert variant=\"warning\" title=\"Finish setup\" layout=\"trailing\" ctaLabel=\"Verify now\" ctaProps={{ onClick: verify }}>\n * Verify your identity to start receiving payouts.\n * </Alert>\n * ```\n */\nexport const Alert = React.forwardRef<HTMLDivElement, AlertProps>(\n (\n {\n className,\n variant = \"info\",\n title,\n icon,\n closable = false,\n onClose,\n closeLabel = \"Close alert\",\n action,\n layout = \"under\",\n ctaLabel,\n ctaProps,\n children,\n ...props\n },\n ref,\n ) => {\n const resolvedIcon = icon === null ? null : (icon ?? DEFAULT_ICONS[variant]);\n const isTrailing = layout === \"trailing\";\n\n return (\n <div\n ref={ref}\n data-testid=\"alert\"\n className={cn(\n // Mirrors the Figma frame: 12px inset with a 16px left inset, 24px\n // from the content row to the close button, `rounded-md` radius.\n \"flex items-start gap-6 rounded-md p-3 pl-4 text-sm leading-[18px]\",\n SURFACE_CLASSES[variant],\n className,\n )}\n {...props}\n >\n {/*\n Content row. Its 4px inset is what takes the container's 12px up to the\n 16px the design specifies around the message, while leaving the close\n button on the container's own 12px. It also puts 28px between the\n message and the close button (this 4px plus the container's 24px gap).\n */}\n <div className=\"flex min-w-0 flex-1 items-start gap-3 py-1 pr-1\">\n {resolvedIcon && (\n // The design's icon slot is 16px, but the default variant icons\n // (InfoCircleIcon and friends) ship at `size-5`, so constrain the\n // glyph here — the same way IconButton sizes its own icon. The 1px\n // top nudge then lands it optically centred on the first 18px line,\n // as in the design's icon-wrapper.\n <span className=\"flex shrink-0 items-start pt-px [&>svg]:size-4\" aria-hidden=\"true\">\n {resolvedIcon}\n </span>\n )}\n\n <div\n className={cn(\n \"flex min-w-0 flex-1\",\n isTrailing ? \"items-center gap-6\" : \"flex-col gap-3\",\n )}\n >\n <div role=\"alert\" className={cn(\"flex flex-col gap-1\", isTrailing && \"min-w-0 flex-1\")}>\n {title && (\n <div\n className={cn(\"typography-body-small-14px-semibold\", MESSAGE_CLASSES[variant])}\n >\n {title}\n </div>\n )}\n {children ? (\n <div className={cn(\"typography-body-small-14px-regular\", MESSAGE_CLASSES[variant])}>\n {children}\n </div>\n ) : null}\n </div>\n <AlertCta\n action={action}\n ctaLabel={ctaLabel}\n ctaProps={ctaProps}\n isTrailing={isTrailing}\n />\n </div>\n </div>\n\n {closable && (\n <IconButton\n variant=\"secondary\"\n size=\"24\"\n onClick={onClose}\n aria-label={closeLabel}\n icon={<CloseIcon size={16} />}\n />\n )}\n </div>\n );\n },\n);\n\nAlert.displayName = \"Alert\";\n"],"names":[],"mappings":";;;;;;;;;;;;AAiCA,MAAM,gBAAuD;AAAA,EAC3D,MAAM,oBAAC,UAAA,EAAS,MAAM,IAAI,QAAM,MAAC;AAAA,EACjC,SAAS,oBAAC,gBAAA,EAAe,MAAM,IA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,GAAA,CAAI;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7B;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,MAAM,cAAc;"}
@@ -165,15 +165,15 @@ const DropdownMenuContent = React.forwardRef(
165
165
  sideOffset,
166
166
  collisionPadding,
167
167
  className: cn(
168
- // `rounded-sm` (12px) is the panel radius `V2 Menu Dropdown` carries
169
- // (product file node `7393:62008`). The 8px `rounded-xs` belongs to the
170
- // rows inside it, not the panel.
168
+ // Panel tokens come from `V2 Menu Dropdown` (product file node
169
+ // `7393:62008`): `rounded-lg` (24px) over `Background/Secondary`, a
170
+ // `Border/Strong` stroke, and 8px of padding. The 12px `rounded-sm` is
171
+ // the row radius, not the panel's — the two were transposed here.
171
172
  //
172
- // The `sheet` variant is deliberately not 12px: it renders through
173
- // `DrawerContent variant="menu"`, whose `MENU_CLASSES` is `rounded-lg`
174
- // (24px). A bottom sheet is a full-width surface with its own radius,
175
- // not a scaled-up popper, so the two are meant to differ.
176
- "w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-border-primary bg-surface-primary p-1 text-content-primary shadow-blur-menu backdrop-blur-[4px]",
173
+ // `backdrop-blur-[4px]` is the CSS equivalent of that node's
174
+ // `blur + shadow/menu` BACKGROUND_BLUR radius 8, which Figma halves on
175
+ // export. It is not a 4-against-8 mismatch.
176
+ "w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-lg border border-border-strong bg-background-secondary p-2 text-content-primary shadow-blur-menu backdrop-blur-[4px]",
177
177
  "data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in",
178
178
  "data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out",
179
179
  "data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2",
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenuRoot.mjs","sources":["../../../src/components/DropdownMenu/DropdownMenuRoot.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"../../utils/floatingContentCollisionPadding\";\nimport { Drawer, DrawerContent, DrawerTrigger } from \"../Drawer/Drawer\";\nimport { type DropdownMenuVariant, DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\n\n// Movement, in CSS px, above which a touch press-and-release counts as a drag.\nconst TAP_MOVEMENT_THRESHOLD_PX = 10;\n\n// Radix menus swallow Tab (a menu has no tab stops, only items), which strands\n// any non-item control rendered inside one — header actions, a search input,\n// reorder handles. Containers of such controls carry this attribute and\n// `DropdownMenuContent` cycles Tab through the focusable elements inside them.\nconst TAB_STOPS_ATTRIBUTE = \"data-dropdown-menu-tab-stops\";\nconst FOCUSABLE_SELECTOR = \"a[href], button, input, select, textarea, [tabindex]\";\n\nfunction getMenuTabStops(content: HTMLElement): HTMLElement[] {\n const stops: HTMLElement[] = [];\n for (const container of content.querySelectorAll<HTMLElement>(`[${TAB_STOPS_ATTRIBUTE}]`)) {\n for (const element of container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) {\n if (element.tabIndex < 0 || element.matches(\":disabled\") || element.hidden) continue;\n stops.push(element);\n }\n }\n return stops;\n}\n\n// Cycles focus through the menu's tab stops on Tab / Shift+Tab, skipping menu\n// items (which keep their arrow-key navigation). Returns without acting when\n// the key isn't a plain Tab, came from a nested menu, or there is nothing to\n// cycle through — Radix then swallows the key as it always has.\nfunction cycleMenuTabStops(event: React.KeyboardEvent<HTMLElement>): void {\n if (event.key !== \"Tab\" || event.altKey || event.ctrlKey || event.metaKey) return;\n // A nested menu's keydowns bubble here through React's portal tree; they are\n // the nested menu's to handle.\n const target = event.target as HTMLElement;\n if (target.closest(\"[data-radix-menu-content]\") !== event.currentTarget) return;\n const stops = getMenuTabStops(event.currentTarget);\n if (stops.length === 0) return;\n // Prevented here so Radix's own handler (which would swallow the key) is\n // skipped — Radix composes it after ours and checks `defaultPrevented`.\n event.preventDefault();\n const index = stops.indexOf(target);\n const last = stops.length - 1;\n const next = event.shiftKey\n ? stops[index <= 0 ? last : index - 1]\n : stops[index === -1 || index === last ? 0 : index + 1];\n // Radix's FocusScope also sees this Tab (after us, ignoring\n // `defaultPrevented`), but a menu's scope is trapped without `loop`, so it\n // only prevents the default — it never moves focus itself.\n next?.focus({ preventScroll: true });\n}\n\ntype ActiveTap = {\n pointerId: number;\n x: number;\n y: number;\n movedPastThreshold: boolean;\n};\n\n/** Props for the {@link DropdownMenu} root component. */\nexport interface DropdownMenuProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root> {\n /** How the menu presents its content. @default \"menu\" */\n variant?: DropdownMenuVariant;\n}\n\n/** Root component that manages open/close state for a dropdown menu. */\nexport function DropdownMenu({\n open: openProp,\n defaultOpen,\n onOpenChange,\n variant = \"menu\",\n children,\n ...props\n}: DropdownMenuProps) {\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n if (variant === \"sheet\") {\n return (\n <DropdownMenuVariantContext.Provider value=\"sheet\">\n <ToggleOpenContext.Provider value={setOpen}>\n <Drawer open={open} onOpenChange={setOpen}>\n {children}\n </Drawer>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n }\n\n return (\n <DropdownMenuVariantContext.Provider value=\"menu\">\n <ToggleOpenContext.Provider value={setOpen}>\n <DropdownMenuPrimitive.Root open={open} onOpenChange={setOpen} {...props}>\n {children}\n </DropdownMenuPrimitive.Root>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n}\n\n/** Props for the {@link DropdownMenuTrigger} component. */\nexport type DropdownMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Trigger\n>;\n\n/**\n * The element that toggles the dropdown menu when clicked.\n *\n * On touch devices, the menu only opens if the press-and-release stays within\n * a small movement threshold. A drag that incidentally ends over the trigger\n * (common when scrolling a feed on Android Chrome) is ignored. Mouse and\n * keyboard interactions are unchanged.\n */\nexport const DropdownMenuTrigger = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,\n DropdownMenuTriggerProps\n>((props, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const tapRef = React.useRef<ActiveTap | null>(null);\n\n // The sheet variant opens a Drawer (Dialog), which already suppresses\n // scroll-drag-end synthetic clicks itself — no need for the touch-tap gating below.\n if (variant === \"sheet\") {\n return <DrawerTrigger {...props} ref={ref} />;\n }\n\n // Used outside our DropdownMenu wrapper — fall through to Radix defaults.\n if (toggleOpen === null) {\n return <DropdownMenuPrimitive.Trigger {...props} ref={ref} />;\n }\n\n return (\n <DropdownMenuPrimitive.Trigger\n {...props}\n ref={ref}\n onPointerDown={(event) => {\n props.onPointerDown?.(event);\n if (event.pointerType === \"mouse\" || props.disabled) return;\n // Keep pointerup / pointercancel on this element if the finger drifts off.\n // Optional because jsdom (used in tests) doesn't implement it.\n event.currentTarget.setPointerCapture?.(event.pointerId);\n tapRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n movedPastThreshold: false,\n };\n // preventDefault stops Radix's pointerdown open path via composeEventHandlers.\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n props.onPointerMove?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId || tap.movedPastThreshold) {\n return;\n }\n const dx = event.clientX - tap.x;\n const dy = event.clientY - tap.y;\n if (Math.hypot(dx, dy) > TAP_MOVEMENT_THRESHOLD_PX) {\n tap.movedPastThreshold = true;\n }\n }}\n onPointerUp={(event) => {\n props.onPointerUp?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId) return;\n const wasDrag = tap.movedPastThreshold;\n tapRef.current = null;\n if (!wasDrag && !props.disabled) {\n toggleOpen((prev) => !prev);\n }\n }}\n onPointerCancel={(event) => {\n props.onPointerCancel?.(event);\n const tap = tapRef.current;\n if (tap !== null && event.pointerId === tap.pointerId) {\n tapRef.current = null;\n }\n }}\n />\n );\n});\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\";\n\n/** Props for the {@link DropdownMenuContent} component. */\nexport interface DropdownMenuContentProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {}\n\n/**\n * The positioned content panel rendered inside a portal.\n *\n * Override the portal z-index per-instance via `style={{ zIndex: 1500 }}` or\n * globally with the `--fanvue-ui-portal-z-index` CSS custom property.\n *\n * @example\n * ```tsx\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild>\n * <Button>Open</Button>\n * </DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Option 1</DropdownMenuItem>\n * <DropdownMenuItem>Option 2</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n * ```\n */\nexport const DropdownMenuContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Content>,\n DropdownMenuContentProps\n>(\n (\n {\n className,\n style,\n sideOffset = 4,\n // Radix defaults `avoidCollisions` to true, so passing `collisionPadding`\n // is enough to keep the menu flipping/shifting to stay on screen — no\n // hand-rolled reposition logic needed.\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n onPointerDownOutside,\n onCloseAutoFocus,\n onKeyDown,\n children,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n // Radix returns focus to the trigger when the menu closes. That is right for\n // the keyboard, but Chrome's :focus-visible heuristic also paints the ring on\n // that programmatic refocus, so dismissing with a click left a focus ring\n // sitting on the trigger. Track pointer dismissals and skip the restore for\n // them only — Escape and Tab still hand focus back with the ring.\n const dismissedByPointer = React.useRef(false);\n\n if (variant === \"sheet\") {\n return (\n <DrawerContent\n ref={ref}\n position=\"bottom\"\n // `\"sheet\"` sits flush to the bottom edge at full width; the design draws\n // this panel inset from all three sides and rounded on every corner, which\n // is `\"menu\"`. Both carry the same modal surface.\n variant=\"menu\"\n // The design's `blur + shadow/menu` effect is a background blur, and the\n // panel's own fill is opaque — so the blur has to go on the overlay to be\n // visible at all. Scoped here rather than on DrawerOverlay so only menus\n // shown this way blur the page behind them.\n overlayProps={{ className: \"backdrop-blur-[8px]\" }}\n // `pb-4` gives the design's 16px below the last row. The rows inset\n // themselves horizontally (see the item's `mx-3`) rather than the panel\n // padding doing it, so the header and its rule can still run full width.\n className={cn(\"flex flex-col gap-1 p-1 pb-4\", className)}\n style={style}\n // Both are destructured above for the popper branch's focus-ring\n // handling, which takes them out of `props` — so the sheet branch has\n // to re-attach them or they are silently dropped. `DrawerContent`\n // forwards them to its `DialogPrimitive.Content`, which supports both.\n // Consumers stack sheets on these (a nested sheet's `onCloseAutoFocus`\n // is the only point at which the parent knows the child has finished\n // animating out), so dropping them breaks the flow with no error.\n onPointerDownOutside={onPointerDownOutside}\n onCloseAutoFocus={onCloseAutoFocus}\n onKeyDown={onKeyDown}\n {...props}\n >\n {children}\n </DrawerContent>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n onPointerDownOutside={(event) => {\n dismissedByPointer.current = true;\n onPointerDownOutside?.(event);\n }}\n onCloseAutoFocus={(event) => {\n if (dismissedByPointer.current) event.preventDefault();\n dismissedByPointer.current = false;\n onCloseAutoFocus?.(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) cycleMenuTabStops(event);\n }}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\n // `rounded-sm` (12px) is the panel radius `V2 Menu Dropdown` carries\n // (product file node `7393:62008`). The 8px `rounded-xs` belongs to the\n // rows inside it, not the panel.\n //\n // The `sheet` variant is deliberately not 12px: it renders through\n // `DrawerContent variant=\"menu\"`, whose `MENU_CLASSES` is `rounded-lg`\n // (24px). A bottom sheet is a full-width surface with its own radius,\n // not a scaled-up popper, so the two are meant to differ.\n \"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-border-primary bg-surface-primary p-1 text-content-primary shadow-blur-menu backdrop-blur-[4px]\",\n \"data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out\",\n \"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2\",\n \"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2\",\n className,\n )}\n style={{\n zIndex: \"var(--fanvue-ui-portal-z-index, 50)\",\n maxHeight: \"var(--radix-dropdown-menu-content-available-height)\",\n ...style,\n }}\n {...props}\n >\n {children}\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\nDropdownMenuContent.displayName = \"DropdownMenuContent\";\n\n/** Props for the {@link DropdownMenuGroup} component. */\nexport type DropdownMenuGroupProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Group\n>;\n\n/**\n * Groups related menu items. Accepts an optional `DropdownMenuLabel`.\n *\n * Requires Radix menu context — not supported inside a `variant=\"sheet\"` menu.\n */\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\";\n"],"names":[],"mappings":";;;;;;;;;AASA,MAAM,4BAA4B;AAMlC,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAE3B,SAAS,gBAAgB,SAAqC;AAC5D,QAAM,QAAuB,CAAA;AAC7B,aAAW,aAAa,QAAQ,iBAA8B,IAAI,mBAAmB,GAAG,GAAG;AACzF,eAAW,WAAW,UAAU,iBAA8B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AAmB,KAAK;AAAA,QAC1B;AAAA,QACA,WAAW,CAAC,UAAU;AACpB,sBAAY,KAAK;AACjB,cAAI,CAAC,MAAM,iBAAkB,mBAAkB,KAAK;AAAA,QACtD;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAST;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,WAAW;AAAA,UACX,GAAG;AAAA,QAAA;AAAA,QAEJ,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;AACA,oBAAoB,cAAc;AAY3B,MAAM,oBAAoB,sBAAsB;AACvD,kBAAkB,cAAc;"}
1
+ {"version":3,"file":"DropdownMenuRoot.mjs","sources":["../../../src/components/DropdownMenu/DropdownMenuRoot.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"../../utils/floatingContentCollisionPadding\";\nimport { Drawer, DrawerContent, DrawerTrigger } from \"../Drawer/Drawer\";\nimport { type DropdownMenuVariant, DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\n\n// Movement, in CSS px, above which a touch press-and-release counts as a drag.\nconst TAP_MOVEMENT_THRESHOLD_PX = 10;\n\n// Radix menus swallow Tab (a menu has no tab stops, only items), which strands\n// any non-item control rendered inside one — header actions, a search input,\n// reorder handles. Containers of such controls carry this attribute and\n// `DropdownMenuContent` cycles Tab through the focusable elements inside them.\nconst TAB_STOPS_ATTRIBUTE = \"data-dropdown-menu-tab-stops\";\nconst FOCUSABLE_SELECTOR = \"a[href], button, input, select, textarea, [tabindex]\";\n\nfunction getMenuTabStops(content: HTMLElement): HTMLElement[] {\n const stops: HTMLElement[] = [];\n for (const container of content.querySelectorAll<HTMLElement>(`[${TAB_STOPS_ATTRIBUTE}]`)) {\n for (const element of container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) {\n if (element.tabIndex < 0 || element.matches(\":disabled\") || element.hidden) continue;\n stops.push(element);\n }\n }\n return stops;\n}\n\n// Cycles focus through the menu's tab stops on Tab / Shift+Tab, skipping menu\n// items (which keep their arrow-key navigation). Returns without acting when\n// the key isn't a plain Tab, came from a nested menu, or there is nothing to\n// cycle through — Radix then swallows the key as it always has.\nfunction cycleMenuTabStops(event: React.KeyboardEvent<HTMLElement>): void {\n if (event.key !== \"Tab\" || event.altKey || event.ctrlKey || event.metaKey) return;\n // A nested menu's keydowns bubble here through React's portal tree; they are\n // the nested menu's to handle.\n const target = event.target as HTMLElement;\n if (target.closest(\"[data-radix-menu-content]\") !== event.currentTarget) return;\n const stops = getMenuTabStops(event.currentTarget);\n if (stops.length === 0) return;\n // Prevented here so Radix's own handler (which would swallow the key) is\n // skipped — Radix composes it after ours and checks `defaultPrevented`.\n event.preventDefault();\n const index = stops.indexOf(target);\n const last = stops.length - 1;\n const next = event.shiftKey\n ? stops[index <= 0 ? last : index - 1]\n : stops[index === -1 || index === last ? 0 : index + 1];\n // Radix's FocusScope also sees this Tab (after us, ignoring\n // `defaultPrevented`), but a menu's scope is trapped without `loop`, so it\n // only prevents the default — it never moves focus itself.\n next?.focus({ preventScroll: true });\n}\n\ntype ActiveTap = {\n pointerId: number;\n x: number;\n y: number;\n movedPastThreshold: boolean;\n};\n\n/** Props for the {@link DropdownMenu} root component. */\nexport interface DropdownMenuProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root> {\n /** How the menu presents its content. @default \"menu\" */\n variant?: DropdownMenuVariant;\n}\n\n/** Root component that manages open/close state for a dropdown menu. */\nexport function DropdownMenu({\n open: openProp,\n defaultOpen,\n onOpenChange,\n variant = \"menu\",\n children,\n ...props\n}: DropdownMenuProps) {\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n if (variant === \"sheet\") {\n return (\n <DropdownMenuVariantContext.Provider value=\"sheet\">\n <ToggleOpenContext.Provider value={setOpen}>\n <Drawer open={open} onOpenChange={setOpen}>\n {children}\n </Drawer>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n }\n\n return (\n <DropdownMenuVariantContext.Provider value=\"menu\">\n <ToggleOpenContext.Provider value={setOpen}>\n <DropdownMenuPrimitive.Root open={open} onOpenChange={setOpen} {...props}>\n {children}\n </DropdownMenuPrimitive.Root>\n </ToggleOpenContext.Provider>\n </DropdownMenuVariantContext.Provider>\n );\n}\n\n/** Props for the {@link DropdownMenuTrigger} component. */\nexport type DropdownMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Trigger\n>;\n\n/**\n * The element that toggles the dropdown menu when clicked.\n *\n * On touch devices, the menu only opens if the press-and-release stays within\n * a small movement threshold. A drag that incidentally ends over the trigger\n * (common when scrolling a feed on Android Chrome) is ignored. Mouse and\n * keyboard interactions are unchanged.\n */\nexport const DropdownMenuTrigger = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,\n DropdownMenuTriggerProps\n>((props, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const tapRef = React.useRef<ActiveTap | null>(null);\n\n // The sheet variant opens a Drawer (Dialog), which already suppresses\n // scroll-drag-end synthetic clicks itself — no need for the touch-tap gating below.\n if (variant === \"sheet\") {\n return <DrawerTrigger {...props} ref={ref} />;\n }\n\n // Used outside our DropdownMenu wrapper — fall through to Radix defaults.\n if (toggleOpen === null) {\n return <DropdownMenuPrimitive.Trigger {...props} ref={ref} />;\n }\n\n return (\n <DropdownMenuPrimitive.Trigger\n {...props}\n ref={ref}\n onPointerDown={(event) => {\n props.onPointerDown?.(event);\n if (event.pointerType === \"mouse\" || props.disabled) return;\n // Keep pointerup / pointercancel on this element if the finger drifts off.\n // Optional because jsdom (used in tests) doesn't implement it.\n event.currentTarget.setPointerCapture?.(event.pointerId);\n tapRef.current = {\n pointerId: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n movedPastThreshold: false,\n };\n // preventDefault stops Radix's pointerdown open path via composeEventHandlers.\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n props.onPointerMove?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId || tap.movedPastThreshold) {\n return;\n }\n const dx = event.clientX - tap.x;\n const dy = event.clientY - tap.y;\n if (Math.hypot(dx, dy) > TAP_MOVEMENT_THRESHOLD_PX) {\n tap.movedPastThreshold = true;\n }\n }}\n onPointerUp={(event) => {\n props.onPointerUp?.(event);\n const tap = tapRef.current;\n if (tap === null || event.pointerId !== tap.pointerId) return;\n const wasDrag = tap.movedPastThreshold;\n tapRef.current = null;\n if (!wasDrag && !props.disabled) {\n toggleOpen((prev) => !prev);\n }\n }}\n onPointerCancel={(event) => {\n props.onPointerCancel?.(event);\n const tap = tapRef.current;\n if (tap !== null && event.pointerId === tap.pointerId) {\n tapRef.current = null;\n }\n }}\n />\n );\n});\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\";\n\n/** Props for the {@link DropdownMenuContent} component. */\nexport interface DropdownMenuContentProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {}\n\n/**\n * The positioned content panel rendered inside a portal.\n *\n * Override the portal z-index per-instance via `style={{ zIndex: 1500 }}` or\n * globally with the `--fanvue-ui-portal-z-index` CSS custom property.\n *\n * @example\n * ```tsx\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild>\n * <Button>Open</Button>\n * </DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Option 1</DropdownMenuItem>\n * <DropdownMenuItem>Option 2</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n * ```\n */\nexport const DropdownMenuContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Content>,\n DropdownMenuContentProps\n>(\n (\n {\n className,\n style,\n sideOffset = 4,\n // Radix defaults `avoidCollisions` to true, so passing `collisionPadding`\n // is enough to keep the menu flipping/shifting to stay on screen — no\n // hand-rolled reposition logic needed.\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n onPointerDownOutside,\n onCloseAutoFocus,\n onKeyDown,\n children,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n // Radix returns focus to the trigger when the menu closes. That is right for\n // the keyboard, but Chrome's :focus-visible heuristic also paints the ring on\n // that programmatic refocus, so dismissing with a click left a focus ring\n // sitting on the trigger. Track pointer dismissals and skip the restore for\n // them only — Escape and Tab still hand focus back with the ring.\n const dismissedByPointer = React.useRef(false);\n\n if (variant === \"sheet\") {\n return (\n <DrawerContent\n ref={ref}\n position=\"bottom\"\n // `\"sheet\"` sits flush to the bottom edge at full width; the design draws\n // this panel inset from all three sides and rounded on every corner, which\n // is `\"menu\"`. Both carry the same modal surface.\n variant=\"menu\"\n // The design's `blur + shadow/menu` effect is a background blur, and the\n // panel's own fill is opaque — so the blur has to go on the overlay to be\n // visible at all. Scoped here rather than on DrawerOverlay so only menus\n // shown this way blur the page behind them.\n overlayProps={{ className: \"backdrop-blur-[8px]\" }}\n // `pb-4` gives the design's 16px below the last row. The rows inset\n // themselves horizontally (see the item's `mx-3`) rather than the panel\n // padding doing it, so the header and its rule can still run full width.\n className={cn(\"flex flex-col gap-1 p-1 pb-4\", className)}\n style={style}\n // Both are destructured above for the popper branch's focus-ring\n // handling, which takes them out of `props` — so the sheet branch has\n // to re-attach them or they are silently dropped. `DrawerContent`\n // forwards them to its `DialogPrimitive.Content`, which supports both.\n // Consumers stack sheets on these (a nested sheet's `onCloseAutoFocus`\n // is the only point at which the parent knows the child has finished\n // animating out), so dropping them breaks the flow with no error.\n onPointerDownOutside={onPointerDownOutside}\n onCloseAutoFocus={onCloseAutoFocus}\n onKeyDown={onKeyDown}\n {...props}\n >\n {children}\n </DrawerContent>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n onPointerDownOutside={(event) => {\n dismissedByPointer.current = true;\n onPointerDownOutside?.(event);\n }}\n onCloseAutoFocus={(event) => {\n if (dismissedByPointer.current) event.preventDefault();\n dismissedByPointer.current = false;\n onCloseAutoFocus?.(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) cycleMenuTabStops(event);\n }}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\n // Panel tokens come from `V2 Menu Dropdown` (product file node\n // `7393:62008`): `rounded-lg` (24px) over `Background/Secondary`, a\n // `Border/Strong` stroke, and 8px of padding. The 12px `rounded-sm` is\n // the row radius, not the panel's — the two were transposed here.\n //\n // `backdrop-blur-[4px]` is the CSS equivalent of that node's\n // `blur + shadow/menu` BACKGROUND_BLUR radius 8, which Figma halves on\n // export. It is not a 4-against-8 mismatch.\n \"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-lg border border-border-strong bg-background-secondary p-2 text-content-primary shadow-blur-menu backdrop-blur-[4px]\",\n \"data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out\",\n \"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2\",\n \"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2\",\n className,\n )}\n style={{\n zIndex: \"var(--fanvue-ui-portal-z-index, 50)\",\n maxHeight: \"var(--radix-dropdown-menu-content-available-height)\",\n ...style,\n }}\n {...props}\n >\n {children}\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\nDropdownMenuContent.displayName = \"DropdownMenuContent\";\n\n/** Props for the {@link DropdownMenuGroup} component. */\nexport type DropdownMenuGroupProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuPrimitive.Group\n>;\n\n/**\n * Groups related menu items. Accepts an optional `DropdownMenuLabel`.\n *\n * Requires Radix menu context — not supported inside a `variant=\"sheet\"` menu.\n */\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\";\n"],"names":[],"mappings":";;;;;;;;;AASA,MAAM,4BAA4B;AAMlC,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAE3B,SAAS,gBAAgB,SAAqC;AAC5D,QAAM,QAAuB,CAAA;AAC7B,aAAW,aAAa,QAAQ,iBAA8B,IAAI,mBAAmB,GAAG,GAAG;AACzF,eAAW,WAAW,UAAU,iBAA8B,kBAAkB,GAAG;AACjF,UAAI,QAAQ,WAAW,KAAK,QAAQ,QAAQ,WAAW,KAAK,QAAQ,OAAQ;AAC5E,YAAM,KAAK,OAAO;AAAA,IACpB;AAAA,EACF;AACA,SAAO;AACT;AAMA,SAAS,kBAAkB,OAA+C;AACxE,MAAI,MAAM,QAAQ,SAAS,MAAM,UAAU,MAAM,WAAW,MAAM,QAAS;AAG3E,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,QAAQ,2BAA2B,MAAM,MAAM,cAAe;AACzE,QAAM,QAAQ,gBAAgB,MAAM,aAAa;AACjD,MAAI,MAAM,WAAW,EAAG;AAGxB,QAAM,eAAA;AACN,QAAM,QAAQ,MAAM,QAAQ,MAAM;AAClC,QAAM,OAAO,MAAM,SAAS;AAC5B,QAAM,OAAO,MAAM,WACf,MAAM,SAAS,IAAI,OAAO,QAAQ,CAAC,IACnC,MAAM,UAAU,MAAM,UAAU,OAAO,IAAI,QAAQ,CAAC;AAIxD,QAAM,MAAM,EAAE,eAAe,KAAA,CAAM;AACrC;AAiBO,SAAS,aAAa;AA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AAY,SAAS;AACvB,aACE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,UAAS;AAAA,UAIT,SAAQ;AAAA,UAKR,cAAc,EAAE,WAAW,sBAAA;AAAA,UAI3B,WAAW,GAAG,gCAAgC,SAAS;AAAA,UACvD;AAAA,UAQA;AAAA,UACA;AAAA,UACA;AAAA,UACC,GAAG;AAAA,UAEH;AAAA,QAAA;AAAA,MAAA;AAAA,IAGP;AAEA,WACE,oBAAC,sBAAsB,QAAtB,EACC,UAAA;AAAA,MAAC,sBAAsB;AAAA,MAAtB;AAAA,QACC;AAAA,QACA,sBAAsB,CAAC,UAAU;AAC/B,6BAAmB,UAAU;AAC7B,iCAAuB,KAAK;AAAA,QAC9B;AAAA,QACA,kBAAkB,CAAC,UAAU;AAC3B,cAAI,mBAAmB,QAAS,OAAM,eAAA;AACtC,6BAAmB,UAAU;AAC7B,6BAAmB,KAAK;AAAA,QAC1B;AAAA,QACA,WAAW,CAAC,UAAU;AACpB,sBAAY,KAAK;AACjB,cAAI,CAAC,MAAM,iBAAkB,mBAAkB,KAAK;AAAA,QACtD;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAST;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,WAAW;AAAA,UACX,GAAG;AAAA,QAAA;AAAA,QAEJ,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;AACA,oBAAoB,cAAc;AAY3B,MAAM,oBAAoB,sBAAsB;AACvD,kBAAkB,cAAc;"}
package/dist/index.d.ts CHANGED
@@ -334,6 +334,24 @@ export declare type AISettingsIconProps = BaseIconProps;
334
334
  * A new version is ready to install.
335
335
  * </Alert>
336
336
  * ```
337
+ *
338
+ * @example
339
+ * The CTA sits under the description by default. `layout="trailing"` keeps it
340
+ * inline with the message, which suits short labels and keeps the alert compact.
341
+ * ```tsx
342
+ * <Alert variant="info" layout="trailing" action={<a href="/docs">Learn more</a>}>
343
+ * Scheduled posts now publish in your local timezone.
344
+ * </Alert>
345
+ * ```
346
+ *
347
+ * @example
348
+ * `ctaLabel` renders the button form of the CTA instead of a link — use it when
349
+ * the alert asks the user to do something specific.
350
+ * ```tsx
351
+ * <Alert variant="warning" title="Finish setup" layout="trailing" ctaLabel="Verify now" ctaProps={{ onClick: verify }}>
352
+ * Verify your identity to start receiving payouts.
353
+ * </Alert>
354
+ * ```
337
355
  */
338
356
  export declare const Alert: React_2.ForwardRefExoticComponent<AlertProps & React_2.RefAttributes<HTMLDivElement>>;
339
357
 
@@ -350,6 +368,16 @@ export declare const AlertIcon: React_2.ForwardRefExoticComponent<BaseIconProps
350
368
  /** Props for {@link AlertIcon}. See {@link BaseIconProps} for the shared shape. */
351
369
  export declare type AlertIconProps = BaseIconProps;
352
370
 
371
+ /**
372
+ * Placement of the call-to-action relative to the message.
373
+ *
374
+ * - `"under"` stacks the action beneath the description. Use it when the CTA
375
+ * label is long or the alert is narrow.
376
+ * - `"trailing"` keeps the action inline with the message, which keeps the
377
+ * alert compact and works best with short labels.
378
+ */
379
+ export declare type AlertLayout = "under" | "trailing";
380
+
353
381
  export declare interface AlertProps extends React_2.HTMLAttributes<HTMLDivElement> {
354
382
  /** Visual style variant of the alert. @default "info" */
355
383
  variant?: AlertVariant;
@@ -370,6 +398,24 @@ export declare interface AlertProps extends React_2.HTMLAttributes<HTMLDivElemen
370
398
  * styling via the Radix `Slot` pattern while remaining a real link/button.
371
399
  */
372
400
  action?: React_2.ReactNode;
401
+ /** Placement of the call-to-action relative to the message. @default "under" */
402
+ layout?: AlertLayout;
403
+ /**
404
+ * Label for a built-in call-to-action button, the button form of the CTA.
405
+ * Use it when the alert asks the user to do something specific — activating a
406
+ * feature, or completing setup — rather than pointing at more detail. Ignored
407
+ * when `action` is set.
408
+ */
409
+ ctaLabel?: React_2.ReactNode;
410
+ /**
411
+ * Props forwarded to the built-in call-to-action button (e.g. `onClick`).
412
+ * `variant` and `size` default to `secondary`/`32` and can be overridden.
413
+ *
414
+ * The stacked CTA is `w-full sm:w-fit`. To override the width, match the
415
+ * modifier chain — a bare `w-auto` replaces `w-full` but leaves `sm:w-fit`
416
+ * in place, so pass `sm:` variants too.
417
+ */
418
+ ctaProps?: Omit<ButtonProps, "children" | "asChild">;
373
419
  }
374
420
 
375
421
  /** Visual style variant of the alert. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fanvue/ui",
3
- "version": "3.33.1",
3
+ "version": "3.34.1",
4
4
  "description": "React component library built with Tailwind CSS for Fanvue ecosystem",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",