@bupple/vss-ui 1.0.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 (65) hide show
  1. package/.turbo/turbo-lint.log +4 -0
  2. package/components.json +21 -0
  3. package/eslint.config.js +4 -0
  4. package/index.ts +2 -0
  5. package/package.json +67 -0
  6. package/postcss.config.mjs +6 -0
  7. package/src/components/accordion.tsx +84 -0
  8. package/src/components/alert-dialog.tsx +198 -0
  9. package/src/components/alert.tsx +77 -0
  10. package/src/components/aspect-ratio.tsx +11 -0
  11. package/src/components/avatar.tsx +109 -0
  12. package/src/components/badge.tsx +50 -0
  13. package/src/components/breadcrumb.tsx +118 -0
  14. package/src/components/button-group.tsx +84 -0
  15. package/src/components/button.tsx +68 -0
  16. package/src/components/calendar.tsx +223 -0
  17. package/src/components/card.tsx +102 -0
  18. package/src/components/carousel.tsx +241 -0
  19. package/src/components/chart.tsx +373 -0
  20. package/src/components/checkbox.tsx +32 -0
  21. package/src/components/collapsible.tsx +33 -0
  22. package/src/components/combobox.tsx +299 -0
  23. package/src/components/command.tsx +194 -0
  24. package/src/components/context-menu.tsx +272 -0
  25. package/src/components/dialog.tsx +171 -0
  26. package/src/components/direction.tsx +20 -0
  27. package/src/components/drawer.tsx +130 -0
  28. package/src/components/dropdown-menu.tsx +278 -0
  29. package/src/components/empty.tsx +102 -0
  30. package/src/components/field.tsx +237 -0
  31. package/src/components/hover-card.tsx +43 -0
  32. package/src/components/input-group.tsx +157 -0
  33. package/src/components/input.tsx +18 -0
  34. package/src/components/item.tsx +197 -0
  35. package/src/components/kbd.tsx +26 -0
  36. package/src/components/label.tsx +21 -0
  37. package/src/components/menubar.tsx +283 -0
  38. package/src/components/native-select.tsx +64 -0
  39. package/src/components/navigation-menu.tsx +166 -0
  40. package/src/components/pagination.tsx +131 -0
  41. package/src/components/popover.tsx +88 -0
  42. package/src/components/progress.tsx +30 -0
  43. package/src/components/radio-group.tsx +46 -0
  44. package/src/components/resizable.tsx +49 -0
  45. package/src/components/scroll-area.tsx +52 -0
  46. package/src/components/select.tsx +209 -0
  47. package/src/components/separator.tsx +25 -0
  48. package/src/components/sheet.tsx +152 -0
  49. package/src/components/sidebar.tsx +703 -0
  50. package/src/components/skeleton.tsx +13 -0
  51. package/src/components/slider.tsx +58 -0
  52. package/src/components/sonner.tsx +45 -0
  53. package/src/components/spinner.tsx +15 -0
  54. package/src/components/switch.tsx +32 -0
  55. package/src/components/table.tsx +115 -0
  56. package/src/components/tabs.tsx +89 -0
  57. package/src/components/textarea.tsx +17 -0
  58. package/src/components/toggle-group.tsx +86 -0
  59. package/src/components/toggle.tsx +48 -0
  60. package/src/components/tooltip.tsx +56 -0
  61. package/src/hooks/use-mobile.ts +19 -0
  62. package/src/lib/portal-container.ts +11 -0
  63. package/src/lib/utils.ts +8 -0
  64. package/src/theme.css +125 -0
  65. package/tsconfig.json +15 -0
