@lark-apaas/coding-templates 0.1.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.
- package/LICENSE +13 -0
- package/README.md +128 -0
- package/meta.json +22 -0
- package/package.json +22 -0
- package/template-html/README.md +148 -0
- package/template-html/_gitignore +2 -0
- package/template-html/index.html +22 -0
- package/template-html/package.json +12 -0
- package/template-html/routes.json +1 -0
- package/template-html/scripts/build.sh +31 -0
- package/template-nextjs-fullstack/README.md +169 -0
- package/template-nextjs-fullstack/_env.local.example +1 -0
- package/template-nextjs-fullstack/_gitignore +41 -0
- package/template-nextjs-fullstack/components.json +25 -0
- package/template-nextjs-fullstack/drizzle.config.ts +10 -0
- package/template-nextjs-fullstack/eslint.config.js +15 -0
- package/template-nextjs-fullstack/next.config.ts +5 -0
- package/template-nextjs-fullstack/package.json +85 -0
- package/template-nextjs-fullstack/postcss.config.js +8 -0
- package/template-nextjs-fullstack/scripts/build.sh +37 -0
- package/template-nextjs-fullstack/src/app/favicon.ico +0 -0
- package/template-nextjs-fullstack/src/app/globals.css +130 -0
- package/template-nextjs-fullstack/src/app/layout.tsx +24 -0
- package/template-nextjs-fullstack/src/app/page.tsx +69 -0
- package/template-nextjs-fullstack/src/app/todos/actions.ts +37 -0
- package/template-nextjs-fullstack/src/app/todos/page.tsx +26 -0
- package/template-nextjs-fullstack/src/app/todos/todo-form.tsx +27 -0
- package/template-nextjs-fullstack/src/app/todos/todo-list.tsx +44 -0
- package/template-nextjs-fullstack/src/components/header.tsx +32 -0
- package/template-nextjs-fullstack/src/components/theme-provider.tsx +8 -0
- package/template-nextjs-fullstack/src/components/ui/README.md +134 -0
- package/template-nextjs-fullstack/src/components/ui/accordion.tsx +66 -0
- package/template-nextjs-fullstack/src/components/ui/alert-dialog.tsx +157 -0
- package/template-nextjs-fullstack/src/components/ui/alert.tsx +71 -0
- package/template-nextjs-fullstack/src/components/ui/aspect-ratio.tsx +11 -0
- package/template-nextjs-fullstack/src/components/ui/avatar.tsx +53 -0
- package/template-nextjs-fullstack/src/components/ui/badge.tsx +42 -0
- package/template-nextjs-fullstack/src/components/ui/breadcrumb.tsx +109 -0
- package/template-nextjs-fullstack/src/components/ui/button-group.tsx +83 -0
- package/template-nextjs-fullstack/src/components/ui/button.tsx +69 -0
- package/template-nextjs-fullstack/src/components/ui/calendar.tsx +213 -0
- package/template-nextjs-fullstack/src/components/ui/card.tsx +82 -0
- package/template-nextjs-fullstack/src/components/ui/carousel.tsx +241 -0
- package/template-nextjs-fullstack/src/components/ui/chart.tsx +357 -0
- package/template-nextjs-fullstack/src/components/ui/checkbox.tsx +32 -0
- package/template-nextjs-fullstack/src/components/ui/collapsible.tsx +33 -0
- package/template-nextjs-fullstack/src/components/ui/command.tsx +208 -0
- package/template-nextjs-fullstack/src/components/ui/context-menu.tsx +324 -0
- package/template-nextjs-fullstack/src/components/ui/dialog.tsx +143 -0
- package/template-nextjs-fullstack/src/components/ui/drawer.tsx +135 -0
- package/template-nextjs-fullstack/src/components/ui/dropdown-menu.tsx +329 -0
- package/template-nextjs-fullstack/src/components/ui/empty.tsx +104 -0
- package/template-nextjs-fullstack/src/components/ui/field.tsx +248 -0
- package/template-nextjs-fullstack/src/components/ui/form.tsx +167 -0
- package/template-nextjs-fullstack/src/components/ui/hover-card.tsx +44 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-ae-colorful-icon.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-ai-colorful-icon.tsx +36 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-android-colorful-icon.tsx +33 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-audio-colorful-icon.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-code-colorful-icon.tsx +28 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-csv-colorful-icon.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-eml-colorful-icon.tsx +29 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-ios-colorful-icon.tsx +25 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-keynote-colorful-icon.tsx +29 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-pages-colorful-icon.tsx +29 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-ps-colorful-icon.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-sketch-colorful-icon.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-slide-colorful-icon.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-vcf-colorful-icon.tsx +29 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-excel-colorful-icon.tsx +23 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-image-colorful-icon.tsx +27 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-pdf-colorful-icon.tsx +20 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-ppt-colorful-icon.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-text-colorful-icon.tsx +12 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-unknown-colorful-icon.tsx +14 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-video-colorful-icon.tsx +23 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-word-colorful-icon.tsx +38 -0
- package/template-nextjs-fullstack/src/components/ui/icons/file-wiki-zip-colorful-icon.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/image.tsx +183 -0
- package/template-nextjs-fullstack/src/components/ui/input-group.tsx +166 -0
- package/template-nextjs-fullstack/src/components/ui/input-otp.tsx +77 -0
- package/template-nextjs-fullstack/src/components/ui/input.tsx +21 -0
- package/template-nextjs-fullstack/src/components/ui/item.tsx +193 -0
- package/template-nextjs-fullstack/src/components/ui/kbd.tsx +28 -0
- package/template-nextjs-fullstack/src/components/ui/label.tsx +24 -0
- package/template-nextjs-fullstack/src/components/ui/menubar.tsx +348 -0
- package/template-nextjs-fullstack/src/components/ui/native-select.tsx +48 -0
- package/template-nextjs-fullstack/src/components/ui/navigation-menu.tsx +168 -0
- package/template-nextjs-fullstack/src/components/ui/pagination.tsx +127 -0
- package/template-nextjs-fullstack/src/components/ui/popover.tsx +48 -0
- package/template-nextjs-fullstack/src/components/ui/progress.tsx +31 -0
- package/template-nextjs-fullstack/src/components/ui/radio-group.tsx +45 -0
- package/template-nextjs-fullstack/src/components/ui/resizable.tsx +56 -0
- package/template-nextjs-fullstack/src/components/ui/scroll-area.tsx +58 -0
- package/template-nextjs-fullstack/src/components/ui/select.tsx +243 -0
- package/template-nextjs-fullstack/src/components/ui/separator.tsx +28 -0
- package/template-nextjs-fullstack/src/components/ui/sheet.tsx +139 -0
- package/template-nextjs-fullstack/src/components/ui/sidebar.tsx +727 -0
- package/template-nextjs-fullstack/src/components/ui/skeleton.tsx +13 -0
- package/template-nextjs-fullstack/src/components/ui/slider.tsx +87 -0
- package/template-nextjs-fullstack/src/components/ui/sonner.tsx +67 -0
- package/template-nextjs-fullstack/src/components/ui/spinner.tsx +16 -0
- package/template-nextjs-fullstack/src/components/ui/streamdown.tsx +186 -0
- package/template-nextjs-fullstack/src/components/ui/switch.tsx +31 -0
- package/template-nextjs-fullstack/src/components/ui/table.tsx +116 -0
- package/template-nextjs-fullstack/src/components/ui/tabs.tsx +66 -0
- package/template-nextjs-fullstack/src/components/ui/textarea.tsx +18 -0
- package/template-nextjs-fullstack/src/components/ui/toggle-group.tsx +83 -0
- package/template-nextjs-fullstack/src/components/ui/toggle.tsx +47 -0
- package/template-nextjs-fullstack/src/components/ui/tooltip.tsx +61 -0
- package/template-nextjs-fullstack/src/db/index.ts +8 -0
- package/template-nextjs-fullstack/src/db/schema.ts +11 -0
- package/template-nextjs-fullstack/src/hooks/use-mobile.ts +19 -0
- package/template-nextjs-fullstack/src/lib/utils.ts +6 -0
- package/template-nextjs-fullstack/tailwind.config.ts +10 -0
- package/template-nextjs-fullstack/tsconfig.json +34 -0
- package/template-nextjs-static/README.md +80 -0
- package/template-nextjs-static/_gitignore +41 -0
- package/template-nextjs-static/components.json +25 -0
- package/template-nextjs-static/eslint.config.js +15 -0
- package/template-nextjs-static/next.config.ts +8 -0
- package/template-nextjs-static/package.json +77 -0
- package/template-nextjs-static/postcss.config.js +8 -0
- package/template-nextjs-static/public/favicon.ico +0 -0
- package/template-nextjs-static/scripts/build.sh +36 -0
- package/template-nextjs-static/src/components/header.tsx +30 -0
- package/template-nextjs-static/src/components/theme-provider.tsx +6 -0
- package/template-nextjs-static/src/components/ui/README.md +134 -0
- package/template-nextjs-static/src/components/ui/accordion.tsx +66 -0
- package/template-nextjs-static/src/components/ui/alert-dialog.tsx +157 -0
- package/template-nextjs-static/src/components/ui/alert.tsx +71 -0
- package/template-nextjs-static/src/components/ui/aspect-ratio.tsx +11 -0
- package/template-nextjs-static/src/components/ui/avatar.tsx +53 -0
- package/template-nextjs-static/src/components/ui/badge.tsx +42 -0
- package/template-nextjs-static/src/components/ui/breadcrumb.tsx +109 -0
- package/template-nextjs-static/src/components/ui/button-group.tsx +83 -0
- package/template-nextjs-static/src/components/ui/button.tsx +69 -0
- package/template-nextjs-static/src/components/ui/calendar.tsx +213 -0
- package/template-nextjs-static/src/components/ui/card.tsx +82 -0
- package/template-nextjs-static/src/components/ui/carousel.tsx +241 -0
- package/template-nextjs-static/src/components/ui/chart.tsx +357 -0
- package/template-nextjs-static/src/components/ui/checkbox.tsx +32 -0
- package/template-nextjs-static/src/components/ui/collapsible.tsx +33 -0
- package/template-nextjs-static/src/components/ui/command.tsx +208 -0
- package/template-nextjs-static/src/components/ui/context-menu.tsx +324 -0
- package/template-nextjs-static/src/components/ui/dialog.tsx +143 -0
- package/template-nextjs-static/src/components/ui/drawer.tsx +135 -0
- package/template-nextjs-static/src/components/ui/dropdown-menu.tsx +329 -0
- package/template-nextjs-static/src/components/ui/empty.tsx +104 -0
- package/template-nextjs-static/src/components/ui/field.tsx +248 -0
- package/template-nextjs-static/src/components/ui/form.tsx +167 -0
- package/template-nextjs-static/src/components/ui/hover-card.tsx +44 -0
- package/template-nextjs-static/src/components/ui/icons/file-ae-colorful-icon.tsx +21 -0
- package/template-nextjs-static/src/components/ui/icons/file-ai-colorful-icon.tsx +36 -0
- package/template-nextjs-static/src/components/ui/icons/file-android-colorful-icon.tsx +33 -0
- package/template-nextjs-static/src/components/ui/icons/file-audio-colorful-icon.tsx +21 -0
- package/template-nextjs-static/src/components/ui/icons/file-code-colorful-icon.tsx +28 -0
- package/template-nextjs-static/src/components/ui/icons/file-csv-colorful-icon.tsx +21 -0
- package/template-nextjs-static/src/components/ui/icons/file-eml-colorful-icon.tsx +29 -0
- package/template-nextjs-static/src/components/ui/icons/file-ios-colorful-icon.tsx +25 -0
- package/template-nextjs-static/src/components/ui/icons/file-keynote-colorful-icon.tsx +29 -0
- package/template-nextjs-static/src/components/ui/icons/file-pages-colorful-icon.tsx +29 -0
- package/template-nextjs-static/src/components/ui/icons/file-ps-colorful-icon.tsx +21 -0
- package/template-nextjs-static/src/components/ui/icons/file-sketch-colorful-icon.tsx +21 -0
- package/template-nextjs-static/src/components/ui/icons/file-slide-colorful-icon.tsx +21 -0
- package/template-nextjs-static/src/components/ui/icons/file-vcf-colorful-icon.tsx +29 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-excel-colorful-icon.tsx +23 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-image-colorful-icon.tsx +27 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-pdf-colorful-icon.tsx +20 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-ppt-colorful-icon.tsx +21 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-text-colorful-icon.tsx +12 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-unknown-colorful-icon.tsx +14 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-video-colorful-icon.tsx +23 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-word-colorful-icon.tsx +38 -0
- package/template-nextjs-static/src/components/ui/icons/file-wiki-zip-colorful-icon.tsx +21 -0
- package/template-nextjs-static/src/components/ui/image.tsx +183 -0
- package/template-nextjs-static/src/components/ui/input-group.tsx +166 -0
- package/template-nextjs-static/src/components/ui/input-otp.tsx +77 -0
- package/template-nextjs-static/src/components/ui/input.tsx +21 -0
- package/template-nextjs-static/src/components/ui/item.tsx +193 -0
- package/template-nextjs-static/src/components/ui/kbd.tsx +28 -0
- package/template-nextjs-static/src/components/ui/label.tsx +24 -0
- package/template-nextjs-static/src/components/ui/menubar.tsx +348 -0
- package/template-nextjs-static/src/components/ui/native-select.tsx +48 -0
- package/template-nextjs-static/src/components/ui/navigation-menu.tsx +168 -0
- package/template-nextjs-static/src/components/ui/pagination.tsx +127 -0
- package/template-nextjs-static/src/components/ui/popover.tsx +48 -0
- package/template-nextjs-static/src/components/ui/progress.tsx +31 -0
- package/template-nextjs-static/src/components/ui/radio-group.tsx +45 -0
- package/template-nextjs-static/src/components/ui/resizable.tsx +56 -0
- package/template-nextjs-static/src/components/ui/scroll-area.tsx +58 -0
- package/template-nextjs-static/src/components/ui/select.tsx +243 -0
- package/template-nextjs-static/src/components/ui/separator.tsx +28 -0
- package/template-nextjs-static/src/components/ui/sheet.tsx +139 -0
- package/template-nextjs-static/src/components/ui/sidebar.tsx +727 -0
- package/template-nextjs-static/src/components/ui/skeleton.tsx +13 -0
- package/template-nextjs-static/src/components/ui/slider.tsx +87 -0
- package/template-nextjs-static/src/components/ui/sonner.tsx +67 -0
- package/template-nextjs-static/src/components/ui/spinner.tsx +16 -0
- package/template-nextjs-static/src/components/ui/streamdown.tsx +186 -0
- package/template-nextjs-static/src/components/ui/switch.tsx +31 -0
- package/template-nextjs-static/src/components/ui/table.tsx +116 -0
- package/template-nextjs-static/src/components/ui/tabs.tsx +66 -0
- package/template-nextjs-static/src/components/ui/textarea.tsx +18 -0
- package/template-nextjs-static/src/components/ui/toggle-group.tsx +83 -0
- package/template-nextjs-static/src/components/ui/toggle.tsx +47 -0
- package/template-nextjs-static/src/components/ui/tooltip.tsx +61 -0
- package/template-nextjs-static/src/hooks/use-mobile.ts +19 -0
- package/template-nextjs-static/src/lib/utils.ts +6 -0
- package/template-nextjs-static/src/pages/_app.tsx +11 -0
- package/template-nextjs-static/src/pages/_document.tsx +13 -0
- package/template-nextjs-static/src/pages/hello.tsx +32 -0
- package/template-nextjs-static/src/pages/index.tsx +76 -0
- package/template-nextjs-static/src/styles/globals.css +143 -0
- package/template-nextjs-static/tailwind.config.ts +10 -0
- package/template-nextjs-static/tsconfig.json +34 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "@/lib/utils"
|
|
2
|
+
|
|
3
|
+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
4
|
+
return (
|
|
5
|
+
<div
|
|
6
|
+
data-slot="skeleton"
|
|
7
|
+
className={cn("bg-accent animate-pulse rounded-md", className)}
|
|
8
|
+
{...props}
|
|
9
|
+
/>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Skeleton }
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as SliderPrimitive from "@radix-ui/react-slider"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
function Slider({
|
|
9
|
+
className,
|
|
10
|
+
defaultValue,
|
|
11
|
+
value,
|
|
12
|
+
min = 0,
|
|
13
|
+
max = 100,
|
|
14
|
+
disabled,
|
|
15
|
+
onClick,
|
|
16
|
+
onMouseDown,
|
|
17
|
+
onKeyDown,
|
|
18
|
+
onKeyUp,
|
|
19
|
+
onPointerDown,
|
|
20
|
+
...props
|
|
21
|
+
}: React.ComponentProps<typeof SliderPrimitive.Root>) {
|
|
22
|
+
const _values = React.useMemo(
|
|
23
|
+
() =>
|
|
24
|
+
Array.isArray(value)
|
|
25
|
+
? value
|
|
26
|
+
: Array.isArray(defaultValue)
|
|
27
|
+
? defaultValue
|
|
28
|
+
: [min, max],
|
|
29
|
+
[value, defaultValue, min, max]
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<SliderPrimitive.Root
|
|
34
|
+
data-slot="slider"
|
|
35
|
+
defaultValue={defaultValue}
|
|
36
|
+
value={value}
|
|
37
|
+
min={min}
|
|
38
|
+
max={max}
|
|
39
|
+
className={cn(
|
|
40
|
+
"relative flex w-full touch-none items-center select-none cursor-pointer data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
onClick={(event) => {
|
|
45
|
+
if (disabled) {
|
|
46
|
+
event.preventDefault()
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
onClick?.(event)
|
|
50
|
+
}}
|
|
51
|
+
onMouseDown={disabled ? undefined : onMouseDown}
|
|
52
|
+
onKeyDown={disabled ? undefined : onKeyDown}
|
|
53
|
+
onKeyUp={disabled ? undefined : onKeyUp}
|
|
54
|
+
onPointerDown={(event) => {
|
|
55
|
+
if (disabled) {
|
|
56
|
+
event.preventDefault()
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
onPointerDown?.(event)
|
|
60
|
+
}}
|
|
61
|
+
{...props}
|
|
62
|
+
>
|
|
63
|
+
<SliderPrimitive.Track
|
|
64
|
+
data-slot="slider-track"
|
|
65
|
+
className={cn(
|
|
66
|
+
"bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
|
|
67
|
+
)}
|
|
68
|
+
>
|
|
69
|
+
<SliderPrimitive.Range
|
|
70
|
+
data-slot="slider-range"
|
|
71
|
+
className={cn(
|
|
72
|
+
"bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
|
|
73
|
+
)}
|
|
74
|
+
/>
|
|
75
|
+
</SliderPrimitive.Track>
|
|
76
|
+
{Array.from({ length: _values.length }, (_, index) => (
|
|
77
|
+
<SliderPrimitive.Thumb
|
|
78
|
+
data-slot="slider-thumb"
|
|
79
|
+
key={index}
|
|
80
|
+
className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] not-data-disabled:hover:ring-4 not-data-disabled:focus-visible:ring-4 not-data-disabled:focus-visible:outline-hidden disabled:cursor-not-allowed data-[disabled]:cursor-not-allowed disabled:opacity-50"
|
|
81
|
+
/>
|
|
82
|
+
))}
|
|
83
|
+
</SliderPrimitive.Root>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { Slider }
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
import {
|
|
6
|
+
CircleAlertIcon,
|
|
7
|
+
CircleCheckIcon,
|
|
8
|
+
CircleXIcon,
|
|
9
|
+
InfoIcon,
|
|
10
|
+
Loader2Icon,
|
|
11
|
+
XIcon,
|
|
12
|
+
} from 'lucide-react';
|
|
13
|
+
import { useTheme } from 'next-themes';
|
|
14
|
+
import { Toaster as Sonner, type ToasterProps } from 'sonner';
|
|
15
|
+
|
|
16
|
+
function Toaster({ className, style, icons, ...props }: ToasterProps) {
|
|
17
|
+
const { theme = 'system' } = useTheme();
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Sonner
|
|
21
|
+
theme={theme as ToasterProps['theme']}
|
|
22
|
+
className={cn('toaster group', className)}
|
|
23
|
+
position="top-center"
|
|
24
|
+
icons={{
|
|
25
|
+
success: (
|
|
26
|
+
<CircleCheckIcon
|
|
27
|
+
fill="currentColor"
|
|
28
|
+
className="size-4 text-success [&>:not(circle)]:stroke-(--normal-bg)"
|
|
29
|
+
/>
|
|
30
|
+
),
|
|
31
|
+
info: (
|
|
32
|
+
<InfoIcon
|
|
33
|
+
fill="currentColor"
|
|
34
|
+
className="size-4 text-info [&>:not(circle)]:stroke-(--normal-bg)"
|
|
35
|
+
/>
|
|
36
|
+
),
|
|
37
|
+
warning: (
|
|
38
|
+
<CircleAlertIcon
|
|
39
|
+
fill="currentColor"
|
|
40
|
+
className="size-4 text-warning [&>:not(circle)]:stroke-(--normal-bg)"
|
|
41
|
+
/>
|
|
42
|
+
),
|
|
43
|
+
error: (
|
|
44
|
+
<CircleXIcon
|
|
45
|
+
fill="currentColor"
|
|
46
|
+
className="size-4 text-destructive [&>:not(circle)]:stroke-(--normal-bg)"
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
close: <XIcon className="size-4 text-accent-foreground" />,
|
|
50
|
+
loading: <Loader2Icon className="size-4 animate-spin text-primary" />,
|
|
51
|
+
...icons,
|
|
52
|
+
}}
|
|
53
|
+
style={
|
|
54
|
+
{
|
|
55
|
+
'--normal-bg': 'var(--popover)',
|
|
56
|
+
'--normal-text': 'var(--popover-foreground)',
|
|
57
|
+
'--normal-border': 'var(--border)',
|
|
58
|
+
'--border-radius': 'var(--radius)',
|
|
59
|
+
...style,
|
|
60
|
+
} as React.CSSProperties
|
|
61
|
+
}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { Toaster };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Loader2Icon } from "lucide-react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
|
|
6
|
+
return (
|
|
7
|
+
<Loader2Icon
|
|
8
|
+
role="status"
|
|
9
|
+
aria-label="Loading"
|
|
10
|
+
className={cn("size-4 animate-spin", className)}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { Spinner }
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Streamdown as StreamdownPrimitive } from 'streamdown';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
import { omit } from 'es-toolkit';
|
|
8
|
+
|
|
9
|
+
const defaultComponents: NonNullable<
|
|
10
|
+
React.ComponentProps<typeof StreamdownPrimitive>['components']
|
|
11
|
+
> = {
|
|
12
|
+
ol: ({ className, ...props }) => (
|
|
13
|
+
<ol
|
|
14
|
+
className={cn(className)}
|
|
15
|
+
data-streamdown="ordered-list"
|
|
16
|
+
{...omit(props, ['node'])}
|
|
17
|
+
/>
|
|
18
|
+
),
|
|
19
|
+
li: ({ className, ...props }) => (
|
|
20
|
+
<li
|
|
21
|
+
className={cn(className)}
|
|
22
|
+
data-streamdown="list-item"
|
|
23
|
+
{...omit(props, ['node'])}
|
|
24
|
+
/>
|
|
25
|
+
),
|
|
26
|
+
ul: ({ className, ...props }) => (
|
|
27
|
+
<ul
|
|
28
|
+
className={cn(className)}
|
|
29
|
+
data-streamdown="unordered-list"
|
|
30
|
+
{...omit(props, ['node'])}
|
|
31
|
+
/>
|
|
32
|
+
),
|
|
33
|
+
hr: ({ className, ...props }) => (
|
|
34
|
+
<hr
|
|
35
|
+
className={cn(className)}
|
|
36
|
+
data-streamdown="horizontal-rule"
|
|
37
|
+
{...omit(props, ['node'])}
|
|
38
|
+
/>
|
|
39
|
+
),
|
|
40
|
+
strong: ({ className, ...props }) => (
|
|
41
|
+
<strong
|
|
42
|
+
className={cn(className)}
|
|
43
|
+
data-streamdown="strong"
|
|
44
|
+
{...omit(props, ['node'])}
|
|
45
|
+
/>
|
|
46
|
+
),
|
|
47
|
+
a: ({ className, href, ...props }) => {
|
|
48
|
+
const isIncomplete = href === 'streamdown:incomplete-link';
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<a
|
|
52
|
+
className={cn(className)}
|
|
53
|
+
data-incomplete={isIncomplete}
|
|
54
|
+
data-streamdown="link"
|
|
55
|
+
href={href}
|
|
56
|
+
rel={props.rel ?? 'noreferrer'}
|
|
57
|
+
target={props.target ?? '_blank'}
|
|
58
|
+
{...omit(props, ['node'])}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
h1: ({ className, ...props }) => (
|
|
63
|
+
<h1
|
|
64
|
+
className={cn(className)}
|
|
65
|
+
data-streamdown="heading-1"
|
|
66
|
+
{...omit(props, ['node'])}
|
|
67
|
+
/>
|
|
68
|
+
),
|
|
69
|
+
h2: ({ className, ...props }) => (
|
|
70
|
+
<h2
|
|
71
|
+
className={cn(className)}
|
|
72
|
+
data-streamdown="heading-2"
|
|
73
|
+
{...omit(props, ['node'])}
|
|
74
|
+
/>
|
|
75
|
+
),
|
|
76
|
+
h3: ({ className, ...props }) => (
|
|
77
|
+
<h3
|
|
78
|
+
className={cn(className)}
|
|
79
|
+
data-streamdown="heading-3"
|
|
80
|
+
{...omit(props, ['node'])}
|
|
81
|
+
/>
|
|
82
|
+
),
|
|
83
|
+
h4: ({ className, ...props }) => (
|
|
84
|
+
<h4
|
|
85
|
+
className={cn(className)}
|
|
86
|
+
data-streamdown="heading-4"
|
|
87
|
+
{...omit(props, ['node'])}
|
|
88
|
+
/>
|
|
89
|
+
),
|
|
90
|
+
h5: ({ className, ...props }) => (
|
|
91
|
+
<h5
|
|
92
|
+
className={cn(className)}
|
|
93
|
+
data-streamdown="heading-5"
|
|
94
|
+
{...omit(props, ['node'])}
|
|
95
|
+
/>
|
|
96
|
+
),
|
|
97
|
+
h6: ({ className, ...props }) => (
|
|
98
|
+
<h6
|
|
99
|
+
className={cn(className)}
|
|
100
|
+
data-streamdown="heading-6"
|
|
101
|
+
{...omit(props, ['node'])}
|
|
102
|
+
/>
|
|
103
|
+
),
|
|
104
|
+
table: ({ className, ...props }) => (
|
|
105
|
+
<table
|
|
106
|
+
className={cn(className)}
|
|
107
|
+
data-streamdown="table-wrapper"
|
|
108
|
+
{...omit(props, ['node'])}
|
|
109
|
+
/>
|
|
110
|
+
),
|
|
111
|
+
thead: ({ className, ...props }) => (
|
|
112
|
+
<thead
|
|
113
|
+
className={cn(className)}
|
|
114
|
+
data-streamdown="table-header"
|
|
115
|
+
{...omit(props, ['node'])}
|
|
116
|
+
/>
|
|
117
|
+
),
|
|
118
|
+
tbody: ({ className, ...props }) => (
|
|
119
|
+
<tbody
|
|
120
|
+
className={cn(className)}
|
|
121
|
+
data-streamdown="table-body"
|
|
122
|
+
{...omit(props, ['node'])}
|
|
123
|
+
/>
|
|
124
|
+
),
|
|
125
|
+
tr: ({ className, ...props }) => (
|
|
126
|
+
<tr
|
|
127
|
+
className={cn(className)}
|
|
128
|
+
data-streamdown="table-row"
|
|
129
|
+
{...omit(props, ['node'])}
|
|
130
|
+
/>
|
|
131
|
+
),
|
|
132
|
+
th: ({ className, ...props }) => (
|
|
133
|
+
<th
|
|
134
|
+
className={cn(className)}
|
|
135
|
+
data-streamdown="table-header-cell"
|
|
136
|
+
{...omit(props, ['node'])}
|
|
137
|
+
/>
|
|
138
|
+
),
|
|
139
|
+
td: ({ className, ...props }) => (
|
|
140
|
+
<td
|
|
141
|
+
className={cn(className)}
|
|
142
|
+
data-streamdown="table-cell"
|
|
143
|
+
{...omit(props, ['node'])}
|
|
144
|
+
/>
|
|
145
|
+
),
|
|
146
|
+
blockquote: ({ className, ...props }) => (
|
|
147
|
+
<blockquote
|
|
148
|
+
className={cn(className)}
|
|
149
|
+
data-streamdown="blockquote"
|
|
150
|
+
{...omit(props, ['node'])}
|
|
151
|
+
/>
|
|
152
|
+
),
|
|
153
|
+
sup: ({ className, ...props }) => (
|
|
154
|
+
<sup className={cn(className)} {...omit(props, ['node'])} />
|
|
155
|
+
),
|
|
156
|
+
sub: ({ className, ...props }) => (
|
|
157
|
+
<sub className={cn(className)} {...omit(props, ['node'])} />
|
|
158
|
+
),
|
|
159
|
+
p: ({ className, ...props }) => (
|
|
160
|
+
<p className={cn(className)} {...omit(props, ['node'])} />
|
|
161
|
+
),
|
|
162
|
+
section: ({ className, ...props }) => (
|
|
163
|
+
<section className={cn(className)} {...omit(props, ['node'])} />
|
|
164
|
+
),
|
|
165
|
+
img: ({ className, alt, ...props }) => (
|
|
166
|
+
<img className={cn(className)} alt={alt ?? ''} {...omit(props, ['node'])} />
|
|
167
|
+
),
|
|
168
|
+
pre: ({ children }) => <div className="not-prose">{children}</div>,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export function Streamdown({
|
|
172
|
+
className,
|
|
173
|
+
components,
|
|
174
|
+
...props
|
|
175
|
+
}: React.ComponentProps<typeof StreamdownPrimitive>) {
|
|
176
|
+
return (
|
|
177
|
+
<StreamdownPrimitive
|
|
178
|
+
className={cn(
|
|
179
|
+
'prose max-w-none dark:prose-invert',
|
|
180
|
+
className,
|
|
181
|
+
)}
|
|
182
|
+
components={{ ...defaultComponents, ...components }}
|
|
183
|
+
{...props}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as SwitchPrimitive from "@radix-ui/react-switch"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
function Switch({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<SwitchPrimitive.Root
|
|
14
|
+
data-slot="switch"
|
|
15
|
+
className={cn(
|
|
16
|
+
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/20 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:data-state:bg-muted",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
<SwitchPrimitive.Thumb
|
|
22
|
+
data-slot="switch-thumb"
|
|
23
|
+
className={cn(
|
|
24
|
+
"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 data-disabled:opacity-60"
|
|
25
|
+
)}
|
|
26
|
+
/>
|
|
27
|
+
</SwitchPrimitive.Root>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Switch }
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
8
|
+
return (
|
|
9
|
+
<div
|
|
10
|
+
data-slot="table-container"
|
|
11
|
+
className="relative w-full overflow-x-auto"
|
|
12
|
+
>
|
|
13
|
+
<table
|
|
14
|
+
data-slot="table"
|
|
15
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
|
23
|
+
return (
|
|
24
|
+
<thead
|
|
25
|
+
data-slot="table-header"
|
|
26
|
+
className={cn("[&_tr]:border-b", className)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
|
33
|
+
return (
|
|
34
|
+
<tbody
|
|
35
|
+
data-slot="table-body"
|
|
36
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
43
|
+
return (
|
|
44
|
+
<tfoot
|
|
45
|
+
data-slot="table-footer"
|
|
46
|
+
className={cn(
|
|
47
|
+
"bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
|
|
48
|
+
className
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
56
|
+
return (
|
|
57
|
+
<tr
|
|
58
|
+
data-slot="table-row"
|
|
59
|
+
className={cn(
|
|
60
|
+
"hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
|
|
61
|
+
className
|
|
62
|
+
)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
69
|
+
return (
|
|
70
|
+
<th
|
|
71
|
+
data-slot="table-head"
|
|
72
|
+
className={cn(
|
|
73
|
+
"text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|
82
|
+
return (
|
|
83
|
+
<td
|
|
84
|
+
data-slot="table-cell"
|
|
85
|
+
className={cn(
|
|
86
|
+
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
87
|
+
className
|
|
88
|
+
)}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function TableCaption({
|
|
95
|
+
className,
|
|
96
|
+
...props
|
|
97
|
+
}: React.ComponentProps<"caption">) {
|
|
98
|
+
return (
|
|
99
|
+
<caption
|
|
100
|
+
data-slot="table-caption"
|
|
101
|
+
className={cn("text-muted-foreground mt-4 text-sm", className)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
Table,
|
|
109
|
+
TableHeader,
|
|
110
|
+
TableBody,
|
|
111
|
+
TableFooter,
|
|
112
|
+
TableHead,
|
|
113
|
+
TableRow,
|
|
114
|
+
TableCell,
|
|
115
|
+
TableCaption,
|
|
116
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
function Tabs({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<TabsPrimitive.Root
|
|
14
|
+
data-slot="tabs"
|
|
15
|
+
className={cn("flex flex-col gap-2", className)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function TabsList({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<typeof TabsPrimitive.List>) {
|
|
25
|
+
return (
|
|
26
|
+
<TabsPrimitive.List
|
|
27
|
+
data-slot="tabs-list"
|
|
28
|
+
className={cn(
|
|
29
|
+
"bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function TabsTrigger({
|
|
38
|
+
className,
|
|
39
|
+
...props
|
|
40
|
+
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
|
|
41
|
+
return (
|
|
42
|
+
<TabsPrimitive.Trigger
|
|
43
|
+
data-slot="tabs-trigger"
|
|
44
|
+
className={cn(
|
|
45
|
+
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/20 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm data-[state=active]:font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:cursor-not-allowed disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function TabsContent({
|
|
54
|
+
className,
|
|
55
|
+
...props
|
|
56
|
+
}: React.ComponentProps<typeof TabsPrimitive.Content>) {
|
|
57
|
+
return (
|
|
58
|
+
<TabsPrimitive.Content
|
|
59
|
+
data-slot="tabs-content"
|
|
60
|
+
className={cn("flex-1 outline-none", className)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
6
|
+
return (
|
|
7
|
+
<textarea
|
|
8
|
+
data-slot="textarea"
|
|
9
|
+
className={cn(
|
|
10
|
+
"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/20 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] enabled:hover:border-primary disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
11
|
+
className
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Textarea }
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
|
|
5
|
+
import { type VariantProps } from "class-variance-authority"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
import { toggleVariants } from "@/components/ui/toggle"
|
|
9
|
+
|
|
10
|
+
const ToggleGroupContext = React.createContext<
|
|
11
|
+
VariantProps<typeof toggleVariants> & {
|
|
12
|
+
spacing?: number
|
|
13
|
+
}
|
|
14
|
+
>({
|
|
15
|
+
size: "default",
|
|
16
|
+
variant: "default",
|
|
17
|
+
spacing: 0,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
function ToggleGroup({
|
|
21
|
+
className,
|
|
22
|
+
variant,
|
|
23
|
+
size,
|
|
24
|
+
spacing = 0,
|
|
25
|
+
children,
|
|
26
|
+
...props
|
|
27
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
|
28
|
+
VariantProps<typeof toggleVariants> & {
|
|
29
|
+
spacing?: number
|
|
30
|
+
}) {
|
|
31
|
+
return (
|
|
32
|
+
<ToggleGroupPrimitive.Root
|
|
33
|
+
data-slot="toggle-group"
|
|
34
|
+
data-variant={variant}
|
|
35
|
+
data-size={size}
|
|
36
|
+
data-spacing={spacing}
|
|
37
|
+
style={{ "--gap": spacing } as React.CSSProperties}
|
|
38
|
+
className={cn(
|
|
39
|
+
"group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs",
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
<ToggleGroupContext.Provider value={{ variant, size, spacing }}>
|
|
45
|
+
{children}
|
|
46
|
+
</ToggleGroupContext.Provider>
|
|
47
|
+
</ToggleGroupPrimitive.Root>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function ToggleGroupItem({
|
|
52
|
+
className,
|
|
53
|
+
children,
|
|
54
|
+
variant,
|
|
55
|
+
size,
|
|
56
|
+
...props
|
|
57
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
|
58
|
+
VariantProps<typeof toggleVariants>) {
|
|
59
|
+
const context = React.useContext(ToggleGroupContext)
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<ToggleGroupPrimitive.Item
|
|
63
|
+
data-slot="toggle-group-item"
|
|
64
|
+
data-variant={context.variant || variant}
|
|
65
|
+
data-size={context.size || size}
|
|
66
|
+
data-spacing={context.spacing}
|
|
67
|
+
className={cn(
|
|
68
|
+
toggleVariants({
|
|
69
|
+
variant: context.variant || variant,
|
|
70
|
+
size: context.size || size,
|
|
71
|
+
}),
|
|
72
|
+
"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10",
|
|
73
|
+
"data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</ToggleGroupPrimitive.Item>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { ToggleGroup, ToggleGroupItem }
|