@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/layout.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { Slot } from '@radix-ui/react-slot';
2
3
  import { cva } from 'class-variance-authority';
3
4
  import { m, LazyMotion, domMax, useMotionValue, animate, useAnimationFrame, AnimatePresence, useReducedMotion } from 'motion/react';
4
5
  import * as React18 from 'react';
@@ -6,7 +7,6 @@ import { createContext, useState, useCallback, useMemo, useEffect, useContext, c
6
7
  import { clsx } from 'clsx';
7
8
  import { twMerge } from 'tailwind-merge';
8
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
- import { Slot } from '@radix-ui/react-slot';
10
10
  import { cornerRadius } from '@bug-on/m3-tokens';
11
11
  import * as RadixScrollArea from '@radix-ui/react-scroll-area';
12
12
  import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
@@ -106,7 +106,10 @@ function useRippleState(options = {}) {
106
106
  const rect = e.currentTarget.getBoundingClientRect();
107
107
  const x = e.clientX - rect.left;
108
108
  const y = e.clientY - rect.top;
109
- const rippleSize = Math.hypot(rect.width, rect.height) * 2;
109
+ const rippleSize = Math.max(
110
+ Math.hypot(rect.width, rect.height) * 2.5,
111
+ 320
112
+ );
110
113
  setRipples((prev) => [
111
114
  ...prev,
112
115
  { id: Date.now(), x, y, size: rippleSize }
@@ -188,6 +191,7 @@ var CardImpl = React18.forwardRef(
188
191
  target,
189
192
  rel: relProp,
190
193
  onClick,
194
+ asChild = false,
191
195
  children
192
196
  } = _b, props = __objRest(_b, [
193
197
  "className",
@@ -198,10 +202,11 @@ var CardImpl = React18.forwardRef(
198
202
  "target",
199
203
  "rel",
200
204
  "onClick",
205
+ "asChild",
201
206
  "children"
202
207
  ]);
203
208
  const safeVariant = variant;
204
- const isInteractive = !!onClick || !!href || interactive;
209
+ const isInteractive = !!onClick || !!href || interactive || asChild;
205
210
  const elevationProps = useCardElevation(safeVariant, disabled);
206
211
  const { ripples, onPointerDown, removeRipple } = useRippleState();
207
212
  const baseClass = cn(
@@ -222,6 +227,26 @@ var CardImpl = React18.forwardRef(
222
227
  // Outlined interactive card: change border color to m3-outline on focus/press/hover
223
228
  variant === "outlined" && "hover:border-m3-outline focus-visible:border-m3-outline active:border-m3-outline"
224
229
  );
230
+ if (asChild) {
231
+ const child = React18.Children.only(children);
232
+ const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
233
+ /* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
234
+ child.props.children
235
+ ] });
236
+ return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
237
+ Slot,
238
+ __spreadProps(__spreadValues({
239
+ ref,
240
+ className: cn(baseClass, interactiveClass),
241
+ "aria-disabled": disabled ? true : void 0,
242
+ tabIndex: disabled ? -1 : 0,
243
+ onPointerDown,
244
+ onClick
245
+ }, props), {
246
+ children: React18.cloneElement(child, { children: innerContent })
247
+ })
248
+ ) });
249
+ }
225
250
  if (!isInteractive) {
226
251
  return /* @__PURE__ */ jsx(
227
252
  "div",
@@ -1466,6 +1491,7 @@ var ButtonComponent = React18.forwardRef(
1466
1491
  shape = "round",
1467
1492
  selected,
1468
1493
  icon,
1494
+ selectedIcon,
1469
1495
  iconPosition = "leading",
1470
1496
  loading = false,
1471
1497
  loadingVariant = "loading-indicator",
@@ -1487,6 +1513,7 @@ var ButtonComponent = React18.forwardRef(
1487
1513
  "shape",
1488
1514
  "selected",
1489
1515
  "icon",
1516
+ "selectedIcon",
1490
1517
  "iconPosition",
1491
1518
  "loading",
1492
1519
  "loadingVariant",
@@ -1586,10 +1613,11 @@ var ButtonComponent = React18.forwardRef(
1586
1613
  layout: BUTTON_SHAPE_MORPH_SPRING,
1587
1614
  default: SPRING_TRANSITION
1588
1615
  };
1616
+ const activeIcon = isSelected && selectedIcon ? selectedIcon : icon;
1589
1617
  const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
1590
1618
  needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
1591
1619
  /* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
1592
- /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "popLayout", children: (loading || icon && iconPosition === "leading") && /* @__PURE__ */ jsx(
1620
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "wait", children: (loading || activeIcon && iconPosition === "leading") && /* @__PURE__ */ jsx(
1593
1621
  AnimatedIconSlot,
1594
1622
  {
1595
1623
  iconSize: sizeTokens.iconSize,
@@ -1611,8 +1639,9 @@ var ButtonComponent = React18.forwardRef(
1611
1639
  trackColor: "transparent",
1612
1640
  "aria-label": "Loading"
1613
1641
  }
1614
- ) : icon
1615
- }
1642
+ ) : activeIcon
1643
+ },
1644
+ isSelected && selectedIcon ? "selected-icon" : "icon"
1616
1645
  ) }),
1617
1646
  labelText && /* @__PURE__ */ jsx(
1618
1647
  m.span,
@@ -1623,14 +1652,15 @@ var ButtonComponent = React18.forwardRef(
1623
1652
  children: labelText
1624
1653
  }
1625
1654
  ),
1626
- /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "popLayout", children: icon && iconPosition === "trailing" && /* @__PURE__ */ jsx(
1655
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "wait", children: !loading && activeIcon && iconPosition === "trailing" && /* @__PURE__ */ jsx(
1627
1656
  AnimatedIconSlot,
1628
1657
  {
1629
1658
  iconSize: sizeTokens.iconSize,
1630
1659
  ariaHidden: true,
1631
1660
  transition: sharedTransition,
1632
- children: icon
1633
- }
1661
+ children: activeIcon
1662
+ },
1663
+ isSelected && selectedIcon ? "selected-icon" : "icon"
1634
1664
  ) })
1635
1665
  ] });
1636
1666
  const handleAsChildPointerDown = React18.useCallback(
@@ -4225,6 +4255,7 @@ var ListItem = React18.memo(ListItemImpl);
4225
4255
  var typographyVariants = cva("m-0 p-0 text-m3-on-surface", {
4226
4256
  variants: {
4227
4257
  variant: {
4258
+ // Short hyphenated
4228
4259
  "display-lg": "text-[57px] leading-[64px] font-normal tracking-[-0.25px]",
4229
4260
  "display-md": "text-[45px] leading-[52px] font-normal tracking-[0px]",
4230
4261
  "display-sm": "text-[36px] leading-[44px] font-normal tracking-[0px]",
@@ -4239,7 +4270,39 @@ var typographyVariants = cva("m-0 p-0 text-m3-on-surface", {
4239
4270
  "label-sm": "text-[11px] leading-[16px] font-medium tracking-[0.5px]",
4240
4271
  "body-lg": "text-[16px] leading-[24px] font-normal tracking-[0.5px]",
4241
4272
  "body-md": "text-[14px] leading-[20px] font-normal tracking-[0.25px]",
4242
- "body-sm": "text-[12px] leading-[16px] font-normal tracking-[0.4px]"
4273
+ "body-sm": "text-[12px] leading-[16px] font-normal tracking-[0.4px]",
4274
+ // Full hyphenated aliases
4275
+ "display-large": "text-[57px] leading-[64px] font-normal tracking-[-0.25px]",
4276
+ "display-medium": "text-[45px] leading-[52px] font-normal tracking-[0px]",
4277
+ "display-small": "text-[36px] leading-[44px] font-normal tracking-[0px]",
4278
+ "headline-large": "text-[32px] leading-[40px] font-normal tracking-[0px]",
4279
+ "headline-medium": "text-[28px] leading-[36px] font-normal tracking-[0px]",
4280
+ "headline-small": "text-[24px] leading-[32px] font-normal tracking-[0px]",
4281
+ "title-large": "text-[22px] leading-[28px] font-normal tracking-[0px]",
4282
+ "title-medium": "text-[16px] leading-[24px] font-medium tracking-[0.15px]",
4283
+ "title-small": "text-[14px] leading-[20px] font-medium tracking-[0.1px]",
4284
+ "label-large": "text-[14px] leading-[20px] font-medium tracking-[0.1px]",
4285
+ "label-medium": "text-[12px] leading-[16px] font-medium tracking-[0.5px]",
4286
+ "label-small": "text-[11px] leading-[16px] font-medium tracking-[0.5px]",
4287
+ "body-large": "text-[16px] leading-[24px] font-normal tracking-[0.5px]",
4288
+ "body-medium": "text-[14px] leading-[20px] font-normal tracking-[0.25px]",
4289
+ "body-small": "text-[12px] leading-[16px] font-normal tracking-[0.4px]",
4290
+ // CamelCase aliases
4291
+ displayLarge: "text-[57px] leading-[64px] font-normal tracking-[-0.25px]",
4292
+ displayMedium: "text-[45px] leading-[52px] font-normal tracking-[0px]",
4293
+ displaySmall: "text-[36px] leading-[44px] font-normal tracking-[0px]",
4294
+ headlineLarge: "text-[32px] leading-[40px] font-normal tracking-[0px]",
4295
+ headlineMedium: "text-[28px] leading-[36px] font-normal tracking-[0px]",
4296
+ headlineSmall: "text-[24px] leading-[32px] font-normal tracking-[0px]",
4297
+ titleLarge: "text-[22px] leading-[28px] font-normal tracking-[0px]",
4298
+ titleMedium: "text-[16px] leading-[24px] font-medium tracking-[0.15px]",
4299
+ titleSmall: "text-[14px] leading-[20px] font-medium tracking-[0.1px]",
4300
+ labelLarge: "text-[14px] leading-[20px] font-medium tracking-[0.1px]",
4301
+ labelMedium: "text-[12px] leading-[16px] font-medium tracking-[0.5px]",
4302
+ labelSmall: "text-[11px] leading-[16px] font-medium tracking-[0.5px]",
4303
+ bodyLarge: "text-[16px] leading-[24px] font-normal tracking-[0.5px]",
4304
+ bodyMedium: "text-[14px] leading-[20px] font-normal tracking-[0.25px]",
4305
+ bodySmall: "text-[12px] leading-[16px] font-normal tracking-[0.4px]"
4243
4306
  }
4244
4307
  },
4245
4308
  defaultVariants: {
@@ -4248,19 +4311,21 @@ var typographyVariants = cva("m-0 p-0 text-m3-on-surface", {
4248
4311
  });
4249
4312
  var Text = React18.forwardRef(
4250
4313
  (_a, ref) => {
4251
- var _b = _a, { className, variant, as: Component } = _b, props = __objRest(_b, ["className", "variant", "as"]);
4314
+ var _b = _a, { className, variant, as: Component, color, weight, style } = _b, props = __objRest(_b, ["className", "variant", "as", "color", "weight", "style"]);
4252
4315
  const defaultComponent = React18.useMemo(() => {
4253
- if ((variant == null ? void 0 : variant.startsWith("display")) || (variant == null ? void 0 : variant.startsWith("headline")))
4254
- return "h1";
4255
- if (variant == null ? void 0 : variant.startsWith("title")) return "h2";
4316
+ const v = variant ? String(variant).toLowerCase() : "";
4317
+ if (v.startsWith("display") || v.startsWith("headline")) return "h1";
4318
+ if (v.startsWith("title")) return "h2";
4256
4319
  return "p";
4257
4320
  }, [variant]);
4258
4321
  const Tag = Component || defaultComponent;
4322
+ const customStyle = __spreadValues(__spreadValues(__spreadValues({}, style), color ? { color } : {}), weight ? { fontWeight: weight } : {});
4259
4323
  return /* @__PURE__ */ jsx(
4260
4324
  Tag,
4261
4325
  __spreadValues({
4262
4326
  ref,
4263
- className: cn(typographyVariants({ variant, className }))
4327
+ className: cn(typographyVariants({ variant, className })),
4328
+ style: customStyle
4264
4329
  }, props)
4265
4330
  );
4266
4331
  }