@agent-native/toolkit 0.6.0 → 0.7.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.
Files changed (173) hide show
  1. package/README.md +17 -1
  2. package/dist/chat-history/ChatHistoryList.d.ts +103 -0
  3. package/dist/chat-history/ChatHistoryList.d.ts.map +1 -0
  4. package/dist/chat-history/ChatHistoryList.js +109 -0
  5. package/dist/chat-history/ChatHistoryList.js.map +1 -0
  6. package/dist/chat-history/ChatHistoryList.spec.d.ts +2 -0
  7. package/dist/chat-history/ChatHistoryList.spec.d.ts.map +1 -0
  8. package/dist/chat-history/ChatHistoryList.spec.js +283 -0
  9. package/dist/chat-history/ChatHistoryList.spec.js.map +1 -0
  10. package/dist/chat-history/index.d.ts +2 -0
  11. package/dist/chat-history/index.d.ts.map +1 -0
  12. package/dist/chat-history/index.js +2 -0
  13. package/dist/chat-history/index.js.map +1 -0
  14. package/dist/chat-history.css +314 -0
  15. package/package.json +17 -1
  16. package/src/app-shell/header-actions.tsx +84 -0
  17. package/src/app-shell/index.ts +1 -0
  18. package/src/chat-history/ChatHistoryList.spec.tsx +453 -0
  19. package/src/chat-history/ChatHistoryList.tsx +469 -0
  20. package/src/chat-history/index.ts +7 -0
  21. package/src/chat-history.css +314 -0
  22. package/src/collab-ui/AgentPresenceChip.tsx +69 -0
  23. package/src/collab-ui/LiveCursorOverlay.tsx +241 -0
  24. package/src/collab-ui/PresenceBar.tsx +346 -0
  25. package/src/collab-ui/RecentEditHighlights.tsx +225 -0
  26. package/src/collab-ui/RemoteSelectionRings.tsx +227 -0
  27. package/src/collab-ui/agent-identity.ts +16 -0
  28. package/src/collab-ui/index.ts +39 -0
  29. package/src/collab-ui/lead-client.ts +32 -0
  30. package/src/collab-ui/types.spec.ts +18 -0
  31. package/src/collab-ui/types.ts +96 -0
  32. package/src/composer/AgentComposerFrame.tsx +59 -0
  33. package/src/composer/ComposerPlusMenu.tsx +983 -0
  34. package/src/composer/MentionPopover.tsx +412 -0
  35. package/src/composer/PastedTextChip.tsx +150 -0
  36. package/src/composer/PromptComposer.spec.ts +73 -0
  37. package/src/composer/PromptComposer.tsx +718 -0
  38. package/src/composer/RealtimeVoiceMode.spec.tsx +771 -0
  39. package/src/composer/RealtimeVoiceMode.tsx +856 -0
  40. package/src/composer/TiptapComposer.spec.ts +390 -0
  41. package/src/composer/TiptapComposer.tsx +2936 -0
  42. package/src/composer/VoiceButton.spec.ts +33 -0
  43. package/src/composer/VoiceButton.tsx +255 -0
  44. package/src/composer/asset-picker-url.spec.ts +56 -0
  45. package/src/composer/asset-picker-url.ts +80 -0
  46. package/src/composer/attachment-accept.spec.ts +22 -0
  47. package/src/composer/attachment-accept.ts +71 -0
  48. package/src/composer/draft-key.spec.ts +19 -0
  49. package/src/composer/draft-key.ts +7 -0
  50. package/src/composer/extensions/FileReference.tsx +55 -0
  51. package/src/composer/extensions/MentionReference.tsx +93 -0
  52. package/src/composer/extensions/SkillReference.tsx +56 -0
  53. package/src/composer/index.ts +79 -0
  54. package/src/composer/pasted-text.spec.ts +162 -0
  55. package/src/composer/pasted-text.ts +160 -0
  56. package/src/composer/prompt-attachments.spec.ts +80 -0
  57. package/src/composer/prompt-attachments.ts +93 -0
  58. package/src/composer/realtime-voice-audio-level.spec.ts +32 -0
  59. package/src/composer/realtime-voice-audio-level.ts +64 -0
  60. package/src/composer/realtime-voice-transcript.spec.ts +95 -0
  61. package/src/composer/realtime-voice-transcript.ts +134 -0
  62. package/src/composer/runtime-adapters.tsx +343 -0
  63. package/src/composer/types.ts +66 -0
  64. package/src/composer/use-file-search.ts +64 -0
  65. package/src/composer/use-mention-search.ts +90 -0
  66. package/src/composer/use-skills.ts +45 -0
  67. package/src/composer/useRealtimeVoiceMode.spec.ts +818 -0
  68. package/src/composer/useRealtimeVoiceMode.tsx +2117 -0
  69. package/src/composer/useVoiceDictation.spec.ts +45 -0
  70. package/src/composer/useVoiceDictation.ts +1191 -0
  71. package/src/context-ui/ContextMeter.tsx +101 -0
  72. package/src/context-ui/ContextSegmentRow.tsx +184 -0
  73. package/src/context-ui/ContextTreemap.tsx +125 -0
  74. package/src/context-ui/ContextXRayPanel.tsx +377 -0
  75. package/src/context-ui/format.ts +42 -0
  76. package/src/context-ui/index.ts +15 -0
  77. package/src/context-ui/types.ts +43 -0
  78. package/src/design-tweaks/index.ts +1 -0
  79. package/src/design-tweaks/visual-style-controls.tsx +1084 -0
  80. package/src/editor/BubbleToolbar.tsx +253 -0
  81. package/src/editor/CodeBlockNode.tsx +254 -0
  82. package/src/editor/DragHandle.spec.ts +588 -0
  83. package/src/editor/DragHandle.ts +1437 -0
  84. package/src/editor/ImageExtension.roundtrip.spec.ts +117 -0
  85. package/src/editor/ImageExtension.ts +306 -0
  86. package/src/editor/RegistryBlockContext.tsx +107 -0
  87. package/src/editor/RegistryBlockNode.spec.ts +279 -0
  88. package/src/editor/RegistryBlockNode.tsx +652 -0
  89. package/src/editor/RichMarkdownEditor.collab.spec.ts +79 -0
  90. package/src/editor/RichMarkdownEditor.roundtrip.spec.ts +226 -0
  91. package/src/editor/RichMarkdownEditor.tsx +81 -0
  92. package/src/editor/RunId.ts +61 -0
  93. package/src/editor/SharedRichEditor.tsx +321 -0
  94. package/src/editor/SlashCommandMenu.tsx +310 -0
  95. package/src/editor/disableHistory.spec.ts +85 -0
  96. package/src/editor/extensions.ts +402 -0
  97. package/src/editor/gfmDoc.spec.ts +230 -0
  98. package/src/editor/gfmDoc.ts +92 -0
  99. package/src/editor/index.ts +93 -0
  100. package/src/editor/registrySlashCommands.ts +131 -0
  101. package/src/editor/structuralReorderUndo.spec.ts +144 -0
  102. package/src/editor/surgical-apply.spec.ts +279 -0
  103. package/src/editor/surgical-apply.ts +192 -0
  104. package/src/editor/useCollabReconcile.concurrent.spec.ts +422 -0
  105. package/src/editor/useCollabReconcile.idempotent.spec.ts +324 -0
  106. package/src/editor/useCollabReconcile.ts +589 -0
  107. package/src/editor.css +510 -0
  108. package/src/hooks/index.ts +2 -0
  109. package/src/hooks/use-mobile.tsx +21 -0
  110. package/src/hooks/use-toast.ts +188 -0
  111. package/src/index.ts +8 -0
  112. package/src/onboarding/index.ts +1 -0
  113. package/src/provider.tsx +47 -0
  114. package/src/sharing/VisibilityBadge.spec.ts +96 -0
  115. package/src/sharing/VisibilityBadge.tsx +37 -0
  116. package/src/sharing/index.ts +4 -0
  117. package/src/styles.css +21 -0
  118. package/src/ui/accordion.tsx +56 -0
  119. package/src/ui/alert-dialog.tsx +141 -0
  120. package/src/ui/alert.tsx +59 -0
  121. package/src/ui/aspect-ratio.tsx +5 -0
  122. package/src/ui/avatar.tsx +48 -0
  123. package/src/ui/badge.tsx +37 -0
  124. package/src/ui/breadcrumb.tsx +115 -0
  125. package/src/ui/button.tsx +78 -0
  126. package/src/ui/calendar.tsx +214 -0
  127. package/src/ui/card.tsx +86 -0
  128. package/src/ui/carousel.tsx +260 -0
  129. package/src/ui/chart.tsx +375 -0
  130. package/src/ui/checkbox.tsx +28 -0
  131. package/src/ui/collapsible.tsx +9 -0
  132. package/src/ui/command.spec.tsx +51 -0
  133. package/src/ui/command.tsx +174 -0
  134. package/src/ui/context-menu.tsx +202 -0
  135. package/src/ui/date-picker.tsx +64 -0
  136. package/src/ui/dialog.spec.tsx +43 -0
  137. package/src/ui/dialog.tsx +146 -0
  138. package/src/ui/drawer.tsx +126 -0
  139. package/src/ui/dropdown-menu.tsx +218 -0
  140. package/src/ui/form.tsx +177 -0
  141. package/src/ui/hover-card.tsx +27 -0
  142. package/src/ui/index.ts +52 -0
  143. package/src/ui/input-otp.tsx +69 -0
  144. package/src/ui/input.tsx +22 -0
  145. package/src/ui/label.tsx +24 -0
  146. package/src/ui/logo.tsx +36 -0
  147. package/src/ui/menubar.tsx +235 -0
  148. package/src/ui/navigation-menu.tsx +128 -0
  149. package/src/ui/pagination.tsx +121 -0
  150. package/src/ui/popover.tsx +44 -0
  151. package/src/ui/progress.tsx +26 -0
  152. package/src/ui/radio-group.tsx +42 -0
  153. package/src/ui/resizable.tsx +43 -0
  154. package/src/ui/scroll-area.tsx +46 -0
  155. package/src/ui/select.tsx +158 -0
  156. package/src/ui/separator.tsx +29 -0
  157. package/src/ui/sheet.tsx +160 -0
  158. package/src/ui/sidebar.tsx +777 -0
  159. package/src/ui/skeleton.tsx +18 -0
  160. package/src/ui/slider.tsx +26 -0
  161. package/src/ui/sonner.tsx +58 -0
  162. package/src/ui/spinner.tsx +17 -0
  163. package/src/ui/switch.tsx +27 -0
  164. package/src/ui/table.tsx +117 -0
  165. package/src/ui/tabs.tsx +53 -0
  166. package/src/ui/textarea.tsx +23 -0
  167. package/src/ui/toast.tsx +127 -0
  168. package/src/ui/toaster.tsx +33 -0
  169. package/src/ui/toggle-group.tsx +59 -0
  170. package/src/ui/toggle.tsx +43 -0
  171. package/src/ui/tooltip.tsx +53 -0
  172. package/src/ui/use-toast.ts +3 -0
  173. package/src/utils.ts +8 -0
