@nswds/ui 7.0.2 → 8.1.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 (42) hide show
  1. package/dist/components/badge.d.ts +1 -1
  2. package/dist/components/button-group.d.ts +104 -5
  3. package/dist/components/button-group.js +166 -11
  4. package/dist/components/button-group.js.map +1 -1
  5. package/dist/components/button.d.ts +46 -7
  6. package/dist/components/button.js +271 -25
  7. package/dist/components/button.js.map +1 -1
  8. package/dist/components/callout.d.ts +1 -1
  9. package/dist/components/combobox.js +3 -2
  10. package/dist/components/combobox.js.map +1 -1
  11. package/dist/components/drawer.d.ts +1 -1
  12. package/dist/components/drawer.js +3 -2
  13. package/dist/components/drawer.js.map +1 -1
  14. package/dist/components/header.d.ts +1 -1
  15. package/dist/components/hover-card.js +3 -2
  16. package/dist/components/hover-card.js.map +1 -1
  17. package/dist/components/link.d.ts +1 -1
  18. package/dist/components/masthead.d.ts +1 -1
  19. package/dist/components/native-select.d.ts +9 -5
  20. package/dist/components/native-select.js +32 -6
  21. package/dist/components/native-select.js.map +1 -1
  22. package/dist/components/navigation-menu.d.ts +1 -1
  23. package/dist/components/navigation-menu.js +6 -4
  24. package/dist/components/navigation-menu.js.map +1 -1
  25. package/dist/components/popover.js +3 -2
  26. package/dist/components/popover.js.map +1 -1
  27. package/dist/components/select.d.ts +8 -4
  28. package/dist/components/select.js +36 -12
  29. package/dist/components/select.js.map +1 -1
  30. package/dist/components/sheet.js +3 -2
  31. package/dist/components/sheet.js.map +1 -1
  32. package/dist/components/site-search.js +3 -2
  33. package/dist/components/site-search.js.map +1 -1
  34. package/dist/components/skip-link.d.ts +1 -1
  35. package/dist/components/tooltip.js +3 -2
  36. package/dist/components/tooltip.js.map +1 -1
  37. package/dist/index.d.ts +5 -4
  38. package/dist/lib/button-group-context.d.ts +46 -0
  39. package/dist/lib/button-group-context.js +12 -0
  40. package/dist/lib/button-group-context.js.map +1 -0
  41. package/dist/styles.css +1 -1
  42. package/package.json +2 -1
@@ -6,7 +6,7 @@ import { Link } from './link.js';
6
6
 
7
7
  declare const badgeVariants: (props?: ({
8
8
  variant?: "solid" | "soft" | "surface" | "outline" | null | undefined;
9
- color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "primary/grey" | "light" | "primary/white" | null | undefined;
9
+ color?: "primary/grey" | "light" | "primary/white" | "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | null | undefined;
11
11
  } & class_variance_authority_types.ClassProp) | undefined) => string;
