@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/pickers.mjs CHANGED
@@ -712,24 +712,36 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
712
712
  if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
713
713
  d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
714
714
  }
715
- d += " Z";
716
715
  return d;
717
716
  }
718
717
  function getSinePath(startX, endX, phase, wl, amp) {
719
718
  if (startX >= endX) return "";
720
- let d = "";
721
- const step = amp === 0 ? Math.max(10, endX - startX) : 1;
722
- const yStart = Math.sin((startX + phase) / wl * 2 * Math.PI) * amp;
723
- d += `M ${startX.toFixed(2)} ${yStart.toFixed(2)}`;
724
- let nextX = Math.ceil(startX / step) * step;
725
- if (nextX === startX) nextX += step;
726
- while (nextX < endX) {
727
- const y = Math.sin((nextX + phase) / wl * 2 * Math.PI) * amp;
728
- d += ` L ${nextX.toFixed(2)} ${y.toFixed(2)}`;
729
- nextX += step;
719
+ if (amp <= 0.01) {
720
+ return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
721
+ }
722
+ const safeWl = Math.max(1, wl);
723
+ const k = 2 * Math.PI / safeWl;
724
+ const phi = phase / safeWl * 2 * Math.PI;
725
+ const yAt = (x) => amp * Math.sin(k * x + phi);
726
+ const dyAt = (x) => amp * k * Math.cos(k * x + phi);
727
+ const step = safeWl / 4;
728
+ let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
729
+ let currentX = startX;
730
+ while (currentX < endX) {
731
+ const nextX = Math.min(endX, currentX + step);
732
+ const dx = nextX - currentX;
733
+ const scale = dx / 3;
734
+ const y0 = yAt(currentX);
735
+ const dy0 = dyAt(currentX);
736
+ const y1 = yAt(nextX);
737
+ const dy1 = dyAt(nextX);
738
+ const cp1x = currentX + scale;
739
+ const cp1y = y0 + scale * dy0;
740
+ const cp2x = nextX - scale;
741
+ const cp2y = y1 - scale * dy1;
742
+ d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
743
+ currentX = nextX;
730
744
  }
731
- const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
732
- d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
733
745
  return d;
734
746
  }
735
747
  var CircularProgress = React13.forwardRef(
@@ -884,16 +896,13 @@ var CircularProgress = React13.forwardRef(
884
896
  position: "absolute",
885
897
  inset: 0,
886
898
  overflow: "visible",
887
- rotate: "-90deg",
888
899
  transformOrigin: "center"
889
900
  },
890
- animate: { rotate: ["-90deg", "270deg"] },
901
+ animate: { rotate: [0, 360] },
891
902
  transition: {
892
- rotate: {
893
- duration: 2 / Math.max(0.1, crawlerSpeed),
894
- repeat: Number.POSITIVE_INFINITY,
895
- ease: "linear"
896
- }
903
+ duration: 2 / Math.max(0.1, crawlerSpeed),
904
+ repeat: Number.POSITIVE_INFINITY,
905
+ ease: "linear"
897
906
  },
898
907
  children: [
899
908
  /* @__PURE__ */ jsx(
@@ -906,17 +915,16 @@ var CircularProgress = React13.forwardRef(
906
915
  stroke: bgTrackColor,
907
916
  strokeWidth: trackHeight,
908
917
  strokeLinecap: "round",
909
- style: { originX: "50%", originY: "50%" },
910
918
  animate: {
911
919
  pathLength: [
912
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
913
- Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
914
- Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
920
+ Math.max(1e-3, 0.9 - 2 * gapForTrack),
921
+ Math.max(1e-3, 0.25 - 2 * gapForTrack),
922
+ Math.max(1e-3, 0.9 - 2 * gapForTrack)
915
923
  ],
916
- rotate: [
917
- `${(0.1 + gapForTrack) * 360}deg`,
918
- `${(1 + gapForTrack) * 360}deg`,
919
- `${(1.1 + gapForTrack) * 360}deg`
924
+ pathOffset: [
925
+ 0.1 + gapForTrack,
926
+ 0.75 + gapForTrack,
927
+ 0.1 + gapForTrack
920
928
  ]
921
929
  },
922
930
  transition: {
@@ -934,10 +942,9 @@ var CircularProgress = React13.forwardRef(
934
942
  stroke: activeColor,
935
943
  strokeWidth: trackHeight,
936
944
  strokeLinecap: "round",
937
- style: { originX: "50%", originY: "50%" },
938
945
  animate: {
939
946
  pathLength: [0.1, 0.75, 0.1],
940
- rotate: ["0deg", "90deg", "360deg"]
947
+ pathOffset: [0, 0.65, 1]
941
948
  },
942
949
  transition: {
943
950
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -955,10 +962,9 @@ var CircularProgress = React13.forwardRef(
955
962
  stroke: activeColor,
956
963
  strokeWidth: trackHeight,
957
964
  strokeLinecap: "round",
958
- style: { originX: "50%", originY: "50%" },
959
965
  animate: {
960
966
  pathLength: [0.1, 0.75, 0.1],
961
- rotate: ["0deg", "90deg", "360deg"]
967
+ pathOffset: [0, 0.65, 1]
962
968
  },
963
969
  transition: {
964
970
  duration: 2 / Math.max(0.1, crawlerSpeed),
@@ -1131,6 +1137,12 @@ var WavyLinearTrack = React13.memo(function WavyLinearTrack2({
1131
1137
  duration: 0.5
1132
1138
  });
1133
1139
  animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
1140
+ } else {
1141
+ animate(amplitudeMV, amplitude, {
1142
+ type: "spring",
1143
+ bounce: 0,
1144
+ duration: 0.5
1145
+ });
1134
1146
  }
1135
1147
  }, [
1136
1148
  clampedValue,
@@ -1144,10 +1156,10 @@ var WavyLinearTrack = React13.memo(function WavyLinearTrack2({
1144
1156
  1,
1145
1157
  isDeterminate ? wavelength : indeterminateWavelength
1146
1158
  );
1147
- const trackAmp = trackShape === "wavy" ? amplitude : 0;
1148
1159
  useAnimationFrame((time) => {
1149
1160
  if (width === 0) return;
1150
1161
  const currentAmp = amplitudeMV.get();
1162
+ const trackAmp = trackShape === "wavy" ? amplitude : 0;
1151
1163
  const phase = time / 1e3 * waveSpeed * activeWavelength;
1152
1164
  const capWidth = trackHeight / 2;
1153
1165
  let activePathD = "";
@@ -1248,7 +1260,7 @@ var WavyLinearTrack = React13.memo(function WavyLinearTrack2({
1248
1260
  "div",
1249
1261
  {
1250
1262
  ref: containerRef,
1251
- className: "relative w-full overflow-hidden",
1263
+ className: "relative w-full",
1252
1264
  style: { height: svgHeight },
1253
1265
  children: width > 0 && /* @__PURE__ */ jsxs(
1254
1266
  "svg",
@@ -1302,7 +1314,7 @@ var LinearProgress = React13.forwardRef(
1302
1314
  waveSpeed = 1,
1303
1315
  crawlerSpeed = 1,
1304
1316
  determinateAnimation = "md3",
1305
- indeterminateAnimation = "continuous",
1317
+ indeterminateAnimation = "md3",
1306
1318
  gapSize = 4,
1307
1319
  showStopIndicator = "auto",
1308
1320
  color,
@@ -1339,15 +1351,15 @@ var LinearProgress = React13.forwardRef(
1339
1351
  setIsRtl(dir === "rtl");
1340
1352
  }
1341
1353
  }, []);
1342
- const isWavy = shape === "wavy";
1343
1354
  const resolvedTrackShape = trackShape != null ? trackShape : shape;
1355
+ const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
1344
1356
  const effectiveAmplitude = React13.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
1345
1357
  const svgHeight = React13.useMemo(
1346
1358
  () => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
1347
1359
  [isWavy, trackHeight, effectiveAmplitude]
1348
1360
  );
1349
1361
  const shouldShowStop = React13.useMemo(
1350
- () => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
1362
+ () => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
1351
1363
  [isDeterminate, resolvedTrackShape, showStopIndicator]
1352
1364
  );
1353
1365
  const stopSize = React13.useMemo(
@@ -1357,6 +1369,8 @@ var LinearProgress = React13.forwardRef(
1357
1369
  const stopOffset = (trackHeight - stopSize) / 2;
1358
1370
  const activeColor = color || "var(--md-sys-color-indicator-active)";
1359
1371
  const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
1372
+ const useWavyTrack = isWavy || !isDeterminate;
1373
+ const trackAmp = isWavy ? effectiveAmplitude : 0;
1360
1374
  return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
1361
1375
  "div",
1362
1376
  __spreadProps(__spreadValues({
@@ -1373,12 +1387,12 @@ var LinearProgress = React13.forwardRef(
1373
1387
  style: { height: svgHeight }
1374
1388
  }, restProps), {
1375
1389
  children: [
1376
- isWavy ? /* @__PURE__ */ jsx(
1390
+ useWavyTrack ? /* @__PURE__ */ jsx(
1377
1391
  WavyLinearTrack,
1378
1392
  {
1379
1393
  trackHeight,
1380
1394
  svgHeight,
1381
- amplitude: effectiveAmplitude,
1395
+ amplitude: trackAmp,
1382
1396
  wavelength,
1383
1397
  indeterminateWavelength,
1384
1398
  activeColor,