motionary 9.7.0 → 9.8.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/CHANGELOG.md +16 -0
- package/dist/chunks/{audio-cgWbDkoY.cjs → audio-BpU-A1m1.cjs} +3 -3
- package/dist/chunks/{audio-cgWbDkoY.cjs.map → audio-BpU-A1m1.cjs.map} +1 -1
- package/dist/chunks/{audio-CynhhWDi.js → audio-D95jwlOh.js} +3 -3
- package/dist/chunks/{audio-CynhhWDi.js.map → audio-D95jwlOh.js.map} +1 -1
- package/dist/chunks/{base-CLuqlLfG.js → base-BnRyfuyM.js} +2 -2
- package/dist/chunks/base-BnRyfuyM.js.map +1 -0
- package/dist/chunks/{base-DoRUZBy-.cjs → base-DBheNxJu.cjs} +2 -2
- package/dist/chunks/base-DBheNxJu.cjs.map +1 -0
- package/dist/chunks/{builtins-ClXshqj-.cjs → builtins-CKKZNR95.cjs} +3 -3
- package/dist/chunks/{builtins-ClXshqj-.cjs.map → builtins-CKKZNR95.cjs.map} +1 -1
- package/dist/chunks/{builtins-Bs4smevg.js → builtins-CqIq1zBv.js} +3 -3
- package/dist/chunks/{builtins-Bs4smevg.js.map → builtins-CqIq1zBv.js.map} +1 -1
- package/dist/chunks/{core-O4grKHSa.cjs → core-D74Fz-dL.cjs} +2 -2
- package/dist/chunks/{core-O4grKHSa.cjs.map → core-D74Fz-dL.cjs.map} +1 -1
- package/dist/chunks/{core-CiN5sqxB.js → core-DsGoL9EY.js} +2 -2
- package/dist/chunks/{core-CiN5sqxB.js.map → core-DsGoL9EY.js.map} +1 -1
- package/dist/chunks/{core-CwO835Wm.cjs → core-MQlXZKUG.cjs} +2 -2
- package/dist/chunks/{core-CwO835Wm.cjs.map → core-MQlXZKUG.cjs.map} +1 -1
- package/dist/chunks/{core-C3Taz-ew.js → core-XA2yhn1b.js} +2 -2
- package/dist/chunks/{core-C3Taz-ew.js.map → core-XA2yhn1b.js.map} +1 -1
- package/dist/chunks/{fx-C-XjLOTc.cjs → fx-B_pbhpDp.cjs} +2 -2
- package/dist/chunks/{fx-C-XjLOTc.cjs.map → fx-B_pbhpDp.cjs.map} +1 -1
- package/dist/chunks/{fx-CQv3IxMf.js → fx-CtnrFEg9.js} +2 -2
- package/dist/chunks/{fx-CQv3IxMf.js.map → fx-CtnrFEg9.js.map} +1 -1
- package/dist/chunks/{gpu-CB8frFOD.js → gpu-CDcXiNA8.js} +2 -2
- package/dist/chunks/{gpu-CB8frFOD.js.map → gpu-CDcXiNA8.js.map} +1 -1
- package/dist/chunks/{gpu-CcdA2D2i.cjs → gpu-cUixt7kT.cjs} +2 -2
- package/dist/chunks/{gpu-CcdA2D2i.cjs.map → gpu-cUixt7kT.cjs.map} +1 -1
- package/dist/chunks/{manifest-PJ0h8RS_.js → manifest-D58HXVY-.js} +2 -2
- package/dist/chunks/{manifest-PJ0h8RS_.js.map → manifest-D58HXVY-.js.map} +1 -1
- package/dist/chunks/{manifest-B08-vo9G.cjs → manifest-PaF9B8Vt.cjs} +2 -2
- package/dist/chunks/{manifest-B08-vo9G.cjs.map → manifest-PaF9B8Vt.cjs.map} +1 -1
- package/dist/chunks/{player-YzQGkKaW.js → player-48Zy_NBG.js} +4 -4
- package/dist/chunks/{player-YzQGkKaW.js.map → player-48Zy_NBG.js.map} +1 -1
- package/dist/chunks/{player-C2n17sdH.cjs → player-C4y4jXSv.cjs} +4 -4
- package/dist/chunks/{player-C2n17sdH.cjs.map → player-C4y4jXSv.cjs.map} +1 -1
- package/dist/chunks/{registry-CnO7ZVPK.js → registry-gFJRpPES.js} +2 -2
- package/dist/chunks/{registry-CnO7ZVPK.js.map → registry-gFJRpPES.js.map} +1 -1
- package/dist/chunks/{registry-BVklOepd.cjs → registry-xQZnSqqV.cjs} +2 -2
- package/dist/chunks/{registry-BVklOepd.cjs.map → registry-xQZnSqqV.cjs.map} +1 -1
- package/dist/chunks/{spring-uQMVJTj9.cjs → spring-BlTQD2AV.cjs} +2 -2
- package/dist/chunks/{spring-uQMVJTj9.cjs.map → spring-BlTQD2AV.cjs.map} +1 -1
- package/dist/chunks/{spring-BFKNHmfl.js → spring-CZDNyqWp.js} +2 -2
- package/dist/chunks/{spring-BFKNHmfl.js.map → spring-CZDNyqWp.js.map} +1 -1
- package/dist/chunks/{variants-DagykrKH.cjs → variants-CrDDJoYK.cjs} +2 -2
- package/dist/chunks/{variants-DagykrKH.cjs.map → variants-CrDDJoYK.cjs.map} +1 -1
- package/dist/chunks/{variants-B-zKORvt.js → variants-GU3yIL4F.js} +2 -2
- package/dist/chunks/{variants-B-zKORvt.js.map → variants-GU3yIL4F.js.map} +1 -1
- package/dist/components/a11y.cjs +1 -1
- package/dist/components/a11y.js +2 -2
- package/dist/components/angular.cjs +8 -8
- package/dist/components/angular.js +8 -8
- package/dist/components/background.cjs +2 -2
- package/dist/components/background.js +2 -2
- package/dist/components/bridge.cjs +1 -1
- package/dist/components/bridge.js +1 -1
- package/dist/components/cards.cjs +2 -2
- package/dist/components/cards.js +2 -2
- package/dist/components/click.cjs +3 -3
- package/dist/components/click.js +3 -3
- package/dist/components/depth.cjs +3 -3
- package/dist/components/depth.js +3 -3
- package/dist/components/design.cjs +3 -3
- package/dist/components/design.js +3 -3
- package/dist/components/dsl.cjs +2 -2
- package/dist/components/dsl.js +2 -2
- package/dist/components/effects.cjs +7 -7
- package/dist/components/effects.js +9 -9
- package/dist/components/engine.cjs +1 -1
- package/dist/components/engine.js +2 -2
- package/dist/components/feedback.cjs +1 -1
- package/dist/components/feedback.js +1 -1
- package/dist/components/fx-3d.cjs +2 -2
- package/dist/components/fx-3d.js +2 -2
- package/dist/components/fx-ai.cjs +2 -2
- package/dist/components/fx-ai.js +2 -2
- package/dist/components/fx-chart.cjs +2 -2
- package/dist/components/fx-chart.js +2 -2
- package/dist/components/fx-cinema.cjs +2 -2
- package/dist/components/fx-cinema.js +2 -2
- package/dist/components/fx-cyber.cjs +2 -2
- package/dist/components/fx-cyber.js +2 -2
- package/dist/components/fx-festival.cjs +2 -2
- package/dist/components/fx-festival.js +2 -2
- package/dist/components/fx-focus.cjs +2 -2
- package/dist/components/fx-focus.js +2 -2
- package/dist/components/fx-form.cjs +2 -2
- package/dist/components/fx-form.js +2 -2
- package/dist/components/fx-game.cjs +2 -2
- package/dist/components/fx-game.js +2 -2
- package/dist/components/fx-genart.cjs +2 -2
- package/dist/components/fx-genart.js +2 -2
- package/dist/components/fx-geo.cjs +2 -2
- package/dist/components/fx-geo.js +2 -2
- package/dist/components/fx-gesture.cjs +2 -2
- package/dist/components/fx-gesture.js +2 -2
- package/dist/components/fx-gpu.cjs +3 -3
- package/dist/components/fx-gpu.js +3 -3
- package/dist/components/fx-light.cjs +2 -2
- package/dist/components/fx-light.js +2 -2
- package/dist/components/fx-lottie.cjs +2 -2
- package/dist/components/fx-lottie.js +2 -2
- package/dist/components/fx-morph.cjs +2 -2
- package/dist/components/fx-morph.js +2 -2
- package/dist/components/fx-music.cjs +3 -3
- package/dist/components/fx-music.js +3 -3
- package/dist/components/fx-organic.cjs +2 -2
- package/dist/components/fx-organic.js +2 -2
- package/dist/components/fx-paper.cjs +2 -2
- package/dist/components/fx-paper.js +2 -2
- package/dist/components/fx-perf.cjs +2 -2
- package/dist/components/fx-perf.js +2 -2
- package/dist/components/fx-physics.cjs +2 -2
- package/dist/components/fx-physics.js +2 -2
- package/dist/components/fx-retro.cjs +2 -2
- package/dist/components/fx-retro.js +2 -2
- package/dist/components/fx-safe.cjs +2 -2
- package/dist/components/fx-safe.js +2 -2
- package/dist/components/fx-shop.cjs +2 -2
- package/dist/components/fx-shop.js +2 -2
- package/dist/components/fx-social.cjs +2 -2
- package/dist/components/fx-social.js +2 -2
- package/dist/components/fx-spatial.cjs +2 -2
- package/dist/components/fx-spatial.js +2 -2
- package/dist/components/fx-surface.cjs +2 -2
- package/dist/components/fx-surface.js +2 -2
- package/dist/components/fx-text.cjs +2 -2
- package/dist/components/fx-text.js +2 -2
- package/dist/components/fx-transitions.cjs +3 -3
- package/dist/components/fx-transitions.js +3 -3
- package/dist/components/fx-video.cjs +2 -2
- package/dist/components/fx-video.js +2 -2
- package/dist/components/fx-weather.cjs +2 -2
- package/dist/components/fx-weather.js +2 -2
- package/dist/components/fx.cjs +5 -5
- package/dist/components/fx.js +6 -6
- package/dist/components/fx2.cjs +5 -5
- package/dist/components/fx2.js +6 -6
- package/dist/components/gesture.cjs +3 -3
- package/dist/components/gesture.js +4 -4
- package/dist/components/interaction.cjs +1 -1
- package/dist/components/interaction.js +1 -1
- package/dist/components/layout.cjs +1 -1
- package/dist/components/layout.js +1 -1
- package/dist/components/lite.cjs +1 -1
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +1 -1
- package/dist/components/lite.js.map +1 -1
- package/dist/components/marketplace.cjs +3 -3
- package/dist/components/marketplace.js +4 -4
- package/dist/components/native.cjs +148 -0
- package/dist/components/native.cjs.map +1 -0
- package/dist/components/native.d.cts +94 -0
- package/dist/components/native.d.ts +94 -0
- package/dist/components/native.js +142 -0
- package/dist/components/native.js.map +1 -0
- package/dist/components/packs.cjs +1 -1
- package/dist/components/packs.js +1 -1
- package/dist/components/page.cjs +2 -2
- package/dist/components/page.js +3 -3
- package/dist/components/perf.cjs +1 -1
- package/dist/components/perf.js +2 -2
- package/dist/components/physics.cjs +2 -2
- package/dist/components/physics.js +3 -3
- package/dist/components/reveal.cjs +1 -1
- package/dist/components/reveal.js +1 -1
- package/dist/components/solid.cjs +8 -8
- package/dist/components/solid.js +8 -8
- package/dist/components/svelte.cjs +8 -8
- package/dist/components/svelte.js +8 -8
- package/dist/components/svg.cjs +1 -1
- package/dist/components/svg.js +1 -1
- package/dist/components/text.cjs +2 -2
- package/dist/components/text.js +2 -2
- package/dist/components/timeline.cjs +2 -2
- package/dist/components/timeline.js +3 -3
- package/dist/components/transitions.cjs +1 -1
- package/dist/components/transitions.js +1 -1
- package/dist/components/ui.cjs +3 -3
- package/dist/components/ui.js +4 -4
- package/dist/components/vue.cjs +8 -8
- package/dist/components/vue.js +8 -8
- package/dist/components/webgl.cjs +1 -1
- package/dist/components/webgl.js +1 -1
- package/dist/components/widgets.cjs +270 -199
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +17 -2
- package/dist/components/widgets.d.ts +17 -2
- package/dist/components/widgets.js +270 -200
- package/dist/components/widgets.js.map +1 -1
- package/dist/components.cjs +8 -8
- package/dist/components.js +10 -10
- package/dist/components.umd.js +1 -1
- package/dist/components.umd.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +1 -1
- package/docs/components.md +15 -0
- package/package.json +21 -1
- package/dist/chunks/base-CLuqlLfG.js.map +0 -1
- package/dist/chunks/base-DoRUZBy-.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var manifest = require('../chunks/manifest-
|
|
4
|
-
require('../chunks/registry-
|
|
5
|
-
require('../chunks/base-
|
|
3
|
+
var manifest = require('../chunks/manifest-PaF9B8Vt.cjs');
|
|
4
|
+
require('../chunks/registry-xQZnSqqV.cjs');
|
|
5
|
+
require('../chunks/base-DBheNxJu.cjs');
|
|
6
6
|
|
|
7
7
|
const MARKETPLACE_FORMAT = 'motionary/marketplace';
|
|
8
8
|
const L = (name, title, description, entry, register, effects, tags, since) => ({ name, title, description, entry, register, effects: effects.split(' '), tags: tags.split(' '), since, author: 'Motionary', official: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { l as loadEffectPack } from '../chunks/manifest-
|
|
2
|
-
export { E as EFFECT_PACK_FORMAT, p as packManifest, v as validateManifest } from '../chunks/manifest-
|
|
3
|
-
import '../chunks/registry-
|
|
4
|
-
import '../chunks/base-
|
|
1
|
+
import { l as loadEffectPack } from '../chunks/manifest-D58HXVY-.js';
|
|
2
|
+
export { E as EFFECT_PACK_FORMAT, p as packManifest, v as validateManifest } from '../chunks/manifest-D58HXVY-.js';
|
|
3
|
+
import '../chunks/registry-gFJRpPES.js';
|
|
4
|
+
import '../chunks/base-BnRyfuyM.js';
|
|
5
5
|
|
|
6
6
|
const MARKETPLACE_FORMAT = 'motionary/marketplace';
|
|
7
7
|
const L = (name, title, description, entry, register, effects, tags, since) => ({ name, title, description, entry, register, effects: effects.split(' '), tags: tags.split(' '), since, author: 'Motionary', official: true });
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var components_dsl = require('./dsl.cjs');
|
|
4
|
+
var components_design = require('./design.cjs');
|
|
5
|
+
var components_tokens = require('./tokens.cjs');
|
|
6
|
+
require('../chunks/registry-xQZnSqqV.cjs');
|
|
7
|
+
require('../chunks/base-DBheNxJu.cjs');
|
|
8
|
+
require('../chunks/core-MQlXZKUG.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `motionary/native` (= `motionary/components/native`, 9.8) — native 2.0:
|
|
12
|
+
* take the motion you designed on the web to React Native and Flutter.
|
|
13
|
+
*
|
|
14
|
+
* - `toReactNative(rules, { name })` — a React Native component (Animated +
|
|
15
|
+
* Easing.bezier / spring) for the entrance and press rules of a motion
|
|
16
|
+
* string.
|
|
17
|
+
* - `toFlutter(rules, { name })` — a Flutter widget (AnimationController +
|
|
18
|
+
* Cubic curves) for the same rules.
|
|
19
|
+
* - `nativeEasing(easing, 'react-native' | 'flutter')` — a CSS easing as
|
|
20
|
+
* `Easing.bezier(…)` / `Cubic(…)`.
|
|
21
|
+
* - `nativeTokens()` — Motionary's motion tokens (durations, easings as
|
|
22
|
+
* bezier arrays, springs) as JSON for native design systems.
|
|
23
|
+
*
|
|
24
|
+
* Complete sample apps live in `examples/native/react-native` and
|
|
25
|
+
* `examples/native/flutter`.
|
|
26
|
+
*/
|
|
27
|
+
const NAMED = { spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)', smooth: 'cubic-bezier(0.22, 1, 0.36, 1)' };
|
|
28
|
+
/** A CSS easing as React Native `Easing.bezier(…)` or Flutter `Cubic(…)` (9.8). */
|
|
29
|
+
function nativeEasing(easing, platform) {
|
|
30
|
+
const p = components_design.easingPoints(NAMED[easing || ''] || easing || 'cubic-bezier(0.22, 1, 0.36, 1)');
|
|
31
|
+
return platform === 'flutter' ? `Cubic(${p.join(', ')})` : `Easing.bezier(${p.join(', ')})`;
|
|
32
|
+
}
|
|
33
|
+
/** Start values for an entrance preset: opacity, translate x / y (dp), scale (9.8). */
|
|
34
|
+
function entranceFrom(effect) {
|
|
35
|
+
const m = { 'fade-up': [0, 24, 1], 'fade-down': [0, -24, 1], 'fade-left': [24, 0, 1], 'fade-right': [-24, 0, 1], scale: [0, 0, 0.85], 'zoom-in': [0, 0, 0.6], 'zoom-out': [0, 0, 1.2] };
|
|
36
|
+
const [x, y, s] = m[effect] || [0, 0, 1];
|
|
37
|
+
return { opacity: 0, x, y, scale: s };
|
|
38
|
+
}
|
|
39
|
+
const ident = (s) => s.replace(/(^|[-_\s]+)([a-z0-9])/gi, (_, __, c) => c.toUpperCase()).replace(/[^A-Za-z0-9]/g, '') || 'Motion';
|
|
40
|
+
const rulesOf = (r) => (typeof r === 'string' ? components_dsl.parseMotion(r).rules : r);
|
|
41
|
+
/** A React Native component for a motion string (entrance on mount, `pop` / press rules on press) (9.8). */
|
|
42
|
+
function toReactNative(rules, opts = {}) {
|
|
43
|
+
const rs = rulesOf(rules);
|
|
44
|
+
const name = ident(opts.name || 'MotionView');
|
|
45
|
+
const enter = rs.find((r) => r.trigger === 'enter' || r.trigger === 'load');
|
|
46
|
+
const press = rs.find((r) => r.trigger === 'click' || r.trigger === 'hover');
|
|
47
|
+
const f = entranceFrom(enter?.effect || 'fade');
|
|
48
|
+
const lines = [
|
|
49
|
+
`// Generated by motionary/native (9.8) from: ${rs.map((r) => `${r.trigger}: ${r.effect}`).join('; ') || '—'}`,
|
|
50
|
+
`import React, { useEffect, useRef } from 'react';`,
|
|
51
|
+
`import { Animated, Easing, ${press ? 'Pressable, ' : ''}AccessibilityInfo } from 'react-native';`,
|
|
52
|
+
``,
|
|
53
|
+
`export function ${name}({ children, index = 0, onPress }) {`,
|
|
54
|
+
` const t = useRef(new Animated.Value(0)).current;`,
|
|
55
|
+
` const s = useRef(new Animated.Value(1)).current;`,
|
|
56
|
+
` useEffect(() => {`,
|
|
57
|
+
` AccessibilityInfo.isReduceMotionEnabled().then((reduce) => {`,
|
|
58
|
+
` if (reduce) return t.setValue(1);`,
|
|
59
|
+
` Animated.timing(t, { toValue: 1, duration: ${enter?.duration ?? 600}, delay: ${enter?.delay ?? 0} + index * ${enter?.stagger ?? 0}, easing: ${nativeEasing(enter?.easing, 'react-native')}, useNativeDriver: true }).start();`,
|
|
60
|
+
` });`,
|
|
61
|
+
` }, []);`,
|
|
62
|
+
` const style = {`,
|
|
63
|
+
` opacity: t.interpolate({ inputRange: [0, 1], outputRange: [${f.opacity}, 1] }),`,
|
|
64
|
+
` transform: [`,
|
|
65
|
+
` { translateX: t.interpolate({ inputRange: [0, 1], outputRange: [${f.x}, 0] }) },`,
|
|
66
|
+
` { translateY: t.interpolate({ inputRange: [0, 1], outputRange: [${f.y}, 0] }) },`,
|
|
67
|
+
` { scale: Animated.multiply(s, t.interpolate({ inputRange: [0, 1], outputRange: [${f.scale}, 1] })) },`,
|
|
68
|
+
` ],`,
|
|
69
|
+
` };`,
|
|
70
|
+
];
|
|
71
|
+
if (press) {
|
|
72
|
+
lines.push(` const pressIn = () => Animated.spring(s, { toValue: 0.92, stiffness: ${components_tokens.MOTION_TOKENS.spring.snappy.stiffness}, damping: ${components_tokens.MOTION_TOKENS.spring.snappy.damping}, useNativeDriver: true }).start();`, ` const pressOut = () => Animated.spring(s, { toValue: 1, stiffness: ${components_tokens.MOTION_TOKENS.spring.bouncy.stiffness}, damping: ${components_tokens.MOTION_TOKENS.spring.bouncy.damping}, useNativeDriver: true }).start();`, ` return (`, ` <Pressable onPressIn={pressIn} onPressOut={pressOut} onPress={onPress}>`, ` <Animated.View style={style}>{children}</Animated.View>`, ` </Pressable>`, ` );`);
|
|
73
|
+
}
|
|
74
|
+
else
|
|
75
|
+
lines.push(` return <Animated.View style={style}>{children}</Animated.View>;`);
|
|
76
|
+
lines.push(`}`, ``);
|
|
77
|
+
return lines.join('\n');
|
|
78
|
+
}
|
|
79
|
+
/** A Flutter widget for a motion string (entrance on first build, press spring) (9.8). */
|
|
80
|
+
function toFlutter(rules, opts = {}) {
|
|
81
|
+
const rs = rulesOf(rules);
|
|
82
|
+
const name = ident(opts.name || 'MotionView');
|
|
83
|
+
const enter = rs.find((r) => r.trigger === 'enter' || r.trigger === 'load');
|
|
84
|
+
const press = rs.some((r) => r.trigger === 'click' || r.trigger === 'hover');
|
|
85
|
+
const f = entranceFrom(enter?.effect || 'fade');
|
|
86
|
+
return [
|
|
87
|
+
`// Generated by motionary/native (9.8) from: ${rs.map((r) => `${r.trigger}: ${r.effect}`).join('; ') || '—'}`,
|
|
88
|
+
`import 'package:flutter/material.dart';`,
|
|
89
|
+
``,
|
|
90
|
+
`class ${name} extends StatefulWidget {`,
|
|
91
|
+
` const ${name}({super.key, required this.child, this.index = 0, this.onTap});`,
|
|
92
|
+
` final Widget child;`,
|
|
93
|
+
` final int index;`,
|
|
94
|
+
` final VoidCallback? onTap;`,
|
|
95
|
+
` @override`,
|
|
96
|
+
` State<${name}> createState() => _${name}State();`,
|
|
97
|
+
`}`,
|
|
98
|
+
``,
|
|
99
|
+
`class _${name}State extends State<${name}> with SingleTickerProviderStateMixin {`,
|
|
100
|
+
` late final AnimationController _c = AnimationController(vsync: this, duration: const Duration(milliseconds: ${enter?.duration ?? 600}));`,
|
|
101
|
+
` late final Animation<double> _t = CurvedAnimation(parent: _c, curve: const ${nativeEasing(enter?.easing, 'flutter')});`,
|
|
102
|
+
` double _scale = 1;`,
|
|
103
|
+
``,
|
|
104
|
+
` @override`,
|
|
105
|
+
` void didChangeDependencies() {`,
|
|
106
|
+
` super.didChangeDependencies();`,
|
|
107
|
+
` if (MediaQuery.of(context).disableAnimations) { _c.value = 1; return; }`,
|
|
108
|
+
` Future.delayed(Duration(milliseconds: ${enter?.delay ?? 0} + widget.index * ${enter?.stagger ?? 0}), () { if (mounted) _c.forward(); });`,
|
|
109
|
+
` }`,
|
|
110
|
+
``,
|
|
111
|
+
` @override`,
|
|
112
|
+
` void dispose() { _c.dispose(); super.dispose(); }`,
|
|
113
|
+
``,
|
|
114
|
+
` @override`,
|
|
115
|
+
` Widget build(BuildContext context) {`,
|
|
116
|
+
` Widget w = AnimatedBuilder(`,
|
|
117
|
+
` animation: _t,`,
|
|
118
|
+
` builder: (context, child) => Opacity(`,
|
|
119
|
+
` opacity: ${f.opacity} + (1 - ${f.opacity}) * _t.value,`,
|
|
120
|
+
` child: Transform.translate(`,
|
|
121
|
+
` offset: Offset(${f.x} * (1 - _t.value), ${f.y} * (1 - _t.value)),`,
|
|
122
|
+
` child: Transform.scale(scale: ${f.scale} + (1 - ${f.scale}) * _t.value, child: child),`,
|
|
123
|
+
` ),`,
|
|
124
|
+
` ),`,
|
|
125
|
+
` child: widget.child,`,
|
|
126
|
+
` );`,
|
|
127
|
+
press
|
|
128
|
+
? ` return GestureDetector(\n onTapDown: (_) => setState(() => _scale = 0.92),\n onTapUp: (_) => setState(() => _scale = 1),\n onTapCancel: () => setState(() => _scale = 1),\n onTap: widget.onTap,\n child: AnimatedScale(scale: _scale, duration: const Duration(milliseconds: 180), curve: Curves.easeOutBack, child: w),\n );`
|
|
129
|
+
: ` return w;`,
|
|
130
|
+
` }`,
|
|
131
|
+
`}`,
|
|
132
|
+
``,
|
|
133
|
+
].join('\n');
|
|
134
|
+
}
|
|
135
|
+
/** Motion tokens for native design systems: durations (ms), easings as bezier arrays, springs (9.8). */
|
|
136
|
+
function nativeTokens() {
|
|
137
|
+
const easing = {};
|
|
138
|
+
for (const [k, v] of Object.entries(components_tokens.MOTION_TOKENS.easing))
|
|
139
|
+
easing[k] = components_design.easingPoints(v);
|
|
140
|
+
return { duration: { ...components_tokens.MOTION_TOKENS.duration }, easing, spring: JSON.parse(JSON.stringify(components_tokens.MOTION_TOKENS.spring)) };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
exports.entranceFrom = entranceFrom;
|
|
144
|
+
exports.nativeEasing = nativeEasing;
|
|
145
|
+
exports.nativeTokens = nativeTokens;
|
|
146
|
+
exports.toFlutter = toFlutter;
|
|
147
|
+
exports.toReactNative = toReactNative;
|
|
148
|
+
//# sourceMappingURL=native.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.cjs","sources":["../../src/components/native/index.ts"],"sourcesContent":["/**\n * `motionary/native` (= `motionary/components/native`, 9.8) — native 2.0:\n * take the motion you designed on the web to React Native and Flutter.\n *\n * - `toReactNative(rules, { name })` — a React Native component (Animated +\n * Easing.bezier / spring) for the entrance and press rules of a motion\n * string.\n * - `toFlutter(rules, { name })` — a Flutter widget (AnimationController +\n * Cubic curves) for the same rules.\n * - `nativeEasing(easing, 'react-native' | 'flutter')` — a CSS easing as\n * `Easing.bezier(…)` / `Cubic(…)`.\n * - `nativeTokens()` — Motionary's motion tokens (durations, easings as\n * bezier arrays, springs) as JSON for native design systems.\n *\n * Complete sample apps live in `examples/native/react-native` and\n * `examples/native/flutter`.\n */\nimport { parseMotion, type MotionRule } from '../dsl/index';\nimport { easingPoints } from '../design/index';\nimport { MOTION_TOKENS } from '../tokens/index';\n\ntype Platform = 'react-native' | 'flutter';\nconst NAMED: Record<string, string> = { spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)', smooth: 'cubic-bezier(0.22, 1, 0.36, 1)' };\n/** A CSS easing as React Native `Easing.bezier(…)` or Flutter `Cubic(…)` (9.8). */\nexport function nativeEasing(easing: string | undefined, platform: Platform): string {\n const p = easingPoints(NAMED[easing || ''] || easing || 'cubic-bezier(0.22, 1, 0.36, 1)');\n return platform === 'flutter' ? `Cubic(${p.join(', ')})` : `Easing.bezier(${p.join(', ')})`;\n}\n\n/** Start values for an entrance preset: opacity, translate x / y (dp), scale (9.8). */\nexport function entranceFrom(effect: string): { opacity: number; x: number; y: number; scale: number } {\n const m: Record<string, [number, number, number]> = { 'fade-up': [0, 24, 1], 'fade-down': [0, -24, 1], 'fade-left': [24, 0, 1], 'fade-right': [-24, 0, 1], scale: [0, 0, 0.85], 'zoom-in': [0, 0, 0.6], 'zoom-out': [0, 0, 1.2] };\n const [x, y, s] = m[effect] || [0, 0, 1];\n return { opacity: 0, x, y, scale: s };\n}\n\nconst ident = (s: string) => s.replace(/(^|[-_\\s]+)([a-z0-9])/gi, (_, __, c) => c.toUpperCase()).replace(/[^A-Za-z0-9]/g, '') || 'Motion';\nconst rulesOf = (r: string | MotionRule[]) => (typeof r === 'string' ? parseMotion(r).rules : r);\n\n/** A React Native component for a motion string (entrance on mount, `pop` / press rules on press) (9.8). */\nexport function toReactNative(rules: string | MotionRule[], opts: { name?: string } = {}): string {\n const rs = rulesOf(rules);\n const name = ident(opts.name || 'MotionView');\n const enter = rs.find((r) => r.trigger === 'enter' || r.trigger === 'load');\n const press = rs.find((r) => r.trigger === 'click' || r.trigger === 'hover');\n const f = entranceFrom(enter?.effect || 'fade');\n const lines = [\n `// Generated by motionary/native (9.8) from: ${rs.map((r) => `${r.trigger}: ${r.effect}`).join('; ') || '—'}`,\n `import React, { useEffect, useRef } from 'react';`,\n `import { Animated, Easing, ${press ? 'Pressable, ' : ''}AccessibilityInfo } from 'react-native';`,\n ``,\n `export function ${name}({ children, index = 0, onPress }) {`,\n ` const t = useRef(new Animated.Value(0)).current;`,\n ` const s = useRef(new Animated.Value(1)).current;`,\n ` useEffect(() => {`,\n ` AccessibilityInfo.isReduceMotionEnabled().then((reduce) => {`,\n ` if (reduce) return t.setValue(1);`,\n ` Animated.timing(t, { toValue: 1, duration: ${enter?.duration ?? 600}, delay: ${enter?.delay ?? 0} + index * ${enter?.stagger ?? 0}, easing: ${nativeEasing(enter?.easing, 'react-native')}, useNativeDriver: true }).start();`,\n ` });`,\n ` }, []);`,\n ` const style = {`,\n ` opacity: t.interpolate({ inputRange: [0, 1], outputRange: [${f.opacity}, 1] }),`,\n ` transform: [`,\n ` { translateX: t.interpolate({ inputRange: [0, 1], outputRange: [${f.x}, 0] }) },`,\n ` { translateY: t.interpolate({ inputRange: [0, 1], outputRange: [${f.y}, 0] }) },`,\n ` { scale: Animated.multiply(s, t.interpolate({ inputRange: [0, 1], outputRange: [${f.scale}, 1] })) },`,\n ` ],`,\n ` };`,\n ];\n if (press) {\n lines.push(\n ` const pressIn = () => Animated.spring(s, { toValue: 0.92, stiffness: ${MOTION_TOKENS.spring.snappy.stiffness}, damping: ${MOTION_TOKENS.spring.snappy.damping}, useNativeDriver: true }).start();`,\n ` const pressOut = () => Animated.spring(s, { toValue: 1, stiffness: ${MOTION_TOKENS.spring.bouncy.stiffness}, damping: ${MOTION_TOKENS.spring.bouncy.damping}, useNativeDriver: true }).start();`,\n ` return (`,\n ` <Pressable onPressIn={pressIn} onPressOut={pressOut} onPress={onPress}>`,\n ` <Animated.View style={style}>{children}</Animated.View>`,\n ` </Pressable>`,\n ` );`\n );\n } else lines.push(` return <Animated.View style={style}>{children}</Animated.View>;`);\n lines.push(`}`, ``);\n return lines.join('\\n');\n}\n\n/** A Flutter widget for a motion string (entrance on first build, press spring) (9.8). */\nexport function toFlutter(rules: string | MotionRule[], opts: { name?: string } = {}): string {\n const rs = rulesOf(rules);\n const name = ident(opts.name || 'MotionView');\n const enter = rs.find((r) => r.trigger === 'enter' || r.trigger === 'load');\n const press = rs.some((r) => r.trigger === 'click' || r.trigger === 'hover');\n const f = entranceFrom(enter?.effect || 'fade');\n return [\n `// Generated by motionary/native (9.8) from: ${rs.map((r) => `${r.trigger}: ${r.effect}`).join('; ') || '—'}`,\n `import 'package:flutter/material.dart';`,\n ``,\n `class ${name} extends StatefulWidget {`,\n ` const ${name}({super.key, required this.child, this.index = 0, this.onTap});`,\n ` final Widget child;`,\n ` final int index;`,\n ` final VoidCallback? onTap;`,\n ` @override`,\n ` State<${name}> createState() => _${name}State();`,\n `}`,\n ``,\n `class _${name}State extends State<${name}> with SingleTickerProviderStateMixin {`,\n ` late final AnimationController _c = AnimationController(vsync: this, duration: const Duration(milliseconds: ${enter?.duration ?? 600}));`,\n ` late final Animation<double> _t = CurvedAnimation(parent: _c, curve: const ${nativeEasing(enter?.easing, 'flutter')});`,\n ` double _scale = 1;`,\n ``,\n ` @override`,\n ` void didChangeDependencies() {`,\n ` super.didChangeDependencies();`,\n ` if (MediaQuery.of(context).disableAnimations) { _c.value = 1; return; }`,\n ` Future.delayed(Duration(milliseconds: ${enter?.delay ?? 0} + widget.index * ${enter?.stagger ?? 0}), () { if (mounted) _c.forward(); });`,\n ` }`,\n ``,\n ` @override`,\n ` void dispose() { _c.dispose(); super.dispose(); }`,\n ``,\n ` @override`,\n ` Widget build(BuildContext context) {`,\n ` Widget w = AnimatedBuilder(`,\n ` animation: _t,`,\n ` builder: (context, child) => Opacity(`,\n ` opacity: ${f.opacity} + (1 - ${f.opacity}) * _t.value,`,\n ` child: Transform.translate(`,\n ` offset: Offset(${f.x} * (1 - _t.value), ${f.y} * (1 - _t.value)),`,\n ` child: Transform.scale(scale: ${f.scale} + (1 - ${f.scale}) * _t.value, child: child),`,\n ` ),`,\n ` ),`,\n ` child: widget.child,`,\n ` );`,\n press\n ? ` return GestureDetector(\\n onTapDown: (_) => setState(() => _scale = 0.92),\\n onTapUp: (_) => setState(() => _scale = 1),\\n onTapCancel: () => setState(() => _scale = 1),\\n onTap: widget.onTap,\\n child: AnimatedScale(scale: _scale, duration: const Duration(milliseconds: 180), curve: Curves.easeOutBack, child: w),\\n );`\n : ` return w;`,\n ` }`,\n `}`,\n ``,\n ].join('\\n');\n}\n\n/** Motion tokens for native design systems: durations (ms), easings as bezier arrays, springs (9.8). */\nexport function nativeTokens(): { duration: Record<string, number>; easing: Record<string, number[]>; spring: Record<string, { stiffness: number; damping: number; mass: number }> } {\n const easing: Record<string, number[]> = {};\n for (const [k, v] of Object.entries(MOTION_TOKENS.easing)) easing[k] = easingPoints(v);\n return { duration: { ...MOTION_TOKENS.duration }, easing, spring: JSON.parse(JSON.stringify(MOTION_TOKENS.spring)) };\n}\n"],"names":["easingPoints","parseMotion","MOTION_TOKENS"],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;AAgBG;AAMH,MAAM,KAAK,GAA2B,EAAE,MAAM,EAAE,mCAAmC,EAAE,MAAM,EAAE,gCAAgC,EAAE;AAC/H;AACM,SAAU,YAAY,CAAC,MAA0B,EAAE,QAAkB,EAAA;AACzE,IAAA,MAAM,CAAC,GAAGA,8BAAY,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,IAAI,MAAM,IAAI,gCAAgC,CAAC;IACzF,OAAO,QAAQ,KAAK,SAAS,GAAG,CAAA,MAAA,EAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG,GAAG,CAAA,cAAA,EAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;AAC7F;AAEA;AACM,SAAU,YAAY,CAAC,MAAc,EAAA;AACzC,IAAA,MAAM,CAAC,GAA6C,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;IACjO,MA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AA,mCAAA,CAAqC;AACrC,QAAA,CAAA,yBAAA,EAA4B,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA,mBAAA,CAAqB;AAC7E,QAAA,CAAA,wCAAA,EAA2C,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,KAAK,CAAA,4BAAA,CAA8B;QAClG,CAAA,UAAA,CAAY;QACZ,CAAA,QAAA,CAAU;QACV,CAAA,0BAAA,CAA4B;QAC5B,CAAA,MAAA,CAAQ;QACR;AACE,cAAE,CAAA,8VAAA;AACF,cAAE,CAAA,aAAA,CAAe;QACnB,CAAA,GAAA,CAAK;QACL,CAAA,CAAA,CAAG;QACH,CAAA,CAAE;AACH,KAAA,CAAC,IAAI,CAAC,IAAI,CAAC;AACd;AAEA;SACgB,YAAY,GAAA;IAC1B,MAAM,MAAM,GAA6B,EAAE;AAC3C,IAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAACA,+BAAa,CAAC,MAAM,CAAC;QAAE,MAAM,CAAC,CAAC,CAAC,GAAGF,8BAAY,CAAC,CAAC,CAAC;AACtF,IAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,GAAGE,+BAAa,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAACA,+BAAa,CAAC,MAAM,CAAC,CAAC,EAAE;AACtH;;;;;;;;"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
3
|
+
* yours) is a plain object registered once and played the same way:
|
|
4
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
5
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
6
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
7
|
+
* animation budget.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const EFFECT_TRIGGERS: readonly ["click", "hover", "enter", "load", "loop", "manual"];
|
|
11
|
+
type EffectTrigger = (typeof EFFECT_TRIGGERS)[number];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `motionary/dsl` (= `motionary/components/dsl`, 9.0) — the declarative
|
|
15
|
+
* motion DSL. Describe motion as one readable string instead of code:
|
|
16
|
+
*
|
|
17
|
+
* ```html
|
|
18
|
+
* <section data-motion="enter: fade-up 600ms ease-out stagger 80ms; hover: pop; click: confetti count=40">
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Grammar — rules separated by `;`, each `trigger: effect [modifiers…]`:
|
|
22
|
+
* - trigger: `enter` · `click` · `hover` · `load` · `loop` · `manual`
|
|
23
|
+
* - effect: any registered effect name (timeline presets, packs, plugins)
|
|
24
|
+
* - modifiers: a duration (`600ms` / `0.6s`), `delay 120ms`,
|
|
25
|
+
* `stagger 80ms` (children one after another), an easing (`ease-out`,
|
|
26
|
+
* `linear`, `spring`, `cubic-bezier(…)`, `steps(…)`), `once`, and
|
|
27
|
+
* `key=value` effect options (numbers / booleans parsed).
|
|
28
|
+
*
|
|
29
|
+
* `parseMotion()` → rules + errors, `serializeMotion()` back to a string,
|
|
30
|
+
* `motion\`…\`` tagged template, `applyMotion(root)` binds every
|
|
31
|
+
* `[data-motion]` under `root` (and watches for new ones with `observe`),
|
|
32
|
+
* `bindMotion(el, rules)` for one element, and `createComponent(json)`
|
|
33
|
+
* builds live markup from the 8.9 `describeComponent()` JSON.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
interface MotionRule {
|
|
37
|
+
trigger: EffectTrigger;
|
|
38
|
+
effect: string;
|
|
39
|
+
duration?: number;
|
|
40
|
+
delay?: number;
|
|
41
|
+
stagger?: number;
|
|
42
|
+
easing?: string;
|
|
43
|
+
once?: boolean;
|
|
44
|
+
options: Record<string, string | number | boolean>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `motionary/native` (= `motionary/components/native`, 9.8) — native 2.0:
|
|
49
|
+
* take the motion you designed on the web to React Native and Flutter.
|
|
50
|
+
*
|
|
51
|
+
* - `toReactNative(rules, { name })` — a React Native component (Animated +
|
|
52
|
+
* Easing.bezier / spring) for the entrance and press rules of a motion
|
|
53
|
+
* string.
|
|
54
|
+
* - `toFlutter(rules, { name })` — a Flutter widget (AnimationController +
|
|
55
|
+
* Cubic curves) for the same rules.
|
|
56
|
+
* - `nativeEasing(easing, 'react-native' | 'flutter')` — a CSS easing as
|
|
57
|
+
* `Easing.bezier(…)` / `Cubic(…)`.
|
|
58
|
+
* - `nativeTokens()` — Motionary's motion tokens (durations, easings as
|
|
59
|
+
* bezier arrays, springs) as JSON for native design systems.
|
|
60
|
+
*
|
|
61
|
+
* Complete sample apps live in `examples/native/react-native` and
|
|
62
|
+
* `examples/native/flutter`.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
type Platform = 'react-native' | 'flutter';
|
|
66
|
+
/** A CSS easing as React Native `Easing.bezier(…)` or Flutter `Cubic(…)` (9.8). */
|
|
67
|
+
declare function nativeEasing(easing: string | undefined, platform: Platform): string;
|
|
68
|
+
/** Start values for an entrance preset: opacity, translate x / y (dp), scale (9.8). */
|
|
69
|
+
declare function entranceFrom(effect: string): {
|
|
70
|
+
opacity: number;
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
scale: number;
|
|
74
|
+
};
|
|
75
|
+
/** A React Native component for a motion string (entrance on mount, `pop` / press rules on press) (9.8). */
|
|
76
|
+
declare function toReactNative(rules: string | MotionRule[], opts?: {
|
|
77
|
+
name?: string;
|
|
78
|
+
}): string;
|
|
79
|
+
/** A Flutter widget for a motion string (entrance on first build, press spring) (9.8). */
|
|
80
|
+
declare function toFlutter(rules: string | MotionRule[], opts?: {
|
|
81
|
+
name?: string;
|
|
82
|
+
}): string;
|
|
83
|
+
/** Motion tokens for native design systems: durations (ms), easings as bezier arrays, springs (9.8). */
|
|
84
|
+
declare function nativeTokens(): {
|
|
85
|
+
duration: Record<string, number>;
|
|
86
|
+
easing: Record<string, number[]>;
|
|
87
|
+
spring: Record<string, {
|
|
88
|
+
stiffness: number;
|
|
89
|
+
damping: number;
|
|
90
|
+
mass: number;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export { entranceFrom, nativeEasing, nativeTokens, toFlutter, toReactNative };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
3
|
+
* yours) is a plain object registered once and played the same way:
|
|
4
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
5
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
6
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
7
|
+
* animation budget.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const EFFECT_TRIGGERS: readonly ["click", "hover", "enter", "load", "loop", "manual"];
|
|
11
|
+
type EffectTrigger = (typeof EFFECT_TRIGGERS)[number];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `motionary/dsl` (= `motionary/components/dsl`, 9.0) — the declarative
|
|
15
|
+
* motion DSL. Describe motion as one readable string instead of code:
|
|
16
|
+
*
|
|
17
|
+
* ```html
|
|
18
|
+
* <section data-motion="enter: fade-up 600ms ease-out stagger 80ms; hover: pop; click: confetti count=40">
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Grammar — rules separated by `;`, each `trigger: effect [modifiers…]`:
|
|
22
|
+
* - trigger: `enter` · `click` · `hover` · `load` · `loop` · `manual`
|
|
23
|
+
* - effect: any registered effect name (timeline presets, packs, plugins)
|
|
24
|
+
* - modifiers: a duration (`600ms` / `0.6s`), `delay 120ms`,
|
|
25
|
+
* `stagger 80ms` (children one after another), an easing (`ease-out`,
|
|
26
|
+
* `linear`, `spring`, `cubic-bezier(…)`, `steps(…)`), `once`, and
|
|
27
|
+
* `key=value` effect options (numbers / booleans parsed).
|
|
28
|
+
*
|
|
29
|
+
* `parseMotion()` → rules + errors, `serializeMotion()` back to a string,
|
|
30
|
+
* `motion\`…\`` tagged template, `applyMotion(root)` binds every
|
|
31
|
+
* `[data-motion]` under `root` (and watches for new ones with `observe`),
|
|
32
|
+
* `bindMotion(el, rules)` for one element, and `createComponent(json)`
|
|
33
|
+
* builds live markup from the 8.9 `describeComponent()` JSON.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
interface MotionRule {
|
|
37
|
+
trigger: EffectTrigger;
|
|
38
|
+
effect: string;
|
|
39
|
+
duration?: number;
|
|
40
|
+
delay?: number;
|
|
41
|
+
stagger?: number;
|
|
42
|
+
easing?: string;
|
|
43
|
+
once?: boolean;
|
|
44
|
+
options: Record<string, string | number | boolean>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `motionary/native` (= `motionary/components/native`, 9.8) — native 2.0:
|
|
49
|
+
* take the motion you designed on the web to React Native and Flutter.
|
|
50
|
+
*
|
|
51
|
+
* - `toReactNative(rules, { name })` — a React Native component (Animated +
|
|
52
|
+
* Easing.bezier / spring) for the entrance and press rules of a motion
|
|
53
|
+
* string.
|
|
54
|
+
* - `toFlutter(rules, { name })` — a Flutter widget (AnimationController +
|
|
55
|
+
* Cubic curves) for the same rules.
|
|
56
|
+
* - `nativeEasing(easing, 'react-native' | 'flutter')` — a CSS easing as
|
|
57
|
+
* `Easing.bezier(…)` / `Cubic(…)`.
|
|
58
|
+
* - `nativeTokens()` — Motionary's motion tokens (durations, easings as
|
|
59
|
+
* bezier arrays, springs) as JSON for native design systems.
|
|
60
|
+
*
|
|
61
|
+
* Complete sample apps live in `examples/native/react-native` and
|
|
62
|
+
* `examples/native/flutter`.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
type Platform = 'react-native' | 'flutter';
|
|
66
|
+
/** A CSS easing as React Native `Easing.bezier(…)` or Flutter `Cubic(…)` (9.8). */
|
|
67
|
+
declare function nativeEasing(easing: string | undefined, platform: Platform): string;
|
|
68
|
+
/** Start values for an entrance preset: opacity, translate x / y (dp), scale (9.8). */
|
|
69
|
+
declare function entranceFrom(effect: string): {
|
|
70
|
+
opacity: number;
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
scale: number;
|
|
74
|
+
};
|
|
75
|
+
/** A React Native component for a motion string (entrance on mount, `pop` / press rules on press) (9.8). */
|
|
76
|
+
declare function toReactNative(rules: string | MotionRule[], opts?: {
|
|
77
|
+
name?: string;
|
|
78
|
+
}): string;
|
|
79
|
+
/** A Flutter widget for a motion string (entrance on first build, press spring) (9.8). */
|
|
80
|
+
declare function toFlutter(rules: string | MotionRule[], opts?: {
|
|
81
|
+
name?: string;
|
|
82
|
+
}): string;
|
|
83
|
+
/** Motion tokens for native design systems: durations (ms), easings as bezier arrays, springs (9.8). */
|
|
84
|
+
declare function nativeTokens(): {
|
|
85
|
+
duration: Record<string, number>;
|
|
86
|
+
easing: Record<string, number[]>;
|
|
87
|
+
spring: Record<string, {
|
|
88
|
+
stiffness: number;
|
|
89
|
+
damping: number;
|
|
90
|
+
mass: number;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export { entranceFrom, nativeEasing, nativeTokens, toFlutter, toReactNative };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { parseMotion } from './dsl.js';
|
|
2
|
+
import { easingPoints } from './design.js';
|
|
3
|
+
import { MOTION_TOKENS } from './tokens.js';
|
|
4
|
+
import '../chunks/registry-gFJRpPES.js';
|
|
5
|
+
import '../chunks/base-BnRyfuyM.js';
|
|
6
|
+
import '../chunks/core-DsGoL9EY.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `motionary/native` (= `motionary/components/native`, 9.8) — native 2.0:
|
|
10
|
+
* take the motion you designed on the web to React Native and Flutter.
|
|
11
|
+
*
|
|
12
|
+
* - `toReactNative(rules, { name })` — a React Native component (Animated +
|
|
13
|
+
* Easing.bezier / spring) for the entrance and press rules of a motion
|
|
14
|
+
* string.
|
|
15
|
+
* - `toFlutter(rules, { name })` — a Flutter widget (AnimationController +
|
|
16
|
+
* Cubic curves) for the same rules.
|
|
17
|
+
* - `nativeEasing(easing, 'react-native' | 'flutter')` — a CSS easing as
|
|
18
|
+
* `Easing.bezier(…)` / `Cubic(…)`.
|
|
19
|
+
* - `nativeTokens()` — Motionary's motion tokens (durations, easings as
|
|
20
|
+
* bezier arrays, springs) as JSON for native design systems.
|
|
21
|
+
*
|
|
22
|
+
* Complete sample apps live in `examples/native/react-native` and
|
|
23
|
+
* `examples/native/flutter`.
|
|
24
|
+
*/
|
|
25
|
+
const NAMED = { spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)', smooth: 'cubic-bezier(0.22, 1, 0.36, 1)' };
|
|
26
|
+
/** A CSS easing as React Native `Easing.bezier(…)` or Flutter `Cubic(…)` (9.8). */
|
|
27
|
+
function nativeEasing(easing, platform) {
|
|
28
|
+
const p = easingPoints(NAMED[easing || ''] || easing || 'cubic-bezier(0.22, 1, 0.36, 1)');
|
|
29
|
+
return platform === 'flutter' ? `Cubic(${p.join(', ')})` : `Easing.bezier(${p.join(', ')})`;
|
|
30
|
+
}
|
|
31
|
+
/** Start values for an entrance preset: opacity, translate x / y (dp), scale (9.8). */
|
|
32
|
+
function entranceFrom(effect) {
|
|
33
|
+
const m = { 'fade-up': [0, 24, 1], 'fade-down': [0, -24, 1], 'fade-left': [24, 0, 1], 'fade-right': [-24, 0, 1], scale: [0, 0, 0.85], 'zoom-in': [0, 0, 0.6], 'zoom-out': [0, 0, 1.2] };
|
|
34
|
+
const [x, y, s] = m[effect] || [0, 0, 1];
|
|
35
|
+
return { opacity: 0, x, y, scale: s };
|
|
36
|
+
}
|
|
37
|
+
const ident = (s) => s.replace(/(^|[-_\s]+)([a-z0-9])/gi, (_, __, c) => c.toUpperCase()).replace(/[^A-Za-z0-9]/g, '') || 'Motion';
|
|
38
|
+
const rulesOf = (r) => (typeof r === 'string' ? parseMotion(r).rules : r);
|
|
39
|
+
/** A React Native component for a motion string (entrance on mount, `pop` / press rules on press) (9.8). */
|
|
40
|
+
function toReactNative(rules, opts = {}) {
|
|
41
|
+
const rs = rulesOf(rules);
|
|
42
|
+
const name = ident(opts.name || 'MotionView');
|
|
43
|
+
const enter = rs.find((r) => r.trigger === 'enter' || r.trigger === 'load');
|
|
44
|
+
const press = rs.find((r) => r.trigger === 'click' || r.trigger === 'hover');
|
|
45
|
+
const f = entranceFrom(enter?.effect || 'fade');
|
|
46
|
+
const lines = [
|
|
47
|
+
`// Generated by motionary/native (9.8) from: ${rs.map((r) => `${r.trigger}: ${r.effect}`).join('; ') || '—'}`,
|
|
48
|
+
`import React, { useEffect, useRef } from 'react';`,
|
|
49
|
+
`import { Animated, Easing, ${press ? 'Pressable, ' : ''}AccessibilityInfo } from 'react-native';`,
|
|
50
|
+
``,
|
|
51
|
+
`export function ${name}({ children, index = 0, onPress }) {`,
|
|
52
|
+
` const t = useRef(new Animated.Value(0)).current;`,
|
|
53
|
+
` const s = useRef(new Animated.Value(1)).current;`,
|
|
54
|
+
` useEffect(() => {`,
|
|
55
|
+
` AccessibilityInfo.isReduceMotionEnabled().then((reduce) => {`,
|
|
56
|
+
` if (reduce) return t.setValue(1);`,
|
|
57
|
+
` Animated.timing(t, { toValue: 1, duration: ${enter?.duration ?? 600}, delay: ${enter?.delay ?? 0} + index * ${enter?.stagger ?? 0}, easing: ${nativeEasing(enter?.easing, 'react-native')}, useNativeDriver: true }).start();`,
|
|
58
|
+
` });`,
|
|
59
|
+
` }, []);`,
|
|
60
|
+
` const style = {`,
|
|
61
|
+
` opacity: t.interpolate({ inputRange: [0, 1], outputRange: [${f.opacity}, 1] }),`,
|
|
62
|
+
` transform: [`,
|
|
63
|
+
` { translateX: t.interpolate({ inputRange: [0, 1], outputRange: [${f.x}, 0] }) },`,
|
|
64
|
+
` { translateY: t.interpolate({ inputRange: [0, 1], outputRange: [${f.y}, 0] }) },`,
|
|
65
|
+
` { scale: Animated.multiply(s, t.interpolate({ inputRange: [0, 1], outputRange: [${f.scale}, 1] })) },`,
|
|
66
|
+
` ],`,
|
|
67
|
+
` };`,
|
|
68
|
+
];
|
|
69
|
+
if (press) {
|
|
70
|
+
lines.push(` const pressIn = () => Animated.spring(s, { toValue: 0.92, stiffness: ${MOTION_TOKENS.spring.snappy.stiffness}, damping: ${MOTION_TOKENS.spring.snappy.damping}, useNativeDriver: true }).start();`, ` const pressOut = () => Animated.spring(s, { toValue: 1, stiffness: ${MOTION_TOKENS.spring.bouncy.stiffness}, damping: ${MOTION_TOKENS.spring.bouncy.damping}, useNativeDriver: true }).start();`, ` return (`, ` <Pressable onPressIn={pressIn} onPressOut={pressOut} onPress={onPress}>`, ` <Animated.View style={style}>{children}</Animated.View>`, ` </Pressable>`, ` );`);
|
|
71
|
+
}
|
|
72
|
+
else
|
|
73
|
+
lines.push(` return <Animated.View style={style}>{children}</Animated.View>;`);
|
|
74
|
+
lines.push(`}`, ``);
|
|
75
|
+
return lines.join('\n');
|
|
76
|
+
}
|
|
77
|
+
/** A Flutter widget for a motion string (entrance on first build, press spring) (9.8). */
|
|
78
|
+
function toFlutter(rules, opts = {}) {
|
|
79
|
+
const rs = rulesOf(rules);
|
|
80
|
+
const name = ident(opts.name || 'MotionView');
|
|
81
|
+
const enter = rs.find((r) => r.trigger === 'enter' || r.trigger === 'load');
|
|
82
|
+
const press = rs.some((r) => r.trigger === 'click' || r.trigger === 'hover');
|
|
83
|
+
const f = entranceFrom(enter?.effect || 'fade');
|
|
84
|
+
return [
|
|
85
|
+
`// Generated by motionary/native (9.8) from: ${rs.map((r) => `${r.trigger}: ${r.effect}`).join('; ') || '—'}`,
|
|
86
|
+
`import 'package:flutter/material.dart';`,
|
|
87
|
+
``,
|
|
88
|
+
`class ${name} extends StatefulWidget {`,
|
|
89
|
+
` const ${name}({super.key, required this.child, this.index = 0, this.onTap});`,
|
|
90
|
+
` final Widget child;`,
|
|
91
|
+
` final int index;`,
|
|
92
|
+
` final VoidCallback? onTap;`,
|
|
93
|
+
` @override`,
|
|
94
|
+
` State<${name}> createState() => _${name}State();`,
|
|
95
|
+
`}`,
|
|
96
|
+
``,
|
|
97
|
+
`class _${name}State extends State<${name}> with SingleTickerProviderStateMixin {`,
|
|
98
|
+
` late final AnimationController _c = AnimationController(vsync: this, duration: const Duration(milliseconds: ${enter?.duration ?? 600}));`,
|
|
99
|
+
` late final Animation<double> _t = CurvedAnimation(parent: _c, curve: const ${nativeEasing(enter?.easing, 'flutter')});`,
|
|
100
|
+
` double _scale = 1;`,
|
|
101
|
+
``,
|
|
102
|
+
` @override`,
|
|
103
|
+
` void didChangeDependencies() {`,
|
|
104
|
+
` super.didChangeDependencies();`,
|
|
105
|
+
` if (MediaQuery.of(context).disableAnimations) { _c.value = 1; return; }`,
|
|
106
|
+
` Future.delayed(Duration(milliseconds: ${enter?.delay ?? 0} + widget.index * ${enter?.stagger ?? 0}), () { if (mounted) _c.forward(); });`,
|
|
107
|
+
` }`,
|
|
108
|
+
``,
|
|
109
|
+
` @override`,
|
|
110
|
+
` void dispose() { _c.dispose(); super.dispose(); }`,
|
|
111
|
+
``,
|
|
112
|
+
` @override`,
|
|
113
|
+
` Widget build(BuildContext context) {`,
|
|
114
|
+
` Widget w = AnimatedBuilder(`,
|
|
115
|
+
` animation: _t,`,
|
|
116
|
+
` builder: (context, child) => Opacity(`,
|
|
117
|
+
` opacity: ${f.opacity} + (1 - ${f.opacity}) * _t.value,`,
|
|
118
|
+
` child: Transform.translate(`,
|
|
119
|
+
` offset: Offset(${f.x} * (1 - _t.value), ${f.y} * (1 - _t.value)),`,
|
|
120
|
+
` child: Transform.scale(scale: ${f.scale} + (1 - ${f.scale}) * _t.value, child: child),`,
|
|
121
|
+
` ),`,
|
|
122
|
+
` ),`,
|
|
123
|
+
` child: widget.child,`,
|
|
124
|
+
` );`,
|
|
125
|
+
press
|
|
126
|
+
? ` return GestureDetector(\n onTapDown: (_) => setState(() => _scale = 0.92),\n onTapUp: (_) => setState(() => _scale = 1),\n onTapCancel: () => setState(() => _scale = 1),\n onTap: widget.onTap,\n child: AnimatedScale(scale: _scale, duration: const Duration(milliseconds: 180), curve: Curves.easeOutBack, child: w),\n );`
|
|
127
|
+
: ` return w;`,
|
|
128
|
+
` }`,
|
|
129
|
+
`}`,
|
|
130
|
+
``,
|
|
131
|
+
].join('\n');
|
|
132
|
+
}
|
|
133
|
+
/** Motion tokens for native design systems: durations (ms), easings as bezier arrays, springs (9.8). */
|
|
134
|
+
function nativeTokens() {
|
|
135
|
+
const easing = {};
|
|
136
|
+
for (const [k, v] of Object.entries(MOTION_TOKENS.easing))
|
|
137
|
+
easing[k] = easingPoints(v);
|
|
138
|
+
return { duration: { ...MOTION_TOKENS.duration }, easing, spring: JSON.parse(JSON.stringify(MOTION_TOKENS.spring)) };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { entranceFrom, nativeEasing, nativeTokens, toFlutter, toReactNative };
|
|
142
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.js","sources":["../../src/components/native/index.ts"],"sourcesContent":["/**\n * `motionary/native` (= `motionary/components/native`, 9.8) — native 2.0:\n * take the motion you designed on the web to React Native and Flutter.\n *\n * - `toReactNative(rules, { name })` — a React Native component (Animated +\n * Easing.bezier / spring) for the entrance and press rules of a motion\n * string.\n * - `toFlutter(rules, { name })` — a Flutter widget (AnimationController +\n * Cubic curves) for the same rules.\n * - `nativeEasing(easing, 'react-native' | 'flutter')` — a CSS easing as\n * `Easing.bezier(…)` / `Cubic(…)`.\n * - `nativeTokens()` — Motionary's motion tokens (durations, easings as\n * bezier arrays, springs) as JSON for native design systems.\n *\n * Complete sample apps live in `examples/native/react-native` and\n * `examples/native/flutter`.\n */\nimport { parseMotion, type MotionRule } from '../dsl/index';\nimport { easingPoints } from '../design/index';\nimport { MOTION_TOKENS } from '../tokens/index';\n\ntype Platform = 'react-native' | 'flutter';\nconst NAMED: Record<string, string> = { spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)', smooth: 'cubic-bezier(0.22, 1, 0.36, 1)' };\n/** A CSS easing as React Native `Easing.bezier(…)` or Flutter `Cubic(…)` (9.8). */\nexport function nativeEasing(easing: string | undefined, platform: Platform): string {\n const p = easingPoints(NAMED[easing || ''] || easing || 'cubic-bezier(0.22, 1, 0.36, 1)');\n return platform === 'flutter' ? `Cubic(${p.join(', ')})` : `Easing.bezier(${p.join(', ')})`;\n}\n\n/** Start values for an entrance preset: opacity, translate x / y (dp), scale (9.8). */\nexport function entranceFrom(effect: string): { opacity: number; x: number; y: number; scale: number } {\n const m: Record<string, [number, number, number]> = { 'fade-up': [0, 24, 1], 'fade-down': [0, -24, 1], 'fade-left': [24, 0, 1], 'fade-right': [-24, 0, 1], scale: [0, 0, 0.85], 'zoom-in': [0, 0, 0.6], 'zoom-out': [0, 0, 1.2] };\n const [x, y, s] = m[effect] || [0, 0, 1];\n return { opacity: 0, x, y, scale: s };\n}\n\nconst ident = (s: string) => s.replace(/(^|[-_\\s]+)([a-z0-9])/gi, (_, __, c) => c.toUpperCase()).replace(/[^A-Za-z0-9]/g, '') || 'Motion';\nconst rulesOf = (r: string | MotionRule[]) => (typeof r === 'string' ? parseMotion(r).rules : r);\n\n/** A React Native component for a motion string (entrance on mount, `pop` / press rules on press) (9.8). */\nexport function toReactNative(rules: string | MotionRule[], opts: { name?: string } = {}): string {\n const rs = rulesOf(rules);\n const name = ident(opts.name || 'MotionView');\n const enter = rs.find((r) => r.trigger === 'enter' || r.trigger === 'load');\n const press = rs.find((r) => r.trigger === 'click' || r.trigger === 'hover');\n const f = entranceFrom(enter?.effect || 'fade');\n const lines = [\n `// Generated by motionary/native (9.8) from: ${rs.map((r) => `${r.trigger}: ${r.effect}`).join('; ') || '—'}`,\n `import React, { useEffect, useRef } from 'react';`,\n `import { Animated, Easing, ${press ? 'Pressable, ' : ''}AccessibilityInfo } from 'react-native';`,\n ``,\n `export function ${name}({ children, index = 0, onPress }) {`,\n ` const t = useRef(new Animated.Value(0)).current;`,\n ` const s = useRef(new Animated.Value(1)).current;`,\n ` useEffect(() => {`,\n ` AccessibilityInfo.isReduceMotionEnabled().then((reduce) => {`,\n ` if (reduce) return t.setValue(1);`,\n ` Animated.timing(t, { toValue: 1, duration: ${enter?.duration ?? 600}, delay: ${enter?.delay ?? 0} + index * ${enter?.stagger ?? 0}, easing: ${nativeEasing(enter?.easing, 'react-native')}, useNativeDriver: true }).start();`,\n ` });`,\n ` }, []);`,\n ` const style = {`,\n ` opacity: t.interpolate({ inputRange: [0, 1], outputRange: [${f.opacity}, 1] }),`,\n ` transform: [`,\n ` { translateX: t.interpolate({ inputRange: [0, 1], outputRange: [${f.x}, 0] }) },`,\n ` { translateY: t.interpolate({ inputRange: [0, 1], outputRange: [${f.y}, 0] }) },`,\n ` { scale: Animated.multiply(s, t.interpolate({ inputRange: [0, 1], outputRange: [${f.scale}, 1] })) },`,\n ` ],`,\n ` };`,\n ];\n if (press) {\n lines.push(\n ` const pressIn = () => Animated.spring(s, { toValue: 0.92, stiffness: ${MOTION_TOKENS.spring.snappy.stiffness}, damping: ${MOTION_TOKENS.spring.snappy.damping}, useNativeDriver: true }).start();`,\n ` const pressOut = () => Animated.spring(s, { toValue: 1, stiffness: ${MOTION_TOKENS.spring.bouncy.stiffness}, damping: ${MOTION_TOKENS.spring.bouncy.damping}, useNativeDriver: true }).start();`,\n ` return (`,\n ` <Pressable onPressIn={pressIn} onPressOut={pressOut} onPress={onPress}>`,\n ` <Animated.View style={style}>{children}</Animated.View>`,\n ` </Pressable>`,\n ` );`\n );\n } else lines.push(` return <Animated.View style={style}>{children}</Animated.View>;`);\n lines.push(`}`, ``);\n return lines.join('\\n');\n}\n\n/** A Flutter widget for a motion string (entrance on first build, press spring) (9.8). */\nexport function toFlutter(rules: string | MotionRule[], opts: { name?: string } = {}): string {\n const rs = rulesOf(rules);\n const name = ident(opts.name || 'MotionView');\n const enter = rs.find((r) => r.trigger === 'enter' || r.trigger === 'load');\n const press = rs.some((r) => r.trigger === 'click' || r.trigger === 'hover');\n const f = entranceFrom(enter?.effect || 'fade');\n return [\n `// Generated by motionary/native (9.8) from: ${rs.map((r) => `${r.trigger}: ${r.effect}`).join('; ') || '—'}`,\n `import 'package:flutter/material.dart';`,\n ``,\n `class ${name} extends StatefulWidget {`,\n ` const ${name}({super.key, required this.child, this.index = 0, this.onTap});`,\n ` final Widget child;`,\n ` final int index;`,\n ` final VoidCallback? onTap;`,\n ` @override`,\n ` State<${name}> createState() => _${name}State();`,\n `}`,\n ``,\n `class _${name}State extends State<${name}> with SingleTickerProviderStateMixin {`,\n ` late final AnimationController _c = AnimationController(vsync: this, duration: const Duration(milliseconds: ${enter?.duration ?? 600}));`,\n ` late final Animation<double> _t = CurvedAnimation(parent: _c, curve: const ${nativeEasing(enter?.easing, 'flutter')});`,\n ` double _scale = 1;`,\n ``,\n ` @override`,\n ` void didChangeDependencies() {`,\n ` super.didChangeDependencies();`,\n ` if (MediaQuery.of(context).disableAnimations) { _c.value = 1; return; }`,\n ` Future.delayed(Duration(milliseconds: ${enter?.delay ?? 0} + widget.index * ${enter?.stagger ?? 0}), () { if (mounted) _c.forward(); });`,\n ` }`,\n ``,\n ` @override`,\n ` void dispose() { _c.dispose(); super.dispose(); }`,\n ``,\n ` @override`,\n ` Widget build(BuildContext context) {`,\n ` Widget w = AnimatedBuilder(`,\n ` animation: _t,`,\n ` builder: (context, child) => Opacity(`,\n ` opacity: ${f.opacity} + (1 - ${f.opacity}) * _t.value,`,\n ` child: Transform.translate(`,\n ` offset: Offset(${f.x} * (1 - _t.value), ${f.y} * (1 - _t.value)),`,\n ` child: Transform.scale(scale: ${f.scale} + (1 - ${f.scale}) * _t.value, child: child),`,\n ` ),`,\n ` ),`,\n ` child: widget.child,`,\n ` );`,\n press\n ? ` return GestureDetector(\\n onTapDown: (_) => setState(() => _scale = 0.92),\\n onTapUp: (_) => setState(() => _scale = 1),\\n onTapCancel: () => setState(() => _scale = 1),\\n onTap: widget.onTap,\\n child: AnimatedScale(scale: _scale, duration: const Duration(milliseconds: 180), curve: Curves.easeOutBack, child: w),\\n );`\n : ` return w;`,\n ` }`,\n `}`,\n ``,\n ].join('\\n');\n}\n\n/** Motion tokens for native design systems: durations (ms), easings as bezier arrays, springs (9.8). */\nexport function nativeTokens(): { duration: Record<string, number>; easing: Record<string, number[]>; spring: Record<string, { stiffness: number; damping: number; mass: number }> } {\n const easing: Record<string, number[]> = {};\n for (const [k, v] of Object.entries(MOTION_TOKENS.easing)) easing[k] = easingPoints(v);\n return { duration: { ...MOTION_TOKENS.duration }, easing, spring: JSON.parse(JSON.stringify(MOTION_TOKENS.spring)) };\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;AAgBG;AAMH,MAAM,KAAK,GAA2B,EAAE,MAAM,EAAE,mCAAmC,EAAE,MAAM,EAAE,gCAAgC,EAAE;AAC/H;AACM,SAAU,YAAY,CAAC,MAA0B,EAAE,QAAkB,EAAA;AACzE,IAAA,MAAM,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,IAAI,MAAM,IAAI,gCAAgC,CAAC;IACzF,OAAO,QAAQ,KAAK,SAAS,GAAG,CAAA,MAAA,EAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG,GAAG,CAAA,cAAA,EAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;AAC7F;AAEA;AACM,SAAU,YAAY,CAAC,MAAc,EAAA;AACzC,IAAA,MAAM,CAAC,GAA6C,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAA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@
|
|
|
1
|
-
import { p as prefersReducedMotion, q as now, m as motionScale, r as raf, D as EASE_OUT, k as clamp, E as EASE_SPRING, u as defineElement } from '../chunks/base-
|
|
1
|
+
import { p as prefersReducedMotion, q as now, m as motionScale, r as raf, D as EASE_OUT, k as clamp, E as EASE_SPRING, u as defineElement } from '../chunks/base-BnRyfuyM.js';
|
|
2
2
|
|
|
3
3
|
const anim = (el, frames, o) => {
|
|
4
4
|
if (typeof el.animate !== 'function')
|
package/dist/components/page.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var base = require('../chunks/base-
|
|
4
|
-
var spring = require('../chunks/spring-
|
|
3
|
+
var base = require('../chunks/base-DBheNxJu.cjs');
|
|
4
|
+
var spring = require('../chunks/spring-BlTQD2AV.cjs');
|
|
5
5
|
|
|
6
6
|
var css$8 = "usa-cursor{--usa-cursor-color:var(--usa-accent,#7c5cff);--usa-cursor-size:28px;position:fixed;inset:0;pointer-events:none;z-index:2147483600;opacity:0;transition:opacity 0.2s ease;contain:strict}usa-cursor[data-active]{opacity:1}usa-cursor .usa-cursor-ring{position:absolute;left:0;top:0;width:var(--usa-cursor-size);height:var(--usa-cursor-size);margin:calc(var(--usa-cursor-size) / -2) 0 0 calc(var(--usa-cursor-size) / -2);border:1.5px solid var(--usa-cursor-color);border-radius:999px;box-sizing:border-box;transition:width 0.25s cubic-bezier(0.34,1.56,0.64,1),height 0.25s cubic-bezier(0.34,1.56,0.64,1),margin 0.25s ease,border-radius 0.25s ease,background-color 0.2s ease;will-change:transform}usa-cursor[data-hover] .usa-cursor-ring:first-child{width:calc(var(--usa-cursor-size) * 1.6);height:calc(var(--usa-cursor-size) * 1.6);margin:calc(var(--usa-cursor-size) * -0.8) 0 0 calc(var(--usa-cursor-size) * -0.8);background:color-mix(in srgb,var(--usa-cursor-color) 15%,transparent)}usa-cursor[data-snapped] .usa-cursor-ring{border-radius:12px;background:color-mix(in srgb,var(--usa-cursor-color) 12%,transparent);translate:-50% -50%;margin:0}usa-cursor[data-down] .usa-cursor-ring:first-child{scale:0.8}usa-cursor .usa-cursor-dot{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:var(--usa-cursor-color)}usa-cursor[data-snapped] .usa-cursor-dot{opacity:0}usa-cursor .usa-cursor-glow{position:absolute;left:-200px;top:-200px;width:400px;height:400px;border-radius:50%;background:radial-gradient(circle,color-mix(in srgb,var(--usa-cursor-color) 35%,transparent),transparent 65%);mix-blend-mode:screen}.usa-cursor-none,.usa-cursor-none *{cursor:none !important}@media (pointer:coarse),(prefers-reduced-motion:reduce){usa-cursor{display:none}.usa-cursor-none,.usa-cursor-none *{cursor:auto !important}}";
|
|
7
7
|
|
package/dist/components/page.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as defineElement, l as caf, r as raf, p as prefersReducedMotion, q as now, i as getMotionSensitivity, h as getMotionIntensity, g as configureComponents, B as adoptStyles } from '../chunks/base-
|
|
2
|
-
export { M as MOTION_SCALE } from '../chunks/base-
|
|
3
|
-
import { e as springSamples } from '../chunks/spring-
|
|
1
|
+
import { u as defineElement, l as caf, r as raf, p as prefersReducedMotion, q as now, i as getMotionSensitivity, h as getMotionIntensity, g as configureComponents, B as adoptStyles } from '../chunks/base-BnRyfuyM.js';
|
|
2
|
+
export { M as MOTION_SCALE } from '../chunks/base-BnRyfuyM.js';
|
|
3
|
+
import { e as springSamples } from '../chunks/spring-CZDNyqWp.js';
|
|
4
4
|
|
|
5
5
|
var css$8 = "usa-cursor{--usa-cursor-color:var(--usa-accent,#7c5cff);--usa-cursor-size:28px;position:fixed;inset:0;pointer-events:none;z-index:2147483600;opacity:0;transition:opacity 0.2s ease;contain:strict}usa-cursor[data-active]{opacity:1}usa-cursor .usa-cursor-ring{position:absolute;left:0;top:0;width:var(--usa-cursor-size);height:var(--usa-cursor-size);margin:calc(var(--usa-cursor-size) / -2) 0 0 calc(var(--usa-cursor-size) / -2);border:1.5px solid var(--usa-cursor-color);border-radius:999px;box-sizing:border-box;transition:width 0.25s cubic-bezier(0.34,1.56,0.64,1),height 0.25s cubic-bezier(0.34,1.56,0.64,1),margin 0.25s ease,border-radius 0.25s ease,background-color 0.2s ease;will-change:transform}usa-cursor[data-hover] .usa-cursor-ring:first-child{width:calc(var(--usa-cursor-size) * 1.6);height:calc(var(--usa-cursor-size) * 1.6);margin:calc(var(--usa-cursor-size) * -0.8) 0 0 calc(var(--usa-cursor-size) * -0.8);background:color-mix(in srgb,var(--usa-cursor-color) 15%,transparent)}usa-cursor[data-snapped] .usa-cursor-ring{border-radius:12px;background:color-mix(in srgb,var(--usa-cursor-color) 12%,transparent);translate:-50% -50%;margin:0}usa-cursor[data-down] .usa-cursor-ring:first-child{scale:0.8}usa-cursor .usa-cursor-dot{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:var(--usa-cursor-color)}usa-cursor[data-snapped] .usa-cursor-dot{opacity:0}usa-cursor .usa-cursor-glow{position:absolute;left:-200px;top:-200px;width:400px;height:400px;border-radius:50%;background:radial-gradient(circle,color-mix(in srgb,var(--usa-cursor-color) 35%,transparent),transparent 65%);mix-blend-mode:screen}.usa-cursor-none,.usa-cursor-none *{cursor:none !important}@media (pointer:coarse),(prefers-reduced-motion:reduce){usa-cursor{display:none}.usa-cursor-none,.usa-cursor-none *{cursor:auto !important}}";
|
|
6
6
|
|
package/dist/components/perf.cjs
CHANGED
package/dist/components/perf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as onFrame, t as setStyleLoader, f as animationBudget, h as getMotionIntensity, g as configureComponents, j as setAnimationBudget, b as activeAnimations } from '../chunks/base-
|
|
2
|
-
export { s as schedulerStats } from '../chunks/base-
|
|
1
|
+
import { o as onFrame, t as setStyleLoader, f as animationBudget, h as getMotionIntensity, g as configureComponents, j as setAnimationBudget, b as activeAnimations } from '../chunks/base-BnRyfuyM.js';
|
|
2
|
+
export { s as schedulerStats } from '../chunks/base-BnRyfuyM.js';
|
|
3
3
|
import { C as COMPONENT_CATEGORIES } from '../chunks/index-tags-B-JBecYg.js';
|
|
4
4
|
|
|
5
5
|
/**
|