@vendure-io/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 (58) hide show
  1. package/package.json +59 -0
  2. package/src/components/ui/accordion.tsx +74 -0
  3. package/src/components/ui/alert-dialog.tsx +187 -0
  4. package/src/components/ui/alert.tsx +76 -0
  5. package/src/components/ui/aspect-ratio.tsx +22 -0
  6. package/src/components/ui/avatar.tsx +109 -0
  7. package/src/components/ui/badge.tsx +52 -0
  8. package/src/components/ui/breadcrumb.tsx +125 -0
  9. package/src/components/ui/button-group.tsx +87 -0
  10. package/src/components/ui/button.tsx +60 -0
  11. package/src/components/ui/calendar.tsx +221 -0
  12. package/src/components/ui/card.tsx +103 -0
  13. package/src/components/ui/carousel.tsx +242 -0
  14. package/src/components/ui/chart.tsx +356 -0
  15. package/src/components/ui/checkbox.tsx +29 -0
  16. package/src/components/ui/collapsible.tsx +21 -0
  17. package/src/components/ui/combobox.tsx +297 -0
  18. package/src/components/ui/command.tsx +196 -0
  19. package/src/components/ui/context-menu.tsx +271 -0
  20. package/src/components/ui/dialog.tsx +157 -0
  21. package/src/components/ui/direction.tsx +6 -0
  22. package/src/components/ui/drawer.tsx +131 -0
  23. package/src/components/ui/dropdown-menu.tsx +271 -0
  24. package/src/components/ui/empty.tsx +101 -0
  25. package/src/components/ui/field.tsx +238 -0
  26. package/src/components/ui/hover-card.tsx +51 -0
  27. package/src/components/ui/input-group.tsx +158 -0
  28. package/src/components/ui/input-otp.tsx +87 -0
  29. package/src/components/ui/input.tsx +20 -0
  30. package/src/components/ui/item.tsx +201 -0
  31. package/src/components/ui/kbd.tsx +26 -0
  32. package/src/components/ui/label.tsx +20 -0
  33. package/src/components/ui/menubar.tsx +283 -0
  34. package/src/components/ui/native-select.tsx +52 -0
  35. package/src/components/ui/navigation-menu.tsx +168 -0
  36. package/src/components/ui/pagination.tsx +130 -0
  37. package/src/components/ui/popover.tsx +90 -0
  38. package/src/components/ui/progress.tsx +83 -0
  39. package/src/components/ui/radio-group.tsx +38 -0
  40. package/src/components/ui/resizable.tsx +50 -0
  41. package/src/components/ui/scroll-area.tsx +55 -0
  42. package/src/components/ui/select.tsx +201 -0
  43. package/src/components/ui/separator.tsx +25 -0
  44. package/src/components/ui/sheet.tsx +135 -0
  45. package/src/components/ui/sidebar.tsx +723 -0
  46. package/src/components/ui/skeleton.tsx +13 -0
  47. package/src/components/ui/slider.tsx +59 -0
  48. package/src/components/ui/sonner.tsx +49 -0
  49. package/src/components/ui/spinner.tsx +10 -0
  50. package/src/components/ui/switch.tsx +32 -0
  51. package/src/components/ui/table.tsx +116 -0
  52. package/src/components/ui/tabs.tsx +82 -0
  53. package/src/components/ui/textarea.tsx +18 -0
  54. package/src/components/ui/toggle-group.tsx +89 -0
  55. package/src/components/ui/toggle.tsx +44 -0
  56. package/src/components/ui/tooltip.tsx +66 -0
  57. package/src/hooks/use-mobile.ts +19 -0
  58. package/src/lib/utils.ts +25 -0
