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

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 (67) hide show
  1. package/dist/plugin/vite-plugin-vendure-dashboard.js +1 -1
  2. package/package.json +40 -27
  3. package/src/app/routes/_authenticated/_collections/collections.graphql.ts +32 -0
  4. package/src/app/routes/_authenticated/_collections/collections.tsx +153 -133
  5. package/src/app/routes/_authenticated/_collections/collections_.$id.tsx +1 -1
  6. package/src/app/routes/_authenticated/_collections/components/collection-bulk-actions.tsx +34 -1
  7. package/src/app/routes/_authenticated/_collections/components/move-collections-dialog.tsx +430 -0
  8. package/src/app/routes/_authenticated/_collections/components/move-single-collection.tsx +33 -0
  9. package/src/app/routes/_authenticated/_customers/components/customer-address-card.tsx +8 -3
  10. package/src/app/routes/_authenticated/_payment-methods/payment-methods_.$id.tsx +1 -1
  11. package/src/app/routes/_authenticated/_products/products_.$id.tsx +1 -1
  12. package/src/app/routes/_authenticated/_promotions/promotions_.$id.tsx +1 -1
  13. package/src/lib/components/data-input/money-input.tsx +2 -9
  14. package/src/lib/components/data-table/data-table.tsx +1 -1
  15. package/src/lib/components/shared/form-field-wrapper.tsx +22 -13
  16. package/src/lib/components/shared/paginated-list-data-table.tsx +1 -1
  17. package/src/lib/components/ui/accordion.tsx +50 -45
  18. package/src/lib/components/ui/alert-dialog.tsx +122 -93
  19. package/src/lib/components/ui/alert.tsx +54 -48
  20. package/src/lib/components/ui/aspect-ratio.tsx +9 -0
  21. package/src/lib/components/ui/avatar.tsx +53 -0
  22. package/src/lib/components/ui/badge.tsx +37 -29
  23. package/src/lib/components/ui/breadcrumb.tsx +89 -82
  24. package/src/lib/components/ui/button.tsx +52 -51
  25. package/src/lib/components/ui/calendar.tsx +196 -435
  26. package/src/lib/components/ui/card.tsx +78 -33
  27. package/src/lib/components/ui/carousel.tsx +241 -0
  28. package/src/lib/components/ui/chart.tsx +351 -0
  29. package/src/lib/components/ui/checkbox.tsx +28 -23
  30. package/src/lib/components/ui/collapsible.tsx +0 -2
  31. package/src/lib/components/ui/command.tsx +159 -114
  32. package/src/lib/components/ui/context-menu.tsx +252 -0
  33. package/src/lib/components/ui/dialog.tsx +115 -90
  34. package/src/lib/components/ui/drawer.tsx +133 -0
  35. package/src/lib/components/ui/dropdown-menu.tsx +207 -170
  36. package/src/lib/components/ui/form.tsx +138 -114
  37. package/src/lib/components/ui/hover-card.tsx +32 -26
  38. package/src/lib/components/ui/input-otp.tsx +77 -0
  39. package/src/lib/components/ui/input.tsx +17 -15
  40. package/src/lib/components/ui/label.tsx +19 -16
  41. package/src/lib/components/ui/menubar.tsx +274 -0
  42. package/src/lib/components/ui/navigation-menu.tsx +168 -0
  43. package/src/lib/components/ui/pagination.tsx +108 -87
  44. package/src/lib/components/ui/popover.tsx +36 -28
  45. package/src/lib/components/ui/progress.tsx +29 -0
  46. package/src/lib/components/ui/radio-group.tsx +45 -0
  47. package/src/lib/components/ui/resizable.tsx +54 -0
  48. package/src/lib/components/ui/scroll-area.tsx +48 -40
  49. package/src/lib/components/ui/select.tsx +151 -129
  50. package/src/lib/components/ui/separator.tsx +22 -20
  51. package/src/lib/components/ui/sheet.tsx +110 -91
  52. package/src/lib/components/ui/sidebar.tsx +652 -622
  53. package/src/lib/components/ui/skeleton.tsx +10 -10
  54. package/src/lib/components/ui/slider.tsx +63 -0
  55. package/src/lib/components/ui/sonner.tsx +7 -11
  56. package/src/lib/components/ui/switch.tsx +27 -22
  57. package/src/lib/components/ui/table.tsx +96 -64
  58. package/src/lib/components/ui/tabs.tsx +56 -38
  59. package/src/lib/components/ui/textarea.tsx +14 -14
  60. package/src/lib/components/ui/toggle-group.tsx +73 -0
  61. package/src/lib/components/ui/toggle.tsx +45 -0
  62. package/src/lib/components/ui/tooltip.tsx +45 -37
  63. package/src/lib/framework/component-registry/component-registry.tsx +5 -3
  64. package/src/lib/framework/page/detail-page.tsx +28 -17
  65. package/src/lib/framework/page/list-page.tsx +1 -1
  66. package/src/lib/index.ts +5 -6
  67. package/vite/vite-plugin-vendure-dashboard.ts +1 -1
@@ -0,0 +1,351 @@
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
+ }
@@ -1,27 +1,32 @@
1
- import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
2
- import { CheckIcon } from 'lucide-react';
3
- import * as React from 'react';
1
+ "use client"
4
2
 
5
- import { cn } from '@/vdb/lib/utils.js';
3
+ import * as React from "react"
4
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
5
+ import { CheckIcon } from "lucide-react"
6
6
 
7
- function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
8
- return (
9
- <CheckboxPrimitive.Root
10
- data-slot="checkbox"
11
- className={cn(
12
- 'peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
13
- className,
14
- )}
15
- {...props}
16
- >
17
- <CheckboxPrimitive.Indicator
18
- data-slot="checkbox-indicator"
19
- className="flex items-center justify-center text-current transition-none"
20
- >
21
- <CheckIcon className="size-3.5" />
22
- </CheckboxPrimitive.Indicator>
23
- </CheckboxPrimitive.Root>
24
- );
7
+ import { cn } from "@/vdb/lib/utils"
8
+
9
+ function Checkbox({
10
+ className,
11
+ ...props
12
+ }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
13
+ return (
14
+ <CheckboxPrimitive.Root
15
+ data-slot="checkbox"
16
+ className={cn(
17
+ "peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
18
+ className
19
+ )}
20
+ {...props}
21
+ >
22
+ <CheckboxPrimitive.Indicator
23
+ data-slot="checkbox-indicator"
24
+ className="flex items-center justify-center text-current transition-none"
25
+ >
26
+ <CheckIcon className="size-3.5" />
27
+ </CheckboxPrimitive.Indicator>
28
+ </CheckboxPrimitive.Root>
29
+ )
25
30
  }
26
31
 
27
- export { Checkbox };
32
+ export { Checkbox }
@@ -1,5 +1,3 @@
1
- "use client"
2
-
3
1
  import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
4
2
 
5
3
  function Collapsible({