@tamagui/animate-presence 1.14.1 → 1.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cjs/AnimatePresence.js +204 -1
  2. package/dist/cjs/AnimatePresence.js.map +2 -2
  3. package/dist/cjs/LayoutGroupContext.js +29 -1
  4. package/dist/cjs/LayoutGroupContext.js.map +2 -2
  5. package/dist/cjs/PresenceChild.js +94 -1
  6. package/dist/cjs/PresenceChild.js.map +2 -2
  7. package/dist/cjs/index.js +19 -1
  8. package/dist/cjs/index.js.map +2 -2
  9. package/dist/cjs/types.js +16 -1
  10. package/dist/cjs/types.js.map +2 -2
  11. package/dist/esm/AnimatePresence.js +177 -1
  12. package/dist/esm/AnimatePresence.js.map +2 -2
  13. package/dist/esm/AnimatePresence.mjs +177 -1
  14. package/dist/esm/AnimatePresence.mjs.map +2 -2
  15. package/dist/esm/LayoutGroupContext.js +5 -1
  16. package/dist/esm/LayoutGroupContext.js.map +2 -2
  17. package/dist/esm/LayoutGroupContext.mjs +5 -1
  18. package/dist/esm/LayoutGroupContext.mjs.map +2 -2
  19. package/dist/esm/PresenceChild.js +60 -1
  20. package/dist/esm/PresenceChild.js.map +2 -2
  21. package/dist/esm/PresenceChild.mjs +60 -1
  22. package/dist/esm/PresenceChild.mjs.map +2 -2
  23. package/dist/esm/index.js +2 -1
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/index.mjs +2 -1
  26. package/dist/esm/index.mjs.map +1 -1
  27. package/dist/jsx/AnimatePresence.js +164 -1
  28. package/dist/jsx/AnimatePresence.js.map +2 -2
  29. package/dist/jsx/AnimatePresence.mjs +164 -1
  30. package/dist/jsx/AnimatePresence.mjs.map +2 -2
  31. package/dist/jsx/LayoutGroupContext.js +5 -1
  32. package/dist/jsx/LayoutGroupContext.js.map +2 -2
  33. package/dist/jsx/LayoutGroupContext.mjs +5 -1
  34. package/dist/jsx/LayoutGroupContext.mjs.map +2 -2
  35. package/dist/jsx/PresenceChild.js +59 -1
  36. package/dist/jsx/PresenceChild.js.map +2 -2
  37. package/dist/jsx/PresenceChild.mjs +59 -1
  38. package/dist/jsx/PresenceChild.mjs.map +2 -2
  39. package/dist/jsx/index.js +2 -1
  40. package/dist/jsx/index.js.map +1 -1
  41. package/dist/jsx/index.mjs +2 -1
  42. package/dist/jsx/index.mjs.map +1 -1
  43. package/package.json +4 -4
