@openconsole/shadcn 0.0.0 → 0.2.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 (73) hide show
  1. package/README.md +380 -0
  2. package/accordion.tsx +66 -66
  3. package/alert-dialog.tsx +196 -196
  4. package/alert.tsx +66 -66
  5. package/aspect-ratio.tsx +11 -11
  6. package/avatar.tsx +53 -53
  7. package/badge.tsx +46 -46
  8. package/breadcrumb.tsx +109 -109
  9. package/button-group.tsx +83 -83
  10. package/button.tsx +60 -60
  11. package/calendar.tsx +219 -219
  12. package/card.tsx +92 -92
  13. package/carousel.tsx +241 -241
  14. package/chart.tsx +374 -374
  15. package/checkbox.tsx +32 -32
  16. package/collapsible.tsx +33 -33
  17. package/command.tsx +184 -184
  18. package/context-menu.tsx +252 -252
  19. package/dialog.tsx +143 -143
  20. package/direction.tsx +22 -22
  21. package/drawer.tsx +135 -135
  22. package/dropdown-menu.tsx +257 -257
  23. package/empty.tsx +104 -104
  24. package/field.tsx +248 -248
  25. package/form.tsx +167 -167
  26. package/hooks/index.ts +1 -1
  27. package/hooks/use-mobile.ts +19 -19
  28. package/hover-card.tsx +44 -44
  29. package/icon.tsx +21 -21
  30. package/index.ts +59 -59
  31. package/input-group.tsx +170 -170
  32. package/input-otp.tsx +77 -77
  33. package/input.tsx +21 -21
  34. package/item.tsx +193 -193
  35. package/kbd.tsx +28 -28
  36. package/label.tsx +24 -24
  37. package/lib/index.ts +1 -1
  38. package/lib/utils.ts +6 -6
  39. package/menubar.tsx +276 -276
  40. package/native-select.tsx +62 -62
  41. package/navigation-menu.tsx +168 -168
  42. package/package.json +10 -2
  43. package/pagination.tsx +127 -127
  44. package/popover.tsx +89 -89
  45. package/progress.tsx +31 -31
  46. package/radio-group.tsx +45 -45
  47. package/resizable.tsx +53 -53
  48. package/scroll-area.tsx +58 -58
  49. package/select.tsx +187 -187
  50. package/separator.tsx +28 -28
  51. package/sheet.tsx +139 -139
  52. package/sidebar.tsx +724 -724
  53. package/skeleton.tsx +13 -13
  54. package/slider.tsx +63 -63
  55. package/sonner.tsx +40 -40
  56. package/spinner.tsx +16 -16
  57. package/styles.css +122 -0
  58. package/switch.tsx +35 -35
  59. package/table.tsx +116 -116
  60. package/tabs.tsx +66 -66
  61. package/textarea.tsx +18 -18
  62. package/toggle-group.tsx +83 -83
  63. package/toggle.tsx +47 -47
  64. package/tooltip.tsx +61 -61
  65. package/tsconfig.json +12 -12
  66. package/tsconfig.tsbuildinfo +1 -1
  67. package/skill/SKILL.md +0 -599
  68. package/skill/customization.md +0 -263
  69. package/skill/rules/base-vs-radix.md +0 -167
  70. package/skill/rules/composition.md +0 -240
  71. package/skill/rules/forms.md +0 -271
  72. package/skill/rules/icons.md +0 -136
  73. package/skill/rules/styling.md +0 -180
