@bug-on/m3-expressive 1.2.0 → 1.2.2

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 (54) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/buttons.d.mts +26 -5
  3. package/dist/buttons.d.ts +26 -5
  4. package/dist/buttons.js +1074 -765
  5. package/dist/buttons.js.map +1 -1
  6. package/dist/buttons.mjs +1066 -765
  7. package/dist/buttons.mjs.map +1 -1
  8. package/dist/core.js +133 -69
  9. package/dist/core.js.map +1 -1
  10. package/dist/core.mjs +133 -69
  11. package/dist/core.mjs.map +1 -1
  12. package/dist/feedback.js +132 -69
  13. package/dist/feedback.js.map +1 -1
  14. package/dist/feedback.mjs +132 -69
  15. package/dist/feedback.mjs.map +1 -1
  16. package/dist/forms.d.mts +2 -2
  17. package/dist/forms.d.ts +2 -2
  18. package/dist/forms.js +74 -9
  19. package/dist/forms.js.map +1 -1
  20. package/dist/forms.mjs +74 -9
  21. package/dist/forms.mjs.map +1 -1
  22. package/dist/{icon-button-D-gs0gfj.d.mts → icon-button-CSsDmuQC.d.mts} +19 -0
  23. package/dist/{icon-button-D-gs0gfj.d.ts → icon-button-CSsDmuQC.d.ts} +19 -0
  24. package/dist/index.d.mts +4 -4
  25. package/dist/index.d.ts +4 -4
  26. package/dist/index.js +2204 -1464
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +2056 -1324
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/layout.d.mts +18 -1
  31. package/dist/layout.d.ts +18 -1
  32. package/dist/layout.js +80 -15
  33. package/dist/layout.js.map +1 -1
  34. package/dist/layout.mjs +80 -15
  35. package/dist/layout.mjs.map +1 -1
  36. package/dist/navigation.d.mts +134 -9
  37. package/dist/navigation.d.ts +134 -9
  38. package/dist/navigation.js +461 -101
  39. package/dist/navigation.js.map +1 -1
  40. package/dist/navigation.mjs +455 -102
  41. package/dist/navigation.mjs.map +1 -1
  42. package/dist/overlays.js +261 -197
  43. package/dist/overlays.js.map +1 -1
  44. package/dist/overlays.mjs +223 -159
  45. package/dist/overlays.mjs.map +1 -1
  46. package/dist/pickers.js +392 -301
  47. package/dist/pickers.js.map +1 -1
  48. package/dist/pickers.mjs +361 -270
  49. package/dist/pickers.mjs.map +1 -1
  50. package/dist/{split-button-trailing-uncheckable-BkPbiBo3.d.ts → split-button-trailing-uncheckable-C-qQlyZx.d.ts} +118 -25
  51. package/dist/{split-button-trailing-uncheckable-D_PLPb-u.d.mts → split-button-trailing-uncheckable-DHJqNeq_.d.mts} +118 -25
  52. package/dist/{text-field-eAIpz9z1.d.mts → text-field-T4Rg-9Bw.d.mts} +7 -0
  53. package/dist/{text-field-eAIpz9z1.d.ts → text-field-T4Rg-9Bw.d.ts} +7 -0
  54. package/package.json +3 -3
