@vendure/dashboard 3.3.6-master-202507030835 → 3.3.6-master-202507031127

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