@mcp-b/react-components 0.1.1 → 0.1.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.
- package/dist/Button-QCM8ZKgR.d.ts +98 -0
- package/dist/CodeBlock-CttHhWcb.js +356 -0
- package/dist/CodeBlock-V6pgafSS.d.ts +174 -0
- package/dist/Select-CRsKCJ9x.d.ts +200 -0
- package/dist/class-names-9UtZwb0J.js +12 -0
- package/dist/components/Accordion.d.ts +81 -0
- package/dist/components/Accordion.js +97 -0
- package/dist/components/AgentConnection.d.ts +69 -0
- package/dist/components/AgentConnection.js +176 -0
- package/dist/components/AlertDialog.d.ts +148 -0
- package/dist/components/AlertDialog.js +141 -0
- package/dist/components/Artifact.d.ts +128 -0
- package/dist/components/Artifact.js +115 -0
- package/dist/components/Autocomplete.d.ts +186 -0
- package/dist/components/Autocomplete.js +186 -0
- package/dist/components/Avatar.d.ts +134 -0
- package/dist/components/Avatar.js +118 -0
- package/dist/components/Badge.d.ts +68 -0
- package/dist/components/Badge.js +108 -0
- package/dist/components/Button.d.ts +2 -0
- package/dist/components/Button.js +73 -0
- package/dist/components/Card.d.ts +87 -0
- package/dist/components/Card.js +81 -0
- package/dist/components/ChainOfThought.d.ts +153 -0
- package/dist/components/ChainOfThought.js +157 -0
- package/dist/components/Checkbox.d.ts +35 -0
- package/dist/components/Checkbox.js +47 -0
- package/dist/components/CheckboxGroup.d.ts +76 -0
- package/dist/components/CheckboxGroup.js +69 -0
- package/dist/components/CodeBlock.d.ts +2 -0
- package/dist/components/CodeBlock.js +2 -0
- package/dist/components/Collapsible.d.ts +127 -0
- package/dist/components/Collapsible.js +103 -0
- package/dist/components/Combobox.d.ts +177 -0
- package/dist/components/Combobox.js +179 -0
- package/dist/components/Commit.d.ts +265 -0
- package/dist/components/Commit.js +282 -0
- package/dist/components/Context.d.ts +129 -0
- package/dist/components/Context.js +309 -0
- package/dist/components/ContextMenu.d.ts +282 -0
- package/dist/components/ContextMenu.js +270 -0
- package/dist/components/Conversation.d.ts +166 -0
- package/dist/components/Conversation.js +202 -0
- package/dist/components/Dialog.d.ts +120 -0
- package/dist/components/Dialog.js +114 -0
- package/dist/components/EnvironmentVariables.d.ts +176 -0
- package/dist/components/EnvironmentVariables.js +221 -0
- package/dist/components/Field.d.ts +281 -0
- package/dist/components/Field.js +274 -0
- package/dist/components/Fieldset.d.ts +93 -0
- package/dist/components/Fieldset.js +81 -0
- package/dist/components/FileTree.d.ts +116 -0
- package/dist/components/FileTree.js +310 -0
- package/dist/components/Form.d.ts +94 -0
- package/dist/components/Form.js +88 -0
- package/dist/components/GithubMotionMark.d.ts +13 -0
- package/dist/components/GithubMotionMark.js +23 -0
- package/dist/components/Input.d.ts +33 -0
- package/dist/components/Input.js +27 -0
- package/dist/components/Label.d.ts +44 -0
- package/dist/components/Label.js +41 -0
- package/dist/components/Menu.d.ts +395 -0
- package/dist/components/Menu.js +338 -0
- package/dist/components/Menubar.d.ts +331 -0
- package/dist/components/Menubar.js +299 -0
- package/dist/components/Message.d.ts +216 -0
- package/dist/components/Message.js +245 -0
- package/dist/components/Meter.d.ts +151 -0
- package/dist/components/Meter.js +121 -0
- package/dist/components/ModelSelector.d.ts +198 -0
- package/dist/components/ModelSelector.js +306 -0
- package/dist/components/NaniteScene.d.ts +33 -0
- package/dist/components/NaniteScene.js +405 -0
- package/dist/components/NavigationMenu.d.ts +256 -0
- package/dist/components/NavigationMenu.js +228 -0
- package/dist/components/NumberField.d.ts +159 -0
- package/dist/components/NumberField.js +123 -0
- package/dist/components/Popover.d.ts +278 -0
- package/dist/components/Popover.js +245 -0
- package/dist/components/PreviewCard.d.ts +156 -0
- package/dist/components/PreviewCard.js +156 -0
- package/dist/components/PricingPage.d.ts +209 -0
- package/dist/components/PricingPage.js +506 -0
- package/dist/components/Progress.d.ts +58 -0
- package/dist/components/Progress.js +51 -0
- package/dist/components/PromptInput.d.ts +399 -0
- package/dist/components/PromptInput.js +737 -0
- package/dist/components/Queue.d.ts +241 -0
- package/dist/components/Queue.js +225 -0
- package/dist/components/RadioGroup.d.ts +78 -0
- package/dist/components/RadioGroup.js +72 -0
- package/dist/components/Reasoning.d.ts +88 -0
- package/dist/components/Reasoning.js +187 -0
- package/dist/components/ScrollArea.d.ts +160 -0
- package/dist/components/ScrollArea.js +145 -0
- package/dist/components/Select.d.ts +2 -0
- package/dist/components/Select.js +260 -0
- package/dist/components/Separator.d.ts +45 -0
- package/dist/components/Separator.js +40 -0
- package/dist/components/Shell.d.ts +163 -0
- package/dist/components/Shell.js +137 -0
- package/dist/components/Slider.d.ts +120 -0
- package/dist/components/Slider.js +115 -0
- package/dist/components/Sources.d.ts +91 -0
- package/dist/components/Sources.js +121 -0
- package/dist/components/Stepper.d.ts +190 -0
- package/dist/components/Stepper.js +315 -0
- package/dist/components/Switch.d.ts +57 -0
- package/dist/components/Switch.js +55 -0
- package/dist/components/Tabs.d.ts +84 -0
- package/dist/components/Tabs.js +78 -0
- package/dist/components/Task.d.ts +100 -0
- package/dist/components/Task.js +120 -0
- package/dist/components/Terminal.d.ts +118 -0
- package/dist/components/Terminal.js +234 -0
- package/dist/components/TestResults.d.ts +236 -0
- package/dist/components/TestResults.js +346 -0
- package/dist/components/Toast.d.ts +192 -0
- package/dist/components/Toast.js +163 -0
- package/dist/components/Toggle.d.ts +69 -0
- package/dist/components/Toggle.js +66 -0
- package/dist/components/ToggleGroup.d.ts +69 -0
- package/dist/components/ToggleGroup.js +99 -0
- package/dist/components/Tool.d.ts +119 -0
- package/dist/components/Tool.js +192 -0
- package/dist/components/Toolbar.d.ts +162 -0
- package/dist/components/Toolbar.js +126 -0
- package/dist/components/Tooltip.d.ts +81 -0
- package/dist/components/Tooltip.js +74 -0
- package/dist/components/WebPreview.d.ts +143 -0
- package/dist/components/WebPreview.js +280 -0
- package/dist/components/useStickToBottom.d.ts +30 -0
- package/dist/components/useStickToBottom.js +95 -0
- package/dist/copy-button-BIATcZWZ.d.ts +16 -0
- package/dist/copy-button-BNgclDrO.js +43 -0
- package/dist/icons-BsWc8g4E.js +221 -0
- package/dist/styles/accordion.css +10 -10
- package/dist/styles/agent-connection.css +18 -17
- package/dist/styles/alert-dialog.css +48 -29
- package/dist/styles/artifact.css +10 -10
- package/dist/styles/autocomplete.css +25 -24
- package/dist/styles/avatar.css +96 -6
- package/dist/styles/badge.css +78 -14
- package/dist/styles/base.css +9 -9
- package/dist/styles/button.css +57 -38
- package/dist/styles/card.css +57 -10
- package/dist/styles/chain-of-thought.css +47 -33
- package/dist/styles/checkbox.css +24 -10
- package/dist/styles/code-block.css +22 -15
- package/dist/styles/collapsible.css +14 -12
- package/dist/styles/combobox.css +26 -25
- package/dist/styles/commit.css +49 -24
- package/dist/styles/context-menu.css +70 -16
- package/dist/styles/context.css +15 -15
- package/dist/styles/conversation.css +12 -12
- package/dist/styles/dialog.css +52 -16
- package/dist/styles/environment-variables.css +19 -19
- package/dist/styles/field.css +184 -22
- package/dist/styles/fieldset.css +5 -4
- package/dist/styles/file-tree.css +17 -17
- package/dist/styles/index.css.d.ts +1 -0
- package/dist/styles/input.css +45 -11
- package/dist/styles/label.css +21 -4
- package/dist/styles/menu.css +55 -32
- package/dist/styles/menubar.css +80 -28
- package/dist/styles/message.css +22 -13
- package/dist/styles/meter.css +8 -8
- package/dist/styles/model-selector.css +33 -21
- package/dist/styles/navigation-menu.css +26 -24
- package/dist/styles/number-field.css +20 -18
- package/dist/styles/popover.css +38 -28
- package/dist/styles/preview-card.css +15 -13
- package/dist/styles/pricing-page.css +53 -53
- package/dist/styles/progress.css +7 -7
- package/dist/styles/prompt-input.css +73 -24
- package/dist/styles/queue.css +58 -32
- package/dist/styles/radio.css +26 -11
- package/dist/styles/reasoning.css +15 -11
- package/dist/styles/scroll-area.css +6 -6
- package/dist/styles/scrollbars.css +4 -4
- package/dist/styles/select.css +84 -25
- package/dist/styles/separator.css +1 -1
- package/dist/styles/shell.css +21 -20
- package/dist/styles/slider.css +35 -11
- package/dist/styles/sources.css +20 -20
- package/dist/styles/stepper.css +22 -22
- package/dist/styles/switch.css +29 -13
- package/dist/styles/tabs.css +23 -16
- package/dist/styles/task.css +27 -23
- package/dist/styles/terminal.css +16 -13
- package/dist/styles/test-results.css +79 -32
- package/dist/styles/toast.css +26 -25
- package/dist/styles/toggle-group.css +12 -12
- package/dist/styles/toggle.css +29 -11
- package/dist/styles/tool.css +54 -32
- package/dist/styles/toolbar.css +30 -28
- package/dist/styles/tooltip.css +10 -8
- package/dist/styles/web-preview.css +37 -21
- package/dist/utils/structured-code.d.ts +10 -0
- package/dist/utils/structured-code.js +81 -0
- package/package.json +16 -7
- package/dist/index.d.ts +0 -7236
- package/dist/index.js +0 -8945
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
3
|
+
|
|
4
|
+
//#region src/components/Toggle.d.ts
|
|
5
|
+
interface ToggleVariantsOptions {
|
|
6
|
+
variant?: "default" | "outline" | null;
|
|
7
|
+
size?: "default" | "sm" | "lg" | null;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Props for the Toggle component.
|
|
12
|
+
*/
|
|
13
|
+
interface ToggleProps extends Omit<React.ComponentPropsWithoutRef<typeof Toggle$1>, "className">, ToggleVariantsOptions {}
|
|
14
|
+
declare function toggleVariants({
|
|
15
|
+
variant,
|
|
16
|
+
size,
|
|
17
|
+
className
|
|
18
|
+
}?: ToggleVariantsOptions): string;
|
|
19
|
+
/**
|
|
20
|
+
* A two-state button that can be on (pressed) or off.
|
|
21
|
+
* Useful for toggling a setting or mode.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Basic toggle
|
|
26
|
+
* <Toggle>
|
|
27
|
+
* Bold
|
|
28
|
+
* </Toggle>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // Controlled toggle
|
|
34
|
+
* const [pressed, setPressed] = useState(false);
|
|
35
|
+
*
|
|
36
|
+
* <Toggle pressed={pressed} onPressedChange={setPressed}>
|
|
37
|
+
* {pressed ? 'On' : 'Off'}
|
|
38
|
+
* </Toggle>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* // With icons
|
|
44
|
+
* <Toggle>
|
|
45
|
+
* {({ pressed }) => pressed ? <BoldIcon filled /> : <BoldIcon />}
|
|
46
|
+
* </Toggle>
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* // Default pressed state
|
|
52
|
+
* <Toggle defaultPressed>
|
|
53
|
+
* Enabled
|
|
54
|
+
* </Toggle>
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @see {@link https://base-ui.com/react/components/toggle | Base UI Toggle}
|
|
58
|
+
*/
|
|
59
|
+
declare function Toggle({
|
|
60
|
+
className,
|
|
61
|
+
variant,
|
|
62
|
+
size,
|
|
63
|
+
ref,
|
|
64
|
+
...props
|
|
65
|
+
}: ToggleProps & {
|
|
66
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
67
|
+
}): React.JSX.Element;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { Toggle, ToggleProps, ToggleVariantsOptions, toggleVariants };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
4
|
+
//#region src/components/Toggle.tsx
|
|
5
|
+
function toggleVariants({ variant = "default", size = "default", className } = {}) {
|
|
6
|
+
return [
|
|
7
|
+
"toggle",
|
|
8
|
+
variant === "outline" && "toggle--outline",
|
|
9
|
+
size !== "default" && `toggle--${size}`,
|
|
10
|
+
className
|
|
11
|
+
].filter(Boolean).join(" ");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A two-state button that can be on (pressed) or off.
|
|
15
|
+
* Useful for toggling a setting or mode.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // Basic toggle
|
|
20
|
+
* <Toggle>
|
|
21
|
+
* Bold
|
|
22
|
+
* </Toggle>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* // Controlled toggle
|
|
28
|
+
* const [pressed, setPressed] = useState(false);
|
|
29
|
+
*
|
|
30
|
+
* <Toggle pressed={pressed} onPressedChange={setPressed}>
|
|
31
|
+
* {pressed ? 'On' : 'Off'}
|
|
32
|
+
* </Toggle>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* // With icons
|
|
38
|
+
* <Toggle>
|
|
39
|
+
* {({ pressed }) => pressed ? <BoldIcon filled /> : <BoldIcon />}
|
|
40
|
+
* </Toggle>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* // Default pressed state
|
|
46
|
+
* <Toggle defaultPressed>
|
|
47
|
+
* Enabled
|
|
48
|
+
* </Toggle>
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @see {@link https://base-ui.com/react/components/toggle | Base UI Toggle}
|
|
52
|
+
*/
|
|
53
|
+
function Toggle({ className = "", variant, size, ref, ...props }) {
|
|
54
|
+
return /* @__PURE__ */ jsx(Toggle$1, {
|
|
55
|
+
ref,
|
|
56
|
+
"data-slot": "toggle",
|
|
57
|
+
className: toggleVariants({
|
|
58
|
+
variant,
|
|
59
|
+
size,
|
|
60
|
+
className
|
|
61
|
+
}),
|
|
62
|
+
...props
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ToggleVariantsOptions } from "./Toggle.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { ToggleGroup as ToggleGroup$1 } from "@base-ui/react/toggle-group";
|
|
4
|
+
import { Toggle } from "@base-ui/react/toggle";
|
|
5
|
+
|
|
6
|
+
//#region src/components/ToggleGroup.d.ts
|
|
7
|
+
type ToggleGroupSize = ToggleVariantsOptions["size"] | "md";
|
|
8
|
+
interface ToggleGroupProps extends Omit<React.ComponentPropsWithRef<typeof ToggleGroup$1>, "className"> {
|
|
9
|
+
className?: string;
|
|
10
|
+
variant?: ToggleVariantsOptions["variant"];
|
|
11
|
+
/**
|
|
12
|
+
* The size of the toggle group.
|
|
13
|
+
* @default 'md'
|
|
14
|
+
*/
|
|
15
|
+
size?: ToggleGroupSize;
|
|
16
|
+
spacing?: number;
|
|
17
|
+
}
|
|
18
|
+
interface ToggleGroupItemProps extends Omit<React.ComponentPropsWithRef<typeof Toggle>, "className">, ToggleVariantsOptions {}
|
|
19
|
+
/**
|
|
20
|
+
* A toggle group component for selecting one or multiple options.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // Single selection (defaultValue is an array)
|
|
25
|
+
* <ToggleGroup defaultValue={["center"]}>
|
|
26
|
+
* <ToggleGroupItem value="left">Left</ToggleGroupItem>
|
|
27
|
+
* <ToggleGroupItem value="center">Center</ToggleGroupItem>
|
|
28
|
+
* <ToggleGroupItem value="right">Right</ToggleGroupItem>
|
|
29
|
+
* </ToggleGroup>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* // Multiple selection
|
|
35
|
+
* <ToggleGroup multiple defaultValue={["bold", "italic"]}>
|
|
36
|
+
* <ToggleGroupItem value="bold">Bold</ToggleGroupItem>
|
|
37
|
+
* <ToggleGroupItem value="italic">Italic</ToggleGroupItem>
|
|
38
|
+
* <ToggleGroupItem value="underline">Underline</ToggleGroupItem>
|
|
39
|
+
* </ToggleGroup>
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @see {@link https://base-ui.com/react/components/toggle-group | Base UI Toggle Group}
|
|
43
|
+
*/
|
|
44
|
+
declare function ToggleGroup({
|
|
45
|
+
size,
|
|
46
|
+
spacing,
|
|
47
|
+
variant,
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
style,
|
|
51
|
+
ref,
|
|
52
|
+
...props
|
|
53
|
+
}: ToggleGroupProps & {
|
|
54
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
55
|
+
}): React.JSX.Element;
|
|
56
|
+
/**
|
|
57
|
+
* A single toggle item within a ToggleGroup.
|
|
58
|
+
*/
|
|
59
|
+
declare function ToggleGroupItem({
|
|
60
|
+
className,
|
|
61
|
+
variant,
|
|
62
|
+
size,
|
|
63
|
+
ref,
|
|
64
|
+
...props
|
|
65
|
+
}: ToggleGroupItemProps & {
|
|
66
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
67
|
+
}): React.JSX.Element;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { ToggleGroup, ToggleGroupItem, ToggleGroupItemProps, ToggleGroupProps };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { toggleVariants } from "./Toggle.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { ToggleGroup as ToggleGroup$1 } from "@base-ui/react/toggle-group";
|
|
5
|
+
import { Toggle } from "@base-ui/react/toggle";
|
|
6
|
+
//#region src/components/ToggleGroup.tsx
|
|
7
|
+
const ToggleGroupContext = React.createContext({
|
|
8
|
+
variant: "default",
|
|
9
|
+
size: "default",
|
|
10
|
+
spacing: 0
|
|
11
|
+
});
|
|
12
|
+
function normalizeSize(size) {
|
|
13
|
+
return size === "md" ? "default" : size;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A toggle group component for selecting one or multiple options.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // Single selection (defaultValue is an array)
|
|
21
|
+
* <ToggleGroup defaultValue={["center"]}>
|
|
22
|
+
* <ToggleGroupItem value="left">Left</ToggleGroupItem>
|
|
23
|
+
* <ToggleGroupItem value="center">Center</ToggleGroupItem>
|
|
24
|
+
* <ToggleGroupItem value="right">Right</ToggleGroupItem>
|
|
25
|
+
* </ToggleGroup>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // Multiple selection
|
|
31
|
+
* <ToggleGroup multiple defaultValue={["bold", "italic"]}>
|
|
32
|
+
* <ToggleGroupItem value="bold">Bold</ToggleGroupItem>
|
|
33
|
+
* <ToggleGroupItem value="italic">Italic</ToggleGroupItem>
|
|
34
|
+
* <ToggleGroupItem value="underline">Underline</ToggleGroupItem>
|
|
35
|
+
* </ToggleGroup>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @see {@link https://base-ui.com/react/components/toggle-group | Base UI Toggle Group}
|
|
39
|
+
*/
|
|
40
|
+
function ToggleGroup({ size = "md", spacing = 0, variant = "default", className = "", children, style, ref, ...props }) {
|
|
41
|
+
const normalizedSize = normalizeSize(size);
|
|
42
|
+
const gap = `${spacing * .25}rem`;
|
|
43
|
+
const groupStyle = typeof style === "function" ? (state) => ({
|
|
44
|
+
...style(state),
|
|
45
|
+
gap
|
|
46
|
+
}) : {
|
|
47
|
+
...style,
|
|
48
|
+
gap
|
|
49
|
+
};
|
|
50
|
+
return /* @__PURE__ */ jsx(ToggleGroup$1, {
|
|
51
|
+
ref,
|
|
52
|
+
"data-size": normalizedSize,
|
|
53
|
+
"data-slot": "toggle-group",
|
|
54
|
+
"data-spacing": spacing,
|
|
55
|
+
"data-variant": variant,
|
|
56
|
+
className: [
|
|
57
|
+
"toggle-group",
|
|
58
|
+
size !== "md" && `toggle-group--${size}`,
|
|
59
|
+
className
|
|
60
|
+
].filter(Boolean).join(" "),
|
|
61
|
+
style: groupStyle,
|
|
62
|
+
...props,
|
|
63
|
+
children: /* @__PURE__ */ jsx(ToggleGroupContext.Provider, {
|
|
64
|
+
value: {
|
|
65
|
+
variant,
|
|
66
|
+
size: normalizedSize,
|
|
67
|
+
spacing
|
|
68
|
+
},
|
|
69
|
+
children
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A single toggle item within a ToggleGroup.
|
|
75
|
+
*/
|
|
76
|
+
function ToggleGroupItem({ className = "", variant, size, ref, ...props }) {
|
|
77
|
+
const context = React.useContext(ToggleGroupContext);
|
|
78
|
+
const itemVariant = variant ?? context.variant;
|
|
79
|
+
const itemSize = size ?? context.size;
|
|
80
|
+
const classes = [
|
|
81
|
+
"toggle-group__item",
|
|
82
|
+
toggleVariants({
|
|
83
|
+
variant: itemVariant,
|
|
84
|
+
size: itemSize
|
|
85
|
+
}),
|
|
86
|
+
className
|
|
87
|
+
].filter(Boolean).join(" ");
|
|
88
|
+
return /* @__PURE__ */ jsx(Toggle, {
|
|
89
|
+
ref,
|
|
90
|
+
"data-size": itemSize,
|
|
91
|
+
"data-slot": "toggle-group-item",
|
|
92
|
+
"data-spacing": context.spacing,
|
|
93
|
+
"data-variant": itemVariant,
|
|
94
|
+
className: classes,
|
|
95
|
+
...props
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { CollapsiblePanelProps, CollapsibleRootProps, CollapsibleTriggerProps } from "./Collapsible.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/Tool.d.ts
|
|
5
|
+
type ToolState = "input-streaming" | "input-available" | "approval-requested" | "approval-responded" | "output-available" | "output-error" | "output-denied";
|
|
6
|
+
interface ToolPart {
|
|
7
|
+
state: ToolState;
|
|
8
|
+
input?: unknown;
|
|
9
|
+
output?: unknown;
|
|
10
|
+
errorText?: string;
|
|
11
|
+
}
|
|
12
|
+
declare function getStatusBadge(status: ToolState): React.JSX.Element;
|
|
13
|
+
interface ToolProps extends Omit<CollapsibleRootProps, "className" | "unstyled"> {
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Current state of the tool invocation. */
|
|
16
|
+
state?: ToolState;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Displays a collapsible tool invocation (name, input, output, state).
|
|
20
|
+
* The state drives the status badge color and default open behavior —
|
|
21
|
+
* `output-available`, `output-error`, and `output-denied` auto-open.
|
|
22
|
+
* Adapted from Vercel AI Elements and restyled with Sigvelo CSS tokens.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Tool state="output-available">
|
|
27
|
+
* <ToolHeader type="function" toolName="search_web" />
|
|
28
|
+
* <ToolContent>
|
|
29
|
+
* <ToolInput input={{ query: "weather in Tokyo" }} />
|
|
30
|
+
* <ToolOutput output={<pre>{JSON.stringify(result, null, 2)}</pre>} />
|
|
31
|
+
* </ToolContent>
|
|
32
|
+
* </Tool>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://elements.ai-sdk.dev/components/tool | AI Elements Tool}
|
|
36
|
+
*/
|
|
37
|
+
declare function Tool({
|
|
38
|
+
className,
|
|
39
|
+
state,
|
|
40
|
+
defaultOpen,
|
|
41
|
+
ref,
|
|
42
|
+
...props
|
|
43
|
+
}: ToolProps & {
|
|
44
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
45
|
+
}): React.JSX.Element;
|
|
46
|
+
interface ToolHeaderProps extends Omit<CollapsibleTriggerProps, "className" | "type" | "unstyled"> {
|
|
47
|
+
className?: string;
|
|
48
|
+
/** The tool "type" (e.g. "function", "retrieval"). */
|
|
49
|
+
type: string;
|
|
50
|
+
/** The specific tool invoked (e.g. "search_web"). */
|
|
51
|
+
toolName?: string;
|
|
52
|
+
/** Optional human-readable title shown alongside the tool name. */
|
|
53
|
+
title?: string;
|
|
54
|
+
/** Current state of the tool invocation. Matches Vercel AI Elements. */
|
|
55
|
+
state?: ToolState;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Clickable header that shows the tool type, name, and state badge.
|
|
59
|
+
*/
|
|
60
|
+
declare function ToolHeader({
|
|
61
|
+
className,
|
|
62
|
+
type,
|
|
63
|
+
toolName,
|
|
64
|
+
title,
|
|
65
|
+
state: stateProp,
|
|
66
|
+
ref,
|
|
67
|
+
...props
|
|
68
|
+
}: ToolHeaderProps & {
|
|
69
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
70
|
+
}): React.JSX.Element;
|
|
71
|
+
interface ToolContentProps extends Omit<CollapsiblePanelProps, "className" | "unstyled"> {
|
|
72
|
+
className?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Collapsible panel holding ToolInput and ToolOutput.
|
|
76
|
+
*/
|
|
77
|
+
declare function ToolContent({
|
|
78
|
+
className,
|
|
79
|
+
children,
|
|
80
|
+
ref,
|
|
81
|
+
...props
|
|
82
|
+
}: ToolContentProps & {
|
|
83
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
84
|
+
}): React.JSX.Element;
|
|
85
|
+
interface ToolInputProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
86
|
+
/** The input passed to the tool (rendered as a JSON code block). */
|
|
87
|
+
input: unknown;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Displays the tool input as a JSON code block.
|
|
91
|
+
*/
|
|
92
|
+
declare function ToolInput({
|
|
93
|
+
className,
|
|
94
|
+
input,
|
|
95
|
+
ref,
|
|
96
|
+
...props
|
|
97
|
+
}: ToolInputProps & {
|
|
98
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
99
|
+
}): React.JSX.Element;
|
|
100
|
+
interface ToolOutputProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
101
|
+
/** The tool output (any React node). Mutually exclusive with errorText. */
|
|
102
|
+
output?: unknown;
|
|
103
|
+
/** Error message, rendered with destructive styling. */
|
|
104
|
+
errorText?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Displays the tool output or error text.
|
|
108
|
+
*/
|
|
109
|
+
declare function ToolOutput({
|
|
110
|
+
className,
|
|
111
|
+
output,
|
|
112
|
+
errorText,
|
|
113
|
+
ref,
|
|
114
|
+
...props
|
|
115
|
+
}: ToolOutputProps & {
|
|
116
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
117
|
+
}): React.JSX.Element | null;
|
|
118
|
+
//#endregion
|
|
119
|
+
export { Tool, ToolContent, ToolContentProps, ToolHeader, ToolHeaderProps, ToolInput, ToolInputProps, ToolOutput, ToolOutputProps, ToolPart, ToolProps, ToolState, getStatusBadge };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { C as SpinnerIcon, D as WrenchIcon, E as WarningIcon, O as XIcon, c as ChevronRightIcon, o as CheckIcon, u as DotIcon } from "../icons-BsWc8g4E.js";
|
|
2
|
+
import { t as cx } from "../class-names-9UtZwb0J.js";
|
|
3
|
+
import { i as CodeBlockContent, r as CodeBlockContainer, t as CodeBlock } from "../CodeBlock-CttHhWcb.js";
|
|
4
|
+
import { Badge } from "./Badge.js";
|
|
5
|
+
import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
|
|
6
|
+
import { formatStructuredCodeDisplay } from "../utils/structured-code.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/Tool.tsx
|
|
10
|
+
const STATE_TO_COLOR = {
|
|
11
|
+
"input-streaming": "primary",
|
|
12
|
+
"input-available": "neutral",
|
|
13
|
+
"approval-requested": "warning",
|
|
14
|
+
"approval-responded": "neutral",
|
|
15
|
+
"output-available": "success",
|
|
16
|
+
"output-error": "destructive",
|
|
17
|
+
"output-denied": "destructive"
|
|
18
|
+
};
|
|
19
|
+
const STATE_LABEL = {
|
|
20
|
+
"input-streaming": "Pending",
|
|
21
|
+
"input-available": "Running",
|
|
22
|
+
"approval-requested": "Awaiting Approval",
|
|
23
|
+
"approval-responded": "Responded",
|
|
24
|
+
"output-available": "Completed",
|
|
25
|
+
"output-error": "Error",
|
|
26
|
+
"output-denied": "Denied"
|
|
27
|
+
};
|
|
28
|
+
const STATE_ICON = {
|
|
29
|
+
"input-streaming": /* @__PURE__ */ jsx(DotIcon, {}),
|
|
30
|
+
"input-available": /* @__PURE__ */ jsx(SpinnerIcon, { className: "tool__status-spinner" }),
|
|
31
|
+
"approval-requested": /* @__PURE__ */ jsx(WarningIcon, {}),
|
|
32
|
+
"approval-responded": /* @__PURE__ */ jsx(CheckIcon, {}),
|
|
33
|
+
"output-available": /* @__PURE__ */ jsx(CheckIcon, {}),
|
|
34
|
+
"output-error": /* @__PURE__ */ jsx(XIcon, {}),
|
|
35
|
+
"output-denied": /* @__PURE__ */ jsx(XIcon, {})
|
|
36
|
+
};
|
|
37
|
+
function getStatusBadge(status) {
|
|
38
|
+
return /* @__PURE__ */ jsxs(Badge, {
|
|
39
|
+
color: STATE_TO_COLOR[status],
|
|
40
|
+
size: "sm",
|
|
41
|
+
className: "tool__header-badge",
|
|
42
|
+
children: [STATE_ICON[status], STATE_LABEL[status]]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const ToolContext = React.createContext(null);
|
|
46
|
+
function useToolContext() {
|
|
47
|
+
const ctx = React.useContext(ToolContext);
|
|
48
|
+
if (!ctx) throw new Error("Tool subcomponents must be used inside <Tool>.");
|
|
49
|
+
return ctx;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Displays a collapsible tool invocation (name, input, output, state).
|
|
53
|
+
* The state drives the status badge color and default open behavior —
|
|
54
|
+
* `output-available`, `output-error`, and `output-denied` auto-open.
|
|
55
|
+
* Adapted from Vercel AI Elements and restyled with Sigvelo CSS tokens.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <Tool state="output-available">
|
|
60
|
+
* <ToolHeader type="function" toolName="search_web" />
|
|
61
|
+
* <ToolContent>
|
|
62
|
+
* <ToolInput input={{ query: "weather in Tokyo" }} />
|
|
63
|
+
* <ToolOutput output={<pre>{JSON.stringify(result, null, 2)}</pre>} />
|
|
64
|
+
* </ToolContent>
|
|
65
|
+
* </Tool>
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @see {@link https://elements.ai-sdk.dev/components/tool | AI Elements Tool}
|
|
69
|
+
*/
|
|
70
|
+
function Tool({ className, state, defaultOpen, ref, ...props }) {
|
|
71
|
+
const autoOpen = state === "output-available" || state === "output-error" || state === "output-denied";
|
|
72
|
+
const ctx = React.useMemo(() => ({ state }), [state]);
|
|
73
|
+
return /* @__PURE__ */ jsx(ToolContext.Provider, {
|
|
74
|
+
value: ctx,
|
|
75
|
+
children: /* @__PURE__ */ jsx(CollapsibleRoot, {
|
|
76
|
+
ref,
|
|
77
|
+
className: cx("tool", className),
|
|
78
|
+
defaultOpen: defaultOpen ?? autoOpen,
|
|
79
|
+
"data-state": state ?? void 0,
|
|
80
|
+
...props,
|
|
81
|
+
unstyled: true
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Clickable header that shows the tool type, name, and state badge.
|
|
87
|
+
*/
|
|
88
|
+
function ToolHeader({ className, type, toolName, title, state: stateProp, ref, ...props }) {
|
|
89
|
+
const { state: contextState } = useToolContext();
|
|
90
|
+
const state = stateProp ?? contextState ?? "input-available";
|
|
91
|
+
const derivedName = type === "dynamic-tool" && toolName ? toolName : type.startsWith("tool-") ? type.split("-").slice(1).join("-") : toolName ?? type;
|
|
92
|
+
return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
93
|
+
ref,
|
|
94
|
+
className: cx("tool__header", className),
|
|
95
|
+
...props,
|
|
96
|
+
unstyled: true,
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsx("span", {
|
|
99
|
+
className: "tool__header-tool-icon",
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
children: /* @__PURE__ */ jsx(WrenchIcon, {})
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ jsx("span", {
|
|
104
|
+
className: "tool__header-type",
|
|
105
|
+
children: type
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: "tool__header-name",
|
|
109
|
+
children: title ?? derivedName
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx("span", { className: "tool__header-spacer" }),
|
|
112
|
+
getStatusBadge(state),
|
|
113
|
+
/* @__PURE__ */ jsx("span", {
|
|
114
|
+
className: "tool__header-icon",
|
|
115
|
+
"aria-hidden": "true",
|
|
116
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Collapsible panel holding ToolInput and ToolOutput.
|
|
123
|
+
*/
|
|
124
|
+
function ToolContent({ className, children, ref, ...props }) {
|
|
125
|
+
return /* @__PURE__ */ jsx(CollapsiblePanel, {
|
|
126
|
+
ref,
|
|
127
|
+
className: cx("tool__content", className),
|
|
128
|
+
...props,
|
|
129
|
+
unstyled: true,
|
|
130
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
131
|
+
className: "tool__content-inner",
|
|
132
|
+
children
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Displays the tool input as a JSON code block.
|
|
138
|
+
*/
|
|
139
|
+
function ToolInput({ className, input, ref, ...props }) {
|
|
140
|
+
const { state } = useToolContext();
|
|
141
|
+
const formattedInput = React.useMemo(() => formatStructuredCodeDisplay(input), [input]);
|
|
142
|
+
const isStreaming = state === "input-streaming";
|
|
143
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
144
|
+
ref,
|
|
145
|
+
className: cx("tool__section", className),
|
|
146
|
+
...props,
|
|
147
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
148
|
+
className: "tool__section-label",
|
|
149
|
+
children: "Input"
|
|
150
|
+
}), /* @__PURE__ */ jsx(CodeBlock, {
|
|
151
|
+
code: formattedInput.code,
|
|
152
|
+
language: formattedInput.language,
|
|
153
|
+
className: "tool__code-block",
|
|
154
|
+
isStreaming,
|
|
155
|
+
children: /* @__PURE__ */ jsx(CodeBlockContainer, { children: /* @__PURE__ */ jsx(CodeBlockContent, {}) })
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Displays the tool output or error text.
|
|
161
|
+
*/
|
|
162
|
+
function ToolOutput({ className, output, errorText, ref, ...props }) {
|
|
163
|
+
const formattedOutput = React.useMemo(() => {
|
|
164
|
+
if (output && typeof output === "object" && !React.isValidElement(output)) return formatStructuredCodeDisplay(output);
|
|
165
|
+
if (typeof output === "string") return {
|
|
166
|
+
code: output,
|
|
167
|
+
language: "json"
|
|
168
|
+
};
|
|
169
|
+
return null;
|
|
170
|
+
}, [output]);
|
|
171
|
+
const isError = errorText !== void 0;
|
|
172
|
+
if (!(output || errorText)) return null;
|
|
173
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
174
|
+
ref,
|
|
175
|
+
className: cx("tool__section", isError && "tool__section--error", className),
|
|
176
|
+
...props,
|
|
177
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
178
|
+
className: "tool__section-label",
|
|
179
|
+
children: isError ? "Error" : "Output"
|
|
180
|
+
}), isError ? /* @__PURE__ */ jsx("div", {
|
|
181
|
+
className: "tool__error-text",
|
|
182
|
+
children: errorText
|
|
183
|
+
}) : formattedOutput ? /* @__PURE__ */ jsx(CodeBlock, {
|
|
184
|
+
code: formattedOutput.code,
|
|
185
|
+
language: formattedOutput.language,
|
|
186
|
+
className: "tool__code-block",
|
|
187
|
+
children: /* @__PURE__ */ jsx(CodeBlockContainer, { children: /* @__PURE__ */ jsx(CodeBlockContent, {}) })
|
|
188
|
+
}) : /* @__PURE__ */ jsx("div", { children: output })]
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
export { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput, getStatusBadge };
|