@vendure-io/ui 2.1.0 → 3.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/package.json +19 -5
  2. package/src/components/atoms/accordion.tsx +21 -6
  3. package/src/components/atoms/alert-dialog.tsx +31 -6
  4. package/src/components/atoms/alert.tsx +73 -13
  5. package/src/components/atoms/avatar.tsx +1 -1
  6. package/src/components/atoms/badge.tsx +7 -2
  7. package/src/components/atoms/breadcrumb.tsx +137 -4
  8. package/src/components/atoms/button-group.tsx +30 -6
  9. package/src/components/atoms/button.tsx +128 -18
  10. package/src/components/atoms/calendar.tsx +6 -6
  11. package/src/components/atoms/card.tsx +130 -16
  12. package/src/components/atoms/carousel.tsx +16 -9
  13. package/src/components/atoms/chart.tsx +87 -1
  14. package/src/components/atoms/checkbox.tsx +85 -7
  15. package/src/components/atoms/collapsible.tsx +2 -1
  16. package/src/components/atoms/combobox.tsx +147 -21
  17. package/src/components/atoms/command.tsx +414 -12
  18. package/src/components/atoms/context-menu.tsx +28 -23
  19. package/src/components/atoms/dialog.tsx +151 -29
  20. package/src/components/atoms/direction.tsx +23 -2
  21. package/src/components/atoms/drawer.tsx +15 -10
  22. package/src/components/atoms/dropdown-menu.tsx +43 -28
  23. package/src/components/atoms/empty.tsx +4 -0
  24. package/src/components/atoms/field.tsx +41 -15
  25. package/src/components/atoms/hover-card.tsx +61 -8
  26. package/src/components/atoms/input-group.tsx +17 -9
  27. package/src/components/atoms/input-otp.tsx +6 -6
  28. package/src/components/atoms/input.tsx +7 -1
  29. package/src/components/atoms/item.tsx +3 -3
  30. package/src/components/atoms/kbd.tsx +32 -3
  31. package/src/components/atoms/label-swap.tsx +82 -0
  32. package/src/components/atoms/label.tsx +1 -1
  33. package/src/components/atoms/menubar.tsx +28 -26
  34. package/src/components/atoms/native-select.tsx +3 -2
  35. package/src/components/atoms/navigation-menu.tsx +13 -8
  36. package/src/components/atoms/pagination.tsx +2 -2
  37. package/src/components/atoms/popover.tsx +23 -5
  38. package/src/components/atoms/progress.tsx +46 -33
  39. package/src/components/atoms/radio-group.tsx +9 -4
  40. package/src/components/atoms/resizable.tsx +1 -1
  41. package/src/components/atoms/scroll-area.tsx +2 -2
  42. package/src/components/atoms/select.tsx +258 -19
  43. package/src/components/atoms/sheet.tsx +59 -23
  44. package/src/components/atoms/sidebar.tsx +333 -23
  45. package/src/components/atoms/skeleton.tsx +1 -1
  46. package/src/components/atoms/slider.tsx +1 -1
  47. package/src/components/atoms/sonner.tsx +128 -38
  48. package/src/components/atoms/spinner.tsx +1 -1
  49. package/src/components/atoms/switch.tsx +10 -5
  50. package/src/components/atoms/table.tsx +147 -7
  51. package/src/components/atoms/tabs.tsx +3 -3
  52. package/src/components/atoms/textarea.tsx +3 -1
  53. package/src/components/atoms/toggle-group.tsx +4 -2
  54. package/src/components/atoms/toggle.tsx +28 -6
  55. package/src/components/atoms/tooltip.tsx +85 -15
  56. package/src/components/molecules/anonymized-token.tsx +24 -8
  57. package/src/components/molecules/app-shell.tsx +53 -20
  58. package/src/components/molecules/arrow-link.tsx +40 -0
  59. package/src/components/molecules/chip.tsx +2 -2
  60. package/src/components/molecules/code-block.tsx +54 -31
  61. package/src/components/molecules/collapsible-section.tsx +129 -0
  62. package/src/components/molecules/confirm-dialog.tsx +113 -9
  63. package/src/components/molecules/copyable-text.tsx +75 -11
  64. package/src/components/molecules/data-table/data-table-bulk-actions.tsx +32 -4
  65. package/src/components/molecules/data-table/data-table-column-header.tsx +20 -3
  66. package/src/components/molecules/data-table/data-table-filters.tsx +1 -1
  67. package/src/components/molecules/data-table/data-table-helpers.tsx +68 -1
  68. package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
  69. package/src/components/molecules/data-table/data-table-types.tsx +138 -4
  70. package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
  71. package/src/components/molecules/data-table/data-table.tsx +916 -84
  72. package/src/components/molecules/data-table/table-pagination.tsx +2 -2
  73. package/src/components/molecules/date-picker.tsx +13 -7
  74. package/src/components/molecules/date-range-picker.tsx +13 -6
  75. package/src/components/molecules/date-time-picker.tsx +13 -7
  76. package/src/components/molecules/date-time.tsx +8 -1
  77. package/src/components/molecules/direction-link.tsx +130 -0
  78. package/src/components/molecules/elapsed-time.tsx +223 -0
  79. package/src/components/molecules/file-dropzone.tsx +2 -2
  80. package/src/components/molecules/id-chip.tsx +169 -32
  81. package/src/components/molecules/inline-code.tsx +4 -0
  82. package/src/components/molecules/issued-secret.tsx +318 -0
  83. package/src/components/molecules/list-row.tsx +349 -0
  84. package/src/components/molecules/live-indicator.tsx +83 -0
  85. package/src/components/molecules/page-header.tsx +117 -5
  86. package/src/components/molecules/password-input.tsx +2 -2
  87. package/src/components/molecules/relative-time.tsx +85 -56
  88. package/src/components/molecules/search-trigger.tsx +127 -0
  89. package/src/components/molecules/secret-value.tsx +26 -9
  90. package/src/components/molecules/skip-link.tsx +1 -1
  91. package/src/components/molecules/stat-card.tsx +4 -4
  92. package/src/components/molecules/state-views/empty-state.tsx +35 -17
  93. package/src/components/molecules/state-views/error-state.tsx +32 -14
  94. package/src/components/molecules/status-badge.tsx +415 -49
  95. package/src/components/molecules/time-tooltip.tsx +140 -0
  96. package/src/components/molecules/timeline.tsx +246 -0
  97. package/src/components/molecules/visibility-icon.tsx +89 -0
  98. package/src/hooks/use-active-label-size.ts +32 -0
  99. package/src/hooks/use-pinned-height.ts +55 -0
  100. package/src/hooks/use-scrolled.ts +27 -0
  101. package/src/lib/content-inset.ts +17 -0
  102. package/src/lib/control-name.ts +55 -0
  103. package/src/lib/dialog-padding.ts +48 -0
  104. package/src/lib/field-surface.ts +31 -0
  105. package/src/lib/format-elapsed.ts +67 -0
  106. package/src/lib/format-relative.ts +29 -1
  107. package/src/lib/highlight.ts +3 -3
  108. package/src/lib/menu-item.tsx +72 -0
  109. package/src/lib/outline-edge.ts +21 -0
  110. package/src/lib/popup-align.ts +67 -0
  111. package/src/lib/popup-direction.ts +22 -0
  112. package/src/lib/popup-motion.ts +19 -0
  113. package/src/lib/state-dictionary.ts +42 -6
  114. package/src/lib/syntax-colors.ts +8 -0
  115. package/src/lib/tint-recipes.ts +68 -0
  116. package/src/lib/tone-icons.ts +24 -0
  117. package/src/lib/trigger-slot.ts +16 -0
  118. package/src/lib/utils.ts +104 -1
