@tamagui/animations-css 1.0.1-beta.139 → 1.0.1-beta.142

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.
@@ -21,24 +21,51 @@ __export(createAnimations_exports, {
21
21
  createAnimations: () => createAnimations
22
22
  });
23
23
  module.exports = __toCommonJS(createAnimations_exports);
24
+ var import_core = require("@tamagui/core");
25
+ var import_react = require("react");
24
26
  function createAnimations(animations) {
25
27
  return {
26
28
  avoidClasses: false,
27
- View: "div",
28
- Text: "span",
29
+ View: import_core.Stack,
30
+ Text: import_core.Text,
29
31
  animations,
32
+ useAnimatedNumber(initial) {
33
+ const val = (0, import_react.useRef)(initial);
34
+ return {
35
+ getInstance() {
36
+ return val;
37
+ },
38
+ getValue() {
39
+ return val.current;
40
+ },
41
+ setValue(next) {
42
+ val.current = next;
43
+ },
44
+ stop() {
45
+ }
46
+ };
47
+ },
48
+ useAnimatedNumberReaction(val, reaction) {
49
+ },
50
+ useAnimatedNumberStyle(val, getStyle) {
51
+ return getStyle(val.getValue());
52
+ },
30
53
  useAnimations: (props, { getStyle }) => {
31
- const animation = animations[props.animation];
54
+ const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation;
55
+ const animation = animations[animationKey];
32
56
  if (!animation) {
33
57
  throw new Error(`no animation found: ${props.animation}`);
34
58
  }
35
59
  const keys = props.animateOnly ? props.animateOnly.join(" ") : "all";
36
- return {
60
+ const style = {
37
61
  style: {
38
62
  transition: `${keys} ${animation}`,
39
63
  ...getStyle()
40
64
  }
41
65
  };
66
+ return (0, import_react.useMemo)(() => {
67
+ return style;
68
+ }, [JSON.stringify(style)]);
42
69
  }
43
70
  };
44
71
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createAnimations.tsx"],
4
- "sourcesContent": ["import { AnimationDriver } from '@tamagui/core'\n\nexport function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {\n return {\n avoidClasses: false,\n View: 'div',\n Text: 'span',\n animations,\n useAnimations: (props, { getStyle }) => {\n const animation = animations[props.animation as any]\n if (!animation) {\n throw new Error(`no animation found: ${props.animation}`)\n }\n\n const keys = props.animateOnly ? props.animateOnly.join(' ') : 'all'\n\n return {\n style: {\n transition: `${keys} ${animation}`,\n ...getStyle(),\n },\n }\n },\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,0BAA4C,YAAmC;AACpF,SAAO;AAAA,IACL,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,eAAe,CAAC,OAAO,EAAE,eAAe;AACtC,YAAM,YAAY,WAAW,MAAM;AACnC,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,uBAAuB,MAAM,WAAW;AAAA,MAC1D;AAEA,YAAM,OAAO,MAAM,cAAc,MAAM,YAAY,KAAK,GAAG,IAAI;AAE/D,aAAO;AAAA,QACL,OAAO;AAAA,UACL,YAAY,GAAG,QAAQ;AAAA,UACvB,GAAG,SAAS;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { AnimationDriver, Stack, Text } from '@tamagui/core'\nimport { useMemo, useRef } from 'react'\n\nexport function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {\n return {\n avoidClasses: false,\n View: Stack,\n Text: Text,\n animations,\n\n useAnimatedNumber(initial) {\n const val = useRef(initial)\n return {\n getInstance() {\n return val\n },\n getValue() {\n return val.current\n },\n setValue(next) {\n val.current = next\n },\n stop() {},\n }\n },\n\n useAnimatedNumberReaction(val, reaction) {\n // TODO use event listeners, would need access to the corresponsing node...\n },\n\n useAnimatedNumberStyle(val, getStyle) {\n return getStyle(val.getValue())\n },\n\n useAnimations: (props, { getStyle }) => {\n const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation\n const animation = animations[animationKey as any]\n if (!animation) {\n throw new Error(`no animation found: ${props.animation}`)\n }\n\n const keys = props.animateOnly ? props.animateOnly.join(' ') : 'all'\n\n const style = {\n style: {\n transition: `${keys} ${animation}`,\n ...getStyle(),\n },\n }\n\n return useMemo(() => {\n return style\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(style)])\n },\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6C;AAC7C,mBAAgC;AAEzB,0BAA4C,YAAmC;AACpF,SAAO;AAAA,IACL,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IAEA,kBAAkB,SAAS;AACzB,YAAM,MAAM,yBAAO,OAAO;AAC1B,aAAO;AAAA,QACL,cAAc;AACZ,iBAAO;AAAA,QACT;AAAA,QACA,WAAW;AACT,iBAAO,IAAI;AAAA,QACb;AAAA,QACA,SAAS,MAAM;AACb,cAAI,UAAU;AAAA,QAChB;AAAA,QACA,OAAO;AAAA,QAAC;AAAA,MACV;AAAA,IACF;AAAA,IAEA,0BAA0B,KAAK,UAAU;AAAA,IAEzC;AAAA,IAEA,uBAAuB,KAAK,UAAU;AACpC,aAAO,SAAS,IAAI,SAAS,CAAC;AAAA,IAChC;AAAA,IAEA,eAAe,CAAC,OAAO,EAAE,eAAe;AACtC,YAAM,eAAe,MAAM,QAAQ,MAAM,SAAS,IAAI,MAAM,UAAU,KAAK,MAAM;AACjF,YAAM,YAAY,WAAW;AAC7B,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,uBAAuB,MAAM,WAAW;AAAA,MAC1D;AAEA,YAAM,OAAO,MAAM,cAAc,MAAM,YAAY,KAAK,GAAG,IAAI;AAE/D,YAAM,QAAQ;AAAA,QACZ,OAAO;AAAA,UACL,YAAY,GAAG,QAAQ;AAAA,UACvB,GAAG,SAAS;AAAA,QACd;AAAA,MACF;AAEA,aAAO,0BAAQ,MAAM;AACnB,eAAO;AAAA,MAET,GAAG,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAAA,IAC5B;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/dist/cjs/index.js CHANGED
File without changes
File without changes
@@ -1,21 +1,48 @@
1
+ import { Stack, Text } from "@tamagui/core";
2
+ import { useMemo, useRef } from "react";
1
3
  function createAnimations(animations) {
2
4
  return {
3
5
  avoidClasses: false,
4
- View: "div",
5
- Text: "span",
6
+ View: Stack,
7
+ Text,
6
8
  animations,
9
+ useAnimatedNumber(initial) {
10
+ const val = useRef(initial);
11
+ return {
12
+ getInstance() {
13
+ return val;
14
+ },
15
+ getValue() {
16
+ return val.current;
17
+ },
18
+ setValue(next) {
19
+ val.current = next;
20
+ },
21
+ stop() {
22
+ }
23
+ };
24
+ },
25
+ useAnimatedNumberReaction(val, reaction) {
26
+ },
27
+ useAnimatedNumberStyle(val, getStyle) {
28
+ return getStyle(val.getValue());
29
+ },
7
30
  useAnimations: (props, { getStyle }) => {
8
- const animation = animations[props.animation];
31
+ const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation;
32
+ const animation = animations[animationKey];
9
33
  if (!animation) {
10
34
  throw new Error(`no animation found: ${props.animation}`);
11
35
  }
12
36
  const keys = props.animateOnly ? props.animateOnly.join(" ") : "all";
13
- return {
37
+ const style = {
14
38
  style: {
15
39
  transition: `${keys} ${animation}`,
16
40
  ...getStyle()
17
41
  }
18
42
  };
43
+ return useMemo(() => {
44
+ return style;
45
+ }, [JSON.stringify(style)]);
19
46
  }
20
47
  };
21
48
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createAnimations.tsx"],
4
- "sourcesContent": ["import { AnimationDriver } from '@tamagui/core'\n\nexport function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {\n return {\n avoidClasses: false,\n View: 'div',\n Text: 'span',\n animations,\n useAnimations: (props, { getStyle }) => {\n const animation = animations[props.animation as any]\n if (!animation) {\n throw new Error(`no animation found: ${props.animation}`)\n }\n\n const keys = props.animateOnly ? props.animateOnly.join(' ') : 'all'\n\n return {\n style: {\n transition: `${keys} ${animation}`,\n ...getStyle(),\n },\n }\n },\n }\n}\n"],
5
- "mappings": "AAEO,0BAA4C,YAAmC;AACpF,SAAO;AAAA,IACL,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,eAAe,CAAC,OAAO,EAAE,eAAe;AACtC,YAAM,YAAY,WAAW,MAAM;AACnC,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,uBAAuB,MAAM,WAAW;AAAA,MAC1D;AAEA,YAAM,OAAO,MAAM,cAAc,MAAM,YAAY,KAAK,GAAG,IAAI;AAE/D,aAAO;AAAA,QACL,OAAO;AAAA,UACL,YAAY,GAAG,QAAQ;AAAA,UACvB,GAAG,SAAS;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { AnimationDriver, Stack, Text } from '@tamagui/core'\nimport { useMemo, useRef } from 'react'\n\nexport function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {\n return {\n avoidClasses: false,\n View: Stack,\n Text: Text,\n animations,\n\n useAnimatedNumber(initial) {\n const val = useRef(initial)\n return {\n getInstance() {\n return val\n },\n getValue() {\n return val.current\n },\n setValue(next) {\n val.current = next\n },\n stop() {},\n }\n },\n\n useAnimatedNumberReaction(val, reaction) {\n // TODO use event listeners, would need access to the corresponsing node...\n },\n\n useAnimatedNumberStyle(val, getStyle) {\n return getStyle(val.getValue())\n },\n\n useAnimations: (props, { getStyle }) => {\n const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation\n const animation = animations[animationKey as any]\n if (!animation) {\n throw new Error(`no animation found: ${props.animation}`)\n }\n\n const keys = props.animateOnly ? props.animateOnly.join(' ') : 'all'\n\n const style = {\n style: {\n transition: `${keys} ${animation}`,\n ...getStyle(),\n },\n }\n\n return useMemo(() => {\n return style\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(style)])\n },\n }\n}\n"],
5
+ "mappings": "AAAA;AACA;AAEO,0BAA4C,YAAmC;AACpF,SAAO;AAAA,IACL,cAAc;AAAA,IACd,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IAEA,kBAAkB,SAAS;AACzB,YAAM,MAAM,OAAO,OAAO;AAC1B,aAAO;AAAA,QACL,cAAc;AACZ,iBAAO;AAAA,QACT;AAAA,QACA,WAAW;AACT,iBAAO,IAAI;AAAA,QACb;AAAA,QACA,SAAS,MAAM;AACb,cAAI,UAAU;AAAA,QAChB;AAAA,QACA,OAAO;AAAA,QAAC;AAAA,MACV;AAAA,IACF;AAAA,IAEA,0BAA0B,KAAK,UAAU;AAAA,IAEzC;AAAA,IAEA,uBAAuB,KAAK,UAAU;AACpC,aAAO,SAAS,IAAI,SAAS,CAAC;AAAA,IAChC;AAAA,IAEA,eAAe,CAAC,OAAO,EAAE,eAAe;AACtC,YAAM,eAAe,MAAM,QAAQ,MAAM,SAAS,IAAI,MAAM,UAAU,KAAK,MAAM;AACjF,YAAM,YAAY,WAAW;AAC7B,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,uBAAuB,MAAM,WAAW;AAAA,MAC1D;AAEA,YAAM,OAAO,MAAM,cAAc,MAAM,YAAY,KAAK,GAAG,IAAI;AAE/D,YAAM,QAAQ;AAAA,QACZ,OAAO;AAAA,UACL,YAAY,GAAG,QAAQ;AAAA,UACvB,GAAG,SAAS;AAAA,QACd;AAAA,MACF;AAEA,aAAO,QAAQ,MAAM;AACnB,eAAO;AAAA,MAET,GAAG,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAAA,IAC5B;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
File without changes
File without changes
@@ -1,21 +1,48 @@
1
+ import { Stack, Text } from "@tamagui/core";
2
+ import { useMemo, useRef } from "react";
1
3
  function createAnimations(animations) {
2
4
  return {
3
5
  avoidClasses: false,
4
- View: "div",
5
- Text: "span",
6
+ View: Stack,
7
+ Text,
6
8
  animations,
9
+ useAnimatedNumber(initial) {
10
+ const val = useRef(initial);
11
+ return {
12
+ getInstance() {
13
+ return val;
14
+ },
15
+ getValue() {
16
+ return val.current;
17
+ },
18
+ setValue(next) {
19
+ val.current = next;
20
+ },
21
+ stop() {
22
+ }
23
+ };
24
+ },
25
+ useAnimatedNumberReaction(val, reaction) {
26
+ },
27
+ useAnimatedNumberStyle(val, getStyle) {
28
+ return getStyle(val.getValue());
29
+ },
7
30
  useAnimations: (props, { getStyle }) => {
8
- const animation = animations[props.animation];
31
+ const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation;
32
+ const animation = animations[animationKey];
9
33
  if (!animation) {
10
34
  throw new Error(`no animation found: ${props.animation}`);
11
35
  }
12
36
  const keys = props.animateOnly ? props.animateOnly.join(" ") : "all";
13
- return {
37
+ const style = {
14
38
  style: {
15
39
  transition: `${keys} ${animation}`,
16
40
  ...getStyle()
17
41
  }
18
42
  };
43
+ return useMemo(() => {
44
+ return style;
45
+ }, [JSON.stringify(style)]);
19
46
  }
20
47
  };
21
48
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createAnimations.tsx"],
4
- "sourcesContent": ["import { AnimationDriver } from '@tamagui/core'\n\nexport function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {\n return {\n avoidClasses: false,\n View: 'div',\n Text: 'span',\n animations,\n useAnimations: (props, { getStyle }) => {\n const animation = animations[props.animation as any]\n if (!animation) {\n throw new Error(`no animation found: ${props.animation}`)\n }\n\n const keys = props.animateOnly ? props.animateOnly.join(' ') : 'all'\n\n return {\n style: {\n transition: `${keys} ${animation}`,\n ...getStyle(),\n },\n }\n },\n }\n}\n"],
5
- "mappings": "AAEO,0BAA4C,YAAmC;AACpF,SAAO;AAAA,IACL,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,eAAe,CAAC,OAAO,EAAE,eAAe;AACtC,YAAM,YAAY,WAAW,MAAM;AACnC,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,uBAAuB,MAAM,WAAW;AAAA,MAC1D;AAEA,YAAM,OAAO,MAAM,cAAc,MAAM,YAAY,KAAK,GAAG,IAAI;AAE/D,aAAO;AAAA,QACL,OAAO;AAAA,UACL,YAAY,GAAG,QAAQ;AAAA,UACvB,GAAG,SAAS;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { AnimationDriver, Stack, Text } from '@tamagui/core'\nimport { useMemo, useRef } from 'react'\n\nexport function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {\n return {\n avoidClasses: false,\n View: Stack,\n Text: Text,\n animations,\n\n useAnimatedNumber(initial) {\n const val = useRef(initial)\n return {\n getInstance() {\n return val\n },\n getValue() {\n return val.current\n },\n setValue(next) {\n val.current = next\n },\n stop() {},\n }\n },\n\n useAnimatedNumberReaction(val, reaction) {\n // TODO use event listeners, would need access to the corresponsing node...\n },\n\n useAnimatedNumberStyle(val, getStyle) {\n return getStyle(val.getValue())\n },\n\n useAnimations: (props, { getStyle }) => {\n const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation\n const animation = animations[animationKey as any]\n if (!animation) {\n throw new Error(`no animation found: ${props.animation}`)\n }\n\n const keys = props.animateOnly ? props.animateOnly.join(' ') : 'all'\n\n const style = {\n style: {\n transition: `${keys} ${animation}`,\n ...getStyle(),\n },\n }\n\n return useMemo(() => {\n return style\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(style)])\n },\n }\n}\n"],
5
+ "mappings": "AAAA;AACA;AAEO,0BAA4C,YAAmC;AACpF,SAAO;AAAA,IACL,cAAc;AAAA,IACd,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IAEA,kBAAkB,SAAS;AACzB,YAAM,MAAM,OAAO,OAAO;AAC1B,aAAO;AAAA,QACL,cAAc;AACZ,iBAAO;AAAA,QACT;AAAA,QACA,WAAW;AACT,iBAAO,IAAI;AAAA,QACb;AAAA,QACA,SAAS,MAAM;AACb,cAAI,UAAU;AAAA,QAChB;AAAA,QACA,OAAO;AAAA,QAAC;AAAA,MACV;AAAA,IACF;AAAA,IAEA,0BAA0B,KAAK,UAAU;AAAA,IAEzC;AAAA,IAEA,uBAAuB,KAAK,UAAU;AACpC,aAAO,SAAS,IAAI,SAAS,CAAC;AAAA,IAChC;AAAA,IAEA,eAAe,CAAC,OAAO,EAAE,eAAe;AACtC,YAAM,eAAe,MAAM,QAAQ,MAAM,SAAS,IAAI,MAAM,UAAU,KAAK,MAAM;AACjF,YAAM,YAAY,WAAW;AAC7B,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,MAAM,uBAAuB,MAAM,WAAW;AAAA,MAC1D;AAEA,YAAM,OAAO,MAAM,cAAc,MAAM,YAAY,KAAK,GAAG,IAAI;AAE/D,YAAM,QAAQ;AAAA,QACZ,OAAO;AAAA,UACL,YAAY,GAAG,QAAQ;AAAA,UACvB,GAAG,SAAS;AAAA,QACd;AAAA,MACF;AAEA,aAAO,QAAQ,MAAM;AACnB,eAAO;AAAA,MAET,GAAG,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAAA,IAC5B;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/dist/jsx/index.js CHANGED
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/animations-css",
3
- "version": "1.0.1-beta.139",
3
+ "version": "1.0.1-beta.142",
4
4
  "source": "src/index.ts",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -14,10 +14,10 @@
14
14
  "dist"
15
15
  ],
16
16
  "dependencies": {
17
- "@tamagui/core": "^1.0.1-beta.139"
17
+ "@tamagui/core": "^1.0.1-beta.142"
18
18
  },
19
19
  "devDependencies": {
20
- "@tamagui/build": "^1.0.1-beta.139"
20
+ "@tamagui/build": "^1.0.1-beta.142"
21
21
  },
22
22
  "scripts": {
23
23
  "build": "tamagui-build",
@@ -1,25 +1,57 @@
1
- import { AnimationDriver } from '@tamagui/core'
1
+ import { AnimationDriver, Stack, Text } from '@tamagui/core'
2
+ import { useMemo, useRef } from 'react'
2
3
 
3
4
  export function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {
4
5
  return {
5
6
  avoidClasses: false,
6
- View: 'div',
7
- Text: 'span',
7
+ View: Stack,
8
+ Text: Text,
8
9
  animations,
10
+
11
+ useAnimatedNumber(initial) {
12
+ const val = useRef(initial)
13
+ return {
14
+ getInstance() {
15
+ return val
16
+ },
17
+ getValue() {
18
+ return val.current
19
+ },
20
+ setValue(next) {
21
+ val.current = next
22
+ },
23
+ stop() {},
24
+ }
25
+ },
26
+
27
+ useAnimatedNumberReaction(val, reaction) {
28
+ // TODO use event listeners, would need access to the corresponsing node...
29
+ },
30
+
31
+ useAnimatedNumberStyle(val, getStyle) {
32
+ return getStyle(val.getValue())
33
+ },
34
+
9
35
  useAnimations: (props, { getStyle }) => {
10
- const animation = animations[props.animation as any]
36
+ const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation
37
+ const animation = animations[animationKey as any]
11
38
  if (!animation) {
12
39
  throw new Error(`no animation found: ${props.animation}`)
13
40
  }
14
41
 
15
42
  const keys = props.animateOnly ? props.animateOnly.join(' ') : 'all'
16
43
 
17
- return {
44
+ const style = {
18
45
  style: {
19
46
  transition: `${keys} ${animation}`,
20
47
  ...getStyle(),
21
48
  },
22
49
  }
50
+
51
+ return useMemo(() => {
52
+ return style
53
+ // eslint-disable-next-line react-hooks/exhaustive-deps
54
+ }, [JSON.stringify(style)])
23
55
  },
24
56
  }
25
57
  }
File without changes
package/types/index.d.ts CHANGED
File without changes