@@ -0,0 +1,241 @@
1
+ 'use client'
2
+
3
+ import type { UseEmblaCarouselType } from 'embla-carousel-react'
4
+
5
+ import { Button } from '@bupple/vss-ui/components/button'
6
+ import { cn } from '@bupple/vss-ui/lib/utils'
7
+ import useEmblaCarousel from 'embla-carousel-react'
8
+ import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react'
9
+ import * as React from 'react'
10
+
11
+ type CarouselApi = UseEmblaCarouselType[1]
12
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
13
+ type CarouselOptions = UseCarouselParameters[0]
14
+ type CarouselPlugin = UseCarouselParameters[1]
15
+
16
+ type CarouselProps = {
17
+ opts?: CarouselOptions
18
+ plugins?: CarouselPlugin
19
+ orientation?: 'horizontal' | 'vertical'
20
+ setApi?: (api: CarouselApi) => void
21
+ }
22
+
23
+ type CarouselContextProps = {
24
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0]
25
+ api: ReturnType<typeof useEmblaCarousel>[1]
26
+ scrollPrev: () => void
27
+ scrollNext: () => void
28
+ canScrollPrev: boolean
29
+ canScrollNext: boolean
30
+ } & CarouselProps
31
+
32
+ const CarouselContext = React.createContext<CarouselContextProps | null>(null)
33
+
34
+ function useCarousel() {
35
+ const context = React.useContext(CarouselContext)
36
+
37
+ if (!context) {
38
+ throw new Error('useCarousel must be used within a <Carousel />')
39
+ }
40
+
41
+ return context
42
+ }
43
+
44
+ function Carousel({
45
+ orientation = 'horizontal',
46
+ opts,
47
+ setApi,
48
+ plugins,
49
+ className,
50
+ children,
51
+ ...props
52
+ }: React.ComponentProps<'div'> & CarouselProps) {
53
+ const [carouselRef, api] = useEmblaCarousel(
54
+ {
55
+ ...opts,
56
+ axis: orientation === 'horizontal' ? 'x' : 'y',
57
+ },
58
+ plugins,
59
+ )
60
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false)
61
+ const [canScrollNext, setCanScrollNext] = React.useState(false)
62
+
63
+ const onSelect = React.useCallback((api: CarouselApi) => {
64
+ if (!api) return
65
+ setCanScrollPrev(api.canScrollPrev())
66
+ setCanScrollNext(api.canScrollNext())
67
+ }, [])
68
+
69
+ const scrollPrev = React.useCallback(() => {
70
+ api?.scrollPrev()
71
+ }, [api])
72
+
73
+ const scrollNext = React.useCallback(() => {
74
+ api?.scrollNext()
75
+ }, [api])
76
+
77
+ const handleKeyDown = React.useCallback(
78
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
79
+ if (event.key === 'ArrowLeft') {
80
+ event.preventDefault()
81
+ scrollPrev()
82
+ } else if (event.key === 'ArrowRight') {
83
+ event.preventDefault()
84
+ scrollNext()
85
+ }
86
+ },
87
+ [scrollPrev, scrollNext],
88
+ )
89
+
90
+ React.useEffect(() => {
91
+ if (!api || !setApi) return
92
+ setApi(api)
93
+ }, [api, setApi])
94
+
95
+ React.useEffect(() => {
96
+ if (!api) return
97
+ onSelect(api)
98
+ api.on('reInit', onSelect)
99
+ api.on('select', onSelect)
100
+
101
+ return () => {
102
+ api?.off('select', onSelect)
103
+ }
104
+ }, [api, onSelect])
105
+
106
+ return (
107
+ <CarouselContext.Provider
108
+ value={{
109
+ carouselRef,
110
+ api: api,
111
+ opts,
112
+ orientation:
113
+ orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
114
+ scrollPrev,
115
+ scrollNext,
116
+ canScrollPrev,
117
+ canScrollNext,
118
+ }}
119
+ >
120
+ <div
121
+ onKeyDownCapture={handleKeyDown}
122
+ className={cn('relative', className)}
123
+ role='region'
124
+ aria-roledescription='carousel'
125
+ data-slot='carousel'
126
+ {...props}
127
+ >
128
+ {children}
129
+ </div>
130
+ </CarouselContext.Provider>
131
+ )
132
+ }
133
+
134
+ function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
135
+ const { carouselRef, orientation } = useCarousel()
136
+
137
+ return (
138
+ <div
139
+ ref={carouselRef}
140
+ className='overflow-hidden'
141
+ data-slot='carousel-content'
142
+ >
143
+ <div
144
+ className={cn(
145
+ 'flex',
146
+ orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col',
147
+ className,
148
+ )}
149
+ {...props}
150
+ />
151
+ </div>
152
+ )
153
+ }
154
+
155
+ function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
156
+ const { orientation } = useCarousel()
157
+
158
+ return (
159
+ <div
160
+ role='group'
161
+ aria-roledescription='slide'
162
+ data-slot='carousel-item'
163
+ className={cn(
164
+ 'min-w-0 shrink-0 grow-0 basis-full',
165
+ orientation === 'horizontal' ? 'pl-4' : 'pt-4',
166
+ className,
167
+ )}
168
+ {...props}
169
+ />
170
+ )
171
+ }
172
+
173
+ function CarouselPrevious({
174
+ className,
175
+ variant = 'outline',
176
+ size = 'icon-sm',
177
+ ...props
178
+ }: React.ComponentProps<typeof Button>) {
179
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel()
180
+
181
+ return (
182
+ <Button
183
+ data-slot='carousel-previous'
184
+ variant={variant}
185
+ size={size}
186
+ className={cn(
187
+ 'absolute touch-manipulation rounded-full',
188
+ orientation === 'horizontal'
189
+ ? 'top-1/2 -left-12 -translate-y-1/2'
190
+ : '-top-12 left-1/2 -translate-x-1/2 rotate-90',
191
+ className,
192
+ )}
193
+ disabled={!canScrollPrev}
194
+ onClick={scrollPrev}
195
+ {...props}
196
+ >
197
+ <ChevronLeftIcon />
198
+ <span className='sr-only'>Previous slide</span>
199
+ </Button>
200
+ )
201
+ }
202
+
203
+ function CarouselNext({
204
+ className,
205
+ variant = 'outline',
206
+ size = 'icon-sm',
207
+ ...props
208
+ }: React.ComponentProps<typeof Button>) {
209
+ const { orientation, scrollNext, canScrollNext } = useCarousel()
210
+
211
+ return (
212
+ <Button
213
+ data-slot='carousel-next'
214
+ variant={variant}
215
+ size={size}
216
+ className={cn(
217
+ 'absolute touch-manipulation rounded-full',
218
+ orientation === 'horizontal'
219
+ ? 'top-1/2 -right-12 -translate-y-1/2'
220
+ : '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
221
+ className,
222
+ )}
223
+ disabled={!canScrollNext}
224
+ onClick={scrollNext}
225
+ {...props}
226
+ >
227
+ <ChevronRightIcon />
228
+ <span className='sr-only'>Next slide</span>
229
+ </Button>
230
+ )
231
+ }
232
+
233
+ export {
234
+ type CarouselApi,
235
+ Carousel,
236
+ CarouselContent,
237
+ CarouselItem,
238
+ CarouselPrevious,
239
+ CarouselNext,
240
+ useCarousel,
241
+ }
@@ -0,0 +1,373 @@
1
+ 'use client'
2
+
3
+ import type { TooltipValueType } from 'recharts'
4
+
5
+ import { cn } from '@bupple/vss-ui/lib/utils'
6
+ import * as React from 'react'
7
+ import * as RechartsPrimitive from 'recharts'
8
+
9
+ // Format: { THEME_NAME: CSS_SELECTOR }
10
+ const THEMES = { light: '', dark: '.dark' } as const
11
+
12
+ const INITIAL_DIMENSION = { width: 320, height: 200 } as const
13
+ type TooltipNameType = number | string
14
+
15
+ export type ChartConfig = Record<
16
+ string,
17
+ {
18
+ label?: React.ReactNode
19
+ icon?: React.ComponentType
20
+ } & (
21
+ | { color?: string; theme?: never }
22
+ | { color?: never; theme: Record<keyof typeof THEMES, string> }
23
+ )
24
+ >
25
+
26
+ type ChartContextProps = {
27
+ config: ChartConfig
28
+ }
29
+
30
+ const ChartContext = React.createContext<ChartContextProps | null>(null)
31
+
32
+ function useChart() {
33
+ const context = React.useContext(ChartContext)
34
+
35
+ if (!context) {
36
+ throw new Error('useChart must be used within a <ChartContainer />')
37
+ }
38
+
39
+ return context
40
+ }
41
+
42
+ function ChartContainer({
43
+ id,
44
+ className,
45
+ children,
46
+ config,
47
+ initialDimension = INITIAL_DIMENSION,
48
+ ...props
49
+ }: React.ComponentProps<'div'> & {
50
+ config: ChartConfig
51
+ children: React.ComponentProps<
52
+ typeof RechartsPrimitive.ResponsiveContainer
53
+ >['children']
54
+ initialDimension?: {
55
+ width: number
56
+ height: number
57
+ }
58
+ }) {
59
+ const uniqueId = React.useId()
60
+ const chartId = `chart-${id ?? uniqueId.replace(/:/g, '')}`
61
+
62
+ return (
63
+ <ChartContext.Provider value={{ config }}>
64
+ <div
65
+ data-slot='chart'
66
+ data-chart={chartId}
67
+ className={cn(
68
+ "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
69
+ className,
70
+ )}
71
+ {...props}
72
+ >
73
+ <ChartStyle id={chartId} config={config} />
74
+ <RechartsPrimitive.ResponsiveContainer
75
+ initialDimension={initialDimension}
76
+ >
77
+ {children}
78
+ </RechartsPrimitive.ResponsiveContainer>
79
+ </div>
80
+ </ChartContext.Provider>
81
+ )
82
+ }
83
+
84
+ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
85
+ const colorConfig = Object.entries(config).filter(
86
+ ([, config]) => config.theme ?? config.color,
87
+ )
88
+
89
+ if (!colorConfig.length) {
90
+ return null
91
+ }
92
+
93
+ return (
94
+ <style
95
+ dangerouslySetInnerHTML={{
96
+ __html: Object.entries(THEMES)
97
+ .map(
98
+ ([theme, prefix]) => `
99
+ ${prefix} [data-chart=${id}] {
100
+ ${colorConfig
101
+ .map(([key, itemConfig]) => {
102
+ const color =
103
+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
104
+ itemConfig.color
105
+ return color ? ` --color-${key}: ${color};` : null
106
+ })
107
+ .join('\n')}
108
+ }
109
+ `,
110
+ )
111
+ .join('\n'),
112
+ }}
113
+ />
114
+ )
115
+ }
116
+
117
+ const ChartTooltip = RechartsPrimitive.Tooltip
118
+
119
+ function ChartTooltipContent({
120
+ active,
121
+ payload,
122
+ className,
123
+ indicator = 'dot',
124
+ hideLabel = false,
125
+ hideIndicator = false,
126
+ label,
127
+ labelFormatter,
128
+ labelClassName,
129
+ formatter,
130
+ color,
131
+ nameKey,
132
+ labelKey,
133
+ }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
134
+ React.ComponentProps<'div'> & {
135
+ hideLabel?: boolean
136
+ hideIndicator?: boolean
137
+ indicator?: 'line' | 'dot' | 'dashed'
138
+ nameKey?: string
139
+ labelKey?: string
140
+ } & Omit<
141
+ RechartsPrimitive.DefaultTooltipContentProps<
142
+ TooltipValueType,
143
+ TooltipNameType
144
+ >,
145
+ 'accessibilityLayer'
146
+ >) {
147
+ const { config } = useChart()
148
+
149
+ const tooltipLabel = React.useMemo(() => {
150
+ if (hideLabel || !payload?.length) {
151
+ return null
152
+ }
153
+
154
+ const [item] = payload
155
+ const key = `${labelKey ?? item?.dataKey ?? item?.name ?? 'value'}`
156
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
157
+ const value =
158
+ !labelKey && typeof label === 'string'
159
+ ? (config[label]?.label ?? label)
160
+ : itemConfig?.label
161
+
162
+ if (labelFormatter) {
163
+ return (
164
+ <div className={cn('font-medium', labelClassName)}>
165
+ {labelFormatter(value, payload)}
166
+ </div>
167
+ )
168
+ }
169
+
170
+ if (!value) {
171
+ return null
172
+ }
173
+
174
+ return <div className={cn('font-medium', labelClassName)}>{value}</div>
175
+ }, [
176
+ label,
177
+ labelFormatter,
178
+ payload,
179
+ hideLabel,
180
+ labelClassName,
181
+ config,
182
+ labelKey,
183
+ ])
184
+
185
+ if (!active || !payload?.length) {
186
+ return null
187
+ }
188
+
189
+ const nestLabel = payload.length === 1 && indicator !== 'dot'
190
+
191
+ return (
192
+ <div
193
+ className={cn(
194
+ 'grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl',
195
+ className,
196
+ )}
197
+ >
198
+ {!nestLabel ? tooltipLabel : null}
199
+ <div className='grid gap-1.5'>
200
+ {payload
201
+ .filter((item) => item.type !== 'none')
202
+ .map((item, index) => {
203
+ const key = `${nameKey ?? item.name ?? item.dataKey ?? 'value'}`
204
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
205
+ const indicatorColor = color ?? item.payload?.fill ?? item.color
206
+
207
+ return (
208
+ <div
209
+ key={index}
210
+ className={cn(
211
+ 'flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground',
212
+ indicator === 'dot' && 'items-center',
213
+ )}
214
+ >
215
+ {formatter && item?.value !== undefined && item.name ? (
216
+ formatter(item.value, item.name, item, index, item.payload)
217
+ ) : (
218
+ <>
219
+ {itemConfig?.icon ? (
220
+ <itemConfig.icon />
221
+ ) : (
222
+ !hideIndicator && (
223
+ <div
224
+ className={cn(
225
+ 'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
226
+ {
227
+ 'h-2.5 w-2.5': indicator === 'dot',
228
+ 'w-1': indicator === 'line',
229
+ 'w-0 border-[1.5px] border-dashed bg-transparent':
230
+ indicator === 'dashed',
231
+ 'my-0.5': nestLabel && indicator === 'dashed',
232
+ },
233
+ )}
234
+ style={
235
+ {
236
+ '--color-bg': indicatorColor,
237
+ '--color-border': indicatorColor,
238
+ } as React.CSSProperties
239
+ }
240
+ />
241
+ )
242
+ )}
243
+ <div
244
+ className={cn(
245
+ 'flex flex-1 justify-between leading-none',
246
+ nestLabel ? 'items-end' : 'items-center',
247
+ )}
248
+ >
249
+ <div className='grid gap-1.5'>
250
+ {nestLabel ? tooltipLabel : null}
251
+ <span className='text-muted-foreground'>
252
+ {itemConfig?.label ?? item.name}
253
+ </span>
254
+ </div>
255
+ {item.value != null && (
256
+ <span className='font-mono font-medium text-foreground tabular-nums'>
257
+ {typeof item.value === 'number'
258
+ ? item.value.toLocaleString()
259
+ : String(item.value)}
260
+ </span>
261
+ )}
262
+ </div>
263
+ </>
264
+ )}
265
+ </div>
266
+ )
267
+ })}
268
+ </div>
269
+ </div>
270
+ )
271
+ }
272
+
273
+ const ChartLegend = RechartsPrimitive.Legend
274
+
275
+ function ChartLegendContent({
276
+ className,
277
+ hideIcon = false,
278
+ payload,
279
+ verticalAlign = 'bottom',
280
+ nameKey,
281
+ }: React.ComponentProps<'div'> & {
282
+ hideIcon?: boolean
283
+ nameKey?: string
284
+ } & RechartsPrimitive.DefaultLegendContentProps) {
285
+ const { config } = useChart()
286
+
287
+ if (!payload?.length) {
288
+ return null
289
+ }
290
+
291
+ return (
292
+ <div
293
+ className={cn(
294
+ 'flex items-center justify-center gap-4',
295
+ verticalAlign === 'top' ? 'pb-3' : 'pt-3',
296
+ className,
297
+ )}
298
+ >
299
+ {payload
300
+ .filter((item) => item.type !== 'none')
301
+ .map((item, index) => {
302
+ const key = `${nameKey ?? item.dataKey ?? 'value'}`
303
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
304
+
305
+ return (
306
+ <div
307
+ key={index}
308
+ className={cn(
309
+ 'flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground',
310
+ )}
311
+ >
312
+ {itemConfig?.icon && !hideIcon ? (
313
+ <itemConfig.icon />
314
+ ) : (
315
+ <div
316
+ className='h-2 w-2 shrink-0 rounded-[2px]'
317
+ style={{
318
+ backgroundColor: item.color,
319
+ }}
320
+ />
321
+ )}
322
+ {itemConfig?.label}
323
+ </div>
324
+ )
325
+ })}
326
+ </div>
327
+ )
328
+ }
329
+
330
+ function getPayloadConfigFromPayload(
331
+ config: ChartConfig,
332
+ payload: unknown,
333
+ key: string,
334
+ ) {
335
+ if (typeof payload !== 'object' || payload === null) {
336
+ return undefined
337
+ }
338
+
339
+ const payloadPayload =
340
+ 'payload' in payload &&
341
+ typeof payload.payload === 'object' &&
342
+ payload.payload !== null
343
+ ? payload.payload
344
+ : undefined
345
+
346
+ let configLabelKey: string = key
347
+
348
+ if (
349
+ key in payload &&
350
+ typeof payload[key as keyof typeof payload] === 'string'
351
+ ) {
352
+ configLabelKey = payload[key as keyof typeof payload] as string
353
+ } else if (
354
+ payloadPayload &&
355
+ key in payloadPayload &&
356
+ typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
357
+ ) {
358
+ configLabelKey = payloadPayload[
359
+ key as keyof typeof payloadPayload
360
+ ] as string
361
+ }
362
+
363
+ return configLabelKey in config ? config[configLabelKey] : config[key]
364
+ }
365
+
366
+ export {
367
+ ChartContainer,
368
+ ChartTooltip,
369
+ ChartTooltipContent,
370
+ ChartLegend,
371
+ ChartLegendContent,
372
+ ChartStyle,
373
+ }
@@ -0,0 +1,32 @@
1
+ import { cn } from '@bupple/vss-ui/lib/utils'
2
+ import { CheckIcon } from 'lucide-react'
3
+ import { Checkbox as CheckboxPrimitive } from 'radix-ui'
4
+ import * as React from 'react'
5
+
6
+ function Checkbox({
7
+ className,
8
+ checkIcon,
9
+ ...props
10
+ }: React.ComponentProps<typeof CheckboxPrimitive.Root> & {
11
+ checkIcon?: React.ReactNode
12
+ }) {
13
+ return (
14
+ <CheckboxPrimitive.Root
15
+ data-slot='checkbox'
16
+ className={cn(
17
+ 'peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary',
18
+ className,
19
+ )}
20
+ {...props}
21
+ >
22
+ <CheckboxPrimitive.Indicator
23
+ data-slot='checkbox-indicator'
24
+ className='grid place-content-center text-current transition-none [&>svg]:size-3.5'
25
+ >
26
+ {checkIcon ?? <CheckIcon />}
27
+ </CheckboxPrimitive.Indicator>
28
+ </CheckboxPrimitive.Root>
29
+ )
30
+ }
31
+
32
+ export { Checkbox }
@@ -0,0 +1,33 @@
1
+ 'use client'
2
+
3
+ import { Collapsible as CollapsiblePrimitive } from 'radix-ui'
4
+
5
+ function Collapsible({
6
+ ...props
7
+ }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
8
+ return <CollapsiblePrimitive.Root data-slot='collapsible' {...props} />
9
+ }
10
+
11
+ function CollapsibleTrigger({
12
+ ...props
13
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
14
+ return (
15
+ <CollapsiblePrimitive.CollapsibleTrigger
16
+ data-slot='collapsible-trigger'
17
+ {...props}
18
+ />
19
+ )
20
+ }
21
+
22
+ function CollapsibleContent({
23
+ ...props
24
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
25
+ return (
26
+ <CollapsiblePrimitive.CollapsibleContent
27
+ data-slot='collapsible-content'
28
+ {...props}
29
+ />
30
+ )
31
+ }
32
+
33
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent }