@tamagui/animate-presence 1.96.0 → 1.97.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 +4 -1
- package/dist/cjs/AnimatePresence.js.map +1 -1
- package/dist/cjs/AnimatePresence.native.js +6 -3
- package/dist/cjs/AnimatePresence.native.js.map +1 -1
- package/dist/esm/AnimatePresence.js +4 -1
- package/dist/esm/AnimatePresence.js.map +1 -1
- package/dist/esm/AnimatePresence.mjs +3 -1
- package/dist/esm/AnimatePresence.native.js +6 -3
- package/dist/esm/AnimatePresence.native.js.map +1 -1
- package/package.json +7 -7
- package/src/AnimatePresence.tsx +148 -147
- package/src/PresenceChild.tsx +1 -1
- package/types/AnimatePresence.d.ts +2 -2
- package/types/AnimatePresence.d.ts.map +1 -1
|
@@ -109,7 +109,10 @@ const AnimatePresence = ({
|
|
|
109
109
|
},
|
|
110
110
|
getChildKey(child)
|
|
111
111
|
);
|
|
112
|
-
}), presentChildren.current = childrenToRender, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: exiting.size ? childrenToRender :
|
|
112
|
+
}), presentChildren.current = childrenToRender, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: exiting.size ? childrenToRender : (
|
|
113
|
+
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
|
|
114
|
+
childrenToRender.map((child) => (0, import_react.cloneElement)(child))
|
|
115
|
+
) });
|
|
113
116
|
};
|
|
114
117
|
AnimatePresence.displayName = "AnimatePresence";
|
|
115
118
|
//# sourceMappingURL=AnimatePresence.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AnimatePresence.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA+B,
|
|
4
|
+
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AAK;AAAA,IASxB;AAAA,EAEJ,CAAC,GAED,gBAAgB,UAAU,kBAGxB,2EACG,kBAAQ,OACL;AAAA;AAAA,IAEA,iBAAiB,IAAI,CAAC,cAAU,2BAAa,KAAK,CAAC;AAAA,KACzD;AAEJ;AAEF,gBAAgB,cAAc;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -123,9 +123,12 @@ var AnimatePresence = function(param) {
|
|
|
123
123
|
children: child
|
|
124
124
|
}, getChildKey(child));
|
|
125
125
|
}), presentChildren.current = childrenToRender, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
126
|
-
children: exiting.size ? childrenToRender :
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
children: exiting.size ? childrenToRender : (
|
|
127
|
+
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
|
|
128
|
+
childrenToRender.map(function(child) {
|
|
129
|
+
return /* @__PURE__ */ (0, import_react.cloneElement)(child);
|
|
130
|
+
})
|
|
131
|
+
)
|
|
129
132
|
});
|
|
130
133
|
};
|
|
131
134
|
AnimatePresence.displayName = "AnimatePresence";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/packages/animate-presence/src/AnimatePresence.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;uDAAA,0BAA+B,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;uDAAA,0BAA+B,sCAG/B,eAA2E,kBAE3E,4BAAmC,iCACnC,uBAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK9B,IAAMA,cAAc,SAACC,OAAAA;SAA2CA,MAAMC,OAAO;;AAE7E,SAASC,kBACPC,UACAC,aAAiD;AAEjDD,WAASE,QAAQ,SAACL,OAAAA;AAChB,QAAMC,MAAMF,YAAYC,KAAAA;AACxBI,gBAAYE,IAAIL,KAAKD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AYC,KAAAA,CAAAA;EAWvB,CAAA,GAEA0B,gBAAgBG,UAAUU,kBAGxB,uCAAAN,KAAA,mBAAAC,UAAA;cACGJ,QAAQkB,OACLT;;MAEAA,iBAAiBJ,IAAI,SAACnC,OAAAA;eAAU0D,+CAAa1D,KAAAA;;;;AAGvD;AAEFY,gBAAgB+C,cAAc;",
|
|
5
5
|
"names": ["getChildKey", "child", "key", "updateChildLookup", "children", "allChildren", "forEach", "set", "onlyElements", "filtered", "Children", "isValidElement", "push", "AnimatePresence", "enterVariant", "exitVariant", "enterExitVariant", "initial", "onExitComplete", "exitBeforeEnter", "presenceAffectsLayout", "custom", "useContext", "forceRender", "LayoutGroupContext", "useForceUpdate", "filteredChildren", "presentChildren", "useRef", "Map", "current", "exiting", "Set", "isInitialRender", "_jsx", "_Fragment", "map", "PresenceChild", "isPresent", "undefined", "childrenToRender", "presentKeys", "targetKeys", "numPresent", "length", "i", "indexOf", "add", "delete", "size", "get", "insertionIndex", "onExit", "removeIndex", "findIndex", "presentChild", "splice", "exitingComponent", "has", "cloneElement", "displayName"]
|
|
6
6
|
}
|
|
@@ -94,7 +94,10 @@ const AnimatePresence = ({
|
|
|
94
94
|
},
|
|
95
95
|
getChildKey(child)
|
|
96
96
|
);
|
|
97
|
-
}), presentChildren.current = childrenToRender, /* @__PURE__ */ jsx(Fragment, { children: exiting.size ? childrenToRender :
|
|
97
|
+
}), presentChildren.current = childrenToRender, /* @__PURE__ */ jsx(Fragment, { children: exiting.size ? childrenToRender : (
|
|
98
|
+
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
|
|
99
|
+
childrenToRender.map((child) => cloneElement(child))
|
|
100
|
+
) });
|
|
98
101
|
};
|
|
99
102
|
AnimatePresence.displayName = "AnimatePresence";
|
|
100
103
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AnimatePresence.tsx"],
|
|
4
|
-
"mappings": "AAAA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AEC;AAAA;AAAA,MARI,YAAY,KAAK;AAAA,IASxB;AAAA,EAEJ,CAAC,GAED,gBAAgB,UAAU,kBAGxB,gCACG,kBAAQ,OACL;AAAA;AAAA,IAEA,iBAAiB,IAAI,CAAC,UAAU,aAAa,KAAK,CAAC;AAAA,KACzD;AAEJ;AAEF,gBAAgB,cAAc;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -86,7 +86,9 @@ const AnimatePresence = ({
|
|
|
86
86
|
children: child
|
|
87
87
|
}, getChildKey(child));
|
|
88
88
|
}), presentChildren.current = childrenToRender, /* @__PURE__ */jsx(Fragment, {
|
|
89
|
-
children: exiting.size ? childrenToRender :
|
|
89
|
+
children: exiting.size ? childrenToRender :
|
|
90
|
+
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
|
|
91
|
+
childrenToRender.map(child => cloneElement(child))
|
|
90
92
|
});
|
|
91
93
|
};
|
|
92
94
|
AnimatePresence.displayName = "AnimatePresence";
|
|
@@ -107,9 +107,12 @@ var AnimatePresence = function(param) {
|
|
|
107
107
|
children: child
|
|
108
108
|
}, getChildKey(child));
|
|
109
109
|
}), presentChildren.current = childrenToRender, /* @__PURE__ */ _jsx(_Fragment, {
|
|
110
|
-
children: exiting.size ? childrenToRender :
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
children: exiting.size ? childrenToRender : (
|
|
111
|
+
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
|
|
112
|
+
childrenToRender.map(function(child) {
|
|
113
|
+
return /* @__PURE__ */ cloneElement(child);
|
|
114
|
+
})
|
|
115
|
+
)
|
|
113
116
|
});
|
|
114
117
|
};
|
|
115
118
|
AnimatePresence.displayName = "AnimatePresence";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/packages/animate-presence/src/AnimatePresence.tsx"],
|
|
4
|
-
"mappings": ";AAAA,SAASA,sBAAsB;
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AC;UACAM;oBAEClB;WATID,YAAYC,KAAAA,CAAAA;AAarB8B,yBAAiBgB,OAAOL,gBAAgB,GAAGM,gBAAAA;;;EAC7C,CAAA,GAIAjB,mBAAmBA,iBAAiBH,IAAI,SAAC3B,OAAAA;AACvC,QAAMC,OAAMD,MAAMC;AAClB,WAAOuB,QAAQwB,IAAI/C,IAAAA,IACjBD,QAEA,qBAACF,eAAAA;MAEC8B,WAAS;MACThB;MACAD;MACAE;MACAI;MACAC;gBAEClB;OARID,YAAYC,KAAAA,CAAAA;EAWvB,CAAA,GAEAqB,gBAAgBE,UAAUO,kBAGxB,qBAAA,WAAA;cACGN,QAAQe,OACLT;;MAEAA,iBAAiBH,IAAI,SAAC3B,OAAAA;eAAUP,6BAAaO,KAAAA;;;;AAGvD;AAEFU,gBAAgBuC,cAAc;",
|
|
5
5
|
"names": ["useForceUpdate", "Children", "cloneElement", "isValidElement", "useContext", "useRef", "LayoutGroupContext", "PresenceChild", "getChildKey", "child", "key", "updateChildLookup", "children", "allChildren", "forEach", "set", "onlyElements", "filtered", "push", "AnimatePresence", "enterVariant", "exitVariant", "enterExitVariant", "initial", "onExitComplete", "exitBeforeEnter", "presenceAffectsLayout", "custom", "forceRender", "filteredChildren", "presentChildren", "Map", "current", "exiting", "Set", "isInitialRender", "map", "isPresent", "undefined", "childrenToRender", "presentKeys", "targetKeys", "numPresent", "length", "i", "indexOf", "add", "delete", "size", "get", "insertionIndex", "onExit", "removeIndex", "findIndex", "presentChild", "splice", "exitingComponent", "has", "displayName"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/animate-presence",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.97.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@tamagui/helpers": "1.
|
|
17
|
-
"@tamagui/use-constant": "1.
|
|
18
|
-
"@tamagui/use-force-update": "1.
|
|
19
|
-
"@tamagui/use-presence": "1.
|
|
20
|
-
"@tamagui/web": "1.
|
|
16
|
+
"@tamagui/helpers": "1.97.1",
|
|
17
|
+
"@tamagui/use-constant": "1.97.1",
|
|
18
|
+
"@tamagui/use-force-update": "1.97.1",
|
|
19
|
+
"@tamagui/use-presence": "1.97.1",
|
|
20
|
+
"@tamagui/web": "1.97.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@tamagui/build": "1.
|
|
23
|
+
"@tamagui/build": "1.97.1"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tamagui-build",
|
package/src/AnimatePresence.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useForceUpdate } from '@tamagui/use-force-update'
|
|
2
2
|
import type { ReactElement, ReactNode } from 'react'
|
|
3
|
-
import
|
|
3
|
+
import type { FunctionComponent, PropsWithChildren } from 'react'
|
|
4
|
+
import { Children, cloneElement, isValidElement, useContext, useRef } from 'react'
|
|
4
5
|
|
|
5
6
|
import { LayoutGroupContext } from './LayoutGroupContext'
|
|
6
7
|
import { PresenceChild } from './PresenceChild'
|
|
@@ -62,161 +63,161 @@ function onlyElements(children: ReactNode): ReactElement<any>[] {
|
|
|
62
63
|
*
|
|
63
64
|
* @public
|
|
64
65
|
*/
|
|
65
|
-
export const AnimatePresence:
|
|
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
|
-
let childrenToRender = [...filteredChildren]
|
|
122
|
-
|
|
123
|
-
// Diff the keys of the currently-present and target children to update our
|
|
124
|
-
// exiting list.
|
|
125
|
-
const presentKeys = presentChildren.current.map(getChildKey)
|
|
126
|
-
const targetKeys = filteredChildren.map(getChildKey)
|
|
127
|
-
|
|
128
|
-
// Diff the present children with our target children and mark those that are exiting
|
|
129
|
-
const numPresent = presentKeys.length
|
|
130
|
-
for (let i = 0; i < numPresent; i++) {
|
|
131
|
-
const key = presentKeys[i]
|
|
132
|
-
if (targetKeys.indexOf(key) === -1) {
|
|
133
|
-
exiting.add(key)
|
|
134
|
-
} else {
|
|
135
|
-
// In case this key has re-entered, remove from the exiting list
|
|
136
|
-
exiting.delete(key)
|
|
66
|
+
export const AnimatePresence: FunctionComponent<PropsWithChildren<AnimatePresenceProps>> =
|
|
67
|
+
({
|
|
68
|
+
children,
|
|
69
|
+
enterVariant,
|
|
70
|
+
exitVariant,
|
|
71
|
+
enterExitVariant,
|
|
72
|
+
initial = true,
|
|
73
|
+
onExitComplete,
|
|
74
|
+
exitBeforeEnter,
|
|
75
|
+
presenceAffectsLayout = true,
|
|
76
|
+
custom,
|
|
77
|
+
}) => {
|
|
78
|
+
// We want to force a re-render once all exiting animations have finished. We
|
|
79
|
+
// either use a local forceRender function, or one from a parent context if it exists.
|
|
80
|
+
let forceRender = useContext(LayoutGroupContext).forceRender ?? useForceUpdate()
|
|
81
|
+
|
|
82
|
+
// Filter out any children that aren't ReactElements. We can only track ReactElements with a props.key
|
|
83
|
+
const filteredChildren = onlyElements(children)
|
|
84
|
+
|
|
85
|
+
// Keep a living record of the children we're actually rendering so we
|
|
86
|
+
// can diff to figure out which are entering and exiting
|
|
87
|
+
const presentChildren = useRef(filteredChildren)
|
|
88
|
+
|
|
89
|
+
// A lookup table to quickly reference components by key
|
|
90
|
+
const allChildren = useRef(new Map<ComponentKey, ReactElement<any>>()).current
|
|
91
|
+
|
|
92
|
+
const exiting = useRef(new Set<ComponentKey>()).current
|
|
93
|
+
updateChildLookup(filteredChildren, allChildren)
|
|
94
|
+
|
|
95
|
+
// If this is the initial component render, just deal with logic surrounding whether
|
|
96
|
+
// we play onMount animations or not.
|
|
97
|
+
const isInitialRender = useRef(true)
|
|
98
|
+
|
|
99
|
+
if (isInitialRender.current) {
|
|
100
|
+
isInitialRender.current = false
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
{filteredChildren.map((child) => (
|
|
104
|
+
<PresenceChild
|
|
105
|
+
key={getChildKey(child)}
|
|
106
|
+
isPresent
|
|
107
|
+
enterExitVariant={enterExitVariant}
|
|
108
|
+
exitVariant={exitVariant}
|
|
109
|
+
enterVariant={enterVariant}
|
|
110
|
+
initial={initial ? undefined : false}
|
|
111
|
+
presenceAffectsLayout={presenceAffectsLayout}
|
|
112
|
+
custom={custom}
|
|
113
|
+
>
|
|
114
|
+
{child}
|
|
115
|
+
</PresenceChild>
|
|
116
|
+
))}
|
|
117
|
+
</>
|
|
118
|
+
)
|
|
137
119
|
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// If we currently have exiting children, and we're deferring rendering incoming children
|
|
141
|
-
// until after all current children have exiting, empty the childrenToRender array
|
|
142
|
-
if (exitBeforeEnter && exiting.size) {
|
|
143
|
-
childrenToRender = []
|
|
144
|
-
}
|
|
145
120
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
//
|
|
150
|
-
|
|
121
|
+
let childrenToRender = [...filteredChildren]
|
|
122
|
+
|
|
123
|
+
// Diff the keys of the currently-present and target children to update our
|
|
124
|
+
// exiting list.
|
|
125
|
+
const presentKeys = presentChildren.current.map(getChildKey)
|
|
126
|
+
const targetKeys = filteredChildren.map(getChildKey)
|
|
127
|
+
|
|
128
|
+
// Diff the present children with our target children and mark those that are exiting
|
|
129
|
+
const numPresent = presentKeys.length
|
|
130
|
+
for (let i = 0; i < numPresent; i++) {
|
|
131
|
+
const key = presentKeys[i]
|
|
132
|
+
if (targetKeys.indexOf(key) === -1) {
|
|
133
|
+
exiting.add(key)
|
|
134
|
+
} else {
|
|
135
|
+
// In case this key has re-entered, remove from the exiting list
|
|
136
|
+
exiting.delete(key)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
151
139
|
|
|
152
|
-
|
|
153
|
-
|
|
140
|
+
// If we currently have exiting children, and we're deferring rendering incoming children
|
|
141
|
+
// until after all current children have exiting, empty the childrenToRender array
|
|
142
|
+
if (exitBeforeEnter && exiting.size) {
|
|
143
|
+
childrenToRender = []
|
|
144
|
+
}
|
|
154
145
|
|
|
155
|
-
|
|
146
|
+
// Loop through all currently exiting components and clone them to overwrite `animate`
|
|
147
|
+
// with any `exit` prop they might have defined.
|
|
148
|
+
exiting.forEach((key) => {
|
|
149
|
+
// If this component is actually entering again, early return
|
|
150
|
+
if (targetKeys.indexOf(key) !== -1) return
|
|
151
|
+
|
|
152
|
+
const child = allChildren.get(key)
|
|
153
|
+
if (!child) return
|
|
154
|
+
|
|
155
|
+
const insertionIndex = presentKeys.indexOf(key)
|
|
156
|
+
|
|
157
|
+
const onExit = () => {
|
|
158
|
+
allChildren.delete(key)
|
|
159
|
+
exiting.delete(key)
|
|
160
|
+
const removeIndex = presentChildren.current.findIndex(
|
|
161
|
+
(presentChild) => presentChild.key === key
|
|
162
|
+
)
|
|
163
|
+
presentChildren.current.splice(removeIndex, 1)
|
|
164
|
+
|
|
165
|
+
if (!exiting.size) {
|
|
166
|
+
presentChildren.current = filteredChildren
|
|
167
|
+
forceRender()
|
|
168
|
+
onExitComplete?.()
|
|
169
|
+
}
|
|
170
|
+
}
|
|
156
171
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
const exitingComponent = (
|
|
173
|
+
<PresenceChild
|
|
174
|
+
key={getChildKey(child)}
|
|
175
|
+
isPresent={false}
|
|
176
|
+
onExitComplete={onExit}
|
|
177
|
+
presenceAffectsLayout={presenceAffectsLayout}
|
|
178
|
+
enterExitVariant={enterExitVariant}
|
|
179
|
+
enterVariant={enterVariant}
|
|
180
|
+
exitVariant={exitVariant}
|
|
181
|
+
custom={custom}
|
|
182
|
+
>
|
|
183
|
+
{child}
|
|
184
|
+
</PresenceChild>
|
|
162
185
|
)
|
|
163
|
-
presentChildren.current.splice(removeIndex, 1)
|
|
164
186
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
childrenToRender.splice(insertionIndex, 0, exitingComponent)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
// Add `MotionContext` even to children that don't need it to ensure we're rendering
|
|
191
|
+
// the same tree between renders
|
|
192
|
+
childrenToRender = childrenToRender.map((child) => {
|
|
193
|
+
const key = child.key as ComponentKey
|
|
194
|
+
return exiting.has(key) ? (
|
|
195
|
+
child
|
|
196
|
+
) : (
|
|
197
|
+
<PresenceChild
|
|
198
|
+
key={getChildKey(child)}
|
|
199
|
+
isPresent
|
|
200
|
+
exitVariant={exitVariant}
|
|
201
|
+
enterVariant={enterVariant}
|
|
202
|
+
enterExitVariant={enterExitVariant}
|
|
203
|
+
presenceAffectsLayout={presenceAffectsLayout}
|
|
204
|
+
custom={custom}
|
|
205
|
+
>
|
|
206
|
+
{child}
|
|
207
|
+
</PresenceChild>
|
|
208
|
+
)
|
|
209
|
+
})
|
|
186
210
|
|
|
187
|
-
|
|
188
|
-
})
|
|
211
|
+
presentChildren.current = childrenToRender
|
|
189
212
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
<PresenceChild
|
|
198
|
-
key={getChildKey(child)}
|
|
199
|
-
isPresent
|
|
200
|
-
exitVariant={exitVariant}
|
|
201
|
-
enterVariant={enterVariant}
|
|
202
|
-
enterExitVariant={enterExitVariant}
|
|
203
|
-
presenceAffectsLayout={presenceAffectsLayout}
|
|
204
|
-
custom={custom}
|
|
205
|
-
>
|
|
206
|
-
{child}
|
|
207
|
-
</PresenceChild>
|
|
213
|
+
return (
|
|
214
|
+
<>
|
|
215
|
+
{exiting.size
|
|
216
|
+
? childrenToRender
|
|
217
|
+
: // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
|
|
218
|
+
childrenToRender.map((child) => cloneElement(child))}
|
|
219
|
+
</>
|
|
208
220
|
)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
presentChildren.current = childrenToRender
|
|
212
|
-
|
|
213
|
-
return (
|
|
214
|
-
<>
|
|
215
|
-
{exiting.size
|
|
216
|
-
? childrenToRender
|
|
217
|
-
: childrenToRender.map((child) => cloneElement(child))}
|
|
218
|
-
</>
|
|
219
|
-
)
|
|
220
|
-
}
|
|
221
|
+
}
|
|
221
222
|
|
|
222
223
|
AnimatePresence.displayName = 'AnimatePresence'
|
package/src/PresenceChild.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useConstant } from '@tamagui/use-constant'
|
|
2
2
|
import { PresenceContext } from '@tamagui/use-presence'
|
|
3
|
-
import {
|
|
3
|
+
import type { PresenceContextProps } from '@tamagui/web'
|
|
4
4
|
import * as React from 'react'
|
|
5
5
|
import { useId } from 'react'
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FunctionComponent, PropsWithChildren } from 'react';
|
|
2
2
|
import type { AnimatePresenceProps } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* `AnimatePresence` enables the animation of components that have been removed from the tree.
|
|
@@ -33,5 +33,5 @@ import type { AnimatePresenceProps } from './types';
|
|
|
33
33
|
*
|
|
34
34
|
* @public
|
|
35
35
|
*/
|
|
36
|
-
export declare const AnimatePresence:
|
|
36
|
+
export declare const AnimatePresence: FunctionComponent<PropsWithChildren<AnimatePresenceProps>>;
|
|
37
37
|
//# sourceMappingURL=AnimatePresence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimatePresence.d.ts","sourceRoot":"","sources":["../src/AnimatePresence.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"AnimatePresence.d.ts","sourceRoot":"","sources":["../src/AnimatePresence.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAKjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAyBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CA2JpF,CAAA"}
|