@vendure-io/ui 2.2.0 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +19 -5
- package/src/components/atoms/accordion.tsx +21 -6
- package/src/components/atoms/alert-dialog.tsx +31 -6
- package/src/components/atoms/alert.tsx +72 -18
- package/src/components/atoms/avatar.tsx +12 -4
- package/src/components/atoms/badge.tsx +7 -2
- package/src/components/atoms/breadcrumb.tsx +493 -4
- package/src/components/atoms/button-group.tsx +30 -6
- package/src/components/atoms/button.tsx +128 -18
- package/src/components/atoms/calendar.tsx +6 -6
- package/src/components/atoms/card.tsx +130 -16
- package/src/components/atoms/carousel.tsx +16 -9
- package/src/components/atoms/chart.tsx +87 -1
- package/src/components/atoms/checkbox.tsx +85 -7
- package/src/components/atoms/collapsible.tsx +2 -1
- package/src/components/atoms/combobox.tsx +358 -29
- package/src/components/atoms/command.tsx +336 -13
- package/src/components/atoms/context-menu.tsx +28 -23
- package/src/components/atoms/dialog.tsx +173 -29
- package/src/components/atoms/direction.tsx +23 -2
- package/src/components/atoms/drawer.tsx +15 -10
- package/src/components/atoms/dropdown-menu.tsx +43 -28
- package/src/components/atoms/empty.tsx +5 -1
- package/src/components/atoms/field.tsx +41 -15
- package/src/components/atoms/hover-card.tsx +61 -8
- package/src/components/atoms/input-group.tsx +19 -11
- package/src/components/atoms/input-otp.tsx +6 -6
- package/src/components/atoms/input.tsx +7 -1
- package/src/components/atoms/item.tsx +3 -3
- package/src/components/atoms/kbd.tsx +32 -3
- package/src/components/atoms/label-swap.tsx +113 -0
- package/src/components/atoms/label.tsx +1 -1
- package/src/components/atoms/menubar.tsx +28 -26
- package/src/components/atoms/native-select.tsx +3 -2
- package/src/components/atoms/navigation-menu.tsx +13 -8
- package/src/components/atoms/pagination.tsx +2 -2
- package/src/components/atoms/popover.tsx +29 -6
- package/src/components/atoms/progress.tsx +46 -33
- package/src/components/atoms/radio-group.tsx +9 -4
- package/src/components/atoms/resizable.tsx +1 -1
- package/src/components/atoms/scroll-area.tsx +2 -2
- package/src/components/atoms/select.tsx +258 -19
- package/src/components/atoms/sheet.tsx +76 -23
- package/src/components/atoms/sidebar.tsx +405 -23
- package/src/components/atoms/skeleton.tsx +1 -1
- package/src/components/atoms/slider.tsx +1 -1
- package/src/components/atoms/sonner.tsx +128 -38
- package/src/components/atoms/spinner.tsx +1 -1
- package/src/components/atoms/switch.tsx +10 -5
- package/src/components/atoms/table.tsx +147 -7
- package/src/components/atoms/tabs.tsx +3 -3
- package/src/components/atoms/textarea.tsx +3 -1
- package/src/components/atoms/toggle-group.tsx +4 -2
- package/src/components/atoms/toggle.tsx +28 -6
- package/src/components/atoms/tooltip.tsx +85 -15
- package/src/components/molecules/anonymized-token.tsx +24 -8
- package/src/components/molecules/app-shell.tsx +53 -20
- package/src/components/molecules/arrow-link.tsx +40 -0
- package/src/components/molecules/chip.tsx +43 -4
- package/src/components/molecules/code-block.tsx +54 -31
- package/src/components/molecules/collapsible-section.tsx +129 -0
- package/src/components/molecules/confirm-dialog.tsx +122 -9
- package/src/components/molecules/copyable-text.tsx +75 -11
- package/src/components/molecules/count-badge.tsx +115 -0
- package/src/components/molecules/data-table/data-table-bulk-actions.tsx +32 -4
- package/src/components/molecules/data-table/data-table-column-header.tsx +20 -3
- package/src/components/molecules/data-table/data-table-filters.tsx +62 -22
- package/src/components/molecules/data-table/data-table-helpers.tsx +88 -1
- package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
- package/src/components/molecules/data-table/data-table-types.tsx +160 -4
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
- package/src/components/molecules/data-table/data-table.tsx +869 -81
- package/src/components/molecules/data-table/table-pagination.tsx +2 -2
- package/src/components/molecules/date-picker.tsx +13 -7
- package/src/components/molecules/date-range-picker.tsx +13 -6
- package/src/components/molecules/date-time-picker.tsx +13 -7
- package/src/components/molecules/date-time.tsx +8 -1
- package/src/components/molecules/direction-link.tsx +130 -0
- package/src/components/molecules/elapsed-time.tsx +223 -0
- package/src/components/molecules/file-dropzone.tsx +2 -2
- package/src/components/molecules/id-chip.tsx +169 -32
- package/src/components/molecules/inline-code.tsx +4 -0
- package/src/components/molecules/issued-secret.tsx +318 -0
- package/src/components/molecules/list-row.tsx +349 -0
- package/src/components/molecules/live-indicator.tsx +83 -0
- package/src/components/molecules/page-header.tsx +117 -5
- package/src/components/molecules/password-input.tsx +2 -2
- package/src/components/molecules/relative-time.tsx +85 -56
- package/src/components/molecules/search-trigger.tsx +111 -0
- package/src/components/molecules/secret-value.tsx +29 -9
- package/src/components/molecules/skip-link.tsx +1 -1
- package/src/components/molecules/stat-card.tsx +4 -4
- package/src/components/molecules/state-views/empty-state.tsx +35 -17
- package/src/components/molecules/state-views/error-state.tsx +32 -14
- package/src/components/molecules/status-badge.tsx +415 -49
- package/src/components/molecules/time-tooltip.tsx +140 -0
- package/src/components/molecules/timeline.tsx +246 -0
- package/src/components/molecules/visibility-icon.tsx +89 -0
- package/src/hooks/use-active-label-size.ts +66 -0
- package/src/hooks/use-apple-platform.ts +26 -0
- package/src/hooks/use-pinned-height.ts +55 -0
- package/src/hooks/use-scrolled.ts +27 -0
- package/src/lib/content-inset.ts +17 -0
- package/src/lib/control-name.ts +55 -0
- package/src/lib/dialog-padding.ts +48 -0
- package/src/lib/field-surface.ts +31 -0
- package/src/lib/format-elapsed.ts +67 -0
- package/src/lib/format-relative.ts +29 -1
- package/src/lib/highlight.ts +3 -3
- package/src/lib/menu-item.tsx +72 -0
- package/src/lib/outline-edge.ts +21 -0
- package/src/lib/popup-align.ts +67 -0
- package/src/lib/popup-direction.ts +22 -0
- package/src/lib/popup-motion.ts +19 -0
- package/src/lib/state-dictionary.ts +42 -6
- package/src/lib/syntax-colors.ts +8 -0
- package/src/lib/tint-recipes.ts +68 -0
- package/src/lib/tone-icons.ts +24 -0
- package/src/lib/trigger-slot.ts +16 -0
- package/src/lib/utils.ts +97 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure-io/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.1",
|
|
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",
|
|
@@ -13,27 +13,41 @@
|
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"exports": {
|
|
15
15
|
"./components/atoms/*": "./src/components/atoms/*.tsx",
|
|
16
|
+
"./components/atoms/label-swap": null,
|
|
16
17
|
"./components/molecules/*": "./src/components/molecules/*.tsx",
|
|
17
18
|
"./components/molecules/code-block/*": null,
|
|
18
19
|
"./components/molecules/data-table/data-table-helpers": null,
|
|
20
|
+
"./components/molecules/data-table/data-table-selection-storage": null,
|
|
21
|
+
"./components/molecules/direction-link": null,
|
|
22
|
+
"./components/molecules/time-tooltip": null,
|
|
19
23
|
"./lib/*": "./src/lib/*.ts",
|
|
20
|
-
"./
|
|
24
|
+
"./lib/control-name": null,
|
|
25
|
+
"./lib/dialog-padding": null,
|
|
26
|
+
"./lib/menu-item": null,
|
|
27
|
+
"./lib/popup-align": null,
|
|
28
|
+
"./lib/popup-direction": null,
|
|
29
|
+
"./lib/popup-motion": null,
|
|
30
|
+
"./lib/trigger-slot": null,
|
|
31
|
+
"./hooks/*": "./src/hooks/*.ts",
|
|
32
|
+
"./hooks/use-active-label-size": null,
|
|
33
|
+
"./hooks/use-pinned-height": null
|
|
21
34
|
},
|
|
22
35
|
"files": [
|
|
23
36
|
"src",
|
|
24
37
|
"!src/**/*.test.ts",
|
|
25
38
|
"!src/**/*.test.tsx",
|
|
39
|
+
"!src/test",
|
|
26
40
|
"README.md",
|
|
27
41
|
"LICENSE.md"
|
|
28
42
|
],
|
|
29
43
|
"scripts": {
|
|
30
|
-
"lint": "biome check src/",
|
|
31
|
-
"check-types": "tsc --noEmit && tsc --noEmit -p tsconfig.stories.json",
|
|
44
|
+
"lint": "biome check src/ guidance/",
|
|
45
|
+
"check-types": "tsc --noEmit && tsc --noEmit -p tsconfig.consumer-lib.json && tsc --noEmit -p tsconfig.stories.json",
|
|
32
46
|
"test": "bun test",
|
|
33
47
|
"pack:check": "bun pm pack --dry-run"
|
|
34
48
|
},
|
|
35
49
|
"peerDependencies": {
|
|
36
|
-
"@vendure-io/design-tokens": "^
|
|
50
|
+
"@vendure-io/design-tokens": "^3.0.0-next.1",
|
|
37
51
|
"react": ">=19",
|
|
38
52
|
"react-dom": ">=19",
|
|
39
53
|
"next": ">=14",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion"
|
|
4
4
|
|
|
5
5
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
6
|
-
import { ChevronDownIcon
|
|
6
|
+
import { ChevronDownIcon } from "lucide-react"
|
|
7
7
|
|
|
8
8
|
function Accordion({ className, ...props }: AccordionPrimitive.Root.Props) {
|
|
9
9
|
return (
|
|
@@ -25,6 +25,13 @@ function AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props) {
|
|
|
25
25
|
)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The header of an item: one full-width button with the title and a down
|
|
30
|
+
* chevron. The chevron sits 2px down, centred on the title's first 20px line,
|
|
31
|
+
* so it stays on that line when the title wraps. A closed trigger fills on
|
|
32
|
+
* hover. The chevron turns over on the panel's height timing, so both settle
|
|
33
|
+
* together; its colour follows the hover on the fill's timing.
|
|
34
|
+
*/
|
|
28
35
|
function AccordionTrigger({
|
|
29
36
|
className,
|
|
30
37
|
children,
|
|
@@ -35,19 +42,27 @@ function AccordionTrigger({
|
|
|
35
42
|
<AccordionPrimitive.Trigger
|
|
36
43
|
data-slot="accordion-trigger"
|
|
37
44
|
className={cn(
|
|
38
|
-
"focus-visible:
|
|
45
|
+
"focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring **:data-[slot=accordion-trigger-icon]:text-muted-foreground group/accordion-trigger relative flex flex-1 cursor-pointer items-start justify-between rounded-md border border-transparent px-3 py-4 text-start text-sm font-medium outline-none transition-colors duration-fast ease-default not-aria-expanded:hover:bg-muted aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ms-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:mt-0.5",
|
|
39
46
|
className
|
|
40
47
|
)}
|
|
41
48
|
{...props}
|
|
42
49
|
>
|
|
43
50
|
{children}
|
|
44
|
-
<ChevronDownIcon
|
|
45
|
-
|
|
51
|
+
<ChevronDownIcon
|
|
52
|
+
data-slot="accordion-trigger-icon"
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
className="pointer-events-none shrink-0 [transition:rotate_var(--transition-duration-slow)_var(--ease-height),color_var(--transition-duration-fast)_var(--ease-default)] group-hover/accordion-trigger:text-foreground group-aria-expanded/accordion-trigger:rotate-180 motion-reduce:[transition:color_var(--transition-duration-fast)_var(--ease-default)]"
|
|
55
|
+
/>
|
|
46
56
|
</AccordionPrimitive.Trigger>
|
|
47
57
|
</AccordionPrimitive.Header>
|
|
48
58
|
)
|
|
49
59
|
}
|
|
50
60
|
|
|
61
|
+
/**
|
|
62
|
+
* The panel eases its height and opacity with CSS transitions, so a second
|
|
63
|
+
* click mid-way reverses from where the panel is. Under reduced motion the
|
|
64
|
+
* height snaps and only a short fade remains.
|
|
65
|
+
*/
|
|
51
66
|
function AccordionContent({
|
|
52
67
|
className,
|
|
53
68
|
children,
|
|
@@ -56,12 +71,12 @@ function AccordionContent({
|
|
|
56
71
|
return (
|
|
57
72
|
<AccordionPrimitive.Panel
|
|
58
73
|
data-slot="accordion-content"
|
|
59
|
-
className="data-
|
|
74
|
+
className="h-(--accordion-panel-height) overflow-hidden text-sm data-starting-style:h-0 data-starting-style:opacity-0 data-ending-style:h-0 data-ending-style:opacity-0 motion-safe:transition-[height,opacity] motion-safe:duration-slow motion-safe:ease-height motion-reduce:transition-opacity motion-reduce:data-ending-style:h-(--accordion-panel-height) motion-reduce:duration-fast motion-reduce:ease-default"
|
|
60
75
|
{...props}
|
|
61
76
|
>
|
|
62
77
|
<div
|
|
63
78
|
className={cn(
|
|
64
|
-
"[&_a]:hover:text-foreground
|
|
79
|
+
"[&_a]:hover:text-foreground px-3 pt-0 pb-4 [&_a]:underline [&_a]:underline-offset-3 [&_p:not(:last-child)]:mb-4",
|
|
65
80
|
className
|
|
66
81
|
)}
|
|
67
82
|
>
|
|
@@ -5,6 +5,10 @@ import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
7
|
import { Button } from "@vendure-io/ui/components/atoms/button"
|
|
8
|
+
import { usePopupDir } from "../../lib/popup-direction.ts"
|
|
9
|
+
import { dialogPaddingStyle } from "../../lib/dialog-padding.ts"
|
|
10
|
+
import { usePinnedHeight } from "../../hooks/use-pinned-height.ts"
|
|
11
|
+
import { triggerSlot } from "../../lib/trigger-slot.ts"
|
|
8
12
|
|
|
9
13
|
function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
|
|
10
14
|
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
|
|
@@ -12,7 +16,7 @@ function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
|
|
|
12
16
|
|
|
13
17
|
function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {
|
|
14
18
|
return (
|
|
15
|
-
<AlertDialogPrimitive.Trigger
|
|
19
|
+
<AlertDialogPrimitive.Trigger {...triggerSlot("alert-dialog-trigger", props.render)} {...props} />
|
|
16
20
|
)
|
|
17
21
|
}
|
|
18
22
|
|
|
@@ -30,7 +34,7 @@ function AlertDialogOverlay({
|
|
|
30
34
|
<AlertDialogPrimitive.Backdrop
|
|
31
35
|
data-slot="alert-dialog-overlay"
|
|
32
36
|
className={cn(
|
|
33
|
-
"
|
|
37
|
+
"fixed inset-0 isolate z-50 bg-scrim transition-opacity duration-dialog-scrim ease-soft data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-dialog-exit supports-backdrop-filter:backdrop-blur-[2px]",
|
|
34
38
|
className
|
|
35
39
|
)}
|
|
36
40
|
{...props}
|
|
@@ -41,35 +45,51 @@ function AlertDialogOverlay({
|
|
|
41
45
|
function AlertDialogContent({
|
|
42
46
|
className,
|
|
43
47
|
size = "default",
|
|
48
|
+
style,
|
|
44
49
|
...props
|
|
45
50
|
}: AlertDialogPrimitive.Popup.Props & {
|
|
46
51
|
size?: "default" | "sm"
|
|
47
52
|
}) {
|
|
53
|
+
const dir = usePopupDir()
|
|
48
54
|
return (
|
|
49
55
|
<AlertDialogPortal>
|
|
50
56
|
<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`, which a `p-*` or `px-*` class also sets (dialogPaddingStyle), and the scroll padding keeps a focused field clear of the header and the footer. */}
|
|
51
58
|
<AlertDialogPrimitive.Popup
|
|
59
|
+
dir={dir}
|
|
52
60
|
data-slot="alert-dialog-content"
|
|
53
61
|
data-size={size}
|
|
54
62
|
className={cn(
|
|
55
|
-
"
|
|
63
|
+
"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",
|
|
56
64
|
className
|
|
57
65
|
)}
|
|
66
|
+
style={dialogPaddingStyle(className, style)}
|
|
58
67
|
{...props}
|
|
59
68
|
/>
|
|
60
69
|
</AlertDialogPortal>
|
|
61
70
|
)
|
|
62
71
|
}
|
|
63
72
|
|
|
73
|
+
// The header and the footer reach over the padding (`--dialog-padding`) and
|
|
74
|
+
// 16px of the 20px gap, with the surface behind, so a scrolled body passes
|
|
75
|
+
// under them. The margins cancel the paddings, and the negative offsets account
|
|
76
|
+
// for a sticky box sticking inside the padding. See DialogHeader.
|
|
77
|
+
const pinned = "sticky z-10 -mx-(--dialog-padding) bg-overlay px-(--dialog-padding)"
|
|
78
|
+
|
|
64
79
|
function AlertDialogHeader({
|
|
65
80
|
className,
|
|
81
|
+
ref,
|
|
66
82
|
...props
|
|
67
83
|
}: React.ComponentProps<"div">) {
|
|
84
|
+
const pinnedRef = usePinnedHeight("--pinned-header-height", "alert-dialog-content", ref)
|
|
68
85
|
return (
|
|
69
86
|
<div
|
|
87
|
+
ref={pinnedRef}
|
|
70
88
|
data-slot="alert-dialog-header"
|
|
71
89
|
className={cn(
|
|
72
|
-
|
|
90
|
+
pinned,
|
|
91
|
+
"-top-(--dialog-padding) -mt-(--dialog-padding) -mb-4 pt-(--dialog-padding) pb-4",
|
|
92
|
+
"grid grid-rows-[auto_1fr] place-items-center gap-2.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-start sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
|
|
73
93
|
className
|
|
74
94
|
)}
|
|
75
95
|
{...props}
|
|
@@ -79,12 +99,17 @@ function AlertDialogHeader({
|
|
|
79
99
|
|
|
80
100
|
function AlertDialogFooter({
|
|
81
101
|
className,
|
|
102
|
+
ref,
|
|
82
103
|
...props
|
|
83
104
|
}: React.ComponentProps<"div">) {
|
|
105
|
+
const pinnedRef = usePinnedHeight("--pinned-footer-height", "alert-dialog-content", ref)
|
|
84
106
|
return (
|
|
85
107
|
<div
|
|
108
|
+
ref={pinnedRef}
|
|
86
109
|
data-slot="alert-dialog-footer"
|
|
87
110
|
className={cn(
|
|
111
|
+
pinned,
|
|
112
|
+
"-bottom-(--dialog-padding) -mt-4 -mb-(--dialog-padding) pt-4 pb-(--dialog-padding)",
|
|
88
113
|
"flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
|
|
89
114
|
className
|
|
90
115
|
)}
|
|
@@ -117,7 +142,7 @@ function AlertDialogTitle({
|
|
|
117
142
|
<AlertDialogPrimitive.Title
|
|
118
143
|
data-slot="alert-dialog-title"
|
|
119
144
|
className={cn(
|
|
120
|
-
"text-style-
|
|
145
|
+
"text-style-dialog-title sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
|
|
121
146
|
className
|
|
122
147
|
)}
|
|
123
148
|
{...props}
|
|
@@ -133,7 +158,7 @@ function AlertDialogDescription({
|
|
|
133
158
|
<AlertDialogPrimitive.Description
|
|
134
159
|
data-slot="alert-dialog-description"
|
|
135
160
|
className={cn(
|
|
136
|
-
"text-
|
|
161
|
+
"text-foreground-secondary *:[a]:hover:text-foreground text-sm text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",
|
|
137
162
|
className
|
|
138
163
|
)}
|
|
139
164
|
{...props}
|
|
@@ -2,24 +2,46 @@ import * as React from "react"
|
|
|
2
2
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
3
|
|
|
4
4
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
5
|
+
import { alertTint, alertToneVars } from "@vendure-io/ui/lib/tint-recipes"
|
|
6
|
+
import { toneIcons } from "@vendure-io/ui/lib/tone-icons"
|
|
5
7
|
|
|
6
8
|
// Alert is an inline-size container so AlertAction can move under the text when
|
|
7
9
|
// the alert is narrow. A container cannot size to its content: an Alert inside a
|
|
8
10
|
// flex row needs a width (it is w-full by default), not w-fit.
|
|
9
11
|
// The grid has no column gap: the icon carries its own margin, so the empty
|
|
10
12
|
// action column of a narrow alert takes no space.
|
|
13
|
+
// The v3 banner: a toned alert is a faint tint of its tone. In light mode the
|
|
14
|
+
// fill is 7% tone in the card and the border 14% tone in the border colour; in
|
|
15
|
+
// dark mode the tone sits over transparent (10% fill, 30% border), because
|
|
16
|
+
// mixed into the cool surface it reads grey. The modes switch the
|
|
17
|
+
// --alert-fill and --alert-border properties, not the utilities, so a
|
|
18
|
+
// consumer's bg-* or border-* class wins in both modes. The icon takes the
|
|
19
|
+
// tone's text slot. Warning tints with the brighter warning-indicator, as an
|
|
20
|
+
// amber text colour mixes to brown. The title stays foreground and the
|
|
21
|
+
// description foreground-secondary in every variant, because a muted grey on
|
|
22
|
+
// a tinted fill falls below text contrast.
|
|
23
|
+
// The recipe lives in lib/tint-recipes.ts, which the contrast test in
|
|
24
|
+
// @vendure-io/design-tokens reads.
|
|
25
|
+
const tonedAlert = alertTint
|
|
26
|
+
|
|
27
|
+
// An alert enters once when it mounts: it fades in and moves 4px down into
|
|
28
|
+
// place, 240ms ease-out (@starting-style: nothing runs after it). Reduced motion
|
|
29
|
+
// keeps the fade. Content padding is 12px inline, 10px block.
|
|
11
30
|
const alertVariants = cva(
|
|
12
|
-
"@container/alert grid grid-cols-[minmax(0,1fr)]
|
|
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] [&:has(>svg:not([data-slot=alert-icon]))>[data-slot=alert-icon]]:hidden w-full relative group/alert transition-[opacity,translate] duration-alert-enter ease-out starting:opacity-0 motion-safe:starting:-translate-y-1",
|
|
13
32
|
{
|
|
14
33
|
variants: {
|
|
15
34
|
variant: {
|
|
16
|
-
default: "bg-card text-card-foreground",
|
|
17
|
-
destructive:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
default: "bg-card text-card-foreground *:[svg]:text-current",
|
|
36
|
+
destructive: [
|
|
37
|
+
tonedAlert,
|
|
38
|
+
alertToneVars.destructive,
|
|
39
|
+
],
|
|
40
|
+
warning: [
|
|
41
|
+
tonedAlert,
|
|
42
|
+
alertToneVars.warning,
|
|
43
|
+
],
|
|
44
|
+
info: [tonedAlert, alertToneVars.info],
|
|
23
45
|
},
|
|
24
46
|
},
|
|
25
47
|
defaultVariants: {
|
|
@@ -28,18 +50,43 @@ const alertVariants = cva(
|
|
|
28
50
|
}
|
|
29
51
|
)
|
|
30
52
|
|
|
53
|
+
// A toned variant shows the icon of its tone, the same shape a StatusBadge of
|
|
54
|
+
// that tone shows. The default variant has no tone and no icon of its own.
|
|
55
|
+
const variantIcons = {
|
|
56
|
+
destructive: toneIcons.critical,
|
|
57
|
+
warning: toneIcons.warning,
|
|
58
|
+
info: toneIcons.info,
|
|
59
|
+
} as const
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A toned Alert shows its tone icon unless the caller passes one. An `icon`
|
|
63
|
+
* prop replaces it, and so does an svg child (the older way): the tone icon is
|
|
64
|
+
* then hidden. `icon={false}` shows no icon.
|
|
65
|
+
*/
|
|
31
66
|
function Alert({
|
|
32
67
|
className,
|
|
33
68
|
variant,
|
|
69
|
+
icon,
|
|
70
|
+
children,
|
|
34
71
|
...props
|
|
35
|
-
}: React.ComponentProps<"div"> &
|
|
72
|
+
}: React.ComponentProps<"div"> &
|
|
73
|
+
VariantProps<typeof alertVariants> & {
|
|
74
|
+
/** Replaces the tone icon. `false` or `null` shows no icon. */
|
|
75
|
+
icon?: React.ReactNode
|
|
76
|
+
}) {
|
|
77
|
+
const ToneIcon = variant && variant !== "default" ? variantIcons[variant] : undefined
|
|
78
|
+
const shownIcon =
|
|
79
|
+
icon !== undefined ? icon || null : ToneIcon ? <ToneIcon aria-hidden data-slot="alert-icon" /> : null
|
|
36
80
|
return (
|
|
37
81
|
<div
|
|
38
82
|
data-slot="alert"
|
|
39
83
|
role="alert"
|
|
40
84
|
className={cn(alertVariants({ variant }), className)}
|
|
41
85
|
{...props}
|
|
42
|
-
|
|
86
|
+
>
|
|
87
|
+
{shownIcon}
|
|
88
|
+
{children}
|
|
89
|
+
</div>
|
|
43
90
|
)
|
|
44
91
|
}
|
|
45
92
|
|
|
@@ -48,7 +95,7 @@ function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
48
95
|
<div
|
|
49
96
|
data-slot="alert-title"
|
|
50
97
|
className={cn(
|
|
51
|
-
"[&_a]:hover:text-foreground col-start-1 font-
|
|
98
|
+
"[&_a]:hover:text-foreground col-start-1 font-semibold group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3",
|
|
52
99
|
className
|
|
53
100
|
)}
|
|
54
101
|
{...props}
|
|
@@ -64,7 +111,7 @@ function AlertDescription({
|
|
|
64
111
|
<div
|
|
65
112
|
data-slot="alert-description"
|
|
66
113
|
className={cn(
|
|
67
|
-
"text-
|
|
114
|
+
"text-foreground-secondary [&_a]:hover:text-foreground col-start-1 text-sm text-balance wrap-anywhere group-has-[>svg]/alert:col-start-2 md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_p:not(:last-child)]:mb-4",
|
|
68
115
|
className
|
|
69
116
|
)}
|
|
70
117
|
{...props}
|
|
@@ -72,17 +119,24 @@ function AlertDescription({
|
|
|
72
119
|
)
|
|
73
120
|
}
|
|
74
121
|
|
|
75
|
-
// From a 28rem-wide alert up, the action takes the last grid column
|
|
76
|
-
//
|
|
77
|
-
// centres its content, so a button lines up with
|
|
78
|
-
// overflows into the alert padding instead of making the alert taller.
|
|
79
|
-
//
|
|
122
|
+
// From a 28rem-wide alert up, the action takes the last grid column and spans
|
|
123
|
+
// the text rows, so the text wraps before it. The action box is one text line
|
|
124
|
+
// high and centres its content, so a button lines up with a line of text and
|
|
125
|
+
// overflows into the alert padding instead of making the alert taller.
|
|
126
|
+
// Where the box sits follows the height of the text beside it (100% of the
|
|
127
|
+
// spanned rows):
|
|
128
|
+
// - Up to two lines (a title and one sentence), it is centred on the text.
|
|
129
|
+
// - From three lines (an error block, a next step), it stays on the first line.
|
|
130
|
+
// The step happens at 2.5 lines; `(2.5lh - 100%) * 999` turns it into 0 or a
|
|
131
|
+
// large value, so `min()` picks either the centre offset or 0.
|
|
132
|
+
// The span of 9 rows covers every text row; extra implicit rows are 0 high.
|
|
133
|
+
// In a narrower alert the action moves to its own row under the text.
|
|
80
134
|
function AlertAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
81
135
|
return (
|
|
82
136
|
<div
|
|
83
137
|
data-slot="alert-action"
|
|
84
138
|
className={cn(
|
|
85
|
-
"col-end-[-1] flex flex-wrap content-center items-center gap-2 @max-md/alert:col-start-1 @max-md/alert:mt-2 @max-md/alert:group-has-[>svg]/alert:col-start-2 @md/alert:row-start-1 @md/alert:ms-3 @md/alert:h-lh @md/alert:self-start",
|
|
139
|
+
"col-end-[-1] flex flex-wrap content-center items-center gap-2 @max-md/alert:col-start-1 @max-md/alert:mt-2 @max-md/alert:group-has-[>svg]/alert:col-start-2 @md/alert:relative @md/alert:row-start-1 @md/alert:row-span-9 @md/alert:ms-3 @md/alert:h-lh @md/alert:self-start @md/alert:top-[min((100%_-_1lh)/2,max(0px,(2.5lh_-_100%)*999))]",
|
|
86
140
|
className
|
|
87
141
|
)}
|
|
88
142
|
{...props}
|
|
@@ -8,16 +8,24 @@ import { cn } from "@vendure-io/ui/lib/utils"
|
|
|
8
8
|
function Avatar({
|
|
9
9
|
className,
|
|
10
10
|
size = "default",
|
|
11
|
+
shape = "circle",
|
|
11
12
|
...props
|
|
12
13
|
}: AvatarPrimitive.Root.Props & {
|
|
13
14
|
size?: "default" | "sm" | "lg"
|
|
15
|
+
/**
|
|
16
|
+
* `circle` for a person. `square` for an account, an organisation or a
|
|
17
|
+
* channel: a logo or initials in a rounded square. The shape covers the
|
|
18
|
+
* ring, the image and the fallback, so do not set a radius by hand.
|
|
19
|
+
*/
|
|
20
|
+
shape?: "circle" | "square"
|
|
14
21
|
}) {
|
|
15
22
|
return (
|
|
16
23
|
<AvatarPrimitive.Root
|
|
17
24
|
data-slot="avatar"
|
|
18
25
|
data-size={size}
|
|
26
|
+
data-shape={shape}
|
|
19
27
|
className={cn(
|
|
20
|
-
"after:border-border group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
|
|
28
|
+
"after:border-border group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 data-[shape=square]:rounded-lg data-[shape=square]:after:rounded-lg dark:after:mix-blend-lighten",
|
|
21
29
|
className
|
|
22
30
|
)}
|
|
23
31
|
{...props}
|
|
@@ -30,7 +38,7 @@ function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {
|
|
|
30
38
|
<AvatarPrimitive.Image
|
|
31
39
|
data-slot="avatar-image"
|
|
32
40
|
className={cn(
|
|
33
|
-
"aspect-square size-full rounded-full object-cover",
|
|
41
|
+
"aspect-square size-full rounded-full object-cover group-data-[shape=square]/avatar:rounded-lg",
|
|
34
42
|
className
|
|
35
43
|
)}
|
|
36
44
|
{...props}
|
|
@@ -46,7 +54,7 @@ function AvatarFallback({
|
|
|
46
54
|
<AvatarPrimitive.Fallback
|
|
47
55
|
data-slot="avatar-fallback"
|
|
48
56
|
className={cn(
|
|
49
|
-
"bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs",
|
|
57
|
+
"bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs group-data-[shape=square]/avatar:rounded-lg",
|
|
50
58
|
className
|
|
51
59
|
)}
|
|
52
60
|
{...props}
|
|
@@ -59,7 +67,7 @@ function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
|
|
|
59
67
|
<span
|
|
60
68
|
data-slot="avatar-badge"
|
|
61
69
|
className={cn(
|
|
62
|
-
"bg-primary text-primary-foreground ring-background absolute
|
|
70
|
+
"bg-primary text-primary-foreground ring-background absolute end-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-blend-color ring-2 select-none",
|
|
63
71
|
"group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
|
|
64
72
|
"group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
|
|
65
73
|
"group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
|
|
@@ -2,10 +2,15 @@ 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 "@vendure-io/ui/lib/content-inset"
|
|
5
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
6
7
|
|
|
8
|
+
// `--content-inset` is the distance from the box to the first letter: the
|
|
9
|
+
// padding and the 1px border, plus a leading `data-icon="inline-start"` icon
|
|
10
|
+
// and the gap. A DataTable cell pulls the badge back by it, so the text lines
|
|
11
|
+
// up with the column header.
|
|
7
12
|
const badgeVariants = cva(
|
|
8
|
-
"h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-
|
|
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-4xl 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"],
|
|
9
14
|
{
|
|
10
15
|
variants: {
|
|
11
16
|
variant: {
|
|
@@ -16,7 +21,7 @@ const badgeVariants = cva(
|
|
|
16
21
|
primary: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
17
22
|
brand: "bg-brand text-brand-foreground [a]:hover:bg-brand/80",
|
|
18
23
|
destructive:
|
|
19
|
-
"bg-destructive/10 [a]:hover:bg-destructive/20
|
|
24
|
+
"bg-destructive/10 [a]:hover:bg-destructive/20 text-destructive-subtle-foreground dark:bg-destructive/20",
|
|
20
25
|
outline:
|
|
21
26
|
"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
22
27
|
ghost:
|