@vendure-io/ui 3.0.0-next.4 → 3.0.0-next.6
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 +154 -59
- 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/carousel.tsx +33 -7
- package/src/components/atoms/chart.tsx +3 -3
- package/src/components/atoms/checkbox.tsx +1 -1
- package/src/components/atoms/combobox.tsx +60 -36
- package/src/components/atoms/command.tsx +17 -7
- 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 +52 -15
- 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 +224 -36
- package/src/components/atoms/skeleton.tsx +6 -3
- package/src/components/atoms/spinner.tsx +7 -2
- 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 +70 -25
- package/src/components/molecules/app-shell.tsx +14 -5
- package/src/components/molecules/checklist/checklist.tsx +47 -17
- package/src/components/molecules/chip.tsx +37 -19
- package/src/components/molecules/choice-card.tsx +117 -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 +17 -5
- package/src/components/molecules/copyable-text.tsx +10 -8
- package/src/components/molecules/data-table/data-table-filters.tsx +36 -6
- 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 +156 -29
- package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
- package/src/components/molecules/data-table/data-table.tsx +156 -75
- package/src/components/molecules/data-table/table-pagination.tsx +142 -38
- package/src/components/molecules/date-picker.tsx +58 -25
- package/src/components/molecules/date-range-picker.tsx +59 -24
- package/src/components/molecules/date-time-picker.tsx +63 -25
- 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 +151 -40
- 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 +13 -115
- package/src/components/molecules/issued-secret.tsx +35 -25
- package/src/components/molecules/live-indicator.tsx +1 -1
- package/src/components/molecules/money.tsx +44 -3
- package/src/components/molecules/multi-select.tsx +62 -16
- 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 +35 -19
- package/src/components/molecules/skip-link.tsx +11 -9
- package/src/components/molecules/stat-card.tsx +145 -33
- package/src/components/molecules/state-views/empty-state.tsx +16 -12
- package/src/components/molecules/state-views/error-state.tsx +36 -20
- package/src/components/molecules/state-views/loading-state.tsx +18 -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 +368 -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure-io/ui",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.6",
|
|
4
4
|
"description": "React component library for Vendure, built on shadcn/ui and Tailwind v4",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://github.com/vendurehq/design/tree/main/packages/ui",
|
|
@@ -16,19 +16,20 @@
|
|
|
16
16
|
"./components/atoms/label-swap": null,
|
|
17
17
|
"./components/molecules/*": "./src/components/molecules/*.tsx",
|
|
18
18
|
"./components/molecules/code-block/*": null,
|
|
19
|
+
"./components/molecules/data-table/data-table-bulk-actions": null,
|
|
19
20
|
"./components/molecules/data-table/data-table-helpers": null,
|
|
21
|
+
"./components/molecules/data-table/data-table-row-count-storage": null,
|
|
20
22
|
"./components/molecules/data-table/data-table-selection-storage": null,
|
|
23
|
+
"./components/molecules/data-table/data-table-view-options": null,
|
|
21
24
|
"./components/molecules/direction-link": null,
|
|
25
|
+
"./components/molecules/id-chip-chrome": null,
|
|
22
26
|
"./components/molecules/time-tooltip": null,
|
|
23
|
-
"./lib
|
|
24
|
-
"./lib/
|
|
25
|
-
"./lib/
|
|
26
|
-
"./lib/
|
|
27
|
-
"./lib/
|
|
28
|
-
"./lib/
|
|
29
|
-
"./lib/popup-direction": null,
|
|
30
|
-
"./lib/popup-motion": null,
|
|
31
|
-
"./lib/trigger-slot": null,
|
|
27
|
+
"./lib/base-ui": "./src/lib/base-ui.ts",
|
|
28
|
+
"./lib/date-value": "./src/lib/date-value.ts",
|
|
29
|
+
"./lib/format-relative": "./src/lib/format-relative.ts",
|
|
30
|
+
"./lib/state-dictionary": "./src/lib/state-dictionary.ts",
|
|
31
|
+
"./lib/tone-icons": "./src/lib/tone-icons.ts",
|
|
32
|
+
"./lib/utils": "./src/lib/utils.ts",
|
|
32
33
|
"./hooks/*": "./src/hooks/*.ts",
|
|
33
34
|
"./hooks/use-active-label-size": null,
|
|
34
35
|
"./hooks/use-pinned-height": null,
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"pack:check": "bun pm pack --dry-run"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
|
-
"@vendure-io/design-tokens": "^3.0.0-next.
|
|
54
|
+
"@vendure-io/design-tokens": "^3.0.0-next.3",
|
|
54
55
|
"react": ">=19",
|
|
55
56
|
"react-dom": ">=19",
|
|
56
57
|
"next": ">=14",
|
|
@@ -6,7 +6,6 @@ import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
7
|
import { Button } from "@vendure-io/ui/components/atoms/button"
|
|
8
8
|
import { usePopupDir } from "../../lib/popup-direction.ts"
|
|
9
|
-
import { dialogPaddingStyle } from "../../lib/dialog-padding.ts"
|
|
10
9
|
import { usePinnedHeight } from "../../hooks/use-pinned-height.ts"
|
|
11
10
|
import { triggerSlot } from "../../lib/trigger-slot.ts"
|
|
12
11
|
|
|
@@ -45,7 +44,6 @@ function AlertDialogOverlay({
|
|
|
45
44
|
function AlertDialogContent({
|
|
46
45
|
className,
|
|
47
46
|
size = "default",
|
|
48
|
-
style,
|
|
49
47
|
...props
|
|
50
48
|
}: AlertDialogPrimitive.Popup.Props & {
|
|
51
49
|
size?: "default" | "sm"
|
|
@@ -54,7 +52,7 @@ function AlertDialogContent({
|
|
|
54
52
|
return (
|
|
55
53
|
<AlertDialogPortal>
|
|
56
54
|
<AlertDialogOverlay />
|
|
57
|
-
{/* At most the viewport height less 1rem on each side. A taller dialog scrolls inside; the header and the footer stick to its edges, as in DialogContent. The padding is `--dialog-padding
|
|
55
|
+
{/* At most the viewport height less 1rem on each side. A taller dialog scrolls inside; the header and the footer stick to its edges, as in DialogContent. The padding is `--dialog-padding`; change the variable, not the padding, and the scroll padding keeps a focused field clear of the header and the footer. */}
|
|
58
56
|
<AlertDialogPrimitive.Popup
|
|
59
57
|
dir={dir}
|
|
60
58
|
data-slot="alert-dialog-content"
|
|
@@ -63,7 +61,6 @@ function AlertDialogContent({
|
|
|
63
61
|
"bg-overlay shadow-overlay group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid grid-cols-[minmax(0,1fr)] max-h-[calc(100dvh-2rem)] w-full -translate-x-1/2 -translate-y-1/2 gap-5 overflow-y-auto overscroll-contain rounded-2xl [--dialog-padding:--spacing(5)] p-(--dialog-padding) [scroll-padding-block:calc(var(--pinned-header-height,0px)+--spacing(1))_calc(var(--pinned-footer-height,0px)+--spacing(1))] transition-[opacity,scale,translate] duration-[var(--transition-duration-normal),var(--transition-duration-dialog-enter),var(--transition-duration-dialog-enter)] ease-out data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-[var(--transition-duration-quick),var(--transition-duration-dialog-exit),var(--transition-duration-dialog-exit)] data-ending-style:ease-[var(--ease-soft),var(--ease-out),var(--ease-out)] motion-safe:data-starting-style:scale-96 motion-safe:data-starting-style:translate-y-[calc(-50%+4px)] motion-safe:data-ending-style:scale-98 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-110",
|
|
64
62
|
className
|
|
65
63
|
)}
|
|
66
|
-
style={dialogPaddingStyle(className, style)}
|
|
67
64
|
{...props}
|
|
68
65
|
/>
|
|
69
66
|
</AlertDialogPortal>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
|
-
import { cva
|
|
2
|
+
import { cva } from "class-variance-authority"
|
|
3
3
|
|
|
4
4
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
5
|
-
import {
|
|
5
|
+
import type { Tone } from "@vendure-io/ui/lib/state-dictionary"
|
|
6
|
+
import { alertTint, alertToneVars } from "../../lib/tint-recipes.ts"
|
|
6
7
|
import { toneIcons } from "@vendure-io/ui/lib/tone-icons"
|
|
8
|
+
import { warnDeprecated } from "../../lib/deprecated.ts"
|
|
7
9
|
|
|
8
10
|
// Alert is an inline-size container so AlertAction can move under the text when
|
|
9
11
|
// the alert is narrow. A container cannot size to its content: an Alert inside a
|
|
@@ -16,9 +18,11 @@ import { toneIcons } from "@vendure-io/ui/lib/tone-icons"
|
|
|
16
18
|
// mixed into the cool surface it reads grey. The modes switch the
|
|
17
19
|
// --alert-fill and --alert-border properties, not the utilities, so a
|
|
18
20
|
// consumer's bg-* or border-* class wins in both modes. The icon takes the
|
|
19
|
-
// tone's text slot.
|
|
21
|
+
// tone's text slot. The tones are the state dictionary's, with the StatusBadge
|
|
22
|
+
// recipe: critical tints with destructive-text, progress with info-text and a
|
|
23
|
+
// spinner. Warning tints with the brighter warning-indicator, as an
|
|
20
24
|
// amber text colour mixes to brown. The title stays foreground and the
|
|
21
|
-
// description foreground-secondary in every
|
|
25
|
+
// description foreground-secondary in every tone, because a muted grey on
|
|
22
26
|
// a tinted fill falls below text contrast.
|
|
23
27
|
// The recipe lives in lib/tint-recipes.ts, which the contrast test in
|
|
24
28
|
// @vendure-io/design-tokens reads.
|
|
@@ -28,60 +32,80 @@ const tonedAlert = alertTint
|
|
|
28
32
|
// place, 240ms ease-out (@starting-style: nothing runs after it). Reduced motion
|
|
29
33
|
// keeps the fade. Content padding is 12px inline, 10px block.
|
|
30
34
|
const alertVariants = cva(
|
|
31
|
-
"@container/alert grid grid-cols-[minmax(0,1fr)] rounded-xl border px-3 py-2.5 text-start text-sm has-[>svg]:grid-cols-[auto_minmax(0,1fr)] has-[>[data-slot=alert-action]]:grid-cols-[minmax(0,1fr)_auto] has-[>svg]:has-[>[data-slot=alert-action]]:grid-cols-[auto_minmax(0,1fr)_auto] *:[svg]:row-span-2 *:[svg]:me-3 *:[svg]:translate-y-0.5 *:[svg:not([class*='size-'])]:size-4 *:[svg:not([class*='stroke-'])]:stroke-[1.75]
|
|
35
|
+
"@container/alert grid grid-cols-[minmax(0,1fr)] rounded-xl border px-3 py-2.5 text-start text-sm has-[>svg]:grid-cols-[auto_minmax(0,1fr)] has-[>[data-slot=alert-action]]:grid-cols-[minmax(0,1fr)_auto] has-[>svg]:has-[>[data-slot=alert-action]]:grid-cols-[auto_minmax(0,1fr)_auto] *:[svg]:row-span-2 *:[svg]:me-3 *:[svg]:translate-y-0.5 *:[svg:not([class*='size-'])]:size-4 *:[svg:not([class*='stroke-'])]:stroke-[1.75] w-full relative group/alert transition-[opacity,translate] duration-alert-enter ease-out starting:opacity-0 motion-safe:starting:-translate-y-1",
|
|
32
36
|
{
|
|
33
37
|
variants: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
tonedAlert,
|
|
38
|
-
alertToneVars.destructive,
|
|
39
|
-
],
|
|
40
|
-
warning: [
|
|
41
|
-
tonedAlert,
|
|
42
|
-
alertToneVars.warning,
|
|
43
|
-
],
|
|
38
|
+
tone: {
|
|
39
|
+
none: "bg-card text-card-foreground *:[svg]:text-current",
|
|
40
|
+
neutral: [tonedAlert, alertToneVars.neutral],
|
|
44
41
|
info: [tonedAlert, alertToneVars.info],
|
|
45
|
-
|
|
42
|
+
success: [tonedAlert, alertToneVars.success],
|
|
43
|
+
warning: [tonedAlert, alertToneVars.warning],
|
|
44
|
+
critical: [tonedAlert, alertToneVars.critical],
|
|
45
|
+
progress: [tonedAlert, alertToneVars.progress],
|
|
46
|
+
} satisfies Record<Tone | "none", unknown>,
|
|
46
47
|
},
|
|
47
48
|
defaultVariants: {
|
|
48
|
-
|
|
49
|
+
tone: "none",
|
|
49
50
|
},
|
|
50
51
|
}
|
|
51
52
|
)
|
|
52
53
|
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
const
|
|
56
|
-
destructive: toneIcons.critical,
|
|
57
|
-
warning: toneIcons.warning,
|
|
58
|
-
info: toneIcons.info,
|
|
59
|
-
} as const
|
|
54
|
+
// The progress spinner turns once per 1.6s, as in StatusBadge, and stands
|
|
55
|
+
// still under reduced motion; the loader shape still says "in motion".
|
|
56
|
+
const spinnerClass = "animate-spin-slow motion-reduce:animate-none"
|
|
60
57
|
|
|
61
58
|
/**
|
|
62
|
-
* A toned Alert
|
|
63
|
-
*
|
|
64
|
-
*
|
|
59
|
+
* A toned Alert is a faint tint of its tone and shows the tone's icon, the
|
|
60
|
+
* same shape a StatusBadge of that tone shows (`progress` spins it). Without a
|
|
61
|
+
* tone it sits on the card with no icon. `icon` replaces the tone icon, and
|
|
62
|
+
* `icon={false}` shows no icon. Pass the icon here, not as a child.
|
|
65
63
|
*/
|
|
64
|
+
// The 2.x variant names and the tone each one maps to. Remove in 4.0.
|
|
65
|
+
const variantTones = {
|
|
66
|
+
default: undefined,
|
|
67
|
+
destructive: "critical",
|
|
68
|
+
warning: "warning",
|
|
69
|
+
info: "info",
|
|
70
|
+
} as const satisfies Record<string, Tone | undefined>
|
|
71
|
+
|
|
66
72
|
function Alert({
|
|
67
73
|
className,
|
|
74
|
+
tone: toneProp,
|
|
68
75
|
variant,
|
|
69
76
|
icon,
|
|
70
77
|
children,
|
|
71
78
|
...props
|
|
72
|
-
}: React.ComponentProps<"div"> &
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
}: React.ComponentProps<"div"> & {
|
|
80
|
+
/** The tone from the state dictionary. Leave it out for a plain notice on the card. */
|
|
81
|
+
tone?: Tone
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Use `tone`: `destructive` is `critical`, `warning` and `info`
|
|
84
|
+
* keep their names, and `default` is no tone. Removed in 4.0.
|
|
85
|
+
*/
|
|
86
|
+
variant?: keyof typeof variantTones
|
|
87
|
+
/** Replaces the tone icon. `false` or `null` shows no icon. */
|
|
88
|
+
icon?: React.ReactNode
|
|
89
|
+
}) {
|
|
90
|
+
if (variant !== undefined) warnDeprecated("Alert", "variant", "tone")
|
|
91
|
+
const tone = toneProp ?? (variant === undefined ? undefined : variantTones[variant])
|
|
92
|
+
const ToneIcon = tone ? toneIcons[tone] : undefined
|
|
78
93
|
const shownIcon =
|
|
79
|
-
icon !== undefined ?
|
|
94
|
+
icon !== undefined ? (
|
|
95
|
+
icon || null
|
|
96
|
+
) : ToneIcon ? (
|
|
97
|
+
<ToneIcon
|
|
98
|
+
aria-hidden
|
|
99
|
+
data-slot="alert-icon"
|
|
100
|
+
className={tone === "progress" ? spinnerClass : undefined}
|
|
101
|
+
/>
|
|
102
|
+
) : null
|
|
80
103
|
return (
|
|
81
104
|
<div
|
|
82
105
|
data-slot="alert"
|
|
106
|
+
data-tone={tone}
|
|
83
107
|
role="alert"
|
|
84
|
-
className={cn(alertVariants({
|
|
108
|
+
className={cn(alertVariants({ tone: tone ?? "none" }), className)}
|
|
85
109
|
{...props}
|
|
86
110
|
>
|
|
87
111
|
{shownIcon}
|
|
@@ -2,7 +2,7 @@ import { mergeProps } from "@base-ui/react/merge-props"
|
|
|
2
2
|
import { useRender } from "@base-ui/react/use-render"
|
|
3
3
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
4
|
|
|
5
|
-
import { contentInsetPull } from "
|
|
5
|
+
import { contentInsetPull } from "../../lib/content-inset.ts"
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
7
|
|
|
8
8
|
// `--content-inset` is the distance from the box to the first letter: the
|
|
@@ -10,7 +10,7 @@ import { cn } from "@vendure-io/ui/lib/utils"
|
|
|
10
10
|
// and the gap. A DataTable cell pulls the badge back by it, so the text lines
|
|
11
11
|
// up with the column header.
|
|
12
12
|
const badgeVariants = cva(
|
|
13
|
-
[contentInsetPull, "[--content-inset:calc(var(--spacing)*2+1px)] has-data-[icon=inline-start]:[--content-inset:calc(var(--spacing)*5.5+1px)] h-5 gap-1 rounded-
|
|
13
|
+
[contentInsetPull, "[--content-inset:calc(var(--spacing)*2+1px)] has-data-[icon=inline-start]:[--content-inset:calc(var(--spacing)*5.5+1px)] h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-xs font-medium transition-[color,background-color,border-color] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&>svg]:size-3! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive overflow-hidden group/badge"],
|
|
14
14
|
{
|
|
15
15
|
variants: {
|
|
16
16
|
variant: {
|
|
@@ -37,11 +37,15 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.tsx"
|
|
|
37
37
|
// Relative: `label-swap` is closed in the package exports.
|
|
38
38
|
import { LabelSwap } from "./label-swap.tsx"
|
|
39
39
|
import { menuItem, menuRadioItem, MenuCheck } from "../../lib/menu-item.tsx"
|
|
40
|
+
import { useMessages } from "../../lib/format-messages.ts"
|
|
41
|
+
import { warnDeprecated } from "../../lib/deprecated.ts"
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
// `aria-label` defaults to `messages.breadcrumb.nav`, "breadcrumb".
|
|
44
|
+
function Breadcrumb({ className, "aria-label": ariaLabel, ...props }: React.ComponentProps<"nav">) {
|
|
45
|
+
const t = useMessages("breadcrumb", { nav: ariaLabel })
|
|
42
46
|
return (
|
|
43
47
|
<nav
|
|
44
|
-
aria-label=
|
|
48
|
+
aria-label={t.nav}
|
|
45
49
|
data-slot="breadcrumb"
|
|
46
50
|
className={cn(className)}
|
|
47
51
|
{...props}
|
|
@@ -130,8 +134,16 @@ function BreadcrumbSeparator({
|
|
|
130
134
|
|
|
131
135
|
function BreadcrumbEllipsis({
|
|
132
136
|
className,
|
|
137
|
+
label,
|
|
133
138
|
...props
|
|
134
|
-
}: React.ComponentProps<"span">
|
|
139
|
+
}: React.ComponentProps<"span"> & {
|
|
140
|
+
/**
|
|
141
|
+
* Screen-reader text of the ellipsis.
|
|
142
|
+
* @default `messages.breadcrumb.more`, "More"
|
|
143
|
+
*/
|
|
144
|
+
label?: string
|
|
145
|
+
}) {
|
|
146
|
+
const t = useMessages("breadcrumb", { more: label })
|
|
135
147
|
return (
|
|
136
148
|
<span
|
|
137
149
|
data-slot="breadcrumb-ellipsis"
|
|
@@ -145,7 +157,7 @@ function BreadcrumbEllipsis({
|
|
|
145
157
|
>
|
|
146
158
|
<MoreHorizontalIcon
|
|
147
159
|
/>
|
|
148
|
-
<span className="sr-only">
|
|
160
|
+
<span className="sr-only">{t.more}</span>
|
|
149
161
|
</span>
|
|
150
162
|
)
|
|
151
163
|
}
|
|
@@ -189,7 +201,12 @@ type BreadcrumbSearchMenuOption = Omit<BreadcrumbMenuOption, "render" | "href">
|
|
|
189
201
|
|
|
190
202
|
/** The props both crumb menus share. */
|
|
191
203
|
type BreadcrumbMenuBaseProps = {
|
|
192
|
-
|
|
204
|
+
/**
|
|
205
|
+
* The items to switch to. `undefined` means they are still loading: the
|
|
206
|
+
* open menu shows a loading row, one item tall, in their place. `[]` means
|
|
207
|
+
* there are none.
|
|
208
|
+
*/
|
|
209
|
+
options: readonly BreadcrumbSearchMenuOption[] | undefined
|
|
193
210
|
value: string
|
|
194
211
|
onValueChange?: (value: string) => void
|
|
195
212
|
/** Names the list: it heads the menu and starts the crumb's accessible name. */
|
|
@@ -215,6 +232,12 @@ type BreadcrumbMenuBaseProps = {
|
|
|
215
232
|
* `placeholder` undefined and the skeleton shows.
|
|
216
233
|
*/
|
|
217
234
|
pending?: boolean
|
|
235
|
+
/**
|
|
236
|
+
* Read while the options load, and after the list label in the pending
|
|
237
|
+
* crumb ("Project: Loading…").
|
|
238
|
+
* @default `messages.breadcrumb.loading`, "Loading…"
|
|
239
|
+
*/
|
|
240
|
+
loadingLabel?: string
|
|
218
241
|
open?: boolean
|
|
219
242
|
onOpenChange?: (open: boolean) => void
|
|
220
243
|
defaultOpen?: boolean
|
|
@@ -261,7 +284,15 @@ const crumbTriggerClassName =
|
|
|
261
284
|
* is known. The skeleton is hidden from screen readers, which hear the
|
|
262
285
|
* status text instead. A `div`, as the skeleton is one.
|
|
263
286
|
*/
|
|
264
|
-
function PendingCrumb({
|
|
287
|
+
function PendingCrumb({
|
|
288
|
+
label,
|
|
289
|
+
loadingLabel,
|
|
290
|
+
className,
|
|
291
|
+
}: {
|
|
292
|
+
label: string
|
|
293
|
+
loadingLabel: string
|
|
294
|
+
className?: string
|
|
295
|
+
}) {
|
|
265
296
|
return (
|
|
266
297
|
<div
|
|
267
298
|
role="status"
|
|
@@ -271,7 +302,7 @@ function PendingCrumb({ label, className }: { label: string; className?: string
|
|
|
271
302
|
className
|
|
272
303
|
)}
|
|
273
304
|
>
|
|
274
|
-
<span className="sr-only">{`${label}:
|
|
305
|
+
<span className="sr-only">{`${label}: ${loadingLabel}`}</span>
|
|
275
306
|
<Skeleton aria-hidden className="h-[0.8lh] w-24 min-w-0 shrink" />
|
|
276
307
|
</div>
|
|
277
308
|
)
|
|
@@ -290,7 +321,8 @@ function useCrumbTrigger({
|
|
|
290
321
|
label,
|
|
291
322
|
placeholder,
|
|
292
323
|
open,
|
|
293
|
-
}: Pick<BreadcrumbMenuBaseProps, "
|
|
324
|
+
}: Pick<BreadcrumbMenuBaseProps, "value" | "label" | "placeholder"> & {
|
|
325
|
+
options: readonly BreadcrumbSearchMenuOption[]
|
|
294
326
|
open: boolean
|
|
295
327
|
}) {
|
|
296
328
|
const found = options.findIndex((option) => option.value === value)
|
|
@@ -427,6 +459,7 @@ function BreadcrumbMenu({
|
|
|
427
459
|
label,
|
|
428
460
|
placeholder,
|
|
429
461
|
pending = false,
|
|
462
|
+
loadingLabel,
|
|
430
463
|
open: openProp,
|
|
431
464
|
onOpenChange,
|
|
432
465
|
defaultOpen = false,
|
|
@@ -434,14 +467,21 @@ function BreadcrumbMenu({
|
|
|
434
467
|
className,
|
|
435
468
|
contentClassName,
|
|
436
469
|
}: Omit<BreadcrumbMenuBaseProps, "options"> & {
|
|
437
|
-
|
|
470
|
+
/**
|
|
471
|
+
* The items to switch to. `undefined` means they are still loading: the
|
|
472
|
+
* open menu shows a loading row, one item tall, in their place. `[]` means
|
|
473
|
+
* there are none.
|
|
474
|
+
*/
|
|
475
|
+
options: readonly BreadcrumbMenuOption[] | undefined
|
|
438
476
|
children?: React.ReactNode
|
|
439
477
|
}) {
|
|
440
478
|
const [open, setOpen] = useMenuOpen(openProp, defaultOpen, onOpenChange)
|
|
441
|
-
const crumb = useCrumbTrigger({ options, value, label, placeholder, open })
|
|
479
|
+
const crumb = useCrumbTrigger({ options: options ?? [], value, label, placeholder, open })
|
|
480
|
+
const t = useMessages("breadcrumb", { loading: loadingLabel })
|
|
442
481
|
// Without a name, a skeleton. The trigger mounts with the first name, so
|
|
443
482
|
// it shows without a swap.
|
|
444
|
-
if (pending && !crumb.named)
|
|
483
|
+
if (pending && !crumb.named)
|
|
484
|
+
return <PendingCrumb label={label} loadingLabel={t.loading} className={className} />
|
|
445
485
|
return (
|
|
446
486
|
<DropdownMenu open={open} onOpenChange={setOpen}>
|
|
447
487
|
<Tooltip>
|
|
@@ -466,34 +506,51 @@ function BreadcrumbMenu({
|
|
|
466
506
|
</Tooltip>
|
|
467
507
|
<DropdownMenuContent
|
|
468
508
|
{...popupEventProps}
|
|
509
|
+
aria-busy={options === undefined || undefined}
|
|
469
510
|
className={cn("w-max min-w-72 max-w-90", contentClassName)}
|
|
470
511
|
>
|
|
471
512
|
<DropdownMenuGroup>
|
|
472
513
|
<DropdownMenuLabel>{label}</DropdownMenuLabel>
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
514
|
+
{options === undefined ? (
|
|
515
|
+
// A disabled item: a menu takes only items, groups and
|
|
516
|
+
// separators, so a screen reader reads "Loading…" as a dimmed
|
|
517
|
+
// item. One item tall, so the items take its place without a jump.
|
|
518
|
+
<MenuPrimitive.Item
|
|
519
|
+
disabled
|
|
520
|
+
data-slot="breadcrumb-menu-loading"
|
|
521
|
+
// The shared item look: the arrow keys stop on it, so it
|
|
522
|
+
// keeps the focus ring.
|
|
523
|
+
className={cn(menuItem, "text-muted-foreground")}
|
|
524
|
+
>
|
|
525
|
+
<Loader2Icon aria-hidden className="size-3.75 animate-spin motion-reduce:animate-none" />
|
|
526
|
+
{t.loading}
|
|
527
|
+
</MenuPrimitive.Item>
|
|
528
|
+
) : (
|
|
529
|
+
<MenuPrimitive.RadioGroup
|
|
530
|
+
value={value}
|
|
531
|
+
onValueChange={(next: string, details) => {
|
|
532
|
+
// A modifier or middle click opens a link row elsewhere: the
|
|
533
|
+
// current item stays.
|
|
534
|
+
if (isNewTabClick(details.event)) return
|
|
535
|
+
onValueChange?.(next)
|
|
536
|
+
}}
|
|
537
|
+
>
|
|
538
|
+
{options.map((option) => (
|
|
539
|
+
<MenuPrimitive.RadioItem
|
|
540
|
+
key={option.value}
|
|
541
|
+
value={option.value}
|
|
542
|
+
disabled={option.disabled}
|
|
543
|
+
closeOnClick={false}
|
|
544
|
+
data-slot="breadcrumb-menu-item"
|
|
545
|
+
render={option.disabled ? undefined : (option.render ?? (option.href !== undefined ? <a href={option.href} /> : undefined))}
|
|
546
|
+
className={cn(menuItem, menuRadioItem)}
|
|
547
|
+
>
|
|
548
|
+
<OptionRow option={option} />
|
|
549
|
+
<MenuCheck />
|
|
550
|
+
</MenuPrimitive.RadioItem>
|
|
551
|
+
))}
|
|
552
|
+
</MenuPrimitive.RadioGroup>
|
|
553
|
+
)}
|
|
497
554
|
</DropdownMenuGroup>
|
|
498
555
|
{children}
|
|
499
556
|
</DropdownMenuContent>
|
|
@@ -518,17 +575,19 @@ function searchFilter(_value: string, search: string, keywords?: string[]) {
|
|
|
518
575
|
* project". The search matches the option labels and `keywords`.
|
|
519
576
|
*
|
|
520
577
|
* Picking an option calls `onValueChange` and closes the popup, so the crumb's
|
|
521
|
-
* label is seen swapping. `
|
|
522
|
-
* options. `error` shows its text as a row that cannot be picked and,
|
|
523
|
-
* `onRetry`, a Retry row. A search that
|
|
578
|
+
* label is seen swapping. `options={undefined}` shows a loading row in place
|
|
579
|
+
* of the options. `error` shows its text as a row that cannot be picked and,
|
|
580
|
+
* with `onRetry`, a Retry row; it wins over the loading row. A search that
|
|
581
|
+
* matches nothing shows `emptyText`.
|
|
524
582
|
* Footer items are `CommandItem`s with `forceMount`, so a search does not
|
|
525
583
|
* hide them, and close the popup themselves through `onOpenChange`. *
|
|
526
|
-
* `
|
|
584
|
+
* `options={undefined}` is about the list in the open popup. `pending` is about the
|
|
527
585
|
* crumb: while the current item loads, it shows the last known name, or a
|
|
528
586
|
* text skeleton in place of a placeholder word when no name is known.
|
|
529
587
|
*/
|
|
530
588
|
function BreadcrumbSearchMenu({
|
|
531
|
-
options,
|
|
589
|
+
options: optionsProp,
|
|
590
|
+
loading: loadingProp,
|
|
532
591
|
value,
|
|
533
592
|
onValueChange,
|
|
534
593
|
label,
|
|
@@ -537,34 +596,63 @@ function BreadcrumbSearchMenu({
|
|
|
537
596
|
open: openProp,
|
|
538
597
|
onOpenChange,
|
|
539
598
|
defaultOpen = false,
|
|
540
|
-
searchPlaceholder
|
|
541
|
-
emptyText
|
|
542
|
-
loading = false,
|
|
599
|
+
searchPlaceholder,
|
|
600
|
+
emptyText,
|
|
543
601
|
error,
|
|
544
602
|
onRetry,
|
|
603
|
+
loadingLabel,
|
|
604
|
+
retryLabel,
|
|
545
605
|
children,
|
|
546
606
|
className,
|
|
547
607
|
contentClassName,
|
|
548
608
|
}: BreadcrumbMenuBaseProps & {
|
|
549
|
-
/**
|
|
609
|
+
/**
|
|
610
|
+
* The search field's placeholder.
|
|
611
|
+
* @default `messages.breadcrumb.search`, "Find {label}…", with `{label}` the menu's `label` in lower case
|
|
612
|
+
*/
|
|
550
613
|
searchPlaceholder?: string
|
|
551
|
-
/**
|
|
614
|
+
/**
|
|
615
|
+
* Shows when the search matches no option.
|
|
616
|
+
* @default `messages.breadcrumb.empty`, "No results."
|
|
617
|
+
*/
|
|
552
618
|
emptyText?: React.ReactNode
|
|
553
|
-
/** The options are on their way: a loading row shows in their place. */
|
|
554
|
-
loading?: boolean
|
|
555
619
|
/** The options could not be read: this text shows as a row. */
|
|
556
620
|
error?: React.ReactNode
|
|
557
621
|
/** With `error`, a Retry row calls it. */
|
|
558
622
|
onRetry?: () => void
|
|
623
|
+
/**
|
|
624
|
+
* The text of the Retry row.
|
|
625
|
+
* @default `messages.breadcrumb.retry`, "Retry"
|
|
626
|
+
*/
|
|
627
|
+
retryLabel?: string
|
|
628
|
+
/**
|
|
629
|
+
* @deprecated Pass `options={undefined}` while the options load. Removed
|
|
630
|
+
* in 4.0.
|
|
631
|
+
*/
|
|
632
|
+
loading?: boolean
|
|
559
633
|
/** Footer items: `CommandItem`s with `forceMount`. */
|
|
560
634
|
children?: React.ReactNode
|
|
561
635
|
}) {
|
|
636
|
+
if (loadingProp !== undefined) {
|
|
637
|
+
warnDeprecated("BreadcrumbSearchMenu", "loading", "options={undefined}")
|
|
638
|
+
}
|
|
639
|
+
// The 2.x `loading` flag stands for `options={undefined}` in the list. The
|
|
640
|
+
// crumb still names the current option from the options it has.
|
|
641
|
+
const options = loadingProp ? undefined : optionsProp
|
|
562
642
|
const [open, setOpen] = useMenuOpen(openProp, defaultOpen, onOpenChange)
|
|
563
|
-
const crumb = useCrumbTrigger({ options, value, label, placeholder, open })
|
|
643
|
+
const crumb = useCrumbTrigger({ options: optionsProp ?? [], value, label, placeholder, open })
|
|
644
|
+
const t = useMessages("breadcrumb", {
|
|
645
|
+
loading: loadingLabel,
|
|
646
|
+
retry: retryLabel,
|
|
647
|
+
search: searchPlaceholder,
|
|
648
|
+
})
|
|
564
649
|
const failed = error != null && error !== false
|
|
650
|
+
// The error wins: a failed first read has no options either.
|
|
651
|
+
const loading = options === undefined && !failed
|
|
565
652
|
// Without a name, a skeleton. The trigger mounts with the first name, so
|
|
566
653
|
// it shows without a swap.
|
|
567
|
-
if (pending && !crumb.named)
|
|
654
|
+
if (pending && !crumb.named)
|
|
655
|
+
return <PendingCrumb label={label} loadingLabel={t.loading} className={className} />
|
|
568
656
|
return (
|
|
569
657
|
<Popover open={open} onOpenChange={setOpen}>
|
|
570
658
|
<Tooltip>
|
|
@@ -597,31 +685,38 @@ function BreadcrumbSearchMenu({
|
|
|
597
685
|
selected after it unmounts, and the field then points at a row
|
|
598
686
|
that is gone (aria-activedescendant). */}
|
|
599
687
|
<Command key={failed ? "failed" : "read"} label={label} filter={searchFilter}>
|
|
600
|
-
<CommandInput autoFocus placeholder={
|
|
601
|
-
{/* Outside the list: a listbox takes only options and groups.
|
|
688
|
+
<CommandInput autoFocus placeholder={t.search.replaceAll("{label}", label.toLowerCase())} />
|
|
689
|
+
{/* Outside the list: a listbox takes only options and groups. As
|
|
690
|
+
tall as one option row with its group's padding, so one
|
|
691
|
+
option takes its place without a jump. */}
|
|
692
|
+
{/* Stays mounted, so screen readers announce the change: a status
|
|
693
|
+
that mounts with its text is not reliably read. */}
|
|
694
|
+
<div role="status" data-slot="breadcrumb-search-menu-status" className="sr-only">
|
|
695
|
+
{loading ? t.loading : null}
|
|
696
|
+
</div>
|
|
602
697
|
{loading && (
|
|
603
698
|
<div
|
|
604
|
-
|
|
699
|
+
aria-hidden
|
|
605
700
|
data-slot="breadcrumb-search-menu-loading"
|
|
606
|
-
className="text-muted-foreground flex min-h-
|
|
701
|
+
className="text-muted-foreground flex min-h-10 items-center gap-2.5 px-4 pt-2 text-sm"
|
|
607
702
|
>
|
|
608
703
|
<Loader2Icon aria-hidden className="size-3.75 animate-spin motion-reduce:animate-none" />
|
|
609
|
-
|
|
704
|
+
{t.loading}
|
|
610
705
|
</div>
|
|
611
706
|
)}
|
|
612
|
-
<CommandList>
|
|
613
|
-
{!loading && !failed && <CommandEmpty>{emptyText}</CommandEmpty>}
|
|
614
|
-
{failed &&
|
|
707
|
+
<CommandList aria-busy={loading || undefined}>
|
|
708
|
+
{!loading && !failed && <CommandEmpty>{emptyText !== undefined ? emptyText : t.empty}</CommandEmpty>}
|
|
709
|
+
{failed && (
|
|
615
710
|
<CommandGroup forceMount heading={error}>
|
|
616
711
|
{onRetry && (
|
|
617
712
|
<CommandItem forceMount value="__retry" onSelect={onRetry}>
|
|
618
713
|
<RefreshCwIcon />
|
|
619
|
-
<span className="min-w-0 truncate">
|
|
714
|
+
<span className="min-w-0 truncate">{t.retry}</span>
|
|
620
715
|
</CommandItem>
|
|
621
716
|
)}
|
|
622
717
|
</CommandGroup>
|
|
623
718
|
)}
|
|
624
|
-
{
|
|
719
|
+
{options !== undefined && options.length > 0 && (
|
|
625
720
|
<CommandGroup>
|
|
626
721
|
{options.map((option) => (
|
|
627
722
|
<CommandItem
|
|
@@ -3,7 +3,7 @@ import { useRender } from "@base-ui/react/use-render"
|
|
|
3
3
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
4
|
|
|
5
5
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
6
|
-
import { outlineEdgeRing } from "
|
|
6
|
+
import { outlineEdgeRing } from "../../lib/outline-edge.ts"
|
|
7
7
|
import { Separator } from "@vendure-io/ui/components/atoms/separator"
|
|
8
8
|
|
|
9
9
|
// The v3 look: the group draws one outer edge and its children draw none.
|
|
@@ -8,9 +8,9 @@ import { cva, type VariantProps } from "class-variance-authority"
|
|
|
8
8
|
|
|
9
9
|
// Relative: `label-swap` is closed in the package exports.
|
|
10
10
|
import { LabelSwap } from "./label-swap.tsx"
|
|
11
|
-
import { contentInsetPull } from "
|
|
11
|
+
import { contentInsetPull } from "../../lib/content-inset.ts"
|
|
12
12
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
13
|
-
import { outlineEdge, outlineEdgeHover } from "
|
|
13
|
+
import { outlineEdge, outlineEdgeHover } from "../../lib/outline-edge.ts"
|
|
14
14
|
import { isDevelopment } from "../../lib/env.ts"
|
|
15
15
|
|
|
16
16
|
// The v3 look: 34px default and 28px sm, the xl radius, 14px medium text.
|
|
@@ -99,7 +99,7 @@ function Calendar({
|
|
|
99
99
|
table: "w-full border-collapse",
|
|
100
100
|
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
101
101
|
weekday: cn(
|
|
102
|
-
"text-muted-foreground rounded-(--cell-radius) flex-1 font-normal text-
|
|
102
|
+
"text-muted-foreground rounded-(--cell-radius) flex-1 font-normal text-xs select-none",
|
|
103
103
|
defaultClassNames.weekday
|
|
104
104
|
),
|
|
105
105
|
week: cn("flex w-full mt-2", defaultClassNames.week),
|
|
@@ -108,7 +108,7 @@ function Calendar({
|
|
|
108
108
|
defaultClassNames.week_number_header
|
|
109
109
|
),
|
|
110
110
|
week_number: cn(
|
|
111
|
-
"text-
|
|
111
|
+
"text-xs select-none text-muted-foreground",
|
|
112
112
|
defaultClassNames.week_number
|
|
113
113
|
),
|
|
114
114
|
day: cn(
|