@tamagui/animate-presence 1.0.0-beta.147
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 +154 -0
- package/dist/cjs/AnimatePresence.js.map +7 -0
- package/dist/cjs/AnimatePresenceContext.js +25 -0
- package/dist/cjs/AnimatePresenceContext.js.map +7 -0
- package/dist/cjs/LayoutGroupContext.js +25 -0
- package/dist/cjs/LayoutGroupContext.js.map +7 -0
- package/dist/cjs/PresenceChild.js +81 -0
- package/dist/cjs/PresenceChild.js.map +7 -0
- package/dist/cjs/index.js +27 -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 +51 -0
- package/dist/cjs/useEntering.js.map +7 -0
- package/dist/cjs/usePresence.js +51 -0
- package/dist/cjs/usePresence.js.map +7 -0
- package/dist/esm/AnimatePresence.js +141 -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 +60 -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/esm/usePresence.js +33 -0
- package/dist/esm/usePresence.js.map +7 -0
- package/dist/jsx/AnimatePresence.js +120 -0
- package/dist/jsx/AnimatePresenceContext.js +5 -0
- package/dist/jsx/LayoutGroupContext.js +5 -0
- package/dist/jsx/PresenceChild.js +57 -0
- package/dist/jsx/index.js +6 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/useEntering.js +32 -0
- package/dist/jsx/usePresence.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
- package/types/usePresence.d.ts +10 -0
- package/types/usePresence.d.ts.map +1 -0
|
@@ -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
|
+
};
|
|
@@ -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 usePresence() {
|
|
7
|
+
const context = useContext(AnimatePresenceContext);
|
|
8
|
+
if (context === null) {
|
|
9
|
+
return [true, null];
|
|
10
|
+
}
|
|
11
|
+
const { isPresent: isPresent2, onExitComplete, register } = context;
|
|
12
|
+
const id = useId();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
register(id);
|
|
15
|
+
}, []);
|
|
16
|
+
const safeToRemove = /* @__PURE__ */ __name(() => onExitComplete == null ? void 0 : onExitComplete(id), "safeToRemove");
|
|
17
|
+
return !isPresent2 ? [false, safeToRemove] : [true];
|
|
18
|
+
}
|
|
19
|
+
__name(usePresence, "usePresence");
|
|
20
|
+
function useIsPresent() {
|
|
21
|
+
return isPresent(useContext(AnimatePresenceContext));
|
|
22
|
+
}
|
|
23
|
+
__name(useIsPresent, "useIsPresent");
|
|
24
|
+
function isPresent(context) {
|
|
25
|
+
return context === null ? true : context.isPresent;
|
|
26
|
+
}
|
|
27
|
+
__name(isPresent, "isPresent");
|
|
28
|
+
export {
|
|
29
|
+
isPresent,
|
|
30
|
+
useIsPresent,
|
|
31
|
+
usePresence
|
|
32
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/animate-presence",
|
|
3
|
+
"version": "1.0.0-beta.147+6d63af55",
|
|
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.147+6d63af55"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@tamagui/build": "^1.0.0-beta.147+6d63af55"
|
|
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": "6d63af55317e3c878ea0b61995728fa480776ffc"
|
|
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":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAc9B,MAAM,WAAW,oBAAoB;IAKnC,OAAO,CAAC,EAAE,OAAO,CAAA;IAOjB,MAAM,CAAC,EAAE,GAAG,CAAA;IAKZ,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAM3B,eAAe,CAAC,EAAE,OAAO,CAAA;IAMzB,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAmED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAkKzE,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,SAAS,EAAE,OAAO,CAAA;IAClB,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,MAAM,CAAC,EAAE,GAAG,CAAA;CACb;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,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAC3B,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAA;IAC/B,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,qBAAqB,EAAE,OAAO,CAAA;CAC/B;AAED,eAAO,MAAM,aAAa,qFAOvB,kBAAkB,gBAmDpB,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnimatePresenceContextProps } from './AnimatePresenceContext';
|
|
2
|
+
export declare type SafeToRemove = () => void;
|
|
3
|
+
declare type AlreadyPresent = [undefined];
|
|
4
|
+
declare type Entering = [true];
|
|
5
|
+
declare type Leaving = [false, SafeToRemove];
|
|
6
|
+
export declare function useEntering(): Entering | Leaving | AlreadyPresent;
|
|
7
|
+
export declare function useIsEntering(): boolean | undefined;
|
|
8
|
+
export declare function isEntering(context: AnimatePresenceContextProps | null): boolean | undefined;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=usePresence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePresence.d.ts","sourceRoot":"","sources":["../src/usePresence.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAE9F,oBAAY,YAAY,GAAG,MAAM,IAAI,CAAA;AAErC,aAAK,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACjC,aAAK,OAAO,GAAG,CAAC,IAAI,CAAC,CAAA;AACrB,aAAK,UAAU,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;AAEvC,wBAAgB,WAAW,IAAI,aAAa,GAAG,OAAO,GAAG,UAAU,CAsBlE;AAMD,wBAAgB,YAAY,YAE3B;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI,WAEpE"}
|