package/dist/core.mjs CHANGED
@@ -6,6 +6,7 @@ import { hexFromArgb, Hct, SchemeExpressive, SchemeNeutral, SchemeMonochrome, Sc
6
6
  import { clsx } from 'clsx';
7
7
  import { twMerge } from 'tailwind-merge';
8
8
  import { LazyMotion, domMax, m, useMotionValue, animate, useAnimationFrame, AnimatePresence, useReducedMotion } from 'motion/react';
9
+ import { Slot } from '@radix-ui/react-slot';
9
10
 
10
11
  var __defProp = Object.defineProperty;
11
12
  var __defProps = Object.defineProperties;
@@ -414,7 +415,10 @@ function useRippleState(options = {}) {
414
415
  const rect = e.currentTarget.getBoundingClientRect();
415
416
  const x = e.clientX - rect.left;
416
417
  const y = e.clientY - rect.top;
417
- const rippleSize = Math.hypot(rect.width, rect.height) * 2;
418
+ const rippleSize = Math.max(
419
+ Math.hypot(rect.width, rect.height) * 2.5,
420
+ 320
421
+ );
418
422
  setRipples((prev) => [
419
423
  ...prev,
420
424
  { id: Date.now(), x, y, size: rippleSize }
@@ -1369,12 +1373,39 @@ function TouchTarget() {
1369
1373
  }
1370
1374
  );
1371
1375
  }
1372
- var SIZE_STYLES = {
1373
- xs: "h-8 w-8",
1374
- sm: "h-10 w-10",
1375
- md: "h-14 w-14",
1376
- lg: "h-24 w-24",
1377
- xl: "h-[8.5rem] w-[8.5rem]"
1376
+ var SIZE_HEIGHT_STYLES = {
1377
+ xs: "h-8",
1378
+ sm: "h-10",
1379
+ md: "h-14",
1380
+ lg: "h-24",
1381
+ xl: "h-[8.5rem]"
1382
+ };
1383
+ var WIDTH_SIZE_STYLES = {
1384
+ xs: {
1385
+ default: "w-8",
1386
+ narrow: "w-8",
1387
+ wide: "w-12"
1388
+ },
1389
+ sm: {
1390
+ default: "w-10",
1391
+ narrow: "w-12",
1392
+ wide: "w-[3.25rem]"
1393
+ },
1394
+ md: {
1395
+ default: "w-14",
1396
+ narrow: "w-12",
1397
+ wide: "w-[4.5rem]"
1398
+ },
1399
+ lg: {
1400
+ default: "w-24",
1401
+ narrow: "w-16",
1402
+ wide: "w-32"
1403
+ },
1404
+ xl: {
1405
+ default: "w-[8.5rem]",
1406
+ narrow: "w-[6.5rem]",
1407
+ wide: "w-[11.5rem]"
1408
+ }
1378
1409
  };
1379
1410
  var SIZE_ICON = {
1380
1411
  xs: { cls: "size-5", px: 20 },
@@ -1475,11 +1506,14 @@ var IconButtonComponent = React11.forwardRef(
1475
1506
  variant = "default",
1476
1507
  colorStyle = "standard",
1477
1508
  size = "sm",
1509
+ widthVariant = "default",
1478
1510
  shape = "round",
1479
1511
  selected,
1512
+ selectedIcon,
1480
1513
  loading = false,
1481
1514
  loadingVariant = "loading-indicator",
1482
1515
  iconSize,
1516
+ asChild = false,
1483
1517
  children,
1484
1518
  onClick,
1485
1519
  onKeyDown,
@@ -1490,17 +1524,20 @@ var IconButtonComponent = React11.forwardRef(
1490
1524
  "variant",
1491
1525
  "colorStyle",
1492
1526
  "size",
1527
+ "widthVariant",
1493
1528
  "shape",
1494
1529
  "selected",
1530
+ "selectedIcon",
1495
1531
  "loading",
1496
1532
  "loadingVariant",
1497
1533
  "iconSize",
1534
+ "asChild",
1498
1535
  "children",
1499
1536
  "onClick",
1500
1537
  "onKeyDown",
1501
1538
  "aria-label"
1502
1539
  ]);
1503
- var _a2, _b2;
1540
+ var _a2, _b2, _c, _d, _e;
1504
1541
  const isToggle = variant === "toggle";
1505
1542
  const isSelected = isToggle && !!selected;
1506
1543
  const resolvedColorClass = React11.useMemo(
@@ -1531,6 +1568,8 @@ var IconButtonComponent = React11.forwardRef(
1531
1568
  const defaultIconPx = sizeIcon.px;
1532
1569
  const iconPx = iconSize != null ? iconSize : defaultIconPx;
1533
1570
  const isCustomSize = iconSize != null && iconSize !== "inherit";
1571
+ const heightClass = (_c = SIZE_HEIGHT_STYLES[size]) != null ? _c : SIZE_HEIGHT_STYLES.sm;
1572
+ const widthClass = (_e = ((_d = WIDTH_SIZE_STYLES[size]) != null ? _d : WIDTH_SIZE_STYLES.sm)[widthVariant]) != null ? _e : WIDTH_SIZE_STYLES.sm.default;
1534
1573
  const needsTouchTarget = size === "xs" || size === "sm";
1535
1574
  const { ripples, onPointerDown, removeRipple } = useRippleState({
1536
1575
  disabled: loading
@@ -1556,7 +1595,90 @@ var IconButtonComponent = React11.forwardRef(
1556
1595
  },
1557
1596
  [loading, onClick, onKeyDown]
1558
1597
  );
1559
- return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
1598
+ const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
1599
+ needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
1600
+ /* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
1601
+ /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
1602
+ m.span,
1603
+ __spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
1604
+ transition: SPRING_TRANSITION,
1605
+ className: cn(
1606
+ "flex items-center justify-center shrink-0",
1607
+ iconSize != null ? void 0 : iconClass
1608
+ ),
1609
+ style: isCustomSize ? { width: `${iconSize}px`, height: `${iconSize}px` } : void 0,
1610
+ children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
1611
+ LoadingIndicator,
1612
+ {
1613
+ size: typeof iconPx === "number" ? iconPx : defaultIconPx,
1614
+ color: "currentColor",
1615
+ "aria-label": "Loading"
1616
+ }
1617
+ ) : /* @__PURE__ */ jsx(
1618
+ ProgressIndicator,
1619
+ {
1620
+ variant: "circular",
1621
+ size: typeof iconPx === "number" ? iconPx : defaultIconPx,
1622
+ color: "currentColor",
1623
+ trackColor: "transparent",
1624
+ "aria-label": "Loading"
1625
+ }
1626
+ )
1627
+ }),
1628
+ "loading"
1629
+ ) : /* @__PURE__ */ jsx(
1630
+ m.span,
1631
+ __spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
1632
+ transition: SPRING_TRANSITION,
1633
+ "aria-hidden": "true",
1634
+ className: cn(
1635
+ "flex items-center justify-center shrink-0 [&_svg]:w-full [&_svg]:h-full [&_.md-icon]:text-[length:inherit]",
1636
+ iconSize != null ? void 0 : iconClass
1637
+ ),
1638
+ style: {
1639
+ fontSize: typeof iconPx === "number" ? `${iconPx}px` : iconPx,
1640
+ width: isCustomSize ? `${iconSize}px` : void 0,
1641
+ height: isCustomSize ? `${iconSize}px` : void 0
1642
+ },
1643
+ children: isSelected && selectedIcon ? selectedIcon : asChild ? React11.Children.only(children).props.children : children
1644
+ }),
1645
+ isSelected && selectedIcon ? "selected-content" : "content"
1646
+ ) })
1647
+ ] });
1648
+ const containerClassName = cn(
1649
+ baseIconButtonClasses,
1650
+ resolvedColorClass,
1651
+ outlineWidthClass,
1652
+ disabledBgClass,
1653
+ "overflow-hidden",
1654
+ heightClass,
1655
+ widthClass,
1656
+ loading && "pointer-events-none opacity-75 cursor-not-allowed",
1657
+ className
1658
+ );
1659
+ if (asChild) {
1660
+ const child = React11.Children.only(children);
1661
+ return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
1662
+ Slot,
1663
+ __spreadProps(__spreadValues({
1664
+ ref,
1665
+ "aria-pressed": isToggle ? isSelected : void 0,
1666
+ "aria-label": ariaLabel,
1667
+ "aria-busy": loading || void 0,
1668
+ "aria-disabled": loading || restProps.disabled,
1669
+ onClick: handleClick,
1670
+ onPointerDown,
1671
+ onKeyDown: handleKeyDown,
1672
+ style: __spreadProps(__spreadValues({}, style), {
1673
+ borderRadius: `${animateRadius}px`
1674
+ }),
1675
+ className: containerClassName
1676
+ }, restProps), {
1677
+ children: React11.cloneElement(child, { children: innerContent })
1678
+ })
1679
+ ) });
1680
+ }
1681
+ return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
1560
1682
  m.button,
