@tamagui/animate-presence 1.0.0-beta.0.204
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/LICENSE.md +9 -0
- package/README.md +1 -0
- package/dist/cjs/AnimatePresence.js +156 -0
- package/dist/cjs/AnimatePresence.js.map +7 -0
- package/dist/cjs/AnimatePresenceContext.js +29 -0
- package/dist/cjs/AnimatePresenceContext.js.map +7 -0
- package/dist/cjs/LayoutGroupContext.js +29 -0
- package/dist/cjs/LayoutGroupContext.js.map +7 -0
- package/dist/cjs/PresenceChild.js +84 -0
- package/dist/cjs/PresenceChild.js.map +7 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/useEntering.js +57 -0
- package/dist/cjs/useEntering.js.map +7 -0
- package/dist/esm/AnimatePresence.js +139 -0
- package/dist/esm/AnimatePresence.js.map +7 -0
- package/dist/esm/AnimatePresenceContext.js +6 -0
- package/dist/esm/AnimatePresenceContext.js.map +7 -0
- package/dist/esm/LayoutGroupContext.js +6 -0
- package/dist/esm/LayoutGroupContext.js.map +7 -0
- package/dist/esm/PresenceChild.js +59 -0
- package/dist/esm/PresenceChild.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/useEntering.js +33 -0
- package/dist/esm/useEntering.js.map +7 -0
- package/dist/jsx/AnimatePresence.js +118 -0
- package/dist/jsx/AnimatePresenceContext.js +5 -0
- package/dist/jsx/LayoutGroupContext.js +5 -0
- package/dist/jsx/PresenceChild.js +56 -0
- package/dist/jsx/index.js +6 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/useEntering.js +32 -0
- package/package.json +30 -0
- package/types/AnimatePresence.d.ts +11 -0
- package/types/AnimatePresence.d.ts.map +1 -0
- package/types/AnimatePresenceContext.d.ts +13 -0
- package/types/AnimatePresenceContext.d.ts.map +1 -0
- package/types/LayoutGroupContext.d.ts +7 -0
- package/types/LayoutGroupContext.d.ts.map +1 -0
- package/types/PresenceChild.d.ts +14 -0
- package/types/PresenceChild.d.ts.map +1 -0
- package/types/index.d.ts +4 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts +10 -0
- package/types/types.d.ts.map +1 -0
- package/types/useEntering.d.ts +6 -0
- package/types/useEntering.d.ts.map +1 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/AnimatePresence.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useForceUpdate, useIsomorphicLayoutEffect, useUnmountEffect } from '@tamagui/core'\nimport React, {\n Children,\n ReactElement,\n ReactNode,\n cloneElement,\n isValidElement,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react'\n\nimport { LayoutGroupContext } from './LayoutGroupContext'\nimport { PresenceChild } from './PresenceChild'\n\nReact['keep']\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 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 exitVariant?: string | null\n\n enterVariant?: string | null\n\n /**\n * Fires when all exiting nodes have completed animating out.\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 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 presenceAffectsLayout?: boolean\n}\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 console.warn(`Children of AnimatePresence require unique keys. \"${key}\" is a duplicate.`)\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) => {\n if (isValidElement(child)) filtered.push(child)\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 * ```jsx\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 * `useEntering` 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 forceRenderLayoutGroup = useContext(LayoutGroupContext).forceRender\n if (forceRenderLayoutGroup) forceRender = forceRenderLayoutGroup\n\n const [isMounted, setIsMounted] = useState(false)\n\n useLayoutEffect(() => {\n setIsMounted(true)\n }, [])\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 useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false\n updateChildLookup(filteredChildren, allChildren)\n presentChildren.current = childrenToRender\n })\n\n useUnmountEffect(() => {\n isInitialRender.current = true\n allChildren.clear()\n exiting.clear()\n })\n\n if (isInitialRender.current) {\n return (\n <>\n {childrenToRender.map((child) => (\n <PresenceChild\n key={getChildKey(child)}\n isEntering\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\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 isEntering={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 === 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 isEntering={undefined}\n exitVariant={exitVariant}\n enterVariant={enterVariant}\n presenceAffectsLayout={presenceAffectsLayout}\n >\n {child}\n </PresenceChild>\n )\n })\n\n // if (process.env.NODE_ENV !== 'production' && exitBeforeEnter && childrenToRender.length > 1) {\n // console.warn(\n // `You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour.`\n // )\n // }\n\n return (\n <>{exiting.size ? childrenToRender : childrenToRender.map((child) => cloneElement(child))}</>\n )\n}\n\nAnimatePresence.displayName = 'AnimatePresence'\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/AnimatePresenceContext.tsx"],
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react'\n\nimport { VariantLabels } from './types'\n\nexport interface AnimatePresenceContextProps {\n id: string\n isEntering: boolean | undefined\n register: (id: string) => () => void\n onExitComplete?: (id: string) => void\n initial?: false | VariantLabels\n exitVariant?: string | null\n enterVariant?: string | null\n}\n\nexport const AnimatePresenceContext = createContext<AnimatePresenceContextProps | null>(null)\n"],
|
|
5
|
+
"mappings": "AAAA;AAcO,MAAM,yBAAyB,cAAkD,IAAI;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/LayoutGroupContext.tsx"],
|
|
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": "AAAA;AAOO,MAAM,qBAAqB,cAAuC,CAAC,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useId } from "@react-aria/utils";
|
|
4
|
+
import { useConstant } from "@tamagui/core";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { AnimatePresenceContext } from "./AnimatePresenceContext";
|
|
7
|
+
const PresenceChild = /* @__PURE__ */ __name(({
|
|
8
|
+
children,
|
|
9
|
+
initial,
|
|
10
|
+
isEntering,
|
|
11
|
+
onExitComplete,
|
|
12
|
+
exitVariant,
|
|
13
|
+
enterVariant,
|
|
14
|
+
presenceAffectsLayout
|
|
15
|
+
}) => {
|
|
16
|
+
const presenceChildren = useConstant(newChildrenMap);
|
|
17
|
+
const id = useId();
|
|
18
|
+
const context = React.useMemo(() => {
|
|
19
|
+
return {
|
|
20
|
+
id,
|
|
21
|
+
initial,
|
|
22
|
+
isEntering,
|
|
23
|
+
exitVariant,
|
|
24
|
+
enterVariant,
|
|
25
|
+
onExitComplete: (childId) => {
|
|
26
|
+
presenceChildren.set(childId, true);
|
|
27
|
+
for (const isComplete of presenceChildren.values()) {
|
|
28
|
+
if (!isComplete) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
onExitComplete == null ? void 0 : onExitComplete();
|
|
33
|
+
},
|
|
34
|
+
register: (childId) => {
|
|
35
|
+
presenceChildren.set(childId, false);
|
|
36
|
+
return () => presenceChildren.delete(childId);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, presenceAffectsLayout ? void 0 : [isEntering, onExitComplete, exitVariant, enterVariant]);
|
|
40
|
+
React.useMemo(() => {
|
|
41
|
+
presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
|
|
42
|
+
}, [isEntering]);
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
if (isEntering === false && !presenceChildren.size) {
|
|
45
|
+
onExitComplete == null ? void 0 : onExitComplete();
|
|
46
|
+
}
|
|
47
|
+
}, [isEntering]);
|
|
48
|
+
return /* @__PURE__ */ React.createElement(AnimatePresenceContext.Provider, {
|
|
49
|
+
value: context
|
|
50
|
+
}, children);
|
|
51
|
+
}, "PresenceChild");
|
|
52
|
+
function newChildrenMap() {
|
|
53
|
+
return /* @__PURE__ */ new Map();
|
|
54
|
+
}
|
|
55
|
+
__name(newChildrenMap, "newChildrenMap");
|
|
56
|
+
export {
|
|
57
|
+
PresenceChild
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=PresenceChild.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/PresenceChild.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useId } from '@react-aria/utils'\nimport { useConstant } from '@tamagui/core'\nimport * as React from 'react'\n\nimport { AnimatePresenceContext, AnimatePresenceContextProps } from './AnimatePresenceContext'\nimport { VariantLabels } from './types'\n\ninterface PresenceChildProps {\n children: React.ReactElement<any>\n isEntering: boolean | undefined\n onExitComplete?: () => void\n initial?: false | VariantLabels\n exitVariant?: string | null\n enterVariant?: string | null\n presenceAffectsLayout: boolean\n}\n\nexport const PresenceChild = ({\n children,\n initial,\n isEntering,\n onExitComplete,\n exitVariant,\n enterVariant,\n presenceAffectsLayout,\n}: PresenceChildProps) => {\n const presenceChildren = useConstant(newChildrenMap)\n const id = useId()\n\n const context = React.useMemo(\n (): AnimatePresenceContextProps => {\n return {\n id,\n initial,\n isEntering,\n exitVariant,\n enterVariant,\n onExitComplete: (childId: string) => {\n presenceChildren.set(childId, 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: (childId: string) => {\n presenceChildren.set(childId, false)\n return () => presenceChildren.delete(childId)\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 presenceAffectsLayout ? undefined : [isEntering, onExitComplete, exitVariant, enterVariant]\n )\n\n // cant this be a useEffect?\n React.useMemo(() => {\n presenceChildren.forEach((_, key) => presenceChildren.set(key, false))\n }, [isEntering])\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 if (isEntering === false && !presenceChildren.size) {\n onExitComplete?.()\n }\n }, [isEntering])\n\n return (\n <AnimatePresenceContext.Provider value={context}>{children}</AnimatePresenceContext.Provider>\n )\n}\n\nfunction newChildrenMap(): Map<string, boolean> {\n return new Map()\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AACA;AAEA;AAaO,MAAM,gBAAgB,wBAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACwB;AACxB,QAAM,mBAAmB,YAAY,cAAc;AACnD,QAAM,KAAK,MAAM;AAEjB,QAAM,UAAU,MAAM,QACpB,MAAmC;AACjC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB,CAAC,YAAoB;AACnC,yBAAiB,IAAI,SAAS,IAAI;AAClC,mBAAW,cAAc,iBAAiB,OAAO,GAAG;AAClD,cAAI,CAAC,YAAY;AACf;AAAA,UACF;AAAA,QACF;AACA;AAAA,MACF;AAAA,MACA,UAAU,CAAC,YAAoB;AAC7B,yBAAiB,IAAI,SAAS,KAAK;AACnC,eAAO,MAAM,iBAAiB,OAAO,OAAO;AAAA,MAC9C;AAAA,IACF;AAAA,EACF,GAMA,wBAAwB,SAAY,CAAC,YAAY,gBAAgB,aAAa,YAAY,CAC5F;AAGA,QAAM,QAAQ,MAAM;AAClB,qBAAiB,QAAQ,CAAC,GAAG,QAAQ,iBAAiB,IAAI,KAAK,KAAK,CAAC;AAAA,EACvE,GAAG,CAAC,UAAU,CAAC;AAMf,QAAM,UAAU,MAAM;AACpB,QAAI,eAAe,SAAS,CAAC,iBAAiB,MAAM;AAClD;AAAA,IACF;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,SACE,oCAAC,uBAAuB,UAAvB;AAAA,IAAgC,OAAO;AAAA,KAAU,QAAS;AAE/D,GA7D6B;AA+D7B,0BAAgD;AAC9C,SAAO,oBAAI,IAAI;AACjB;AAFS;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useId } from "@react-aria/utils";
|
|
4
|
+
import { useContext, useEffect } from "react";
|
|
5
|
+
import { AnimatePresenceContext } from "./AnimatePresenceContext";
|
|
6
|
+
function useEntering() {
|
|
7
|
+
const context = useContext(AnimatePresenceContext);
|
|
8
|
+
if (context === null) {
|
|
9
|
+
return [void 0, void 0];
|
|
10
|
+
}
|
|
11
|
+
const { isEntering: isEntering2, onExitComplete, register } = context;
|
|
12
|
+
const id = useId();
|
|
13
|
+
const safeToRemove = /* @__PURE__ */ __name(() => onExitComplete == null ? void 0 : onExitComplete(id), "safeToRemove");
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
register(id);
|
|
16
|
+
}, []);
|
|
17
|
+
return isEntering2 === false ? [false, safeToRemove] : isEntering2 === true ? [true, safeToRemove] : [void 0, safeToRemove];
|
|
18
|
+
}
|
|
19
|
+
__name(useEntering, "useEntering");
|
|
20
|
+
function useIsEntering() {
|
|
21
|
+
return isEntering(useContext(AnimatePresenceContext));
|
|
22
|
+
}
|
|
23
|
+
__name(useIsEntering, "useIsEntering");
|
|
24
|
+
function isEntering(context) {
|
|
25
|
+
return context === null ? void 0 : context.isEntering;
|
|
26
|
+
}
|
|
27
|
+
__name(isEntering, "isEntering");
|
|
28
|
+
export {
|
|
29
|
+
isEntering,
|
|
30
|
+
useEntering,
|
|
31
|
+
useIsEntering
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=useEntering.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useEntering.ts"],
|
|
4
|
+
"sourcesContent": ["import { useId } from '@react-aria/utils'\nimport { useContext, useEffect } from 'react'\n\nimport { AnimatePresenceContext, AnimatePresenceContextProps } from './AnimatePresenceContext'\n\nexport type SafeToRemove = () => void\n\nexport function useEntering(): [boolean | undefined, undefined | (() => void)] {\n const context = useContext(AnimatePresenceContext)\n\n if (context === null) {\n return [undefined, undefined]\n }\n\n const { isEntering, onExitComplete, register } = context\n // Replace with useId when released in React\n const id = useId()\n const safeToRemove = () => onExitComplete?.(id)\n\n // It's safe to call the following hooks conditionally (after an early return) because the context will always\n // either be null or non-null for the lifespan of the component.\n\n useEffect(() => {\n register(id)\n }, [])\n\n return isEntering === false\n ? [false, safeToRemove]\n : isEntering === true\n ? [true, safeToRemove]\n : [undefined, safeToRemove]\n}\n\n/**\n * Similar to `useEntering`, except `useIsEntering` simply returns whether or not the component is present.\n * There is no `safeToRemove` function. ```\n */\nexport function useIsEntering() {\n return isEntering(useContext(AnimatePresenceContext))\n}\n\nexport function isEntering(context: AnimatePresenceContextProps | null) {\n return context === null ? undefined : context.isEntering\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AAEA;AAIO,uBAAwE;AAC7E,QAAM,UAAU,WAAW,sBAAsB;AAEjD,MAAI,YAAY,MAAM;AACpB,WAAO,CAAC,QAAW,MAAS;AAAA,EAC9B;AAEA,QAAM,EAAE,yBAAY,gBAAgB,aAAa;AAEjD,QAAM,KAAK,MAAM;AACjB,QAAM,eAAe,6BAAM,iDAAiB,KAAvB;AAKrB,YAAU,MAAM;AACd,aAAS,EAAE;AAAA,EACb,GAAG,CAAC,CAAC;AAEL,SAAO,gBAAe,QAClB,CAAC,OAAO,YAAY,IACpB,gBAAe,OACf,CAAC,MAAM,YAAY,IACnB,CAAC,QAAW,YAAY;AAC9B;AAxBgB;AA8BT,yBAAyB;AAC9B,SAAO,WAAW,WAAW,sBAAsB,CAAC;AACtD;AAFgB;AAIT,oBAAoB,SAA6C;AACtE,SAAO,YAAY,OAAO,SAAY,QAAQ;AAChD;AAFgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useForceUpdate, useIsomorphicLayoutEffect, useUnmountEffect } from "@tamagui/core";
|
|
4
|
+
import React, {
|
|
5
|
+
Children,
|
|
6
|
+
cloneElement,
|
|
7
|
+
isValidElement,
|
|
8
|
+
useContext,
|
|
9
|
+
useLayoutEffect,
|
|
10
|
+
useRef,
|
|
11
|
+
useState
|
|
12
|
+
} from "react";
|
|
13
|
+
import { LayoutGroupContext } from "./LayoutGroupContext";
|
|
14
|
+
import { PresenceChild } from "./PresenceChild";
|
|
15
|
+
React["keep"];
|
|
16
|
+
const getChildKey = /* @__PURE__ */ __name((child) => child.key || "", "getChildKey");
|
|
17
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
18
|
+
function updateChildLookup(children, allChildren) {
|
|
19
|
+
const seenChildren = isDev ? /* @__PURE__ */ new Set() : null;
|
|
20
|
+
children.forEach((child) => {
|
|
21
|
+
const key = getChildKey(child);
|
|
22
|
+
if (isDev && seenChildren && seenChildren.has(key)) {
|
|
23
|
+
console.warn(`Children of AnimatePresence require unique keys. "${key}" is a duplicate.`);
|
|
24
|
+
seenChildren.add(key);
|
|
25
|
+
}
|
|
26
|
+
allChildren.set(key, child);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
__name(updateChildLookup, "updateChildLookup");
|
|
30
|
+
function onlyElements(children) {
|
|
31
|
+
const filtered = [];
|
|
32
|
+
Children.forEach(children, (child) => {
|
|
33
|
+
if (isValidElement(child))
|
|
34
|
+
filtered.push(child);
|
|
35
|
+
});
|
|
36
|
+
return filtered;
|
|
37
|
+
}
|
|
38
|
+
__name(onlyElements, "onlyElements");
|
|
39
|
+
const AnimatePresence = /* @__PURE__ */ __name(({
|
|
40
|
+
children,
|
|
41
|
+
enterVariant,
|
|
42
|
+
exitVariant,
|
|
43
|
+
initial = true,
|
|
44
|
+
onExitComplete,
|
|
45
|
+
exitBeforeEnter,
|
|
46
|
+
presenceAffectsLayout = true
|
|
47
|
+
}) => {
|
|
48
|
+
let forceRender = useForceUpdate();
|
|
49
|
+
const forceRenderLayoutGroup = useContext(LayoutGroupContext).forceRender;
|
|
50
|
+
if (forceRenderLayoutGroup)
|
|
51
|
+
forceRender = forceRenderLayoutGroup;
|
|
52
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
setIsMounted(true);
|
|
55
|
+
}, []);
|
|
56
|
+
const filteredChildren = onlyElements(children);
|
|
57
|
+
let childrenToRender = filteredChildren;
|
|
58
|
+
const exiting = /* @__PURE__ */ new Set();
|
|
59
|
+
const presentChildren = useRef(childrenToRender);
|
|
60
|
+
const allChildren = useRef(/* @__PURE__ */ new Map()).current;
|
|
61
|
+
const isInitialRender = useRef(true);
|
|
62
|
+
useIsomorphicLayoutEffect(() => {
|
|
63
|
+
isInitialRender.current = false;
|
|
64
|
+
updateChildLookup(filteredChildren, allChildren);
|
|
65
|
+
presentChildren.current = childrenToRender;
|
|
66
|
+
});
|
|
67
|
+
useUnmountEffect(() => {
|
|
68
|
+
isInitialRender.current = true;
|
|
69
|
+
allChildren.clear();
|
|
70
|
+
exiting.clear();
|
|
71
|
+
});
|
|
72
|
+
if (isInitialRender.current) {
|
|
73
|
+
return <>{childrenToRender.map((child) => <PresenceChild key={getChildKey(child)} isEntering exitVariant={exitVariant} enterVariant={enterVariant} initial={initial ? void 0 : false} presenceAffectsLayout={presenceAffectsLayout}>{child}</PresenceChild>)}</>;
|
|
74
|
+
}
|
|
75
|
+
childrenToRender = [...childrenToRender];
|
|
76
|
+
const presentKeys = presentChildren.current.map(getChildKey);
|
|
77
|
+
const targetKeys = filteredChildren.map(getChildKey);
|
|
78
|
+
const numPresent = presentKeys.length;
|
|
79
|
+
for (let i = 0; i < numPresent; i++) {
|
|
80
|
+
const key = presentKeys[i];
|
|
81
|
+
if (targetKeys.indexOf(key) === -1) {
|
|
82
|
+
exiting.add(key);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (exitBeforeEnter && exiting.size) {
|
|
86
|
+
childrenToRender = [];
|
|
87
|
+
}
|
|
88
|
+
exiting.forEach((key) => {
|
|
89
|
+
if (targetKeys.indexOf(key) !== -1)
|
|
90
|
+
return;
|
|
91
|
+
const child = allChildren.get(key);
|
|
92
|
+
if (!child)
|
|
93
|
+
return;
|
|
94
|
+
const insertionIndex = presentKeys.indexOf(key);
|
|
95
|
+
childrenToRender.splice(insertionIndex, 0, <PresenceChild key={getChildKey(child)} isEntering={false} onExitComplete={() => {
|
|
96
|
+
allChildren.delete(key);
|
|
97
|
+
exiting.delete(key);
|
|
98
|
+
const removeIndex = presentChildren.current.findIndex((presentChild) => presentChild.key === key);
|
|
99
|
+
presentChildren.current.splice(removeIndex, 1);
|
|
100
|
+
if (!exiting.size) {
|
|
101
|
+
presentChildren.current = filteredChildren;
|
|
102
|
+
if (isMounted === false)
|
|
103
|
+
return;
|
|
104
|
+
forceRender();
|
|
105
|
+
onExitComplete == null ? void 0 : onExitComplete();
|
|
106
|
+
}
|
|
107
|
+
}} exitVariant={exitVariant} enterVariant={enterVariant} presenceAffectsLayout={presenceAffectsLayout}>{child}</PresenceChild>);
|
|
108
|
+
});
|
|
109
|
+
childrenToRender = childrenToRender.map((child) => {
|
|
110
|
+
const key = child.key;
|
|
111
|
+
return exiting.has(key) ? child : <PresenceChild key={getChildKey(child)} isEntering={void 0} exitVariant={exitVariant} enterVariant={enterVariant} presenceAffectsLayout={presenceAffectsLayout}>{child}</PresenceChild>;
|
|
112
|
+
});
|
|
113
|
+
return <>{exiting.size ? childrenToRender : childrenToRender.map((child) => cloneElement(child))}</>;
|
|
114
|
+
}, "AnimatePresence");
|
|
115
|
+
AnimatePresence.displayName = "AnimatePresence";
|
|
116
|
+
export {
|
|
117
|
+
AnimatePresence
|
|
118
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useId } from "@react-aria/utils";
|
|
4
|
+
import { useConstant } from "@tamagui/core";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { AnimatePresenceContext } from "./AnimatePresenceContext";
|
|
7
|
+
const PresenceChild = /* @__PURE__ */ __name(({
|
|
8
|
+
children,
|
|
9
|
+
initial,
|
|
10
|
+
isEntering,
|
|
11
|
+
onExitComplete,
|
|
12
|
+
exitVariant,
|
|
13
|
+
enterVariant,
|
|
14
|
+
presenceAffectsLayout
|
|
15
|
+
}) => {
|
|
16
|
+
const presenceChildren = useConstant(newChildrenMap);
|
|
17
|
+
const id = useId();
|
|
18
|
+
const context = React.useMemo(() => {
|
|
19
|
+
return {
|
|
20
|
+
id,
|
|
21
|
+
initial,
|
|
22
|
+
isEntering,
|
|
23
|
+
exitVariant,
|
|
24
|
+
enterVariant,
|
|
25
|
+
onExitComplete: (childId) => {
|
|
26
|
+
presenceChildren.set(childId, true);
|
|
27
|
+
for (const isComplete of presenceChildren.values()) {
|
|
28
|
+
if (!isComplete) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
onExitComplete == null ? void 0 : onExitComplete();
|
|
33
|
+
},
|
|
34
|
+
register: (childId) => {
|
|
35
|
+
presenceChildren.set(childId, false);
|
|
36
|
+
return () => presenceChildren.delete(childId);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, presenceAffectsLayout ? void 0 : [isEntering, onExitComplete, exitVariant, enterVariant]);
|
|
40
|
+
React.useMemo(() => {
|
|
41
|
+
presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
|
|
42
|
+
}, [isEntering]);
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
if (isEntering === false && !presenceChildren.size) {
|
|
45
|
+
onExitComplete == null ? void 0 : onExitComplete();
|
|
46
|
+
}
|
|
47
|
+
}, [isEntering]);
|
|
48
|
+
return <AnimatePresenceContext.Provider value={context}>{children}</AnimatePresenceContext.Provider>;
|
|
49
|
+
}, "PresenceChild");
|
|
50
|
+
function newChildrenMap() {
|
|
51
|
+
return /* @__PURE__ */ new Map();
|
|
52
|
+
}
|
|
53
|
+
__name(newChildrenMap, "newChildrenMap");
|
|
54
|
+
export {
|
|
55
|
+
PresenceChild
|
|
56
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useId } from "@react-aria/utils";
|
|
4
|
+
import { useContext, useEffect } from "react";
|
|
5
|
+
import { AnimatePresenceContext } from "./AnimatePresenceContext";
|
|
6
|
+
function useEntering() {
|
|
7
|
+
const context = useContext(AnimatePresenceContext);
|
|
8
|
+
if (context === null) {
|
|
9
|
+
return [void 0, void 0];
|
|
10
|
+
}
|
|
11
|
+
const { isEntering: isEntering2, onExitComplete, register } = context;
|
|
12
|
+
const id = useId();
|
|
13
|
+
const safeToRemove = /* @__PURE__ */ __name(() => onExitComplete == null ? void 0 : onExitComplete(id), "safeToRemove");
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
register(id);
|
|
16
|
+
}, []);
|
|
17
|
+
return isEntering2 === false ? [false, safeToRemove] : isEntering2 === true ? [true, safeToRemove] : [void 0, safeToRemove];
|
|
18
|
+
}
|
|
19
|
+
__name(useEntering, "useEntering");
|
|
20
|
+
function useIsEntering() {
|
|
21
|
+
return isEntering(useContext(AnimatePresenceContext));
|
|
22
|
+
}
|
|
23
|
+
__name(useIsEntering, "useIsEntering");
|
|
24
|
+
function isEntering(context) {
|
|
25
|
+
return context === null ? void 0 : context.isEntering;
|
|
26
|
+
}
|
|
27
|
+
__name(isEntering, "isEntering");
|
|
28
|
+
export {
|
|
29
|
+
isEntering,
|
|
30
|
+
useEntering,
|
|
31
|
+
useIsEntering
|
|
32
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/animate-presence",
|
|
3
|
+
"version": "1.0.0-beta.0.204+0834a094",
|
|
4
|
+
"source": "src/index.ts",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"typings": "types",
|
|
7
|
+
"main": "dist/cjs",
|
|
8
|
+
"module": "dist/esm",
|
|
9
|
+
"module:jsx": "dist/jsx",
|
|
10
|
+
"files": [
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@tamagui/core": "^1.0.0-beta.0.204+0834a094"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@tamagui/build": "^1.0.0-beta.0.204+0834a094"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tamagui-build",
|
|
22
|
+
"watch": "tamagui-build --watch",
|
|
23
|
+
"clean": "tamagui-build clean",
|
|
24
|
+
"clean:build": "tamagui-build clean:build"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "0834a0945f7b958c260d70f207d29a678e11b0ae"
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface AnimatePresenceProps {
|
|
3
|
+
initial?: boolean;
|
|
4
|
+
exitVariant?: string | null;
|
|
5
|
+
enterVariant?: string | null;
|
|
6
|
+
onExitComplete?: () => void;
|
|
7
|
+
exitBeforeEnter?: boolean;
|
|
8
|
+
presenceAffectsLayout?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const AnimatePresence: React.FunctionComponent<React.PropsWithChildren<AnimatePresenceProps>>;
|
|
11
|
+
//# sourceMappingURL=AnimatePresence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimatePresence.d.ts","sourceRoot":"","sources":["../src/AnimatePresence.tsx"],"names":[],"mappings":"AACA,OAAO,KAWN,MAAM,OAAO,CAAA;AAOd,MAAM,WAAW,oBAAoB;IAKnC,OAAO,CAAC,EAAE,OAAO,CAAA;IAOjB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAK5B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAM3B,eAAe,CAAC,EAAE,OAAO,CAAA;IAMzB,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAuED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,iBAAiB,CACnD,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAwK9C,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { VariantLabels } from './types';
|
|
3
|
+
export interface AnimatePresenceContextProps {
|
|
4
|
+
id: string;
|
|
5
|
+
isEntering: boolean | undefined;
|
|
6
|
+
register: (id: string) => () => void;
|
|
7
|
+
onExitComplete?: (id: string) => void;
|
|
8
|
+
initial?: false | VariantLabels;
|
|
9
|
+
exitVariant?: string | null;
|
|
10
|
+
enterVariant?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare const AnimatePresenceContext: import("react").Context<AnimatePresenceContextProps | null>;
|
|
13
|
+
//# sourceMappingURL=AnimatePresenceContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimatePresenceContext.d.ts","sourceRoot":"","sources":["../src/AnimatePresenceContext.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,OAAO,GAAG,SAAS,CAAA;IAC/B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,IAAI,CAAA;IACpC,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,eAAO,MAAM,sBAAsB,6DAA0D,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface LayoutGroupContextProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
forceRender?: VoidFunction;
|
|
5
|
+
}
|
|
6
|
+
export declare const LayoutGroupContext: import("react").Context<LayoutGroupContextProps>;
|
|
7
|
+
//# sourceMappingURL=LayoutGroupContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LayoutGroupContext.d.ts","sourceRoot":"","sources":["../src/LayoutGroupContext.tsx"],"names":[],"mappings":";AAEA,MAAM,WAAW,uBAAuB;IACtC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE,YAAY,CAAA;CAC3B;AAED,eAAO,MAAM,kBAAkB,kDAA6C,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { VariantLabels } from './types';
|
|
3
|
+
interface PresenceChildProps {
|
|
4
|
+
children: React.ReactElement<any>;
|
|
5
|
+
isEntering: boolean | undefined;
|
|
6
|
+
onExitComplete?: () => void;
|
|
7
|
+
initial?: false | VariantLabels;
|
|
8
|
+
exitVariant?: string | null;
|
|
9
|
+
enterVariant?: string | null;
|
|
10
|
+
presenceAffectsLayout: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const PresenceChild: ({ children, initial, isEntering, onExitComplete, exitVariant, enterVariant, presenceAffectsLayout, }: PresenceChildProps) => JSX.Element;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=PresenceChild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresenceChild.d.ts","sourceRoot":"","sources":["../src/PresenceChild.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IACjC,UAAU,EAAE,OAAO,GAAG,SAAS,CAAA;IAC/B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAC3B,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,qBAAqB,EAAE,OAAO,CAAA;CAC/B;AAED,eAAO,MAAM,aAAa,yGAQvB,kBAAkB,gBAqDpB,CAAA"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA"}
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,IAAI,CAAA;IACP,CAAC,EAAE,IAAI,CAAA;CACR;AAED,oBAAY,aAAa,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AnimatePresenceContextProps } from './AnimatePresenceContext';
|
|
2
|
+
export declare type SafeToRemove = () => void;
|
|
3
|
+
export declare function useEntering(): [boolean | undefined, undefined | (() => void)];
|
|
4
|
+
export declare function useIsEntering(): boolean | undefined;
|
|
5
|
+
export declare function isEntering(context: AnimatePresenceContextProps | null): boolean | undefined;
|
|
6
|
+
//# sourceMappingURL=useEntering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEntering.d.ts","sourceRoot":"","sources":["../src/useEntering.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAE9F,oBAAY,YAAY,GAAG,MAAM,IAAI,CAAA;AAErC,wBAAgB,WAAW,IAAI,CAAC,OAAO,GAAG,SAAS,EAAE,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAwB7E;AAMD,wBAAgB,aAAa,wBAE5B;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI,uBAErE"}
|