@tamagui/animate 1.128.1 → 1.129.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.
@@ -24,12 +24,22 @@ __export(Animate_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(Animate_exports);
26
26
  var import_animate_presence = require("@tamagui/animate-presence"),
27
+ import_react = require("react"),
27
28
  import_jsx_runtime = require("react/jsx-runtime");
28
29
  function Animate({
29
30
  children,
31
+ lazyMount,
30
32
  type,
33
+ present,
31
34
  ...props
32
35
  }) {
36
+ const [lazyMounted, setLazyMounted] = (0, import_react.useState)(lazyMount ? !1 : present);
37
+ (0, import_react.useEffect)(() => {
38
+ lazyMount && present && (0, import_react.startTransition)(() => {
39
+ setLazyMounted(present);
40
+ });
41
+ }, [lazyMount, present]);
42
+ const mounted = present ? lazyMount ? lazyMounted : present : !1;
33
43
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.PresenceChild, {
34
44
  initial: props.initial ? void 0 : !1,
35
45
  onExitComplete: props.onExitComplete,
@@ -37,12 +47,12 @@ function Animate({
37
47
  exitVariant: props.exitVariant,
38
48
  enterExitVariant: props.enterExitVariant,
39
49
  presenceAffectsLayout: !1,
40
- isPresent: props.present,
50
+ isPresent: present,
41
51
  custom: props.custom,
42
52
  children
43
53
  }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
44
54
  ...props,
45
- children: props.present ? children : null
55
+ children: mounted ? children : null
46
56
  }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
47
57
  children
48
58
  });
@@ -17,8 +17,21 @@ __export(Animate_exports, {
17
17
  Animate: () => Animate
18
18
  });
19
19
  module.exports = __toCommonJS(Animate_exports);
20
- var import_animate_presence = require("@tamagui/animate-presence"), import_jsx_runtime = require("react/jsx-runtime");
21
- function Animate({ children, type, ...props }) {
20
+ var import_animate_presence = require("@tamagui/animate-presence"), import_react = require("react"), import_jsx_runtime = require("react/jsx-runtime");
21
+ function Animate({
22
+ children,
23
+ lazyMount,
24
+ type,
25
+ present,
26
+ ...props
27
+ }) {
28
+ const [lazyMounted, setLazyMounted] = (0, import_react.useState)(lazyMount ? !1 : present);
29
+ (0, import_react.useEffect)(() => {
30
+ lazyMount && present && (0, import_react.startTransition)(() => {
31
+ setLazyMounted(present);
32
+ });
33
+ }, [lazyMount, present]);
34
+ const mounted = present ? lazyMount ? lazyMounted : present : !1;
22
35
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
23
36
  import_animate_presence.PresenceChild,
24
37
  {
@@ -28,10 +41,10 @@ function Animate({ children, type, ...props }) {
28
41
  exitVariant: props.exitVariant,
29
42
  enterExitVariant: props.enterExitVariant,
30
43
  presenceAffectsLayout: !1,
31
- isPresent: props.present,
44
+ isPresent: present,
32
45
  custom: props.custom,
33
46
  children
34
47
  }
35
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { ...props, children: props.present ? children : null }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
48
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { ...props, children: mounted ? children : null }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
36
49
  }
37
50
  //# sourceMappingURL=Animate.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Animate.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA+C,sCAsCvC;AAJD,SAAS,QAAQ,EAAE,UAAU,MAAM,GAAG,MAAM,GAA8B;AAC/E,SAAI,SAAS,aACP,MAAM,sBAEN;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,MAAM,UAAU,SAAY;AAAA,MACrC,gBAAgB,MAAM;AAAA,MACtB,cAAc,MAAM;AAAA,MACpB,aAAa,MAAM;AAAA,MACnB,kBAAkB,MAAM;AAAA,MAGxB,uBAAuB;AAAA,MACvB,WAAW,MAAM;AAAA,MACjB,QAAQ,MAAM;AAAA,MAEb;AAAA;AAAA,EACH,IAIG,4CAAC,2CAAiB,GAAG,OAAQ,gBAAM,UAAU,WAAW,MAAK,IAG/D,2EAAG,UAAS;AACrB;",
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA+C,sCAC/C,eAAqD,kBA0D7C;AAvBD,SAAS,QAAQ;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAChC,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,YAAY,KAAQ,OAAO;AAE1E,8BAAU,MAAM;AACd,IAAK,aACA,eACL,8BAAgB,MAAM;AACpB,qBAAe,OAAO;AAAA,IACxB,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,OAAO,CAAC;AAGvB,QAAM,UAAW,UAAkB,YAAY,cAAc,UAAlC;AAE3B,SAAI,SAAS,aACP,MAAM,sBAEN;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,MAAM,UAAU,SAAY;AAAA,MACrC,gBAAgB,MAAM;AAAA,MACtB,cAAc,MAAM;AAAA,MACpB,aAAa,MAAM;AAAA,MACnB,kBAAkB,MAAM;AAAA,MAGxB,uBAAuB;AAAA,MACvB,WAAW;AAAA,MACX,QAAQ,MAAM;AAAA,MAEb;AAAA;AAAA,EACH,IAIG,4CAAC,2CAAiB,GAAG,OAAQ,oBAAU,WAAW,MAAK,IAGzD,2EAAG,UAAS;AACrB;",
5
5
  "names": []
6
6
  }
@@ -18,9 +18,18 @@ __export(Animate_exports, {
18
18
  Animate: () => Animate
19
19
  });
20
20
  module.exports = __toCommonJS(Animate_exports);
21
- var import_jsx_runtime = require("react/jsx-runtime"), import_animate_presence = require("@tamagui/animate-presence");
21
+ var import_jsx_runtime = require("react/jsx-runtime"), import_animate_presence = require("@tamagui/animate-presence"), import_react = require("react");
22
22
  function Animate(param) {
23
- var { children, type, ...props } = param;
23
+ var { children, lazyMount, type, present, ...props } = param, [lazyMounted, setLazyMounted] = (0, import_react.useState)(lazyMount ? !1 : present);
24
+ (0, import_react.useEffect)(function() {
25
+ lazyMount && present && (0, import_react.startTransition)(function() {
26
+ setLazyMounted(present);
27
+ });
28
+ }, [
29
+ lazyMount,
30
+ present
31
+ ]);
32
+ var mounted = present ? lazyMount ? lazyMounted : present : !1;
24
33
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.PresenceChild, {
25
34
  initial: props.initial ? void 0 : !1,
26
35
  onExitComplete: props.onExitComplete,
@@ -30,12 +39,12 @@ function Animate(param) {
30
39
  // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
31
40
  // but since we always re-render this component on open changes this should be fine to leave off?
32
41
  presenceAffectsLayout: !1,
33
- isPresent: props.present,
42
+ isPresent: present,
34
43
  custom: props.custom,
35
44
  children
36
45
  }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
37
46
  ...props,
38
- children: props.present ? children : null
47
+ children: mounted ? children : null
39
48
  }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
40
49
  children
41
50
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Animate.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;uDACA,0BAA+C;AAkCxC,SAASA,QAAQ,OAA0C;MAA1C,EAAEC,UAAUC,MAAM,GAAGC,MAAAA,IAArB;AACtB,SAAID,SAAS,aACPC,MAAMC,sBAEN,uCAAAC,KAACC,uCAAAA;IACCC,SAASJ,MAAMI,UAAUC,SAAY;IACrCC,gBAAgBN,MAAMM;IACtBC,cAAcP,MAAMO;IACpBC,aAAaR,MAAMQ;IACnBC,kBAAkBT,MAAMS;;;IAGxBC,uBAAuB;IACvBC,WAAWX,MAAMY;IACjBC,QAAQb,MAAMa;;OAOb,uCAAAX,KAACY,yCAAAA;IAAiB,GAAGd;cAAQA,MAAMY,UAAUd,WAAW;OAG1D,uCAAAI,KAAA,mBAAAa,UAAA;;;AACT;",
5
- "names": ["Animate", "children", "type", "props", "keepChildrenMounted", "_jsx", "PresenceChild", "initial", "undefined", "onExitComplete", "enterVariant", "exitVariant", "enterExitVariant", "presenceAffectsLayout", "isPresent", "present", "custom", "AnimatePresence", "_Fragment"]
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;uDACA,0BAA+C,sCAC/C,eAAqD;AAmC9C,SAASA,QAAQ,OAMT;MANS,EACtBC,UACAC,WACAC,MACAC,SACA,GAAGC,MAAAA,IALmB,OAOhB,CAACC,aAAaC,cAAAA,QAAkBC,uBAASN,YAAY,KAAQE,OAAAA;AAEnEK,8BAAU,WAAA;AACR,IAAKP,aACAE,eACLM,8BAAgB,WAAA;AACdH,qBAAeH,OAAAA;IACjB,CAAA;EACF,GAAG;IAACF;IAAWE;GAAQ;AAGvB,MAAMO,UAAWP,UAAkBF,YAAYI,cAAcF,UAAlC;AAE3B,SAAID,SAAS,aACPE,MAAMO,sBAEN,uCAAAC,KAACC,uCAAAA;IACCC,SAASV,MAAMU,UAAUC,SAAY;IACrCC,gBAAgBZ,MAAMY;IACtBC,cAAcb,MAAMa;IACpBC,aAAad,MAAMc;IACnBC,kBAAkBf,MAAMe;;;IAGxBC,uBAAuB;IACvBC,WAAWlB;IACXmB,QAAQlB,MAAMkB;;OAOb,uCAAAV,KAACW,yCAAAA;IAAiB,GAAGnB;cAAQM,UAAUV,WAAW;OAGpD,uCAAAY,KAAA,mBAAAY,UAAA;;;AACT;",
5
+ "names": ["Animate", "children", "lazyMount", "type", "present", "props", "lazyMounted", "setLazyMounted", "useState", "useEffect", "startTransition", "mounted", "keepChildrenMounted", "_jsx", "PresenceChild", "initial", "undefined", "onExitComplete", "enterVariant", "exitVariant", "enterExitVariant", "presenceAffectsLayout", "isPresent", "custom", "AnimatePresence", "_Fragment"]
6
6
  }
@@ -1,6 +1,20 @@
1
1
  import { AnimatePresence, PresenceChild } from "@tamagui/animate-presence";
2
+ import { startTransition, useEffect, useState } from "react";
2
3
  import { Fragment, jsx } from "react/jsx-runtime";
3
- function Animate({ children, type, ...props }) {
4
+ function Animate({
5
+ children,
6
+ lazyMount,
7
+ type,
8
+ present,
9
+ ...props
10
+ }) {
11
+ const [lazyMounted, setLazyMounted] = useState(lazyMount ? !1 : present);
12
+ useEffect(() => {
13
+ lazyMount && present && startTransition(() => {
14
+ setLazyMounted(present);
15
+ });
16
+ }, [lazyMount, present]);
17
+ const mounted = present ? lazyMount ? lazyMounted : present : !1;
4
18
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */ jsx(
5
19
  PresenceChild,
6
20
  {
@@ -10,11 +24,11 @@ function Animate({ children, type, ...props }) {
10
24
  exitVariant: props.exitVariant,
11
25
  enterExitVariant: props.enterExitVariant,
12
26
  presenceAffectsLayout: !1,
13
- isPresent: props.present,
27
+ isPresent: present,
14
28
  custom: props.custom,
15
29
  children
16
30
  }
17
- ) : /* @__PURE__ */ jsx(AnimatePresence, { ...props, children: props.present ? children : null }) : /* @__PURE__ */ jsx(Fragment, { children });
31
+ ) : /* @__PURE__ */ jsx(AnimatePresence, { ...props, children: mounted ? children : null }) : /* @__PURE__ */ jsx(Fragment, { children });
18
32
  }
19
33
  export {
20
34
  Animate
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Animate.tsx"],
4
- "mappings": "AACA,SAAS,iBAAiB,qBAAqB;AAsCvC,SAoBC,UApBD;AAJD,SAAS,QAAQ,EAAE,UAAU,MAAM,GAAG,MAAM,GAA8B;AAC/E,SAAI,SAAS,aACP,MAAM,sBAEN;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,MAAM,UAAU,SAAY;AAAA,MACrC,gBAAgB,MAAM;AAAA,MACtB,cAAc,MAAM;AAAA,MACpB,aAAa,MAAM;AAAA,MACnB,kBAAkB,MAAM;AAAA,MAGxB,uBAAuB;AAAA,MACvB,WAAW,MAAM;AAAA,MACjB,QAAQ,MAAM;AAAA,MAEb;AAAA;AAAA,EACH,IAIG,oBAAC,mBAAiB,GAAG,OAAQ,gBAAM,UAAU,WAAW,MAAK,IAG/D,gCAAG,UAAS;AACrB;",
4
+ "mappings": "AACA,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,iBAAiB,WAAW,gBAAgB;AA0D7C,SAoBC,UApBD;AAvBD,SAAS,QAAQ;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAChC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,YAAY,KAAQ,OAAO;AAE1E,YAAU,MAAM;AACd,IAAK,aACA,WACL,gBAAgB,MAAM;AACpB,qBAAe,OAAO;AAAA,IACxB,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,OAAO,CAAC;AAGvB,QAAM,UAAW,UAAkB,YAAY,cAAc,UAAlC;AAE3B,SAAI,SAAS,aACP,MAAM,sBAEN;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,MAAM,UAAU,SAAY;AAAA,MACrC,gBAAgB,MAAM;AAAA,MACtB,cAAc,MAAM;AAAA,MACpB,aAAa,MAAM;AAAA,MACnB,kBAAkB,MAAM;AAAA,MAGxB,uBAAuB;AAAA,MACvB,WAAW;AAAA,MACX,QAAQ,MAAM;AAAA,MAEb;AAAA;AAAA,EACH,IAIG,oBAAC,mBAAiB,GAAG,OAAQ,oBAAU,WAAW,MAAK,IAGzD,gCAAG,UAAS;AACrB;",
5
5
  "names": []
6
6
  }
@@ -1,10 +1,20 @@
1
1
  import { AnimatePresence, PresenceChild } from "@tamagui/animate-presence";
2
+ import { startTransition, useEffect, useState } from "react";
2
3
  import { Fragment, jsx } from "react/jsx-runtime";
3
4
  function Animate({
4
5
  children,
6
+ lazyMount,
5
7
  type,
8
+ present,
6
9
  ...props
7
10
  }) {
11
+ const [lazyMounted, setLazyMounted] = useState(lazyMount ? !1 : present);
12
+ useEffect(() => {
13
+ lazyMount && present && startTransition(() => {
14
+ setLazyMounted(present);
15
+ });
16
+ }, [lazyMount, present]);
17
+ const mounted = present ? lazyMount ? lazyMounted : present : !1;
8
18
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */jsx(PresenceChild, {
9
19
  initial: props.initial ? void 0 : !1,
10
20
  onExitComplete: props.onExitComplete,
@@ -12,12 +22,12 @@ function Animate({
12
22
  exitVariant: props.exitVariant,
13
23
  enterExitVariant: props.enterExitVariant,
14
24
  presenceAffectsLayout: !1,
15
- isPresent: props.present,
25
+ isPresent: present,
16
26
  custom: props.custom,
17
27
  children
18
28
  }) : /* @__PURE__ */jsx(AnimatePresence, {
19
29
  ...props,
20
- children: props.present ? children : null
30
+ children: mounted ? children : null
21
31
  }) : /* @__PURE__ */jsx(Fragment, {
22
32
  children
23
33
  });
@@ -1 +1 @@
1
- {"version":3,"names":["AnimatePresence","PresenceChild","Fragment","jsx","Animate","children","type","props","keepChildrenMounted","initial","onExitComplete","enterVariant","exitVariant","enterExitVariant","presenceAffectsLayout","isPresent","present","custom"],"sources":["../../src/Animate.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,eAAA,EAAiBC,aAAA,QAAqB;AAsCvC,SAoBCC,QAAA,EApBDC,GAAA;AAJD,SAASC,QAAQ;EAAEC,QAAA;EAAUC,IAAA;EAAM,GAAGC;AAAM,GAA8B;EAC/E,OAAID,IAAA,KAAS,aACPC,KAAA,CAAMC,mBAAA,GAEN,eAAAL,GAAA,CAACF,aAAA;IACCQ,OAAA,EAASF,KAAA,CAAME,OAAA,GAAU,SAAY;IACrCC,cAAA,EAAgBH,KAAA,CAAMG,cAAA;IACtBC,YAAA,EAAcJ,KAAA,CAAMI,YAAA;IACpBC,WAAA,EAAaL,KAAA,CAAMK,WAAA;IACnBC,gBAAA,EAAkBN,KAAA,CAAMM,gBAAA;IAGxBC,qBAAA,EAAuB;IACvBC,SAAA,EAAWR,KAAA,CAAMS,OAAA;IACjBC,MAAA,EAAQV,KAAA,CAAMU,MAAA;IAEbZ;EAAA,CACH,IAIG,eAAAF,GAAA,CAACH,eAAA;IAAiB,GAAGO,KAAA;IAAQF,QAAA,EAAAE,KAAA,CAAMS,OAAA,GAAUX,QAAA,GAAW;EAAA,CAAK,IAG/D,eAAAF,GAAA,CAAAD,QAAA;IAAGG;EAAA,CAAS;AACrB","ignoreList":[]}
1
+ {"version":3,"names":["AnimatePresence","PresenceChild","startTransition","useEffect","useState","Fragment","jsx","Animate","children","lazyMount","type","present","props","lazyMounted","setLazyMounted","mounted","keepChildrenMounted","initial","onExitComplete","enterVariant","exitVariant","enterExitVariant","presenceAffectsLayout","isPresent","custom"],"sources":["../../src/Animate.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,eAAA,EAAiBC,aAAA,QAAqB;AAC/C,SAASC,eAAA,EAAiBC,SAAA,EAAWC,QAAA,QAAgB;AA0D7C,SAoBCC,QAAA,EApBDC,GAAA;AAvBD,SAASC,QAAQ;EACtBC,QAAA;EACAC,SAAA;EACAC,IAAA;EACAC,OAAA;EACA,GAAGC;AACL,GAAkC;EAChC,MAAM,CAACC,WAAA,EAAaC,cAAc,IAAIV,QAAA,CAASK,SAAA,GAAY,KAAQE,OAAO;EAE1ER,SAAA,CAAU,MAAM;IACTM,SAAA,IACAE,OAAA,IACLT,eAAA,CAAgB,MAAM;MACpBY,cAAA,CAAeH,OAAO;IACxB,CAAC;EACH,GAAG,CAACF,SAAA,EAAWE,OAAO,CAAC;EAGvB,MAAMI,OAAA,GAAWJ,OAAA,GAAkBF,SAAA,GAAYI,WAAA,GAAcF,OAAA,GAAlC;EAE3B,OAAID,IAAA,KAAS,aACPE,KAAA,CAAMI,mBAAA,GAEN,eAAAV,GAAA,CAACL,aAAA;IACCgB,OAAA,EAASL,KAAA,CAAMK,OAAA,GAAU,SAAY;IACrCC,cAAA,EAAgBN,KAAA,CAAMM,cAAA;IACtBC,YAAA,EAAcP,KAAA,CAAMO,YAAA;IACpBC,WAAA,EAAaR,KAAA,CAAMQ,WAAA;IACnBC,gBAAA,EAAkBT,KAAA,CAAMS,gBAAA;IAGxBC,qBAAA,EAAuB;IACvBC,SAAA,EAAWZ,OAAA;IACXa,MAAA,EAAQZ,KAAA,CAAMY,MAAA;IAEbhB;EAAA,CACH,IAIG,eAAAF,GAAA,CAACN,eAAA;IAAiB,GAAGY,KAAA;IAAQJ,QAAA,EAAAO,OAAA,GAAUP,QAAA,GAAW;EAAA,CAAK,IAGzD,eAAAF,GAAA,CAAAD,QAAA;IAAGG;EAAA,CAAS;AACrB","ignoreList":[]}
@@ -1,11 +1,21 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { AnimatePresence, PresenceChild } from "@tamagui/animate-presence";
3
+ import { startTransition, useEffect, useState } from "react";
3
4
  function Animate(param) {
4
5
  var {
5
- children,
6
- type,
7
- ...props
8
- } = param;
6
+ children,
7
+ lazyMount,
8
+ type,
9
+ present,
10
+ ...props
11
+ } = param,
12
+ [lazyMounted, setLazyMounted] = useState(lazyMount ? !1 : present);
13
+ useEffect(function () {
14
+ lazyMount && present && startTransition(function () {
15
+ setLazyMounted(present);
16
+ });
17
+ }, [lazyMount, present]);
18
+ var mounted = present ? lazyMount ? lazyMounted : present : !1;
9
19
  return type === "presence" ? props.keepChildrenMounted ? /* @__PURE__ */_jsx(PresenceChild, {
10
20
  initial: props.initial ? void 0 : !1,
11
21
  onExitComplete: props.onExitComplete,
@@ -15,12 +25,12 @@ function Animate(param) {
15
25
  // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
16
26
  // but since we always re-render this component on open changes this should be fine to leave off?
17
27
  presenceAffectsLayout: !1,
18
- isPresent: props.present,
28
+ isPresent: present,
19
29
  custom: props.custom,
20
30
  children
21
31
  }) : /* @__PURE__ */_jsx(AnimatePresence, {
22
32
  ...props,
23
- children: props.present ? children : null
33
+ children: mounted ? children : null
24
34
  }) : /* @__PURE__ */_jsx(_Fragment, {
25
35
  children
26
36
  });
@@ -1 +1 @@
1
- {"version":3,"names":["jsx","_jsx","Fragment","_Fragment","AnimatePresence","PresenceChild","Animate","param","children","type","props","keepChildrenMounted","initial","onExitComplete","enterVariant","exitVariant","enterExitVariant","presenceAffectsLayout","isPresent","present","custom"],"sources":["../../src/Animate.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,GAAA,IAAAC,IAAA,EAAAC,QAAiB,IAAAC,SAAA,QAAqB;AAsCvC,SAoBCC,eApBD,EAAAC,aAAA;AAJD,SAASC,QAAQC,KAAE;EACxB;IAAAC,QAAI;IAASC,IAAA;IAAA,GAAAC;EACP,IAAMH,KAAA;EAEN,OAACE,IAAA,kBAAAC,KAAA,CAAAC,mBAAA,kBAAAV,IAAA,CAAAI,aAAA;IAAAO,OAAA,EAAAF,KAAA,CAAAE,OAAA;IAAAC,cACU,EAAAH,KAAM,CAAAG,cAAsB;IAAAC,YACrC,EAAAJ,KAAgB,CAAAI,YAAM;IAAAC,WACtB,EAAAL,KAAc,CAAAK,WAAM;IAAAC,gBACP,EAAAN,KAAM,CAAAM,gBAAA;IAAA;IACK;IAGDC,qBACN;IAAAC,SACjB,EAAQR,KAAM,CAAAS,OAAA;IAAAC,MAEb,EAAAV,KAAA,CAAAU,MAAA;IAAAZ;EACH,KAIG,eAAAP,IAAC,CAAAG,eAAA,EAAiB;IAI7B,GAAAM,KAAA","ignoreList":[]}
1
+ {"version":3,"names":["jsx","_jsx","Fragment","_Fragment","AnimatePresence","PresenceChild","startTransition","useEffect","useState","Animate","param","children","lazyMount","type","present","props","lazyMounted","setLazyMounted","mounted","keepChildrenMounted","initial","onExitComplete","enterVariant","exitVariant","enterExitVariant","presenceAffectsLayout","isPresent","custom"],"sources":["../../src/Animate.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,GAAA,IAAAC,IAAA,EAAAC,QAAiB,IAAAC,SAAA,QAAqB;AAC/C,SAASC,eAAA,EAAiBC,aAAW,mCAAgB;AA0D7C,SAoBCC,eApBD,EAAAC,SAAA,EAAAC,QAAA;AAvBD,SAASC,QAAQC,KAAA;EACtB;MAAAC,QAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,OAAA;MAAA,GAAAC;IAAA,IAAAL,KAAA;IAAA,CAAAM,WAAA,EAAAC,cAAA,IAAAT,QAAA,CAAAI,SAAA,QAAAE,OAAA;EACAP,SAAA;IACAK,SAAA,IAAAE,OAAA,IAAAR,eAAA;MACAW,cAAA,CAAAH,OAAA;IACA,CAAG;EACL,CAAkC,GAChCF,SAAO,EAEPE,OAAA,CACE,CAAK;EAGH,IAAAI,OAAA,GAAAJ,OAAe,GAAAF,SAAO,GAAAI,WAAA,GAAAF,OAAA;EAAA,OACvBD,IAAA,kBAAAE,KAAA,CAAAI,mBAAA,kBAAAlB,IAAA,CAAAI,aAAA;IACHe,OAAI,EAAAL,KAAW,CAAAK,OAAQ;IAGvBC,cAAiB,EAAAN,KAAA,CAAAM,cAA8B;IAE/CC,YAAI,EAASP,KAAA,CAAAO,YACP;IAECC,WAAA,EAAAR,KAAA,CAAAQ,WAAA;IAAAC,gBAAA,EAAAT,KAAA,CAAAS,gBAAA;IAAA;IACsC;IACfC,qBACR,EAAM;IAAAC,SACpB,EAAAZ,OAAa;IAAMa,MACnB,EAAAZ,KAAA,CAAAY,MAAkB;IAAMhB;EAGD,KACvB,eAAWV,IAAA,CAAAG,eAAA;IAAA,GACXW,KAAA;IAAcJ,QAEb,EAAAO,OAAA,GAAAP,QAAA;EAAA,oBAAAV,IAAA,CAAAE,SAAA;IACHQ;EAQR","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/animate",
3
- "version": "1.128.1",
3
+ "version": "1.129.1",
4
4
  "source": "src/index.ts",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -13,10 +13,10 @@
13
13
  "dist"
14
14
  ],
15
15
  "dependencies": {
16
- "@tamagui/animate-presence": "1.128.1"
16
+ "@tamagui/animate-presence": "1.129.1"
17
17
  },
18
18
  "devDependencies": {
19
- "@tamagui/build": "1.128.1"
19
+ "@tamagui/build": "1.129.1"
20
20
  },
21
21
  "scripts": {
22
22
  "build": "tamagui-build",
package/src/Animate.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { AnimatePresenceProps } from '@tamagui/animate-presence'
2
2
  import { AnimatePresence, PresenceChild } from '@tamagui/animate-presence'
3
+ import { startTransition, useEffect, useState } from 'react'
3
4
  import type { JSX } from 'react/jsx-runtime'
4
5
 
5
6
  type BaseProps = {
@@ -10,6 +11,7 @@ type PresenceProps = AnimatePresenceProps & {
10
11
  type: 'presence'
11
12
  present: boolean
12
13
  keepChildrenMounted?: boolean
14
+ lazyMount?: boolean
13
15
  }
14
16
 
15
17
  export type AnimateProps = BaseProps & PresenceProps
@@ -33,7 +35,26 @@ export type AnimateProps = BaseProps & PresenceProps
33
35
  *
34
36
  */
35
37
 
36
- export function Animate({ children, type, ...props }: AnimateProps): JSX.Element {
38
+ export function Animate({
39
+ children,
40
+ lazyMount,
41
+ type,
42
+ present,
43
+ ...props
44
+ }: AnimateProps): React.ReactNode {
45
+ const [lazyMounted, setLazyMounted] = useState(lazyMount ? false : present)
46
+
47
+ useEffect(() => {
48
+ if (!lazyMount) return
49
+ if (!present) return
50
+ startTransition(() => {
51
+ setLazyMounted(present)
52
+ })
53
+ }, [lazyMount, present])
54
+
55
+ // always immediately unmount
56
+ const mounted = !present ? false : lazyMount ? lazyMounted : present
57
+
37
58
  if (type === 'presence') {
38
59
  if (props.keepChildrenMounted) {
39
60
  return (
@@ -46,7 +67,7 @@ export function Animate({ children, type, ...props }: AnimateProps): JSX.Element
46
67
  // BUGFIX: this causes continous re-renders if keepChildrenMounted is true, see HeaderMenu
47
68
  // but since we always re-render this component on open changes this should be fine to leave off?
48
69
  presenceAffectsLayout={false}
49
- isPresent={props.present}
70
+ isPresent={present}
50
71
  custom={props.custom}
51
72
  >
52
73
  {children as any}
@@ -54,7 +75,7 @@ export function Animate({ children, type, ...props }: AnimateProps): JSX.Element
54
75
  )
55
76
  }
56
77
 
57
- return <AnimatePresence {...props}>{props.present ? children : null}</AnimatePresence>
78
+ return <AnimatePresence {...props}>{mounted ? children : null}</AnimatePresence>
58
79
  }
59
80
 
60
81
  return <>{children}</>
@@ -1,10 +1,12 @@
1
1
  import type { AnimatePresenceProps } from "@tamagui/animate-presence";
2
- import type { JSX } from "react/jsx-runtime";
3
- type BaseProps = { children: React.ReactNode };
2
+ type BaseProps = {
3
+ children: React.ReactNode;
4
+ };
4
5
  type PresenceProps = AnimatePresenceProps & {
5
6
  type: "presence";
6
7
  present: boolean;
7
8
  keepChildrenMounted?: boolean;
9
+ lazyMount?: boolean;
8
10
  };
9
11
  export type AnimateProps = BaseProps & PresenceProps;
10
12
  /**
@@ -25,7 +27,7 @@ export type AnimateProps = BaseProps & PresenceProps;
25
27
  *
26
28
  *
27
29
  */
28
- export declare function Animate({ children, type,...props }: AnimateProps): JSX.Element;
30
+ export declare function Animate({ children, lazyMount, type, present,...props }: AnimateProps): React.ReactNode;
29
31
  export {};
30
32
 
31
33
  //# sourceMappingURL=Animate.d.ts.map
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AAAA,cAAc,4BAA4B,2BAA2B;AAErE,cAAc,WAAW,mBAAmB;KAEvC,YAAY,EACf,UAAU,MAAM,UACjB;KAEI,gBAAgB,uBAAuB;CAC1C,MAAM;CACN;CACA;AACD;AAED,YAAY,eAAe,YAAY;;;;;;;;;;;;;;;;;;;AAqBvC,OAAO,iBAAS,QAAQ,EAAE,UAAU,KAAM,GAAG,OAAqB,EAAZ,eAAe,IAAI",
2
+ "mappings": "AAAA,cAAc,4BAA4B,2BAA2B;KAKhE,YAAY;CACf,UAAU,MAAM;AACjB;KAEI,gBAAgB,uBAAuB;CAC1C,MAAM;CACN;CACA;CACA;AACD;AAED,YAAY,eAAe,YAAY;;;;;;;;;;;;;;;;;;;AAqBvC,OAAO,iBAAS,QAAQ,EACtB,UACA,WACA,MACA,QACA,GAAG,OACU,EAAZ,eAAe,MAAM",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/Animate.tsx"
6
6
  ],
7
7
  "sourcesContent": [
8
- "import type { AnimatePresenceProps } from '@tamagui/animate-presence'\nimport { AnimatePresence, PresenceChild } from '@tamagui/animate-presence'\nimport type { JSX } from 'react/jsx-runtime'\n\ntype BaseProps = {\n children: React.ReactNode\n}\n\ntype PresenceProps = AnimatePresenceProps & {\n type: 'presence'\n present: boolean\n keepChildrenMounted?: 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({ children, type, ...props }: AnimateProps): JSX.Element {\n if (type === 'presence') {\n if (props.keepChildrenMounted) {\n return (\n <PresenceChild\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={props.present}\n custom={props.custom}\n >\n {children as any}\n </PresenceChild>\n )\n }\n\n return <AnimatePresence {...props}>{props.present ? children : null}</AnimatePresence>\n }\n\n return <>{children}</>\n}\n"
8
+ "import type { AnimatePresenceProps } from '@tamagui/animate-presence'\nimport { AnimatePresence, PresenceChild } from '@tamagui/animate-presence'\nimport { startTransition, useEffect, useState } from 'react'\nimport type { JSX } from 'react/jsx-runtime'\n\ntype BaseProps = {\n children: React.ReactNode\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 ...props\n}: AnimateProps): React.ReactNode {\n const [lazyMounted, setLazyMounted] = useState(lazyMount ? false : present)\n\n useEffect(() => {\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 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 {children as any}\n </PresenceChild>\n )\n }\n\n return <AnimatePresence {...props}>{mounted ? children : null}</AnimatePresence>\n }\n\n return <>{children}</>\n}\n"
9
9
  ],
10
10
  "version": 3
11
11
  }