@copilotkit/react-ui 1.8.0-next.3 → 1.8.0-next.5

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 (95) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/{chunk-LXCH2BIB.mjs → chunk-6H7IQRIU.mjs} +2 -2
  3. package/dist/{chunk-KG6DW6R2.mjs → chunk-DFHFPZQD.mjs} +7 -7
  4. package/dist/{chunk-LKCAF2HG.mjs → chunk-FFNESJSG.mjs} +2 -2
  5. package/dist/{chunk-QGK5GOSC.mjs → chunk-GBXUOB6L.mjs} +8 -8
  6. package/dist/{chunk-2LRE4W6A.mjs → chunk-LYHZXHTJ.mjs} +3 -2
  7. package/dist/{chunk-2LRE4W6A.mjs.map → chunk-LYHZXHTJ.mjs.map} +1 -1
  8. package/dist/chunk-MMVDU6DF.mjs +1 -0
  9. package/dist/{chunk-GDJAAFIK.mjs → chunk-QS7UFQFD.mjs} +2 -2
  10. package/dist/{chunk-5GNYGURH.mjs → chunk-Z6YOBQUJ.mjs} +8 -8
  11. package/dist/components/chat/Chat.js +2 -1
  12. package/dist/components/chat/Chat.js.map +1 -1
  13. package/dist/components/chat/Chat.mjs +4 -4
  14. package/dist/components/chat/Header.mjs +4 -4
  15. package/dist/components/chat/Input.js +2 -1
  16. package/dist/components/chat/Input.js.map +1 -1
  17. package/dist/components/chat/Input.mjs +1 -1
  18. package/dist/components/chat/Modal.js +2 -1
  19. package/dist/components/chat/Modal.js.map +1 -1
  20. package/dist/components/chat/Modal.mjs +9 -9
  21. package/dist/components/chat/Popup.js +2 -1
  22. package/dist/components/chat/Popup.js.map +1 -1
  23. package/dist/components/chat/Popup.mjs +10 -10
  24. package/dist/components/chat/Sidebar.js +2 -1
  25. package/dist/components/chat/Sidebar.js.map +1 -1
  26. package/dist/components/chat/Sidebar.mjs +10 -10
  27. package/dist/components/chat/index.js +2 -1
  28. package/dist/components/chat/index.js.map +1 -1
  29. package/dist/components/chat/index.mjs +13 -13
  30. package/dist/components/dev-console/console.mjs +3 -3
  31. package/dist/components/dev-console/index.mjs +4 -4
  32. package/dist/components/index.d.ts +0 -3
  33. package/dist/components/index.js +2 -291
  34. package/dist/components/index.js.map +1 -1
  35. package/dist/components/index.mjs +15 -27
  36. package/dist/index.css +64 -42
  37. package/dist/index.css.map +1 -1
  38. package/dist/index.d.ts +0 -3
  39. package/dist/index.js +4 -293
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +15 -27
  42. package/dist/types/css.d.ts +4 -9
  43. package/dist/types/css.js.map +1 -1
  44. package/package.json +4 -4
  45. package/src/components/chat/Input.tsx +6 -1
  46. package/src/components/index.ts +0 -1
  47. package/src/css/button.css +1 -1
  48. package/src/css/colors.css +79 -23
  49. package/src/css/console.css +1 -1
  50. package/src/css/header.css +2 -2
  51. package/src/css/input.css +19 -10
  52. package/src/css/messages.css +2 -2
  53. package/src/css/panel.css +1 -1
  54. package/src/css/suggestions.css +2 -2
  55. package/src/types/css.ts +4 -9
  56. package/dist/chunk-EJG6RRSX.mjs +0 -138
  57. package/dist/chunk-EJG6RRSX.mjs.map +0 -1
  58. package/dist/chunk-MCO235PS.mjs +0 -164
  59. package/dist/chunk-MCO235PS.mjs.map +0 -1
  60. package/dist/chunk-MWC5OV7Z.mjs +0 -1
  61. package/dist/chunk-N7LTE54T.mjs +0 -1
  62. package/dist/chunk-N7LTE54T.mjs.map +0 -1
  63. package/dist/chunk-UCVCAGU7.mjs +0 -1
  64. package/dist/chunk-UCVCAGU7.mjs.map +0 -1
  65. package/dist/components/crew/DefaultResponseRenderer.d.ts +0 -110
  66. package/dist/components/crew/DefaultResponseRenderer.js +0 -175
  67. package/dist/components/crew/DefaultResponseRenderer.js.map +0 -1
  68. package/dist/components/crew/DefaultResponseRenderer.mjs +0 -10
  69. package/dist/components/crew/DefaultResponseRenderer.mjs.map +0 -1
  70. package/dist/components/crew/DefaultStateRenderer.d.ts +0 -88
  71. package/dist/components/crew/DefaultStateRenderer.js +0 -198
  72. package/dist/components/crew/DefaultStateRenderer.js.map +0 -1
  73. package/dist/components/crew/DefaultStateRenderer.mjs +0 -8
  74. package/dist/components/crew/DefaultStateRenderer.mjs.map +0 -1
  75. package/dist/components/crew/index.d.ts +0 -4
  76. package/dist/components/crew/index.js +0 -335
  77. package/dist/components/crew/index.js.map +0 -1
  78. package/dist/components/crew/index.mjs +0 -16
  79. package/dist/components/crew/index.mjs.map +0 -1
  80. package/dist/components/crew/types.d.ts +0 -340
  81. package/dist/components/crew/types.js +0 -19
  82. package/dist/components/crew/types.js.map +0 -1
  83. package/dist/components/crew/types.mjs +0 -2
  84. package/dist/components/crew/types.mjs.map +0 -1
  85. package/src/components/crew/DefaultResponseRenderer.tsx +0 -298
  86. package/src/components/crew/DefaultStateRenderer.tsx +0 -326
  87. package/src/components/crew/index.ts +0 -3
  88. package/src/components/crew/types.ts +0 -398
  89. /package/dist/{chunk-LXCH2BIB.mjs.map → chunk-6H7IQRIU.mjs.map} +0 -0
  90. /package/dist/{chunk-KG6DW6R2.mjs.map → chunk-DFHFPZQD.mjs.map} +0 -0
  91. /package/dist/{chunk-LKCAF2HG.mjs.map → chunk-FFNESJSG.mjs.map} +0 -0
  92. /package/dist/{chunk-QGK5GOSC.mjs.map → chunk-GBXUOB6L.mjs.map} +0 -0
  93. /package/dist/{chunk-MWC5OV7Z.mjs.map → chunk-MMVDU6DF.mjs.map} +0 -0
  94. /package/dist/{chunk-GDJAAFIK.mjs.map → chunk-QS7UFQFD.mjs.map} +0 -0
  95. /package/dist/{chunk-5GNYGURH.mjs.map → chunk-Z6YOBQUJ.mjs.map} +0 -0
