burne-ui 2.0.5 → 2.1.1
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/components/core/Button/buttonAnimations.js +6 -1
- package/dist/components/core/ContextMenu/ContextMenu.js +4 -2
- package/dist/components/core/utils/overlayTriggerSqueeze.d.ts +2 -0
- package/dist/components/core/utils/overlayTriggerSqueeze.js +33 -0
- package/dist/components/core/utils/runOpenAfterSqueeze.js +2 -0
- package/dist/theme/ThemeProvider.js +8 -5
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useMemo, useCallback,
|
|
3
|
+
import { useState, useLayoutEffect, useMemo, useCallback, useEffect } from "react";
|
|
4
4
|
import { MotionConfigProvider } from "../components/core/utils/motionConfigContext.js";
|
|
5
5
|
import { SkinProvider } from "../skins/skinContext.js";
|
|
6
|
-
import {
|
|
6
|
+
import { DEFAULT_THEME_STORAGE_KEY, resolveTheme } from "./themeConfig.js";
|
|
7
7
|
import { BurneThemeContext } from "./themeContext.js";
|
|
8
8
|
import { useBurneTheme, useBurneThemeOptional } from "./themeContext.js";
|
|
9
9
|
function readStoredTheme(storageKey) {
|
|
@@ -46,10 +46,13 @@ function ThemeProvider({
|
|
|
46
46
|
skin,
|
|
47
47
|
skins
|
|
48
48
|
}) {
|
|
49
|
-
const [uncontrolled, setUncontrolled] = useState(
|
|
50
|
-
return readStoredTheme(storageKey) ?? defaultTheme;
|
|
51
|
-
});
|
|
49
|
+
const [uncontrolled, setUncontrolled] = useState(defaultTheme);
|
|
52
50
|
const [systemRevision, setSystemRevision] = useState(0);
|
|
51
|
+
useLayoutEffect(() => {
|
|
52
|
+
if (themeProp !== void 0) return;
|
|
53
|
+
const stored = readStoredTheme(storageKey);
|
|
54
|
+
if (stored !== null) setUncontrolled(stored);
|
|
55
|
+
}, [storageKey]);
|
|
53
56
|
const theme = themeProp ?? uncontrolled;
|
|
54
57
|
const resolvedTheme = useMemo(() => {
|
|
55
58
|
return resolveTheme(theme);
|