@gridui/motion 0.0.0-stage → 1.0.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.
Files changed (40) hide show
  1. package/README.md +257 -2
  2. package/dist/chunk-MMMTUJVS.js +106 -0
  3. package/dist/chunk-MMMTUJVS.js.map +7 -0
  4. package/dist/index.d.ts +25 -0
  5. package/dist/index.js +682 -0
  6. package/dist/index.js.map +7 -0
  7. package/dist/layout-motion/layout-motion.d.ts +20 -0
  8. package/dist/motion-config/context.d.ts +2 -0
  9. package/dist/motion-config/motion-config.d.ts +2 -0
  10. package/dist/motion-config/types.d.ts +27 -0
  11. package/dist/motion-config/validate-transition.d.ts +2 -0
  12. package/dist/motion-layout-group/context.d.ts +1 -0
  13. package/dist/motion-layout-group/motion-layout-group.d.ts +6 -0
  14. package/dist/motion-reveal/motion-reveal.d.ts +9 -0
  15. package/dist/motion-scope/motion-scope.d.ts +6 -0
  16. package/dist/motion-sequence/controller.d.ts +37 -0
  17. package/dist/motion-sequence/use-motion-sequence.d.ts +4 -0
  18. package/dist/motion-size/motion-size.d.ts +8 -0
  19. package/dist/policy.d.ts +4 -0
  20. package/dist/policy.js +15 -0
  21. package/dist/policy.js.map +7 -0
  22. package/dist/presence/presence.d.ts +9 -0
  23. package/dist/shared/dom-policy.d.ts +13 -0
  24. package/dist/shared/outcome.d.ts +1 -0
  25. package/dist/shared/resolve-transition.d.ts +9 -0
  26. package/dist/shared/state.d.ts +6 -0
  27. package/dist/shared/use-motion-policy.d.ts +10 -0
  28. package/dist/shared/use-motion-style.d.ts +3 -0
  29. package/dist/spring-value/controller.d.ts +26 -0
  30. package/dist/spring-value/use-spring-value.d.ts +3 -0
  31. package/docs/catalog.json +233 -0
  32. package/docs/reference/README.md +10 -0
  33. package/docs/reference/layout-motion.md +116 -0
  34. package/docs/reference/motion-config.md +46 -0
  35. package/docs/reference/motion-layout-group.md +24 -0
  36. package/docs/reference/motion-reveal.md +110 -0
  37. package/docs/reference/motion-scope.md +60 -0
  38. package/docs/reference/motion-size.md +64 -0
  39. package/docs/reference/presence.md +42 -0
  40. package/package.json +50 -3
