@bug-on/m3-expressive 1.2.7 → 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 +12 -0
- package/dist/buttons.d.mts +3 -3
- package/dist/buttons.d.ts +3 -3
- package/dist/buttons.js +195 -50
- package/dist/buttons.js.map +1 -1
- package/dist/buttons.mjs +196 -51
- package/dist/buttons.mjs.map +1 -1
- package/dist/{core-D4048_K5.d.mts → core-CAU8g2HY.d.mts} +1 -1
- package/dist/{core-Bc5Wj_pc.d.ts → core-DRrLnsnJ.d.ts} +1 -1
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +159 -28
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +160 -29
- package/dist/core.mjs.map +1 -1
- package/dist/feedback.d.mts +28 -6
- package/dist/feedback.d.ts +28 -6
- package/dist/feedback.js +161 -30
- package/dist/feedback.js.map +1 -1
- package/dist/feedback.mjs +162 -31
- 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/{icon-button-CSsDmuQC.d.mts → icon-button-CqdQBsRe.d.ts} +11 -5
- package/dist/{icon-button-CSsDmuQC.d.ts → icon-button-USJo7AqO.d.mts} +11 -5
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +570 -309
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +570 -310
- package/dist/index.mjs.map +1 -1
- package/dist/layout.d.mts +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +159 -60
- package/dist/layout.js.map +1 -1
- package/dist/layout.mjs +160 -61
- package/dist/layout.mjs.map +1 -1
- package/dist/{md3-Dty-Qcad.d.mts → md3-D0_Z7IXj.d.mts} +9 -1
- package/dist/{md3-Dty-Qcad.d.ts → md3-D0_Z7IXj.d.ts} +9 -1
- package/dist/navigation.d.mts +103 -33
- package/dist/navigation.d.ts +103 -33
- package/dist/navigation.js +443 -152
- package/dist/navigation.js.map +1 -1
- package/dist/navigation.mjs +444 -154
- package/dist/navigation.mjs.map +1 -1
- package/dist/overlays.js +159 -28
- package/dist/overlays.js.map +1 -1
- package/dist/overlays.mjs +160 -29
- package/dist/overlays.mjs.map +1 -1
- package/dist/pickers.js +159 -28
- package/dist/pickers.js.map +1 -1
- package/dist/pickers.mjs +160 -29
- package/dist/pickers.mjs.map +1 -1
- package/dist/{split-button-trailing-uncheckable-DPJL3bO6.d.mts → split-button-trailing-uncheckable-CIVEYgjY.d.mts} +12 -7
- package/dist/{split-button-trailing-uncheckable--BhNTEJw.d.ts → split-button-trailing-uncheckable-DTQJjzsB.d.ts} +12 -7
- 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/pickers.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { m,
|
|
2
|
+
import { m, useMotionValue, animate, useAnimationFrame, LazyMotion, domMax, AnimatePresence, useReducedMotion } from 'motion/react';
|
|
3
3
|
import * as React6 from 'react';
|
|
4
4
|
import { useState, useCallback, useMemo, useReducer } from 'react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
@@ -685,7 +685,7 @@ LoadingIndicator.displayName = "LoadingIndicator";
|
|
|
685
685
|
function easeInOutCubic(x) {
|
|
686
686
|
return x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;
|
|
687
687
|
}
|
|
688
|
-
function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
688
|
+
function generateWavyCircularPath(center, radius, amplitude, wavelength, phase = 0) {
|
|
689
689
|
const circumference = 2 * Math.PI * radius;
|
|
690
690
|
const numWaves = Math.max(
|
|
691
691
|
3,
|
|
@@ -693,8 +693,8 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
|
693
693
|
);
|
|
694
694
|
const steps = numWaves * 4;
|
|
695
695
|
const dt = 2 * Math.PI / steps;
|
|
696
|
-
const rAt = (t) => radius + amplitude * Math.sin(numWaves * t);
|
|
697
|
-
const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t);
|
|
696
|
+
const rAt = (t) => radius + amplitude * Math.sin(numWaves * t + phase);
|
|
697
|
+
const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t + phase);
|
|
698
698
|
const xAt = (t) => center + rAt(t) * Math.cos(t);
|
|
699
699
|
const yAt = (t) => center + rAt(t) * Math.sin(t);
|
|
700
700
|
const dxAt = (t) => drAt(t) * Math.cos(t) - rAt(t) * Math.sin(t);
|
|
@@ -759,15 +759,18 @@ var CircularProgress = React6.forwardRef(
|
|
|
759
759
|
size = 48,
|
|
760
760
|
trackHeight = 4,
|
|
761
761
|
shape = "flat",
|
|
762
|
+
trackShape = "flat",
|
|
762
763
|
amplitude,
|
|
763
764
|
wavelength,
|
|
764
765
|
gapSize = 4,
|
|
766
|
+
waveSpeed = 1,
|
|
765
767
|
crawlerSpeed = 1,
|
|
766
768
|
color,
|
|
767
769
|
trackColor,
|
|
768
770
|
showTrack = "auto",
|
|
769
771
|
minProgress = DEFAULT_MIN_PROGRESS,
|
|
770
772
|
maxProgress = DEFAULT_MAX_PROGRESS,
|
|
773
|
+
determinateAnimation = "md3",
|
|
771
774
|
amplitudeRange,
|
|
772
775
|
className,
|
|
773
776
|
"aria-label": ariaLabel
|
|
@@ -776,15 +779,18 @@ var CircularProgress = React6.forwardRef(
|
|
|
776
779
|
"size",
|
|
777
780
|
"trackHeight",
|
|
778
781
|
"shape",
|
|
782
|
+
"trackShape",
|
|
779
783
|
"amplitude",
|
|
780
784
|
"wavelength",
|
|
781
785
|
"gapSize",
|
|
786
|
+
"waveSpeed",
|
|
782
787
|
"crawlerSpeed",
|
|
783
788
|
"color",
|
|
784
789
|
"trackColor",
|
|
785
790
|
"showTrack",
|
|
786
791
|
"minProgress",
|
|
787
792
|
"maxProgress",
|
|
793
|
+
"determinateAnimation",
|
|
788
794
|
"amplitudeRange",
|
|
789
795
|
"className",
|
|
790
796
|
"aria-label"
|
|
@@ -797,6 +803,7 @@ var CircularProgress = React6.forwardRef(
|
|
|
797
803
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
798
804
|
const isWavy = shape === "wavy";
|
|
799
805
|
const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
|
|
806
|
+
const shouldShowDeterminateTrack = showTrack === "auto" ? true : showTrack;
|
|
800
807
|
const BASELINE_SIZE = 48;
|
|
801
808
|
const scaleFactor = size / BASELINE_SIZE;
|
|
802
809
|
const effectiveAmplitude = React6.useMemo(
|
|
@@ -829,19 +836,50 @@ var CircularProgress = React6.forwardRef(
|
|
|
829
836
|
const trackOffset = isDeterminate ? activeAngularFraction + gapForTrack : 0;
|
|
830
837
|
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
831
838
|
const ActiveCircleElem = m.circle;
|
|
832
|
-
const ActivePathElem = m.path;
|
|
833
839
|
const indeterminateSvgRef = React6.useRef(null);
|
|
834
840
|
const indeterminateTrackRef = React6.useRef(null);
|
|
835
841
|
const indeterminateActiveRef = React6.useRef(null);
|
|
836
842
|
const indeterminateWavyTrackPathRef = React6.useRef(null);
|
|
837
843
|
const indeterminateWavyActivePathRef = React6.useRef(null);
|
|
844
|
+
const determinateWavyActivePathRef = React6.useRef(null);
|
|
845
|
+
const determinateWavyTrackPathRef = React6.useRef(null);
|
|
838
846
|
const cachedPathLengthRef = React6.useRef(0);
|
|
847
|
+
const fractionMV = useMotionValue(isDeterminate ? clampedValue / 100 : 0);
|
|
848
|
+
const amplitudeMV = useMotionValue(isWavy ? effectiveAmplitude : 0);
|
|
849
|
+
React6.useEffect(() => {
|
|
850
|
+
if (isDeterminate) {
|
|
851
|
+
animate(fractionMV, clampedValue / 100, {
|
|
852
|
+
duration: 0.4,
|
|
853
|
+
ease: [0.2, 0, 0, 1]
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
}, [clampedValue, isDeterminate, fractionMV]);
|
|
857
|
+
React6.useEffect(() => {
|
|
858
|
+
if (!isDeterminate || !isWavy) return;
|
|
859
|
+
const fraction = clampedValue / 100;
|
|
860
|
+
let targetAmp = effectiveAmplitude;
|
|
861
|
+
if (determinateAnimation === "md3") {
|
|
862
|
+
targetAmp = fraction <= 0.1 || fraction >= 0.95 ? 0 : effectiveAmplitude;
|
|
863
|
+
}
|
|
864
|
+
animate(amplitudeMV, targetAmp, {
|
|
865
|
+
type: "spring",
|
|
866
|
+
bounce: 0,
|
|
867
|
+
duration: 0.5
|
|
868
|
+
});
|
|
869
|
+
}, [
|
|
870
|
+
clampedValue,
|
|
871
|
+
isDeterminate,
|
|
872
|
+
isWavy,
|
|
873
|
+
effectiveAmplitude,
|
|
874
|
+
amplitudeMV,
|
|
875
|
+
determinateAnimation
|
|
876
|
+
]);
|
|
839
877
|
React6.useLayoutEffect(() => {
|
|
840
878
|
if (!isWavy || !wavyActivePath) {
|
|
841
879
|
cachedPathLengthRef.current = circumference;
|
|
842
880
|
return;
|
|
843
881
|
}
|
|
844
|
-
const el = indeterminateActiveRef.current;
|
|
882
|
+
const el = indeterminateActiveRef.current || determinateWavyActivePathRef.current;
|
|
845
883
|
if (el && "getTotalLength" in el) {
|
|
846
884
|
try {
|
|
847
885
|
const len = el.getTotalLength();
|
|
@@ -855,7 +893,65 @@ var CircularProgress = React6.forwardRef(
|
|
|
855
893
|
cachedPathLengthRef.current = circumference;
|
|
856
894
|
}, [isWavy, circumference, wavyActivePath]);
|
|
857
895
|
useAnimationFrame((time) => {
|
|
858
|
-
|
|
896
|
+
const safeWaveSpeed = Math.max(0.1, waveSpeed);
|
|
897
|
+
const wavePhase = time / 1e3 * safeWaveSpeed * 2 * Math.PI;
|
|
898
|
+
if (isDeterminate) {
|
|
899
|
+
if (isWavy) {
|
|
900
|
+
const currentAmp = amplitudeMV.get();
|
|
901
|
+
const dynamicPath = generateWavyCircularPath(
|
|
902
|
+
center,
|
|
903
|
+
radius,
|
|
904
|
+
currentAmp,
|
|
905
|
+
effectiveWavelength,
|
|
906
|
+
wavePhase
|
|
907
|
+
);
|
|
908
|
+
if (determinateWavyActivePathRef.current) {
|
|
909
|
+
determinateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
910
|
+
}
|
|
911
|
+
if (trackShape === "wavy" && determinateWavyTrackPathRef.current) {
|
|
912
|
+
determinateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
|
|
913
|
+
}
|
|
914
|
+
const pathEl = determinateWavyActivePathRef.current;
|
|
915
|
+
let totalLen = cachedPathLengthRef.current || circumference;
|
|
916
|
+
if (pathEl) {
|
|
917
|
+
try {
|
|
918
|
+
const len = pathEl.getTotalLength();
|
|
919
|
+
if (len > 0) totalLen = len;
|
|
920
|
+
} catch (e) {
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
const activeFrac = Math.max(0, Math.min(1, fractionMV.get()));
|
|
924
|
+
const activeLen = totalLen * activeFrac;
|
|
925
|
+
if (determinateWavyActivePathRef.current) {
|
|
926
|
+
determinateWavyActivePathRef.current.setAttribute(
|
|
927
|
+
"stroke-dasharray",
|
|
928
|
+
`${activeLen} ${totalLen}`
|
|
929
|
+
);
|
|
930
|
+
determinateWavyActivePathRef.current.setAttribute(
|
|
931
|
+
"stroke-dashoffset",
|
|
932
|
+
"0"
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
if (shouldShowDeterminateTrack && trackShape === "wavy" && determinateWavyTrackPathRef.current) {
|
|
936
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
937
|
+
const trackStartFrac = activeFrac + gapFrac;
|
|
938
|
+
const trackLen = Math.max(
|
|
939
|
+
1e-3,
|
|
940
|
+
totalLen * (1 - activeFrac - 2 * gapFrac)
|
|
941
|
+
);
|
|
942
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
943
|
+
determinateWavyTrackPathRef.current.setAttribute(
|
|
944
|
+
"stroke-dasharray",
|
|
945
|
+
`${trackLen} ${totalLen}`
|
|
946
|
+
);
|
|
947
|
+
determinateWavyTrackPathRef.current.setAttribute(
|
|
948
|
+
"stroke-dashoffset",
|
|
949
|
+
`${trackOff}`
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
859
955
|
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
860
956
|
const scaledTime = time * safeCrawlerSpeed;
|
|
861
957
|
const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
|
|
@@ -890,7 +986,8 @@ var CircularProgress = React6.forwardRef(
|
|
|
890
986
|
center,
|
|
891
987
|
radius,
|
|
892
988
|
currentAmplitude,
|
|
893
|
-
effectiveWavelength
|
|
989
|
+
effectiveWavelength,
|
|
990
|
+
wavePhase
|
|
894
991
|
);
|
|
895
992
|
if (indeterminateWavyActivePathRef.current) {
|
|
896
993
|
indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
@@ -985,7 +1082,7 @@ var CircularProgress = React6.forwardRef(
|
|
|
985
1082
|
style: { width: size, height: size }
|
|
986
1083
|
}, restProps), {
|
|
987
1084
|
children: /* @__PURE__ */ jsxs(LazyMotion, { features: domMax, strict: true, children: [
|
|
988
|
-
/* @__PURE__ */
|
|
1085
|
+
/* @__PURE__ */ jsx(
|
|
989
1086
|
"svg",
|
|
990
1087
|
{
|
|
991
1088
|
width: size,
|
|
@@ -993,8 +1090,18 @@ var CircularProgress = React6.forwardRef(
|
|
|
993
1090
|
viewBox: `0 0 ${size} ${size}`,
|
|
994
1091
|
"aria-hidden": "true",
|
|
995
1092
|
style: { transform: "rotate(-90deg)", overflow: "visible" },
|
|
996
|
-
children: [
|
|
997
|
-
|
|
1093
|
+
children: isDeterminate ? isWavy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1094
|
+
shouldShowDeterminateTrack && (trackShape === "wavy" ? /* @__PURE__ */ jsx(
|
|
1095
|
+
"path",
|
|
1096
|
+
{
|
|
1097
|
+
ref: determinateWavyTrackPathRef,
|
|
1098
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
1099
|
+
fill: "none",
|
|
1100
|
+
stroke: bgTrackColor,
|
|
1101
|
+
strokeWidth: trackHeight,
|
|
1102
|
+
strokeLinecap: "round"
|
|
1103
|
+
}
|
|
1104
|
+
) : /* @__PURE__ */ jsx(
|
|
998
1105
|
m.circle,
|
|
999
1106
|
{
|
|
1000
1107
|
cx: center,
|
|
@@ -1003,28 +1110,52 @@ var CircularProgress = React6.forwardRef(
|
|
|
1003
1110
|
fill: "none",
|
|
1004
1111
|
stroke: bgTrackColor,
|
|
1005
1112
|
strokeWidth: trackHeight,
|
|
1006
|
-
initial: {
|
|
1007
|
-
|
|
1113
|
+
initial: {
|
|
1114
|
+
pathLength: trackLength,
|
|
1115
|
+
pathOffset: trackOffset
|
|
1116
|
+
},
|
|
1117
|
+
animate: {
|
|
1118
|
+
pathLength: trackLength,
|
|
1119
|
+
pathOffset: trackOffset
|
|
1120
|
+
},
|
|
1008
1121
|
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
|
|
1009
1122
|
strokeLinecap: "round"
|
|
1010
1123
|
}
|
|
1011
|
-
)
|
|
1012
|
-
|
|
1013
|
-
|
|
1124
|
+
)),
|
|
1125
|
+
/* @__PURE__ */ jsx(
|
|
1126
|
+
"path",
|
|
1014
1127
|
{
|
|
1128
|
+
ref: determinateWavyActivePathRef,
|
|
1015
1129
|
d: wavyActivePath != null ? wavyActivePath : "",
|
|
1016
1130
|
fill: "none",
|
|
1017
1131
|
stroke: activeColor,
|
|
1018
1132
|
strokeWidth: trackHeight,
|
|
1019
|
-
strokeLinecap: "round"
|
|
1020
|
-
initial: { pathLength: 0 },
|
|
1021
|
-
animate: { pathLength: clampedValue / 100 },
|
|
1022
|
-
transition: {
|
|
1023
|
-
duration: 0.4,
|
|
1024
|
-
ease: [0.2, 0, 0, 1]
|
|
1025
|
-
}
|
|
1133
|
+
strokeLinecap: "round"
|
|
1026
1134
|
}
|
|
1027
|
-
)
|
|
1135
|
+
)
|
|
1136
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1137
|
+
/* @__PURE__ */ jsx(
|
|
1138
|
+
m.circle,
|
|
1139
|
+
{
|
|
1140
|
+
cx: center,
|
|
1141
|
+
cy: center,
|
|
1142
|
+
r: radius,
|
|
1143
|
+
fill: "none",
|
|
1144
|
+
stroke: bgTrackColor,
|
|
1145
|
+
strokeWidth: trackHeight,
|
|
1146
|
+
initial: {
|
|
1147
|
+
pathLength: trackLength,
|
|
1148
|
+
pathOffset: trackOffset
|
|
1149
|
+
},
|
|
1150
|
+
animate: {
|
|
1151
|
+
pathLength: trackLength,
|
|
1152
|
+
pathOffset: trackOffset
|
|
1153
|
+
},
|
|
1154
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
|
|
1155
|
+
strokeLinecap: "round"
|
|
1156
|
+
}
|
|
1157
|
+
),
|
|
1158
|
+
/* @__PURE__ */ jsx(
|
|
1028
1159
|
ActiveCircleElem,
|
|
1029
1160
|
{
|
|
1030
1161
|
cx: center,
|
|
@@ -1041,8 +1172,8 @@ var CircularProgress = React6.forwardRef(
|
|
|
1041
1172
|
ease: [0.2, 0, 0, 1]
|
|
1042
1173
|
}
|
|
1043
1174
|
}
|
|
1044
|
-
)
|
|
1045
|
-
]
|
|
1175
|
+
)
|
|
1176
|
+
] }) : null
|
|
1046
1177
|
}
|
|
1047
1178
|
),
|
|
1048
1179
|
!isDeterminate && /* @__PURE__ */ jsx(
|
|
@@ -1810,7 +1941,7 @@ var IconButtonComponent = React6.forwardRef(
|
|
|
1810
1941
|
variant = "default",
|
|
1811
1942
|
colorStyle = "standard",
|
|
1812
1943
|
size = "sm",
|
|
1813
|
-
|
|
1944
|
+
width = "default",
|
|
1814
1945
|
shape = "round",
|
|
1815
1946
|
selected,
|
|
1816
1947
|
selectedIcon,
|
|
@@ -1828,7 +1959,7 @@ var IconButtonComponent = React6.forwardRef(
|
|
|
1828
1959
|
"variant",
|
|
1829
1960
|
"colorStyle",
|
|
1830
1961
|
"size",
|
|
1831
|
-
"
|
|
1962
|
+
"width",
|
|
1832
1963
|
"shape",
|
|
1833
1964
|
"selected",
|
|
1834
1965
|
"selectedIcon",
|
|
@@ -1873,7 +2004,7 @@ var IconButtonComponent = React6.forwardRef(
|
|
|
1873
2004
|
const iconPx = iconSize != null ? iconSize : defaultIconPx;
|
|
1874
2005
|
const isCustomSize = iconSize != null && iconSize !== "inherit";
|
|
1875
2006
|
const heightClass = (_c = SIZE_HEIGHT_STYLES[size]) != null ? _c : SIZE_HEIGHT_STYLES.sm;
|
|
1876
|
-
const widthClass = (_e = ((_d = WIDTH_SIZE_STYLES[size]) != null ? _d : WIDTH_SIZE_STYLES.sm)[
|
|
2007
|
+
const widthClass = (_e = ((_d = WIDTH_SIZE_STYLES[size]) != null ? _d : WIDTH_SIZE_STYLES.sm)[width]) != null ? _e : WIDTH_SIZE_STYLES.sm.default;
|
|
1877
2008
|
const needsTouchTarget = size === "xs" || size === "sm";
|
|
1878
2009
|
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
1879
2010
|
disabled: loading
|