@hanzogui/animations-moti 2.0.0-rc.41-hanzoai.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,308 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
34
+ var createAnimations_exports = {};
35
+ __export(createAnimations_exports, {
36
+ createAnimations: () => createAnimations
37
+ });
38
+ module.exports = __toCommonJS(createAnimations_exports);
39
+ var import_use_presence = require("@hanzogui/use-presence");
40
+ var import_core = require("@hanzogui/core");
41
+ var import_author = require("moti/author");
42
+ var import_react = __toESM(require("react"), 1);
43
+ var import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1);
44
+ var import_jsx_runtime = require("react/jsx-runtime");
45
+ const resolveDynamicValue = (value, isDark) => {
46
+ if (value && typeof value === "object" && "dynamic" in value) {
47
+ const dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light;
48
+ return dynamicValue;
49
+ }
50
+ return value;
51
+ };
52
+ const safeESModule = a => {
53
+ const b = a;
54
+ const out = b.__esModule || b[Symbol.toStringTag] === "Module" ? b.default : b;
55
+ return out || a;
56
+ };
57
+ const Animated = safeESModule(import_react_native_reanimated.default);
58
+ function createHanzoguiAnimatedComponent(defaultTag = "div") {
59
+ const isText = defaultTag === "span";
60
+ const Component = Animated.createAnimatedComponent((0, import_react.forwardRef)((propsIn, ref) => {
61
+ const {
62
+ forwardedRef,
63
+ animation,
64
+ render = defaultTag,
65
+ ...propsRest
66
+ } = propsIn;
67
+ const hostRef = (0, import_react.useRef)(null);
68
+ const composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref, hostRef);
69
+ const stateRef = (0, import_react.useRef)(null);
70
+ if (!stateRef.current) {
71
+ stateRef.current = {
72
+ get host() {
73
+ return hostRef.current;
74
+ }
75
+ };
76
+ }
77
+ const [_, state] = (0, import_core.useThemeWithState)({});
78
+ const result = (0, import_core.getSplitStyles)(propsRest, isText ? import_core.Text.staticConfig : import_core.View.staticConfig, state?.theme, state?.name, {
79
+ unmounted: false
80
+ }, {
81
+ isAnimated: false,
82
+ noClass: true
83
+ });
84
+ const props = result?.viewProps || {};
85
+ const Element = render;
86
+ const transformedProps = import_core.hooks.usePropsTransform?.(render, props, stateRef, false);
87
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Element, {
88
+ ...transformedProps,
89
+ ref: composedRefs
90
+ });
91
+ }));
92
+ Component["acceptRenderProp"] = true;
93
+ return Component;
94
+ }
95
+ const AnimatedView = createHanzoguiAnimatedComponent("div");
96
+ const AnimatedText = createHanzoguiAnimatedComponent("span");
97
+ const onlyAnimateKeys = {
98
+ transform: true,
99
+ opacity: true,
100
+ height: true,
101
+ width: true,
102
+ backgroundColor: true,
103
+ borderColor: true,
104
+ borderLeftColor: true,
105
+ borderRightColor: true,
106
+ borderTopColor: true,
107
+ borderBottomColor: true,
108
+ borderRadius: true,
109
+ borderTopLeftRadius: true,
110
+ borderTopRightRadius: true,
111
+ borderBottomLeftRadius: true,
112
+ borderBottomRightRadius: true,
113
+ borderLeftWidth: true,
114
+ borderRightWidth: true,
115
+ borderTopWidth: true,
116
+ borderBottomWidth: true,
117
+ color: true,
118
+ left: true,
119
+ right: true,
120
+ top: true,
121
+ bottom: true,
122
+ fontSize: true,
123
+ fontWeight: true,
124
+ lineHeight: true,
125
+ letterSpacing: true
126
+ };
127
+ function createAnimations(animations) {
128
+ return {
129
+ needsCustomComponent: true,
130
+ View: import_core.isWeb ? AnimatedView : Animated.View,
131
+ Text: import_core.isWeb ? AnimatedText : Animated.Text,
132
+ // View: Animated.View,
133
+ // Text: Animated.Text,
134
+ isReactNative: true,
135
+ inputStyle: "value",
136
+ outputStyle: "inline",
137
+ animations,
138
+ usePresence: import_use_presence.usePresence,
139
+ ResetPresence: import_use_presence.ResetPresence,
140
+ useAnimatedNumber(initial) {
141
+ const sharedValue = (0, import_react_native_reanimated.useSharedValue)(initial);
142
+ return import_react.default.useMemo(() => ({
143
+ getInstance() {
144
+ "worklet";
145
+
146
+ return sharedValue;
147
+ },
148
+ getValue() {
149
+ "worklet";
150
+
151
+ return sharedValue.value;
152
+ },
153
+ setValue(next, config = {
154
+ type: "spring"
155
+ }, onFinish) {
156
+ "worklet";
157
+
158
+ if (config.type === "direct") {
159
+ sharedValue.value = next;
160
+ onFinish?.();
161
+ } else if (config.type === "spring") {
162
+ sharedValue.value = (0, import_react_native_reanimated.withSpring)(next, config, onFinish ? () => {
163
+ "worklet";
164
+
165
+ (0, import_react_native_reanimated.runOnJS)(onFinish)();
166
+ } : void 0);
167
+ } else {
168
+ sharedValue.value = (0, import_react_native_reanimated.withTiming)(next, config, onFinish ? () => {
169
+ "worklet";
170
+
171
+ (0, import_react_native_reanimated.runOnJS)(onFinish)();
172
+ } : void 0);
173
+ }
174
+ },
175
+ stop() {
176
+ "worklet";
177
+
178
+ (0, import_react_native_reanimated.cancelAnimation)(sharedValue);
179
+ }
180
+ }), [sharedValue]);
181
+ },
182
+ useAnimatedNumberReaction({
183
+ value
184
+ }, onValue) {
185
+ const instance = value.getInstance();
186
+ return (0, import_react_native_reanimated.useAnimatedReaction)(() => {
187
+ return instance.value;
188
+ }, (next, prev) => {
189
+ if (prev !== next) {
190
+ (0, import_react_native_reanimated.runOnJS)(onValue)(next);
191
+ }
192
+ },
193
+ // dependency array is very important here
194
+ [onValue, instance]);
195
+ },
196
+ /**
197
+ * `getStyle` must be a worklet
198
+ */
199
+ useAnimatedNumberStyle(val, getStyle) {
200
+ const instance = val.getInstance();
201
+ const derivedValue = (0, import_react_native_reanimated.useDerivedValue)(() => {
202
+ return instance.value;
203
+ }, [instance, getStyle]);
204
+ return (0, import_react_native_reanimated.useAnimatedStyle)(() => {
205
+ return getStyle(derivedValue.value);
206
+ }, [val, getStyle, derivedValue, instance]);
207
+ },
208
+ useAnimations: animationProps => {
209
+ const {
210
+ props,
211
+ presence,
212
+ style,
213
+ componentState
214
+ } = animationProps;
215
+ const animationKey = Array.isArray(props.transition) ? props.transition[0] : props.transition;
216
+ const isHydrating = componentState.unmounted === true;
217
+ const disableAnimation = isHydrating || !animationKey;
218
+ const presenceContext = import_react.default.useContext(import_use_presence.PresenceContext);
219
+ const [, themeState] = (0, import_core.useThemeWithState)({});
220
+ const isDark = themeState?.scheme === "dark" || themeState?.name?.startsWith("dark");
221
+ const {
222
+ dontAnimate,
223
+ motiProps
224
+ } = (0, import_react.useMemo)(() => {
225
+ let animate = {};
226
+ let dontAnimate2 = {};
227
+ if (disableAnimation) {
228
+ for (const key in style) {
229
+ const rawValue = style[key];
230
+ const value = resolveDynamicValue(rawValue, isDark);
231
+ if (value === void 0) continue;
232
+ dontAnimate2[key] = value;
233
+ }
234
+ } else {
235
+ const animateOnly = props.animateOnly;
236
+ for (const key in style) {
237
+ const rawValue = style[key];
238
+ const value = resolveDynamicValue(rawValue, isDark);
239
+ if (value === void 0) continue;
240
+ if (!onlyAnimateKeys[key] || value === "auto" || typeof value === "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key)) {
241
+ dontAnimate2[key] = value;
242
+ } else {
243
+ animate[key] = value;
244
+ }
245
+ }
246
+ }
247
+ if (componentState.unmounted === "should-enter") {
248
+ for (const key in style) {
249
+ const rawValue = style[key];
250
+ const value = resolveDynamicValue(rawValue, isDark);
251
+ if (value === void 0) continue;
252
+ dontAnimate2[key] = value;
253
+ }
254
+ }
255
+ const styles = animate;
256
+ const isExiting = Boolean(presence?.[1]);
257
+ const usePresenceValue = presence || void 0;
258
+ let transition = isHydrating ? {
259
+ type: "transition",
260
+ duration: 0
261
+ } : animations[animationKey];
262
+ let hasClonedTransition = false;
263
+ if (Array.isArray(props.transition)) {
264
+ const config = props.transition[1];
265
+ if (config && typeof config === "object") {
266
+ for (const key in config) {
267
+ const val = config[key];
268
+ if (!hasClonedTransition) {
269
+ transition = Object.assign({}, transition);
270
+ hasClonedTransition = true;
271
+ }
272
+ if (typeof val === "string") {
273
+ transition[key] = animations[val];
274
+ } else {
275
+ transition[key] = val;
276
+ }
277
+ }
278
+ }
279
+ }
280
+ return {
281
+ dontAnimate: dontAnimate2,
282
+ motiProps: {
283
+ animate: isExiting || componentState.unmounted === true ? {} : styles,
284
+ transition: componentState.unmounted ? {
285
+ duration: 0
286
+ } : transition,
287
+ usePresenceValue,
288
+ presenceContext,
289
+ exit: isExiting ? styles : void 0
290
+ }
291
+ };
292
+ }, [presenceContext, presence, animationKey, componentState.unmounted, JSON.stringify(style), presenceContext, isDark]);
293
+ const moti = (0, import_author.useMotify)(motiProps);
294
+ if (process.env.NODE_ENV === "development" && props["debug"] && props["debug"] !== "profile") {
295
+ console.info(`useMotify(`, JSON.stringify(motiProps, null, 2) + ")", {
296
+ "componentState.unmounted": componentState.unmounted,
297
+ animationProps,
298
+ motiProps,
299
+ moti,
300
+ style: [dontAnimate, moti.style]
301
+ });
302
+ }
303
+ return {
304
+ style: [dontAnimate, moti.style]
305
+ };
306
+ }
307
+ };
308
+ }
@@ -0,0 +1,328 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
+ value: true
35
+ }), mod);
36
+ var createAnimations_exports = {};
37
+ __export(createAnimations_exports, {
38
+ createAnimations: () => createAnimations
39
+ });
40
+ module.exports = __toCommonJS(createAnimations_exports);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_use_presence = require("@hanzogui/use-presence");
43
+ var import_core = require("@hanzogui/core");
44
+ var import_author = require("moti/author");
45
+ var import_react = __toESM(require("react"), 1);
46
+ var import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1);
47
+ function _type_of(obj) {
48
+ "@swc/helpers - typeof";
49
+
50
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
51
+ }
52
+ var resolveDynamicValue = function (value, isDark) {
53
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "dynamic" in value) {
54
+ var dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light;
55
+ return dynamicValue;
56
+ }
57
+ return value;
58
+ };
59
+ var safeESModule = function (a) {
60
+ var b = a;
61
+ var out = b.__esModule || b[Symbol.toStringTag] === "Module" ? b.default : b;
62
+ return out || a;
63
+ };
64
+ var Animated = safeESModule(import_react_native_reanimated.default);
65
+ function createHanzoguiAnimatedComponent() {
66
+ var defaultTag = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "div";
67
+ var isText = defaultTag === "span";
68
+ var Component = Animated.createAnimatedComponent(/* @__PURE__ */(0, import_react.forwardRef)(function (propsIn, ref) {
69
+ var _hooks_usePropsTransform;
70
+ var {
71
+ forwardedRef,
72
+ animation,
73
+ render = defaultTag,
74
+ ...propsRest
75
+ } = propsIn;
76
+ var hostRef = (0, import_react.useRef)(null);
77
+ var composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref, hostRef);
78
+ var stateRef = (0, import_react.useRef)(null);
79
+ if (!stateRef.current) {
80
+ stateRef.current = {
81
+ get host() {
82
+ return hostRef.current;
83
+ }
84
+ };
85
+ }
86
+ var [_, state] = (0, import_core.useThemeWithState)({});
87
+ var result = (0, import_core.getSplitStyles)(propsRest, isText ? import_core.Text.staticConfig : import_core.View.staticConfig, state === null || state === void 0 ? void 0 : state.theme, state === null || state === void 0 ? void 0 : state.name, {
88
+ unmounted: false
89
+ }, {
90
+ isAnimated: false,
91
+ noClass: true
92
+ });
93
+ var props = (result === null || result === void 0 ? void 0 : result.viewProps) || {};
94
+ var Element = render;
95
+ var transformedProps = (_hooks_usePropsTransform = import_core.hooks.usePropsTransform) === null || _hooks_usePropsTransform === void 0 ? void 0 : _hooks_usePropsTransform.call(import_core.hooks, render, props, stateRef, false);
96
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Element, {
97
+ ...transformedProps,
98
+ ref: composedRefs
99
+ });
100
+ }));
101
+ Component["acceptRenderProp"] = true;
102
+ return Component;
103
+ }
104
+ var AnimatedView = createHanzoguiAnimatedComponent("div");
105
+ var AnimatedText = createHanzoguiAnimatedComponent("span");
106
+ var onlyAnimateKeys = {
107
+ transform: true,
108
+ opacity: true,
109
+ height: true,
110
+ width: true,
111
+ backgroundColor: true,
112
+ borderColor: true,
113
+ borderLeftColor: true,
114
+ borderRightColor: true,
115
+ borderTopColor: true,
116
+ borderBottomColor: true,
117
+ borderRadius: true,
118
+ borderTopLeftRadius: true,
119
+ borderTopRightRadius: true,
120
+ borderBottomLeftRadius: true,
121
+ borderBottomRightRadius: true,
122
+ borderLeftWidth: true,
123
+ borderRightWidth: true,
124
+ borderTopWidth: true,
125
+ borderBottomWidth: true,
126
+ color: true,
127
+ left: true,
128
+ right: true,
129
+ top: true,
130
+ bottom: true,
131
+ fontSize: true,
132
+ fontWeight: true,
133
+ lineHeight: true,
134
+ letterSpacing: true
135
+ };
136
+ function createAnimations(animations) {
137
+ return {
138
+ needsCustomComponent: true,
139
+ View: import_core.isWeb ? AnimatedView : Animated.View,
140
+ Text: import_core.isWeb ? AnimatedText : Animated.Text,
141
+ // View: Animated.View,
142
+ // Text: Animated.Text,
143
+ isReactNative: true,
144
+ inputStyle: "value",
145
+ outputStyle: "inline",
146
+ animations,
147
+ usePresence: import_use_presence.usePresence,
148
+ ResetPresence: import_use_presence.ResetPresence,
149
+ useAnimatedNumber(initial) {
150
+ var sharedValue = (0, import_react_native_reanimated.useSharedValue)(initial);
151
+ return import_react.default.useMemo(function () {
152
+ return {
153
+ getInstance() {
154
+ "worklet";
155
+
156
+ return sharedValue;
157
+ },
158
+ getValue() {
159
+ "worklet";
160
+
161
+ return sharedValue.value;
162
+ },
163
+ setValue(next) {
164
+ "worklet";
165
+
166
+ var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
167
+ type: "spring"
168
+ },
169
+ onFinish = arguments.length > 2 ? arguments[2] : void 0;
170
+ if (config.type === "direct") {
171
+ sharedValue.value = next;
172
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish();
173
+ } else if (config.type === "spring") {
174
+ sharedValue.value = (0, import_react_native_reanimated.withSpring)(next, config, onFinish ? function () {
175
+ "worklet";
176
+
177
+ (0, import_react_native_reanimated.runOnJS)(onFinish)();
178
+ } : void 0);
179
+ } else {
180
+ sharedValue.value = (0, import_react_native_reanimated.withTiming)(next, config, onFinish ? function () {
181
+ "worklet";
182
+
183
+ (0, import_react_native_reanimated.runOnJS)(onFinish)();
184
+ } : void 0);
185
+ }
186
+ },
187
+ stop() {
188
+ "worklet";
189
+
190
+ (0, import_react_native_reanimated.cancelAnimation)(sharedValue);
191
+ }
192
+ };
193
+ }, [sharedValue]);
194
+ },
195
+ useAnimatedNumberReaction(param, onValue) {
196
+ var {
197
+ value
198
+ } = param;
199
+ var instance = value.getInstance();
200
+ return (0, import_react_native_reanimated.useAnimatedReaction)(function () {
201
+ return instance.value;
202
+ }, function (next, prev) {
203
+ if (prev !== next) {
204
+ (0, import_react_native_reanimated.runOnJS)(onValue)(next);
205
+ }
206
+ },
207
+ // dependency array is very important here
208
+ [onValue, instance]);
209
+ },
210
+ /**
211
+ * `getStyle` must be a worklet
212
+ */
213
+ useAnimatedNumberStyle(val, getStyle) {
214
+ var instance = val.getInstance();
215
+ var derivedValue = (0, import_react_native_reanimated.useDerivedValue)(function () {
216
+ return instance.value;
217
+ },
218
+ // dependency array is very important here
219
+ [instance, getStyle]);
220
+ return (0, import_react_native_reanimated.useAnimatedStyle)(function () {
221
+ return getStyle(derivedValue.value);
222
+ },
223
+ // dependency array is very important here
224
+ [val, getStyle, derivedValue, instance]);
225
+ },
226
+ useAnimations: function (animationProps) {
227
+ var _themeState_name;
228
+ var {
229
+ props,
230
+ presence,
231
+ style,
232
+ componentState
233
+ } = animationProps;
234
+ var animationKey = Array.isArray(props.transition) ? props.transition[0] : props.transition;
235
+ var isHydrating = componentState.unmounted === true;
236
+ var disableAnimation = isHydrating || !animationKey;
237
+ var presenceContext = import_react.default.useContext(import_use_presence.PresenceContext);
238
+ var [, themeState] = (0, import_core.useThemeWithState)({});
239
+ var isDark = (themeState === null || themeState === void 0 ? void 0 : themeState.scheme) === "dark" || (themeState === null || themeState === void 0 ? void 0 : (_themeState_name = themeState.name) === null || _themeState_name === void 0 ? void 0 : _themeState_name.startsWith("dark"));
240
+ var {
241
+ dontAnimate,
242
+ motiProps
243
+ } = (0, import_react.useMemo)(function () {
244
+ var animate = {};
245
+ var dontAnimate2 = {};
246
+ if (disableAnimation) {
247
+ for (var key in style) {
248
+ var rawValue = style[key];
249
+ var value = resolveDynamicValue(rawValue, isDark);
250
+ if (value === void 0) continue;
251
+ dontAnimate2[key] = value;
252
+ }
253
+ } else {
254
+ var animateOnly = props.animateOnly;
255
+ for (var key1 in style) {
256
+ var rawValue1 = style[key1];
257
+ var value1 = resolveDynamicValue(rawValue1, isDark);
258
+ if (value1 === void 0) continue;
259
+ if (!onlyAnimateKeys[key1] || value1 === "auto" || typeof value1 === "string" && value1.startsWith("calc") || animateOnly && !animateOnly.includes(key1)) {
260
+ dontAnimate2[key1] = value1;
261
+ } else {
262
+ animate[key1] = value1;
263
+ }
264
+ }
265
+ }
266
+ if (componentState.unmounted === "should-enter") {
267
+ for (var key2 in style) {
268
+ var rawValue2 = style[key2];
269
+ var value2 = resolveDynamicValue(rawValue2, isDark);
270
+ if (value2 === void 0) continue;
271
+ dontAnimate2[key2] = value2;
272
+ }
273
+ }
274
+ var styles = animate;
275
+ var isExiting = Boolean(presence === null || presence === void 0 ? void 0 : presence[1]);
276
+ var usePresenceValue = presence || void 0;
277
+ var transition = isHydrating ? {
278
+ type: "transition",
279
+ duration: 0
280
+ } : animations[animationKey];
281
+ var hasClonedTransition = false;
282
+ if (Array.isArray(props.transition)) {
283
+ var config = props.transition[1];
284
+ if (config && (typeof config === "undefined" ? "undefined" : _type_of(config)) === "object") {
285
+ for (var key3 in config) {
286
+ var val = config[key3];
287
+ if (!hasClonedTransition) {
288
+ transition = Object.assign({}, transition);
289
+ hasClonedTransition = true;
290
+ }
291
+ if (typeof val === "string") {
292
+ transition[key3] = animations[val];
293
+ } else {
294
+ transition[key3] = val;
295
+ }
296
+ }
297
+ }
298
+ }
299
+ return {
300
+ dontAnimate: dontAnimate2,
301
+ motiProps: {
302
+ animate: isExiting || componentState.unmounted === true ? {} : styles,
303
+ transition: componentState.unmounted ? {
304
+ duration: 0
305
+ } : transition,
306
+ usePresenceValue,
307
+ presenceContext,
308
+ exit: isExiting ? styles : void 0
309
+ }
310
+ };
311
+ }, [presenceContext, presence, animationKey, componentState.unmounted, JSON.stringify(style), presenceContext, isDark]);
312
+ var moti = (0, import_author.useMotify)(motiProps);
313
+ if (process.env.NODE_ENV === "development" && props["debug"] && props["debug"] !== "profile") {
314
+ console.info(`useMotify(`, JSON.stringify(motiProps, null, 2) + ")", {
315
+ "componentState.unmounted": componentState.unmounted,
316
+ animationProps,
317
+ motiProps,
318
+ moti,
319
+ style: [dontAnimate, moti.style]
320
+ });
321
+ }
322
+ return {
323
+ style: [dontAnimate, moti.style]
324
+ };
325
+ }
326
+ };
327
+ }
328
+ //# sourceMappingURL=createAnimations.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","createAnimations_exports","__export","createAnimations","module","exports","import_jsx_runtime","require","import_use_presence","import_core","import_author","import_react","__toESM","import_react_native_reanimated","_type_of","obj","Symbol","constructor","resolveDynamicValue","isDark","dynamicValue","dynamic","dark","light","safeESModule","a","b","out","__esModule","toStringTag","default","Animated","createHanzoguiAnimatedComponent","defaultTag","arguments","length","isText","Component","createAnimatedComponent","forwardRef","propsIn","ref","_hooks_usePropsTransform","forwardedRef","animation","render","propsRest","hostRef","useRef","composedRefs","useComposedRefs","stateRef","current","host","_","state","useThemeWithState","result","getSplitStyles","Text","staticConfig","View","theme","name","unmounted","isAnimated","noClass","props","viewProps","Element","transformedProps","hooks","usePropsTransform","call","jsx","AnimatedView","AnimatedText","onlyAnimateKeys","transform","opacity","height","width","backgroundColor","borderColor","borderLeftColor","borderRightColor","borderTopColor","borderBottomColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","color","left","right","top","bottom","fontSize","fontWeight","lineHeight","letterSpacing","animations","needsCustomComponent","isWeb","isReactNative","inputStyle","outputStyle","usePresence","ResetPresence","useAnimatedNumber","initial","sharedValue","useSharedValue","useMemo","getInstance","getValue","setValue","next","config","type","onFinish","withSpring","runOnJS","withTiming","stop","cancelAnimation","useAnimatedNumberReaction","param","onValue","instance","useAnimatedReaction","prev","useAnimatedNumberStyle","val","getStyle","derivedValue","useDerivedValue","useAnimatedStyle","useAnimations","animationProps","_themeState_name","presence","style","componentState","animationKey","Array","isArray","transition","isHydrating","disableAnimation","presenceContext","useContext","PresenceContext","themeState","scheme","startsWith","dontAnimate","motiProps","animate","dontAnimate2","key","rawValue","animateOnly","key1","rawValue1","value1","includes","key2","rawValue2","value2","styles","isExiting","Boolean","usePresenceValue","duration","hasClonedTransition","key3","Object","assign","exit"],"sources":["../../src/createAnimations.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,wBAAA;AAAAC,QAAA,CAAAD,wBAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAA4D,CAAAK,wBAAA;AAE5D,IAAAK,kBAUO,GAAAC,OAAA;AAWP,IAAAC,mBAA0B,GAAAD,OAAA;AAE1B,IAAAE,WAAA,GAAAF,OAAmD;AAGnD,IAAAG,aAAA,GAAAH,OAAA,cASO;AAwDM,IAAAI,YAAA,GAAAC,OAAA,CAAAL,OAAA;AA9Eb,IAAAM,8BAA6B,GAAYD,OAAA,CAAAL,OAAyB;AAChE,SAAIO,QAASA,CAAAC,GAAA,EAAO;EAClB,uBAAqB;;EACrB,OAAAA,GAAO,WAAAC,MAAA,oBAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAAA;AAET,IAAAG,mBAAO,YAAAA,CAAAlB,KAAA,EAAAmB,MAAA;EACT,IAA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