@tinybigui/react 0.20.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/index.cjs +488 -174
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +291 -113
- package/dist/index.d.ts +291 -113
- package/dist/index.js +481 -173
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8213,7 +8213,8 @@ function TooltipOverlayHeadless({
|
|
|
8213
8213
|
}
|
|
8214
8214
|
var TooltipAnimationContext = React.createContext({
|
|
8215
8215
|
isExiting: false,
|
|
8216
|
-
onAnimationEnd: () => void 0
|
|
8216
|
+
onAnimationEnd: () => void 0,
|
|
8217
|
+
reducedMotion: false
|
|
8217
8218
|
});
|
|
8218
8219
|
function useTooltipAnimation() {
|
|
8219
8220
|
return React.useContext(TooltipAnimationContext);
|
|
@@ -8223,46 +8224,60 @@ function TooltipTrigger({
|
|
|
8223
8224
|
delay = 300,
|
|
8224
8225
|
isDisabled
|
|
8225
8226
|
}) {
|
|
8227
|
+
const reducedMotion = useReducedMotion();
|
|
8226
8228
|
const [isMounted, setIsMounted] = React.useState(false);
|
|
8227
8229
|
const [isExiting, setIsExiting] = React.useState(false);
|
|
8228
8230
|
const isExitingRef = React.useRef(false);
|
|
8229
8231
|
const isPointerOverTooltipRef = React.useRef(false);
|
|
8230
8232
|
const pendingCloseRef = React.useRef(false);
|
|
8231
|
-
const
|
|
8232
|
-
if (open) {
|
|
8233
|
-
pendingCloseRef.current = false;
|
|
8234
|
-
isExitingRef.current = false;
|
|
8235
|
-
setIsMounted(true);
|
|
8236
|
-
setIsExiting(false);
|
|
8237
|
-
} else if (isPointerOverTooltipRef.current) {
|
|
8238
|
-
pendingCloseRef.current = true;
|
|
8239
|
-
} else if (!isExitingRef.current) {
|
|
8240
|
-
isExitingRef.current = true;
|
|
8241
|
-
setIsExiting(true);
|
|
8242
|
-
}
|
|
8243
|
-
}, []);
|
|
8244
|
-
const handleAnimationEnd = React.useCallback(() => {
|
|
8245
|
-
if (!isExitingRef.current) return;
|
|
8233
|
+
const unmountImmediately = React.useCallback(() => {
|
|
8246
8234
|
isExitingRef.current = false;
|
|
8247
8235
|
pendingCloseRef.current = false;
|
|
8248
8236
|
setIsMounted(false);
|
|
8249
8237
|
setIsExiting(false);
|
|
8250
8238
|
}, []);
|
|
8239
|
+
const handleOpenChange = React.useCallback(
|
|
8240
|
+
(open) => {
|
|
8241
|
+
if (open) {
|
|
8242
|
+
pendingCloseRef.current = false;
|
|
8243
|
+
isExitingRef.current = false;
|
|
8244
|
+
setIsMounted(true);
|
|
8245
|
+
setIsExiting(false);
|
|
8246
|
+
} else if (isPointerOverTooltipRef.current) {
|
|
8247
|
+
pendingCloseRef.current = true;
|
|
8248
|
+
} else if (reducedMotion) {
|
|
8249
|
+
unmountImmediately();
|
|
8250
|
+
} else if (!isExitingRef.current) {
|
|
8251
|
+
isExitingRef.current = true;
|
|
8252
|
+
setIsExiting(true);
|
|
8253
|
+
}
|
|
8254
|
+
},
|
|
8255
|
+
[reducedMotion, unmountImmediately]
|
|
8256
|
+
);
|
|
8257
|
+
const handleAnimationEnd = React.useCallback(() => {
|
|
8258
|
+
if (!isExitingRef.current) return;
|
|
8259
|
+
unmountImmediately();
|
|
8260
|
+
}, [unmountImmediately]);
|
|
8251
8261
|
const handleOverlayPointerEnter = React.useCallback(() => {
|
|
8252
8262
|
isPointerOverTooltipRef.current = true;
|
|
8253
8263
|
pendingCloseRef.current = false;
|
|
8254
8264
|
}, []);
|
|
8255
8265
|
const handleOverlayPointerLeave = React.useCallback(() => {
|
|
8256
8266
|
isPointerOverTooltipRef.current = false;
|
|
8257
|
-
if (pendingCloseRef.current
|
|
8267
|
+
if (pendingCloseRef.current) {
|
|
8258
8268
|
pendingCloseRef.current = false;
|
|
8259
|
-
|
|
8260
|
-
|
|
8269
|
+
if (reducedMotion) {
|
|
8270
|
+
unmountImmediately();
|
|
8271
|
+
} else if (!isExitingRef.current) {
|
|
8272
|
+
isExitingRef.current = true;
|
|
8273
|
+
setIsExiting(true);
|
|
8274
|
+
}
|
|
8261
8275
|
}
|
|
8262
|
-
}, []);
|
|
8276
|
+
}, [reducedMotion, unmountImmediately]);
|
|
8263
8277
|
const contextValue = {
|
|
8264
8278
|
isExiting,
|
|
8265
|
-
onAnimationEnd: handleAnimationEnd
|
|
8279
|
+
onAnimationEnd: handleAnimationEnd,
|
|
8280
|
+
reducedMotion
|
|
8266
8281
|
};
|
|
8267
8282
|
const [triggerChild, tooltipChild] = children;
|
|
8268
8283
|
const placement = React.isValidElement(tooltipChild) ? tooltipChild.props.placement ?? "top" : "top";
|
|
@@ -8291,51 +8306,69 @@ function TooltipTrigger({
|
|
|
8291
8306
|
) });
|
|
8292
8307
|
}
|
|
8293
8308
|
var tooltipVariants = classVarianceAuthority.cva(
|
|
8294
|
-
|
|
8309
|
+
[
|
|
8310
|
+
"z-50 inline-flex items-center w-fit",
|
|
8311
|
+
"min-h-6 rounded-xs px-2 py-1",
|
|
8312
|
+
"text-body-small bg-inverse-surface text-inverse-on-surface",
|
|
8313
|
+
"max-w-50"
|
|
8314
|
+
],
|
|
8295
8315
|
{
|
|
8296
8316
|
variants: {
|
|
8297
8317
|
/**
|
|
8298
|
-
*
|
|
8318
|
+
* Controls the enter/exit animation class.
|
|
8299
8319
|
* Managed by `TooltipTrigger`'s animation state machine.
|
|
8300
|
-
*
|
|
8320
|
+
* Set to `"none"` when `prefers-reduced-motion: reduce` is active.
|
|
8321
|
+
* @default "enter"
|
|
8301
8322
|
*/
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8323
|
+
animation: {
|
|
8324
|
+
enter: "animate-md-scale-in",
|
|
8325
|
+
exit: "animate-md-scale-out",
|
|
8326
|
+
none: ""
|
|
8305
8327
|
}
|
|
8306
8328
|
},
|
|
8307
8329
|
defaultVariants: {
|
|
8308
|
-
|
|
8330
|
+
animation: "enter"
|
|
8309
8331
|
}
|
|
8310
8332
|
}
|
|
8311
8333
|
);
|
|
8312
8334
|
var richTooltipVariants = classVarianceAuthority.cva(
|
|
8313
|
-
|
|
8335
|
+
[
|
|
8336
|
+
"z-50 flex flex-col w-fit",
|
|
8337
|
+
"min-h-6 rounded-md px-4 py-3",
|
|
8338
|
+
"bg-surface-container text-on-surface shadow-elevation-2",
|
|
8339
|
+
"max-w-80"
|
|
8340
|
+
],
|
|
8314
8341
|
{
|
|
8315
8342
|
variants: {
|
|
8316
8343
|
/**
|
|
8317
|
-
*
|
|
8344
|
+
* Controls the enter/exit animation class.
|
|
8318
8345
|
* Managed by `TooltipTrigger`'s animation state machine.
|
|
8319
|
-
*
|
|
8346
|
+
* Set to `"none"` when `prefers-reduced-motion: reduce` is active.
|
|
8347
|
+
* @default "enter"
|
|
8320
8348
|
*/
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8349
|
+
animation: {
|
|
8350
|
+
enter: "animate-md-scale-in",
|
|
8351
|
+
exit: "animate-md-scale-out",
|
|
8352
|
+
none: ""
|
|
8324
8353
|
}
|
|
8325
8354
|
},
|
|
8326
8355
|
defaultVariants: {
|
|
8327
|
-
|
|
8356
|
+
animation: "enter"
|
|
8328
8357
|
}
|
|
8329
8358
|
}
|
|
8330
8359
|
);
|
|
8360
|
+
var richTooltipTitleVariants = classVarianceAuthority.cva(["text-title-small text-on-surface-variant mb-1"]);
|
|
8361
|
+
var richTooltipSupportingTextVariants = classVarianceAuthority.cva(["text-body-medium text-on-surface-variant"]);
|
|
8362
|
+
var richTooltipActionsVariants = classVarianceAuthority.cva(["flex items-center justify-start mt-3 -ml-2"]);
|
|
8331
8363
|
var Tooltip = React.forwardRef(
|
|
8332
8364
|
({ children, className, placement: _placement }, ref) => {
|
|
8333
|
-
const { isExiting, onAnimationEnd } = useTooltipAnimation();
|
|
8365
|
+
const { isExiting, onAnimationEnd, reducedMotion } = useTooltipAnimation();
|
|
8366
|
+
const animation = reducedMotion ? "none" : isExiting ? "exit" : "enter";
|
|
8334
8367
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8335
8368
|
"div",
|
|
8336
8369
|
{
|
|
8337
8370
|
ref,
|
|
8338
|
-
className: cn(tooltipVariants({
|
|
8371
|
+
className: cn(tooltipVariants({ animation }), className),
|
|
8339
8372
|
onAnimationEnd,
|
|
8340
8373
|
children
|
|
8341
8374
|
}
|
|
@@ -8345,17 +8378,18 @@ var Tooltip = React.forwardRef(
|
|
|
8345
8378
|
Tooltip.displayName = "Tooltip";
|
|
8346
8379
|
var RichTooltip = React.forwardRef(
|
|
8347
8380
|
({ title, children, action, className, placement: _placement }, ref) => {
|
|
8348
|
-
const { isExiting, onAnimationEnd } = useTooltipAnimation();
|
|
8381
|
+
const { isExiting, onAnimationEnd, reducedMotion } = useTooltipAnimation();
|
|
8382
|
+
const animation = reducedMotion ? "none" : isExiting ? "exit" : "enter";
|
|
8349
8383
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8350
8384
|
"div",
|
|
8351
8385
|
{
|
|
8352
8386
|
ref,
|
|
8353
|
-
className: cn(richTooltipVariants({
|
|
8387
|
+
className: cn(richTooltipVariants({ animation }), className),
|
|
8354
8388
|
onAnimationEnd,
|
|
8355
8389
|
children: [
|
|
8356
|
-
title && /* @__PURE__ */ jsxRuntime.jsx("p", { className:
|
|
8357
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className:
|
|
8358
|
-
action
|
|
8390
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: richTooltipTitleVariants(), children: title }),
|
|
8391
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: richTooltipSupportingTextVariants(), children }),
|
|
8392
|
+
action && /* @__PURE__ */ jsxRuntime.jsx("div", { className: richTooltipActionsVariants(), children: action })
|
|
8359
8393
|
]
|
|
8360
8394
|
}
|
|
8361
8395
|
);
|
|
@@ -9632,105 +9666,354 @@ var Badge = React.forwardRef(
|
|
|
9632
9666
|
}
|
|
9633
9667
|
);
|
|
9634
9668
|
Badge.displayName = "Badge";
|
|
9635
|
-
var splitButtonContainerVariants = classVarianceAuthority.cva(
|
|
9636
|
-
|
|
9669
|
+
var splitButtonContainerVariants = classVarianceAuthority.cva([
|
|
9670
|
+
"relative inline-flex items-stretch",
|
|
9671
|
+
"gap-0.5"
|
|
9672
|
+
// MD3 2dp gap between segments
|
|
9673
|
+
]);
|
|
9674
|
+
var splitButtonLeadingVariants = classVarianceAuthority.cva(
|
|
9675
|
+
[
|
|
9676
|
+
// Layout
|
|
9677
|
+
"group/sb-leading relative inline-flex items-center justify-center",
|
|
9678
|
+
"cursor-pointer select-none",
|
|
9679
|
+
// Shape — asymmetric corners via CSS variable
|
|
9680
|
+
"rounded-tl-full rounded-bl-full",
|
|
9681
|
+
"rounded-tr-[var(--sb-inner-radius,var(--radius-xs))]",
|
|
9682
|
+
"rounded-br-[var(--sb-inner-radius,var(--radius-xs))]",
|
|
9683
|
+
// Inner-corner morph — xs/sm/md defaults; lg/xl override in size variants below.
|
|
9684
|
+
// Specificity ladder: rest (0,0,0) < hover (0,1,0) < focus (0,2,0) < pressed (0,3,0)
|
|
9685
|
+
"[--sb-inner-radius:var(--radius-xs)]",
|
|
9686
|
+
"data-[hovered]:[--sb-inner-radius:var(--radius-sm)]",
|
|
9687
|
+
"data-[focus-visible]:data-[focus-visible]:[--sb-inner-radius:var(--radius-sm)]",
|
|
9688
|
+
// Pressed morphs stronger than hover/focus — tripled selector → (0,3,0)
|
|
9689
|
+
"data-[pressed]:data-[pressed]:data-[pressed]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9690
|
+
// Spatial transition for border-radius morphing
|
|
9691
|
+
"transition-[border-radius]",
|
|
9692
|
+
"duration-expressive-fast-spatial ease-expressive-fast-spatial",
|
|
9693
|
+
// Disabled — self-targeting
|
|
9694
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none"
|
|
9695
|
+
],
|
|
9637
9696
|
{
|
|
9638
9697
|
variants: {
|
|
9698
|
+
/**
|
|
9699
|
+
* Visual variant — controls container color, text color, and elevation.
|
|
9700
|
+
* State layer color is handled in splitButtonStateLayerVariants.
|
|
9701
|
+
*/
|
|
9639
9702
|
variant: {
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9703
|
+
/**
|
|
9704
|
+
* Filled — highest emphasis.
|
|
9705
|
+
* container=primary, label=on-primary
|
|
9706
|
+
* Elevation: 0 base → 1 hover → 0 focus/pressed
|
|
9707
|
+
*/
|
|
9708
|
+
filled: [
|
|
9709
|
+
"bg-primary text-on-primary shadow-none",
|
|
9710
|
+
"group-data-[hovered]/sb-leading:shadow-elevation-1",
|
|
9711
|
+
"group-data-[focus-visible]/sb-leading:shadow-none",
|
|
9712
|
+
"group-data-[pressed]/sb-leading:group-data-[pressed]/sb-leading:shadow-none",
|
|
9713
|
+
// Disabled
|
|
9714
|
+
"data-[disabled]:bg-on-surface/12 data-[disabled]:text-on-surface/38 data-[disabled]:shadow-none"
|
|
9715
|
+
],
|
|
9716
|
+
/**
|
|
9717
|
+
* Tonal — secondary emphasis.
|
|
9718
|
+
* container=secondary-container, label=on-secondary-container
|
|
9719
|
+
* Elevation: 0 base → 1 hover → 0 focus/pressed
|
|
9720
|
+
*/
|
|
9721
|
+
tonal: [
|
|
9722
|
+
"bg-secondary-container text-on-secondary-container shadow-none",
|
|
9723
|
+
"group-data-[hovered]/sb-leading:shadow-elevation-1",
|
|
9724
|
+
"group-data-[focus-visible]/sb-leading:shadow-none",
|
|
9725
|
+
"group-data-[pressed]/sb-leading:group-data-[pressed]/sb-leading:shadow-none",
|
|
9726
|
+
// Disabled
|
|
9727
|
+
"data-[disabled]:bg-on-surface/12 data-[disabled]:text-on-surface/38 data-[disabled]:shadow-none"
|
|
9728
|
+
],
|
|
9729
|
+
/**
|
|
9730
|
+
* Outlined — medium emphasis. Transparent with border.
|
|
9731
|
+
* container=transparent, border=outline, label=primary
|
|
9732
|
+
* Elevation: always 0
|
|
9733
|
+
*/
|
|
9734
|
+
outlined: [
|
|
9735
|
+
"bg-transparent border border-outline text-primary",
|
|
9736
|
+
// Disabled
|
|
9737
|
+
"data-[disabled]:border-on-surface/12 data-[disabled]:text-on-surface/38"
|
|
9738
|
+
],
|
|
9739
|
+
/**
|
|
9740
|
+
* Elevated — uses surface-container-low with a level-1 shadow base.
|
|
9741
|
+
* container=surface-container-low, label=primary
|
|
9742
|
+
* Elevation: 1 base → 2 hover → 1 focus/pressed
|
|
9743
|
+
*/
|
|
9744
|
+
elevated: [
|
|
9745
|
+
"bg-surface-container-low text-primary shadow-elevation-1",
|
|
9746
|
+
"group-data-[hovered]/sb-leading:shadow-elevation-2",
|
|
9747
|
+
"group-data-[focus-visible]/sb-leading:shadow-elevation-1",
|
|
9748
|
+
"group-data-[pressed]/sb-leading:group-data-[pressed]/sb-leading:shadow-elevation-1",
|
|
9749
|
+
// Disabled
|
|
9750
|
+
"data-[disabled]:bg-on-surface/12 data-[disabled]:text-on-surface/38 data-[disabled]:shadow-none"
|
|
9751
|
+
]
|
|
9643
9752
|
},
|
|
9753
|
+
/**
|
|
9754
|
+
* Size — governs height, horizontal padding, typography, and inner-corner rest/morph values.
|
|
9755
|
+
* lg/xl need larger rest radii so their morph steps differ from xs/sm/md.
|
|
9756
|
+
*/
|
|
9644
9757
|
size: {
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9758
|
+
xs: "h-8 pl-4 pr-3 text-label-large",
|
|
9759
|
+
sm: "h-10 pl-6 pr-4 text-label-large",
|
|
9760
|
+
md: "h-14 pl-8 pr-6 text-title-medium",
|
|
9761
|
+
lg: [
|
|
9762
|
+
"h-24 pl-10 pr-8 text-headline-small",
|
|
9763
|
+
// lg rest=sm, hover/focus→lg, pressed→xl
|
|
9764
|
+
"[--sb-inner-radius:var(--radius-sm)]",
|
|
9765
|
+
"data-[hovered]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9766
|
+
"data-[focus-visible]:data-[focus-visible]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9767
|
+
"data-[pressed]:data-[pressed]:data-[pressed]:[--sb-inner-radius:var(--radius-xl)]"
|
|
9768
|
+
],
|
|
9769
|
+
xl: [
|
|
9770
|
+
"h-[8.5rem] pl-12 pr-10 text-headline-large",
|
|
9771
|
+
// xl rest=md, hover/focus→lg, pressed→xl
|
|
9772
|
+
"[--sb-inner-radius:var(--radius-md)]",
|
|
9773
|
+
"data-[hovered]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9774
|
+
"data-[focus-visible]:data-[focus-visible]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9775
|
+
"data-[pressed]:data-[pressed]:data-[pressed]:[--sb-inner-radius:var(--radius-xl)]"
|
|
9776
|
+
]
|
|
9652
9777
|
}
|
|
9653
9778
|
},
|
|
9654
9779
|
defaultVariants: {
|
|
9655
9780
|
variant: "filled",
|
|
9656
|
-
size: "
|
|
9657
|
-
isDisabled: false
|
|
9781
|
+
size: "sm"
|
|
9658
9782
|
}
|
|
9659
9783
|
}
|
|
9660
9784
|
);
|
|
9661
|
-
var
|
|
9785
|
+
var splitButtonTrailingVariants = classVarianceAuthority.cva(
|
|
9662
9786
|
[
|
|
9663
|
-
|
|
9664
|
-
"
|
|
9665
|
-
"
|
|
9787
|
+
// Layout — square so that selected (rounded-full on all corners) = perfect circle
|
|
9788
|
+
"group/sb-trailing relative inline-flex items-center justify-center shrink-0",
|
|
9789
|
+
"cursor-pointer select-none",
|
|
9790
|
+
// Shape — asymmetric corners, inner on the left side
|
|
9791
|
+
"rounded-tr-full rounded-br-full",
|
|
9792
|
+
"rounded-tl-[var(--sb-inner-radius,var(--radius-xs))]",
|
|
9793
|
+
"rounded-bl-[var(--sb-inner-radius,var(--radius-xs))]",
|
|
9794
|
+
// Inner-corner morph — xs/sm/md defaults; lg/xl override in size variants below.
|
|
9795
|
+
// Specificity ladder: rest (0,0,0) < hover (0,1,0) < focus (0,2,0) < pressed (0,3,0) < selected (0,4,0)
|
|
9796
|
+
"[--sb-inner-radius:var(--radius-xs)]",
|
|
9797
|
+
"data-[hovered]:[--sb-inner-radius:var(--radius-sm)]",
|
|
9798
|
+
"data-[focus-visible]:data-[focus-visible]:[--sb-inner-radius:var(--radius-sm)]",
|
|
9799
|
+
// Pressed morphs stronger than hover/focus — tripled → (0,3,0)
|
|
9800
|
+
"data-[pressed]:data-[pressed]:data-[pressed]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9801
|
+
// Selected (menu open) → full circle; quadrupled → (0,4,0) always wins
|
|
9802
|
+
"data-[selected]:data-[selected]:data-[selected]:data-[selected]:[--sb-inner-radius:var(--radius-full)]",
|
|
9803
|
+
// Spatial transition for border-radius morphing
|
|
9804
|
+
"transition-[border-radius]",
|
|
9805
|
+
"duration-expressive-fast-spatial ease-expressive-fast-spatial",
|
|
9806
|
+
// Disabled — self-targeting
|
|
9807
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none"
|
|
9666
9808
|
],
|
|
9667
9809
|
{
|
|
9668
9810
|
variants: {
|
|
9669
9811
|
variant: {
|
|
9670
|
-
filled:
|
|
9671
|
-
|
|
9672
|
-
|
|
9812
|
+
filled: [
|
|
9813
|
+
"bg-primary text-on-primary shadow-none",
|
|
9814
|
+
"group-data-[hovered]/sb-trailing:shadow-elevation-1",
|
|
9815
|
+
"group-data-[focus-visible]/sb-trailing:shadow-none",
|
|
9816
|
+
"group-data-[pressed]/sb-trailing:group-data-[pressed]/sb-trailing:shadow-none",
|
|
9817
|
+
"data-[disabled]:bg-on-surface/12 data-[disabled]:text-on-surface/38 data-[disabled]:shadow-none"
|
|
9818
|
+
],
|
|
9819
|
+
tonal: [
|
|
9820
|
+
"bg-secondary-container text-on-secondary-container shadow-none",
|
|
9821
|
+
"group-data-[hovered]/sb-trailing:shadow-elevation-1",
|
|
9822
|
+
"group-data-[focus-visible]/sb-trailing:shadow-none",
|
|
9823
|
+
"group-data-[pressed]/sb-trailing:group-data-[pressed]/sb-trailing:shadow-none",
|
|
9824
|
+
"data-[disabled]:bg-on-surface/12 data-[disabled]:text-on-surface/38 data-[disabled]:shadow-none"
|
|
9825
|
+
],
|
|
9826
|
+
outlined: [
|
|
9827
|
+
"bg-transparent border border-outline text-primary",
|
|
9828
|
+
"data-[disabled]:border-on-surface/12 data-[disabled]:text-on-surface/38"
|
|
9829
|
+
],
|
|
9830
|
+
elevated: [
|
|
9831
|
+
"bg-surface-container-low text-primary shadow-elevation-1",
|
|
9832
|
+
"group-data-[hovered]/sb-trailing:shadow-elevation-2",
|
|
9833
|
+
"group-data-[focus-visible]/sb-trailing:shadow-elevation-1",
|
|
9834
|
+
"group-data-[pressed]/sb-trailing:group-data-[pressed]/sb-trailing:shadow-elevation-1",
|
|
9835
|
+
"data-[disabled]:bg-on-surface/12 data-[disabled]:text-on-surface/38 data-[disabled]:shadow-none"
|
|
9836
|
+
]
|
|
9673
9837
|
},
|
|
9674
9838
|
size: {
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9839
|
+
// Square dimensions (width = height) so selected state = perfect circle.
|
|
9840
|
+
// Per-size inner-radius rest/morph values mirror the leading segment.
|
|
9841
|
+
xs: "h-8 w-8",
|
|
9842
|
+
sm: "h-10 w-10",
|
|
9843
|
+
md: "h-14 w-14",
|
|
9844
|
+
lg: [
|
|
9845
|
+
"h-24 w-24",
|
|
9846
|
+
// lg rest=sm, hover/focus→lg, pressed→xl; selected→full handled in base classes
|
|
9847
|
+
"[--sb-inner-radius:var(--radius-sm)]",
|
|
9848
|
+
"data-[hovered]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9849
|
+
"data-[focus-visible]:data-[focus-visible]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9850
|
+
"data-[pressed]:data-[pressed]:data-[pressed]:[--sb-inner-radius:var(--radius-xl)]"
|
|
9851
|
+
],
|
|
9852
|
+
xl: [
|
|
9853
|
+
"h-[8.5rem] w-[8.5rem]",
|
|
9854
|
+
// xl rest=md, hover/focus→lg, pressed→xl; selected→full handled in base classes
|
|
9855
|
+
"[--sb-inner-radius:var(--radius-md)]",
|
|
9856
|
+
"data-[hovered]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9857
|
+
"data-[focus-visible]:data-[focus-visible]:[--sb-inner-radius:var(--radius-lg)]",
|
|
9858
|
+
"data-[pressed]:data-[pressed]:data-[pressed]:[--sb-inner-radius:var(--radius-xl)]"
|
|
9859
|
+
]
|
|
9678
9860
|
}
|
|
9679
9861
|
},
|
|
9680
9862
|
defaultVariants: {
|
|
9681
9863
|
variant: "filled",
|
|
9682
|
-
size: "
|
|
9864
|
+
size: "sm"
|
|
9683
9865
|
}
|
|
9684
9866
|
}
|
|
9685
9867
|
);
|
|
9686
|
-
var
|
|
9868
|
+
var splitButtonStateLayerVariants = classVarianceAuthority.cva(
|
|
9687
9869
|
[
|
|
9688
|
-
"
|
|
9689
|
-
"
|
|
9690
|
-
"focus-visible:outline-primary focus-visible:outline-2 focus-visible:outline-offset-2"
|
|
9870
|
+
"absolute inset-0 rounded-[inherit] overflow-hidden pointer-events-none opacity-0",
|
|
9871
|
+
"transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects"
|
|
9691
9872
|
],
|
|
9692
9873
|
{
|
|
9693
9874
|
variants: {
|
|
9694
9875
|
variant: {
|
|
9695
|
-
filled: "
|
|
9696
|
-
tonal: "
|
|
9697
|
-
outlined: "
|
|
9876
|
+
filled: "bg-on-primary",
|
|
9877
|
+
tonal: "bg-on-secondary-container",
|
|
9878
|
+
outlined: "bg-primary",
|
|
9879
|
+
elevated: "bg-primary"
|
|
9698
9880
|
},
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9881
|
+
/**
|
|
9882
|
+
* groupScope identifies which segment this state layer belongs to so it
|
|
9883
|
+
* reads from the correct group-data-[x]/<scope> selectors.
|
|
9884
|
+
*/
|
|
9885
|
+
groupScope: {
|
|
9886
|
+
leading: [
|
|
9887
|
+
"group-data-[hovered]/sb-leading:opacity-8",
|
|
9888
|
+
"group-data-[focus-visible]/sb-leading:opacity-10",
|
|
9889
|
+
"group-data-[pressed]/sb-leading:group-data-[pressed]/sb-leading:opacity-10",
|
|
9890
|
+
"group-data-[disabled]/sb-leading:hidden"
|
|
9891
|
+
],
|
|
9892
|
+
trailing: [
|
|
9893
|
+
"group-data-[hovered]/sb-trailing:opacity-8",
|
|
9894
|
+
"group-data-[focus-visible]/sb-trailing:opacity-10",
|
|
9895
|
+
"group-data-[pressed]/sb-trailing:group-data-[pressed]/sb-trailing:opacity-10",
|
|
9896
|
+
"group-data-[disabled]/sb-trailing:hidden"
|
|
9897
|
+
]
|
|
9703
9898
|
}
|
|
9704
9899
|
},
|
|
9705
9900
|
defaultVariants: {
|
|
9706
9901
|
variant: "filled",
|
|
9707
|
-
|
|
9902
|
+
groupScope: "leading"
|
|
9708
9903
|
}
|
|
9709
9904
|
}
|
|
9710
9905
|
);
|
|
9906
|
+
var splitButtonFocusRingVariants = classVarianceAuthority.cva(
|
|
9907
|
+
[
|
|
9908
|
+
"pointer-events-none absolute inset-[-3px]",
|
|
9909
|
+
"outline outline-2 outline-offset-0 outline-secondary",
|
|
9910
|
+
"transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
|
|
9911
|
+
"opacity-0"
|
|
9912
|
+
],
|
|
9913
|
+
{
|
|
9914
|
+
variants: {
|
|
9915
|
+
/**
|
|
9916
|
+
* Corner shape must match the segment it wraps.
|
|
9917
|
+
* Leading: full-left, inner-right follows --sb-inner-radius.
|
|
9918
|
+
* Trailing: full-right, inner-left follows --sb-inner-radius.
|
|
9919
|
+
*/
|
|
9920
|
+
groupScope: {
|
|
9921
|
+
leading: [
|
|
9922
|
+
"rounded-tl-full rounded-bl-full",
|
|
9923
|
+
"rounded-tr-[calc(var(--sb-inner-radius,var(--radius-xs))+3px)]",
|
|
9924
|
+
"rounded-br-[calc(var(--sb-inner-radius,var(--radius-xs))+3px)]",
|
|
9925
|
+
"group-data-[focus-visible]/sb-leading:opacity-100"
|
|
9926
|
+
],
|
|
9927
|
+
trailing: [
|
|
9928
|
+
"rounded-tr-full rounded-br-full",
|
|
9929
|
+
"rounded-tl-[calc(var(--sb-inner-radius,var(--radius-xs))+3px)]",
|
|
9930
|
+
"rounded-bl-[calc(var(--sb-inner-radius,var(--radius-xs))+3px)]",
|
|
9931
|
+
"group-data-[focus-visible]/sb-trailing:opacity-100"
|
|
9932
|
+
]
|
|
9933
|
+
}
|
|
9934
|
+
},
|
|
9935
|
+
defaultVariants: { groupScope: "leading" }
|
|
9936
|
+
}
|
|
9937
|
+
);
|
|
9938
|
+
var splitButtonLabelVariants = classVarianceAuthority.cva(["relative z-10 inline-flex items-center"]);
|
|
9939
|
+
var splitButtonIconVariants = classVarianceAuthority.cva(
|
|
9940
|
+
[
|
|
9941
|
+
"relative z-10 inline-flex shrink-0 items-center justify-center",
|
|
9942
|
+
// Spatial spring motion for the optical-offset translate
|
|
9943
|
+
"transition-transform duration-spring-standard-fast-spatial ease-spring-standard-fast-spatial",
|
|
9944
|
+
// Reset offset when the trailing segment is in selected state (menu open)
|
|
9945
|
+
"group-data-[selected]/sb-trailing:translate-x-0"
|
|
9946
|
+
],
|
|
9947
|
+
{
|
|
9948
|
+
variants: {
|
|
9949
|
+
size: {
|
|
9950
|
+
// Include per-size icon dimension + unselected optical offset
|
|
9951
|
+
xs: ["size-5", "-translate-x-px"],
|
|
9952
|
+
sm: ["size-5", "-translate-x-px"],
|
|
9953
|
+
md: ["size-6", "-translate-x-0.5"],
|
|
9954
|
+
lg: ["size-8", "-translate-x-[3px]"],
|
|
9955
|
+
xl: ["size-10", "-translate-x-[6px]"]
|
|
9956
|
+
}
|
|
9957
|
+
},
|
|
9958
|
+
defaultVariants: { size: "sm" }
|
|
9959
|
+
}
|
|
9960
|
+
);
|
|
9961
|
+
var splitButtonMenuVariants = classVarianceAuthority.cva([
|
|
9962
|
+
"absolute top-full right-0 z-50 mt-1 min-w-40",
|
|
9963
|
+
"bg-surface-container rounded-md py-2",
|
|
9964
|
+
"shadow-elevation-2",
|
|
9965
|
+
"animate-md-scale-in"
|
|
9966
|
+
]);
|
|
9967
|
+
var splitButtonMenuItemVariants = classVarianceAuthority.cva(
|
|
9968
|
+
[
|
|
9969
|
+
"text-body-large text-on-surface cursor-pointer px-4 py-2",
|
|
9970
|
+
"hover:bg-on-surface/8",
|
|
9971
|
+
"focus:bg-on-surface/10 focus:outline-none"
|
|
9972
|
+
],
|
|
9973
|
+
{
|
|
9974
|
+
variants: {
|
|
9975
|
+
isDisabled: {
|
|
9976
|
+
true: "text-on-surface/38 pointer-events-none cursor-not-allowed",
|
|
9977
|
+
false: ""
|
|
9978
|
+
}
|
|
9979
|
+
},
|
|
9980
|
+
defaultVariants: { isDisabled: false }
|
|
9981
|
+
}
|
|
9982
|
+
);
|
|
9711
9983
|
var splitButtonVariants = {
|
|
9712
9984
|
container: splitButtonContainerVariants,
|
|
9713
|
-
|
|
9714
|
-
|
|
9985
|
+
leading: splitButtonLeadingVariants,
|
|
9986
|
+
trailing: splitButtonTrailingVariants,
|
|
9987
|
+
stateLayer: splitButtonStateLayerVariants,
|
|
9988
|
+
focusRing: splitButtonFocusRingVariants,
|
|
9989
|
+
label: splitButtonLabelVariants,
|
|
9990
|
+
icon: splitButtonIconVariants,
|
|
9991
|
+
menu: splitButtonMenuVariants,
|
|
9992
|
+
menuItem: splitButtonMenuItemVariants
|
|
9715
9993
|
};
|
|
9716
|
-
var ChevronIcon = ({
|
|
9994
|
+
var ChevronIcon = ({
|
|
9995
|
+
isOpen,
|
|
9996
|
+
reducedMotion
|
|
9997
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9717
9998
|
"svg",
|
|
9718
9999
|
{
|
|
9719
10000
|
"aria-hidden": "true",
|
|
9720
10001
|
"data-testid": "split-button-chevron",
|
|
9721
|
-
width: "18",
|
|
9722
|
-
height: "18",
|
|
9723
10002
|
viewBox: "0 0 24 24",
|
|
9724
10003
|
fill: "none",
|
|
9725
10004
|
xmlns: "http://www.w3.org/2000/svg",
|
|
9726
|
-
className: cn(
|
|
10005
|
+
className: cn(
|
|
10006
|
+
"size-full",
|
|
10007
|
+
!reducedMotion && "duration-expressive-fast-spatial ease-expressive-fast-spatial transition-transform",
|
|
10008
|
+
isOpen && "rotate-180"
|
|
10009
|
+
),
|
|
9727
10010
|
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 10l5 5 5-5H7z", fill: "currentColor" })
|
|
9728
10011
|
}
|
|
9729
10012
|
);
|
|
9730
10013
|
var SplitButton = React.forwardRef(
|
|
9731
10014
|
({
|
|
9732
10015
|
variant = "filled",
|
|
9733
|
-
size = "
|
|
10016
|
+
size = "sm",
|
|
9734
10017
|
primaryLabel,
|
|
9735
10018
|
onPrimaryAction,
|
|
9736
10019
|
items,
|
|
@@ -9738,32 +10021,73 @@ var SplitButton = React.forwardRef(
|
|
|
9738
10021
|
"aria-label": ariaLabel,
|
|
9739
10022
|
className
|
|
9740
10023
|
}, forwardedRef) => {
|
|
9741
|
-
const
|
|
9742
|
-
const
|
|
10024
|
+
const leadingRef = React.useRef(null);
|
|
10025
|
+
const trailingRef = React.useRef(null);
|
|
9743
10026
|
const menuRef = React.useRef(null);
|
|
10027
|
+
const reducedMotion = useReducedMotion();
|
|
9744
10028
|
const menuState = reactStately.useMenuTriggerState({});
|
|
9745
|
-
const
|
|
10029
|
+
const [isLeadingPressed, setIsLeadingPressed] = React.useState(false);
|
|
10030
|
+
const handleLeadingPressStart = React.useCallback(() => setIsLeadingPressed(true), []);
|
|
10031
|
+
const handleLeadingPressEnd = React.useCallback(() => setIsLeadingPressed(false), []);
|
|
10032
|
+
const { isHovered: isLeadingHovered, hoverProps: leadingHoverProps } = reactAria.useHover({
|
|
10033
|
+
isDisabled
|
|
10034
|
+
});
|
|
10035
|
+
const { isFocusVisible: isLeadingFocusVisible, focusProps: leadingFocusProps } = reactAria.useFocusRing();
|
|
10036
|
+
const { buttonProps: leadingButtonProps } = reactAria.useButton(
|
|
9746
10037
|
{
|
|
9747
10038
|
isDisabled,
|
|
9748
10039
|
onPress: onPrimaryAction,
|
|
10040
|
+
onPressStart: handleLeadingPressStart,
|
|
10041
|
+
onPressEnd: handleLeadingPressEnd,
|
|
9749
10042
|
elementType: "button"
|
|
9750
10043
|
},
|
|
9751
|
-
|
|
10044
|
+
leadingRef
|
|
9752
10045
|
);
|
|
9753
|
-
const
|
|
10046
|
+
const [isTrailingPressed, setIsTrailingPressed] = React.useState(false);
|
|
10047
|
+
const handleTrailingPressStart = React.useCallback(() => setIsTrailingPressed(true), []);
|
|
10048
|
+
const handleTrailingPressEnd = React.useCallback(() => setIsTrailingPressed(false), []);
|
|
10049
|
+
const { isHovered: isTrailingHovered, hoverProps: trailingHoverProps } = reactAria.useHover({
|
|
10050
|
+
isDisabled
|
|
10051
|
+
});
|
|
10052
|
+
const { isFocusVisible: isTrailingFocusVisible, focusProps: trailingFocusProps } = reactAria.useFocusRing();
|
|
10053
|
+
const handleTrailingPress = React.useCallback(() => {
|
|
9754
10054
|
if (menuState.isOpen) {
|
|
9755
10055
|
menuState.close();
|
|
9756
10056
|
} else {
|
|
9757
10057
|
menuState.open();
|
|
9758
10058
|
}
|
|
9759
10059
|
}, [menuState]);
|
|
9760
|
-
const { buttonProps:
|
|
10060
|
+
const { buttonProps: trailingButtonProps } = reactAria.useButton(
|
|
9761
10061
|
{
|
|
9762
10062
|
isDisabled,
|
|
9763
|
-
onPress:
|
|
10063
|
+
onPress: handleTrailingPress,
|
|
10064
|
+
onPressStart: handleTrailingPressStart,
|
|
10065
|
+
onPressEnd: handleTrailingPressEnd,
|
|
9764
10066
|
elementType: "button"
|
|
9765
10067
|
},
|
|
9766
|
-
|
|
10068
|
+
trailingRef
|
|
10069
|
+
);
|
|
10070
|
+
const { onMouseDown: handleLeadingRipple, ripples: leadingRipples } = useRipple({
|
|
10071
|
+
disabled: isDisabled
|
|
10072
|
+
});
|
|
10073
|
+
const { onMouseDown: handleTrailingRipple, ripples: trailingRipples } = useRipple({
|
|
10074
|
+
disabled: isDisabled
|
|
10075
|
+
});
|
|
10076
|
+
const onLeadingMouseDown = React.useCallback(
|
|
10077
|
+
(e) => {
|
|
10078
|
+
const ariaHandler = leadingButtonProps.onMouseDown;
|
|
10079
|
+
ariaHandler?.(e);
|
|
10080
|
+
handleLeadingRipple(e);
|
|
10081
|
+
},
|
|
10082
|
+
[leadingButtonProps, handleLeadingRipple]
|
|
10083
|
+
);
|
|
10084
|
+
const onTrailingMouseDown = React.useCallback(
|
|
10085
|
+
(e) => {
|
|
10086
|
+
const ariaHandler = trailingButtonProps.onMouseDown;
|
|
10087
|
+
ariaHandler?.(e);
|
|
10088
|
+
handleTrailingRipple(e);
|
|
10089
|
+
},
|
|
10090
|
+
[trailingButtonProps, handleTrailingRipple]
|
|
9767
10091
|
);
|
|
9768
10092
|
const handleMenuItemSelect = React.useCallback(
|
|
9769
10093
|
(item) => {
|
|
@@ -9779,13 +10103,11 @@ var SplitButton = React.forwardRef(
|
|
|
9779
10103
|
const handleGlobalKeyDown = (e) => {
|
|
9780
10104
|
if (e.key === "Escape") {
|
|
9781
10105
|
menuState.close();
|
|
9782
|
-
|
|
10106
|
+
trailingRef.current?.focus();
|
|
9783
10107
|
}
|
|
9784
10108
|
};
|
|
9785
10109
|
document.addEventListener("keydown", handleGlobalKeyDown);
|
|
9786
|
-
return () =>
|
|
9787
|
-
document.removeEventListener("keydown", handleGlobalKeyDown);
|
|
9788
|
-
};
|
|
10110
|
+
return () => document.removeEventListener("keydown", handleGlobalKeyDown);
|
|
9789
10111
|
}, [menuState, menuState.isOpen]);
|
|
9790
10112
|
const handleMenuKeyDown = React.useCallback(
|
|
9791
10113
|
(e) => {
|
|
@@ -9818,7 +10140,7 @@ var SplitButton = React.forwardRef(
|
|
|
9818
10140
|
}
|
|
9819
10141
|
case "Escape": {
|
|
9820
10142
|
menuState.close();
|
|
9821
|
-
|
|
10143
|
+
trailingRef.current?.focus();
|
|
9822
10144
|
break;
|
|
9823
10145
|
}
|
|
9824
10146
|
}
|
|
@@ -9843,28 +10165,6 @@ var SplitButton = React.forwardRef(
|
|
|
9843
10165
|
},
|
|
9844
10166
|
[menuState]
|
|
9845
10167
|
);
|
|
9846
|
-
const { onMouseDown: handlePrimaryRipple, ripples: primaryRipples } = useRipple({
|
|
9847
|
-
disabled: isDisabled
|
|
9848
|
-
});
|
|
9849
|
-
const { onMouseDown: handleDropdownRipple, ripples: dropdownRipples } = useRipple({
|
|
9850
|
-
disabled: isDisabled
|
|
9851
|
-
});
|
|
9852
|
-
const onPrimaryMouseDown = React.useCallback(
|
|
9853
|
-
(e) => {
|
|
9854
|
-
const ariaHandler = primaryButtonProps.onMouseDown;
|
|
9855
|
-
ariaHandler?.(e);
|
|
9856
|
-
handlePrimaryRipple(e);
|
|
9857
|
-
},
|
|
9858
|
-
[primaryButtonProps, handlePrimaryRipple]
|
|
9859
|
-
);
|
|
9860
|
-
const onDropdownMouseDown = React.useCallback(
|
|
9861
|
-
(e) => {
|
|
9862
|
-
const ariaHandler = dropdownButtonProps.onMouseDown;
|
|
9863
|
-
ariaHandler?.(e);
|
|
9864
|
-
handleDropdownRipple(e);
|
|
9865
|
-
},
|
|
9866
|
-
[dropdownButtonProps, handleDropdownRipple]
|
|
9867
|
-
);
|
|
9868
10168
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative inline-flex", children: [
|
|
9869
10169
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9870
10170
|
"div",
|
|
@@ -9872,63 +10172,81 @@ var SplitButton = React.forwardRef(
|
|
|
9872
10172
|
ref: forwardedRef,
|
|
9873
10173
|
role: "group",
|
|
9874
10174
|
"aria-label": ariaLabel ?? `${primaryLabel} split button`,
|
|
9875
|
-
className: cn(splitButtonContainerVariants(
|
|
10175
|
+
className: cn(splitButtonContainerVariants(), className),
|
|
9876
10176
|
children: [
|
|
9877
10177
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9878
10178
|
"button",
|
|
9879
10179
|
{
|
|
9880
|
-
...
|
|
9881
|
-
ref:
|
|
10180
|
+
...reactAria.mergeProps(leadingButtonProps, leadingHoverProps, leadingFocusProps),
|
|
10181
|
+
ref: leadingRef,
|
|
9882
10182
|
type: "button",
|
|
9883
10183
|
tabIndex: isDisabled ? -1 : 0,
|
|
9884
|
-
onMouseDown:
|
|
9885
|
-
|
|
10184
|
+
onMouseDown: onLeadingMouseDown,
|
|
10185
|
+
...getInteractionDataAttributes({
|
|
10186
|
+
isHovered: isLeadingHovered,
|
|
10187
|
+
isFocusVisible: isLeadingFocusVisible,
|
|
10188
|
+
isPressed: isLeadingPressed,
|
|
10189
|
+
isDisabled
|
|
10190
|
+
}),
|
|
10191
|
+
className: splitButtonLeadingVariants({ variant, size }),
|
|
9886
10192
|
children: [
|
|
9887
10193
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9888
10194
|
"span",
|
|
9889
10195
|
{
|
|
9890
10196
|
"data-testid": "primary-state-layer",
|
|
9891
10197
|
"aria-hidden": "true",
|
|
9892
|
-
className:
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
10198
|
+
className: splitButtonStateLayerVariants({ variant, groupScope: "leading" })
|
|
10199
|
+
}
|
|
10200
|
+
),
|
|
10201
|
+
leadingRipples,
|
|
10202
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10203
|
+
"span",
|
|
10204
|
+
{
|
|
10205
|
+
"aria-hidden": "true",
|
|
10206
|
+
className: splitButtonFocusRingVariants({ groupScope: "leading" })
|
|
9897
10207
|
}
|
|
9898
10208
|
),
|
|
9899
|
-
|
|
9900
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative z-10", children: primaryLabel })
|
|
10209
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: splitButtonLabelVariants(), children: primaryLabel })
|
|
9901
10210
|
]
|
|
9902
10211
|
}
|
|
9903
10212
|
),
|
|
9904
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "split-button-divider", "aria-hidden": "true" }),
|
|
9905
10213
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9906
10214
|
"button",
|
|
9907
10215
|
{
|
|
9908
|
-
...
|
|
9909
|
-
ref:
|
|
10216
|
+
...reactAria.mergeProps(trailingButtonProps, trailingHoverProps, trailingFocusProps),
|
|
10217
|
+
ref: trailingRef,
|
|
9910
10218
|
type: "button",
|
|
9911
10219
|
tabIndex: isDisabled ? -1 : 0,
|
|
9912
10220
|
"aria-haspopup": "menu",
|
|
9913
10221
|
"aria-expanded": menuState.isOpen,
|
|
9914
10222
|
"aria-label": `${primaryLabel} options, expand`,
|
|
9915
|
-
onMouseDown:
|
|
9916
|
-
|
|
10223
|
+
onMouseDown: onTrailingMouseDown,
|
|
10224
|
+
...getInteractionDataAttributes({
|
|
10225
|
+
isHovered: isTrailingHovered,
|
|
10226
|
+
isFocusVisible: isTrailingFocusVisible,
|
|
10227
|
+
isPressed: isTrailingPressed,
|
|
10228
|
+
isSelected: menuState.isOpen,
|
|
10229
|
+
isDisabled
|
|
10230
|
+
}),
|
|
10231
|
+
className: splitButtonTrailingVariants({ variant, size }),
|
|
9917
10232
|
children: [
|
|
9918
10233
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9919
10234
|
"span",
|
|
9920
10235
|
{
|
|
9921
10236
|
"data-testid": "dropdown-state-layer",
|
|
9922
10237
|
"aria-hidden": "true",
|
|
9923
|
-
className:
|
|
9924
|
-
"pointer-events-none absolute inset-0 bg-current opacity-0",
|
|
9925
|
-
"duration-spring-standard-fast-effects ease-spring-standard-fast-effects transition-opacity",
|
|
9926
|
-
"group-hover/dropdown:opacity-8"
|
|
9927
|
-
)
|
|
10238
|
+
className: splitButtonStateLayerVariants({ variant, groupScope: "trailing" })
|
|
9928
10239
|
}
|
|
9929
10240
|
),
|
|
9930
|
-
|
|
9931
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10241
|
+
trailingRipples,
|
|
10242
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10243
|
+
"span",
|
|
10244
|
+
{
|
|
10245
|
+
"aria-hidden": "true",
|
|
10246
|
+
className: splitButtonFocusRingVariants({ groupScope: "trailing" })
|
|
10247
|
+
}
|
|
10248
|
+
),
|
|
10249
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: splitButtonIconVariants({ size }), children: /* @__PURE__ */ jsxRuntime.jsx(ChevronIcon, { isOpen: menuState.isOpen, reducedMotion }) })
|
|
9932
10250
|
]
|
|
9933
10251
|
}
|
|
9934
10252
|
)
|
|
@@ -9942,10 +10260,7 @@ var SplitButton = React.forwardRef(
|
|
|
9942
10260
|
role: "menu",
|
|
9943
10261
|
"aria-label": `${primaryLabel} options`,
|
|
9944
10262
|
onKeyDown: handleMenuKeyDown,
|
|
9945
|
-
className:
|
|
9946
|
-
"bg-surface-container absolute top-full right-0 z-50 mt-1 min-w-40 rounded-md py-2",
|
|
9947
|
-
"shadow-elevation-2"
|
|
9948
|
-
),
|
|
10263
|
+
className: splitButtonMenuVariants(),
|
|
9949
10264
|
children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9950
10265
|
"li",
|
|
9951
10266
|
{
|
|
@@ -9954,11 +10269,7 @@ var SplitButton = React.forwardRef(
|
|
|
9954
10269
|
"aria-disabled": item.isDisabled ?? void 0,
|
|
9955
10270
|
onClick: () => handleMenuItemSelect(item),
|
|
9956
10271
|
onKeyDown: (e) => handleMenuItemKeyDown(e, item),
|
|
9957
|
-
className:
|
|
9958
|
-
"text-body-large text-on-surface cursor-pointer px-4 py-2",
|
|
9959
|
-
"hover:bg-on-surface/8",
|
|
9960
|
-
item.isDisabled && "text-on-surface/38 pointer-events-none"
|
|
9961
|
-
),
|
|
10272
|
+
className: splitButtonMenuItemVariants({ isDisabled: item.isDisabled ?? false }),
|
|
9962
10273
|
children: item.label
|
|
9963
10274
|
},
|
|
9964
10275
|
item.label
|
|
@@ -9978,32 +10289,32 @@ var SplitButtonHeadless = React.forwardRef(
|
|
|
9978
10289
|
"aria-label": ariaLabel,
|
|
9979
10290
|
className
|
|
9980
10291
|
}, forwardedRef) => {
|
|
9981
|
-
const
|
|
9982
|
-
const
|
|
10292
|
+
const leadingRef = React.useRef(null);
|
|
10293
|
+
const trailingRef = React.useRef(null);
|
|
9983
10294
|
const menuRef = React.useRef(null);
|
|
9984
10295
|
const menuState = reactStately.useMenuTriggerState({});
|
|
9985
|
-
const { buttonProps:
|
|
10296
|
+
const { buttonProps: leadingButtonProps } = reactAria.useButton(
|
|
9986
10297
|
{
|
|
9987
10298
|
isDisabled,
|
|
9988
10299
|
onPress: onPrimaryAction,
|
|
9989
10300
|
elementType: "button"
|
|
9990
10301
|
},
|
|
9991
|
-
|
|
10302
|
+
leadingRef
|
|
9992
10303
|
);
|
|
9993
|
-
const
|
|
10304
|
+
const handleTrailingPress = React.useCallback(() => {
|
|
9994
10305
|
if (menuState.isOpen) {
|
|
9995
10306
|
menuState.close();
|
|
9996
10307
|
} else {
|
|
9997
10308
|
menuState.open();
|
|
9998
10309
|
}
|
|
9999
10310
|
}, [menuState]);
|
|
10000
|
-
const { buttonProps:
|
|
10311
|
+
const { buttonProps: trailingButtonProps } = reactAria.useButton(
|
|
10001
10312
|
{
|
|
10002
10313
|
isDisabled,
|
|
10003
|
-
onPress:
|
|
10314
|
+
onPress: handleTrailingPress,
|
|
10004
10315
|
elementType: "button"
|
|
10005
10316
|
},
|
|
10006
|
-
|
|
10317
|
+
trailingRef
|
|
10007
10318
|
);
|
|
10008
10319
|
const handleMenuItemSelect = React.useCallback(
|
|
10009
10320
|
(item) => {
|
|
@@ -10019,13 +10330,11 @@ var SplitButtonHeadless = React.forwardRef(
|
|
|
10019
10330
|
const handleGlobalKeyDown = (e) => {
|
|
10020
10331
|
if (e.key === "Escape") {
|
|
10021
10332
|
menuState.close();
|
|
10022
|
-
|
|
10333
|
+
trailingRef.current?.focus();
|
|
10023
10334
|
}
|
|
10024
10335
|
};
|
|
10025
10336
|
document.addEventListener("keydown", handleGlobalKeyDown);
|
|
10026
|
-
return () =>
|
|
10027
|
-
document.removeEventListener("keydown", handleGlobalKeyDown);
|
|
10028
|
-
};
|
|
10337
|
+
return () => document.removeEventListener("keydown", handleGlobalKeyDown);
|
|
10029
10338
|
}, [menuState, menuState.isOpen]);
|
|
10030
10339
|
const handleMenuKeyDown = React.useCallback(
|
|
10031
10340
|
(e) => {
|
|
@@ -10058,7 +10367,7 @@ var SplitButtonHeadless = React.forwardRef(
|
|
|
10058
10367
|
}
|
|
10059
10368
|
case "Escape": {
|
|
10060
10369
|
menuState.close();
|
|
10061
|
-
|
|
10370
|
+
trailingRef.current?.focus();
|
|
10062
10371
|
break;
|
|
10063
10372
|
}
|
|
10064
10373
|
}
|
|
@@ -10094,19 +10403,18 @@ var SplitButtonHeadless = React.forwardRef(
|
|
|
10094
10403
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10095
10404
|
"button",
|
|
10096
10405
|
{
|
|
10097
|
-
...
|
|
10098
|
-
ref:
|
|
10406
|
+
...leadingButtonProps,
|
|
10407
|
+
ref: leadingRef,
|
|
10099
10408
|
type: "button",
|
|
10100
10409
|
tabIndex: isDisabled ? -1 : 0,
|
|
10101
10410
|
children: primaryLabel
|
|
10102
10411
|
}
|
|
10103
10412
|
),
|
|
10104
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true" }),
|
|
10105
10413
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10106
10414
|
"button",
|
|
10107
10415
|
{
|
|
10108
|
-
...
|
|
10109
|
-
ref:
|
|
10416
|
+
...trailingButtonProps,
|
|
10417
|
+
ref: trailingRef,
|
|
10110
10418
|
type: "button",
|
|
10111
10419
|
tabIndex: isDisabled ? -1 : 0,
|
|
10112
10420
|
"aria-haspopup": "menu",
|
|
@@ -16376,8 +16684,14 @@ exports.sliderHandleVariants = sliderHandleVariants;
|
|
|
16376
16684
|
exports.sliderInactiveTrackVariants = sliderInactiveTrackVariants;
|
|
16377
16685
|
exports.sliderTrackLayoutVariants = sliderTrackLayoutVariants;
|
|
16378
16686
|
exports.splitButtonContainerVariants = splitButtonContainerVariants;
|
|
16379
|
-
exports.
|
|
16380
|
-
exports.
|
|
16687
|
+
exports.splitButtonFocusRingVariants = splitButtonFocusRingVariants;
|
|
16688
|
+
exports.splitButtonIconVariants = splitButtonIconVariants;
|
|
16689
|
+
exports.splitButtonLabelVariants = splitButtonLabelVariants;
|
|
16690
|
+
exports.splitButtonLeadingVariants = splitButtonLeadingVariants;
|
|
16691
|
+
exports.splitButtonMenuItemVariants = splitButtonMenuItemVariants;
|
|
16692
|
+
exports.splitButtonMenuVariants = splitButtonMenuVariants;
|
|
16693
|
+
exports.splitButtonStateLayerVariants = splitButtonStateLayerVariants;
|
|
16694
|
+
exports.splitButtonTrailingVariants = splitButtonTrailingVariants;
|
|
16381
16695
|
exports.splitButtonVariants = splitButtonVariants;
|
|
16382
16696
|
exports.supportingTextVariants = supportingTextVariants;
|
|
16383
16697
|
exports.timeInputFieldVariants = timeInputFieldVariants;
|