@bug-on/m3-expressive 1.2.2 → 1.2.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @bug-on/m3-expressive
2
2
 
3
+ ## 1.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d03619: Added asChild for navigation item
8
+
3
9
  ## 1.2.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -15841,8 +15841,11 @@ var NavigationBarItemComponent = React61__namespace.forwardRef(
15841
15841
  disabled = false,
15842
15842
  badge,
15843
15843
  className,
15844
- "aria-label": ariaLabelProp
15844
+ "aria-label": ariaLabelProp,
15845
+ asChild = false,
15846
+ children
15845
15847
  }, ref) => {
15848
+ var _a;
15846
15849
  const {
15847
15850
  variant,
15848
15851
  itemLayout,
@@ -15870,6 +15873,101 @@ var NavigationBarItemComponent = React61__namespace.forwardRef(
15870
15873
  [disabled, selected, onClick]
15871
15874
  );
15872
15875
  const filledIcon = cloneIconWithFill(icon, selected);
15876
+ const itemClassName = cn(
15877
+ "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none h-full items-center justify-center min-w-0",
15878
+ variant === "xr" ? isResponsiveHorizontal ? "flex-1 min-[600px]:flex-initial min-[600px]:w-auto" : isForcedHorizontal ? "flex-initial w-auto" : "flex-1" : isForcedHorizontal ? "flex-initial w-auto" : "flex-1",
15879
+ disabled && "pointer-events-none opacity-[0.38]",
15880
+ contextItemClassName,
15881
+ className
15882
+ );
15883
+ if (asChild && children) {
15884
+ const child = React61__namespace.Children.only(children);
15885
+ const innerContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
15886
+ /* @__PURE__ */ jsxRuntime.jsxs(
15887
+ "div",
15888
+ {
15889
+ className: cn(
15890
+ "relative flex items-center justify-center flex-col gap-y-1 w-full px-1 py-1.5",
15891
+ isResponsiveHorizontal && "min-[600px]:flex-row min-[600px]:gap-y-0 min-[600px]:gap-x-1.5 min-[600px]:h-10 min-[600px]:px-4 min-[600px]:py-0 min-[600px]:rounded-full min-[600px]:w-auto",
15892
+ isForcedHorizontal && "flex-row gap-y-0 gap-x-1.5 h-10 px-4 py-0 rounded-full w-auto"
15893
+ ),
15894
+ children: [
15895
+ /* @__PURE__ */ jsxRuntime.jsxs(
15896
+ "div",
15897
+ {
15898
+ className: cn(
15899
+ "absolute inset-0 z-0 hidden",
15900
+ isResponsiveHorizontal && "min-[600px]:block",
15901
+ isForcedHorizontal && "block!"
15902
+ ),
15903
+ children: [
15904
+ /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsxRuntime.jsx(ActivePill, {}) }),
15905
+ /* @__PURE__ */ jsxRuntime.jsx(HoverStateLayer, {}),
15906
+ /* @__PURE__ */ jsxRuntime.jsx(RippleLayer, { ripples, onRippleDone: removeRipple })
15907
+ ]
15908
+ }
15909
+ ),
15910
+ /* @__PURE__ */ jsxRuntime.jsxs(
15911
+ "div",
15912
+ {
15913
+ className: cn(
15914
+ "relative flex items-center justify-center shrink-0 z-10",
15915
+ "h-8 w-16 mx-auto rounded-full",
15916
+ isResponsiveHorizontal && "min-[600px]:size-6 min-[600px]:w-auto min-[600px]:h-auto",
15917
+ isForcedHorizontal && "size-6 w-auto h-auto"
15918
+ ),
15919
+ children: [
15920
+ /* @__PURE__ */ jsxRuntime.jsxs(
15921
+ "div",
15922
+ {
15923
+ className: cn(
15924
+ "absolute inset-0 z-0",
15925
+ isResponsiveHorizontal && "min-[600px]:hidden",
15926
+ isForcedHorizontal && "hidden"
15927
+ ),
15928
+ children: [
15929
+ /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsxRuntime.jsx(ActivePill, {}) }),
15930
+ /* @__PURE__ */ jsxRuntime.jsx(HoverStateLayer, {}),
15931
+ /* @__PURE__ */ jsxRuntime.jsx(RippleLayer, { ripples, onRippleDone: removeRipple })
15932
+ ]
15933
+ }
15934
+ ),
15935
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative z-10 flex size-6 items-center justify-center text-current", children: /* @__PURE__ */ jsxRuntime.jsx(IconContainer, { selected, badge, children: filledIcon }) })
15936
+ ]
15937
+ }
15938
+ ),
15939
+ /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ jsxRuntime.jsx(
15940
+ "span",
15941
+ {
15942
+ className: cn(
15943
+ "z-10 transition-all duration-200 truncate px-1",
15944
+ selected ? "text-m3-on-surface" : "text-m3-on-surface-variant",
15945
+ "font-medium text-[12px] leading-4 tracking-[0.5px]"
15946
+ ),
15947
+ children: (_a = child.props.children) != null ? _a : label
15948
+ },
15949
+ "nav-label"
15950
+ ) })
15951
+ ]
15952
+ }
15953
+ ),
15954
+ /* @__PURE__ */ jsxRuntime.jsx(TouchTarget, {})
15955
+ ] });
15956
+ return /* @__PURE__ */ jsxRuntime.jsx(
15957
+ reactSlot.Slot,
15958
+ {
15959
+ ref,
15960
+ role: "menuitem",
15961
+ "aria-current": selected ? "page" : void 0,
15962
+ "aria-disabled": disabled ? true : void 0,
15963
+ "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
15964
+ onClick: handleClick,
15965
+ onPointerDown,
15966
+ className: itemClassName,
15967
+ children: React61__namespace.cloneElement(child, { children: innerContent })
15968
+ }
15969
+ );
15970
+ }
15873
15971
  return /* @__PURE__ */ jsxRuntime.jsxs(
15874
15972
  react.m.button,
15875
15973
  {
@@ -15881,13 +15979,7 @@ var NavigationBarItemComponent = React61__namespace.forwardRef(
15881
15979
  "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
15882
15980
  onClick: handleClick,
15883
15981
  onPointerDown,
15884
- className: cn(
15885
- "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none h-full items-center justify-center min-w-0",
15886
- variant === "xr" ? isResponsiveHorizontal ? "flex-1 min-[600px]:flex-initial min-[600px]:w-auto" : isForcedHorizontal ? "flex-initial w-auto" : "flex-1" : isForcedHorizontal ? "flex-initial w-auto" : "flex-1",
15887
- disabled && "pointer-events-none opacity-[0.38]",
15888
- contextItemClassName,
15889
- className
15890
- ),
15982
+ className: itemClassName,
15891
15983
  children: [
15892
15984
  /* @__PURE__ */ jsxRuntime.jsxs(
15893
15985
  "div",
@@ -16192,8 +16284,11 @@ var NavigationRailItemComponent = React61__namespace.forwardRef(
16192
16284
  disabled = false,
16193
16285
  badge,
16194
16286
  className,
16195
- "aria-label": ariaLabelProp
16287
+ "aria-label": ariaLabelProp,
16288
+ asChild = false,
16289
+ children
16196
16290
  }, ref) => {
16291
+ var _a;
16197
16292
  const { variant, labelVisibility } = React61__namespace.useContext(
16198
16293
  NavigationRailContext
16199
16294
  );
@@ -16217,6 +16312,96 @@ var NavigationRailItemComponent = React61__namespace.forwardRef(
16217
16312
  );
16218
16313
  const filledIcon = cloneIconWithFill2(icon, selected);
16219
16314
  const labelInitial = isModal ? false : { opacity: 0, x: isExpanded ? -12 : 0, y: isExpanded ? 0 : -8 };
16315
+ const itemClassName = cn(
16316
+ "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none",
16317
+ "focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2 rounded-full",
16318
+ disabled && "pointer-events-none opacity-[0.38]",
16319
+ isExpanded ? "w-full flex-row items-center px-3 h-14" : "w-full flex-col justify-center h-14",
16320
+ className
16321
+ );
16322
+ if (asChild && children) {
16323
+ const child = React61__namespace.Children.only(children);
16324
+ const innerContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16325
+ /* @__PURE__ */ jsxRuntime.jsxs(
16326
+ react.m.div,
16327
+ {
16328
+ layout: enableLayout,
16329
+ className: cn(
16330
+ "relative flex z-10",
16331
+ isExpanded ? "flex-row items-center w-fit h-14 px-4 gap-x-3 rounded-full" : "flex-col items-center justify-center w-full gap-y-1 rounded-full"
16332
+ ),
16333
+ children: [
16334
+ isExpanded && /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsxRuntime.jsx(
16335
+ ActivePill2,
16336
+ {
16337
+ layoutId: activePillId,
16338
+ disableInitial: isModal
16339
+ }
16340
+ ) }),
16341
+ isExpanded && /* @__PURE__ */ jsxRuntime.jsx(HoverStateLayer2, {}),
16342
+ isExpanded && /* @__PURE__ */ jsxRuntime.jsx(RippleLayer2, { ripples, onRippleDone: removeRipple }),
16343
+ /* @__PURE__ */ jsxRuntime.jsxs(
16344
+ react.m.div,
16345
+ {
16346
+ layout: enableLayout,
16347
+ className: cn(
16348
+ "relative flex items-center justify-center shrink-0 z-10",
16349
+ isExpanded ? "size-6" : "h-8 w-14 mx-auto"
16350
+ ),
16351
+ style: { borderRadius: 9999 },
16352
+ children: [
16353
+ !isExpanded && /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsxRuntime.jsx(ActivePill2, { layoutId: activePillId }) }),
16354
+ !isExpanded && /* @__PURE__ */ jsxRuntime.jsx(HoverStateLayer2, {}),
16355
+ !isExpanded && /* @__PURE__ */ jsxRuntime.jsx(RippleLayer2, { ripples, onRippleDone: removeRipple }),
16356
+ /* @__PURE__ */ jsxRuntime.jsx(
16357
+ react.m.div,
16358
+ {
16359
+ layout: enableLayout ? "position" : false,
16360
+ className: "relative z-10 flex size-6 items-center justify-center text-current",
16361
+ children: /* @__PURE__ */ jsxRuntime.jsx(IconContainer2, { selected, badge, children: filledIcon })
16362
+ }
16363
+ )
16364
+ ]
16365
+ }
16366
+ ),
16367
+ /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { mode: "popLayout", children: showLabel && (label || child.props.children) && /* @__PURE__ */ jsxRuntime.jsx(
16368
+ react.m.span,
16369
+ {
16370
+ layout: enableLayout ? "position" : false,
16371
+ initial: labelInitial,
16372
+ animate: { opacity: 1, x: 0, y: 0 },
16373
+ exit: { opacity: 0, transition: { duration: 0.1 } },
16374
+ transition: SPRING_TRANSITION,
16375
+ className: cn(
16376
+ "z-10 transition-colors duration-200 whitespace-nowrap",
16377
+ selected ? "text-m3-on-surface" : "text-m3-on-surface-variant",
16378
+ isExpanded ? "text-sm font-medium tracking-wide text-left" : "text-xs font-medium tracking-wide"
16379
+ ),
16380
+ children: (_a = child.props.children) != null ? _a : label
16381
+ },
16382
+ "rail-label"
16383
+ ) })
16384
+ ]
16385
+ }
16386
+ ),
16387
+ /* @__PURE__ */ jsxRuntime.jsx(TouchTarget, {})
16388
+ ] });
16389
+ return /* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domMax, strict: true, children: /* @__PURE__ */ jsxRuntime.jsx(
16390
+ reactSlot.Slot,
16391
+ {
16392
+ ref,
16393
+ role: "menuitem",
16394
+ "aria-current": selected ? "page" : void 0,
16395
+ "aria-disabled": disabled ? true : void 0,
16396
+ "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
16397
+ onClick: handleClick,
16398
+ onPointerDown,
16399
+ className: itemClassName,
16400
+ tabIndex: -1,
16401
+ children: React61__namespace.cloneElement(child, { children: innerContent })
16402
+ }
16403
+ ) });
16404
+ }
16220
16405
  return /* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domMax, strict: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
16221
16406
  react.m.button,
16222
16407
  {
@@ -16229,13 +16414,7 @@ var NavigationRailItemComponent = React61__namespace.forwardRef(
16229
16414
  "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
16230
16415
  onClick: handleClick,
16231
16416
  onPointerDown,
16232
- className: cn(
16233
- "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none",
16234
- "focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2 rounded-full",
16235
- disabled && "pointer-events-none opacity-[0.38]",
16236
- isExpanded ? "w-full flex-row items-center px-3 h-14" : "w-full flex-col justify-center h-14",
16237
- className
16238
- ),
16417
+ className: itemClassName,
16239
16418
  tabIndex: -1,
16240
16419
  children: [
16241
16420
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -23211,6 +23390,12 @@ var BottomDockedToolbar = React61__namespace.forwardRef(
23211
23390
  BottomDockedToolbar.displayName = "BottomDockedToolbar";
23212
23391
 
23213
23392
  // src/ui/toolbar/toolbar-tokens.ts
23393
+ var TOOLBAR_SPRING_TRANSITION = {
23394
+ type: "spring",
23395
+ stiffness: 300,
23396
+ damping: 30,
23397
+ mass: 0.8
23398
+ };
23214
23399
  var FloatingToolbarTokens = {
23215
23400
  ContainerBetweenSpace: 4,
23216
23401
  ContainerHeight: 64};
@@ -23642,13 +23827,17 @@ var ToolbarIconButton = React61__namespace.forwardRef(
23642
23827
  toolbarSize = "default",
23643
23828
  selected,
23644
23829
  asChild,
23645
- className
23830
+ className,
23831
+ transition,
23832
+ whileTap
23646
23833
  } = _b, props = __objRest(_b, [
23647
23834
  "emphasis",
23648
23835
  "toolbarSize",
23649
23836
  "selected",
23650
23837
  "asChild",
23651
- "className"
23838
+ "className",
23839
+ "transition",
23840
+ "whileTap"
23652
23841
  ]);
23653
23842
  const context = useToolbarContext();
23654
23843
  const widthClass = TOOLBAR_ICON_BUTTON_WIDTH[toolbarSize];
@@ -23659,16 +23848,20 @@ var ToolbarIconButton = React61__namespace.forwardRef(
23659
23848
  } : {
23660
23849
  variant: "default"
23661
23850
  };
23851
+ const motionProps = asChild ? __spreadValues(__spreadValues({}, transition !== void 0 && { transition }), whileTap !== void 0 && { whileTap }) : {
23852
+ transition: transition != null ? transition : TOOLBAR_SPRING_TRANSITION,
23853
+ whileTap: whileTap != null ? whileTap : { scale: 0.95 }
23854
+ };
23662
23855
  return /* @__PURE__ */ jsxRuntime.jsx(
23663
23856
  IconButton,
23664
- __spreadValues(__spreadProps(__spreadValues({
23857
+ __spreadValues(__spreadProps(__spreadValues(__spreadValues({
23665
23858
  ref,
23666
23859
  asChild,
23667
23860
  colorStyle,
23668
23861
  size: "md",
23669
23862
  shape: "round",
23670
23863
  iconSize: ToolbarIconButtonTokens.IconSize
23671
- }, iconButtonProps), {
23864
+ }, motionProps), iconButtonProps), {
23672
23865
  className: cn(
23673
23866
  "h-[48px]",
23674
23867
  widthClass,
@@ -23844,8 +24037,8 @@ var ToolbarToggleButton = React61__namespace.forwardRef(
23844
24037
  [pressScale, pressBounceOffset]
23845
24038
  );
23846
24039
  const transitionConfig = React61__namespace.useMemo(
23847
- () => ({
23848
- scale: FAST_SPATIAL_SPRING,
24040
+ () => __spreadProps(__spreadValues({}, TOOLBAR_SPRING_TRANSITION), {
24041
+ scale: TOOLBAR_SPRING_TRANSITION,
23849
24042
  x: {
23850
24043
  duration: 0.35,
23851
24044
  ease: "easeInOut"