@tamagui/animate-presence 1.114.4 → 1.115.0

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,119 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var AnimatePresence_exports = {};
22
+ __export(AnimatePresence_exports, {
23
+ AnimatePresence: () => AnimatePresence
24
+ });
25
+ module.exports = __toCommonJS(AnimatePresence_exports);
26
+ var import_use_force_update = require("@tamagui/use-force-update"),
27
+ import_react = require("react"),
28
+ import_LayoutGroupContext = require("./LayoutGroupContext.cjs"),
29
+ import_PresenceChild = require("./PresenceChild.cjs"),
30
+ import_jsx_runtime = require("react/jsx-runtime");
31
+ const getChildKey = child => child.key || "";
32
+ function updateChildLookup(children, allChildren) {
33
+ children.forEach(child => {
34
+ const key = getChildKey(child);
35
+ allChildren.set(key, child);
36
+ });
37
+ }
38
+ function onlyElements(children) {
39
+ const filtered = [];
40
+ return import_react.Children.forEach(children, child => {
41
+ (0, import_react.isValidElement)(child) && filtered.push(child);
42
+ }), filtered;
43
+ }
44
+ const AnimatePresence = ({
45
+ children,
46
+ enterVariant,
47
+ exitVariant,
48
+ enterExitVariant,
49
+ initial = !0,
50
+ onExitComplete,
51
+ exitBeforeEnter,
52
+ presenceAffectsLayout = !0,
53
+ custom
54
+ }) => {
55
+ let forceRender = (0, import_react.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender ?? (0, import_use_force_update.useForceUpdate)();
56
+ const filteredChildren = onlyElements(children),
57
+ presentChildren = (0, import_react.useRef)(filteredChildren),
58
+ allChildren = (0, import_react.useRef)(/* @__PURE__ */new Map()).current,
59
+ exiting = (0, import_react.useRef)(/* @__PURE__ */new Set()).current;
60
+ updateChildLookup(filteredChildren, allChildren);
61
+ const isInitialRender = (0, import_react.useRef)(!0);
62
+ if (isInitialRender.current) return isInitialRender.current = !1, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
63
+ children: filteredChildren.map(child => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
64
+ isPresent: !0,
65
+ enterExitVariant,
66
+ exitVariant,
67
+ enterVariant,
68
+ initial: initial ? void 0 : !1,
69
+ presenceAffectsLayout,
70
+ custom,
71
+ children: child
72
+ }, getChildKey(child)))
73
+ });
74
+ let childrenToRender = [...filteredChildren];
75
+ const presentKeys = presentChildren.current.map(getChildKey),
76
+ targetKeys = filteredChildren.map(getChildKey),
77
+ numPresent = presentKeys.length;
78
+ for (let i = 0; i < numPresent; i++) {
79
+ const key = presentKeys[i];
80
+ targetKeys.indexOf(key) === -1 ? exiting.add(key) : exiting.delete(key);
81
+ }
82
+ return exitBeforeEnter && exiting.size && (childrenToRender = []), exiting.forEach(key => {
83
+ if (targetKeys.indexOf(key) !== -1) return;
84
+ const child = allChildren.get(key);
85
+ if (!child) return;
86
+ const insertionIndex = presentKeys.indexOf(key),
87
+ exitingComponent = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
88
+ isPresent: !1,
89
+ onExitComplete: () => {
90
+ allChildren.delete(key), exiting.delete(key);
91
+ const removeIndex = presentChildren.current.findIndex(presentChild => presentChild.key === key);
92
+ presentChildren.current.splice(removeIndex, 1), exiting.size || (presentChildren.current = filteredChildren, forceRender(), onExitComplete?.());
93
+ },
94
+ presenceAffectsLayout,
95
+ enterExitVariant,
96
+ enterVariant,
97
+ exitVariant,
98
+ custom,
99
+ children: child
100
+ }, getChildKey(child));
101
+ childrenToRender.splice(insertionIndex, 0, exitingComponent);
102
+ }), childrenToRender = childrenToRender.map(child => {
103
+ const key = child.key;
104
+ return exiting.has(key) ? child : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
105
+ isPresent: !0,
106
+ exitVariant,
107
+ enterVariant,
108
+ enterExitVariant,
109
+ presenceAffectsLayout,
110
+ custom,
111
+ children: child
112
+ }, getChildKey(child));
113
+ }), presentChildren.current = childrenToRender, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
114
+ children: exiting.size ? childrenToRender :
115
+ // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
116
+ childrenToRender.map(child => (0, import_react.cloneElement)(child))
117
+ });
118
+ };
119
+ AnimatePresence.displayName = "AnimatePresence";
@@ -2,29 +2,37 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
6
7
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
15
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
21
  // If the importer is in node compatibility mode or this is not an ESM
