@tamagui/animations-css 1.0.1-beta.141 → 1.0.1-beta.144

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,15 +21,38 @@ __export(createAnimations_exports, {
21
21
  createAnimations: () => createAnimations
22
22
  });
23
23
  module.exports = __toCommonJS(createAnimations_exports);
24
+ var import_core = require("@tamagui/core");
24
25
  var import_react = require("react");
25
26
  function createAnimations(animations) {
26
27
  return {
27
28
  avoidClasses: false,
28
- View: "div",
29
- Text: "span",
29
+ View: import_core.Stack,
30
+ Text: import_core.Text,
30
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
+ },
31
53
  useAnimations: (props, { getStyle }) => {
32
- const animation = animations[props.animation];
54
+ const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation;
55
+ const animation = animations[animationKey];
33
56
  if (!animation) {
34
57
  throw new Error(`no animation found: ${props.animation}`);
35
58
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createAnimations.tsx"],
4
- "sourcesContent": ["import { AnimationDriver } from '@tamagui/core'\nimport { useMemo } from 'react'\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 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;AACA,mBAAwB;AAEjB,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,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;",
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
  }
@@ -1,12 +1,35 @@
1
- import { useMemo } from "react";
1
+ import { Stack, Text } from "@tamagui/core";
2
+ import { useMemo, useRef } from "react";
2
3
  function createAnimations(animations) {
3
4
  return {
4
5
  avoidClasses: false,
5
- View: "div",
6
- Text: "span",
6
+ View: Stack,
7
+ Text,
7
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
+ },
8
30
  useAnimations: (props, { getStyle }) => {
9
- const animation = animations[props.animation];
31
+ const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation;
32
+ const animation = animations[animationKey];
10
33
  if (!animation) {
11
34
  throw new Error(`no animation found: ${props.animation}`);
12
35
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createAnimations.tsx"],
4
- "sourcesContent": ["import { AnimationDriver } from '@tamagui/core'\nimport { useMemo } from 'react'\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 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": "AACA;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,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;",
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
  }
@@ -1,12 +1,35 @@
1
- import { useMemo } from "react";
1
+ import { Stack, Text } from "@tamagui/core";
2
+ import { useMemo, useRef } from "react";
2
3
  function createAnimations(animations) {
3
4
  return {
4
5
  avoidClasses: false,
5
- View: "div",
6
- Text: "span",
6
+ View: Stack,
7
+ Text,
7
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
+ },
8
30
  useAnimations: (props, { getStyle }) => {
9
- const animation = animations[props.animation];
31
+ const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation;
32
+ const animation = animations[animationKey];
10
33
  if (!animation) {
11
34
  throw new Error(`no animation found: ${props.animation}`);
12
35
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createAnimations.tsx"],
4
- "sourcesContent": ["import { AnimationDriver } from '@tamagui/core'\nimport { useMemo } from 'react'\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 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": "AACA;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,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;",
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/animations-css",
3
- "version": "1.0.1-beta.141",
3
+ "version": "1.0.1-beta.144",
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.141"
17
+ "@tamagui/core": "^1.0.1-beta.144"
18
18
  },
19
19
  "devDependencies": {
20
- "@tamagui/build": "^1.0.1-beta.141"
20
+ "@tamagui/build": "^1.0.1-beta.144"
21
21
  },
22
22
  "scripts": {
23
23
  "build": "tamagui-build",
@@ -1,14 +1,40 @@
1
- import { AnimationDriver } from '@tamagui/core'
2
- import { useMemo } from 'react'
1
+ import { AnimationDriver, Stack, Text } from '@tamagui/core'
2
+ import { useMemo, useRef } from 'react'
3
3
 
4
4
  export function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {
5
5
  return {
6
6
  avoidClasses: false,
7
- View: 'div',
8
- Text: 'span',
7
+ View: Stack,
8
+ Text: Text,
9
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
+
10
35
  useAnimations: (props, { getStyle }) => {
11
- 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]
12
38
  if (!animation) {
13
39
  throw new Error(`no animation found: ${props.animation}`)
14
40
  }