@tamagui/animate-presence 2.0.0-rc.9 → 2.0.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.
- package/dist/cjs/AnimatePresence.cjs +112 -91
- package/dist/cjs/AnimatePresence.native.js +127 -106
- package/dist/cjs/AnimatePresence.native.js.map +1 -1
- package/dist/cjs/LayoutGroupContext.cjs +24 -22
- package/dist/cjs/LayoutGroupContext.native.js +26 -24
- package/dist/cjs/LayoutGroupContext.native.js.map +1 -1
- package/dist/cjs/PresenceChild.cjs +58 -45
- package/dist/cjs/PresenceChild.native.js +103 -91
- package/dist/cjs/PresenceChild.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/types.native.js +7 -5
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/AnimatePresence.mjs +96 -77
- package/dist/esm/AnimatePresence.mjs.map +1 -1
- package/dist/esm/AnimatePresence.native.js +111 -92
- package/dist/esm/AnimatePresence.native.js.map +1 -1
- package/dist/esm/PresenceChild.mjs +29 -18
- package/dist/esm/PresenceChild.mjs.map +1 -1
- package/dist/esm/PresenceChild.native.js +60 -50
- package/dist/esm/PresenceChild.native.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -6
- package/package.json +10 -9
- package/src/AnimatePresence.tsx +150 -143
- package/src/types.ts +10 -9
- package/types/AnimatePresence.d.ts.map +1 -1
- package/types/types.d.ts +9 -9
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/AnimatePresence.js +0 -121
- package/dist/cjs/AnimatePresence.js.map +0 -6
- package/dist/cjs/LayoutGroupContext.js +0 -30
- package/dist/cjs/LayoutGroupContext.js.map +0 -6
- package/dist/cjs/PresenceChild.js +0 -77
- package/dist/cjs/PresenceChild.js.map +0 -6
- package/dist/cjs/index.js +0 -18
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/esm/AnimatePresence.js +0 -110
- package/dist/esm/AnimatePresence.js.map +0 -6
- package/dist/esm/LayoutGroupContext.js +0 -6
- package/dist/esm/LayoutGroupContext.js.map +0 -6
- package/dist/esm/PresenceChild.js +0 -57
- package/dist/esm/PresenceChild.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
|
@@ -3,126 +3,147 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var AnimatePresence_exports = {};
|
|
22
24
|
__export(AnimatePresence_exports, {
|
|
23
25
|
AnimatePresence: () => AnimatePresence
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(AnimatePresence_exports);
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
}
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_use_constant = require("@tamagui/use-constant");
|
|
30
|
+
var import_use_force_update = require("@tamagui/use-force-update");
|
|
31
|
+
var import_react2 = require("react");
|
|
32
|
+
var import_LayoutGroupContext = require("./LayoutGroupContext.cjs");
|
|
33
|
+
var import_PresenceChild = require("./PresenceChild.cjs");
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
const getChildKey = child => {
|
|
36
|
+
return child.key || (() => {
|
|
37
|
+
const ct = child.type;
|
|
38
|
+
const defaultName = ct["displayName"] || ct["name"] || "";
|
|
39
|
+
if (ct && typeof ct === "object" && "staticConfig" in ct) {
|
|
40
|
+
return ct.staticConfig.componentName || defaultName;
|
|
41
|
+
}
|
|
42
|
+
return defaultName;
|
|
43
|
+
})();
|
|
44
|
+
};
|
|
43
45
|
function onlyElements(children) {
|
|
44
46
|
const filtered = [];
|
|
45
|
-
|
|
46
|
-
(0,
|
|
47
|
-
})
|
|
47
|
+
import_react2.Children.forEach(children, child => {
|
|
48
|
+
if ((0, import_react2.isValidElement)(child)) filtered.push(child);
|
|
49
|
+
});
|
|
50
|
+
return filtered;
|
|
48
51
|
}
|
|
49
52
|
const AnimatePresence = ({
|
|
50
53
|
children,
|
|
51
54
|
enterVariant,
|
|
52
55
|
exitVariant,
|
|
53
56
|
enterExitVariant,
|
|
54
|
-
initial =
|
|
57
|
+
initial = true,
|
|
55
58
|
onExitComplete,
|
|
56
59
|
exitBeforeEnter,
|
|
57
|
-
|
|
60
|
+
mode,
|
|
61
|
+
presenceAffectsLayout = true,
|
|
58
62
|
custom,
|
|
59
63
|
passThrough
|
|
60
64
|
}) => {
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
65
|
+
const effectiveMode = mode ?? (exitBeforeEnter ? "wait" : "sync");
|
|
66
|
+
const presentChildren = (0, import_react2.useMemo)(() => onlyElements(children), [children]);
|
|
67
|
+
const presentKeys = presentChildren.map(getChildKey);
|
|
68
|
+
const isInitialRender = (0, import_react2.useRef)(true);
|
|
69
|
+
const frozenCustomRef = (0, import_react2.useRef)(/* @__PURE__ */new Map());
|
|
70
|
+
const pendingPresentChildren = (0, import_react2.useRef)(presentChildren);
|
|
71
|
+
const exitComplete = (0, import_use_constant.useConstant)(() => /* @__PURE__ */new Map());
|
|
72
|
+
const [diffedChildren, setDiffedChildren] = (0, import_react2.useState)(presentChildren);
|
|
73
|
+
const [renderedChildren, setRenderedChildren] = (0, import_react2.useState)(presentChildren);
|
|
74
|
+
const forceRender = (0, import_react2.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender ?? (0, import_use_force_update.useForceUpdate)();
|
|
75
|
+
if (passThrough) {
|
|
76
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
77
|
+
children
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
(0, import_react.useInsertionEffect)(() => {
|
|
81
|
+
isInitialRender.current = false;
|
|
82
|
+
pendingPresentChildren.current = presentChildren;
|
|
83
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
84
|
+
const key = getChildKey(renderedChildren[i]);
|
|
85
|
+
if (!presentKeys.includes(key)) {
|
|
86
|
+
if (exitComplete.get(key) !== true) {
|
|
87
|
+
exitComplete.set(key, false);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
exitComplete.delete(key);
|
|
91
|
+
frozenCustomRef.current.delete(key);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
|
|
95
|
+
if (presentChildren !== diffedChildren) {
|
|
96
|
+
let nextChildren = [...presentChildren];
|
|
97
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
98
|
+
const child = renderedChildren[i];
|
|
99
|
+
const key = getChildKey(child);
|
|
100
|
+
if (!presentKeys.includes(key)) {
|
|
101
|
+
nextChildren.splice(i, 0, child);
|
|
102
|
+
if (!frozenCustomRef.current.has(key)) {
|
|
103
|
+
frozenCustomRef.current.set(key, custom);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const exitingChildren = renderedChildren.filter(child => !presentKeys.includes(getChildKey(child)));
|
|
108
|
+
if (effectiveMode === "wait" && exitingChildren.length) {
|
|
109
|
+
nextChildren = exitingChildren;
|
|
110
|
+
}
|
|
111
|
+
setRenderedChildren(onlyElements(nextChildren));
|
|
112
|
+
setDiffedChildren(presentChildren);
|
|
113
|
+
return null;
|
|
92
114
|
}
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
116
|
+
children: renderedChildren.map(child => {
|
|
117
|
+
const key = getChildKey(child);
|
|
118
|
+
const isPresent = presentChildren === renderedChildren || presentKeys.includes(key);
|
|
119
|
+
const onExit = () => {
|
|
120
|
+
if (exitComplete.has(key)) {
|
|
121
|
+
exitComplete.set(key, true);
|
|
122
|
+
} else {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
let isEveryExitComplete = true;
|
|
126
|
+
exitComplete.forEach(isExitComplete => {
|
|
127
|
+
if (!isExitComplete) isEveryExitComplete = false;
|
|
128
|
+
});
|
|
129
|
+
if (isEveryExitComplete) {
|
|
130
|
+
forceRender?.();
|
|
131
|
+
setRenderedChildren(pendingPresentChildren.current);
|
|
132
|
+
onExitComplete?.();
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
|
|
136
|
+
isPresent,
|
|
137
|
+
initial: !isInitialRender.current || initial ? void 0 : false,
|
|
138
|
+
custom: isPresent ? custom : frozenCustomRef.current.get(key) ?? custom,
|
|
105
139
|
presenceAffectsLayout,
|
|
106
140
|
enterExitVariant,
|
|
107
141
|
enterVariant,
|
|
108
142
|
exitVariant,
|
|
109
|
-
|
|
143
|
+
onExitComplete: isPresent ? void 0 : onExit,
|
|
110
144
|
children: child
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
}), childrenToRender = childrenToRender.map(child => {
|
|
114
|
-
const key = child.key;
|
|
115
|
-
return exiting.has(key) ? child : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
|
|
116
|
-
isPresent: !0,
|
|
117
|
-
exitVariant,
|
|
118
|
-
enterVariant,
|
|
119
|
-
enterExitVariant,
|
|
120
|
-
presenceAffectsLayout,
|
|
121
|
-
custom,
|
|
122
|
-
children: child
|
|
123
|
-
}, getChildKey(child));
|
|
124
|
-
}), presentChildren.current = childrenToRender, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
125
|
-
children: exiting.size ? childrenToRender : childrenToRender.map(child => (0, import_react.cloneElement)(child))
|
|
145
|
+
}, key);
|
|
146
|
+
})
|
|
126
147
|
});
|
|
127
148
|
};
|
|
128
149
|
AnimatePresence.displayName = "AnimatePresence";
|
|
@@ -5,139 +5,160 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var AnimatePresence_exports = {};
|
|
24
26
|
__export(AnimatePresence_exports, {
|
|
25
27
|
AnimatePresence: () => AnimatePresence
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(AnimatePresence_exports);
|
|
28
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_use_constant = require("@tamagui/use-constant");
|
|
33
|
+
var import_use_force_update = require("@tamagui/use-force-update");
|
|
34
|
+
var import_react2 = require("react");
|
|
35
|
+
var import_LayoutGroupContext = require("./LayoutGroupContext.native.js");
|
|
36
|
+
var import_PresenceChild = require("./PresenceChild.native.js");
|
|
34
37
|
function _type_of(obj) {
|
|
35
38
|
"@swc/helpers - typeof";
|
|
36
39
|
|
|
37
|
-
return obj && typeof Symbol
|
|
40
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
38
41
|
}
|
|
39
42
|
var getChildKey = function (child) {
|
|
40
43
|
return child.key || function () {
|
|
41
|
-
var ct = child.type
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
var ct = child.type;
|
|
45
|
+
var defaultName = ct["displayName"] || ct["name"] || "";
|
|
46
|
+
if (ct && (typeof ct === "undefined" ? "undefined" : _type_of(ct)) === "object" && "staticConfig" in ct) {
|
|
47
|
+
return ct.staticConfig.componentName || defaultName;
|
|
48
|
+
}
|
|
49
|
+
return defaultName;
|
|
44
50
|
}();
|
|
45
51
|
};
|
|
46
|
-
function updateChildLookup(children, allChildren) {
|
|
47
|
-
children.forEach(function (child) {
|
|
48
|
-
var key = getChildKey(child);
|
|
49
|
-
allChildren.set(key, child);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
52
|
function onlyElements(children) {
|
|
53
53
|
var filtered = [];
|
|
54
|
-
|
|
55
|
-
/* @__PURE__ */(0,
|
|
56
|
-
})
|
|
54
|
+
import_react2.Children.forEach(children, function (child) {
|
|
55
|
+
if (/* @__PURE__ */(0, import_react2.isValidElement)(child)) filtered.push(child);
|
|
56
|
+
});
|
|
57
|
+
return filtered;
|
|
57
58
|
}
|
|
58
59
|
var AnimatePresence = function (param) {
|
|
59
60
|
var {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
61
|
+
children,
|
|
62
|
+
enterVariant,
|
|
63
|
+
exitVariant,
|
|
64
|
+
enterExitVariant,
|
|
65
|
+
initial = true,
|
|
66
|
+
onExitComplete,
|
|
67
|
+
exitBeforeEnter,
|
|
68
|
+
mode,
|
|
69
|
+
presenceAffectsLayout = true,
|
|
70
|
+
custom,
|
|
71
|
+
passThrough
|
|
72
|
+
} = param;
|
|
73
|
+
var effectiveMode = mode !== null && mode !== void 0 ? mode : exitBeforeEnter ? "wait" : "sync";
|
|
74
|
+
var presentChildren = (0, import_react2.useMemo)(function () {
|
|
75
|
+
return onlyElements(children);
|
|
76
|
+
}, [children]);
|
|
77
|
+
var presentKeys = presentChildren.map(getChildKey);
|
|
78
|
+
var isInitialRender = (0, import_react2.useRef)(true);
|
|
79
|
+
var frozenCustomRef = (0, import_react2.useRef)(/* @__PURE__ */new Map());
|
|
80
|
+
var pendingPresentChildren = (0, import_react2.useRef)(presentChildren);
|
|
81
|
+
var exitComplete = (0, import_use_constant.useConstant)(function () {
|
|
82
|
+
return /* @__PURE__ */new Map();
|
|
81
83
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
enterVariant,
|
|
91
|
-
initial: initial ? void 0 : !1,
|
|
92
|
-
presenceAffectsLayout,
|
|
93
|
-
custom,
|
|
94
|
-
children: child
|
|
95
|
-
}, getChildKey(child));
|
|
96
|
-
})
|
|
97
|
-
});
|
|
98
|
-
for (var childrenToRender = [...filteredChildren], presentKeys = presentChildren.current.map(getChildKey), targetKeys = filteredChildren.map(getChildKey), numPresent = presentKeys.length, i = 0; i < numPresent; i++) {
|
|
99
|
-
var key = presentKeys[i];
|
|
100
|
-
targetKeys.indexOf(key) === -1 ? exiting.add(key) : exiting.delete(key);
|
|
84
|
+
var [diffedChildren, setDiffedChildren] = (0, import_react2.useState)(presentChildren);
|
|
85
|
+
var [renderedChildren, setRenderedChildren] = (0, import_react2.useState)(presentChildren);
|
|
86
|
+
var _useContext_forceRender;
|
|
87
|
+
var forceRender = (_useContext_forceRender = (0, import_react2.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender) !== null && _useContext_forceRender !== void 0 ? _useContext_forceRender : (0, import_use_force_update.useForceUpdate)();
|
|
88
|
+
if (passThrough) {
|
|
89
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
90
|
+
children
|
|
91
|
+
});
|
|
101
92
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
exitingComponent = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
|
|
115
|
-
isPresent: !1,
|
|
116
|
-
onExitComplete: onExit,
|
|
117
|
-
presenceAffectsLayout,
|
|
118
|
-
enterExitVariant,
|
|
119
|
-
enterVariant,
|
|
120
|
-
exitVariant,
|
|
121
|
-
custom,
|
|
122
|
-
children: child
|
|
123
|
-
}, getChildKey(child));
|
|
124
|
-
childrenToRender.splice(insertionIndex, 0, exitingComponent);
|
|
93
|
+
(0, import_react.useInsertionEffect)(function () {
|
|
94
|
+
isInitialRender.current = false;
|
|
95
|
+
pendingPresentChildren.current = presentChildren;
|
|
96
|
+
for (var i2 = 0; i2 < renderedChildren.length; i2++) {
|
|
97
|
+
var key2 = getChildKey(renderedChildren[i2]);
|
|
98
|
+
if (!presentKeys.includes(key2)) {
|
|
99
|
+
if (exitComplete.get(key2) !== true) {
|
|
100
|
+
exitComplete.set(key2, false);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
exitComplete.delete(key2);
|
|
104
|
+
frozenCustomRef.current.delete(key2);
|
|
125
105
|
}
|
|
126
106
|
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
107
|
+
}, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
|
|
108
|
+
if (presentChildren !== diffedChildren) {
|
|
109
|
+
var nextChildren = [...presentChildren];
|
|
110
|
+
for (var i = 0; i < renderedChildren.length; i++) {
|
|
111
|
+
var child = renderedChildren[i];
|
|
112
|
+
var key = getChildKey(child);
|
|
113
|
+
if (!presentKeys.includes(key)) {
|
|
114
|
+
nextChildren.splice(i, 0, child);
|
|
115
|
+
if (!frozenCustomRef.current.has(key)) {
|
|
116
|
+
frozenCustomRef.current.set(key, custom);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
var exitingChildren = renderedChildren.filter(function (child2) {
|
|
121
|
+
return !presentKeys.includes(getChildKey(child2));
|
|
122
|
+
});
|
|
123
|
+
if (effectiveMode === "wait" && exitingChildren.length) {
|
|
124
|
+
nextChildren = exitingChildren;
|
|
125
|
+
}
|
|
126
|
+
setRenderedChildren(onlyElements(nextChildren));
|
|
127
|
+
setDiffedChildren(presentChildren);
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
131
|
+
children: renderedChildren.map(function (child2) {
|
|
132
|
+
var key2 = getChildKey(child2);
|
|
133
|
+
var isPresent = presentChildren === renderedChildren || presentKeys.includes(key2);
|
|
134
|
+
var onExit = function () {
|
|
135
|
+
if (exitComplete.has(key2)) {
|
|
136
|
+
exitComplete.set(key2, true);
|
|
137
|
+
} else {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
var isEveryExitComplete = true;
|
|
141
|
+
exitComplete.forEach(function (isExitComplete) {
|
|
142
|
+
if (!isExitComplete) isEveryExitComplete = false;
|
|
143
|
+
});
|
|
144
|
+
if (isEveryExitComplete) {
|
|
145
|
+
forceRender === null || forceRender === void 0 ? void 0 : forceRender();
|
|
146
|
+
setRenderedChildren(pendingPresentChildren.current);
|
|
147
|
+
onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var _frozenCustomRef_current_get;
|
|
151
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
|
|
152
|
+
isPresent,
|
|
153
|
+
initial: !isInitialRender.current || initial ? void 0 : false,
|
|
154
|
+
custom: isPresent ? custom : (_frozenCustomRef_current_get = frozenCustomRef.current.get(key2)) !== null && _frozenCustomRef_current_get !== void 0 ? _frozenCustomRef_current_get : custom,
|
|
155
|
+
presenceAffectsLayout,
|
|
156
|
+
enterExitVariant,
|
|
157
|
+
enterVariant,
|
|
158
|
+
exitVariant,
|
|
159
|
+
onExitComplete: isPresent ? void 0 : onExit,
|
|
160
|
+
children: child2
|
|
161
|
+
}, key2);
|
|
141
162
|
})
|
|
142
163
|
});
|
|
143
164
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","AnimatePresence_exports","__export","AnimatePresence","module","exports","import_jsx_runtime","require","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","AnimatePresence_exports","__export","AnimatePresence","module","exports","import_jsx_runtime","require","import_react","import_use_constant","import_use_force_update","import_react2","import_LayoutGroupContext","import_PresenceChild","_type_of","obj","Symbol","constructor","getChildKey","child","key","ct","type","defaultName","staticConfig","componentName","onlyElements","children","filtered","Children","forEach","isValidElement","push","param","enterVariant","exitVariant","enterExitVariant","initial","onExitComplete","exitBeforeEnter","mode","presenceAffectsLayout","custom","passThrough","effectiveMode","presentChildren","useMemo","presentKeys","map","isInitialRender","useRef","frozenCustomRef","Map","pendingPresentChildren","exitComplete","useConstant","diffedChildren","setDiffedChildren","useState","renderedChildren","setRenderedChildren","_useContext_forceRender","forceRender","useContext","LayoutGroupContext","useForceUpdate","jsx","Fragment","useInsertionEffect","current","i2","length","key2","includes","get","set","delete","join","nextChildren","i","splice","has","exitingChildren","filter","child2","isPresent","onExit","isEveryExitComplete","isExitComplete","_frozenCustomRef_current_get","PresenceChild"],"sources":["../../src/AnimatePresence.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,eAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAmC,CAAAK,uBAAA;AACnC,IAAAK,kBAAA,GAAAC,OAA4B;AAC5B,IAAAC,YAAA,GAAAD,OAAA,QAA+B;AAE/B,IAAAE,mBAAgF,GAAAF,OAAA;AAChF,IAAAG,uBAAA,GAAAH,OAAmC;AACnC,IAAAI,aAAA,GAAAJ,OAA8B;AAiGnB,IAAAK,yBAAA,GAAAL,OAAA;AA5FX,IAAAM,oBAAqB,GAAAN,OAA2C;AAC9D,SACEO,QAAMA,CAAAC,GAAA,EACL;EAEC,uBAAiB;;EACjB,OAAAA,GAAM,WAAAC,MAAiB,gBAAkB,IAAGD,GAAA,CAAAE,WAAW,KAAAD,MAAA,qBAAAD,GAAA;AACvD;AAEE,IAAAG,WAAO,GAAG,SAAAA,CAAAC,KAAa;EAAiB,OAC1CA,KAAA,CAAAC,GAAA;IACA,IAAAC,EAAA,GAAOF,KAAA,CAAAG,IAAA;IACT,IAAGC,WAAA,GAAAF,EAAA,mBAAAA,EAAA;IAEP,IAAAA,EAAA,YAAAA,EAA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,cAAA;QACA;MAAA;MACA,IACAmD,4BAA4B;MAAY,OAEvC,mBAAAnF,kBAAA,CAAA4D,GAAA,EAAArD,oBAAA,CAAA6E,aAAA;QAAAL,SAAA;QAVIhD,OAAA,GAAAY,eAAA,CAAAoB,OAAA,IAAAhC,OAAA;QAWPK,MAAA,EAAA2C,SAAA,GAAA3C,MAAA,IAAA+C,4BAAA,GAAAtC,eAAA,CAAAkB,OAAA,CAAAK,GAAA,CAAAF,IAAA,eAAAiB,4BAAA,cAAAA,4BAAA,GAAA/C,MAAA;QAGND,qBAAA;QAEJL,gBAAA;QAEAF,YAAgB","ignoreList":[]}
|
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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);
|
|
32
34
|
var LayoutGroupContext_exports = {};
|
|
33
35
|
__export(LayoutGroupContext_exports, {
|
|
34
36
|
LayoutGroupContext: () => LayoutGroupContext
|