@timeax/form-palette 0.0.3 → 0.0.5

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 (120) hide show
  1. package/{src/schema/adapter.ts → dist/adapters.d.mts} +118 -43
  2. package/dist/adapters.d.ts +292 -0
  3. package/dist/adapters.js +13283 -0
  4. package/dist/adapters.js.map +1 -0
  5. package/dist/adapters.mjs +13269 -0
  6. package/dist/adapters.mjs.map +1 -0
  7. package/dist/index.d.mts +3744 -0
  8. package/dist/index.d.ts +3744 -0
  9. package/dist/index.js +43014 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/index.mjs +42965 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/package.json +22 -7
  14. package/.scaffold-cache.json +0 -537
  15. package/src/.scaffold-cache.json +0 -544
  16. package/src/adapters/axios.ts +0 -117
  17. package/src/adapters/index.ts +0 -91
  18. package/src/adapters/inertia.ts +0 -187
  19. package/src/core/adapter-registry.ts +0 -87
  20. package/src/core/bound/bind-host.ts +0 -14
  21. package/src/core/bound/observe-bound-field.ts +0 -172
  22. package/src/core/bound/wait-for-bound-field.ts +0 -57
  23. package/src/core/context.ts +0 -23
  24. package/src/core/core-provider.tsx +0 -818
  25. package/src/core/core-root.tsx +0 -72
  26. package/src/core/core-shell.tsx +0 -44
  27. package/src/core/errors/error-strip.tsx +0 -71
  28. package/src/core/errors/index.ts +0 -2
  29. package/src/core/errors/map-error-bag.ts +0 -51
  30. package/src/core/errors/map-zod.ts +0 -39
  31. package/src/core/hooks/use-button.ts +0 -220
  32. package/src/core/hooks/use-core-context.ts +0 -20
  33. package/src/core/hooks/use-core-utility.ts +0 -0
  34. package/src/core/hooks/use-core.ts +0 -13
  35. package/src/core/hooks/use-field.ts +0 -497
  36. package/src/core/hooks/use-optional-field.ts +0 -28
  37. package/src/core/index.ts +0 -0
  38. package/src/core/registry/binder-registry.ts +0 -82
  39. package/src/core/registry/field-registry.ts +0 -187
  40. package/src/core/test.tsx +0 -17
  41. package/src/global.d.ts +0 -14
  42. package/src/index.ts +0 -68
  43. package/src/input/index.ts +0 -4
  44. package/src/input/input-field.tsx +0 -854
  45. package/src/input/input-layout-graph.ts +0 -230
  46. package/src/input/input-props.ts +0 -190
  47. package/src/lib/get-global-countries.ts +0 -87
  48. package/src/lib/utils.ts +0 -6
  49. package/src/presets/index.ts +0 -0
  50. package/src/presets/shadcn-preset.ts +0 -0
  51. package/src/presets/shadcn-variants/checkbox.tsx +0 -849
  52. package/src/presets/shadcn-variants/chips.tsx +0 -756
  53. package/src/presets/shadcn-variants/color.tsx +0 -284
  54. package/src/presets/shadcn-variants/custom.tsx +0 -227
  55. package/src/presets/shadcn-variants/date.tsx +0 -796
  56. package/src/presets/shadcn-variants/file.tsx +0 -764
  57. package/src/presets/shadcn-variants/keyvalue.tsx +0 -556
  58. package/src/presets/shadcn-variants/multiselect.tsx +0 -1132
  59. package/src/presets/shadcn-variants/number.tsx +0 -176
  60. package/src/presets/shadcn-variants/password.tsx +0 -737
  61. package/src/presets/shadcn-variants/phone.tsx +0 -628
  62. package/src/presets/shadcn-variants/radio.tsx +0 -578
  63. package/src/presets/shadcn-variants/select.tsx +0 -956
  64. package/src/presets/shadcn-variants/slider.tsx +0 -622
  65. package/src/presets/shadcn-variants/text.tsx +0 -343
  66. package/src/presets/shadcn-variants/textarea.tsx +0 -66
  67. package/src/presets/shadcn-variants/toggle.tsx +0 -218
  68. package/src/presets/shadcn-variants/treeselect.tsx +0 -784
  69. package/src/presets/ui/badge.tsx +0 -46
  70. package/src/presets/ui/button.tsx +0 -60
  71. package/src/presets/ui/calendar.tsx +0 -214
  72. package/src/presets/ui/checkbox.tsx +0 -115
  73. package/src/presets/ui/custom.tsx +0 -0
  74. package/src/presets/ui/dialog.tsx +0 -141
  75. package/src/presets/ui/field.tsx +0 -246
  76. package/src/presets/ui/input-mask.tsx +0 -739
  77. package/src/presets/ui/input-otp.tsx +0 -77
  78. package/src/presets/ui/input.tsx +0 -1011
  79. package/src/presets/ui/label.tsx +0 -22
  80. package/src/presets/ui/number.tsx +0 -1370
  81. package/src/presets/ui/popover.tsx +0 -46
  82. package/src/presets/ui/radio-group.tsx +0 -43
  83. package/src/presets/ui/scroll-area.tsx +0 -56
  84. package/src/presets/ui/select.tsx +0 -190
  85. package/src/presets/ui/separator.tsx +0 -28
  86. package/src/presets/ui/slider.tsx +0 -61
  87. package/src/presets/ui/switch.tsx +0 -32
  88. package/src/presets/ui/textarea.tsx +0 -634
  89. package/src/presets/ui/time-dropdowns.tsx +0 -350
  90. package/src/schema/core.ts +0 -429
  91. package/src/schema/field-map.ts +0 -0
  92. package/src/schema/field.ts +0 -224
  93. package/src/schema/index.ts +0 -0
  94. package/src/schema/input-field.ts +0 -260
  95. package/src/schema/presets.ts +0 -0
  96. package/src/schema/variant.ts +0 -216
  97. package/src/variants/core/checkbox.tsx +0 -54
  98. package/src/variants/core/chips.tsx +0 -22
  99. package/src/variants/core/color.tsx +0 -16
  100. package/src/variants/core/custom.tsx +0 -18
  101. package/src/variants/core/date.tsx +0 -25
  102. package/src/variants/core/file.tsx +0 -9
  103. package/src/variants/core/keyvalue.tsx +0 -12
  104. package/src/variants/core/multiselect.tsx +0 -28
  105. package/src/variants/core/number.tsx +0 -115
  106. package/src/variants/core/password.tsx +0 -35
  107. package/src/variants/core/phone.tsx +0 -16
  108. package/src/variants/core/radio.tsx +0 -38
  109. package/src/variants/core/select.tsx +0 -15
  110. package/src/variants/core/slider.tsx +0 -55
  111. package/src/variants/core/text.tsx +0 -114
  112. package/src/variants/core/textarea.tsx +0 -22
  113. package/src/variants/core/toggle.tsx +0 -50
  114. package/src/variants/core/treeselect.tsx +0 -11
  115. package/src/variants/helpers/selection-summary.tsx +0 -236
  116. package/src/variants/index.ts +0 -75
  117. package/src/variants/registry.ts +0 -38
  118. package/src/variants/select-shared.ts +0 -0
  119. package/src/variants/shared.ts +0 -126
  120. package/tsconfig.json +0 -14
