@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/feedback.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useReducedMotion, LazyMotion, domMax, m, useMotionValue, animate,
|
|
3
|
-
import * as
|
|
2
|
+
import { useReducedMotion, LazyMotion, domMax, m, useAnimationFrame, useMotionValue, animate, AnimatePresence } from 'motion/react';
|
|
3
|
+
import * as React3 from 'react';
|
|
4
4
|
import { forwardRef, useState, useCallback, useEffect, useRef, useId, cloneElement, useLayoutEffect } from 'react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -78,9 +78,9 @@ function formatBadgeLabel(children, max) {
|
|
|
78
78
|
return "";
|
|
79
79
|
}
|
|
80
80
|
function detectBadgeHasContent(badge) {
|
|
81
|
-
return
|
|
81
|
+
return React3.isValidElement(badge) && badge.props.children != null;
|
|
82
82
|
}
|
|
83
|
-
var BadgeImpl =
|
|
83
|
+
var BadgeImpl = React3.forwardRef(
|
|
84
84
|
(_a, ref) => {
|
|
85
85
|
var _b = _a, {
|
|
86
86
|
children,
|
|
@@ -134,7 +134,7 @@ var BadgeImpl = React12.forwardRef(
|
|
|
134
134
|
}
|
|
135
135
|
);
|
|
136
136
|
BadgeImpl.displayName = "Badge";
|
|
137
|
-
var Badge =
|
|
137
|
+
var Badge = React3.memo(BadgeImpl);
|
|
138
138
|
function BadgedBox({
|
|
139
139
|
badge,
|
|
140
140
|
children,
|
|
@@ -200,11 +200,11 @@ var ROTATE_KEY_SPLINES = [
|
|
|
200
200
|
var ROTATE_VALUES = "0 24 24; 154 24 24; 309 24 24; 463 24 24; 617 24 24; 771 24 24; 926 24 24; 1080 24 24";
|
|
201
201
|
var DETERMINATE_CIRCLE = "M24 7 C34.49 7 41 13.51 41 24 C41 34.49 34.49 41 24 41 C13.51 41 7 34.49 7 24 C7 13.51 13.51 7 24 7 Z";
|
|
202
202
|
var DETERMINATE_SOFT_BURST = "M20.9 10.4 21.4 9.5 21.9 8.7 22.5 7.8 23.2 7.2 24.2 7 25.1 7.4 25.7 8.1 26.2 9 26.8 9.8 27.3 10.6 28.1 11.2 29 11.3 30 11 30.9 10.6 31.8 10.3 32.8 9.9 33.7 10 34.5 10.6 34.9 11.5 34.8 12.5 34.8 13.5 34.7 14.5 34.7 15.5 35.2 16.3 36 16.8 37 17.1 37.9 17.3 38.9 17.5 39.8 17.9 40.4 18.7 40.5 19.7 40 20.5 39.4 21.3 38.7 22 38.1 22.8 37.6 23.7 37.7 24.6 38.3 25.5 38.9 26.2 39.6 27 40.2 27.7 40.5 28.7 40.3 29.6 39.5 30.3 38.6 30.6 37.6 30.8 36.7 31 35.7 31.3 35 31.9 34.6 32.8 34.7 33.8 34.8 34.8 34.9 35.8 34.8 36.8 34.3 37.6 33.4 38.1 32.4 38 31.5 37.6 30.6 37.2 29.7 36.9 28.7 36.6 27.8 36.9 27.1 37.6 26.6 38.5 26.1 39.3 25.5 40.2 24.8 40.8 23.8 41 22.9 40.6 22.3 39.9 21.8 39 21.2 38.2 20.7 37.4 19.9 36.8 19 36.7 18 37 17.1 37.4 16.2 37.7 15.2 38.1 14.3 38 13.5 37.4 13.1 36.5 13.2 35.5 13.2 34.5 13.3 33.5 13.3 32.5 12.8 31.7 12 31.2 11 31 10.1 30.7 9.1 30.5 8.2 30.1 7.6 29.3 7.5 28.3 8 27.5 8.7 26.7 9.3 26 9.9 25.2 10.4 24.3 10.3 23.4 9.7 22.5 9.1 21.8 8.4 21 7.8 20.3 7.5 19.3 7.7 18.4 8.5 17.7 9.4 17.4 10.4 17.2 11.3 17 12.3 16.7 13 16.1 13.4 15.2 13.3 14.2 13.2 13.2 13.1 12.2 13.2 11.2 13.7 10.4 14.6 9.9 15.6 10 16.5 10.4 17.4 10.8 18.3 11.1 19.3 11.4 20.2 11.1Z";
|
|
203
|
-
var IndeterminateSvg =
|
|
203
|
+
var IndeterminateSvg = React3.memo(function IndeterminateSvg2({
|
|
204
204
|
size
|
|
205
205
|
}) {
|
|
206
|
-
const [ready, setReady] =
|
|
207
|
-
|
|
206
|
+
const [ready, setReady] = React3.useState(false);
|
|
207
|
+
React3.useEffect(() => {
|
|
208
208
|
const raf = requestAnimationFrame(() => setReady(true));
|
|
209
209
|
return () => cancelAnimationFrame(raf);
|
|
210
210
|
}, []);
|
|
@@ -249,7 +249,7 @@ var IndeterminateSvg = React12.memo(function IndeterminateSvg2({
|
|
|
249
249
|
}
|
|
250
250
|
);
|
|
251
251
|
});
|
|
252
|
-
var DeterminateSvg =
|
|
252
|
+
var DeterminateSvg = React3.memo(function DeterminateSvg2({
|
|
253
253
|
size,
|
|
254
254
|
progress
|
|
255
255
|
}) {
|
|
@@ -274,7 +274,7 @@ var DeterminateSvg = React12.memo(function DeterminateSvg2({
|
|
|
274
274
|
}
|
|
275
275
|
);
|
|
276
276
|
});
|
|
277
|
-
var LoadingIndicator =
|
|
277
|
+
var LoadingIndicator = React3.forwardRef(
|
|
278
278
|
(_a, ref) => {
|
|
279
279
|
var _b = _a, {
|
|
280
280
|
variant = "uncontained",
|
|
@@ -369,27 +369,47 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
|
369
369
|
if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
|
|
370
370
|
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
|
|
371
371
|
}
|
|
372
|
-
d
|
|
373
|
-
return d;
|
|
372
|
+
return `${d} Z`;
|
|
374
373
|
}
|
|
375
374
|
function getSinePath(startX, endX, phase, wl, amp) {
|
|
376
375
|
if (startX >= endX) return "";
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
376
|
+
if (amp <= 0.01) {
|
|
377
|
+
return `M ${startX.toFixed(2)} 0 L ${endX.toFixed(2)} 0`;
|
|
378
|
+
}
|
|
379
|
+
const safeWl = Math.max(1, wl);
|
|
380
|
+
const k = 2 * Math.PI / safeWl;
|
|
381
|
+
const phi = phase / safeWl * 2 * Math.PI;
|
|
382
|
+
const yAt = (x) => amp * Math.sin(k * x + phi);
|
|
383
|
+
const dyAt = (x) => amp * k * Math.cos(k * x + phi);
|
|
384
|
+
const step = safeWl / 4;
|
|
385
|
+
let d = `M ${startX.toFixed(2)} ${yAt(startX).toFixed(2)}`;
|
|
386
|
+
let currentX = startX;
|
|
387
|
+
while (currentX < endX) {
|
|
388
|
+
const nextX = Math.min(endX, currentX + step);
|
|
389
|
+
const dx = nextX - currentX;
|
|
390
|
+
const scale = dx / 3;
|
|
391
|
+
const y0 = yAt(currentX);
|
|
392
|
+
const dy0 = dyAt(currentX);
|
|
393
|
+
const y1 = yAt(nextX);
|
|
394
|
+
const dy1 = dyAt(nextX);
|
|
395
|
+
const cp1x = currentX + scale;
|
|
396
|
+
const cp1y = y0 + scale * dy0;
|
|
397
|
+
const cp2x = nextX - scale;
|
|
398
|
+
const cp2y = y1 - scale * dy1;
|
|
399
|
+
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${nextX.toFixed(2)} ${y1.toFixed(2)}`;
|
|
400
|
+
currentX = nextX;
|
|
387
401
|
}
|
|
388
|
-
const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
|
|
389
|
-
d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
|
|
390
402
|
return d;
|
|
391
403
|
}
|
|
392
|
-
var
|
|
404
|
+
var GLOBAL_ROTATION_DURATION = 6e3;
|
|
405
|
+
var GLOBAL_ROTATION_TARGET = 1080;
|
|
406
|
+
var ADDITIONAL_ROTATION_CYCLE = 1500;
|
|
407
|
+
var ADDITIONAL_ROTATION_STEP = 90;
|
|
408
|
+
var ADDITIONAL_ROTATION_EASE_DURATION = 500;
|
|
409
|
+
var DEFAULT_MIN_PROGRESS = 0.1;
|
|
410
|
+
var DEFAULT_MAX_PROGRESS = 0.8;
|
|
411
|
+
var PROGRESS_CYCLE_DURATION = 1500;
|
|
412
|
+
var CircularProgress = React3.forwardRef(
|
|
393
413
|
(_a, ref) => {
|
|
394
414
|
var _b = _a, {
|
|
395
415
|
value,
|
|
@@ -402,6 +422,10 @@ var CircularProgress = React12.forwardRef(
|
|
|
402
422
|
crawlerSpeed = 1,
|
|
403
423
|
color,
|
|
404
424
|
trackColor,
|
|
425
|
+
showTrack = "auto",
|
|
426
|
+
minProgress = DEFAULT_MIN_PROGRESS,
|
|
427
|
+
maxProgress = DEFAULT_MAX_PROGRESS,
|
|
428
|
+
amplitudeRange,
|
|
405
429
|
className,
|
|
406
430
|
"aria-label": ariaLabel
|
|
407
431
|
} = _b, restProps = __objRest(_b, [
|
|
@@ -415,6 +439,10 @@ var CircularProgress = React12.forwardRef(
|
|
|
415
439
|
"crawlerSpeed",
|
|
416
440
|
"color",
|
|
417
441
|
"trackColor",
|
|
442
|
+
"showTrack",
|
|
443
|
+
"minProgress",
|
|
444
|
+
"maxProgress",
|
|
445
|
+
"amplitudeRange",
|
|
418
446
|
"className",
|
|
419
447
|
"aria-label"
|
|
420
448
|
]);
|
|
@@ -425,17 +453,22 @@ var CircularProgress = React12.forwardRef(
|
|
|
425
453
|
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
426
454
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
427
455
|
const isWavy = shape === "wavy";
|
|
456
|
+
const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
|
|
428
457
|
const BASELINE_SIZE = 48;
|
|
429
458
|
const scaleFactor = size / BASELINE_SIZE;
|
|
430
|
-
const effectiveAmplitude =
|
|
459
|
+
const effectiveAmplitude = React3.useMemo(
|
|
431
460
|
() => amplitude != null ? amplitude : 1.6 * scaleFactor,
|
|
432
461
|
[amplitude, scaleFactor]
|
|
433
462
|
);
|
|
434
|
-
const effectiveWavelength =
|
|
463
|
+
const effectiveWavelength = React3.useMemo(
|
|
435
464
|
() => wavelength != null ? wavelength : 15 * scaleFactor,
|
|
436
465
|
[wavelength, scaleFactor]
|
|
437
466
|
);
|
|
438
|
-
const
|
|
467
|
+
const resolvedAmplitudeRange = React3.useMemo(
|
|
468
|
+
() => amplitudeRange != null ? amplitudeRange : [0, effectiveAmplitude],
|
|
469
|
+
[amplitudeRange, effectiveAmplitude]
|
|
470
|
+
);
|
|
471
|
+
const wavyActivePath = React3.useMemo(
|
|
439
472
|
() => isWavy ? generateWavyCircularPath(
|
|
440
473
|
center,
|
|
441
474
|
radius,
|
|
@@ -444,8 +477,8 @@ var CircularProgress = React12.forwardRef(
|
|
|
444
477
|
) : null,
|
|
445
478
|
[isWavy, center, radius, effectiveAmplitude, effectiveWavelength]
|
|
446
479
|
);
|
|
447
|
-
const circumference =
|
|
448
|
-
const gapForTrack =
|
|
480
|
+
const circumference = React3.useMemo(() => 2 * Math.PI * radius, [radius]);
|
|
481
|
+
const gapForTrack = React3.useMemo(
|
|
449
482
|
() => (gapSize + trackHeight) / circumference,
|
|
450
483
|
[gapSize, trackHeight, circumference]
|
|
451
484
|
);
|
|
@@ -454,6 +487,145 @@ var CircularProgress = React12.forwardRef(
|
|
|
454
487
|
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
455
488
|
const ActiveCircleElem = m.circle;
|
|
456
489
|
const ActivePathElem = m.path;
|
|
490
|
+
const indeterminateSvgRef = React3.useRef(null);
|
|
491
|
+
const indeterminateTrackRef = React3.useRef(null);
|
|
492
|
+
const indeterminateActiveRef = React3.useRef(null);
|
|
493
|
+
const indeterminateWavyTrackPathRef = React3.useRef(null);
|
|
494
|
+
const indeterminateWavyActivePathRef = React3.useRef(null);
|
|
495
|
+
const cachedPathLengthRef = React3.useRef(0);
|
|
496
|
+
React3.useLayoutEffect(() => {
|
|
497
|
+
if (!isWavy || !wavyActivePath) {
|
|
498
|
+
cachedPathLengthRef.current = circumference;
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const el = indeterminateActiveRef.current;
|
|
502
|
+
if (el && "getTotalLength" in el) {
|
|
503
|
+
try {
|
|
504
|
+
const len = el.getTotalLength();
|
|
505
|
+
if (len > 0) {
|
|
506
|
+
cachedPathLengthRef.current = len;
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
} catch (e) {
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
cachedPathLengthRef.current = circumference;
|
|
513
|
+
}, [isWavy, circumference, wavyActivePath]);
|
|
514
|
+
useAnimationFrame((time) => {
|
|
515
|
+
if (isDeterminate) return;
|
|
516
|
+
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
517
|
+
const scaledTime = time * safeCrawlerSpeed;
|
|
518
|
+
const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
|
|
519
|
+
const globalAngle = globalCycle / GLOBAL_ROTATION_DURATION * GLOBAL_ROTATION_TARGET;
|
|
520
|
+
const additionalFullCycles = Math.floor(
|
|
521
|
+
scaledTime / ADDITIONAL_ROTATION_CYCLE
|
|
522
|
+
);
|
|
523
|
+
const additionalCycleTime = scaledTime % ADDITIONAL_ROTATION_CYCLE;
|
|
524
|
+
const additionalEaseT = Math.min(
|
|
525
|
+
1,
|
|
526
|
+
additionalCycleTime / ADDITIONAL_ROTATION_EASE_DURATION
|
|
527
|
+
);
|
|
528
|
+
const additionalAngle = (additionalFullCycles + easeInOutCubic(additionalEaseT)) * ADDITIONAL_ROTATION_STEP;
|
|
529
|
+
const totalRotation = globalAngle + additionalAngle;
|
|
530
|
+
if (indeterminateSvgRef.current) {
|
|
531
|
+
indeterminateSvgRef.current.style.transform = `rotate(${totalRotation - 90}deg)`;
|
|
532
|
+
}
|
|
533
|
+
const progressFullCycle = PROGRESS_CYCLE_DURATION * 2;
|
|
534
|
+
const progressCycleTime = scaledTime % progressFullCycle;
|
|
535
|
+
let progress;
|
|
536
|
+
if (progressCycleTime < PROGRESS_CYCLE_DURATION) {
|
|
537
|
+
const t = progressCycleTime / PROGRESS_CYCLE_DURATION;
|
|
538
|
+
progress = minProgress + (maxProgress - minProgress) * easeInOutCubic(t);
|
|
539
|
+
} else {
|
|
540
|
+
const t = (progressCycleTime - PROGRESS_CYCLE_DURATION) / PROGRESS_CYCLE_DURATION;
|
|
541
|
+
progress = maxProgress - (maxProgress - minProgress) * easeInOutCubic(t);
|
|
542
|
+
}
|
|
543
|
+
if (isWavy) {
|
|
544
|
+
const amplitudeT = (progress - minProgress) / (maxProgress - minProgress);
|
|
545
|
+
const currentAmplitude = resolvedAmplitudeRange[0] + (resolvedAmplitudeRange[1] - resolvedAmplitudeRange[0]) * amplitudeT;
|
|
546
|
+
const dynamicPath = generateWavyCircularPath(
|
|
547
|
+
center,
|
|
548
|
+
radius,
|
|
549
|
+
currentAmplitude,
|
|
550
|
+
effectiveWavelength
|
|
551
|
+
);
|
|
552
|
+
if (indeterminateWavyActivePathRef.current) {
|
|
553
|
+
indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
554
|
+
}
|
|
555
|
+
if (indeterminateWavyTrackPathRef.current) {
|
|
556
|
+
indeterminateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
|
|
557
|
+
}
|
|
558
|
+
const pathEl = indeterminateWavyActivePathRef.current;
|
|
559
|
+
let totalLen = cachedPathLengthRef.current || circumference;
|
|
560
|
+
if (pathEl) {
|
|
561
|
+
try {
|
|
562
|
+
const len = pathEl.getTotalLength();
|
|
563
|
+
if (len > 0) totalLen = len;
|
|
564
|
+
} catch (e) {
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
568
|
+
const activeLen = totalLen * progress;
|
|
569
|
+
const activeOff = 0;
|
|
570
|
+
if (indeterminateWavyActivePathRef.current) {
|
|
571
|
+
indeterminateWavyActivePathRef.current.setAttribute(
|
|
572
|
+
"stroke-dasharray",
|
|
573
|
+
`${activeLen} ${totalLen}`
|
|
574
|
+
);
|
|
575
|
+
indeterminateWavyActivePathRef.current.setAttribute(
|
|
576
|
+
"stroke-dashoffset",
|
|
577
|
+
`${activeOff}`
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
if (shouldShowIndeterminateTrack && indeterminateWavyTrackPathRef.current) {
|
|
581
|
+
const trackStartFrac = progress + gapFrac;
|
|
582
|
+
const trackLen = Math.max(
|
|
583
|
+
1e-3,
|
|
584
|
+
totalLen * (1 - progress - 2 * gapFrac)
|
|
585
|
+
);
|
|
586
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
587
|
+
indeterminateWavyTrackPathRef.current.setAttribute(
|
|
588
|
+
"stroke-dasharray",
|
|
589
|
+
`${trackLen} ${totalLen}`
|
|
590
|
+
);
|
|
591
|
+
indeterminateWavyTrackPathRef.current.setAttribute(
|
|
592
|
+
"stroke-dashoffset",
|
|
593
|
+
`${trackOff}`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
} else {
|
|
597
|
+
const totalLen = circumference;
|
|
598
|
+
const activeLen = totalLen * progress;
|
|
599
|
+
const activeOff = 0;
|
|
600
|
+
if (indeterminateActiveRef.current) {
|
|
601
|
+
indeterminateActiveRef.current.setAttribute(
|
|
602
|
+
"stroke-dasharray",
|
|
603
|
+
`${activeLen} ${totalLen}`
|
|
604
|
+
);
|
|
605
|
+
indeterminateActiveRef.current.setAttribute(
|
|
606
|
+
"stroke-dashoffset",
|
|
607
|
+
`${activeOff}`
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
if (shouldShowIndeterminateTrack && indeterminateTrackRef.current) {
|
|
611
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
612
|
+
const trackStartFrac = progress + gapFrac;
|
|
613
|
+
const trackLen = Math.max(
|
|
614
|
+
1e-3,
|
|
615
|
+
totalLen * (1 - progress - 2 * gapFrac)
|
|
616
|
+
);
|
|
617
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
618
|
+
indeterminateTrackRef.current.setAttribute(
|
|
619
|
+
"stroke-dasharray",
|
|
620
|
+
`${trackLen} ${totalLen}`
|
|
621
|
+
);
|
|
622
|
+
indeterminateTrackRef.current.setAttribute(
|
|
623
|
+
"stroke-dashoffset",
|
|
624
|
+
`${trackOff}`
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
});
|
|
457
629
|
return /* @__PURE__ */ jsx(
|
|
458
630
|
"div",
|
|
459
631
|
__spreadProps(__spreadValues({
|
|
@@ -530,9 +702,10 @@ var CircularProgress = React12.forwardRef(
|
|
|
530
702
|
]
|
|
531
703
|
}
|
|
532
704
|
),
|
|
533
|
-
!isDeterminate && /* @__PURE__ */
|
|
534
|
-
|
|
705
|
+
!isDeterminate && /* @__PURE__ */ jsx(
|
|
706
|
+
"svg",
|
|
535
707
|
{
|
|
708
|
+
ref: indeterminateSvgRef,
|
|
536
709
|
width: size,
|
|
537
710
|
height: size,
|
|
538
711
|
viewBox: `0 0 ${size} ${size}`,
|
|
@@ -541,90 +714,60 @@ var CircularProgress = React12.forwardRef(
|
|
|
541
714
|
position: "absolute",
|
|
542
715
|
inset: 0,
|
|
543
716
|
overflow: "visible",
|
|
544
|
-
|
|
545
|
-
|
|
717
|
+
transformOrigin: "center",
|
|
718
|
+
transform: "rotate(-90deg)"
|
|
546
719
|
},
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
551
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
552
|
-
ease: "linear"
|
|
553
|
-
}
|
|
554
|
-
},
|
|
555
|
-
children: [
|
|
556
|
-
/* @__PURE__ */ jsx(
|
|
557
|
-
m.circle,
|
|
720
|
+
children: isWavy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
721
|
+
shouldShowIndeterminateTrack && /* @__PURE__ */ jsx(
|
|
722
|
+
"path",
|
|
558
723
|
{
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
r: radius,
|
|
724
|
+
ref: indeterminateWavyTrackPathRef,
|
|
725
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
562
726
|
fill: "none",
|
|
563
727
|
stroke: bgTrackColor,
|
|
564
728
|
strokeWidth: trackHeight,
|
|
565
|
-
strokeLinecap: "round"
|
|
566
|
-
style: { originX: "50%", originY: "50%" },
|
|
567
|
-
animate: {
|
|
568
|
-
pathLength: [
|
|
569
|
-
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
|
|
570
|
-
Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
|
|
571
|
-
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
|
|
572
|
-
],
|
|
573
|
-
rotate: [
|
|
574
|
-
`${(0.1 + gapForTrack) * 360}deg`,
|
|
575
|
-
`${(1 + gapForTrack) * 360}deg`,
|
|
576
|
-
`${(1.1 + gapForTrack) * 360}deg`
|
|
577
|
-
]
|
|
578
|
-
},
|
|
579
|
-
transition: {
|
|
580
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
581
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
582
|
-
ease: [0.4, 0, 0.2, 1]
|
|
583
|
-
}
|
|
729
|
+
strokeLinecap: "round"
|
|
584
730
|
}
|
|
585
731
|
),
|
|
586
|
-
|
|
587
|
-
|
|
732
|
+
/* @__PURE__ */ jsx(
|
|
733
|
+
"path",
|
|
588
734
|
{
|
|
735
|
+
ref: indeterminateWavyActivePathRef,
|
|
589
736
|
d: wavyActivePath != null ? wavyActivePath : "",
|
|
590
737
|
fill: "none",
|
|
591
738
|
stroke: activeColor,
|
|
592
739
|
strokeWidth: trackHeight,
|
|
593
|
-
strokeLinecap: "round"
|
|
594
|
-
style: { originX: "50%", originY: "50%" },
|
|
595
|
-
animate: {
|
|
596
|
-
pathLength: [0.1, 0.75, 0.1],
|
|
597
|
-
rotate: ["0deg", "90deg", "360deg"]
|
|
598
|
-
},
|
|
599
|
-
transition: {
|
|
600
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
601
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
602
|
-
ease: [0.4, 0, 0.2, 1]
|
|
603
|
-
}
|
|
740
|
+
strokeLinecap: "round"
|
|
604
741
|
}
|
|
605
|
-
)
|
|
606
|
-
|
|
742
|
+
)
|
|
743
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
744
|
+
shouldShowIndeterminateTrack && /* @__PURE__ */ jsx(
|
|
745
|
+
"circle",
|
|
746
|
+
{
|
|
747
|
+
ref: indeterminateTrackRef,
|
|
748
|
+
cx: center,
|
|
749
|
+
cy: center,
|
|
750
|
+
r: radius,
|
|
751
|
+
fill: "none",
|
|
752
|
+
stroke: bgTrackColor,
|
|
753
|
+
strokeWidth: trackHeight,
|
|
754
|
+
strokeLinecap: "round"
|
|
755
|
+
}
|
|
756
|
+
),
|
|
757
|
+
/* @__PURE__ */ jsx(
|
|
758
|
+
"circle",
|
|
607
759
|
{
|
|
760
|
+
ref: indeterminateActiveRef,
|
|
608
761
|
cx: center,
|
|
609
762
|
cy: center,
|
|
610
763
|
r: radius,
|
|
611
764
|
fill: "none",
|
|
612
765
|
stroke: activeColor,
|
|
613
766
|
strokeWidth: trackHeight,
|
|
614
|
-
strokeLinecap: "round"
|
|
615
|
-
style: { originX: "50%", originY: "50%" },
|
|
616
|
-
animate: {
|
|
617
|
-
pathLength: [0.1, 0.75, 0.1],
|
|
618
|
-
rotate: ["0deg", "90deg", "360deg"]
|
|
619
|
-
},
|
|
620
|
-
transition: {
|
|
621
|
-
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
622
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
623
|
-
ease: [0.4, 0, 0.2, 1]
|
|
624
|
-
}
|
|
767
|
+
strokeLinecap: "round"
|
|
625
768
|
}
|
|
626
769
|
)
|
|
627
|
-
]
|
|
770
|
+
] })
|
|
628
771
|
}
|
|
629
772
|
)
|
|
630
773
|
] })
|
|
@@ -634,9 +777,9 @@ var CircularProgress = React12.forwardRef(
|
|
|
634
777
|
);
|
|
635
778
|
CircularProgress.displayName = "CircularProgress";
|
|
636
779
|
function useContainerWidth() {
|
|
637
|
-
const [width, setWidth] =
|
|
638
|
-
const observerRef =
|
|
639
|
-
const ref =
|
|
780
|
+
const [width, setWidth] = React3.useState(0);
|
|
781
|
+
const observerRef = React3.useRef(null);
|
|
782
|
+
const ref = React3.useCallback((node) => {
|
|
640
783
|
if (observerRef.current) {
|
|
641
784
|
observerRef.current.disconnect();
|
|
642
785
|
observerRef.current = null;
|
|
@@ -650,7 +793,7 @@ function useContainerWidth() {
|
|
|
650
793
|
observerRef.current = obs;
|
|
651
794
|
}
|
|
652
795
|
}, []);
|
|
653
|
-
|
|
796
|
+
React3.useEffect(() => {
|
|
654
797
|
return () => {
|
|
655
798
|
if (observerRef.current) {
|
|
656
799
|
observerRef.current.disconnect();
|
|
@@ -660,7 +803,7 @@ function useContainerWidth() {
|
|
|
660
803
|
return [ref, width];
|
|
661
804
|
}
|
|
662
805
|
function useMergedRef(...refs) {
|
|
663
|
-
return
|
|
806
|
+
return React3.useCallback(
|
|
664
807
|
(node) => {
|
|
665
808
|
for (const ref of refs) {
|
|
666
809
|
if (typeof ref === "function") {
|
|
@@ -674,7 +817,7 @@ function useMergedRef(...refs) {
|
|
|
674
817
|
[refs]
|
|
675
818
|
);
|
|
676
819
|
}
|
|
677
|
-
var FlatLinearTrack =
|
|
820
|
+
var FlatLinearTrack = React3.memo(function FlatLinearTrack2({
|
|
678
821
|
trackHeight,
|
|
679
822
|
activeColor,
|
|
680
823
|
trackColor,
|
|
@@ -750,7 +893,7 @@ var FlatLinearTrack = React12.memo(function FlatLinearTrack2({
|
|
|
750
893
|
}
|
|
751
894
|
);
|
|
752
895
|
});
|
|
753
|
-
var WavyLinearTrack =
|
|
896
|
+
var WavyLinearTrack = React3.memo(function WavyLinearTrack2({
|
|
754
897
|
trackHeight,
|
|
755
898
|
svgHeight,
|
|
756
899
|
amplitude,
|
|
@@ -769,13 +912,13 @@ var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
|
769
912
|
}) {
|
|
770
913
|
const isDeterminate = typeof value === "number";
|
|
771
914
|
const clampedValue = isDeterminate ? Math.max(0, Math.min(100, value)) : 100;
|
|
772
|
-
const titleId =
|
|
915
|
+
const titleId = React3.useId();
|
|
773
916
|
const [containerRef, width] = useContainerWidth();
|
|
774
|
-
const activePathRef =
|
|
775
|
-
const trackPathRef =
|
|
917
|
+
const activePathRef = React3.useRef(null);
|
|
918
|
+
const trackPathRef = React3.useRef(null);
|
|
776
919
|
const amplitudeMV = useMotionValue(amplitude);
|
|
777
920
|
const fractionMV = useMotionValue(isDeterminate ? clampedValue / 100 : 1);
|
|
778
|
-
|
|
921
|
+
React3.useEffect(() => {
|
|
779
922
|
if (isDeterminate) {
|
|
780
923
|
const fraction = clampedValue / 100;
|
|
781
924
|
let targetAmp = amplitude;
|
|
@@ -788,6 +931,12 @@ var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
|
788
931
|
duration: 0.5
|
|
789
932
|
});
|
|
790
933
|
animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
|
|
934
|
+
} else {
|
|
935
|
+
animate(amplitudeMV, amplitude, {
|
|
936
|
+
type: "spring",
|
|
937
|
+
bounce: 0,
|
|
938
|
+
duration: 0.5
|
|
939
|
+
});
|
|
791
940
|
}
|
|
792
941
|
}, [
|
|
793
942
|
clampedValue,
|
|
@@ -801,10 +950,10 @@ var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
|
801
950
|
1,
|
|
802
951
|
isDeterminate ? wavelength : indeterminateWavelength
|
|
803
952
|
);
|
|
804
|
-
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
805
953
|
useAnimationFrame((time) => {
|
|
806
954
|
if (width === 0) return;
|
|
807
955
|
const currentAmp = amplitudeMV.get();
|
|
956
|
+
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
808
957
|
const phase = time / 1e3 * waveSpeed * activeWavelength;
|
|
809
958
|
const capWidth = trackHeight / 2;
|
|
810
959
|
let activePathD = "";
|
|
@@ -824,7 +973,7 @@ var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
|
824
973
|
currentAmp
|
|
825
974
|
);
|
|
826
975
|
} else if (fraction === 0) {
|
|
827
|
-
activePathD =
|
|
976
|
+
activePathD = "";
|
|
828
977
|
}
|
|
829
978
|
const trackStart = adjHead + totalGap;
|
|
830
979
|
if (trackStart < width - capWidth) {
|
|
@@ -856,20 +1005,20 @@ var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
|
856
1005
|
activeLines.push({ tail: l1T, head: l1H });
|
|
857
1006
|
activeLines.push({ tail: l2T, head: l2H });
|
|
858
1007
|
}
|
|
859
|
-
const
|
|
860
|
-
const
|
|
861
|
-
const
|
|
1008
|
+
const activeSegments = activeLines.map((line) => {
|
|
1009
|
+
const rawTail = line.tail * width;
|
|
1010
|
+
const rawHead = line.head * width;
|
|
862
1011
|
const adjTail = Math.max(
|
|
863
1012
|
capWidth,
|
|
864
|
-
Math.min(width - capWidth,
|
|
1013
|
+
Math.min(width - capWidth, rawTail)
|
|
865
1014
|
);
|
|
866
1015
|
const adjHead = Math.max(
|
|
867
1016
|
capWidth,
|
|
868
|
-
Math.min(width - capWidth,
|
|
1017
|
+
Math.min(width - capWidth, rawHead)
|
|
869
1018
|
);
|
|
870
1019
|
return { adjTail, adjHead };
|
|
871
1020
|
}).filter((seg) => seg.adjHead - seg.adjTail > 0.1);
|
|
872
|
-
activePathD =
|
|
1021
|
+
activePathD = activeSegments.map(
|
|
873
1022
|
(seg) => getSinePath(
|
|
874
1023
|
seg.adjTail,
|
|
875
1024
|
seg.adjHead,
|
|
@@ -878,13 +1027,24 @@ var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
|
878
1027
|
currentAmp
|
|
879
1028
|
)
|
|
880
1029
|
).join(" ");
|
|
1030
|
+
const validActiveLines = activeLines.filter(
|
|
1031
|
+
(line) => line.head > line.tail && line.head * width > 0 && line.tail * width < width
|
|
1032
|
+
).sort((a, b) => a.tail - b.tail);
|
|
881
1033
|
let currentTrackX = capWidth;
|
|
882
|
-
for (const
|
|
883
|
-
const
|
|
1034
|
+
for (const line of validActiveLines) {
|
|
1035
|
+
const blockStart = line.tail * width - totalGap;
|
|
1036
|
+
const blockEnd = line.head * width + totalGap;
|
|
1037
|
+
const trackEnd = Math.min(width - capWidth, blockStart);
|
|
884
1038
|
if (trackEnd > currentTrackX) {
|
|
885
|
-
trackD += `${getSinePath(
|
|
1039
|
+
trackD += `${getSinePath(
|
|
1040
|
+
currentTrackX,
|
|
1041
|
+
trackEnd,
|
|
1042
|
+
phase,
|
|
1043
|
+
activeWavelength,
|
|
1044
|
+
trackAmp
|
|
1045
|
+
)} `;
|
|
886
1046
|
}
|
|
887
|
-
currentTrackX = Math.max(currentTrackX,
|
|
1047
|
+
currentTrackX = Math.max(currentTrackX, blockEnd);
|
|
888
1048
|
}
|
|
889
1049
|
if (currentTrackX < width - capWidth) {
|
|
890
1050
|
trackD += getSinePath(
|
|
@@ -897,15 +1057,15 @@ var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
|
897
1057
|
}
|
|
898
1058
|
}
|
|
899
1059
|
if (activePathRef.current)
|
|
900
|
-
activePathRef.current.setAttribute("d", activePathD);
|
|
1060
|
+
activePathRef.current.setAttribute("d", activePathD || "");
|
|
901
1061
|
if (trackPathRef.current)
|
|
902
|
-
trackPathRef.current.setAttribute("d", trackD.trim());
|
|
1062
|
+
trackPathRef.current.setAttribute("d", trackD.trim() || "");
|
|
903
1063
|
});
|
|
904
1064
|
return /* @__PURE__ */ jsx(
|
|
905
1065
|
"div",
|
|
906
1066
|
{
|
|
907
1067
|
ref: containerRef,
|
|
908
|
-
className: "relative w-full
|
|
1068
|
+
className: "relative w-full",
|
|
909
1069
|
style: { height: svgHeight },
|
|
910
1070
|
children: width > 0 && /* @__PURE__ */ jsxs(
|
|
911
1071
|
"svg",
|
|
@@ -946,7 +1106,7 @@ var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
|
946
1106
|
}
|
|
947
1107
|
);
|
|
948
1108
|
});
|
|
949
|
-
var LinearProgress =
|
|
1109
|
+
var LinearProgress = React3.forwardRef(
|
|
950
1110
|
(_a, ref) => {
|
|
951
1111
|
var _b = _a, {
|
|
952
1112
|
value,
|
|
@@ -959,7 +1119,7 @@ var LinearProgress = React12.forwardRef(
|
|
|
959
1119
|
waveSpeed = 1,
|
|
960
1120
|
crawlerSpeed = 1,
|
|
961
1121
|
determinateAnimation = "md3",
|
|
962
|
-
indeterminateAnimation = "
|
|
1122
|
+
indeterminateAnimation = "md3",
|
|
963
1123
|
gapSize = 4,
|
|
964
1124
|
showStopIndicator = "auto",
|
|
965
1125
|
color,
|
|
@@ -987,33 +1147,35 @@ var LinearProgress = React12.forwardRef(
|
|
|
987
1147
|
]);
|
|
988
1148
|
const isDeterminate = value !== void 0;
|
|
989
1149
|
const clampedValue = isDeterminate ? Math.min(100, Math.max(0, value)) : 0;
|
|
990
|
-
const containerRef =
|
|
1150
|
+
const containerRef = React3.useRef(null);
|
|
991
1151
|
const mergedRef = useMergedRef(ref, containerRef);
|
|
992
|
-
const [isRtl, setIsRtl] =
|
|
993
|
-
|
|
1152
|
+
const [isRtl, setIsRtl] = React3.useState(false);
|
|
1153
|
+
React3.useEffect(() => {
|
|
994
1154
|
if (containerRef.current) {
|
|
995
1155
|
const dir = getComputedStyle(containerRef.current).direction;
|
|
996
1156
|
setIsRtl(dir === "rtl");
|
|
997
1157
|
}
|
|
998
1158
|
}, []);
|
|
999
|
-
const isWavy = shape === "wavy";
|
|
1000
1159
|
const resolvedTrackShape = trackShape != null ? trackShape : shape;
|
|
1001
|
-
const
|
|
1002
|
-
const
|
|
1160
|
+
const isWavy = shape === "wavy" || resolvedTrackShape === "wavy";
|
|
1161
|
+
const effectiveAmplitude = React3.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
|
|
1162
|
+
const svgHeight = React3.useMemo(
|
|
1003
1163
|
() => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
|
|
1004
1164
|
[isWavy, trackHeight, effectiveAmplitude]
|
|
1005
1165
|
);
|
|
1006
|
-
const shouldShowStop =
|
|
1007
|
-
() => isDeterminate && resolvedTrackShape === "flat" &&
|
|
1166
|
+
const shouldShowStop = React3.useMemo(
|
|
1167
|
+
() => isDeterminate && resolvedTrackShape === "flat" && showStopIndicator !== false,
|
|
1008
1168
|
[isDeterminate, resolvedTrackShape, showStopIndicator]
|
|
1009
1169
|
);
|
|
1010
|
-
const stopSize =
|
|
1170
|
+
const stopSize = React3.useMemo(
|
|
1011
1171
|
() => Math.max(2, trackHeight > 4 ? 4 : trackHeight / 2),
|
|
1012
1172
|
[trackHeight]
|
|
1013
1173
|
);
|
|
1014
1174
|
const stopOffset = (trackHeight - stopSize) / 2;
|
|
1015
1175
|
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
1016
1176
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
1177
|
+
const useWavyTrack = isWavy || !isDeterminate;
|
|
1178
|
+
const trackAmp = isWavy ? effectiveAmplitude : 0;
|
|
1017
1179
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
|
|
1018
1180
|
"div",
|
|
1019
1181
|
__spreadProps(__spreadValues({
|
|
@@ -1030,12 +1192,12 @@ var LinearProgress = React12.forwardRef(
|
|
|
1030
1192
|
style: { height: svgHeight }
|
|
1031
1193
|
}, restProps), {
|
|
1032
1194
|
children: [
|
|
1033
|
-
|
|
1195
|
+
useWavyTrack ? /* @__PURE__ */ jsx(
|
|
1034
1196
|
WavyLinearTrack,
|
|
1035
1197
|
{
|
|
1036
1198
|
trackHeight,
|
|
1037
1199
|
svgHeight,
|
|
1038
|
-
amplitude:
|
|
1200
|
+
amplitude: trackAmp,
|
|
1039
1201
|
wavelength,
|
|
1040
1202
|
indeterminateWavelength,
|
|
1041
1203
|
activeColor,
|
|
@@ -1080,14 +1242,14 @@ var LinearProgress = React12.forwardRef(
|
|
|
1080
1242
|
}
|
|
1081
1243
|
);
|
|
1082
1244
|
LinearProgress.displayName = "LinearProgress";
|
|
1083
|
-
var ProgressIndicator =
|
|
1245
|
+
var ProgressIndicator = React3.forwardRef((props, ref) => {
|
|
1084
1246
|
if (props.variant === "circular") {
|
|
1085
1247
|
return /* @__PURE__ */ jsx(CircularProgress, __spreadValues({ ref }, props));
|
|
1086
1248
|
}
|
|
1087
1249
|
return /* @__PURE__ */ jsx(LinearProgress, __spreadValues({ ref }, props));
|
|
1088
1250
|
});
|
|
1089
1251
|
ProgressIndicator.displayName = "ProgressIndicator";
|
|
1090
|
-
var RippleItem =
|
|
1252
|
+
var RippleItem = React3.memo(function RippleItem2({
|
|
1091
1253
|
ripple,
|
|
1092
1254
|
onDone
|
|
1093
1255
|
}) {
|
|
@@ -1131,8 +1293,8 @@ function Ripple({
|
|
|
1131
1293
|
}
|
|
1132
1294
|
function useRippleState(options = {}) {
|
|
1133
1295
|
const { disabled = false } = options;
|
|
1134
|
-
const [ripples, setRipples] =
|
|
1135
|
-
const onPointerDown =
|
|
1296
|
+
const [ripples, setRipples] = React3.useState([]);
|
|
1297
|
+
const onPointerDown = React3.useCallback(
|
|
1136
1298
|
(e) => {
|
|
1137
1299
|
if (disabled) return;
|
|
1138
1300
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
@@ -1149,7 +1311,7 @@ function useRippleState(options = {}) {
|
|
|
1149
1311
|
},
|
|
1150
1312
|
[disabled]
|
|
1151
1313
|
);
|
|
1152
|
-
const removeRipple =
|
|
1314
|
+
const removeRipple = React3.useCallback((id) => {
|
|
1153
1315
|
setRipples((prev) => prev.filter((r) => r.id !== id));
|
|
1154
1316
|
}, []);
|
|
1155
1317
|
return { ripples, onPointerDown, removeRipple };
|
|
@@ -1297,7 +1459,7 @@ function resolveDisabledBgClass(colorStyle) {
|
|
|
1297
1459
|
}
|
|
1298
1460
|
return "disabled:text-m3-on-surface/[0.38]";
|
|
1299
1461
|
}
|
|
1300
|
-
var IconButtonComponent =
|
|
1462
|
+
var IconButtonComponent = React3.forwardRef(
|
|
1301
1463
|
(_a, ref) => {
|
|
1302
1464
|
var _b = _a, {
|
|
1303
1465
|
className,
|
|
@@ -1339,18 +1501,18 @@ var IconButtonComponent = React12.forwardRef(
|
|
|
1339
1501
|
var _a2, _b2, _c, _d, _e;
|
|
1340
1502
|
const isToggle = variant === "toggle";
|
|
1341
1503
|
const isSelected = isToggle && !!selected;
|
|
1342
|
-
const resolvedColorClass =
|
|
1504
|
+
const resolvedColorClass = React3.useMemo(
|
|
1343
1505
|
() => isSelected ? colorStyles[colorStyle].selected : colorStyles[colorStyle].default,
|
|
1344
1506
|
[isSelected, colorStyle]
|
|
1345
1507
|
);
|
|
1346
|
-
const outlineWidthClass =
|
|
1508
|
+
const outlineWidthClass = React3.useMemo(
|
|
1347
1509
|
() => {
|
|
1348
1510
|
var _a3;
|
|
1349
1511
|
return colorStyle === "outlined" && !isSelected ? (_a3 = SIZE_OUTLINE_WIDTH[size]) != null ? _a3 : "border" : "";
|
|
1350
1512
|
},
|
|
1351
1513
|
[colorStyle, isSelected, size]
|
|
1352
1514
|
);
|
|
1353
|
-
const disabledBgClass =
|
|
1515
|
+
const disabledBgClass = React3.useMemo(
|
|
1354
1516
|
() => resolveDisabledBgClass(colorStyle),
|
|
1355
1517
|
[colorStyle]
|
|
1356
1518
|
);
|
|
@@ -1373,7 +1535,7 @@ var IconButtonComponent = React12.forwardRef(
|
|
|
1373
1535
|
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
1374
1536
|
disabled: loading
|
|
1375
1537
|
});
|
|
1376
|
-
const handleClick =
|
|
1538
|
+
const handleClick = React3.useCallback(
|
|
1377
1539
|
(e) => {
|
|
1378
1540
|
if (loading) {
|
|
1379
1541
|
e.preventDefault();
|
|
@@ -1383,7 +1545,7 @@ var IconButtonComponent = React12.forwardRef(
|
|
|
1383
1545
|
},
|
|
1384
1546
|
[loading, onClick]
|
|
1385
1547
|
);
|
|
1386
|
-
const handleKeyDown =
|
|
1548
|
+
const handleKeyDown = React3.useCallback(
|
|
1387
1549
|
(e) => {
|
|
1388
1550
|
if (loading) return;
|
|
1389
1551
|
if ((e.key === "Enter" || e.key === " ") && onClick) {
|
|
@@ -1439,7 +1601,7 @@ var IconButtonComponent = React12.forwardRef(
|
|
|
1439
1601
|
width: isCustomSize ? `${iconSize}px` : void 0,
|
|
1440
1602
|
height: isCustomSize ? `${iconSize}px` : void 0
|
|
1441
1603
|
},
|
|
1442
|
-
children: isSelected && selectedIcon ? selectedIcon : asChild ?
|
|
1604
|
+
children: isSelected && selectedIcon ? selectedIcon : asChild ? React3.Children.only(children).props.children : children
|
|
1443
1605
|
}),
|
|
1444
1606
|
isSelected && selectedIcon ? "selected-content" : "content"
|
|
1445
1607
|
) })
|
|
@@ -1456,7 +1618,7 @@ var IconButtonComponent = React12.forwardRef(
|
|
|
1456
1618
|
className
|
|
1457
1619
|
);
|
|
1458
1620
|
if (asChild) {
|
|
1459
|
-
const child =
|
|
1621
|
+
const child = React3.Children.only(children);
|
|
1460
1622
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
1461
1623
|
Slot,
|
|
1462
1624
|
__spreadProps(__spreadValues({
|
|
@@ -1473,7 +1635,7 @@ var IconButtonComponent = React12.forwardRef(
|
|
|
1473
1635
|
}),
|
|
1474
1636
|
className: containerClassName
|
|
1475
1637
|
}, restProps), {
|
|
1476
|
-
children:
|
|
1638
|
+
children: React3.cloneElement(child, { children: innerContent })
|
|
1477
1639
|
})
|
|
1478
1640
|
) });
|
|
1479
1641
|
}
|
|
@@ -1501,13 +1663,13 @@ var IconButtonComponent = React12.forwardRef(
|
|
|
1501
1663
|
}
|
|
1502
1664
|
);
|
|
1503
1665
|
IconButtonComponent.displayName = "IconButton";
|
|
1504
|
-
var IconButton =
|
|
1666
|
+
var IconButton = React3.memo(IconButtonComponent);
|
|
1505
1667
|
var VARIANT_FONT = {
|
|
1506
1668
|
outlined: "'Material Symbols Outlined'",
|
|
1507
1669
|
rounded: "'Material Symbols Rounded'",
|
|
1508
1670
|
sharp: "'Material Symbols Sharp'"
|
|
1509
1671
|
};
|
|
1510
|
-
var IconComponent =
|
|
1672
|
+
var IconComponent = React3.forwardRef(
|
|
1511
1673
|
(_a, ref) => {
|
|
1512
1674
|
var _b = _a, {
|
|
1513
1675
|
name,
|
|
@@ -1573,7 +1735,7 @@ var IconComponent = React12.forwardRef(
|
|
|
1573
1735
|
}
|
|
1574
1736
|
);
|
|
1575
1737
|
IconComponent.displayName = "Icon";
|
|
1576
|
-
var Icon =
|
|
1738
|
+
var Icon = React3.memo(IconComponent);
|
|
1577
1739
|
var DURATION_MAP = {
|
|
1578
1740
|
short: 4e3,
|
|
1579
1741
|
long: 7e3
|
|
@@ -1615,9 +1777,9 @@ function toSnackbarData(item) {
|
|
|
1615
1777
|
return { id: generateId(), visuals: item.visuals, resolve: item.resolve };
|
|
1616
1778
|
}
|
|
1617
1779
|
function useSnackbarState() {
|
|
1618
|
-
const [current, setCurrent] =
|
|
1619
|
-
const queueRef =
|
|
1620
|
-
const showSnackbar =
|
|
1780
|
+
const [current, setCurrent] = React3.useState(null);
|
|
1781
|
+
const queueRef = React3.useRef([]);
|
|
1782
|
+
const showSnackbar = React3.useCallback(
|
|
1621
1783
|
(visuals) => {
|
|
1622
1784
|
return new Promise((resolve) => {
|
|
1623
1785
|
const item = { visuals, resolve };
|
|
@@ -1630,14 +1792,14 @@ function useSnackbarState() {
|
|
|
1630
1792
|
},
|
|
1631
1793
|
[]
|
|
1632
1794
|
);
|
|
1633
|
-
const _dismiss =
|
|
1795
|
+
const _dismiss = React3.useCallback((result) => {
|
|
1634
1796
|
setCurrent((prev) => {
|
|
1635
1797
|
if (prev) prev.resolve(result);
|
|
1636
1798
|
const next = queueRef.current.shift();
|
|
1637
1799
|
return next ? toSnackbarData(next) : null;
|
|
1638
1800
|
});
|
|
1639
1801
|
}, []);
|
|
1640
|
-
|
|
1802
|
+
React3.useEffect(() => {
|
|
1641
1803
|
return () => {
|
|
1642
1804
|
for (const item of queueRef.current) {
|
|
1643
1805
|
item.resolve(RESULT.DISMISSED);
|
|
@@ -1647,7 +1809,7 @@ function useSnackbarState() {
|
|
|
1647
1809
|
}, []);
|
|
1648
1810
|
return { current, showSnackbar, _dismiss };
|
|
1649
1811
|
}
|
|
1650
|
-
var Snackbar =
|
|
1812
|
+
var Snackbar = React3.memo(function Snackbar2({
|
|
1651
1813
|
data,
|
|
1652
1814
|
className
|
|
1653
1815
|
}) {
|
|
@@ -1661,15 +1823,15 @@ var Snackbar = React12.memo(function Snackbar2({
|
|
|
1661
1823
|
} = visuals;
|
|
1662
1824
|
const reducedMotion = useReducedMotion();
|
|
1663
1825
|
const durationMs = resolveDuration(duration);
|
|
1664
|
-
|
|
1826
|
+
React3.useEffect(() => {
|
|
1665
1827
|
const timer = setTimeout(() => resolve(RESULT.DISMISSED), durationMs);
|
|
1666
1828
|
return () => clearTimeout(timer);
|
|
1667
1829
|
}, [resolve, durationMs]);
|
|
1668
|
-
const handleAction =
|
|
1830
|
+
const handleAction = React3.useCallback(
|
|
1669
1831
|
() => resolve(RESULT.ACTION),
|
|
1670
1832
|
[resolve]
|
|
1671
1833
|
);
|
|
1672
|
-
const handleDismiss =
|
|
1834
|
+
const handleDismiss = React3.useCallback(
|
|
1673
1835
|
() => resolve(RESULT.DISMISSED),
|
|
1674
1836
|
[resolve]
|
|
1675
1837
|
);
|
|
@@ -1737,7 +1899,7 @@ var Snackbar = React12.memo(function Snackbar2({
|
|
|
1737
1899
|
Snackbar.displayName = "Snackbar";
|
|
1738
1900
|
function SnackbarHost({ state, className }) {
|
|
1739
1901
|
const { current, _dismiss } = state;
|
|
1740
|
-
const wrappedData =
|
|
1902
|
+
const wrappedData = React3.useMemo(() => {
|
|
1741
1903
|
if (!current) return null;
|
|
1742
1904
|
return __spreadProps(__spreadValues({}, current), { resolve: _dismiss });
|
|
1743
1905
|
}, [current, _dismiss]);
|
|
@@ -1755,12 +1917,12 @@ function SnackbarHost({ state, className }) {
|
|
|
1755
1917
|
) });
|
|
1756
1918
|
}
|
|
1757
1919
|
SnackbarHost.displayName = "SnackbarHost";
|
|
1758
|
-
var SnackbarContext =
|
|
1920
|
+
var SnackbarContext = React3.createContext(
|
|
1759
1921
|
null
|
|
1760
1922
|
);
|
|
1761
1923
|
function SnackbarProvider({ children }) {
|
|
1762
1924
|
const state = useSnackbarState();
|
|
1763
|
-
const contextValue =
|
|
1925
|
+
const contextValue = React3.useMemo(
|
|
1764
1926
|
() => ({ showSnackbar: state.showSnackbar }),
|
|
1765
1927
|
[state.showSnackbar]
|
|
1766
1928
|
);
|
|
@@ -1771,7 +1933,7 @@ function SnackbarProvider({ children }) {
|
|
|
1771
1933
|
}
|
|
1772
1934
|
SnackbarProvider.displayName = "SnackbarProvider";
|
|
1773
1935
|
function useSnackbar() {
|
|
1774
|
-
const ctx =
|
|
1936
|
+
const ctx = React3.useContext(SnackbarContext);
|
|
1775
1937
|
if (!ctx) {
|
|
1776
1938
|
throw new Error("useSnackbar must be used within a <SnackbarProvider>.");
|
|
1777
1939
|
}
|
|
@@ -2349,7 +2511,7 @@ function TooltipBox({
|
|
|
2349
2511
|
onKeyDown: handleKeyDown,
|
|
2350
2512
|
"aria-label": ariaLabel,
|
|
2351
2513
|
"aria-describedby": state.isVisible ? tooltipId : void 0,
|
|
2352
|
-
children:
|
|
2514
|
+
children: React3.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children })
|
|
2353
2515
|
}
|
|
2354
2516
|
),
|
|
2355
2517
|
mounted && createPortal(
|