12
12
  type BadgeProps = VariantProps<typeof badgeVariants> & React__default.ComponentPropsWithoutRef<'span'> & {
@@ -1,15 +1,114 @@
1
- import * as React$1 from 'react';
2
1
  import * as class_variance_authority_types from 'class-variance-authority/types';
3
2
  import { useRender } from '@base-ui/react/use-render';
4
3
  import { VariantProps } from 'class-variance-authority';
4
+ import * as React from 'react';
5
+ export { ButtonGroupBoundary } from '../lib/button-group-context.js';
6
+ import { ButtonProps } from './button.js';
5
7
  import { Separator } from './separator.js';
8
+ import '@base-ui/react/button';
9
+ import './link.js';
6
10
  import '@base-ui/react/separator';
7
11
 
12
+ /**
13
+ * The group owns the boundary. It draws the frame or the band, the hairline
14
+ * between segments and the 4px corners, and it clips its children to that
15
+ * radius — so a segment never computes a corner of its own. The segments are
16
+ * ordinary Buttons: they read `ButtonGroupContext` and give up the chrome the
17
+ * group now draws (see `styles.segment` in button.tsx).
18
+ *
19
+ * This replaces a wrapper that collapsed borders through `[data-slot]` child
20
+ * selectors copied from shadcn. Button never emitted `data-slot`, so none of
21
+ * those rules matched: every Button kept its own 2px outline and 4px corners,
22
+ * and neighbours met with a 4px doubled border.
23
+ *
24
+ * Every colour is Button's own `--btn-fill` / `--btn-bg` / `--btn-text` pair,
25
+ * applied to the group by `buttonColorVariants`, so a group's `color` means
26
+ * what a Button's does: the ink flips for dark mode the same way, and on a
27
+ * soft or surface band it steps to the darker ink those tints need the same
28
+ * way (`styles.tintInk` in button.tsx). The segments learn they sit on that
29
+ * tint from the `band` the context carries, and step their own colour's ink,
30
+ * so a segment naming another colour keeps it. Hairlines take the text
31
+ * colour, per the masterbrand's line system. These classes therefore only
32
+ * paint on an element that also carries `buttonColorVariants` —
33
+ * `ring-(--btn-bg)` is invalid without it — so a consumer extending the
34
+ * group's styling applies the two together, as `ButtonGroup` does.
35
+ *
36
+ * Two kinds of rule reach a segment. What depends on the segment's
37
+ * NEIGHBOURS — dividers, seams, the text cell — lives here and uses the CHILD
38
+ * combinator (`&>`) and sibling combinators, so it needs the segments to be
39
+ * direct children. What depends only on the BAND — the re-ink on a solid
40
+ * band, the frame-revealing `bg-clip-padding` — lives on the segment itself,
41
+ * keyed on the `data-band` the group tells it through context, so it holds
42
+ * for a segment rendered through a trigger's `render` prop or wrapped in a
43
+ * span. Never a descendant rule: a group is not meant to nest, but if one
44
+ * ever does, a descendant rule from the outer band would re-ink the inner
45
+ * group's segments.
46
+ */
8
47
  declare const buttonGroupVariants: (props?: ({
48
+ variant?: "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
9
49
  orientation?: "horizontal" | "vertical" | null | undefined;
10
50
  } & class_variance_authority_types.ClassProp) | undefined) => string;
11
- declare function ButtonGroup({ className, orientation, ...props }: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>): React$1.JSX.Element;
12
- declare function ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
13
- declare function ButtonGroupSeparator({ className, orientation, ...props }: React.ComponentProps<typeof Separator>): React$1.JSX.Element;
51
+ /** The group variants a ButtonGroup can paint. `link` has no group form. */
52
+ type ButtonGroupVariant = NonNullable<VariantProps<typeof buttonGroupVariants>['variant']>;
53
+ type ButtonGroupProps = Omit<React.ComponentProps<'div'>, 'color'> & VariantProps<typeof buttonGroupVariants> & {
54
+ /**
55
+ * Colour token, with Button's meaning: `primary` by default. Sets the
56
+ * ink the frame, band and dividers are drawn in, and the default colour
57
+ * of every segment.
58
+ */
59
+ color?: ButtonProps['color'];
60
+ /**
61
+ * Scale step, with Button's meaning. The default size of every segment.
62
+ * `icon` is not offered: it is a 40px chrome square, and the group clips
63
+ * to its own box, so the 44px touch expansion Button adds on a coarse
64
+ * pointer would be cut off. A segment that asks for `icon` anyway renders
65
+ * as `iconOnly` at the group's own step, so it lines up with the segments
66
+ * beside it.
67
+ */
68
+ size?: Exclude<ButtonProps['size'], 'icon'>;
69
+ };
70
+ /**
71
+ * Joins a row (or column) of Buttons into one control. Takes Button's variant
72
+ * family — `outline` (the default), `solid`, `soft`, `surface`, `ghost` — and
73
+ * its colour tokens and size steps, and hands them to its segments as
74
+ * defaults. A segment may name its own emphasis: a `solid` Save inside an
75
+ * outline group is the primary action of that row.
76
+ *
77
+ * Children are Buttons (or ButtonLinks), `ButtonGroupText` for an inline
78
+ * label, and `ButtonGroupSeparator` for a semantic boundary, as DIRECT
79
+ * children: the hairlines between segments are drawn on the segments' shared
80
+ * edges, so a segment wrapped in another element (a span holding a tooltip
81
+ * on a disabled segment, say) keeps its label and its band treatment but
82
+ * loses the hairlines it shares with its neighbours — the one before it, and
83
+ * the one after it too when the wrapped segment is the first child. It is a group of buttons, not a general
84
+ * control frame — an input or select with an attached action is InputGroup's
85
+ * job — and groups do not nest.
86
+ *
87
+ * A popup opened from a segment (a split button's menu) renders through a
88
+ * portal, which React context follows. Every popup in this package resets the
89
+ * group context at its portal, so the Buttons inside render normally; wrap
90
+ * the contents of an overlay from another library in `ButtonGroupBoundary`
91
+ * to get the same. Without that reset a Button inside the popup renders as a
92
+ * segment of the group it was opened from, and on a solid band that means its
93
+ * label takes the band's colour — white on the popup's own surface.
94
+ */
95
+ declare function ButtonGroup({ className, variant, orientation, color, size, children, ...props }: ButtonGroupProps): React.JSX.Element;
96
+ /**
97
+ * An inline label between segments — a unit, a count, a mode. Sits at the
98
+ * body size (16px), never smaller: it shares a line with 16px button labels,
99
+ * so anything below that reads as fine print. Semibold, the weight the
100
+ * InputGroup addon uses for the same job. On a framed or ghost group it sits
101
+ * on the sunken surface so it reads as chrome rather than as a button; on a
102
+ * band it sits on the band, and a solid band gives it the band's label colour
103
+ * at the label weight (see `buttonGroupVariants`).
104
+ */
105
+ declare function ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
106
+ /**
107
+ * A semantic boundary between segments. Every segment is already divided by
108
+ * a hairline, so the separator draws nothing of its own — it exists for
109
+ * assistive technology, which hears it as a region boundary, and it follows
110
+ * the group's orientation unless told otherwise.
111
+ */
112
+ declare function ButtonGroupSeparator({ className, orientation, ...props }: React.ComponentProps<typeof Separator>): React.JSX.Element;
14
113
 
15
- export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants };
114
+ export { ButtonGroup, type ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, type ButtonGroupVariant, buttonGroupVariants };
@@ -1,37 +1,184 @@
1
+ "use client"
1
2
  import { jsx } from 'react/jsx-runtime';
2
3
  import { mergeProps } from '@base-ui/react/merge-props';
3
4
  import { useRender } from '@base-ui/react/use-render';
4
5
  import { cva } from 'class-variance-authority';
6
+ import * as React from 'react';
7
+ import { ButtonGroupContext } from '../lib/button-group-context.js';
8
+ export { ButtonGroupBoundary } from '../lib/button-group-context.js';
5
9
  import { cn } from '../lib/utils.js';
10
+ import { buttonColorVariants } from './button.js';
6
11
  import { Separator } from './separator.js';
7
12
 