@@ -1,2 +1,205 @@
1
- "use strict";var S=Object.create;var E=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var q=(e,n)=>{for(var t in n)E(e,t,{get:n[t],enumerable:!0})},A=(e,n,t,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of _(n))!F.call(e,o)&&o!==t&&E(e,o,{get:()=>n[o],enumerable:!(c=W(n,o))||c.enumerable});return e};var G=(e,n,t)=>(t=e!=null?S(z(e)):{},A(n||!e||!e.__esModule?E(t,"default",{value:e,enumerable:!0}):t,e)),T=e=>A(E({},"__esModule",{value:!0}),e);var Y={};q(Y,{AnimatePresence:()=>w});module.exports=T(Y);var a=require("react/jsx-runtime"),f=require("@tamagui/web"),s=G(require("react")),V=require("./LayoutGroupContext"),C=require("./PresenceChild");const d=e=>e.key||"",O=process.env.NODE_ENV!=="production";function B(e,n){const t=O?new Set:null;e.forEach(c=>{const o=d(c);O&&t&&t.has(o)&&(console.warn(`Children of AnimatePresence require unique keys. "${o}" is a duplicate.`),t.add(o)),n.set(o,c)})}function U(e){const n=[];return s.Children.forEach(e,(t,c)=>{(0,s.isValidElement)(t)&&(t.key?n.push(t):(process.env.NODE_ENV==="development"&&console.warn("No key given to AnimatePresence child, assigning index as key"),n.push(s.default.cloneElement(t,{key:c}))))}),n}const w=({children:e,enterVariant:n,exitVariant:t,initial:c=!0,onExitComplete:o,exitBeforeEnter:N,presenceAffectsLayout:R=!0})=>{let k=(0,f.useForceUpdate)();const D=(0,f.useDidFinishSSR)(),K=(0,s.useContext)(V.LayoutGroupContext).forceRender;K&&(k=K);const p=(0,s.useRef)(!1),y=U(e);let i=y;const u=new Set,m=(0,s.useRef)(i),h=(0,s.useRef)(new Map).current,P=(0,s.useRef)(!0);(0,s.useEffect)(()=>(p.current=!0,()=>{p.current=!1,P.current=!0,h.clear(),u.clear()}),[]),(0,f.useIsomorphicLayoutEffect)(()=>{P.current=!1,B(y,h),m.current=i});const g=process.env.NODE_ENV==="development"?(0,s.useRef)(!1):null;if(P.current)return(0,a.jsx)(a.Fragment,{children:i.map(r=>(0,a.jsx)(C.PresenceChild,{isPresent:Boolean(D?!0:p.current),exitVariant:t,enterVariant:n,initial:c?void 0:!1,presenceAffectsLayout:R,children:r},d(r)))});i=[...i];const v=m.current.map(d),x=y.map(d),I=v.length;for(let r=0;r<I;r++){const l=v[r];x.indexOf(l)===-1&&u.add(l)}return N&&u.size&&(i=[]),u.forEach(r=>{if(x.indexOf(r)!==-1)return;const l=h.get(r);if(!l)return;const L=v.indexOf(r);i.splice(L,0,(0,a.jsx)(C.PresenceChild,{isPresent:!1,onExitComplete:()=>{h.delete(r),u.delete(r);const b=m.current.findIndex(M=>M.key===r);if(m.current.splice(b,1),!u.size){if(m.current=y,p.current===!1)return;k(),o==null||o()}},exitVariant:t,enterVariant:n,presenceAffectsLayout:R,children:l},d(l)))}),i=i.map(r=>{const l=r.key;return u.has(l)?r:(0,a.jsx)(C.PresenceChild,{isPresent:!0,exitVariant:t,enterVariant:n,presenceAffectsLayout:R,children:r},d(r))}),process.env.NODE_ENV==="development"&&N&&i.length>1&&g&&!g.current&&(g.current=!0,console.log("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This can lead to odd visual behaviour.")),(0,a.jsx)(a.Fragment,{children:u.size?i:i.map(r=>(0,s.cloneElement)(r))})};w.displayName="AnimatePresence";0&&(module.exports={AnimatePresence});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var AnimatePresence_exports = {};
30
+ __export(AnimatePresence_exports, {
31
+ AnimatePresence: () => AnimatePresence
32
+ });
33
+ module.exports = __toCommonJS(AnimatePresence_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_web = require("@tamagui/web");
36
+ var import_react = __toESM(require("react"));
37
+ var import_LayoutGroupContext = require("./LayoutGroupContext");
38
+ var import_PresenceChild = require("./PresenceChild");
39
+ const getChildKey = (child) => child.key || "";
40
+ const isDev = process.env.NODE_ENV !== "production";
41
+ function updateChildLookup(children, allChildren) {
42
+ const seenChildren = isDev ? /* @__PURE__ */ new Set() : null;
43
+ children.forEach((child) => {
44
+ const key = getChildKey(child);
45
+ if (isDev && seenChildren && seenChildren.has(key)) {
46
+ console.warn(
47
+ `Children of AnimatePresence require unique keys. "${key}" is a duplicate.`
48
+ );
49
+ seenChildren.add(key);
50
+ }
51
+ allChildren.set(key, child);
52
+ });
53
+ }
54
+ function onlyElements(children) {
55
+ const filtered = [];
56
+ import_react.Children.forEach(children, (child, index) => {
57
+ if ((0, import_react.isValidElement)(child)) {
58
+ if (!child.key) {
59
+ if (process.env.NODE_ENV === "development") {
60
+ console.warn("No key given to AnimatePresence child, assigning index as key");
61
+ }
62
+ filtered.push(
63
+ import_react.default.cloneElement(child, {
64
+ key: index
65
+ })
66
+ );
67
+ } else {
68
+ filtered.push(child);
69
+ }
70
+ }
71
+ });
72
+ return filtered;
73
+ }
74
+ const AnimatePresence = ({
75
+ children,
76
+ enterVariant,
77
+ exitVariant,
78
+ initial = true,
79
+ onExitComplete,
80
+ exitBeforeEnter,
81
+ presenceAffectsLayout = true
82
+ }) => {
83
+ let forceRender = (0, import_web.useForceUpdate)();
84
+ const isClientMounted = (0, import_web.useDidFinishSSR)();
85
+ const forceRenderLayoutGroup = (0, import_react.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender;
86
+ if (forceRenderLayoutGroup)
87
+ forceRender = forceRenderLayoutGroup;
88
+ const isMounted = (0, import_react.useRef)(false);
89
+ const filteredChildren = onlyElements(children);
90
+ let childrenToRender = filteredChildren;
91
+ const exiting = /* @__PURE__ */ new Set();
92
+ const presentChildren = (0, import_react.useRef)(childrenToRender);
93
+ const allChildren = (0, import_react.useRef)(/* @__PURE__ */ new Map()).current;
94
+ const isInitialRender = (0, import_react.useRef)(true);
95
+ (0, import_react.useEffect)(() => {
96
+ isMounted.current = true;
97
+ return () => {
98
+ isMounted.current = false;
99
+ isInitialRender.current = true;
100
+ allChildren.clear();
101
+ exiting.clear();
102
+ };
103
+ }, []);
104
+ (0, import_web.useIsomorphicLayoutEffect)(() => {
105
+ isInitialRender.current = false;
106
+ updateChildLookup(filteredChildren, allChildren);
107
+ presentChildren.current = childrenToRender;
108
+ });
109
+ const hasWarned = process.env.NODE_ENV === "development" ? (0, import_react.useRef)(false) : null;
110
+ if (isInitialRender.current) {
111
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: childrenToRender.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
112
+ import_PresenceChild.PresenceChild,
113
+ {
114
+ isPresent: Boolean(isClientMounted ? true : isMounted.current),
115
+ exitVariant,
116
+ enterVariant,
117
+ initial: initial ? void 0 : false,
118
+ presenceAffectsLayout,
119
+ children: child
120
+ },
121
+ getChildKey(child)
122
+ )) });
123
+ }
124
+ childrenToRender = [...childrenToRender];
125
+ const presentKeys = presentChildren.current.map(getChildKey);
126
+ const targetKeys = filteredChildren.map(getChildKey);
127
+ const numPresent = presentKeys.length;
128
+ for (let i = 0; i < numPresent; i++) {
129
+ const key = presentKeys[i];
130
+ if (targetKeys.indexOf(key) === -1) {
131
+ exiting.add(key);
132
+ }
133
+ }
134
+ if (exitBeforeEnter && exiting.size) {
135
+ childrenToRender = [];
136
+ }
137
+ exiting.forEach((key) => {
138
+ if (targetKeys.indexOf(key) !== -1)
139
+ return;
140
+ const child = allChildren.get(key);
141
+ if (!child)
142
+ return;
143
+ const insertionIndex = presentKeys.indexOf(key);
144
+ childrenToRender.splice(
145
+ insertionIndex,
146
+ 0,
147
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
148
+ import_PresenceChild.PresenceChild,
149
+ {
150
+ isPresent: false,
151
+ onExitComplete: () => {
152
+ allChildren.delete(key);
153
+ exiting.delete(key);
154
+ const removeIndex = presentChildren.current.findIndex(
155
+ (presentChild) => presentChild.key === key
156
+ );
157
+ presentChildren.current.splice(removeIndex, 1);
158
+ if (!exiting.size) {
159
+ presentChildren.current = filteredChildren;
160
+ if (isMounted.current === false)
161
+ return;
162
+ forceRender();
163
+ onExitComplete == null ? void 0 : onExitComplete();
164
+ }
165
+ },
166
+ exitVariant,
167
+ enterVariant,
168
+ presenceAffectsLayout,
169
+ children: child
170
+ },
171
+ getChildKey(child)
172
+ )
173
+ );
174
+ });
175
+ childrenToRender = childrenToRender.map((child) => {
176
+ const key = child.key;
177
+ return exiting.has(key) ? child : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
+ import_PresenceChild.PresenceChild,
179
+ {
180
+ isPresent: true,
181
+ exitVariant,
182
+ enterVariant,
183
+ presenceAffectsLayout,
184
+ children: child
185
+ },
186
+ getChildKey(child)
187
+ );
188
+ });
189
+ if (process.env.NODE_ENV === "development") {
190
+ const shouldWarn = exitBeforeEnter && childrenToRender.length > 1;
191
+ if (shouldWarn && hasWarned && !hasWarned.current) {
192
+ hasWarned.current = true;
193
+ console.log(
194
+ `You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This can lead to odd visual behaviour.`
195
+ );
196
+ }
197
+ }
198
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: exiting.size ? childrenToRender : childrenToRender.map((child) => (0, import_react.cloneElement)(child)) });
199
+ };
200
+ AnimatePresence.displayName = "AnimatePresence";
201
+ // Annotate the CommonJS export names for ESM import in node:
202
+ 0 && (module.exports = {
203
+ AnimatePresence
204
+ });
2
205
  //# sourceMappingURL=AnimatePresence.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/AnimatePresence.tsx"],
