@tamagui/animations-react-native 1.0.1-beta.92

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.
@@ -0,0 +1,93 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var createAnimations_exports = {};
19
+ __export(createAnimations_exports, {
20
+ createAnimations: () => createAnimations
21
+ });
22
+ module.exports = __toCommonJS(createAnimations_exports);
23
+ var import_animate_presence = require("@tamagui/animate-presence");
24
+ var import_react = require("react");
25
+ var import_react_native = require("react-native");
26
+ function createAnimations(animations) {
27
+ const AnimatedView = import_react_native.Animated.View;
28
+ const AnimatedText = import_react_native.Animated.Text;
29
+ AnimatedView["displayName"] = "AnimatedView";
30
+ AnimatedText["displayName"] = "AnimatedText";
31
+ return {
32
+ avoidClasses: true,
33
+ animations,
34
+ View: AnimatedView,
35
+ Text: AnimatedText,
36
+ useAnimations: (props, helpers) => {
37
+ var _a, _b;
38
+ const { pseudos, onDidAnimate, delay, getStyle, state, staticConfig } = helpers;
39
+ const [isPresent, sendExitComplete] = (0, import_animate_presence.usePresence)();
40
+ const presence = (0, import_react.useContext)(import_animate_presence.PresenceContext);
41
+ const exitStyle = (presence == null ? void 0 : presence.exitVariant) ? ((_b = (_a = staticConfig.variantsParsed) == null ? void 0 : _a[presence.exitVariant]) == null ? void 0 : _b.true) || pseudos.exitStyle : pseudos.exitStyle;
42
+ const onDidAnimateCb = (0, import_react.useCallback)((...args2) => {
43
+ onDidAnimate == null ? void 0 : onDidAnimate(...args2);
44
+ }, [onDidAnimate]);
45
+ const isExiting = isPresent === false;
46
+ const isEntering = !state.mounted;
47
+ const all = getStyle({
48
+ isExiting,
49
+ isEntering,
50
+ exitVariant: presence == null ? void 0 : presence.exitVariant,
51
+ enterVariant: presence == null ? void 0 : presence.enterVariant
52
+ });
53
+ const animatedValues = (0, import_react.useRef)({});
54
+ const [animatedStyles, nonAnimatedStyle] = [{}, {}];
55
+ const animatedStyleKey = {
56
+ transform: true,
57
+ opacity: true
58
+ };
59
+ for (const key of Object.keys(all)) {
60
+ if (animatedStyleKey[key]) {
61
+ animatedStyles[key] = all[key];
62
+ } else {
63
+ nonAnimatedStyle[key] = all[key];
64
+ }
65
+ }
66
+ const animatedStyle = animatedStyleKey;
67
+ const args = [
68
+ JSON.stringify(all),
69
+ state.mounted,
70
+ state.hover,
71
+ state.press,
72
+ state.pressIn,
73
+ state.focus,
74
+ delay,
75
+ isPresent,
76
+ onDidAnimate,
77
+ onDidAnimateCb,
78
+ presence == null ? void 0 : presence.exitVariant,
79
+ presence == null ? void 0 : presence.enterVariant
80
+ ];
81
+ return (0, import_react.useMemo)(() => {
82
+ return {
83
+ style: [nonAnimatedStyle, animatedStyle]
84
+ };
85
+ }, args);
86
+ }
87
+ };
88
+ }
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ createAnimations
92
+ });
93
+ //# sourceMappingURL=createAnimations.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/createAnimations.tsx"],
4
+ "sourcesContent": ["import { PresenceContext, usePresence } from '@tamagui/animate-presence'\nimport { AnimationDriver, AnimationProp } from '@tamagui/core'\nimport { useCallback, useContext, useMemo, useRef, useState } from 'react'\nimport { Animated } from 'react-native'\n\ntype AnimationsConfig<A extends Object = any> = {\n [Key in keyof A]: AnimationConfig\n}\n\ntype AnimationConfig = {}\n// | ({ type: 'timing'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithTimingConfig)\n// | ({ type: 'spring'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithSpringConfig)\n// | ({ type: 'decay'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithDecayConfig)\n\nexport function createAnimations<A extends AnimationsConfig>(animations: A): AnimationDriver<A> {\n const AnimatedView = Animated.View\n const AnimatedText = Animated.Text\n\n AnimatedView['displayName'] = 'AnimatedView'\n AnimatedText['displayName'] = 'AnimatedText'\n\n return {\n avoidClasses: true,\n animations,\n View: AnimatedView,\n Text: AnimatedText,\n useAnimations: (props, helpers) => {\n const { pseudos, onDidAnimate, delay, getStyle, state, staticConfig } = helpers\n const [isPresent, sendExitComplete] = usePresence()\n const presence = useContext(PresenceContext)\n\n const exitStyle = presence?.exitVariant\n ? staticConfig.variantsParsed?.[presence.exitVariant]?.true || pseudos.exitStyle\n : pseudos.exitStyle\n\n const onDidAnimateCb = useCallback<NonNullable<typeof onDidAnimate>>(\n (...args) => {\n onDidAnimate?.(...args)\n },\n [onDidAnimate]\n )\n\n const isExiting = isPresent === false\n const isEntering = !state.mounted\n\n const all = getStyle({\n isExiting,\n isEntering,\n exitVariant: presence?.exitVariant,\n enterVariant: presence?.enterVariant,\n })\n\n const animatedValues = useRef<Record<string, Animated.Value>>({})\n\n // TODO loop and create values, run them if they change\n\n const [animatedStyles, nonAnimatedStyle] = [{}, {}]\n const animatedStyleKey = {\n transform: true,\n opacity: true,\n }\n for (const key of Object.keys(all)) {\n if (animatedStyleKey[key]) {\n animatedStyles[key] = all[key]\n } else {\n nonAnimatedStyle[key] = all[key]\n }\n }\n\n const animatedStyle = animatedStyleKey\n\n const args = [\n JSON.stringify(all),\n state.mounted,\n state.hover,\n state.press,\n state.pressIn,\n state.focus,\n delay,\n isPresent,\n onDidAnimate,\n onDidAnimateCb,\n presence?.exitVariant,\n presence?.enterVariant,\n ]\n\n // const callback = (\n // isExiting: boolean,\n // exitingStyleProps: Record<string, boolean>,\n // key: string,\n // value: any\n // ) => {\n // return (completed, current) => {\n // onDidAnimateCb(key, completed, current, {\n // attemptedValue: value,\n // })\n // if (isExiting) {\n // exitingStyleProps[key] = false\n // const areStylesExiting = Object.values(exitingStyleProps).some(Boolean)\n // // if this is true, then we've finished our exit animations\n // if (!areStylesExiting) {\n // sendExitComplete?.()\n // }\n // }\n // }\n // }\n\n return useMemo(() => {\n return {\n style: [nonAnimatedStyle, animatedStyle],\n }\n }, args)\n },\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA6C;AAE7C,mBAAmE;AACnE,0BAAyB;AAWlB,0BAAsD,YAAmC;AAC9F,QAAM,eAAe,6BAAS;AAC9B,QAAM,eAAe,6BAAS;AAE9B,eAAa,iBAAiB;AAC9B,eAAa,iBAAiB;AAE9B,SAAO;AAAA,IACL,cAAc;AAAA,IACd;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN,eAAe,CAAC,OAAO,YAAY;AA1BvC;AA2BM,YAAM,EAAE,SAAS,cAAc,OAAO,UAAU,OAAO,iBAAiB;AACxE,YAAM,CAAC,WAAW,oBAAoB,yCAAY;AAClD,YAAM,WAAW,6BAAW,uCAAe;AAE3C,YAAM,YAAY,sCAAU,eACxB,0BAAa,mBAAb,mBAA8B,SAAS,iBAAvC,mBAAqD,SAAQ,QAAQ,YACrE,QAAQ;AAEZ,YAAM,iBAAiB,8BACrB,IAAI,UAAS;AACX,qDAAe,GAAG;AAAA,MACpB,GACA,CAAC,YAAY,CACf;AAEA,YAAM,YAAY,cAAc;AAChC,YAAM,aAAa,CAAC,MAAM;AAE1B,YAAM,MAAM,SAAS;AAAA,QACnB;AAAA,QACA;AAAA,QACA,aAAa,qCAAU;AAAA,QACvB,cAAc,qCAAU;AAAA,MAC1B,CAAC;AAED,YAAM,iBAAiB,yBAAuC,CAAC,CAAC;AAIhE,YAAM,CAAC,gBAAgB,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC;AAClD,YAAM,mBAAmB;AAAA,QACvB,WAAW;AAAA,QACX,SAAS;AAAA,MACX;AACA,iBAAW,OAAO,OAAO,KAAK,GAAG,GAAG;AAClC,YAAI,iBAAiB,MAAM;AACzB,yBAAe,OAAO,IAAI;AAAA,QAC5B,OAAO;AACL,2BAAiB,OAAO,IAAI;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,gBAAgB;AAEtB,YAAM,OAAO;AAAA,QACX,KAAK,UAAU,GAAG;AAAA,QAClB,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,qCAAU;AAAA,QACV,qCAAU;AAAA,MACZ;AAuBA,aAAO,0BAAQ,MAAM;AACnB,eAAO;AAAA,UACL,OAAO,CAAC,kBAAkB,aAAa;AAAA,QACzC;AAAA,MACF,GAAG,IAAI;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./createAnimations"), module.exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "sourcesContent": ["export * from './createAnimations'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,+BAAd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,70 @@
1
+ import { PresenceContext, usePresence } from "@tamagui/animate-presence";
2
+ import { useCallback, useContext, useMemo, useRef } from "react";
3
+ import { Animated } from "react-native";
4
+ function createAnimations(animations) {
5
+ const AnimatedView = Animated.View;
6
+ const AnimatedText = Animated.Text;
7
+ AnimatedView["displayName"] = "AnimatedView";
8
+ AnimatedText["displayName"] = "AnimatedText";
9
+ return {
10
+ avoidClasses: true,
11
+ animations,
12
+ View: AnimatedView,
13
+ Text: AnimatedText,
14
+ useAnimations: (props, helpers) => {
15
+ var _a, _b;
16
+ const { pseudos, onDidAnimate, delay, getStyle, state, staticConfig } = helpers;
17
+ const [isPresent, sendExitComplete] = usePresence();
18
+ const presence = useContext(PresenceContext);
19
+ const exitStyle = (presence == null ? void 0 : presence.exitVariant) ? ((_b = (_a = staticConfig.variantsParsed) == null ? void 0 : _a[presence.exitVariant]) == null ? void 0 : _b.true) || pseudos.exitStyle : pseudos.exitStyle;
20
+ const onDidAnimateCb = useCallback((...args2) => {
21
+ onDidAnimate == null ? void 0 : onDidAnimate(...args2);
22
+ }, [onDidAnimate]);
23
+ const isExiting = isPresent === false;
24
+ const isEntering = !state.mounted;
25
+ const all = getStyle({
26
+ isExiting,
27
+ isEntering,
28
+ exitVariant: presence == null ? void 0 : presence.exitVariant,
29
+ enterVariant: presence == null ? void 0 : presence.enterVariant
30
+ });
31
+ const animatedValues = useRef({});
32
+ const [animatedStyles, nonAnimatedStyle] = [{}, {}];
33
+ const animatedStyleKey = {
34
+ transform: true,
35
+ opacity: true
36
+ };
37
+ for (const key of Object.keys(all)) {
38
+ if (animatedStyleKey[key]) {
39
+ animatedStyles[key] = all[key];
40
+ } else {
41
+ nonAnimatedStyle[key] = all[key];
42
+ }
43
+ }
44
+ const animatedStyle = animatedStyleKey;
45
+ const args = [
46
+ JSON.stringify(all),
47
+ state.mounted,
48
+ state.hover,
49
+ state.press,
50
+ state.pressIn,
51
+ state.focus,
52
+ delay,
53
+ isPresent,
54
+ onDidAnimate,
55
+ onDidAnimateCb,
56
+ presence == null ? void 0 : presence.exitVariant,
57
+ presence == null ? void 0 : presence.enterVariant
58
+ ];
59
+ return useMemo(() => {
60
+ return {
61
+ style: [nonAnimatedStyle, animatedStyle]
62
+ };
63
+ }, args);
64
+ }
65
+ };
66
+ }
67
+ export {
68
+ createAnimations
69
+ };
70
+ //# sourceMappingURL=createAnimations.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/createAnimations.tsx"],
4
+ "sourcesContent": ["import { PresenceContext, usePresence } from '@tamagui/animate-presence'\nimport { AnimationDriver, AnimationProp } from '@tamagui/core'\nimport { useCallback, useContext, useMemo, useRef, useState } from 'react'\nimport { Animated } from 'react-native'\n\ntype AnimationsConfig<A extends Object = any> = {\n [Key in keyof A]: AnimationConfig\n}\n\ntype AnimationConfig = {}\n// | ({ type: 'timing'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithTimingConfig)\n// | ({ type: 'spring'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithSpringConfig)\n// | ({ type: 'decay'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithDecayConfig)\n\nexport function createAnimations<A extends AnimationsConfig>(animations: A): AnimationDriver<A> {\n const AnimatedView = Animated.View\n const AnimatedText = Animated.Text\n\n AnimatedView['displayName'] = 'AnimatedView'\n AnimatedText['displayName'] = 'AnimatedText'\n\n return {\n avoidClasses: true,\n animations,\n View: AnimatedView,\n Text: AnimatedText,\n useAnimations: (props, helpers) => {\n const { pseudos, onDidAnimate, delay, getStyle, state, staticConfig } = helpers\n const [isPresent, sendExitComplete] = usePresence()\n const presence = useContext(PresenceContext)\n\n const exitStyle = presence?.exitVariant\n ? staticConfig.variantsParsed?.[presence.exitVariant]?.true || pseudos.exitStyle\n : pseudos.exitStyle\n\n const onDidAnimateCb = useCallback<NonNullable<typeof onDidAnimate>>(\n (...args) => {\n onDidAnimate?.(...args)\n },\n [onDidAnimate]\n )\n\n const isExiting = isPresent === false\n const isEntering = !state.mounted\n\n const all = getStyle({\n isExiting,\n isEntering,\n exitVariant: presence?.exitVariant,\n enterVariant: presence?.enterVariant,\n })\n\n const animatedValues = useRef<Record<string, Animated.Value>>({})\n\n // TODO loop and create values, run them if they change\n\n const [animatedStyles, nonAnimatedStyle] = [{}, {}]\n const animatedStyleKey = {\n transform: true,\n opacity: true,\n }\n for (const key of Object.keys(all)) {\n if (animatedStyleKey[key]) {\n animatedStyles[key] = all[key]\n } else {\n nonAnimatedStyle[key] = all[key]\n }\n }\n\n const animatedStyle = animatedStyleKey\n\n const args = [\n JSON.stringify(all),\n state.mounted,\n state.hover,\n state.press,\n state.pressIn,\n state.focus,\n delay,\n isPresent,\n onDidAnimate,\n onDidAnimateCb,\n presence?.exitVariant,\n presence?.enterVariant,\n ]\n\n // const callback = (\n // isExiting: boolean,\n // exitingStyleProps: Record<string, boolean>,\n // key: string,\n // value: any\n // ) => {\n // return (completed, current) => {\n // onDidAnimateCb(key, completed, current, {\n // attemptedValue: value,\n // })\n // if (isExiting) {\n // exitingStyleProps[key] = false\n // const areStylesExiting = Object.values(exitingStyleProps).some(Boolean)\n // // if this is true, then we've finished our exit animations\n // if (!areStylesExiting) {\n // sendExitComplete?.()\n // }\n // }\n // }\n // }\n\n return useMemo(() => {\n return {\n style: [nonAnimatedStyle, animatedStyle],\n }\n }, args)\n },\n }\n}\n"],
5
+ "mappings": "AAAA;AAEA;AACA;AA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A;AAAA,QACA;AAAA,QACA;AAAA,QACA,qCAAU;AAAA,QACV,qCAAU;AAAA,MACZ;AAuBA,aAAO,QAAQ,MAAM;AACnB,eAAO;AAAA,UACL,OAAO,CAAC,kBAAkB,aAAa;AAAA,QACzC;AAAA,MACF,GAAG,IAAI;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./createAnimations";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "sourcesContent": ["export * from './createAnimations'\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,70 @@
1
+ import { PresenceContext, usePresence } from "@tamagui/animate-presence";
2
+ import { useCallback, useContext, useMemo, useRef } from "react";
3
+ import { Animated } from "react-native";
4
+ function createAnimations(animations) {
5
+ const AnimatedView = Animated.View;
6
+ const AnimatedText = Animated.Text;
7
+ AnimatedView["displayName"] = "AnimatedView";
8
+ AnimatedText["displayName"] = "AnimatedText";
9
+ return {
10
+ avoidClasses: true,
11
+ animations,
12
+ View: AnimatedView,
13
+ Text: AnimatedText,
14
+ useAnimations: (props, helpers) => {
15
+ var _a, _b;
16
+ const { pseudos, onDidAnimate, delay, getStyle, state, staticConfig } = helpers;
17
+ const [isPresent, sendExitComplete] = usePresence();
18
+ const presence = useContext(PresenceContext);
19
+ const exitStyle = (presence == null ? void 0 : presence.exitVariant) ? ((_b = (_a = staticConfig.variantsParsed) == null ? void 0 : _a[presence.exitVariant]) == null ? void 0 : _b.true) || pseudos.exitStyle : pseudos.exitStyle;
20
+ const onDidAnimateCb = useCallback((...args2) => {
21
+ onDidAnimate == null ? void 0 : onDidAnimate(...args2);
22
+ }, [onDidAnimate]);
23
+ const isExiting = isPresent === false;
24
+ const isEntering = !state.mounted;
25
+ const all = getStyle({
26
+ isExiting,
27
+ isEntering,
28
+ exitVariant: presence == null ? void 0 : presence.exitVariant,
29
+ enterVariant: presence == null ? void 0 : presence.enterVariant
30
+ });
31
+ const animatedValues = useRef({});
32
+ const [animatedStyles, nonAnimatedStyle] = [{}, {}];
33
+ const animatedStyleKey = {
34
+ transform: true,
35
+ opacity: true
36
+ };
37
+ for (const key of Object.keys(all)) {
38
+ if (animatedStyleKey[key]) {
39
+ animatedStyles[key] = all[key];
40
+ } else {
41
+ nonAnimatedStyle[key] = all[key];
42
+ }
43
+ }
44
+ const animatedStyle = animatedStyleKey;
45
+ const args = [
46
+ JSON.stringify(all),
47
+ state.mounted,
48
+ state.hover,
49
+ state.press,
50
+ state.pressIn,
51
+ state.focus,
52
+ delay,
53
+ isPresent,
54
+ onDidAnimate,
55
+ onDidAnimateCb,
56
+ presence == null ? void 0 : presence.exitVariant,
57
+ presence == null ? void 0 : presence.enterVariant
58
+ ];
59
+ return useMemo(() => {
60
+ return {
61
+ style: [nonAnimatedStyle, animatedStyle]
62
+ };
63
+ }, args);
64
+ }
65
+ };
66
+ }
67
+ export {
68
+ createAnimations
69
+ };
70
+ //# sourceMappingURL=createAnimations.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/createAnimations.tsx"],
4
+ "sourcesContent": ["import { PresenceContext, usePresence } from '@tamagui/animate-presence'\nimport { AnimationDriver, AnimationProp } from '@tamagui/core'\nimport { useCallback, useContext, useMemo, useRef, useState } from 'react'\nimport { Animated } from 'react-native'\n\ntype AnimationsConfig<A extends Object = any> = {\n [Key in keyof A]: AnimationConfig\n}\n\ntype AnimationConfig = {}\n// | ({ type: 'timing'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithTimingConfig)\n// | ({ type: 'spring'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithSpringConfig)\n// | ({ type: 'decay'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithDecayConfig)\n\nexport function createAnimations<A extends AnimationsConfig>(animations: A): AnimationDriver<A> {\n const AnimatedView = Animated.View\n const AnimatedText = Animated.Text\n\n AnimatedView['displayName'] = 'AnimatedView'\n AnimatedText['displayName'] = 'AnimatedText'\n\n return {\n avoidClasses: true,\n animations,\n View: AnimatedView,\n Text: AnimatedText,\n useAnimations: (props, helpers) => {\n const { pseudos, onDidAnimate, delay, getStyle, state, staticConfig } = helpers\n const [isPresent, sendExitComplete] = usePresence()\n const presence = useContext(PresenceContext)\n\n const exitStyle = presence?.exitVariant\n ? staticConfig.variantsParsed?.[presence.exitVariant]?.true || pseudos.exitStyle\n : pseudos.exitStyle\n\n const onDidAnimateCb = useCallback<NonNullable<typeof onDidAnimate>>(\n (...args) => {\n onDidAnimate?.(...args)\n },\n [onDidAnimate]\n )\n\n const isExiting = isPresent === false\n const isEntering = !state.mounted\n\n const all = getStyle({\n isExiting,\n isEntering,\n exitVariant: presence?.exitVariant,\n enterVariant: presence?.enterVariant,\n })\n\n const animatedValues = useRef<Record<string, Animated.Value>>({})\n\n // TODO loop and create values, run them if they change\n\n const [animatedStyles, nonAnimatedStyle] = [{}, {}]\n const animatedStyleKey = {\n transform: true,\n opacity: true,\n }\n for (const key of Object.keys(all)) {\n if (animatedStyleKey[key]) {\n animatedStyles[key] = all[key]\n } else {\n nonAnimatedStyle[key] = all[key]\n }\n }\n\n const animatedStyle = animatedStyleKey\n\n const args = [\n JSON.stringify(all),\n state.mounted,\n state.hover,\n state.press,\n state.pressIn,\n state.focus,\n delay,\n isPresent,\n onDidAnimate,\n onDidAnimateCb,\n presence?.exitVariant,\n presence?.enterVariant,\n ]\n\n // const callback = (\n // isExiting: boolean,\n // exitingStyleProps: Record<string, boolean>,\n // key: string,\n // value: any\n // ) => {\n // return (completed, current) => {\n // onDidAnimateCb(key, completed, current, {\n // attemptedValue: value,\n // })\n // if (isExiting) {\n // exitingStyleProps[key] = false\n // const areStylesExiting = Object.values(exitingStyleProps).some(Boolean)\n // // if this is true, then we've finished our exit animations\n // if (!areStylesExiting) {\n // sendExitComplete?.()\n // }\n // }\n // }\n // }\n\n return useMemo(() =>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MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,qCAAU;AAAA,QACV,qCAAU;AAAA,MACZ;AAuBA,aAAO,QAAQ,MAAM;AACnB,eAAO;AAAA,UACL,OAAO,CAAC,kBAAkB,aAAa;AAAA,QACzC;AAAA,MACF,GAAG,IAAI;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./createAnimations";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "sourcesContent": ["export * from './createAnimations'\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@tamagui/animations-react-native",
3
+ "version": "1.0.1-beta.92",
4
+ "source": "src/index.ts",
5
+ "sideEffects": true,
6
+ "license": "MIT",
7
+ "types": "./types/index.d.ts",
8
+ "main": "dist/cjs",
9
+ "module": "dist/esm",
10
+ "module:jsx": "dist/jsx",
11
+ "files": [
12
+ "src",
13
+ "types",
14
+ "dist"
15
+ ],
16
+ "dependencies": {
17
+ "@tamagui/animate-presence": "^1.0.1-beta.92",
18
+ "@tamagui/core": "^1.0.1-beta.92"
19
+ },
20
+ "devDependencies": {
21
+ "@tamagui/build": "^1.0.1-beta.92",
22
+ "react": "*",
23
+ "react-dom": "*",
24
+ "react-native": "*"
25
+ },
26
+ "peerDependencies": {
27
+ "react": "*",
28
+ "react-dom": "*",
29
+ "react-native": "*"
30
+ },
31
+ "scripts": {
32
+ "build": "tamagui-build",
33
+ "watch": "tamagui-build --watch",
34
+ "clean": "tamagui-build clean",
35
+ "clean:build": "tamagui-build clean:build"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
41
+ }
@@ -0,0 +1,115 @@
1
+ import { PresenceContext, usePresence } from '@tamagui/animate-presence'
2
+ import { AnimationDriver, AnimationProp } from '@tamagui/core'
3
+ import { useCallback, useContext, useMemo, useRef, useState } from 'react'
4
+ import { Animated } from 'react-native'
5
+
6
+ type AnimationsConfig<A extends Object = any> = {
7
+ [Key in keyof A]: AnimationConfig
8
+ }
9
+
10
+ type AnimationConfig = {}
11
+ // | ({ type: 'timing'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithTimingConfig)
12
+ // | ({ type: 'spring'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithSpringConfig)
13
+ // | ({ type: 'decay'; loop?: number; repeat?: number; repeatReverse?: boolean } & WithDecayConfig)
14
+
15
+ export function createAnimations<A extends AnimationsConfig>(animations: A): AnimationDriver<A> {
16
+ const AnimatedView = Animated.View
17
+ const AnimatedText = Animated.Text
18
+
19
+ AnimatedView['displayName'] = 'AnimatedView'
20
+ AnimatedText['displayName'] = 'AnimatedText'
21
+
22
+ return {
23
+ avoidClasses: true,
24
+ animations,
25
+ View: AnimatedView,
26
+ Text: AnimatedText,
27
+ useAnimations: (props, helpers) => {
28
+ const { pseudos, onDidAnimate, delay, getStyle, state, staticConfig } = helpers
29
+ const [isPresent, sendExitComplete] = usePresence()
30
+ const presence = useContext(PresenceContext)
31
+
32
+ const exitStyle = presence?.exitVariant
33
+ ? staticConfig.variantsParsed?.[presence.exitVariant]?.true || pseudos.exitStyle
34
+ : pseudos.exitStyle
35
+
36
+ const onDidAnimateCb = useCallback<NonNullable<typeof onDidAnimate>>(
37
+ (...args) => {
38
+ onDidAnimate?.(...args)
39
+ },
40
+ [onDidAnimate]
41
+ )
42
+
43
+ const isExiting = isPresent === false
44
+ const isEntering = !state.mounted
45
+
46
+ const all = getStyle({
47
+ isExiting,
48
+ isEntering,
49
+ exitVariant: presence?.exitVariant,
50
+ enterVariant: presence?.enterVariant,
51
+ })
52
+
53
+ const animatedValues = useRef<Record<string, Animated.Value>>({})
54
+
55
+ // TODO loop and create values, run them if they change
56
+
57
+ const [animatedStyles, nonAnimatedStyle] = [{}, {}]
58
+ const animatedStyleKey = {
59
+ transform: true,
60
+ opacity: true,
61
+ }
62
+ for (const key of Object.keys(all)) {
63
+ if (animatedStyleKey[key]) {
64
+ animatedStyles[key] = all[key]
65
+ } else {
66
+ nonAnimatedStyle[key] = all[key]
67
+ }
68
+ }
69
+
70
+ const animatedStyle = animatedStyleKey
71
+
72
+ const args = [
73
+ JSON.stringify(all),
74
+ state.mounted,
75
+ state.hover,
76
+ state.press,
77
+ state.pressIn,
78
+ state.focus,
79
+ delay,
80
+ isPresent,
81
+ onDidAnimate,
82
+ onDidAnimateCb,
83
+ presence?.exitVariant,
84
+ presence?.enterVariant,
85
+ ]
86
+
87
+ // const callback = (
88
+ // isExiting: boolean,
89
+ // exitingStyleProps: Record<string, boolean>,
90
+ // key: string,
91
+ // value: any
92
+ // ) => {
93
+ // return (completed, current) => {
94
+ // onDidAnimateCb(key, completed, current, {
95
+ // attemptedValue: value,
96
+ // })
97
+ // if (isExiting) {
98
+ // exitingStyleProps[key] = false
99
+ // const areStylesExiting = Object.values(exitingStyleProps).some(Boolean)
100
+ // // if this is true, then we've finished our exit animations
101
+ // if (!areStylesExiting) {
102
+ // sendExitComplete?.()
103
+ // }
104
+ // }
105
+ // }
106
+ // }
107
+
108
+ return useMemo(() => {
109
+ return {
110
+ style: [nonAnimatedStyle, animatedStyle],
111
+ }
112
+ }, args)
113
+ },
114
+ }
115
+ }
package/src/index.tsx ADDED
@@ -0,0 +1 @@
1
+ export * from './createAnimations'
@@ -0,0 +1,8 @@
1
+ import { AnimationDriver } from '@tamagui/core';
2
+ declare type AnimationsConfig<A extends Object = any> = {
3
+ [Key in keyof A]: AnimationConfig;
4
+ };
5
+ declare type AnimationConfig = {};
6
+ export declare function createAnimations<A extends AnimationsConfig>(animations: A): AnimationDriver<A>;
7
+ export {};
8
+ //# sourceMappingURL=createAnimations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAnimations.d.ts","sourceRoot":"","sources":["../src/createAnimations.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAiB,MAAM,eAAe,CAAA;AAI9D,aAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,IAAI;KAC7C,GAAG,IAAI,MAAM,CAAC,GAAG,eAAe;CAClC,CAAA;AAED,aAAK,eAAe,GAAG,EAAE,CAAA;AAKzB,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,gBAAgB,EAAE,UAAU,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAoG9F"}
@@ -0,0 +1,2 @@
1
+ export * from './createAnimations';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}