13
+ const DEFAULT_GROUP_VARIANT = "outline";
14
+ const DEFAULT_GROUP_ORIENTATION = "horizontal";
8
15
  const buttonGroupVariants = cva(
9
- "flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-e-sm [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
16
+ [
17
+ "isolate inline-flex w-fit items-stretch overflow-hidden rounded-sm",
18
+ // `items-stretch` above is what makes every segment the same size across
19
+ // the group's cross axis — except an icon-only one, which `styles.iconOnly`
20
+ // squares with `size-(--btn-h)`. A definite cross size is precisely the
21
+ // case flexbox does NOT stretch (CSS Flexbox §9.4: stretch applies only
22
+ // when the cross-size property computes to `auto`), so the square holds its
23
+ // 52px whatever the segments beside it do. In a column that is every mixed
24
+ // group: a 52px square in a 135px band, with a void beside it and the
25
+ // hairline above it stopping a third of the way across. In a row it needs a
26
+ // label to wrap first, which `min-h-(--btn-h)` on the button explicitly
27
+ // allows — a floor, not a fixed height — and then the square sits at the
28
+ // top of a 136px row.
29
+ //
30
+ // So the group releases the cross dimension and lets `items-stretch` do its
31
+ // work, keeping the main one: the square stays a square whenever its
32
+ // neighbours are one line tall, and grows with them when they are not.
33
+ // Keyed on the group's own orientation, so neither rule is a bare utility
34
+ // the other has to override, and reached through the child combinator, so
35
+ // a nested icon button (inside a popup opened from a segment, say) is not
36
+ // touched. (0,3,0) against `size-(--btn-h)`'s (0,1,0).
37
+ "data-[orientation=horizontal]:[&>[data-slot][data-icon-only]]:h-auto",
38
+ "data-[orientation=vertical]:[&>[data-slot][data-icon-only]]:w-auto",
39
+ // The band's label colour, resolved HERE from the group's own colour
40
+ // token and inherited by every segment as a computed value. A segment on
41
+ // a solid band re-points its ink to this (see `styles.segment` in
42
+ // button.tsx); publishing it from the group is what stops a segment that
43
+ // names its own `color` from reading its own `--btn-text` instead.
44
+ "[--group-label:var(--btn-text)]",
45
+ // Dividers. A Button or ButtonGroupText carries `data-slot` and a 1px
46
+ // transparent border, so the divider is that border recoloured on the
47
+ // shared edge: no extra pixel, and the group's outer box stays exactly
48
+ // one button tall. (ButtonGroupSeparator carries `data-slot` too but no
49
+ // border and no size, so the hairline beside it is drawn by the segment
50
+ // after it.) Keyed on orientation both ways so neither rule is a bare
51
+ // utility the other overrides, and written as `[data-slot]~[data-slot]`
52
+ // for specificity: Button's `dark:border-white/5` is a border-color
53
+ // SHORTHAND at (0,2,0), and this longhand only beats it by specificity,
54
+ // never by emission order (AGENTS.md §4, the two-build cascade).
55
+ //
56
+ // `loading` reaches these rules as well as `disabled`: Button derives
57
+ // `disabled` from either, so a busy segment is a disabled one here. The
58
+ // boundary therefore moves by a pixel when a request starts, which is the
59
+ // contract holding rather than breaking — the alternative is a
60
+ // half-strength hairline beside an enabled control for as long as the
61
+ // request runs. `Segment Props` pins it.
62
+ //
63
+ // A disabled segment fades itself with `opacity-50`, and a divider drawn
64
+ // on its own leading edge would fade with it — leaving one weak hairline
65
+ // in an otherwise full-strength row, right where the eye reads the join.
66
+ // So the boundary before a disabled segment is drawn on the trailing edge
67
+ // of the segment BEFORE it instead, and the disabled segment's own
68
+ // leading edge stays transparent. A separator between the two has no edge
69
+ // to paint, so the rule also looks through one.
70
+ //
71
+ // The one hairline this does NOT lift out of the fade is the one BETWEEN
72
+ // two adjacent disabled segments: its only available edge belongs to a
73
+ // disabled element either way, so it renders at 50% like the pair it
74
+ // divides. That is the coherent reading — the whole run is unavailable,
75
+ // and a full-strength line inside it would draw more attention than the
76
+ // controls do — and lifting it would mean moving dividers off the
77
+ // segments entirely, onto a layer the group owns. `Disabled` renders the
78
+ // case and pins where each edge lands.
79
+ "data-[orientation=horizontal]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-s-(--divider)",
80
+ "data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-e-(--divider)",
81
+ "data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-e-(--divider)",
82
+ "data-[orientation=vertical]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-t-(--divider)",
83
+ "data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-b-(--divider)",
84
+ "data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-b-(--divider)",
85
+ // Two solid segments side by side (a split button): the ink divider would
86
+ // vanish on the fill, so the seam is a reversed hairline in the label
87
+ // colour. Above the general divider on specificity, with the same
88
+ // disabled handling, and again looking through a separator.
89
+ "data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30",
90
+ "data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30",
91
+ "data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30",
92
+ "data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30",
93
+ "data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30",
94
+ "data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30",
95
+ "data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30",
96
+ "data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30"
97
+ ],
10
98
  {
11
99
  variants: {
100
+ variant: {
101
+ // A 1px hairline frame in the ink, drawn as an inset ring so it adds
102
+ // no height: the group is exactly as tall as a lone Button beside it.
103
+ // No fill of its own, like Button's outline: the surface shows
104
+ // through, so a `white` outline group on a dark panel stays a frame.
105
+ // Forced-colours mode discards box shadows, so the frame is restated
106
+ // there as an outline, which that mode keeps and recolours. The text
107
+ // cell stops its background at the padding box so the frame shows
108
+ // through its transparent border.
109
+ outline: [
110
+ "ring-1 ring-(--btn-bg) [--divider:var(--btn-bg)] ring-inset",
111
+ "forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1",
112
+ "[&>[data-slot=button-group-text]]:bg-clip-padding"
113
+ ],
114
+ // The band. Segments re-ink themselves on it (see `styles.segment` in
115
+ // button.tsx); the text cell sits on the band in its label colour, at
116
+ // the label weight so it reads as a label rather than as another
117
+ // button.
118
+ solid: [
119
+ "bg-(--btn-fill) [--divider:color-mix(in_oklab,var(--btn-text)_30%,transparent)]",
120
+ "[&>[data-slot=button-group-text]]:bg-transparent [&>[data-slot=button-group-text]]:font-medium [&>[data-slot=button-group-text]]:text-(--btn-text)"
121
+ ],
122
+ // Button's soft pair — ink at 10%, 20% in dark — as a band. The text
123
+ // cell sits on the band.
124
+ soft: "bg-(--btn-bg)/10 [--divider:color-mix(in_oklab,var(--btn-bg)_30%,transparent)] dark:bg-(--btn-bg)/20 [&>[data-slot=button-group-text]]:bg-transparent",
125
+ // Button's surface pair: ink at 5% inside an ink/50 hairline, restated
126
+ // as an outline for forced colours like the outline frame.
127
+ surface: [
128
+ "bg-(--btn-bg)/5 ring-1 ring-(--btn-bg)/50 [--divider:color-mix(in_oklab,var(--btn-bg)_50%,transparent)] ring-inset dark:bg-(--btn-bg)/30",
129
+ "forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1",
130
+ "[&>[data-slot=button-group-text]]:bg-transparent"
131
+ ],
132
+ // No frame, no fill: only the hairlines between segments remain.
133
+ ghost: "[--divider:var(--btn-bg)]"
134
+ },
12
135
  orientation: {
13
- horizontal: "*:data-slot:rounded-e-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-e-sm! [&>[data-slot]~[data-slot]]:rounded-s-none [&>[data-slot]~[data-slot]]:border-s-0",
14
- vertical: "flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-sm! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0"
136
+ horizontal: "flex-row",
137
+ vertical: "flex-col"
15
138
  }
16
139
  },
17
140
  defaultVariants: {
18
- orientation: "horizontal"
141
+ variant: DEFAULT_GROUP_VARIANT,
142
+ orientation: DEFAULT_GROUP_ORIENTATION
19
143
  }
20
144
  }
21
145
  );
