@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.
@@ -2662,8 +2662,11 @@ var NavigationBarItemComponent = React36.forwardRef(
2662
2662
  disabled = false,
2663
2663
  badge,
2664
2664
  className,
2665
- "aria-label": ariaLabelProp
2665
+ "aria-label": ariaLabelProp,
2666
+ asChild = false,
2667
+ children
2666
2668
  }, ref) => {
2669
+ var _a;
2667
2670
  const {
2668
2671
  variant,
2669
2672
  itemLayout,
@@ -2691,6 +2694,101 @@ var NavigationBarItemComponent = React36.forwardRef(
2691
2694
  [disabled, selected, onClick]
2692
2695
  );
2693
2696
  const filledIcon = cloneIconWithFill(icon, selected);
2697
+ const itemClassName = cn(
2698
+ "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none h-full items-center justify-center min-w-0",
2699
+ 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",
2700
+ disabled && "pointer-events-none opacity-[0.38]",
2701
+ contextItemClassName,
2702
+ className
2703
+ );
2704
+ if (asChild && children) {
2705
+ const child = React36.Children.only(children);
2706
+ const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
2707
+ /* @__PURE__ */ jsxs(
2708
+ "div",
2709
+ {
2710
+ className: cn(
2711
+ "relative flex items-center justify-center flex-col gap-y-1 w-full px-1 py-1.5",
2712
+ 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",
2713
+ isForcedHorizontal && "flex-row gap-y-0 gap-x-1.5 h-10 px-4 py-0 rounded-full w-auto"
2714
+ ),
2715
+ children: [
2716
+ /* @__PURE__ */ jsxs(
2717
+ "div",
2718
+ {
2719
+ className: cn(
2720
+ "absolute inset-0 z-0 hidden",
2721
+ isResponsiveHorizontal && "min-[600px]:block",
2722
+ isForcedHorizontal && "block!"
2723
+ ),
2724
+ children: [
2725
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsx(ActivePill, {}) }),
2726
+ /* @__PURE__ */ jsx(HoverStateLayer, {}),
2727
+ /* @__PURE__ */ jsx(RippleLayer, { ripples, onRippleDone: removeRipple })
2728
+ ]
2729
+ }
2730
+ ),
2731
+ /* @__PURE__ */ jsxs(
2732
+ "div",
2733
+ {
2734
+ className: cn(
2735
+ "relative flex items-center justify-center shrink-0 z-10",
2736
+ "h-8 w-16 mx-auto rounded-full",
2737
+ isResponsiveHorizontal && "min-[600px]:size-6 min-[600px]:w-auto min-[600px]:h-auto",
2738
+ isForcedHorizontal && "size-6 w-auto h-auto"
2739
+ ),
2740
+ children: [
2741
+ /* @__PURE__ */ jsxs(
2742
+ "div",
2743
+ {
2744
+ className: cn(
2745
+ "absolute inset-0 z-0",
2746
+ isResponsiveHorizontal && "min-[600px]:hidden",
2747
+ isForcedHorizontal && "hidden"
2748
+ ),
2749
+ children: [
2750
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsx(ActivePill, {}) }),
2751
+ /* @__PURE__ */ jsx(HoverStateLayer, {}),
2752
+ /* @__PURE__ */ jsx(RippleLayer, { ripples, onRippleDone: removeRipple })
2753
+ ]
2754
+ }
2755
+ ),
2756
+ /* @__PURE__ */ jsx("div", { className: "relative z-10 flex size-6 items-center justify-center text-current", children: /* @__PURE__ */ jsx(IconContainer, { selected, badge, children: filledIcon }) })
2757
+ ]
2758
+ }
2759
+ ),
2760
+ /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ jsx(
2761
+ "span",
2762
+ {
2763
+ className: cn(
2764
+ "z-10 transition-all duration-200 truncate px-1",
2765
+ selected ? "text-m3-on-surface" : "text-m3-on-surface-variant",
2766
+ "font-medium text-[12px] leading-4 tracking-[0.5px]"
2767
+ ),
2768
+ children: (_a = child.props.children) != null ? _a : label
2769
+ },
2770
+ "nav-label"
2771
+ ) })
2772
+ ]
2773
+ }
2774
+ ),
2775
+ /* @__PURE__ */ jsx(TouchTarget, {})
2776
+ ] });
2777
+ return /* @__PURE__ */ jsx(
2778
+ Slot,
2779
+ {
2780
+ ref,
2781
+ role: "menuitem",
2782
+ "aria-current": selected ? "page" : void 0,
2783
+ "aria-disabled": disabled ? true : void 0,
2784
+ "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
2785
+ onClick: handleClick,
2786
+ onPointerDown,
2787
+ className: itemClassName,
2788
+ children: React36.cloneElement(child, { children: innerContent })
2789
+ }
2790
+ );
2791
+ }
2694
2792
  return /* @__PURE__ */ jsxs(
2695
2793
  m.button,
2696
2794
  {
@@ -2702,13 +2800,7 @@ var NavigationBarItemComponent = React36.forwardRef(
2702
2800
  "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
2703
2801
  onClick: handleClick,
2704
2802
  onPointerDown,
2705
- className: cn(
2706
- "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none h-full items-center justify-center min-w-0",
2707
- 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",
2708
- disabled && "pointer-events-none opacity-[0.38]",
2709
- contextItemClassName,
2710
- className
2711
- ),
2803
+ className: itemClassName,
2712
2804
  children: [
2713
2805
  /* @__PURE__ */ jsxs(
2714
2806
  "div",
@@ -3013,8 +3105,11 @@ var NavigationRailItemComponent = React36.forwardRef(
3013
3105
  disabled = false,
3014
3106
  badge,
3015
3107
  className,
3016
- "aria-label": ariaLabelProp
3108
+ "aria-label": ariaLabelProp,
3109
+ asChild = false,
3110
+ children
3017
3111
  }, ref) => {
3112
+ var _a;
3018
3113
  const { variant, labelVisibility } = React36.useContext(
3019
3114
  NavigationRailContext
3020
3115
  );
@@ -3038,6 +3133,96 @@ var NavigationRailItemComponent = React36.forwardRef(
3038
3133
  );
3039
3134
  const filledIcon = cloneIconWithFill2(icon, selected);
3040
3135
  const labelInitial = isModal ? false : { opacity: 0, x: isExpanded ? -12 : 0, y: isExpanded ? 0 : -8 };
3136
+ const itemClassName = cn(
3137
+ "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none",
3138
+ "focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2 rounded-full",
3139
+ disabled && "pointer-events-none opacity-[0.38]",
3140
+ isExpanded ? "w-full flex-row items-center px-3 h-14" : "w-full flex-col justify-center h-14",
3141
+ className
3142
+ );
3143
+ if (asChild && children) {
3144
+ const child = React36.Children.only(children);
3145
+ const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
3146
+ /* @__PURE__ */ jsxs(
3147
+ m.div,
3148
+ {
3149
+ layout: enableLayout,
3150
+ className: cn(
3151
+ "relative flex z-10",
3152
+ 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"
3153
+ ),
3154
+ children: [
3155
+ isExpanded && /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsx(
3156
+ ActivePill2,
3157
+ {
3158
+ layoutId: activePillId,
3159
+ disableInitial: isModal
3160
+ }
3161
+ ) }),
3162
+ isExpanded && /* @__PURE__ */ jsx(HoverStateLayer2, {}),
3163
+ isExpanded && /* @__PURE__ */ jsx(RippleLayer2, { ripples, onRippleDone: removeRipple }),
3164
+ /* @__PURE__ */ jsxs(
3165
+ m.div,
3166
+ {
3167
+ layout: enableLayout,
3168
+ className: cn(
3169
+ "relative flex items-center justify-center shrink-0 z-10",
3170
+ isExpanded ? "size-6" : "h-8 w-14 mx-auto"
3171
+ ),
3172
+ style: { borderRadius: 9999 },
3173
+ children: [
3174
+ !isExpanded && /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsx(ActivePill2, { layoutId: activePillId }) }),
3175
+ !isExpanded && /* @__PURE__ */ jsx(HoverStateLayer2, {}),
3176
+ !isExpanded && /* @__PURE__ */ jsx(RippleLayer2, { ripples, onRippleDone: removeRipple }),
3177
+ /* @__PURE__ */ jsx(
3178
+ m.div,
3179
+ {
3180
+ layout: enableLayout ? "position" : false,
3181
+ className: "relative z-10 flex size-6 items-center justify-center text-current",
3182
+ children: /* @__PURE__ */ jsx(IconContainer2, { selected, badge, children: filledIcon })
3183
+ }
3184
+ )
3185
+ ]
3186
+ }
3187
+ ),
3188
+ /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", children: showLabel && (label || child.props.children) && /* @__PURE__ */ jsx(
3189
+ m.span,
3190
+ {
3191
+ layout: enableLayout ? "position" : false,
3192
+ initial: labelInitial,
3193
+ animate: { opacity: 1, x: 0, y: 0 },
3194
+ exit: { opacity: 0, transition: { duration: 0.1 } },
3195
+ transition: SPRING_TRANSITION,
3196
+ className: cn(
3197
+ "z-10 transition-colors duration-200 whitespace-nowrap",
3198
+ selected ? "text-m3-on-surface" : "text-m3-on-surface-variant",
3199
+ isExpanded ? "text-sm font-medium tracking-wide text-left" : "text-xs font-medium tracking-wide"
3200
+ ),
3201
+ children: (_a = child.props.children) != null ? _a : label
3202
+ },
3203
+ "rail-label"
3204
+ ) })
3205
+ ]
3206
+ }
3207
+ ),
3208
+ /* @__PURE__ */ jsx(TouchTarget, {})
3209
+ ] });
3210
+ return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
3211
+ Slot,
3212
+ {
3213
+ ref,
3214
+ role: "menuitem",
3215
+ "aria-current": selected ? "page" : void 0,
3216
+ "aria-disabled": disabled ? true : void 0,
3217
+ "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
3218
+ onClick: handleClick,
3219
+ onPointerDown,
3220
+ className: itemClassName,
3221
+ tabIndex: -1,
3222
+ children: React36.cloneElement(child, { children: innerContent })
3223
+ }
3224
+ ) });
3225
+ }
3041
3226
  return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
