@hanzogui/animate 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.
- package/LICENSE +40 -19
- package/dist/cjs/Animate.cjs +77 -0
- package/dist/cjs/Animate.native.js +81 -0
- package/dist/cjs/Animate.native.js.map +1 -0
- package/dist/cjs/index.cjs +20 -0
- package/dist/cjs/index.native.js +23 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/esm/Animate.mjs +52 -0
- package/dist/esm/Animate.mjs.map +1 -0
- package/dist/esm/Animate.native.js +53 -0
- package/dist/esm/Animate.native.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +2 -0
- package/dist/esm/index.native.js.map +1 -0
- package/package.json +11 -10
- package/types/Animate.d.ts.map +11 -0
- package/types/index.d.ts.map +11 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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,77 @@
|
|
|
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 Animate_exports = {};
|
|
24
|
+
__export(Animate_exports, {
|
|
25
|
+
Animate: () => Animate
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(Animate_exports);
|
|
28
|
+
var import_animate_presence = require("@hanzogui/animate-presence");
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function Animate({
|
|
32
|
+
children,
|
|
33
|
+
lazyMount,
|
|
34
|
+
type,
|
|
35
|
+
present,
|
|
36
|
+
passThrough,
|
|
37
|
+
...props
|
|
38
|
+
}) {
|
|
39
|
+
const [lazyMounted, setLazyMounted] = (0, import_react.useState)(lazyMount ? false : present);
|
|
40
|
+
(0, import_react.useEffect)(() => {
|
|
41
|
+
if (passThrough) return;
|
|
42
|
+
if (!lazyMount) return;
|
|
43
|
+
if (!present) return;
|
|
44
|
+
(0, import_react.startTransition)(() => {
|
|
45
|
+
setLazyMounted(present);
|
|
46
|
+
});
|
|
47
|
+
}, [lazyMount, present]);
|
|
48
|
+
const mounted = !present ? false : lazyMount ? lazyMounted : present;
|
|
49
|
+
if (type === "presence") {
|
|
50
|
+
if (props.keepChildrenMounted) {
|
|
51
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.PresenceChild, {
|
|
52
|
+
isPresent: true,
|
|
53
|
+
...(!passThrough && {
|
|
54
|
+
initial: props.initial ? void 0 : false,
|
|
55
|
+
onExitComplete: props.onExitComplete,
|
|
56
|
+
enterVariant: props.enterVariant,
|
|
57
|
+
exitVariant: props.exitVariant,
|
|
58
|
+
enterExitVariant: props.enterExitVariant,
|
|
59
|
+
// BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
|
|
60
|
+
// but since we always re-render this component on open changes this should be fine to leave off?
|
|
61
|
+
presenceAffectsLayout: false,
|
|
62
|
+
isPresent: present,
|
|
63
|
+
custom: props.custom
|
|
64
|
+
}),
|
|
65
|
+
children
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
|
|
69
|
+
passThrough,
|
|
70
|
+
...props,
|
|
71
|
+
children: mounted || passThrough ? children : null
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
75
|
+
children
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 Animate_exports = {};
|
|
26
|
+
__export(Animate_exports, {
|
|
27
|
+
Animate: () => Animate
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Animate_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_animate_presence = require("@hanzogui/animate-presence");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
function Animate(param) {
|
|
34
|
+
var {
|
|
35
|
+
children,
|
|
36
|
+
lazyMount,
|
|
37
|
+
type,
|
|
38
|
+
present,
|
|
39
|
+
passThrough,
|
|
40
|
+
...props
|
|
41
|
+
} = param;
|
|
42
|
+
var [lazyMounted, setLazyMounted] = (0, import_react.useState)(lazyMount ? false : present);
|
|
43
|
+
(0, import_react.useEffect)(function () {
|
|
44
|
+
if (passThrough) return;
|
|
45
|
+
if (!lazyMount) return;
|
|
46
|
+
if (!present) return;
|
|
47
|
+
(0, import_react.startTransition)(function () {
|
|
48
|
+
setLazyMounted(present);
|
|
49
|
+
});
|
|
50
|
+
}, [lazyMount, present]);
|
|
51
|
+
var mounted = !present ? false : lazyMount ? lazyMounted : present;
|
|
52
|
+
if (type === "presence") {
|
|
53
|
+
if (props.keepChildrenMounted) {
|
|
54
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.PresenceChild, {
|
|
55
|
+
isPresent: true,
|
|
56
|
+
...(!passThrough && {
|
|
57
|
+
initial: props.initial ? void 0 : false,
|
|
58
|
+
onExitComplete: props.onExitComplete,
|
|
59
|
+
enterVariant: props.enterVariant,
|
|
60
|
+
exitVariant: props.exitVariant,
|
|
61
|
+
enterExitVariant: props.enterExitVariant,
|
|
62
|
+
// BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
|
|
63
|
+
// but since we always re-render this component on open changes this should be fine to leave off?
|
|
64
|
+
presenceAffectsLayout: false,
|
|
65
|
+
isPresent: present,
|
|
66
|
+
custom: props.custom
|
|
67
|
+
}),
|
|
68
|
+
children
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
|
|
72
|
+
passThrough,
|
|
73
|
+
...props,
|
|
74
|
+
children: mounted || passThrough ? children : null
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
78
|
+
children
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=Animate.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Animate_exports","__export","Animate","module","exports","import_jsx_runtime","require","import_animate_presence","import_react","param","children","lazyMount","type","present","passThrough","props","lazyMounted","setLazyMounted","useState","useEffect","startTransition","mounted","keepChildrenMounted","jsx","PresenceChild","isPresent","initial","onExitComplete","enterVariant","exitVariant","enterExitVariant","presenceAffectsLayout","custom","AnimatePresence","Fragment"],"sources":["../../src/Animate.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,eAAA;AAAAC,QAAA,CAAAD,eAAA;EAAAE,OAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAA+CK,eAAA;AAC/C,IAAAK,kBAAqD,GAAAC,OAAA;AA4D7C,IAAAC,uBAAA,GAAAD,OAAA;AAzBD,IAAAE,YAAS,GAAQF,OAAA;AAAA,SACtBJ,QAAAO,KAAA;EACA;IAAAC,QAAA;IAAAC,SAAA;IAAAC,IAAA;IAAAC,OAAA;IAAAC,WAAA;IAAA,GAAAC;EAAA,IAAAN,KAAA;EACA,KAAAO,WAAA,EAAAC,cAAA,QAAAT,YAAA,CAAAU,QAAA,EAAAP,SAAA,WAAAE,OAAA;EACA,IAAAL,YAAA,CAAAW,SAAA;IACA,IAAAL,WAAA;IACA,IAAG,CAAAH,SAAA;IAC6B,KAAAE,OAAA;IAChC,IAAML,YAAC,CAAAY,eAA2B,cAAI;MAEtCH,cAAA,CAAAJ,OAAA;IACE;EACA,IACAF,SAAK,EACLE,OAAA,CACE;EAAsB,IACvBQ,OAAA,IAAAR,OAAA,WAAAF,SAAA,GAAAK,WAAA,GAAAH,OAAA;EACH,IAAID,IAAA,eAAmB;IAGvB,IAAMG,KAAA,CAAAO,mBAAqB;MAEvB,sBAAqB,IAAAjB,kBAAA,CAAAkB,GAAA,EAAAhB,uBAAA,CAAAiB,aAAA;QACnBC,SAAM;QACR,KAAAX,WACE;UAACY,OAAA,EAAAX,KAAA,CAAAW,OAAA;UAAAC,cAAA,EAAAZ,KAAA,CAAAY,cAAA;UACCC,YAAS,EAAAb,KAAA,CAAAa,YAAA;UACRC,WAAK,EAAAd,KAAA,CAAec,WAAA;UAAAC,gBACV,EAAMf,KAAA,CAAAe,gBAAsB;UAAA;UACf;UACFC,qBACD;UAAAN,SACnB,EAAAZ,OAAA;UAAwBmB,MAAA,EAAAjB,KAAA,CAAAiB;QAAA;QAAAtB;MAGD;IACZ;IACG,OAChB,mBAAAL,kBAAA,CAAAkB,GAAA,EAAAhB,uBAAA,CAAA0B,eAAA;MAAAnB,WAEC;MAAA,GAAAC,KAAA;MACHL,QAAA,EAAAW,OAAA,IAAAP,WAAA,GAAAJ,QAAA;IAEJ;EAEA;EAKF,0BAAAL,kBAAA,CAAAkB,GAAA,EAAAlB,kBAAA,CAAA6B,QAAA;IAEAxB;EACF","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./Animate.cjs"), module.exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
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("./Animate.native.js"), module.exports);
|
|
23
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"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","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AnimatePresence, PresenceChild } from "@hanzogui/animate-presence";
|
|
2
|
+
import { startTransition, useEffect, useState } from "react";
|
|
3
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
+
function Animate({
|
|
5
|
+
children,
|
|
6
|
+
lazyMount,
|
|
7
|
+
type,
|
|
8
|
+
present,
|
|
9
|
+
passThrough,
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
12
|
+
const [lazyMounted, setLazyMounted] = useState(lazyMount ? false : present);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (passThrough) return;
|
|
15
|
+
if (!lazyMount) return;
|
|
16
|
+
if (!present) return;
|
|
17
|
+
startTransition(() => {
|
|
18
|
+
setLazyMounted(present);
|
|
19
|
+
});
|
|
20
|
+
}, [lazyMount, present]);
|
|
21
|
+
const mounted = !present ? false : lazyMount ? lazyMounted : present;
|
|
22
|
+
if (type === "presence") {
|
|
23
|
+
if (props.keepChildrenMounted) {
|
|
24
|
+
return /* @__PURE__ */jsx(PresenceChild, {
|
|
25
|
+
isPresent: true,
|
|
26
|
+
...(!passThrough && {
|
|
27
|
+
initial: props.initial ? void 0 : false,
|
|
28
|
+
onExitComplete: props.onExitComplete,
|
|
29
|
+
enterVariant: props.enterVariant,
|
|
30
|
+
exitVariant: props.exitVariant,
|
|
31
|
+
enterExitVariant: props.enterExitVariant,
|
|
32
|
+
// BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
|
|
33
|
+
// but since we always re-render this component on open changes this should be fine to leave off?
|
|
34
|
+
presenceAffectsLayout: false,
|
|
35
|
+
isPresent: present,
|
|
36
|
+
custom: props.custom
|
|
37
|
+
}),
|
|
38
|
+
children
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */jsx(AnimatePresence, {
|
|
42
|
+
passThrough,
|
|
43
|
+
...props,
|
|
44
|
+
children: mounted || passThrough ? children : null
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */jsx(Fragment, {
|
|
48
|
+
children
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export { Animate };
|
|
52
|
+
//# sourceMappingURL=Animate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AnimatePresence","PresenceChild","startTransition","useEffect","useState","Fragment","jsx","Animate","children","lazyMount","type","present","passThrough","props","lazyMounted","setLazyMounted","mounted","keepChildrenMounted","isPresent","initial","onExitComplete","enterVariant","exitVariant","enterExitVariant","presenceAffectsLayout","custom"],"sources":["../../src/Animate.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,eAAA,EAAiBC,aAAA,QAAqB;AAC/C,SAASC,eAAA,EAAiBC,SAAA,EAAWC,QAAA,QAAgB;AA4D7C,SA2BCC,QAAA,EA3BDC,GAAA;AAzBD,SAASC,QAAQ;EACtBC,QAAA;EACAC,SAAA;EACAC,IAAA;EACAC,OAAA;EACAC,WAAA;EACA,GAAGC;AACL,GAAkC;EAChC,MAAM,CAACC,WAAA,EAAaC,cAAc,IAAIX,QAAA,CAASK,SAAA,GAAY,QAAQE,OAAO;EAE1ER,SAAA,CAAU,MAAM;IACd,IAAIS,WAAA,EAAa;IACjB,IAAI,CAACH,SAAA,EAAW;IAChB,IAAI,CAACE,OAAA,EAAS;IACdT,eAAA,CAAgB,MAAM;MACpBa,cAAA,CAAeJ,OAAO;IACxB,CAAC;EACH,GAAG,CAACF,SAAA,EAAWE,OAAO,CAAC;EAGvB,MAAMK,OAAA,GAAU,CAACL,OAAA,GAAU,QAAQF,SAAA,GAAYK,WAAA,GAAcH,OAAA;EAE7D,IAAID,IAAA,KAAS,YAAY;IACvB,IAAIG,KAAA,CAAMI,mBAAA,EAAqB;MAC7B,OACE,eAAAX,GAAA,CAACL,aAAA;QACCiB,SAAA,EAAS;QACR,IAAI,CAACN,WAAA,IAAe;UACnBO,OAAA,EAASN,KAAA,CAAMM,OAAA,GAAU,SAAY;UACrCC,cAAA,EAAgBP,KAAA,CAAMO,cAAA;UACtBC,YAAA,EAAcR,KAAA,CAAMQ,YAAA;UACpBC,WAAA,EAAaT,KAAA,CAAMS,WAAA;UACnBC,gBAAA,EAAkBV,KAAA,CAAMU,gBAAA;UAAA;UAAA;UAGxBC,qBAAA,EAAuB;UACvBN,SAAA,EAAWP,OAAA;UACXc,MAAA,EAAQZ,KAAA,CAAMY;QAChB;QAECjB;MAAA,CACH;IAEJ;IAEA,OACE,eAAAF,GAAA,CAACN,eAAA;MAAgBY,WAAA;MAA2B,GAAGC,KAAA;MAC5CL,QAAA,EAAAQ,OAAA,IAAWJ,WAAA,GAAcJ,QAAA,GAAW;IAAA,CACvC;EAEJ;EAEA,OAAO,eAAAF,GAAA,CAAAD,QAAA;IAAGG;EAAA,CAAS;AACrB","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { AnimatePresence, PresenceChild } from "@hanzogui/animate-presence";
|
|
3
|
+
import { startTransition, useEffect, useState } from "react";
|
|
4
|
+
function Animate(param) {
|
|
5
|
+
var {
|
|
6
|
+
children,
|
|
7
|
+
lazyMount,
|
|
8
|
+
type,
|
|
9
|
+
present,
|
|
10
|
+
passThrough,
|
|
11
|
+
...props
|
|
12
|
+
} = param;
|
|
13
|
+
var [lazyMounted, setLazyMounted] = useState(lazyMount ? false : present);
|
|
14
|
+
useEffect(function () {
|
|
15
|
+
if (passThrough) return;
|
|
16
|
+
if (!lazyMount) return;
|
|
17
|
+
if (!present) return;
|
|
18
|
+
startTransition(function () {
|
|
19
|
+
setLazyMounted(present);
|
|
20
|
+
});
|
|
21
|
+
}, [lazyMount, present]);
|
|
22
|
+
var mounted = !present ? false : lazyMount ? lazyMounted : present;
|
|
23
|
+
if (type === "presence") {
|
|
24
|
+
if (props.keepChildrenMounted) {
|
|
25
|
+
return /* @__PURE__ */_jsx(PresenceChild, {
|
|
26
|
+
isPresent: true,
|
|
27
|
+
...(!passThrough && {
|
|
28
|
+
initial: props.initial ? void 0 : false,
|
|
29
|
+
onExitComplete: props.onExitComplete,
|
|
30
|
+
enterVariant: props.enterVariant,
|
|
31
|
+
exitVariant: props.exitVariant,
|
|
32
|
+
enterExitVariant: props.enterExitVariant,
|
|
33
|
+
// BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
|
|
34
|
+
// but since we always re-render this component on open changes this should be fine to leave off?
|
|
35
|
+
presenceAffectsLayout: false,
|
|
36
|
+
isPresent: present,
|
|
37
|
+
custom: props.custom
|
|
38
|
+
}),
|
|
39
|
+
children
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */_jsx(AnimatePresence, {
|
|
43
|
+
passThrough,
|
|
44
|
+
...props,
|
|
45
|
+
children: mounted || passThrough ? children : null
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return /* @__PURE__ */_jsx(_Fragment, {
|
|
49
|
+
children
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export { Animate };
|
|
53
|
+
//# sourceMappingURL=Animate.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","Fragment","_Fragment","AnimatePresence","PresenceChild","startTransition","useEffect","useState","Animate","param","children","lazyMount","type","present","passThrough","props","lazyMounted","setLazyMounted","mounted","keepChildrenMounted","isPresent","initial","onExitComplete","enterVariant","exitVariant","enterExitVariant","presenceAffectsLayout","custom"],"sources":["../../src/Animate.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,GAAA,IAAAC,IAAA,EAAAC,QAAiB,IAAAC,SAAA,QAAqB;AAC/C,SAASC,eAAA,EAAiBC,aAAW,oCAAgB;AA4D7C,SA2BCC,eA3BD,EAAAC,SAAA,EAAAC,QAAA;AAzBD,SAASC,QAAQC,KAAA;EACtB;IAAAC,QAAA;IAAAC,SAAA;IAAAC,IAAA;IAAAC,OAAA;IAAAC,WAAA;IAAA,GAAAC;EAAA,IAAAN,KAAA;EACA,KAAAO,WAAA,EAAAC,cAAA,IAAAV,QAAA,CAAAI,SAAA,WAAAE,OAAA;EACAP,SAAA;IACA,IAAAQ,WAAA;IACA,KAAAH,SAAA;IACA,IAAG,CAAAE,OAAA;IAC6BR,eAAA;MAChCY,cAAO,CAAAJ,OAAa;IAEpB;EACE,IACAF,SAAK,EACLE,OAAK,CACL;EACE,IAAAK,OAAA,IAAAL,OAAe,QAAO,GAAAF,SAAA,GAAAK,WAAA,GAAAH,OAAA;EAAA,IACvBD,IAAA;IACH,IAAIG,KAAA,CAAAI,mBAAmB;MAGvB,OAAM,eAAqBnB,IAAA,CAAAI,aAAQ,EAAY;QAE3CgB,SAAS;QACP,KAAAN,WAAM;UACRO,OACE,EAAAN,KAAA,CAAAM,OAAA;UAACC,cAAA,EAAAP,KAAA,CAAAO,cAAA;UAAAC,YAAA,EAAAR,KAAA,CAAAQ,YAAA;UACCC,WAAS,EAAAT,KAAA,CAAAS,WAAA;UACRC,gBAAK,EAAAV,KAAe,CAAAU,gBAAA;UAAA;UACkB;UACfC,qBACR,EAAM;UAAAN,SACpB,EAAAP,OAAa;UAAMc,MACnB,EAAAZ,KAAA,CAAAY;QAAwB;QAAAjB;MAAA;IAGD;IACZ,sBACGV,IAAA,CAAAG,eAAA;MAAAW,WAChB;MAAA,GAAAC,KAEC;MAAAL,QAAA,EAAAQ,OAAA,IAAAJ,WAAA,GAAAJ,QAAA;IAAA,EACH;EAAA;EAIJ,sBACEV,IAAA,CAAAE,SAAC;IAILQ;EAEA;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/animate",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"license": "
|
|
3
|
+
"version": "7.3.1",
|
|
4
|
+
"license": "BSD-3-Clause",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
@@ -31,19 +31,20 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
35
|
-
"watch": "
|
|
36
|
-
"clean": "
|
|
37
|
-
"clean:build": "
|
|
34
|
+
"build": "gui-build",
|
|
35
|
+
"watch": "gui-build --watch",
|
|
36
|
+
"clean": "gui-build clean",
|
|
37
|
+
"clean:build": "gui-build clean:build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@hanzogui/animate-presence": "
|
|
40
|
+
"@hanzogui/animate-presence": "7.3.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@hanzogui/build": "
|
|
43
|
+
"@hanzogui/build": "7.3.1",
|
|
44
44
|
"react": ">=19"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=19"
|
|
48
|
-
}
|
|
49
|
-
|
|
48
|
+
},
|
|
49
|
+
"author": "Hanzo AI <dev@hanzo.ai>"
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAAA,cAAc,4BAA4B;KAIrC,YAAY;CACf,UAAU,MAAM;CAChB;;KAGG,gBAAgB,uBAAuB;CAC1C,MAAM;CACN;CACA;CACA;;AAGF,YAAY,eAAe,YAAY;;;;;;;;;;;;;;;;;;;AAqBvC,OAAO,iBAAS,QAAQ,EACtB,UACA,WACA,MACA,SACA,aACA,GAAG,SACF,eAAe,MAAM",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/Animate.tsx"
|
|
6
|
+
],
|
|
7
|
+
"version": 3,
|
|
8
|
+
"sourcesContent": [
|
|
9
|
+
"import type { AnimatePresenceProps } from '@hanzogui/animate-presence'\nimport { AnimatePresence, PresenceChild } from '@hanzogui/animate-presence'\nimport { startTransition, useEffect, useState } from 'react'\n\ntype BaseProps = {\n children: React.ReactNode\n passThrough?: boolean\n}\n\ntype PresenceProps = AnimatePresenceProps & {\n type: 'presence'\n present: boolean\n keepChildrenMounted?: boolean\n lazyMount?: boolean\n}\n\nexport type AnimateProps = BaseProps & PresenceProps\n\n/**\n * Because mounting and unmounting children can be expensive, this gives us the\n * option to avoid that.\n *\n * type: 'presence' will act just like AnimatePresence, except you use `present`\n * instead of conditional children.\n * Note that this does avoid reconciling the children even when present={false}\n * so no extra cost to perf over AnimatePresence.\n *\n * type: 'presence' with keepChildrenMounted true *always* render the children so you pay\n * the cost up-front to mount them, but then you avoid the mount cost at the start\n * of the animation.\n *\n * There's no \"right way\" it just depends on the use case, this component just makes\n * it easier to choose the strategy yourself.\n *\n *\n */\n\nexport function Animate({\n children,\n lazyMount,\n type,\n present,\n passThrough,\n ...props\n}: AnimateProps): React.ReactNode {\n const [lazyMounted, setLazyMounted] = useState(lazyMount ? false : present)\n\n useEffect(() => {\n if (passThrough) return\n if (!lazyMount) return\n if (!present) return\n startTransition(() => {\n setLazyMounted(present)\n })\n }, [lazyMount, present])\n\n // always immediately unmount\n const mounted = !present ? false : lazyMount ? lazyMounted : present\n\n if (type === 'presence') {\n if (props.keepChildrenMounted) {\n return (\n <PresenceChild\n isPresent\n {...(!passThrough && {\n initial: props.initial ? undefined : false,\n onExitComplete: props.onExitComplete,\n enterVariant: props.enterVariant,\n exitVariant: props.exitVariant,\n enterExitVariant: props.enterExitVariant,\n // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu\n // but since we always re-render this component on open changes this should be fine to leave off?\n presenceAffectsLayout: false,\n isPresent: present,\n custom: props.custom,\n })}\n >\n {children as any}\n </PresenceChild>\n )\n }\n\n return (\n <AnimatePresence passThrough={passThrough} {...props}>\n {mounted || passThrough ? children : null}\n </AnimatePresence>\n )\n }\n\n return <>{children}</>\n}\n"
|
|
10
|
+
]
|
|
11
|
+
}
|