@bug-on/m3-expressive 1.2.7 → 1.3.1
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.d.mts +3 -3
- package/dist/buttons.d.ts +3 -3
- package/dist/buttons.js +195 -50
- package/dist/buttons.js.map +1 -1
- package/dist/buttons.mjs +196 -51
- package/dist/buttons.mjs.map +1 -1
- package/dist/{core-D4048_K5.d.mts → core-CAU8g2HY.d.mts} +1 -1
- package/dist/{core-Bc5Wj_pc.d.ts → core-DRrLnsnJ.d.ts} +1 -1
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +159 -28
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +160 -29
- package/dist/core.mjs.map +1 -1
- package/dist/feedback.d.mts +28 -6
- package/dist/feedback.d.ts +28 -6
- package/dist/feedback.js +161 -30
- package/dist/feedback.js.map +1 -1
- package/dist/feedback.mjs +162 -31
- package/dist/feedback.mjs.map +1 -1
- package/dist/forms.d.mts +3 -2
- package/dist/forms.d.ts +3 -2
- package/dist/forms.js +88 -100
- package/dist/forms.js.map +1 -1
- package/dist/forms.mjs +88 -100
- package/dist/forms.mjs.map +1 -1
- package/dist/{icon-button-CSsDmuQC.d.mts → icon-button-CqdQBsRe.d.ts} +11 -5
- package/dist/{icon-button-CSsDmuQC.d.ts → icon-button-USJo7AqO.d.mts} +11 -5
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +570 -309
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +570 -310
- package/dist/index.mjs.map +1 -1
- package/dist/layout.d.mts +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +159 -60
- package/dist/layout.js.map +1 -1
- package/dist/layout.mjs +160 -61
- package/dist/layout.mjs.map +1 -1
- package/dist/{md3-Dty-Qcad.d.mts → md3-D0_Z7IXj.d.mts} +9 -1
- package/dist/{md3-Dty-Qcad.d.ts → md3-D0_Z7IXj.d.ts} +9 -1
- package/dist/navigation.d.mts +103 -33
- package/dist/navigation.d.ts +103 -33
- package/dist/navigation.js +443 -152
- package/dist/navigation.js.map +1 -1
- package/dist/navigation.mjs +444 -154
- package/dist/navigation.mjs.map +1 -1
- package/dist/overlays.js +159 -28
- package/dist/overlays.js.map +1 -1
- package/dist/overlays.mjs +160 -29
- package/dist/overlays.mjs.map +1 -1
- package/dist/pickers.js +159 -28
- package/dist/pickers.js.map +1 -1
- package/dist/pickers.mjs +160 -29
- package/dist/pickers.mjs.map +1 -1
- package/dist/{split-button-trailing-uncheckable-DPJL3bO6.d.mts → split-button-trailing-uncheckable-CIVEYgjY.d.mts} +12 -7
- package/dist/{split-button-trailing-uncheckable--BhNTEJw.d.ts → split-button-trailing-uncheckable-DTQJjzsB.d.ts} +12 -7
- package/dist/{text-field-DWC7qOvp.d.mts → text-field-CiOmDM_8.d.ts} +52 -51
- package/dist/{text-field-DWC7qOvp.d.ts → text-field-Ear3hCSq.d.mts} +52 -51
- package/package.json +3 -3
package/dist/feedback.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useReducedMotion, LazyMotion, domMax, m,
|
|
2
|
+
import { useReducedMotion, LazyMotion, domMax, m, useMotionValue, animate, useAnimationFrame, AnimatePresence } from 'motion/react';
|
|
3
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';
|
|
@@ -139,9 +139,9 @@ function BadgedBox({
|
|
|
139
139
|
badge,
|
|
140
140
|
children,
|
|
141
141
|
className,
|
|
142
|
-
|
|
142
|
+
size
|
|
143
143
|
}) {
|
|
144
|
-
const isLarge =
|
|
144
|
+
const isLarge = size ? size === "lg" : detectBadgeHasContent(badge);
|
|
145
145
|
const badgePositionClass = isLarge ? "translate-x-[35%] -translate-y-[35%]" : "translate-x-[50%] -translate-y-[50%]";
|
|
146
146
|
return /* @__PURE__ */ jsxs("span", { className: cn("relative inline-flex", className), children: [
|
|
147
147
|
children,
|
|
@@ -342,7 +342,7 @@ LoadingIndicator.displayName = "LoadingIndicator";
|
|
|
342
342
|
function easeInOutCubic(x) {
|
|
343
343
|
return x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;
|
|
344
344
|
}
|
|
345
|
-
function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
345
|
+
function generateWavyCircularPath(center, radius, amplitude, wavelength, phase = 0) {
|
|
346
346
|
const circumference = 2 * Math.PI * radius;
|
|
347
347
|
const numWaves = Math.max(
|
|
348
348
|
3,
|
|
@@ -350,8 +350,8 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
|
350
350
|
);
|
|
351
351
|
const steps = numWaves * 4;
|
|
352
352
|
const dt = 2 * Math.PI / steps;
|
|
353
|
-
const rAt = (t) => radius + amplitude * Math.sin(numWaves * t);
|
|
354
|
-
const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t);
|
|
353
|
+
const rAt = (t) => radius + amplitude * Math.sin(numWaves * t + phase);
|
|
354
|
+
const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t + phase);
|
|
355
355
|
const xAt = (t) => center + rAt(t) * Math.cos(t);
|
|
356
356
|
const yAt = (t) => center + rAt(t) * Math.sin(t);
|
|
357
357
|
const dxAt = (t) => drAt(t) * Math.cos(t) - rAt(t) * Math.sin(t);
|
|
@@ -416,15 +416,18 @@ var CircularProgress = React3.forwardRef(
|
|
|
416
416
|
size = 48,
|
|
417
417
|
trackHeight = 4,
|
|
418
418
|
shape = "flat",
|
|
419
|
+
trackShape = "flat",
|
|
419
420
|
amplitude,
|
|
420
421
|
wavelength,
|
|
421
422
|
gapSize = 4,
|
|
423
|
+
waveSpeed = 1,
|
|
422
424
|
crawlerSpeed = 1,
|
|
423
425
|
color,
|
|
424
426
|
trackColor,
|
|
425
427
|
showTrack = "auto",
|
|
426
428
|
minProgress = DEFAULT_MIN_PROGRESS,
|
|
427
429
|
maxProgress = DEFAULT_MAX_PROGRESS,
|
|
430
|
+
determinateAnimation = "md3",
|
|
428
431
|
amplitudeRange,
|
|
429
432
|
className,
|
|
430
433
|
"aria-label": ariaLabel
|
|
@@ -433,15 +436,18 @@ var CircularProgress = React3.forwardRef(
|
|
|
433
436
|
"size",
|
|
434
437
|
"trackHeight",
|
|
435
438
|
"shape",
|
|
439
|
+
"trackShape",
|
|
436
440
|
"amplitude",
|
|
437
441
|
"wavelength",
|
|
438
442
|
"gapSize",
|
|
443
|
+
"waveSpeed",
|
|
439
444
|
"crawlerSpeed",
|
|
440
445
|
"color",
|
|
441
446
|
"trackColor",
|
|
442
447
|
"showTrack",
|
|
443
448
|
"minProgress",
|
|
444
449
|
"maxProgress",
|
|
450
|
+
"determinateAnimation",
|
|
445
451
|
"amplitudeRange",
|
|
446
452
|
"className",
|
|
447
453
|
"aria-label"
|
|
@@ -454,6 +460,7 @@ var CircularProgress = React3.forwardRef(
|
|
|
454
460
|
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
455
461
|
const isWavy = shape === "wavy";
|
|
456
462
|
const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
|
|
463
|
+
const shouldShowDeterminateTrack = showTrack === "auto" ? true : showTrack;
|
|
457
464
|
const BASELINE_SIZE = 48;
|
|
458
465
|
const scaleFactor = size / BASELINE_SIZE;
|
|
459
466
|
const effectiveAmplitude = React3.useMemo(
|
|
@@ -486,19 +493,50 @@ var CircularProgress = React3.forwardRef(
|
|
|
486
493
|
const trackOffset = isDeterminate ? activeAngularFraction + gapForTrack : 0;
|
|
487
494
|
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
488
495
|
const ActiveCircleElem = m.circle;
|
|
489
|
-
const ActivePathElem = m.path;
|
|
490
496
|
const indeterminateSvgRef = React3.useRef(null);
|
|
491
497
|
const indeterminateTrackRef = React3.useRef(null);
|
|
492
498
|
const indeterminateActiveRef = React3.useRef(null);
|
|
493
499
|
const indeterminateWavyTrackPathRef = React3.useRef(null);
|
|
494
500
|
const indeterminateWavyActivePathRef = React3.useRef(null);
|
|
501
|
+
const determinateWavyActivePathRef = React3.useRef(null);
|
|
502
|
+
const determinateWavyTrackPathRef = React3.useRef(null);
|
|
495
503
|
const cachedPathLengthRef = React3.useRef(0);
|
|
504
|
+
const fractionMV = useMotionValue(isDeterminate ? clampedValue / 100 : 0);
|
|
505
|
+
const amplitudeMV = useMotionValue(isWavy ? effectiveAmplitude : 0);
|
|
506
|
+
React3.useEffect(() => {
|
|
507
|
+
if (isDeterminate) {
|
|
508
|
+
animate(fractionMV, clampedValue / 100, {
|
|
509
|
+
duration: 0.4,
|
|
510
|
+
ease: [0.2, 0, 0, 1]
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}, [clampedValue, isDeterminate, fractionMV]);
|
|
514
|
+
React3.useEffect(() => {
|
|
515
|
+
if (!isDeterminate || !isWavy) return;
|
|
516
|
+
const fraction = clampedValue / 100;
|
|
517
|
+
let targetAmp = effectiveAmplitude;
|
|
518
|
+
if (determinateAnimation === "md3") {
|
|
519
|
+
targetAmp = fraction <= 0.1 || fraction >= 0.95 ? 0 : effectiveAmplitude;
|
|
520
|
+
}
|
|
521
|
+
animate(amplitudeMV, targetAmp, {
|
|
522
|
+
type: "spring",
|
|
523
|
+
bounce: 0,
|
|
524
|
+
duration: 0.5
|
|
525
|
+
});
|
|
526
|
+
}, [
|
|
527
|
+
clampedValue,
|
|
528
|
+
isDeterminate,
|
|
529
|
+
isWavy,
|
|
530
|
+
effectiveAmplitude,
|
|
531
|
+
amplitudeMV,
|
|
532
|
+
determinateAnimation
|
|
533
|
+
]);
|
|
496
534
|
React3.useLayoutEffect(() => {
|
|
497
535
|
if (!isWavy || !wavyActivePath) {
|
|
498
536
|
cachedPathLengthRef.current = circumference;
|
|
499
537
|
return;
|
|
500
538
|
}
|
|
501
|
-
const el = indeterminateActiveRef.current;
|
|
539
|
+
const el = indeterminateActiveRef.current || determinateWavyActivePathRef.current;
|
|
502
540
|
if (el && "getTotalLength" in el) {
|
|
503
541
|
try {
|
|
504
542
|
const len = el.getTotalLength();
|
|
@@ -512,7 +550,65 @@ var CircularProgress = React3.forwardRef(
|
|
|
512
550
|
cachedPathLengthRef.current = circumference;
|
|
513
551
|
}, [isWavy, circumference, wavyActivePath]);
|
|
514
552
|
useAnimationFrame((time) => {
|
|
515
|
-
|
|
553
|
+
const safeWaveSpeed = Math.max(0.1, waveSpeed);
|
|
554
|
+
const wavePhase = time / 1e3 * safeWaveSpeed * 2 * Math.PI;
|
|
555
|
+
if (isDeterminate) {
|
|
556
|
+
if (isWavy) {
|
|
557
|
+
const currentAmp = amplitudeMV.get();
|
|
558
|
+
const dynamicPath = generateWavyCircularPath(
|
|
559
|
+
center,
|
|
560
|
+
radius,
|
|
561
|
+
currentAmp,
|
|
562
|
+
effectiveWavelength,
|
|
563
|
+
wavePhase
|
|
564
|
+
);
|
|
565
|
+
if (determinateWavyActivePathRef.current) {
|
|
566
|
+
determinateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
567
|
+
}
|
|
568
|
+
if (trackShape === "wavy" && determinateWavyTrackPathRef.current) {
|
|
569
|
+
determinateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
|
|
570
|
+
}
|
|
571
|
+
const pathEl = determinateWavyActivePathRef.current;
|
|
572
|
+
let totalLen = cachedPathLengthRef.current || circumference;
|
|
573
|
+
if (pathEl) {
|
|
574
|
+
try {
|
|
575
|
+
const len = pathEl.getTotalLength();
|
|
576
|
+
if (len > 0) totalLen = len;
|
|
577
|
+
} catch (e) {
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const activeFrac = Math.max(0, Math.min(1, fractionMV.get()));
|
|
581
|
+
const activeLen = totalLen * activeFrac;
|
|
582
|
+
if (determinateWavyActivePathRef.current) {
|
|
583
|
+
determinateWavyActivePathRef.current.setAttribute(
|
|
584
|
+
"stroke-dasharray",
|
|
585
|
+
`${activeLen} ${totalLen}`
|
|
586
|
+
);
|
|
587
|
+
determinateWavyActivePathRef.current.setAttribute(
|
|
588
|
+
"stroke-dashoffset",
|
|
589
|
+
"0"
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
if (shouldShowDeterminateTrack && trackShape === "wavy" && determinateWavyTrackPathRef.current) {
|
|
593
|
+
const gapFrac = (gapSize + trackHeight) / totalLen;
|
|
594
|
+
const trackStartFrac = activeFrac + gapFrac;
|
|
595
|
+
const trackLen = Math.max(
|
|
596
|
+
1e-3,
|
|
597
|
+
totalLen * (1 - activeFrac - 2 * gapFrac)
|
|
598
|
+
);
|
|
599
|
+
const trackOff = -totalLen * trackStartFrac;
|
|
600
|
+
determinateWavyTrackPathRef.current.setAttribute(
|
|
601
|
+
"stroke-dasharray",
|
|
602
|
+
`${trackLen} ${totalLen}`
|
|
603
|
+
);
|
|
604
|
+
determinateWavyTrackPathRef.current.setAttribute(
|
|
605
|
+
"stroke-dashoffset",
|
|
606
|
+
`${trackOff}`
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
516
612
|
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
517
613
|
const scaledTime = time * safeCrawlerSpeed;
|
|
518
614
|
const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
|
|
@@ -547,7 +643,8 @@ var CircularProgress = React3.forwardRef(
|
|
|
547
643
|
center,
|
|
548
644
|
radius,
|
|
549
645
|
currentAmplitude,
|
|
550
|
-
effectiveWavelength
|
|
646
|
+
effectiveWavelength,
|
|
647
|
+
wavePhase
|
|
551
648
|
);
|
|
552
649
|
if (indeterminateWavyActivePathRef.current) {
|
|
553
650
|
indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
|
|
@@ -642,7 +739,7 @@ var CircularProgress = React3.forwardRef(
|
|
|
642
739
|
style: { width: size, height: size }
|
|
643
740
|
}, restProps), {
|
|
644
741
|
children: /* @__PURE__ */ jsxs(LazyMotion, { features: domMax, strict: true, children: [
|
|
645
|
-
/* @__PURE__ */
|
|
742
|
+
/* @__PURE__ */ jsx(
|
|
646
743
|
"svg",
|
|
647
744
|
{
|
|
648
745
|
width: size,
|
|
@@ -650,8 +747,18 @@ var CircularProgress = React3.forwardRef(
|
|
|
650
747
|
viewBox: `0 0 ${size} ${size}`,
|
|
651
748
|
"aria-hidden": "true",
|
|
652
749
|
style: { transform: "rotate(-90deg)", overflow: "visible" },
|
|
653
|
-
children: [
|
|
654
|
-
|
|
750
|
+
children: isDeterminate ? isWavy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
751
|
+
shouldShowDeterminateTrack && (trackShape === "wavy" ? /* @__PURE__ */ jsx(
|
|
752
|
+
"path",
|
|
753
|
+
{
|
|
754
|
+
ref: determinateWavyTrackPathRef,
|
|
755
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
756
|
+
fill: "none",
|
|
757
|
+
stroke: bgTrackColor,
|
|
758
|
+
strokeWidth: trackHeight,
|
|
759
|
+
strokeLinecap: "round"
|
|
760
|
+
}
|
|
761
|
+
) : /* @__PURE__ */ jsx(
|
|
655
762
|
m.circle,
|
|
656
763
|
{
|
|
657
764
|
cx: center,
|
|
@@ -660,28 +767,52 @@ var CircularProgress = React3.forwardRef(
|
|
|
660
767
|
fill: "none",
|
|
661
768
|
stroke: bgTrackColor,
|
|
662
769
|
strokeWidth: trackHeight,
|
|
663
|
-
initial: {
|
|
664
|
-
|
|
770
|
+
initial: {
|
|
771
|
+
pathLength: trackLength,
|
|
772
|
+
pathOffset: trackOffset
|
|
773
|
+
},
|
|
774
|
+
animate: {
|
|
775
|
+
pathLength: trackLength,
|
|
776
|
+
pathOffset: trackOffset
|
|
777
|
+
},
|
|
665
778
|
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
|
|
666
779
|
strokeLinecap: "round"
|
|
667
780
|
}
|
|
668
|
-
)
|
|
669
|
-
|
|
670
|
-
|
|
781
|
+
)),
|
|
782
|
+
/* @__PURE__ */ jsx(
|
|
783
|
+
"path",
|
|
671
784
|
{
|
|
785
|
+
ref: determinateWavyActivePathRef,
|
|
672
786
|
d: wavyActivePath != null ? wavyActivePath : "",
|
|
673
787
|
fill: "none",
|
|
674
788
|
stroke: activeColor,
|
|
675
789
|
strokeWidth: trackHeight,
|
|
676
|
-
strokeLinecap: "round"
|
|
677
|
-
initial: { pathLength: 0 },
|
|
678
|
-
animate: { pathLength: clampedValue / 100 },
|
|
679
|
-
transition: {
|
|
680
|
-
duration: 0.4,
|
|
681
|
-
ease: [0.2, 0, 0, 1]
|
|
682
|
-
}
|
|
790
|
+
strokeLinecap: "round"
|
|
683
791
|
}
|
|
684
|
-
)
|
|
792
|
+
)
|
|
793
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
794
|
+
/* @__PURE__ */ jsx(
|
|
795
|
+
m.circle,
|
|
796
|
+
{
|
|
797
|
+
cx: center,
|
|
798
|
+
cy: center,
|
|
799
|
+
r: radius,
|
|
800
|
+
fill: "none",
|
|
801
|
+
stroke: bgTrackColor,
|
|
802
|
+
strokeWidth: trackHeight,
|
|
803
|
+
initial: {
|
|
804
|
+
pathLength: trackLength,
|
|
805
|
+
pathOffset: trackOffset
|
|
806
|
+
},
|
|
807
|
+
animate: {
|
|
808
|
+
pathLength: trackLength,
|
|
809
|
+
pathOffset: trackOffset
|
|
810
|
+
},
|
|
811
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
|
|
812
|
+
strokeLinecap: "round"
|
|
813
|
+
}
|
|
814
|
+
),
|
|
815
|
+
/* @__PURE__ */ jsx(
|
|
685
816
|
ActiveCircleElem,
|
|
686
817
|
{
|
|
687
818
|
cx: center,
|
|
@@ -698,8 +829,8 @@ var CircularProgress = React3.forwardRef(
|
|
|
698
829
|
ease: [0.2, 0, 0, 1]
|
|
699
830
|
}
|
|
700
831
|
}
|
|
701
|
-
)
|
|
702
|
-
]
|
|
832
|
+
)
|
|
833
|
+
] }) : null
|
|
703
834
|
}
|
|
704
835
|
),
|
|
705
836
|
!isDeterminate && /* @__PURE__ */ jsx(
|
|
@@ -1467,7 +1598,7 @@ var IconButtonComponent = React3.forwardRef(
|
|
|
1467
1598
|
variant = "default",
|
|
1468
1599
|
colorStyle = "standard",
|
|
1469
1600
|
size = "sm",
|
|
1470
|
-
|
|
1601
|
+
width = "default",
|
|
1471
1602
|
shape = "round",
|
|
1472
1603
|
selected,
|
|
1473
1604
|
selectedIcon,
|
|
@@ -1485,7 +1616,7 @@ var IconButtonComponent = React3.forwardRef(
|
|
|
1485
1616
|
"variant",
|
|
1486
1617
|
"colorStyle",
|
|
1487
1618
|
"size",
|
|
1488
|
-
"
|
|
1619
|
+
"width",
|
|
1489
1620
|
"shape",
|
|
1490
1621
|
"selected",
|
|
1491
1622
|
"selectedIcon",
|
|
@@ -1530,7 +1661,7 @@ var IconButtonComponent = React3.forwardRef(
|
|
|
1530
1661
|
const iconPx = iconSize != null ? iconSize : defaultIconPx;
|
|
1531
1662
|
const isCustomSize = iconSize != null && iconSize !== "inherit";
|
|
1532
1663
|
const heightClass = (_c = SIZE_HEIGHT_STYLES[size]) != null ? _c : SIZE_HEIGHT_STYLES.sm;
|
|
1533
|
-
const widthClass = (_e = ((_d = WIDTH_SIZE_STYLES[size]) != null ? _d : WIDTH_SIZE_STYLES.sm)[
|
|
1664
|
+
const widthClass = (_e = ((_d = WIDTH_SIZE_STYLES[size]) != null ? _d : WIDTH_SIZE_STYLES.sm)[width]) != null ? _e : WIDTH_SIZE_STYLES.sm.default;
|
|
1534
1665
|
const needsTouchTarget = size === "xs" || size === "sm";
|
|
1535
1666
|
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
1536
1667
|
disabled: loading
|