4
4
  "sourcesContent": ["import { useDidFinishSSR, useForceUpdate, useIsomorphicLayoutEffect } from '@tamagui/web'\nimport React, {\n Children,\n ReactElement,\n ReactNode,\n cloneElement,\n isValidElement,\n useContext,\n useEffect,\n useRef,\n} from 'react'\n\nimport { LayoutGroupContext } from './LayoutGroupContext'\nimport { PresenceChild } from './PresenceChild'\nimport { AnimatePresenceProps } from './types'\n\ntype ComponentKey = string | number\n\nconst getChildKey = (child: ReactElement<any>): ComponentKey => child.key || ''\n\nconst isDev = process.env.NODE_ENV !== 'production'\n\nfunction updateChildLookup(\n children: ReactElement<any>[],\n allChildren: Map<ComponentKey, ReactElement<any>>\n) {\n const seenChildren = isDev ? new Set<ComponentKey>() : null\n\n children.forEach((child) => {\n const key = getChildKey(child)\n\n if (isDev && seenChildren && seenChildren.has(key)) {\n // eslint-disable-next-line no-console\n console.warn(\n `Children of AnimatePresence require unique keys. \"${key}\" is a duplicate.`\n )\n\n seenChildren.add(key)\n }\n\n allChildren.set(key, child)\n })\n}\n\nfunction onlyElements(children: ReactNode): ReactElement<any>[] {\n const filtered: ReactElement<any>[] = []\n\n // We use forEach here instead of map as map mutates the component key by preprending `.$`\n Children.forEach(children, (child, index) => {\n if (isValidElement(child)) {\n if (!child.key) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No key given to AnimatePresence child, assigning index as key')\n }\n filtered.push(\n React.cloneElement(child, {\n key: index,\n })\n )\n } else {\n filtered.push(child)\n }\n }\n })\n\n return filtered\n}\n\n/**\n * `AnimatePresence` enables the animation of components that have been removed from the tree.\n *\n * When adding/removing more than a single child, every child **must** be given a unique `key` prop.\n *\n * Any `motion` components that have an `exit` property defined will animate out when removed from\n * the tree.\n *\n * ```tsx\n * import { motion, AnimatePresence } from 'framer-motion'\n *\n * export const Items = ({ items }) => (\n * <AnimatePresence>\n * {items.map(item => (\n * <motion.div\n * key={item.id}\n * initial={{ opacity: 0 }}\n * animate={{ opacity: 1 }}\n * exit={{ opacity: 0 }}\n * />\n * ))}\n * </AnimatePresence>\n * )\n * ```\n *\n * You can sequence exit animations throughout a tree using variants.\n *\n * If a child contains multiple `motion` components with `exit` props, it will only unmount the child\n * once all `motion` components have finished animating out. Likewise, any components using\n * `usePresence` all need to call `safeToRemove`.\n *\n * @public\n */\nexport const AnimatePresence: React.FunctionComponent<\n React.PropsWithChildren<AnimatePresenceProps>\n> = ({\n children,\n enterVariant,\n exitVariant,\n initial = true,\n onExitComplete,\n exitBeforeEnter,\n presenceAffectsLayout = true,\n}) => {\n // We want to force a re-render once all exiting animations have finished. We\n // either use a local forceRender function, or one from a parent context if it exists.\n let forceRender = useForceUpdate()\n const isClientMounted = useDidFinishSSR()\n const forceRenderLayoutGroup = useContext(LayoutGroupContext).forceRender\n if (forceRenderLayoutGroup) forceRender = forceRenderLayoutGroup\n\n const isMounted = useRef(false)\n\n // Filter out any children that aren't ReactElements. We can only track ReactElements with a props.key\n const filteredChildren = onlyElements(children)\n let childrenToRender = filteredChildren\n\n const exiting = new Set<ComponentKey>()\n\n // Keep a living record of the children we're actually rendering so we\n // can diff to figure out which are entering and exiting\n const presentChildren = useRef(childrenToRender)\n\n // A lookup table to quickly reference components by key\n const allChildren = useRef(new Map<ComponentKey, ReactElement<any>>()).current\n\n // If this is the initial component render, just deal with logic surrounding whether\n // we play onMount animations or not.\n const isInitialRender = useRef(true)\n\n useEffect(() => {\n isMounted.current = true\n return () => {\n isMounted.current = false\n isInitialRender.current = true\n allChildren.clear()\n exiting.clear()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false\n updateChildLookup(filteredChildren, allChildren)\n presentChildren.current = childrenToRender\n })\n\n const hasWarned = process.env.NODE_ENV === 'development' ? useRef(false) : null\n\n if (isInitialRender.current) {\n return (\n <>\n {childrenToRender.map((child) => (\n <PresenceChild\n key={getChildKey(child)}\n isPresent={Boolean(isClientMounted ? true : isMounted.current)}\n exitVariant={exitVariant}\n enterVariant={enterVariant}\n initial={initial ? undefined : false}\n presenceAffectsLayout={presenceAffectsLayout}\n >\n {child}\n </PresenceChild>\n ))}\n </>\n )\n }\n\n // If this is a subsequent render, deal with entering and exiting children\n childrenToRender = [...childrenToRender]\n\n // Diff the keys of the currently-present and target children to update our\n // exiting list.\n const presentKeys = presentChildren.current.map(getChildKey)\n const targetKeys = filteredChildren.map(getChildKey)\n\n // Diff the present children with our target children and mark those that are exiting\n const numPresent = presentKeys.length\n for (let i = 0; i < numPresent; i++) {\n const key = presentKeys[i]\n if (targetKeys.indexOf(key) === -1) {\n exiting.add(key)\n }\n }\n\n // If we currently have exiting children, and we're deferring rendering incoming children\n // until after all current children have exiting, empty the childrenToRender array\n if (exitBeforeEnter && exiting.size) {\n childrenToRender = []\n }\n\n // Loop through all currently exiting components and clone them to overwrite `animate`\n // with any `exit` prop they might have defined.\n exiting.forEach((key) => {\n // If this component is actually entering again, early return\n if (targetKeys.indexOf(key) !== -1) return\n\n const child = allChildren.get(key)\n if (!child) return\n\n const insertionIndex = presentKeys.indexOf(key)\n\n childrenToRender.splice(\n insertionIndex,\n 0,\n <PresenceChild\n key={getChildKey(child)}\n isPresent={false}\n onExitComplete={() => {\n allChildren.delete(key)\n exiting.delete(key)\n\n // Remove this child from the present children\n const removeIndex = presentChildren.current.findIndex(\n (presentChild) => presentChild.key === key\n )\n presentChildren.current.splice(removeIndex, 1)\n\n // Defer re-rendering until all exiting children have indeed left\n if (!exiting.size) {\n presentChildren.current = filteredChildren\n\n if (isMounted.current === false) return\n\n forceRender()\n onExitComplete?.()\n }\n }}\n exitVariant={exitVariant}\n enterVariant={enterVariant}\n presenceAffectsLayout={presenceAffectsLayout}\n >\n {child}\n </PresenceChild>\n )\n })\n\n // Add `MotionContext` even to children that don't need it to ensure we're rendering\n // the same tree between renders\n childrenToRender = childrenToRender.map((child) => {\n const key = child.key as string | number\n return exiting.has(key) ? (\n child\n ) : (\n <PresenceChild\n key={getChildKey(child)}\n isPresent\n exitVariant={exitVariant}\n enterVariant={enterVariant}\n presenceAffectsLayout={presenceAffectsLayout}\n >\n {child}\n </PresenceChild>\n )\n })\n\n if (process.env.NODE_ENV === 'development') {\n const shouldWarn = exitBeforeEnter && childrenToRender.length > 1\n if (shouldWarn && hasWarned && !hasWarned.current) {\n hasWarned.current = true\n // eslint-disable-next-line no-console\n console.log(\n `You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This can lead to odd visual behaviour.`\n )\n }\n }\n\n return (\n <>\n {exiting.size\n ? childrenToRender\n : childrenTo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AiBJ,EAAY,QAAQrB,CAAG,EAE9CgB,EAAiB,OACfS,EACA,KACA,OAAC,iBAEC,UAAW,GACX,eAAgB,IAAM,CACpB3B,EAAY,OAAOE,CAAG,EACtBiB,EAAQ,OAAOjB,CAAG,EAGlB,MAAM0B,EAAcR,EAAgB,QAAQ,UACzCS,GAAiBA,EAAa,MAAQ3B,CACzC,EAIA,GAHAkB,EAAgB,QAAQ,OAAOQ,EAAa,CAAC,EAGzC,CAACT,EAAQ,KAAM,CAGjB,GAFAC,EAAgB,QAAUH,EAEtBD,EAAU,UAAY,GAAO,OAEjCH,EAAY,EACZH,GAAA,MAAAA,GACF,CACF,EACA,YAAaF,EACb,aAAcD,EACd,sBAAuBK,EAEtB,SAAAhB,GA1BID,EAAYC,CAAK,CA2BxB,CACF,CACF,CAAC,EAIDsB,EAAmBA,EAAiB,IAAKtB,GAAU,CACjD,MAAMM,EAAMN,EAAM,IAClB,OAAOuB,EAAQ,IAAIjB,CAAG,EACpBN,KAEA,OAAC,iBAEC,UAAS,GACT,YAAaY,EACb,aAAcD,EACd,sBAAuBK,EAEtB,SAAAhB,GANID,EAAYC,CAAK,CAOxB,CAEJ,CAAC,EAEG,QAAQ,IAAI,WAAa,eACRe,GAAmBO,EAAiB,OAAS,GAC9CI,GAAa,CAACA,EAAU,UACxCA,EAAU,QAAU,GAEpB,QAAQ,IACN,4JACF,MAKF,mBACG,SAAAH,EAAQ,KACLD,EACAA,EAAiB,IAAKtB,MAAU,gBAAaA,CAAK,CAAC,EACzD,CAEJ,EAEAR,EAAgB,YAAc",
6
- "names": ["AnimatePresence_exports", "__export", "AnimatePresence", "__toCommonJS", "import_jsx_runtime", "import_web", "import_react", "import_LayoutGroupContext", "import_PresenceChild", "getChildKey", "child", "isDev", "updateChildLookup", "children", "allChildren", "seenChildren", "key", "onlyElements", "filtered", "index", "React", "enterVariant", "exitVariant", "initial", "onExitComplete", "exitBeforeEnter", "presenceAffectsLayout", "forceRender", "isClientMounted", "forceRenderLayoutGroup", "isMounted", "filteredChildren", "childrenToRender", "exiting", "presentChildren", "isInitialRender", "hasWarned", "presentKeys", "targetKeys", "numPresent", "i", "insertionIndex", "removeIndex", "presentChild"]
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgKM;AAhKN,iBAA2E;AAC3E,mBASO;AAEP,gCAAmC;AACnC,2BAA8B;AAK9B,MAAM,cAAc,CAAC,UAA2C,MAAM,OAAO;AAE7E,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,SAAS,kBACP,UACA,aACA;AACA,QAAM,eAAe,QAAQ,oBAAI,IAAkB,IAAI;AAEvD,WAAS,QAAQ,CAAC,UAAU;AAC1B,UAAM,MAAM,YAAY,KAAK;AAE7B,QAAI,SAAS,gBAAgB,aAAa,IAAI,GAAG,GAAG;AAElD,cAAQ;AAAA,QACN,qDAAqD;AAAA,MACvD;AAEA,mBAAa,IAAI,GAAG;AAAA,IACtB;AAEA,gBAAY,IAAI,KAAK,KAAK;AAAA,EAC5B,CAAC;AACH;AAEA,SAAS,aAAa,UAA0C;AAC9D,QAAM,WAAgC,CAAC;AAGvC,wBAAS,QAAQ,UAAU,CAAC,OAAO,UAAU;AAC3C,YAAI,6BAAe,KAAK,GAAG;AACzB,UAAI,CAAC,MAAM,KAAK;AACd,YAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,kBAAQ,KAAK,+DAA+D;AAAA,QAC9E;AACA,iBAAS;AAAA,UACP,aAAAA,QAAM,aAAa,OAAO;AAAA,YACxB,KAAK;AAAA,UACP,CAAC;AAAA,QACH;AAAA,MACF,OAAO;AACL,iBAAS,KAAK,KAAK;AAAA,MACrB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAmCO,MAAM,kBAET,CAAC;AAAA,EACH;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,wBAAwB;AAC1B,MAAM;AAG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AAU,SAAS;AACjD,gBAAU,UAAU;AAEpB,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SACE,2EACG,kBAAQ,OACL,mBACA,iBAAiB,IAAI,CAAC,cAAU,2BAAa,KAAK,CAAC,GACzD;AAEJ;AAEA,gBAAgB,cAAc;",
6
+ "names": ["React"]
7
7
  }