@@ -3,21 +3,43 @@ 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 "@vendure-io/ui/lib/outline-edge"
6
7
  import { Separator } from "@vendure-io/ui/components/atoms/separator"
7
8
 
9
+ // The v3 look: the group draws one outer edge and its children draw none.
10
+ // Children keep a transparent 1px border, so a child's padding-clipped fill
11
+ // never covers the group's inset ring, and a later child's leading border is
12
+ // the 1px divider (a ButtonGroupSeparator replaces it). Only the outer ends
13
+ // are rounded. A group that holds other groups is a layout row only: no edge,
14
+ // no fill, and its child groups keep their own radius. The group sits on
15
+ // shadow-control; its children drop their own.
8
16
  const buttonGroupVariants = cva(
9
- "has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md flex w-fit items-stretch *:focus-visible:z-10 *:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
17
+ "has-[>[data-slot=button-group]]:gap-2 has-[>[data-slot=button-group]]:bg-transparent has-[>[data-slot=button-group]]:inset-ring-0 has-[>[data-slot=button-group]]:shadow-none has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-e-xl flex w-fit items-stretch rounded-xl *:data-slot:border-transparent [&>[data-slot]:not([data-slot=button-group])]:shadow-none *:focus-visible:z-10 *:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 [&>[data-slot=button-group-separator]+[data-slot]]:border-s-transparent! [&>[data-slot=button-group-separator]+[data-slot]]:border-t-transparent!",
10
18
  {
11
19
  variants: {
12
20
  orientation: {
13
21
  horizontal:
14
- "[&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-md! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0 *:data-slot:rounded-r-none",
22
+ "[&>[data-slot]:not([data-slot=button-group])]:rounded-none [&>[data-slot]:not([data-slot]~*)]:rounded-s-xl! [&>[data-slot]:not(:has(~[data-slot]))]:rounded-e-xl!",
15
23
  vertical:
16
- "[&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-md! flex-col [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0 *:data-slot:rounded-b-none",
24
+ "[&>[data-slot]:not([data-slot=button-group])]:rounded-none [&>[data-slot]:not([data-slot]~*)]:rounded-t-xl! [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-xl! flex-col",
25
+ },
26
+ variant: {
27
+ default: ["bg-card inset-ring shadow-control", outlineEdgeRing],
28
+ // A primary split button: a main action and a menu trigger on one
29
+ // primary fill. Use default Buttons inside. Children clip their fill
30
+ // to the border box so a hovered segment fills edge to edge.
31
+ primary: "bg-primary shadow-control *:data-slot:bg-clip-border",
17
32
  },
18
33
  },
34
+ compoundVariants: [
35
+ { orientation: "horizontal", variant: "default", className: "[&>[data-slot]~[data-slot]]:border-s-border" },
36
+ { orientation: "vertical", variant: "default", className: "[&>[data-slot]~[data-slot]]:border-t-border" },
37
+ { orientation: "horizontal", variant: "primary", className: "[&>[data-slot]~[data-slot]]:border-s-primary-foreground/20" },
38
+ { orientation: "vertical", variant: "primary", className: "[&>[data-slot]~[data-slot]]:border-t-primary-foreground/20" },
39
+ ],
19
40
  defaultVariants: {
20
41
  orientation: "horizontal",
42
+ variant: "default",
21
43
  },
22
44
  }
23
45
  )
