@hanzogui/animate-presence 8.3.1 → 8.3.3

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 (66) hide show
  1. package/dist/cjs/AnimatePresence.js +161 -0
  2. package/dist/cjs/AnimatePresence.js.map +1 -0
  3. package/dist/cjs/LayoutGroupContext.js +7 -0
  4. package/dist/cjs/LayoutGroupContext.js.map +1 -0
  5. package/dist/cjs/PresenceChild.js +60 -0
  6. package/dist/cjs/PresenceChild.js.map +1 -0
  7. package/dist/cjs/index.js +8 -0
  8. package/dist/cjs/index.js.map +1 -0
  9. package/dist/cjs/package.json +1 -0
  10. package/dist/cjs/types.js +3 -0
  11. package/dist/cjs/types.js.map +1 -0
  12. package/dist/esm/AnimatePresence.js +157 -0
  13. package/dist/esm/AnimatePresence.js.map +1 -0
  14. package/dist/esm/LayoutGroupContext.js +3 -0
  15. package/dist/esm/LayoutGroupContext.js.map +1 -0
  16. package/dist/esm/PresenceChild.js +56 -0
  17. package/dist/esm/PresenceChild.js.map +1 -0
  18. package/dist/esm/index.js +5 -5
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/types.js +2 -0
  21. package/dist/esm/types.js.map +1 -0
  22. package/package.json +24 -19
  23. package/src/AnimatePresence.tsx +3 -3
  24. package/src/PresenceChild.tsx +1 -1
  25. package/src/index.ts +3 -3
  26. package/types/AnimatePresence.d.ts +1 -1
  27. package/types/AnimatePresence.d.ts.map +1 -1
  28. package/types/PresenceChild.d.ts +2 -2
  29. package/types/PresenceChild.d.ts.map +1 -1
  30. package/types/index.d.ts +3 -3
  31. package/types/index.d.ts.map +1 -1
  32. package/dist/cjs/AnimatePresence.cjs +0 -149
  33. package/dist/cjs/AnimatePresence.native.js +0 -166
  34. package/dist/cjs/AnimatePresence.native.js.map +0 -1
  35. package/dist/cjs/LayoutGroupContext.cjs +0 -40
  36. package/dist/cjs/LayoutGroupContext.native.js +0 -43
  37. package/dist/cjs/LayoutGroupContext.native.js.map +0 -1
  38. package/dist/cjs/PresenceChild.cjs +0 -101
  39. package/dist/cjs/PresenceChild.native.js +0 -128
  40. package/dist/cjs/PresenceChild.native.js.map +0 -1
  41. package/dist/cjs/index.cjs +0 -23
  42. package/dist/cjs/index.native.js +0 -26
  43. package/dist/cjs/index.native.js.map +0 -1
  44. package/dist/cjs/types.cjs +0 -18
  45. package/dist/cjs/types.native.js +0 -21
  46. package/dist/cjs/types.native.js.map +0 -1
  47. package/dist/esm/AnimatePresence.mjs +0 -124
  48. package/dist/esm/AnimatePresence.mjs.map +0 -1
  49. package/dist/esm/AnimatePresence.native.js +0 -138
  50. package/dist/esm/AnimatePresence.native.js.map +0 -1
  51. package/dist/esm/LayoutGroupContext.mjs +0 -4
  52. package/dist/esm/LayoutGroupContext.mjs.map +0 -1
  53. package/dist/esm/LayoutGroupContext.native.js +0 -4
  54. package/dist/esm/LayoutGroupContext.native.js.map +0 -1
  55. package/dist/esm/PresenceChild.mjs +0 -65
  56. package/dist/esm/PresenceChild.mjs.map +0 -1
  57. package/dist/esm/PresenceChild.native.js +0 -89
  58. package/dist/esm/PresenceChild.native.js.map +0 -1
  59. package/dist/esm/index.mjs +0 -5
  60. package/dist/esm/index.mjs.map +0 -1
  61. package/dist/esm/index.native.js +0 -5
  62. package/dist/esm/index.native.js.map +0 -1
  63. package/dist/esm/types.mjs +0 -2
  64. package/dist/esm/types.mjs.map +0 -1
  65. package/dist/esm/types.native.js +0 -2
  66. package/dist/esm/types.native.js.map +0 -1
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './AnimatePresence'
1
+ export * from './AnimatePresence.tsx'
2
2
  export * from '@hanzogui/use-presence'
3
- export * from './types'
4
- export * from './PresenceChild'
3
+ export * from './types.ts'
4
+ export * from './PresenceChild.tsx'
@@ -1,4 +1,4 @@
1
1
  import type { FunctionComponent, PropsWithChildren } from 'react';
2
- import type { AnimatePresenceProps } from './types';
2
+ import type { AnimatePresenceProps } from './types.ts';
3
3
  export declare const AnimatePresence: FunctionComponent<PropsWithChildren<AnimatePresenceProps>>;
4
4
  //# sourceMappingURL=AnimatePresence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnimatePresence.d.ts","sourceRoot":"","sources":["../src/AnimatePresence.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAA2B,MAAM,OAAO,CAAA;AAI1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AA6BnD,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAC7C,iBAAiB,CAAC,oBAAoB,CAAC,CAmLxC,CAAA"}
