@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.mjs CHANGED
@@ -515,24 +515,36 @@ 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 += " Z";
519
518
  return d;
520
519
  }
521
520
  function getSinePath(startX, endX, phase, wl, amp) {
522
521
  if (startX >= endX) return "";
523
- let d = "";
524
- const step = amp === 0 ? Math.max(10, endX - startX) : 1;
525
- const yStart = Math.sin((startX + phase) / wl * 2 * Math.PI) * amp;
526
- d += `M ${startX.toFixed(2)} ${yStart.toFixed(2)}`;
527
- let nextX = Math.ceil(startX / step) * step;
528
- if (nextX === startX) nextX += step;
529
- while (nextX < endX) {
530
- const y = Math.sin((nextX + phase) / wl * 2 * Math.PI) * amp;
531
- d += ` L ${nextX.toFixed(2)} ${y.toFixed(2)}`;
532
- nextX += step;
533
- }
534
- const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
535
- d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
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
  }
538
550
  var CircularProgress = React18.forwardRef(
@@ -687,16 +699,13 @@ var CircularProgress = React18.forwardRef(
687
699
  position: "absolute",
688
700
  inset: 0,
689
701
  overflow: "visible",
690
- rotate: "-90deg",
691
702
  transformOrigin: "center"
692
703
  },
693
- animate: { rotate: ["-90deg", "270deg"] },
704
+ animate: { rotate: [0, 360] },
694
705
  transition: {
695
- rotate: {
696
- duration: 2 / Math.max(0.1, crawlerSpeed),
697
- repeat: Number.POSITIVE_INFINITY,
698
- ease: "linear"
699
- }
706
+ duration: 2 / Math.max(0.1, crawlerSpeed),
707
+ repeat: Number.POSITIVE_INFINITY,
708
+ ease: "linear"
700
709
  },
701
710
  children: [
702
711
  /* @__PURE__ */ jsx(
@@ -709,17 +718,16 @@ var CircularProgress = React18.forwardRef(
709
718
  stroke: bgTrackColor,
710
719
  strokeWidth: trackHeight,
711
720
  strokeLinecap: "round",
712
- style: { originX: "50%", originY: "50%" },
713
721
  animate: {
714
722
  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)
723
+ Math.max(1e-3, 0.9 - 2 * gapForTrack),
724
+ Math.max(1e-3, 0.25 - 2 * gapForTrack),
725
+ Math.max(1e-3, 0.9 - 2 * gapForTrack)
718
726
  ],
719
- rotate: [
720
- `${(0.1 + gapForTrack) * 360}deg`,
721
- `${(1 + gapForTrack) * 360}deg`,
722
- `${(1.1 + gapForTrack) * 360}deg`
727
+ pathOffset: [
728
+ 0.1 + gapForTrack,
729
+ 0.75 + gapForTrack,
730
+ 0.1 + gapForTrack
723
731
  ]
724
732
  },
725
733
  transition: {
@@ -737,10 +745,9 @@ var CircularProgress = React18.forwardRef(
737
745
  stroke: activeColor,
738
746
  strokeWidth: trackHeight,
739
747
  strokeLinecap: "round",
740
- style: { originX: "50%", originY: "50%" },
741
748
  animate: {
742
749
  pathLength: [0.1, 0.75, 0.1],
743
- rotate: ["0deg", "90deg", "360deg"]
750
+ pathOffset: [0, 0.65, 1]
744
751
  },
745
752
  transition: {
746
753
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -758,10 +765,9 @@ var CircularProgress = React18.forwardRef(
758
765
  stroke: activeColor,
759
766
  strokeWidth: trackHeight,
760
767
  strokeLinecap: "round",
761
- style: { originX: "50%", originY: "50%" },
762
768
  animate: {
763
769
  pathLength: [0.1, 0.75, 0.1],
764
- rotate: ["0deg", "90deg", "360deg"]
770
+ pathOffset: [0, 0.65, 1]
765
771
  },
766
772
  transition: {
767
773
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -934,6 +940,12 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
934
940
  duration: 0.5
935
941
  });
936
942
  animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
943
+ } else {
944
+ animate(amplitudeMV, amplitude, {
945
+ type: "spring",
946
+ bounce: 0,
947
+ duration: 0.5
948
+ });
937
949
  }
938
950
  }, [
939
951
  clampedValue,
@@ -947,10 +959,10 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
947
959
  1,
948
960
  isDeterminate ? wavelength : indeterminateWavelength
949
961
  );
950
- const trackAmp = trackShape === "wavy" ? amplitude : 0;
951
962
  useAnimationFrame((time) => {
952
963
  if (width === 0) return;
953
964
  const currentAmp = amplitudeMV.get();
965
+ const trackAmp = trackShape === "wavy" ? amplitude : 0;
954
966
  const phase = time / 1e3 * waveSpeed * activeWavelength;
955
967
  const capWidth = trackHeight / 2;
956
968
  let activePathD = "";
@@ -1051,7 +1063,7 @@ var WavyLinearTrack = React18.memo(function WavyLinearTrack2({
1051
1063
  "div",
1052
1064
  {
1053
1065
  ref: containerRef,
1054
- className: "relative w-full overflow-hidden",
1066
+ className: "relative w-full",
1055
1067
  style: { height: svgHeight },
1056
1068
  children: width > 0 && /* @__PURE__ */ jsxs(
1057
1069
  "svg",
@@ -1105,7 +1117,7 @@ var LinearProgress = React18.forwardRef(
1105
1117
  waveSpeed = 1,
1106
1118
  crawlerSpeed = 1,
1107
1119
  determinateAnimation = "md3",
1108
- indeterminateAnimation = "continuous",
1120
+ indeterminateAnimation = "md3",
1109
1121
  gapSize = 4,
1110
1122
  showStopIndicator = "auto",
1111
1123
  color,
@@ -1142,15 +1154,15 @@ var LinearProgress = React18.forwardRef(
1142
1154
  setIsRtl(dir === "rtl");
1143
1155
  }
1144
1156
  }, []);
1145
- const isWavy = shape === "wavy";
1146
1157
  const resolvedTrackShape = trackShape != null ? trackShape : shape;
1158
+ const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
1147
1159
  const effectiveAmplitude = React18.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
1148
1160
  const svgHeight = React18.useMemo(
1149
1161
  () => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
1150
1162
  [isWavy, trackHeight, effectiveAmplitude]
1151
1163
  );
1152
1164
  const shouldShowStop = React18.useMemo(
1153
- () => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
1165
+ () => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
1154
1166
  [isDeterminate, resolvedTrackShape, showStopIndicator]
1155
1167
  );
1156
1168
  const stopSize = React18.useMemo(
@@ -1160,6 +1172,8 @@ var LinearProgress = React18.forwardRef(
1160
1172
  const stopOffset = (trackHeight - stopSize) / 2;
1161
1173
  const activeColor = color || "var(--md-sys-color-indicator-active)";
1162
1174
  const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
1175
+ const useWavyTrack = isWavy || !isDeterminate;
1176
+ const trackAmp = isWavy ? effectiveAmplitude : 0;
1163
1177
  return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
1164
1178
  "div",
1165
1179
  __spreadProps(__spreadValues({
@@ -1176,12 +1190,12 @@ var LinearProgress = React18.forwardRef(
1176
1190
  style: { height: svgHeight }
1177
1191
  }, restProps), {
1178
1192
  children: [
1179
- isWavy ? /* @__PURE__ */ jsx(
1193
+ useWavyTrack ? /* @__PURE__ */ jsx(
1180
1194
  WavyLinearTrack,
1181
1195
  {
1182
1196
  trackHeight,
1183
1197
  svgHeight,
1184
- amplitude: effectiveAmplitude,
1198
+ amplitude: trackAmp,
1185
1199
  wavelength,
1186
1200
  indeterminateWavelength,
1187
1201
  activeColor,