@suzumiyaaoba/mdxr 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 +21 -0
- package/README.md +56 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +2902 -0
- package/dist/components.d.mts +791 -0
- package/dist/components.mjs +2 -0
- package/dist/config-SI9IyFiC.mjs +184 -0
- package/dist/doc-context-CEqzMYKv.d.mts +568 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.mjs +4 -0
- package/dist/ui-GKFD0mx5.mjs +15986 -0
- package/package.json +131 -0
- package/skill/SKILL.md +49 -0
- package/skill/references/components/charts.md +172 -0
- package/skill/references/components/document.md +98 -0
- package/skill/references/components/forms.md +35 -0
- package/skill/references/components/investigation.md +198 -0
- package/skill/references/components/layout.md +68 -0
- package/skill/references/components/output.md +158 -0
- package/skill/references/components/planning.md +155 -0
- package/skill/references/components/reports.md +252 -0
- package/skill/references/components/shadcn.md +19 -0
- package/skill/references/components.md +186 -0
- package/skill/references/extending.md +48 -0
- package/src/ask-sheet.ts +40 -0
- package/src/assets/css.ts +392 -0
- package/src/assets/scripts.ts +78 -0
- package/src/catalog.ts +287 -0
- package/src/cli.ts +178 -0
- package/src/client/doc-events.ts +1108 -0
- package/src/client/entry.ts +27 -0
- package/src/client-js.ts +47 -0
- package/src/component-map.ts +47 -0
- package/src/components/ui/accordion.tsx +77 -0
- package/src/components/ui/alert-dialog.tsx +185 -0
- package/src/components/ui/alert.tsx +76 -0
- package/src/components/ui/aspect-ratio.tsx +22 -0
- package/src/components/ui/attachment.tsx +208 -0
- package/src/components/ui/avatar.tsx +106 -0
- package/src/components/ui/badge.tsx +52 -0
- package/src/components/ui/breadcrumb.tsx +121 -0
- package/src/components/ui/bubble.tsx +128 -0
- package/src/components/ui/button-group.tsx +88 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/calendar.tsx +226 -0
- package/src/components/ui/card.tsx +102 -0
- package/src/components/ui/carousel.tsx +246 -0
- package/src/components/ui/chart.tsx +379 -0
- package/src/components/ui/checkbox.tsx +27 -0
- package/src/components/ui/collapsible.tsx +19 -0
- package/src/components/ui/combobox.tsx +298 -0
- package/src/components/ui/command.tsx +193 -0
- package/src/components/ui/context-menu.tsx +271 -0
- package/src/components/ui/dialog.tsx +159 -0
- package/src/components/ui/direction.tsx +4 -0
- package/src/components/ui/drawer.tsx +227 -0
- package/src/components/ui/dropdown-menu.tsx +269 -0
- package/src/components/ui/empty.tsx +104 -0
- package/src/components/ui/field.tsx +237 -0
- package/src/components/ui/fieldset.tsx +32 -0
- package/src/components/ui/frame.tsx +87 -0
- package/src/components/ui/hover-card.tsx +50 -0
- package/src/components/ui/input-group.tsx +159 -0
- package/src/components/ui/input-otp.tsx +83 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/item.tsx +202 -0
- package/src/components/ui/kbd.tsx +26 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/marker.tsx +71 -0
- package/src/components/ui/menubar.tsx +284 -0
- package/src/components/ui/message-scroller.tsx +128 -0
- package/src/components/ui/message.tsx +91 -0
- package/src/components/ui/meter.tsx +80 -0
- package/src/components/ui/native-select.tsx +64 -0
- package/src/components/ui/navigation-menu.tsx +170 -0
- package/src/components/ui/pagination.tsx +133 -0
- package/src/components/ui/popover.tsx +87 -0
- package/src/components/ui/progress.tsx +82 -0
- package/src/components/ui/questionnaire.tsx +328 -0
- package/src/components/ui/radio-group.tsx +35 -0
- package/src/components/ui/resizable.tsx +49 -0
- package/src/components/ui/scroll-area.tsx +50 -0
- package/src/components/ui/select.tsx +201 -0
- package/src/components/ui/separator.tsx +22 -0
- package/src/components/ui/sheet.tsx +135 -0
- package/src/components/ui/sidebar.tsx +730 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/slider.tsx +51 -0
- package/src/components/ui/spinner.tsx +16 -0
- package/src/components/ui/switch.tsx +31 -0
- package/src/components/ui/table.tsx +113 -0
- package/src/components/ui/tabs.tsx +82 -0
- package/src/components/ui/textarea.tsx +17 -0
- package/src/components/ui/toast.tsx +229 -0
- package/src/components/ui/toggle-group.tsx +87 -0
- package/src/components/ui/toggle.tsx +43 -0
- package/src/components/ui/tooltip.tsx +65 -0
- package/src/components.ts +78 -0
- package/src/config.ts +56 -0
- package/src/define.ts +122 -0
- package/src/doc-context.ts +20 -0
- package/src/editor.ts +94 -0
- package/src/format-error.ts +78 -0
- package/src/guards.ts +84 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/html.ts +91 -0
- package/src/hydrate/export-index.ts +232 -0
- package/src/hydrate/import-scan.ts +169 -0
- package/src/hydrate/plugins.ts +118 -0
- package/src/hydrate/runtime-module.ts +145 -0
- package/src/hydrate-runtime.ts +67 -0
- package/src/hydrate.ts +147 -0
- package/src/index.ts +16 -0
- package/src/init.ts +57 -0
- package/src/langs.ts +148 -0
- package/src/lines.ts +53 -0
- package/src/load-user-module.ts +191 -0
- package/src/mdx.ts +248 -0
- package/src/paths.ts +36 -0
- package/src/rehype/shiki.ts +533 -0
- package/src/remark/alerts.ts +53 -0
- package/src/remark/ast.ts +96 -0
- package/src/remark/callouts.ts +25 -0
- package/src/remark/code-file.ts +85 -0
- package/src/remark/code-meta.ts +21 -0
- package/src/remark/directives.ts +170 -0
- package/src/remark/file-paths.ts +64 -0
- package/src/remark/headings.ts +131 -0
- package/src/remark/no-js.ts +40 -0
- package/src/render.ts +337 -0
- package/src/serve.ts +322 -0
- package/src/styles/globals.css +134 -0
- package/src/styles/shadcn.css +641 -0
- package/src/tailwind.ts +119 -0
- package/src/ui/approvals.tsx +76 -0
- package/src/ui/ask-question.tsx +386 -0
- package/src/ui/ask.tsx +206 -0
- package/src/ui/attrs.ts +51 -0
- package/src/ui/audit.tsx +139 -0
- package/src/ui/bar-chart.tsx +334 -0
- package/src/ui/benchmarks.tsx +143 -0
- package/src/ui/bits.tsx +537 -0
- package/src/ui/board.tsx +173 -0
- package/src/ui/bridge.tsx +207 -0
- package/src/ui/bumps.tsx +178 -0
- package/src/ui/callout.tsx +106 -0
- package/src/ui/changes.tsx +89 -0
- package/src/ui/chart-bits.tsx +52 -0
- package/src/ui/chart.ts +577 -0
- package/src/ui/checks.tsx +203 -0
- package/src/ui/child-index.tsx +44 -0
- package/src/ui/children.ts +43 -0
- package/src/ui/chips.tsx +49 -0
- package/src/ui/cmd.tsx +27 -0
- package/src/ui/columns.tsx +31 -0
- package/src/ui/comments.tsx +544 -0
- package/src/ui/compare.tsx +67 -0
- package/src/ui/decision.tsx +79 -0
- package/src/ui/deps.tsx +78 -0
- package/src/ui/details.tsx +43 -0
- package/src/ui/diff-parse.ts +307 -0
- package/src/ui/diff.tsx +458 -0
- package/src/ui/diffstat.tsx +58 -0
- package/src/ui/due.tsx +65 -0
- package/src/ui/effort.tsx +29 -0
- package/src/ui/endpoints.tsx +118 -0
- package/src/ui/envvars.tsx +96 -0
- package/src/ui/figure.tsx +37 -0
- package/src/ui/file-icon.ts +1020 -0
- package/src/ui/file-link.ts +32 -0
- package/src/ui/file-ref.tsx +39 -0
- package/src/ui/files.tsx +112 -0
- package/src/ui/findings.tsx +85 -0
- package/src/ui/flow.tsx +73 -0
- package/src/ui/funnel.tsx +121 -0
- package/src/ui/gantt.tsx +443 -0
- package/src/ui/gauges.tsx +135 -0
- package/src/ui/glossary.tsx +29 -0
- package/src/ui/graph-layout.ts +149 -0
- package/src/ui/graph-specs.tsx +102 -0
- package/src/ui/graph.tsx +278 -0
- package/src/ui/grid.tsx +119 -0
- package/src/ui/hypothesis.tsx +94 -0
- package/src/ui/icon.tsx +80 -0
- package/src/ui/incident.tsx +130 -0
- package/src/ui/index.ts +342 -0
- package/src/ui/ins-del.tsx +41 -0
- package/src/ui/json.tsx +190 -0
- package/src/ui/layout.ts +9 -0
- package/src/ui/line-chart.tsx +251 -0
- package/src/ui/matrix.tsx +208 -0
- package/src/ui/meta.tsx +73 -0
- package/src/ui/option.tsx +64 -0
- package/src/ui/owner.tsx +40 -0
- package/src/ui/packages.tsx +104 -0
- package/src/ui/pathway.tsx +96 -0
- package/src/ui/phase.tsx +41 -0
- package/src/ui/pie-chart.tsx +170 -0
- package/src/ui/plan.tsx +77 -0
- package/src/ui/pre.tsx +175 -0
- package/src/ui/priority.tsx +51 -0
- package/src/ui/props.tsx +77 -0
- package/src/ui/quadrant.tsx +172 -0
- package/src/ui/radar.tsx +200 -0
- package/src/ui/ref.tsx +160 -0
- package/src/ui/release.tsx +178 -0
- package/src/ui/req.tsx +42 -0
- package/src/ui/review.tsx +133 -0
- package/src/ui/risk.tsx +67 -0
- package/src/ui/sankey.tsx +287 -0
- package/src/ui/scatter.tsx +237 -0
- package/src/ui/schema.tsx +113 -0
- package/src/ui/score.tsx +105 -0
- package/src/ui/search.tsx +120 -0
- package/src/ui/series.tsx +38 -0
- package/src/ui/severity.tsx +69 -0
- package/src/ui/shadcn.tsx +216 -0
- package/src/ui/spark.tsx +86 -0
- package/src/ui/stack.tsx +57 -0
- package/src/ui/stats.tsx +63 -0
- package/src/ui/status-badge.tsx +66 -0
- package/src/ui/statuspage.tsx +238 -0
- package/src/ui/steps.tsx +74 -0
- package/src/ui/summary.tsx +41 -0
- package/src/ui/symbol-ref.tsx +73 -0
- package/src/ui/terminal.tsx +117 -0
- package/src/ui/tests.tsx +218 -0
- package/src/ui/timeline.tsx +63 -0
- package/src/ui/toc.tsx +56 -0
- package/src/ui/tones.ts +187 -0
- package/src/ui/trace.tsx +69 -0
- package/src/ui/tree.tsx +281 -0
- package/src/ui/treemap.tsx +128 -0
- package/src/ui/venn.tsx +258 -0
- package/src/ui/verdict.tsx +78 -0
- package/src/ui/waterfall.tsx +142 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
|
|
3
|
+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
4
|
+
return (
|
|
5
|
+
<div
|
|
6
|
+
data-slot="skeleton"
|
|
7
|
+
className={cn("bg-muted animate-pulse rounded-md", className)}
|
|
8
|
+
{...props}
|
|
9
|
+
/>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Skeleton };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Slider as SliderPrimitive } from "@base-ui/react/slider";
|
|
2
|
+
import { cn } from "cn";
|
|
3
|
+
|
|
4
|
+
function Slider({
|
|
5
|
+
className,
|
|
6
|
+
defaultValue,
|
|
7
|
+
value,
|
|
8
|
+
min = 0,
|
|
9
|
+
max = 100,
|
|
10
|
+
...props
|
|
11
|
+
}: SliderPrimitive.Root.Props) {
|
|
12
|
+
const _values = Array.isArray(value)
|
|
13
|
+
? value
|
|
14
|
+
: Array.isArray(defaultValue)
|
|
15
|
+
? defaultValue
|
|
16
|
+
: [min, max];
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<SliderPrimitive.Root
|
|
20
|
+
className={cn("data-horizontal:w-full data-vertical:h-full", className)}
|
|
21
|
+
data-slot="slider"
|
|
22
|
+
defaultValue={defaultValue}
|
|
23
|
+
value={value}
|
|
24
|
+
min={min}
|
|
25
|
+
max={max}
|
|
26
|
+
thumbAlignment="edge"
|
|
27
|
+
{...props}
|
|
28
|
+
>
|
|
29
|
+
<SliderPrimitive.Control className="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">
|
|
30
|
+
<SliderPrimitive.Track
|
|
31
|
+
data-slot="slider-track"
|
|
32
|
+
className="bg-muted relative grow overflow-hidden rounded-full select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1"
|
|
33
|
+
>
|
|
34
|
+
<SliderPrimitive.Indicator
|
|
35
|
+
data-slot="slider-range"
|
|
36
|
+
className="bg-primary select-none data-horizontal:h-full data-vertical:w-full"
|
|
37
|
+
/>
|
|
38
|
+
</SliderPrimitive.Track>
|
|
39
|
+
{Array.from({ length: _values.length }, (_, index) => (
|
|
40
|
+
<SliderPrimitive.Thumb
|
|
41
|
+
data-slot="slider-thumb"
|
|
42
|
+
key={index}
|
|
43
|
+
className="border-ring ring-ring/50 relative block size-3 shrink-0 rounded-full border bg-white 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"
|
|
44
|
+
/>
|
|
45
|
+
))}
|
|
46
|
+
</SliderPrimitive.Control>
|
|
47
|
+
</SliderPrimitive.Root>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { Slider };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
import { Loader2Icon } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
|
|
5
|
+
return (
|
|
6
|
+
<Loader2Icon
|
|
7
|
+
data-slot="spinner"
|
|
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,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
|
|
6
|
+
function Switch({
|
|
7
|
+
className,
|
|
8
|
+
size = "default",
|
|
9
|
+
...props
|
|
10
|
+
}: SwitchPrimitive.Root.Props & {
|
|
11
|
+
size?: "sm" | "default";
|
|
12
|
+
}) {
|
|
13
|
+
return (
|
|
14
|
+
<SwitchPrimitive.Root
|
|
15
|
+
data-slot="switch"
|
|
16
|
+
data-size={size}
|
|
17
|
+
className={cn(
|
|
18
|
+
"peer group/switch focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 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 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:ring-3 aria-invalid:ring-3 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px]",
|
|
19
|
+
className
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
<SwitchPrimitive.Thumb
|
|
24
|
+
data-slot="switch-thumb"
|
|
25
|
+
className="bg-background dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground pointer-events-none block rounded-full 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)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0"
|
|
26
|
+
/>
|
|
27
|
+
</SwitchPrimitive.Root>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Switch };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
data-slot="table-container"
|
|
8
|
+
className="relative w-full overflow-x-auto"
|
|
9
|
+
>
|
|
10
|
+
<table
|
|
11
|
+
data-slot="table"
|
|
12
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
|
20
|
+
return (
|
|
21
|
+
<thead
|
|
22
|
+
data-slot="table-header"
|
|
23
|
+
className={cn("[&_tr]:border-b", className)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
|
30
|
+
return (
|
|
31
|
+
<tbody
|
|
32
|
+
data-slot="table-body"
|
|
33
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
40
|
+
return (
|
|
41
|
+
<tfoot
|
|
42
|
+
data-slot="table-footer"
|
|
43
|
+
className={cn(
|
|
44
|
+
"bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
|
|
45
|
+
className
|
|
46
|
+
)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
53
|
+
return (
|
|
54
|
+
<tr
|
|
55
|
+
data-slot="table-row"
|
|
56
|
+
className={cn(
|
|
57
|
+
"hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
|
|
58
|
+
className
|
|
59
|
+
)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
66
|
+
return (
|
|
67
|
+
<th
|
|
68
|
+
data-slot="table-head"
|
|
69
|
+
className={cn(
|
|
70
|
+
"text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0",
|
|
71
|
+
className
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|
79
|
+
return (
|
|
80
|
+
<td
|
|
81
|
+
data-slot="table-cell"
|
|
82
|
+
className={cn(
|
|
83
|
+
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
|
|
84
|
+
className
|
|
85
|
+
)}
|
|
86
|
+
{...props}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function TableCaption({
|
|
92
|
+
className,
|
|
93
|
+
...props
|
|
94
|
+
}: React.ComponentProps<"caption">) {
|
|
95
|
+
return (
|
|
96
|
+
<caption
|
|
97
|
+
data-slot="table-caption"
|
|
98
|
+
className={cn("text-muted-foreground mt-4 text-sm", className)}
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
Table,
|
|
106
|
+
TableHeader,
|
|
107
|
+
TableBody,
|
|
108
|
+
TableFooter,
|
|
109
|
+
TableHead,
|
|
110
|
+
TableRow,
|
|
111
|
+
TableCell,
|
|
112
|
+
TableCaption,
|
|
113
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import type { VariantProps } from "class-variance-authority";
|
|
6
|
+
import { cn } from "cn";
|
|
7
|
+
|
|
8
|
+
function Tabs({
|
|
9
|
+
className,
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
...props
|
|
12
|
+
}: TabsPrimitive.Root.Props) {
|
|
13
|
+
return (
|
|
14
|
+
<TabsPrimitive.Root
|
|
15
|
+
data-slot="tabs"
|
|
16
|
+
data-orientation={orientation}
|
|
17
|
+
className={cn(
|
|
18
|
+
"group/tabs flex gap-2 data-horizontal:flex-col",
|
|
19
|
+
className
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const tabsListVariants = cva(
|
|
27
|
+
"group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center rounded-lg p-[3px] group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
|
|
28
|
+
{
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
variant: "default",
|
|
31
|
+
},
|
|
32
|
+
variants: {
|
|
33
|
+
variant: {
|
|
34
|
+
default: "bg-muted",
|
|
35
|
+
line: "gap-1 bg-transparent",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
function TabsList({
|
|
42
|
+
className,
|
|
43
|
+
variant = "default",
|
|
44
|
+
...props
|
|
45
|
+
}: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>) {
|
|
46
|
+
return (
|
|
47
|
+
<TabsPrimitive.List
|
|
48
|
+
data-slot="tabs-list"
|
|
49
|
+
data-variant={variant}
|
|
50
|
+
className={cn(tabsListVariants({ variant }), className)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
|
|
57
|
+
return (
|
|
58
|
+
<TabsPrimitive.Tab
|
|
59
|
+
data-slot="tabs-trigger"
|
|
60
|
+
className={cn(
|
|
61
|
+
"text-foreground/60 hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
62
|
+
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
|
|
63
|
+
"data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
|
|
64
|
+
"after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
|
|
73
|
+
return (
|
|
74
|
+
<TabsPrimitive.Panel
|
|
75
|
+
data-slot="tabs-content"
|
|
76
|
+
className={cn("flex-1 text-sm outline-none", className)}
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
5
|
+
return (
|
|
6
|
+
<textarea
|
|
7
|
+
data-slot="textarea"
|
|
8
|
+
className={cn(
|
|
9
|
+
"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex field-sizing-content min-h-16 w-full rounded-lg border bg-transparent px-2.5 py-2 text-base transition-colors outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 md:text-sm",
|
|
10
|
+
className
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Textarea };
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Toast as ToastPrimitive } from "@base-ui/react/toast";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import {
|
|
6
|
+
XIcon,
|
|
7
|
+
CircleCheckIcon,
|
|
8
|
+
InfoIcon,
|
|
9
|
+
TriangleAlertIcon,
|
|
10
|
+
OctagonXIcon,
|
|
11
|
+
Loader2Icon,
|
|
12
|
+
} from "lucide-react";
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
|
|
15
|
+
import { Button } from "./button.js";
|
|
16
|
+
|
|
17
|
+
const toast = ToastPrimitive.createToastManager();
|
|
18
|
+
|
|
19
|
+
function ToastProvider({ ...props }: ToastPrimitive.Provider.Props) {
|
|
20
|
+
return <ToastPrimitive.Provider {...props} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function ToastPortal({ ...props }: ToastPrimitive.Portal.Props) {
|
|
24
|
+
return <ToastPrimitive.Portal data-slot="toast-portal" {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function ToastViewport({ className, ...props }: ToastPrimitive.Viewport.Props) {
|
|
28
|
+
return (
|
|
29
|
+
<ToastPrimitive.Viewport
|
|
30
|
+
data-slot="toast-viewport"
|
|
31
|
+
className={cn(
|
|
32
|
+
"pointer-events-none fixed inset-x-4 bottom-4 z-50 mx-auto w-auto max-w-sm outline-none sm:right-4 sm:left-auto sm:mx-0 sm:w-full",
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function Toast({ className, ...props }: ToastPrimitive.Root.Props) {
|
|
41
|
+
return (
|
|
42
|
+
<ToastPrimitive.Root
|
|
43
|
+
data-slot="toast"
|
|
44
|
+
className={cn(
|
|
45
|
+
"group/toast bg-popover text-popover-foreground focus-visible:border-ring focus-visible:ring-ring/50 pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-2xl border shadow-lg will-change-transform outline-none select-none focus-visible:ring-[3px]",
|
|
46
|
+
"[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]",
|
|
47
|
+
"h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]",
|
|
48
|
+
"after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
|
|
49
|
+
"data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]",
|
|
50
|
+
"data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]",
|
|
51
|
+
"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]",
|
|
52
|
+
"data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
|
|
53
|
+
"data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
|
|
54
|
+
"data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
|
|
55
|
+
"data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
|
|
56
|
+
"data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
|
|
57
|
+
"data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
|
|
58
|
+
"data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
|
|
59
|
+
"data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
|
|
60
|
+
className
|
|
61
|
+
)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function ToastContent({ className, ...props }: ToastPrimitive.Content.Props) {
|
|
68
|
+
return (
|
|
69
|
+
<ToastPrimitive.Content
|
|
70
|
+
data-slot="toast-content"
|
|
71
|
+
className={cn(
|
|
72
|
+
"flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100",
|
|
73
|
+
className
|
|
74
|
+
)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function ToastTitle({ className, ...props }: ToastPrimitive.Title.Props) {
|
|
81
|
+
return (
|
|
82
|
+
<ToastPrimitive.Title
|
|
83
|
+
data-slot="toast-title"
|
|
84
|
+
className={cn("text-sm font-medium", className)}
|
|
85
|
+
{...props}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function ToastDescription({
|
|
91
|
+
className,
|
|
92
|
+
...props
|
|
93
|
+
}: ToastPrimitive.Description.Props) {
|
|
94
|
+
return (
|
|
95
|
+
<ToastPrimitive.Description
|
|
96
|
+
data-slot="toast-description"
|
|
97
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function ToastAction({
|
|
104
|
+
className,
|
|
105
|
+
render = <Button variant="outline" size="sm" />,
|
|
106
|
+
...props
|
|
107
|
+
}: ToastPrimitive.Action.Props) {
|
|
108
|
+
return (
|
|
109
|
+
<ToastPrimitive.Action
|
|
110
|
+
data-slot="toast-action"
|
|
111
|
+
render={render}
|
|
112
|
+
className={cn("shrink-0", className)}
|
|
113
|
+
{...props}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function ToastClose({
|
|
119
|
+
className,
|
|
120
|
+
children,
|
|
121
|
+
render = <Button variant="ghost" size="icon-sm" />,
|
|
122
|
+
...props
|
|
123
|
+
}: ToastPrimitive.Close.Props) {
|
|
124
|
+
return (
|
|
125
|
+
<ToastPrimitive.Close
|
|
126
|
+
data-slot="toast-close"
|
|
127
|
+
aria-label="Close toast"
|
|
128
|
+
render={render}
|
|
129
|
+
className={cn(
|
|
130
|
+
"text-muted-foreground hover:text-foreground relative shrink-0 after:absolute after:-inset-2 after:content-['']",
|
|
131
|
+
className
|
|
132
|
+
)}
|
|
133
|
+
{...props}
|
|
134
|
+
>
|
|
135
|
+
{children ?? <XIcon aria-hidden="true" />}
|
|
136
|
+
</ToastPrimitive.Close>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function ToastIcon({ type }: { type: string | undefined }) {
|
|
141
|
+
let icon: React.ReactNode = null;
|
|
142
|
+
|
|
143
|
+
if (type === "success") {
|
|
144
|
+
icon = <CircleCheckIcon aria-hidden="true" />;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (type === "info") {
|
|
148
|
+
icon = <InfoIcon aria-hidden="true" />;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (type === "warning") {
|
|
152
|
+
icon = <TriangleAlertIcon aria-hidden="true" />;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (type === "error") {
|
|
156
|
+
icon = <OctagonXIcon className="text-destructive" aria-hidden="true" />;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (type === "loading") {
|
|
160
|
+
icon = <Loader2Icon className="animate-spin" aria-hidden="true" />;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (!icon) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<span
|
|
169
|
+
data-slot="toast-icon"
|
|
170
|
+
className="shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4"
|
|
171
|
+
>
|
|
172
|
+
{icon}
|
|
173
|
+
</span>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function ToastList() {
|
|
178
|
+
const { toasts } = ToastPrimitive.useToastManager();
|
|
179
|
+
|
|
180
|
+
return toasts.map((toastItem) => (
|
|
181
|
+
<Toast key={toastItem.id} toast={toastItem}>
|
|
182
|
+
<ToastContent>
|
|
183
|
+
<ToastIcon type={toastItem.type} />
|
|
184
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
185
|
+
<ToastTitle />
|
|
186
|
+
<ToastDescription />
|
|
187
|
+
</div>
|
|
188
|
+
<ToastAction />
|
|
189
|
+
<ToastClose />
|
|
190
|
+
</ToastContent>
|
|
191
|
+
</Toast>
|
|
192
|
+
));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function Toaster({
|
|
196
|
+
children,
|
|
197
|
+
toastManager = toast,
|
|
198
|
+
...props
|
|
199
|
+
}: ToastPrimitive.Provider.Props) {
|
|
200
|
+
return (
|
|
201
|
+
<ToastProvider toastManager={toastManager} {...props}>
|
|
202
|
+
{children}
|
|
203
|
+
<ToastPortal>
|
|
204
|
+
<ToastViewport>
|
|
205
|
+
<ToastList />
|
|
206
|
+
</ToastViewport>
|
|
207
|
+
</ToastPortal>
|
|
208
|
+
</ToastProvider>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const { createToastManager } = ToastPrimitive;
|
|
213
|
+
const { useToastManager } = ToastPrimitive;
|
|
214
|
+
|
|
215
|
+
export {
|
|
216
|
+
Toaster,
|
|
217
|
+
Toast,
|
|
218
|
+
ToastAction,
|
|
219
|
+
ToastClose,
|
|
220
|
+
ToastContent,
|
|
221
|
+
ToastDescription,
|
|
222
|
+
ToastPortal,
|
|
223
|
+
ToastProvider,
|
|
224
|
+
ToastTitle,
|
|
225
|
+
ToastViewport,
|
|
226
|
+
createToastManager,
|
|
227
|
+
toast,
|
|
228
|
+
useToastManager,
|
|
229
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
2
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group";
|
|
3
|
+
import type { VariantProps } from "class-variance-authority";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
|
|
7
|
+
import { toggleVariants } from "./toggle.js";
|
|
8
|
+
|
|
9
|
+
const ToggleGroupContext = React.createContext<
|
|
10
|
+
VariantProps<typeof toggleVariants> & {
|
|
11
|
+
spacing?: number;
|
|
12
|
+
orientation?: "horizontal" | "vertical";
|
|
13
|
+
}
|
|
14
|
+
>({
|
|
15
|
+
orientation: "horizontal",
|
|
16
|
+
size: "default",
|
|
17
|
+
spacing: 2,
|
|
18
|
+
variant: "default",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
function ToggleGroup({
|
|
22
|
+
className,
|
|
23
|
+
variant,
|
|
24
|
+
size,
|
|
25
|
+
spacing = 2,
|
|
26
|
+
orientation = "horizontal",
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}: ToggleGroupPrimitive.Props &
|
|
30
|
+
VariantProps<typeof toggleVariants> & {
|
|
31
|
+
spacing?: number;
|
|
32
|
+
orientation?: "horizontal" | "vertical";
|
|
33
|
+
}) {
|
|
34
|
+
return (
|
|
35
|
+
<ToggleGroupPrimitive
|
|
36
|
+
data-slot="toggle-group"
|
|
37
|
+
data-variant={variant}
|
|
38
|
+
data-size={size}
|
|
39
|
+
data-spacing={spacing}
|
|
40
|
+
data-orientation={orientation}
|
|
41
|
+
style={{ "--gap": spacing } as React.CSSProperties}
|
|
42
|
+
className={cn(
|
|
43
|
+
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-vertical:flex-col data-vertical:items-stretch data-[size=sm]:rounded-[min(var(--radius-md),10px)]",
|
|
44
|
+
className
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
<ToggleGroupContext.Provider
|
|
49
|
+
value={{ orientation, size, spacing, variant }}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</ToggleGroupContext.Provider>
|
|
53
|
+
</ToggleGroupPrimitive>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function ToggleGroupItem({
|
|
58
|
+
className,
|
|
59
|
+
children,
|
|
60
|
+
variant = "default",
|
|
61
|
+
size = "default",
|
|
62
|
+
...props
|
|
63
|
+
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
|
|
64
|
+
const context = React.useContext(ToggleGroupContext);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<TogglePrimitive
|
|
68
|
+
data-slot="toggle-group-item"
|
|
69
|
+
data-variant={context.variant || variant}
|
|
70
|
+
data-size={context.size || size}
|
|
71
|
+
data-spacing={context.spacing}
|
|
72
|
+
className={cn(
|
|
73
|
+
"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",
|
|
74
|
+
toggleVariants({
|
|
75
|
+
size: context.size || size,
|
|
76
|
+
variant: context.variant || variant,
|
|
77
|
+
}),
|
|
78
|
+
className
|
|
79
|
+
)}
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
{children}
|
|
83
|
+
</TogglePrimitive>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import type { VariantProps } from "class-variance-authority";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
|
|
6
|
+
const toggleVariants = cva(
|
|
7
|
+
"group/toggle hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/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 inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
8
|
+
{
|
|
9
|
+
defaultVariants: {
|
|
10
|
+
size: "default",
|
|
11
|
+
variant: "default",
|
|
12
|
+
},
|
|
13
|
+
variants: {
|
|
14
|
+
size: {
|
|
15
|
+
default:
|
|
16
|
+
"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
17
|
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
18
|
+
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",
|
|
19
|
+
},
|
|
20
|
+
variant: {
|
|
21
|
+
default: "bg-transparent",
|
|
22
|
+
outline: "border-input hover:bg-muted border bg-transparent",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
function Toggle({
|
|
29
|
+
className,
|
|
30
|
+
variant = "default",
|
|
31
|
+
size = "default",
|
|
32
|
+
...props
|
|
33
|
+
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
|
|
34
|
+
return (
|
|
35
|
+
<TogglePrimitive
|
|
36
|
+
data-slot="toggle"
|
|
37
|
+
className={cn(toggleVariants({ className, size, variant }))}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Toggle, toggleVariants };
|