@bug-on/m3-expressive 1.3.0 → 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.
Files changed (50) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/buttons.d.mts +1 -1
  3. package/dist/buttons.d.ts +1 -1
  4. package/dist/buttons.js +185 -40
  5. package/dist/buttons.js.map +1 -1
  6. package/dist/buttons.mjs +186 -41
  7. package/dist/buttons.mjs.map +1 -1
  8. package/dist/core.js +156 -25
  9. package/dist/core.js.map +1 -1
  10. package/dist/core.mjs +157 -26
  11. package/dist/core.mjs.map +1 -1
  12. package/dist/feedback.d.mts +20 -0
  13. package/dist/feedback.d.ts +20 -0
  14. package/dist/feedback.js +156 -25
  15. package/dist/feedback.js.map +1 -1
  16. package/dist/feedback.mjs +157 -26
  17. package/dist/feedback.mjs.map +1 -1
  18. package/dist/forms.d.mts +3 -2
  19. package/dist/forms.d.ts +3 -2
  20. package/dist/forms.js +88 -100
  21. package/dist/forms.js.map +1 -1
  22. package/dist/forms.mjs +88 -100
  23. package/dist/forms.mjs.map +1 -1
  24. package/dist/index.d.mts +3 -3
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +279 -146
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +280 -147
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/layout.js +158 -27
  31. package/dist/layout.js.map +1 -1
  32. package/dist/layout.mjs +159 -28
  33. package/dist/layout.mjs.map +1 -1
  34. package/dist/navigation.js +156 -25
  35. package/dist/navigation.js.map +1 -1
  36. package/dist/navigation.mjs +157 -26
  37. package/dist/navigation.mjs.map +1 -1
  38. package/dist/overlays.js +156 -25
  39. package/dist/overlays.js.map +1 -1
  40. package/dist/overlays.mjs +157 -26
  41. package/dist/overlays.mjs.map +1 -1
  42. package/dist/pickers.js +156 -25
  43. package/dist/pickers.js.map +1 -1
  44. package/dist/pickers.mjs +157 -26
  45. package/dist/pickers.mjs.map +1 -1
  46. package/dist/{split-button-trailing-uncheckable-26qlZvKT.d.mts → split-button-trailing-uncheckable-CIVEYgjY.d.mts} +2 -0
  47. package/dist/{split-button-trailing-uncheckable-CXUVrH64.d.ts → split-button-trailing-uncheckable-DTQJjzsB.d.ts} +2 -0
  48. package/dist/{text-field-DWC7qOvp.d.mts → text-field-CiOmDM_8.d.ts} +52 -51
  49. package/dist/{text-field-DWC7qOvp.d.ts → text-field-Ear3hCSq.d.mts} +52 -51
  50. package/package.json +3 -3
package/dist/overlays.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import * as RadixDialog from '@radix-ui/react-dialog';
3
- import { m, useAnimationFrame, LazyMotion, domMax, useMotionValue, animate, AnimatePresence, useReducedMotion, useTransform } from 'motion/react';
3
+ import { m, useMotionValue, animate, useAnimationFrame, LazyMotion, domMax, AnimatePresence, useReducedMotion, useTransform } from 'motion/react';
4
4
  import * as React2 from 'react';
5
5
  import { useState, useRef, useCallback, useMemo, useEffect, useLayoutEffect } from 'react';
6
6
  import { clsx } from 'clsx';
@@ -231,7 +231,7 @@ LoadingIndicator.displayName = "LoadingIndicator";
231
231
  function easeInOutCubic(x) {
232
232
  return x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;
233
233
  }
