@cognitap/radiant 0.0.5 → 0.0.6
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/CHANGELOG.md +17 -0
- package/README.md +8 -0
- package/dist/library/Button.d.ts +3 -1
- package/dist/library/Button.d.ts.map +1 -1
- package/dist/library/Button.js +43 -2
- package/dist/library/Button.js.map +1 -1
- package/dist/library/Collapsible.d.ts +2 -1
- package/dist/library/Collapsible.d.ts.map +1 -1
- package/dist/library/Collapsible.js +5 -2
- package/dist/library/Collapsible.js.map +1 -1
- package/dist/library/Dialog.d.ts +2 -1
- package/dist/library/Dialog.d.ts.map +1 -1
- package/dist/library/Dialog.js +5 -2
- package/dist/library/Dialog.js.map +1 -1
- package/dist/library/ThemeScope.d.ts.map +1 -1
- package/dist/library/ThemeScope.js +10 -9
- package/dist/library/ThemeScope.js.map +1 -1
- package/dist/library/index.d.ts +3 -1
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js +1 -0
- package/dist/library/index.js.map +1 -1
- package/dist/library/motion/MotionLink.d.ts +7 -0
- package/dist/library/motion/MotionLink.d.ts.map +1 -0
- package/dist/library/motion/MotionLink.js +45 -0
- package/dist/library/motion/MotionLink.js.map +1 -0
- package/dist/library/motion/browser.d.ts +5 -0
- package/dist/library/motion/browser.d.ts.map +1 -0
- package/dist/library/motion/browser.js +35 -0
- package/dist/library/motion/browser.js.map +1 -0
- package/dist/library/motion/config.d.ts +26 -0
- package/dist/library/motion/config.d.ts.map +1 -0
- package/dist/library/motion/config.js +58 -0
- package/dist/library/motion/config.js.map +1 -0
- package/dist/library/motion/context.d.ts +2 -0
- package/dist/library/motion/context.d.ts.map +1 -0
- package/dist/library/motion/context.js +5 -0
- package/dist/library/motion/context.js.map +1 -0
- package/dist/library/motion/drag.d.ts +20 -0
- package/dist/library/motion/drag.d.ts.map +1 -0
- package/dist/library/motion/drag.js +138 -0
- package/dist/library/motion/drag.js.map +1 -0
- package/dist/library/motion/dragBrowser.d.ts +4 -0
- package/dist/library/motion/dragBrowser.d.ts.map +1 -0
- package/dist/library/motion/dragBrowser.js +156 -0
- package/dist/library/motion/dragBrowser.js.map +1 -0
- package/dist/library/motion/follow.d.ts +9 -0
- package/dist/library/motion/follow.d.ts.map +1 -0
- package/dist/library/motion/follow.js +26 -0
- package/dist/library/motion/follow.js.map +1 -0
- package/dist/library/motion/host.d.ts +27 -0
- package/dist/library/motion/host.d.ts.map +1 -0
- package/dist/library/motion/host.js +62 -0
- package/dist/library/motion/host.js.map +1 -0
- package/dist/library/motion/index.d.ts +16 -0
- package/dist/library/motion/index.d.ts.map +1 -0
- package/dist/library/motion/index.js +9 -0
- package/dist/library/motion/index.js.map +1 -0
- package/dist/library/motion/layout.d.ts +20 -0
- package/dist/library/motion/layout.d.ts.map +1 -0
- package/dist/library/motion/layout.js +67 -0
- package/dist/library/motion/layout.js.map +1 -0
- package/dist/library/motion/layoutDom.d.ts +17 -0
- package/dist/library/motion/layoutDom.d.ts.map +1 -0
- package/dist/library/motion/layoutDom.js +272 -0
- package/dist/library/motion/layoutDom.js.map +1 -0
- package/dist/library/motion/press.d.ts +5 -0
- package/dist/library/motion/press.d.ts.map +1 -0
- package/dist/library/motion/press.js +72 -0
- package/dist/library/motion/press.js.map +1 -0
- package/dist/library/motion/pressPolicy.d.ts +5 -0
- package/dist/library/motion/pressPolicy.d.ts.map +1 -0
- package/dist/library/motion/pressPolicy.js +8 -0
- package/dist/library/motion/pressPolicy.js.map +1 -0
- package/dist/library/motion/react.d.ts +35 -0
- package/dist/library/motion/react.d.ts.map +1 -0
- package/dist/library/motion/react.js +224 -0
- package/dist/library/motion/react.js.map +1 -0
- package/dist/library/motion/runtime.d.ts +22 -0
- package/dist/library/motion/runtime.d.ts.map +1 -0
- package/dist/library/motion/runtime.js +117 -0
- package/dist/library/motion/runtime.js.map +1 -0
- package/dist/library/motion/transitions.d.ts +5 -0
- package/dist/library/motion/transitions.d.ts.map +1 -0
- package/dist/library/motion/transitions.js +211 -0
- package/dist/library/motion/transitions.js.map +1 -0
- package/dist/library/styles.css +1 -1
- package/dist/library/themes/defineTheme.d.ts +3 -0
- package/dist/library/themes/defineTheme.d.ts.map +1 -1
- package/dist/library/themes/defineTheme.js +4 -2
- package/dist/library/themes/defineTheme.js.map +1 -1
- package/dist/library/themes/index.d.ts +1 -1
- package/dist/library/themes/index.d.ts.map +1 -1
- package/dist/library/themes/index.js.map +1 -1
- package/dist/library/themes/themeDocument.d.ts.map +1 -1
- package/dist/library/themes/themeDocument.js +11 -5
- package/dist/library/themes/themeDocument.js.map +1 -1
- package/dist/library/themes/themeDocumentTypes.d.ts +5 -1
- package/dist/library/themes/themeDocumentTypes.d.ts.map +1 -1
- package/dist/library/themes/themeDocumentTypes.js.map +1 -1
- package/docs/motion.md +434 -0
- package/docs/system.md +26 -0
- package/package.json +14 -3
- package/src/Button.tsx +49 -1
- package/src/Collapsible.tsx +13 -1
- package/src/Dialog.tsx +10 -1
- package/src/ThemeScope.tsx +21 -17
- package/src/index.ts +9 -0
- package/src/motion/MotionLink.tsx +64 -0
- package/src/motion/browser.ts +45 -0
- package/src/motion/config.ts +79 -0
- package/src/motion/context.ts +4 -0
- package/src/motion/drag.ts +151 -0
- package/src/motion/dragBrowser.ts +159 -0
- package/src/motion/follow.ts +28 -0
- package/src/motion/host.ts +88 -0
- package/src/motion/index.ts +28 -0
- package/src/motion/layout.ts +78 -0
- package/src/motion/layoutDom.ts +293 -0
- package/src/motion/press.ts +77 -0
- package/src/motion/pressPolicy.ts +12 -0
- package/src/motion/react.ts +272 -0
- package/src/motion/runtime.ts +122 -0
- package/src/motion/transitions.ts +206 -0
- package/src/themes/defineTheme.ts +10 -2
- package/src/themes/index.ts +1 -0
- package/src/themes/themeDocument.ts +14 -6
- package/src/themes/themeDocumentTypes.ts +12 -5
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The source owns destinations; the existing spring owns position, momentum and physics. */
|
|
2
|
+
export function bindSpringSource(spring, source) {
|
|
3
|
+
if (source === spring)
|
|
4
|
+
throw new TypeError('A spring cannot follow itself.');
|
|
5
|
+
let active = true;
|
|
6
|
+
const off = source.subscribe(value => {
|
|
7
|
+
if (active)
|
|
8
|
+
spring.to(value);
|
|
9
|
+
});
|
|
10
|
+
try {
|
|
11
|
+
// Read after subscribing so a synchronous subscription cannot leave a stale goal.
|
|
12
|
+
spring.to(source.get());
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
active = false;
|
|
16
|
+
off();
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
if (!active)
|
|
21
|
+
return;
|
|
22
|
+
active = false;
|
|
23
|
+
off();
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=follow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.js","sourceRoot":"","sources":["../../../src/motion/follow.ts"],"names":[],"mappings":"AAOA,6FAA6F;AAC7F,MAAM,UAAU,gBAAgB,CAAC,MAAwB,EAAE,MAAoB;IAC7E,IAAI,MAAM,KAAK,MAAM;QAAE,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAA;IAC5E,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACnC,IAAI,MAAM;YAAE,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IACF,IAAI,CAAC;QACH,kFAAkF;QAClF,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAA;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,KAAK,CAAA;QACd,GAAG,EAAE,CAAA;QACL,MAAM,KAAK,CAAA;IACb,CAAC;IACD,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,MAAM;YAAE,OAAM;QACnB,MAAM,GAAG,KAAK,CAAA;QACd,GAAG,EAAE,CAAA;IACP,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { SpringController } from './runtime.js'\n\n/** Synchronous numeric snapshot with notifications in the same units as the follower. */\nexport interface SpringSource {\n get(): number\n subscribe(listener: (value: number) => void): () => void\n}\n/** The source owns destinations; the existing spring owns position, momentum and physics. */\nexport function bindSpringSource(spring: SpringController, source: SpringSource): () => void {\n if (source === spring) throw new TypeError('A spring cannot follow itself.')\n let active = true\n const off = source.subscribe(value => {\n if (active) spring.to(value)\n })\n try {\n // Read after subscribing so a synchronous subscription cannot leave a stale goal.\n spring.to(source.get())\n } catch (error) {\n active = false\n off()\n throw error\n }\n return () => {\n if (!active) return\n active = false\n off()\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Ref } from 'react';
|
|
2
|
+
import type { MotionProfile } from './config.js';
|
|
3
|
+
export interface MotionHostBinding {
|
|
4
|
+
update(profile: MotionProfile): void;
|
|
5
|
+
press?(event: PointerEvent | KeyboardEvent): void;
|
|
6
|
+
release?(): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface MotionHostRuntime {
|
|
10
|
+
press(node: HTMLElement, profile: MotionProfile): MotionHostBinding;
|
|
11
|
+
disclosure?(node: HTMLElement, profile: MotionProfile): MotionHostBinding;
|
|
12
|
+
dialog?(node: HTMLElement, profile: MotionProfile): MotionHostBinding;
|
|
13
|
+
}
|
|
14
|
+
export declare const MotionHostContext: import("react").Context<MotionHostRuntime | null>;
|
|
15
|
+
/** Engine-free bridge: only the opt-in provider supplies implementation. */
|
|
16
|
+
export declare function usePressHost<Node extends HTMLElement>(ref: Ref<Node> | undefined, disabled: boolean): {
|
|
17
|
+
ref: import("react").RefCallback<Node>;
|
|
18
|
+
active: boolean;
|
|
19
|
+
press(event: PointerEvent | KeyboardEvent): void;
|
|
20
|
+
release(): void;
|
|
21
|
+
};
|
|
22
|
+
/** Shared lifecycle for native presentation adapters; no engine enters the root path. */
|
|
23
|
+
export declare function useTransitionHost<Node extends HTMLElement>(kind: 'disclosure' | 'dialog', ref: Ref<Node> | undefined, disabled: boolean): {
|
|
24
|
+
ref: import("react").RefCallback<Node>;
|
|
25
|
+
active: boolean;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../src/motion/host.ts"],"names":[],"mappings":"AACA,OAAO,EAAgD,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,GAAG,IAAI,CAAA;IACjD,OAAO,CAAC,IAAI,IAAI,CAAA;IAChB,OAAO,IAAI,IAAI,CAAA;CAChB;AACD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAAA;IACnE,UAAU,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAAA;IACzE,MAAM,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAAA;CACtE;AACD,eAAO,MAAM,iBAAiB,mDAAgD,CAAA;AAC9E,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,SAAS,WAAW,EACnD,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,SAAS,EAC1B,QAAQ,EAAE,OAAO;;;iBA2BF,YAAY,GAAG,aAAa;;EAO5C;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,WAAW,EACxD,IAAI,EAAE,YAAY,GAAG,QAAQ,EAC7B,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,SAAS,EAC1B,QAAQ,EAAE,OAAO;;;EA0BlB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext, useEffect, useRef } from 'react';
|
|
3
|
+
import { MotionProfileContext } from './context.js';
|
|
4
|
+
import { useComposedRefs } from '../react/useComposedRefs.js';
|
|
5
|
+
export const MotionHostContext = createContext(null);
|
|
6
|
+
/** Engine-free bridge: only the opt-in provider supplies implementation. */
|
|
7
|
+
export function usePressHost(ref, disabled) {
|
|
8
|
+
const runtime = useContext(MotionHostContext);
|
|
9
|
+
const profile = useContext(MotionProfileContext);
|
|
10
|
+
const node = useRef(null);
|
|
11
|
+
const binding = useRef(null);
|
|
12
|
+
const composed = useComposedRefs(node, ref);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (disabled || !runtime || !node.current || binding.current?.node !== node.current) {
|
|
15
|
+
binding.current?.value.destroy();
|
|
16
|
+
binding.current = null;
|
|
17
|
+
}
|
|
18
|
+
if (!disabled && runtime && node.current) {
|
|
19
|
+
binding.current ??= { node: node.current, value: runtime.press(node.current, profile) };
|
|
20
|
+
binding.current.value.update(profile);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
useEffect(() => () => {
|
|
24
|
+
binding.current?.value.destroy();
|
|
25
|
+
binding.current = null;
|
|
26
|
+
}, []);
|
|
27
|
+
return {
|
|
28
|
+
ref: composed,
|
|
29
|
+
active: runtime !== null && !disabled,
|
|
30
|
+
press(event) {
|
|
31
|
+
binding.current?.value.press?.(event);
|
|
32
|
+
},
|
|
33
|
+
release() {
|
|
34
|
+
binding.current?.value.release?.();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Shared lifecycle for native presentation adapters; no engine enters the root path. */
|
|
39
|
+
export function useTransitionHost(kind, ref, disabled) {
|
|
40
|
+
const runtime = useContext(MotionHostContext);
|
|
41
|
+
const profile = useContext(MotionProfileContext);
|
|
42
|
+
const node = useRef(null);
|
|
43
|
+
const binding = useRef(null);
|
|
44
|
+
const composed = useComposedRefs(node, ref);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const attach = runtime?.[kind];
|
|
47
|
+
if (disabled || !attach || !node.current || binding.current?.node !== node.current) {
|
|
48
|
+
binding.current?.value.destroy();
|
|
49
|
+
binding.current = null;
|
|
50
|
+
}
|
|
51
|
+
if (!disabled && attach && node.current) {
|
|
52
|
+
binding.current ??= { node: node.current, value: attach(node.current, profile) };
|
|
53
|
+
binding.current.value.update(profile);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
useEffect(() => () => {
|
|
57
|
+
binding.current?.value.destroy();
|
|
58
|
+
binding.current = null;
|
|
59
|
+
}, []);
|
|
60
|
+
return { ref: composed, active: !disabled && runtime?.[kind] !== undefined };
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../src/motion/host.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAY,MAAM,OAAO,CAAA;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAa7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAA2B,IAAI,CAAC,CAAA;AAC9E,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAC1B,GAA0B,EAC1B,QAAiB;IAEjB,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC7C,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAA;IAChD,MAAM,IAAI,GAAG,MAAM,CAAO,IAAI,CAA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ACH,CAAA;IACD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAA;AAC9E,CAAC","sourcesContent":["'use client'\nimport { createContext, useContext, useEffect, useRef, type Ref } from 'react'\nimport type { MotionProfile } from './config.js'\nimport { MotionProfileContext } from './context.js'\nimport { useComposedRefs } from '../react/useComposedRefs.js'\n\nexport interface MotionHostBinding {\n update(profile: MotionProfile): void\n press?(event: PointerEvent | KeyboardEvent): void\n release?(): void\n destroy(): void\n}\nexport interface MotionHostRuntime {\n press(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n disclosure?(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n dialog?(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n}\nexport const MotionHostContext = createContext<MotionHostRuntime | null>(null)\n/** Engine-free bridge: only the opt-in provider supplies implementation. */\nexport function usePressHost<Node extends HTMLElement>(\n ref: Ref<Node> | undefined,\n disabled: boolean\n) {\n const runtime = useContext(MotionHostContext)\n const profile = useContext(MotionProfileContext)\n const node = useRef<Node>(null)\n const binding = useRef<{ node: HTMLElement; value: MotionHostBinding } | null>(null)\n const composed = useComposedRefs(node, ref)\n useEffect(() => {\n if (disabled || !runtime || !node.current || binding.current?.node !== node.current) {\n binding.current?.value.destroy()\n binding.current = null\n }\n if (!disabled && runtime && node.current) {\n binding.current ??= { node: node.current, value: runtime.press(node.current, profile) }\n binding.current.value.update(profile)\n }\n })\n useEffect(\n () => () => {\n binding.current?.value.destroy()\n binding.current = null\n },\n []\n )\n return {\n ref: composed,\n active: runtime !== null && !disabled,\n press(event: PointerEvent | KeyboardEvent) {\n binding.current?.value.press?.(event)\n },\n release() {\n binding.current?.value.release?.()\n }\n }\n}\n\n/** Shared lifecycle for native presentation adapters; no engine enters the root path. */\nexport function useTransitionHost<Node extends HTMLElement>(\n kind: 'disclosure' | 'dialog',\n ref: Ref<Node> | undefined,\n disabled: boolean\n) {\n const runtime = useContext(MotionHostContext)\n const profile = useContext(MotionProfileContext)\n const node = useRef<Node>(null)\n const binding = useRef<{ node: Node; value: MotionHostBinding } | null>(null)\n const composed = useComposedRefs(node, ref)\n useEffect(() => {\n const attach = runtime?.[kind]\n if (disabled || !attach || !node.current || binding.current?.node !== node.current) {\n binding.current?.value.destroy()\n binding.current = null\n }\n if (!disabled && attach && node.current) {\n binding.current ??= { node: node.current, value: attach(node.current, profile) }\n binding.current.value.update(profile)\n }\n })\n useEffect(\n () => () => {\n binding.current?.value.destroy()\n binding.current = null\n },\n []\n )\n return { ref: composed, active: !disabled && runtime?.[kind] !== undefined }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { defineMotionProfile, defaultMotionProfile, motionInteractions, resolveMotion, resolveSpringParameters } from './config.js';
|
|
2
|
+
export type { MotionProfile, MotionProfileInput, MotionInteraction, SpringParameters } from './config.js';
|
|
3
|
+
export { createSpring } from './runtime.js';
|
|
4
|
+
export type { SpringController, SpringOptions } from './runtime.js';
|
|
5
|
+
export { bindSpringStyle } from './browser.js';
|
|
6
|
+
export type { SpringStyleProperty } from './browser.js';
|
|
7
|
+
export { createLayoutSpring } from './layout.js';
|
|
8
|
+
export type { LayoutBounds } from './layout.js';
|
|
9
|
+
export { createSpringDrag } from './drag.js';
|
|
10
|
+
export type { SpringDragOptions, SpringDragController } from './drag.js';
|
|
11
|
+
export { bindSpringDrag } from './dragBrowser.js';
|
|
12
|
+
export { bindSpringSource } from './follow.js';
|
|
13
|
+
export type { SpringSource } from './follow.js';
|
|
14
|
+
export { bindSpringLayout } from './layoutDom.js';
|
|
15
|
+
export type { SpringLayoutController } from './layoutDom.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/motion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACxB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { defineMotionProfile, defaultMotionProfile, motionInteractions, resolveMotion, resolveSpringParameters } from './config.js';
|
|
2
|
+
export { createSpring } from './runtime.js';
|
|
3
|
+
export { bindSpringStyle } from './browser.js';
|
|
4
|
+
export { createLayoutSpring } from './layout.js';
|
|
5
|
+
export { createSpringDrag } from './drag.js';
|
|
6
|
+
export { bindSpringDrag } from './dragBrowser.js';
|
|
7
|
+
export { bindSpringSource } from './follow.js';
|
|
8
|
+
export { bindSpringLayout } from './layoutDom.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/motion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACxB,MAAM,aAAa,CAAA;AAOpB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA","sourcesContent":["export {\n defineMotionProfile,\n defaultMotionProfile,\n motionInteractions,\n resolveMotion,\n resolveSpringParameters\n} from './config.js'\nexport type {\n MotionProfile,\n MotionProfileInput,\n MotionInteraction,\n SpringParameters\n} from './config.js'\nexport { createSpring } from './runtime.js'\nexport type { SpringController, SpringOptions } from './runtime.js'\nexport { bindSpringStyle } from './browser.js'\nexport type { SpringStyleProperty } from './browser.js'\nexport { createLayoutSpring } from './layout.js'\nexport type { LayoutBounds } from './layout.js'\nexport { createSpringDrag } from './drag.js'\nexport type { SpringDragOptions, SpringDragController } from './drag.js'\nexport { bindSpringDrag } from './dragBrowser.js'\n\nexport { bindSpringSource } from './follow.js'\nexport type { SpringSource } from './follow.js'\n\nexport { bindSpringLayout } from './layoutDom.js'\nexport type { SpringLayoutController } from './layoutDom.js'\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type SpringOptions } from './runtime.js';
|
|
2
|
+
export interface LayoutBounds {
|
|
3
|
+
readonly x: number;
|
|
4
|
+
readonly y: number;
|
|
5
|
+
readonly width: number;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
}
|
|
8
|
+
/** Measured local-pixel foundation; measurement and host projection belong to the layout adapter. */
|
|
9
|
+
export declare function createLayoutSpring(initial: LayoutBounds, options?: SpringOptions): {
|
|
10
|
+
get: () => LayoutBounds;
|
|
11
|
+
getVelocity: () => LayoutBounds;
|
|
12
|
+
isAnimating: () => boolean;
|
|
13
|
+
to(next: LayoutBounds): void;
|
|
14
|
+
jump(next: LayoutBounds): void;
|
|
15
|
+
configure(next: SpringOptions): void;
|
|
16
|
+
subscribe(listener: (bounds: LayoutBounds) => void): () => void;
|
|
17
|
+
stop(): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/motion/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAA;AAE/D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAaD,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,GAAE,aAAkB;eAWxE,YAAY;uBAMJ,YAAY;;aAOpB,YAAY;eAIV,YAAY;oBAIP,aAAa;wBAMT,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;;;EAkBrD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createSpring } from './runtime.js';
|
|
2
|
+
const axes = ['x', 'y', 'width', 'height'];
|
|
3
|
+
function validate(bounds) {
|
|
4
|
+
for (const axis of axes) {
|
|
5
|
+
if (!Number.isFinite(bounds[axis]) ||
|
|
6
|
+
((axis === 'width' || axis === 'height') && bounds[axis] < 0))
|
|
7
|
+
throw new TypeError('Layout bounds require finite local pixel coordinates and nonnegative dimensions.');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Measured local-pixel foundation; measurement and host projection belong to the layout adapter. */
|
|
11
|
+
export function createLayoutSpring(initial, options = {}) {
|
|
12
|
+
validate(initial);
|
|
13
|
+
if (options.reducedValue !== undefined)
|
|
14
|
+
throw new TypeError('Layout off mode snaps to measured bounds; reducedValue is scalar only.');
|
|
15
|
+
const values = {
|
|
16
|
+
x: createSpring(initial.x, options),
|
|
17
|
+
y: createSpring(initial.y, options),
|
|
18
|
+
width: createSpring(initial.width, options),
|
|
19
|
+
height: createSpring(initial.height, options)
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
get: () => ({
|
|
23
|
+
x: values.x.get(),
|
|
24
|
+
y: values.y.get(),
|
|
25
|
+
width: values.width.get(),
|
|
26
|
+
height: values.height.get()
|
|
27
|
+
}),
|
|
28
|
+
getVelocity: () => ({
|
|
29
|
+
x: values.x.getVelocity(),
|
|
30
|
+
y: values.y.getVelocity(),
|
|
31
|
+
width: values.width.getVelocity(),
|
|
32
|
+
height: values.height.getVelocity()
|
|
33
|
+
}),
|
|
34
|
+
isAnimating: () => axes.some(axis => values[axis].isAnimating()),
|
|
35
|
+
to(next) {
|
|
36
|
+
validate(next);
|
|
37
|
+
axes.forEach(axis => values[axis].to(next[axis]));
|
|
38
|
+
},
|
|
39
|
+
jump(next) {
|
|
40
|
+
validate(next);
|
|
41
|
+
axes.forEach(axis => values[axis].jump(next[axis]));
|
|
42
|
+
},
|
|
43
|
+
configure(next) {
|
|
44
|
+
if (next.reducedValue !== undefined)
|
|
45
|
+
throw new TypeError('Layout off mode snaps to measured bounds.');
|
|
46
|
+
// Validate all options before changing any axis.
|
|
47
|
+
axes.forEach(axis => values[axis].configure(next));
|
|
48
|
+
},
|
|
49
|
+
subscribe(listener) {
|
|
50
|
+
const snapshot = () => listener({
|
|
51
|
+
x: values.x.get(),
|
|
52
|
+
y: values.y.get(),
|
|
53
|
+
width: values.width.get(),
|
|
54
|
+
height: values.height.get()
|
|
55
|
+
});
|
|
56
|
+
const off = axes.map(axis => values[axis].subscribe(snapshot));
|
|
57
|
+
return () => off.forEach(remove => remove());
|
|
58
|
+
},
|
|
59
|
+
stop() {
|
|
60
|
+
axes.forEach(axis => values[axis].stop());
|
|
61
|
+
},
|
|
62
|
+
destroy() {
|
|
63
|
+
axes.forEach(axis => values[axis].destroy());
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/motion/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAA;AAQ/D,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAA;AACnD,SAAS,QAAQ,CAAC,MAAoB;IACpC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC9B,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE7D,MAAM,IAAI,SAAS,CACjB,kFAAkF,CACnF,CAAA;IACL,CAAC;AACH,CAAC;AACD,qGAAqG;AACrG,MAAM,UAAU,kBAAkB,CAAC,OAAqB,EAAE,UAAyB,EAAE;IACnF,QAAQ,CAAC,OAAO,CAAC,CAAA;IACjB,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;QACpC,MAAM,IAAI,SAAS,CAAC,wEAAwE,CAAC,CAAA;IAC/F,MAAM,MAAM,GAAG;QACb,CAAC,EAAE,Y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,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { createSpring, type SpringOptions } from './runtime.js'\n\nexport interface LayoutBounds {\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n}\nconst axes = ['x', 'y', 'width', 'height'] as const\nfunction validate(bounds: LayoutBounds) {\n for (const axis of axes) {\n if (\n !Number.isFinite(bounds[axis]) ||\n ((axis === 'width' || axis === 'height') && bounds[axis] < 0)\n )\n throw new TypeError(\n 'Layout bounds require finite local pixel coordinates and nonnegative dimensions.'\n )\n }\n}\n/** Measured local-pixel foundation; measurement and host projection belong to the layout adapter. */\nexport function createLayoutSpring(initial: LayoutBounds, options: SpringOptions = {}) {\n validate(initial)\n if (options.reducedValue !== undefined)\n throw new TypeError('Layout off mode snaps to measured bounds; reducedValue is scalar only.')\n const values = {\n x: createSpring(initial.x, options),\n y: createSpring(initial.y, options),\n width: createSpring(initial.width, options),\n height: createSpring(initial.height, options)\n }\n return {\n get: (): LayoutBounds => ({\n x: values.x.get(),\n y: values.y.get(),\n width: values.width.get(),\n height: values.height.get()\n }),\n getVelocity: (): LayoutBounds => ({\n x: values.x.getVelocity(),\n y: values.y.getVelocity(),\n width: values.width.getVelocity(),\n height: values.height.getVelocity()\n }),\n isAnimating: () => axes.some(axis => values[axis].isAnimating()),\n to(next: LayoutBounds) {\n validate(next)\n axes.forEach(axis => values[axis].to(next[axis]))\n },\n jump(next: LayoutBounds) {\n validate(next)\n axes.forEach(axis => values[axis].jump(next[axis]))\n },\n configure(next: SpringOptions) {\n if (next.reducedValue !== undefined)\n throw new TypeError('Layout off mode snaps to measured bounds.')\n // Validate all options before changing any axis.\n axes.forEach(axis => values[axis].configure(next))\n },\n subscribe(listener: (bounds: LayoutBounds) => void) {\n const snapshot = () =>\n listener({\n x: values.x.get(),\n y: values.y.get(),\n width: values.width.get(),\n height: values.height.get()\n })\n const off = axes.map(axis => values[axis].subscribe(snapshot))\n return () => off.forEach(remove => remove())\n },\n stop() {\n axes.forEach(axis => values[axis].stop())\n },\n destroy() {\n axes.forEach(axis => values[axis].destroy())\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type LayoutBounds } from './layout.js';
|
|
2
|
+
import type { SpringOptions } from './runtime.js';
|
|
3
|
+
export interface SpringLayoutController {
|
|
4
|
+
/** Measure all natural-flow slots together and retarget their persistent springs. */
|
|
5
|
+
measure(): void;
|
|
6
|
+
configure(options: SpringOptions): void;
|
|
7
|
+
get(slot: HTMLElement): LayoutBounds | undefined;
|
|
8
|
+
getVelocity(slot: HTMLElement): LayoutBounds | undefined;
|
|
9
|
+
isAnimating(): boolean;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Direct-child natural-flow slots with one dedicated motion part each.
|
|
14
|
+
* Never clone/reparent a semantic host or scale text, borders or children.
|
|
15
|
+
*/
|
|
16
|
+
export declare function bindSpringLayout(root: HTMLElement, options?: SpringOptions): SpringLayoutController;
|
|
17
|
+
//# sourceMappingURL=layoutDom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutDom.d.ts","sourceRoot":"","sources":["../../../src/motion/layoutDom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,OAAO,IAAI,IAAI,CAAA;IACf,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;IACvC,GAAG,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;IAChD,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;IACxD,WAAW,IAAI,OAAO,CAAA;IACtB,OAAO,IAAI,IAAI,CAAA;CAChB;AAiCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE,aAAkB,GAC1B,sBAAsB,CAgPxB"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { createLayoutSpring } from './layout.js';
|
|
2
|
+
import { resolveSpringParameters } from './config.js';
|
|
3
|
+
/** Inline property lease. Capture the latest author value on each projection. */
|
|
4
|
+
function styles(node) {
|
|
5
|
+
const previous = new Map();
|
|
6
|
+
const written = new Map();
|
|
7
|
+
return {
|
|
8
|
+
set(key, value) {
|
|
9
|
+
if (!written.has(key))
|
|
10
|
+
previous.set(key, {
|
|
11
|
+
value: node.style.getPropertyValue(key),
|
|
12
|
+
priority: node.style.getPropertyPriority(key)
|
|
13
|
+
});
|
|
14
|
+
node.style.setProperty(key, value);
|
|
15
|
+
written.set(key, node.style.getPropertyValue(key));
|
|
16
|
+
},
|
|
17
|
+
restore() {
|
|
18
|
+
for (const [key, value] of written) {
|
|
19
|
+
if (node.style.getPropertyValue(key) !== value)
|
|
20
|
+
continue;
|
|
21
|
+
const saved = previous.get(key);
|
|
22
|
+
if (saved.value)
|
|
23
|
+
node.style.setProperty(key, saved.value, saved.priority);
|
|
24
|
+
else
|
|
25
|
+
node.style.removeProperty(key);
|
|
26
|
+
}
|
|
27
|
+
written.clear();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Direct-child natural-flow slots with one dedicated motion part each.
|
|
33
|
+
* Never clone/reparent a semantic host or scale text, borders or children.
|
|
34
|
+
*/
|
|
35
|
+
export function bindSpringLayout(root, options = {}) {
|
|
36
|
+
if (options.reducedValue !== undefined)
|
|
37
|
+
throw new TypeError('Layout off mode snaps to measured bounds.');
|
|
38
|
+
const win = root.ownerDocument.defaultView;
|
|
39
|
+
const entries = new Map();
|
|
40
|
+
let currentOptions = { ...options, parameters: resolveSpringParameters(options.parameters) };
|
|
41
|
+
let frame;
|
|
42
|
+
let needsMeasure = false;
|
|
43
|
+
let destroyed = false;
|
|
44
|
+
const resize = new win.ResizeObserver(schedule);
|
|
45
|
+
function contentChanged(records) {
|
|
46
|
+
if (records.some(record => {
|
|
47
|
+
// These style mutations are our own projection writes. Other content/style
|
|
48
|
+
// mutations can change natural layout and must be measured as a group.
|
|
49
|
+
if (record.type === 'attributes' && record.attributeName === 'style') {
|
|
50
|
+
if (entries.has(record.target))
|
|
51
|
+
return false;
|
|
52
|
+
if (Array.from(entries.values()).some(entry => entry.part === record.target))
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}))
|
|
57
|
+
schedule();
|
|
58
|
+
}
|
|
59
|
+
const mutations = new win.MutationObserver(contentChanged);
|
|
60
|
+
function restore(entry) {
|
|
61
|
+
entry.partStyle.restore();
|
|
62
|
+
entry.slotStyle.restore();
|
|
63
|
+
}
|
|
64
|
+
function dispose(slot, entry) {
|
|
65
|
+
restore(entry);
|
|
66
|
+
entry.spring.destroy();
|
|
67
|
+
resize.unobserve(slot);
|
|
68
|
+
entries.delete(slot);
|
|
69
|
+
}
|
|
70
|
+
function draw() {
|
|
71
|
+
// Preserve external mutations queued by an earlier frame callback before
|
|
72
|
+
// discarding the records generated by our own presentation writes.
|
|
73
|
+
contentChanged(mutations.takeRecords());
|
|
74
|
+
for (const entry of entries.values()) {
|
|
75
|
+
const bounds = entry.spring.get();
|
|
76
|
+
entry.partStyle.set('width', `${Math.max(0, bounds.width)}px`);
|
|
77
|
+
entry.partStyle.set('height', `${Math.max(0, bounds.height)}px`);
|
|
78
|
+
entry.partStyle.set('translate', `${bounds.x - entry.target.x}px ${bounds.y - entry.target.y}px`);
|
|
79
|
+
}
|
|
80
|
+
mutations.takeRecords();
|
|
81
|
+
}
|
|
82
|
+
function project(slot, entry) {
|
|
83
|
+
entry.slotStyle.set('position', 'relative');
|
|
84
|
+
entry.slotStyle.set('box-sizing', 'border-box');
|
|
85
|
+
entry.slotStyle.set('flex', 'none');
|
|
86
|
+
entry.slotStyle.set('width', `${entry.target.width}px`);
|
|
87
|
+
entry.slotStyle.set('height', `${entry.target.height}px`);
|
|
88
|
+
entry.partStyle.set('position', 'absolute');
|
|
89
|
+
entry.partStyle.set('left', '0px');
|
|
90
|
+
entry.partStyle.set('top', '0px');
|
|
91
|
+
entry.partStyle.set('box-sizing', 'border-box');
|
|
92
|
+
}
|
|
93
|
+
function measure() {
|
|
94
|
+
if (destroyed)
|
|
95
|
+
return;
|
|
96
|
+
needsMeasure = false;
|
|
97
|
+
for (let ancestor = root; ancestor; ancestor = ancestor.parentElement) {
|
|
98
|
+
const css = win.getComputedStyle(ancestor);
|
|
99
|
+
const matrix = css.transform === 'none' ? undefined : new win.DOMMatrixReadOnly(css.transform);
|
|
100
|
+
if ((matrix &&
|
|
101
|
+
(!matrix.is2D || matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1)) ||
|
|
102
|
+
(css.scale !== 'none' && css.scale.split(' ').some(value => Number(value) !== 1)) ||
|
|
103
|
+
(css.rotate !== 'none' && parseFloat(css.rotate) !== 0) ||
|
|
104
|
+
(css.zoom && Number(css.zoom) !== 1) ||
|
|
105
|
+
css.perspective !== 'none')
|
|
106
|
+
throw new TypeError('Layout measurement requires an unscaled, unrotated coordinate space.');
|
|
107
|
+
}
|
|
108
|
+
// Release every reservation before any geometry read. Measuring one item
|
|
109
|
+
// while its siblings are projected would feed animation back into layout.
|
|
110
|
+
entries.forEach(restore);
|
|
111
|
+
const slots = Array.from(root.children).filter((node) => node instanceof win.HTMLElement && node.hasAttribute('data-rad-layout-slot'));
|
|
112
|
+
for (const [slot, entry] of entries) {
|
|
113
|
+
if (!slots.includes(slot) || slot.firstElementChild !== entry.part)
|
|
114
|
+
dispose(slot, entry);
|
|
115
|
+
}
|
|
116
|
+
const origin = root.getBoundingClientRect();
|
|
117
|
+
const targets = slots.map(slot => {
|
|
118
|
+
const part = slot.firstElementChild;
|
|
119
|
+
if (slot.children.length !== 1 ||
|
|
120
|
+
!(part instanceof win.HTMLElement) ||
|
|
121
|
+
!part.hasAttribute('data-rad-layout-part'))
|
|
122
|
+
throw new TypeError('Each layout slot requires a first-child data-rad-layout-part.');
|
|
123
|
+
const css = win.getComputedStyle(slot);
|
|
124
|
+
if (!['static', 'relative'].includes(css.position) ||
|
|
125
|
+
['inline', 'contents'].includes(css.display) ||
|
|
126
|
+
[
|
|
127
|
+
'borderLeftWidth',
|
|
128
|
+
'borderTopWidth',
|
|
129
|
+
'borderRightWidth',
|
|
130
|
+
'borderBottomWidth',
|
|
131
|
+
'paddingLeft',
|
|
132
|
+
'paddingTop',
|
|
133
|
+
'paddingRight',
|
|
134
|
+
'paddingBottom'
|
|
135
|
+
].some(key => parseFloat(css[key]) > 0))
|
|
136
|
+
throw new TypeError('Layout slots must be unpadded, borderless normal-flow wrappers.');
|
|
137
|
+
const partCss = win.getComputedStyle(part);
|
|
138
|
+
if (!['static', 'relative'].includes(partCss.position) ||
|
|
139
|
+
[css, partCss].some(style => style.transform !== 'none' ||
|
|
140
|
+
style.translate !== 'none' ||
|
|
141
|
+
style.scale !== 'none' ||
|
|
142
|
+
style.rotate !== 'none') ||
|
|
143
|
+
['marginLeft', 'marginTop', 'marginRight', 'marginBottom'].some(key => parseFloat(partCss[key]) !== 0))
|
|
144
|
+
throw new TypeError('Use dedicated transform-free layout slots and motion parts with no part margins.');
|
|
145
|
+
const rect = slot.getBoundingClientRect();
|
|
146
|
+
return {
|
|
147
|
+
slot,
|
|
148
|
+
part,
|
|
149
|
+
bounds: {
|
|
150
|
+
x: rect.left - origin.left - root.clientLeft + root.scrollLeft,
|
|
151
|
+
y: rect.top - origin.top - root.clientTop + root.scrollTop,
|
|
152
|
+
width: rect.width,
|
|
153
|
+
height: rect.height
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
for (const { slot, part, bounds } of targets) {
|
|
158
|
+
let entry = entries.get(slot);
|
|
159
|
+
if (!entry) {
|
|
160
|
+
entry = {
|
|
161
|
+
part,
|
|
162
|
+
slotStyle: styles(slot),
|
|
163
|
+
partStyle: styles(part),
|
|
164
|
+
spring: createLayoutSpring(bounds, currentOptions),
|
|
165
|
+
target: bounds
|
|
166
|
+
};
|
|
167
|
+
entries.set(slot, entry);
|
|
168
|
+
resize.observe(slot);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
entry.target = bounds;
|
|
172
|
+
entry.spring.to(bounds);
|
|
173
|
+
}
|
|
174
|
+
project(slot, entry);
|
|
175
|
+
}
|
|
176
|
+
mutations.takeRecords();
|
|
177
|
+
draw();
|
|
178
|
+
if (controller.isAnimating())
|
|
179
|
+
requestFrame();
|
|
180
|
+
else
|
|
181
|
+
entries.forEach(restore);
|
|
182
|
+
mutations.takeRecords();
|
|
183
|
+
}
|
|
184
|
+
function tick() {
|
|
185
|
+
frame = undefined;
|
|
186
|
+
if (destroyed)
|
|
187
|
+
return;
|
|
188
|
+
if (needsMeasure)
|
|
189
|
+
measure();
|
|
190
|
+
else
|
|
191
|
+
draw();
|
|
192
|
+
if (controller.isAnimating())
|
|
193
|
+
requestFrame();
|
|
194
|
+
else {
|
|
195
|
+
entries.forEach(restore);
|
|
196
|
+
mutations.takeRecords();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function requestFrame() {
|
|
200
|
+
if (frame === undefined)
|
|
201
|
+
frame = win.requestAnimationFrame(tick);
|
|
202
|
+
}
|
|
203
|
+
function schedule() {
|
|
204
|
+
if (destroyed)
|
|
205
|
+
return;
|
|
206
|
+
needsMeasure = true;
|
|
207
|
+
requestFrame();
|
|
208
|
+
}
|
|
209
|
+
const controller = {
|
|
210
|
+
measure,
|
|
211
|
+
configure(next) {
|
|
212
|
+
if (destroyed)
|
|
213
|
+
return;
|
|
214
|
+
if (next.reducedValue !== undefined)
|
|
215
|
+
throw new TypeError('Layout off mode snaps to measured bounds.');
|
|
216
|
+
// Validate before changing any entry or remembering options for new slots.
|
|
217
|
+
currentOptions = {
|
|
218
|
+
...currentOptions,
|
|
219
|
+
...next,
|
|
220
|
+
parameters: resolveSpringParameters(next.parameters, currentOptions.parameters)
|
|
221
|
+
};
|
|
222
|
+
entries.forEach(entry => entry.spring.configure(next));
|
|
223
|
+
if (controller.isAnimating()) {
|
|
224
|
+
draw();
|
|
225
|
+
requestFrame();
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
entries.forEach(restore);
|
|
229
|
+
mutations.takeRecords();
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
get: slot => entries.get(slot)?.spring.get(),
|
|
233
|
+
getVelocity: slot => entries.get(slot)?.spring.getVelocity(),
|
|
234
|
+
isAnimating: () => Array.from(entries.values()).some(entry => entry.spring.isAnimating()),
|
|
235
|
+
destroy() {
|
|
236
|
+
if (destroyed)
|
|
237
|
+
return;
|
|
238
|
+
destroyed = true;
|
|
239
|
+
if (frame !== undefined)
|
|
240
|
+
win.cancelAnimationFrame(frame);
|
|
241
|
+
mutations.disconnect();
|
|
242
|
+
resize.disconnect();
|
|
243
|
+
root.removeEventListener('load', schedule, true);
|
|
244
|
+
root.removeEventListener('scroll', schedule, true);
|
|
245
|
+
win.removeEventListener('resize', schedule);
|
|
246
|
+
root.ownerDocument.fonts?.removeEventListener('loadingdone', schedule);
|
|
247
|
+
for (const [slot, entry] of entries)
|
|
248
|
+
dispose(slot, entry);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
try {
|
|
252
|
+
measure();
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
controller.destroy();
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
resize.observe(root);
|
|
259
|
+
mutations.observe(root, {
|
|
260
|
+
subtree: true,
|
|
261
|
+
childList: true,
|
|
262
|
+
characterData: true,
|
|
263
|
+
attributes: true,
|
|
264
|
+
attributeFilter: ['class', 'style', 'hidden', 'open']
|
|
265
|
+
});
|
|
266
|
+
root.addEventListener('load', schedule, true);
|
|
267
|
+
root.addEventListener('scroll', schedule, true);
|
|
268
|
+
win.addEventListener('resize', schedule);
|
|
269
|
+
root.ownerDocument.fonts?.addEventListener('loadingdone', schedule);
|
|
270
|
+
return controller;
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=layoutDom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutDom.js","sourceRoot":"","sources":["../../../src/motion/layoutDom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAYrD,iFAAiF;AACjF,SAAS,MAAM,CAAC,IAAiB;IAC/B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+C,CAAA;IACvE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAA;IACzC,OAAO;QACL,GAAG,CAAC,GAAW,EAAE,KAAa;YAC5B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;gBACnB,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE;oBAChB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC;oBACvC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC;iBAC9C,CAAC,CAAA;YACJ,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YAClC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAA;QACpD,CAAC;QACD,OAAO;YACL,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;gBACnC,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,KAAK;oBAAE,SAAQ;gBACxD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG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SpringParameters } from './config.js'\nimport type { SpringOptions } from './runtime.js'\n\nexport interface SpringLayoutController {\n /** Measure all natural-flow slots together and retarget their persistent springs. */\n measure(): void\n configure(options: SpringOptions): void\n get(slot: HTMLElement): LayoutBounds | undefined\n getVelocity(slot: HTMLElement): LayoutBounds | undefined\n isAnimating(): boolean\n destroy(): void\n}\n/** Inline property lease. Capture the latest author value on each projection. */\nfunction styles(node: HTMLElement) {\n const previous = new Map<string, { value: string; priority: string }>()\n const written = new Map<string, string>()\n return {\n set(key: string, value: string) {\n if (!written.has(key))\n previous.set(key, {\n value: node.style.getPropertyValue(key),\n priority: node.style.getPropertyPriority(key)\n })\n node.style.setProperty(key, value)\n written.set(key, node.style.getPropertyValue(key))\n },\n restore() {\n for (const [key, value] of written) {\n if (node.style.getPropertyValue(key) !== value) continue\n const saved = previous.get(key)!\n if (saved.value) node.style.setProperty(key, saved.value, saved.priority)\n else node.style.removeProperty(key)\n }\n written.clear()\n }\n }\n}\ntype Entry = {\n part: HTMLElement\n slotStyle: ReturnType<typeof styles>\n partStyle: ReturnType<typeof styles>\n spring: ReturnType<typeof createLayoutSpring>\n target: LayoutBounds\n}\n/**\n * Direct-child natural-flow slots with one dedicated motion part each.\n * Never clone/reparent a semantic host or scale text, borders or children.\n */\nexport function bindSpringLayout(\n root: HTMLElement,\n options: SpringOptions = {}\n): SpringLayoutController {\n if (options.reducedValue !== undefined)\n throw new TypeError('Layout off mode snaps to measured bounds.')\n const win = root.ownerDocument.defaultView!\n const entries = new Map<HTMLElement, Entry>()\n let currentOptions = { ...options, parameters: resolveSpringParameters(options.parameters) }\n let frame: number | undefined\n let needsMeasure = false\n let destroyed = false\n const resize = new win.ResizeObserver(schedule)\n function contentChanged(records: MutationRecord[]) {\n if (\n records.some(record => {\n // These style mutations are our own projection writes. Other content/style\n // mutations can change natural layout and must be measured as a group.\n if (record.type === 'attributes' && record.attributeName === 'style') {\n if (entries.has(record.target as HTMLElement)) return false\n if (Array.from(entries.values()).some(entry => entry.part === record.target)) return false\n }\n return true\n })\n )\n schedule()\n }\n const mutations = new win.MutationObserver(contentChanged)\n function restore(entry: Entry) {\n entry.partStyle.restore()\n entry.slotStyle.restore()\n }\n function dispose(slot: HTMLElement, entry: Entry) {\n restore(entry)\n entry.spring.destroy()\n resize.unobserve(slot)\n entries.delete(slot)\n }\n function draw() {\n // Preserve external mutations queued by an earlier frame callback before\n // discarding the records generated by our own presentation writes.\n contentChanged(mutations.takeRecords())\n for (const entry of entries.values()) {\n const bounds = entry.spring.get()\n entry.partStyle.set('width', `${Math.max(0, bounds.width)}px`)\n entry.partStyle.set('height', `${Math.max(0, bounds.height)}px`)\n entry.partStyle.set(\n 'translate',\n `${bounds.x - entry.target.x}px ${bounds.y - entry.target.y}px`\n )\n }\n mutations.takeRecords()\n }\n function project(slot: HTMLElement, entry: Entry) {\n entry.slotStyle.set('position', 'relative')\n entry.slotStyle.set('box-sizing', 'border-box')\n entry.slotStyle.set('flex', 'none')\n entry.slotStyle.set('width', `${entry.target.width}px`)\n entry.slotStyle.set('height', `${entry.target.height}px`)\n entry.partStyle.set('position', 'absolute')\n entry.partStyle.set('left', '0px')\n entry.partStyle.set('top', '0px')\n entry.partStyle.set('box-sizing', 'border-box')\n }\n function measure() {\n if (destroyed) return\n needsMeasure = false\n for (let ancestor: HTMLElement | null = root; ancestor; ancestor = ancestor.parentElement) {\n const css = win.getComputedStyle(ancestor)\n const matrix = css.transform === 'none' ? undefined : new win.DOMMatrixReadOnly(css.transform)\n if (\n (matrix &&\n (!matrix.is2D || matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1)) ||\n (css.scale !== 'none' && css.scale.split(' ').some(value => Number(value) !== 1)) ||\n (css.rotate !== 'none' && parseFloat(css.rotate) !== 0) ||\n (css.zoom && Number(css.zoom) !== 1) ||\n css.perspective !== 'none'\n )\n throw new TypeError('Layout measurement requires an unscaled, unrotated coordinate space.')\n }\n // Release every reservation before any geometry read. Measuring one item\n // while its siblings are projected would feed animation back into layout.\n entries.forEach(restore)\n const slots = Array.from(root.children).filter(\n (node): node is HTMLElement =>\n node instanceof win.HTMLElement && node.hasAttribute('data-rad-layout-slot')\n )\n for (const [slot, entry] of entries) {\n if (!slots.includes(slot) || slot.firstElementChild !== entry.part) dispose(slot, entry)\n }\n const origin = root.getBoundingClientRect()\n const targets = slots.map(slot => {\n const part = slot.firstElementChild\n if (\n slot.children.length !== 1 ||\n !(part instanceof win.HTMLElement) ||\n !part.hasAttribute('data-rad-layout-part')\n )\n throw new TypeError('Each layout slot requires a first-child data-rad-layout-part.')\n const css = win.getComputedStyle(slot)\n if (\n !['static', 'relative'].includes(css.position) ||\n ['inline', 'contents'].includes(css.display) ||\n [\n 'borderLeftWidth',\n 'borderTopWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'paddingLeft',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom'\n ].some(key => parseFloat(css[key as keyof CSSStyleDeclaration] as string) > 0)\n )\n throw new TypeError('Layout slots must be unpadded, borderless normal-flow wrappers.')\n const partCss = win.getComputedStyle(part)\n if (\n !['static', 'relative'].includes(partCss.position) ||\n [css, partCss].some(\n style =>\n style.transform !== 'none' ||\n style.translate !== 'none' ||\n style.scale !== 'none' ||\n style.rotate !== 'none'\n ) ||\n ['marginLeft', 'marginTop', 'marginRight', 'marginBottom'].some(\n key => parseFloat(partCss[key as keyof CSSStyleDeclaration] as string) !== 0\n )\n )\n throw new TypeError(\n 'Use dedicated transform-free layout slots and motion parts with no part margins.'\n )\n const rect = slot.getBoundingClientRect()\n return {\n slot,\n part,\n bounds: {\n x: rect.left - origin.left - root.clientLeft + root.scrollLeft,\n y: rect.top - origin.top - root.clientTop + root.scrollTop,\n width: rect.width,\n height: rect.height\n }\n }\n })\n for (const { slot, part, bounds } of targets) {\n let entry = entries.get(slot)\n if (!entry) {\n entry = {\n part,\n slotStyle: styles(slot),\n partStyle: styles(part),\n spring: createLayoutSpring(bounds, currentOptions),\n target: bounds\n }\n entries.set(slot, entry)\n resize.observe(slot)\n } else {\n entry.target = bounds\n entry.spring.to(bounds)\n }\n project(slot, entry)\n }\n mutations.takeRecords()\n draw()\n if (controller.isAnimating()) requestFrame()\n else entries.forEach(restore)\n mutations.takeRecords()\n }\n function tick() {\n frame = undefined\n if (destroyed) return\n if (needsMeasure) measure()\n else draw()\n if (controller.isAnimating()) requestFrame()\n else {\n entries.forEach(restore)\n mutations.takeRecords()\n }\n }\n function requestFrame() {\n if (frame === undefined) frame = win.requestAnimationFrame(tick)\n }\n function schedule() {\n if (destroyed) return\n needsMeasure = true\n requestFrame()\n }\n const controller: SpringLayoutController = {\n measure,\n configure(next) {\n if (destroyed) return\n if (next.reducedValue !== undefined)\n throw new TypeError('Layout off mode snaps to measured bounds.')\n // Validate before changing any entry or remembering options for new slots.\n currentOptions = {\n ...currentOptions,\n ...next,\n parameters: resolveSpringParameters(next.parameters, currentOptions.parameters)\n }\n entries.forEach(entry => entry.spring.configure(next))\n if (controller.isAnimating()) {\n draw()\n requestFrame()\n } else {\n entries.forEach(restore)\n mutations.takeRecords()\n }\n },\n get: slot => entries.get(slot)?.spring.get(),\n getVelocity: slot => entries.get(slot)?.spring.getVelocity(),\n isAnimating: () => Array.from(entries.values()).some(entry => entry.spring.isAnimating()),\n destroy() {\n if (destroyed) return\n destroyed = true\n if (frame !== undefined) win.cancelAnimationFrame(frame)\n mutations.disconnect()\n resize.disconnect()\n root.removeEventListener('load', schedule, true)\n root.removeEventListener('scroll', schedule, true)\n win.removeEventListener('resize', schedule)\n root.ownerDocument.fonts?.removeEventListener('loadingdone', schedule)\n for (const [slot, entry] of entries) dispose(slot, entry)\n }\n }\n try {\n measure()\n } catch (error) {\n controller.destroy()\n throw error\n }\n resize.observe(root)\n mutations.observe(root, {\n subtree: true,\n childList: true,\n characterData: true,\n attributes: true,\n attributeFilter: ['class', 'style', 'hidden', 'open']\n })\n root.addEventListener('load', schedule, true)\n root.addEventListener('scroll', schedule, true)\n win.addEventListener('resize', schedule)\n root.ownerDocument.fonts?.addEventListener('loadingdone', schedule)\n return controller\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type MotionProfile } from './config.js';
|
|
2
|
+
import type { MotionHostBinding } from './host.js';
|
|
3
|
+
/** Presentation only: this adapter never clicks, submits, captures or prevents input. */
|
|
4
|
+
export declare function bindPressMotion(node: HTMLElement, initialProfile: MotionProfile): MotionHostBinding;
|
|
5
|
+
//# sourceMappingURL=press.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../../src/motion/press.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD,yFAAyF;AACzF,wBAAgB,eAAe,CAC7B,IAAI,EAAE,WAAW,EACjB,cAAc,EAAE,aAAa,GAC5B,iBAAiB,CAmEnB"}
|