@fanvue/ui 3.47.0 → 3.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.d.ts +39 -0
- package/dist/charts.mjs +2 -0
- package/dist/charts.mjs.map +1 -1
- package/dist/cjs/charts.cjs +2 -0
- package/dist/cjs/charts.cjs.map +1 -1
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs +7 -3
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartGrid.cjs +31 -0
- package/dist/cjs/components/Chart/ChartGrid.cjs.map +1 -0
- package/dist/cjs/components/ChatInput/ChatInput.cjs +21 -11
- package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +31 -34
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs +5 -4
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +10 -10
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +12 -7
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -1
- package/dist/cjs/components/EmptyState/EmptyState.cjs +9 -1
- package/dist/cjs/components/EmptyState/EmptyState.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.cjs +2 -1
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/Icons/BaseIcon.cjs +5 -1
- package/dist/cjs/components/Icons/BaseIcon.cjs.map +1 -1
- package/dist/cjs/components/Icons/IconDefaults.cjs +26 -0
- package/dist/cjs/components/Icons/IconDefaults.cjs.map +1 -0
- package/dist/cjs/components/Icons/MenuRowIcon.cjs +26 -0
- package/dist/cjs/components/Icons/MenuRowIcon.cjs.map +1 -0
- package/dist/cjs/components/Link/Link.cjs +7 -3
- package/dist/cjs/components/Link/Link.cjs.map +1 -1
- package/dist/cjs/components/MediaPlayChip/MediaPlayChip.cjs +56 -0
- package/dist/cjs/components/MediaPlayChip/MediaPlayChip.cjs.map +1 -0
- package/dist/cjs/components/Select/Select.cjs +13 -10
- package/dist/cjs/components/Select/Select.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsList.cjs +4 -2
- package/dist/cjs/components/Tabs/TabsList.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsListSkeleton.cjs +30 -0
- package/dist/cjs/components/Tabs/TabsListSkeleton.cjs.map +1 -0
- package/dist/cjs/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/cjs/components/UndoAlertPrompt/UndoAlertPrompt.cjs +66 -0
- package/dist/cjs/components/UndoAlertPrompt/UndoAlertPrompt.cjs.map +1 -0
- package/dist/cjs/components/UserItem/UserItem.cjs +6 -1
- package/dist/cjs/components/UserItem/UserItem.cjs.map +1 -1
- package/dist/cjs/index.cjs +7 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs +7 -3
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs.map +1 -1
- package/dist/components/Chart/ChartGrid.mjs +31 -0
- package/dist/components/Chart/ChartGrid.mjs.map +1 -0
- package/dist/components/ChatInput/ChatInput.mjs +21 -11
- package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs +32 -35
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs +5 -4
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +10 -10
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +12 -7
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -1
- package/dist/components/EmptyState/EmptyState.mjs +9 -1
- package/dist/components/EmptyState/EmptyState.mjs.map +1 -1
- package/dist/components/IconButton/IconButton.mjs +2 -1
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/Icons/BaseIcon.mjs +5 -1
- package/dist/components/Icons/BaseIcon.mjs.map +1 -1
- package/dist/components/Icons/IconDefaults.mjs +9 -0
- package/dist/components/Icons/IconDefaults.mjs.map +1 -0
- package/dist/components/Icons/MenuRowIcon.mjs +26 -0
- package/dist/components/Icons/MenuRowIcon.mjs.map +1 -0
- package/dist/components/Link/Link.mjs +7 -3
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/MediaPlayChip/MediaPlayChip.mjs +39 -0
- package/dist/components/MediaPlayChip/MediaPlayChip.mjs.map +1 -0
- package/dist/components/Select/Select.mjs +13 -10
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/Tabs/TabsList.mjs +4 -2
- package/dist/components/Tabs/TabsList.mjs.map +1 -1
- package/dist/components/Tabs/TabsListSkeleton.mjs +13 -0
- package/dist/components/Tabs/TabsListSkeleton.mjs.map +1 -0
- package/dist/components/Tooltip/Tooltip.mjs +1 -1
- package/dist/components/Tooltip/Tooltip.mjs.map +1 -1
- package/dist/components/UndoAlertPrompt/UndoAlertPrompt.mjs +48 -0
- package/dist/components/UndoAlertPrompt/UndoAlertPrompt.mjs.map +1 -0
- package/dist/components/UserItem/UserItem.mjs +6 -1
- package/dist/components/UserItem/UserItem.mjs.map +1 -1
- package/dist/index.d.ts +159 -9
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -1
- package/dist/styles/base.css +23 -0
- package/package.json +1 -1
package/dist/charts.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CartesianGrid } from 'recharts';
|
|
2
|
+
import { JSX } from 'react/jsx-runtime';
|
|
1
3
|
import { Legend } from 'recharts';
|
|
2
4
|
import { LegendPayload } from 'recharts/types/component/DefaultLegendContent';
|
|
3
5
|
import { NameType } from 'recharts/types/component/DefaultTooltipContent';
|
|
@@ -165,6 +167,43 @@ declare type ChartContextValue = {
|
|
|
165
167
|
config: ChartConfig;
|
|
166
168
|
};
|
|
167
169
|
|
|
170
|
+
/**
|
|
171
|
+
* The design-system grid for cartesian charts: dotted horizontal lines and one solid
|
|
172
|
+
* baseline at value 0, above and below which every other line stays dotted. Render
|
|
173
|
+
* it as a direct child of a Recharts `<LineChart>`, `<AreaChart>` or `<BarChart>`.
|
|
174
|
+
*
|
|
175
|
+
* Grid lines use `neutral-alphas-200`, the colour `ChartContainer` gives Recharts'
|
|
176
|
+
* default grid. The baseline uses `border-strong`.
|
|
177
|
+
*
|
|
178
|
+
* The baseline extends the y-axis domain to include zero, so it stays visible when
|
|
179
|
+
* every value is negative. Leave `<YAxis domain>` at its default: the axis then starts
|
|
180
|
+
* at zero, or at the lowest value when the data goes below zero.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```tsx
|
|
184
|
+
* <ChartContainer config={chartConfig}>
|
|
185
|
+
* <LineChart data={data}>
|
|
186
|
+
* <ChartGrid />
|
|
187
|
+
* <XAxis dataKey="day" />
|
|
188
|
+
* <YAxis />
|
|
189
|
+
* <Line dataKey="net" stroke="var(--color-net)" />
|
|
190
|
+
* </LineChart>
|
|
191
|
+
* </ChartContainer>
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export declare function ChartGrid(props: ChartGridProps): JSX.Element;
|
|
195
|
+
|
|
196
|
+
export declare namespace ChartGrid {
|
|
197
|
+
var displayName: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Props for {@link ChartGrid}. Forwarded to Recharts' `CartesianGrid`; `xAxisId` and
|
|
202
|
+
* `yAxisId` also place the zero baseline. The line colour and dash are fixed by the
|
|
203
|
+
* design system, so `stroke` and `strokeDasharray` are not accepted.
|
|
204
|
+
*/
|
|
205
|
+
export declare type ChartGridProps = Omit<React_2.ComponentProps<typeof CartesianGrid>, "stroke" | "strokeDasharray">;
|
|
206
|
+
|
|
168
207
|
/** Re-export of Recharts `Legend` — use with `content={<ChartLegendContent />}`. */
|
|
169
208
|
export declare const ChartLegend: typeof Legend;
|
|
170
209
|
|
package/dist/charts.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ChartCard } from "./components/Chart/ChartCard.mjs";
|
|
3
3
|
import { ChartCenterLabel } from "./components/Chart/ChartCenterLabel.mjs";
|
|
4
4
|
import { ChartContainer } from "./components/Chart/ChartContainer.mjs";
|
|
5
|
+
import { ChartGrid } from "./components/Chart/ChartGrid.mjs";
|
|
5
6
|
import { ChartLegend, ChartLegendContent } from "./components/Chart/ChartLegend.mjs";
|
|
6
7
|
import { ChartLoadingOverlay } from "./components/Chart/ChartLoadingOverlay.mjs";
|
|
7
8
|
import { ChartMetricTrend } from "./components/Chart/ChartMetricTrend.mjs";
|
|
@@ -16,6 +17,7 @@ export {
|
|
|
16
17
|
ChartCard,
|
|
17
18
|
ChartCenterLabel,
|
|
18
19
|
ChartContainer,
|
|
20
|
+
ChartGrid,
|
|
19
21
|
ChartLegend,
|
|
20
22
|
ChartLegendContent,
|
|
21
23
|
ChartLoadingOverlay,
|
package/dist/charts.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"charts.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
package/dist/cjs/charts.cjs
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
const ChartCard = require("./components/Chart/ChartCard.cjs");
|
|
5
5
|
const ChartCenterLabel = require("./components/Chart/ChartCenterLabel.cjs");
|
|
6
6
|
const ChartContainer = require("./components/Chart/ChartContainer.cjs");
|
|
7
|
+
const ChartGrid = require("./components/Chart/ChartGrid.cjs");
|
|
7
8
|
const ChartLegend = require("./components/Chart/ChartLegend.cjs");
|
|
8
9
|
const ChartLoadingOverlay = require("./components/Chart/ChartLoadingOverlay.cjs");
|
|
9
10
|
const ChartMetricTrend = require("./components/Chart/ChartMetricTrend.cjs");
|
|
@@ -17,6 +18,7 @@ const useChart = require("./components/Chart/useChart.cjs");
|
|
|
17
18
|
exports.ChartCard = ChartCard.ChartCard;
|
|
18
19
|
exports.ChartCenterLabel = ChartCenterLabel.ChartCenterLabel;
|
|
19
20
|
exports.ChartContainer = ChartContainer.ChartContainer;
|
|
21
|
+
exports.ChartGrid = ChartGrid.ChartGrid;
|
|
20
22
|
exports.ChartLegend = ChartLegend.ChartLegend;
|
|
21
23
|
exports.ChartLegendContent = ChartLegend.ChartLegendContent;
|
|
22
24
|
exports.ChartLoadingOverlay = ChartLoadingOverlay.ChartLoadingOverlay;
|
package/dist/cjs/charts.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"charts.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -155,9 +155,13 @@ const RollingNumber = React__namespace.forwardRef(
|
|
|
155
155
|
)
|
|
156
156
|
},
|
|
157
157
|
`digit-${index}`
|
|
158
|
-
) : (
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
159
|
+
"span",
|
|
160
|
+
{
|
|
161
|
+
style: { height: "1em", lineHeight: "1em" },
|
|
162
|
+
children: char
|
|
163
|
+
},
|
|
164
|
+
`separator-${index}`
|
|
161
165
|
)
|
|
162
166
|
) })
|
|
163
167
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimatedNumber.cjs","sources":["../../../../src/components/AnimatedNumber/AnimatedNumber.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { usePrefersReducedMotion } from \"@/utils/usePrefersReducedMotion\";\n\n/** How a value change is animated. */\nexport type AnimatedNumberVariant =\n /**\n * Per-digit odometer: each digit column slides to its new value and the box\n * width eases when the digit count changes. Reads as mechanical, so it suits\n * a single headline figure rather than a grid of them.\n */\n | \"roll\"\n /**\n * Interpolates the value and re-formats it each frame, so the whole number\n * counts from old to new. Calmer than `roll` when several figures on a page\n * change at once.\n */\n | \"count\";\n\n/** Props for {@link AnimatedNumber}. */\nexport interface AnimatedNumberProps\n extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** The value to display. Animates whenever this changes. */\n value: number;\n /**\n * Turns the value into the displayed string. Receives interpolated values in\n * the `count` variant, so it must handle non-integers.\n * @default String(Math.round(value))\n */\n format?: (value: number) => string;\n /** Which animation to run. @default \"count\" */\n variant?: AnimatedNumberVariant;\n /** Animation duration in milliseconds. @default 500 */\n durationMs?: number;\n}\n\nconst DEFAULT_DURATION_MS = 500;\n\nconst defaultFormat = (value: number) => String(Math.round(value));\n\n/** Decelerating ease, so the value settles rather than stopping abruptly. */\nconst easeOutCubic = (t: number) => 1 - (1 - t) ** 3;\n\nconst DIGITS = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\n\nconst isDigit = (char: string) => char >= \"0\" && char <= \"9\";\n\n/**\n * Animates a number when its value changes, either by rolling each digit like\n * an odometer or by counting through the intermediate values.\n *\n * Both variants collapse to an instant swap under\n * `prefers-reduced-motion: reduce`.\n *\n * The rolling variant stacks all ten digits in each column, so the visual is\n * hidden from assistive technology and the formatted value is exposed once as\n * text instead.\n *\n * @example\n * ```tsx\n * // Headline figure\n * <AnimatedNumber value={totalGross} format={formatPrice} variant=\"roll\" />\n *\n * // Supporting figure\n * <AnimatedNumber value={activeFans} variant=\"count\" />\n * ```\n */\nexport const AnimatedNumber = React.forwardRef<HTMLSpanElement, AnimatedNumberProps>(\n (\n {\n value,\n format = defaultFormat,\n variant = \"count\",\n durationMs = DEFAULT_DURATION_MS,\n className,\n ...props\n },\n ref,\n ) => {\n const reducedMotion = usePrefersReducedMotion();\n\n if (variant === \"roll\") {\n return (\n <RollingNumber\n ref={ref}\n value={value}\n format={format}\n durationMs={reducedMotion ? 0 : durationMs}\n className={className}\n {...props}\n />\n );\n }\n\n return (\n <CountingNumber\n ref={ref}\n value={value}\n format={format}\n durationMs={reducedMotion ? 0 : durationMs}\n className={className}\n {...props}\n />\n );\n },\n);\n\nAnimatedNumber.displayName = \"AnimatedNumber\";\n\ntype VariantProps = Omit<AnimatedNumberProps, \"variant\" | \"format\" | \"durationMs\"> & {\n format: (value: number) => string;\n durationMs: number;\n};\n\nconst CountingNumber = React.forwardRef<HTMLSpanElement, VariantProps>(\n ({ value, format, durationMs, className, ...props }, ref) => {\n const [displayValue, setDisplayValue] = React.useState(value);\n // Tracks what is on screen, so an interrupted tween resumes from there. Storing\n // the abandoned *target* instead would start the next tween from a number that\n // was never displayed, which shows as a jump to the old target before counting\n // on — a refetch or filter change landing mid-animation is enough to hit it.\n const displayRef = React.useRef(value);\n\n React.useEffect(() => {\n const from = displayRef.current;\n if (from === value || durationMs === 0) {\n displayRef.current = value;\n setDisplayValue(value);\n return;\n }\n\n let frame = 0;\n let start: number | undefined;\n\n const step = (now: number) => {\n start ??= now;\n const progress = Math.min((now - start) / durationMs, 1);\n const next = from + (value - from) * easeOutCubic(progress);\n displayRef.current = next;\n setDisplayValue(next);\n if (progress < 1) {\n frame = requestAnimationFrame(step);\n }\n };\n\n frame = requestAnimationFrame(step);\n return () => cancelAnimationFrame(frame);\n }, [value, durationMs]);\n\n return (\n <span ref={ref} className={cn(\"tabular-nums\", className)} {...props}>\n {format(displayValue)}\n </span>\n );\n },\n);\n\nCountingNumber.displayName = \"AnimatedNumber.Counting\";\n\nconst RollingNumber = React.forwardRef<HTMLSpanElement, VariantProps>(\n ({ value, format, durationMs, className, ...props }, ref) => {\n const display = format(value);\n const characters = React.useMemo(() => Array.from(display), [display]);\n\n // Lock the box to its measured width so a change in digit count eases\n // instead of snapping: `width: auto` cannot be transitioned.\n const contentRef = React.useRef<HTMLSpanElement>(null);\n const [boxWidth, setBoxWidth] = React.useState<number>();\n\n // On the render where the width is still `auto` there is nothing to\n // transition from, so the duration is zeroed. This is belt-and-braces rather\n // than load-bearing: `auto` to a length is not interpolatable, so no\n // transition would run either way.\n const hasMeasured = boxWidth !== undefined;\n\n // Re-measure rather than measuring once per `display`: the box is\n // `overflow-hidden`, so a web font landing after the first measurement leaves\n // the locked width too narrow for the wider glyphs and clips the number until\n // the value next changes, which for a headline figure may be never. Observing\n // covers a container change too. Same approach as `useCyclingTextTrackWidth`.\n React.useLayoutEffect(() => {\n const node = contentRef.current;\n if (!node || !display) {\n return;\n }\n\n const measure = () => {\n const measured = node.scrollWidth;\n if (measured) {\n setBoxWidth(measured);\n }\n };\n\n measure();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, [display]);\n\n return (\n <span\n ref={ref}\n className={cn(\"inline-flex overflow-hidden tabular-nums\", className)}\n style={{\n width: boxWidth,\n transitionProperty: \"width\",\n transitionDuration: hasMeasured ? `${durationMs}ms` : \"0ms\",\n transitionTimingFunction: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n }}\n {...props}\n >\n {/* The digit columns list 0-9 apiece, which assistive tech would read\n out in full, so expose the formatted value as text instead. */}\n <span className=\"sr-only\">{display}</span>\n <span ref={contentRef} aria-hidden className=\"inline-flex whitespace-pre\">\n {characters.map((char, index) =>\n isDigit(char) ? (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: a column is a position in the number, so it must keep its identity (and animate) when its digit changes\n key={`digit-${index}`}\n className=\"relative inline-block overflow-hidden\"\n style={{ height: \"1em\", lineHeight: \"1em\" }}\n >\n <span\n className=\"flex flex-col\"\n style={{\n transform: `translateY(-${Number(char) * 10}%)`,\n transitionProperty: \"transform\",\n transitionDuration: `${durationMs}ms`,\n transitionTimingFunction: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n }}\n >\n {DIGITS.map((digit) => (\n <span key={digit} style={{ height: \"1em\", lineHeight: \"1em\" }}>\n {digit}\n </span>\n ))}\n </span>\n </span>\n ) : (\n // biome-ignore lint/suspicious/noArrayIndexKey: same positional identity as the digit columns\n <span key={`separator-${index}`}>{char}</span>\n ),\n )}\n </span>\n </span>\n );\n },\n);\n\nRollingNumber.displayName = \"AnimatedNumber.Rolling\";\n"],"names":["React","usePrefersReducedMotion","jsx","cn","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,sBAAsB;AAE5B,MAAM,gBAAgB,CAAC,UAAkB,OAAO,KAAK,MAAM,KAAK,CAAC;AAGjE,MAAM,eAAe,CAAC,MAAc,KAAK,IAAI,MAAM;AAEnD,MAAM,SAAS,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAEhE,MAAM,UAAU,CAAC,SAAiB,QAAQ,OAAO,QAAQ;AAsBlD,MAAM,iBAAiBA,iBAAM;AAAA,EAClC,CACE;AAAA,IACE;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,aAAa;AAAA,IACb;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,gBAAgBC,wBAAAA,wBAAA;AAEtB,QAAI,YAAY,QAAQ;AACtB,aACEC,2BAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA,YAAY,gBAAgB,IAAI;AAAA,UAChC;AAAA,UACC,GAAG;AAA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AAAA,gBAEpC,UAAAA,2BAAAA;AAAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAU;AAAA,oBACV,OAAO;AAAA,sBACL,WAAW,eAAe,OAAO,IAAI,IAAI,EAAE;AAAA,sBAC3C,oBAAoB;AAAA,sBACpB,oBAAoB,GAAG,UAAU;AAAA,sBACjC,0BAA0B;AAAA,oBAAA;AAAA,oBAG3B,UAAA,OAAO,IAAI,CAAC,yCACV,QAAA,EAAiB,OAAO,EAAE,QAAQ,OAAO,YAAY,MAAA,GACnD,UAAA,MAAA,GADQ,KAEX,CACD;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACH;AAAA,cAlBK,SAAS,KAAK;AAAA,YAAA;AAAA;AAAA,cAsBrBA,2BAAAA,IAAC,QAAA,EAAiC,UAAA,KAAA,GAAvB,aAAa,KAAK,EAAU;AAAA;AAAA,UAAA,EAE3C,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,cAAc,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"AnimatedNumber.cjs","sources":["../../../../src/components/AnimatedNumber/AnimatedNumber.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { usePrefersReducedMotion } from \"@/utils/usePrefersReducedMotion\";\n\n/** How a value change is animated. */\nexport type AnimatedNumberVariant =\n /**\n * Per-digit odometer: each digit column slides to its new value and the box\n * width eases when the digit count changes. Reads as mechanical, so it suits\n * a single headline figure rather than a grid of them.\n */\n | \"roll\"\n /**\n * Interpolates the value and re-formats it each frame, so the whole number\n * counts from old to new. Calmer than `roll` when several figures on a page\n * change at once.\n */\n | \"count\";\n\n/** Props for {@link AnimatedNumber}. */\nexport interface AnimatedNumberProps\n extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** The value to display. Animates whenever this changes. */\n value: number;\n /**\n * Turns the value into the displayed string. Receives interpolated values in\n * the `count` variant, so it must handle non-integers.\n * @default String(Math.round(value))\n */\n format?: (value: number) => string;\n /** Which animation to run. @default \"count\" */\n variant?: AnimatedNumberVariant;\n /** Animation duration in milliseconds. @default 500 */\n durationMs?: number;\n}\n\nconst DEFAULT_DURATION_MS = 500;\n\nconst defaultFormat = (value: number) => String(Math.round(value));\n\n/** Decelerating ease, so the value settles rather than stopping abruptly. */\nconst easeOutCubic = (t: number) => 1 - (1 - t) ** 3;\n\nconst DIGITS = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\n\nconst isDigit = (char: string) => char >= \"0\" && char <= \"9\";\n\n/**\n * Animates a number when its value changes, either by rolling each digit like\n * an odometer or by counting through the intermediate values.\n *\n * Both variants collapse to an instant swap under\n * `prefers-reduced-motion: reduce`.\n *\n * The rolling variant stacks all ten digits in each column, so the visual is\n * hidden from assistive technology and the formatted value is exposed once as\n * text instead.\n *\n * @example\n * ```tsx\n * // Headline figure\n * <AnimatedNumber value={totalGross} format={formatPrice} variant=\"roll\" />\n *\n * // Supporting figure\n * <AnimatedNumber value={activeFans} variant=\"count\" />\n * ```\n */\nexport const AnimatedNumber = React.forwardRef<HTMLSpanElement, AnimatedNumberProps>(\n (\n {\n value,\n format = defaultFormat,\n variant = \"count\",\n durationMs = DEFAULT_DURATION_MS,\n className,\n ...props\n },\n ref,\n ) => {\n const reducedMotion = usePrefersReducedMotion();\n\n if (variant === \"roll\") {\n return (\n <RollingNumber\n ref={ref}\n value={value}\n format={format}\n durationMs={reducedMotion ? 0 : durationMs}\n className={className}\n {...props}\n />\n );\n }\n\n return (\n <CountingNumber\n ref={ref}\n value={value}\n format={format}\n durationMs={reducedMotion ? 0 : durationMs}\n className={className}\n {...props}\n />\n );\n },\n);\n\nAnimatedNumber.displayName = \"AnimatedNumber\";\n\ntype VariantProps = Omit<AnimatedNumberProps, \"variant\" | \"format\" | \"durationMs\"> & {\n format: (value: number) => string;\n durationMs: number;\n};\n\nconst CountingNumber = React.forwardRef<HTMLSpanElement, VariantProps>(\n ({ value, format, durationMs, className, ...props }, ref) => {\n const [displayValue, setDisplayValue] = React.useState(value);\n // Tracks what is on screen, so an interrupted tween resumes from there. Storing\n // the abandoned *target* instead would start the next tween from a number that\n // was never displayed, which shows as a jump to the old target before counting\n // on — a refetch or filter change landing mid-animation is enough to hit it.\n const displayRef = React.useRef(value);\n\n React.useEffect(() => {\n const from = displayRef.current;\n if (from === value || durationMs === 0) {\n displayRef.current = value;\n setDisplayValue(value);\n return;\n }\n\n let frame = 0;\n let start: number | undefined;\n\n const step = (now: number) => {\n start ??= now;\n const progress = Math.min((now - start) / durationMs, 1);\n const next = from + (value - from) * easeOutCubic(progress);\n displayRef.current = next;\n setDisplayValue(next);\n if (progress < 1) {\n frame = requestAnimationFrame(step);\n }\n };\n\n frame = requestAnimationFrame(step);\n return () => cancelAnimationFrame(frame);\n }, [value, durationMs]);\n\n return (\n <span ref={ref} className={cn(\"tabular-nums\", className)} {...props}>\n {format(displayValue)}\n </span>\n );\n },\n);\n\nCountingNumber.displayName = \"AnimatedNumber.Counting\";\n\nconst RollingNumber = React.forwardRef<HTMLSpanElement, VariantProps>(\n ({ value, format, durationMs, className, ...props }, ref) => {\n const display = format(value);\n const characters = React.useMemo(() => Array.from(display), [display]);\n\n // Lock the box to its measured width so a change in digit count eases\n // instead of snapping: `width: auto` cannot be transitioned.\n const contentRef = React.useRef<HTMLSpanElement>(null);\n const [boxWidth, setBoxWidth] = React.useState<number>();\n\n // On the render where the width is still `auto` there is nothing to\n // transition from, so the duration is zeroed. This is belt-and-braces rather\n // than load-bearing: `auto` to a length is not interpolatable, so no\n // transition would run either way.\n const hasMeasured = boxWidth !== undefined;\n\n // Re-measure rather than measuring once per `display`: the box is\n // `overflow-hidden`, so a web font landing after the first measurement leaves\n // the locked width too narrow for the wider glyphs and clips the number until\n // the value next changes, which for a headline figure may be never. Observing\n // covers a container change too. Same approach as `useCyclingTextTrackWidth`.\n React.useLayoutEffect(() => {\n const node = contentRef.current;\n if (!node || !display) {\n return;\n }\n\n const measure = () => {\n const measured = node.scrollWidth;\n if (measured) {\n setBoxWidth(measured);\n }\n };\n\n measure();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, [display]);\n\n return (\n <span\n ref={ref}\n className={cn(\"inline-flex overflow-hidden tabular-nums\", className)}\n style={{\n width: boxWidth,\n transitionProperty: \"width\",\n transitionDuration: hasMeasured ? `${durationMs}ms` : \"0ms\",\n transitionTimingFunction: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n }}\n {...props}\n >\n {/* The digit columns list 0-9 apiece, which assistive tech would read\n out in full, so expose the formatted value as text instead. */}\n <span className=\"sr-only\">{display}</span>\n <span ref={contentRef} aria-hidden className=\"inline-flex whitespace-pre\">\n {characters.map((char, index) =>\n isDigit(char) ? (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: a column is a position in the number, so it must keep its identity (and animate) when its digit changes\n key={`digit-${index}`}\n className=\"relative inline-block overflow-hidden\"\n style={{ height: \"1em\", lineHeight: \"1em\" }}\n >\n <span\n className=\"flex flex-col\"\n style={{\n transform: `translateY(-${Number(char) * 10}%)`,\n transitionProperty: \"transform\",\n transitionDuration: `${durationMs}ms`,\n transitionTimingFunction: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n }}\n >\n {DIGITS.map((digit) => (\n <span key={digit} style={{ height: \"1em\", lineHeight: \"1em\" }}>\n {digit}\n </span>\n ))}\n </span>\n </span>\n ) : (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: same positional identity as the digit columns\n key={`separator-${index}`}\n style={{ height: \"1em\", lineHeight: \"1em\" }}\n >\n {char}\n </span>\n ),\n )}\n </span>\n </span>\n );\n },\n);\n\nRollingNumber.displayName = \"AnimatedNumber.Rolling\";\n"],"names":["React","usePrefersReducedMotion","jsx","cn","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,sBAAsB;AAE5B,MAAM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AAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,cAAc,cAAc;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const recharts = require("recharts");
|
|
6
|
+
function ChartGrid(props) {
|
|
7
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9
|
+
recharts.CartesianGrid,
|
|
10
|
+
{
|
|
11
|
+
vertical: false,
|
|
12
|
+
...props,
|
|
13
|
+
stroke: "var(--color-neutral-alphas-200)",
|
|
14
|
+
strokeDasharray: "2 4"
|
|
15
|
+
}
|
|
16
|
+
),
|
|
17
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18
|
+
recharts.ReferenceLine,
|
|
19
|
+
{
|
|
20
|
+
y: 0,
|
|
21
|
+
xAxisId: props.xAxisId,
|
|
22
|
+
yAxisId: props.yAxisId,
|
|
23
|
+
stroke: "var(--color-border-strong)",
|
|
24
|
+
ifOverflow: "extendDomain"
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
ChartGrid.displayName = "ChartGrid";
|
|
30
|
+
exports.ChartGrid = ChartGrid;
|
|
31
|
+
//# sourceMappingURL=ChartGrid.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartGrid.cjs","sources":["../../../../src/components/Chart/ChartGrid.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { CartesianGrid, ReferenceLine } from \"recharts\";\n\n/**\n * Props for {@link ChartGrid}. Forwarded to Recharts' `CartesianGrid`; `xAxisId` and\n * `yAxisId` also place the zero baseline. The line colour and dash are fixed by the\n * design system, so `stroke` and `strokeDasharray` are not accepted.\n */\nexport type ChartGridProps = Omit<\n React.ComponentProps<typeof CartesianGrid>,\n \"stroke\" | \"strokeDasharray\"\n>;\n\n/**\n * The design-system grid for cartesian charts: dotted horizontal lines and one solid\n * baseline at value 0, above and below which every other line stays dotted. Render\n * it as a direct child of a Recharts `<LineChart>`, `<AreaChart>` or `<BarChart>`.\n *\n * Grid lines use `neutral-alphas-200`, the colour `ChartContainer` gives Recharts'\n * default grid. The baseline uses `border-strong`.\n *\n * The baseline extends the y-axis domain to include zero, so it stays visible when\n * every value is negative. Leave `<YAxis domain>` at its default: the axis then starts\n * at zero, or at the lowest value when the data goes below zero.\n *\n * @example\n * ```tsx\n * <ChartContainer config={chartConfig}>\n * <LineChart data={data}>\n * <ChartGrid />\n * <XAxis dataKey=\"day\" />\n * <YAxis />\n * <Line dataKey=\"net\" stroke=\"var(--color-net)\" />\n * </LineChart>\n * </ChartContainer>\n * ```\n */\nexport function ChartGrid(props: ChartGridProps) {\n return (\n <>\n <CartesianGrid\n vertical={false}\n {...props}\n stroke=\"var(--color-neutral-alphas-200)\"\n strokeDasharray=\"2 4\"\n />\n <ReferenceLine\n y={0}\n xAxisId={props.xAxisId}\n yAxisId={props.yAxisId}\n stroke=\"var(--color-border-strong)\"\n ifOverflow=\"extendDomain\"\n />\n </>\n );\n}\n\nChartGrid.displayName = \"ChartGrid\";\n"],"names":["jsxs","Fragment","jsx","CartesianGrid","ReferenceLine"],"mappings":";;;;;AAqCO,SAAS,UAAU,OAAuB;AAC/C,SACEA,2BAAAA,KAAAC,qBAAA,EACE,UAAA;AAAA,IAAAC,2BAAAA;AAAAA,MAACC,SAAAA;AAAAA,MAAA;AAAA,QACC,UAAU;AAAA,QACT,GAAG;AAAA,QACJ,QAAO;AAAA,QACP,iBAAgB;AAAA,MAAA;AAAA,IAAA;AAAA,IAElBD,2BAAAA;AAAAA,MAACE,SAAAA;AAAAA,MAAA;AAAA,QACC,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,QACf,SAAS,MAAM;AAAA,QACf,QAAO;AAAA,QACP,YAAW;AAAA,MAAA;AAAA,IAAA;AAAA,EACb,GACF;AAEJ;AAEA,UAAU,cAAc;;"}
|
|
@@ -10,6 +10,7 @@ const AddIcon = require("../Icons/AddIcon.cjs");
|
|
|
10
10
|
const ArrowUpIcon = require("../Icons/ArrowUpIcon.cjs");
|
|
11
11
|
const ChevronDownIcon = require("../Icons/ChevronDownIcon.cjs");
|
|
12
12
|
const CloseIcon = require("../Icons/CloseIcon.cjs");
|
|
13
|
+
const MenuRowIcon = require("../Icons/MenuRowIcon.cjs");
|
|
13
14
|
const TickIcon = require("../Icons/TickIcon.cjs");
|
|
14
15
|
const DropdownMenuRoot = require("../DropdownMenu/DropdownMenuRoot.cjs");
|
|
15
16
|
const DropdownMenuItem = require("../DropdownMenu/DropdownMenuItem.cjs");
|
|
@@ -312,8 +313,9 @@ function InlineSelect({
|
|
|
312
313
|
/* @__PURE__ */ jsxRuntime.jsx(Drawer.DrawerTrigger, { asChild: true, children: trigger }),
|
|
313
314
|
/* @__PURE__ */ jsxRuntime.jsxs(Drawer.DrawerContent, { position: "bottom", variant: "sheet", children: [
|
|
314
315
|
/* @__PURE__ */ jsxRuntime.jsx(Drawer.DrawerHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(Drawer.DrawerTitle, { className: "typography-header-heading-xs", children: menuTitle ?? "Select an option" }) }),
|
|
315
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1 overflow-y-auto px-
|
|
316
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1 overflow-y-auto px-2 pb-2", role: "listbox", children: options.map((option) => {
|
|
316
317
|
const isSelected = option.value === value;
|
|
318
|
+
const hasDescription = !!option.description;
|
|
317
319
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
318
320
|
"button",
|
|
319
321
|
{
|
|
@@ -325,21 +327,29 @@ function InlineSelect({
|
|
|
325
327
|
setOpen(false);
|
|
326
328
|
},
|
|
327
329
|
className: cn.cn(
|
|
328
|
-
"flex w-full
|
|
330
|
+
"group flex min-h-10 w-full gap-2 rounded-sm px-3 py-2 text-left outline-none",
|
|
331
|
+
hasDescription ? "items-start" : "items-center",
|
|
329
332
|
"focus-visible:shadow-focus-ring",
|
|
330
|
-
"typography-body-
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
// the selected option from a hovered-but-unselected one.
|
|
334
|
-
isSelected && ["bg-neutral-alphas-100", "hover:bg-neutral-alphas-200"]
|
|
333
|
+
"typography-body-small-14px-regular text-content-primary hover:bg-interaction-hover",
|
|
334
|
+
// The selected option shares the hover fill, as in DropdownMenuItem.
|
|
335
|
+
isSelected && "bg-interaction-hover"
|
|
335
336
|
),
|
|
336
337
|
children: [
|
|
337
|
-
option.icon && /* @__PURE__ */ jsxRuntime.jsx(
|
|
338
|
+
option.icon && /* @__PURE__ */ jsxRuntime.jsx(MenuRowIcon.MenuRowIcon, { alignToTitle: hasDescription, children: option.icon }),
|
|
338
339
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
339
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
340
|
-
|
|
340
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
341
|
+
"span",
|
|
342
|
+
{
|
|
343
|
+
className: cn.cn(
|
|
344
|
+
"truncate",
|
|
345
|
+
hasDescription && "typography-body-small-14px-semibold"
|
|
346
|
+
),
|
|
347
|
+
children: option.menuLabel ?? option.label
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
hasDescription && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-small-14px-regular truncate text-content-secondary", children: option.description })
|
|
341
351
|
] }),
|
|
342
|
-
isSelected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex shrink-0 items-center
|
|
352
|
+
isSelected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn("flex shrink-0 items-center", hasDescription && "h-4.5"), children: /* @__PURE__ */ jsxRuntime.jsx(SelectedTick, {}) })
|
|
343
353
|
]
|
|
344
354
|
},
|
|
345
355
|
option.value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatInput.cjs","sources":["../../../../src/components/ChatInput/ChatInput.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Drawer, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger } from \"../Drawer/Drawer\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from \"../DropdownMenu/DropdownMenu\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { AddIcon } from \"../Icons/AddIcon\";\nimport { ArrowUpIcon } from \"../Icons/ArrowUpIcon\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { TickIcon } from \"../Icons/TickIcon\";\n\n/** A single image thumbnail in the built-in attachment strip. */\nexport interface ChatInputAttachmentItem {\n /** Stable id passed to {@link ChatInputProps.onAttachmentRemove} and used as React `key`. */\n id: string;\n /** Image URL for the thumbnail. */\n src: string;\n /** Optional value passed to the remove control `aria-label`. */\n ariaLabel?: string;\n}\n\n/** A single option for the inline model/dropdown selector. */\nexport interface ChatInputSelectOption {\n /** Unique value for this option. */\n value: string;\n /** Short label shown on the collapsed trigger button (e.g. \"Sonnet 4.6\"). */\n label: string;\n /**\n * Optional longer title shown on the option's row inside the open menu/sheet\n * (e.g. \"Claude Sonnet 4.6\"). Falls back to {@link label} when omitted.\n */\n menuLabel?: string;\n /** Optional secondary text shown below the label in the dropdown menu. */\n description?: string;\n /** Optional icon rendered to the left of the label. */\n icon?: React.ReactNode;\n}\n\n/**\n * Props for {@link ChatInput}. Standard textarea HTML attributes are forwarded to the inner\n * `<textarea>` except `className` (applied to the outer container), `rows` (use `minRows`), and\n * `onSubmit` (replaced by the chat message submit callback).\n */\nexport interface ChatInputProps\n extends Omit<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n \"className\" | \"rows\" | \"onSubmit\"\n > {\n /** Minimum number of visible rows. @default 1 */\n minRows?: number;\n /** Maximum number of visible rows before scrolling. @default 6 */\n maxRows?: number;\n /** Whether a submission is in progress (disables submit, shows visual feedback). @default false */\n loading?: boolean;\n /**\n * Callback fired when the user submits (clicks the send button or presses Enter without Shift).\n * Receives the current trimmed text value.\n */\n onSubmit?: (value: string) => void;\n /**\n * When `true`, renders an \"attach file\" button in the bottom-left toolbar.\n * @default false\n */\n showFileButton?: boolean;\n /** Callback fired when the attach-file button is clicked. Only relevant when `showFileButton` is `true`. */\n onFileClick?: () => void;\n /** Accessible label for the attach-file button. @default \"Attach file\" */\n fileButtonAriaLabel?: string;\n /** Accessible label for the submit button. @default \"Send message\" */\n submitAriaLabel?: string;\n /** Icon element for the submit button. @default `<ArrowUpIcon />` */\n submitIcon?: React.ReactNode;\n /**\n * Optional content rendered in the bottom-right toolbar, to the left of the submit button.\n * When provided, takes precedence over the built-in `selectOptions` dropdown.\n */\n toolbarRight?: React.ReactNode;\n /**\n * Options for the built-in inline dropdown selector (e.g. model picker).\n * Ignored when `toolbarRight` is provided.\n */\n selectOptions?: ChatInputSelectOption[];\n /**\n * How the built-in selector presents its options:\n * - `\"menu\"` (default) — a dropdown anchored to the trigger, for pointer/desktop.\n * - `\"sheet\"` — a bottom sheet, for mobile/touch viewports.\n *\n * The viewport decision belongs to the consumer (it owns the breakpoint\n * source of truth), so pass e.g. `selectVariant={isDesktop ? \"menu\" : \"sheet\"}`.\n * @default \"menu\"\n */\n selectVariant?: \"menu\" | \"sheet\";\n /**\n * Title shown at the top of the `\"sheet\"` variant of the built-in selector\n * (e.g. \"Switch AI Model\"). @default \"Select an option\"\n */\n selectMenuTitle?: string;\n /** Currently selected value for the built-in dropdown. Should match one of `selectOptions[].value`. */\n selectValue?: string;\n /** When `true`, disables only the built-in dropdown selector. @default false */\n selectDisabled?: boolean;\n /** Callback fired when the user picks a different dropdown option. */\n onSelectChange?: (value: string) => void;\n /**\n * Image attachments shown in the built-in thumbnail strip. Ignored when {@link ChatInputProps.attachmentPreviews}\n * is provided (including `null`).\n */\n attachments?: ChatInputAttachmentItem[];\n /**\n * Called when the user removes a built-in thumbnail. The remove button is disabled when this is\n * omitted or the input is {@link ChatInputProps.disabled}.\n */\n onAttachmentRemove?: (id: string) => void;\n /**\n * Replaces the built-in attachment strip entirely. When set to any value other than `undefined`\n * (including `null` or `[]`), {@link ChatInputProps.attachments} is ignored.\n */\n attachmentPreviews?: React.ReactNode;\n /** Additional className applied to the outermost container. */\n className?: string;\n}\n\nconst LINE_HEIGHT = 18;\nconst TEXTAREA_PY = 12;\n\nfunction calculateHeight(rows: number): number {\n return LINE_HEIGHT * rows + TEXTAREA_PY * 2;\n}\n\ninterface ChatInputDefaultAttachmentThumbnailsProps {\n attachments: ChatInputAttachmentItem[];\n onAttachmentRemove?: (id: string) => void;\n disabled?: boolean;\n}\n\nfunction ChatInputDefaultAttachmentThumbnails({\n attachments,\n onAttachmentRemove,\n disabled = false,\n}: ChatInputDefaultAttachmentThumbnailsProps) {\n return attachments.map((item) => (\n <div\n key={item.id}\n className=\"relative size-16 shrink-0 overflow-hidden rounded-sm border border-neutral-200 bg-background-secondary\"\n >\n <img src={item.src} alt=\"\" className=\"size-full object-cover\" />\n <IconButton\n variant=\"tertiary\"\n size=\"24\"\n aria-label={item.ariaLabel ? `Remove ${item.ariaLabel}` : \"Remove attachment\"}\n icon={<CloseIcon className=\"!size-3\" />}\n disabled={disabled || !onAttachmentRemove}\n onClick={() => onAttachmentRemove?.(item.id)}\n className=\"absolute top-0.5 right-0.5 size-5 bg-neutral-900/40 p-1 text-white hover:bg-neutral-900/55\"\n />\n </div>\n ));\n}\n\n/**\n * A chat-style multi-line input with an integrated toolbar containing an\n * optional file-attach button, optional right-side controls (e.g. a model\n * selector), and a submit button — all inside a single bordered container.\n *\n * Designed to behave like modern AI chat inputs: auto-grows with content,\n * submits on Enter (Shift+Enter for newlines), and keeps controls inline.\n *\n * @example\n * ```tsx\n * <ChatInput\n * placeholder=\"Type a message...\"\n * onSubmit={(text) => send(text)}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * placeholder=\"Ask the agent...\"\n * showFileButton\n * onFileClick={() => openFilePicker()}\n * selectOptions={[\n * { value: \"fanvue-ai\", label: \"Fanvue AI\", icon: <AIIcon className=\"size-4\" /> },\n * { value: \"example\", label: \"Example\", icon: <BulbIcon className=\"size-4\" /> },\n * ]}\n * selectValue=\"fanvue-ai\"\n * onSelectChange={(v) => setModel(v)}\n * onSubmit={(text) => send(text)}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * showFileButton\n * onFileClick={() => openPicker()}\n * attachments={files}\n * onAttachmentRemove={(id) => setFiles((prev) => prev.filter((f) => f.id !== id))}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * showFileButton\n * onFileClick={() => openPicker()}\n * attachmentPreviews={<CustomVideoStrip items={items} />}\n * />\n * ```\n */\nexport const ChatInput = React.forwardRef<HTMLTextAreaElement, ChatInputProps>(\n (\n {\n className,\n minRows = 1,\n maxRows = 6,\n disabled = false,\n loading = false,\n value,\n defaultValue,\n placeholder,\n maxLength,\n \"aria-label\": ariaLabel,\n onChange,\n onKeyDown,\n onSubmit,\n showFileButton = false,\n onFileClick,\n fileButtonAriaLabel = \"Attach file\",\n submitAriaLabel = \"Send message\",\n submitIcon,\n toolbarRight,\n selectOptions,\n selectVariant = \"menu\",\n selectMenuTitle,\n selectValue,\n selectDisabled = false,\n onSelectChange,\n attachments,\n onAttachmentRemove,\n attachmentPreviews,\n style,\n ...textareaProps\n },\n ref,\n ) => {\n const internalRef = React.useRef<HTMLTextAreaElement>(null);\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? \"\");\n const resolvedValue = value !== undefined ? value : internalValue;\n const isControlled = value !== undefined;\n\n const mergedRef = React.useCallback(\n (node: HTMLTextAreaElement | null) => {\n (internalRef as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n }\n },\n [ref],\n );\n\n const adjustHeight = React.useCallback(() => {\n const textarea = internalRef.current;\n if (!textarea) return;\n\n const minHeight = calculateHeight(minRows);\n const maxHeight = calculateHeight(maxRows);\n\n textarea.style.height = `${minHeight}px`;\n const desired = Math.min(Math.max(textarea.scrollHeight, minHeight), maxHeight);\n textarea.style.height = `${desired}px`;\n }, [minRows, maxRows]);\n\n React.useEffect(() => {\n adjustHeight();\n }, [adjustHeight]);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) {\n setInternalValue(e.target.value);\n }\n onChange?.(e);\n };\n\n const canSubmit = !!String(resolvedValue).trim() && !disabled && !loading;\n\n const handleSubmit = () => {\n const text = String(resolvedValue).trim();\n if (!text || !canSubmit) return;\n onSubmit?.(text);\n if (!isControlled) {\n setInternalValue(\"\");\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n onKeyDown?.(e);\n };\n\n const minHeight = calculateHeight(minRows);\n const maxHeight = calculateHeight(maxRows);\n\n const useCustomAttachmentPreviews = attachmentPreviews !== undefined;\n const customAttachmentStrip = useCustomAttachmentPreviews ? attachmentPreviews : null;\n const defaultAttachmentStrip =\n !useCustomAttachmentPreviews && !!attachments?.length ? (\n <ChatInputDefaultAttachmentThumbnails\n attachments={attachments ?? []}\n disabled={disabled}\n onAttachmentRemove={onAttachmentRemove}\n />\n ) : null;\n const resolvedAttachmentStrip = customAttachmentStrip ?? defaultAttachmentStrip;\n const hasAttachmentStrip = resolvedAttachmentStrip != null;\n\n const selectedOption =\n selectOptions?.find((o) => o.value === selectValue) ?? selectOptions?.[0];\n const resolvedToolbarRight =\n toolbarRight ??\n (selectOptions && selectOptions.length > 0 ? (\n <InlineSelect\n options={selectOptions}\n value={selectValue}\n onChange={onSelectChange}\n disabled={disabled || selectDisabled}\n selectedOption={selectedOption}\n variant={selectVariant}\n menuTitle={selectMenuTitle}\n />\n ) : null);\n\n return (\n <div\n className={cn(\n \"relative flex flex-col gap-6 rounded-lg border border-border-primary bg-surface-primary\",\n \"has-focus-visible:outline-none\",\n \"motion-safe:transition-colors\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n <div className=\"flex flex-col\">\n {hasAttachmentStrip ? (\n <div className=\"flex gap-2 overflow-x-auto px-4 pt-4 pb-2 [scrollbar-width:thin]\">\n {resolvedAttachmentStrip}\n </div>\n ) : null}\n <textarea\n {...textareaProps}\n ref={mergedRef}\n value={isControlled ? value : internalValue}\n placeholder={placeholder}\n maxLength={maxLength}\n disabled={disabled}\n aria-label={ariaLabel ?? placeholder}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n rows={minRows}\n className={cn(\n \"w-full resize-none bg-transparent px-4\",\n hasAttachmentStrip ? \"pt-0\" : \"pt-4\",\n \"typography-body-small-14px-regular text-content-primary\",\n \"placeholder:text-content-tertiary\",\n \"focus:outline-none disabled:cursor-not-allowed\",\n \"overflow-y-auto\",\n )}\n style={{\n minHeight: `${minHeight}px`,\n maxHeight: `${maxHeight}px`,\n ...style,\n }}\n />\n </div>\n\n <div className=\"flex items-center justify-between gap-2 px-4 pb-4\">\n <div className=\"flex items-center gap-1\">\n {showFileButton && (\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<AddIcon />}\n aria-label={fileButtonAriaLabel}\n onClick={onFileClick}\n disabled={disabled}\n className=\"max-sm:-ml-2 sm:border sm:border-border-primary\"\n />\n )}\n </div>\n\n <div className=\"flex items-center gap-1\">\n {resolvedToolbarRight}\n <IconButton\n variant=\"primary\"\n size=\"32\"\n icon={submitIcon ?? <ArrowUpIcon />}\n aria-label={submitAriaLabel}\n onClick={handleSubmit}\n disabled={!canSubmit}\n className=\"disabled:bg-surface-secondary disabled:text-icons-primary disabled:opacity-100\"\n />\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatInput.displayName = \"ChatInput\";\n\ninterface InlineSelectProps {\n options: ChatInputSelectOption[];\n value?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n selectedOption?: ChatInputSelectOption;\n /** Presentation: anchored dropdown (`\"menu\"`) or bottom sheet (`\"sheet\"`). */\n variant: \"menu\" | \"sheet\";\n /** Title for the bottom-sheet header. */\n menuTitle?: string;\n}\n\ninterface SelectTriggerButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Whether the menu/sheet is open (drives chevron rotation + active background). */\n open: boolean;\n selectedOption?: ChatInputSelectOption;\n /** Label shown when no option is selected. */\n fallbackLabel?: string;\n}\n\n/**\n * The collapsed pill trigger (icon + short label + chevron). Shared by the\n * desktop menu and mobile sheet; spreads Radix-injected trigger props via\n * `asChild`.\n */\nconst SelectTriggerButton = React.forwardRef<HTMLButtonElement, SelectTriggerButtonProps>(\n ({ open, selectedOption, fallbackLabel, className, ...props }, ref) => (\n <button\n ref={ref}\n type=\"button\"\n aria-label=\"Select model\"\n className={cn(\n \"typography-description-12px-semibold text-content-primary\",\n \"flex items-center gap-1 rounded-md px-2 py-2\",\n \"hover:bg-neutral-alphas-50 focus-visible:shadow-focus-ring focus-visible:outline-none\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n \"motion-safe:transition-colors\",\n open && \"bg-neutral-alphas-50\",\n className,\n )}\n {...props}\n >\n {selectedOption?.icon && (\n <span className=\"flex shrink-0 items-center [&>svg]:size-4\">{selectedOption.icon}</span>\n )}\n {selectedOption?.label ?? fallbackLabel ?? \"Select\"}\n <ChevronDownIcon\n className={cn(\"size-4 motion-safe:transition-transform\", open && \"rotate-180\")}\n />\n </button>\n ),\n);\nSelectTriggerButton.displayName = \"SelectTriggerButton\";\n\n/** The green tick shown on the selected option (matches DropDown V2). */\nfunction SelectedTick() {\n return <TickIcon size={16} className=\"text-success-negative-content\" aria-hidden=\"true\" />;\n}\n\n/**\n * Inline model/option selector for the ChatInput toolbar. Renders the\n * design-system dropdown (DropDown V2) on desktop and a bottom sheet on mobile.\n */\nfunction InlineSelect({\n options,\n value,\n onChange,\n disabled,\n selectedOption,\n variant,\n menuTitle,\n}: InlineSelectProps) {\n const [open, setOpen] = React.useState(false);\n const fallbackLabel = options[0]?.label;\n\n // Never allow the menu/sheet to open while disabled, regardless of how the\n // open request originates (click, keyboard, programmatic).\n const handleOpenChange = (next: boolean) => {\n if (disabled && next) return;\n setOpen(next);\n };\n\n const trigger = (\n <SelectTriggerButton\n open={open}\n selectedOption={selectedOption}\n fallbackLabel={fallbackLabel}\n disabled={disabled}\n />\n );\n\n if (variant === \"sheet\") {\n return (\n <Drawer open={open} onOpenChange={handleOpenChange}>\n <DrawerTrigger asChild>{trigger}</DrawerTrigger>\n <DrawerContent position=\"bottom\" variant=\"sheet\">\n <DrawerHeader>\n <DrawerTitle className=\"typography-header-heading-xs\">\n {menuTitle ?? \"Select an option\"}\n </DrawerTitle>\n </DrawerHeader>\n {/* Mirrors DropdownMenuItem's two-line layout, which can't be reused\n here because it requires a DropdownMenu (Radix Menu) context. */}\n <div className=\"flex flex-col gap-1 overflow-y-auto px-4 pb-4\" role=\"listbox\">\n {options.map((option) => {\n const isSelected = option.value === value;\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"option\"\n aria-selected={isSelected}\n onClick={() => {\n onChange?.(option.value);\n setOpen(false);\n }}\n className={cn(\n \"flex w-full items-start gap-2 rounded-sm px-3 py-2 text-left outline-none\",\n \"focus-visible:shadow-focus-ring\",\n \"typography-body-default-16px-regular text-content-primary hover:bg-neutral-alphas-50\",\n // bg-interaction-hover aliases to the same token as the\n // plain hover background above, so it can't distinguish\n // the selected option from a hovered-but-unselected one.\n isSelected && [\"bg-neutral-alphas-100\", \"hover:bg-neutral-alphas-200\"],\n )}\n >\n {option.icon && (\n <span className=\"flex shrink-0 items-center pt-1 [&>svg]:size-4\">\n {option.icon}\n </span>\n )}\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <span className=\"truncate\">{option.menuLabel ?? option.label}</span>\n {option.description && (\n <span className=\"typography-body-small-14px-regular truncate text-content-secondary\">\n {option.description}\n </span>\n )}\n </span>\n {isSelected && (\n <span className=\"flex shrink-0 items-center pt-1\">\n <SelectedTick />\n </span>\n )}\n </button>\n );\n })}\n </div>\n </DrawerContent>\n </Drawer>\n );\n }\n\n return (\n <DropdownMenu open={open} onOpenChange={handleOpenChange}>\n <DropdownMenuTrigger asChild>{trigger}</DropdownMenuTrigger>\n <DropdownMenuContent side=\"top\" align=\"end\" className=\"min-w-[244px]\">\n {options.map((option) => {\n const isSelected = option.value === value;\n return (\n <DropdownMenuItem\n key={option.value}\n size=\"40\"\n selected={isSelected}\n description={option.description}\n leadingIcon={\n option.icon ? (\n <span className=\"flex size-4 items-center [&>svg]:size-4\">{option.icon}</span>\n ) : undefined\n }\n trailingIcon={isSelected ? <SelectedTick /> : undefined}\n onSelect={() => onChange?.(option.value)}\n >\n {option.menuLabel ?? option.label}\n </DropdownMenuItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n"],"names":["jsxs","jsx","IconButton","CloseIcon","React","minHeight","maxHeight","cn","AddIcon","ArrowUpIcon","ChevronDownIcon","TickIcon","Drawer","DrawerTrigger","DrawerContent","DrawerHeader","DrawerTitle","DropdownMenu","DropdownMenuTrigger","DropdownMenuContent","DropdownMenuItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HA,MAAM,cAAc;AACpB,MAAM,cAAc;AAEpB,SAAS,gBAAgB,MAAsB;AAC7C,SAAO,cAAc,OAAO,cAAc;AAC5C;AAQA,SAAS,qCAAqC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA,WAAW;AACb,GAA8C;AAC5C,SAAO,YAAY,IAAI,CAAC,SACtBA,2BA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,MAAK,OAAM,OAAM,OAAM,WAAU,iBACnD,UAAA,QAAQ,IAAI,CAAC,WAAW;AACvB,YAAM,aAAa,OAAO,UAAU;AACpC,aACElB,2BAAAA;AAAAA,QAACmB,iBAAAA;AAAAA,QAAA;AAAA,UAEC,MAAK;AAAA,UACL,UAAU;AAAA,UACV,aAAa,OAAO;AAAA,UACpB,aACE,OAAO,OACLnB,2BAAAA,IAAC,UAAK,WAAU,2CAA2C,UAAA,OAAO,KAAA,CAAK,IACrE;AAAA,UAEN,cAAc,aAAaA,2BAAAA,IAAC,cAAA,CAAA,CAAa,IAAK;AAAA,UAC9C,UAAU,MAAM,WAAW,OAAO,KAAK;AAAA,UAEtC,UAAA,OAAO,aAAa,OAAO;AAAA,QAAA;AAAA,QAZvB,OAAO;AAAA,MAAA;AAAA,IAelB,CAAC,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;;"}
|
|
1
|
+
{"version":3,"file":"ChatInput.cjs","sources":["../../../../src/components/ChatInput/ChatInput.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Drawer, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger } from \"../Drawer/Drawer\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from \"../DropdownMenu/DropdownMenu\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { AddIcon } from \"../Icons/AddIcon\";\nimport { ArrowUpIcon } from \"../Icons/ArrowUpIcon\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { MenuRowIcon } from \"../Icons/MenuRowIcon\";\nimport { TickIcon } from \"../Icons/TickIcon\";\n\n/** A single image thumbnail in the built-in attachment strip. */\nexport interface ChatInputAttachmentItem {\n /** Stable id passed to {@link ChatInputProps.onAttachmentRemove} and used as React `key`. */\n id: string;\n /** Image URL for the thumbnail. */\n src: string;\n /** Optional value passed to the remove control `aria-label`. */\n ariaLabel?: string;\n}\n\n/** A single option for the inline model/dropdown selector. */\nexport interface ChatInputSelectOption {\n /** Unique value for this option. */\n value: string;\n /** Short label shown on the collapsed trigger button (e.g. \"Sonnet 4.6\"). */\n label: string;\n /**\n * Optional longer title shown on the option's row inside the open menu/sheet\n * (e.g. \"Claude Sonnet 4.6\"). Falls back to {@link label} when omitted.\n */\n menuLabel?: string;\n /** Optional secondary text shown below the label in the dropdown menu. */\n description?: string;\n /** Optional icon rendered to the left of the label. */\n icon?: React.ReactNode;\n}\n\n/**\n * Props for {@link ChatInput}. Standard textarea HTML attributes are forwarded to the inner\n * `<textarea>` except `className` (applied to the outer container), `rows` (use `minRows`), and\n * `onSubmit` (replaced by the chat message submit callback).\n */\nexport interface ChatInputProps\n extends Omit<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n \"className\" | \"rows\" | \"onSubmit\"\n > {\n /** Minimum number of visible rows. @default 1 */\n minRows?: number;\n /** Maximum number of visible rows before scrolling. @default 6 */\n maxRows?: number;\n /** Whether a submission is in progress (disables submit, shows visual feedback). @default false */\n loading?: boolean;\n /**\n * Callback fired when the user submits (clicks the send button or presses Enter without Shift).\n * Receives the current trimmed text value.\n */\n onSubmit?: (value: string) => void;\n /**\n * When `true`, renders an \"attach file\" button in the bottom-left toolbar.\n * @default false\n */\n showFileButton?: boolean;\n /** Callback fired when the attach-file button is clicked. Only relevant when `showFileButton` is `true`. */\n onFileClick?: () => void;\n /** Accessible label for the attach-file button. @default \"Attach file\" */\n fileButtonAriaLabel?: string;\n /** Accessible label for the submit button. @default \"Send message\" */\n submitAriaLabel?: string;\n /** Icon element for the submit button. @default `<ArrowUpIcon />` */\n submitIcon?: React.ReactNode;\n /**\n * Optional content rendered in the bottom-right toolbar, to the left of the submit button.\n * When provided, takes precedence over the built-in `selectOptions` dropdown.\n */\n toolbarRight?: React.ReactNode;\n /**\n * Options for the built-in inline dropdown selector (e.g. model picker).\n * Ignored when `toolbarRight` is provided.\n */\n selectOptions?: ChatInputSelectOption[];\n /**\n * How the built-in selector presents its options:\n * - `\"menu\"` (default) — a dropdown anchored to the trigger, for pointer/desktop.\n * - `\"sheet\"` — a bottom sheet, for mobile/touch viewports.\n *\n * The viewport decision belongs to the consumer (it owns the breakpoint\n * source of truth), so pass e.g. `selectVariant={isDesktop ? \"menu\" : \"sheet\"}`.\n * @default \"menu\"\n */\n selectVariant?: \"menu\" | \"sheet\";\n /**\n * Title shown at the top of the `\"sheet\"` variant of the built-in selector\n * (e.g. \"Switch AI Model\"). @default \"Select an option\"\n */\n selectMenuTitle?: string;\n /** Currently selected value for the built-in dropdown. Should match one of `selectOptions[].value`. */\n selectValue?: string;\n /** When `true`, disables only the built-in dropdown selector. @default false */\n selectDisabled?: boolean;\n /** Callback fired when the user picks a different dropdown option. */\n onSelectChange?: (value: string) => void;\n /**\n * Image attachments shown in the built-in thumbnail strip. Ignored when {@link ChatInputProps.attachmentPreviews}\n * is provided (including `null`).\n */\n attachments?: ChatInputAttachmentItem[];\n /**\n * Called when the user removes a built-in thumbnail. The remove button is disabled when this is\n * omitted or the input is {@link ChatInputProps.disabled}.\n */\n onAttachmentRemove?: (id: string) => void;\n /**\n * Replaces the built-in attachment strip entirely. When set to any value other than `undefined`\n * (including `null` or `[]`), {@link ChatInputProps.attachments} is ignored.\n */\n attachmentPreviews?: React.ReactNode;\n /** Additional className applied to the outermost container. */\n className?: string;\n}\n\nconst LINE_HEIGHT = 18;\nconst TEXTAREA_PY = 12;\n\nfunction calculateHeight(rows: number): number {\n return LINE_HEIGHT * rows + TEXTAREA_PY * 2;\n}\n\ninterface ChatInputDefaultAttachmentThumbnailsProps {\n attachments: ChatInputAttachmentItem[];\n onAttachmentRemove?: (id: string) => void;\n disabled?: boolean;\n}\n\nfunction ChatInputDefaultAttachmentThumbnails({\n attachments,\n onAttachmentRemove,\n disabled = false,\n}: ChatInputDefaultAttachmentThumbnailsProps) {\n return attachments.map((item) => (\n <div\n key={item.id}\n className=\"relative size-16 shrink-0 overflow-hidden rounded-sm border border-neutral-200 bg-background-secondary\"\n >\n <img src={item.src} alt=\"\" className=\"size-full object-cover\" />\n <IconButton\n variant=\"tertiary\"\n size=\"24\"\n aria-label={item.ariaLabel ? `Remove ${item.ariaLabel}` : \"Remove attachment\"}\n icon={<CloseIcon className=\"!size-3\" />}\n disabled={disabled || !onAttachmentRemove}\n onClick={() => onAttachmentRemove?.(item.id)}\n className=\"absolute top-0.5 right-0.5 size-5 bg-neutral-900/40 p-1 text-white hover:bg-neutral-900/55\"\n />\n </div>\n ));\n}\n\n/**\n * A chat-style multi-line input with an integrated toolbar containing an\n * optional file-attach button, optional right-side controls (e.g. a model\n * selector), and a submit button — all inside a single bordered container.\n *\n * Designed to behave like modern AI chat inputs: auto-grows with content,\n * submits on Enter (Shift+Enter for newlines), and keeps controls inline.\n *\n * @example\n * ```tsx\n * <ChatInput\n * placeholder=\"Type a message...\"\n * onSubmit={(text) => send(text)}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * placeholder=\"Ask the agent...\"\n * showFileButton\n * onFileClick={() => openFilePicker()}\n * selectOptions={[\n * { value: \"fanvue-ai\", label: \"Fanvue AI\", icon: <AIIcon className=\"size-4\" /> },\n * { value: \"example\", label: \"Example\", icon: <BulbIcon className=\"size-4\" /> },\n * ]}\n * selectValue=\"fanvue-ai\"\n * onSelectChange={(v) => setModel(v)}\n * onSubmit={(text) => send(text)}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * showFileButton\n * onFileClick={() => openPicker()}\n * attachments={files}\n * onAttachmentRemove={(id) => setFiles((prev) => prev.filter((f) => f.id !== id))}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * showFileButton\n * onFileClick={() => openPicker()}\n * attachmentPreviews={<CustomVideoStrip items={items} />}\n * />\n * ```\n */\nexport const ChatInput = React.forwardRef<HTMLTextAreaElement, ChatInputProps>(\n (\n {\n className,\n minRows = 1,\n maxRows = 6,\n disabled = false,\n loading = false,\n value,\n defaultValue,\n placeholder,\n maxLength,\n \"aria-label\": ariaLabel,\n onChange,\n onKeyDown,\n onSubmit,\n showFileButton = false,\n onFileClick,\n fileButtonAriaLabel = \"Attach file\",\n submitAriaLabel = \"Send message\",\n submitIcon,\n toolbarRight,\n selectOptions,\n selectVariant = \"menu\",\n selectMenuTitle,\n selectValue,\n selectDisabled = false,\n onSelectChange,\n attachments,\n onAttachmentRemove,\n attachmentPreviews,\n style,\n ...textareaProps\n },\n ref,\n ) => {\n const internalRef = React.useRef<HTMLTextAreaElement>(null);\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? \"\");\n const resolvedValue = value !== undefined ? value : internalValue;\n const isControlled = value !== undefined;\n\n const mergedRef = React.useCallback(\n (node: HTMLTextAreaElement | null) => {\n (internalRef as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n }\n },\n [ref],\n );\n\n const adjustHeight = React.useCallback(() => {\n const textarea = internalRef.current;\n if (!textarea) return;\n\n const minHeight = calculateHeight(minRows);\n const maxHeight = calculateHeight(maxRows);\n\n textarea.style.height = `${minHeight}px`;\n const desired = Math.min(Math.max(textarea.scrollHeight, minHeight), maxHeight);\n textarea.style.height = `${desired}px`;\n }, [minRows, maxRows]);\n\n React.useEffect(() => {\n adjustHeight();\n }, [adjustHeight]);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) {\n setInternalValue(e.target.value);\n }\n onChange?.(e);\n };\n\n const canSubmit = !!String(resolvedValue).trim() && !disabled && !loading;\n\n const handleSubmit = () => {\n const text = String(resolvedValue).trim();\n if (!text || !canSubmit) return;\n onSubmit?.(text);\n if (!isControlled) {\n setInternalValue(\"\");\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n onKeyDown?.(e);\n };\n\n const minHeight = calculateHeight(minRows);\n const maxHeight = calculateHeight(maxRows);\n\n const useCustomAttachmentPreviews = attachmentPreviews !== undefined;\n const customAttachmentStrip = useCustomAttachmentPreviews ? attachmentPreviews : null;\n const defaultAttachmentStrip =\n !useCustomAttachmentPreviews && !!attachments?.length ? (\n <ChatInputDefaultAttachmentThumbnails\n attachments={attachments ?? []}\n disabled={disabled}\n onAttachmentRemove={onAttachmentRemove}\n />\n ) : null;\n const resolvedAttachmentStrip = customAttachmentStrip ?? defaultAttachmentStrip;\n const hasAttachmentStrip = resolvedAttachmentStrip != null;\n\n const selectedOption =\n selectOptions?.find((o) => o.value === selectValue) ?? selectOptions?.[0];\n const resolvedToolbarRight =\n toolbarRight ??\n (selectOptions && selectOptions.length > 0 ? (\n <InlineSelect\n options={selectOptions}\n value={selectValue}\n onChange={onSelectChange}\n disabled={disabled || selectDisabled}\n selectedOption={selectedOption}\n variant={selectVariant}\n menuTitle={selectMenuTitle}\n />\n ) : null);\n\n return (\n <div\n className={cn(\n \"relative flex flex-col gap-6 rounded-lg border border-border-primary bg-surface-primary\",\n \"has-focus-visible:outline-none\",\n \"motion-safe:transition-colors\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n <div className=\"flex flex-col\">\n {hasAttachmentStrip ? (\n <div className=\"flex gap-2 overflow-x-auto px-4 pt-4 pb-2 [scrollbar-width:thin]\">\n {resolvedAttachmentStrip}\n </div>\n ) : null}\n <textarea\n {...textareaProps}\n ref={mergedRef}\n value={isControlled ? value : internalValue}\n placeholder={placeholder}\n maxLength={maxLength}\n disabled={disabled}\n aria-label={ariaLabel ?? placeholder}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n rows={minRows}\n className={cn(\n \"w-full resize-none bg-transparent px-4\",\n hasAttachmentStrip ? \"pt-0\" : \"pt-4\",\n \"typography-body-small-14px-regular text-content-primary\",\n \"placeholder:text-content-tertiary\",\n \"focus:outline-none disabled:cursor-not-allowed\",\n \"overflow-y-auto\",\n )}\n style={{\n minHeight: `${minHeight}px`,\n maxHeight: `${maxHeight}px`,\n ...style,\n }}\n />\n </div>\n\n <div className=\"flex items-center justify-between gap-2 px-4 pb-4\">\n <div className=\"flex items-center gap-1\">\n {showFileButton && (\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<AddIcon />}\n aria-label={fileButtonAriaLabel}\n onClick={onFileClick}\n disabled={disabled}\n className=\"max-sm:-ml-2 sm:border sm:border-border-primary\"\n />\n )}\n </div>\n\n <div className=\"flex items-center gap-1\">\n {resolvedToolbarRight}\n <IconButton\n variant=\"primary\"\n size=\"32\"\n icon={submitIcon ?? <ArrowUpIcon />}\n aria-label={submitAriaLabel}\n onClick={handleSubmit}\n disabled={!canSubmit}\n className=\"disabled:bg-surface-secondary disabled:text-icons-primary disabled:opacity-100\"\n />\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatInput.displayName = \"ChatInput\";\n\ninterface InlineSelectProps {\n options: ChatInputSelectOption[];\n value?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n selectedOption?: ChatInputSelectOption;\n /** Presentation: anchored dropdown (`\"menu\"`) or bottom sheet (`\"sheet\"`). */\n variant: \"menu\" | \"sheet\";\n /** Title for the bottom-sheet header. */\n menuTitle?: string;\n}\n\ninterface SelectTriggerButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Whether the menu/sheet is open (drives chevron rotation + active background). */\n open: boolean;\n selectedOption?: ChatInputSelectOption;\n /** Label shown when no option is selected. */\n fallbackLabel?: string;\n}\n\n/**\n * The collapsed pill trigger (icon + short label + chevron). Shared by the\n * desktop menu and mobile sheet; spreads Radix-injected trigger props via\n * `asChild`.\n */\nconst SelectTriggerButton = React.forwardRef<HTMLButtonElement, SelectTriggerButtonProps>(\n ({ open, selectedOption, fallbackLabel, className, ...props }, ref) => (\n <button\n ref={ref}\n type=\"button\"\n aria-label=\"Select model\"\n className={cn(\n \"typography-description-12px-semibold text-content-primary\",\n \"flex items-center gap-1 rounded-md px-2 py-2\",\n \"hover:bg-neutral-alphas-50 focus-visible:shadow-focus-ring focus-visible:outline-none\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n \"motion-safe:transition-colors\",\n open && \"bg-neutral-alphas-50\",\n className,\n )}\n {...props}\n >\n {selectedOption?.icon && (\n <span className=\"flex shrink-0 items-center [&>svg]:size-4\">{selectedOption.icon}</span>\n )}\n {selectedOption?.label ?? fallbackLabel ?? \"Select\"}\n <ChevronDownIcon\n className={cn(\"size-4 motion-safe:transition-transform\", open && \"rotate-180\")}\n />\n </button>\n ),\n);\nSelectTriggerButton.displayName = \"SelectTriggerButton\";\n\n/** The green tick shown on the selected option (matches DropDown V2). */\nfunction SelectedTick() {\n return <TickIcon size={16} className=\"text-success-negative-content\" aria-hidden=\"true\" />;\n}\n\n/**\n * Inline model/option selector for the ChatInput toolbar. Renders the\n * design-system dropdown (DropDown V2) on desktop and a bottom sheet on mobile.\n */\nfunction InlineSelect({\n options,\n value,\n onChange,\n disabled,\n selectedOption,\n variant,\n menuTitle,\n}: InlineSelectProps) {\n const [open, setOpen] = React.useState(false);\n const fallbackLabel = options[0]?.label;\n\n // Never allow the menu/sheet to open while disabled, regardless of how the\n // open request originates (click, keyboard, programmatic).\n const handleOpenChange = (next: boolean) => {\n if (disabled && next) return;\n setOpen(next);\n };\n\n const trigger = (\n <SelectTriggerButton\n open={open}\n selectedOption={selectedOption}\n fallbackLabel={fallbackLabel}\n disabled={disabled}\n />\n );\n\n if (variant === \"sheet\") {\n return (\n <Drawer open={open} onOpenChange={handleOpenChange}>\n <DrawerTrigger asChild>{trigger}</DrawerTrigger>\n <DrawerContent position=\"bottom\" variant=\"sheet\">\n <DrawerHeader>\n <DrawerTitle className=\"typography-header-heading-xs\">\n {menuTitle ?? \"Select an option\"}\n </DrawerTitle>\n </DrawerHeader>\n {/* Mirrors DropdownMenuItem's rows, which can't be reused here because\n they require a DropdownMenu (Radix Menu) context. */}\n <div className=\"flex flex-col gap-1 overflow-y-auto px-2 pb-2\" role=\"listbox\">\n {options.map((option) => {\n const isSelected = option.value === value;\n const hasDescription = !!option.description;\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"option\"\n aria-selected={isSelected}\n onClick={() => {\n onChange?.(option.value);\n setOpen(false);\n }}\n className={cn(\n \"group flex min-h-10 w-full gap-2 rounded-sm px-3 py-2 text-left outline-none\",\n hasDescription ? \"items-start\" : \"items-center\",\n \"focus-visible:shadow-focus-ring\",\n \"typography-body-small-14px-regular text-content-primary hover:bg-interaction-hover\",\n // The selected option shares the hover fill, as in DropdownMenuItem.\n isSelected && \"bg-interaction-hover\",\n )}\n >\n {option.icon && (\n <MenuRowIcon alignToTitle={hasDescription}>{option.icon}</MenuRowIcon>\n )}\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <span\n className={cn(\n \"truncate\",\n hasDescription && \"typography-body-small-14px-semibold\",\n )}\n >\n {option.menuLabel ?? option.label}\n </span>\n {hasDescription && (\n <span className=\"typography-body-small-14px-regular truncate text-content-secondary\">\n {option.description}\n </span>\n )}\n </span>\n {isSelected && (\n <span className={cn(\"flex shrink-0 items-center\", hasDescription && \"h-4.5\")}>\n <SelectedTick />\n </span>\n )}\n </button>\n );\n })}\n </div>\n </DrawerContent>\n </Drawer>\n );\n }\n\n return (\n <DropdownMenu open={open} onOpenChange={handleOpenChange}>\n <DropdownMenuTrigger asChild>{trigger}</DropdownMenuTrigger>\n <DropdownMenuContent side=\"top\" align=\"end\" className=\"min-w-[244px]\">\n {options.map((option) => {\n const isSelected = option.value === value;\n return (\n <DropdownMenuItem\n key={option.value}\n size=\"40\"\n selected={isSelected}\n description={option.description}\n leadingIcon={\n option.icon ? (\n <span className=\"flex size-4 items-center [&>svg]:size-4\">{option.icon}</span>\n ) : undefined\n }\n trailingIcon={isSelected ? <SelectedTick /> : undefined}\n onSelect={() => onChange?.(option.value)}\n >\n {option.menuLabel ?? option.label}\n </DropdownMenuItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n"],"names":["jsxs","jsx","IconButton","CloseIcon","React","minHeight","maxHeight","cn","AddIcon","ArrowUpIcon","ChevronDownIcon","TickIcon","Drawer","DrawerTrigger","DrawerContent","DrawerHeader","DrawerTitle","MenuRowIcon","DropdownMenu","DropdownMenuTrigger","DropdownMenuContent","DropdownMenuItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIA,MAAM,cAAc;AACpB,MAAM,cAAc;AAEpB,SAAS,gBAAgB,MAAsB;AAC7C,SAAO,cAAc,OAAO,cAAc;AAC5C;AAQA,SAAS,qCAAqC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA,WAAW;AACb,GAA8C;AAC5C,SAAO,YAAY,IAAI,CAAC,SACtBA,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MAEC,WAAU;AAAA,MAEV,UAAA;AAAA,QAAAC,+BAAC,SAAI,KAAK,KAAK,KAAK,KAAI,IAAG,WAAU,0BAAyB;AAAA,QAC9DA,2BAAAA;AAAAA,UAACC,WAAAA;AAAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,cAAY,KAAK,YAAY,UAAU,KAAK,SAAS,KAAK;AAAA,YAC1D,MAAMD,2BAAAA,IAACE,UAAAA,WAAA,EAAU,WAAU,UAAA,CAAU;AAAA,YACrC,UAAU,YAAY,CAAC;AAAA,YACvB,SAAS,MAAM,qBAAqB,KAAK,EAAE;AAAA,YAC3C,WAAU;AAAA,UAAA;AAAA,QAAA;AAAA,MACZ;AAAA,IAAA;AAAA,IAZK,KAAK;AAAA,EAAA,CAcb;AACH;AAqDO,MAAM,YAAYC,iBAAM;AAAA,EAC7B,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;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CAAC,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;;"}
|
|
@@ -6,6 +6,7 @@ const DropdownMenuPrimitive = require("@radix-ui/react-dropdown-menu");
|
|
|
6
6
|
const reactSlot = require("@radix-ui/react-slot");
|
|
7
7
|
const React = require("react");
|
|
8
8
|
const cn = require("../../utils/cn.cjs");
|
|
9
|
+
const MenuRowIcon = require("../Icons/MenuRowIcon.cjs");
|
|
9
10
|
const context = require("./context.cjs");
|
|
10
11
|
function _interopNamespaceDefault(e) {
|
|
11
12
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -45,17 +46,13 @@ const SIZE_NORMALIZED = {
|
|
|
45
46
|
sm: "32"
|
|
46
47
|
};
|
|
47
48
|
const ITEM_SIZE_CLASSES = {
|
|
48
|
-
"40": "min-h-10 py-2 typography-body-
|
|
49
|
+
"40": "min-h-10 py-2 typography-body-small-14px-regular",
|
|
49
50
|
"32": "min-h-8 py-[7px] typography-body-small-14px-regular"
|
|
50
51
|
};
|
|
51
52
|
const ITEM_COUNT_TYPOGRAPHY = {
|
|
52
53
|
"40": "typography-body-small-14px-regular",
|
|
53
54
|
"32": "typography-body-small-14px-regular"
|
|
54
55
|
};
|
|
55
|
-
const ITEM_SELECTED_TYPOGRAPHY = {
|
|
56
|
-
"40": "typography-body-default-16px-semibold",
|
|
57
|
-
"32": "typography-body-small-14px-semibold"
|
|
58
|
-
};
|
|
59
56
|
const DropdownMenuItem = React__namespace.forwardRef(
|
|
60
57
|
({
|
|
61
58
|
size = "40",
|
|
@@ -81,18 +78,18 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
81
78
|
const itemClassName = cn.cn(
|
|
82
79
|
// `text-start` because the sheet variant renders the row as a <button>,
|
|
83
80
|
// whose UA-centred text misaligned it from the popper variant's rows.
|
|
84
|
-
"group flex w-full cursor-pointer gap-2 rounded-
|
|
81
|
+
"group flex w-full cursor-pointer gap-2 rounded-sm px-3 text-start outline-none",
|
|
85
82
|
hasDescription ? "items-start" : "items-center",
|
|
86
83
|
// The sheet's header runs the full width of the panel, so its rows have to
|
|
87
|
-
// come in off the edge themselves —
|
|
88
|
-
//
|
|
89
|
-
// over; `w-full` plus a margin would overflow.
|
|
90
|
-
variant === "sheet" && "mx-
|
|
84
|
+
// come in off the edge themselves — 4px here on the panel's own 4px gives the
|
|
85
|
+
// same 8px inset as the popper panel. `w-auto` lets the column stretch them
|
|
86
|
+
// to the space left over; `w-full` plus a margin would overflow.
|
|
87
|
+
variant === "sheet" && "mx-1 w-auto",
|
|
91
88
|
ITEM_SIZE_CLASSES[normalizedSize],
|
|
92
89
|
// A 24px avatar would push the compact 32px row past its height with the
|
|
93
90
|
// default padding; tighten it so the avatar variant keeps the 32px contract.
|
|
94
91
|
hasAvatar && !hasDescription && normalizedSize === "32" && "py-1",
|
|
95
|
-
"data-[highlighted]:bg-
|
|
92
|
+
"data-[highlighted]:bg-interaction-hover",
|
|
96
93
|
"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled",
|
|
97
94
|
"disabled:cursor-not-allowed disabled:text-content-disabled",
|
|
98
95
|
// Sheet-variant asChild items are marked disabled via aria-disabled
|
|
@@ -100,16 +97,16 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
100
97
|
// data-disabled — neither selector above matches them.
|
|
101
98
|
"aria-disabled:cursor-not-allowed aria-disabled:text-content-disabled",
|
|
102
99
|
destructive && "text-error-content",
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
selected && [
|
|
107
|
-
"bg-buttons-primary-default text-content-primary-inverted data-[highlighted]:bg-buttons-primary-default",
|
|
108
|
-
!hasDescription && ITEM_SELECTED_TYPOGRAPHY[normalizedSize]
|
|
109
|
-
],
|
|
100
|
+
// Selected: the same `Interaction/Hover` fill as a highlighted row (library
|
|
101
|
+
// node `23452:13432`), so the current value reads as the resting highlight.
|
|
102
|
+
selected && "bg-interaction-hover",
|
|
110
103
|
className
|
|
111
104
|
);
|
|
112
|
-
const
|
|
105
|
+
const selectedProps = selected ? {
|
|
106
|
+
...props["aria-checked"] === void 0 && { "aria-current": "true" },
|
|
107
|
+
"data-selected": ""
|
|
108
|
+
} : void 0;
|
|
109
|
+
const iconAlignClassName = hasDescription ? "flex h-4.5 shrink-0 items-center" : null;
|
|
113
110
|
const countNode = count != null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
114
111
|
"span",
|
|
115
112
|
{
|
|
@@ -117,27 +114,20 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
117
114
|
"shrink-0 tabular-nums",
|
|
118
115
|
iconAlignClassName,
|
|
119
116
|
ITEM_COUNT_TYPOGRAPHY[normalizedSize],
|
|
120
|
-
destructive ? "text-error-content" :
|
|
117
|
+
destructive ? "text-error-content" : "text-content-tertiary",
|
|
121
118
|
"group-data-[disabled]:text-content-disabled"
|
|
122
119
|
),
|
|
123
120
|
children: count
|
|
124
121
|
}
|
|
125
122
|
);
|
|
126
|
-
const
|
|
123
|
+
const renderIcon = (icon, className2) => /* @__PURE__ */ jsxRuntime.jsx(MenuRowIcon.MenuRowIcon, { inheritColor: destructive, alignToTitle: hasDescription, className: className2, children: icon });
|
|
124
|
+
const leadingNode = leadingIcon != null && renderIcon(leadingIcon);
|
|
125
|
+
const trailingNode = trailingIcon != null && renderIcon(trailingIcon, asChild ? "ms-auto" : void 0);
|
|
127
126
|
const itemChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
128
|
-
avatar != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn("shrink-0", iconAlignClassName), children: avatar }) :
|
|
127
|
+
avatar != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn("shrink-0", iconAlignClassName), children: avatar }) : leadingNode,
|
|
129
128
|
hasDescription ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
130
129
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-small-14px-semibold truncate", children }),
|
|
131
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
132
|
-
"span",
|
|
133
|
-
{
|
|
134
|
-
className: cn.cn(
|
|
135
|
-
"typography-body-small-14px-regular truncate",
|
|
136
|
-
selected ? "text-content-primary-inverted" : "text-content-secondary"
|
|
137
|
-
),
|
|
138
|
-
children: description
|
|
139
|
-
}
|
|
140
|
-
)
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-small-14px-regular truncate text-content-secondary", children: description })
|
|
141
131
|
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children }),
|
|
142
132
|
countNode,
|
|
143
133
|
trailingNode
|
|
@@ -154,6 +144,7 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
154
144
|
...sheetSpecificProps,
|
|
155
145
|
role: "option",
|
|
156
146
|
"aria-selected": selected,
|
|
147
|
+
"data-selected": selected ? "" : void 0,
|
|
157
148
|
className: itemClassName,
|
|
158
149
|
onClick: (event) => {
|
|
159
150
|
if (disabled) {
|
|
@@ -165,7 +156,7 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
165
156
|
onSelect?.(event.nativeEvent);
|
|
166
157
|
if (!event.nativeEvent.defaultPrevented) toggleOpen?.(() => false);
|
|
167
158
|
},
|
|
168
|
-
children: asChild ? children : itemChildren
|
|
159
|
+
children: asChild ? [leadingNode, /* @__PURE__ */ jsxRuntime.jsx(reactSlot.Slottable, { children }, "children"), trailingNode] : itemChildren
|
|
169
160
|
}
|
|
170
161
|
);
|
|
171
162
|
}
|
|
@@ -178,8 +169,13 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
178
169
|
className: itemClassName,
|
|
179
170
|
disabled,
|
|
180
171
|
onSelect,
|
|
172
|
+
...selectedProps,
|
|
181
173
|
...props,
|
|
182
|
-
children
|
|
174
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(reactSlot.Slot, { children: [
|
|
175
|
+
leadingNode,
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactSlot.Slottable, { children }),
|
|
177
|
+
trailingNode
|
|
178
|
+
] })
|
|
183
179
|
}
|
|
184
180
|
);
|
|
185
181
|
}
|
|
@@ -190,6 +186,7 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
190
186
|
className: itemClassName,
|
|
191
187
|
disabled,
|
|
192
188
|
onSelect,
|
|
189
|
+
...selectedProps,
|
|
193
190
|
...props,
|
|
194
191
|
children: itemChildren
|
|
195
192
|
}
|