cooterlabs 1.0.2 → 2.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.
@@ -0,0 +1,113 @@
1
+ import * as React from "react"
2
+ import * as SelectPrimitive from "@radix-ui/react-select"
3
+ import { Check, ChevronDown } from "lucide-react"
4
+ import { cn } from "../../lib/utils"
5
+ import {
6
+ inputVariants,
7
+ inputSizes,
8
+ inputStatuses,
9
+ statusTextColors,
10
+ } from "./input"
11
+
12
+ const Select = SelectPrimitive.Root
13
+ const SelectGroup = SelectPrimitive.Group
14
+ const SelectValue = SelectPrimitive.Value
15
+
16
+ export interface SelectTriggerProps
17
+ extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> {
18
+ variant?: keyof typeof inputVariants
19
+ size?: keyof typeof inputSizes
20
+ status?: keyof typeof statusTextColors
21
+ }
22
+
23
+ const SelectTrigger = React.forwardRef<
24
+ React.ElementRef<typeof SelectPrimitive.Trigger>,
25
+ SelectTriggerProps
26
+ >(
27
+ (
28
+ {
29
+ className,
30
+ variant = "outline",
31
+ size = "large",
32
+ status,
33
+ children,
34
+ ...props
35
+ },
36
+ ref
37
+ ) => (
38
+ <SelectPrimitive.Trigger
39
+ ref={ref}
40
+ className={cn(
41
+ "flex w-full items-center justify-between gap-2 rounded-xs border-[1.5px] text-foreground transition-colors focus-visible:outline-none focus-visible:shadow-focus disabled:pointer-events-none disabled:border-grey-200 disabled:bg-secondary disabled:text-grey-400 data-[placeholder]:text-muted-foreground [&>span]:truncate",
42
+ inputVariants[variant],
43
+ inputSizes[size],
44
+ status && inputStatuses[variant][status],
45
+ className
46
+ )}
47
+ {...props}
48
+ >
49
+ {children}
50
+ <SelectPrimitive.Icon asChild>
51
+ <ChevronDown
52
+ className={cn(
53
+ "size-4 shrink-0 text-muted-foreground",
54
+ status && statusTextColors[status]
55
+ )}
56
+ />
57
+ </SelectPrimitive.Icon>
58
+ </SelectPrimitive.Trigger>
59
+ )
60
+ )
61
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
62
+
63
+ const SelectContent = React.forwardRef<
64
+ React.ElementRef<typeof SelectPrimitive.Content>,
65
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
66
+ >(({ className, children, position = "popper", sideOffset = 4, ...props }, ref) => (
67
+ <SelectPrimitive.Portal>
68
+ <SelectPrimitive.Content
69
+ ref={ref}
70
+ position={position}
71
+ sideOffset={sideOffset}
72
+ className={cn(
73
+ "z-50 max-h-72 min-w-[var(--radix-select-trigger-width)] overflow-y-auto rounded-xs border border-grey-100 bg-popover text-popover-foreground shadow-400",
74
+ className
75
+ )}
76
+ {...props}
77
+ >
78
+ <SelectPrimitive.Viewport className="p-1">
79
+ {children}
80
+ </SelectPrimitive.Viewport>
81
+ </SelectPrimitive.Content>
82
+ </SelectPrimitive.Portal>
83
+ ))
84
+ SelectContent.displayName = SelectPrimitive.Content.displayName
85
+
86
+ const SelectItem = React.forwardRef<
87
+ React.ElementRef<typeof SelectPrimitive.Item>,
88
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
89
+ >(({ className, children, ...props }, ref) => (
90
+ <SelectPrimitive.Item
91
+ ref={ref}
92
+ className={cn(
93
+ "relative flex h-10 cursor-default select-none items-center gap-2 rounded-xxs px-3 pr-9 text-b3 outline-none transition-colors data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
94
+ className
95
+ )}
96
+ {...props}
97
+ >
98
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
99
+ <SelectPrimitive.ItemIndicator className="absolute right-3">
100
+ <Check />
101
+ </SelectPrimitive.ItemIndicator>
102
+ </SelectPrimitive.Item>
103
+ ))
104
+ SelectItem.displayName = SelectPrimitive.Item.displayName
105
+
106
+ export {
107
+ Select,
108
+ SelectGroup,
109
+ SelectValue,
110
+ SelectTrigger,
111
+ SelectContent,
112
+ SelectItem,
113
+ }
@@ -0,0 +1,88 @@
1
+ import * as React from "react"
2
+ import { Check } from "lucide-react"
3
+ import { cn } from "../../lib/utils"
4
+
5
+ const stepperCircleStates = {
6
+ completed: "bg-primary text-primary-foreground",
7
+ current: "border border-primary bg-background text-primary",
8
+ upcoming: "border border-grey-200 bg-background text-grey-400",
9
+ }
10
+
11
+ const stepperLabelStates = {
12
+ completed: "text-foreground",
13
+ current: "text-primary",
14
+ upcoming: "text-grey-400",
15
+ }
16
+
17
+ const Stepper = React.forwardRef<
18
+ HTMLOListElement,
19
+ React.OlHTMLAttributes<HTMLOListElement>
20
+ >(({ className, ...props }, ref) => (
21
+ <ol
22
+ ref={ref}
23
+ className={cn("flex w-full items-center", className)}
24
+ {...props}
25
+ />
26
+ ))
27
+ Stepper.displayName = "Stepper"
28
+
29
+ export interface StepperItemProps
30
+ extends React.LiHTMLAttributes<HTMLLIElement> {
31
+ index: number
32
+ state?: keyof typeof stepperCircleStates
33
+ }
34
+
35
+ const StepperItem = React.forwardRef<HTMLLIElement, StepperItemProps>(
36
+ ({ className, index, state = "upcoming", children, ...props }, ref) => (
37
+ <li
38
+ ref={ref}
39
+ aria-current={state === "current" ? "step" : undefined}
40
+ className={cn("flex items-center gap-2", className)}
41
+ {...props}
42
+ >
43
+ <span
44
+ className={cn(
45
+ "flex size-8 shrink-0 items-center justify-center rounded-full text-c2 transition-colors",
46
+ stepperCircleStates[state]
47
+ )}
48
+ >
49
+ {state === "completed" ? (
50
+ <Check className="size-4" aria-hidden="true" />
51
+ ) : (
52
+ index
53
+ )}
54
+ </span>
55
+ {children != null && (
56
+ <span className={cn("text-c1", stepperLabelStates[state])}>
57
+ {children}
58
+ </span>
59
+ )}
60
+ </li>
61
+ )
62
+ )
63
+ StepperItem.displayName = "StepperItem"
64
+
65
+ export interface StepperSeparatorProps
66
+ extends React.HTMLAttributes<HTMLLIElement> {
67
+ completed?: boolean
68
+ }
69
+
70
+ const StepperSeparator = ({
71
+ className,
72
+ completed = false,
73
+ ...props
74
+ }: StepperSeparatorProps) => (
75
+ <li
76
+ role="presentation"
77
+ aria-hidden="true"
78
+ className={cn(
79
+ "mx-2 h-px flex-1",
80
+ completed ? "bg-primary" : "bg-grey-200",
81
+ className
82
+ )}
83
+ {...props}
84
+ />
85
+ )
86
+ StepperSeparator.displayName = "StepperSeparator"
87
+
88
+ export { Stepper, StepperItem, StepperSeparator }
@@ -0,0 +1,52 @@
1
+ import * as React from "react"
2
+ import * as TabsPrimitive from "@radix-ui/react-tabs"
3
+ import { cn } from "../../lib/utils"
4
+
5
+ const Tabs = TabsPrimitive.Root
6
+
7
+ const TabsList = React.forwardRef<
8
+ React.ComponentRef<typeof TabsPrimitive.List>,
9
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
10
+ >(({ className, ...props }, ref) => (
11
+ <TabsPrimitive.List
12
+ ref={ref}
13
+ className={cn(
14
+ "inline-flex items-center justify-center gap-1 rounded-xs bg-secondary p-1",
15
+ className
16
+ )}
17
+ {...props}
18
+ />
19
+ ))
20
+ TabsList.displayName = TabsPrimitive.List.displayName
21
+
22
+ const TabsTrigger = React.forwardRef<
23
+ React.ComponentRef<typeof TabsPrimitive.Trigger>,
24
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
25
+ >(({ className, ...props }, ref) => (
26
+ <TabsPrimitive.Trigger
27
+ ref={ref}
28
+ className={cn(
29
+ "inline-flex h-10 items-center justify-center whitespace-nowrap rounded-xxs px-4 text-b4 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:shadow-focus disabled:pointer-events-none disabled:text-grey-400 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-100",
30
+ className
31
+ )}
32
+ {...props}
33
+ />
34
+ ))
35
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
36
+
37
+ const TabsContent = React.forwardRef<
38
+ React.ComponentRef<typeof TabsPrimitive.Content>,
39
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
40
+ >(({ className, ...props }, ref) => (
41
+ <TabsPrimitive.Content
42
+ ref={ref}
43
+ className={cn(
44
+ "mt-2 focus-visible:outline-none focus-visible:shadow-focus",
45
+ className
46
+ )}
47
+ {...props}
48
+ />
49
+ ))
50
+ TabsContent.displayName = TabsPrimitive.Content.displayName
51
+
52
+ export { Tabs, TabsList, TabsTrigger, TabsContent }
@@ -1,10 +1,5 @@
1
1
  import * as React from "react"