package/README.md CHANGED
@@ -1,3 +1,258 @@
1
- # Temporary Holding Version
1
+ # @gridui/motion
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared React motion policy, presence/layout transitions, spring values, scoped
4
+ sequences, intrinsic sizing, and visibility-triggered decoration.
5
+ Import `MotionConfig`, `Presence`, and `LayoutMotion` from `@gridui/motion`.
6
+ Load `@gridui/theme/styles.css`; Motion has no component stylesheet. The package
7
+ uses Motion internally. Consumers do not need to import its engine directly.
8
+
9
+ ```tsx
10
+ import { LayoutMotion, MotionConfig, Presence } from "@gridui/motion";
11
+
12
+ <MotionConfig tempo={1} reducedMotion="user">
13
+ <Presence>
14
+ {items.map(item => (
15
+ <LayoutMotion key={item.id} layout="position"
16
+ enter={{ opacity: 0 }} exit={{ opacity: 0 }}>
17
+ {item.label}
18
+ </LayoutMotion>
19
+ ))}
20
+ </Presence>
21
+ </MotionConfig>
22
+ ```
23
+
24
+ ## Configuration
25
+
26
+ `MotionConfig` adds no DOM. Omitted properties inherit from the nearest provider.
27
+ The default `tempo` is 1; 0.8 is faster and 1.2 is slower. Nested values replace
28
+ the inherited tempo rather than multiplying it. Tempo must be finite and positive.
29
+ `disabled` settles changes immediately. `reducedMotion` is `user` by default or
30
+ `always`; system preferences are observed live. There is no preference bypass.
31
+
32
+ `transition` selects either `{ type: "tween", duration, ease }` or
33
+ `{ type: "spring", stiffness, damping, mass }`. Durations use milliseconds.
34
+ Tween duration may be zero; spring parameters must be finite and positive.
35
+ `ease` accepts `linear`, `easeIn`, `easeOut`, `easeInOut`, or a cubic-bezier tuple.
36
+ Springs default to stiffness 170, damping 26, and mass 1. Tempo scales both
37
+ duration and spring time without changing the spring's damping ratio.
38
+
39
+ Each LayoutMotion reads the local Theme duration and ease-out tokens on mount and
40
+ local style, class, or motion-configuration updates. Explicit transitions override these defaults. Missing or unsupported
41
+ token values use the standard 180ms/ease-out fallback. Pure stylesheet changes are
42
+ picked up on the next such update. Per-element transitions replace the provider
43
+ transition; omitted tween fields still use local Theme tokens.
44
+
45
+ All existing GridUI animation families use shared policy and tempo, including CSS
46
+ microinteractions, overlay portals, TextMorph, skeleton/image reveals, Sortable,
47
+ BottomSheet, Sidebar, CaseShowcase, and the opt-in brand logo. Local animation
48
+ switches can disable an effect; they cannot override an ancestor's disabled or
49
+ always-reduced policy or the system preference. Legacy `respectReducedMotion=false`
50
+ is accepted for source compatibility but no longer bypasses policy.
51
+
52
+ CSS components and specialized engines preserve their existing timing/easing APIs.
53
+ The `transition` setting configures LayoutMotion (including animated TabsPanel);
54
+ it does not replace CSS Theme easing or authored TextMorph/player timing.
55
+ Readiness delays, toast dismiss timers, and direct pointer tracking are not animation
56
+ durations and are not scaled. Tempo updates preserve TextMorph, reveal, and player
57
+ progress; new dnd-kit transitions use the latest configured timing.
58
+
59
+ ## CSS and imperative integration
60
+
61
+ MotionConfig is a React policy provider. GridUI components bridge it automatically
62
+ to their actual DOM roots, including Portal destinations, without extra wrappers.
63
+ Theme tokens remain unscaled base durations. Owned CSS multiplies duration and
64
+ delay by `--gridui-motion-factor` exactly once. Theme remains React-free.
65
+
66
+ Use MotionScope for application-owned CSS or a custom portal:
67
+
68
+ ```tsx
69
+ <MotionConfig tempo={1.5}>
70
+ <MotionScope asChild><section className="my-animation">Content</section></MotionScope>
71
+ </MotionConfig>
72
+ ```
73
+
74
+ Custom CSS can use `calc(var(--gridui-motion-duration-normal) *
75
+ var(--gridui-motion-factor, 1))` for duration and
76
+ `var(--gridui-motion-animation, my-keyframes)` for animation-name.
77
+ MotionScope supports native div props; `asChild` preserves the child's DOM and ref.
78
+ A custom portal needs its own MotionScope at the destination.
79
+ Tempo and policy cross React portals; arbitrary Theme token overrides follow DOM
80
+ inheritance and must be applied at the destination when needed.
81
+
82
+ The engine-free `@gridui/motion/policy` entry exports `useMotionPolicy`, `useMotionStyle`,
83
+ `readMotionDuration`, `readMotionPolicy`, and `observeMotionPolicy`. `useMotionPolicy` gives
84
+ `tempo`, `immediate`, `disabled`, `reducedMotion`, `transition`, `ready`, and `reason`.
85
+ `reason` is `pending`, `disabled`, `reduced-motion`, or undefined. Wait for `ready`
86
+ before using a preference to advance domain state; pending SSR preference only
87
+ suppresses decoration. Raw tempo is bridged independently from the effective CSS factor. `useMotionStyle` merges
88
+ caller styles with policy variables. `readMotionDuration` resolves base ms/s and
89
+ `calc()` tokens without tempo. DOM observers report policy changes and return cleanup;
90
+ imperative engines remain responsible for settling their own animation handles.
91
+ SSR policy is immediate until the browser preference is available. Observers subscribe
92
+ to the current ancestor chain and owning document; dispose and re-subscribe after
93
+ reparenting. Stylesheet-only changes require a fresh read. They do not scan descendants.
94
+
95
+ ## Presence
96
+
97
+ Keep `Presence` mounted and give each direct child a stable key. `mode` is `sync`
98
+ (default), `wait` (one child at a time), or `popLayout` (remove exiting children
99
+ from layout while they animate). Custom direct children in popLayout mode must
100
+ forward their ref to the actual DOM element. `initial` defaults to false, keeping
101
+ initial content visible; opt in only for deliberately animated mounting.
102
+ `onExitComplete` runs after all exiting children finish.
103
+
104
+ Presence includes a namespaced layout group. Matching `layoutId` values connect
105
+ elements inside that boundary; independent boundaries do not share identities.
106
+ Wrap related boundaries in `MotionLayoutGroup` to deliberately share identities.
107
+ The group adds no DOM and retains its own namespace. Use plain React keys for identity. Presence owns animation lifetime only: it does
108
+ not own selection, focus restoration, or application state.
109
+
110
+ ## LayoutMotion
111
+
112
+ LayoutMotion renders one div and forwards native props and its root ref.
113
+ The animation layer owns opacity and transform; use animate for these values
114
+ and keep independently transformed content on a child element.
115
+ `layout` defaults to true; `position`, `size`, and false select narrower behavior.
116
+ `layoutId` connects shared elements. Layout changes are driven by React updates,
117
+ not an observer of arbitrary DOM mutations or viewport-only CSS changes.
118
+ `enter`, `animate`, and `exit` accept opacity, x, y, and scale. The animate default
119
+ is opacity 1, x/y 0, and scale 1. Without enter, mounting does not animate.
120
+ Without exit, removal does not add a visual exit effect.
121
+ `transition` and `exitTransition` override timing. Completion callbacks are
122
+ `onAnimationComplete` and `onLayoutAnimationComplete`. A started value animation
123
+ completes once, including when policy finishes it early; cancelled and no-op runs
124
+ do not call onAnimationComplete. Removal never depends on a callback firing.
125
+ Timing/easing updates apply to the next value target; tempo changes adjust active
126
+ value playback without restarting. Layout projection captures timing when it starts.
127
+ `layoutScroll` marks a scrolling measurement root; `layoutRoot` marks a fixed root.
128
+ Styles use React CSSProperties, excluding animation-owned transform and opacity.
129
+ MotionValues and layout projection share Motion's transform composition. Motion 14
130
+ can retain an internal projection after disabling layout; a scoped transform adapter
131
+ suppresses it immediately until it settles, without claiming to cancel engine work.
132
+
133
+ Removed content becomes inert and aria-hidden immediately while its visual exit
134
+ finishes. Applications still move focus to a sensible surviving control before
135
+ removing focused content. Reduced motion and disabled configuration settle
136
+ transitions without hiding usable content. Server output contains ordinary,
137
+ visible content; no browser measurement is needed to render it.
138
+
139
+ Grid can compose this without an extra wrapper:
140
+
141
+ ```tsx
142
+ <Grid columns={columns} gap={16}>
143
+ {items.map(item => (
144
+ <GridItem key={item.id} asChild>
145
+ <LayoutMotion layout="position">{item.label}</LayoutMotion>
146
+ </GridItem>
147
+ ))}
148
+ </Grid>
149
+ ```
150
+
151
+ Keep GridItem as a direct child when using fillLastRow. Use gap-based grids for
152
+ independent moving cards. Framed shared seams are final-layout geometry and are
153
+ not guaranteed continuous while individual cells move. Do not attach two engines
154
+ to the same transform, including a Sortable drag root.
155
+
156
+ See [architecture](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/architecture.md)
157
+ and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-core/motion/.changeset/history).
158
+
159
+ ## Spring values
160
+
161
+ `useSpringValue(initial, options?)` returns a stable numeric controller. Subscribe
162
+ in an effect and write an owned DOM property; do not put each frame in React state.
163
+ The initial value is captured once. `get()` reads position, `getVelocity()` reads
164
+ units per real second, `set(target, velocity?)` retargets with continuity,
165
+ `stop()` freezes, and `jump(target)` cancels and sets a value immediately.
166
+ `subscribe(callback)` returns cleanup. The hook stops its animation on unmount;
167
+ each subscription remains owned by the effect that created it.
168
+
169
+ `set` returns a promise of `finished` or `cancelled`; superseding, stop, jump, and
170
+ unmount cancel the previous run. Policy-imposed immediate completion finishes it.
171
+ Reissuing the same active target without an explicit velocity keeps that run.
172
+ Explicit initial momentum survives additional retargets before the first frame,
173
+ including coordinate rebasing with jump followed by an explicit velocity. Stopped,
174
+ jumped, completed and disposed values report zero velocity.
175
+ Spring options are stiffness/damping/mass and optional precision (rest distance and
176
+ speed tolerance in value units). Local options replace a provider spring;
177
+ a provider tween does not convert this capability into a tween. Tempo adjusts
178
+ playback speed; explicit velocity is in real units/second. Pointer input time and
179
+ component state commits stay outside the controller. BottomSheet is a consumer.
180
+
181
+ ## Intrinsic content height
182
+
183
+ `MotionSize` renders an outer div and an inner flow-root measurement div. It
184
+ observes the inner content and animates the outer height with `useSpringValue`;
185
+ width remains natural. Children must have intrinsic height rather than depend on
186
+ the animated outer height. `spring` optionally configures its spring. Initial/SSR
187
+ height is natural, without measurement. Height is released to auto after settling;
188
+ clipping is applied only during resizing. Avoid focus outlines extending outside
189
+ the changing viewport during the transition, and keep application focus ownership.
190
+
191
+ Wrap sibling TabsPanels in one MotionSize to animate their combined natural height.
192
+ Use `motion` on panels for their optional opacity transitions. No Tabs selection,
193
+ keepMounted, focus or content-state behavior moves into MotionSize. It is not a
194
+ virtualized-list measurement system. Grid shared seams remain final-layout geometry.
195
+
196
+ ## Scoped sequences
197
+
198
+ `useMotionSequence(scopeRef)` accepts a stable ref to a mounted DOM root and returns
199
+ `play(steps, options?)`. Each step has an explicit descendant `element`, `to`, and
200
+ optional `from`, `duration` (ms) and `ease`. States use opacity/x/y/scale; a transform
201
+ step owns the entire transform. Never target a LayoutMotion or Sortable transform
202
+ root. There are no global selectors. Steps must stay within the scope.
203
+
204
+ The default order is sequence; `order: "parallel"` starts steps together.
205
+ `stagger` (ms) adds gaps between sequential steps or offsets parallel starts.
206
+ Overlapping steps cannot own the same element/property. Later sequential steps
207
+ inherit the earlier destination unless an explicit from state replaces it.
208
+ Step timing overrides a provider tween, then local Theme values. Provider springs
209
+ do not supply duration-based sequence timing. Timing is captured per play;
210
+ live tempo changes adjust playback rate while preserving progress.
211
+
212
+ The returned run exposes `finished`, `cancel()` and `finish()`. Cancellation freezes
213
+ owned properties and resolves `cancelled`; finishing applies authored final states
214
+ and resolves `finished`. A new play cancels the previous run. Disabled/reduced policy
215
+ finishes immediately. Completion is independent of animation DOM events. Unmount
216
+ cancels work and restores the original inline values and priorities of owned
217
+ properties. Do not let another engine or React style updates own these properties
218
+ while the scope is mounted. Pause/seek/reverse/repeat and scene interpretation are
219
+ outside this API; CaseShowcase retains its specialized player and scene model.
220
+
221
+ ## Visibility
222
+
223
+ `MotionReveal` renders a LayoutMotion div. Initially visible and SSR content stays
224
+ visible. Once an observer reports the element offscreen, its optional `enter`
225
+ state (default opacity 0/y 12) prepares it for entry. Above-the-fold content is not
226
+ hidden just to animate mounting. `once` defaults to true; false resets decoration
227
+ immediately on leaving and allows another entry. `amount` is 0..1; `root` and
228
+ `rootMargin` configure the IntersectionObserver. Use a measured scrolling root for
229
+ nested views. Keyboard focus reveals content immediately and keeps it visible.
230
+ Disabled/reduced motion keeps content visible without observation. The component
231
+ does not own application visibility, loading, navigation, or continuous scroll.
232
+
233
+ ## Support and implementation boundary
234
+
235
+ The maintained browser suite currently verifies Chromium. This is not a Firefox,
236
+ WebKit, embedded WebView, mobile-device performance, or screen-reader certification.
237
+ These capabilities use the existing modern browser baseline (WAAPI, ResizeObserver,
238
+ IntersectionObserver, inert and CSS custom properties); no polyfill is installed.
239
+ Public types contain no Motion engine types. Policy-only imports are engine-free
240
+ at runtime, although the package itself still declares the Motion dependency.
241
+
242
+ Implementation status and measured limitations: [motion TODO](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/plans/motion-roadmap.md).
243
+
244
+ ## Imperative spring ownership
245
+
246
+ `createSpringValue(initial, options?, policy?)` exposes the same numeric executor
247
+ outside React. The default policy is `{ tempo: 1, immediate: false }`; imperative
248
+ callers must supply and update their own policy. Its value methods match
249
+ useSpringValue, with `configure(options, policy)` and idempotent `dispose()`.
250
+ Configure changes future spring parameters and updates the active run's tempo or
251
+ immediate policy. Subscriptions return cleanup; dispose also releases them and
252
+ resolves a pending run as cancelled. Mutating/subscribing/configuring a disposed
253
+ controller throws. Use a fresh controller when recreating an imperative owner.
254
+
255
+ TextMorph consumes this factory for dynamic visual identities; it does not call
256
+ React hooks in a character loop. The factory does not own DOM, text, measurement,
257
+ or a global animation registry. The React hook keeps its existing StrictMode-safe
258
+ lifecycle binding to the same implementation.
@@ -0,0 +1,106 @@
1
+ // src/shared/dom-policy.ts
2
+ var query = "(prefers-reduced-motion: reduce)";
3
+ var readMotionDuration = (element, token = "--gridui-motion-duration-normal", fallback = 180) => {
4
+ const value = element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue(token).trim();
5
+ const parse = (time) => {
6
+ if (!/^(?:\d*\.)?\d+(?:ms|s)$/.test(time)) {
7
+ return void 0;
8
+ }
9
+ return Number.parseFloat(time) * (time.endsWith("ms") ? 1 : 1e3);
10
+ };
11
+ const direct = parse(value);
12
+ if (direct !== void 0) {
13
+ return direct;
14
+ }
15
+ if (!value || !element.ownerDocument.defaultView.CSS.supports("transition-duration", value)) {
16
+ return fallback;
17
+ }
18
+ const probe = element.ownerDocument.createElement("span");
19
+ probe.style.cssText = "position:absolute;visibility:hidden;pointer-events:none";
20
+ probe.style.transitionDuration = value;
21
+ element.ownerDocument.body.append(probe);
22
+ const result = parse(element.ownerDocument.defaultView.getComputedStyle(probe).transitionDuration);
23
+ probe.remove();
24
+ return result ?? fallback;
25
+ };
26
+ var readMotionPolicy = (element) => {
27
+ const style = element.ownerDocument.defaultView.getComputedStyle(element);
28
+ const factor = Number.parseFloat(style.getPropertyValue("--gridui-motion-tempo"));
29
+ return {
30
+ immediate: element.ownerDocument.defaultView.matchMedia(query).matches || style.getPropertyValue("--gridui-motion-disabled").trim() === "1",
31
+ tempo: Number.isFinite(factor) && factor > 0 ? factor : 1
32
+ };
33
+ };
34
+ var observeMotionPolicy = (element, changed) => {
35
+ let previous = readMotionPolicy(element);
36
+ const update = () => {
37
+ const next = readMotionPolicy(element);
38
+ if (next.immediate !== previous.immediate || next.tempo !== previous.tempo) {
39
+ previous = next;
40
+ changed(next);
41
+ }
42
+ };
43
+ const observer = new element.ownerDocument.defaultView.MutationObserver(update);
44
+ for (let node = element; node; node = node.parentElement) {
45
+ observer.observe(node, { attributes: true, attributeFilter: ["style", "class"] });
46
+ }
47
+ const media = element.ownerDocument.defaultView.matchMedia(query);
48
+ media.addEventListener("change", update);
49
+ return () => {
50
+ observer.disconnect();
51
+ media.removeEventListener("change", update);
52
+ };
53
+ };
54
+
55
+ // src/shared/use-motion-policy.ts
56
+ import { useContext, useSyncExternalStore } from "react";
57
+
58
+ // src/motion-config/context.ts
59
+ import { createContext } from "react";
60
+ var MotionContext = createContext({
61
+ tempo: 1,
62
+ reducedMotion: "user",
63
+ disabled: false,
64
+ transition: void 0
65
+ });
66
+
67
+ // src/shared/use-motion-policy.ts
68
+ var query2 = "(prefers-reduced-motion: reduce)";
69
+ var subscribe = (notify) => {
70
+ const preference = window.matchMedia(query2);
71
+ preference.addEventListener("change", notify);
72
+ return () => void preference.removeEventListener("change", notify);
73
+ };
74
+ var snapshot = () => window.matchMedia(query2).matches;
75
+ var serverSnapshot = () => void 0;
76
+ var useMotionPolicy = () => {
77
+ const settings = useContext(MotionContext);
78
+ const systemReduced = useSyncExternalStore(subscribe, snapshot, serverSnapshot);
79
+ const ready = systemReduced !== void 0;
80
+ const reason = settings.disabled ? "disabled" : settings.reducedMotion === "always" || systemReduced ? "reduced-motion" : !ready ? "pending" : void 0;
81
+ return { ...settings, ready, reason, immediate: reason !== void 0 };
82
+ };
83
+
84
+ // src/shared/use-motion-style.ts
85
+ var useMotionStyle = (style) => {
86
+ const policy = useMotionPolicy();
87
+ return {
88
+ ...style,
89
+ "--gridui-motion-tempo": policy.tempo,
90
+ "--gridui-motion-factor": policy.immediate ? 0 : policy.tempo,
91
+ "--gridui-motion-disabled": policy.immediate ? 1 : 0,
92
+ "--gridui-motion-animation": policy.immediate ? "none" : "initial",
93
+ "--gridui-motion-transition": policy.immediate ? "none" : "initial",
94
+ "--gridui-motion-transform": policy.immediate ? "none" : "initial"
95
+ };
96
+ };
97
+
98
+ export {
99
+ MotionContext,
100
+ readMotionDuration,
101
+ readMotionPolicy,
102
+ observeMotionPolicy,
103
+ useMotionPolicy,
104
+ useMotionStyle
105
+ };
106
+ //# sourceMappingURL=chunk-MMMTUJVS.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/shared/dom-policy.ts", "../src/shared/use-motion-policy.ts", "../src/motion-config/context.ts", "../src/shared/use-motion-style.ts"],
4
+ "sourcesContent": ["export type DOMMotionPolicy = { readonly immediate: boolean; readonly tempo: number };\nconst query = \"(prefers-reduced-motion: reduce)\";\n\n/** Read base time tokens without applying tempo. CSS calc()/var() resolve in the browser. */\nexport const readMotionDuration = (element: Element, token = \"--gridui-motion-duration-normal\", fallback = 180): number => {\n const value = element.ownerDocument.defaultView!.getComputedStyle(element).getPropertyValue(token).trim();\n const parse = (time: string): number | undefined => {\n if (!/^(?:\\d*\\.)?\\d+(?:ms|s)$/.test(time)) { return undefined; }\n return Number.parseFloat(time) * (time.endsWith(\"ms\") ? 1 : 1000);\n };\n const direct = parse(value);\n if (direct !== undefined) { return direct; }\n if (!value || !element.ownerDocument.defaultView!.CSS.supports(\"transition-duration\", value)) { return fallback; }\n const probe = element.ownerDocument.createElement(\"span\");\n probe.style.cssText = \"position:absolute;visibility:hidden;pointer-events:none\";\n probe.style.transitionDuration = value;\n element.ownerDocument.body.append(probe);\n const result = parse(element.ownerDocument.defaultView!.getComputedStyle(probe).transitionDuration);\n probe.remove();\n return result ?? fallback;\n};\n\nexport const readMotionPolicy = (element: Element): DOMMotionPolicy => {\n const style = element.ownerDocument.defaultView!.getComputedStyle(element);\n const factor = Number.parseFloat(style.getPropertyValue(\"--gridui-motion-tempo\"));\n return {\n immediate: element.ownerDocument.defaultView!.matchMedia(query).matches\n || style.getPropertyValue(\"--gridui-motion-disabled\").trim() === \"1\",\n tempo: Number.isFinite(factor) && factor > 0 ? factor : 1,\n };\n};\n\n/**\n * Observe the current ancestor chain and document preference. Re-subscribe after\n * reparenting; stylesheet-only changes are read on the next explicit read/update.\n * Resource lifecycle stays independent. This observer never scans descendants.\n */\nexport const observeMotionPolicy = (element: Element, changed: (policy: DOMMotionPolicy) => void): (() => void) => {\n let previous = readMotionPolicy(element);\n const update = () => {\n const next = readMotionPolicy(element);\n if (next.immediate !== previous.immediate || next.tempo !== previous.tempo) {\n previous = next;\n changed(next);\n }\n };\n const observer = new element.ownerDocument.defaultView!.MutationObserver(update);\n for (let node: Element | null = element; node; node = node.parentElement) {\n observer.observe(node, { attributes: true, attributeFilter: [\"style\", \"class\"] });\n }\n const media = element.ownerDocument.defaultView!.matchMedia(query);\n media.addEventListener(\"change\", update);\n return () => {\n observer.disconnect();\n media.removeEventListener(\"change\", update);\n };\n};\n", "import { useContext, useSyncExternalStore } from \"react\";\nimport { MotionContext } from \"../motion-config/context\";\n\nconst query = \"(prefers-reduced-motion: reduce)\";\nconst subscribe = (notify: () => void): (() => void) => {\n const preference = window.matchMedia(query);\n preference.addEventListener(\"change\", notify);\n return () => void preference.removeEventListener(\"change\", notify);\n};\nconst snapshot = (): boolean => window.matchMedia(query).matches;\nconst serverSnapshot = (): undefined => undefined;\n\n/** Unknown server preference is visually immediate but must not advance domain state. */\nexport const useMotionPolicy = () => {\n const settings = useContext(MotionContext);\n const systemReduced = useSyncExternalStore<boolean | undefined>(subscribe, snapshot, serverSnapshot);\n const ready = systemReduced !== undefined;\n const reason = settings.disabled ? \"disabled\" : settings.reducedMotion === \"always\" || systemReduced\n ? \"reduced-motion\" : !ready ? \"pending\" : undefined;\n return { ...settings, ready, reason, immediate: reason !== undefined };\n};\n", "import { createContext } from \"react\";\nimport type { MotionSettings } from \"./types\";\n\nexport const MotionContext = createContext<MotionSettings>({\n tempo: 1,\n reducedMotion: \"user\",\n disabled: false,\n transition: undefined,\n});\n", "import type { CSSProperties } from \"react\";\nimport { useMotionPolicy } from \"./use-motion-policy\";\n\n/** Bridge React policy to owned CSS, including nodes rendered through a portal. */\nexport const useMotionStyle = (style?: CSSProperties): CSSProperties => {\n const policy = useMotionPolicy();\n return {\n ...style,\n \"--gridui-motion-tempo\": policy.tempo,\n \"--gridui-motion-factor\": policy.immediate ? 0 : policy.tempo,\n \"--gridui-motion-disabled\": policy.immediate ? 1 : 0,\n \"--gridui-motion-animation\": policy.immediate ? \"none\" : \"initial\",\n \"--gridui-motion-transition\": policy.immediate ? \"none\" : \"initial\",\n \"--gridui-motion-transform\": policy.immediate ? \"none\" : \"initial\",\n } as CSSProperties;\n};\n"],
5
+ "mappings": "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",
6
+ "names": ["query"]
7
+ }
@@ -0,0 +1,25 @@
1
+ export { MotionConfig } from "./motion-config/motion-config";
2
+ export type { MotionConfigProps, MotionEase, MotionTransition } from "./motion-config/types";
3
+ export { Presence } from "./presence/presence";
4
+ export type { PresenceProps } from "./presence/presence";
5
+ export { LayoutMotion } from "./layout-motion/layout-motion";
6
+ export type { LayoutMotionProps } from "./layout-motion/layout-motion";
7
+ export { MotionScope } from "./motion-scope/motion-scope";
8
+ export type { MotionScopeProps } from "./motion-scope/motion-scope";
9
+ export { useMotionPolicy } from "./shared/use-motion-policy";
10
+ export { useMotionStyle } from "./shared/use-motion-style";
11
+ export { readMotionDuration, readMotionPolicy, observeMotionPolicy } from "./shared/dom-policy";
12
+ export type { DOMMotionPolicy } from "./shared/dom-policy";
13
+ export { MotionLayoutGroup } from "./motion-layout-group/motion-layout-group";
14
+ export type { MotionLayoutGroupProps } from "./motion-layout-group/motion-layout-group";
15
+ export { useSpringValue } from "./spring-value/use-spring-value";
16
+ export { createSpringValue } from "./spring-value/controller";
17
+ export type { SpringValue, SpringValueOptions, SpringValuePolicy, SpringValueController } from "./spring-value/controller";
18
+ export type { MotionOutcome } from "./shared/outcome";
19
+ export { MotionSize } from "./motion-size/motion-size";
20
+ export type { MotionSizeProps } from "./motion-size/motion-size";
21
+ export type { MotionState } from "./shared/state";
22
+ export { useMotionSequence } from "./motion-sequence/use-motion-sequence";
23
+ export type { MotionStep, MotionSequenceOptions, MotionSequence, MotionRun } from "./motion-sequence/controller";
24
+ export { MotionReveal } from "./motion-reveal/motion-reveal";
25
+ export type { MotionRevealProps } from "./motion-reveal/motion-reveal";