@@ -1,2 +1,30 @@
1
- "use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var c=(t,o)=>{for(var e in o)n(t,e,{get:o[e],enumerable:!0})},s=(t,o,e,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of x(o))!a.call(t,r)&&r!==e&&n(t,r,{get:()=>o[r],enumerable:!(p=i(o,r))||p.enumerable});return t};var C=t=>s(n({},"__esModule",{value:!0}),t);var f={};c(f,{LayoutGroupContext:()=>d});module.exports=C(f);var u=require("react");const d=(0,u.createContext)({});0&&(module.exports={LayoutGroupContext});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var LayoutGroupContext_exports = {};
20
+ __export(LayoutGroupContext_exports, {
21
+ LayoutGroupContext: () => LayoutGroupContext
22
+ });
23
+ module.exports = __toCommonJS(LayoutGroupContext_exports);
24
+ var import_react = require("react");
25
+ const LayoutGroupContext = (0, import_react.createContext)({});
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ LayoutGroupContext
29
+ });
2
30
  //# sourceMappingURL=LayoutGroupContext.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/LayoutGroupContext.tsx"],
4
4
  "sourcesContent": ["import { createContext } from 'react'\n\nexport interface LayoutGroupContextProps {\n id?: string\n forceRender?: VoidFunction\n}\n\nexport const LayoutGroupContext = createContext<LayoutGroupContextProps>({})\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA8B,iBAOvB,MAAMF,KAAqB,iBAAuC,CAAC,CAAC",
6
- "names": ["LayoutGroupContext_exports", "__export", "LayoutGroupContext", "__toCommonJS", "import_react"]
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAOvB,MAAM,yBAAqB,4BAAuC,CAAC,CAAC;",
6
+ "names": []
7
7
  }
