create-disposabl-app 0.9.1 → 0.10.1

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 (90) hide show
  1. package/dist/disposabl.js +1 -1
  2. package/dist/index.js +2 -2
  3. package/dist/templates/default/.github/workflows/pipeline.yml +1 -1
  4. package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +1 -1
  5. package/dist/templates/default/bun.lock +77 -1397
  6. package/dist/templates/default/package.json +1 -2
  7. package/dist/templates/default/packages/backend/README.md +3 -1
  8. package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +6 -0
  9. package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +0 -2
  10. package/dist/templates/default/packages/backend/convex/auth.config.ts +2 -10
  11. package/dist/templates/default/packages/backend/convex/convex.config.ts +3 -14
  12. package/dist/templates/default/packages/backend/convex/mcpEnterprise/README.md +42 -0
  13. package/dist/templates/default/packages/backend/convex/mcpEnterprise/internal.ts +153 -0
  14. package/dist/templates/default/packages/backend/convex/mcpEnterprise/provision.ts +102 -0
  15. package/dist/templates/default/packages/backend/convex/mcpEnterprise/validator.ts +35 -0
  16. package/dist/templates/default/packages/backend/convex/schema.ts +18 -0
  17. package/dist/templates/default/packages/backend/package.json +0 -1
  18. package/dist/templates/default/packages/cli/README.md +9 -24
  19. package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/login.tsx +1 -1
  20. package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/signUp.tsx +1 -1
  21. package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +71 -13
  22. package/dist/templates/default/packages/disposabl-kit/package.json +4 -14
  23. package/dist/templates/default/packages/disposabl-kit/server/http.ts +19 -12
  24. package/dist/templates/default/packages/disposabl-kit/server/lib/functions.ts +12 -0
  25. package/dist/templates/default/packages/disposabl-kit/server/mcp/enterprise.ts +267 -0
  26. package/dist/templates/default/packages/disposabl-kit/server/mcp/identity.ts +33 -0
  27. package/dist/templates/default/vendor/README.md +30 -0
  28. package/dist/templates/default/vendor/convex-auth-6c0ebf3f.tgz +0 -0
  29. package/package.json +1 -1
  30. package/dist/templates/default/apps/web/src/components/connections/expo-connection.tsx +0 -97
  31. package/dist/templates/default/apps/web/src/components/connections/provider-logo.tsx +0 -44
  32. package/dist/templates/default/apps/web/src/components/connections/use-connection-setup.ts +0 -169
  33. package/dist/templates/default/packages/disposabl-kit/client/components/ui/accordion.tsx +0 -77
  34. package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert-dialog.tsx +0 -185
  35. package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert.tsx +0 -75
  36. package/dist/templates/default/packages/disposabl-kit/client/components/ui/aspect-ratio.tsx +0 -22
  37. package/dist/templates/default/packages/disposabl-kit/client/components/ui/attachment.tsx +0 -207
  38. package/dist/templates/default/packages/disposabl-kit/client/components/ui/avatar.tsx +0 -106
  39. package/dist/templates/default/packages/disposabl-kit/client/components/ui/badge.tsx +0 -51
  40. package/dist/templates/default/packages/disposabl-kit/client/components/ui/breadcrumb.tsx +0 -121
  41. package/dist/templates/default/packages/disposabl-kit/client/components/ui/bubble.tsx +0 -127
  42. package/dist/templates/default/packages/disposabl-kit/client/components/ui/button-group.tsx +0 -87
  43. package/dist/templates/default/packages/disposabl-kit/client/components/ui/calendar.tsx +0 -241
  44. package/dist/templates/default/packages/disposabl-kit/client/components/ui/carousel.tsx +0 -239
  45. package/dist/templates/default/packages/disposabl-kit/client/components/ui/chart.tsx +0 -368
  46. package/dist/templates/default/packages/disposabl-kit/client/components/ui/checkbox.tsx +0 -27
  47. package/dist/templates/default/packages/disposabl-kit/client/components/ui/code-block.tsx +0 -243
  48. package/dist/templates/default/packages/disposabl-kit/client/components/ui/collapsible.tsx +0 -19
  49. package/dist/templates/default/packages/disposabl-kit/client/components/ui/combobox.tsx +0 -300
  50. package/dist/templates/default/packages/disposabl-kit/client/components/ui/command.tsx +0 -194
  51. package/dist/templates/default/packages/disposabl-kit/client/components/ui/context-menu.tsx +0 -271
  52. package/dist/templates/default/packages/disposabl-kit/client/components/ui/dialog.tsx +0 -156
  53. package/dist/templates/default/packages/disposabl-kit/client/components/ui/direction.tsx +0 -4
  54. package/dist/templates/default/packages/disposabl-kit/client/components/ui/drawer.tsx +0 -224
  55. package/dist/templates/default/packages/disposabl-kit/client/components/ui/dropdown-menu.tsx +0 -269
  56. package/dist/templates/default/packages/disposabl-kit/client/components/ui/empty.tsx +0 -103
  57. package/dist/templates/default/packages/disposabl-kit/client/components/ui/hover-card.tsx +0 -50
  58. package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-group.tsx +0 -158
  59. package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-otp.tsx +0 -83
  60. package/dist/templates/default/packages/disposabl-kit/client/components/ui/item.tsx +0 -201
  61. package/dist/templates/default/packages/disposabl-kit/client/components/ui/kbd.tsx +0 -26
  62. package/dist/templates/default/packages/disposabl-kit/client/components/ui/marker.tsx +0 -70
  63. package/dist/templates/default/packages/disposabl-kit/client/components/ui/menubar.tsx +0 -284
  64. package/dist/templates/default/packages/disposabl-kit/client/components/ui/message-scroller.tsx +0 -128
  65. package/dist/templates/default/packages/disposabl-kit/client/components/ui/message.tsx +0 -91
  66. package/dist/templates/default/packages/disposabl-kit/client/components/ui/native-select.tsx +0 -64
  67. package/dist/templates/default/packages/disposabl-kit/client/components/ui/navigation-menu.tsx +0 -170
  68. package/dist/templates/default/packages/disposabl-kit/client/components/ui/pagination.tsx +0 -133
  69. package/dist/templates/default/packages/disposabl-kit/client/components/ui/popover.tsx +0 -87
  70. package/dist/templates/default/packages/disposabl-kit/client/components/ui/progress.tsx +0 -82
  71. package/dist/templates/default/packages/disposabl-kit/client/components/ui/questionnaire.tsx +0 -330
  72. package/dist/templates/default/packages/disposabl-kit/client/components/ui/radio-group.tsx +0 -35
  73. package/dist/templates/default/packages/disposabl-kit/client/components/ui/resizable.tsx +0 -49
  74. package/dist/templates/default/packages/disposabl-kit/client/components/ui/scroll-area.tsx +0 -51
  75. package/dist/templates/default/packages/disposabl-kit/client/components/ui/select.tsx +0 -201
  76. package/dist/templates/default/packages/disposabl-kit/client/components/ui/sheet.tsx +0 -132
  77. package/dist/templates/default/packages/disposabl-kit/client/components/ui/sidebar.tsx +0 -723
  78. package/dist/templates/default/packages/disposabl-kit/client/components/ui/skeleton.tsx +0 -13
  79. package/dist/templates/default/packages/disposabl-kit/client/components/ui/slider.tsx +0 -51
  80. package/dist/templates/default/packages/disposabl-kit/client/components/ui/switch.tsx +0 -31
  81. package/dist/templates/default/packages/disposabl-kit/client/components/ui/table.tsx +0 -113
  82. package/dist/templates/default/packages/disposabl-kit/client/components/ui/tabs.tsx +0 -81
  83. package/dist/templates/default/packages/disposabl-kit/client/components/ui/textarea.tsx +0 -17
  84. package/dist/templates/default/packages/disposabl-kit/client/components/ui/toast.tsx +0 -229
  85. package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle-group.tsx +0 -87
  86. package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle.tsx +0 -42
  87. package/dist/templates/default/packages/disposabl-kit/client/components/ui/tooltip.tsx +0 -65
  88. package/dist/templates/default/packages/disposabl-kit/client/components/ui/trace.tsx +0 -161
  89. package/dist/templates/default/packages/disposabl-kit/client/hooks/use-mobile.ts +0 -21
  90. package/dist/templates/default/patches/@convex-dev%2Fauth@2.0.0-beta.0.patch +0 -310