22
146
  function ButtonGroup({
23
147
  className,
148
+ variant,
24
149
  orientation,
150
+ color,
151
+ size,
152
+ children,
25
153
  ...props
26
154
  }) {
155
+ const resolvedVariant = variant ?? DEFAULT_GROUP_VARIANT;
156
+ const resolvedOrientation = orientation ?? DEFAULT_GROUP_ORIENTATION;
157
+ const resolvedColor = color ?? void 0;
158
+ const resolvedSize = size ?? void 0;
159
+ const context = React.useMemo(
160
+ () => ({
161
+ band: resolvedVariant,
162
+ color: resolvedColor,
163
+ size: resolvedSize,
164
+ orientation: resolvedOrientation
165
+ }),
166
+ [resolvedVariant, resolvedColor, resolvedSize, resolvedOrientation]
167
+ );
27
168
  return /* @__PURE__ */ jsx(
28
169
  "div",
29
170
  {
30
171
  role: "group",
31
172
  "data-slot": "button-group",
32
- "data-orientation": orientation,
33
- className: cn(buttonGroupVariants({ orientation }), className),
34
- ...props
173
+ className: cn(
174
+ buttonColorVariants({ color: resolvedColor, variant: resolvedVariant }),
175
+ buttonGroupVariants({ variant: resolvedVariant, orientation: resolvedOrientation }),
176
+ className
177
+ ),
178
+ ...props,
179
+ "data-variant": resolvedVariant,
180
+ "data-orientation": resolvedOrientation,
181
+ children: /* @__PURE__ */ jsx(ButtonGroupContext.Provider, { value: context, children })
35
182
  }
36
183
  );
37
184
  }