@@ -25,6 +47,7 @@ const buttonGroupVariants = cva(
25
47
  function ButtonGroup({
26
48
  className,
27
49
  orientation,
50
+ variant,
28
51
  ...props
29
52
  }: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {
30
53
  return (
@@ -32,7 +55,8 @@ function ButtonGroup({
32
55
  role="group"
33
56
  data-slot="button-group"
34
57
  data-orientation={orientation}
35
- className={cn(buttonGroupVariants({ orientation }), className)}
58
+ data-variant={variant}
59
+ className={cn(buttonGroupVariants({ orientation, variant }), className)}
36
60
  {...props}
37
61
  />
38
62
  )
@@ -48,7 +72,7 @@ function ButtonGroupText({
48
72
  props: mergeProps<"div">(
49
73
  {
50
74
  className: cn(
51
- "bg-muted gap-2 rounded-md border px-2.5 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 flex items-center [&_svg]:pointer-events-none",
75
+ "bg-muted gap-2 rounded-xl border px-2.5 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 flex items-center [&_svg]:pointer-events-none",
52
76
  className
53
77
  ),
54
78
  },
@@ -71,7 +95,7 @@ function ButtonGroupSeparator({
71
95
  data-slot="button-group-separator"
72
96
  orientation={orientation}
73
97
  className={cn(
74
- "bg-input relative self-stretch data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto",
98
+ "bg-border relative self-stretch data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto",
75
99
  className
76
100
  )}
77
101
  {...props}
@@ -1,44 +1,126 @@
1
1
  "use client"
2
2
 
3
+ import type * as React from "react"
3
4
  import { Button as ButtonPrimitive } from "@base-ui/react/button"
4
5
  import { cva, type VariantProps } from "class-variance-authority"
5
6
 
7
+ // Relative: `label-swap` is closed in the package exports.
8
+ import { LabelSwap } from "./label-swap.tsx"
9
+ import { contentInsetPull } from "@vendure-io/ui/lib/content-inset"
6
10
  import { cn } from "@vendure-io/ui/lib/utils"
11
+ import { outlineEdge, outlineEdgeHover } from "@vendure-io/ui/lib/outline-edge"
12
+
13
+ // The v3 look: 34px default and 28px sm, the xl radius, 13px medium text.
14
+ // Every size keeps its side padding with or without a `data-icon` icon;
15
+ // default and sm have a 7px gap. Press feedback is a 0.97 scale on :active,
16
+ // on ease-press in 150ms. Base UI's Button never emits data-pressed, so the
17
+ // old data-pressed brightness rule never fired. Fill, border, text colour,
18
+ // opacity (disabled) and the box shadow (aria-invalid ring, shadow-control)
19
+ // ease in 120ms. The focus outline and a width change are instant.
20
+ // Hovers on opaque fills mix in another slot instead of lowering the alpha,
21
+ // so a hovered segment still reads on a filled ButtonGroup. The mixes read
22
+ // the slot variables (--primary, not --color-primary): the --color-* aliases
23
+ // resolve on :root and would ignore a nested .dark scope.
24
+ // A decorative icon next to the label is quieter than the label: 55% at rest,
25
+ // 85% on hover or while its menu is open. Icon-only sizes keep the icon at
26
+ // full strength, and a Spinner (role="status") is never dimmed.
27
+ // A ChevronDown that opens a menu turns 180° while the menu is open, in
28
+ // 220ms on the strong ease-out; with reduced motion it turns at once.
29
+ // Primary, outline, destructive and destructive-outline sit on shadow-control,
30
+ // a 1px lift off the surface; a disabled button drops it. Inside a ButtonGroup the group carries
31
+ // the shadow and the edge, so an outline child keeps its border off on hover.
32
+ // A disabled button that keeps its tab stop and tooltip carries
33
+ // aria-disabled="true", set by Base UI for `disabled focusableWhenDisabled`
34
+ // or by hand. It looks like a native disabled button: half opacity, no
35
+ // shadow, no press scale, and every hover rule is undone while it is
36
+ // aria-disabled (`aria-disabled:hover:` restates the rest fill, text and icon
37
+ // strength), so a consumer's own `hover:` class keeps working on an enabled
38
+ // button. It keeps its pointer events, so its tooltip opens, and shows a
39
+ // not-allowed cursor. Only Base UI's prop also ignores the click.
40
+ // Reduced motion turns the press off with `scale: none`, not `1`: any other
41
+ // value makes the button the containing block of its ::after, so a stretched
42
+ // ::after shrinks to the button mid-press and the click misses. A button that
43
+ // stretches its ::after also takes `active:scale-none` at full motion.
44
+ // Each text size sets `--content-inset`, the distance from the box to the
45
+ // first letter: the padding and the 1px border, plus a leading
46
+ // `data-icon="inline-start"` icon and the gap. A DataTable cell and the sort
47
+ // header pull the button back by it, so the label lines up with the column.
48
+ // Icon-only sizes have no text and set none.
49
+ //
50
+ // The small icon sizes (icon-xs 24px, icon-sm 28px) take a 40 × 40px click
51
+ // area: an invisible ::before, centred on the button. The button stays
52
+ // static: `position` would make it the containing block of a stretched
53
+ // ::after (a chip's copy button, a row link). So the ::before has no insets
54
+ // and sits at its static position, which the button's own centring puts in
55
+ // the middle of the button; its size is in px, not %, for the same reason.
56
+ // The text sizes stay out: their area would have to follow the label width,
57
+ // which needs a percentage, and so a positioned button.
58
+ // Neighbours never share a point. Next to a control (a toolbar, a
59
+ // ButtonGroup, a field and its clear button) the area keeps the button's
60
+ // own width (`--button-box`) and only grows up and down; in a vertical
61
+ // ButtonGroup it keeps the height too. In an InputGroup and in the copy
62
+ // chips it is off: the field and the chip are the click target there.
63
+ const smallIconClickArea = [
64
+ "before:absolute before:size-10",
65
+ "[:is(a,button,input,select,textarea,[role=button])+&]:before:w-(--button-box) [&:has(+:is(a,button,input,select,textarea,[role=button]))]:before:w-(--button-box)",
66
+ "[[data-slot=button-group][data-orientation=vertical]>&]:before:h-(--button-box)",
67
+ "[:is([data-slot=input-group],[data-slot=chip],[data-slot=id-chip],[data-slot=anonymized-token],[data-slot=secret-value],[data-slot=copyable-text])_&]:before:hidden",
68
+ ]
7
69
 
8
70
  const buttonVariants = cva(
9
- "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive rounded-md border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-3 aria-invalid:ring-3 [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all duration-(--transition-duration-fast) ease-(--ease-default) data-pressed:brightness-95 dark:data-pressed:brightness-110 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none cursor-pointer",
71
+ [contentInsetPull, "focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:focus-visible:outline-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive rounded-xl border border-transparent bg-clip-padding text-sm font-medium aria-invalid:ring-3 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] inline-flex items-center justify-center whitespace-nowrap [transition:background-color_var(--transition-duration-quick)_var(--ease-default),border-color_var(--transition-duration-quick)_var(--ease-default),color_var(--transition-duration-quick)_var(--ease-default),opacity_var(--transition-duration-quick)_var(--ease-default),box-shadow_var(--transition-duration-quick)_var(--ease-default),scale_var(--transition-duration-moderate)_var(--ease-press)] active:scale-[0.97] motion-reduce:active:scale-none disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none aria-disabled:opacity-50 aria-disabled:shadow-none aria-disabled:cursor-not-allowed aria-disabled:active:scale-none [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none cursor-pointer [&>svg]:[transition:opacity_var(--transition-duration-moderate)_var(--ease-default),rotate_var(--transition-duration-button-icon-turn)_var(--ease-out)] motion-reduce:[&>svg]:[transition:opacity_var(--transition-duration-moderate)_var(--ease-default)] aria-expanded:[&>svg.lucide-chevron-down]:rotate-180"],
10
72
  {
11
73
  variants: {
12
74
  variant: {
13
- default: "bg-primary text-primary-foreground hover:bg-primary/80",
75
+ default:
76
+ "bg-primary text-primary-foreground shadow-control [--primary-hover:color-mix(in_oklab,var(--primary),var(--background)_14%)] hover:bg-(--primary-hover) aria-expanded:bg-(--primary-hover) aria-disabled:hover:bg-primary",
14
77
  // Identity/marketing CTA only ("Start free trial", "Upgrade to Cloud"):
15
78
  // a deliberate brand moment, not a louder `default` primary. Brand is a
16
79
  // signature, not a wallpaper; see Button guidance before reaching for it.
17
- brand: "bg-brand text-brand-foreground hover:bg-brand/80",
80
+ brand: "bg-brand text-brand-foreground shadow-control hover:bg-brand/80 aria-disabled:hover:bg-brand",
18
81
  outline:
19
- "border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground",
82
+ [outlineEdge, outlineEdgeHover, "bg-card not-dark:[&:not([data-slot=button-group]>*)]:bg-clip-border text-foreground shadow-control hover:bg-[color-mix(in_oklab,var(--card),var(--foreground)_4%)] aria-expanded:bg-[color-mix(in_oklab,var(--card),var(--foreground)_4%)] aria-disabled:hover:bg-card"],
20
83
  secondary:
21
- "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
84
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground aria-disabled:hover:bg-secondary",
22
85
  ghost:
23
- "hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground",
86
+ "text-foreground-secondary hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground aria-disabled:hover:bg-transparent aria-disabled:hover:text-foreground-secondary",
87
+ // Solid: destructive-foreground on destructive holds 4.5:1 in both
88
+ // modes (checked in @vendure-io/design-tokens). Hover mixes toward
89
+ // destructive-900, a shade darker in both modes.
24
90
  destructive:
25
- "bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive-subtle-foreground focus-visible:border-destructive/40 dark:hover:bg-destructive/30",
26
- link: "text-primary underline-offset-4 hover:underline",
91
+ "bg-destructive text-destructive-foreground shadow-control hover:bg-[color-mix(in_oklab,var(--destructive),var(--destructive-900)_15%)] aria-expanded:bg-[color-mix(in_oklab,var(--destructive),var(--destructive-900)_15%)] aria-disabled:hover:bg-destructive",
92
+ // Quiet destructive: the outline button with a red label and icon,
93
+ // for a danger zone at rest. Hover and an open menu tint the fill red
94
+ // (10% destructive into card, an opaque mix, so the label keeps 4.5:1;
95
+ // checked in @vendure-io/design-tokens). The solid `destructive`
96
+ // stays for the confirm inside the dialog.
97
+ "destructive-outline":
98
+ [outlineEdge, outlineEdgeHover, "bg-card not-dark:[&:not([data-slot=button-group]>*)]:bg-clip-border text-destructive-text shadow-control [--destructive-outline-hover:color-mix(in_oklab,var(--card),var(--destructive)_10%)] hover:bg-(--destructive-outline-hover) aria-expanded:bg-(--destructive-outline-hover) aria-disabled:hover:bg-card"],
99
+ link: "text-primary underline-offset-4 hover:underline aria-disabled:hover:no-underline",
27
100
  },
28
101
  size: {
29
102
  default:
30
- "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
31
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
32
- sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
33
- lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
34
- icon: "size-9",
35
- "icon-xs":
36
- "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
37
- "icon-sm":
38
- "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
103
+ "h-8.5 gap-1.75 px-3.25 [--content-inset:calc(var(--spacing)*3.25+1px)] has-data-[icon=inline-start]:[--content-inset:calc(var(--spacing)*9+1px)] [&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85 aria-disabled:hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 aria-expanded:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85",
104
+ xs: "h-6 gap-1 rounded-lg px-2 text-xs [--content-inset:calc(var(--spacing)*2+1px)] has-data-[icon=inline-start]:[--content-inset:calc(var(--spacing)*6+1px)] [&_svg:not([class*='size-'])]:size-3 [&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85 aria-disabled:hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 aria-expanded:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85",
105
+ sm: "h-7 gap-1.75 px-2.5 text-xs [--content-inset:calc(var(--spacing)*2.5+1px)] has-data-[icon=inline-start]:[--content-inset:calc(var(--spacing)*8.25+1px)] [&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85 aria-disabled:hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 aria-expanded:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85",
106
+ lg: "h-10 gap-2 px-4 [--content-inset:calc(var(--spacing)*4+1px)] has-data-[icon=inline-start]:[--content-inset:calc(var(--spacing)*10+1px)] [&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85 aria-disabled:hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-55 aria-expanded:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-85",
107
+ icon: "size-8.5",
108
+ "icon-xs": [
109
+ "size-6 rounded-lg [&_svg:not([class*='size-'])]:size-3 [--button-box:--spacing(6)]",
110
+ smallIconClickArea,
111
+ ],
112
+ "icon-sm": ["size-7 [--button-box:--spacing(7)]", smallIconClickArea],
39
113
  "icon-lg": "size-10",
40
114
  },
41
115
  },
116
+ // The primary fill keeps its icon a little stronger at rest.
117
+ compoundVariants: [
118
+ {
119
+ variant: "default",
120
+ size: ["default", "xs", "sm", "lg"],
121
+ className: "[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-75 hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-75 aria-disabled:hover:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-75 aria-expanded:[&>svg:not([role=status]):not([class*='opacity-'])]:opacity-75",
122
+ },
123
+ ],
42
124
  defaultVariants: {
43
125
  variant: "default",
44
126
  size: "default",
@@ -68,4 +150,32 @@ function Button({
68
150
  )
69
151
  }
70
152
 
71
- export { Button, buttonVariants }
153
+ /**
154
+ * A button label that changes in place, such as "Select" → "Selected". The
155
+ * labels share one grid cell and `active` picks the one that shows; the others
156
+ * are hidden from the accessible name. A label before it leaves 4px upward, a
157
+ * label after it waits 4px below, both faded out with a 2px blur, and the
158
+ * button eases to the width of the active label, clipping the wider one as it
159
+ * goes. The width follows the label, also when a web font loads late. With
160
+ * reduced motion the labels only crossfade and the width changes at once. A
161
+ * label may hold an icon; it keeps full strength (only a direct svg child of
162
+ * the button is dimmed).
163
+ */
164
+ function ButtonLabelSwap(
165
+ props: Omit<React.ComponentProps<"span">, "children"> & {
166
+ labels: readonly React.ReactNode[]
167
+ active: number
168
+ }
169
+ ) {
170
+ return (
171
+ <LabelSwap
172
+ data-slot="button-label-swap"
173
+ timing="button"
174
+ {...props}
175
+ className={cn("gap-[inherit] overflow-x-clip whitespace-nowrap", props.className)}
176
+ labelClassName="inline-flex items-center gap-[inherit]"
177
+ />
178
+ )
179
+ }
180
+
181
+ export { Button, ButtonLabelSwap, buttonVariants }
@@ -103,19 +103,19 @@ function Calendar({
103
103
  defaultClassNames.week_number
104
104
  ),
105
105
  day: cn(
106
- "relative w-full rounded-(--cell-radius) h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius) group/day aspect-square select-none",
106
+ "relative w-full rounded-(--cell-radius) h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-e-(--cell-radius) group/day aspect-square select-none",
107
107
  props.showWeekNumber
108
- ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
109
- : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
108
+ ? "[&:nth-child(2)[data-selected=true]_button]:rounded-s-(--cell-radius)"
109
+ : "[&:first-child[data-selected=true]_button]:rounded-s-(--cell-radius)",
110
110
  defaultClassNames.day
111
111
  ),
112
112
  range_start: cn(
113
- "rounded-l-(--cell-radius) bg-muted relative after:bg-muted after:absolute after:inset-y-0 after:w-4 after:right-0 z-0 isolate",
113
+ "rounded-s-(--cell-radius) bg-muted relative after:bg-muted after:absolute after:inset-y-0 after:w-4 after:end-0 z-0 isolate",
114
114
  defaultClassNames.range_start
115
115
  ),
116
116
  range_middle: cn("rounded-none", defaultClassNames.range_middle),
117
117
  range_end: cn(
118
- "rounded-r-(--cell-radius) bg-muted relative after:bg-muted after:absolute after:inset-y-0 after:w-4 after:left-0 z-0 isolate",
118
+ "rounded-e-(--cell-radius) bg-muted relative after:bg-muted after:absolute after:inset-y-0 after:w-4 after:start-0 z-0 isolate",
119
119
  defaultClassNames.range_end
120
120
  ),
121
121
  today: cn(
@@ -209,7 +209,7 @@ function CalendarDayButton({
209
209
  data-range-end={modifiers.range_end}
210
210
  data-range-middle={modifiers.range_middle}
211
211
  className={cn(
212
- "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-foreground relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) [&>span]:text-xs [&>span]:opacity-70",
212
+ "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground dark:hover:text-foreground relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal tabular-nums group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) [&>span]:text-xs [&>span]:opacity-70",
213
213
  defaultClassNames.day,
214
214
  className
215
215
  )}
@@ -1,24 +1,46 @@
1
1
  import * as React from "react"
2
2
 
3
+ import type { Tone } from "@vendure-io/ui/lib/state-dictionary"
3
4
  import { cn } from "@vendure-io/ui/lib/utils"
4
5
 
5
6
  // The size variant publishes the card's spacing contract as CSS variables
6
- // (--card-px: horizontal content padding, --card-gap: vertical rhythm shared
7
- // by the root padding and the flex gap). Slots consume the variables instead
7
+ // (--card-ps: start padding, --card-px: end padding, --card-gap: vertical
8
+ // rhythm shared by the root padding and the flex gap). The default card starts
9
+ // its content 2px further in than it ends (18px / 16px), the inset the v3 look
10
+ // gives every panel head and row. Slots consume the variables instead
8
11
  // of `group-data-[size=sm]` hooks so that nested cards resolve to the NEAREST
9
12
  // card — a group selector matches any ancestor and leaks the outer card's
10
13
  // size into an inner one.
14
+ // The v3 panel: a 12px radius, a full-strength hairline border and the
15
+ // themed shadow-control, the 1px lift a resting control has.
16
+ // --card-head is the height of a one-line header: 48px, the height of a row,
17
+ // so a header and the rows under it share one rhythm (44px in the sm size).
18
+ // variant="accent" marks the one card that holds the live subject of the
19
+ // page, such as the deployment that is building: the border mixes toward the
20
+ // brand (38% in dark; 30% in light, where the translucent `border` gives the
21
+ // brand more weight in the mix), and a 1.5% brand wash fades out by 55% of
22
+ // the height. The bright brand (brand-500) is the same in both modes. Use it on at most one card per
23
+ // view, and show state inside it with a bare StatusBadge, not a chip.
24
+ const ACCENT_CARD =
25
+ "data-[variant=accent]:border-[color:color-mix(in_oklab,var(--brand-500)_30%,var(--border))] dark:data-[variant=accent]:border-[color:color-mix(in_oklab,var(--brand-500)_38%,var(--border))] data-[variant=accent]:bg-[image:linear-gradient(180deg,color-mix(in_oklab,var(--brand-500)_1.5%,transparent),transparent_55%)]"
26
+
11
27
  function Card({
12
28
  className,
13
29
  size = "default",
30
+ variant = "default",
14
31
  ...props
15
- }: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
32
+ }: React.ComponentProps<"div"> & {
33
+ size?: "default" | "sm"
34
+ variant?: "default" | "accent"
35
+ }) {
16
36
  return (
17
37
  <div
18
38
  data-slot="card"
19
39
  data-size={size}
40
+ data-variant={variant}
20
41
  className={cn(
21
- "bg-card text-card-foreground group/card [--card-gap:--spacing(6)] [--card-px:--spacing(6)] data-[size=sm]:[--card-gap:--spacing(4)] data-[size=sm]:[--card-px:--spacing(4)] flex flex-col gap-(--card-gap) overflow-hidden rounded-xl border border-border/60 py-(--card-gap) text-sm has-[>img:first-child]:pt-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
42
+ "bg-card text-card-foreground group/card [--card-gap:--spacing(4)] [--card-ps:--spacing(4.5)] [--card-px:--spacing(4)] [--card-head:--spacing(12)] data-[size=sm]:[--card-gap:--spacing(3)] data-[size=sm]:[--card-ps:--spacing(3)] data-[size=sm]:[--card-px:--spacing(3)] data-[size=sm]:[--card-head:--spacing(11)] flex flex-col gap-(--card-gap) overflow-hidden rounded-2xl border border-border shadow-control py-(--card-gap) text-sm has-[>img:first-child]:pt-0 *:[img:first-child]:rounded-t-2xl *:[img:last-child]:rounded-b-2xl",
43
+ ACCENT_CARD,
22
44
  className
23
45
  )}
24
46
  {...props}
@@ -26,15 +48,27 @@ function Card({
26
48
  )
27
49
  }
28
50
 
29
- // Band dividers (consumer-applied border-b / border-t on header/footer) render
30
- // at row-separator strength (border/50) so the card outline (border/60) stays
31
- // the strongest structural line.
51
+ // A one-line header (only a CardTitle and an optional CardAction) is one
52
+ // --card-head row: 48px, 44px in the sm size, measured from the card edge to
53
+ // the next content (or to the border-b). The header keeps the card padding
54
+ // above it and the card gap below it. Its children take a negative block
55
+ // margin so their line fits between the two, and the header drops its row
56
+ // gap (the action spans an empty second row). Nothing moves out of the
57
+ // header's box, so a card with its own padding or gap keeps its layout, and a
58
+ // title that wraps makes the header taller. A header with a description,
59
+ // controls or chips keeps the padded layout.
60
+ const ONE_LINE_HEADER =
61
+ "[&:has(>[data-slot=card-title]):not(:has(>:not([data-slot=card-title],[data-slot=card-action])))]:gap-y-0 [&:has(>[data-slot=card-title]):not(:has(>:not([data-slot=card-title],[data-slot=card-action])))]:*:my-[calc((var(--card-head)-2*var(--card-gap)-1lh)/2)] [&:has(>[data-slot=card-title]):not(:has(>:not([data-slot=card-title],[data-slot=card-action])))]:[&.border-b]:*:my-[calc((var(--card-head)-2*var(--card-gap)-1px-1lh)/2)]"
62
+
63
+ // Band dividers (consumer-applied border-b / border-t on header/footer) use the
64
+ // same hairline as the card outline and the CardRows separators.
32
65
  function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
33
66
  return (
34
67
  <div
35
68
  data-slot="card-header"
36
69
  className={cn(
37
- "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-px) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:border-border/50 [.border-b]:pb-(--card-gap)",
70
+ "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-2xl ps-(--card-ps) pe-(--card-px) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-gap)",
71
+ ONE_LINE_HEADER,
38
72
  className
39
73
  )}
40
74
  {...props}
@@ -42,12 +76,49 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
42
76
  )
43
77
  }
44
78
 
79
+ // The card-title role at body size: 13px/600 in foreground-secondary, quieter
80
+ // than the data it labels. Spelled out because tailwind-merge would drop the
81
+ // `text-style-card-title` utility next to `text-sm`. A title that holds a
82
+ // CardCount lays out as a row: the gap is the 10px to the count, and the JSX
83
+ // space before the count no longer adds to it.
45
84
  function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
46
85
  return (
47
86
  <div
48
87
  data-slot="card-title"
49
88
  className={cn(
50
- "text-style-card-title group-data-[size=sm]/card:text-sm",
89
+ "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",
90
+ className
91
+ )}
92
+ {...props}
93
+ />
94
+ )
95
+ }
96
+
97
+ // A count beside the title, such as the number of rows in the card. Place it
98
+ // inside CardTitle so it sits on the title line, 10px after the title. The
99
+ // count is muted; `tone` colours a count that needs action, such as rows
100
+ // waiting on the user (warning) or failed pushes (critical). The tones are
101
+ // glossary tones; `critical` renders with the `destructive` slots. The card
102
+ // itself stays neutral.
103
+ type CardCountTone = Extract<Tone, "neutral" | "warning" | "critical">
104
+
105
+ const cardCountTone: Record<CardCountTone, string> = {
106
+ neutral: "text-muted-foreground",
107
+ warning: "text-warning-text",
108
+ critical: "text-destructive-text",
109
+ }
110
+
111
+ function CardCount({
112
+ className,
113
+ tone = "neutral",
114
+ ...props
115
+ }: React.ComponentProps<"span"> & { tone?: CardCountTone }) {
116
+ return (
117
+ <span
118
+ data-slot="card-count"
119
+ className={cn(
120
+ cardCountTone[tone],
121
+ "text-xs font-semibold tabular-nums",
51
122
  className
52
123
  )}
53
124
  {...props}
@@ -59,18 +130,21 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
59
130
  return (
60
131
  <div
61
132
  data-slot="card-description"
62
- className={cn("text-muted-foreground text-sm", className)}
133
+ className={cn("text-foreground-secondary text-sm", className)}
63
134
  {...props}
64
135
  />
65
136
  )
66
137
  }
67
138
 
139
+ // The action box is one title line high and centres its content, so a small
140
+ // button lines up with the title and overflows into the card padding instead
141
+ // of making the header row taller.
68
142
  function CardAction({ className, ...props }: React.ComponentProps<"div">) {
69
143
  return (
70
144
  <div
71
145
  data-slot="card-action"
72
146
  className={cn(
73
- "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
147
+ "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",
74
148
  className
75
149
  )}
76
150
  {...props}
@@ -82,7 +156,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
82
156
  return (
83
157
  <div
84
158
  data-slot="card-content"
85
- className={cn("px-(--card-px)", className)}
159
+ className={cn("ps-(--card-ps) pe-(--card-px)", className)}
86
160
  {...props}
87
161
  />
88
162
  )
@@ -98,14 +172,50 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
98
172
  // must carry its band border (border-b / border-t), otherwise the table
99
173
  // sits directly against the band's content.
100
174
  // - The edge-cell selector ((0,2,1)) out-specifies a plain padding utility on
101
- // the cell ((0,1,0)): a `pl-*`/`pr-*` on a first/last cell silently loses —
102
- // override with the important modifier (`pl-0!`) when a cell must opt out.
175
+ // the cell ((0,1,0)): a `ps-*`/`pe-*` on a first/last cell silently loses —
176
+ // override with the important modifier (`ps-0!`) when a cell must opt out.
103
177
  function CardTable({ className, ...props }: React.ComponentProps<"div">) {
104
178
  return (
105
179
  <div
106
180
  data-slot="card-table"
107
181
  className={cn(
108
- "-my-(--card-gap) [&_tr>*:first-child]:pl-(--card-px) [&_tr>*:last-child]:pr-(--card-px)",
182
+ "-my-(--card-gap) [&_tr>*:first-child]:ps-[calc(var(--card-ps)+var(--column-indent,0px))] [&_tr>*:last-child]:pe-(--card-px)",
183
+ className
184
+ )}
185
+ {...props}
186
+ />
187
+ )
188
+ }
189
+
190
+ // Hosts a list of rows edge to edge, for cards whose body is a list. Each row
191
+ // draws its own top border, so the first row's border divides it from the
192
+ // header: do not add border-b to a CardHeader above CardRows. The negative
193
+ // bottom margin cancels the card padding (or the gap before a footer, which
194
+ // then must carry its band border-t). As the first child, CardRows also
195
+ // cancels the top padding and drops the first row's border. The card clips
196
+ // its children, and the last row takes the bottom radius so its hover fill
197
+ // and focus ring follow the corner.
198
+ function CardRows({ className, ...props }: React.ComponentProps<"div">) {
199
+ return (
200
+ <div
201
+ data-slot="card-rows"
202
+ className={cn(
203
+ "-mb-(--card-gap) first:-mt-(--card-gap) *:last:rounded-b-2xl [&:first-child>*:first-child]:border-t-0",
204
+ className
205
+ )}
206
+ {...props}
207
+ />
208
+ )
209
+ }
210
+
211
+ // One row of CardRows: a 48px minimum height, a top border and the card's
212
+ // horizontal padding, so row content lines up with the header.
213
+ function CardRow({ className, ...props }: React.ComponentProps<"div">) {
214
+ return (
215
+ <div
216
+ data-slot="card-row"
217
+ className={cn(
218
+ "flex min-h-12 items-center gap-3 border-t ps-(--card-ps) pe-(--card-px) py-2",
109
219
  className
110
220
  )}
111
221
  {...props}
@@ -118,7 +228,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
118
228
  <div
119
229
  data-slot="card-footer"
120
230
  className={cn(
121
- "flex items-center rounded-b-xl px-(--card-px) [.border-t]:border-border/50 [.border-t]:pt-(--card-gap)",
231
+ "flex items-center rounded-b-2xl ps-(--card-ps) pe-(--card-px) [.border-t]:pt-(--card-gap)",
122
232
  className
123
233
  )}
124
234
  {...props}
@@ -131,8 +241,12 @@ export {
131
241
  CardHeader,
132
242
  CardFooter,
133
243
  CardTitle,
244
+ CardCount,
134
245
  CardAction,
135
246
  CardDescription,
136
247
  CardContent,
137
248
  CardTable,
249
+ CardRows,
250
+ CardRow,
251
+ type CardCountTone,
138
252
  }