@rootnative/inertia 0.0.5 → 0.0.7
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 +69 -1
- package/README.md +7 -1
- package/dist/{chunk-OAUWLPQH.mjs → chunk-52QSN2VQ.mjs} +1 -1
- package/dist/{chunk-VQ5D35UA.js → chunk-6V7MOBXO.js} +93 -33
- package/dist/{chunk-RIVVBABB.mjs → chunk-HPJMIBBK.mjs} +93 -34
- package/dist/{chunk-XSK5MNUH.mjs → chunk-KBFN4TRO.mjs} +1 -1
- package/dist/chunk-NPJ46457.js +8 -0
- package/dist/chunk-QJYFTTM2.js +28 -0
- package/dist/{chunk-QQVDZKSD.js → chunk-QYR66E2G.js} +2 -2
- package/dist/{chunk-GTJ6VAH5.mjs → chunk-RUIOM2YZ.mjs} +1 -1
- package/dist/{chunk-27MKBTSG.mjs → chunk-VSK2E35J.mjs} +1 -1
- package/dist/{chunk-27U6766G.js → chunk-WGCF3WQG.js} +2 -2
- package/dist/{chunk-COEJVWRZ.mjs → chunk-WMLS4TMX.mjs} +1 -1
- package/dist/chunk-YUTS6JRU.js +8 -0
- package/dist/chunk-ZOBOKLAS.mjs +22 -0
- package/dist/chunk-ZSOCRHU3.js +8 -0
- package/dist/gestureLayer/index.d.mts +2 -2
- package/dist/gestureLayer/index.d.ts +2 -2
- package/dist/index.d.mts +45 -9
- package/dist/index.d.ts +45 -9
- package/dist/index.js +32 -22
- package/dist/index.mjs +16 -13
- package/dist/motion/FlatList.d.mts +53 -0
- package/dist/motion/FlatList.d.ts +53 -0
- package/dist/motion/FlatList.js +13 -0
- package/dist/motion/FlatList.mjs +4 -0
- package/dist/motion/Image.d.mts +1 -1
- package/dist/motion/Image.d.ts +1 -1
- package/dist/motion/Image.js +3 -3
- package/dist/motion/Image.mjs +2 -2
- package/dist/motion/Pressable.d.mts +1 -1
- package/dist/motion/Pressable.d.ts +1 -1
- package/dist/motion/Pressable.js +3 -3
- package/dist/motion/Pressable.mjs +2 -2
- package/dist/motion/ScrollView.d.mts +1 -1
- package/dist/motion/ScrollView.d.ts +1 -1
- package/dist/motion/ScrollView.js +3 -3
- package/dist/motion/ScrollView.mjs +2 -2
- package/dist/motion/Text.d.mts +1 -1
- package/dist/motion/Text.d.ts +1 -1
- package/dist/motion/Text.js +3 -3
- package/dist/motion/Text.mjs +2 -2
- package/dist/motion/View.d.mts +1 -1
- package/dist/motion/View.d.ts +1 -1
- package/dist/motion/View.js +3 -3
- package/dist/motion/View.mjs +2 -2
- package/dist/touch/index.d.mts +1 -1
- package/dist/touch/index.d.ts +1 -1
- package/dist/{types-BQgLJeQG.d.mts → types-DyJpG64F.d.mts} +1 -1
- package/dist/{types-BQgLJeQG.d.ts → types-DyJpG64F.d.ts} +1 -1
- package/dist/{useGesture-DfaTx-3t.d.mts → useGesture-CnZQnYHH.d.mts} +1 -1
- package/dist/{useGesture-B0_CzOUz.d.ts → useGesture-DbH46EBp.d.ts} +1 -1
- package/jest-setup.js +7 -1
- package/llms.txt +8 -3
- package/package.json +8 -1
- package/src/index.ts +5 -0
- package/src/internal/boxShadow.ts +71 -9
- package/src/internal/color.ts +70 -0
- package/src/motion/FlatList.tsx +77 -0
- package/src/motion/createMotionComponent.tsx +116 -47
- package/src/motion/index.ts +3 -0
- package/src/values/useScroll.ts +9 -5
- package/dist/chunk-67GHRCF6.js +0 -8
- package/dist/chunk-GPOMFIIU.js +0 -8
- package/dist/chunk-K63LXGKS.js +0 -8
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk6V7MOBXO_js = require('./chunk-6V7MOBXO.js');
|
|
4
|
+
var Animated = require('react-native-reanimated');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var Animated__default = /*#__PURE__*/_interopDefault(Animated);
|
|
9
|
+
|
|
10
|
+
var MotionFlatList = chunk6V7MOBXO_js.createMotionComponent(
|
|
11
|
+
Animated__default.default.FlatList
|
|
12
|
+
// `createMotionComponent<C>` returns a non-generic `MotionComponent<C>`, so
|
|
13
|
+
// `data` / `renderItem` would collapse to `any` and lose `ItemT` inference.
|
|
14
|
+
// Restore it with the same call-signature cast Reanimated itself uses for
|
|
15
|
+
// this exact problem (see its `ReanimatedFlatList` export, and the
|
|
16
|
+
// `@ts-expect-error` above `AnimatedFlatList` explaining that
|
|
17
|
+
// `createAnimatedComponent` cannot create generic components).
|
|
18
|
+
//
|
|
19
|
+
// **Both** generics live on the one call signature, and that is deliberate:
|
|
20
|
+
// `ItemT` infers from `data` while `V` infers from `variants`, independently.
|
|
21
|
+
// Declaring only `ItemT` (the obvious first cut) silently drops the
|
|
22
|
+
// variant-key narrowing that `MotionComponent` provides on every other
|
|
23
|
+
// primitive — `animate="typo"` would stop being a compile error here and
|
|
24
|
+
// nowhere else. Both directions are pinned in
|
|
25
|
+
// `__type-tests__/flat-list.test-d.tsx`.
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
exports.MotionFlatList = MotionFlatList;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6V7MOBXO_js = require('./chunk-6V7MOBXO.js');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
|
|
6
|
-
var MotionScrollView =
|
|
6
|
+
var MotionScrollView = chunk6V7MOBXO_js.createMotionComponent(reactNative.ScrollView);
|
|
7
7
|
|
|
8
8
|
exports.MotionScrollView = MotionScrollView;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6V7MOBXO_js = require('./chunk-6V7MOBXO.js');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
|
|
6
|
-
var MotionPressable =
|
|
6
|
+
var MotionPressable = chunk6V7MOBXO_js.createMotionComponent(reactNative.Pressable);
|
|
7
7
|
|
|
8
8
|
exports.MotionPressable = MotionPressable;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createMotionComponent } from './chunk-HPJMIBBK.mjs';
|
|
2
|
+
import Animated from 'react-native-reanimated';
|
|
3
|
+
|
|
4
|
+
var MotionFlatList = createMotionComponent(
|
|
5
|
+
Animated.FlatList
|
|
6
|
+
// `createMotionComponent<C>` returns a non-generic `MotionComponent<C>`, so
|
|
7
|
+
// `data` / `renderItem` would collapse to `any` and lose `ItemT` inference.
|
|
8
|
+
// Restore it with the same call-signature cast Reanimated itself uses for
|
|
9
|
+
// this exact problem (see its `ReanimatedFlatList` export, and the
|
|
10
|
+
// `@ts-expect-error` above `AnimatedFlatList` explaining that
|
|
11
|
+
// `createAnimatedComponent` cannot create generic components).
|
|
12
|
+
//
|
|
13
|
+
// **Both** generics live on the one call signature, and that is deliberate:
|
|
14
|
+
// `ItemT` infers from `data` while `V` infers from `variants`, independently.
|
|
15
|
+
// Declaring only `ItemT` (the obvious first cut) silently drops the
|
|
16
|
+
// variant-key narrowing that `MotionComponent` provides on every other
|
|
17
|
+
// primitive — `animate="typo"` would stop being a compile error here and
|
|
18
|
+
// nowhere else. Both directions are pinned in
|
|
19
|
+
// `__type-tests__/flat-list.test-d.tsx`.
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export { MotionFlatList };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
|
|
2
|
-
import { U as UseGestureHandlers } from '../useGesture-
|
|
3
|
-
import {
|
|
2
|
+
import { U as UseGestureHandlers } from '../useGesture-CnZQnYHH.mjs';
|
|
3
|
+
import { b as TransitionInput, G as GestureLayerTransitions } from '../types-DyJpG64F.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-native';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
|
|
2
|
-
import { U as UseGestureHandlers } from '../useGesture-
|
|
3
|
-
import {
|
|
2
|
+
import { U as UseGestureHandlers } from '../useGesture-DbH46EBp.js';
|
|
3
|
+
import { b as TransitionInput, G as GestureLayerTransitions } from '../types-DyJpG64F.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-native';
|
|
6
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2,11 +2,12 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
|
|
5
|
-
import { M as MotionComponent, N as NamedTransitions,
|
|
6
|
-
export {
|
|
5
|
+
import { M as MotionComponent, V as VariantsMap, a as MotionProps, N as NamedTransitions, b as TransitionInput, T as TransitionConfig, A as AnimatableValue, E as EasingInput, S as SpringTransition, c as TransitionName, d as VariantController } from './types-DyJpG64F.mjs';
|
|
6
|
+
export { e as AnimateStyle, f as AnimationCallbackInfo, B as BoxShadowInput, D as DecayTransition, g as EasingFunction, h as EasingFunctionFactory, i as GestureSubStates, j as NoAnimationTransition, P as PerPropertyTransition, R as RegisteredTransitions, k as RepeatConfig, l as SequenceStep, m as TimingTransition, n as Transition } from './types-DyJpG64F.mjs';
|
|
7
7
|
import { SharedValue, useAnimatedStyle } from 'react-native-reanimated';
|
|
8
8
|
export { SharedValue } from 'react-native-reanimated';
|
|
9
|
-
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-
|
|
9
|
+
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-CnZQnYHH.mjs';
|
|
10
|
+
export { MotionFlatList } from './motion/FlatList.mjs';
|
|
10
11
|
export { MotionImage } from './motion/Image.mjs';
|
|
11
12
|
export { MotionPressable } from './motion/Pressable.mjs';
|
|
12
13
|
export { MotionScrollView } from './motion/ScrollView.mjs';
|
|
@@ -36,6 +37,9 @@ declare const Motion: {
|
|
|
36
37
|
readonly Image: MotionComponent<typeof react_native.Image>;
|
|
37
38
|
readonly Pressable: MotionComponent<react.ForwardRefExoticComponent<react_native.PressableProps & react.RefAttributes<react_native.View>>>;
|
|
38
39
|
readonly ScrollView: MotionComponent<typeof react_native.ScrollView>;
|
|
40
|
+
readonly FlatList: <ItemT = any, V extends VariantsMap<react_native.FlatListProps<ItemT>> = VariantsMap<react_native.FlatListProps<ItemT>>>(props: react_native.FlatListProps<ItemT> & MotionProps<react_native.FlatListProps<ItemT>, V> & {
|
|
41
|
+
ref?: React.Ref<react_native.FlatList<ItemT>>;
|
|
42
|
+
}) => React.ReactElement;
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
/**
|
|
@@ -292,6 +296,34 @@ declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: numb
|
|
|
292
296
|
*/
|
|
293
297
|
declare function buildReleaseAnimation(transition: TransitionConfig, toValue: number): unknown;
|
|
294
298
|
|
|
299
|
+
/**
|
|
300
|
+
* The one colour spelling Reanimated's animation drivers cannot accept.
|
|
301
|
+
*
|
|
302
|
+
* Reanimated dispatches an animation on the runtime shape of its **source**
|
|
303
|
+
* value, and `isColor()` is the gate for the RGBA-channel path. That gate is
|
|
304
|
+
* `processColorInitially(value) != null`, and Reanimated's colour-name table
|
|
305
|
+
* (`Colors.ts`) maps `transparent` to `undefined` — every other CSS colour
|
|
306
|
+
* name maps to a packed integer. So `'transparent'` is the single named colour
|
|
307
|
+
* that reports **false**.
|
|
308
|
+
*
|
|
309
|
+
* A value that fails the gate but is still a string falls to the
|
|
310
|
+
* prefix-number-suffix branch, which exists for values like `'100%'`. It runs
|
|
311
|
+
* `parseFloat('transparent')` → `NaN`, animates that, and re-attaches the
|
|
312
|
+
* prefix, so the slot fills with `'transparentNaN'`. Under `withTiming` the
|
|
313
|
+
* animation still snaps to its target when the duration elapses, which hides
|
|
314
|
+
* the fault; under `withSpring` — the library default — settling is decided by
|
|
315
|
+
* comparisons against `NaN`, which are all false, so the animation runs
|
|
316
|
+
* forever and the colour never appears.
|
|
317
|
+
*
|
|
318
|
+
* `'rgba(0, 0, 0, 0)'` is the same colour and passes the gate.
|
|
319
|
+
*
|
|
320
|
+
* This only applies to values handed to `withSpring` / `withTiming`.
|
|
321
|
+
* `interpolateColor` parses `'transparent'` correctly, which is why the
|
|
322
|
+
* gesture cascade, the shared-element carry, and `useShadow` are unaffected
|
|
323
|
+
* and keep the consumer's own spelling.
|
|
324
|
+
*/
|
|
325
|
+
declare const TRANSPARENT = "rgba(0, 0, 0, 0)";
|
|
326
|
+
|
|
295
327
|
/**
|
|
296
328
|
* Drive a `SharedValue<number>` toward `target` with **any** transition shape
|
|
297
329
|
* — spring, timing, decay, or no-animation — or a `TransitionName` registered
|
|
@@ -703,10 +735,10 @@ interface UseScrollResult {
|
|
|
703
735
|
/** Vertical scroll offset in points. */
|
|
704
736
|
scrollY: SharedValue<number>;
|
|
705
737
|
/**
|
|
706
|
-
* Handler to pass to
|
|
707
|
-
*
|
|
708
|
-
* as a worklet — but the type narrows to the same
|
|
709
|
-
* `onScroll` prop expects so it composes cleanly.
|
|
738
|
+
* Handler to pass to the `onScroll` prop of `Motion.ScrollView` or
|
|
739
|
+
* `Motion.FlatList` (or any other Reanimated animated scroller). The handler
|
|
740
|
+
* is opaque to JS — it runs as a worklet — but the type narrows to the same
|
|
741
|
+
* shape RN's native `onScroll` prop expects so it composes cleanly.
|
|
710
742
|
*/
|
|
711
743
|
onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
712
744
|
}
|
|
@@ -738,9 +770,13 @@ interface UseScrollResult {
|
|
|
738
770
|
* read from any worklet (`useAnimatedStyle`, `useDerivedValue`,
|
|
739
771
|
* `useTransform`) without a JS-thread bounce.
|
|
740
772
|
*
|
|
741
|
-
* Remember to set `scrollEventThrottle={16}` on
|
|
773
|
+
* Remember to set `scrollEventThrottle={16}` on a `Motion.ScrollView` for 60Hz
|
|
742
774
|
* updates — RN's default is to dispatch on every event, which on iOS still
|
|
743
775
|
* means one per frame, but Android benefits from the explicit cap.
|
|
776
|
+
*
|
|
777
|
+
* `Motion.FlatList` needs no such setting — it defaults `scrollEventThrottle`
|
|
778
|
+
* to 1 for you. Prefer it over `Motion.ScrollView` for long or unbounded lists:
|
|
779
|
+
* it virtualizes, and both accept this handler.
|
|
744
780
|
*/
|
|
745
781
|
declare function useScroll(): UseScrollResult;
|
|
746
782
|
|
|
@@ -869,4 +905,4 @@ declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnTyp
|
|
|
869
905
|
*/
|
|
870
906
|
declare function useVariants<V extends Readonly<Record<string, object>>>(variants: V, initial?: keyof V & string): VariantController<keyof V & string>;
|
|
871
907
|
|
|
872
|
-
export { AnimatableValue, type Animator, type BoxShadowLayer, type ColorCascadeLayer, type ColorStyleKey, EasingInput, type ExtrapolationMode, type InterpolatedStyleMap, Motion, MotionComponent, MotionConfig, type MotionConfigProps, type MotionConfigValue, NamedTransitions, type NumericStyleKey, Presence, type PresenceContextValue, type ReducedMotion, type ShadowConfig, SpringTransition, type TransformKey, TransitionConfig, TransitionInput, TransitionName, type UseColorCascadeOptions, type UseColorTransitionOptions, type UseInterpolatedStyleOptions, type UseScrollResult, type UseShadowOptions, type UseTransformOptions, VariantController, buildReleaseAnimation, createMotionComponent, cubicBezier, ensureWorkletEasing, resolveAnimatableValue, resolveNamedTransition, resolveTransition, useAnimation, useAnimator, useBooleanSpring, useColorCascade, useColorTransition, useInterpolatedStyle, useMotionConfig, useMotionValue, useNamedTransitions, usePresence, useScroll, useShadow, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
|
908
|
+
export { AnimatableValue, type Animator, type BoxShadowLayer, type ColorCascadeLayer, type ColorStyleKey, EasingInput, type ExtrapolationMode, type InterpolatedStyleMap, Motion, MotionComponent, MotionConfig, type MotionConfigProps, type MotionConfigValue, MotionProps, NamedTransitions, type NumericStyleKey, Presence, type PresenceContextValue, type ReducedMotion, type ShadowConfig, SpringTransition, TRANSPARENT, type TransformKey, TransitionConfig, TransitionInput, TransitionName, type UseColorCascadeOptions, type UseColorTransitionOptions, type UseInterpolatedStyleOptions, type UseScrollResult, type UseShadowOptions, type UseTransformOptions, VariantController, VariantsMap, buildReleaseAnimation, createMotionComponent, cubicBezier, ensureWorkletEasing, resolveAnimatableValue, resolveNamedTransition, resolveTransition, useAnimation, useAnimator, useBooleanSpring, useColorCascade, useColorTransition, useInterpolatedStyle, useMotionConfig, useMotionValue, useNamedTransitions, usePresence, useScroll, useShadow, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
|
|
5
|
-
import { M as MotionComponent, N as NamedTransitions,
|
|
6
|
-
export {
|
|
5
|
+
import { M as MotionComponent, V as VariantsMap, a as MotionProps, N as NamedTransitions, b as TransitionInput, T as TransitionConfig, A as AnimatableValue, E as EasingInput, S as SpringTransition, c as TransitionName, d as VariantController } from './types-DyJpG64F.js';
|
|
6
|
+
export { e as AnimateStyle, f as AnimationCallbackInfo, B as BoxShadowInput, D as DecayTransition, g as EasingFunction, h as EasingFunctionFactory, i as GestureSubStates, j as NoAnimationTransition, P as PerPropertyTransition, R as RegisteredTransitions, k as RepeatConfig, l as SequenceStep, m as TimingTransition, n as Transition } from './types-DyJpG64F.js';
|
|
7
7
|
import { SharedValue, useAnimatedStyle } from 'react-native-reanimated';
|
|
8
8
|
export { SharedValue } from 'react-native-reanimated';
|
|
9
|
-
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-
|
|
9
|
+
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-DbH46EBp.js';
|
|
10
|
+
export { MotionFlatList } from './motion/FlatList.js';
|
|
10
11
|
export { MotionImage } from './motion/Image.js';
|
|
11
12
|
export { MotionPressable } from './motion/Pressable.js';
|
|
12
13
|
export { MotionScrollView } from './motion/ScrollView.js';
|
|
@@ -36,6 +37,9 @@ declare const Motion: {
|
|
|
36
37
|
readonly Image: MotionComponent<typeof react_native.Image>;
|
|
37
38
|
readonly Pressable: MotionComponent<react.ForwardRefExoticComponent<react_native.PressableProps & react.RefAttributes<react_native.View>>>;
|
|
38
39
|
readonly ScrollView: MotionComponent<typeof react_native.ScrollView>;
|
|
40
|
+
readonly FlatList: <ItemT = any, V extends VariantsMap<react_native.FlatListProps<ItemT>> = VariantsMap<react_native.FlatListProps<ItemT>>>(props: react_native.FlatListProps<ItemT> & MotionProps<react_native.FlatListProps<ItemT>, V> & {
|
|
41
|
+
ref?: React.Ref<react_native.FlatList<ItemT>>;
|
|
42
|
+
}) => React.ReactElement;
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
/**
|
|
@@ -292,6 +296,34 @@ declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: numb
|
|
|
292
296
|
*/
|
|
293
297
|
declare function buildReleaseAnimation(transition: TransitionConfig, toValue: number): unknown;
|
|
294
298
|
|
|
299
|
+
/**
|
|
300
|
+
* The one colour spelling Reanimated's animation drivers cannot accept.
|
|
301
|
+
*
|
|
302
|
+
* Reanimated dispatches an animation on the runtime shape of its **source**
|
|
303
|
+
* value, and `isColor()` is the gate for the RGBA-channel path. That gate is
|
|
304
|
+
* `processColorInitially(value) != null`, and Reanimated's colour-name table
|
|
305
|
+
* (`Colors.ts`) maps `transparent` to `undefined` — every other CSS colour
|
|
306
|
+
* name maps to a packed integer. So `'transparent'` is the single named colour
|
|
307
|
+
* that reports **false**.
|
|
308
|
+
*
|
|
309
|
+
* A value that fails the gate but is still a string falls to the
|
|
310
|
+
* prefix-number-suffix branch, which exists for values like `'100%'`. It runs
|
|
311
|
+
* `parseFloat('transparent')` → `NaN`, animates that, and re-attaches the
|
|
312
|
+
* prefix, so the slot fills with `'transparentNaN'`. Under `withTiming` the
|
|
313
|
+
* animation still snaps to its target when the duration elapses, which hides
|
|
314
|
+
* the fault; under `withSpring` — the library default — settling is decided by
|
|
315
|
+
* comparisons against `NaN`, which are all false, so the animation runs
|
|
316
|
+
* forever and the colour never appears.
|
|
317
|
+
*
|
|
318
|
+
* `'rgba(0, 0, 0, 0)'` is the same colour and passes the gate.
|
|
319
|
+
*
|
|
320
|
+
* This only applies to values handed to `withSpring` / `withTiming`.
|
|
321
|
+
* `interpolateColor` parses `'transparent'` correctly, which is why the
|
|
322
|
+
* gesture cascade, the shared-element carry, and `useShadow` are unaffected
|
|
323
|
+
* and keep the consumer's own spelling.
|
|
324
|
+
*/
|
|
325
|
+
declare const TRANSPARENT = "rgba(0, 0, 0, 0)";
|
|
326
|
+
|
|
295
327
|
/**
|
|
296
328
|
* Drive a `SharedValue<number>` toward `target` with **any** transition shape
|
|
297
329
|
* — spring, timing, decay, or no-animation — or a `TransitionName` registered
|
|
@@ -703,10 +735,10 @@ interface UseScrollResult {
|
|
|
703
735
|
/** Vertical scroll offset in points. */
|
|
704
736
|
scrollY: SharedValue<number>;
|
|
705
737
|
/**
|
|
706
|
-
* Handler to pass to
|
|
707
|
-
*
|
|
708
|
-
* as a worklet — but the type narrows to the same
|
|
709
|
-
* `onScroll` prop expects so it composes cleanly.
|
|
738
|
+
* Handler to pass to the `onScroll` prop of `Motion.ScrollView` or
|
|
739
|
+
* `Motion.FlatList` (or any other Reanimated animated scroller). The handler
|
|
740
|
+
* is opaque to JS — it runs as a worklet — but the type narrows to the same
|
|
741
|
+
* shape RN's native `onScroll` prop expects so it composes cleanly.
|
|
710
742
|
*/
|
|
711
743
|
onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
712
744
|
}
|
|
@@ -738,9 +770,13 @@ interface UseScrollResult {
|
|
|
738
770
|
* read from any worklet (`useAnimatedStyle`, `useDerivedValue`,
|
|
739
771
|
* `useTransform`) without a JS-thread bounce.
|
|
740
772
|
*
|
|
741
|
-
* Remember to set `scrollEventThrottle={16}` on
|
|
773
|
+
* Remember to set `scrollEventThrottle={16}` on a `Motion.ScrollView` for 60Hz
|
|
742
774
|
* updates — RN's default is to dispatch on every event, which on iOS still
|
|
743
775
|
* means one per frame, but Android benefits from the explicit cap.
|
|
776
|
+
*
|
|
777
|
+
* `Motion.FlatList` needs no such setting — it defaults `scrollEventThrottle`
|
|
778
|
+
* to 1 for you. Prefer it over `Motion.ScrollView` for long or unbounded lists:
|
|
779
|
+
* it virtualizes, and both accept this handler.
|
|
744
780
|
*/
|
|
745
781
|
declare function useScroll(): UseScrollResult;
|
|
746
782
|
|
|
@@ -869,4 +905,4 @@ declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnTyp
|
|
|
869
905
|
*/
|
|
870
906
|
declare function useVariants<V extends Readonly<Record<string, object>>>(variants: V, initial?: keyof V & string): VariantController<keyof V & string>;
|
|
871
907
|
|
|
872
|
-
export { AnimatableValue, type Animator, type BoxShadowLayer, type ColorCascadeLayer, type ColorStyleKey, EasingInput, type ExtrapolationMode, type InterpolatedStyleMap, Motion, MotionComponent, MotionConfig, type MotionConfigProps, type MotionConfigValue, NamedTransitions, type NumericStyleKey, Presence, type PresenceContextValue, type ReducedMotion, type ShadowConfig, SpringTransition, type TransformKey, TransitionConfig, TransitionInput, TransitionName, type UseColorCascadeOptions, type UseColorTransitionOptions, type UseInterpolatedStyleOptions, type UseScrollResult, type UseShadowOptions, type UseTransformOptions, VariantController, buildReleaseAnimation, createMotionComponent, cubicBezier, ensureWorkletEasing, resolveAnimatableValue, resolveNamedTransition, resolveTransition, useAnimation, useAnimator, useBooleanSpring, useColorCascade, useColorTransition, useInterpolatedStyle, useMotionConfig, useMotionValue, useNamedTransitions, usePresence, useScroll, useShadow, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
|
908
|
+
export { AnimatableValue, type Animator, type BoxShadowLayer, type ColorCascadeLayer, type ColorStyleKey, EasingInput, type ExtrapolationMode, type InterpolatedStyleMap, Motion, MotionComponent, MotionConfig, type MotionConfigProps, type MotionConfigValue, MotionProps, NamedTransitions, type NumericStyleKey, Presence, type PresenceContextValue, type ReducedMotion, type ShadowConfig, SpringTransition, TRANSPARENT, type TransformKey, TransitionConfig, TransitionInput, TransitionName, type UseColorCascadeOptions, type UseColorTransitionOptions, type UseInterpolatedStyleOptions, type UseScrollResult, type UseShadowOptions, type UseTransformOptions, VariantController, VariantsMap, buildReleaseAnimation, createMotionComponent, cubicBezier, ensureWorkletEasing, resolveAnimatableValue, resolveNamedTransition, resolveTransition, useAnimation, useAnimator, useBooleanSpring, useColorCascade, useColorTransition, useInterpolatedStyle, useMotionConfig, useMotionValue, useNamedTransitions, usePresence, useScroll, useShadow, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk4NAMD62I_js = require('./chunk-4NAMD62I.js');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
4
|
+
var chunkNPJ46457_js = require('./chunk-NPJ46457.js');
|
|
5
|
+
var chunkZSOCRHU3_js = require('./chunk-ZSOCRHU3.js');
|
|
6
|
+
var chunkYUTS6JRU_js = require('./chunk-YUTS6JRU.js');
|
|
7
|
+
var chunkWGCF3WQG_js = require('./chunk-WGCF3WQG.js');
|
|
8
|
+
var chunkQYR66E2G_js = require('./chunk-QYR66E2G.js');
|
|
9
|
+
var chunkQJYFTTM2_js = require('./chunk-QJYFTTM2.js');
|
|
10
|
+
var chunk6V7MOBXO_js = require('./chunk-6V7MOBXO.js');
|
|
10
11
|
var chunkOBRGJAST_js = require('./chunk-OBRGJAST.js');
|
|
11
12
|
var chunkPM6CVGXJ_js = require('./chunk-PM6CVGXJ.js');
|
|
12
13
|
var react = require('react');
|
|
@@ -15,11 +16,12 @@ var reactNativeWorklets = require('react-native-worklets');
|
|
|
15
16
|
|
|
16
17
|
// src/motion/index.ts
|
|
17
18
|
var Motion = {
|
|
18
|
-
View:
|
|
19
|
-
Text:
|
|
20
|
-
Image:
|
|
21
|
-
Pressable:
|
|
22
|
-
ScrollView:
|
|
19
|
+
View: chunkNPJ46457_js.MotionView,
|
|
20
|
+
Text: chunkZSOCRHU3_js.MotionText,
|
|
21
|
+
Image: chunkYUTS6JRU_js.MotionImage,
|
|
22
|
+
Pressable: chunkWGCF3WQG_js.MotionPressable,
|
|
23
|
+
ScrollView: chunkQYR66E2G_js.MotionScrollView,
|
|
24
|
+
FlatList: chunkQJYFTTM2_js.MotionFlatList
|
|
23
25
|
};
|
|
24
26
|
function useAnimation(target, transition) {
|
|
25
27
|
const output = reactNativeReanimated.useSharedValue(target);
|
|
@@ -362,9 +364,9 @@ function useShadow({
|
|
|
362
364
|
const hasElevation = from.elevation !== void 0 || to.elevation !== void 0;
|
|
363
365
|
const hasColor = from.shadowColor !== void 0 || to.shadowColor !== void 0;
|
|
364
366
|
const hasOffset = from.shadowOffset !== void 0 || to.shadowOffset !== void 0;
|
|
365
|
-
const boxShadowPairs = from.boxShadow !== void 0 || to.boxShadow !== void 0 ?
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
const boxShadowPairs = from.boxShadow !== void 0 || to.boxShadow !== void 0 ? chunk6V7MOBXO_js.pairBoxShadowLayers(
|
|
368
|
+
chunk6V7MOBXO_js.resolveBoxShadowInput(from.boxShadow),
|
|
369
|
+
chunk6V7MOBXO_js.resolveBoxShadowInput(to.boxShadow)
|
|
368
370
|
) : [];
|
|
369
371
|
const opacityFrom = from.shadowOpacity ?? 0;
|
|
370
372
|
const opacityTo = to.shadowOpacity ?? 0;
|
|
@@ -467,35 +469,43 @@ Object.defineProperty(exports, "useGesture", {
|
|
|
467
469
|
});
|
|
468
470
|
Object.defineProperty(exports, "MotionView", {
|
|
469
471
|
enumerable: true,
|
|
470
|
-
get: function () { return
|
|
472
|
+
get: function () { return chunkNPJ46457_js.MotionView; }
|
|
471
473
|
});
|
|
472
474
|
Object.defineProperty(exports, "MotionText", {
|
|
473
475
|
enumerable: true,
|
|
474
|
-
get: function () { return
|
|
476
|
+
get: function () { return chunkZSOCRHU3_js.MotionText; }
|
|
475
477
|
});
|
|
476
478
|
Object.defineProperty(exports, "MotionImage", {
|
|
477
479
|
enumerable: true,
|
|
478
|
-
get: function () { return
|
|
480
|
+
get: function () { return chunkYUTS6JRU_js.MotionImage; }
|
|
479
481
|
});
|
|
480
482
|
Object.defineProperty(exports, "MotionPressable", {
|
|
481
483
|
enumerable: true,
|
|
482
|
-
get: function () { return
|
|
484
|
+
get: function () { return chunkWGCF3WQG_js.MotionPressable; }
|
|
483
485
|
});
|
|
484
486
|
Object.defineProperty(exports, "MotionScrollView", {
|
|
485
487
|
enumerable: true,
|
|
486
|
-
get: function () { return
|
|
488
|
+
get: function () { return chunkQYR66E2G_js.MotionScrollView; }
|
|
489
|
+
});
|
|
490
|
+
Object.defineProperty(exports, "MotionFlatList", {
|
|
491
|
+
enumerable: true,
|
|
492
|
+
get: function () { return chunkQJYFTTM2_js.MotionFlatList; }
|
|
487
493
|
});
|
|
488
494
|
Object.defineProperty(exports, "Presence", {
|
|
489
495
|
enumerable: true,
|
|
490
|
-
get: function () { return
|
|
496
|
+
get: function () { return chunk6V7MOBXO_js.Presence; }
|
|
497
|
+
});
|
|
498
|
+
Object.defineProperty(exports, "TRANSPARENT", {
|
|
499
|
+
enumerable: true,
|
|
500
|
+
get: function () { return chunk6V7MOBXO_js.TRANSPARENT; }
|
|
491
501
|
});
|
|
492
502
|
Object.defineProperty(exports, "createMotionComponent", {
|
|
493
503
|
enumerable: true,
|
|
494
|
-
get: function () { return
|
|
504
|
+
get: function () { return chunk6V7MOBXO_js.createMotionComponent; }
|
|
495
505
|
});
|
|
496
506
|
Object.defineProperty(exports, "usePresence", {
|
|
497
507
|
enumerable: true,
|
|
498
|
-
get: function () { return
|
|
508
|
+
get: function () { return chunk6V7MOBXO_js.usePresence; }
|
|
499
509
|
});
|
|
500
510
|
Object.defineProperty(exports, "MotionConfig", {
|
|
501
511
|
enumerable: true,
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export { useGesture } from './chunk-OW5XTGVN.mjs';
|
|
2
|
-
import { MotionView } from './chunk-
|
|
3
|
-
export { MotionView } from './chunk-
|
|
4
|
-
import { MotionText } from './chunk-
|
|
5
|
-
export { MotionText } from './chunk-
|
|
6
|
-
import { MotionImage } from './chunk-
|
|
7
|
-
export { MotionImage } from './chunk-
|
|
8
|
-
import { MotionPressable } from './chunk-
|
|
9
|
-
export { MotionPressable } from './chunk-
|
|
10
|
-
import { MotionScrollView } from './chunk-
|
|
11
|
-
export { MotionScrollView } from './chunk-
|
|
12
|
-
import {
|
|
13
|
-
export {
|
|
2
|
+
import { MotionView } from './chunk-RUIOM2YZ.mjs';
|
|
3
|
+
export { MotionView } from './chunk-RUIOM2YZ.mjs';
|
|
4
|
+
import { MotionText } from './chunk-WMLS4TMX.mjs';
|
|
5
|
+
export { MotionText } from './chunk-WMLS4TMX.mjs';
|
|
6
|
+
import { MotionImage } from './chunk-KBFN4TRO.mjs';
|
|
7
|
+
export { MotionImage } from './chunk-KBFN4TRO.mjs';
|
|
8
|
+
import { MotionPressable } from './chunk-52QSN2VQ.mjs';
|
|
9
|
+
export { MotionPressable } from './chunk-52QSN2VQ.mjs';
|
|
10
|
+
import { MotionScrollView } from './chunk-VSK2E35J.mjs';
|
|
11
|
+
export { MotionScrollView } from './chunk-VSK2E35J.mjs';
|
|
12
|
+
import { MotionFlatList } from './chunk-ZOBOKLAS.mjs';
|
|
13
|
+
export { MotionFlatList } from './chunk-ZOBOKLAS.mjs';
|
|
14
|
+
import { pairBoxShadowLayers, resolveBoxShadowInput } from './chunk-HPJMIBBK.mjs';
|
|
15
|
+
export { Presence, TRANSPARENT, createMotionComponent, usePresence } from './chunk-HPJMIBBK.mjs';
|
|
14
16
|
import { useShouldReduceMotion, resolveNamedTransition, useNamedTransitions, lookupNamedTransition } from './chunk-Z3HCJ43H.mjs';
|
|
15
17
|
export { MotionConfig, resolveNamedTransition, useMotionConfig, useNamedTransitions, useShouldReduceMotion } from './chunk-Z3HCJ43H.mjs';
|
|
16
18
|
import { stableSig, resolveTransition, springToReanimated, warnNonWorkletOnce } from './chunk-REYL77RE.mjs';
|
|
@@ -25,7 +27,8 @@ var Motion = {
|
|
|
25
27
|
Text: MotionText,
|
|
26
28
|
Image: MotionImage,
|
|
27
29
|
Pressable: MotionPressable,
|
|
28
|
-
ScrollView: MotionScrollView
|
|
30
|
+
ScrollView: MotionScrollView,
|
|
31
|
+
FlatList: MotionFlatList
|
|
29
32
|
};
|
|
30
33
|
function useAnimation(target, transition) {
|
|
31
34
|
const output = useSharedValue(target);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { FlatListProps, FlatList } from 'react-native';
|
|
2
|
+
import { V as VariantsMap, a as MotionProps } from '../types-DyJpG64F.mjs';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Animatable, virtualized `FlatList`.
|
|
7
|
+
*
|
|
8
|
+
* Built on Reanimated's `Animated.FlatList` rather than RN's `FlatList`. That
|
|
9
|
+
* wrapper supplies two things this primitive would otherwise have to
|
|
10
|
+
* re-implement: the `CellRendererComponent` injection that powers per-row
|
|
11
|
+
* `itemLayoutAnimation`, and a `scrollEventThrottle` default of 1.
|
|
12
|
+
*
|
|
13
|
+
* A note on that throttle default, because the reasoning is easy to get wrong
|
|
14
|
+
* from Reanimated's own source comment: it says RN defaults FlatList's
|
|
15
|
+
* `scrollEventThrottle` to 50, which **is stale**. On RN 0.81
|
|
16
|
+
* (`@react-native/virtualized-lists`, `VirtualizedList.js`) the default is
|
|
17
|
+
* `props.scrollEventThrottle ?? 0.0001` — effectively every frame. So the
|
|
18
|
+
* patch is belt-and-braces on current RN rather than the load-bearing reason
|
|
19
|
+
* to use the wrapper. It is still worth inheriting: it costs nothing, and it
|
|
20
|
+
* pins the behaviour if RN's default changes again. **Do not restate the "50"
|
|
21
|
+
* figure as fact** — verify against the installed RN before relying on it.
|
|
22
|
+
*
|
|
23
|
+
* This is the primitive that lets one list both virtualize and animate. The
|
|
24
|
+
* `useScroll()` handler works because `Motion.*` components are Reanimated
|
|
25
|
+
* animated components — the same mechanism `Motion.ScrollView` relies on, and
|
|
26
|
+
* nothing about it was ever specific to `ScrollView`:
|
|
27
|
+
*
|
|
28
|
+
* ```tsx
|
|
29
|
+
* const { scrollY, onScroll } = useScroll()
|
|
30
|
+
*
|
|
31
|
+
* <Motion.FlatList
|
|
32
|
+
* data={items}
|
|
33
|
+
* renderItem={renderItem}
|
|
34
|
+
* onScroll={onScroll}
|
|
35
|
+
* initial={{ opacity: 0 }}
|
|
36
|
+
* animate={{ opacity: 1 }}
|
|
37
|
+
* />
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* Two scoping notes:
|
|
41
|
+
*
|
|
42
|
+
* - `animate` / `initial` / `gesture` apply to the **scroll container**, not to
|
|
43
|
+
* rows. Animate rows by using a `Motion.*` primitive inside `renderItem`.
|
|
44
|
+
* - The `layout` prop animates the list frame. Per-row layout animation is
|
|
45
|
+
* Reanimated's `itemLayoutAnimation`, which is forwarded through untouched.
|
|
46
|
+
* Note that row-level layout animation can fight the list's own measurement
|
|
47
|
+
* passes — measure before adopting it.
|
|
48
|
+
*/
|
|
49
|
+
declare const MotionFlatList: <ItemT = any, V extends VariantsMap<FlatListProps<ItemT>> = VariantsMap<FlatListProps<ItemT>>>(props: FlatListProps<ItemT> & MotionProps<FlatListProps<ItemT>, V> & {
|
|
50
|
+
ref?: React.Ref<FlatList<ItemT>>;
|
|
51
|
+
}) => React.ReactElement;
|
|
52
|
+
|
|
53
|
+
export { MotionFlatList };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { FlatListProps, FlatList } from 'react-native';
|
|
2
|
+
import { V as VariantsMap, a as MotionProps } from '../types-DyJpG64F.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Animatable, virtualized `FlatList`.
|
|
7
|
+
*
|
|
8
|
+
* Built on Reanimated's `Animated.FlatList` rather than RN's `FlatList`. That
|
|
9
|
+
* wrapper supplies two things this primitive would otherwise have to
|
|
10
|
+
* re-implement: the `CellRendererComponent` injection that powers per-row
|
|
11
|
+
* `itemLayoutAnimation`, and a `scrollEventThrottle` default of 1.
|
|
12
|
+
*
|
|
13
|
+
* A note on that throttle default, because the reasoning is easy to get wrong
|
|
14
|
+
* from Reanimated's own source comment: it says RN defaults FlatList's
|
|
15
|
+
* `scrollEventThrottle` to 50, which **is stale**. On RN 0.81
|
|
16
|
+
* (`@react-native/virtualized-lists`, `VirtualizedList.js`) the default is
|
|
17
|
+
* `props.scrollEventThrottle ?? 0.0001` — effectively every frame. So the
|
|
18
|
+
* patch is belt-and-braces on current RN rather than the load-bearing reason
|
|
19
|
+
* to use the wrapper. It is still worth inheriting: it costs nothing, and it
|
|
20
|
+
* pins the behaviour if RN's default changes again. **Do not restate the "50"
|
|
21
|
+
* figure as fact** — verify against the installed RN before relying on it.
|
|
22
|
+
*
|
|
23
|
+
* This is the primitive that lets one list both virtualize and animate. The
|
|
24
|
+
* `useScroll()` handler works because `Motion.*` components are Reanimated
|
|
25
|
+
* animated components — the same mechanism `Motion.ScrollView` relies on, and
|
|
26
|
+
* nothing about it was ever specific to `ScrollView`:
|
|
27
|
+
*
|
|
28
|
+
* ```tsx
|
|
29
|
+
* const { scrollY, onScroll } = useScroll()
|
|
30
|
+
*
|
|
31
|
+
* <Motion.FlatList
|
|
32
|
+
* data={items}
|
|
33
|
+
* renderItem={renderItem}
|
|
34
|
+
* onScroll={onScroll}
|
|
35
|
+
* initial={{ opacity: 0 }}
|
|
36
|
+
* animate={{ opacity: 1 }}
|
|
37
|
+
* />
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* Two scoping notes:
|
|
41
|
+
*
|
|
42
|
+
* - `animate` / `initial` / `gesture` apply to the **scroll container**, not to
|
|
43
|
+
* rows. Animate rows by using a `Motion.*` primitive inside `renderItem`.
|
|
44
|
+
* - The `layout` prop animates the list frame. Per-row layout animation is
|
|
45
|
+
* Reanimated's `itemLayoutAnimation`, which is forwarded through untouched.
|
|
46
|
+
* Note that row-level layout animation can fight the list's own measurement
|
|
47
|
+
* passes — measure before adopting it.
|
|
48
|
+
*/
|
|
49
|
+
declare const MotionFlatList: <ItemT = any, V extends VariantsMap<FlatListProps<ItemT>> = VariantsMap<FlatListProps<ItemT>>>(props: FlatListProps<ItemT> & MotionProps<FlatListProps<ItemT>, V> & {
|
|
50
|
+
ref?: React.Ref<FlatList<ItemT>>;
|
|
51
|
+
}) => React.ReactElement;
|
|
52
|
+
|
|
53
|
+
export { MotionFlatList };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkQJYFTTM2_js = require('../chunk-QJYFTTM2.js');
|
|
4
|
+
require('../chunk-6V7MOBXO.js');
|
|
5
|
+
require('../chunk-OBRGJAST.js');
|
|
6
|
+
require('../chunk-PM6CVGXJ.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "MotionFlatList", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkQJYFTTM2_js.MotionFlatList; }
|
|
13
|
+
});
|
package/dist/motion/Image.d.mts
CHANGED
package/dist/motion/Image.d.ts
CHANGED