@hanzogui/animate-presence 7.0.0 → 7.3.1

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 (47) hide show
  1. package/LICENSE +40 -19
  2. package/dist/cjs/AnimatePresence.cjs +149 -0
  3. package/dist/cjs/AnimatePresence.native.js +166 -0
  4. package/dist/cjs/AnimatePresence.native.js.map +1 -0
  5. package/dist/cjs/LayoutGroupContext.cjs +40 -0
  6. package/dist/cjs/LayoutGroupContext.native.js +43 -0
  7. package/dist/cjs/LayoutGroupContext.native.js.map +1 -0
  8. package/dist/cjs/PresenceChild.cjs +101 -0
  9. package/dist/cjs/PresenceChild.native.js +128 -0
  10. package/dist/cjs/PresenceChild.native.js.map +1 -0
  11. package/dist/cjs/index.cjs +23 -0
  12. package/dist/cjs/index.native.js +26 -0
  13. package/dist/cjs/index.native.js.map +1 -0
  14. package/dist/cjs/types.cjs +18 -0
  15. package/dist/cjs/types.native.js +21 -0
  16. package/dist/cjs/types.native.js.map +1 -0
  17. package/dist/esm/AnimatePresence.mjs +124 -0
  18. package/dist/esm/AnimatePresence.mjs.map +1 -0
  19. package/dist/esm/AnimatePresence.native.js +138 -0
  20. package/dist/esm/AnimatePresence.native.js.map +1 -0
  21. package/dist/esm/LayoutGroupContext.mjs +4 -0
  22. package/dist/esm/LayoutGroupContext.mjs.map +1 -0
  23. package/dist/esm/LayoutGroupContext.native.js +4 -0
  24. package/dist/esm/LayoutGroupContext.native.js.map +1 -0
  25. package/dist/esm/PresenceChild.mjs +65 -0
  26. package/dist/esm/PresenceChild.mjs.map +1 -0
  27. package/dist/esm/PresenceChild.native.js +89 -0
  28. package/dist/esm/PresenceChild.native.js.map +1 -0
  29. package/dist/esm/index.js +5 -0
  30. package/dist/esm/index.js.map +1 -0
  31. package/dist/esm/index.mjs +5 -0
  32. package/dist/esm/index.mjs.map +1 -0
  33. package/dist/esm/index.native.js +5 -0
  34. package/dist/esm/index.native.js.map +1 -0
  35. package/dist/esm/types.mjs +2 -0
  36. package/dist/esm/types.mjs.map +1 -0
  37. package/dist/esm/types.native.js +2 -0
  38. package/dist/esm/types.native.js.map +1 -0
  39. package/package.json +16 -15
  40. package/src/AnimatePresence.tsx +1 -1
  41. package/types/AnimatePresence.d.ts.map +1 -0
  42. package/types/LayoutGroupContext.d.ts.map +1 -0
  43. package/types/PresenceChild.d.ts +1 -1
  44. package/types/PresenceChild.d.ts.map +1 -0
  45. package/types/index.d.ts.map +1 -0
  46. package/types/types.d.ts.map +1 -0
  47. package/LICENSE.md +0 -9
package/LICENSE CHANGED
@@ -1,21 +1,42 @@
1
- MIT License
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026-present, Hanzo AI, Inc.
4
+
5
+ Portions of this software are derived from upstream code originally licensed under
6
+ the MIT License, with the following copyright notices retained per its terms:
2
7
 
