@rootnative/inertia 0.0.0-alpha.4 → 0.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/{chunk-5I3G43XA.js → chunk-2HYD2ZBK.js} +2 -2
- package/dist/chunk-3UTJJ4A3.js +8 -0
- package/dist/{chunk-Q6ZTMLTI.js → chunk-4PEHWDAZ.js} +7 -7
- package/dist/chunk-4QGXK6TF.js +8 -0
- package/dist/{chunk-WPPLZNM4.mjs → chunk-6SMPIOIC.mjs} +1 -1
- package/dist/{chunk-6EP3S2PN.js → chunk-7AOERN53.js} +3 -3
- package/dist/{chunk-6UQ4KA6V.js → chunk-7UDYEFBU.js} +22 -22
- package/dist/{chunk-K4KR5BIS.mjs → chunk-ALRHDFZE.mjs} +1 -1
- package/dist/{chunk-QQJSBIXV.mjs → chunk-CWLFUYIY.mjs} +1 -1
- package/dist/{chunk-6FENLMCA.mjs → chunk-CY7Y64C3.mjs} +17 -1
- package/dist/{chunk-I76OC6RX.mjs → chunk-DWCLIBYO.mjs} +2 -2
- package/dist/{chunk-IJNVUM5U.mjs → chunk-JVBXPF2G.mjs} +1 -1
- package/dist/{chunk-OBE7KTMK.mjs → chunk-NXDJZD6A.mjs} +1 -1
- package/dist/{chunk-SFRNO6AW.js → chunk-PTRF47DA.js} +17 -0
- package/dist/{chunk-L2EVRKSC.mjs → chunk-R63GIUNU.mjs} +1 -1
- package/dist/{chunk-ZQUCQRZT.mjs → chunk-RGNX6UZN.mjs} +2 -2
- package/dist/{chunk-OM5FXU4I.js → chunk-TDSO63CJ.js} +2 -2
- package/dist/chunk-Z7HIOFKQ.js +8 -0
- package/dist/gestureLayer/index.js +10 -10
- package/dist/gestureLayer/index.mjs +3 -3
- package/dist/index.d.mts +78 -13
- package/dist/index.d.ts +78 -13
- package/dist/index.js +202 -44
- package/dist/index.mjs +178 -20
- package/dist/motion/Image.js +5 -5
- package/dist/motion/Image.mjs +4 -4
- package/dist/motion/Pressable.js +5 -5
- package/dist/motion/Pressable.mjs +4 -4
- package/dist/motion/ScrollView.js +5 -5
- package/dist/motion/ScrollView.mjs +4 -4
- package/dist/motion/Text.js +5 -5
- package/dist/motion/Text.mjs +4 -4
- package/dist/motion/View.js +5 -5
- package/dist/motion/View.mjs +4 -4
- package/dist/touch/index.js +3 -3
- package/dist/touch/index.mjs +1 -1
- package/llms.txt +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/internal/boxShadow.ts +204 -0
- package/src/internal/nonWorkletWarning.ts +41 -0
- package/src/layout/resolveLayout.ts +3 -2
- package/src/transitions/easing.ts +13 -8
- package/src/values/index.ts +1 -0
- package/src/values/useShadow.ts +76 -1
- package/src/values/useTransform.ts +28 -12
- package/dist/chunk-NDKVHL3N.js +0 -8
- package/dist/chunk-SCTX5Z7I.js +0 -8
- package/dist/chunk-WZGMAXKC.js +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -250,15 +250,15 @@ declare function cubicBezier(css: string): EasingInput;
|
|
|
250
250
|
/**
|
|
251
251
|
* Reanimated 3.9+ validates that easing functions used in nested-transition
|
|
252
252
|
* contexts (variants, sequences, per-property maps) are worklets, and crashes
|
|
253
|
-
* with `[Reanimated] The easing function is not a worklet` otherwise.
|
|
254
|
-
* library accepts plain functions on the public surface; this helper wraps
|
|
255
|
-
* them so consumers don't have to think about the worklet boundary.
|
|
253
|
+
* with `[Reanimated] The easing function is not a worklet` otherwise.
|
|
256
254
|
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* wrapper
|
|
255
|
+
* Custom easing functions MUST therefore be worklets — put the `'worklet'`
|
|
256
|
+
* directive as the function's first statement (Reanimated's built-in
|
|
257
|
+
* `Easing.*` helpers and inertia's `cubicBezier()` already are). A plain
|
|
258
|
+
* function warns in dev and falls back to a directive-wrapped call-through;
|
|
259
|
+
* that wrapper works on web (single-threaded) but its closure holds the
|
|
260
|
+
* opaque plain function, which native builds reject when the transition's
|
|
261
|
+
* config is serialized to the UI thread.
|
|
262
262
|
*
|
|
263
263
|
* Reanimated 4 changed `Easing.bezier(...)` to return an
|
|
264
264
|
* `EasingFunctionFactory` (`{ factory: () => EasingFunction }`) rather than
|
|
@@ -479,9 +479,17 @@ interface UseTransformOptions {
|
|
|
479
479
|
* const distance = useTransform(() => Math.sqrt(x.value ** 2 + y.value ** 2))
|
|
480
480
|
* ```
|
|
481
481
|
*
|
|
482
|
-
* The transformer
|
|
483
|
-
*
|
|
484
|
-
*
|
|
482
|
+
* The transformer MUST be a worklet — put the `'worklet'` directive as its
|
|
483
|
+
* first statement so the consumer's Babel plugin captures the shared values
|
|
484
|
+
* it reads as its closure. It runs on the UI thread on every frame where
|
|
485
|
+
* any read shared value changes.
|
|
486
|
+
*
|
|
487
|
+
* A plain function cannot work here, and the hook warns in dev when it gets
|
|
488
|
+
* one: the best-effort wrapper it falls back to closes over the opaque
|
|
489
|
+
* function reference, not the shared values read inside it, so Reanimated
|
|
490
|
+
* can't track them as dependencies — the derived value only refreshes on
|
|
491
|
+
* React re-renders, and native builds reject the plain function when the
|
|
492
|
+
* closure crosses to the UI thread.
|
|
485
493
|
*/
|
|
486
494
|
declare function useTransform<T>(transformer: () => T): SharedValue<T>;
|
|
487
495
|
/**
|
|
@@ -547,11 +555,42 @@ interface UseScrollResult {
|
|
|
547
555
|
*/
|
|
548
556
|
declare function useScroll(): UseScrollResult;
|
|
549
557
|
|
|
558
|
+
/**
|
|
559
|
+
* CSS `box-shadow` parsing + pairing for `useShadow`.
|
|
560
|
+
*
|
|
561
|
+
* Design systems store web elevation tokens as CSS `box-shadow` strings
|
|
562
|
+
* (`'0px 1px 2px rgba(0,0,0,0.3), 0px 1px 3px 1px rgba(0,0,0,0.15)'`).
|
|
563
|
+
* Like `cubicBezier`, this module makes those tokens directly consumable:
|
|
564
|
+
* strings are parsed once on the JS thread into flat layer records the
|
|
565
|
+
* `useShadow` worklet can interpolate without any frame-time string work.
|
|
566
|
+
*
|
|
567
|
+
* Invalid input **throws** rather than warning — shadow tokens are
|
|
568
|
+
* constructed at theme/module setup, and a malformed token should fail
|
|
569
|
+
* loudly there, not silently render the wrong elevation.
|
|
570
|
+
*/
|
|
571
|
+
/**
|
|
572
|
+
* One layer of a `box-shadow`, structurally mirroring React Native's
|
|
573
|
+
* `BoxShadowValue` (RN 0.76+ `boxShadow` style). Lengths are px numbers.
|
|
574
|
+
*/
|
|
575
|
+
interface BoxShadowLayer {
|
|
576
|
+
offsetX: number;
|
|
577
|
+
offsetY: number;
|
|
578
|
+
/** Must be >= 0, per CSS. @default 0 */
|
|
579
|
+
blurRadius?: number;
|
|
580
|
+
/** @default 0 */
|
|
581
|
+
spreadDistance?: number;
|
|
582
|
+
/** Any color string Reanimated's `interpolateColor` accepts. @default 'black' */
|
|
583
|
+
color?: string;
|
|
584
|
+
/** @default false */
|
|
585
|
+
inset?: boolean;
|
|
586
|
+
}
|
|
587
|
+
|
|
550
588
|
/**
|
|
551
589
|
* Shape accepted on either end of a `useShadow` tween. Every field is
|
|
552
590
|
* optional — only keys present on at least one side participate in the
|
|
553
591
|
* output style. Mirrors the flat shadow keys on `Motion.View`'s `animate`
|
|
554
|
-
* surface, plus the nested `shadowOffset` source
|
|
592
|
+
* surface, plus the nested `shadowOffset` source and the CSS `boxShadow`
|
|
593
|
+
* surface.
|
|
555
594
|
*/
|
|
556
595
|
interface ShadowConfig {
|
|
557
596
|
shadowOpacity?: number;
|
|
@@ -563,6 +602,19 @@ interface ShadowConfig {
|
|
|
563
602
|
/** Android elevation. iOS shadow consumers can leave this off. */
|
|
564
603
|
elevation?: number;
|
|
565
604
|
shadowColor?: string;
|
|
605
|
+
/**
|
|
606
|
+
* CSS `box-shadow` — the shadow surface on web (react-native-web passes
|
|
607
|
+
* it through as CSS) and on React Native 0.76+ new-architecture native.
|
|
608
|
+
* Accepts the CSS string form design systems store elevation tokens in
|
|
609
|
+
* (`'0px 1px 2px rgba(0,0,0,0.3), 0px 1px 3px 1px rgba(0,0,0,0.15)'`;
|
|
610
|
+
* px lengths only) or structured layers. Multi-layer shadows interpolate
|
|
611
|
+
* per layer; when one side has fewer layers, it is padded with invisible
|
|
612
|
+
* layers, CSS-transition style. A malformed string **throws** at render
|
|
613
|
+
* (like `cubicBezier` — token mistakes should fail loudly at setup).
|
|
614
|
+
* The classic `shadow*`/`elevation` keys don't reach the web renderer —
|
|
615
|
+
* provide `boxShadow` alongside them when the tween must show up there.
|
|
616
|
+
*/
|
|
617
|
+
boxShadow?: string | readonly BoxShadowLayer[];
|
|
566
618
|
}
|
|
567
619
|
interface UseShadowOptions {
|
|
568
620
|
/** Shadow state at `progress === 0`. */
|
|
@@ -599,6 +651,19 @@ interface UseShadowOptions {
|
|
|
599
651
|
* `shadowColor`, `{ width: 0, height: 0 }` for `shadowOffset`). This is a
|
|
600
652
|
* pure interpolator — to "animate" the shadow, drive `progress` with a
|
|
601
653
|
* spring, timing, or gesture upstream.
|
|
654
|
+
*
|
|
655
|
+
* The classic `shadow*`/`elevation` keys don't render on web. When the
|
|
656
|
+
* tween must show up there (or on RN 0.76+ new-arch native via the CSS
|
|
657
|
+
* shadow model), provide `boxShadow` on both ends — CSS string tokens or
|
|
658
|
+
* structured layers; multi-layer shadows interpolate per layer:
|
|
659
|
+
*
|
|
660
|
+
* ```tsx
|
|
661
|
+
* const shadowStyle = useShadow({
|
|
662
|
+
* from: { boxShadow: theme.elevation.level1 }, // '0px 1px 2px rgba(0,0,0,0.3), 0px 1px 3px 1px rgba(0,0,0,0.15)'
|
|
663
|
+
* to: { boxShadow: theme.elevation.level2 },
|
|
664
|
+
* progress,
|
|
665
|
+
* })
|
|
666
|
+
* ```
|
|
602
667
|
*/
|
|
603
668
|
declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnType<typeof useAnimatedStyle>;
|
|
604
669
|
|
|
@@ -615,4 +680,4 @@ declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnTyp
|
|
|
615
680
|
*/
|
|
616
681
|
declare function useVariants<V extends Readonly<Record<string, object>>>(variants: V, initial?: keyof V & string): VariantController<keyof V & string>;
|
|
617
682
|
|
|
618
|
-
export { AnimatableValue, type ColorStyleKey, EasingInput, type ExtrapolationMode, Motion, MotionComponent, MotionConfig, type MotionConfigProps, type MotionConfigValue, NamedTransitions, Presence, type PresenceContextValue, type ReducedMotion, type ShadowConfig, SpringTransition, TransitionConfig, TransitionInput, TransitionName, type UseColorTransitionOptions, type UseScrollResult, type UseShadowOptions, type UseTransformOptions, VariantController, buildReleaseAnimation, createMotionComponent, cubicBezier, ensureWorkletEasing, resolveAnimatableValue, resolveNamedTransition, resolveTransition, useAnimation, useBooleanSpring, useColorTransition, useMotionConfig, useMotionValue, useNamedTransitions, usePresence, useScroll, useShadow, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
|
683
|
+
export { AnimatableValue, type BoxShadowLayer, type ColorStyleKey, EasingInput, type ExtrapolationMode, Motion, MotionComponent, MotionConfig, type MotionConfigProps, type MotionConfigValue, NamedTransitions, Presence, type PresenceContextValue, type ReducedMotion, type ShadowConfig, SpringTransition, TransitionConfig, TransitionInput, TransitionName, type UseColorTransitionOptions, type UseScrollResult, type UseShadowOptions, type UseTransformOptions, VariantController, buildReleaseAnimation, createMotionComponent, cubicBezier, ensureWorkletEasing, resolveAnimatableValue, resolveNamedTransition, resolveTransition, useAnimation, useBooleanSpring, useColorTransition, useMotionConfig, useMotionValue, useNamedTransitions, usePresence, useScroll, useShadow, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
3
|
+
var chunk4PEHWDAZ_js = require('./chunk-4PEHWDAZ.js');
|
|
4
|
+
var chunk4QGXK6TF_js = require('./chunk-4QGXK6TF.js');
|
|
5
|
+
var chunkZ7HIOFKQ_js = require('./chunk-Z7HIOFKQ.js');
|
|
6
|
+
var chunk3UTJJ4A3_js = require('./chunk-3UTJJ4A3.js');
|
|
7
|
+
var chunkTDSO63CJ_js = require('./chunk-TDSO63CJ.js');
|
|
8
|
+
var chunk2HYD2ZBK_js = require('./chunk-2HYD2ZBK.js');
|
|
9
|
+
var chunk7UDYEFBU_js = require('./chunk-7UDYEFBU.js');
|
|
10
|
+
var chunk7AOERN53_js = require('./chunk-7AOERN53.js');
|
|
11
|
+
var chunkPTRF47DA_js = require('./chunk-PTRF47DA.js');
|
|
12
12
|
var react = require('react');
|
|
13
13
|
var reactNativeReanimated = require('react-native-reanimated');
|
|
14
14
|
var reactNativeWorklets = require('react-native-worklets');
|
|
15
15
|
|
|
16
16
|
// src/motion/index.ts
|
|
17
17
|
var Motion = {
|
|
18
|
-
View:
|
|
19
|
-
Text:
|
|
20
|
-
Image:
|
|
21
|
-
Pressable:
|
|
22
|
-
ScrollView:
|
|
18
|
+
View: chunk4QGXK6TF_js.MotionView,
|
|
19
|
+
Text: chunkZ7HIOFKQ_js.MotionText,
|
|
20
|
+
Image: chunk3UTJJ4A3_js.MotionImage,
|
|
21
|
+
Pressable: chunkTDSO63CJ_js.MotionPressable,
|
|
22
|
+
ScrollView: chunk2HYD2ZBK_js.MotionScrollView
|
|
23
23
|
};
|
|
24
24
|
function useAnimation(target, transition) {
|
|
25
25
|
const output = reactNativeReanimated.useSharedValue(target);
|
|
26
|
-
const shouldReduceMotion =
|
|
27
|
-
const resolved =
|
|
28
|
-
const cfgSig =
|
|
26
|
+
const shouldReduceMotion = chunk7AOERN53_js.useShouldReduceMotion();
|
|
27
|
+
const resolved = chunk7AOERN53_js.resolveNamedTransition(transition, chunk7AOERN53_js.useNamedTransitions());
|
|
28
|
+
const cfgSig = chunkPTRF47DA_js.stableSig(resolved);
|
|
29
29
|
react.useEffect(() => {
|
|
30
30
|
const cfg = shouldReduceMotion ? { type: "no-animation" } : resolved ?? { type: "spring" };
|
|
31
|
-
output.value =
|
|
31
|
+
output.value = chunkPTRF47DA_js.resolveTransition(cfg, target);
|
|
32
32
|
}, [target, cfgSig, shouldReduceMotion]);
|
|
33
33
|
return output;
|
|
34
34
|
}
|
|
35
35
|
function useSpring(target, config) {
|
|
36
|
-
const spring = resolveSpringInput(config,
|
|
36
|
+
const spring = resolveSpringInput(config, chunk7AOERN53_js.useNamedTransitions());
|
|
37
37
|
const reanimConfig = react.useMemo(
|
|
38
|
-
() =>
|
|
38
|
+
() => chunkPTRF47DA_js.springToReanimated(spring ?? {}),
|
|
39
39
|
// Keyed on the resolved primitive fields rather than the `config` object
|
|
40
40
|
// identity: callers routinely pass a fresh object literal each render, so
|
|
41
41
|
// depending on `config` itself would rebuild the Reanimated config on
|
|
@@ -74,7 +74,7 @@ function useSpring(target, config) {
|
|
|
74
74
|
}
|
|
75
75
|
function resolveSpringInput(config, registry) {
|
|
76
76
|
if (typeof config !== "string") return config;
|
|
77
|
-
const cfg =
|
|
77
|
+
const cfg = chunk7AOERN53_js.lookupNamedTransition(config, registry);
|
|
78
78
|
if (cfg.type === void 0 || cfg.type === "spring") return cfg;
|
|
79
79
|
if (__DEV__) {
|
|
80
80
|
console.warn(
|
|
@@ -107,10 +107,18 @@ function useTransform(arg1, inputRange, outputRange, options) {
|
|
|
107
107
|
let producer;
|
|
108
108
|
if (typeof arg1 === "function") {
|
|
109
109
|
const userFn = arg1;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
if (reactNativeWorklets.isWorkletFunction(userFn)) {
|
|
111
|
+
producer = userFn;
|
|
112
|
+
} else {
|
|
113
|
+
chunkPTRF47DA_js.warnNonWorkletOnce(
|
|
114
|
+
"useTransform-transformer",
|
|
115
|
+
"[inertia] useTransform: the transformer is not a worklet, so the shared values it reads can't be tracked as dependencies \u2014 the derived value will only refresh on React re-renders, and native builds reject plain functions on the UI thread. Add the 'worklet' directive as the first statement of the transformer."
|
|
116
|
+
);
|
|
117
|
+
producer = () => {
|
|
118
|
+
"worklet";
|
|
119
|
+
return userFn();
|
|
120
|
+
};
|
|
121
|
+
}
|
|
114
122
|
} else {
|
|
115
123
|
const source = arg1;
|
|
116
124
|
const input = inputRange;
|
|
@@ -158,6 +166,127 @@ function useScroll() {
|
|
|
158
166
|
onScroll: handler
|
|
159
167
|
};
|
|
160
168
|
}
|
|
169
|
+
|
|
170
|
+
// src/internal/boxShadow.ts
|
|
171
|
+
var LENGTH = /^[+-]?(\d+\.?\d*|\.\d+)(px)?$/i;
|
|
172
|
+
var UNIT_LIKE = /^[+-]?(\d+\.?\d*|\.\d+)[a-z%]+$/i;
|
|
173
|
+
function invalid(input, reason) {
|
|
174
|
+
return new Error(
|
|
175
|
+
`[inertia] parseBoxShadow: ${reason} in ${JSON.stringify(input)}. Expected CSS box-shadow syntax with px lengths: '[inset] <offset-x> <offset-y> [blur] [spread] [color], ...'`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
function splitLayers(input) {
|
|
179
|
+
const layers = [];
|
|
180
|
+
let depth = 0;
|
|
181
|
+
let start = 0;
|
|
182
|
+
for (let i = 0; i < input.length; i++) {
|
|
183
|
+
const ch = input[i];
|
|
184
|
+
if (ch === "(") depth++;
|
|
185
|
+
else if (ch === ")") depth--;
|
|
186
|
+
else if (ch === "," && depth === 0) {
|
|
187
|
+
layers.push(input.slice(start, i));
|
|
188
|
+
start = i + 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
layers.push(input.slice(start));
|
|
192
|
+
return layers;
|
|
193
|
+
}
|
|
194
|
+
function tokenize(layer) {
|
|
195
|
+
const tokens = [];
|
|
196
|
+
let depth = 0;
|
|
197
|
+
let current = "";
|
|
198
|
+
for (const ch of layer) {
|
|
199
|
+
if (ch === "(") depth++;
|
|
200
|
+
else if (ch === ")") depth--;
|
|
201
|
+
if (depth === 0 && /\s/.test(ch)) {
|
|
202
|
+
if (current) tokens.push(current);
|
|
203
|
+
current = "";
|
|
204
|
+
} else {
|
|
205
|
+
current += ch;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (current) tokens.push(current);
|
|
209
|
+
return tokens;
|
|
210
|
+
}
|
|
211
|
+
function parseBoxShadow(input) {
|
|
212
|
+
const trimmed = input.trim();
|
|
213
|
+
if (trimmed === "") throw invalid(input, "empty string");
|
|
214
|
+
if (trimmed.toLowerCase() === "none") return [];
|
|
215
|
+
return splitLayers(trimmed).map((layerString) => {
|
|
216
|
+
const tokens = tokenize(layerString.trim());
|
|
217
|
+
if (tokens.length === 0) throw invalid(input, "empty layer");
|
|
218
|
+
const lengths = [];
|
|
219
|
+
let color;
|
|
220
|
+
let inset = false;
|
|
221
|
+
for (const token of tokens) {
|
|
222
|
+
if (token.toLowerCase() === "inset") {
|
|
223
|
+
if (inset) throw invalid(input, "duplicate 'inset'");
|
|
224
|
+
inset = true;
|
|
225
|
+
} else if (LENGTH.test(token)) {
|
|
226
|
+
lengths.push(parseFloat(token));
|
|
227
|
+
} else if (UNIT_LIKE.test(token)) {
|
|
228
|
+
throw invalid(input, `unsupported unit in ${JSON.stringify(token)}`);
|
|
229
|
+
} else {
|
|
230
|
+
if (color !== void 0) throw invalid(input, "multiple colors");
|
|
231
|
+
color = token;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (lengths.length < 2 || lengths.length > 4) {
|
|
235
|
+
throw invalid(input, `expected 2-4 lengths, got ${lengths.length}`);
|
|
236
|
+
}
|
|
237
|
+
const [offsetX = 0, offsetY = 0, blurRadius = 0, spreadDistance = 0] = lengths;
|
|
238
|
+
if (blurRadius < 0) throw invalid(input, "negative blur radius");
|
|
239
|
+
return {
|
|
240
|
+
offsetX,
|
|
241
|
+
offsetY,
|
|
242
|
+
blurRadius,
|
|
243
|
+
spreadDistance,
|
|
244
|
+
color: color ?? "black",
|
|
245
|
+
inset
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function resolveBoxShadowInput(input) {
|
|
250
|
+
if (input === void 0) return [];
|
|
251
|
+
if (typeof input === "string") return parseBoxShadow(input);
|
|
252
|
+
return input.map((layer) => ({
|
|
253
|
+
offsetX: layer.offsetX,
|
|
254
|
+
offsetY: layer.offsetY,
|
|
255
|
+
blurRadius: layer.blurRadius ?? 0,
|
|
256
|
+
spreadDistance: layer.spreadDistance ?? 0,
|
|
257
|
+
color: layer.color ?? "black",
|
|
258
|
+
inset: layer.inset ?? false
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
function pairBoxShadowLayers(from, to) {
|
|
262
|
+
const count = Math.max(from.length, to.length);
|
|
263
|
+
const pairs = [];
|
|
264
|
+
for (let i = 0; i < count; i++) {
|
|
265
|
+
const a = from[i];
|
|
266
|
+
const b = to[i];
|
|
267
|
+
const fromLayer = a ?? invisibleLayer(b.inset);
|
|
268
|
+
const toLayer = b ?? invisibleLayer(a.inset);
|
|
269
|
+
if (fromLayer.inset !== toLayer.inset) {
|
|
270
|
+
throw new Error(
|
|
271
|
+
`[inertia] useShadow: boxShadow layer ${i} is 'inset' on one side but not the other \u2014 inset cannot be interpolated. Give both sides the same inset-ness (pad with a transparent layer if needed).`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
pairs.push({ from: fromLayer, to: toLayer });
|
|
275
|
+
}
|
|
276
|
+
return pairs;
|
|
277
|
+
}
|
|
278
|
+
function invisibleLayer(inset) {
|
|
279
|
+
return {
|
|
280
|
+
offsetX: 0,
|
|
281
|
+
offsetY: 0,
|
|
282
|
+
blurRadius: 0,
|
|
283
|
+
spreadDistance: 0,
|
|
284
|
+
color: "transparent",
|
|
285
|
+
inset
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/values/useShadow.ts
|
|
161
290
|
function useShadow({
|
|
162
291
|
from,
|
|
163
292
|
to,
|
|
@@ -168,6 +297,10 @@ function useShadow({
|
|
|
168
297
|
const hasElevation = from.elevation !== void 0 || to.elevation !== void 0;
|
|
169
298
|
const hasColor = from.shadowColor !== void 0 || to.shadowColor !== void 0;
|
|
170
299
|
const hasOffset = from.shadowOffset !== void 0 || to.shadowOffset !== void 0;
|
|
300
|
+
const boxShadowPairs = from.boxShadow !== void 0 || to.boxShadow !== void 0 ? pairBoxShadowLayers(
|
|
301
|
+
resolveBoxShadowInput(from.boxShadow),
|
|
302
|
+
resolveBoxShadowInput(to.boxShadow)
|
|
303
|
+
) : [];
|
|
171
304
|
const opacityFrom = from.shadowOpacity ?? 0;
|
|
172
305
|
const opacityTo = to.shadowOpacity ?? 0;
|
|
173
306
|
const radiusFrom = from.shadowRadius ?? 0;
|
|
@@ -202,6 +335,31 @@ function useShadow({
|
|
|
202
335
|
height: reactNativeReanimated.interpolate(t, [0, 1], [offsetHFrom, offsetHTo])
|
|
203
336
|
};
|
|
204
337
|
}
|
|
338
|
+
if (boxShadowPairs.length > 0) {
|
|
339
|
+
let css = "";
|
|
340
|
+
let first = true;
|
|
341
|
+
for (const pair of boxShadowPairs) {
|
|
342
|
+
const x = reactNativeReanimated.interpolate(t, [0, 1], [pair.from.offsetX, pair.to.offsetX]);
|
|
343
|
+
const y = reactNativeReanimated.interpolate(t, [0, 1], [pair.from.offsetY, pair.to.offsetY]);
|
|
344
|
+
const blur = Math.max(
|
|
345
|
+
0,
|
|
346
|
+
reactNativeReanimated.interpolate(t, [0, 1], [pair.from.blurRadius, pair.to.blurRadius])
|
|
347
|
+
);
|
|
348
|
+
const spread = reactNativeReanimated.interpolate(
|
|
349
|
+
t,
|
|
350
|
+
[0, 1],
|
|
351
|
+
[pair.from.spreadDistance, pair.to.spreadDistance]
|
|
352
|
+
);
|
|
353
|
+
const color = reactNativeReanimated.interpolateColor(
|
|
354
|
+
t,
|
|
355
|
+
[0, 1],
|
|
356
|
+
[pair.from.color, pair.to.color]
|
|
357
|
+
);
|
|
358
|
+
css += (first ? "" : ", ") + (pair.from.inset ? "inset " : "") + `${x}px ${y}px ${blur}px ${spread}px ${color}`;
|
|
359
|
+
first = false;
|
|
360
|
+
}
|
|
361
|
+
out.boxShadow = css;
|
|
362
|
+
}
|
|
205
363
|
return out;
|
|
206
364
|
});
|
|
207
365
|
}
|
|
@@ -240,79 +398,79 @@ function useVariants(variants, initial) {
|
|
|
240
398
|
|
|
241
399
|
Object.defineProperty(exports, "useGesture", {
|
|
242
400
|
enumerable: true,
|
|
243
|
-
get: function () { return
|
|
401
|
+
get: function () { return chunk4PEHWDAZ_js.useGesture; }
|
|
244
402
|
});
|
|
245
403
|
Object.defineProperty(exports, "MotionView", {
|
|
246
404
|
enumerable: true,
|
|
247
|
-
get: function () { return
|
|
405
|
+
get: function () { return chunk4QGXK6TF_js.MotionView; }
|
|
248
406
|
});
|
|
249
407
|
Object.defineProperty(exports, "MotionText", {
|
|
250
408
|
enumerable: true,
|
|
251
|
-
get: function () { return
|
|
409
|
+
get: function () { return chunkZ7HIOFKQ_js.MotionText; }
|
|
252
410
|
});
|
|
253
411
|
Object.defineProperty(exports, "MotionImage", {
|
|
254
412
|
enumerable: true,
|
|
255
|
-
get: function () { return
|
|
413
|
+
get: function () { return chunk3UTJJ4A3_js.MotionImage; }
|
|
256
414
|
});
|
|
257
415
|
Object.defineProperty(exports, "MotionPressable", {
|
|
258
416
|
enumerable: true,
|
|
259
|
-
get: function () { return
|
|
417
|
+
get: function () { return chunkTDSO63CJ_js.MotionPressable; }
|
|
260
418
|
});
|
|
261
419
|
Object.defineProperty(exports, "MotionScrollView", {
|
|
262
420
|
enumerable: true,
|
|
263
|
-
get: function () { return
|
|
421
|
+
get: function () { return chunk2HYD2ZBK_js.MotionScrollView; }
|
|
264
422
|
});
|
|
265
423
|
Object.defineProperty(exports, "Presence", {
|
|
266
424
|
enumerable: true,
|
|
267
|
-
get: function () { return
|
|
425
|
+
get: function () { return chunk7UDYEFBU_js.Presence; }
|
|
268
426
|
});
|
|
269
427
|
Object.defineProperty(exports, "createMotionComponent", {
|
|
270
428
|
enumerable: true,
|
|
271
|
-
get: function () { return
|
|
429
|
+
get: function () { return chunk7UDYEFBU_js.createMotionComponent; }
|
|
272
430
|
});
|
|
273
431
|
Object.defineProperty(exports, "usePresence", {
|
|
274
432
|
enumerable: true,
|
|
275
|
-
get: function () { return
|
|
433
|
+
get: function () { return chunk7UDYEFBU_js.usePresence; }
|
|
276
434
|
});
|
|
277
435
|
Object.defineProperty(exports, "MotionConfig", {
|
|
278
436
|
enumerable: true,
|
|
279
|
-
get: function () { return
|
|
437
|
+
get: function () { return chunk7AOERN53_js.MotionConfig; }
|
|
280
438
|
});
|
|
281
439
|
Object.defineProperty(exports, "resolveNamedTransition", {
|
|
282
440
|
enumerable: true,
|
|
283
|
-
get: function () { return
|
|
441
|
+
get: function () { return chunk7AOERN53_js.resolveNamedTransition; }
|
|
284
442
|
});
|
|
285
443
|
Object.defineProperty(exports, "useMotionConfig", {
|
|
286
444
|
enumerable: true,
|
|
287
|
-
get: function () { return
|
|
445
|
+
get: function () { return chunk7AOERN53_js.useMotionConfig; }
|
|
288
446
|
});
|
|
289
447
|
Object.defineProperty(exports, "useNamedTransitions", {
|
|
290
448
|
enumerable: true,
|
|
291
|
-
get: function () { return
|
|
449
|
+
get: function () { return chunk7AOERN53_js.useNamedTransitions; }
|
|
292
450
|
});
|
|
293
451
|
Object.defineProperty(exports, "useShouldReduceMotion", {
|
|
294
452
|
enumerable: true,
|
|
295
|
-
get: function () { return
|
|
453
|
+
get: function () { return chunk7AOERN53_js.useShouldReduceMotion; }
|
|
296
454
|
});
|
|
297
455
|
Object.defineProperty(exports, "buildReleaseAnimation", {
|
|
298
456
|
enumerable: true,
|
|
299
|
-
get: function () { return
|
|
457
|
+
get: function () { return chunkPTRF47DA_js.buildReleaseAnimation; }
|
|
300
458
|
});
|
|
301
459
|
Object.defineProperty(exports, "cubicBezier", {
|
|
302
460
|
enumerable: true,
|
|
303
|
-
get: function () { return
|
|
461
|
+
get: function () { return chunkPTRF47DA_js.cubicBezier; }
|
|
304
462
|
});
|
|
305
463
|
Object.defineProperty(exports, "ensureWorkletEasing", {
|
|
306
464
|
enumerable: true,
|
|
307
|
-
get: function () { return
|
|
465
|
+
get: function () { return chunkPTRF47DA_js.ensureWorkletEasing; }
|
|
308
466
|
});
|
|
309
467
|
Object.defineProperty(exports, "resolveAnimatableValue", {
|
|
310
468
|
enumerable: true,
|
|
311
|
-
get: function () { return
|
|
469
|
+
get: function () { return chunkPTRF47DA_js.resolveAnimatableValue; }
|
|
312
470
|
});
|
|
313
471
|
Object.defineProperty(exports, "resolveTransition", {
|
|
314
472
|
enumerable: true,
|
|
315
|
-
get: function () { return
|
|
473
|
+
get: function () { return chunkPTRF47DA_js.resolveTransition; }
|
|
316
474
|
});
|
|
317
475
|
exports.Motion = Motion;
|
|
318
476
|
exports.useAnimation = useAnimation;
|