burne-ui 2.0.4 → 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.
- package/cli/skin-build.mjs +4 -2
- package/cli/skin-stylesheet.d.mts +9 -6
- package/cli/skin-stylesheet.mjs +20 -4
- package/dist/cli/skin-stylesheet.js +11 -4
- package/dist/components/core/Button/buttonAnimations.js +6 -1
- package/dist/components/core/ContextMenu/ContextMenu.js +4 -2
- package/dist/components/core/DatePicker/datePickerParts.js +7 -0
- package/dist/components/core/Field/fieldParts.d.ts +1 -1
- package/dist/components/core/Tabs/tabsParts.js +2 -2
- package/dist/components/core/Tabs/tabsStyles.d.ts +3 -1
- package/dist/components/core/Tabs/tabsStyles.js +4 -0
- package/dist/components/core/Tabs/useSlidingTabIndicator.d.ts +2 -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/components/core/utils/slotMotion/createMotionScope.js +4 -0
- package/dist/components/core/utils/slotMotion/useMotionPart.js +3 -3
- package/dist/internal.js +1 -2
- package/dist/skins/skinDocument.d.ts +10 -3
- package/dist/skins/skinDocument.js +11 -6
- package/dist/skins/skinTypes.d.ts +11 -3
- package/dist/studio/designDocument.js +1 -2
- package/dist/studio/liveSkinSlots.d.ts +2 -0
- package/dist/studio/liveSkinSlots.js +8 -0
- package/dist/studio/studioMode.d.ts +4 -4
- package/dist/studio/studioMode.js +3 -17
- package/dist/studio/studioModeContext.d.ts +4 -2
- package/dist/studio/studioModeContext.js +7 -6
- package/dist/studio.d.ts +3 -2
- package/dist/studio.js +3 -3
- package/package.json +1 -1
package/cli/skin-build.mjs
CHANGED
|
@@ -18,11 +18,13 @@ function authorCss(css) {
|
|
|
18
18
|
|
|
19
19
|
export function buildSkin(dir) {
|
|
20
20
|
const loaded = loadSkinPackage(dir);
|
|
21
|
-
const
|
|
21
|
+
const live = readSkinLiveSlots();
|
|
22
|
+
const errors = validateSkin({ ...loaded, slots: readSkinSlots(), live });
|
|
22
23
|
if (errors.length > 0) {
|
|
23
24
|
throw new Error(errors.join("\n"));
|
|
24
25
|
}
|
|
25
|
-
const
|
|
26
|
+
const targets = new Set(live.targets);
|
|
27
|
+
const generated = renderSkinStylesheet(loaded.definition, { isTarget: (slot) => targets.has(slot) }).trimEnd();
|
|
26
28
|
const extra = authorCss(loaded.css);
|
|
27
29
|
const css = extra ? `${generated}\n\n${extra}\n` : `${generated}\n`;
|
|
28
30
|
const outDir = join(dir, "dist");
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export function renderSkinStylesheet(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function renderSkinStylesheet(
|
|
2
|
+
skin: {
|
|
3
|
+
name: string;
|
|
4
|
+
tokens?: Record<string, string>;
|
|
5
|
+
tokensLight?: Record<string, string>;
|
|
6
|
+
tokensDark?: Record<string, string>;
|
|
7
|
+
},
|
|
8
|
+
options?: { isTarget?: (slot: string) => boolean },
|
|
9
|
+
): string;
|
package/cli/skin-stylesheet.mjs
CHANGED
|
@@ -21,7 +21,12 @@ function sameTokenRecord(a, b) {
|
|
|
21
21
|
return aKeys.every((key) => a[key] === b[key]);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* `options.isTarget(slot)` tells a target slot (class) from a part (`data-skin-slot`).
|
|
26
|
+
* Without it every rule slot is a target.
|
|
27
|
+
*/
|
|
28
|
+
export function renderSkinStylesheet(skin, options = {}) {
|
|
29
|
+
const isTarget = typeof options.isTarget === "function" ? options.isTarget : () => true;
|
|
25
30
|
const name = String(skin.name).replace(/"/g, "");
|
|
26
31
|
const dark = mergedSkinTokens(skin.tokens, skin.tokensDark);
|
|
27
32
|
const light = mergedSkinTokens(skin.tokens, skin.tokensLight);
|
|
@@ -39,7 +44,7 @@ export function renderSkinStylesheet(skin) {
|
|
|
39
44
|
lightDiffers ? cssBlock(darkSelector, dark).trimEnd() : "",
|
|
40
45
|
renderSkinFonts(skin),
|
|
41
46
|
renderSkinProperties(skin),
|
|
42
|
-
renderSkinRules(skin),
|
|
47
|
+
renderSkinRules(skin, isTarget),
|
|
43
48
|
"",
|
|
44
49
|
]
|
|
45
50
|
.filter((part) => part !== "")
|
|
@@ -58,13 +63,24 @@ function declarationBlock(selector, style) {
|
|
|
58
63
|
return `${selector} {\n${body}\n}`;
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
/**
|
|
67
|
+
* A target slot keeps its `.skin-{name}-{slot}` class. Any other rule slot is a part
|
|
68
|
+
* (`card.title`) marked by `data-skin-slot`, scoped to a node the skin paints.
|
|
69
|
+
*/
|
|
70
|
+
function ruleSelector(skin, slot, isTarget) {
|
|
71
|
+
if (isTarget(slot)) return `.${ruleClass(skin.name, slot)}`;
|
|
72
|
+
const name = String(skin.name).replace(/"/g, "");
|
|
73
|
+
const part = String(slot).replace(/"/g, "");
|
|
74
|
+
return `:is([data-variant="${name}"], [data-skin="${name}"]) [data-skin-slot~="${part}"]`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function renderSkinRules(skin, isTarget) {
|
|
62
78
|
const rules = skin.rules;
|
|
63
79
|
if (!rules || typeof rules !== "object") return "";
|
|
64
80
|
const blocks = [];
|
|
65
81
|
for (const [slot, spec] of Object.entries(rules)) {
|
|
66
82
|
if (!spec || typeof spec !== "object") continue;
|
|
67
|
-
const selector =
|
|
83
|
+
const selector = ruleSelector(skin, slot, isTarget);
|
|
68
84
|
// Theme branches before :hover. `:where` keeps the dark page rule at class
|
|
69
85
|
// specificity, so a later `:hover` of the same class still wins.
|
|
70
86
|
// `<html>` in the dark theme has no attribute, so the page matches `:root:not([data-theme="light"])`.
|
|
@@ -14,7 +14,8 @@ function sameTokenRecord(a, b) {
|
|
|
14
14
|
if (aKeys.length !== Object.keys(b).length) return false;
|
|
15
15
|
return aKeys.every((key) => a[key] === b[key]);
|
|
16
16
|
}
|
|
17
|
-
function renderSkinStylesheet(skin) {
|
|
17
|
+
function renderSkinStylesheet(skin, options = {}) {
|
|
18
|
+
const isTarget = typeof options.isTarget === "function" ? options.isTarget : () => true;
|
|
18
19
|
const name = String(skin.name).replace(/"/g, "");
|
|
19
20
|
const dark = mergedSkinTokens(skin.tokens, skin.tokensDark);
|
|
20
21
|
const light = mergedSkinTokens(skin.tokens, skin.tokensLight);
|
|
@@ -32,7 +33,7 @@ function renderSkinStylesheet(skin) {
|
|
|
32
33
|
lightDiffers ? cssBlock(darkSelector, dark).trimEnd() : "",
|
|
33
34
|
renderSkinFonts(skin),
|
|
34
35
|
renderSkinProperties(skin),
|
|
35
|
-
renderSkinRules(skin),
|
|
36
|
+
renderSkinRules(skin, isTarget),
|
|
36
37
|
""
|
|
37
38
|
].filter((part) => part !== "").join("\n\n");
|
|
38
39
|
}
|
|
@@ -48,13 +49,19 @@ function declarationBlock(selector, style) {
|
|
|
48
49
|
${body}
|
|
49
50
|
}`;
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function ruleSelector(skin, slot, isTarget) {
|
|
53
|
+
if (isTarget(slot)) return `.${ruleClass(skin.name, slot)}`;
|
|
54
|
+
const name = String(skin.name).replace(/"/g, "");
|
|
55
|
+
const part = String(slot).replace(/"/g, "");
|
|
56
|
+
return `:is([data-variant="${name}"], [data-skin="${name}"]) [data-skin-slot~="${part}"]`;
|
|
57
|
+
}
|
|
58
|
+
function renderSkinRules(skin, isTarget) {
|
|
52
59
|
const rules = skin.rules;
|
|
53
60
|
if (!rules || typeof rules !== "object") return "";
|
|
54
61
|
const blocks = [];
|
|
55
62
|
for (const [slot, spec] of Object.entries(rules)) {
|
|
56
63
|
if (!spec || typeof spec !== "object") continue;
|
|
57
|
-
const selector =
|
|
64
|
+
const selector = ruleSelector(skin, slot, isTarget);
|
|
58
65
|
const darkSelector = `:where(:root:not([data-theme="light"])) ${selector}, [data-theme="dark"] ${selector}`;
|
|
59
66
|
blocks.push(declarationBlock(selector, spec.style));
|
|
60
67
|
blocks.push(declarationBlock(darkSelector, spec.dark));
|
|
@@ -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
|
|
@@ -74,16 +74,23 @@ const DatePickerTrigger = forwardRef(
|
|
|
74
74
|
});
|
|
75
75
|
const icon = useDatePickerIconMotion(field.open);
|
|
76
76
|
const text = field.empty ? field.placeholder : field.display;
|
|
77
|
+
const openedByPointerRef = useRef(false);
|
|
77
78
|
const handleClick = (event) => {
|
|
78
79
|
onClick?.(event);
|
|
79
80
|
if (event.defaultPrevented || field.disabled || field.readOnly) return;
|
|
81
|
+
if (openedByPointerRef.current) {
|
|
82
|
+
openedByPointerRef.current = false;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
80
85
|
if (field.open) field.setOpen(false);
|
|
86
|
+
else if (!trigger.openingRef.current) trigger.openAfterSqueeze(() => field.setOpen(true));
|
|
81
87
|
};
|
|
82
88
|
const handlePointerDown = (event) => {
|
|
83
89
|
trigger.pointerHandlers.onPointerDown?.(event);
|
|
84
90
|
if (event.defaultPrevented || field.disabled || field.readOnly) return;
|
|
85
91
|
if (field.open || trigger.openingRef.current || event.button !== 0) return;
|
|
86
92
|
event.preventDefault();
|
|
93
|
+
openedByPointerRef.current = true;
|
|
87
94
|
trigger.openAfterSqueeze(() => field.setOpen(true));
|
|
88
95
|
};
|
|
89
96
|
const handleKeyDown = (event) => {
|
|
@@ -37,6 +37,6 @@ export declare const FieldSetActions: import('react').ForwardRefExoticComponent<
|
|
|
37
37
|
motion?: import('../../../index.js').Prettify<import('./fieldTypes.js').FieldPartMotion>;
|
|
38
38
|
} & import('react').RefAttributes<HTMLDivElement>>;
|
|
39
39
|
export declare function FieldSetStack({ legend, loose, groups, actions, }: UseFieldSetRootStateResult): import("react/jsx-runtime").JSX.Element | null;
|
|
40
|
-
export declare const FieldSetRootInner: import('react').ForwardRefExoticComponent<Omit<FieldSetProps, "size" | "
|
|
40
|
+
export declare const FieldSetRootInner: import('react').ForwardRefExoticComponent<Omit<FieldSetProps, "size" | "children" | "motion" | "motionState" | "motionPayload" | "playInitialState" | "motionController" | "classNames"> & {
|
|
41
41
|
state: UseFieldSetRootStateResult;
|
|
42
42
|
} & import('react').RefAttributes<HTMLFieldSetElement>>;
|
|
@@ -5,7 +5,7 @@ import { mergeForwardedRef } from "../utils/mergeRefs.js";
|
|
|
5
5
|
import { collectTabButtons, focusTabAt } from "./tabsA11y.js";
|
|
6
6
|
import { useTabsListEnter } from "./tabsAnimations.js";
|
|
7
7
|
import { TabsClassNamesProvider, useTabsContext, useTabsClassNames, useOptionalTabsMotionScope } from "./tabsContext.js";
|
|
8
|
-
import { tabsIndicatorClass, tabsListClass } from "./tabsStyles.js";
|
|
8
|
+
import { tabsIndicatorShape, tabsIndicatorClass, tabsListClass } from "./tabsStyles.js";
|
|
9
9
|
import { useSlidingTabIndicator } from "./useSlidingTabIndicator.js";
|
|
10
10
|
import { useMotionPart } from "../utils/slotMotion/useMotionPart.js";
|
|
11
11
|
const TabsList = forwardRef(function TabsList2({ className, classNames, children, onKeyDown, motion, ...rest }, ref) {
|
|
@@ -52,7 +52,7 @@ const TabsListSurface = forwardRef(
|
|
|
52
52
|
indicatorPart.targetRef,
|
|
53
53
|
value,
|
|
54
54
|
orientation,
|
|
55
|
-
variant,
|
|
55
|
+
tabsIndicatorShape(variant),
|
|
56
56
|
tabElementsRef,
|
|
57
57
|
layoutEpoch,
|
|
58
58
|
scope
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TabsOrientation, TabsSize, TabsVariant } from './tabsTypes.js';
|
|
1
|
+
import { TabsOrientation, TabsSize, TabsVariant, KitTabsVariant } from './tabsTypes.js';
|
|
2
2
|
export declare function tabsRootClass({ orientation, slotClass, className, }: {
|
|
3
3
|
orientation: TabsOrientation;
|
|
4
4
|
slotClass?: string;
|
|
@@ -10,6 +10,8 @@ export declare function tabsListClass({ orientation, variant, slotClass, classNa
|
|
|
10
10
|
slotClass?: string;
|
|
11
11
|
className?: string;
|
|
12
12
|
}): string;
|
|
13
|
+
/** Kit base of a skin variant: `useSlidingTabIndicator` measures an underline or a pill by it. */
|
|
14
|
+
export declare function tabsIndicatorShape(variant: TabsVariant): KitTabsVariant;
|
|
13
15
|
export declare function tabsIndicatorClass({ variant, slotClass, }: {
|
|
14
16
|
variant: TabsVariant;
|
|
15
17
|
slotClass?: string;
|
|
@@ -56,6 +56,9 @@ function tabsListClass({
|
|
|
56
56
|
className
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
|
+
function tabsIndicatorShape(variant) {
|
|
60
|
+
return resolveVariantVisual(variant, KIT_TABS_VARIANTS, "tabs.indicator").key;
|
|
61
|
+
}
|
|
59
62
|
function tabsIndicatorClass({
|
|
60
63
|
variant,
|
|
61
64
|
slotClass
|
|
@@ -111,6 +114,7 @@ function tabsPanelClass({
|
|
|
111
114
|
export {
|
|
112
115
|
tabTextVariant,
|
|
113
116
|
tabsIndicatorClass,
|
|
117
|
+
tabsIndicatorShape,
|
|
114
118
|
tabsListClass,
|
|
115
119
|
tabsPanelClass,
|
|
116
120
|
tabsRootClass,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { MotionScopeValue } from '../utils/slotMotion/index.js';
|
|
3
|
-
import {
|
|
4
|
-
export declare function useSlidingTabIndicator(listRef: RefObject<HTMLElement | null>, indicatorRef: RefObject<HTMLElement | null>, activeValue: string | null, orientation: TabsOrientation, variant:
|
|
3
|
+
import { KitTabsVariant, TabsOrientation } from './tabsTypes.js';
|
|
4
|
+
export declare function useSlidingTabIndicator(listRef: RefObject<HTMLElement | null>, indicatorRef: RefObject<HTMLElement | null>, activeValue: string | null, orientation: TabsOrientation, variant: KitTabsVariant, tabElementsRef: RefObject<Map<string, HTMLButtonElement>>, layoutEpoch: number, scope: MotionScopeValue | null): void;
|
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext, useRef, useMemo, useLayoutEffect } from "react";
|
|
4
|
+
import { studioSlotIds, applyStudioSlotMark } from "../../../../studio/studioModeContext.js";
|
|
4
5
|
import { bindStudioController } from "../../../../studio/studioNodes.js";
|
|
5
6
|
import gsap from "gsap";
|
|
6
7
|
import { useMotionConfig } from "../motionConfigContext.js";
|
|
@@ -21,6 +22,7 @@ function createMotionScopeController({
|
|
|
21
22
|
registry = createMotionRegistry()
|
|
22
23
|
}) {
|
|
23
24
|
const hostIds = /* @__PURE__ */ new Map();
|
|
25
|
+
const hostMarks = /* @__PURE__ */ new Map();
|
|
24
26
|
const getSlots = () => splitMotionRootMap(getRootMotion()).slots;
|
|
25
27
|
const getEvents = () => splitMotionRootMap(getRootMotion()).events;
|
|
26
28
|
const getStates = () => splitMotionRootMap(getRootMotion()).states;
|
|
@@ -52,6 +54,8 @@ function createMotionScopeController({
|
|
|
52
54
|
hostIds.set(slot, id);
|
|
53
55
|
}
|
|
54
56
|
register({ id, slot, node });
|
|
57
|
+
const ids = node ? studioSlotIds(scope.debugName, slot, void 0) : [];
|
|
58
|
+
hostMarks.set(slot, applyStudioSlotMark(hostMarks.get(slot) ?? null, node, ids, scope));
|
|
55
59
|
};
|
|
56
60
|
const resolve = (slot, phase, partMotion) => resolveSlotPhase(slot, phase, partMotion, getSlots(), getDefaults());
|
|
57
61
|
const play = (slot, name, options) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRef, useCallback, useLayoutEffect, useMemo } from "react";
|
|
3
3
|
import { shouldSkipInteractiveHoverLift } from "../hoverInteractiveLift.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useSkinSlotCheck, studioSlotIds, applyStudioSlotMark } from "../../../../studio/studioModeContext.js";
|
|
5
5
|
import { mergeForwardedRef } from "../mergeRefs.js";
|
|
6
6
|
import { useLazyRef } from "../useLazyRef.js";
|
|
7
7
|
import { useMotionPointerPhases } from "./useMotionPointerPhases.js";
|
|
@@ -43,7 +43,7 @@ function useMotionPart({
|
|
|
43
43
|
onPointerUp,
|
|
44
44
|
studioSlot
|
|
45
45
|
}) {
|
|
46
|
-
const isLiveSlot =
|
|
46
|
+
const isLiveSlot = useSkinSlotCheck();
|
|
47
47
|
const targetRef = useRef(null);
|
|
48
48
|
const motionRef = useRef(motion);
|
|
49
49
|
motionRef.current = motion;
|
|
@@ -74,7 +74,7 @@ function useMotionPart({
|
|
|
74
74
|
targetRef.current = node;
|
|
75
75
|
syncRegistration(node, motionRef.current);
|
|
76
76
|
if (forwardedRef != null) mergeForwardedRef(forwardedRef, node);
|
|
77
|
-
const ids = node
|
|
77
|
+
const ids = node ? studioSlotIds(scope?.debugName, slot, studioSlot, isLiveSlot) : [];
|
|
78
78
|
studioMarkRef.current = applyStudioSlotMark(studioMarkRef.current, node, ids, scope);
|
|
79
79
|
},
|
|
80
80
|
[forwardedRef, isLiveSlot, scope, slot, studioSlot, syncRegistration]
|
package/dist/internal.js
CHANGED
|
@@ -15,7 +15,7 @@ import { playShadowFade, removeShadowFadeHost, snapShadowFade } from "./componen
|
|
|
15
15
|
import { SHADOW_CSS_VAR, SHADOW_INTERACTION_GEOM, SHADOW_KNOB_CSS_DEFAULTS, SHADOW_LIFT_CSS_VAR, SHADOW_OPACITY_BASE } from "./tokens/shadows.js";
|
|
16
16
|
import { SKIN_FORBIDDEN_TOKENS, isForbiddenSkinToken } from "./skins/skinTypes.js";
|
|
17
17
|
import { applySkinVars, baselineFor, captureBaseline, isPaletteSkinToken, releaseSkinVars, resolveSkinTokens, skinSurfaceStyle } from "./skins/resolveSkinTokens.js";
|
|
18
|
-
import { SKIN_DOCUMENT_SCHEMA, SKIN_EDITOR_EXAMPLE, parseSkinDocument, renderSkinPackage, skinExportName, skinToJson } from "./skins/skinDocument.js";
|
|
18
|
+
import { SKIN_DOCUMENT_SCHEMA, SKIN_EDITOR_EXAMPLE, parseSkinDocument, renderSkinPackage, renderSkinStylesheet, skinExportName, skinToJson } from "./skins/skinDocument.js";
|
|
19
19
|
import { resolveAlertLiveRole } from "./components/core/Alert/alertA11y.js";
|
|
20
20
|
import { resolveAlertStatus, resolveAlertVariant } from "./components/core/Alert/alertAPI.js";
|
|
21
21
|
import { primaryButtonStatusForAlertTone, primaryButtonVariantForAlertTone } from "./components/composite/AlertDialog/alertDialogAPI.js";
|
|
@@ -46,7 +46,6 @@ import { applyBurneThemeConfig, applyCustomThemeTokens, applyTokens, clearCustom
|
|
|
46
46
|
import { applyThemeMode } from "./theme/ThemeProvider.js";
|
|
47
47
|
import { default as default2 } from "gsap";
|
|
48
48
|
import { hasMotionRecipe, isKitMotionRecipe, listMotionRecipes, unregisterMotionRecipe } from "./components/core/utils/slotMotion/motionRecipeRegistry.js";
|
|
49
|
-
import { renderSkinStylesheet } from "./cli/skin-stylesheet.js";
|
|
50
49
|
import { shadowLayerCount } from "./cli/skin-color.js";
|
|
51
50
|
import { useBurneThemeRuntime, useBurneThemeRuntimeOptional } from "./theme/themeRuntimeContext.js";
|
|
52
51
|
export {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { parseCssColor, shadowLayerCount } from '../../cli/skin-color.mjs';
|
|
2
|
-
import { renderSkinStylesheet } from '../../cli/skin-stylesheet.mjs';
|
|
3
2
|
import { SkinDefinition } from './skinTypes.js';
|
|
4
|
-
export { parseCssColor,
|
|
3
|
+
export { parseCssColor, shadowLayerCount };
|
|
5
4
|
export type SkinDocument = Omit<SkinDefinition, "layers">;
|
|
6
5
|
/** `paper` and `soft-paper`. Used as the npm package suffix. */
|
|
7
6
|
export declare const SKIN_NAME_PATTERN: RegExp;
|
|
7
|
+
/**
|
|
8
|
+
* Token blocks, fonts, `@property`, and `rules`. A target rule matches its
|
|
9
|
+
* `.skin-{name}-{slot}` class; a part rule (`card.title`) matches `data-skin-slot`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderSkinStylesheet(skin: SkinDocument): string;
|
|
8
12
|
export type SkinParseResult = {
|
|
9
13
|
ok: true;
|
|
10
14
|
skin: SkinDocument;
|
|
@@ -21,7 +25,10 @@ export declare function skinExportName(name: string): string;
|
|
|
21
25
|
export declare const SKIN_PACKAGE_PEER = "^2.0.0";
|
|
22
26
|
/** Class written for `rules[slot]`. Stable across export. */
|
|
23
27
|
export declare function skinRuleClass(name: string, slot: string): string;
|
|
24
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Copy the generated rule class onto `targets` so the CSS matches a node.
|
|
30
|
+
* Motion-only parts stay out of `targets`: their CSS matches `data-skin-slot`.
|
|
31
|
+
*/
|
|
25
32
|
export declare function bindSkinRuleClasses(skin: SkinDocument): SkinDocument;
|
|
26
33
|
export type SkinPackageFileName = "package.json" | "README.md" | "LICENSE" | "tsconfig.json" | "tsconfig.build.json" | "src/index.ts" | "src/skin.json" | "src/skin.css";
|
|
27
34
|
export type SkinPackageFiles = Record<SkinPackageFileName, string>;
|
|
@@ -2,11 +2,11 @@ import { MOTION_PHASE_NAMES } from "../components/core/utils/slotMotion/slotMoti
|
|
|
2
2
|
import { checkContrastPairs, checkFocusRingContrast } from "../cli/skin-color.js";
|
|
3
3
|
import { parseCssColor, shadowLayerCount } from "../cli/skin-color.js";
|
|
4
4
|
import { skinMotionRecipeError } from "../cli/skin-recipe.js";
|
|
5
|
-
import { renderSkinStylesheet } from "../cli/skin-stylesheet.js";
|
|
5
|
+
import { renderSkinStylesheet as renderSkinStylesheet$1 } from "../cli/skin-stylesheet.js";
|
|
6
6
|
import { isAcceptedSkinSlot, skinSlotIssue } from "./skinSlotRegistry.js";
|
|
7
7
|
import { isForbiddenSkinToken } from "./skinTypes.js";
|
|
8
|
-
import { SKIN_SLOTS } from "./skinSlots.generated.js";
|
|
9
8
|
import { SKIN_TARGET_SLOTS, SKIN_MOTION_SLOTS, SKIN_LAYER_SLOTS } from "./skinLiveSlots.generated.js";
|
|
9
|
+
import { SKIN_SLOTS } from "./skinSlots.generated.js";
|
|
10
10
|
const DOCUMENT_KEYS = /* @__PURE__ */ new Set([
|
|
11
11
|
"name",
|
|
12
12
|
"extends",
|
|
@@ -80,6 +80,10 @@ const SLOTS = new Set(SKIN_SLOTS);
|
|
|
80
80
|
const TARGET_SLOTS = new Set(SKIN_TARGET_SLOTS);
|
|
81
81
|
const MOTION_SLOTS = new Set(SKIN_MOTION_SLOTS);
|
|
82
82
|
const LAYER_SLOTS = new Set(SKIN_LAYER_SLOTS);
|
|
83
|
+
const RULE_SLOTS = /* @__PURE__ */ new Set([...SKIN_TARGET_SLOTS, ...SKIN_MOTION_SLOTS]);
|
|
84
|
+
function renderSkinStylesheet(skin) {
|
|
85
|
+
return renderSkinStylesheet$1(skin, { isTarget: (slot) => isAcceptedSkinSlot(slot, TARGET_SLOTS) });
|
|
86
|
+
}
|
|
83
87
|
function slotError(label, slot, live) {
|
|
84
88
|
const issue = skinSlotIssue(slot, SLOTS, live);
|
|
85
89
|
if (issue === "empty") return `${label} slot is empty`;
|
|
@@ -205,7 +209,7 @@ function readDeclarations(value, label, errors) {
|
|
|
205
209
|
}
|
|
206
210
|
const style = {};
|
|
207
211
|
for (const [key, item] of Object.entries(value)) {
|
|
208
|
-
if (!/^(
|
|
212
|
+
if (!/^(?:--|-(?:webkit|moz)-)?[a-zA-Z_][\w-]*$/.test(key)) errors.push(`${label} property ${key} is not a CSS property`);
|
|
209
213
|
if (typeof item !== "string" || /[{};]/.test(item)) errors.push(`${label}.${key} has an unsafe value`);
|
|
210
214
|
else style[key] = item;
|
|
211
215
|
}
|
|
@@ -245,7 +249,7 @@ function readRules(value, errors) {
|
|
|
245
249
|
}
|
|
246
250
|
const rules = {};
|
|
247
251
|
for (const [slot, spec] of Object.entries(value)) {
|
|
248
|
-
const slotProblem = slotError("rules", slot,
|
|
252
|
+
const slotProblem = slotError("rules", slot, RULE_SLOTS);
|
|
249
253
|
if (slotProblem) errors.push(slotProblem);
|
|
250
254
|
if (!isRecord(spec)) {
|
|
251
255
|
errors.push(`rules.${slot} must be an object`);
|
|
@@ -278,7 +282,7 @@ function readRules(value, errors) {
|
|
|
278
282
|
}
|
|
279
283
|
next[branch] = map;
|
|
280
284
|
}
|
|
281
|
-
if (isAcceptedSkinSlot(slot,
|
|
285
|
+
if (isAcceptedSkinSlot(slot, RULE_SLOTS)) rules[slot] = next;
|
|
282
286
|
}
|
|
283
287
|
return rules;
|
|
284
288
|
}
|
|
@@ -481,6 +485,7 @@ function bindSkinRuleClasses(skin) {
|
|
|
481
485
|
if (!skin.rules || Object.keys(skin.rules).length === 0) return skin;
|
|
482
486
|
const targets = { ...skin.targets };
|
|
483
487
|
for (const slot of Object.keys(skin.rules)) {
|
|
488
|
+
if (!isAcceptedSkinSlot(slot, TARGET_SLOTS)) continue;
|
|
484
489
|
const extra = skinRuleClass(skin.name, slot);
|
|
485
490
|
const current = targets[slot];
|
|
486
491
|
if (current == null) targets[slot] = { extend: extra };
|
|
@@ -659,7 +664,7 @@ const SKIN_DOCUMENT_SCHEMA = {
|
|
|
659
664
|
}
|
|
660
665
|
]
|
|
661
666
|
}),
|
|
662
|
-
rules: slotMapSchema(SKIN_TARGET_SLOTS, { type: "object" }),
|
|
667
|
+
rules: slotMapSchema([...SKIN_TARGET_SLOTS, ...SKIN_MOTION_SLOTS.filter((slot) => !TARGET_SLOTS.has(slot))], { type: "object" }),
|
|
663
668
|
properties: { type: "object", additionalProperties: { type: "object" } },
|
|
664
669
|
fonts: { type: "array", items: { type: "object" } },
|
|
665
670
|
motion: {
|
|
@@ -11,6 +11,12 @@ type AuthorSkinSlot = keyof SkinSlotRegistry & string;
|
|
|
11
11
|
export type SkinTargetSlot = KitSkinTargetSlot | AuthorSkinSlot;
|
|
12
12
|
export type SkinMotionSlot = KitSkinMotionSlot | AuthorSkinSlot;
|
|
13
13
|
export type SkinLayerSlot = KitSkinLayerSlot | AuthorSkinSlot;
|
|
14
|
+
/**
|
|
15
|
+
* `rules` key. A target slot gets the `.skin-{name}-{slot}` class through `targets`.
|
|
16
|
+
* A motion-only part (`card.title`, `button.text`) is matched by its `data-skin-slot`
|
|
17
|
+
* inside a node painted by the skin.
|
|
18
|
+
*/
|
|
19
|
+
export type SkinRuleSlot = SkinTargetSlot | SkinMotionSlot;
|
|
14
20
|
/**
|
|
15
21
|
* Geometry of the focus ring. Color tokens are allowed: the validator requires
|
|
16
22
|
* ≥3:1 against `background` and `surface`. Forced-colors still paints `Highlight`
|
|
@@ -139,10 +145,12 @@ export type SkinDefinition = {
|
|
|
139
145
|
/** Ярус 2 classes. Only slots `resolveVariantVisual` actually reads. */
|
|
140
146
|
targets?: Partial<Record<SkinTargetSlot, SkinTargetSpec>>;
|
|
141
147
|
/**
|
|
142
|
-
* Ярус 2 CSS properties.
|
|
143
|
-
* it to `targets`, so the rule works without Tailwind.
|
|
148
|
+
* Ярус 2 CSS properties. For a target slot export writes a class `.skin-{name}-{slot}`
|
|
149
|
+
* and appends it to `targets`, so the rule works without Tailwind. A motion-only part
|
|
150
|
+
* (`card.title`) is matched by `[data-skin-slot~="card.title"]` under
|
|
151
|
+
* `[data-variant="{name}"]` or `[data-skin="{name}"]`.
|
|
144
152
|
*/
|
|
145
|
-
rules?: Partial<Record<
|
|
153
|
+
rules?: Partial<Record<SkinRuleSlot, SkinSlotRules>>;
|
|
146
154
|
/** `@property` declarations for variables this skin animates. */
|
|
147
155
|
properties?: Record<string, SkinPropertyDefinition>;
|
|
148
156
|
/** Fonts loaded with the skin stylesheet. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SKIN_CONTRAST_PAIRS, parseCssColor, contrastRatio, AA_CONTRAST } from "../cli/skin-color.js";
|
|
2
|
-
import { renderSkinStylesheet } from "../
|
|
3
|
-
import { SKIN_NAME_PATTERN, parseSkinDocument, bindSkinRuleClasses } from "../skins/skinDocument.js";
|
|
2
|
+
import { SKIN_NAME_PATTERN, parseSkinDocument, renderSkinStylesheet, bindSkinRuleClasses } from "../skins/skinDocument.js";
|
|
4
3
|
import { createDefaultThemeState, exportThemeCss, COLOR_CSS_VAR, motionConfigFromThemeState } from "../theme/themeDefaults.js";
|
|
5
4
|
import { THEME_TOKEN_SCHEMA } from "./themeTokenSchema.js";
|
|
6
5
|
const DESIGN_DOCUMENT_VERSION = 1;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SKIN_TARGET_SLOTS, SKIN_LAYER_SLOTS, SKIN_MOTION_SLOTS } from "../skins/skinLiveSlots.generated.js";
|
|
2
|
+
const LIVE_SKIN_SLOTS = /* @__PURE__ */ new Set([...SKIN_TARGET_SLOTS, ...SKIN_LAYER_SLOTS, ...SKIN_MOTION_SLOTS]);
|
|
3
|
+
function isLiveSkinSlot(id) {
|
|
4
|
+
return LIVE_SKIN_SLOTS.has(id);
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
isLiveSkinSlot
|
|
8
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Studio canvas root. Kit parts carry `data-skin-slot` everywhere; inside this
|
|
4
|
+
* provider marks narrow to live skin slots and `useStudioMode()` is true.
|
|
5
|
+
*/
|
|
5
6
|
export declare function StudioModeProvider({ children }: {
|
|
6
7
|
children: ReactNode;
|
|
7
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export declare function isLiveSkinSlot(id: string): boolean;
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { SKIN_TARGET_SLOTS, SKIN_LAYER_SLOTS, SKIN_MOTION_SLOTS } from "../skins/skinLiveSlots.generated.js";
|
|
3
|
+
import { isLiveSkinSlot } from "./liveSkinSlots.js";
|
|
5
4
|
import { StudioSlotProvider } from "./studioModeContext.js";
|
|
6
|
-
import { skinSlotId, useStudioMode } from "./studioModeContext.js";
|
|
7
|
-
const LIVE_SKIN_SLOTS = /* @__PURE__ */ new Set([
|
|
8
|
-
...SKIN_TARGET_SLOTS,
|
|
9
|
-
...SKIN_LAYER_SLOTS,
|
|
10
|
-
...SKIN_MOTION_SLOTS
|
|
11
|
-
]);
|
|
12
5
|
function StudioModeProvider({ children }) {
|
|
13
|
-
|
|
14
|
-
return /* @__PURE__ */ jsx(StudioSlotProvider, { isLive, children });
|
|
15
|
-
}
|
|
16
|
-
function isLiveSkinSlot(id) {
|
|
17
|
-
return LIVE_SKIN_SLOTS.has(id);
|
|
6
|
+
return /* @__PURE__ */ jsx(StudioSlotProvider, { isLive: isLiveSkinSlot, children });
|
|
18
7
|
}
|
|
19
8
|
export {
|
|
20
|
-
StudioModeProvider
|
|
21
|
-
isLiveSkinSlot,
|
|
22
|
-
skinSlotId,
|
|
23
|
-
useStudioMode
|
|
9
|
+
StudioModeProvider
|
|
24
10
|
};
|
|
@@ -6,6 +6,8 @@ export declare function StudioSlotProvider({ isLive, children, }: {
|
|
|
6
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare function useStudioMode(): boolean;
|
|
8
8
|
export declare function useStudioSlotCheck(): StudioSlotCheck | null;
|
|
9
|
+
/** The studio narrows marks to live skin slots. */
|
|
10
|
+
export declare function useSkinSlotCheck(): StudioSlotCheck;
|
|
9
11
|
/** `Button` + `root` → `button.root`, matching the live skin slot list. */
|
|
10
12
|
export declare function skinSlotId(debugName: string, slot: string): string;
|
|
11
13
|
export type StudioSlotMark = {
|
|
@@ -19,10 +21,10 @@ export type StudioSlotMark = {
|
|
|
19
21
|
*/
|
|
20
22
|
export declare function applyStudioSlotMark(previous: StudioSlotMark | null, node: HTMLElement | null, ids: readonly string[], scope: object | null): StudioSlotMark | null;
|
|
21
23
|
/** Motion id plus an extra target id, when both are in the live set. */
|
|
22
|
-
export declare function studioSlotIds(debugName: string | undefined, slot: string, studioSlot: string | undefined, isLive
|
|
24
|
+
export declare function studioSlotIds(debugName: string | undefined, slot: string, studioSlot: string | undefined, isLive?: StudioSlotCheck): string[];
|
|
23
25
|
/**
|
|
24
26
|
* Marks a node whose motion slot id is not the skin target id
|
|
25
|
-
* (`alertDialog.panel`, `disclosure.trigger`, …).
|
|
27
|
+
* (`alertDialog.panel`, `disclosure.trigger`, …).
|
|
26
28
|
* Binding runs in the ref callback, so a swapped node (`asChild`) is marked and the previous one is cleared.
|
|
27
29
|
*/
|
|
28
30
|
export declare function useStudioSlotRef<T extends HTMLElement>(slotId: string, scope?: object | null): (node: T | null) => void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useContext, createContext, useRef, useCallback } from "react";
|
|
4
4
|
import { bindStudioNode, unbindStudioNode } from "./studioNodes.js";
|
|
5
|
+
const anySkinSlot = () => true;
|
|
5
6
|
const StudioModeContext = createContext(null);
|
|
6
7
|
function StudioSlotProvider({
|
|
7
8
|
isLive,
|
|
@@ -12,8 +13,8 @@ function StudioSlotProvider({
|
|
|
12
13
|
function useStudioMode() {
|
|
13
14
|
return useContext(StudioModeContext) !== null;
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
return useContext(StudioModeContext);
|
|
16
|
+
function useSkinSlotCheck() {
|
|
17
|
+
return useContext(StudioModeContext) ?? anySkinSlot;
|
|
17
18
|
}
|
|
18
19
|
function skinSlotId(debugName, slot) {
|
|
19
20
|
return `${debugName.slice(0, 1).toLowerCase()}${debugName.slice(1)}.${slot}`;
|
|
@@ -49,7 +50,7 @@ function applyStudioSlotMark(previous, node, ids, scope) {
|
|
|
49
50
|
if (scope) bindStudioNode(node, scope);
|
|
50
51
|
return { node, ids: [...ids], scope };
|
|
51
52
|
}
|
|
52
|
-
function studioSlotIds(debugName, slot, studioSlot, isLive) {
|
|
53
|
+
function studioSlotIds(debugName, slot, studioSlot, isLive = anySkinSlot) {
|
|
53
54
|
const ids = [];
|
|
54
55
|
if (debugName) {
|
|
55
56
|
const motionId = skinSlotId(debugName, slot);
|
|
@@ -59,10 +60,10 @@ function studioSlotIds(debugName, slot, studioSlot, isLive) {
|
|
|
59
60
|
return ids;
|
|
60
61
|
}
|
|
61
62
|
function useStudioSlotRef(slotId, scope) {
|
|
62
|
-
const isLive =
|
|
63
|
+
const isLive = useSkinSlotCheck();
|
|
63
64
|
const markRef = useRef(null);
|
|
64
65
|
return useCallback((node) => {
|
|
65
|
-
const ids = node && isLive
|
|
66
|
+
const ids = node && isLive(slotId) ? [slotId] : [];
|
|
66
67
|
markRef.current = applyStudioSlotMark(markRef.current, node, ids, scope ?? null);
|
|
67
68
|
}, [isLive, scope, slotId]);
|
|
68
69
|
}
|
|
@@ -71,7 +72,7 @@ export {
|
|
|
71
72
|
applyStudioSlotMark,
|
|
72
73
|
skinSlotId,
|
|
73
74
|
studioSlotIds,
|
|
75
|
+
useSkinSlotCheck,
|
|
74
76
|
useStudioMode,
|
|
75
|
-
useStudioSlotCheck,
|
|
76
77
|
useStudioSlotRef
|
|
77
78
|
};
|
package/dist/studio.d.ts
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { DESIGN_DOCUMENT_SCHEMA, DESIGN_DOCUMENT_VERSION, contrastRatio, designThemeToState, parseCssColor, parseDesignDocument, renderDesignCss, validateDesign, type DesignDocument, type DesignMeta, type DesignParseResult, type DesignTheme, type DesignValidation, } from './studio/designDocument.js';
|
|
9
9
|
export { THEME_TOKEN_SCHEMA, themeTokenSchemaEntry, type ThemeTokenControlType, type ThemeTokenSchemaEntry, } from './studio/themeTokenSchema.js';
|
|
10
|
-
export { isLiveSkinSlot
|
|
11
|
-
export {
|
|
10
|
+
export { isLiveSkinSlot } from './studio/liveSkinSlots.js';
|
|
11
|
+
export { StudioModeProvider } from './studio/studioMode.js';
|
|
12
|
+
export { skinSlotId, useStudioMode, useStudioSlotRef } from './studio/studioModeContext.js';
|
|
12
13
|
export { findMotionController } from './studio/studioNodes.js';
|
|
13
14
|
export { forceStateAttribute, FORCE_STATE_TOKENS, playForceStateMotion, type ForceStateToken, } from './studio/forceState.js';
|
|
14
15
|
export { paletteFromBrand } from './studio/paletteFromBrand.js';
|
package/dist/studio.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DESIGN_DOCUMENT_SCHEMA, DESIGN_DOCUMENT_VERSION, designThemeToState, designToSkin, parseDesignDocument, renderDesignCss, validateDesign } from "./studio/designDocument.js";
|
|
2
2
|
import { THEME_TOKEN_SCHEMA, themeTokenSchemaEntry } from "./studio/themeTokenSchema.js";
|
|
3
|
-
import {
|
|
3
|
+
import { isLiveSkinSlot } from "./studio/liveSkinSlots.js";
|
|
4
|
+
import { StudioModeProvider } from "./studio/studioMode.js";
|
|
4
5
|
import { skinSlotId, useStudioMode, useStudioSlotRef } from "./studio/studioModeContext.js";
|
|
5
6
|
import { findMotionController } from "./studio/studioNodes.js";
|
|
6
7
|
import { FORCE_STATE_TOKENS, forceStateAttribute, playForceStateMotion } from "./studio/forceState.js";
|
|
@@ -13,10 +14,9 @@ import { applyThemeTokens, clearThemeInlineTokens, createDefaultThemeState, expo
|
|
|
13
14
|
import { resolveThemeTokenState, themeTokenStateToConfig } from "./theme/themeConfig.js";
|
|
14
15
|
import { KIT_MOTION_RECIPE_META } from "./components/core/utils/slotMotion/kitMotionRecipeMeta.js";
|
|
15
16
|
import { SKIN_LAYER_SLOTS, SKIN_MOTION_SLOTS, SKIN_TARGET_SLOTS } from "./skins/skinLiveSlots.generated.js";
|
|
16
|
-
import { bindSkinRuleClasses, formatSkinPackage, parseSkinDocument, renderSkinPackage } from "./skins/skinDocument.js";
|
|
17
|
+
import { bindSkinRuleClasses, formatSkinPackage, parseSkinDocument, renderSkinPackage, renderSkinStylesheet } from "./skins/skinDocument.js";
|
|
17
18
|
import { DARK_COLORS, LIGHT_COLORS } from "./theme/themePalettes.js";
|
|
18
19
|
import { contrastRatio, parseCssColor } from "./cli/skin-color.js";
|
|
19
|
-
import { renderSkinStylesheet } from "./cli/skin-stylesheet.js";
|
|
20
20
|
export {
|
|
21
21
|
AMBER_DARK_COLORS,
|
|
22
22
|
AMBER_LIGHT_COLORS,
|