zudoku 0.13.6 → 0.13.7
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/dist/app/main.js +1 -1
- package/dist/app/main.js.map +1 -1
- package/dist/lib/plugins/api-keys/CreateApiKey.js +1 -1
- package/dist/lib/plugins/api-keys/CreateApiKey.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +2 -2
- package/dist/lib/plugins/openapi/playground/Playground.js +1 -1
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
- package/dist/lib/ui/Accordion.d.ts +7 -0
- package/dist/lib/ui/Accordion.js +14 -0
- package/dist/lib/ui/Accordion.js.map +1 -0
- package/dist/lib/ui/Alert.d.ts +8 -0
- package/dist/lib/ui/Alert.js +23 -0
- package/dist/lib/ui/Alert.js.map +1 -0
- package/dist/lib/ui/AlertDialog.d.ts +20 -0
- package/dist/lib/ui/AlertDialog.js +27 -0
- package/dist/lib/ui/AlertDialog.js.map +1 -0
- package/dist/lib/ui/AspectRatio.d.ts +3 -0
- package/dist/lib/ui/AspectRatio.js +4 -0
- package/dist/lib/ui/AspectRatio.js.map +1 -0
- package/dist/lib/ui/Badge.d.ts +9 -0
- package/dist/lib/ui/Badge.js +21 -0
- package/dist/lib/ui/Badge.js.map +1 -0
- package/dist/lib/ui/Breadcrumb.d.ts +19 -0
- package/dist/lib/ui/Breadcrumb.js +24 -0
- package/dist/lib/ui/Breadcrumb.js.map +1 -0
- package/dist/lib/ui/Button.d.ts +1 -2
- package/dist/lib/ui/Button.js +1 -1
- package/dist/lib/ui/Button.js.map +1 -1
- package/dist/lib/ui/Carousel.d.ts +18 -0
- package/dist/lib/ui/Carousel.js +99 -0
- package/dist/lib/ui/Carousel.js.map +1 -0
- package/dist/lib/ui/Checkbox.d.ts +4 -0
- package/dist/lib/ui/Checkbox.js +9 -0
- package/dist/lib/ui/Checkbox.js.map +1 -0
- package/dist/lib/ui/Collapsible.d.ts +5 -0
- package/dist/lib/ui/Collapsible.js +6 -0
- package/dist/lib/ui/Collapsible.js.map +1 -0
- package/dist/lib/{components → ui}/Dialog.js +2 -2
- package/dist/lib/ui/Dialog.js.map +1 -0
- package/dist/lib/ui/Form.d.ts +23 -0
- package/dist/lib/ui/Form.js +63 -0
- package/dist/lib/ui/Form.js.map +1 -0
- package/dist/lib/ui/HoverCard.d.ts +6 -0
- package/dist/lib/ui/HoverCard.js +10 -0
- package/dist/lib/ui/HoverCard.js.map +1 -0
- package/dist/lib/ui/Label.d.ts +5 -0
- package/dist/lib/ui/Label.js +10 -0
- package/dist/lib/ui/Label.js.map +1 -0
- package/dist/lib/ui/Pagination.d.ts +28 -0
- package/dist/lib/ui/Pagination.js +24 -0
- package/dist/lib/ui/Pagination.js.map +1 -0
- package/dist/lib/ui/Popover.d.ts +6 -0
- package/dist/lib/ui/Popover.js +10 -0
- package/dist/lib/ui/Popover.js.map +1 -0
- package/dist/lib/ui/Progress.d.ts +4 -0
- package/dist/lib/ui/Progress.js +8 -0
- package/dist/lib/ui/Progress.js.map +1 -0
- package/dist/lib/ui/RadioGroup.d.ts +5 -0
- package/dist/lib/ui/RadioGroup.js +15 -0
- package/dist/lib/ui/RadioGroup.js.map +1 -0
- package/dist/lib/ui/ScrollArea.d.ts +5 -0
- package/dist/lib/ui/ScrollArea.js +12 -0
- package/dist/lib/ui/ScrollArea.js.map +1 -0
- package/dist/lib/ui/Select.js.map +1 -0
- package/dist/lib/ui/Skeleton.d.ts +2 -0
- package/dist/lib/ui/Skeleton.js +7 -0
- package/dist/lib/ui/Skeleton.js.map +1 -0
- package/dist/lib/ui/Slider.d.ts +4 -0
- package/dist/lib/ui/Slider.js +8 -0
- package/dist/lib/ui/Slider.js.map +1 -0
- package/dist/lib/ui/Switch.d.ts +4 -0
- package/dist/lib/ui/Switch.js +8 -0
- package/dist/lib/ui/Switch.js.map +1 -0
- package/dist/lib/ui/Textarea.d.ts +4 -0
- package/dist/lib/ui/Textarea.js +9 -0
- package/dist/lib/ui/Textarea.js.map +1 -0
- package/dist/lib/ui/Toggle.d.ts +12 -0
- package/dist/lib/ui/Toggle.js +26 -0
- package/dist/lib/ui/Toggle.js.map +1 -0
- package/dist/lib/ui/ToggleGroup.d.ts +12 -0
- package/dist/lib/ui/ToggleGroup.js +21 -0
- package/dist/lib/ui/ToggleGroup.js.map +1 -0
- package/dist/lib/ui/Tooltip.d.ts +7 -0
- package/dist/lib/ui/Tooltip.js +11 -0
- package/dist/lib/ui/Tooltip.js.map +1 -0
- package/dist/vite/plugin-component.js +17 -7
- package/dist/vite/plugin-component.js.map +1 -1
- package/lib/{AuthenticationPlugin-tBvLKsFg.js → AuthenticationPlugin-Bpdes0cJ.js} +2 -2
- package/lib/{AuthenticationPlugin-tBvLKsFg.js.map → AuthenticationPlugin-Bpdes0cJ.js.map} +1 -1
- package/lib/{CategoryHeading-D2WS6sRI.js → CategoryHeading-Bb9dqxD3.js} +4 -4
- package/lib/{CategoryHeading-D2WS6sRI.js.map → CategoryHeading-Bb9dqxD3.js.map} +1 -1
- package/lib/{DeveloperHint-CRiZjqd2.js → DeveloperHint-DHdLXGHA.js} +2 -2
- package/lib/{DeveloperHint-CRiZjqd2.js.map → DeveloperHint-DHdLXGHA.js.map} +1 -1
- package/lib/{Markdown-DM4zv3MA.js → Markdown-1BO9EA_X.js} +4265 -6650
- package/lib/Markdown-1BO9EA_X.js.map +1 -0
- package/lib/{MdxPage-tWI_P8wP.js → MdxPage-BEOcOICU.js} +26 -25
- package/lib/{MdxPage-tWI_P8wP.js.map → MdxPage-BEOcOICU.js.map} +1 -1
- package/lib/{OperationList-Cd3lue0b.js → OperationList-Cea2Yt8e.js} +131 -127
- package/lib/{OperationList-Cd3lue0b.js.map → OperationList-Cea2Yt8e.js.map} +1 -1
- package/lib/{Route-DI0Y0pIV.js → Route-BHT-onwf.js} +2 -2
- package/lib/{Route-DI0Y0pIV.js.map → Route-BHT-onwf.js.map} +1 -1
- package/lib/Select-m1aXZGAP.js +223 -0
- package/lib/Select-m1aXZGAP.js.map +1 -0
- package/lib/{SlotletProvider-CBqY8mp6.js → SlotletProvider-CPfsBw39.js} +4 -4
- package/lib/{SlotletProvider-CBqY8mp6.js.map → SlotletProvider-CPfsBw39.js.map} +1 -1
- package/lib/Spinner-C6zroowC.js +40 -0
- package/lib/Spinner-C6zroowC.js.map +1 -0
- package/lib/StaggeredRender-DDHSzQKE.js +17 -0
- package/lib/StaggeredRender-DDHSzQKE.js.map +1 -0
- package/lib/{ZudokuContext-DEoP3GGJ.js → ZudokuContext-D1D8Anlj.js} +19 -19
- package/lib/{ZudokuContext-DEoP3GGJ.js.map → ZudokuContext-D1D8Anlj.js.map} +1 -1
- package/lib/cn-BmFQLtkS.js +2279 -0
- package/lib/cn-BmFQLtkS.js.map +1 -0
- package/lib/hook-JSRuxV1P.js +229 -0
- package/lib/hook-JSRuxV1P.js.map +1 -0
- package/lib/index-BuAyrJe3.js +46 -0
- package/lib/index-BuAyrJe3.js.map +1 -0
- package/lib/{index-Bs9roz8y.js → index-Cj-F-4ME.js} +1203 -1428
- package/lib/index-Cj-F-4ME.js.map +1 -0
- package/lib/index.esm-C5mr_sKO.js +1193 -0
- package/lib/index.esm-C5mr_sKO.js.map +1 -0
- package/lib/ui/Accordion.js +47 -0
- package/lib/ui/Accordion.js.map +1 -0
- package/lib/ui/Alert.js +51 -0
- package/lib/ui/Alert.js.map +1 -0
- package/lib/ui/AlertDialog.js +114 -0
- package/lib/ui/AlertDialog.js.map +1 -0
- package/lib/ui/AspectRatio.js +6 -0
- package/lib/ui/AspectRatio.js.map +1 -0
- package/lib/ui/Badge.js +27 -0
- package/lib/ui/Badge.js.map +1 -0
- package/lib/ui/Breadcrumb.js +94 -0
- package/lib/ui/Breadcrumb.js.map +1 -0
- package/lib/ui/Button.js +49 -0
- package/lib/ui/Button.js.map +1 -0
- package/lib/ui/Callout.js +77 -0
- package/lib/ui/Callout.js.map +1 -0
- package/lib/ui/Card.js +62 -0
- package/lib/ui/Card.js.map +1 -0
- package/lib/ui/Carousel.js +1410 -0
- package/lib/ui/Carousel.js.map +1 -0
- package/lib/ui/Checkbox.js +28 -0
- package/lib/ui/Checkbox.js.map +1 -0
- package/lib/ui/Collapsible.js +8 -0
- package/lib/ui/Collapsible.js.map +1 -0
- package/lib/ui/Dialog.js +101 -0
- package/lib/ui/Dialog.js.map +1 -0
- package/lib/ui/Drawer.js +1153 -0
- package/lib/ui/Drawer.js.map +1 -0
- package/lib/ui/DropdownMenu.js +145 -0
- package/lib/ui/DropdownMenu.js.map +1 -0
- package/lib/ui/Form.js +95 -0
- package/lib/ui/Form.js.map +1 -0
- package/lib/ui/HoverCard.js +24 -0
- package/lib/ui/HoverCard.js.map +1 -0
- package/lib/ui/Input.js +22 -0
- package/lib/ui/Input.js.map +1 -0
- package/lib/ui/Label.js +20 -0
- package/lib/ui/Label.js.map +1 -0
- package/lib/ui/Note.js +51 -0
- package/lib/ui/Note.js.map +1 -0
- package/lib/ui/Pagination.js +106 -0
- package/lib/ui/Pagination.js.map +1 -0
- package/lib/ui/Popover.js +24 -0
- package/lib/ui/Popover.js.map +1 -0
- package/lib/ui/Progress.js +27 -0
- package/lib/ui/Progress.js.map +1 -0
- package/lib/ui/RadioGroup.js +32 -0
- package/lib/ui/RadioGroup.js.map +1 -0
- package/lib/ui/ScrollArea.js +39 -0
- package/lib/ui/ScrollArea.js.map +1 -0
- package/lib/ui/Select.js +122 -0
- package/lib/ui/Select.js.map +1 -0
- package/lib/ui/Skeleton.js +18 -0
- package/lib/ui/Skeleton.js.map +1 -0
- package/lib/ui/Slider.js +24 -0
- package/lib/ui/Slider.js.map +1 -0
- package/lib/ui/Switch.js +28 -0
- package/lib/ui/Switch.js.map +1 -0
- package/lib/ui/Tabs.js +47 -0
- package/lib/ui/Tabs.js.map +1 -0
- package/lib/ui/Textarea.js +21 -0
- package/lib/ui/Textarea.js.map +1 -0
- package/lib/ui/Toggle.js +38 -0
- package/lib/ui/Toggle.js.map +1 -0
- package/lib/ui/ToggleGroup.js +42 -0
- package/lib/ui/ToggleGroup.js.map +1 -0
- package/lib/ui/Tooltip.js +24 -0
- package/lib/ui/Tooltip.js.map +1 -0
- package/lib/{utils-G5XSiZc9.js → utils-B2yoT99j.js} +61 -61
- package/lib/{utils-G5XSiZc9.js.map → utils-B2yoT99j.js.map} +1 -1
- package/lib/zudoku.auth-clerk.js +1 -1
- package/lib/zudoku.auth-openid.js +2 -2
- package/lib/zudoku.components.js +847 -2844
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +22 -19
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +14 -13
- package/lib/zudoku.plugin-custom-pages.js.map +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +6 -5
- package/lib/zudoku.plugin-openapi.js.map +1 -1
- package/package.json +28 -6
- package/src/app/main.tsx +1 -1
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +2 -2
- package/src/lib/plugins/openapi/Sidecar.tsx +2 -2
- package/src/lib/plugins/openapi/playground/Playground.tsx +3 -3
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +1 -1
- package/src/lib/ui/Accordion.tsx +56 -0
- package/src/lib/ui/Alert.tsx +59 -0
- package/src/lib/ui/AlertDialog.tsx +139 -0
- package/src/lib/ui/AspectRatio.tsx +5 -0
- package/src/lib/ui/Badge.tsx +36 -0
- package/src/lib/ui/Breadcrumb.tsx +115 -0
- package/src/lib/ui/Button.tsx +1 -1
- package/src/lib/ui/Carousel.tsx +260 -0
- package/src/lib/ui/Checkbox.tsx +28 -0
- package/src/lib/ui/Collapsible.tsx +9 -0
- package/src/lib/{components → ui}/Dialog.tsx +4 -3
- package/src/lib/ui/Form.tsx +177 -0
- package/src/lib/ui/HoverCard.tsx +27 -0
- package/src/lib/ui/Label.tsx +24 -0
- package/src/lib/ui/Pagination.tsx +117 -0
- package/src/lib/ui/Popover.tsx +29 -0
- package/src/lib/ui/Progress.tsx +26 -0
- package/src/lib/ui/RadioGroup.tsx +42 -0
- package/src/lib/ui/ScrollArea.tsx +46 -0
- package/src/lib/ui/Skeleton.tsx +15 -0
- package/src/lib/ui/Slider.tsx +26 -0
- package/src/lib/ui/Switch.tsx +27 -0
- package/src/lib/ui/Textarea.tsx +23 -0
- package/src/lib/ui/Toggle.tsx +43 -0
- package/src/lib/ui/ToggleGroup.tsx +59 -0
- package/src/lib/ui/Tooltip.tsx +28 -0
- package/dist/internal.d.ts +0 -1
- package/dist/internal.js +0 -2
- package/dist/internal.js.map +0 -1
- package/dist/lib/components/Dialog.js.map +0 -1
- package/dist/lib/components/Select.js.map +0 -1
- package/lib/Input-CO-1DOZa.js +0 -2229
- package/lib/Input-CO-1DOZa.js.map +0 -1
- package/lib/Markdown-DM4zv3MA.js.map +0 -1
- package/lib/Spinner-DFQhPMBl.js +0 -505
- package/lib/Spinner-DFQhPMBl.js.map +0 -1
- package/lib/index-Bs9roz8y.js.map +0 -1
- package/lib/index-CBr6BM_4.js +0 -2867
- package/lib/index-CBr6BM_4.js.map +0 -1
- package/lib/index-UUT9q9f9.js +0 -124
- package/lib/index-UUT9q9f9.js.map +0 -1
- /package/dist/lib/{components → ui}/Dialog.d.ts +0 -0
- /package/dist/lib/{components → ui}/Select.d.ts +0 -0
- /package/dist/lib/{components → ui}/Select.js +0 -0
- /package/src/lib/{components → ui}/Select.tsx +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {
|
|
5
|
+
Controller,
|
|
6
|
+
ControllerProps,
|
|
7
|
+
FieldPath,
|
|
8
|
+
FieldValues,
|
|
9
|
+
FormProvider,
|
|
10
|
+
useFormContext,
|
|
11
|
+
} from "react-hook-form";
|
|
12
|
+
|
|
13
|
+
import { cn } from "../util/cn.js";
|
|
14
|
+
import { Label } from "./Label.js";
|
|
15
|
+
|
|
16
|
+
const Form = FormProvider;
|
|
17
|
+
|
|
18
|
+
type FormFieldContextValue<
|
|
19
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
20
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
21
|
+
> = {
|
|
22
|
+
name: TName;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
|
26
|
+
{} as FormFieldContextValue,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const FormField = <
|
|
30
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
31
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
32
|
+
>({
|
|
33
|
+
...props
|
|
34
|
+
}: ControllerProps<TFieldValues, TName>) => {
|
|
35
|
+
return (
|
|
36
|
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
|
37
|
+
<Controller {...props} />
|
|
38
|
+
</FormFieldContext.Provider>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const useFormField = () => {
|
|
43
|
+
const fieldContext = React.useContext(FormFieldContext);
|
|
44
|
+
const itemContext = React.useContext(FormItemContext);
|
|
45
|
+
const { getFieldState, formState } = useFormContext();
|
|
46
|
+
|
|
47
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
48
|
+
|
|
49
|
+
if (!fieldContext) {
|
|
50
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { id } = itemContext;
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
name: fieldContext.name,
|
|
58
|
+
formItemId: `${id}-form-item`,
|
|
59
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
60
|
+
formMessageId: `${id}-form-item-message`,
|
|
61
|
+
...fieldState,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type FormItemContextValue = {
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const FormItemContext = React.createContext<FormItemContextValue>(
|
|
70
|
+
{} as FormItemContextValue,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const FormItem = React.forwardRef<
|
|
74
|
+
HTMLDivElement,
|
|
75
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
76
|
+
>(({ className, ...props }, ref) => {
|
|
77
|
+
const id = React.useId();
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<FormItemContext.Provider value={{ id }}>
|
|
81
|
+
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
|
82
|
+
</FormItemContext.Provider>
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
FormItem.displayName = "FormItem";
|
|
86
|
+
|
|
87
|
+
const FormLabel = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
90
|
+
>(({ className, ...props }, ref) => {
|
|
91
|
+
const { error, formItemId } = useFormField();
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Label
|
|
95
|
+
ref={ref}
|
|
96
|
+
className={cn(error && "text-destructive", className)}
|
|
97
|
+
htmlFor={formItemId}
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
FormLabel.displayName = "FormLabel";
|
|
103
|
+
|
|
104
|
+
const FormControl = React.forwardRef<
|
|
105
|
+
React.ElementRef<typeof Slot>,
|
|
106
|
+
React.ComponentPropsWithoutRef<typeof Slot>
|
|
107
|
+
>(({ ...props }, ref) => {
|
|
108
|
+
const { error, formItemId, formDescriptionId, formMessageId } =
|
|
109
|
+
useFormField();
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<Slot
|
|
113
|
+
ref={ref}
|
|
114
|
+
id={formItemId}
|
|
115
|
+
aria-describedby={
|
|
116
|
+
!error
|
|
117
|
+
? `${formDescriptionId}`
|
|
118
|
+
: `${formDescriptionId} ${formMessageId}`
|
|
119
|
+
}
|
|
120
|
+
aria-invalid={!!error}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
FormControl.displayName = "FormControl";
|
|
126
|
+
|
|
127
|
+
const FormDescription = React.forwardRef<
|
|
128
|
+
HTMLParagraphElement,
|
|
129
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
130
|
+
>(({ className, ...props }, ref) => {
|
|
131
|
+
const { formDescriptionId } = useFormField();
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<p
|
|
135
|
+
ref={ref}
|
|
136
|
+
id={formDescriptionId}
|
|
137
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
FormDescription.displayName = "FormDescription";
|
|
143
|
+
|
|
144
|
+
const FormMessage = React.forwardRef<
|
|
145
|
+
HTMLParagraphElement,
|
|
146
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
147
|
+
>(({ className, children, ...props }, ref) => {
|
|
148
|
+
const { error, formMessageId } = useFormField();
|
|
149
|
+
const body = error ? String(error.message) : children;
|
|
150
|
+
|
|
151
|
+
if (!body) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<p
|
|
157
|
+
ref={ref}
|
|
158
|
+
id={formMessageId}
|
|
159
|
+
className={cn("text-sm font-medium text-destructive", className)}
|
|
160
|
+
{...props}
|
|
161
|
+
>
|
|
162
|
+
{body}
|
|
163
|
+
</p>
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
FormMessage.displayName = "FormMessage";
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
Form,
|
|
170
|
+
FormControl,
|
|
171
|
+
FormDescription,
|
|
172
|
+
FormField,
|
|
173
|
+
FormItem,
|
|
174
|
+
FormLabel,
|
|
175
|
+
FormMessage,
|
|
176
|
+
useFormField,
|
|
177
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../util/cn.js";
|
|
5
|
+
|
|
6
|
+
const HoverCard = HoverCardPrimitive.Root;
|
|
7
|
+
|
|
8
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
9
|
+
|
|
10
|
+
const HoverCardContent = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
|
13
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
14
|
+
<HoverCardPrimitive.Content
|
|
15
|
+
ref={ref}
|
|
16
|
+
align={align}
|
|
17
|
+
sideOffset={sideOffset}
|
|
18
|
+
className={cn(
|
|
19
|
+
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
25
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
26
|
+
|
|
27
|
+
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../util/cn.js";
|
|
6
|
+
|
|
7
|
+
const labelVariants = cva(
|
|
8
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const Label = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
14
|
+
VariantProps<typeof labelVariants>
|
|
15
|
+
>(({ className, ...props }, ref) => (
|
|
16
|
+
<LabelPrimitive.Root
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn(labelVariants(), className)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
));
|
|
22
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
23
|
+
|
|
24
|
+
export { Label };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../util/cn.js";
|
|
5
|
+
import { ButtonProps, buttonVariants } from "./Button.js";
|
|
6
|
+
|
|
7
|
+
const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
|
|
8
|
+
<nav
|
|
9
|
+
role="navigation"
|
|
10
|
+
aria-label="pagination"
|
|
11
|
+
className={cn("mx-auto flex w-full justify-center", className)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
Pagination.displayName = "Pagination";
|
|
16
|
+
|
|
17
|
+
const PaginationContent = React.forwardRef<
|
|
18
|
+
HTMLUListElement,
|
|
19
|
+
React.ComponentProps<"ul">
|
|
20
|
+
>(({ className, ...props }, ref) => (
|
|
21
|
+
<ul
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn("flex flex-row items-center gap-1", className)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
));
|
|
27
|
+
PaginationContent.displayName = "PaginationContent";
|
|
28
|
+
|
|
29
|
+
const PaginationItem = React.forwardRef<
|
|
30
|
+
HTMLLIElement,
|
|
31
|
+
React.ComponentProps<"li">
|
|
32
|
+
>(({ className, ...props }, ref) => (
|
|
33
|
+
<li ref={ref} className={cn("", className)} {...props} />
|
|
34
|
+
));
|
|
35
|
+
PaginationItem.displayName = "PaginationItem";
|
|
36
|
+
|
|
37
|
+
type PaginationLinkProps = {
|
|
38
|
+
isActive?: boolean;
|
|
39
|
+
} & Pick<ButtonProps, "size"> &
|
|
40
|
+
React.ComponentProps<"a">;
|
|
41
|
+
|
|
42
|
+
const PaginationLink = ({
|
|
43
|
+
className,
|
|
44
|
+
isActive,
|
|
45
|
+
size = "icon",
|
|
46
|
+
...props
|
|
47
|
+
}: PaginationLinkProps) => (
|
|
48
|
+
<a
|
|
49
|
+
aria-current={isActive ? "page" : undefined}
|
|
50
|
+
className={cn(
|
|
51
|
+
buttonVariants({
|
|
52
|
+
variant: isActive ? "outline" : "ghost",
|
|
53
|
+
size,
|
|
54
|
+
}),
|
|
55
|
+
className,
|
|
56
|
+
)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
PaginationLink.displayName = "PaginationLink";
|
|
61
|
+
|
|
62
|
+
const PaginationPrevious = ({
|
|
63
|
+
className,
|
|
64
|
+
...props
|
|
65
|
+
}: React.ComponentProps<typeof PaginationLink>) => (
|
|
66
|
+
<PaginationLink
|
|
67
|
+
aria-label="Go to previous page"
|
|
68
|
+
size="default"
|
|
69
|
+
className={cn("gap-1 pl-2.5", className)}
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
<ChevronLeft className="h-4 w-4" />
|
|
73
|
+
<span>Previous</span>
|
|
74
|
+
</PaginationLink>
|
|
75
|
+
);
|
|
76
|
+
PaginationPrevious.displayName = "PaginationPrevious";
|
|
77
|
+
|
|
78
|
+
const PaginationNext = ({
|
|
79
|
+
className,
|
|
80
|
+
...props
|
|
81
|
+
}: React.ComponentProps<typeof PaginationLink>) => (
|
|
82
|
+
<PaginationLink
|
|
83
|
+
aria-label="Go to next page"
|
|
84
|
+
size="default"
|
|
85
|
+
className={cn("gap-1 pr-2.5", className)}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
<span>Next</span>
|
|
89
|
+
<ChevronRight className="h-4 w-4" />
|
|
90
|
+
</PaginationLink>
|
|
91
|
+
);
|
|
92
|
+
PaginationNext.displayName = "PaginationNext";
|
|
93
|
+
|
|
94
|
+
const PaginationEllipsis = ({
|
|
95
|
+
className,
|
|
96
|
+
...props
|
|
97
|
+
}: React.ComponentProps<"span">) => (
|
|
98
|
+
<span
|
|
99
|
+
aria-hidden
|
|
100
|
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
|
101
|
+
{...props}
|
|
102
|
+
>
|
|
103
|
+
<MoreHorizontal className="h-4 w-4" />
|
|
104
|
+
<span className="sr-only">More pages</span>
|
|
105
|
+
</span>
|
|
106
|
+
);
|
|
107
|
+
PaginationEllipsis.displayName = "PaginationEllipsis";
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
Pagination,
|
|
111
|
+
PaginationContent,
|
|
112
|
+
PaginationEllipsis,
|
|
113
|
+
PaginationItem,
|
|
114
|
+
PaginationLink,
|
|
115
|
+
PaginationNext,
|
|
116
|
+
PaginationPrevious,
|
|
117
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../util/cn.js";
|
|
5
|
+
|
|
6
|
+
const Popover = PopoverPrimitive.Root;
|
|
7
|
+
|
|
8
|
+
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
9
|
+
|
|
10
|
+
const PopoverContent = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
13
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
14
|
+
<PopoverPrimitive.Portal>
|
|
15
|
+
<PopoverPrimitive.Content
|
|
16
|
+
ref={ref}
|
|
17
|
+
align={align}
|
|
18
|
+
sideOffset={sideOffset}
|
|
19
|
+
className={cn(
|
|
20
|
+
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
</PopoverPrimitive.Portal>
|
|
26
|
+
));
|
|
27
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
28
|
+
|
|
29
|
+
export { Popover, PopoverContent, PopoverTrigger };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../util/cn.js";
|
|
5
|
+
|
|
6
|
+
const Progress = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof ProgressPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
|
|
9
|
+
>(({ className, value, ...props }, ref) => (
|
|
10
|
+
<ProgressPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn(
|
|
13
|
+
"relative h-4 w-full overflow-hidden rounded-full bg-secondary",
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
>
|
|
18
|
+
<ProgressPrimitive.Indicator
|
|
19
|
+
className="h-full w-full flex-1 bg-primary transition-all"
|
|
20
|
+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
21
|
+
/>
|
|
22
|
+
</ProgressPrimitive.Root>
|
|
23
|
+
));
|
|
24
|
+
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
25
|
+
|
|
26
|
+
export { Progress };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
2
|
+
import { Circle } from "lucide-react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../util/cn.js";
|
|
6
|
+
|
|
7
|
+
const RadioGroup = React.forwardRef<
|
|
8
|
+
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
|
9
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
|
10
|
+
>(({ className, ...props }, ref) => {
|
|
11
|
+
return (
|
|
12
|
+
<RadioGroupPrimitive.Root
|
|
13
|
+
className={cn("grid gap-2", className)}
|
|
14
|
+
{...props}
|
|
15
|
+
ref={ref}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
20
|
+
|
|
21
|
+
const RadioGroupItem = React.forwardRef<
|
|
22
|
+
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
|
23
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
|
24
|
+
>(({ className, ...props }, ref) => {
|
|
25
|
+
return (
|
|
26
|
+
<RadioGroupPrimitive.Item
|
|
27
|
+
ref={ref}
|
|
28
|
+
className={cn(
|
|
29
|
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
|
35
|
+
<Circle className="h-2.5 w-2.5 fill-current text-current" />
|
|
36
|
+
</RadioGroupPrimitive.Indicator>
|
|
37
|
+
</RadioGroupPrimitive.Item>
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
41
|
+
|
|
42
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../util/cn.js";
|
|
5
|
+
|
|
6
|
+
const ScrollArea = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
|
9
|
+
>(({ className, children, ...props }, ref) => (
|
|
10
|
+
<ScrollAreaPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn("relative overflow-hidden", className)}
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
|
16
|
+
{children}
|
|
17
|
+
</ScrollAreaPrimitive.Viewport>
|
|
18
|
+
<ScrollBar />
|
|
19
|
+
<ScrollAreaPrimitive.Corner />
|
|
20
|
+
</ScrollAreaPrimitive.Root>
|
|
21
|
+
));
|
|
22
|
+
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
23
|
+
|
|
24
|
+
const ScrollBar = React.forwardRef<
|
|
25
|
+
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
|
26
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
27
|
+
>(({ className, orientation = "vertical", ...props }, ref) => (
|
|
28
|
+
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
29
|
+
ref={ref}
|
|
30
|
+
orientation={orientation}
|
|
31
|
+
className={cn(
|
|
32
|
+
"flex touch-none select-none transition-colors",
|
|
33
|
+
orientation === "vertical" &&
|
|
34
|
+
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
|
35
|
+
orientation === "horizontal" &&
|
|
36
|
+
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
>
|
|
41
|
+
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
|
42
|
+
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
43
|
+
));
|
|
44
|
+
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
45
|
+
|
|
46
|
+
export { ScrollArea, ScrollBar };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cn } from "../util/cn.js";
|
|
2
|
+
|
|
3
|
+
function Skeleton({
|
|
4
|
+
className,
|
|
5
|
+
...props
|
|
6
|
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
className={cn("animate-pulse rounded-md bg-muted", className)}
|
|
10
|
+
{...props}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { Skeleton };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../util/cn.js";
|
|
5
|
+
|
|
6
|
+
const Slider = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof SliderPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => (
|
|
10
|
+
<SliderPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn(
|
|
13
|
+
"relative flex w-full touch-none select-none items-center",
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
>
|
|
18
|
+
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
|
|
19
|
+
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
|
20
|
+
</SliderPrimitive.Track>
|
|
21
|
+
<SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
|
|
22
|
+
</SliderPrimitive.Root>
|
|
23
|
+
));
|
|
24
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
25
|
+
|
|
26
|
+
export { Slider };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../util/cn.js";
|
|
5
|
+
|
|
6
|
+
const Switch = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => (
|
|
10
|
+
<SwitchPrimitives.Root
|
|
11
|
+
className={cn(
|
|
12
|
+
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
ref={ref}
|
|
17
|
+
>
|
|
18
|
+
<SwitchPrimitives.Thumb
|
|
19
|
+
className={cn(
|
|
20
|
+
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
|
|
21
|
+
)}
|
|
22
|
+
/>
|
|
23
|
+
</SwitchPrimitives.Root>
|
|
24
|
+
));
|
|
25
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
26
|
+
|
|
27
|
+
export { Switch };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../util/cn.js";
|
|
4
|
+
|
|
5
|
+
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
6
|
+
|
|
7
|
+
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
8
|
+
({ className, ...props }, ref) => {
|
|
9
|
+
return (
|
|
10
|
+
<textarea
|
|
11
|
+
className={cn(
|
|
12
|
+
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
ref={ref}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
Textarea.displayName = "Textarea";
|
|
22
|
+
|
|
23
|
+
export { Textarea };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../util/cn.js";
|
|
6
|
+
|
|
7
|
+
const toggleVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 gap-2",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-transparent",
|
|
13
|
+
outline:
|
|
14
|
+
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
default: "h-10 px-3 min-w-10",
|
|
18
|
+
sm: "h-9 px-2.5 min-w-9",
|
|
19
|
+
lg: "h-11 px-5 min-w-11",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
size: "default",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const Toggle = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof TogglePrimitive.Root>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
|
|
32
|
+
VariantProps<typeof toggleVariants>
|
|
33
|
+
>(({ className, variant, size, ...props }, ref) => (
|
|
34
|
+
<TogglePrimitive.Root
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
));
|
|
40
|
+
|
|
41
|
+
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
42
|
+
|
|
43
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../util/cn.js";
|
|
6
|
+
import { toggleVariants } from "./Toggle.js";
|
|
7
|
+
|
|
8
|
+
const ToggleGroupContext = React.createContext<
|
|
9
|
+
VariantProps<typeof toggleVariants>
|
|
10
|
+
>({
|
|
11
|
+
size: "default",
|
|
12
|
+
variant: "default",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const ToggleGroup = React.forwardRef<
|
|
16
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
17
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
|
|
18
|
+
VariantProps<typeof toggleVariants>
|
|
19
|
+
>(({ className, variant, size, children, ...props }, ref) => (
|
|
20
|
+
<ToggleGroupPrimitive.Root
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={cn("flex items-center justify-center gap-1", className)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
26
|
+
{children}
|
|
27
|
+
</ToggleGroupContext.Provider>
|
|
28
|
+
</ToggleGroupPrimitive.Root>
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
32
|
+
|
|
33
|
+
const ToggleGroupItem = React.forwardRef<
|
|
34
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
35
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
|
|
36
|
+
VariantProps<typeof toggleVariants>
|
|
37
|
+
>(({ className, children, variant, size, ...props }, ref) => {
|
|
38
|
+
const context = React.useContext(ToggleGroupContext);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<ToggleGroupPrimitive.Item
|
|
42
|
+
ref={ref}
|
|
43
|
+
className={cn(
|
|
44
|
+
toggleVariants({
|
|
45
|
+
variant: context.variant || variant,
|
|
46
|
+
size: context.size || size,
|
|
47
|
+
}),
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
</ToggleGroupPrimitive.Item>
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
58
|
+
|
|
59
|
+
export { ToggleGroup, ToggleGroupItem };
|