@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/dist/index.mjs CHANGED
@@ -15816,8 +15816,11 @@ var NavigationBarItemComponent = React61.forwardRef(
15816
15816
  disabled = false,
15817
15817
  badge,
15818
15818
  className,
15819
- "aria-label": ariaLabelProp
15819
+ "aria-label": ariaLabelProp,
15820
+ asChild = false,
15821
+ children
15820
15822
  }, ref) => {
15823
+ var _a;
15821
15824
  const {
15822
15825
  variant,
15823
15826
  itemLayout,
@@ -15845,6 +15848,101 @@ var NavigationBarItemComponent = React61.forwardRef(
15845
15848
  [disabled, selected, onClick]
15846
15849
  );
15847
15850
  const filledIcon = cloneIconWithFill(icon, selected);
15851
+ const itemClassName = cn(
15852
+ "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none h-full items-center justify-center min-w-0",
15853
+ 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",
15854
+ disabled && "pointer-events-none opacity-[0.38]",
15855
+ contextItemClassName,
15856
+ className
15857
+ );
15858
+ if (asChild && children) {
15859
+ const child = React61.Children.only(children);
15860
+ const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
15861
+ /* @__PURE__ */ jsxs(
15862
+ "div",
15863
+ {
15864
+ className: cn(
15865
+ "relative flex items-center justify-center flex-col gap-y-1 w-full px-1 py-1.5",
15866
+ 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",
15867
+ isForcedHorizontal && "flex-row gap-y-0 gap-x-1.5 h-10 px-4 py-0 rounded-full w-auto"
15868
+ ),
15869
+ children: [
15870
+ /* @__PURE__ */ jsxs(
15871
+ "div",
15872
+ {
15873
+ className: cn(
15874
+ "absolute inset-0 z-0 hidden",
15875
+ isResponsiveHorizontal && "min-[600px]:block",
15876
+ isForcedHorizontal && "block!"
15877
+ ),
15878
+ children: [
15879
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsx(ActivePill, {}) }),
15880
+ /* @__PURE__ */ jsx(HoverStateLayer, {}),
15881
+ /* @__PURE__ */ jsx(RippleLayer, { ripples, onRippleDone: removeRipple })
15882
+ ]
15883
+ }
15884
+ ),
15885
+ /* @__PURE__ */ jsxs(
15886
+ "div",
15887
+ {
15888
+ className: cn(
15889
+ "relative flex items-center justify-center shrink-0 z-10",
15890
+ "h-8 w-16 mx-auto rounded-full",
15891
+ isResponsiveHorizontal && "min-[600px]:size-6 min-[600px]:w-auto min-[600px]:h-auto",
15892
+ isForcedHorizontal && "size-6 w-auto h-auto"
15893
+ ),
15894
+ children: [
15895
+ /* @__PURE__ */ jsxs(
15896
+ "div",
15897
+ {
15898
+ className: cn(
15899
+ "absolute inset-0 z-0",
15900
+ isResponsiveHorizontal && "min-[600px]:hidden",
15901
+ isForcedHorizontal && "hidden"
15902
+ ),
15903
+ children: [
15904
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsx(ActivePill, {}) }),
15905
+ /* @__PURE__ */ jsx(HoverStateLayer, {}),
15906
+ /* @__PURE__ */ jsx(RippleLayer, { ripples, onRippleDone: removeRipple })
15907
+ ]
15908
+ }
15909
+ ),
15910
+ /* @__PURE__ */ jsx("div", { className: "relative z-10 flex size-6 items-center justify-center text-current", children: /* @__PURE__ */ jsx(IconContainer, { selected, badge, children: filledIcon }) })
15911
+ ]
15912
+ }
15913
+ ),
15914
+ /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ jsx(
15915
+ "span",
15916
+ {
15917
+ className: cn(
15918
+ "z-10 transition-all duration-200 truncate px-1",
15919
+ selected ? "text-m3-on-surface" : "text-m3-on-surface-variant",
15920
+ "font-medium text-[12px] leading-4 tracking-[0.5px]"
15921
+ ),
15922
+ children: (_a = child.props.children) != null ? _a : label
15923
+ },
15924
+ "nav-label"
15925
+ ) })
15926
+ ]
15927
+ }
15928
+ ),
15929
+ /* @__PURE__ */ jsx(TouchTarget, {})
15930
+ ] });
15931
+ return /* @__PURE__ */ jsx(
15932
+ Slot,
15933
+ {
15934
+ ref,
15935
+ role: "menuitem",
15936
+ "aria-current": selected ? "page" : void 0,
15937
+ "aria-disabled": disabled ? true : void 0,
15938
+ "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
15939
+ onClick: handleClick,
15940
+ onPointerDown,
15941
+ className: itemClassName,
15942
+ children: React61.cloneElement(child, { children: innerContent })
15943
+ }
15944
+ );
15945
+ }
15848
15946
  return /* @__PURE__ */ jsxs(
15849
15947
  m.button,
15850
15948
  {
@@ -15856,13 +15954,7 @@ var NavigationBarItemComponent = React61.forwardRef(
15856
15954
  "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
15857
15955
  onClick: handleClick,
15858
15956
  onPointerDown,
15859
- className: cn(
15860
- "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none h-full items-center justify-center min-w-0",
15861
- 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",
15862
- disabled && "pointer-events-none opacity-[0.38]",
15863
- contextItemClassName,
15864
- className
15865
- ),
15957
+ className: itemClassName,
15866
15958
  children: [
15867
15959
  /* @__PURE__ */ jsxs(
15868
15960
  "div",
@@ -16167,8 +16259,11 @@ var NavigationRailItemComponent = React61.forwardRef(
16167
16259
  disabled = false,
16168
16260
  badge,
16169
16261
  className,
16170
- "aria-label": ariaLabelProp
16262
+ "aria-label": ariaLabelProp,
16263
+ asChild = false,
16264
+ children
16171
16265
  }, ref) => {
16266
+ var _a;
16172
16267
  const { variant, labelVisibility } = React61.useContext(
16173
16268
  NavigationRailContext
16174
16269
  );
@@ -16192,6 +16287,96 @@ var NavigationRailItemComponent = React61.forwardRef(
16192
16287
  );
16193
16288
  const filledIcon = cloneIconWithFill2(icon, selected);
16194
16289
  const labelInitial = isModal ? false : { opacity: 0, x: isExpanded ? -12 : 0, y: isExpanded ? 0 : -8 };
16290
+ const itemClassName = cn(
16291
+ "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none",
16292
+ "focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2 rounded-full",
16293
+ disabled && "pointer-events-none opacity-[0.38]",
16294
+ isExpanded ? "w-full flex-row items-center px-3 h-14" : "w-full flex-col justify-center h-14",
16295
+ className
16296
+ );
16297
+ if (asChild && children) {
16298
+ const child = React61.Children.only(children);
16299
+ const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
16300
+ /* @__PURE__ */ jsxs(
16301
+ m.div,
16302
+ {
16303
+ layout: enableLayout,
16304
+ className: cn(
16305
+ "relative flex z-10",
16306
+ 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"
16307
+ ),
16308
+ children: [
16309
+ isExpanded && /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsx(
16310
+ ActivePill2,
16311
+ {
16312
+ layoutId: activePillId,
16313
+ disableInitial: isModal
16314
+ }
16315
+ ) }),
16316
+ isExpanded && /* @__PURE__ */ jsx(HoverStateLayer2, {}),
16317
+ isExpanded && /* @__PURE__ */ jsx(RippleLayer2, { ripples, onRippleDone: removeRipple }),
16318
+ /* @__PURE__ */ jsxs(
16319
+ m.div,
16320
+ {
16321
+ layout: enableLayout,
16322
+ className: cn(
16323
+ "relative flex items-center justify-center shrink-0 z-10",
16324
+ isExpanded ? "size-6" : "h-8 w-14 mx-auto"
16325
+ ),
16326
+ style: { borderRadius: 9999 },
16327
+ children: [
16328
+ !isExpanded && /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: selected && /* @__PURE__ */ jsx(ActivePill2, { layoutId: activePillId }) }),
16329
+ !isExpanded && /* @__PURE__ */ jsx(HoverStateLayer2, {}),
16330
+ !isExpanded && /* @__PURE__ */ jsx(RippleLayer2, { ripples, onRippleDone: removeRipple }),
16331
+ /* @__PURE__ */ jsx(
16332
+ m.div,
16333
+ {
16334
+ layout: enableLayout ? "position" : false,
16335
+ className: "relative z-10 flex size-6 items-center justify-center text-current",
16336
+ children: /* @__PURE__ */ jsx(IconContainer2, { selected, badge, children: filledIcon })
16337
+ }
16338
+ )
16339
+ ]
16340
+ }
16341
+ ),
16342
+ /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", children: showLabel && (label || child.props.children) && /* @__PURE__ */ jsx(
16343
+ m.span,
16344
+ {
16345
+ layout: enableLayout ? "position" : false,
16346
+ initial: labelInitial,
16347
+ animate: { opacity: 1, x: 0, y: 0 },
16348
+ exit: { opacity: 0, transition: { duration: 0.1 } },
16349
+ transition: SPRING_TRANSITION,
16350
+ className: cn(
16351
+ "z-10 transition-colors duration-200 whitespace-nowrap",
16352
+ selected ? "text-m3-on-surface" : "text-m3-on-surface-variant",
16353
+ isExpanded ? "text-sm font-medium tracking-wide text-left" : "text-xs font-medium tracking-wide"
16354
+ ),
16355
+ children: (_a = child.props.children) != null ? _a : label
16356
+ },
16357
+ "rail-label"
16358
+ ) })
16359
+ ]
16360
+ }
16361
+ ),
16362
+ /* @__PURE__ */ jsx(TouchTarget, {})
16363
+ ] });
16364
+ return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
16365
+ Slot,
16366
+ {
16367
+ ref,
16368
+ role: "menuitem",
16369
+ "aria-current": selected ? "page" : void 0,
16370
+ "aria-disabled": disabled ? true : void 0,
16371
+ "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
16372
+ onClick: handleClick,
16373
+ onPointerDown,
16374
+ className: itemClassName,
16375
+ tabIndex: -1,
16376
+ children: React61.cloneElement(child, { children: innerContent })
16377
+ }
16378
+ ) });
16379
+ }
16195
16380
  return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