package/field.tsx CHANGED
@@ -1,248 +1,248 @@
1
- "use client"
2
-
3
- import { useMemo } from "react"
4
- import { cva, type VariantProps } from "class-variance-authority"
5
-
6
- import { cn } from "./lib/utils"
7
- import { Label } from "./label"
8
- import { Separator } from "./separator"
9
-
10
- function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
11
- return (
12
- <fieldset
13
- data-slot="field-set"
14
- className={cn(
15
- "flex flex-col gap-6",
16
- "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
17
- className
18
- )}
19
- {...props}
20
- />
21
- )
22
- }
23
-
24
- function FieldLegend({
25
- className,
26
- variant = "legend",
27
- ...props
28
- }: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
29
- return (
30
- <legend
31
- data-slot="field-legend"
32
- data-variant={variant}
33
- className={cn(
34
- "mb-3 font-medium",
35
- "data-[variant=legend]:text-base",
36
- "data-[variant=label]:text-sm",
37
- className
38
- )}
39
- {...props}
40
- />
41
- )
42
- }
43
-
44
- function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
45
- return (
46
- <div
47
- data-slot="field-group"
48
- className={cn(
49
- "group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
50
- className
51
- )}
52
- {...props}
53
- />
54
- )
55
- }
56
-
57
- const fieldVariants = cva(
58
- "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
59
- {
60
- variants: {
61
- orientation: {
62
- vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
63
- horizontal: [
64
- "flex-row items-center",
65
- "[&>[data-slot=field-label]]:flex-auto",
66
- "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
67
- ],
68
- responsive: [
69
- "flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto",
70
- "@md/field-group:[&>[data-slot=field-label]]:flex-auto",
71
- "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
72
- ],
73
- },
74
- },
75
- defaultVariants: {
76
- orientation: "vertical",
77
- },
78
- }
79
- )
80
-
81
- function Field({
82
- className,
83
- orientation = "vertical",
84
- ...props
85
- }: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
86
- return (
87
- <div
88
- role="group"
89
- data-slot="field"
90
- data-orientation={orientation}
91
- className={cn(fieldVariants({ orientation }), className)}
92
- {...props}
93
- />
94
- )
95
- }
96
-
97
- function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
98
- return (
99
- <div
100
- data-slot="field-content"
101
- className={cn(
102
- "group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
103
- className
104
- )}
105
- {...props}
106
- />
107
- )
108
- }
109
-
110
- function FieldLabel({
111
- className,
112
- ...props
113
- }: React.ComponentProps<typeof Label>) {
114
- return (
115
- <Label
116
- data-slot="field-label"
117
- className={cn(
118
- "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
119
- "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
120
- "has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10",
121
- className
122
- )}
123
- {...props}
124
- />
125
- )
126
- }
127
-
128
- function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
129
- return (
130
- <div
131
- data-slot="field-label"
132
- className={cn(
133
- "flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
134
- className
135
- )}
136
- {...props}
137
- />
138
- )
139
- }
140
-
141
- function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
142
- return (
143
- <p
144
- data-slot="field-description"
145
- className={cn(
146
- "text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance",
147
- "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
148
- "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
149
- className
150
- )}
151
- {...props}
152
- />
153
- )
154
- }
155
-
156
- function FieldSeparator({
157
- children,
158
- className,
159
- ...props
160
- }: React.ComponentProps<"div"> & {
161
- children?: React.ReactNode
162
- }) {
163
- return (
164
- <div
165
- data-slot="field-separator"
166
- data-content={!!children}
167
- className={cn(
168
- "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
169
- className
170
- )}
171
- {...props}
172
- >
173
- <Separator className="absolute inset-0 top-1/2" />
174
- {children && (
175
- <span
176
- className="relative mx-auto block w-fit bg-background px-2 text-muted-foreground"
177
- data-slot="field-separator-content"
178
- >
179
- {children}
180
- </span>
181
- )}
182
- </div>
183
- )
184
- }
185
-
186
- function FieldError({
187
- className,
188
- children,
189
- errors,
190
- ...props
191
- }: React.ComponentProps<"div"> & {
192
- errors?: Array<{ message?: string } | undefined>
193
- }) {
194
- const content = useMemo(() => {
195
- if (children) {
196
- return children
197
- }
198
-
199
- if (!errors?.length) {
200
- return null
201
- }
202
-
203
- const uniqueErrors = [
204
- ...new Map(errors.map((error) => [error?.message, error])).values(),
205
- ]
206
-
207
- if (uniqueErrors?.length == 1) {
208
- return uniqueErrors[0]?.message
209
- }
210
-
211
- return (
212
- <ul className="ml-4 flex list-disc flex-col gap-1">
213
- {uniqueErrors.map(
214
- (error, index) =>
215
- error?.message && <li key={index}>{error.message}</li>
216
- )}
217
- </ul>
218
- )
219
- }, [children, errors])
220
-
221
- if (!content) {
222
- return null
223
- }
224
-
225
- return (
226
- <div
227
- role="alert"
228
- data-slot="field-error"
229
- className={cn("text-sm font-normal text-destructive", className)}
230
- {...props}
231
- >
232
- {content}
233
- </div>
234
- )
235
- }
236
-
237
- export {
238
- Field,
239
- FieldLabel,
240
- FieldDescription,
241
- FieldError,
242
- FieldGroup,
243
- FieldLegend,
244
- FieldSeparator,
245
- FieldSet,
246
- FieldContent,
247
- FieldTitle,
248
- }
1
+ "use client"
2
+
3
+ import { useMemo } from "react"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+
6
+ import { cn } from "./lib/utils"
7
+ import { Label } from "./label"
8
+ import { Separator } from "./separator"
9
+
10
+ function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
11
+ return (
12
+ <fieldset
13
+ data-slot="field-set"
14
+ className={cn(
15
+ "flex flex-col gap-6",
16
+ "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
17
+ className
18
+ )}
19
+ {...props}
20
+ />
21
+ )
22
+ }
23
+
24
+ function FieldLegend({
25
+ className,
26
+ variant = "legend",
27
+ ...props
28
+ }: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
29
+ return (
30
+ <legend
31
+ data-slot="field-legend"
32
+ data-variant={variant}
33
+ className={cn(
34
+ "mb-3 font-medium",
35
+ "data-[variant=legend]:text-base",
36
+ "data-[variant=label]:text-sm",
37
+ className
38
+ )}
39
+ {...props}
40
+ />
41
+ )
42
+ }
43
+
44
+ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
45
+ return (
46
+ <div
47
+ data-slot="field-group"
48
+ className={cn(
49
+ "group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
50
+ className
51
+ )}
52
+ {...props}
53
+ />
54
+ )
55
+ }
56
+
57
+ const fieldVariants = cva(
58
+ "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
59
+ {
60
+ variants: {
61
+ orientation: {
62
+ vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
63
+ horizontal: [
64
+ "flex-row items-center",
65
+ "[&>[data-slot=field-label]]:flex-auto",
66
+ "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
67
+ ],
68
+ responsive: [
69
+ "flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto",
70
+ "@md/field-group:[&>[data-slot=field-label]]:flex-auto",
71
+ "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
72
+ ],
73
+ },
74
+ },
75
+ defaultVariants: {
76
+ orientation: "vertical",
77
+ },
78
+ }
79
+ )
80
+
81
+ function Field({
82
+ className,
83
+ orientation = "vertical",
84
+ ...props
85
+ }: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
86
+ return (
87
+ <div
88
+ role="group"
89
+ data-slot="field"
90
+ data-orientation={orientation}
91
+ className={cn(fieldVariants({ orientation }), className)}
92
+ {...props}
93
+ />
94
+ )
95
+ }
96
+
97
+ function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
98
+ return (
99
+ <div
100
+ data-slot="field-content"
101
+ className={cn(
102
+ "group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
103
+ className
104
+ )}
105
+ {...props}
106
+ />
107
+ )
108
+ }
109
+
110
+ function FieldLabel({
111
+ className,
112
+ ...props
113
+ }: React.ComponentProps<typeof Label>) {
114
+ return (
115
+ <Label
116
+ data-slot="field-label"
117
+ className={cn(
118
+ "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
119
+ "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
120
+ "has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10",
121
+ className
122
+ )}
123
+ {...props}
124
+ />
125
+ )
126
+ }
127
+
128
+ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
129
+ return (
130
+ <div
131
+ data-slot="field-label"
132
+ className={cn(
133
+ "flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
134
+ className
135
+ )}
136
+ {...props}
137
+ />
138
+ )
139
+ }
140
+
141
+ function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
142
+ return (
143
+ <p
144
+ data-slot="field-description"
145
+ className={cn(
146
+ "text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance",
147
+ "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
148
+ "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
149
+ className
150
+ )}
151
+ {...props}
152
+ />
153
+ )
154
+ }
155
+
156
+ function FieldSeparator({
157
+ children,
158
+ className,
159
+ ...props
160
+ }: React.ComponentProps<"div"> & {
161
+ children?: React.ReactNode
162
+ }) {
163
+ return (
164
+ <div
165
+ data-slot="field-separator"
166
+ data-content={!!children}
167
+ className={cn(
168
+ "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
169
+ className
170
+ )}
171
+ {...props}
172
+ >
173
+ <Separator className="absolute inset-0 top-1/2" />
174
+ {children && (
175
+ <span
176
+ className="relative mx-auto block w-fit bg-background px-2 text-muted-foreground"
177
+ data-slot="field-separator-content"
178
+ >
179
+ {children}
180
+ </span>
181
+ )}
182
+ </div>
183
+ )
184
+ }
185
+
186
+ function FieldError({
187
+ className,
188
+ children,
189
+ errors,
190
+ ...props
191
+ }: React.ComponentProps<"div"> & {
192
+ errors?: Array<{ message?: string } | undefined>
193
+ }) {
194
+ const content = useMemo(() => {
195
+ if (children) {
196
+ return children
197
+ }
198
+
199
+ if (!errors?.length) {
200
+ return null
201
+ }
202
+
203
+ const uniqueErrors = [
204
+ ...new Map(errors.map((error) => [error?.message, error])).values(),
205
+ ]
206
+
207
+ if (uniqueErrors?.length == 1) {
208
+ return uniqueErrors[0]?.message
209
+ }
210
+
211
+ return (
212
+ <ul className="ml-4 flex list-disc flex-col gap-1">
213
+ {uniqueErrors.map(
214
+ (error, index) =>
215
+ error?.message && <li key={index}>{error.message}</li>
216
+ )}
217
+ </ul>
218
+ )
219
+ }, [children, errors])
220
+
221
+ if (!content) {
222
+ return null
223
+ }
224
+
225
+ return (
226
+ <div
227
+ role="alert"
228
+ data-slot="field-error"
229
+ className={cn("text-sm font-normal text-destructive", className)}
230
+ {...props}
231
+ >
232
+ {content}
233
+ </div>
234
+ )
235
+ }
236
+
237
+ export {
238
+ Field,
239
+ FieldLabel,
240
+ FieldDescription,
241
+ FieldError,
242
+ FieldGroup,
243
+ FieldLegend,
244
+ FieldSeparator,
245
+ FieldSet,
246
+ FieldContent,
247
+ FieldTitle,
248
+ }