@bug-on/m3-expressive 1.2.6 → 1.2.7

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.
@@ -6338,7 +6338,7 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
6338
6338
  if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
6339
6339
  d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
6340
6340
  }
6341
- return d;
6341
+ return `${d} Z`;
6342
6342
  }
6343
6343
  function getSinePath(startX, endX, phase, wl, amp) {
6344
6344
  if (startX >= endX) return "";
@@ -6370,6 +6370,14 @@ function getSinePath(startX, endX, phase, wl, amp) {
6370
6370
  }
6371
6371
  return d;
6372
6372
  }
6373
+ var GLOBAL_ROTATION_DURATION = 6e3;
6374
+ var GLOBAL_ROTATION_TARGET = 1080;
6375
+ var ADDITIONAL_ROTATION_CYCLE = 1500;
6376
+ var ADDITIONAL_ROTATION_STEP = 90;
6377
+ var ADDITIONAL_ROTATION_EASE_DURATION = 500;
6378
+ var DEFAULT_MIN_PROGRESS = 0.1;
6379
+ var DEFAULT_MAX_PROGRESS = 0.8;
6380
+ var PROGRESS_CYCLE_DURATION = 1500;
6373
6381
  var CircularProgress = React37__namespace.forwardRef(
6374
6382
  (_a, ref) => {
6375
6383
  var _b = _a, {
@@ -6383,6 +6391,10 @@ var CircularProgress = React37__namespace.forwardRef(
6383
6391
  crawlerSpeed = 1,
6384
6392
  color,
6385
6393
  trackColor,
6394
+ showTrack = "auto",
6395
+ minProgress = DEFAULT_MIN_PROGRESS,
6396
+ maxProgress = DEFAULT_MAX_PROGRESS,
6397
+ amplitudeRange,
6386
6398
  className,
6387
6399
  "aria-label": ariaLabel
6388
6400
  } = _b, restProps = __objRest(_b, [
@@ -6396,6 +6408,10 @@ var CircularProgress = React37__namespace.forwardRef(
6396
6408
  "crawlerSpeed",
6397
6409
  "color",
6398
6410
  "trackColor",
6411
+ "showTrack",
6412
+ "minProgress",
6413
+ "maxProgress",
6414
+ "amplitudeRange",
6399
6415
  "className",
6400
6416
  "aria-label"
6401
6417
  ]);
@@ -6406,6 +6422,7 @@ var CircularProgress = React37__namespace.forwardRef(
6406
6422
  const activeColor = color || "var(--md-sys-color-indicator-active)";
6407
6423
  const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
6408
6424
  const isWavy = shape === "wavy";
6425
+ const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
6409
6426
  const BASELINE_SIZE = 48;
6410
6427
  const scaleFactor = size / BASELINE_SIZE;
6411
6428
  const effectiveAmplitude = React37__namespace.useMemo(
@@ -6416,6 +6433,10 @@ var CircularProgress = React37__namespace.forwardRef(
6416
6433
  () => wavelength != null ? wavelength : 15 * scaleFactor,
6417
6434
  [wavelength, scaleFactor]
6418
6435
  );
6436
+ const resolvedAmplitudeRange = React37__namespace.useMemo(
6437
+ () => amplitudeRange != null ? amplitudeRange : [0, effectiveAmplitude],
6438
+ [amplitudeRange, effectiveAmplitude]
6439
+ );
6419
6440
  const wavyActivePath = React37__namespace.useMemo(
6420
6441
  () => isWavy ? generateWavyCircularPath(
6421
6442
  center,
@@ -6435,6 +6456,145 @@ var CircularProgress = React37__namespace.forwardRef(
6435
6456
  const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
6436
6457
  const ActiveCircleElem = react.m.circle;
6437
6458
  const ActivePathElem = react.m.path;
6459
+ const indeterminateSvgRef = React37__namespace.useRef(null);
6460
+ const indeterminateTrackRef = React37__namespace.useRef(null);
6461
+ const indeterminateActiveRef = React37__namespace.useRef(null);
6462
+ const indeterminateWavyTrackPathRef = React37__namespace.useRef(null);
6463
+ const indeterminateWavyActivePathRef = React37__namespace.useRef(null);
6464
+ const cachedPathLengthRef = React37__namespace.useRef(0);
6465
+ React37__namespace.useLayoutEffect(() => {
6466
+ if (!isWavy || !wavyActivePath) {
6467
+ cachedPathLengthRef.current = circumference;
6468
+ return;
6469
+ }
6470
+ const el = indeterminateActiveRef.current;
6471
+ if (el && "getTotalLength" in el) {
6472
+ try {
6473
+ const len = el.getTotalLength();
6474
+ if (len > 0) {
6475
+ cachedPathLengthRef.current = len;
6476
+ return;
6477
+ }
6478
+ } catch (e) {
6479
+ }
6480
+ }
6481
+ cachedPathLengthRef.current = circumference;
6482
+ }, [isWavy, circumference, wavyActivePath]);
6483
+ react.useAnimationFrame((time) => {
6484
+ if (isDeterminate) return;
6485
+ const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
6486
+ const scaledTime = time * safeCrawlerSpeed;
6487
+ const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
6488
+ const globalAngle = globalCycle / GLOBAL_ROTATION_DURATION * GLOBAL_ROTATION_TARGET;
6489
+ const additionalFullCycles = Math.floor(
6490
+ scaledTime / ADDITIONAL_ROTATION_CYCLE
6491
+ );
6492
+ const additionalCycleTime = scaledTime % ADDITIONAL_ROTATION_CYCLE;
6493
+ const additionalEaseT = Math.min(
6494
+ 1,
6495
+ additionalCycleTime / ADDITIONAL_ROTATION_EASE_DURATION
6496
+ );
6497
+ const additionalAngle = (additionalFullCycles + easeInOutCubic(additionalEaseT)) * ADDITIONAL_ROTATION_STEP;
6498
+ const totalRotation = globalAngle + additionalAngle;
6499
+ if (indeterminateSvgRef.current) {
6500
+ indeterminateSvgRef.current.style.transform = `rotate(${totalRotation - 90}deg)`;
6501
+ }
6502
+ const progressFullCycle = PROGRESS_CYCLE_DURATION * 2;
6503
+ const progressCycleTime = scaledTime % progressFullCycle;
6504
+ let progress;
6505
+ if (progressCycleTime < PROGRESS_CYCLE_DURATION) {
6506
+ const t = progressCycleTime / PROGRESS_CYCLE_DURATION;
6507
+ progress = minProgress + (maxProgress - minProgress) * easeInOutCubic(t);
6508
+ } else {
6509
+ const t = (progressCycleTime - PROGRESS_CYCLE_DURATION) / PROGRESS_CYCLE_DURATION;
6510
+ progress = maxProgress - (maxProgress - minProgress) * easeInOutCubic(t);
6511
+ }
6512
+ if (isWavy) {
6513
+ const amplitudeT = (progress - minProgress) / (maxProgress - minProgress);
6514
+ const currentAmplitude = resolvedAmplitudeRange[0] + (resolvedAmplitudeRange[1] - resolvedAmplitudeRange[0]) * amplitudeT;
6515
+ const dynamicPath = generateWavyCircularPath(
6516
+ center,
6517
+ radius,
6518
+ currentAmplitude,
6519
+ effectiveWavelength
6520
+ );
6521
+ if (indeterminateWavyActivePathRef.current) {
6522
+ indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
6523
+ }
6524
+ if (indeterminateWavyTrackPathRef.current) {
6525
+ indeterminateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
6526
+ }
6527
+ const pathEl = indeterminateWavyActivePathRef.current;
6528
+ let totalLen = cachedPathLengthRef.current || circumference;
6529
+ if (pathEl) {
6530
+ try {
6531
+ const len = pathEl.getTotalLength();
6532
+ if (len > 0) totalLen = len;
6533
+ } catch (e) {
6534
+ }
6535
+ }
6536
+ const gapFrac = (gapSize + trackHeight) / totalLen;
6537
+ const activeLen = totalLen * progress;
6538
+ const activeOff = 0;
6539
+ if (indeterminateWavyActivePathRef.current) {
6540
+ indeterminateWavyActivePathRef.current.setAttribute(
6541
+ "stroke-dasharray",
6542
+ `${activeLen} ${totalLen}`
6543
+ );
6544
+ indeterminateWavyActivePathRef.current.setAttribute(
6545
+ "stroke-dashoffset",
6546
+ `${activeOff}`
6547
+ );
6548
+ }
6549
+ if (shouldShowIndeterminateTrack && indeterminateWavyTrackPathRef.current) {
6550
+ const trackStartFrac = progress + gapFrac;
6551
+ const trackLen = Math.max(
6552
+ 1e-3,
6553
+ totalLen * (1 - progress - 2 * gapFrac)
6554
+ );
6555
+ const trackOff = -totalLen * trackStartFrac;
6556
+ indeterminateWavyTrackPathRef.current.setAttribute(
6557
+ "stroke-dasharray",
6558
+ `${trackLen} ${totalLen}`
6559
+ );
6560
+ indeterminateWavyTrackPathRef.current.setAttribute(
6561
+ "stroke-dashoffset",
6562
+ `${trackOff}`
6563
+ );
6564
+ }
6565
+ } else {
6566
+ const totalLen = circumference;
6567
+ const activeLen = totalLen * progress;
6568
+ const activeOff = 0;
6569
+ if (indeterminateActiveRef.current) {
6570
+ indeterminateActiveRef.current.setAttribute(
6571
+ "stroke-dasharray",
6572
+ `${activeLen} ${totalLen}`
6573
+ );
6574
+ indeterminateActiveRef.current.setAttribute(
6575
+ "stroke-dashoffset",
6576
+ `${activeOff}`
6577
+ );
6578
+ }
6579
+ if (shouldShowIndeterminateTrack && indeterminateTrackRef.current) {
6580
+ const gapFrac = (gapSize + trackHeight) / totalLen;
6581
+ const trackStartFrac = progress + gapFrac;
6582
+ const trackLen = Math.max(
6583
+ 1e-3,
6584
+ totalLen * (1 - progress - 2 * gapFrac)
6585
+ );
6586
+ const trackOff = -totalLen * trackStartFrac;
6587
+ indeterminateTrackRef.current.setAttribute(
6588
+ "stroke-dasharray",
6589
+ `${trackLen} ${totalLen}`
6590
+ );
6591
+ indeterminateTrackRef.current.setAttribute(
6592
+ "stroke-dashoffset",
6593
+ `${trackOff}`
6594
+ );
6595
+ }
6596
+ }
6597
+ });
6438
6598
  return /* @__PURE__ */ jsxRuntime.jsx(
6439
6599
  "div",
6440
6600
  __spreadProps(__spreadValues({
@@ -6511,9 +6671,10 @@ var CircularProgress = React37__namespace.forwardRef(
6511
6671
  ]
6512
6672
  }
6513
6673
  ),
6514
- !isDeterminate && /* @__PURE__ */ jsxRuntime.jsxs(
6515
- react.m.svg,
6674
+ !isDeterminate && /* @__PURE__ */ jsxRuntime.jsx(
6675
+ "svg",
6516
6676
  {
6677
+ ref: indeterminateSvgRef,
6517
6678
  width: size,
6518
6679
  height: size,
6519
6680
  viewBox: `0 0 ${size} ${size}`,
@@ -6522,84 +6683,60 @@ var CircularProgress = React37__namespace.forwardRef(
6522
6683
  position: "absolute",
6523
6684
  inset: 0,
6524
6685
  overflow: "visible",
6525
- transformOrigin: "center"
6526
- },
6527
- animate: { rotate: [0, 360] },
6528
- transition: {
6529
- duration: 2 / Math.max(0.1, crawlerSpeed),
6530
- repeat: Number.POSITIVE_INFINITY,
6531
- ease: "linear"
6686
+ transformOrigin: "center",
6687
+ transform: "rotate(-90deg)"
6532
6688
  },
6533
- children: [
6534
- /* @__PURE__ */ jsxRuntime.jsx(
6535
- react.m.circle,
6689
+ children: isWavy ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6690
+ shouldShowIndeterminateTrack && /* @__PURE__ */ jsxRuntime.jsx(
6691
+ "path",
6536
6692
  {
6537
- cx: center,
6538
- cy: center,
6539
- r: radius,
6693
+ ref: indeterminateWavyTrackPathRef,
6694
+ d: wavyActivePath != null ? wavyActivePath : "",
6540
6695
  fill: "none",
6541
6696
  stroke: bgTrackColor,
6542
6697
  strokeWidth: trackHeight,
6543
- strokeLinecap: "round",
6544
- animate: {
6545
- pathLength: [
6546
- Math.max(1e-3, 0.9 - 2 * gapForTrack),
6547
- Math.max(1e-3, 0.25 - 2 * gapForTrack),
6548
- Math.max(1e-3, 0.9 - 2 * gapForTrack)
6549
- ],
6550
- pathOffset: [
6551
- 0.1 + gapForTrack,
6552
- 0.75 + gapForTrack,
6553
- 0.1 + gapForTrack
6554
- ]
6555
- },
6556
- transition: {
6557
- duration: 2 / Math.max(0.1, crawlerSpeed),
6558
- repeat: Number.POSITIVE_INFINITY,
6559
- ease: [0.4, 0, 0.2, 1]
6560
- }
6698
+ strokeLinecap: "round"
6561
6699
  }
6562
6700
  ),
6563
- isWavy ? /* @__PURE__ */ jsxRuntime.jsx(
6564
- ActivePathElem,
6701
+ /* @__PURE__ */ jsxRuntime.jsx(
6702
+ "path",
6565
6703
  {
6704
+ ref: indeterminateWavyActivePathRef,
6566
6705
  d: wavyActivePath != null ? wavyActivePath : "",
6567
6706
  fill: "none",
6568
6707
  stroke: activeColor,
6569
6708
  strokeWidth: trackHeight,
6570
- strokeLinecap: "round",
6571
- animate: {
6572
- pathLength: [0.1, 0.75, 0.1],
6573
- pathOffset: [0, 0.65, 1]
6574
- },
6575
- transition: {
6576
- duration: 2 / Math.max(0.1, crawlerSpeed),
6577
- repeat: Number.POSITIVE_INFINITY,
6578
- ease: [0.4, 0, 0.2, 1]
6579
- }
6709
+ strokeLinecap: "round"
6580
6710
  }
6581
- ) : /* @__PURE__ */ jsxRuntime.jsx(
6582
- ActiveCircleElem,
6711
+ )
6712
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6713
+ shouldShowIndeterminateTrack && /* @__PURE__ */ jsxRuntime.jsx(
6714
+ "circle",
6583
6715
  {
6716
+ ref: indeterminateTrackRef,
6717
+ cx: center,
6718
+ cy: center,
6719
+ r: radius,
6720
+ fill: "none",
6721
+ stroke: bgTrackColor,
6722
+ strokeWidth: trackHeight,
6723
+ strokeLinecap: "round"
6724
+ }
6725
+ ),
6726
+ /* @__PURE__ */ jsxRuntime.jsx(
6727
+ "circle",
6728
+ {
6729
+ ref: indeterminateActiveRef,
6584
6730
  cx: center,
6585
6731
  cy: center,
6586
6732
  r: radius,
6587
6733
  fill: "none",
6588
6734
  stroke: activeColor,
6589
6735
  strokeWidth: trackHeight,
6590
- strokeLinecap: "round",
6591
- animate: {
6592
- pathLength: [0.1, 0.75, 0.1],
6593
- pathOffset: [0, 0.65, 1]
6594
- },
6595
- transition: {
6596
- duration: 2 / Math.max(0.1, crawlerSpeed),
6597
- repeat: Number.POSITIVE_INFINITY,
6598
- ease: [0.4, 0, 0.2, 1]
6599
- }
6736
+ strokeLinecap: "round"
6600
6737
  }
6601
6738
  )
6602
- ]
6739
+ ] })
6603
6740
  }
6604
6741
  )
6605
6742
  ] })
@@ -6805,7 +6942,7 @@ var WavyLinearTrack = React37__namespace.memo(function WavyLinearTrack2({
6805
6942
  currentAmp
6806
6943
  );
6807
6944
  } else if (fraction === 0) {
6808
- activePathD = `M ${capWidth} 0 L ${capWidth + 0.01} 0`;
6945
+ activePathD = "";
6809
6946
  }
6810
6947
  const trackStart = adjHead + totalGap;
6811
6948
  if (trackStart < width - capWidth) {
@@ -6837,20 +6974,20 @@ var WavyLinearTrack = React37__namespace.memo(function WavyLinearTrack2({
6837
6974
  activeLines.push({ tail: l1T, head: l1H });
6838
6975
  activeLines.push({ tail: l2T, head: l2H });
6839
6976
  }
6840
- const segments = activeLines.map((line) => {
6841
- const barTail = line.tail * width;
6842
- const barHead = line.head * width;
6977
+ const activeSegments = activeLines.map((line) => {
6978
+ const rawTail = line.tail * width;
6979
+ const rawHead = line.head * width;
6843
6980
  const adjTail = Math.max(
6844
6981
  capWidth,
6845
- Math.min(width - capWidth, barTail)
6982
+ Math.min(width - capWidth, rawTail)
6846
6983
  );
6847
6984
  const adjHead = Math.max(
6848
6985
  capWidth,
6849
- Math.min(width - capWidth, barHead)
6986
+ Math.min(width - capWidth, rawHead)
6850
6987
  );
6851
6988
  return { adjTail, adjHead };
6852
6989
  }).filter((seg) => seg.adjHead - seg.adjTail > 0.1);
6853
- activePathD = segments.map(
6990
+ activePathD = activeSegments.map(
6854
6991
  (seg) => getSinePath(
6855
6992
  seg.adjTail,
6856
6993
  seg.adjHead,
@@ -6859,13 +6996,24 @@ var WavyLinearTrack = React37__namespace.memo(function WavyLinearTrack2({
6859
6996
  currentAmp
6860
6997
  )
6861
6998
  ).join(" ");
6999
+ const validActiveLines = activeLines.filter(
7000
+ (line) => line.head > line.tail && line.head * width > 0 && line.tail * width < width
7001
+ ).sort((a, b) => a.tail - b.tail);
6862
7002
  let currentTrackX = capWidth;
6863
- for (const seg of segments) {
6864
- const trackEnd = seg.adjTail - totalGap;
7003
+ for (const line of validActiveLines) {
7004
+ const blockStart = line.tail * width - totalGap;
7005
+ const blockEnd = line.head * width + totalGap;
7006
+ const trackEnd = Math.min(width - capWidth, blockStart);
6865
7007
  if (trackEnd > currentTrackX) {
6866
- trackD += `${getSinePath(currentTrackX, trackEnd, phase, activeWavelength, trackAmp)} `;
7008
+ trackD += `${getSinePath(
7009
+ currentTrackX,
7010
+ trackEnd,
7011
+ phase,
7012
+ activeWavelength,
7013
+ trackAmp
7014
+ )} `;
6867
7015
  }
6868
- currentTrackX = Math.max(currentTrackX, seg.adjHead + totalGap);
7016
+ currentTrackX = Math.max(currentTrackX, blockEnd);
6869
7017
  }
6870
7018
  if (currentTrackX < width - capWidth) {
6871
7019
  trackD += getSinePath(
@@ -6878,9 +7026,9 @@ var WavyLinearTrack = React37__namespace.memo(function WavyLinearTrack2({
6878
7026
  }
6879
7027
  }
6880
7028
  if (activePathRef.current)
6881
- activePathRef.current.setAttribute("d", activePathD);
7029
+ activePathRef.current.setAttribute("d", activePathD || "");
6882
7030
  if (trackPathRef.current)
6883
- trackPathRef.current.setAttribute("d", trackD.trim());
7031
+ trackPathRef.current.setAttribute("d", trackD.trim() || "");
6884
7032
  });
6885
7033
  return /* @__PURE__ */ jsxRuntime.jsx(
6886
7034
  "div",