3042
3227
  m.button,
3043
3228
  {
@@ -3050,13 +3235,7 @@ var NavigationRailItemComponent = React36.forwardRef(
3050
3235
  "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
3051
3236
  onClick: handleClick,
3052
3237
  onPointerDown,
3053
- className: cn(
3054
- "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none",
3055
- "focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2 rounded-full",
3056
- disabled && "pointer-events-none opacity-[0.38]",
3057
- isExpanded ? "w-full flex-row items-center px-3 h-14" : "w-full flex-col justify-center h-14",
3058
- className
3059
- ),
3238
+ className: itemClassName,
3060
3239
  tabIndex: -1,
3061
3240
  children: [
3062
3241
  /* @__PURE__ */ jsxs(
@@ -6194,6 +6373,12 @@ var BottomDockedToolbar = React36.forwardRef(
6194
6373
  BottomDockedToolbar.displayName = "BottomDockedToolbar";
6195
6374
 
6196
6375
  // src/ui/toolbar/toolbar-tokens.ts
6376
+ var TOOLBAR_SPRING_TRANSITION = {
6377
+ type: "spring",
6378
+ stiffness: 300,
6379
+ damping: 30,
6380
+ mass: 0.8
6381
+ };
6197
6382
  var FloatingToolbarTokens = {
6198
6383
  ContainerBetweenSpace: 4,
6199
6384
  ContainerHeight: 64};
@@ -6625,13 +6810,17 @@ var ToolbarIconButton = React36.forwardRef(
6625
6810
  toolbarSize = "default",
6626
6811
  selected,
6627
6812
  asChild,
6628
- className
6813
+ className,
6814
+ transition,
6815
+ whileTap
6629
6816
  } = _b, props = __objRest(_b, [
6630
6817
  "emphasis",
6631
6818
  "toolbarSize",
6632
6819
  "selected",
6633
6820
  "asChild",
6634
- "className"
6821
+ "className",
6822
+ "transition",
6823
+ "whileTap"
6635
6824
  ]);
6636
6825
  const context = useToolbarContext();
6637
6826
  const widthClass = TOOLBAR_ICON_BUTTON_WIDTH[toolbarSize];
@@ -6642,16 +6831,20 @@ var ToolbarIconButton = React36.forwardRef(
6642
6831
  } : {
6643
6832
  variant: "default"
6644
6833
  };
6834
+ const motionProps = asChild ? __spreadValues(__spreadValues({}, transition !== void 0 && { transition }), whileTap !== void 0 && { whileTap }) : {
6835
+ transition: transition != null ? transition : TOOLBAR_SPRING_TRANSITION,
6836
+ whileTap: whileTap != null ? whileTap : { scale: 0.95 }
6837
+ };
6645
6838
  return /* @__PURE__ */ jsx(
6646
6839
  IconButton,
6647
- __spreadValues(__spreadProps(__spreadValues({
6840
+ __spreadValues(__spreadProps(__spreadValues(__spreadValues({
6648
6841
  ref,
6649
6842
  asChild,
6650
6843
  colorStyle,
6651
6844
  size: "md",
6652
6845
  shape: "round",
6653
6846
  iconSize: ToolbarIconButtonTokens.IconSize
6654
- }, iconButtonProps), {
6847
+ }, motionProps), iconButtonProps), {
6655
6848
  className: cn(
6656
6849
  "h-[48px]",
6657
6850
  widthClass,
@@ -6827,8 +7020,8 @@ var ToolbarToggleButton = React36.forwardRef(
6827
7020
  [pressScale, pressBounceOffset]
6828
7021
  );
6829
7022
  const transitionConfig = React36.useMemo(
6830
- () => ({
6831
- scale: FAST_SPATIAL_SPRING,
7023
+ () => __spreadProps(__spreadValues({}, TOOLBAR_SPRING_TRANSITION), {
7024
+ scale: TOOLBAR_SPRING_TRANSITION,
6832
7025
  x: {
6833
7026
  duration: 0.35,
6834
7027
  ease: "easeInOut"