@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/overlays.mjs CHANGED
@@ -258,24 +258,36 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
258
258
  if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
259
259
  d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
260
260
  }
261
- d += " Z";
262
261
  return d;
263
262
  }
264
263
  function getSinePath(startX, endX, phase, wl, amp) {
265
264
  if (startX >= endX) return "";
266
- let d = "";
267
- const step = amp === 0 ? Math.max(10, endX - startX) : 1;
268
- const yStart = Math.sin((startX + phase) / wl * 2 * Math.PI) * amp;
269
- d += `M ${startX.toFixed(2)} ${yStart.toFixed(2)}`;
270
- let nextX = Math.ceil(startX / step) * step;
271
- if (nextX === startX) nextX += step;
272
- while (nextX < endX) {
273
- const y = Math.sin((nextX + phase) / wl * 2 * Math.PI) * amp;
274
- d += ` L ${nextX.toFixed(2)} ${y.toFixed(2)}`;
275
- nextX += step;
265
+ if (amp <= 0.01) {
266
+ return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
267
+ }
268
+ const safeWl = Math.max(1, wl);
269
+ const k = 2 * Math.PI / safeWl;
270
+ const phi = phase / safeWl * 2 * Math.PI;
271
+ const yAt = (x) => amp * Math.sin(k * x + phi);
272
+ const dyAt = (x) => amp * k * Math.cos(k * x + phi);
273
+ const step = safeWl / 4;
274
+ let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
275
+ let currentX = startX;
276
+ while (currentX < endX) {
277
+ const nextX = Math.min(endX, currentX + step);
278
+ const dx = nextX - currentX;
279
+ const scale = dx / 3;
280
+ const y0 = yAt(currentX);
281
+ const dy0 = dyAt(currentX);
282
+ const y1 = yAt(nextX);
283
+ const dy1 = dyAt(nextX);
284
+ const cp1x = currentX + scale;
285
+ const cp1y = y0 + scale * dy0;
286
+ const cp2x = nextX - scale;
287
+ const cp2y = y1 - scale * dy1;
288
+ d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
289
+ currentX = nextX;
276
290
  }
277
- const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
278
- d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
279
291
  return d;
280
292
  }
281
293
  var CircularProgress = React9.forwardRef(
@@ -430,16 +442,13 @@ var CircularProgress = React9.forwardRef(
430
442
  position: "absolute",
431
443
  inset: 0,
432
444
  overflow: "visible",
433
- rotate: "-90deg",
434
445
  transformOrigin: "center"
435
446
  },
436
- animate: { rotate: ["-90deg", "270deg"] },
447
+ animate: { rotate: [0, 360] },
437
448
  transition: {
438
- rotate: {
439
- duration: 2 / Math.max(0.1, crawlerSpeed),
440
- repeat: Number.POSITIVE_INFINITY,
441
- ease: "linear"
442
- }
449
+ duration: 2 / Math.max(0.1, crawlerSpeed),
450
+ repeat: Number.POSITIVE_INFINITY,
451
+ ease: "linear"
443
452
  },
444
453
  children: [
445
454
  /* @__PURE__ */ jsx(
@@ -452,17 +461,16 @@ var CircularProgress = React9.forwardRef(
452
461
  stroke: bgTrackColor,
453
462
  strokeWidth: trackHeight,
454
463
  strokeLinecap: "round",
455
- style: { originX: "50%", originY: "50%" },
456
464
  animate: {
457
465
  pathLength: [
458
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
459
- Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
460
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
466
+ Math.max(1e-3, 0.9 - 2 * gapForTrack),
467
+ Math.max(1e-3, 0.25 - 2 * gapForTrack),
468
+ Math.max(1e-3, 0.9 - 2 * gapForTrack)
461
469
  ],
462
- rotate: [
463
- `${(0.1 + gapForTrack) * 360}deg`,
464
- `${(1 + gapForTrack) * 360}deg`,
465
- `${(1.1 + gapForTrack) * 360}deg`
470
+ pathOffset: [
471
+ 0.1 + gapForTrack,
472
+ 0.75 + gapForTrack,
473
+ 0.1 + gapForTrack
466
474
  ]
467
475
  },
468
476
  transition: {
@@ -480,10 +488,9 @@ var CircularProgress = React9.forwardRef(
480
488
  stroke: activeColor,
481
489
  strokeWidth: trackHeight,
482
490
  strokeLinecap: "round",
483
- style: { originX: "50%", originY: "50%" },
484
491
  animate: {
485
492
  pathLength: [0.1, 0.75, 0.1],
486
- rotate: ["0deg", "90deg", "360deg"]
493
+ pathOffset: [0, 0.65, 1]
487
494
  },
488
495
  transition: {
489
496
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -501,10 +508,9 @@ var CircularProgress = React9.forwardRef(
501
508
  stroke: activeColor,
502
509
  strokeWidth: trackHeight,
503
510
  strokeLinecap: "round",
504
- style: { originX: "50%", originY: "50%" },
505
511
  animate: {
506
512
  pathLength: [0.1, 0.75, 0.1],
507
- rotate: ["0deg", "90deg", "360deg"]
513
+ pathOffset: [0, 0.65, 1]
508
514
  },
509
515
  transition: {
510
516
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -677,6 +683,12 @@ var WavyLinearTrack = React9.memo(function WavyLinearTrack2({
677
683
  duration: 0.5
678
684
  });
679
685
  animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
686
+ } else {
687
+ animate(amplitudeMV, amplitude, {
688
+ type: "spring",
689
+ bounce: 0,
690
+ duration: 0.5
691
+ });
680
692
  }
681
693
  }, [
682
694
  clampedValue,
@@ -690,10 +702,10 @@ var WavyLinearTrack = React9.memo(function WavyLinearTrack2({
690
702
  1,
691
703
  isDeterminate ? wavelength : indeterminateWavelength
692
704
  );
693
- const trackAmp = trackShape === "wavy" ? amplitude : 0;
694
705
  useAnimationFrame((time) => {
695
706
  if (width === 0) return;
696
707
  const currentAmp = amplitudeMV.get();
708
+ const trackAmp = trackShape === "wavy" ? amplitude : 0;
697
709
  const phase = time / 1e3 * waveSpeed * activeWavelength;
698
710
  const capWidth = trackHeight / 2;
699
711
  let activePathD = "";
@@ -794,7 +806,7 @@ var WavyLinearTrack = React9.memo(function WavyLinearTrack2({
794
806
  "div",
795
807
  {
796
808
  ref: containerRef,
797
- className: "relative w-full overflow-hidden",
809
+ className: "relative w-full",
798
810
  style: { height: svgHeight },
799
811
  children: width > 0 && /* @__PURE__ */ jsxs(
800
812
  "svg",
@@ -848,7 +860,7 @@ var LinearProgress = React9.forwardRef(
848
860
  waveSpeed = 1,
849
861
  crawlerSpeed = 1,
850
862
  determinateAnimation = "md3",
851
- indeterminateAnimation = "continuous",
863
+ indeterminateAnimation = "md3",
852
864
  gapSize = 4,
853
865
  showStopIndicator = "auto",
854
866
  color,
@@ -885,15 +897,15 @@ var LinearProgress = React9.forwardRef(
885
897
  setIsRtl(dir === "rtl");
886
898
  }
887
899
  }, []);
888
- const isWavy = shape === "wavy";
889
900
  const resolvedTrackShape = trackShape != null ? trackShape : shape;
901
+ const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
890
902
  const effectiveAmplitude = React9.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
891
903
  const svgHeight = React9.useMemo(
892
904
  () => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
893
905
  [isWavy, trackHeight, effectiveAmplitude]
894
906
  );
895
907
  const shouldShowStop = React9.useMemo(
896
- () => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
908
+ () => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
897
909
  [isDeterminate, resolvedTrackShape, showStopIndicator]
898
910
  );
899
911
  const stopSize = React9.useMemo(
@@ -903,6 +915,8 @@ var LinearProgress = React9.forwardRef(
903
915
  const stopOffset = (trackHeight - stopSize) / 2;
904
916
  const activeColor = color || "var(--md-sys-color-indicator-active)";
905
917
  const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
918
+ const useWavyTrack = isWavy || !isDeterminate;
919
+ const trackAmp = isWavy ? effectiveAmplitude : 0;
906
920
  return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
907
921
  "div",
908
922
  __spreadProps(__spreadValues({
@@ -919,12 +933,12 @@ var LinearProgress = React9.forwardRef(
919
933
  style: { height: svgHeight }
920
934
  }, restProps), {
921
935
  children: [
922
- isWavy ? /* @__PURE__ */ jsx(
936
+ useWavyTrack ? /* @__PURE__ */ jsx(
923
937
  WavyLinearTrack,
924
938
  {
925
939
  trackHeight,
926
940
  svgHeight,
927
- amplitude: effectiveAmplitude,
941
+ amplitude: trackAmp,
928
942
  wavelength,
929
943
  indeterminateWavelength,
930
944
  activeColor,