@vendure-io/ui 2.1.0 → 3.0.0-next.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.
- package/package.json +19 -5
- package/src/components/atoms/accordion.tsx +21 -6
- package/src/components/atoms/alert-dialog.tsx +31 -6
- package/src/components/atoms/alert.tsx +73 -13
- package/src/components/atoms/avatar.tsx +1 -1
- package/src/components/atoms/badge.tsx +7 -2
- package/src/components/atoms/breadcrumb.tsx +137 -4
- package/src/components/atoms/button-group.tsx +30 -6
- package/src/components/atoms/button.tsx +128 -18
- package/src/components/atoms/calendar.tsx +6 -6
- package/src/components/atoms/card.tsx +130 -16
- package/src/components/atoms/carousel.tsx +16 -9
- package/src/components/atoms/chart.tsx +87 -1
- package/src/components/atoms/checkbox.tsx +85 -7
- package/src/components/atoms/collapsible.tsx +2 -1
- package/src/components/atoms/combobox.tsx +147 -21
- package/src/components/atoms/command.tsx +414 -12
- package/src/components/atoms/context-menu.tsx +28 -23
- package/src/components/atoms/dialog.tsx +151 -29
- package/src/components/atoms/direction.tsx +23 -2
- package/src/components/atoms/drawer.tsx +15 -10
- package/src/components/atoms/dropdown-menu.tsx +43 -28
- package/src/components/atoms/empty.tsx +4 -0
- package/src/components/atoms/field.tsx +41 -15
- package/src/components/atoms/hover-card.tsx +61 -8
- package/src/components/atoms/input-group.tsx +17 -9
- package/src/components/atoms/input-otp.tsx +6 -6
- package/src/components/atoms/input.tsx +7 -1
- package/src/components/atoms/item.tsx +3 -3
- package/src/components/atoms/kbd.tsx +32 -3
- package/src/components/atoms/label-swap.tsx +82 -0
- package/src/components/atoms/label.tsx +1 -1
- package/src/components/atoms/menubar.tsx +28 -26
- package/src/components/atoms/native-select.tsx +3 -2
- package/src/components/atoms/navigation-menu.tsx +13 -8
- package/src/components/atoms/pagination.tsx +2 -2
- package/src/components/atoms/popover.tsx +23 -5
- package/src/components/atoms/progress.tsx +46 -33
- package/src/components/atoms/radio-group.tsx +9 -4
- package/src/components/atoms/resizable.tsx +1 -1
- package/src/components/atoms/scroll-area.tsx +2 -2
- package/src/components/atoms/select.tsx +258 -19
- package/src/components/atoms/sheet.tsx +59 -23
- package/src/components/atoms/sidebar.tsx +333 -23
- package/src/components/atoms/skeleton.tsx +1 -1
- package/src/components/atoms/slider.tsx +1 -1
- package/src/components/atoms/sonner.tsx +128 -38
- package/src/components/atoms/spinner.tsx +1 -1
- package/src/components/atoms/switch.tsx +10 -5
- package/src/components/atoms/table.tsx +147 -7
- package/src/components/atoms/tabs.tsx +3 -3
- package/src/components/atoms/textarea.tsx +3 -1
- package/src/components/atoms/toggle-group.tsx +4 -2
- package/src/components/atoms/toggle.tsx +28 -6
- package/src/components/atoms/tooltip.tsx +85 -15
- package/src/components/molecules/anonymized-token.tsx +24 -8
- package/src/components/molecules/app-shell.tsx +53 -20
- package/src/components/molecules/arrow-link.tsx +40 -0
- package/src/components/molecules/chip.tsx +2 -2
- package/src/components/molecules/code-block.tsx +54 -31
- package/src/components/molecules/collapsible-section.tsx +129 -0
- package/src/components/molecules/confirm-dialog.tsx +113 -9
- package/src/components/molecules/copyable-text.tsx +75 -11
- package/src/components/molecules/data-table/data-table-bulk-actions.tsx +32 -4
- package/src/components/molecules/data-table/data-table-column-header.tsx +20 -3
- package/src/components/molecules/data-table/data-table-filters.tsx +1 -1
- package/src/components/molecules/data-table/data-table-helpers.tsx +68 -1
- package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
- package/src/components/molecules/data-table/data-table-types.tsx +138 -4
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
- package/src/components/molecules/data-table/data-table.tsx +916 -84
- package/src/components/molecules/data-table/table-pagination.tsx +2 -2
- package/src/components/molecules/date-picker.tsx +13 -7
- package/src/components/molecules/date-range-picker.tsx +13 -6
- package/src/components/molecules/date-time-picker.tsx +13 -7
- package/src/components/molecules/date-time.tsx +8 -1
- package/src/components/molecules/direction-link.tsx +130 -0
- package/src/components/molecules/elapsed-time.tsx +223 -0
- package/src/components/molecules/file-dropzone.tsx +2 -2
- package/src/components/molecules/id-chip.tsx +169 -32
- package/src/components/molecules/inline-code.tsx +4 -0
- package/src/components/molecules/issued-secret.tsx +318 -0
- package/src/components/molecules/list-row.tsx +349 -0
- package/src/components/molecules/live-indicator.tsx +83 -0
- package/src/components/molecules/page-header.tsx +117 -5
- package/src/components/molecules/password-input.tsx +2 -2
- package/src/components/molecules/relative-time.tsx +85 -56
- package/src/components/molecules/search-trigger.tsx +127 -0
- package/src/components/molecules/secret-value.tsx +26 -9
- package/src/components/molecules/skip-link.tsx +1 -1
- package/src/components/molecules/stat-card.tsx +4 -4
- package/src/components/molecules/state-views/empty-state.tsx +35 -17
- package/src/components/molecules/state-views/error-state.tsx +32 -14
- package/src/components/molecules/status-badge.tsx +415 -49
- package/src/components/molecules/time-tooltip.tsx +140 -0
- package/src/components/molecules/timeline.tsx +246 -0
- package/src/components/molecules/visibility-icon.tsx +89 -0
- package/src/hooks/use-active-label-size.ts +32 -0
- package/src/hooks/use-pinned-height.ts +55 -0
- package/src/hooks/use-scrolled.ts +27 -0
- package/src/lib/content-inset.ts +17 -0
- package/src/lib/control-name.ts +55 -0
- package/src/lib/dialog-padding.ts +48 -0
- package/src/lib/field-surface.ts +31 -0
- package/src/lib/format-elapsed.ts +67 -0
- package/src/lib/format-relative.ts +29 -1
- package/src/lib/highlight.ts +3 -3
- package/src/lib/menu-item.tsx +72 -0
- package/src/lib/outline-edge.ts +21 -0
- package/src/lib/popup-align.ts +67 -0
- package/src/lib/popup-direction.ts +22 -0
- package/src/lib/popup-motion.ts +19 -0
- package/src/lib/state-dictionary.ts +42 -6
- package/src/lib/syntax-colors.ts +8 -0
- package/src/lib/tint-recipes.ts +68 -0
- package/src/lib/tone-icons.ts +24 -0
- package/src/lib/trigger-slot.ts +16 -0
- package/src/lib/utils.ts +104 -1
|
@@ -4,6 +4,7 @@ import * as React from "react"
|
|
|
4
4
|
import { Command as CommandPrimitive, useCommandState } from "cmdk"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
|
+
import { MenuCheck, menuCheckItem } from "../../lib/menu-item.tsx"
|
|
7
8
|
import {
|
|
8
9
|
Dialog,
|
|
9
10
|
DialogContent,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
InputGroup,
|
|
16
17
|
InputGroupAddon,
|
|
17
18
|
} from "@vendure-io/ui/components/atoms/input-group"
|
|
18
|
-
import { SearchIcon
|
|
19
|
+
import { SearchIcon } from "lucide-react"
|
|
19
20
|
|
|
20
21
|
function Command({
|
|
21
22
|
className,
|
|
@@ -25,7 +26,7 @@ function Command({
|
|
|
25
26
|
<CommandPrimitive
|
|
26
27
|
data-slot="command"
|
|
27
28
|
className={cn(
|
|
28
|
-
"bg-popover text-popover-foreground flex size-full flex-col overflow-hidden rounded-xl!
|
|
29
|
+
"bg-popover text-popover-foreground flex size-full flex-col overflow-hidden rounded-xl! in-data-command-palette:rounded-3xl!",
|
|
29
30
|
className
|
|
30
31
|
)}
|
|
31
32
|
{...props}
|
|
@@ -53,12 +54,23 @@ function CommandDialog({
|
|
|
53
54
|
<DialogTitle>{title}</DialogTitle>
|
|
54
55
|
<DialogDescription>{description}</DialogDescription>
|
|
55
56
|
</DialogHeader>
|
|
57
|
+
{/* The palette: 600px wide, 12% of the viewport from the top so the
|
|
58
|
+
list can grow down without moving the input. It opens often, so its
|
|
59
|
+
motion is smaller than a dialog's: it drops 6px from 98% at the top
|
|
60
|
+
centre instead of scaling from 96%. It takes a little longer to settle
|
|
61
|
+
(opacity 160ms, transform 180ms) and closes in 110ms. Reduced motion
|
|
62
|
+
fades only. data-command-palette scopes the palette styles of the
|
|
63
|
+
Command parts to this dialog. */}
|
|
56
64
|
<DialogContent
|
|
65
|
+
data-command-palette=""
|
|
57
66
|
className={cn(
|
|
58
|
-
"top-
|
|
67
|
+
"shadow-overlay top-[12vh] translate-y-0 gap-0 overflow-hidden rounded-3xl! p-0 ring-0 sm:max-w-150 origin-top transition-[opacity,scale,translate] duration-[var(--transition-duration-palette-enter),var(--transition-duration-palette-move),var(--transition-duration-palette-move)] motion-safe:data-starting-style:-translate-y-1.5 motion-safe:data-starting-style:scale-98 data-ending-style:duration-palette-exit data-ending-style:ease-[var(--ease-soft),var(--ease-out),var(--ease-out)] motion-safe:data-ending-style:scale-98 motion-reduce:transition-opacity motion-reduce:duration-palette-tint motion-reduce:ease-soft",
|
|
59
68
|
className
|
|
60
69
|
)}
|
|
61
70
|
showCloseButton={showCloseButton}
|
|
71
|
+
// The palette is transient and keeps the page in view: a lighter scrim
|
|
72
|
+
// with a 2px blur that fades with the palette.
|
|
73
|
+
overlayClassName="bg-scrim-subtle duration-palette-enter ease-out data-ending-style:duration-palette-exit supports-backdrop-filter:backdrop-blur-[2px]"
|
|
62
74
|
>
|
|
63
75
|
{children}
|
|
64
76
|
</DialogContent>
|
|
@@ -71,12 +83,14 @@ function CommandInput({
|
|
|
71
83
|
...props
|
|
72
84
|
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
73
85
|
return (
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
// Unboxed: the input runs edge to edge above a hairline, with no field
|
|
87
|
+
// border, fill or ring. 54px with 16px text in the palette dialog.
|
|
88
|
+
<div data-slot="command-input-wrapper" className="border-border border-b">
|
|
89
|
+
<InputGroup className="h-10! rounded-none! border-0! bg-transparent! pe-3.5 shadow-none! ring-0! outline-none! in-data-command-palette:h-13.5! *:data-[slot=input-group-addon]:ps-3! in-data-command-palette:*:data-[slot=input-group-addon]:ps-4.5!">
|
|
76
90
|
<CommandPrimitive.Input
|
|
77
91
|
data-slot="command-input"
|
|
78
92
|
className={cn(
|
|
79
|
-
"w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
93
|
+
"placeholder:text-muted-foreground w-full ps-2.5! text-sm outline-hidden in-data-command-palette:text-base disabled:cursor-not-allowed disabled:opacity-50",
|
|
80
94
|
className
|
|
81
95
|
)}
|
|
82
96
|
{...props}
|
|
@@ -89,18 +103,330 @@ function CommandInput({
|
|
|
89
103
|
)
|
|
90
104
|
}
|
|
91
105
|
|
|
106
|
+
// In the palette, results that appear after the first render (a new query)
|
|
107
|
+
// fade in from a 3px blur, 50ms after the old results start to leave. Rows that
|
|
108
|
+
// stay are not touched: cmdk re-inserts them when it sorts, so the ghost marks
|
|
109
|
+
// every shown result data-result-seen before the query changes. The colour
|
|
110
|
+
// transition is the palette item's own (see CommandItem). Reduced motion drops
|
|
111
|
+
// the blur.
|
|
112
|
+
const ENTERING_RESULTS =
|
|
113
|
+
"[&[data-results-ready]_:is([cmdk-item],[cmdk-group-heading],[cmdk-empty]):not([data-result-seen],[data-slot=command-results-ghost]_*)]:transition-[color,opacity,filter] [&[data-results-ready]_:is([cmdk-item],[cmdk-group-heading],[cmdk-empty]):not([data-result-seen],[data-slot=command-results-ghost]_*)]:duration-[var(--transition-duration-palette-tint),var(--transition-duration-normal),var(--transition-duration-palette-result-blur)] [&[data-results-ready]_:is([cmdk-item],[cmdk-group-heading],[cmdk-empty]):not([data-result-seen],[data-slot=command-results-ghost]_*)]:delay-[var(--transition-duration-instant),var(--transition-duration-palette-result-delay),var(--transition-duration-palette-result-delay)] [&[data-results-ready]_:is([cmdk-item],[cmdk-group-heading],[cmdk-empty]):not([data-result-seen],[data-slot=command-results-ghost]_*)]:ease-[var(--ease-soft),var(--ease-soft),var(--ease-out)] [&[data-results-ready]_:is([cmdk-item],[cmdk-group-heading],[cmdk-empty]):not([data-result-seen],[data-slot=command-results-ghost]_*)]:starting:opacity-0 motion-safe:[&[data-results-ready]_:is([cmdk-item],[cmdk-group-heading],[cmdk-empty]):not([data-result-seen],[data-slot=command-results-ghost]_*)]:starting:blur-[3px]"
|
|
114
|
+
|
|
115
|
+
// cmdk measures the list's content and writes it to --cmdk-list-height, so the
|
|
116
|
+
// list eases to its new height as results change. The first measure is not
|
|
117
|
+
// animated (the height starts as auto). Reduced motion drops the animation.
|
|
92
118
|
function CommandList({
|
|
93
119
|
className,
|
|
120
|
+
slidingHighlight = false,
|
|
121
|
+
children,
|
|
94
122
|
...props
|
|
95
|
-
}: React.ComponentProps<typeof CommandPrimitive.List>
|
|
123
|
+
}: React.ComponentProps<typeof CommandPrimitive.List> & {
|
|
124
|
+
/**
|
|
125
|
+
* Draws the selected item's highlight as one fill that follows the
|
|
126
|
+
* selection from item to item, and eases the list's scroll with it. Off by
|
|
127
|
+
* default: each item then fills itself.
|
|
128
|
+
*/
|
|
129
|
+
slidingHighlight?: boolean
|
|
130
|
+
}) {
|
|
96
131
|
return (
|
|
97
132
|
<CommandPrimitive.List
|
|
98
133
|
data-slot="command-list"
|
|
134
|
+
data-highlight={slidingHighlight ? "slide" : undefined}
|
|
99
135
|
className={cn(
|
|
100
|
-
"no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",
|
|
136
|
+
"no-scrollbar h-(--cmdk-list-height) max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto overscroll-contain outline-none transition-[height] duration-normal ease-height in-data-command-palette:max-h-95 motion-reduce:transition-none *:[[cmdk-list-sizer]]:relative *:[[cmdk-list-sizer]]:p-1",
|
|
137
|
+
ENTERING_RESULTS,
|
|
101
138
|
className
|
|
102
139
|
)}
|
|
103
140
|
{...props}
|
|
141
|
+
>
|
|
142
|
+
{slidingHighlight && <CommandHighlight />}
|
|
143
|
+
<CommandResultsGhost />
|
|
144
|
+
{children}
|
|
145
|
+
</CommandPrimitive.List>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// The palette's results crossfade. Just before the query changes (beforeinput),
|
|
150
|
+
// a copy of the current results goes into this layer, at the place they were
|
|
151
|
+
// shown, and fades out with a 3px blur (opacity 140ms, blur 160ms) while the
|
|
152
|
+
// new results fade in under it. Only in the palette (a CommandList in
|
|
153
|
+
// CommandDialog). Reduced motion skips the copy: new results only fade in.
|
|
154
|
+
function CommandResultsGhost() {
|
|
155
|
+
const ref = React.useRef<HTMLDivElement>(null)
|
|
156
|
+
|
|
157
|
+
React.useLayoutEffect(() => {
|
|
158
|
+
const ghost = ref.current
|
|
159
|
+
const sizer = ghost?.parentElement
|
|
160
|
+
const list = sizer?.closest<HTMLElement>("[cmdk-list]")
|
|
161
|
+
const root = sizer?.closest("[cmdk-root]")
|
|
162
|
+
if (
|
|
163
|
+
!ghost ||
|
|
164
|
+
!sizer ||
|
|
165
|
+
!list ||
|
|
166
|
+
!root ||
|
|
167
|
+
!list.closest("[data-command-palette]")
|
|
168
|
+
) {
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)")
|
|
172
|
+
let timer = 0
|
|
173
|
+
|
|
174
|
+
// Results rendered from now on are new: they fade in.
|
|
175
|
+
const frame = requestAnimationFrame(() => {
|
|
176
|
+
list.dataset.resultsReady = ""
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
const onBeforeInput = (event: Event) => {
|
|
180
|
+
if (!(event.target instanceof HTMLInputElement)) {
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
// Results shown now stay still if the new query keeps them.
|
|
184
|
+
for (const result of Array.from(
|
|
185
|
+
sizer.querySelectorAll<HTMLElement>(
|
|
186
|
+
"[cmdk-item],[cmdk-group-heading],[cmdk-empty]"
|
|
187
|
+
)
|
|
188
|
+
)) {
|
|
189
|
+
if (ghost.contains(result)) {
|
|
190
|
+
continue
|
|
191
|
+
}
|
|
192
|
+
if (result.offsetParent) {
|
|
193
|
+
result.dataset.resultSeen = ""
|
|
194
|
+
} else {
|
|
195
|
+
delete result.dataset.resultSeen
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (reduced.matches) {
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
const copies: Node[] = []
|
|
202
|
+
for (const child of Array.from(sizer.children)) {
|
|
203
|
+
if (
|
|
204
|
+
child === ghost ||
|
|
205
|
+
child.getAttribute("data-slot") === "command-highlight"
|
|
206
|
+
) {
|
|
207
|
+
continue
|
|
208
|
+
}
|
|
209
|
+
const copy = child.cloneNode(true) as HTMLElement
|
|
210
|
+
// The copy must not answer cmdk's or the highlight's item queries.
|
|
211
|
+
for (const node of [copy, ...Array.from(copy.querySelectorAll("*"))]) {
|
|
212
|
+
node.removeAttribute("id")
|
|
213
|
+
node.removeAttribute("cmdk-item")
|
|
214
|
+
node.removeAttribute("cmdk-empty")
|
|
215
|
+
node.removeAttribute("data-result-seen")
|
|
216
|
+
}
|
|
217
|
+
copies.push(copy)
|
|
218
|
+
}
|
|
219
|
+
ghost.replaceChildren(...copies)
|
|
220
|
+
// A new query scrolls the list to the top: keep the copy where it was.
|
|
221
|
+
ghost.style.top = `${-list.scrollTop}px`
|
|
222
|
+
delete ghost.dataset.leaving
|
|
223
|
+
void ghost.offsetHeight
|
|
224
|
+
ghost.dataset.leaving = ""
|
|
225
|
+
window.clearTimeout(timer)
|
|
226
|
+
timer = window.setTimeout(() => ghost.replaceChildren(), 220)
|
|
227
|
+
}
|
|
228
|
+
root.addEventListener("beforeinput", onBeforeInput, true)
|
|
229
|
+
|
|
230
|
+
return () => {
|
|
231
|
+
cancelAnimationFrame(frame)
|
|
232
|
+
window.clearTimeout(timer)
|
|
233
|
+
root.removeEventListener("beforeinput", onBeforeInput, true)
|
|
234
|
+
delete list.dataset.resultsReady
|
|
235
|
+
}
|
|
236
|
+
}, [])
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<div
|
|
240
|
+
ref={ref}
|
|
241
|
+
aria-hidden="true"
|
|
242
|
+
role="none"
|
|
243
|
+
inert
|
|
244
|
+
data-slot="command-results-ghost"
|
|
245
|
+
className="pointer-events-none absolute inset-x-0 top-0 z-10 p-1 empty:hidden data-leaving:*:opacity-0 data-leaving:*:blur-[3px] data-leaving:*:transition-[opacity,filter] data-leaving:*:duration-[var(--transition-duration-palette-result-exit),var(--transition-duration-palette-enter)] data-leaving:*:ease-soft"
|
|
246
|
+
/>
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// The follower's time constant. Each frame closes 1 - e^(-dt/42ms) of the
|
|
251
|
+
// distance: about 95% in 130ms, with no overshoot.
|
|
252
|
+
const FOLLOW_MS = 42
|
|
253
|
+
const NAVIGATION_KEYS = new Set([
|
|
254
|
+
"ArrowDown",
|
|
255
|
+
"ArrowUp",
|
|
256
|
+
"Home",
|
|
257
|
+
"End",
|
|
258
|
+
"PageDown",
|
|
259
|
+
"PageUp",
|
|
260
|
+
])
|
|
261
|
+
|
|
262
|
+
// The sliding highlight of a CommandList. It sits in cmdk's list sizer, so it
|
|
263
|
+
// scrolls with the items, and follows the item cmdk marks
|
|
264
|
+
// data-selected="true": a MutationObserver catches the selection moving and
|
|
265
|
+
// the results changing, a ResizeObserver catches layout changes.
|
|
266
|
+
//
|
|
267
|
+
// One follower moves the highlight and the list's scroll together, so they
|
|
268
|
+
// never disagree. It approaches its target exponentially every frame, so a
|
|
269
|
+
// new target while it moves (a held arrow key) continues from where it is
|
|
270
|
+
// instead of restarting. cmdk scrolls the selected item into view at once;
|
|
271
|
+
// after a key press the follower takes that scroll back and eases to it.
|
|
272
|
+
// Wheel and pointer scrolling stay native. Reduced motion jumps.
|
|
273
|
+
function CommandHighlight() {
|
|
274
|
+
const ref = React.useRef<HTMLDivElement>(null)
|
|
275
|
+
|
|
276
|
+
React.useLayoutEffect(() => {
|
|
277
|
+
const highlight = ref.current
|
|
278
|
+
const sizer = highlight?.parentElement
|
|
279
|
+
const list = sizer?.closest<HTMLElement>("[cmdk-list]")
|
|
280
|
+
if (!highlight || !sizer || !list) {
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)")
|
|
284
|
+
|
|
285
|
+
// y and h are shown, ty and th are the target. scroll is the list's
|
|
286
|
+
// shown scroll position, scrollTo its target while the follower scrolls.
|
|
287
|
+
const f = {
|
|
288
|
+
y: 0,
|
|
289
|
+
h: 0,
|
|
290
|
+
ty: 0,
|
|
291
|
+
th: 0,
|
|
292
|
+
scroll: list.scrollTop,
|
|
293
|
+
scrollTo: null as number | null,
|
|
294
|
+
placed: false,
|
|
295
|
+
byKey: false,
|
|
296
|
+
raf: 0,
|
|
297
|
+
last: 0,
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const draw = () => {
|
|
301
|
+
highlight.style.transform = `translateY(${f.y}px)`
|
|
302
|
+
highlight.style.height = `${f.h}px`
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const tick = (time: number) => {
|
|
306
|
+
const dt = f.last ? Math.min(time - f.last, 48) : 16
|
|
307
|
+
f.last = time
|
|
308
|
+
const k = reduced.matches ? 1 : 1 - Math.exp(-dt / FOLLOW_MS)
|
|
309
|
+
f.y = Math.abs(f.ty - f.y) < 0.25 ? f.ty : f.y + (f.ty - f.y) * k
|
|
310
|
+
f.h = Math.abs(f.th - f.h) < 0.25 ? f.th : f.h + (f.th - f.h) * k
|
|
311
|
+
draw()
|
|
312
|
+
let moving = f.y !== f.ty || f.h !== f.th
|
|
313
|
+
if (f.scrollTo !== null) {
|
|
314
|
+
const next = f.scroll + (f.scrollTo - f.scroll) * k
|
|
315
|
+
f.scroll = Math.abs(f.scrollTo - next) < 0.5 ? f.scrollTo : next
|
|
316
|
+
list.scrollTop = f.scroll
|
|
317
|
+
if (f.scroll === f.scrollTo) {
|
|
318
|
+
f.scrollTo = null
|
|
319
|
+
} else {
|
|
320
|
+
moving = true
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (moving) {
|
|
324
|
+
f.raf = requestAnimationFrame(tick)
|
|
325
|
+
} else {
|
|
326
|
+
f.raf = 0
|
|
327
|
+
f.last = 0
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const place = () => {
|
|
332
|
+
const selected = sizer.querySelector<HTMLElement>(
|
|
333
|
+
'[cmdk-item][data-selected="true"]'
|
|
334
|
+
)
|
|
335
|
+
if (!selected) {
|
|
336
|
+
delete highlight.dataset.shown
|
|
337
|
+
f.byKey = false
|
|
338
|
+
return
|
|
339
|
+
}
|
|
340
|
+
// Layout offsets, not client rects: they ignore the dialog's scale-in.
|
|
341
|
+
let top = 0
|
|
342
|
+
let left = 0
|
|
343
|
+
for (
|
|
344
|
+
let node: HTMLElement | null = selected;
|
|
345
|
+
node && node !== sizer;
|
|
346
|
+
node = node.offsetParent as HTMLElement | null
|
|
347
|
+
) {
|
|
348
|
+
top += node.offsetTop
|
|
349
|
+
left += node.offsetLeft
|
|
350
|
+
}
|
|
351
|
+
highlight.style.left = `${left}px`
|
|
352
|
+
highlight.style.width = `${selected.offsetWidth}px`
|
|
353
|
+
f.ty = top
|
|
354
|
+
f.th = selected.offsetHeight
|
|
355
|
+
if (!f.placed) {
|
|
356
|
+
f.placed = true
|
|
357
|
+
f.y = f.ty
|
|
358
|
+
f.h = f.th
|
|
359
|
+
draw()
|
|
360
|
+
}
|
|
361
|
+
highlight.dataset.shown = ""
|
|
362
|
+
// cmdk has already scrolled the item into view. Show the old position
|
|
363
|
+
// and let the follower ease to cmdk's.
|
|
364
|
+
if (f.byKey && list.scrollTop !== f.scroll && !reduced.matches) {
|
|
365
|
+
f.scrollTo = list.scrollTop
|
|
366
|
+
list.scrollTop = f.scroll
|
|
367
|
+
}
|
|
368
|
+
f.byKey = false
|
|
369
|
+
if (!f.raf) {
|
|
370
|
+
f.raf = requestAnimationFrame(tick)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
place()
|
|
375
|
+
const frame = requestAnimationFrame(() => {
|
|
376
|
+
highlight.dataset.ready = ""
|
|
377
|
+
})
|
|
378
|
+
const mutations = new MutationObserver(place)
|
|
379
|
+
mutations.observe(sizer, {
|
|
380
|
+
subtree: true,
|
|
381
|
+
childList: true,
|
|
382
|
+
attributes: true,
|
|
383
|
+
attributeFilter: ["data-selected", "hidden"],
|
|
384
|
+
})
|
|
385
|
+
const resize = new ResizeObserver(place)
|
|
386
|
+
resize.observe(sizer)
|
|
387
|
+
|
|
388
|
+
const root = sizer.closest("[cmdk-root]")
|
|
389
|
+
// Only moves between items scroll through the follower. A new query
|
|
390
|
+
// starts at the top of the list at once.
|
|
391
|
+
const onKeyDown = (event: Event) => {
|
|
392
|
+
const { key, ctrlKey } = event as KeyboardEvent
|
|
393
|
+
f.byKey =
|
|
394
|
+
NAVIGATION_KEYS.has(key) || (ctrlKey && "npjk".includes(key))
|
|
395
|
+
}
|
|
396
|
+
// Scrolling by hand takes over from the follower.
|
|
397
|
+
const onScroll = () => {
|
|
398
|
+
if (f.scrollTo === null) {
|
|
399
|
+
f.scroll = list.scrollTop
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const onManualScroll = () => {
|
|
403
|
+
f.scrollTo = null
|
|
404
|
+
f.scroll = list.scrollTop
|
|
405
|
+
}
|
|
406
|
+
root?.addEventListener("keydown", onKeyDown)
|
|
407
|
+
list.addEventListener("scroll", onScroll, { passive: true })
|
|
408
|
+
list.addEventListener("wheel", onManualScroll, { passive: true })
|
|
409
|
+
list.addEventListener("pointerdown", onManualScroll)
|
|
410
|
+
|
|
411
|
+
return () => {
|
|
412
|
+
cancelAnimationFrame(frame)
|
|
413
|
+
cancelAnimationFrame(f.raf)
|
|
414
|
+
mutations.disconnect()
|
|
415
|
+
resize.disconnect()
|
|
416
|
+
root?.removeEventListener("keydown", onKeyDown)
|
|
417
|
+
list.removeEventListener("scroll", onScroll)
|
|
418
|
+
list.removeEventListener("wheel", onManualScroll)
|
|
419
|
+
list.removeEventListener("pointerdown", onManualScroll)
|
|
420
|
+
}
|
|
421
|
+
}, [])
|
|
422
|
+
|
|
423
|
+
return (
|
|
424
|
+
<div
|
|
425
|
+
ref={ref}
|
|
426
|
+
aria-hidden="true"
|
|
427
|
+
role="none"
|
|
428
|
+
data-slot="command-highlight"
|
|
429
|
+
className="bg-muted pointer-events-none absolute top-0 left-0 rounded-sm opacity-0 will-change-transform forced-colors:outline-2 forced-colors:-outline-offset-2 forced-colors:outline-solid forced-colors:outline-[Highlight] in-data-command-palette:rounded-xl data-shown:opacity-100 data-ready:transition-opacity data-ready:duration-fast data-ready:ease-soft"
|
|
104
430
|
/>
|
|
105
431
|
)
|
|
106
432
|
}
|
|
@@ -157,7 +483,21 @@ function CommandSeparator({
|
|
|
157
483
|
}
|
|
158
484
|
|
|
159
485
|
// cmdk writes data-selected="true" or "false" on every item, so the highlight
|
|
160
|
-
//
|
|
486
|
+
// keys on the "true" value. A checked item (`data-checked="true"`) draws the
|
|
487
|
+
// MenuCheck of every menu and list; the check sits in its own span, because
|
|
488
|
+
// MenuCheck also shows for a selected option and every cmdk item carries
|
|
489
|
+
// data-selected. The check hides when the item has a shortcut or a detail.
|
|
490
|
+
// In a CommandList with slidingHighlight, the list's highlight replaces the
|
|
491
|
+
// item's own fill. The highlight is the muted fill, as in every combobox,
|
|
492
|
+
// select and menu. In forced colors, where fills drop, the
|
|
493
|
+
// highlight is a Highlight outline. Palette items are 40px tall and quiet at
|
|
494
|
+
// rest: foreground-secondary text, with the label (CommandItemLabel) in medium
|
|
495
|
+
// weight. The highlighted row has the muted fill, turns its text to
|
|
496
|
+
// foreground and its leading icon to the brand indicator.
|
|
497
|
+
function isChecked(value: unknown) {
|
|
498
|
+
return value === true || value === "true"
|
|
499
|
+
}
|
|
500
|
+
|
|
161
501
|
function CommandItem({
|
|
162
502
|
className,
|
|
163
503
|
children,
|
|
@@ -167,17 +507,41 @@ function CommandItem({
|
|
|
167
507
|
<CommandPrimitive.Item
|
|
168
508
|
data-slot="command-item"
|
|
169
509
|
className={cn(
|
|
170
|
-
"data-[selected=true]:bg-
|
|
510
|
+
"group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[selected=true]:bg-muted not-in-data-command-palette:data-[selected=true]:text-accent-foreground not-in-data-command-palette:data-[selected=true]:**:[svg]:text-accent-foreground in-data-[highlight=slide]:data-[selected=true]:bg-transparent! not-in-data-[highlight=slide]:data-[selected=true]:forced-colors:outline-2 not-in-data-[highlight=slide]:data-[selected=true]:forced-colors:-outline-offset-2 not-in-data-[highlight=slide]:data-[selected=true]:forced-colors:outline-solid not-in-data-[highlight=slide]:data-[selected=true]:forced-colors:outline-[Highlight] in-data-command-palette:h-10 in-data-command-palette:gap-3 in-data-command-palette:rounded-xl in-data-command-palette:px-2.5 in-data-command-palette:text-foreground-secondary in-data-command-palette:data-[selected=true]:text-foreground in-data-command-palette:transition-[color] in-data-command-palette:duration-palette-tint in-data-command-palette:ease-soft data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-[opacity,color] [&>svg:not([class*='opacity-'])]:duration-moderate not-in-data-command-palette:data-[selected=true]:[&>svg:not([class*='opacity-'])]:opacity-85 in-data-command-palette:[&>svg:not([class*='opacity-'])]:duration-palette-tint in-data-command-palette:[&>svg:not([class*='opacity-'])]:ease-soft in-data-command-palette:data-[selected=true]:[&>svg:not([class*='opacity-'])]:opacity-100 in-data-command-palette:data-[selected=true]:[&>svg:not([class*='opacity-'])]:text-brand-indicator",
|
|
171
511
|
className
|
|
172
512
|
)}
|
|
173
513
|
{...props}
|
|
174
514
|
>
|
|
175
515
|
{children}
|
|
176
|
-
<
|
|
516
|
+
<span
|
|
517
|
+
data-slot="command-item-check"
|
|
518
|
+
data-checked={isChecked(props["data-checked" as keyof typeof props]) ? "" : undefined}
|
|
519
|
+
className={cn(
|
|
520
|
+
menuCheckItem,
|
|
521
|
+
"ms-auto flex shrink-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-has-data-[slot=command-item-detail]/command-item:hidden"
|
|
522
|
+
)}
|
|
523
|
+
>
|
|
524
|
+
<MenuCheck />
|
|
525
|
+
</span>
|
|
177
526
|
</CommandPrimitive.Item>
|
|
178
527
|
)
|
|
179
528
|
}
|
|
180
529
|
|
|
530
|
+
// An item's label. In the palette it is medium weight; text after it, such as
|
|
531
|
+
// a hint or CommandItemDetail, keeps the regular weight.
|
|
532
|
+
function CommandItemLabel({
|
|
533
|
+
className,
|
|
534
|
+
...props
|
|
535
|
+
}: React.ComponentProps<"span">) {
|
|
536
|
+
return (
|
|
537
|
+
<span
|
|
538
|
+
data-slot="command-item-label"
|
|
539
|
+
className={cn("min-w-0 truncate in-data-command-palette:font-medium", className)}
|
|
540
|
+
{...props}
|
|
541
|
+
/>
|
|
542
|
+
)
|
|
543
|
+
}
|
|
544
|
+
|
|
181
545
|
function CommandShortcut({
|
|
182
546
|
className,
|
|
183
547
|
...props
|
|
@@ -186,7 +550,42 @@ function CommandShortcut({
|
|
|
186
550
|
<span
|
|
187
551
|
data-slot="command-shortcut"
|
|
188
552
|
className={cn(
|
|
189
|
-
"text-muted-foreground group-data-[selected=true]/command-item:text-foreground
|
|
553
|
+
"text-muted-foreground group-data-[selected=true]/command-item:text-foreground ms-auto text-xs tracking-widest",
|
|
554
|
+
className
|
|
555
|
+
)}
|
|
556
|
+
{...props}
|
|
557
|
+
/>
|
|
558
|
+
)
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Where an item lives, such as "Production · Acme", at the end of the row. It
|
|
562
|
+
// shows on the highlighted item only: repeated on every row it is noise. It
|
|
563
|
+
// slides in 4px from a 1px blur as the highlight arrives (opacity 180ms,
|
|
564
|
+
// transform 220ms, after 40ms) and leaves in 90ms. Reduced motion fades only.
|
|
565
|
+
function CommandItemDetail({
|
|
566
|
+
className,
|
|
567
|
+
...props
|
|
568
|
+
}: React.ComponentProps<"span">) {
|
|
569
|
+
return (
|
|
570
|
+
<span
|
|
571
|
+
data-slot="command-item-detail"
|
|
572
|
+
className={cn(
|
|
573
|
+
"text-muted-foreground ms-auto max-w-[55%] shrink-0 truncate ps-3 text-xs opacity-0 -translate-x-1 rtl:translate-x-1 blur-[1px] transition-[opacity,translate,filter] duration-palette-detail-exit ease-soft group-data-[selected=true]/command-item:translate-x-0 group-data-[selected=true]/command-item:opacity-100 group-data-[selected=true]/command-item:blur-none group-data-[selected=true]/command-item:delay-(--transition-duration-palette-detail-delay) group-data-[selected=true]/command-item:duration-[var(--transition-duration-palette-move),var(--transition-duration-palette-detail-move),var(--transition-duration-palette-move)] group-data-[selected=true]/command-item:ease-out motion-reduce:translate-x-0 motion-reduce:blur-none",
|
|
574
|
+
className
|
|
575
|
+
)}
|
|
576
|
+
{...props}
|
|
577
|
+
/>
|
|
578
|
+
)
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// Key hints under the list. Each direct child is one hint: Kbd keys and a
|
|
582
|
+
// label. The keys render at 18px here.
|
|
583
|
+
function CommandFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
584
|
+
return (
|
|
585
|
+
<div
|
|
586
|
+
data-slot="command-footer"
|
|
587
|
+
className={cn(
|
|
588
|
+
"border-border bg-muted/50 text-muted-foreground flex h-10 shrink-0 items-center gap-4 border-t px-3.5 text-xs *:flex *:items-center *:gap-1 **:data-[slot=kbd]:h-4.5 **:data-[slot=kbd]:min-w-4.5",
|
|
190
589
|
className
|
|
191
590
|
)}
|
|
192
591
|
{...props}
|
|
@@ -202,6 +601,9 @@ export {
|
|
|
202
601
|
CommandEmpty,
|
|
203
602
|
CommandGroup,
|
|
204
603
|
CommandItem,
|
|
604
|
+
CommandItemLabel,
|
|
205
605
|
CommandShortcut,
|
|
606
|
+
CommandItemDetail,
|
|
206
607
|
CommandSeparator,
|
|
608
|
+
CommandFooter,
|
|
207
609
|
}
|
|
@@ -4,7 +4,11 @@ import * as React from "react"
|
|
|
4
4
|
import { ContextMenu as ContextMenuPrimitive } from "@base-ui/react/context-menu"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
|
-
import {
|
|
7
|
+
import { popupMotion } from "../../lib/popup-motion.ts"
|
|
8
|
+
import { ChevronRightIcon } from "lucide-react"
|
|
9
|
+
import { usePopupDir } from "../../lib/popup-direction.ts"
|
|
10
|
+
import { triggerSlot } from "../../lib/trigger-slot.ts"
|
|
11
|
+
import { menuCheckItem, menuItemDisabled, menuRadioItem, MenuCheck } from "../../lib/menu-item.tsx"
|
|
8
12
|
|
|
9
13
|
function ContextMenu({ ...props }: ContextMenuPrimitive.Root.Props) {
|
|
10
14
|
return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />
|
|
@@ -22,7 +26,7 @@ function ContextMenuTrigger({
|
|
|
22
26
|
}: ContextMenuPrimitive.Trigger.Props) {
|
|
23
27
|
return (
|
|
24
28
|
<ContextMenuPrimitive.Trigger
|
|
25
|
-
|
|
29
|
+
{...triggerSlot("context-menu-trigger", props.render)}
|
|
26
30
|
className={cn("select-none", className)}
|
|
27
31
|
{...props}
|
|
28
32
|
/>
|
|
@@ -41,9 +45,11 @@ function ContextMenuContent({
|
|
|
41
45
|
ContextMenuPrimitive.Positioner.Props,
|
|
42
46
|
"align" | "alignOffset" | "side" | "sideOffset"
|
|
43
47
|
>) {
|
|
48
|
+
const dir = usePopupDir()
|
|
44
49
|
return (
|
|
45
50
|
<ContextMenuPrimitive.Portal>
|
|
46
51
|
<ContextMenuPrimitive.Positioner
|
|
52
|
+
dir={dir}
|
|
47
53
|
className="isolate z-50 outline-none"
|
|
48
54
|
align={align}
|
|
49
55
|
alignOffset={alignOffset}
|
|
@@ -52,7 +58,7 @@ function ContextMenuContent({
|
|
|
52
58
|
>
|
|
53
59
|
<ContextMenuPrimitive.Popup
|
|
54
60
|
data-slot="context-menu-content"
|
|
55
|
-
className={cn("
|
|
61
|
+
className={cn("bg-popover text-popover-foreground shadow-overlay rounded-xl p-1.25 z-50 max-h-(--available-height) min-w-36 overflow-x-hidden overflow-y-auto outline-none", popupMotion, className )}
|
|
56
62
|
{...props}
|
|
57
63
|
/>
|
|
58
64
|
</ContextMenuPrimitive.Positioner>
|
|
@@ -78,7 +84,7 @@ function ContextMenuLabel({
|
|
|
78
84
|
data-slot="context-menu-label"
|
|
79
85
|
data-inset={inset}
|
|
80
86
|
className={cn(
|
|
81
|
-
"text-muted-foreground px-2 py-1.5 text-xs font-medium data-inset:
|
|
87
|
+
"text-muted-foreground px-2 py-1.5 text-xs font-medium data-inset:ps-8",
|
|
82
88
|
className
|
|
83
89
|
)}
|
|
84
90
|
{...props}
|
|
@@ -101,7 +107,8 @@ function ContextMenuItem({
|
|
|
101
107
|
data-inset={inset}
|
|
102
108
|
data-variant={variant}
|
|
103
109
|
className={cn(
|
|
104
|
-
|
|
110
|
+
menuItemDisabled,
|
|
111
|
+
"not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground data-[variant=destructive]:text-destructive-text data-[variant=destructive]:not-data-disabled:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive-text data-[variant=destructive]:*:[svg]:text-destructive-text data-[variant=destructive]:[&>svg:not([class*='opacity-'])]:opacity-100 not-data-[variant=destructive]:not-data-disabled:focus:*:[svg]:text-accent-foreground group/context-menu-item relative flex min-h-8.5 cursor-default items-center gap-2 rounded-lg px-2 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
|
|
105
112
|
className
|
|
106
113
|
)}
|
|
107
114
|
{...props}
|
|
@@ -128,13 +135,14 @@ function ContextMenuSubTrigger({
|
|
|
128
135
|
data-slot="context-menu-sub-trigger"
|
|
129
136
|
data-inset={inset}
|
|
130
137
|
className={cn(
|
|
131
|
-
|
|
138
|
+
menuItemDisabled,
|
|
139
|
+
"not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground data-popup-open:bg-muted data-popup-open:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-lg px-2 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
|
|
132
140
|
className
|
|
133
141
|
)}
|
|
134
142
|
{...props}
|
|
135
143
|
>
|
|
136
144
|
{children}
|
|
137
|
-
<ChevronRightIcon className="
|
|
145
|
+
<ChevronRightIcon className="ms-auto rtl:rotate-180" />
|
|
138
146
|
</ContextMenuPrimitive.SubmenuTrigger>
|
|
139
147
|
)
|
|
140
148
|
}
|
|
@@ -145,8 +153,7 @@ function ContextMenuSubContent({
|
|
|
145
153
|
return (
|
|
146
154
|
<ContextMenuContent
|
|
147
155
|
data-slot="context-menu-sub-content"
|
|
148
|
-
|
|
149
|
-
side="right"
|
|
156
|
+
side="inline-end"
|
|
150
157
|
{...props}
|
|
151
158
|
/>
|
|
152
159
|
)
|
|
@@ -166,17 +173,16 @@ function ContextMenuCheckboxItem({
|
|
|
166
173
|
data-slot="context-menu-checkbox-item"
|
|
167
174
|
data-inset={inset}
|
|
168
175
|
className={cn(
|
|
169
|
-
|
|
176
|
+
menuItemDisabled,
|
|
177
|
+
menuCheckItem,
|
|
178
|
+
"not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-lg px-2 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85 pe-8",
|
|
170
179
|
className
|
|
171
180
|
)}
|
|
172
181
|
checked={checked}
|
|
173
182
|
{...props}
|
|
174
183
|
>
|
|
175
|
-
<span className="pointer-events-none absolute
|
|
176
|
-
<
|
|
177
|
-
<CheckIcon
|
|
178
|
-
/>
|
|
179
|
-
</ContextMenuPrimitive.CheckboxItemIndicator>
|
|
184
|
+
<span className="pointer-events-none absolute end-2 flex items-center justify-center">
|
|
185
|
+
<MenuCheck />
|
|
180
186
|
</span>
|
|
181
187
|
{children}
|
|
182
188
|
</ContextMenuPrimitive.CheckboxItem>
|
|
@@ -207,16 +213,15 @@ function ContextMenuRadioItem({
|
|
|
207
213
|
data-slot="context-menu-radio-item"
|
|
208
214
|
data-inset={inset}
|
|
209
215
|
className={cn(
|
|
210
|
-
|
|
216
|
+
menuItemDisabled,
|
|
217
|
+
menuRadioItem,
|
|
218
|
+
"not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2 rounded-lg px-2 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85 pe-8",
|
|
211
219
|
className
|
|
212
220
|
)}
|
|
213
221
|
{...props}
|
|
214
222
|
>
|
|
215
|
-
<span className="pointer-events-none absolute
|
|
216
|
-
<
|
|
217
|
-
<CheckIcon
|
|
218
|
-
/>
|
|
219
|
-
</ContextMenuPrimitive.RadioItemIndicator>
|
|
223
|
+
<span className="pointer-events-none absolute end-2 flex items-center justify-center">
|
|
224
|
+
<MenuCheck />
|
|
220
225
|
</span>
|
|
221
226
|
{children}
|
|
222
227
|
</ContextMenuPrimitive.RadioItem>
|
|
@@ -230,7 +235,7 @@ function ContextMenuSeparator({
|
|
|
230
235
|
return (
|
|
231
236
|
<ContextMenuPrimitive.Separator
|
|
232
237
|
data-slot="context-menu-separator"
|
|
233
|
-
className={cn("bg-border -mx-1 my-1 h-px", className)}
|
|
238
|
+
className={cn("bg-border -mx-1.25 my-1.25 h-px", className)}
|
|
234
239
|
{...props}
|
|
235
240
|
/>
|
|
236
241
|
)
|
|
@@ -244,7 +249,7 @@ function ContextMenuShortcut({
|
|
|
244
249
|
<span
|
|
245
250
|
data-slot="context-menu-shortcut"
|
|
246
251
|
className={cn(
|
|
247
|
-
"text-muted-foreground group-focus/context-menu-item:text-accent-foreground
|
|
252
|
+
"text-muted-foreground group-focus/context-menu-item:text-accent-foreground ms-auto text-xs tracking-widest",
|
|
248
253
|
className
|
|
249
254
|
)}
|
|
250
255
|
{...props}
|