@@ -1,2 +1,95 @@
1
- "use strict";var b=Object.create;var c=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var C=(e,n)=>{for(var r in n)c(e,r,{get:n[r],enumerable:!0})},l=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of v(n))!w.call(e,t)&&t!==r&&c(e,t,{get:()=>n[t],enumerable:!(s=M(n,t))||s.enumerable});return e};var L=(e,n,r)=>(r=e!=null?b(y(e)):{},l(n||!e||!e.__esModule?c(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>l(c({},"__esModule",{value:!0}),e);var A={};C(A,{PresenceChild:()=>V});module.exports=R(A);var P=require("react/jsx-runtime"),d=require("@tamagui/use-presence"),i=L(require("react")),p=require("react");const V=({children:e,initial:n,isPresent:r,onExitComplete:s,exitVariant:t,enterVariant:u,presenceAffectsLayout:m})=>{const o=i.useMemo(z,[]),g=(0,p.useId)()||"",h=i.useMemo(()=>({id:g,initial:n,isPresent:r,exitVariant:t,enterVariant:u,onExitComplete:a=>{o.set(a,!0);for(const f of o.values())if(!f)return;s==null||s()},register:a=>(o.set(a,!1),()=>o.delete(a))}),m?void 0:[r,t,u]);return i.useMemo(()=>{o.forEach((a,f)=>o.set(f,!1))},[r]),i.useEffect(()=>{!(r||o.size)&&(s==null||s())},[r]),(0,P.jsx)(d.PresenceContext.Provider,{value:h,children:e})};function z(){return new Map}0&&(module.exports={PresenceChild});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var PresenceChild_exports = {};
30
+ __export(PresenceChild_exports, {
31
+ PresenceChild: () => PresenceChild
32
+ });
33
+ module.exports = __toCommonJS(PresenceChild_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_use_presence = require("@tamagui/use-presence");
36
+ var React = __toESM(require("react"));
37
+ var import_react = require("react");
38
+ const PresenceChild = ({
39
+ children,
40
+ initial,
41
+ isPresent,
42
+ onExitComplete,
43
+ exitVariant,
44
+ enterVariant,
45
+ presenceAffectsLayout
46
+ }) => {
47
+ const presenceChildren = React.useMemo(newChildrenMap, []);
48
+ const id = (0, import_react.useId)() || "";
49
+ const context = React.useMemo(
50
+ () => {
51
+ return {
52
+ id,
53
+ initial,
54
+ isPresent,
55
+ exitVariant,
56
+ enterVariant,
57
+ onExitComplete: (id2) => {
58
+ presenceChildren.set(id2, true);
59
+ for (const isComplete of presenceChildren.values()) {
60
+ if (!isComplete) {
61
+ return;
62
+ }
63
+ }
64
+ onExitComplete == null ? void 0 : onExitComplete();
65
+ },
66
+ register: (id2) => {
67
+ presenceChildren.set(id2, false);
68
+ return () => presenceChildren.delete(id2);
69
+ }
70
+ };
71
+ },
72
+ /**
73
+ * If the presence of a child affects the layout of the components around it,
74
+ * we want to make a new context value to ensure they get re-rendered
75
+ * so they can detect that layout change.
76
+ */
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
78
+ presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]
79
+ );
80
+ React.useMemo(() => {
81
+ presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
82
+ }, [isPresent]);
83
+ React.useEffect(() => {
84
+ !(isPresent || presenceChildren.size) && (onExitComplete == null ? void 0 : onExitComplete());
85
+ }, [isPresent]);
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, { value: context, children });
87
+ };
88
+ function newChildrenMap() {
89
+ return /* @__PURE__ */ new Map();
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ PresenceChild
94
+ });
2
95
  //# sourceMappingURL=PresenceChild.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/PresenceChild.tsx"],
4
4
  "sourcesContent": ["import { PresenceContext } from '@tamagui/use-presence'\nimport type { PresenceContextProps } from '@tamagui/web'\nimport * as React from 'react'\nimport { useId } from 'react'\n\nimport { VariantLabels } from './types'\n\ninterface PresenceChildProps {\n children: React.ReactElement<any>\n isPresent: boolean\n onExitComplete?: () => void\n initial?: false | VariantLabels\n custom?: any\n presenceAffectsLayout: boolean\n exitVariant?: string | null\n enterVariant?: string | null\n}\n\nexport const PresenceChild = ({\n children,\n initial,\n isPresent,\n onExitComplete,\n exitVariant,\n enterVariant,\n presenceAffectsLayout,\n}: PresenceChildProps) => {\n const presenceChildren = React.useMemo(newChildrenMap, [])\n const id = useId() || ''\n\n const context = React.useMemo(\n (): PresenceContextProps => {\n return {\n id,\n initial,\n isPresent,\n exitVariant,\n enterVariant,\n onExitComplete: (id: string) => {\n presenceChildren.set(id, true)\n for (const isComplete of presenceChildren.values()) {\n if (!isComplete) {\n return // can stop searching when any is incomplete\n }\n }\n onExitComplete?.()\n },\n register: (id: string) => {\n presenceChildren.set(id, false)\n return () => presenceChildren.delete(id)\n },\n }\n },\n /**\n * If the presence of a child affects the layout of the components around it,\n * we want to make a new context value to ensure they get re-rendered\n * so they can detect that layout change.\n */\n // eslint-disable-next-line react-hooks/exhaustive-deps\n presenceAffectsLayout ? undefined : [isPresent, exitVariant, enterVariant]\n )\n\n React.useMemo(() => {\n presenceChildren.forEach((_, key) => presenceChildren.set(key, false))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isPresent])\n\n /**\n * If there's no animated components to fire exit animations, we want to remove this\n * component immediately.\n */\n React.useEffect(() => {\n !(isPresent || presenceChildren.size) && onExitComplete?.()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isPresent])\n\n return <PresenceContext.Provider value={context}>{children}</PresenceContext.Provider>\n}\n\nfunction newChildrenMap(): Map<string, boolean> {\n return new Map()\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GA4ES,IAAAI,EAAA,6BA5ETC,EAAgC,iCAEhCC,EAAuB,oBACvBC,EAAsB,iBAef,MAAML,EAAgB,CAAC,CAC5B,SAAAM,EACA,QAAAC,EACA,UAAAC,EACA,eAAAC,EACA,YAAAC,EACA,aAAAC,EACA,sBAAAC,CACF,IAA0B,CACxB,MAAMC,EAAmBT,EAAM,QAAQU,EAAgB,CAAC,CAAC,EACnDC,KAAK,SAAM,GAAK,GAEhBC,EAAUZ,EAAM,QACpB,KACS,CACL,GAAAW,EACA,QAAAR,EACA,UAAAC,EACA,YAAAE,EACA,aAAAC,EACA,eAAiBI,GAAe,CAC9BF,EAAiB,IAAIE,EAAI,EAAI,EAC7B,UAAWE,KAAcJ,EAAiB,OAAO,EAC/C,GAAI,CAACI,EACH,OAGJR,GAAA,MAAAA,GACF,EACA,SAAWM,IACTF,EAAiB,IAAIE,EAAI,EAAK,EACvB,IAAMF,EAAiB,OAAOE,CAAE,EAE3C,GAQFH,EAAwB,OAAY,CAACJ,EAAWE,EAAaC,CAAY,CAC3E,EAEA,OAAAP,EAAM,QAAQ,IAAM,CAClBS,EAAiB,QAAQ,CAACK,EAAGC,IAAQN,EAAiB,IAAIM,EAAK,EAAK,CAAC,CAEvE,EAAG,CAACX,CAAS,CAAC,EAMdJ,EAAM,UAAU,IAAM,CACpB,EAAEI,GAAaK,EAAiB,QAASJ,GAAA,MAAAA,IAE3C,EAAG,CAACD,CAAS,CAAC,KAEP,OAAC,kBAAgB,SAAhB,CAAyB,MAAOQ,EAAU,SAAAV,EAAS,CAC7D,EAEA,SAASQ,GAAuC,CAC9C,OAAO,IAAI,GACb",
6
- "names": ["PresenceChild_exports", "__export", "PresenceChild", "__toCommonJS", "import_jsx_runtime", "import_use_presence", "React", "import_react", "children", "initial", "isPresent", "onExitComplete", "exitVariant", "enterVariant", "presenceAffectsLayout", "presenceChildren", "newChildrenMap", "id", "context", "isComplete", "_", "key"]
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4ES;AA5ET,0BAAgC;AAEhC,YAAuB;AACvB,mBAAsB;AAef,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,mBAAmB,MAAM,QAAQ,gBAAgB,CAAC,CAAC;AACzD,QAAM,SAAK,oBAAM,KAAK;AAEtB,QAAM,UAAU,MAAM;AAAA,IACpB,MAA4B;AAC1B,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAgB,CAACA,QAAe;AAC9B,2BAAiB,IAAIA,KAAI,IAAI;AAC7B,qBAAW,cAAc,iBAAiB,OAAO,GAAG;AAClD,gBAAI,CAAC,YAAY;AACf;AAAA,YACF;AAAA,UACF;AACA;AAAA,QACF;AAAA,QACA,UAAU,CAACA,QAAe;AACxB,2BAAiB,IAAIA,KAAI,KAAK;AAC9B,iBAAO,MAAM,iBAAiB,OAAOA,GAAE;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,wBAAwB,SAAY,CAAC,WAAW,aAAa,YAAY;AAAA,EAC3E;AAEA,QAAM,QAAQ,MAAM;AAClB,qBAAiB,QAAQ,CAAC,GAAG,QAAQ,iBAAiB,IAAI,KAAK,KAAK,CAAC;AAAA,EAEvE,GAAG,CAAC,SAAS,CAAC;AAMd,QAAM,UAAU,MAAM;AACpB,MAAE,aAAa,iBAAiB,UAAS;AAAA,EAE3C,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO,4CAAC,oCAAgB,UAAhB,EAAyB,OAAO,SAAU,UAAS;AAC7D;AAEA,SAAS,iBAAuC;AAC9C,SAAO,oBAAI,IAAI;AACjB;",
6
+ "names": ["id"]
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,20 @@
1
- "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require("./AnimatePresence"),module.exports);f(e,require("@tamagui/use-presence"),module.exports);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./AnimatePresence"), module.exports);
19
+ __reExport(src_exports, require("@tamagui/use-presence"), module.exports);
2
20
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export * from './AnimatePresence'\nexport * from '@tamagui/use-presence'\n"],
5
- "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,6BAAd,gBACAE,EAAAF,EAAc,iCADd",
6
- "names": ["src_exports", "__toCommonJS", "__reExport"]
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,kCADd;",
6
+ "names": []
7
7
  }
