@bug-on/m3-expressive 1.2.5 → 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.
- package/CHANGELOG.md +12 -0
- package/dist/buttons.js +260 -98
- package/dist/buttons.js.map +1 -1
- package/dist/buttons.mjs +261 -99
- package/dist/buttons.mjs.map +1 -1
- package/dist/core.js +338 -176
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +321 -159
- package/dist/core.mjs.map +1 -1
- package/dist/feedback.d.mts +32 -0
- package/dist/feedback.d.ts +32 -0
- package/dist/feedback.js +348 -186
- package/dist/feedback.js.map +1 -1
- package/dist/feedback.mjs +326 -164
- package/dist/feedback.mjs.map +1 -1
- package/dist/index.js +261 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +262 -100
- package/dist/index.mjs.map +1 -1
- package/dist/layout.js +261 -99
- package/dist/layout.js.map +1 -1
- package/dist/layout.mjs +262 -100
- package/dist/layout.mjs.map +1 -1
- package/dist/navigation.js +260 -98
- package/dist/navigation.js.map +1 -1
- package/dist/navigation.mjs +261 -99
- package/dist/navigation.mjs.map +1 -1
- package/dist/overlays.js +391 -229
- package/dist/overlays.js.map +1 -1
- package/dist/overlays.mjs +354 -192
- package/dist/overlays.mjs.map +1 -1
- package/dist/pickers.js +399 -237
- package/dist/pickers.js.map +1 -1
- package/dist/pickers.mjs +367 -205
- package/dist/pickers.mjs.map +1 -1
- package/package.json +1 -1
package/dist/buttons.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
-
import { m, LazyMotion, domMax, useMotionValue, animate,
|
|
3
|
+
import { m, useAnimationFrame, LazyMotion, domMax, useMotionValue, animate, AnimatePresence, useReducedMotion, useSpring, useTransform } from 'motion/react';
|
|
4
4
|
import * as React16 from 'react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -256,26 +256,46 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
|
256
256
|
if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
|
|
257
257
|
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
|
|
258
258
|
}
|
|
259
|
-
d
|
|
260
|
-
return d;
|
|
259
|
+
return `${d} Z`;
|
|
261
260
|
}
|
|
262
261
|
function getSinePath(startX, endX, phase, wl, amp) {
|
|
263
262
|
if (startX >= endX) return "";
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
263
|
+
if (amp <= 0.01) {
|
|
264
|
+
return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
|
|
265
|
+
}
|
|
266
|
+
const safeWl = Math.max(1, wl);
|
|
267
|
+
const k = 2 * Math.PI / safeWl;
|
|
268
|
+
const phi = phase / safeWl * 2 * Math.PI;
|
|
269
|
+
const yAt = (x) => amp * Math.sin(k * x + phi);
|
|
270
|
+
const dyAt = (x) => amp * k * Math.cos(k * x + phi);
|
|
271
|
+
const step = safeWl / 4;
|
|
272
|
+
let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
|
|
273
|
+
let currentX = startX;
|
|
274
|
+
while (currentX < endX) {
|
|
275
|
+
const nextX = Math.min(endX, currentX + step);
|
|
276
|
+
const dx = nextX - currentX;
|
|
277
|
+
const scale = dx / 3;
|
|
278
|
+
const y0 = yAt(currentX);
|
|
279
|
+
const dy0 = dyAt(currentX);
|
|
280
|
+
const y1 = yAt(nextX);
|
|
281
|
+
const dy1 = dyAt(nextX);
|
|
282
|
+
const cp1x = currentX + scale;
|
|
283
|
+
const cp1y = y0 + scale * dy0;
|
|
284
|
+
const cp2x = nextX - scale;
|
|
285
|
+
const cp2y = y1 - scale * dy1;
|
|
286
|
+
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
|
|
287
|
+
currentX = nextX;
|
|
274
288
|
}
|
|
275
|
-
const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
|
|
276
|
-
d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
|
|
277
289
|
return d;
|
|
278
290
|
}
|
|
291
|
+
var GLOBAL_ROTATION_DURATION = 6e3;
|
|
292
|
+
var GLOBAL_ROTATION_TARGET = 1080;
|
|
293
|
+
var ADDITIONAL_ROTATION_CYCLE = 1500;
|
|
294
|
+
var ADDITIONAL_ROTATION_STEP = 90;
|
|
295
|
+
var ADDITIONAL_ROTATION_EASE_DURATION = 500;
|
|
296
|
+
var DEFAULT_MIN_PROGRESS = 0.1;
|
|
297
|
+
var DEFAULT_MAX_PROGRESS = 0.8;
|
|
298
|
+
var PROGRESS_CYCLE_DURATION = 1500;
|
|
279
299
|
var CircularProgress = React16.forwardRef(
|
|
280
300
|
(_a, ref) => {
|
|
281
301
|
var _b = _a, {
|
|
@@ -289,6 +309,10 @@ var CircularProgress = React16.forwardRef(
|
|
|
289
309
|
crawlerSpeed = 1,
|
|
290
310
|
color,
|
|
291
311
|
trackColor,
|
|
312
|
+
showTrack = "auto",
|
|
313
|
+
minProgress = DEFAULT_MIN_PROGRESS,
|
|
314
|
+
maxProgress = DEFAULT_MAX_PROGRESS,
|
|
315
|
+
amplitudeRange,
|
|
292
316
|
className,
|
|
293
317
|
"aria-label": ariaLabel
|
|
294
318
|
} = _b, restProps = __objRest(_b, [
|
|
@@ -302,6 +326,10 @@ var CircularProgress = React16.forwardRef(
|
|
|
302
326
|
"crawlerSpeed",
|
|
303
327
|
"color",
|
|
304
328
|
"trackColor",
|
|
329
|
+
"showTrack",
|
|
330
|
+
"minProgress",
|
|
331
|
+
"maxProgress",
|
|
332
|
+
"amplitudeRange",
|
|
305
333
|
"className",
|
|
306
334
|
"aria-label"
|
|
307
335
|
]);
|
|
@@ -312,6 +340,7 @@ var CircularProgress = React16.forwardRef(
|
|
|
312
340
|
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
313
341
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
314
342
|
const isWavy = shape === "wavy";
|
|
343
|
+
const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
|
|
315
344
|
const BASELINE_SIZE = 48;
|
|
316
345
|
const scaleFactor = size / BASELINE_SIZE;
|
|
317
346
|
const effectiveAmplitude = React16.useMemo(
|
|
@@ -322,6 +351,10 @@ var CircularProgress = React16.forwardRef(
|
|
|
322
351
|
() => wavelength != null ? wavelength : 15 * scaleFactor,
|
|
323
352
|
[wavelength, scaleFactor]
|
|
324
353
|
);
|
|
354
|
+
const resolvedAmplitudeRange = React16.useMemo(
|
|
355
|
+
() => amplitudeRange != null ? amplitudeRange : [0, effectiveAmplitude],
|
|
356
|
+
[amplitudeRange, effectiveAmplitude]
|
|
357
|
+
);
|
|
325
358
|
const wavyActivePath = React16.useMemo(
|
|
326
359
|
() => isWavy ? generateWavyCircularPath(
|
|
327
360
|
center,
|
|
@@ -341,6 +374,145 @@ var CircularProgress = React16.forwardRef(
|
|
|
341
374
|
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
342
375
|
const ActiveCircleElem = m.circle;
|
|
343
376
|
const ActivePathElem = m.path;
|
|
377
|
+
const indeterminateSvgRef = React16.useRef(null);
|
|
378
|
+
const indeterminateTrackRef = React16.useRef(null);
|
|
379
|
+
const indeterminateActiveRef = React16.useRef(null);
|
|
380
|
+
const indeterminateWavyTrackPathRef = React16.useRef(null);
|
|
381
|
+
const indeterminateWavyActivePathRef = React16.useRef(null);
|
|
382
|
+
const cachedPathLengthRef = React16.useRef(0);
|
|
383
|
+
React16.useLayoutEffect(() => {
|
|
384
|
+
if (!isWavy || !wavyActivePath) {
|
|
385
|
+
cachedPathLengthRef.current = circumference;
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const el = indeterminateActiveRef.current;
|
|
389
|
+
if (el && "getTotalLength" in el) {
|
|
390
|
+
try {
|
|
391
|
+
const len = el.getTotalLength();
|
|
392
|
+
if (len > 0) {
|
|
393
|
+
cachedPathLengthRef.current = len;
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
} catch (e) {
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
cachedPathLengthRef.current = circumference;
|
|
400
|
+
}, [isWavy, circumference, wavyActivePath]);
|
|
401
|
+
useAnimationFrame((time) => {
|
|
402
|
+
if (isDeterminate) return;
|
|
403
|
+
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
404
|
+
const scaledTime = time * safeCrawlerSpeed;
|
|
405
|
+
const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
|
|
406
|
+
const globalAngle = globalCycle / GLOBAL_ROTATION_DURATION * GLOBAL_ROTATION_TARGET;
|
|
407
|
+
const additionalFullCycles = Math.floor(
|
|
408
|
+
scaledTime / ADDITIONAL_ROTATION_CYCLE
|
|
409
|
+
);
|
|
410
|
+
const additionalCycleTime = scaledTime % ADDITIONAL_ROTATION_CYCLE;
|
|
411
|
+
const additionalEaseT = Math.min(
|
|
412
|
+
1,
|
|
413
|
+
additionalCycleTime / ADDITIONAL_ROTATION_EASE_DURATION
|
|
414
|
+
);
|
|
415
|
+
const additionalAngle = (additionalFullCycles + easeInOutCubic(additionalEaseT)) * ADDITIONAL_ROTATION_STEP;
|
|
416
|
+
const totalRotation = globalAngle + additionalAngle;
|
|
417
|
+
if (indeterminateSvgRef.current) {
|
|
418
|
+
indeterminateSvgRef.current.style.transform = `rotate(${totalRotation - 90}deg)`;
|
|
419
|
+
}
|
|
420
|
+
const progressFullCycle = PROGRESS_CYCLE_DURATION * 2;
|
|
421
|
+
const progressCycleTime = scaledTime % progressFullCycle;
|
|
422
|
+
let progress;
|
|
423
|
+
if (progressCycleTime < PROGRESS_CYCLE_DURATION) {
|
|
424
|
+
const t = progressCycleTime / PROGRESS_CYCLE_DURATION;
|
|
425
|
+
progress = minProgress + (maxProgress - minProgress) * easeInOutCubic(t);
|
|
426
|
+
} else {
|
|
427
|
+
const t = (progressCycleTime - PROGRESS_CYCLE_DURATION) / PROGRESS_CYCLE_DURATION;
|
|
428
|
+
progress = maxProgress - (maxProgress - minProgress) * easeInOutCubic(t);
|
|
429
|
+
}
|
|
430
|
+
if (isWavy) {
|
|
431
|
+
const amplitudeT = (progress - minProgress) / (maxProgress - minProgress);
|
|
432
|
+
const currentAmplitude = resolvedAmplitudeRange[0] + (resolvedAmplitudeRange[1] - resolvedAmplitudeRange[0]) * amplitudeT;
|
|
433
|
+
const dynamicPath = generateWavyCircularPath(
|
|
434
|
+
center,
|
|
435
|
+
radius,
|
|
436
|
+
currentAmplitude,
|
|
437
|
+
effectiveWavelength
|
|
438
|
+
);
|
|
439
|
+
if (indeterminateWavyActivePathRef.current) {
|
|
440
|
+
indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
441
|
+
}
|
|
442
|
+
if (indeterminateWavyTrackPathRef.current) {
|
|
443
|
+
indeterminateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
|
|
444
|
+
}
|
|
445
|
+
const pathEl = indeterminateWavyActivePathRef.current;
|
|
446
|
+
let totalLen = cachedPathLengthRef.current || circumference;
|
|
447
|
+
if (pathEl) {
|
|
448
|
+
try {
|
|
449
|
+
const len = pathEl.getTotalLength();
|
|
450
|
+
if (len > 0) totalLen = len;
|
|
451
|
+
} catch (e) {
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
455
|
+
const activeLen = totalLen * progress;
|
|
456
|
+
const activeOff = 0;
|
|
457
|
+
if (indeterminateWavyActivePathRef.current) {
|
|
458
|
+
indeterminateWavyActivePathRef.current.setAttribute(
|
|
459
|
+
"stroke-dasharray",
|
|
460
|
+
`${activeLen} ${totalLen}`
|
|
461
|
+
);
|
|
462
|
+
indeterminateWavyActivePathRef.current.setAttribute(
|
|
463
|
+
"stroke-dashoffset",
|
|
464
|
+
`${activeOff}`
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
if (shouldShowIndeterminateTrack && indeterminateWavyTrackPathRef.current) {
|
|
468
|
+
const trackStartFrac = progress + gapFrac;
|
|
469
|
+
const trackLen = Math.max(
|
|
470
|
+
1e-3,
|
|
471
|
+
totalLen * (1 - progress - 2 * gapFrac)
|
|
472
|
+
);
|
|
473
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
474
|
+
indeterminateWavyTrackPathRef.current.setAttribute(
|
|
475
|
+
"stroke-dasharray",
|
|
476
|
+
`${trackLen} ${totalLen}`
|
|
477
|
+
);
|
|
478
|
+
indeterminateWavyTrackPathRef.current.setAttribute(
|
|
479
|
+
"stroke-dashoffset",
|
|
480
|
+
`${trackOff}`
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
} else {
|
|
484
|
+
const totalLen = circumference;
|
|
485
|
+
const activeLen = totalLen * progress;
|
|
486
|
+
const activeOff = 0;
|
|
487
|
+
if (indeterminateActiveRef.current) {
|
|
488
|
+
indeterminateActiveRef.current.setAttribute(
|
|
489
|
+
"stroke-dasharray",
|
|
490
|
+
`${activeLen} ${totalLen}`
|
|
491
|
+
);
|
|
492
|
+
indeterminateActiveRef.current.setAttribute(
|
|
493
|
+
"stroke-dashoffset",
|
|
494
|
+
`${activeOff}`
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
if (shouldShowIndeterminateTrack && indeterminateTrackRef.current) {
|
|
498
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
499
|
+
const trackStartFrac = progress + gapFrac;
|
|
500
|
+
const trackLen = Math.max(
|
|
501
|
+
1e-3,
|
|
502
|
+
totalLen * (1 - progress - 2 * gapFrac)
|
|
503
|
+
);
|
|
504
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
505
|
+
indeterminateTrackRef.current.setAttribute(
|
|
506
|
+
"stroke-dasharray",
|
|
507
|
+
`${trackLen} ${totalLen}`
|
|
508
|
+
);
|
|
509
|
+
indeterminateTrackRef.current.setAttribute(
|
|
510
|
+
"stroke-dashoffset",
|
|
511
|
+
`${trackOff}`
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
344
516
|
return /* @__PURE__ */ jsx(
|
|
345
517
|
"div",
|
|
346
518
|
__spreadProps(__spreadValues({
|
|
@@ -417,9 +589,10 @@ var CircularProgress = React16.forwardRef(
|
|
|
417
589
|
]
|
|
418
590
|
}
|
|
419
591
|
),
|
|
420
|
-
!isDeterminate && /* @__PURE__ */
|
|
421
|
-
|
|
592
|
+
!isDeterminate && /* @__PURE__ */ jsx(
|
|
593
|
+
"svg",
|
|
422
594
|
{
|
|
595
|
+
ref: indeterminateSvgRef,
|
|
423
596
|
width: size,
|
|
424
597
|
height: size,
|
|
425
598
|
viewBox: `0 0 ${size} ${size}`,
|
|
@@ -428,90 +601,60 @@ var CircularProgress = React16.forwardRef(
|
|
|
428
601
|
position: "absolute",
|
|
429
602
|
inset: 0,
|
|
430
603
|
overflow: "visible",
|
|
431
|
-
|
|
432
|
-
|
|
604
|
+
transformOrigin: "center",
|
|
605
|
+
transform: "rotate(-90deg)"
|
|
433
606
|
},
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
438
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
439
|
-
ease: "linear"
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
children: [
|
|
443
|
-
/* @__PURE__ */ jsx(
|
|
444
|
-
m.circle,
|
|
607
|
+
children: isWavy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
608
|
+
shouldShowIndeterminateTrack && /* @__PURE__ */ jsx(
|
|
609
|
+
"path",
|
|
445
610
|
{
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
r: radius,
|
|
611
|
+
ref: indeterminateWavyTrackPathRef,
|
|
612
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
449
613
|
fill: "none",
|
|
450
614
|
stroke: bgTrackColor,
|
|
451
615
|
strokeWidth: trackHeight,
|
|
452
|
-
strokeLinecap: "round"
|
|
453
|
-
style: { originX: "50%", originY: "50%" },
|
|
454
|
-
animate: {
|
|
455
|
-
pathLength: [
|
|
456
|
-
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
|
|
457
|
-
Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
|
|
458
|
-
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
|
|
459
|
-
],
|
|
460
|
-
rotate: [
|
|
461
|
-
`${(0.1 + gapForTrack) * 360}deg`,
|
|
462
|
-
`${(1 + gapForTrack) * 360}deg`,
|
|
463
|
-
`${(1.1 + gapForTrack) * 360}deg`
|
|
464
|
-
]
|
|
465
|
-
},
|
|
466
|
-
transition: {
|
|
467
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
468
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
469
|
-
ease: [0.4, 0, 0.2, 1]
|
|
470
|
-
}
|
|
616
|
+
strokeLinecap: "round"
|
|
471
617
|
}
|
|
472
618
|
),
|
|
473
|
-
|
|
474
|
-
|
|
619
|
+
/* @__PURE__ */ jsx(
|
|
620
|
+
"path",
|
|
475
621
|
{
|
|
622
|
+
ref: indeterminateWavyActivePathRef,
|
|
476
623
|
d: wavyActivePath != null ? wavyActivePath : "",
|
|
477
624
|
fill: "none",
|
|
478
625
|
stroke: activeColor,
|
|
479
626
|
strokeWidth: trackHeight,
|
|
480
|
-
strokeLinecap: "round"
|
|
481
|
-
style: { originX: "50%", originY: "50%" },
|
|
482
|
-
animate: {
|
|
483
|
-
pathLength: [0.1, 0.75, 0.1],
|
|
484
|
-
rotate: ["0deg", "90deg", "360deg"]
|
|
485
|
-
},
|
|
486
|
-
transition: {
|
|
487
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
488
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
489
|
-
ease: [0.4, 0, 0.2, 1]
|
|
490
|
-
}
|
|
627
|
+
strokeLinecap: "round"
|
|
491
628
|
}
|
|
492
|
-
)
|
|
493
|
-
|
|
629
|
+
)
|
|
630
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
631
|
+
shouldShowIndeterminateTrack && /* @__PURE__ */ jsx(
|
|
632
|
+
"circle",
|
|
494
633
|
{
|
|
634
|
+
ref: indeterminateTrackRef,
|
|
635
|
+
cx: center,
|
|
636
|
+
cy: center,
|
|
637
|
+
r: radius,
|
|
638
|
+
fill: "none",
|
|
639
|
+
stroke: bgTrackColor,
|
|
640
|
+
strokeWidth: trackHeight,
|
|
641
|
+
strokeLinecap: "round"
|
|
642
|
+
}
|
|
643
|
+
),
|
|
644
|
+
/* @__PURE__ */ jsx(
|
|
645
|
+
"circle",
|
|
646
|
+
{
|
|
647
|
+
ref: indeterminateActiveRef,
|
|
495
648
|
cx: center,
|
|
496
649
|
cy: center,
|
|
497
650
|
r: radius,
|
|
498
651
|
fill: "none",
|
|
499
652
|
stroke: activeColor,
|
|
500
653
|
strokeWidth: trackHeight,
|
|
501
|
-
strokeLinecap: "round"
|
|
502
|
-
style: { originX: "50%", originY: "50%" },
|
|
503
|
-
animate: {
|
|
504
|
-
pathLength: [0.1, 0.75, 0.1],
|
|
505
|
-
rotate: ["0deg", "90deg", "360deg"]
|
|
506
|
-
},
|
|
507
|
-
transition: {
|
|
508
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
509
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
510
|
-
ease: [0.4, 0, 0.2, 1]
|
|
511
|
-
}
|
|
654
|
+
strokeLinecap: "round"
|
|
512
655
|
}
|
|
513
656
|
)
|
|
514
|
-
]
|
|
657
|
+
] })
|
|
515
658
|
}
|
|
516
659
|
)
|
|
517
660
|
] })
|
|
@@ -675,6 +818,12 @@ var WavyLinearTrack = React16.memo(function WavyLinearTrack2({
|
|
|
675
818
|
duration: 0.5
|
|
676
819
|
});
|
|
677
820
|
animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
|
|
821
|
+
} else {
|
|
822
|
+
animate(amplitudeMV, amplitude, {
|
|
823
|
+
type: "spring",
|
|
824
|
+
bounce: 0,
|
|
825
|
+
duration: 0.5
|
|
826
|
+
});
|
|
678
827
|
}
|
|
679
828
|
}, [
|
|
680
829
|
clampedValue,
|
|
@@ -688,10 +837,10 @@ var WavyLinearTrack = React16.memo(function WavyLinearTrack2({
|
|
|
688
837
|
1,
|
|
689
838
|
isDeterminate ? wavelength : indeterminateWavelength
|
|
690
839
|
);
|
|
691
|
-
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
692
840
|
useAnimationFrame((time) => {
|
|
693
841
|
if (width === 0) return;
|
|
694
842
|
const currentAmp = amplitudeMV.get();
|
|
843
|
+
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
695
844
|
const phase = time / 1e3 * waveSpeed * activeWavelength;
|
|
696
845
|
const capWidth = trackHeight / 2;
|
|
697
846
|
let activePathD = "";
|
|
@@ -711,7 +860,7 @@ var WavyLinearTrack = React16.memo(function WavyLinearTrack2({
|
|
|
711
860
|
currentAmp
|
|
712
861
|
);
|
|
713
862
|
} else if (fraction === 0) {
|
|
714
|
-
activePathD =
|
|
863
|
+
activePathD = "";
|
|
715
864
|
}
|
|
716
865
|
const trackStart = adjHead + totalGap;
|
|
717
866
|
if (trackStart < width - capWidth) {
|
|
@@ -743,20 +892,20 @@ var WavyLinearTrack = React16.memo(function WavyLinearTrack2({
|
|
|
743
892
|
activeLines.push({ tail: l1T, head: l1H });
|
|
744
893
|
activeLines.push({ tail: l2T, head: l2H });
|
|
745
894
|
}
|
|
746
|
-
const
|
|
747
|
-
const
|
|
748
|
-
const
|
|
895
|
+
const activeSegments = activeLines.map((line) => {
|
|
896
|
+
const rawTail = line.tail * width;
|
|
897
|
+
const rawHead = line.head * width;
|
|
749
898
|
const adjTail = Math.max(
|
|
750
899
|
capWidth,
|
|
751
|
-
Math.min(width - capWidth,
|
|
900
|
+
Math.min(width - capWidth, rawTail)
|
|
752
901
|
);
|
|
753
902
|
const adjHead = Math.max(
|
|
754
903
|
capWidth,
|
|
755
|
-
Math.min(width - capWidth,
|
|
904
|
+
Math.min(width - capWidth, rawHead)
|
|
756
905
|
);
|
|
757
906
|
return { adjTail, adjHead };
|
|
758
907
|
}).filter((seg) => seg.adjHead - seg.adjTail > 0.1);
|
|
759
|
-
activePathD =
|
|
908
|
+
activePathD = activeSegments.map(
|
|
760
909
|
(seg) => getSinePath(
|
|
761
910
|
seg.adjTail,
|
|
762
911
|
seg.adjHead,
|
|
@@ -765,13 +914,24 @@ var WavyLinearTrack = React16.memo(function WavyLinearTrack2({
|
|
|
765
914
|
currentAmp
|
|
766
915
|
)
|
|
767
916
|
).join(" ");
|
|
917
|
+
const validActiveLines = activeLines.filter(
|
|
918
|
+
(line) => line.head > line.tail && line.head * width > 0 && line.tail * width < width
|
|
919
|
+
).sort((a, b) => a.tail - b.tail);
|
|
768
920
|
let currentTrackX = capWidth;
|
|
769
|
-
for (const
|
|
770
|
-
const
|
|
921
|
+
for (const line of validActiveLines) {
|
|
922
|
+
const blockStart = line.tail * width - totalGap;
|
|
923
|
+
const blockEnd = line.head * width + totalGap;
|
|
924
|
+
const trackEnd = Math.min(width - capWidth, blockStart);
|
|
771
925
|
if (trackEnd > currentTrackX) {
|
|
772
|
-
trackD += `${getSinePath(
|
|
926
|
+
trackD += `${getSinePath(
|
|
927
|
+
currentTrackX,
|
|
928
|
+
trackEnd,
|
|
929
|
+
phase,
|
|
930
|
+
activeWavelength,
|
|
931
|
+
trackAmp
|
|
932
|
+
)} `;
|
|
773
933
|
}
|
|
774
|
-
currentTrackX = Math.max(currentTrackX,
|
|
934
|
+
currentTrackX = Math.max(currentTrackX, blockEnd);
|
|
775
935
|
}
|
|
776
936
|
if (currentTrackX < width - capWidth) {
|
|
777
937
|
trackD += getSinePath(
|
|
@@ -784,15 +944,15 @@ var WavyLinearTrack = React16.memo(function WavyLinearTrack2({
|
|
|
784
944
|
}
|
|
785
945
|
}
|
|
786
946
|
if (activePathRef.current)
|
|
787
|
-
activePathRef.current.setAttribute("d", activePathD);
|
|
947
|
+
activePathRef.current.setAttribute("d", activePathD || "");
|
|
788
948
|
if (trackPathRef.current)
|
|
789
|
-
trackPathRef.current.setAttribute("d", trackD.trim());
|
|
949
|
+
trackPathRef.current.setAttribute("d", trackD.trim() || "");
|
|
790
950
|
});
|
|
791
951
|
return /* @__PURE__ */ jsx(
|
|
792
952
|
"div",
|
|
793
953
|
{
|
|
794
954
|
ref: containerRef,
|
|
795
|
-
className: "relative w-full
|
|
955
|
+
className: "relative w-full",
|
|
796
956
|
style: { height: svgHeight },
|
|
797
957
|
children: width > 0 && /* @__PURE__ */ jsxs(
|
|
798
958
|
"svg",
|
|
@@ -846,7 +1006,7 @@ var LinearProgress = React16.forwardRef(
|
|
|
846
1006
|
waveSpeed = 1,
|
|
847
1007
|
crawlerSpeed = 1,
|
|
848
1008
|
determinateAnimation = "md3",
|
|
849
|
-
indeterminateAnimation = "
|
|
1009
|
+
indeterminateAnimation = "md3",
|
|
850
1010
|
gapSize = 4,
|
|
851
1011
|
showStopIndicator = "auto",
|
|
852
1012
|
color,
|
|
@@ -883,15 +1043,15 @@ var LinearProgress = React16.forwardRef(
|
|
|
883
1043
|
setIsRtl(dir === "rtl");
|
|
884
1044
|
}
|
|
885
1045
|
}, []);
|
|
886
|
-
const isWavy = shape === "wavy";
|
|
887
1046
|
const resolvedTrackShape = trackShape != null ? trackShape : shape;
|
|
1047
|
+
const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
|
|
888
1048
|
const effectiveAmplitude = React16.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
|
|
889
1049
|
const svgHeight = React16.useMemo(
|
|
890
1050
|
() => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
|
|
891
1051
|
[isWavy, trackHeight, effectiveAmplitude]
|
|
892
1052
|
);
|
|
893
1053
|
const shouldShowStop = React16.useMemo(
|
|
894
|
-
() => isDeterminate && resolvedTrackShape === "flat" &&
|
|
1054
|
+
() => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
|
|
895
1055
|
[isDeterminate, resolvedTrackShape, showStopIndicator]
|
|
896
1056
|
);
|
|
897
1057
|
const stopSize = React16.useMemo(
|
|
@@ -901,6 +1061,8 @@ var LinearProgress = React16.forwardRef(
|
|
|
901
1061
|
const stopOffset = (trackHeight - stopSize) / 2;
|
|
902
1062
|
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
903
1063
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
1064
|
+
const useWavyTrack = isWavy || !isDeterminate;
|
|
1065
|
+
const trackAmp = isWavy ? effectiveAmplitude : 0;
|
|
904
1066
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
|
|
905
1067
|
"div",
|
|
906
1068
|
__spreadProps(__spreadValues({
|
|
@@ -917,12 +1079,12 @@ var LinearProgress = React16.forwardRef(
|
|
|
917
1079
|
style: { height: svgHeight }
|
|
918
1080
|
}, restProps), {
|
|
919
1081
|
children: [
|
|
920
|
-
|
|
1082
|
+
useWavyTrack ? /* @__PURE__ */ jsx(
|
|
921
1083
|
WavyLinearTrack,
|
|
922
1084
|
{
|
|
923
1085
|
trackHeight,
|
|
924
1086
|
svgHeight,
|
|
925
|
-
amplitude:
|
|
1087
|
+
amplitude: trackAmp,
|
|
926
1088
|
wavelength,
|
|
927
1089
|
indeterminateWavelength,
|
|
928
1090
|
activeColor,
|