@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
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.5",
|
|
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,6 +37,8 @@ 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
|
function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
|
|
42
44
|
return (
|
|
@@ -189,7 +191,12 @@ type BreadcrumbSearchMenuOption = Omit<BreadcrumbMenuOption, "render" | "href">
|
|
|
189
191
|
|
|
190
192
|
/** The props both crumb menus share. */
|
|
191
193
|
type BreadcrumbMenuBaseProps = {
|
|
192
|
-
|
|
194
|
+
/**
|
|
195
|
+
* The items to switch to. `undefined` means they are still loading: the
|
|
196
|
+
* open menu shows a loading row, one item tall, in their place. `[]` means
|
|
197
|
+
* there are none.
|
|
198
|
+
*/
|
|
199
|
+
options: readonly BreadcrumbSearchMenuOption[] | undefined
|
|
193
200
|
value: string
|
|
194
201
|
onValueChange?: (value: string) => void
|
|
195
202
|
/** Names the list: it heads the menu and starts the crumb's accessible name. */
|
|
@@ -215,6 +222,12 @@ type BreadcrumbMenuBaseProps = {
|
|
|
215
222
|
* `placeholder` undefined and the skeleton shows.
|
|
216
223
|
*/
|
|
217
224
|
pending?: boolean
|
|
225
|
+
/**
|
|
226
|
+
* Read while the options load, and after the list label in the pending
|
|
227
|
+
* crumb ("Project: Loading…").
|
|
228
|
+
* @default `messages.breadcrumb.loading`, "Loading…"
|
|
229
|
+
*/
|
|
230
|
+
loadingLabel?: string
|
|
218
231
|
open?: boolean
|
|
219
232
|
onOpenChange?: (open: boolean) => void
|
|
220
233
|
defaultOpen?: boolean
|
|
@@ -261,7 +274,15 @@ const crumbTriggerClassName =
|
|
|
261
274
|
* is known. The skeleton is hidden from screen readers, which hear the
|
|
262
275
|
* status text instead. A `div`, as the skeleton is one.
|
|
263
276
|
*/
|
|
264
|
-
function PendingCrumb({
|
|
277
|
+
function PendingCrumb({
|
|
278
|
+
label,
|
|
279
|
+
loadingLabel,
|
|
280
|
+
className,
|
|
281
|
+
}: {
|
|
282
|
+
label: string
|
|
283
|
+
loadingLabel: string
|
|
284
|
+
className?: string
|
|
285
|
+
}) {
|
|
265
286
|
return (
|
|
266
287
|
<div
|
|
267
288
|
role="status"
|
|
@@ -271,7 +292,7 @@ function PendingCrumb({ label, className }: { label: string; className?: string
|
|
|
271
292
|
className
|
|
272
293
|
)}
|
|
273
294
|
>
|
|
274
|
-
<span className="sr-only">{`${label}:
|
|
295
|
+
<span className="sr-only">{`${label}: ${loadingLabel}`}</span>
|
|
275
296
|
<Skeleton aria-hidden className="h-[0.8lh] w-24 min-w-0 shrink" />
|
|
276
297
|
</div>
|
|
277
298
|
)
|
|
@@ -290,7 +311,8 @@ function useCrumbTrigger({
|
|
|
290
311
|
label,
|
|
291
312
|
placeholder,
|
|
292
313
|
open,
|
|
293
|
-
}: Pick<BreadcrumbMenuBaseProps, "
|
|
314
|
+
}: Pick<BreadcrumbMenuBaseProps, "value" | "label" | "placeholder"> & {
|
|
315
|
+
options: readonly BreadcrumbSearchMenuOption[]
|
|
294
316
|
open: boolean
|
|
295
317
|
}) {
|
|
296
318
|
const found = options.findIndex((option) => option.value === value)
|
|
@@ -427,6 +449,7 @@ function BreadcrumbMenu({
|
|
|
427
449
|
label,
|
|
428
450
|
placeholder,
|
|
429
451
|
pending = false,
|
|
452
|
+
loadingLabel,
|
|
430
453
|
open: openProp,
|
|
431
454
|
onOpenChange,
|
|
432
455
|
defaultOpen = false,
|
|
@@ -434,14 +457,21 @@ function BreadcrumbMenu({
|
|
|
434
457
|
className,
|
|
435
458
|
contentClassName,
|
|
436
459
|
}: Omit<BreadcrumbMenuBaseProps, "options"> & {
|
|
437
|
-
|
|
460
|
+
/**
|
|
461
|
+
* The items to switch to. `undefined` means they are still loading: the
|
|
462
|
+
* open menu shows a loading row, one item tall, in their place. `[]` means
|
|
463
|
+
* there are none.
|
|
464
|
+
*/
|
|
465
|
+
options: readonly BreadcrumbMenuOption[] | undefined
|
|
438
466
|
children?: React.ReactNode
|
|
439
467
|
}) {
|
|
440
468
|
const [open, setOpen] = useMenuOpen(openProp, defaultOpen, onOpenChange)
|
|
441
|
-
const crumb = useCrumbTrigger({ options, value, label, placeholder, open })
|
|
469
|
+
const crumb = useCrumbTrigger({ options: options ?? [], value, label, placeholder, open })
|
|
470
|
+
const t = useMessages("breadcrumb", { loading: loadingLabel })
|
|
442
471
|
// Without a name, a skeleton. The trigger mounts with the first name, so
|
|
443
472
|
// it shows without a swap.
|
|
444
|
-
if (pending && !crumb.named)
|
|
473
|
+
if (pending && !crumb.named)
|
|
474
|
+
return <PendingCrumb label={label} loadingLabel={t.loading} className={className} />
|
|
445
475
|
return (
|
|
446
476
|
<DropdownMenu open={open} onOpenChange={setOpen}>
|
|
447
477
|
<Tooltip>
|
|
@@ -466,34 +496,51 @@ function BreadcrumbMenu({
|
|
|
466
496
|
</Tooltip>
|
|
467
497
|
<DropdownMenuContent
|
|
468
498
|
{...popupEventProps}
|
|
499
|
+
aria-busy={options === undefined || undefined}
|
|
469
500
|
className={cn("w-max min-w-72 max-w-90", contentClassName)}
|
|
470
501
|
>
|
|
471
502
|
<DropdownMenuGroup>
|
|
472
503
|
<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
|
-
|
|
504
|
+
{options === undefined ? (
|
|
505
|
+
// A disabled item: a menu takes only items, groups and
|
|
506
|
+
// separators, so a screen reader reads "Loading…" as a dimmed
|
|
507
|
+
// item. One item tall, so the items take its place without a jump.
|
|
508
|
+
<MenuPrimitive.Item
|
|
509
|
+
disabled
|
|
510
|
+
data-slot="breadcrumb-menu-loading"
|
|
511
|
+
// The shared item look: the arrow keys stop on it, so it
|
|
512
|
+
// keeps the focus ring.
|
|
513
|
+
className={cn(menuItem, "text-muted-foreground")}
|
|
514
|
+
>
|
|
515
|
+
<Loader2Icon aria-hidden className="size-3.75 animate-spin motion-reduce:animate-none" />
|
|
516
|
+
{t.loading}
|
|
517
|
+
</MenuPrimitive.Item>
|
|
518
|
+
) : (
|
|
519
|
+
<MenuPrimitive.RadioGroup
|
|
520
|
+
value={value}
|
|
521
|
+
onValueChange={(next: string, details) => {
|
|
522
|
+
// A modifier or middle click opens a link row elsewhere: the
|
|
523
|
+
// current item stays.
|
|
524
|
+
if (isNewTabClick(details.event)) return
|
|
525
|
+
onValueChange?.(next)
|
|
526
|
+
}}
|
|
527
|
+
>
|
|
528
|
+
{options.map((option) => (
|
|
529
|
+
<MenuPrimitive.RadioItem
|
|
530
|
+
key={option.value}
|
|
531
|
+
value={option.value}
|
|
532
|
+
disabled={option.disabled}
|
|
533
|
+
closeOnClick={false}
|
|
534
|
+
data-slot="breadcrumb-menu-item"
|
|
535
|
+
render={option.disabled ? undefined : (option.render ?? (option.href !== undefined ? <a href={option.href} /> : undefined))}
|
|
536
|
+
className={cn(menuItem, menuRadioItem)}
|
|
537
|
+
>
|
|
538
|
+
<OptionRow option={option} />
|
|
539
|
+
<MenuCheck />
|
|
540
|
+
</MenuPrimitive.RadioItem>
|
|
541
|
+
))}
|
|
542
|
+
</MenuPrimitive.RadioGroup>
|
|
543
|
+
)}
|
|
497
544
|
</DropdownMenuGroup>
|
|
498
545
|
{children}
|
|
499
546
|
</DropdownMenuContent>
|
|
@@ -518,17 +565,19 @@ function searchFilter(_value: string, search: string, keywords?: string[]) {
|
|
|
518
565
|
* project". The search matches the option labels and `keywords`.
|
|
519
566
|
*
|
|
520
567
|
* 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
|
|
568
|
+
* label is seen swapping. `options={undefined}` shows a loading row in place
|
|
569
|
+
* of the options. `error` shows its text as a row that cannot be picked and,
|
|
570
|
+
* with `onRetry`, a Retry row; it wins over the loading row. A search that
|
|
571
|
+
* matches nothing shows `emptyText`.
|
|
524
572
|
* Footer items are `CommandItem`s with `forceMount`, so a search does not
|
|
525
573
|
* hide them, and close the popup themselves through `onOpenChange`. *
|
|
526
|
-
* `
|
|
574
|
+
* `options={undefined}` is about the list in the open popup. `pending` is about the
|
|
527
575
|
* crumb: while the current item loads, it shows the last known name, or a
|
|
528
576
|
* text skeleton in place of a placeholder word when no name is known.
|
|
529
577
|
*/
|
|
530
578
|
function BreadcrumbSearchMenu({
|
|
531
|
-
options,
|
|
579
|
+
options: optionsProp,
|
|
580
|
+
loading: loadingProp,
|
|
532
581
|
value,
|
|
533
582
|
onValueChange,
|
|
534
583
|
label,
|
|
@@ -539,9 +588,10 @@ function BreadcrumbSearchMenu({
|
|
|
539
588
|
defaultOpen = false,
|
|
540
589
|
searchPlaceholder = `Find ${label.toLowerCase()}…`,
|
|
541
590
|
emptyText = "No results.",
|
|
542
|
-
loading = false,
|
|
543
591
|
error,
|
|
544
592
|
onRetry,
|
|
593
|
+
loadingLabel,
|
|
594
|
+
retryLabel,
|
|
545
595
|
children,
|
|
546
596
|
className,
|
|
547
597
|
contentClassName,
|
|
@@ -550,21 +600,39 @@ function BreadcrumbSearchMenu({
|
|
|
550
600
|
searchPlaceholder?: string
|
|
551
601
|
/** Shows when the search matches no option. */
|
|
552
602
|
emptyText?: React.ReactNode
|
|
553
|
-
/** The options are on their way: a loading row shows in their place. */
|
|
554
|
-
loading?: boolean
|
|
555
603
|
/** The options could not be read: this text shows as a row. */
|
|
556
604
|
error?: React.ReactNode
|
|
557
605
|
/** With `error`, a Retry row calls it. */
|
|
558
606
|
onRetry?: () => void
|
|
607
|
+
/**
|
|
608
|
+
* The text of the Retry row.
|
|
609
|
+
* @default `messages.breadcrumb.retry`, "Retry"
|
|
610
|
+
*/
|
|
611
|
+
retryLabel?: string
|
|
612
|
+
/**
|
|
613
|
+
* @deprecated Pass `options={undefined}` while the options load. Removed
|
|
614
|
+
* in 4.0.
|
|
615
|
+
*/
|
|
616
|
+
loading?: boolean
|
|
559
617
|
/** Footer items: `CommandItem`s with `forceMount`. */
|
|
560
618
|
children?: React.ReactNode
|
|
561
619
|
}) {
|
|
620
|
+
if (loadingProp !== undefined) {
|
|
621
|
+
warnDeprecated("BreadcrumbSearchMenu", "loading", "options={undefined}")
|
|
622
|
+
}
|
|
623
|
+
// The 2.x `loading` flag stands for `options={undefined}` in the list. The
|
|
624
|
+
// crumb still names the current option from the options it has.
|
|
625
|
+
const options = loadingProp ? undefined : optionsProp
|
|
562
626
|
const [open, setOpen] = useMenuOpen(openProp, defaultOpen, onOpenChange)
|
|
563
|
-
const crumb = useCrumbTrigger({ options, value, label, placeholder, open })
|
|
627
|
+
const crumb = useCrumbTrigger({ options: optionsProp ?? [], value, label, placeholder, open })
|
|
628
|
+
const t = useMessages("breadcrumb", { loading: loadingLabel, retry: retryLabel })
|
|
564
629
|
const failed = error != null && error !== false
|
|
630
|
+
// The error wins: a failed first read has no options either.
|
|
631
|
+
const loading = options === undefined && !failed
|
|
565
632
|
// Without a name, a skeleton. The trigger mounts with the first name, so
|
|
566
633
|
// it shows without a swap.
|
|
567
|
-
if (pending && !crumb.named)
|
|
634
|
+
if (pending && !crumb.named)
|
|
635
|
+
return <PendingCrumb label={label} loadingLabel={t.loading} className={className} />
|
|
568
636
|
return (
|
|
569
637
|
<Popover open={open} onOpenChange={setOpen}>
|
|
570
638
|
<Tooltip>
|
|
@@ -598,30 +666,37 @@ function BreadcrumbSearchMenu({
|
|
|
598
666
|
that is gone (aria-activedescendant). */}
|
|
599
667
|
<Command key={failed ? "failed" : "read"} label={label} filter={searchFilter}>
|
|
600
668
|
<CommandInput autoFocus placeholder={searchPlaceholder} />
|
|
601
|
-
{/* Outside the list: a listbox takes only options and groups.
|
|
669
|
+
{/* Outside the list: a listbox takes only options and groups. As
|
|
670
|
+
tall as one option row with its group's padding, so one
|
|
671
|
+
option takes its place without a jump. */}
|
|
672
|
+
{/* Stays mounted, so screen readers announce the change: a status
|
|
673
|
+
that mounts with its text is not reliably read. */}
|
|
674
|
+
<div role="status" data-slot="breadcrumb-search-menu-status" className="sr-only">
|
|
675
|
+
{loading ? t.loading : null}
|
|
676
|
+
</div>
|
|
602
677
|
{loading && (
|
|
603
678
|
<div
|
|
604
|
-
|
|
679
|
+
aria-hidden
|
|
605
680
|
data-slot="breadcrumb-search-menu-loading"
|
|
606
|
-
className="text-muted-foreground flex min-h-
|
|
681
|
+
className="text-muted-foreground flex min-h-10 items-center gap-2.5 px-4 pt-2 text-sm"
|
|
607
682
|
>
|
|
608
683
|
<Loader2Icon aria-hidden className="size-3.75 animate-spin motion-reduce:animate-none" />
|
|
609
|
-
|
|
684
|
+
{t.loading}
|
|
610
685
|
</div>
|
|
611
686
|
)}
|
|
612
|
-
<CommandList>
|
|
687
|
+
<CommandList aria-busy={loading || undefined}>
|
|
613
688
|
{!loading && !failed && <CommandEmpty>{emptyText}</CommandEmpty>}
|
|
614
|
-
{failed &&
|
|
689
|
+
{failed && (
|
|
615
690
|
<CommandGroup forceMount heading={error}>
|
|
616
691
|
{onRetry && (
|
|
617
692
|
<CommandItem forceMount value="__retry" onSelect={onRetry}>
|
|
618
693
|
<RefreshCwIcon />
|
|
619
|
-
<span className="min-w-0 truncate">
|
|
694
|
+
<span className="min-w-0 truncate">{t.retry}</span>
|
|
620
695
|
</CommandItem>
|
|
621
696
|
)}
|
|
622
697
|
</CommandGroup>
|
|
623
698
|
)}
|
|
624
|
-
{
|
|
699
|
+
{options !== undefined && options.length > 0 && (
|
|
625
700
|
<CommandGroup>
|
|
626
701
|
{options.map((option) => (
|
|
627
702
|
<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(
|
|
@@ -103,7 +103,7 @@ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
103
103
|
<div
|
|
104
104
|
data-slot="card-title"
|
|
105
105
|
className={cn(
|
|
106
|
-
"font-heading text-sm font-semibold tracking-[-0.005em] text-foreground-secondary has-data-[slot=card-count]:flex has-data-[slot=card-count]:items-baseline has-data-[slot=card-count]:gap-2.5",
|
|
106
|
+
"font-heading text-sm font-semibold tracking-[-0.005em] text-foreground-secondary has-data-[slot=card-count]:flex has-data-[slot=card-count]:items-baseline has-data-[slot=card-count]:gap-2.5 @max-xs/card-header:col-span-full",
|
|
107
107
|
className
|
|
108
108
|
)}
|
|
109
109
|
{...props}
|
|
@@ -176,7 +176,10 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
176
176
|
return (
|
|
177
177
|
<div
|
|
178
178
|
data-slot="card-description"
|
|
179
|
-
className={cn(
|
|
179
|
+
className={cn(
|
|
180
|
+
"text-foreground-secondary text-sm @max-xs/card-header:col-span-full",
|
|
181
|
+
className
|
|
182
|
+
)}
|
|
180
183
|
{...props}
|
|
181
184
|
/>
|
|
182
185
|
)
|
|
@@ -185,12 +188,22 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
185
188
|
// The action box is one title line high and centres its content, so a small
|
|
186
189
|
// button lines up with the title and overflows into the card padding instead
|
|
187
190
|
// of making the header row taller.
|
|
191
|
+
// When the header is narrower than 20rem (a container query on the header,
|
|
192
|
+
// so it follows the card and not the viewport) the action leaves the second
|
|
193
|
+
// column and takes its own row under the title and description, which then
|
|
194
|
+
// span the header too. The action starts at the inline start (the right in
|
|
195
|
+
// RTL), grows to its content's height and wraps inside the header instead of
|
|
196
|
+
// overflowing.
|
|
197
|
+
const NARROW_ACTION =
|
|
198
|
+
"@max-xs/card-header:order-last @max-xs/card-header:col-span-full @max-xs/card-header:col-start-1 @max-xs/card-header:row-span-1 @max-xs/card-header:row-start-auto @max-xs/card-header:mt-2 @max-xs/card-header:h-auto @max-xs/card-header:max-w-full @max-xs/card-header:justify-self-start"
|
|
199
|
+
|
|
188
200
|
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
189
201
|
return (
|
|
190
202
|
<div
|
|
191
203
|
data-slot="card-action"
|
|
192
204
|
className={cn(
|
|
193
205
|
"col-start-2 row-span-2 row-start-1 flex h-lh flex-wrap content-center items-center gap-2 self-start justify-self-end",
|
|
206
|
+
NARROW_ACTION,
|
|
194
207
|
className
|
|
195
208
|
)}
|
|
196
209
|
{...props}
|