234
- function generateWavyCircularPath(center, radius, amplitude, wavelength) {
234
+ function generateWavyCircularPath(center, radius, amplitude, wavelength, phase = 0) {
235
235
  const circumference = 2 * Math.PI * radius;
236
236
  const numWaves = Math.max(
237
237
  3,
@@ -239,8 +239,8 @@ function generateWavyCircularPath(center, radius, amplitude, wavelength) {
239
239
  );
240
240
  const steps = numWaves * 4;
241
241
  const dt = 2 * Math.PI / steps;
242
- const rAt = (t) => radius + amplitude * Math.sin(numWaves * t);
243
- const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t);
242
+ const rAt = (t) => radius + amplitude * Math.sin(numWaves * t + phase);
243
+ const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t + phase);
244
244
  const xAt = (t) => center + rAt(t) * Math.cos(t);
245
245
  const yAt = (t) => center + rAt(t) * Math.sin(t);
246
246
  const dxAt = (t) => drAt(t) * Math.cos(t) - rAt(t) * Math.sin(t);
@@ -305,15 +305,18 @@ var CircularProgress = React2.forwardRef(
305
305
  size = 48,
306
306
  trackHeight = 4,
307
307
  shape = "flat",
308
+ trackShape = "flat",
308
309
  amplitude,
309
310
  wavelength,
310
311
  gapSize = 4,
312
+ waveSpeed = 1,
311
313
  crawlerSpeed = 1,
312
314
  color,
313
315
  trackColor,
314
316
  showTrack = "auto",
315
317
  minProgress = DEFAULT_MIN_PROGRESS,
316
318
  maxProgress = DEFAULT_MAX_PROGRESS,
319
+ determinateAnimation = "md3",
317
320
  amplitudeRange,
318
321
  className,
319
322
  "aria-label": ariaLabel
@@ -322,15 +325,18 @@ var CircularProgress = React2.forwardRef(
322
325
  "size",
323
326
  "trackHeight",
324
327
  "shape",
328
+ "trackShape",
325
329
  "amplitude",
326
330
  "wavelength",
327
331
  "gapSize",
332
+ "waveSpeed",
328
333
  "crawlerSpeed",
329
334
  "color",
330
335
  "trackColor",
331
336
  "showTrack",
332
337
  "minProgress",
333
338
  "maxProgress",
339
+ "determinateAnimation",
334
340
  "amplitudeRange",
335
341
  "className",
336
342
  "aria-label"
@@ -343,6 +349,7 @@ var CircularProgress = React2.forwardRef(
343
349
  const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
344
350
  const isWavy = shape === "wavy";
345
351
  const shouldShowIndeterminateTrack = showTrack === "auto" ? isWavy : showTrack;
352
+ const shouldShowDeterminateTrack = showTrack === "auto" ? true : showTrack;
346
353
  const BASELINE_SIZE = 48;
347
354
  const scaleFactor = size / BASELINE_SIZE;
348
355
  const effectiveAmplitude = React2.useMemo(
@@ -375,19 +382,50 @@ var CircularProgress = React2.forwardRef(
375
382
  const trackOffset = isDeterminate ? activeAngularFraction + gapForTrack : 0;
376
383
  const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
377
384
  const ActiveCircleElem = m.circle;
378
- const ActivePathElem = m.path;
379
385
  const indeterminateSvgRef = React2.useRef(null);
380
386
  const indeterminateTrackRef = React2.useRef(null);
381
387
  const indeterminateActiveRef = React2.useRef(null);
382
388
  const indeterminateWavyTrackPathRef = React2.useRef(null);
383
389
  const indeterminateWavyActivePathRef = React2.useRef(null);
390
+ const determinateWavyActivePathRef = React2.useRef(null);
391
+ const determinateWavyTrackPathRef = React2.useRef(null);
384
392
  const cachedPathLengthRef = React2.useRef(0);
393
+ const fractionMV = useMotionValue(isDeterminate ? clampedValue / 100 : 0);
394
+ const amplitudeMV = useMotionValue(isWavy ? effectiveAmplitude : 0);
395
+ React2.useEffect(() => {
396
+ if (isDeterminate) {
397
+ animate(fractionMV, clampedValue / 100, {
398
+ duration: 0.4,
399
+ ease: [0.2, 0, 0, 1]
400
+ });
401
+ }
402
+ }, [clampedValue, isDeterminate, fractionMV]);
403
+ React2.useEffect(() => {
404
+ if (!isDeterminate || !isWavy) return;
405
+ const fraction = clampedValue / 100;
406
+ let targetAmp = effectiveAmplitude;
407
+ if (determinateAnimation === "md3") {
408
+ targetAmp = fraction <= 0.1 || fraction >= 0.95 ? 0 : effectiveAmplitude;
409
+ }
410
+ animate(amplitudeMV, targetAmp, {
411
+ type: "spring",
412
+ bounce: 0,
413
+ duration: 0.5
414
+ });
415
+ }, [
416
+ clampedValue,
417
+ isDeterminate,
418
+ isWavy,
419
+ effectiveAmplitude,
420
+ amplitudeMV,
421
+ determinateAnimation
422
+ ]);
385
423
  React2.useLayoutEffect(() => {
386
424
  if (!isWavy || !wavyActivePath) {
387
425
  cachedPathLengthRef.current = circumference;
388
426
  return;
389
427
  }
390
- const el = indeterminateActiveRef.current;
428
+ const el = indeterminateActiveRef.current || determinateWavyActivePathRef.current;
391
429
  if (el && "getTotalLength" in el) {
392
430
  try {
393
431
  const len = el.getTotalLength();
@@ -401,7 +439,65 @@ var CircularProgress = React2.forwardRef(
401
439
  cachedPathLengthRef.current = circumference;
402
440
  }, [isWavy, circumference, wavyActivePath]);
403
441
  useAnimationFrame((time) => {
404
- if (isDeterminate) return;
442
+ const safeWaveSpeed = Math.max(0.1, waveSpeed);
443
+ const wavePhase = time / 1e3 * safeWaveSpeed * 2 * Math.PI;
444
+ if (isDeterminate) {
445
+ if (isWavy) {
446
+ const currentAmp = amplitudeMV.get();
447
+ const dynamicPath = generateWavyCircularPath(
448
+ center,
449
+ radius,
450
+ currentAmp,
451
+ effectiveWavelength,
452
+ wavePhase
453
+ );
454
+ if (determinateWavyActivePathRef.current) {
455
+ determinateWavyActivePathRef.current.setAttribute("d", dynamicPath);
456
+ }
457
+ if (trackShape === "wavy" && determinateWavyTrackPathRef.current) {
458
+ determinateWavyTrackPathRef.current.setAttribute("d", dynamicPath);
459
+ }
460
+ const pathEl = determinateWavyActivePathRef.current;
461
+ let totalLen = cachedPathLengthRef.current || circumference;
462
+ if (pathEl) {
463
+ try {
464
+ const len = pathEl.getTotalLength();
465
+ if (len > 0) totalLen = len;
466
+ } catch (e) {
467
+ }
468
+ }
469
+ const activeFrac = Math.max(0, Math.min(1, fractionMV.get()));
470
+ const activeLen = totalLen * activeFrac;
471
+ if (determinateWavyActivePathRef.current) {
472
+ determinateWavyActivePathRef.current.setAttribute(
473
+ "stroke-dasharray",
474
+ `${activeLen} ${totalLen}`
475
+ );
476
+ determinateWavyActivePathRef.current.setAttribute(
477
+ "stroke-dashoffset",
478
+ "0"
479
+ );
480
+ }
481
+ if (shouldShowDeterminateTrack && trackShape === "wavy" && determinateWavyTrackPathRef.current) {
482
+ const gapFrac = (gapSize + trackHeight) / totalLen;
483
+ const trackStartFrac = activeFrac + gapFrac;
484
+ const trackLen = Math.max(
485
+ 1e-3,
486
+ totalLen * (1 - activeFrac - 2 * gapFrac)
487
+ );
488
+ const trackOff = -totalLen * trackStartFrac;
489
+ determinateWavyTrackPathRef.current.setAttribute(
490
+ "stroke-dasharray",
491
+ `${trackLen} ${totalLen}`
492
+ );
493
+ determinateWavyTrackPathRef.current.setAttribute(
494
+ "stroke-dashoffset",
495
+ `${trackOff}`
496
+ );
497
+ }
498
+ }
499
+ return;
500
+ }
405
501
  const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
406
502
  const scaledTime = time * safeCrawlerSpeed;
407
503
  const globalCycle = scaledTime % GLOBAL_ROTATION_DURATION;
@@ -436,7 +532,8 @@ var CircularProgress = React2.forwardRef(
436
532
  center,
437
533
  radius,
438
534
  currentAmplitude,
439
- effectiveWavelength
535
+ effectiveWavelength,
536
+ wavePhase
440
537
  );
441
538
  if (indeterminateWavyActivePathRef.current) {
442
539
  indeterminateWavyActivePathRef.current.setAttribute("d", dynamicPath);
@@ -531,7 +628,7 @@ var CircularProgress = React2.forwardRef(
531
628
  style: { width: size, height: size }
532
629
  }, restProps), {
533
630
  children: /* @__PURE__ */ jsxs(LazyMotion, { features: domMax, strict: true, children: [
534
- /* @__PURE__ */ jsxs(
631
+ /* @__PURE__ */ jsx(
535
632
  "svg",
536
633
  {
537
634
  width: size,
@@ -539,8 +636,18 @@ var CircularProgress = React2.forwardRef(
539
636
  viewBox: `0 0 ${size} ${size}`,
540
637
  "aria-hidden": "true",
541
638
  style: { transform: "rotate(-90deg)", overflow: "visible" },
542
- children: [
543
- isDeterminate ? /* @__PURE__ */ jsx(
639
+ children: isDeterminate ? isWavy ? /* @__PURE__ */ jsxs(Fragment, { children: [
640
+ shouldShowDeterminateTrack && (trackShape === "wavy" ? /* @__PURE__ */ jsx(
641
+ "path",
642
+ {
643
+ ref: determinateWavyTrackPathRef,
644
+ d: wavyActivePath != null ? wavyActivePath : "",
645
+ fill: "none",
646
+ stroke: bgTrackColor,
647
+ strokeWidth: trackHeight,
648
+ strokeLinecap: "round"
649
+ }
650
+ ) : /* @__PURE__ */ jsx(
544
651
  m.circle,
545
652
  {
546
653
  cx: center,
@@ -549,28 +656,52 @@ var CircularProgress = React2.forwardRef(
549
656
  fill: "none",
550
657
  stroke: bgTrackColor,
551
658
  strokeWidth: trackHeight,
552
- initial: { pathLength: trackLength, pathOffset: trackOffset },
553
- animate: { pathLength: trackLength, pathOffset: trackOffset },
659
+ initial: {
660
+ pathLength: trackLength,
661
+ pathOffset: trackOffset
662
+ },
663
+ animate: {
664
+ pathLength: trackLength,
665
+ pathOffset: trackOffset
666
+ },
554
667
  transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
555
668
  strokeLinecap: "round"
556
669
  }
557
- ) : null,
558
- isDeterminate && (isWavy ? /* @__PURE__ */ jsx(
559
- ActivePathElem,
670
+ )),
671
+ /* @__PURE__ */ jsx(
672
+ "path",
560
673
  {
674
+ ref: determinateWavyActivePathRef,
561
675
  d: wavyActivePath != null ? wavyActivePath : "",
562
676
  fill: "none",
563
677
  stroke: activeColor,
564
678
  strokeWidth: trackHeight,
565
- strokeLinecap: "round",
566
- initial: { pathLength: 0 },
567
- animate: { pathLength: clampedValue / 100 },
568
- transition: {
569
- duration: 0.4,
570
- ease: [0.2, 0, 0, 1]
571
- }
679
+ strokeLinecap: "round"
572
680
  }
573
- ) : /* @__PURE__ */ jsx(
681
+ )
682
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
683
+ /* @__PURE__ */ jsx(
684
+ m.circle,
685
+ {
686
+ cx: center,
687
+ cy: center,
688
+ r: radius,
689
+ fill: "none",
690
+ stroke: bgTrackColor,
691
+ strokeWidth: trackHeight,
692
+ initial: {
693
+ pathLength: trackLength,
694
+ pathOffset: trackOffset
695
+ },
696
+ animate: {
697
+ pathLength: trackLength,
698
+ pathOffset: trackOffset
699
+ },
700
+ transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
701
+ strokeLinecap: "round"
702
+ }
703
+ ),
704
+ /* @__PURE__ */ jsx(
574
705
  ActiveCircleElem,
575
706
  {
576
707
  cx: center,
@@ -587,8 +718,8 @@ var CircularProgress = React2.forwardRef(
587
718
  ease: [0.2, 0, 0, 1]
588
719
  }
589
720
  }
590
- ))
591
- ]
721
+ )
722
+ ] }) : null
592
723
  }
593
724
  ),
594
725
  !isDeterminate && /* @__PURE__ */ jsx(