1
+ {"version":3,"file":"AnimatePresence.d.ts","sourceRoot":"","sources":["../src/AnimatePresence.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAA2B,MAAM,OAAO,CAAA;AAI1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AA6BtD,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAC7C,iBAAiB,CAAC,oBAAoB,CAAC,CAmLxC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { VariantLabels } from './types';
2
+ import type { VariantLabels } from './types.ts';
3
3
  interface PresenceChildProps {
4
4
  children: React.ReactElement<any>;
5
5
  isPresent: boolean;
@@ -11,6 +11,6 @@ interface PresenceChildProps {
11
11
  enterVariant?: string | null;
12
12
  enterExitVariant?: string | null;
13
13
  }
14
- export declare const PresenceChild: React.MemoExoticComponent<({ children, initial, isPresent, onExitComplete, exitVariant, enterVariant, enterExitVariant, presenceAffectsLayout, custom, }: PresenceChildProps) => import("react/jsx-runtime").JSX.Element>;
14
+ export declare const PresenceChild: React.MemoExoticComponent<({ children, initial, isPresent, onExitComplete, exitVariant, enterVariant, enterExitVariant, presenceAffectsLayout, custom, }: PresenceChildProps) => React.JSX.Element>;
15
15
  export {};
16
16
  //# sourceMappingURL=PresenceChild.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PresenceChild.d.ts","sourceRoot":"","sources":["../src/PresenceChild.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IACjC,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAC3B,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAA;IAC/B,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC;AAGD,eAAO,MAAM,aAAa,4JAWrB,kBAAkB,6CAqDtB,CAAA"}
1
+ {"version":3,"file":"PresenceChild.d.ts","sourceRoot":"","sources":["../src/PresenceChild.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IACjC,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAC3B,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAA;IAC/B,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC;AAGD,eAAO,MAAM,aAAa,4JAWrB,kBAAkB,uBAqDtB,CAAA"}
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './AnimatePresence';
1
+ export * from './AnimatePresence.tsx';
2
2
  export * from '@hanzogui/use-presence';
3
- export * from './types';
4
- export * from './PresenceChild';
3
+ export * from './types.ts';
4
+ export * from './PresenceChild.tsx';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA"}
@@ -1,149 +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) __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";
@@ -1,166 +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 __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
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","AnimatePresence_exports","__export","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","key","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","get","set","delete","join","nextChildren","i","splice","has","exitingChildren","filter","child2","isPresent","onExit","isEveryExitComplete","isExitComplete","_frozenCustomRef_current_get","PresenceChild"],"sources":["../../src/AnimatePresence.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;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BACrB,CAAAZ,eAAA;IACL;EAAA;EAGF,sBAAI,IAAAvC,kBAAsB,CAAA4D,GAAA,EAAA5D,kBAAA,CAAA6D,QAAA;IAC1BxC,QAAA,EAAAgC,gBAAsB,CAAAX,GAAA,WAAAoC,MAAmB;MACvC,IAAAZ,IAAK,GAAAtD,WAAgB,CAAAkE,MAAA;MACvB,IAACC,SAAA,GAAAxC,eAAA,KAAAc,gBAAA,IAAAZ,WAAA,CAAA0B,QAAA,CAAAD,IAAA;MAED,IAAIc,MAAA,YAAAA,CAAA;QACF,IAAAhC,YAAc,CAAA2B,GAAA,CAAAT,IAAA;UACdlB,YAAA,CAAAqB,GAAA,CAAAH,IAAoB;QACpB;UACF;QACF;QAEA,IACEe,mBAAA;QAACjC,YAAA,CAAAxB,OAAA,WAAA0D,cAAA;UAAA,KAAAA,cAAA,EAAAD,mBAAA;QAEC;QACA,IAAAA,mBAAU;UACVzB,WAAQ,SAAY,IAAAA,WAAU,UAAgB,SAAQ,CAAI,GAAGA,WAAK;UAClEF,mBAAA,CAAAP,sBAAA,CAAAgB,OAAA;UACA/B,cAAA,aAAAA,cAAA,uBAAAA,cAAA;QACA;MAAA;MACA,IACAmD,4BAA4B;MAAY,OAEvC,mBAAAnF,kBAAA,CAAA4D,GAAA,EAAArD,oBAAA,CAAA6E,aAAA;QAAAL,SAAA;QAVIhD,OAAA,GAAAY,eAAA,CAAAoB,OAAA,IAAAhC,OAAA;QAWPK,MAAA,EAAA2C,SAAA,GAAA3C,MAAA,IAAA+C,4BAAA,GAAAtC,eAAA,CAAAkB,OAAA,CAAAK,GAAA,CAAAF,IAAA,eAAAiB,4BAAA,cAAAA,4BAAA,GAAA/C,MAAA;QAGND,qBAAA;QAEJL,gBAAA;QAEAF,YAAgB","ignoreList":[]}
@@ -1,40 +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;
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({});
@@ -1,43 +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 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
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","LayoutGroupContext_exports","__export","LayoutGroupContext","module","exports","import_react","__toESM","require"],"sources":["../../src/LayoutGroupContext.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAkB,CAAAK,0BAAA;AAOX,IAAAK,YAAM,GAAAC,OAAA,CAAqBC,OAAA","ignoreList":[]}
@@ -1,101 +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;
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
- }