@nexub/react-native 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { FadeIn, FadeInDown, FadeInUp, FadeOut, FadeOutDown, FadeOutUp, LinearTransition, ReduceMotion, SlideOutLeft, SlideOutRight, ZoomIn, ZoomOut } from 'react-native-reanimated';
|
|
4
4
|
import { native } from '@nexub/tokens/native';
|
|
5
5
|
|
|
6
6
|
// Layout-animation presets built from the same spring tokens as the web
|
|
@@ -30,38 +30,7 @@ const EXIT = {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* same rule @nexub/tokens uses for the CSS spring durations.
|
|
35
|
-
*/
|
|
36
|
-
export function springSettleMs({
|
|
37
|
-
stiffness,
|
|
38
|
-
damping,
|
|
39
|
-
mass
|
|
40
|
-
}) {
|
|
41
|
-
const dt = 1 / 1000;
|
|
42
|
-
let x = 0;
|
|
43
|
-
let v = 0;
|
|
44
|
-
let still = 0;
|
|
45
|
-
for (let t = 0; t < 3; t += dt) {
|
|
46
|
-
const a = (stiffness * (1 - x) - damping * v) / mass;
|
|
47
|
-
v += a * dt;
|
|
48
|
-
x += v * dt;
|
|
49
|
-
still = Math.abs(1 - x) < 0.001 && Math.abs(v) < 0.01 ? still + 1 : 0;
|
|
50
|
-
if (still > 16) return Math.round((t - 0.016) * 1000);
|
|
51
|
-
}
|
|
52
|
-
return 3000;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Enter and exit run as timed animations lasting the spring token's settle
|
|
56
|
-
// time, on the system decelerate / accelerate curves: Reanimated's
|
|
57
|
-
// physics-spring entering animations (`springify()` with stiffness/damping)
|
|
58
|
-
// left entering views invisible on iOS. Layout transitions move views that are
|
|
59
|
-
// already visible, so they keep the physics spring.
|
|
60
|
-
const decelerate = Easing.bezier(0, 0, 0.2, 1);
|
|
61
|
-
const accelerate = Easing.bezier(0.4, 0, 1, 1);
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* `entering` animation, timed to the spatial spring.
|
|
33
|
+
* `entering` animation on the spatial spring.
|
|
65
34
|
* `up` rises into place (rows, toasts from below); `down` drops in (banners).
|
|
66
35
|
*
|
|
67
36
|
* ```tsx
|
|
@@ -69,16 +38,18 @@ const accelerate = Easing.bezier(0.4, 0, 1, 1);
|
|
|
69
38
|
* ```
|
|
70
39
|
*/
|
|
71
40
|
export function nxEnter(kind = 'fade', speed = 'default') {
|
|
72
|
-
|
|
41
|
+
const s = native.motion.spring.spatial[speed];
|
|
42
|
+
return ENTER[kind].springify().stiffness(s.stiffness).damping(s.damping).mass(s.mass).reduceMotion(ReduceMotion.System);
|
|
73
43
|
}
|
|
74
44
|
|
|
75
45
|
/**
|
|
76
|
-
* `exiting` animation
|
|
46
|
+
* `exiting` animation on the effects spring: quicker than enter, no overshoot.
|
|
77
47
|
* `start` / `end` slide out toward that edge (swipe-to-delete), following RTL.
|
|
78
48
|
*/
|
|
79
49
|
export function nxExit(kind = 'fade', speed = 'fast', rtl = false) {
|
|
50
|
+
const s = native.motion.spring.effects[speed];
|
|
80
51
|
const builder = kind === 'start' || kind === 'end' ? kind === 'start' !== rtl ? SlideOutLeft : SlideOutRight : EXIT[kind];
|
|
81
|
-
return builder.
|
|
52
|
+
return builder.springify().stiffness(s.stiffness).damping(s.damping).mass(s.mass).reduceMotion(ReduceMotion.System);
|
|
82
53
|
}
|
|
83
54
|
|
|
84
55
|
/** `layout` transition: siblings glide to their new place on the spatial spring. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["FadeIn","FadeInDown","FadeInUp","FadeOut","FadeOutDown","FadeOutUp","LinearTransition","ReduceMotion","SlideOutLeft","SlideOutRight","ZoomIn","ZoomOut","native","nxSpring","family","speed","motion","spring","reduceMotion","System","ENTER","fade","up","down","scale","EXIT","nxEnter","kind","s","spatial","springify","stiffness","damping","mass","nxExit","rtl","effects","builder","nxLayout"],"sourceRoot":"../../../src","sources":["theme/motion.ts"],"mappings":";;AAAA,SACEA,MAAM,EACNC,UAAU,EACVC,QAAQ,EACRC,OAAO,EACPC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,aAAa,EACbC,MAAM,EACNC,OAAO,QACF,yBAAyB;AAChC,SAASC,MAAM,QAAQ,sBAAsB;;AAE7C;AACA;AACA;AACA;AACA;;AAKA;AACA,OAAO,SAASC,QAAQA,CAACC,MAAoB,GAAG,SAAS,EAAEC,KAAkB,GAAG,SAAS,EAAE;EACzF,OAAO;IAAE,GAAGH,MAAM,CAACI,MAAM,CAACC,MAAM,CAACH,MAAM,CAAC,CAACC,KAAK,CAAC;IAAEG,YAAY,EAAEX,YAAY,CAACY;EAAO,CAAC;AACtF;AAKA,MAAMC,KAAK,GAAG;EAAEC,IAAI,EAAErB,MAAM;EAAEsB,EAAE,EAAEpB,QAAQ;EAAEqB,IAAI,EAAEtB,UAAU;EAAEuB,KAAK,EAAEd;AAAO,CAAU;AACtF,MAAMe,IAAI,GAAG;EAAEJ,IAAI,EAAElB,OAAO;EAAEmB,EAAE,EAAEjB,SAAS;EAAEkB,IAAI,EAAEnB,WAAW;EAAEoB,KAAK,EAAEb;AAAQ,CAAU;;AAEzF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASe,OAAOA,CAACC,IAAe,GAAG,MAAM,EAAEZ,KAAkB,GAAG,SAAS,EAAE;EAChF,MAAMa,CAAC,GAAGhB,MAAM,CAACI,MAAM,CAACC,MAAM,CAACY,OAAO,CAACd,KAAK,CAAC;EAC7C,OAAOK,KAAK,CAACO,IAAI,CAAC,CACfG,SAAS,CAAC,CAAC,CACXC,SAAS,CAACH,CAAC,CAACG,SAAS,CAAC,CACtBC,OAAO,CAACJ,CAAC,CAACI,OAAO,CAAC,CAClBC,IAAI,CAACL,CAAC,CAACK,IAAI,CAAC,CACZf,YAAY,CAACX,YAAY,CAACY,MAAM,CAAC;AACtC;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASe,MAAMA,CAACP,IAAc,GAAG,MAAM,EAAEZ,KAAkB,GAAG,MAAM,EAAEoB,GAAG,GAAG,KAAK,EAAE;EACxF,MAAMP,CAAC,GAAGhB,MAAM,CAACI,MAAM,CAACC,MAAM,CAACmB,OAAO,CAACrB,KAAK,CAAC;EAC7C,MAAMsB,OAAO,GACXV,IAAI,KAAK,OAAO,IAAIA,IAAI,KAAK,KAAK,GAC7BA,IAAI,KAAK,OAAO,KAAMQ,GAAG,GACxB3B,YAAY,GACZC,aAAa,GACfgB,IAAI,CAACE,IAAI,CAAC;EAChB,OAAOU,OAAO,CACXP,SAAS,CAAC,CAAC,CACXC,SAAS,CAACH,CAAC,CAACG,SAAS,CAAC,CACtBC,OAAO,CAACJ,CAAC,CAACI,OAAO,CAAC,CAClBC,IAAI,CAACL,CAAC,CAACK,IAAI,CAAC,CACZf,YAAY,CAACX,YAAY,CAACY,MAAM,CAAC;AACtC;;AAEA;AACA,OAAO,SAASmB,QAAQA,CAACvB,KAAkB,GAAG,SAAS,EAAE;EACvD,MAAMa,CAAC,GAAGhB,MAAM,CAACI,MAAM,CAACC,MAAM,CAACY,OAAO,CAACd,KAAK,CAAC;EAC7C,OAAOT,gBAAgB,CAACwB,SAAS,CAAC,CAAC,CAChCC,SAAS,CAACH,CAAC,CAACG,SAAS,CAAC,CACtBC,OAAO,CAACJ,CAAC,CAACI,OAAO,CAAC,CAClBC,IAAI,CAACL,CAAC,CAACK,IAAI,CAAC,CACZf,YAAY,CAACX,YAAY,CAACY,MAAM,CAAC;AACtC","ignoreList":[]}
|
|
@@ -52,16 +52,7 @@ export declare function nxSpring(family?: SpringFamily, speed?: SpringSpeed): {
|
|
|
52
52
|
export type EnterKind = 'fade' | 'up' | 'down' | 'scale';
|
|
53
53
|
export type ExitKind = 'fade' | 'up' | 'down' | 'scale' | 'start' | 'end';
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
* same rule @nexub/tokens uses for the CSS spring durations.
|
|
57
|
-
*/
|
|
58
|
-
export declare function springSettleMs({ stiffness, damping, mass }: {
|
|
59
|
-
stiffness: number;
|
|
60
|
-
damping: number;
|
|
61
|
-
mass: number;
|
|
62
|
-
}): number;
|
|
63
|
-
/**
|
|
64
|
-
* `entering` animation, timed to the spatial spring.
|
|
55
|
+
* `entering` animation on the spatial spring.
|
|
65
56
|
* `up` rises into place (rows, toasts from below); `down` drops in (banners).
|
|
66
57
|
*
|
|
67
58
|
* ```tsx
|
|
@@ -70,7 +61,7 @@ export declare function springSettleMs({ stiffness, damping, mass }: {
|
|
|
70
61
|
*/
|
|
71
62
|
export declare function nxEnter(kind?: EnterKind, speed?: SpringSpeed): FadeIn | FadeInUp | FadeInDown | ZoomIn;
|
|
72
63
|
/**
|
|
73
|
-
* `exiting` animation
|
|
64
|
+
* `exiting` animation on the effects spring: quicker than enter, no overshoot.
|
|
74
65
|
* `start` / `end` slide out toward that edge (swipe-to-delete), following RTL.
|
|
75
66
|
*/
|
|
76
67
|
export declare function nxExit(kind?: ExitKind, speed?: SpringSpeed, rtl?: boolean): FadeOut | ZoomOut | SlideOutLeft;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../../src/theme/motion.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../../src/theme/motion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,QAAQ,EACR,OAAO,EAGP,gBAAgB,EAChB,YAAY,EACZ,YAAY,EAEZ,MAAM,EACN,OAAO,EACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQ9C,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;AAC7D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC;AAEzE,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,MAAM,GAAE,YAAwB,EAAE,KAAK,GAAE,WAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAExF;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;AACzD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAK1E;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,GAAE,SAAkB,EAAE,KAAK,GAAE,WAAuB,2CAQ/E;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,GAAE,QAAiB,EAAE,KAAK,GAAE,WAAoB,EAAE,GAAG,UAAQ,oCAcvF;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,KAAK,GAAE,WAAuB,oBAOtD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexub/react-native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "React Native components for Nexub Design System — native chrome, Nexub content. Same tokens, brands and prop names as @nexub/react, for Expo and bare React Native apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/Nexub-AI/nexub-ds#readme",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"@expo-google-fonts/inter": "^0.4.2",
|
|
64
64
|
"@expo-google-fonts/plus-jakarta-sans": "^0.4.2",
|
|
65
65
|
"lucide-react-native": "^1.64.0",
|
|
66
|
-
"@nexub/core": "2.
|
|
67
|
-
"@nexub/icons": "2.
|
|
68
|
-
"@nexub/tokens": "2.
|
|
66
|
+
"@nexub/core": "2.3.1",
|
|
67
|
+
"@nexub/icons": "2.3.1",
|
|
68
|
+
"@nexub/tokens": "2.3.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"expo-glass-effect": ">=57.0.0",
|
package/src/theme/motion.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Easing,
|
|
3
2
|
FadeIn,
|
|
4
3
|
FadeInDown,
|
|
5
4
|
FadeInUp,
|
|
@@ -36,34 +35,7 @@ const ENTER = { fade: FadeIn, up: FadeInUp, down: FadeInDown, scale: ZoomIn } as
|
|
|
36
35
|
const EXIT = { fade: FadeOut, up: FadeOutUp, down: FadeOutDown, scale: ZoomOut } as const;
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
40
|
-
* same rule @nexub/tokens uses for the CSS spring durations.
|
|
41
|
-
*/
|
|
42
|
-
export function springSettleMs({ stiffness, damping, mass }: { stiffness: number; damping: number; mass: number }) {
|
|
43
|
-
const dt = 1 / 1000;
|
|
44
|
-
let x = 0;
|
|
45
|
-
let v = 0;
|
|
46
|
-
let still = 0;
|
|
47
|
-
for (let t = 0; t < 3; t += dt) {
|
|
48
|
-
const a = (stiffness * (1 - x) - damping * v) / mass;
|
|
49
|
-
v += a * dt;
|
|
50
|
-
x += v * dt;
|
|
51
|
-
still = Math.abs(1 - x) < 0.001 && Math.abs(v) < 0.01 ? still + 1 : 0;
|
|
52
|
-
if (still > 16) return Math.round((t - 0.016) * 1000);
|
|
53
|
-
}
|
|
54
|
-
return 3000;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Enter and exit run as timed animations lasting the spring token's settle
|
|
58
|
-
// time, on the system decelerate / accelerate curves: Reanimated's
|
|
59
|
-
// physics-spring entering animations (`springify()` with stiffness/damping)
|
|
60
|
-
// left entering views invisible on iOS. Layout transitions move views that are
|
|
61
|
-
// already visible, so they keep the physics spring.
|
|
62
|
-
const decelerate = Easing.bezier(0, 0, 0.2, 1);
|
|
63
|
-
const accelerate = Easing.bezier(0.4, 0, 1, 1);
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* `entering` animation, timed to the spatial spring.
|
|
38
|
+
* `entering` animation on the spatial spring.
|
|
67
39
|
* `up` rises into place (rows, toasts from below); `down` drops in (banners).
|
|
68
40
|
*
|
|
69
41
|
* ```tsx
|
|
@@ -71,17 +43,21 @@ const accelerate = Easing.bezier(0.4, 0, 1, 1);
|
|
|
71
43
|
* ```
|
|
72
44
|
*/
|
|
73
45
|
export function nxEnter(kind: EnterKind = 'fade', speed: SpringSpeed = 'default') {
|
|
46
|
+
const s = native.motion.spring.spatial[speed];
|
|
74
47
|
return ENTER[kind]
|
|
75
|
-
.
|
|
76
|
-
.
|
|
48
|
+
.springify()
|
|
49
|
+
.stiffness(s.stiffness)
|
|
50
|
+
.damping(s.damping)
|
|
51
|
+
.mass(s.mass)
|
|
77
52
|
.reduceMotion(ReduceMotion.System);
|
|
78
53
|
}
|
|
79
54
|
|
|
80
55
|
/**
|
|
81
|
-
* `exiting` animation
|
|
56
|
+
* `exiting` animation on the effects spring: quicker than enter, no overshoot.
|
|
82
57
|
* `start` / `end` slide out toward that edge (swipe-to-delete), following RTL.
|
|
83
58
|
*/
|
|
84
59
|
export function nxExit(kind: ExitKind = 'fade', speed: SpringSpeed = 'fast', rtl = false) {
|
|
60
|
+
const s = native.motion.spring.effects[speed];
|
|
85
61
|
const builder =
|
|
86
62
|
kind === 'start' || kind === 'end'
|
|
87
63
|
? (kind === 'start') !== rtl
|
|
@@ -89,8 +65,10 @@ export function nxExit(kind: ExitKind = 'fade', speed: SpringSpeed = 'fast', rtl
|
|
|
89
65
|
: SlideOutRight
|
|
90
66
|
: EXIT[kind];
|
|
91
67
|
return builder
|
|
92
|
-
.
|
|
93
|
-
.
|
|
68
|
+
.springify()
|
|
69
|
+
.stiffness(s.stiffness)
|
|
70
|
+
.damping(s.damping)
|
|
71
|
+
.mass(s.mass)
|
|
94
72
|
.reduceMotion(ReduceMotion.System);
|
|
95
73
|
}
|
|
96
74
|
|