@tamagui/animate-presence 2.7.7 → 3.0.0-beta.643.1
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/dist/cjs/AnimatePresence.cjs +102 -128
- package/dist/cjs/AnimatePresence.native.cjs +135 -0
- package/dist/cjs/AnimatePresence.native.js +112 -141
- package/dist/cjs/AnimatePresence.native.js.map +1 -1
- package/dist/cjs/LayoutGroupContext.cjs +18 -26
- package/dist/cjs/LayoutGroupContext.native.cjs +34 -0
- package/dist/cjs/LayoutGroupContext.native.js +19 -26
- package/dist/cjs/LayoutGroupContext.native.js.map +1 -1
- package/dist/cjs/PresenceChild.cjs +61 -81
- package/dist/cjs/PresenceChild.native.cjs +105 -0
- package/dist/cjs/PresenceChild.native.js +83 -104
- package/dist/cjs/PresenceChild.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +24 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +10 -11
- package/dist/cjs/types.native.cjs +19 -0
- package/dist/cjs/types.native.js +10 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/AnimatePresence.mjs +90 -112
- package/dist/esm/AnimatePresence.mjs.map +1 -1
- package/dist/esm/AnimatePresence.native.js +100 -126
- package/dist/esm/AnimatePresence.native.js.map +1 -1
- package/dist/esm/LayoutGroupContext.mjs +2 -0
- package/dist/esm/LayoutGroupContext.mjs.map +1 -1
- package/dist/esm/LayoutGroupContext.native.js +3 -1
- package/dist/esm/LayoutGroupContext.native.js.map +1 -1
- package/dist/esm/PresenceChild.mjs +45 -55
- package/dist/esm/PresenceChild.mjs.map +1 -1
- package/dist/esm/PresenceChild.native.js +68 -80
- package/dist/esm/PresenceChild.native.js.map +1 -1
- package/dist/esm/index.js +7 -5
- package/dist/esm/index.mjs +7 -5
- package/dist/esm/index.native.js +7 -5
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/package.json +8 -8
- package/src/AnimatePresence.tsx +3 -25
- package/src/PresenceChild.tsx +1 -10
- package/src/types.ts +0 -24
- package/types/AnimatePresence.d.ts.map +1 -1
- package/types/PresenceChild.d.ts +1 -4
- package/types/PresenceChild.d.ts.map +1 -1
- package/types/types.d.ts +0 -20
- package/types/types.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
package/dist/cjs/types.cjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
13
14
|
};
|
|
14
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
}), mod);
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
17
16
|
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var types_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/cjs/types.native.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
15
16
|
};
|
|
16
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
}), mod);
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
18
|
var types_exports = {};
|
|
20
19
|
module.exports = __toCommonJS(types_exports);
|
|
20
|
+
|
|
21
21
|
//# sourceMappingURL=types.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"types.native.js","names":[],"sources":["cjs/types.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar types_exports = {};\nmodule.exports = __toCommonJS(types_exports);\n//# sourceMappingURL=types.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa"}
|
|
@@ -1,124 +1,102 @@
|
|
|
1
|
-
import { useInsertionEffect } from "react";
|
|
1
|
+
import { Children, isValidElement, useContext, useInsertionEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { useConstant } from "@tamagui/use-constant";
|
|
3
3
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
4
|
-
import { Children, isValidElement, useContext, useMemo, useRef, useState } from "react";
|
|
5
4
|
import { LayoutGroupContext } from "./LayoutGroupContext.mjs";
|
|
6
5
|
import { PresenceChild } from "./PresenceChild.mjs";
|
|
7
6
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const defaultName = ct["displayName"] || ct["name"] || "";
|
|
12
|
-
if (ct && typeof ct === "object" && "staticConfig" in ct) {
|
|
13
|
-
return ct.staticConfig.componentName || defaultName;
|
|
14
|
-
}
|
|
15
|
-
return defaultName;
|
|
16
|
-
})();
|
|
7
|
+
|
|
8
|
+
const getChildKey = (child) => {
|
|
9
|
+
return child.key ?? "";
|
|
17
10
|
};
|
|
18
11
|
function onlyElements(children) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
const filtered = [];
|
|
13
|
+
Children.forEach(children, (child) => {
|
|
14
|
+
if (isValidElement(child)) filtered.push(child);
|
|
15
|
+
});
|
|
16
|
+
return filtered;
|
|
24
17
|
}
|
|
25
|
-
const AnimatePresence = ({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
onExitComplete?.();
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
return /* @__PURE__ */jsx(PresenceChild, {
|
|
109
|
-
isPresent,
|
|
110
|
-
initial: !isInitialRender.current || initial ? void 0 : false,
|
|
111
|
-
custom: isPresent ? custom : frozenCustomRef.current.get(key) ?? custom,
|
|
112
|
-
presenceAffectsLayout,
|
|
113
|
-
enterExitVariant,
|
|
114
|
-
enterVariant,
|
|
115
|
-
exitVariant,
|
|
116
|
-
onExitComplete: isPresent ? void 0 : onExit,
|
|
117
|
-
children: child
|
|
118
|
-
}, key);
|
|
119
|
-
})
|
|
120
|
-
});
|
|
18
|
+
const AnimatePresence = ({ children, initial = true, onExitComplete, mode = "sync", presenceAffectsLayout = true, custom, passThrough }) => {
|
|
19
|
+
const presentChildren = useMemo(() => onlyElements(children), [children]);
|
|
20
|
+
const presentKeys = presentChildren.map(getChildKey);
|
|
21
|
+
const isInitialRender = useRef(true);
|
|
22
|
+
const frozenCustomRef = useRef(/* @__PURE__ */ new Map());
|
|
23
|
+
const pendingPresentChildren = useRef(presentChildren);
|
|
24
|
+
const exitComplete = useConstant(() => /* @__PURE__ */ new Map());
|
|
25
|
+
const [diffedChildren, setDiffedChildren] = useState(presentChildren);
|
|
26
|
+
const [renderedChildren, setRenderedChildren] = useState(presentChildren);
|
|
27
|
+
const forceRender = useContext(LayoutGroupContext).forceRender ?? useForceUpdate();
|
|
28
|
+
if (passThrough) {
|
|
29
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
30
|
+
}
|
|
31
|
+
useInsertionEffect(() => {
|
|
32
|
+
isInitialRender.current = false;
|
|
33
|
+
pendingPresentChildren.current = presentChildren;
|
|
34
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
35
|
+
const key = getChildKey(renderedChildren[i]);
|
|
36
|
+
if (!presentKeys.includes(key)) {
|
|
37
|
+
if (exitComplete.get(key) !== true) {
|
|
38
|
+
exitComplete.set(key, false);
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
exitComplete.delete(key);
|
|
42
|
+
frozenCustomRef.current.delete(key);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [
|
|
46
|
+
renderedChildren,
|
|
47
|
+
presentKeys.length,
|
|
48
|
+
presentKeys.join("-")
|
|
49
|
+
]);
|
|
50
|
+
if (presentChildren !== diffedChildren) {
|
|
51
|
+
let nextChildren = [...presentChildren];
|
|
52
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
53
|
+
const child = renderedChildren[i];
|
|
54
|
+
const key = getChildKey(child);
|
|
55
|
+
if (!presentKeys.includes(key)) {
|
|
56
|
+
nextChildren.splice(i, 0, child);
|
|
57
|
+
if (!frozenCustomRef.current.has(key)) {
|
|
58
|
+
frozenCustomRef.current.set(key, custom);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const exitingChildren = renderedChildren.filter((child) => !presentKeys.includes(getChildKey(child)));
|
|
63
|
+
if (mode === "wait" && exitingChildren.length) {
|
|
64
|
+
nextChildren = exitingChildren;
|
|
65
|
+
}
|
|
66
|
+
setRenderedChildren(onlyElements(nextChildren));
|
|
67
|
+
setDiffedChildren(presentChildren);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderedChildren.map((child) => {
|
|
71
|
+
const key = getChildKey(child);
|
|
72
|
+
const isPresent = presentChildren === renderedChildren || presentKeys.includes(key);
|
|
73
|
+
const onExit = () => {
|
|
74
|
+
if (exitComplete.has(key)) {
|
|
75
|
+
exitComplete.set(key, true);
|
|
76
|
+
} else {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
let isEveryExitComplete = true;
|
|
80
|
+
exitComplete.forEach((isExitComplete) => {
|
|
81
|
+
if (!isExitComplete) isEveryExitComplete = false;
|
|
82
|
+
});
|
|
83
|
+
if (isEveryExitComplete) {
|
|
84
|
+
forceRender?.();
|
|
85
|
+
setRenderedChildren(pendingPresentChildren.current);
|
|
86
|
+
onExitComplete?.();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return /* @__PURE__ */ jsx(PresenceChild, {
|
|
90
|
+
isPresent,
|
|
91
|
+
initial: !isInitialRender.current || initial ? void 0 : false,
|
|
92
|
+
custom: isPresent ? custom : frozenCustomRef.current.get(key) ?? custom,
|
|
93
|
+
presenceAffectsLayout,
|
|
94
|
+
onExitComplete: isPresent ? void 0 : onExit,
|
|
95
|
+
children: child
|
|
96
|
+
}, key);
|
|
97
|
+
}) });
|
|
121
98
|
};
|
|
122
99
|
AnimatePresence.displayName = "AnimatePresence";
|
|
100
|
+
|
|
123
101
|
export { AnimatePresence };
|
|
124
102
|
//# sourceMappingURL=AnimatePresence.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"AnimatePresence.js","names":[],"sources":["esm/AnimatePresence.js"],"sourcesContent":["import { useInsertionEffect } from \"react\";\nimport { useConstant } from \"@tamagui/use-constant\";\nimport { useForceUpdate } from \"@tamagui/use-force-update\";\nimport { Children, isValidElement, useContext, useMemo, useRef, useState } from \"react\";\nimport { LayoutGroupContext } from \"./LayoutGroupContext\";\nimport { PresenceChild } from \"./PresenceChild\";\nimport { Fragment, jsx } from \"react/jsx-runtime\";\nconst getChildKey = (child) => {\n return child.key ?? \"\";\n};\nfunction onlyElements(children) {\n const filtered = [];\n Children.forEach(children, (child) => {\n if (isValidElement(child)) filtered.push(child);\n });\n return filtered;\n}\nconst AnimatePresence = ({\n children,\n initial = true,\n onExitComplete,\n mode = \"sync\",\n presenceAffectsLayout = true,\n custom,\n passThrough\n}) => {\n const presentChildren = useMemo(() => onlyElements(children), [children]);\n const presentKeys = presentChildren.map(getChildKey);\n const isInitialRender = useRef(true);\n const frozenCustomRef = useRef(/* @__PURE__ */ new Map());\n const pendingPresentChildren = useRef(presentChildren);\n const exitComplete = useConstant(() => /* @__PURE__ */ new Map());\n const [diffedChildren, setDiffedChildren] = useState(presentChildren);\n const [renderedChildren, setRenderedChildren] = useState(presentChildren);\n const forceRender = useContext(LayoutGroupContext).forceRender ?? useForceUpdate();\n if (passThrough) {\n return /* @__PURE__ */ jsx(Fragment, { children });\n }\n useInsertionEffect(() => {\n isInitialRender.current = false;\n pendingPresentChildren.current = presentChildren;\n for (let i = 0; i < renderedChildren.length; i++) {\n const key = getChildKey(renderedChildren[i]);\n if (!presentKeys.includes(key)) {\n if (exitComplete.get(key) !== true) {\n exitComplete.set(key, false);\n }\n } else {\n exitComplete.delete(key);\n frozenCustomRef.current.delete(key);\n }\n }\n }, [renderedChildren, presentKeys.length, presentKeys.join(\"-\")]);\n if (presentChildren !== diffedChildren) {\n let nextChildren = [...presentChildren];\n for (let i = 0; i < renderedChildren.length; i++) {\n const child = renderedChildren[i];\n const key = getChildKey(child);\n if (!presentKeys.includes(key)) {\n nextChildren.splice(i, 0, child);\n if (!frozenCustomRef.current.has(key)) {\n frozenCustomRef.current.set(key, custom);\n }\n }\n }\n const exitingChildren = renderedChildren.filter(\n (child) => !presentKeys.includes(getChildKey(child))\n );\n if (mode === \"wait\" && exitingChildren.length) {\n nextChildren = exitingChildren;\n }\n setRenderedChildren(onlyElements(nextChildren));\n setDiffedChildren(presentChildren);\n return null;\n }\n return /* @__PURE__ */ jsx(Fragment, { children: renderedChildren.map((child) => {\n const key = getChildKey(child);\n const isPresent = presentChildren === renderedChildren || presentKeys.includes(key);\n const onExit = () => {\n if (exitComplete.has(key)) {\n exitComplete.set(key, true);\n } else {\n return;\n }\n let isEveryExitComplete = true;\n exitComplete.forEach((isExitComplete) => {\n if (!isExitComplete) isEveryExitComplete = false;\n });\n if (isEveryExitComplete) {\n forceRender?.();\n setRenderedChildren(pendingPresentChildren.current);\n onExitComplete?.();\n }\n };\n return /* @__PURE__ */ jsx(\n PresenceChild,\n {\n isPresent,\n initial: !isInitialRender.current || initial ? void 0 : false,\n custom: isPresent ? custom : frozenCustomRef.current.get(key) ?? custom,\n presenceAffectsLayout,\n onExitComplete: isPresent ? void 0 : onExit,\n children: child\n },\n key\n );\n }) });\n};\nAnimatePresence.displayName = \"AnimatePresence\";\nexport {\n AnimatePresence\n};\n//# sourceMappingURL=AnimatePresence.js.map\n"],"mappings":"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"}
|
|
@@ -1,138 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useInsertionEffect } from "react";
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children, isValidElement, useContext, useInsertionEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useConstant } from "@tamagui/use-constant";
|
|
4
4
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
5
|
-
import { Children, isValidElement, useContext, useMemo, useRef, useState } from "react";
|
|
6
5
|
import { LayoutGroupContext } from "./LayoutGroupContext.native.js";
|
|
7
6
|
import { PresenceChild } from "./PresenceChild.native.js";
|
|
8
|
-
function _type_of(obj) {
|
|
9
|
-
"@swc/helpers - typeof";
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return child.key || function () {
|
|
15
|
-
var ct = child.type;
|
|
16
|
-
var defaultName = ct["displayName"] || ct["name"] || "";
|
|
17
|
-
if (ct && (typeof ct === "undefined" ? "undefined" : _type_of(ct)) === "object" && "staticConfig" in ct) {
|
|
18
|
-
return ct.staticConfig.componentName || defaultName;
|
|
19
|
-
}
|
|
20
|
-
return defaultName;
|
|
21
|
-
}();
|
|
8
|
+
var getChildKey = function(child) {
|
|
9
|
+
var _child_key;
|
|
10
|
+
return (_child_key = child.key) !== null && _child_key !== void 0 ? _child_key : "";
|
|
22
11
|
};
|
|
23
12
|
function onlyElements(children) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
var filtered = [];
|
|
14
|
+
Children.forEach(children, function(child) {
|
|
15
|
+
if (/* @__PURE__ */ isValidElement(child)) filtered.push(child);
|
|
16
|
+
});
|
|
17
|
+
return filtered;
|
|
29
18
|
}
|
|
30
|
-
var AnimatePresence = function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
var _frozenCustomRef_current_get;
|
|
122
|
-
return /* @__PURE__ */_jsx(PresenceChild, {
|
|
123
|
-
isPresent,
|
|
124
|
-
initial: !isInitialRender.current || initial ? void 0 : false,
|
|
125
|
-
custom: isPresent ? custom : (_frozenCustomRef_current_get = frozenCustomRef.current.get(key2)) !== null && _frozenCustomRef_current_get !== void 0 ? _frozenCustomRef_current_get : custom,
|
|
126
|
-
presenceAffectsLayout,
|
|
127
|
-
enterExitVariant,
|
|
128
|
-
enterVariant,
|
|
129
|
-
exitVariant,
|
|
130
|
-
onExitComplete: isPresent ? void 0 : onExit,
|
|
131
|
-
children: child2
|
|
132
|
-
}, key2);
|
|
133
|
-
})
|
|
134
|
-
});
|
|
19
|
+
var AnimatePresence = function(param) {
|
|
20
|
+
var { children, initial = true, onExitComplete, mode = "sync", presenceAffectsLayout = true, custom, passThrough } = param;
|
|
21
|
+
var presentChildren = useMemo(function() {
|
|
22
|
+
return onlyElements(children);
|
|
23
|
+
}, [children]);
|
|
24
|
+
var presentKeys = presentChildren.map(getChildKey);
|
|
25
|
+
var isInitialRender = useRef(true);
|
|
26
|
+
var frozenCustomRef = useRef(/* @__PURE__ */ new Map());
|
|
27
|
+
var pendingPresentChildren = useRef(presentChildren);
|
|
28
|
+
var exitComplete = useConstant(function() {
|
|
29
|
+
return /* @__PURE__ */ new Map();
|
|
30
|
+
});
|
|
31
|
+
var [diffedChildren, setDiffedChildren] = useState(presentChildren);
|
|
32
|
+
var [renderedChildren, setRenderedChildren] = useState(presentChildren);
|
|
33
|
+
var _useContext_forceRender;
|
|
34
|
+
var forceRender = (_useContext_forceRender = useContext(LayoutGroupContext).forceRender) !== null && _useContext_forceRender !== void 0 ? _useContext_forceRender : useForceUpdate();
|
|
35
|
+
if (passThrough) {
|
|
36
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
37
|
+
}
|
|
38
|
+
useInsertionEffect(function() {
|
|
39
|
+
isInitialRender.current = false;
|
|
40
|
+
pendingPresentChildren.current = presentChildren;
|
|
41
|
+
for (var i2 = 0; i2 < renderedChildren.length; i2++) {
|
|
42
|
+
var key2 = getChildKey(renderedChildren[i2]);
|
|
43
|
+
if (!presentKeys.includes(key2)) {
|
|
44
|
+
if (exitComplete.get(key2) !== true) {
|
|
45
|
+
exitComplete.set(key2, false);
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
exitComplete.delete(key2);
|
|
49
|
+
frozenCustomRef.current.delete(key2);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, [
|
|
53
|
+
renderedChildren,
|
|
54
|
+
presentKeys.length,
|
|
55
|
+
presentKeys.join("-")
|
|
56
|
+
]);
|
|
57
|
+
if (presentChildren !== diffedChildren) {
|
|
58
|
+
var nextChildren = [...presentChildren];
|
|
59
|
+
for (var i = 0; i < renderedChildren.length; i++) {
|
|
60
|
+
var child = renderedChildren[i];
|
|
61
|
+
var key = getChildKey(child);
|
|
62
|
+
if (!presentKeys.includes(key)) {
|
|
63
|
+
nextChildren.splice(i, 0, child);
|
|
64
|
+
if (!frozenCustomRef.current.has(key)) {
|
|
65
|
+
frozenCustomRef.current.set(key, custom);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
var exitingChildren = renderedChildren.filter(function(child2) {
|
|
70
|
+
return !presentKeys.includes(getChildKey(child2));
|
|
71
|
+
});
|
|
72
|
+
if (mode === "wait" && exitingChildren.length) {
|
|
73
|
+
nextChildren = exitingChildren;
|
|
74
|
+
}
|
|
75
|
+
setRenderedChildren(onlyElements(nextChildren));
|
|
76
|
+
setDiffedChildren(presentChildren);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderedChildren.map(function(child2) {
|
|
80
|
+
var key2 = getChildKey(child2);
|
|
81
|
+
var isPresent = presentChildren === renderedChildren || presentKeys.includes(key2);
|
|
82
|
+
var onExit = function() {
|
|
83
|
+
if (exitComplete.has(key2)) {
|
|
84
|
+
exitComplete.set(key2, true);
|
|
85
|
+
} else {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
var isEveryExitComplete = true;
|
|
89
|
+
exitComplete.forEach(function(isExitComplete) {
|
|
90
|
+
if (!isExitComplete) isEveryExitComplete = false;
|
|
91
|
+
});
|
|
92
|
+
if (isEveryExitComplete) {
|
|
93
|
+
forceRender === null || forceRender === void 0 ? void 0 : forceRender();
|
|
94
|
+
setRenderedChildren(pendingPresentChildren.current);
|
|
95
|
+
onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var _frozenCustomRef_current_get;
|
|
99
|
+
return /* @__PURE__ */ jsx(PresenceChild, {
|
|
100
|
+
isPresent,
|
|
101
|
+
initial: !isInitialRender.current || initial ? void 0 : false,
|
|
102
|
+
custom: isPresent ? custom : (_frozenCustomRef_current_get = frozenCustomRef.current.get(key2)) !== null && _frozenCustomRef_current_get !== void 0 ? _frozenCustomRef_current_get : custom,
|
|
103
|
+
presenceAffectsLayout,
|
|
104
|
+
onExitComplete: isPresent ? void 0 : onExit,
|
|
105
|
+
children: child2
|
|
106
|
+
}, key2);
|
|
107
|
+
}) });
|
|
135
108
|
};
|
|
136
109
|
AnimatePresence.displayName = "AnimatePresence";
|
|
110
|
+
|
|
137
111
|
export { AnimatePresence };
|
|
138
112
|
//# sourceMappingURL=AnimatePresence.native.js.map
|