@bug-on/m3-expressive 1.2.5 → 1.2.7
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.js +260 -98
- package/dist/buttons.js.map +1 -1
- package/dist/buttons.mjs +261 -99
- package/dist/buttons.mjs.map +1 -1
- package/dist/core.js +338 -176
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +321 -159
- package/dist/core.mjs.map +1 -1
- package/dist/feedback.d.mts +32 -0
- package/dist/feedback.d.ts +32 -0
- package/dist/feedback.js +348 -186
- package/dist/feedback.js.map +1 -1
- package/dist/feedback.mjs +326 -164
- package/dist/feedback.mjs.map +1 -1
- package/dist/index.js +261 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +262 -100
- package/dist/index.mjs.map +1 -1
- package/dist/layout.js +261 -99
- package/dist/layout.js.map +1 -1
- package/dist/layout.mjs +262 -100
- package/dist/layout.mjs.map +1 -1
- package/dist/navigation.js +260 -98
- package/dist/navigation.js.map +1 -1
- package/dist/navigation.mjs +261 -99
- package/dist/navigation.mjs.map +1 -1
- package/dist/overlays.js +391 -229
- package/dist/overlays.js.map +1 -1
- package/dist/overlays.mjs +354 -192
- package/dist/overlays.mjs.map +1 -1
- package/dist/pickers.js +399 -237
- package/dist/pickers.js.map +1 -1
- package/dist/pickers.mjs +367 -205
- package/dist/pickers.mjs.map +1 -1
- package/package.json +1 -1
package/dist/core.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import * as
|
|
2
|
+
import * as React4 from 'react';
|
|
3
3
|
import { createContext, useState, useEffect, useRef, useCallback, useMemo, useContext } from 'react';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { hexFromArgb, Hct, SchemeExpressive, SchemeNeutral, SchemeMonochrome, SchemeContent, SchemeFidelity, SchemeVibrant, SchemeTonalSpot } from '@material/material-color-utilities';
|
|
6
6
|
import { clsx } from 'clsx';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
|
-
import { LazyMotion, domMax, m, useMotionValue, animate,
|
|
8
|
+
import { LazyMotion, domMax, m, useAnimationFrame, useMotionValue, animate, AnimatePresence, useReducedMotion } from 'motion/react';
|
|
9
9
|
import { Slot } from '@radix-ui/react-slot';
|
|
10
10
|
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -297,7 +297,7 @@ var VARIANT_FONT = {
|
|
|
297
297
|
rounded: "'Material Symbols Rounded'",
|
|
298
298
|
sharp: "'Material Symbols Sharp'"
|
|
299
299
|
};
|
|
300
|
-
var IconComponent =
|
|
300
|
+
var IconComponent = React4.forwardRef(
|
|
301
301
|
(_a, ref) => {
|
|
302
302
|
var _b = _a, {
|
|
303
303
|
name,
|
|
@@ -363,8 +363,8 @@ var IconComponent = React11.forwardRef(
|
|
|
363
363
|
}
|
|
364
364
|
);
|
|
365
365
|
IconComponent.displayName = "Icon";
|
|
366
|
-
var Icon =
|
|
367
|
-
var RippleItem =
|
|
366
|
+
var Icon = React4.memo(IconComponent);
|
|
367
|
+
var RippleItem = React4.memo(function RippleItem2({
|
|
368
368
|
ripple,
|
|
369
369
|
onDone
|
|
370
370
|
}) {
|
|
@@ -408,8 +408,8 @@ function Ripple({
|
|
|
408
408
|
}
|
|
409
409
|
function useRippleState(options = {}) {
|
|
410
410
|
const { disabled = false } = options;
|
|
411
|
-
const [ripples, setRipples] =
|
|
412
|
-
const onPointerDown =
|
|
411
|
+
const [ripples, setRipples] = React4.useState([]);
|
|
412
|
+
const onPointerDown = React4.useCallback(
|
|
413
413
|
(e) => {
|
|
414
414
|
if (disabled) return;
|
|
415
415
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
@@ -426,7 +426,7 @@ function useRippleState(options = {}) {
|
|
|
426
426
|
},
|
|
427
427
|
[disabled]
|
|
428
428
|
);
|
|
429
|
-
const removeRipple =
|
|
429
|
+
const removeRipple = React4.useCallback((id) => {
|
|
430
430
|
setRipples((prev) => prev.filter((r) => r.id !== id));
|
|
431
431
|
}, []);
|
|
432
432
|
return { ripples, onPointerDown, removeRipple };
|
|
@@ -477,11 +477,11 @@ var ROTATE_KEY_SPLINES = [
|
|
|
477
477
|
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";
|
|
478
478
|
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";
|
|
479
479
|
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";
|
|
480
|
-
var IndeterminateSvg =
|
|
480
|
+
var IndeterminateSvg = React4.memo(function IndeterminateSvg2({
|
|
481
481
|
size
|
|
482
482
|
}) {
|
|
483
|
-
const [ready, setReady] =
|
|
484
|
-
|
|
483
|
+
const [ready, setReady] = React4.useState(false);
|
|
484
|
+
React4.useEffect(() => {
|
|
485
485
|
const raf = requestAnimationFrame(() => setReady(true));
|
|
486
486
|
return () => cancelAnimationFrame(raf);
|
|
487
487
|
}, []);
|
|
@@ -526,7 +526,7 @@ var IndeterminateSvg = React11.memo(function IndeterminateSvg2({
|
|
|
526
526
|
}
|
|
527
527
|
);
|
|
528
528
|
});
|
|
529
|
-
var DeterminateSvg =
|
|
529
|
+
var DeterminateSvg = React4.memo(function DeterminateSvg2({
|
|
530
530
|
size,
|
|
531
531
|
progress
|
|
532
532
|
}) {
|
|
@@ -551,7 +551,7 @@ var DeterminateSvg = React11.memo(function DeterminateSvg2({
|
|
|
551
551
|
}
|
|
552
552
|
);
|
|
553
553
|
});
|
|
554
|
-
var LoadingIndicator =
|
|
554
|
+
var LoadingIndicator = React4.forwardRef(
|
|
555
555
|
(_a, ref) => {
|
|
556
556
|
var _b = _a, {
|
|
557
557
|
variant = "uncontained",
|
|
@@ -646,27 +646,47 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
|
646
646
|
if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
|
|
647
647
|
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
|
|
648
648
|
}
|
|
649
|
-
d
|
|
650
|
-
return d;
|
|
649
|
+
return `${d} Z`;
|
|
651
650
|
}
|
|
652
651
|
function getSinePath(startX, endX, phase, wl, amp) {
|
|
653
652
|
if (startX >= endX) return "";
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
653
|
+
if (amp <= 0.01) {
|
|
654
|
+
return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
|
|
655
|
+
}
|
|
656
|
+
const safeWl = Math.max(1, wl);
|
|
657
|
+
const k = 2 * Math.PI / safeWl;
|
|
658
|
+
const phi = phase / safeWl * 2 * Math.PI;
|
|
659
|
+
const yAt = (x) => amp * Math.sin(k * x + phi);
|
|
660
|
+
const dyAt = (x) => amp * k * Math.cos(k * x + phi);
|
|
661
|
+
const step = safeWl / 4;
|
|
662
|
+
let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
|
|
663
|
+
let currentX = startX;
|
|
664
|
+
while (currentX < endX) {
|
|
665
|
+
const nextX = Math.min(endX, currentX + step);
|
|
666
|
+
const dx = nextX - currentX;
|
|
667
|
+
const scale = dx / 3;
|
|
668
|
+
const y0 = yAt(currentX);
|
|
669
|
+
const dy0 = dyAt(currentX);
|
|
670
|
+
const y1 = yAt(nextX);
|
|
671
|
+
const dy1 = dyAt(nextX);
|
|
672
|
+
const cp1x = currentX + scale;
|
|
673
|
+
const cp1y = y0 + scale * dy0;
|
|
674
|
+
const cp2x = nextX - scale;
|
|
675
|
+
const cp2y = y1 - scale * dy1;
|
|
676
|
+
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
|
|
677
|
+
currentX = nextX;
|
|
678
|
+
}
|
|
667
679
|
return d;
|
|
668
680
|
}
|
|
669
|
-
var
|
|
681
|
+
var GLOBAL_ROTATION_DURATION = 6e3;
|
|
682
|
+
var GLOBAL_ROTATION_TARGET = 1080;
|
|
683
|
+
var ADDITIONAL_ROTATION_CYCLE = 1500;
|
|
684
|
+
var ADDITIONAL_ROTATION_STEP = 90;
|
|
685
|
+
var ADDITIONAL_ROTATION_EASE_DURATION = 500;
|
|
686
|
+
var DEFAULT_MIN_PROGRESS = 0.1;
|
|
687
|
+
var DEFAULT_MAX_PROGRESS = 0.8;
|
|
688
|
+
var PROGRESS_CYCLE_DURATION = 1500;
|
|
689
|
+
var CircularProgress = React4.forwardRef(
|
|
670
690
|
(_a, ref) => {
|
|
671
691
|
var _b = _a, {
|
|
672
692
|
value,
|
|
@@ -679,6 +699,10 @@ var CircularProgress = React11.forwardRef(
|
|
|
679
699
|
crawlerSpeed = 1,
|
|
680
700
|
color,
|
|
681
701
|
trackColor,
|
|
702
|
+
showTrack = "auto",
|
|
703
|
+
minProgress = DEFAULT_MIN_PROGRESS,
|
|
704
|
+
maxProgress = DEFAULT_MAX_PROGRESS,
|
|
705
|
+
amplitudeRange,
|
|
682
706
|
className,
|
|
683
707
|
"aria-label": ariaLabel
|
|
684
708
|
} = _b, restProps = __objRest(_b, [
|
|
@@ -692,6 +716,10 @@ var CircularProgress = React11.forwardRef(
|
|
|
692
716
|
"crawlerSpeed",
|
|
693
717
|
"color",
|
|
694
718
|
"trackColor",
|
|
719
|
+
"showTrack",
|
|
720
|
+
"minProgress",
|
|
721
|
+
"maxProgress",
|
|
722
|
+
"amplitudeRange",
|
|
695
723
|
"className",
|
|
696
724
|
"aria-label"
|
|
697
725
|
]);
|
|
@@ -702,17 +730,22 @@ var CircularProgress = React11.forwardRef(
|
|
|
702
730
|
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
703
731
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
704
732
|
const isWavy = shape === "wavy";
|
|
733
|
+
const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
|
|
705
734
|
const BASELINE_SIZE = 48;
|
|
706
735
|
const scaleFactor = size / BASELINE_SIZE;
|
|
707
|
-
const effectiveAmplitude =
|
|
736
|
+
const effectiveAmplitude = React4.useMemo(
|
|
708
737
|
() => amplitude != null ? amplitude : 1.6 * scaleFactor,
|
|
709
738
|
[amplitude, scaleFactor]
|
|
710
739
|
);
|
|
711
|
-
const effectiveWavelength =
|
|
740
|
+
const effectiveWavelength = React4.useMemo(
|
|
712
741
|
() => wavelength != null ? wavelength : 15 * scaleFactor,
|
|
713
742
|
[wavelength, scaleFactor]
|
|
714
743
|
);
|
|
715
|
-
const
|
|
744
|
+
const resolvedAmplitudeRange = React4.useMemo(
|
|
745
|
+
() => amplitudeRange != null ? amplitudeRange : [0, effectiveAmplitude],
|
|
746
|
+
[amplitudeRange, effectiveAmplitude]
|
|
747
|
+
);
|
|
748
|
+
const wavyActivePath = React4.useMemo(
|
|
716
749
|
() => isWavy ? generateWavyCircularPath(
|
|
717
750
|
center,
|
|
718
751
|
radius,
|
|
@@ -721,8 +754,8 @@ var CircularProgress = React11.forwardRef(
|
|
|
721
754
|
) : null,
|
|
722
755
|
[isWavy, center, radius, effectiveAmplitude, effectiveWavelength]
|
|
723
756
|
);
|
|
724
|
-
const circumference =
|
|
725
|
-
const gapForTrack =
|
|
757
|
+
const circumference = React4.useMemo(() => 2 * Math.PI * radius, [radius]);
|
|
758
|
+
const gapForTrack = React4.useMemo(
|
|
726
759
|
() => (gapSize + trackHeight) / circumference,
|
|
727
760
|
[gapSize, trackHeight, circumference]
|
|
728
761
|
);
|
|
@@ -731,6 +764,145 @@ var CircularProgress = React11.forwardRef(
|
|
|
731
764
|
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
732
765
|
const ActiveCircleElem = m.circle;
|
|
733
766
|
const ActivePathElem = m.path;
|
|
767
|
+
const indeterminateSvgRef = React4.useRef(null);
|
|
768
|
+
const indeterminateTrackRef = React4.useRef(null);
|
|
769
|
+
const indeterminateActiveRef = React4.useRef(null);
|
|
770
|
+
const indeterminateWavyTrackPathRef = React4.useRef(null);
|
|
771
|
+
const indeterminateWavyActivePathRef = React4.useRef(null);
|
|
772
|
+
const cachedPathLengthRef = React4.useRef(0);
|
|
773
|
+
React4.useLayoutEffect(() => {
|
|
774
|
+
if (!isWavy || !wavyActivePath) {
|
|
775
|
+
cachedPathLengthRef.current = circumference;
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const el = indeterminateActiveRef.current;
|
|
779
|
+
if (el && "getTotalLength" in el) {
|
|
780
|
+
try {
|
|
781
|
+
const len = el.getTotalLength();
|
|
782
|
+
if (len > 0) {
|
|
783
|
+
cachedPathLengthRef.current = len;
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
} catch (e) {
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
cachedPathLengthRef.current = circumference;
|
|
790
|
+
}, [isWavy, circumference, wavyActivePath]);
|
|
791
|
+
useAnimationFrame((time) => {
|
|
792
|
+
if (isDeterminate) return;
|
|
793
|
+
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
794
|
+
const scaledTime = time * safeCrawlerSpeed;
|
|
795
|
+
const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
|
|
796
|
+
const globalAngle = globalCycle / GLOBAL_ROTATION_DURATION * GLOBAL_ROTATION_TARGET;
|
|
797
|
+
const additionalFullCycles = Math.floor(
|
|
798
|
+
scaledTime / ADDITIONAL_ROTATION_CYCLE
|
|
799
|
+
);
|
|
800
|
+
const additionalCycleTime = scaledTime % ADDITIONAL_ROTATION_CYCLE;
|
|
801
|
+
const additionalEaseT = Math.min(
|
|
802
|
+
1,
|
|
803
|
+
additionalCycleTime / ADDITIONAL_ROTATION_EASE_DURATION
|
|
804
|
+
);
|
|
805
|
+
const additionalAngle = (additionalFullCycles + easeInOutCubic(additionalEaseT)) * ADDITIONAL_ROTATION_STEP;
|
|
806
|
+
const totalRotation = globalAngle + additionalAngle;
|
|
807
|
+
if (indeterminateSvgRef.current) {
|
|
808
|
+
indeterminateSvgRef.current.style.transform = `rotate(${totalRotation - 90}deg)`;
|
|
809
|
+
}
|
|
810
|
+
const progressFullCycle = PROGRESS_CYCLE_DURATION * 2;
|
|
811
|
+
const progressCycleTime = scaledTime % progressFullCycle;
|
|
812
|
+
let progress;
|
|
813
|
+
if (progressCycleTime < PROGRESS_CYCLE_DURATION) {
|
|
814
|
+
const t = progressCycleTime / PROGRESS_CYCLE_DURATION;
|
|
815
|
+
progress = minProgress + (maxProgress - minProgress) * easeInOutCubic(t);
|
|
816
|
+
} else {
|
|
817
|
+
const t = (progressCycleTime - PROGRESS_CYCLE_DURATION) / PROGRESS_CYCLE_DURATION;
|
|
818
|
+
progress = maxProgress - (maxProgress - minProgress) * easeInOutCubic(t);
|
|
819
|
+
}
|
|
820
|
+
if (isWavy) {
|
|
821
|
+
const amplitudeT = (progress - minProgress) / (maxProgress - minProgress);
|
|
822
|
+
const currentAmplitude = resolvedAmplitudeRange[0] + (resolvedAmplitudeRange[1] - resolvedAmplitudeRange[0]) * amplitudeT;
|
|
823
|
+
const dynamicPath = generateWavyCircularPath(
|
|
824
|
+
center,
|
|
825
|
+
radius,
|
|
826
|
+
currentAmplitude,
|
|
827
|
+
effectiveWavelength
|
|
828
|
+
);
|
|
829
|
+
if (indeterminateWavyActivePathRef.current) {
|
|
830
|
+
indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
831
|
+
}
|
|
832
|
+
if (indeterminateWavyTrackPathRef.current) {
|
|
833
|
+
indeterminateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
|
|
834
|
+
}
|
|
835
|
+
const pathEl = indeterminateWavyActivePathRef.current;
|
|
836
|
+
let totalLen = cachedPathLengthRef.current || circumference;
|
|
837
|
+
if (pathEl) {
|
|
838
|
+
try {
|
|
839
|
+
const len = pathEl.getTotalLength();
|
|
840
|
+
if (len > 0) totalLen = len;
|
|
841
|
+
} catch (e) {
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
845
|
+
const activeLen = totalLen * progress;
|
|
846
|
+
const activeOff = 0;
|
|
847
|
+
if (indeterminateWavyActivePathRef.current) {
|
|
848
|
+
indeterminateWavyActivePathRef.current.setAttribute(
|
|
849
|
+
"stroke-dasharray",
|
|
850
|
+
`${activeLen} ${totalLen}`
|
|
851
|
+
);
|
|
852
|
+
indeterminateWavyActivePathRef.current.setAttribute(
|
|
853
|
+
"stroke-dashoffset",
|
|
854
|
+
`${activeOff}`
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
if (shouldShowIndeterminateTrack && indeterminateWavyTrackPathRef.current) {
|
|
858
|
+
const trackStartFrac = progress + gapFrac;
|
|
859
|
+
const trackLen = Math.max(
|
|
860
|
+
1e-3,
|
|
861
|
+
totalLen * (1 - progress - 2 * gapFrac)
|
|
862
|
+
);
|
|
863
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
864
|
+
indeterminateWavyTrackPathRef.current.setAttribute(
|
|
865
|
+
"stroke-dasharray",
|
|
866
|
+
`${trackLen} ${totalLen}`
|
|
867
|
+
);
|
|
868
|
+
indeterminateWavyTrackPathRef.current.setAttribute(
|
|
869
|
+
"stroke-dashoffset",
|
|
870
|
+
`${trackOff}`
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
} else {
|
|
874
|
+
const totalLen = circumference;
|
|
875
|
+
const activeLen = totalLen * progress;
|
|
876
|
+
const activeOff = 0;
|
|
877
|
+
if (indeterminateActiveRef.current) {
|
|
878
|
+
indeterminateActiveRef.current.setAttribute(
|
|
879
|
+
"stroke-dasharray",
|
|
880
|
+
`${activeLen} ${totalLen}`
|
|
881
|
+
);
|
|
882
|
+
indeterminateActiveRef.current.setAttribute(
|
|
883
|
+
"stroke-dashoffset",
|
|
884
|
+
`${activeOff}`
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
if (shouldShowIndeterminateTrack && indeterminateTrackRef.current) {
|
|
888
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
889
|
+
const trackStartFrac = progress + gapFrac;
|
|
890
|
+
const trackLen = Math.max(
|
|
891
|
+
1e-3,
|
|
892
|
+
totalLen * (1 - progress - 2 * gapFrac)
|
|
893
|
+
);
|
|
894
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
895
|
+
indeterminateTrackRef.current.setAttribute(
|
|
896
|
+
"stroke-dasharray",
|
|
897
|
+
`${trackLen} ${totalLen}`
|
|
898
|
+
);
|
|
899
|
+
indeterminateTrackRef.current.setAttribute(
|
|
900
|
+
"stroke-dashoffset",
|
|
901
|
+
`${trackOff}`
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
});
|
|
734
906
|
return /* @__PURE__ */ jsx(
|
|
735
907
|
"div",
|
|
736
908
|
__spreadProps(__spreadValues({
|
|
@@ -807,9 +979,10 @@ var CircularProgress = React11.forwardRef(
|
|
|
807
979
|
]
|
|
808
980
|
}
|
|
809
981
|
),
|
|
810
|
-
!isDeterminate && /* @__PURE__ */
|
|
811
|
-
|
|
982
|
+
!isDeterminate && /* @__PURE__ */ jsx(
|
|
983
|
+
"svg",
|
|
812
984
|
{
|
|
985
|
+
ref: indeterminateSvgRef,
|
|
813
986
|
width: size,
|
|
814
987
|
height: size,
|
|
815
988
|
viewBox: `0 0 ${size} ${size}`,
|
|
@@ -818,90 +991,60 @@ var CircularProgress = React11.forwardRef(
|
|
|
818
991
|
position: "absolute",
|
|
819
992
|
inset: 0,
|
|
820
993
|
overflow: "visible",
|
|
821
|
-
|
|
822
|
-
|
|
994
|
+
transformOrigin: "center",
|
|
995
|
+
transform: "rotate(-90deg)"
|
|
823
996
|
},
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
828
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
829
|
-
ease: "linear"
|
|
830
|
-
}
|
|
831
|
-
},
|
|
832
|
-
children: [
|
|
833
|
-
/* @__PURE__ */ jsx(
|
|
834
|
-
m.circle,
|
|
997
|
+
children: isWavy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
998
|
+
shouldShowIndeterminateTrack && /* @__PURE__ */ jsx(
|
|
999
|
+
"path",
|
|
835
1000
|
{
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
r: radius,
|
|
1001
|
+
ref: indeterminateWavyTrackPathRef,
|
|
1002
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
839
1003
|
fill: "none",
|
|
840
1004
|
stroke: bgTrackColor,
|
|
841
1005
|
strokeWidth: trackHeight,
|
|
842
|
-
strokeLinecap: "round"
|
|
843
|
-
style: { originX: "50%", originY: "50%" },
|
|
844
|
-
animate: {
|
|
845
|
-
pathLength: [
|
|
846
|
-
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
|
|
847
|
-
Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
|
|
848
|
-
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
|
|
849
|
-
],
|
|
850
|
-
rotate: [
|
|
851
|
-
`${(0.1 + gapForTrack) * 360}deg`,
|
|
852
|
-
`${(1 + gapForTrack) * 360}deg`,
|
|
853
|
-
`${(1.1 + gapForTrack) * 360}deg`
|
|
854
|
-
]
|
|
855
|
-
},
|
|
856
|
-
transition: {
|
|
857
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
858
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
859
|
-
ease: [0.4, 0, 0.2, 1]
|
|
860
|
-
}
|
|
1006
|
+
strokeLinecap: "round"
|
|
861
1007
|
}
|
|
862
1008
|
),
|
|
863
|
-
|
|
864
|
-
|
|
1009
|
+
/* @__PURE__ */ jsx(
|
|
1010
|
+
"path",
|
|
865
1011
|
{
|
|
1012
|
+
ref: indeterminateWavyActivePathRef,
|
|
866
1013
|
d: wavyActivePath != null ? wavyActivePath : "",
|
|
867
1014
|
fill: "none",
|
|
868
1015
|
stroke: activeColor,
|
|
869
1016
|
strokeWidth: trackHeight,
|
|
870
|
-
strokeLinecap: "round"
|
|
871
|
-
style: { originX: "50%", originY: "50%" },
|
|
872
|
-
animate: {
|
|
873
|
-
pathLength: [0.1, 0.75, 0.1],
|
|
874
|
-
rotate: ["0deg", "90deg", "360deg"]
|
|
875
|
-
},
|
|
876
|
-
transition: {
|
|
877
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
878
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
879
|
-
ease: [0.4, 0, 0.2, 1]
|
|
880
|
-
}
|
|
1017
|
+
strokeLinecap: "round"
|
|
881
1018
|
}
|
|
882
|
-
)
|
|
883
|
-
|
|
1019
|
+
)
|
|
1020
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1021
|
+
shouldShowIndeterminateTrack && /* @__PURE__ */ jsx(
|
|
1022
|
+
"circle",
|
|
1023
|
+
{
|
|
1024
|
+
ref: indeterminateTrackRef,
|
|
1025
|
+
cx: center,
|
|
1026
|
+
cy: center,
|
|
1027
|
+
r: radius,
|
|
1028
|
+
fill: "none",
|
|
1029
|
+
stroke: bgTrackColor,
|
|
1030
|
+
strokeWidth: trackHeight,
|
|
1031
|
+
strokeLinecap: "round"
|
|
1032
|
+
}
|
|
1033
|
+
),
|
|
1034
|
+
/* @__PURE__ */ jsx(
|
|
1035
|
+
"circle",
|
|
884
1036
|
{
|
|
1037
|
+
ref: indeterminateActiveRef,
|
|
885
1038
|
cx: center,
|
|
886
1039
|
cy: center,
|
|
887
1040
|
r: radius,
|
|
888
1041
|
fill: "none",
|
|
889
1042
|
stroke: activeColor,
|
|
890
1043
|
strokeWidth: trackHeight,
|
|
891
|
-
strokeLinecap: "round"
|
|
892
|
-
style: { originX: "50%", originY: "50%" },
|
|
893
|
-
animate: {
|
|
894
|
-
pathLength: [0.1, 0.75, 0.1],
|
|
895
|
-
rotate: ["0deg", "90deg", "360deg"]
|
|
896
|
-
},
|
|
897
|
-
transition: {
|
|
898
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
899
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
900
|
-
ease: [0.4, 0, 0.2, 1]
|
|
901
|
-
}
|
|
1044
|
+
strokeLinecap: "round"
|
|
902
1045
|
}
|
|
903
1046
|
)
|
|
904
|
-
]
|
|
1047
|
+
] })
|
|
905
1048
|
}
|
|
906
1049
|
)
|
|
907
1050
|
] })
|
|
@@ -911,9 +1054,9 @@ var CircularProgress = React11.forwardRef(
|
|
|
911
1054
|
);
|
|
912
1055
|
CircularProgress.displayName = "CircularProgress";
|
|
913
1056
|
function useContainerWidth() {
|
|
914
|
-
const [width, setWidth] =
|
|
915
|
-
const observerRef =
|
|
916
|
-
const ref =
|
|
1057
|
+
const [width, setWidth] = React4.useState(0);
|
|
1058
|
+
const observerRef = React4.useRef(null);
|
|
1059
|
+
const ref = React4.useCallback((node) => {
|
|
917
1060
|
if (observerRef.current) {
|
|
918
1061
|
observerRef.current.disconnect();
|
|
919
1062
|
observerRef.current = null;
|
|
@@ -927,7 +1070,7 @@ function useContainerWidth() {
|
|
|
927
1070
|
observerRef.current = obs;
|
|
928
1071
|
}
|
|
929
1072
|
}, []);
|
|
930
|
-
|
|
1073
|
+
React4.useEffect(() => {
|
|
931
1074
|
return () => {
|
|
932
1075
|
if (observerRef.current) {
|
|
933
1076
|
observerRef.current.disconnect();
|
|
@@ -937,7 +1080,7 @@ function useContainerWidth() {
|
|
|
937
1080
|
return [ref, width];
|
|
938
1081
|
}
|
|
939
1082
|
function useMergedRef(...refs) {
|
|
940
|
-
return
|
|
1083
|
+
return React4.useCallback(
|
|
941
1084
|
(node) => {
|
|
942
1085
|
for (const ref of refs) {
|
|
943
1086
|
if (typeof ref === "function") {
|
|
@@ -951,7 +1094,7 @@ function useMergedRef(...refs) {
|
|
|
951
1094
|
[refs]
|
|
952
1095
|
);
|
|
953
1096
|
}
|
|
954
|
-
var FlatLinearTrack =
|
|
1097
|
+
var FlatLinearTrack = React4.memo(function FlatLinearTrack2({
|
|
955
1098
|
trackHeight,
|
|
956
1099
|
activeColor,
|
|
957
1100
|
trackColor,
|
|
@@ -1027,7 +1170,7 @@ var FlatLinearTrack = React11.memo(function FlatLinearTrack2({
|
|
|
1027
1170
|
}
|
|
1028
1171
|
);
|
|
1029
1172
|
});
|
|
1030
|
-
var WavyLinearTrack =
|
|
1173
|
+
var WavyLinearTrack = React4.memo(function WavyLinearTrack2({
|
|
1031
1174
|
trackHeight,
|
|
1032
1175
|
svgHeight,
|
|
1033
1176
|
amplitude,
|
|
@@ -1046,13 +1189,13 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
1046
1189
|
}) {
|
|
1047
1190
|
const isDeterminate = typeof value === "number";
|
|
1048
1191
|
const clampedValue = isDeterminate ? Math.max(0, Math.min(100, value)) : 100;
|
|
1049
|
-
const titleId =
|
|
1192
|
+
const titleId = React4.useId();
|
|
1050
1193
|
const [containerRef, width] = useContainerWidth();
|
|
1051
|
-
const activePathRef =
|
|
1052
|
-
const trackPathRef =
|
|
1194
|
+
const activePathRef = React4.useRef(null);
|
|
1195
|
+
const trackPathRef = React4.useRef(null);
|
|
1053
1196
|
const amplitudeMV = useMotionValue(amplitude);
|
|
1054
1197
|
const fractionMV = useMotionValue(isDeterminate ? clampedValue / 100 : 1);
|
|
1055
|
-
|
|
1198
|
+
React4.useEffect(() => {
|
|
1056
1199
|
if (isDeterminate) {
|
|
1057
1200
|
const fraction = clampedValue / 100;
|
|
1058
1201
|
let targetAmp = amplitude;
|
|
@@ -1065,6 +1208,12 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
1065
1208
|
duration: 0.5
|
|
1066
1209
|
});
|
|
1067
1210
|
animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
|
|
1211
|
+
} else {
|
|
1212
|
+
animate(amplitudeMV, amplitude, {
|
|
1213
|
+
type: "spring",
|
|
1214
|
+
bounce: 0,
|
|
1215
|
+
duration: 0.5
|
|
1216
|
+
});
|
|
1068
1217
|
}
|
|
1069
1218
|
}, [
|
|
1070
1219
|
clampedValue,
|
|
@@ -1078,10 +1227,10 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
1078
1227
|
1,
|
|
1079
1228
|
isDeterminate ? wavelength : indeterminateWavelength
|
|
1080
1229
|
);
|
|
1081
|
-
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
1082
1230
|
useAnimationFrame((time) => {
|
|
1083
1231
|
if (width === 0) return;
|
|
1084
1232
|
const currentAmp = amplitudeMV.get();
|
|
1233
|
+
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
1085
1234
|
const phase = time / 1e3 * waveSpeed * activeWavelength;
|
|
1086
1235
|
const capWidth = trackHeight / 2;
|
|
1087
1236
|
let activePathD = "";
|
|
@@ -1101,7 +1250,7 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
1101
1250
|
currentAmp
|
|
1102
1251
|
);
|
|
1103
1252
|
} else if (fraction === 0) {
|
|
1104
|
-
activePathD =
|
|
1253
|
+
activePathD = "";
|
|
1105
1254
|
}
|
|
1106
1255
|
const trackStart = adjHead + totalGap;
|
|
1107
1256
|
if (trackStart < width - capWidth) {
|
|
@@ -1133,20 +1282,20 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
1133
1282
|
activeLines.push({ tail: l1T, head: l1H });
|
|
1134
1283
|
activeLines.push({ tail: l2T, head: l2H });
|
|
1135
1284
|
}
|
|
1136
|
-
const
|
|
1137
|
-
const
|
|
1138
|
-
const
|
|
1285
|
+
const activeSegments = activeLines.map((line) => {
|
|
1286
|
+
const rawTail = line.tail * width;
|
|
1287
|
+
const rawHead = line.head * width;
|
|
1139
1288
|
const adjTail = Math.max(
|
|
1140
1289
|
capWidth,
|
|
1141
|
-
Math.min(width - capWidth,
|
|
1290
|
+
Math.min(width - capWidth, rawTail)
|
|
1142
1291
|
);
|
|
1143
1292
|
const adjHead = Math.max(
|
|
1144
1293
|
capWidth,
|
|
1145
|
-
Math.min(width - capWidth,
|
|
1294
|
+
Math.min(width - capWidth, rawHead)
|
|
1146
1295
|
);
|
|
1147
1296
|
return { adjTail, adjHead };
|
|
1148
1297
|
}).filter((seg) => seg.adjHead - seg.adjTail > 0.1);
|
|
1149
|
-
activePathD =
|
|
1298
|
+
activePathD = activeSegments.map(
|
|
1150
1299
|
(seg) => getSinePath(
|
|
1151
1300
|
seg.adjTail,
|
|
1152
1301
|
seg.adjHead,
|
|
@@ -1155,13 +1304,24 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
1155
1304
|
currentAmp
|
|
1156
1305
|
)
|
|
1157
1306
|
).join(" ");
|
|
1307
|
+
const validActiveLines = activeLines.filter(
|
|
1308
|
+
(line) => line.head > line.tail && line.head * width > 0 && line.tail * width < width
|
|
1309
|
+
).sort((a, b) => a.tail - b.tail);
|
|
1158
1310
|
let currentTrackX = capWidth;
|
|
1159
|
-
for (const
|
|
1160
|
-
const
|
|
1311
|
+
for (const line of validActiveLines) {
|
|
1312
|
+
const blockStart = line.tail * width - totalGap;
|
|
1313
|
+
const blockEnd = line.head * width + totalGap;
|
|
1314
|
+
const trackEnd = Math.min(width - capWidth, blockStart);
|
|
1161
1315
|
if (trackEnd > currentTrackX) {
|
|
1162
|
-
trackD += `${getSinePath(
|
|
1316
|
+
trackD += `${getSinePath(
|
|
1317
|
+
currentTrackX,
|
|
1318
|
+
trackEnd,
|
|
1319
|
+
phase,
|
|
1320
|
+
activeWavelength,
|
|
1321
|
+
trackAmp
|
|
1322
|
+
)} `;
|
|
1163
1323
|
}
|
|
1164
|
-
currentTrackX = Math.max(currentTrackX,
|
|
1324
|
+
currentTrackX = Math.max(currentTrackX, blockEnd);
|
|
1165
1325
|
}
|
|
1166
1326
|
if (currentTrackX < width - capWidth) {
|
|
1167
1327
|
trackD += getSinePath(
|
|
@@ -1174,15 +1334,15 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
1174
1334
|
}
|
|
1175
1335
|
}
|
|
1176
1336
|
if (activePathRef.current)
|
|
1177
|
-
activePathRef.current.setAttribute("d", activePathD);
|
|
1337
|
+
activePathRef.current.setAttribute("d", activePathD || "");
|
|
1178
1338
|
if (trackPathRef.current)
|
|
1179
|
-
trackPathRef.current.setAttribute("d", trackD.trim());
|
|
1339
|
+
trackPathRef.current.setAttribute("d", trackD.trim() || "");
|
|
1180
1340
|
});
|
|
1181
1341
|
return /* @__PURE__ */ jsx(
|
|
1182
1342
|
"div",
|
|
1183
1343
|
{
|
|
1184
1344
|
ref: containerRef,
|
|
1185
|
-
className: "relative w-full
|
|
1345
|
+
className: "relative w-full",
|
|
1186
1346
|
style: { height: svgHeight },
|
|
1187
1347
|
children: width > 0 && /* @__PURE__ */ jsxs(
|
|
1188
1348
|
"svg",
|
|
@@ -1223,7 +1383,7 @@ var WavyLinearTrack = React11.memo(function WavyLinearTrack2({
|
|
|
1223
1383
|
}
|
|
1224
1384
|
);
|
|
1225
1385
|
});
|
|
1226
|
-
var LinearProgress =
|
|
1386
|
+
var LinearProgress = React4.forwardRef(
|
|
1227
1387
|
(_a, ref) => {
|
|
1228
1388
|
var _b = _a, {
|
|
1229
1389
|
value,
|
|
@@ -1236,7 +1396,7 @@ var LinearProgress = React11.forwardRef(
|
|
|
1236
1396
|
waveSpeed = 1,
|
|
1237
1397
|
crawlerSpeed = 1,
|
|
1238
1398
|
determinateAnimation = "md3",
|
|
1239
|
-
indeterminateAnimation = "
|
|
1399
|
+
indeterminateAnimation = "md3",
|
|
1240
1400
|
gapSize = 4,
|
|
1241
1401
|
showStopIndicator = "auto",
|
|
1242
1402
|
color,
|
|
@@ -1264,33 +1424,35 @@ var LinearProgress = React11.forwardRef(
|
|
|
1264
1424
|
]);
|
|
1265
1425
|
const isDeterminate = value !== void 0;
|
|
1266
1426
|
const clampedValue = isDeterminate ? Math.min(100, Math.max(0, value)) : 0;
|
|
1267
|
-
const containerRef =
|
|
1427
|
+
const containerRef = React4.useRef(null);
|
|
1268
1428
|
const mergedRef = useMergedRef(ref, containerRef);
|
|
1269
|
-
const [isRtl, setIsRtl] =
|
|
1270
|
-
|
|
1429
|
+
const [isRtl, setIsRtl] = React4.useState(false);
|
|
1430
|
+
React4.useEffect(() => {
|
|
1271
1431
|
if (containerRef.current) {
|
|
1272
1432
|
const dir = getComputedStyle(containerRef.current).direction;
|
|
1273
1433
|
setIsRtl(dir === "rtl");
|
|
1274
1434
|
}
|
|
1275
1435
|
}, []);
|
|
1276
|
-
const isWavy = shape === "wavy";
|
|
1277
1436
|
const resolvedTrackShape = trackShape != null ? trackShape : shape;
|
|
1278
|
-
const
|
|
1279
|
-
const
|
|
1437
|
+
const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
|
|
1438
|
+
const effectiveAmplitude = React4.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
|
|
1439
|
+
const svgHeight = React4.useMemo(
|
|
1280
1440
|
() => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
|
|
1281
1441
|
[isWavy, trackHeight, effectiveAmplitude]
|
|
1282
1442
|
);
|
|
1283
|
-
const shouldShowStop =
|
|
1284
|
-
() => isDeterminate && resolvedTrackShape === "flat" &&
|
|
1443
|
+
const shouldShowStop = React4.useMemo(
|
|
1444
|
+
() => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
|
|
1285
1445
|
[isDeterminate, resolvedTrackShape, showStopIndicator]
|
|
1286
1446
|
);
|
|
1287
|
-
const stopSize =
|
|
1447
|
+
const stopSize = React4.useMemo(
|
|
1288
1448
|
() => Math.max(2, trackHeight > 4 ? 4 : trackHeight / 2),
|
|
1289
1449
|
[trackHeight]
|
|
1290
1450
|
);
|
|
1291
1451
|
const stopOffset = (trackHeight - stopSize) / 2;
|
|
1292
1452
|
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
1293
1453
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
1454
|
+
const useWavyTrack = isWavy || !isDeterminate;
|
|
1455
|
+
const trackAmp = isWavy ? effectiveAmplitude : 0;
|
|
1294
1456
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
|
|
1295
1457
|
"div",
|
|
1296
1458
|
__spreadProps(__spreadValues({
|
|
@@ -1307,12 +1469,12 @@ var LinearProgress = React11.forwardRef(
|
|
|
1307
1469
|
style: { height: svgHeight }
|
|
1308
1470
|
}, restProps), {
|
|
1309
1471
|
children: [
|
|
1310
|
-
|
|
1472
|
+
useWavyTrack ? /* @__PURE__ */ jsx(
|
|
1311
1473
|
WavyLinearTrack,
|
|
1312
1474
|
{
|
|
1313
1475
|
trackHeight,
|
|
1314
1476
|
svgHeight,
|
|
1315
|
-
amplitude:
|
|
1477
|
+
amplitude: trackAmp,
|
|
1316
1478
|
wavelength,
|
|
1317
1479
|
indeterminateWavelength,
|
|
1318
1480
|
activeColor,
|
|
@@ -1357,7 +1519,7 @@ var LinearProgress = React11.forwardRef(
|
|
|
1357
1519
|
}
|
|
1358
1520
|
);
|
|
1359
1521
|
LinearProgress.displayName = "LinearProgress";
|
|
1360
|
-
var ProgressIndicator =
|
|
1522
|
+
var ProgressIndicator = React4.forwardRef((props, ref) => {
|
|
1361
1523
|
if (props.variant === "circular") {
|
|
1362
1524
|
return /* @__PURE__ */ jsx(CircularProgress, __spreadValues({ ref }, props));
|
|
1363
1525
|
}
|
|
@@ -1498,7 +1660,7 @@ function resolveDisabledBgClass(colorStyle) {
|
|
|
1498
1660
|
}
|
|
1499
1661
|
return "disabled:text-m3-on-surface/[0.38]";
|
|
1500
1662
|
}
|
|
1501
|
-
var IconButtonComponent =
|
|
1663
|
+
var IconButtonComponent = React4.forwardRef(
|
|
1502
1664
|
(_a, ref) => {
|
|
1503
1665
|
var _b = _a, {
|
|
1504
1666
|
className,
|
|
@@ -1540,18 +1702,18 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
1540
1702
|
var _a2, _b2, _c, _d, _e;
|
|
1541
1703
|
const isToggle = variant === "toggle";
|
|
1542
1704
|
const isSelected = isToggle && !!selected;
|
|
1543
|
-
const resolvedColorClass =
|
|
1705
|
+
const resolvedColorClass = React4.useMemo(
|
|
1544
1706
|
() => isSelected ? colorStyles[colorStyle].selected : colorStyles[colorStyle].default,
|
|
1545
1707
|
[isSelected, colorStyle]
|
|
1546
1708
|
);
|
|
1547
|
-
const outlineWidthClass =
|
|
1709
|
+
const outlineWidthClass = React4.useMemo(
|
|
1548
1710
|
() => {
|
|
1549
1711
|
var _a3;
|
|
1550
1712
|
return colorStyle === "outlined" && !isSelected ? (_a3 = SIZE_OUTLINE_WIDTH[size]) != null ? _a3 : "border" : "";
|
|
1551
1713
|
},
|
|
1552
1714
|
[colorStyle, isSelected, size]
|
|
1553
1715
|
);
|
|
1554
|
-
const disabledBgClass =
|
|
1716
|
+
const disabledBgClass = React4.useMemo(
|
|
1555
1717
|
() => resolveDisabledBgClass(colorStyle),
|
|
1556
1718
|
[colorStyle]
|
|
1557
1719
|
);
|
|
@@ -1574,7 +1736,7 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
1574
1736
|
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
1575
1737
|
disabled: loading
|
|
1576
1738
|
});
|
|
1577
|
-
const handleClick =
|
|
1739
|
+
const handleClick = React4.useCallback(
|
|
1578
1740
|
(e) => {
|
|
1579
1741
|
if (loading) {
|
|
1580
1742
|
e.preventDefault();
|
|
@@ -1584,7 +1746,7 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
1584
1746
|
},
|
|
1585
1747
|
[loading, onClick]
|
|
1586
1748
|
);
|
|
1587
|
-
const handleKeyDown =
|
|
1749
|
+
const handleKeyDown = React4.useCallback(
|
|
1588
1750
|
(e) => {
|
|
1589
1751
|
if (loading) return;
|
|
1590
1752
|
if ((e.key === "Enter" || e.key === " ") && onClick) {
|
|
@@ -1640,7 +1802,7 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
1640
1802
|
width: isCustomSize ? `${iconSize}px` : void 0,
|
|
1641
1803
|
height: isCustomSize ? `${iconSize}px` : void 0
|
|
1642
1804
|
},
|
|
1643
|
-
children: isSelected && selectedIcon ? selectedIcon : asChild ?
|
|
1805
|
+
children: isSelected && selectedIcon ? selectedIcon : asChild ? React4.Children.only(children).props.children : children
|
|
1644
1806
|
}),
|
|
1645
1807
|
isSelected && selectedIcon ? "selected-content" : "content"
|
|
1646
1808
|
) })
|
|
@@ -1657,7 +1819,7 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
1657
1819
|
className
|
|
1658
1820
|
);
|
|
1659
1821
|
if (asChild) {
|
|
1660
|
-
const child =
|
|
1822
|
+
const child = React4.Children.only(children);
|
|
1661
1823
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
1662
1824
|
Slot,
|
|
1663
1825
|
__spreadProps(__spreadValues({
|
|
@@ -1674,7 +1836,7 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
1674
1836
|
}),
|
|
1675
1837
|
className: containerClassName
|
|
1676
1838
|
}, restProps), {
|
|
1677
|
-
children:
|
|
1839
|
+
children: React4.cloneElement(child, { children: innerContent })
|
|
1678
1840
|
})
|
|
1679
1841
|
) });
|
|
1680
1842
|
}
|
|
@@ -1702,7 +1864,7 @@ var IconButtonComponent = React11.forwardRef(
|
|
|
1702
1864
|
}
|
|
1703
1865
|
);
|
|
1704
1866
|
IconButtonComponent.displayName = "IconButton";
|
|
1705
|
-
var IconButton =
|
|
1867
|
+
var IconButton = React4.memo(IconButtonComponent);
|
|
1706
1868
|
var DURATION_MAP = {
|
|
1707
1869
|
short: 4e3,
|
|
1708
1870
|
long: 7e3
|
|
@@ -1744,9 +1906,9 @@ function toSnackbarData(item) {
|
|
|
1744
1906
|
return { id: generateId(), visuals: item.visuals, resolve: item.resolve };
|
|
1745
1907
|
}
|
|
1746
1908
|
function useSnackbarState() {
|
|
1747
|
-
const [current, setCurrent] =
|
|
1748
|
-
const queueRef =
|
|
1749
|
-
const showSnackbar =
|
|
1909
|
+
const [current, setCurrent] = React4.useState(null);
|
|
1910
|
+
const queueRef = React4.useRef([]);
|
|
1911
|
+
const showSnackbar = React4.useCallback(
|
|
1750
1912
|
(visuals) => {
|
|
1751
1913
|
return new Promise((resolve) => {
|
|
1752
1914
|
const item = { visuals, resolve };
|
|
@@ -1759,14 +1921,14 @@ function useSnackbarState() {
|
|
|
1759
1921
|
},
|
|
1760
1922
|
[]
|
|
1761
1923
|
);
|
|
1762
|
-
const _dismiss =
|
|
1924
|
+
const _dismiss = React4.useCallback((result) => {
|
|
1763
1925
|
setCurrent((prev) => {
|
|
1764
1926
|
if (prev) prev.resolve(result);
|
|
1765
1927
|
const next = queueRef.current.shift();
|
|
1766
1928
|
return next ? toSnackbarData(next) : null;
|
|
1767
1929
|
});
|
|
1768
1930
|
}, []);
|
|
1769
|
-
|
|
1931
|
+
React4.useEffect(() => {
|
|
1770
1932
|
return () => {
|
|
1771
1933
|
for (const item of queueRef.current) {
|
|
1772
1934
|
item.resolve(RESULT.DISMISSED);
|
|
@@ -1776,7 +1938,7 @@ function useSnackbarState() {
|
|
|
1776
1938
|
}, []);
|
|
1777
1939
|
return { current, showSnackbar, _dismiss };
|
|
1778
1940
|
}
|
|
1779
|
-
var Snackbar =
|
|
1941
|
+
var Snackbar = React4.memo(function Snackbar2({
|
|
1780
1942
|
data,
|
|
1781
1943
|
className
|
|
1782
1944
|
}) {
|
|
@@ -1790,15 +1952,15 @@ var Snackbar = React11.memo(function Snackbar2({
|
|
|
1790
1952
|
} = visuals;
|
|
1791
1953
|
const reducedMotion = useReducedMotion();
|
|
1792
1954
|
const durationMs = resolveDuration(duration);
|
|
1793
|
-
|
|
1955
|
+
React4.useEffect(() => {
|
|
1794
1956
|
const timer = setTimeout(() => resolve(RESULT.DISMISSED), durationMs);
|
|
1795
1957
|
return () => clearTimeout(timer);
|
|
1796
1958
|
}, [resolve, durationMs]);
|
|
1797
|
-
const handleAction =
|
|
1959
|
+
const handleAction = React4.useCallback(
|
|
1798
1960
|
() => resolve(RESULT.ACTION),
|
|
1799
1961
|
[resolve]
|
|
1800
1962
|
);
|
|
1801
|
-
const handleDismiss =
|
|
1963
|
+
const handleDismiss = React4.useCallback(
|
|
1802
1964
|
() => resolve(RESULT.DISMISSED),
|
|
1803
1965
|
[resolve]
|
|
1804
1966
|
);
|
|
@@ -1866,7 +2028,7 @@ var Snackbar = React11.memo(function Snackbar2({
|
|
|
1866
2028
|
Snackbar.displayName = "Snackbar";
|
|
1867
2029
|
function SnackbarHost({ state, className }) {
|
|
1868
2030
|
const { current, _dismiss } = state;
|
|
1869
|
-
const wrappedData =
|
|
2031
|
+
const wrappedData = React4.useMemo(() => {
|
|
1870
2032
|
if (!current) return null;
|
|
1871
2033
|
return __spreadProps(__spreadValues({}, current), { resolve: _dismiss });
|
|
1872
2034
|
}, [current, _dismiss]);
|
|
@@ -1884,7 +2046,7 @@ function SnackbarHost({ state, className }) {
|
|
|
1884
2046
|
) });
|
|
1885
2047
|
}
|
|
1886
2048
|
SnackbarHost.displayName = "SnackbarHost";
|
|
1887
|
-
var SnackbarContext =
|
|
2049
|
+
var SnackbarContext = React4.createContext(
|
|
1888
2050
|
null
|
|
1889
2051
|
);
|
|
1890
2052
|
|