@vendure-io/ui 2.0.0-beta.9 → 2.0.0-rc.1
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.
- package/LICENSE.md +34 -0
- package/package.json +9 -7
- package/src/components/atoms/alert-dialog.tsx +1 -1
- package/src/components/atoms/alert.tsx +1 -1
- package/src/components/atoms/badge.tsx +1 -1
- package/src/components/atoms/button.tsx +2 -2
- package/src/components/atoms/card.tsx +39 -4
- package/src/components/atoms/checkbox.tsx +1 -1
- package/src/components/atoms/combobox.tsx +24 -5
- package/src/components/atoms/command.tsx +16 -5
- package/src/components/atoms/context-menu.tsx +1 -1
- package/src/components/atoms/dialog.tsx +1 -1
- package/src/components/atoms/drawer.tsx +134 -35
- package/src/components/atoms/dropdown-menu.tsx +1 -1
- package/src/components/atoms/field.tsx +2 -2
- package/src/components/atoms/input.tsx +1 -1
- package/src/components/atoms/item.tsx +4 -1
- package/src/components/atoms/menubar.tsx +1 -1
- package/src/components/atoms/native-select.tsx +1 -1
- package/src/components/atoms/navigation-menu.tsx +5 -2
- package/src/components/atoms/progress.tsx +1 -1
- package/src/components/atoms/radio-group.tsx +1 -1
- package/src/components/atoms/scroll-area.tsx +1 -2
- package/src/components/atoms/select.tsx +1 -1
- package/src/components/atoms/sheet.tsx +1 -1
- package/src/components/atoms/sidebar.tsx +6 -4
- package/src/components/atoms/slider.tsx +2 -2
- package/src/components/atoms/switch.tsx +1 -1
- package/src/components/atoms/table.tsx +34 -2
- package/src/components/atoms/tabs.tsx +64 -1
- package/src/components/atoms/textarea.tsx +1 -1
- package/src/components/atoms/toggle-group.tsx +1 -1
- package/src/components/atoms/toggle.tsx +5 -2
- package/src/components/molecules/chip.tsx +7 -2
- package/src/components/molecules/code-block/file-type-icons.tsx +123 -0
- package/src/components/molecules/code-block/process-code.ts +60 -0
- package/src/components/molecules/code-block/transform-command.tsx +177 -0
- package/src/components/molecules/code-block.tsx +25 -443
- package/src/components/molecules/combobox-free-text.tsx +23 -2
- package/src/components/molecules/copyable-text.tsx +14 -1
- package/src/components/molecules/data-table/data-table-bulk-actions.tsx +12 -13
- package/src/components/molecules/data-table/data-table-types.tsx +50 -2
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -1
- package/src/components/molecules/data-table/data-table.tsx +188 -96
- package/src/components/molecules/date-picker.tsx +3 -1
- package/src/components/molecules/date-range-picker.tsx +3 -1
- package/src/components/molecules/date-time-picker.tsx +3 -1
- package/src/components/molecules/file-dropzone.tsx +15 -5
- package/src/components/molecules/illustrations/empty-database.tsx +8 -5
- package/src/components/molecules/illustrations/error.tsx +19 -17
- package/src/components/molecules/illustrations/expired.tsx +55 -0
- package/src/components/molecules/illustrations/first-run.tsx +3 -1
- package/src/components/molecules/illustrations/no-activity.tsx +35 -14
- package/src/components/molecules/illustrations/no-customers.tsx +66 -0
- package/src/components/molecules/illustrations/no-documents.tsx +4 -3
- package/src/components/molecules/illustrations/no-invoices.tsx +45 -0
- package/src/components/molecules/illustrations/no-notifications.tsx +7 -8
- package/src/components/molecules/illustrations/no-orders.tsx +25 -17
- package/src/components/molecules/illustrations/no-plugins.tsx +21 -31
- package/src/components/molecules/illustrations/no-products.tsx +53 -0
- package/src/components/molecules/illustrations/no-projects.tsx +54 -0
- package/src/components/molecules/illustrations/no-promotions.tsx +49 -0
- package/src/components/molecules/illustrations/no-subscription.tsx +72 -0
- package/src/components/molecules/illustrations/not-found.tsx +17 -15
- package/src/components/molecules/illustrations/offline.tsx +12 -10
- package/src/components/molecules/illustrations/payment-failed.tsx +53 -0
- package/src/components/molecules/illustrations/success.tsx +43 -0
- package/src/components/molecules/inline-code.tsx +26 -0
- package/src/components/molecules/page-header.tsx +7 -3
- package/src/components/molecules/stat-card.tsx +13 -12
- package/src/components/molecules/state-views/empty-state.tsx +12 -1
- package/src/components/molecules/state-views/loading-state.tsx +7 -3
- package/src/lib/highlight.ts +37 -1
- package/src/lib/state-dictionary.ts +18 -5
- package/src/lib/utils.ts +0 -19
|
@@ -1,43 +1,100 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import * as React from "react"
|
|
4
|
-
import { Drawer as DrawerPrimitive } from "
|
|
4
|
+
import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
7
|
|
|
8
|
+
// Follows the shadcn base-vega Base UI drawer (upstream replaced vaul, which
|
|
9
|
+
// depends on Radix). Divergences: the scrim and surface use the scrim and
|
|
10
|
+
// overlay slots, the title uses our type style, and reduced motion turns the
|
|
11
|
+
// transitions off.
|
|
12
|
+
|
|
13
|
+
type DrawerContextProps = {
|
|
14
|
+
hasSnapPoints: boolean
|
|
15
|
+
modal: DrawerPrimitive.Root.Props["modal"]
|
|
16
|
+
showSwipeHandle: boolean
|
|
17
|
+
swipeDirection: NonNullable<DrawerPrimitive.Root.Props["swipeDirection"]>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const DrawerContext = React.createContext<DrawerContextProps | null>(null)
|
|
21
|
+
|
|
22
|
+
function useDrawer() {
|
|
23
|
+
const context = React.useContext(DrawerContext)
|
|
24
|
+
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error("useDrawer must be used within a Drawer.")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return context
|
|
30
|
+
}
|
|
31
|
+
|
|
8
32
|
function Drawer({
|
|
33
|
+
modal = true,
|
|
34
|
+
showSwipeHandle = false,
|
|
35
|
+
snapPoints,
|
|
36
|
+
swipeDirection = "down",
|
|
9
37
|
...props
|
|
10
|
-
}:
|
|
11
|
-
|
|
38
|
+
}: DrawerPrimitive.Root.Props & {
|
|
39
|
+
showSwipeHandle?: boolean
|
|
40
|
+
}) {
|
|
41
|
+
const hasSnapPoints = snapPoints != null && snapPoints.length > 0
|
|
42
|
+
const contextValue = React.useMemo(
|
|
43
|
+
() => ({ hasSnapPoints, modal, showSwipeHandle, swipeDirection }),
|
|
44
|
+
[hasSnapPoints, modal, showSwipeHandle, swipeDirection]
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<DrawerContext.Provider value={contextValue}>
|
|
49
|
+
<DrawerPrimitive.Root
|
|
50
|
+
data-slot="drawer"
|
|
51
|
+
modal={modal}
|
|
52
|
+
snapPoints={snapPoints}
|
|
53
|
+
swipeDirection={swipeDirection}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
</DrawerContext.Provider>
|
|
57
|
+
)
|
|
12
58
|
}
|
|
13
59
|
|
|
14
|
-
function DrawerTrigger({
|
|
15
|
-
...props
|
|
16
|
-
}: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {
|
|
60
|
+
function DrawerTrigger({ ...props }: DrawerPrimitive.Trigger.Props) {
|
|
17
61
|
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />
|
|
18
62
|
}
|
|
19
63
|
|
|
20
|
-
function DrawerPortal({
|
|
21
|
-
...props
|
|
22
|
-
}: React.ComponentProps<typeof DrawerPrimitive.Portal>) {
|
|
64
|
+
function DrawerPortal({ ...props }: DrawerPrimitive.Portal.Props) {
|
|
23
65
|
return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />
|
|
24
66
|
}
|
|
25
67
|
|
|
26
|
-
function DrawerClose({
|
|
27
|
-
...props
|
|
28
|
-
}: React.ComponentProps<typeof DrawerPrimitive.Close>) {
|
|
68
|
+
function DrawerClose({ ...props }: DrawerPrimitive.Close.Props) {
|
|
29
69
|
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />
|
|
30
70
|
}
|
|
31
71
|
|
|
32
72
|
function DrawerOverlay({
|
|
33
73
|
className,
|
|
34
74
|
...props
|
|
35
|
-
}:
|
|
75
|
+
}: DrawerPrimitive.Backdrop.Props) {
|
|
36
76
|
return (
|
|
37
|
-
<DrawerPrimitive.
|
|
77
|
+
<DrawerPrimitive.Backdrop
|
|
38
78
|
data-slot="drawer-overlay"
|
|
39
79
|
className={cn(
|
|
40
|
-
"
|
|
80
|
+
"fixed inset-0 z-50 min-h-dvh bg-scrim opacity-[max(var(--drawer-overlay-min-opacity,0),calc(1-var(--drawer-swipe-progress)))] transition-opacity duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] select-none data-ending-style:pointer-events-none data-ending-style:opacity-0 data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-snap-points:[--drawer-overlay-min-opacity:0.5] data-starting-style:opacity-0 data-swiping:duration-0 supports-backdrop-filter:backdrop-blur-xs supports-[-webkit-touch-callout:none]:absolute motion-reduce:transition-none",
|
|
81
|
+
className
|
|
82
|
+
)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function DrawerSwipeHandle({
|
|
89
|
+
className,
|
|
90
|
+
...props
|
|
91
|
+
}: React.ComponentProps<"div">) {
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
data-slot="drawer-swipe-handle"
|
|
95
|
+
aria-hidden="true"
|
|
96
|
+
className={cn(
|
|
97
|
+
"relative z-10 flex shrink-0 cursor-grab transition-opacity duration-200 group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-[swipe-axis=x]/drawer-popup:h-full group-data-[swipe-axis=x]/drawer-popup:w-3 group-data-[swipe-axis=x]/drawer-popup:items-center group-data-[swipe-axis=y]/drawer-popup:h-3 group-data-[swipe-axis=y]/drawer-popup:w-full group-data-[swipe-axis=y]/drawer-popup:justify-center group-data-[swipe-direction=down]/drawer-popup:items-end group-data-[swipe-direction=left]/drawer-popup:order-last group-data-[swipe-direction=left]/drawer-popup:justify-start group-data-[swipe-direction=right]/drawer-popup:justify-end group-data-[swipe-direction=up]/drawer-popup:order-last group-data-[swipe-direction=up]/drawer-popup:items-start after:block after:shrink-0 after:rounded-full after:bg-muted group-data-[swipe-axis=x]/drawer-popup:after:h-[100px] group-data-[swipe-axis=x]/drawer-popup:after:w-1.5 group-data-[swipe-axis=y]/drawer-popup:after:h-1.5 group-data-[swipe-axis=y]/drawer-popup:after:w-[100px] active:cursor-grabbing",
|
|
41
98
|
className
|
|
42
99
|
)}
|
|
43
100
|
{...props}
|
|
@@ -49,21 +106,65 @@ function DrawerContent({
|
|
|
49
106
|
className,
|
|
50
107
|
children,
|
|
51
108
|
...props
|
|
52
|
-
}:
|
|
109
|
+
}: DrawerPrimitive.Popup.Props) {
|
|
110
|
+
const { hasSnapPoints, modal, showSwipeHandle, swipeDirection } = useDrawer()
|
|
111
|
+
const swipeAxis =
|
|
112
|
+
swipeDirection === "down" || swipeDirection === "up" ? "y" : "x"
|
|
113
|
+
|
|
53
114
|
return (
|
|
54
115
|
<DrawerPortal data-slot="drawer-portal">
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{...props}
|
|
116
|
+
{modal === true && (
|
|
117
|
+
<DrawerOverlay data-snap-points={hasSnapPoints ? "" : undefined} />
|
|
118
|
+
)}
|
|
119
|
+
<DrawerPrimitive.Viewport
|
|
120
|
+
data-slot="drawer-viewport"
|
|
121
|
+
data-modal={modal}
|
|
122
|
+
className="pointer-events-none fixed inset-0 z-50 select-none data-[modal=true]:pointer-events-auto"
|
|
63
123
|
>
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
124
|
+
<DrawerPrimitive.Popup
|
|
125
|
+
data-slot="drawer-popup"
|
|
126
|
+
data-swipe-axis={swipeAxis}
|
|
127
|
+
data-snap-points={hasSnapPoints ? "" : undefined}
|
|
128
|
+
className={cn(
|
|
129
|
+
// Base.
|
|
130
|
+
"group/drawer-popup pointer-events-auto fixed z-50 m-(--drawer-inset,0px) flex h-(--drawer-content-height) max-h-(--drawer-content-max-height,none) min-h-0 w-(--drawer-content-width,auto) transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] flex-col bg-overlay text-sm text-popover-foreground transition-[transform,height,opacity,filter] duration-450 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform outline-none select-none [interpolate-size:allow-keywords] data-[swipe-direction=down]:rounded-t-xl data-[swipe-direction=down]:border-t data-[swipe-direction=left]:rounded-r-xl data-[swipe-direction=left]:border-r data-[swipe-direction=right]:rounded-l-xl data-[swipe-direction=right]:border-l data-[swipe-direction=up]:rounded-b-xl data-[swipe-direction=up]:border-b motion-reduce:transition-none",
|
|
131
|
+
// Nested.
|
|
132
|
+
"data-nested-drawer-open:overflow-hidden data-nested-drawer-open:brightness-95",
|
|
133
|
+
// Bleed.
|
|
134
|
+
"after:pointer-events-none after:absolute after:bg-(--drawer-bleed-background,var(--color-overlay)) data-[swipe-axis=x]:after:inset-y-0 data-[swipe-axis=x]:after:w-(--bleed) data-[swipe-axis=y]:after:inset-x-0 data-[swipe-axis=y]:after:h-(--bleed) data-[swipe-direction=down]:after:top-full data-[swipe-direction=left]:after:right-full data-[swipe-direction=right]:after:left-full data-[swipe-direction=up]:after:bottom-full",
|
|
135
|
+
// Sizing.
|
|
136
|
+
"[--drawer-content-height:var(--drawer-height,auto)] data-[swipe-axis=x]:[--drawer-content-width:75%] data-[swipe-axis=y]:[--drawer-content-max-height:calc(100dvh-6rem)] data-[swipe-axis=y]:data-snap-points:[--drawer-content-height:100dvh] data-[swipe-axis=x]:sm:[--drawer-content-width:24rem]",
|
|
137
|
+
// Stack.
|
|
138
|
+
"[--bleed:3rem] [--peek:1rem] [--stack-height:var(--drawer-frontmost-height,var(--drawer-height,0px))] [--stack-peek-offset:max(0px,calc((var(--nested-drawers)-var(--stack-progress))*var(--peek)))] [--stack-progress:clamp(0,var(--drawer-swipe-progress),1)] [--stack-scale-base:max(0,calc(1-(var(--nested-drawers)*var(--stack-step))))] [--stack-scale:clamp(0,calc(var(--stack-scale-base)+(var(--stack-step)*var(--stack-progress))),1)] [--stack-shrink:calc(1-var(--stack-scale))] [--stack-step:0.05]",
|
|
139
|
+
// Transitions.
|
|
140
|
+
"data-ending-style:transform-(--closed-transform) data-ending-style:opacity-[0.9999] data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-nested-drawer-swiping:duration-0 data-ending-style:data-nested-drawer-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-starting-style:transform-(--closed-transform) data-swiping:duration-0 data-ending-style:data-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)]",
|
|
141
|
+
// Axis: y.
|
|
142
|
+
"data-[swipe-axis=y]:inset-x-0 data-[swipe-axis=y]:data-nested-drawer-open:h-(--stack-height)",
|
|
143
|
+
// Axis: x.
|
|
144
|
+
"data-[swipe-axis=x]:inset-y-0 data-[swipe-axis=x]:flex-row",
|
|
145
|
+
// Direction: down.
|
|
146
|
+
"data-[swipe-direction=down]:bottom-0 data-[swipe-direction=down]:origin-bottom data-[swipe-direction=down]:[--closed-transform:translate3d(0,calc(100%+var(--drawer-inset,0px)+2px),0)] data-[swipe-direction=down]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)-var(--stack-peek-offset)-(var(--stack-shrink)*var(--stack-height)))]",
|
|
147
|
+
// Direction: up.
|
|
148
|
+
"data-[swipe-direction=up]:top-0 data-[swipe-direction=up]:origin-top data-[swipe-direction=up]:[--closed-transform:translate3d(0,calc(-100%-var(--drawer-inset,0px)-2px),0)] data-[swipe-direction=up]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)+var(--stack-peek-offset)+(var(--stack-shrink)*var(--stack-height)))]",
|
|
149
|
+
// Direction: left.
|
|
150
|
+
"data-[swipe-direction=left]:left-0 data-[swipe-direction=left]:origin-left data-[swipe-direction=left]:[--closed-transform:translate3d(calc(-100%-var(--drawer-inset,0px)-2px),0,0)] data-[swipe-direction=left]:[--translate-x:calc(var(--drawer-swipe-movement-x)+var(--stack-peek-offset)+(var(--stack-shrink)*100%))]",
|
|
151
|
+
// Direction: right.
|
|
152
|
+
"data-[swipe-direction=right]:right-0 data-[swipe-direction=right]:origin-right data-[swipe-direction=right]:[--closed-transform:translate3d(calc(100%+var(--drawer-inset,0px)+2px),0,0)] data-[swipe-direction=right]:[--translate-x:calc(var(--drawer-swipe-movement-x)-var(--stack-peek-offset)-(var(--stack-shrink)*100%))]",
|
|
153
|
+
className
|
|
154
|
+
)}
|
|
155
|
+
{...props}
|
|
156
|
+
>
|
|
157
|
+
{showSwipeHandle && <DrawerSwipeHandle />}
|
|
158
|
+
<DrawerPrimitive.Content
|
|
159
|
+
data-slot="drawer-content"
|
|
160
|
+
className={cn(
|
|
161
|
+
"flex min-h-0 flex-1 flex-col overflow-hidden overscroll-contain rounded-[inherit] transition-opacity duration-300 ease-[cubic-bezier(0.45,1.005,0,1.005)] select-text group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-swiping/drawer-popup:select-none"
|
|
162
|
+
)}
|
|
163
|
+
>
|
|
164
|
+
{children}
|
|
165
|
+
</DrawerPrimitive.Content>
|
|
166
|
+
</DrawerPrimitive.Popup>
|
|
167
|
+
</DrawerPrimitive.Viewport>
|
|
67
168
|
</DrawerPortal>
|
|
68
169
|
)
|
|
69
170
|
}
|
|
@@ -73,7 +174,7 @@ function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
73
174
|
<div
|
|
74
175
|
data-slot="drawer-header"
|
|
75
176
|
className={cn(
|
|
76
|
-
"flex flex-col gap-0.5 p-4
|
|
177
|
+
"flex shrink-0 flex-col gap-0.5 p-4 pb-0 group-data-[swipe-axis=y]/drawer-popup:text-center md:gap-1.5 md:text-left",
|
|
77
178
|
className
|
|
78
179
|
)}
|
|
79
180
|
{...props}
|
|
@@ -85,16 +186,13 @@ function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
85
186
|
return (
|
|
86
187
|
<div
|
|
87
188
|
data-slot="drawer-footer"
|
|
88
|
-
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
|
|
189
|
+
className={cn("mt-auto flex shrink-0 flex-col gap-2 p-4 pt-0", className)}
|
|
89
190
|
{...props}
|
|
90
191
|
/>
|
|
91
192
|
)
|
|
92
193
|
}
|
|
93
194
|
|
|
94
|
-
function DrawerTitle({
|
|
95
|
-
className,
|
|
96
|
-
...props
|
|
97
|
-
}: React.ComponentProps<typeof DrawerPrimitive.Title>) {
|
|
195
|
+
function DrawerTitle({ className, ...props }: DrawerPrimitive.Title.Props) {
|
|
98
196
|
return (
|
|
99
197
|
<DrawerPrimitive.Title
|
|
100
198
|
data-slot="drawer-title"
|
|
@@ -107,11 +205,11 @@ function DrawerTitle({
|
|
|
107
205
|
function DrawerDescription({
|
|
108
206
|
className,
|
|
109
207
|
...props
|
|
110
|
-
}:
|
|
208
|
+
}: DrawerPrimitive.Description.Props) {
|
|
111
209
|
return (
|
|
112
210
|
<DrawerPrimitive.Description
|
|
113
211
|
data-slot="drawer-description"
|
|
114
|
-
className={cn("text-
|
|
212
|
+
className={cn("text-sm text-balance text-muted-foreground", className)}
|
|
115
213
|
{...props}
|
|
116
214
|
/>
|
|
117
215
|
)
|
|
@@ -121,6 +219,7 @@ export {
|
|
|
121
219
|
Drawer,
|
|
122
220
|
DrawerPortal,
|
|
123
221
|
DrawerOverlay,
|
|
222
|
+
DrawerSwipeHandle,
|
|
124
223
|
DrawerTrigger,
|
|
125
224
|
DrawerClose,
|
|
126
225
|
DrawerContent,
|
|
@@ -89,7 +89,7 @@ function DropdownMenuItem({
|
|
|
89
89
|
data-inset={inset}
|
|
90
90
|
data-variant={variant}
|
|
91
91
|
className={cn(
|
|
92
|
-
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
92
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive-subtle-foreground data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive-subtle-foreground data-[variant=destructive]:*:[svg]:text-destructive-subtle-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
93
93
|
className
|
|
94
94
|
)}
|
|
95
95
|
{...props}
|
|
@@ -52,7 +52,7 @@ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const fieldVariants = cva(
|
|
55
|
-
"data-[invalid=true]:text-destructive gap-3 group/field flex w-full",
|
|
55
|
+
"data-[invalid=true]:text-destructive-subtle-foreground gap-3 group/field flex w-full",
|
|
56
56
|
{
|
|
57
57
|
variants: {
|
|
58
58
|
orientation: {
|
|
@@ -216,7 +216,7 @@ function FieldError({
|
|
|
216
216
|
<div
|
|
217
217
|
role="alert"
|
|
218
218
|
data-slot="field-error"
|
|
219
|
-
className={cn("text-destructive text-sm font-normal", className)}
|
|
219
|
+
className={cn("text-destructive-subtle-foreground text-sm font-normal", className)}
|
|
220
220
|
{...props}
|
|
221
221
|
>
|
|
222
222
|
{content}
|
|
@@ -9,7 +9,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
|
9
9
|
type={type}
|
|
10
10
|
data-slot="input"
|
|
11
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
|
|
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 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 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
13
|
className
|
|
14
14
|
)}
|
|
15
15
|
{...props}
|
|
@@ -6,10 +6,13 @@ import { cva, type VariantProps } from "class-variance-authority"
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
7
|
import { Separator } from "@vendure-io/ui/components/atoms/separator"
|
|
8
8
|
|
|
9
|
+
// No role="list": Item renders any element through its render prop (often a
|
|
10
|
+
// link), so it cannot take role="listitem", and a list without listitem
|
|
11
|
+
// children fails axe aria-required-children. Pass role="list" and wrap items
|
|
12
|
+
// in role="listitem" elements when the group is a real list.
|
|
9
13
|
function ItemGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
10
14
|
return (
|
|
11
15
|
<div
|
|
12
|
-
role="list"
|
|
13
16
|
data-slot="item-group"
|
|
14
17
|
className={cn(
|
|
15
18
|
"group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2",
|
|
@@ -98,7 +98,7 @@ function MenubarItem({
|
|
|
98
98
|
data-inset={inset}
|
|
99
99
|
data-variant={variant}
|
|
100
100
|
className={cn(
|
|
101
|
-
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive! not-data-[variant=destructive]:focus:**:text-accent-foreground group/menubar-item gap-2 rounded-sm px-2 py-1.5 text-sm data-disabled:opacity-50 data-inset:pl-8 [&_svg:not([class*='size-'])]:size-4",
|
|
101
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive-subtle-foreground data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive-subtle-foreground data-[variant=destructive]:*:[svg]:text-destructive-subtle-foreground! not-data-[variant=destructive]:focus:**:text-accent-foreground group/menubar-item gap-2 rounded-sm px-2 py-1.5 text-sm data-disabled:opacity-50 data-inset:pl-8 [&_svg:not([class*='size-'])]:size-4",
|
|
102
102
|
className
|
|
103
103
|
)}
|
|
104
104
|
{...props}
|
|
@@ -24,7 +24,7 @@ function NativeSelect({
|
|
|
24
24
|
<select
|
|
25
25
|
data-slot="native-select"
|
|
26
26
|
data-size={size}
|
|
27
|
-
className="border-input placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive
|
|
27
|
+
className="border-input placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive h-9 w-full min-w-0 appearance-none rounded-md border bg-transparent py-1 pr-8 pl-2.5 text-sm transition-[color,box-shadow] outline-none select-none focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:ring-3 data-[size=sm]:h-8"
|
|
28
28
|
{...props}
|
|
29
29
|
/>
|
|
30
30
|
<ChevronDownIcon className="text-muted-foreground pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 select-none" aria-hidden="true" data-slot="native-select-icon" />
|
|
@@ -56,7 +56,7 @@ function NavigationMenuItem({
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const navigationMenuTriggerStyle = cva(
|
|
59
|
-
"bg-
|
|
59
|
+
"bg-transparent hover:bg-muted focus:bg-muted data-open:hover:bg-muted data-open:focus:bg-muted data-open:bg-muted/50 focus-visible:ring-ring data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted rounded-md px-4 py-2 text-sm font-medium transition-all focus-visible:ring-2 disabled:opacity-50 group/navigation-menu-trigger inline-flex h-9 w-max items-center justify-center disabled:pointer-events-none outline-none"
|
|
60
60
|
)
|
|
61
61
|
|
|
62
62
|
function NavigationMenuTrigger({
|
|
@@ -121,6 +121,9 @@ function NavigationMenuPositioner({
|
|
|
121
121
|
)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
// Base UI writes a valueless data-active (with aria-current="page") on the
|
|
125
|
+
// active link, so the variant is data-active:, not data-[active=true]:. The
|
|
126
|
+
// active link gets the tabs line-variant underline.
|
|
124
127
|
function NavigationMenuLink({
|
|
125
128
|
className,
|
|
126
129
|
...props
|
|
@@ -129,7 +132,7 @@ function NavigationMenuLink({
|
|
|
129
132
|
<NavigationMenuPrimitive.Link
|
|
130
133
|
data-slot="navigation-menu-link"
|
|
131
134
|
className={cn(
|
|
132
|
-
"data-
|
|
135
|
+
"data-active:text-foreground data-active:font-medium focus-visible:ring-ring hover:bg-muted focus:bg-muted relative flex items-center gap-1.5 rounded-sm p-2 text-sm transition-all outline-none focus-visible:ring-2 [&_svg:not([class*='size-'])]:size-4 after:bg-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:opacity-0 after:transition-opacity data-active:after:opacity-100",
|
|
133
136
|
className
|
|
134
137
|
)}
|
|
135
138
|
{...props}
|
|
@@ -29,7 +29,7 @@ function ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props) {
|
|
|
29
29
|
return (
|
|
30
30
|
<ProgressPrimitive.Track
|
|
31
31
|
className={cn(
|
|
32
|
-
"bg-
|
|
32
|
+
"bg-control-border relative flex h-1.5 w-full items-center overflow-x-hidden rounded-full",
|
|
33
33
|
className
|
|
34
34
|
)}
|
|
35
35
|
data-slot="progress-track"
|
|
@@ -20,7 +20,7 @@ function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) {
|
|
|
20
20
|
<RadioPrimitive.Root
|
|
21
21
|
data-slot="radio-group-item"
|
|
22
22
|
className={cn(
|
|
23
|
-
"border-
|
|
23
|
+
"border-control-border dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3",
|
|
24
24
|
className
|
|
25
25
|
)}
|
|
26
26
|
{...props}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import * as React from "react"
|
|
4
3
|
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
|
|
5
4
|
|
|
6
5
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
@@ -18,7 +17,7 @@ function ScrollArea({
|
|
|
18
17
|
>
|
|
19
18
|
<ScrollAreaPrimitive.Viewport
|
|
20
19
|
data-slot="scroll-area-viewport"
|
|
21
|
-
className="focus-visible:ring-ring
|
|
20
|
+
className="focus-visible:ring-ring size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-2"
|
|
22
21
|
>
|
|
23
22
|
{children}
|
|
24
23
|
</ScrollAreaPrimitive.Viewport>
|
|
@@ -41,7 +41,7 @@ function SelectTrigger({
|
|
|
41
41
|
data-slot="select-trigger"
|
|
42
42
|
data-size={size}
|
|
43
43
|
className={cn(
|
|
44
|
-
"border-input data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive
|
|
44
|
+
"border-input data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-1.5 rounded-md border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
45
45
|
className
|
|
46
46
|
)}
|
|
47
47
|
{...props}
|
|
@@ -28,7 +28,7 @@ function SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {
|
|
|
28
28
|
<SheetPrimitive.Backdrop
|
|
29
29
|
data-slot="sheet-overlay"
|
|
30
30
|
className={cn(
|
|
31
|
-
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 z-50 bg-
|
|
31
|
+
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 z-50 bg-scrim motion-reduce:animate-none data-open:duration-(--transition-duration-normal) data-open:ease-(--ease-out) data-closed:duration-(--transition-duration-fast) data-closed:ease-(--ease-in) data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",
|
|
32
32
|
className
|
|
33
33
|
)}
|
|
34
34
|
{...props}
|
|
@@ -317,7 +317,7 @@ function SidebarInset({
|
|
|
317
317
|
props: mergeProps<"main">(
|
|
318
318
|
{
|
|
319
319
|
className: cn(
|
|
320
|
-
"bg-background relative flex w-full flex-1 flex-col md:peer-data-[variant=inset]:bg-surface md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:border md:peer-data-[variant=inset]:border-border/60
|
|
320
|
+
"bg-background relative flex w-full flex-1 flex-col md:peer-data-[variant=inset]:bg-surface md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:border md:peer-data-[variant=inset]:border-border/60",
|
|
321
321
|
className
|
|
322
322
|
),
|
|
323
323
|
},
|
|
@@ -489,14 +489,16 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
|
489
489
|
)
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
+
// Hover and active share the sidebar-accent fill, so the active item also gets
|
|
493
|
+
// a sidebar-primary bar on its leading edge.
|
|
492
494
|
const sidebarMenuButtonVariants = cva(
|
|
493
|
-
"ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground gap-2 rounded-md p-2 text-left text-sm transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 data-active:font-medium peer/menu-button flex w-full items-center overflow-hidden outline-hidden group/menu-button disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&_svg]:size-4 [&_svg]:shrink-0",
|
|
495
|
+
"before:bg-sidebar-primary relative before:absolute before:inset-y-1.5 before:left-0 before:w-0.5 before:rounded-full before:opacity-0 data-active:before:opacity-100 ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground gap-2 rounded-md p-2 text-left text-sm transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 data-active:font-medium peer/menu-button flex w-full items-center overflow-hidden outline-hidden group/menu-button disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&_svg]:size-4 [&>svg:first-child]:size-4.5 [&>svg:first-child]:[stroke-width:2.125] [&_svg]:shrink-0",
|
|
494
496
|
{
|
|
495
497
|
variants: {
|
|
496
498
|
variant: {
|
|
497
499
|
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
498
500
|
outline:
|
|
499
|
-
"bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground shadow-[
|
|
501
|
+
"bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground shadow-[0_0_0_1px_var(--sidebar-border)] hover:shadow-[0_0_0_1px_var(--sidebar-accent)]",
|
|
500
502
|
},
|
|
501
503
|
size: {
|
|
502
504
|
default: "h-8 text-sm",
|
|
@@ -694,7 +696,7 @@ function SidebarMenuSubButton({
|
|
|
694
696
|
props: mergeProps<"a">(
|
|
695
697
|
{
|
|
696
698
|
className: cn(
|
|
697
|
-
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground h-7 gap-2 rounded-md px-2 focus-visible:ring-2 data-[size=md]:text-sm data-[size=sm]:text-xs [&>svg]:size-4 flex min-w-0 -translate-x-px items-center overflow-hidden outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0",
|
|
699
|
+
"before:bg-sidebar-primary relative before:absolute before:inset-y-1.5 before:left-0 before:w-0.5 before:rounded-full before:opacity-0 data-active:before:opacity-100 text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground h-7 gap-2 rounded-md px-2 focus-visible:ring-2 data-[size=md]:text-sm data-[size=sm]:text-xs [&>svg]:size-4 flex min-w-0 -translate-x-px items-center overflow-hidden outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0",
|
|
698
700
|
className
|
|
699
701
|
),
|
|
700
702
|
},
|
|
@@ -37,7 +37,7 @@ function Slider({
|
|
|
37
37
|
<SliderPrimitive.Control className="relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col">
|
|
38
38
|
<SliderPrimitive.Track
|
|
39
39
|
data-slot="slider-track"
|
|
40
|
-
className="bg-
|
|
40
|
+
className="bg-control-border relative grow overflow-hidden rounded-full select-none data-horizontal:h-1.5 data-horizontal:w-full data-vertical:h-full data-vertical:w-1.5"
|
|
41
41
|
>
|
|
42
42
|
<SliderPrimitive.Indicator
|
|
43
43
|
data-slot="slider-range"
|
|
@@ -48,7 +48,7 @@ function Slider({
|
|
|
48
48
|
<SliderPrimitive.Thumb
|
|
49
49
|
data-slot="slider-thumb"
|
|
50
50
|
key={index}
|
|
51
|
-
className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-
|
|
51
|
+
className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-background transition-[color,box-shadow] select-none hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
52
52
|
/>
|
|
53
53
|
))}
|
|
54
54
|
</SliderPrimitive.Control>
|
|
@@ -16,7 +16,7 @@ function Switch({
|
|
|
16
16
|
data-slot="switch"
|
|
17
17
|
data-size={size}
|
|
18
18
|
className={cn(
|
|
19
|
-
"data-checked:bg-primary data-unchecked:bg-
|
|
19
|
+
"data-checked:bg-primary data-unchecked:bg-control-border focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 aria-invalid:ring-3 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px]",
|
|
20
20
|
className
|
|
21
21
|
)}
|
|
22
22
|
{...props}
|
|
@@ -4,11 +4,40 @@ import * as React from "react"
|
|
|
4
4
|
|
|
5
5
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
6
6
|
|
|
7
|
+
// When the table is wider than its container, the container scrolls and must
|
|
8
|
+
// be reachable by keyboard (axe scrollable-region-focusable), so it becomes a
|
|
9
|
+
// tab stop with a focus ring. A table that fits adds no tab stop.
|
|
7
10
|
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
11
|
+
const containerRef = React.useRef<HTMLDivElement>(null)
|
|
12
|
+
const [scrollable, setScrollable] = React.useState(false)
|
|
13
|
+
|
|
14
|
+
// Measure before the first paint, so an overflowing table is a tab stop
|
|
15
|
+
// from the start; the observer then tracks later size changes.
|
|
16
|
+
React.useLayoutEffect(() => {
|
|
17
|
+
const container = containerRef.current
|
|
18
|
+
if (!container) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
const update = () =>
|
|
22
|
+
setScrollable(container.scrollWidth > container.clientWidth)
|
|
23
|
+
update()
|
|
24
|
+
if (typeof ResizeObserver === "undefined") {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
const observer = new ResizeObserver(update)
|
|
28
|
+
observer.observe(container)
|
|
29
|
+
if (container.firstElementChild) {
|
|
30
|
+
observer.observe(container.firstElementChild)
|
|
31
|
+
}
|
|
32
|
+
return () => observer.disconnect()
|
|
33
|
+
}, [])
|
|
34
|
+
|
|
8
35
|
return (
|
|
9
36
|
<div
|
|
37
|
+
ref={containerRef}
|
|
10
38
|
data-slot="table-container"
|
|
11
|
-
|
|
39
|
+
tabIndex={scrollable ? 0 : undefined}
|
|
40
|
+
className="focus-visible:ring-ring relative w-full overflow-x-auto rounded-[inherit] outline-none focus-visible:ring-2"
|
|
12
41
|
>
|
|
13
42
|
<table
|
|
14
43
|
data-slot="table"
|
|
@@ -52,12 +81,15 @@ function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
|
52
81
|
)
|
|
53
82
|
}
|
|
54
83
|
|
|
84
|
+
// data-state="selected" is the DataTable (TanStack) row-selection marker, not a
|
|
85
|
+
// Radix attribute, so the selector is live. Selected rows use the accent fill
|
|
86
|
+
// plus a primary bar on the leading edge, so they stay distinct from hover.
|
|
55
87
|
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
56
88
|
return (
|
|
57
89
|
<tr
|
|
58
90
|
data-slot="table-row"
|
|
59
91
|
className={cn(
|
|
60
|
-
"hover:bg-muted/50 data-[state=selected]:bg-
|
|
92
|
+
"hover:bg-muted/50 data-[state=selected]:bg-accent data-[state=selected]:shadow-[inset_2px_0_0_var(--primary)] border-b border-border/50 transition-colors",
|
|
61
93
|
className
|
|
62
94
|
)}
|
|
63
95
|
{...props}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { mergeProps } from "@base-ui/react/merge-props"
|
|
3
4
|
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs"
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render"
|
|
4
6
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
7
|
|
|
6
8
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
@@ -82,4 +84,65 @@ function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
|
|
|
82
84
|
)
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
// Link tabs: section navigation where each tab is a route. They look like the
|
|
88
|
+
// line variant, but they are a <nav> of links with aria-current="page", not a
|
|
89
|
+
// tablist. Base UI Tabs would put role="tab" on a link and expect a panel for
|
|
90
|
+
// each tab, and the router already owns which section shows.
|
|
91
|
+
function TabsNav({ className, ...props }: React.ComponentProps<"nav">) {
|
|
92
|
+
return (
|
|
93
|
+
<nav
|
|
94
|
+
data-slot="tabs-nav"
|
|
95
|
+
className={cn(
|
|
96
|
+
// The padding keeps the focus ring and the underline inside the
|
|
97
|
+
// scroll box, which clips everything outside it.
|
|
98
|
+
"text-muted-foreground flex h-9 max-w-full items-center gap-1 overflow-x-auto p-[3px]",
|
|
99
|
+
className
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// `active` sets aria-current="page". The style reads aria-current, so a router
|
|
107
|
+
// link that sets it on the active route (TanStack Router, React Router's
|
|
108
|
+
// NavLink) works through `render` without `active`.
|
|
109
|
+
function TabsLink({
|
|
110
|
+
className,
|
|
111
|
+
active,
|
|
112
|
+
render,
|
|
113
|
+
...props
|
|
114
|
+
}: useRender.ComponentProps<"a"> & { active?: boolean }) {
|
|
115
|
+
return useRender({
|
|
116
|
+
defaultTagName: "a",
|
|
117
|
+
render,
|
|
118
|
+
props: mergeProps<"a">(
|
|
119
|
+
{
|
|
120
|
+
// Leave the attribute to the router link unless `active` is set.
|
|
121
|
+
...(active !== undefined && {
|
|
122
|
+
"aria-current": active ? ("page" as const) : undefined,
|
|
123
|
+
}),
|
|
124
|
+
className: cn(
|
|
125
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-full shrink-0 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-[3px] focus-visible:outline-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
126
|
+
"aria-[current=page]:text-foreground dark:aria-[current=page]:text-foreground",
|
|
127
|
+
// The underline sits on the bottom edge of the nav, like the line variant.
|
|
128
|
+
"after:bg-foreground after:absolute after:inset-x-0 after:bottom-[-4px] after:h-0.5 after:opacity-0 after:transition-opacity aria-[current=page]:after:opacity-100",
|
|
129
|
+
className
|
|
130
|
+
),
|
|
131
|
+
},
|
|
132
|
+
props
|
|
133
|
+
),
|
|
134
|
+
state: {
|
|
135
|
+
slot: "tabs-link",
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
Tabs,
|
|
142
|
+
TabsList,
|
|
143
|
+
TabsTrigger,
|
|
144
|
+
TabsContent,
|
|
145
|
+
TabsNav,
|
|
146
|
+
TabsLink,
|
|
147
|
+
tabsListVariants,
|
|
148
|
+
}
|