@bug-on/m3-expressive 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/buttons.d.mts +1 -1
- package/dist/buttons.d.ts +1 -1
- package/dist/buttons.js +185 -40
- package/dist/buttons.js.map +1 -1
- package/dist/buttons.mjs +186 -41
- package/dist/buttons.mjs.map +1 -1
- package/dist/core.js +156 -25
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +157 -26
- package/dist/core.mjs.map +1 -1
- package/dist/feedback.d.mts +20 -0
- package/dist/feedback.d.ts +20 -0
- package/dist/feedback.js +156 -25
- package/dist/feedback.js.map +1 -1
- package/dist/feedback.mjs +157 -26
- package/dist/feedback.mjs.map +1 -1
- package/dist/forms.d.mts +3 -2
- package/dist/forms.d.ts +3 -2
- package/dist/forms.js +88 -100
- package/dist/forms.js.map +1 -1
- package/dist/forms.mjs +88 -100
- package/dist/forms.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +279 -146
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +280 -147
- package/dist/index.mjs.map +1 -1
- package/dist/layout.js +158 -27
- package/dist/layout.js.map +1 -1
- package/dist/layout.mjs +159 -28
- package/dist/layout.mjs.map +1 -1
- package/dist/navigation.js +156 -25
- package/dist/navigation.js.map +1 -1
- package/dist/navigation.mjs +157 -26
- package/dist/navigation.mjs.map +1 -1
- package/dist/overlays.js +156 -25
- package/dist/overlays.js.map +1 -1
- package/dist/overlays.mjs +157 -26
- package/dist/overlays.mjs.map +1 -1
- package/dist/pickers.js +156 -25
- package/dist/pickers.js.map +1 -1
- package/dist/pickers.mjs +157 -26
- package/dist/pickers.mjs.map +1 -1
- package/dist/{split-button-trailing-uncheckable-26qlZvKT.d.mts → split-button-trailing-uncheckable-CIVEYgjY.d.mts} +2 -0
- package/dist/{split-button-trailing-uncheckable-CXUVrH64.d.ts → split-button-trailing-uncheckable-DTQJjzsB.d.ts} +2 -0
- package/dist/{text-field-DWC7qOvp.d.mts → text-field-CiOmDM_8.d.ts} +52 -51
- package/dist/{text-field-DWC7qOvp.d.ts → text-field-Ear3hCSq.d.mts} +52 -51
- package/package.json +3 -3
package/dist/core.mjs
CHANGED
|
@@ -5,7 +5,7 @@ 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,
|
|
8
|
+
import { LazyMotion, domMax, m, useMotionValue, animate, useAnimationFrame, AnimatePresence, useReducedMotion } from 'motion/react';
|
|
9
9
|
import { Slot } from '@radix-ui/react-slot';
|
|
10
10
|
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -619,7 +619,7 @@ LoadingIndicator.displayName = "LoadingIndicator";
|
|
|
619
619
|
function easeInOutCubic(x) {
|
|
620
620
|
return x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;
|
|
621
621
|
}
|
|
622
|
-
function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
622
|
+
function generateWavyCircularPath(center, radius, amplitude, wavelength, phase = 0) {
|
|
623
623
|
const circumference = 2 * Math.PI * radius;
|
|
624
624
|
const numWaves = Math.max(
|
|
625
625
|
3,
|
|
@@ -627,8 +627,8 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
|
627
627
|
);
|
|
628
628
|
const steps = numWaves * 4;
|
|
629
629
|
const dt = 2 * Math.PI / steps;
|
|
630
|
-
const rAt = (t) => radius + amplitude * Math.sin(numWaves * t);
|
|
631
|
-
const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t);
|
|
630
|
+
const rAt = (t) => radius + amplitude * Math.sin(numWaves * t + phase);
|
|
631
|
+
const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t + phase);
|
|
632
632
|
const xAt = (t) => center + rAt(t) * Math.cos(t);
|
|
633
633
|
const yAt = (t) => center + rAt(t) * Math.sin(t);
|
|
634
634
|
const dxAt = (t) => drAt(t) * Math.cos(t) - rAt(t) * Math.sin(t);
|
|
@@ -693,15 +693,18 @@ var CircularProgress = React4.forwardRef(
|
|
|
693
693
|
size = 48,
|
|
694
694
|
trackHeight = 4,
|
|
695
695
|
shape = "flat",
|
|
696
|
+
trackShape = "flat",
|
|
696
697
|
amplitude,
|
|
697
698
|
wavelength,
|
|
698
699
|
gapSize = 4,
|
|
700
|
+
waveSpeed = 1,
|
|
699
701
|
crawlerSpeed = 1,
|
|
700
702
|
color,
|
|
701
703
|
trackColor,
|
|
702
704
|
showTrack = "auto",
|
|
703
705
|
minProgress = DEFAULT_MIN_PROGRESS,
|
|
704
706
|
maxProgress = DEFAULT_MAX_PROGRESS,
|
|
707
|
+
determinateAnimation = "md3",
|
|
705
708
|
amplitudeRange,
|
|
706
709
|
className,
|
|
707
710
|
"aria-label": ariaLabel
|
|
@@ -710,15 +713,18 @@ var CircularProgress = React4.forwardRef(
|
|
|
710
713
|
"size",
|
|
711
714
|
"trackHeight",
|
|
712
715
|
"shape",
|
|
716
|
+
"trackShape",
|
|
713
717
|
"amplitude",
|
|
714
718
|
"wavelength",
|
|
715
719
|
"gapSize",
|
|
720
|
+
"waveSpeed",
|
|
716
721
|
"crawlerSpeed",
|
|
717
722
|
"color",
|
|
718
723
|
"trackColor",
|
|
719
724
|
"showTrack",
|
|
720
725
|
"minProgress",
|
|
721
726
|
"maxProgress",
|
|
727
|
+
"determinateAnimation",
|
|
722
728
|
"amplitudeRange",
|
|
723
729
|
"className",
|
|
724
730
|
"aria-label"
|
|
@@ -731,6 +737,7 @@ var CircularProgress = React4.forwardRef(
|
|
|
731
737
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
732
738
|
const isWavy = shape === "wavy";
|
|
733
739
|
const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
|
|
740
|
+
const shouldShowDeterminateTrack = showTrack === "auto" ? true : showTrack;
|
|
734
741
|
const BASELINE_SIZE = 48;
|
|
735
742
|
const scaleFactor = size / BASELINE_SIZE;
|
|
736
743
|
const effectiveAmplitude = React4.useMemo(
|
|
@@ -763,19 +770,50 @@ var CircularProgress = React4.forwardRef(
|
|
|
763
770
|
const trackOffset = isDeterminate ? activeAngularFraction + gapForTrack : 0;
|
|
764
771
|
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
765
772
|
const ActiveCircleElem = m.circle;
|
|
766
|
-
const ActivePathElem = m.path;
|
|
767
773
|
const indeterminateSvgRef = React4.useRef(null);
|
|
768
774
|
const indeterminateTrackRef = React4.useRef(null);
|
|
769
775
|
const indeterminateActiveRef = React4.useRef(null);
|
|
770
776
|
const indeterminateWavyTrackPathRef = React4.useRef(null);
|
|
771
777
|
const indeterminateWavyActivePathRef = React4.useRef(null);
|
|
778
|
+
const determinateWavyActivePathRef = React4.useRef(null);
|
|
779
|
+
const determinateWavyTrackPathRef = React4.useRef(null);
|
|
772
780
|
const cachedPathLengthRef = React4.useRef(0);
|
|
781
|
+
const fractionMV = useMotionValue(isDeterminate ? clampedValue / 100 : 0);
|
|
782
|
+
const amplitudeMV = useMotionValue(isWavy ? effectiveAmplitude : 0);
|
|
783
|
+
React4.useEffect(() => {
|
|
784
|
+
if (isDeterminate) {
|
|
785
|
+
animate(fractionMV, clampedValue / 100, {
|
|
786
|
+
duration: 0.4,
|
|
787
|
+
ease: [0.2, 0, 0, 1]
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
}, [clampedValue, isDeterminate, fractionMV]);
|
|
791
|
+
React4.useEffect(() => {
|
|
792
|
+
if (!isDeterminate || !isWavy) return;
|
|
793
|
+
const fraction = clampedValue / 100;
|
|
794
|
+
let targetAmp = effectiveAmplitude;
|
|
795
|
+
if (determinateAnimation === "md3") {
|
|
796
|
+
targetAmp = fraction <= 0.1 || fraction >= 0.95 ? 0 : effectiveAmplitude;
|
|
797
|
+
}
|
|
798
|
+
animate(amplitudeMV, targetAmp, {
|
|
799
|
+
type: "spring",
|
|
800
|
+
bounce: 0,
|
|
801
|
+
duration: 0.5
|
|
802
|
+
});
|
|
803
|
+
}, [
|
|
804
|
+
clampedValue,
|
|
805
|
+
isDeterminate,
|
|
806
|
+
isWavy,
|
|
807
|
+
effectiveAmplitude,
|
|
808
|
+
amplitudeMV,
|
|
809
|
+
determinateAnimation
|
|
810
|
+
]);
|
|
773
811
|
React4.useLayoutEffect(() => {
|
|
774
812
|
if (!isWavy || !wavyActivePath) {
|
|
775
813
|
cachedPathLengthRef.current = circumference;
|
|
776
814
|
return;
|
|
777
815
|
}
|
|
778
|
-
const el = indeterminateActiveRef.current;
|
|
816
|
+
const el = indeterminateActiveRef.current || determinateWavyActivePathRef.current;
|
|
779
817
|
if (el && "getTotalLength" in el) {
|
|
780
818
|
try {
|
|
781
819
|
const len = el.getTotalLength();
|
|
@@ -789,7 +827,65 @@ var CircularProgress = React4.forwardRef(
|
|
|
789
827
|
cachedPathLengthRef.current = circumference;
|
|
790
828
|
}, [isWavy, circumference, wavyActivePath]);
|
|
791
829
|
useAnimationFrame((time) => {
|
|
792
|
-
|
|
830
|
+
const safeWaveSpeed = Math.max(0.1, waveSpeed);
|
|
831
|
+
const wavePhase = time / 1e3 * safeWaveSpeed * 2 * Math.PI;
|
|
832
|
+
if (isDeterminate) {
|
|
833
|
+
if (isWavy) {
|
|
834
|
+
const currentAmp = amplitudeMV.get();
|
|
835
|
+
const dynamicPath = generateWavyCircularPath(
|
|
836
|
+
center,
|
|
837
|
+
radius,
|
|
838
|
+
currentAmp,
|
|
839
|
+
effectiveWavelength,
|
|
840
|
+
wavePhase
|
|
841
|
+
);
|
|
842
|
+
if (determinateWavyActivePathRef.current) {
|
|
843
|
+
determinateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
844
|
+
}
|
|
845
|
+
if (trackShape === "wavy" && determinateWavyTrackPathRef.current) {
|
|
846
|
+
determinateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
|
|
847
|
+
}
|
|
848
|
+
const pathEl = determinateWavyActivePathRef.current;
|
|
849
|
+
let totalLen = cachedPathLengthRef.current || circumference;
|
|
850
|
+
if (pathEl) {
|
|
851
|
+
try {
|
|
852
|
+
const len = pathEl.getTotalLength();
|
|
853
|
+
if (len > 0) totalLen = len;
|
|
854
|
+
} catch (e) {
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
const activeFrac = Math.max(0, Math.min(1, fractionMV.get()));
|
|
858
|
+
const activeLen = totalLen * activeFrac;
|
|
859
|
+
if (determinateWavyActivePathRef.current) {
|
|
860
|
+
determinateWavyActivePathRef.current.setAttribute(
|
|
861
|
+
"stroke-dasharray",
|
|
862
|
+
`${activeLen} ${totalLen}`
|
|
863
|
+
);
|
|
864
|
+
determinateWavyActivePathRef.current.setAttribute(
|
|
865
|
+
"stroke-dashoffset",
|
|
866
|
+
"0"
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
if (shouldShowDeterminateTrack && trackShape === "wavy" && determinateWavyTrackPathRef.current) {
|
|
870
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
871
|
+
const trackStartFrac = activeFrac + gapFrac;
|
|
872
|
+
const trackLen = Math.max(
|
|
873
|
+
1e-3,
|
|
874
|
+
totalLen * (1 - activeFrac - 2 * gapFrac)
|
|
875
|
+
);
|
|
876
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
877
|
+
determinateWavyTrackPathRef.current.setAttribute(
|
|
878
|
+
"stroke-dasharray",
|
|
879
|
+
`${trackLen} ${totalLen}`
|
|
880
|
+
);
|
|
881
|
+
determinateWavyTrackPathRef.current.setAttribute(
|
|
882
|
+
"stroke-dashoffset",
|
|
883
|
+
`${trackOff}`
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
793
889
|
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
794
890
|
const scaledTime = time * safeCrawlerSpeed;
|
|
795
891
|
const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
|
|
@@ -824,7 +920,8 @@ var CircularProgress = React4.forwardRef(
|
|
|
824
920
|
center,
|
|
825
921
|
radius,
|
|
826
922
|
currentAmplitude,
|
|
827
|
-
effectiveWavelength
|
|
923
|
+
effectiveWavelength,
|
|
924
|
+
wavePhase
|
|
828
925
|
);
|
|
829
926
|
if (indeterminateWavyActivePathRef.current) {
|
|
830
927
|
indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
@@ -919,7 +1016,7 @@ var CircularProgress = React4.forwardRef(
|
|
|
919
1016
|
style: { width: size, height: size }
|
|
920
1017
|
}, restProps), {
|
|
921
1018
|
children: /* @__PURE__ */ jsxs(LazyMotion, { features: domMax, strict: true, children: [
|
|
922
|
-
/* @__PURE__ */
|
|
1019
|
+
/* @__PURE__ */ jsx(
|
|
923
1020
|
"svg",
|
|
924
1021
|
{
|
|
925
1022
|
width: size,
|
|
@@ -927,8 +1024,18 @@ var CircularProgress = React4.forwardRef(
|
|
|
927
1024
|
viewBox: `0 0 ${size} ${size}`,
|
|
928
1025
|
"aria-hidden": "true",
|
|
929
1026
|
style: { transform: "rotate(-90deg)", overflow: "visible" },
|
|
930
|
-
children: [
|
|
931
|
-
|
|
1027
|
+
children: isDeterminate ? isWavy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1028
|
+
shouldShowDeterminateTrack && (trackShape === "wavy" ? /* @__PURE__ */ jsx(
|
|
1029
|
+
"path",
|
|
1030
|
+
{
|
|
1031
|
+
ref: determinateWavyTrackPathRef,
|
|
1032
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
1033
|
+
fill: "none",
|
|
1034
|
+
stroke: bgTrackColor,
|
|
1035
|
+
strokeWidth: trackHeight,
|
|
1036
|
+
strokeLinecap: "round"
|
|
1037
|
+
}
|
|
1038
|
+
) : /* @__PURE__ */ jsx(
|
|
932
1039
|
m.circle,
|
|
933
1040
|
{
|
|
934
1041
|
cx: center,
|
|
@@ -937,28 +1044,52 @@ var CircularProgress = React4.forwardRef(
|
|
|
937
1044
|
fill: "none",
|
|
938
1045
|
stroke: bgTrackColor,
|
|
939
1046
|
strokeWidth: trackHeight,
|
|
940
|
-
initial: {
|
|
941
|
-
|
|
1047
|
+
initial: {
|
|
1048
|
+
pathLength: trackLength,
|
|
1049
|
+
pathOffset: trackOffset
|
|
1050
|
+
},
|
|
1051
|
+
animate: {
|
|
1052
|
+
pathLength: trackLength,
|
|
1053
|
+
pathOffset: trackOffset
|
|
1054
|
+
},
|
|
942
1055
|
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
|
|
943
1056
|
strokeLinecap: "round"
|
|
944
1057
|
}
|
|
945
|
-
)
|
|
946
|
-
|
|
947
|
-
|
|
1058
|
+
)),
|
|
1059
|
+
/* @__PURE__ */ jsx(
|
|
1060
|
+
"path",
|
|
948
1061
|
{
|
|
1062
|
+
ref: determinateWavyActivePathRef,
|
|
949
1063
|
d: wavyActivePath != null ? wavyActivePath : "",
|
|
950
1064
|
fill: "none",
|
|
951
1065
|
stroke: activeColor,
|
|
952
1066
|
strokeWidth: trackHeight,
|
|
953
|
-
strokeLinecap: "round"
|
|
954
|
-
initial: { pathLength: 0 },
|
|
955
|
-
animate: { pathLength: clampedValue / 100 },
|
|
956
|
-
transition: {
|
|
957
|
-
duration: 0.4,
|
|
958
|
-
ease: [0.2, 0, 0, 1]
|
|
959
|
-
}
|
|
1067
|
+
strokeLinecap: "round"
|
|
960
1068
|
}
|
|
961
|
-
)
|
|
1069
|
+
)
|
|
1070
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1071
|
+
/* @__PURE__ */ jsx(
|
|
1072
|
+
m.circle,
|
|
1073
|
+
{
|
|
1074
|
+
cx: center,
|
|
1075
|
+
cy: center,
|
|
1076
|
+
r: radius,
|
|
1077
|
+
fill: "none",
|
|
1078
|
+
stroke: bgTrackColor,
|
|
1079
|
+
strokeWidth: trackHeight,
|
|
1080
|
+
initial: {
|
|
1081
|
+
pathLength: trackLength,
|
|
1082
|
+
pathOffset: trackOffset
|
|
1083
|
+
},
|
|
1084
|
+
animate: {
|
|
1085
|
+
pathLength: trackLength,
|
|
1086
|
+
pathOffset: trackOffset
|
|
1087
|
+
},
|
|
1088
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
|
|
1089
|
+
strokeLinecap: "round"
|
|
1090
|
+
}
|
|
1091
|
+
),
|
|
1092
|
+
/* @__PURE__ */ jsx(
|
|
962
1093
|
ActiveCircleElem,
|
|
963
1094
|
{
|
|
964
1095
|
cx: center,
|
|
@@ -975,8 +1106,8 @@ var CircularProgress = React4.forwardRef(
|
|
|
975
1106
|
ease: [0.2, 0, 0, 1]
|
|
976
1107
|
}
|
|
977
1108
|
}
|
|
978
|
-
)
|
|
979
|
-
]
|
|
1109
|
+
)
|
|
1110
|
+
] }) : null
|
|
980
1111
|
}
|
|
981
1112
|
),
|
|
982
1113
|
!isDeterminate && /* @__PURE__ */ jsx(
|