2
- import { clsx, type ClassValue } from "clsx"
3
- import { twMerge } from "tailwind-merge"
4
-
5
- export function cn(...inputs: ClassValue[]) {
6
- return twMerge(clsx(inputs))
7
- }
2
+ import { cn } from "../../lib/utils"
8
3
 
9
4
  export interface TextareaProps
10
5
  extends React.TextareaHTMLAttributes<HTMLTextAreaElement> { }
@@ -14,7 +9,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
14
9
  return (
15
10
  <textarea
16
11
  className={cn(
17
- "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm 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",
12
+ "flex min-h-24 w-full rounded-xs border border-input bg-background px-4 py-3 text-b1 text-foreground transition-colors placeholder:text-muted-foreground hover:border-grey-300 focus-visible:outline-none focus-visible:shadow-focus aria-invalid:border-error disabled:pointer-events-none disabled:border-grey-200 disabled:bg-secondary disabled:text-grey-400",
18
13
  className
19
14
  )}
20
15
  ref={ref}
@@ -0,0 +1,22 @@
1
+ import * as React from "react"
2
+ import * as SwitchPrimitive from "@radix-ui/react-switch"
3
+ import { cn } from "../../lib/utils"
4
+
5
+ const Toggle = React.forwardRef<
6
+ React.ElementRef<typeof SwitchPrimitive.Root>,
7
+ React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>
8
+ >(({ className, ...props }, ref) => (
9
+ <SwitchPrimitive.Root
10
+ ref={ref}
11
+ className={cn(
12
+ "peer inline-flex h-6 w-11 shrink-0 items-center rounded-full bg-grey-200 px-0.5 transition-colors hover:bg-grey-300 focus-visible:outline-none focus-visible:shadow-focus disabled:pointer-events-none disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:hover:bg-primary-700",
13
+ className
14
+ )}
15
+ {...props}
16
+ >
17
+ <SwitchPrimitive.Thumb className="pointer-events-none block size-5 rounded-full bg-background shadow-100 transition-transform data-[state=checked]:translate-x-5" />
18
+ </SwitchPrimitive.Root>
19
+ ))
20
+ Toggle.displayName = "Toggle"
21
+
22
+ export { Toggle }
@@ -0,0 +1,32 @@
1
+ import * as React from "react"
2
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip"
3
+ import { cn } from "../../lib/utils"
4
+
5
+ const TooltipProvider = TooltipPrimitive.Provider
6
+
7
+ const Tooltip = TooltipPrimitive.Root
8
+
9
+ const TooltipTrigger = TooltipPrimitive.Trigger
10
+
11
+ const TooltipContent = React.forwardRef<
12
+ React.ElementRef<typeof TooltipPrimitive.Content>,
13
+ React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
14
+ >(({ className, sideOffset = 4, children, ...props }, ref) => (
15
+ <TooltipPrimitive.Portal>
16
+ <TooltipPrimitive.Content
17
+ ref={ref}
18
+ sideOffset={sideOffset}
19
+ className={cn(
20
+ "z-50 overflow-hidden rounded-xs bg-primary-500 px-3 py-1.5 text-b3 font-medium text-white shadow-300",
21
+ className
22
+ )}
23
+ {...props}
24
+ >
25
+ {children}
26
+ <TooltipPrimitive.Arrow className="fill-grey-900" />
27
+ </TooltipPrimitive.Content>
28
+ </TooltipPrimitive.Portal>
29
+ ))
30
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName
31
+
32
+ export { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent }