@sero-ai/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-typecheck.log +1 -1
- package/LICENSE +201 -0
- package/dist/index.cjs +15527 -0
- package/dist/index.d.cts +2246 -0
- package/dist/index.d.ts +2246 -0
- package/dist/index.js +14985 -0
- package/package.json +27 -22
- package/src/components/ai-elements/attachments.tsx +4 -4
- package/src/components/ai-elements/audio-player.tsx +1 -1
- package/src/components/ai-elements/chain-of-thought.tsx +2 -2
- package/src/components/ai-elements/confirmation.tsx +2 -2
- package/src/components/ai-elements/context.tsx +2 -2
- package/src/components/ai-elements/environment-variables.tsx +6 -6
- package/src/components/ai-elements/file-tree.tsx +3 -3
- package/src/components/ai-elements/inline-citation.tsx +2 -2
- package/src/components/ai-elements/jsx-preview.tsx +2 -2
- package/src/components/ai-elements/message.tsx +2 -2
- package/src/components/ai-elements/mic-selector.tsx +8 -8
- package/src/components/ai-elements/open-in-chat.tsx +2 -2
- package/src/components/ai-elements/package-info.tsx +4 -4
- package/src/components/ai-elements/plan.tsx +2 -2
- package/src/components/ai-elements/prompt-input-context.tsx +8 -8
- package/src/components/ai-elements/queue.tsx +1 -1
- package/src/components/ai-elements/reasoning.tsx +3 -3
- package/src/components/ai-elements/schema-display.tsx +7 -7
- package/src/components/ai-elements/snippet.tsx +3 -3
- package/src/components/ai-elements/sources.tsx +2 -2
- package/src/components/ai-elements/terminal.tsx +5 -5
- package/src/components/ai-elements/test-results.tsx +8 -8
- package/src/components/ai-elements/transcription.tsx +2 -2
- package/src/components/ai-elements/voice-selector.tsx +2 -2
- package/src/components/ai-elements/web-preview.tsx +5 -6
- package/src/components/model-selection/available-model-picker.tsx +1 -1
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/carousel.tsx +1 -1
- package/src/components/ui/chart.tsx +3 -3
- package/src/components/ui/command.tsx +1 -1
- package/src/components/ui/field.tsx +2 -2
- package/src/components/ui/form.tsx +2 -2
- package/src/components/ui/input-otp.tsx +2 -2
- package/src/components/ui/input.tsx +3 -1
- package/src/components/ui/menubar.tsx +1 -1
- package/src/components/ui/native-select.tsx +2 -0
- package/src/components/ui/navigation-menu.tsx +1 -1
- package/src/components/ui/plugin-safety-disclaimer.tsx +3 -3
- package/src/components/ui/progress.tsx +1 -1
- package/src/components/ui/resizable.tsx +1 -1
- package/src/components/ui/search-input.tsx +26 -27
- package/src/components/ui/slider.tsx +7 -2
- package/src/components/ui/textarea.tsx +3 -1
- package/src/components/ui/toggle-group.tsx +1 -1
- package/src/components/ui/tree.tsx +3 -3
- package/src/index.ts +3 -0
- package/src/styles/globals.css +91 -26
- package/src/styles/plugin.css +4 -0
- package/src/theme/apply-theme.ts +250 -0
- package/src/theme/index.ts +2 -0
- package/src/theme/types.ts +253 -0
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sero-ai/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Shared UI components, AI elements, and design tokens for the Sero platform",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./
|
|
7
|
-
"types": "./
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"typecheck": "tsc --noEmit"
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
15
14
|
},
|
|
16
15
|
"peerDependencies": {
|
|
17
|
-
"react": "
|
|
18
|
-
"react-dom": "
|
|
16
|
+
"react": "^19.2.4",
|
|
17
|
+
"react-dom": "^19.2.4"
|
|
19
18
|
},
|
|
20
19
|
"dependencies": {
|
|
21
20
|
"@base-ui/react": "^1.3.0",
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
"@radix-ui/react-use-controllable-state": "^1.2.2",
|
|
25
24
|
"@remixicon/react": "^4.9.0",
|
|
26
25
|
"@rive-app/react-webgl2": "^4.27.1",
|
|
27
|
-
"@sero-ai/common": "workspace:*",
|
|
28
26
|
"@streamdown/cjk": "^1.0.2",
|
|
29
27
|
"@streamdown/code": "^1.1.0",
|
|
30
28
|
"@streamdown/math": "^1.0.2",
|
|
@@ -38,9 +36,9 @@
|
|
|
38
36
|
"date-fns": "^4.1.0",
|
|
39
37
|
"embla-carousel-react": "^8.6.0",
|
|
40
38
|
"input-otp": "^1.4.2",
|
|
41
|
-
"lucide-react": "
|
|
39
|
+
"lucide-react": "^0.563.0",
|
|
42
40
|
"media-chrome": "^4.18.0",
|
|
43
|
-
"motion": "
|
|
41
|
+
"motion": "^12.34.0",
|
|
44
42
|
"nanoid": "^5.1.11",
|
|
45
43
|
"next-themes": "^0.4.6",
|
|
46
44
|
"radix-ui": "^1.4.3",
|
|
@@ -52,20 +50,27 @@
|
|
|
52
50
|
"recharts": "2.15.4",
|
|
53
51
|
"shiki": "^3.23.0",
|
|
54
52
|
"sonner": "^2.0.7",
|
|
55
|
-
"streamdown": "
|
|
53
|
+
"streamdown": "^2.5.0",
|
|
56
54
|
"tailwind-merge": "^3.5.0",
|
|
57
55
|
"tokenlens": "^1.3.1",
|
|
58
56
|
"use-stick-to-bottom": "^1.1.4",
|
|
59
|
-
"vaul": "^1.1.2"
|
|
57
|
+
"vaul": "^1.1.2",
|
|
58
|
+
"@sero-ai/common": "0.3.1"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
61
|
"@hookform/resolvers": "^5.2.2",
|
|
63
|
-
"@types/react": "
|
|
64
|
-
"@types/react-dom": "
|
|
62
|
+
"@types/react": "^19.2.13",
|
|
63
|
+
"@types/react-dom": "^19.2.3",
|
|
65
64
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
66
65
|
"shadcn": "^3.8.5",
|
|
67
|
-
"tailwindcss": "
|
|
66
|
+
"tailwindcss": "4.1.18",
|
|
67
|
+
"tsup": "^8.5.1",
|
|
68
68
|
"tw-animate-css": "^1.4.0",
|
|
69
|
-
"typescript": "
|
|
70
|
-
}
|
|
71
|
-
|
|
69
|
+
"typescript": "^5.9.3"
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
73
|
+
"typecheck": "tsc --noEmit"
|
|
74
|
+
},
|
|
75
|
+
"module": "./dist/index.mjs"
|
|
76
|
+
}
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
VideoIcon,
|
|
20
20
|
XIcon,
|
|
21
21
|
} from "lucide-react";
|
|
22
|
-
import { createContext, useCallback,
|
|
22
|
+
import { createContext, useCallback, use, useMemo } from "react";
|
|
23
23
|
|
|
24
24
|
// ============================================================================
|
|
25
25
|
// Types
|
|
@@ -133,10 +133,10 @@ const AttachmentContext = createContext<AttachmentContextValue | null>(null);
|
|
|
133
133
|
// ============================================================================
|
|
134
134
|
|
|
135
135
|
export const useAttachmentsContext = () =>
|
|
136
|
-
|
|
136
|
+
use(AttachmentsContext) ?? { variant: "grid" as const };
|
|
137
137
|
|
|
138
138
|
export const useAttachmentContext = () => {
|
|
139
|
-
const ctx =
|
|
139
|
+
const ctx = use(AttachmentContext);
|
|
140
140
|
if (!ctx) {
|
|
141
141
|
throw new Error("Attachment components must be used within <Attachment>");
|
|
142
142
|
}
|
|
@@ -253,7 +253,7 @@ export const AttachmentPreview = ({
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
if (mediaCategory === "video" && data.type === "file" && data.url) {
|
|
256
|
-
return <video className="size-full object-cover" muted src={data.url} />;
|
|
256
|
+
return <video aria-label="Video preview" className="size-full object-cover" muted src={data.url} />;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
const Icon = mediaCategoryIcons[mediaCategory];
|
|
@@ -78,7 +78,7 @@ export type AudioPlayerElementProps = Omit<ComponentProps<"audio">, "src"> &
|
|
|
78
78
|
|
|
79
79
|
export const AudioPlayerElement = ({ ...props }: AudioPlayerElementProps) => (
|
|
80
80
|
// oxlint-disable-next-line eslint-plugin-jsx-a11y(media-has-caption) -- audio player captions are provided by consumer
|
|
81
|
-
<audio
|
|
81
|
+
<audio aria-label="Audio preview"
|
|
82
82
|
data-slot="audio-player-element"
|
|
83
83
|
slot="media"
|
|
84
84
|
src={
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "../ui/collapsible";
|
|
13
13
|
import { cn } from "../../lib/utils";
|
|
14
14
|
import { BrainIcon, ChevronDownIcon, DotIcon } from "lucide-react";
|
|
15
|
-
import { createContext, memo,
|
|
15
|
+
import { createContext, memo, use, useMemo } from "react";
|
|
16
16
|
|
|
17
17
|
interface ChainOfThoughtContextValue {
|
|
18
18
|
isOpen: boolean;
|
|
@@ -24,7 +24,7 @@ const ChainOfThoughtContext = createContext<ChainOfThoughtContextValue | null>(
|
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
const useChainOfThought = () => {
|
|
27
|
-
const context =
|
|
27
|
+
const context = use(ChainOfThoughtContext);
|
|
28
28
|
if (!context) {
|
|
29
29
|
throw new Error(
|
|
30
30
|
"ChainOfThought components must be used within ChainOfThought"
|
|
@@ -6,7 +6,7 @@ import type { ComponentProps, ReactNode } from "react";
|
|
|
6
6
|
import { Alert, AlertDescription } from "../ui/alert";
|
|
7
7
|
import { Button } from "../ui/button";
|
|
8
8
|
import { cn } from "../../lib/utils";
|
|
9
|
-
import { createContext,
|
|
9
|
+
import { createContext, use } from "react";
|
|
10
10
|
|
|
11
11
|
type ToolUIPartApproval =
|
|
12
12
|
| {
|
|
@@ -46,7 +46,7 @@ const ConfirmationContext = createContext<ConfirmationContextValue | null>(
|
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
const useConfirmation = () => {
|
|
49
|
-
const context =
|
|
49
|
+
const context = use(ConfirmationContext);
|
|
50
50
|
|
|
51
51
|
if (!context) {
|
|
52
52
|
throw new Error("Confirmation components must be used within Confirmation");
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../ui/hover-card";
|
|
12
12
|
import { Progress } from "../ui/progress";
|
|
13
13
|
import { cn } from "../../lib/utils";
|
|
14
|
-
import { createContext,
|
|
14
|
+
import { createContext, use, useMemo } from "react";
|
|
15
15
|
import { getUsage } from "tokenlens";
|
|
16
16
|
|
|
17
17
|
const PERCENT_MAX = 100;
|
|
@@ -32,7 +32,7 @@ interface ContextSchema {
|
|
|
32
32
|
const ContextContext = createContext<ContextSchema | null>(null);
|
|
33
33
|
|
|
34
34
|
const useContextValue = () => {
|
|
35
|
-
const context =
|
|
35
|
+
const context = use(ContextContext);
|
|
36
36
|
|
|
37
37
|
if (!context) {
|
|
38
38
|
throw new Error("Context components must be used within Context");
|
|
@@ -10,7 +10,7 @@ import { CheckIcon, CopyIcon, EyeIcon, EyeOffIcon } from "lucide-react";
|
|
|
10
10
|
import {
|
|
11
11
|
createContext,
|
|
12
12
|
useCallback,
|
|
13
|
-
|
|
13
|
+
use,
|
|
14
14
|
useEffect,
|
|
15
15
|
useMemo,
|
|
16
16
|
useRef,
|
|
@@ -111,7 +111,7 @@ export const EnvironmentVariablesToggle = ({
|
|
|
111
111
|
className,
|
|
112
112
|
...props
|
|
113
113
|
}: EnvironmentVariablesToggleProps) => {
|
|
114
|
-
const { showValues, setShowValues } =
|
|
114
|
+
const { showValues, setShowValues } = use(EnvironmentVariablesContext);
|
|
115
115
|
|
|
116
116
|
return (
|
|
117
117
|
<div className={cn("flex items-center gap-2", className)}>
|
|
@@ -206,7 +206,7 @@ export const EnvironmentVariableName = ({
|
|
|
206
206
|
children,
|
|
207
207
|
...props
|
|
208
208
|
}: EnvironmentVariableNameProps) => {
|
|
209
|
-
const { name } =
|
|
209
|
+
const { name } = use(EnvironmentVariableContext);
|
|
210
210
|
|
|
211
211
|
return (
|
|
212
212
|
<span className={cn("font-mono text-sm", className)} {...props}>
|
|
@@ -222,8 +222,8 @@ export const EnvironmentVariableValue = ({
|
|
|
222
222
|
children,
|
|
223
223
|
...props
|
|
224
224
|
}: EnvironmentVariableValueProps) => {
|
|
225
|
-
const { value } =
|
|
226
|
-
const { showValues } =
|
|
225
|
+
const { value } = use(EnvironmentVariableContext);
|
|
226
|
+
const { showValues } = use(EnvironmentVariablesContext);
|
|
227
227
|
|
|
228
228
|
const displayValue = showValues
|
|
229
229
|
? value
|
|
@@ -263,7 +263,7 @@ export const EnvironmentVariableCopyButton = ({
|
|
|
263
263
|
}: EnvironmentVariableCopyButtonProps) => {
|
|
264
264
|
const [isCopied, setIsCopied] = useState(false);
|
|
265
265
|
const timeoutRef = useRef<number>(0);
|
|
266
|
-
const { name, value } =
|
|
266
|
+
const { name, value } = use(EnvironmentVariableContext);
|
|
267
267
|
|
|
268
268
|
const getTextToCopy = useCallback((): string => {
|
|
269
269
|
const formatMap = {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
createContext,
|
|
19
19
|
useCallback,
|
|
20
|
-
|
|
20
|
+
use,
|
|
21
21
|
useMemo,
|
|
22
22
|
useState,
|
|
23
23
|
} from "react";
|
|
@@ -120,7 +120,7 @@ export const FileTreeFolder = ({
|
|
|
120
120
|
...props
|
|
121
121
|
}: FileTreeFolderProps) => {
|
|
122
122
|
const { expandedPaths, togglePath, selectedPath, onSelect } =
|
|
123
|
-
|
|
123
|
+
use(FileTreeContext);
|
|
124
124
|
const isExpanded = expandedPaths.has(path);
|
|
125
125
|
const isSelected = selectedPath === path;
|
|
126
126
|
|
|
@@ -204,7 +204,7 @@ export const FileTreeFile = ({
|
|
|
204
204
|
children,
|
|
205
205
|
...props
|
|
206
206
|
}: FileTreeFileProps) => {
|
|
207
|
-
const { selectedPath, onSelect } =
|
|
207
|
+
const { selectedPath, onSelect } = use(FileTreeContext);
|
|
208
208
|
const isSelected = selectedPath === path;
|
|
209
209
|
|
|
210
210
|
const handleClick = useCallback(() => {
|
|
@@ -19,7 +19,7 @@ import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
|
|
|
19
19
|
import {
|
|
20
20
|
createContext,
|
|
21
21
|
useCallback,
|
|
22
|
-
|
|
22
|
+
use,
|
|
23
23
|
useEffect,
|
|
24
24
|
useState,
|
|
25
25
|
} from "react";
|
|
@@ -93,7 +93,7 @@ export const InlineCitationCardBody = ({
|
|
|
93
93
|
const CarouselApiContext = createContext<CarouselApi | undefined>(undefined);
|
|
94
94
|
|
|
95
95
|
const useCarouselApi = () => {
|
|
96
|
-
const context =
|
|
96
|
+
const context = use(CarouselApiContext);
|
|
97
97
|
return context;
|
|
98
98
|
};
|
|
99
99
|
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
createContext,
|
|
10
10
|
memo,
|
|
11
11
|
useCallback,
|
|
12
|
-
|
|
12
|
+
use,
|
|
13
13
|
useEffect,
|
|
14
14
|
useMemo,
|
|
15
15
|
useRef,
|
|
@@ -32,7 +32,7 @@ const JSXPreviewContext = createContext<JSXPreviewContextValue | null>(null);
|
|
|
32
32
|
const TAG_REGEX = /<\/?([a-zA-Z][a-zA-Z0-9]*)\s*([^>]*?)(\/)?>/;
|
|
33
33
|
|
|
34
34
|
export const useJSXPreview = () => {
|
|
35
|
-
const context =
|
|
35
|
+
const context = use(JSXPreviewContext);
|
|
36
36
|
if (!context) {
|
|
37
37
|
throw new Error("JSXPreview components must be used within JSXPreview");
|
|
38
38
|
}
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
createContext,
|
|
25
25
|
memo,
|
|
26
26
|
useCallback,
|
|
27
|
-
|
|
27
|
+
use,
|
|
28
28
|
useEffect,
|
|
29
29
|
useMemo,
|
|
30
30
|
useState,
|
|
@@ -128,7 +128,7 @@ const MessageBranchContext = createContext<MessageBranchContextType | null>(
|
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
const useMessageBranch = () => {
|
|
131
|
-
const context =
|
|
131
|
+
const context = use(MessageBranchContext);
|
|
132
132
|
|
|
133
133
|
if (!context) {
|
|
134
134
|
throw new Error(
|
|
@@ -21,7 +21,7 @@ import { ChevronsUpDownIcon } from "lucide-react";
|
|
|
21
21
|
import {
|
|
22
22
|
createContext,
|
|
23
23
|
useCallback,
|
|
24
|
-
|
|
24
|
+
use,
|
|
25
25
|
useEffect,
|
|
26
26
|
useMemo,
|
|
27
27
|
useRef,
|
|
@@ -112,7 +112,7 @@ export const MicSelectorTrigger = ({
|
|
|
112
112
|
children,
|
|
113
113
|
...props
|
|
114
114
|
}: MicSelectorTriggerProps) => {
|
|
115
|
-
const { setWidth } =
|
|
115
|
+
const { setWidth } = use(MicSelectorContext);
|
|
116
116
|
const ref = useRef<HTMLButtonElement>(null);
|
|
117
117
|
|
|
118
118
|
useEffect(() => {
|
|
@@ -158,7 +158,7 @@ export const MicSelectorContent = ({
|
|
|
158
158
|
popoverOptions,
|
|
159
159
|
...props
|
|
160
160
|
}: MicSelectorContentProps) => {
|
|
161
|
-
const { width, onValueChange, value } =
|
|
161
|
+
const { width, onValueChange, value } = use(MicSelectorContext);
|
|
162
162
|
|
|
163
163
|
return (
|
|
164
164
|
<PopoverContent
|
|
@@ -178,7 +178,7 @@ export type MicSelectorInputProps = ComponentProps<typeof CommandInput> & {
|
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
export const MicSelectorInput = ({ ...props }: MicSelectorInputProps) => (
|
|
181
|
-
<CommandInput placeholder="Search microphones
|
|
181
|
+
<CommandInput placeholder="Search microphones…" {...props} />
|
|
182
182
|
);
|
|
183
183
|
|
|
184
184
|
export type MicSelectorListProps = Omit<
|
|
@@ -192,7 +192,7 @@ export const MicSelectorList = ({
|
|
|
192
192
|
children,
|
|
193
193
|
...props
|
|
194
194
|
}: MicSelectorListProps) => {
|
|
195
|
-
const { data } =
|
|
195
|
+
const { data } = use(MicSelectorContext);
|
|
196
196
|
|
|
197
197
|
return <CommandList {...props}>{children(data)}</CommandList>;
|
|
198
198
|
};
|
|
@@ -207,7 +207,7 @@ export const MicSelectorEmpty = ({
|
|
|
207
207
|
export type MicSelectorItemProps = ComponentProps<typeof CommandItem>;
|
|
208
208
|
|
|
209
209
|
export const MicSelectorItem = (props: MicSelectorItemProps) => {
|
|
210
|
-
const { onValueChange, onOpenChange } =
|
|
210
|
+
const { onValueChange, onOpenChange } = use(MicSelectorContext);
|
|
211
211
|
|
|
212
212
|
const handleSelect = useCallback(
|
|
213
213
|
(currentValue: string) => {
|
|
@@ -256,13 +256,13 @@ export const MicSelectorValue = ({
|
|
|
256
256
|
className,
|
|
257
257
|
...props
|
|
258
258
|
}: MicSelectorValueProps) => {
|
|
259
|
-
const { data, value } =
|
|
259
|
+
const { data, value } = use(MicSelectorContext);
|
|
260
260
|
const currentDevice = data.find((d) => d.deviceId === value);
|
|
261
261
|
|
|
262
262
|
if (!currentDevice) {
|
|
263
263
|
return (
|
|
264
264
|
<span className={cn("flex-1 text-left", className)} {...props}>
|
|
265
|
-
Select microphone
|
|
265
|
+
Select microphone…
|
|
266
266
|
</span>
|
|
267
267
|
);
|
|
268
268
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
ExternalLinkIcon,
|
|
18
18
|
MessageCircleIcon,
|
|
19
19
|
} from "lucide-react";
|
|
20
|
-
import { createContext,
|
|
20
|
+
import { createContext, use } from "react";
|
|
21
21
|
|
|
22
22
|
const providers = {
|
|
23
23
|
chatgpt: {
|
|
@@ -188,7 +188,7 @@ const providers = {
|
|
|
188
188
|
const OpenInContext = createContext<{ query: string } | undefined>(undefined);
|
|
189
189
|
|
|
190
190
|
const useOpenInContext = () => {
|
|
191
|
-
const context =
|
|
191
|
+
const context = use(OpenInContext);
|
|
192
192
|
if (!context) {
|
|
193
193
|
throw new Error("OpenIn components must be used within an OpenIn provider");
|
|
194
194
|
}
|
|
@@ -5,7 +5,7 @@ import type { HTMLAttributes } from "react";
|
|
|
5
5
|
import { Badge } from "../ui/badge";
|
|
6
6
|
import { cn } from "../../lib/utils";
|
|
7
7
|
import { ArrowRightIcon, MinusIcon, PackageIcon, PlusIcon } from "lucide-react";
|
|
8
|
-
import { createContext,
|
|
8
|
+
import { createContext, use } from "react";
|
|
9
9
|
|
|
10
10
|
type ChangeType = "major" | "minor" | "patch" | "added" | "removed";
|
|
11
11
|
|
|
@@ -78,7 +78,7 @@ export const PackageInfoName = ({
|
|
|
78
78
|
children,
|
|
79
79
|
...props
|
|
80
80
|
}: PackageInfoNameProps) => {
|
|
81
|
-
const { name } =
|
|
81
|
+
const { name } = use(PackageInfoContext);
|
|
82
82
|
|
|
83
83
|
return (
|
|
84
84
|
<div className={cn("flex items-center gap-2", className)} {...props}>
|
|
@@ -112,7 +112,7 @@ export const PackageInfoChangeType = ({
|
|
|
112
112
|
children,
|
|
113
113
|
...props
|
|
114
114
|
}: PackageInfoChangeTypeProps) => {
|
|
115
|
-
const { changeType } =
|
|
115
|
+
const { changeType } = use(PackageInfoContext);
|
|
116
116
|
|
|
117
117
|
if (!changeType) {
|
|
118
118
|
return null;
|
|
@@ -141,7 +141,7 @@ export const PackageInfoVersion = ({
|
|
|
141
141
|
children,
|
|
142
142
|
...props
|
|
143
143
|
}: PackageInfoVersionProps) => {
|
|
144
|
-
const { currentVersion, newVersion } =
|
|
144
|
+
const { currentVersion, newVersion } = use(PackageInfoContext);
|
|
145
145
|
|
|
146
146
|
if (!(currentVersion || newVersion)) {
|
|
147
147
|
return null;
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "../ui/collapsible";
|
|
20
20
|
import { cn } from "../../lib/utils";
|
|
21
21
|
import { ChevronsUpDownIcon } from "lucide-react";
|
|
22
|
-
import { createContext,
|
|
22
|
+
import { createContext, use } from "react";
|
|
23
23
|
|
|
24
24
|
import { Shimmer } from "./shimmer";
|
|
25
25
|
|
|
@@ -30,7 +30,7 @@ interface PlanContextValue {
|
|
|
30
30
|
const PlanContext = createContext<PlanContextValue | null>(null);
|
|
31
31
|
|
|
32
32
|
const usePlan = () => {
|
|
33
|
-
const context =
|
|
33
|
+
const context = use(PlanContext);
|
|
34
34
|
if (!context) {
|
|
35
35
|
throw new Error("Plan components must be used within Plan");
|
|
36
36
|
}
|
|
@@ -14,7 +14,7 @@ import { nanoid } from "nanoid";
|
|
|
14
14
|
import {
|
|
15
15
|
createContext,
|
|
16
16
|
useCallback,
|
|
17
|
-
|
|
17
|
+
use,
|
|
18
18
|
useEffect,
|
|
19
19
|
useMemo,
|
|
20
20
|
useRef,
|
|
@@ -71,7 +71,7 @@ export const LocalReferencedSourcesContext = createContext<ReferencedSourcesCont
|
|
|
71
71
|
// ============================================================================
|
|
72
72
|
|
|
73
73
|
export const usePromptInputController = () => {
|
|
74
|
-
const ctx =
|
|
74
|
+
const ctx = use(PromptInputController);
|
|
75
75
|
if (!ctx) {
|
|
76
76
|
throw new Error(
|
|
77
77
|
"Wrap your component inside <PromptInputProvider> to use usePromptInputController()."
|
|
@@ -80,12 +80,12 @@ export const usePromptInputController = () => {
|
|
|
80
80
|
return ctx;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
/** Optional variant
|
|
83
|
+
/** Optional variant, does NOT throw. Useful for dual-mode components. */
|
|
84
84
|
export const useOptionalPromptInputController = () =>
|
|
85
|
-
|
|
85
|
+
use(PromptInputController);
|
|
86
86
|
|
|
87
87
|
export const useProviderAttachments = () => {
|
|
88
|
-
const ctx =
|
|
88
|
+
const ctx = use(ProviderAttachmentsContext);
|
|
89
89
|
if (!ctx) {
|
|
90
90
|
throw new Error(
|
|
91
91
|
"Wrap your component inside <PromptInputProvider> to use useProviderAttachments()."
|
|
@@ -95,12 +95,12 @@ export const useProviderAttachments = () => {
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
const useOptionalProviderAttachments = () =>
|
|
98
|
-
|
|
98
|
+
use(ProviderAttachmentsContext);
|
|
99
99
|
|
|
100
100
|
export const usePromptInputAttachments = () => {
|
|
101
101
|
// Prefer local context (inside PromptInput) as it has validation, fall back to provider
|
|
102
102
|
const provider = useOptionalProviderAttachments();
|
|
103
|
-
const local =
|
|
103
|
+
const local = use(LocalAttachmentsContext);
|
|
104
104
|
const context = local ?? provider;
|
|
105
105
|
if (!context) {
|
|
106
106
|
throw new Error(
|
|
@@ -111,7 +111,7 @@ export const usePromptInputAttachments = () => {
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
export const usePromptInputReferencedSources = () => {
|
|
114
|
-
const ctx =
|
|
114
|
+
const ctx = use(LocalReferencedSourcesContext);
|
|
115
115
|
if (!ctx) {
|
|
116
116
|
throw new Error(
|
|
117
117
|
"usePromptInputReferencedSources must be used within a LocalReferencedSourcesContext.Provider"
|
|
@@ -154,7 +154,7 @@ export const QueueItemImage = ({
|
|
|
154
154
|
}: QueueItemImageProps) => (
|
|
155
155
|
<img
|
|
156
156
|
alt=""
|
|
157
|
-
className={cn("
|
|
157
|
+
className={cn("size-8 rounded border object-cover", className)}
|
|
158
158
|
height={32}
|
|
159
159
|
width={32}
|
|
160
160
|
{...props}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
createContext,
|
|
19
19
|
memo,
|
|
20
20
|
useCallback,
|
|
21
|
-
|
|
21
|
+
use,
|
|
22
22
|
useEffect,
|
|
23
23
|
useMemo,
|
|
24
24
|
useRef,
|
|
@@ -38,7 +38,7 @@ interface ReasoningContextValue {
|
|
|
38
38
|
const ReasoningContext = createContext<ReasoningContextValue | null>(null);
|
|
39
39
|
|
|
40
40
|
export const useReasoning = () => {
|
|
41
|
-
const context =
|
|
41
|
+
const context = use(ReasoningContext);
|
|
42
42
|
if (!context) {
|
|
43
43
|
throw new Error("Reasoning components must be used within Reasoning");
|
|
44
44
|
}
|
|
@@ -157,7 +157,7 @@ export type ReasoningTriggerProps = ComponentProps<
|
|
|
157
157
|
|
|
158
158
|
const defaultGetThinkingMessage = (isStreaming: boolean, duration?: number) => {
|
|
159
159
|
if (isStreaming || duration === 0) {
|
|
160
|
-
return <Shimmer duration={1}>Thinking
|
|
160
|
+
return <Shimmer duration={1}>Thinking…</Shimmer>;
|
|
161
161
|
}
|
|
162
162
|
if (duration === undefined) {
|
|
163
163
|
return <p>Thought for a few seconds</p>;
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "../ui/collapsible";
|
|
11
11
|
import { cn } from "../../lib/utils";
|
|
12
12
|
import { ChevronRightIcon } from "lucide-react";
|
|
13
|
-
import { createContext,
|
|
13
|
+
import { createContext, use, useMemo } from "react";
|
|
14
14
|
|
|
15
15
|
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
16
16
|
|
|
@@ -144,7 +144,7 @@ export const SchemaDisplayMethod = ({
|
|
|
144
144
|
children,
|
|
145
145
|
...props
|
|
146
146
|
}: SchemaDisplayMethodProps) => {
|
|
147
|
-
const { method } =
|
|
147
|
+
const { method } = use(SchemaDisplayContext);
|
|
148
148
|
|
|
149
149
|
return (
|
|
150
150
|
<Badge
|
|
@@ -164,7 +164,7 @@ export const SchemaDisplayPath = ({
|
|
|
164
164
|
children,
|
|
165
165
|
...props
|
|
166
166
|
}: SchemaDisplayPathProps) => {
|
|
167
|
-
const { path } =
|
|
167
|
+
const { path } = use(SchemaDisplayContext);
|
|
168
168
|
|
|
169
169
|
// Highlight path parameters
|
|
170
170
|
const highlightedPath = path.replaceAll(
|
|
@@ -191,7 +191,7 @@ export const SchemaDisplayDescription = ({
|
|
|
191
191
|
children,
|
|
192
192
|
...props
|
|
193
193
|
}: SchemaDisplayDescriptionProps) => {
|
|
194
|
-
const { description } =
|
|
194
|
+
const { description } = use(SchemaDisplayContext);
|
|
195
195
|
|
|
196
196
|
return (
|
|
197
197
|
<p
|
|
@@ -225,7 +225,7 @@ export const SchemaDisplayParameters = ({
|
|
|
225
225
|
children,
|
|
226
226
|
...props
|
|
227
227
|
}: SchemaDisplayParametersProps) => {
|
|
228
|
-
const { parameters } =
|
|
228
|
+
const { parameters } = use(SchemaDisplayContext);
|
|
229
229
|
|
|
230
230
|
return (
|
|
231
231
|
<Collapsible className={cn(className)} defaultOpen {...props}>
|
|
@@ -293,7 +293,7 @@ export const SchemaDisplayRequest = ({
|
|
|
293
293
|
children,
|
|
294
294
|
...props
|
|
295
295
|
}: SchemaDisplayRequestProps) => {
|
|
296
|
-
const { requestBody } =
|
|
296
|
+
const { requestBody } = use(SchemaDisplayContext);
|
|
297
297
|
|
|
298
298
|
return (
|
|
299
299
|
<Collapsible className={cn(className)} defaultOpen {...props}>
|
|
@@ -320,7 +320,7 @@ export const SchemaDisplayResponse = ({
|
|
|
320
320
|
children,
|
|
321
321
|
...props
|
|
322
322
|
}: SchemaDisplayResponseProps) => {
|
|
323
|
-
const { responseBody } =
|
|
323
|
+
const { responseBody } = use(SchemaDisplayContext);
|
|
324
324
|
|
|
325
325
|
return (
|
|
326
326
|
<Collapsible className={cn(className)} defaultOpen {...props}>
|
|
@@ -14,7 +14,7 @@ import { CheckIcon, CopyIcon } from "lucide-react";
|
|
|
14
14
|
import {
|
|
15
15
|
createContext,
|
|
16
16
|
useCallback,
|
|
17
|
-
|
|
17
|
+
use,
|
|
18
18
|
useEffect,
|
|
19
19
|
useRef,
|
|
20
20
|
useState,
|
|
@@ -66,7 +66,7 @@ export type SnippetInputProps = Omit<
|
|
|
66
66
|
>;
|
|
67
67
|
|
|
68
68
|
export const SnippetInput = ({ className, ...props }: SnippetInputProps) => {
|
|
69
|
-
const { code } =
|
|
69
|
+
const { code } = use(SnippetContext);
|
|
70
70
|
|
|
71
71
|
return (
|
|
72
72
|
<InputGroupInput
|
|
@@ -94,7 +94,7 @@ export const SnippetCopyButton = ({
|
|
|
94
94
|
}: SnippetCopyButtonProps) => {
|
|
95
95
|
const [isCopied, setIsCopied] = useState(false);
|
|
96
96
|
const timeoutRef = useRef<number>(0);
|
|
97
|
-
const { code } =
|
|
97
|
+
const { code } = use(SnippetContext);
|
|
98
98
|
|
|
99
99
|
const copyToClipboard = useCallback(async () => {
|
|
100
100
|
if (typeof window === "undefined" || !navigator?.clipboard?.writeText) {
|
|
@@ -36,7 +36,7 @@ export const SourcesTrigger = ({
|
|
|
36
36
|
{children ?? (
|
|
37
37
|
<>
|
|
38
38
|
<p className="font-medium">Used {count} sources</p>
|
|
39
|
-
<ChevronDownIcon className="
|
|
39
|
+
<ChevronDownIcon className="size-4" />
|
|
40
40
|
</>
|
|
41
41
|
)}
|
|
42
42
|
</CollapsibleTrigger>
|
|
@@ -70,7 +70,7 @@ export const Source = ({ href, title, children, ...props }: SourceProps) => (
|
|
|
70
70
|
>
|
|
71
71
|
{children ?? (
|
|
72
72
|
<>
|
|
73
|
-
<BookIcon className="
|
|
73
|
+
<BookIcon className="size-4" />
|
|
74
74
|
<span className="block font-medium">{title}</span>
|
|
75
75
|
</>
|
|
76
76
|
)}
|