@bug-on/m3-expressive 1.2.5 → 1.2.6

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/dist/layout.js CHANGED
@@ -537,24 +537,36 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
537
537
  if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
538
538
  d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
539
539
  }
540
- d += " Z";
541
540
  return d;
542
541
  }
543
542
  function getSinePath(startX, endX, phase, wl, amp) {
544
543
  if (startX >= endX) return "";
545
- let d = "";
546
- const step = amp === 0 ? Math.max(10, endX - startX) : 1;
547
- const yStart = Math.sin((startX + phase) / wl * 2 * Math.PI) * amp;
548
- d += `M ${startX.toFixed(2)} ${yStart.toFixed(2)}`;
549
- let nextX = Math.ceil(startX / step) * step;
550
- if (nextX === startX) nextX += step;
551
- while (nextX < endX) {
552
- const y = Math.sin((nextX + phase) / wl * 2 * Math.PI) * amp;
553
- d += ` L ${nextX.toFixed(2)} ${y.toFixed(2)}`;
554
- nextX += step;
555
- }
556
- const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
557
- d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
544
+ if (amp <= 0.01) {
545
+ return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
546
+ }
547
+ const safeWl = Math.max(1, wl);
548
+ const k = 2 * Math.PI / safeWl;
549
+ const phi = phase / safeWl * 2 * Math.PI;
550
+ const yAt = (x) => amp * Math.sin(k * x + phi);
551
+ const dyAt = (x) => amp * k * Math.cos(k * x + phi);
552
+ const step = safeWl / 4;
553
+ let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
554
+ let currentX = startX;
555
+ while (currentX < endX) {
556
+ const nextX = Math.min(endX, currentX + step);
557
+ const dx = nextX - currentX;
558
+ const scale = dx / 3;
559
+ const y0 = yAt(currentX);
560
+ const dy0 = dyAt(currentX);
561
+ const y1 = yAt(nextX);
562
+ const dy1 = dyAt(nextX);
563
+ const cp1x = currentX + scale;
564
+ const cp1y = y0 + scale * dy0;
565
+ const cp2x = nextX - scale;
566
+ const cp2y = y1 - scale * dy1;
567
+ d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
568
+ currentX = nextX;
569
+ }
558
570
  return d;
559
571
  }
