@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/index.mjs CHANGED
@@ -5689,24 +5689,36 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
5689
5689
  if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
5690
5690
  d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
5691
5691
  }
5692
- d += " Z";
5693
5692
  return d;
5694
5693
  }
5695
5694
  function getSinePath(startX, endX, phase, wl, amp) {
5696
5695
  if (startX >= endX) return "";
5697
- let d = "";
5698
- const step = amp === 0 ? Math.max(10, endX - startX) : 1;
5699
- const yStart = Math.sin((startX + phase) / wl * 2 * Math.PI) * amp;
5700
- d += `M ${startX.toFixed(2)} ${yStart.toFixed(2)}`;
5701
- let nextX = Math.ceil(startX / step) * step;
5702
- if (nextX === startX) nextX += step;
5703
- while (nextX < endX) {
5704
- const y = Math.sin((nextX + phase) / wl * 2 * Math.PI) * amp;
5705
- d += ` L ${nextX.toFixed(2)} ${y.toFixed(2)}`;
5706
- nextX += step;
5707
- }
5708
- const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
5709
- d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
5696
+ if (amp <= 0.01) {
5697
+ return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
5698
+ }
5699
+ const safeWl = Math.max(1, wl);
5700
+ const k = 2 * Math.PI / safeWl;
5701
+ const phi = phase / safeWl * 2 * Math.PI;
5702
+ const yAt = (x) => amp * Math.sin(k * x + phi);
5703
+ const dyAt = (x) => amp * k * Math.cos(k * x + phi);
5704
+ const step = safeWl / 4;
5705
+ let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
5706
+ let currentX = startX;
5707
+ while (currentX < endX) {
5708
+ const nextX = Math.min(endX, currentX + step);
5709
+ const dx = nextX - currentX;
5710
+ const scale = dx / 3;
5711
+ const y0 = yAt(currentX);
5712
+ const dy0 = dyAt(currentX);
5713
+ const y1 = yAt(nextX);
5714
+ const dy1 = dyAt(nextX);
5715
+ const cp1x = currentX + scale;
5716
+ const cp1y = y0 + scale * dy0;
5717
+ const cp2x = nextX - scale;
5718
+ const cp2y = y1 - scale * dy1;
5719
+ d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
5720
+ currentX = nextX;
5721
+ }
5710
5722
  return d;
5711
5723
  }