17
22
  // file that has been converted to a CommonJS file using a Babel-
18
23
  // compatible transform (i.e. "__esModule" has not been set), then set
19
24
  // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
23
32
  var LayoutGroupContext_exports = {};
24
33
  __export(LayoutGroupContext_exports, {
25
34
  LayoutGroupContext: () => LayoutGroupContext
26
35
  });
27
36
  module.exports = __toCommonJS(LayoutGroupContext_exports);
28
37
  var import_react = __toESM(require("react"));
29
- const LayoutGroupContext = import_react.default.createContext({});
30
- //# sourceMappingURL=LayoutGroupContext.js.map
38
+ const LayoutGroupContext = import_react.default.createContext({});
@@ -0,0 +1,88 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ 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", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var PresenceChild_exports = {};
33
+ __export(PresenceChild_exports, {
34
+ PresenceChild: () => PresenceChild
35
+ });
36
+ module.exports = __toCommonJS(PresenceChild_exports);
37
+ var import_use_constant = require("@tamagui/use-constant"),
38
+ import_use_presence = require("@tamagui/use-presence"),
39
+ React = __toESM(require("react")),
40
+ import_react = require("react"),
41
+ import_jsx_runtime = require("react/jsx-runtime");
42
+ const PresenceChild = React.memo(({
43
+ children,
44
+ initial,
45
+ isPresent,
46
+ onExitComplete,
47
+ exitVariant,
48
+ enterVariant,
49
+ enterExitVariant,
50
+ presenceAffectsLayout,
51
+ custom
52
+ }) => {
53
+ const presenceChildren = (0, import_use_constant.useConstant)(newChildrenMap),
54
+ id = (0, import_react.useId)() || "",
55
+ context = React.useMemo(() => ({
56
+ id,
57
+ initial,
58
+ isPresent,
59
+ custom,
60
+ exitVariant,
61
+ enterVariant,
62
+ enterExitVariant,
63
+ onExitComplete: () => {
64
+ presenceChildren.set(id, !0);
65
+ for (const isComplete of presenceChildren.values()) if (!isComplete) return;
66
+ onExitComplete?.();
67
+ },
68
+ register: () => (presenceChildren.set(id, !1), () => presenceChildren.delete(id))
69
+ }),
70
+ /**
71
+ * If the presence of a child affects the layout of the components around it,
72
+ * we want to make a new context value to ensure they get re-rendered
73
+ * so they can detect that layout change.
74
+ */
75
+ // @ts-expect-error its ok
76
+ presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]);
77
+ return React.useMemo(() => {
78
+ presenceChildren.forEach((_, key) => presenceChildren.set(key, !1));
79
+ }, [isPresent]), React.useEffect(() => {
80
+ !isPresent && !presenceChildren.size && onExitComplete?.();
81
+ }, [isPresent]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, {
82
+ value: context,
83
+ children
84
+ });
85
+ });
86
+ function newChildrenMap() {
87
+ return /* @__PURE__ */new Map();
88
+ }
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./AnimatePresence.cjs"), module.exports);
19
+ __reExport(src_exports, require("@tamagui/use-presence"), module.exports);
20
+ __reExport(src_exports, require("./types.cjs"), module.exports);
21
+ __reExport(src_exports, require("./PresenceChild.cjs"), module.exports);
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ };
12
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
+ value: !0
14
+ }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/animate-presence",
3
- "version": "1.114.4",
3
+ "version": "1.115.0",
4
4
  "source": "src/index.ts",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -13,14 +13,14 @@
13
13
  "dist"
14
14
  ],
