@truefoundry/agent-ui-sdk 0.0.1 → 0.0.3

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 (79) hide show
  1. package/README.md +192 -80
  2. package/dist/index.d.ts +229 -281
  3. package/dist/index.js +1824 -1791
  4. package/dist/index.js.map +1 -1
  5. package/dist/styles.css +2 -0
  6. package/package.json +36 -19
  7. package/src/atoms/AskUserPrompt.tsx +0 -102
  8. package/src/atoms/AttachmentCard.tsx +0 -92
  9. package/src/atoms/AttachmentPickerButton.tsx +0 -19
  10. package/src/atoms/AttachmentPreviewDialog.tsx +0 -34
  11. package/src/atoms/BranchIndicator.tsx +0 -41
  12. package/src/atoms/CodeBlockHeader.tsx +0 -44
  13. package/src/atoms/ComposerShell.tsx +0 -112
  14. package/src/atoms/Markdown.test.tsx +0 -28
  15. package/src/atoms/Markdown.tsx +0 -288
  16. package/src/atoms/McpAuthPrompt.tsx +0 -60
  17. package/src/atoms/MessageActionBar.tsx +0 -60
  18. package/src/atoms/MessageBubble.tsx +0 -80
  19. package/src/atoms/MessageErrorBanner.tsx +0 -26
  20. package/src/atoms/MessageIndicator.tsx +0 -23
  21. package/src/atoms/OpenUIBlock.test.tsx +0 -37
  22. package/src/atoms/OpenUIBlock.tsx +0 -50
  23. package/src/atoms/ReasoningCard.tsx +0 -52
  24. package/src/atoms/SandboxArtifactList.tsx +0 -63
  25. package/src/atoms/ScrollToBottomButton.tsx +0 -34
  26. package/src/atoms/Skeletons.tsx +0 -32
  27. package/src/atoms/ThreadListMisc.tsx +0 -76
  28. package/src/atoms/ThreadListRow.tsx +0 -81
  29. package/src/atoms/ThreadShell.tsx +0 -93
  30. package/src/atoms/Toast.tsx +0 -60
  31. package/src/atoms/ToolApprovalBar.tsx +0 -92
  32. package/src/atoms/ToolCallCard.tsx +0 -186
  33. package/src/atoms/ToolGroupCard.tsx +0 -52
  34. package/src/atoms/UserMessageActionBar.tsx +0 -62
  35. package/src/atoms/WelcomeScreen.tsx +0 -22
  36. package/src/atoms/lib/cn.ts +0 -6
  37. package/src/atoms/primitives/Avatar.tsx +0 -57
  38. package/src/atoms/primitives/Button.tsx +0 -73
  39. package/src/atoms/primitives/Collapsible.tsx +0 -32
  40. package/src/atoms/primitives/Dialog.tsx +0 -152
  41. package/src/atoms/primitives/IconButton.tsx +0 -43
  42. package/src/atoms/primitives/Skeleton.tsx +0 -17
  43. package/src/atoms/primitives/Tooltip.tsx +0 -58
  44. package/src/containers/AskUserContainer.tsx +0 -49
  45. package/src/containers/AssistantMessageContainer.test.tsx +0 -56
  46. package/src/containers/AssistantMessageContainer.tsx +0 -128
  47. package/src/containers/AssistantTextContainer.test.tsx +0 -111
  48. package/src/containers/AssistantTextContainer.tsx +0 -54
  49. package/src/containers/AttachmentsContainer.tsx +0 -83
  50. package/src/containers/ComposerContainer.tsx +0 -66
  51. package/src/containers/ErrorToasterContainer.tsx +0 -76
  52. package/src/containers/McpAuthContainer.test.tsx +0 -100
  53. package/src/containers/McpAuthContainer.tsx +0 -22
  54. package/src/containers/MessageImageContainer.tsx +0 -37
  55. package/src/containers/ReasoningContainer.tsx +0 -32
  56. package/src/containers/RuntimeHarness.tsx +0 -39
  57. package/src/containers/Thread.tsx +0 -9
  58. package/src/containers/ThreadContainer.test.tsx +0 -52
  59. package/src/containers/ThreadContainer.tsx +0 -87
  60. package/src/containers/ThreadListContainer.tsx +0 -63
  61. package/src/containers/ToolCallContainer.test.tsx +0 -135
  62. package/src/containers/ToolCallContainer.tsx +0 -167
  63. package/src/containers/ToolGroupContainer.test.tsx +0 -56
  64. package/src/containers/ToolGroupContainer.tsx +0 -24
  65. package/src/containers/UserEditComposerContainer.test.tsx +0 -52
  66. package/src/containers/UserEditComposerContainer.tsx +0 -86
  67. package/src/containers/UserMessageContainer.test.tsx +0 -99
  68. package/src/containers/UserMessageContainer.tsx +0 -26
  69. package/src/containers/nestedApprovalBridge.ts +0 -20
  70. package/src/containers/useAttachmentPreviewSrc.ts +0 -42
  71. package/src/hooks/useComposerBusyState.test.ts +0 -78
  72. package/src/hooks/useComposerBusyState.ts +0 -69
  73. package/src/index.ts +0 -193
  74. package/src/testSetup.ts +0 -42
  75. package/src/theme/SlotsProvider.test.tsx +0 -64
  76. package/src/theme/SlotsProvider.tsx +0 -41
  77. package/src/theme/defaultSlots.ts +0 -131
  78. package/src/theme/tokens.ts +0 -98
  79. package/src/theme/useClassDarkMode.ts +0 -24
