@coorpacademy/components 10.5.7-alpha.5 → 10.5.7-alpha.9
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/es/atom/range/handle.css +18 -2
- package/es/atom/range/handle.js +7 -3
- package/es/atom/range/handle.js.map +1 -1
- package/es/atom/range/style.css +2 -2
- package/es/atom/select/index.js +38 -20
- package/es/atom/select/index.js.map +1 -1
- package/es/atom/select/style.css +154 -42
- package/es/atom/select/test/fixtures/player.js +11 -0
- package/es/atom/select/test/fixtures/player.js.map +1 -0
- package/es/atom/select/test/select.js +49 -0
- package/es/atom/select/test/select.js.map +1 -0
- package/es/molecule/cockpit-popin/test/fixtures.js +17 -0
- package/es/molecule/cockpit-popin/test/fixtures.js.map +1 -0
- package/es/molecule/questions/drop-down/index.js +1 -6
- package/es/molecule/questions/drop-down/index.js.map +1 -1
- package/es/molecule/questions/free-text/index.js +35 -15
- package/es/molecule/questions/free-text/index.js.map +1 -1
- package/es/molecule/questions/free-text/style.css +39 -15
- package/es/molecule/questions/free-text/test/fixtures/default.js +1 -1
- package/es/molecule/questions/free-text/test/fixtures/default.js.map +1 -1
- package/es/molecule/questions/free-text/test/fixtures/with-value-on-change.js +9 -0
- package/es/molecule/questions/free-text/test/fixtures/with-value-on-change.js.map +1 -0
- package/es/molecule/questions/free-text/test/fixtures/{with-default-value.js → with-value.js} +2 -2
- package/es/molecule/questions/free-text/test/fixtures/with-value.js.map +1 -0
- package/es/molecule/questions/free-text/test/free-text.js +106 -0
- package/es/molecule/questions/free-text/test/free-text.js.map +1 -0
- package/es/molecule/questions/qcm/style.css +4 -0
- package/es/molecule/questions/qcm-drag/index.js +53 -21
- package/es/molecule/questions/qcm-drag/index.js.map +1 -1
- package/es/molecule/questions/qcm-drag/style.css +72 -22
- package/es/molecule/questions/qcm-graphic/index.js +1 -0
- package/es/molecule/questions/qcm-graphic/index.js.map +1 -1
- package/es/molecule/questions/qcm-graphic/style.css +12 -2
- package/es/molecule/questions/qcm-graphic/test/fixtures/default.js +1 -1
- package/es/molecule/questions/qcm-graphic/test/fixtures/default.js.map +1 -1
- package/es/molecule/questions/qcm-graphic/test/fixtures/no-selected.js +1 -1
- package/es/molecule/questions/qcm-graphic/test/fixtures/no-selected.js.map +1 -1
- package/es/molecule/questions/qcm-graphic/test/qcm-graphic.js +1 -1
- package/es/molecule/questions/qcm-graphic/test/qcm-graphic.js.map +1 -1
- package/es/molecule/questions/question-range/style.css +9 -8
- package/es/molecule/questions/template/index.js +13 -10
- package/es/molecule/questions/template/index.js.map +1 -1
- package/es/molecule/search/test/fixtures.js +15 -0
- package/es/molecule/search/test/fixtures.js.map +1 -0
- package/lib/atom/range/handle.css +18 -2
- package/lib/atom/range/handle.js +8 -3
- package/lib/atom/range/handle.js.map +1 -1
- package/lib/atom/range/style.css +2 -2
- package/lib/atom/select/index.js +40 -17
- package/lib/atom/select/index.js.map +1 -1
- package/lib/atom/select/style.css +154 -42
- package/lib/atom/select/test/fixtures/player.js +21 -0
- package/lib/atom/select/test/fixtures/player.js.map +1 -0
- package/lib/atom/select/test/select.js +62 -0
- package/lib/atom/select/test/select.js.map +1 -0
- package/lib/molecule/cockpit-popin/test/fixtures.js +28 -0
- package/lib/molecule/cockpit-popin/test/fixtures.js.map +1 -0
- package/lib/molecule/questions/drop-down/index.js +1 -5
- package/lib/molecule/questions/drop-down/index.js.map +1 -1
- package/lib/molecule/questions/free-text/index.js +32 -14
- package/lib/molecule/questions/free-text/index.js.map +1 -1
- package/lib/molecule/questions/free-text/style.css +39 -15
- package/lib/molecule/questions/free-text/test/fixtures/default.js +1 -1
- package/lib/molecule/questions/free-text/test/fixtures/default.js.map +1 -1
- package/lib/molecule/questions/free-text/test/fixtures/with-value-on-change.js +14 -0
- package/lib/molecule/questions/free-text/test/fixtures/with-value-on-change.js.map +1 -0
- package/lib/molecule/questions/free-text/test/fixtures/{with-default-value.js → with-value.js} +2 -2
- package/lib/molecule/questions/free-text/test/fixtures/with-value.js.map +1 -0
- package/lib/molecule/questions/free-text/test/free-text.js +119 -0
- package/lib/molecule/questions/free-text/test/free-text.js.map +1 -0
- package/lib/molecule/questions/qcm/style.css +4 -0
- package/lib/molecule/questions/qcm-drag/index.js +53 -21
- package/lib/molecule/questions/qcm-drag/index.js.map +1 -1
- package/lib/molecule/questions/qcm-drag/style.css +72 -22
- package/lib/molecule/questions/qcm-graphic/index.js +1 -0
- package/lib/molecule/questions/qcm-graphic/index.js.map +1 -1
- package/lib/molecule/questions/qcm-graphic/style.css +12 -2
- package/lib/molecule/questions/qcm-graphic/test/fixtures/default.js +1 -1
- package/lib/molecule/questions/qcm-graphic/test/fixtures/default.js.map +1 -1
- package/lib/molecule/questions/qcm-graphic/test/fixtures/no-selected.js +1 -1
- package/lib/molecule/questions/qcm-graphic/test/fixtures/no-selected.js.map +1 -1
- package/lib/molecule/questions/qcm-graphic/test/qcm-graphic.js +1 -1
- package/lib/molecule/questions/qcm-graphic/test/qcm-graphic.js.map +1 -1
- package/lib/molecule/questions/question-range/style.css +9 -8
- package/lib/molecule/questions/template/index.js +13 -10
- package/lib/molecule/questions/template/index.js.map +1 -1
- package/lib/molecule/search/test/fixtures.js +25 -0
- package/lib/molecule/search/test/fixtures.js.map +1 -0
- package/package.json +2 -2
- package/es/molecule/questions/free-text/test/fixtures/with-default-value.js.map +0 -1
- package/lib/molecule/questions/free-text/test/fixtures/with-default-value.js.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
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 browserEnv from 'browser-env';
|
|
4
|
+
import test from 'ava';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { mount, configure } from 'enzyme';
|
|
7
|
+
import cloneDeep from 'lodash/fp/cloneDeep';
|
|
8
|
+
import noop from 'lodash/fp/noop';
|
|
9
|
+
import Adapter from 'enzyme-adapter-react-16';
|
|
10
|
+
import Select from '..';
|
|
11
|
+
import playerFixture from './fixtures/player';
|
|
12
|
+
browserEnv();
|
|
13
|
+
configure({
|
|
14
|
+
adapter: new Adapter()
|
|
15
|
+
});
|
|
16
|
+
test('classnames: should pass the styles pertinent to a player theme, text color: use skin color (selected, valid option, player)', t => {
|
|
17
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(Select, _extends({}, playerFixture.props, {
|
|
18
|
+
onChange: noop
|
|
19
|
+
})));
|
|
20
|
+
const selectWrapper = wrapper.find('[data-name="select-wrapper"]');
|
|
21
|
+
t.true(selectWrapper.at(0).exists()); // should use skin color
|
|
22
|
+
|
|
23
|
+
t.deepEqual(selectWrapper.at(0).props().style, {
|
|
24
|
+
color: '#00B0FF'
|
|
25
|
+
});
|
|
26
|
+
const selectSpan = selectWrapper.at(0).find('[data-name="select-span"]');
|
|
27
|
+
t.true(selectSpan.at(0).exists());
|
|
28
|
+
t.is(selectSpan.at(0).props().className, 'select__selectSpan select__noLabelCommon');
|
|
29
|
+
});
|
|
30
|
+
test('text color: should not use skin color (selected, invalid option, player), long label', t => {
|
|
31
|
+
const withInvalid = cloneDeep(playerFixture.props);
|
|
32
|
+
withInvalid.options[1] = {
|
|
33
|
+
name: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean.',
|
|
34
|
+
value: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean.',
|
|
35
|
+
selected: true,
|
|
36
|
+
validOption: false
|
|
37
|
+
};
|
|
38
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(Select, _extends({}, withInvalid, {
|
|
39
|
+
onChange: noop
|
|
40
|
+
})));
|
|
41
|
+
const selectWrapper = wrapper.find('[data-name="select-wrapper"]');
|
|
42
|
+
t.true(selectWrapper.at(0).exists()); // should not use skin color
|
|
43
|
+
|
|
44
|
+
t.deepEqual(selectWrapper.at(0).props().style, {});
|
|
45
|
+
const selectSpan = selectWrapper.at(0).find('[data-name="select-span"]');
|
|
46
|
+
t.true(selectSpan.at(0).exists());
|
|
47
|
+
t.is(selectSpan.at(0).props().className, 'select__selectSpan select__noLabelCommon select__longLabel');
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/atom/select/test/select.js"],"names":["browserEnv","test","React","mount","configure","cloneDeep","noop","Adapter","Select","playerFixture","adapter","t","wrapper","props","selectWrapper","find","true","at","exists","deepEqual","style","color","selectSpan","is","className","withInvalid","options","name","value","selected","validOption"],"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,SAAP,MAAsB,qBAAtB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,OAAP,MAAoB,yBAApB;AACA,OAAOC,MAAP,MAAmB,IAAnB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AAEAT,UAAU;AACVI,SAAS,CAAC;AAACM,EAAAA,OAAO,EAAE,IAAIH,OAAJ;AAAV,CAAD,CAAT;AAEAN,IAAI,CAAC,6HAAD,EAAgIU,CAAC,IAAI;AACvI,QAAMC,OAAO,GAAGT,KAAK,eAAC,oBAAC,MAAD,eAAYM,aAAa,CAACI,KAA1B;AAAiC,IAAA,QAAQ,EAAEP;AAA3C,KAAD,CAArB;AACA,QAAMQ,aAAa,GAAGF,OAAO,CAACG,IAAR,CAAa,8BAAb,CAAtB;AACAJ,EAAAA,CAAC,CAACK,IAAF,CAAOF,aAAa,CAACG,EAAd,CAAiB,CAAjB,EAAoBC,MAApB,EAAP,EAHuI,CAIvI;;AACAP,EAAAA,CAAC,CAACQ,SAAF,CAAYL,aAAa,CAACG,EAAd,CAAiB,CAAjB,E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C,CAACK,IAAF,CAAOM,UAAU,CAACL,EAAX,CAAc,CAAd,EAAiBC,MAAjB,EAAP;AACAP,EAAAA,CAAC,CAACY,EAAF,CACED,UAAU,CAACL,EAAX,CAAc,CAAd,EAAiBJ,KAAjB,GAAyBW,SAD3B,EAEE,4DAFF;AAID,CAnBG,CAAJ","sourcesContent":["import browserEnv from 'browser-env';\nimport test from 'ava';\nimport React from 'react';\nimport {mount, configure} from 'enzyme';\nimport cloneDeep from 'lodash/fp/cloneDeep';\nimport noop from 'lodash/fp/noop';\nimport Adapter from 'enzyme-adapter-react-16';\nimport Select from '..';\nimport playerFixture from './fixtures/player';\n\nbrowserEnv();\nconfigure({adapter: new Adapter()});\n\ntest('classnames: should pass the styles pertinent to a player theme, text color: use skin color (selected, valid option, player)', t => {\n const wrapper = mount(<Select {...playerFixture.props} onChange={noop} />);\n const selectWrapper = wrapper.find('[data-name=\"select-wrapper\"]');\n t.true(selectWrapper.at(0).exists());\n // should use skin color\n t.deepEqual(selectWrapper.at(0).props().style, {\n color: '#00B0FF'\n });\n const selectSpan = selectWrapper.at(0).find('[data-name=\"select-span\"]');\n t.true(selectSpan.at(0).exists());\n t.is(selectSpan.at(0).props().className, 'select__selectSpan select__noLabelCommon');\n});\n\ntest('text color: should not use skin color (selected, invalid option, player), long label', t => {\n const withInvalid = cloneDeep(playerFixture.props);\n withInvalid.options[1] = {\n name: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean.',\n value: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean.',\n selected: true,\n validOption: false\n };\n const wrapper = mount(<Select {...withInvalid} onChange={noop} />);\n const selectWrapper = wrapper.find('[data-name=\"select-wrapper\"]');\n t.true(selectWrapper.at(0).exists());\n // should not use skin color\n t.deepEqual(selectWrapper.at(0).props().style, {});\n const selectSpan = selectWrapper.at(0).find('[data-name=\"select-span\"]');\n t.true(selectSpan.at(0).exists());\n t.is(\n selectSpan.at(0).props().className,\n 'select__selectSpan select__noLabelCommon select__longLabel'\n );\n});\n"],"file":"select.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import forEach from 'lodash/forEach';
|
|
3
|
+
import renderComponentMacro from '../../../test/helpers/render-component';
|
|
4
|
+
import MoleculeCockpitPopin from '..';
|
|
5
|
+
import fixtureDefault from './fixtures/default';
|
|
6
|
+
import fixtureLoading from './fixtures/loading';
|
|
7
|
+
import fixtureVideoTranslate from './fixtures/video-translate';
|
|
8
|
+
test('Molecule › MoleculeCockpitPopin > should have valid propTypes', t => {
|
|
9
|
+
t.pass();
|
|
10
|
+
forEach(MoleculeCockpitPopin.propTypes, (value, key) => {
|
|
11
|
+
t.not(value, undefined, `PropType for "Molecule.MoleculeCockpitPopin.propTypes.${key}" may not be undefined. Did you mistype the propTypes definition?`);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
test('Molecule › MoleculeCockpitPopin › Default › should be rendered', renderComponentMacro, MoleculeCockpitPopin, fixtureDefault);
|
|
15
|
+
test('Molecule › MoleculeCockpitPopin › Loading › should be rendered', renderComponentMacro, MoleculeCockpitPopin, fixtureLoading);
|
|
16
|
+
test('Molecule › MoleculeCockpitPopin › VideoTranslate › should be rendered', renderComponentMacro, MoleculeCockpitPopin, fixtureVideoTranslate);
|
|
17
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/cockpit-popin/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","MoleculeCockpitPopin","fixtureDefault","fixtureLoading","fixtureVideoTranslate","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,oBAAP,MAAiC,IAAjC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEAN,IAAI,CAAC,+DAAD,EAAkEO,CAAC,IAAI;AACzEA,EAAAA,CAAC,CAACC,IAAF;AACAP,EAAAA,OAAO,CAACE,oBAAoB,CAACM,SAAtB,EAAiC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACtDJ,IAAAA,CAAC,CAACK,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,yDAAwDF,GAAI,mEAArF;AACD,GAFM,CAAP;AAGD,CALG,CAAJ;AAOAX,IAAI,CAAC,gEAAD,EAAmEE,oBAAnE,EAAyFC,oBAAzF,EAA+GC,cAA/G,CAAJ;AACAJ,IAAI,CAAC,gEAAD,EAAmEE,oBAAnE,EAAyFC,oBAAzF,EAA+GE,cAA/G,CAAJ;AACAL,IAAI,CAAC,uEAAD,EAA0EE,oBAA1E,EAAgGC,oBAAhG,EAAsHG,qBAAtH,CAAJ","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport MoleculeCockpitPopin from '..';\nimport fixtureDefault from './fixtures/default';\nimport fixtureLoading from './fixtures/loading';\nimport fixtureVideoTranslate from './fixtures/video-translate';\n\ntest('Molecule › MoleculeCockpitPopin > should have valid propTypes', t => {\n t.pass();\n forEach(MoleculeCockpitPopin.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Molecule.MoleculeCockpitPopin.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Molecule › MoleculeCockpitPopin › Default › should be rendered', renderComponentMacro, MoleculeCockpitPopin, fixtureDefault);\ntest('Molecule › MoleculeCockpitPopin › Loading › should be rendered', renderComponentMacro, MoleculeCockpitPopin, fixtureLoading);\ntest('Molecule › MoleculeCockpitPopin › VideoTranslate › should be rendered', renderComponentMacro, MoleculeCockpitPopin, fixtureVideoTranslate);\n"],"file":"fixtures.js"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import _find from "lodash/fp/find";
|
|
2
|
-
|
|
3
|
-
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); }
|
|
4
|
-
|
|
5
2
|
import React from 'react';
|
|
6
3
|
import PropTypes from 'prop-types';
|
|
7
4
|
import Select, { SelectOptionPropTypes } from '../../../atom/select';
|
|
@@ -29,9 +26,7 @@ const DropDown = props => {
|
|
|
29
26
|
|
|
30
27
|
DropDown.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
31
28
|
onChange: Select.propTypes.onChange,
|
|
32
|
-
options: PropTypes.arrayOf(PropTypes.shape(
|
|
33
|
-
validOption: PropTypes.bool
|
|
34
|
-
}))),
|
|
29
|
+
options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),
|
|
35
30
|
theme: Select.propTypes.theme
|
|
36
31
|
} : {};
|
|
37
32
|
export default DropDown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/questions/drop-down/index.js"],"names":["React","PropTypes","Select","SelectOptionPropTypes","style","DropDown","props","options","onChange","theme","propsTheme","currentSelection","defaultTheme","validOption","wrapper","propTypes","arrayOf","shape"
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/questions/drop-down/index.js"],"names":["React","PropTypes","Select","SelectOptionPropTypes","style","DropDown","props","options","onChange","theme","propsTheme","currentSelection","defaultTheme","validOption","wrapper","propTypes","arrayOf","shape"],"mappings":";AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,MAAP,IAAgBC,qBAAhB,QAA4C,sBAA5C;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,QAAQ,GAAGC,KAAK,IAAI;AACxB,QAAM;AAACC,IAAAA,OAAD;AAAUC,IAAAA,QAAV;AAAoBC,IAAAA,KAAK,EAAEC;AAA3B,MAAyCJ,KAA/C;;AAEA,QAAMK,gBAAgB,GAAG,MAAK,UAAL,EAAiBJ,OAAjB,CAAzB;;AACA,QAAMK,YAAY,GAChB,CAACD,gBAAD,IAAqBA,gBAAgB,CAACE,WAAjB,KAAiC,KAAtD,GAA8D,SAA9D,GAA0E,UAD5E;AAGA,QAAMJ,KAAK,GAAGC,UAAU,IAAIE,YAA5B;AAEA,sBACE;AAAK,IAAA,SAAS,EAAER,KAAK,CAACU;AAAtB,kBACE,oBAAC,MAAD;AAAQ,IAAA,KAAK,EAAEL,KAAf;AAAsB,IAAA,OAAO,EAAEF,OAA/B;AAAwC,IAAA,QAAQ,EAAEC;AAAlD,IADF,CADF;AAKD,CAdD;;AAgBAH,QAAQ,CAACU,SAAT,2CAAqB;AACnBP,EAAAA,QAAQ,EAAEN,MAAM,CAACa,SAAP,CAAiBP,QADR;AAEnBD,EAAAA,OAAO,EAAEN,SAAS,CAACe,OAAV,CAAkBf,SAAS,CAACgB,KAAV,CAAgBd,qBAAhB,CAAlB,CAFU;AAGnBM,EAAAA,KAAK,EAAEP,MAAM,CAACa,SAAP,CAAiBN;AAHL,CAArB;AAMA,eAAeJ,QAAf","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {find} from 'lodash/fp';\nimport Select, {SelectOptionPropTypes} from '../../../atom/select';\nimport style from './style.css';\n\nconst DropDown = props => {\n const {options, onChange, theme: propsTheme} = props;\n\n const currentSelection = find('selected', options);\n const defaultTheme =\n !currentSelection || currentSelection.validOption === false ? 'invalid' : 'question';\n\n const theme = propsTheme || defaultTheme;\n\n return (\n <div className={style.wrapper}>\n <Select theme={theme} options={options} onChange={onChange} />\n </div>\n );\n};\n\nDropDown.propTypes = {\n onChange: Select.propTypes.onChange,\n options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),\n theme: Select.propTypes.theme\n};\n\nexport default DropDown;\n"],"file":"index.js"}
|
|
@@ -1,34 +1,53 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _getOr from "lodash/fp/getOr";
|
|
2
2
|
import _noop from "lodash/fp/noop";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
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); }
|
|
5
|
+
|
|
6
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
4
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import { convert } from 'css-color-function';
|
|
5
9
|
import Provider from '../../../atom/provider';
|
|
6
10
|
import style from './style.css';
|
|
7
11
|
|
|
8
|
-
const FreeText = (props, {
|
|
9
|
-
skin
|
|
10
|
-
}) => {
|
|
12
|
+
const FreeText = (props, context) => {
|
|
11
13
|
const {
|
|
12
14
|
placeholder = '',
|
|
13
15
|
value = '',
|
|
14
|
-
onChange = _noop
|
|
16
|
+
onChange = _noop,
|
|
17
|
+
'aria-label': ariaLabel
|
|
15
18
|
} = props;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
19
|
+
const [hovered, setHovered] = useState(false);
|
|
20
|
+
const handleChange = useCallback(e => onChange(e.target.value), [onChange]);
|
|
21
|
+
|
|
22
|
+
const primarySkinColor = _getOr('#00B0FF', 'skin.common.primary', context);
|
|
23
|
+
|
|
24
|
+
const handleMouseOver = useCallback(() => setHovered(true), [setHovered]);
|
|
25
|
+
const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);
|
|
26
|
+
const shadowBoxPrimaryColor = useMemo(() => convert(`color(${primarySkinColor} a(12%))`), [primarySkinColor]);
|
|
18
27
|
return /*#__PURE__*/React.createElement("div", {
|
|
19
28
|
"data-name": "freeText",
|
|
20
|
-
className: style.wrapper
|
|
29
|
+
className: style.wrapper,
|
|
30
|
+
onMouseOver: handleMouseOver,
|
|
31
|
+
onMouseLeave: handleMouseLeave,
|
|
32
|
+
style: _extends({}, value && {
|
|
33
|
+
boxShadow: hovered ? 'none' : `0 4px 16px ${shadowBoxPrimaryColor}`
|
|
34
|
+
})
|
|
21
35
|
}, /*#__PURE__*/React.createElement("input", {
|
|
36
|
+
"data-name": "free-text-input",
|
|
22
37
|
type: "text",
|
|
23
|
-
|
|
38
|
+
"aria-label": ariaLabel || value || placeholder,
|
|
39
|
+
className: style.freeText,
|
|
24
40
|
placeholder: placeholder,
|
|
25
41
|
value: value,
|
|
26
42
|
onInput: handleChange,
|
|
27
43
|
onChange: _noop,
|
|
28
|
-
style: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
style: _extends(_extends({
|
|
45
|
+
boxShadow: `0 4px 16px ${shadowBoxPrimaryColor}`
|
|
46
|
+
}, value && {
|
|
47
|
+
boxShadow: `0 4px 16px ${hovered ? convert(`color(${primarySkinColor} a(20%))`) : shadowBoxPrimaryColor}`
|
|
48
|
+
}), {}, {
|
|
49
|
+
color: primarySkinColor
|
|
50
|
+
})
|
|
32
51
|
}));
|
|
33
52
|
};
|
|
34
53
|
|
|
@@ -38,7 +57,8 @@ FreeText.contextTypes = {
|
|
|
38
57
|
FreeText.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
39
58
|
placeholder: PropTypes.string,
|
|
40
59
|
value: PropTypes.string,
|
|
41
|
-
onChange: PropTypes.func
|
|
60
|
+
onChange: PropTypes.func,
|
|
61
|
+
'aria-label': PropTypes.string
|
|
42
62
|
} : {};
|
|
43
63
|
export default FreeText;
|
|
44
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/questions/free-text/index.js"],"names":["React","useMemo","PropTypes","Provider","style","FreeText","props","
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/questions/free-text/index.js"],"names":["React","useCallback","useMemo","useState","PropTypes","convert","Provider","style","FreeText","props","context","placeholder","value","onChange","ariaLabel","hovered","setHovered","handleChange","e","target","primarySkinColor","handleMouseOver","handleMouseLeave","shadowBoxPrimaryColor","wrapper","boxShadow","freeText","color","contextTypes","skin","childContextTypes","propTypes","string","func"],"mappings":";;;;;AAAA,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,OAA5B,EAAqCC,QAArC,QAAoD,OAApD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,SAAQC,OAAR,QAAsB,oBAAtB;AACA,OAAOC,QAAP,MAAqB,wBAArB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,QAAQ,GAAG,CAACC,KAAD,EAAQC,OAAR,KAAoB;AACnC,QAAM;AAACC,IAAAA,WAAW,GAAG,EAAf;AAAmBC,IAAAA,KAAK,GAAG,EAA3B;AAA+BC,IAAAA,QAAQ,QAAvC;AAAgD,kBAAcC;AAA9D,MAA2EL,KAAjF;AACA,QAAM,CAACM,OAAD,EAAUC,UAAV,IAAwBb,QAAQ,CAAC,KAAD,CAAtC;AAEA,QAAMc,YAAY,GAAGhB,WAAW,CAACiB,CAAC,IAAIL,QAAQ,CAACK,CAAC,CAACC,MAAF,CAASP,KAAV,CAAd,EAAgC,CAACC,QAAD,CAAhC,CAAhC;;AACA,QAAMO,gBAAgB,GAAG,OAAM,SAAN,EAAiB,qBAAjB,EAAwCV,OAAxC,CAAzB;;AAEA,QAAMW,eAAe,GAAGpB,WAAW,CAAC,MAAMe,UAAU,CAAC,IAAD,CAAjB,EAAyB,CAACA,UAAD,CAAzB,CAAnC;AAEA,QAAMM,gBAAgB,GAAGrB,WAAW,CAAC,MAAMe,UAAU,CAAC,KAAD,CAAjB,EAA0B,CAACA,UAAD,CAA1B,CAApC;AAEA,QAAMO,qBAAqB,GAAGrB,OAAO,CAAC,MAAMG,OAAO,CAAE,SAAQe,gBAAiB,UAA3B,CAAd,EAAqD,CACxFA,gBADwF,CAArD,CAArC;AAIA,sBACE;AACE,iBAAU,UADZ;AAEE,IAAA,SAAS,EAAEb,KAAK,CAACiB,OAFnB;AAGE,IAAA,WAAW,EAAEH,eAHf;AAIE,IAAA,YAAY,EAAEC,gBAJhB;AAKE,IAAA,KAAK,eACCV,KAAK,IAAI;AACXa,MAAAA,SAAS,EAAEV,OAAO,GAAG,MAAH,GAAa,cAAaQ,qBAAsB;AADvD,KADV;AALP,kBAWE;AACE,iBAAU,iBADZ;AAEE,IAAA,IAAI,EAAC,MAFP;AAGE,kBAAYT,SAAS,IAAIF,KAAb,IAAsBD,WAHpC;AAIE,IAAA,SAAS,EAAEJ,KAAK,CAACmB,QAJnB;AAKE,IAAA,WAAW,EAAEf,WALf;AAME,IAAA,KAAK,EAAEC,KANT;AAOE,IAAA,OAAO,EAAEK,YAPX;AAQE,IAAA,QAAQ,OARV;AASE,IAAA,KAAK;AACHQ,MAAAA,SAAS,EAAG,cAAaF,qBAAsB;AAD5C,OAECX,KAAK,IAAI;AACXa,MAAAA,SAAS,EAAG,cACVV,OAAO,GAAGV,OAAO,CAAE,SAAQe,gBAAiB,UAA3B,CAAV,GAAkDG,qBAC1D;AAHU,KAFV;AAOHI,MAAAA,KAAK,EAAEP;AAPJ;AATP,IAXF,CADF;AAiCD,CAhDD;;AAkDAZ,QAAQ,CAACoB,YAAT,GAAwB;AACtBC,EAAAA,IAAI,EAAEvB,QAAQ,CAACwB,iBAAT,CAA2BD;AADX,CAAxB;AAIArB,QAAQ,CAACuB,SAAT,2CAAqB;AACnBpB,EAAAA,WAAW,EAAEP,SAAS,CAAC4B,MADJ;AAEnBpB,EAAAA,KAAK,EAAER,SAAS,CAAC4B,MAFE;AAGnBnB,EAAAA,QAAQ,EAAET,SAAS,CAAC6B,IAHD;AAInB,gBAAc7B,SAAS,CAAC4B;AAJL,CAArB;AAOA,eAAexB,QAAf","sourcesContent":["import React, {useCallback, useMemo, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport {noop, getOr} from 'lodash/fp';\nimport {convert} from 'css-color-function';\nimport Provider from '../../../atom/provider';\nimport style from './style.css';\n\nconst FreeText = (props, context) => {\n const {placeholder = '', value = '', onChange = noop, 'aria-label': ariaLabel} = props;\n const [hovered, setHovered] = useState(false);\n\n const handleChange = useCallback(e => onChange(e.target.value), [onChange]);\n const primarySkinColor = getOr('#00B0FF', 'skin.common.primary', context);\n\n const handleMouseOver = useCallback(() => setHovered(true), [setHovered]);\n\n const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);\n\n const shadowBoxPrimaryColor = useMemo(() => convert(`color(${primarySkinColor} a(12%))`), [\n primarySkinColor\n ]);\n\n return (\n <div\n data-name=\"freeText\"\n className={style.wrapper}\n onMouseOver={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n style={{\n ...(value && {\n boxShadow: hovered ? 'none' : `0 4px 16px ${shadowBoxPrimaryColor}`\n })\n }}\n >\n <input\n data-name=\"free-text-input\"\n type=\"text\"\n aria-label={ariaLabel || value || placeholder}\n className={style.freeText}\n placeholder={placeholder}\n value={value}\n onInput={handleChange}\n onChange={noop}\n style={{\n boxShadow: `0 4px 16px ${shadowBoxPrimaryColor}`,\n ...(value && {\n boxShadow: `0 4px 16px ${\n hovered ? convert(`color(${primarySkinColor} a(20%))`) : shadowBoxPrimaryColor\n }`\n }),\n color: primarySkinColor\n }}\n />\n </div>\n );\n};\n\nFreeText.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nFreeText.propTypes = {\n placeholder: PropTypes.string,\n value: PropTypes.string,\n onChange: PropTypes.func,\n 'aria-label': PropTypes.string\n};\n\nexport default FreeText;\n"],"file":"index.js"}
|
|
@@ -1,41 +1,65 @@
|
|
|
1
1
|
@value breakpoints: "../../../variables/breakpoints.css";
|
|
2
2
|
@value mobile from breakpoints;
|
|
3
3
|
@value colors: "../../../variables/colors.css";
|
|
4
|
-
@value
|
|
5
|
-
@value
|
|
4
|
+
@value box_shadow_light_dark from colors;
|
|
5
|
+
@value cm_blue_900 from colors;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
.freeText {
|
|
9
|
+
border: unset;
|
|
10
|
+
border-width: 0;
|
|
8
11
|
font-family: "Gilroy";
|
|
9
12
|
font-weight: 700;
|
|
10
13
|
text-transform: none;
|
|
11
|
-
padding: 0 15px;
|
|
12
|
-
border: solid 1px;
|
|
13
|
-
border-color: color(black lightness(85%));
|
|
14
14
|
height: 50px;
|
|
15
|
-
border-radius:
|
|
15
|
+
border-radius: 8px;
|
|
16
16
|
font-size: 14px;
|
|
17
|
-
width:
|
|
17
|
+
max-width: calc(100% - 24px);
|
|
18
|
+
width: 100%;
|
|
18
19
|
outline: none;
|
|
20
|
+
padding-left: 12px;
|
|
21
|
+
padding-right: 12px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.freeText::placeholder {
|
|
25
|
+
color: color(cm_blue_900 a(0.3));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.freeText:-ms-input-placeholder {
|
|
29
|
+
color: color(cm_blue_900 a(0.3))!important;
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
.
|
|
22
|
-
|
|
32
|
+
.freeText:focus {
|
|
33
|
+
outline: none;
|
|
23
34
|
}
|
|
24
35
|
|
|
25
|
-
.
|
|
36
|
+
.freeText:hover {
|
|
26
37
|
outline: none;
|
|
27
38
|
}
|
|
28
39
|
|
|
40
|
+
.wrapper {
|
|
41
|
+
border-radius: 8px;
|
|
42
|
+
box-shadow: 0px 4px 16px box_shadow_light_dark;
|
|
43
|
+
margin: 0 15px;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
width: 230px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.wrapper:hover {
|
|
49
|
+
box-shadow: none;
|
|
50
|
+
overflow: visible;
|
|
51
|
+
}
|
|
52
|
+
|
|
29
53
|
@media mobile {
|
|
30
54
|
.wrapper {
|
|
31
|
-
width:
|
|
55
|
+
max-width: calc(100% - 30px);
|
|
56
|
+
width: auto;
|
|
32
57
|
box-sizing: border-box;
|
|
33
|
-
max-width: 100%;
|
|
34
58
|
}
|
|
35
59
|
|
|
36
|
-
.
|
|
60
|
+
.freeText {
|
|
61
|
+
min-width: fit-content;
|
|
37
62
|
width: 100%;
|
|
38
|
-
margin: 0;
|
|
39
63
|
box-sizing: border-box;
|
|
40
64
|
}
|
|
41
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/default.js"],"names":["props","placeholder","
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/default.js"],"names":["props","placeholder","value","undefined"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,WAAW,EAAE,uBADR;AAELC,IAAAA,KAAK,EAAEC;AAFF;AADM,CAAf","sourcesContent":["export default {\n props: {\n placeholder: 'Type your answer here',\n value: undefined\n }\n};\n"],"file":"default.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/with-value-on-change.js"],"names":["props","placeholder","value","onChange"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,WAAW,EAAE,uBADR;AAELC,IAAAA,KAAK,EAAE,OAFF;AAGLC,IAAAA,QAAQ,EAAE,MAAM,CAAE,CAHb;AAIL,kBAAc;AAJT;AADM,CAAf","sourcesContent":["export default {\n props: {\n placeholder: 'Type your answer here',\n value: 'plop!',\n onChange: () => {},\n 'aria-label': 'aria input'\n }\n};\n"],"file":"with-value-on-change.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/with-value.js"],"names":["props","placeholder","value"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,WAAW,EAAE,uBADR;AAELC,IAAAA,KAAK,EAAE;AAFF;AADM,CAAf","sourcesContent":["export default {\n props: {\n placeholder: 'Type your answer here',\n value: 'plop!'\n }\n};\n"],"file":"with-value.js"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import _identity from "lodash/fp/identity";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
|
|
5
|
+
import browserEnv from 'browser-env';
|
|
6
|
+
import test from 'ava';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { shallow, mount, configure } from 'enzyme';
|
|
9
|
+
import Adapter from 'enzyme-adapter-react-16';
|
|
10
|
+
import FreeText from '..';
|
|
11
|
+
import defaultFixture from './fixtures/default';
|
|
12
|
+
import withValueFixture from './fixtures/with-value';
|
|
13
|
+
import withValueOnChangeFixture from './fixtures/with-value-on-change';
|
|
14
|
+
browserEnv();
|
|
15
|
+
configure({
|
|
16
|
+
adapter: new Adapter()
|
|
17
|
+
});
|
|
18
|
+
const translate = _identity;
|
|
19
|
+
test('onInput should be reachable and replace onChange, onChange should not trigger value changes, should use aria-label', t => {
|
|
20
|
+
t.plan(7);
|
|
21
|
+
let onInputWasTriggered = false;
|
|
22
|
+
|
|
23
|
+
const props = _extends(_extends({}, withValueOnChangeFixture.props), {}, {
|
|
24
|
+
onChange: value => {
|
|
25
|
+
onInputWasTriggered = true;
|
|
26
|
+
t.is(value, 'new value');
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(FreeText, props), {
|
|
31
|
+
context: {
|
|
32
|
+
translate
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
let freeText = wrapper.find('[data-name="free-text-input"]');
|
|
36
|
+
t.true(freeText.at(0).exists());
|
|
37
|
+
t.is(freeText.at(0).props()['aria-label'], 'aria input');
|
|
38
|
+
t.is(freeText.at(0).props().value, 'plop!'); // should not trigger a value change with onChange
|
|
39
|
+
|
|
40
|
+
freeText.at(0).simulate('change', {
|
|
41
|
+
target: {
|
|
42
|
+
value: 'new value'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
wrapper.update(); // should not update the trigger flag with onChange
|
|
46
|
+
|
|
47
|
+
t.false(onInputWasTriggered);
|
|
48
|
+
freeText.at(0).simulate('input', {
|
|
49
|
+
target: {
|
|
50
|
+
value: 'new value'
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
wrapper.update();
|
|
54
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
55
|
+
t.true(onInputWasTriggered);
|
|
56
|
+
t.pass();
|
|
57
|
+
});
|
|
58
|
+
test('should set: boxShadow (hover & not hovered variants) && color for the input if a value is provided', t => {
|
|
59
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(FreeText, withValueFixture.props));
|
|
60
|
+
let freeTextWrapper = wrapper.find('[data-name="freeText"]');
|
|
61
|
+
t.true(freeTextWrapper.at(0).exists());
|
|
62
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
63
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'
|
|
64
|
+
});
|
|
65
|
+
let freeText = wrapper.find('[data-name="free-text-input"]');
|
|
66
|
+
t.true(freeText.at(0).exists());
|
|
67
|
+
t.is(freeText.at(0).props().value, 'plop!');
|
|
68
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
69
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'
|
|
70
|
+
});
|
|
71
|
+
freeTextWrapper.simulate('mouseover');
|
|
72
|
+
wrapper.update();
|
|
73
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
74
|
+
freeTextWrapper = wrapper.find('[data-name="freeText"]'); // hovered
|
|
75
|
+
|
|
76
|
+
t.deepEqual(freeText.at(0).props().style, {
|
|
77
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.2)',
|
|
78
|
+
color: '#00B0FF'
|
|
79
|
+
});
|
|
80
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
81
|
+
boxShadow: 'none'
|
|
82
|
+
});
|
|
83
|
+
freeTextWrapper.simulate('mouseleave');
|
|
84
|
+
wrapper.update();
|
|
85
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
86
|
+
t.deepEqual(freeText.at(0).props().style, {
|
|
87
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)',
|
|
88
|
+
color: '#00B0FF'
|
|
89
|
+
});
|
|
90
|
+
t.pass();
|
|
91
|
+
});
|
|
92
|
+
test('should use value as default aria-label if no aria-label is provided', t => {
|
|
93
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(FreeText, withValueFixture.props));
|
|
94
|
+
const freeText = wrapper.find('[data-name="free-text-input"]');
|
|
95
|
+
t.true(freeText.at(0).exists());
|
|
96
|
+
t.is(freeText.at(0).props()['aria-label'], 'plop!');
|
|
97
|
+
t.pass();
|
|
98
|
+
});
|
|
99
|
+
test('should use placeholder as default aria-label if no aria-label is provided and no value is present', t => {
|
|
100
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(FreeText, defaultFixture.props));
|
|
101
|
+
const freeText = wrapper.find('[data-name="free-text-input"]');
|
|
102
|
+
t.true(freeText.at(0).exists());
|
|
103
|
+
t.is(freeText.at(0).props()['aria-label'], 'Type your answer here');
|
|
104
|
+
t.pass();
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=free-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/molecule/questions/free-text/test/free-text.js"],"names":["browserEnv","test","React","shallow","mount","configure","Adapter","FreeText","defaultFixture","withValueFixture","withValueOnChangeFixture","adapter","translate","t","plan","onInputWasTriggered","props","onChange","value","is","wrapper","context","freeText","find","true","at","exists","simulate","target","update","false","pass","freeTextWrapper","deepEqual","style","boxShadow","color"],"mappings":";;;;AAAA,OAAOA,UAAP,MAAuB,aAAvB;AACA,OAAOC,IAAP,MAA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CA9B,IAAI,CAAC,qEAAD,EAAwEY,CAAC,IAAI;AAC/E,QAAMO,OAAO,GAAGhB,KAAK,eAAC,oBAAC,QAAD,EAAcK,gBAAgB,CAACO,KAA/B,CAAD,CAArB;AACA,QAAMM,QAAQ,GAAGF,OAAO,CAACG,IAAR,CAAa,+BAAb,CAAjB;AACAV,EAAAA,CAAC,CAACW,IAAF,CAAOF,QAAQ,CAACG,EAAT,CAAY,CAAZ,EAAeC,MAAf,EAAP;AACAb,EAAAA,CAAC,CAACM,EAAF,CAAKG,QAAQ,CAACG,EAAT,CAAY,CAAZ,EAAeT,KAAf,GAAuB,YAAvB,CAAL,EAA2C,OAA3C;AACAH,EAAAA,CAAC,CAACkB,IAAF;AACD,CANG,CAAJ;AAQA9B,IAAI,CAAC,mGAAD,EAAsGY,CAAC,IAAI;AAC7G,QAAMO,OAAO,GAAGhB,KAAK,eAAC,oBAAC,QAAD,EAAcI,cAAc,CAACQ,KAA7B,CAAD,CAArB;AACA,QAAMM,QAAQ,GAAGF,OAAO,CAACG,IAAR,CAAa,+BAAb,CAAjB;AACAV,EAAAA,CAAC,CAACW,IAAF,CAAOF,QAAQ,CAACG,EAAT,CAAY,CAAZ,EAAeC,MAAf,EAAP;AACAb,EAAAA,CAAC,CAACM,EAAF,CAAKG,QAAQ,CAACG,EAAT,CAAY,CAAZ,EAAeT,KAAf,GAAuB,YAAvB,CAAL,EAA2C,uBAA3C;AACAH,EAAAA,CAAC,CAACkB,IAAF;AACD,CANG,CAAJ","sourcesContent":["import browserEnv from 'browser-env';\nimport test from 'ava';\nimport React from 'react';\nimport {shallow, mount, configure} from 'enzyme';\nimport {identity} from 'lodash/fp';\nimport Adapter from 'enzyme-adapter-react-16';\nimport FreeText from '..';\nimport defaultFixture from './fixtures/default';\nimport withValueFixture from './fixtures/with-value';\nimport withValueOnChangeFixture from './fixtures/with-value-on-change';\n\nbrowserEnv();\nconfigure({adapter: new Adapter()});\nconst translate = identity;\n\ntest('onInput should be reachable and replace onChange, onChange should not trigger value changes, should use aria-label', t => {\n t.plan(7);\n let onInputWasTriggered = false;\n const props = {\n ...withValueOnChangeFixture.props,\n onChange: value => {\n onInputWasTriggered = true;\n t.is(value, 'new value');\n }\n };\n const wrapper = shallow(<FreeText {...props} />, {\n context: {translate}\n });\n let freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(freeText.at(0).exists());\n t.is(freeText.at(0).props()['aria-label'], 'aria input');\n t.is(freeText.at(0).props().value, 'plop!');\n // should not trigger a value change with onChange\n freeText.at(0).simulate('change', {target: {value: 'new value'}});\n wrapper.update();\n // should not update the trigger flag with onChange\n t.false(onInputWasTriggered);\n freeText.at(0).simulate('input', {target: {value: 'new value'}});\n wrapper.update();\n freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(onInputWasTriggered);\n t.pass();\n});\n\ntest('should set: boxShadow (hover & not hovered variants) && color for the input if a value is provided', t => {\n const wrapper = mount(<FreeText {...withValueFixture.props} />);\n let freeTextWrapper = wrapper.find('[data-name=\"freeText\"]');\n t.true(freeTextWrapper.at(0).exists());\n t.deepEqual(freeTextWrapper.at(0).props().style, {\n boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'\n });\n\n let freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(freeText.at(0).exists());\n t.is(freeText.at(0).props().value, 'plop!');\n t.deepEqual(freeTextWrapper.at(0).props().style, {\n boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'\n });\n freeTextWrapper.simulate('mouseover');\n wrapper.update();\n\n freeText = wrapper.find('[data-name=\"free-text-input\"]');\n freeTextWrapper = wrapper.find('[data-name=\"freeText\"]');\n // hovered\n t.deepEqual(freeText.at(0).props().style, {\n boxShadow: '0 4px 16px rgba(0, 176, 255, 0.2)',\n color: '#00B0FF'\n });\n t.deepEqual(freeTextWrapper.at(0).props().style, {\n boxShadow: 'none'\n });\n\n freeTextWrapper.simulate('mouseleave');\n wrapper.update();\n freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.deepEqual(freeText.at(0).props().style, {\n boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)',\n color: '#00B0FF'\n });\n\n t.pass();\n});\n\ntest('should use value as default aria-label if no aria-label is provided', t => {\n const wrapper = mount(<FreeText {...withValueFixture.props} />);\n const freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(freeText.at(0).exists());\n t.is(freeText.at(0).props()['aria-label'], 'plop!');\n t.pass();\n});\n\ntest('should use placeholder as default aria-label if no aria-label is provided and no value is present', t => {\n const wrapper = mount(<FreeText {...defaultFixture.props} />);\n const freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(freeText.at(0).exists());\n t.is(freeText.at(0).props()['aria-label'], 'Type your answer here');\n t.pass();\n});\n"],"file":"free-text.js"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _getOr from "lodash/fp/getOr";
|
|
1
2
|
import _orderBy from "lodash/fp/orderBy";
|
|
2
3
|
import _filter from "lodash/fp/filter";
|
|
3
4
|
import _pipe from "lodash/fp/pipe";
|
|
@@ -6,6 +7,7 @@ import PropTypes from 'prop-types';
|
|
|
6
7
|
import classnames from 'classnames';
|
|
7
8
|
import Provider from '../../../atom/provider';
|
|
8
9
|
import { innerHTML } from '../../../atom/label/style.css';
|
|
10
|
+
import { getShadowBoxColorFromPrimary } from '../../../util/get-shadow-box-color-from-primary';
|
|
9
11
|
import style from './style.css';
|
|
10
12
|
const AnswersPropTypes = process.env.NODE_ENV !== "production" ? PropTypes.arrayOf(PropTypes.shape({
|
|
11
13
|
onClick: PropTypes.func,
|
|
@@ -38,7 +40,7 @@ const Choices = ({
|
|
|
38
40
|
selected
|
|
39
41
|
} = answer;
|
|
40
42
|
return /*#__PURE__*/React.createElement("div", {
|
|
41
|
-
className: classnames(selected ? style.invisibleAnswer : style.
|
|
43
|
+
className: classnames(selected ? style.invisibleAnswer : style.unselected, innerHTML),
|
|
42
44
|
"data-name": "answer",
|
|
43
45
|
onClick: onClick,
|
|
44
46
|
key: key // eslint-disable-next-line react/no-danger
|
|
@@ -49,7 +51,7 @@ const Choices = ({
|
|
|
49
51
|
});
|
|
50
52
|
});
|
|
51
53
|
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
-
className: style.
|
|
54
|
+
className: style.choices
|
|
53
55
|
}, answersViews);
|
|
54
56
|
};
|
|
55
57
|
|
|
@@ -57,9 +59,10 @@ Choices.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
57
59
|
answers: AnswersPropTypes
|
|
58
60
|
} : {};
|
|
59
61
|
|
|
60
|
-
const
|
|
62
|
+
const SelectedAnswerSections = ({
|
|
61
63
|
answers,
|
|
62
|
-
help
|
|
64
|
+
help,
|
|
65
|
+
backgroundColor
|
|
63
66
|
}) => {
|
|
64
67
|
const selectedAnswers = _pipe(_filter('selected'), _orderBy('order', 'asc'))(answers);
|
|
65
68
|
|
|
@@ -69,15 +72,31 @@ const SelectionBox = ({
|
|
|
69
72
|
title
|
|
70
73
|
} = answer;
|
|
71
74
|
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
-
className: classnames(style.selectedAnswer, innerHTML),
|
|
73
75
|
"data-selected": "true",
|
|
74
76
|
onClick: onClick,
|
|
75
|
-
key: key
|
|
77
|
+
key: key,
|
|
78
|
+
"data-name": "selectedAnswer",
|
|
79
|
+
className: style.selected,
|
|
80
|
+
style: {
|
|
81
|
+
boxShadow: `0px 4px 16px ${getShadowBoxColorFromPrimary(backgroundColor)}`
|
|
82
|
+
}
|
|
83
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
"data-name": "answerBackground",
|
|
85
|
+
style: {
|
|
86
|
+
backgroundColor
|
|
87
|
+
},
|
|
88
|
+
className: style.background
|
|
89
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: style.content
|
|
91
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
92
|
+
"data-name": "answerContent",
|
|
93
|
+
className: classnames(style.selectedAnswerText, innerHTML),
|
|
94
|
+
title: title // eslint-disable-next-line react/no-danger
|
|
76
95
|
,
|
|
77
96
|
dangerouslySetInnerHTML: {
|
|
78
97
|
__html: title
|
|
79
98
|
}
|
|
80
|
-
});
|
|
99
|
+
})));
|
|
81
100
|
});
|
|
82
101
|
|
|
83
102
|
if (selectedAnswersViews.length > 0) {
|
|
@@ -93,29 +112,42 @@ const SelectionBox = ({
|
|
|
93
112
|
}
|
|
94
113
|
};
|
|
95
114
|
|
|
96
|
-
|
|
115
|
+
SelectedAnswerSections.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
97
116
|
answers: AnswersPropTypes,
|
|
98
|
-
help: EmptyView.propTypes.help
|
|
117
|
+
help: EmptyView.propTypes.help,
|
|
118
|
+
backgroundColor: PropTypes.string
|
|
99
119
|
} : {};
|
|
100
120
|
|
|
101
121
|
const QcmDrag = ({
|
|
102
122
|
answers,
|
|
103
123
|
help
|
|
104
|
-
}, context) =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
}, context) => {
|
|
125
|
+
const {
|
|
126
|
+
skin
|
|
127
|
+
} = context;
|
|
128
|
+
|
|
129
|
+
const primarySkinColor = _getOr('#00B0FF', 'common.primary', skin);
|
|
130
|
+
|
|
131
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
className: style.wrapper
|
|
133
|
+
}, /*#__PURE__*/React.createElement(SelectedAnswerSections, {
|
|
134
|
+
answers: answers,
|
|
135
|
+
help: help,
|
|
136
|
+
backgroundColor: primarySkinColor
|
|
137
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
138
|
+
"data-name": "qcm-drag-answers",
|
|
139
|
+
className: style.answers
|
|
140
|
+
}, /*#__PURE__*/React.createElement(Choices, {
|
|
141
|
+
answers: answers
|
|
142
|
+
})));
|
|
143
|
+
};
|
|
115
144
|
|
|
116
145
|
QcmDrag.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
117
146
|
answers: AnswersPropTypes,
|
|
118
|
-
help:
|
|
147
|
+
help: SelectedAnswerSections.propTypes.help
|
|
119
148
|
} : {};
|
|
149
|
+
QcmDrag.contextTypes = {
|
|
150
|
+
skin: Provider.childContextTypes.skin
|
|
151
|
+
};
|
|
120
152
|
export default QcmDrag;
|
|
121
153
|
//# sourceMappingURL=index.js.map
|