@hanzogui/animate 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ Much of this is taken from framer-motion.
@@ -0,0 +1,66 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var Animate_exports = {};
22
+ __export(Animate_exports, {
23
+ Animate: () => Animate
24
+ });
25
+ module.exports = __toCommonJS(Animate_exports);
26
+ var import_gui_animate_presence = require("@hanzo/gui-animate-presence"),
27
+ import_react = require("react"),
28
+ import_jsx_runtime = require("react/jsx-runtime");
29
+ function Animate({
30
+ children,
31
+ lazyMount,
32
+ type,
33
+ present,
34
+ passThrough,
35
+ ...props
36
+ }) {
37
+ const [lazyMounted, setLazyMounted] = (0, import_react.useState)(lazyMount ? !1 : present);
38
+ (0, import_react.useEffect)(() => {
39
+ passThrough || lazyMount && present && (0, import_react.startTransition)(() => {
40
+ setLazyMounted(present);
41
+ });
42
+ }, [lazyMount, present]);
43
+ const mounted = present ? lazyMount ? lazyMounted : present : !1;
44
+ return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.PresenceChild, {
45
+ isPresent: !0,
46
+ ...(!passThrough && {
47
+ initial: props.initial ? void 0 : !1,
48
+ onExitComplete: props.onExitComplete,
49
+ enterVariant: props.enterVariant,
50
+ exitVariant: props.exitVariant,
51
+ enterExitVariant: props.enterExitVariant,
52
+ // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
53
+ // but since we always re-render this component on open changes this should be fine to leave off?
54
+ presenceAffectsLayout: !1,
55
+ isPresent: present,
56
+ custom: props.custom
57
+ }),
58
+ children
59
+ }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.AnimatePresence, {
60
+ passThrough,
61
+ ...props,
62
+ children: mounted || passThrough ? children : null
63
+ }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
64
+ children
65
+ });
66
+ }
@@ -0,0 +1,70 @@
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: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var Animate_exports = {};
24
+ __export(Animate_exports, {
25
+ Animate: () => Animate
26
+ });
27
+ module.exports = __toCommonJS(Animate_exports);
28
+ var import_jsx_runtime = require("react/jsx-runtime"),
29
+ import_gui_animate_presence = require("@hanzo/gui-animate-presence"),
30
+ import_react = require("react");
31
+ function Animate(param) {
32
+ var {
33
+ children,
34
+ lazyMount,
35
+ type,
36
+ present,
37
+ passThrough,
38
+ ...props
39
+ } = param,
40
+ [lazyMounted, setLazyMounted] = (0, import_react.useState)(lazyMount ? !1 : present);
41
+ (0, import_react.useEffect)(function () {
42
+ passThrough || lazyMount && present && (0, import_react.startTransition)(function () {
43
+ setLazyMounted(present);
44
+ });
45
+ }, [lazyMount, present]);
46
+ var mounted = present ? lazyMount ? lazyMounted : present : !1;
47
+ return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.PresenceChild, {
48
+ isPresent: !0,
49
+ ...(!passThrough && {
50
+ initial: props.initial ? void 0 : !1,
51
+ onExitComplete: props.onExitComplete,
52
+ enterVariant: props.enterVariant,
53
+ exitVariant: props.exitVariant,
54
+ enterExitVariant: props.enterExitVariant,
55
+ // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
56
+ // but since we always re-render this component on open changes this should be fine to leave off?
57
+ presenceAffectsLayout: !1,
58
+ isPresent: present,
59
+ custom: props.custom
60
+ }),
61
+ children
62
+ }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.AnimatePresence, {
63
+ passThrough,
64
+ ...props,
65
+ children: mounted || passThrough ? children : null
66
+ }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
67
+ children
68
+ });
69
+ }
70
+ //# 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_gui_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,CAAAK,eAA+C;AAoCxC,IAAAK,kBAAiB,GAAAC,OAAA;EAAAC,2BAAA,GAAAD,OAAA;EAAAE,YAAA,GAAAF,OAAA;AAAA,SACtBJ,QAAAO,KAAA;EACA;MAAAC,QAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,OAAA;MAAAC,WAAA;MAAA,GAAAC;IAAA,IAAAN,KAAA;IAAA,CAAAO,WAAA,EAAAC,cAAA,QAAAT,YAAA,CAAAU,QAAA,EAAAP,SAAA,QAAAE,OAAA;EACA,IAAAL,YAAA,CAAAW,SAAA;IACAL,WAAA,IAAAH,SAAA,IAAAE,OAAA,QAAAL,YAAA,CAAAY,eAAA;MACAH,cAAA,CAAAJ,OAAA;IACA,CAAG;EACL,CAAkC,GAChCF,SAAO,EAEPE,OAAA,CACE,CAAI;EAIF,IAAAQ,OAAA,GAAAR,OAAe,GAAAF,SAAO,GAAAK,WAAA,GAAAH,OAAA;EAAA,OACvBD,IAAA,kBAAAG,KAAA,CAAAO,mBAAA,sBAAAjB,kBAAA,CAAAkB,GAAA,EAAAhB,2BAAA,CAAAiB,aAAA;IACHC,SAAI,IAAW;IAGf,KAAMX,WAAW;MAEjBY,OAAI,EAAAX,KAAS,CAAAW,OAAA,GACP,MAAM;MAELC,cAAA,EAAAZ,KAAA,CAAAY,cAAA;MAAAC,YAAA,EAAAb,KAAA,CAAAa,YAAA;MACCC,WAAS,EAAAd,KAAA,CAAAc,WAAA;MACRC,gBAAK,EAAAf,KAAe,CAAAe,gBAAA;MAAA;MACkB;MACfC,qBACR,EAAM;MAAAN,SACpB,EAAAZ,OAAa;MAAMmB,MACnB,EAAAjB,KAAA,CAAAiB;IAAwB;IAAAtB;EAAA,oBAGxB,IAAAL,kBAAuB,CAAAkB,GAAA,EAAAhB,2BAAA,CAAA0B,eAAA;IAAAnB,WACvB;IAAW,GAAAC,KACX;IAAcL,QAChB,EAAAW,OAAA,IAAAP,WAAA,GAAAJ,QAAA;EAAA,KAEC,mBAAAL,kBAAA,CAAAkB,GAAA,EAAAlB,kBAAA,CAAA6B,QAAA;IAAAxB;EACH;AAYR","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./Animate.cjs"), module.exports);
@@ -0,0 +1,21 @@
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") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ return to;
13
+ },
14
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: !0
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./Animate.native.js"), module.exports);
21
+ //# 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,43 @@
1
+ import { AnimatePresence, PresenceChild } from "@hanzo/gui-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 ? !1 : present);
13
+ useEffect(() => {
14
+ passThrough || lazyMount && present && startTransition(() => {
15
+ setLazyMounted(present);
16
+ });
17
+ }, [lazyMount, present]);
18
+ const mounted = present ? lazyMount ? lazyMounted : present : !1;
19
+ return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */jsx(PresenceChild, {
20
+ isPresent: !0,
21
+ ...(!passThrough && {
22
+ initial: props.initial ? void 0 : !1,
23
+ onExitComplete: props.onExitComplete,
24
+ enterVariant: props.enterVariant,
25
+ exitVariant: props.exitVariant,
26
+ enterExitVariant: props.enterExitVariant,
27
+ // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
28
+ // but since we always re-render this component on open changes this should be fine to leave off?
29
+ presenceAffectsLayout: !1,
30
+ isPresent: present,
31
+ custom: props.custom
32
+ }),
33
+ children
34
+ }) : /* @__PURE__ */jsx(AnimatePresence, {
35
+ passThrough,
36
+ ...props,
37
+ children: mounted || passThrough ? children : null
38
+ }) : /* @__PURE__ */jsx(Fragment, {
39
+ children
40
+ });
41
+ }
42
+ export { Animate };
43
+ //# 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,KAAQE,OAAO;EAE1ER,SAAA,CAAU,MAAM;IACVS,WAAA,IACCH,SAAA,IACAE,OAAA,IACLT,eAAA,CAAgB,MAAM;MACpBa,cAAA,CAAeJ,OAAO;IACxB,CAAC;EACH,GAAG,CAACF,SAAA,EAAWE,OAAO,CAAC;EAGvB,MAAMK,OAAA,GAAWL,OAAA,GAAkBF,SAAA,GAAYK,WAAA,GAAcH,OAAA,GAAlC;EAE3B,OAAID,IAAA,KAAS,aACPG,KAAA,CAAMI,mBAAA,GAEN,eAAAX,GAAA,CAACL,aAAA;IACCiB,SAAA,EAAS;IACR,IAAI,CAACN,WAAA,IAAe;MACnBO,OAAA,EAASN,KAAA,CAAMM,OAAA,GAAU,SAAY;MACrCC,cAAA,EAAgBP,KAAA,CAAMO,cAAA;MACtBC,YAAA,EAAcR,KAAA,CAAMQ,YAAA;MACpBC,WAAA,EAAaT,KAAA,CAAMS,WAAA;MACnBC,gBAAA,EAAkBV,KAAA,CAAMU,gBAAA;MAAA;MAAA;MAGxBC,qBAAA,EAAuB;MACvBN,SAAA,EAAWP,OAAA;MACXc,MAAA,EAAQZ,KAAA,CAAMY;IAChB;IAECjB;EAAA,CACH,IAKF,eAAAF,GAAA,CAACN,eAAA;IAAgBY,WAAA;IAA2B,GAAGC,KAAA;IAC5CL,QAAA,EAAAQ,OAAA,IAAWJ,WAAA,GAAcJ,QAAA,GAAW;EAAA,CACvC,IAIG,eAAAF,GAAA,CAAAD,QAAA;IAAGG;EAAA,CAAS;AACrB","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { AnimatePresence, PresenceChild } from "@hanzo/gui-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
+ [lazyMounted, setLazyMounted] = useState(lazyMount ? !1 : present);
14
+ useEffect(function () {
15
+ passThrough || lazyMount && present && startTransition(function () {
16
+ setLazyMounted(present);
17
+ });
18
+ }, [lazyMount, present]);
19
+ var mounted = present ? lazyMount ? lazyMounted : present : !1;
20
+ return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */_jsx(PresenceChild, {
21
+ isPresent: !0,
22
+ ...(!passThrough && {
23
+ initial: props.initial ? void 0 : !1,
24
+ onExitComplete: props.onExitComplete,
25
+ enterVariant: props.enterVariant,
26
+ exitVariant: props.exitVariant,
27
+ enterExitVariant: props.enterExitVariant,
28
+ // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
29
+ // but since we always re-render this component on open changes this should be fine to leave off?
30
+ presenceAffectsLayout: !1,
31
+ isPresent: present,
32
+ custom: props.custom
33
+ }),
34
+ children
35
+ }) : /* @__PURE__ */_jsx(AnimatePresence, {
36
+ passThrough,
37
+ ...props,
38
+ children: mounted || passThrough ? children : null
39
+ }) : /* @__PURE__ */_jsx(_Fragment, {
40
+ children
41
+ });
42
+ }
43
+ export { Animate };
44
+ //# 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,qCAAgB;AA4D7C,SA2BCC,eA3BD,EAAAC,SAAA,EAAAC,QAAA;AAzBD,SAASC,QAAQC,KAAA;EACtB;MAAAC,QAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,OAAA;MAAAC,WAAA;MAAA,GAAAC;IAAA,IAAAN,KAAA;IAAA,CAAAO,WAAA,EAAAC,cAAA,IAAAV,QAAA,CAAAI,SAAA,QAAAE,OAAA;EACAP,SAAA;IACAQ,WAAA,IAAAH,SAAA,IAAAE,OAAA,IAAAR,eAAA;MACAY,cAAA,CAAAJ,OAAA;IACA;EACA,GAAG,CAC6BF,SAAA,EAChCE,OAAO,CAEP;EACE,IAAIK,OAAA,GAAAL,OACC,GAAAF,SACA,GAAAK,WACL,GAAAH,OAAgB;EACd,OAAAD,IAAA,eAAsB,GAAAG,KAAA,CAAAI,mBAAA,kBAAAnB,IAAA,CAAAI,aAAA;IACxBgB,SAAC;IACH,IAAI,CAAAN,WAAW;MAGfO,OAAM,EAAAN,KAAW,CAAAM,OAAkB,YAAY;MAE/CC,cAAa,EAAAP,KAAA,CAAAO,cACD;MAELC,YAAA,EAAAR,KAAA,CAAAQ,YAAA;MAAAC,WAAA,EAAAT,KAAA,CAAAS,WAAA;MACCC,gBAAS,EAAAV,KAAA,CAAAU,gBAAA;MACR;MAAoB;MACkBC,qBACrB,GAAM;MAAAN,SACtB,EAAAP,OAAc;MAAMc,MACpB,EAAAZ,KAAA,CAAAY;IAAmB;IACKjB;EAAA,oBAAAV,IAAA,CAAAG,eAAA;IAAAW,WAGxB;IAAuB,GAAAC,KACvB;IAAWL,QACX,EAAAQ,OAAQ,IAAMJ,WAAA,GAAAJ,QAAA;EAAA,KAChB,eAAAV,IAAA,CAAAE,SAAA;IAAAQ;EAEC;AAAA;AAaX,S","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./Animate.mjs";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./Animate.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./Animate.native.js";
2
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@hanzogui/animate",
3
+ "version": "2.0.0",
4
+ "license": "MIT",
5
+ "source": "src/index.ts",
6
+ "files": [
7
+ "src",
8
+ "types",
9
+ "dist"
10
+ ],
11
+ "type": "module",
12
+ "sideEffects": [
13
+ "*.css"
14
+ ],
15
+ "main": "dist/cjs",
16
+ "module": "dist/esm",
17
+ "types": "./types/index.d.ts",
18
+ "exports": {
19
+ "./package.json": "./package.json",
20
+ ".": {
21
+ "types": "./types/index.d.ts",
22
+ "react-native": "./dist/esm/index.native.js",
23
+ "browser": "./dist/esm/index.mjs",
24
+ "module": "./dist/esm/index.mjs",
25
+ "import": "./dist/esm/index.mjs",
26
+ "require": "./dist/cjs/index.cjs",
27
+ "default": "./dist/esm/index.mjs"
28
+ }
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "build": "hanzo-gui-build",
35
+ "watch": "hanzo-gui-build --watch",
36
+ "clean": "hanzo-gui-build clean",
37
+ "clean:build": "hanzo-gui-build clean:build"
38
+ },
39
+ "dependencies": {
40
+ "@hanzogui/animate-presence": "2.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@hanzogui/build": "2.0.0-rc.29",
44
+ "react": ">=19"
45
+ },
46
+ "peerDependencies": {
47
+ "react": ">=19"
48
+ }
49
+ }
@@ -0,0 +1,91 @@
1
+ import type { AnimatePresenceProps } from '@hanzogui/animate-presence'
2
+ import { AnimatePresence, PresenceChild } from '@hanzogui/animate-presence'
3
+ import { startTransition, useEffect, useState } from 'react'
4
+
5
+ type BaseProps = {
6
+ children: React.ReactNode
7
+ passThrough?: boolean
8
+ }
9
+
10
+ type PresenceProps = AnimatePresenceProps & {
11
+ type: 'presence'
12
+ present: boolean
13
+ keepChildrenMounted?: boolean
14
+ lazyMount?: boolean
15
+ }
16
+
17
+ export type AnimateProps = BaseProps & PresenceProps
18
+
19
+ /**
20
+ * Because mounting and unmounting children can be expensive, this gives us the
21
+ * option to avoid that.
22
+ *
23
+ * type: 'presence' will act just like AnimatePresence, except you use `present`
24
+ * instead of conditional children.
25
+ * Note that this does avoid reconciling the children even when present={false}
26
+ * so no extra cost to perf over AnimatePresence.
27
+ *
28
+ * type: 'presence' with keepChildrenMounted true *always* render the children so you pay
29
+ * the cost up-front to mount them, but then you avoid the mount cost at the start
30
+ * of the animation.
31
+ *
32
+ * There's no "right way" it just depends on the use case, this component just makes
33
+ * it easier to choose the strategy yourself.
34
+ *
35
+ *
36
+ */
37
+
38
+ export function Animate({
39
+ children,
40
+ lazyMount,
41
+ type,
42
+ present,
43
+ passThrough,
44
+ ...props
45
+ }: AnimateProps): React.ReactNode {
46
+ const [lazyMounted, setLazyMounted] = useState(lazyMount ? false : present)
47
+
48
+ useEffect(() => {
49
+ if (passThrough) return
50
+ if (!lazyMount) return
51
+ if (!present) return
52
+ startTransition(() => {
53
+ setLazyMounted(present)
54
+ })
55
+ }, [lazyMount, present])
56
+
57
+ // always immediately unmount
58
+ const mounted = !present ? false : lazyMount ? lazyMounted : present
59
+
60
+ if (type === 'presence') {
61
+ if (props.keepChildrenMounted) {
62
+ return (
63
+ <PresenceChild
64
+ isPresent
65
+ {...(!passThrough && {
66
+ initial: props.initial ? undefined : false,
67
+ onExitComplete: props.onExitComplete,
68
+ enterVariant: props.enterVariant,
69
+ exitVariant: props.exitVariant,
70
+ enterExitVariant: props.enterExitVariant,
71
+ // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
72
+ // but since we always re-render this component on open changes this should be fine to leave off?
73
+ presenceAffectsLayout: false,
74
+ isPresent: present,
75
+ custom: props.custom,
76
+ })}
77
+ >
78
+ {children as any}
79
+ </PresenceChild>
80
+ )
81
+ }
82
+
83
+ return (
84
+ <AnimatePresence passThrough={passThrough} {...props}>
85
+ {mounted || passThrough ? children : null}
86
+ </AnimatePresence>
87
+ )
88
+ }
89
+
90
+ return <>{children}</>
91
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './Animate'
@@ -0,0 +1,34 @@
1
+ import type { AnimatePresenceProps } from "@gui/animate-presence";
2
+ type BaseProps = {
3
+ children: React.ReactNode;
4
+ passThrough?: boolean;
5
+ };
6
+ type PresenceProps = AnimatePresenceProps & {
7
+ type: "presence";
8
+ present: boolean;
9
+ keepChildrenMounted?: boolean;
10
+ lazyMount?: boolean;
11
+ };
12
+ export type AnimateProps = BaseProps & PresenceProps;
13
+ /**
14
+ * Because mounting and unmounting children can be expensive, this gives us the
15
+ * option to avoid that.
16
+ *
17
+ * type: 'presence' will act just like AnimatePresence, except you use `present`
18
+ * instead of conditional children.
19
+ * Note that this does avoid reconciling the children even when present={false}
20
+ * so no extra cost to perf over AnimatePresence.
21
+ *
22
+ * type: 'presence' with keepChildrenMounted true *always* render the children so you pay
23
+ * the cost up-front to mount them, but then you avoid the mount cost at the start
24
+ * of the animation.
25
+ *
26
+ * There's no "right way" it just depends on the use case, this component just makes
27
+ * it easier to choose the strategy yourself.
28
+ *
29
+ *
30
+ */
31
+ export declare function Animate({ children, lazyMount, type, present, passThrough, ...props }: AnimateProps): React.ReactNode;
32
+ export {};
33
+
34
+ //# sourceMappingURL=Animate.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from "./Animate";
2
+
3
+ //# sourceMappingURL=index.d.ts.map