@kinetixui/ui 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.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +1176 -0
  3. package/dist/index.js +3939 -0
  4. package/package.json +106 -0
  5. package/src/components/accordion.tsx +52 -0
  6. package/src/components/alert-dialog.tsx +115 -0
  7. package/src/components/alert.tsx +47 -0
  8. package/src/components/aspect-ratio.tsx +7 -0
  9. package/src/components/audio-player.tsx +150 -0
  10. package/src/components/avatar.tsx +76 -0
  11. package/src/components/badge.tsx +40 -0
  12. package/src/components/breadcrumb.tsx +77 -0
  13. package/src/components/button.tsx +119 -0
  14. package/src/components/calendar.tsx +60 -0
  15. package/src/components/card.tsx +50 -0
  16. package/src/components/carousel.tsx +181 -0
  17. package/src/components/chart.tsx +177 -0
  18. package/src/components/checkbox.tsx +38 -0
  19. package/src/components/circular-progress.tsx +67 -0
  20. package/src/components/code-block.tsx +96 -0
  21. package/src/components/collapsible.tsx +9 -0
  22. package/src/components/command.tsx +123 -0
  23. package/src/components/context-menu.tsx +132 -0
  24. package/src/components/data-table.tsx +92 -0
  25. package/src/components/date-picker.tsx +68 -0
  26. package/src/components/dialog.tsx +101 -0
  27. package/src/components/drawer.tsx +82 -0
  28. package/src/components/dropdown-menu.tsx +132 -0
  29. package/src/components/fab.tsx +58 -0
  30. package/src/components/field.tsx +128 -0
  31. package/src/components/file-upload.tsx +183 -0
  32. package/src/components/footer.tsx +62 -0
  33. package/src/components/form.tsx +130 -0
  34. package/src/components/hover-card.tsx +28 -0
  35. package/src/components/image.tsx +87 -0
  36. package/src/components/inform.tsx +82 -0
  37. package/src/components/input-group.tsx +96 -0
  38. package/src/components/input-otp.tsx +63 -0
  39. package/src/components/input.tsx +72 -0
  40. package/src/components/label.tsx +20 -0
  41. package/src/components/list.tsx +69 -0
  42. package/src/components/menubar.tsx +168 -0
  43. package/src/components/metric.tsx +51 -0
  44. package/src/components/modal.tsx +126 -0
  45. package/src/components/navigation-bar.tsx +49 -0
  46. package/src/components/navigation-menu.tsx +117 -0
  47. package/src/components/number-input.tsx +86 -0
  48. package/src/components/pagination.tsx +77 -0
  49. package/src/components/password-input.tsx +36 -0
  50. package/src/components/popover.tsx +32 -0
  51. package/src/components/progress.tsx +24 -0
  52. package/src/components/quote.tsx +34 -0
  53. package/src/components/radio-group.tsx +44 -0
  54. package/src/components/rating.tsx +88 -0
  55. package/src/components/resizable.tsx +40 -0
  56. package/src/components/scroll-area.tsx +39 -0
  57. package/src/components/select.tsx +124 -0
  58. package/src/components/separator.tsx +25 -0
  59. package/src/components/sheet.tsx +104 -0
  60. package/src/components/sidebar.tsx +390 -0
  61. package/src/components/skeleton.tsx +9 -0
  62. package/src/components/slider.tsx +24 -0
  63. package/src/components/sonner.tsx +30 -0
  64. package/src/components/spinner.tsx +43 -0
  65. package/src/components/stepper.tsx +75 -0
  66. package/src/components/switch.tsx +37 -0
  67. package/src/components/tab-bar.tsx +58 -0
  68. package/src/components/table-of-contents.tsx +46 -0
  69. package/src/components/table.tsx +70 -0
  70. package/src/components/tabs.tsx +54 -0
  71. package/src/components/tag.tsx +56 -0
  72. package/src/components/textarea.tsx +56 -0
  73. package/src/components/toggle-group.tsx +41 -0
  74. package/src/components/toggle.tsx +34 -0
  75. package/src/components/tooltip.tsx +31 -0
  76. package/src/index.ts +305 -0
  77. package/src/lib/utils.ts +7 -0
  78. package/src/stories/Button.stories.tsx +155 -0
  79. package/src/stories/Input.stories.tsx +80 -0
  80. package/src/stories/Textarea.stories.tsx +69 -0
  81. package/tailwind.config.ts +107 -0