@@ -1,164 +0,0 @@
1
- import {
2
- __spreadValues
3
- } from "./chunk-MRXNTQOX.mjs";
4
-
5
- // src/components/crew/DefaultStateRenderer.tsx
6
- import { useState, useRef, useEffect, useMemo } from "react";
7
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
- var DefaultExpandIcon = ({ className }) => /* @__PURE__ */ jsx(
9
- "svg",
10
- {
11
- className,
12
- width: "16",
13
- height: "16",
14
- viewBox: "0 0 24 24",
15
- fill: "none",
16
- stroke: "currentColor",
17
- strokeWidth: "2",
18
- strokeLinecap: "round",
19
- strokeLinejoin: "round",
20
- children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
21
- }
22
- );
23
- var DefaultCollapseIcon = ({ className }) => /* @__PURE__ */ jsx(
24
- "svg",
25
- {
26
- className,
27
- width: "16",
28
- height: "16",
29
- viewBox: "0 0 24 24",
30
- fill: "none",
31
- stroke: "currentColor",
32
- strokeWidth: "2",
33
- strokeLinecap: "round",
34
- strokeLinejoin: "round",
35
- children: /* @__PURE__ */ jsx("polyline", { points: "18 15 12 9 6 15" })
36
- }
37
- );
38
- var DefaultLoaderIcon = ({ className }) => /* @__PURE__ */ jsx(
39
- "svg",
40
- {
41
- className: `${className} copilotkit-spinner`,
42
- width: "16",
43
- height: "16",
44
- viewBox: "0 0 24 24",
45
- fill: "none",
46
- stroke: "currentColor",
47
- strokeWidth: "2",
48
- strokeLinecap: "round",
49
- strokeLinejoin: "round",
50
- children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
51
- }
52
- );
53
- var formatContent = (result) => {
54
- if (result === null || result === void 0)
55
- return "";
56
- return typeof result === "string" ? result : JSON.stringify(result, null, 2);
57
- };
58
- var DefaultSkeletonLoader = ({ className }) => /* @__PURE__ */ jsxs("div", { className: className || "copilotkit-skeleton", children: [
59
- /* @__PURE__ */ jsxs("div", { className: "copilotkit-skeleton-header", children: [
60
- /* @__PURE__ */ jsx("div", { className: "copilotkit-skeleton-title" }),
61
- /* @__PURE__ */ jsx("div", { className: "copilotkit-skeleton-subtitle" })
62
- ] }),
63
- /* @__PURE__ */ jsx("div", { className: "copilotkit-skeleton-content" })
64
- ] });
65
- var DefaultStateItemRenderer = ({
66
- item,
67
- isNewest,
68
- className
69
- }) => /* @__PURE__ */ jsxs(
70
- "div",
71
- {
72
- className: `${className || "copilotkit-state-item"} ${isNewest ? "copilotkit-state-item-newest" : ""}`,
73
- children: [
74
- /* @__PURE__ */ jsx("div", { className: "copilotkit-state-item-header", children: "tool" in item ? item.tool : item.name }),
75
- "thought" in item && item.thought && /* @__PURE__ */ jsx("div", { className: "copilotkit-state-item-thought", children: item.thought }),
76
- "result" in item && item.result !== void 0 && item.result !== null && /* @__PURE__ */ jsx("div", { className: "copilotkit-state-item-result", children: formatContent(item.result) }),
77
- "description" in item && item.description && /* @__PURE__ */ jsx("div", { className: "copilotkit-state-item-description", children: item.description })
78
- ]
79
- }
80
- );
81
- var DefaultStateRenderer = ({
82
- state,
83
- status,
84
- StateItemRenderer = DefaultStateItemRenderer,
85
- SkeletonLoader = DefaultSkeletonLoader,
86
- labels,
87
- icons,
88
- className = "copilotkit-state",
89
- contentClassName = "copilotkit-state-content",
90
- itemClassName = "copilotkit-state-item",
91
- maxHeight = "250px",
92
- defaultCollapsed = true
93
- }) => {
94
- const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed);
95
- const contentRef = useRef(null);
96
- const prevItemsLengthRef = useRef(0);
97
- const [newestItemId, setNewestItemId] = useState(null);
98
- const defaultLabels = {
99
- inProgressLabel: "Analyzing",
100
- completeLabel: "Analyzed",
101
- emptyLabel: "No activity"
102
- };
103
- const mergedLabels = __spreadValues(__spreadValues({}, defaultLabels), labels);
104
- const ExpandIcon = (icons == null ? void 0 : icons.expand) || DefaultExpandIcon;
105
- const CollapseIcon = (icons == null ? void 0 : icons.collapse) || DefaultCollapseIcon;
106
- const items = useMemo(() => {
107
- var _a;
108
- return state ? [...((_a = state.steps) == null ? void 0 : _a.filter((s) => s.tool)) || [], ...state.tasks || []].sort(
109
- (a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
110
- ) : [];
111
- }, [state]);
112
- const isThinking = status === "inProgress" && items.length === 0;
113
- useEffect(() => {
114
- if (!state)
115
- return;
116
- if (items.length > prevItemsLengthRef.current) {
117
- if (items.length > 0) {
118
- const newest = items[items.length - 1];
119
- setNewestItemId(newest.id);
120
- setTimeout(() => {
121
- setNewestItemId(null);
122
- }, 1500);
123
- }
124
- if (contentRef.current && !isCollapsed) {
125
- contentRef.current.scrollTop = contentRef.current.scrollHeight;
126
- }
127
- }
128
- prevItemsLengthRef.current = items.length;
129
- }, [items, isCollapsed, state]);
130
- if (!state) {
131
- return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(DefaultLoaderIcon, { className: "copilotkit-loader" }) });
132
- }
133
- if (isCollapsed && items.length === 0 && !isThinking)
134
- return null;
135
- return /* @__PURE__ */ jsxs("div", { className, children: [
136
- /* @__PURE__ */ jsxs("div", { className: "copilotkit-state-header", onClick: () => setIsCollapsed(!isCollapsed), children: [
137
- isCollapsed ? /* @__PURE__ */ jsx(ExpandIcon, { className: "copilotkit-icon" }) : /* @__PURE__ */ jsx(CollapseIcon, { className: "copilotkit-icon" }),
138
- /* @__PURE__ */ jsx("div", { className: "copilotkit-state-label", children: status === "inProgress" ? /* @__PURE__ */ jsx("span", { className: "copilotkit-state-label-loading", children: mergedLabels.inProgressLabel }) : mergedLabels.completeLabel })
139
- ] }),
140
- !isCollapsed && /* @__PURE__ */ jsx("div", { ref: contentRef, className: contentClassName, style: { maxHeight }, children: items.length > 0 ? items.map((item) => /* @__PURE__ */ jsx(
141
- StateItemRenderer,
142
- {
143
- item,
144
- isNewest: item.id === newestItemId,
145
- className: itemClassName
146
- },
147
- item.id
148
- )) : isThinking ? (
149
- // Show skeleton loader while thinking
150
- /* @__PURE__ */ jsxs(Fragment, { children: [
151
- /* @__PURE__ */ jsx(SkeletonLoader, {}),
152
- /* @__PURE__ */ jsx(SkeletonLoader, {})
153
- ] })
154
- ) : (
155
- // Empty state
156
- /* @__PURE__ */ jsx("div", { className: "copilotkit-state-empty", children: mergedLabels.emptyLabel })
157
- ) })
158
- ] });
159
- };
160
-
161
- export {
162
- DefaultStateRenderer
163
- };
164
- //# sourceMappingURL=chunk-MCO235PS.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/crew/DefaultStateRenderer.tsx"],"sourcesContent":["/**\n * <br/>\n * A state renderer component for the CopilotKit framework. This component displays\n * the internal state of an agent, such as the steps it has taken and the tasks it has performed.\n * It provides a collapsible UI that shows the agent's thought process and actions.\n *\n * ## Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ## Usage\n *\n * ```tsx\n * import { DefaultStateRenderer } from \"@copilotkit/react-ui\";\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * // Basic usage\n * <DefaultStateRenderer\n * state={agentState}\n * status=\"inProgress\"\n * />\n * ```\n *\n * ## Customization\n *\n * You can customize the appearance and behavior of the component:\n *\n * ```tsx\n * // Custom labels and styling\n * <DefaultStateRenderer\n * state={agentState}\n * status=\"inProgress\"\n * labels={{\n * inProgressLabel: \"Thinking...\",\n * completeLabel: \"Finished processing\",\n * emptyLabel: \"Nothing to show\"\n * }}\n * className=\"my-custom-state\"\n * contentClassName=\"my-custom-content\"\n * itemClassName=\"my-custom-item\"\n * maxHeight=\"300px\"\n * defaultCollapsed={false}\n * />\n *\n * // Custom renderers\n * <DefaultStateRenderer\n * state={agentState}\n * status=\"inProgress\"\n * StateItemRenderer={({ item, isNewest, className }) => (\n * <MyCustomItemRenderer item={item} isNewest={isNewest} className={className} />\n * )}\n * SkeletonLoader={({ className }) => (\n * <MyCustomSkeletonLoader className={className} />\n * )}\n * />\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx title=\"YourRootComponent.tsx\"\n * ...\n * import \"@copilotkit/react-ui/styles.css\"; // [!code highlight]\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.\n */\n\nimport React, { useState, useRef, useEffect, useMemo } from \"react\";\nimport {\n AgentState,\n StateRendererProps,\n StateItemRendererProps,\n SkeletonLoaderProps,\n ToolStateItem,\n TaskStateItem,\n ResponseRendererIconProps,\n} from \"./types\";\n\n/**\n * Default expand icon component\n */\nconst DefaultExpandIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6 9 12 15 18 9\"></polyline>\n </svg>\n);\n\n/**\n * Default collapse icon component\n */\nconst DefaultCollapseIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"18 15 12 9 6 15\"></polyline>\n </svg>\n);\n\n/**\n * Default loader icon component\n */\nconst DefaultLoaderIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={`${className} copilotkit-spinner`}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21 12a9 9 0 1 1-6.219-8.56\"></path>\n </svg>\n);\n\n/**\n * Helper to safely format content\n */\nconst formatContent = (result: unknown): string => {\n if (result === null || result === undefined) return \"\";\n return typeof result === \"string\" ? result : JSON.stringify(result, null, 2);\n};\n\n/**\n * Default skeleton loader component\n */\nconst DefaultSkeletonLoader: React.FC<SkeletonLoaderProps> = ({ className }) => (\n <div className={className || \"copilotkit-skeleton\"}>\n <div className=\"copilotkit-skeleton-header\">\n <div className=\"copilotkit-skeleton-title\"></div>\n <div className=\"copilotkit-skeleton-subtitle\"></div>\n </div>\n <div className=\"copilotkit-skeleton-content\"></div>\n </div>\n);\n\n/**\n * Default state item renderer component\n */\nconst DefaultStateItemRenderer: React.FC<StateItemRendererProps> = ({\n item,\n isNewest,\n className,\n}) => (\n <div\n className={`${className || \"copilotkit-state-item\"} ${isNewest ? \"copilotkit-state-item-newest\" : \"\"}`}\n >\n <div className=\"copilotkit-state-item-header\">{\"tool\" in item ? item.tool : item.name}</div>\n\n {\"thought\" in item && item.thought && (\n <div className=\"copilotkit-state-item-thought\">{item.thought}</div>\n )}\n\n {\"result\" in item && item.result !== undefined && item.result !== null && (\n <div className=\"copilotkit-state-item-result\">{formatContent(item.result)}</div>\n )}\n\n {\"description\" in item && item.description && (\n <div className=\"copilotkit-state-item-description\">{item.description}</div>\n )}\n </div>\n);\n\n/**\n * Default state renderer component\n */\nexport const DefaultStateRenderer: React.FC<StateRendererProps> = ({\n state,\n status,\n StateItemRenderer = DefaultStateItemRenderer,\n SkeletonLoader = DefaultSkeletonLoader,\n labels,\n icons,\n className = \"copilotkit-state\",\n contentClassName = \"copilotkit-state-content\",\n itemClassName = \"copilotkit-state-item\",\n maxHeight = \"250px\",\n defaultCollapsed = true,\n}) => {\n const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed);\n const contentRef = useRef<HTMLDivElement>(null);\n const prevItemsLengthRef = useRef<number>(0);\n const [newestItemId, setNewestItemId] = useState<string | null>(null);\n\n // Default label values\n const defaultLabels = {\n inProgressLabel: \"Analyzing\",\n completeLabel: \"Analyzed\",\n emptyLabel: \"No activity\",\n };\n\n // Merge provided labels with defaults\n const mergedLabels = { ...defaultLabels, ...labels };\n\n // Decide which icon to display\n const ExpandIcon = icons?.expand || DefaultExpandIcon;\n const CollapseIcon = icons?.collapse || DefaultCollapseIcon;\n\n // Safely compute derived values using useMemo\n const items = useMemo(() => {\n return state\n ? [...(state.steps?.filter((s) => s.tool) || []), ...(state.tasks || [])].sort(\n (a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),\n )\n : [];\n }, [state]);\n\n // Determine if we should show skeleton UI (thinking but no items yet)\n const isThinking = status === \"inProgress\" && items.length === 0;\n\n // Track newest item and auto-scroll\n useEffect(() => {\n if (!state) return; // Skip effect if no state\n\n // If new items were added\n if (items.length > prevItemsLengthRef.current) {\n // Get the newest item\n if (items.length > 0) {\n const newest = items[items.length - 1];\n setNewestItemId(newest.id);\n\n // Clear the animation after 1.5 seconds\n setTimeout(() => {\n setNewestItemId(null);\n }, 1500);\n }\n\n // Auto-scroll to bottom\n if (contentRef.current && !isCollapsed) {\n contentRef.current.scrollTop = contentRef.current.scrollHeight;\n }\n }\n\n prevItemsLengthRef.current = items.length;\n }, [items, isCollapsed, state]);\n\n // Early return for loading state with no state\n if (!state) {\n return (\n <div className={className}>\n <DefaultLoaderIcon className=\"copilotkit-loader\" />\n </div>\n );\n }\n\n // Don't render anything if collapsed and empty and not thinking\n if (isCollapsed && items.length === 0 && !isThinking) return null;\n\n return (\n <div className={className}>\n {/* Header with toggle */}\n <div className=\"copilotkit-state-header\" onClick={() => setIsCollapsed(!isCollapsed)}>\n {isCollapsed ? (\n <ExpandIcon className=\"copilotkit-icon\" />\n ) : (\n <CollapseIcon className=\"copilotkit-icon\" />\n )}\n <div className=\"copilotkit-state-label\">\n {status === \"inProgress\" ? (\n <span className=\"copilotkit-state-label-loading\">{mergedLabels.inProgressLabel}</span>\n ) : (\n mergedLabels.completeLabel\n )}\n </div>\n </div>\n\n {/* Content area */}\n {!isCollapsed && (\n <div ref={contentRef} className={contentClassName} style={{ maxHeight }}>\n {/* Render items if available */}\n {items.length > 0 ? (\n items.map((item) => (\n <StateItemRenderer\n key={item.id}\n item={item}\n isNewest={item.id === newestItemId}\n className={itemClassName}\n />\n ))\n ) : isThinking ? (\n // Show skeleton loader while thinking\n <>\n <SkeletonLoader />\n <SkeletonLoader />\n </>\n ) : (\n // Empty state\n <div className=\"copilotkit-state-empty\">{mergedLabels.emptyLabel}</div>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;AA+EA,SAAgB,UAAU,QAAQ,WAAW,eAAe;AA0BxD,SAgNQ,UAhNR,KAuDA,YAvDA;AAZJ,IAAM,oBAAyD,CAAC,EAAE,UAAU,MAC1E;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,MAAK;AAAA,IACL,QAAO;AAAA,IACP,aAAY;AAAA,IACZ,eAAc;AAAA,IACd,gBAAe;AAAA,IAEf,8BAAC,cAAS,QAAO,kBAAiB;AAAA;AACpC;AAMF,IAAM,sBAA2D,CAAC,EAAE,UAAU,MAC5E;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,MAAK;AAAA,IACL,QAAO;AAAA,IACP,aAAY;AAAA,IACZ,eAAc;AAAA,IACd,gBAAe;AAAA,IAEf,8BAAC,cAAS,QAAO,mBAAkB;AAAA;AACrC;AAMF,IAAM,oBAAyD,CAAC,EAAE,UAAU,MAC1E;AAAA,EAAC;AAAA;AAAA,IACC,WAAW,GAAG;AAAA,IACd,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,MAAK;AAAA,IACL,QAAO;AAAA,IACP,aAAY;AAAA,IACZ,eAAc;AAAA,IACd,gBAAe;AAAA,IAEf,8BAAC,UAAK,GAAE,+BAA8B;AAAA;AACxC;AAMF,IAAM,gBAAgB,CAAC,WAA4B;AACjD,MAAI,WAAW,QAAQ,WAAW;AAAW,WAAO;AACpD,SAAO,OAAO,WAAW,WAAW,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC;AAC7E;AAKA,IAAM,wBAAuD,CAAC,EAAE,UAAU,MACxE,qBAAC,S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0BACZ,qBAAW,eACV,oBAAC,UAAK,WAAU,kCAAkC,uBAAa,iBAAgB,IAE/E,aAAa,eAEjB;AAAA,OACF;AAAA,IAGC,CAAC,eACA,oBAAC,SAAI,KAAK,YAAY,WAAW,kBAAkB,OAAO,EAAE,UAAU,GAEnE,gBAAM,SAAS,IACd,MAAM,IAAI,CAAC,SACT;AAAA,MAAC;AAAA;AAAA,QAEC;AAAA,QACA,UAAU,KAAK,OAAO;AAAA,QACtB,WAAW;AAAA;AAAA,MAHN,KAAK;AAAA,IAIZ,CACD,IACC;AAAA;AAAA,MAEF,iCACE;AAAA,4BAAC,kBAAe;AAAA,QAChB,oBAAC,kBAAe;AAAA,SAClB;AAAA;AAAA;AAAA,MAGA,oBAAC,SAAI,WAAU,0BAA0B,uBAAa,YAAW;AAAA,OAErE;AAAA,KAEJ;AAEJ;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-MWC5OV7Z.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-N7LTE54T.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-UCVCAGU7.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,110 +0,0 @@
1
- import React__default from 'react';
2
- import { ResponseRendererProps } from './types.js';
3
-
4
- /**
5
- * <br/>
6
- * A response renderer component for the CopilotKit framework. This component displays
7
- * a response that may require user feedback, such as approving or rejecting a suggestion.
8
- * It provides a flexible, customizable interface for rendering responses with user interaction.
9
- *
10
- * ## Install Dependencies
11
- *
12
- * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
13
- *
14
- * ```shell npm2yarn \"@copilotkit/react-ui"\
15
- * npm install @copilotkit/react-core @copilotkit/react-ui
16
- * ```
17
- *
18
- * ## Usage
19
- *
20
- * ```tsx
21
- * import { DefaultResponseRenderer } from "@copilotkit/react-ui";
22
- * import "@copilotkit/react-ui/styles.css";
23
- *
24
- * // Basic usage
25
- * <DefaultResponseRenderer
26
- * response={{
27
- * id: "response-1",
28
- * content: "I've analyzed your data and found these insights..."
29
- * }}
30
- * status="inProgress"
31
- * onRespond={(input) => console.log(`User responded: ${input}`)}
32
- * />
33
- * ```
34
- *
35
- * ## Customization
36
- *
37
- * You can customize the appearance and behavior of the component:
38
- *
39
- * ```tsx
40
- * // Custom labels and styling
41
- * <DefaultResponseRenderer
42
- * response={{
43
- * id: "task-123",
44
- * content: "Would you like to proceed with this recommendation?"
45
- * }}
46
- * status="inProgress"
47
- * onRespond={handleResponse}
48
- * labels={{
49
- * responseLabel: "AI Recommendation",
50
- * approveLabel: "Yes, proceed",
51
- * rejectLabel: "No, cancel",
52
- * approvedMessage: "Proceeding with recommendation",
53
- * rejectedMessage: "Recommendation cancelled"
54
- * }}
55
- * className="my-custom-response"
56
- * contentClassName="my-custom-content"
57
- * buttonClassName="my-custom-button"
58
- * />
59
- *
60
- * // Custom components
61
- * <DefaultResponseRenderer
62
- * response={{
63
- * id: "task-456",
64
- * content: "# Important Decision\nThis requires your approval"
65
- * }}
66
- * status="inProgress"
67
- * onRespond={handleResponse}
68
- * ContentRenderer={({ content, className }) => (
69
- * <MyMarkdownRenderer content={content} className={className} />
70
- * )}
71
- * FeedbackButton={({ label, onClick, className }) => (
72
- * <MyCustomButton label={label} onClick={onClick} className={className} />
73
- * )}
74
- * />
75
- * ```
76
- *
77
- * ### Look & Feel
78
- *
79
- * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
80
- * ```tsx title="YourRootComponent.tsx"
81
- * ...
82
- * import "@copilotkit/react-ui/styles.css"; // [!code highlight]
83
- *
84
- * export function YourRootComponent() {
85
- * return (
86
- * <CopilotKit>
87
- * ...
88
- * </CopilotKit>
89
- * );
90
- * }
91
- * ```
92
- * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.
93
- */
94
-
95
- /**
96
- * Creates a cache for storing response feedback
97
- */
98
- declare const createResponseCache: <T extends {
99
- id: string;
100
- }>() => {
101
- getResponse: (id: string) => T | undefined;
102
- setResponse: (id: string, response: T) => Map<string, T>;
103
- };
104
- /**
105
- * Default response renderer component that handles rendering responses
106
- * and collecting user feedback
107
- */
108
- declare const DefaultResponseRenderer: React__default.FC<ResponseRendererProps>;
109
-
110
- export { DefaultResponseRenderer, createResponseCache };
@@ -1,175 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
- var __export = (target, all) => {
24
- for (var name in all)
25
- __defProp(target, name, { get: all[name], enumerable: true });
26
- };
27
- var __copyProps = (to, from, except, desc) => {
28
- if (from && typeof from === "object" || typeof from === "function") {
29
- for (let key of __getOwnPropNames(from))
30
- if (!__hasOwnProp.call(to, key) && key !== except)
31
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
- }
33
- return to;
34
- };
35
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
-
37
- // src/components/crew/DefaultResponseRenderer.tsx
38
- var DefaultResponseRenderer_exports = {};
39
- __export(DefaultResponseRenderer_exports, {
40
- DefaultResponseRenderer: () => DefaultResponseRenderer,
41
- createResponseCache: () => createResponseCache
42
- });
43
- module.exports = __toCommonJS(DefaultResponseRenderer_exports);
44
- var import_react = require("react");
45
- var import_jsx_runtime = require("react/jsx-runtime");
46
- var createResponseCache = () => {
47
- const responseCache = /* @__PURE__ */ new Map();
48
- return {
49
- getResponse: (id) => responseCache.get(id),
50
- setResponse: (id, response) => responseCache.set(id, response)
51
- };
52
- };
53
- var useResponseCache = createResponseCache();
54
- var DefaultExpandIcon = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
- "svg",
56
- {
57
- className,
58
- width: "12",
59
- height: "12",
60
- viewBox: "0 0 24 24",
61
- fill: "none",
62
- stroke: "currentColor",
63
- strokeWidth: "2",
64
- strokeLinecap: "round",
65
- strokeLinejoin: "round",
66
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "6 9 12 15 18 9" })
67
- }
68
- );
69
- var DefaultCollapseIcon = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
- "svg",
71
- {
72
- className,
73
- width: "12",
74
- height: "12",
75
- viewBox: "0 0 24 24",
76
- fill: "none",
77
- stroke: "currentColor",
78
- strokeWidth: "2",
79
- strokeLinecap: "round",
80
- strokeLinejoin: "round",
81
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "18 15 12 9 6 15" })
82
- }
83
- );
84
- var DefaultContentRenderer = ({ content, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, children: content });
85
- var DefaultFeedbackButton = ({ label, onClick, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { onClick, className, children: label });
86
- var DefaultCompletedFeedback = ({ message, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: message }) });
87
- var DefaultResponseRenderer = ({
88
- response,
89
- status,
90
- onRespond,
91
- icons,
92
- labels,
93
- ContentRenderer = DefaultContentRenderer,
94
- FeedbackButton = DefaultFeedbackButton,
95
- CompletedFeedback = DefaultCompletedFeedback,
96
- className = "copilotkit-response",
97
- contentClassName = "copilotkit-response-content",
98
- actionsClassName = "copilotkit-response-actions",
99
- buttonClassName = "copilotkit-response-button",
100
- completedFeedbackClassName = "copilotkit-response-completed-feedback"
101
- }) => {
102
- const [isExpanded, setIsExpanded] = (0, import_react.useState)(true);
103
- const defaultLabels = {
104
- responseLabel: "Response",
105
- approveLabel: "Approve",
106
- rejectLabel: "Reject",
107
- approvedMessage: "Approved",
108
- rejectedMessage: "Rejected",
109
- feedbackSubmittedMessage: "Feedback submitted"
110
- };
111
- const mergedLabels = __spreadValues(__spreadValues({}, defaultLabels), labels);
112
- const renderFeedback = () => {
113
- if (status === "complete") {
114
- const cachedResponse = useResponseCache.getResponse(response.id);
115
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
116
- CompletedFeedback,
117
- {
118
- message: (cachedResponse == null ? void 0 : cachedResponse.__feedback__) ? cachedResponse.__feedback__ === mergedLabels.approvedMessage ? mergedLabels.approvedMessage : mergedLabels.rejectedMessage : mergedLabels.feedbackSubmittedMessage,
119
- className: completedFeedbackClassName
120
- }
121
- );
122
- }
123
- if (status === "inProgress" || status === "executing") {
124
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
125
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
126
- FeedbackButton,
127
- {
128
- label: mergedLabels.approveLabel,
129
- onClick: () => {
130
- setIsExpanded(false);
131
- onRespond == null ? void 0 : onRespond(mergedLabels.approveLabel);
132
- useResponseCache.setResponse(response.id, __spreadProps(__spreadValues({}, response), {
133
- __feedback__: mergedLabels.approvedMessage
134
- }));
135
- },
136
- className: buttonClassName
137
- }
138
- ),
139
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
140
- FeedbackButton,
141
- {
142
- label: mergedLabels.rejectLabel,
143
- onClick: () => {
144
- setIsExpanded(false);
145
- useResponseCache.setResponse(response.id, __spreadProps(__spreadValues({}, response), {
146
- __feedback__: mergedLabels.rejectedMessage
147
- }));
148
- onRespond == null ? void 0 : onRespond(mergedLabels.rejectLabel);
149
- },
150
- className: buttonClassName
151
- }
152
- )
153
- ] });
154
- }
155
- return null;
156
- };
157
- const ExpandIcon = (icons == null ? void 0 : icons.expand) || DefaultExpandIcon;
158
- const CollapseIcon = (icons == null ? void 0 : icons.collapse) || DefaultCollapseIcon;
159
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className, children: [
160
- isExpanded && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentRenderer, { content: response.content, className: contentClassName }),
161
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: actionsClassName, children: [
162
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "copilotkit-response-label", children: [
163
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { onClick: () => setIsExpanded(!isExpanded), className: "copilotkit-toggle-button", children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollapseIcon, { className: "copilotkit-icon" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, { className: "copilotkit-icon" }) }),
164
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: mergedLabels.responseLabel })
165
- ] }),
166
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "copilotkit-response-buttons", children: renderFeedback() })
167
- ] })
168
- ] });
169
- };
170
- // Annotate the CommonJS export names for ESM import in node:
171
- 0 && (module.exports = {
172
- DefaultResponseRenderer,
173
- createResponseCache
174
- });
175
- //# sourceMappingURL=DefaultResponseRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/crew/DefaultResponseRenderer.tsx"],"sourcesContent":["/**\n * <br/>\n * A response renderer component for the CopilotKit framework. This component displays\n * a response that may require user feedback, such as approving or rejecting a suggestion.\n * It provides a flexible, customizable interface for rendering responses with user interaction.\n *\n * ## Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ## Usage\n *\n * ```tsx\n * import { DefaultResponseRenderer } from \"@copilotkit/react-ui\";\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * // Basic usage\n * <DefaultResponseRenderer\n * response={{\n * id: \"response-1\",\n * content: \"I've analyzed your data and found these insights...\"\n * }}\n * status=\"inProgress\"\n * onRespond={(input) => console.log(`User responded: ${input}`)}\n * />\n * ```\n *\n * ## Customization\n *\n * You can customize the appearance and behavior of the component:\n *\n * ```tsx\n * // Custom labels and styling\n * <DefaultResponseRenderer\n * response={{\n * id: \"task-123\",\n * content: \"Would you like to proceed with this recommendation?\"\n * }}\n * status=\"inProgress\"\n * onRespond={handleResponse}\n * labels={{\n * responseLabel: \"AI Recommendation\",\n * approveLabel: \"Yes, proceed\",\n * rejectLabel: \"No, cancel\",\n * approvedMessage: \"Proceeding with recommendation\",\n * rejectedMessage: \"Recommendation cancelled\"\n * }}\n * className=\"my-custom-response\"\n * contentClassName=\"my-custom-content\"\n * buttonClassName=\"my-custom-button\"\n * />\n *\n * // Custom components\n * <DefaultResponseRenderer\n * response={{\n * id: \"task-456\",\n * content: \"# Important Decision\\nThis requires your approval\"\n * }}\n * status=\"inProgress\"\n * onRespond={handleResponse}\n * ContentRenderer={({ content, className }) => (\n * <MyMarkdownRenderer content={content} className={className} />\n * )}\n * FeedbackButton={({ label, onClick, className }) => (\n * <MyCustomButton label={label} onClick={onClick} className={className} />\n * )}\n * />\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx title=\"YourRootComponent.tsx\"\n * ...\n * import \"@copilotkit/react-ui/styles.css\"; // [!code highlight]\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.\n */\n\nimport React, { useState } from \"react\";\nimport {\n Response,\n ResponseRendererProps,\n ContentRendererProps,\n FeedbackButtonProps,\n CompletedFeedbackProps,\n ResponseRendererIconProps,\n} from \"./types\";\n\n/**\n * Creates a cache for storing response feedback\n */\nconst createResponseCache = <T extends { id: string }>() => {\n const responseCache = new Map<string, T>();\n\n return {\n getResponse: (id: string) => responseCache.get(id),\n setResponse: (id: string, response: T) => responseCache.set(id, response),\n };\n};\n\n/**\n * Default global response cache instance\n */\nconst useResponseCache = createResponseCache<Response & { __feedback__?: string }>();\n\n/**\n * Default expand icon component\n */\nconst DefaultExpandIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={className}\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6 9 12 15 18 9\"></polyline>\n </svg>\n);\n\n/**\n * Default collapse icon component\n */\nconst DefaultCollapseIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={className}\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"18 15 12 9 6 15\"></polyline>\n </svg>\n);\n\n/**\n * Default content renderer that simply displays text\n */\nconst DefaultContentRenderer: React.FC<ContentRendererProps> = ({ content, className }) => (\n <div className={className}>{content}</div>\n);\n\n/**\n * Default feedback button component\n */\nconst DefaultFeedbackButton: React.FC<FeedbackButtonProps> = ({ label, onClick, className }) => (\n <button onClick={onClick} className={className}>\n {label}\n </button>\n);\n\n/**\n * Default completed feedback component\n */\nconst DefaultCompletedFeedback: React.FC<CompletedFeedbackProps> = ({ message, className }) => (\n <div className={className}>\n <span>{message}</span>\n </div>\n);\n\n/**\n * Default response renderer component that handles rendering responses\n * and collecting user feedback\n */\nexport const DefaultResponseRenderer: React.FC<ResponseRendererProps> = ({\n response,\n status,\n onRespond,\n icons,\n labels,\n ContentRenderer = DefaultContentRenderer,\n FeedbackButton = DefaultFeedbackButton,\n CompletedFeedback = DefaultCompletedFeedback,\n className = \"copilotkit-response\",\n contentClassName = \"copilotkit-response-content\",\n actionsClassName = \"copilotkit-response-actions\",\n buttonClassName = \"copilotkit-response-button\",\n completedFeedbackClassName = \"copilotkit-response-completed-feedback\",\n}) => {\n const [isExpanded, setIsExpanded] = useState(true);\n\n // Default label values\n const defaultLabels = {\n responseLabel: \"Response\",\n approveLabel: \"Approve\",\n rejectLabel: \"Reject\",\n approvedMessage: \"Approved\",\n rejectedMessage: \"Rejected\",\n feedbackSubmittedMessage: \"Feedback submitted\",\n };\n\n // Merge provided labels with defaults\n const mergedLabels = { ...defaultLabels, ...labels };\n\n // Function to render feedback UI based on status\n const renderFeedback = () => {\n if (status === \"complete\") {\n const cachedResponse = useResponseCache.getResponse(response.id);\n return (\n <CompletedFeedback\n message={\n cachedResponse?.__feedback__\n ? cachedResponse.__feedback__ === mergedLabels.approvedMessage\n ? mergedLabels.approvedMessage\n : mergedLabels.rejectedMessage\n : mergedLabels.feedbackSubmittedMessage\n }\n className={completedFeedbackClassName}\n />\n );\n }\n\n if (status === \"inProgress\" || status === \"executing\") {\n return (\n <>\n <FeedbackButton\n label={mergedLabels.approveLabel}\n onClick={() => {\n setIsExpanded(false);\n onRespond?.(mergedLabels.approveLabel);\n useResponseCache.setResponse(response.id, {\n ...response,\n __feedback__: mergedLabels.approvedMessage,\n });\n }}\n className={buttonClassName}\n />\n <FeedbackButton\n label={mergedLabels.rejectLabel}\n onClick={() => {\n setIsExpanded(false);\n useResponseCache.setResponse(response.id, {\n ...response,\n __feedback__: mergedLabels.rejectedMessage,\n });\n onRespond?.(mergedLabels.rejectLabel);\n }}\n className={buttonClassName}\n />\n </>\n );\n }\n\n return null;\n };\n\n // Decide which icon to display\n const ExpandIcon = icons?.expand || DefaultExpandIcon;\n const CollapseIcon = icons?.collapse || DefaultCollapseIcon;\n\n return (\n <div className={className}>\n {/* Response content - conditionally expanded */}\n {isExpanded && <ContentRenderer content={response.content} className={contentClassName} />}\n\n <div className={actionsClassName}>\n <div className=\"copilotkit-response-label\">\n <button onClick={() => setIsExpanded(!isExpanded)} className=\"copilotkit-toggle-button\">\n {isExpanded ? (\n <CollapseIcon className=\"copilotkit-icon\" />\n ) : (\n <ExpandIcon className=\"copilotkit-icon\" />\n )}\n </button>\n <span>{mergedLabels.responseLabel}</span>\n </div>\n\n <div className=\"copilotkit-response-buttons\">{renderFeedback()}</div>\n </div>\n </div>\n );\n};\n\n/**\n * Export the response cache for reuse\n */\nexport { createResponseCache };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2FA,mBAAgC;AA0C5B;AA7BJ,IAAM,sBAAsB,MAAgC;AAC1D,QAAM,gBAAgB,oBAAI,IAAe;AAEzC,SAAO;AAAA,IACL,aAAa,CAAC,OAAe,cAAc,IAAI,EAAE;AAAA,IACjD,aAAa,CAAC,IAAY,aAAgB,cAAc,IAAI,IAAI,QAAQ;AAAA,EAC1E;AACF;AAKA,IAAM,mBAAmB,oBAA0D;AAKnF,IAAM,oBAAyD,CAAC,EAAE,UAAU,MAC1E;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA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+BAA+B,yBAAe,GAAE;AAAA,OACjE;AAAA,KACF;AAEJ;","names":[]}
@@ -1,10 +0,0 @@
1
- import {
2
- DefaultResponseRenderer,
3
- createResponseCache
4
- } from "../../chunk-EJG6RRSX.mjs";
5
- import "../../chunk-MRXNTQOX.mjs";
6
- export {
7
- DefaultResponseRenderer,
8
- createResponseCache
9
- };
10
- //# sourceMappingURL=DefaultResponseRenderer.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,88 +0,0 @@
1
- import React__default from 'react';
2
- import { StateRendererProps } from './types.js';
3
-
4
- /**
5
- * <br/>
6
- * A state renderer component for the CopilotKit framework. This component displays
7
- * the internal state of an agent, such as the steps it has taken and the tasks it has performed.
8
- * It provides a collapsible UI that shows the agent's thought process and actions.
9
- *
10
- * ## Install Dependencies
11
- *
12
- * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
13
- *
14
- * ```shell npm2yarn \"@copilotkit/react-ui"\
15
- * npm install @copilotkit/react-core @copilotkit/react-ui
16
- * ```
17
- *
18
- * ## Usage
19
- *
20
- * ```tsx
21
- * import { DefaultStateRenderer } from "@copilotkit/react-ui";
22
- * import "@copilotkit/react-ui/styles.css";
23
- *
24
- * // Basic usage
25
- * <DefaultStateRenderer
26
- * state={agentState}
27
- * status="inProgress"
28
- * />
29
- * ```
30
- *
31
- * ## Customization
32
- *
33
- * You can customize the appearance and behavior of the component:
34
- *
35
- * ```tsx
36
- * // Custom labels and styling
37
- * <DefaultStateRenderer
38
- * state={agentState}
39
- * status="inProgress"
40
- * labels={{
41
- * inProgressLabel: "Thinking...",
42
- * completeLabel: "Finished processing",
43
- * emptyLabel: "Nothing to show"
44
- * }}
45
- * className="my-custom-state"
46
- * contentClassName="my-custom-content"
47
- * itemClassName="my-custom-item"
48
- * maxHeight="300px"
49
- * defaultCollapsed={false}
50
- * />
51
- *
52
- * // Custom renderers
53
- * <DefaultStateRenderer
54
- * state={agentState}
55
- * status="inProgress"
56
- * StateItemRenderer={({ item, isNewest, className }) => (
57
- * <MyCustomItemRenderer item={item} isNewest={isNewest} className={className} />
58
- * )}
59
- * SkeletonLoader={({ className }) => (
60
- * <MyCustomSkeletonLoader className={className} />
61
- * )}
62
- * />
63
- * ```
64
- *
65
- * ### Look & Feel
66
- *
67
- * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
68
- * ```tsx title="YourRootComponent.tsx"
69
- * ...
70
- * import "@copilotkit/react-ui/styles.css"; // [!code highlight]
71
- *
72
- * export function YourRootComponent() {
73
- * return (
74
- * <CopilotKit>
75
- * ...
76
- * </CopilotKit>
77
- * );
78
- * }
79
- * ```
80
- * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.
81
- */
82
-
83
- /**
84
- * Default state renderer component
85
- */
86
- declare const DefaultStateRenderer: React__default.FC<StateRendererProps>;
87
-
88
- export { DefaultStateRenderer };