@@ -41,7 +188,10 @@ function ButtonGroupText({ className, render, ...props }) {
41
188
  props: mergeProps(
42
189
  {
43
190
  className: cn(
44
- "flex items-center gap-2 rounded-sm border bg-muted px-2.5 text-xs/relaxed font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
191
+ // The transparent border is what the group's divider recolours.
192
+ "flex items-center gap-2 border border-transparent bg-(--surface-sunken) px-4 text-base font-semibold text-muted-foreground select-none",
193
+ // A glyph beside the text matches Button's 24px label glyph.
194
+ "[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-6",
45
195
  className
46
196
  )
47
197
  },
@@ -55,16 +205,21 @@ function ButtonGroupText({ className, render, ...props }) {
55
205
  }
56
206
  function ButtonGroupSeparator({
57
207
  className,
58
- orientation = "vertical",
208
+ orientation,
59
209
  ...props
60
210
  }) {
211
+ const group = React.useContext(ButtonGroupContext);
212
+ const resolvedOrientation = orientation ?? (group?.orientation === "vertical" ? "horizontal" : "vertical");
61
213
  return /* @__PURE__ */ jsx(
62
214
  Separator,
63
215
  {
64
216
  "data-slot": "button-group-separator",
65
- orientation,
217
+ orientation: resolvedOrientation,
66
218
  className: cn(
67
- "relative self-stretch bg-input data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto",
219
+ // Zero-size on its own axis and transparent: the hairline beside it
220
+ // is the group's divider, not this element. Same variant keys as the
221
+ // primitive's own sizing so tailwind-merge resolves them here.
222
+ "self-stretch bg-transparent data-[orientation=horizontal]:h-0 data-[orientation=vertical]:w-0",
68
223
  className
69
224
  ),
70
225
  ...props
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/button-group.tsx"],"names":[],"mappings":";;;;;;;AAOA,MAAM,mBAAA,GAAsB,GAAA;AAAA,EAC1B,0RAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,WAAA,EAAa;AAAA,QACX,UAAA,EACE,oKAAA;AAAA,QACF,QAAA,EACE;AAAA;AACJ,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,WAAA,EAAa;AAAA;AACf;AAEJ;AAEA,SAAS,WAAA,CAAY;AAAA,EACnB,SAAA;AAAA,EACA,WAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA2E;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,OAAA;AAAA,MACL,WAAA,EAAU,cAAA;AAAA,MACV,kBAAA,EAAkB,WAAA;AAAA,MAClB,WAAW,EAAA,CAAG,mBAAA,CAAoB,EAAE,WAAA,EAAa,GAAG,SAAS,CAAA;AAAA,MAC5D,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,gBAAgB,EAAE,SAAA,EAAW,MAAA,EAAQ,GAAG,OAAM,EAAoC;AACzF,EAAA,OAAO,SAAA,CAAU;AAAA,IACf,cAAA,EAAgB,KAAA;AAAA,IAChB,KAAA,EAAO,UAAA;AAAA,MACL;AAAA,QACE,SAAA,EAAW,EAAA;AAAA,UACT,wJAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA,MACA;AAAA,KACF;AAAA,IACA,MAAA;AAAA,IACA,KAAA,EAAO;AAAA,MACL,IAAA,EAAM;AAAA;AACR,GACD,CAAA;AACH;AAEA,SAAS,oBAAA,CAAqB;AAAA,EAC5B,SAAA;AAAA,EACA,WAAA,GAAc,UAAA;AAAA,EACd,GAAG;AACL,CAAA,EAA2C;AACzC,EAAA,uBACE,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,wBAAA;AAAA,MACV,WAAA;AAAA,MACA,SAAA,EAAW,EAAA;AAAA,QACT,sHAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"button-group.js","sourcesContent":["import { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils.js'\nimport { Separator } from './separator.js'\n\nconst buttonGroupVariants = cva(\n \"flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-e-sm [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1\",\n {\n variants: {\n orientation: {\n horizontal:\n '*:data-slot:rounded-e-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-e-sm! [&>[data-slot]~[data-slot]]:rounded-s-none [&>[data-slot]~[data-slot]]:border-s-0',\n vertical:\n 'flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-sm! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0',\n },\n },\n defaultVariants: {\n orientation: 'horizontal',\n },\n },\n)\n\nfunction ButtonGroup({\n className,\n orientation,\n ...props\n}: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>) {\n return (\n <div\n role='group'\n data-slot='button-group'\n data-orientation={orientation}\n className={cn(buttonGroupVariants({ orientation }), className)}\n {...props}\n />\n )\n}\n\nfunction ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>) {\n return useRender({\n defaultTagName: 'div',\n props: mergeProps<'div'>(\n {\n className: cn(\n \"flex items-center gap-2 rounded-sm border bg-muted px-2.5 text-xs/relaxed font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4\",\n className,\n ),\n },\n props,\n ),\n render,\n state: {\n slot: 'button-group-text',\n },\n })\n}\n\nfunction ButtonGroupSeparator({\n className,\n orientation = 'vertical',\n ...props\n}: React.ComponentProps<typeof Separator>) {\n return (\n <Separator\n data-slot='button-group-separator'\n orientation={orientation}\n className={cn(\n 'relative self-stretch bg-input data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants }\n"]}
1
+ {"version":3,"sources":["../../src/components/button-group.tsx"],"names":[],"mappings":"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","file":"button-group.js","sourcesContent":["'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport {\n ButtonGroupBoundary,\n ButtonGroupContext,\n type ButtonGroupContextValue,\n} from '../lib/button-group-context.js'\nimport { cn } from '../lib/utils.js'\nimport { buttonColorVariants, type ButtonProps } from './button.js'\nimport { Separator } from './separator.js'\n\nconst DEFAULT_GROUP_VARIANT = 'outline' as const\nconst DEFAULT_GROUP_ORIENTATION = 'horizontal' as const\n\n/**\n * The group owns the boundary. It draws the frame or the band, the hairline\n * between segments and the 4px corners, and it clips its children to that\n * radius — so a segment never computes a corner of its own. The segments are\n * ordinary Buttons: they read `ButtonGroupContext` and give up the chrome the\n * group now draws (see `styles.segment` in button.tsx).\n *\n * This replaces a wrapper that collapsed borders through `[data-slot]` child\n * selectors copied from shadcn. Button never emitted `data-slot`, so none of\n * those rules matched: every Button kept its own 2px outline and 4px corners,\n * and neighbours met with a 4px doubled border.\n *\n * Every colour is Button's own `--btn-fill` / `--btn-bg` / `--btn-text` pair,\n * applied to the group by `buttonColorVariants`, so a group's `color` means\n * what a Button's does: the ink flips for dark mode the same way, and on a\n * soft or surface band it steps to the darker ink those tints need the same\n * way (`styles.tintInk` in button.tsx). The segments learn they sit on that\n * tint from the `band` the context carries, and step their own colour's ink,\n * so a segment naming another colour keeps it. Hairlines take the text\n * colour, per the masterbrand's line system. These classes therefore only\n * paint on an element that also carries `buttonColorVariants` —\n * `ring-(--btn-bg)` is invalid without it — so a consumer extending the\n * group's styling applies the two together, as `ButtonGroup` does.\n *\n * Two kinds of rule reach a segment. What depends on the segment's\n * NEIGHBOURS — dividers, seams, the text cell — lives here and uses the CHILD\n * combinator (`&>`) and sibling combinators, so it needs the segments to be\n * direct children. What depends only on the BAND — the re-ink on a solid\n * band, the frame-revealing `bg-clip-padding` — lives on the segment itself,\n * keyed on the `data-band` the group tells it through context, so it holds\n * for a segment rendered through a trigger's `render` prop or wrapped in a\n * span. Never a descendant rule: a group is not meant to nest, but if one\n * ever does, a descendant rule from the outer band would re-ink the inner\n * group's segments.\n */\nconst buttonGroupVariants = cva(\n [\n 'isolate inline-flex w-fit items-stretch overflow-hidden rounded-sm',\n // `items-stretch` above is what makes every segment the same size across\n // the group's cross axis — except an icon-only one, which `styles.iconOnly`\n // squares with `size-(--btn-h)`. A definite cross size is precisely the\n // case flexbox does NOT stretch (CSS Flexbox §9.4: stretch applies only\n // when the cross-size property computes to `auto`), so the square holds its\n // 52px whatever the segments beside it do. In a column that is every mixed\n // group: a 52px square in a 135px band, with a void beside it and the\n // hairline above it stopping a third of the way across. In a row it needs a\n // label to wrap first, which `min-h-(--btn-h)` on the button explicitly\n // allows — a floor, not a fixed height — and then the square sits at the\n // top of a 136px row.\n //\n // So the group releases the cross dimension and lets `items-stretch` do its\n // work, keeping the main one: the square stays a square whenever its\n // neighbours are one line tall, and grows with them when they are not.\n // Keyed on the group's own orientation, so neither rule is a bare utility\n // the other has to override, and reached through the child combinator, so\n // a nested icon button (inside a popup opened from a segment, say) is not\n // touched. (0,3,0) against `size-(--btn-h)`'s (0,1,0).\n 'data-[orientation=horizontal]:[&>[data-slot][data-icon-only]]:h-auto',\n 'data-[orientation=vertical]:[&>[data-slot][data-icon-only]]:w-auto',\n // The band's label colour, resolved HERE from the group's own colour\n // token and inherited by every segment as a computed value. A segment on\n // a solid band re-points its ink to this (see `styles.segment` in\n // button.tsx); publishing it from the group is what stops a segment that\n // names its own `color` from reading its own `--btn-text` instead.\n '[--group-label:var(--btn-text)]',\n // Dividers. A Button or ButtonGroupText carries `data-slot` and a 1px\n // transparent border, so the divider is that border recoloured on the\n // shared edge: no extra pixel, and the group's outer box stays exactly\n // one button tall. (ButtonGroupSeparator carries `data-slot` too but no\n // border and no size, so the hairline beside it is drawn by the segment\n // after it.) Keyed on orientation both ways so neither rule is a bare\n // utility the other overrides, and written as `[data-slot]~[data-slot]`\n // for specificity: Button's `dark:border-white/5` is a border-color\n // SHORTHAND at (0,2,0), and this longhand only beats it by specificity,\n // never by emission order (AGENTS.md §4, the two-build cascade).\n //\n // `loading` reaches these rules as well as `disabled`: Button derives\n // `disabled` from either, so a busy segment is a disabled one here. The\n // boundary therefore moves by a pixel when a request starts, which is the\n // contract holding rather than breaking — the alternative is a\n // half-strength hairline beside an enabled control for as long as the\n // request runs. `Segment Props` pins it.\n //\n // A disabled segment fades itself with `opacity-50`, and a divider drawn\n // on its own leading edge would fade with it — leaving one weak hairline\n // in an otherwise full-strength row, right where the eye reads the join.\n // So the boundary before a disabled segment is drawn on the trailing edge\n // of the segment BEFORE it instead, and the disabled segment's own\n // leading edge stays transparent. A separator between the two has no edge\n // to paint, so the rule also looks through one.\n //\n // The one hairline this does NOT lift out of the fade is the one BETWEEN\n // two adjacent disabled segments: its only available edge belongs to a\n // disabled element either way, so it renders at 50% like the pair it\n // divides. That is the coherent reading — the whole run is unavailable,\n // and a full-strength line inside it would draw more attention than the\n // controls do — and lifting it would mean moving dividers off the\n // segments entirely, onto a layer the group owns. `Disabled` renders the\n // case and pins where each edge lands.\n 'data-[orientation=horizontal]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-s-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-t-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-b-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-b-(--divider)',\n // Two solid segments side by side (a split button): the ink divider would\n // vanish on the fill, so the seam is a reversed hairline in the label\n // colour. Above the general divider on specificity, with the same\n // disabled handling, and again looking through a separator.\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n ],\n {\n variants: {\n variant: {\n // A 1px hairline frame in the ink, drawn as an inset ring so it adds\n // no height: the group is exactly as tall as a lone Button beside it.\n // No fill of its own, like Button's outline: the surface shows\n // through, so a `white` outline group on a dark panel stays a frame.\n // Forced-colours mode discards box shadows, so the frame is restated\n // there as an outline, which that mode keeps and recolours. The text\n // cell stops its background at the padding box so the frame shows\n // through its transparent border.\n outline: [\n 'ring-1 ring-(--btn-bg) [--divider:var(--btn-bg)] ring-inset',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-clip-padding',\n ],\n // The band. Segments re-ink themselves on it (see `styles.segment` in\n // button.tsx); the text cell sits on the band in its label colour, at\n // the label weight so it reads as a label rather than as another\n // button.\n solid: [\n 'bg-(--btn-fill) [--divider:color-mix(in_oklab,var(--btn-text)_30%,transparent)]',\n '[&>[data-slot=button-group-text]]:bg-transparent [&>[data-slot=button-group-text]]:font-medium [&>[data-slot=button-group-text]]:text-(--btn-text)',\n ],\n // Button's soft pair — ink at 10%, 20% in dark — as a band. The text\n // cell sits on the band.\n soft: 'bg-(--btn-bg)/10 [--divider:color-mix(in_oklab,var(--btn-bg)_30%,transparent)] dark:bg-(--btn-bg)/20 [&>[data-slot=button-group-text]]:bg-transparent',\n // Button's surface pair: ink at 5% inside an ink/50 hairline, restated\n // as an outline for forced colours like the outline frame.\n surface: [\n 'bg-(--btn-bg)/5 ring-1 ring-(--btn-bg)/50 [--divider:color-mix(in_oklab,var(--btn-bg)_50%,transparent)] ring-inset dark:bg-(--btn-bg)/30',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-transparent',\n ],\n // No frame, no fill: only the hairlines between segments remain.\n ghost: '[--divider:var(--btn-bg)]',\n },\n orientation: {\n horizontal: 'flex-row',\n vertical: 'flex-col',\n },\n },\n defaultVariants: {\n variant: DEFAULT_GROUP_VARIANT,\n orientation: DEFAULT_GROUP_ORIENTATION,\n },\n },\n)\n\n/** The group variants a ButtonGroup can paint. `link` has no group form. */\ntype ButtonGroupVariant = NonNullable<VariantProps<typeof buttonGroupVariants>['variant']>\n\ntype ButtonGroupProps = Omit<React.ComponentProps<'div'>, 'color'> &\n VariantProps<typeof buttonGroupVariants> & {\n /**\n * Colour token, with Button's meaning: `primary` by default. Sets the\n * ink the frame, band and dividers are drawn in, and the default colour\n * of every segment.\n */\n color?: ButtonProps['color']\n /**\n * Scale step, with Button's meaning. The default size of every segment.\n * `icon` is not offered: it is a 40px chrome square, and the group clips\n * to its own box, so the 44px touch expansion Button adds on a coarse\n * pointer would be cut off. A segment that asks for `icon` anyway renders\n * as `iconOnly` at the group's own step, so it lines up with the segments\n * beside it.\n */\n size?: Exclude<ButtonProps['size'], 'icon'>\n }\n\n/**\n * Joins a row (or column) of Buttons into one control. Takes Button's variant\n * family — `outline` (the default), `solid`, `soft`, `surface`, `ghost` — and\n * its colour tokens and size steps, and hands them to its segments as\n * defaults. A segment may name its own emphasis: a `solid` Save inside an\n * outline group is the primary action of that row.\n *\n * Children are Buttons (or ButtonLinks), `ButtonGroupText` for an inline\n * label, and `ButtonGroupSeparator` for a semantic boundary, as DIRECT\n * children: the hairlines between segments are drawn on the segments' shared\n * edges, so a segment wrapped in another element (a span holding a tooltip\n * on a disabled segment, say) keeps its label and its band treatment but\n * loses the hairlines it shares with its neighbours — the one before it, and\n * the one after it too when the wrapped segment is the first child. It is a group of buttons, not a general\n * control frame — an input or select with an attached action is InputGroup's\n * job — and groups do not nest.\n *\n * A popup opened from a segment (a split button's menu) renders through a\n * portal, which React context follows. Every popup in this package resets the\n * group context at its portal, so the Buttons inside render normally; wrap\n * the contents of an overlay from another library in `ButtonGroupBoundary`\n * to get the same. Without that reset a Button inside the popup renders as a\n * segment of the group it was opened from, and on a solid band that means its\n * label takes the band's colour — white on the popup's own surface.\n */\nfunction ButtonGroup({\n className,\n variant,\n orientation,\n color,\n size,\n children,\n ...props\n}: ButtonGroupProps) {\n const resolvedVariant = variant ?? DEFAULT_GROUP_VARIANT\n const resolvedOrientation = orientation ?? DEFAULT_GROUP_ORIENTATION\n // `null` is admitted by both prop types (they borrow Button's, which allow\n // it) and is the idiomatic way to thread an optional prop through a\n // wrapper. cva reads it as \"no variant\" rather than \"unspecified\", so an\n // unnormalised `null` would emit no size or colour classes AT ALL — and\n // because a segment resolves `color ?? group.color`, one `null` on the\n // group would turn every child's own `undefined` into an explicit `null`\n // and un-style the whole row: no padding, no height, and a frame still\n // pointing at a `--btn-bg` nothing defines. Normalising here means the\n // group and its segments both fall back to the same cva defaults a lone\n // Button gets.\n const resolvedColor = color ?? undefined\n const resolvedSize = size ?? undefined\n const context = React.useMemo<ButtonGroupContextValue>(\n () => ({\n band: resolvedVariant,\n color: resolvedColor,\n size: resolvedSize,\n orientation: resolvedOrientation,\n }),\n [resolvedVariant, resolvedColor, resolvedSize, resolvedOrientation],\n )\n\n return (\n <div\n role='group'\n data-slot='button-group'\n className={cn(\n buttonColorVariants({ color: resolvedColor, variant: resolvedVariant }),\n buttonGroupVariants({ variant: resolvedVariant, orientation: resolvedOrientation }),\n className,\n )}\n {...props}\n // AFTER the spread, so that no prop can override these two — unlike\n // `data-slot` above, and unlike Button, which puts its own stamps first\n // so InputGroupButton can relabel them. `data-orientation` is what every\n // divider rule keys on, while the flex direction comes from the cva\n // variant and the separator's axis from the context — neither of which\n // a prop can reach. If a prop could override it, a row handed\n // `data-orientation='vertical'` would paint column dividers across\n // itself. Nothing in the package keys on `data-variant` (the band\n // treatment reaches the segments through `data-band` instead), but it is\n // the group's public description of itself, and stamped last it cannot\n // be made to contradict the variant the group actually paints. The\n // Segment Props play pins both. `data-slot` stays first because\n // relabelling a group is the same escape hatch Button offers.\n data-variant={resolvedVariant}\n data-orientation={resolvedOrientation}\n >\n <ButtonGroupContext.Provider value={context}>{children}</ButtonGroupContext.Provider>\n </div>\n )\n}\n\n/**\n * An inline label between segments — a unit, a count, a mode. Sits at the\n * body size (16px), never smaller: it shares a line with 16px button labels,\n * so anything below that reads as fine print. Semibold, the weight the\n * InputGroup addon uses for the same job. On a framed or ghost group it sits\n * on the sunken surface so it reads as chrome rather than as a button; on a\n * band it sits on the band, and a solid band gives it the band's label colour\n * at the label weight (see `buttonGroupVariants`).\n */\nfunction ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>) {\n return useRender({\n defaultTagName: 'div',\n props: mergeProps<'div'>(\n {\n className: cn(\n // The transparent border is what the group's divider recolours.\n 'flex items-center gap-2 border border-transparent bg-(--surface-sunken) px-4 text-base font-semibold text-muted-foreground select-none',\n // A glyph beside the text matches Button's 24px label glyph.\n \"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-6\",\n className,\n ),\n },\n props,\n ),\n render,\n state: {\n slot: 'button-group-text',\n },\n })\n}\n\n/**\n * A semantic boundary between segments. Every segment is already divided by\n * a hairline, so the separator draws nothing of its own — it exists for\n * assistive technology, which hears it as a region boundary, and it follows\n * the group's orientation unless told otherwise.\n */\nfunction ButtonGroupSeparator({\n className,\n orientation,\n ...props\n}: React.ComponentProps<typeof Separator>) {\n const group = React.useContext(ButtonGroupContext)\n const resolvedOrientation =\n orientation ?? (group?.orientation === 'vertical' ? 'horizontal' : 'vertical')\n\n return (\n <Separator\n data-slot='button-group-separator'\n orientation={resolvedOrientation}\n className={cn(\n // Zero-size on its own axis and transparent: the hairline beside it\n // is the group's divider, not this element. Same variant keys as the\n // primitive's own sizing so tailwind-merge resolves them here.\n 'self-stretch bg-transparent data-[orientation=horizontal]:h-0 data-[orientation=vertical]:w-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n ButtonGroup,\n ButtonGroupBoundary,\n ButtonGroupSeparator,\n ButtonGroupText,\n buttonGroupVariants,\n}\nexport type { ButtonGroupProps, ButtonGroupVariant }\n"]}
@@ -4,12 +4,44 @@ import { VariantProps } from 'class-variance-authority';
4
4
  import React__default from 'react';
5
5
  import { Link } from './link.js';
6
6
 
7
- declare const buttonVariants: (props?: ({
8
- variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
9
- color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "danger" | "success" | "warning" | null | undefined;
7
+ declare const buttonCva: (props?: ({
8
+ variant?: "solid" | "soft" | "surface" | "outline" | "link" | "ghost" | null | undefined;
9
+ color?: "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | "success" | "warning" | "danger" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
11
11
  iconOnly?: boolean | null | undefined;
12
+ onTint?: boolean | null | undefined;
12
13
  } & class_variance_authority_types.ClassProp) | undefined) => string;
14
+ /** The props `buttonVariants` takes: the cva's own. */
15
+ type ButtonVariantProps = NonNullable<Parameters<typeof buttonCva>[0]>;
16
+ /**
17
+ * Button's class string. A thin wrapper over the cva so that two things hold
18
+ * for every caller, not only for `Button` itself: `onTint` defaults to
19
+ * whether the variant is one that paints its label on a tint, so a caller
20
+ * styling its own element with `buttonVariants({ variant: 'soft', … })` gets
21
+ * the stepped ink without knowing about it; and the string is merged before
22
+ * it is returned. The cva's output carries both the colour's own `--btn-bg`
23
+ * and, on the tint, the stepped one from `styles.tintInk`. `cn` keeps the
24
+ * later, so one declaration reaches the DOM and the pair is settled at the
25
+ * class-string level, never by stylesheet order — the two-build hazard in
26
+ * AGENTS.md §4 needs two rules in the cascade, and this leaves it one.
27
+ */
28
+ declare function buttonVariants({ onTint, ...props }?: ButtonVariantProps): string;
29
+ declare const buttonColorCva: (props?: ({
30
+ color?: "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | "success" | "warning" | "danger" | null | undefined;
31
+ onTint?: boolean | null | undefined;
32
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
33
+ /**
34
+ * Button's colour tokens on their own — the `--btn-fill` / `--btn-bg` /
35
+ * `--btn-border` / `--btn-text` pair for each token, with the dark-mode ink
36
+ * flip and, on the tint, the stepped ink those tints need (`styles.tintInk`).
37
+ * ButtonGroup applies this to itself so the frame, band and dividers it draws
38
+ * take the same ink its segments do, and a group's `color` means exactly what
39
+ * a Button's does. Takes the group's `variant` and derives `onTint` from it
40
+ * as `buttonVariants` does, and merges the string for the same reason.
41
+ */
42
+ declare function buttonColorVariants({ variant, onTint, ...props }?: NonNullable<Parameters<typeof buttonColorCva>[0]> & {
43
+ variant?: ButtonVariantProps['variant'];
44
+ }): string;
13
45
  /**
14
46
  * An icon slot. Takes either form:
15
47
  *
@@ -26,7 +58,7 @@ declare const buttonVariants: (props?: ({
26
58
  */
27
59
  type IconSlot = React__default.ElementType | React__default.ReactElement;
28
60
  /** Visual/content props shared by `Button` and `ButtonLink`. */
29
- type ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOnly' | 'color'> & {
61
+ type ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOnly' | 'color' | 'onTint'> & {
30
62
  /**
31
63
  * Colour token. Most are safe on any surface: the non-solid variants take
32
64
  * their ink from the token and it flips for dark mode, so `primary` reads
@@ -41,6 +73,10 @@ type ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOn
41
73
  * `primary-800` panel — and use `primary` on a light or theme-flipping
42
74
  * surface. `solid` is unaffected either way, since it pairs `--btn-fill`
43
75
  * with `--btn-text` rather than painting the ink.
76
+ *
77
+ * On a tint — `soft`, `surface`, or any non-solid segment of a soft or
78
+ * surface ButtonGroup — `tertiary`, `accent`, `success` and `warning` step
79
+ * to their `-700` ink so the label clears 4.5:1; see `styles.tintInk`.
44
80
  */
45
81
  color?: 'white' | 'grey' | 'primary' | 'secondary' | 'tertiary' | 'accent' | 'danger' | 'success' | 'warning' | null;
46
82
  /**
@@ -52,6 +88,9 @@ type ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOn
52
88
  * square (header actions, dialog close buttons, footer social links) that
53
89
  * lines up with none of them. For an icon-only button that must sit level
54
90
  * with text buttons beside it, pair `iconOnly` with `sm`/`default`/`lg`.
91
+ * Inside a ButtonGroup `icon` renders exactly that way, as `iconOnly` at
92
+ * the group's own step: the group clips to its own box, so the square's
93
+ * 44px touch expansion would be cut off.
55
94
  */
56
95
  size?: 'sm' | 'default' | 'lg' | 'icon' | null;
57
96
  /**
@@ -104,7 +143,7 @@ type ButtonLinkProps = ButtonOwnProps & Omit<React__default.ComponentPropsWithou
104
143
  * Base UI's `render` prop is available for composition (e.g. rendering a
105
144
  * framework-specific element while keeping Button behaviour).
106
145
  */
107
- declare function Button({ className, variant, color, size, iconOnly, children, block, loading, alignContent, disabled, leadingVisual, trailingVisual, trailingAction, labelWrap, count, countLabel, ref, ...props }: ButtonProps): React__default.JSX.Element;
146
+ declare function Button({ className, variant: variantProp, color: colorProp, size: sizeProp, iconOnly: iconOnlyProp, children, block, loading, alignContent, disabled, leadingVisual, trailingVisual, trailingAction, labelWrap, count, countLabel, ref, ...props }: ButtonProps): React__default.JSX.Element;
108
147
  /**
109
148
  * Button-styled anchor. Renders through `Link`, so it picks up the
110
149
  * framework link component from `LinkProvider` (e.g. next/link) and accepts
@@ -112,7 +151,7 @@ declare function Button({ className, variant, color, size, iconOnly, children, b
112
151
  * `aria-disabled` and a click guard, since anchors have no `disabled`
113
152
  * attribute.
114
153
  */
115
- declare function ButtonLink({ className, variant, color, size, iconOnly, children, block, loading, alignContent, disabled, leadingVisual, trailingVisual, trailingAction, labelWrap, count, countLabel, ref, ...props }: ButtonLinkProps): React__default.JSX.Element;
154
+ declare function ButtonLink({ className, variant: variantProp, color: colorProp, size: sizeProp, iconOnly: iconOnlyProp, children, block, loading, alignContent, disabled, leadingVisual, trailingVisual, trailingAction, labelWrap, count, countLabel, ref, ...props }: ButtonLinkProps): React__default.JSX.Element;
116
155
  /**
117
156
  * Expand the hit area to at least 44×44px on touch devices
118
157
  */
@@ -120,4 +159,4 @@ declare function TouchTarget({ children }: {
120
159
  children: React__default.ReactNode;
121
160
  }): React__default.JSX.Element;
122
161
 
123
- export { Button, ButtonLink, type ButtonLinkProps, type ButtonProps, type IconSlot, TouchTarget, buttonVariants };
162
+ export { Button, ButtonLink, type ButtonLinkProps, type ButtonProps, type IconSlot, TouchTarget, buttonColorVariants, buttonVariants };