16196
16381
  m.button,
16197
16382
  {
@@ -16204,13 +16389,7 @@ var NavigationRailItemComponent = React61.forwardRef(
16204
16389
  "aria-label": ariaLabelProp || (typeof label === "string" ? label : void 0),
16205
16390
  onClick: handleClick,
16206
16391
  onPointerDown,
16207
- className: cn(
16208
- "group relative flex cursor-pointer transition-colors duration-200 outline-none select-none",
16209
- "focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2 rounded-full",
16210
- disabled && "pointer-events-none opacity-[0.38]",
16211
- isExpanded ? "w-full flex-row items-center px-3 h-14" : "w-full flex-col justify-center h-14",
16212
- className
16213
- ),
16392
+ className: itemClassName,
16214
16393
  tabIndex: -1,
16215
16394
  children: [
16216
16395
  /* @__PURE__ */ jsxs(
@@ -23186,6 +23365,12 @@ var BottomDockedToolbar = React61.forwardRef(
23186
23365
  BottomDockedToolbar.displayName = "BottomDockedToolbar";
23187
23366
 
23188
23367
  // src/ui/toolbar/toolbar-tokens.ts
23368
+ var TOOLBAR_SPRING_TRANSITION = {
23369
+ type: "spring",
23370
+ stiffness: 300,
23371
+ damping: 30,
23372
+ mass: 0.8
23373
+ };
23189
23374
  var FloatingToolbarTokens = {
23190
23375
  ContainerBetweenSpace: 4,
23191
23376
  ContainerHeight: 64};
@@ -23617,13 +23802,17 @@ var ToolbarIconButton = React61.forwardRef(
23617
23802
  toolbarSize = "default",
23618
23803
  selected,
23619
23804
  asChild,
23620
- className
23805
+ className,
23806
+ transition,
23807
+ whileTap
23621
23808
  } = _b, props = __objRest(_b, [
23622
23809
  "emphasis",
23623
23810
  "toolbarSize",
23624
23811
  "selected",
23625
23812
  "asChild",
23626
- "className"
23813
+ "className",
23814
+ "transition",
23815
+ "whileTap"
23627
23816
  ]);
23628
23817
  const context = useToolbarContext();
23629
23818
  const widthClass = TOOLBAR_ICON_BUTTON_WIDTH[toolbarSize];
@@ -23634,16 +23823,20 @@ var ToolbarIconButton = React61.forwardRef(
23634
23823
  } : {
23635
23824
  variant: "default"
23636
23825
  };
23826
+ const motionProps = asChild ? __spreadValues(__spreadValues({}, transition !== void 0 && { transition }), whileTap !== void 0 && { whileTap }) : {
23827
+ transition: transition != null ? transition : TOOLBAR_SPRING_TRANSITION,
23828
+ whileTap: whileTap != null ? whileTap : { scale: 0.95 }
23829
+ };
23637
23830
  return /* @__PURE__ */ jsx(
23638
23831
  IconButton,
23639
- __spreadValues(__spreadProps(__spreadValues({
23832
+ __spreadValues(__spreadProps(__spreadValues(__spreadValues({
23640
23833
  ref,
23641
23834
  asChild,
23642
23835
  colorStyle,
23643
23836
  size: "md",
23644
23837
  shape: "round",
23645
23838
  iconSize: ToolbarIconButtonTokens.IconSize
23646
- }, iconButtonProps), {
23839
+ }, motionProps), iconButtonProps), {
23647
23840
  className: cn(
23648
23841
  "h-[48px]",
23649
23842
  widthClass,
@@ -23819,8 +24012,8 @@ var ToolbarToggleButton = React61.forwardRef(
23819
24012
  [pressScale, pressBounceOffset]
23820
24013
  );
23821
24014
  const transitionConfig = React61.useMemo(
23822
- () => ({
23823
- scale: FAST_SPATIAL_SPRING,
24015
+ () => __spreadProps(__spreadValues({}, TOOLBAR_SPRING_TRANSITION), {
24016
+ scale: TOOLBAR_SPRING_TRANSITION,
23824
24017
  x: {
23825
24018
  duration: 0.35,
23826
24019
  ease: "easeInOut"