560
572
  var CircularProgress = React18__namespace.forwardRef(
@@ -709,16 +721,13 @@ var CircularProgress = React18__namespace.forwardRef(
709
721
  position: "absolute",
710
722
  inset: 0,
711
723
  overflow: "visible",
712
- rotate: "-90deg",
713
724
  transformOrigin: "center"
714
725
  },
715
- animate: { rotate: ["-90deg", "270deg"] },
726
+ animate: { rotate: [0, 360] },
716
727
  transition: {
717
- rotate: {
718
- duration: 2 / Math.max(0.1, crawlerSpeed),
719
- repeat: Number.POSITIVE_INFINITY,
720
- ease: "linear"
721
- }
728
+ duration: 2 / Math.max(0.1, crawlerSpeed),
729
+ repeat: Number.POSITIVE_INFINITY,
730
+ ease: "linear"
722
731
  },
723
732
  children: [
724
733
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -731,17 +740,16 @@ var CircularProgress = React18__namespace.forwardRef(
731
740
  stroke: bgTrackColor,
732
741
  strokeWidth: trackHeight,
733
742
  strokeLinecap: "round",
734
- style: { originX: "50%", originY: "50%" },
735
743
  animate: {
736
744
  pathLength: [
737
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
738
- Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
739
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
745
+ Math.max(1e-3, 0.9 - 2 * gapForTrack),
746
+ Math.max(1e-3, 0.25 - 2 * gapForTrack),
747
+ Math.max(1e-3, 0.9 - 2 * gapForTrack)
740
748
  ],
741
- rotate: [
742
- `${(0.1 + gapForTrack) * 360}deg`,
743
- `${(1 + gapForTrack) * 360}deg`,
744
- `${(1.1 + gapForTrack) * 360}deg`
749
+ pathOffset: [
750
+ 0.1 + gapForTrack,
751
+ 0.75 + gapForTrack,
752
+ 0.1 + gapForTrack
745
753
  ]
746
754
  },
747
755
  transition: {
@@ -759,10 +767,9 @@ var CircularProgress = React18__namespace.forwardRef(
759
767
  stroke: activeColor,
760
768
  strokeWidth: trackHeight,
761
769
  strokeLinecap: "round",
762
- style: { originX: "50%", originY: "50%" },
763
770
  animate: {
764
771
  pathLength: [0.1, 0.75, 0.1],
765
- rotate: ["0deg", "90deg", "360deg"]
772
+ pathOffset: [0, 0.65, 1]
766
773
  },
767
774
  transition: {
768
775
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -780,10 +787,9 @@ var CircularProgress = React18__namespace.forwardRef(
780
787
  stroke: activeColor,
781
788
  strokeWidth: trackHeight,
782
789
  strokeLinecap: "round",
783
- style: { originX: "50%", originY: "50%" },
784
790
  animate: {
785
791
  pathLength: [0.1, 0.75, 0.1],
786
- rotate: ["0deg", "90deg", "360deg"]
792
+ pathOffset: [0, 0.65, 1]
787
793
  },
788
794
  transition: {
789
795
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -956,6 +962,12 @@ var WavyLinearTrack = React18__namespace.memo(function WavyLinearTrack2({
956
962
  duration: 0.5
957
963
  });
958
964
  react.animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
965
+ } else {
966
+ react.animate(amplitudeMV, amplitude, {
967
+ type: "spring",
968
+ bounce: 0,
969
+ duration: 0.5
970
+ });
959
971
  }
960
972
  }, [
961
973
  clampedValue,
@@ -969,10 +981,10 @@ var WavyLinearTrack = React18__namespace.memo(function WavyLinearTrack2({
969
981
  1,
970
982
  isDeterminate ? wavelength : indeterminateWavelength
971
983
  );
972
- const trackAmp = trackShape === "wavy" ? amplitude : 0;
973
984
  react.useAnimationFrame((time) => {
974
985
  if (width === 0) return;
975
986
  const currentAmp = amplitudeMV.get();
987
+ const trackAmp = trackShape === "wavy" ? amplitude : 0;
976
988
  const phase = time / 1e3 * waveSpeed * activeWavelength;
977
989
  const capWidth = trackHeight / 2;
978
990
  let activePathD = "";
@@ -1073,7 +1085,7 @@ var WavyLinearTrack = React18__namespace.memo(function WavyLinearTrack2({
1073
1085
  "div",
1074
1086
  {
1075
1087
  ref: containerRef,
1076
- className: "relative w-full overflow-hidden",
1088
+ className: "relative w-full",
1077
1089
  style: { height: svgHeight },
1078
1090
  children: width > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
1079
1091
  "svg",
@@ -1127,7 +1139,7 @@ var LinearProgress = React18__namespace.forwardRef(
1127
1139
  waveSpeed = 1,
1128
1140
  crawlerSpeed = 1,
1129
1141
  determinateAnimation = "md3",
1130
- indeterminateAnimation = "continuous",
1142
+ indeterminateAnimation = "md3",
1131
1143
  gapSize = 4,
1132
1144
  showStopIndicator = "auto",
1133
1145
  color,
@@ -1164,15 +1176,15 @@ var LinearProgress = React18__namespace.forwardRef(
1164
1176
  setIsRtl(dir === "rtl");
1165
1177
  }
1166
1178
  }, []);
1167
- const isWavy = shape === "wavy";
1168
1179
  const resolvedTrackShape = trackShape != null ? trackShape : shape;
1180
+ const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
1169
1181
  const effectiveAmplitude = React18__namespace.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
1170
1182
  const svgHeight = React18__namespace.useMemo(
1171
1183
  () => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
1172
1184
  [isWavy, trackHeight, effectiveAmplitude]
1173
1185
  );
1174
1186
  const shouldShowStop = React18__namespace.useMemo(
1175
- () => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
1187
+ () => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
1176
1188
  [isDeterminate, resolvedTrackShape, showStopIndicator]
1177
1189
  );
1178
1190
  const stopSize = React18__namespace.useMemo(
@@ -1182,6 +1194,8 @@ var LinearProgress = React18__namespace.forwardRef(
1182
1194
  const stopOffset = (trackHeight - stopSize) / 2;
1183
1195
  const activeColor = color || "var(--md-sys-color-indicator-active)";
1184
1196
  const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
1197
+ const useWavyTrack = isWavy || !isDeterminate;
1198
+ const trackAmp = isWavy ? effectiveAmplitude : 0;
1185
1199
  return /* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domMax, strict: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1186
1200
  "div",
1187
1201
  __spreadProps(__spreadValues({
@@ -1198,12 +1212,12 @@ var LinearProgress = React18__namespace.forwardRef(
1198
1212
  style: { height: svgHeight }
1199
1213
  }, restProps), {
1200
1214
  children: [
1201
- isWavy ? /* @__PURE__ */ jsxRuntime.jsx(
1215
+ useWavyTrack ? /* @__PURE__ */ jsxRuntime.jsx(
1202
1216
  WavyLinearTrack,
1203
1217
  {
1204
1218
  trackHeight,
1205
1219
  svgHeight,
1206
- amplitude: effectiveAmplitude,
1220
+ amplitude: trackAmp,
1207
1221
  wavelength,
1208
1222
  indeterminateWavelength,
1209
1223
  activeColor,