@mostra/kit 0.0.0-stage → 0.19.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/README.md +43 -2
- package/css/kit.css +59 -0
- package/css/shadcn.css +638 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.d.ts +60 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +112 -0
- package/dist/layout.js.map +1 -0
- package/dist/questionnaire.d.ts +100 -0
- package/dist/questionnaire.d.ts.map +1 -0
- package/dist/questionnaire.js +632 -0
- package/dist/questionnaire.js.map +1 -0
- package/package.json +120 -3
- package/registry/LICENSE.md +21 -0
- package/registry/base/accordion.json +19 -0
- package/registry/base/alert-dialog.json +21 -0
- package/registry/base/alert.json +18 -0
- package/registry/base/aspect-ratio.json +17 -0
- package/registry/base/attachment.json +22 -0
- package/registry/base/avatar.json +18 -0
- package/registry/base/badge.json +19 -0
- package/registry/base/breadcrumb.json +19 -0
- package/registry/base/bubble.json +19 -0
- package/registry/base/button-group.json +22 -0
- package/registry/base/button.json +19 -0
- package/registry/base/calendar.json +22 -0
- package/registry/base/card.json +17 -0
- package/registry/base/carousel.json +22 -0
- package/registry/base/chart.json +21 -0
- package/registry/base/checkbox.json +19 -0
- package/registry/base/code-block.json +23 -0
- package/registry/base/collapsible.json +17 -0
- package/registry/base/combobox.json +23 -0
- package/registry/base/command.json +23 -0
- package/registry/base/components/mostra/layout.tsx +221 -0
- package/registry/base/components/mostra/questionnaire.tsx +1005 -0
- package/registry/base/components/ui/accordion.tsx +71 -0
- package/registry/base/components/ui/alert-dialog.tsx +187 -0
- package/registry/base/components/ui/alert.tsx +75 -0
- package/registry/base/components/ui/aspect-ratio.tsx +22 -0
- package/registry/base/components/ui/attachment.tsx +207 -0
- package/registry/base/components/ui/avatar.tsx +108 -0
- package/registry/base/components/ui/badge.tsx +54 -0
- package/registry/base/components/ui/breadcrumb.tsx +124 -0
- package/registry/base/components/ui/bubble.tsx +127 -0
- package/registry/base/components/ui/button-group.tsx +87 -0
- package/registry/base/components/ui/button.tsx +57 -0
- package/registry/base/components/ui/calendar.tsx +221 -0
- package/registry/base/components/ui/card.tsx +102 -0
- package/registry/base/components/ui/carousel.tsx +242 -0
- package/registry/base/components/ui/chart.tsx +372 -0
- package/registry/base/components/ui/checkbox.tsx +28 -0
- package/registry/base/components/ui/code-block.tsx +249 -0
- package/registry/base/components/ui/collapsible.tsx +21 -0
- package/registry/base/components/ui/combobox.tsx +297 -0
- package/registry/base/components/ui/command.tsx +196 -0
- package/registry/base/components/ui/context-menu.tsx +270 -0
- package/registry/base/components/ui/dialog.tsx +160 -0
- package/registry/base/components/ui/direction.tsx +6 -0
- package/registry/base/components/ui/drawer.tsx +227 -0
- package/registry/base/components/ui/dropdown-menu.tsx +267 -0
- package/registry/base/components/ui/empty.tsx +103 -0
- package/registry/base/components/ui/field.tsx +238 -0
- package/registry/base/components/ui/hover-card.tsx +50 -0
- package/registry/base/components/ui/input-group.tsx +158 -0
- package/registry/base/components/ui/input-otp.tsx +86 -0
- package/registry/base/components/ui/input.tsx +19 -0
- package/registry/base/components/ui/item.tsx +201 -0
- package/registry/base/components/ui/kbd.tsx +26 -0
- package/registry/base/components/ui/label.tsx +19 -0
- package/registry/base/components/ui/marker.tsx +70 -0
- package/registry/base/components/ui/menubar.tsx +280 -0
- package/registry/base/components/ui/message-scroller.tsx +131 -0
- package/registry/base/components/ui/message.tsx +91 -0
- package/registry/base/components/ui/native-select.tsx +60 -0
- package/registry/base/components/ui/navigation-menu.tsx +167 -0
- package/registry/base/components/ui/pagination.tsx +130 -0
- package/registry/base/components/ui/popover.tsx +89 -0
- package/registry/base/components/ui/progress.tsx +82 -0
- package/registry/base/components/ui/questionnaire.tsx +324 -0
- package/registry/base/components/ui/radio-group.tsx +37 -0
- package/registry/base/components/ui/resizable.tsx +49 -0
- package/registry/base/components/ui/scroll-area.tsx +53 -0
- package/registry/base/components/ui/select.tsx +200 -0
- package/registry/base/components/ui/separator.tsx +24 -0
- package/registry/base/components/ui/sheet.tsx +138 -0
- package/registry/base/components/ui/sidebar.tsx +723 -0
- package/registry/base/components/ui/skeleton.tsx +13 -0
- package/registry/base/components/ui/slider.tsx +51 -0
- package/registry/base/components/ui/sonner.tsx +65 -0
- package/registry/base/components/ui/spinner.tsx +10 -0
- package/registry/base/components/ui/switch.tsx +31 -0
- package/registry/base/components/ui/table.tsx +116 -0
- package/registry/base/components/ui/tabs.tsx +85 -0
- package/registry/base/components/ui/textarea.tsx +17 -0
- package/registry/base/components/ui/toast.tsx +234 -0
- package/registry/base/components/ui/toggle-group.tsx +89 -0
- package/registry/base/components/ui/toggle.tsx +44 -0
- package/registry/base/components/ui/tooltip.tsx +65 -0
- package/registry/base/components/ui/trace.tsx +162 -0
- package/registry/base/context-menu.json +19 -0
- package/registry/base/dialog.json +22 -0
- package/registry/base/direction.json +17 -0
- package/registry/base/drawer.json +18 -0
- package/registry/base/dropdown-menu.json +19 -0
- package/registry/base/empty.json +18 -0
- package/registry/base/field.json +22 -0
- package/registry/base/hooks/use-highlighted-code.ts +75 -0
- package/registry/base/hooks/use-mobile.ts +19 -0
- package/registry/base/hover-card.json +18 -0
- package/registry/base/input-group.json +23 -0
- package/registry/base/input-otp.json +19 -0
- package/registry/base/input.json +18 -0
- package/registry/base/item.json +22 -0
- package/registry/base/kbd.json +17 -0
- package/registry/base/label.json +17 -0
- package/registry/base/lib/highlighter.tsx +124 -0
- package/registry/base/lib/utils.ts +1 -0
- package/registry/base/marker.json +19 -0
- package/registry/base/menubar.json +22 -0
- package/registry/base/message-scroller.json +22 -0
- package/registry/base/message.json +17 -0
- package/registry/base/mostra-layout.json +20 -0
- package/registry/base/mostra-questionnaire.json +22 -0
- package/registry/base/native-select.json +18 -0
- package/registry/base/navigation-menu.json +20 -0
- package/registry/base/pagination.json +21 -0
- package/registry/base/popover.json +18 -0
- package/registry/base/progress.json +18 -0
- package/registry/base/questionnaire.json +22 -0
- package/registry/base/radio-group.json +18 -0
- package/registry/base/registry.json +287 -0
- package/registry/base/resizable.json +18 -0
- package/registry/base/scroll-area.json +18 -0
- package/registry/base/select.json +19 -0
- package/registry/base/separator.json +18 -0
- package/registry/base/sheet.json +22 -0
- package/registry/base/sidebar.json +29 -0
- package/registry/base/skeleton.json +17 -0
- package/registry/base/slider.json +18 -0
- package/registry/base/sonner.json +18 -0
- package/registry/base/spinner.json +18 -0
- package/registry/base/switch.json +18 -0
- package/registry/base/table.json +17 -0
- package/registry/base/tabs.json +19 -0
- package/registry/base/textarea.json +17 -0
- package/registry/base/toast.json +22 -0
- package/registry/base/toggle-group.json +22 -0
- package/registry/base/toggle.json +19 -0
- package/registry/base/tooltip.json +18 -0
- package/registry/base/trace.json +21 -0
- package/registry/base/use-highlighted-code.json +21 -0
- package/registry/base/use-mobile.json +14 -0
- package/registry/base/utils.json +17 -0
- package/registry/radix/accordion.json +19 -0
- package/registry/radix/alert-dialog.json +21 -0
- package/registry/radix/alert.json +18 -0
- package/registry/radix/aspect-ratio.json +17 -0
- package/registry/radix/attachment.json +22 -0
- package/registry/radix/avatar.json +18 -0
- package/registry/radix/badge.json +19 -0
- package/registry/radix/breadcrumb.json +19 -0
- package/registry/radix/bubble.json +19 -0
- package/registry/radix/button-group.json +22 -0
- package/registry/radix/button.json +19 -0
- package/registry/radix/calendar.json +22 -0
- package/registry/radix/card.json +17 -0
- package/registry/radix/carousel.json +22 -0
- package/registry/radix/chart.json +18 -0
- package/registry/radix/checkbox.json +19 -0
- package/registry/radix/code-block.json +23 -0
- package/registry/radix/collapsible.json +17 -0
- package/registry/radix/combobox.json +23 -0
- package/registry/radix/command.json +23 -0
- package/registry/radix/components/mostra/layout.tsx +221 -0
- package/registry/radix/components/mostra/questionnaire.tsx +1005 -0
- package/registry/radix/components/ui/accordion.tsx +80 -0
- package/registry/radix/components/ui/alert-dialog.tsx +199 -0
- package/registry/radix/components/ui/alert.tsx +75 -0
- package/registry/radix/components/ui/aspect-ratio.tsx +11 -0
- package/registry/radix/components/ui/attachment.tsx +204 -0
- package/registry/radix/components/ui/avatar.tsx +111 -0
- package/registry/radix/components/ui/badge.tsx +51 -0
- package/registry/radix/components/ui/breadcrumb.tsx +121 -0
- package/registry/radix/components/ui/bubble.tsx +124 -0
- package/registry/radix/components/ui/button-group.tsx +83 -0
- package/registry/radix/components/ui/button.tsx +66 -0
- package/registry/radix/components/ui/calendar.tsx +222 -0
- package/registry/radix/components/ui/card.tsx +102 -0
- package/registry/radix/components/ui/carousel.tsx +242 -0
- package/registry/radix/components/ui/chart.tsx +372 -0
- package/registry/radix/components/ui/checkbox.tsx +32 -0
- package/registry/radix/components/ui/code-block.tsx +249 -0
- package/registry/radix/components/ui/collapsible.tsx +33 -0
- package/registry/radix/components/ui/combobox.tsx +299 -0
- package/registry/radix/components/ui/command.tsx +195 -0
- package/registry/radix/components/ui/context-menu.tsx +262 -0
- package/registry/radix/components/ui/dialog.tsx +168 -0
- package/registry/radix/components/ui/direction.tsx +22 -0
- package/registry/radix/components/ui/drawer.tsx +133 -0
- package/registry/radix/components/ui/dropdown-menu.tsx +268 -0
- package/registry/radix/components/ui/empty.tsx +103 -0
- package/registry/radix/components/ui/field.tsx +238 -0
- package/registry/radix/components/ui/hover-card.tsx +43 -0
- package/registry/radix/components/ui/input-group.tsx +156 -0
- package/registry/radix/components/ui/input-otp.tsx +86 -0
- package/registry/radix/components/ui/input.tsx +18 -0
- package/registry/radix/components/ui/item.tsx +196 -0
- package/registry/radix/components/ui/kbd.tsx +26 -0
- package/registry/radix/components/ui/label.tsx +23 -0
- package/registry/radix/components/ui/marker.tsx +68 -0
- package/registry/radix/components/ui/menubar.tsx +279 -0
- package/registry/radix/components/ui/message-scroller.tsx +131 -0
- package/registry/radix/components/ui/message.tsx +91 -0
- package/registry/radix/components/ui/native-select.tsx +60 -0
- package/registry/radix/components/ui/navigation-menu.tsx +163 -0
- package/registry/radix/components/ui/pagination.tsx +129 -0
- package/registry/radix/components/ui/popover.tsx +88 -0
- package/registry/radix/components/ui/progress.tsx +30 -0
- package/registry/radix/components/ui/questionnaire.tsx +324 -0
- package/registry/radix/components/ui/radio-group.tsx +43 -0
- package/registry/radix/components/ui/resizable.tsx +49 -0
- package/registry/radix/components/ui/scroll-area.tsx +54 -0
- package/registry/radix/components/ui/select.tsx +191 -0
- package/registry/radix/components/ui/separator.tsx +27 -0
- package/registry/radix/components/ui/sheet.tsx +147 -0
- package/registry/radix/components/ui/sidebar.tsx +702 -0
- package/registry/radix/components/ui/skeleton.tsx +13 -0
- package/registry/radix/components/ui/slider.tsx +62 -0
- package/registry/radix/components/ui/sonner.tsx +65 -0
- package/registry/radix/components/ui/spinner.tsx +10 -0
- package/registry/radix/components/ui/switch.tsx +32 -0
- package/registry/radix/components/ui/table.tsx +116 -0
- package/registry/radix/components/ui/tabs.tsx +129 -0
- package/registry/radix/components/ui/textarea.tsx +17 -0
- package/registry/radix/components/ui/toggle-group.tsx +89 -0
- package/registry/radix/components/ui/toggle.tsx +46 -0
- package/registry/radix/components/ui/tooltip.tsx +56 -0
- package/registry/radix/components/ui/trace.tsx +162 -0
- package/registry/radix/context-menu.json +19 -0
- package/registry/radix/dialog.json +22 -0
- package/registry/radix/direction.json +17 -0
- package/registry/radix/drawer.json +18 -0
- package/registry/radix/dropdown-menu.json +19 -0
- package/registry/radix/empty.json +18 -0
- package/registry/radix/field.json +22 -0
- package/registry/radix/hooks/use-highlighted-code.ts +75 -0
- package/registry/radix/hooks/use-mobile.ts +19 -0
- package/registry/radix/hover-card.json +18 -0
- package/registry/radix/input-group.json +23 -0
- package/registry/radix/input-otp.json +19 -0
- package/registry/radix/input.json +17 -0
- package/registry/radix/item.json +22 -0
- package/registry/radix/kbd.json +17 -0
- package/registry/radix/label.json +18 -0
- package/registry/radix/lib/highlighter.tsx +124 -0
- package/registry/radix/lib/utils.ts +1 -0
- package/registry/radix/marker.json +19 -0
- package/registry/radix/menubar.json +19 -0
- package/registry/radix/message-scroller.json +22 -0
- package/registry/radix/message.json +17 -0
- package/registry/radix/mostra-layout.json +20 -0
- package/registry/radix/mostra-questionnaire.json +22 -0
- package/registry/radix/native-select.json +18 -0
- package/registry/radix/navigation-menu.json +20 -0
- package/registry/radix/pagination.json +21 -0
- package/registry/radix/popover.json +18 -0
- package/registry/radix/progress.json +18 -0
- package/registry/radix/questionnaire.json +22 -0
- package/registry/radix/radio-group.json +18 -0
- package/registry/radix/registry.json +283 -0
- package/registry/radix/resizable.json +18 -0
- package/registry/radix/scroll-area.json +18 -0
- package/registry/radix/select.json +19 -0
- package/registry/radix/separator.json +18 -0
- package/registry/radix/sheet.json +22 -0
- package/registry/radix/sidebar.json +29 -0
- package/registry/radix/skeleton.json +17 -0
- package/registry/radix/slider.json +18 -0
- package/registry/radix/sonner.json +18 -0
- package/registry/radix/spinner.json +18 -0
- package/registry/radix/switch.json +18 -0
- package/registry/radix/table.json +17 -0
- package/registry/radix/tabs.json +19 -0
- package/registry/radix/textarea.json +17 -0
- package/registry/radix/toggle-group.json +22 -0
- package/registry/radix/toggle.json +19 -0
- package/registry/radix/tooltip.json +18 -0
- package/registry/radix/trace.json +21 -0
- package/registry/radix/use-highlighted-code.json +21 -0
- package/registry/radix/use-mobile.json +14 -0
- package/registry/radix/utils.json +17 -0
- package/src/index.ts +15 -0
- package/src/layout.tsx +221 -0
- package/src/questionnaire.tsx +1005 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "cn"
|
|
5
|
+
import { Slider as SliderPrimitive } from "radix-ui"
|
|
6
|
+
|
|
7
|
+
function Slider({
|
|
8
|
+
className,
|
|
9
|
+
defaultValue,
|
|
10
|
+
value,
|
|
11
|
+
min = 0,
|
|
12
|
+
max = 100,
|
|
13
|
+
"aria-label": ariaLabel,
|
|
14
|
+
"aria-labelledby": ariaLabelledBy,
|
|
15
|
+
...props
|
|
16
|
+
}: React.ComponentProps<typeof SliderPrimitive.Root>) {
|
|
17
|
+
const _values = React.useMemo(
|
|
18
|
+
() =>
|
|
19
|
+
Array.isArray(value)
|
|
20
|
+
? value
|
|
21
|
+
: Array.isArray(defaultValue)
|
|
22
|
+
? defaultValue
|
|
23
|
+
: [min, max],
|
|
24
|
+
[value, defaultValue, min, max]
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<SliderPrimitive.Root
|
|
29
|
+
data-slot="slider"
|
|
30
|
+
defaultValue={defaultValue}
|
|
31
|
+
value={value}
|
|
32
|
+
min={min}
|
|
33
|
+
max={max}
|
|
34
|
+
className={cn(
|
|
35
|
+
"relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col",
|
|
36
|
+
className
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
>
|
|
40
|
+
<SliderPrimitive.Track
|
|
41
|
+
data-slot="slider-track"
|
|
42
|
+
className="relative grow overflow-hidden rounded-full bg-muted data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1"
|
|
43
|
+
>
|
|
44
|
+
<SliderPrimitive.Range
|
|
45
|
+
data-slot="slider-range"
|
|
46
|
+
className="absolute bg-primary select-none data-horizontal:h-full data-vertical:w-full"
|
|
47
|
+
/>
|
|
48
|
+
</SliderPrimitive.Track>
|
|
49
|
+
{Array.from({ length: _values.length }, (_, index) => (
|
|
50
|
+
<SliderPrimitive.Thumb
|
|
51
|
+
data-slot="slider-thumb"
|
|
52
|
+
aria-label={ariaLabel}
|
|
53
|
+
aria-labelledby={ariaLabelledBy}
|
|
54
|
+
key={index}
|
|
55
|
+
className="relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"
|
|
56
|
+
/>
|
|
57
|
+
))}
|
|
58
|
+
</SliderPrimitive.Root>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { Slider }
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
|
4
|
+
import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react"
|
|
5
|
+
|
|
6
|
+
import * as React from "react"
|
|
7
|
+
|
|
8
|
+
/** The page's appearance as Mostra sets it on `<html data-appearance>`, else the device's. */
|
|
9
|
+
function useAppearance(): ToasterProps["theme"] {
|
|
10
|
+
const read = (): ToasterProps["theme"] => {
|
|
11
|
+
const value = typeof document === "undefined" ? undefined : document.documentElement.dataset["appearance"]
|
|
12
|
+
return value === "light" || value === "dark" ? value : "system"
|
|
13
|
+
}
|
|
14
|
+
const [appearance, setAppearance] = React.useState(read)
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
const observer = new MutationObserver(() => setAppearance(read()))
|
|
17
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-appearance"] })
|
|
18
|
+
return () => observer.disconnect()
|
|
19
|
+
}, [])
|
|
20
|
+
return appearance
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Toaster = ({ ...props }: ToasterProps) => {
|
|
24
|
+
const theme = useAppearance()
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Sonner
|
|
28
|
+
theme={theme}
|
|
29
|
+
className="toaster group"
|
|
30
|
+
icons={{
|
|
31
|
+
success: (
|
|
32
|
+
<CircleCheckIcon className="size-4" />
|
|
33
|
+
),
|
|
34
|
+
info: (
|
|
35
|
+
<InfoIcon className="size-4" />
|
|
36
|
+
),
|
|
37
|
+
warning: (
|
|
38
|
+
<TriangleAlertIcon className="size-4" />
|
|
39
|
+
),
|
|
40
|
+
error: (
|
|
41
|
+
<OctagonXIcon className="size-4" />
|
|
42
|
+
),
|
|
43
|
+
loading: (
|
|
44
|
+
<Loader2Icon className="size-4 animate-spin" />
|
|
45
|
+
),
|
|
46
|
+
}}
|
|
47
|
+
style={
|
|
48
|
+
{
|
|
49
|
+
"--normal-bg": "var(--popover)",
|
|
50
|
+
"--normal-text": "var(--popover-foreground)",
|
|
51
|
+
"--normal-border": "var(--border)",
|
|
52
|
+
"--border-radius": "var(--radius)",
|
|
53
|
+
} as React.CSSProperties
|
|
54
|
+
}
|
|
55
|
+
toastOptions={{
|
|
56
|
+
classNames: {
|
|
57
|
+
toast: "cn-toast",
|
|
58
|
+
},
|
|
59
|
+
}}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { Toaster }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cn } from "cn"
|
|
2
|
+
import { Loader2Icon } from "lucide-react"
|
|
3
|
+
|
|
4
|
+
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
|
|
5
|
+
return (
|
|
6
|
+
<Loader2Icon data-slot="spinner" role="status" aria-label="Loading" className={cn("size-4 animate-spin", className)} {...props} />
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { Spinner }
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "cn"
|
|
5
|
+
import { Switch as SwitchPrimitive } from "radix-ui"
|
|
6
|
+
|
|
7
|
+
function Switch({
|
|
8
|
+
className,
|
|
9
|
+
size = "default",
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof SwitchPrimitive.Root> & {
|
|
12
|
+
size?: "sm" | "default"
|
|
13
|
+
}) {
|
|
14
|
+
return (
|
|
15
|
+
<SwitchPrimitive.Root
|
|
16
|
+
data-slot="switch"
|
|
17
|
+
data-size={size}
|
|
18
|
+
className={cn(
|
|
19
|
+
"peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
<SwitchPrimitive.Thumb
|
|
25
|
+
data-slot="switch-thumb"
|
|
26
|
+
className="pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"
|
|
27
|
+
/>
|
|
28
|
+
</SwitchPrimitive.Root>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { Switch }
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "cn"
|
|
5
|
+
|
|
6
|
+
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
data-slot="table-container"
|
|
10
|
+
tabIndex={0}
|
|
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
|
+
"border-t bg-muted/50 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
|
+
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
|
|
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
|
+
"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
|
|
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",
|
|
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("mt-4 text-sm text-muted-foreground", 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,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { Tabs as TabsPrimitive } from "radix-ui";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
function Tabs({
|
|
9
|
+
className,
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
|
|
13
|
+
return (
|
|
14
|
+
<TabsPrimitive.Root
|
|
15
|
+
data-slot="tabs"
|
|
16
|
+
data-orientation={orientation}
|
|
17
|
+
className={cn("group/tabs flex gap-3 data-horizontal:flex-col", className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const tabsListVariants = cva(
|
|
24
|
+
"group/tabs-list relative isolate inline-flex w-fit items-center text-muted-foreground group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col",
|
|
25
|
+
{
|
|
26
|
+
variants: {
|
|
27
|
+
variant: {
|
|
28
|
+
default:
|
|
29
|
+
"rounded-(--tabs-radius) bg-(--tabs-track-bg) p-(--tabs-track-pad) shadow-(--tabs-track-shadow)",
|
|
30
|
+
line: "gap-1 shadow-[inset_0_-1px_0_var(--border)]",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "default",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Where the active tab is inside its list, as Base UI's tab indicator gives it
|
|
41
|
+
* (`--active-tab-left`, `-top`, `-width`, `-height`), so the indicator moves to it.
|
|
42
|
+
*/
|
|
43
|
+
function useActiveTab(list: React.RefObject<HTMLDivElement | null>): React.CSSProperties {
|
|
44
|
+
const [box, setBox] = React.useState<React.CSSProperties>({});
|
|
45
|
+
React.useLayoutEffect(() => {
|
|
46
|
+
const element = list.current;
|
|
47
|
+
if (element === null) return;
|
|
48
|
+
const measure = () => {
|
|
49
|
+
const active = element.querySelector<HTMLElement>(
|
|
50
|
+
'[data-slot="tabs-trigger"][data-state="active"]',
|
|
51
|
+
);
|
|
52
|
+
if (active === null) return setBox({ opacity: 0 });
|
|
53
|
+
setBox({
|
|
54
|
+
"--active-tab-left": `${active.offsetLeft}px`,
|
|
55
|
+
"--active-tab-top": `${active.offsetTop}px`,
|
|
56
|
+
"--active-tab-width": `${active.offsetWidth}px`,
|
|
57
|
+
"--active-tab-height": `${active.offsetHeight}px`,
|
|
58
|
+
} as React.CSSProperties);
|
|
59
|
+
};
|
|
60
|
+
measure();
|
|
61
|
+
const resized = new ResizeObserver(measure);
|
|
62
|
+
resized.observe(element);
|
|
63
|
+
const changed = new MutationObserver(measure);
|
|
64
|
+
changed.observe(element, { subtree: true, attributes: true, attributeFilter: ["data-state"] });
|
|
65
|
+
return () => {
|
|
66
|
+
resized.disconnect();
|
|
67
|
+
changed.disconnect();
|
|
68
|
+
};
|
|
69
|
+
}, [list]);
|
|
70
|
+
return box;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function TabsList({
|
|
74
|
+
className,
|
|
75
|
+
variant = "default",
|
|
76
|
+
children,
|
|
77
|
+
...props
|
|
78
|
+
}: React.ComponentProps<typeof TabsPrimitive.List> & VariantProps<typeof tabsListVariants>) {
|
|
79
|
+
const list = React.useRef<HTMLDivElement>(null);
|
|
80
|
+
const active = useActiveTab(list);
|
|
81
|
+
return (
|
|
82
|
+
<TabsPrimitive.List
|
|
83
|
+
ref={list}
|
|
84
|
+
data-slot="tabs-list"
|
|
85
|
+
data-variant={variant}
|
|
86
|
+
className={cn(tabsListVariants({ variant }), className)}
|
|
87
|
+
{...props}
|
|
88
|
+
>
|
|
89
|
+
{children}
|
|
90
|
+
<span
|
|
91
|
+
aria-hidden
|
|
92
|
+
data-slot="tabs-indicator"
|
|
93
|
+
style={active}
|
|
94
|
+
className={cn(
|
|
95
|
+
"absolute -z-10 transition-[left,top,width,height] duration-(--state-ms) ease-(--ease-out) motion-reduce:transition-none",
|
|
96
|
+
"top-[calc(var(--active-tab-top)+var(--active-tab-height)-var(--tabs-indicator-h))] left-(--active-tab-left) h-(--tabs-indicator-h) w-(--active-tab-width) [--tabs-indicator-h:calc(var(--tabs-indicator-fill)*var(--active-tab-height)+(1-var(--tabs-indicator-fill))*var(--tabs-indicator-line))]",
|
|
97
|
+
"rounded-(--tabs-indicator-radius) bg-(--tabs-indicator-bg) shadow-(--tabs-indicator-shadow)",
|
|
98
|
+
"group-data-[variant=line]/tabs-list:top-[calc(var(--active-tab-top)+var(--active-tab-height)-2px)] group-data-[variant=line]/tabs-list:h-0.5 group-data-[variant=line]/tabs-list:rounded-none group-data-[variant=line]/tabs-list:bg-foreground group-data-[variant=line]/tabs-list:shadow-none",
|
|
99
|
+
)}
|
|
100
|
+
/>
|
|
101
|
+
</TabsPrimitive.List>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
|
|
106
|
+
return (
|
|
107
|
+
<TabsPrimitive.Trigger
|
|
108
|
+
data-slot="tabs-trigger"
|
|
109
|
+
className={cn(
|
|
110
|
+
"relative inline-flex h-(--control-h-sm) flex-1 items-center justify-center gap-1.5 rounded-(--tabs-indicator-radius) px-4 text-[0.9375rem] font-medium whitespace-nowrap text-muted-foreground transition-colors duration-(--state-ms) outline-none group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
111
|
+
"data-active:text-(--tabs-active-fg) group-data-[variant=line]/tabs-list:rounded-none group-data-[variant=line]/tabs-list:px-1 group-data-[variant=line]/tabs-list:data-active:text-foreground",
|
|
112
|
+
className,
|
|
113
|
+
)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>) {
|
|
120
|
+
return (
|
|
121
|
+
<TabsPrimitive.Content
|
|
122
|
+
data-slot="tabs-content"
|
|
123
|
+
className={cn("flex-1 text-sm outline-none", className)}
|
|
124
|
+
{...props}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cn } from "cn"
|
|
3
|
+
|
|
4
|
+
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
5
|
+
return (
|
|
6
|
+
<textarea
|
|
7
|
+
data-slot="textarea"
|
|
8
|
+
className={cn(
|
|
9
|
+
"flex field-sizing-content min-h-24 w-full rounded-control border border-input bg-(--field) px-3.5 py-2 text-base transition-[border-color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 shadow-control duration-(--state-ms)",
|
|
10
|
+
className
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Textarea }
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { cn } from "cn"
|
|
6
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui"
|
|
7
|
+
|
|
8
|
+
import { toggleVariants } from "@/components/ui/toggle"
|
|
9
|
+
|
|
10
|
+
const ToggleGroupContext = React.createContext<
|
|
11
|
+
VariantProps<typeof toggleVariants> & {
|
|
12
|
+
spacing?: number
|
|
13
|
+
orientation?: "horizontal" | "vertical"
|
|
14
|
+
}
|
|
15
|
+
>({
|
|
16
|
+
size: "default",
|
|
17
|
+
variant: "default",
|
|
18
|
+
spacing: 2,
|
|
19
|
+
orientation: "horizontal",
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
function ToggleGroup({
|
|
23
|
+
className,
|
|
24
|
+
variant,
|
|
25
|
+
size,
|
|
26
|
+
spacing = 2,
|
|
27
|
+
orientation = "horizontal",
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
|
31
|
+
VariantProps<typeof toggleVariants> & {
|
|
32
|
+
spacing?: number
|
|
33
|
+
orientation?: "horizontal" | "vertical"
|
|
34
|
+
}) {
|
|
35
|
+
return (
|
|
36
|
+
<ToggleGroupPrimitive.Root
|
|
37
|
+
data-slot="toggle-group"
|
|
38
|
+
data-variant={variant}
|
|
39
|
+
data-size={size}
|
|
40
|
+
data-spacing={spacing}
|
|
41
|
+
data-orientation={orientation}
|
|
42
|
+
style={{ "--gap": spacing } as React.CSSProperties}
|
|
43
|
+
className={cn(
|
|
44
|
+
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",
|
|
45
|
+
className
|
|
46
|
+
)}
|
|
47
|
+
{...props}
|
|
48
|
+
>
|
|
49
|
+
<ToggleGroupContext.Provider
|
|
50
|
+
value={{ variant, size, spacing, orientation }}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
</ToggleGroupContext.Provider>
|
|
54
|
+
</ToggleGroupPrimitive.Root>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function ToggleGroupItem({
|
|
59
|
+
className,
|
|
60
|
+
children,
|
|
61
|
+
variant = "default",
|
|
62
|
+
size = "default",
|
|
63
|
+
...props
|
|
64
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
|
65
|
+
VariantProps<typeof toggleVariants>) {
|
|
66
|
+
const context = React.useContext(ToggleGroupContext)
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<ToggleGroupPrimitive.Item
|
|
70
|
+
data-slot="toggle-group-item"
|
|
71
|
+
data-variant={context.variant || variant}
|
|
72
|
+
data-size={context.size || size}
|
|
73
|
+
data-spacing={context.spacing}
|
|
74
|
+
className={cn(
|
|
75
|
+
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
|
|
76
|
+
toggleVariants({
|
|
77
|
+
variant: context.variant || variant,
|
|
78
|
+
size: context.size || size,
|
|
79
|
+
}),
|
|
80
|
+
className
|
|
81
|
+
)}
|
|
82
|
+
{...props}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</ToggleGroupPrimitive.Item>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { ToggleGroup, ToggleGroupItem }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { cn } from "cn"
|
|
6
|
+
import { Toggle as TogglePrimitive } from "radix-ui"
|
|
7
|
+
|
|
8
|
+
const toggleVariants = cva(
|
|
9
|
+
"group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "bg-transparent",
|
|
14
|
+
outline: "border border-input bg-transparent hover:bg-muted",
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
default:
|
|
18
|
+
"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
19
|
+
sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
20
|
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: "default",
|
|
25
|
+
size: "default",
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
function Toggle({
|
|
31
|
+
className,
|
|
32
|
+
variant = "default",
|
|
33
|
+
size = "default",
|
|
34
|
+
...props
|
|
35
|
+
}: React.ComponentProps<typeof TogglePrimitive.Root> &
|
|
36
|
+
VariantProps<typeof toggleVariants>) {
|
|
37
|
+
return (
|
|
38
|
+
<TogglePrimitive.Root
|
|
39
|
+
data-slot="toggle"
|
|
40
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Toggle, toggleVariants }
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "cn"
|
|
5
|
+
import { Tooltip as TooltipPrimitive } from "radix-ui"
|
|
6
|
+
|
|
7
|
+
function TooltipProvider({
|
|
8
|
+
delayDuration = 0,
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
|
11
|
+
return (
|
|
12
|
+
<TooltipPrimitive.Provider
|
|
13
|
+
data-slot="tooltip-provider"
|
|
14
|
+
delayDuration={delayDuration}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function Tooltip({
|
|
21
|
+
...props
|
|
22
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
|
23
|
+
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function TooltipTrigger({
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
|
29
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function TooltipContent({
|
|
33
|
+
className,
|
|
34
|
+
sideOffset = 0,
|
|
35
|
+
children,
|
|
36
|
+
...props
|
|
37
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
38
|
+
return (
|
|
39
|
+
<TooltipPrimitive.Portal>
|
|
40
|
+
<TooltipPrimitive.Content
|
|
41
|
+
data-slot="tooltip-content"
|
|
42
|
+
sideOffset={sideOffset}
|
|
43
|
+
className={cn(
|
|
44
|
+
"z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
45
|
+
className
|
|
46
|
+
)}
|
|
47
|
+
{...props}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
|
|
51
|
+
</TooltipPrimitive.Content>
|
|
52
|
+
</TooltipPrimitive.Portal>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }
|