@vvedantb/ui 0.1.1 → 0.1.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 (74) hide show
  1. package/LICENSE +21 -21
  2. package/package.json +3 -2
  3. package/src/ai-elements/artifact.tsx +99 -99
  4. package/src/ai-elements/attachments.tsx +366 -366
  5. package/src/ai-elements/chain-of-thought.tsx +212 -212
  6. package/src/ai-elements/code-block.tsx +478 -478
  7. package/src/ai-elements/conversation.tsx +157 -157
  8. package/src/ai-elements/image.tsx +25 -25
  9. package/src/ai-elements/inline-citation.tsx +252 -252
  10. package/src/ai-elements/message.tsx +269 -269
  11. package/src/ai-elements/model-selector.tsx +211 -211
  12. package/src/ai-elements/prompt-input.tsx +1018 -1018
  13. package/src/ai-elements/queue.tsx +251 -251
  14. package/src/ai-elements/reasoning.tsx +178 -178
  15. package/src/ai-elements/shimmer.tsx +56 -56
  16. package/src/ai-elements/sources.tsx +77 -77
  17. package/src/ai-elements/speech-input.tsx +290 -290
  18. package/src/ai-elements/suggestion.tsx +191 -191
  19. package/src/css.d.ts +2 -2
  20. package/src/index.ts +96 -96
  21. package/src/motion/presets.ts +35 -35
  22. package/src/motion/presets.vibot.ts +105 -105
  23. package/src/ui/_menu-classes.ts +30 -30
  24. package/src/ui/_menu-classes.vibot.ts +33 -33
  25. package/src/ui/accordion.tsx +81 -81
  26. package/src/ui/accordion.verve.tsx +56 -56
  27. package/src/ui/badge.tsx +34 -34
  28. package/src/ui/breadcrumb.tsx +83 -83
  29. package/src/ui/button-group.tsx +84 -84
  30. package/src/ui/button.tsx +57 -57
  31. package/src/ui/card.tsx +27 -27
  32. package/src/ui/carousel.tsx +211 -211
  33. package/src/ui/checkbox.tsx +27 -27
  34. package/src/ui/clear-input.tsx +170 -170
  35. package/src/ui/clear-input.vibot.tsx +76 -76
  36. package/src/ui/clearInputDissolve.ts +214 -214
  37. package/src/ui/collapsible.tsx +7 -7
  38. package/src/ui/command.tsx +148 -148
  39. package/src/ui/context-menu.tsx +173 -173
  40. package/src/ui/dialog.tsx +149 -149
  41. package/src/ui/dropdown-menu.tsx +178 -178
  42. package/src/ui/hover-card.tsx +31 -31
  43. package/src/ui/input-group.tsx +162 -162
  44. package/src/ui/input-group.verve.tsx +150 -150
  45. package/src/ui/input.tsx +21 -21
  46. package/src/ui/kbd.tsx +18 -18
  47. package/src/ui/label.tsx +20 -20
  48. package/src/ui/labeled-switch-row.tsx +53 -53
  49. package/src/ui/modalTransition.ts +85 -85
  50. package/src/ui/pagination.tsx +47 -47
  51. package/src/ui/popover.tsx +33 -33
  52. package/src/ui/progress.tsx +25 -25
  53. package/src/ui/radix-select.tsx +202 -202
  54. package/src/ui/scroll-area.tsx +55 -55
  55. package/src/ui/scroll-area.verve.tsx +43 -43
  56. package/src/ui/search-input.tsx +29 -29
  57. package/src/ui/select.tsx +163 -163
  58. package/src/ui/separator.tsx +28 -28
  59. package/src/ui/sheet.tsx +100 -87
  60. package/src/ui/skeleton.tsx +18 -18
  61. package/src/ui/sonner.css +16 -16
  62. package/src/ui/sonner.tsx +47 -47
  63. package/src/ui/spinner.tsx +27 -27
  64. package/src/ui/surface-classes.ts +55 -55
  65. package/src/ui/switch.tsx +26 -26
  66. package/src/ui/table.tsx +123 -123
  67. package/src/ui/tabs.tsx +140 -140
  68. package/src/ui/tabsSliding.ts +56 -56
  69. package/src/ui/textarea.tsx +21 -21
  70. package/src/ui/time-picker.tsx +170 -170
  71. package/src/ui/tooltip.tsx +25 -25
  72. package/src/ui/visually-hidden.tsx +3 -3
  73. package/src/utils/cn.ts +16 -16
  74. package/src/utils/ref.ts +10 -10
