@langchain/macaw-components 1.5.0 → 1.5.2

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.
Files changed (91) hide show
  1. package/dist/catalog.json +826 -556
  2. package/dist/components/ChatComposer/ChatComposer.d.ts +31 -0
  3. package/dist/components/ChatComposer/ChatComposer.js +142 -0
  4. package/dist/components/ChatComposer/ChatComposer.js.map +1 -0
  5. package/dist/components/ChatComposer/ChatComposerAttachments.d.ts +17 -0
  6. package/dist/components/ChatComposer/ChatComposerAttachments.js +117 -0
  7. package/dist/components/ChatComposer/ChatComposerAttachments.js.map +1 -0
  8. package/dist/components/ChatComposer/ChatComposerCodeBlock.d.ts +2 -0
  9. package/dist/components/ChatComposer/ChatComposerCodeBlock.js +100 -0
  10. package/dist/components/ChatComposer/ChatComposerCodeBlock.js.map +1 -0
  11. package/dist/components/ChatComposer/ChatComposerCodeBlockAdapter.d.ts +19 -0
  12. package/dist/components/ChatComposer/ChatComposerCodeBlockAdapter.js +107 -0
  13. package/dist/components/ChatComposer/ChatComposerCodeBlockAdapter.js.map +1 -0
  14. package/dist/components/ChatComposer/ChatComposerCodeBlockView.d.ts +5 -0
  15. package/dist/components/ChatComposer/ChatComposerCodeBlockView.js +104 -0
  16. package/dist/components/ChatComposer/ChatComposerCodeBlockView.js.map +1 -0
  17. package/dist/components/ChatComposer/ChatComposerContext.d.ts +15 -0
  18. package/dist/components/ChatComposer/ChatComposerContext.js +16 -0
  19. package/dist/components/ChatComposer/ChatComposerContext.js.map +1 -0
  20. package/dist/components/ChatComposer/ChatComposerInput.d.ts +19 -0
  21. package/dist/components/ChatComposer/ChatComposerInput.js +38 -0
  22. package/dist/components/ChatComposer/ChatComposerInput.js.map +1 -0
  23. package/dist/components/ChatComposer/ChatComposerModelSelect.d.ts +3 -0
  24. package/dist/components/ChatComposer/ChatComposerModelSelect.js +56 -0
  25. package/dist/components/ChatComposer/ChatComposerModelSelect.js.map +1 -0
  26. package/dist/components/ChatComposer/ChatComposerPlainInput.d.ts +8 -0
  27. package/dist/components/ChatComposer/ChatComposerPlainInput.js +48 -0
  28. package/dist/components/ChatComposer/ChatComposerPlainInput.js.map +1 -0
  29. package/dist/components/ChatComposer/ChatComposerRichInput.d.ts +7 -0
  30. package/dist/components/ChatComposer/ChatComposerRichInput.js +53 -0
  31. package/dist/components/ChatComposer/ChatComposerRichInput.js.map +1 -0
  32. package/dist/components/ChatComposer/index.d.ts +10 -0
  33. package/dist/components/ChatComposer/index.js +6 -0
  34. package/dist/components/ChatComposer/useChatComposerEditor.d.ts +21 -0
  35. package/dist/components/ChatComposer/useChatComposerEditor.js +113 -0
  36. package/dist/components/ChatComposer/useChatComposerEditor.js.map +1 -0
  37. package/dist/components/ChatMessage/ChatMessage.js +1 -1
  38. package/dist/components/ChatState/ChatState.d.ts +16 -0
  39. package/dist/components/ChatState/ChatState.js +96 -0
  40. package/dist/components/ChatState/ChatState.js.map +1 -0
  41. package/dist/components/ChatState/ChatStateTimer.d.ts +11 -0
  42. package/dist/components/ChatState/ChatStateTimer.js +57 -0
  43. package/dist/components/ChatState/ChatStateTimer.js.map +1 -0
  44. package/dist/components/ChatState/index.d.ts +2 -0
  45. package/dist/components/ChatState/index.js +2 -0
  46. package/dist/components/ChatToolCall/ChatToolCall.d.ts +23 -0
  47. package/dist/components/ChatToolCall/ChatToolCall.js +98 -0
  48. package/dist/components/ChatToolCall/ChatToolCall.js.map +1 -0
  49. package/dist/components/ChatToolCall/ChatToolCall.types.d.ts +10 -0
  50. package/dist/components/ChatToolCall/ChatToolCall.types.js +0 -0
  51. package/dist/components/ChatToolCall/ChatToolCall.value.d.ts +2 -0
  52. package/dist/components/ChatToolCall/ChatToolCall.value.js +82 -0
  53. package/dist/components/ChatToolCall/ChatToolCall.value.js.map +1 -0
  54. package/dist/components/ChatToolCall/ChatToolCallAccordion.d.ts +17 -0
  55. package/dist/components/ChatToolCall/ChatToolCallAccordion.js +56 -0
  56. package/dist/components/ChatToolCall/ChatToolCallAccordion.js.map +1 -0
  57. package/dist/components/ChatToolCall/ChatToolCallDetails.d.ts +4 -0
  58. package/dist/components/ChatToolCall/ChatToolCallDetails.js +66 -0
  59. package/dist/components/ChatToolCall/ChatToolCallDetails.js.map +1 -0
  60. package/dist/components/ChatToolCall/ChatToolCallGroup.d.ts +11 -0
  61. package/dist/components/ChatToolCall/ChatToolCallGroup.js +63 -0
  62. package/dist/components/ChatToolCall/ChatToolCallGroup.js.map +1 -0
  63. package/dist/components/ChatToolCall/ChatToolCallReasoning.d.ts +18 -0
  64. package/dist/components/ChatToolCall/ChatToolCallReasoning.js +45 -0
  65. package/dist/components/ChatToolCall/ChatToolCallReasoning.js.map +1 -0
  66. package/dist/components/ChatToolCall/ChatToolCallStatusRow.d.ts +11 -0
  67. package/dist/components/ChatToolCall/ChatToolCallStatusRow.js +36 -0
  68. package/dist/components/ChatToolCall/ChatToolCallStatusRow.js.map +1 -0
  69. package/dist/components/ChatToolCall/index.d.ts +7 -0
  70. package/dist/components/ChatToolCall/index.js +4 -0
  71. package/dist/components/Code/CodeLite.js +1 -1
  72. package/dist/components/Code/index.js +7 -8
  73. package/dist/components/Code/index.js.map +1 -1
  74. package/dist/components/Input/Input.js +1 -1
  75. package/dist/components/Select/Select.d.ts +5 -0
  76. package/dist/components/Select/Select.js +2 -1
  77. package/dist/components/Select/Select.js.map +1 -1
  78. package/dist/components/TextWithLinks.js +1 -1
  79. package/dist/components/index.d.ts +2 -0
  80. package/dist/components/index.js +7 -2
  81. package/dist/components.css +2 -0
  82. package/dist/icons/LongTailPhosphorIcons.js +1 -1
  83. package/dist/icons/WeightedPhosphorIcons.js +1 -1
  84. package/dist/index.js +7 -2
  85. package/dist/utilities.css +1 -1
  86. package/dist/utils/componentUtils.d.ts +2 -0
  87. package/dist/utils/componentUtils.js +8 -0
  88. package/dist/utils/componentUtils.js.map +1 -0
  89. package/docs/CHAT.md +31 -0
  90. package/docs/DESIGN.md +44 -0
  91. package/package.json +29 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatToolCallDetails.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallDetails.tsx"],"sourcesContent":["import { CodeLite } from '../Code/CodeLite';\nimport { Text } from '../Text';\nimport type { ChatToolCallModel } from './ChatToolCall.types';\nimport { formatChatToolCallValue } from './ChatToolCall.value';\n\nfunction DetailsValue({ value }: { value: unknown }) {\n const preview = formatChatToolCallValue(value);\n\n if (typeof value === 'string') {\n return (\n <Text\n variant=\"xs\"\n color=\"tertiary\"\n className=\"max-h-60 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere]\"\n >\n {preview}\n </Text>\n );\n }\n\n return (\n <div className=\"max-h-60 max-w-full overflow-auto rounded-md bg-surface-level-2 p-space-2 [overflow-wrap:anywhere]\">\n <CodeLite\n value={preview}\n language=\"json\"\n className=\"text-xxs\"\n showGutter={false}\n wrapLines\n />\n </div>\n );\n}\n\nfunction DetailsSection({\n label,\n value,\n emptyLabel,\n}: {\n label: string;\n value: unknown;\n emptyLabel: string;\n}) {\n return (\n <section aria-label={label} className=\"flex min-w-0 flex-col gap-space-2\">\n <Text variant=\"xs\" weight=\"medium\" color=\"quaternary\">\n {label}\n </Text>\n {value === undefined ? (\n <Text variant=\"xs\" color=\"tertiary\">\n {emptyLabel}\n </Text>\n ) : (\n <DetailsValue value={value} />\n )}\n </section>\n );\n}\n\nexport function ChatToolCallDetails({\n toolCall,\n}: {\n toolCall: ChatToolCallModel;\n}) {\n return (\n <div className=\"flex min-w-0 flex-col gap-space-3\">\n <DetailsSection\n label=\"Request\"\n value={toolCall.args}\n emptyLabel=\"No arguments\"\n />\n <DetailsSection\n label=\"Response\"\n value={toolCall.result}\n emptyLabel={\n toolCall.status === 'pending' || toolCall.status === 'running'\n ? 'Awaiting response'\n : 'No response provided'\n }\n />\n {toolCall.error !== undefined && (\n <DetailsSection\n label=\"Error\"\n value={toolCall.error}\n emptyLabel=\"No error details\"\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AAKA,SAAS,aAAa,EAAE,SAA6B;CACnD,MAAM,UAAU,wBAAwB,KAAK;CAE7C,IAAI,OAAO,UAAU,UACnB,OACE,oBAAC,MAAD;EACE,SAAQ;EACR,OAAM;EACN,WAAU;EAET,UAAA;CACG,CAAA;CAIV,OACE,oBAAC,OAAD;EAAK,WAAU;EACb,UAAA,oBAAC,UAAD;GACE,OAAO;GACP,UAAS;GACT,WAAU;GACV,YAAY;GACZ,WAAA;EACD,CAAA;CACE,CAAA;AAET;AAEA,SAAS,eAAe,EACtB,OACA,OACA,cAKC;CACD,OACE,qBAAC,WAAD;EAAS,cAAY;EAAO,WAAU;EAAtC,UAAA,CACE,oBAAC,MAAD;GAAM,SAAQ;GAAK,QAAO;GAAS,OAAM;GACtC,UAAA;EACG,CAAA,GACL,UAAU,KAAA,IACT,oBAAC,MAAD;GAAM,SAAQ;GAAK,OAAM;GACtB,UAAA;EACG,CAAA,IAEN,oBAAC,cAAD,EAAqB,MAAQ,CAAA,CAExB;;AAEb;AAEA,SAAgB,oBAAoB,EAClC,YAGC;CACD,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACE,oBAAC,gBAAD;IACE,OAAM;IACN,OAAO,SAAS;IAChB,YAAW;GACZ,CAAA;GACD,oBAAC,gBAAD;IACE,OAAM;IACN,OAAO,SAAS;IAChB,YACE,SAAS,WAAW,aAAa,SAAS,WAAW,YACjD,sBACA;GAEP,CAAA;GACA,SAAS,UAAU,KAAA,KAClB,oBAAC,gBAAD;IACE,OAAM;IACN,OAAO,SAAS;IAChB,YAAW;GACZ,CAAA;EAEA;;AAET"}
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface ChatToolCallGroupProps {
3
+ /** Hosts supply the count/summary and group only consecutive content. */
4
+ label: string;
5
+ children: ReactNode;
6
+ expanded?: boolean;
7
+ defaultExpanded?: boolean;
8
+ onExpandedChange?: (expanded: boolean) => void;
9
+ className?: string;
10
+ }
11
+ export declare function ChatToolCallGroup({ label, children, expanded, defaultExpanded, onExpandedChange, className, }: ChatToolCallGroupProps): import("react").JSX.Element;
@@ -0,0 +1,63 @@
1
+ import { cn } from "../../utils/cn.js";
2
+ import { Text } from "../Text/Text.js";
3
+ import { Button } from "../Button/Button.js";
4
+ import { useId } from "react";
5
+ import { CaretRightIcon } from "@phosphor-icons/react/dist/ssr/CaretRight";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
8
+ import { WrenchIcon } from "@phosphor-icons/react/dist/ssr/Wrench";
9
+ //#region packages/components/src/components/ChatToolCall/ChatToolCallGroup.tsx
10
+ function ChatToolCallGroup({ label, children, expanded, defaultExpanded = false, onExpandedChange, className }) {
11
+ const contentId = useId();
12
+ const [isExpanded = false, setExpanded] = useControllableState({
13
+ prop: expanded,
14
+ defaultProp: defaultExpanded,
15
+ onChange: onExpandedChange
16
+ });
17
+ return /* @__PURE__ */ jsxs("div", {
18
+ className: cn("min-w-0 max-w-full font-sans text-xxs", className),
19
+ children: [/* @__PURE__ */ jsxs(Button, {
20
+ type: "button",
21
+ variant: "plain",
22
+ color: "secondary",
23
+ size: "sm",
24
+ "aria-label": label,
25
+ "aria-controls": contentId,
26
+ "aria-expanded": isExpanded,
27
+ onClick: () => setExpanded(!isExpanded),
28
+ className: "h-auto max-w-full justify-start gap-space-2 bg-transparent px-0 py-space-1 text-left shadow-none hover:bg-transparent",
29
+ children: [
30
+ /* @__PURE__ */ jsx(CaretRightIcon, {
31
+ size: 12,
32
+ weight: "regular",
33
+ "aria-hidden": "true",
34
+ className: cn("shrink-0 text-icon-tertiary transition-transform duration-normal motion-reduce:transition-none", isExpanded && "rotate-90")
35
+ }),
36
+ /* @__PURE__ */ jsx(WrenchIcon, {
37
+ size: 16,
38
+ weight: "regular",
39
+ "aria-hidden": "true",
40
+ className: "shrink-0 text-icon-tertiary"
41
+ }),
42
+ /* @__PURE__ */ jsx(Text, {
43
+ as: "span",
44
+ variant: "xs",
45
+ color: "tertiary",
46
+ className: "min-w-0 truncate",
47
+ children: label
48
+ })
49
+ ]
50
+ }), /* @__PURE__ */ jsx("div", {
51
+ id: contentId,
52
+ hidden: !isExpanded,
53
+ children: /* @__PURE__ */ jsx("div", {
54
+ className: "flex min-w-0 flex-col gap-0 pl-space-5",
55
+ children
56
+ })
57
+ })]
58
+ });
59
+ }
60
+ //#endregion
61
+ export { ChatToolCallGroup };
62
+
63
+ //# sourceMappingURL=ChatToolCallGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatToolCallGroup.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallGroup.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { CaretRightIcon } from '@phosphor-icons/react/dist/ssr/CaretRight';\nimport { WrenchIcon } from '@phosphor-icons/react/dist/ssr/Wrench';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Text } from '../Text';\n\nexport interface ChatToolCallGroupProps {\n /** Hosts supply the count/summary and group only consecutive content. */\n label: string;\n children: ReactNode;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n className?: string;\n}\n\nexport function ChatToolCallGroup({\n label,\n children,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\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\n return (\n <div className={cn('min-w-0 max-w-full font-sans text-xxs', className)}>\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 className=\"h-auto max-w-full justify-start gap-space-2 bg-transparent px-0 py-space-1 text-left shadow-none hover:bg-transparent\"\n >\n <CaretRightIcon\n size={12}\n weight=\"regular\"\n aria-hidden=\"true\"\n className={cn(\n 'shrink-0 text-icon-tertiary transition-transform duration-normal motion-reduce:transition-none',\n isExpanded && 'rotate-90'\n )}\n />\n <WrenchIcon\n size={16}\n weight=\"regular\"\n aria-hidden=\"true\"\n className=\"shrink-0 text-icon-tertiary\"\n />\n <Text\n as=\"span\"\n variant=\"xs\"\n color=\"tertiary\"\n className=\"min-w-0 truncate\"\n >\n {label}\n </Text>\n </Button>\n <div id={contentId} hidden={!isExpanded}>\n <div className=\"flex min-w-0 flex-col gap-0 pl-space-5\">{children}</div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAgB,kBAAkB,EAChC,OACA,UACA,UACA,kBAAkB,OAClB,kBACA,aACyB;CACzB,MAAM,YAAY,MAAM;CACxB,MAAM,CAAC,aAAa,OAAO,eAAe,qBAAqB;EAC7D,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;CAED,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,yCAAyC,SAAS;EAArE,UAAA,CACE,qBAAC,QAAD;GACE,MAAK;GACL,SAAQ;GACR,OAAM;GACN,MAAK;GACL,cAAY;GACZ,iBAAe;GACf,iBAAe;GACf,eAAe,YAAY,CAAC,UAAU;GACtC,WAAU;GATZ,UAAA;IAWE,oBAAC,gBAAD;KACE,MAAM;KACN,QAAO;KACP,eAAY;KACZ,WAAW,GACT,kGACA,cAAc,WAChB;IACD,CAAA;IACD,oBAAC,YAAD;KACE,MAAM;KACN,QAAO;KACP,eAAY;KACZ,WAAU;IACX,CAAA;IACD,oBAAC,MAAD;KACE,IAAG;KACH,SAAQ;KACR,OAAM;KACN,WAAU;KAET,UAAA;IACG,CAAA;GACA;EACR,CAAA,GAAA,oBAAC,OAAD;GAAK,IAAI;GAAW,QAAQ,CAAC;GAC3B,UAAA,oBAAC,OAAD;IAAK,WAAU;IAA0C;GAAc,CAAA;EACpE,CAAA,CACF;;AAET"}
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type ChatStateStatus } from '../ChatState/index.js';
3
+ export interface ChatToolCallReasoningProps {
4
+ /** Only content intentionally disclosed by the host; never raw hidden model reasoning. */
5
+ children: ReactNode;
6
+ variant?: 'default' | 'simple';
7
+ /** Simple row inspection; the host owns navigation, panes, and permissions. */
8
+ onInspect?: () => void;
9
+ /** Tooltip and accessible action label for Simple row inspection. */
10
+ inspectLabel?: string;
11
+ label?: string;
12
+ status?: ChatStateStatus;
13
+ elapsedMs?: number;
14
+ expanded?: boolean;
15
+ defaultExpanded?: boolean;
16
+ onExpandedChange?: (expanded: boolean) => void;
17
+ }
18
+ export declare function ChatToolCallReasoning({ children, variant, onInspect, inspectLabel, label, status, elapsedMs, expanded, defaultExpanded, onExpandedChange, }: ChatToolCallReasoningProps): import("react").JSX.Element;
@@ -0,0 +1,45 @@
1
+ import { Text } from "../Text/Text.js";
2
+ import { ChatState } from "../ChatState/ChatState.js";
3
+ import { ChatToolCallAccordion } from "./ChatToolCallAccordion.js";
4
+ import { ChatToolCallStatusRow } from "./ChatToolCallStatusRow.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region packages/components/src/components/ChatToolCall/ChatToolCallReasoning.tsx
7
+ function ChatToolCallReasoning({ children, variant = "default", onInspect, inspectLabel, label = "Reasoning summary", status = "completed", elapsedMs, expanded, defaultExpanded = false, onExpandedChange }) {
8
+ const heading = /* @__PURE__ */ jsx(Text, {
9
+ as: "span",
10
+ variant: "xs",
11
+ weight: "medium",
12
+ color: "secondary",
13
+ className: "min-w-0 truncate",
14
+ children: label
15
+ });
16
+ const state = /* @__PURE__ */ jsx(ChatState, {
17
+ variant: "simple",
18
+ status,
19
+ showElapsed: status === "streaming",
20
+ elapsedMs
21
+ });
22
+ if (variant === "simple") return /* @__PURE__ */ jsx(ChatToolCallStatusRow, {
23
+ groupLabel: label,
24
+ heading,
25
+ status: state,
26
+ onInspect,
27
+ inspectLabel
28
+ });
29
+ return /* @__PURE__ */ jsx(ChatToolCallAccordion, {
30
+ groupLabel: label,
31
+ triggerLabel: label,
32
+ detailsLabel: `${label} details`,
33
+ heading,
34
+ status: state,
35
+ expanded,
36
+ defaultExpanded,
37
+ onExpandedChange,
38
+ detailsClassName: "break-words border-l-0 text-tertiary [overflow-wrap:anywhere]",
39
+ children
40
+ });
41
+ }
42
+ //#endregion
43
+ export { ChatToolCallReasoning };
44
+
45
+ //# sourceMappingURL=ChatToolCallReasoning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatToolCallReasoning.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallReasoning.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { ChatState, type ChatStateStatus } from '../ChatState';\nimport { Text } from '../Text';\nimport { ChatToolCallAccordion } from './ChatToolCallAccordion';\nimport { ChatToolCallStatusRow } from './ChatToolCallStatusRow';\n\nexport interface ChatToolCallReasoningProps {\n /** Only content intentionally disclosed by the host; never raw hidden model reasoning. */\n children: ReactNode;\n variant?: 'default' | 'simple';\n /** Simple row inspection; the host owns navigation, panes, and permissions. */\n onInspect?: () => void;\n /** Tooltip and accessible action label for Simple row inspection. */\n inspectLabel?: string;\n label?: string;\n status?: ChatStateStatus;\n elapsedMs?: number;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}\n\nexport function ChatToolCallReasoning({\n children,\n variant = 'default',\n onInspect,\n inspectLabel,\n label = 'Reasoning summary',\n status = 'completed',\n elapsedMs,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n}: ChatToolCallReasoningProps) {\n const heading = (\n <Text\n as=\"span\"\n variant=\"xs\"\n weight=\"medium\"\n color=\"secondary\"\n className=\"min-w-0 truncate\"\n >\n {label}\n </Text>\n );\n const state = (\n <ChatState\n variant=\"simple\"\n status={status}\n showElapsed={status === 'streaming'}\n elapsedMs={elapsedMs}\n />\n );\n\n if (variant === 'simple') {\n return (\n <ChatToolCallStatusRow\n groupLabel={label}\n heading={heading}\n status={state}\n onInspect={onInspect}\n inspectLabel={inspectLabel}\n />\n );\n }\n\n return (\n <ChatToolCallAccordion\n groupLabel={label}\n triggerLabel={label}\n detailsLabel={`${label} details`}\n heading={heading}\n status={state}\n expanded={expanded}\n defaultExpanded={defaultExpanded}\n onExpandedChange={onExpandedChange}\n detailsClassName=\"break-words border-l-0 text-tertiary [overflow-wrap:anywhere]\"\n >\n {children}\n </ChatToolCallAccordion>\n );\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,sBAAsB,EACpC,UACA,UAAU,WACV,WACA,cACA,QAAQ,qBACR,SAAS,aACT,WACA,UACA,kBAAkB,OAClB,oBAC6B;CAC7B,MAAM,UACJ,oBAAC,MAAD;EACE,IAAG;EACH,SAAQ;EACR,QAAO;EACP,OAAM;EACN,WAAU;EAET,UAAA;CACG,CAAA;CAER,MAAM,QACJ,oBAAC,WAAD;EACE,SAAQ;EACA;EACR,aAAa,WAAW;EACb;CACZ,CAAA;CAGH,IAAI,YAAY,UACd,OACE,oBAAC,uBAAD;EACE,YAAY;EACH;EACT,QAAQ;EACG;EACG;CACf,CAAA;CAIL,OACE,oBAAC,uBAAD;EACE,YAAY;EACZ,cAAc;EACd,cAAc,GAAG,MAAM;EACd;EACT,QAAQ;EACE;EACO;EACC;EAClB,kBAAiB;EAEhB;CACoB,CAAA;AAE3B"}
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ interface ChatToolCallStatusRowProps {
3
+ heading: ReactNode;
4
+ status: ReactNode;
5
+ groupLabel: string;
6
+ onInspect?: () => void;
7
+ inspectLabel?: string;
8
+ className?: string;
9
+ }
10
+ export declare function ChatToolCallStatusRow({ heading, status, groupLabel, onInspect, inspectLabel, className, }: ChatToolCallStatusRowProps): import("react").JSX.Element;
11
+ export {};
@@ -0,0 +1,36 @@
1
+ import { cn } from "../../utils/cn.js";
2
+ import { Tooltip } from "../Tooltip/Tooltip.js";
3
+ import { Button } from "../Button/Button.js";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ //#region packages/components/src/components/ChatToolCall/ChatToolCallStatusRow.tsx
6
+ function ChatToolCallStatusRow({ heading, status, groupLabel, onInspect, inspectLabel = "View tool details", className }) {
7
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
8
+ className: "flex min-w-0 flex-1 items-center gap-space-2 py-space-1",
9
+ children: heading
10
+ }), status] });
11
+ return /* @__PURE__ */ jsx("div", {
12
+ role: "group",
13
+ "aria-label": groupLabel,
14
+ className: cn("min-w-0 max-w-full font-sans text-xxs text-secondary", className),
15
+ children: onInspect ? /* @__PURE__ */ jsx(Tooltip, {
16
+ title: inspectLabel,
17
+ children: /* @__PURE__ */ jsx(Button, {
18
+ type: "button",
19
+ size: "xs",
20
+ variant: "plain",
21
+ color: "secondary",
22
+ "aria-label": `${groupLabel}: ${inspectLabel}`,
23
+ onClick: onInspect,
24
+ className: "focus-visible:ring-focus flex h-auto w-full flex-wrap items-center gap-space-1 rounded-md border-0 px-space-1 py-0 text-left transition-colors duration-fast hover:bg-surface-level-2 focus-visible:outline-hidden focus-visible:ring-2 motion-reduce:transition-none dark:hover:bg-surface-level-2",
25
+ children: content
26
+ })
27
+ }) : /* @__PURE__ */ jsx("div", {
28
+ className: "flex flex-wrap items-center gap-space-1 rounded-md px-space-1 transition-colors duration-fast hover:bg-surface-level-2 motion-reduce:transition-none",
29
+ children: content
30
+ })
31
+ });
32
+ }
33
+ //#endregion
34
+ export { ChatToolCallStatusRow };
35
+
36
+ //# sourceMappingURL=ChatToolCallStatusRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatToolCallStatusRow.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCallStatusRow.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Tooltip } from '../Tooltip';\n\ninterface ChatToolCallStatusRowProps {\n heading: ReactNode;\n status: ReactNode;\n groupLabel: string;\n onInspect?: () => void;\n inspectLabel?: string;\n className?: string;\n}\n\nexport function ChatToolCallStatusRow({\n heading,\n status,\n groupLabel,\n onInspect,\n inspectLabel = 'View tool details',\n className,\n}: ChatToolCallStatusRowProps) {\n const content = (\n <>\n <span className=\"flex min-w-0 flex-1 items-center gap-space-2 py-space-1\">\n {heading}\n </span>\n {status}\n </>\n );\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 {onInspect ? (\n <Tooltip title={inspectLabel}>\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"plain\"\n color=\"secondary\"\n aria-label={`${groupLabel}: ${inspectLabel}`}\n onClick={onInspect}\n className=\"focus-visible:ring-focus flex h-auto w-full flex-wrap items-center gap-space-1 rounded-md border-0 px-space-1 py-0 text-left transition-colors duration-fast hover:bg-surface-level-2 focus-visible:outline-hidden focus-visible:ring-2 motion-reduce:transition-none dark:hover:bg-surface-level-2\"\n >\n {content}\n </Button>\n </Tooltip>\n ) : (\n <div className=\"flex flex-wrap items-center gap-space-1 rounded-md px-space-1 transition-colors duration-fast hover:bg-surface-level-2 motion-reduce:transition-none\">\n {content}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AAeA,SAAgB,sBAAsB,EACpC,SACA,QACA,YACA,WACA,eAAe,qBACf,aAC6B;CAC7B,MAAM,UACJ,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;EAAM,WAAU;EACb,UAAA;CACG,CAAA,GACL,MACD,EAAA,CAAA;CAGJ,OACE,oBAAC,OAAD;EACE,MAAK;EACL,cAAY;EACZ,WAAW,GACT,wDACA,SACF;EAEC,UAAA,YACC,oBAAC,SAAD;GAAS,OAAO;GACd,UAAA,oBAAC,QAAD;IACE,MAAK;IACL,MAAK;IACL,SAAQ;IACR,OAAM;IACN,cAAY,GAAG,WAAW,IAAI;IAC9B,SAAS;IACT,WAAU;IAET,UAAA;GACK,CAAA;EACD,CAAA,IAET,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA;EACE,CAAA;CAEJ,CAAA;AAET"}
@@ -0,0 +1,7 @@
1
+ export { ChatToolCall } from './ChatToolCall.js';
2
+ export type { ChatToolCallProps } from './ChatToolCall.js';
3
+ export { ChatToolCallGroup } from './ChatToolCallGroup.js';
4
+ export type { ChatToolCallGroupProps } from './ChatToolCallGroup.js';
5
+ export { ChatToolCallReasoning } from './ChatToolCallReasoning.js';
6
+ export type { ChatToolCallReasoningProps } from './ChatToolCallReasoning.js';
7
+ export type { ChatToolCallModel, ChatToolCallStatus, } from './ChatToolCall.types.js';
@@ -0,0 +1,4 @@
1
+ import { ChatToolCall } from "./ChatToolCall.js";
2
+ import { ChatToolCallGroup } from "./ChatToolCallGroup.js";
3
+ import { ChatToolCallReasoning } from "./ChatToolCallReasoning.js";
4
+ export { ChatToolCall, ChatToolCallGroup, ChatToolCallReasoning };
@@ -4,8 +4,8 @@ import { Text } from "../Text/Text.js";
4
4
  import { IconButton } from "../IconButton/IconButton.js";
