@bug-on/m3-expressive 1.2.0 → 1.2.2
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/CHANGELOG.md +12 -0
- package/dist/buttons.d.mts +26 -5
- package/dist/buttons.d.ts +26 -5
- package/dist/buttons.js +1074 -765
- package/dist/buttons.js.map +1 -1
- package/dist/buttons.mjs +1066 -765
- package/dist/buttons.mjs.map +1 -1
- package/dist/core.js +133 -69
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +133 -69
- package/dist/core.mjs.map +1 -1
- package/dist/feedback.js +132 -69
- package/dist/feedback.js.map +1 -1
- package/dist/feedback.mjs +132 -69
- package/dist/feedback.mjs.map +1 -1
- package/dist/forms.d.mts +2 -2
- package/dist/forms.d.ts +2 -2
- package/dist/forms.js +74 -9
- package/dist/forms.js.map +1 -1
- package/dist/forms.mjs +74 -9
- package/dist/forms.mjs.map +1 -1
- package/dist/{icon-button-D-gs0gfj.d.mts → icon-button-CSsDmuQC.d.mts} +19 -0
- package/dist/{icon-button-D-gs0gfj.d.ts → icon-button-CSsDmuQC.d.ts} +19 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2204 -1464
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2056 -1324
- package/dist/index.mjs.map +1 -1
- package/dist/layout.d.mts +18 -1
- package/dist/layout.d.ts +18 -1
- package/dist/layout.js +80 -15
- package/dist/layout.js.map +1 -1
- package/dist/layout.mjs +80 -15
- package/dist/layout.mjs.map +1 -1
- package/dist/navigation.d.mts +134 -9
- package/dist/navigation.d.ts +134 -9
- package/dist/navigation.js +461 -101
- package/dist/navigation.js.map +1 -1
- package/dist/navigation.mjs +455 -102
- package/dist/navigation.mjs.map +1 -1
- package/dist/overlays.js +261 -197
- package/dist/overlays.js.map +1 -1
- package/dist/overlays.mjs +223 -159
- package/dist/overlays.mjs.map +1 -1
- package/dist/pickers.js +392 -301
- package/dist/pickers.js.map +1 -1
- package/dist/pickers.mjs +361 -270
- package/dist/pickers.mjs.map +1 -1
- package/dist/{split-button-trailing-uncheckable-BkPbiBo3.d.ts → split-button-trailing-uncheckable-C-qQlyZx.d.ts} +118 -25
- package/dist/{split-button-trailing-uncheckable-D_PLPb-u.d.mts → split-button-trailing-uncheckable-DHJqNeq_.d.mts} +118 -25
- package/dist/{text-field-eAIpz9z1.d.mts → text-field-T4Rg-9Bw.d.mts} +7 -0
- package/dist/{text-field-eAIpz9z1.d.ts → text-field-T4Rg-9Bw.d.ts} +7 -0
- package/package.json +3 -3
package/dist/buttons.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Slot } from '@radix-ui/react-slot';
|
|
3
3
|
import { m, LazyMotion, domMax, useMotionValue, animate, useAnimationFrame, AnimatePresence, useReducedMotion, useSpring, useTransform } from 'motion/react';
|
|
4
|
-
import * as
|
|
4
|
+
import * as React16 from 'react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -87,11 +87,11 @@ var ROTATE_KEY_SPLINES = [
|
|
|
87
87
|
var ROTATE_VALUES = "0 24 24; 154 24 24; 309 24 24; 463 24 24; 617 24 24; 771 24 24; 926 24 24; 1080 24 24";
|
|
88
88
|
var DETERMINATE_CIRCLE = "M24 7 C34.49 7 41 13.51 41 24 C41 34.49 34.49 41 24 41 C13.51 41 7 34.49 7 24 C7 13.51 13.51 7 24 7 Z";
|
|
89
89
|
var DETERMINATE_SOFT_BURST = "M20.9 10.4 21.4 9.5 21.9 8.7 22.5 7.8 23.2 7.2 24.2 7 25.1 7.4 25.7 8.1 26.2 9 26.8 9.8 27.3 10.6 28.1 11.2 29 11.3 30 11 30.9 10.6 31.8 10.3 32.8 9.9 33.7 10 34.5 10.6 34.9 11.5 34.8 12.5 34.8 13.5 34.7 14.5 34.7 15.5 35.2 16.3 36 16.8 37 17.1 37.9 17.3 38.9 17.5 39.8 17.9 40.4 18.7 40.5 19.7 40 20.5 39.4 21.3 38.7 22 38.1 22.8 37.6 23.7 37.7 24.6 38.3 25.5 38.9 26.2 39.6 27 40.2 27.7 40.5 28.7 40.3 29.6 39.5 30.3 38.6 30.6 37.6 30.8 36.7 31 35.7 31.3 35 31.9 34.6 32.8 34.7 33.8 34.8 34.8 34.9 35.8 34.8 36.8 34.3 37.6 33.4 38.1 32.4 38 31.5 37.6 30.6 37.2 29.7 36.9 28.7 36.6 27.8 36.9 27.1 37.6 26.6 38.5 26.1 39.3 25.5 40.2 24.8 40.8 23.8 41 22.9 40.6 22.3 39.9 21.8 39 21.2 38.2 20.7 37.4 19.9 36.8 19 36.7 18 37 17.1 37.4 16.2 37.7 15.2 38.1 14.3 38 13.5 37.4 13.1 36.5 13.2 35.5 13.2 34.5 13.3 33.5 13.3 32.5 12.8 31.7 12 31.2 11 31 10.1 30.7 9.1 30.5 8.2 30.1 7.6 29.3 7.5 28.3 8 27.5 8.7 26.7 9.3 26 9.9 25.2 10.4 24.3 10.3 23.4 9.7 22.5 9.1 21.8 8.4 21 7.8 20.3 7.5 19.3 7.7 18.4 8.5 17.7 9.4 17.4 10.4 17.2 11.3 17 12.3 16.7 13 16.1 13.4 15.2 13.3 14.2 13.2 13.2 13.1 12.2 13.2 11.2 13.7 10.4 14.6 9.9 15.6 10 16.5 10.4 17.4 10.8 18.3 11.1 19.3 11.4 20.2 11.1Z";
|
|
90
|
-
var IndeterminateSvg =
|
|
90
|
+
var IndeterminateSvg = React16.memo(function IndeterminateSvg2({
|
|
91
91
|
size
|
|
92
92
|
}) {
|
|
93
|
-
const [ready, setReady] =
|
|
94
|
-
|
|
93
|
+
const [ready, setReady] = React16.useState(false);
|
|
94
|
+
React16.useEffect(() => {
|
|
95
95
|
const raf = requestAnimationFrame(() => setReady(true));
|
|
96
96
|
return () => cancelAnimationFrame(raf);
|
|
97
97
|
}, []);
|
|
@@ -136,7 +136,7 @@ var IndeterminateSvg = React11.memo(function IndeterminateSvg2({
|
|
|
136
136
|
}
|
|
137
137
|
);
|
|
138
138
|
});
|
|
139
|
-
var DeterminateSvg =
|
|
139
|
+
var DeterminateSvg = React16.memo(function DeterminateSvg2({
|
|
140
140
|
size,
|
|
141
141
|
progress
|
|
142
142
|
}) {
|
|
@@ -161,7 +161,7 @@ var DeterminateSvg = React11.memo(function DeterminateSvg2({
|
|
|
161
161
|
}
|
|
162
162
|
);
|
|
163
163
|
});
|
|
164
|
-
var LoadingIndicator =
|
|
164
|
+
var LoadingIndicator = React16.forwardRef(
|
|
165
165
|
(_a, ref) => {
|
|
166
166
|
var _b = _a, {
|
|
167
167
|
variant = "uncontained",
|
|
@@ -276,7 +276,7 @@ function getSinePath(startX, endX, phase, wl, amp) {
|
|
|
276
276
|
d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
|
|
277
277
|
return d;
|
|
278
278
|
}
|
|
279
|
-
var CircularProgress =
|
|
279
|
+
var CircularProgress = React16.forwardRef(
|
|
280
280
|
(_a, ref) => {
|
|
281
281
|
var _b = _a, {
|
|
282
282
|
value,
|
|
@@ -314,15 +314,15 @@ var CircularProgress = React11.forwardRef(
|
|
|
314
314
|
const isWavy = shape === "wavy";
|
|
315
315
|
const BASELINE_SIZE = 48;
|
|
316
316
|
const scaleFactor = size / BASELINE_SIZE;
|
|
317
|
-
const effectiveAmplitude =
|
|
317
|
+
const effectiveAmplitude = React16.useMemo(
|
|
318
318
|
() => amplitude != null ? amplitude : 1.6 * scaleFactor,
|
|
319
319
|
[amplitude, scaleFactor]
|
|
320
320
|
);
|
|
321
|
-
const effectiveWavelength =
|
|
321
|
+
const effectiveWavelength = React16.useMemo(
|
|
322
322
|
() => wavelength != null ? wavelength : 15 * scaleFactor,
|
|
323
323
|
[wavelength, scaleFactor]
|
|
324
324
|
);
|
|
325
|
-
const wavyActivePath =
|
|
325
|
+
const wavyActivePath = React16.useMemo(
|
|
326
326
|
() => isWavy ? generateWavyCircularPath(
|
|
327
327
|
center,
|
|
328
328
|
radius,
|
|
@@ -331,8 +331,8 @@ var CircularProgress = React11.forwardRef(
|
|
|
331
331
|
) : null,
|
|
332
332
|
[isWavy, center, radius, effectiveAmplitude, effectiveWavelength]
|
|
333
333
|
);
|
|
334
|
-
const circumference =
|
|
335
|
-
const gapForTrack =
|
|
334
|
+
const circumference = React16.useMemo(() => 2 * Math.PI * radius, [radius]);
|
|
335
|
+
const gapForTrack = React16.useMemo(
|
|
336
336
|
() => (gapSize + trackHeight) / circumference,
|
|
337
337
|
[gapSize, trackHeight, circumference]
|
|
338
338
|
);
|
|
@@ -521,9 +521,9 @@ var CircularProgress = React11.forwardRef(
|
|
|
521
521
|
);
|
|
522
522
|
CircularProgress.displayName = "CircularProgress";
|
|
523
523
|
function useContainerWidth() {
|
|
524
|
-
const [width, setWidth] =
|
|
525
|
-
const observerRef =
|
|
526
|
-
const ref =
|
|
524
|
+
const [width, setWidth] = React16.useState(0);
|
|
525
|
+
const observerRef = React16.useRef(null);
|
|
526
|
+
const ref = React16.useCallback((node) => {
|
|
527
527
|
if (observerRef.current) {
|
|
528
528
|
observerRef.current.disconnect();
|
|
529
529
|
observerRef.current = null;
|
|
@@ -537,7 +537,7 @@ function useContainerWidth() {
|
|
|
537
537
|
observerRef.current = obs;
|
|
538
538
|
}
|
|
539
539
|
}, []);
|
|
540
|
-
|
|
540
|
+
React16.useEffect(() => {
|
|
541
541
|
return () => {
|
|
542
542
|
if (observerRef.current) {
|
|
543
543
|
observerRef.current.disconnect();
|
|
@@ -547,7 +547,7 @@ function useContainerWidth() {
|
|
|
547
547
|
return [ref, width];
|
|
548
548
|
}
|
|
549
549
|
function useMergedRef(...refs) {
|
|
550
|
-
return
|
|
550
|
+
return React16.useCallback(
|
|
551
551
|
(node) => {
|
|
552
552
|
for (const ref of refs) {
|
|
553
553
|
if (typeof ref === "function") {
|
|
@@ -561,7 +561,7 @@ function useMergedRef(...refs) {
|
|
|
561
561
|
[refs]
|
|
562
562
|
);
|
|
563
563
|
}
|
|
564
|
-
var FlatLinearTrack =
|
|
564
|
+
var FlatLinearTrack = React16.memo(function FlatLinearTrack2({
|
|
565
565
|
trackHeight,
|
|
566
566
|
activeColor,
|
|
567
567
|
trackColor,
|
|
@@ -637,7 +637,7 @@ var FlatLinearTrack = React11.memo(function FlatLinearTrack2({
|
|
|
637
637
|
}
|
|
638
638
|
);
|
|
639
639
|
});
|
|
640
|
-
var WavyLinearTrack =
|
|
640
|
+
var WavyLinearTrack = React16.memo(function WavyLinearTrack2({
|
|
641
641
|
trackHeight,
|
|
642
642
|
svgHeight,
|
|
643
643
|
amplitude,
|
|
@@ -656,13 +656,13 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
656
656
|
}) {
|
|
657
657
|
const isDeterminate = typeof value === "number";
|
|
658
658
|
const clampedValue = isDeterminate ? Math.max(0, Math.min(100, value)) : 100;
|
|
659
|
-
const titleId =
|
|
659
|
+
const titleId = React16.useId();
|
|
660
660
|
const [containerRef, width] = useContainerWidth();
|
|
661
|
-
const activePathRef =
|
|
662
|
-
const trackPathRef =
|
|
661
|
+
const activePathRef = React16.useRef(null);
|
|
662
|
+
const trackPathRef = React16.useRef(null);
|
|
663
663
|
const amplitudeMV = useMotionValue(amplitude);
|
|
664
664
|
const fractionMV = useMotionValue(isDeterminate ? clampedValue / 100 : 1);
|
|
665
|
-
|
|
665
|
+
React16.useEffect(() => {
|
|
666
666
|
if (isDeterminate) {
|
|
667
667
|
const fraction = clampedValue / 100;
|
|
668
668
|
let targetAmp = amplitude;
|
|
@@ -833,7 +833,7 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
833
833
|
}
|
|
834
834
|
);
|
|
835
835
|
});
|
|
836
|
-
var LinearProgress =
|
|
836
|
+
var LinearProgress = React16.forwardRef(
|
|
837
837
|
(_a, ref) => {
|
|
838
838
|
var _b = _a, {
|
|
839
839
|
value,
|
|
@@ -874,10 +874,10 @@ var LinearProgress = React11.forwardRef(
|
|
|
874
874
|
]);
|
|
875
875
|
const isDeterminate = value !== void 0;
|
|
876
876
|
const clampedValue = isDeterminate ? Math.min(100, Math.max(0, value)) : 0;
|
|
877
|
-
const containerRef =
|
|
877
|
+
const containerRef = React16.useRef(null);
|
|
878
878
|
const mergedRef = useMergedRef(ref, containerRef);
|
|
879
|
-
const [isRtl, setIsRtl] =
|
|
880
|
-
|
|
879
|
+
const [isRtl, setIsRtl] = React16.useState(false);
|
|
880
|
+
React16.useEffect(() => {
|
|
881
881
|
if (containerRef.current) {
|
|
882
882
|
const dir = getComputedStyle(containerRef.current).direction;
|
|
883
883
|
setIsRtl(dir === "rtl");
|
|
@@ -885,16 +885,16 @@ var LinearProgress = React11.forwardRef(
|
|
|
885
885
|
}, []);
|
|
886
886
|
const isWavy = shape === "wavy";
|
|
887
887
|
const resolvedTrackShape = trackShape != null ? trackShape : shape;
|
|
888
|
-
const effectiveAmplitude =
|
|
889
|
-
const svgHeight =
|
|
888
|
+
const effectiveAmplitude = React16.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
|
|
889
|
+
const svgHeight = React16.useMemo(
|
|
890
890
|
() => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
|
|
891
891
|
[isWavy, trackHeight, effectiveAmplitude]
|
|
892
892
|
);
|
|
893
|
-
const shouldShowStop =
|
|
893
|
+
const shouldShowStop = React16.useMemo(
|
|
894
894
|
() => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
|
|
895
895
|
[isDeterminate, resolvedTrackShape, showStopIndicator]
|
|
896
896
|
);
|
|
897
|
-
const stopSize =
|
|
897
|
+
const stopSize = React16.useMemo(
|
|
898
898
|
() => Math.max(2, trackHeight > 4 ? 4 : trackHeight / 2),
|
|
899
899
|
[trackHeight]
|
|
900
900
|
);
|
|
@@ -967,14 +967,14 @@ var LinearProgress = React11.forwardRef(
|
|
|
967
967
|
}
|
|
968
968
|
);
|
|
969
969
|
LinearProgress.displayName = "LinearProgress";
|
|
970
|
-
var ProgressIndicator =
|
|
970
|
+
var ProgressIndicator = React16.forwardRef((props, ref) => {
|
|
971
971
|
if (props.variant === "circular") {
|
|
972
972
|
return /* @__PURE__ */ jsx(CircularProgress, __spreadValues({ ref }, props));
|
|
973
973
|
}
|
|
974
974
|
return /* @__PURE__ */ jsx(LinearProgress, __spreadValues({ ref }, props));
|
|
975
975
|
});
|
|
976
976
|
ProgressIndicator.displayName = "ProgressIndicator";
|
|
977
|
-
var RippleItem =
|
|
977
|
+
var RippleItem = React16.memo(function RippleItem2({
|
|
978
978
|
ripple,
|
|
979
979
|
onDone
|
|
980
980
|
}) {
|
|
@@ -1018,14 +1018,17 @@ function Ripple({
|
|
|
1018
1018
|
}
|
|
1019
1019
|
function useRippleState(options = {}) {
|
|
1020
1020
|
const { disabled = false } = options;
|
|
1021
|
-
const [ripples, setRipples] =
|
|
1022
|
-
const onPointerDown =
|
|
1021
|
+
const [ripples, setRipples] = React16.useState([]);
|
|
1022
|
+
const onPointerDown = React16.useCallback(
|
|
1023
1023
|
(e) => {
|
|
1024
1024
|
if (disabled) return;
|
|
1025
1025
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1026
1026
|
const x = e.clientX - rect.left;
|
|
1027
1027
|
const y = e.clientY - rect.top;
|
|
1028
|
-
const rippleSize = Math.
|
|
1028
|
+
const rippleSize = Math.max(
|
|
1029
|
+
Math.hypot(rect.width, rect.height) * 2.5,
|
|
1030
|
+
320
|
|
1031
|
+
);
|
|
1029
1032
|
setRipples((prev) => [
|
|
1030
1033
|
...prev,
|
|
1031
1034
|
{ id: Date.now(), x, y, size: rippleSize }
|
|
@@ -1033,7 +1036,7 @@ function useRippleState(options = {}) {
|
|
|
1033
1036
|
},
|
|
1034
1037
|
[disabled]
|
|
1035
1038
|
);
|
|
1036
|
-
const removeRipple =
|
|
1039
|
+
const removeRipple = React16.useCallback((id) => {
|
|
1037
1040
|
setRipples((prev) => prev.filter((r) => r.id !== id));
|
|
1038
1041
|
}, []);
|
|
1039
1042
|
return { ripples, onPointerDown, removeRipple };
|
|
@@ -1289,7 +1292,7 @@ function AnimatedIconSlot({
|
|
|
1289
1292
|
}
|
|
1290
1293
|
);
|
|
1291
1294
|
}
|
|
1292
|
-
var ButtonComponent =
|
|
1295
|
+
var ButtonComponent = React16.forwardRef(
|
|
1293
1296
|
(_a, ref) => {
|
|
1294
1297
|
var _b = _a, {
|
|
1295
1298
|
className,
|
|
@@ -1301,6 +1304,7 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1301
1304
|
shape = "round",
|
|
1302
1305
|
selected,
|
|
1303
1306
|
icon,
|
|
1307
|
+
selectedIcon,
|
|
1304
1308
|
iconPosition = "leading",
|
|
1305
1309
|
loading = false,
|
|
1306
1310
|
loadingVariant = "loading-indicator",
|
|
@@ -1322,6 +1326,7 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1322
1326
|
"shape",
|
|
1323
1327
|
"selected",
|
|
1324
1328
|
"icon",
|
|
1329
|
+
"selectedIcon",
|
|
1325
1330
|
"iconPosition",
|
|
1326
1331
|
"loading",
|
|
1327
1332
|
"loadingVariant",
|
|
@@ -1351,9 +1356,9 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1351
1356
|
borderWidth: outlineWidth != null ? outlineWidth : colorStyle === "outlined" ? sizeTokens.outlineWidth : 0,
|
|
1352
1357
|
borderStyle: colorStyle === "outlined" ? "solid" : void 0
|
|
1353
1358
|
}, style);
|
|
1354
|
-
const labelText =
|
|
1359
|
+
const labelText = React16.useMemo(() => {
|
|
1355
1360
|
if (asChild) {
|
|
1356
|
-
const child =
|
|
1361
|
+
const child = React16.Children.only(children);
|
|
1357
1362
|
return child.props.children;
|
|
1358
1363
|
}
|
|
1359
1364
|
return children;
|
|
@@ -1361,8 +1366,8 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1361
1366
|
const computedAriaLabel = ariaLabelProp || (typeof children === "string" ? children : void 0);
|
|
1362
1367
|
const needsTouchTarget = size === "xs" || size === "sm";
|
|
1363
1368
|
const motionRadius = useMotionValue(animateRadius);
|
|
1364
|
-
const asChildRef =
|
|
1365
|
-
const mergedRef =
|
|
1369
|
+
const asChildRef = React16.useRef(null);
|
|
1370
|
+
const mergedRef = React16.useCallback(
|
|
1366
1371
|
(node) => {
|
|
1367
1372
|
asChildRef.current = node;
|
|
1368
1373
|
if (typeof ref === "function") ref(node);
|
|
@@ -1371,14 +1376,14 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1371
1376
|
},
|
|
1372
1377
|
[ref]
|
|
1373
1378
|
);
|
|
1374
|
-
|
|
1379
|
+
React16.useEffect(() => {
|
|
1375
1380
|
if (!asChild) return;
|
|
1376
1381
|
return motionRadius.on("change", (v) => {
|
|
1377
1382
|
if (asChildRef.current)
|
|
1378
1383
|
asChildRef.current.style.borderRadius = `${v}px`;
|
|
1379
1384
|
});
|
|
1380
1385
|
}, [motionRadius, asChild]);
|
|
1381
|
-
|
|
1386
|
+
React16.useEffect(() => {
|
|
1382
1387
|
if (!asChild) return;
|
|
1383
1388
|
const controls = springAnimate(motionRadius, animateRadius);
|
|
1384
1389
|
return () => controls.stop();
|
|
@@ -1386,14 +1391,14 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1386
1391
|
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
1387
1392
|
disabled: loading
|
|
1388
1393
|
});
|
|
1389
|
-
const handleClick =
|
|
1394
|
+
const handleClick = React16.useCallback(
|
|
1390
1395
|
(e) => {
|
|
1391
1396
|
if (loading) return e.preventDefault();
|
|
1392
1397
|
onClick == null ? void 0 : onClick(e);
|
|
1393
1398
|
},
|
|
1394
1399
|
[loading, onClick]
|
|
1395
1400
|
);
|
|
1396
|
-
const handleKeyDown =
|
|
1401
|
+
const handleKeyDown = React16.useCallback(
|
|
1397
1402
|
(e) => {
|
|
1398
1403
|
if (loading) return;
|
|
1399
1404
|
if (onClick && (e.key === "Enter" || e.key === " ")) {
|
|
@@ -1421,10 +1426,11 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1421
1426
|
layout: BUTTON_SHAPE_MORPH_SPRING,
|
|
1422
1427
|
default: SPRING_TRANSITION
|
|
1423
1428
|
};
|
|
1429
|
+
const activeIcon = isSelected && selectedIcon ? selectedIcon : icon;
|
|
1424
1430
|
const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1425
1431
|
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
1426
1432
|
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
1427
|
-
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "
|
|
1433
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "wait", children: (loading || activeIcon && iconPosition === "leading") && /* @__PURE__ */ jsx(
|
|
1428
1434
|
AnimatedIconSlot,
|
|
1429
1435
|
{
|
|
1430
1436
|
iconSize: sizeTokens.iconSize,
|
|
@@ -1446,8 +1452,9 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1446
1452
|
trackColor: "transparent",
|
|
1447
1453
|
"aria-label": "Loading"
|
|
1448
1454
|
}
|
|
1449
|
-
) :
|
|
1450
|
-
}
|
|
1455
|
+
) : activeIcon
|
|
1456
|
+
},
|
|
1457
|
+
isSelected && selectedIcon ? "selected-icon" : "icon"
|
|
1451
1458
|
) }),
|
|
1452
1459
|
labelText && /* @__PURE__ */ jsx(
|
|
1453
1460
|
m.span,
|
|
@@ -1458,27 +1465,28 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1458
1465
|
children: labelText
|
|
1459
1466
|
}
|
|
1460
1467
|
),
|
|
1461
|
-
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "
|
|
1468
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "wait", children: !loading && activeIcon && iconPosition === "trailing" && /* @__PURE__ */ jsx(
|
|
1462
1469
|
AnimatedIconSlot,
|
|
1463
1470
|
{
|
|
1464
1471
|
iconSize: sizeTokens.iconSize,
|
|
1465
1472
|
ariaHidden: true,
|
|
1466
1473
|
transition: sharedTransition,
|
|
1467
|
-
children:
|
|
1468
|
-
}
|
|
1474
|
+
children: activeIcon
|
|
1475
|
+
},
|
|
1476
|
+
isSelected && selectedIcon ? "selected-icon" : "icon"
|
|
1469
1477
|
) })
|
|
1470
1478
|
] });
|
|
1471
|
-
const handleAsChildPointerDown =
|
|
1479
|
+
const handleAsChildPointerDown = React16.useCallback(
|
|
1472
1480
|
(e) => {
|
|
1473
1481
|
springAnimate(motionRadius, pressedRadius);
|
|
1474
1482
|
onPointerDown == null ? void 0 : onPointerDown(e);
|
|
1475
1483
|
},
|
|
1476
1484
|
[motionRadius, pressedRadius, onPointerDown]
|
|
1477
1485
|
);
|
|
1478
|
-
const handleAsChildPointerUp =
|
|
1486
|
+
const handleAsChildPointerUp = React16.useCallback(() => {
|
|
1479
1487
|
springAnimate(motionRadius, animateRadius);
|
|
1480
1488
|
}, [motionRadius, animateRadius]);
|
|
1481
|
-
const handlePointerDown =
|
|
1489
|
+
const handlePointerDown = React16.useCallback(
|
|
1482
1490
|
(e) => {
|
|
1483
1491
|
onPointerDown(e);
|
|
1484
1492
|
},
|
|
@@ -1488,7 +1496,7 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1488
1496
|
const strippedProps = __spreadValues({}, restProps);
|
|
1489
1497
|
for (const key of MOTION_PROP_KEYS) delete strippedProps[key];
|
|
1490
1498
|
const htmlProps = strippedProps;
|
|
1491
|
-
const child =
|
|
1499
|
+
const child = React16.Children.only(children);
|
|
1492
1500
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
1493
1501
|
Slot,
|
|
1494
1502
|
__spreadProps(__spreadValues({
|
|
@@ -1505,7 +1513,7 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1505
1513
|
}),
|
|
1506
1514
|
className: buttonClassName
|
|
1507
1515
|
}, htmlProps), {
|
|
1508
|
-
children:
|
|
1516
|
+
children: React16.cloneElement(child, { children: innerContent })
|
|
1509
1517
|
})
|
|
1510
1518
|
) });
|
|
1511
1519
|
}
|
|
@@ -1534,13 +1542,343 @@ var ButtonComponent = React11.forwardRef(
|
|
|
1534
1542
|
}
|
|
1535
1543
|
);
|
|
1536
1544
|
ButtonComponent.displayName = "Button";
|
|
1537
|
-
var Button =
|
|
1545
|
+
var Button = React16.memo(ButtonComponent);
|
|
1546
|
+
|
|
1547
|
+
// src/ui/buttons/button-distribute/button-distribute-tokens.ts
|
|
1548
|
+
var DISTRIBUTE_SPRING_TRANSITION = {
|
|
1549
|
+
type: "spring",
|
|
1550
|
+
stiffness: 300,
|
|
1551
|
+
damping: 30,
|
|
1552
|
+
mass: 0.8
|
|
1553
|
+
};
|
|
1554
|
+
var DISTRIBUTE_EASING_BEZIER = "cubic-bezier(0.2, 0.0, 0.0, 1.0)";
|
|
1555
|
+
var DISTRIBUTE_DURATION_MS = 350;
|
|
1556
|
+
var DEFAULT_EXPAND_RATIO = 0.3;
|
|
1557
|
+
var DEFAULT_FIXED_SIZE = 48;
|
|
1558
|
+
var DEFAULT_GAP = "0.5rem";
|
|
1559
|
+
var DISTRIBUTE_RADIUS_TOKENS = {
|
|
1560
|
+
xs: { circleRadius: 16, pillRadius: 16, pressedRadius: 8 },
|
|
1561
|
+
sm: { circleRadius: 20, pillRadius: 20, pressedRadius: 10 },
|
|
1562
|
+
md: { circleRadius: 28, pillRadius: 28, pressedRadius: 16 },
|
|
1563
|
+
lg: { circleRadius: 48, pillRadius: 48, pressedRadius: 28 },
|
|
1564
|
+
xl: { circleRadius: 68, pillRadius: 68, pressedRadius: 40 }
|
|
1565
|
+
};
|
|
1566
|
+
var DISTRIBUTE_HEIGHT_TOKENS = {
|
|
1567
|
+
xs: "h-8",
|
|
1568
|
+
sm: "h-10",
|
|
1569
|
+
md: "h-14",
|
|
1570
|
+
lg: "h-24",
|
|
1571
|
+
xl: "h-[8.5rem]"
|
|
1572
|
+
};
|
|
1573
|
+
function useDistributeWeights({
|
|
1574
|
+
count,
|
|
1575
|
+
weights,
|
|
1576
|
+
activeIndex,
|
|
1577
|
+
expandRatio = DEFAULT_EXPAND_RATIO,
|
|
1578
|
+
mode = "dynamic",
|
|
1579
|
+
isTextItem
|
|
1580
|
+
}) {
|
|
1581
|
+
return React16.useMemo(() => {
|
|
1582
|
+
if (count <= 0) return [];
|
|
1583
|
+
if (mode === "mixed") {
|
|
1584
|
+
const baseWeights2 = new Array(count).fill(0).map((_, idx) => {
|
|
1585
|
+
if (idx === 0 || idx === count - 1) return 0;
|
|
1586
|
+
return weights && weights[idx] !== void 0 ? weights[idx] : 1;
|
|
1587
|
+
});
|
|
1588
|
+
if (activeIndex === null || activeIndex < 0 || activeIndex >= count || count === 1) {
|
|
1589
|
+
return baseWeights2;
|
|
1590
|
+
}
|
|
1591
|
+
const result2 = [...baseWeights2];
|
|
1592
|
+
const expandAmount2 = expandRatio * 1.5;
|
|
1593
|
+
if (activeIndex === 0) {
|
|
1594
|
+
result2[0] = expandAmount2;
|
|
1595
|
+
for (let i = 1; i < count - 1; i++) {
|
|
1596
|
+
result2[i] = Math.max(0.5, baseWeights2[i] - expandRatio * 0.4);
|
|
1597
|
+
}
|
|
1598
|
+
} else if (activeIndex === count - 1) {
|
|
1599
|
+
result2[count - 1] = expandAmount2;
|
|
1600
|
+
for (let i = 1; i < count - 1; i++) {
|
|
1601
|
+
result2[i] = Math.max(0.5, baseWeights2[i] - expandRatio * 0.4);
|
|
1602
|
+
}
|
|
1603
|
+
} else {
|
|
1604
|
+
result2[activeIndex] = baseWeights2[activeIndex] + expandRatio;
|
|
1605
|
+
for (let i = 1; i < count - 1; i++) {
|
|
1606
|
+
if (i !== activeIndex) {
|
|
1607
|
+
result2[i] = Math.max(0.5, baseWeights2[i] - expandRatio * 0.5);
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
return result2;
|
|
1612
|
+
}
|
|
1613
|
+
let baseWeights;
|
|
1614
|
+
if (weights && weights.length === count) {
|
|
1615
|
+
baseWeights = [...weights];
|
|
1616
|
+
} else if (mode === "dynamic" && count === 3) {
|
|
1617
|
+
baseWeights = [1, 2, 1];
|
|
1618
|
+
} else {
|
|
1619
|
+
baseWeights = new Array(count).fill(1);
|
|
1620
|
+
}
|
|
1621
|
+
if (activeIndex === null || activeIndex < 0 || activeIndex >= count || count === 1) {
|
|
1622
|
+
return baseWeights;
|
|
1623
|
+
}
|
|
1624
|
+
const totalWeight = baseWeights.reduce((acc, w) => acc + w, 0);
|
|
1625
|
+
const activeBaseWeight = baseWeights[activeIndex];
|
|
1626
|
+
const expandAmount = expandRatio * totalWeight;
|
|
1627
|
+
const minWeights = baseWeights.map((w, idx) => {
|
|
1628
|
+
if (isTextItem == null ? void 0 : isTextItem[idx]) {
|
|
1629
|
+
return Math.max(0.75, w * 0.65);
|
|
1630
|
+
}
|
|
1631
|
+
return 0.4;
|
|
1632
|
+
});
|
|
1633
|
+
const shrinkCapacity = baseWeights.map(
|
|
1634
|
+
(w, idx) => idx === activeIndex ? 0 : Math.max(0, w - minWeights[idx])
|
|
1635
|
+
);
|
|
1636
|
+
const totalCapacity = shrinkCapacity.reduce((acc, cap) => acc + cap, 0);
|
|
1637
|
+
const result = [...baseWeights];
|
|
1638
|
+
if (totalCapacity > 0) {
|
|
1639
|
+
const actualExpand = Math.min(expandAmount, totalCapacity);
|
|
1640
|
+
result[activeIndex] = activeBaseWeight + actualExpand;
|
|
1641
|
+
for (let i = 0; i < count; i++) {
|
|
1642
|
+
if (i !== activeIndex) {
|
|
1643
|
+
const shrinkAmount = actualExpand * (shrinkCapacity[i] / totalCapacity);
|
|
1644
|
+
result[i] = Math.max(minWeights[i], baseWeights[i] - shrinkAmount);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return result;
|
|
1649
|
+
}, [count, weights, activeIndex, expandRatio, mode, isTextItem]);
|
|
1650
|
+
}
|
|
1651
|
+
var ButtonDistribute = React16.forwardRef(
|
|
1652
|
+
(_a, ref) => {
|
|
1653
|
+
var _b = _a, {
|
|
1654
|
+
className,
|
|
1655
|
+
style,
|
|
1656
|
+
mode = "dynamic",
|
|
1657
|
+
weights,
|
|
1658
|
+
expandRatio = 0.3,
|
|
1659
|
+
expandOnHover = false,
|
|
1660
|
+
fixedSize = 48,
|
|
1661
|
+
leadingSize,
|
|
1662
|
+
trailingSize,
|
|
1663
|
+
gap = "0.5rem",
|
|
1664
|
+
size = "sm",
|
|
1665
|
+
itemClassName,
|
|
1666
|
+
children,
|
|
1667
|
+
onMouseLeave
|
|
1668
|
+
} = _b, restProps = __objRest(_b, [
|
|
1669
|
+
"className",
|
|
1670
|
+
"style",
|
|
1671
|
+
"mode",
|
|
1672
|
+
"weights",
|
|
1673
|
+
"expandRatio",
|
|
1674
|
+
"expandOnHover",
|
|
1675
|
+
"fixedSize",
|
|
1676
|
+
"leadingSize",
|
|
1677
|
+
"trailingSize",
|
|
1678
|
+
"gap",
|
|
1679
|
+
"size",
|
|
1680
|
+
"itemClassName",
|
|
1681
|
+
"children",
|
|
1682
|
+
"onMouseLeave"
|
|
1683
|
+
]);
|
|
1684
|
+
var _a2, _b2;
|
|
1685
|
+
const [activeIndex, setActiveIndex] = React16.useState(null);
|
|
1686
|
+
const [pressedIndex, setPressedIndex] = React16.useState(null);
|
|
1687
|
+
const childrenArray = React16.useMemo(
|
|
1688
|
+
() => React16.Children.toArray(children).filter(React16.isValidElement),
|
|
1689
|
+
[children]
|
|
1690
|
+
);
|
|
1691
|
+
const count = childrenArray.length;
|
|
1692
|
+
const isTextItem = React16.useMemo(() => {
|
|
1693
|
+
return childrenArray.map((child) => {
|
|
1694
|
+
const childEl = child;
|
|
1695
|
+
if (typeof childEl.props.children === "string") return true;
|
|
1696
|
+
if (Array.isArray(childEl.props.children)) {
|
|
1697
|
+
return childEl.props.children.some(
|
|
1698
|
+
(c) => typeof c === "string" && c.trim().length > 0
|
|
1699
|
+
);
|
|
1700
|
+
}
|
|
1701
|
+
return false;
|
|
1702
|
+
});
|
|
1703
|
+
}, [childrenArray]);
|
|
1704
|
+
const calculatedWeights = useDistributeWeights({
|
|
1705
|
+
count,
|
|
1706
|
+
weights,
|
|
1707
|
+
activeIndex,
|
|
1708
|
+
expandRatio,
|
|
1709
|
+
mode,
|
|
1710
|
+
isTextItem
|
|
1711
|
+
});
|
|
1712
|
+
const handleGroupMouseLeave = React16.useCallback(
|
|
1713
|
+
(e) => {
|
|
1714
|
+
setActiveIndex(null);
|
|
1715
|
+
setPressedIndex(null);
|
|
1716
|
+
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
1717
|
+
},
|
|
1718
|
+
[onMouseLeave]
|
|
1719
|
+
);
|
|
1720
|
+
const resolvedGap = typeof gap === "number" ? `${gap}px` : gap;
|
|
1721
|
+
const effectiveLeadingSize = typeof (leadingSize != null ? leadingSize : fixedSize) === "number" ? `${leadingSize != null ? leadingSize : fixedSize}px` : leadingSize != null ? leadingSize : fixedSize;
|
|
1722
|
+
const effectiveTrailingSize = typeof (trailingSize != null ? trailingSize : fixedSize) === "number" ? `${trailingSize != null ? trailingSize : fixedSize}px` : trailingSize != null ? trailingSize : fixedSize;
|
|
1723
|
+
const radiusTokens = (_a2 = DISTRIBUTE_RADIUS_TOKENS[size]) != null ? _a2 : DISTRIBUTE_RADIUS_TOKENS.sm;
|
|
1724
|
+
const heightClass = (_b2 = DISTRIBUTE_HEIGHT_TOKENS[size]) != null ? _b2 : DISTRIBUTE_HEIGHT_TOKENS.sm;
|
|
1725
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
1726
|
+
"fieldset",
|
|
1727
|
+
__spreadProps(__spreadValues({
|
|
1728
|
+
ref,
|
|
1729
|
+
onMouseLeave: handleGroupMouseLeave,
|
|
1730
|
+
onPointerCancel: () => setPressedIndex(null),
|
|
1731
|
+
className: cn(
|
|
1732
|
+
"inline-flex flex-row items-center border-none p-0 m-0 box-border overflow-hidden select-none w-full",
|
|
1733
|
+
heightClass,
|
|
1734
|
+
className
|
|
1735
|
+
),
|
|
1736
|
+
style: __spreadValues({
|
|
1737
|
+
gap: resolvedGap
|
|
1738
|
+
}, style)
|
|
1739
|
+
}, restProps), {
|
|
1740
|
+
children: childrenArray.map((child, index) => {
|
|
1741
|
+
var _a3, _b3, _c, _d, _e, _f;
|
|
1742
|
+
const isFirst = index === 0;
|
|
1743
|
+
const isLast = index === count - 1;
|
|
1744
|
+
const childElement = child;
|
|
1745
|
+
const isActive = activeIndex === index;
|
|
1746
|
+
const isPressed = pressedIndex === index;
|
|
1747
|
+
const isSquish = isActive || isPressed;
|
|
1748
|
+
let flexStyle = {};
|
|
1749
|
+
let targetFlexBasis = 0;
|
|
1750
|
+
const parsePx = (val) => {
|
|
1751
|
+
if (typeof val === "number") return val;
|
|
1752
|
+
const parsed = Number.parseFloat(val);
|
|
1753
|
+
return Number.isNaN(parsed) ? 48 : parsed;
|
|
1754
|
+
};
|
|
1755
|
+
const leadingPx = parsePx(effectiveLeadingSize);
|
|
1756
|
+
const trailingPx = parsePx(effectiveTrailingSize);
|
|
1757
|
+
const leadingCompressedPx = Math.max(
|
|
1758
|
+
40,
|
|
1759
|
+
Math.round(leadingPx * (1 - expandRatio))
|
|
1760
|
+
);
|
|
1761
|
+
const trailingCompressedPx = Math.max(
|
|
1762
|
+
40,
|
|
1763
|
+
Math.round(trailingPx * (1 - expandRatio))
|
|
1764
|
+
);
|
|
1765
|
+
if (mode === "dynamic" || mode === "fixed") {
|
|
1766
|
+
const currentWeight = (_a3 = calculatedWeights[index]) != null ? _a3 : 1;
|
|
1767
|
+
flexStyle = {
|
|
1768
|
+
flexGrow: currentWeight,
|
|
1769
|
+
flexShrink: 1,
|
|
1770
|
+
flexBasis: 0,
|
|
1771
|
+
minWidth: 0
|
|
1772
|
+
};
|
|
1773
|
+
targetFlexBasis = 0;
|
|
1774
|
+
} else if (mode === "mixed") {
|
|
1775
|
+
const currentWeight = (_b3 = calculatedWeights[index]) != null ? _b3 : 0;
|
|
1776
|
+
if (isFirst) {
|
|
1777
|
+
targetFlexBasis = activeIndex !== null && activeIndex > 0 ? `${leadingCompressedPx}px` : effectiveLeadingSize;
|
|
1778
|
+
flexStyle = {
|
|
1779
|
+
flexBasis: targetFlexBasis,
|
|
1780
|
+
flexGrow: currentWeight,
|
|
1781
|
+
flexShrink: 0,
|
|
1782
|
+
minWidth: 0
|
|
1783
|
+
};
|
|
1784
|
+
} else if (isLast) {
|
|
1785
|
+
targetFlexBasis = activeIndex !== null && activeIndex < count - 1 ? `${trailingCompressedPx}px` : effectiveTrailingSize;
|
|
1786
|
+
flexStyle = {
|
|
1787
|
+
flexBasis: targetFlexBasis,
|
|
1788
|
+
flexGrow: currentWeight,
|
|
1789
|
+
flexShrink: 0,
|
|
1790
|
+
minWidth: 0
|
|
1791
|
+
};
|
|
1792
|
+
} else {
|
|
1793
|
+
targetFlexBasis = 0;
|
|
1794
|
+
flexStyle = {
|
|
1795
|
+
flexBasis: 0,
|
|
1796
|
+
flexGrow: (_c = calculatedWeights[index]) != null ? _c : 1,
|
|
1797
|
+
flexShrink: 1,
|
|
1798
|
+
minWidth: 0
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
const handleMouseEnter = (e) => {
|
|
1803
|
+
var _a4, _b4;
|
|
1804
|
+
if (expandOnHover) {
|
|
1805
|
+
setActiveIndex(index);
|
|
1806
|
+
}
|
|
1807
|
+
(_b4 = (_a4 = childElement.props).onMouseEnter) == null ? void 0 : _b4.call(_a4, e);
|
|
1808
|
+
};
|
|
1809
|
+
const handleFocus = (e) => {
|
|
1810
|
+
var _a4, _b4;
|
|
1811
|
+
setActiveIndex(index);
|
|
1812
|
+
(_b4 = (_a4 = childElement.props).onFocus) == null ? void 0 : _b4.call(_a4, e);
|
|
1813
|
+
};
|
|
1814
|
+
const handlePointerDown = (e) => {
|
|
1815
|
+
var _a4, _b4;
|
|
1816
|
+
setPressedIndex(index);
|
|
1817
|
+
setActiveIndex(index);
|
|
1818
|
+
(_b4 = (_a4 = childElement.props).onPointerDown) == null ? void 0 : _b4.call(_a4, e);
|
|
1819
|
+
};
|
|
1820
|
+
const handlePointerUp = (e) => {
|
|
1821
|
+
var _a4, _b4;
|
|
1822
|
+
setPressedIndex(null);
|
|
1823
|
+
if (!expandOnHover) {
|
|
1824
|
+
setActiveIndex(null);
|
|
1825
|
+
}
|
|
1826
|
+
(_b4 = (_a4 = childElement.props).onPointerUp) == null ? void 0 : _b4.call(_a4, e);
|
|
1827
|
+
};
|
|
1828
|
+
const handleClick = (e) => {
|
|
1829
|
+
var _a4, _b4;
|
|
1830
|
+
setPressedIndex(null);
|
|
1831
|
+
if (!expandOnHover) {
|
|
1832
|
+
setActiveIndex(null);
|
|
1833
|
+
}
|
|
1834
|
+
(_b4 = (_a4 = childElement.props).onClick) == null ? void 0 : _b4.call(_a4, e);
|
|
1835
|
+
};
|
|
1836
|
+
const clonedChild = React16.cloneElement(childElement, {
|
|
1837
|
+
size: (_d = childElement.props.size) != null ? _d : size,
|
|
1838
|
+
className: cn(
|
|
1839
|
+
"w-full! h-full! justify-center items-center flex-1 rounded-[inherit]! px-3! sm:px-4!",
|
|
1840
|
+
childElement.props.className
|
|
1841
|
+
)
|
|
1842
|
+
});
|
|
1843
|
+
return /* @__PURE__ */ jsx(
|
|
1844
|
+
m.div,
|
|
1845
|
+
{
|
|
1846
|
+
layout: true,
|
|
1847
|
+
initial: false,
|
|
1848
|
+
animate: {
|
|
1849
|
+
flexGrow: (_f = flexStyle.flexGrow) != null ? _f : 1,
|
|
1850
|
+
flexBasis: targetFlexBasis,
|
|
1851
|
+
borderRadius: isSquish ? radiusTokens.pressedRadius : radiusTokens.pillRadius
|
|
1852
|
+
},
|
|
1853
|
+
transition: __spreadProps(__spreadValues({}, DISTRIBUTE_SPRING_TRANSITION), {
|
|
1854
|
+
borderRadius: BUTTON_RADIUS_SPRING
|
|
1855
|
+
}),
|
|
1856
|
+
onMouseEnter: handleMouseEnter,
|
|
1857
|
+
onFocus: handleFocus,
|
|
1858
|
+
onPointerDown: handlePointerDown,
|
|
1859
|
+
onPointerUp: handlePointerUp,
|
|
1860
|
+
onClick: handleClick,
|
|
1861
|
+
className: cn(
|
|
1862
|
+
"relative inline-flex items-center justify-center shrink-0 min-w-0 overflow-hidden h-full",
|
|
1863
|
+
itemClassName
|
|
1864
|
+
),
|
|
1865
|
+
style: flexStyle,
|
|
1866
|
+
children: clonedChild
|
|
1867
|
+
},
|
|
1868
|
+
(_e = childElement.key) != null ? _e : index
|
|
1869
|
+
);
|
|
1870
|
+
})
|
|
1871
|
+
})
|
|
1872
|
+
) });
|
|
1873
|
+
}
|
|
1874
|
+
);
|
|
1875
|
+
ButtonDistribute.displayName = "ButtonDistribute";
|
|
1538
1876
|
var VARIANT_FONT = {
|
|
1539
1877
|
outlined: "'Material Symbols Outlined'",
|
|
1540
1878
|
rounded: "'Material Symbols Rounded'",
|
|
1541
1879
|
sharp: "'Material Symbols Sharp'"
|
|
1542
1880
|
};
|
|
1543
|
-
var IconComponent =
|
|
1881
|
+
var IconComponent = React16.forwardRef(
|
|
1544
1882
|
(_a, ref) => {
|
|
1545
1883
|
var _b = _a, {
|
|
1546
1884
|
name,
|
|
@@ -1606,7 +1944,7 @@ var IconComponent = React11.forwardRef(
|
|
|
1606
1944
|
}
|
|
1607
1945
|
);
|
|
1608
1946
|
IconComponent.displayName = "Icon";
|
|
1609
|
-
var Icon =
|
|
1947
|
+
var Icon = React16.memo(IconComponent);
|
|
1610
1948
|
var BUTTON_GROUP_TOKENS = {
|
|
1611
1949
|
standard: {
|
|
1612
1950
|
betweenSpace: 12,
|
|
@@ -1662,7 +2000,6 @@ function buildConnectedShapes(size, defaultCorners, pressedCorners) {
|
|
|
1662
2000
|
};
|
|
1663
2001
|
}
|
|
1664
2002
|
var ButtonGroupDefaults = {
|
|
1665
|
-
expandedRatio: 0.15,
|
|
1666
2003
|
connectedLeadingButtonShapes: (size) => buildConnectedShapes(
|
|
1667
2004
|
size,
|
|
1668
2005
|
(o, i) => ({ tl: o, tr: i, br: i, bl: o }),
|
|
@@ -1691,8 +2028,6 @@ var ButtonGroupDefaults = {
|
|
|
1691
2028
|
)
|
|
1692
2029
|
};
|
|
1693
2030
|
var PILL_BORDER_RADIUS = 9999;
|
|
1694
|
-
var MIN_FLEX_GROW = 0.01;
|
|
1695
|
-
var PADDING_EXPAND_MULTIPLIER = 4;
|
|
1696
2031
|
var CHECK_ICON_SIZE = 24;
|
|
1697
2032
|
var CHECK_ICON = /* @__PURE__ */ jsx(Icon, { name: "check", variant: "rounded", size: CHECK_ICON_SIZE, weight: 700 });
|
|
1698
2033
|
var CHECK_ICON_GAP_MAP = {
|
|
@@ -1708,19 +2043,7 @@ var CHECK_ICON_MOTION = {
|
|
|
1708
2043
|
damping: 34,
|
|
1709
2044
|
mass: 0.75
|
|
1710
2045
|
};
|
|
1711
|
-
var
|
|
1712
|
-
type: "spring",
|
|
1713
|
-
stiffness: 360,
|
|
1714
|
-
damping: 38,
|
|
1715
|
-
mass: 0.85
|
|
1716
|
-
};
|
|
1717
|
-
var NAVBAR_EXPRESSIVE_SPRING = {
|
|
1718
|
-
type: "spring",
|
|
1719
|
-
stiffness: 430,
|
|
1720
|
-
damping: 38,
|
|
1721
|
-
mass: 0.8
|
|
1722
|
-
};
|
|
1723
|
-
var AnimatedCheckLabel = React11.memo(function AnimatedCheckLabel2({
|
|
2046
|
+
var AnimatedCheckLabel = React16.memo(function AnimatedCheckLabel2({
|
|
1724
2047
|
selected,
|
|
1725
2048
|
size,
|
|
1726
2049
|
children
|
|
@@ -1757,23 +2080,6 @@ var AnimatedCheckLabel = React11.memo(function AnimatedCheckLabel2({
|
|
|
1757
2080
|
}
|
|
1758
2081
|
);
|
|
1759
2082
|
});
|
|
1760
|
-
var AnimatedNavbarLabel = React11.memo(function AnimatedNavbarLabel2({
|
|
1761
|
-
show,
|
|
1762
|
-
children
|
|
1763
|
-
}) {
|
|
1764
|
-
return /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "popLayout", children: show && /* @__PURE__ */ jsx(
|
|
1765
|
-
m.span,
|
|
1766
|
-
{
|
|
1767
|
-
initial: { width: 0, opacity: 0, scale: 0.8 },
|
|
1768
|
-
animate: { width: "auto", opacity: 1, scale: 1 },
|
|
1769
|
-
exit: { width: 0, opacity: 0, scale: 0.8 },
|
|
1770
|
-
transition: NAVBAR_EXPRESSIVE_SPRING,
|
|
1771
|
-
className: "overflow-hidden whitespace-nowrap text-sm font-semibold tracking-[0.01em] ml-1.5",
|
|
1772
|
-
children
|
|
1773
|
-
},
|
|
1774
|
-
"navbar-label"
|
|
1775
|
-
) });
|
|
1776
|
-
});
|
|
1777
2083
|
function resolveConnectedShapes(variant, orientation, isFirst, isLast, itemSize) {
|
|
1778
2084
|
const defaults = ButtonGroupDefaults.connectedLeadingButtonShapes(itemSize);
|
|
1779
2085
|
if (variant !== "connected") return defaults;
|
|
@@ -1794,7 +2100,7 @@ function resolveConnectedShapes(variant, orientation, isFirst, isLast, itemSize)
|
|
|
1794
2100
|
}
|
|
1795
2101
|
return defaults;
|
|
1796
2102
|
}
|
|
1797
|
-
function resolveIconAndLabel(element, isSelected, itemSize,
|
|
2103
|
+
function resolveIconAndLabel(element, isSelected, itemSize, showCheck, iconBehavior, labelBehavior) {
|
|
1798
2104
|
let icon = element.props.icon;
|
|
1799
2105
|
let label = element.props.children;
|
|
1800
2106
|
const animateCheckInLabel = showCheck && iconBehavior !== "none" && iconBehavior !== "selected" && label !== void 0;
|
|
@@ -1810,51 +2116,12 @@ function resolveIconAndLabel(element, isSelected, itemSize, variant, showCheck,
|
|
|
1810
2116
|
}
|
|
1811
2117
|
if (animateCheckInLabel && label !== void 0) {
|
|
1812
2118
|
label = /* @__PURE__ */ jsx(AnimatedCheckLabel, { selected: isSelected, size: itemSize, children: label });
|
|
1813
|
-
} else if (variant === "navbar" && label !== void 0) {
|
|
1814
|
-
const showLabel = !labelBehavior || labelBehavior === "all" || labelBehavior === "selected" && isSelected;
|
|
1815
|
-
label = /* @__PURE__ */ jsx(AnimatedNavbarLabel, { show: showLabel, children: label });
|
|
1816
2119
|
}
|
|
1817
2120
|
return { icon, label };
|
|
1818
2121
|
}
|
|
1819
|
-
function
|
|
1820
|
-
const increment = expandedRatio * PADDING_EXPAND_MULTIPLIER;
|
|
1821
|
-
if (activeMorphing) {
|
|
1822
|
-
const isFlexLayout = fullWidth || variant === "connected" && orientation === "horizontal";
|
|
1823
|
-
if (isFlexLayout) {
|
|
1824
|
-
if (isSelected) return { flexGrow: 1 + expandedRatio };
|
|
1825
|
-
if (hasSelected && count > 1)
|
|
1826
|
-
return {
|
|
1827
|
-
flexGrow: Math.max(MIN_FLEX_GROW, 1 - expandedRatio / (count - 1))
|
|
1828
|
-
};
|
|
1829
|
-
return { flexGrow: 1 };
|
|
1830
|
-
}
|
|
1831
|
-
if (isSelected)
|
|
1832
|
-
return { paddingInline: `calc(${basePx} + ${increment}rem)` };
|
|
1833
|
-
if (hasSelected && count > 1) {
|
|
1834
|
-
const decrement = increment / (count - 1);
|
|
1835
|
-
return { paddingInline: `calc(${basePx} - ${decrement}rem)` };
|
|
1836
|
-
}
|
|
1837
|
-
return { paddingInline: basePx };
|
|
1838
|
-
}
|
|
1839
|
-
if (morphingWidth && variant === "standard") {
|
|
1840
|
-
if (fullWidth) return { flexGrow: isPressed ? 1 + expandedRatio : 1 };
|
|
1841
|
-
return {
|
|
1842
|
-
paddingInline: isPressed ? `calc(${basePx} + ${increment}rem)` : basePx
|
|
1843
|
-
};
|
|
1844
|
-
}
|
|
1845
|
-
return {};
|
|
1846
|
-
}
|
|
1847
|
-
function buildMotionProps(variant, isSelected, isPressed, itemSize, shapes, flex, existingAnimate, existingWhileTap) {
|
|
2122
|
+
function buildMotionProps(variant, isSelected, isPressed, itemSize, shapes, existingAnimate, existingWhileTap) {
|
|
1848
2123
|
var _a, _b;
|
|
1849
2124
|
const props = { animate: __spreadValues({}, existingAnimate) };
|
|
1850
|
-
if (variant !== "navbar") {
|
|
1851
|
-
if (flex.flexGrow !== void 0) {
|
|
1852
|
-
props.animate.flexGrow = flex.flexGrow;
|
|
1853
|
-
}
|
|
1854
|
-
if (flex.paddingInline !== void 0) {
|
|
1855
|
-
props.animate.paddingInline = flex.paddingInline;
|
|
1856
|
-
}
|
|
1857
|
-
}
|
|
1858
2125
|
if (variant === "standard") {
|
|
1859
2126
|
const pressedRadius = (_a = PRESSED_RADIUS_MAP[itemSize]) != null ? _a : PRESSED_RADIUS_MAP.sm;
|
|
1860
2127
|
const itemSizeTokens = (_b = BUTTON_SIZE_TOKENS[itemSize]) != null ? _b : BUTTON_SIZE_TOKENS.sm;
|
|
@@ -1865,9 +2132,6 @@ function buildMotionProps(variant, isSelected, isPressed, itemSize, shapes, flex
|
|
|
1865
2132
|
}, existingWhileTap);
|
|
1866
2133
|
props.transition = {
|
|
1867
2134
|
borderRadius: BUTTON_RADIUS_SPRING,
|
|
1868
|
-
flexGrow: WIDTH_MORPH_SPRING,
|
|
1869
|
-
paddingInline: WIDTH_MORPH_SPRING,
|
|
1870
|
-
layout: WIDTH_MORPH_SPRING,
|
|
1871
2135
|
default: BUTTON_SHAPE_MORPH_SPRING
|
|
1872
2136
|
};
|
|
1873
2137
|
props.layout = true;
|
|
@@ -1894,26 +2158,16 @@ function buildMotionProps(variant, isSelected, isPressed, itemSize, shapes, flex
|
|
|
1894
2158
|
borderBottomLeftRadius: shapes.pressed.bl
|
|
1895
2159
|
}, existingWhileTap);
|
|
1896
2160
|
props.transition = __spreadProps(__spreadValues({}, BUTTON_SHAPE_MORPH_SPRING), {
|
|
1897
|
-
flexGrow: WIDTH_MORPH_SPRING,
|
|
1898
|
-
paddingInline: WIDTH_MORPH_SPRING,
|
|
1899
2161
|
borderTopLeftRadius: BUTTON_RADIUS_SPRING,
|
|
1900
2162
|
borderTopRightRadius: BUTTON_RADIUS_SPRING,
|
|
1901
2163
|
borderBottomRightRadius: BUTTON_RADIUS_SPRING,
|
|
1902
|
-
borderBottomLeftRadius: BUTTON_RADIUS_SPRING
|
|
1903
|
-
layout: WIDTH_MORPH_SPRING
|
|
2164
|
+
borderBottomLeftRadius: BUTTON_RADIUS_SPRING
|
|
1904
2165
|
});
|
|
1905
2166
|
props.layout = true;
|
|
1906
2167
|
}
|
|
1907
|
-
if (variant === "navbar") {
|
|
1908
|
-
props.layout = true;
|
|
1909
|
-
props.transition = {
|
|
1910
|
-
layout: WIDTH_MORPH_SPRING,
|
|
1911
|
-
default: BUTTON_SHAPE_MORPH_SPRING
|
|
1912
|
-
};
|
|
1913
|
-
}
|
|
1914
2168
|
return props;
|
|
1915
2169
|
}
|
|
1916
|
-
var ButtonGroupComponent =
|
|
2170
|
+
var ButtonGroupComponent = React16.forwardRef(
|
|
1917
2171
|
(_a, ref) => {
|
|
1918
2172
|
var _b = _a, {
|
|
1919
2173
|
className,
|
|
@@ -1921,10 +2175,7 @@ var ButtonGroupComponent = React11.forwardRef(
|
|
|
1921
2175
|
orientation = "horizontal",
|
|
1922
2176
|
fullWidth = false,
|
|
1923
2177
|
size,
|
|
1924
|
-
morphingWidth = true,
|
|
1925
|
-
activeMorphing = false,
|
|
1926
2178
|
itemClassName,
|
|
1927
|
-
expandedRatio = ButtonGroupDefaults.expandedRatio,
|
|
1928
2179
|
showCheck = false,
|
|
1929
2180
|
children,
|
|
1930
2181
|
iconBehavior,
|
|
@@ -1936,126 +2187,50 @@ var ButtonGroupComponent = React11.forwardRef(
|
|
|
1936
2187
|
"orientation",
|
|
1937
2188
|
"fullWidth",
|
|
1938
2189
|
"size",
|
|
1939
|
-
"morphingWidth",
|
|
1940
|
-
"activeMorphing",
|
|
1941
2190
|
"itemClassName",
|
|
1942
|
-
"expandedRatio",
|
|
1943
2191
|
"showCheck",
|
|
1944
2192
|
"children",
|
|
1945
2193
|
"iconBehavior",
|
|
1946
2194
|
"labelBehavior",
|
|
1947
2195
|
"style"
|
|
1948
2196
|
]);
|
|
1949
|
-
const [pressedIndex, setPressedIndex] =
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1952
|
-
);
|
|
1953
|
-
const layoutIdGroup = React11.useId();
|
|
1954
|
-
const rootRef = React11.useRef(null);
|
|
1955
|
-
const setRootRef = React11.useCallback(
|
|
1956
|
-
(node) => {
|
|
1957
|
-
rootRef.current = node;
|
|
1958
|
-
if (typeof ref === "function") {
|
|
1959
|
-
ref(node);
|
|
1960
|
-
} else if (ref) {
|
|
1961
|
-
ref.current = node;
|
|
1962
|
-
}
|
|
1963
|
-
},
|
|
1964
|
-
[ref]
|
|
1965
|
-
);
|
|
1966
|
-
const childrenArray = React11.useMemo(
|
|
1967
|
-
() => React11.Children.toArray(children).filter(React11.isValidElement),
|
|
2197
|
+
const [pressedIndex, setPressedIndex] = React16.useState(null);
|
|
2198
|
+
const childrenArray = React16.useMemo(
|
|
2199
|
+
() => React16.Children.toArray(children).filter(React16.isValidElement),
|
|
1968
2200
|
[children]
|
|
1969
2201
|
);
|
|
1970
2202
|
const count = childrenArray.length;
|
|
1971
|
-
const
|
|
1972
|
-
() => `${childrenArray.map((child, index) => {
|
|
1973
|
-
var _a2, _b2, _c, _d, _e;
|
|
1974
|
-
const element = child;
|
|
1975
|
-
const label = typeof element.props.children === "string" || typeof element.props.children === "number" ? element.props.children : (_a2 = element.key) != null ? _a2 : index;
|
|
1976
|
-
return [
|
|
1977
|
-
(_b2 = element.key) != null ? _b2 : index,
|
|
1978
|
-
(_d = (_c = element.props.size) != null ? _c : size) != null ? _d : "",
|
|
1979
|
-
label,
|
|
1980
|
-
Boolean(element.props.icon),
|
|
1981
|
-
(_e = element.props.className) != null ? _e : ""
|
|
1982
|
-
].join(":");
|
|
1983
|
-
}).join("|")}|${variant}|${orientation}|${showCheck}`,
|
|
1984
|
-
[childrenArray, orientation, showCheck, size, variant]
|
|
1985
|
-
);
|
|
1986
|
-
const groupSizeSignatureRef = React11.useRef(groupSizeSignature);
|
|
1987
|
-
React11.useLayoutEffect(() => {
|
|
1988
|
-
if (groupSizeSignatureRef.current !== groupSizeSignature) {
|
|
1989
|
-
groupSizeSignatureRef.current = groupSizeSignature;
|
|
1990
|
-
setLockedGroupSize(null);
|
|
1991
|
-
}
|
|
1992
|
-
}, [groupSizeSignature]);
|
|
1993
|
-
const hasExplicitGroupSize = orientation === "horizontal" ? (style == null ? void 0 : style.width) !== void 0 || (style == null ? void 0 : style.inlineSize) !== void 0 : (style == null ? void 0 : style.height) !== void 0 || (style == null ? void 0 : style.blockSize) !== void 0;
|
|
1994
|
-
const shouldLockGroupSize = activeMorphing && !fullWidth && !hasExplicitGroupSize && count > 1;
|
|
1995
|
-
React11.useLayoutEffect(() => {
|
|
1996
|
-
if (!shouldLockGroupSize) {
|
|
1997
|
-
if (lockedGroupSize !== null) setLockedGroupSize(null);
|
|
1998
|
-
return;
|
|
1999
|
-
}
|
|
2000
|
-
if (lockedGroupSize !== null) return;
|
|
2001
|
-
const node = rootRef.current;
|
|
2002
|
-
if (!node) return;
|
|
2003
|
-
const rect = node.getBoundingClientRect();
|
|
2004
|
-
const nextSize = orientation === "horizontal" ? rect.width : rect.height;
|
|
2005
|
-
if (nextSize > 0) {
|
|
2006
|
-
setLockedGroupSize(Math.ceil(nextSize * 100) / 100);
|
|
2007
|
-
}
|
|
2008
|
-
}, [lockedGroupSize, orientation, shouldLockGroupSize]);
|
|
2009
|
-
const groupStyle = React11.useMemo(() => {
|
|
2010
|
-
const nextStyle = __spreadValues({}, style);
|
|
2011
|
-
if (shouldLockGroupSize && lockedGroupSize !== null) {
|
|
2012
|
-
if (orientation === "horizontal") {
|
|
2013
|
-
nextStyle.inlineSize = `${lockedGroupSize}px`;
|
|
2014
|
-
} else {
|
|
2015
|
-
nextStyle.blockSize = `${lockedGroupSize}px`;
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
return nextStyle;
|
|
2019
|
-
}, [lockedGroupSize, orientation, shouldLockGroupSize, style]);
|
|
2020
|
-
const hasSelected = React11.useMemo(
|
|
2021
|
-
() => childrenArray.some(
|
|
2022
|
-
(child) => child.props.selected
|
|
2023
|
-
),
|
|
2024
|
-
[childrenArray]
|
|
2025
|
-
);
|
|
2026
|
-
const handlePointerLeaveAndUp = React11.useCallback(() => {
|
|
2203
|
+
const handlePointerLeaveAndUp = React16.useCallback(() => {
|
|
2027
2204
|
setPressedIndex(null);
|
|
2028
2205
|
}, []);
|
|
2029
2206
|
return /* @__PURE__ */ jsx(
|
|
2030
2207
|
"fieldset",
|
|
2031
2208
|
__spreadProps(__spreadValues({
|
|
2032
|
-
ref
|
|
2209
|
+
ref,
|
|
2033
2210
|
className: cn(
|
|
2034
2211
|
"inline-flex p-0 m-0 border-none max-w-full [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
2035
2212
|
orientation === "vertical" ? "flex-col items-stretch overflow-y-auto overflow-x-hidden" : "flex-row overflow-x-auto overflow-y-hidden",
|
|
2036
|
-
variant === "standard" ? "gap-3" :
|
|
2213
|
+
variant === "standard" ? "gap-3" : "gap-0.5",
|
|
2037
2214
|
fullWidth && "w-full",
|
|
2038
2215
|
fullWidth && orientation === "vertical" && "h-full",
|
|
2039
2216
|
className
|
|
2040
2217
|
),
|
|
2041
|
-
style
|
|
2218
|
+
style,
|
|
2042
2219
|
onPointerLeave: handlePointerLeaveAndUp,
|
|
2043
2220
|
onPointerUp: handlePointerLeaveAndUp
|
|
2044
2221
|
}, props), {
|
|
2045
2222
|
children: childrenArray.map((child, index) => {
|
|
2046
|
-
var _a2
|
|
2223
|
+
var _a2;
|
|
2047
2224
|
const element = child;
|
|
2048
2225
|
const isSelected = element.props.selected === true;
|
|
2049
2226
|
const isFirst = index === 0;
|
|
2050
2227
|
const isLast = index === count - 1;
|
|
2051
2228
|
const itemSize = size || element.props.size || "sm";
|
|
2052
|
-
const basePx = ((_a2 = BUTTON_SIZE_TOKENS[itemSize]) == null ? void 0 : _a2.leadingSpace) || "1rem";
|
|
2053
2229
|
const isPressed = pressedIndex === index;
|
|
2054
2230
|
const { icon: explicitIcon, label: explicitLabel } = resolveIconAndLabel(
|
|
2055
2231
|
element,
|
|
2056
2232
|
isSelected,
|
|
2057
2233
|
itemSize,
|
|
2058
|
-
variant,
|
|
2059
2234
|
showCheck,
|
|
2060
2235
|
iconBehavior,
|
|
2061
2236
|
labelBehavior
|
|
@@ -2067,25 +2242,6 @@ var ButtonGroupComponent = React11.forwardRef(
|
|
|
2067
2242
|
isLast,
|
|
2068
2243
|
itemSize
|
|
2069
2244
|
);
|
|
2070
|
-
const flex = resolveFlexTargets(
|
|
2071
|
-
variant,
|
|
2072
|
-
orientation,
|
|
2073
|
-
isSelected,
|
|
2074
|
-
isPressed,
|
|
2075
|
-
hasSelected,
|
|
2076
|
-
count,
|
|
2077
|
-
fullWidth,
|
|
2078
|
-
activeMorphing,
|
|
2079
|
-
morphingWidth,
|
|
2080
|
-
expandedRatio,
|
|
2081
|
-
basePx
|
|
2082
|
-
);
|
|
2083
|
-
const dynamicStyle = __spreadValues({}, element.props.style);
|
|
2084
|
-
if (variant !== "navbar" && flex.flexGrow !== void 0 && fullWidth) {
|
|
2085
|
-
dynamicStyle.flexBasis = 0;
|
|
2086
|
-
dynamicStyle.flexShrink = 1;
|
|
2087
|
-
dynamicStyle.minWidth = 0;
|
|
2088
|
-
}
|
|
2089
2245
|
const existingAnimate = typeof element.props.animate === "object" && !Array.isArray(element.props.animate) ? element.props.animate : {};
|
|
2090
2246
|
const existingWhileTap = typeof element.props.whileTap === "object" && !Array.isArray(element.props.whileTap) ? element.props.whileTap : {};
|
|
2091
2247
|
const motionProps = buildMotionProps(
|
|
@@ -2094,19 +2250,12 @@ var ButtonGroupComponent = React11.forwardRef(
|
|
|
2094
2250
|
isPressed,
|
|
2095
2251
|
itemSize,
|
|
2096
2252
|
shapes,
|
|
2097
|
-
flex,
|
|
2098
2253
|
existingAnimate,
|
|
2099
2254
|
existingWhileTap
|
|
2100
2255
|
);
|
|
2101
2256
|
const connectedClasses = variant === "connected" && isSelected ? "z-20" : "";
|
|
2102
|
-
const
|
|
2103
|
-
|
|
2104
|
-
flexShrink: fullWidth ? 1 : 0,
|
|
2105
|
-
flexGrow: flex.flexGrow,
|
|
2106
|
-
minWidth: labelBehavior !== "selected" ? 0 : "fit-content"
|
|
2107
|
-
} : {};
|
|
2108
|
-
const clonedElement = React11.cloneElement(element, __spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues({
|
|
2109
|
-
key: (_b2 = element.key) != null ? _b2 : index,
|
|
2257
|
+
const clonedElement = React16.cloneElement(element, __spreadValues(__spreadProps(__spreadValues({
|
|
2258
|
+
key: (_a2 = element.key) != null ? _a2 : index,
|
|
2110
2259
|
tabIndex: isFirst ? 0 : -1,
|
|
2111
2260
|
size: size || element.props.size,
|
|
2112
2261
|
icon: explicitIcon,
|
|
@@ -2114,71 +2263,20 @@ var ButtonGroupComponent = React11.forwardRef(
|
|
|
2114
2263
|
}, variant === "connected" && {
|
|
2115
2264
|
colorStyle: element.props.colorStyle || "tonal",
|
|
2116
2265
|
selectedColorStyle: element.props.selectedColorStyle || "filled"
|
|
2117
|
-
}),
|
|
2118
|
-
colorStyle: "text",
|
|
2119
|
-
selectedColorStyle: "text",
|
|
2120
|
-
className: cn(
|
|
2121
|
-
element.props.className,
|
|
2122
|
-
"w-full! h-full! px-3! min-w-0! relative z-20 flex items-center justify-center",
|
|
2123
|
-
isSelected ? "text-m3-on-secondary-container! hover:bg-transparent! active:bg-transparent!" : "text-m3-on-surface-variant! hover:bg-transparent! active:bg-transparent!",
|
|
2124
|
-
itemClassName
|
|
2125
|
-
)
|
|
2126
|
-
}), variant !== "navbar" && {
|
|
2266
|
+
}), {
|
|
2127
2267
|
className: cn(
|
|
2128
2268
|
element.props.className,
|
|
2129
2269
|
connectedClasses,
|
|
2130
2270
|
"focus-visible:z-10 hover:z-10 relative min-w-0",
|
|
2131
2271
|
orientation === "vertical" && "w-full",
|
|
2272
|
+
fullWidth && "flex-1",
|
|
2132
2273
|
itemClassName
|
|
2133
|
-
)
|
|
2134
|
-
}), {
|
|
2135
|
-
style: variant === "navbar" ? __spreadProps(__spreadValues({}, dynamicStyle), { minWidth: 0 }) : dynamicStyle,
|
|
2274
|
+
),
|
|
2136
2275
|
onPointerDown: (e) => {
|
|
2137
2276
|
setPressedIndex(index);
|
|
2138
2277
|
if (element.props.onPointerDown) element.props.onPointerDown(e);
|
|
2139
2278
|
}
|
|
2140
2279
|
}), motionProps));
|
|
2141
|
-
if (variant === "navbar") {
|
|
2142
|
-
return /* @__PURE__ */ jsxs(
|
|
2143
|
-
m.div,
|
|
2144
|
-
{
|
|
2145
|
-
layout: true,
|
|
2146
|
-
whileTap: { scale: 0.96 },
|
|
2147
|
-
transition: NAVBAR_EXPRESSIVE_SPRING,
|
|
2148
|
-
className: "group relative h-full flex items-center justify-center min-w-0",
|
|
2149
|
-
style: navbarFlexStyle,
|
|
2150
|
-
children: [
|
|
2151
|
-
/* @__PURE__ */ jsxs(
|
|
2152
|
-
"div",
|
|
2153
|
-
{
|
|
2154
|
-
className: "absolute inset-x-1 inset-y-0 m-auto flex items-center justify-center pointer-events-none",
|
|
2155
|
-
style: { zIndex: 1 },
|
|
2156
|
-
children: [
|
|
2157
|
-
/* @__PURE__ */ jsx(
|
|
2158
|
-
"div",
|
|
2159
|
-
{
|
|
2160
|
-
className: "w-full h-[40px] bg-m3-on-surface-variant/8 opacity-0 group-hover:opacity-100 transition-opacity duration-200",
|
|
2161
|
-
style: { borderRadius: PILL_BORDER_RADIUS }
|
|
2162
|
-
}
|
|
2163
|
-
),
|
|
2164
|
-
/* @__PURE__ */ jsx(AnimatePresence, { children: isSelected && /* @__PURE__ */ jsx(
|
|
2165
|
-
m.div,
|
|
2166
|
-
{
|
|
2167
|
-
layoutId: `navbar-active-indicator-${layoutIdGroup}`,
|
|
2168
|
-
className: "absolute inset-0 m-auto w-full h-[40px] bg-m3-secondary-container",
|
|
2169
|
-
style: { borderRadius: PILL_BORDER_RADIUS },
|
|
2170
|
-
transition: NAVBAR_EXPRESSIVE_SPRING
|
|
2171
|
-
}
|
|
2172
|
-
) })
|
|
2173
|
-
]
|
|
2174
|
-
}
|
|
2175
|
-
),
|
|
2176
|
-
clonedElement
|
|
2177
|
-
]
|
|
2178
|
-
},
|
|
2179
|
-
(_c = element.key) != null ? _c : index
|
|
2180
|
-
);
|
|
2181
|
-
}
|
|
2182
2280
|
return clonedElement;
|
|
2183
2281
|
})
|
|
2184
2282
|
})
|
|
@@ -2186,7 +2284,7 @@ var ButtonGroupComponent = React11.forwardRef(
|
|
|
2186
2284
|
}
|
|
2187
2285
|
);
|
|
2188
2286
|
ButtonGroupComponent.displayName = "ButtonGroup";
|
|
2189
|
-
var ButtonGroup =
|
|
2287
|
+
var ButtonGroup = React16.memo(ButtonGroupComponent);
|
|
2190
2288
|
var SIZE_HEIGHT = {
|
|
2191
2289
|
sm: "h-14",
|
|
2192
2290
|
md: "h-20",
|
|
@@ -2241,9 +2339,9 @@ var COLOR_CLASSES = {
|
|
|
2241
2339
|
}
|
|
2242
2340
|
};
|
|
2243
2341
|
function useScrollCollapse(enabled, scrollThreshold, onCollapsedChange) {
|
|
2244
|
-
const [collapsed, setCollapsed] =
|
|
2245
|
-
const lastScrollY =
|
|
2246
|
-
|
|
2342
|
+
const [collapsed, setCollapsed] = React16.useState(false);
|
|
2343
|
+
const lastScrollY = React16.useRef(0);
|
|
2344
|
+
React16.useEffect(() => {
|
|
2247
2345
|
if (!enabled || typeof window === "undefined") return;
|
|
2248
2346
|
lastScrollY.current = window.scrollY;
|
|
2249
2347
|
const handleScroll = () => {
|
|
@@ -2266,7 +2364,7 @@ function useScrollCollapse(enabled, scrollThreshold, onCollapsedChange) {
|
|
|
2266
2364
|
}, [enabled, scrollThreshold, collapsed, onCollapsedChange]);
|
|
2267
2365
|
return collapsed;
|
|
2268
2366
|
}
|
|
2269
|
-
var ExtendedFABComponent =
|
|
2367
|
+
var ExtendedFABComponent = React16.forwardRef(
|
|
2270
2368
|
(_a, ref) => {
|
|
2271
2369
|
var _b = _a, {
|
|
2272
2370
|
className,
|
|
@@ -2283,6 +2381,8 @@ var ExtendedFABComponent = React11.forwardRef(
|
|
|
2283
2381
|
scrollThreshold = 50,
|
|
2284
2382
|
collapsed,
|
|
2285
2383
|
onCollapsedChange,
|
|
2384
|
+
asChild = false,
|
|
2385
|
+
children,
|
|
2286
2386
|
onClick,
|
|
2287
2387
|
onKeyDown,
|
|
2288
2388
|
layoutId,
|
|
@@ -2302,16 +2402,18 @@ var ExtendedFABComponent = React11.forwardRef(
|
|
|
2302
2402
|
"scrollThreshold",
|
|
2303
2403
|
"collapsed",
|
|
2304
2404
|
"onCollapsedChange",
|
|
2405
|
+
"asChild",
|
|
2406
|
+
"children",
|
|
2305
2407
|
"onClick",
|
|
2306
2408
|
"onKeyDown",
|
|
2307
2409
|
"layoutId",
|
|
2308
2410
|
"aria-label"
|
|
2309
2411
|
]);
|
|
2310
2412
|
var _a2, _b2, _c, _d;
|
|
2311
|
-
const localRef =
|
|
2312
|
-
|
|
2313
|
-
const [dir, setDir] =
|
|
2314
|
-
|
|
2413
|
+
const localRef = React16.useRef(null);
|
|
2414
|
+
React16.useImperativeHandle(ref, () => localRef.current);
|
|
2415
|
+
const [dir, setDir] = React16.useState("ltr");
|
|
2416
|
+
React16.useEffect(() => {
|
|
2315
2417
|
var _a3;
|
|
2316
2418
|
if (!localRef.current) return;
|
|
2317
2419
|
const closestDir = (_a3 = localRef.current.closest("[dir]")) == null ? void 0 : _a3.getAttribute("dir");
|
|
@@ -2332,7 +2434,7 @@ var ExtendedFABComponent = React11.forwardRef(
|
|
|
2332
2434
|
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
2333
2435
|
disabled: loading
|
|
2334
2436
|
});
|
|
2335
|
-
const handleClick =
|
|
2437
|
+
const handleClick = React16.useCallback(
|
|
2336
2438
|
(e) => {
|
|
2337
2439
|
if (loading) {
|
|
2338
2440
|
e.preventDefault();
|
|
@@ -2342,7 +2444,7 @@ var ExtendedFABComponent = React11.forwardRef(
|
|
|
2342
2444
|
},
|
|
2343
2445
|
[loading, onClick]
|
|
2344
2446
|
);
|
|
2345
|
-
const handleKeyDown =
|
|
2447
|
+
const handleKeyDown = React16.useCallback(
|
|
2346
2448
|
(e) => {
|
|
2347
2449
|
if (loading) return;
|
|
2348
2450
|
if ((e.key === "Enter" || e.key === " ") && onClick) {
|
|
@@ -2353,7 +2455,109 @@ var ExtendedFABComponent = React11.forwardRef(
|
|
|
2353
2455
|
},
|
|
2354
2456
|
[loading, onClick, onKeyDown]
|
|
2355
2457
|
);
|
|
2356
|
-
|
|
2458
|
+
const containerClassName = cn(
|
|
2459
|
+
"relative shrink-0 inline-flex items-center select-none cursor-pointer overflow-hidden",
|
|
2460
|
+
"transition-[box-shadow,filter] duration-200",
|
|
2461
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2",
|
|
2462
|
+
"disabled:pointer-events-none disabled:opacity-[0.38] disabled:shadow-none",
|
|
2463
|
+
colors.bg,
|
|
2464
|
+
colors.text,
|
|
2465
|
+
lowered ? "shadow-sm" : "shadow-md",
|
|
2466
|
+
(_d = SIZE_HEIGHT[size]) != null ? _d : "h-14",
|
|
2467
|
+
SIZE_TEXT[size],
|
|
2468
|
+
isCollapsed ? cn("px-0 justify-center", SIZE_WIDTH_COLLAPSED[size]) : cn(
|
|
2469
|
+
hasIcon ? "justify-start" : "justify-center",
|
|
2470
|
+
SIZE_PADDING[size],
|
|
2471
|
+
hasIcon && SIZE_GAP[size]
|
|
2472
|
+
),
|
|
2473
|
+
dir === "rtl" || restProps.dir === "rtl" ? "flex-row-reverse" : "flex-row",
|
|
2474
|
+
loading && "pointer-events-none opacity-75 cursor-not-allowed",
|
|
2475
|
+
className
|
|
2476
|
+
);
|
|
2477
|
+
const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2478
|
+
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
2479
|
+
hasIcon && /* @__PURE__ */ jsx(
|
|
2480
|
+
m.span,
|
|
2481
|
+
{
|
|
2482
|
+
layout: "position",
|
|
2483
|
+
className: cn(
|
|
2484
|
+
"flex items-center justify-center shrink-0",
|
|
2485
|
+
sizeIcon.cls
|
|
2486
|
+
),
|
|
2487
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
|
|
2488
|
+
m.span,
|
|
2489
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
2490
|
+
transition: SPRING_TRANSITION,
|
|
2491
|
+
className: "flex items-center justify-center shrink-0 w-full h-full",
|
|
2492
|
+
children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
|
|
2493
|
+
LoadingIndicator,
|
|
2494
|
+
{
|
|
2495
|
+
size: sizeIcon.px,
|
|
2496
|
+
color: "currentColor",
|
|
2497
|
+
"aria-label": "Loading"
|
|
2498
|
+
}
|
|
2499
|
+
) : /* @__PURE__ */ jsx(
|
|
2500
|
+
ProgressIndicator,
|
|
2501
|
+
{
|
|
2502
|
+
variant: "circular",
|
|
2503
|
+
size: sizeIcon.px,
|
|
2504
|
+
color: "currentColor",
|
|
2505
|
+
trackColor: "transparent",
|
|
2506
|
+
"aria-label": "Loading"
|
|
2507
|
+
}
|
|
2508
|
+
)
|
|
2509
|
+
}),
|
|
2510
|
+
"loading"
|
|
2511
|
+
) : icon && /* @__PURE__ */ jsx(
|
|
2512
|
+
m.span,
|
|
2513
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
2514
|
+
transition: SPRING_TRANSITION,
|
|
2515
|
+
"aria-hidden": "true",
|
|
2516
|
+
className: "flex items-center justify-center shrink-0 w-full h-full [&>svg]:w-full [&>svg]:h-full",
|
|
2517
|
+
children: icon
|
|
2518
|
+
}),
|
|
2519
|
+
"icon"
|
|
2520
|
+
) })
|
|
2521
|
+
}
|
|
2522
|
+
),
|
|
2523
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: !isCollapsed && /* @__PURE__ */ jsx(
|
|
2524
|
+
m.span,
|
|
2525
|
+
{
|
|
2526
|
+
layout: "position",
|
|
2527
|
+
initial: { opacity: 0, width: 0 },
|
|
2528
|
+
animate: { opacity: 1, width: "auto" },
|
|
2529
|
+
exit: { opacity: 0, width: 0 },
|
|
2530
|
+
transition: {
|
|
2531
|
+
opacity: { duration: 0.15, ease: "linear" },
|
|
2532
|
+
width: SPRING_TRANSITION
|
|
2533
|
+
},
|
|
2534
|
+
className: "overflow-hidden whitespace-nowrap",
|
|
2535
|
+
children: label
|
|
2536
|
+
},
|
|
2537
|
+
"label"
|
|
2538
|
+
) })
|
|
2539
|
+
] });
|
|
2540
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(AnimatePresence, { children: visible && !(isCollapsed && !hasIcon) && (asChild ? /* @__PURE__ */ jsx(
|
|
2541
|
+
Slot,
|
|
2542
|
+
__spreadProps(__spreadValues({
|
|
2543
|
+
ref: localRef,
|
|
2544
|
+
"aria-label": ariaLabel || label,
|
|
2545
|
+
"aria-busy": loading || void 0,
|
|
2546
|
+
"aria-disabled": loading || restProps.disabled,
|
|
2547
|
+
onClick: handleClick,
|
|
2548
|
+
onPointerDown,
|
|
2549
|
+
onKeyDown: handleKeyDown,
|
|
2550
|
+
style: __spreadProps(__spreadValues({}, style), {
|
|
2551
|
+
borderRadius: `${radiusConfig.default}px`
|
|
2552
|
+
}),
|
|
2553
|
+
className: containerClassName
|
|
2554
|
+
}, restProps), {
|
|
2555
|
+
children: React16.cloneElement(
|
|
2556
|
+
React16.Children.only(children),
|
|
2557
|
+
{ children: innerContent }
|
|
2558
|
+
)
|
|
2559
|
+
})
|
|
2560
|
+
) : /* @__PURE__ */ jsx(
|
|
2357
2561
|
m.button,
|
|
2358
2562
|
__spreadProps(__spreadValues({
|
|
2359
2563
|
ref: localRef,
|
|
@@ -2385,95 +2589,15 @@ var ExtendedFABComponent = React11.forwardRef(
|
|
|
2385
2589
|
opacity: { duration: 0.2, ease: "linear" },
|
|
2386
2590
|
layout: SPRING_TRANSITION
|
|
2387
2591
|
},
|
|
2388
|
-
className:
|
|
2389
|
-
"relative shrink-0 inline-flex items-center select-none cursor-pointer overflow-hidden",
|
|
2390
|
-
"transition-[box-shadow,filter] duration-200",
|
|
2391
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2",
|
|
2392
|
-
"disabled:pointer-events-none disabled:opacity-[0.38] disabled:shadow-none",
|
|
2393
|
-
colors.bg,
|
|
2394
|
-
colors.text,
|
|
2395
|
-
lowered ? "shadow-sm" : "shadow-md",
|
|
2396
|
-
(_d = SIZE_HEIGHT[size]) != null ? _d : "h-14",
|
|
2397
|
-
SIZE_TEXT[size],
|
|
2398
|
-
isCollapsed ? cn("px-0 justify-center", SIZE_WIDTH_COLLAPSED[size]) : cn(
|
|
2399
|
-
hasIcon ? "justify-start" : "justify-center",
|
|
2400
|
-
SIZE_PADDING[size],
|
|
2401
|
-
hasIcon && SIZE_GAP[size]
|
|
2402
|
-
),
|
|
2403
|
-
dir === "rtl" || restProps.dir === "rtl" ? "flex-row-reverse" : "flex-row",
|
|
2404
|
-
loading && "pointer-events-none opacity-75 cursor-not-allowed",
|
|
2405
|
-
className
|
|
2406
|
-
)
|
|
2592
|
+
className: containerClassName
|
|
2407
2593
|
}, restProps), {
|
|
2408
|
-
children:
|
|
2409
|
-
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
2410
|
-
hasIcon && /* @__PURE__ */ jsx(
|
|
2411
|
-
m.span,
|
|
2412
|
-
{
|
|
2413
|
-
layout: "position",
|
|
2414
|
-
className: cn(
|
|
2415
|
-
"flex items-center justify-center shrink-0",
|
|
2416
|
-
sizeIcon.cls
|
|
2417
|
-
),
|
|
2418
|
-
children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
|
|
2419
|
-
m.span,
|
|
2420
|
-
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
2421
|
-
transition: SPRING_TRANSITION,
|
|
2422
|
-
className: "flex items-center justify-center shrink-0 w-full h-full",
|
|
2423
|
-
children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
|
|
2424
|
-
LoadingIndicator,
|
|
2425
|
-
{
|
|
2426
|
-
size: sizeIcon.px,
|
|
2427
|
-
color: "currentColor",
|
|
2428
|
-
"aria-label": "Loading"
|
|
2429
|
-
}
|
|
2430
|
-
) : /* @__PURE__ */ jsx(
|
|
2431
|
-
ProgressIndicator,
|
|
2432
|
-
{
|
|
2433
|
-
variant: "circular",
|
|
2434
|
-
size: sizeIcon.px,
|
|
2435
|
-
color: "currentColor",
|
|
2436
|
-
trackColor: "transparent",
|
|
2437
|
-
"aria-label": "Loading"
|
|
2438
|
-
}
|
|
2439
|
-
)
|
|
2440
|
-
}),
|
|
2441
|
-
"loading"
|
|
2442
|
-
) : icon && /* @__PURE__ */ jsx(
|
|
2443
|
-
m.span,
|
|
2444
|
-
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
2445
|
-
transition: SPRING_TRANSITION,
|
|
2446
|
-
"aria-hidden": "true",
|
|
2447
|
-
className: "flex items-center justify-center shrink-0 w-full h-full [&>svg]:w-full [&>svg]:h-full",
|
|
2448
|
-
children: icon
|
|
2449
|
-
}),
|
|
2450
|
-
"icon"
|
|
2451
|
-
) })
|
|
2452
|
-
}
|
|
2453
|
-
),
|
|
2454
|
-
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: !isCollapsed && /* @__PURE__ */ jsx(
|
|
2455
|
-
m.span,
|
|
2456
|
-
{
|
|
2457
|
-
layout: "position",
|
|
2458
|
-
initial: { opacity: 0, width: 0 },
|
|
2459
|
-
animate: { opacity: 1, width: "auto" },
|
|
2460
|
-
exit: { opacity: 0, width: 0 },
|
|
2461
|
-
transition: {
|
|
2462
|
-
opacity: { duration: 0.15, ease: "linear" },
|
|
2463
|
-
width: SPRING_TRANSITION
|
|
2464
|
-
},
|
|
2465
|
-
className: "overflow-hidden whitespace-nowrap",
|
|
2466
|
-
children: label
|
|
2467
|
-
},
|
|
2468
|
-
"label"
|
|
2469
|
-
) })
|
|
2470
|
-
]
|
|
2594
|
+
children: innerContent
|
|
2471
2595
|
})
|
|
2472
|
-
) }) });
|
|
2596
|
+
)) }) });
|
|
2473
2597
|
}
|
|
2474
2598
|
);
|
|
2475
2599
|
ExtendedFABComponent.displayName = "ExtendedFAB";
|
|
2476
|
-
var ExtendedFAB =
|
|
2600
|
+
var ExtendedFAB = React16.memo(ExtendedFABComponent);
|
|
2477
2601
|
var SIZE_STYLES = {
|
|
2478
2602
|
sm: "h-10 w-10",
|
|
2479
2603
|
md: "h-14 w-14",
|
|
@@ -2544,7 +2668,7 @@ function FABPosition({
|
|
|
2544
2668
|
}
|
|
2545
2669
|
);
|
|
2546
2670
|
}
|
|
2547
|
-
var FABComponent =
|
|
2671
|
+
var FABComponent = React16.forwardRef(
|
|
2548
2672
|
(_a, ref) => {
|
|
2549
2673
|
var _b = _a, {
|
|
2550
2674
|
className,
|
|
@@ -2558,6 +2682,7 @@ var FABComponent = React11.forwardRef(
|
|
|
2558
2682
|
loading = false,
|
|
2559
2683
|
loadingVariant = "loading-indicator",
|
|
2560
2684
|
visible = true,
|
|
2685
|
+
asChild = false,
|
|
2561
2686
|
onClick,
|
|
2562
2687
|
onKeyDown,
|
|
2563
2688
|
"aria-label": ariaLabel
|
|
@@ -2573,6 +2698,7 @@ var FABComponent = React11.forwardRef(
|
|
|
2573
2698
|
"loading",
|
|
2574
2699
|
"loadingVariant",
|
|
2575
2700
|
"visible",
|
|
2701
|
+
"asChild",
|
|
2576
2702
|
"onClick",
|
|
2577
2703
|
"onKeyDown",
|
|
2578
2704
|
"aria-label"
|
|
@@ -2589,7 +2715,7 @@ var FABComponent = React11.forwardRef(
|
|
|
2589
2715
|
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
2590
2716
|
disabled: loading
|
|
2591
2717
|
});
|
|
2592
|
-
const handleClick =
|
|
2718
|
+
const handleClick = React16.useCallback(
|
|
2593
2719
|
(e) => {
|
|
2594
2720
|
if (loading) {
|
|
2595
2721
|
e.preventDefault();
|
|
@@ -2599,7 +2725,7 @@ var FABComponent = React11.forwardRef(
|
|
|
2599
2725
|
},
|
|
2600
2726
|
[loading, onClick]
|
|
2601
2727
|
);
|
|
2602
|
-
const handleKeyDown =
|
|
2728
|
+
const handleKeyDown = React16.useCallback(
|
|
2603
2729
|
(e) => {
|
|
2604
2730
|
if (loading) return;
|
|
2605
2731
|
if ((e.key === "Enter" || e.key === " ") && onClick) {
|
|
@@ -2610,19 +2736,116 @@ var FABComponent = React11.forwardRef(
|
|
|
2610
2736
|
},
|
|
2611
2737
|
[loading, onClick, onKeyDown]
|
|
2612
2738
|
);
|
|
2613
|
-
|
|
2739
|
+
const labelContent = asChild ? React16.Children.only(children).props.children : children;
|
|
2740
|
+
const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2741
|
+
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
2742
|
+
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
2743
|
+
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
|
|
2744
|
+
m.span,
|
|
2745
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
2746
|
+
transition: SPRING_TRANSITION,
|
|
2747
|
+
className: cn(
|
|
2748
|
+
"flex items-center justify-center shrink-0",
|
|
2749
|
+
iconClass
|
|
2750
|
+
),
|
|
2751
|
+
children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
|
|
2752
|
+
LoadingIndicator,
|
|
2753
|
+
{
|
|
2754
|
+
size: iconPx,
|
|
2755
|
+
color: "currentColor",
|
|
2756
|
+
"aria-label": "Loading"
|
|
2757
|
+
}
|
|
2758
|
+
) : /* @__PURE__ */ jsx(
|
|
2759
|
+
ProgressIndicator,
|
|
2760
|
+
{
|
|
2761
|
+
variant: "circular",
|
|
2762
|
+
size: iconPx,
|
|
2763
|
+
color: "currentColor",
|
|
2764
|
+
trackColor: "transparent",
|
|
2765
|
+
"aria-label": "Loading"
|
|
2766
|
+
}
|
|
2767
|
+
)
|
|
2768
|
+
}),
|
|
2769
|
+
"loading"
|
|
2770
|
+
) : /* @__PURE__ */ jsx(
|
|
2771
|
+
m.span,
|
|
2772
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
2773
|
+
transition: SPRING_TRANSITION,
|
|
2774
|
+
"aria-hidden": "true",
|
|
2775
|
+
className: cn(
|
|
2776
|
+
"flex items-center justify-center shrink-0 [&>svg]:w-full [&>svg]:h-full",
|
|
2777
|
+
iconClass
|
|
2778
|
+
),
|
|
2779
|
+
children: icon
|
|
2780
|
+
}),
|
|
2781
|
+
"icon"
|
|
2782
|
+
) }),
|
|
2783
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: extended && labelContent && /* @__PURE__ */ jsx(
|
|
2784
|
+
m.span,
|
|
2785
|
+
{
|
|
2786
|
+
initial: { width: 0, opacity: 0 },
|
|
2787
|
+
animate: { width: "auto", opacity: 1 },
|
|
2788
|
+
exit: { width: 0, opacity: 0 },
|
|
2789
|
+
transition: SPRING_TRANSITION,
|
|
2790
|
+
className: "overflow-hidden whitespace-nowrap ml-3",
|
|
2791
|
+
children: labelContent
|
|
2792
|
+
},
|
|
2793
|
+
"label"
|
|
2794
|
+
) })
|
|
2795
|
+
] });
|
|
2796
|
+
const containerClassName = cn(
|
|
2797
|
+
"relative shrink-0 inline-flex items-center justify-center",
|
|
2798
|
+
"select-none cursor-pointer overflow-hidden",
|
|
2799
|
+
"transition-[box-shadow,opacity,filter] duration-200",
|
|
2800
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2",
|
|
2801
|
+
"disabled:pointer-events-none disabled:opacity-[0.38] disabled:shadow-none",
|
|
2802
|
+
colors.bg,
|
|
2803
|
+
colors.text,
|
|
2804
|
+
lowered ? "shadow-sm" : colors.shadow,
|
|
2805
|
+
(_d = SIZE_STYLES[size]) != null ? _d : "h-14 w-14",
|
|
2806
|
+
extended && "w-auto px-6",
|
|
2807
|
+
SIZE_TEXT_CLASS[size],
|
|
2808
|
+
loading && "pointer-events-none opacity-75 cursor-not-allowed",
|
|
2809
|
+
className
|
|
2810
|
+
);
|
|
2811
|
+
const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
|
|
2812
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(AnimatePresence, { children: visible && (asChild ? /* @__PURE__ */ jsx(
|
|
2813
|
+
Slot,
|
|
2814
|
+
__spreadProps(__spreadValues({
|
|
2815
|
+
ref,
|
|
2816
|
+
"aria-label": computedAriaLabel,
|
|
2817
|
+
"aria-busy": loading || void 0,
|
|
2818
|
+
"aria-disabled": loading || restProps.disabled,
|
|
2819
|
+
onClick: handleClick,
|
|
2820
|
+
onPointerDown,
|
|
2821
|
+
onKeyDown: handleKeyDown,
|
|
2822
|
+
style: __spreadProps(__spreadValues({}, style), {
|
|
2823
|
+
borderRadius: `${animateRadius}px`
|
|
2824
|
+
}),
|
|
2825
|
+
className: containerClassName
|
|
2826
|
+
}, restProps), {
|
|
2827
|
+
children: React16.cloneElement(
|
|
2828
|
+
React16.Children.only(children),
|
|
2829
|
+
{ children: innerContent }
|
|
2830
|
+
)
|
|
2831
|
+
})
|
|
2832
|
+
) : /* @__PURE__ */ jsx(
|
|
2614
2833
|
m.button,
|
|
2615
2834
|
__spreadProps(__spreadValues({
|
|
2616
2835
|
ref,
|
|
2617
2836
|
type: "button",
|
|
2618
|
-
"aria-label":
|
|
2837
|
+
"aria-label": computedAriaLabel,
|
|
2619
2838
|
"aria-busy": loading || void 0,
|
|
2620
2839
|
"aria-disabled": loading || restProps.disabled,
|
|
2621
2840
|
onClick: handleClick,
|
|
2622
2841
|
onPointerDown,
|
|
2623
2842
|
onKeyDown: handleKeyDown,
|
|
2624
2843
|
style,
|
|
2625
|
-
initial: {
|
|
2844
|
+
initial: {
|
|
2845
|
+
scale: 0.5,
|
|
2846
|
+
opacity: 0,
|
|
2847
|
+
borderRadius: animateRadius
|
|
2848
|
+
},
|
|
2626
2849
|
animate: { scale: 1, opacity: 1, borderRadius: animateRadius },
|
|
2627
2850
|
exit: { scale: 0.5, opacity: 0 },
|
|
2628
2851
|
whileTap: { borderRadius: pressedRadius },
|
|
@@ -2631,84 +2854,15 @@ var FABComponent = React11.forwardRef(
|
|
|
2631
2854
|
scale: SPRING_TRANSITION,
|
|
2632
2855
|
opacity: { duration: 0.25, ease: "easeOut" }
|
|
2633
2856
|
},
|
|
2634
|
-
className:
|
|
2635
|
-
"relative shrink-0 inline-flex items-center justify-center",
|
|
2636
|
-
"select-none cursor-pointer overflow-hidden",
|
|
2637
|
-
"transition-[box-shadow,opacity,filter] duration-200",
|
|
2638
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2",
|
|
2639
|
-
"disabled:pointer-events-none disabled:opacity-[0.38] disabled:shadow-none",
|
|
2640
|
-
colors.bg,
|
|
2641
|
-
colors.text,
|
|
2642
|
-
lowered ? "shadow-sm" : colors.shadow,
|
|
2643
|
-
(_d = SIZE_STYLES[size]) != null ? _d : "h-14 w-14",
|
|
2644
|
-
extended && "w-auto px-6",
|
|
2645
|
-
SIZE_TEXT_CLASS[size],
|
|
2646
|
-
loading && "pointer-events-none opacity-75 cursor-not-allowed",
|
|
2647
|
-
className
|
|
2648
|
-
)
|
|
2857
|
+
className: containerClassName
|
|
2649
2858
|
}, restProps), {
|
|
2650
|
-
children:
|
|
2651
|
-
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
2652
|
-
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
2653
|
-
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
|
|
2654
|
-
m.span,
|
|
2655
|
-
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
2656
|
-
transition: SPRING_TRANSITION,
|
|
2657
|
-
className: cn(
|
|
2658
|
-
"flex items-center justify-center shrink-0",
|
|
2659
|
-
iconClass
|
|
2660
|
-
),
|
|
2661
|
-
children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
|
|
2662
|
-
LoadingIndicator,
|
|
2663
|
-
{
|
|
2664
|
-
size: iconPx,
|
|
2665
|
-
color: "currentColor",
|
|
2666
|
-
"aria-label": "Loading"
|
|
2667
|
-
}
|
|
2668
|
-
) : /* @__PURE__ */ jsx(
|
|
2669
|
-
ProgressIndicator,
|
|
2670
|
-
{
|
|
2671
|
-
variant: "circular",
|
|
2672
|
-
size: iconPx,
|
|
2673
|
-
color: "currentColor",
|
|
2674
|
-
trackColor: "transparent",
|
|
2675
|
-
"aria-label": "Loading"
|
|
2676
|
-
}
|
|
2677
|
-
)
|
|
2678
|
-
}),
|
|
2679
|
-
"loading"
|
|
2680
|
-
) : /* @__PURE__ */ jsx(
|
|
2681
|
-
m.span,
|
|
2682
|
-
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
2683
|
-
transition: SPRING_TRANSITION,
|
|
2684
|
-
"aria-hidden": "true",
|
|
2685
|
-
className: cn(
|
|
2686
|
-
"flex items-center justify-center shrink-0 [&>svg]:w-full [&>svg]:h-full",
|
|
2687
|
-
iconClass
|
|
2688
|
-
),
|
|
2689
|
-
children: icon
|
|
2690
|
-
}),
|
|
2691
|
-
"icon"
|
|
2692
|
-
) }),
|
|
2693
|
-
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: extended && children && /* @__PURE__ */ jsx(
|
|
2694
|
-
m.span,
|
|
2695
|
-
{
|
|
2696
|
-
initial: { width: 0, opacity: 0 },
|
|
2697
|
-
animate: { width: "auto", opacity: 1 },
|
|
2698
|
-
exit: { width: 0, opacity: 0 },
|
|
2699
|
-
transition: SPRING_TRANSITION,
|
|
2700
|
-
className: "overflow-hidden whitespace-nowrap ml-3",
|
|
2701
|
-
children
|
|
2702
|
-
},
|
|
2703
|
-
"label"
|
|
2704
|
-
) })
|
|
2705
|
-
]
|
|
2859
|
+
children: innerContent
|
|
2706
2860
|
})
|
|
2707
|
-
) }) });
|
|
2861
|
+
)) }) });
|
|
2708
2862
|
}
|
|
2709
2863
|
);
|
|
2710
2864
|
FABComponent.displayName = "FAB";
|
|
2711
|
-
var FAB =
|
|
2865
|
+
var FAB = React16.memo(FABComponent);
|
|
2712
2866
|
var SPRING_NORMAL = { stiffness: 700, damping: 40 };
|
|
2713
2867
|
var SPRING_REDUCED = { stiffness: 1e4, damping: 100 };
|
|
2714
2868
|
var FOCUS_DELAY_MS = 50;
|
|
@@ -2816,7 +2970,7 @@ function CloseIcon() {
|
|
|
2816
2970
|
function defaultFabIcon(progress) {
|
|
2817
2971
|
return progress > 0.5 ? /* @__PURE__ */ jsx(CloseIcon, {}) : /* @__PURE__ */ jsx(AddIcon, {});
|
|
2818
2972
|
}
|
|
2819
|
-
var ToggleFABComponent =
|
|
2973
|
+
var ToggleFABComponent = React16.forwardRef(
|
|
2820
2974
|
({
|
|
2821
2975
|
expanded,
|
|
2822
2976
|
onToggle,
|
|
@@ -2834,7 +2988,7 @@ var ToggleFABComponent = React11.forwardRef(
|
|
|
2834
2988
|
const sizeTokens = (_b = TOGGLE_FAB_SIZES[fabSize]) != null ? _b : TOGGLE_FAB_SIZES.baseline;
|
|
2835
2989
|
const springConfig = prefersReduced ? SPRING_REDUCED : SPRING_NORMAL;
|
|
2836
2990
|
const checkedProgress = useSpring(expanded ? 1 : 0, springConfig);
|
|
2837
|
-
|
|
2991
|
+
React16.useEffect(() => {
|
|
2838
2992
|
checkedProgress.set(expanded ? 1 : 0);
|
|
2839
2993
|
}, [expanded, checkedProgress]);
|
|
2840
2994
|
const borderRadius = useTransform(
|
|
@@ -2842,12 +2996,12 @@ var ToggleFABComponent = React11.forwardRef(
|
|
|
2842
2996
|
[0, 1],
|
|
2843
2997
|
[`${sizeTokens.initialRadius}px`, `${sizeTokens.finalRadius}px`]
|
|
2844
2998
|
);
|
|
2845
|
-
const [iconProgress, setIconProgress] =
|
|
2846
|
-
|
|
2999
|
+
const [iconProgress, setIconProgress] = React16.useState(expanded ? 1 : 0);
|
|
3000
|
+
React16.useEffect(() => {
|
|
2847
3001
|
return checkedProgress.on("change", setIconProgress);
|
|
2848
3002
|
}, [checkedProgress]);
|
|
2849
3003
|
const { ripples, onPointerDown, removeRipple } = useRippleState();
|
|
2850
|
-
const handleClick =
|
|
3004
|
+
const handleClick = React16.useCallback(() => {
|
|
2851
3005
|
onToggle(!expanded);
|
|
2852
3006
|
}, [expanded, onToggle]);
|
|
2853
3007
|
return /* @__PURE__ */ jsxs(
|
|
@@ -2896,7 +3050,7 @@ var ToggleFABComponent = React11.forwardRef(
|
|
|
2896
3050
|
}
|
|
2897
3051
|
);
|
|
2898
3052
|
ToggleFABComponent.displayName = "ToggleFAB";
|
|
2899
|
-
var ToggleFAB =
|
|
3053
|
+
var ToggleFAB = React16.memo(ToggleFABComponent);
|
|
2900
3054
|
function FABMenuItem({
|
|
2901
3055
|
icon,
|
|
2902
3056
|
label,
|
|
@@ -2904,12 +3058,14 @@ function FABMenuItem({
|
|
|
2904
3058
|
disabled = false,
|
|
2905
3059
|
colorVariant = "primary",
|
|
2906
3060
|
className,
|
|
2907
|
-
tabIndex = 0
|
|
3061
|
+
tabIndex = 0,
|
|
3062
|
+
asChild = false,
|
|
3063
|
+
children
|
|
2908
3064
|
}) {
|
|
2909
3065
|
var _a;
|
|
2910
3066
|
const colors = (_a = MENU_ITEM_COLORS[colorVariant]) != null ? _a : MENU_ITEM_COLORS.primary;
|
|
2911
3067
|
const { ripples, onPointerDown, removeRipple } = useRippleState({ disabled });
|
|
2912
|
-
const handleClick =
|
|
3068
|
+
const handleClick = React16.useCallback(
|
|
2913
3069
|
(e) => {
|
|
2914
3070
|
if (disabled) {
|
|
2915
3071
|
e.preventDefault();
|
|
@@ -2919,7 +3075,7 @@ function FABMenuItem({
|
|
|
2919
3075
|
},
|
|
2920
3076
|
[disabled, onClick]
|
|
2921
3077
|
);
|
|
2922
|
-
const handleKeyDown =
|
|
3078
|
+
const handleKeyDown = React16.useCallback(
|
|
2923
3079
|
(e) => {
|
|
2924
3080
|
if (disabled) return;
|
|
2925
3081
|
if (e.key === "Enter" || e.key === " ") {
|
|
@@ -2929,48 +3085,68 @@ function FABMenuItem({
|
|
|
2929
3085
|
},
|
|
2930
3086
|
[disabled, onClick]
|
|
2931
3087
|
);
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
{
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
3088
|
+
const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3089
|
+
/* @__PURE__ */ jsx(TouchTarget, {}),
|
|
3090
|
+
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
3091
|
+
/* @__PURE__ */ jsx(
|
|
3092
|
+
"span",
|
|
3093
|
+
{
|
|
3094
|
+
"aria-hidden": "true",
|
|
3095
|
+
className: "relative z-10 flex items-center justify-center size-6 shrink-0 [&>svg]:w-full [&>svg]:h-full pointer-events-none",
|
|
3096
|
+
children: icon
|
|
3097
|
+
}
|
|
3098
|
+
),
|
|
3099
|
+
label && /* @__PURE__ */ jsx("span", { className: "relative z-10 text-base font-medium leading-none pointer-events-none", children: label })
|
|
3100
|
+
] });
|
|
3101
|
+
const containerClassName = cn(
|
|
3102
|
+
"relative inline-flex flex-row items-center",
|
|
3103
|
+
"select-none cursor-pointer overflow-hidden",
|
|
3104
|
+
"whitespace-nowrap",
|
|
3105
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-1",
|
|
3106
|
+
MENU_ITEM_STYLES.size,
|
|
3107
|
+
MENU_ITEM_STYLES.gap,
|
|
3108
|
+
label ? MENU_ITEM_STYLES.padding : "px-4",
|
|
3109
|
+
!label && "justify-center",
|
|
3110
|
+
colors.bg,
|
|
3111
|
+
colors.text,
|
|
3112
|
+
disabled && "opacity-[0.38] pointer-events-none",
|
|
3113
|
+
className
|
|
3114
|
+
);
|
|
3115
|
+
const containerStyle = {
|
|
3116
|
+
transformOrigin: "right",
|
|
3117
|
+
borderRadius: `${MENU_ITEM_STYLES.cornerRadius}px`
|
|
3118
|
+
};
|
|
3119
|
+
if (asChild) {
|
|
3120
|
+
const child = React16.Children.only(children);
|
|
3121
|
+
return /* @__PURE__ */ jsx(m.div, { variants: MENU_ITEM_VARIANTS, style: containerStyle, children: /* @__PURE__ */ jsx(
|
|
3122
|
+
Slot,
|
|
3123
|
+
{
|
|
3124
|
+
role: "menuitem",
|
|
3125
|
+
tabIndex,
|
|
3126
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
3127
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
3128
|
+
onClick: handleClick,
|
|
3129
|
+
onPointerDown,
|
|
3130
|
+
onKeyDown: handleKeyDown,
|
|
3131
|
+
className: containerClassName,
|
|
3132
|
+
children: React16.cloneElement(child, { children: innerContent })
|
|
3133
|
+
}
|
|
3134
|
+
) });
|
|
3135
|
+
}
|
|
3136
|
+
return /* @__PURE__ */ jsx(
|
|
3137
|
+
m.div,
|
|
3138
|
+
{
|
|
3139
|
+
role: "menuitem",
|
|
3140
|
+
tabIndex,
|
|
3141
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
3142
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
3143
|
+
onClick: handleClick,
|
|
3144
|
+
onPointerDown,
|
|
3145
|
+
onKeyDown: handleKeyDown,
|
|
3146
|
+
variants: MENU_ITEM_VARIANTS,
|
|
3147
|
+
style: containerStyle,
|
|
3148
|
+
className: containerClassName,
|
|
3149
|
+
children: innerContent
|
|
2974
3150
|
}
|
|
2975
3151
|
);
|
|
2976
3152
|
}
|
|
@@ -2986,13 +3162,13 @@ function FABMenu({
|
|
|
2986
3162
|
focusLast = true,
|
|
2987
3163
|
"aria-label": ariaLabel
|
|
2988
3164
|
}) {
|
|
2989
|
-
const fabId =
|
|
2990
|
-
const menuId =
|
|
2991
|
-
const toggleRef =
|
|
2992
|
-
const itemRefs =
|
|
2993
|
-
const [focusedIndex, setFocusedIndex] =
|
|
2994
|
-
const reversedItems =
|
|
2995
|
-
const focusItem =
|
|
3165
|
+
const fabId = React16.useId();
|
|
3166
|
+
const menuId = React16.useId();
|
|
3167
|
+
const toggleRef = React16.useRef(null);
|
|
3168
|
+
const itemRefs = React16.useRef([]);
|
|
3169
|
+
const [focusedIndex, setFocusedIndex] = React16.useState(-1);
|
|
3170
|
+
const reversedItems = React16.useMemo(() => [...items].reverse(), [items]);
|
|
3171
|
+
const focusItem = React16.useCallback((index) => {
|
|
2996
3172
|
var _a;
|
|
2997
3173
|
const clampedIndex = Math.max(
|
|
2998
3174
|
0,
|
|
@@ -3001,8 +3177,8 @@ function FABMenu({
|
|
|
3001
3177
|
setFocusedIndex(clampedIndex);
|
|
3002
3178
|
(_a = itemRefs.current[clampedIndex]) == null ? void 0 : _a.focus();
|
|
3003
3179
|
}, []);
|
|
3004
|
-
const wasExpandedRef =
|
|
3005
|
-
|
|
3180
|
+
const wasExpandedRef = React16.useRef(false);
|
|
3181
|
+
React16.useEffect(() => {
|
|
3006
3182
|
var _a;
|
|
3007
3183
|
if (expanded) {
|
|
3008
3184
|
wasExpandedRef.current = true;
|
|
@@ -3017,7 +3193,7 @@ function FABMenu({
|
|
|
3017
3193
|
wasExpandedRef.current = false;
|
|
3018
3194
|
setFocusedIndex(-1);
|
|
3019
3195
|
}, [expanded, focusLast, items.length, focusItem]);
|
|
3020
|
-
const handleMenuKeyDown =
|
|
3196
|
+
const handleMenuKeyDown = React16.useCallback(
|
|
3021
3197
|
(e) => {
|
|
3022
3198
|
if (!expanded) return;
|
|
3023
3199
|
const lastIndex = items.length - 1;
|
|
@@ -3141,12 +3317,39 @@ function FABMenu({
|
|
|
3141
3317
|
)
|
|
3142
3318
|
] });
|
|
3143
3319
|
}
|
|
3144
|
-
var
|
|
3145
|
-
xs: "h-8
|
|
3146
|
-
sm: "h-10
|
|
3147
|
-
md: "h-14
|
|
3148
|
-
lg: "h-24
|
|
3149
|
-
xl: "h-[8.5rem]
|
|
3320
|
+
var SIZE_HEIGHT_STYLES = {
|
|
3321
|
+
xs: "h-8",
|
|
3322
|
+
sm: "h-10",
|
|
3323
|
+
md: "h-14",
|
|
3324
|
+
lg: "h-24",
|
|
3325
|
+
xl: "h-[8.5rem]"
|
|
3326
|
+
};
|
|
3327
|
+
var WIDTH_SIZE_STYLES = {
|
|
3328
|
+
xs: {
|
|
3329
|
+
default: "w-8",
|
|
3330
|
+
narrow: "w-8",
|
|
3331
|
+
wide: "w-12"
|
|
3332
|
+
},
|
|
3333
|
+
sm: {
|
|
3334
|
+
default: "w-10",
|
|
3335
|
+
narrow: "w-12",
|
|
3336
|
+
wide: "w-[3.25rem]"
|
|
3337
|
+
},
|
|
3338
|
+
md: {
|
|
3339
|
+
default: "w-14",
|
|
3340
|
+
narrow: "w-12",
|
|
3341
|
+
wide: "w-[4.5rem]"
|
|
3342
|
+
},
|
|
3343
|
+
lg: {
|
|
3344
|
+
default: "w-24",
|
|
3345
|
+
narrow: "w-16",
|
|
3346
|
+
wide: "w-32"
|
|
3347
|
+
},
|
|
3348
|
+
xl: {
|
|
3349
|
+
default: "w-[8.5rem]",
|
|
3350
|
+
narrow: "w-[6.5rem]",
|
|
3351
|
+
wide: "w-[11.5rem]"
|
|
3352
|
+
}
|
|
3150
3353
|
};
|
|
3151
3354
|
var SIZE_ICON3 = {
|
|
3152
3355
|
xs: { cls: "size-5", px: 20 },
|
|
@@ -3239,7 +3442,7 @@ function resolveDisabledBgClass(colorStyle) {
|
|
|
3239
3442
|
}
|
|
3240
3443
|
return "disabled:text-m3-on-surface/[0.38]";
|
|
3241
3444
|
}
|
|
3242
|
-
var IconButtonComponent =
|
|
3445
|
+
var IconButtonComponent = React16.forwardRef(
|
|
3243
3446
|
(_a, ref) => {
|
|
3244
3447
|
var _b = _a, {
|
|
3245
3448
|
className,
|
|
@@ -3247,11 +3450,14 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
3247
3450
|
variant = "default",
|
|
3248
3451
|
colorStyle = "standard",
|
|
3249
3452
|
size = "sm",
|
|
3453
|
+
widthVariant = "default",
|
|
3250
3454
|
shape = "round",
|
|
3251
3455
|
selected,
|
|
3456
|
+
selectedIcon,
|
|
3252
3457
|
loading = false,
|
|
3253
3458
|
loadingVariant = "loading-indicator",
|
|
3254
3459
|
iconSize,
|
|
3460
|
+
asChild = false,
|
|
3255
3461
|
children,
|
|
3256
3462
|
onClick,
|
|
3257
3463
|
onKeyDown,
|
|
@@ -3262,31 +3468,34 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
3262
3468
|
"variant",
|
|
3263
3469
|
"colorStyle",
|
|
3264
3470
|
"size",
|
|
3471
|
+
"widthVariant",
|
|
3265
3472
|
"shape",
|
|
3266
3473
|
"selected",
|
|
3474
|
+
"selectedIcon",
|
|
3267
3475
|
"loading",
|
|
3268
3476
|
"loadingVariant",
|
|
3269
3477
|
"iconSize",
|
|
3478
|
+
"asChild",
|
|
3270
3479
|
"children",
|
|
3271
3480
|
"onClick",
|
|
3272
3481
|
"onKeyDown",
|
|
3273
3482
|
"aria-label"
|
|
3274
3483
|
]);
|
|
3275
|
-
var _a2, _b2;
|
|
3484
|
+
var _a2, _b2, _c, _d, _e;
|
|
3276
3485
|
const isToggle = variant === "toggle";
|
|
3277
3486
|
const isSelected = isToggle && !!selected;
|
|
3278
|
-
const resolvedColorClass =
|
|
3487
|
+
const resolvedColorClass = React16.useMemo(
|
|
3279
3488
|
() => isSelected ? colorStyles[colorStyle].selected : colorStyles[colorStyle].default,
|
|
3280
3489
|
[isSelected, colorStyle]
|
|
3281
3490
|
);
|
|
3282
|
-
const outlineWidthClass =
|
|
3491
|
+
const outlineWidthClass = React16.useMemo(
|
|
3283
3492
|
() => {
|
|
3284
3493
|
var _a3;
|
|
3285
3494
|
return colorStyle === "outlined" && !isSelected ? (_a3 = SIZE_OUTLINE_WIDTH[size]) != null ? _a3 : "border" : "";
|
|
3286
3495
|
},
|
|
3287
3496
|
[colorStyle, isSelected, size]
|
|
3288
3497
|
);
|
|
3289
|
-
const disabledBgClass =
|
|
3498
|
+
const disabledBgClass = React16.useMemo(
|
|
3290
3499
|
() => resolveDisabledBgClass(colorStyle),
|
|
3291
3500
|
[colorStyle]
|
|
3292
3501
|
);
|
|
@@ -3303,11 +3512,13 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
3303
3512
|
const defaultIconPx = sizeIcon.px;
|
|
3304
3513
|
const iconPx = iconSize != null ? iconSize : defaultIconPx;
|
|
3305
3514
|
const isCustomSize = iconSize != null && iconSize !== "inherit";
|
|
3515
|
+
const heightClass = (_c = SIZE_HEIGHT_STYLES[size]) != null ? _c : SIZE_HEIGHT_STYLES.sm;
|
|
3516
|
+
const widthClass = (_e = ((_d = WIDTH_SIZE_STYLES[size]) != null ? _d : WIDTH_SIZE_STYLES.sm)[widthVariant]) != null ? _e : WIDTH_SIZE_STYLES.sm.default;
|
|
3306
3517
|
const needsTouchTarget = size === "xs" || size === "sm";
|
|
3307
3518
|
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
3308
3519
|
disabled: loading
|
|
3309
3520
|
});
|
|
3310
|
-
const handleClick =
|
|
3521
|
+
const handleClick = React16.useCallback(
|
|
3311
3522
|
(e) => {
|
|
3312
3523
|
if (loading) {
|
|
3313
3524
|
e.preventDefault();
|
|
@@ -3317,7 +3528,7 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
3317
3528
|
},
|
|
3318
3529
|
[loading, onClick]
|
|
3319
3530
|
);
|
|
3320
|
-
const handleKeyDown =
|
|
3531
|
+
const handleKeyDown = React16.useCallback(
|
|
3321
3532
|
(e) => {
|
|
3322
3533
|
if (loading) return;
|
|
3323
3534
|
if ((e.key === "Enter" || e.key === " ") && onClick) {
|
|
@@ -3328,7 +3539,90 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
3328
3539
|
},
|
|
3329
3540
|
[loading, onClick, onKeyDown]
|
|
3330
3541
|
);
|
|
3331
|
-
|
|
3542
|
+
const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3543
|
+
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
3544
|
+
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
3545
|
+
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
|
|
3546
|
+
m.span,
|
|
3547
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
3548
|
+
transition: SPRING_TRANSITION,
|
|
3549
|
+
className: cn(
|
|
3550
|
+
"flex items-center justify-center shrink-0",
|
|
3551
|
+
iconSize != null ? void 0 : iconClass
|
|
3552
|
+
),
|
|
3553
|
+
style: isCustomSize ? { width: `${iconSize}px`, height: `${iconSize}px` } : void 0,
|
|
3554
|
+
children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
|
|
3555
|
+
LoadingIndicator,
|
|
3556
|
+
{
|
|
3557
|
+
size: typeof iconPx === "number" ? iconPx : defaultIconPx,
|
|
3558
|
+
color: "currentColor",
|
|
3559
|
+
"aria-label": "Loading"
|
|
3560
|
+
}
|
|
3561
|
+
) : /* @__PURE__ */ jsx(
|
|
3562
|
+
ProgressIndicator,
|
|
3563
|
+
{
|
|
3564
|
+
variant: "circular",
|
|
3565
|
+
size: typeof iconPx === "number" ? iconPx : defaultIconPx,
|
|
3566
|
+
color: "currentColor",
|
|
3567
|
+
trackColor: "transparent",
|
|
3568
|
+
"aria-label": "Loading"
|
|
3569
|
+
}
|
|
3570
|
+
)
|
|
3571
|
+
}),
|
|
3572
|
+
"loading"
|
|
3573
|
+
) : /* @__PURE__ */ jsx(
|
|
3574
|
+
m.span,
|
|
3575
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
3576
|
+
transition: SPRING_TRANSITION,
|
|
3577
|
+
"aria-hidden": "true",
|
|
3578
|
+
className: cn(
|
|
3579
|
+
"flex items-center justify-center shrink-0 [&_svg]:w-full [&_svg]:h-full [&_.md-icon]:text-[length:inherit]",
|
|
3580
|
+
iconSize != null ? void 0 : iconClass
|
|
3581
|
+
),
|
|
3582
|
+
style: {
|
|
3583
|
+
fontSize: typeof iconPx === "number" ? `${iconPx}px` : iconPx,
|
|
3584
|
+
width: isCustomSize ? `${iconSize}px` : void 0,
|
|
3585
|
+
height: isCustomSize ? `${iconSize}px` : void 0
|
|
3586
|
+
},
|
|
3587
|
+
children: isSelected && selectedIcon ? selectedIcon : asChild ? React16.Children.only(children).props.children : children
|
|
3588
|
+
}),
|
|
3589
|
+
isSelected && selectedIcon ? "selected-content" : "content"
|
|
3590
|
+
) })
|
|
3591
|
+
] });
|
|
3592
|
+
const containerClassName = cn(
|
|
3593
|
+
baseIconButtonClasses,
|
|
3594
|
+
resolvedColorClass,
|
|
3595
|
+
outlineWidthClass,
|
|
3596
|
+
disabledBgClass,
|
|
3597
|
+
"overflow-hidden",
|
|
3598
|
+
heightClass,
|
|
3599
|
+
widthClass,
|
|
3600
|
+
loading && "pointer-events-none opacity-75 cursor-not-allowed",
|
|
3601
|
+
className
|
|
3602
|
+
);
|
|
3603
|
+
if (asChild) {
|
|
3604
|
+
const child = React16.Children.only(children);
|
|
3605
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
3606
|
+
Slot,
|
|
3607
|
+
__spreadProps(__spreadValues({
|
|
3608
|
+
ref,
|
|
3609
|
+
"aria-pressed": isToggle ? isSelected : void 0,
|
|
3610
|
+
"aria-label": ariaLabel,
|
|
3611
|
+
"aria-busy": loading || void 0,
|
|
3612
|
+
"aria-disabled": loading || restProps.disabled,
|
|
3613
|
+
onClick: handleClick,
|
|
3614
|
+
onPointerDown,
|
|
3615
|
+
onKeyDown: handleKeyDown,
|
|
3616
|
+
style: __spreadProps(__spreadValues({}, style), {
|
|
3617
|
+
borderRadius: `${animateRadius}px`
|
|
3618
|
+
}),
|
|
3619
|
+
className: containerClassName
|
|
3620
|
+
}, restProps), {
|
|
3621
|
+
children: React16.cloneElement(child, { children: innerContent })
|
|
3622
|
+
})
|
|
3623
|
+
) });
|
|
3624
|
+
}
|
|
3625
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
3332
3626
|
m.button,
|
|
3333
3627
|
__spreadProps(__spreadValues({
|
|
3334
3628
|
ref,
|
|
@@ -3344,78 +3638,20 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
3344
3638
|
animate: { borderRadius: animateRadius },
|
|
3345
3639
|
whileTap: { borderRadius: pressedRadius },
|
|
3346
3640
|
transition: { borderRadius: SPRING_TRANSITION_FAST },
|
|
3347
|
-
className:
|
|
3348
|
-
baseIconButtonClasses,
|
|
3349
|
-
resolvedColorClass,
|
|
3350
|
-
outlineWidthClass,
|
|
3351
|
-
disabledBgClass,
|
|
3352
|
-
"overflow-hidden",
|
|
3353
|
-
SIZE_STYLES2[size],
|
|
3354
|
-
loading && "pointer-events-none opacity-75 cursor-not-allowed",
|
|
3355
|
-
className
|
|
3356
|
-
)
|
|
3641
|
+
className: containerClassName
|
|
3357
3642
|
}, restProps), {
|
|
3358
|
-
children:
|
|
3359
|
-
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
3360
|
-
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
3361
|
-
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
|
|
3362
|
-
m.span,
|
|
3363
|
-
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
3364
|
-
transition: SPRING_TRANSITION,
|
|
3365
|
-
className: cn(
|
|
3366
|
-
"flex items-center justify-center shrink-0",
|
|
3367
|
-
iconSize != null ? void 0 : iconClass
|
|
3368
|
-
),
|
|
3369
|
-
style: isCustomSize ? { width: `${iconSize}px`, height: `${iconSize}px` } : void 0,
|
|
3370
|
-
children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
|
|
3371
|
-
LoadingIndicator,
|
|
3372
|
-
{
|
|
3373
|
-
size: typeof iconPx === "number" ? iconPx : defaultIconPx,
|
|
3374
|
-
color: "currentColor",
|
|
3375
|
-
"aria-label": "Loading"
|
|
3376
|
-
}
|
|
3377
|
-
) : /* @__PURE__ */ jsx(
|
|
3378
|
-
ProgressIndicator,
|
|
3379
|
-
{
|
|
3380
|
-
variant: "circular",
|
|
3381
|
-
size: typeof iconPx === "number" ? iconPx : defaultIconPx,
|
|
3382
|
-
color: "currentColor",
|
|
3383
|
-
trackColor: "transparent",
|
|
3384
|
-
"aria-label": "Loading"
|
|
3385
|
-
}
|
|
3386
|
-
)
|
|
3387
|
-
}),
|
|
3388
|
-
"loading"
|
|
3389
|
-
) : /* @__PURE__ */ jsx(
|
|
3390
|
-
m.span,
|
|
3391
|
-
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
3392
|
-
transition: SPRING_TRANSITION,
|
|
3393
|
-
"aria-hidden": "true",
|
|
3394
|
-
className: cn(
|
|
3395
|
-
"flex items-center justify-center shrink-0 [&_svg]:w-full [&_svg]:h-full [&_.md-icon]:text-[length:inherit]!",
|
|
3396
|
-
iconSize != null ? void 0 : iconClass
|
|
3397
|
-
),
|
|
3398
|
-
style: {
|
|
3399
|
-
fontSize: typeof iconPx === "number" ? `${iconPx}px` : iconPx,
|
|
3400
|
-
width: isCustomSize ? `${iconSize}px` : void 0,
|
|
3401
|
-
height: isCustomSize ? `${iconSize}px` : void 0
|
|
3402
|
-
},
|
|
3403
|
-
children
|
|
3404
|
-
}),
|
|
3405
|
-
"content"
|
|
3406
|
-
) })
|
|
3407
|
-
]
|
|
3643
|
+
children: innerContent
|
|
3408
3644
|
})
|
|
3409
3645
|
) });
|
|
3410
3646
|
}
|
|
3411
3647
|
);
|
|
3412
3648
|
IconButtonComponent.displayName = "IconButton";
|
|
3413
|
-
var IconButton =
|
|
3414
|
-
var SplitButtonContext =
|
|
3649
|
+
var IconButton = React16.memo(IconButtonComponent);
|
|
3650
|
+
var SplitButtonContext = React16.createContext(null);
|
|
3415
3651
|
function useSplitButtonContext() {
|
|
3416
|
-
return
|
|
3652
|
+
return React16.useContext(SplitButtonContext);
|
|
3417
3653
|
}
|
|
3418
|
-
var SplitButtonLayoutComponent =
|
|
3654
|
+
var SplitButtonLayoutComponent = React16.forwardRef(
|
|
3419
3655
|
(_a, ref) => {
|
|
3420
3656
|
var _b = _a, {
|
|
3421
3657
|
leadingButton,
|
|
@@ -3432,10 +3668,10 @@ var SplitButtonLayoutComponent = React11.forwardRef(
|
|
|
3432
3668
|
"variant",
|
|
3433
3669
|
"size"
|
|
3434
3670
|
]);
|
|
3435
|
-
const leadingProps =
|
|
3671
|
+
const leadingProps = React16.isValidElement(leadingButton) ? leadingButton.props : {};
|
|
3436
3672
|
const size = layoutSize || leadingProps.size;
|
|
3437
3673
|
const variant = layoutVariant || leadingProps.variant;
|
|
3438
|
-
const contextValue =
|
|
3674
|
+
const contextValue = React16.useMemo(
|
|
3439
3675
|
() => ({
|
|
3440
3676
|
size,
|
|
3441
3677
|
variant
|
|
@@ -3461,8 +3697,8 @@ var SplitButtonLayoutComponent = React11.forwardRef(
|
|
|
3461
3697
|
}
|
|
3462
3698
|
);
|
|
3463
3699
|
SplitButtonLayoutComponent.displayName = "SplitButtonLayout";
|
|
3464
|
-
var SplitButtonLayout =
|
|
3465
|
-
var StateLayer =
|
|
3700
|
+
var SplitButtonLayout = React16.memo(SplitButtonLayoutComponent);
|
|
3701
|
+
var StateLayer = React16.forwardRef(
|
|
3466
3702
|
(_a, ref) => {
|
|
3467
3703
|
var _b = _a, { className, hovered, focused, pressed } = _b, props = __objRest(_b, ["className", "hovered", "focused", "pressed"]);
|
|
3468
3704
|
let opacity = 0;
|
|
@@ -3714,7 +3950,7 @@ var splitButtonVariants = cva(
|
|
|
3714
3950
|
}
|
|
3715
3951
|
}
|
|
3716
3952
|
);
|
|
3717
|
-
var SplitButtonLeadingComponent =
|
|
3953
|
+
var SplitButtonLeadingComponent = React16.forwardRef(
|
|
3718
3954
|
(_a, ref) => {
|
|
3719
3955
|
var _b = _a, {
|
|
3720
3956
|
className,
|
|
@@ -3724,6 +3960,7 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3724
3960
|
icon,
|
|
3725
3961
|
children,
|
|
3726
3962
|
disabled,
|
|
3963
|
+
asChild = false,
|
|
3727
3964
|
onClick,
|
|
3728
3965
|
onPointerDown,
|
|
3729
3966
|
onPointerUp,
|
|
@@ -3739,6 +3976,7 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3739
3976
|
"icon",
|
|
3740
3977
|
"children",
|
|
3741
3978
|
"disabled",
|
|
3979
|
+
"asChild",
|
|
3742
3980
|
"onClick",
|
|
3743
3981
|
"onPointerDown",
|
|
3744
3982
|
"onPointerUp",
|
|
@@ -3751,9 +3989,9 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3751
3989
|
const context = useSplitButtonContext();
|
|
3752
3990
|
const actualSize = (_a2 = context == null ? void 0 : context.size) != null ? _a2 : size;
|
|
3753
3991
|
const actualVariant = (_b2 = context == null ? void 0 : context.variant) != null ? _b2 : variant;
|
|
3754
|
-
const [isHovered, setIsHovered] =
|
|
3755
|
-
const [isFocused, setIsFocused] =
|
|
3756
|
-
const [isPressed, setIsPressed] =
|
|
3992
|
+
const [isHovered, setIsHovered] = React16.useState(false);
|
|
3993
|
+
const [isFocused, setIsFocused] = React16.useState(false);
|
|
3994
|
+
const [isPressed, setIsPressed] = React16.useState(false);
|
|
3757
3995
|
const tokens = SPLIT_BUTTON_TOKENS[actualSize];
|
|
3758
3996
|
const typographyClass = (_c = BUTTON_TYPOGRAPHY_TOKENS[actualSize]) != null ? _c : BUTTON_TYPOGRAPHY_TOKENS.sm;
|
|
3759
3997
|
const needsTouchTarget = actualSize === "xs" || actualSize === "sm";
|
|
@@ -3765,7 +4003,7 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3765
4003
|
const innerCornerRadius = isPressed || isFocused ? tokens.innerCorner.pressed : isHovered ? tokens.innerCorner.hovered : tokens.innerCorner.default;
|
|
3766
4004
|
const outerRadius = tokens.containerHeight * tokens.outerCornerPercent / 100;
|
|
3767
4005
|
const borderRadius = `${outerRadius}px ${innerCornerRadius}px ${innerCornerRadius}px ${outerRadius}px`;
|
|
3768
|
-
const handleClick =
|
|
4006
|
+
const handleClick = React16.useCallback(
|
|
3769
4007
|
(e) => {
|
|
3770
4008
|
if (disabled) {
|
|
3771
4009
|
e.preventDefault();
|
|
@@ -3775,7 +4013,7 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3775
4013
|
},
|
|
3776
4014
|
[disabled, onClick]
|
|
3777
4015
|
);
|
|
3778
|
-
const handlePointerDown =
|
|
4016
|
+
const handlePointerDown = React16.useCallback(
|
|
3779
4017
|
(e) => {
|
|
3780
4018
|
onRipplePointerDown(e);
|
|
3781
4019
|
setIsPressed(true);
|
|
@@ -3783,19 +4021,19 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3783
4021
|
},
|
|
3784
4022
|
[onRipplePointerDown, onPointerDown]
|
|
3785
4023
|
);
|
|
3786
|
-
const handlePointerUp =
|
|
4024
|
+
const handlePointerUp = React16.useCallback(
|
|
3787
4025
|
(e) => {
|
|
3788
4026
|
setIsPressed(false);
|
|
3789
4027
|
onPointerUp == null ? void 0 : onPointerUp(e);
|
|
3790
4028
|
},
|
|
3791
4029
|
[onPointerUp]
|
|
3792
4030
|
);
|
|
3793
|
-
const handlePointerEnter =
|
|
4031
|
+
const handlePointerEnter = React16.useCallback(() => {
|
|
3794
4032
|
if (!disabled) {
|
|
3795
4033
|
setIsHovered(true);
|
|
3796
4034
|
}
|
|
3797
4035
|
}, [disabled]);
|
|
3798
|
-
const handlePointerLeave =
|
|
4036
|
+
const handlePointerLeave = React16.useCallback(
|
|
3799
4037
|
(e) => {
|
|
3800
4038
|
setIsHovered(false);
|
|
3801
4039
|
setIsPressed(false);
|
|
@@ -3803,21 +4041,21 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3803
4041
|
},
|
|
3804
4042
|
[onPointerLeave]
|
|
3805
4043
|
);
|
|
3806
|
-
const handlePointerCancel =
|
|
4044
|
+
const handlePointerCancel = React16.useCallback(
|
|
3807
4045
|
(e) => {
|
|
3808
4046
|
setIsPressed(false);
|
|
3809
4047
|
onPointerCancel == null ? void 0 : onPointerCancel(e);
|
|
3810
4048
|
},
|
|
3811
4049
|
[onPointerCancel]
|
|
3812
4050
|
);
|
|
3813
|
-
const handleFocus =
|
|
4051
|
+
const handleFocus = React16.useCallback(
|
|
3814
4052
|
(e) => {
|
|
3815
4053
|
if (!disabled) setIsFocused(true);
|
|
3816
4054
|
onFocus == null ? void 0 : onFocus(e);
|
|
3817
4055
|
},
|
|
3818
4056
|
[disabled, onFocus]
|
|
3819
4057
|
);
|
|
3820
|
-
const handleBlur =
|
|
4058
|
+
const handleBlur = React16.useCallback(
|
|
3821
4059
|
(e) => {
|
|
3822
4060
|
setIsFocused(false);
|
|
3823
4061
|
onBlur == null ? void 0 : onBlur(e);
|
|
@@ -3825,12 +4063,73 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3825
4063
|
[onBlur]
|
|
3826
4064
|
);
|
|
3827
4065
|
const leadingIconSize = LEADING_ICON_SIZE_FOR_SIZE[actualSize];
|
|
3828
|
-
|
|
4066
|
+
const labelContent = asChild ? React16.Children.only(children).props.children : children;
|
|
4067
|
+
const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4068
|
+
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
4069
|
+
/* @__PURE__ */ jsx(
|
|
4070
|
+
StateLayer,
|
|
4071
|
+
{
|
|
4072
|
+
hovered: isHovered,
|
|
4073
|
+
focused: isFocused,
|
|
4074
|
+
pressed: isPressed
|
|
4075
|
+
}
|
|
4076
|
+
),
|
|
4077
|
+
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
4078
|
+
icon && /* @__PURE__ */ jsx(
|
|
4079
|
+
"span",
|
|
4080
|
+
{
|
|
4081
|
+
className: "flex items-center justify-center shrink-0 [&>svg]:w-full [&>svg]:h-full overflow-hidden [&_.md-icon]:text-[length:inherit]!",
|
|
4082
|
+
style: {
|
|
4083
|
+
fontSize: leadingIconSize,
|
|
4084
|
+
width: leadingIconSize,
|
|
4085
|
+
height: leadingIconSize
|
|
4086
|
+
},
|
|
4087
|
+
children: icon
|
|
4088
|
+
}
|
|
4089
|
+
),
|
|
4090
|
+
labelContent && /* @__PURE__ */ jsx("span", { className: "inline-flex items-center h-full gap-[inherit]", children: labelContent })
|
|
4091
|
+
] });
|
|
4092
|
+
const containerClassName = cn(
|
|
4093
|
+
splitButtonVariants({
|
|
4094
|
+
variant: actualVariant,
|
|
4095
|
+
size: actualSize,
|
|
4096
|
+
disabled
|
|
4097
|
+
}),
|
|
4098
|
+
typographyClass,
|
|
4099
|
+
className
|
|
4100
|
+
);
|
|
4101
|
+
const mergedStyle = __spreadValues({
|
|
4102
|
+
paddingInlineStart: tokens.leadingPadding.start,
|
|
4103
|
+
paddingInlineEnd: tokens.leadingPadding.end,
|
|
4104
|
+
gap: "8px",
|
|
4105
|
+
borderRadius
|
|
4106
|
+
}, style);
|
|
4107
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: asChild ? /* @__PURE__ */ jsx(
|
|
4108
|
+
Slot,
|
|
4109
|
+
__spreadProps(__spreadValues({
|
|
4110
|
+
ref,
|
|
4111
|
+
"aria-disabled": disabled || void 0,
|
|
4112
|
+
onClick: handleClick,
|
|
4113
|
+
onPointerDown: handlePointerDown,
|
|
4114
|
+
onPointerUp: handlePointerUp,
|
|
4115
|
+
onPointerEnter: handlePointerEnter,
|
|
4116
|
+
onPointerLeave: handlePointerLeave,
|
|
4117
|
+
onPointerCancel: handlePointerCancel,
|
|
4118
|
+
onFocus: handleFocus,
|
|
4119
|
+
onBlur: handleBlur,
|
|
4120
|
+
style: mergedStyle,
|
|
4121
|
+
className: containerClassName
|
|
4122
|
+
}, restProps), {
|
|
4123
|
+
children: React16.cloneElement(
|
|
4124
|
+
React16.Children.only(children),
|
|
4125
|
+
{ children: innerContent }
|
|
4126
|
+
)
|
|
4127
|
+
})
|
|
4128
|
+
) : /* @__PURE__ */ jsx(
|
|
3829
4129
|
m.button,
|
|
3830
4130
|
__spreadProps(__spreadValues({
|
|
3831
4131
|
ref,
|
|
3832
4132
|
type: "button",
|
|
3833
|
-
"aria-disabled": disabled,
|
|
3834
4133
|
disabled,
|
|
3835
4134
|
onClick: handleClick,
|
|
3836
4135
|
onPointerDown: handlePointerDown,
|
|
@@ -3847,56 +4146,24 @@ var SplitButtonLeadingComponent = React11.forwardRef(
|
|
|
3847
4146
|
paddingInlineEnd: tokens.leadingPadding.end,
|
|
3848
4147
|
gap: "8px"
|
|
3849
4148
|
}, style),
|
|
3850
|
-
className:
|
|
3851
|
-
splitButtonVariants({
|
|
3852
|
-
variant: actualVariant,
|
|
3853
|
-
size: actualSize,
|
|
3854
|
-
disabled
|
|
3855
|
-
}),
|
|
3856
|
-
typographyClass,
|
|
3857
|
-
className
|
|
3858
|
-
)
|
|
4149
|
+
className: containerClassName
|
|
3859
4150
|
}, restProps), {
|
|
3860
|
-
children:
|
|
3861
|
-
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
3862
|
-
/* @__PURE__ */ jsx(
|
|
3863
|
-
StateLayer,
|
|
3864
|
-
{
|
|
3865
|
-
hovered: isHovered,
|
|
3866
|
-
focused: isFocused,
|
|
3867
|
-
pressed: isPressed
|
|
3868
|
-
}
|
|
3869
|
-
),
|
|
3870
|
-
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
3871
|
-
icon && /* @__PURE__ */ jsx(
|
|
3872
|
-
"span",
|
|
3873
|
-
{
|
|
3874
|
-
className: "flex items-center justify-center shrink-0 [&>svg]:w-full [&>svg]:h-full overflow-hidden [&_.md-icon]:text-[length:inherit]!",
|
|
3875
|
-
style: {
|
|
3876
|
-
fontSize: leadingIconSize,
|
|
3877
|
-
width: leadingIconSize,
|
|
3878
|
-
height: leadingIconSize
|
|
3879
|
-
},
|
|
3880
|
-
children: icon
|
|
3881
|
-
}
|
|
3882
|
-
),
|
|
3883
|
-
children && /* @__PURE__ */ jsx("span", { className: "inline-flex items-center h-full gap-[inherit]", children })
|
|
3884
|
-
]
|
|
4151
|
+
children: innerContent
|
|
3885
4152
|
})
|
|
3886
4153
|
) });
|
|
3887
4154
|
}
|
|
3888
4155
|
);
|
|
3889
4156
|
SplitButtonLeadingComponent.displayName = "SplitButtonLeading";
|
|
3890
|
-
var SplitButtonLeading =
|
|
3891
|
-
var FilledSplitButtonLeading =
|
|
4157
|
+
var SplitButtonLeading = React16.memo(SplitButtonLeadingComponent);
|
|
4158
|
+
var FilledSplitButtonLeading = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonLeading, __spreadValues({ ref, variant: "filled" }, props)));
|
|
3892
4159
|
FilledSplitButtonLeading.displayName = "FilledSplitButtonLeading";
|
|
3893
|
-
var TonalSplitButtonLeading =
|
|
4160
|
+
var TonalSplitButtonLeading = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonLeading, __spreadValues({ ref, variant: "tonal" }, props)));
|
|
3894
4161
|
TonalSplitButtonLeading.displayName = "TonalSplitButtonLeading";
|
|
3895
|
-
var ElevatedSplitButtonLeading =
|
|
4162
|
+
var ElevatedSplitButtonLeading = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonLeading, __spreadValues({ ref, variant: "elevated" }, props)));
|
|
3896
4163
|
ElevatedSplitButtonLeading.displayName = "ElevatedSplitButtonLeading";
|
|
3897
|
-
var OutlinedSplitButtonLeading =
|
|
4164
|
+
var OutlinedSplitButtonLeading = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonLeading, __spreadValues({ ref, variant: "outlined" }, props)));
|
|
3898
4165
|
OutlinedSplitButtonLeading.displayName = "OutlinedSplitButtonLeading";
|
|
3899
|
-
var SplitButtonTrailingComponent =
|
|
4166
|
+
var SplitButtonTrailingComponent = React16.forwardRef(
|
|
3900
4167
|
(_a, ref) => {
|
|
3901
4168
|
var _b = _a, {
|
|
3902
4169
|
className,
|
|
@@ -3913,6 +4180,8 @@ var SplitButtonTrailingComponent = React11.forwardRef(
|
|
|
3913
4180
|
onPointerCancel,
|
|
3914
4181
|
onFocus,
|
|
3915
4182
|
onBlur,
|
|
4183
|
+
asChild = false,
|
|
4184
|
+
children,
|
|
3916
4185
|
"aria-label": ariaLabel
|
|
3917
4186
|
} = _b, restProps = __objRest(_b, [
|
|
3918
4187
|
"className",
|
|
@@ -3929,15 +4198,17 @@ var SplitButtonTrailingComponent = React11.forwardRef(
|
|
|
3929
4198
|
"onPointerCancel",
|
|
3930
4199
|
"onFocus",
|
|
3931
4200
|
"onBlur",
|
|
4201
|
+
"asChild",
|
|
4202
|
+
"children",
|
|
3932
4203
|
"aria-label"
|
|
3933
4204
|
]);
|
|
3934
4205
|
var _a2, _b2;
|
|
3935
4206
|
const context = useSplitButtonContext();
|
|
3936
4207
|
const actualSize = (_a2 = context == null ? void 0 : context.size) != null ? _a2 : size;
|
|
3937
4208
|
const actualVariant = (_b2 = context == null ? void 0 : context.variant) != null ? _b2 : variant;
|
|
3938
|
-
const [isHovered, setIsHovered] =
|
|
3939
|
-
const [isFocused, setIsFocused] =
|
|
3940
|
-
const [isPressed, setIsPressed] =
|
|
4209
|
+
const [isHovered, setIsHovered] = React16.useState(false);
|
|
4210
|
+
const [isFocused, setIsFocused] = React16.useState(false);
|
|
4211
|
+
const [isPressed, setIsPressed] = React16.useState(false);
|
|
3941
4212
|
const tokens = SPLIT_BUTTON_TOKENS[actualSize];
|
|
3942
4213
|
const prefersReducedMotion = useReducedMotion();
|
|
3943
4214
|
const needsTouchTarget = actualSize === "xs" || actualSize === "sm";
|
|
@@ -3949,12 +4220,12 @@ var SplitButtonTrailingComponent = React11.forwardRef(
|
|
|
3949
4220
|
const innerCornerRadius = isPressed || isFocused ? tokens.innerCorner.pressed : isHovered ? tokens.innerCorner.hovered : tokens.innerCorner.default;
|
|
3950
4221
|
const outerRadius = tokens.containerHeight * tokens.outerCornerPercent / 100;
|
|
3951
4222
|
const borderRadius = checked ? `${outerRadius}px ${outerRadius}px ${outerRadius}px ${outerRadius}px` : `${innerCornerRadius}px ${outerRadius}px ${outerRadius}px ${innerCornerRadius}px`;
|
|
3952
|
-
const handleToggle =
|
|
4223
|
+
const handleToggle = React16.useCallback(() => {
|
|
3953
4224
|
if (!disabled) {
|
|
3954
4225
|
onCheckedChange(!checked);
|
|
3955
4226
|
}
|
|
3956
4227
|
}, [disabled, checked, onCheckedChange]);
|
|
3957
|
-
const handlePointerDown =
|
|
4228
|
+
const handlePointerDown = React16.useCallback(
|
|
3958
4229
|
(e) => {
|
|
3959
4230
|
onRipplePointerDown(e);
|
|
3960
4231
|
setIsPressed(true);
|
|
@@ -3962,19 +4233,19 @@ var SplitButtonTrailingComponent = React11.forwardRef(
|
|
|
3962
4233
|
},
|
|
3963
4234
|
[onRipplePointerDown, onPointerDown]
|
|
3964
4235
|
);
|
|
3965
|
-
const handlePointerUp =
|
|
4236
|
+
const handlePointerUp = React16.useCallback(
|
|
3966
4237
|
(e) => {
|
|
3967
4238
|
setIsPressed(false);
|
|
3968
4239
|
onPointerUp == null ? void 0 : onPointerUp(e);
|
|
3969
4240
|
},
|
|
3970
4241
|
[onPointerUp]
|
|
3971
4242
|
);
|
|
3972
|
-
const handlePointerEnter =
|
|
4243
|
+
const handlePointerEnter = React16.useCallback(() => {
|
|
3973
4244
|
if (!disabled) {
|
|
3974
4245
|
setIsHovered(true);
|
|
3975
4246
|
}
|
|
3976
4247
|
}, [disabled]);
|
|
3977
|
-
const handlePointerLeave =
|
|
4248
|
+
const handlePointerLeave = React16.useCallback(
|
|
3978
4249
|
(e) => {
|
|
3979
4250
|
setIsHovered(false);
|
|
3980
4251
|
setIsPressed(false);
|
|
@@ -3982,35 +4253,102 @@ var SplitButtonTrailingComponent = React11.forwardRef(
|
|
|
3982
4253
|
},
|
|
3983
4254
|
[onPointerLeave]
|
|
3984
4255
|
);
|
|
3985
|
-
const handlePointerCancel =
|
|
4256
|
+
const handlePointerCancel = React16.useCallback(
|
|
3986
4257
|
(e) => {
|
|
3987
4258
|
setIsPressed(false);
|
|
3988
4259
|
onPointerCancel == null ? void 0 : onPointerCancel(e);
|
|
3989
4260
|
},
|
|
3990
4261
|
[onPointerCancel]
|
|
3991
4262
|
);
|
|
3992
|
-
const handleFocus =
|
|
4263
|
+
const handleFocus = React16.useCallback(
|
|
3993
4264
|
(e) => {
|
|
3994
4265
|
if (!disabled) setIsFocused(true);
|
|
3995
4266
|
onFocus == null ? void 0 : onFocus(e);
|
|
3996
4267
|
},
|
|
3997
4268
|
[disabled, onFocus]
|
|
3998
4269
|
);
|
|
3999
|
-
const handleBlur =
|
|
4270
|
+
const handleBlur = React16.useCallback(
|
|
4000
4271
|
(e) => {
|
|
4001
4272
|
setIsFocused(false);
|
|
4002
4273
|
onBlur == null ? void 0 : onBlur(e);
|
|
4003
4274
|
},
|
|
4004
4275
|
[onBlur]
|
|
4005
4276
|
);
|
|
4006
|
-
|
|
4277
|
+
const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4278
|
+
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
4279
|
+
/* @__PURE__ */ jsx(
|
|
4280
|
+
StateLayer,
|
|
4281
|
+
{
|
|
4282
|
+
hovered: isHovered,
|
|
4283
|
+
focused: isFocused,
|
|
4284
|
+
pressed: isPressed
|
|
4285
|
+
}
|
|
4286
|
+
),
|
|
4287
|
+
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
4288
|
+
/* @__PURE__ */ jsx(
|
|
4289
|
+
m.div,
|
|
4290
|
+
{
|
|
4291
|
+
animate: {
|
|
4292
|
+
rotate: checked ? 180 : 0,
|
|
4293
|
+
x: checked ? 0 : tokens.opticalCenterOffset
|
|
4294
|
+
},
|
|
4295
|
+
transition: prefersReducedMotion ? { duration: 0 } : SPLIT_BUTTON_CHEVRON_SPRING,
|
|
4296
|
+
className: "flex items-center justify-center shrink-0",
|
|
4297
|
+
children: icon != null ? icon : /* @__PURE__ */ jsx(
|
|
4298
|
+
Icon,
|
|
4299
|
+
{
|
|
4300
|
+
name: "arrow_drop_down",
|
|
4301
|
+
size: tokens.trailingIconSize,
|
|
4302
|
+
opticalSize: 24
|
|
4303
|
+
}
|
|
4304
|
+
)
|
|
4305
|
+
}
|
|
4306
|
+
)
|
|
4307
|
+
] });
|
|
4308
|
+
const containerClassName = cn(
|
|
4309
|
+
splitButtonVariants({
|
|
4310
|
+
variant: actualVariant,
|
|
4311
|
+
size: actualSize,
|
|
4312
|
+
disabled
|
|
4313
|
+
}),
|
|
4314
|
+
className
|
|
4315
|
+
);
|
|
4316
|
+
const mergedStyle = __spreadValues({
|
|
4317
|
+
paddingInlineStart: tokens.trailingPadding.start,
|
|
4318
|
+
paddingInlineEnd: tokens.trailingPadding.end,
|
|
4319
|
+
borderRadius
|
|
4320
|
+
}, style);
|
|
4321
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: asChild ? /* @__PURE__ */ jsx(
|
|
4322
|
+
Slot,
|
|
4323
|
+
__spreadProps(__spreadValues({
|
|
4324
|
+
ref,
|
|
4325
|
+
"aria-label": ariaLabel,
|
|
4326
|
+
"aria-expanded": checked,
|
|
4327
|
+
"aria-disabled": disabled,
|
|
4328
|
+
onClick: handleToggle,
|
|
4329
|
+
onPointerDown: handlePointerDown,
|
|
4330
|
+
onPointerUp: handlePointerUp,
|
|
4331
|
+
onPointerEnter: handlePointerEnter,
|
|
4332
|
+
onPointerLeave: handlePointerLeave,
|
|
4333
|
+
onPointerCancel: handlePointerCancel,
|
|
4334
|
+
onFocus: handleFocus,
|
|
4335
|
+
onBlur: handleBlur,
|
|
4336
|
+
style: mergedStyle,
|
|
4337
|
+
className: containerClassName
|
|
4338
|
+
}, restProps), {
|
|
4339
|
+
children: React16.cloneElement(
|
|
4340
|
+
React16.Children.only(children),
|
|
4341
|
+
{ children: innerContent }
|
|
4342
|
+
)
|
|
4343
|
+
})
|
|
4344
|
+
) : /* @__PURE__ */ jsx(
|
|
4007
4345
|
m.button,
|
|
4008
4346
|
__spreadProps(__spreadValues({
|
|
4009
4347
|
ref,
|
|
4010
4348
|
type: "button",
|
|
4011
|
-
"aria-pressed": checked,
|
|
4012
|
-
"aria-expanded": checked,
|
|
4013
4349
|
"aria-label": ariaLabel,
|
|
4350
|
+
"aria-expanded": checked,
|
|
4351
|
+
"aria-disabled": disabled,
|
|
4014
4352
|
disabled,
|
|
4015
4353
|
onClick: handleToggle,
|
|
4016
4354
|
onPointerDown: handlePointerDown,
|
|
@@ -4026,61 +4364,24 @@ var SplitButtonTrailingComponent = React11.forwardRef(
|
|
|
4026
4364
|
paddingInlineStart: tokens.trailingPadding.start,
|
|
4027
4365
|
paddingInlineEnd: tokens.trailingPadding.end
|
|
4028
4366
|
}, style),
|
|
4029
|
-
className:
|
|
4030
|
-
splitButtonVariants({
|
|
4031
|
-
variant: actualVariant,
|
|
4032
|
-
size: actualSize,
|
|
4033
|
-
disabled
|
|
4034
|
-
}),
|
|
4035
|
-
className
|
|
4036
|
-
)
|
|
4367
|
+
className: containerClassName
|
|
4037
4368
|
}, restProps), {
|
|
4038
|
-
children:
|
|
4039
|
-
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
4040
|
-
/* @__PURE__ */ jsx(
|
|
4041
|
-
StateLayer,
|
|
4042
|
-
{
|
|
4043
|
-
hovered: isHovered,
|
|
4044
|
-
focused: isFocused,
|
|
4045
|
-
pressed: isPressed
|
|
4046
|
-
}
|
|
4047
|
-
),
|
|
4048
|
-
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
4049
|
-
/* @__PURE__ */ jsx(
|
|
4050
|
-
m.div,
|
|
4051
|
-
{
|
|
4052
|
-
animate: {
|
|
4053
|
-
rotate: checked ? 180 : 0,
|
|
4054
|
-
x: checked ? 0 : tokens.opticalCenterOffset
|
|
4055
|
-
},
|
|
4056
|
-
transition: prefersReducedMotion ? { duration: 0 } : SPLIT_BUTTON_CHEVRON_SPRING,
|
|
4057
|
-
className: "flex items-center justify-center shrink-0",
|
|
4058
|
-
children: icon != null ? icon : /* @__PURE__ */ jsx(
|
|
4059
|
-
Icon,
|
|
4060
|
-
{
|
|
4061
|
-
name: "arrow_drop_down",
|
|
4062
|
-
size: tokens.trailingIconSize,
|
|
4063
|
-
opticalSize: 24
|
|
4064
|
-
}
|
|
4065
|
-
)
|
|
4066
|
-
}
|
|
4067
|
-
)
|
|
4068
|
-
]
|
|
4369
|
+
children: innerContent
|
|
4069
4370
|
})
|
|
4070
4371
|
) });
|
|
4071
4372
|
}
|
|
4072
4373
|
);
|
|
4073
4374
|
SplitButtonTrailingComponent.displayName = "SplitButtonTrailing";
|
|
4074
|
-
var SplitButtonTrailing =
|
|
4075
|
-
var FilledSplitButtonTrailing =
|
|
4375
|
+
var SplitButtonTrailing = React16.memo(SplitButtonTrailingComponent);
|
|
4376
|
+
var FilledSplitButtonTrailing = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonTrailing, __spreadValues({ ref, variant: "filled" }, props)));
|
|
4076
4377
|
FilledSplitButtonTrailing.displayName = "FilledSplitButtonTrailing";
|
|
4077
|
-
var TonalSplitButtonTrailing =
|
|
4378
|
+
var TonalSplitButtonTrailing = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonTrailing, __spreadValues({ ref, variant: "tonal" }, props)));
|
|
4078
4379
|
TonalSplitButtonTrailing.displayName = "TonalSplitButtonTrailing";
|
|
4079
|
-
var ElevatedSplitButtonTrailing =
|
|
4380
|
+
var ElevatedSplitButtonTrailing = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonTrailing, __spreadValues({ ref, variant: "elevated" }, props)));
|
|
4080
4381
|
ElevatedSplitButtonTrailing.displayName = "ElevatedSplitButtonTrailing";
|
|
4081
|
-
var OutlinedSplitButtonTrailing =
|
|
4382
|
+
var OutlinedSplitButtonTrailing = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonTrailing, __spreadValues({ ref, variant: "outlined" }, props)));
|
|
4082
4383
|
OutlinedSplitButtonTrailing.displayName = "OutlinedSplitButtonTrailing";
|
|
4083
|
-
var SplitButtonTrailingUncheckableComponent =
|
|
4384
|
+
var SplitButtonTrailingUncheckableComponent = React16.forwardRef(
|
|
4084
4385
|
(_a, ref) => {
|
|
4085
4386
|
var _b = _a, {
|
|
4086
4387
|
className,
|
|
@@ -4117,9 +4418,9 @@ var SplitButtonTrailingUncheckableComponent = React11.forwardRef(
|
|
|
4117
4418
|
const context = useSplitButtonContext();
|
|
4118
4419
|
const actualSize = (_a2 = context == null ? void 0 : context.size) != null ? _a2 : size;
|
|
4119
4420
|
const actualVariant = (_b2 = context == null ? void 0 : context.variant) != null ? _b2 : variant;
|
|
4120
|
-
const [isHovered, setIsHovered] =
|
|
4121
|
-
const [isFocused, setIsFocused] =
|
|
4122
|
-
const [isPressed, setIsPressed] =
|
|
4421
|
+
const [isHovered, setIsHovered] = React16.useState(false);
|
|
4422
|
+
const [isFocused, setIsFocused] = React16.useState(false);
|
|
4423
|
+
const [isPressed, setIsPressed] = React16.useState(false);
|
|
4123
4424
|
const tokens = SPLIT_BUTTON_TOKENS[actualSize];
|
|
4124
4425
|
const needsTouchTarget = actualSize === "xs" || actualSize === "sm";
|
|
4125
4426
|
const {
|
|
@@ -4130,7 +4431,7 @@ var SplitButtonTrailingUncheckableComponent = React11.forwardRef(
|
|
|
4130
4431
|
const innerCornerRadius = isPressed || isFocused ? tokens.innerCorner.pressed : isHovered ? tokens.innerCorner.hovered : tokens.innerCorner.default;
|
|
4131
4432
|
const outerRadius = tokens.containerHeight * tokens.outerCornerPercent / 100;
|
|
4132
4433
|
const borderRadius = `${innerCornerRadius}px ${outerRadius}px ${outerRadius}px ${innerCornerRadius}px`;
|
|
4133
|
-
const handlePointerDown =
|
|
4434
|
+
const handlePointerDown = React16.useCallback(
|
|
4134
4435
|
(e) => {
|
|
4135
4436
|
onRipplePointerDown(e);
|
|
4136
4437
|
setIsPressed(true);
|
|
@@ -4138,19 +4439,19 @@ var SplitButtonTrailingUncheckableComponent = React11.forwardRef(
|
|
|
4138
4439
|
},
|
|
4139
4440
|
[onRipplePointerDown, onPointerDown]
|
|
4140
4441
|
);
|
|
4141
|
-
const handlePointerUp =
|
|
4442
|
+
const handlePointerUp = React16.useCallback(
|
|
4142
4443
|
(e) => {
|
|
4143
4444
|
setIsPressed(false);
|
|
4144
4445
|
onPointerUp == null ? void 0 : onPointerUp(e);
|
|
4145
4446
|
},
|
|
4146
4447
|
[onPointerUp]
|
|
4147
4448
|
);
|
|
4148
|
-
const handlePointerEnter =
|
|
4449
|
+
const handlePointerEnter = React16.useCallback(() => {
|
|
4149
4450
|
if (!disabled) {
|
|
4150
4451
|
setIsHovered(true);
|
|
4151
4452
|
}
|
|
4152
4453
|
}, [disabled]);
|
|
4153
|
-
const handlePointerLeave =
|
|
4454
|
+
const handlePointerLeave = React16.useCallback(
|
|
4154
4455
|
(e) => {
|
|
4155
4456
|
setIsHovered(false);
|
|
4156
4457
|
setIsPressed(false);
|
|
@@ -4158,21 +4459,21 @@ var SplitButtonTrailingUncheckableComponent = React11.forwardRef(
|
|
|
4158
4459
|
},
|
|
4159
4460
|
[onPointerLeave]
|
|
4160
4461
|
);
|
|
4161
|
-
const handlePointerCancel =
|
|
4462
|
+
const handlePointerCancel = React16.useCallback(
|
|
4162
4463
|
(e) => {
|
|
4163
4464
|
setIsPressed(false);
|
|
4164
4465
|
onPointerCancel == null ? void 0 : onPointerCancel(e);
|
|
4165
4466
|
},
|
|
4166
4467
|
[onPointerCancel]
|
|
4167
4468
|
);
|
|
4168
|
-
const handleFocus =
|
|
4469
|
+
const handleFocus = React16.useCallback(
|
|
4169
4470
|
(e) => {
|
|
4170
4471
|
if (!disabled) setIsFocused(true);
|
|
4171
4472
|
onFocus == null ? void 0 : onFocus(e);
|
|
4172
4473
|
},
|
|
4173
4474
|
[disabled, onFocus]
|
|
4174
4475
|
);
|
|
4175
|
-
const handleBlur =
|
|
4476
|
+
const handleBlur = React16.useCallback(
|
|
4176
4477
|
(e) => {
|
|
4177
4478
|
setIsFocused(false);
|
|
4178
4479
|
onBlur == null ? void 0 : onBlur(e);
|
|
@@ -4239,18 +4540,18 @@ var SplitButtonTrailingUncheckableComponent = React11.forwardRef(
|
|
|
4239
4540
|
}
|
|
4240
4541
|
);
|
|
4241
4542
|
SplitButtonTrailingUncheckableComponent.displayName = "SplitButtonTrailingUncheckable";
|
|
4242
|
-
var SplitButtonTrailingUncheckable =
|
|
4543
|
+
var SplitButtonTrailingUncheckable = React16.memo(
|
|
4243
4544
|
SplitButtonTrailingUncheckableComponent
|
|
4244
4545
|
);
|
|
4245
|
-
var FilledSplitButtonTrailingUncheckable =
|
|
4546
|
+
var FilledSplitButtonTrailingUncheckable = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonTrailingUncheckable, __spreadValues({ ref, variant: "filled" }, props)));
|
|
4246
4547
|
FilledSplitButtonTrailingUncheckable.displayName = "FilledSplitButtonTrailingUncheckable";
|
|
4247
|
-
var TonalSplitButtonTrailingUncheckable =
|
|
4548
|
+
var TonalSplitButtonTrailingUncheckable = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonTrailingUncheckable, __spreadValues({ ref, variant: "tonal" }, props)));
|
|
4248
4549
|
TonalSplitButtonTrailingUncheckable.displayName = "TonalSplitButtonTrailingUncheckable";
|
|
4249
|
-
var ElevatedSplitButtonTrailingUncheckable =
|
|
4550
|
+
var ElevatedSplitButtonTrailingUncheckable = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonTrailingUncheckable, __spreadValues({ ref, variant: "elevated" }, props)));
|
|
4250
4551
|
ElevatedSplitButtonTrailingUncheckable.displayName = "ElevatedSplitButtonTrailingUncheckable";
|
|
4251
|
-
var OutlinedSplitButtonTrailingUncheckable =
|
|
4552
|
+
var OutlinedSplitButtonTrailingUncheckable = React16.forwardRef((props, ref) => /* @__PURE__ */ jsx(SplitButtonTrailingUncheckable, __spreadValues({ ref, variant: "outlined" }, props)));
|
|
4252
4553
|
OutlinedSplitButtonTrailingUncheckable.displayName = "OutlinedSplitButtonTrailingUncheckable";
|
|
4253
4554
|
|
|
4254
|
-
export { BUTTON_COLOR_TOKENS, BUTTON_GROUP_TOKENS, BUTTON_SIZE_TOKENS, Button, ButtonGroup, ButtonGroupDefaults, ElevatedSplitButtonLeading, ElevatedSplitButtonTrailing, ElevatedSplitButtonTrailingUncheckable, ExtendedFAB, FAB, FABMenu, FABMenuItem, FABPosition, FilledSplitButtonLeading, FilledSplitButtonTrailing, FilledSplitButtonTrailingUncheckable, IconButton, LEADING_ICON_SIZE_FOR_SIZE, OutlinedSplitButtonLeading, OutlinedSplitButtonTrailing, OutlinedSplitButtonTrailingUncheckable, SPLIT_BUTTON_CHEVRON_SPRING, SPLIT_BUTTON_RADIUS_SPRING, SPLIT_BUTTON_TOKENS, SplitButtonLayout, SplitButtonLeading, SplitButtonTrailing, SplitButtonTrailingUncheckable, ToggleFAB, TonalSplitButtonLeading, TonalSplitButtonTrailing, TonalSplitButtonTrailingUncheckable, splitButtonVariants };
|
|
4555
|
+
export { BUTTON_COLOR_TOKENS, BUTTON_GROUP_TOKENS, BUTTON_SIZE_TOKENS, Button, ButtonDistribute, ButtonGroup, ButtonGroupDefaults, DEFAULT_EXPAND_RATIO, DEFAULT_FIXED_SIZE, DEFAULT_GAP, DISTRIBUTE_DURATION_MS, DISTRIBUTE_EASING_BEZIER, DISTRIBUTE_RADIUS_TOKENS, DISTRIBUTE_SPRING_TRANSITION, ElevatedSplitButtonLeading, ElevatedSplitButtonTrailing, ElevatedSplitButtonTrailingUncheckable, ExtendedFAB, FAB, FABMenu, FABMenuItem, FABPosition, FilledSplitButtonLeading, FilledSplitButtonTrailing, FilledSplitButtonTrailingUncheckable, IconButton, LEADING_ICON_SIZE_FOR_SIZE, OutlinedSplitButtonLeading, OutlinedSplitButtonTrailing, OutlinedSplitButtonTrailingUncheckable, SPLIT_BUTTON_CHEVRON_SPRING, SPLIT_BUTTON_RADIUS_SPRING, SPLIT_BUTTON_TOKENS, SplitButtonLayout, SplitButtonLeading, SplitButtonTrailing, SplitButtonTrailingUncheckable, ToggleFAB, TonalSplitButtonLeading, TonalSplitButtonTrailing, TonalSplitButtonTrailingUncheckable, splitButtonVariants };
|
|
4255
4556
|
//# sourceMappingURL=buttons.mjs.map
|
|
4256
4557
|
//# sourceMappingURL=buttons.mjs.map
|