@@ -0,0 +1,158 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import { Button } from "@/components/ui/button"
8
+ import { Input } from "@/components/ui/input"
9
+ import { Textarea } from "@/components/ui/textarea"
10
+
11
+ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
12
+ return (
13
+ <div
14
+ data-slot="input-group"
15
+ role="group"
16
+ className={cn(
17
+ "border-input dark:bg-input/30 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-3 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
18
+ className
19
+ )}
20
+ {...props}
21
+ />
22
+ )
23
+ }
24
+
25
+ const inputGroupAddonVariants = cva(
26
+ "text-muted-foreground h-auto gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4 flex cursor-text items-center justify-center select-none",
27
+ {
28
+ variants: {
29
+ align: {
30
+ "inline-start":
31
+ "pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem] order-first",
32
+ "inline-end":
33
+ "pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem] order-last",
34
+ "block-start":
35
+ "px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start",
36
+ "block-end":
37
+ "px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start",
38
+ },
39
+ },
40
+ defaultVariants: {
41
+ align: "inline-start",
42
+ },
43
+ }
44
+ )
45
+
46
+ function InputGroupAddon({
47
+ className,
48
+ align = "inline-start",
49
+ ...props
50
+ }: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
51
+ return (
52
+ <div
53
+ role="group"
54
+ data-slot="input-group-addon"
55
+ data-align={align}
56
+ className={cn(inputGroupAddonVariants({ align }), className)}
57
+ onClick={(e) => {
58
+ if ((e.target as HTMLElement).closest("button")) {
59
+ return
60
+ }
61
+ e.currentTarget.parentElement?.querySelector("input")?.focus()
62
+ }}
63
+ {...props}
64
+ />
65
+ )
66
+ }
67
+
68
+ const inputGroupButtonVariants = cva(
69
+ "gap-2 text-sm shadow-none flex items-center",
70
+ {
71
+ variants: {
72
+ size: {
73
+ xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
74
+ sm: "",
75
+ "icon-xs":
76
+ "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
77
+ "icon-sm": "size-8 p-0 has-[>svg]:p-0",
78
+ },
79
+ },
80
+ defaultVariants: {
81
+ size: "xs",
82
+ },
83
+ }
84
+ )
85
+
86
+ function InputGroupButton({
87
+ className,
88
+ type = "button",
89
+ variant = "ghost",
90
+ size = "xs",
91
+ ...props
92
+ }: Omit<React.ComponentProps<typeof Button>, "size" | "type"> &
93
+ VariantProps<typeof inputGroupButtonVariants> & {
94
+ type?: "button" | "submit" | "reset"
95
+ }) {
96
+ return (
97
+ <Button
98
+ type={type}
99
+ data-size={size}
100
+ variant={variant}
101
+ className={cn(inputGroupButtonVariants({ size }), className)}
102
+ {...props}
103
+ />
104
+ )
105
+ }
106
+
107
+ function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
108
+ return (
109
+ <span
110
+ className={cn(
111
+ "text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
112
+ className
113
+ )}
114
+ {...props}
115
+ />
116
+ )
117
+ }
118
+
119
+ function InputGroupInput({
120
+ className,
121
+ ...props
122
+ }: React.ComponentProps<"input">) {
123
+ return (
124
+ <Input
125
+ data-slot="input-group-control"
126
+ className={cn(
127
+ "flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",
128
+ className
129
+ )}
130
+ {...props}
131
+ />
132
+ )
133
+ }
134
+
135
+ function InputGroupTextarea({
136
+ className,
137
+ ...props
138
+ }: React.ComponentProps<"textarea">) {
139
+ return (
140
+ <Textarea
141
+ data-slot="input-group-control"
142
+ className={cn(
143
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",
144
+ className
145
+ )}
146
+ {...props}
147
+ />
148
+ )
149
+ }
150
+
151
+ export {
152
+ InputGroup,
153
+ InputGroupAddon,
154
+ InputGroupButton,
155
+ InputGroupText,
156
+ InputGroupInput,
157
+ InputGroupTextarea,
158
+ }
@@ -0,0 +1,87 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { OTPInput, OTPInputContext } from "input-otp"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import { MinusIcon } from "lucide-react"
8
+
9
+ function InputOTP({
10
+ className,
11
+ containerClassName,
12
+ ...props
13
+ }: React.ComponentProps<typeof OTPInput> & {
14
+ containerClassName?: string
15
+ }) {
16
+ return (
17
+ <OTPInput
18
+ data-slot="input-otp"
19
+ containerClassName={cn(
20
+ "cn-input-otp flex items-center has-disabled:opacity-50",
21
+ containerClassName
22
+ )}
23
+ spellCheck={false}
24
+ className={cn("disabled:cursor-not-allowed", className)}
25
+ {...props}
26
+ />
27
+ )
28
+ }
29
+
30
+ function InputOTPGroup({ className, ...props }: React.ComponentProps<"div">) {
31
+ return (
32
+ <div
33
+ data-slot="input-otp-group"
34
+ className={cn(
35
+ "has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive flex items-center rounded-md has-aria-invalid:ring-3",
36
+ className
37
+ )}
38
+ {...props}
39
+ />
40
+ )
41
+ }
42
+
43
+ function InputOTPSlot({
44
+ index,
45
+ className,
46
+ ...props
47
+ }: React.ComponentProps<"div"> & {
48
+ index: number
49
+ }) {
50
+ const inputOTPContext = React.useContext(OTPInputContext)
51
+ const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}
52
+
53
+ return (
54
+ <div
55
+ data-slot="input-otp-slot"
56
+ data-active={isActive}
57
+ className={cn(
58
+ "dark:bg-input/30 border-input data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive relative flex size-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-3",
59
+ className
60
+ )}
61
+ {...props}
62
+ >
63
+ {char}
64
+ {hasFakeCaret && (
65
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
66
+ <div className="animate-caret-blink bg-foreground h-4 w-px duration-1000" />
67
+ </div>
68
+ )}
69
+ </div>
70
+ )
71
+ }
72
+
73
+ function InputOTPSeparator({ ...props }: React.ComponentProps<"div">) {
74
+ return (
75
+ <div
76
+ data-slot="input-otp-separator"
77
+ className="flex items-center [&_svg:not([class*='size-'])]:size-4"
78
+ role="separator"
79
+ {...props}
80
+ >
81
+ <MinusIcon
82
+ />
83
+ </div>
84
+ )
85
+ }
86
+
87
+ export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
@@ -0,0 +1,20 @@
1
+ import * as React from "react"
2
+ import { Input as InputPrimitive } from "@base-ui/react/input"
3
+
4
+ import { cn } from "@/lib/utils"
5
+
6
+ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
7
+ return (
8
+ <InputPrimitive
9
+ type={type}
10
+ data-slot="input"
11
+ className={cn(
12
+ "dark:bg-input/30 border-input 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:aria-invalid:border-destructive/50 file:text-foreground placeholder:text-muted-foreground h-9 w-full min-w-0 rounded-md border bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 md:text-sm",
13
+ className
14
+ )}
15
+ {...props}
16
+ />
17
+ )
18
+ }
19
+
20
+ export { Input }
@@ -0,0 +1,201 @@
1
+ import * as React from "react"
2
+ import { mergeProps } from "@base-ui/react/merge-props"
3
+ import { useRender } from "@base-ui/react/use-render"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import { Separator } from "@/components/ui/separator"
8
+
9
+ function ItemGroup({ className, ...props }: React.ComponentProps<"div">) {
10
+ return (
11
+ <div
12
+ role="list"
13
+ data-slot="item-group"
14
+ className={cn(
15
+ "group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2",
16
+ className
17
+ )}
18
+ {...props}
19
+ />
20
+ )
21
+ }
22
+
23
+ function ItemSeparator({
24
+ className,
25
+ ...props
26
+ }: React.ComponentProps<typeof Separator>) {
27
+ return (
28
+ <Separator
29
+ data-slot="item-separator"
30
+ orientation="horizontal"
31
+ className={cn("my-2", className)}
32
+ {...props}
33
+ />
34
+ )
35
+ }
36
+
37
+ const itemVariants = cva(
38
+ "[a]:hover:bg-muted rounded-md border text-sm w-full group/item focus-visible:border-ring focus-visible:ring-ring/50 flex items-center flex-wrap outline-none transition-colors duration-100 focus-visible:ring-[3px] [a]:transition-colors",
39
+ {
40
+ variants: {
41
+ variant: {
42
+ default: "border-transparent",
43
+ outline: "border-border",
44
+ muted: "bg-muted/50 border-transparent",
45
+ },
46
+ size: {
47
+ default: "gap-3.5 px-4 py-3.5",
48
+ sm: "gap-2.5 px-3 py-2.5",
49
+ xs: "gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0",
50
+ },
51
+ },
52
+ defaultVariants: {
53
+ variant: "default",
54
+ size: "default",
55
+ },
56
+ }
57
+ )
58
+
59
+ function Item({
60
+ className,
61
+ variant = "default",
62
+ size = "default",
63
+ render,
64
+ ...props
65
+ }: useRender.ComponentProps<"div"> & VariantProps<typeof itemVariants>) {
66
+ return useRender({
67
+ defaultTagName: "div",
68
+ props: mergeProps<"div">(
69
+ {
70
+ className: cn(itemVariants({ variant, size, className })),
71
+ },
72
+ props
73
+ ),
74
+ render,
75
+ state: {
76
+ slot: "item",
77
+ variant,
78
+ size,
79
+ },
80
+ })
81
+ }
82
+
83
+ const itemMediaVariants = cva(
84
+ "gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start flex shrink-0 items-center justify-center [&_svg]:pointer-events-none",
85
+ {
86
+ variants: {
87
+ variant: {
88
+ default: "bg-transparent",
89
+ icon: "[&_svg:not([class*='size-'])]:size-4",
90
+ image:
91
+ "size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover",
92
+ },
93
+ },
94
+ defaultVariants: {
95
+ variant: "default",
96
+ },
97
+ }
98
+ )
99
+
100
+ function ItemMedia({
101
+ className,
102
+ variant = "default",
103
+ ...props
104
+ }: React.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>) {
105
+ return (
106
+ <div
107
+ data-slot="item-media"
108
+ data-variant={variant}
109
+ className={cn(itemMediaVariants({ variant, className }))}
110
+ {...props}
111
+ />
112
+ )
113
+ }
114
+
115
+ function ItemContent({ className, ...props }: React.ComponentProps<"div">) {
116
+ return (
117
+ <div
118
+ data-slot="item-content"
119
+ className={cn(
120
+ "flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none",
121
+ className
122
+ )}
123
+ {...props}
124
+ />
125
+ )
126
+ }
127
+
128
+ function ItemTitle({ className, ...props }: React.ComponentProps<"div">) {
129
+ return (
130
+ <div
131
+ data-slot="item-title"
132
+ className={cn(
133
+ "line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4",
134
+ className
135
+ )}
136
+ {...props}
137
+ />
138
+ )
139
+ }
140
+
141
+ function ItemDescription({ className, ...props }: React.ComponentProps<"p">) {
142
+ return (
143
+ <p
144
+ data-slot="item-description"
145
+ className={cn(
146
+ "text-muted-foreground [&>a:hover]:text-primary line-clamp-2 text-left text-sm leading-normal font-normal group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4",
147
+ className
148
+ )}
149
+ {...props}
150
+ />
151
+ )
152
+ }
153
+
154
+ function ItemActions({ className, ...props }: React.ComponentProps<"div">) {
155
+ return (
156
+ <div
157
+ data-slot="item-actions"
158
+ className={cn("flex items-center gap-2", className)}
159
+ {...props}
160
+ />
161
+ )
162
+ }
163
+
164
+ function ItemHeader({ className, ...props }: React.ComponentProps<"div">) {
165
+ return (
166
+ <div
167
+ data-slot="item-header"
168
+ className={cn(
169
+ "flex basis-full items-center justify-between gap-2",
170
+ className
171
+ )}
172
+ {...props}
173
+ />
174
+ )
175
+ }
176
+
177
+ function ItemFooter({ className, ...props }: React.ComponentProps<"div">) {
178
+ return (
179
+ <div
180
+ data-slot="item-footer"
181
+ className={cn(
182
+ "flex basis-full items-center justify-between gap-2",
183
+ className
184
+ )}
185
+ {...props}
186
+ />
187
+ )
188
+ }
189
+
190
+ export {
191
+ Item,
192
+ ItemMedia,
193
+ ItemContent,
194
+ ItemActions,
195
+ ItemGroup,
196
+ ItemSeparator,
197
+ ItemTitle,
198
+ ItemDescription,
199
+ ItemHeader,
200
+ ItemFooter,
201
+ }
@@ -0,0 +1,26 @@
1
+ import { cn } from "@/lib/utils"
2
+
3
+ function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
4
+ return (
5
+ <kbd
6
+ data-slot="kbd"
7
+ className={cn(
8
+ "bg-muted text-muted-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none [&_svg:not([class*='size-'])]:size-3",
9
+ className
10
+ )}
11
+ {...props}
12
+ />
13
+ )
14
+ }
15
+
16
+ function KbdGroup({ className, ...props }: React.ComponentProps<"div">) {
17
+ return (
18
+ <kbd
19
+ data-slot="kbd-group"
20
+ className={cn("inline-flex items-center gap-1", className)}
21
+ {...props}
22
+ />
23
+ )
24
+ }
25
+
26
+ export { Kbd, KbdGroup }
@@ -0,0 +1,20 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+
5
+ import { cn } from "@/lib/utils"
6
+
7
+ function Label({ className, ...props }: React.ComponentProps<"label">) {
8
+ return (
9
+ <label
10
+ data-slot="label"
11
+ className={cn(
12
+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
13
+ className
14
+ )}
15
+ {...props}
16
+ />
17
+ )
18
+ }
19
+
20
+ export { Label }