5
5
  import { useCodeMirror } from "../../utils/useCodeMirror.js";
6
6
  import { CopyIconButton } from "../CopyButton/CopyButton.js";
7
- import { convertFile, getVisibleLines, parseFile } from "./CodeLite.utils.js";
8
7
  import { CodeToolbar } from "./CodeToolbar.js";
8
+ import { convertFile, getVisibleLines, parseFile } from "./CodeLite.utils.js";
9
9
  import { Suspense, lazy, memo, useEffect, useRef, useState } from "react";
10
10
  import { DotsThreeIcon } from "@phosphor-icons/react/dist/ssr/DotsThree";
11
11
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -3,19 +3,18 @@ import zIndices from "../../utils/zIndices.js";
3
3
  import { useZIndex } from "../../utils/useZIndex.js";
4
4
  import { Button } from "../Button/Button.js";
5
5
  import { Banner } from "../Banner/Banner.js";
6
- import "../Banner/index.js";
7
6
  import { useColorScheme } from "../../hooks/useColorScheme.js";
8
- import { getLanguageExtension, getSyntaxTheme, useEditorTheme } from "./Code.utils.js";
9
- import { CODE_LANGUAGES, resolveCodeLanguage } from "./codeLanguages.js";
10
- import { CodeLanguageSelect } from "./CodeLanguageSelect.js";
7
+ import { getNonce } from "../../utils/csp-nonce.js";
11
8
  import { useCodeMirror } from "../../utils/useCodeMirror.js";
12
9
  import { CopyButton } from "../CopyButton/CopyButton.js";
13
- import { CodeToolbar } from "./CodeToolbar.js";
14
- import "./constants.js";
15
- import { getImageReplacerExtensions } from "./ImageReplacerExtension.js";
16
- import { getNonce } from "../../utils/csp-nonce.js";
17
10
  import { ErrorBoundary } from "../ErrorBoundary.js";
11
+ import "./constants.js";
18
12
  import { PlainTextEditor } from "../PlainTextEditor/index.js";
13
+ import { getLanguageExtension, getSyntaxTheme, useEditorTheme } from "./Code.utils.js";
14
+ import { getImageReplacerExtensions } from "./ImageReplacerExtension.js";
15
+ import { CODE_LANGUAGES, resolveCodeLanguage } from "./codeLanguages.js";
16
+ import { CodeLanguageSelect } from "./CodeLanguageSelect.js";
17
+ import { CodeToolbar } from "./CodeToolbar.js";
19
18
  import { useMemo, useState } from "react";
20
19
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
21
20
  //#region packages/components/src/components/Code/index.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Code/index.tsx"],"sourcesContent":["import { type ReactNode, useMemo, useState } from 'react';\n\nimport type { Extension } from '@codemirror/state';\nimport type { EditorView, ViewUpdate } from '@codemirror/view';\n\nimport { useColorScheme } from '../../hooks/useColorScheme';\nimport { cn } from '../../utils/cn';\nimport { getNonce } from '../../utils/csp-nonce';\nimport { useCodeMirror } from '../../utils/useCodeMirror';\nimport { useZIndex } from '../../utils/useZIndex';\nimport zIndices from '../../utils/zIndices';\nimport { Banner } from '../Banner';\nimport { Button } from '../Button';\nimport { CopyButton } from '../CopyButton';\nimport { ErrorBoundary } from '../ErrorBoundary';\nimport { PlainTextEditor } from '../PlainTextEditor';\nimport {\n getLanguageExtension,\n getSyntaxTheme,\n useEditorTheme,\n} from './Code.utils';\nimport { MAX_CODE_LENGTH } from './constants';\nimport { getImageReplacerExtensions } from './ImageReplacerExtension';\nimport type { CodeLanguageType } from './types';\n\nexport { CodeLanguageSelect } from './CodeLanguageSelect';\nexport type { CodeLanguageSelectProps } from './CodeLanguageSelect';\nexport { CodeToolbar } from './CodeToolbar';\nexport type { CodeToolbarProps } from './CodeToolbar';\nexport { CODE_LANGUAGES, resolveCodeLanguage } from './codeLanguages';\nexport type { CodeLanguageType } from './types';\n\n/** Props for the syntax-highlighted CodeMirror block. */\nexport interface CodeProps {\n language: CodeLanguageType;\n extensions?: Extension[];\n value: string | undefined;\n onChange?: (code: string) => void;\n readOnly?: boolean;\n autoFocus?: boolean;\n height?: string;\n maxHeight?: string;\n omitMaxHeight?: boolean;\n width?: string;\n fontSize?: string;\n placeholder?: string;\n ariaLabel?: string;\n toolbar?: ReactNode;\n /** Floating copy control when no toolbar is supplied. */\n showCopyButton?: boolean;\n showFoldGutter?: boolean;\n testId?: string;\n variant?: 'plain' | 'full';\n onCreateEditor?: (view: EditorView) => void;\n /** Receives document and selection updates, including programmatic changes. */\n onUpdate?: (update: ViewUpdate) => void;\n converterExtensions?: Extension[];\n}\n\n/**\n * Renders syntax-highlighted code with optional editing and copy support.\n *\n * Import directly from `@langchain/macaw-components/Code` so the CodeMirror\n * dependency is only loaded by surfaces that use it.\n */\nexport const Code = ({\n value,\n readOnly,\n onChange,\n autoFocus,\n placeholder,\n ariaLabel,\n language,\n extensions,\n converterExtensions,\n height,\n maxHeight,\n omitMaxHeight,\n width,\n fontSize,\n onCreateEditor,\n onUpdate,\n variant = 'full',\n testId,\n toolbar,\n showCopyButton,\n showFoldGutter = true,\n}: CodeProps) => {\n const cm = useCodeMirror();\n const { isDarkMode } = useColorScheme();\n const copyButtonZIndex = useZIndex(zIndices.floatingBar);\n\n const [ignoreWarning, setIgnoreWarning] = useState(false);\n\n const lineCount = value?.split('\\n').length ?? 0;\n\n // Stable CM-derived values — memoized so StateField/ViewPlugin instances are\n // created once and not recreated on every render (which resets editor state).\n const imageReplacerExtensions = useMemo(\n () => (cm ? getImageReplacerExtensions(cm) : null),\n [cm]\n );\n const editorTheme = useEditorTheme(cm, { variant, showFoldGutter });\n const langExt = useMemo(\n () => (cm ? getLanguageExtension(cm, language) : null),\n [cm, language]\n );\n const syntaxTheme = useMemo(\n () => (cm ? getSyntaxTheme(cm, isDarkMode) : null),\n [cm, isDarkMode]\n );\n\n const nonce = getNonce();\n\n const mExtensions = useMemo(() => {\n if (!cm || !imageReplacerExtensions || !langExt || !editorTheme) return [];\n const { keymap, defaultKeymap, EditorView } = cm;\n const { decorationStateField, imageReplacerPlugin } =\n imageReplacerExtensions;\n return [\n keymap.of([{ key: 'Mod-Enter', run: () => true }, ...defaultKeymap]),\n langExt.language,\n ...(extensions ?? []),\n // YAML folding blocks rendering for large files, so cap it at 500 lines.\n ...(lineCount <= 500\n ? (converterExtensions ?? langExt.extensions ?? [])\n : []),\n imageReplacerPlugin,\n decorationStateField,\n EditorView.lineWrapping,\n editorTheme,\n // Untagged text otherwise uses the syntax theme's dim default.\n ...(language === 'plaintext'\n ? [\n EditorView.theme({\n '.cm-content': { color: 'var(--text-primary)' },\n }),\n ]\n : []),\n ...(ariaLabel\n ? [EditorView.contentAttributes.of({ 'aria-label': ariaLabel })]\n : []),\n ...(readOnly ? [EditorView.editable.of(false)] : []),\n ...(nonce ? [EditorView.cspNonce.of(nonce)] : []),\n ];\n // extensions/converterExtensions are caller-provided arrays. Include them\n // directly so changes propagate.\n }, [\n cm,\n imageReplacerExtensions,\n langExt,\n editorTheme,\n language,\n ariaLabel,\n extensions,\n converterExtensions,\n lineCount,\n readOnly,\n nonce,\n ]);\n\n if (value == null) return null;\n\n // Avoid mounting CodeMirror by default when style recomputation could block rendering.\n const showWarning = lineCount > MAX_CODE_LENGTH && !ignoreWarning;\n const hasToolbar = Boolean(toolbar);\n const CodeMirror = cm?.CodeMirror;\n const editorHeight = hasToolbar && height ? '100%' : height;\n const editor = showWarning ? (\n <Banner\n intent=\"warning\"\n action={\n <Button\n variant=\"underlined\"\n color=\"secondary\"\n size=\"sm\"\n onClick={() => setIgnoreWarning(true)}\n >\n Open anyway\n </Button>\n }\n >\n This content might be too long to display in the editor.\n </Banner>\n ) : !CodeMirror || !syntaxTheme ? (\n <PlainTextEditor\n value={value}\n readOnly={true}\n placeholder={placeholder}\n className={cn(\n 'font-mono text-xs',\n height && 'h-full overflow-auto',\n maxHeight && !omitMaxHeight && `max-h-[${maxHeight}]`\n )}\n />\n ) : (\n <ErrorBoundary fallback={() => <div>Error showing code</div>}>\n <CodeMirror\n value={value}\n readOnly={readOnly}\n autoFocus={autoFocus}\n placeholder={placeholder}\n height={editorHeight}\n maxHeight={omitMaxHeight ? undefined : (maxHeight ?? '50vh')}\n width={hasToolbar ? '100%' : width}\n style={{\n fontSize,\n backgroundColor: 'var(--bg-surface-level-2)',\n borderRadius: hasToolbar ? 0 : 'var(--radius-lg)',\n cursor: readOnly ? 'default' : 'text',\n ...(editorHeight ? { height: editorHeight } : {}),\n ...(width ? { width: hasToolbar ? '100%' : width } : {}),\n }}\n extensions={mExtensions}\n onCreateEditor={onCreateEditor}\n onUpdate={onUpdate}\n onChange={(code) => {\n if (!readOnly) {\n onChange?.(code);\n }\n }}\n theme={syntaxTheme}\n basicSetup={{\n foldGutter: showFoldGutter,\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n defaultKeymap: false,\n ...(variant === 'plain' && {\n lineNumbers: false,\n highlightSelectionMatches: false,\n }),\n }}\n />\n </ErrorBoundary>\n );\n\n return (\n <div\n data-testid={testId}\n className={cn(\n 'group relative text-xs',\n height && !hasToolbar && 'h-full',\n hasToolbar &&\n 'flex flex-col overflow-hidden rounded-lg border border-subtle bg-surface-level-2'\n )}\n style={hasToolbar ? { width, height } : undefined}\n >\n {hasToolbar ? (\n <>\n <div className=\"shrink-0\">{toolbar}</div>\n <div className={cn(height && 'min-h-0 flex-1 overflow-auto')}>\n {editor}\n </div>\n </>\n ) : (\n editor\n )}\n {!hasToolbar &&\n !showWarning &&\n CodeMirror &&\n syntaxTheme &&\n showCopyButton &&\n value && (\n <div\n onMouseDown={(e) => e.preventDefault()}\n className=\"absolute right-1 top-1 opacity-0 transition-opacity duration-300 group-hover:opacity-100\"\n style={{ zIndex: copyButtonZIndex }}\n >\n <CopyButton copy={value} variant=\"icon\" />\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAa,QAAQ,EACnB,OACA,UACA,UACA,WACA,aACA,WACA,UACA,YACA,qBACA,QACA,WACA,eACA,OACA,UACA,gBACA,UACA,UAAU,QACV,QACA,SACA,gBACA,iBAAiB,WACF;CACf,MAAM,KAAK,cAAc;CACzB,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,mBAAmB,UAAU,SAAS,WAAW;CAEvD,MAAM,CAAC,eAAe,oBAAoB,SAAS,KAAK;CAExD,MAAM,YAAY,OAAO,MAAM,IAAI,CAAC,CAAC,UAAU;CAI/C,MAAM,0BAA0B,cACvB,KAAK,2BAA2B,EAAE,IAAI,MAC7C,CAAC,EAAE,CACL;CACA,MAAM,cAAc,eAAe,IAAI;EAAE;EAAS;CAAe,CAAC;CAClE,MAAM,UAAU,cACP,KAAK,qBAAqB,IAAI,QAAQ,IAAI,MACjD,CAAC,IAAI,QAAQ,CACf;CACA,MAAM,cAAc,cACX,KAAK,eAAe,IAAI,UAAU,IAAI,MAC7C,CAAC,IAAI,UAAU,CACjB;CAEA,MAAM,QAAQ,SAAS;CAEvB,MAAM,cAAc,cAAc;EAChC,IAAI,CAAC,MAAM,CAAC,2BAA2B,CAAC,WAAW,CAAC,aAAa,OAAO,CAAC;EACzE,MAAM,EAAE,QAAQ,eAAe,eAAe;EAC9C,MAAM,EAAE,sBAAsB,wBAC5B;EACF,OAAO;GACL,OAAO,GAAG,CAAC;IAAE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AO,aAAa,SAAS;GAC7B,OAAO;IACL;IACA,iBAAiB;IACjB,cAAc,aAAa,IAAI;IAC/B,QAAQ,WAAW,YAAY;IAC/B,GAAI,eAAe,EAAE,QAAQ,aAAa,IAAI,CAAC;IAC/C,GAAI,QAAQ,EAAE,OAAO,aAAa,SAAS,MAAM,IAAI,CAAC;GACxD;GACA,YAAY;GACI;GACN;GACV,WAAW,SAAS;IAClB,IAAI,CAAC,UACH,WAAW,IAAI;GAEnB;GACA,OAAO;GACP,YAAY;IACV,YAAY;IACZ,qBAAqB;IACrB,2BAA2B;IAC3B,eAAe;IACf,GAAI,YAAY,WAAW;KACzB,aAAa;KACb,2BAA2B;IAC7B;GACF;EACD,CAAA;CACY,CAAA;CAGjB,OACE,qBAAC,OAAD;EACE,eAAa;EACb,WAAW,GACT,0BACA,UAAU,CAAC,cAAc,UACzB,cACE,kFACJ;EACA,OAAO,aAAa;GAAE;GAAO;EAAO,IAAI,KAAA;EAR1C,UAAA,CAUG,aACC,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,OAAD;GAAK,WAAU;GAAY,UAAA;EAAa,CAAA,GACxC,oBAAC,OAAD;GAAK,WAAW,GAAG,UAAU,8BAA8B;GACxD,UAAA;EACE,CAAA,CACL,EAAA,CAAA,IAEF,QAED,CAAC,cACA,CAAC,eACD,cACA,eACA,kBACA,SACE,oBAAC,OAAD;GACE,cAAc,MAAM,EAAE,eAAe;GACrC,WAAU;GACV,OAAO,EAAE,QAAQ,iBAAiB;GAElC,UAAA,oBAAC,YAAD;IAAY,MAAM;IAAO,SAAQ;GAAQ,CAAA;EACtC,CAAA,CAEN;;AAET"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Code/index.tsx"],"sourcesContent":["import { type ReactNode, useMemo, useState } from 'react';\n\nimport type { Extension } from '@codemirror/state';\nimport type { EditorView, ViewUpdate } from '@codemirror/view';\n\nimport { useColorScheme } from '../../hooks/useColorScheme';\nimport { cn } from '../../utils/cn';\nimport { getNonce } from '../../utils/csp-nonce';\nimport { useCodeMirror } from '../../utils/useCodeMirror';\nimport { useZIndex } from '../../utils/useZIndex';\nimport zIndices from '../../utils/zIndices';\nimport { Banner } from '../Banner';\nimport { Button } from '../Button';\nimport { CopyButton } from '../CopyButton';\nimport { ErrorBoundary } from '../ErrorBoundary';\nimport { PlainTextEditor } from '../PlainTextEditor';\nimport {\n getLanguageExtension,\n getSyntaxTheme,\n useEditorTheme,\n} from './Code.utils';\nimport { MAX_CODE_LENGTH } from './constants';\nimport { getImageReplacerExtensions } from './ImageReplacerExtension';\nimport type { CodeLanguageType } from './types';\n\nexport { CodeLanguageSelect } from './CodeLanguageSelect';\nexport type { CodeLanguageSelectProps } from './CodeLanguageSelect';\nexport { CodeToolbar } from './CodeToolbar';\nexport type { CodeToolbarProps } from './CodeToolbar';\nexport { CODE_LANGUAGES, resolveCodeLanguage } from './codeLanguages';\nexport type { CodeLanguageType } from './types';\n\n/** Props for the syntax-highlighted CodeMirror block. */\nexport interface CodeProps {\n language: CodeLanguageType;\n extensions?: Extension[];\n value: string | undefined;\n onChange?: (code: string) => void;\n readOnly?: boolean;\n autoFocus?: boolean;\n height?: string;\n maxHeight?: string;\n omitMaxHeight?: boolean;\n width?: string;\n fontSize?: string;\n placeholder?: string;\n ariaLabel?: string;\n toolbar?: ReactNode;\n /** Floating copy control when no toolbar is supplied. */\n showCopyButton?: boolean;\n showFoldGutter?: boolean;\n testId?: string;\n variant?: 'plain' | 'full';\n onCreateEditor?: (view: EditorView) => void;\n /** Receives document and selection updates, including programmatic changes. */\n onUpdate?: (update: ViewUpdate) => void;\n converterExtensions?: Extension[];\n}\n\n/**\n * Renders syntax-highlighted code with optional editing and copy support.\n *\n * Import directly from `@langchain/macaw-components/Code` so the CodeMirror\n * dependency is only loaded by surfaces that use it.\n */\nexport const Code = ({\n value,\n readOnly,\n onChange,\n autoFocus,\n placeholder,\n ariaLabel,\n language,\n extensions,\n converterExtensions,\n height,\n maxHeight,\n omitMaxHeight,\n width,\n fontSize,\n onCreateEditor,\n onUpdate,\n variant = 'full',\n testId,\n toolbar,\n showCopyButton,\n showFoldGutter = true,\n}: CodeProps) => {\n const cm = useCodeMirror();\n const { isDarkMode } = useColorScheme();\n const copyButtonZIndex = useZIndex(zIndices.floatingBar);\n\n const [ignoreWarning, setIgnoreWarning] = useState(false);\n\n const lineCount = value?.split('\\n').length ?? 0;\n\n // Stable CM-derived values — memoized so StateField/ViewPlugin instances are\n // created once and not recreated on every render (which resets editor state).\n const imageReplacerExtensions = useMemo(\n () => (cm ? getImageReplacerExtensions(cm) : null),\n [cm]\n );\n const editorTheme = useEditorTheme(cm, { variant, showFoldGutter });\n const langExt = useMemo(\n () => (cm ? getLanguageExtension(cm, language) : null),\n [cm, language]\n );\n const syntaxTheme = useMemo(\n () => (cm ? getSyntaxTheme(cm, isDarkMode) : null),\n [cm, isDarkMode]\n );\n\n const nonce = getNonce();\n\n const mExtensions = useMemo(() => {\n if (!cm || !imageReplacerExtensions || !langExt || !editorTheme) return [];\n const { keymap, defaultKeymap, EditorView } = cm;\n const { decorationStateField, imageReplacerPlugin } =\n imageReplacerExtensions;\n return [\n keymap.of([{ key: 'Mod-Enter', run: () => true }, ...defaultKeymap]),\n langExt.language,\n ...(extensions ?? []),\n // YAML folding blocks rendering for large files, so cap it at 500 lines.\n ...(lineCount <= 500\n ? (converterExtensions ?? langExt.extensions ?? [])\n : []),\n imageReplacerPlugin,\n decorationStateField,\n EditorView.lineWrapping,\n editorTheme,\n // Untagged text otherwise uses the syntax theme's dim default.\n ...(language === 'plaintext'\n ? [\n EditorView.theme({\n '.cm-content': { color: 'var(--text-primary)' },\n }),\n ]\n : []),\n ...(ariaLabel\n ? [EditorView.contentAttributes.of({ 'aria-label': ariaLabel })]\n : []),\n ...(readOnly ? [EditorView.editable.of(false)] : []),\n ...(nonce ? [EditorView.cspNonce.of(nonce)] : []),\n ];\n // extensions/converterExtensions are caller-provided arrays. Include them\n // directly so changes propagate.\n }, [\n cm,\n imageReplacerExtensions,\n langExt,\n editorTheme,\n language,\n ariaLabel,\n extensions,\n converterExtensions,\n lineCount,\n readOnly,\n nonce,\n ]);\n\n if (value == null) return null;\n\n // Avoid mounting CodeMirror by default when style recomputation could block rendering.\n const showWarning = lineCount > MAX_CODE_LENGTH && !ignoreWarning;\n const hasToolbar = Boolean(toolbar);\n const CodeMirror = cm?.CodeMirror;\n const editorHeight = hasToolbar && height ? '100%' : height;\n const editor = showWarning ? (\n <Banner\n intent=\"warning\"\n action={\n <Button\n variant=\"underlined\"\n color=\"secondary\"\n size=\"sm\"\n onClick={() => setIgnoreWarning(true)}\n >\n Open anyway\n </Button>\n }\n >\n This content might be too long to display in the editor.\n </Banner>\n ) : !CodeMirror || !syntaxTheme ? (\n <PlainTextEditor\n value={value}\n readOnly={true}\n placeholder={placeholder}\n className={cn(\n 'font-mono text-xs',\n height && 'h-full overflow-auto',\n maxHeight && !omitMaxHeight && `max-h-[${maxHeight}]`\n )}\n />\n ) : (\n <ErrorBoundary fallback={() => <div>Error showing code</div>}>\n <CodeMirror\n value={value}\n readOnly={readOnly}\n autoFocus={autoFocus}\n placeholder={placeholder}\n height={editorHeight}\n maxHeight={omitMaxHeight ? undefined : (maxHeight ?? '50vh')}\n width={hasToolbar ? '100%' : width}\n style={{\n fontSize,\n backgroundColor: 'var(--bg-surface-level-2)',\n borderRadius: hasToolbar ? 0 : 'var(--radius-lg)',\n cursor: readOnly ? 'default' : 'text',\n ...(editorHeight ? { height: editorHeight } : {}),\n ...(width ? { width: hasToolbar ? '100%' : width } : {}),\n }}\n extensions={mExtensions}\n onCreateEditor={onCreateEditor}\n onUpdate={onUpdate}\n onChange={(code) => {\n if (!readOnly) {\n onChange?.(code);\n }\n }}\n theme={syntaxTheme}\n basicSetup={{\n foldGutter: showFoldGutter,\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n defaultKeymap: false,\n ...(variant === 'plain' && {\n lineNumbers: false,\n highlightSelectionMatches: false,\n }),\n }}\n />\n </ErrorBoundary>\n );\n\n return (\n <div\n data-testid={testId}\n className={cn(\n 'group relative text-xs',\n height && !hasToolbar && 'h-full',\n hasToolbar &&\n 'flex flex-col overflow-hidden rounded-lg border border-subtle bg-surface-level-2'\n )}\n style={hasToolbar ? { width, height } : undefined}\n >\n {hasToolbar ? (\n <>\n <div className=\"shrink-0\">{toolbar}</div>\n <div className={cn(height && 'min-h-0 flex-1 overflow-auto')}>\n {editor}\n </div>\n </>\n ) : (\n editor\n )}\n {!hasToolbar &&\n !showWarning &&\n CodeMirror &&\n syntaxTheme &&\n showCopyButton &&\n value && (\n <div\n onMouseDown={(e) => e.preventDefault()}\n className=\"absolute right-1 top-1 opacity-0 transition-opacity duration-300 group-hover:opacity-100\"\n style={{ zIndex: copyButtonZIndex }}\n >\n <CopyButton copy={value} variant=\"icon\" />\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAa,QAAQ,EACnB,OACA,UACA,UACA,WACA,aACA,WACA,UACA,YACA,qBACA,QACA,WACA,eACA,OACA,UACA,gBACA,UACA,UAAU,QACV,QACA,SACA,gBACA,iBAAiB,WACF;CACf,MAAM,KAAK,cAAc;CACzB,MAAM,EAAE,eAAe,eAAe;CACtC,MAAM,mBAAmB,UAAU,SAAS,WAAW;CAEvD,MAAM,CAAC,eAAe,oBAAoB,SAAS,KAAK;CAExD,MAAM,YAAY,OAAO,MAAM,IAAI,CAAC,CAAC,UAAU;CAI/C,MAAM,0BAA0B,cACvB,KAAK,2BAA2B,EAAE,IAAI,MAC7C,CAAC,EAAE,CACL;CACA,MAAM,cAAc,eAAe,IAAI;EAAE;EAAS;CAAe,CAAC;CAClE,MAAM,UAAU,cACP,KAAK,qBAAqB,IAAI,QAAQ,IAAI,MACjD,CAAC,IAAI,QAAQ,CACf;CACA,MAAM,cAAc,cACX,KAAK,eAAe,IAAI,UAAU,IAAI,MAC7C,CAAC,IAAI,UAAU,CACjB;CAEA,MAAM,QAAQ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AET"}