@@ -0,0 +1,62 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cn } from "../lib/utils";
5
+
6
+ /**
7
+ * Footer — a page footer shell: columns of nav links plus a bottom bar
8
+ * (copyright, legal, social). Compose `FooterColumn` / `FooterLink` /
9
+ * `FooterBottom` inside it.
10
+ */
11
+ const Footer = React.forwardRef<HTMLElement, React.HTMLAttributes<HTMLElement>>(
12
+ ({ className, children, ...props }, ref) => (
13
+ <footer ref={ref} className={cn("w-full border-t border-border bg-background px-6 py-10 font-sans", className)} {...props}>
14
+ {children}
15
+ </footer>
16
+ ),
17
+ );
18
+ Footer.displayName = "Footer";
19
+
20
+ export interface FooterColumnProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
21
+ title: React.ReactNode;
22
+ }
23
+
24
+ const FooterColumn = React.forwardRef<HTMLDivElement, FooterColumnProps>(
25
+ ({ className, title, children, ...props }, ref) => (
26
+ <div ref={ref} className={cn("flex flex-col gap-3", className)} {...props}>
27
+ <p className="text-label-md font-medium text-foreground">{title}</p>
28
+ <div className="flex flex-col gap-2">{children}</div>
29
+ </div>
30
+ ),
31
+ );
32
+ FooterColumn.displayName = "FooterColumn";
33
+
34
+ const FooterLink = React.forwardRef<HTMLAnchorElement, React.AnchorHTMLAttributes<HTMLAnchorElement>>(
35
+ ({ className, ...props }, ref) => (
36
+ <a
37
+ ref={ref}
38
+ className={cn(
39
+ "text-body-sm text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground",
40
+ className,
41
+ )}
42
+ {...props}
43
+ />
44
+ ),
45
+ );
46
+ FooterLink.displayName = "FooterLink";
47
+
48
+ const FooterBottom = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
49
+ ({ className, ...props }, ref) => (
50
+ <div
51
+ ref={ref}
52
+ className={cn(
53
+ "mt-8 flex flex-wrap items-center justify-between gap-3 border-t border-border pt-6 text-body-sm text-muted-foreground",
54
+ className,
55
+ )}
56
+ {...props}
57
+ />
58
+ ),
59
+ );
60
+ FooterBottom.displayName = "FooterBottom";
61
+
62
+ export { Footer, FooterColumn, FooterLink, FooterBottom };
@@ -0,0 +1,130 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as LabelPrimitive from "@radix-ui/react-label";
5
+ import { Slot } from "@radix-ui/react-slot";
6
+ import {
7
+ Controller,
8
+ FormProvider,
9
+ useFormContext,
10
+ useFormState,
11
+ type ControllerProps,
12
+ type FieldPath,
13
+ type FieldValues,
14
+ } from "react-hook-form";
15
+ import { cn } from "../lib/utils";
16
+ import { Label } from "./label";
17
+
18
+ const Form = FormProvider;
19
+
20
+ type FormFieldContextValue<
21
+ TFieldValues extends FieldValues = FieldValues,
22
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
23
+ > = { name: TName };
24
+
25
+ const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);
26
+
27
+ const FormField = <
28
+ TFieldValues extends FieldValues = FieldValues,
29
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
30
+ >({
31
+ ...props
32
+ }: ControllerProps<TFieldValues, TName>) => (
33
+ <FormFieldContext.Provider value={{ name: props.name }}>
34
+ <Controller {...props} />
35
+ </FormFieldContext.Provider>
36
+ );
37
+
38
+ const useFormField = () => {
39
+ const fieldContext = React.useContext(FormFieldContext);
40
+ const itemContext = React.useContext(FormItemContext);
41
+ const { getFieldState } = useFormContext();
42
+ const formState = useFormState({ name: fieldContext.name });
43
+ const fieldState = getFieldState(fieldContext.name, formState);
44
+
45
+ if (!fieldContext) throw new Error("useFormField should be used within <FormField>");
46
+
47
+ const { id } = itemContext;
48
+ return {
49
+ id,
50
+ name: fieldContext.name,
51
+ formItemId: `${id}-form-item`,
52
+ formDescriptionId: `${id}-form-item-description`,
53
+ formMessageId: `${id}-form-item-message`,
54
+ ...fieldState,
55
+ };
56
+ };
57
+
58
+ type FormItemContextValue = { id: string };
59
+ const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
60
+
61
+ const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
62
+ ({ className, ...props }, ref) => {
63
+ const id = React.useId();
64
+ return (
65
+ <FormItemContext.Provider value={{ id }}>
66
+ <div ref={ref} className={cn("grid gap-2", className)} {...props} />
67
+ </FormItemContext.Provider>
68
+ );
69
+ },
70
+ );
71
+ FormItem.displayName = "FormItem";
72
+
73
+ const FormLabel = React.forwardRef<
74
+ React.ElementRef<typeof LabelPrimitive.Root>,
75
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
76
+ >(({ className, ...props }, ref) => {
77
+ const { error, formItemId } = useFormField();
78
+ return <Label ref={ref} className={cn(error && "text-destructive", className)} htmlFor={formItemId} {...props} />;
79
+ });
80
+ FormLabel.displayName = "FormLabel";
81
+
82
+ const FormControl = React.forwardRef<
83
+ React.ElementRef<typeof Slot>,
84
+ React.ComponentPropsWithoutRef<typeof Slot>
85
+ >(({ ...props }, ref) => {
86
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
87
+ return (
88
+ <Slot
89
+ ref={ref}
90
+ id={formItemId}
91
+ aria-describedby={!error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`}
92
+ aria-invalid={!!error}
93
+ {...props}
94
+ />
95
+ );
96
+ });
97
+ FormControl.displayName = "FormControl";
98
+
99
+ const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
100
+ ({ className, ...props }, ref) => {
101
+ const { formDescriptionId } = useFormField();
102
+ return <p ref={ref} id={formDescriptionId} className={cn("text-sm text-muted-foreground", className)} {...props} />;
103
+ },
104
+ );
105
+ FormDescription.displayName = "FormDescription";
106
+
107
+ const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
108
+ ({ className, children, ...props }, ref) => {
109
+ const { error, formMessageId } = useFormField();
110
+ const body = error ? String(error?.message ?? "") : children;
111
+ if (!body) return null;
112
+ return (
113
+ <p ref={ref} id={formMessageId} className={cn("text-sm font-medium text-destructive", className)} {...props}>
114
+ {body}
115
+ </p>
116
+ );
117
+ },
118
+ );
119
+ FormMessage.displayName = "FormMessage";
120
+
121
+ export {
122
+ useFormField,
123
+ Form,
124
+ FormItem,
125
+ FormLabel,
126
+ FormControl,
127
+ FormDescription,
128
+ FormMessage,
129
+ FormField,
130
+ };
@@ -0,0 +1,28 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
5
+ import { cn } from "../lib/utils";
6
+
7
+ const HoverCard = HoverCardPrimitive.Root;
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 font-sans",
20
+ "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",
21
+ className,
22
+ )}
23
+ {...props}
24
+ />
25
+ ));
26
+ HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
27
+
28
+ export { HoverCard, HoverCardTrigger, HoverCardContent };
@@ -0,0 +1,87 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { ImageOff } from "lucide-react";
5
+ import { cn } from "../lib/utils";
6
+
7
+ /**
8
+ * Image — a ratio-locked image with a muted placeholder while loading and a
9
+ * fallback on error (presets 1:1 / 3:2 / 4:3 / 3:4 / 3:1 / 16:9). Pass
10
+ * `ratio` as a preset string or a number (w / h).
11
+ */
12
+ const RATIOS: Record<string, number> = {
13
+ "1:1": 1,
14
+ "3:2": 3 / 2,
15
+ "4:3": 4 / 3,
16
+ "3:4": 3 / 4,
17
+ "3:1": 3,
18
+ "16:9": 16 / 9,
19
+ };
20
+
21
+ export interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
22
+ ratio?: keyof typeof RATIOS | number;
23
+ rounded?: boolean;
24
+ fallback?: React.ReactNode;
25
+ }
26
+
27
+ const Image = React.forwardRef<HTMLImageElement, ImageProps>(
28
+ ({ ratio = "1:1", rounded = true, fallback, className, alt = "", onLoad, onError, ...props }, forwardedRef) => {
29
+ const [status, setStatus] = React.useState<"loading" | "loaded" | "error">("loading");
30
+ const innerRef = React.useRef<HTMLImageElement | null>(null);
31
+ const setRef = React.useCallback(
32
+ (node: HTMLImageElement | null) => {
33
+ innerRef.current = node;
34
+ if (typeof forwardedRef === "function") forwardedRef(node);
35
+ else if (forwardedRef) (forwardedRef as React.MutableRefObject<HTMLImageElement | null>).current = node;
36
+ },
37
+ [forwardedRef],
38
+ );
39
+ const r = typeof ratio === "number" ? ratio : (RATIOS[ratio] ?? 1);
40
+
41
+ // A cached image can finish loading before React attaches onLoad (notably
42
+ // after hydration of a statically-rendered page) — reconcile on mount.
43
+ React.useEffect(() => {
44
+ const img = innerRef.current;
45
+ if (!img) return;
46
+ if (img.complete) setStatus(img.naturalWidth > 0 ? "loaded" : "error");
47
+ }, [props.src]);
48
+
49
+ return (
50
+ <div
51
+ className={cn(
52
+ "relative w-full overflow-hidden bg-muted",
53
+ rounded && "rounded-md",
54
+ className,
55
+ )}
56
+ style={{ aspectRatio: r }}
57
+ >
58
+ {status === "error" ? (
59
+ <div className="absolute inset-0 grid place-items-center text-muted-foreground">
60
+ {fallback ?? <ImageOff className="size-6" />}
61
+ </div>
62
+ ) : (
63
+ <img
64
+ ref={setRef}
65
+ alt={alt}
66
+ className={cn(
67
+ "size-full object-cover transition-opacity duration-300",
68
+ status === "loaded" ? "opacity-100" : "opacity-0",
69
+ )}
70
+ onLoad={(e) => {
71
+ setStatus("loaded");
72
+ onLoad?.(e);
73
+ }}
74
+ onError={(e) => {
75
+ setStatus("error");
76
+ onError?.(e);
77
+ }}
78
+ {...props}
79
+ />
80
+ )}
81
+ </div>
82
+ );
83
+ },
84
+ );
85
+ Image.displayName = "Image";
86
+
87
+ export { Image };
@@ -0,0 +1,82 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import { CircleAlert, CircleCheck, Info, TriangleAlert, X } from "lucide-react";
6
+ import { cn } from "../lib/utils";
7
+
8
+ /**
9
+ * Inform — a persistent, dismissible, intent-tinted inline notice with an
10
+ * optional action (information / warning / success / error / action).
11
+ * Distinct from `Alert` (border-only, static): Inform is filled, closable,
12
+ * and can carry a CTA.
13
+ */
14
+ const informVariants = cva(
15
+ "flex items-start gap-2.5 rounded-md p-3 text-body-sm font-sans [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0",
16
+ {
17
+ variants: {
18
+ variant: {
19
+ information: "bg-info/10 text-info",
20
+ warning: "bg-warning/15 text-warning",
21
+ success: "bg-success/15 text-success",
22
+ error: "bg-destructive/10 text-destructive",
23
+ action: "bg-foreground text-background",
24
+ },
25
+ },
26
+ defaultVariants: { variant: "information" },
27
+ },
28
+ );
29
+
30
+ const ICON = {
31
+ information: Info,
32
+ warning: TriangleAlert,
33
+ success: CircleCheck,
34
+ error: CircleAlert,
35
+ action: Info,
36
+ } as const;
37
+
38
+ export interface InformProps
39
+ extends React.HTMLAttributes<HTMLDivElement>,
40
+ VariantProps<typeof informVariants> {
41
+ hideIcon?: boolean;
42
+ onDismiss?: () => void;
43
+ /** optional CTA rendered below the message */
44
+ action?: { label: React.ReactNode; onClick?: () => void; icon?: React.ReactNode };
45
+ }
46
+
47
+ const Inform = React.forwardRef<HTMLDivElement, InformProps>(
48
+ ({ className, variant = "information", hideIcon, onDismiss, action, children, ...props }, ref) => {
49
+ const Icon = ICON[variant ?? "information"];
50
+ return (
51
+ <div ref={ref} role="status" className={cn(informVariants({ variant }), className)} {...props}>
52
+ {!hideIcon && <Icon />}
53
+ <div className="min-w-0 flex-1">
54
+ <p className="[&:not(:only-child)]:mb-2">{children}</p>
55
+ {action && (
56
+ <button
57
+ type="button"
58
+ onClick={action.onClick}
59
+ className="inline-flex items-center gap-1.5 text-label-md font-medium underline-offset-2 outline-none hover:underline focus-visible:underline [&>svg]:size-4"
60
+ >
61
+ {action.icon}
62
+ {action.label}
63
+ </button>
64
+ )}
65
+ </div>
66
+ {onDismiss && (
67
+ <button
68
+ type="button"
69
+ onClick={onDismiss}
70
+ aria-label="Dismiss"
71
+ className="-m-0.5 shrink-0 rounded-[2px] p-0.5 opacity-70 outline-none transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-current"
72
+ >
73
+ <X className="size-3.5" />
74
+ </button>
75
+ )}
76
+ </div>
77
+ );
78
+ },
79
+ );
80
+ Inform.displayName = "Inform";
81
+
82
+ export { Inform, informVariants };
@@ -0,0 +1,96 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import { cn } from "../lib/utils";
6
+
7
+ /**
8
+ * InputGroup — a single bordered shell that hosts an input plus fixed add-ons
9
+ * (icon, text, dropdown, button) on either side. Matches the KinetixUI design
10
+ * source's "Fixed Add-on" pattern. Border / focus glow / invalid state apply to
11
+ * the whole group.
12
+ *
13
+ * <InputGroup>
14
+ * <InputGroupText>https://</InputGroupText>
15
+ * <InputGroupInput placeholder="kinetixui.com" />
16
+ * </InputGroup>
17
+ */
18
+ const InputGroup = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
19
+ ({ className, ...props }, ref) => (
20
+ <div
21
+ ref={ref}
22
+ data-slot="input-group"
23
+ className={cn(
24
+ "flex w-full items-center overflow-hidden rounded-sm border border-input bg-background font-sans transition-colors",
25
+ "focus-within:border-primary focus-within:shadow-focus",
26
+ "has-[[aria-invalid=true]]:border-destructive has-[[aria-invalid=true]]:focus-within:shadow-focus-destructive",
27
+ "has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
28
+ className,
29
+ )}
30
+ {...props}
31
+ />
32
+ ),
33
+ );
34
+ InputGroup.displayName = "InputGroup";
35
+
36
+ const InputGroupInput = React.forwardRef<
37
+ HTMLInputElement,
38
+ Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">
39
+ >(({ className, type = "text", ...props }, ref) => (
40
+ <input
41
+ ref={ref}
42
+ type={type}
43
+ data-slot="input-group-input"
44
+ className={cn(
45
+ "min-w-0 flex-1 bg-transparent px-3 py-3 text-body-md text-foreground",
46
+ "placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed",
47
+ className,
48
+ )}
49
+ {...props}
50
+ />
51
+ ));
52
+ InputGroupInput.displayName = "InputGroupInput";
53
+
54
+ const addonVariants = cva("flex shrink-0 items-center gap-2 text-muted-foreground [&_svg]:size-4 [&_svg]:shrink-0", {
55
+ variants: { align: { start: "pl-3", end: "pr-3" } },
56
+ defaultVariants: { align: "start" },
57
+ });
58
+
59
+ const InputGroupAddon = React.forwardRef<
60
+ HTMLDivElement,
61
+ React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof addonVariants>
62
+ >(({ className, align, ...props }, ref) => (
63
+ <div ref={ref} data-slot="input-group-addon" className={cn(addonVariants({ align }), className)} {...props} />
64
+ ));
65
+ InputGroupAddon.displayName = "InputGroupAddon";
66
+
67
+ const InputGroupText = React.forwardRef<HTMLSpanElement, React.HTMLAttributes<HTMLSpanElement>>(
68
+ ({ className, ...props }, ref) => (
69
+ <span
70
+ ref={ref}
71
+ className={cn("select-none whitespace-nowrap px-3 text-body-md text-muted-foreground", className)}
72
+ {...props}
73
+ />
74
+ ),
75
+ );
76
+ InputGroupText.displayName = "InputGroupText";
77
+
78
+ const InputGroupButton = React.forwardRef<
79
+ HTMLButtonElement,
80
+ React.ButtonHTMLAttributes<HTMLButtonElement>
81
+ >(({ className, type = "button", ...props }, ref) => (
82
+ <button
83
+ ref={ref}
84
+ type={type}
85
+ className={cn(
86
+ "flex h-full shrink-0 items-center gap-1.5 self-stretch border-l border-input bg-muted px-3 text-label-md text-foreground",
87
+ "outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:cursor-not-allowed disabled:opacity-50",
88
+ "[&_svg]:size-4 [&_svg]:shrink-0",
89
+ className,
90
+ )}
91
+ {...props}
92
+ />
93
+ ));
94
+ InputGroupButton.displayName = "InputGroupButton";
95
+
96
+ export { InputGroup, InputGroupInput, InputGroupAddon, InputGroupText, InputGroupButton };
@@ -0,0 +1,63 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { OTPInput, OTPInputContext } from "input-otp";
5
+ import { Minus } from "lucide-react";
6
+ import { cn } from "../lib/utils";
7
+
8
+ const InputOTP = React.forwardRef<
9
+ React.ElementRef<typeof OTPInput>,
10
+ React.ComponentPropsWithoutRef<typeof OTPInput>
11
+ >(({ className, containerClassName, ...props }, ref) => (
12
+ <OTPInput
13
+ ref={ref}
14
+ containerClassName={cn("flex items-center gap-2 has-[:disabled]:opacity-50", containerClassName)}
15
+ className={cn("disabled:cursor-not-allowed", className)}
16
+ {...props}
17
+ />
18
+ ));
19
+ InputOTP.displayName = "InputOTP";
20
+
21
+ const InputOTPGroup = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(
22
+ ({ className, ...props }, ref) => <div ref={ref} className={cn("flex items-center", className)} {...props} />,
23
+ );
24
+ InputOTPGroup.displayName = "InputOTPGroup";
25
+
26
+ const InputOTPSlot = React.forwardRef<
27
+ React.ElementRef<"div">,
28
+ React.ComponentPropsWithoutRef<"div"> & { index: number }
29
+ >(({ index, className, ...props }, ref) => {
30
+ const inputOTPContext = React.useContext(OTPInputContext);
31
+ const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index] ?? {};
32
+
33
+ return (
34
+ <div
35
+ ref={ref}
36
+ className={cn(
37
+ "relative flex size-9 items-center justify-center border-y border-r border-input text-sm shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",
38
+ isActive && "z-10 ring-1 ring-ring",
39
+ className,
40
+ )}
41
+ {...props}
42
+ >
43
+ {char}
44
+ {hasFakeCaret && (
45
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
46
+ <div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
47
+ </div>
48
+ )}
49
+ </div>
50
+ );
51
+ });
52
+ InputOTPSlot.displayName = "InputOTPSlot";
53
+
54
+ const InputOTPSeparator = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(
55
+ ({ ...props }, ref) => (
56
+ <div ref={ref} role="separator" {...props}>
57
+ <Minus className="size-4" />
58
+ </div>
59
+ ),
60
+ );
61
+ InputOTPSeparator.displayName = "InputOTPSeparator";
62
+
63
+ export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
@@ -0,0 +1,72 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import { cn } from "../lib/utils";
6
+
7
+ /**
8
+ * Input — generated from Figma "KinetixUI" › UI Components ›
9
+ * 01. Form Inputs › Input (node 54855:13836).
10
+ *
11
+ * Figma component property: state = Default | Focus | Error | Disabled.
12
+ * Focus is the CSS `:focus-visible` pseudo-class and Disabled is the native
13
+ * attribute; the `state` prop force-pins one for docs / snapshots, and
14
+ * `state="Error"` sets `aria-invalid`. Focus uses the `--shadow-focus` token.
15
+ *
16
+ * Figma's component bundles a label + helper text; those live in the `Field`
17
+ * composition (their colour tracks the control's state). This is the bare
18
+ * control. Tokens: border `--input`, focus `--ring`, error `--destructive`,
19
+ * radius `--radius-sm` (Figma `input` = 4px), padding `--spacing-3`,
20
+ * text = Body Medium (14 / 20, +0.25).
21
+ */
22
+ const inputVariants = cva(
23
+ [
24
+ "flex w-full border border-input bg-background px-3 py-3",
25
+ "font-sans text-[14px] leading-5 tracking-[0.25px] text-foreground",
26
+ "placeholder:text-muted-foreground",
27
+ "outline-none transition-colors",
28
+ "focus-visible:border-primary focus-visible:shadow-focus",
29
+ "disabled:cursor-not-allowed disabled:opacity-50",
30
+ "aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-visible:border-destructive aria-[invalid=true]:focus-visible:shadow-focus-destructive",
31
+ ],
32
+ {
33
+ variants: {
34
+ state: {
35
+ Default: "",
36
+ Focus: "border-primary shadow-focus",
37
+ Error: "border-destructive",
38
+ Disabled: "opacity-50 pointer-events-none",
39
+ },
40
+ /** corner style — matches the design source's Corners property */
41
+ corners: {
42
+ sharp: "rounded-none",
43
+ default: "rounded-sm",
44
+ rounded: "rounded-md",
45
+ pill: "rounded-full px-4",
46
+ },
47
+ },
48
+ defaultVariants: { state: "Default", corners: "default" },
49
+ },
50
+ );
51
+
52
+ export interface InputProps
53
+ extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">,
54
+ VariantProps<typeof inputVariants> {}
55
+
56
+ const Input = React.forwardRef<HTMLInputElement, InputProps>(
57
+ ({ className, state, corners, type = "text", disabled, "aria-invalid": ariaInvalid, ...props }, ref) => (
58
+ <input
59
+ ref={ref}
60
+ type={type}
61
+ data-slot="input"
62
+ data-state={state ? state.toLowerCase() : undefined}
63
+ aria-invalid={ariaInvalid ?? (state === "Error" || undefined)}
64
+ disabled={disabled || state === "Disabled"}
65
+ className={cn(inputVariants({ state, corners }), className)}
66
+ {...props}
67
+ />
68
+ ),
69
+ );
70
+ Input.displayName = "Input";
71
+
72
+ export { Input, inputVariants };
@@ -0,0 +1,20 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as LabelPrimitive from "@radix-ui/react-label";
5
+ import { cva, type VariantProps } from "class-variance-authority";
6
+ import { cn } from "../lib/utils";
7
+
8
+ const labelVariants = cva(
9
+ "text-sm font-medium leading-none font-sans peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
10
+ );
11
+
12
+ const Label = React.forwardRef<
13
+ React.ElementRef<typeof LabelPrimitive.Root>,
14
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
15
+ >(({ className, ...props }, ref) => (
16
+ <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
17
+ ));
18
+ Label.displayName = LabelPrimitive.Root.displayName;
19
+
20
+ export { Label };