@@ -1,368 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "@disposabl/disposabl-kit/client/lib/utils";
3
- import * as RechartsPrimitive from "recharts";
4
- import type { TooltipValueType } from "recharts";
5
-
6
- // Format: { THEME_NAME: CSS_SELECTOR }
7
- const THEMES = { light: "", dark: ".dark" } as const;
8
-
9
- const INITIAL_DIMENSION = { width: 320, height: 200 } as const;
10
- type TooltipNameType = number | string;
11
-
12
- export type ChartConfig = Record<
13
- string,
14
- {
15
- label?: React.ReactNode;
16
- icon?: React.ComponentType;
17
- } & (
18
- | { color?: string; theme?: never }
19
- | { color?: never; theme: Record<keyof typeof THEMES, string> }
20
- )
21
- >;
22
-
23
- type ChartContextProps = {
24
- config: ChartConfig;
25
- };
26
-
27
- const ChartContext = React.createContext<ChartContextProps | null>(null);
28
-
29
- function useChart() {
30
- const context = React.useContext(ChartContext);
31
-
32
- if (!context) {
33
- throw new Error("useChart must be used within a <ChartContainer />");
34
- }
35
-
36
- return context;
37
- }
38
-
39
- function ChartContainer({
40
- id,
41
- className,
42
- children,
43
- config,
44
- initialDimension = INITIAL_DIMENSION,
45
- ...props
46
- }: React.ComponentProps<"div"> & {
47
- config: ChartConfig;
48
- children: React.ComponentProps<
49
- typeof RechartsPrimitive.ResponsiveContainer
50
- >["children"];
51
- initialDimension?: {
52
- width: number;
53
- height: number;
54
- };
55
- }) {
56
- const uniqueId = React.useId();
57
- const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
58
-
59
- return (
60
- <ChartContext.Provider value={{ config }}>
61
- <div
62
- data-slot="chart"
63
- data-chart={chartId}
64
- className={cn(
65
- "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-hidden [&_.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]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
66
- className,
67
- )}
68
- {...props}
69
- >
70
- <ChartStyle id={chartId} config={config} />
71
- <RechartsPrimitive.ResponsiveContainer
72
- initialDimension={initialDimension}
73
- >
74
- {children}
75
- </RechartsPrimitive.ResponsiveContainer>
76
- </div>
77
- </ChartContext.Provider>
78
- );
79
- }
80
-
81
- const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
82
- const colorConfig = Object.entries(config).filter(
83
- ([, itemConfig]) => itemConfig.theme ?? itemConfig.color,
84
- );
85
-
86
- if (!colorConfig.length) {
87
- return null;
88
- }
89
-
90
- return (
91
- <style
92
- dangerouslySetInnerHTML={{
93
- __html: Object.entries(THEMES)
94
- .map(
95
- ([theme, prefix]) => `
96
- ${prefix} [data-chart=${id}] {
97
- ${colorConfig
98
- .map(([key, itemConfig]) => {
99
- const color =
100
- itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
101
- itemConfig.color;
102
- return color ? ` --color-${key}: ${color};` : null;
103
- })
104
- .join("\n")}
105
- }
106
- `,
107
- )
108
- .join("\n"),
109
- }}
110
- />
111
- );
112
- };
113
-
114
- const ChartTooltip = RechartsPrimitive.Tooltip;
115
-
116
- function ChartTooltipContent({
117
- active,
118
- payload,
119
- className,
120
- indicator = "dot",
121
- hideLabel = false,
122
- hideIndicator = false,
123
- label,
124
- labelFormatter,
125
- labelClassName,
126
- formatter,
127
- color,
128
- nameKey,
129
- labelKey,
130
- }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
131
- React.ComponentProps<"div"> & {
132
- hideLabel?: boolean;
133
- hideIndicator?: boolean;
134
- indicator?: "line" | "dot" | "dashed";
135
- nameKey?: string;
136
- labelKey?: string;
137
- } & Omit<
138
- RechartsPrimitive.DefaultTooltipContentProps<
139
- TooltipValueType,
140
- TooltipNameType
141
- >,
142
- "accessibilityLayer"
143
- >) {
144
- const { config } = useChart();
145
-
146
- const tooltipLabel = React.useMemo(() => {
147
- if (hideLabel || !payload?.length) {
148
- return null;
149
- }
150
-
151
- const [item] = payload;
152
- const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
153
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
154
- const value =
155
- !labelKey && typeof label === "string"
156
- ? (config[label]?.label ?? label)
157
- : itemConfig?.label;
158
-
159
- if (labelFormatter) {
160
- return (
161
- <div className={cn("font-medium", labelClassName)}>
162
- {labelFormatter(value, payload)}
163
- </div>
164
- );
165
- }
166
-
167
- if (!value) {
168
- return null;
169
- }
170
-
171
- return <div className={cn("font-medium", labelClassName)}>{value}</div>;
172
- }, [
173
- label,
174
- labelFormatter,
175
- payload,
176
- hideLabel,
177
- labelClassName,
178
- config,
179
- labelKey,
180
- ]);
181
-
182
- if (!active || !payload?.length) {
183
- return null;
184
- }
185
-
186
- const nestLabel = payload.length === 1 && indicator !== "dot";
187
-
188
- return (
189
- <div
190
- className={cn(
191
- "grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
192
- className,
193
- )}
194
- >
195
- {!nestLabel ? tooltipLabel : null}
196
- <div className="grid gap-1.5">
197
- {payload
198
- .filter((item) => item.type !== "none")
199
- .map((item, index) => {
200
- const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;
201
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
202
- const indicatorColor = color ?? item.payload?.fill ?? item.color;
203
-
204
- return (
205
- <div
206
- key={index}
207
- className={cn(
208
- "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
209
- indicator === "dot" && "items-center",
210
- )}
211
- >
212
- {formatter && item.value !== undefined && item.name ? (
213
- formatter(item.value, item.name, item, index, item.payload)
214
- ) : (
215
- <>
216
- {itemConfig?.icon ? (
217
- <itemConfig.icon />
218
- ) : (
219
- !hideIndicator && (
220
- <div
221
- className={cn(
222
- "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
223
- {
224
- "h-2.5 w-2.5": indicator === "dot",
225
- "w-1": indicator === "line",
226
- "w-0 border-[1.5px] border-dashed bg-transparent":
227
- indicator === "dashed",
228
- "my-0.5": nestLabel && indicator === "dashed",
229
- },
230
- )}
231
- style={
232
- {
233
- "--color-bg": indicatorColor,
234
- "--color-border": indicatorColor,
235
- } as React.CSSProperties
236
- }
237
- />
238
- )
239
- )}
240
- <div
241
- className={cn(
242
- "flex flex-1 justify-between leading-none",
243
- nestLabel ? "items-end" : "items-center",
244
- )}
245
- >
246
- <div className="grid gap-1.5">
247
- {nestLabel ? tooltipLabel : null}
248
- <span className="text-muted-foreground">
249
- {itemConfig?.label ?? item.name}
250
- </span>
251
- </div>
252
- {item.value != null && (
253
- <span className="font-mono font-medium text-foreground tabular-nums">
254
- {typeof item.value === "number"
255
- ? item.value.toLocaleString()
256
- : String(item.value)}
257
- </span>
258
- )}
259
- </div>
260
- </>
261
- )}
262
- </div>
263
- );
264
- })}
265
- </div>
266
- </div>
267
- );
268
- }
269
-
270
- const ChartLegend = RechartsPrimitive.Legend;
271
-
272
- function ChartLegendContent({
273
- className,
274
- hideIcon = false,
275
- payload,
276
- verticalAlign = "bottom",
277
- nameKey,
278
- }: React.ComponentProps<"div"> & {
279
- hideIcon?: boolean;
280
- nameKey?: string;
281
- } & RechartsPrimitive.DefaultLegendContentProps) {
282
- const { config } = useChart();
283
-
284
- if (!payload?.length) {
285
- return null;
286
- }
287
-
288
- return (
289
- <div
290
- className={cn(
291
- "flex items-center justify-center gap-4",
292
- verticalAlign === "top" ? "pb-3" : "pt-3",
293
- className,
294
- )}
295
- >
296
- {payload
297
- .filter((item) => item.type !== "none")
298
- .map((item, index) => {
299
- const key = `${nameKey ?? item.dataKey ?? "value"}`;
300
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
301
-
302
- return (
303
- <div
304
- key={index}
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
- function getPayloadConfigFromPayload(
328
- config: ChartConfig,
329
- payload: unknown,
330
- key: string,
331
- ) {
332
- if (typeof payload !== "object" || payload === null) {
333
- return undefined;
334
- }
335
-
336
- const payloadPayload =
337
- "payload" in payload &&
338
- typeof payload.payload === "object" &&
339
- payload.payload !== null
340
- ? payload.payload
341
- : undefined;
342
-
343
- let configLabelKey: string = key;
344
-
345
- if (
346
- key in payload &&
347
- typeof payload[key as keyof typeof payload] === "string"
348
- ) {
349
- configLabelKey = payload[key as keyof typeof payload];
350
- } else if (
351
- payloadPayload &&
352
- key in payloadPayload &&
353
- typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
354
- ) {
355
- configLabelKey = payloadPayload[key as keyof typeof payloadPayload];
356
- }
357
-
358
- return configLabelKey in config ? config[configLabelKey] : config[key];
359
- }
360
-
361
- export {
362
- ChartContainer,
363
- ChartTooltip,
364
- ChartTooltipContent,
365
- ChartLegend,
366
- ChartLegendContent,
367
- ChartStyle,
368
- };
@@ -1,27 +0,0 @@
1
- "use client";
2
-
3
- import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
4
- import { cn } from "@disposabl/disposabl-kit/client/lib/utils";
5
- import { CheckIcon } from "lucide-react";
6
-
7
- function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
8
- return (
9
- <CheckboxPrimitive.Root
10
- data-slot="checkbox"
11
- className={cn(
12
- "peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",
13
- className,
14
- )}
15
- {...props}
16
- >
17
- <CheckboxPrimitive.Indicator
18
- data-slot="checkbox-indicator"
19
- className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
20
- >
21
- <CheckIcon />
22
- </CheckboxPrimitive.Indicator>
23
- </CheckboxPrimitive.Root>
24
- );
25
- }
26
-
27
- export { Checkbox };
@@ -1,243 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import { cva, type VariantProps } from "class-variance-authority";
5
- import { cn } from "@disposabl/disposabl-kit/client/lib/utils";
6
-
7
- import { Button } from "@disposabl/disposabl-kit/client/components/ui/button";
8
- import { CheckIcon, CopyIcon } from "lucide-react";
9
-
10
- const codeBlockVariants = cva(
11
- "group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs",
12
- {
13
- variants: {
14
- variant: {
15
- default:
16
- "border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30",
17
- destructive:
18
- "border border-destructive/30 text-destructive dark:border-destructive/40",
19
- },
20
- },
21
- defaultVariants: {
22
- variant: "default",
23
- },
24
- },
25
- );
26
-
27
- function CodeBlock({
28
- className,
29
- variant = "default",
30
- size = "default",
31
- ...props
32
- }: React.ComponentProps<"div"> &
33
- VariantProps<typeof codeBlockVariants> & { size?: "default" | "sm" }) {
34
- return (
35
- <div
36
- data-slot="code-block"
37
- data-variant={variant}
38
- data-size={size}
39
- className={cn(codeBlockVariants({ variant }), className)}
40
- {...props}
41
- />
42
- );
43
- }
44
-
45
- function CodeBlockHeader({ className, ...props }: React.ComponentProps<"div">) {
46
- return (
47
- <div
48
- data-slot="code-block-header"
49
- className={cn(
50
- "flex min-w-0 shrink-0 items-center gap-2 px-4 pt-4 text-muted-foreground group-data-[size=sm]/code-block:px-3 group-data-[size=sm]/code-block:pt-3 group-data-[variant=destructive]/code-block:text-destructive *:has-[>[data-slot=code-block-title]]:min-w-0",
51
- className,
52
- )}
53
- {...props}
54
- />
55
- );
56
- }
57
-
58
- function CodeBlockTitle({ className, ...props }: React.ComponentProps<"div">) {
59
- return (
60
- <div
61
- data-slot="code-block-title"
62
- className={cn(
63
- "min-w-0 truncate font-sans text-sm font-medium text-foreground group-data-[size=sm]/code-block:text-xs group-data-[variant=destructive]/code-block:text-destructive [&_svg]:pointer-events-none [&_svg]:inline-block [&_svg]:align-middle [&_svg:not([class*='size-'])]:size-4 group-data-[size=sm]/code-block:[&_svg:not([class*='size-'])]:size-3.5 *:[svg]:me-1.5",
64
- className,
65
- )}
66
- {...props}
67
- />
68
- );
69
- }
70
-
71
- function CodeBlockActions({
72
- className,
73
- ...props
74
- }: React.ComponentProps<"div">) {
75
- return (
76
- <div
77
- data-slot="code-block-actions"
78
- className={cn(
79
- "-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-3 [[data-slot=code-block]>&]:top-3 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-2 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10",
80
- className,
81
- )}
82
- {...props}
83
- />
84
- );
85
- }
86
-
87
- function CodeBlockCopyButton({
88
- value,
89
- variant = "ghost",
90
- size = "icon-xs",
91
- className,
92
- onClick,
93
- ...props
94
- }: React.ComponentProps<typeof Button> & { value: string }) {
95
- const [copied, setCopied] = React.useState(false);
96
-
97
- React.useEffect(() => {
98
- if (!copied) {
99
- return;
100
- }
101
-
102
- const timeout = setTimeout(() => setCopied(false), 2000);
103
- return () => clearTimeout(timeout);
104
- }, [copied]);
105
-
106
- return (
107
- <>
108
- <Button
109
- data-slot="code-block-copy-button"
110
- data-copied={copied || undefined}
111
- variant={variant}
112
- size={size}
113
- aria-label={copied ? "Copied" : "Copy"}
114
- className={cn(className)}
115
- onClick={(event) => {
116
- onClick?.(event);
117
- navigator.clipboard
118
- .writeText(value)
119
- .then(() => setCopied(true))
120
- .catch(() => {});
121
- }}
122
- {...props}
123
- >
124
- {copied ? <CheckIcon /> : <CopyIcon />}
125
- </Button>
126
- <span aria-live="polite" className="sr-only">
127
- {copied ? "Copied" : ""}
128
- </span>
129
- </>
130
- );
131
- }
132
-
133
- function CodeBlockContent({
134
- className,
135
- children,
136
- style,
137
- wrap = false,
138
- lineNumbers = false,
139
- startLine = 1,
140
- ...props
141
- }: React.ComponentProps<"pre"> & {
142
- wrap?: boolean;
143
- lineNumbers?: boolean;
144
- startLine?: number;
145
- }) {
146
- return (
147
- <pre
148
- data-slot="code-block-content"
149
- data-wrap={wrap || undefined}
150
- data-numbered={lineNumbers || undefined}
151
- dir="ltr"
152
- tabIndex={0}
153
- style={{ counterReset: `line ${startLine - 1}`, ...style }}
154
- className={cn(
155
- "min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-4 py-4 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-3 group-data-[size=sm]/code-block:py-3 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap",
156
- className,
157
- )}
158
- {...props}
159
- >
160
- <code
161
- data-slot="code-block-code"
162
- className="grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0"
163
- >
164
- {lineNumbers && typeof children === "string"
165
- ? children
166
- .replace(/\n$/, "")
167
- .split("\n")
168
- .map((line, index) => (
169
- <CodeBlockLine key={index}>{line}</CodeBlockLine>
170
- ))
171
- : children}
172
- </code>
173
- </pre>
174
- );
175
- }
176
-
177
- const codeBlockLineVariants = cva(
178
- "relative -mx-4 block min-h-lh px-4 group-data-[size=sm]/code-block:-mx-3 group-data-[size=sm]/code-block:px-3 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']",
179
- {
180
- variants: {
181
- variant: {
182
- default: "",
183
- added: "bg-muted after:content-['+']",
184
- removed: "bg-destructive/10 after:text-destructive after:content-['−']",
185
- highlighted: "bg-muted",
186
- },
187
- },
188
- defaultVariants: {
189
- variant: "default",
190
- },
191
- },
192
- );
193
-
194
- function CodeBlockLine({
195
- className,
196
- variant = "default",
197
- children,
198
- ...props
199
- }: React.ComponentProps<"span"> & VariantProps<typeof codeBlockLineVariants>) {
200
- // An empty line holds a newline so copying a selection keeps blank lines.
201
- const empty =
202
- children === undefined ||
203
- children === null ||
204
- children === "" ||
205
- (Array.isArray(children) && children.length === 0);
206
-
207
- return (
208
- <span
209
- data-slot="code-block-line"
210
- data-variant={variant}
211
- className={cn(codeBlockLineVariants({ variant }), className)}
212
- {...props}
213
- >
214
- <span data-slot="code-block-line-content" className="min-w-0">
215
- {empty ? "\n" : children}
216
- </span>
217
- </span>
218
- );
219
- }
220
-
221
- function CodeBlockFooter({ className, ...props }: React.ComponentProps<"div">) {
222
- return (
223
- <div
224
- data-slot="code-block-footer"
225
- className={cn(
226
- "flex min-w-0 shrink-0 items-center gap-2 px-4 pb-4 text-muted-foreground group-data-[size=sm]/code-block:px-3 group-data-[size=sm]/code-block:pb-3",
227
- className,
228
- )}
229
- {...props}
230
- />
231
- );
232
- }
233
-
234
- export {
235
- CodeBlock,
236
- CodeBlockHeader,
237
- CodeBlockTitle,
238
- CodeBlockActions,
239
- CodeBlockCopyButton,
240
- CodeBlockContent,
241
- CodeBlockLine,
242
- CodeBlockFooter,
243
- };
@@ -1,19 +0,0 @@
1
- import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
2
-
3
- function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
4
- return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
5
- }
6
-
7
- function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
8
- return (
9
- <CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />
10
- );
11
- }
12
-
13
- function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {
14
- return (
15
- <CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />
16
- );
17
- }
18
-
19
- export { Collapsible, CollapsibleTrigger, CollapsibleContent };