burne-ui 2.0.5 → 2.1.0

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.
@@ -3,6 +3,7 @@ import { clearMotionTransform, killMotion } from "../utils/gsapMotion.js";
3
3
  import { useRef, useCallback, useMemo, useLayoutEffect, useEffect } from "react";
4
4
  import { initElementShadow, isInteractivePressKey, shouldSkipInteractiveHoverLift, shadowNone } from "../utils/hoverInteractiveLift.js";
5
5
  import { mergeForwardedRef } from "../utils/mergeRefs.js";
6
+ import { isOverlayTriggerOpening } from "../utils/overlayTriggerSqueeze.js";
6
7
  import { shadowMotionFor } from "../utils/useShadowMotion.js";
7
8
  import { overlaySkinMotion, usesKitElevationMember } from "../../../skins/resolveVariantVisual.js";
8
9
  import { useButtonMotionScope } from "./buttonContext.js";
@@ -138,7 +139,11 @@ function useButtonAnimations({
138
139
  (e) => {
139
140
  onPointerDown?.(e);
140
141
  if (!enabled || e.defaultPrevented) return;
141
- playRoot("pressIn");
142
+ const node = e.currentTarget;
143
+ queueMicrotask(() => {
144
+ if (isOverlayTriggerOpening(node)) return;
145
+ playRoot("pressIn");
146
+ });
142
147
  },
143
148
  [enabled, onPointerDown, playRoot]
144
149
  );
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useRef, forwardRef, useCallback, isValidElement, cloneElement, useLayoutEffect } from "react";
3
+ import { useRef, forwardRef, useCallback, isValidElement, cloneElement, useLayoutEffect, useState, useEffect } from "react";
4
4
  import { createPortal } from "react-dom";
5
5
  import { Dropdown } from "../Dropdown/index.js";
6
6
  import { useDropdown, useDropdownClassNames } from "../Dropdown/dropdownContext.js";
@@ -22,7 +22,9 @@ function ContextMenuPoint() {
22
22
  const rect = trigger.getBoundingClientRect();
23
23
  placeContextMenuAnchor(anchor, rect.left, rect.bottom);
24
24
  }, [anchorRef, open, triggerRef]);
25
- if (typeof document === "undefined") return null;
25
+ const [mounted, setMounted] = useState(false);
26
+ useEffect(() => setMounted(true), []);
27
+ if (!mounted) return null;
26
28
  return createPortal(
27
29
  /* @__PURE__ */ jsx("span", { ref: anchorRef, "aria-hidden": true, tabIndex: -1, className: CONTEXT_MENU_ANCHOR_CLASS }),
28
30
  document.body
@@ -14,6 +14,8 @@ export declare function playOverlayTriggerOpenSqueeze({ scope, el, partMotion, c
14
14
  partMotion?: MotionPartPhases;
15
15
  config?: Readonly<MotionConfig>;
16
16
  }): Promise<void>;
17
+ /** True while the trigger runs its own open press, so the child control skips a second one. */
18
+ export declare function isOverlayTriggerOpening(el: Element | null): boolean;
17
19
  export declare function useOverlayTriggerSlot<T extends HTMLElement>({ scope, slot, motion, forwardedRef, onPointerOver, onPointerOut, onPointerDown, onPointerUp, }: {
18
20
  scope: MotionScopeValue | null;
19
21
  slot?: string;
@@ -3,8 +3,10 @@ import { useRef, useCallback } from "react";
3
3
  import { animateInteractivePressSqueeze } from "./hoverInteractiveLift.js";
4
4
  import { useMotionConfig } from "./motionConfigContext.js";
5
5
  import { useOpeningRef, runOpenAfterSqueeze } from "./runOpenAfterSqueeze.js";
6
+ import { lookupSkin } from "../../../skins/skinLookup.js";
6
7
  import { bindLiftRecipes } from "./slotMotion/recipes/bindLift.js";
7
8
  import { useMotionPart } from "./slotMotion/useMotionPart.js";
9
+ import { runMotionPhase } from "./slotMotion/runMotionPhase.js";
8
10
  bindLiftRecipes();
9
11
  const OVERLAY_TRIGGER_MOTION_DEFAULTS = {
10
12
  trigger: {
@@ -18,6 +20,20 @@ async function playOverlayTriggerOpenSqueeze({
18
20
  partMotion,
19
21
  config
20
22
  }) {
23
+ const skinPress = skinPressRecipeFor(el);
24
+ if (skinPress) {
25
+ await runMotionPhase({
26
+ el,
27
+ phase: "pressIn",
28
+ value: skinPress,
29
+ targets: { trigger: el },
30
+ params: { pointerInside: () => el.matches(":hover") },
31
+ waitForComplete: false,
32
+ slot: "trigger",
33
+ config
34
+ }).finished;
35
+ return;
36
+ }
21
37
  if (!scope) {
22
38
  await animateInteractivePressSqueeze(el, { config });
23
39
  return;
@@ -30,6 +46,22 @@ async function playOverlayTriggerOpenSqueeze({
30
46
  }
31
47
  await scope.play("trigger", "pressIn", { el, partMotion }).finished;
32
48
  }
49
+ function skinPressRecipeFor(el) {
50
+ const variant = el.dataset.variant;
51
+ if (!variant) return void 0;
52
+ const skin = lookupSkin(variant);
53
+ if (!skin?.motion) return void 0;
54
+ const slots = (el.dataset.skinSlot ?? "").split(/\s+/).filter(Boolean);
55
+ for (const slot of slots) {
56
+ const phases = skin.motion[slot];
57
+ const press = phases?.pressIn;
58
+ if (typeof press === "string") return press;
59
+ }
60
+ return void 0;
61
+ }
62
+ function isOverlayTriggerOpening(el) {
63
+ return el instanceof HTMLElement && el.dataset.overlayOpening === "true";
64
+ }
33
65
  function useOverlayTriggerSlot({
34
66
  scope,
35
67
  slot = "trigger",
@@ -79,6 +111,7 @@ function useOverlayTriggerSlot({
79
111
  }
80
112
  export {
81
113
  OVERLAY_TRIGGER_MOTION_DEFAULTS,
114
+ isOverlayTriggerOpening,
82
115
  playOverlayTriggerOpenSqueeze,
83
116
  useOverlayTriggerSlot
84
117
  };
@@ -27,8 +27,10 @@ function runOpenAfterSqueeze({
27
27
  return;
28
28
  }
29
29
  openingRef.current = true;
30
+ el.dataset.overlayOpening = "true";
30
31
  void runSqueeze(el).then(() => {
31
32
  openingRef.current = false;
33
+ delete el.dataset.overlayOpening;
32
34
  openNow();
33
35
  });
34
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "burne-ui",
3
- "version": "2.0.5",
3
+ "version": "2.1.0",
4
4
  "description": "React UI kit (Burne UI)",
5
5
  "license": "MIT",
6
6
  "repository": {