5712
5724
  var CircularProgress = React62.forwardRef(
@@ -5861,16 +5873,13 @@ var CircularProgress = React62.forwardRef(
5861
5873
  position: "absolute",
5862
5874
  inset: 0,
5863
5875
  overflow: "visible",
5864
- rotate: "-90deg",
5865
5876
  transformOrigin: "center"
5866
5877
  },
5867
- animate: { rotate: ["-90deg", "270deg"] },
5878
+ animate: { rotate: [0, 360] },
5868
5879
  transition: {
5869
- rotate: {
5870
- duration: 2 / Math.max(0.1, crawlerSpeed),
5871
- repeat: Number.POSITIVE_INFINITY,
5872
- ease: "linear"
5873
- }
5880
+ duration: 2 / Math.max(0.1, crawlerSpeed),
5881
+ repeat: Number.POSITIVE_INFINITY,
5882
+ ease: "linear"
5874
5883
  },
5875
5884
  children: [
5876
5885
  /* @__PURE__ */ jsx(
@@ -5883,17 +5892,16 @@ var CircularProgress = React62.forwardRef(
5883
5892
  stroke: bgTrackColor,
5884
5893
  strokeWidth: trackHeight,
5885
5894
  strokeLinecap: "round",
5886
- style: { originX: "50%", originY: "50%" },
5887
5895
  animate: {
5888
5896
  pathLength: [
5889
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
5890
- Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
5891
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
5897
+ Math.max(1e-3, 0.9 - 2 * gapForTrack),
5898
+ Math.max(1e-3, 0.25 - 2 * gapForTrack),
5899
+ Math.max(1e-3, 0.9 - 2 * gapForTrack)
5892
5900
  ],
5893
- rotate: [
5894
- `${(0.1 + gapForTrack) * 360}deg`,
5895
- `${(1 + gapForTrack) * 360}deg`,
5896
- `${(1.1 + gapForTrack) * 360}deg`
5901
+ pathOffset: [
5902
+ 0.1 + gapForTrack,
5903
+ 0.75 + gapForTrack,
5904
+ 0.1 + gapForTrack
5897
5905
  ]
5898
5906
  },
5899
5907
  transition: {
@@ -5911,10 +5919,9 @@ var CircularProgress = React62.forwardRef(
5911
5919
  stroke: activeColor,
5912
5920
  strokeWidth: trackHeight,
5913
5921
  strokeLinecap: "round",
5914
- style: { originX: "50%", originY: "50%" },
5915
5922
  animate: {
5916
5923
  pathLength: [0.1, 0.75, 0.1],
5917
- rotate: ["0deg", "90deg", "360deg"]
5924
+ pathOffset: [0, 0.65, 1]
5918
5925
  },
5919
5926
  transition: {
5920
5927
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -5932,10 +5939,9 @@ var CircularProgress = React62.forwardRef(
5932
5939
  stroke: activeColor,
5933
5940
  strokeWidth: trackHeight,
5934
5941
  strokeLinecap: "round",
5935
- style: { originX: "50%", originY: "50%" },
5936
5942
  animate: {
5937
5943
  pathLength: [0.1, 0.75, 0.1],
5938
- rotate: ["0deg", "90deg", "360deg"]
5944
+ pathOffset: [0, 0.65, 1]
5939
5945
  },
5940
5946
  transition: {
5941
5947
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -6108,6 +6114,12 @@ var WavyLinearTrack = React62.memo(function WavyLinearTrack2({
6108
6114
  duration: 0.5
6109
6115
  });
6110
6116
  animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
6117
+ } else {
6118
+ animate(amplitudeMV, amplitude, {
6119
+ type: "spring",
6120
+ bounce: 0,
6121
+ duration: 0.5
6122
+ });
6111
6123
  }
6112
6124
  }, [
6113
6125
  clampedValue,
@@ -6121,10 +6133,10 @@ var WavyLinearTrack = React62.memo(function WavyLinearTrack2({
6121
6133
  1,
6122
6134
  isDeterminate ? wavelength : indeterminateWavelength
6123
6135
  );
6124
- const trackAmp = trackShape === "wavy" ? amplitude : 0;
6125
6136
  useAnimationFrame((time) => {
6126
6137
  if (width === 0) return;
6127
6138
  const currentAmp = amplitudeMV.get();
6139
+ const trackAmp = trackShape === "wavy" ? amplitude : 0;
6128
6140
  const phase = time / 1e3 * waveSpeed * activeWavelength;
6129
6141
  const capWidth = trackHeight / 2;
6130
6142
  let activePathD = "";
@@ -6225,7 +6237,7 @@ var WavyLinearTrack = React62.memo(function WavyLinearTrack2({
6225
6237
  "div",
6226
6238
  {
6227
6239
  ref: containerRef,
6228
- className: "relative w-full overflow-hidden",
6240
+ className: "relative w-full",
6229
6241
  style: { height: svgHeight },
6230
6242
  children: width > 0 && /* @__PURE__ */ jsxs(
6231
6243
  "svg",
@@ -6279,7 +6291,7 @@ var LinearProgress = React62.forwardRef(
6279
6291
  waveSpeed = 1,
6280
6292
  crawlerSpeed = 1,
6281
6293
  determinateAnimation = "md3",
6282
- indeterminateAnimation = "continuous",
6294
+ indeterminateAnimation = "md3",
6283
6295
  gapSize = 4,
6284
6296
  showStopIndicator = "auto",
6285
6297
  color,
@@ -6316,15 +6328,15 @@ var LinearProgress = React62.forwardRef(
6316
6328
  setIsRtl(dir === "rtl");
6317
6329
  }
6318
6330
  }, []);
6319
- const isWavy = shape === "wavy";
6320
6331
  const resolvedTrackShape = trackShape != null ? trackShape : shape;
6332
+ const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
6321
6333
  const effectiveAmplitude = React62.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
6322
6334
  const svgHeight = React62.useMemo(
6323
6335
  () => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
6324
6336
  [isWavy, trackHeight, effectiveAmplitude]
6325
6337
  );
6326
6338
  const shouldShowStop = React62.useMemo(
6327
- () => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
6339
+ () => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
6328
6340
  [isDeterminate, resolvedTrackShape, showStopIndicator]
6329
6341
  );
6330
6342
  const stopSize = React62.useMemo(
@@ -6334,6 +6346,8 @@ var LinearProgress = React62.forwardRef(
6334
6346
  const stopOffset = (trackHeight - stopSize) / 2;
6335
6347
  const activeColor = color || "var(--md-sys-color-indicator-active)";
6336
6348
  const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
6349
+ const useWavyTrack = isWavy || !isDeterminate;
6350
+ const trackAmp = isWavy ? effectiveAmplitude : 0;
6337
6351
  return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
6338
6352
  "div",
6339
6353
  __spreadProps(__spreadValues({
@@ -6350,12 +6364,12 @@ var LinearProgress = React62.forwardRef(
6350
6364
  style: { height: svgHeight }
6351
6365
  }, restProps), {
6352
6366
  children: [
6353
- isWavy ? /* @__PURE__ */ jsx(
6367
+ useWavyTrack ? /* @__PURE__ */ jsx(
6354
6368
  WavyLinearTrack,
6355
6369
  {
6356
6370
  trackHeight,
6357
6371
  svgHeight,
6358
- amplitude: effectiveAmplitude,
6372
+ amplitude: trackAmp,
6359
6373
  wavelength,
6360
6374
  indeterminateWavelength,
6361
6375
  activeColor,