@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.js CHANGED
@@ -281,24 +281,36 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
281
281
  if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
282
282
  d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
283
283
  }
284
- d += " Z";
285
284
  return d;
286
285
  }
287
286
  function getSinePath(startX, endX, phase, wl, amp) {
288
287
  if (startX >= endX) return "";
289
- let d = "";
290
- const step = amp === 0 ? Math.max(10, endX - startX) : 1;
291
- const yStart = Math.sin((startX + phase) / wl * 2 * Math.PI) * amp;
292
- d += `M ${startX.toFixed(2)} ${yStart.toFixed(2)}`;
293
- let nextX = Math.ceil(startX / step) * step;
294
- if (nextX === startX) nextX += step;
295
- while (nextX < endX) {
296
- const y = Math.sin((nextX + phase) / wl * 2 * Math.PI) * amp;
297
- d += ` L ${nextX.toFixed(2)} ${y.toFixed(2)}`;
298
- nextX += step;
288
+ if (amp <= 0.01) {
289
+ return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
290
+ }
291
+ const safeWl = Math.max(1, wl);
292
+ const k = 2 * Math.PI / safeWl;
293
+ const phi = phase / safeWl * 2 * Math.PI;
294
+ const yAt = (x) => amp * Math.sin(k * x + phi);
295
+ const dyAt = (x) => amp * k * Math.cos(k * x + phi);
296
+ const step = safeWl / 4;
297
+ let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
298
+ let currentX = startX;
299
+ while (currentX < endX) {
300
+ const nextX = Math.min(endX, currentX + step);
301
+ const dx = nextX - currentX;
302
+ const scale = dx / 3;
303
+ const y0 = yAt(currentX);
304
+ const dy0 = dyAt(currentX);
305
+ const y1 = yAt(nextX);
306
+ const dy1 = dyAt(nextX);
307
+ const cp1x = currentX + scale;
308
+ const cp1y = y0 + scale * dy0;
309
+ const cp2x = nextX - scale;
310
+ const cp2y = y1 - scale * dy1;
311
+ d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
312
+ currentX = nextX;
299
313
  }
300
- const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
301
- d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
302
314
  return d;
303
315
  }
304
316
  var CircularProgress = React9__namespace.forwardRef(
@@ -453,16 +465,13 @@ var CircularProgress = React9__namespace.forwardRef(
453
465
  position: "absolute",
454
466
  inset: 0,
455
467
  overflow: "visible",
456
- rotate: "-90deg",
457
468
  transformOrigin: "center"
458
469
  },
459
- animate: { rotate: ["-90deg", "270deg"] },
470
+ animate: { rotate: [0, 360] },
460
471
  transition: {
461
- rotate: {
462
- duration: 2 / Math.max(0.1, crawlerSpeed),
463
- repeat: Number.POSITIVE_INFINITY,
464
- ease: "linear"
465
- }
472
+ duration: 2 / Math.max(0.1, crawlerSpeed),
473
+ repeat: Number.POSITIVE_INFINITY,
474
+ ease: "linear"
466
475
  },
467
476
  children: [
468
477
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -475,17 +484,16 @@ var CircularProgress = React9__namespace.forwardRef(
475
484
  stroke: bgTrackColor,
476
485
  strokeWidth: trackHeight,
477
486
  strokeLinecap: "round",
478
- style: { originX: "50%", originY: "50%" },
479
487
  animate: {
480
488
  pathLength: [
481
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
482
- Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
483
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
489
+ Math.max(1e-3, 0.9 - 2 * gapForTrack),
490
+ Math.max(1e-3, 0.25 - 2 * gapForTrack),
491
+ Math.max(1e-3, 0.9 - 2 * gapForTrack)
484
492
  ],
485
- rotate: [
486
- `${(0.1 + gapForTrack) * 360}deg`,
487
- `${(1 + gapForTrack) * 360}deg`,
488
- `${(1.1 + gapForTrack) * 360}deg`
493
+ pathOffset: [
494
+ 0.1 + gapForTrack,
495
+ 0.75 + gapForTrack,
496
+ 0.1 + gapForTrack
489
497
  ]
490
498
  },
491
499
  transition: {
@@ -503,10 +511,9 @@ var CircularProgress = React9__namespace.forwardRef(
503
511
  stroke: activeColor,
504
512
  strokeWidth: trackHeight,
505
513
  strokeLinecap: "round",
506
- style: { originX: "50%", originY: "50%" },
507
514
  animate: {
508
515
  pathLength: [0.1, 0.75, 0.1],
509
- rotate: ["0deg", "90deg", "360deg"]
516
+ pathOffset: [0, 0.65, 1]
510
517
  },
511
518
  transition: {
512
519
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -524,10 +531,9 @@ var CircularProgress = React9__namespace.forwardRef(
524
531
  stroke: activeColor,
525
532
  strokeWidth: trackHeight,
526
533
  strokeLinecap: "round",
527
- style: { originX: "50%", originY: "50%" },
528
534
  animate: {
529
535
  pathLength: [0.1, 0.75, 0.1],
530
- rotate: ["0deg", "90deg", "360deg"]
536
+ pathOffset: [0, 0.65, 1]
531
537
  },
532
538
  transition: {
533
539
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -700,6 +706,12 @@ var WavyLinearTrack = React9__namespace.memo(function WavyLinearTrack2({
700
706
  duration: 0.5
701
707
  });
702
708
  react.animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
709
+ } else {
710
+ react.animate(amplitudeMV, amplitude, {
711
+ type: "spring",
712
+ bounce: 0,
713
+ duration: 0.5
714
+ });
703
715
  }
704
716
  }, [
705
717
  clampedValue,
@@ -713,10 +725,10 @@ var WavyLinearTrack = React9__namespace.memo(function WavyLinearTrack2({
713
725
  1,
714
726
  isDeterminate ? wavelength : indeterminateWavelength
715
727
  );
716
- const trackAmp = trackShape === "wavy" ? amplitude : 0;
717
728
  react.useAnimationFrame((time) => {
718
729
  if (width === 0) return;
719
730
  const currentAmp = amplitudeMV.get();
731
+ const trackAmp = trackShape === "wavy" ? amplitude : 0;
720
732
  const phase = time / 1e3 * waveSpeed * activeWavelength;
721
733
  const capWidth = trackHeight / 2;
722
734
  let activePathD = "";
@@ -817,7 +829,7 @@ var WavyLinearTrack = React9__namespace.memo(function WavyLinearTrack2({
817
829
  "div",
818
830
  {
819
831
  ref: containerRef,
820
- className: "relative w-full overflow-hidden",
832
+ className: "relative w-full",
821
833
  style: { height: svgHeight },
822
834
  children: width > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
823
835
  "svg",
@@ -871,7 +883,7 @@ var LinearProgress = React9__namespace.forwardRef(
871
883
  waveSpeed = 1,
872
884
  crawlerSpeed = 1,
873
885
  determinateAnimation = "md3",
874
- indeterminateAnimation = "continuous",
886
+ indeterminateAnimation = "md3",
875
887
  gapSize = 4,
876
888
  showStopIndicator = "auto",
877
889
  color,
@@ -908,15 +920,15 @@ var LinearProgress = React9__namespace.forwardRef(
908
920
  setIsRtl(dir === "rtl");
909
921
  }
910
922
  }, []);
911
- const isWavy = shape === "wavy";
912
923
  const resolvedTrackShape = trackShape != null ? trackShape : shape;
924
+ const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
913
925
  const effectiveAmplitude = React9__namespace.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
914
926
  const svgHeight = React9__namespace.useMemo(
915
927
  () => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
916
928
  [isWavy, trackHeight, effectiveAmplitude]
917
929
  );
918
930
  const shouldShowStop = React9__namespace.useMemo(
919
- () => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
931
+ () => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
920
932
  [isDeterminate, resolvedTrackShape, showStopIndicator]
921
933
  );
922
934
  const stopSize = React9__namespace.useMemo(
@@ -926,6 +938,8 @@ var LinearProgress = React9__namespace.forwardRef(
926
938
  const stopOffset = (trackHeight - stopSize) / 2;
927
939
  const activeColor = color || "var(--md-sys-color-indicator-active)";
928
940
  const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
941
+ const useWavyTrack = isWavy || !isDeterminate;
942
+ const trackAmp = isWavy ? effectiveAmplitude : 0;
929
943
  return /* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domMax, strict: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
930
944
  "div",
931
945
  __spreadProps(__spreadValues({
@@ -942,12 +956,12 @@ var LinearProgress = React9__namespace.forwardRef(
942
956
  style: { height: svgHeight }
943
957
  }, restProps), {
944
958
  children: [
945
- isWavy ? /* @__PURE__ */ jsxRuntime.jsx(
959
+ useWavyTrack ? /* @__PURE__ */ jsxRuntime.jsx(
946
960
  WavyLinearTrack,
947
961
  {
948
962
  trackHeight,
949
963
  svgHeight,
950
- amplitude: effectiveAmplitude,
964
+ amplitude: trackAmp,
951
965
  wavelength,
952
966
  indeterminateWavelength,
953
967
  activeColor,