@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.
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/button-group.d.ts +104 -5
- package/dist/components/button-group.js +166 -11
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button.d.ts +46 -7
- package/dist/components/button.js +271 -25
- package/dist/components/button.js.map +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/combobox.js +3 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/drawer.d.ts +1 -1
- package/dist/components/drawer.js +3 -2
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/header.d.ts +1 -1
- package/dist/components/hover-card.js +3 -2
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/link.d.ts +1 -1
- package/dist/components/masthead.d.ts +1 -1
- package/dist/components/native-select.d.ts +9 -5
- package/dist/components/native-select.js +32 -6
- package/dist/components/native-select.js.map +1 -1
- package/dist/components/navigation-menu.d.ts +1 -1
- package/dist/components/navigation-menu.js +6 -4
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/popover.js +3 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/select.d.ts +8 -4
- package/dist/components/select.js +36 -12
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.js +3 -2
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/site-search.js +3 -2
- package/dist/components/site-search.js.map +1 -1
- package/dist/components/skip-link.d.ts +1 -1
- package/dist/components/tooltip.js +3 -2
- package/dist/components/tooltip.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/lib/button-group-context.d.ts +46 -0
- package/dist/lib/button-group-context.js +12 -0
- package/dist/lib/button-group-context.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -1
|
@@ -4,6 +4,7 @@ import { Button as Button$1 } from '@base-ui/react/button';
|
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import React from 'react';
|
|
7
|
+
import { ButtonGroupContext } from '../lib/button-group-context.js';
|
|
7
8
|
import { cn } from '../lib/utils.js';
|
|
8
9
|
import { Link } from '../components/link.js';
|
|
9
10
|
import { Spinner } from '../components/spinner.js';
|
|
@@ -207,7 +208,8 @@ const styles = {
|
|
|
207
208
|
// (`text-(--btn-bg)`), the border on `outline`/`surface`, the tint on
|
|
208
209
|
// `soft`/`surface`, the `link` halos, the state overlays derived in
|
|
209
210
|
// `styles.base`, and the focus ring. They start life the same colour, and
|
|
210
|
-
//
|
|
211
|
+
// part company in two places: dark mode, and — for the four tokens in
|
|
212
|
+
// `styles.tintInk` — on the token's own tint.
|
|
211
213
|
//
|
|
212
214
|
// They used to be one variable, which made the ink un-flippable. The values
|
|
213
215
|
// here are masterbrand palette steps, and palette steps are theme-invariant —
|
|
@@ -334,6 +336,63 @@ const styles = {
|
|
|
334
336
|
"data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
|
|
335
337
|
]
|
|
336
338
|
},
|
|
339
|
+
// Ink on the tint.
|
|
340
|
+
//
|
|
341
|
+
// `soft` and `surface` paint the label in the ink over a tint of the same
|
|
342
|
+
// ink, and for four tokens that pair cannot carry a label. Their inks are
|
|
343
|
+
// `-600` steps that sit at 4.53–5.18:1 on pure white to begin with, so any
|
|
344
|
+
// tint of themselves takes them under the 4.5:1 WCAG 1.4.3 asks of a 16px
|
|
345
|
+
// bold label: on a 10% band, primary-600 measures 4.00:1, accent-600
|
|
346
|
+
// 4.39:1, success-600 3.96:1 and warning-600 3.96:1, and a lone Button
|
|
347
|
+
// lands lower still (3.49–3.76:1) because its `before` fill layer paints
|
|
348
|
+
// the tint a second time inside the border. No lower tint rescues them —
|
|
349
|
+
// at 3% three of the four still fail — so the tint stays and the ink steps
|
|
350
|
+
// down to `-700`, which measures 7.0:1 or better on the band and 5.9:1 or
|
|
351
|
+
// better on the doubled tint. Not `-800`: for tertiary that is primary's
|
|
352
|
+
// own ink, and a soft tertiary would become a soft primary. Neither step
|
|
353
|
+
// is the ramps' text step (that is `-800`), so the case rests on the
|
|
354
|
+
// measurements, not on a ramp role. The other five tokens keep their ink;
|
|
355
|
+
// their closest pair is danger-600 at 4.71:1.
|
|
356
|
+
//
|
|
357
|
+
// It is `--btn-bg` that steps, not the text colour alone: the tint, the
|
|
358
|
+
// hover and active overlays and the focus ring all derive from it (the
|
|
359
|
+
// Derived State Rule in DESIGN.md). Two things stay outside the step and
|
|
360
|
+
// are known: the press overlay takes a lone soft tertiary to 4.40:1 and a
|
|
361
|
+
// lone soft accent to 4.18:1 for the duration of the press (2.8:1 before),
|
|
362
|
+
// and `outline`, `ghost` and `link` keep the `-600` ink, which clears
|
|
363
|
+
// 4.5:1 on pure white only — on an off-white such as `background-subtle`
|
|
364
|
+
// those three measure 4.15–4.19:1 for the same four tokens.
|
|
365
|
+
//
|
|
366
|
+
// Keyed on `onTint`, not on the variant: a segment of a soft or surface
|
|
367
|
+
// ButtonGroup band sits on the band's tint with `ghost` as its own
|
|
368
|
+
// variant, and it steps its own colour's ink there — a danger segment on a
|
|
369
|
+
// tertiary band stays danger. `buttonVariants` derives `onTint` from the
|
|
370
|
+
// variant for a lone Button; `resolveGroupDefaults` sets it for a segment.
|
|
371
|
+
//
|
|
372
|
+
// These are bare declarations at (0,1,0), so the colour's `dark:` ink at
|
|
373
|
+
// (0,2,0) wins over them exactly as it wins over the light ink above —
|
|
374
|
+
// dark mode is untouched, and its `-200` inks clear 5.8:1 on their tints.
|
|
375
|
+
// The colour's own light ink is not fought in the cascade at all:
|
|
376
|
+
// `buttonVariants` and `buttonColorVariants` merge their class strings
|
|
377
|
+
// before returning them, so one `--btn-bg` declaration reaches the DOM,
|
|
378
|
+
// and a surface that imposes its ink through `className` (footer.tsx) is
|
|
379
|
+
// merged later still.
|
|
380
|
+
//
|
|
381
|
+
// Raw tokens rather than the `--color-*` bridges, for the tree-shaking
|
|
382
|
+
// reason above `danger`: no utility in the package uses the primary,
|
|
383
|
+
// accent, success or warning `-700` steps, so none of those four bridges
|
|
384
|
+
// survives the build (grey-700 does, through step-indicator.tsx). A
|
|
385
|
+
// runtime re-theme that writes only the bridges — Storybook's theme
|
|
386
|
+
// picker — therefore leaves these inks at masterbrand, as it leaves the
|
|
387
|
+
// `dark:` inks; a rebrand that redefines the raw tokens is unaffected.
|
|
388
|
+
// The figures above are for the masterbrand colourway theme.css imports:
|
|
389
|
+
// a colourway swap (AGENTS.md §3) must re-measure this table.
|
|
390
|
+
tintInk: [
|
|
391
|
+
{ onTint: true, color: "tertiary", className: "[--btn-bg:var(--primary-700)]" },
|
|
392
|
+
{ onTint: true, color: "accent", className: "[--btn-bg:var(--accent-700)]" },
|
|
393
|
+
{ onTint: true, color: "success", className: "[--btn-bg:var(--success-700)]" },
|
|
394
|
+
{ onTint: true, color: "warning", className: "[--btn-bg:var(--warning-700)]" }
|
|
395
|
+
],
|
|
337
396
|
// Each step publishes its own height as `--btn-h`, built from the same two
|
|
338
397
|
// numbers that produce its box: one line box (`text-base/7` — Tailwind's
|
|
339
398
|
// `/7` is `--spacing(7)`, so this is the same token, not a matching literal)
|
|
@@ -362,9 +421,81 @@ const styles = {
|
|
|
362
421
|
// Square the button at the current step and drop the horizontal padding, so
|
|
363
422
|
// the scale step and "is this icon-only" are independent axes. The glyph
|
|
364
423
|
// needs no adjustment — the step already sizes it off the ladder.
|
|
365
|
-
iconOnly: "size-(--btn-h) flex-none p-0 sm:p-0"
|
|
424
|
+
iconOnly: "size-(--btn-h) flex-none p-0 sm:p-0",
|
|
425
|
+
// A segment: this button sits inside a ButtonGroup, which owns the boundary
|
|
426
|
+
// (frame, band, dividers, the 4px corners) and clips to its own radius. The
|
|
427
|
+
// button gives up the parts of its chrome the group now draws. Every rule is
|
|
428
|
+
// keyed on `data-segment` — an attribute selector, (0,2,0) against the
|
|
429
|
+
// variant's (0,1,0) and (0,3,0) against its `dark:` rules — so it wins on
|
|
430
|
+
// specificity, never on emission order (see the two-build note in AGENTS.md
|
|
431
|
+
// §4). InputGroupAction takes the same approach for the same reason.
|
|
432
|
+
segment: [
|
|
433
|
+
// Corners belong to the group. The fill and overlay layers are squared too
|
|
434
|
+
// — left at `calc(var(--radius-sm)-1px)` they notch the shared edges.
|
|
435
|
+
"data-[segment]:rounded-none data-[segment]:before:rounded-none data-[segment]:after:rounded-none data-[segment]:dark:after:rounded-none",
|
|
436
|
+
// The dark-mode overlay grows 1px to cover the button's own border; inside
|
|
437
|
+
// a group that 1px is the divider, and the hover tint must not paint over it.
|
|
438
|
+
"data-[segment]:dark:after:inset-0",
|
|
439
|
+
// No shadow: a `shadow-sm` whisper belongs under a button on the page, not
|
|
440
|
+
// under one segment of a control.
|
|
441
|
+
"data-[segment]:before:shadow-none",
|
|
442
|
+
// A framed group (`outline`, `surface`) draws its frame as an inset ring
|
|
443
|
+
// on the group, which paints beneath its children. A solid segment's own
|
|
444
|
+
// background (the optical border, `bg-(--btn-border)`) would cover that
|
|
445
|
+
// ring on the top and bottom edges, so on those bands backgrounds stop at
|
|
446
|
+
// the padding box and the 1px transparent border lets the frame through.
|
|
447
|
+
// The `before` fill layer is positioned inside the padding box already.
|
|
448
|
+
// Only on framed bands: on `ghost` or `soft` nothing paints beneath that
|
|
449
|
+
// pixel, and clipping there would leave a solid segment 1px short of the
|
|
450
|
+
// group's edge on both sides.
|
|
451
|
+
"data-[segment]:data-[band=outline]:bg-clip-padding data-[segment]:data-[band=surface]:bg-clip-padding",
|
|
452
|
+
// The group clips its corners (`overflow-hidden`), which would clip a ring
|
|
453
|
+
// sitting 2px outside the button, so the ring moves 2px inside instead —
|
|
454
|
+
// the same inversion the nav rails use inside a scroll container.
|
|
455
|
+
"data-[segment]:focus:-outline-offset-2",
|
|
456
|
+
// Inside the segment, a ring in the ink on a solid fill is fill on fill:
|
|
457
|
+
// in light mode `--btn-bg` and `--btn-fill` are the same token. So a solid
|
|
458
|
+
// segment rings in its label colour, the pair InputGroupAction's solid
|
|
459
|
+
// variant uses. (0,4,0) against the base ring's (0,2,0). A segment that
|
|
460
|
+
// is not solid keeps the ink ring; on a solid band the rule below re-points
|
|
461
|
+
// its ink to the label colour, so that ring is white there too.
|
|
462
|
+
"data-[segment]:data-[variant=solid]:focus:outline-(--btn-text)",
|
|
463
|
+
// On a solid band a segment that is not itself solid is painted on the
|
|
464
|
+
// band, so its ink becomes the band's label colour: white label, white/10
|
|
465
|
+
// hover, white ring, and a soft segment's tint becomes white/10 too. The
|
|
466
|
+
// press overlay takes solid's own black/15 so a band and a lone solid
|
|
467
|
+
// Button give the same feedback.
|
|
468
|
+
//
|
|
469
|
+
// The colour comes from `--group-label`, which the GROUP publishes from
|
|
470
|
+
// its own `--btn-text` — resolved at the group, then inherited — so a
|
|
471
|
+
// segment that names its own `color` cannot hijack it through its own
|
|
472
|
+
// `--btn-text` (that would put a `secondary` segment's grey ink on a
|
|
473
|
+
// primary band). And the rule is keyed on `data-band`, which the segment
|
|
474
|
+
// is told by the group through context, never on DOM ancestry: a segment
|
|
475
|
+
// rendered through a trigger's `render` prop, or wrapped in a span for a
|
|
476
|
+
// tooltip, is re-inked like any other. (0,4,0) against the colour token's
|
|
477
|
+
// (0,1,0) and its dark-mode ink at (0,2,0).
|
|
478
|
+
"data-[segment]:not-data-[variant=solid]:data-[band=solid]:[--btn-bg:var(--group-label)]",
|
|
479
|
+
"data-[segment]:not-data-[variant=solid]:data-[band=solid]:[--btn-active-overlay:var(--color-black)]/15",
|
|
480
|
+
// ...and it loses its own tint there. `soft` is the only non-solid variant
|
|
481
|
+
// that can reach this rule with a fill of its own (`surface` is not a
|
|
482
|
+
// segment emphasis, `ghost` paints nothing), and it paints TWO 10% layers
|
|
483
|
+
// — its element background and its `before` fill. Re-inked to the label
|
|
484
|
+
// colour those become white on white, and white/10 twice over lifts the
|
|
485
|
+
// band under the label just enough to break it: on the four bands whose
|
|
486
|
+
// white label already sits near the floor the pair measures 3.37:1
|
|
487
|
+
// (success), 3.39:1 (warning), 3.41:1 (tertiary) and 4.15:1 (accent),
|
|
488
|
+
// against 4.53:1 to 5.18:1 for the same bands with the tint gone. So a
|
|
489
|
+
// soft segment on a solid band reads as the ghost segments beside it do,
|
|
490
|
+
// and its emphasis is carried by `data-variant` for the seam rules rather
|
|
491
|
+
// than by a fill. Three attribute selectors, (0,3,0), so it beats both
|
|
492
|
+
// soft's own bare `bg-(--btn-bg)/10` and its `dark:` pair on specificity
|
|
493
|
+
// rather than on emission order (AGENTS.md §4).
|
|
494
|
+
"data-[segment]:not-data-[variant=solid]:data-[band=solid]:bg-transparent",
|
|
495
|
+
"data-[segment]:not-data-[variant=solid]:data-[band=solid]:before:bg-transparent"
|
|
496
|
+
]
|
|
366
497
|
};
|
|
367
|
-
const
|
|
498
|
+
const buttonCva = cva(styles.base, {
|
|
368
499
|
variants: {
|
|
369
500
|
variant: {
|
|
370
501
|
solid: styles.solid,
|
|
@@ -396,9 +527,22 @@ const buttonVariants = cva(styles.base, {
|
|
|
396
527
|
iconOnly: {
|
|
397
528
|
true: styles.iconOnly,
|
|
398
529
|
false: ""
|
|
530
|
+
},
|
|
531
|
+
// Whether the label sits on a tint of its own ink: a lone `soft` or
|
|
532
|
+
// `surface` Button, or any non-solid segment of a soft or surface
|
|
533
|
+
// ButtonGroup band. `buttonVariants` derives it from the variant when a
|
|
534
|
+
// caller leaves it unset; `resolveGroupDefaults` sets it for a segment.
|
|
535
|
+
onTint: {
|
|
536
|
+
true: "",
|
|
537
|
+
false: ""
|
|
399
538
|
}
|
|
400
539
|
},
|
|
401
540
|
compoundVariants: [
|
|
541
|
+
// ── Ink on the tint ──────────────────────────────────────────────────
|
|
542
|
+
//
|
|
543
|
+
// See `styles.tintInk`. The colour's own `--btn-bg` is still in this
|
|
544
|
+
// string; `buttonVariants` merges the two before returning.
|
|
545
|
+
...styles.tintInk,
|
|
402
546
|
// ── Icon-only glyph sizes ────────────────────────────────────────────
|
|
403
547
|
//
|
|
404
548
|
// With no label beside it the glyph has nothing to match, so here — and
|
|
@@ -438,9 +582,35 @@ const buttonVariants = cva(styles.base, {
|
|
|
438
582
|
defaultVariants: {
|
|
439
583
|
variant: "solid",
|
|
440
584
|
color: "primary",
|
|
441
|
-
size: "default"
|
|
585
|
+
size: "default",
|
|
586
|
+
onTint: false
|
|
442
587
|
}
|
|
443
588
|
});
|
|
589
|
+
const TINT_VARIANTS = /* @__PURE__ */ new Set(["soft", "surface"]);
|
|
590
|
+
function buttonVariants({ onTint, ...props } = {}) {
|
|
591
|
+
return cn(buttonCva({ ...props, onTint: onTint ?? TINT_VARIANTS.has(props.variant) }));
|
|
592
|
+
}
|
|
593
|
+
const buttonColorCva = cva("", {
|
|
594
|
+
variants: {
|
|
595
|
+
color: styles.colors,
|
|
596
|
+
// The band: a soft or surface group paints its tint from its own
|
|
597
|
+
// `--btn-bg`, so it is on the tint the way its segments are.
|
|
598
|
+
onTint: {
|
|
599
|
+
true: "",
|
|
600
|
+
false: ""
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
compoundVariants: styles.tintInk,
|
|
604
|
+
defaultVariants: { color: "primary", onTint: false }
|
|
605
|
+
});
|
|
606
|
+
function buttonColorVariants({
|
|
607
|
+
variant,
|
|
608
|
+
onTint,
|
|
609
|
+
...props
|
|
610
|
+
} = {}) {
|
|
611
|
+
return cn(buttonColorCva({ ...props, onTint: onTint ?? TINT_VARIANTS.has(variant) }));
|
|
612
|
+
}
|
|
613
|
+
const EMPHASISED_SEGMENT_VARIANTS = /* @__PURE__ */ new Set(["solid", "soft"]);
|
|
444
614
|
function renderIconSlot(slot) {
|
|
445
615
|
if (!slot) return null;
|
|
446
616
|
if (React.isValidElement(slot)) {
|
|
@@ -457,11 +627,14 @@ function buttonClasses({
|
|
|
457
627
|
block,
|
|
458
628
|
alignContent,
|
|
459
629
|
className,
|
|
460
|
-
effectiveDisabled
|
|
630
|
+
effectiveDisabled,
|
|
631
|
+
segment,
|
|
632
|
+
onTint
|
|
461
633
|
}) {
|
|
462
634
|
return clsx(
|
|
463
635
|
cn(
|
|
464
|
-
buttonVariants({ variant, color, size, iconOnly }),
|
|
636
|
+
buttonVariants({ variant, color, size, iconOnly, onTint }),
|
|
637
|
+
segment && styles.segment,
|
|
465
638
|
block && "w-full",
|
|
466
639
|
alignContent === "start" && "justify-start",
|
|
467
640
|
className
|
|
@@ -469,6 +642,53 @@ function buttonClasses({
|
|
|
469
642
|
effectiveDisabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
470
643
|
);
|
|
471
644
|
}
|
|
645
|
+
function resolveGroupDefaults(group, {
|
|
646
|
+
variant,
|
|
647
|
+
color,
|
|
648
|
+
size,
|
|
649
|
+
iconOnly
|
|
650
|
+
}) {
|
|
651
|
+
if (!group) {
|
|
652
|
+
return {
|
|
653
|
+
variant: variant ?? "solid",
|
|
654
|
+
color,
|
|
655
|
+
size,
|
|
656
|
+
iconOnly,
|
|
657
|
+
segment: void 0,
|
|
658
|
+
band: void 0,
|
|
659
|
+
onTint: void 0
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
const emphasised = EMPHASISED_SEGMENT_VARIANTS.has(variant);
|
|
663
|
+
const resolvedSize = size ?? group.size;
|
|
664
|
+
const iconStep = resolvedSize === "icon";
|
|
665
|
+
const groupStep = group.size === "icon" ? void 0 : group.size;
|
|
666
|
+
const resolved = emphasised ? variant : "ghost";
|
|
667
|
+
return {
|
|
668
|
+
variant: resolved,
|
|
669
|
+
color: color ?? group.color,
|
|
670
|
+
size: iconStep ? groupStep ?? "default" : resolvedSize,
|
|
671
|
+
// `??`, not `||`: an explicit `iconOnly={false}` is the author saying
|
|
672
|
+
// "not a square", and the `icon` coercion must not overrule it. Only an
|
|
673
|
+
// unstated `iconOnly` falls through to the coercion.
|
|
674
|
+
iconOnly: iconOnly ?? iconStep,
|
|
675
|
+
segment: emphasised ? "override" : "default",
|
|
676
|
+
band: group.band,
|
|
677
|
+
// On a soft or surface band every segment that is not solid sits on the
|
|
678
|
+
// band's tint whatever its own variant, so its ink steps as a lone soft
|
|
679
|
+
// Button's does (`styles.tintInk`) — its own colour's ink, not the
|
|
680
|
+
// band's: the group's colour is a default, never an override, so a
|
|
681
|
+
// danger segment on a tertiary band stays danger. The band is the group's
|
|
682
|
+
// own variant, which is what `band` carries.
|
|
683
|
+
onTint: resolved !== "solid" && TINT_VARIANTS.has(group.band)
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
function useSegmentDefaults(props) {
|
|
687
|
+
const group = React.useContext(ButtonGroupContext);
|
|
688
|
+
const resolved = resolveGroupDefaults(group, props);
|
|
689
|
+
warnIfIconStepInGroup(group, props.size ?? group?.size);
|
|
690
|
+
return resolved;
|
|
691
|
+
}
|
|
472
692
|
function ButtonContent({
|
|
473
693
|
loading,
|
|
474
694
|
leadingVisual,
|
|
@@ -524,19 +744,22 @@ function warnIfIconButtonUnlabelled(size, iconOnly, props, children) {
|
|
|
524
744
|
);
|
|
525
745
|
}
|
|
526
746
|
}
|
|
747
|
+
function warnIfIconStepInGroup(group, size) {
|
|
748
|
+
if (process.env.NODE_ENV === "production") {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (group && size === "icon") {
|
|
752
|
+
console.warn(
|
|
753
|
+
`[nswds/ui] size="icon" inside a ButtonGroup renders as iconOnly at the group's own step, so the square lines up with the segments beside it: the group clips its box, so the 40px square would lose its 44px touch target. Pair iconOnly with the group's size instead.`
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
527
757
|
function Button({
|
|
528
758
|
className,
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
// rules in `styles.colors` never matched a default `<Button>`. It fell
|
|
534
|
-
// through to the derived overlay in `styles.base` and painted `--btn-bg` at
|
|
535
|
-
// 10% over its own fill, which is the same colour: no visible hover at all.
|
|
536
|
-
variant = "solid",
|
|
537
|
-
color,
|
|
538
|
-
size,
|
|
539
|
-
iconOnly,
|
|
759
|
+
variant: variantProp,
|
|
760
|
+
color: colorProp,
|
|
761
|
+
size: sizeProp,
|
|
762
|
+
iconOnly: iconOnlyProp,
|
|
540
763
|
children,
|
|
541
764
|
block,
|
|
542
765
|
loading,
|
|
@@ -552,11 +775,21 @@ function Button({
|
|
|
552
775
|
...props
|
|
553
776
|
}) {
|
|
554
777
|
const effectiveDisabled = disabled || loading;
|
|
778
|
+
const { variant, color, size, iconOnly, segment, band, onTint } = useSegmentDefaults({
|
|
779
|
+
variant: variantProp,
|
|
780
|
+
color: colorProp,
|
|
781
|
+
size: sizeProp,
|
|
782
|
+
iconOnly: iconOnlyProp
|
|
783
|
+
});
|
|
555
784
|
warnIfIconButtonUnlabelled(size, iconOnly, props, children);
|
|
556
785
|
return /* @__PURE__ */ jsx(
|
|
557
786
|
Button$1,
|
|
558
787
|
{
|
|
788
|
+
"data-slot": "button",
|
|
559
789
|
"data-variant": variant,
|
|
790
|
+
"data-segment": segment,
|
|
791
|
+
"data-band": band,
|
|
792
|
+
"data-icon-only": iconOnly || void 0,
|
|
560
793
|
"aria-busy": loading || void 0,
|
|
561
794
|
...props,
|
|
562
795
|
disabled: effectiveDisabled,
|
|
@@ -568,7 +801,9 @@ function Button({
|
|
|
568
801
|
block,
|
|
569
802
|
alignContent,
|
|
570
803
|
className,
|
|
571
|
-
effectiveDisabled
|
|
804
|
+
effectiveDisabled,
|
|
805
|
+
segment,
|
|
806
|
+
onTint
|
|
572
807
|
}),
|
|
573
808
|
ref,
|
|
574
809
|
children: /* @__PURE__ */ jsx(
|
|
@@ -589,11 +824,10 @@ function Button({
|
|
|
589
824
|
}
|
|
590
825
|
function ButtonLink({
|
|
591
826
|
className,
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
iconOnly,
|
|
827
|
+
variant: variantProp,
|
|
828
|
+
color: colorProp,
|
|
829
|
+
size: sizeProp,
|
|
830
|
+
iconOnly: iconOnlyProp,
|
|
597
831
|
children,
|
|
598
832
|
block,
|
|
599
833
|
loading,
|
|
@@ -609,12 +843,22 @@ function ButtonLink({
|
|
|
609
843
|
...props
|
|
610
844
|
}) {
|
|
611
845
|
const effectiveDisabled = disabled || loading;
|
|
846
|
+
const { variant, color, size, iconOnly, segment, band, onTint } = useSegmentDefaults({
|
|
847
|
+
variant: variantProp,
|
|
848
|
+
color: colorProp,
|
|
849
|
+
size: sizeProp,
|
|
850
|
+
iconOnly: iconOnlyProp
|
|
851
|
+
});
|
|
612
852
|
warnIfIconButtonUnlabelled(size, iconOnly, props, children);
|
|
613
853
|
return /* @__PURE__ */ jsx(
|
|
614
854
|
Link,
|
|
615
855
|
{
|
|
616
856
|
variant: "unstyled",
|
|
857
|
+
"data-slot": "button",
|
|
617
858
|
"data-variant": variant,
|
|
859
|
+
"data-segment": segment,
|
|
860
|
+
"data-band": band,
|
|
861
|
+
"data-icon-only": iconOnly || void 0,
|
|
618
862
|
"aria-busy": loading || void 0,
|
|
619
863
|
...props,
|
|
620
864
|
...effectiveDisabled ? {
|
|
@@ -631,7 +875,9 @@ function ButtonLink({
|
|
|
631
875
|
block,
|
|
632
876
|
alignContent,
|
|
633
877
|
className,
|
|
634
|
-
effectiveDisabled
|
|
878
|
+
effectiveDisabled,
|
|
879
|
+
segment,
|
|
880
|
+
onTint
|
|
635
881
|
}),
|
|
636
882
|
ref,
|
|
637
883
|
children: /* @__PURE__ */ jsx(
|
|
@@ -663,6 +909,6 @@ function TouchTarget({ children }) {
|
|
|
663
909
|
] });
|
|
664
910
|
}
|
|
665
911
|
|
|
666
|
-
export { Button, ButtonLink, TouchTarget, buttonVariants };
|
|
912
|
+
export { Button, ButtonLink, TouchTarget, buttonColorVariants, buttonVariants };
|
|
667
913
|
//# sourceMappingURL=button.js.map
|
|
668
914
|
//# sourceMappingURL=button.js.map
|