@hanzogui/animate-presence 8.3.0 → 8.3.2
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/dist/cjs/AnimatePresence.js +161 -0
- package/dist/cjs/AnimatePresence.js.map +1 -0
- package/dist/cjs/LayoutGroupContext.js +7 -0
- package/dist/cjs/LayoutGroupContext.js.map +1 -0
- package/dist/cjs/PresenceChild.js +60 -0
- package/dist/cjs/PresenceChild.js.map +1 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/AnimatePresence.js +157 -0
- package/dist/esm/AnimatePresence.js.map +1 -0
- package/dist/esm/LayoutGroupContext.js +3 -0
- package/dist/esm/LayoutGroupContext.js.map +1 -0
- package/dist/esm/PresenceChild.js +56 -0
- package/dist/esm/PresenceChild.js.map +1 -0
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +19 -19
- package/src/AnimatePresence.tsx +3 -3
- package/src/PresenceChild.tsx +1 -1
- package/src/index.ts +3 -3
- package/types/AnimatePresence.d.ts +1 -1
- package/types/AnimatePresence.d.ts.map +1 -1
- package/types/PresenceChild.d.ts +2 -2
- package/types/PresenceChild.d.ts.map +1 -1
- package/types/index.d.ts +3 -3
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/AnimatePresence.cjs +0 -149
- package/dist/cjs/AnimatePresence.native.js +0 -166
- package/dist/cjs/AnimatePresence.native.js.map +0 -1
- package/dist/cjs/LayoutGroupContext.cjs +0 -40
- package/dist/cjs/LayoutGroupContext.native.js +0 -43
- package/dist/cjs/LayoutGroupContext.native.js.map +0 -1
- package/dist/cjs/PresenceChild.cjs +0 -101
- package/dist/cjs/PresenceChild.native.js +0 -128
- package/dist/cjs/PresenceChild.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -23
- package/dist/cjs/index.native.js +0 -26
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/cjs/types.cjs +0 -18
- package/dist/cjs/types.native.js +0 -21
- package/dist/cjs/types.native.js.map +0 -1
- package/dist/esm/AnimatePresence.mjs +0 -124
- package/dist/esm/AnimatePresence.mjs.map +0 -1
- package/dist/esm/AnimatePresence.native.js +0 -138
- package/dist/esm/AnimatePresence.native.js.map +0 -1
- package/dist/esm/LayoutGroupContext.mjs +0 -4
- package/dist/esm/LayoutGroupContext.mjs.map +0 -1
- package/dist/esm/LayoutGroupContext.native.js +0 -4
- package/dist/esm/LayoutGroupContext.native.js.map +0 -1
- package/dist/esm/PresenceChild.mjs +0 -65
- package/dist/esm/PresenceChild.mjs.map +0 -1
- package/dist/esm/PresenceChild.native.js +0 -89
- package/dist/esm/PresenceChild.native.js.map +0 -1
- package/dist/esm/index.mjs +0 -5
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -5
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js +0 -2
- package/dist/esm/types.native.js.map +0 -1
|
@@ -1,128 +0,0 @@
|
|
|
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 PresenceChild_exports = {};
|
|
37
|
-
__export(PresenceChild_exports, {
|
|
38
|
-
PresenceChild: () => PresenceChild
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(PresenceChild_exports);
|
|
41
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
-
var import_use_constant = require("@hanzogui/use-constant");
|
|
43
|
-
var import_use_presence = require("@hanzogui/use-presence");
|
|
44
|
-
var React = __toESM(require("react"), 1);
|
|
45
|
-
var import_react = require("react");
|
|
46
|
-
var PresenceChild = /* @__PURE__ */React.memo(function (param) {
|
|
47
|
-
var {
|
|
48
|
-
children,
|
|
49
|
-
initial,
|
|
50
|
-
isPresent,
|
|
51
|
-
onExitComplete,
|
|
52
|
-
exitVariant,
|
|
53
|
-
enterVariant,
|
|
54
|
-
enterExitVariant,
|
|
55
|
-
presenceAffectsLayout,
|
|
56
|
-
custom
|
|
57
|
-
} = param;
|
|
58
|
-
var presenceChildren = (0, import_use_constant.useConstant)(newChildrenMap);
|
|
59
|
-
var id = (0, import_react.useId)() || "";
|
|
60
|
-
var context = React.useMemo(function () {
|
|
61
|
-
return {
|
|
62
|
-
id,
|
|
63
|
-
initial,
|
|
64
|
-
isPresent,
|
|
65
|
-
custom,
|
|
66
|
-
exitVariant,
|
|
67
|
-
enterVariant,
|
|
68
|
-
enterExitVariant,
|
|
69
|
-
onExitComplete: function () {
|
|
70
|
-
presenceChildren.set(id, true);
|
|
71
|
-
var _iteratorNormalCompletion = true,
|
|
72
|
-
_didIteratorError = false,
|
|
73
|
-
_iteratorError = void 0;
|
|
74
|
-
try {
|
|
75
|
-
for (var _iterator = presenceChildren.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
76
|
-
var isComplete = _step.value;
|
|
77
|
-
if (!isComplete) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} catch (err) {
|
|
82
|
-
_didIteratorError = true;
|
|
83
|
-
_iteratorError = err;
|
|
84
|
-
} finally {
|
|
85
|
-
try {
|
|
86
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
87
|
-
_iterator.return();
|
|
88
|
-
}
|
|
89
|
-
} finally {
|
|
90
|
-
if (_didIteratorError) {
|
|
91
|
-
throw _iteratorError;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
|
|
96
|
-
},
|
|
97
|
-
register: function () {
|
|
98
|
-
presenceChildren.set(id, false);
|
|
99
|
-
return function () {
|
|
100
|
-
return presenceChildren.delete(id);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* If the presence of a child affects the layout of the components around it,
|
|
107
|
-
* we want to make a new context value to ensure they get re-rendered
|
|
108
|
-
* so they can detect that layout change.
|
|
109
|
-
*/
|
|
110
|
-
// @ts-expect-error its ok
|
|
111
|
-
presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]);
|
|
112
|
-
React.useMemo(function () {
|
|
113
|
-
presenceChildren.forEach(function (_, key) {
|
|
114
|
-
return presenceChildren.set(key, false);
|
|
115
|
-
});
|
|
116
|
-
}, [isPresent]);
|
|
117
|
-
React.useEffect(function () {
|
|
118
|
-
!isPresent && !presenceChildren.size && (onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete());
|
|
119
|
-
}, [isPresent]);
|
|
120
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, {
|
|
121
|
-
value: context,
|
|
122
|
-
children
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
function newChildrenMap() {
|
|
126
|
-
return /* @__PURE__ */new Map();
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=PresenceChild.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","PresenceChild_exports","__export","PresenceChild","module","exports","import_jsx_runtime","require","import_use_constant","import_use_presence","React","__toESM","import_react","memo","param","children","initial","isPresent","onExitComplete","exitVariant","enterVariant","enterExitVariant","presenceAffectsLayout","custom","presenceChildren","useConstant","newChildrenMap","id","useId","context","useMemo","set","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","values","Symbol","iterator","_step","next","done","isComplete","err","return","register","delete"],"sources":["../../src/PresenceChild.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,aAAA,EAAAA,CAAA,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AS,MAAiB;YACnB;UACA,UAAU;YACR,IAAAX,iBAAqB,EAAI;cACzB,MAAOC,cAAM;YACf;UACF;QACF;QAAAhB,cAAA,aAAAA,cAAA,uBAAAA,cAAA;MAAA;MAAA2B,QAAA,WAAAA,CAAA;QAAArB,gBAAA,CAAAO,GAAA,CAAAJ,EAAA;QAAA;UAAA,OAAAH,gBAAA,CAAAsB,MAAA,CAAAnB,EAAA;QAQA;MACF;IAEA;EACE;EACF;AAMA;AACE;AAAyD;AAG3D;EACF;EACFL,qBAAA,aAEAL,SAAS,EACPE,WAAO,EACTC,YAAA,C","ignoreList":[]}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,23 +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)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
-
get: () => from[key],
|
|
9
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
}), mod);
|
|
18
|
-
var index_exports = {};
|
|
19
|
-
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./AnimatePresence.cjs"), module.exports);
|
|
21
|
-
__reExport(index_exports, require("@hanzogui/use-presence"), module.exports);
|
|
22
|
-
__reExport(index_exports, require("./types.cjs"), module.exports);
|
|
23
|
-
__reExport(index_exports, require("./PresenceChild.cjs"), module.exports);
|
package/dist/cjs/index.native.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
-
get: () => from[key],
|
|
11
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
}), mod);
|
|
20
|
-
var index_exports = {};
|
|
21
|
-
module.exports = __toCommonJS(index_exports);
|
|
22
|
-
__reExport(index_exports, require("./AnimatePresence.native.js"), module.exports);
|
|
23
|
-
__reExport(index_exports, require("@hanzogui/use-presence"), module.exports);
|
|
24
|
-
__reExport(index_exports, require("./types.native.js"), module.exports);
|
|
25
|
-
__reExport(index_exports, require("./PresenceChild.native.js"), module.exports);
|
|
26
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,iCAAAH,MADd,CAAAC,OAAA;AAEAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,yBAFd,GAAAH,MAAA,CAAAC,OAAA;AAGAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,uBAAAH,MAAA,CAAAC,OAHd","ignoreList":[]}
|
package/dist/cjs/types.cjs
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)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
-
get: () => from[key],
|
|
9
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
}), mod);
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
package/dist/cjs/types.native.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
-
get: () => from[key],
|
|
11
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
}), mod);
|
|
19
|
-
var types_exports = {};
|
|
20
|
-
module.exports = __toCommonJS(types_exports);
|
|
21
|
-
//# sourceMappingURL=types.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","types_exports"],"sources":["../../src/types.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA","ignoreList":[]}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { useInsertionEffect } from "react";
|
|
2
|
-
import { useConstant } from "@hanzogui/use-constant";
|
|
3
|
-
import { useForceUpdate } from "@hanzogui/use-force-update";
|
|
4
|
-
import { Children, isValidElement, useContext, useMemo, useRef, useState } from "react";
|
|
5
|
-
import { LayoutGroupContext } from "./LayoutGroupContext.mjs";
|
|
6
|
-
import { PresenceChild } from "./PresenceChild.mjs";
|
|
7
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
8
|
-
const getChildKey = child => {
|
|
9
|
-
return child.key || (() => {
|
|
10
|
-
const ct = child.type;
|
|
11
|
-
const defaultName = ct["displayName"] || ct["name"] || "";
|
|
12
|
-
if (ct && typeof ct === "object" && "staticConfig" in ct) {
|
|
13
|
-
return ct.staticConfig.componentName || defaultName;
|
|
14
|
-
}
|
|
15
|
-
return defaultName;
|
|
16
|
-
})();
|
|
17
|
-
};
|
|
18
|
-
function onlyElements(children) {
|
|
19
|
-
const filtered = [];
|
|
20
|
-
Children.forEach(children, child => {
|
|
21
|
-
if (isValidElement(child)) filtered.push(child);
|
|
22
|
-
});
|
|
23
|
-
return filtered;
|
|
24
|
-
}
|
|
25
|
-
const AnimatePresence = ({
|
|
26
|
-
children,
|
|
27
|
-
enterVariant,
|
|
28
|
-
exitVariant,
|
|
29
|
-
enterExitVariant,
|
|
30
|
-
initial = true,
|
|
31
|
-
onExitComplete,
|
|
32
|
-
exitBeforeEnter,
|
|
33
|
-
mode,
|
|
34
|
-
presenceAffectsLayout = true,
|
|
35
|
-
custom,
|
|
36
|
-
passThrough
|
|
37
|
-
}) => {
|
|
38
|
-
const effectiveMode = mode ?? (exitBeforeEnter ? "wait" : "sync");
|
|
39
|
-
const presentChildren = useMemo(() => onlyElements(children), [children]);
|
|
40
|
-
const presentKeys = presentChildren.map(getChildKey);
|
|
41
|
-
const isInitialRender = useRef(true);
|
|
42
|
-
const frozenCustomRef = useRef(/* @__PURE__ */new Map());
|
|
43
|
-
const pendingPresentChildren = useRef(presentChildren);
|
|
44
|
-
const exitComplete = useConstant(() => /* @__PURE__ */new Map());
|
|
45
|
-
const [diffedChildren, setDiffedChildren] = useState(presentChildren);
|
|
46
|
-
const [renderedChildren, setRenderedChildren] = useState(presentChildren);
|
|
47
|
-
const forceRender = useContext(LayoutGroupContext).forceRender ?? useForceUpdate();
|
|
48
|
-
if (passThrough) {
|
|
49
|
-
return /* @__PURE__ */jsx(Fragment, {
|
|
50
|
-
children
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
useInsertionEffect(() => {
|
|
54
|
-
isInitialRender.current = false;
|
|
55
|
-
pendingPresentChildren.current = presentChildren;
|
|
56
|
-
for (let i = 0; i < renderedChildren.length; i++) {
|
|
57
|
-
const key = getChildKey(renderedChildren[i]);
|
|
58
|
-
if (!presentKeys.includes(key)) {
|
|
59
|
-
if (exitComplete.get(key) !== true) {
|
|
60
|
-
exitComplete.set(key, false);
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
exitComplete.delete(key);
|
|
64
|
-
frozenCustomRef.current.delete(key);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
|
|
68
|
-
if (presentChildren !== diffedChildren) {
|
|
69
|
-
let nextChildren = [...presentChildren];
|
|
70
|
-
for (let i = 0; i < renderedChildren.length; i++) {
|
|
71
|
-
const child = renderedChildren[i];
|
|
72
|
-
const key = getChildKey(child);
|
|
73
|
-
if (!presentKeys.includes(key)) {
|
|
74
|
-
nextChildren.splice(i, 0, child);
|
|
75
|
-
if (!frozenCustomRef.current.has(key)) {
|
|
76
|
-
frozenCustomRef.current.set(key, custom);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const exitingChildren = renderedChildren.filter(child => !presentKeys.includes(getChildKey(child)));
|
|
81
|
-
if (effectiveMode === "wait" && exitingChildren.length) {
|
|
82
|
-
nextChildren = exitingChildren;
|
|
83
|
-
}
|
|
84
|
-
setRenderedChildren(onlyElements(nextChildren));
|
|
85
|
-
setDiffedChildren(presentChildren);
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
return /* @__PURE__ */jsx(Fragment, {
|
|
89
|
-
children: renderedChildren.map(child => {
|
|
90
|
-
const key = getChildKey(child);
|
|
91
|
-
const isPresent = presentChildren === renderedChildren || presentKeys.includes(key);
|
|
92
|
-
const onExit = () => {
|
|
93
|
-
if (exitComplete.has(key)) {
|
|
94
|
-
exitComplete.set(key, true);
|
|
95
|
-
} else {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
let isEveryExitComplete = true;
|
|
99
|
-
exitComplete.forEach(isExitComplete => {
|
|
100
|
-
if (!isExitComplete) isEveryExitComplete = false;
|
|
101
|
-
});
|
|
102
|
-
if (isEveryExitComplete) {
|
|
103
|
-
forceRender?.();
|
|
104
|
-
setRenderedChildren(pendingPresentChildren.current);
|
|
105
|
-
onExitComplete?.();
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
return /* @__PURE__ */jsx(PresenceChild, {
|
|
109
|
-
isPresent,
|
|
110
|
-
initial: !isInitialRender.current || initial ? void 0 : false,
|
|
111
|
-
custom: isPresent ? custom : frozenCustomRef.current.get(key) ?? custom,
|
|
112
|
-
presenceAffectsLayout,
|
|
113
|
-
enterExitVariant,
|
|
114
|
-
enterVariant,
|
|
115
|
-
exitVariant,
|
|
116
|
-
onExitComplete: isPresent ? void 0 : onExit,
|
|
117
|
-
children: child
|
|
118
|
-
}, key);
|
|
119
|
-
})
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
AnimatePresence.displayName = "AnimatePresence";
|
|
123
|
-
export { AnimatePresence };
|
|
124
|
-
//# sourceMappingURL=AnimatePresence.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useInsertionEffect","useConstant","useForceUpdate","Children","isValidElement","useContext","useMemo","useRef","useState","LayoutGroupContext","PresenceChild","Fragment","jsx","getChildKey","child","key","ct","type","defaultName","staticConfig","componentName","onlyElements","children","filtered","forEach","push","AnimatePresence","enterVariant","exitVariant","enterExitVariant","initial","onExitComplete","exitBeforeEnter","mode","presenceAffectsLayout","custom","passThrough","effectiveMode","presentChildren","presentKeys","map","isInitialRender","frozenCustomRef","Map","pendingPresentChildren","exitComplete","diffedChildren","setDiffedChildren","renderedChildren","setRenderedChildren","forceRender","current","i","length","includes","get","set","delete","join","nextChildren","splice","has","exitingChildren","filter","isPresent","onExit","isEveryExitComplete","isExitComplete","displayName"],"sources":["../../src/AnimatePresence.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AACnC,SAASC,WAAA,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8B,YAAA,CAAaW,GAAA,CAAIzC,GAAA,EAAK,IAAI;QAC5B,OAAO;UACL;QACF;QAEA,IAAImD,mBAAA,GAAsB;QAC1BrB,YAAA,CAAarB,OAAA,CAAS2C,cAAA,IAAmB;UACvC,IAAI,CAACA,cAAA,EAAgBD,mBAAA,GAAsB;QAC7C,CAAC;QAED,IAAIA,mBAAA,EAAqB;UACvBhB,WAAA,GAAc;UACdD,mBAAA,CAAoBL,sBAAA,CAAuBO,OAAO;UAClDpB,cAAA,GAAiB;QACnB;MACF;MAEA,OACE,eAAAnB,GAAA,CAACF,aAAA;QAECsD,SAAA;QACAlC,OAAA,EAAS,CAACW,eAAA,CAAgBU,OAAA,IAAWrB,OAAA,GAAU,SAAY;QAC3DK,MAAA,EAAQ6B,SAAA,GAAY7B,MAAA,GAAUO,eAAA,CAAgBS,OAAA,CAAQI,GAAA,CAAIxC,GAAG,KAAKoB,MAAA;QAClED,qBAAA;QACAL,gBAAA;QACAF,YAAA;QACAC,WAAA;QACAG,cAAA,EAAgBiC,SAAA,GAAY,SAAYC,MAAA;QAEvC3C,QAAA,EAAAR;MAAA,GAVIC,GAWP;IAEJ,CAAC;EAAA,CACH;AAEJ;AAEAW,eAAA,CAAgB0C,WAAA,GAAc","ignoreList":[]}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useInsertionEffect } from "react";
|
|
3
|
-
import { useConstant } from "@hanzogui/use-constant";
|
|
4
|
-
import { useForceUpdate } from "@hanzogui/use-force-update";
|
|
5
|
-
import { Children, isValidElement, useContext, useMemo, useRef, useState } from "react";
|
|
6
|
-
import { LayoutGroupContext } from "./LayoutGroupContext.native.js";
|
|
7
|
-
import { PresenceChild } from "./PresenceChild.native.js";
|
|
8
|
-
function _type_of(obj) {
|
|
9
|
-
"@swc/helpers - typeof";
|
|
10
|
-
|
|
11
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
12
|
-
}
|
|
13
|
-
var getChildKey = function (child) {
|
|
14
|
-
return child.key || function () {
|
|
15
|
-
var ct = child.type;
|
|
16
|
-
var defaultName = ct["displayName"] || ct["name"] || "";
|
|
17
|
-
if (ct && (typeof ct === "undefined" ? "undefined" : _type_of(ct)) === "object" && "staticConfig" in ct) {
|
|
18
|
-
return ct.staticConfig.componentName || defaultName;
|
|
19
|
-
}
|
|
20
|
-
return defaultName;
|
|
21
|
-
}();
|
|
22
|
-
};
|
|
23
|
-
function onlyElements(children) {
|
|
24
|
-
var filtered = [];
|
|
25
|
-
Children.forEach(children, function (child) {
|
|
26
|
-
if (/* @__PURE__ */isValidElement(child)) filtered.push(child);
|
|
27
|
-
});
|
|
28
|
-
return filtered;
|
|
29
|
-
}
|
|
30
|
-
var AnimatePresence = function (param) {
|
|
31
|
-
var {
|
|
32
|
-
children,
|
|
33
|
-
enterVariant,
|
|
34
|
-
exitVariant,
|
|
35
|
-
enterExitVariant,
|
|
36
|
-
initial = true,
|
|
37
|
-
onExitComplete,
|
|
38
|
-
exitBeforeEnter,
|
|
39
|
-
mode,
|
|
40
|
-
presenceAffectsLayout = true,
|
|
41
|
-
custom,
|
|
42
|
-
passThrough
|
|
43
|
-
} = param;
|
|
44
|
-
var effectiveMode = mode !== null && mode !== void 0 ? mode : exitBeforeEnter ? "wait" : "sync";
|
|
45
|
-
var presentChildren = useMemo(function () {
|
|
46
|
-
return onlyElements(children);
|
|
47
|
-
}, [children]);
|
|
48
|
-
var presentKeys = presentChildren.map(getChildKey);
|
|
49
|
-
var isInitialRender = useRef(true);
|
|
50
|
-
var frozenCustomRef = useRef(/* @__PURE__ */new Map());
|
|
51
|
-
var pendingPresentChildren = useRef(presentChildren);
|
|
52
|
-
var exitComplete = useConstant(function () {
|
|
53
|
-
return /* @__PURE__ */new Map();
|
|
54
|
-
});
|
|
55
|
-
var [diffedChildren, setDiffedChildren] = useState(presentChildren);
|
|
56
|
-
var [renderedChildren, setRenderedChildren] = useState(presentChildren);
|
|
57
|
-
var _useContext_forceRender;
|
|
58
|
-
var forceRender = (_useContext_forceRender = useContext(LayoutGroupContext).forceRender) !== null && _useContext_forceRender !== void 0 ? _useContext_forceRender : useForceUpdate();
|
|
59
|
-
if (passThrough) {
|
|
60
|
-
return /* @__PURE__ */_jsx(_Fragment, {
|
|
61
|
-
children
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
useInsertionEffect(function () {
|
|
65
|
-
isInitialRender.current = false;
|
|
66
|
-
pendingPresentChildren.current = presentChildren;
|
|
67
|
-
for (var i2 = 0; i2 < renderedChildren.length; i2++) {
|
|
68
|
-
var key2 = getChildKey(renderedChildren[i2]);
|
|
69
|
-
if (!presentKeys.includes(key2)) {
|
|
70
|
-
if (exitComplete.get(key2) !== true) {
|
|
71
|
-
exitComplete.set(key2, false);
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
exitComplete.delete(key2);
|
|
75
|
-
frozenCustomRef.current.delete(key2);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
|
|
79
|
-
if (presentChildren !== diffedChildren) {
|
|
80
|
-
var nextChildren = [...presentChildren];
|
|
81
|
-
for (var i = 0; i < renderedChildren.length; i++) {
|
|
82
|
-
var child = renderedChildren[i];
|
|
83
|
-
var key = getChildKey(child);
|
|
84
|
-
if (!presentKeys.includes(key)) {
|
|
85
|
-
nextChildren.splice(i, 0, child);
|
|
86
|
-
if (!frozenCustomRef.current.has(key)) {
|
|
87
|
-
frozenCustomRef.current.set(key, custom);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
var exitingChildren = renderedChildren.filter(function (child2) {
|
|
92
|
-
return !presentKeys.includes(getChildKey(child2));
|
|
93
|
-
});
|
|
94
|
-
if (effectiveMode === "wait" && exitingChildren.length) {
|
|
95
|
-
nextChildren = exitingChildren;
|
|
96
|
-
}
|
|
97
|
-
setRenderedChildren(onlyElements(nextChildren));
|
|
98
|
-
setDiffedChildren(presentChildren);
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
return /* @__PURE__ */_jsx(_Fragment, {
|
|
102
|
-
children: renderedChildren.map(function (child2) {
|
|
103
|
-
var key2 = getChildKey(child2);
|
|
104
|
-
var isPresent = presentChildren === renderedChildren || presentKeys.includes(key2);
|
|
105
|
-
var onExit = function () {
|
|
106
|
-
if (exitComplete.has(key2)) {
|
|
107
|
-
exitComplete.set(key2, true);
|
|
108
|
-
} else {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
var isEveryExitComplete = true;
|
|
112
|
-
exitComplete.forEach(function (isExitComplete) {
|
|
113
|
-
if (!isExitComplete) isEveryExitComplete = false;
|
|
114
|
-
});
|
|
115
|
-
if (isEveryExitComplete) {
|
|
116
|
-
forceRender === null || forceRender === void 0 ? void 0 : forceRender();
|
|
117
|
-
setRenderedChildren(pendingPresentChildren.current);
|
|
118
|
-
onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
var _frozenCustomRef_current_get;
|
|
122
|
-
return /* @__PURE__ */_jsx(PresenceChild, {
|
|
123
|
-
isPresent,
|
|
124
|
-
initial: !isInitialRender.current || initial ? void 0 : false,
|
|
125
|
-
custom: isPresent ? custom : (_frozenCustomRef_current_get = frozenCustomRef.current.get(key2)) !== null && _frozenCustomRef_current_get !== void 0 ? _frozenCustomRef_current_get : custom,
|
|
126
|
-
presenceAffectsLayout,
|
|
127
|
-
enterExitVariant,
|
|
128
|
-
enterVariant,
|
|
129
|
-
exitVariant,
|
|
130
|
-
onExitComplete: isPresent ? void 0 : onExit,
|
|
131
|
-
children: child2
|
|
132
|
-
}, key2);
|
|
133
|
-
})
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
AnimatePresence.displayName = "AnimatePresence";
|
|
137
|
-
export { AnimatePresence };
|
|
138
|
-
//# sourceMappingURL=AnimatePresence.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","Fragment","_Fragment","useInsertionEffect","useConstant","useForceUpdate","Children","isValidElement","useContext","useMemo","useRef","useState","LayoutGroupContext","PresenceChild","_type_of","obj","Symbol","constructor","getChildKey","child","key","ct","type","defaultName","staticConfig","componentName","onlyElements","children","filtered","forEach","push","AnimatePresence","param","enterVariant","exitVariant","enterExitVariant","initial","onExitComplete","exitBeforeEnter","mode","presenceAffectsLayout","custom","passThrough","effectiveMode","presentChildren","presentKeys","map","isInitialRender","frozenCustomRef","Map","pendingPresentChildren","exitComplete","diffedChildren","setDiffedChildren","renderedChildren","setRenderedChildren","_useContext_forceRender","forceRender","current","i2","length","key2","includes","get","set","delete","join","nextChildren","i","splice","has","exitingChildren","filter","child2","isPresent","onExit","isEveryExitComplete","isExitComplete","_frozenCustomRef_current_get"],"sources":["../../src/AnimatePresence.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAA0B;AACnC,SAASC,kBAAA,QAAmB;AAC5B,SAASC,WAAA,gCAAsB;AAE/B,SAASC,cAAU,oCAAqC;AACxD,SAASC,QAAA,EAAAC,cAAA,EAA0BC,UAAA,EAAAC,OAAA,EAAAC,MAAA,EAAAC,QAAA;AACnC,SAASC,kBAAA,QAAqB;AAiGnB,SAAAC,aAAA;AA5FX,SAAMC,SAAAC,GAAe;EACnB,uBAEG;;EAEC,OAAAA,GAAM,IAAK,OAAMC,MAAA,oBAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AACjB;AACA,IAAAG,WAAU,YAAAA,CAAOC,KAAO;EAEtB,OAAAA,KAAO,CAAAC,GAAG,gBAAa;IACzB,IAAAC,EAAA,GAAAF,KAAA,CAAAG,IAAA;IACA,IAAAC,WAAO,GAAAF,EAAA,mBAAAA,EAAA;IACT,IAAGA,EAA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F,IAAA,eAAAiB,4BAAA,cAAAA,4BAAA,GAAArC,MAAA;QAWPD,qBAAA;QAGNL,gBAAA;QAEJF,YAAA;QAEAC,WAAgB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","LayoutGroupContext","createContext"],"sources":["../../src/LayoutGroupContext.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAOX,MAAMC,kBAAA,GAAqBD,KAAA,CAAME,aAAA,CAAuC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","LayoutGroupContext","createContext"],"sources":["../../src/LayoutGroupContext.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAOX,IAAAC,kBAAM,kBAA2BD,KAAA,CAAuCE,aAAE","ignoreList":[]}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useConstant } from "@hanzogui/use-constant";
|
|
2
|
-
import { PresenceContext } from "@hanzogui/use-presence";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { useId } from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
const PresenceChild = React.memo(({
|
|
7
|
-
children,
|
|
8
|
-
initial,
|
|
9
|
-
isPresent,
|
|
10
|
-
onExitComplete,
|
|
11
|
-
exitVariant,
|
|
12
|
-
enterVariant,
|
|
13
|
-
enterExitVariant,
|
|
14
|
-
presenceAffectsLayout,
|
|
15
|
-
custom
|
|
16
|
-
}) => {
|
|
17
|
-
const presenceChildren = useConstant(newChildrenMap);
|
|
18
|
-
const id = useId() || "";
|
|
19
|
-
const context = React.useMemo(() => {
|
|
20
|
-
return {
|
|
21
|
-
id,
|
|
22
|
-
initial,
|
|
23
|
-
isPresent,
|
|
24
|
-
custom,
|
|
25
|
-
exitVariant,
|
|
26
|
-
enterVariant,
|
|
27
|
-
enterExitVariant,
|
|
28
|
-
onExitComplete: () => {
|
|
29
|
-
presenceChildren.set(id, true);
|
|
30
|
-
for (const isComplete of presenceChildren.values()) {
|
|
31
|
-
if (!isComplete) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
onExitComplete?.();
|
|
36
|
-
},
|
|
37
|
-
register: () => {
|
|
38
|
-
presenceChildren.set(id, false);
|
|
39
|
-
return () => presenceChildren.delete(id);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
/**
|
|
44
|
-
* If the presence of a child affects the layout of the components around it,
|
|
45
|
-
* we want to make a new context value to ensure they get re-rendered
|
|
46
|
-
* so they can detect that layout change.
|
|
47
|
-
*/
|
|
48
|
-
// @ts-expect-error its ok
|
|
49
|
-
presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]);
|
|
50
|
-
React.useMemo(() => {
|
|
51
|
-
presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
|
|
52
|
-
}, [isPresent]);
|
|
53
|
-
React.useEffect(() => {
|
|
54
|
-
!isPresent && !presenceChildren.size && onExitComplete?.();
|
|
55
|
-
}, [isPresent]);
|
|
56
|
-
return /* @__PURE__ */jsx(PresenceContext.Provider, {
|
|
57
|
-
value: context,
|
|
58
|
-
children
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
function newChildrenMap() {
|
|
62
|
-
return /* @__PURE__ */new Map();
|
|
63
|
-
}
|
|
64
|
-
export { PresenceChild };
|
|
65
|
-
//# sourceMappingURL=PresenceChild.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useConstant","PresenceContext","React","useId","jsx","PresenceChild","memo","children","initial","isPresent","onExitComplete","exitVariant","enterVariant","enterExitVariant","presenceAffectsLayout","custom","presenceChildren","newChildrenMap","id","context","useMemo","set","isComplete","values","register","delete","forEach","_","key","useEffect","size","Provider","value","Map"],"sources":["../../src/PresenceChild.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAA,QAAmB;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