@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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _ava = _interopRequireDefault(require("ava"));
|
|
4
|
+
|
|
5
|
+
var _forEach = _interopRequireDefault(require("lodash/forEach"));
|
|
6
|
+
|
|
7
|
+
var _renderComponent = _interopRequireDefault(require("../../../test/helpers/render-component"));
|
|
8
|
+
|
|
9
|
+
var _ = _interopRequireDefault(require(".."));
|
|
10
|
+
|
|
11
|
+
var _default = _interopRequireDefault(require("./fixtures/default"));
|
|
12
|
+
|
|
13
|
+
var _loading = _interopRequireDefault(require("./fixtures/loading"));
|
|
14
|
+
|
|
15
|
+
var _videoTranslate = _interopRequireDefault(require("./fixtures/video-translate"));
|
|
16
|
+
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
|
|
19
|
+
(0, _ava.default)('Molecule › MoleculeCockpitPopin > should have valid propTypes', t => {
|
|
20
|
+
t.pass();
|
|
21
|
+
(0, _forEach.default)(_.default.propTypes, (value, key) => {
|
|
22
|
+
t.not(value, undefined, `PropType for "Molecule.MoleculeCockpitPopin.propTypes.${key}" may not be undefined. Did you mistype the propTypes definition?`);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
(0, _ava.default)('Molecule › MoleculeCockpitPopin › Default › should be rendered', _renderComponent.default, _.default, _default.default);
|
|
26
|
+
(0, _ava.default)('Molecule › MoleculeCockpitPopin › Loading › should be rendered', _renderComponent.default, _.default, _loading.default);
|
|
27
|
+
(0, _ava.default)('Molecule › MoleculeCockpitPopin › VideoTranslate › should be rendered', _renderComponent.default, _.default, _videoTranslate.default);
|
|
28
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/cockpit-popin/test/fixtures.js"],"names":["t","pass","MoleculeCockpitPopin","propTypes","value","key","not","undefined","renderComponentMacro","fixtureDefault","fixtureLoading","fixtureVideoTranslate"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,kBAAK,+DAAL,EAAsEA,CAAC,IAAI;AACzEA,EAAAA,CAAC,CAACC,IAAF;AACA,wBAAQC,UAAqBC,SAA7B,EAAwC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACtDL,IAAAA,CAAC,CAACM,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,yDAAwDF,GAAI,mEAArF;AACD,GAFD;AAGD,CALD;AAOA,kBAAK,gEAAL,EAAuEG,wBAAvE,EAA6FN,SAA7F,EAAmHO,gBAAnH;AACA,kBAAK,gEAAL,EAAuED,wBAAvE,EAA6FN,SAA7F,EAAmHQ,gBAAnH;AACA,kBAAK,uEAAL,EAA8EF,wBAA9E,EAAoGN,SAApG,EAA0HS,uBAA1H","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"}
|
|
@@ -19,8 +19,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
22
|
-
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); }
|
|
23
|
-
|
|
24
22
|
const DropDown = props => {
|
|
25
23
|
const {
|
|
26
24
|
options,
|
|
@@ -41,9 +39,7 @@ const DropDown = props => {
|
|
|
41
39
|
|
|
42
40
|
DropDown.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
43
41
|
onChange: _select.default.propTypes.onChange,
|
|
44
|
-
options: _propTypes.default.arrayOf(_propTypes.default.shape(
|
|
45
|
-
validOption: _propTypes.default.bool
|
|
46
|
-
}))),
|
|
42
|
+
options: _propTypes.default.arrayOf(_propTypes.default.shape(_select.SelectOptionPropTypes)),
|
|
47
43
|
theme: _select.default.propTypes.theme
|
|
48
44
|
} : {};
|
|
49
45
|
var _default = DropDown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/questions/drop-down/index.js"],"names":["DropDown","props","options","onChange","theme","propsTheme","currentSelection","defaultTheme","validOption","style","wrapper","propTypes","Select","PropTypes","arrayOf","shape","SelectOptionPropTypes"
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/questions/drop-down/index.js"],"names":["DropDown","props","options","onChange","theme","propsTheme","currentSelection","defaultTheme","validOption","style","wrapper","propTypes","Select","PropTypes","arrayOf","shape","SelectOptionPropTypes"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;;;AAEA,MAAMA,QAAQ,GAAGC,KAAK,IAAI;AACxB,QAAM;AAACC,IAAAA,OAAD;AAAUC,IAAAA,QAAV;AAAoBC,IAAAA,KAAK,EAAEC;AAA3B,MAAyCJ,KAA/C;AAEA,QAAMK,gBAAgB,GAAG,oBAAK,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,EAAEE,eAAMC;AAAtB,kBACE,6BAAC,eAAD;AAAQ,IAAA,KAAK,EAAEN,KAAf;AAAsB,IAAA,OAAO,EAAEF,OAA/B;AAAwC,IAAA,QAAQ,EAAEC;AAAlD,IADF,CADF;AAKD,CAdD;;AAgBAH,QAAQ,CAACW,SAAT,2CAAqB;AACnBR,EAAAA,QAAQ,EAAES,gBAAOD,SAAP,CAAiBR,QADR;AAEnBD,EAAAA,OAAO,EAAEW,mBAAUC,OAAV,CAAkBD,mBAAUE,KAAV,CAAgBC,6BAAhB,CAAlB,CAFU;AAGnBZ,EAAAA,KAAK,EAAEQ,gBAAOD,SAAP,CAAiBP;AAHL,CAArB;eAMeJ,Q","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"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
|
|
7
7
|
|
|
8
8
|
var _noop2 = _interopRequireDefault(require("lodash/fp/noop"));
|
|
9
9
|
|
|
@@ -11,6 +11,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
|
|
14
|
+
var _cssColorFunction = require("css-color-function");
|
|
15
|
+
|
|
14
16
|
var _provider = _interopRequireDefault(require("../../../atom/provider"));
|
|
15
17
|
|
|
16
18
|
var _style = _interopRequireDefault(require("./style.css"));
|
|
@@ -21,30 +23,45 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
const FreeText = (props, context) => {
|
|
27
29
|
const {
|
|
28
30
|
placeholder = '',
|
|
29
31
|
value = '',
|
|
30
|
-
onChange = _noop2.default
|
|
32
|
+
onChange = _noop2.default,
|
|
33
|
+
'aria-label': ariaLabel
|
|
31
34
|
} = props;
|
|
32
|
-
const
|
|
33
|
-
const
|
|
35
|
+
const [hovered, setHovered] = (0, _react.useState)(false);
|
|
36
|
+
const handleChange = (0, _react.useCallback)(e => onChange(e.target.value), [onChange]);
|
|
37
|
+
const primarySkinColor = (0, _getOr2.default)('#00B0FF', 'skin.common.primary', context);
|
|
38
|
+
const handleMouseOver = (0, _react.useCallback)(() => setHovered(true), [setHovered]);
|
|
39
|
+
const handleMouseLeave = (0, _react.useCallback)(() => setHovered(false), [setHovered]);
|
|
40
|
+
const shadowBoxPrimaryColor = (0, _react.useMemo)(() => (0, _cssColorFunction.convert)(`color(${primarySkinColor} a(12%))`), [primarySkinColor]);
|
|
34
41
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
35
42
|
"data-name": "freeText",
|
|
36
|
-
className: _style.default.wrapper
|
|
43
|
+
className: _style.default.wrapper,
|
|
44
|
+
onMouseOver: handleMouseOver,
|
|
45
|
+
onMouseLeave: handleMouseLeave,
|
|
46
|
+
style: _extends({}, value && {
|
|
47
|
+
boxShadow: hovered ? 'none' : `0 4px 16px ${shadowBoxPrimaryColor}`
|
|
48
|
+
})
|
|
37
49
|
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
50
|
+
"data-name": "free-text-input",
|
|
38
51
|
type: "text",
|
|
39
|
-
|
|
52
|
+
"aria-label": ariaLabel || value || placeholder,
|
|
53
|
+
className: _style.default.freeText,
|
|
40
54
|
placeholder: placeholder,
|
|
41
55
|
value: value,
|
|
42
56
|
onInput: handleChange,
|
|
43
57
|
onChange: _noop2.default,
|
|
44
|
-
style: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
style: _extends(_extends({
|
|
59
|
+
boxShadow: `0 4px 16px ${shadowBoxPrimaryColor}`
|
|
60
|
+
}, value && {
|
|
61
|
+
boxShadow: `0 4px 16px ${hovered ? (0, _cssColorFunction.convert)(`color(${primarySkinColor} a(20%))`) : shadowBoxPrimaryColor}`
|
|
62
|
+
}), {}, {
|
|
63
|
+
color: primarySkinColor
|
|
64
|
+
})
|
|
48
65
|
}));
|
|
49
66
|
};
|
|
50
67
|
|
|
@@ -54,7 +71,8 @@ FreeText.contextTypes = {
|
|
|
54
71
|
FreeText.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
55
72
|
placeholder: _propTypes.default.string,
|
|
56
73
|
value: _propTypes.default.string,
|
|
57
|
-
onChange: _propTypes.default.func
|
|
74
|
+
onChange: _propTypes.default.func,
|
|
75
|
+
'aria-label': _propTypes.default.string
|
|
58
76
|
} : {};
|
|
59
77
|
var _default = FreeText;
|
|
60
78
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/questions/free-text/index.js"],"names":["FreeText","props","
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/questions/free-text/index.js"],"names":["FreeText","props","context","placeholder","value","onChange","ariaLabel","hovered","setHovered","handleChange","e","target","primarySkinColor","handleMouseOver","handleMouseLeave","shadowBoxPrimaryColor","style","wrapper","boxShadow","freeText","color","contextTypes","skin","Provider","childContextTypes","propTypes","PropTypes","string","func"],"mappings":";;;;;;;;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;AAKE,IAAA,WAAW,EAAEhB,WALf;AAME,IAAA,KAAK,EAAEC,KANT;AAOE,IAAA,OAAO,EAAEK,YAPX;AAQE,IAAA,QAAQ,gBARV;AASE,IAAA,KAAK;AACHS,MAAAA,SAAS,EAAG,cAAaH,qBAAsB;AAD5C,OAECX,KAAK,IAAI;AACXc,MAAAA,SAAS,EAAG,cACVX,OAAO,GAAG,+BAAS,SAAQK,gBAAiB,UAAlC,CAAH,GAAkDG,qBAC1D;AAHU,KAFV;AAOHK,MAAAA,KAAK,EAAER;AAPJ;AATP,IAXF,CADF;AAiCD,CAhDD;;AAkDAZ,QAAQ,CAACqB,YAAT,GAAwB;AACtBC,EAAAA,IAAI,EAAEC,kBAASC,iBAAT,CAA2BF;AADX,CAAxB;AAIAtB,QAAQ,CAACyB,SAAT,2CAAqB;AACnBtB,EAAAA,WAAW,EAAEuB,mBAAUC,MADJ;AAEnBvB,EAAAA,KAAK,EAAEsB,mBAAUC,MAFE;AAGnBtB,EAAAA,QAAQ,EAAEqB,mBAAUE,IAHD;AAInB,gBAAcF,mBAAUC;AAJL,CAArB;eAOe3B,Q","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":";;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,WAAW,EAAE,uBADR;AAELC,IAAAA,KAAK,EAAEC;AAFF;AADM,C","sourcesContent":["export default {\n props: {\n placeholder: 'Type your answer here',\n value: undefined\n }\n};\n"],"file":"default.js"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _default = {
|
|
6
|
+
props: {
|
|
7
|
+
placeholder: 'Type your answer here',
|
|
8
|
+
value: 'plop!',
|
|
9
|
+
onChange: () => {},
|
|
10
|
+
'aria-label': 'aria input'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.default = _default;
|
|
14
|
+
//# sourceMappingURL=with-value-on-change.js.map
|
|
@@ -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":";;;;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,C","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"}
|
package/lib/molecule/questions/free-text/test/fixtures/{with-default-value.js → with-value.js}
RENAMED
|
@@ -5,8 +5,8 @@ exports.default = void 0;
|
|
|
5
5
|
var _default = {
|
|
6
6
|
props: {
|
|
7
7
|
placeholder: 'Type your answer here',
|
|
8
|
-
|
|
8
|
+
value: 'plop!'
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
exports.default = _default;
|
|
12
|
-
//# sourceMappingURL=with-
|
|
12
|
+
//# sourceMappingURL=with-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/with-value.js"],"names":["props","placeholder","value"],"mappings":";;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,WAAW,EAAE,uBADR;AAELC,IAAAA,KAAK,EAAE;AAFF;AADM,C","sourcesContent":["export default {\n props: {\n placeholder: 'Type your answer here',\n value: 'plop!'\n }\n};\n"],"file":"with-value.js"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _identity2 = _interopRequireDefault(require("lodash/fp/identity"));
|
|
4
|
+
|
|
5
|
+
var _browserEnv = _interopRequireDefault(require("browser-env"));
|
|
6
|
+
|
|
7
|
+
var _ava = _interopRequireDefault(require("ava"));
|
|
8
|
+
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
|
|
11
|
+
var _enzyme = require("enzyme");
|
|
12
|
+
|
|
13
|
+
var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));
|
|
14
|
+
|
|
15
|
+
var _ = _interopRequireDefault(require(".."));
|
|
16
|
+
|
|
17
|
+
var _default = _interopRequireDefault(require("./fixtures/default"));
|
|
18
|
+
|
|
19
|
+
var _withValue = _interopRequireDefault(require("./fixtures/with-value"));
|
|
20
|
+
|
|
21
|
+
var _withValueOnChange = _interopRequireDefault(require("./fixtures/with-value-on-change"));
|
|
22
|
+
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
|
|
25
|
+
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); }
|
|
26
|
+
|
|
27
|
+
(0, _browserEnv.default)();
|
|
28
|
+
(0, _enzyme.configure)({
|
|
29
|
+
adapter: new _enzymeAdapterReact.default()
|
|
30
|
+
});
|
|
31
|
+
const translate = _identity2.default;
|
|
32
|
+
(0, _ava.default)('onInput should be reachable and replace onChange, onChange should not trigger value changes, should use aria-label', t => {
|
|
33
|
+
t.plan(7);
|
|
34
|
+
let onInputWasTriggered = false;
|
|
35
|
+
|
|
36
|
+
const props = _extends(_extends({}, _withValueOnChange.default.props), {}, {
|
|
37
|
+
onChange: value => {
|
|
38
|
+
onInputWasTriggered = true;
|
|
39
|
+
t.is(value, 'new value');
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_.default, props), {
|
|
44
|
+
context: {
|
|
45
|
+
translate
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
let freeText = wrapper.find('[data-name="free-text-input"]');
|
|
49
|
+
t.true(freeText.at(0).exists());
|
|
50
|
+
t.is(freeText.at(0).props()['aria-label'], 'aria input');
|
|
51
|
+
t.is(freeText.at(0).props().value, 'plop!'); // should not trigger a value change with onChange
|
|
52
|
+
|
|
53
|
+
freeText.at(0).simulate('change', {
|
|
54
|
+
target: {
|
|
55
|
+
value: 'new value'
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
wrapper.update(); // should not update the trigger flag with onChange
|
|
59
|
+
|
|
60
|
+
t.false(onInputWasTriggered);
|
|
61
|
+
freeText.at(0).simulate('input', {
|
|
62
|
+
target: {
|
|
63
|
+
value: 'new value'
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
wrapper.update();
|
|
67
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
68
|
+
t.true(onInputWasTriggered);
|
|
69
|
+
t.pass();
|
|
70
|
+
});
|
|
71
|
+
(0, _ava.default)('should set: boxShadow (hover & not hovered variants) && color for the input if a value is provided', t => {
|
|
72
|
+
const wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_.default, _withValue.default.props));
|
|
73
|
+
let freeTextWrapper = wrapper.find('[data-name="freeText"]');
|
|
74
|
+
t.true(freeTextWrapper.at(0).exists());
|
|
75
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
76
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'
|
|
77
|
+
});
|
|
78
|
+
let freeText = wrapper.find('[data-name="free-text-input"]');
|
|
79
|
+
t.true(freeText.at(0).exists());
|
|
80
|
+
t.is(freeText.at(0).props().value, 'plop!');
|
|
81
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
82
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'
|
|
83
|
+
});
|
|
84
|
+
freeTextWrapper.simulate('mouseover');
|
|
85
|
+
wrapper.update();
|
|
86
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
87
|
+
freeTextWrapper = wrapper.find('[data-name="freeText"]'); // hovered
|
|
88
|
+
|
|
89
|
+
t.deepEqual(freeText.at(0).props().style, {
|
|
90
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.2)',
|
|
91
|
+
color: '#00B0FF'
|
|
92
|
+
});
|
|
93
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
94
|
+
boxShadow: 'none'
|
|
95
|
+
});
|
|
96
|
+
freeTextWrapper.simulate('mouseleave');
|
|
97
|
+
wrapper.update();
|
|
98
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
99
|
+
t.deepEqual(freeText.at(0).props().style, {
|
|
100
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)',
|
|
101
|
+
color: '#00B0FF'
|
|
102
|
+
});
|
|
103
|
+
t.pass();
|
|
104
|
+
});
|
|
105
|
+
(0, _ava.default)('should use value as default aria-label if no aria-label is provided', t => {
|
|
106
|
+
const wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_.default, _withValue.default.props));
|
|
107
|
+
const freeText = wrapper.find('[data-name="free-text-input"]');
|
|
108
|
+
t.true(freeText.at(0).exists());
|
|
109
|
+
t.is(freeText.at(0).props()['aria-label'], 'plop!');
|
|
110
|
+
t.pass();
|
|
111
|
+
});
|
|
112
|
+
(0, _ava.default)('should use placeholder as default aria-label if no aria-label is provided and no value is present', t => {
|
|
113
|
+
const wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_.default, _default.default.props));
|
|
114
|
+
const freeText = wrapper.find('[data-name="free-text-input"]');
|
|
115
|
+
t.true(freeText.at(0).exists());
|
|
116
|
+
t.is(freeText.at(0).props()['aria-label'], 'Type your answer here');
|
|
117
|
+
t.pass();
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=free-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/molecule/questions/free-text/test/free-text.js"],"names":["adapter","Adapter","translate","t","plan","onInputWasTriggered","props","withValueOnChangeFixture","onChange","value","is","wrapper","context","freeText","find","true","at","exists","simulate","target","update","false","pass","withValueFixture","freeTextWrapper","deepEqual","style","boxShadow","color","defaultFixture"],"mappings":";;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA;AACA,uBAAU;AAACA,EAAAA,OAAO,EAAE,IAAIC,2BAAJ;AAAV,CAAV;AACA,MAAMC,SAAS,qBAAf;AAEA,kBAAK,oHAAL,EAA2HC,CAAC,IAAI;AAC9HA,EAAAA,CAAC,CAACC,IAAF,CAAO,CAAP;AACA,MAAIC,mBAAmB,GAAG,KAA1B;;AACA,QAAMC,KAAK,yBACNC,2BAAyBD,KADnB;AAETE,IAAAA,QAAQ,EAAEC,KAAK,IAAI;AACjBJ,MAAAA,mBAAmB,GAAG,IAAtB;AACAF,MAAAA,CAAC,CAACO,EAAF,CAAKD,KAAL,EAAY,WAAZ;AACD;AALQ,IAAX;;AAOA,QAAME,OAAO,GAAG,mCAAQ,6BAAC,SAAD,EAAcL,KAAd,CAAR,EAAiC;AAC/CM,IAAAA,OAAO,EAAE;AAACV,MAAAA;AAAD;AADsC,G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AAF;AACD,CAND","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"}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
|
|
6
|
+
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
|
|
7
|
+
|
|
6
8
|
var _orderBy2 = _interopRequireDefault(require("lodash/fp/orderBy"));
|
|
7
9
|
|
|
8
10
|
var _filter2 = _interopRequireDefault(require("lodash/fp/filter"));
|
|
@@ -19,6 +21,8 @@ var _provider = _interopRequireDefault(require("../../../atom/provider"));
|
|
|
19
21
|
|
|
20
22
|
var _style = require("../../../atom/label/style.css");
|
|
21
23
|
|
|
24
|
+
var _getShadowBoxColorFromPrimary = require("../../../util/get-shadow-box-color-from-primary");
|
|
25
|
+
|
|
22
26
|
var _style2 = _interopRequireDefault(require("./style.css"));
|
|
23
27
|
|
|
24
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -54,7 +58,7 @@ const Choices = ({
|
|
|
54
58
|
selected
|
|
55
59
|
} = answer;
|
|
56
60
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
57
|
-
className: (0, _classnames.default)(selected ? _style2.default.invisibleAnswer : _style2.default.
|
|
61
|
+
className: (0, _classnames.default)(selected ? _style2.default.invisibleAnswer : _style2.default.unselected, _style.innerHTML),
|
|
58
62
|
"data-name": "answer",
|
|
59
63
|
onClick: onClick,
|
|
60
64
|
key: key // eslint-disable-next-line react/no-danger
|
|
@@ -65,7 +69,7 @@ const Choices = ({
|
|
|
65
69
|
});
|
|
66
70
|
});
|
|
67
71
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
68
|
-
className: _style2.default.
|
|
72
|
+
className: _style2.default.choices
|
|
69
73
|
}, answersViews);
|
|
70
74
|
};
|
|
71
75
|
|
|
@@ -73,9 +77,10 @@ Choices.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
73
77
|
answers: AnswersPropTypes
|
|
74
78
|
} : {};
|
|
75
79
|
|
|
76
|
-
const
|
|
80
|
+
const SelectedAnswerSections = ({
|
|
77
81
|
answers,
|
|
78
|
-
help
|
|
82
|
+
help,
|
|
83
|
+
backgroundColor
|
|
79
84
|
}) => {
|
|
80
85
|
const selectedAnswers = (0, _pipe2.default)((0, _filter2.default)('selected'), (0, _orderBy2.default)('order', 'asc'))(answers);
|
|
81
86
|
const selectedAnswersViews = selectedAnswers.map((answer, key) => {
|
|
@@ -84,15 +89,31 @@ const SelectionBox = ({
|
|
|
84
89
|
title
|
|
85
90
|
} = answer;
|
|
86
91
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
87
|
-
className: (0, _classnames.default)(_style2.default.selectedAnswer, _style.innerHTML),
|
|
88
92
|
"data-selected": "true",
|
|
89
93
|
onClick: onClick,
|
|
90
|
-
key: key
|
|
94
|
+
key: key,
|
|
95
|
+
"data-name": "selectedAnswer",
|
|
96
|
+
className: _style2.default.selected,
|
|
97
|
+
style: {
|
|
98
|
+
boxShadow: `0px 4px 16px ${(0, _getShadowBoxColorFromPrimary.getShadowBoxColorFromPrimary)(backgroundColor)}`
|
|
99
|
+
}
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
101
|
+
"data-name": "answerBackground",
|
|
102
|
+
style: {
|
|
103
|
+
backgroundColor
|
|
104
|
+
},
|
|
105
|
+
className: _style2.default.background
|
|
106
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
107
|
+
className: _style2.default.content
|
|
108
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
109
|
+
"data-name": "answerContent",
|
|
110
|
+
className: (0, _classnames.default)(_style2.default.selectedAnswerText, _style.innerHTML),
|
|
111
|
+
title: title // eslint-disable-next-line react/no-danger
|
|
91
112
|
,
|
|
92
113
|
dangerouslySetInnerHTML: {
|
|
93
114
|
__html: title
|
|
94
115
|
}
|
|
95
|
-
});
|
|
116
|
+
})));
|
|
96
117
|
});
|
|
97
118
|
|
|
98
119
|
if (selectedAnswersViews.length > 0) {
|
|
@@ -108,30 +129,41 @@ const SelectionBox = ({
|
|
|
108
129
|
}
|
|
109
130
|
};
|
|
110
131
|
|
|
111
|
-
|
|
132
|
+
SelectedAnswerSections.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
112
133
|
answers: AnswersPropTypes,
|
|
113
|
-
help: EmptyView.propTypes.help
|
|
134
|
+
help: EmptyView.propTypes.help,
|
|
135
|
+
backgroundColor: _propTypes.default.string
|
|
114
136
|
} : {};
|
|
115
137
|
|
|
116
138
|
const QcmDrag = ({
|
|
117
139
|
answers,
|
|
118
140
|
help
|
|
119
|
-
}, context) =>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
141
|
+
}, context) => {
|
|
142
|
+
const {
|
|
143
|
+
skin
|
|
144
|
+
} = context;
|
|
145
|
+
const primarySkinColor = (0, _getOr2.default)('#00B0FF', 'common.primary', skin);
|
|
146
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
147
|
+
className: _style2.default.wrapper
|
|
148
|
+
}, /*#__PURE__*/_react.default.createElement(SelectedAnswerSections, {
|
|
149
|
+
answers: answers,
|
|
150
|
+
help: help,
|
|
151
|
+
backgroundColor: primarySkinColor
|
|
152
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
153
|
+
"data-name": "qcm-drag-answers",
|
|
154
|
+
className: _style2.default.answers
|
|
155
|
+
}, /*#__PURE__*/_react.default.createElement(Choices, {
|
|
156
|
+
answers: answers
|
|
157
|
+
})));
|
|
158
|
+
};
|
|
130
159
|
|
|
131
160
|
QcmDrag.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
132
161
|
answers: AnswersPropTypes,
|
|
133
|
-
help:
|
|
162
|
+
help: SelectedAnswerSections.propTypes.help
|
|
134
163
|
} : {};
|
|
164
|
+
QcmDrag.contextTypes = {
|
|
165
|
+
skin: _provider.default.childContextTypes.skin
|
|
166
|
+
};
|
|
135
167
|
var _default = QcmDrag;
|
|
136
168
|
exports.default = _default;
|
|
137
169
|
//# sourceMappingURL=index.js.map
|