@@ -1,186 +0,0 @@
1
- import type { ComponentType, ReactNode } from "react";
2
- import { BriefcaseIcon, CheckIcon, ChevronDownIcon, LoaderIcon, PlugIcon, WrenchIcon, XCircleIcon } from "lucide-react";
3
-
4
- import { cn } from "./lib/cn.js";
5
- import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./primitives/Collapsible.js";
6
-
7
- export type ToolCallStatus = "running" | "success" | "error";
8
-
9
- type ToolCallCardBaseProps = {
10
- variant: "tool" | "sub-agent" | "mcp-listing";
11
- name: string;
12
- status: ToolCallStatus;
13
- expanded: boolean;
14
- onToggle: () => void;
15
- /** Not in the Section 6 screenshot contract; ported from the reference's live per-call timer. */
16
- durationText?: string;
17
- className?: string;
18
- };
19
-
20
- export type ToolCallCardToolProps = ToolCallCardBaseProps & {
21
- variant: "tool";
22
- argsText?: string;
23
- result?: string;
24
- isError?: boolean;
25
- /**
26
- * Extends the Section 6 contract: renders the pending tool-approval / ask-user
27
- * UI when this call requires action. The reference screenshots didn't include
28
- * an in-flight approval state, so this slot was inferred rather than observed.
29
- */
30
- approvalSlot?: ReactNode;
31
- };
32
-
33
- export type ToolCallCardSubAgentProps = ToolCallCardBaseProps & {
34
- variant: "sub-agent";
35
- agentName: string;
36
- instruction: string;
37
- stepCount: number;
38
- children?: ReactNode;
39
- };
40
-
41
- export type ToolCallCardMcpProps = ToolCallCardBaseProps & {
42
- variant: "mcp-listing";
43
- serverName: string;
44
- description: string;
45
- argsText: string;
46
- resultText: string;
47
- };
48
-
49
- export type ToolCallCardProps = ToolCallCardToolProps | ToolCallCardSubAgentProps | ToolCallCardMcpProps;
50
-
51
- const variantIcon: Record<ToolCallCardProps["variant"], ComponentType<{ className?: string }>> = {
52
- tool: WrenchIcon,
53
- "sub-agent": BriefcaseIcon,
54
- "mcp-listing": PlugIcon,
55
- };
56
-
57
- function StatusIcon({ status }: { status: ToolCallStatus }) {
58
- if (status === "running") {
59
- return (
60
- <LoaderIcon
61
- data-slot="tool-call-card-status-icon"
62
- className="text-muted-foreground size-4 shrink-0 animate-spin [animation-duration:0.6s]"
63
- />
64
- );
65
- }
66
- if (status === "success") {
67
- return (
68
- <CheckIcon
69
- data-slot="tool-call-card-status-icon"
70
- className="size-4 shrink-0 text-emerald-600 dark:text-emerald-400"
71
- />
72
- );
73
- }
74
- return <XCircleIcon data-slot="tool-call-card-status-icon" className="text-destructive size-4 shrink-0" />;
75
- }
76
-
77
- function IconChip({ Icon }: { Icon: ComponentType<{ className?: string }> }) {
78
- return (
79
- <span className="bg-muted text-muted-foreground flex size-6 shrink-0 items-center justify-center rounded-md">
80
- <Icon className="size-3.5" />
81
- </span>
82
- );
83
- }
84
-
85
- export function ToolCallCard(props: ToolCallCardProps) {
86
- const { variant, name, status, expanded, onToggle, durationText, className } = props;
87
- const VariantIcon = variantIcon[variant];
88
-
89
- return (
90
- <Collapsible
91
- data-slot="tool-call-card"
92
- data-variant={variant}
93
- open={expanded}
94
- onOpenChange={onToggle}
95
- className={cn("aui-tool-call-card w-full rounded-lg border py-2", className)}
96
- >
97
- <CollapsibleTrigger className="flex w-full items-center gap-2 px-3 text-left">
98
- <IconChip Icon={VariantIcon} />
99
- {variant === "tool" && <span className="text-sm">{name}</span>}
100
- {variant === "sub-agent" && (
101
- <span className="flex min-w-0 flex-col items-start">
102
- <span className="text-muted-foreground text-[10px] font-semibold tracking-wide uppercase">
103
- Sub-agent
104
- </span>
105
- <span className="truncate text-sm font-medium">{props.agentName}</span>
106
- </span>
107
- )}
108
- {variant === "mcp-listing" && (
109
- <span className="truncate text-sm">Listing tools · {props.serverName}</span>
110
- )}
111
- <span className="ml-auto flex shrink-0 items-center gap-2">
112
- {durationText && (
113
- <span className="text-muted-foreground text-xs tabular-nums">{durationText}</span>
114
- )}
115
- <StatusIcon status={status} />
116
- <ChevronDownIcon
117
- className={cn(
118
- "size-4 shrink-0 transition-transform duration-200 ease-[cubic-bezier(0.32,0.72,0,1)]",
119
- expanded ? "rotate-0" : "-rotate-90",
120
- )}
121
- />
122
- </span>
123
- </CollapsibleTrigger>
124
- <CollapsibleContent className="px-3 pt-2">
125
- {variant === "tool" && (
126
- <div className="flex flex-col gap-2">
127
- {props.approvalSlot}
128
- {props.argsText && (
129
- <div>
130
- <p className="text-muted-foreground text-xs font-medium">Request:</p>
131
- <pre className="bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs break-words whitespace-pre-wrap">
132
- {props.argsText}
133
- </pre>
134
- </div>
135
- )}
136
- {props.result !== undefined && (
137
- <div>
138
- <p className="text-muted-foreground text-xs font-medium">Result:</p>
139
- <pre
140
- className={cn(
141
- "bg-muted/50 mt-1 rounded-md p-2.5 text-xs break-words whitespace-pre-wrap",
142
- props.isError ? "text-destructive" : "text-foreground/90",
143
- )}
144
- >
145
- {props.result}
146
- </pre>
147
- </div>
148
- )}
149
- </div>
150
- )}
151
- {variant === "sub-agent" && (
152
- <div className="flex flex-col gap-2">
153
- <p className="text-muted-foreground line-clamp-2 text-sm">{props.instruction}</p>
154
- <p className="text-muted-foreground text-[10px] font-medium tracking-wide uppercase">
155
- Steps · {props.stepCount} steps
156
- </p>
157
- <div className="border-border/60 flex flex-col gap-2 border-l pl-3">{props.children}</div>
158
- </div>
159
- )}
160
- {variant === "mcp-listing" && (
161
- <div className="flex flex-col gap-2">
162
- <p className="text-muted-foreground text-sm">{props.description}</p>
163
- <div>
164
- <p className="text-muted-foreground text-xs font-medium">Request:</p>
165
- <pre className="bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs break-words whitespace-pre-wrap">
166
- {props.argsText}
167
- </pre>
168
- </div>
169
- <div>
170
- <p className="text-muted-foreground text-xs font-medium">Result:</p>
171
- <pre className="bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs break-words whitespace-pre-wrap">
172
- {props.resultText}
173
- </pre>
174
- </div>
175
- </div>
176
- )}
177
- </CollapsibleContent>
178
- </Collapsible>
179
- );
180
- }
181
-
182
- declare module "../theme/SlotsProvider.js" {
183
- interface AtomSlots {
184
- ToolCallCard: typeof ToolCallCard;
185
- }
186
- }
@@ -1,52 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import { ChevronDownIcon, LoaderIcon } from "lucide-react";
3
-
4
- import { cn } from "./lib/cn.js";
5
- import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./primitives/Collapsible.js";
6
-
7
- export type ToolGroupCardProps = {
8
- toolCallCount: number;
9
- expanded: boolean;
10
- active?: boolean;
11
- onToggle: () => void;
12
- children: ReactNode;
13
- className?: string;
14
- };
15
-
16
- export function ToolGroupCard({
17
- toolCallCount,
18
- expanded,
19
- active = false,
20
- onToggle,
21
- children,
22
- className,
23
- }: ToolGroupCardProps) {
24
- const label = `${toolCallCount} tool ${toolCallCount === 1 ? "call" : "calls"}`;
25
-
26
- return (
27
- <Collapsible
28
- data-slot="tool-group-card"
29
- open={expanded}
30
- onOpenChange={onToggle}
31
- className={cn("aui-tool-group-card group/tool-group w-full", className)}
32
- >
33
- <CollapsibleTrigger className="text-muted-foreground hover:text-foreground flex origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]">
34
- {active && <LoaderIcon className="size-3 shrink-0 animate-spin [animation-duration:0.6s]" />}
35
- <span className="text-xs font-medium">{label}</span>
36
- <ChevronDownIcon
37
- className={cn(
38
- "size-3 shrink-0 transition-transform duration-200 ease-[cubic-bezier(0.32,0.72,0,1)]",
39
- expanded ? "rotate-0" : "-rotate-90",
40
- )}
41
- />
42
- </CollapsibleTrigger>
43
- <CollapsibleContent className="mt-1 flex flex-col gap-1">{children}</CollapsibleContent>
44
- </Collapsible>
45
- );
46
- }
47
-
48
- declare module "../theme/SlotsProvider.js" {
49
- interface AtomSlots {
50
- ToolGroupCard: typeof ToolGroupCard;
51
- }
52
- }
@@ -1,62 +0,0 @@
1
- "use client";
2
-
3
- import { ActionBarPrimitive, useAui, useAuiState } from "@assistant-ui/react";
4
- import { useActionBarCopy } from "@assistant-ui/core/react";
5
- import { CheckIcon, CopyIcon, PencilIcon, RotateCcwIcon } from "lucide-react";
6
- import { trueFoundryExtras } from "@truefoundry/assistant-ui-runtime";
7
-
8
- import { useSlot } from "../theme/SlotsProvider.js";
9
- import { cn } from "./lib/cn.js";
10
-
11
- function parseTurnIdFromMessageId(messageId: string): string {
12
- return messageId.replace(/-user$/, "");
13
- }
14
-
15
- export type UserMessageActionBarProps = {
16
- className?: string;
17
- };
18
-
19
- export function UserMessageActionBar({ className }: UserMessageActionBarProps) {
20
- const IconButton = useSlot("IconButton");
21
- const aui = useAui();
22
- const messageId = useAuiState((s) => s.message.id);
23
- const turnId = parseTurnIdFromMessageId(messageId);
24
- const { isCopied } = useActionBarCopy();
25
-
26
- return (
27
- <ActionBarPrimitive.Root
28
- hideWhenRunning
29
- className={cn(
30
- "aui-user-action-bar-root text-muted-foreground animate-in fade-in flex gap-1 duration-200",
31
- className,
32
- )}
33
- >
34
- <ActionBarPrimitive.Edit asChild>
35
- <IconButton tooltip="Edit">
36
- <PencilIcon />
37
- </IconButton>
38
- </ActionBarPrimitive.Edit>
39
- <IconButton
40
- tooltip="Reset"
41
- onClick={() => void trueFoundryExtras.get(aui).resetFromTurn(turnId)}
42
- >
43
- <RotateCcwIcon />
44
- </IconButton>
45
- <ActionBarPrimitive.Copy asChild>
46
- <IconButton tooltip="Copy">
47
- {isCopied ? (
48
- <CheckIcon className="animate-in zoom-in-50 fade-in duration-200 ease-out" />
49
- ) : (
50
- <CopyIcon className="animate-in zoom-in-75 fade-in duration-150" />
51
- )}
52
- </IconButton>
53
- </ActionBarPrimitive.Copy>
54
- </ActionBarPrimitive.Root>
55
- );
56
- }
57
-
58
- declare module "../theme/SlotsProvider.js" {
59
- interface AtomSlots {
60
- UserMessageActionBar: typeof UserMessageActionBar;
61
- }
62
- }
@@ -1,22 +0,0 @@
1
- import { cn } from "./lib/cn.js";
2
-
3
- export type WelcomeScreenProps = {
4
- heading?: string;
5
- className?: string;
6
- };
7
-
8
- export function WelcomeScreen({ heading = "How can I help you today?", className }: WelcomeScreenProps) {
9
- return (
10
- <div className={cn("aui-thread-welcome-root mb-6 flex flex-col items-center px-4 text-center", className)}>
11
- <h1 className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-2xl font-semibold duration-200">
12
- {heading}
13
- </h1>
14
- </div>
15
- );
16
- }
17
-
18
- declare module "../theme/SlotsProvider.js" {
19
- interface AtomSlots {
20
- WelcomeScreen: typeof WelcomeScreen;
21
- }
22
- }
@@ -1,6 +0,0 @@
1
- import { clsx, type ClassValue } from "clsx";
2
- import { twMerge } from "tailwind-merge";
3
-
4
- export function cn(...inputs: ClassValue[]) {
5
- return twMerge(clsx(inputs));
6
- }
@@ -1,57 +0,0 @@
1
- import type { ComponentProps } from "react";
2
- import { Avatar as AvatarPrimitive } from "radix-ui";
3
-
4
- import { cn } from "../lib/cn.js";
5
-
6
- export type AvatarProps = ComponentProps<typeof AvatarPrimitive.Root> & {
7
- size?: "default" | "sm" | "lg";
8
- };
9
-
10
- export function Avatar({ className, size = "default", ...props }: AvatarProps) {
11
- return (
12
- <AvatarPrimitive.Root
13
- data-slot="avatar"
14
- data-size={size}
15
- className={cn(
16
- "group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
17
- className,
18
- )}
19
- {...props}
20
- />
21
- );
22
- }
23
-
24
- export type AvatarImageProps = ComponentProps<typeof AvatarPrimitive.Image>;
25
-
26
- export function AvatarImage({ className, ...props }: AvatarImageProps) {
27
- return (
28
- <AvatarPrimitive.Image
29
- data-slot="avatar-image"
30
- className={cn("aspect-square size-full rounded-full object-cover", className)}
31
- {...props}
32
- />
33
- );
34
- }
35
-
36
- export type AvatarFallbackProps = ComponentProps<typeof AvatarPrimitive.Fallback>;
37
-
38
- export function AvatarFallback({ className, ...props }: AvatarFallbackProps) {
39
- return (
40
- <AvatarPrimitive.Fallback
41
- data-slot="avatar-fallback"
42
- className={cn(
43
- "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
44
- className,
45
- )}
46
- {...props}
47
- />
48
- );
49
- }
50
-
51
- declare module "../../theme/SlotsProvider.js" {
52
- interface AtomSlots {
53
- Avatar: typeof Avatar;
54
- AvatarImage: typeof AvatarImage;
55
- AvatarFallback: typeof AvatarFallback;
56
- }
57
- }
@@ -1,73 +0,0 @@
1
- import type { ComponentProps } from "react";
2
- import { cva, type VariantProps } from "class-variance-authority";
3
- import { Slot } from "radix-ui";
4
-
5
- import { cn } from "../lib/cn.js";
6
-
7
- export const buttonVariants = cva(
8
- "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
9
- {
10
- variants: {
11
- variant: {
12
- default: "bg-primary text-primary-foreground hover:bg-primary/80",
13
- outline:
14
- "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
15
- secondary:
16
- "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
17
- ghost:
18
- "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
19
- destructive:
20
- "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
21
- link: "text-primary underline-offset-4 hover:underline",
22
- },
23
- size: {
24
- default:
25
- "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
26
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
27
- sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
28
- lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
29
- icon: "size-8",
30
- "icon-xs":
31
- "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
32
- "icon-sm":
33
- "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
34
- "icon-lg": "size-9",
35
- },
36
- },
37
- defaultVariants: {
38
- variant: "default",
39
- size: "default",
40
- },
41
- },
42
- );
43
-
44
- export type ButtonProps = ComponentProps<"button"> &
45
- VariantProps<typeof buttonVariants> & {
46
- asChild?: boolean;
47
- };
48
-
49
- export function Button({
50
- className,
51
- variant = "default",
52
- size = "default",
53
- asChild = false,
54
- ...props
55
- }: ButtonProps) {
56
- const Comp = asChild ? Slot.Root : "button";
57
-
58
- return (
59
- <Comp
60
- data-slot="button"
61
- data-variant={variant}
62
- data-size={size}
63
- className={cn(buttonVariants({ variant, size, className }))}
64
- {...props}
65
- />
66
- );
67
- }
68
-
69
- declare module "../../theme/SlotsProvider.js" {
70
- interface AtomSlots {
71
- Button: typeof Button;
72
- }
73
- }
@@ -1,32 +0,0 @@
1
- import type { ComponentProps } from "react";
2
- import { Collapsible as CollapsiblePrimitive } from "radix-ui";
3
-
4
- export type CollapsibleProps = ComponentProps<typeof CollapsiblePrimitive.Root>;
5
-
6
- export function Collapsible(props: CollapsibleProps) {
7
- return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
8
- }
9
-
10
- export type CollapsibleTriggerProps = ComponentProps<
11
- typeof CollapsiblePrimitive.CollapsibleTrigger
12
- >;
13
-
14
- export function CollapsibleTrigger(props: CollapsibleTriggerProps) {
15
- return <CollapsiblePrimitive.CollapsibleTrigger data-slot="collapsible-trigger" {...props} />;
16
- }
17
-
18
- export type CollapsibleContentProps = ComponentProps<
19
- typeof CollapsiblePrimitive.CollapsibleContent
20
- >;
21
-
22
- export function CollapsibleContent(props: CollapsibleContentProps) {
23
- return <CollapsiblePrimitive.CollapsibleContent data-slot="collapsible-content" {...props} />;
24
- }
25
-
26
- declare module "../../theme/SlotsProvider.js" {
27
- interface AtomSlots {
28
- Collapsible: typeof Collapsible;
29
- CollapsibleTrigger: typeof CollapsibleTrigger;
30
- CollapsibleContent: typeof CollapsibleContent;
31
- }
32
- }
@@ -1,152 +0,0 @@
1
- import type { ComponentProps } from "react";
2
- import { Dialog as DialogPrimitive } from "radix-ui";
3
- import { XIcon } from "lucide-react";
4
-
5
- import { cn } from "../lib/cn.js";
6
- import { Button } from "./Button.js";
7
-
8
- export type DialogProps = ComponentProps<typeof DialogPrimitive.Root>;
9
-
10
- export function Dialog(props: DialogProps) {
11
- return <DialogPrimitive.Root data-slot="dialog" {...props} />;
12
- }
13
-
14
- export type DialogTriggerProps = ComponentProps<typeof DialogPrimitive.Trigger>;
15
-
16
- export function DialogTrigger(props: DialogTriggerProps) {
17
- return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
18
- }
19
-
20
- export type DialogPortalProps = ComponentProps<typeof DialogPrimitive.Portal>;
21
-
22
- export function DialogPortal(props: DialogPortalProps) {
23
- return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
24
- }
25
-
26
- export type DialogCloseProps = ComponentProps<typeof DialogPrimitive.Close>;
27
-
28
- export function DialogClose(props: DialogCloseProps) {
29
- return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
30
- }
31
-
32
- export type DialogOverlayProps = ComponentProps<typeof DialogPrimitive.Overlay>;
33
-
34
- export function DialogOverlay({ className, ...props }: DialogOverlayProps) {
35
- return (
36
- <DialogPrimitive.Overlay
37
- data-slot="dialog-overlay"
38
- className={cn(
39
- "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
40
- className,
41
- )}
42
- {...props}
43
- />
44
- );
45
- }
46
-
47
- export type DialogContentProps = ComponentProps<typeof DialogPrimitive.Content> & {
48
- showCloseButton?: boolean;
49
- };
50
-
51
- export function DialogContent({
52
- className,
53
- children,
54
- showCloseButton = true,
55
- ...props
56
- }: DialogContentProps) {
57
- return (
58
- <DialogPortal>
59
- <DialogOverlay />
60
- <DialogPrimitive.Content
61
- data-slot="dialog-content"
62
- className={cn(
63
- "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
64
- className,
65
- )}
66
- {...props}
67
- >
68
- {children}
69
- {showCloseButton && (
70
- <DialogPrimitive.Close data-slot="dialog-close" asChild>
71
- <Button variant="ghost" className="absolute top-2 right-2" size="icon-sm">
72
- <XIcon />
73
- <span className="sr-only">Close</span>
74
- </Button>
75
- </DialogPrimitive.Close>
76
- )}
77
- </DialogPrimitive.Content>
78
- </DialogPortal>
79
- );
80
- }
81
-
82
- export type DialogHeaderProps = ComponentProps<"div">;
83
-
84
- export function DialogHeader({ className, ...props }: DialogHeaderProps) {
85
- return <div data-slot="dialog-header" className={cn("flex flex-col gap-2", className)} {...props} />;
86
- }
87
-
88
- export type DialogFooterProps = ComponentProps<"div"> & {
89
- showCloseButton?: boolean;
90
- };
91
-
92
- export function DialogFooter({ className, showCloseButton = false, children, ...props }: DialogFooterProps) {
93
- return (
94
- <div
95
- data-slot="dialog-footer"
96
- className={cn(
97
- "-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",
98
- className,
99
- )}
100
- {...props}
101
- >
102
- {children}
103
- {showCloseButton && (
104
- <DialogPrimitive.Close asChild>
105
- <Button variant="outline">Close</Button>
106
- </DialogPrimitive.Close>
107
- )}
108
- </div>
109
- );
110
- }
111
-
112
- export type DialogTitleProps = ComponentProps<typeof DialogPrimitive.Title>;
113
-
114
- export function DialogTitle({ className, ...props }: DialogTitleProps) {
115
- return (
116
- <DialogPrimitive.Title
117
- data-slot="dialog-title"
118
- className={cn("font-heading text-base leading-none font-medium", className)}
119
- {...props}
120
- />
121
- );
122
- }
123
-
124
- export type DialogDescriptionProps = ComponentProps<typeof DialogPrimitive.Description>;
125
-
126
- export function DialogDescription({ className, ...props }: DialogDescriptionProps) {
127
- return (
128
- <DialogPrimitive.Description
129
- data-slot="dialog-description"
130
- className={cn(
131
- "text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
132
- className,
133
- )}
134
- {...props}
135
- />
136
- );
137
- }
138
-
139
- declare module "../../theme/SlotsProvider.js" {
140
- interface AtomSlots {
141
- Dialog: typeof Dialog;
142
- DialogTrigger: typeof DialogTrigger;
143
- DialogPortal: typeof DialogPortal;
144
- DialogClose: typeof DialogClose;
145
- DialogOverlay: typeof DialogOverlay;
146
- DialogContent: typeof DialogContent;
147
- DialogHeader: typeof DialogHeader;
148
- DialogFooter: typeof DialogFooter;
149
- DialogTitle: typeof DialogTitle;
150
- DialogDescription: typeof DialogDescription;
151
- }
152
- }