@coorpacademy/components 10.17.0 → 10.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/es/atom/drag-and-drop/index.js +8 -5
- package/es/atom/drag-and-drop/index.js.map +1 -1
- package/es/atom/drag-and-drop/style.css +5 -0
- package/es/atom/drag-and-drop/test/fixtures/disabled-with-image-reset.js +12 -0
- package/es/atom/drag-and-drop/test/fixtures/disabled-with-image-reset.js.map +1 -0
- package/es/atom/drag-and-drop/test/fixtures/disabled.js +12 -0
- package/es/atom/drag-and-drop/test/fixtures/disabled.js.map +1 -0
- package/es/atom/drag-and-drop/test/fixtures.js +4 -0
- package/es/atom/drag-and-drop/test/fixtures.js.map +1 -1
- package/es/atom/image-upload/index.js +3 -1
- package/es/atom/image-upload/index.js.map +1 -1
- package/es/atom/image-upload/test/fixtures/disabled.js +12 -0
- package/es/atom/image-upload/test/fixtures/disabled.js.map +1 -0
- package/es/atom/image-upload/test/fixtures.js +2 -0
- package/es/atom/image-upload/test/fixtures.js.map +1 -1
- package/es/atom/lottie-wrapper/index.js +37 -9
- package/es/atom/lottie-wrapper/index.js.map +1 -1
- package/es/atom/lottie-wrapper/test/fixtures/confetti.js +3 -1
- package/es/atom/lottie-wrapper/test/fixtures/confetti.js.map +1 -1
- package/es/atom/lottie-wrapper/test/fixtures/controls.js +10 -0
- package/es/atom/lottie-wrapper/test/fixtures/controls.js.map +1 -0
- package/es/atom/lottie-wrapper/test/fixtures/default.js +3 -1
- package/es/atom/lottie-wrapper/test/fixtures/default.js.map +1 -1
- package/es/atom/lottie-wrapper/test/fixtures/rank.js +3 -1
- package/es/atom/lottie-wrapper/test/fixtures/rank.js.map +1 -1
- package/es/atom/lottie-wrapper/test/fixtures.js +2 -0
- package/es/atom/lottie-wrapper/test/fixtures.js.map +1 -1
- package/es/atom/lottie-wrapper/test/lottie.js +57 -20
- package/es/atom/lottie-wrapper/test/lottie.js.map +1 -1
- package/es/molecule/drag-and-drop-wrapper/test/fixtures/{without-checkbox.js → disabled.js} +3 -2
- package/es/molecule/drag-and-drop-wrapper/test/fixtures/disabled.js.map +1 -0
- package/es/molecule/drag-and-drop-wrapper/test/fixtures.js +2 -2
- package/es/molecule/drag-and-drop-wrapper/test/fixtures.js.map +1 -1
- package/es/organism/rewards-form/test/fixtures/default.js +3 -2
- package/es/organism/rewards-form/test/fixtures/default.js.map +1 -1
- package/lib/atom/drag-and-drop/index.js +9 -5
- package/lib/atom/drag-and-drop/index.js.map +1 -1
- package/lib/atom/drag-and-drop/style.css +5 -0
- package/lib/atom/drag-and-drop/test/fixtures/disabled-with-image-reset.js +21 -0
- package/lib/atom/drag-and-drop/test/fixtures/disabled-with-image-reset.js.map +1 -0
- package/lib/atom/drag-and-drop/test/fixtures/disabled.js +21 -0
- package/lib/atom/drag-and-drop/test/fixtures/disabled.js.map +1 -0
- package/lib/atom/drag-and-drop/test/fixtures.js +6 -0
- package/lib/atom/drag-and-drop/test/fixtures.js.map +1 -1
- package/lib/atom/image-upload/index.js +3 -1
- package/lib/atom/image-upload/index.js.map +1 -1
- package/lib/atom/image-upload/test/fixtures/disabled.js +21 -0
- package/lib/atom/image-upload/test/fixtures/disabled.js.map +1 -0
- package/lib/atom/image-upload/test/fixtures.js +3 -0
- package/lib/atom/image-upload/test/fixtures.js.map +1 -1
- package/lib/atom/lottie-wrapper/index.js +42 -10
- package/lib/atom/lottie-wrapper/index.js.map +1 -1
- package/lib/atom/lottie-wrapper/test/fixtures/confetti.js +3 -1
- package/lib/atom/lottie-wrapper/test/fixtures/confetti.js.map +1 -1
- package/lib/atom/lottie-wrapper/test/fixtures/controls.js +19 -0
- package/lib/atom/lottie-wrapper/test/fixtures/controls.js.map +1 -0
- package/lib/atom/lottie-wrapper/test/fixtures/default.js +3 -1
- package/lib/atom/lottie-wrapper/test/fixtures/default.js.map +1 -1
- package/lib/atom/lottie-wrapper/test/fixtures/rank.js +3 -1
- package/lib/atom/lottie-wrapper/test/fixtures/rank.js.map +1 -1
- package/lib/atom/lottie-wrapper/test/fixtures.js +3 -0
- package/lib/atom/lottie-wrapper/test/fixtures.js.map +1 -1
- package/lib/atom/lottie-wrapper/test/lottie.js +60 -21
- package/lib/atom/lottie-wrapper/test/lottie.js.map +1 -1
- package/lib/molecule/drag-and-drop-wrapper/test/fixtures/{without-checkbox.js → disabled.js} +3 -2
- package/lib/molecule/drag-and-drop-wrapper/test/fixtures/disabled.js.map +1 -0
- package/lib/molecule/drag-and-drop-wrapper/test/fixtures.js +3 -3
- package/lib/molecule/drag-and-drop-wrapper/test/fixtures.js.map +1 -1
- package/lib/organism/rewards-form/test/fixtures/default.js +4 -3
- package/lib/organism/rewards-form/test/fixtures/default.js.map +1 -1
- package/package.json +4 -3
- package/es/molecule/drag-and-drop-wrapper/test/fixtures/without-checkbox.js.map +0 -1
- package/lib/molecule/drag-and-drop-wrapper/test/fixtures/without-checkbox.js.map +0 -1
|
@@ -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,
|
|
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;
|
|
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 {
|
|
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
|
-
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
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","
|
|
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,KAAK,yBACNN,eAAe,CAACM,KADV;AAETQ,IAAAA,gBAAgB,EA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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"}
|
|
@@ -4,8 +4,9 @@ import firstdDragAndDrop from '../../../../atom/image-upload/test/fixtures/defau
|
|
|
4
4
|
export default {
|
|
5
5
|
props: {
|
|
6
6
|
list: [_extends(_extends({}, firstdDragAndDrop.props), {}, {
|
|
7
|
-
title: 'Add a badge'
|
|
7
|
+
title: 'Add a badge',
|
|
8
|
+
disabled: true
|
|
8
9
|
})]
|
|
9
10
|
}
|
|
10
11
|
};
|
|
11
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=disabled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/molecule/drag-and-drop-wrapper/test/fixtures/disabled.js"],"names":["firstdDragAndDrop","props","list","title","disabled"],"mappings":";;AAAA,OAAOA,iBAAP,MAA8B,qDAA9B;AAEA,eAAe;AACbC,EAAAA,KAAK,EAAE;AACLC,IAAAA,IAAI,EAAE,uBAAKF,iBAAiB,CAACC,KAAvB;AAA8BE,MAAAA,KAAK,EAAE,aAArC;AAAoDC,MAAAA,QAAQ,EAAE;AAA9D;AADD;AADM,CAAf","sourcesContent":["import firstdDragAndDrop from '../../../../atom/image-upload/test/fixtures/default';\n\nexport default {\n props: {\n list: [{...firstdDragAndDrop.props, title: 'Add a badge', disabled: true}]\n }\n};\n"],"file":"disabled.js"}
|
|
@@ -3,8 +3,8 @@ import forEach from 'lodash/forEach';
|
|
|
3
3
|
import renderComponentMacro from '../../../test/helpers/render-component';
|
|
4
4
|
import MoleculeDragAndDropWrapper from '..';
|
|
5
5
|
import fixtureDefault from './fixtures/default';
|
|
6
|
+
import fixtureDisabled from './fixtures/disabled';
|
|
6
7
|
import fixtureTwoDragAndDrops from './fixtures/two-drag-and-drops';
|
|
7
|
-
import fixtureWithoutCheckbox from './fixtures/without-checkbox';
|
|
8
8
|
test('Molecule › MoleculeDragAndDropWrapper > should have valid propTypes', t => {
|
|
9
9
|
t.pass();
|
|
10
10
|
forEach(MoleculeDragAndDropWrapper.propTypes, (value, key) => {
|
|
@@ -12,6 +12,6 @@ test('Molecule › MoleculeDragAndDropWrapper > should have valid propTypes', t
|
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
test('Molecule › MoleculeDragAndDropWrapper › Default › should be rendered', renderComponentMacro, MoleculeDragAndDropWrapper, fixtureDefault);
|
|
15
|
+
test('Molecule › MoleculeDragAndDropWrapper › Disabled › should be rendered', renderComponentMacro, MoleculeDragAndDropWrapper, fixtureDisabled);
|
|
15
16
|
test('Molecule › MoleculeDragAndDropWrapper › TwoDragAndDrops › should be rendered', renderComponentMacro, MoleculeDragAndDropWrapper, fixtureTwoDragAndDrops);
|
|
16
|
-
test('Molecule › MoleculeDragAndDropWrapper › WithoutCheckbox › should be rendered', renderComponentMacro, MoleculeDragAndDropWrapper, fixtureWithoutCheckbox);
|
|
17
17
|
//# sourceMappingURL=fixtures.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/drag-and-drop-wrapper/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","MoleculeDragAndDropWrapper","fixtureDefault","
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/drag-and-drop-wrapper/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","MoleculeDragAndDropWrapper","fixtureDefault","fixtureDisabled","fixtureTwoDragAndDrops","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,0BAAP,MAAuC,IAAvC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,sBAAP,MAAmC,+BAAnC;AAEAN,IAAI,CAAC,qEAAD,EAAwEO,CAAC,IAAI;AAC/EA,EAAAA,CAAC,CAACC,IAAF;AACAP,EAAAA,OAAO,CAACE,0BAA0B,CAACM,SAA5B,EAAuC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AAC5DJ,IAAAA,CAAC,CAACK,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,+DAA8DF,GAAI,mEAA3F;AACD,GAFM,CAAP;AAGD,CALG,CAAJ;AAOAX,IAAI,CAAC,sEAAD,EAAyEE,oBAAzE,EAA+FC,0BAA/F,EAA2HC,cAA3H,CAAJ;AACAJ,IAAI,CAAC,uEAAD,EAA0EE,oBAA1E,EAAgGC,0BAAhG,EAA4HE,eAA5H,CAAJ;AACAL,IAAI,CAAC,8EAAD,EAAiFE,oBAAjF,EAAuGC,0BAAvG,EAAmIG,sBAAnI,CAAJ","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport MoleculeDragAndDropWrapper from '..';\nimport fixtureDefault from './fixtures/default';\nimport fixtureDisabled from './fixtures/disabled';\nimport fixtureTwoDragAndDrops from './fixtures/two-drag-and-drops';\n\ntest('Molecule › MoleculeDragAndDropWrapper > should have valid propTypes', t => {\n t.pass();\n forEach(MoleculeDragAndDropWrapper.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Molecule.MoleculeDragAndDropWrapper.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Molecule › MoleculeDragAndDropWrapper › Default › should be rendered', renderComponentMacro, MoleculeDragAndDropWrapper, fixtureDefault);\ntest('Molecule › MoleculeDragAndDropWrapper › Disabled › should be rendered', renderComponentMacro, MoleculeDragAndDropWrapper, fixtureDisabled);\ntest('Molecule › MoleculeDragAndDropWrapper › TwoDragAndDrops › should be rendered', renderComponentMacro, MoleculeDragAndDropWrapper, fixtureTwoDragAndDrops);\n"],"file":"fixtures.js"}
|
|
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import inputText from '../../../../atom/input-text-with-title/test/fixtures/error';
|
|
4
4
|
import CheckboxWithTitle from '../../../../atom/checkbox-with-title/test/fixtures/checked';
|
|
5
|
-
import singleDragAndDrop from '../../../../molecule/drag-and-drop-wrapper/test/fixtures/
|
|
5
|
+
import singleDragAndDrop from '../../../../molecule/drag-and-drop-wrapper/test/fixtures/disabled';
|
|
6
6
|
import doubleDragAndDrop from '../../../../molecule/drag-and-drop-wrapper/test/fixtures/two-drag-and-drops';
|
|
7
7
|
export default {
|
|
8
8
|
props: {
|
|
@@ -25,7 +25,8 @@ export default {
|
|
|
25
25
|
childType: 'drag-and-drop-wrapper'
|
|
26
26
|
}),
|
|
27
27
|
checkboxWithTitle: {
|
|
28
|
-
title: 'Create diploma'
|
|
28
|
+
title: 'Create diploma',
|
|
29
|
+
checked: true
|
|
29
30
|
}
|
|
30
31
|
}]
|
|
31
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/organism/rewards-form/test/fixtures/default.js"],"names":["inputText","CheckboxWithTitle","singleDragAndDrop","doubleDragAndDrop","props","items","child","childType","title","undefined","checkboxWithTitle"],"mappings":";;AAAA,OAAOA,SAAP,MAAsB,4DAAtB;AACA,OAAOC,iBAAP,MAA8B,4DAA9B;AACA,OAAOC,iBAAP,MAA8B,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/organism/rewards-form/test/fixtures/default.js"],"names":["inputText","CheckboxWithTitle","singleDragAndDrop","doubleDragAndDrop","props","items","child","childType","title","undefined","checkboxWithTitle","checked"],"mappings":";;AAAA,OAAOA,SAAP,MAAsB,4DAAtB;AACA,OAAOC,iBAAP,MAA8B,4DAA9B;AACA,OAAOC,iBAAP,MAA8B,mEAA9B;AACA,OAAOC,iBAAP,MAA8B,6EAA9B;AAEA,eAAe;AACbC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAE,CACL;AACEC,MAAAA,KAAK,wBAAMN,SAAS,CAACI,KAAhB;AAAuBG,QAAAA,SAAS,EAAE,YAAlC;AAAgDC,QAAAA,KAAK,EAAEC;AAAvD,QADP;AAEEC,MAAAA,iBAAiB,EAAET,iBAAiB,CAACG;AAFvC,KADK,EAKL;AACEE,MAAAA,KAAK,wBACAJ,iBAAiB,CAACE,KADlB;AAEHG,QAAAA,SAAS,EAAE,uBAFR;AAGHC,QAAAA,KAAK,EAAE;AAHJ,QADP;AAMEE,MAAAA,iBAAiB,EAAE;AAACF,QAAAA,KAAK,EAAE;AAAR;AANrB,KALK,EAaL;AACEF,MAAAA,KAAK,wBAAMH,iBAAiB,CAACC,KAAxB;AAA+BG,QAAAA,SAAS,EAAE;AAA1C,QADP;AAEEG,MAAAA,iBAAiB,EAAE;AAACF,QAAAA,KAAK,EAAE,gBAAR;AAA0BG,QAAAA,OAAO,EAAE;AAAnC;AAFrB,KAbK;AADF;AADM,CAAf","sourcesContent":["import inputText from '../../../../atom/input-text-with-title/test/fixtures/error';\nimport CheckboxWithTitle from '../../../../atom/checkbox-with-title/test/fixtures/checked';\nimport singleDragAndDrop from '../../../../molecule/drag-and-drop-wrapper/test/fixtures/disabled';\nimport doubleDragAndDrop from '../../../../molecule/drag-and-drop-wrapper/test/fixtures/two-drag-and-drops';\n\nexport default {\n props: {\n items: [\n {\n child: {...inputText.props, childType: 'input-text', title: undefined},\n checkboxWithTitle: CheckboxWithTitle.props\n },\n {\n child: {\n ...singleDragAndDrop.props,\n childType: 'drag-and-drop-wrapper',\n title: 'Create badge'\n },\n checkboxWithTitle: {title: 'Create badge'}\n },\n {\n child: {...doubleDragAndDrop.props, childType: 'drag-and-drop-wrapper'},\n checkboxWithTitle: {title: 'Create diploma', checked: true}\n }\n ]\n }\n};\n"],"file":"default.js"}
|
|
@@ -15,6 +15,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _novaIcons = require("@coorpacademy/nova-icons");
|
|
17
17
|
|
|
18
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
|
+
|
|
18
20
|
var _loader = _interopRequireDefault(require("../loader"));
|
|
19
21
|
|
|
20
22
|
var _buttonLink = _interopRequireDefault(require("../button-link"));
|
|
@@ -65,7 +67,8 @@ class DragAndDrop extends _react.default.Component {
|
|
|
65
67
|
onReset = null,
|
|
66
68
|
error = '',
|
|
67
69
|
buttonAriaLabel = '',
|
|
68
|
-
errorButtonLabel = ''
|
|
70
|
+
errorButtonLabel = '',
|
|
71
|
+
disabled = false
|
|
69
72
|
} = this.props;
|
|
70
73
|
const {
|
|
71
74
|
dragging
|
|
@@ -109,7 +112,7 @@ class DragAndDrop extends _react.default.Component {
|
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
const resetContent = previewContent && previewContent.src ? /*#__PURE__*/_react.default.createElement("div", {
|
|
112
|
-
className: _style.default.resetUploadWrapper
|
|
115
|
+
className: (0, _classnames.default)(_style.default.resetUploadWrapper, disabled && _style.default.disabled)
|
|
113
116
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
114
117
|
className: _style.default.resetSrcLabel
|
|
115
118
|
}, previewContent.label ? previewContent.label : previewContent.src), onReset ? /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidStatusClose, {
|
|
@@ -152,9 +155,9 @@ class DragAndDrop extends _react.default.Component {
|
|
|
152
155
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
153
156
|
className: _style.default.title
|
|
154
157
|
}, title), !(0, _isEmpty2.default)(previewContent) || loading ? /*#__PURE__*/_react.default.createElement("div", {
|
|
155
|
-
className: previewContainer
|
|
158
|
+
className: (0, _classnames.default)(previewContainer, disabled && _style.default.disabled)
|
|
156
159
|
}, previewView) : /*#__PURE__*/_react.default.createElement("div", {
|
|
157
|
-
className: dragging ? _style.default.dragging : inputWrapper,
|
|
160
|
+
className: (0, _classnames.default)(dragging ? _style.default.dragging : inputWrapper, disabled && _style.default.disabled),
|
|
158
161
|
id: idBox
|
|
159
162
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
160
163
|
className: _style.default.infosContainer
|
|
@@ -167,7 +170,7 @@ class DragAndDrop extends _react.default.Component {
|
|
|
167
170
|
}, description) : null, error ? null : /*#__PURE__*/_react.default.createElement("div", {
|
|
168
171
|
className: _style.default.dragAndDropLabel
|
|
169
172
|
}, 'Drag & Drop here')), button, /*#__PURE__*/_react.default.createElement("div", null, children(this.handleDragStart, this.handleDragStop))), error ? /*#__PURE__*/_react.default.createElement("span", {
|
|
170
|
-
className: _style.default.errorMessage
|
|
173
|
+
className: (0, _classnames.default)(_style.default.errorMessage, disabled && _style.default.disabled)
|
|
171
174
|
}, error) : resetContent);
|
|
172
175
|
}
|
|
173
176
|
|
|
@@ -185,6 +188,7 @@ DragAndDrop.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
185
188
|
}),
|
|
186
189
|
loading: _propTypes.default.bool,
|
|
187
190
|
modified: _propTypes.default.bool,
|
|
191
|
+
disabled: _propTypes.default.bool,
|
|
188
192
|
children: _propTypes.default.func,
|
|
189
193
|
onReset: _propTypes.default.func,
|
|
190
194
|
error: _propTypes.default.string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/atom/drag-and-drop/index.js"],"names":["constantNull","DragAndDrop","React","Component","constructor","props","state","dragging","handleDragStart","bind","handleDragStop","setState","render","idBox","children","title","description","uploadLabel","previewLabel","previewContent","loading","modified","onReset","error","buttonAriaLabel","errorButtonLabel","previewView","type","style","preview","src","loaderWrapper","loadingCancel","closeIcon","loader","loaderText","resetContent","resetUploadWrapper","resetSrcLabel","label","buildButton","defaultButtonProps","icon","position","button","previewContainer","modifiedPreviewContainer","inputWrapper","modifiedInputWrapper","errorInputWrapper","wrapper","infosContainer","iconError","dragAndDropLabel","errorMessage","propTypes","PropTypes","string","shape","bool","func"],"mappings":";;;;;;;;;;;AAAA;;AACA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G,IAVF;AAWjBtC,EAAAA,QAAQ,EAAEmC,mBAAUG,IAXH;AAYjB7C,EAAAA,QAAQ,EAAE0C,mBAAUI,IAZH;AAajBtC,EAAAA,OAAO,EAAEkC,mBAAUI,IAbF;AAcjBrC,EAAAA,KAAK,EAAEiC,mBAAUC,MAdA;AAejBjC,EAAAA,eAAe,EAAEgC,mBAAUC,MAfV;AAgBjBhC,EAAAA,gBAAgB,EAAE+B,mBAAUC;AAhBX,C;eAgLNxD,W","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {uniqueId, constant, isEmpty} from 'lodash/fp';\nimport {\n NovaSolidStatusClose as Close,\n NovaSolidFilesBasicFileUpload2 as FileUploadIcon,\n NovaSolidFilesBasicFileBlock2 as FileUploadBlockedIcon\n} from '@coorpacademy/nova-icons';\nimport Loader from '../loader';\nimport Button from '../button-link';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst constantNull = constant(null);\n\nclass DragAndDrop extends React.Component {\n static propTypes = {\n title: PropTypes.string,\n description: PropTypes.string,\n uploadLabel: PropTypes.string,\n previewLabel: PropTypes.string,\n previewContent: PropTypes.shape({\n type: PropTypes.string,\n src: PropTypes.string,\n label: PropTypes.string\n }),\n loading: PropTypes.bool,\n modified: PropTypes.bool,\n children: PropTypes.func,\n onReset: PropTypes.func,\n error: PropTypes.string,\n buttonAriaLabel: PropTypes.string,\n errorButtonLabel: PropTypes.string\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n dragging: false\n };\n\n this.handleDragStart = this.handleDragStart.bind(this);\n this.handleDragStop = this.handleDragStop.bind(this);\n }\n\n handleDragStart() {\n this.setState({\n dragging: true\n });\n }\n\n handleDragStop() {\n this.setState({\n dragging: false\n });\n }\n\n render() {\n const idBox = uniqueId('drop-box-');\n const {\n children = constantNull,\n title,\n description,\n uploadLabel,\n previewLabel = '',\n previewContent,\n loading = false,\n modified = false,\n onReset = null,\n error = '',\n buttonAriaLabel = '',\n errorButtonLabel = ''\n } = this.props;\n const {dragging} = this.state;\n\n let previewView = null;\n\n if (previewContent && previewContent.type === 'image') {\n previewView = (\n <div className={style.preview}>\n <img src={previewContent.src} />\n </div>\n );\n } else if (previewContent && previewContent.type === 'video') {\n previewView = (\n <div className={style.preview}>\n <video controls src={previewContent.src} type=\"video/*\" />\n </div>\n );\n } else if (loading) {\n previewView = (\n <div className={style.loaderWrapper}>\n <div className={style.loadingCancel}>\n <Close\n data-name=\"reset-content-icon\"\n height={12}\n width={12}\n className={style.closeIcon}\n onClick={onReset}\n />\n </div>\n <div className={style.loader}>\n <Loader theme=\"coorpmanager\" />\n </div>\n <span className={style.loaderText}>Uploading</span>\n </div>\n );\n } else {\n previewView = <span>{previewLabel}</span>;\n }\n\n const resetContent =\n previewContent && previewContent.src ? (\n <div className={style.resetUploadWrapper}>\n <div className={style.resetSrcLabel}>\n {previewContent.label ? previewContent.label : previewContent.src}\n </div>\n {onReset ? (\n <Close\n data-name=\"reset-content-icon\"\n height={12}\n width={12}\n className={style.closeIcon}\n onClick={onReset}\n />\n ) : null}\n </div>\n ) : null;\n\n const buildButton = () => {\n const defaultButtonProps = {\n label: uploadLabel,\n 'aria-label': buttonAriaLabel,\n 'data-name': 'default-button',\n icon: {\n position: 'left',\n type: 'folders'\n }\n };\n if (dragging) {\n return null;\n } else if (error) {\n return <Button {...defaultButtonProps} label={errorButtonLabel} icon={{}} />;\n } else {\n return <Button {...defaultButtonProps} />;\n }\n };\n\n const button = buildButton(dragging, error);\n\n const previewContainer = getClassState(\n style.previewContainer,\n style.modifiedPreviewContainer,\n null,\n modified,\n error\n );\n const inputWrapper = getClassState(\n style.inputWrapper,\n style.modifiedInputWrapper,\n style.errorInputWrapper,\n modified,\n error\n );\n\n return (\n <div className={style.wrapper} data-name=\"drag-and-drop-wrapper\">\n <div className={style.title}>{title}</div>\n {!isEmpty(previewContent) || loading ? (\n <div className={previewContainer}>{previewView}</div>\n ) : (\n <div className={dragging ? style.dragging : inputWrapper} id={idBox}>\n <div className={style.infosContainer}>\n {error ? (\n <FileUploadBlockedIcon className={style.iconError} />\n ) : (\n <FileUploadIcon className={style.icon} />\n )}\n {description ? <div className={style.description}>{description}</div> : null}\n {error ? null : <div className={style.dragAndDropLabel}>{'Drag & Drop here'}</div>}\n </div>\n {button}\n <div>{children(this.handleDragStart, this.handleDragStop)}</div>\n </div>\n )}\n {error ? <span className={style.errorMessage}>{error}</span> : resetContent}\n </div>\n );\n }\n}\n\nexport default DragAndDrop;\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/drag-and-drop/index.js"],"names":["constantNull","DragAndDrop","React","Component","constructor","props","state","dragging","handleDragStart","bind","handleDragStop","setState","render","idBox","children","title","description","uploadLabel","previewLabel","previewContent","loading","modified","onReset","error","buttonAriaLabel","errorButtonLabel","disabled","previewView","type","style","preview","src","loaderWrapper","loadingCancel","closeIcon","loader","loaderText","resetContent","resetUploadWrapper","resetSrcLabel","label","buildButton","defaultButtonProps","icon","position","button","previewContainer","modifiedPreviewContainer","inputWrapper","modifiedInputWrapper","errorInputWrapper","wrapper","infosContainer","iconError","dragAndDropLabel","errorMessage","propTypes","PropTypes","string","shape","bool","func"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,YAAY,GAAG,wBAAS,IAAT,CAArB;;AAEA,MAAMC,WAAN,SAA0BC,eAAMC,SAAhC,CAA0C;AAqBxCC,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,UAAMA,KAAN;AAEA,SAAKC,KAAL,GAAa;AACXC,MAAAA,QAAQ,EAAE;AADC,KAAb;AAIA,SAAKC,eAAL,GAAuB,KAAKA,eAAL,CAAqBC,IAArB,CAA0B,IAA1B,CAAvB;AACA,SAAKC,cAAL,GAAsB,KAAKA,cAAL,CAAoBD,IAApB,CAAyB,IAAzB,CAAtB;AACD;;AAEDD,EAAAA,eAAe,GAAG;AAChB,SAAKG,QAAL,CAA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A;AAgBjBlC,EAAAA,eAAe,EAAEiC,mBAAUC,MAhBV;AAiBjBjC,EAAAA,gBAAgB,EAAEgC,mBAAUC;AAjBX,C;eAgMNzD,W","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {uniqueId, constant, isEmpty} from 'lodash/fp';\nimport {\n NovaSolidStatusClose as Close,\n NovaSolidFilesBasicFileUpload2 as FileUploadIcon,\n NovaSolidFilesBasicFileBlock2 as FileUploadBlockedIcon\n} from '@coorpacademy/nova-icons';\nimport classnames from 'classnames';\nimport Loader from '../loader';\nimport Button from '../button-link';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst constantNull = constant(null);\n\nclass DragAndDrop extends React.Component {\n static propTypes = {\n title: PropTypes.string,\n description: PropTypes.string,\n uploadLabel: PropTypes.string,\n previewLabel: PropTypes.string,\n previewContent: PropTypes.shape({\n type: PropTypes.string,\n src: PropTypes.string,\n label: PropTypes.string\n }),\n loading: PropTypes.bool,\n modified: PropTypes.bool,\n disabled: PropTypes.bool,\n children: PropTypes.func,\n onReset: PropTypes.func,\n error: PropTypes.string,\n buttonAriaLabel: PropTypes.string,\n errorButtonLabel: PropTypes.string\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n dragging: false\n };\n\n this.handleDragStart = this.handleDragStart.bind(this);\n this.handleDragStop = this.handleDragStop.bind(this);\n }\n\n handleDragStart() {\n this.setState({\n dragging: true\n });\n }\n\n handleDragStop() {\n this.setState({\n dragging: false\n });\n }\n\n render() {\n const idBox = uniqueId('drop-box-');\n const {\n children = constantNull,\n title,\n description,\n uploadLabel,\n previewLabel = '',\n previewContent,\n loading = false,\n modified = false,\n onReset = null,\n error = '',\n buttonAriaLabel = '',\n errorButtonLabel = '',\n disabled = false\n } = this.props;\n const {dragging} = this.state;\n\n let previewView = null;\n\n if (previewContent && previewContent.type === 'image') {\n previewView = (\n <div className={style.preview}>\n <img src={previewContent.src} />\n </div>\n );\n } else if (previewContent && previewContent.type === 'video') {\n previewView = (\n <div className={style.preview}>\n <video controls src={previewContent.src} type=\"video/*\" />\n </div>\n );\n } else if (loading) {\n previewView = (\n <div className={style.loaderWrapper}>\n <div className={style.loadingCancel}>\n <Close\n data-name=\"reset-content-icon\"\n height={12}\n width={12}\n className={style.closeIcon}\n onClick={onReset}\n />\n </div>\n <div className={style.loader}>\n <Loader theme=\"coorpmanager\" />\n </div>\n <span className={style.loaderText}>Uploading</span>\n </div>\n );\n } else {\n previewView = <span>{previewLabel}</span>;\n }\n\n const resetContent =\n previewContent && previewContent.src ? (\n <div className={classnames(style.resetUploadWrapper, disabled && style.disabled)}>\n <div className={style.resetSrcLabel}>\n {previewContent.label ? previewContent.label : previewContent.src}\n </div>\n {onReset ? (\n <Close\n data-name=\"reset-content-icon\"\n height={12}\n width={12}\n className={style.closeIcon}\n onClick={onReset}\n />\n ) : null}\n </div>\n ) : null;\n\n const buildButton = () => {\n const defaultButtonProps = {\n label: uploadLabel,\n 'aria-label': buttonAriaLabel,\n 'data-name': 'default-button',\n icon: {\n position: 'left',\n type: 'folders'\n }\n };\n if (dragging) {\n return null;\n } else if (error) {\n return <Button {...defaultButtonProps} label={errorButtonLabel} icon={{}} />;\n } else {\n return <Button {...defaultButtonProps} />;\n }\n };\n\n const button = buildButton(dragging, error);\n\n const previewContainer = getClassState(\n style.previewContainer,\n style.modifiedPreviewContainer,\n null,\n modified,\n error\n );\n const inputWrapper = getClassState(\n style.inputWrapper,\n style.modifiedInputWrapper,\n style.errorInputWrapper,\n modified,\n error\n );\n\n return (\n <div className={style.wrapper} data-name=\"drag-and-drop-wrapper\">\n <div className={style.title}>{title}</div>\n {!isEmpty(previewContent) || loading ? (\n <div className={classnames(previewContainer, disabled && style.disabled)}>\n {previewView}\n </div>\n ) : (\n <div\n className={classnames(\n dragging ? style.dragging : inputWrapper,\n disabled && style.disabled\n )}\n id={idBox}\n >\n <div className={style.infosContainer}>\n {error ? (\n <FileUploadBlockedIcon className={style.iconError} />\n ) : (\n <FileUploadIcon className={style.icon} />\n )}\n {description ? <div className={style.description}>{description}</div> : null}\n {error ? null : <div className={style.dragAndDropLabel}>{'Drag & Drop here'}</div>}\n </div>\n {button}\n <div>{children(this.handleDragStart, this.handleDragStop)}</div>\n </div>\n )}\n {error ? (\n <span className={classnames(style.errorMessage, disabled && style.disabled)}>\n {error}\n </span>\n ) : (\n resetContent\n )}\n </div>\n );\n }\n}\n\nexport default DragAndDrop;\n"],"file":"index.js"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
|
|
6
|
+
var _withImageReset = _interopRequireDefault(require("./with-image-reset"));
|
|
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
|
+
const {
|
|
13
|
+
props
|
|
14
|
+
} = _withImageReset.default;
|
|
15
|
+
var _default = {
|
|
16
|
+
props: _extends(_extends({}, props), {}, {
|
|
17
|
+
disabled: true
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
exports.default = _default;
|
|
21
|
+
//# sourceMappingURL=disabled-with-image-reset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/atom/drag-and-drop/test/fixtures/disabled-with-image-reset.js"],"names":["props","withImageReset","disabled"],"mappings":";;;;;AAAA;;;;;;AAEA,MAAM;AAACA,EAAAA;AAAD,IAAUC,uBAAhB;eAEe;AACbD,EAAAA,KAAK,wBACAA,KADA;AAEHE,IAAAA,QAAQ,EAAE;AAFP;AADQ,C","sourcesContent":["import withImageReset from './with-image-reset';\n\nconst {props} = withImageReset;\n\nexport default {\n props: {\n ...props,\n disabled: true\n }\n};\n"],"file":"disabled-with-image-reset.js"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
const {
|
|
13
|
+
props
|
|
14
|
+
} = _default2.default;
|
|
15
|
+
var _default = {
|
|
16
|
+
props: _extends(_extends({}, props), {}, {
|
|
17
|
+
disabled: true
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
exports.default = _default;
|
|
21
|
+
//# sourceMappingURL=disabled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/atom/drag-and-drop/test/fixtures/disabled.js"],"names":["props","defaultProps","disabled"],"mappings":";;;;;AAAA;;;;;;AAEA,MAAM;AAACA,EAAAA;AAAD,IAAUC,iBAAhB;eAEe;AACbD,EAAAA,KAAK,wBACAA,KADA;AAEHE,IAAAA,QAAQ,EAAE;AAFP;AADQ,C","sourcesContent":["import defaultProps from './default';\n\nconst {props} = defaultProps;\n\nexport default {\n props: {\n ...props,\n disabled: true\n }\n};\n"],"file":"disabled.js"}
|
|
@@ -12,6 +12,10 @@ var _cleanAndModified = _interopRequireDefault(require("./fixtures/clean-and-mod
|
|
|
12
12
|
|
|
13
13
|
var _default = _interopRequireDefault(require("./fixtures/default"));
|
|
14
14
|
|
|
15
|
+
var _disabledWithImageReset = _interopRequireDefault(require("./fixtures/disabled-with-image-reset"));
|
|
16
|
+
|
|
17
|
+
var _disabled = _interopRequireDefault(require("./fixtures/disabled"));
|
|
18
|
+
|
|
15
19
|
var _error = _interopRequireDefault(require("./fixtures/error"));
|
|
16
20
|
|
|
17
21
|
var _loading = _interopRequireDefault(require("./fixtures/loading"));
|
|
@@ -38,6 +42,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
38
42
|
});
|
|
39
43
|
(0, _ava.default)('Atom › AtomDragAndDrop › CleanAndModified › should be rendered', _renderComponent.default, _.default, _cleanAndModified.default);
|
|
40
44
|
(0, _ava.default)('Atom › AtomDragAndDrop › Default › should be rendered', _renderComponent.default, _.default, _default.default);
|
|
45
|
+
(0, _ava.default)('Atom › AtomDragAndDrop › DisabledWithImageReset › should be rendered', _renderComponent.default, _.default, _disabledWithImageReset.default);
|
|
46
|
+
(0, _ava.default)('Atom › AtomDragAndDrop › Disabled › should be rendered', _renderComponent.default, _.default, _disabled.default);
|
|
41
47
|
(0, _ava.default)('Atom › AtomDragAndDrop › Error › should be rendered', _renderComponent.default, _.default, _error.default);
|
|
42
48
|
(0, _ava.default)('Atom › AtomDragAndDrop › Loading › should be rendered', _renderComponent.default, _.default, _loading.default);
|
|
43
49
|
(0, _ava.default)('Atom › AtomDragAndDrop › Modified › should be rendered', _renderComponent.default, _.default, _modified.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/atom/drag-and-drop/test/fixtures.js"],"names":["t","pass","AtomDragAndDrop","propTypes","value","key","not","undefined","renderComponentMacro","fixtureCleanAndModified","fixtureDefault","fixtureError","fixtureLoading","fixtureModified","fixtureWithChildren","fixtureWithImageReset","fixtureWithImage","fixtureWithLongDescription","fixtureWithVideo"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,kBAAK,sDAAL,EAA6DA,CAAC,IAAI;AAChEA,EAAAA,CAAC,CAACC,IAAF;AACA,wBAAQC,UAAgBC,SAAxB,EAAmC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACjDL,IAAAA,CAAC,CAACM,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,gDAA+CF,GAAI,mEAA5E;AACD,GAFD;AAGD,CALD;AAOA,kBAAK,gEAAL,EAAuEG,wBAAvE,EAA6FN,SAA7F,EAA8GO,yBAA9G;AACA,kBAAK,uDAAL,EAA8DD,wBAA9D,EAAoFN,SAApF,EAAqGQ,gBAArG;AACA,kBAAK,qDAAL,
|
|
1
|
+
{"version":3,"sources":["../../../../src/atom/drag-and-drop/test/fixtures.js"],"names":["t","pass","AtomDragAndDrop","propTypes","value","key","not","undefined","renderComponentMacro","fixtureCleanAndModified","fixtureDefault","fixtureDisabledWithImageReset","fixtureDisabled","fixtureError","fixtureLoading","fixtureModified","fixtureWithChildren","fixtureWithImageReset","fixtureWithImage","fixtureWithLongDescription","fixtureWithVideo"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,kBAAK,sDAAL,EAA6DA,CAAC,IAAI;AAChEA,EAAAA,CAAC,CAACC,IAAF;AACA,wBAAQC,UAAgBC,SAAxB,EAAmC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACjDL,IAAAA,CAAC,CAACM,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,gDAA+CF,GAAI,mEAA5E;AACD,GAFD;AAGD,CALD;AAOA,kBAAK,gEAAL,EAAuEG,wBAAvE,EAA6FN,SAA7F,EAA8GO,yBAA9G;AACA,kBAAK,uDAAL,EAA8DD,wBAA9D,EAAoFN,SAApF,EAAqGQ,gBAArG;AACA,kBAAK,sEAAL,EAA6EF,wBAA7E,EAAmGN,SAAnG,EAAoHS,+BAApH;AACA,kBAAK,wDAAL,EAA+DH,wBAA/D,EAAqFN,SAArF,EAAsGU,iBAAtG;AACA,kBAAK,qDAAL,EAA4DJ,wBAA5D,EAAkFN,SAAlF,EAAmGW,cAAnG;AACA,kBAAK,uDAAL,EAA8DL,wBAA9D,EAAoFN,SAApF,EAAqGY,gBAArG;AACA,kBAAK,wDAAL,EAA+DN,wBAA/D,EAAqFN,SAArF,EAAsGa,iBAAtG;AACA,kBAAK,4DAAL,EAAmEP,wBAAnE,EAAyFN,SAAzF,EAA0Gc,qBAA1G;AACA,kBAAK,8DAAL,EAAqER,wBAArE,EAA2FN,SAA3F,EAA4Ge,uBAA5G;AACA,kBAAK,yDAAL,EAAgET,wBAAhE,EAAsFN,SAAtF,EAAuGgB,kBAAvG;AACA,kBAAK,mEAAL,EAA0EV,wBAA1E,EAAgGN,SAAhG,EAAiHiB,4BAAjH;AACA,kBAAK,yDAAL,EAAgEX,wBAAhE,EAAsFN,SAAtF,EAAuGkB,kBAAvG","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport AtomDragAndDrop from '..';\nimport fixtureCleanAndModified from './fixtures/clean-and-modified';\nimport fixtureDefault from './fixtures/default';\nimport fixtureDisabledWithImageReset from './fixtures/disabled-with-image-reset';\nimport fixtureDisabled from './fixtures/disabled';\nimport fixtureError from './fixtures/error';\nimport fixtureLoading from './fixtures/loading';\nimport fixtureModified from './fixtures/modified';\nimport fixtureWithChildren from './fixtures/with-children';\nimport fixtureWithImageReset from './fixtures/with-image-reset';\nimport fixtureWithImage from './fixtures/with-image';\nimport fixtureWithLongDescription from './fixtures/with-long-description';\nimport fixtureWithVideo from './fixtures/with-video';\n\ntest('Atom › AtomDragAndDrop > should have valid propTypes', t => {\n t.pass();\n forEach(AtomDragAndDrop.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Atom.AtomDragAndDrop.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Atom › AtomDragAndDrop › CleanAndModified › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureCleanAndModified);\ntest('Atom › AtomDragAndDrop › Default › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureDefault);\ntest('Atom › AtomDragAndDrop › DisabledWithImageReset › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureDisabledWithImageReset);\ntest('Atom › AtomDragAndDrop › Disabled › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureDisabled);\ntest('Atom › AtomDragAndDrop › Error › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureError);\ntest('Atom › AtomDragAndDrop › Loading › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureLoading);\ntest('Atom › AtomDragAndDrop › Modified › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureModified);\ntest('Atom › AtomDragAndDrop › WithChildren › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureWithChildren);\ntest('Atom › AtomDragAndDrop › WithImageReset › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureWithImageReset);\ntest('Atom › AtomDragAndDrop › WithImage › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureWithImage);\ntest('Atom › AtomDragAndDrop › WithLongDescription › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureWithLongDescription);\ntest('Atom › AtomDragAndDrop › WithVideo › should be rendered', renderComponentMacro, AtomDragAndDrop, fixtureWithVideo);\n"],"file":"fixtures.js"}
|
|
@@ -37,6 +37,7 @@ const ImageUpload = ({
|
|
|
37
37
|
uploadLabel,
|
|
38
38
|
loading,
|
|
39
39
|
modified,
|
|
40
|
+
disabled = false,
|
|
40
41
|
onChange,
|
|
41
42
|
onReset = null,
|
|
42
43
|
name,
|
|
@@ -62,13 +63,14 @@ const ImageUpload = ({
|
|
|
62
63
|
modified: modified,
|
|
63
64
|
onReset: handleReset,
|
|
64
65
|
error: error,
|
|
66
|
+
disabled: disabled,
|
|
65
67
|
buttonAriaLabel: buttonAriaLabel,
|
|
66
68
|
errorButtonLabel: errorButtonLabel
|
|
67
69
|
}, (onDragStart, onDragStop) => /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("input", {
|
|
68
70
|
type: "file",
|
|
69
71
|
name: name,
|
|
70
72
|
accept: acceptedImages,
|
|
71
|
-
disabled: loading,
|
|
73
|
+
disabled: loading || disabled,
|
|
72
74
|
className: _style.default.input,
|
|
73
75
|
onChange: onChange,
|
|
74
76
|
onDragEnter: onDragStart,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/atom/image-upload/index.js"],"names":["ImageUpload","title","description","previewLabel","previewContent","uploadLabel","loading","modified","onChange","onReset","name","imageTypes","error","buttonAriaLabel","errorButtonLabel","handleReset","e","preventDefault","acceptedImages","t","onDragStart","onDragStop","style","input","propTypes","DragAndDrop","PropTypes","string","func","arrayOf","ImagePropType"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,WAAW,GAAG,CAAC;AACnBC,EAAAA,KADmB;AAEnBC,EAAAA,WAFmB;AAGnBC,EAAAA,YAHmB;AAInBC,EAAAA,cAJmB;AAKnBC,EAAAA,WALmB;AAMnBC,EAAAA,OANmB;AAOnBC,EAAAA,QAPmB;AAQnBC,EAAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/image-upload/index.js"],"names":["ImageUpload","title","description","previewLabel","previewContent","uploadLabel","loading","modified","disabled","onChange","onReset","name","imageTypes","error","buttonAriaLabel","errorButtonLabel","handleReset","e","preventDefault","acceptedImages","t","onDragStart","onDragStop","style","input","propTypes","DragAndDrop","PropTypes","string","func","arrayOf","ImagePropType"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,WAAW,GAAG,CAAC;AACnBC,EAAAA,KADmB;AAEnBC,EAAAA,WAFmB;AAGnBC,EAAAA,YAHmB;AAInBC,EAAAA,cAJmB;AAKnBC,EAAAA,W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AAEe,eAAMC,KALnB;AAME,IAAA,QAAQ,EAAEf,QANZ;AAOE,IAAA,WAAW,EAAEY,WAPf;AAQE,IAAA,MAAM,EAAEC,UARV;AASE,IAAA,WAAW,EAAEA;AATf,IADF,CAfJ,CADF;AAgCD,CAhED;;AAkEAtB,WAAW,CAACyB,SAAZ,iEACKC,qBAAYD,SADjB;AAEEd,EAAAA,IAAI,EAAEgB,mBAAUC,MAFlB;AAGEnB,EAAAA,QAAQ,EAAEkB,mBAAUE,IAHtB;AAIEnB,EAAAA,OAAO,EAAEiB,mBAAUE,IAJrB;AAKEjB,EAAAA,UAAU,EAAEe,mBAAUG,OAAV,CAAkBC,wBAAlB,CALd;AAMElB,EAAAA,KAAK,EAAEc,mBAAUC,MANnB;AAOEd,EAAAA,eAAe,EAAEa,mBAAUC,MAP7B;AAQEb,EAAAA,gBAAgB,EAAEY,mBAAUC;AAR9B;eAWe5B,W","sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport {join, map, pipe, isNil} from 'lodash/fp';\nimport DragAndDrop from '../drag-and-drop';\nimport {ImagePropType} from '../../util/proptypes';\nimport style from './style.css';\n\nconst ImageUpload = ({\n title,\n description,\n previewLabel,\n previewContent,\n uploadLabel,\n loading,\n modified,\n disabled = false,\n onChange,\n onReset = null,\n name,\n // See ImagePropType for accepted values\n imageTypes = ['*'],\n error = '',\n buttonAriaLabel,\n errorButtonLabel\n}) => {\n const handleReset = useCallback(\n e => {\n if (isNil(onReset)) return;\n e.preventDefault();\n return onReset(e);\n },\n [onReset]\n );\n\n const acceptedImages = pipe(\n map(t => `image/${t}`),\n join(',')\n )(imageTypes);\n\n return (\n <DragAndDrop\n title={title}\n description={description}\n previewLabel={previewLabel}\n previewContent={previewContent}\n uploadLabel={uploadLabel}\n loading={loading}\n modified={modified}\n onReset={handleReset}\n error={error}\n disabled={disabled}\n buttonAriaLabel={buttonAriaLabel}\n errorButtonLabel={errorButtonLabel}\n >\n {(onDragStart, onDragStop) => (\n <div>\n <input\n type=\"file\"\n name={name}\n accept={acceptedImages}\n disabled={loading || disabled}\n className={style.input}\n onChange={onChange}\n onDragEnter={onDragStart}\n onDrop={onDragStop}\n onDragLeave={onDragStop}\n />\n </div>\n )}\n </DragAndDrop>\n );\n};\n\nImageUpload.propTypes = {\n ...DragAndDrop.propTypes,\n name: PropTypes.string,\n onChange: PropTypes.func,\n onReset: PropTypes.func,\n imageTypes: PropTypes.arrayOf(ImagePropType),\n error: PropTypes.string,\n buttonAriaLabel: PropTypes.string,\n errorButtonLabel: PropTypes.string\n};\n\nexport default ImageUpload;\n"],"file":"index.js"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
const {
|
|
13
|
+
props
|
|
14
|
+
} = _default2.default;
|
|
15
|
+
var _default = {
|
|
16
|
+
props: _extends(_extends({}, props), {}, {
|
|
17
|
+
disabled: true
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
exports.default = _default;
|
|
21
|
+
//# sourceMappingURL=disabled.js.map
|