1561
1683
  __spreadProps(__spreadValues({
1562
1684
  ref,
@@ -1572,67 +1694,9 @@ var IconButtonComponent = React11.forwardRef(
1572
1694
  animate: { borderRadius: animateRadius },
1573
1695
  whileTap: { borderRadius: pressedRadius },
1574
1696
  transition: { borderRadius: SPRING_TRANSITION_FAST },
1575
- className: cn(
1576
- baseIconButtonClasses,
1577
- resolvedColorClass,
1578
- outlineWidthClass,
1579
- disabledBgClass,
1580
- "overflow-hidden",
1581
- SIZE_STYLES[size],
1582
- loading && "pointer-events-none opacity-75 cursor-not-allowed",
1583
- className
1584
- )
1697
+ className: containerClassName
1585
1698
  }, restProps), {
1586
- children: [
1587
- needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
1588
- /* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
1589
- /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
1590
- m.span,
1591
- __spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
1592
- transition: SPRING_TRANSITION,
1593
- className: cn(
1594
- "flex items-center justify-center shrink-0",
1595
- iconSize != null ? void 0 : iconClass
1596
- ),
1597
- style: isCustomSize ? { width: `${iconSize}px`, height: `${iconSize}px` } : void 0,
1598
- children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
1599
- LoadingIndicator,
1600
- {
1601
- size: typeof iconPx === "number" ? iconPx : defaultIconPx,
1602
- color: "currentColor",
1603
- "aria-label": "Loading"
1604
- }
1605
- ) : /* @__PURE__ */ jsx(
1606
- ProgressIndicator,
1607
- {
1608
- variant: "circular",
1609
- size: typeof iconPx === "number" ? iconPx : defaultIconPx,
1610
- color: "currentColor",
1611
- trackColor: "transparent",
1612
- "aria-label": "Loading"
1613
- }
1614
- )
1615
- }),
1616
- "loading"
1617
- ) : /* @__PURE__ */ jsx(
1618
- m.span,
1619
- __spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
1620
- transition: SPRING_TRANSITION,
1621
- "aria-hidden": "true",
1622
- className: cn(
1623
- "flex items-center justify-center shrink-0 [&_svg]:w-full [&_svg]:h-full [&_.md-icon]:text-[length:inherit]!",
1624
- iconSize != null ? void 0 : iconClass
1625
- ),
1626
- style: {
1627
- fontSize: typeof iconPx === "number" ? `${iconPx}px` : iconPx,
1628
- width: isCustomSize ? `${iconSize}px` : void 0,
1629
- height: isCustomSize ? `${iconSize}px` : void 0
1630
- },
1631
- children
1632
- }),
1633
- "content"
1634
- ) })
1635
- ]
1699
+ children: innerContent
1636
1700
  })
1637
1701
  ) });
1638
1702
  }