15
15
  "dependencies": {
16
- "@tamagui/helpers": "1.114.4",
17
- "@tamagui/use-constant": "1.114.4",
18
- "@tamagui/use-force-update": "1.114.4",
19
- "@tamagui/use-presence": "1.114.4",
20
- "@tamagui/web": "1.114.4"
16
+ "@tamagui/helpers": "1.115.0",
17
+ "@tamagui/use-constant": "1.115.0",
18
+ "@tamagui/use-force-update": "1.115.0",
19
+ "@tamagui/use-presence": "1.115.0",
20
+ "@tamagui/web": "1.115.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@tamagui/build": "1.114.4"
23
+ "@tamagui/build": "1.115.0"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tamagui-build",
@@ -37,7 +37,8 @@
37
37
  "react-native": "./dist/cjs/index.native.js",
38
38
  "types": "./types/index.d.ts",
39
39
  "import": "./dist/esm/index.mjs",
40
- "require": "./dist/cjs/index.js"
40
+ "require": "./dist/cjs/index.cjs",
41
+ "default": "./dist/cjs/index.native.js"
41
42
  }
42
43
  },
43
44
  "publishConfig": {
@@ -1,116 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var AnimatePresence_exports = {};
16
- __export(AnimatePresence_exports, {
17
- AnimatePresence: () => AnimatePresence
18
- });
19
- module.exports = __toCommonJS(AnimatePresence_exports);
20
- var import_use_force_update = require("@tamagui/use-force-update"), import_react = require("react"), import_LayoutGroupContext = require("./LayoutGroupContext"), import_PresenceChild = require("./PresenceChild"), import_jsx_runtime = require("react/jsx-runtime");
21
- const getChildKey = (child) => child.key || "";
22
- function updateChildLookup(children, allChildren) {
23
- children.forEach((child) => {
24
- const key = getChildKey(child);
25
- allChildren.set(key, child);
26
- });
27
- }
28
- function onlyElements(children) {
29
- const filtered = [];
30
- return import_react.Children.forEach(children, (child) => {
31
- (0, import_react.isValidElement)(child) && filtered.push(child);
32
- }), filtered;
33
- }
34
- const AnimatePresence = ({
35
- children,
36
- enterVariant,
37
- exitVariant,
38
- enterExitVariant,
39
- initial = !0,
40
- onExitComplete,
41
- exitBeforeEnter,
42
- presenceAffectsLayout = !0,
43
- custom
44
- }) => {
45
- let forceRender = (0, import_react.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender ?? (0, import_use_force_update.useForceUpdate)();
46
- const filteredChildren = onlyElements(children), presentChildren = (0, import_react.useRef)(filteredChildren), allChildren = (0, import_react.useRef)(/* @__PURE__ */ new Map()).current, exiting = (0, import_react.useRef)(/* @__PURE__ */ new Set()).current;
47
- updateChildLookup(filteredChildren, allChildren);
48
- const isInitialRender = (0, import_react.useRef)(!0);
49
- if (isInitialRender.current)
50
- return isInitialRender.current = !1, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: filteredChildren.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
51
- import_PresenceChild.PresenceChild,
52
- {
53
- isPresent: !0,
54
- enterExitVariant,
55
- exitVariant,
56
- enterVariant,
57
- initial: initial ? void 0 : !1,
58
- presenceAffectsLayout,
59
- custom,
60
- children: child
61
- },
62
- getChildKey(child)
63
- )) });
64
- let childrenToRender = [...filteredChildren];
65
- const presentKeys = presentChildren.current.map(getChildKey), targetKeys = filteredChildren.map(getChildKey), numPresent = presentKeys.length;
66
- for (let i = 0; i < numPresent; i++) {
67
- const key = presentKeys[i];
68
- targetKeys.indexOf(key) === -1 ? exiting.add(key) : exiting.delete(key);
69
- }
70
- return exitBeforeEnter && exiting.size && (childrenToRender = []), exiting.forEach((key) => {
71
- if (targetKeys.indexOf(key) !== -1) return;
72
- const child = allChildren.get(key);
73
- if (!child) return;
74
- const insertionIndex = presentKeys.indexOf(key), exitingComponent = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
- import_PresenceChild.PresenceChild,
76
- {
77
- isPresent: !1,
78
- onExitComplete: () => {
79
- allChildren.delete(key), exiting.delete(key);
80
- const removeIndex = presentChildren.current.findIndex(
81
- (presentChild) => presentChild.key === key
82
- );
83
- presentChildren.current.splice(removeIndex, 1), exiting.size || (presentChildren.current = filteredChildren, forceRender(), onExitComplete?.());
84
- },
85
- presenceAffectsLayout,
86
- enterExitVariant,
87
- enterVariant,
88
- exitVariant,
89
- custom,
90
- children: child
91
- },
92
- getChildKey(child)
93
- );
94
- childrenToRender.splice(insertionIndex, 0, exitingComponent);
95
- }), childrenToRender = childrenToRender.map((child) => {
96
- const key = child.key;
97
- return exiting.has(key) ? child : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
- import_PresenceChild.PresenceChild,
99
- {
100
- isPresent: !0,
101
- exitVariant,
102
- enterVariant,
103
- enterExitVariant,
104
- presenceAffectsLayout,
105
- custom,
106
- children: child
107
- },
108
- getChildKey(child)
109
- );
110
- }), presentChildren.current = childrenToRender, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: exiting.size ? childrenToRender : (
111
- // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
112
- childrenToRender.map((child) => (0, import_react.cloneElement)(child))
113
- ) });
114
- };
115
- AnimatePresence.displayName = "AnimatePresence";
116
- //# sourceMappingURL=AnimatePresence.js.map
@@ -1,77 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var PresenceChild_exports = {};
24
- __export(PresenceChild_exports, {
25
- PresenceChild: () => PresenceChild
26
- });
27
- module.exports = __toCommonJS(PresenceChild_exports);
28
- var import_use_constant = require("@tamagui/use-constant"), import_use_presence = require("@tamagui/use-presence"), React = __toESM(require("react")), import_react = require("react"), import_jsx_runtime = require("react/jsx-runtime");
29
- const PresenceChild = React.memo(
30
- ({
31
- children,
32
- initial,
33
- isPresent,
34
- onExitComplete,
35
- exitVariant,
36
- enterVariant,
37
- enterExitVariant,
38
- presenceAffectsLayout,
39
- custom
40
- }) => {
41
- const presenceChildren = (0, import_use_constant.useConstant)(newChildrenMap), id = (0, import_react.useId)() || "", context = React.useMemo(
42
- () => ({
43
- id,
44
- initial,
45
- isPresent,
46
- custom,
47
- exitVariant,
48
- enterVariant,
49
- enterExitVariant,
50
- onExitComplete: () => {
51
- presenceChildren.set(id, !0);
52
- for (const isComplete of presenceChildren.values())
53
- if (!isComplete)
54
- return;
55
- onExitComplete?.();
56
- },
57
- register: () => (presenceChildren.set(id, !1), () => presenceChildren.delete(id))
58
- }),
59
- /**
60
- * If the presence of a child affects the layout of the components around it,
61
- * we want to make a new context value to ensure they get re-rendered
62
- * so they can detect that layout change.
63
- */
64
- // @ts-expect-error its ok
65
- presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]
66
- );
67
- return React.useMemo(() => {
68
- presenceChildren.forEach((_, key) => presenceChildren.set(key, !1));
69
- }, [isPresent]), React.useEffect(() => {
70
- !isPresent && !presenceChildren.size && onExitComplete?.();
71
- }, [isPresent]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, { value: context, children });
72
- }
73
- );
74
- function newChildrenMap() {
75
- return /* @__PURE__ */ new Map();
76
- }
77
- //# sourceMappingURL=PresenceChild.js.map
package/dist/cjs/index.js DELETED
@@ -1,18 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- __reExport(src_exports, require("./AnimatePresence"), module.exports);
15
- __reExport(src_exports, require("@tamagui/use-presence"), module.exports);
16
- __reExport(src_exports, require("./types"), module.exports);
17
- __reExport(src_exports, require("./PresenceChild"), module.exports);
18
- //# sourceMappingURL=index.js.map
package/dist/cjs/types.js DELETED
@@ -1,14 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- };
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var types_exports = {};
13
- module.exports = __toCommonJS(types_exports);
14
- //# sourceMappingURL=types.js.map
File without changes
File without changes