3
8
  Copyright (c) 2020 Nate Wienert
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
9
+ Copyright (c) 2015-present, Nicolas Gallagher.
10
+ Copyright (c) 2015-present, Facebook, Inc.
11
+ Copyright (c) 2021 Radix
12
+ Copyright (c) 2017 Carmelo Pullara
13
+ Copyright (c) 2018 Framer B.V.
14
+ Copyright (c) 2022 WorkOS
15
+
16
+ All rights reserved.
17
+
18
+ Redistribution and use in source and binary forms, with or without
19
+ modification, are permitted provided that the following conditions are met:
20
+
21
+ 1. Redistributions of source code must retain the above copyright notice, this
22
+ list of conditions and the following disclaimer.
23
+
24
+ 2. Redistributions in binary form must reproduce the above copyright notice,
25
+ this list of conditions and the following disclaimer in the documentation
26
+ and/or other materials provided with the distribution.
27
+
28
+ 3. Neither the name of the copyright holder nor the names of its contributors
29
+ may be used to endorse or promote products derived from this software
30
+ without specific prior written permission.
31
+
32
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
36
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,149 @@
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: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var AnimatePresence_exports = {};
24
+ __export(AnimatePresence_exports, {
25
+ AnimatePresence: () => AnimatePresence
26
+ });
27
+ module.exports = __toCommonJS(AnimatePresence_exports);
28
+ var import_react = require("react");
29
+ var import_use_constant = require("@hanzogui/use-constant");
30
+ var import_use_force_update = require("@hanzogui/use-force-update");
31
+ var import_react2 = require("react");
32
+ var import_LayoutGroupContext = require("./LayoutGroupContext.cjs");
33
+ var import_PresenceChild = require("./PresenceChild.cjs");
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ const getChildKey = child => {
36
+ return child.key || (() => {
37
+ const ct = child.type;
38
+ const defaultName = ct["displayName"] || ct["name"] || "";
39
+ if (ct && typeof ct === "object" && "staticConfig" in ct) {
40
+ return ct.staticConfig.componentName || defaultName;
41
+ }
42
+ return defaultName;
43
+ })();
44
+ };
45
+ function onlyElements(children) {
46
+ const filtered = [];
47
+ import_react2.Children.forEach(children, child => {
48
+ if ((0, import_react2.isValidElement)(child)) filtered.push(child);
49
+ });
50
+ return filtered;
51
+ }
52
+ const AnimatePresence = ({
53
+ children,
54
+ enterVariant,
55
+ exitVariant,
56
+ enterExitVariant,
57
+ initial = true,
58
+ onExitComplete,
59
+ exitBeforeEnter,
60
+ mode,
61
+ presenceAffectsLayout = true,
62
+ custom,
63
+ passThrough
64
+ }) => {
65
+ const effectiveMode = mode ?? (exitBeforeEnter ? "wait" : "sync");
66
+ const presentChildren = (0, import_react2.useMemo)(() => onlyElements(children), [children]);
67
+ const presentKeys = presentChildren.map(getChildKey);
68
+ const isInitialRender = (0, import_react2.useRef)(true);
69
+ const frozenCustomRef = (0, import_react2.useRef)(/* @__PURE__ */new Map());
70
+ const pendingPresentChildren = (0, import_react2.useRef)(presentChildren);
71
+ const exitComplete = (0, import_use_constant.useConstant)(() => /* @__PURE__ */new Map());
72
+ const [diffedChildren, setDiffedChildren] = (0, import_react2.useState)(presentChildren);
73
+ const [renderedChildren, setRenderedChildren] = (0, import_react2.useState)(presentChildren);
74
+ const forceRender = (0, import_react2.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender ?? (0, import_use_force_update.useForceUpdate)();
75
+ if (passThrough) {
76
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
77
+ children
78
+ });
79
+ }
80
+ (0, import_react.useInsertionEffect)(() => {
81
+ isInitialRender.current = false;
82
+ pendingPresentChildren.current = presentChildren;
83
+ for (let i = 0; i < renderedChildren.length; i++) {
84
+ const key = getChildKey(renderedChildren[i]);
85
+ if (!presentKeys.includes(key)) {
86
+ if (exitComplete.get(key) !== true) {
87
+ exitComplete.set(key, false);
88
+ }
89
+ } else {
90
+ exitComplete.delete(key);
91
+ frozenCustomRef.current.delete(key);
92
+ }
93
+ }
94
+ }, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
95
+ if (presentChildren !== diffedChildren) {
96
+ let nextChildren = [...presentChildren];
97
+ for (let i = 0; i < renderedChildren.length; i++) {
98
+ const child = renderedChildren[i];
99
+ const key = getChildKey(child);
100
+ if (!presentKeys.includes(key)) {
101
+ nextChildren.splice(i, 0, child);
102
+ if (!frozenCustomRef.current.has(key)) {
103
+ frozenCustomRef.current.set(key, custom);
104
+ }
105
+ }
106
+ }
107
+ const exitingChildren = renderedChildren.filter(child => !presentKeys.includes(getChildKey(child)));
108
+ if (effectiveMode === "wait" && exitingChildren.length) {
109
+ nextChildren = exitingChildren;
110
+ }
111
+ setRenderedChildren(onlyElements(nextChildren));
112
+ setDiffedChildren(presentChildren);
113
+ return null;
114
+ }
115
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
116
+ children: renderedChildren.map(child => {
117
+ const key = getChildKey(child);
118
+ const isPresent = presentChildren === renderedChildren || presentKeys.includes(key);
119
+ const onExit = () => {
120
+ if (exitComplete.has(key)) {
121
+ exitComplete.set(key, true);
122
+ } else {
123
+ return;
124
+ }
125
+ let isEveryExitComplete = true;
126
+ exitComplete.forEach(isExitComplete => {
127
+ if (!isExitComplete) isEveryExitComplete = false;
128
+ });
129
+ if (isEveryExitComplete) {
130
+ forceRender?.();
131
+ setRenderedChildren(pendingPresentChildren.current);
132
+ onExitComplete?.();
133
+ }
134
+ };
135
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
136
+ isPresent,
137
+ initial: !isInitialRender.current || initial ? void 0 : false,
138
+ custom: isPresent ? custom : frozenCustomRef.current.get(key) ?? custom,
139
+ presenceAffectsLayout,
140
+ enterExitVariant,
141
+ enterVariant,
142
+ exitVariant,
143
+ onExitComplete: isPresent ? void 0 : onExit,
144
+ children: child
145
+ }, key);
146
+ })
147
+ });
148
+ };
149
+ AnimatePresence.displayName = "AnimatePresence";
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var AnimatePresence_exports = {};
26
+ __export(AnimatePresence_exports, {
27
+ AnimatePresence: () => AnimatePresence
28
+ });
29
+ module.exports = __toCommonJS(AnimatePresence_exports);
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ var import_react = require("react");
32
+ var import_use_constant = require("@hanzogui/use-constant");
33
+ var import_use_force_update = require("@hanzogui/use-force-update");
34
+ var import_react2 = require("react");
35
+ var import_LayoutGroupContext = require("./LayoutGroupContext.native.js");
36
+ var import_PresenceChild = require("./PresenceChild.native.js");
37
+ function _type_of(obj) {
38
+ "@swc/helpers - typeof";
39
+
40
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
41
+ }
42
+ var getChildKey = function (child) {
43
+ return child.key || function () {
44
+ var ct = child.type;
45
+ var defaultName = ct["displayName"] || ct["name"] || "";
46
+ if (ct && (typeof ct === "undefined" ? "undefined" : _type_of(ct)) === "object" && "staticConfig" in ct) {
47
+ return ct.staticConfig.componentName || defaultName;
48
+ }
49
+ return defaultName;
50
+ }();
51
+ };
52
+ function onlyElements(children) {
53
+ var filtered = [];
54
+ import_react2.Children.forEach(children, function (child) {
55
+ if (/* @__PURE__ */(0, import_react2.isValidElement)(child)) filtered.push(child);
56
+ });
57
+ return filtered;
58
+ }
59
+ var AnimatePresence = function (param) {
60
+ var {
61
+ children,
62
+ enterVariant,
63
+ exitVariant,
64
+ enterExitVariant,
65
+ initial = true,
66
+ onExitComplete,
67
+ exitBeforeEnter,
68
+ mode,
69
+ presenceAffectsLayout = true,
70
+ custom,
71
+ passThrough
72
+ } = param;
73
+ var effectiveMode = mode !== null && mode !== void 0 ? mode : exitBeforeEnter ? "wait" : "sync";
74
+ var presentChildren = (0, import_react2.useMemo)(function () {
75
+ return onlyElements(children);
76
+ }, [children]);
77
+ var presentKeys = presentChildren.map(getChildKey);
78
+ var isInitialRender = (0, import_react2.useRef)(true);
79
+ var frozenCustomRef = (0, import_react2.useRef)(/* @__PURE__ */new Map());
80
+ var pendingPresentChildren = (0, import_react2.useRef)(presentChildren);
81
+ var exitComplete = (0, import_use_constant.useConstant)(function () {
82
+ return /* @__PURE__ */new Map();
83
+ });
84
+ var [diffedChildren, setDiffedChildren] = (0, import_react2.useState)(presentChildren);
85
+ var [renderedChildren, setRenderedChildren] = (0, import_react2.useState)(presentChildren);
86
+ var _useContext_forceRender;
87
+ var forceRender = (_useContext_forceRender = (0, import_react2.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender) !== null && _useContext_forceRender !== void 0 ? _useContext_forceRender : (0, import_use_force_update.useForceUpdate)();
88
+ if (passThrough) {
89
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
90
+ children
91
+ });
92
+ }
93
+ (0, import_react.useInsertionEffect)(function () {
94
+ isInitialRender.current = false;
95
+ pendingPresentChildren.current = presentChildren;
96
+ for (var i2 = 0; i2 < renderedChildren.length; i2++) {
97
+ var key2 = getChildKey(renderedChildren[i2]);
98
+ if (!presentKeys.includes(key2)) {
99
+ if (exitComplete.get(key2) !== true) {
100
+ exitComplete.set(key2, false);
101
+ }
102
+ } else {
103
+ exitComplete.delete(key2);
104
+ frozenCustomRef.current.delete(key2);
105
+ }
106
+ }
107
+ }, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
108
+ if (presentChildren !== diffedChildren) {
109
+ var nextChildren = [...presentChildren];
110
+ for (var i = 0; i < renderedChildren.length; i++) {
111
+ var child = renderedChildren[i];
112
+ var key = getChildKey(child);
113
+ if (!presentKeys.includes(key)) {
114
+ nextChildren.splice(i, 0, child);
115
+ if (!frozenCustomRef.current.has(key)) {
116
+ frozenCustomRef.current.set(key, custom);
117
+ }
118
+ }
119
+ }
120
+ var exitingChildren = renderedChildren.filter(function (child2) {
121
+ return !presentKeys.includes(getChildKey(child2));
122
+ });
123
+ if (effectiveMode === "wait" && exitingChildren.length) {
124
+ nextChildren = exitingChildren;
125
+ }
126
+ setRenderedChildren(onlyElements(nextChildren));
127
+ setDiffedChildren(presentChildren);
128
+ return null;
129
+ }
130
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
131
+ children: renderedChildren.map(function (child2) {
132
+ var key2 = getChildKey(child2);
133
+ var isPresent = presentChildren === renderedChildren || presentKeys.includes(key2);
134
+ var onExit = function () {
135
+ if (exitComplete.has(key2)) {
136
+ exitComplete.set(key2, true);
137
+ } else {
138
+ return;
139
+ }
140
+ var isEveryExitComplete = true;
141
+ exitComplete.forEach(function (isExitComplete) {
142
+ if (!isExitComplete) isEveryExitComplete = false;
143
+ });
144
+ if (isEveryExitComplete) {
145
+ forceRender === null || forceRender === void 0 ? void 0 : forceRender();
146
+ setRenderedChildren(pendingPresentChildren.current);
147
+ onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
148
+ }
149
+ };
150
+ var _frozenCustomRef_current_get;
151
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
152
+ isPresent,
153
+ initial: !isInitialRender.current || initial ? void 0 : false,
154
+ custom: isPresent ? custom : (_frozenCustomRef_current_get = frozenCustomRef.current.get(key2)) !== null && _frozenCustomRef_current_get !== void 0 ? _frozenCustomRef_current_get : custom,
155
+ presenceAffectsLayout,
156
+ enterExitVariant,
157
+ enterVariant,
158
+ exitVariant,
159
+ onExitComplete: isPresent ? void 0 : onExit,
160
+ children: child2
161
+ }, key2);
162
+ })
163
+ });
164
+ };
165
+ AnimatePresence.displayName = "AnimatePresence";
166
+ //# sourceMappingURL=AnimatePresence.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","AnimatePresence_exports","AnimatePresence","module","exports","import_jsx_runtime","require","import_react","import_use_constant","import_use_force_update","import_react2","import_LayoutGroupContext","import_PresenceChild","_type_of","obj","Symbol","constructor","getChildKey","child","ct","type","defaultName","staticConfig","componentName","onlyElements","children","filtered","Children","forEach","isValidElement","push","param","enterVariant","exitVariant","enterExitVariant","initial","onExitComplete","exitBeforeEnter","mode","presenceAffectsLayout","custom","passThrough","effectiveMode","presentChildren","useMemo","presentKeys","map","isInitialRender","useRef","frozenCustomRef","Map","pendingPresentChildren","exitComplete","useConstant","diffedChildren","setDiffedChildren","useState","renderedChildren","setRenderedChildren","_useContext_forceRender","forceRender","useContext","LayoutGroupContext","useForceUpdate","jsx","Fragment","useInsertionEffect","current","i2","length","key2","includes","set","delete","join","nextChildren","i","splice","has","exitingChildren","filter","child2","isPresent","onExit","isEveryExitComplete","isExitComplete","_frozenCustomRef_current_get","PresenceChild","displayName"],"sources":["AnimatePresence.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar AnimatePresence_exports = {};\n__export(AnimatePresence_exports, {\n AnimatePresence: () => AnimatePresence\n});\nmodule.exports = __toCommonJS(AnimatePresence_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_react = require(\"react\");\nvar import_use_constant = require(\"@hanzogui/use-constant\");\nvar import_use_force_update = require(\"@hanzogui/use-force-update\");\nvar import_react2 = require(\"react\");\nvar import_LayoutGroupContext = require(\"./LayoutGroupContext\");\nvar import_PresenceChild = require(\"./PresenceChild\");\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nvar getChildKey = function(child) {\n return child.key || (function() {\n var ct = child.type;\n var defaultName = ct[\"displayName\"] || ct[\"name\"] || \"\";\n if (ct && (typeof ct === \"undefined\" ? \"undefined\" : _type_of(ct)) === \"object\" && \"staticConfig\" in ct) {\n return ct.staticConfig.componentName || defaultName;\n }\n return defaultName;\n })();\n};\nfunction onlyElements(children) {\n var filtered = [];\n import_react2.Children.forEach(children, function(child) {\n if (/* @__PURE__ */ (0, import_react2.isValidElement)(child)) filtered.push(child);\n });\n return filtered;\n}\nvar AnimatePresence = function(param) {\n var { children, enterVariant, exitVariant, enterExitVariant, initial = true, onExitComplete, exitBeforeEnter, mode, presenceAffectsLayout = true, custom, passThrough } = param;\n var effectiveMode = mode !== null && mode !== void 0 ? mode : exitBeforeEnter ? \"wait\" : \"sync\";\n var presentChildren = (0, import_react2.useMemo)(function() {\n return onlyElements(children);\n }, [\n children\n ]);\n var presentKeys = presentChildren.map(getChildKey);\n var isInitialRender = (0, import_react2.useRef)(true);\n var frozenCustomRef = (0, import_react2.useRef)(/* @__PURE__ */ new Map());\n var pendingPresentChildren = (0, import_react2.useRef)(presentChildren);\n var exitComplete = (0, import_use_constant.useConstant)(function() {\n return /* @__PURE__ */ new Map();\n });\n var [diffedChildren, setDiffedChildren] = (0, import_react2.useState)(presentChildren);\n var [renderedChildren, setRenderedChildren] = (0, import_react2.useState)(presentChildren);\n var _useContext_forceRender;\n var forceRender = (_useContext_forceRender = (0, import_react2.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender) !== null && _useContext_forceRender !== void 0 ? _useContext_forceRender : (0, import_use_force_update.useForceUpdate)();\n if (passThrough) {\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {\n children\n });\n }\n (0, import_react.useInsertionEffect)(function() {\n isInitialRender.current = false;\n pendingPresentChildren.current = presentChildren;\n for (var i2 = 0; i2 < renderedChildren.length; i2++) {\n var key2 = getChildKey(renderedChildren[i2]);\n if (!presentKeys.includes(key2)) {\n if (exitComplete.get(key2) !== true) {\n exitComplete.set(key2, false);\n }\n } else {\n exitComplete.delete(key2);\n frozenCustomRef.current.delete(key2);\n }\n }\n }, [\n renderedChildren,\n presentKeys.length,\n presentKeys.join(\"-\")\n ]);\n if (presentChildren !== diffedChildren) {\n var nextChildren = [\n ...presentChildren\n ];\n for (var i = 0; i < renderedChildren.length; i++) {\n var child = renderedChildren[i];\n var key = getChildKey(child);\n if (!presentKeys.includes(key)) {\n nextChildren.splice(i, 0, child);\n if (!frozenCustomRef.current.has(key)) {\n frozenCustomRef.current.set(key, custom);\n }\n }\n }\n var exitingChildren = renderedChildren.filter(function(child2) {\n return !presentKeys.includes(getChildKey(child2));\n });\n if (effectiveMode === \"wait\" && exitingChildren.length) {\n nextChildren = exitingChildren;\n }\n setRenderedChildren(onlyElements(nextChildren));\n setDiffedChildren(presentChildren);\n return null;\n }\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {\n children: renderedChildren.map(function(child2) {\n var key2 = getChildKey(child2);\n var isPresent = presentChildren === renderedChildren || presentKeys.includes(key2);\n var onExit = function() {\n if (exitComplete.has(key2)) {\n exitComplete.set(key2, true);\n } else {\n return;\n }\n var isEveryExitComplete = true;\n exitComplete.forEach(function(isExitComplete) {\n if (!isExitComplete) isEveryExitComplete = false;\n });\n if (isEveryExitComplete) {\n forceRender === null || forceRender === void 0 ? void 0 : forceRender();\n setRenderedChildren(pendingPresentChildren.current);\n onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();\n }\n };\n var _frozenCustomRef_current_get;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {\n isPresent,\n initial: !isInitialRender.current || initial ? void 0 : false,\n custom: isPresent ? custom : (_frozenCustomRef_current_get = frozenCustomRef.current.get(key2)) !== null && _frozenCustomRef_current_get !== void 0 ? _frozenCustomRef_current_get : custom,\n presenceAffectsLayout,\n enterExitVariant,\n enterVariant,\n exitVariant,\n onExitComplete: isPresent ? void 0 : onExit,\n children: child2\n }, key2);\n })\n });\n};\nAnimatePresence.displayName = \"AnimatePresence\";\n//# sourceMappingURL=AnimatePresence.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG,EAClBZ,SAAS,CAACW,MAAM,EAAEE,IAAI,EAAE;IAAEC,GAAG,EAAEF,GAAG,CAACC,IAAI,CAAC;IAAEE,UAAU,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC;AACD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,KAAK;EAC5C,IAAIF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;IAClE,KAAK,IAAIG,GAAG,IAAIhB,iBAAiB,CAACa,IAAI,CAAC,EACrC,IAAI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AED,mBAAmB,GAAG,KAAK;QAClD,CAAC,CAAC;QACF,IAAIA,mBAAmB,EAAE;UACvBxB,WAAW,KAAK,IAAI,IAAIA,WAAW,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,WAAW,CAAC,CAAC;UACvEF,mBAAmB,CAACP,sBAAsB,CAACgB,OAAO,CAAC;UACnD/B,cAAc,KAAK,IAAI,IAAIA,cAAc,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,cAAc,CAAC,CAAC;QAClF;MACF,CAAC;MACD,IAAIkD,4BAA4B;MAChC,OAAO,eAAgB,CAAC,CAAC,EAAEjF,kBAAkB,CAAC2D,GAAG,EAAEpD,oBAAoB,CAAC2E,aAAa,EAAE;QACrFL,SAAS;QACT/C,OAAO,EAAE,CAACY,eAAe,CAACoB,OAAO,IAAIhC,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK;QAC7DK,MAAM,EAAE0C,SAAS,GAAG1C,MAAM,GAAG,CAAC8C,4BAA4B,GAAGrC,eAAe,CAACkB,OAAO,CAAC9E,GAAG,CAACiF,IAAI,CAAC,MAAM,IAAI,IAAIgB,4BAA4B,KAAK,KAAK,CAAC,GAAGA,4BAA4B,GAAG9C,MAAM;QAC3LD,qBAAqB;QACrBL,gBAAgB;QAChBF,YAAY;QACZC,WAAW;QACXG,cAAc,EAAE8C,SAAS,GAAG,KAAK,CAAC,GAAGC,MAAM;QAC3C1D,QAAQ,EAAEwD;MACZ,CAAC,EAAEX,IAAI,CAAC;IACV,CAAC;EACH,CAAC,CAAC;AACJ,CAAC;AACDpE,eAAe,CAACsF,WAAW,GAAG,iBAAiB","ignoreList":[]}
@@ -0,0 +1,40 @@
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
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
34
+ var LayoutGroupContext_exports = {};
35
+ __export(LayoutGroupContext_exports, {
36
+ LayoutGroupContext: () => LayoutGroupContext
37
+ });
38
+ module.exports = __toCommonJS(LayoutGroupContext_exports);
39
+ var import_react = __toESM(require("react"), 1);
40
+ const LayoutGroupContext = import_react.default.createContext({});
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
+ value: true
35
+ }), mod);
36
+ var LayoutGroupContext_exports = {};
37
+ __export(LayoutGroupContext_exports, {
38
+ LayoutGroupContext: () => LayoutGroupContext
39
+ });
40
+ module.exports = __toCommonJS(LayoutGroupContext_exports);
41
+ var import_react = __toESM(require("react"), 1);
42
+ var LayoutGroupContext = /* @__PURE__ */import_react.default.createContext({});
43
+ //# sourceMappingURL=LayoutGroupContext.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","LayoutGroupContext_exports","LayoutGroupContext","module","exports","import_react","require","default","createContext"],"sources":["LayoutGroupContext.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar LayoutGroupContext_exports = {};\n__export(LayoutGroupContext_exports, {\n LayoutGroupContext: () => LayoutGroupContext\n});\nmodule.exports = __toCommonJS(LayoutGroupContext_exports);\nvar import_react = __toESM(require(\"react\"), 1);\nvar LayoutGroupContext = /* @__PURE__ */ import_react.default.createContext({});\n//# sourceMappingURL=LayoutGroupContext.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,QAAQ,GAAGC,MAAM,CAACC,MAAM;AAC5B,IAAIC,SAAS,GAAGF,MAAM,CAACG,cAAc;AACrC,IAAIC,gBAAgB,GAAGJ,MAAM,CAACK,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGN,MAAM,CAACO,mBAAmB;AAClD,IAAIC,YAAY,GAAGR,MAAM,CAACS,cAAc;AACxC,IAAIC,YAAY,GAAGV,MAAM,CAACW,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG,E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,EAAE;EAAE4B,KAAK,EAAE;AAAK,CAAC,CAAC,EAAEH,GAAG,CAAC;AAC1F,IAAIK,0BAA0B,GAAG,CAAC,CAAC;AACnCnB,QAAQ,CAACmB,0BAA0B,EAAE;EACnCC,kBAAkB,EAAEA,CAAA,KAAMA;AAC5B,CAAC,CAAC;AACFC,MAAM,CAACC,OAAO,GAAGJ,YAAY,CAACC,0BAA0B,CAAC;AACzD,IAAII,YAAY,GAAGV,OAAO,CAACW,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC/C,IAAIJ,kBAAkB,GAAG,eAAgBG,YAAY,CAACE,OAAO,CAACC,aAAa,CAAC,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,101 @@
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
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
34
+ var PresenceChild_exports = {};
35
+ __export(PresenceChild_exports, {
36
+ PresenceChild: () => PresenceChild
37
+ });
38
+ module.exports = __toCommonJS(PresenceChild_exports);
39
+ var import_use_constant = require("@hanzogui/use-constant");
40
+ var import_use_presence = require("@hanzogui/use-presence");
41
+ var React = __toESM(require("react"), 1);
42
+ var import_react = require("react");
43
+ var import_jsx_runtime = require("react/jsx-runtime");
44
+ const PresenceChild = React.memo(({
45
+ children,
46
+ initial,
47
+ isPresent,
48
+ onExitComplete,
49
+ exitVariant,
50
+ enterVariant,
51
+ enterExitVariant,
52
+ presenceAffectsLayout,
53
+ custom
54
+ }) => {
55
+ const presenceChildren = (0, import_use_constant.useConstant)(newChildrenMap);
56
+ const id = (0, import_react.useId)() || "";
57
+ const context = React.useMemo(() => {
58
+ return {
59
+ id,
60
+ initial,
61
+ isPresent,
62
+ custom,
63
+ exitVariant,
64
+ enterVariant,
65
+ enterExitVariant,
66
+ onExitComplete: () => {
67
+ presenceChildren.set(id, true);
68
+ for (const isComplete of presenceChildren.values()) {
69
+ if (!isComplete) {
70
+ return;
71
+ }
72
+ }
73
+ onExitComplete?.();
74
+ },
75
+ register: () => {
76
+ presenceChildren.set(id, false);
77
+ return () => presenceChildren.delete(id);
78
+ }
79
+ };
80
+ },
81
+ /**
82
+ * If the presence of a child affects the layout of the components around it,
83
+ * we want to make a new context value to ensure they get re-rendered
84
+ * so they can detect that layout change.
85
+ */
86
+ // @ts-expect-error its ok
87
+ presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]);
88
+ React.useMemo(() => {
89
+ presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
90
+ }, [isPresent]);
91
+ React.useEffect(() => {
92
+ !isPresent && !presenceChildren.size && onExitComplete?.();
93
+ }, [isPresent]);
94
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, {
95
+ value: context,
96
+ children
97
+ });
98
+ });
99
+ function newChildrenMap() {
100
+ return /* @__PURE__ */new Map();
101
+ }