@@ -1,46 +0,0 @@
1
- import * as React from "react"
2
- import * as PopoverPrimitive from "@radix-ui/react-popover"
3
-
4
- import { cn } from "@/lib/utils"
5
-
6
- function Popover({
7
- ...props
8
- }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
9
- return <PopoverPrimitive.Root data-slot="popover" {...props} />
10
- }
11
-
12
- function PopoverTrigger({
13
- ...props
14
- }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
15
- return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
16
- }
17
-
18
- function PopoverContent({
19
- className,
20
- align = "center",
21
- sideOffset = 4,
22
- ...props
23
- }: React.ComponentProps<typeof PopoverPrimitive.Content>) {
24
- return (
25
- <PopoverPrimitive.Portal>
26
- <PopoverPrimitive.Content
27
- data-slot="popover-content"
28
- align={align}
29
- sideOffset={sideOffset}
30
- className={cn(
31
- "bg-popover text-popover-foreground 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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
32
- className
33
- )}
34
- {...props}
35
- />
36
- </PopoverPrimitive.Portal>
37
- )
38
- }
39
-
40
- function PopoverAnchor({
41
- ...props
42
- }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
43
- return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
44
- }
45
-
46
- export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
@@ -1,43 +0,0 @@
1
- import * as React from "react"
2
- import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
3
- import { CircleIcon } from "lucide-react"
4
-
5
- import { cn } from "@/lib/utils"
6
-
7
- function RadioGroup({
8
- className,
9
- ...props
10
- }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
11
- return (
12
- <RadioGroupPrimitive.Root
13
- data-slot="radio-group"
14
- className={cn("grid gap-3", className)}
15
- {...props}
16
- />
17
- )
18
- }
19
-
20
- function RadioGroupItem({
21
- className,
22
- ...props
23
- }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
24
- return (
25
- <RadioGroupPrimitive.Item
26
- data-slot="radio-group-item"
27
- className={cn(
28
- "border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
29
- className
30
- )}
31
- {...props}
32
- >
33
- <RadioGroupPrimitive.Indicator
34
- data-slot="radio-group-indicator"
35
- className="relative flex items-center justify-center"
36
- >
37
- <CircleIcon className="fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" />
38
- </RadioGroupPrimitive.Indicator>
39
- </RadioGroupPrimitive.Item>
40
- )
41
- }
42
-
43
- export { RadioGroup, RadioGroupItem }
@@ -1,56 +0,0 @@
1
- import * as React from "react"
2
- import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
3
-
4
- import { cn } from "@/lib/utils"
5
-
6
- function ScrollArea({
7
- className,
8
- children,
9
- ...props
10
- }: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
11
- return (
12
- <ScrollAreaPrimitive.Root
13
- data-slot="scroll-area"
14
- className={cn("relative", className)}
15
- {...props}
16
- >
17
- <ScrollAreaPrimitive.Viewport
18
- data-slot="scroll-area-viewport"
19
- className="focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"
20
- >
21
- {children}
22
- </ScrollAreaPrimitive.Viewport>
23
- <ScrollBar />
24
- <ScrollAreaPrimitive.Corner />
25
- </ScrollAreaPrimitive.Root>
26
- )
27
- }
28
-
29
- function ScrollBar({
30
- className,
31
- orientation = "vertical",
32
- ...props
33
- }: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {
34
- return (
35
- <ScrollAreaPrimitive.ScrollAreaScrollbar
36
- data-slot="scroll-area-scrollbar"
37
- orientation={orientation}
38
- className={cn(
39
- "flex touch-none p-px transition-colors select-none",
40
- orientation === "vertical" &&
41
- "h-full w-2.5 border-l border-l-transparent",
42
- orientation === "horizontal" &&
43
- "h-2.5 flex-col border-t border-t-transparent",
44
- className
45
- )}
46
- {...props}
47
- >
48
- <ScrollAreaPrimitive.ScrollAreaThumb
49
- data-slot="scroll-area-thumb"
50
- className="bg-border relative flex-1 rounded-full"
51
- />
52
- </ScrollAreaPrimitive.ScrollAreaScrollbar>
53
- )
54
- }
55
-
56
- export { ScrollArea, ScrollBar }
@@ -1,190 +0,0 @@
1
- import * as React from "react"
2
- import * as SelectPrimitive from "@radix-ui/react-select"
3
- import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
4
-
5
- import { cn } from "@/lib/utils"
6
-
7
- function Select({
8
- ...props
9
- }: React.ComponentProps<typeof SelectPrimitive.Root>) {
10
- return <SelectPrimitive.Root data-slot="select" {...props} />
11
- }
12
-
13
- function SelectGroup({
14
- ...props
15
- }: React.ComponentProps<typeof SelectPrimitive.Group>) {
16
- return <SelectPrimitive.Group data-slot="select-group" {...props} />
17
- }
18
-
19
- function SelectValue({
20
- ...props
21
- }: React.ComponentProps<typeof SelectPrimitive.Value>) {
22
- return <SelectPrimitive.Value data-slot="select-value" {...props} />
23
- }
24
- function SelectTrigger({
25
- className,
26
- size = "default",
27
- children,
28
- icon: Icon = ChevronDownIcon,
29
- ...props
30
- }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
31
- size?: "sm" | "default"
32
- /**
33
- * Optional custom icon component.
34
- * Example: `icon={ChevronUpIcon}`
35
- */
36
- icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>
37
- }) {
38
- return (
39
- <SelectPrimitive.Trigger
40
- data-slot="select-trigger"
41
- data-size={size}
42
- className={cn(
43
- "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
44
- className
45
- )}
46
- {...props}
47
- >
48
- {children}
49
- <SelectPrimitive.Icon asChild>
50
- <Icon className="size-4 opacity-50" />
51
- </SelectPrimitive.Icon>
52
- </SelectPrimitive.Trigger>
53
- )
54
- }
55
-
56
- function SelectContent({
57
- className,
58
- children,
59
- position = "popper",
60
- align = "center",
61
- ...props
62
- }: React.ComponentProps<typeof SelectPrimitive.Content>) {
63
- return (
64
- <SelectPrimitive.Portal>
65
- <SelectPrimitive.Content
66
- data-slot="select-content"
67
- className={cn(
68
- "bg-popover text-popover-foreground 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
69
- position === "popper" &&
70
- "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
71
- className
72
- )}
73
- position={position}
74
- align={align}
75
- {...props}
76
- >
77
- <SelectScrollUpButton />
78
- <SelectPrimitive.Viewport
79
- className={cn(
80
- "p-1",
81
- position === "popper" &&
82
- "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
83
- )}
84
- >
85
- {children}
86
- </SelectPrimitive.Viewport>
87
- <SelectScrollDownButton />
88
- </SelectPrimitive.Content>
89
- </SelectPrimitive.Portal>
90
- )
91
- }
92
-
93
- function SelectLabel({
94
- className,
95
- ...props
96
- }: React.ComponentProps<typeof SelectPrimitive.Label>) {
97
- return (
98
- <SelectPrimitive.Label
99
- data-slot="select-label"
100
- className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
101
- {...props}
102
- />
103
- )
104
- }
105
-
106
- function SelectItem({
107
- className,
108
- children,
109
- ...props
110
- }: React.ComponentProps<typeof SelectPrimitive.Item>) {
111
- return (
112
- <SelectPrimitive.Item
113
- data-slot="select-item"
114
- className={cn(
115
- "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
116
- className
117
- )}
118
- {...props}
119
- >
120
- <span className="absolute right-2 flex size-3.5 items-center justify-center">
121
- <SelectPrimitive.ItemIndicator>
122
- <CheckIcon className="size-4" />
123
- </SelectPrimitive.ItemIndicator>
124
- </span>
125
- <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
126
- </SelectPrimitive.Item>
127
- )
128
- }
129
-
130
- function SelectSeparator({
131
- className,
132
- ...props
133
- }: React.ComponentProps<typeof SelectPrimitive.Separator>) {
134
- return (
135
- <SelectPrimitive.Separator
136
- data-slot="select-separator"
137
- className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
138
- {...props}
139
- />
140
- )
141
- }
142
-
143
- function SelectScrollUpButton({
144
- className,
145
- ...props
146
- }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
147
- return (
148
- <SelectPrimitive.ScrollUpButton
149
- data-slot="select-scroll-up-button"
150
- className={cn(
151
- "flex cursor-default items-center justify-center py-1",
152
- className
153
- )}
154
- {...props}
155
- >
156
- <ChevronUpIcon className="size-4" />
157
- </SelectPrimitive.ScrollUpButton>
158
- )
159
- }
160
-
161
- function SelectScrollDownButton({
162
- className,
163
- ...props
164
- }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
165
- return (
166
- <SelectPrimitive.ScrollDownButton
167
- data-slot="select-scroll-down-button"
168
- className={cn(
169
- "flex cursor-default items-center justify-center py-1",
170
- className
171
- )}
172
- {...props}
173
- >
174
- <ChevronDownIcon className="size-4" />
175
- </SelectPrimitive.ScrollDownButton>
176
- )
177
- }
178
-
179
- export {
180
- Select,
181
- SelectContent,
182
- SelectGroup,
183
- SelectItem,
184
- SelectLabel,
185
- SelectScrollDownButton,
186
- SelectScrollUpButton,
187
- SelectSeparator,
188
- SelectTrigger,
189
- SelectValue,
190
- }
@@ -1,28 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as SeparatorPrimitive from "@radix-ui/react-separator"
5
-
6
- import { cn } from "@/lib/utils"
7
-
8
- function Separator({
9
- className,
10
- orientation = "horizontal",
11
- decorative = true,
12
- ...props
13
- }: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
14
- return (
15
- <SeparatorPrimitive.Root
16
- data-slot="separator"
17
- decorative={decorative}
18
- orientation={orientation}
19
- className={cn(
20
- "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
21
- className
22
- )}
23
- {...props}
24
- />
25
- )
26
- }
27
-
28
- export { Separator }
@@ -1,61 +0,0 @@
1
- import * as React from "react"
2
- import * as SliderPrimitive from "@radix-ui/react-slider"
3
-
4
- import { cn } from "@/lib/utils"
5
-
6
- function Slider({
7
- className,
8
- defaultValue,
9
- value,
10
- min = 0,
11
- max = 100,
12
- ...props
13
- }: React.ComponentProps<typeof SliderPrimitive.Root>) {
14
- const _values = React.useMemo(
15
- () =>
16
- Array.isArray(value)
17
- ? value
18
- : Array.isArray(defaultValue)
19
- ? defaultValue
20
- : [min, max],
21
- [value, defaultValue, min, max]
22
- )
23
-
24
- return (
25
- <SliderPrimitive.Root
26
- data-slot="slider"
27
- defaultValue={defaultValue}
28
- value={value}
29
- min={min}
30
- max={max}
31
- className={cn(
32
- "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
33
- className
34
- )}
35
- {...props}
36
- >
37
- <SliderPrimitive.Track
38
- data-slot="slider-track"
39
- className={cn(
40
- "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
41
- )}
42
- >
43
- <SliderPrimitive.Range
44
- data-slot="slider-range"
45
- className={cn(
46
- "bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
47
- )}
48
- />
49
- </SliderPrimitive.Track>
50
- {Array.from({ length: _values.length }, (_, index) => (
51
- <SliderPrimitive.Thumb
52
- data-slot="slider-thumb"
53
- key={index}
54
- className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
55
- />
56
- ))}
57
- </SliderPrimitive.Root>
58
- )
59
- }
60
-
61
- export { Slider }
@@ -1,32 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as SwitchPrimitive from "@radix-ui/react-switch"
5
-
6
- import { cn } from "@/lib/utils"
7
-
8
- function Switch({
9
- className,
10
- thumbClassName,
11
- ...props
12
- }: React.ComponentProps<typeof SwitchPrimitive.Root> & { thumbClassName?: string }) {
13
- return (
14
- <SwitchPrimitive.Root
15
- data-slot="switch"
16
- className={cn(
17
- "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
18
- className
19
- )}
20
- {...props}
21
- >
22
- <SwitchPrimitive.Thumb
23
- data-slot="switch-thumb"
24
- className={cn(
25
- "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0", thumbClassName
26
- )}
27
- />
28
- </SwitchPrimitive.Root>
29
- )
30
- }
31
-
32
- export { Switch }