@coorpacademy/components 10.17.0 → 10.17.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.
Files changed (30) hide show
  1. package/README.md +21 -1
  2. package/es/atom/lottie-wrapper/index.js +37 -9
  3. package/es/atom/lottie-wrapper/index.js.map +1 -1
  4. package/es/atom/lottie-wrapper/test/fixtures/confetti.js +3 -1
  5. package/es/atom/lottie-wrapper/test/fixtures/confetti.js.map +1 -1
  6. package/es/atom/lottie-wrapper/test/fixtures/controls.js +10 -0
  7. package/es/atom/lottie-wrapper/test/fixtures/controls.js.map +1 -0
  8. package/es/atom/lottie-wrapper/test/fixtures/default.js +3 -1
  9. package/es/atom/lottie-wrapper/test/fixtures/default.js.map +1 -1
  10. package/es/atom/lottie-wrapper/test/fixtures/rank.js +3 -1
  11. package/es/atom/lottie-wrapper/test/fixtures/rank.js.map +1 -1
  12. package/es/atom/lottie-wrapper/test/fixtures.js +2 -0
  13. package/es/atom/lottie-wrapper/test/fixtures.js.map +1 -1
  14. package/es/atom/lottie-wrapper/test/lottie.js +57 -20
  15. package/es/atom/lottie-wrapper/test/lottie.js.map +1 -1
  16. package/lib/atom/lottie-wrapper/index.js +42 -10
  17. package/lib/atom/lottie-wrapper/index.js.map +1 -1
  18. package/lib/atom/lottie-wrapper/test/fixtures/confetti.js +3 -1
  19. package/lib/atom/lottie-wrapper/test/fixtures/confetti.js.map +1 -1
  20. package/lib/atom/lottie-wrapper/test/fixtures/controls.js +19 -0
  21. package/lib/atom/lottie-wrapper/test/fixtures/controls.js.map +1 -0
  22. package/lib/atom/lottie-wrapper/test/fixtures/default.js +3 -1
  23. package/lib/atom/lottie-wrapper/test/fixtures/default.js.map +1 -1
  24. package/lib/atom/lottie-wrapper/test/fixtures/rank.js +3 -1
  25. package/lib/atom/lottie-wrapper/test/fixtures/rank.js.map +1 -1
  26. package/lib/atom/lottie-wrapper/test/fixtures.js +3 -0
  27. package/lib/atom/lottie-wrapper/test/fixtures.js.map +1 -1
  28. package/lib/atom/lottie-wrapper/test/lottie.js +60 -21
  29. package/lib/atom/lottie-wrapper/test/lottie.js.map +1 -1
  30. package/package.json +4 -3
package/README.md CHANGED
@@ -116,7 +116,27 @@ const props = {
116
116
  height: 200,
117
117
  width: 200,
118
118
  ie11ImageBackup:
119
- 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'
119
+ 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
120
+ // autoplay: true // autoplay is true by default
121
+ }
122
+ ```
123
+
124
+ If you need to control the animation (play/pause/stop), then you must set autoplay to false &
125
+ add your desired state, among the available states: `play, pause, stop, loading`
126
+
127
+ ```javascript
128
+ const props = {
129
+ 'aria-label': 'aria lottie',
130
+ 'data-name': 'default-lottie',
131
+ className: undefined,
132
+ animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
133
+ loop: true,
134
+ height: 200,
135
+ width: 200,
136
+ ie11ImageBackup:
137
+ 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
138
+ autoplay: false,
139
+ animationControl: 'loading' // play can be passed directly without using loading first
120
140
  }
