@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,297 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Combobox as ComboboxPrimitive } from "@base-ui/react"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import { Button } from "@/components/ui/button"
8
+ import {
9
+ InputGroup,
10
+ InputGroupAddon,
11
+ InputGroupButton,
12
+ InputGroupInput,
13
+ } from "@/components/ui/input-group"
14
+ import { ChevronDownIcon, XIcon, CheckIcon } from "lucide-react"
15
+
16
+ const Combobox = ComboboxPrimitive.Root
17
+
18
+ function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
19
+ return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />
20
+ }
21
+
22
+ function ComboboxTrigger({
23
+ className,
24
+ children,
25
+ ...props
26
+ }: ComboboxPrimitive.Trigger.Props) {
27
+ return (
28
+ <ComboboxPrimitive.Trigger
29
+ data-slot="combobox-trigger"
30
+ className={cn("[&_svg:not([class*='size-'])]:size-4", className)}
31
+ {...props}
32
+ >
33
+ {children}
34
+ <ChevronDownIcon className="text-muted-foreground pointer-events-none size-4" />
35
+ </ComboboxPrimitive.Trigger>
36
+ )
37
+ }
38
+
39
+ function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {
40
+ return (
41
+ <ComboboxPrimitive.Clear
42
+ data-slot="combobox-clear"
43
+ render={<InputGroupButton variant="ghost" size="icon-xs" />}
44
+ className={cn(className)}
45
+ {...props}
46
+ >
47
+ <XIcon className="pointer-events-none" />
48
+ </ComboboxPrimitive.Clear>
49
+ )
50
+ }
51
+
52
+ function ComboboxInput({
53
+ className,
54
+ children,
55
+ disabled = false,
56
+ showTrigger = true,
57
+ showClear = false,
58
+ ...props
59
+ }: ComboboxPrimitive.Input.Props & {
60
+ showTrigger?: boolean
61
+ showClear?: boolean
62
+ }) {
63
+ return (
64
+ <InputGroup className={cn("w-auto", className)}>
65
+ <ComboboxPrimitive.Input
66
+ render={<InputGroupInput disabled={disabled} />}
67
+ {...props}
68
+ />
69
+ <InputGroupAddon align="inline-end">
70
+ {showTrigger && (
71
+ <InputGroupButton
72
+ size="icon-xs"
73
+ variant="ghost"
74
+ render={<ComboboxTrigger />}
75
+ data-slot="input-group-button"
76
+ className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"
77
+ disabled={disabled}
78
+ />
79
+ )}
80
+ {showClear && <ComboboxClear disabled={disabled} />}
81
+ </InputGroupAddon>
82
+ {children}
83
+ </InputGroup>
84
+ )
85
+ }
86
+
87
+ function ComboboxContent({
88
+ className,
89
+ side = "bottom",
90
+ sideOffset = 6,
91
+ align = "start",
92
+ alignOffset = 0,
93
+ anchor,
94
+ ...props
95
+ }: ComboboxPrimitive.Popup.Props &
96
+ Pick<
97
+ ComboboxPrimitive.Positioner.Props,
98
+ "side" | "align" | "sideOffset" | "alignOffset" | "anchor"
99
+ >) {
100
+ return (
101
+ <ComboboxPrimitive.Portal>
102
+ <ComboboxPrimitive.Positioner
103
+ side={side}
104
+ sideOffset={sideOffset}
105
+ align={align}
106
+ alignOffset={alignOffset}
107
+ anchor={anchor}
108
+ className="isolate z-50"
109
+ >
110
+ <ComboboxPrimitive.Popup
111
+ data-slot="combobox-content"
112
+ data-chips={!!anchor}
113
+ className={cn("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-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 ring-foreground/10 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:border-input/30 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md shadow-md ring-1 duration-100 data-[chips=true]:min-w-(--anchor-width) *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:shadow-none", className )}
114
+ {...props}
115
+ />
116
+ </ComboboxPrimitive.Positioner>
117
+ </ComboboxPrimitive.Portal>
118
+ )
119
+ }
120
+
121
+ function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
122
+ return (
123
+ <ComboboxPrimitive.List
124
+ data-slot="combobox-list"
125
+ className={cn(
126
+ "no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
127
+ className
128
+ )}
129
+ {...props}
130
+ />
131
+ )
132
+ }
133
+
134
+ function ComboboxItem({
135
+ className,
136
+ children,
137
+ ...props
138
+ }: ComboboxPrimitive.Item.Props) {
139
+ return (
140
+ <ComboboxPrimitive.Item
141
+ data-slot="combobox-item"
142
+ className={cn(
143
+ "data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-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",
144
+ className
145
+ )}
146
+ {...props}
147
+ >
148
+ {children}
149
+ <ComboboxPrimitive.ItemIndicator
150
+ render={
151
+ <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
152
+ }
153
+ >
154
+ <CheckIcon className="pointer-events-none" />
155
+ </ComboboxPrimitive.ItemIndicator>
156
+ </ComboboxPrimitive.Item>
157
+ )
158
+ }
159
+
160
+ function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
161
+ return (
162
+ <ComboboxPrimitive.Group
163
+ data-slot="combobox-group"
164
+ className={cn(className)}
165
+ {...props}
166
+ />
167
+ )
168
+ }
169
+
170
+ function ComboboxLabel({
171
+ className,
172
+ ...props
173
+ }: ComboboxPrimitive.GroupLabel.Props) {
174
+ return (
175
+ <ComboboxPrimitive.GroupLabel
176
+ data-slot="combobox-label"
177
+ className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
178
+ {...props}
179
+ />
180
+ )
181
+ }
182
+
183
+ function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
184
+ return (
185
+ <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
186
+ )
187
+ }
188
+
189
+ function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
190
+ return (
191
+ <ComboboxPrimitive.Empty
192
+ data-slot="combobox-empty"
193
+ className={cn(
194
+ "text-muted-foreground hidden w-full justify-center py-2 text-center text-sm group-data-empty/combobox-content:flex",
195
+ className
196
+ )}
197
+ {...props}
198
+ />
199
+ )
200
+ }
201
+
202
+ function ComboboxSeparator({
203
+ className,
204
+ ...props
205
+ }: ComboboxPrimitive.Separator.Props) {
206
+ return (
207
+ <ComboboxPrimitive.Separator
208
+ data-slot="combobox-separator"
209
+ className={cn("bg-border -mx-1 my-1 h-px", className)}
210
+ {...props}
211
+ />
212
+ )
213
+ }
214
+
215
+ function ComboboxChips({
216
+ className,
217
+ ...props
218
+ }: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> &
219
+ ComboboxPrimitive.Chips.Props) {
220
+ return (
221
+ <ComboboxPrimitive.Chips
222
+ data-slot="combobox-chips"
223
+ className={cn(
224
+ "dark:bg-input/30 border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive dark:has-aria-invalid:border-destructive/50 flex min-h-9 flex-wrap items-center gap-1.5 rounded-md border bg-transparent bg-clip-padding px-2.5 py-1.5 text-sm shadow-xs transition-[color,box-shadow] focus-within:ring-3 has-aria-invalid:ring-3 has-data-[slot=combobox-chip]:px-1.5",
225
+ className
226
+ )}
227
+ {...props}
228
+ />
229
+ )
230
+ }
231
+
232
+ function ComboboxChip({
233
+ className,
234
+ children,
235
+ showRemove = true,
236
+ ...props
237
+ }: ComboboxPrimitive.Chip.Props & {
238
+ showRemove?: boolean
239
+ }) {
240
+ return (
241
+ <ComboboxPrimitive.Chip
242
+ data-slot="combobox-chip"
243
+ className={cn(
244
+ "bg-muted text-foreground flex h-[calc(--spacing(5.5))] w-fit items-center justify-center gap-1 rounded-sm px-1.5 text-xs font-medium whitespace-nowrap has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
245
+ className
246
+ )}
247
+ {...props}
248
+ >
249
+ {children}
250
+ {showRemove && (
251
+ <ComboboxPrimitive.ChipRemove
252
+ render={<Button variant="ghost" size="icon-xs" />}
253
+ className="-ml-1 opacity-50 hover:opacity-100"
254
+ data-slot="combobox-chip-remove"
255
+ >
256
+ <XIcon className="pointer-events-none" />
257
+ </ComboboxPrimitive.ChipRemove>
258
+ )}
259
+ </ComboboxPrimitive.Chip>
260
+ )
261
+ }
262
+
263
+ function ComboboxChipsInput({
264
+ className,
265
+ ...props
266
+ }: ComboboxPrimitive.Input.Props) {
267
+ return (
268
+ <ComboboxPrimitive.Input
269
+ data-slot="combobox-chip-input"
270
+ className={cn("min-w-16 flex-1 outline-none", className)}
271
+ {...props}
272
+ />
273
+ )
274
+ }
275
+
276
+ function useComboboxAnchor() {
277
+ return React.useRef<HTMLDivElement | null>(null)
278
+ }
279
+
280
+ export {
281
+ Combobox,
282
+ ComboboxInput,
283
+ ComboboxContent,
284
+ ComboboxList,
285
+ ComboboxItem,
286
+ ComboboxGroup,
287
+ ComboboxLabel,
288
+ ComboboxCollection,
289
+ ComboboxEmpty,
290
+ ComboboxSeparator,
291
+ ComboboxChips,
292
+ ComboboxChip,
293
+ ComboboxChipsInput,
294
+ ComboboxTrigger,
295
+ ComboboxValue,
296
+ useComboboxAnchor,
297
+ }
@@ -0,0 +1,196 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Command as CommandPrimitive } from "cmdk"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import {
8
+ Dialog,
9
+ DialogContent,
10
+ DialogDescription,
11
+ DialogHeader,
12
+ DialogTitle,
13
+ } from "@/components/ui/dialog"
14
+ import {
15
+ InputGroup,
16
+ InputGroupAddon,
17
+ } from "@/components/ui/input-group"
18
+ import { SearchIcon, CheckIcon } from "lucide-react"
19
+
20
+ function Command({
21
+ className,
22
+ ...props
23
+ }: React.ComponentProps<typeof CommandPrimitive>) {
24
+ return (
25
+ <CommandPrimitive
26
+ data-slot="command"
27
+ className={cn(
28
+ "bg-popover text-popover-foreground flex size-full flex-col overflow-hidden rounded-xl! p-1",
29
+ className
30
+ )}
31
+ {...props}
32
+ />
33
+ )
34
+ }
35
+
36
+ function CommandDialog({
37
+ title = "Command Palette",
38
+ description = "Search for a command to run...",
39
+ children,
40
+ className,
41
+ showCloseButton = false,
42
+ ...props
43
+ }: Omit<React.ComponentProps<typeof Dialog>, "children"> & {
44
+ title?: string
45
+ description?: string
46
+ className?: string
47
+ showCloseButton?: boolean
48
+ children: React.ReactNode
49
+ }) {
50
+ return (
51
+ <Dialog {...props}>
52
+ <DialogHeader className="sr-only">
53
+ <DialogTitle>{title}</DialogTitle>
54
+ <DialogDescription>{description}</DialogDescription>
55
+ </DialogHeader>
56
+ <DialogContent
57
+ className={cn(
58
+ "top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",
59
+ className
60
+ )}
61
+ showCloseButton={showCloseButton}
62
+ >
63
+ {children}
64
+ </DialogContent>
65
+ </Dialog>
66
+ )
67
+ }
68
+
69
+ function CommandInput({
70
+ className,
71
+ ...props
72
+ }: React.ComponentProps<typeof CommandPrimitive.Input>) {
73
+ return (
74
+ <div data-slot="command-input-wrapper" className="p-1 pb-0">
75
+ <InputGroup className="bg-input/30 border-input/30 h-8! rounded-lg! shadow-none! *:data-[slot=input-group-addon]:pl-2!">
76
+ <CommandPrimitive.Input
77
+ data-slot="command-input"
78
+ className={cn(
79
+ "w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
80
+ className
81
+ )}
82
+ {...props}
83
+ />
84
+ <InputGroupAddon>
85
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
86
+ </InputGroupAddon>
87
+ </InputGroup>
88
+ </div>
89
+ )
90
+ }
91
+
92
+ function CommandList({
93
+ className,
94
+ ...props
95
+ }: React.ComponentProps<typeof CommandPrimitive.List>) {
96
+ return (
97
+ <CommandPrimitive.List
98
+ data-slot="command-list"
99
+ className={cn(
100
+ "no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",
101
+ className
102
+ )}
103
+ {...props}
104
+ />
105
+ )
106
+ }
107
+
108
+ function CommandEmpty({
109
+ className,
110
+ ...props
111
+ }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
112
+ return (
113
+ <CommandPrimitive.Empty
114
+ data-slot="command-empty"
115
+ className={cn("py-6 text-center text-sm", className)}
116
+ {...props}
117
+ />
118
+ )
119
+ }
120
+
121
+ function CommandGroup({
122
+ className,
123
+ ...props
124
+ }: React.ComponentProps<typeof CommandPrimitive.Group>) {
125
+ return (
126
+ <CommandPrimitive.Group
127
+ data-slot="command-group"
128
+ className={cn(
129
+ "text-foreground **:[[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium",
130
+ className
131
+ )}
132
+ {...props}
133
+ />
134
+ )
135
+ }
136
+
137
+ function CommandSeparator({
138
+ className,
139
+ ...props
140
+ }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
141
+ return (
142
+ <CommandPrimitive.Separator
143
+ data-slot="command-separator"
144
+ className={cn("bg-border -mx-1 h-px w-auto", className)}
145
+ {...props}
146
+ />
147
+ )
148
+ }
149
+
150
+ function CommandItem({
151
+ className,
152
+ children,
153
+ ...props
154
+ }: React.ComponentProps<typeof CommandPrimitive.Item>) {
155
+ return (
156
+ <CommandPrimitive.Item
157
+ data-slot="command-item"
158
+ className={cn(
159
+ "data-selected:bg-muted data-selected:text-foreground data-selected:**:[svg]:text-foreground group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
160
+ className
161
+ )}
162
+ {...props}
163
+ >
164
+ {children}
165
+ <CheckIcon className="ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" />
166
+ </CommandPrimitive.Item>
167
+ )
168
+ }
169
+
170
+ function CommandShortcut({
171
+ className,
172
+ ...props
173
+ }: React.ComponentProps<"span">) {
174
+ return (
175
+ <span
176
+ data-slot="command-shortcut"
177
+ className={cn(
178
+ "text-muted-foreground group-data-selected/command-item:text-foreground ml-auto text-xs tracking-widest",
179
+ className
180
+ )}
181
+ {...props}
182
+ />
183
+ )
184
+ }
185
+
186
+ export {
187
+ Command,
188
+ CommandDialog,
189
+ CommandInput,
190
+ CommandList,
191
+ CommandEmpty,
192
+ CommandGroup,
193
+ CommandItem,
194
+ CommandShortcut,
195
+ CommandSeparator,
196
+ }