@@ -7,11 +7,11 @@ import { CONTROL_ICON_SIZES } from "../../utils/controlIconSizes.js";
7
7
  import { INPUT_TEXT_CLASSES, getInputContainerClasses, getInputElementClasses } from "./inputStyles.js";
8
8
  import { forwardRef, useEffect, useId, useRef, useState } from "react";
9
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
+ import { PaperclipIcon } from "@phosphor-icons/react/dist/ssr/Paperclip";
10
11
  import { useDebouncedCallback } from "use-debounce";
11
12
  import { CalendarBlankIcon } from "@phosphor-icons/react/dist/ssr/CalendarBlank";
12
13
  import { EyeIcon } from "@phosphor-icons/react/dist/ssr/Eye";
13
14
  import { EyeSlashIcon } from "@phosphor-icons/react/dist/ssr/EyeSlash";
14
- import { PaperclipIcon } from "@phosphor-icons/react/dist/ssr/Paperclip";
15
15
  //#region packages/components/src/components/Input/Input.tsx
16
16
  function InputIconSlot({ icon, action, size, disabled }) {
17
17
  const isDisabled = disabled || action?.disabled;
@@ -69,6 +69,11 @@ interface SelectBaseProps<T extends string = string> extends DataAttributes {
69
69
  side?: 'top' | 'bottom' | 'left' | 'right';
70
70
  /** Alignment of the popover relative to the trigger */
71
71
  align?: 'start' | 'center' | 'end';
72
+ /**
73
+ * Called when the menu closes, before focus returns to the trigger. Move
74
+ * focus elsewhere and call `event.preventDefault()` to keep it there.
75
+ */
76
+ onCloseAutoFocus?: (event: Event) => void;
72
77
  /** aria-label for the trigger button */
73
78
  'aria-label'?: string;
74
79
  /** Test id for the trigger button */
@@ -21,7 +21,7 @@ function optionToItem(opt) {
21
21
  keywords: opt.label ? [opt.label] : void 0
22
22
  };
23
23
  }
24
- function OptionSelect({ value, onChange, options, groups, placeholder = "Select...", searchPlaceholder = "Search...", disabled = false, size = "sm", emptyText = "No results found.", open: controlledOpen, onOpenChange: controlledOnOpenChange, allowDeselect, hideSearch = true, disableFilter, onSearchChange, loading, loadingRows, onEndReached, endReachedThresholdPx, triggerClassName, variant = "outlined", contentClassName, renderValue, renderOption, side, align = "start", "aria-label": ariaLabel, "data-testid": dataTestId, ...rest }) {
24
+ function OptionSelect({ value, onChange, options, groups, placeholder = "Select...", searchPlaceholder = "Search...", disabled = false, size = "sm", emptyText = "No results found.", open: controlledOpen, onOpenChange: controlledOnOpenChange, allowDeselect, hideSearch = true, disableFilter, onSearchChange, loading, loadingRows, onEndReached, endReachedThresholdPx, triggerClassName, variant = "outlined", contentClassName, renderValue, renderOption, side, align = "start", onCloseAutoFocus, "aria-label": ariaLabel, "data-testid": dataTestId, ...rest }) {
25
25
  const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
26
26
  const isControlled = controlledOpen !== void 0;
27
27
  const open = isControlled ? controlledOpen : uncontrolledOpen;
@@ -103,6 +103,7 @@ function OptionSelect({ value, onChange, options, groups, placeholder = "Select.
103
103
  className: cn("w-max min-w-[var(--radix-popover-trigger-width)] max-w-[min(24rem,calc(100vw-1rem))] p-0 text-primary", contentClassName),
104
104
  side,
105
105
  align,
106
+ onCloseAutoFocus,
106
107
  children: commandGroups ? /* @__PURE__ */ jsx(CommandMenu, {
107
108
  groups: commandGroups,
108
109
  ...commandMenuSharedProps
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { CaretDownIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n CONTROL_SIZES,\n type ControlSize,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { Button } from '../Button';\nimport { CommandMenu } from '../Command/CommandMenu';\nimport type { CommandMenuGroup, CommandMenuItem } from '../Command/CommandMenu';\nimport { Icon } from '../Icon';\nimport { Popover, PopoverContent, PopoverTrigger } from '../Popover';\nimport { Text } from '../Text';\n\nexport interface SelectOption<T extends string = string> {\n /** The value used for selection and filtering */\n value: T;\n /** Display label (defaults to value if not provided) */\n label?: string;\n /** Secondary description text displayed below the label */\n description?: string;\n /** Element displayed on the right side of the item (e.g. badge, shortcut) */\n rightDecorator?: ReactNode;\n /** Whether this option is disabled */\n disabled?: boolean;\n}\n\nexport interface SelectGroup<T extends string = string> {\n heading?: string;\n options: SelectOption<T>[];\n}\n\nexport type SelectSize = ControlSize;\n\nexport type SelectVariant = 'outlined' | 'plain';\n\ninterface SelectBaseProps<T extends string = string> extends DataAttributes {\n /** The currently selected value */\n value?: T;\n /** Callback when selection changes. Receives undefined when deselected. */\n onChange: (value: T | undefined) => void;\n /** Placeholder text when no value is selected */\n placeholder?: string;\n /** Placeholder text for the search input */\n searchPlaceholder?: string;\n /** Whether the select is disabled */\n disabled?: boolean;\n /** Exact trigger height: xs=20px, sm=24px, md=32px, lg=40px. */\n size?: SelectSize;\n /** Text to show when no options match the search */\n emptyText?: string;\n /** Allow deselecting the current value by clicking it again (default: false) */\n allowDeselect?: boolean;\n /** Hide the search input (default: true, search is hidden) */\n hideSearch?: boolean;\n /** Disable client-side filtering by cmdk (default: false). Set true for server-side filtering. */\n disableFilter?: boolean;\n /** Callback when the search input value changes. Useful for server-side filtering. */\n onSearchChange?: (query: string) => void;\n /** Whether more items are currently being loaded */\n loading?: boolean;\n /** Number of skeleton rows to show while loading (default: 5) */\n loadingRows?: number;\n /** Callback when the user scrolls near the end of the list. Use for infinite loading. */\n onEndReached?: () => void;\n /** Distance in pixels from the bottom to trigger onEndReached (default: 50) */\n endReachedThresholdPx?: number;\n /** Additional class name for the trigger button */\n triggerClassName?: string;\n /**\n * Trigger appearance. `outlined` (default) is a full-width form field.\n * `plain` drops the field fill and border and sizes the trigger to its\n * value, so it reads as text until hovered — for an inline setting in a row,\n * such as a member's role, where a field box would crowd it.\n */\n variant?: SelectVariant;\n /** Additional class name for the popover content */\n contentClassName?: string;\n /** Custom render function for the selected value in the trigger */\n renderValue?: (option: SelectOption<T>) => ReactNode;\n /** Custom render function for each option in the list */\n renderOption?: (option: SelectOption<T>, isSelected: boolean) => ReactNode;\n /** Side of the trigger to align the popover */\n side?: 'top' | 'bottom' | 'left' | 'right';\n /** Alignment of the popover relative to the trigger */\n align?: 'start' | 'center' | 'end';\n /** aria-label for the trigger button */\n 'aria-label'?: string;\n /** Test id for the trigger button */\n 'data-testid'?: string;\n}\n\nexport type SelectProps<T extends string = string> = SelectBaseProps<T> &\n (\n | {\n options: SelectOption<T>[];\n groups?: never;\n }\n | {\n groups: SelectGroup<T>[];\n options?: never;\n }\n ) &\n (\n | {\n /** Controlled open state */\n open: boolean;\n /** Callback when open state changes (required when `open` is provided) */\n onOpenChange: (open: boolean) => void;\n }\n | {\n open?: never;\n onOpenChange?: never;\n }\n );\n\nfunction optionToItem(opt: SelectOption): CommandMenuItem {\n return {\n value: opt.value,\n label: opt.label,\n description: opt.description,\n rightDecorator: opt.rightDecorator,\n disabled: opt.disabled,\n keywords: opt.label ? [opt.label] : undefined,\n };\n}\n\nfunction OptionSelect<T extends string = string>({\n value,\n onChange,\n options,\n groups,\n placeholder = 'Select...',\n searchPlaceholder = 'Search...',\n disabled = false,\n size = 'sm',\n emptyText = 'No results found.',\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n allowDeselect,\n hideSearch = true,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n triggerClassName,\n variant = 'outlined',\n contentClassName,\n renderValue,\n renderOption,\n side,\n align = 'start',\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n ...rest\n}: SelectProps<T>) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const isControlled = controlledOpen !== undefined;\n const open = isControlled ? controlledOpen : uncontrolledOpen;\n const setOpen = isControlled ? controlledOnOpenChange : setUncontrolledOpen;\n\n const allOptions = useMemo<SelectOption<T>[]>(\n () => (groups ? groups.flatMap((g) => g.options) : (options ?? [])),\n [groups, options]\n );\n\n const selectedOption = useMemo(\n () => allOptions.find((opt) => opt.value === value),\n [allOptions, value]\n );\n\n const handleSelect = useCallback(\n (optionValue: string) => {\n const match = allOptions.find((o) => o.value === optionValue);\n if (!match) return;\n if (allowDeselect && match.value === value) {\n onChange(undefined);\n } else {\n onChange(match.value);\n }\n setOpen(false);\n },\n [allowDeselect, value, onChange, setOpen, allOptions]\n );\n\n const items: CommandMenuItem[] = useMemo(\n () => (options ?? []).map(optionToItem),\n [options]\n );\n\n const commandGroups: CommandMenuGroup[] | undefined = useMemo(\n () =>\n groups?.map((g) => ({\n heading: g.heading,\n items: g.options.map(optionToItem),\n })),\n [groups]\n );\n\n const renderItem = renderOption\n ? (item: CommandMenuItem, isSelected: boolean) => {\n const option = allOptions.find((o) => o.value === item.value);\n return option ? renderOption(option, isSelected) : null;\n }\n : undefined;\n const searchInputSize = size === 'xs' ? 'sm' : size === 'lg' ? 'md' : size;\n const triggerButtonSize = size === 'lg' ? 'md' : size;\n const itemRowSize: OptionRowSize =\n size === 'xs' || size === 'sm' ? 'sm' : 'md';\n\n const commandMenuSharedProps = {\n value,\n onSelect: handleSelect,\n placeholder: searchPlaceholder,\n emptyText,\n hideSearch,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n renderItem,\n inputSize: searchInputSize,\n itemRowSize,\n };\n\n const triggerContent =\n selectedOption && renderValue ? (\n renderValue(selectedOption)\n ) : (\n <Text\n as=\"span\"\n variant={triggerButtonSize}\n weight=\"normal\"\n className=\"min-w-0 truncate text-left\"\n >\n {selectedOption\n ? (selectedOption.label ?? selectedOption.value)\n : placeholder}\n </Text>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n {...pickDataAttributes(rest)}\n role=\"combobox\"\n aria-expanded={open}\n aria-label={ariaLabel ?? placeholder}\n variant={variant}\n color=\"secondary\"\n size={triggerButtonSize}\n className={cn(\n 'box-border justify-between py-0',\n CONTROL_SIZES[size].heightClassName,\n variant === 'plain'\n ? cn(\n 'w-auto max-w-full gap-space-1 px-space-1',\n // The shared disabled fill, in both themes.\n disabled && 'bg-disabled text-disabled dark:bg-disabled'\n )\n : cn(\n 'w-full',\n disabled\n ? 'border-muted bg-input-disabled text-disabled dark:bg-input-disabled'\n : 'bg-input border-input shadow-none hover:bg-input-hover hover:border-input-hover focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none'\n ),\n triggerClassName\n )}\n disabled={disabled}\n data-testid={dataTestId}\n >\n {triggerContent}\n <Icon\n aria-hidden\n icon={CaretDownIcon}\n iconClassName={CONTROL_ICON_SIZES[size].iconClassName}\n className={disabled ? 'text-icon-disabled' : 'text-inherit'}\n weight=\"regular\"\n />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n 'w-max min-w-[var(--radix-popover-trigger-width)] max-w-[min(24rem,calc(100vw-1rem))] p-0 text-primary',\n contentClassName\n )}\n side={side}\n align={align}\n >\n {commandGroups ? (\n <CommandMenu groups={commandGroups} {...commandMenuSharedProps} />\n ) : (\n <CommandMenu items={items} {...commandMenuSharedProps} />\n )}\n </PopoverContent>\n </Popover>\n );\n}\n\nexport function Select<T extends string = string>(\n props: SelectProps<T>\n): React.ReactElement<unknown> {\n return <OptionSelect {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;AA4HA,SAAS,aAAa,KAAoC;CACxD,OAAO;EACL,OAAO,IAAI;EACX,OAAO,IAAI;EACX,aAAa,IAAI;EACjB,gBAAgB,IAAI;EACpB,UAAU,IAAI;EACd,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,KAAA;CACtC;AACF;AAEA,SAAS,aAAwC,EAC/C,OACA,UACA,SACA,QACA,cAAc,aACd,oBAAoB,aACpB,WAAW,OACX,OAAO,MACP,YAAY,qBACZ,MAAM,gBACN,cAAc,wBACd,eACA,aAAa,MACb,eACA,gBACA,SACA,aACA,cACA,uBACA,kBACA,U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;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX,aAhBA,SAAS,QAAQ,SAAS,OAAO,OAAO;CAiB1C;CAEA,MAAM,iBACJ,kBAAkB,cAChB,YAAY,cAAc,IAE1B,oBAAC,MAAD;EACE,IAAG;EACH,SAAS;EACT,QAAO;EACP,WAAU;EAET,UAAA,iBACI,eAAe,SAAS,eAAe,QACxC;CACA,CAAA;CAGV,OACE,qBAAC,SAAD;EAAe;EAAM,cAAc;EAAnC,UAAA,CACE,oBAAC,gBAAD;GAAgB,SAAA;GACd,UAAA,qBAAC,QAAD;IACE,GAAI,mBAAmB,IAAI;IAC3B,MAAK;IACL,iBAAe;IACf,cAAY,aAAa;IAChB;IACT,OAAM;IACN,MAAM;IACN,WAAW,GACT,mCACA,cAAc,KAAK,CAAC,iBACpB,YAAY,UACR,GACE,4CAEA,YAAY,4CACd,IACA,GACE,UACA,WACI,wEACA,4LACN,GACJ,gBACF;IACU;IACV,eAAa;IA1Bf,UAAA,CA4BG,gBACD,oBAAC,MAAD;KACE,eAAA;KACA,MAAM;KACN,eAAe,mBAAmB,KAAK,CAAC;KACxC,WAAW,WAAW,uBAAuB;KAC7C,QAAO;IACR,CAAA,CACK;;EACM,CAAA,GAChB,oBAAC,gBAAD;GACE,WAAW,GACT,yGACA,gBACF;GACM;GACC;GAEN,UAAA,gBACC,oBAAC,aAAD;IAAa,QAAQ;IAAe,GAAI;GAAyB,CAAA,IAEjE,oBAAC,aAAD;IAAoB;IAAO,GAAI;GAAyB,CAAA;EAE5C,CAAA,CACT;;AAEb;AAEA,SAAgB,OACd,OAC6B;CAC7B,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC"}
1
+ {"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { CaretDownIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n CONTROL_SIZES,\n type ControlSize,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { Button } from '../Button';\nimport { CommandMenu } from '../Command/CommandMenu';\nimport type { CommandMenuGroup, CommandMenuItem } from '../Command/CommandMenu';\nimport { Icon } from '../Icon';\nimport { Popover, PopoverContent, PopoverTrigger } from '../Popover';\nimport { Text } from '../Text';\n\nexport interface SelectOption<T extends string = string> {\n /** The value used for selection and filtering */\n value: T;\n /** Display label (defaults to value if not provided) */\n label?: string;\n /** Secondary description text displayed below the label */\n description?: string;\n /** Element displayed on the right side of the item (e.g. badge, shortcut) */\n rightDecorator?: ReactNode;\n /** Whether this option is disabled */\n disabled?: boolean;\n}\n\nexport interface SelectGroup<T extends string = string> {\n heading?: string;\n options: SelectOption<T>[];\n}\n\nexport type SelectSize = ControlSize;\n\nexport type SelectVariant = 'outlined' | 'plain';\n\ninterface SelectBaseProps<T extends string = string> extends DataAttributes {\n /** The currently selected value */\n value?: T;\n /** Callback when selection changes. Receives undefined when deselected. */\n onChange: (value: T | undefined) => void;\n /** Placeholder text when no value is selected */\n placeholder?: string;\n /** Placeholder text for the search input */\n searchPlaceholder?: string;\n /** Whether the select is disabled */\n disabled?: boolean;\n /** Exact trigger height: xs=20px, sm=24px, md=32px, lg=40px. */\n size?: SelectSize;\n /** Text to show when no options match the search */\n emptyText?: string;\n /** Allow deselecting the current value by clicking it again (default: false) */\n allowDeselect?: boolean;\n /** Hide the search input (default: true, search is hidden) */\n hideSearch?: boolean;\n /** Disable client-side filtering by cmdk (default: false). Set true for server-side filtering. */\n disableFilter?: boolean;\n /** Callback when the search input value changes. Useful for server-side filtering. */\n onSearchChange?: (query: string) => void;\n /** Whether more items are currently being loaded */\n loading?: boolean;\n /** Number of skeleton rows to show while loading (default: 5) */\n loadingRows?: number;\n /** Callback when the user scrolls near the end of the list. Use for infinite loading. */\n onEndReached?: () => void;\n /** Distance in pixels from the bottom to trigger onEndReached (default: 50) */\n endReachedThresholdPx?: number;\n /** Additional class name for the trigger button */\n triggerClassName?: string;\n /**\n * Trigger appearance. `outlined` (default) is a full-width form field.\n * `plain` drops the field fill and border and sizes the trigger to its\n * value, so it reads as text until hovered — for an inline setting in a row,\n * such as a member's role, where a field box would crowd it.\n */\n variant?: SelectVariant;\n /** Additional class name for the popover content */\n contentClassName?: string;\n /** Custom render function for the selected value in the trigger */\n renderValue?: (option: SelectOption<T>) => ReactNode;\n /** Custom render function for each option in the list */\n renderOption?: (option: SelectOption<T>, isSelected: boolean) => ReactNode;\n /** Side of the trigger to align the popover */\n side?: 'top' | 'bottom' | 'left' | 'right';\n /** Alignment of the popover relative to the trigger */\n align?: 'start' | 'center' | 'end';\n /**\n * Called when the menu closes, before focus returns to the trigger. Move\n * focus elsewhere and call `event.preventDefault()` to keep it there.\n */\n onCloseAutoFocus?: (event: Event) => void;\n /** aria-label for the trigger button */\n 'aria-label'?: string;\n /** Test id for the trigger button */\n 'data-testid'?: string;\n}\n\nexport type SelectProps<T extends string = string> = SelectBaseProps<T> &\n (\n | {\n options: SelectOption<T>[];\n groups?: never;\n }\n | {\n groups: SelectGroup<T>[];\n options?: never;\n }\n ) &\n (\n | {\n /** Controlled open state */\n open: boolean;\n /** Callback when open state changes (required when `open` is provided) */\n onOpenChange: (open: boolean) => void;\n }\n | {\n open?: never;\n onOpenChange?: never;\n }\n );\n\nfunction optionToItem(opt: SelectOption): CommandMenuItem {\n return {\n value: opt.value,\n label: opt.label,\n description: opt.description,\n rightDecorator: opt.rightDecorator,\n disabled: opt.disabled,\n keywords: opt.label ? [opt.label] : undefined,\n };\n}\n\nfunction OptionSelect<T extends string = string>({\n value,\n onChange,\n options,\n groups,\n placeholder = 'Select...',\n searchPlaceholder = 'Search...',\n disabled = false,\n size = 'sm',\n emptyText = 'No results found.',\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n allowDeselect,\n hideSearch = true,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n triggerClassName,\n variant = 'outlined',\n contentClassName,\n renderValue,\n renderOption,\n side,\n align = 'start',\n onCloseAutoFocus,\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n ...rest\n}: SelectProps<T>) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const isControlled = controlledOpen !== undefined;\n const open = isControlled ? controlledOpen : uncontrolledOpen;\n const setOpen = isControlled ? controlledOnOpenChange : setUncontrolledOpen;\n\n const allOptions = useMemo<SelectOption<T>[]>(\n () => (groups ? groups.flatMap((g) => g.options) : (options ?? [])),\n [groups, options]\n );\n\n const selectedOption = useMemo(\n () => allOptions.find((opt) => opt.value === value),\n [allOptions, value]\n );\n\n const handleSelect = useCallback(\n (optionValue: string) => {\n const match = allOptions.find((o) => o.value === optionValue);\n if (!match) return;\n if (allowDeselect && match.value === value) {\n onChange(undefined);\n } else {\n onChange(match.value);\n }\n setOpen(false);\n },\n [allowDeselect, value, onChange, setOpen, allOptions]\n );\n\n const items: CommandMenuItem[] = useMemo(\n () => (options ?? []).map(optionToItem),\n [options]\n );\n\n const commandGroups: CommandMenuGroup[] | undefined = useMemo(\n () =>\n groups?.map((g) => ({\n heading: g.heading,\n items: g.options.map(optionToItem),\n })),\n [groups]\n );\n\n const renderItem = renderOption\n ? (item: CommandMenuItem, isSelected: boolean) => {\n const option = allOptions.find((o) => o.value === item.value);\n return option ? renderOption(option, isSelected) : null;\n }\n : undefined;\n const searchInputSize = size === 'xs' ? 'sm' : size === 'lg' ? 'md' : size;\n const triggerButtonSize = size === 'lg' ? 'md' : size;\n const itemRowSize: OptionRowSize =\n size === 'xs' || size === 'sm' ? 'sm' : 'md';\n\n const commandMenuSharedProps = {\n value,\n onSelect: handleSelect,\n placeholder: searchPlaceholder,\n emptyText,\n hideSearch,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n renderItem,\n inputSize: searchInputSize,\n itemRowSize,\n };\n\n const triggerContent =\n selectedOption && renderValue ? (\n renderValue(selectedOption)\n ) : (\n <Text\n as=\"span\"\n variant={triggerButtonSize}\n weight=\"normal\"\n className=\"min-w-0 truncate text-left\"\n >\n {selectedOption\n ? (selectedOption.label ?? selectedOption.value)\n : placeholder}\n </Text>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n {...pickDataAttributes(rest)}\n role=\"combobox\"\n aria-expanded={open}\n aria-label={ariaLabel ?? placeholder}\n variant={variant}\n color=\"secondary\"\n size={triggerButtonSize}\n className={cn(\n 'box-border justify-between py-0',\n CONTROL_SIZES[size].heightClassName,\n variant === 'plain'\n ? cn(\n 'w-auto max-w-full gap-space-1 px-space-1',\n // The shared disabled fill, in both themes.\n disabled && 'bg-disabled text-disabled dark:bg-disabled'\n )\n : cn(\n 'w-full',\n disabled\n ? 'border-muted bg-input-disabled text-disabled dark:bg-input-disabled'\n : 'bg-input border-input shadow-none hover:bg-input-hover hover:border-input-hover focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none'\n ),\n triggerClassName\n )}\n disabled={disabled}\n data-testid={dataTestId}\n >\n {triggerContent}\n <Icon\n aria-hidden\n icon={CaretDownIcon}\n iconClassName={CONTROL_ICON_SIZES[size].iconClassName}\n className={disabled ? 'text-icon-disabled' : 'text-inherit'}\n weight=\"regular\"\n />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n 'w-max min-w-[var(--radix-popover-trigger-width)] max-w-[min(24rem,calc(100vw-1rem))] p-0 text-primary',\n contentClassName\n )}\n side={side}\n align={align}\n onCloseAutoFocus={onCloseAutoFocus}\n >\n {commandGroups ? (\n <CommandMenu groups={commandGroups} {...commandMenuSharedProps} />\n ) : (\n <CommandMenu items={items} {...commandMenuSharedProps} />\n )}\n </PopoverContent>\n </Popover>\n );\n}\n\nexport function Select<T extends string = string>(\n props: SelectProps<T>\n): React.ReactElement<unknown> {\n return <OptionSelect {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;AAiIA,SAAS,aAAa,KAAoC;CACxD,OAAO;EACL,OAAO,IAAI;EACX,OAAO,IAAI;EACX,aAAa,IAAI;EACjB,gBAAgB,IAAI;EACpB,UAAU,IAAI;EACd,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,KAAA;CACtC;AACF;AAEA,SAAS,aAAwC,EAC/C,OACA,UACA,SACA,QACA,cAAc,aACd,oBAAoB,aACpB,WAAW,OACX,OAAO,MACP,YAAY,qBACZ,MAAM,gBACN,cAAc,wBACd,eACA,aAAa,MACb,eACA,gBACA,SACA,aACA,cACA,uBACA,kBACA,UAAU,YACV,kBACA,aACA,cACA,MACA,QAAQ,SACR,kBACA,cAAc,WACd,eAAe,YACf,GAAG,QACc;CACjB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAC9D,MAAM,eAAe,mBAAmB,KAAA;CACxC,MAAM,OAAO,eAAe,iBAAiB;CAC7C,MAAM,UAAU,eAAe,yBAAyB;CAExD,MAAM,aAAa,cACV,SAAS,OAAO,SAAS,MAAM,EAAE,OAAO,IAAK,WAAW,CAAC,GAChE,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,iBAAiB,cACf,WAAW,MAAM,QAAQ,IAAI,UAAU,KAAK,GAClD,CAAC,YAAY,KAAK,CACpB;CAEA,MAAM,eAAe,aAClB,gBAAwB;EACvB,MAAM,QAAQ,WAAW,MAAM,MAAM,EAAE,UAAU,WAAW;EAC5D,IAAI,CAAC,OAAO;EACZ,IAAI,iBAAiB,MAAM,UAAU,OACnC,SAAS,KAAA,CAAS;OAElB,SAAS,MAAM,KAAK;EAEtB,QAAQ,KAAK;CACf,GACA;EAAC;EAAe;EAAO;EAAU;EAAS;CAAU,CACtD;CAEA,MAAM,QAA2B,eACxB,WAAW,CAAC,EAAA,CAAG,IAAI,YAAY,GACtC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AA,GAChB,oBAAC,gBAAD;GACE,WAAW,GACT,yGACA,gBACF;GACM;GACC;GACW;GAEjB,UAAA,gBACC,oBAAC,aAAD;IAAa,QAAQ;IAAe,GAAI;GAAyB,CAAA,IAEjE,oBAAC,aAAD;IAAoB;IAAO,GAAI;GAAyB,CAAA;EAE5C,CAAA,CACT;;AAEb;AAEA,SAAgB,OACd,OAC6B;CAC7B,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC"}
@@ -1,8 +1,8 @@
1
1
  import { Text } from "./Text/Text.js";
2
2
  import { Button } from "./Button/Button.js";
3
- import { MAX_TEXT_LENGTH } from "./Code/constants.js";
4
3
  import { getScrollParent } from "../utils/get-closest-scroll-parent.js";
5
4
  import { parseTextWithLinks } from "../utils/parseTextLinks.js";
5
+ import { MAX_TEXT_LENGTH } from "./Code/constants.js";
6
6
  import { TextVirtualizer } from "./TextVirtualizer.js";
7
7
  import { useMemo, useState } from "react";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -28,6 +28,8 @@ export { StatusBadge } from './StatusBadge/index.js';
28
28
  export type { StatusBadgeProps, StatusBadgeSize, StatusBadgeVariant, } from './StatusBadge/index.js';
29
29
  export { Banner } from './Banner/Banner.js';
30
30
  export type { BannerProps } from './Banner/Banner.js';
31
+ export { ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerToolbar, } from './ChatComposer/index.js';
32
+ export type { ChatComposerActionProps, ChatComposerAttachmentMenuProps, ChatComposerAttachmentProps, ChatComposerAttachmentsProps, ChatComposerContextValue, ChatComposerDrawerIntent, ChatComposerInputHandle, ChatComposerInputProps, ChatComposerModelSelectProps, ChatComposerProps, ChatComposerToolbarProps, } from './ChatComposer/index.js';
31
33
  export { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, } from './ChatMessage/index.js';
32
34
  export type { ChatMessageAction, ChatMessageActionCapabilities, ChatMessageActionsProps, ChatMessageBodyProps, ChatMessageContentBlock, ChatMessageHeaderProps, ChatMessageModel, ChatMessageProps, ChatMessageRole, ChatMessageStatus, ChatTurnDividerProps, } from './ChatMessage/index.js';
33
35
  export { Checkbox, getCheckedState } from './Checkbox/index.js';
@@ -17,6 +17,12 @@ import { Link } from "./Link/Link.js";
17
17
  import { EmptyState } from "./EmptyState/EmptyState.js";
18
18
  import { CircleSkeleton, Skeleton, SkeletonRows } from "./Skeleton/Skeleton.js";
19
19
  import { ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow } from "./ChartTooltip/ChartTooltip.js";
20
+ import { ChatComposerContext } from "./ChatComposer/ChatComposerContext.js";
21
+ import { ChatComposer, ChatComposerAction, ChatComposerToolbar } from "./ChatComposer/ChatComposer.js";
22
+ import { ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments } from "./ChatComposer/ChatComposerAttachments.js";
23
+ import { Textarea } from "./Textarea/Textarea.js";
24
+ import { ChatComposerInput } from "./ChatComposer/ChatComposerInput.js";
25
+ import { ChatComposerModelSelect } from "./ChatComposer/ChatComposerModelSelect.js";
20
26
  import { Divider } from "./Divider/Divider.js";
21
27
  import { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider } from "./ChatMessage/ChatMessage.js";
22
28
  import { Checkbox } from "./Checkbox/Checkbox.js";
@@ -40,5 +46,4 @@ import { RadioGroupItem } from "./RadioGroup/RadioGroupItem.js";
40
46
  import { Slider } from "./Slider/Slider.js";
41
47
  import { StatusBadge } from "./StatusBadge/StatusBadge.js";
42
48
  import { Switch } from "./Switch/Switch.js";
43
- import { Textarea } from "./Textarea/Textarea.js";
44
- export { Attachment, AttachmentList, Avatar, Badge, Banner, Breadcrumb, BreadcrumbLink, BreadcrumbPage, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
49
+ export { Attachment, AttachmentList, Avatar, Badge, Banner, Breadcrumb, BreadcrumbLink, BreadcrumbPage, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerToolbar, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
@@ -1,3 +1,5 @@
1
1
  /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
+ ._editor_1jx45_3 p.is-editor-empty:first-child:before{pointer-events:none;float:left;height:0;color:var(--text-placeholder);content:attr(data-placeholder)}._editor_1jx45_3 p{margin:0}._editor_1jx45_3>*+*{margin-top:.5rem}._editor_1jx45_3 h1,._editor_1jx45_3 h2,._editor_1jx45_3 h3,._editor_1jx45_3 h4,._editor_1jx45_3 h5,._editor_1jx45_3 h6{font-size:1rem;line-height:var(--tw-leading,1.5rem);--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600)}._editor_1jx45_3 ul{padding-left:1.5rem;list-style-type:disc;list-style-position:outside}._editor_1jx45_3 ol{padding-left:1.5rem;list-style-type:decimal;list-style-position:outside}._editor_1jx45_3 a{color:var(--text-link);text-underline-offset:2px;text-decoration-line:underline}._editor_1jx45_3 blockquote{border-left-style:var(--tw-border-style);border-left-width:2px;border-color:var(--border-default);color:var(--text-secondary);padding-left:.75rem}._editor_1jx45_3 :not(pre)>code{border-radius:var(--radius-sm);background-color:var(--bg-surface-level-2);padding-inline:.25rem;font-family:Fira Code,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}._editor_1jx45_3 pre code{background-color:#0000;padding:0}._editor_1jx45_3 hr{border-color:var(--border-default)}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}
3
+ /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
4
  ._grid_rs273_4{grid-template:repeat(3,minmax(0,1fr))/repeat(3,minmax(0,1fr));gap:10%;display:inline-grid}._pixel_rs273_10{opacity:.15;animation:_pixel-on_rs273_1 var(--loading-cycle) ease-in-out infinite;border-radius:1px}._dot_rs273_16{border-radius:var(--radius-full)}._inactive_rs273_20{opacity:.07;animation:none}._grid_rs273_4[data-animated=false] ._pixel_rs273_10{animation:none}._grid_rs273_4[data-animated=false] ._pixel_rs273_10:not(._inactive_rs273_20){opacity:.5}._shimmer_rs273_33{--macaw-shimmer-highlight:var(--text-primary);color:#0000;-webkit-background-clip:text;background-clip:text;background-image:linear-gradient(to right, var(--text-tertiary) 35%, var(--macaw-shimmer-highlight) 50%, var(--text-tertiary) 65%);background-size:200% 100%;animation:1.4s linear infinite _shimmer-text_rs273_1}._slow_rs273_46{animation-duration:2.8s}._brandShimmer_rs273_50{--macaw-shimmer-highlight:var(--text-brand-primary)}@keyframes _pixel-on_rs273_1{0%,to{opacity:.15}18%,42%{opacity:1}62%{opacity:.15}}@keyframes _shimmer-text_rs273_1{0%{background-position:150%}to{background-position:-50%}}@media (prefers-reduced-motion:reduce){._pixel_rs273_10,._shimmer_rs273_33{animation:none}._pixel_rs273_10:not(._inactive_rs273_20){opacity:.5}._shimmer_rs273_33{color:var(--text-secondary);background:0 0}}@media (forced-colors:active){._shimmer_rs273_33{color:canvastext;background:0 0}._pixel_rs273_10{background:canvastext}}
3
5
  /*$vite$:1*/
@@ -3,6 +3,7 @@ import { CaretUpDownIcon } from "@phosphor-icons/react/dist/ssr/CaretUpDown";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { InfoIcon } from "@phosphor-icons/react/dist/ssr/Info";
5
5
  import { PushPinIcon } from "@phosphor-icons/react/dist/ssr/PushPin";
6
+ import { WrenchIcon } from "@phosphor-icons/react/dist/ssr/Wrench";
6
7
  import { BinaryIcon } from "@phosphor-icons/react/dist/ssr/Binary";
7
8
  import { BriefcaseIcon } from "@phosphor-icons/react/dist/ssr/Briefcase";
8
9
  import { BuildingsIcon } from "@phosphor-icons/react/dist/ssr/Buildings";
@@ -36,7 +37,6 @@ import { StarIcon } from "@phosphor-icons/react/dist/ssr/Star";
36
37
  import { SunIcon } from "@phosphor-icons/react/dist/ssr/Sun";
37
38
  import { TagIcon } from "@phosphor-icons/react/dist/ssr/Tag";
38
39
  import { ToggleLeftIcon } from "@phosphor-icons/react/dist/ssr/ToggleLeft";
39
- import { WrenchIcon } from "@phosphor-icons/react/dist/ssr/Wrench";
40
40
  //#region packages/components/src/icons/LongTailPhosphorIcons.tsx
41
41
  var createWeightedIcon = (Icon, weight, displayName) => {
42
42
  const WeightedIcon = (props) => /* @__PURE__ */ jsx(Icon, {
@@ -4,10 +4,10 @@ import { jsx } from "react/jsx-runtime";
4
4
  import { CheckCircleIcon } from "@phosphor-icons/react/dist/ssr/CheckCircle";
5
5
  import { WarningIcon } from "@phosphor-icons/react/dist/ssr/Warning";
6
6
  import { MagnifyingGlassIcon } from "@phosphor-icons/react/dist/ssr/MagnifyingGlass";
7
+ import { WrenchIcon } from "@phosphor-icons/react/dist/ssr/Wrench";
7
8
  import { FileCodeIcon } from "@phosphor-icons/react/dist/ssr/FileCode";
8
9
  import { SquaresFourIcon } from "@phosphor-icons/react/dist/ssr/SquaresFour";
9
10
  import { StarIcon } from "@phosphor-icons/react/dist/ssr/Star";
10
- import { WrenchIcon } from "@phosphor-icons/react/dist/ssr/Wrench";
11
11
  import { AlarmIcon } from "@phosphor-icons/react/dist/ssr/Alarm";
12
12
  import { ArticleIcon } from "@phosphor-icons/react/dist/ssr/Article";
13
13
  import { ChartBarIcon } from "@phosphor-icons/react/dist/ssr/ChartBar";
package/dist/index.js CHANGED
@@ -17,6 +17,12 @@ import { Link } from "./components/Link/Link.js";
17
17
  import { EmptyState } from "./components/EmptyState/EmptyState.js";
18
18
  import { CircleSkeleton, Skeleton, SkeletonRows } from "./components/Skeleton/Skeleton.js";
19
19
  import { ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow } from "./components/ChartTooltip/ChartTooltip.js";
20
+ import { ChatComposerContext } from "./components/ChatComposer/ChatComposerContext.js";
21
+ import { ChatComposer, ChatComposerAction, ChatComposerToolbar } from "./components/ChatComposer/ChatComposer.js";
22
+ import { ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments } from "./components/ChatComposer/ChatComposerAttachments.js";
23
+ import { Textarea } from "./components/Textarea/Textarea.js";
24
+ import { ChatComposerInput } from "./components/ChatComposer/ChatComposerInput.js";
25
+ import { ChatComposerModelSelect } from "./components/ChatComposer/ChatComposerModelSelect.js";
20
26
  import { Divider } from "./components/Divider/Divider.js";
21
27
  import { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider } from "./components/ChatMessage/ChatMessage.js";
22
28
  import { Checkbox } from "./components/Checkbox/Checkbox.js";
@@ -40,6 +46,5 @@ import { RadioGroupItem } from "./components/RadioGroup/RadioGroupItem.js";
40
46
  import { Slider } from "./components/Slider/Slider.js";
41
47
  import { StatusBadge } from "./components/StatusBadge/StatusBadge.js";
42
48
  import { Switch } from "./components/Switch/Switch.js";
43
- import { Textarea } from "./components/Textarea/Textarea.js";
44
49
  import "./components/index.js";
45
- export { Attachment, AttachmentList, Avatar, Badge, Banner, Breadcrumb, BreadcrumbLink, BreadcrumbPage, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
50
+ export { Attachment, AttachmentList, Avatar, Badge, Banner, Breadcrumb, BreadcrumbLink, BreadcrumbPage, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatComposer, ChatComposerAction, ChatComposerAttachment, ChatComposerAttachmentMenu, ChatComposerAttachments, ChatComposerContext, ChatComposerInput, ChatComposerModelSelect, ChatComposerToolbar, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };