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