@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/layout.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Slot } from '@radix-ui/react-slot';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
|
-
import { m, LazyMotion, domMax, useMotionValue, animate,
|
|
4
|
+
import { m, LazyMotion, domMax, useAnimationFrame, useMotionValue, animate, AnimatePresence, useReducedMotion } from 'motion/react';
|
|
5
5
|
import * as React18 from 'react';
|
|
6
6
|
import { createContext, useState, useCallback, useMemo, useEffect, useContext, createElement } from 'react';
|
|
7
7
|
import { clsx } from 'clsx';
|
|
@@ -515,26 +515,46 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
|
515
515
|
if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
|
|
516
516
|
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
|
|
517
517
|
}
|
|
518
|
-
d
|
|
519
|
-
return d;
|
|
518
|
+
return `${d} Z`;
|
|
520
519
|
}
|
|
521
520
|
function getSinePath(startX, endX, phase, wl, amp) {
|
|
522
521
|
if (startX >= endX) return "";
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
522
|
+
if (amp <= 0.01) {
|
|
523
|
+
return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
|
|
524
|
+
}
|
|
525
|
+
const safeWl = Math.max(1, wl);
|
|
526
|
+
const k = 2 * Math.PI / safeWl;
|
|
527
|
+
const phi = phase / safeWl * 2 * Math.PI;
|
|
528
|
+
const yAt = (x) => amp * Math.sin(k * x + phi);
|
|
529
|
+
const dyAt = (x) => amp * k * Math.cos(k * x + phi);
|
|
530
|
+
const step = safeWl / 4;
|
|
531
|
+
let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
|
|
532
|
+
let currentX = startX;
|
|
533
|
+
while (currentX < endX) {
|
|
534
|
+
const nextX = Math.min(endX, currentX + step);
|
|
535
|
+
const dx = nextX - currentX;
|
|
536
|
+
const scale = dx / 3;
|
|
537
|
+
const y0 = yAt(currentX);
|
|
538
|
+
const dy0 = dyAt(currentX);
|
|
539
|
+
const y1 = yAt(nextX);
|
|
540
|
+
const dy1 = dyAt(nextX);
|
|
541
|
+
const cp1x = currentX + scale;
|
|
542
|
+
const cp1y = y0 + scale * dy0;
|
|
543
|
+
const cp2x = nextX - scale;
|
|
544
|
+
const cp2y = y1 - scale * dy1;
|
|
545
|
+
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
|
|
546
|
+
currentX = nextX;
|
|
547
|
+
}
|
|
536
548
|
return d;
|
|
537
549
|
}
|
|
550
|
+
var GLOBAL_ROTATION_DURATION = 6e3;
|
|
551
|
+
var GLOBAL_ROTATION_TARGET = 1080;
|
|
552
|
+
var ADDITIONAL_ROTATION_CYCLE = 1500;
|
|
553
|
+
var ADDITIONAL_ROTATION_STEP = 90;
|
|
554
|
+
var ADDITIONAL_ROTATION_EASE_DURATION = 500;
|
|
555
|
+
var DEFAULT_MIN_PROGRESS = 0.1;
|
|
556
|
+
var DEFAULT_MAX_PROGRESS = 0.8;
|
|
557
|
+
var PROGRESS_CYCLE_DURATION = 1500;
|
|
538
558
|
var CircularProgress = React18.forwardRef(
|
|
539
559
|
(_a, ref) => {
|
|
540
560
|
var _b = _a, {
|
|
@@ -548,6 +568,10 @@ var CircularProgress = React18.forwardRef(
|
|
|
548
568
|
crawlerSpeed = 1,
|
|
549
569
|
color,
|
|
550
570
|
trackColor,
|
|
571
|
+
showTrack = "auto",
|
|
572
|
+
minProgress = DEFAULT_MIN_PROGRESS,
|
|
573
|
+
maxProgress = DEFAULT_MAX_PROGRESS,
|
|
574
|
+
amplitudeRange,
|
|
551
575
|
className,
|
|
552
576
|
"aria-label": ariaLabel
|
|
553
577
|
} = _b, restProps = __objRest(_b, [
|
|
@@ -561,6 +585,10 @@ var CircularProgress = React18.forwardRef(
|
|
|
561
585
|
"crawlerSpeed",
|
|
562
586
|
"color",
|
|
563
587
|
"trackColor",
|
|
588
|
+
"showTrack",
|
|
589
|
+
"minProgress",
|
|
590
|
+
"maxProgress",
|
|
591
|
+
"amplitudeRange",
|
|
564
592
|
"className",
|
|
565
593
|
"aria-label"
|
|
566
594
|
]);
|
|
@@ -571,6 +599,7 @@ var CircularProgress = React18.forwardRef(
|
|
|
571
599
|
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
572
600
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
573
601
|
const isWavy = shape === "wavy";
|
|
602
|
+
const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
|
|
574
603
|
const BASELINE_SIZE = 48;
|
|
575
604
|
const scaleFactor = size / BASELINE_SIZE;
|
|
576
605
|
const effectiveAmplitude = React18.useMemo(
|
|
@@ -581,6 +610,10 @@ var CircularProgress = React18.forwardRef(
|
|
|
581
610
|
() => wavelength != null ? wavelength : 15 * scaleFactor,
|
|
582
611
|
[wavelength, scaleFactor]
|
|
583
612
|
);
|
|
613
|
+
const resolvedAmplitudeRange = React18.useMemo(
|
|
614
|
+
() => amplitudeRange != null ? amplitudeRange : [0, effectiveAmplitude],
|
|
615
|
+
[amplitudeRange, effectiveAmplitude]
|
|
616
|
+
);
|
|
584
617
|
const wavyActivePath = React18.useMemo(
|
|
585
618
|
() => isWavy ? generateWavyCircularPath(
|
|
586
619
|
center,
|
|
@@ -600,6 +633,145 @@ var CircularProgress = React18.forwardRef(
|
|
|
600
633
|
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
601
634
|
const ActiveCircleElem = m.circle;
|
|
602
635
|
const ActivePathElem = m.path;
|
|
636
|
+
const indeterminateSvgRef = React18.useRef(null);
|
|
637
|
+
const indeterminateTrackRef = React18.useRef(null);
|
|
638
|
+
const indeterminateActiveRef = React18.useRef(null);
|
|
639
|
+
const indeterminateWavyTrackPathRef = React18.useRef(null);
|
|
640
|
+
const indeterminateWavyActivePathRef = React18.useRef(null);
|
|
641
|
+
const cachedPathLengthRef = React18.useRef(0);
|
|
642
|
+
React18.useLayoutEffect(() => {
|
|
643
|
+
if (!isWavy || !wavyActivePath) {
|
|
644
|
+
cachedPathLengthRef.current = circumference;
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
const el = indeterminateActiveRef.current;
|
|
648
|
+
if (el && "getTotalLength" in el) {
|
|
649
|
+
try {
|
|
650
|
+
const len = el.getTotalLength();
|
|
651
|
+
if (len > 0) {
|
|
652
|
+
cachedPathLengthRef.current = len;
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
} catch (e) {
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
cachedPathLengthRef.current = circumference;
|
|
659
|
+
}, [isWavy, circumference, wavyActivePath]);
|
|
660
|
+
useAnimationFrame((time) => {
|
|
661
|
+
if (isDeterminate) return;
|
|
662
|
+
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
663
|
+
const scaledTime = time * safeCrawlerSpeed;
|
|
664
|
+
const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
|
|
665
|
+
const globalAngle = globalCycle / GLOBAL_ROTATION_DURATION * GLOBAL_ROTATION_TARGET;
|
|
666
|
+
const additionalFullCycles = Math.floor(
|
|
667
|
+
scaledTime / ADDITIONAL_ROTATION_CYCLE
|
|
668
|
+
);
|
|
669
|
+
const additionalCycleTime = scaledTime % ADDITIONAL_ROTATION_CYCLE;
|
|
670
|
+
const additionalEaseT = Math.min(
|
|
671
|
+
1,
|
|
672
|
+
additionalCycleTime / ADDITIONAL_ROTATION_EASE_DURATION
|
|
673
|
+
);
|
|
674
|
+
const additionalAngle = (additionalFullCycles + easeInOutCubic(additionalEaseT)) * ADDITIONAL_ROTATION_STEP;
|
|
675
|
+
const totalRotation = globalAngle + additionalAngle;
|
|
676
|
+
if (indeterminateSvgRef.current) {
|
|
677
|
+
indeterminateSvgRef.current.style.transform = `rotate(${totalRotation - 90}deg)`;
|
|
678
|
+
}
|
|
679
|
+
const progressFullCycle = PROGRESS_CYCLE_DURATION * 2;
|
|
680
|
+
const progressCycleTime = scaledTime % progressFullCycle;
|
|
681
|
+
let progress;
|
|
682
|
+
if (progressCycleTime < PROGRESS_CYCLE_DURATION) {
|
|
683
|
+
const t = progressCycleTime / PROGRESS_CYCLE_DURATION;
|
|
684
|
+
progress = minProgress + (maxProgress - minProgress) * easeInOutCubic(t);
|
|
685
|
+
} else {
|
|
686
|
+
const t = (progressCycleTime - PROGRESS_CYCLE_DURATION) / PROGRESS_CYCLE_DURATION;
|
|
687
|
+
progress = maxProgress - (maxProgress - minProgress) * easeInOutCubic(t);
|
|
688
|
+
}
|
|
689
|
+
if (isWavy) {
|
|
690
|
+
const amplitudeT = (progress - minProgress) / (maxProgress - minProgress);
|
|
691
|
+
const currentAmplitude = resolvedAmplitudeRange[0] + (resolvedAmplitudeRange[1] - resolvedAmplitudeRange[0]) * amplitudeT;
|
|
692
|
+
const dynamicPath = generateWavyCircularPath(
|
|
693
|
+
center,
|
|
694
|
+
radius,
|
|
695
|
+
currentAmplitude,
|
|
696
|
+
effectiveWavelength
|
|
697
|
+
);
|
|
698
|
+
if (indeterminateWavyActivePathRef.current) {
|
|
699
|
+
indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
700
|
+
}
|
|
701
|
+
if (indeterminateWavyTrackPathRef.current) {
|
|
702
|
+
indeterminateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
|
|
703
|
+
}
|
|
704
|
+
const pathEl = indeterminateWavyActivePathRef.current;
|
|
705
|
+
let totalLen = cachedPathLengthRef.current || circumference;
|
|
706
|
+
if (pathEl) {
|
|
707
|
+
try {
|
|
708
|
+
const len = pathEl.getTotalLength();
|
|
709
|
+
if (len > 0) totalLen = len;
|
|
710
|
+
} catch (e) {
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
714
|
+
const activeLen = totalLen * progress;
|
|
715
|
+
const activeOff = 0;
|
|
716
|
+
if (indeterminateWavyActivePathRef.current) {
|
|
717
|
+
indeterminateWavyActivePathRef.current.setAttribute(
|
|
718
|
+
"stroke-dasharray",
|
|
719
|
+
`${activeLen} ${totalLen}`
|
|
720
|
+
);
|
|
721
|
+
indeterminateWavyActivePathRef.current.setAttribute(
|
|
722
|
+
"stroke-dashoffset",
|
|
723
|
+
`${activeOff}`
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
if (shouldShowIndeterminateTrack && indeterminateWavyTrackPathRef.current) {
|
|
727
|
+
const trackStartFrac = progress + gapFrac;
|
|
728
|
+
const trackLen = Math.max(
|
|
729
|
+
1e-3,
|
|
730
|
+
totalLen * (1 - progress - 2 * gapFrac)
|
|
731
|
+
);
|
|
732
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
733
|
+
indeterminateWavyTrackPathRef.current.setAttribute(
|
|
734
|
+
"stroke-dasharray",
|
|
735
|
+
`${trackLen} ${totalLen}`
|
|
736
|
+
);
|
|
737
|
+
indeterminateWavyTrackPathRef.current.setAttribute(
|
|
738
|
+
"stroke-dashoffset",
|
|
739
|
+
`${trackOff}`
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
} else {
|
|
743
|
+
const totalLen = circumference;
|
|
744
|
+
const activeLen = totalLen * progress;
|
|
745
|
+
const activeOff = 0;
|
|
746
|
+
if (indeterminateActiveRef.current) {
|
|
747
|
+
indeterminateActiveRef.current.setAttribute(
|
|
748
|
+
"stroke-dasharray",
|
|
749
|
+
`${activeLen} ${totalLen}`
|
|
750
|
+
);
|
|
751
|
+
indeterminateActiveRef.current.setAttribute(
|
|
752
|
+
"stroke-dashoffset",
|
|
753
|
+
`${activeOff}`
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
if (shouldShowIndeterminateTrack && indeterminateTrackRef.current) {
|
|
757
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
758
|
+
const trackStartFrac = progress + gapFrac;
|
|
759
|
+
const trackLen = Math.max(
|
|
760
|
+
1e-3,
|
|
761
|
+
totalLen * (1 - progress - 2 * gapFrac)
|
|
762
|
+
);
|
|
763
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
764
|
+
indeterminateTrackRef.current.setAttribute(
|
|
765
|
+
"stroke-dasharray",
|
|
766
|
+
`${trackLen} ${totalLen}`
|
|
767
|
+
);
|
|
768
|
+
indeterminateTrackRef.current.setAttribute(
|
|
769
|
+
"stroke-dashoffset",
|
|
770
|
+
`${trackOff}`
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
});
|
|
603
775
|
return /* @__PURE__ */ jsx(
|
|
604
776
|
"div",
|
|
605
777
|
__spreadProps(__spreadValues({
|
|
@@ -676,9 +848,10 @@ var CircularProgress = React18.forwardRef(
|
|
|
676
848
|
]
|
|
677
849
|
}
|
|
678
850
|
),
|
|
679
|
-
!isDeterminate && /* @__PURE__ */
|
|
680
|
-
|
|
851
|
+
!isDeterminate && /* @__PURE__ */ jsx(
|
|
852
|
+
"svg",
|
|
681
853
|
{
|
|
854
|
+
ref: indeterminateSvgRef,
|
|
682
855
|
width: size,
|
|
683
856
|
height: size,
|
|
684
857
|
viewBox: `0 0 ${size} ${size}`,
|
|
@@ -687,90 +860,60 @@ var CircularProgress = React18.forwardRef(
|
|
|
687
860
|
position: "absolute",
|
|
688
861
|
inset: 0,
|
|
689
862
|
overflow: "visible",
|
|
690
|
-
|
|
691
|
-
|
|
863
|
+
transformOrigin: "center",
|
|
864
|
+
transform: "rotate(-90deg)"
|
|
692
865
|
},
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
697
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
698
|
-
ease: "linear"
|
|
699
|
-
}
|
|
700
|
-
},
|
|
701
|
-
children: [
|
|
702
|
-
/* @__PURE__ */ jsx(
|
|
703
|
-
m.circle,
|
|
866
|
+
children: isWavy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
867
|
+
shouldShowIndeterminateTrack && /* @__PURE__ */ jsx(
|
|
868
|
+
"path",
|
|
704
869
|
{
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
r: radius,
|
|
870
|
+
ref: indeterminateWavyTrackPathRef,
|
|
871
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
708
872
|
fill: "none",
|
|
709
873
|
stroke: bgTrackColor,
|
|
710
874
|
strokeWidth: trackHeight,
|
|
711
|
-
strokeLinecap: "round"
|
|
712
|
-
style: { originX: "50%", originY: "50%" },
|
|
713
|
-
animate: {
|
|
714
|
-
pathLength: [
|
|
715
|
-
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
|
|
716
|
-
Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
|
|
717
|
-
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
|
|
718
|
-
],
|
|
719
|
-
rotate: [
|
|
720
|
-
`${(0.1 + gapForTrack) * 360}deg`,
|
|
721
|
-
`${(1 + gapForTrack) * 360}deg`,
|
|
722
|
-
`${(1.1 + gapForTrack) * 360}deg`
|
|
723
|
-
]
|
|
724
|
-
},
|
|
725
|
-
transition: {
|
|
726
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
727
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
728
|
-
ease: [0.4, 0, 0.2, 1]
|
|
729
|
-
}
|
|
875
|
+
strokeLinecap: "round"
|
|
730
876
|
}
|
|
731
877
|
),
|
|
732
|
-
|
|
733
|
-
|
|
878
|
+
/* @__PURE__ */ jsx(
|
|
879
|
+
"path",
|
|
734
880
|
{
|
|
881
|
+
ref: indeterminateWavyActivePathRef,
|
|
735
882
|
d: wavyActivePath != null ? wavyActivePath : "",
|
|
736
883
|
fill: "none",
|
|
737
884
|
stroke: activeColor,
|
|
738
885
|
strokeWidth: trackHeight,
|
|
739
|
-
strokeLinecap: "round"
|
|
740
|
-
style: { originX: "50%", originY: "50%" },
|
|
741
|
-
animate: {
|
|
742
|
-
pathLength: [0.1, 0.75, 0.1],
|
|
743
|
-
rotate: ["0deg", "90deg", "360deg"]
|
|
744
|
-
},
|
|
745
|
-
transition: {
|
|
746
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
747
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
748
|
-
ease: [0.4, 0, 0.2, 1]
|
|
749
|
-
}
|
|
886
|
+
strokeLinecap: "round"
|
|
750
887
|
}
|
|
751
|
-
)
|
|
752
|
-
|
|
888
|
+
)
|
|
889
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
890
|
+
shouldShowIndeterminateTrack && /* @__PURE__ */ jsx(
|
|
891
|
+
"circle",
|
|
892
|
+
{
|
|
893
|
+
ref: indeterminateTrackRef,
|
|
894
|
+
cx: center,
|
|
895
|
+
cy: center,
|
|
896
|
+
r: radius,
|
|
897
|
+
fill: "none",
|
|
898
|
+
stroke: bgTrackColor,
|
|
899
|
+
strokeWidth: trackHeight,
|
|
900
|
+
strokeLinecap: "round"
|
|
901
|
+
}
|
|
902
|
+
),
|
|
903
|
+
/* @__PURE__ */ jsx(
|
|
904
|
+
"circle",
|
|
753
905
|
{
|
|
906
|
+
ref: indeterminateActiveRef,
|
|
754
907
|
cx: center,
|
|
755
908
|
cy: center,
|
|
756
909
|
r: radius,
|
|
757
910
|
fill: "none",
|
|
758
911
|
stroke: activeColor,
|
|
759
912
|
strokeWidth: trackHeight,
|
|
760
|
-
strokeLinecap: "round"
|
|
761
|
-
style: { originX: "50%", originY: "50%" },
|
|
762
|
-
animate: {
|
|
763
|
-
pathLength: [0.1, 0.75, 0.1],
|
|
764
|
-
rotate: ["0deg", "90deg", "360deg"]
|
|
765
|
-
},
|
|
766
|
-
transition: {
|
|
767
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
768
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
769
|
-
ease: [0.4, 0, 0.2, 1]
|
|
770
|
-
}
|
|
913
|
+
strokeLinecap: "round"
|
|
771
914
|
}
|
|
772
915
|
)
|
|
773
|
-
]
|
|
916
|
+
] })
|
|
774
917
|
}
|
|
775
918
|
)
|
|
776
919
|
] })
|
|
@@ -934,6 +1077,12 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
|
|
|
934
1077
|
duration: 0.5
|
|
935
1078
|
});
|
|
936
1079
|
animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
|
|
1080
|
+
} else {
|
|
1081
|
+
animate(amplitudeMV, amplitude, {
|
|
1082
|
+
type: "spring",
|
|
1083
|
+
bounce: 0,
|
|
1084
|
+
duration: 0.5
|
|
1085
|
+
});
|
|
937
1086
|
}
|
|
938
1087
|
}, [
|
|
939
1088
|
clampedValue,
|
|
@@ -947,10 +1096,10 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
|
|
|
947
1096
|
1,
|
|
948
1097
|
isDeterminate ? wavelength : indeterminateWavelength
|
|
949
1098
|
);
|
|
950
|
-
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
951
1099
|
useAnimationFrame((time) => {
|
|
952
1100
|
if (width === 0) return;
|
|
953
1101
|
const currentAmp = amplitudeMV.get();
|
|
1102
|
+
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
954
1103
|
const phase = time / 1e3 * waveSpeed * activeWavelength;
|
|
955
1104
|
const capWidth = trackHeight / 2;
|
|
956
1105
|
let activePathD = "";
|
|
@@ -970,7 +1119,7 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
|
|
|
970
1119
|
currentAmp
|
|
971
1120
|
);
|
|
972
1121
|
} else if (fraction === 0) {
|
|
973
|
-
activePathD =
|
|
1122
|
+
activePathD = "";
|
|
974
1123
|
}
|
|
975
1124
|
const trackStart = adjHead + totalGap;
|
|
976
1125
|
if (trackStart < width - capWidth) {
|
|
@@ -1002,20 +1151,20 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
|
|
|
1002
1151
|
activeLines.push({ tail: l1T, head: l1H });
|
|
1003
1152
|
activeLines.push({ tail: l2T, head: l2H });
|
|
1004
1153
|
}
|
|
1005
|
-
const
|
|
1006
|
-
const
|
|
1007
|
-
const
|
|
1154
|
+
const activeSegments = activeLines.map((line) => {
|
|
1155
|
+
const rawTail = line.tail * width;
|
|
1156
|
+
const rawHead = line.head * width;
|
|
1008
1157
|
const adjTail = Math.max(
|
|
1009
1158
|
capWidth,
|
|
1010
|
-
Math.min(width - capWidth,
|
|
1159
|
+
Math.min(width - capWidth, rawTail)
|
|
1011
1160
|
);
|
|
1012
1161
|
const adjHead = Math.max(
|
|
1013
1162
|
capWidth,
|
|
1014
|
-
Math.min(width - capWidth,
|
|
1163
|
+
Math.min(width - capWidth, rawHead)
|
|
1015
1164
|
);
|
|
1016
1165
|
return { adjTail, adjHead };
|
|
1017
1166
|
}).filter((seg) => seg.adjHead - seg.adjTail > 0.1);
|
|
1018
|
-
activePathD =
|
|
1167
|
+
activePathD = activeSegments.map(
|
|
1019
1168
|
(seg) => getSinePath(
|
|
1020
1169
|
seg.adjTail,
|
|
1021
1170
|
seg.adjHead,
|
|
@@ -1024,13 +1173,24 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
|
|
|
1024
1173
|
currentAmp
|
|
1025
1174
|
)
|
|
1026
1175
|
).join(" ");
|
|
1176
|
+
const validActiveLines = activeLines.filter(
|
|
1177
|
+
(line) => line.head > line.tail && line.head * width > 0 && line.tail * width < width
|
|
1178
|
+
).sort((a, b) => a.tail - b.tail);
|
|
1027
1179
|
let currentTrackX = capWidth;
|
|
1028
|
-
for (const
|
|
1029
|
-
const
|
|
1180
|
+
for (const line of validActiveLines) {
|
|
1181
|
+
const blockStart = line.tail * width - totalGap;
|
|
1182
|
+
const blockEnd = line.head * width + totalGap;
|
|
1183
|
+
const trackEnd = Math.min(width - capWidth, blockStart);
|
|
1030
1184
|
if (trackEnd > currentTrackX) {
|
|
1031
|
-
trackD += `${getSinePath(
|
|
1185
|
+
trackD += `${getSinePath(
|
|
1186
|
+
currentTrackX,
|
|
1187
|
+
trackEnd,
|
|
1188
|
+
phase,
|
|
1189
|
+
activeWavelength,
|
|
1190
|
+
trackAmp
|
|
1191
|
+
)} `;
|
|
1032
1192
|
}
|
|
1033
|
-
currentTrackX = Math.max(currentTrackX,
|
|
1193
|
+
currentTrackX = Math.max(currentTrackX, blockEnd);
|
|
1034
1194
|
}
|
|
1035
1195
|
if (currentTrackX < width - capWidth) {
|
|
1036
1196
|
trackD += getSinePath(
|
|
@@ -1043,15 +1203,15 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
|
|
|
1043
1203
|
}
|
|
1044
1204
|
}
|
|
1045
1205
|
if (activePathRef.current)
|
|
1046
|
-
activePathRef.current.setAttribute("d", activePathD);
|
|
1206
|
+
activePathRef.current.setAttribute("d", activePathD || "");
|
|
1047
1207
|
if (trackPathRef.current)
|
|
1048
|
-
trackPathRef.current.setAttribute("d", trackD.trim());
|
|
1208
|
+
trackPathRef.current.setAttribute("d", trackD.trim() || "");
|
|
1049
1209
|
});
|
|
1050
1210
|
return /* @__PURE__ */ jsx(
|
|
1051
1211
|
"div",
|
|
1052
1212
|
{
|
|
1053
1213
|
ref: containerRef,
|
|
1054
|
-
className: "relative w-full
|
|
1214
|
+
className: "relative w-full",
|
|
1055
1215
|
style: { height: svgHeight },
|
|
1056
1216
|
children: width > 0 && /* @__PURE__ */ jsxs(
|
|
1057
1217
|
"svg",
|
|
@@ -1105,7 +1265,7 @@ var LinearProgress = React18.forwardRef(
|
|
|
1105
1265
|
waveSpeed = 1,
|
|
1106
1266
|
crawlerSpeed = 1,
|
|
1107
1267
|
determinateAnimation = "md3",
|
|
1108
|
-
indeterminateAnimation = "
|
|
1268
|
+
indeterminateAnimation = "md3",
|
|
1109
1269
|
gapSize = 4,
|
|
1110
1270
|
showStopIndicator = "auto",
|
|
1111
1271
|
color,
|
|
@@ -1142,15 +1302,15 @@ var LinearProgress = React18.forwardRef(
|
|
|
1142
1302
|
setIsRtl(dir === "rtl");
|
|
1143
1303
|
}
|
|
1144
1304
|
}, []);
|
|
1145
|
-
const isWavy = shape === "wavy";
|
|
1146
1305
|
const resolvedTrackShape = trackShape != null ? trackShape : shape;
|
|
1306
|
+
const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
|
|
1147
1307
|
const effectiveAmplitude = React18.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
|
|
1148
1308
|
const svgHeight = React18.useMemo(
|
|
1149
1309
|
() => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
|
|
1150
1310
|
[isWavy, trackHeight, effectiveAmplitude]
|
|
1151
1311
|
);
|
|
1152
1312
|
const shouldShowStop = React18.useMemo(
|
|
1153
|
-
() => isDeterminate && resolvedTrackShape === "flat" &&
|
|
1313
|
+
() => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
|
|
1154
1314
|
[isDeterminate, resolvedTrackShape, showStopIndicator]
|
|
1155
1315
|
);
|
|
1156
1316
|
const stopSize = React18.useMemo(
|
|
@@ -1160,6 +1320,8 @@ var LinearProgress = React18.forwardRef(
|
|
|
1160
1320
|
const stopOffset = (trackHeight - stopSize) / 2;
|
|
1161
1321
|
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
1162
1322
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
1323
|
+
const useWavyTrack = isWavy || !isDeterminate;
|
|
1324
|
+
const trackAmp = isWavy ? effectiveAmplitude : 0;
|
|
1163
1325
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
|
|
1164
1326
|
"div",
|
|
1165
1327
|
__spreadProps(__spreadValues({
|
|
@@ -1176,12 +1338,12 @@ var LinearProgress = React18.forwardRef(
|
|
|
1176
1338
|
style: { height: svgHeight }
|
|
1177
1339
|
}, restProps), {
|
|
1178
1340
|
children: [
|
|
1179
|
-
|
|
1341
|
+
useWavyTrack ? /* @__PURE__ */ jsx(
|
|
1180
1342
|
WavyLinearTrack,
|
|
1181
1343
|
{
|
|
1182
1344
|
trackHeight,
|
|
1183
1345
|
svgHeight,
|
|
1184
|
-
amplitude:
|
|
1346
|
+
amplitude: trackAmp,
|
|
1185
1347
|
wavelength,
|
|
1186
1348
|
indeterminateWavelength,
|
|
1187
1349
|
activeColor,
|