@@ -1,269 +1,269 @@
1
- "use client";
2
- import type { UIMessage } from "ai";
3
- import type { ComponentProps, HTMLAttributes, ReactElement } from "react";
4
- import { Button } from "../ui/button";
5
- import { ButtonGroup, ButtonGroupText } from "../ui/button-group";
6
- import {
7
- Tooltip,
8
- TooltipContent,
9
- TooltipProvider,
10
- TooltipTrigger,
11
- } from "../ui/tooltip";
12
- import { cn } from "../utils/cn";
13
- import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
14
- import { createContext, useContext, useEffect, useState } from "react";
15
- export type MessageProps = HTMLAttributes<HTMLDivElement> & {
16
- from: UIMessage["role"];
17
- };
18
- export const Message = ({ className, from, ...props }: MessageProps) => (
19
- <div
20
- className={cn(
21
- "group flex w-full max-w-[95%] flex-col gap-2",
22
- from === "user" ? "is-user ml-auto justify-end" : "is-assistant",
23
- className,
24
- )}
25
- {...props}
26
- />
27
- );
28
- export type MessageContentProps = HTMLAttributes<HTMLDivElement>;
29
- export const MessageContent = ({
30
- children,
31
- className,
32
- ...props
33
- }: MessageContentProps) => (
34
- <div
35
- className={cn(
36
- "is-user:dark flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-sm",
37
- "group-[.is-user]:ml-auto group-[.is-user]:rounded-2xl group-[.is-user]:rounded-br-md group-[.is-user]:bg-primary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-primary-foreground",
38
- "group-[.is-assistant]:px-0 group-[.is-assistant]:text-foreground",
39
- className,
40
- )}
41
- {...props}
42
- >
43
- {children}
44
- </div>
45
- );
46
- export type MessageActionsBarProps = ComponentProps<"div">;
47
- export const MessageActionsBar = ({
48
- className,
49
- children,
50
- ...props
51
- }: MessageActionsBarProps) => (
52
- <div className={cn("flex items-center gap-1", className)} {...props}>
53
- {children}
54
- </div>
55
- );
56
- export type MessageActionProps = ComponentProps<typeof Button> & {
57
- tooltip?: string;
58
- label?: string;
59
- };
60
- export const MessageAction = ({
61
- tooltip,
62
- children,
63
- label,
64
- variant = "ghost",
65
- size = "icon-sm",
66
- ...props
67
- }: MessageActionProps) => {
68
- const button = (
69
- <Button size={size} type="button" variant={variant} {...props}>
70
- {children}
71
- <span className="sr-only">{label || tooltip}</span>
72
- </Button>
73
- );
74
- if (tooltip) {
75
- return (
76
- <TooltipProvider>
77
- <Tooltip>
78
- <TooltipTrigger asChild>{button}</TooltipTrigger>
79
- <TooltipContent>
80
- <p>{tooltip}</p>
81
- </TooltipContent>
82
- </Tooltip>
83
- </TooltipProvider>
84
- );
85
- }
86
- return button;
87
- };
88
- interface MessageBranchContextType {
89
- currentBranch: number;
90
- totalBranches: number;
91
- goToPrevious: () => void;
92
- goToNext: () => void;
93
- branches: ReactElement[];
94
- setBranches: (branches: ReactElement[]) => void;
95
- }
96
- const MessageBranchContext = createContext<MessageBranchContextType | null>(
97
- null,
98
- );
99
- const useMessageBranch = () => {
100
- const context = useContext(MessageBranchContext);
101
- if (!context) {
102
- throw new Error(
103
- "MessageBranch components must be used within MessageBranch",
104
- );
105
- }
106
- return context;
107
- };
108
- export type MessageBranchProps = HTMLAttributes<HTMLDivElement> & {
109
- defaultBranch?: number;
110
- onBranchChange?: (branchIndex: number) => void;
111
- };
112
- export const MessageBranch = ({
113
- defaultBranch = 0,
114
- onBranchChange,
115
- className,
116
- ...props
117
- }: MessageBranchProps) => {
118
- const [currentBranch, setCurrentBranch] = useState(defaultBranch);
119
- const [branches, setBranches] = useState<ReactElement[]>([]);
120
- const handleBranchChange = (newBranch: number) => {
121
- setCurrentBranch(newBranch);
122
- onBranchChange?.(newBranch);
123
- };
124
- const goToPrevious = () => {
125
- const newBranch =
126
- currentBranch > 0 ? currentBranch - 1 : branches.length - 1;
127
- handleBranchChange(newBranch);
128
- };
129
- const goToNext = () => {
130
- const newBranch =
131
- currentBranch < branches.length - 1 ? currentBranch + 1 : 0;
132
- handleBranchChange(newBranch);
133
- };
134
- const contextValue = {
135
- branches,
136
- currentBranch,
137
- goToNext,
138
- goToPrevious,
139
- setBranches,
140
- totalBranches: branches.length,
141
- };
142
- return (
143
- <MessageBranchContext.Provider value={contextValue}>
144
- <div
145
- className={cn("grid w-full gap-2 [&>div]:pb-0", className)}
146
- {...props}
147
- />
148
- </MessageBranchContext.Provider>
149
- );
150
- };
151
- export type MessageBranchContentProps = HTMLAttributes<HTMLDivElement>;
152
- export const MessageBranchContent = ({
153
- children,
154
- ...props
155
- }: MessageBranchContentProps) => {
156
- const { currentBranch, setBranches, branches } = useMessageBranch();
157
- const childrenArray = Array.isArray(children) ? children : [children];
158
- useEffect(() => {
159
- if (branches.length !== childrenArray.length) {
160
- setBranches(childrenArray);
161
- }
162
- }, [childrenArray, branches, setBranches]);
163
- return childrenArray.map((branch, index) => (
164
- <div
165
- className={cn(
166
- "grid gap-2 overflow-hidden [&>div]:pb-0",
167
- index === currentBranch ? "block" : "hidden",
168
- )}
169
- key={branch.key}
170
- {...props}
171
- >
172
- {branch}
173
- </div>
174
- ));
175
- };
176
- export type MessageBranchSelectorProps = ComponentProps<typeof ButtonGroup>;
177
- export const MessageBranchSelector = ({
178
- className,
179
- ...props
180
- }: MessageBranchSelectorProps) => {
181
- const { totalBranches } = useMessageBranch();
182
- if (totalBranches <= 1) {
183
- return null;
184
- }
185
- return (
186
- <ButtonGroup
187
- className={cn(
188
- "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
189
- className,
190
- )}
191
- orientation="horizontal"
192
- {...props}
193
- />
194
- );
195
- };
196
- export type MessageBranchPreviousProps = ComponentProps<typeof Button>;
197
- export const MessageBranchPrevious = ({
198
- children,
199
- ...props
200
- }: MessageBranchPreviousProps) => {
201
- const { goToPrevious, totalBranches } = useMessageBranch();
202
- return (
203
- <Button
204
- aria-label="Previous branch"
205
- disabled={totalBranches <= 1}
206
- onClick={goToPrevious}
207
- size="icon-sm"
208
- type="button"
209
- variant="ghost"
210
- {...props}
211
- >
212
- {children ?? <IconChevronLeft size={14} />}
213
- </Button>
214
- );
215
- };
216
- export type MessageBranchNextProps = ComponentProps<typeof Button>;
217
- export const MessageBranchNext = ({
218
- children,
219
- ...props
220
- }: MessageBranchNextProps) => {
221
- const { goToNext, totalBranches } = useMessageBranch();
222
- return (
223
- <Button
224
- aria-label="Next branch"
225
- disabled={totalBranches <= 1}
226
- onClick={goToNext}
227
- size="icon-sm"
228
- type="button"
229
- variant="ghost"
230
- {...props}
231
- >
232
- {children ?? <IconChevronRight size={14} />}
233
- </Button>
234
- );
235
- };
236
- export type MessageBranchPageProps = HTMLAttributes<HTMLSpanElement>;
237
- export const MessageBranchPage = ({
238
- className,
239
- ...props
240
- }: MessageBranchPageProps) => {
241
- const { currentBranch, totalBranches } = useMessageBranch();
242
- return (
243
- <ButtonGroupText
244
- className={cn(
245
- "border-none bg-transparent text-muted shadow-none",
246
- className,
247
- )}
248
- {...props}
249
- >
250
- {currentBranch + 1} of {totalBranches}
251
- </ButtonGroupText>
252
- );
253
- };
254
- export type MessageToolbarProps = ComponentProps<"div">;
255
- export const MessageToolbar = ({
256
- className,
257
- children,
258
- ...props
259
- }: MessageToolbarProps) => (
260
- <div
261
- className={cn(
262
- "mt-4 flex w-full items-center justify-between gap-4",
263
- className,
264
- )}
265
- {...props}
266
- >
267
- {children}
268
- </div>
269
- );
1
+ "use client";
2
+ import type { UIMessage } from "ai";
3
+ import type { ComponentProps, HTMLAttributes, ReactElement } from "react";
4
+ import { Button } from "../ui/button";
5
+ import { ButtonGroup, ButtonGroupText } from "../ui/button-group";
6
+ import {
7
+ Tooltip,
8
+ TooltipContent,
9
+ TooltipProvider,
10
+ TooltipTrigger,
11
+ } from "../ui/tooltip";
12
+ import { cn } from "../utils/cn";
13
+ import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
14
+ import { createContext, useContext, useEffect, useState } from "react";
15
+ export type MessageProps = HTMLAttributes<HTMLDivElement> & {
16
+ from: UIMessage["role"];
17
+ };
18
+ export const Message = ({ className, from, ...props }: MessageProps) => (
19
+ <div
20
+ className={cn(
21
+ "group flex w-full max-w-[95%] flex-col gap-2",
22
+ from === "user" ? "is-user ml-auto justify-end" : "is-assistant",
23
+ className,
24
+ )}
25
+ {...props}
26
+ />
27
+ );
28
+ export type MessageContentProps = HTMLAttributes<HTMLDivElement>;
29
+ export const MessageContent = ({
30
+ children,
31
+ className,
32
+ ...props
33
+ }: MessageContentProps) => (
34
+ <div
35
+ className={cn(
36
+ "flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-sm",
37
+ "group-[.is-user]:ml-auto group-[.is-user]:rounded-2xl group-[.is-user]:rounded-br-md group-[.is-user]:bg-accent group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-accent-foreground",
38
+ "group-[.is-assistant]:px-0 group-[.is-assistant]:text-foreground",
39
+ className,
40
+ )}
41
+ {...props}
42
+ >
43
+ {children}
44
+ </div>
45
+ );
46
+ export type MessageActionsBarProps = ComponentProps<"div">;
47
+ export const MessageActionsBar = ({
48
+ className,
49
+ children,
50
+ ...props
51
+ }: MessageActionsBarProps) => (
52
+ <div className={cn("flex items-center gap-1", className)} {...props}>
53
+ {children}
54
+ </div>
55
+ );
56
+ export type MessageActionProps = ComponentProps<typeof Button> & {
57
+ tooltip?: string;
58
+ label?: string;
59
+ };
60
+ export const MessageAction = ({
61
+ tooltip,
62
+ children,
63
+ label,
64
+ variant = "ghost",
65
+ size = "icon-sm",
66
+ ...props
67
+ }: MessageActionProps) => {
68
+ const button = (
69
+ <Button size={size} type="button" variant={variant} {...props}>
70
+ {children}
71
+ <span className="sr-only">{label || tooltip}</span>
72
+ </Button>
73
+ );
74
+ if (tooltip) {
75
+ return (
76
+ <TooltipProvider>
77
+ <Tooltip>
78
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
79
+ <TooltipContent>
80
+ <p>{tooltip}</p>
81
+ </TooltipContent>
82
+ </Tooltip>
83
+ </TooltipProvider>
84
+ );
85
+ }
86
+ return button;
87
+ };
88
+ interface MessageBranchContextType {
89
+ currentBranch: number;
90
+ totalBranches: number;
91
+ goToPrevious: () => void;
92
+ goToNext: () => void;
93
+ branches: ReactElement[];
94
+ setBranches: (branches: ReactElement[]) => void;
95
+ }
96
+ const MessageBranchContext = createContext<MessageBranchContextType | null>(
97
+ null,
98
+ );
99
+ const useMessageBranch = () => {
100
+ const context = useContext(MessageBranchContext);
101
+ if (!context) {
102
+ throw new Error(
103
+ "MessageBranch components must be used within MessageBranch",
104
+ );
105
+ }
106
+ return context;
107
+ };
108
+ export type MessageBranchProps = HTMLAttributes<HTMLDivElement> & {
109
+ defaultBranch?: number;
110
+ onBranchChange?: (branchIndex: number) => void;
111
+ };
112
+ export const MessageBranch = ({
113
+ defaultBranch = 0,
114
+ onBranchChange,
115
+ className,
116
+ ...props
117
+ }: MessageBranchProps) => {
118
+ const [currentBranch, setCurrentBranch] = useState(defaultBranch);
119
+ const [branches, setBranches] = useState<ReactElement[]>([]);
120
+ const handleBranchChange = (newBranch: number) => {
121
+ setCurrentBranch(newBranch);
122
+ onBranchChange?.(newBranch);
123
+ };
124
+ const goToPrevious = () => {
125
+ const newBranch =
126
+ currentBranch > 0 ? currentBranch - 1 : branches.length - 1;
127
+ handleBranchChange(newBranch);
128
+ };
129
+ const goToNext = () => {
130
+ const newBranch =
131
+ currentBranch < branches.length - 1 ? currentBranch + 1 : 0;
132
+ handleBranchChange(newBranch);
133
+ };
134
+ const contextValue = {
135
+ branches,
136
+ currentBranch,
137
+ goToNext,
138
+ goToPrevious,
139
+ setBranches,
140
+ totalBranches: branches.length,
141
+ };
142
+ return (
143
+ <MessageBranchContext.Provider value={contextValue}>
144
+ <div
145
+ className={cn("grid w-full gap-2 [&>div]:pb-0", className)}
146
+ {...props}
147
+ />
148
+ </MessageBranchContext.Provider>
149
+ );
150
+ };
151
+ export type MessageBranchContentProps = HTMLAttributes<HTMLDivElement>;
152
+ export const MessageBranchContent = ({
153
+ children,
154
+ ...props
155
+ }: MessageBranchContentProps) => {
156
+ const { currentBranch, setBranches, branches } = useMessageBranch();
157
+ const childrenArray = Array.isArray(children) ? children : [children];
158
+ useEffect(() => {
159
+ if (branches.length !== childrenArray.length) {
160
+ setBranches(childrenArray);
161
+ }
162
+ }, [childrenArray, branches, setBranches]);
163
+ return childrenArray.map((branch, index) => (
164
+ <div
165
+ className={cn(
166
+ "grid gap-2 overflow-hidden [&>div]:pb-0",
167
+ index === currentBranch ? "block" : "hidden",
168
+ )}
169
+ key={branch.key}
170
+ {...props}
171
+ >
172
+ {branch}
173
+ </div>
174
+ ));
175
+ };
176
+ export type MessageBranchSelectorProps = ComponentProps<typeof ButtonGroup>;
177
+ export const MessageBranchSelector = ({
178
+ className,
179
+ ...props
180
+ }: MessageBranchSelectorProps) => {
181
+ const { totalBranches } = useMessageBranch();
182
+ if (totalBranches <= 1) {
183
+ return null;
184
+ }
185
+ return (
186
+ <ButtonGroup
187
+ className={cn(
188
+ "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
189
+ className,
190
+ )}
191
+ orientation="horizontal"
192
+ {...props}
193
+ />
194
+ );
195
+ };
196
+ export type MessageBranchPreviousProps = ComponentProps<typeof Button>;
197
+ export const MessageBranchPrevious = ({
198
+ children,
199
+ ...props
200
+ }: MessageBranchPreviousProps) => {
201
+ const { goToPrevious, totalBranches } = useMessageBranch();
202
+ return (
203
+ <Button
204
+ aria-label="Previous branch"
205
+ disabled={totalBranches <= 1}
206
+ onClick={goToPrevious}
207
+ size="icon-sm"
208
+ type="button"
209
+ variant="ghost"
210
+ {...props}
211
+ >
212
+ {children ?? <IconChevronLeft size={14} />}
213
+ </Button>
214
+ );
215
+ };
216
+ export type MessageBranchNextProps = ComponentProps<typeof Button>;
217
+ export const MessageBranchNext = ({
218
+ children,
219
+ ...props
220
+ }: MessageBranchNextProps) => {
221
+ const { goToNext, totalBranches } = useMessageBranch();
222
+ return (
223
+ <Button
224
+ aria-label="Next branch"
225
+ disabled={totalBranches <= 1}
226
+ onClick={goToNext}
227
+ size="icon-sm"
228
+ type="button"
229
+ variant="ghost"
230
+ {...props}
231
+ >
232
+ {children ?? <IconChevronRight size={14} />}
233
+ </Button>
234
+ );
235
+ };
236
+ export type MessageBranchPageProps = HTMLAttributes<HTMLSpanElement>;
237
+ export const MessageBranchPage = ({
238
+ className,
239
+ ...props
240
+ }: MessageBranchPageProps) => {
241
+ const { currentBranch, totalBranches } = useMessageBranch();
242
+ return (
243
+ <ButtonGroupText
244
+ className={cn(
245
+ "border-none bg-transparent text-muted shadow-none",
246
+ className,
247
+ )}
248
+ {...props}
249
+ >
250
+ {currentBranch + 1} of {totalBranches}
251
+ </ButtonGroupText>
252
+ );
253
+ };
254
+ export type MessageToolbarProps = ComponentProps<"div">;
255
+ export const MessageToolbar = ({
256
+ className,
257
+ children,
258
+ ...props
259
+ }: MessageToolbarProps) => (
260
+ <div
261
+ className={cn(
262
+ "mt-4 flex w-full items-center justify-between gap-4",
263
+ className,
264
+ )}
265
+ {...props}
266
+ >
267
+ {children}
268
+ </div>
269
+ );