package/dist/cjs/types.js CHANGED
@@ -1,2 +1,17 @@
1
- "use strict";var r=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var l=(n,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of s(e))!x.call(n,t)&&t!==a&&r(n,t,{get:()=>e[t],enumerable:!(i=o(e,t))||i.enumerable});return n};var p=n=>l(r({},"__esModule",{value:!0}),n);var c={};module.exports=p(c);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
2
17
  //# sourceMappingURL=types.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts"],
4
4
  "sourcesContent": ["export interface Axis {\n min: number\n max: number\n}\n\nexport interface Box {\n x: Axis\n y: Axis\n}\n\nexport type VariantLabels = string | string[]\n\n/**\n * @public\n */\nexport interface AnimatePresenceProps {\n /**\n * By passing `initial={false}`, `AnimatePresence` will disable any initial animations on children\n * that are present when the component is first rendered.\n *\n * ```jsx\n * <AnimatePresence initial={false}>\n * {isVisible && (\n * <motion.div\n * key=\"modal\"\n * initial={{ opacity: 0 }}\n * animate={{ opacity: 1 }}\n * exit={{ opacity: 0 }}\n * />\n * )}\n * </AnimatePresence>\n * ```\n *\n * @public\n */\n initial?: boolean\n\n /**\n * When a component is removed, there's no longer a chance to update its props. So if a component's `exit`\n * prop is defined as a dynamic variant and you want to pass a new `custom` prop, you can do so via `AnimatePresence`.\n * This will ensure all leaving components animate using the latest data.\n *\n * @public\n */\n custom?: any\n\n /**\n * Fires when all exiting nodes have completed animating out.\n *\n * @public\n */\n onExitComplete?: () => void\n\n /**\n * If set to `true`, `AnimatePresence` will only render one component at a time. The exiting component\n * will finish its exit animation before the entering component is rendered.\n *\n * ```jsx\n * const MyComponent = ({ currentItem }) => (\n * <AnimatePresence exitBeforeEnter>\n * <motion.div key={currentItem} exit={{ opacity: 0 }} />\n * </AnimatePresence>\n * )\n * ```\n *\n * @beta\n */\n exitBeforeEnter?: boolean\n\n /**\n * Used in Framer to flag that sibling children *shouldn't* re-render as a result of a\n * child being removed.\n *\n * @internal\n */\n presenceAffectsLayout?: boolean\n\n exitVariant?: string | null\n\n enterVariant?: string | null\n}\n"],
5
- "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
- "names": ["types_exports", "__toCommonJS"]
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
7
  }