@tamagui/animate-presence 1.61.3 → 1.62.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.js +44 -99
- package/dist/cjs/AnimatePresence.js.map +1 -1
- package/dist/cjs/AnimatePresence.native.js +147 -0
- package/dist/cjs/AnimatePresence.native.js.map +6 -0
- package/dist/cjs/LayoutGroupContext.js +5 -9
- package/dist/cjs/LayoutGroupContext.js.map +1 -1
- package/dist/cjs/LayoutGroupContext.native.js +27 -0
- package/dist/cjs/LayoutGroupContext.native.js.map +6 -0
- package/dist/cjs/PresenceChild.js +30 -51
- package/dist/cjs/PresenceChild.js.map +1 -1
- package/dist/cjs/PresenceChild.native.js +78 -0
- package/dist/cjs/PresenceChild.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +26 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/types.js +3 -6
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/types.native.js +15 -0
- package/dist/cjs/types.native.js.map +6 -0
- package/dist/esm/AnimatePresence.js +37 -81
- package/dist/esm/AnimatePresence.js.map +1 -1
- package/dist/esm/PresenceChild.js +23 -34
- package/dist/esm/PresenceChild.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,122 +17,78 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var AnimatePresence_exports = {};
|
|
30
24
|
__export(AnimatePresence_exports, {
|
|
31
25
|
AnimatePresence: () => AnimatePresence
|
|
32
26
|
});
|
|
33
27
|
module.exports = __toCommonJS(AnimatePresence_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
|
|
36
|
-
var import_web = require("@tamagui/web");
|
|
37
|
-
var import_react = __toESM(require("react"));
|
|
38
|
-
var import_LayoutGroupContext = require("./LayoutGroupContext");
|
|
39
|
-
var import_PresenceChild = require("./PresenceChild");
|
|
40
|
-
const getChildKey = (child) => child.key || "";
|
|
41
|
-
const isDev = process.env.NODE_ENV !== "production";
|
|
28
|
+
var import_use_force_update = require("@tamagui/use-force-update"), import_web = require("@tamagui/web"), import_react = __toESM(require("react")), import_LayoutGroupContext = require("./LayoutGroupContext"), import_PresenceChild = require("./PresenceChild"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
const getChildKey = (child) => child.key || "", isDev = process.env.NODE_ENV !== "production";
|
|
42
30
|
function updateChildLookup(children, allChildren) {
|
|
43
31
|
const seenChildren = isDev ? /* @__PURE__ */ new Set() : null;
|
|
44
32
|
children.forEach((child) => {
|
|
45
33
|
const key = getChildKey(child);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
);
|
|
50
|
-
seenChildren.add(key);
|
|
51
|
-
}
|
|
52
|
-
allChildren.set(key, child);
|
|
34
|
+
isDev && seenChildren && seenChildren.has(key) && (console.warn(
|
|
35
|
+
`Children of AnimatePresence require unique keys. "${key}" is a duplicate.`
|
|
36
|
+
), seenChildren.add(key)), allChildren.set(key, child);
|
|
53
37
|
});
|
|
54
38
|
}
|
|
55
39
|
function onlyElements(children) {
|
|
56
40
|
const filtered = [];
|
|
57
|
-
import_react.Children.forEach(children, (child, index) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
import_react.default.cloneElement(child, {
|
|
65
|
-
key: index
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
} else {
|
|
69
|
-
filtered.push(child);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return filtered;
|
|
41
|
+
return import_react.Children.forEach(children, (child, index) => {
|
|
42
|
+
(0, import_react.isValidElement)(child) && (!child.key && import_react.Children.count(children) > 1 ? (process.env.NODE_ENV === "development" && console.warn("No key given to AnimatePresence child, assigning index as key"), filtered.push(
|
|
43
|
+
import_react.default.cloneElement(child, {
|
|
44
|
+
key: index
|
|
45
|
+
})
|
|
46
|
+
)) : filtered.push(child));
|
|
47
|
+
}), filtered;
|
|
74
48
|
}
|
|
75
49
|
const AnimatePresence = ({
|
|
76
50
|
children,
|
|
77
51
|
enterVariant,
|
|
78
52
|
exitVariant,
|
|
79
53
|
enterExitVariant,
|
|
80
|
-
initial =
|
|
54
|
+
initial = !0,
|
|
81
55
|
onExitComplete,
|
|
82
56
|
exitBeforeEnter,
|
|
83
|
-
presenceAffectsLayout =
|
|
57
|
+
presenceAffectsLayout = !0
|
|
84
58
|
}) => {
|
|
85
59
|
let forceRender = (0, import_use_force_update.useForceUpdate)();
|
|
86
|
-
const isClientMounted = (0, import_web.useDidFinishSSR)();
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
forceRender = forceRenderLayoutGroup;
|
|
90
|
-
const isMounted = (0, import_react.useRef)(false);
|
|
91
|
-
const filteredChildren = onlyElements(children);
|
|
60
|
+
const isClientMounted = (0, import_web.useDidFinishSSR)(), forceRenderLayoutGroup = (0, import_react.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender;
|
|
61
|
+
forceRenderLayoutGroup && (forceRender = forceRenderLayoutGroup);
|
|
62
|
+
const isMounted = (0, import_react.useRef)(!1), filteredChildren = onlyElements(children);
|
|
92
63
|
let childrenToRender = filteredChildren;
|
|
93
|
-
const exiting = /* @__PURE__ */ new Set();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
isMounted.current = true;
|
|
99
|
-
return () => {
|
|
100
|
-
isMounted.current = false;
|
|
101
|
-
isInitialRender.current = true;
|
|
102
|
-
allChildren.clear();
|
|
103
|
-
exiting.clear();
|
|
104
|
-
};
|
|
105
|
-
}, []);
|
|
106
|
-
(0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
107
|
-
isInitialRender.current = false;
|
|
108
|
-
updateChildLookup(filteredChildren, allChildren);
|
|
109
|
-
presentChildren.current = childrenToRender;
|
|
64
|
+
const exiting = /* @__PURE__ */ new Set(), presentChildren = (0, import_react.useRef)(childrenToRender), allChildren = (0, import_react.useRef)(/* @__PURE__ */ new Map()).current, isInitialRender = (0, import_react.useRef)(!0);
|
|
65
|
+
(0, import_react.useEffect)(() => (isMounted.current = !0, () => {
|
|
66
|
+
isMounted.current = !1, isInitialRender.current = !0, allChildren.clear(), exiting.clear();
|
|
67
|
+
}), []), (0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
68
|
+
isInitialRender.current = !1, updateChildLookup(filteredChildren, allChildren), presentChildren.current = childrenToRender;
|
|
110
69
|
});
|
|
111
|
-
const hasWarned = process.env.NODE_ENV === "development" ? (0, import_react.useRef)(
|
|
112
|
-
if (isInitialRender.current)
|
|
70
|
+
const hasWarned = process.env.NODE_ENV === "development" ? (0, import_react.useRef)(!1) : null;
|
|
71
|
+
if (isInitialRender.current)
|
|
113
72
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: childrenToRender.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
114
73
|
import_PresenceChild.PresenceChild,
|
|
115
74
|
{
|
|
116
|
-
isPresent:
|
|
75
|
+
isPresent: !!(isClientMounted || isMounted.current),
|
|
117
76
|
enterExitVariant,
|
|
118
77
|
exitVariant,
|
|
119
78
|
enterVariant,
|
|
120
|
-
initial: initial ? void 0 :
|
|
79
|
+
initial: initial ? void 0 : !1,
|
|
121
80
|
presenceAffectsLayout,
|
|
122
81
|
children: child
|
|
123
82
|
},
|
|
124
83
|
getChildKey(child)
|
|
125
84
|
)) });
|
|
126
|
-
}
|
|
127
85
|
childrenToRender = [...childrenToRender];
|
|
128
|
-
const presentKeys = presentChildren.current.map(getChildKey);
|
|
129
|
-
const targetKeys = filteredChildren.map(getChildKey);
|
|
130
|
-
const numPresent = presentKeys.length;
|
|
86
|
+
const presentKeys = presentChildren.current.map(getChildKey), targetKeys = filteredChildren.map(getChildKey), numPresent = presentKeys.length;
|
|
131
87
|
for (let i = 0; i < numPresent; i++) {
|
|
132
88
|
const key = presentKeys[i];
|
|
133
|
-
|
|
134
|
-
exiting.add(key);
|
|
135
|
-
}
|
|
89
|
+
targetKeys.indexOf(key) === -1 && exiting.add(key);
|
|
136
90
|
}
|
|
137
|
-
|
|
138
|
-
childrenToRender = [];
|
|
139
|
-
}
|
|
140
|
-
exiting.forEach((key) => {
|
|
91
|
+
return exitBeforeEnter && exiting.size && (childrenToRender = []), exiting.forEach((key) => {
|
|
141
92
|
if (targetKeys.indexOf(key) !== -1)
|
|
142
93
|
return;
|
|
143
94
|
const child = allChildren.get(key);
|
|
@@ -150,20 +101,16 @@ const AnimatePresence = ({
|
|
|
150
101
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
102
|
import_PresenceChild.PresenceChild,
|
|
152
103
|
{
|
|
153
|
-
isPresent:
|
|
104
|
+
isPresent: !1,
|
|
154
105
|
onExitComplete: () => {
|
|
155
|
-
allChildren.delete(key);
|
|
156
|
-
exiting.delete(key);
|
|
106
|
+
allChildren.delete(key), exiting.delete(key);
|
|
157
107
|
const removeIndex = presentChildren.current.findIndex(
|
|
158
108
|
(presentChild) => presentChild.key === key
|
|
159
109
|
);
|
|
160
|
-
presentChildren.current.splice(removeIndex, 1)
|
|
161
|
-
|
|
162
|
-
presentChildren.current = filteredChildren;
|
|
163
|
-
if (isMounted.current === false)
|
|
110
|
+
if (presentChildren.current.splice(removeIndex, 1), !exiting.size) {
|
|
111
|
+
if (presentChildren.current = filteredChildren, isMounted.current === !1)
|
|
164
112
|
return;
|
|
165
|
-
forceRender();
|
|
166
|
-
onExitComplete == null ? void 0 : onExitComplete();
|
|
113
|
+
forceRender(), onExitComplete?.();
|
|
167
114
|
}
|
|
168
115
|
},
|
|
169
116
|
exitVariant,
|
|
@@ -175,13 +122,12 @@ const AnimatePresence = ({
|
|
|
175
122
|
getChildKey(child)
|
|
176
123
|
)
|
|
177
124
|
);
|
|
178
|
-
})
|
|
179
|
-
childrenToRender = childrenToRender.map((child) => {
|
|
125
|
+
}), childrenToRender = childrenToRender.map((child) => {
|
|
180
126
|
const key = child.key;
|
|
181
127
|
return exiting.has(key) ? child : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
182
128
|
import_PresenceChild.PresenceChild,
|
|
183
129
|
{
|
|
184
|
-
isPresent:
|
|
130
|
+
isPresent: !0,
|
|
185
131
|
exitVariant,
|
|
186
132
|
enterVariant,
|
|
187
133
|
enterExitVariant,
|
|
@@ -190,8 +136,7 @@ const AnimatePresence = ({
|
|
|
190
136
|
},
|
|
191
137
|
getChildKey(child)
|
|
192
138
|
);
|
|
193
|
-
});
|
|
194
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: exiting.size ? childrenToRender : childrenToRender.map((child) => (0, import_react.cloneElement)(child)) });
|
|
139
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: exiting.size ? childrenToRender : childrenToRender.map((child) => (0, import_react.cloneElement)(child)) });
|
|
195
140
|
};
|
|
196
141
|
AnimatePresence.displayName = "AnimatePresence";
|
|
197
142
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AnimatePresence.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA+B,sCAC/B,aAA2D,yBAC3D,eASO,2BAEP,4BAAmC,iCACnC,uBAA8B,4BAkJxB;AA7IN,MAAM,cAAc,CA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AAO,GAAG,GACtB,QAAQ,OAAO,GAAG;AAGlB,kBAAM,cAAc,gBAAgB,QAAQ;AAAA,cAC1C,CAAC,iBAAiB,aAAa,QAAQ;AAAA,YACzC;AAIA,gBAHA,gBAAgB,QAAQ,OAAO,aAAa,CAAC,GAGzC,CAAC,QAAQ,MAAM;AAGjB,kBAFA,gBAAgB,UAAU,kBAEtB,UAAU,YAAY;AAAO;AAEjC,0BAAY,GACZ,iBAAiB;AAAA,YACnB;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,QA3BI,YAAY,KAAK;AAAA,MA4BxB;AAAA,IACF;AAAA,EACF,CAAC,GAID,mBAAmB,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,QACA;AAAA,QAEC;AAAA;AAAA,MAPI,YAAY,KAAK;AAAA,IAQxB;AAAA,EAEJ,CAAC,GAGC,2EACG,kBAAQ,OACL,mBACA,iBAAiB,IAAI,CAAC,cAAU,2BAAa,KAAK,CAAC,GACzD;AAEJ;AAEA,gBAAgB,cAAc;",
|
|
5
5
|
"names": ["React"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,147 @@
|
|
|
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, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
+
var AnimatePresence_exports = {};
|
|
25
|
+
__export(AnimatePresence_exports, {
|
|
26
|
+
AnimatePresence: () => AnimatePresence
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(AnimatePresence_exports);
|
|
29
|
+
var import_use_force_update = require("@tamagui/use-force-update"), import_web = require("@tamagui/web"), import_react = __toESM(require("react")), import_LayoutGroupContext = require("./LayoutGroupContext"), import_PresenceChild = require("./PresenceChild"), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
const getChildKey = (child) => child.key || "", isDev = process.env.NODE_ENV !== "production";
|
|
31
|
+
function updateChildLookup(children, allChildren) {
|
|
32
|
+
const seenChildren = isDev ? /* @__PURE__ */ new Set() : null;
|
|
33
|
+
children.forEach((child) => {
|
|
34
|
+
const key = getChildKey(child);
|
|
35
|
+
isDev && seenChildren && seenChildren.has(key) && (console.warn(
|
|
36
|
+
`Children of AnimatePresence require unique keys. "${key}" is a duplicate.`
|
|
37
|
+
), seenChildren.add(key)), allChildren.set(key, child);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function onlyElements(children) {
|
|
41
|
+
const filtered = [];
|
|
42
|
+
return import_react.Children.forEach(children, (child, index) => {
|
|
43
|
+
(0, import_react.isValidElement)(child) && (!child.key && import_react.Children.count(children) > 1 ? (process.env.NODE_ENV === "development" && console.warn("No key given to AnimatePresence child, assigning index as key"), filtered.push(
|
|
44
|
+
import_react.default.cloneElement(child, {
|
|
45
|
+
key: index
|
|
46
|
+
})
|
|
47
|
+
)) : filtered.push(child));
|
|
48
|
+
}), filtered;
|
|
49
|
+
}
|
|
50
|
+
const AnimatePresence = ({
|
|
51
|
+
children,
|
|
52
|
+
enterVariant,
|
|
53
|
+
exitVariant,
|
|
54
|
+
enterExitVariant,
|
|
55
|
+
initial = !0,
|
|
56
|
+
onExitComplete,
|
|
57
|
+
exitBeforeEnter,
|
|
58
|
+
presenceAffectsLayout = !0
|
|
59
|
+
}) => {
|
|
60
|
+
let forceRender = (0, import_use_force_update.useForceUpdate)();
|
|
61
|
+
const isClientMounted = (0, import_web.useDidFinishSSR)(), forceRenderLayoutGroup = (0, import_react.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender;
|
|
62
|
+
forceRenderLayoutGroup && (forceRender = forceRenderLayoutGroup);
|
|
63
|
+
const isMounted = (0, import_react.useRef)(!1), filteredChildren = onlyElements(children);
|
|
64
|
+
let childrenToRender = filteredChildren;
|
|
65
|
+
const exiting = /* @__PURE__ */ new Set(), presentChildren = (0, import_react.useRef)(childrenToRender), allChildren = (0, import_react.useRef)(/* @__PURE__ */ new Map()).current, isInitialRender = (0, import_react.useRef)(!0);
|
|
66
|
+
(0, import_react.useEffect)(() => (isMounted.current = !0, () => {
|
|
67
|
+
isMounted.current = !1, isInitialRender.current = !0, allChildren.clear(), exiting.clear();
|
|
68
|
+
}), []), (0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
69
|
+
isInitialRender.current = !1, updateChildLookup(filteredChildren, allChildren), presentChildren.current = childrenToRender;
|
|
70
|
+
});
|
|
71
|
+
const hasWarned = process.env.NODE_ENV === "development" ? (0, import_react.useRef)(!1) : null;
|
|
72
|
+
if (isInitialRender.current)
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: childrenToRender.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
import_PresenceChild.PresenceChild,
|
|
75
|
+
{
|
|
76
|
+
isPresent: !!(isClientMounted || isMounted.current),
|
|
77
|
+
enterExitVariant,
|
|
78
|
+
exitVariant,
|
|
79
|
+
enterVariant,
|
|
80
|
+
initial: initial ? void 0 : !1,
|
|
81
|
+
presenceAffectsLayout,
|
|
82
|
+
children: child
|
|
83
|
+
},
|
|
84
|
+
getChildKey(child)
|
|
85
|
+
)) });
|
|
86
|
+
childrenToRender = [...childrenToRender];
|
|
87
|
+
const presentKeys = presentChildren.current.map(getChildKey), targetKeys = filteredChildren.map(getChildKey), numPresent = presentKeys.length;
|
|
88
|
+
for (let i = 0; i < numPresent; i++) {
|
|
89
|
+
const key = presentKeys[i];
|
|
90
|
+
targetKeys.indexOf(key) === -1 && exiting.add(key);
|
|
91
|
+
}
|
|
92
|
+
return exitBeforeEnter && exiting.size && (childrenToRender = []), exiting.forEach((key) => {
|
|
93
|
+
if (targetKeys.indexOf(key) !== -1)
|
|
94
|
+
return;
|
|
95
|
+
const child = allChildren.get(key);
|
|
96
|
+
if (!child)
|
|
97
|
+
return;
|
|
98
|
+
const insertionIndex = presentKeys.indexOf(key);
|
|
99
|
+
childrenToRender.splice(
|
|
100
|
+
insertionIndex,
|
|
101
|
+
0,
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
103
|
+
import_PresenceChild.PresenceChild,
|
|
104
|
+
{
|
|
105
|
+
isPresent: !1,
|
|
106
|
+
onExitComplete: () => {
|
|
107
|
+
allChildren.delete(key), exiting.delete(key);
|
|
108
|
+
const removeIndex = presentChildren.current.findIndex(
|
|
109
|
+
(presentChild) => presentChild.key === key
|
|
110
|
+
);
|
|
111
|
+
if (presentChildren.current.splice(removeIndex, 1), !exiting.size) {
|
|
112
|
+
if (presentChildren.current = filteredChildren, isMounted.current === !1)
|
|
113
|
+
return;
|
|
114
|
+
forceRender(), onExitComplete?.();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
exitVariant,
|
|
118
|
+
enterVariant,
|
|
119
|
+
enterExitVariant,
|
|
120
|
+
presenceAffectsLayout,
|
|
121
|
+
children: child
|
|
122
|
+
},
|
|
123
|
+
getChildKey(child)
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
}), childrenToRender = childrenToRender.map((child) => {
|
|
127
|
+
const key = child.key;
|
|
128
|
+
return exiting.has(key) ? child : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
129
|
+
import_PresenceChild.PresenceChild,
|
|
130
|
+
{
|
|
131
|
+
isPresent: !0,
|
|
132
|
+
exitVariant,
|
|
133
|
+
enterVariant,
|
|
134
|
+
enterExitVariant,
|
|
135
|
+
presenceAffectsLayout,
|
|
136
|
+
children: child
|
|
137
|
+
},
|
|
138
|
+
getChildKey(child)
|
|
139
|
+
);
|
|
140
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: exiting.size ? childrenToRender : childrenToRender.map((child) => (0, import_react.cloneElement)(child)) });
|
|
141
|
+
};
|
|
142
|
+
AnimatePresence.displayName = "AnimatePresence";
|
|
143
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
+
0 && (module.exports = {
|
|
145
|
+
AnimatePresence
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=AnimatePresence.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/AnimatePresence.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAA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,GAAG;AAE9C,qBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UAEC,WAAW;AAAA,UACX,gBAAgB,MAAM;AACpB,wBAAY,OAAO,GAAG,GACtB,QAAQ,OAAO,GAAG;AAGlB,kBAAM,cAAc,gBAAgB,QAAQ;AAAA,cAC1C,CAAC,iBAAiB,aAAa,QAAQ;AAAA,YACzC;AAIA,gBAHA,gBAAgB,QAAQ,OAAO,aAAa,CAAC,GAGzC,CAAC,QAAQ,MAAM;AAGjB,kBAFA,gBAAgB,UAAU,kBAEtB,UAAU,YAAY;AAAO;AAEjC,0BAAY,GACZ,iBAAiB;AAAA,YACnB;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,QA3BI,YAAY,KAAK;AAAA,MA4BxB;AAAA,IACF;AAAA,EACF,CAAC,GAID,mBAAmB,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,QACA;AAAA,QAEC;AAAA;AAAA,MAPI,YAAY,KAAK;AAAA,IAQxB;AAAA,EAEJ,CAAC,GAGC,2EACG,kBAAQ,OACL,mBACA,iBAAiB,IAAI,CAAC,cAAU,2BAAa,KAAK,CAAC,GACzD;AAEJ;AAEA,gBAAgB,cAAc;",
|
|
5
|
+
"names": ["React"]
|
|
6
|
+
}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
10
|
for (let key of __getOwnPropNames(from))
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
12
|
return to;
|
|
17
13
|
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
19
15
|
var LayoutGroupContext_exports = {};
|
|
20
16
|
__export(LayoutGroupContext_exports, {
|
|
21
17
|
LayoutGroupContext: () => LayoutGroupContext
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/LayoutGroupContext.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAOvB,MAAM,yBAAqB,4BAAuC,CAAC,CAAC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var LayoutGroupContext_exports = {};
|
|
17
|
+
__export(LayoutGroupContext_exports, {
|
|
18
|
+
LayoutGroupContext: () => LayoutGroupContext
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(LayoutGroupContext_exports);
|
|
21
|
+
var import_react = require("react");
|
|
22
|
+
const LayoutGroupContext = (0, import_react.createContext)({});
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
LayoutGroupContext
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=LayoutGroupContext.js.map
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,20 +17,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var PresenceChild_exports = {};
|
|
30
24
|
__export(PresenceChild_exports, {
|
|
31
25
|
PresenceChild: () => PresenceChild
|
|
32
26
|
});
|
|
33
27
|
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 import_web = require("@tamagui/web");
|
|
37
|
-
var React = __toESM(require("react"));
|
|
38
|
-
var import_react = require("react");
|
|
28
|
+
var import_use_presence = require("@tamagui/use-presence"), import_web = require("@tamagui/web"), React = __toESM(require("react")), import_react = require("react"), import_jsx_runtime = require("react/jsx-runtime");
|
|
39
29
|
const PresenceChild = ({
|
|
40
30
|
children,
|
|
41
31
|
initial,
|
|
@@ -46,32 +36,23 @@ const PresenceChild = ({
|
|
|
46
36
|
enterExitVariant,
|
|
47
37
|
presenceAffectsLayout
|
|
48
38
|
}) => {
|
|
49
|
-
const presenceChildren = React.useMemo(newChildrenMap, [])
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
onExitComplete == null ? void 0 : onExitComplete();
|
|
68
|
-
},
|
|
69
|
-
register: (id2) => {
|
|
70
|
-
presenceChildren.set(id2, false);
|
|
71
|
-
return () => presenceChildren.delete(id2);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
},
|
|
39
|
+
const presenceChildren = React.useMemo(newChildrenMap, []), id = (0, import_react.useId)() || "", context = React.useMemo(
|
|
40
|
+
() => ({
|
|
41
|
+
id,
|
|
42
|
+
initial,
|
|
43
|
+
isPresent,
|
|
44
|
+
exitVariant,
|
|
45
|
+
enterVariant,
|
|
46
|
+
enterExitVariant,
|
|
47
|
+
onExitComplete: (id2) => {
|
|
48
|
+
presenceChildren.set(id2, !0);
|
|
49
|
+
for (const isComplete of presenceChildren.values())
|
|
50
|
+
if (!isComplete)
|
|
51
|
+
return;
|
|
52
|
+
onExitComplete?.();
|
|
53
|
+
},
|
|
54
|
+
register: (id2) => (presenceChildren.set(id2, !1), () => presenceChildren.delete(id2))
|
|
55
|
+
}),
|
|
75
56
|
/**
|
|
76
57
|
* If the presence of a child affects the layout of the components around it,
|
|
77
58
|
* we want to make a new context value to ensure they get re-rendered
|
|
@@ -80,13 +61,11 @@ const PresenceChild = ({
|
|
|
80
61
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
62
|
presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]
|
|
82
63
|
);
|
|
83
|
-
React.useMemo(() => {
|
|
84
|
-
presenceChildren.forEach((_, key) => presenceChildren.set(key,
|
|
85
|
-
}, [isPresent])
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}, [isPresent]);
|
|
89
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, { value: context, children });
|
|
64
|
+
return React.useMemo(() => {
|
|
65
|
+
presenceChildren.forEach((_, key) => presenceChildren.set(key, !1));
|
|
66
|
+
}, [isPresent]), (0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
67
|
+
!(isPresent || presenceChildren.size) && onExitComplete?.();
|
|
68
|
+
}, [isPresent]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, { value: context, children });
|
|
90
69
|
};
|
|
91
70
|
function newChildrenMap() {
|
|
92
71
|
return /* @__PURE__ */ new Map();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/PresenceChild.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC,kCAChC,aAAgE,yBAChE,QAAuB,2BACvB,eAAsB,kBA4Eb;AA5DF,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,mBAAmB,MAAM,QAAQ,gBAAgB,CAAC,CAAC,GACnD,SAAK,oBAAM,KAAK,IAEhB,UAAU,MAAM;AAAA,IACpB,OACS;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB,CAACA,QAAe;AAC9B,yBAAiB,IAAIA,KAAI,EAAI;AAC7B,mBAAW,cAAc,iBAAiB,OAAO;AAC/C,cAAI,CAAC;AACH;AAGJ,yBAAiB;AAAA,MACnB;AAAA,MACA,UAAU,CAACA,SACT,iBAAiB,IAAIA,KAAI,EAAK,GACvB,MAAM,iBAAiB,OAAOA,GAAE;AAAA,IAE3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQF,wBAAwB,SAAY,CAAC,WAAW,aAAa,YAAY;AAAA,EAC3E;AAEA,eAAM,QAAQ,MAAM;AAClB,qBAAiB,QAAQ,CAAC,GAAG,QAAQ,iBAAiB,IAAI,KAAK,EAAK,CAAC;AAAA,EAEvE,GAAG,CAAC,SAAS,CAAC,OAMd,sCAA0B,MAAM;AAC9B,MAAE,aAAa,iBAAiB,SAAS,iBAAiB;AAAA,EAE5D,GAAG,CAAC,SAAS,CAAC,GAEP,4CAAC,oCAAgB,UAAhB,EAAyB,OAAO,SAAU,UAAS;AAC7D;AAEA,SAAS,iBAAuC;AAC9C,SAAO,oBAAI,IAAI;AACjB;",
|
|
5
5
|
"names": ["id"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
+
var PresenceChild_exports = {};
|
|
25
|
+
__export(PresenceChild_exports, {
|
|
26
|
+
PresenceChild: () => PresenceChild
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(PresenceChild_exports);
|
|
29
|
+
var import_use_presence = require("@tamagui/use-presence"), import_web = require("@tamagui/web"), React = __toESM(require("react")), import_react = require("react"), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
const PresenceChild = ({
|
|
31
|
+
children,
|
|
32
|
+
initial,
|
|
33
|
+
isPresent,
|
|
34
|
+
onExitComplete,
|
|
35
|
+
exitVariant,
|
|
36
|
+
enterVariant,
|
|
37
|
+
enterExitVariant,
|
|
38
|
+
presenceAffectsLayout
|
|
39
|
+
}) => {
|
|
40
|
+
const presenceChildren = React.useMemo(newChildrenMap, []), id = (0, import_react.useId)() || "", context = React.useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
id,
|
|
43
|
+
initial,
|
|
44
|
+
isPresent,
|
|
45
|
+
exitVariant,
|
|
46
|
+
enterVariant,
|
|
47
|
+
enterExitVariant,
|
|
48
|
+
onExitComplete: (id2) => {
|
|
49
|
+
presenceChildren.set(id2, !0);
|
|
50
|
+
for (const isComplete of presenceChildren.values())
|
|
51
|
+
if (!isComplete)
|
|
52
|
+
return;
|
|
53
|
+
onExitComplete?.();
|
|
54
|
+
},
|
|
55
|
+
register: (id2) => (presenceChildren.set(id2, !1), () => presenceChildren.delete(id2))
|
|
56
|
+
}),
|
|
57
|
+
/**
|
|
58
|
+
* If the presence of a child affects the layout of the components around it,
|
|
59
|
+
* we want to make a new context value to ensure they get re-rendered
|
|
60
|
+
* so they can detect that layout change.
|
|
61
|
+
*/
|
|
62
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
+
presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]
|
|
64
|
+
);
|
|
65
|
+
return React.useMemo(() => {
|
|
66
|
+
presenceChildren.forEach((_, key) => presenceChildren.set(key, !1));
|
|
67
|
+
}, [isPresent]), (0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
68
|
+
!(isPresent || presenceChildren.size) && onExitComplete?.();
|
|
69
|
+
}, [isPresent]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, { value: context, children });
|
|
70
|
+
};
|
|
71
|
+
function newChildrenMap() {
|
|
72
|
+
return /* @__PURE__ */ new Map();
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
PresenceChild
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=PresenceChild.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/PresenceChild.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA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
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
7
|
for (let key of __getOwnPropNames(from))
|
|
9
|
-
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
9
|
return to;
|
|
13
|
-
};
|
|
14
|
-
var
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
10
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
12
|
var src_exports = {};
|
|
17
13
|
module.exports = __toCommonJS(src_exports);
|
|
18
14
|
__reExport(src_exports, require("./AnimatePresence"), module.exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,kCADd;AAEA,wBAAc,oBAFd;AAGA,wBAAc,4BAHd;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
+
var src_exports = {};
|
|
14
|
+
module.exports = __toCommonJS(src_exports);
|
|
15
|
+
__reExport(src_exports, require("./AnimatePresence"), module.exports);
|
|
16
|
+
__reExport(src_exports, require("@tamagui/use-presence"), module.exports);
|
|
17
|
+
__reExport(src_exports, require("./types"), module.exports);
|
|
18
|
+
__reExport(src_exports, require("./PresenceChild"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./AnimatePresence"),
|
|
22
|
+
...require("@tamagui/use-presence"),
|
|
23
|
+
...require("./types"),
|
|
24
|
+
...require("./PresenceChild")
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
package/dist/cjs/types.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
7
|
for (let key of __getOwnPropNames(from))
|
|
9
|
-
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
9
|
return to;
|
|
13
10
|
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
12
|
var types_exports = {};
|
|
16
13
|
module.exports = __toCommonJS(types_exports);
|
|
17
14
|
//# sourceMappingURL=types.js.map
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
};
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
+
var types_exports = {};
|
|
14
|
+
module.exports = __toCommonJS(types_exports);
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
1
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
3
2
|
import { useDidFinishSSR, useIsomorphicLayoutEffect } from "@tamagui/web";
|
|
4
3
|
import React, {
|
|
@@ -11,107 +10,70 @@ import React, {
|
|
|
11
10
|
} from "react";
|
|
12
11
|
import { LayoutGroupContext } from "./LayoutGroupContext";
|
|
13
12
|
import { PresenceChild } from "./PresenceChild";
|
|
14
|
-
|
|
15
|
-
const isDev = process.env.NODE_ENV !== "production";
|
|
13
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
14
|
+
const getChildKey = (child) => child.key || "", isDev = process.env.NODE_ENV !== "production";
|
|
16
15
|
function updateChildLookup(children, allChildren) {
|
|
17
16
|
const seenChildren = isDev ? /* @__PURE__ */ new Set() : null;
|
|
18
17
|
children.forEach((child) => {
|
|
19
18
|
const key = getChildKey(child);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
seenChildren.add(key);
|
|
25
|
-
}
|
|
26
|
-
allChildren.set(key, child);
|
|
19
|
+
isDev && seenChildren && seenChildren.has(key) && (console.warn(
|
|
20
|
+
`Children of AnimatePresence require unique keys. "${key}" is a duplicate.`
|
|
21
|
+
), seenChildren.add(key)), allChildren.set(key, child);
|
|
27
22
|
});
|
|
28
23
|
}
|
|
29
24
|
function onlyElements(children) {
|
|
30
25
|
const filtered = [];
|
|
31
|
-
Children.forEach(children, (child, index) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
React.cloneElement(child, {
|
|
39
|
-
key: index
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
} else {
|
|
43
|
-
filtered.push(child);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return filtered;
|
|
26
|
+
return Children.forEach(children, (child, index) => {
|
|
27
|
+
isValidElement(child) && (!child.key && Children.count(children) > 1 ? (process.env.NODE_ENV === "development" && console.warn("No key given to AnimatePresence child, assigning index as key"), filtered.push(
|
|
28
|
+
React.cloneElement(child, {
|
|
29
|
+
key: index
|
|
30
|
+
})
|
|
31
|
+
)) : filtered.push(child));
|
|
32
|
+
}), filtered;
|
|
48
33
|
}
|
|
49
34
|
const AnimatePresence = ({
|
|
50
35
|
children,
|
|
51
36
|
enterVariant,
|
|
52
37
|
exitVariant,
|
|
53
38
|
enterExitVariant,
|
|
54
|
-
initial =
|
|
39
|
+
initial = !0,
|
|
55
40
|
onExitComplete,
|
|
56
41
|
exitBeforeEnter,
|
|
57
|
-
presenceAffectsLayout =
|
|
42
|
+
presenceAffectsLayout = !0
|
|
58
43
|
}) => {
|
|
59
44
|
let forceRender = useForceUpdate();
|
|
60
|
-
const isClientMounted = useDidFinishSSR();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
forceRender = forceRenderLayoutGroup;
|
|
64
|
-
const isMounted = useRef(false);
|
|
65
|
-
const filteredChildren = onlyElements(children);
|
|
45
|
+
const isClientMounted = useDidFinishSSR(), forceRenderLayoutGroup = useContext(LayoutGroupContext).forceRender;
|
|
46
|
+
forceRenderLayoutGroup && (forceRender = forceRenderLayoutGroup);
|
|
47
|
+
const isMounted = useRef(!1), filteredChildren = onlyElements(children);
|
|
66
48
|
let childrenToRender = filteredChildren;
|
|
67
|
-
const exiting = /* @__PURE__ */ new Set();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
isMounted.current = true;
|
|
73
|
-
return () => {
|
|
74
|
-
isMounted.current = false;
|
|
75
|
-
isInitialRender.current = true;
|
|
76
|
-
allChildren.clear();
|
|
77
|
-
exiting.clear();
|
|
78
|
-
};
|
|
79
|
-
}, []);
|
|
80
|
-
useIsomorphicLayoutEffect(() => {
|
|
81
|
-
isInitialRender.current = false;
|
|
82
|
-
updateChildLookup(filteredChildren, allChildren);
|
|
83
|
-
presentChildren.current = childrenToRender;
|
|
49
|
+
const exiting = /* @__PURE__ */ new Set(), presentChildren = useRef(childrenToRender), allChildren = useRef(/* @__PURE__ */ new Map()).current, isInitialRender = useRef(!0);
|
|
50
|
+
useEffect(() => (isMounted.current = !0, () => {
|
|
51
|
+
isMounted.current = !1, isInitialRender.current = !0, allChildren.clear(), exiting.clear();
|
|
52
|
+
}), []), useIsomorphicLayoutEffect(() => {
|
|
53
|
+
isInitialRender.current = !1, updateChildLookup(filteredChildren, allChildren), presentChildren.current = childrenToRender;
|
|
84
54
|
});
|
|
85
|
-
const hasWarned = process.env.NODE_ENV === "development" ? useRef(
|
|
86
|
-
if (isInitialRender.current)
|
|
55
|
+
const hasWarned = process.env.NODE_ENV === "development" ? useRef(!1) : null;
|
|
56
|
+
if (isInitialRender.current)
|
|
87
57
|
return /* @__PURE__ */ jsx(Fragment, { children: childrenToRender.map((child) => /* @__PURE__ */ jsx(
|
|
88
58
|
PresenceChild,
|
|
89
59
|
{
|
|
90
|
-
isPresent:
|
|
60
|
+
isPresent: !!(isClientMounted || isMounted.current),
|
|
91
61
|
enterExitVariant,
|
|
92
62
|
exitVariant,
|
|
93
63
|
enterVariant,
|
|
94
|
-
initial: initial ? void 0 :
|
|
64
|
+
initial: initial ? void 0 : !1,
|
|
95
65
|
presenceAffectsLayout,
|
|
96
66
|
children: child
|
|
97
67
|
},
|
|
98
68
|
getChildKey(child)
|
|
99
69
|
)) });
|
|
100
|
-
}
|
|
101
70
|
childrenToRender = [...childrenToRender];
|
|
102
|
-
const presentKeys = presentChildren.current.map(getChildKey);
|
|
103
|
-
const targetKeys = filteredChildren.map(getChildKey);
|
|
104
|
-
const numPresent = presentKeys.length;
|
|
71
|
+
const presentKeys = presentChildren.current.map(getChildKey), targetKeys = filteredChildren.map(getChildKey), numPresent = presentKeys.length;
|
|
105
72
|
for (let i = 0; i < numPresent; i++) {
|
|
106
73
|
const key = presentKeys[i];
|
|
107
|
-
|
|
108
|
-
exiting.add(key);
|
|
109
|
-
}
|
|
74
|
+
targetKeys.indexOf(key) === -1 && exiting.add(key);
|
|
110
75
|
}
|
|
111
|
-
|
|
112
|
-
childrenToRender = [];
|
|
113
|
-
}
|
|
114
|
-
exiting.forEach((key) => {
|
|
76
|
+
return exitBeforeEnter && exiting.size && (childrenToRender = []), exiting.forEach((key) => {
|
|
115
77
|
if (targetKeys.indexOf(key) !== -1)
|
|
116
78
|
return;
|
|
117
79
|
const child = allChildren.get(key);
|
|
@@ -124,20 +86,16 @@ const AnimatePresence = ({
|
|
|
124
86
|
/* @__PURE__ */ jsx(
|
|
125
87
|
PresenceChild,
|
|
126
88
|
{
|
|
127
|
-
isPresent:
|
|
89
|
+
isPresent: !1,
|
|
128
90
|
onExitComplete: () => {
|
|
129
|
-
allChildren.delete(key);
|
|
130
|
-
exiting.delete(key);
|
|
91
|
+
allChildren.delete(key), exiting.delete(key);
|
|
131
92
|
const removeIndex = presentChildren.current.findIndex(
|
|
132
93
|
(presentChild) => presentChild.key === key
|
|
133
94
|
);
|
|
134
|
-
presentChildren.current.splice(removeIndex, 1)
|
|
135
|
-
|
|
136
|
-
presentChildren.current = filteredChildren;
|
|
137
|
-
if (isMounted.current === false)
|
|
95
|
+
if (presentChildren.current.splice(removeIndex, 1), !exiting.size) {
|
|
96
|
+
if (presentChildren.current = filteredChildren, isMounted.current === !1)
|
|
138
97
|
return;
|
|
139
|
-
forceRender();
|
|
140
|
-
onExitComplete == null ? void 0 : onExitComplete();
|
|
98
|
+
forceRender(), onExitComplete?.();
|
|
141
99
|
}
|
|
142
100
|
},
|
|
143
101
|
exitVariant,
|
|
@@ -149,13 +107,12 @@ const AnimatePresence = ({
|
|
|
149
107
|
getChildKey(child)
|
|
150
108
|
)
|
|
151
109
|
);
|
|
152
|
-
})
|
|
153
|
-
childrenToRender = childrenToRender.map((child) => {
|
|
110
|
+
}), childrenToRender = childrenToRender.map((child) => {
|
|
154
111
|
const key = child.key;
|
|
155
112
|
return exiting.has(key) ? child : /* @__PURE__ */ jsx(
|
|
156
113
|
PresenceChild,
|
|
157
114
|
{
|
|
158
|
-
isPresent:
|
|
115
|
+
isPresent: !0,
|
|
159
116
|
exitVariant,
|
|
160
117
|
enterVariant,
|
|
161
118
|
enterExitVariant,
|
|
@@ -164,8 +121,7 @@ const AnimatePresence = ({
|
|
|
164
121
|
},
|
|
165
122
|
getChildKey(child)
|
|
166
123
|
);
|
|
167
|
-
});
|
|
168
|
-
return /* @__PURE__ */ jsx(Fragment, { children: exiting.size ? childrenToRender : childrenToRender.map((child) => cloneElement(child)) });
|
|
124
|
+
}), /* @__PURE__ */ jsx(Fragment, { children: exiting.size ? childrenToRender : childrenToRender.map((child) => cloneElement(child)) });
|
|
169
125
|
};
|
|
170
126
|
AnimatePresence.displayName = "AnimatePresence";
|
|
171
127
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AnimatePresence.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AAAA,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB,iCAAiC;AAC3D,OAAO;AAAA,EACL;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAkJxB,mBAEI,WAFJ;AA7IN,MAAM,cAAc,CAAC,UAA2C,MAAM,OAAO,IAEvE,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,IAAI,SAAS,gBAAgB,aAAa,IAAI,GAAG,MAC/C,QAAQ;AAAA,MACN,qDAAqD,GAAG;AAAA,IAC1D,GAEA,aAAa,IAAI,GAAG,IAGtB,YAAY,IAAI,KAAK,KAAK;AAAA,EAC5B,CAAC;AACH;AAEA,SAAS,aAAa,UAA0C;AA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,EACF,CAAC,GAID,mBAAmB,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,QACA;AAAA,QAEC;AAAA;AAAA,MAPI,YAAY,KAAK;AAAA,IAQxB;AAAA,EAEJ,CAAC,GAGC,gCACG,kBAAQ,OACL,mBACA,iBAAiB,IAAI,CAAC,UAAU,aAAa,KAAK,CAAC,GACzD;AAEJ;AAEA,gBAAgB,cAAc;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { PresenceContext } from "@tamagui/use-presence";
|
|
3
2
|
import { useIsomorphicLayoutEffect } from "@tamagui/web";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
import { useId } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
const PresenceChild = ({
|
|
7
7
|
children,
|
|
8
8
|
initial,
|
|
@@ -13,32 +13,23 @@ const PresenceChild = ({
|
|
|
13
13
|
enterExitVariant,
|
|
14
14
|
presenceAffectsLayout
|
|
15
15
|
}) => {
|
|
16
|
-
const presenceChildren = React.useMemo(newChildrenMap, [])
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
onExitComplete == null ? void 0 : onExitComplete();
|
|
35
|
-
},
|
|
36
|
-
register: (id2) => {
|
|
37
|
-
presenceChildren.set(id2, false);
|
|
38
|
-
return () => presenceChildren.delete(id2);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
},
|
|
16
|
+
const presenceChildren = React.useMemo(newChildrenMap, []), id = useId() || "", context = React.useMemo(
|
|
17
|
+
() => ({
|
|
18
|
+
id,
|
|
19
|
+
initial,
|
|
20
|
+
isPresent,
|
|
21
|
+
exitVariant,
|
|
22
|
+
enterVariant,
|
|
23
|
+
enterExitVariant,
|
|
24
|
+
onExitComplete: (id2) => {
|
|
25
|
+
presenceChildren.set(id2, !0);
|
|
26
|
+
for (const isComplete of presenceChildren.values())
|
|
27
|
+
if (!isComplete)
|
|
28
|
+
return;
|
|
29
|
+
onExitComplete?.();
|
|
30
|
+
},
|
|
31
|
+
register: (id2) => (presenceChildren.set(id2, !1), () => presenceChildren.delete(id2))
|
|
32
|
+
}),
|
|
42
33
|
/**
|
|
43
34
|
* If the presence of a child affects the layout of the components around it,
|
|
44
35
|
* we want to make a new context value to ensure they get re-rendered
|
|
@@ -47,13 +38,11 @@ const PresenceChild = ({
|
|
|
47
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
39
|
presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]
|
|
49
40
|
);
|
|
50
|
-
React.useMemo(() => {
|
|
51
|
-
presenceChildren.forEach((_, key) => presenceChildren.set(key,
|
|
52
|
-
}, [isPresent])
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}, [isPresent]);
|
|
56
|
-
return /* @__PURE__ */ jsx(PresenceContext.Provider, { value: context, children });
|
|
41
|
+
return React.useMemo(() => {
|
|
42
|
+
presenceChildren.forEach((_, key) => presenceChildren.set(key, !1));
|
|
43
|
+
}, [isPresent]), useIsomorphicLayoutEffect(() => {
|
|
44
|
+
!(isPresent || presenceChildren.size) && onExitComplete?.();
|
|
45
|
+
}, [isPresent]), /* @__PURE__ */ jsx(PresenceContext.Provider, { value: context, children });
|
|
57
46
|
};
|
|
58
47
|
function newChildrenMap() {
|
|
59
48
|
return /* @__PURE__ */ new Map();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
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6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/animate-presence",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.62.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@tamagui/use-force-update": "1.
|
|
17
|
-
"@tamagui/use-presence": "1.
|
|
18
|
-
"@tamagui/web": "1.
|
|
16
|
+
"@tamagui/use-force-update": "1.62.1",
|
|
17
|
+
"@tamagui/use-presence": "1.62.1",
|
|
18
|
+
"@tamagui/web": "1.62.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@tamagui/build": "1.
|
|
21
|
+
"@tamagui/build": "1.62.1"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tamagui-build",
|