@tamagui/animate-presence 1.0.0-beta.189 → 1.0.0-beta.200

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.
@@ -0,0 +1,51 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 useEntering_exports = {};
20
+ __export(useEntering_exports, {
21
+ isEntering: () => isEntering,
22
+ useEntering: () => useEntering,
23
+ useIsEntering: () => useIsEntering
24
+ });
25
+ module.exports = __toCommonJS(useEntering_exports);
26
+ var import_utils = require("@react-aria/utils");
27
+ var import_react = require("react");
28
+ var import_AnimatePresenceContext = require("./AnimatePresenceContext");
29
+ function useEntering() {
30
+ const context = (0, import_react.useContext)(import_AnimatePresenceContext.AnimatePresenceContext);
31
+ if (context === null) {
32
+ return [void 0, void 0];
33
+ }
34
+ const { isEntering: isEntering2, onExitComplete, register } = context;
35
+ const id = (0, import_utils.useId)();
36
+ const safeToRemove = /* @__PURE__ */ __name(() => onExitComplete == null ? void 0 : onExitComplete(id), "safeToRemove");
37
+ (0, import_react.useEffect)(() => {
38
+ register(id);
39
+ }, []);
40
+ return isEntering2 === false ? [false, safeToRemove] : isEntering2 === true ? [true, safeToRemove] : [void 0, safeToRemove];
41
+ }
42
+ __name(useEntering, "useEntering");
43
+ function useIsEntering() {
44
+ return isEntering((0, import_react.useContext)(import_AnimatePresenceContext.AnimatePresenceContext));
45
+ }
46
+ __name(useIsEntering, "useIsEntering");
47
+ function isEntering(context) {
48
+ return context === null ? void 0 : context.isEntering;
49
+ }
50
+ __name(isEntering, "isEntering");
51
+ //# 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AACtB,mBAAsC;AAEtC,oCAAoE;AAI7D,uBAAwE;AAC7E,QAAM,UAAU,6BAAW,oDAAsB;AAEjD,MAAI,YAAY,MAAM;AACpB,WAAO,CAAC,QAAW,MAAS;AAAA,EAC9B;AAEA,QAAM,EAAE,yBAAY,gBAAgB,aAAa;AAEjD,QAAM,KAAK,wBAAM;AACjB,QAAM,eAAe,6BAAM,iDAAiB,KAAvB;AAKrB,8BAAU,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,6BAAW,oDAAsB,CAAC;AACtD;AAFgB;AAIT,oBAAoB,SAA6C;AACtE,SAAO,YAAY,OAAO,SAAY,QAAQ;AAChD;AAFgB;",
6
+ "names": []
7
+ }
@@ -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,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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/animate-presence",
3
- "version": "1.0.0-beta.189+64107267",
3
+ "version": "1.0.0-beta.200+9591831d",
4
4
  "source": "src/index.ts",
5
5
  "license": "MIT",
6
6
  "typings": "types",
@@ -12,10 +12,10 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@tamagui/core": "^1.0.0-beta.189+64107267"
15
+ "@tamagui/core": "^1.0.0-beta.200+9591831d"
16
16
  },
17
17
  "devDependencies": {
18
- "@tamagui/build": "^1.0.0-beta.189+64107267"
18
+ "@tamagui/build": "^1.0.0-beta.200+9591831d"
19
19
  },
20
20
  "scripts": {
21
21
  "build": "tamagui-build",
@@ -26,5 +26,5 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "6410726774260b4de48c270c81a17b168995a3b7"
29
+ "gitHead": "9591831d7d4a58cc4e01846e68a0d3324570b5c8"
30
30
  }
@@ -1,10 +1,11 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  export interface AnimatePresenceProps {
3
3
  initial?: boolean;
4
- custom?: any;
4
+ exitVariant?: string | null;
5
+ enterVariant?: string | null;
5
6
  onExitComplete?: () => void;
6
7
  exitBeforeEnter?: boolean;
7
8
  presenceAffectsLayout?: boolean;
8
9
  }
9
- export declare const AnimatePresence: React.FunctionComponent<AnimatePresenceProps>;
10
+ export declare const AnimatePresence: React.FunctionComponent<React.PropsWithChildren<AnimatePresenceProps>>;
10
11
  //# sourceMappingURL=AnimatePresence.d.ts.map
@@ -2,11 +2,12 @@
2
2
  import { VariantLabels } from './types';
3
3
  export interface AnimatePresenceContextProps {
4
4
  id: string;
5
- isPresent: boolean;
5
+ isEntering: boolean | undefined;
6
6
  register: (id: string) => () => void;
7
7
  onExitComplete?: (id: string) => void;
8
8
  initial?: false | VariantLabels;
9
- custom?: any;
9
+ exitVariant?: string | null;
10
+ enterVariant?: string | null;
10
11
  }
11
12
  export declare const AnimatePresenceContext: import("react").Context<AnimatePresenceContextProps | null>;
12
13
  //# sourceMappingURL=AnimatePresenceContext.d.ts.map
@@ -2,12 +2,13 @@ import * as React from 'react';
2
2
  import { VariantLabels } from './types';
3
3
  interface PresenceChildProps {
4
4
  children: React.ReactElement<any>;
5
- isPresent: boolean;
5
+ isEntering: boolean | undefined;
6
6
  onExitComplete?: () => void;
7
7
  initial?: false | VariantLabels;
8
- custom?: any;
8
+ exitVariant?: string | null;
9
+ enterVariant?: string | null;
9
10
  presenceAffectsLayout: boolean;
10
11
  }
11
- export declare const PresenceChild: ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, }: PresenceChildProps) => JSX.Element;
12
+ export declare const PresenceChild: ({ children, initial, isEntering, onExitComplete, exitVariant, enterVariant, presenceAffectsLayout, }: PresenceChildProps) => JSX.Element;
12
13
  export {};
13
14
  //# sourceMappingURL=PresenceChild.d.ts.map
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './AnimatePresence';
2
- export * from './usePresence';
2
+ export * from './useEntering';
3
3
  export { AnimatePresenceContext } from './AnimatePresenceContext';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -1,10 +1,10 @@
1
1
  import { AnimatePresenceContextProps } from './AnimatePresenceContext';
2
2
  export declare type SafeToRemove = () => void;
3
- declare type AlwaysPresent = [true, null];
4
- declare type Present = [true];
5
- declare type NotPresent = [false, SafeToRemove];
6
- export declare function usePresence(): AlwaysPresent | Present | NotPresent;
7
- export declare function useIsPresent(): boolean;
8
- export declare function isPresent(context: AnimatePresenceContextProps | null): boolean;
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
9
  export {};
10
10
  //# sourceMappingURL=usePresence.d.ts.map