121
141
  ```
122
142
 
@@ -7,8 +7,16 @@ import lottie from 'lottie-web';
7
7
  import get from 'lodash/fp/get';
8
8
  import has from 'lodash/fp/has';
9
9
  import includes from 'lodash/fp/includes';
10
+ import keys from 'lodash/fp/keys';
11
+ import omit from 'lodash/fp/omit';
10
12
  import unfetch from 'isomorphic-unfetch';
11
13
  import style from './style.css';
14
+ export const ANIMATION_CONTROL = {
15
+ play: 'play',
16
+ pause: 'pause',
17
+ stop: 'stop',
18
+ loading: 'loading'
19
+ };
12
20
 
13
21
  const isIE11 = () => {
14
22
  if (typeof window === 'undefined') return;
@@ -19,7 +27,7 @@ const isIE11 = () => {
19
27
  return hasMsCrypto || hasRevision && hasTrident;
20
28
  };
21
29
 
22
- export const fetchAndLoadAnimation = async (animationSrc, containerRef, loop, animationClassnames, hideOnTransparent, _lottie, _fetch) => {
30
+ export const fetchAndLoadAnimation = async (_lottie, _fetch, animationSrc, containerRef, loop, animationClassnames, hideOnTransparent, autoplay) => {
23
31
  const animationUrl = new URL(animationSrc).toString();
24
32
  const fetchResult = await _fetch(animationUrl, {
25
33
  headers: {
@@ -33,7 +41,7 @@ export const fetchAndLoadAnimation = async (animationSrc, containerRef, loop, an
33
41
  container: containerRef.current,
34
42
  // the dom element that will contain the animation
35
43
  renderer: 'svg',
36
- autoplay: true,
44
+ autoplay,
37
45
  loop,
38
46
  animationData,
39
47
  rendererSettings: {
@@ -58,29 +66,44 @@ const LottieWrapper = props => {
58
66
  width,
59
67
  height,
60
68
  ie11ImageBackup,
61
- backupImageClassName
69
+ backupImageClassName,
70
+ autoplay = true,
71
+ animationControl
62
72
  } = props;
63
73
  const {
64
74
  className: animationClassName,
65
75
  hideOnTransparent = true
66
76
  } = rendererSettings;
67
- const containerRef = useRef(null);
77
+ const containerRef = useRef(null); // lottie's animation instance
78
+
68
79
  const [animationItem, setAnimationItem] = useState(null);
80
+ const [isAnimationVisible, setIsAnimationVisible] = useState(autoplay);
69
81
 
70
82
  const _isIE11 = useMemo(() => isIE11(), []);
71
83
 
72
84
  const wrapperClassName = useMemo(() => classnames(className, style.lottieContainer), [className]);
73
85
  const lottieAnimationClassName = useMemo(() => classnames(animationClassName, style.animation), [animationClassName]);
74
86
  const ie11BackupImageClassName = useMemo(() => classnames(backupImageClassName, style.backupImage), [backupImageClassName]);
87
+ useEffect(() => {
88
+ // enzyme does not handle well the state update after an async useEffect in tests
89
+ // to remove when the migration towards @testing-library/react is done
90
+
91
+ /* istanbul ignore next */
92
+ if (animationItem && includes(animationControl, keys(omit('loading', ANIMATION_CONTROL))) && !autoplay) {
93
+ setIsAnimationVisible(true);
94
+ animationItem[animationControl]();
95
+ if (animationControl === ANIMATION_CONTROL.stop) setIsAnimationVisible(false);
96
+ }
97
+ }, [animationControl, animationItem, autoplay]);
75
98
  useEffect(() => {
76
99
  const loadAnimation = async () => {
77
100
  if (!_isIE11 && !animationItem) {
78
- /* istanbul ignore next */
101
+ /* istanbul ignore else */
79
102
  if (typeof window !== 'undefined') {
80
103
  window.lottie = lottie;
81
104
  }
82
105
 
83
- const animation = await fetchAndLoadAnimation(animationSrc, containerRef, loop, lottieAnimationClassName, hideOnTransparent, lottie, unfetch);
106
+ const animation = await fetchAndLoadAnimation(lottie, unfetch, animationSrc, containerRef, loop, lottieAnimationClassName, hideOnTransparent, autoplay);
84
107
  /* istanbul ignore next */
85
108
 
86
109
  setAnimationItem(animation);
@@ -91,18 +114,21 @@ const LottieWrapper = props => {
91
114
  return () => animationItem &&
92
115
  /* istanbul ignore next */
93
116
  lottie.destroy(animationItem.name);
94
- }, [lottieAnimationClassName, containerRef, hideOnTransparent, loop, animationSrc, _isIE11, animationItem]);
117
+ }, [lottieAnimationClassName, containerRef, hideOnTransparent, loop, animationSrc, _isIE11, animationItem, autoplay]);
95
118
  return /*#__PURE__*/React.createElement("div", {
96
119
  ref: containerRef,
97
120
  "aria-label": ariaLabel,
98
121
  "data-name": dataName,
99
122
  className: wrapperClassName,
100
- style: _extends(_extends({}, width && {
123
+ style: _extends(_extends(_extends({}, width && {
101
124
  width: `${width}px`,
102
125
  maxWidth: `${width}px`
103
126
  }), height && {
104
127
  height: `${height}px`,
105
128
  maxHeight: `${height}px`
129
+ }), {}, {
130
+ opacity: isAnimationVisible ? 1 : 0,
131
+ transition: 'opacity 0.25s ease-in'
106
132
  })
107
133
  }, _isIE11 ? /*#__PURE__*/React.createElement("img", {
108
134
  src: ie11ImageBackup,
@@ -124,7 +150,9 @@ LottieWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
124
150
  width: PropTypes.number,
125
151
  className: PropTypes.string,
126
152
  ie11ImageBackup: PropTypes.string.isRequired,
127
- backupImageClassName: PropTypes.string
153
+ backupImageClassName: PropTypes.string,
154
+ autoplay: PropTypes.bool,
155
+ animationControl: PropTypes.oneOf(keys(ANIMATION_CONTROL))
128
156
  } : {};
129
157
  export default LottieWrapper;
130
158
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/atom/lottie-wrapper/index.js"],"names":["React","useMemo","useRef","useEffect","useState","PropTypes","classnames","lottie","get","has","includes","unfetch","style","isIE11","window","userAgent","hasMsCrypto","hasRevision","hasTrident","fetchAndLoadAnimation","animationSrc","containerRef","loop","animationClassnames","hideOnTransparent","_lottie","_fetch","animationUrl","URL","toString","fetchResult","headers","animationData","json","animation","loadAnimation","container","current","renderer","autoplay","rendererSettings","className","preserveAspectRatio","LottieWrapper","props","dataName","ariaLabel","width","height","ie11ImageBackup","backupImageClassName","animationClassName","animationItem","setAnimationItem","_isIE11","wrapperClassName","lottieContainer","lottieAnimationClassName","ie11BackupImageClassName","backupImage","destroy","name","maxWidth","maxHeight","propTypes","string","isRequired","bool","shape","number"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,OAAf,EAAwBC,MAAxB,EAAgCC,SAAhC,EAA2CC,QAA3C,QAA0D,OAA1D;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,MAAP,MAAmB,YAAnB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,QAAP,MAAqB,oBAArB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,MAAM,GAAG,MAAM;AACnB,MAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACnC,QAAMC,SAAS,GAAGP,GAAG,CAAC,qBAAD,EAAwBM,MAAxB,CAArB;AACA,QAAME,WAAW,GAAGP,GAAG,CAAC,UAAD,EAAaK,MAAb,CAAvB;AACA,QAAMG,WAAW,GAAGP,QAAQ,CAAC,KAAD,EAAQK,SAAR,CAA5B;AACA,QAAMG,UAAU,GAAGR,QAAQ,CAAC,UAAD,EAAaK,SAAb,CAA3B;AA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EpC,SAAS,CAAC4D,MAXG;AAYxBhB,EAAAA,eAAe,EAAE5C,SAAS,CAAC4D,MAAV,CAAiBC,UAZV;AAaxBhB,EAAAA,oBAAoB,EAAE7C,SAAS,CAAC4D;AAbR,CAA1B;AAgBA,eAAetB,aAAf","sourcesContent":["import React, {useMemo, useRef, useEffect, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport lottie from 'lottie-web';\nimport get from 'lodash/fp/get';\nimport has from 'lodash/fp/has';\nimport includes from 'lodash/fp/includes';\nimport unfetch from 'isomorphic-unfetch';\nimport style from './style.css';\n\nconst isIE11 = () => {\n if (typeof window === 'undefined') return;\n const userAgent = get('navigator.userAgent', window);\n const hasMsCrypto = has('msCrypto', window);\n const hasRevision = includes('rv:', userAgent);\n const hasTrident = includes('Trident/', userAgent);\n\n return hasMsCrypto || (hasRevision && hasTrident);\n};\n\nexport const fetchAndLoadAnimation = async (\n animationSrc,\n containerRef,\n loop,\n animationClassnames,\n hideOnTransparent,\n _lottie,\n _fetch\n) => {\n const animationUrl = new URL(animationSrc).toString();\n const fetchResult = await _fetch(animationUrl, {\n headers: {\n 'X-Requested-With': 'XMLHttpRequest',\n 'Content-Type': 'application/json'\n }\n });\n\n const animationData = await fetchResult.json();\n\n const animation = _lottie.loadAnimation({\n container: containerRef.current, // the dom element that will contain the animation\n renderer: 'svg',\n autoplay: true,\n loop,\n animationData,\n rendererSettings: {\n className: animationClassnames,\n hideOnTransparent,\n preserveAspectRatio: 'xMidYMid meet' // same options as a preserveAspectRatio prop\n }\n });\n return animation;\n};\n\nconst LottieWrapper = props => {\n const {\n className,\n 'data-name': dataName,\n 'aria-label': ariaLabel,\n animationSrc,\n loop = false,\n rendererSettings = {},\n width,\n height,\n ie11ImageBackup,\n backupImageClassName\n } = props;\n\n const {className: animationClassName, hideOnTransparent = true} = rendererSettings;\n\n const containerRef = useRef(null);\n\n const [animationItem, setAnimationItem] = useState(null);\n\n const _isIE11 = useMemo(() => isIE11(), []);\n\n const wrapperClassName = useMemo(() => classnames(className, style.lottieContainer), [className]);\n\n const lottieAnimationClassName = useMemo(() => classnames(animationClassName, style.animation), [\n animationClassName\n ]);\n\n const ie11BackupImageClassName = useMemo(\n () => classnames(backupImageClassName, style.backupImage),\n [backupImageClassName]\n );\n\n useEffect(() => {\n const loadAnimation = async () => {\n if (!_isIE11 && !animationItem) {\n /* istanbul ignore next */\n if (typeof window !== 'undefined') {\n window.lottie = lottie;\n }\n const animation = await fetchAndLoadAnimation(\n animationSrc,\n containerRef,\n loop,\n lottieAnimationClassName,\n hideOnTransparent,\n lottie,\n unfetch\n );\n\n /* istanbul ignore next */\n setAnimationItem(animation);\n }\n };\n\n loadAnimation();\n return () => animationItem && /* istanbul ignore next */ lottie.destroy(animationItem.name);\n }, [\n lottieAnimationClassName,\n containerRef,\n hideOnTransparent,\n loop,\n animationSrc,\n _isIE11,\n animationItem\n ]);\n\n return (\n <div\n ref={containerRef}\n aria-label={ariaLabel}\n data-name={dataName}\n className={wrapperClassName}\n style={{\n ...(width && {\n width: `${width}px`,\n maxWidth: `${width}px`\n }),\n ...(height && {\n height: `${height}px`,\n maxHeight: `${height}px`\n })\n }}\n >\n {_isIE11 ? (\n <img\n src={ie11ImageBackup}\n className={ie11BackupImageClassName}\n data-name=\"ie11-backup-image\"\n />\n ) : null}\n </div>\n );\n};\n\nLottieWrapper.propTypes = {\n 'aria-label': PropTypes.string.isRequired,\n 'data-name': PropTypes.string,\n animationSrc: PropTypes.string.isRequired,\n loop: PropTypes.bool,\n rendererSettings: PropTypes.shape({\n hideOnTransparent: PropTypes.bool,\n className: PropTypes.string\n }),\n height: PropTypes.number,\n width: PropTypes.number,\n className: PropTypes.string,\n ie11ImageBackup: PropTypes.string.isRequired,\n backupImageClassName: PropTypes.string\n};\n\nexport default LottieWrapper;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/atom/lottie-wrapper/index.js"],"names":["React","useMemo","useRef","useEffect","useState","PropTypes","classnames","lottie","get","has","includes","keys","omit","unfetch","style","ANIMATION_CONTROL","play","pause","stop","loading","isIE11","window","userAgent","hasMsCrypto","hasRevision","hasTrident","fetchAndLoadAnimation","_lottie","_fetch","animationSrc","containerRef","loop","animationClassnames","hideOnTransparent","autoplay","animationUrl","URL","toString","fetchResult","headers","animationData","json","animation","loadAnimation","container","current","renderer","rendererSettings","className","preserveAspectRatio","LottieWrapper","props","dataName","ariaLabel","width","height","ie11ImageBackup","backupImageClassName","animationControl","animationClassName","animationItem","setAnimationItem","isAnimationVisible","setIsAnimationVisible","_isIE11","wrapperClassName","lottieContainer","lottieAnimationClassName","ie11BackupImageClassName","backupImage","destroy","name","maxWidth","maxHeight","opacity","transition","propTypes","string","isRequired","bool","shape","number","oneOf"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,OAAf,EAAwBC,MAAxB,EAAgCC,SAAhC,EAA2CC,QAA3C,QAA0D,OAA1D;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,MAAP,MAAmB,YAAnB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,QAAP,MAAqB,oBAArB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,KAAP,MAAkB,aAAlB;AAEA,OAAO,MAAMC,iBAAiB,GAAG;AAC/BC,EAAAA,IAAI,EAAE,MADyB;AAE/BC,EAAAA,KAAK,EAAE,OAFwB;AAG/BC,EAAAA,IAAI,EAAE,MAHyB;AAI/BC,EAAAA,OAAO,EAAE;AAJsB,CAA1B;;AAOP,MAAMC,MAAM,GAAG,MAAM;AACnB,MAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACnC,QAAMC,SAAS,GAAGd,GAAG,CAAC,qBAAD,EAAwBa,MAAxB,CAArB;AACA,QAAME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cesContent":["import React, {useMemo, useRef, useEffect, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport lottie from 'lottie-web';\nimport get from 'lodash/fp/get';\nimport has from 'lodash/fp/has';\nimport includes from 'lodash/fp/includes';\nimport keys from 'lodash/fp/keys';\nimport omit from 'lodash/fp/omit';\nimport unfetch from 'isomorphic-unfetch';\nimport style from './style.css';\n\nexport const ANIMATION_CONTROL = {\n play: 'play',\n pause: 'pause',\n stop: 'stop',\n loading: 'loading'\n};\n\nconst isIE11 = () => {\n if (typeof window === 'undefined') return;\n const userAgent = get('navigator.userAgent', window);\n const hasMsCrypto = has('msCrypto', window);\n const hasRevision = includes('rv:', userAgent);\n const hasTrident = includes('Trident/', userAgent);\n\n return hasMsCrypto || (hasRevision && hasTrident);\n};\n\nexport const fetchAndLoadAnimation = async (\n _lottie,\n _fetch,\n animationSrc,\n containerRef,\n loop,\n animationClassnames,\n hideOnTransparent,\n autoplay\n) => {\n const animationUrl = new URL(animationSrc).toString();\n const fetchResult = await _fetch(animationUrl, {\n headers: {\n 'X-Requested-With': 'XMLHttpRequest',\n 'Content-Type': 'application/json'\n }\n });\n\n const animationData = await fetchResult.json();\n\n const animation = _lottie.loadAnimation({\n container: containerRef.current, // the dom element that will contain the animation\n renderer: 'svg',\n autoplay,\n loop,\n animationData,\n rendererSettings: {\n className: animationClassnames,\n hideOnTransparent,\n preserveAspectRatio: 'xMidYMid meet' // same options as a preserveAspectRatio prop\n }\n });\n return animation;\n};\n\nconst LottieWrapper = props => {\n const {\n className,\n 'data-name': dataName,\n 'aria-label': ariaLabel,\n animationSrc,\n loop = false,\n rendererSettings = {},\n width,\n height,\n ie11ImageBackup,\n backupImageClassName,\n autoplay = true,\n animationControl\n } = props;\n\n const {className: animationClassName, hideOnTransparent = true} = rendererSettings;\n\n const containerRef = useRef(null);\n\n // lottie's animation instance\n const [animationItem, setAnimationItem] = useState(null);\n\n const [isAnimationVisible, setIsAnimationVisible] = useState(autoplay);\n\n const _isIE11 = useMemo(() => isIE11(), []);\n\n const wrapperClassName = useMemo(() => classnames(className, style.lottieContainer), [className]);\n\n const lottieAnimationClassName = useMemo(() => classnames(animationClassName, style.animation), [\n animationClassName\n ]);\n\n const ie11BackupImageClassName = useMemo(\n () => classnames(backupImageClassName, style.backupImage),\n [backupImageClassName]\n );\n\n useEffect(() => {\n // enzyme does not handle well the state update after an async useEffect in tests\n // to remove when the migration towards @testing-library/react is done\n /* istanbul ignore next */\n if (\n animationItem &&\n includes(animationControl, keys(omit('loading', ANIMATION_CONTROL))) &&\n !autoplay\n ) {\n setIsAnimationVisible(true);\n animationItem[animationControl]();\n if (animationControl === ANIMATION_CONTROL.stop) setIsAnimationVisible(false);\n }\n }, [animationControl, animationItem, autoplay]);\n\n useEffect(() => {\n const loadAnimation = async () => {\n if (!_isIE11 && !animationItem) {\n /* istanbul ignore else */\n if (typeof window !== 'undefined') {\n window.lottie = lottie;\n }\n const animation = await fetchAndLoadAnimation(\n lottie,\n unfetch,\n animationSrc,\n containerRef,\n loop,\n lottieAnimationClassName,\n hideOnTransparent,\n autoplay\n );\n\n /* istanbul ignore next */\n setAnimationItem(animation);\n }\n };\n\n loadAnimation();\n return () => animationItem && /* istanbul ignore next */ lottie.destroy(animationItem.name);\n }, [\n lottieAnimationClassName,\n containerRef,\n hideOnTransparent,\n loop,\n animationSrc,\n _isIE11,\n animationItem,\n autoplay\n ]);\n\n return (\n <div\n ref={containerRef}\n aria-label={ariaLabel}\n data-name={dataName}\n className={wrapperClassName}\n style={{\n ...(width && {\n width: `${width}px`,\n maxWidth: `${width}px`\n }),\n ...(height && {\n height: `${height}px`,\n maxHeight: `${height}px`\n }),\n opacity: isAnimationVisible ? 1 : 0,\n transition: 'opacity 0.25s ease-in'\n }}\n >\n {_isIE11 ? (\n <img\n src={ie11ImageBackup}\n className={ie11BackupImageClassName}\n data-name=\"ie11-backup-image\"\n />\n ) : null}\n </div>\n );\n};\n\nLottieWrapper.propTypes = {\n 'aria-label': PropTypes.string.isRequired,\n 'data-name': PropTypes.string,\n animationSrc: PropTypes.string.isRequired,\n loop: PropTypes.bool,\n rendererSettings: PropTypes.shape({\n hideOnTransparent: PropTypes.bool,\n className: PropTypes.string\n }),\n height: PropTypes.number,\n width: PropTypes.number,\n className: PropTypes.string,\n ie11ImageBackup: PropTypes.string.isRequired,\n backupImageClassName: PropTypes.string,\n autoplay: PropTypes.bool,\n animationControl: PropTypes.oneOf(keys(ANIMATION_CONTROL))\n};\n\nexport default LottieWrapper;\n"],"file":"index.js"}
@@ -5,13 +5,15 @@ export default {
5
5
  className: undefined,
6
6
  animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',
7
7
  loop: undefined,
8
+ autoplay: true,
8
9
  rendererSettings: {
9
10
  hideOnTransparent: false,
10
11
  animationClassName: ''
11
12
  },
12
13
  height: 600,
13
14
  width: 1000,
14
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg'
15
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg',
16
+ animationControl: undefined
15
17
  }
16
18
  };
17
19
  //# sourceMappingURL=confetti.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/confetti.js"],"names":["props","className","undefined","animationSrc","loop","rendererSettings","hideOnTransparent","animationClassName","height","width","ie11ImageBackup"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,yEAJT;AAKLC,IAAAA,IAAI,EAAEF,SALD;AAMLG,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,iBAAiB,EAAE,KADH;AAEhBC,MAAAA,kBAAkB,EAAE;AAFJ,KANb;AAULC,IAAAA,MAAM,EAAE,GAVH;AAWLC,IAAAA,KAAK,EAAE,IAXF;AAYLC,IAAAA,eAAe,EACb;AAbG;AADM,CAAf","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',\n loop: undefined,\n rendererSettings: {\n hideOnTransparent: false,\n animationClassName: ''\n },\n height: 600,\n width: 1000,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg'\n }\n};\n"],"file":"confetti.js"}
1
+ {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/confetti.js"],"names":["props","className","undefined","animationSrc","loop","autoplay","rendererSettings","hideOnTransparent","animationClassName","height","width","ie11ImageBackup","animationControl"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,yEAJT;AAKLC,IAAAA,IAAI,EAAEF,SALD;AAMLG,IAAAA,QAAQ,EAAE,IANL;AAOLC,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,iBAAiB,EAAE,KADH;AAEhBC,MAAAA,kBAAkB,EAAE;AAFJ,KAPb;AAWLC,IAAAA,MAAM,EAAE,GAXH;AAYLC,IAAAA,KAAK,EAAE,IAZF;AAaLC,IAAAA,eAAe,EACb,iFAdG;AAeLC,IAAAA,gBAAgB,EAAEV;AAfb;AADM,CAAf","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',\n loop: undefined,\n autoplay: true,\n rendererSettings: {\n hideOnTransparent: false,\n animationClassName: ''\n },\n height: 600,\n width: 1000,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg',\n animationControl: undefined\n }\n};\n"],"file":"confetti.js"}
@@ -0,0 +1,10 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import defaultProps from './default';
4
+ export default {
5
+ props: _extends(_extends({}, defaultProps.props), {}, {
6
+ autoplay: false,
7
+ animationControl: 'loading'
8
+ })
9
+ };
10
+ //# sourceMappingURL=controls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/controls.js"],"names":["defaultProps","props","autoplay","animationControl"],"mappings":";;AAAA,OAAOA,YAAP,MAAyB,WAAzB;AAEA,eAAe;AACbC,EAAAA,KAAK,wBACAD,YAAY,CAACC,KADb;AAEHC,IAAAA,QAAQ,EAAE,KAFP;AAGHC,IAAAA,gBAAgB,EAAE;AAHf;AADQ,CAAf","sourcesContent":["import defaultProps from './default';\n\nexport default {\n props: {\n ...defaultProps.props,\n autoplay: false,\n animationControl: 'loading'\n }\n};\n"],"file":"controls.js"}
@@ -5,13 +5,15 @@ export default {
5
5
  className: undefined,
6
6
  animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',
7
7
  loop: false,
8
+ autoplay: undefined,
8
9
  rendererSettings: {
9
10
  hideOnTransparent: false,
10
11
  animationClassName: ''
11
12
  },
12
13
  height: 200,
13
14
  width: 200,
14
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg'
15
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg',
16
+ animationControl: undefined
15
17
  }
16
18
  };
17
19
  //# sourceMappingURL=default.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/default.js"],"names":["props","className","undefined","animationSrc","loop","rendererSettings","hideOnTransparent","animationClassName","height","width","ie11ImageBackup"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,qEAJT;AAKLC,IAAAA,IAAI,EAAE,KALD;AAMLC,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,iBAAiB,EAAE,KADH;AAEhBC,MAAAA,kBAAkB,EAAE;AAFJ,KANb;AAULC,IAAAA,MAAM,EAAE,GAVH;AAWLC,IAAAA,KAAK,EAAE,GAXF;AAYLC,IAAAA,eAAe,EACb;AAbG;AADM,CAAf","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',\n loop: false,\n rendererSettings: {\n hideOnTransparent: false,\n animationClassName: ''\n },\n height: 200,\n width: 200,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg'\n }\n};\n"],"file":"default.js"}
1
+ {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/default.js"],"names":["props","className","undefined","animationSrc","loop","autoplay","rendererSettings","hideOnTransparent","animationClassName","height","width","ie11ImageBackup","animationControl"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,qEAJT;AAKLC,IAAAA,IAAI,EAAE,KALD;AAMLC,IAAAA,QAAQ,EAAEH,SANL;AAOLI,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,iBAAiB,EAAE,KADH;AAEhBC,MAAAA,kBAAkB,EAAE;AAFJ,KAPb;AAWLC,IAAAA,MAAM,EAAE,GAXH;AAYLC,IAAAA,KAAK,EAAE,GAZF;AAaLC,IAAAA,eAAe,EACb,mFAdG;AAeLC,IAAAA,gBAAgB,EAAEV;AAfb;AADM,CAAf","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',\n loop: false,\n autoplay: undefined,\n rendererSettings: {\n hideOnTransparent: false,\n animationClassName: ''\n },\n height: 200,\n width: 200,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg',\n animationControl: undefined\n }\n};\n"],"file":"default.js"}
@@ -5,9 +5,11 @@ export default {
5
5
  className: undefined,
6
6
  animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
7
7
  loop: true,
8
+ autoplay: true,
8
9
  height: 200,
9
10
  width: 200,
10
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'
11
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
12
+ animationControl: undefined
11
13
  }
12
14
  };
13
15
  //# sourceMappingURL=rank.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/rank.js"],"names":["props","className","undefined","animationSrc","loop","height","width","ie11ImageBackup"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,qEAJT;AAKLC,IAAAA,IAAI,EAAE,IALD;AAMLC,IAAAA,MAAM,EAAE,GANH;AAOLC,IAAAA,KAAK,EAAE,GAPF;AAQLC,IAAAA,eAAe,EACb;AATG;AADM,CAAf","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',\n loop: true,\n height: 200,\n width: 200,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'\n }\n};\n"],"file":"rank.js"}
1
+ {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/rank.js"],"names":["props","className","undefined","animationSrc","loop","autoplay","height","width","ie11ImageBackup","animationControl"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,qEAJT;AAKLC,IAAAA,IAAI,EAAE,IALD;AAMLC,IAAAA,QAAQ,EAAE,IANL;AAOLC,IAAAA,MAAM,EAAE,GAPH;AAQLC,IAAAA,KAAK,EAAE,GARF;AASLC,IAAAA,eAAe,EACb,kFAVG;AAWLC,IAAAA,gBAAgB,EAAEP;AAXb;AADM,CAAf","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',\n loop: true,\n autoplay: true,\n height: 200,\n width: 200,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',\n animationControl: undefined\n }\n};\n"],"file":"rank.js"}
@@ -3,6 +3,7 @@ import forEach from 'lodash/forEach';
3
3
  import renderComponentMacro from '../../../test/helpers/render-component';
4
4
  import AtomLottieWrapper from '..';
5
5
  import fixtureConfetti from './fixtures/confetti';
6
+ import fixtureControls from './fixtures/controls';
6
7
  import fixtureDefault from './fixtures/default';
7
8
  import fixtureRank from './fixtures/rank';
8
9
  test('Atom › AtomLottieWrapper > should have valid propTypes', t => {
@@ -12,6 +13,7 @@ test('Atom › AtomLottieWrapper > should have valid propTypes', t => {
12
13
  });
13
14
  });
14
15
  test('Atom › AtomLottieWrapper › Confetti › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureConfetti);
16
+ test('Atom › AtomLottieWrapper › Controls › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureControls);
15
17
  test('Atom › AtomLottieWrapper › Default › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureDefault);
16
18
  test('Atom › AtomLottieWrapper › Rank › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureRank);
17
19
  //# sourceMappingURL=fixtures.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/atom/lottie-wrapper/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","AtomLottieWrapper","fixtureConfetti","fixtureDefault","fixtureRank","t","pass","propTypes","value","key","not","undefined"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,KAAjB;AACA,OAAOC,OAAP,MAAoB,gBAApB;AACA,OAAOC,oBAAP,MAAiC,wCAAjC;AACA,OAAOC,iBAAP,MAA8B,IAA9B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AAEAN,IAAI,CAAC,wDAAD,EAA2DO,CAAC,IAAI;AAClEA,EAAAA,CAAC,CAACC,IAAF;AACAP,EAAAA,OAAO,CAACE,iBAAiB,CAACM,SAAnB,EAA8B,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACnDJ,IAAAA,CAAC,CAACK,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,kDAAiDF,GAAI,mEAA9E;AACD,GAFM,CAAP;AAGD,CALG,CAAJ;AAOAX,IAAI,CAAC,0DAAD,EAA6DE,oBAA7D,EAAmFC,iBAAnF,EAAsGC,eAAtG,CAAJ;AACAJ,IAAI,CAAC,yDAAD,EAA4DE,oBAA5D,EAAkFC,iBAAlF,EAAqGE,cAArG,CAAJ;AACAL,IAAI,CAAC,sDAAD,EAAyDE,oBAAzD,EAA+EC,iBAA/E,EAAkGG,WAAlG,CAAJ","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport AtomLottieWrapper from '..';\nimport fixtureConfetti from './fixtures/confetti';\nimport fixtureDefault from './fixtures/default';\nimport fixtureRank from './fixtures/rank';\n\ntest('Atom › AtomLottieWrapper > should have valid propTypes', t => {\n t.pass();\n forEach(AtomLottieWrapper.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Atom.AtomLottieWrapper.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Atom › AtomLottieWrapper › Confetti › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureConfetti);\ntest('Atom › AtomLottieWrapper › Default › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureDefault);\ntest('Atom › AtomLottieWrapper › Rank › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureRank);\n"],"file":"fixtures.js"}
1
+ {"version":3,"sources":["../../../../src/atom/lottie-wrapper/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","AtomLottieWrapper","fixtureConfetti","fixtureControls","fixtureDefault","fixtureRank","t","pass","propTypes","value","key","not","undefined"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,KAAjB;AACA,OAAOC,OAAP,MAAoB,gBAApB;AACA,OAAOC,oBAAP,MAAiC,wCAAjC;AACA,OAAOC,iBAAP,MAA8B,IAA9B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AAEAP,IAAI,CAAC,wDAAD,EAA2DQ,CAAC,IAAI;AAClEA,EAAAA,CAAC,CAACC,IAAF;AACAR,EAAAA,OAAO,CAACE,iBAAiB,CAACO,SAAnB,EAA8B,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACnDJ,IAAAA,CAAC,CAACK,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,kDAAiDF,GAAI,mEAA9E;AACD,GAFM,CAAP;AAGD,CALG,CAAJ;AAOAZ,IAAI,CAAC,0DAAD,EAA6DE,oBAA7D,EAAmFC,iBAAnF,EAAsGC,eAAtG,CAAJ;AACAJ,IAAI,CAAC,0DAAD,EAA6DE,oBAA7D,EAAmFC,iBAAnF,EAAsGE,eAAtG,CAAJ;AACAL,IAAI,CAAC,yDAAD,EAA4DE,oBAA5D,EAAkFC,iBAAlF,EAAqGG,cAArG,CAAJ;AACAN,IAAI,CAAC,sDAAD,EAAyDE,oBAAzD,EAA+EC,iBAA/E,EAAkGI,WAAlG,CAAJ","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport AtomLottieWrapper from '..';\nimport fixtureConfetti from './fixtures/confetti';\nimport fixtureControls from './fixtures/controls';\nimport fixtureDefault from './fixtures/default';\nimport fixtureRank from './fixtures/rank';\n\ntest('Atom › AtomLottieWrapper > should have valid propTypes', t => {\n t.pass();\n forEach(AtomLottieWrapper.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Atom.AtomLottieWrapper.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Atom › AtomLottieWrapper › Confetti › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureConfetti);\ntest('Atom › AtomLottieWrapper › Controls › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureControls);\ntest('Atom › AtomLottieWrapper › Default › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureDefault);\ntest('Atom › AtomLottieWrapper › Rank › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureRank);\n"],"file":"fixtures.js"}
@@ -1,20 +1,44 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
1
3
  import browserEnv from 'browser-env';
2
4
  import test from 'ava';
3
5
  import React from 'react';
4
- import { mount, configure } from 'enzyme';
5
- import Adapter from 'enzyme-adapter-react-16';
6
+ import { render, cleanup } from '@testing-library/react';
6
7
  import LottieWrapper, { fetchAndLoadAnimation } from '..';
7
8
  import starFixture from './fixtures/default';
9
+ import controlsFixture from './fixtures/controls';
8
10
  browserEnv();
9
- configure({
10
- adapter: new Adapter()
11
- });
11
+ test.afterEach(cleanup);
12
12
  test('should update && load the animation, should clean up after unmount', t => {
13
- const wrapper = mount( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
14
- wrapper.update();
15
- const backupImage = wrapper.find('[data-name="ie11-backup-image"]');
16
- t.false(backupImage.at(0).exists());
17
- wrapper.unmount();
13
+ const {
14
+ container,
15
+ rerender,
16
+ unmount
17
+ } = render( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
18
+ rerender( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
19
+ const wrapper = container.querySelectorAll('[data-name="default-lottie"]');
20
+ t.truthy(wrapper);
21
+ const backupImage = wrapper[0].querySelector('[data-name="ie11-backup-image"]');
22
+ t.falsy(backupImage);
23
+ unmount();
24
+ t.pass();
25
+ });
26
+ test('lottie controls: should update && load the animation, should clean up after unmount', t => {
27
+ const props = _extends(_extends({}, controlsFixture.props), {}, {
28
+ animationControl: 'play'
29
+ });
30
+
31
+ const {
32
+ container,
33
+ rerender,
34
+ unmount
35
+ } = render( /*#__PURE__*/React.createElement(LottieWrapper, props));
36
+ rerender( /*#__PURE__*/React.createElement(LottieWrapper, props));
37
+ const wrapper = container.querySelectorAll('[data-name="default-lottie"]');
38
+ t.truthy(wrapper);
39
+ const backupImage = wrapper[0].querySelector('[data-name="ie11-backup-image"]');
40
+ t.falsy(backupImage);
41
+ unmount();
18
42
  t.pass();
19
43
  });
20
44
  test('ie11: should load an image in place of the animation', t => {
@@ -25,17 +49,23 @@ test('ie11: should load an image in place of the animation', t => {
25
49
  return 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
26
50
  });
27
51
 
28
- const wrapper = mount( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
29
- wrapper.update();
30
- const backupImage = wrapper.find('[data-name="ie11-backup-image"]');
31
- t.true(backupImage.at(0).exists());
32
- wrapper.unmount();
52
+ const {
53
+ container,
54
+ rerender,
55
+ unmount
56
+ } = render( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
57
+ rerender( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
58
+ const wrapper = container.querySelectorAll('[data-name="default-lottie"]');
59
+ t.truthy(wrapper);
60
+ const backupImage = wrapper[0].querySelector('[data-name="ie11-backup-image"]');
61
+ t.truthy(backupImage);
33
62
  delete window.msCrypto; // eslint-disable-next-line lodash-fp/prefer-constant
34
63
 
35
64
  window.navigator.__defineGetter__('userAgent', function () {
36
65
  return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';
37
66
  });
38
67
 
68
+ unmount();
39
69
  t.pass();
40
70
  });
41
71
  test('other browser: should not load an image in place of the animation', t => {
@@ -44,15 +74,22 @@ test('other browser: should not load an image in place of the animation', t => {
44
74
  return 'Mozilla/5.0 (other stuff; rv:77.0) like Gecko';
45
75
  });
46
76
 
47
- const wrapper = mount( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
48
- const backupImage = wrapper.find('[data-name="ie11-backup-image"]');
49
- t.false(backupImage.at(0).exists());
50
- wrapper.unmount(); // eslint-disable-next-line lodash-fp/prefer-constant
77
+ const {
78
+ container,
79
+ rerender,
80
+ unmount
81
+ } = render( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
82
+ rerender( /*#__PURE__*/React.createElement(LottieWrapper, starFixture.props));
83
+ const wrapper = container.querySelectorAll('[data-name="default-lottie"]');
84
+ t.truthy(wrapper);
85
+ const backupImage = wrapper[0].querySelector('[data-name="ie11-backup-image"]');
86
+ t.falsy(backupImage); // eslint-disable-next-line lodash-fp/prefer-constant
51
87
 
52
88
  window.navigator.__defineGetter__('userAgent', function () {
53
89
  return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';
54
90
  });
55
91
 
92
+ unmount();
56
93
  t.pass();
57
94
  });
58
95
  test('fetchAndLoadAnimation', async t => {
@@ -76,7 +113,7 @@ test('fetchAndLoadAnimation', async t => {
76
113
  };
77
114
  };
78
115
 
79
- const animation = await fetchAndLoadAnimation(props.animationSrc, '123456', true, 'test', true, _lottie, _fetch);
116
+ const animation = await fetchAndLoadAnimation(_lottie, _fetch, props.animationSrc, '123456', true, 'test', true);
80
117
  t.is(animation.name, 'animation');
81
118
  });
82
119
  //# sourceMappingURL=lottie.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/atom/lottie-wrapper/test/lottie.js"],"names":["browserEnv","test","React","mount","configure","Adapter","LottieWrapper","fetchAndLoadAnimation","starFixture","adapter","t","wrapper","props","update","backupImage","find","false","at","exists","unmount","pass","window","msCrypto","navigator","__defineGetter__","true","plan","_lottie","loadAnimation","name","_fetch","json","animationData","animation","animationSrc","is"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,aAAvB;AACA,OAAOC,IAAP,MAAiB,KAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAAQC,KAAR,EAAeC,SAAf,QAA+B,QAA/B;AACA,OAAOC,OAAP,MAAoB,yBAApB;AACA,OAAOC,aAAP,IAAuBC,qBAAvB,QAAmD,IAAnD;AACA,OAAOC,WAAP,MAAwB,oBAAxB;AAEAR,UAAU;AACVI,SAAS,CAAC;AAACK,EAAAA,OAAO,EAAE,IAAIJ,OAAJ;AAAV,CAAD,CAAT;AAEAJ,IAAI,CAAC,oEAAD,EAAuES,CAAC,IAAI;AAC9E,QAAMC,OAAO,GAAGR,KAAK,eAAC,oBAAC,aAAD,EAAmBK,WAAW,CAACI,KAA/B,CAAD,CAArB;AAEAD,EAAAA,OAAO,CAACE,MAAR;AAEA,QAAMC,WAAW,GAAGH,OAAO,CAACI,IAAR,CAAa,iCAAb,CAApB;AACAL,EAAAA,CAAC,CAACM,KAAF,CAAQF,WAAW,CAACG,EAAZ,CAAe,CAAf,EAAkBC,MAAlB,EAAR;AAEAP,EAAAA,OAAO,C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AA,OAAO,CAACQ,OAAR,GAX6E,CAa7E;;AACAE,EAAAA,MAAM,CAACE,SAAP,CAAiBC,gBAAjB,CAAkC,WAAlC,EAA+C,YAAY;AACzD,WAAO,0EAAP;AACD,GAFD;;AAIAd,EAAAA,CAAC,CAACU,IAAF;AACD,CAnBG,CAAJ;AAqBAnB,IAAI,CAAC,uBAAD,EAA0B,MAAMS,CAAN,IAAW;AACvCA,EAAAA,CAAC,CAACgB,IAAF,CAAO,CAAP;AACA,QAAMd,KAAK,GAAGJ,WAAW,CAACI,KAA1B;AACA,QAAMe,OAAO,GAAG;AACdC,IAAAA,aAAa,EAAE,MAAM;AACnBlB,MAAAA,CAAC,CAACU,IAAF;AACA,aAAO;AAACS,QAAAA,IAAI,EAAE;AAAP,OAAP;AACD;AAJa,GAAhB;;AAMA,QAAMC,MAAM,GAAG,MAAM;AACnBpB,IAAAA,CAAC,CAACU,IAAF;AACA,WAAO;AACLW,MAAAA,IAAI,EAAE,OAAO;AACXC,QAAAA,aAAa,EAAE;AADJ,OAAP;AADD,KAAP;AAKD,GAPD;;AAQA,QAAMC,SAAS,GAAG,MAAM1B,qBAAqB,CAC3CK,KAAK,CAACsB,YADqC,EAE3C,QAF2C,EAG3C,IAH2C,EAI3C,MAJ2C,EAK3C,IAL2C,EAM3CP,OAN2C,EAO3CG,MAP2C,CAA7C;AAUApB,EAAAA,CAAC,CAACyB,EAAF,CAAKF,SAAS,CAACJ,IAAf,EAAqB,WAArB;AACD,CA5BG,CAAJ","sourcesContent":["import browserEnv from 'browser-env';\nimport test from 'ava';\nimport React from 'react';\nimport {mount, configure} from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\nimport LottieWrapper, {fetchAndLoadAnimation} from '..';\nimport starFixture from './fixtures/default';\n\nbrowserEnv();\nconfigure({adapter: new Adapter()});\n\ntest('should update && load the animation, should clean up after unmount', t => {\n const wrapper = mount(<LottieWrapper {...starFixture.props} />);\n\n wrapper.update();\n\n const backupImage = wrapper.find('[data-name=\"ie11-backup-image\"]');\n t.false(backupImage.at(0).exists());\n\n wrapper.unmount();\n\n t.pass();\n});\n\ntest('ie11: should load an image in place of the animation', t => {\n window.msCrypto = () => {};\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';\n });\n\n const wrapper = mount(<LottieWrapper {...starFixture.props} />);\n\n wrapper.update();\n\n const backupImage = wrapper.find('[data-name=\"ie11-backup-image\"]');\n t.true(backupImage.at(0).exists());\n\n wrapper.unmount();\n\n delete window.msCrypto;\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';\n });\n\n t.pass();\n});\n\ntest('other browser: should not load an image in place of the animation', t => {\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (other stuff; rv:77.0) like Gecko';\n });\n\n const wrapper = mount(<LottieWrapper {...starFixture.props} />);\n\n const backupImage = wrapper.find('[data-name=\"ie11-backup-image\"]');\n t.false(backupImage.at(0).exists());\n\n wrapper.unmount();\n\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';\n });\n\n t.pass();\n});\n\ntest('fetchAndLoadAnimation', async t => {\n t.plan(3);\n const props = starFixture.props;\n const _lottie = {\n loadAnimation: () => {\n t.pass();\n return {name: 'animation'};\n }\n };\n const _fetch = () => {\n t.pass();\n return {\n json: () => ({\n animationData: 'some value'\n })\n };\n };\n const animation = await fetchAndLoadAnimation(\n props.animationSrc,\n '123456',\n true,\n 'test',\n true,\n _lottie,\n _fetch\n );\n\n t.is(animation.name, 'animation');\n});\n"],"file":"lottie.js"}
1
+ {"version":3,"sources":["../../../../src/atom/lottie-wrapper/test/lottie.js"],"names":["browserEnv","test","React","render","cleanup","LottieWrapper","fetchAndLoadAnimation","starFixture","controlsFixture","afterEach","t","container","rerender","unmount","props","wrapper","querySelectorAll","truthy","backupImage","querySelector","falsy","pass","animationControl","window","msCrypto","navigator","__defineGetter__","plan","_lottie","loadAnimation","name","_fetch","json","animationData","animation","animationSrc","is"],"mappings":";;AAAA,OAAOA,UAAP,MAAuB,aAAvB;AACA,OAAOC,IAAP,MAAiB,KAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAAQC,MAAR,EAAgBC,OAAhB,QAA8B,wBAA9B;AACA,OAAOC,aAAP,IAAuBC,qBAAvB,QAAmD,IAAnD;AACA,OAAOC,WAAP,MAAwB,oBAAxB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AAEAR,UAAU;AAEVC,IAAI,CAACQ,SAAL,CAAeL,OAAf;AAEAH,IAAI,CAAC,oEAAD,EAAuES,CAAC,IAAI;AAC9E,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA;AAAtB,MAAiCV,MAAM,eAAC,oBAAC,aAAD,EAAmBI,WAAW,CAACO,KAA/B,CAAD,CAA7C;AAEAF,EAAAA,QAAQ,eAAC,oBAAC,aAAD,EAAmBL,WAAW,CAACO,KAA/B,CAAD,CAAR;AAEA,QAAMC,OAAO,GAAGJ,SAAS,CAACK,gBAAV,CAA2B,8BAA3B,CAAhB;AACAN,EAAAA,CAAC,CAACO,MAAF,CAASF,OAAT;AAEA,QAAMG,WAAW,GAAGH,OAAO,CAAC,CAAD,CAAP,CAAWI,aAAX,CAAyB,iCAAzB,CAApB;AACAT,EAAAA,CAAC,CAACU,KAAF,CAAQF,WAAR;AAEAL,EAAAA,OAAO;AAEPH,EAAAA,CAAC,CAACW,IAAF;AACD,CAdG,CAAJ;AAgBApB,IAAI,CAAC,qFAAD,EAAwFS,CAAC,IAAI;AAC/F,QAAMI,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AAK,GAAGP,WAAW,CAACO,KAA1B;AACA,QAAMc,OAAO,GAAG;AACdC,IAAAA,aAAa,EAAE,MAAM;AACnBnB,MAAAA,CAAC,CAACW,IAAF;AACA,aAAO;AAACS,QAAAA,IAAI,EAAE;AAAP,OAAP;AACD;AAJa,GAAhB;;AAMA,QAAMC,MAAM,GAAG,MAAM;AACnBrB,IAAAA,CAAC,CAACW,IAAF;AACA,WAAO;AACLW,MAAAA,IAAI,EAAE,OAAO;AACXC,QAAAA,aAAa,EAAE;AADJ,OAAP;AADD,KAAP;AAKD,GAPD;;AAQA,QAAMC,SAAS,GAAG,MAAM5B,qBAAqB,CAC3CsB,OAD2C,EAE3CG,MAF2C,EAG3CjB,KAAK,CAACqB,YAHqC,EAI3C,QAJ2C,EAK3C,IAL2C,EAM3C,MAN2C,EAO3C,IAP2C,CAA7C;AAUAzB,EAAAA,CAAC,CAAC0B,EAAF,CAAKF,SAAS,CAACJ,IAAf,EAAqB,WAArB;AACD,CA5BG,CAAJ","sourcesContent":["import browserEnv from 'browser-env';\nimport test from 'ava';\nimport React from 'react';\nimport {render, cleanup} from '@testing-library/react';\nimport LottieWrapper, {fetchAndLoadAnimation} from '..';\nimport starFixture from './fixtures/default';\nimport controlsFixture from './fixtures/controls';\n\nbrowserEnv();\n\ntest.afterEach(cleanup);\n\ntest('should update && load the animation, should clean up after unmount', t => {\n const {container, rerender, unmount} = render(<LottieWrapper {...starFixture.props} />);\n\n rerender(<LottieWrapper {...starFixture.props} />);\n\n const wrapper = container.querySelectorAll('[data-name=\"default-lottie\"]');\n t.truthy(wrapper);\n\n const backupImage = wrapper[0].querySelector('[data-name=\"ie11-backup-image\"]');\n t.falsy(backupImage);\n\n unmount();\n\n t.pass();\n});\n\ntest('lottie controls: should update && load the animation, should clean up after unmount', t => {\n const props = {\n ...controlsFixture.props,\n animationControl: 'play'\n };\n\n const {container, rerender, unmount} = render(<LottieWrapper {...props} />);\n\n rerender(<LottieWrapper {...props} />);\n const wrapper = container.querySelectorAll('[data-name=\"default-lottie\"]');\n t.truthy(wrapper);\n\n const backupImage = wrapper[0].querySelector('[data-name=\"ie11-backup-image\"]');\n t.falsy(backupImage);\n unmount();\n\n t.pass();\n});\n\ntest('ie11: should load an image in place of the animation', t => {\n window.msCrypto = () => {};\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';\n });\n\n const {container, rerender, unmount} = render(<LottieWrapper {...starFixture.props} />);\n\n rerender(<LottieWrapper {...starFixture.props} />);\n const wrapper = container.querySelectorAll('[data-name=\"default-lottie\"]');\n t.truthy(wrapper);\n\n const backupImage = wrapper[0].querySelector('[data-name=\"ie11-backup-image\"]');\n t.truthy(backupImage);\n\n delete window.msCrypto;\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';\n });\n unmount();\n\n t.pass();\n});\n\ntest('other browser: should not load an image in place of the animation', t => {\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (other stuff; rv:77.0) like Gecko';\n });\n\n const {container, rerender, unmount} = render(<LottieWrapper {...starFixture.props} />);\n\n rerender(<LottieWrapper {...starFixture.props} />);\n const wrapper = container.querySelectorAll('[data-name=\"default-lottie\"]');\n t.truthy(wrapper);\n\n const backupImage = wrapper[0].querySelector('[data-name=\"ie11-backup-image\"]');\n t.falsy(backupImage);\n\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';\n });\n unmount();\n\n t.pass();\n});\n\ntest('fetchAndLoadAnimation', async t => {\n t.plan(3);\n const props = starFixture.props;\n const _lottie = {\n loadAnimation: () => {\n t.pass();\n return {name: 'animation'};\n }\n };\n const _fetch = () => {\n t.pass();\n return {\n json: () => ({\n animationData: 'some value'\n })\n };\n };\n const animation = await fetchAndLoadAnimation(\n _lottie,\n _fetch,\n props.animationSrc,\n '123456',\n true,\n 'test',\n true\n );\n\n t.is(animation.name, 'animation');\n});\n"],"file":"lottie.js"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.default = exports.fetchAndLoadAnimation = void 0;
4
+ exports.default = exports.fetchAndLoadAnimation = exports.ANIMATION_CONTROL = void 0;
5
5
 
6
6
  var _react = _interopRequireWildcard(require("react"));
7
7
 
@@ -17,6 +17,10 @@ var _has = _interopRequireDefault(require("lodash/fp/has"));
17
17
 
18
18
  var _includes = _interopRequireDefault(require("lodash/fp/includes"));
19
19
 
20
+ var _keys = _interopRequireDefault(require("lodash/fp/keys"));
21
+
22
+ var _omit = _interopRequireDefault(require("lodash/fp/omit"));
23
+
20
24
  var _isomorphicUnfetch = _interopRequireDefault(require("isomorphic-unfetch"));
21
25
 
22
26
  var _style = _interopRequireDefault(require("./style.css"));
@@ -29,6 +33,14 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
29
33
 
30
34
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
31
35
 
36
+ const ANIMATION_CONTROL = {
37
+ play: 'play',
38
+ pause: 'pause',
39
+ stop: 'stop',
40
+ loading: 'loading'
41
+ };
42
+ exports.ANIMATION_CONTROL = ANIMATION_CONTROL;
43
+
32
44
  const isIE11 = () => {
33
45
  if (typeof window === 'undefined') return;
34
46
  const userAgent = (0, _get.default)('navigator.userAgent', window);
@@ -38,7 +50,7 @@ const isIE11 = () => {
38
50
  return hasMsCrypto || hasRevision && hasTrident;
39
51
  };
40
52
 
41
- const fetchAndLoadAnimation = async (animationSrc, containerRef, loop, animationClassnames, hideOnTransparent, _lottie, _fetch) => {
53
+ const fetchAndLoadAnimation = async (_lottie, _fetch, animationSrc, containerRef, loop, animationClassnames, hideOnTransparent, autoplay) => {
42
54
  const animationUrl = new URL(animationSrc).toString();
43
55
  const fetchResult = await _fetch(animationUrl, {
44
56
  headers: {
@@ -52,7 +64,7 @@ const fetchAndLoadAnimation = async (animationSrc, containerRef, loop, animation
52
64
  container: containerRef.current,
53
65
  // the dom element that will contain the animation
54
66
  renderer: 'svg',
55
- autoplay: true,
67
+ autoplay,
56
68
  loop,
57
69
  animationData,
58
70
  rendererSettings: {
@@ -79,29 +91,44 @@ const LottieWrapper = props => {
79
91
  width,
80
92
  height,
81
93
  ie11ImageBackup,
82
- backupImageClassName
94
+ backupImageClassName,
95
+ autoplay = true,
96
+ animationControl
83
97
  } = props;
84
98
  const {
85
99
  className: animationClassName,
86
100
  hideOnTransparent = true
87
101
  } = rendererSettings;
88
- const containerRef = (0, _react.useRef)(null);
102
+ const containerRef = (0, _react.useRef)(null); // lottie's animation instance
103
+
89
104
  const [animationItem, setAnimationItem] = (0, _react.useState)(null);
105
+ const [isAnimationVisible, setIsAnimationVisible] = (0, _react.useState)(autoplay);
90
106
 
91
107
  const _isIE11 = (0, _react.useMemo)(() => isIE11(), []);
92
108
 
93
109
  const wrapperClassName = (0, _react.useMemo)(() => (0, _classnames.default)(className, _style.default.lottieContainer), [className]);
94
110
  const lottieAnimationClassName = (0, _react.useMemo)(() => (0, _classnames.default)(animationClassName, _style.default.animation), [animationClassName]);
95
111
  const ie11BackupImageClassName = (0, _react.useMemo)(() => (0, _classnames.default)(backupImageClassName, _style.default.backupImage), [backupImageClassName]);
112
+ (0, _react.useEffect)(() => {
113
+ // enzyme does not handle well the state update after an async useEffect in tests
114
+ // to remove when the migration towards @testing-library/react is done
115
+
116
+ /* istanbul ignore next */
117
+ if (animationItem && (0, _includes.default)(animationControl, (0, _keys.default)((0, _omit.default)('loading', ANIMATION_CONTROL))) && !autoplay) {
118
+ setIsAnimationVisible(true);
119
+ animationItem[animationControl]();
120
+ if (animationControl === ANIMATION_CONTROL.stop) setIsAnimationVisible(false);
121
+ }
122
+ }, [animationControl, animationItem, autoplay]);
96
123
  (0, _react.useEffect)(() => {
97
124
  const loadAnimation = async () => {
98
125
  if (!_isIE11 && !animationItem) {
99
- /* istanbul ignore next */
126
+ /* istanbul ignore else */
100
127
  if (typeof window !== 'undefined') {
101
128
  window.lottie = _lottieWeb.default;
102
129
  }
103
130
 
104
- const animation = await fetchAndLoadAnimation(animationSrc, containerRef, loop, lottieAnimationClassName, hideOnTransparent, _lottieWeb.default, _isomorphicUnfetch.default);
131
+ const animation = await fetchAndLoadAnimation(_lottieWeb.default, _isomorphicUnfetch.default, animationSrc, containerRef, loop, lottieAnimationClassName, hideOnTransparent, autoplay);
105
132
  /* istanbul ignore next */
106
133
 
107
134
  setAnimationItem(animation);
@@ -112,18 +139,21 @@ const LottieWrapper = props => {
112
139
  return () => animationItem &&
113
140
  /* istanbul ignore next */
114
141
  _lottieWeb.default.destroy(animationItem.name);
115
- }, [lottieAnimationClassName, containerRef, hideOnTransparent, loop, animationSrc, _isIE11, animationItem]);
142
+ }, [lottieAnimationClassName, containerRef, hideOnTransparent, loop, animationSrc, _isIE11, animationItem, autoplay]);
116
143
  return /*#__PURE__*/_react.default.createElement("div", {
117
144
  ref: containerRef,
118
145
  "aria-label": ariaLabel,
119
146
  "data-name": dataName,
120
147
  className: wrapperClassName,
121
- style: _extends(_extends({}, width && {
148
+ style: _extends(_extends(_extends({}, width && {
122
149
  width: `${width}px`,
123
150
  maxWidth: `${width}px`
124
151
  }), height && {
125
152
  height: `${height}px`,
126
153
  maxHeight: `${height}px`
154
+ }), {}, {
155
+ opacity: isAnimationVisible ? 1 : 0,
156
+ transition: 'opacity 0.25s ease-in'
127
157
  })
128
158
  }, _isIE11 ? /*#__PURE__*/_react.default.createElement("img", {
129
159
  src: ie11ImageBackup,
@@ -145,7 +175,9 @@ LottieWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
145
175
  width: _propTypes.default.number,
146
176
  className: _propTypes.default.string,
147
177
  ie11ImageBackup: _propTypes.default.string.isRequired,
148
- backupImageClassName: _propTypes.default.string
178
+ backupImageClassName: _propTypes.default.string,
179
+ autoplay: _propTypes.default.bool,
180
+ animationControl: _propTypes.default.oneOf((0, _keys.default)(ANIMATION_CONTROL))
149
181
  } : {};
150
182
  var _default = LottieWrapper;
151
183
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/atom/lottie-wrapper/index.js"],"names":["isIE11","window","userAgent","hasMsCrypto","hasRevision","hasTrident","fetchAndLoadAnimation","animationSrc","containerRef","loop","animationClassnames","hideOnTransparent","_lottie","_fetch","animationUrl","URL","toString","fetchResult","headers","animationData","json","animation","loadAnimation","container","current","renderer","autoplay","rendererSettings","className","preserveAspectRatio","LottieWrapper","props","dataName","ariaLabel","width","height","ie11ImageBackup","backupImageClassName","animationClassName","animationItem","setAnimationItem","_isIE11","wrapperClassName","style","lottieContainer","lottieAnimationClassName","ie11BackupImageClassName","backupImage","lottie","unfetch","destroy","name","maxWidth","maxHeight","propTypes","PropTypes","string","isRequired","bool","shape","number"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,MAAM,GAAG,MAAM;AACnB,MAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACnC,QAAMC,SAAS,GAAG,kBAAI,qBAAJ,EAA2BD,MAA3B,CAAlB;AACA,QAAME,WAAW,GAAG,kBAAI,UAAJ,EAAgBF,MAAhB,CAApB;AACA,QAAMG,WAAW,GAAG,uBAAS,KAAT,EAAgBF,SAAhB,CAApB;AACA,QAAMG,UAAU,GAAG,uBAAS,UAAT,EAAqBH,SAArB,CAAnB;AAEA,SAAOC,WAAW,IAAKC,WAAW,IAAIC,UAAtC;AACD,CARD;;AAUO,MA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;AAkCA,sBACE;AACE,IAAA,GAAG,EAAE/B,YADP;AAEE,kBAAYyB,SAFd;AAGE,iBAAWD,QAHb;AAIE,IAAA,SAAS,EAAEU,gBAJb;AAKE,IAAA,KAAK,wBACCR,KAAK,IAAI;AACXA,MAAAA,KAAK,EAAG,GAAEA,KAAM,IADL;AAEXkB,MAAAA,QAAQ,EAAG,GAAElB,KAAM;AAFR,KADV,GAKCC,MAAM,IAAI;AACZA,MAAAA,MAAM,EAAG,GAAEA,MAAO,IADN;AAEZkB,MAAAA,SAAS,EAAG,GAAElB,MAAO;AAFT,KALX;AALP,KAgBGM,OAAO,gBACN;AACE,IAAA,GAAG,EAAEL,eADP;AAEE,IAAA,SAAS,EAAEU,wBAFb;AAGE,iBAAU;AAHZ,IADM,GAMJ,IAtBN,CADF;AA0BD,CA7FD;;AA+FAhB,aAAa,CAACwB,SAAd,2CAA0B;AACxB,gBAAcC,mBAAUC,MAAV,CAAiBC,UADP;AAExB,eAAaF,mBAAUC,MAFC;AAGxBjD,EAAAA,YAAY,EAAEgD,mBAAUC,MAAV,CAAiBC,UAHP;AAIxBhD,EAAAA,IAAI,EAAE8C,mBAAUG,IAJQ;AAKxB/B,EAAAA,gBAAgB,EAAE4B,mBAAUI,KAAV,CAAgB;AAChChD,IAAAA,iBAAiB,EAAE4C,mBAAUG,IADG;AAEhC9B,IAAAA,SAAS,EAAE2B,mBAAUC;AAFW,GAAhB,CALM;AASxBrB,EAAAA,MAAM,EAAEoB,mBAAUK,MATM;AAUxB1B,EAAAA,KAAK,EAAEqB,mBAAUK,MAVO;AAWxBhC,EAAAA,SAAS,EAAE2B,mBAAUC,MAXG;AAYxBpB,EAAAA,eAAe,EAAEmB,mBAAUC,MAAV,CAAiBC,UAZV;AAaxBpB,EAAAA,oBAAoB,EAAEkB,mBAAUC;AAbR,CAA1B;eAgBe1B,a","sourcesContent":["import React, {useMemo, useRef, useEffect, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport lottie from 'lottie-web';\nimport get from 'lodash/fp/get';\nimport has from 'lodash/fp/has';\nimport includes from 'lodash/fp/includes';\nimport unfetch from 'isomorphic-unfetch';\nimport style from './style.css';\n\nconst isIE11 = () => {\n if (typeof window === 'undefined') return;\n const userAgent = get('navigator.userAgent', window);\n const hasMsCrypto = has('msCrypto', window);\n const hasRevision = includes('rv:', userAgent);\n const hasTrident = includes('Trident/', userAgent);\n\n return hasMsCrypto || (hasRevision && hasTrident);\n};\n\nexport const fetchAndLoadAnimation = async (\n animationSrc,\n containerRef,\n loop,\n animationClassnames,\n hideOnTransparent,\n _lottie,\n _fetch\n) => {\n const animationUrl = new URL(animationSrc).toString();\n const fetchResult = await _fetch(animationUrl, {\n headers: {\n 'X-Requested-With': 'XMLHttpRequest',\n 'Content-Type': 'application/json'\n }\n });\n\n const animationData = await fetchResult.json();\n\n const animation = _lottie.loadAnimation({\n container: containerRef.current, // the dom element that will contain the animation\n renderer: 'svg',\n autoplay: true,\n loop,\n animationData,\n rendererSettings: {\n className: animationClassnames,\n hideOnTransparent,\n preserveAspectRatio: 'xMidYMid meet' // same options as a preserveAspectRatio prop\n }\n });\n return animation;\n};\n\nconst LottieWrapper = props => {\n const {\n className,\n 'data-name': dataName,\n 'aria-label': ariaLabel,\n animationSrc,\n loop = false,\n rendererSettings = {},\n width,\n height,\n ie11ImageBackup,\n backupImageClassName\n } = props;\n\n const {className: animationClassName, hideOnTransparent = true} = rendererSettings;\n\n const containerRef = useRef(null);\n\n const [animationItem, setAnimationItem] = useState(null);\n\n const _isIE11 = useMemo(() => isIE11(), []);\n\n const wrapperClassName = useMemo(() => classnames(className, style.lottieContainer), [className]);\n\n const lottieAnimationClassName = useMemo(() => classnames(animationClassName, style.animation), [\n animationClassName\n ]);\n\n const ie11BackupImageClassName = useMemo(\n () => classnames(backupImageClassName, style.backupImage),\n [backupImageClassName]\n );\n\n useEffect(() => {\n const loadAnimation = async () => {\n if (!_isIE11 && !animationItem) {\n /* istanbul ignore next */\n if (typeof window !== 'undefined') {\n window.lottie = lottie;\n }\n const animation = await fetchAndLoadAnimation(\n animationSrc,\n containerRef,\n loop,\n lottieAnimationClassName,\n hideOnTransparent,\n lottie,\n unfetch\n );\n\n /* istanbul ignore next */\n setAnimationItem(animation);\n }\n };\n\n loadAnimation();\n return () => animationItem && /* istanbul ignore next */ lottie.destroy(animationItem.name);\n }, [\n lottieAnimationClassName,\n containerRef,\n hideOnTransparent,\n loop,\n animationSrc,\n _isIE11,\n animationItem\n ]);\n\n return (\n <div\n ref={containerRef}\n aria-label={ariaLabel}\n data-name={dataName}\n className={wrapperClassName}\n style={{\n ...(width && {\n width: `${width}px`,\n maxWidth: `${width}px`\n }),\n ...(height && {\n height: `${height}px`,\n maxHeight: `${height}px`\n })\n }}\n >\n {_isIE11 ? (\n <img\n src={ie11ImageBackup}\n className={ie11BackupImageClassName}\n data-name=\"ie11-backup-image\"\n />\n ) : null}\n </div>\n );\n};\n\nLottieWrapper.propTypes = {\n 'aria-label': PropTypes.string.isRequired,\n 'data-name': PropTypes.string,\n animationSrc: PropTypes.string.isRequired,\n loop: PropTypes.bool,\n rendererSettings: PropTypes.shape({\n hideOnTransparent: PropTypes.bool,\n className: PropTypes.string\n }),\n height: PropTypes.number,\n width: PropTypes.number,\n className: PropTypes.string,\n ie11ImageBackup: PropTypes.string.isRequired,\n backupImageClassName: PropTypes.string\n};\n\nexport default LottieWrapper;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/atom/lottie-wrapper/index.js"],"names":["ANIMATION_CONTROL","play","pause","stop","loading","isIE11","window","userAgent","hasMsCrypto","hasRevision","hasTrident","fetchAndLoadAnimation","_lottie","_fetch","animationSrc","containerRef","loop","animationClassnames","hideOnTransparent","autoplay","animationUrl","URL","toString","fetchResult","headers","animationData","json","animation","loadAnimation","container","current","renderer","rendererSettings","className","preserveAspectRatio","LottieWrapper","props","dataName","ariaLabel","width","height","ie11ImageBackup","backupImageClassName","animationControl","animationClassName","animationItem","setAnimationItem","isAnimationVisible","setIsAnimationVisible","_isIE11","wrapperClassName","style","lottieContainer","lottieAnimationClassName","ie11BackupImageClassName","backupImage","lottie","unfetch","destroy","name","maxWidth","maxHeight","opacity","transition","propTypes","PropTypes","string","isRequired","bool","shape","number","oneOf"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEO,MAAMA,iBAAiB,GAAG;AAC/BC,EAAAA,IAAI,EAAE,MADyB;AAE/BC,EAAAA,KAAK,EAAE,OAFwB;AAG/BC,EAAAA,IAAI,EAAE,MAHyB;AAI/BC,EAAAA,OAAO,EAAE;AAJsB,CAA1B;;;AAOP,MAAMC,MAAM,GAAG,MAAM;AACnB,MAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACnC,QAAMC,SAAS,GAAG,kBAAI,qBAAJ,EAA2BD,MAA3B,CAAlB;AACA,QAAME,WAAW,GAAG,kBAAI,UAAJ,EAAgBF,MAAhB,CAApB;AACA,QAAMG,WAAW,GAAG,uBAAS,KAAT,EAAgBF,SAAhB,CAApB;AACA,QAAMG,UAAU,GAAG,uBAAS,UAAT,EAAqBH,SAArB,CAAnB;AAEA,SAAOC,WAAW,IAAKC,WAAW,IAAIC,UAAtC;AACD,CARD;;AAUO,MAAMC,qBAAqB,GAAG,OACnCC,OADmC,EAEnCC,MAFmC,EAGnCC,YAHmC,EAInCC,YAJmC,EAKnCC,IALmC,EAMnCC,mBANmC,EAOnCC,iBAPmC,EAQnCC,QARmC,KAShC;AACH,QAAMC,YAAY,GAAG,IAAIC,GAAJ,CAAQP,YAAR,EAAsBQ,QAAtB,EAArB;AACA,QAAMC,WAAW,GAAG,MAAMV,MAAM,CAACO,YAAD,EAAe;AAC7CI,IAAAA,OAAO,EAAE;AACP,0BAAoB,gBADb;AAEP,sBAAgB;AAFT;AADoC,GAAf,CAAhC;AAOA,QAAMC,aAAa,GAAG,MAAMF,WAAW,CAACG,IAAZ,EA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VO;AAWxBrC,EAAAA,SAAS,EAAEgC,mBAAUC,MAXG;AAYxBzB,EAAAA,eAAe,EAAEwB,mBAAUC,MAAV,CAAiBC,UAZV;AAaxBzB,EAAAA,oBAAoB,EAAEuB,mBAAUC,MAbR;AAcxB/C,EAAAA,QAAQ,EAAE8C,mBAAUG,IAdI;AAexBzB,EAAAA,gBAAgB,EAAEsB,mBAAUM,KAAV,CAAgB,mBAAKvE,iBAAL,CAAhB;AAfM,CAA1B;eAkBemC,a","sourcesContent":["import React, {useMemo, useRef, useEffect, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport lottie from 'lottie-web';\nimport get from 'lodash/fp/get';\nimport has from 'lodash/fp/has';\nimport includes from 'lodash/fp/includes';\nimport keys from 'lodash/fp/keys';\nimport omit from 'lodash/fp/omit';\nimport unfetch from 'isomorphic-unfetch';\nimport style from './style.css';\n\nexport const ANIMATION_CONTROL = {\n play: 'play',\n pause: 'pause',\n stop: 'stop',\n loading: 'loading'\n};\n\nconst isIE11 = () => {\n if (typeof window === 'undefined') return;\n const userAgent = get('navigator.userAgent', window);\n const hasMsCrypto = has('msCrypto', window);\n const hasRevision = includes('rv:', userAgent);\n const hasTrident = includes('Trident/', userAgent);\n\n return hasMsCrypto || (hasRevision && hasTrident);\n};\n\nexport const fetchAndLoadAnimation = async (\n _lottie,\n _fetch,\n animationSrc,\n containerRef,\n loop,\n animationClassnames,\n hideOnTransparent,\n autoplay\n) => {\n const animationUrl = new URL(animationSrc).toString();\n const fetchResult = await _fetch(animationUrl, {\n headers: {\n 'X-Requested-With': 'XMLHttpRequest',\n 'Content-Type': 'application/json'\n }\n });\n\n const animationData = await fetchResult.json();\n\n const animation = _lottie.loadAnimation({\n container: containerRef.current, // the dom element that will contain the animation\n renderer: 'svg',\n autoplay,\n loop,\n animationData,\n rendererSettings: {\n className: animationClassnames,\n hideOnTransparent,\n preserveAspectRatio: 'xMidYMid meet' // same options as a preserveAspectRatio prop\n }\n });\n return animation;\n};\n\nconst LottieWrapper = props => {\n const {\n className,\n 'data-name': dataName,\n 'aria-label': ariaLabel,\n animationSrc,\n loop = false,\n rendererSettings = {},\n width,\n height,\n ie11ImageBackup,\n backupImageClassName,\n autoplay = true,\n animationControl\n } = props;\n\n const {className: animationClassName, hideOnTransparent = true} = rendererSettings;\n\n const containerRef = useRef(null);\n\n // lottie's animation instance\n const [animationItem, setAnimationItem] = useState(null);\n\n const [isAnimationVisible, setIsAnimationVisible] = useState(autoplay);\n\n const _isIE11 = useMemo(() => isIE11(), []);\n\n const wrapperClassName = useMemo(() => classnames(className, style.lottieContainer), [className]);\n\n const lottieAnimationClassName = useMemo(() => classnames(animationClassName, style.animation), [\n animationClassName\n ]);\n\n const ie11BackupImageClassName = useMemo(\n () => classnames(backupImageClassName, style.backupImage),\n [backupImageClassName]\n );\n\n useEffect(() => {\n // enzyme does not handle well the state update after an async useEffect in tests\n // to remove when the migration towards @testing-library/react is done\n /* istanbul ignore next */\n if (\n animationItem &&\n includes(animationControl, keys(omit('loading', ANIMATION_CONTROL))) &&\n !autoplay\n ) {\n setIsAnimationVisible(true);\n animationItem[animationControl]();\n if (animationControl === ANIMATION_CONTROL.stop) setIsAnimationVisible(false);\n }\n }, [animationControl, animationItem, autoplay]);\n\n useEffect(() => {\n const loadAnimation = async () => {\n if (!_isIE11 && !animationItem) {\n /* istanbul ignore else */\n if (typeof window !== 'undefined') {\n window.lottie = lottie;\n }\n const animation = await fetchAndLoadAnimation(\n lottie,\n unfetch,\n animationSrc,\n containerRef,\n loop,\n lottieAnimationClassName,\n hideOnTransparent,\n autoplay\n );\n\n /* istanbul ignore next */\n setAnimationItem(animation);\n }\n };\n\n loadAnimation();\n return () => animationItem && /* istanbul ignore next */ lottie.destroy(animationItem.name);\n }, [\n lottieAnimationClassName,\n containerRef,\n hideOnTransparent,\n loop,\n animationSrc,\n _isIE11,\n animationItem,\n autoplay\n ]);\n\n return (\n <div\n ref={containerRef}\n aria-label={ariaLabel}\n data-name={dataName}\n className={wrapperClassName}\n style={{\n ...(width && {\n width: `${width}px`,\n maxWidth: `${width}px`\n }),\n ...(height && {\n height: `${height}px`,\n maxHeight: `${height}px`\n }),\n opacity: isAnimationVisible ? 1 : 0,\n transition: 'opacity 0.25s ease-in'\n }}\n >\n {_isIE11 ? (\n <img\n src={ie11ImageBackup}\n className={ie11BackupImageClassName}\n data-name=\"ie11-backup-image\"\n />\n ) : null}\n </div>\n );\n};\n\nLottieWrapper.propTypes = {\n 'aria-label': PropTypes.string.isRequired,\n 'data-name': PropTypes.string,\n animationSrc: PropTypes.string.isRequired,\n loop: PropTypes.bool,\n rendererSettings: PropTypes.shape({\n hideOnTransparent: PropTypes.bool,\n className: PropTypes.string\n }),\n height: PropTypes.number,\n width: PropTypes.number,\n className: PropTypes.string,\n ie11ImageBackup: PropTypes.string.isRequired,\n backupImageClassName: PropTypes.string,\n autoplay: PropTypes.bool,\n animationControl: PropTypes.oneOf(keys(ANIMATION_CONTROL))\n};\n\nexport default LottieWrapper;\n"],"file":"index.js"}
@@ -9,13 +9,15 @@ var _default = {
9
9
  className: undefined,
10
10
  animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',
11
11
  loop: undefined,
12
+ autoplay: true,
12
13
  rendererSettings: {
13
14
  hideOnTransparent: false,
14
15
  animationClassName: ''
15
16
  },
16
17
  height: 600,
17
18
  width: 1000,
18
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg'
19
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg',
20
+ animationControl: undefined
19
21
  }
20
22
  };
21
23
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/confetti.js"],"names":["props","className","undefined","animationSrc","loop","rendererSettings","hideOnTransparent","animationClassName","height","width","ie11ImageBackup"],"mappings":";;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,yEAJT;AAKLC,IAAAA,IAAI,EAAEF,SALD;AAMLG,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,iBAAiB,EAAE,KADH;AAEhBC,MAAAA,kBAAkB,EAAE;AAFJ,KANb;AAULC,IAAAA,MAAM,EAAE,GAVH;AAWLC,IAAAA,KAAK,EAAE,IAXF;AAYLC,IAAAA,eAAe,EACb;AAbG;AADM,C","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',\n loop: undefined,\n rendererSettings: {\n hideOnTransparent: false,\n animationClassName: ''\n },\n height: 600,\n width: 1000,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg'\n }\n};\n"],"file":"confetti.js"}
1
+ {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/confetti.js"],"names":["props","className","undefined","animationSrc","loop","autoplay","rendererSettings","hideOnTransparent","animationClassName","height","width","ie11ImageBackup","animationControl"],"mappings":";;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,yEAJT;AAKLC,IAAAA,IAAI,EAAEF,SALD;AAMLG,IAAAA,QAAQ,EAAE,IANL;AAOLC,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,iBAAiB,EAAE,KADH;AAEhBC,MAAAA,kBAAkB,EAAE;AAFJ,KAPb;AAWLC,IAAAA,MAAM,EAAE,GAXH;AAYLC,IAAAA,KAAK,EAAE,IAZF;AAaLC,IAAAA,eAAe,EACb,iFAdG;AAeLC,IAAAA,gBAAgB,EAAEV;AAfb;AADM,C","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',\n loop: undefined,\n autoplay: true,\n rendererSettings: {\n hideOnTransparent: false,\n animationClassName: ''\n },\n height: 600,\n width: 1000,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg',\n animationControl: undefined\n }\n};\n"],"file":"confetti.js"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+
6
+ var _default2 = _interopRequireDefault(require("./default"));
7
+
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+
10
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
+
12
+ var _default = {
13
+ props: _extends(_extends({}, _default2.default.props), {}, {
14
+ autoplay: false,
15
+ animationControl: 'loading'
16
+ })
17
+ };
18
+ exports.default = _default;
19
+ //# sourceMappingURL=controls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/controls.js"],"names":["props","defaultProps","autoplay","animationControl"],"mappings":";;;;;AAAA;;;;;;eAEe;AACbA,EAAAA,KAAK,wBACAC,kBAAaD,KADb;AAEHE,IAAAA,QAAQ,EAAE,KAFP;AAGHC,IAAAA,gBAAgB,EAAE;AAHf;AADQ,C","sourcesContent":["import defaultProps from './default';\n\nexport default {\n props: {\n ...defaultProps.props,\n autoplay: false,\n animationControl: 'loading'\n }\n};\n"],"file":"controls.js"}
@@ -9,13 +9,15 @@ var _default = {
9
9
  className: undefined,
10
10
  animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',
11
11
  loop: false,
12
+ autoplay: undefined,
12
13
  rendererSettings: {
13
14
  hideOnTransparent: false,
14
15
  animationClassName: ''
15
16
  },
16
17
  height: 200,
17
18
  width: 200,
18
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg'
19
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg',
20
+ animationControl: undefined
19
21
  }
20
22
  };
21
23
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/default.js"],"names":["props","className","undefined","animationSrc","loop","rendererSettings","hideOnTransparent","animationClassName","height","width","ie11ImageBackup"],"mappings":";;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,qEAJT;AAKLC,IAAAA,IAAI,EAAE,KALD;AAMLC,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,iBAAiB,EAAE,KADH;AAEhBC,MAAAA,kBAAkB,EAAE;AAFJ,KANb;AAULC,IAAAA,MAAM,EAAE,GAVH;AAWLC,IAAAA,KAAK,EAAE,GAXF;AAYLC,IAAAA,eAAe,EACb;AAbG;AADM,C","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',\n loop: false,\n rendererSettings: {\n hideOnTransparent: false,\n animationClassName: ''\n },\n height: 200,\n width: 200,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg'\n }\n};\n"],"file":"default.js"}
1
+ {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/default.js"],"names":["props","className","undefined","animationSrc","loop","autoplay","rendererSettings","hideOnTransparent","animationClassName","height","width","ie11ImageBackup","animationControl"],"mappings":";;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,qEAJT;AAKLC,IAAAA,IAAI,EAAE,KALD;AAMLC,IAAAA,QAAQ,EAAEH,SANL;AAOLI,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,iBAAiB,EAAE,KADH;AAEhBC,MAAAA,kBAAkB,EAAE;AAFJ,KAPb;AAWLC,IAAAA,MAAM,EAAE,GAXH;AAYLC,IAAAA,KAAK,EAAE,GAZF;AAaLC,IAAAA,eAAe,EACb,mFAdG;AAeLC,IAAAA,gBAAgB,EAAEV;AAfb;AADM,C","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',\n loop: false,\n autoplay: undefined,\n rendererSettings: {\n hideOnTransparent: false,\n animationClassName: ''\n },\n height: 200,\n width: 200,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg',\n animationControl: undefined\n }\n};\n"],"file":"default.js"}
@@ -9,9 +9,11 @@ var _default = {
9
9
  className: undefined,
10
10
  animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
11
11
  loop: true,
12
+ autoplay: true,
12
13
  height: 200,
13
14
  width: 200,
14
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'
15
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
16
+ animationControl: undefined
15
17
  }
16
18
  };
17
19
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/rank.js"],"names":["props","className","undefined","animationSrc","loop","height","width","ie11ImageBackup"],"mappings":";;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,qEAJT;AAKLC,IAAAA,IAAI,EAAE,IALD;AAMLC,IAAAA,MAAM,EAAE,GANH;AAOLC,IAAAA,KAAK,EAAE,GAPF;AAQLC,IAAAA,eAAe,EACb;AATG;AADM,C","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',\n loop: true,\n height: 200,\n width: 200,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'\n }\n};\n"],"file":"rank.js"}
1
+ {"version":3,"sources":["../../../../../src/atom/lottie-wrapper/test/fixtures/rank.js"],"names":["props","className","undefined","animationSrc","loop","autoplay","height","width","ie11ImageBackup","animationControl"],"mappings":";;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACL,kBAAc,aADT;AAEL,iBAAa,gBAFR;AAGLC,IAAAA,SAAS,EAAEC,SAHN;AAILC,IAAAA,YAAY,EAAE,qEAJT;AAKLC,IAAAA,IAAI,EAAE,IALD;AAMLC,IAAAA,QAAQ,EAAE,IANL;AAOLC,IAAAA,MAAM,EAAE,GAPH;AAQLC,IAAAA,KAAK,EAAE,GARF;AASLC,IAAAA,eAAe,EACb,kFAVG;AAWLC,IAAAA,gBAAgB,EAAEP;AAXb;AADM,C","sourcesContent":["export default {\n props: {\n 'aria-label': 'aria lottie',\n 'data-name': 'default-lottie',\n className: undefined,\n animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',\n loop: true,\n autoplay: true,\n height: 200,\n width: 200,\n ie11ImageBackup:\n 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',\n animationControl: undefined\n }\n};\n"],"file":"rank.js"}
@@ -10,6 +10,8 @@ var _ = _interopRequireDefault(require(".."));
10
10
 
11
11
  var _confetti = _interopRequireDefault(require("./fixtures/confetti"));
12
12
 
13
+ var _controls = _interopRequireDefault(require("./fixtures/controls"));
14
+
13
15
  var _default = _interopRequireDefault(require("./fixtures/default"));
14
16
 
15
17
  var _rank = _interopRequireDefault(require("./fixtures/rank"));
@@ -23,6 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
25
  });
24
26
  });
25
27
  (0, _ava.default)('Atom › AtomLottieWrapper › Confetti › should be rendered', _renderComponent.default, _.default, _confetti.default);
28
+ (0, _ava.default)('Atom › AtomLottieWrapper › Controls › should be rendered', _renderComponent.default, _.default, _controls.default);
26
29
  (0, _ava.default)('Atom › AtomLottieWrapper › Default › should be rendered', _renderComponent.default, _.default, _default.default);
27
30
  (0, _ava.default)('Atom › AtomLottieWrapper › Rank › should be rendered', _renderComponent.default, _.default, _rank.default);
28
31
  //# sourceMappingURL=fixtures.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/atom/lottie-wrapper/test/fixtures.js"],"names":["t","pass","AtomLottieWrapper","propTypes","value","key","not","undefined","renderComponentMacro","fixtureConfetti","fixtureDefault","fixtureRank"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,kBAAK,wDAAL,EAA+DA,CAAC,IAAI;AAClEA,EAAAA,CAAC,CAACC,IAAF;AACA,wBAAQC,UAAkBC,SAA1B,EAAqC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACnDL,IAAAA,CAAC,CAACM,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,kDAAiDF,GAAI,mEAA9E;AACD,GAFD;AAGD,CALD;AAOA,kBAAK,0DAAL,EAAiEG,wBAAjE,EAAuFN,SAAvF,EAA0GO,iBAA1G;AACA,kBAAK,yDAAL,EAAgED,wBAAhE,EAAsFN,SAAtF,EAAyGQ,gBAAzG;AACA,kBAAK,sDAAL,EAA6DF,wBAA7D,EAAmFN,SAAnF,EAAsGS,aAAtG","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport AtomLottieWrapper from '..';\nimport fixtureConfetti from './fixtures/confetti';\nimport fixtureDefault from './fixtures/default';\nimport fixtureRank from './fixtures/rank';\n\ntest('Atom › AtomLottieWrapper > should have valid propTypes', t => {\n t.pass();\n forEach(AtomLottieWrapper.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Atom.AtomLottieWrapper.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Atom › AtomLottieWrapper › Confetti › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureConfetti);\ntest('Atom › AtomLottieWrapper › Default › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureDefault);\ntest('Atom › AtomLottieWrapper › Rank › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureRank);\n"],"file":"fixtures.js"}
1
+ {"version":3,"sources":["../../../../src/atom/lottie-wrapper/test/fixtures.js"],"names":["t","pass","AtomLottieWrapper","propTypes","value","key","not","undefined","renderComponentMacro","fixtureConfetti","fixtureControls","fixtureDefault","fixtureRank"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,kBAAK,wDAAL,EAA+DA,CAAC,IAAI;AAClEA,EAAAA,CAAC,CAACC,IAAF;AACA,wBAAQC,UAAkBC,SAA1B,EAAqC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACnDL,IAAAA,CAAC,CAACM,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,kDAAiDF,GAAI,mEAA9E;AACD,GAFD;AAGD,CALD;AAOA,kBAAK,0DAAL,EAAiEG,wBAAjE,EAAuFN,SAAvF,EAA0GO,iBAA1G;AACA,kBAAK,0DAAL,EAAiED,wBAAjE,EAAuFN,SAAvF,EAA0GQ,iBAA1G;AACA,kBAAK,yDAAL,EAAgEF,wBAAhE,EAAsFN,SAAtF,EAAyGS,gBAAzG;AACA,kBAAK,sDAAL,EAA6DH,wBAA7D,EAAmFN,SAAnF,EAAsGU,aAAtG","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport AtomLottieWrapper from '..';\nimport fixtureConfetti from './fixtures/confetti';\nimport fixtureControls from './fixtures/controls';\nimport fixtureDefault from './fixtures/default';\nimport fixtureRank from './fixtures/rank';\n\ntest('Atom › AtomLottieWrapper > should have valid propTypes', t => {\n t.pass();\n forEach(AtomLottieWrapper.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Atom.AtomLottieWrapper.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Atom › AtomLottieWrapper › Confetti › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureConfetti);\ntest('Atom › AtomLottieWrapper › Controls › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureControls);\ntest('Atom › AtomLottieWrapper › Default › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureDefault);\ntest('Atom › AtomLottieWrapper › Rank › should be rendered', renderComponentMacro, AtomLottieWrapper, fixtureRank);\n"],"file":"fixtures.js"}
@@ -6,30 +6,56 @@ var _ava = _interopRequireDefault(require("ava"));
6
6
 
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
 
9
- var _enzyme = require("enzyme");
10
-
11
- var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));
9
+ var _react2 = require("@testing-library/react");
12
10
 
13
11
  var _ = _interopRequireWildcard(require(".."));
14
12
 
15
13
  var _default = _interopRequireDefault(require("./fixtures/default"));
16
14
 
15
+ var _controls = _interopRequireDefault(require("./fixtures/controls"));
16
+
17
17
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
18
18
 
19
19
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
20
 
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
22
 
23
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
24
+
23
25
  (0, _browserEnv.default)();
24
- (0, _enzyme.configure)({
25
- adapter: new _enzymeAdapterReact.default()
26
- });
26
+
27
+ _ava.default.afterEach(_react2.cleanup);
28
+
27
29
  (0, _ava.default)('should update && load the animation, should clean up after unmount', t => {
28
- const wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
29
- wrapper.update();
30
- const backupImage = wrapper.find('[data-name="ie11-backup-image"]');
31
- t.false(backupImage.at(0).exists());
32
- wrapper.unmount();
30
+ const {
31
+ container,
32
+ rerender,
33
+ unmount
34
+ } = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
35
+ rerender( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
36
+ const wrapper = container.querySelectorAll('[data-name="default-lottie"]');
37
+ t.truthy(wrapper);
38
+ const backupImage = wrapper[0].querySelector('[data-name="ie11-backup-image"]');
39
+ t.falsy(backupImage);
40
+ unmount();
41
+ t.pass();
42
+ });
43
+ (0, _ava.default)('lottie controls: should update && load the animation, should clean up after unmount', t => {
44
+ const props = _extends(_extends({}, _controls.default.props), {}, {
45
+ animationControl: 'play'
46
+ });
47
+
48
+ const {
49
+ container,
50
+ rerender,
51
+ unmount
52
+ } = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.default, props));
53
+ rerender( /*#__PURE__*/_react.default.createElement(_.default, props));
54
+ const wrapper = container.querySelectorAll('[data-name="default-lottie"]');
55
+ t.truthy(wrapper);
56
+ const backupImage = wrapper[0].querySelector('[data-name="ie11-backup-image"]');
57
+ t.falsy(backupImage);
58
+ unmount();
33
59
  t.pass();
34
60
  });
35
61
  (0, _ava.default)('ie11: should load an image in place of the animation', t => {
@@ -40,17 +66,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
40
66
  return 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
41
67
  });
42
68
 
43
- const wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
44
- wrapper.update();
45
- const backupImage = wrapper.find('[data-name="ie11-backup-image"]');
46
- t.true(backupImage.at(0).exists());
47
- wrapper.unmount();
69
+ const {
70
+ container,
71
+ rerender,
72
+ unmount
73
+ } = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
74
+ rerender( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
75
+ const wrapper = container.querySelectorAll('[data-name="default-lottie"]');
76
+ t.truthy(wrapper);
77
+ const backupImage = wrapper[0].querySelector('[data-name="ie11-backup-image"]');
78
+ t.truthy(backupImage);
48
79
  delete window.msCrypto; // eslint-disable-next-line lodash-fp/prefer-constant
49
80
 
50
81
  window.navigator.__defineGetter__('userAgent', function () {
51
82
  return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';
52
83
  });
53
84
 
85
+ unmount();
54
86
  t.pass();
55
87
  });
56
88
  (0, _ava.default)('other browser: should not load an image in place of the animation', t => {
@@ -59,15 +91,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
59
91
  return 'Mozilla/5.0 (other stuff; rv:77.0) like Gecko';
60
92
  });
61
93
 
62
- const wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
63
- const backupImage = wrapper.find('[data-name="ie11-backup-image"]');
64
- t.false(backupImage.at(0).exists());
65
- wrapper.unmount(); // eslint-disable-next-line lodash-fp/prefer-constant
94
+ const {
95
+ container,
96
+ rerender,
97
+ unmount
98
+ } = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
99
+ rerender( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
100
+ const wrapper = container.querySelectorAll('[data-name="default-lottie"]');
101
+ t.truthy(wrapper);
102
+ const backupImage = wrapper[0].querySelector('[data-name="ie11-backup-image"]');
103
+ t.falsy(backupImage); // eslint-disable-next-line lodash-fp/prefer-constant
66
104
 
67
105
  window.navigator.__defineGetter__('userAgent', function () {
68
106
  return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';
69
107
  });
70
108
 
109
+ unmount();
71
110
  t.pass();
72
111
  });
73
112
  (0, _ava.default)('fetchAndLoadAnimation', async t => {
@@ -91,7 +130,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
91
130
  };
92
131
  };
93
132
 
94
- const animation = await (0, _.fetchAndLoadAnimation)(props.animationSrc, '123456', true, 'test', true, _lottie, _fetch);
133
+ const animation = await (0, _.fetchAndLoadAnimation)(_lottie, _fetch, props.animationSrc, '123456', true, 'test', true);
95
134
  t.is(animation.name, 'animation');
96
135
  });
97
136
  //# sourceMappingURL=lottie.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/atom/lottie-wrapper/test/lottie.js"],"names":["adapter","Adapter","t","wrapper","starFixture","props","update","backupImage","find","false","at","exists","unmount","pass","window","msCrypto","navigator","__defineGetter__","true","plan","_lottie","loadAnimation","name","_fetch","json","animationData","animation","animationSrc","is"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA;AACA,uBAAU;AAACA,EAAAA,OAAO,EAAE,IAAIC,2BAAJ;AAAV,CAAV;AAEA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,YAAY;AACzD,WAAO,+CAAP;AACD,GAFD;;AAIA,QAAMd,OAAO,GAAG,iCAAM,6BAAC,SAAD,EAAmBC,iBAAYC,KAA/B,CAAN,CAAhB;AAEA,QAAME,WAAW,GAAGJ,OAAO,CAACK,IAAR,CAAa,iCAAb,CAApB;AACAN,EAAAA,CAAC,CAACO,KAAF,CAAQF,WAAW,CAACG,EAAZ,CAAe,CAAf,EAAkBC,MAAlB,EAAR;AAEAR,EAAAA,OAAO,CAACS,OAAR,GAX6E,CAa7E;;AACAE,EAAAA,MAAM,CAACE,SAAP,CAAiBC,gBAAjB,CAAkC,WAAlC,EAA+C,YAAY;AACzD,WAAO,0EAAP;AACD,GAFD;;AAIAf,EAAAA,CAAC,CAACW,IAAF;AACD,CAnBD;AAqBA,kBAAK,uBAAL,EAA8B,MAAMX,CAAN,IAAW;AACvCA,EAAAA,CAAC,CAACiB,IAAF,CAAO,CAAP;AACA,QAAMd,KAAK,GAAGD,iBAAYC,KAA1B;AACA,QAAMe,OAAO,GAAG;AACdC,IAAAA,aAAa,EAAE,MAAM;AACnBnB,MAAAA,CAAC,CAACW,IAAF;AACA,aAAO;AAACS,QAAAA,IAAI,EAAE;AAAP,OAAP;AACD;AAJa,GAAhB;;AAMA,QAAMC,MAAM,GAAG,MAAM;AACnBrB,IAAAA,CAAC,CAACW,IAAF;AACA,WAAO;AACLW,MAAAA,IAAI,EAAE,OAAO;AACXC,QAAAA,aAAa,EAAE;AADJ,OAAP;AADD,KAAP;AAKD,GAPD;;AAQA,QAAMC,SAAS,GAAG,MAAM,6BACtBrB,KAAK,CAACsB,YADgB,EAEtB,QAFsB,EAGtB,IAHsB,EAItB,MAJsB,EAKtB,IALsB,EAMtBP,OANsB,EAOtBG,MAPsB,CAAxB;AAUArB,EAAAA,CAAC,CAAC0B,EAAF,CAAKF,SAAS,CAACJ,IAAf,EAAqB,WAArB;AACD,CA5BD","sourcesContent":["import browserEnv from 'browser-env';\nimport test from 'ava';\nimport React from 'react';\nimport {mount, configure} from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\nimport LottieWrapper, {fetchAndLoadAnimation} from '..';\nimport starFixture from './fixtures/default';\n\nbrowserEnv();\nconfigure({adapter: new Adapter()});\n\ntest('should update && load the animation, should clean up after unmount', t => {\n const wrapper = mount(<LottieWrapper {...starFixture.props} />);\n\n wrapper.update();\n\n const backupImage = wrapper.find('[data-name=\"ie11-backup-image\"]');\n t.false(backupImage.at(0).exists());\n\n wrapper.unmount();\n\n t.pass();\n});\n\ntest('ie11: should load an image in place of the animation', t => {\n window.msCrypto = () => {};\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';\n });\n\n const wrapper = mount(<LottieWrapper {...starFixture.props} />);\n\n wrapper.update();\n\n const backupImage = wrapper.find('[data-name=\"ie11-backup-image\"]');\n t.true(backupImage.at(0).exists());\n\n wrapper.unmount();\n\n delete window.msCrypto;\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';\n });\n\n t.pass();\n});\n\ntest('other browser: should not load an image in place of the animation', t => {\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (other stuff; rv:77.0) like Gecko';\n });\n\n const wrapper = mount(<LottieWrapper {...starFixture.props} />);\n\n const backupImage = wrapper.find('[data-name=\"ie11-backup-image\"]');\n t.false(backupImage.at(0).exists());\n\n wrapper.unmount();\n\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';\n });\n\n t.pass();\n});\n\ntest('fetchAndLoadAnimation', async t => {\n t.plan(3);\n const props = starFixture.props;\n const _lottie = {\n loadAnimation: () => {\n t.pass();\n return {name: 'animation'};\n }\n };\n const _fetch = () => {\n t.pass();\n return {\n json: () => ({\n animationData: 'some value'\n })\n };\n };\n const animation = await fetchAndLoadAnimation(\n props.animationSrc,\n '123456',\n true,\n 'test',\n true,\n _lottie,\n _fetch\n );\n\n t.is(animation.name, 'animation');\n});\n"],"file":"lottie.js"}
1
+ {"version":3,"sources":["../../../../src/atom/lottie-wrapper/test/lottie.js"],"names":["test","afterEach","cleanup","t","container","rerender","unmount","starFixture","props","wrapper","querySelectorAll","truthy","backupImage","querySelector","falsy","pass","controlsFixture","animationControl","window","msCrypto","navigator","__defineGetter__","plan","_lottie","loadAnimation","name","_fetch","json","animationData","animation","animationSrc","is"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA;;AAEAA,aAAKC,SAAL,CAAeC,eAAf;;AAEA,kBAAK,oEAAL,EAA2EC,CAAC,IAAI;AAC9E,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA;AAAtB,MAAiC,kCAAO,6BAAC,SAAD,EAAmBC,iBAAYC,KAA/B,CAAP,CAAvC;AAEAH,EAAAA,QAAQ,eAAC,6BAAC,SAAD,EAAmBE,iBAAYC,KAA/B,CAAD,CAAR;AAEA,QAAMC,OAAO,GAAGL,SAAS,CAACM,gBAAV,CAA2B,8BAA3B,CAAhB;AACAP,EAAAA,CAAC,CAACQ,MAAF,CAASF,OAAT;AAEA,QAAMG,WAAW,GAAGH,OAAO,CAAC,CAAD,CAAP,CAAWI,aAAX,CAAyB,iCAAzB,CAApB;AACAV,EAAAA,CAAC,CAACW,KAAF,CAAQF,WAAR;AAEAN,EAAAA,OAAO;AAEPH,EAAAA,CAAC,CAACY,IAAF;AACD,CAdD;AAgBA,kBAAK,qFAAL,EAA4FZ,CAAC,IAAI;AAC/F,QAAMK,KAAK,yBACNQ,kBAAgBR,KADV;AAETS,IAAAA,g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,IAAF;AACA,aAAO;AAACU,QAAAA,IAAI,EAAE;AAAP,OAAP;AACD;AAJa,GAAhB;;AAMA,QAAMC,MAAM,GAAG,MAAM;AACnBvB,IAAAA,CAAC,CAACY,IAAF;AACA,WAAO;AACLY,MAAAA,IAAI,EAAE,OAAO;AACXC,QAAAA,aAAa,EAAE;AADJ,OAAP;AADD,KAAP;AAKD,GAPD;;AAQA,QAAMC,SAAS,GAAG,MAAM,6BACtBN,OADsB,EAEtBG,MAFsB,EAGtBlB,KAAK,CAACsB,YAHgB,EAItB,QAJsB,EAKtB,IALsB,EAMtB,MANsB,EAOtB,IAPsB,CAAxB;AAUA3B,EAAAA,CAAC,CAAC4B,EAAF,CAAKF,SAAS,CAACJ,IAAf,EAAqB,WAArB;AACD,CA5BD","sourcesContent":["import browserEnv from 'browser-env';\nimport test from 'ava';\nimport React from 'react';\nimport {render, cleanup} from '@testing-library/react';\nimport LottieWrapper, {fetchAndLoadAnimation} from '..';\nimport starFixture from './fixtures/default';\nimport controlsFixture from './fixtures/controls';\n\nbrowserEnv();\n\ntest.afterEach(cleanup);\n\ntest('should update && load the animation, should clean up after unmount', t => {\n const {container, rerender, unmount} = render(<LottieWrapper {...starFixture.props} />);\n\n rerender(<LottieWrapper {...starFixture.props} />);\n\n const wrapper = container.querySelectorAll('[data-name=\"default-lottie\"]');\n t.truthy(wrapper);\n\n const backupImage = wrapper[0].querySelector('[data-name=\"ie11-backup-image\"]');\n t.falsy(backupImage);\n\n unmount();\n\n t.pass();\n});\n\ntest('lottie controls: should update && load the animation, should clean up after unmount', t => {\n const props = {\n ...controlsFixture.props,\n animationControl: 'play'\n };\n\n const {container, rerender, unmount} = render(<LottieWrapper {...props} />);\n\n rerender(<LottieWrapper {...props} />);\n const wrapper = container.querySelectorAll('[data-name=\"default-lottie\"]');\n t.truthy(wrapper);\n\n const backupImage = wrapper[0].querySelector('[data-name=\"ie11-backup-image\"]');\n t.falsy(backupImage);\n unmount();\n\n t.pass();\n});\n\ntest('ie11: should load an image in place of the animation', t => {\n window.msCrypto = () => {};\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';\n });\n\n const {container, rerender, unmount} = render(<LottieWrapper {...starFixture.props} />);\n\n rerender(<LottieWrapper {...starFixture.props} />);\n const wrapper = container.querySelectorAll('[data-name=\"default-lottie\"]');\n t.truthy(wrapper);\n\n const backupImage = wrapper[0].querySelector('[data-name=\"ie11-backup-image\"]');\n t.truthy(backupImage);\n\n delete window.msCrypto;\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';\n });\n unmount();\n\n t.pass();\n});\n\ntest('other browser: should not load an image in place of the animation', t => {\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (other stuff; rv:77.0) like Gecko';\n });\n\n const {container, rerender, unmount} = render(<LottieWrapper {...starFixture.props} />);\n\n rerender(<LottieWrapper {...starFixture.props} />);\n const wrapper = container.querySelectorAll('[data-name=\"default-lottie\"]');\n t.truthy(wrapper);\n\n const backupImage = wrapper[0].querySelector('[data-name=\"ie11-backup-image\"]');\n t.falsy(backupImage);\n\n // eslint-disable-next-line lodash-fp/prefer-constant\n window.navigator.__defineGetter__('userAgent', function () {\n return 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/13.2.0';\n });\n unmount();\n\n t.pass();\n});\n\ntest('fetchAndLoadAnimation', async t => {\n t.plan(3);\n const props = starFixture.props;\n const _lottie = {\n loadAnimation: () => {\n t.pass();\n return {name: 'animation'};\n }\n };\n const _fetch = () => {\n t.pass();\n return {\n json: () => ({\n animationData: 'some value'\n })\n };\n };\n const animation = await fetchAndLoadAnimation(\n _lottie,\n _fetch,\n props.animationSrc,\n '123456',\n true,\n 'test',\n true\n );\n\n t.is(animation.name, 'animation');\n});\n"],"file":"lottie.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/components",
3
- "version": "10.17.0",
3
+ "version": "10.17.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -94,6 +94,7 @@
94
94
  "@storybook/addon-knobs": "^5.3.18",
95
95
  "@storybook/addons": "^5.3.18",
96
96
  "@storybook/react": "^5.3.18",
97
+ "@testing-library/react": "12.1.5",
97
98
  "ava": "^3.8.2",
98
99
  "babel-loader": "^8.1.0",
99
100
  "babel-plugin-istanbul": "^6.0.0",
@@ -103,7 +104,7 @@
103
104
  "concurrently": "^5.2.0",
104
105
  "cross-env": "^7.0.2",
105
106
  "enzyme": "^3.11.0",
106
- "enzyme-adapter-react-16": "^1.15.2",
107
+ "enzyme-adapter-react-16": "^1.15.6",
107
108
  "eslint": "^7.3.1",
108
109
  "file-loader": "^6.0.0",
109
110
  "glob": "^7.1.6",
@@ -121,5 +122,5 @@
121
122
  "webpack-hot-middleware": "^2.25.0"
122
123
  },
123
124
  "author": "CoorpAcademy",
124
- "gitHead": "ddddc43b9c0b7beb2547c9411cab45e8aa76dcb7"
125
+ "gitHead": "0c41a2cae50611864e56d039d246ebf3a41ef0d1"
125
126
  }