@@ -0,0 +1,375 @@
1
+ import * as React from "react";
2
+ import * as RechartsPrimitive from "recharts";
3
+
4
+ import { cn } from "../utils.js";
5
+
6
+ // Format: { THEME_NAME: CSS_SELECTOR }
7
+ const THEMES = { light: "", dark: ".dark" } as const;
8
+
9
+ export type ChartConfig = {
10
+ [k in string]: {
11
+ label?: React.ReactNode;
12
+ icon?: React.ComponentType;
13
+ } & (
14
+ | { color?: string; theme?: never }
15
+ | { color?: never; theme: Record<keyof typeof THEMES, string> }
16
+ );
17
+ };
18
+
19
+ type ChartContextProps = {
20
+ config: ChartConfig;
21
+ };
22
+
23
+ const ChartContext = React.createContext<ChartContextProps | null>(null);
24
+
25
+ function useChart() {
26
+ const context = React.useContext(ChartContext);
27
+
28
+ if (!context) {
29
+ throw new Error("useChart must be used within a <ChartContainer />");
30
+ }
31
+
32
+ return context;
33
+ }
34
+
35
+ const ChartContainer = React.forwardRef<
36
+ HTMLDivElement,
37
+ React.ComponentProps<"div"> & {
38
+ config: ChartConfig;
39
+ children: React.ComponentProps<
40
+ typeof RechartsPrimitive.ResponsiveContainer
41
+ >["children"];
42
+ }
43
+ >(({ id, className, children, config, ...props }, ref) => {
44
+ const uniqueId = React.useId();
45
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
46
+
47
+ return (
48
+ <ChartContext.Provider value={{ config }}>
49
+ <div
50
+ data-chart={chartId}
51
+ ref={ref}
52
+ className={cn(
53
+ "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
54
+ className,
55
+ )}
56
+ {...props}
57
+ >
58
+ <ChartStyle id={chartId} config={config} />
59
+ <RechartsPrimitive.ResponsiveContainer>
60
+ {children}
61
+ </RechartsPrimitive.ResponsiveContainer>
62
+ </div>
63
+ </ChartContext.Provider>
64
+ );
65
+ });
66
+ ChartContainer.displayName = "Chart";
67
+
68
+ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
69
+ const colorConfig = Object.entries(config).filter(
70
+ ([_, config]) => config.theme || config.color,
71
+ );
72
+
73
+ if (!colorConfig.length) {
74
+ return null;
75
+ }
76
+
77
+ return (
78
+ <style
79
+ dangerouslySetInnerHTML={{
80
+ __html: Object.entries(THEMES)
81
+ .map(
82
+ ([theme, prefix]) => `
83
+ ${prefix} [data-chart=${id}] {
84
+ ${colorConfig
85
+ .map(([key, itemConfig]) => {
86
+ const color =
87
+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
88
+ itemConfig.color;
89
+ return color ? ` --color-${key}: ${color};` : null;
90
+ })
91
+ .join("\n")}
92
+ }
93
+ `,
94
+ )
95
+ .join("\n"),
96
+ }}
97
+ />
98
+ );
99
+ };
100
+
101
+ const ChartTooltip = RechartsPrimitive.Tooltip;
102
+
103
+ const ChartTooltipContent = React.forwardRef<
104
+ HTMLDivElement,
105
+ RechartsPrimitive.TooltipProps<string | number, string> &
106
+ React.ComponentProps<"div"> & {
107
+ active?: boolean;
108
+ payload?: ReadonlyArray<
109
+ RechartsPrimitive.TooltipPayloadEntry<string | number, string>
110
+ >;
111
+ label?: React.ReactNode;
112
+ hideLabel?: boolean;
113
+ hideIndicator?: boolean;
114
+ indicator?: "line" | "dot" | "dashed";
115
+ nameKey?: string;
116
+ labelKey?: string;
117
+ }
118
+ >(
119
+ (
120
+ {
121
+ active,
122
+ payload,
123
+ className,
124
+ indicator = "dot",
125
+ hideLabel = false,
126
+ hideIndicator = false,
127
+ label,
128
+ labelFormatter,
129
+ labelClassName,
130
+ formatter,
131
+ color,
132
+ nameKey,
133
+ labelKey,
134
+ },
135
+ ref,
136
+ ) => {
137
+ const { config } = useChart();
138
+
139
+ const tooltipLabel = React.useMemo(() => {
140
+ if (hideLabel || !payload?.length) {
141
+ return null;
142
+ }
143
+
144
+ const [item] = payload;
145
+ const key = `${labelKey || item.dataKey || item.name || "value"}`;
146
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
147
+ const value =
148
+ !labelKey && typeof label === "string"
149
+ ? config[label as keyof typeof config]?.label || label
150
+ : itemConfig?.label;
151
+
152
+ if (labelFormatter) {
153
+ return (
154
+ <div className={cn("font-medium", labelClassName)}>
155
+ {labelFormatter(value, payload)}
156
+ </div>
157
+ );
158
+ }
159
+
160
+ if (!value) {
161
+ return null;
162
+ }
163
+
164
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>;
165
+ }, [
166
+ label,
167
+ labelFormatter,
168
+ payload,
169
+ hideLabel,
170
+ labelClassName,
171
+ config,
172
+ labelKey,
173
+ ]);
174
+
175
+ if (!active || !payload?.length) {
176
+ return null;
177
+ }
178
+
179
+ const nestLabel = payload.length === 1 && indicator !== "dot";
180
+
181
+ return (
182
+ <div
183
+ ref={ref}
184
+ className={cn(
185
+ "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
186
+ className,
187
+ )}
188
+ >
189
+ {!nestLabel ? tooltipLabel : null}
190
+ <div className="grid gap-1.5">
191
+ {payload.map((item, index) => {
192
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
193
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
194
+ const indicatorColor = color || item.payload.fill || item.color;
195
+
196
+ return (
197
+ <div
198
+ key={key}
199
+ className={cn(
200
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
201
+ indicator === "dot" && "items-center",
202
+ )}
203
+ >
204
+ {formatter && item?.value !== undefined && item.name ? (
205
+ formatter(item.value, item.name, item, index, item.payload)
206
+ ) : (
207
+ <>
208
+ {itemConfig?.icon ? (
209
+ <itemConfig.icon />
210
+ ) : (
211
+ !hideIndicator && (
212
+ <div
213
+ className={cn(
214
+ "shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",
215
+ {
216
+ "h-2.5 w-2.5": indicator === "dot",
217
+ "w-1": indicator === "line",
218
+ "w-0 border-[1.5px] border-dashed bg-transparent":
219
+ indicator === "dashed",
220
+ "my-0.5": nestLabel && indicator === "dashed",
221
+ },
222
+ )}
223
+ style={
224
+ {
225
+ "--color-bg": indicatorColor,
226
+ "--color-border": indicatorColor,
227
+ } as React.CSSProperties
228
+ }
229
+ />
230
+ )
231
+ )}
232
+ <div
233
+ className={cn(
234
+ "flex flex-1 justify-between leading-none",
235
+ nestLabel ? "items-end" : "items-center",
236
+ )}
237
+ >
238
+ <div className="grid gap-1.5">
239
+ {nestLabel ? tooltipLabel : null}
240
+ <span className="text-muted-foreground">
241
+ {itemConfig?.label || item.name}
242
+ </span>
243
+ </div>
244
+ {item.value && (
245
+ <span className="font-mono font-medium tabular-nums text-foreground">
246
+ {item.value.toLocaleString()}
247
+ </span>
248
+ )}
249
+ </div>
250
+ </>
251
+ )}
252
+ </div>
253
+ );
254
+ })}
255
+ </div>
256
+ </div>
257
+ );
258
+ },
259
+ );
260
+ ChartTooltipContent.displayName = "ChartTooltip";
261
+
262
+ const ChartLegend = RechartsPrimitive.Legend;
263
+
264
+ const ChartLegendContent = React.forwardRef<
265
+ HTMLDivElement,
266
+ React.ComponentProps<"div"> & {
267
+ payload?: Array<{
268
+ value: string;
269
+ color?: string;
270
+ dataKey?: string | number;
271
+ type?: string;
272
+ }>;
273
+ verticalAlign?: "top" | "bottom";
274
+ } & {
275
+ hideIcon?: boolean;
276
+ nameKey?: string;
277
+ }
278
+ >(
279
+ (
280
+ { className, hideIcon = false, payload, verticalAlign = "bottom", nameKey },
281
+ ref,
282
+ ) => {
283
+ const { config } = useChart();
284
+
285
+ if (!payload?.length) {
286
+ return null;
287
+ }
288
+
289
+ return (
290
+ <div
291
+ ref={ref}
292
+ className={cn(
293
+ "flex items-center justify-center gap-4",
294
+ verticalAlign === "top" ? "pb-3" : "pt-3",
295
+ className,
296
+ )}
297
+ >
298
+ {payload.map((item) => {
299
+ const key = `${nameKey || item.dataKey || "value"}`;
300
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
301
+
302
+ return (
303
+ <div
304
+ key={item.value}
305
+ className={cn(
306
+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",
307
+ )}
308
+ >
309
+ {itemConfig?.icon && !hideIcon ? (
310
+ <itemConfig.icon />
311
+ ) : (
312
+ <div
313
+ className="h-2 w-2 shrink-0 rounded-[2px]"
314
+ style={{
315
+ backgroundColor: item.color,
316
+ }}
317
+ />
318
+ )}
319
+ {itemConfig?.label}
320
+ </div>
321
+ );
322
+ })}
323
+ </div>
324
+ );
325
+ },
326
+ );
327
+ ChartLegendContent.displayName = "ChartLegend";
328
+
329
+ // Helper to extract item config from a payload.
330
+ function getPayloadConfigFromPayload(
331
+ config: ChartConfig,
332
+ payload: unknown,
333
+ key: string,
334
+ ) {
335
+ if (typeof payload !== "object" || payload === null) {
336
+ return undefined;
337
+ }
338
+
339
+ const payloadPayload =
340
+ "payload" in payload &&
341
+ typeof payload.payload === "object" &&
342
+ payload.payload !== null
343
+ ? payload.payload
344
+ : undefined;
345
+
346
+ let configLabelKey: string = key;
347
+
348
+ if (
349
+ key in payload &&
350
+ typeof payload[key as keyof typeof payload] === "string"
351
+ ) {
352
+ configLabelKey = payload[key as keyof typeof payload] as string;
353
+ } else if (
354
+ payloadPayload &&
355
+ key in payloadPayload &&
356
+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
357
+ ) {
358
+ configLabelKey = payloadPayload[
359
+ key as keyof typeof payloadPayload
360
+ ] as string;
361
+ }
362
+
363
+ return configLabelKey in config
364
+ ? config[configLabelKey]
365
+ : config[key as keyof typeof config];
366
+ }
367
+
368
+ export {
369
+ ChartContainer,
370
+ ChartTooltip,
371
+ ChartTooltipContent,
372
+ ChartLegend,
373
+ ChartLegendContent,
374
+ ChartStyle,
375
+ };
@@ -0,0 +1,28 @@
1
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
2
+ import { IconCheck } from "@tabler/icons-react";
3
+ import * as React from "react";
4
+
5
+ import { cn } from "../utils.js";
6
+
7
+ const Checkbox = React.forwardRef<
8
+ React.ElementRef<typeof CheckboxPrimitive.Root>,
9
+ React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
10
+ >(({ className, ...props }, ref) => (
11
+ <CheckboxPrimitive.Root
12
+ ref={ref}
13
+ className={cn(
14
+ "peer h-4 w-4 shrink-0 transition-colors duration-150 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
15
+ className,
16
+ )}
17
+ {...props}
18
+ >
19
+ <CheckboxPrimitive.Indicator
20
+ className={cn("flex items-center justify-center text-current")}
21
+ >
22
+ <IconCheck className="h-4 w-4" />
23
+ </CheckboxPrimitive.Indicator>
24
+ </CheckboxPrimitive.Root>
25
+ ));
26
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
27
+
28
+ export { Checkbox };
@@ -0,0 +1,9 @@
1
+ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
2
+
3
+ const Collapsible = CollapsiblePrimitive.Root;
4
+
5
+ const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
6
+
7
+ const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
8
+
9
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent };
@@ -0,0 +1,51 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ import { CommandDialog } from "./command.js";
5
+
6
+ interface CommandDialogElement extends ReactElement {
7
+ props: {
8
+ children: ReactElement<{
9
+ children: ReactNode;
10
+ motion: "default" | "instant";
11
+ }>;
12
+ };
13
+ }
14
+
15
+ function renderCommandDialog(
16
+ motion?: "default" | "instant",
17
+ commandProps?: React.ComponentProps<typeof CommandDialog>["commandProps"],
18
+ ): CommandDialogElement {
19
+ return CommandDialog({
20
+ children: "Commands",
21
+ motion,
22
+ commandProps,
23
+ }) as CommandDialogElement;
24
+ }
25
+
26
+ describe("CommandDialog", () => {
27
+ it("preserves standard dialog motion by default", () => {
28
+ expect(renderCommandDialog().props.children.props.motion).toBe("default");
29
+ });
30
+
31
+ it("passes the instant motion option to its dialog content", () => {
32
+ expect(renderCommandDialog("instant").props.children.props.motion).toBe(
33
+ "instant",
34
+ );
35
+ });
36
+
37
+ it("forwards command root behavior props", () => {
38
+ const filter = () => 1;
39
+ const dialog = renderCommandDialog(undefined, {
40
+ filter,
41
+ value: "selected-command",
42
+ });
43
+ const content = dialog.props.children;
44
+ const command = (
45
+ content.props.children as ReactElement<Record<string, unknown>>[]
46
+ )[1];
47
+
48
+ expect(command.props.filter).toBe(filter);
49
+ expect(command.props.value).toBe("selected-command");
50
+ });
51
+ });
@@ -0,0 +1,174 @@
1
+ import { type DialogProps } from "@radix-ui/react-dialog";
2
+ import { IconSearch } from "@tabler/icons-react";
3
+ import { Command as CommandPrimitive } from "cmdk";
4
+ import * as React from "react";
5
+
6
+ import { cn } from "../utils.js";
7
+ import { Dialog, DialogContent, DialogTitle } from "./dialog.js";
8
+
9
+ const Command = React.forwardRef<
10
+ React.ElementRef<typeof CommandPrimitive>,
11
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive>
12
+ >(({ className, ...props }, ref) => (
13
+ <CommandPrimitive
14
+ ref={ref}
15
+ className={cn(
16
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
17
+ className,
18
+ )}
19
+ {...props}
20
+ />
21
+ ));
22
+ Command.displayName = CommandPrimitive.displayName;
23
+
24
+ interface CommandDialogProps extends DialogProps {
25
+ motion?: "default" | "instant";
26
+ commandProps?: Omit<
27
+ React.ComponentPropsWithoutRef<typeof Command>,
28
+ "children"
29
+ >;
30
+ }
31
+
32
+ const CommandDialog = ({
33
+ children,
34
+ motion = "default",
35
+ commandProps,
36
+ ...props
37
+ }: CommandDialogProps) => {
38
+ return (
39
+ <Dialog {...props}>
40
+ <DialogContent
41
+ className="top-[15vh] translate-y-0 overflow-hidden p-0 shadow-lg"
42
+ motion={motion}
43
+ >
44
+ <DialogTitle className="sr-only">Command menu</DialogTitle>
45
+ <Command
46
+ {...commandProps}
47
+ className={cn(
48
+ "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",
49
+ commandProps?.className,
50
+ )}
51
+ >
52
+ {children}
53
+ </Command>
54
+ </DialogContent>
55
+ </Dialog>
56
+ );
57
+ };
58
+
59
+ const CommandInput = React.forwardRef<
60
+ React.ElementRef<typeof CommandPrimitive.Input>,
61
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
62
+ >(({ className, ...props }, ref) => (
63
+ <div className="flex items-center border-b px-3" cmdk-input-wrapper="">
64
+ <IconSearch className="me-2 h-4 w-4 shrink-0 opacity-50" />
65
+ <CommandPrimitive.Input
66
+ ref={ref}
67
+ className={cn(
68
+ "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
69
+ className,
70
+ )}
71
+ {...props}
72
+ />
73
+ </div>
74
+ ));
75
+
76
+ CommandInput.displayName = CommandPrimitive.Input.displayName;
77
+
78
+ const CommandList = React.forwardRef<
79
+ React.ElementRef<typeof CommandPrimitive.List>,
80
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
81
+ >(({ className, ...props }, ref) => (
82
+ <CommandPrimitive.List
83
+ ref={ref}
84
+ className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
85
+ {...props}
86
+ />
87
+ ));
88
+
89
+ CommandList.displayName = CommandPrimitive.List.displayName;
90
+
91
+ const CommandEmpty = React.forwardRef<
92
+ React.ElementRef<typeof CommandPrimitive.Empty>,
93
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
94
+ >((props, ref) => (
95
+ <CommandPrimitive.Empty
96
+ ref={ref}
97
+ className="py-6 text-center text-sm"
98
+ {...props}
99
+ />
100
+ ));
101
+
102
+ CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
103
+
104
+ const CommandGroup = React.forwardRef<
105
+ React.ElementRef<typeof CommandPrimitive.Group>,
106
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
107
+ >(({ className, ...props }, ref) => (
108
+ <CommandPrimitive.Group
109
+ ref={ref}
110
+ className={cn(
111
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
112
+ className,
113
+ )}
114
+ {...props}
115
+ />
116
+ ));
117
+
118
+ CommandGroup.displayName = CommandPrimitive.Group.displayName;
119
+
120
+ const CommandSeparator = React.forwardRef<
121
+ React.ElementRef<typeof CommandPrimitive.Separator>,
122
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
123
+ >(({ className, ...props }, ref) => (
124
+ <CommandPrimitive.Separator
125
+ ref={ref}
126
+ className={cn("-mx-1 h-px bg-border", className)}
127
+ {...props}
128
+ />
129
+ ));
130
+ CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
131
+
132
+ const CommandItem = React.forwardRef<
133
+ React.ElementRef<typeof CommandPrimitive.Item>,
134
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
135
+ >(({ className, ...props }, ref) => (
136
+ <CommandPrimitive.Item
137
+ ref={ref}
138
+ className={cn(
139
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
140
+ className,
141
+ )}
142
+ {...props}
143
+ />
144
+ ));
145
+
146
+ CommandItem.displayName = CommandPrimitive.Item.displayName;
147
+
148
+ const CommandShortcut = ({
149
+ className,
150
+ ...props
151
+ }: React.HTMLAttributes<HTMLSpanElement>) => {
152
+ return (
153
+ <span
154
+ className={cn(
155
+ "ms-auto text-xs tracking-widest text-muted-foreground",
156
+ className,
157
+ )}
158
+ {...props}
159
+ />
160
+ );
161
+ };
162
+ CommandShortcut.displayName = "CommandShortcut";
163
+
164
+ export {
165
+ Command,
166
+ CommandDialog,
167
+ CommandInput,
168
+ CommandList,
169
+ CommandEmpty,
170
+ CommandGroup,
171
+ CommandItem,
172
+ CommandShortcut,
173
+ CommandSeparator,
174
+ };