@vendure-io/ui 3.0.0-next.4 → 3.0.0-next.5
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 +12 -11
- package/src/components/atoms/alert-dialog.tsx +1 -4
- package/src/components/atoms/alert.tsx +59 -35
- package/src/components/atoms/badge.tsx +2 -2
- package/src/components/atoms/breadcrumb.tsx +124 -49
- package/src/components/atoms/button-group.tsx +1 -1
- package/src/components/atoms/button.tsx +2 -2
- package/src/components/atoms/calendar.tsx +2 -2
- package/src/components/atoms/card.tsx +15 -2
- package/src/components/atoms/chart.tsx +3 -3
- package/src/components/atoms/checkbox.tsx +1 -1
- package/src/components/atoms/combobox.tsx +37 -26
- package/src/components/atoms/command.tsx +3 -3
- package/src/components/atoms/context-menu.tsx +5 -5
- package/src/components/atoms/dialog.tsx +30 -14
- package/src/components/atoms/dropdown-menu.tsx +1 -1
- package/src/components/atoms/hover-card.tsx +1 -1
- package/src/components/atoms/input-group.tsx +30 -12
- package/src/components/atoms/input-otp.tsx +2 -2
- package/src/components/atoms/input.tsx +13 -3
- package/src/components/atoms/menubar.tsx +2 -2
- package/src/components/atoms/native-select.tsx +1 -1
- package/src/components/atoms/navigation-menu.tsx +3 -3
- package/src/components/atoms/pagination.tsx +9 -3
- package/src/components/atoms/popover.tsx +1 -1
- package/src/components/atoms/select.tsx +3 -3
- package/src/components/atoms/sheet.tsx +35 -15
- package/src/components/atoms/sidebar.tsx +200 -31
- package/src/components/atoms/skeleton.tsx +6 -3
- package/src/components/atoms/tabs.tsx +6 -2
- package/src/components/atoms/textarea.tsx +1 -1
- package/src/components/atoms/toggle.tsx +1 -1
- package/src/components/molecules/action-needed.tsx +483 -0
- package/src/components/molecules/anonymized-token.tsx +52 -8
- package/src/components/molecules/chip.tsx +37 -19
- package/src/components/molecules/choice-card.tsx +114 -9
- package/src/components/molecules/code-block/package-manager-storage.ts +50 -0
- package/src/components/molecules/code-block/process-code.ts +1 -1
- package/src/components/molecules/code-block.tsx +58 -47
- package/src/components/molecules/combobox-free-text.tsx +75 -20
- package/src/components/molecules/confirm-dialog.tsx +11 -1
- package/src/components/molecules/copyable-text.tsx +10 -8
- package/src/components/molecules/data-table/data-table-filters.tsx +14 -2
- package/src/components/molecules/data-table/data-table-helpers.tsx +109 -3
- package/src/components/molecules/data-table/data-table-row-count-storage.tsx +88 -0
- package/src/components/molecules/data-table/data-table-selection-storage.tsx +33 -15
- package/src/components/molecules/data-table/data-table-types.tsx +123 -13
- package/src/components/molecules/data-table/data-table.tsx +109 -49
- package/src/components/molecules/data-table/table-pagination.tsx +96 -14
- package/src/components/molecules/date-picker.tsx +55 -24
- package/src/components/molecules/date-range-picker.tsx +54 -23
- package/src/components/molecules/date-time-picker.tsx +60 -24
- package/src/components/molecules/date-time.tsx +38 -3
- package/src/components/molecules/elapsed-time.tsx +61 -12
- package/src/components/molecules/file-dropzone.tsx +139 -39
- package/src/components/molecules/format-provider.tsx +14 -4
- package/src/components/molecules/id-chip-chrome.tsx +114 -0
- package/src/components/molecules/id-chip.tsx +3 -107
- package/src/components/molecules/issued-secret.tsx +1 -1
- package/src/components/molecules/live-indicator.tsx +1 -1
- package/src/components/molecules/money.tsx +44 -3
- package/src/components/molecules/multi-select.tsx +56 -14
- package/src/components/molecules/page-header.tsx +6 -2
- package/src/components/molecules/password-input.tsx +11 -10
- package/src/components/molecules/relative-time.tsx +88 -16
- package/src/components/molecules/search-trigger.tsx +5 -3
- package/src/components/molecules/secret-value.tsx +10 -2
- package/src/components/molecules/stat-card.tsx +143 -33
- package/src/components/molecules/state-views/empty-state.tsx +16 -12
- package/src/components/molecules/state-views/error-state.tsx +19 -15
- package/src/components/molecules/state-views/loading-state.tsx +16 -6
- package/src/components/molecules/state-views/skeleton-parts.tsx +6 -4
- package/src/components/molecules/status-badge.tsx +11 -35
- package/src/components/molecules/time-tooltip.tsx +55 -1
- package/src/hooks/use-copy.ts +3 -1
- package/src/lib/deprecated.ts +71 -0
- package/src/lib/field-surface.ts +7 -7
- package/src/lib/format-messages.ts +192 -0
- package/src/lib/highlight.ts +1 -1
- package/src/lib/menu-item.tsx +1 -1
- package/src/lib/tint-recipes.ts +10 -5
- package/src/lib/utils.ts +19 -1
- package/src/lib/dialog-padding.ts +0 -48
|
@@ -259,7 +259,7 @@ function ChartTooltipContent({
|
|
|
259
259
|
return (
|
|
260
260
|
<div
|
|
261
261
|
className={cn(
|
|
262
|
-
"bg-popover text-popover-foreground grid min-w-32 items-start gap-1.5 rounded-
|
|
262
|
+
"bg-popover text-popover-foreground grid min-w-32 items-start gap-1.5 rounded-2xl px-2.5 py-1.5 text-xs shadow-overlay",
|
|
263
263
|
className
|
|
264
264
|
)}
|
|
265
265
|
>
|
|
@@ -290,7 +290,7 @@ function ChartTooltipContent({
|
|
|
290
290
|
!hideIndicator && (
|
|
291
291
|
<div
|
|
292
292
|
className={cn(
|
|
293
|
-
"shrink-0 rounded-
|
|
293
|
+
"shrink-0 rounded-sm border-(--color-border) bg-(--color-bg)",
|
|
294
294
|
{
|
|
295
295
|
"h-2.5 w-2.5": indicator === "dot",
|
|
296
296
|
"w-1": indicator === "line",
|
|
@@ -380,7 +380,7 @@ function ChartLegendContent({
|
|
|
380
380
|
<itemConfig.icon />
|
|
381
381
|
) : (
|
|
382
382
|
<div
|
|
383
|
-
className="h-2 w-2 shrink-0 rounded-
|
|
383
|
+
className="h-2 w-2 shrink-0 rounded-sm"
|
|
384
384
|
style={{
|
|
385
385
|
backgroundColor: item.color,
|
|
386
386
|
}}
|
|
@@ -70,7 +70,7 @@ function Checkbox({ className, indeterminate, ...props }: CheckboxPrimitive.Root
|
|
|
70
70
|
<CheckboxPrimitive.Root
|
|
71
71
|
data-slot="checkbox"
|
|
72
72
|
className={(state) => cn(
|
|
73
|
-
"group/checkbox border-control-border dark:bg-input/30 data-checked:text-primary-foreground data-checked:border-primary data-indeterminate:text-primary-foreground data-indeterminate:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:focus-visible:outline-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 peer relative flex size-4 shrink-0 items-center justify-center rounded-
|
|
73
|
+
"group/checkbox border-control-border dark:bg-input/30 data-checked:text-primary-foreground data-checked:border-primary data-indeterminate:text-primary-foreground data-indeterminate:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:focus-visible:outline-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 peer relative flex size-4 shrink-0 items-center justify-center rounded-md border outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:ring-3",
|
|
74
74
|
rootTransition,
|
|
75
75
|
hole,
|
|
76
76
|
fill,
|
|
@@ -5,8 +5,8 @@ import { Combobox as ComboboxPrimitive } from "@base-ui/react"
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
7
|
import { MenuCheck, menuCheckItem, menuItemDisabled } from "../../lib/menu-item.tsx"
|
|
8
|
-
import { statusChipRing } from "
|
|
9
|
-
import { fieldSurface, fieldSurfaceWithin } from "
|
|
8
|
+
import { statusChipRing } from "../../lib/tint-recipes.ts"
|
|
9
|
+
import { fieldSurface, fieldSurfaceWithin } from "../../lib/field-surface.ts"
|
|
10
10
|
import { popupMotion } from "../../lib/popup-motion.ts"
|
|
11
11
|
import { Button } from "@vendure-io/ui/components/atoms/button"
|
|
12
12
|
import {
|
|
@@ -19,6 +19,8 @@ import { ChevronDownIcon, Loader2Icon, XIcon } from "lucide-react"
|
|
|
19
19
|
import { usePopupDir } from "../../lib/popup-direction.ts"
|
|
20
20
|
import { usePopupAlign } from "../../lib/popup-align.ts"
|
|
21
21
|
import { hasName, nameFrom, useRegisteredRef } from "../../lib/control-name.ts"
|
|
22
|
+
import { useMessages } from "../../lib/format-messages.ts"
|
|
23
|
+
import { warnDeprecated } from "../../lib/deprecated.ts"
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* The controls of the nearest Combobox. Base UI names the trigger and the
|
|
@@ -39,7 +41,7 @@ type ComboboxPagingProps = {
|
|
|
39
41
|
/**
|
|
40
42
|
* Asks for the next page of a server-searched list. Called once when the
|
|
41
43
|
* list scrolls near its end, or the arrow keys reach its last option, while
|
|
42
|
-
* `hasMore` is set and `
|
|
44
|
+
* `hasMore` is set and `isLoading` is not. It is called again once the
|
|
43
45
|
* options change, the search changes, the list reopens, or the list
|
|
44
46
|
* scrolls away from its end and back: a failed fetch is retried by
|
|
45
47
|
* scrolling, never in a loop.
|
|
@@ -52,8 +54,13 @@ type ComboboxPagingProps = {
|
|
|
52
54
|
* assistive technology and announces `loadingLabel`. With no options yet,
|
|
53
55
|
* the loading row takes the place of ComboboxEmpty.
|
|
54
56
|
*/
|
|
57
|
+
isLoading?: boolean
|
|
58
|
+
/** @deprecated Use `isLoading`. Removed in 4.0. */
|
|
55
59
|
loading?: boolean
|
|
56
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Announced to screen readers while `isLoading` is set.
|
|
62
|
+
* @default `messages.combobox.loading`, "Loading…"
|
|
63
|
+
*/
|
|
57
64
|
loadingLabel?: string
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -62,7 +69,7 @@ type ComboboxPagingProps = {
|
|
|
62
69
|
* Null when the Combobox takes none of the paging props.
|
|
63
70
|
*/
|
|
64
71
|
type ComboboxPaging = {
|
|
65
|
-
|
|
72
|
+
isLoading: boolean
|
|
66
73
|
loadingLabel: string
|
|
67
74
|
canLoadMore: boolean
|
|
68
75
|
list: HTMLElement | null
|
|
@@ -78,12 +85,15 @@ const ComboboxPagingContext = React.createContext<ComboboxPaging | null>(null)
|
|
|
78
85
|
function Combobox<Value, Multiple extends boolean | undefined = false, Item = Value>({
|
|
79
86
|
onLoadMore,
|
|
80
87
|
hasMore = false,
|
|
88
|
+
isLoading: isLoadingProp,
|
|
81
89
|
loading,
|
|
82
|
-
loadingLabel
|
|
90
|
+
loadingLabel,
|
|
83
91
|
onItemHighlighted,
|
|
84
92
|
onInputValueChange,
|
|
85
93
|
...props
|
|
86
94
|
}: ComboboxPrimitive.Root.Props<Value, Multiple, Item> & ComboboxPagingProps) {
|
|
95
|
+
if (loading !== undefined) warnDeprecated("Combobox", "loading", "isLoading")
|
|
96
|
+
const isLoading = isLoadingProp ?? loading
|
|
87
97
|
const [trigger, setTrigger] = React.useState<HTMLElement | null>(null)
|
|
88
98
|
const [input, setInput] = React.useState<HTMLElement | null>(null)
|
|
89
99
|
const [list, setList] = React.useState<HTMLElement | null>(null)
|
|
@@ -91,16 +101,16 @@ function Combobox<Value, Multiple extends boolean | undefined = false, Item = Va
|
|
|
91
101
|
|
|
92
102
|
// Read at call time, so an observer set up on an earlier render sees the
|
|
93
103
|
// current flags.
|
|
94
|
-
const latest = React.useRef({ onLoadMore, hasMore,
|
|
104
|
+
const latest = React.useRef({ onLoadMore, hasMore, isLoading })
|
|
95
105
|
React.useLayoutEffect(() => {
|
|
96
|
-
latest.current = { onLoadMore, hasMore,
|
|
106
|
+
latest.current = { onLoadMore, hasMore, isLoading }
|
|
97
107
|
})
|
|
98
108
|
// Set once a page is asked for. Scrolling fires many events before the
|
|
99
|
-
// consumer's `
|
|
109
|
+
// consumer's `isLoading` flag turns on; the latch keeps that to one call.
|
|
100
110
|
const latched = React.useRef(false)
|
|
101
111
|
const requestMore = React.useCallback(() => {
|
|
102
112
|
const current = latest.current
|
|
103
|
-
if (!current.onLoadMore || !current.hasMore || current.
|
|
113
|
+
if (!current.onLoadMore || !current.hasMore || current.isLoading || latched.current) return
|
|
104
114
|
latched.current = true
|
|
105
115
|
current.onLoadMore()
|
|
106
116
|
}, [])
|
|
@@ -109,13 +119,14 @@ function Combobox<Value, Multiple extends boolean | undefined = false, Item = Va
|
|
|
109
119
|
}, [])
|
|
110
120
|
|
|
111
121
|
const canLoadMore = onLoadMore !== undefined
|
|
112
|
-
const enabled = canLoadMore ||
|
|
122
|
+
const enabled = canLoadMore || isLoading !== undefined
|
|
123
|
+
const t = useMessages("combobox", { loading: loadingLabel })
|
|
113
124
|
const paging = React.useMemo(
|
|
114
125
|
() =>
|
|
115
126
|
enabled
|
|
116
127
|
? {
|
|
117
|
-
|
|
118
|
-
loadingLabel,
|
|
128
|
+
isLoading: !!isLoading,
|
|
129
|
+
loadingLabel: t.loading,
|
|
119
130
|
canLoadMore,
|
|
120
131
|
list,
|
|
121
132
|
setList,
|
|
@@ -123,7 +134,7 @@ function Combobox<Value, Multiple extends boolean | undefined = false, Item = Va
|
|
|
123
134
|
rearm,
|
|
124
135
|
}
|
|
125
136
|
: null,
|
|
126
|
-
[enabled,
|
|
137
|
+
[enabled, isLoading, t.loading, canLoadMore, list, requestMore, rearm]
|
|
127
138
|
)
|
|
128
139
|
|
|
129
140
|
return (
|
|
@@ -330,7 +341,7 @@ function ComboboxContent({
|
|
|
330
341
|
data-slot="combobox-content"
|
|
331
342
|
data-chips={!!anchor}
|
|
332
343
|
data-field-group={!!fieldGroup}
|
|
333
|
-
className={cn("bg-popover text-popover-foreground shadow-overlay group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] overflow-hidden rounded-
|
|
344
|
+
className={cn("bg-popover text-popover-foreground shadow-overlay group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] overflow-hidden rounded-2xl data-[chips=true]:min-w-(--anchor-width) data-[field-group=true]:min-w-(--anchor-width) *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:shadow-none *:data-[slot=input-group]:inset-ring-0", popupMotion, className )}
|
|
334
345
|
// A closing list is gone for assistive technology: the input no
|
|
335
346
|
// longer points at it, and it takes no input while it fades out.
|
|
336
347
|
// With the search input inside it, the popup is a dialog: it takes
|
|
@@ -418,9 +429,9 @@ function ComboboxList({ className, children, ref, ...props }: ComboboxPrimitive.
|
|
|
418
429
|
{...(hasName(props) ? {} : name)}
|
|
419
430
|
ref={listRef}
|
|
420
431
|
data-slot="combobox-list"
|
|
421
|
-
aria-busy={paging?.
|
|
432
|
+
aria-busy={paging?.isLoading || undefined}
|
|
422
433
|
className={cn(
|
|
423
|
-
"no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
|
|
434
|
+
"no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1.25 data-empty:p-0",
|
|
424
435
|
className
|
|
425
436
|
)}
|
|
426
437
|
{...props}
|
|
@@ -431,7 +442,7 @@ function ComboboxList({ className, children, ref, ...props }: ComboboxPrimitive.
|
|
|
431
442
|
{/* Decorative: a listbox holds only options and groups, so the
|
|
432
443
|
row is hidden from assistive technology. The list is busy
|
|
433
444
|
and the status below announces the load. */}
|
|
434
|
-
{paging.
|
|
445
|
+
{paging.isLoading && (
|
|
435
446
|
<div
|
|
436
447
|
data-slot="combobox-loading"
|
|
437
448
|
aria-hidden="true"
|
|
@@ -450,7 +461,7 @@ function ComboboxList({ className, children, ref, ...props }: ComboboxPrimitive.
|
|
|
450
461
|
listbox, which may hold only options and groups. */}
|
|
451
462
|
{paging && (
|
|
452
463
|
<ComboboxPrimitive.Status data-slot="combobox-status" className="sr-only">
|
|
453
|
-
{paging.
|
|
464
|
+
{paging.isLoading ? paging.loadingLabel : null}
|
|
454
465
|
</ComboboxPrimitive.Status>
|
|
455
466
|
)}
|
|
456
467
|
</>
|
|
@@ -473,7 +484,7 @@ function ComboboxItem({
|
|
|
473
484
|
className={cn(
|
|
474
485
|
menuItemDisabled,
|
|
475
486
|
menuCheckItem,
|
|
476
|
-
"not-data-disabled:data-highlighted:bg-muted not-data-disabled:data-highlighted:text-accent-foreground data-disabled:data-highlighted:outline-solid data-disabled:data-highlighted:outline-2 data-disabled:data-highlighted:-outline-offset-2 data-disabled:data-highlighted:outline-ring not-data-[variant=destructive]:not-data-disabled:data-highlighted:**:text-accent-foreground relative flex min-h-8.5 w-full cursor-default items-center gap-2 rounded-
|
|
487
|
+
"not-data-disabled:data-highlighted:bg-muted not-data-disabled:data-highlighted:text-accent-foreground data-disabled:data-highlighted:outline-solid data-disabled:data-highlighted:outline-2 data-disabled:data-highlighted:-outline-offset-2 data-disabled:data-highlighted:outline-ring not-data-[variant=destructive]:not-data-disabled:data-highlighted:**:text-accent-foreground relative flex min-h-8.5 w-full cursor-default items-center gap-2 rounded-[calc(var(--radius-2xl)-5px)] py-1.5 pe-8 ps-2 text-sm outline-hidden select-none [&_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:data-highlighted:[&>svg:not([class*='opacity-'])]:opacity-85",
|
|
477
488
|
className
|
|
478
489
|
)}
|
|
479
490
|
{...props}
|
|
@@ -518,13 +529,13 @@ function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
|
|
|
518
529
|
// While a page loads, the list's loading row stands in for the empty state:
|
|
519
530
|
// a new search has no options yet, but it is not empty.
|
|
520
531
|
function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
|
|
521
|
-
const
|
|
532
|
+
const isLoading = !!React.useContext(ComboboxPagingContext)?.isLoading
|
|
522
533
|
return (
|
|
523
534
|
<ComboboxPrimitive.Empty
|
|
524
535
|
data-slot="combobox-empty"
|
|
525
536
|
className={cn(
|
|
526
537
|
"text-muted-foreground hidden w-full justify-center py-2 text-center text-sm group-data-empty/combobox-content:flex",
|
|
527
|
-
|
|
538
|
+
isLoading && "group-data-empty/combobox-content:hidden",
|
|
528
539
|
className
|
|
529
540
|
)}
|
|
530
541
|
{...props}
|
|
@@ -567,9 +578,9 @@ function ComboboxChips({
|
|
|
567
578
|
// muted field it sits on, with a grey outline, so each value stands out.
|
|
568
579
|
// It has the Chip height, 24px, and is denser than a standalone Chip: the
|
|
569
580
|
// label is 8px from the edge, so a field fits more of them. In the 34px
|
|
570
|
-
// field it sits 5px from the edge, so its corner is the field's
|
|
571
|
-
// 5px,
|
|
572
|
-
// chip's
|
|
581
|
+
// field it sits 5px from the edge, so its corner is the field's 8px minus that
|
|
582
|
+
// 5px, 3px. The remove button sits 4px inside the chip, so its corner is the
|
|
583
|
+
// chip's 3px minus 4px, which is square.
|
|
573
584
|
function ComboboxChip({
|
|
574
585
|
className,
|
|
575
586
|
children,
|
|
@@ -585,7 +596,7 @@ function ComboboxChip({
|
|
|
585
596
|
<ComboboxPrimitive.Chip
|
|
586
597
|
data-slot="combobox-chip"
|
|
587
598
|
className={cn(
|
|
588
|
-
"bg-accent [--status-tone:var(--neutral-text)]", statusChipRing, "text-foreground flex h-6 w-fit items-center justify-center gap-1.5 rounded-[calc(var(--radius-
|
|
599
|
+
"bg-accent [--status-tone:var(--neutral-text)]", statusChipRing, "text-foreground flex h-6 w-fit items-center justify-center gap-1.5 rounded-[calc(var(--radius-xl)-5px)] ps-2 pe-2 text-xs font-medium whitespace-nowrap has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pe-1",
|
|
589
600
|
className
|
|
590
601
|
)}
|
|
591
602
|
{...props}
|
|
@@ -93,7 +93,7 @@ function CommandInput({
|
|
|
93
93
|
// Unboxed: the input runs edge to edge above a hairline, with no field
|
|
94
94
|
// border, fill or ring. 54px with 16px text in the palette dialog.
|
|
95
95
|
<div data-slot="command-input-wrapper" className="border-border border-b">
|
|
96
|
-
<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!">
|
|
96
|
+
<InputGroup className="h-10! rounded-none! border-0! bg-transparent! pe-3.5 shadow-none! inset-ring-0! 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!">
|
|
97
97
|
<CommandPrimitive.Input
|
|
98
98
|
data-slot="command-input"
|
|
99
99
|
className={cn(
|
|
@@ -336,7 +336,7 @@ function CommandHighlight() {
|
|
|
336
336
|
aria-hidden="true"
|
|
337
337
|
role="none"
|
|
338
338
|
data-slot="command-highlight"
|
|
339
|
-
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-
|
|
339
|
+
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-[calc(var(--radius-3xl)-8px)] data-shown:opacity-100 data-ready:transition-opacity data-ready:duration-fast data-ready:ease-soft in-data-command-palette:transition-none!"
|
|
340
340
|
/>
|
|
341
341
|
)
|
|
342
342
|
}
|
|
@@ -419,7 +419,7 @@ function CommandItem({
|
|
|
419
419
|
<CommandPrimitive.Item
|
|
420
420
|
data-slot="command-item"
|
|
421
421
|
className={cn(
|
|
422
|
-
"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-
|
|
422
|
+
"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-[calc(var(--radius-3xl)-8px)] in-data-command-palette:px-2.5 in-data-command-palette:text-foreground-secondary in-data-command-palette:data-[selected=true]:text-foreground 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-'])]:transition-none! 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",
|
|
423
423
|
className
|
|
424
424
|
)}
|
|
425
425
|
{...props}
|
|
@@ -58,7 +58,7 @@ function ContextMenuContent({
|
|
|
58
58
|
>
|
|
59
59
|
<ContextMenuPrimitive.Popup
|
|
60
60
|
data-slot="context-menu-content"
|
|
61
|
-
className={cn("bg-popover text-popover-foreground shadow-overlay rounded-
|
|
61
|
+
className={cn("bg-popover text-popover-foreground shadow-overlay rounded-2xl p-1.25 z-50 max-h-(--available-height) min-w-36 overflow-x-hidden overflow-y-auto outline-none", popupMotion, className )}
|
|
62
62
|
{...props}
|
|
63
63
|
/>
|
|
64
64
|
</ContextMenuPrimitive.Positioner>
|
|
@@ -108,7 +108,7 @@ function ContextMenuItem({
|
|
|
108
108
|
data-variant={variant}
|
|
109
109
|
className={cn(
|
|
110
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-
|
|
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-[calc(var(--radius-2xl)-5px)] 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",
|
|
112
112
|
className
|
|
113
113
|
)}
|
|
114
114
|
{...props}
|
|
@@ -136,7 +136,7 @@ function ContextMenuSubTrigger({
|
|
|
136
136
|
data-inset={inset}
|
|
137
137
|
className={cn(
|
|
138
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-
|
|
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-[calc(var(--radius-2xl)-5px)] 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",
|
|
140
140
|
className
|
|
141
141
|
)}
|
|
142
142
|
{...props}
|
|
@@ -175,7 +175,7 @@ function ContextMenuCheckboxItem({
|
|
|
175
175
|
className={cn(
|
|
176
176
|
menuItemDisabled,
|
|
177
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-
|
|
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-[calc(var(--radius-2xl)-5px)] 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",
|
|
179
179
|
className
|
|
180
180
|
)}
|
|
181
181
|
checked={checked}
|
|
@@ -215,7 +215,7 @@ function ContextMenuRadioItem({
|
|
|
215
215
|
className={cn(
|
|
216
216
|
menuItemDisabled,
|
|
217
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-
|
|
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-[calc(var(--radius-2xl)-5px)] 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",
|
|
219
219
|
className
|
|
220
220
|
)}
|
|
221
221
|
{...props}
|
|
@@ -5,10 +5,10 @@ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
|
|
|
5
5
|
|
|
6
6
|
import type { Tone } from "@vendure-io/ui/lib/state-dictionary"
|
|
7
7
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
8
|
+
import { useMessages } from "../../lib/format-messages.ts"
|
|
8
9
|
import { Button } from "@vendure-io/ui/components/atoms/button"
|
|
9
10
|
import { XIcon } from "lucide-react"
|
|
10
11
|
import { usePopupDir } from "../../lib/popup-direction.ts"
|
|
11
|
-
import { dialogPaddingStyle } from "../../lib/dialog-padding.ts"
|
|
12
12
|
import { usePinnedHeight } from "../../hooks/use-pinned-height.ts"
|
|
13
13
|
import { triggerSlot } from "../../lib/trigger-slot.ts"
|
|
14
14
|
|
|
@@ -55,10 +55,11 @@ function DialogOverlay({
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// Tells DialogHeader to host the close button, so the ✕ stays pinned with the
|
|
58
|
-
// header while the body scrolls.
|
|
59
|
-
|
|
58
|
+
// header while the body scrolls. The value is the button's accessible name, or
|
|
59
|
+
// null when the dialog shows no ✕.
|
|
60
|
+
const DialogCloseButtonContext = React.createContext<string | null>(null)
|
|
60
61
|
|
|
61
|
-
function DialogCloseButton({ className }: { className?: string }) {
|
|
62
|
+
function DialogCloseButton({ className, label }: { className?: string; label: string }) {
|
|
62
63
|
return (
|
|
63
64
|
<DialogPrimitive.Close
|
|
64
65
|
data-slot="dialog-close"
|
|
@@ -73,7 +74,7 @@ function DialogCloseButton({ className }: { className?: string }) {
|
|
|
73
74
|
>
|
|
74
75
|
<XIcon
|
|
75
76
|
/>
|
|
76
|
-
<span className="sr-only">
|
|
77
|
+
<span className="sr-only">{label}</span>
|
|
77
78
|
</DialogPrimitive.Close>
|
|
78
79
|
)
|
|
79
80
|
}
|
|
@@ -94,8 +95,8 @@ function DialogContent({
|
|
|
94
95
|
children,
|
|
95
96
|
size = "default",
|
|
96
97
|
showCloseButton,
|
|
98
|
+
closeLabel,
|
|
97
99
|
overlayClassName,
|
|
98
|
-
style,
|
|
99
100
|
...props
|
|
100
101
|
}: DialogPrimitive.Popup.Props & {
|
|
101
102
|
/**
|
|
@@ -114,6 +115,11 @@ function DialogContent({
|
|
|
114
115
|
* wins over that.
|
|
115
116
|
*/
|
|
116
117
|
showCloseButton?: boolean
|
|
118
|
+
/**
|
|
119
|
+
* The ✕'s accessible name. Defaults to `messages.dialog.close` from
|
|
120
|
+
* `FormatProvider`, then "Close".
|
|
121
|
+
*/
|
|
122
|
+
closeLabel?: string
|
|
117
123
|
/** Classes for the backdrop behind the dialog, e.g. `bg-scrim-subtle`. */
|
|
118
124
|
overlayClassName?: string
|
|
119
125
|
}) {
|
|
@@ -124,12 +130,13 @@ function DialogContent({
|
|
|
124
130
|
return () => setCloseControls((count) => count - 1)
|
|
125
131
|
}, [])
|
|
126
132
|
const showClose = showCloseButton ?? closeControls === 0
|
|
133
|
+
const t = useMessages("dialog", { close: closeLabel })
|
|
127
134
|
return (
|
|
128
135
|
<DialogPortal>
|
|
129
136
|
<DialogOverlay className={overlayClassName} />
|
|
130
137
|
{/* Enters from 4px below at 96%: opacity 200ms, scale and translate 240ms on the strong ease-out. Leaves to 98% (opacity 120ms on `ease`, scale 140ms on the strong ease-out). The scrim fades in 180ms and out in 140ms. Reduced motion keeps the fades. */}
|
|
131
138
|
{/* At most the viewport height less 1rem on each side. A taller dialog scrolls inside; DialogHeader and DialogFooter stick to its top and bottom edges. */}
|
|
132
|
-
{/* The padding is `--dialog-padding` (20px), and the pinned header and footer reach over it. Change the variable
|
|
139
|
+
{/* The padding is `--dialog-padding` (20px), and the pinned header and footer reach over it. Change the variable, not the padding: a `p-*` class leaves the header and the footer at 20px. */}
|
|
133
140
|
{/* One column as wide as the space inside the padding: content wider than that shrinks or wraps inside it instead of widening the dialog past its padding. */}
|
|
134
141
|
{/* The scroll padding is the pinned header's and footer's measured heights plus 4px for a focus ring: a focused field scrolls clear of both. */}
|
|
135
142
|
<DialogPrimitive.Popup
|
|
@@ -141,17 +148,19 @@ function DialogContent({
|
|
|
141
148
|
dialogSizes[size],
|
|
142
149
|
className
|
|
143
150
|
)}
|
|
144
|
-
style={dialogPaddingStyle(className, style)}
|
|
145
151
|
{...props}
|
|
146
152
|
>
|
|
147
153
|
<DialogCloseControlContext.Provider value={registerCloseControl}>
|
|
148
|
-
<DialogCloseButtonContext.Provider value={showClose}>
|
|
154
|
+
<DialogCloseButtonContext.Provider value={showClose ? t.close : null}>
|
|
149
155
|
{children}
|
|
150
156
|
</DialogCloseButtonContext.Provider>
|
|
151
157
|
</DialogCloseControlContext.Provider>
|
|
152
158
|
{/* A dialog without a DialogHeader keeps the ✕ here, in the corner. */}
|
|
153
159
|
{showClose && (
|
|
154
|
-
<DialogCloseButton
|
|
160
|
+
<DialogCloseButton
|
|
161
|
+
label={t.close}
|
|
162
|
+
className="group-has-data-[slot=dialog-header]/dialog-content:hidden"
|
|
163
|
+
/>
|
|
155
164
|
)}
|
|
156
165
|
</DialogPrimitive.Popup>
|
|
157
166
|
</DialogPortal>
|
|
@@ -168,7 +177,7 @@ function DialogContent({
|
|
|
168
177
|
const pinned = "sticky z-10 -mx-(--dialog-padding) bg-overlay px-(--dialog-padding)"
|
|
169
178
|
|
|
170
179
|
function DialogHeader({ className, children, ref, ...props }: React.ComponentProps<"div">) {
|
|
171
|
-
const
|
|
180
|
+
const closeLabel = React.useContext(DialogCloseButtonContext)
|
|
172
181
|
const pinnedRef = usePinnedHeight("--pinned-header-height", "dialog-content", ref)
|
|
173
182
|
return (
|
|
174
183
|
<div
|
|
@@ -178,13 +187,13 @@ function DialogHeader({ className, children, ref, ...props }: React.ComponentPro
|
|
|
178
187
|
pinned,
|
|
179
188
|
"-top-(--dialog-padding) -mt-(--dialog-padding) -mb-4 flex flex-col gap-2.5 pt-(--dialog-padding) pb-4",
|
|
180
189
|
// The text stops before the close button, so a long title wraps instead of running under it.
|
|
181
|
-
|
|
190
|
+
closeLabel !== null && "pe-14",
|
|
182
191
|
className
|
|
183
192
|
)}
|
|
184
193
|
{...props}
|
|
185
194
|
>
|
|
186
195
|
{children}
|
|
187
|
-
{
|
|
196
|
+
{closeLabel !== null && <DialogCloseButton label={closeLabel} />}
|
|
188
197
|
</div>
|
|
189
198
|
)
|
|
190
199
|
}
|
|
@@ -192,13 +201,20 @@ function DialogHeader({ className, children, ref, ...props }: React.ComponentPro
|
|
|
192
201
|
function DialogFooter({
|
|
193
202
|
className,
|
|
194
203
|
showCloseButton = false,
|
|
204
|
+
closeLabel,
|
|
195
205
|
children,
|
|
196
206
|
ref,
|
|
197
207
|
...props
|
|
198
208
|
}: React.ComponentProps<"div"> & {
|
|
199
209
|
showCloseButton?: boolean
|
|
210
|
+
/**
|
|
211
|
+
* The text of the Close button that `showCloseButton` adds. Defaults to
|
|
212
|
+
* `messages.dialog.close` from `FormatProvider`, then "Close".
|
|
213
|
+
*/
|
|
214
|
+
closeLabel?: string
|
|
200
215
|
}) {
|
|
201
216
|
useRegisterCloseControl()
|
|
217
|
+
const t = useMessages("dialog", { close: closeLabel })
|
|
202
218
|
const pinnedRef = usePinnedHeight("--pinned-footer-height", "dialog-content", ref)
|
|
203
219
|
return (
|
|
204
220
|
<div
|
|
@@ -214,7 +230,7 @@ function DialogFooter({
|
|
|
214
230
|
{children}
|
|
215
231
|
{showCloseButton && (
|
|
216
232
|
<DialogPrimitive.Close render={<Button variant="outline" />}>
|
|
217
|
-
|
|
233
|
+
{t.close}
|
|
218
234
|
</DialogPrimitive.Close>
|
|
219
235
|
)}
|
|
220
236
|
</div>
|
|
@@ -62,7 +62,7 @@ function DropdownMenuContent({
|
|
|
62
62
|
<MenuPrimitive.Popup
|
|
63
63
|
ref={popupRef}
|
|
64
64
|
data-slot="dropdown-menu-content"
|
|
65
|
-
className={cn("bg-popover text-popover-foreground shadow-overlay rounded-
|
|
65
|
+
className={cn("bg-popover text-popover-foreground shadow-overlay rounded-2xl p-1.25 z-50 max-h-(--available-height) min-w-60 overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", popupMotion, className )}
|
|
66
66
|
{...props}
|
|
67
67
|
/>
|
|
68
68
|
</MenuPrimitive.Positioner>
|
|
@@ -90,7 +90,7 @@ function HoverCardContent({
|
|
|
90
90
|
ref={popupRef}
|
|
91
91
|
data-slot="hover-card-content"
|
|
92
92
|
className={cn(
|
|
93
|
-
"bg-popover text-popover-foreground shadow-overlay z-50 w-64 rounded-
|
|
93
|
+
"bg-popover text-popover-foreground shadow-overlay z-50 w-64 rounded-2xl p-4 text-sm outline-hidden",
|
|
94
94
|
popupMotion,
|
|
95
95
|
className
|
|
96
96
|
)}
|
|
@@ -4,19 +4,30 @@ import * as React from "react"
|
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
|
-
import { fieldSurface } from "
|
|
7
|
+
import { fieldSurface } from "../../lib/field-surface.ts"
|
|
8
8
|
import { Button } from "@vendure-io/ui/components/atoms/button"
|
|
9
9
|
import { Input } from "@vendure-io/ui/components/atoms/input"
|
|
10
10
|
import { Textarea } from "@vendure-io/ui/components/atoms/textarea"
|
|
11
11
|
|
|
12
|
-
function InputGroup({
|
|
12
|
+
function InputGroup({
|
|
13
|
+
className,
|
|
14
|
+
size = "default",
|
|
15
|
+
...props
|
|
16
|
+
}: React.ComponentProps<"div"> & {
|
|
17
|
+
/**
|
|
18
|
+
* The field height: `default` is 34px, `sm` is 28px, the height of a small
|
|
19
|
+
* Button. The input and the buttons inside follow it.
|
|
20
|
+
*/
|
|
21
|
+
size?: "sm" | "default"
|
|
22
|
+
}) {
|
|
13
23
|
return (
|
|
14
24
|
<div
|
|
15
25
|
data-slot="input-group"
|
|
26
|
+
data-size={size}
|
|
16
27
|
role="group"
|
|
17
28
|
className={cn(
|
|
18
29
|
fieldSurface,
|
|
19
|
-
"has-[[data-slot=input-group-control]:focus-visible]:outline-solid has-[[data-slot=input-group-control]:focus-visible]:outline-2 has-[[data-slot=input-group-control]:focus-visible]:-outline-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-ring has-[[data-slot][aria-invalid=true]]:outline-destructive has-[[data-slot][aria-invalid=true]]:
|
|
30
|
+
"has-[[data-slot=input-group-control]:focus-visible]:outline-solid has-[[data-slot=input-group-control]:focus-visible]:outline-2 has-[[data-slot=input-group-control]:focus-visible]:-outline-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-ring has-[[data-slot][aria-invalid=true]]:outline-destructive has-[[data-slot][aria-invalid=true]]:inset-ring-destructive group/input-group relative flex h-8.5 data-[size=sm]:h-7 data-[size=sm]:has-[>textarea]:h-auto data-[size=sm]:has-[>[data-align=block-end]]:h-auto data-[size=sm]:has-[>[data-align=block-start]]:h-auto w-full min-w-0 items-center in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 in-data-[slot=combobox-content]:outline-none! has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pe-1.5 has-[>[data-align=inline-start]]:[&>input]:ps-1.5",
|
|
20
31
|
className
|
|
21
32
|
)}
|
|
22
33
|
{...props}
|
|
@@ -29,9 +40,11 @@ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
29
40
|
// content about 10px in. Logical sides, so right-to-left mirrors it.
|
|
30
41
|
// A kbd in an addon drops its own fill and uses the secondary text colour
|
|
31
42
|
// and the input hairline, as the v3 look's search field does: its muted text
|
|
32
|
-
// on its fill on the
|
|
43
|
+
// on its fill on the field fill fails the axe contrast check.
|
|
33
44
|
const inputGroupAddonVariants = cva(
|
|
34
|
-
|
|
45
|
+
// A CopyButton (24px) nests its corner like an xs InputGroupButton: the
|
|
46
|
+
// field's 8px minus the gap, 5px in a 34px group and 2px in a 28px one.
|
|
47
|
+
"[&>[data-slot=copy-button]]:rounded-[calc(var(--radius-xl)-5px)] group-data-[size=sm]/input-group:[&>[data-slot=copy-button]]:rounded-[calc(var(--radius-xl)-2px)] text-muted-foreground **:data-[slot=kbd]:bg-transparent **:data-[slot=kbd]:text-foreground-secondary **:data-[slot=kbd]:inset-ring-input h-auto gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>svg:not([class*='size-'])]:size-4 [&>svg:not([class*='stroke-'])]:stroke-[1.75] flex cursor-text items-center justify-center select-none",
|
|
35
48
|
{
|
|
36
49
|
variants: {
|
|
37
50
|
align: {
|
|
@@ -73,16 +86,21 @@ function InputGroupAddon({
|
|
|
73
86
|
)
|
|
74
87
|
}
|
|
75
88
|
|
|
89
|
+
// The text sizes use 12px text, like a Button of the same size. The corner
|
|
90
|
+
// is the field's 8px minus the gap between the button and the field edge, so
|
|
91
|
+
// the two corners run parallel: a 24px button sits 5px inside a 34px field
|
|
92
|
+
// and 2px inside a 28px one, a 28px button 3px inside a 34px field and flush
|
|
93
|
+
// in a 28px one.
|
|
76
94
|
const inputGroupButtonVariants = cva(
|
|
77
95
|
"gap-2 text-sm shadow-none flex items-center",
|
|
78
96
|
{
|
|
79
97
|
variants: {
|
|
80
98
|
size: {
|
|
81
|
-
xs: "h-6 gap-1 rounded-
|
|
82
|
-
sm: "h-7 gap-1.5 px-2.5",
|
|
99
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius-xl)-5px)] group-data-[size=sm]/input-group:rounded-[calc(var(--radius-xl)-2px)] px-1.5 text-xs [&>svg:not([class*='size-'])]:size-3.5",
|
|
100
|
+
sm: "h-7 gap-1.5 rounded-[calc(var(--radius-xl)-3px)] group-data-[size=sm]/input-group:rounded-xl px-2.5 text-xs",
|
|
83
101
|
"icon-xs":
|
|
84
|
-
"size-6 rounded-
|
|
85
|
-
"icon-sm": "size-7 p-0 has-[>svg]:p-0",
|
|
102
|
+
"size-6 rounded-[calc(var(--radius-xl)-5px)] group-data-[size=sm]/input-group:rounded-[calc(var(--radius-xl)-2px)] p-0 has-[>svg]:p-0",
|
|
103
|
+
"icon-sm": "size-7 rounded-[calc(var(--radius-xl)-3px)] group-data-[size=sm]/input-group:rounded-xl p-0 has-[>svg]:p-0",
|
|
86
104
|
},
|
|
87
105
|
},
|
|
88
106
|
defaultVariants: {
|
|
@@ -127,12 +145,12 @@ function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
|
|
|
127
145
|
function InputGroupInput({
|
|
128
146
|
className,
|
|
129
147
|
...props
|
|
130
|
-
}: React.ComponentProps<"
|
|
148
|
+
}: Omit<React.ComponentProps<typeof Input>, "size">) {
|
|
131
149
|
return (
|
|
132
150
|
<Input
|
|
133
151
|
data-slot="input-group-control"
|
|
134
152
|
className={cn(
|
|
135
|
-
"flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:shadow-none focus-visible:ring-0 focus-visible:outline-none aria-invalid:shadow-none aria-invalid:focus-visible:shadow-none aria-invalid:ring-0 dark:bg-transparent",
|
|
153
|
+
"flex-1 rounded-none border-0 bg-transparent shadow-none inset-ring-0 aria-invalid:inset-ring-0 group-data-[size=sm]/input-group:h-7 ring-0 focus-visible:shadow-none focus-visible:ring-0 focus-visible:outline-none aria-invalid:shadow-none aria-invalid:focus-visible:shadow-none aria-invalid:ring-0 dark:bg-transparent",
|
|
136
154
|
className
|
|
137
155
|
)}
|
|
138
156
|
{...props}
|
|
@@ -148,7 +166,7 @@ function InputGroupTextarea({
|
|
|
148
166
|
<Textarea
|
|
149
167
|
data-slot="input-group-control"
|
|
150
168
|
className={cn(
|
|
151
|
-
"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:shadow-none focus-visible:ring-0 focus-visible:outline-none aria-invalid:shadow-none aria-invalid:focus-visible:shadow-none aria-invalid:ring-0 dark:bg-transparent",
|
|
169
|
+
"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none inset-ring-0 aria-invalid:inset-ring-0 ring-0 focus-visible:shadow-none focus-visible:ring-0 focus-visible:outline-none aria-invalid:shadow-none aria-invalid:focus-visible:shadow-none aria-invalid:ring-0 dark:bg-transparent",
|
|
152
170
|
className
|
|
153
171
|
)}
|
|
154
172
|
{...props}
|
|
@@ -4,7 +4,7 @@ import * as React from "react"
|
|
|
4
4
|
import { OTPInput, OTPInputContext } from "input-otp"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
|
-
import { fieldSurfaceWithin } from "
|
|
7
|
+
import { fieldSurfaceWithin } from "../../lib/field-surface.ts"
|
|
8
8
|
import { MinusIcon } from "lucide-react"
|
|
9
9
|
|
|
10
10
|
function InputOTP({
|
|
@@ -55,7 +55,7 @@ function InputOTPSlot({
|
|
|
55
55
|
data-slot="input-otp-slot"
|
|
56
56
|
data-active={isActive}
|
|
57
57
|
className={cn(
|
|
58
|
-
"border-border data-[active=true]:outline-solid data-[active=true]:outline-2 data-[active=true]:-outline-offset-2 data-[active=true]:outline-ring data-[active=true]:aria-invalid:outline-destructive relative flex size-8.5 items-center justify-center border-s text-sm outline-none first:rounded-s-
|
|
58
|
+
"border-border data-[active=true]:outline-solid data-[active=true]:outline-2 data-[active=true]:-outline-offset-2 data-[active=true]:outline-ring data-[active=true]:aria-invalid:outline-destructive relative flex size-8.5 items-center justify-center border-s text-sm outline-none first:rounded-s-xl first:border-s-0 last:rounded-e-xl data-[active=true]:z-10",
|
|
59
59
|
className
|
|
60
60
|
)}
|
|
61
61
|
{...props}
|