@langchain/macaw-components 1.7.17 → 1.7.19
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/catalog.json +786 -772
- package/dist/components/Banner/Banner.js +1 -1
- package/dist/components/Banner/Banner.js.map +1 -1
- package/dist/components/ChatContextWindowPopover/ChatContextWindowPopover.d.ts +20 -0
- package/dist/components/ChatContextWindowPopover/ChatContextWindowPopover.js +146 -0
- package/dist/components/ChatContextWindowPopover/ChatContextWindowPopover.js.map +1 -0
- package/dist/components/ChatContextWindowPopover/index.d.ts +2 -0
- package/dist/components/ChatContextWindowPopover/index.js +2 -0
- package/dist/components/ChatPlan/ChatPlan.js +2 -2
- package/dist/components/ChatPlan/ChatPlan.js.map +1 -1
- package/dist/components/ChatToolCall/ChatToolCallAccordion.js +1 -1
- package/dist/components/ChatToolCall/ChatToolCallAccordion.js.map +1 -1
- package/dist/components/ChatToolCall/ChatToolCallGroup.js +1 -1
- package/dist/components/ChatToolCall/ChatToolCallGroup.js.map +1 -1
- package/dist/components/CircularProgress/CircularProgress.d.ts +1 -1
- package/dist/components/CircularProgress/CircularProgress.js +1 -0
- package/dist/components/CircularProgress/CircularProgress.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/dist/components/ProgressBar/ProgressBar.js +10 -3
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/utilities.css +1 -1
- package/docs/DESIGN.md +15 -0
- package/package.json +6 -2
|
@@ -70,7 +70,7 @@ var Banner = ({ title, children, dismissible = false, className, intent = "warni
|
|
|
70
70
|
variant: "plain",
|
|
71
71
|
icon: XIcon,
|
|
72
72
|
label: "Close",
|
|
73
|
-
className: "shrink-0 self-center text-secondary hover:bg-transparent",
|
|
73
|
+
className: "shrink-0 self-center text-secondary hover:bg-transparent dark:hover:bg-transparent",
|
|
74
74
|
onClick: () => {
|
|
75
75
|
setShow(false);
|
|
76
76
|
onDismiss?.();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","names":[],"sources":["../../../src/components/Banner/Banner.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useState } from 'react';\n\nimport { CheckCircleIcon } from '@phosphor-icons/react/dist/ssr/CheckCircle';\nimport { ExclamationMarkIcon } from '@phosphor-icons/react/dist/ssr/ExclamationMark';\nimport { InfoIcon } from '@phosphor-icons/react/dist/ssr/Info';\nimport { WarningIcon } from '@phosphor-icons/react/dist/ssr/Warning';\n\nimport { XIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport { Icon } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\n\nexport type BannerIntent = 'warning' | 'info' | 'success' | 'error' | 'neutral';\n\nexport type BannerProps = {\n title?: string;\n children?: ReactNode;\n dismissible?: boolean;\n className?: string;\n intent?: BannerIntent;\n shadow?: boolean;\n onDismiss?: () => void;\n icon?: ReactNode;\n action?: ReactNode;\n flush?: boolean;\n};\n\nexport const Banner = ({\n title,\n children,\n dismissible = false,\n className,\n intent = 'warning',\n shadow = false,\n onDismiss,\n icon,\n action,\n flush = false,\n}: BannerProps) => {\n const [show, setShow] = useState(true);\n\n const renderIcon = () => {\n if (icon !== undefined) {\n return icon;\n }\n switch (intent) {\n case 'warning':\n return (\n <Icon\n icon={WarningIcon}\n weight=\"fill\"\n size=\"md\"\n className=\"text-warning-secondary\"\n />\n );\n case 'info':\n return (\n <Icon\n icon={InfoIcon}\n weight=\"fill\"\n size=\"md\"\n className=\"text-brand-100 dark:text-brand-600\"\n />\n );\n case 'success':\n return (\n <Icon\n icon={CheckCircleIcon}\n weight=\"fill\"\n size=\"md\"\n className=\"text-success-secondary\"\n />\n );\n case 'error':\n return (\n <Icon\n icon={ExclamationMarkIcon}\n weight=\"regular\"\n size=\"md\"\n className=\"text-error-secondary\"\n />\n );\n case 'neutral':\n return (\n <Icon\n icon={InfoIcon}\n weight=\"fill\"\n size=\"md\"\n className=\"text-tertiary\"\n />\n );\n default:\n return null;\n }\n };\n\n const titleElement =\n title == null ? null : (\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"medium\"\n color=\"primary\"\n className={cn(\n 'whitespace-normal break-words',\n children != null && 'mr-space-2'\n )}\n >\n {title}\n </Text>\n );\n\n const contentElement =\n children == null ? null : typeof children === 'string' ? (\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n color=\"secondary\"\n className=\"whitespace-normal break-words\"\n >\n {children}\n </Text>\n ) : (\n children\n );\n\n const iconElement = renderIcon();\n\n const dismissButton = dismissible ? (\n <IconButton\n color=\"secondary\"\n variant=\"plain\"\n icon={XIcon}\n label=\"Close\"\n className=\"shrink-0 self-center text-secondary hover:bg-transparent\"\n onClick={() => {\n setShow(false);\n onDismiss?.();\n }}\n />\n ) : null;\n\n if (!show) return null;\n return (\n <div\n className={cn(\n 'm-0 flex items-center gap-space-2 border border-transparent px-space-4 py-space-3 text-sm',\n shadow && 'shadow-lg',\n intent === 'warning' && 'bg-warning',\n intent === 'info' && 'bg-brand-subtle-gradient',\n intent === 'success' && 'bg-success',\n intent === 'error' && 'bg-error',\n intent === 'neutral' && 'bg-elevated',\n intent === 'neutral' && !flush && 'border-default',\n !flush && 'rounded-md',\n className\n )}\n >\n {iconElement != null && (\n <div className=\"mr-space-1 flex shrink-0 items-center\">\n {iconElement}\n </div>\n )}\n <Text as=\"div\" variant=\"sm\" className=\"min-w-0 flex-1\">\n {titleElement}\n {contentElement}\n </Text>\n {action ? (\n <div className=\"flex shrink-0 items-center\">{action}</div>\n ) : null}\n {dismissButton}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA6BA,IAAa,UAAU,EACrB,OACA,UACA,cAAc,OACd,WACA,SAAS,WACT,SAAS,OACT,WACA,MACA,QACA,QAAQ,YACS;CACjB,MAAM,CAAC,MAAM,WAAW,SAAS,IAAI;CAErC,MAAM,mBAAmB;EACvB,IAAI,SAAS,KAAA,GACX,OAAO;EAET,QAAQ,QAAR;GACE,KAAK,WACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,KAAK,QACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,KAAK,WACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,KAAK,SACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,KAAK,WACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,SACE,OAAO;EACX;CACF;CAEA,MAAM,eACJ,SAAS,OAAO,OACd,oBAAC,MAAD;EACE,IAAG;EACH,SAAQ;EACR,QAAO;EACP,OAAM;EACN,WAAW,GACT,iCACA,YAAY,QAAQ,YACtB;EAEC,UAAA;CACG,CAAA;CAGV,MAAM,iBACJ,YAAY,OAAO,OAAO,OAAO,aAAa,WAC5C,oBAAC,MAAD;EACE,IAAG;EACH,SAAQ;EACR,QAAO;EACP,OAAM;EACN,WAAU;EAET;CACG,CAAA,IAEN;CAGJ,MAAM,cAAc,WAAW;CAE/B,MAAM,gBAAgB,cACpB,oBAAC,YAAD;EACE,OAAM;EACN,SAAQ;EACR,MAAM;EACN,OAAM;EACN,WAAU;EACV,eAAe;GACb,QAAQ,KAAK;GACb,YAAY;EACd;CACD,CAAA,IACC;CAEJ,IAAI,CAAC,MAAM,OAAO;CAClB,OACE,qBAAC,OAAD;EACE,WAAW,GACT,6FACA,UAAU,aACV,WAAW,aAAa,cACxB,WAAW,UAAU,4BACrB,WAAW,aAAa,cACxB,WAAW,WAAW,YACtB,WAAW,aAAa,eACxB,WAAW,aAAa,CAAC,SAAS,kBAClC,CAAC,SAAS,cACV,SACF;EAZF,UAAA;GAcG,eAAe,QACd,oBAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA;GAEP,qBAAC,MAAD;IAAM,IAAG;IAAM,SAAQ;IAAK,WAAU;IAAtC,UAAA,CACG,cACA,cACG;;GACL,SACC,oBAAC,OAAD;IAAK,WAAU;IAA8B,UAAA;GAAY,CAAA,IACvD;GACH;EACE;;AAET"}
|
|
1
|
+
{"version":3,"file":"Banner.js","names":[],"sources":["../../../src/components/Banner/Banner.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useState } from 'react';\n\nimport { CheckCircleIcon } from '@phosphor-icons/react/dist/ssr/CheckCircle';\nimport { ExclamationMarkIcon } from '@phosphor-icons/react/dist/ssr/ExclamationMark';\nimport { InfoIcon } from '@phosphor-icons/react/dist/ssr/Info';\nimport { WarningIcon } from '@phosphor-icons/react/dist/ssr/Warning';\n\nimport { XIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport { Icon } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\n\nexport type BannerIntent = 'warning' | 'info' | 'success' | 'error' | 'neutral';\n\nexport type BannerProps = {\n title?: string;\n children?: ReactNode;\n dismissible?: boolean;\n className?: string;\n intent?: BannerIntent;\n shadow?: boolean;\n onDismiss?: () => void;\n icon?: ReactNode;\n action?: ReactNode;\n flush?: boolean;\n};\n\nexport const Banner = ({\n title,\n children,\n dismissible = false,\n className,\n intent = 'warning',\n shadow = false,\n onDismiss,\n icon,\n action,\n flush = false,\n}: BannerProps) => {\n const [show, setShow] = useState(true);\n\n const renderIcon = () => {\n if (icon !== undefined) {\n return icon;\n }\n switch (intent) {\n case 'warning':\n return (\n <Icon\n icon={WarningIcon}\n weight=\"fill\"\n size=\"md\"\n className=\"text-warning-secondary\"\n />\n );\n case 'info':\n return (\n <Icon\n icon={InfoIcon}\n weight=\"fill\"\n size=\"md\"\n className=\"text-brand-100 dark:text-brand-600\"\n />\n );\n case 'success':\n return (\n <Icon\n icon={CheckCircleIcon}\n weight=\"fill\"\n size=\"md\"\n className=\"text-success-secondary\"\n />\n );\n case 'error':\n return (\n <Icon\n icon={ExclamationMarkIcon}\n weight=\"regular\"\n size=\"md\"\n className=\"text-error-secondary\"\n />\n );\n case 'neutral':\n return (\n <Icon\n icon={InfoIcon}\n weight=\"fill\"\n size=\"md\"\n className=\"text-tertiary\"\n />\n );\n default:\n return null;\n }\n };\n\n const titleElement =\n title == null ? null : (\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"medium\"\n color=\"primary\"\n className={cn(\n 'whitespace-normal break-words',\n children != null && 'mr-space-2'\n )}\n >\n {title}\n </Text>\n );\n\n const contentElement =\n children == null ? null : typeof children === 'string' ? (\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n color=\"secondary\"\n className=\"whitespace-normal break-words\"\n >\n {children}\n </Text>\n ) : (\n children\n );\n\n const iconElement = renderIcon();\n\n const dismissButton = dismissible ? (\n <IconButton\n color=\"secondary\"\n variant=\"plain\"\n icon={XIcon}\n label=\"Close\"\n className=\"shrink-0 self-center text-secondary hover:bg-transparent dark:hover:bg-transparent\"\n onClick={() => {\n setShow(false);\n onDismiss?.();\n }}\n />\n ) : null;\n\n if (!show) return null;\n return (\n <div\n className={cn(\n 'm-0 flex items-center gap-space-2 border border-transparent px-space-4 py-space-3 text-sm',\n shadow && 'shadow-lg',\n intent === 'warning' && 'bg-warning',\n intent === 'info' && 'bg-brand-subtle-gradient',\n intent === 'success' && 'bg-success',\n intent === 'error' && 'bg-error',\n intent === 'neutral' && 'bg-elevated',\n intent === 'neutral' && !flush && 'border-default',\n !flush && 'rounded-md',\n className\n )}\n >\n {iconElement != null && (\n <div className=\"mr-space-1 flex shrink-0 items-center\">\n {iconElement}\n </div>\n )}\n <Text as=\"div\" variant=\"sm\" className=\"min-w-0 flex-1\">\n {titleElement}\n {contentElement}\n </Text>\n {action ? (\n <div className=\"flex shrink-0 items-center\">{action}</div>\n ) : null}\n {dismissButton}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA6BA,IAAa,UAAU,EACrB,OACA,UACA,cAAc,OACd,WACA,SAAS,WACT,SAAS,OACT,WACA,MACA,QACA,QAAQ,YACS;CACjB,MAAM,CAAC,MAAM,WAAW,SAAS,IAAI;CAErC,MAAM,mBAAmB;EACvB,IAAI,SAAS,KAAA,GACX,OAAO;EAET,QAAQ,QAAR;GACE,KAAK,WACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,KAAK,QACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,KAAK,WACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,KAAK,SACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,KAAK,WACH,OACE,oBAAC,MAAD;IACE,MAAM;IACN,QAAO;IACP,MAAK;IACL,WAAU;GACX,CAAA;GAEL,SACE,OAAO;EACX;CACF;CAEA,MAAM,eACJ,SAAS,OAAO,OACd,oBAAC,MAAD;EACE,IAAG;EACH,SAAQ;EACR,QAAO;EACP,OAAM;EACN,WAAW,GACT,iCACA,YAAY,QAAQ,YACtB;EAEC,UAAA;CACG,CAAA;CAGV,MAAM,iBACJ,YAAY,OAAO,OAAO,OAAO,aAAa,WAC5C,oBAAC,MAAD;EACE,IAAG;EACH,SAAQ;EACR,QAAO;EACP,OAAM;EACN,WAAU;EAET;CACG,CAAA,IAEN;CAGJ,MAAM,cAAc,WAAW;CAE/B,MAAM,gBAAgB,cACpB,oBAAC,YAAD;EACE,OAAM;EACN,SAAQ;EACR,MAAM;EACN,OAAM;EACN,WAAU;EACV,eAAe;GACb,QAAQ,KAAK;GACb,YAAY;EACd;CACD,CAAA,IACC;CAEJ,IAAI,CAAC,MAAM,OAAO;CAClB,OACE,qBAAC,OAAD;EACE,WAAW,GACT,6FACA,UAAU,aACV,WAAW,aAAa,cACxB,WAAW,UAAU,4BACrB,WAAW,aAAa,cACxB,WAAW,WAAW,YACtB,WAAW,aAAa,eACxB,WAAW,aAAa,CAAC,SAAS,kBAClC,CAAC,SAAS,cACV,SACF;EAZF,UAAA;GAcG,eAAe,QACd,oBAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA;GAEP,qBAAC,MAAD;IAAM,IAAG;IAAM,SAAQ;IAAK,WAAU;IAAtC,UAAA,CACG,cACA,cACG;;GACL,SACC,oBAAC,OAAD;IAAK,WAAU;IAA8B,UAAA;GAAY,CAAA,IACvD;GACH;EACE;;AAET"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface ChatContextWindowPopoverProps {
|
|
3
|
+
/** Current context occupancy, not cumulative billed tokens. Null means unavailable. */
|
|
4
|
+
tokensUsed: number | null;
|
|
5
|
+
/** Effective model capacity; omit when the provider does not report it. */
|
|
6
|
+
contextWindow?: number | null;
|
|
7
|
+
model?: string;
|
|
8
|
+
/** Fraction at which to warn, from 0 to 1. Defaults to 0.8. */
|
|
9
|
+
warningThreshold?: number;
|
|
10
|
+
/** Replaces the default guidance, e.g. an estimate or automatic compaction policy. */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Product-owned details, such as token breakdowns or session cost. */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/** Optional actions or status, e.g. compact, retry, or ThinkingState. */
|
|
15
|
+
footer?: ReactNode;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Shared context-usage presentation; apps own data, additional content, and actions. */
|
|
20
|
+
export declare function ChatContextWindowPopover({ tokensUsed, contextWindow, model, warningThreshold, description, children, footer, disabled, className, }: ChatContextWindowPopoverProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { Text } from "../Text/Text.js";
|
|
3
|
+
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
4
|
+
import { Button } from "../Button/Button.js";
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../Popover/Popover.js";
|
|
6
|
+
import { CircularProgress } from "../CircularProgress/CircularProgress.js";
|
|
7
|
+
import { ProgressBar } from "../ProgressBar/ProgressBar.js";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region packages/components/src/components/ChatContextWindowPopover/ChatContextWindowPopover.tsx
|
|
11
|
+
var compact = new Intl.NumberFormat("en-US", {
|
|
12
|
+
notation: "compact",
|
|
13
|
+
maximumFractionDigits: 1
|
|
14
|
+
});
|
|
15
|
+
var exact = new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 });
|
|
16
|
+
function validTokens(value) {
|
|
17
|
+
return value != null && Number.isFinite(value) && value >= 0 ? value : null;
|
|
18
|
+
}
|
|
19
|
+
/** Shared context-usage presentation; apps own data, additional content, and actions. */
|
|
20
|
+
function ChatContextWindowPopover({ tokensUsed, contextWindow, model, warningThreshold = .8, description, children, footer, disabled = false, className }) {
|
|
21
|
+
const [open, setOpen] = useState(false);
|
|
22
|
+
const used = validTokens(tokensUsed);
|
|
23
|
+
const limit = validTokens(contextWindow) || null;
|
|
24
|
+
const ratio = used != null && limit != null ? used / limit : null;
|
|
25
|
+
const threshold = Number.isFinite(warningThreshold) ? Math.min(1, Math.max(0, warningThreshold)) : .8;
|
|
26
|
+
const isFull = ratio != null && ratio >= 1;
|
|
27
|
+
const isNearLimit = ratio != null && ratio >= threshold;
|
|
28
|
+
const intent = isFull ? "error" : isNearLimit ? "warning" : "neutral";
|
|
29
|
+
const percentage = ratio == null ? null : Math.min(isFull ? Infinity : 99, Math.round(ratio * 100));
|
|
30
|
+
const status = used == null ? "Token usage is unavailable." : limit == null ? "The provider has not reported a context limit." : isFull ? "Context limit reached" : isNearLimit ? "Context nearly full" : `${compact.format(limit - used)} tokens remaining`;
|
|
31
|
+
const label = `Context window: ${used == null ? "usage unavailable" : `${exact.format(used)} tokens used${limit == null ? ", limit unknown" : ` of ${exact.format(limit)}, ${percentage}% used`}`}`;
|
|
32
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
33
|
+
open: open && !disabled,
|
|
34
|
+
onOpenChange: setOpen,
|
|
35
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
36
|
+
title: percentage == null ? "Context usage" : `Context: ${percentage}% used`,
|
|
37
|
+
disabled,
|
|
38
|
+
children: /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
39
|
+
asChild: true,
|
|
40
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
41
|
+
type: "button",
|
|
42
|
+
size: "sm",
|
|
43
|
+
color: "secondary",
|
|
44
|
+
variant: "plain",
|
|
45
|
+
disabled,
|
|
46
|
+
"aria-label": label,
|
|
47
|
+
className: cn("w-6 shrink-0 px-0", className),
|
|
48
|
+
children: /* @__PURE__ */ jsx(CircularProgress, {
|
|
49
|
+
size: 16,
|
|
50
|
+
strokeWidth: 2,
|
|
51
|
+
segments: ratio == null ? [] : [{
|
|
52
|
+
variant: intent,
|
|
53
|
+
percentage: Math.min(ratio, 1)
|
|
54
|
+
}]
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
}), /* @__PURE__ */ jsxs(PopoverContent, {
|
|
59
|
+
side: "top",
|
|
60
|
+
align: "end",
|
|
61
|
+
sideOffset: 8,
|
|
62
|
+
collisionPadding: 12,
|
|
63
|
+
"aria-label": "Context window",
|
|
64
|
+
className: "flex w-72 max-w-[calc(100vw-1.5rem)] flex-col gap-space-4 text-primary",
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsxs("div", {
|
|
67
|
+
className: "flex flex-col gap-space-3",
|
|
68
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
69
|
+
className: "flex items-center justify-between gap-space-3",
|
|
70
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
71
|
+
variant: "sm",
|
|
72
|
+
weight: "medium",
|
|
73
|
+
children: "Context Window"
|
|
74
|
+
}), percentage != null && /* @__PURE__ */ jsxs(Text, {
|
|
75
|
+
variant: "xs",
|
|
76
|
+
color: "secondary",
|
|
77
|
+
className: "tabular-nums",
|
|
78
|
+
children: [percentage, "% used"]
|
|
79
|
+
})]
|
|
80
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
81
|
+
className: "flex flex-col gap-space-2",
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsxs("div", {
|
|
84
|
+
className: "flex flex-wrap items-baseline gap-space-1 tabular-nums",
|
|
85
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
86
|
+
variant: "h2",
|
|
87
|
+
as: "span",
|
|
88
|
+
children: used == null ? "—" : compact.format(used)
|
|
89
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
90
|
+
variant: "xs",
|
|
91
|
+
color: "secondary",
|
|
92
|
+
children: limit == null ? "tokens used" : `/ ${compact.format(limit)} tokens`
|
|
93
|
+
})]
|
|
94
|
+
}),
|
|
95
|
+
ratio != null && /* @__PURE__ */ jsx(ProgressBar, {
|
|
96
|
+
value: Math.min(ratio, 1),
|
|
97
|
+
max: 1,
|
|
98
|
+
size: "sm",
|
|
99
|
+
color: intent,
|
|
100
|
+
fill: "solid",
|
|
101
|
+
"aria-label": "Context window usage",
|
|
102
|
+
"aria-valuetext": label
|
|
103
|
+
}),
|
|
104
|
+
/* @__PURE__ */ jsx(Text, {
|
|
105
|
+
variant: "xs",
|
|
106
|
+
className: cn("leading-normal text-secondary", isNearLimit && "text-warning-primary", isFull && "text-error-secondary"),
|
|
107
|
+
children: description ?? status
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})]
|
|
111
|
+
}),
|
|
112
|
+
children,
|
|
113
|
+
model && /* @__PURE__ */ jsx("dl", {
|
|
114
|
+
className: "border-t border-subtle pt-space-3",
|
|
115
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
116
|
+
className: "flex items-baseline justify-between gap-space-4",
|
|
117
|
+
children: [/* @__PURE__ */ jsx("dt", {
|
|
118
|
+
className: "shrink-0",
|
|
119
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
120
|
+
variant: "xs",
|
|
121
|
+
color: "secondary",
|
|
122
|
+
children: "Model"
|
|
123
|
+
})
|
|
124
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
125
|
+
className: "min-w-0 text-right",
|
|
126
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
127
|
+
variant: "xs",
|
|
128
|
+
as: "div",
|
|
129
|
+
className: "leading-normal break-words tabular-nums [overflow-wrap:anywhere]",
|
|
130
|
+
children: model
|
|
131
|
+
})
|
|
132
|
+
})]
|
|
133
|
+
})
|
|
134
|
+
}),
|
|
135
|
+
footer && /* @__PURE__ */ jsx("div", {
|
|
136
|
+
className: "border-t border-subtle pt-space-3",
|
|
137
|
+
children: footer
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
})]
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { ChatContextWindowPopover };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=ChatContextWindowPopover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatContextWindowPopover.js","names":[],"sources":["../../../src/components/ChatContextWindowPopover/ChatContextWindowPopover.tsx"],"sourcesContent":["import { useState, type ReactNode } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { CircularProgress } from '../CircularProgress';\nimport { Popover, PopoverContent, PopoverTrigger } from '../Popover';\nimport { ProgressBar } from '../ProgressBar';\nimport { Text } from '../Text';\nimport { Tooltip } from '../Tooltip';\n\nexport interface ChatContextWindowPopoverProps {\n /** Current context occupancy, not cumulative billed tokens. Null means unavailable. */\n tokensUsed: number | null;\n /** Effective model capacity; omit when the provider does not report it. */\n contextWindow?: number | null;\n model?: string;\n /** Fraction at which to warn, from 0 to 1. Defaults to 0.8. */\n warningThreshold?: number;\n /** Replaces the default guidance, e.g. an estimate or automatic compaction policy. */\n description?: string;\n /** Product-owned details, such as token breakdowns or session cost. */\n children?: ReactNode;\n /** Optional actions or status, e.g. compact, retry, or ThinkingState. */\n footer?: ReactNode;\n disabled?: boolean;\n className?: string;\n}\n\nconst compact = new Intl.NumberFormat('en-US', {\n notation: 'compact',\n maximumFractionDigits: 1,\n});\nconst exact = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 });\n\nfunction validTokens(value: number | null | undefined) {\n return value != null && Number.isFinite(value) && value >= 0 ? value : null;\n}\n\n/** Shared context-usage presentation; apps own data, additional content, and actions. */\nexport function ChatContextWindowPopover({\n tokensUsed,\n contextWindow,\n model,\n warningThreshold = 0.8,\n description,\n children,\n footer,\n disabled = false,\n className,\n}: ChatContextWindowPopoverProps) {\n const [open, setOpen] = useState(false);\n const used = validTokens(tokensUsed);\n const limit = validTokens(contextWindow) || null;\n const ratio = used != null && limit != null ? used / limit : null;\n const threshold = Number.isFinite(warningThreshold)\n ? Math.min(1, Math.max(0, warningThreshold))\n : 0.8;\n const isFull = ratio != null && ratio >= 1;\n const isNearLimit = ratio != null && ratio >= threshold;\n const intent = isFull ? 'error' : isNearLimit ? 'warning' : 'neutral';\n // Rounding must not claim the window is full before it is.\n const percentage =\n ratio == null\n ? null\n : Math.min(isFull ? Infinity : 99, Math.round(ratio * 100));\n const status =\n used == null\n ? 'Token usage is unavailable.'\n : limit == null\n ? 'The provider has not reported a context limit.'\n : isFull\n ? 'Context limit reached'\n : isNearLimit\n ? 'Context nearly full'\n : `${compact.format(limit - used)} tokens remaining`;\n const label = `Context window: ${\n used == null\n ? 'usage unavailable'\n : `${exact.format(used)} tokens used${limit == null ? ', limit unknown' : ` of ${exact.format(limit)}, ${percentage}% used`}`\n }`;\n\n return (\n <Popover open={open && !disabled} onOpenChange={setOpen}>\n <Tooltip\n title={\n percentage == null ? 'Context usage' : `Context: ${percentage}% used`\n }\n disabled={disabled}\n >\n <PopoverTrigger asChild>\n <Button\n type=\"button\"\n size=\"sm\"\n color=\"secondary\"\n variant=\"plain\"\n disabled={disabled}\n aria-label={label}\n className={cn('w-6 shrink-0 px-0', className)}\n >\n <CircularProgress\n size={16}\n strokeWidth={2}\n segments={\n ratio == null\n ? []\n : [{ variant: intent, percentage: Math.min(ratio, 1) }]\n }\n />\n </Button>\n </PopoverTrigger>\n </Tooltip>\n <PopoverContent\n side=\"top\"\n align=\"end\"\n sideOffset={8}\n collisionPadding={12}\n aria-label=\"Context window\"\n className=\"flex w-72 max-w-[calc(100vw-1.5rem)] flex-col gap-space-4 text-primary\"\n >\n <div className=\"flex flex-col gap-space-3\">\n <div className=\"flex items-center justify-between gap-space-3\">\n <Text variant=\"sm\" weight=\"medium\">\n Context Window\n </Text>\n {percentage != null && (\n <Text variant=\"xs\" color=\"secondary\" className=\"tabular-nums\">\n {percentage}% used\n </Text>\n )}\n </div>\n <div className=\"flex flex-col gap-space-2\">\n <div className=\"flex flex-wrap items-baseline gap-space-1 tabular-nums\">\n <Text variant=\"h2\" as=\"span\">\n {used == null ? '—' : compact.format(used)}\n </Text>\n <Text variant=\"xs\" color=\"secondary\">\n {limit == null\n ? 'tokens used'\n : `/ ${compact.format(limit)} tokens`}\n </Text>\n </div>\n {ratio != null && (\n <ProgressBar\n value={Math.min(ratio, 1)}\n max={1}\n size=\"sm\"\n color={intent}\n fill=\"solid\"\n aria-label=\"Context window usage\"\n aria-valuetext={label}\n />\n )}\n <Text\n variant=\"xs\"\n className={cn(\n 'leading-normal text-secondary',\n isNearLimit && 'text-warning-primary',\n isFull && 'text-error-secondary'\n )}\n >\n {description ?? status}\n </Text>\n </div>\n </div>\n {children}\n {model && (\n <dl className=\"border-t border-subtle pt-space-3\">\n <div className=\"flex items-baseline justify-between gap-space-4\">\n <dt className=\"shrink-0\">\n <Text variant=\"xs\" color=\"secondary\">\n Model\n </Text>\n </dt>\n <dd className=\"min-w-0 text-right\">\n <Text\n variant=\"xs\"\n as=\"div\"\n className=\"leading-normal break-words tabular-nums [overflow-wrap:anywhere]\"\n >\n {model}\n </Text>\n </dd>\n </div>\n </dl>\n )}\n {footer && (\n <div className=\"border-t border-subtle pt-space-3\">{footer}</div>\n )}\n </PopoverContent>\n </Popover>\n );\n}\n"],"mappings":"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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cn } from "../../utils/cn.js";
|
|
2
2
|
import { Text } from "../Text/Text.js";
|
|
3
3
|
import { Button } from "../Button/Button.js";
|
|
4
|
+
import { CircularProgress } from "../CircularProgress/CircularProgress.js";
|
|
4
5
|
import { ChatToolCallCaret } from "../ChatToolCall/ChatToolCallCaret.js";
|
|
5
6
|
import { ChatToolCallCollapse } from "../ChatToolCall/ChatToolCallCollapse.js";
|
|
6
|
-
import { CircularProgress } from "../CircularProgress/CircularProgress.js";
|
|
7
7
|
import { useId, useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
@@ -79,7 +79,7 @@ function ChatPlan({ items, title = "Plan", presentation = "block", expanded, def
|
|
|
79
79
|
"aria-expanded": isExpanded,
|
|
80
80
|
"aria-controls": listId,
|
|
81
81
|
onClick: () => setExpanded(!isExpanded),
|
|
82
|
-
className: "h-auto min-w-0 justify-start gap-space-2 border-0 bg-transparent px-0 py-space-1 text-left shadow-none hover:bg-transparent",
|
|
82
|
+
className: "h-auto min-w-0 justify-start gap-space-2 border-0 bg-transparent px-0 py-space-1 text-left shadow-none hover:bg-transparent dark:hover:bg-transparent",
|
|
83
83
|
children: [
|
|
84
84
|
/* @__PURE__ */ jsx(CircularProgress, {
|
|
85
85
|
size: 14,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatPlan.js","names":[],"sources":["../../../src/components/ChatPlan/ChatPlan.tsx"],"sourcesContent":["import { useId, useState } from 'react';\n\nimport { CheckCircleIcon } from '@phosphor-icons/react/dist/ssr/CheckCircle';\nimport { CircleIcon } from '@phosphor-icons/react/dist/ssr/Circle';\nimport { CircleDashedIcon } from '@phosphor-icons/react/dist/ssr/CircleDashed';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ChatToolCallCaret } from '../ChatToolCall/ChatToolCallCaret';\nimport { ChatToolCallCollapse } from '../ChatToolCall/ChatToolCallCollapse';\nimport { CircularProgress } from '../CircularProgress';\nimport { Text } from '../Text';\n\nexport type ChatPlanItemStatus = 'pending' | 'in-progress' | 'completed';\n\nexport interface ChatPlanItem {\n /** Stable across updates, so items keep their place as the plan changes. */\n id: string;\n label: string;\n status: ChatPlanItemStatus;\n}\n\nexport interface ChatPlanProps {\n /** Items in the agent's order. Renders nothing when empty. */\n items: readonly ChatPlanItem[];\n /** Defaults to \"Plan\". */\n title?: string;\n /**\n * `drawer` fits `ChatComposer`'s drawer slot, alone or stacked with other\n * drawer content.\n */\n presentation?: 'block' | 'drawer';\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n className?: string;\n}\n\n// Outline icons in ChatState's colors, so a plan reads like the rest of the chat.\nconst ITEM_PRESENTATIONS = {\n pending: {\n label: 'Pending',\n icon: CircleIcon,\n iconClassName: 'text-icon-tertiary',\n textColor: 'secondary',\n },\n 'in-progress': {\n label: 'In progress',\n icon: CircleDashedIcon,\n iconClassName: 'text-icon-secondary',\n textColor: 'primary',\n },\n completed: {\n label: 'Completed',\n icon: CheckCircleIcon,\n iconClassName: 'text-icon-success',\n textColor: 'tertiary',\n },\n} as const;\n\nconst ENTER =\n 'animate-in fade-in ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none';\n\nfunction summarize(items: readonly ChatPlanItem[]) {\n const total = items.length;\n const done = items.filter((item) => item.status === 'completed').length;\n const currentIndex = items.findIndex((item) => item.status === 'in-progress');\n if (currentIndex !== -1) {\n return {\n done,\n progress: `Task ${currentIndex + 1} of ${total}`,\n current: items[currentIndex].label,\n };\n }\n return {\n done,\n progress: done === total ? `All ${total} done` : `${done} of ${total} done`,\n current: undefined,\n };\n}\n\n/**\n * An agent's task list, such as the todos a deep agent writes as it works.\n * Collapsed, it shows progress and the current task; expanded, every task.\n */\nexport function ChatPlan({\n items,\n title = 'Plan',\n presentation = 'block',\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n className,\n}: ChatPlanProps) {\n const listId = useId();\n const currentId = useId();\n const [isExpanded = false, setExpanded] = useControllableState({\n prop: expanded,\n defaultProp: defaultExpanded,\n onChange: onExpandedChange,\n });\n // A plan restored from history appears at rest; only changes animate.\n const [initial] = useState(() => ({\n completed: new Set(\n items.filter((item) => item.status === 'completed').map((item) => item.id)\n ),\n current: summarize(items).current,\n }));\n if (items.length === 0) return null;\n\n const isDrawer = presentation === 'drawer';\n const { done, progress, current } = summarize(items);\n\n return (\n <section\n aria-label={title}\n className={cn(\n 'flex min-w-0 max-w-full flex-col font-sans text-primary',\n isDrawer\n ? // Its own neutral surface keeps the plan neutral when it shares a\n // drawer whose intent colors a question or notice.\n cn(\n 'bg-surface-level-2 px-space-4 py-space-2',\n ENTER,\n 'duration-normal'\n )\n : 'rounded-lg border border-subtle bg-elevated px-space-3 py-space-2',\n className\n )}\n >\n <Button\n type=\"button\"\n variant=\"plain\"\n color=\"secondary\"\n size=\"sm\"\n aria-label={`${title}: ${progress}`}\n aria-describedby={current && !isExpanded ? currentId : undefined}\n aria-expanded={isExpanded}\n aria-controls={listId}\n onClick={() => setExpanded(!isExpanded)}\n className=\"h-auto min-w-0 justify-start gap-space-2 border-0 bg-transparent px-0 py-space-1 text-left shadow-none hover:bg-transparent\"\n >\n <CircularProgress\n size={14}\n strokeWidth={2}\n segments={[{ variant: 'success', percentage: done / items.length }]}\n className=\"shrink-0\"\n />\n <Text as=\"span\" variant=\"xs\" weight=\"medium\" className=\"shrink-0\">\n {title}\n </Text>\n <Text\n as=\"span\"\n variant=\"xs\"\n color=\"secondary\"\n className=\"shrink-0 tabular-nums\"\n >\n {progress}\n </Text>\n {current && !isExpanded && (\n <Text\n // The next task crossfades in as the agent moves on.\n key={current}\n id={currentId}\n as=\"span\"\n variant=\"xs\"\n color=\"tertiary\"\n className={cn(\n 'min-w-0 truncate',\n current !== initial.current &&\n cn(ENTER, 'slide-in-from-bottom-1 duration-normal')\n )}\n >\n {current}\n </Text>\n )}\n <ChatToolCallCaret open={isExpanded} className=\"ml-auto\" />\n </Button>\n <ChatToolCallCollapse open={isExpanded} id={listId}>\n <ol\n aria-label={`${title} tasks`}\n className={cn(\n 'm-0 flex list-none flex-col gap-space-1 p-0 pb-space-1 pt-space-1',\n // Short enough that a question sharing the drawer stays in view.\n isDrawer &&\n 'max-h-[min(12rem,30dvh)] overflow-y-auto overscroll-contain'\n )}\n >\n {items.map((item) => {\n const {\n icon: StatusIcon,\n iconClassName,\n label,\n textColor,\n } = ITEM_PRESENTATIONS[item.status];\n const justCompleted =\n item.status === 'completed' && !initial.completed.has(item.id);\n return (\n <li\n key={item.id}\n data-status={item.status}\n className=\"flex min-w-0 items-start gap-space-2\"\n >\n <StatusIcon\n // Remounts on each status change so a new check pops in.\n key={item.status}\n size={14}\n weight=\"regular\"\n aria-hidden=\"true\"\n className={cn(\n 'mt-0.5 shrink-0',\n iconClassName,\n justCompleted && cn(ENTER, 'zoom-in-75 duration-normal')\n )}\n />\n <Text\n as=\"span\"\n variant=\"xs\"\n color={textColor}\n className=\"min-w-0 leading-5 transition-colors duration-slow [overflow-wrap:anywhere] motion-reduce:transition-none\"\n >\n {item.label}\n <span className=\"sr-only\">{` (${label})`}</span>\n </Text>\n </li>\n );\n })}\n </ol>\n </ChatToolCallCollapse>\n </section>\n );\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"ChatPlan.js","names":[],"sources":["../../../src/components/ChatPlan/ChatPlan.tsx"],"sourcesContent":["import { useId, useState } from 'react';\n\nimport { CheckCircleIcon } from '@phosphor-icons/react/dist/ssr/CheckCircle';\nimport { CircleIcon } from '@phosphor-icons/react/dist/ssr/Circle';\nimport { CircleDashedIcon } from '@phosphor-icons/react/dist/ssr/CircleDashed';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ChatToolCallCaret } from '../ChatToolCall/ChatToolCallCaret';\nimport { ChatToolCallCollapse } from '../ChatToolCall/ChatToolCallCollapse';\nimport { CircularProgress } from '../CircularProgress';\nimport { Text } from '../Text';\n\nexport type ChatPlanItemStatus = 'pending' | 'in-progress' | 'completed';\n\nexport interface ChatPlanItem {\n /** Stable across updates, so items keep their place as the plan changes. */\n id: string;\n label: string;\n status: ChatPlanItemStatus;\n}\n\nexport interface ChatPlanProps {\n /** Items in the agent's order. Renders nothing when empty. */\n items: readonly ChatPlanItem[];\n /** Defaults to \"Plan\". */\n title?: string;\n /**\n * `drawer` fits `ChatComposer`'s drawer slot, alone or stacked with other\n * drawer content.\n */\n presentation?: 'block' | 'drawer';\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n className?: string;\n}\n\n// Outline icons in ChatState's colors, so a plan reads like the rest of the chat.\nconst ITEM_PRESENTATIONS = {\n pending: {\n label: 'Pending',\n icon: CircleIcon,\n iconClassName: 'text-icon-tertiary',\n textColor: 'secondary',\n },\n 'in-progress': {\n label: 'In progress',\n icon: CircleDashedIcon,\n iconClassName: 'text-icon-secondary',\n textColor: 'primary',\n },\n completed: {\n label: 'Completed',\n icon: CheckCircleIcon,\n iconClassName: 'text-icon-success',\n textColor: 'tertiary',\n },\n} as const;\n\nconst ENTER =\n 'animate-in fade-in ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none';\n\nfunction summarize(items: readonly ChatPlanItem[]) {\n const total = items.length;\n const done = items.filter((item) => item.status === 'completed').length;\n const currentIndex = items.findIndex((item) => item.status === 'in-progress');\n if (currentIndex !== -1) {\n return {\n done,\n progress: `Task ${currentIndex + 1} of ${total}`,\n current: items[currentIndex].label,\n };\n }\n return {\n done,\n progress: done === total ? `All ${total} done` : `${done} of ${total} done`,\n current: undefined,\n };\n}\n\n/**\n * An agent's task list, such as the todos a deep agent writes as it works.\n * Collapsed, it shows progress and the current task; expanded, every task.\n */\nexport function ChatPlan({\n items,\n title = 'Plan',\n presentation = 'block',\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n className,\n}: ChatPlanProps) {\n const listId = useId();\n const currentId = useId();\n const [isExpanded = false, setExpanded] = useControllableState({\n prop: expanded,\n defaultProp: defaultExpanded,\n onChange: onExpandedChange,\n });\n // A plan restored from history appears at rest; only changes animate.\n const [initial] = useState(() => ({\n completed: new Set(\n items.filter((item) => item.status === 'completed').map((item) => item.id)\n ),\n current: summarize(items).current,\n }));\n if (items.length === 0) return null;\n\n const isDrawer = presentation === 'drawer';\n const { done, progress, current } = summarize(items);\n\n return (\n <section\n aria-label={title}\n className={cn(\n 'flex min-w-0 max-w-full flex-col font-sans text-primary',\n isDrawer\n ? // Its own neutral surface keeps the plan neutral when it shares a\n // drawer whose intent colors a question or notice.\n cn(\n 'bg-surface-level-2 px-space-4 py-space-2',\n ENTER,\n 'duration-normal'\n )\n : 'rounded-lg border border-subtle bg-elevated px-space-3 py-space-2',\n className\n )}\n >\n <Button\n type=\"button\"\n variant=\"plain\"\n color=\"secondary\"\n size=\"sm\"\n aria-label={`${title}: ${progress}`}\n aria-describedby={current && !isExpanded ? currentId : undefined}\n aria-expanded={isExpanded}\n aria-controls={listId}\n onClick={() => setExpanded(!isExpanded)}\n className=\"h-auto min-w-0 justify-start gap-space-2 border-0 bg-transparent px-0 py-space-1 text-left shadow-none hover:bg-transparent dark:hover:bg-transparent\"\n >\n <CircularProgress\n size={14}\n strokeWidth={2}\n segments={[{ variant: 'success', percentage: done / items.length }]}\n className=\"shrink-0\"\n />\n <Text as=\"span\" variant=\"xs\" weight=\"medium\" className=\"shrink-0\">\n {title}\n </Text>\n <Text\n as=\"span\"\n variant=\"xs\"\n color=\"secondary\"\n className=\"shrink-0 tabular-nums\"\n >\n {progress}\n </Text>\n {current && !isExpanded && (\n <Text\n // The next task crossfades in as the agent moves on.\n key={current}\n id={currentId}\n as=\"span\"\n variant=\"xs\"\n color=\"tertiary\"\n className={cn(\n 'min-w-0 truncate',\n current !== initial.current &&\n cn(ENTER, 'slide-in-from-bottom-1 duration-normal')\n )}\n >\n {current}\n </Text>\n )}\n <ChatToolCallCaret open={isExpanded} className=\"ml-auto\" />\n </Button>\n <ChatToolCallCollapse open={isExpanded} id={listId}>\n <ol\n aria-label={`${title} tasks`}\n className={cn(\n 'm-0 flex list-none flex-col gap-space-1 p-0 pb-space-1 pt-space-1',\n // Short enough that a question sharing the drawer stays in view.\n isDrawer &&\n 'max-h-[min(12rem,30dvh)] overflow-y-auto overscroll-contain'\n )}\n >\n {items.map((item) => {\n const {\n icon: StatusIcon,\n iconClassName,\n label,\n textColor,\n } = ITEM_PRESENTATIONS[item.status];\n const justCompleted =\n item.status === 'completed' && !initial.completed.has(item.id);\n return (\n <li\n key={item.id}\n data-status={item.status}\n className=\"flex min-w-0 items-start gap-space-2\"\n >\n <StatusIcon\n // Remounts on each status change so a new check pops in.\n key={item.status}\n size={14}\n weight=\"regular\"\n aria-hidden=\"true\"\n className={cn(\n 'mt-0.5 shrink-0',\n iconClassName,\n justCompleted && cn(ENTER, 'zoom-in-75 duration-normal')\n )}\n />\n <Text\n as=\"span\"\n variant=\"xs\"\n color={textColor}\n className=\"min-w-0 leading-5 transition-colors duration-slow [overflow-wrap:anywhere] motion-reduce:transition-none\"\n >\n {item.label}\n <span className=\"sr-only\">{` (${label})`}</span>\n </Text>\n </li>\n );\n })}\n </ol>\n </ChatToolCallCollapse>\n </section>\n );\n}\n"],"mappings":"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"}
|
|
@@ -33,7 +33,7 @@ function ChatToolCallAccordion({ heading, status, meta, children, groupLabel, tr
|
|
|
33
33
|
"aria-controls": detailsId,
|
|
34
34
|
"aria-expanded": isExpanded,
|
|
35
35
|
onClick: () => setExpanded(!isExpanded),
|
|
36
|
-
className: "static h-auto min-w-0 flex-1 border-0 justify-start gap-space-2 px-0 py-space-1 text-left shadow-none outline-none after:absolute after:inset-0 after:rounded-md hover:bg-transparent focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus",
|
|
36
|
+
className: "static h-auto min-w-0 flex-1 border-0 justify-start gap-space-2 px-0 py-space-1 text-left shadow-none outline-none after:absolute after:inset-0 after:rounded-md hover:bg-transparent dark:hover:bg-transparent focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus",
|
|
37
37
|
children: heading
|
|
38
38
|
}) : /* @__PURE__ */ jsx("span", {
|
|
39
39
|
className: "flex min-w-0 flex-1 items-center gap-space-2 py-space-1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatToolCallAccordion.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallAccordion.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ChatToolCallCaret } from './ChatToolCallCaret';\nimport { ChatToolCallCollapse } from './ChatToolCallCollapse';\n\nconst SWAP_TRANSITION =\n 'transition-[opacity,scale] duration-fast ease-out motion-reduce:transition-none';\n\ninterface ChatToolCallAccordionProps {\n heading: ReactNode;\n status: ReactNode;\n /** Trailing content before the status, outside the toggle. */\n meta?: ReactNode;\n children: ReactNode;\n groupLabel: string;\n triggerLabel: string;\n triggerDescriptionId?: string;\n detailsLabel: string;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n className?: string;\n detailsClassName?: string;\n}\n\nexport function ChatToolCallAccordion({\n heading,\n status,\n meta,\n children,\n groupLabel,\n triggerLabel,\n triggerDescriptionId,\n detailsLabel,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n className,\n detailsClassName,\n}: ChatToolCallAccordionProps) {\n const detailsId = useId();\n const hasDetails = children != null && children !== false;\n const [expandedState = false, setExpanded] = useControllableState({\n prop: expanded,\n defaultProp: defaultExpanded,\n onChange: onExpandedChange,\n });\n const isExpanded = hasDetails && expandedState;\n\n return (\n <div\n role=\"group\"\n aria-label={groupLabel}\n className={cn(\n 'min-w-0 max-w-full font-sans text-xxs text-secondary',\n className\n )}\n >\n <div className=\"group/row relative flex min-w-0 items-center gap-space-2 rounded-md px-space-1 transition-colors duration-fast hover:bg-surface-level-2 motion-reduce:transition-none\">\n {hasDetails ? (\n <Button\n type=\"button\"\n variant=\"plain\"\n color=\"secondary\"\n size=\"sm\"\n aria-label={triggerLabel}\n aria-describedby={triggerDescriptionId}\n aria-controls={detailsId}\n aria-expanded={isExpanded}\n onClick={() => setExpanded(!isExpanded)}\n // Stretched over the row so the status and caret are clickable too.\n className=\"static h-auto min-w-0 flex-1 border-0 justify-start gap-space-2 px-0 py-space-1 text-left shadow-none outline-none after:absolute after:inset-0 after:rounded-md hover:bg-transparent focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus\"\n >\n {heading}\n </Button>\n ) : (\n <span className=\"flex min-w-0 flex-1 items-center gap-space-2 py-space-1\">\n {heading}\n </span>\n )}\n {meta != null && (\n // Raised above the stretched toggle so links and buttons stay clickable.\n <span className=\"relative z-[1] flex min-w-0 shrink-0 items-center gap-space-1 text-tertiary\">\n {meta}\n </span>\n )}\n {/* Status and caret share the trailing slot: status at rest, caret on\n hover or keyboard focus. */}\n <span className=\"pointer-events-none relative grid shrink-0 items-center justify-items-end *:col-start-1 *:row-start-1\">\n <span\n className={cn(\n 'flex items-center',\n SWAP_TRANSITION,\n hasDetails &&\n 'group-hover/row:scale-90 group-hover/row:opacity-0 group-has-[:focus-visible]/row:scale-90 group-has-[:focus-visible]/row:opacity-0'\n )}\n >\n {status}\n </span>\n {hasDetails && (\n <ChatToolCallCaret\n open={isExpanded}\n className={cn(\n SWAP_TRANSITION,\n 'scale-90 opacity-0 group-hover/row:scale-100 group-hover/row:opacity-100 group-has-[:focus-visible]/row:scale-100 group-has-[:focus-visible]/row:opacity-100'\n )}\n />\n )}\n </span>\n </div>\n {hasDetails && (\n <ChatToolCallCollapse\n open={isExpanded}\n id={detailsId}\n role=\"region\"\n aria-label={detailsLabel}\n className={cn(\n 'min-w-0 py-space-2 pl-space-5 pr-space-1 text-tertiary',\n detailsClassName\n )}\n >\n {children}\n </ChatToolCallCollapse>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AASA,IAAM,kBACJ;AAmBF,SAAgB,sBAAsB,EACpC,SACA,QACA,MACA,UACA,YACA,cACA,sBACA,cACA,UACA,kBAAkB,OAClB,kBACA,WACA,oBAC6B;CAC7B,MAAM,YAAY,MAAM;CACxB,MAAM,aAAa,YAAY,QAAQ,aAAa;CACpD,MAAM,CAAC,gBAAgB,OAAO,eAAe,qBAAqB;EAChE,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;CACD,MAAM,aAAa,cAAc;CAEjC,OACE,qBAAC,OAAD;EACE,MAAK;EACL,cAAY;EACZ,WAAW,GACT,wDACA,SACF;EANF,UAAA,CAQE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACG,aACC,oBAAC,QAAD;KACE,MAAK;KACL,SAAQ;KACR,OAAM;KACN,MAAK;KACL,cAAY;KACZ,oBAAkB;KAClB,iBAAe;KACf,iBAAe;KACf,eAAe,YAAY,CAAC,UAAU;KAEtC,WAAU;KAET,UAAA;IACK,CAAA,IAER,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA;IACG,CAAA;IAEP,QAAQ,QAEP,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA;IACG,CAAA;IAIR,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACE,oBAAC,QAAD;MACE,WAAW,GACT,qBACA,iBACA,cACE,qIACJ;MAEC,UAAA;KACG,CAAA,GACL,cACC,oBAAC,mBAAD;MACE,MAAM;MACN,WAAW,GACT,iBACA,8JACF;KACD,CAAA,CAEC;;GACH;EACJ,CAAA,GAAA,cACC,oBAAC,sBAAD;GACE,MAAM;GACN,IAAI;GACJ,MAAK;GACL,cAAY;GACZ,WAAW,GACT,0DACA,gBACF;GAEC;EACmB,CAAA,CAErB;;AAET"}
|
|
1
|
+
{"version":3,"file":"ChatToolCallAccordion.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallAccordion.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ChatToolCallCaret } from './ChatToolCallCaret';\nimport { ChatToolCallCollapse } from './ChatToolCallCollapse';\n\nconst SWAP_TRANSITION =\n 'transition-[opacity,scale] duration-fast ease-out motion-reduce:transition-none';\n\ninterface ChatToolCallAccordionProps {\n heading: ReactNode;\n status: ReactNode;\n /** Trailing content before the status, outside the toggle. */\n meta?: ReactNode;\n children: ReactNode;\n groupLabel: string;\n triggerLabel: string;\n triggerDescriptionId?: string;\n detailsLabel: string;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n className?: string;\n detailsClassName?: string;\n}\n\nexport function ChatToolCallAccordion({\n heading,\n status,\n meta,\n children,\n groupLabel,\n triggerLabel,\n triggerDescriptionId,\n detailsLabel,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n className,\n detailsClassName,\n}: ChatToolCallAccordionProps) {\n const detailsId = useId();\n const hasDetails = children != null && children !== false;\n const [expandedState = false, setExpanded] = useControllableState({\n prop: expanded,\n defaultProp: defaultExpanded,\n onChange: onExpandedChange,\n });\n const isExpanded = hasDetails && expandedState;\n\n return (\n <div\n role=\"group\"\n aria-label={groupLabel}\n className={cn(\n 'min-w-0 max-w-full font-sans text-xxs text-secondary',\n className\n )}\n >\n <div className=\"group/row relative flex min-w-0 items-center gap-space-2 rounded-md px-space-1 transition-colors duration-fast hover:bg-surface-level-2 motion-reduce:transition-none\">\n {hasDetails ? (\n <Button\n type=\"button\"\n variant=\"plain\"\n color=\"secondary\"\n size=\"sm\"\n aria-label={triggerLabel}\n aria-describedby={triggerDescriptionId}\n aria-controls={detailsId}\n aria-expanded={isExpanded}\n onClick={() => setExpanded(!isExpanded)}\n // Stretched over the row so the status and caret are clickable too.\n className=\"static h-auto min-w-0 flex-1 border-0 justify-start gap-space-2 px-0 py-space-1 text-left shadow-none outline-none after:absolute after:inset-0 after:rounded-md hover:bg-transparent dark:hover:bg-transparent focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus\"\n >\n {heading}\n </Button>\n ) : (\n <span className=\"flex min-w-0 flex-1 items-center gap-space-2 py-space-1\">\n {heading}\n </span>\n )}\n {meta != null && (\n // Raised above the stretched toggle so links and buttons stay clickable.\n <span className=\"relative z-[1] flex min-w-0 shrink-0 items-center gap-space-1 text-tertiary\">\n {meta}\n </span>\n )}\n {/* Status and caret share the trailing slot: status at rest, caret on\n hover or keyboard focus. */}\n <span className=\"pointer-events-none relative grid shrink-0 items-center justify-items-end *:col-start-1 *:row-start-1\">\n <span\n className={cn(\n 'flex items-center',\n SWAP_TRANSITION,\n hasDetails &&\n 'group-hover/row:scale-90 group-hover/row:opacity-0 group-has-[:focus-visible]/row:scale-90 group-has-[:focus-visible]/row:opacity-0'\n )}\n >\n {status}\n </span>\n {hasDetails && (\n <ChatToolCallCaret\n open={isExpanded}\n className={cn(\n SWAP_TRANSITION,\n 'scale-90 opacity-0 group-hover/row:scale-100 group-hover/row:opacity-100 group-has-[:focus-visible]/row:scale-100 group-has-[:focus-visible]/row:opacity-100'\n )}\n />\n )}\n </span>\n </div>\n {hasDetails && (\n <ChatToolCallCollapse\n open={isExpanded}\n id={detailsId}\n role=\"region\"\n aria-label={detailsLabel}\n className={cn(\n 'min-w-0 py-space-2 pl-space-5 pr-space-1 text-tertiary',\n detailsClassName\n )}\n >\n {children}\n </ChatToolCallCollapse>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AASA,IAAM,kBACJ;AAmBF,SAAgB,sBAAsB,EACpC,SACA,QACA,MACA,UACA,YACA,cACA,sBACA,cACA,UACA,kBAAkB,OAClB,kBACA,WACA,oBAC6B;CAC7B,MAAM,YAAY,MAAM;CACxB,MAAM,aAAa,YAAY,QAAQ,aAAa;CACpD,MAAM,CAAC,gBAAgB,OAAO,eAAe,qBAAqB;EAChE,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;CACD,MAAM,aAAa,cAAc;CAEjC,OACE,qBAAC,OAAD;EACE,MAAK;EACL,cAAY;EACZ,WAAW,GACT,wDACA,SACF;EANF,UAAA,CAQE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACG,aACC,oBAAC,QAAD;KACE,MAAK;KACL,SAAQ;KACR,OAAM;KACN,MAAK;KACL,cAAY;KACZ,oBAAkB;KAClB,iBAAe;KACf,iBAAe;KACf,eAAe,YAAY,CAAC,UAAU;KAEtC,WAAU;KAET,UAAA;IACK,CAAA,IAER,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA;IACG,CAAA;IAEP,QAAQ,QAEP,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA;IACG,CAAA;IAIR,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACE,oBAAC,QAAD;MACE,WAAW,GACT,qBACA,iBACA,cACE,qIACJ;MAEC,UAAA;KACG,CAAA,GACL,cACC,oBAAC,mBAAD;MACE,MAAM;MACN,WAAW,GACT,iBACA,8JACF;KACD,CAAA,CAEC;;GACH;EACJ,CAAA,GAAA,cACC,oBAAC,sBAAD;GACE,MAAM;GACN,IAAI;GACJ,MAAK;GACL,cAAY;GACZ,WAAW,GACT,0DACA,gBACF;GAEC;EACmB,CAAA,CAErB;;AAET"}
|
|
@@ -32,7 +32,7 @@ function ChatToolCallGroup({ label, children, expanded, defaultExpanded = false,
|
|
|
32
32
|
"aria-controls": contentId,
|
|
33
33
|
"aria-expanded": isExpanded,
|
|
34
34
|
onClick: () => setExpanded(!isExpanded),
|
|
35
|
-
className: "static h-auto min-w-0 flex-1 justify-start gap-space-2 border-0 bg-transparent px-0 py-space-1 text-left shadow-none outline-none after:absolute after:inset-0 after:rounded-md hover:bg-transparent focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus",
|
|
35
|
+
className: "static h-auto min-w-0 flex-1 justify-start gap-space-2 border-0 bg-transparent px-0 py-space-1 text-left shadow-none outline-none after:absolute after:inset-0 after:rounded-md hover:bg-transparent dark:hover:bg-transparent focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus",
|
|
36
36
|
children: [icons.length > 0 && /* @__PURE__ */ jsx("span", {
|
|
37
37
|
"aria-hidden": "true",
|
|
38
38
|
className: "flex shrink-0 items-center",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatToolCallGroup.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallGroup.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ChatState } from '../ChatState';\nimport { Text } from '../Text';\nimport { ChatToolCallCaret } from './ChatToolCallCaret';\nimport { ChatToolCallCollapse } from './ChatToolCallCollapse';\nimport {\n ChatToolCallGroupContext,\n useGroupRows,\n} from './ChatToolCallGroupContext';\nimport { ChatToolCallIcon } from './ChatToolCallIcon';\n\nexport interface ChatToolCallGroupProps {\n /**\n * Hosts supply the count/summary and group only consecutive content. To\n * summarize a whole turn, use a label such as\n * `Worked for ${formatChatDuration(ms)} · 6 actions`.\n */\n label: string;\n children: ReactNode;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /**\n * Marks the work as in progress even when no row runs, such as while the\n * agent decides its next step. Defaults to whether any row is running.\n */\n running?: boolean;\n /** Show elapsed time beside the header's indicator while the work runs. */\n showElapsed?: boolean;\n /** Host-measured duration for the header timer. */\n elapsedMs?: number;\n /**\n * Wall-clock start of the grouped work, such as the turn's first event. The\n * header timer counts from it, so it keeps counting across remounts.\n */\n startedAt?: Date | number;\n className?: string;\n}\n\nexport function ChatToolCallGroup({\n label,\n children,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n running,\n showElapsed = false,\n elapsedMs,\n startedAt,\n className,\n}: ChatToolCallGroupProps) {\n const contentId = useId();\n const [isExpanded = false, setExpanded] = useControllableState({\n prop: expanded,\n defaultProp: defaultExpanded,\n onChange: onExpandedChange,\n });\n const { registry, anyRunning, allSucceeded, icons } = useGroupRows();\n const working = running ?? anyRunning;\n\n return (\n <div className={cn('min-w-0 max-w-full font-sans text-xxs', className)}>\n <div\n className={cn(\n 'relative flex min-w-0 items-center gap-space-2 pr-space-1',\n // Flush left so the first tile's padded glyph lines up with row icons.\n icons.length > 0 ? 'pl-0' : 'pl-space-1'\n )}\n >\n <Button\n type=\"button\"\n variant=\"plain\"\n color=\"secondary\"\n size=\"sm\"\n aria-label={label}\n aria-controls={contentId}\n aria-expanded={isExpanded}\n onClick={() => setExpanded(!isExpanded)}\n // Stretched over the header so the whole row toggles the group.\n className=\"static h-auto min-w-0 flex-1 justify-start gap-space-2 border-0 bg-transparent px-0 py-space-1 text-left shadow-none outline-none after:absolute after:inset-0 after:rounded-md hover:bg-transparent focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus\"\n >\n {icons.length > 0 && (\n <span aria-hidden=\"true\" className=\"flex shrink-0 items-center\">\n {icons.map((icon, index) => (\n <span\n key={index}\n className={cn(\n 'flex size-5 items-center justify-center rounded-[6px] border border-subtle bg-surface-level-2',\n index > 0 && '-ml-space-1'\n )}\n >\n <ChatToolCallIcon>{icon}</ChatToolCallIcon>\n </span>\n ))}\n </span>\n )}\n <span className=\"flex min-w-0 items-center gap-space-1\">\n <Text\n as=\"span\"\n variant=\"xs\"\n color=\"tertiary\"\n className=\"min-w-0 truncate\"\n >\n {label}\n </Text>\n <ChatToolCallCaret open={isExpanded} />\n </span>\n </Button>\n {/* Rows omit success and the running indicator; the header carries them. */}\n {(working || allSucceeded) && (\n <span className=\"pointer-events-none relative flex shrink-0 items-center\">\n <ChatState\n variant=\"simple\"\n status={working ? 'streaming' : 'completed'}\n showElapsed={showElapsed && working}\n elapsedMs={elapsedMs}\n startedAt={startedAt}\n />\n </span>\n )}\n </div>\n <ChatToolCallGroupContext.Provider value={registry}>\n <ChatToolCallCollapse\n open={isExpanded}\n keepMounted\n id={contentId}\n className=\"flex min-w-0 flex-col gap-0.5\"\n >\n {children}\n </ChatToolCallCollapse>\n </ChatToolCallGroupContext.Provider>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4CA,SAAgB,kBAAkB,EAChC,OACA,UACA,UACA,kBAAkB,OAClB,kBACA,SACA,cAAc,OACd,WACA,WACA,aACyB;CACzB,MAAM,YAAY,MAAM;CACxB,MAAM,CAAC,aAAa,OAAO,eAAe,qBAAqB;EAC7D,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,UAAU,YAAY,cAAc,UAAU,aAAa;CACnE,MAAM,UAAU,WAAW;CAE3B,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,yCAAyC,SAAS;EAArE,UAAA,CACE,qBAAC,OAAD;GACE,WAAW,GACT,6DAEA,MAAM,SAAS,IAAI,SAAS,YAC9B;GALF,UAAA,CAOE,qBAAC,QAAD;IACE,MAAK;IACL,SAAQ;IACR,OAAM;IACN,MAAK;IACL,cAAY;IACZ,iBAAe;IACf,iBAAe;IACf,eAAe,YAAY,CAAC,UAAU;IAEtC,WAAU;IAVZ,UAAA,CAYG,MAAM,SAAS,KACd,oBAAC,QAAD;KAAM,eAAY;KAAO,WAAU;KAChC,UAAA,MAAM,KAAK,MAAM,UAChB,oBAAC,QAAD;MAEE,WAAW,GACT,iGACA,QAAQ,KAAK,aACf;MAEA,UAAA,oBAAC,kBAAD,EAAA,UAAmB,KAAuB,CAAA;KACtC,GAPC,KAOD,CACP;IACG,CAAA,GAER,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACE,oBAAC,MAAD;MACE,IAAG;MACH,SAAQ;MACR,OAAM;MACN,WAAU;MAET,UAAA;KACG,CAAA,GACN,oBAAC,mBAAD,EAAmB,MAAM,WAAa,CAAA,CAClC;IACA,CAAA,CAAA;GAEN,CAAA,IAAA,WAAW,iBACX,oBAAC,QAAD;IAAM,WAAU;IACd,UAAA,oBAAC,WAAD;KACE,SAAQ;KACR,QAAQ,UAAU,cAAc;KAChC,aAAa,eAAe;KACjB;KACA;IACZ,CAAA;GACG,CAAA,CAEL;EACL,CAAA,GAAA,oBAAC,yBAAyB,UAA1B;GAAmC,OAAO;GACxC,UAAA,oBAAC,sBAAD;IACE,MAAM;IACN,aAAA;IACA,IAAI;IACJ,WAAU;IAET;GACmB,CAAA;EACW,CAAA,CAChC;;AAET"}
|
|
1
|
+
{"version":3,"file":"ChatToolCallGroup.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallGroup.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ChatState } from '../ChatState';\nimport { Text } from '../Text';\nimport { ChatToolCallCaret } from './ChatToolCallCaret';\nimport { ChatToolCallCollapse } from './ChatToolCallCollapse';\nimport {\n ChatToolCallGroupContext,\n useGroupRows,\n} from './ChatToolCallGroupContext';\nimport { ChatToolCallIcon } from './ChatToolCallIcon';\n\nexport interface ChatToolCallGroupProps {\n /**\n * Hosts supply the count/summary and group only consecutive content. To\n * summarize a whole turn, use a label such as\n * `Worked for ${formatChatDuration(ms)} · 6 actions`.\n */\n label: string;\n children: ReactNode;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /**\n * Marks the work as in progress even when no row runs, such as while the\n * agent decides its next step. Defaults to whether any row is running.\n */\n running?: boolean;\n /** Show elapsed time beside the header's indicator while the work runs. */\n showElapsed?: boolean;\n /** Host-measured duration for the header timer. */\n elapsedMs?: number;\n /**\n * Wall-clock start of the grouped work, such as the turn's first event. The\n * header timer counts from it, so it keeps counting across remounts.\n */\n startedAt?: Date | number;\n className?: string;\n}\n\nexport function ChatToolCallGroup({\n label,\n children,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n running,\n showElapsed = false,\n elapsedMs,\n startedAt,\n className,\n}: ChatToolCallGroupProps) {\n const contentId = useId();\n const [isExpanded = false, setExpanded] = useControllableState({\n prop: expanded,\n defaultProp: defaultExpanded,\n onChange: onExpandedChange,\n });\n const { registry, anyRunning, allSucceeded, icons } = useGroupRows();\n const working = running ?? anyRunning;\n\n return (\n <div className={cn('min-w-0 max-w-full font-sans text-xxs', className)}>\n <div\n className={cn(\n 'relative flex min-w-0 items-center gap-space-2 pr-space-1',\n // Flush left so the first tile's padded glyph lines up with row icons.\n icons.length > 0 ? 'pl-0' : 'pl-space-1'\n )}\n >\n <Button\n type=\"button\"\n variant=\"plain\"\n color=\"secondary\"\n size=\"sm\"\n aria-label={label}\n aria-controls={contentId}\n aria-expanded={isExpanded}\n onClick={() => setExpanded(!isExpanded)}\n // Stretched over the header so the whole row toggles the group.\n className=\"static h-auto min-w-0 flex-1 justify-start gap-space-2 border-0 bg-transparent px-0 py-space-1 text-left shadow-none outline-none after:absolute after:inset-0 after:rounded-md hover:bg-transparent dark:hover:bg-transparent focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus\"\n >\n {icons.length > 0 && (\n <span aria-hidden=\"true\" className=\"flex shrink-0 items-center\">\n {icons.map((icon, index) => (\n <span\n key={index}\n className={cn(\n 'flex size-5 items-center justify-center rounded-[6px] border border-subtle bg-surface-level-2',\n index > 0 && '-ml-space-1'\n )}\n >\n <ChatToolCallIcon>{icon}</ChatToolCallIcon>\n </span>\n ))}\n </span>\n )}\n <span className=\"flex min-w-0 items-center gap-space-1\">\n <Text\n as=\"span\"\n variant=\"xs\"\n color=\"tertiary\"\n className=\"min-w-0 truncate\"\n >\n {label}\n </Text>\n <ChatToolCallCaret open={isExpanded} />\n </span>\n </Button>\n {/* Rows omit success and the running indicator; the header carries them. */}\n {(working || allSucceeded) && (\n <span className=\"pointer-events-none relative flex shrink-0 items-center\">\n <ChatState\n variant=\"simple\"\n status={working ? 'streaming' : 'completed'}\n showElapsed={showElapsed && working}\n elapsedMs={elapsedMs}\n startedAt={startedAt}\n />\n </span>\n )}\n </div>\n <ChatToolCallGroupContext.Provider value={registry}>\n <ChatToolCallCollapse\n open={isExpanded}\n keepMounted\n id={contentId}\n className=\"flex min-w-0 flex-col gap-0.5\"\n >\n {children}\n </ChatToolCallCollapse>\n </ChatToolCallGroupContext.Provider>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4CA,SAAgB,kBAAkB,EAChC,OACA,UACA,UACA,kBAAkB,OAClB,kBACA,SACA,cAAc,OACd,WACA,WACA,aACyB;CACzB,MAAM,YAAY,MAAM;CACxB,MAAM,CAAC,aAAa,OAAO,eAAe,qBAAqB;EAC7D,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,UAAU,YAAY,cAAc,UAAU,aAAa;CACnE,MAAM,UAAU,WAAW;CAE3B,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,yCAAyC,SAAS;EAArE,UAAA,CACE,qBAAC,OAAD;GACE,WAAW,GACT,6DAEA,MAAM,SAAS,IAAI,SAAS,YAC9B;GALF,UAAA,CAOE,qBAAC,QAAD;IACE,MAAK;IACL,SAAQ;IACR,OAAM;IACN,MAAK;IACL,cAAY;IACZ,iBAAe;IACf,iBAAe;IACf,eAAe,YAAY,CAAC,UAAU;IAEtC,WAAU;IAVZ,UAAA,CAYG,MAAM,SAAS,KACd,oBAAC,QAAD;KAAM,eAAY;KAAO,WAAU;KAChC,UAAA,MAAM,KAAK,MAAM,UAChB,oBAAC,QAAD;MAEE,WAAW,GACT,iGACA,QAAQ,KAAK,aACf;MAEA,UAAA,oBAAC,kBAAD,EAAA,UAAmB,KAAuB,CAAA;KACtC,GAPC,KAOD,CACP;IACG,CAAA,GAER,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACE,oBAAC,MAAD;MACE,IAAG;MACH,SAAQ;MACR,OAAM;MACN,WAAU;MAET,UAAA;KACG,CAAA,GACN,oBAAC,mBAAD,EAAmB,MAAM,WAAa,CAAA,CAClC;IACA,CAAA,CAAA;GAEN,CAAA,IAAA,WAAW,iBACX,oBAAC,QAAD;IAAM,WAAU;IACd,UAAA,oBAAC,WAAD;KACE,SAAQ;KACR,QAAQ,UAAU,cAAc;KAChC,aAAa,eAAe;KACjB;KACA;IACZ,CAAA;GACG,CAAA,CAEL;EACL,CAAA,GAAA,oBAAC,yBAAyB,UAA1B;GAAmC,OAAO;GACxC,UAAA,oBAAC,sBAAD;IACE,MAAM;IACN,aAAA;IACA,IAAI;IACJ,WAAU;IAET;GACmB,CAAA;EACW,CAAA,CAChC;;AAET"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ProgressSegmentVariant = 'brand' | 'success' | 'error' | 'warning';
|
|
1
|
+
export type ProgressSegmentVariant = 'brand' | 'neutral' | 'success' | 'error' | 'warning';
|
|
2
2
|
export interface ProgressSegment {
|
|
3
3
|
/** Semantic color applied to the segment. */
|
|
4
4
|
variant: ProgressSegmentVariant;
|
|
@@ -3,6 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
//#region packages/components/src/components/CircularProgress/CircularProgress.tsx
|
|
4
4
|
var segmentVariantClasses = {
|
|
5
5
|
brand: "text-icon-brand",
|
|
6
|
+
neutral: "text-icon-secondary",
|
|
6
7
|
success: "text-success-secondary",
|
|
7
8
|
error: "text-error-secondary",
|
|
8
9
|
warning: "text-warning-secondary"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircularProgress.js","names":[],"sources":["../../../src/components/CircularProgress/CircularProgress.tsx"],"sourcesContent":["import { cn } from '../../utils/cn';\n\nexport type ProgressSegmentVariant
|
|
1
|
+
{"version":3,"file":"CircularProgress.js","names":[],"sources":["../../../src/components/CircularProgress/CircularProgress.tsx"],"sourcesContent":["import { cn } from '../../utils/cn';\n\nexport type ProgressSegmentVariant =\n | 'brand'\n | 'neutral'\n | 'success'\n | 'error'\n | 'warning';\n\nexport interface ProgressSegment {\n /** Semantic color applied to the segment. */\n variant: ProgressSegmentVariant;\n percentage: number;\n}\n\nconst segmentVariantClasses: Record<ProgressSegmentVariant, string> = {\n brand: 'text-icon-brand',\n neutral: 'text-icon-secondary',\n success: 'text-success-secondary',\n error: 'text-error-secondary',\n warning: 'text-warning-secondary',\n};\n\nfunction normalizePercentage(percentage: number, max: number) {\n if (!Number.isFinite(percentage)) return 0;\n return Math.min(Math.max(percentage, 0), max);\n}\n\n/**\n * CircularProgress renders a circular progress ring.\n *\n * Two modes:\n * - **Determinate value** — pass `value` (0–1) for a single-color ring (e.g. a\n * sampling rate). Renders with `role=\"progressbar\"` for accessibility.\n * - **Segments** — pass `segments` for a multi-color ring, each with its own\n * color and fraction of the circle.\n *\n * @example\n * ```tsx\n * // Determinate value (single ring)\n * <CircularProgress value={0.73} size={16} strokeWidth={2} aria-label=\"Sampling rate\" />\n *\n * // Multi-segment\n * <CircularProgress\n * segments={[\n * { variant: 'success', percentage: 0.3 },\n * { variant: 'error', percentage: 0.1 },\n * ]}\n * size={120}\n * strokeWidth={8}\n * />\n * ```\n */\ninterface CircularProgressBaseProps {\n size?: number;\n strokeWidth?: number;\n className?: string;\n testId?: string;\n}\n\ninterface CircularProgressValueProps extends CircularProgressBaseProps {\n /** Determinate progress, 0–1. */\n value: number;\n segments?: never;\n /** Accessible name describing the determinate value. */\n 'aria-label': string;\n}\n\ninterface CircularProgressSegmentsProps extends CircularProgressBaseProps {\n /** Multi-segment progress. */\n segments: ProgressSegment[];\n value?: never;\n /** Accessible summary. Omit only when the ring is decorative. */\n 'aria-label'?: string;\n}\n\nexport type CircularProgressProps =\n | CircularProgressValueProps\n | CircularProgressSegmentsProps;\n\nexport function CircularProgress({\n value,\n segments,\n size = 100,\n strokeWidth = 10,\n className,\n testId,\n 'aria-label': ariaLabel,\n}: CircularProgressProps) {\n // Determinate single-value mode collapses to a one-segment ring.\n const isValueMode = value != null;\n const normalizedValue = normalizePercentage(value ?? 0, 1);\n const resolvedSegments: ProgressSegment[] =\n segments ??\n (value != null ? [{ variant: 'brand', percentage: normalizedValue }] : []);\n\n // Calculate dimensions\n const radius = (size - strokeWidth) / 2;\n const circumference = 2 * Math.PI * radius;\n const center = size / 2;\n\n // Calculate segment paths\n let currentAngle = 0;\n\n return (\n <div\n className={cn('relative inline-block', className)}\n data-testid={testId}\n style={{ width: size, height: size }}\n {...(isValueMode\n ? {\n role: 'progressbar',\n 'aria-label': ariaLabel,\n 'aria-valuenow': Math.round(normalizedValue * 100),\n 'aria-valuemin': 0,\n 'aria-valuemax': 100,\n }\n : ariaLabel\n ? { role: 'img', 'aria-label': ariaLabel }\n : {})}\n >\n {/* Background circle */}\n <svg\n aria-hidden=\"true\"\n width={size}\n height={size}\n viewBox={`0 0 ${size} ${size}`}\n >\n <circle\n cx={center}\n cy={center}\n r={radius}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={strokeWidth}\n className=\"text-quaternary opacity-20\"\n />\n\n {/* Segments */}\n {resolvedSegments.map((segment, index) => {\n const strokeDasharray = circumference;\n const remainingPercentage = Math.max(1 - currentAngle, 0);\n const normalizedPercentage = normalizePercentage(\n segment.percentage,\n remainingPercentage\n );\n const strokeDashoffset = circumference * (1 - normalizedPercentage);\n\n // Calculate rotation for this segment\n const rotation = currentAngle * 360 - 90; // -90 to start at top\n currentAngle += normalizedPercentage;\n\n return (\n <circle\n key={index}\n cx={center}\n cy={center}\n r={radius}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={strokeWidth}\n strokeLinecap={isValueMode ? 'round' : 'butt'}\n strokeDasharray={strokeDasharray}\n strokeDashoffset={strokeDashoffset}\n className={cn(\n segmentVariantClasses[segment.variant],\n 'transition-[stroke-dashoffset,transform] duration-slower ease-in-out motion-reduce:transition-none'\n )}\n style={{\n transform: `rotate(${rotation}deg)`,\n transformOrigin: `${center}px ${center}px`,\n }}\n />\n );\n })}\n </svg>\n </div>\n );\n}\n"],"mappings":";;;AAeA,IAAM,wBAAgE;CACpE,OAAO;CACP,SAAS;CACT,SAAS;CACT,OAAO;CACP,SAAS;AACX;AAEA,SAAS,oBAAoB,YAAoB,KAAa;CAC5D,IAAI,CAAC,OAAO,SAAS,UAAU,GAAG,OAAO;CACzC,OAAO,KAAK,IAAI,KAAK,IAAI,YAAY,CAAC,GAAG,GAAG;AAC9C;AAsDA,SAAgB,iBAAiB,EAC/B,OACA,UACA,OAAO,KACP,cAAc,IACd,WACA,QACA,cAAc,aACU;CAExB,MAAM,cAAc,SAAS;CAC7B,MAAM,kBAAkB,oBAAoB,SAAS,GAAG,CAAC;CACzD,MAAM,mBACJ,aACC,SAAS,OAAO,CAAC;EAAE,SAAS;EAAS,YAAY;CAAgB,CAAC,IAAI,CAAC;CAG1E,MAAM,UAAU,OAAO,eAAe;CACtC,MAAM,gBAAgB,IAAI,KAAK,KAAK;CACpC,MAAM,SAAS,OAAO;CAGtB,IAAI,eAAe;CAEnB,OACE,oBAAC,OAAD;EACE,WAAW,GAAG,yBAAyB,SAAS;EAChD,eAAa;EACb,OAAO;GAAE,OAAO;GAAM,QAAQ;EAAK;EACnC,GAAK,cACD;GACE,MAAM;GACN,cAAc;GACd,iBAAiB,KAAK,MAAM,kBAAkB,GAAG;GACjD,iBAAiB;GACjB,iBAAiB;EACnB,IACA,YACE;GAAE,MAAM;GAAO,cAAc;EAAU,IACvC,CAAC;EAGP,UAAA,qBAAC,OAAD;GACE,eAAY;GACZ,OAAO;GACP,QAAQ;GACR,SAAS,OAAO,KAAK,GAAG;GAJ1B,UAAA,CAME,oBAAC,UAAD;IACE,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,MAAK;IACL,QAAO;IACM;IACb,WAAU;GACX,CAAA,GAGA,iBAAiB,KAAK,SAAS,UAAU;IACxC,MAAM,kBAAkB;IACxB,MAAM,sBAAsB,KAAK,IAAI,IAAI,cAAc,CAAC;IACxD,MAAM,uBAAuB,oBAC3B,QAAQ,YACR,mBACF;IACA,MAAM,mBAAmB,iBAAiB,IAAI;IAG9C,MAAM,WAAW,eAAe,MAAM;IACtC,gBAAgB;IAEhB,OACE,oBAAC,UAAD;KAEE,IAAI;KACJ,IAAI;KACJ,GAAG;KACH,MAAK;KACL,QAAO;KACM;KACb,eAAe,cAAc,UAAU;KACtB;KACC;KAClB,WAAW,GACT,sBAAsB,QAAQ,UAC9B,oGACF;KACA,OAAO;MACL,WAAW,UAAU,SAAS;MAC9B,iBAAiB,GAAG,OAAO,KAAK,OAAO;KACzC;IACD,GAlBM,KAkBN;GAEL,CAAC,CACE;;CACF,CAAA;AAET"}
|
|
@@ -13,6 +13,8 @@ interface ProgressBarBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, 'ari
|
|
|
13
13
|
size?: ProgressBarSize;
|
|
14
14
|
/** Semantic color for the completed portion of the bar. */
|
|
15
15
|
color?: ProgressBarColor;
|
|
16
|
+
/** Solid for compact usage meters; gradient for the default visualization. */
|
|
17
|
+
fill?: 'solid' | 'gradient';
|
|
16
18
|
/** Optional fixed-style label rendered above or beneath the bar. */
|
|
17
19
|
label?: string;
|
|
18
20
|
/** Vertical label placement. */
|
|
@@ -20,6 +20,13 @@ var COLOR_GRADIENTS = {
|
|
|
20
20
|
warning: "linear-gradient(to left, var(--viz-orange-150), var(--viz-orange-75))",
|
|
21
21
|
error: "linear-gradient(to left, var(--viz-red-300), var(--viz-red-200))"
|
|
22
22
|
};
|
|
23
|
+
var SOLID_COLORS = {
|
|
24
|
+
brand: "bg-brand",
|
|
25
|
+
neutral: "bg-current text-icon-secondary",
|
|
26
|
+
success: "bg-success-strong",
|
|
27
|
+
warning: "bg-warning-strong",
|
|
28
|
+
error: "bg-error-strong"
|
|
29
|
+
};
|
|
23
30
|
function getFiniteValue(value, fallback) {
|
|
24
31
|
return Number.isFinite(value) ? value : fallback;
|
|
25
32
|
}
|
|
@@ -38,7 +45,7 @@ function clampValue(value, min, max) {
|
|
|
38
45
|
* A single-value determinate horizontal progress indicator for measurable
|
|
39
46
|
* completion or usage. Use `LinearProgress` for indeterminate loading states.
|
|
40
47
|
*/
|
|
41
|
-
var ProgressBar = forwardRef(({ value, min = 0, max = 100, size = "md", color = "brand", label, labelPosition = "bottom", className, ...props }, ref) => {
|
|
48
|
+
var ProgressBar = forwardRef(({ value, min = 0, max = 100, size = "md", color = "brand", fill = "gradient", label, labelPosition = "bottom", className, ...props }, ref) => {
|
|
42
49
|
const range = getNormalizedRange(min, max);
|
|
43
50
|
const clampedValue = clampValue(value, range.min, range.max);
|
|
44
51
|
const progressPercent = (clampedValue - range.min) / (range.max - range.min) * 100;
|
|
@@ -52,10 +59,10 @@ var ProgressBar = forwardRef(({ value, min = 0, max = 100, size = "md", color =
|
|
|
52
59
|
className: cn("relative w-full flex-none overflow-hidden rounded-xs bg-surface-level-3", SIZE_CLASSES[size], className),
|
|
53
60
|
children: /* @__PURE__ */ jsx("div", {
|
|
54
61
|
"aria-hidden": "true",
|
|
55
|
-
className: "h-full rounded-xs transition-[width] duration-normal ease-out motion-reduce:transition-none",
|
|
62
|
+
className: cn("h-full rounded-xs transition-[width] duration-normal ease-out motion-reduce:transition-none", fill === "solid" && SOLID_COLORS[color]),
|
|
56
63
|
style: {
|
|
57
64
|
width: `${progressPercent}%`,
|
|
58
|
-
backgroundImage: COLOR_GRADIENTS[color]
|
|
65
|
+
backgroundImage: fill === "gradient" ? COLOR_GRADIENTS[color] : void 0
|
|
59
66
|
}
|
|
60
67
|
})
|
|
61
68
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","names":[],"sources":["../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { Text } from '../Text';\n\ntype ProgressBarSize = 'sm' | 'md' | 'lg';\ntype ProgressBarColor = 'brand' | 'neutral' | 'success' | 'warning' | 'error';\ntype ProgressBarLabelPosition = 'top' | 'bottom';\n\ninterface ProgressBarBaseProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-valuemax'\n | 'aria-valuemin'\n | 'aria-valuenow'\n | 'children'\n | 'color'\n | 'role'\n> {\n /** Current progress value. */\n value: number;\n /** Minimum progress value. */\n min?: number;\n /** Maximum progress value. */\n max?: number;\n /** Bar height. Use `sm` in dense table layouts. */\n size?: ProgressBarSize;\n /** Semantic color for the completed portion of the bar. */\n color?: ProgressBarColor;\n /** Optional fixed-style label rendered above or beneath the bar. */\n label?: string;\n /** Vertical label placement. */\n labelPosition?: ProgressBarLabelPosition;\n}\n\ninterface ProgressBarWithAriaLabel extends ProgressBarBaseProps {\n /** Accessible name describing what is progressing. */\n 'aria-label': string;\n 'aria-labelledby'?: never;\n}\n\ninterface ProgressBarWithAriaLabelledBy extends ProgressBarBaseProps {\n /** ID of an element that names what is progressing. */\n 'aria-labelledby': string;\n 'aria-label'?: never;\n}\n\ntype ProgressBarProps =\n | ProgressBarWithAriaLabel\n | ProgressBarWithAriaLabelledBy;\n\nconst SIZE_CLASSES: Record<ProgressBarSize, string> = {\n sm: 'h-1',\n md: 'h-2',\n lg: 'h-3',\n};\n\nconst LABEL_VARIANTS: Record<ProgressBarSize, 'xs' | 'sm' | 'md'> = {\n sm: 'xs',\n md: 'sm',\n lg: 'md',\n};\n\nconst COLOR_GRADIENTS: Record<ProgressBarColor, string> = {\n brand: 'linear-gradient(to left, var(--viz-brand-200), var(--viz-brand-75))',\n neutral:\n 'linear-gradient(to left, var(--viz-neutral-150), var(--viz-neutral-75))',\n success:\n 'linear-gradient(to left, var(--viz-green-200), var(--viz-green-100))',\n warning:\n 'linear-gradient(to left, var(--viz-orange-150), var(--viz-orange-75))',\n error: 'linear-gradient(to left, var(--viz-red-300), var(--viz-red-200))',\n};\n\nfunction getFiniteValue(value: number, fallback: number) {\n return Number.isFinite(value) ? value : fallback;\n}\n\nfunction getNormalizedRange(min: number, max: number) {\n const normalizedMin = getFiniteValue(min, 0);\n const normalizedMax = getFiniteValue(max, normalizedMin + 100);\n\n return {\n min: normalizedMin,\n max: normalizedMax > normalizedMin ? normalizedMax : normalizedMin + 100,\n };\n}\n\nfunction clampValue(value: number, min: number, max: number) {\n return Math.min(Math.max(getFiniteValue(value, min), min), max);\n}\n\n/**\n * A single-value determinate horizontal progress indicator for measurable\n * completion or usage. Use `LinearProgress` for indeterminate loading states.\n */\nconst ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(\n (\n {\n value,\n min = 0,\n max = 100,\n size = 'md',\n color = 'brand',\n label,\n labelPosition = 'bottom',\n className,\n ...props\n },\n ref\n ) => {\n const range = getNormalizedRange(min, max);\n const clampedValue = clampValue(value, range.min, range.max);\n const progressPercent =\n ((clampedValue - range.min) / (range.max - range.min)) * 100;\n\n const progressBar = (\n <div\n {...props}\n ref={ref}\n role=\"progressbar\"\n aria-valuemin={range.min}\n aria-valuemax={range.max}\n aria-valuenow={clampedValue}\n className={cn(\n 'relative w-full flex-none overflow-hidden rounded-xs bg-surface-level-3',\n SIZE_CLASSES[size],\n className\n )}\n >\n <div\n aria-hidden=\"true\"\n className
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","names":[],"sources":["../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { Text } from '../Text';\n\ntype ProgressBarSize = 'sm' | 'md' | 'lg';\ntype ProgressBarColor = 'brand' | 'neutral' | 'success' | 'warning' | 'error';\ntype ProgressBarLabelPosition = 'top' | 'bottom';\n\ninterface ProgressBarBaseProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-valuemax'\n | 'aria-valuemin'\n | 'aria-valuenow'\n | 'children'\n | 'color'\n | 'role'\n> {\n /** Current progress value. */\n value: number;\n /** Minimum progress value. */\n min?: number;\n /** Maximum progress value. */\n max?: number;\n /** Bar height. Use `sm` in dense table layouts. */\n size?: ProgressBarSize;\n /** Semantic color for the completed portion of the bar. */\n color?: ProgressBarColor;\n /** Solid for compact usage meters; gradient for the default visualization. */\n fill?: 'solid' | 'gradient';\n /** Optional fixed-style label rendered above or beneath the bar. */\n label?: string;\n /** Vertical label placement. */\n labelPosition?: ProgressBarLabelPosition;\n}\n\ninterface ProgressBarWithAriaLabel extends ProgressBarBaseProps {\n /** Accessible name describing what is progressing. */\n 'aria-label': string;\n 'aria-labelledby'?: never;\n}\n\ninterface ProgressBarWithAriaLabelledBy extends ProgressBarBaseProps {\n /** ID of an element that names what is progressing. */\n 'aria-labelledby': string;\n 'aria-label'?: never;\n}\n\ntype ProgressBarProps =\n | ProgressBarWithAriaLabel\n | ProgressBarWithAriaLabelledBy;\n\nconst SIZE_CLASSES: Record<ProgressBarSize, string> = {\n sm: 'h-1',\n md: 'h-2',\n lg: 'h-3',\n};\n\nconst LABEL_VARIANTS: Record<ProgressBarSize, 'xs' | 'sm' | 'md'> = {\n sm: 'xs',\n md: 'sm',\n lg: 'md',\n};\n\nconst COLOR_GRADIENTS: Record<ProgressBarColor, string> = {\n brand: 'linear-gradient(to left, var(--viz-brand-200), var(--viz-brand-75))',\n neutral:\n 'linear-gradient(to left, var(--viz-neutral-150), var(--viz-neutral-75))',\n success:\n 'linear-gradient(to left, var(--viz-green-200), var(--viz-green-100))',\n warning:\n 'linear-gradient(to left, var(--viz-orange-150), var(--viz-orange-75))',\n error: 'linear-gradient(to left, var(--viz-red-300), var(--viz-red-200))',\n};\n\nconst SOLID_COLORS: Record<ProgressBarColor, string> = {\n brand: 'bg-brand',\n neutral: 'bg-current text-icon-secondary',\n success: 'bg-success-strong',\n warning: 'bg-warning-strong',\n error: 'bg-error-strong',\n};\n\nfunction getFiniteValue(value: number, fallback: number) {\n return Number.isFinite(value) ? value : fallback;\n}\n\nfunction getNormalizedRange(min: number, max: number) {\n const normalizedMin = getFiniteValue(min, 0);\n const normalizedMax = getFiniteValue(max, normalizedMin + 100);\n\n return {\n min: normalizedMin,\n max: normalizedMax > normalizedMin ? normalizedMax : normalizedMin + 100,\n };\n}\n\nfunction clampValue(value: number, min: number, max: number) {\n return Math.min(Math.max(getFiniteValue(value, min), min), max);\n}\n\n/**\n * A single-value determinate horizontal progress indicator for measurable\n * completion or usage. Use `LinearProgress` for indeterminate loading states.\n */\nconst ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(\n (\n {\n value,\n min = 0,\n max = 100,\n size = 'md',\n color = 'brand',\n fill = 'gradient',\n label,\n labelPosition = 'bottom',\n className,\n ...props\n },\n ref\n ) => {\n const range = getNormalizedRange(min, max);\n const clampedValue = clampValue(value, range.min, range.max);\n const progressPercent =\n ((clampedValue - range.min) / (range.max - range.min)) * 100;\n\n const progressBar = (\n <div\n {...props}\n ref={ref}\n role=\"progressbar\"\n aria-valuemin={range.min}\n aria-valuemax={range.max}\n aria-valuenow={clampedValue}\n className={cn(\n 'relative w-full flex-none overflow-hidden rounded-xs bg-surface-level-3',\n SIZE_CLASSES[size],\n className\n )}\n >\n <div\n aria-hidden=\"true\"\n className={cn(\n 'h-full rounded-xs transition-[width] duration-normal ease-out motion-reduce:transition-none',\n fill === 'solid' && SOLID_COLORS[color]\n )}\n style={{\n width: `${progressPercent}%`,\n backgroundImage:\n fill === 'gradient' ? COLOR_GRADIENTS[color] : undefined,\n }}\n />\n </div>\n );\n\n if (label === undefined) return progressBar;\n\n const progressLabel = (\n <Text as=\"span\" variant={LABEL_VARIANTS[size]} color=\"tertiary\">\n {label}\n </Text>\n );\n\n return (\n <div className=\"flex w-full flex-col gap-space-1\">\n {labelPosition === 'top' && progressLabel}\n {progressBar}\n {labelPosition === 'bottom' && progressLabel}\n </div>\n );\n }\n);\n\nProgressBar.displayName = 'ProgressBar';\n\nexport { ProgressBar };\nexport type {\n ProgressBarColor,\n ProgressBarLabelPosition,\n ProgressBarProps,\n ProgressBarSize,\n};\n"],"mappings":";;;;;AAsDA,IAAM,eAAgD;CACpD,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,iBAA8D;CAClE,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,kBAAoD;CACxD,OAAO;CACP,SACE;CACF,SACE;CACF,SACE;CACF,OAAO;AACT;AAEA,IAAM,eAAiD;CACrD,OAAO;CACP,SAAS;CACT,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,SAAS,eAAe,OAAe,UAAkB;CACvD,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;AAEA,SAAS,mBAAmB,KAAa,KAAa;CACpD,MAAM,gBAAgB,eAAe,KAAK,CAAC;CAC3C,MAAM,gBAAgB,eAAe,KAAK,gBAAgB,GAAG;CAE7D,OAAO;EACL,KAAK;EACL,KAAK,gBAAgB,gBAAgB,gBAAgB,gBAAgB;CACvE;AACF;AAEA,SAAS,WAAW,OAAe,KAAa,KAAa;CAC3D,OAAO,KAAK,IAAI,KAAK,IAAI,eAAe,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG;AAChE;;;;;AAMA,IAAM,cAAc,YAEhB,EACE,OACA,MAAM,GACN,MAAM,KACN,OAAO,MACP,QAAQ,SACR,OAAO,YACP,OACA,gBAAgB,UAChB,WACA,GAAG,SAEL,QACG;CACH,MAAM,QAAQ,mBAAmB,KAAK,GAAG;CACzC,MAAM,eAAe,WAAW,OAAO,MAAM,KAAK,MAAM,GAAG;CAC3D,MAAM,mBACF,eAAe,MAAM,QAAQ,MAAM,MAAM,MAAM,OAAQ;CAE3D,MAAM,cACJ,oBAAC,OAAD;EACE,GAAI;EACC;EACL,MAAK;EACL,iBAAe,MAAM;EACrB,iBAAe,MAAM;EACrB,iBAAe;EACf,WAAW,GACT,2EACA,aAAa,OACb,SACF;EAEA,UAAA,oBAAC,OAAD;GACE,eAAY;GACZ,WAAW,GACT,+FACA,SAAS,WAAW,aAAa,MACnC;GACA,OAAO;IACL,OAAO,GAAG,gBAAgB;IAC1B,iBACE,SAAS,aAAa,gBAAgB,SAAS,KAAA;GACnD;EACD,CAAA;CACE,CAAA;CAGP,IAAI,UAAU,KAAA,GAAW,OAAO;CAEhC,MAAM,gBACJ,oBAAC,MAAD;EAAM,IAAG;EAAO,SAAS,eAAe;EAAO,OAAM;EAClD,UAAA;CACG,CAAA;CAGR,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACG,kBAAkB,SAAS;GAC3B;GACA,kBAAkB,YAAY;EAC5B;;AAET,CACF;AAEA,YAAY,cAAc"}
|
package/dist/components/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { Textarea } from "./Textarea/Textarea.js";
|
|
|
24
24
|
import { ChatComposerTextarea } from "./ChatComposer/ChatComposerTextarea.js";
|
|
25
25
|
import { ChatComposerInput } from "./ChatComposer/ChatComposerInput.js";
|
|
26
26
|
import { ChatComposerModelSelect } from "./ChatComposer/ChatComposerModelSelect.js";
|
|
27
|
+
import { ProgressBar } from "./ProgressBar/ProgressBar.js";
|
|
27
28
|
import { ChatConversation } from "./ChatConversation/ChatConversation.js";
|
|
28
29
|
import { Divider } from "./Divider/Divider.js";
|
|
29
30
|
import { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider } from "./ChatMessage/ChatMessage.js";
|
|
@@ -45,7 +46,6 @@ import { Kbd, KbdGroup } from "./Kbd/Kbd.js";
|
|
|
45
46
|
import { LinearProgress } from "./LinearProgress/LinearProgress.js";
|
|
46
47
|
import { MetricChart } from "./MetricChart/MetricChart.js";
|
|
47
48
|
import { formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime } from "./MetricChart/formatters.js";
|
|
48
|
-
import { ProgressBar } from "./ProgressBar/ProgressBar.js";
|
|
49
49
|
import { RadioCard } from "./RadioCard/RadioCard.js";
|
|
50
50
|
import { Slider } from "./Slider/Slider.js";
|
|
51
51
|
import { StatusBadge } from "./StatusBadge/StatusBadge.js";
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { Textarea } from "./components/Textarea/Textarea.js";
|
|
|
24
24
|
import { ChatComposerTextarea } from "./components/ChatComposer/ChatComposerTextarea.js";
|
|
25
25
|
import { ChatComposerInput } from "./components/ChatComposer/ChatComposerInput.js";
|
|
26
26
|
import { ChatComposerModelSelect } from "./components/ChatComposer/ChatComposerModelSelect.js";
|
|
27
|
+
import { ProgressBar } from "./components/ProgressBar/ProgressBar.js";
|
|
27
28
|
import { ChatConversation } from "./components/ChatConversation/ChatConversation.js";
|
|
28
29
|
import { Divider } from "./components/Divider/Divider.js";
|
|
29
30
|
import { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider } from "./components/ChatMessage/ChatMessage.js";
|
|
@@ -45,7 +46,6 @@ import { Kbd, KbdGroup } from "./components/Kbd/Kbd.js";
|
|
|
45
46
|
import { LinearProgress } from "./components/LinearProgress/LinearProgress.js";
|
|
46
47
|
import { MetricChart } from "./components/MetricChart/MetricChart.js";
|
|
47
48
|
import { formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime } from "./components/MetricChart/formatters.js";
|
|
48
|
-
import { ProgressBar } from "./components/ProgressBar/ProgressBar.js";
|
|
49
49
|
import { RadioCard } from "./components/RadioCard/RadioCard.js";
|
|
50
50
|
import { Slider } from "./components/Slider/Slider.js";
|
|
51
51
|
import { StatusBadge } from "./components/StatusBadge/StatusBadge.js";
|