@vvedantb/ui 0.1.1 → 0.1.2
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 -21
- package/package.json +3 -2
- package/src/ai-elements/artifact.tsx +99 -99
- package/src/ai-elements/attachments.tsx +366 -366
- package/src/ai-elements/chain-of-thought.tsx +212 -212
- package/src/ai-elements/code-block.tsx +478 -478
- package/src/ai-elements/conversation.tsx +157 -157
- package/src/ai-elements/image.tsx +25 -25
- package/src/ai-elements/inline-citation.tsx +252 -252
- package/src/ai-elements/message.tsx +269 -269
- package/src/ai-elements/model-selector.tsx +211 -211
- package/src/ai-elements/prompt-input.tsx +1018 -1018
- package/src/ai-elements/queue.tsx +251 -251
- package/src/ai-elements/reasoning.tsx +178 -178
- package/src/ai-elements/shimmer.tsx +56 -56
- package/src/ai-elements/sources.tsx +77 -77
- package/src/ai-elements/speech-input.tsx +290 -290
- package/src/ai-elements/suggestion.tsx +191 -191
- package/src/css.d.ts +2 -2
- package/src/index.ts +96 -96
- package/src/motion/presets.ts +35 -35
- package/src/motion/presets.vibot.ts +105 -105
- package/src/ui/_menu-classes.ts +30 -30
- package/src/ui/_menu-classes.vibot.ts +33 -33
- package/src/ui/accordion.tsx +81 -81
- package/src/ui/accordion.verve.tsx +56 -56
- package/src/ui/badge.tsx +34 -34
- package/src/ui/breadcrumb.tsx +83 -83
- package/src/ui/button-group.tsx +84 -84
- package/src/ui/button.tsx +57 -57
- package/src/ui/card.tsx +27 -27
- package/src/ui/carousel.tsx +211 -211
- package/src/ui/checkbox.tsx +27 -27
- package/src/ui/clear-input.tsx +170 -170
- package/src/ui/clear-input.vibot.tsx +76 -76
- package/src/ui/clearInputDissolve.ts +214 -214
- package/src/ui/collapsible.tsx +7 -7
- package/src/ui/command.tsx +148 -148
- package/src/ui/context-menu.tsx +173 -173
- package/src/ui/dialog.tsx +149 -149
- package/src/ui/dropdown-menu.tsx +178 -178
- package/src/ui/hover-card.tsx +31 -31
- package/src/ui/input-group.tsx +162 -162
- package/src/ui/input-group.verve.tsx +150 -150
- package/src/ui/input.tsx +21 -21
- package/src/ui/kbd.tsx +18 -18
- package/src/ui/label.tsx +20 -20
- package/src/ui/labeled-switch-row.tsx +53 -53
- package/src/ui/modalTransition.ts +85 -85
- package/src/ui/pagination.tsx +47 -47
- package/src/ui/popover.tsx +33 -33
- package/src/ui/progress.tsx +25 -25
- package/src/ui/radix-select.tsx +202 -202
- package/src/ui/scroll-area.tsx +55 -55
- package/src/ui/scroll-area.verve.tsx +43 -43
- package/src/ui/search-input.tsx +29 -29
- package/src/ui/select.tsx +163 -163
- package/src/ui/separator.tsx +28 -28
- package/src/ui/sheet.tsx +87 -87
- package/src/ui/skeleton.tsx +18 -18
- package/src/ui/sonner.css +16 -16
- package/src/ui/sonner.tsx +47 -47
- package/src/ui/spinner.tsx +27 -27
- package/src/ui/surface-classes.ts +55 -55
- package/src/ui/switch.tsx +26 -26
- package/src/ui/table.tsx +123 -123
- package/src/ui/tabs.tsx +140 -140
- package/src/ui/tabsSliding.ts +56 -56
- package/src/ui/textarea.tsx +21 -21
- package/src/ui/time-picker.tsx +170 -170
- package/src/ui/tooltip.tsx +25 -25
- package/src/ui/visually-hidden.tsx +3 -3
- package/src/utils/cn.ts +16 -16
- package/src/utils/ref.ts +10 -10
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
-
import { cn } from "../utils/cn";
|
|
6
|
-
import { Button, type ButtonProps } from "./button";
|
|
7
|
-
import { Input } from "./input";
|
|
8
|
-
import { Textarea } from "./textarea";
|
|
9
|
-
|
|
10
|
-
const InputGroup = React.forwardRef<
|
|
11
|
-
HTMLDivElement,
|
|
12
|
-
React.HTMLAttributes<HTMLDivElement> & { error?: boolean }
|
|
13
|
-
>(({ className, error, ...props }, ref) => (
|
|
14
|
-
<div
|
|
15
|
-
ref={ref}
|
|
16
|
-
data-input-group=""
|
|
17
|
-
className={cn(
|
|
18
|
-
"flex h-10 flex-wrap rounded-field border border-border bg-field-background text-sm transition-[border-color,box-shadow] duration-200 ease-smooth",
|
|
19
|
-
"has-[textarea]:h-auto",
|
|
20
|
-
"has-data-[slot=input-group-control]:h-auto",
|
|
21
|
-
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",
|
|
22
|
-
"has-focus-visible:border-focus-border has-focus-visible:outline-hidden has-focus-visible:ring-2 has-focus-visible:ring-focus-ring",
|
|
23
|
-
error &&
|
|
24
|
-
"border-danger-border has-focus-visible:border-danger has-focus-visible:ring-danger-ring",
|
|
25
|
-
className,
|
|
26
|
-
)}
|
|
27
|
-
{...props}
|
|
28
|
-
/>
|
|
29
|
-
));
|
|
30
|
-
InputGroup.displayName = "InputGroup";
|
|
31
|
-
|
|
32
|
-
const inputGroupAddonVariants = cva("flex items-center", {
|
|
33
|
-
variants: {
|
|
34
|
-
align: {
|
|
35
|
-
"inline-start": "flex-row ps-3",
|
|
36
|
-
"inline-end": "flex-row pe-3",
|
|
37
|
-
"block-start": "w-full flex-row border-b border-separator px-3 py-2",
|
|
38
|
-
"block-end": "w-full flex-row px-3 py-2",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
defaultVariants: {
|
|
42
|
-
align: "inline-start",
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const InputGroupAddon = React.forwardRef<
|
|
47
|
-
HTMLDivElement,
|
|
48
|
-
React.HTMLAttributes<HTMLDivElement> &
|
|
49
|
-
VariantProps<typeof inputGroupAddonVariants>
|
|
50
|
-
>(({ className, align, onClick, ...props }, ref) => (
|
|
51
|
-
<div
|
|
52
|
-
ref={ref}
|
|
53
|
-
data-align={align}
|
|
54
|
-
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
55
|
-
onClick={(e) => {
|
|
56
|
-
if (onClick) {
|
|
57
|
-
onClick(e);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const group = (e.currentTarget as HTMLElement).closest(
|
|
61
|
-
"[data-input-group]",
|
|
62
|
-
);
|
|
63
|
-
const input = group?.querySelector("textarea, input");
|
|
64
|
-
if (input instanceof HTMLElement) input.focus();
|
|
65
|
-
}}
|
|
66
|
-
{...props}
|
|
67
|
-
/>
|
|
68
|
-
));
|
|
69
|
-
InputGroupAddon.displayName = "InputGroupAddon";
|
|
70
|
-
|
|
71
|
-
const inputGroupButtonVariants = cva("shrink-0 shadow-none", {
|
|
72
|
-
variants: {
|
|
73
|
-
size: {
|
|
74
|
-
xs: "h-7 rounded-lg px-2 text-xs",
|
|
75
|
-
sm: "h-8 rounded-lg px-2.5 text-xs",
|
|
76
|
-
"icon-xs": "h-7 w-7 rounded-lg",
|
|
77
|
-
"icon-sm": "h-8 w-8 rounded-lg",
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
defaultVariants: {
|
|
81
|
-
size: "xs",
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const InputGroupButton = React.forwardRef<
|
|
86
|
-
HTMLButtonElement,
|
|
87
|
-
ButtonProps & VariantProps<typeof inputGroupButtonVariants>
|
|
88
|
-
>(({ className, size, variant = "ghost", ...props }, ref) => (
|
|
89
|
-
<Button
|
|
90
|
-
ref={ref}
|
|
91
|
-
variant={variant}
|
|
92
|
-
className={cn(inputGroupButtonVariants({ size }), className)}
|
|
93
|
-
{...props}
|
|
94
|
-
/>
|
|
95
|
-
));
|
|
96
|
-
InputGroupButton.displayName = "InputGroupButton";
|
|
97
|
-
|
|
98
|
-
function InputGroupText({
|
|
99
|
-
className,
|
|
100
|
-
...props
|
|
101
|
-
}: React.HTMLAttributes<HTMLSpanElement>) {
|
|
102
|
-
return (
|
|
103
|
-
<span
|
|
104
|
-
className={cn(
|
|
105
|
-
"flex items-center text-sm text-muted-foreground/95",
|
|
106
|
-
className,
|
|
107
|
-
)}
|
|
108
|
-
{...props}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const InputGroupInput = React.forwardRef<
|
|
114
|
-
HTMLInputElement,
|
|
115
|
-
React.ComponentProps<typeof Input>
|
|
116
|
-
>(({ className, ...props }, ref) => (
|
|
117
|
-
<Input
|
|
118
|
-
ref={ref}
|
|
119
|
-
className={cn(
|
|
120
|
-
"h-full flex-1 border-0 bg-transparent px-3 py-2 shadow-none focus-visible:border-0 focus-visible:ring-0",
|
|
121
|
-
className,
|
|
122
|
-
)}
|
|
123
|
-
{...props}
|
|
124
|
-
/>
|
|
125
|
-
));
|
|
126
|
-
InputGroupInput.displayName = "InputGroupInput";
|
|
127
|
-
|
|
128
|
-
const InputGroupTextarea = React.forwardRef<
|
|
129
|
-
HTMLTextAreaElement,
|
|
130
|
-
React.ComponentProps<typeof Textarea>
|
|
131
|
-
>(({ className, ...props }, ref) => (
|
|
132
|
-
<Textarea
|
|
133
|
-
ref={ref}
|
|
134
|
-
className={cn(
|
|
135
|
-
"flex-1 resize-none border-0 bg-transparent px-3 py-2.5 shadow-none focus-visible:border-0 focus-visible:ring-0 field-sizing-content",
|
|
136
|
-
className,
|
|
137
|
-
)}
|
|
138
|
-
{...props}
|
|
139
|
-
/>
|
|
140
|
-
));
|
|
141
|
-
InputGroupTextarea.displayName = "InputGroupTextarea";
|
|
142
|
-
|
|
143
|
-
export {
|
|
144
|
-
InputGroup,
|
|
145
|
-
InputGroupAddon,
|
|
146
|
-
InputGroupButton,
|
|
147
|
-
InputGroupText,
|
|
148
|
-
InputGroupInput,
|
|
149
|
-
InputGroupTextarea,
|
|
150
|
-
};
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../utils/cn";
|
|
6
|
+
import { Button, type ButtonProps } from "./button";
|
|
7
|
+
import { Input } from "./input";
|
|
8
|
+
import { Textarea } from "./textarea";
|
|
9
|
+
|
|
10
|
+
const InputGroup = React.forwardRef<
|
|
11
|
+
HTMLDivElement,
|
|
12
|
+
React.HTMLAttributes<HTMLDivElement> & { error?: boolean }
|
|
13
|
+
>(({ className, error, ...props }, ref) => (
|
|
14
|
+
<div
|
|
15
|
+
ref={ref}
|
|
16
|
+
data-input-group=""
|
|
17
|
+
className={cn(
|
|
18
|
+
"flex h-10 flex-wrap rounded-field border border-border bg-field-background text-sm transition-[border-color,box-shadow] duration-200 ease-smooth",
|
|
19
|
+
"has-[textarea]:h-auto",
|
|
20
|
+
"has-data-[slot=input-group-control]:h-auto",
|
|
21
|
+
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",
|
|
22
|
+
"has-focus-visible:border-focus-border has-focus-visible:outline-hidden has-focus-visible:ring-2 has-focus-visible:ring-focus-ring",
|
|
23
|
+
error &&
|
|
24
|
+
"border-danger-border has-focus-visible:border-danger has-focus-visible:ring-danger-ring",
|
|
25
|
+
className,
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
));
|
|
30
|
+
InputGroup.displayName = "InputGroup";
|
|
31
|
+
|
|
32
|
+
const inputGroupAddonVariants = cva("flex items-center", {
|
|
33
|
+
variants: {
|
|
34
|
+
align: {
|
|
35
|
+
"inline-start": "flex-row ps-3",
|
|
36
|
+
"inline-end": "flex-row pe-3",
|
|
37
|
+
"block-start": "w-full flex-row border-b border-separator px-3 py-2",
|
|
38
|
+
"block-end": "w-full flex-row px-3 py-2",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
align: "inline-start",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const InputGroupAddon = React.forwardRef<
|
|
47
|
+
HTMLDivElement,
|
|
48
|
+
React.HTMLAttributes<HTMLDivElement> &
|
|
49
|
+
VariantProps<typeof inputGroupAddonVariants>
|
|
50
|
+
>(({ className, align, onClick, ...props }, ref) => (
|
|
51
|
+
<div
|
|
52
|
+
ref={ref}
|
|
53
|
+
data-align={align}
|
|
54
|
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
55
|
+
onClick={(e) => {
|
|
56
|
+
if (onClick) {
|
|
57
|
+
onClick(e);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const group = (e.currentTarget as HTMLElement).closest(
|
|
61
|
+
"[data-input-group]",
|
|
62
|
+
);
|
|
63
|
+
const input = group?.querySelector("textarea, input");
|
|
64
|
+
if (input instanceof HTMLElement) input.focus();
|
|
65
|
+
}}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
));
|
|
69
|
+
InputGroupAddon.displayName = "InputGroupAddon";
|
|
70
|
+
|
|
71
|
+
const inputGroupButtonVariants = cva("shrink-0 shadow-none", {
|
|
72
|
+
variants: {
|
|
73
|
+
size: {
|
|
74
|
+
xs: "h-7 rounded-lg px-2 text-xs",
|
|
75
|
+
sm: "h-8 rounded-lg px-2.5 text-xs",
|
|
76
|
+
"icon-xs": "h-7 w-7 rounded-lg",
|
|
77
|
+
"icon-sm": "h-8 w-8 rounded-lg",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
defaultVariants: {
|
|
81
|
+
size: "xs",
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const InputGroupButton = React.forwardRef<
|
|
86
|
+
HTMLButtonElement,
|
|
87
|
+
ButtonProps & VariantProps<typeof inputGroupButtonVariants>
|
|
88
|
+
>(({ className, size, variant = "ghost", ...props }, ref) => (
|
|
89
|
+
<Button
|
|
90
|
+
ref={ref}
|
|
91
|
+
variant={variant}
|
|
92
|
+
className={cn(inputGroupButtonVariants({ size }), className)}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
));
|
|
96
|
+
InputGroupButton.displayName = "InputGroupButton";
|
|
97
|
+
|
|
98
|
+
function InputGroupText({
|
|
99
|
+
className,
|
|
100
|
+
...props
|
|
101
|
+
}: React.HTMLAttributes<HTMLSpanElement>) {
|
|
102
|
+
return (
|
|
103
|
+
<span
|
|
104
|
+
className={cn(
|
|
105
|
+
"flex items-center text-sm text-muted-foreground/95",
|
|
106
|
+
className,
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const InputGroupInput = React.forwardRef<
|
|
114
|
+
HTMLInputElement,
|
|
115
|
+
React.ComponentProps<typeof Input>
|
|
116
|
+
>(({ className, ...props }, ref) => (
|
|
117
|
+
<Input
|
|
118
|
+
ref={ref}
|
|
119
|
+
className={cn(
|
|
120
|
+
"h-full flex-1 rounded-none border-0 bg-transparent px-3 py-2 shadow-none focus-visible:border-0 focus-visible:ring-0",
|
|
121
|
+
className,
|
|
122
|
+
)}
|
|
123
|
+
{...props}
|
|
124
|
+
/>
|
|
125
|
+
));
|
|
126
|
+
InputGroupInput.displayName = "InputGroupInput";
|
|
127
|
+
|
|
128
|
+
const InputGroupTextarea = React.forwardRef<
|
|
129
|
+
HTMLTextAreaElement,
|
|
130
|
+
React.ComponentProps<typeof Textarea>
|
|
131
|
+
>(({ className, ...props }, ref) => (
|
|
132
|
+
<Textarea
|
|
133
|
+
ref={ref}
|
|
134
|
+
className={cn(
|
|
135
|
+
"flex-1 resize-none rounded-none border-0 bg-transparent px-3 py-2.5 shadow-none focus-visible:border-0 focus-visible:ring-0 field-sizing-content",
|
|
136
|
+
className,
|
|
137
|
+
)}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
));
|
|
141
|
+
InputGroupTextarea.displayName = "InputGroupTextarea";
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
InputGroup,
|
|
145
|
+
InputGroupAddon,
|
|
146
|
+
InputGroupButton,
|
|
147
|
+
InputGroupText,
|
|
148
|
+
InputGroupInput,
|
|
149
|
+
InputGroupTextarea,
|
|
150
|
+
};
|
package/src/ui/input.tsx
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { cn } from "../utils/cn";
|
|
3
|
-
|
|
4
|
-
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
|
5
|
-
({ className, type, ...props }, ref) => {
|
|
6
|
-
return (
|
|
7
|
-
<input
|
|
8
|
-
type={type}
|
|
9
|
-
className={cn(
|
|
10
|
-
"flex h-10 w-full max-sm:min-w-0 rounded-
|
|
11
|
-
className,
|
|
12
|
-
)}
|
|
13
|
-
ref={ref}
|
|
14
|
-
{...props}
|
|
15
|
-
/>
|
|
16
|
-
);
|
|
17
|
-
},
|
|
18
|
-
);
|
|
19
|
-
Input.displayName = "Input";
|
|
20
|
-
|
|
21
|
-
export { Input };
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../utils/cn";
|
|
3
|
+
|
|
4
|
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
|
5
|
+
({ className, type, ...props }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<input
|
|
8
|
+
type={type}
|
|
9
|
+
className={cn(
|
|
10
|
+
"flex h-10 w-full max-sm:min-w-0 rounded-field border border-border bg-field-background px-3.5 py-2 text-base sm:text-sm transition-[border-color,box-shadow,background-color] duration-200 ease-smooth file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-field-placeholder focus-visible:border-focus-border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
ref={ref}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
Input.displayName = "Input";
|
|
20
|
+
|
|
21
|
+
export { Input };
|
package/src/ui/kbd.tsx
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { cn } from "../utils/cn";
|
|
3
|
-
|
|
4
|
-
const Kbd = React.forwardRef<HTMLElement, React.HTMLAttributes<HTMLElement>>(
|
|
5
|
-
({ className, ...props }, ref) => (
|
|
6
|
-
<kbd
|
|
7
|
-
ref={ref}
|
|
8
|
-
className={cn(
|
|
9
|
-
"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded-md bg-surface-secondary px-1.5 font-mono text-[10px] font-medium text-muted-foreground",
|
|
10
|
-
className,
|
|
11
|
-
)}
|
|
12
|
-
{...props}
|
|
13
|
-
/>
|
|
14
|
-
),
|
|
15
|
-
);
|
|
16
|
-
Kbd.displayName = "Kbd";
|
|
17
|
-
|
|
18
|
-
export { Kbd };
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../utils/cn";
|
|
3
|
+
|
|
4
|
+
const Kbd = React.forwardRef<HTMLElement, React.HTMLAttributes<HTMLElement>>(
|
|
5
|
+
({ className, ...props }, ref) => (
|
|
6
|
+
<kbd
|
|
7
|
+
ref={ref}
|
|
8
|
+
className={cn(
|
|
9
|
+
"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded-md bg-surface-secondary px-1.5 font-mono text-[10px] font-medium text-muted-foreground",
|
|
10
|
+
className,
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
),
|
|
15
|
+
);
|
|
16
|
+
Kbd.displayName = "Kbd";
|
|
17
|
+
|
|
18
|
+
export { Kbd };
|
package/src/ui/label.tsx
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
-
import { cn } from "../utils/cn";
|
|
4
|
-
|
|
5
|
-
const labelClass =
|
|
6
|
-
"text-sm font-medium leading-none tracking-normal text-foreground/90 peer-disabled:cursor-not-allowed peer-disabled:opacity-70";
|
|
7
|
-
|
|
8
|
-
const Label = React.forwardRef<
|
|
9
|
-
React.ComponentRef<typeof LabelPrimitive.Root>,
|
|
10
|
-
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
11
|
-
>(({ className, ...props }, ref) => (
|
|
12
|
-
<LabelPrimitive.Root
|
|
13
|
-
ref={ref}
|
|
14
|
-
className={cn(labelClass, className)}
|
|
15
|
-
{...props}
|
|
16
|
-
/>
|
|
17
|
-
));
|
|
18
|
-
Label.displayName = LabelPrimitive.Root.displayName;
|
|
19
|
-
|
|
20
|
-
export { Label };
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
|
|
5
|
+
const labelClass =
|
|
6
|
+
"text-sm font-medium leading-none tracking-normal text-foreground/90 peer-disabled:cursor-not-allowed peer-disabled:opacity-70";
|
|
7
|
+
|
|
8
|
+
const Label = React.forwardRef<
|
|
9
|
+
React.ComponentRef<typeof LabelPrimitive.Root>,
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
11
|
+
>(({ className, ...props }, ref) => (
|
|
12
|
+
<LabelPrimitive.Root
|
|
13
|
+
ref={ref}
|
|
14
|
+
className={cn(labelClass, className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
));
|
|
18
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
19
|
+
|
|
20
|
+
export { Label };
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import { Label } from "./label";
|
|
3
|
-
import { Switch } from "./switch";
|
|
4
|
-
|
|
5
|
-
interface LabeledSwitchRowProps {
|
|
6
|
-
id: string;
|
|
7
|
-
label: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
checked: boolean;
|
|
10
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
icon?: ReactNode;
|
|
13
|
-
trailing?: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function LabeledSwitchRow({
|
|
17
|
-
id,
|
|
18
|
-
label,
|
|
19
|
-
description,
|
|
20
|
-
checked,
|
|
21
|
-
onCheckedChange,
|
|
22
|
-
disabled,
|
|
23
|
-
icon,
|
|
24
|
-
trailing,
|
|
25
|
-
}: LabeledSwitchRowProps) {
|
|
26
|
-
return (
|
|
27
|
-
<div className="flex items-center justify-between gap-3 max-sm:flex-wrap">
|
|
28
|
-
<div className="flex min-w-0 items-start gap-2">
|
|
29
|
-
{icon ? (
|
|
30
|
-
<span className="mt-0.5 shrink-0 text-muted">{icon}</span>
|
|
31
|
-
) : null}
|
|
32
|
-
<div className="min-w-0">
|
|
33
|
-
<Label htmlFor={id} className="text-sm font-medium">
|
|
34
|
-
{label}
|
|
35
|
-
</Label>
|
|
36
|
-
{description ? (
|
|
37
|
-
<p className="mt-1 text-xs text-muted text-pretty">{description}</p>
|
|
38
|
-
) : null}
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
{trailing ?? (
|
|
42
|
-
<div className="flex min-h-10 shrink-0 items-center">
|
|
43
|
-
<Switch
|
|
44
|
-
id={id}
|
|
45
|
-
checked={checked}
|
|
46
|
-
onCheckedChange={onCheckedChange}
|
|
47
|
-
disabled={disabled}
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
)}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Label } from "./label";
|
|
3
|
+
import { Switch } from "./switch";
|
|
4
|
+
|
|
5
|
+
interface LabeledSwitchRowProps {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
checked: boolean;
|
|
10
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
trailing?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function LabeledSwitchRow({
|
|
17
|
+
id,
|
|
18
|
+
label,
|
|
19
|
+
description,
|
|
20
|
+
checked,
|
|
21
|
+
onCheckedChange,
|
|
22
|
+
disabled,
|
|
23
|
+
icon,
|
|
24
|
+
trailing,
|
|
25
|
+
}: LabeledSwitchRowProps) {
|
|
26
|
+
return (
|
|
27
|
+
<div className="flex items-center justify-between gap-3 max-sm:flex-wrap">
|
|
28
|
+
<div className="flex min-w-0 items-start gap-2">
|
|
29
|
+
{icon ? (
|
|
30
|
+
<span className="mt-0.5 shrink-0 text-muted">{icon}</span>
|
|
31
|
+
) : null}
|
|
32
|
+
<div className="min-w-0">
|
|
33
|
+
<Label htmlFor={id} className="text-sm font-medium">
|
|
34
|
+
{label}
|
|
35
|
+
</Label>
|
|
36
|
+
{description ? (
|
|
37
|
+
<p className="mt-1 text-xs text-muted text-pretty">{description}</p>
|
|
38
|
+
) : null}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
{trailing ?? (
|
|
42
|
+
<div className="flex min-h-10 shrink-0 items-center">
|
|
43
|
+
<Switch
|
|
44
|
+
id={id}
|
|
45
|
+
checked={checked}
|
|
46
|
+
onCheckedChange={onCheckedChange}
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|