@tamagui/animate 1.43.0

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.
Files changed (40) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/Animate.js +50 -0
  3. package/dist/cjs/Animate.js.map +6 -0
  4. package/dist/cjs/AnimatePresence.js +205 -0
  5. package/dist/cjs/AnimatePresence.js.map +6 -0
  6. package/dist/cjs/LayoutGroupContext.js +30 -0
  7. package/dist/cjs/LayoutGroupContext.js.map +6 -0
  8. package/dist/cjs/PresenceChild.js +95 -0
  9. package/dist/cjs/PresenceChild.js.map +6 -0
  10. package/dist/cjs/index.js +23 -0
  11. package/dist/cjs/index.js.map +6 -0
  12. package/dist/cjs/types.js +17 -0
  13. package/dist/cjs/types.js.map +6 -0
  14. package/dist/esm/Animate.js +29 -0
  15. package/dist/esm/Animate.js.map +6 -0
  16. package/dist/esm/AnimatePresence.js +178 -0
  17. package/dist/esm/AnimatePresence.js.map +6 -0
  18. package/dist/esm/LayoutGroupContext.js +6 -0
  19. package/dist/esm/LayoutGroupContext.js.map +6 -0
  20. package/dist/esm/PresenceChild.js +61 -0
  21. package/dist/esm/PresenceChild.js.map +6 -0
  22. package/dist/esm/index.js +2 -0
  23. package/dist/esm/index.js.map +6 -0
  24. package/dist/esm/types.js +1 -0
  25. package/dist/esm/types.js.map +6 -0
  26. package/dist/jsx/Animate.js +24 -0
  27. package/dist/jsx/Animate.js.map +6 -0
  28. package/dist/jsx/Animate.mjs +24 -0
  29. package/dist/jsx/Animate.mjs.map +6 -0
  30. package/dist/jsx/index.js +2 -0
  31. package/dist/jsx/index.js.map +6 -0
  32. package/dist/jsx/index.mjs +2 -0
  33. package/dist/jsx/index.mjs.map +6 -0
  34. package/package.json +40 -0
  35. package/src/Animate.tsx +59 -0
  36. package/src/index.ts +1 -0
  37. package/types/Animate.d.ts +32 -0
  38. package/types/Animate.d.ts.map +1 -0
  39. package/types/index.d.ts +2 -0
  40. package/types/index.d.ts.map +1 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ Much of this is taken from framer-motion.
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Animate_exports = {};
20
+ __export(Animate_exports, {
21
+ Animate: () => Animate
22
+ });
23
+ module.exports = __toCommonJS(Animate_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_animate_presence = require("@tamagui/animate-presence");
26
+ function Animate({ children, type, ...props }) {
27
+ if (type === "presence") {
28
+ if (props.keepChildrenMounted) {
29
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
30
+ import_animate_presence.PresenceChild,
31
+ {
32
+ initial: props.initial ? void 0 : false,
33
+ onExitComplete: props.onExitComplete,
34
+ enterVariant: props.enterVariant,
35
+ exitVariant: props.exitVariant,
36
+ presenceAffectsLayout: props.presenceAffectsLayout || true,
37
+ isPresent: props.present,
38
+ children
39
+ }
40
+ );
41
+ }
42
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { ...props, children: props.present ? children : null });
43
+ }
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ Animate
49
+ });
50
+ //# sourceMappingURL=Animate.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Animate.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCQ;AAzCR,8BAIO;AAiCA,SAAS,QAAQ,EAAE,UAAU,MAAM,GAAG,MAAM,GAAiB;AAClE,MAAI,SAAS,YAAY;AACvB,QAAI,MAAM,qBAAqB;AAC7B,aACE;AAAA,QAAC;AAAA;AAAA,UACC,SAAS,MAAM,UAAU,SAAY;AAAA,UACrC,gBAAgB,MAAM;AAAA,UACtB,cAAc,MAAM;AAAA,UACpB,aAAa,MAAM;AAAA,UACnB,uBAAuB,MAAM,yBAAyB;AAAA,UACtD,WAAW,MAAM;AAAA,UAEhB;AAAA;AAAA,MACH;AAAA,IAEJ;AAEA,WAAO,4CAAC,2CAAiB,GAAG,OAAQ,gBAAM,UAAU,WAAW,MAAK;AAAA,EACtE;AAEA,SAAO,2EAAG,UAAS;AACrB;",
5
+ "names": []
6
+ }
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var AnimatePresence_exports = {};
30
+ __export(AnimatePresence_exports, {
31
+ AnimatePresence: () => AnimatePresence
32
+ });
33
+ module.exports = __toCommonJS(AnimatePresence_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_web = require("@tamagui/web");
36
+ var import_react = __toESM(require("react"));
37
+ var import_LayoutGroupContext = require("./LayoutGroupContext");
38
+ var import_PresenceChild = require("./PresenceChild");
39
+ const getChildKey = (child) => child.key || "";
40
+ const isDev = process.env.NODE_ENV !== "production";
41
+ function updateChildLookup(children, allChildren) {
42
+ const seenChildren = isDev ? /* @__PURE__ */ new Set() : null;
43
+ children.forEach((child) => {
44
+ const key = getChildKey(child);
45
+ if (isDev && seenChildren && seenChildren.has(key)) {
46
+ console.warn(
47
+ `Children of AnimatePresence require unique keys. "${key}" is a duplicate.`
48
+ );
49
+ seenChildren.add(key);
50
+ }
51
+ allChildren.set(key, child);
52
+ });
53
+ }
54
+ function onlyElements(children) {
55
+ const filtered = [];
56
+ import_react.Children.forEach(children, (child, index) => {
57
+ if ((0, import_react.isValidElement)(child)) {
58
+ if (!child.key && import_react.Children.count(children) > 1) {
59
+ if (process.env.NODE_ENV === "development") {
60
+ console.warn("No key given to AnimatePresence child, assigning index as key");
61
+ }
62
+ filtered.push(
63
+ import_react.default.cloneElement(child, {
64
+ key: index
65
+ })
66
+ );
67
+ } else {
68
+ filtered.push(child);
69
+ }
70
+ }
71
+ });
72
+ return filtered;
73
+ }
74
+ const AnimatePresence = ({
75
+ children,
76
+ enterVariant,
77
+ exitVariant,
78
+ initial = true,
79
+ onExitComplete,
80
+ exitBeforeEnter,
81
+ presenceAffectsLayout = true
82
+ }) => {
83
+ let forceRender = (0, import_web.useForceUpdate)();
84
+ const isClientMounted = (0, import_web.useDidFinishSSR)();
85
+ const forceRenderLayoutGroup = (0, import_react.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender;
86
+ if (forceRenderLayoutGroup)
87
+ forceRender = forceRenderLayoutGroup;
88
+ const isMounted = (0, import_react.useRef)(false);
89
+ const filteredChildren = onlyElements(children);
90
+ let childrenToRender = filteredChildren;
91
+ const exiting = /* @__PURE__ */ new Set();
92
+ const presentChildren = (0, import_react.useRef)(childrenToRender);
93
+ const allChildren = (0, import_react.useRef)(/* @__PURE__ */ new Map()).current;
94
+ const isInitialRender = (0, import_react.useRef)(true);
95
+ (0, import_react.useEffect)(() => {
96
+ isMounted.current = true;
97
+ return () => {
98
+ isMounted.current = false;
99
+ isInitialRender.current = true;
100
+ allChildren.clear();
101
+ exiting.clear();
102
+ };
103
+ }, []);
104
+ (0, import_web.useIsomorphicLayoutEffect)(() => {
105
+ isInitialRender.current = false;
106
+ updateChildLookup(filteredChildren, allChildren);
107
+ presentChildren.current = childrenToRender;
108
+ });
109
+ const hasWarned = process.env.NODE_ENV === "development" ? (0, import_react.useRef)(false) : null;
110
+ if (isInitialRender.current) {
111
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: childrenToRender.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
112
+ import_PresenceChild.PresenceChild,
113
+ {
114
+ isPresent: Boolean(isClientMounted ? true : isMounted.current),
115
+ exitVariant,
116
+ enterVariant,
117
+ initial: initial ? void 0 : false,
118
+ presenceAffectsLayout,
119
+ children: child
120
+ },
121
+ getChildKey(child)
122
+ )) });
123
+ }
124
+ childrenToRender = [...childrenToRender];
125
+ const presentKeys = presentChildren.current.map(getChildKey);
126
+ const targetKeys = filteredChildren.map(getChildKey);
127
+ const numPresent = presentKeys.length;
128
+ for (let i = 0; i < numPresent; i++) {
129
+ const key = presentKeys[i];
130
+ if (targetKeys.indexOf(key) === -1) {
131
+ exiting.add(key);
132
+ }
133
+ }
134
+ if (exitBeforeEnter && exiting.size) {
135
+ childrenToRender = [];
136
+ }
137
+ exiting.forEach((key) => {
138
+ if (targetKeys.indexOf(key) !== -1)
139
+ return;
140
+ const child = allChildren.get(key);
141
+ if (!child)
142
+ return;
143
+ const insertionIndex = presentKeys.indexOf(key);
144
+ childrenToRender.splice(
145
+ insertionIndex,
146
+ 0,
147
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
148
+ import_PresenceChild.PresenceChild,
149
+ {
150
+ isPresent: false,
151
+ onExitComplete: () => {
152
+ allChildren.delete(key);
153
+ exiting.delete(key);
154
+ const removeIndex = presentChildren.current.findIndex(
155
+ (presentChild) => presentChild.key === key
156
+ );
157
+ presentChildren.current.splice(removeIndex, 1);
158
+ if (!exiting.size) {
159
+ presentChildren.current = filteredChildren;
160
+ if (isMounted.current === false)
161
+ return;
162
+ forceRender();
163
+ onExitComplete == null ? void 0 : onExitComplete();
164
+ }
165
+ },
166
+ exitVariant,
167
+ enterVariant,
168
+ presenceAffectsLayout,
169
+ children: child
170
+ },
171
+ getChildKey(child)
172
+ )
173
+ );
174
+ });
175
+ childrenToRender = childrenToRender.map((child) => {
176
+ const key = child.key;
177
+ return exiting.has(key) ? child : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
+ import_PresenceChild.PresenceChild,
179
+ {
180
+ isPresent: true,
181
+ exitVariant,
182
+ enterVariant,
183
+ presenceAffectsLayout,
184
+ children: child
185
+ },
186
+ getChildKey(child)
187
+ );
188
+ });
189
+ if (process.env.NODE_ENV === "development") {
190
+ const shouldWarn = exitBeforeEnter && childrenToRender.length > 1;
191
+ if (shouldWarn && hasWarned && !hasWarned.current) {
192
+ hasWarned.current = true;
193
+ console.log(
194
+ `You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This can lead to odd visual behaviour.`
195
+ );
196
+ }
197
+ }
198
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: exiting.size ? childrenToRender : childrenToRender.map((child) => (0, import_react.cloneElement)(child)) });
199
+ };
200
+ AnimatePresence.displayName = "AnimatePresence";
201
+ // Annotate the CommonJS export names for ESM import in node:
202
+ 0 && (module.exports = {
203
+ AnimatePresence
204
+ });
205
+ //# sourceMappingURL=AnimatePresence.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/AnimatePresence.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8JM;AA9JN,iBAA2E;AAC3E,mBASO;AAEP,gCAAmC;AACnC,2BAA8B;AAK9B,MAAM,cAAc,CAAC,UAA2C,MAAM,OAAO;AAE7E,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,SAAS,kBACP,UACA,aACA;AACA,QAAM,eAAe,QAAQ,oBAAI,IAAkB,IAAI;AAEvD,WAAS,QAAQ,CAAC,UAAU;AAC1B,UAAM,MAAM,YAAY,KAAK;AAE7B,QAAI,SAAS,gBAAgB,aAAa,IAAI,GAAG,GAAG;AAClD,cAAQ;AAAA,QACN,qDAAqD;AAAA,MACvD;AAEA,mBAAa,IAAI,GAAG;AAAA,IACtB;AAEA,gBAAY,IAAI,KAAK,KAAK;AAAA,EAC5B,CAAC;AACH;AAEA,SAAS,aAAa,UAA0C;AAC9D,QAAM,WAAgC,CAAC;AAGvC,wBAAS,QAAQ,UAAU,CAAC,OAAO,UAAU;AAC3C,YAAI,6BAAe,KAAK,GAAG;AACzB,UAAI,CAAC,MAAM,OAAO,sBAAS,MAAM,QAAQ,IAAI,GAAG;AAC9C,YAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C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;AAID,qBAAmB,iBAAiB,IAAI,CAAC,UAAU;AACjD,UAAM,MAAM,MAAM;AAClB,WAAO,QAAQ,IAAI,GAAG,IACpB,QAEA;AAAA,MAAC;AAAA;AAAA,QAEC,WAAS;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QAEC;AAAA;AAAA,MANI,YAAY,KAAK;AAAA,IAOxB;AAAA,EAEJ,CAAC;AAED,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,UAAM,aAAa,mBAAmB,iBAAiB,SAAS;AAChE,QAAI,cAAc,aAAa,CAAC,UAAU,SAAS;AACjD,gBAAU,UAAU;AAEpB,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SACE,2EACG,kBAAQ,OACL,mBACA,iBAAiB,IAAI,CAAC,cAAU,2BAAa,KAAK,CAAC,GACzD;AAEJ;AAEA,gBAAgB,cAAc;",
5
+ "names": ["React"]
6
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var LayoutGroupContext_exports = {};
20
+ __export(LayoutGroupContext_exports, {
21
+ LayoutGroupContext: () => LayoutGroupContext
22
+ });
23
+ module.exports = __toCommonJS(LayoutGroupContext_exports);
24
+ var import_react = require("react");
25
+ const LayoutGroupContext = (0, import_react.createContext)({});
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ LayoutGroupContext
29
+ });
30
+ //# sourceMappingURL=LayoutGroupContext.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/LayoutGroupContext.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAOvB,MAAM,yBAAqB,4BAAuC,CAAC,CAAC;",
5
+ "names": []
6
+ }
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var PresenceChild_exports = {};
30
+ __export(PresenceChild_exports, {
31
+ PresenceChild: () => PresenceChild
32
+ });
33
+ module.exports = __toCommonJS(PresenceChild_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_use_presence = require("@tamagui/use-presence");
36
+ var React = __toESM(require("react"));
37
+ var import_react = require("react");
38
+ const PresenceChild = ({
39
+ children,
40
+ initial,
41
+ isPresent,
42
+ onExitComplete,
43
+ exitVariant,
44
+ enterVariant,
45
+ presenceAffectsLayout
46
+ }) => {
47
+ const presenceChildren = React.useMemo(newChildrenMap, []);
48
+ const id = (0, import_react.useId)() || "";
49
+ const context = React.useMemo(
50
+ () => {
51
+ return {
52
+ id,
53
+ initial,
54
+ isPresent,
55
+ exitVariant,
56
+ enterVariant,
57
+ onExitComplete: (id2) => {
58
+ presenceChildren.set(id2, true);
59
+ for (const isComplete of presenceChildren.values()) {
60
+ if (!isComplete) {
61
+ return;
62
+ }
63
+ }
64
+ onExitComplete == null ? void 0 : onExitComplete();
65
+ },
66
+ register: (id2) => {
67
+ presenceChildren.set(id2, false);
68
+ return () => presenceChildren.delete(id2);
69
+ }
70
+ };
71
+ },
72
+ /**
73
+ * If the presence of a child affects the layout of the components around it,
74
+ * we want to make a new context value to ensure they get re-rendered
75
+ * so they can detect that layout change.
76
+ */
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
78
+ presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]
79
+ );
80
+ React.useMemo(() => {
81
+ presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
82
+ }, [isPresent]);
83
+ React.useEffect(() => {
84
+ !(isPresent || presenceChildren.size) && (onExitComplete == null ? void 0 : onExitComplete());
85
+ }, [isPresent]);
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, { value: context, children });
87
+ };
88
+ function newChildrenMap() {
89
+ return /* @__PURE__ */ new Map();
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ PresenceChild
94
+ });
95
+ //# sourceMappingURL=PresenceChild.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/PresenceChild.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4ES;AA5ET,0BAAgC;AAEhC,YAAuB;AACvB,mBAAsB;AAef,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,mBAAmB,MAAM,QAAQ,gBAAgB,CAAC,CAAC;AACzD,QAAM,SAAK,oBAAM,KAAK;AAEtB,QAAM,UAAU,MAAM;AAAA,IACpB,MAA4B;AAC1B,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAgB,CAACA,QAAe;AAC9B,2BAAiB,IAAIA,KAAI,IAAI;AAC7B,qBAAW,cAAc,iBAAiB,OAAO,GAAG;AAClD,gBAAI,CAAC,YAAY;AACf;AAAA,YACF;AAAA,UACF;AACA;AAAA,QACF;AAAA,QACA,UAAU,CAACA,QAAe;AACxB,2BAAiB,IAAIA,KAAI,KAAK;AAC9B,iBAAO,MAAM,iBAAiB,OAAOA,GAAE;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,wBAAwB,SAAY,CAAC,WAAW,aAAa,YAAY;AAAA,EAC3E;AAEA,QAAM,QAAQ,MAAM;AAClB,qBAAiB,QAAQ,CAAC,GAAG,QAAQ,iBAAiB,IAAI,KAAK,KAAK,CAAC;AAAA,EAEvE,GAAG,CAAC,SAAS,CAAC;AAMd,QAAM,UAAU,MAAM;AACpB,MAAE,aAAa,iBAAiB,UAAS;AAAA,EAE3C,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO,4CAAC,oCAAgB,UAAhB,EAAyB,OAAO,SAAU,UAAS;AAC7D;AAEA,SAAS,iBAAuC;AAC9C,SAAO,oBAAI,IAAI;AACjB;",
5
+ "names": ["id"]
6
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./Animate"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./Animate")
22
+ });
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,sBAAd;",
5
+ "names": []
6
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/types.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
5
+ "names": []
6
+ }
@@ -0,0 +1,29 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import {
3
+ AnimatePresence,
4
+ PresenceChild
5
+ } from "@tamagui/animate-presence";
6
+ function Animate({ children, type, ...props }) {
7
+ if (type === "presence") {
8
+ if (props.keepChildrenMounted) {
9
+ return /* @__PURE__ */ jsx(
10
+ PresenceChild,
11
+ {
12
+ initial: props.initial ? void 0 : false,
13
+ onExitComplete: props.onExitComplete,
14
+ enterVariant: props.enterVariant,
15
+ exitVariant: props.exitVariant,
16
+ presenceAffectsLayout: props.presenceAffectsLayout || true,
17
+ isPresent: props.present,
18
+ children
19
+ }
20
+ );
21
+ }
22
+ return /* @__PURE__ */ jsx(AnimatePresence, { ...props, children: props.present ? children : null });
23
+ }
24
+ return /* @__PURE__ */ jsx(Fragment, { children });
25
+ }
26
+ export {
27
+ Animate
28
+ };
29
+ //# sourceMappingURL=Animate.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Animate.tsx"],
4
+ "mappings": "AAyCQ,SAgBC,UAhBD;AAzCR;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AAiCA,SAAS,QAAQ,EAAE,UAAU,MAAM,GAAG,MAAM,GAAiB;AAClE,MAAI,SAAS,YAAY;AACvB,QAAI,MAAM,qBAAqB;AAC7B,aACE;AAAA,QAAC;AAAA;AAAA,UACC,SAAS,MAAM,UAAU,SAAY;AAAA,UACrC,gBAAgB,MAAM;AAAA,UACtB,cAAc,MAAM;AAAA,UACpB,aAAa,MAAM;AAAA,UACnB,uBAAuB,MAAM,yBAAyB;AAAA,UACtD,WAAW,MAAM;AAAA,UAEhB;AAAA;AAAA,MACH;AAAA,IAEJ;AAEA,WAAO,oBAAC,mBAAiB,GAAG,OAAQ,gBAAM,UAAU,WAAW,MAAK;AAAA,EACtE;AAEA,SAAO,gCAAG,UAAS;AACrB;",
5
+ "names": []
6
+ }
@@ -0,0 +1,178 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { useDidFinishSSR, useForceUpdate, useIsomorphicLayoutEffect } from "@tamagui/web";
3
+ import React, {
4
+ Children,
5
+ cloneElement,
6
+ isValidElement,
7
+ useContext,
8
+ useEffect,
9
+ useRef
10
+ } from "react";
11
+ import { LayoutGroupContext } from "./LayoutGroupContext";
12
+ import { PresenceChild } from "./PresenceChild";
13
+ const getChildKey = (child) => child.key || "";
14
+ const isDev = process.env.NODE_ENV !== "production";
15
+ function updateChildLookup(children, allChildren) {
16
+ const seenChildren = isDev ? /* @__PURE__ */ new Set() : null;
17
+ children.forEach((child) => {
18
+ const key = getChildKey(child);
19
+ if (isDev && seenChildren && seenChildren.has(key)) {
20
+ console.warn(
21
+ `Children of AnimatePresence require unique keys. "${key}" is a duplicate.`
22
+ );
23
+ seenChildren.add(key);
24
+ }
25
+ allChildren.set(key, child);
26
+ });
27
+ }
28
+ function onlyElements(children) {
29
+ const filtered = [];
30
+ Children.forEach(children, (child, index) => {
31
+ if (isValidElement(child)) {
32
+ if (!child.key && Children.count(children) > 1) {
33
+ if (process.env.NODE_ENV === "development") {
34
+ console.warn("No key given to AnimatePresence child, assigning index as key");
35
+ }
36
+ filtered.push(
37
+ React.cloneElement(child, {
38
+ key: index
39
+ })
40
+ );
41
+ } else {
42
+ filtered.push(child);
43
+ }
44
+ }
45
+ });
46
+ return filtered;
47
+ }
48
+ const AnimatePresence = ({
49
+ children,
50
+ enterVariant,
51
+ exitVariant,
52
+ initial = true,
53
+ onExitComplete,
54
+ exitBeforeEnter,
55
+ presenceAffectsLayout = true
56
+ }) => {
57
+ let forceRender = useForceUpdate();
58
+ const isClientMounted = useDidFinishSSR();
59
+ const forceRenderLayoutGroup = useContext(LayoutGroupContext).forceRender;
60
+ if (forceRenderLayoutGroup)
61
+ forceRender = forceRenderLayoutGroup;
62
+ const isMounted = useRef(false);
63
+ const filteredChildren = onlyElements(children);
64
+ let childrenToRender = filteredChildren;
65
+ const exiting = /* @__PURE__ */ new Set();
66
+ const presentChildren = useRef(childrenToRender);
67
+ const allChildren = useRef(/* @__PURE__ */ new Map()).current;
68
+ const isInitialRender = useRef(true);
69
+ useEffect(() => {
70
+ isMounted.current = true;
71
+ return () => {
72
+ isMounted.current = false;
73
+ isInitialRender.current = true;
74
+ allChildren.clear();
75
+ exiting.clear();
76
+ };
77
+ }, []);
78
+ useIsomorphicLayoutEffect(() => {
79
+ isInitialRender.current = false;
80
+ updateChildLookup(filteredChildren, allChildren);
81
+ presentChildren.current = childrenToRender;
82
+ });
83
+ const hasWarned = process.env.NODE_ENV === "development" ? useRef(false) : null;
84
+ if (isInitialRender.current) {
85
+ return /* @__PURE__ */ jsx(Fragment, { children: childrenToRender.map((child) => /* @__PURE__ */ jsx(
86
+ PresenceChild,
87
+ {
88
+ isPresent: Boolean(isClientMounted ? true : isMounted.current),
89
+ exitVariant,
90
+ enterVariant,
91
+ initial: initial ? void 0 : false,
92
+ presenceAffectsLayout,
93
+ children: child
94
+ },
95
+ getChildKey(child)
96
+ )) });
97
+ }
98
+ childrenToRender = [...childrenToRender];
99
+ const presentKeys = presentChildren.current.map(getChildKey);
100
+ const targetKeys = filteredChildren.map(getChildKey);
101
+ const numPresent = presentKeys.length;
102
+ for (let i = 0; i < numPresent; i++) {
103
+ const key = presentKeys[i];
104
+ if (targetKeys.indexOf(key) === -1) {
105
+ exiting.add(key);
106
+ }
107
+ }
108
+ if (exitBeforeEnter && exiting.size) {
109
+ childrenToRender = [];
110
+ }
111
+ exiting.forEach((key) => {
112
+ if (targetKeys.indexOf(key) !== -1)
113
+ return;
114
+ const child = allChildren.get(key);
115
+ if (!child)
116
+ return;
117
+ const insertionIndex = presentKeys.indexOf(key);
118
+ childrenToRender.splice(
119
+ insertionIndex,
120
+ 0,
121
+ /* @__PURE__ */ jsx(
122
+ PresenceChild,
123
+ {
124
+ isPresent: false,
125
+ onExitComplete: () => {
126
+ allChildren.delete(key);
127
+ exiting.delete(key);
128
+ const removeIndex = presentChildren.current.findIndex(
129
+ (presentChild) => presentChild.key === key
130
+ );
131
+ presentChildren.current.splice(removeIndex, 1);
132
+ if (!exiting.size) {
133
+ presentChildren.current = filteredChildren;
134
+ if (isMounted.current === false)
135
+ return;
136
+ forceRender();
137
+ onExitComplete == null ? void 0 : onExitComplete();
138
+ }
139
+ },
140
+ exitVariant,
141
+ enterVariant,
142
+ presenceAffectsLayout,
143
+ children: child
144
+ },
145
+ getChildKey(child)
146
+ )
147
+ );
148
+ });
149
+ childrenToRender = childrenToRender.map((child) => {
150
+ const key = child.key;
151
+ return exiting.has(key) ? child : /* @__PURE__ */ jsx(
152
+ PresenceChild,
153
+ {
154
+ isPresent: true,
155
+ exitVariant,
156
+ enterVariant,
157
+ presenceAffectsLayout,
158
+ children: child
159
+ },
160
+ getChildKey(child)
161
+ );
162
+ });
163
+ if (process.env.NODE_ENV === "development") {
164
+ const shouldWarn = exitBeforeEnter && childrenToRender.length > 1;
165
+ if (shouldWarn && hasWarned && !hasWarned.current) {
166
+ hasWarned.current = true;
167
+ console.log(
168
+ `You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This can lead to odd visual behaviour.`
169
+ );
170
+ }
171
+ }
172
+ return /* @__PURE__ */ jsx(Fragment, { children: exiting.size ? childrenToRender : childrenToRender.map((child) => cloneElement(child)) });
173
+ };
174
+ AnimatePresence.displayName = "AnimatePresence";
175
+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,aAAa,eAAe;AAC1C,UAAM,aAAa,mBAAmB,iBAAiB,SAAS;AAChE,QAAI,cAAc,aAAa,CAAC,UAAU,SAAS;AACjD,gBAAU,UAAU;AAEpB,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SACE,gCACG,kBAAQ,OACL,mBACA,iBAAiB,IAAI,CAAC,UAAU,aAAa,KAAK,CAAC,GACzD;AAEJ;AAEA,gBAAgB,cAAc;",
5
+ "names": []
6
+ }
@@ -0,0 +1,6 @@
1
+ import { createContext } from "react";
2
+ const LayoutGroupContext = createContext({});
3
+ export {
4
+ LayoutGroupContext
5
+ };
6
+ //# sourceMappingURL=LayoutGroupContext.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/LayoutGroupContext.tsx"],
4
+ "mappings": "AAAA,SAAS,qBAAqB;AAOvB,MAAM,qBAAqB,cAAuC,CAAC,CAAC;",
5
+ "names": []
6
+ }
@@ -0,0 +1,61 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { PresenceContext } from "@tamagui/use-presence";
3
+ import * as React from "react";
4
+ import { useId } from "react";
5
+ const PresenceChild = ({
6
+ children,
7
+ initial,
8
+ isPresent,
9
+ onExitComplete,
10
+ exitVariant,
11
+ enterVariant,
12
+ presenceAffectsLayout
13
+ }) => {
14
+ const presenceChildren = React.useMemo(newChildrenMap, []);
15
+ const id = useId() || "";
16
+ const context = React.useMemo(
17
+ () => {
18
+ return {
19
+ id,
20
+ initial,
21
+ isPresent,
22
+ exitVariant,
23
+ enterVariant,
24
+ onExitComplete: (id2) => {
25
+ presenceChildren.set(id2, true);
26
+ for (const isComplete of presenceChildren.values()) {
27
+ if (!isComplete) {
28
+ return;
29
+ }
30
+ }
31
+ onExitComplete == null ? void 0 : onExitComplete();
32
+ },
33
+ register: (id2) => {
34
+ presenceChildren.set(id2, false);
35
+ return () => presenceChildren.delete(id2);
36
+ }
37
+ };
38
+ },
39
+ /**
40
+ * If the presence of a child affects the layout of the components around it,
41
+ * we want to make a new context value to ensure they get re-rendered
42
+ * so they can detect that layout change.
43
+ */
44
+ // eslint-disable-next-line react-hooks/exhaustive-deps
45
+ presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]
46
+ );
47
+ React.useMemo(() => {
48
+ presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
49
+ }, [isPresent]);
50
+ React.useEffect(() => {
51
+ !(isPresent || presenceChildren.size) && (onExitComplete == null ? void 0 : onExitComplete());
52
+ }, [isPresent]);
53
+ return /* @__PURE__ */ jsx(PresenceContext.Provider, { value: context, children });
54
+ };
55
+ function newChildrenMap() {
56
+ return /* @__PURE__ */ new Map();
57
+ }
58
+ export {
59
+ PresenceChild
60
+ };
61
+ //# sourceMappingURL=PresenceChild.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/PresenceChild.tsx"],
4
+ "mappings": "AA4ES;AA5ET,SAAS,uBAAuB;AAEhC,YAAY,WAAW;AACvB,SAAS,aAAa;AAef,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,mBAAmB,MAAM,QAAQ,gBAAgB,CAAC,CAAC;AACzD,QAAM,KAAK,MAAM,KAAK;AAEtB,QAAM,UAAU,MAAM;AAAA,IACpB,MAA4B;AAC1B,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAgB,CAACA,QAAe;AAC9B,2BAAiB,IAAIA,KAAI,IAAI;AAC7B,qBAAW,cAAc,iBAAiB,OAAO,GAAG;AAClD,gBAAI,CAAC,YAAY;AACf;AAAA,YACF;AAAA,UACF;AACA;AAAA,QACF;AAAA,QACA,UAAU,CAACA,QAAe;AACxB,2BAAiB,IAAIA,KAAI,KAAK;AAC9B,iBAAO,MAAM,iBAAiB,OAAOA,GAAE;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,wBAAwB,SAAY,CAAC,WAAW,aAAa,YAAY;AAAA,EAC3E;AAEA,QAAM,QAAQ,MAAM;AAClB,qBAAiB,QAAQ,CAAC,GAAG,QAAQ,iBAAiB,IAAI,KAAK,KAAK,CAAC;AAAA,EAEvE,GAAG,CAAC,SAAS,CAAC;AAMd,QAAM,UAAU,MAAM;AACpB,MAAE,aAAa,iBAAiB,UAAS;AAAA,EAE3C,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,SAAU,UAAS;AAC7D;AAEA,SAAS,iBAAuC;AAC9C,SAAO,oBAAI,IAAI;AACjB;",
5
+ "names": ["id"]
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Animate";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": "AAAA,cAAc;",
5
+ "names": []
6
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "mappings": "",
5
+ "names": []
6
+ }
@@ -0,0 +1,24 @@
1
+ import {
2
+ AnimatePresence,
3
+ PresenceChild
4
+ } from "@tamagui/animate-presence";
5
+ function Animate({ children, type, ...props }) {
6
+ if (type === "presence") {
7
+ if (props.keepChildrenMounted) {
8
+ return <PresenceChild
9
+ initial={props.initial ? void 0 : false}
10
+ onExitComplete={props.onExitComplete}
11
+ enterVariant={props.enterVariant}
12
+ exitVariant={props.exitVariant}
13
+ presenceAffectsLayout={props.presenceAffectsLayout || true}
14
+ isPresent={props.present}
15
+ >{children}</PresenceChild>;
16
+ }
17
+ return <AnimatePresence {...props}>{props.present ? children : null}</AnimatePresence>;
18
+ }
19
+ return <>{children}</>;
20
+ }
21
+ export {
22
+ Animate
23
+ };
24
+ //# sourceMappingURL=Animate.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Animate.tsx"],
4
+ "mappings": "AAAA;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AAiCA,SAAS,QAAQ,EAAE,UAAU,MAAM,GAAG,MAAM,GAAiB;AAClE,MAAI,SAAS,YAAY;AACvB,QAAI,MAAM,qBAAqB;AAC7B,aACE,CAAC;AAAA,QACC,SAAS,MAAM,UAAU,SAAY;AAAA,QACrC,gBAAgB,MAAM;AAAA,QACtB,cAAc,MAAM;AAAA,QACpB,aAAa,MAAM;AAAA,QACnB,uBAAuB,MAAM,yBAAyB;AAAA,QACtD,WAAW,MAAM;AAAA,QAEhB,SACH,EATC;AAAA,IAWL;AAEA,WAAO,CAAC,oBAAoB,QAAQ,MAAM,UAAU,WAAW,KAAK,EAA5D;AAAA,EACV;AAEA,SAAO,GAAG,SAAS;AACrB;",
5
+ "names": []
6
+ }
@@ -0,0 +1,24 @@
1
+ import {
2
+ AnimatePresence,
3
+ PresenceChild
4
+ } from "@tamagui/animate-presence";
5
+ function Animate({ children, type, ...props }) {
6
+ if (type === "presence") {
7
+ if (props.keepChildrenMounted) {
8
+ return <PresenceChild
9
+ initial={props.initial ? void 0 : false}
10
+ onExitComplete={props.onExitComplete}
11
+ enterVariant={props.enterVariant}
12
+ exitVariant={props.exitVariant}
13
+ presenceAffectsLayout={props.presenceAffectsLayout || true}
14
+ isPresent={props.present}
15
+ >{children}</PresenceChild>;
16
+ }
17
+ return <AnimatePresence {...props}>{props.present ? children : null}</AnimatePresence>;
18
+ }
19
+ return <>{children}</>;
20
+ }
21
+ export {
22
+ Animate
23
+ };
24
+ //# sourceMappingURL=Animate.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Animate.tsx"],
4
+ "mappings": "AAAA;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AAiCA,SAAS,QAAQ,EAAE,UAAU,MAAM,GAAG,MAAM,GAAiB;AAClE,MAAI,SAAS,YAAY;AACvB,QAAI,MAAM,qBAAqB;AAC7B,aACE,CAAC;AAAA,QACC,SAAS,MAAM,UAAU,SAAY;AAAA,QACrC,gBAAgB,MAAM;AAAA,QACtB,cAAc,MAAM;AAAA,QACpB,aAAa,MAAM;AAAA,QACnB,uBAAuB,MAAM,yBAAyB;AAAA,QACtD,WAAW,MAAM;AAAA,QAEhB,SACH,EATC;AAAA,IAWL;AAEA,WAAO,CAAC,oBAAoB,QAAQ,MAAM,UAAU,WAAW,KAAK,EAA5D;AAAA,EACV;AAEA,SAAO,GAAG,SAAS;AACrB;",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Animate";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": "AAAA,cAAc;",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Animate";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": "AAAA,cAAc;",
5
+ "names": []
6
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@tamagui/animate",
3
+ "version": "1.43.0",
4
+ "source": "src/index.ts",
5
+ "sideEffects": false,
6
+ "license": "MIT",
7
+ "types": "./types/index.d.ts",
8
+ "main": "dist/cjs",
9
+ "module": "dist/esm",
10
+ "files": [
11
+ "src",
12
+ "types",
13
+ "dist"
14
+ ],
15
+ "dependencies": {
16
+ "@tamagui/animate-presence": "1.43.0"
17
+ },
18
+ "devDependencies": {
19
+ "@tamagui/build": "1.43.0"
20
+ },
21
+ "scripts": {
22
+ "build": "tamagui-build",
23
+ "watch": "tamagui-build --watch",
24
+ "clean": "tamagui-build clean",
25
+ "clean:build": "tamagui-build clean:build",
26
+ "lint": "../../node_modules/.bin/rome check src",
27
+ "lint:fix": "../../node_modules/.bin/rome check --apply src"
28
+ },
29
+ "exports": {
30
+ "./package.json": "./package.json",
31
+ ".": {
32
+ "types": "./types/index.d.ts",
33
+ "import": "./dist/esm/index.js",
34
+ "require": "./dist/cjs/index.js"
35
+ }
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ }
40
+ }
@@ -0,0 +1,59 @@
1
+ import {
2
+ AnimatePresence,
3
+ AnimatePresenceProps,
4
+ PresenceChild,
5
+ } from '@tamagui/animate-presence'
6
+
7
+ type BaseProps = {
8
+ children: React.ReactNode
9
+ }
10
+
11
+ type PresenceProps = AnimatePresenceProps & {
12
+ type: 'presence'
13
+ present: boolean
14
+ keepChildrenMounted?: boolean
15
+ }
16
+
17
+ export type AnimateProps = BaseProps & PresenceProps
18
+
19
+ /**
20
+ * Because mounting and unmounting children can be expensive, this gives us the
21
+ * option to avoid that.
22
+ *
23
+ * type: 'presence' will act just like AnimatePresence, except you use `present`
24
+ * instead of conditional children.
25
+ * Note that this does avoid reconciling the children even when present={false}
26
+ * so no extra cost to perf over AnimatePresence.
27
+ *
28
+ * type: 'presence' with keepChildrenMounted true *always* render the children so you pay
29
+ * the cost up-front to mount them, but then you avoid the mount cost at the start
30
+ * of the animation.
31
+ *
32
+ * There's no "right way" it just depends on the use case, this component just makes
33
+ * it easier to choose the strategy yourself.
34
+ *
35
+ *
36
+ */
37
+
38
+ export function Animate({ children, type, ...props }: AnimateProps) {
39
+ if (type === 'presence') {
40
+ if (props.keepChildrenMounted) {
41
+ return (
42
+ <PresenceChild
43
+ initial={props.initial ? undefined : false}
44
+ onExitComplete={props.onExitComplete}
45
+ enterVariant={props.enterVariant}
46
+ exitVariant={props.exitVariant}
47
+ presenceAffectsLayout={props.presenceAffectsLayout || true}
48
+ isPresent={props.present}
49
+ >
50
+ {children as any}
51
+ </PresenceChild>
52
+ )
53
+ }
54
+
55
+ return <AnimatePresence {...props}>{props.present ? children : null}</AnimatePresence>
56
+ }
57
+
58
+ return <>{children}</>
59
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './Animate'
@@ -0,0 +1,32 @@
1
+ /// <reference types="react" />
2
+ import { AnimatePresenceProps } from '@tamagui/animate-presence';
3
+ type BaseProps = {
4
+ children: React.ReactNode;
5
+ };
6
+ type PresenceProps = AnimatePresenceProps & {
7
+ type: 'presence';
8
+ present: boolean;
9
+ keepChildrenMounted?: boolean;
10
+ };
11
+ export type AnimateProps = BaseProps & PresenceProps;
12
+ /**
13
+ * Because mounting and unmounting children can be expensive, this gives us the
14
+ * option to avoid that.
15
+ *
16
+ * type: 'presence' will act just like AnimatePresence, except you use `present`
17
+ * instead of conditional children.
18
+ * Note that this does avoid reconciling the children even when present={false}
19
+ * so no extra cost to perf over AnimatePresence.
20
+ *
21
+ * type: 'presence' with keepChildrenMounted true *always* render the children so you pay
22
+ * the cost up-front to mount them, but then you avoid the mount cost at the start
23
+ * of the animation.
24
+ *
25
+ * There's no "right way" it just depends on the use case, this component just makes
26
+ * it easier to choose the strategy yourself.
27
+ *
28
+ *
29
+ */
30
+ export declare function Animate({ children, type, ...props }: AnimateProps): JSX.Element;
31
+ export {};
32
+ //# sourceMappingURL=Animate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Animate.d.ts","sourceRoot":"","sources":["../src/Animate.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,oBAAoB,EAErB,MAAM,2BAA2B,CAAA;AAElC,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,KAAK,aAAa,GAAG,oBAAoB,GAAG;IAC1C,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,aAAa,CAAA;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,eAqBjE"}
@@ -0,0 +1,2 @@
1
+ export * from './Animate';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}