@coorpacademy/components 10.5.7-alpha.6.5 → 10.5.7-alpha.8
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/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/fixtures.js +2 -0
- package/es/atom/select/test/fixtures.js.map +1 -1
- package/es/atom/select/test/select.js +49 -0
- package/es/atom/select/test/select.js.map +1 -0
- package/es/molecule/course-sections/test/fixtures.js +15 -0
- package/es/molecule/course-sections/test/fixtures.js.map +1 -0
- package/es/molecule/draggable-list/test/fixtures.js +15 -0
- package/es/molecule/draggable-list/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/fixtures.js +4 -2
- package/es/molecule/questions/free-text/test/fixtures.js.map +1 -1
- 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 +73 -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 -0
- 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/template/index.js +13 -10
- package/es/molecule/questions/template/index.js.map +1 -1
- package/es/molecule/wizard-summary/test/fixtures.js +2 -0
- package/es/molecule/wizard-summary/test/fixtures.js.map +1 -1
- package/es/organism/wizard-contents/test/fixtures.js +2 -0
- package/es/organism/wizard-contents/test/fixtures.js.map +1 -1
- package/es/template/back-office/brand-update/test/fixtures.js +2 -0
- package/es/template/back-office/brand-update/test/fixtures.js.map +1 -1
- 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/fixtures.js +3 -0
- package/lib/atom/select/test/fixtures.js.map +1 -1
- package/lib/atom/select/test/select.js +62 -0
- package/lib/atom/select/test/select.js.map +1 -0
- package/lib/molecule/course-sections/test/fixtures.js +25 -0
- package/lib/molecule/course-sections/test/fixtures.js.map +1 -0
- package/lib/molecule/draggable-list/test/fixtures.js +25 -0
- package/lib/molecule/draggable-list/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/fixtures.js +5 -2
- package/lib/molecule/questions/free-text/test/fixtures.js.map +1 -1
- 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 +73 -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 -0
- 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/template/index.js +13 -10
- package/lib/molecule/questions/template/index.js.map +1 -1
- package/lib/molecule/wizard-summary/test/fixtures.js +3 -0
- package/lib/molecule/wizard-summary/test/fixtures.js.map +1 -1
- package/lib/organism/wizard-contents/test/fixtures.js +3 -0
- package/lib/organism/wizard-contents/test/fixtures.js.map +1 -1
- package/lib/template/back-office/brand-update/test/fixtures.js +3 -0
- package/lib/template/back-office/brand-update/test/fixtures.js.map +1 -1
- package/package.json +2 -2
- package/es/molecule/cockpit-popin/test/fixtures.js +0 -17
- package/es/molecule/cockpit-popin/test/fixtures.js.map +0 -1
- package/es/molecule/questions/free-text/test/fixtures/with-default-value.js.map +0 -1
- package/es/molecule/search/test/fixtures.js +0 -15
- package/es/molecule/search/test/fixtures.js.map +0 -1
- package/lib/molecule/cockpit-popin/test/fixtures.js +0 -28
- package/lib/molecule/cockpit-popin/test/fixtures.js.map +0 -1
- package/lib/molecule/questions/free-text/test/fixtures/with-default-value.js.map +0 -1
- package/lib/molecule/search/test/fixtures.js +0 -25
- package/lib/molecule/search/test/fixtures.js.map +0 -1
package/es/atom/select/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import _size from "lodash/fp/size";
|
|
2
|
+
import _includes from "lodash/fp/includes";
|
|
1
3
|
import _filter from "lodash/fp/filter";
|
|
4
|
+
import _getOr from "lodash/fp/getOr";
|
|
2
5
|
import _get from "lodash/fp/get";
|
|
3
6
|
import _map from "lodash/fp/map";
|
|
4
7
|
import _keys from "lodash/fp/keys";
|
|
5
8
|
import _find from "lodash/fp/find";
|
|
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
|
+
|
|
6
12
|
import React, { useMemo } from 'react';
|
|
7
13
|
import PropTypes from 'prop-types';
|
|
8
14
|
import classnames from 'classnames';
|
|
@@ -18,7 +24,9 @@ const themeStyle = {
|
|
|
18
24
|
question: style.question,
|
|
19
25
|
sort: style.sort,
|
|
20
26
|
thematiques: style.thematiques,
|
|
21
|
-
|
|
27
|
+
player: style.player,
|
|
28
|
+
template: style.template // we keep template in case it is used anywhere else?
|
|
29
|
+
|
|
22
30
|
};
|
|
23
31
|
|
|
24
32
|
const Select = (props, context) => {
|
|
@@ -40,52 +48,61 @@ const Select = (props, context) => {
|
|
|
40
48
|
const {
|
|
41
49
|
skin
|
|
42
50
|
} = context;
|
|
43
|
-
const title = propTitle ? `${propTitle}${required ? '*' : ''}` : null;
|
|
51
|
+
const title = useMemo(() => propTitle ? `${propTitle}${required ? '*' : ''}` : null, [propTitle, required]);
|
|
44
52
|
const optionList = options && options.map((option, index) => {
|
|
45
53
|
return /*#__PURE__*/React.createElement("option", {
|
|
46
54
|
key: index,
|
|
47
|
-
value: option.value
|
|
55
|
+
value: option.value,
|
|
56
|
+
className: style.selectOption
|
|
48
57
|
}, option.name);
|
|
49
58
|
});
|
|
50
59
|
const titleView = title ? /*#__PURE__*/React.createElement("span", {
|
|
51
60
|
className: style.title
|
|
52
61
|
}, title, " ") : null;
|
|
53
|
-
const selected = multiple ? _map(_get('value'), _filter({
|
|
62
|
+
const selected = useMemo(() => multiple ? _map(_get('value'), _filter({
|
|
54
63
|
selected: true
|
|
55
64
|
}, options)) : _get('value', _find({
|
|
56
65
|
selected: true
|
|
57
|
-
}, options));
|
|
58
|
-
const selectedLabel = multiple ? _map(_get('name'), _filter({
|
|
66
|
+
}, options)), [multiple, options]);
|
|
67
|
+
const selectedLabel = useMemo(() => multiple ? _map(_get('name'), _filter({
|
|
59
68
|
selected: true
|
|
60
69
|
}, options)) : _get('name', _find({
|
|
61
70
|
selected: true
|
|
62
|
-
}, options));
|
|
71
|
+
}, options)), [multiple, options]);
|
|
72
|
+
const isSelectedInValidOption = useMemo(() => theme === 'player' && _getOr(false, 'name', _find({
|
|
73
|
+
validOption: false,
|
|
74
|
+
selected: true
|
|
75
|
+
}, options)), [options, theme]);
|
|
63
76
|
const handleChange = useMemo(() => multiple ? e => {
|
|
64
77
|
onChange(_map(_get('value'), e.target.selectedOptions));
|
|
65
78
|
} : e => {
|
|
66
79
|
onChange(e.target.value);
|
|
67
80
|
}, [onChange, multiple]);
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const color = _get('common.primary', skin);
|
|
72
|
-
|
|
73
|
-
const skinColor = {
|
|
74
|
-
color: selected && (theme === 'question' || theme === 'template') ? color : null
|
|
75
|
-
};
|
|
81
|
+
const black = useMemo(() => _getOr('#14171A', 'common.black', skin), [skin]);
|
|
82
|
+
const color = useMemo(() => _getOr('#00B0FF', 'common.primary', skin), [skin]);
|
|
83
|
+
const shouldUseSkinFontColor = useMemo(() => !isSelectedInValidOption && selected && _includes(theme, ['question', 'template', 'player']), [isSelectedInValidOption, selected, theme]);
|
|
76
84
|
const arrowView = !multiple ? /*#__PURE__*/React.createElement(ArrowDown, {
|
|
77
85
|
color: selected && (theme === 'question' || theme === 'template') ? color : black,
|
|
78
86
|
className: style.arrow
|
|
79
87
|
}) : null;
|
|
80
|
-
const behaviourClassName = getClassState(style.default, style.modified, style.error, modified, error);
|
|
81
|
-
const composedClassName = classnames(theme ? themeStyle[theme] : behaviourClassName, selected ? style.selected : style.unselected, className);
|
|
88
|
+
const behaviourClassName = useMemo(() => getClassState(style.default, style.modified, style.error, modified, error), [error, modified]);
|
|
89
|
+
const composedClassName = useMemo(() => classnames(theme ? themeStyle[theme] : behaviourClassName, selected ? style.selected : style.unselected, className), [behaviourClassName, className, selected, theme]);
|
|
90
|
+
const labelSize = useMemo(() => _size(selectedLabel), [selectedLabel]);
|
|
91
|
+
const isLongLabel = useMemo(() => labelSize >= 65, [labelSize]);
|
|
82
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
83
93
|
className: composedClassName
|
|
84
94
|
}, /*#__PURE__*/React.createElement("label", {
|
|
85
|
-
|
|
95
|
+
"data-name": "select-wrapper",
|
|
96
|
+
style: _extends({}, shouldUseSkinFontColor && {
|
|
97
|
+
color
|
|
98
|
+
}),
|
|
99
|
+
className: style.selectWrapper
|
|
86
100
|
}, titleView, /*#__PURE__*/React.createElement("span", {
|
|
87
|
-
|
|
101
|
+
"data-name": "select-span",
|
|
102
|
+
className: classnames(style.selectSpan, _includes(theme, ['player', 'invalid', 'question', 'thematiques', 'template']) ? style.noLabelCommon : null, borderClassName, isLongLabel ? style.longLabel : null)
|
|
88
103
|
}, selectedLabel), arrowView, /*#__PURE__*/React.createElement("select", {
|
|
104
|
+
"data-name": "native-select",
|
|
105
|
+
className: style.selectBox,
|
|
89
106
|
title: selectedLabel,
|
|
90
107
|
name: name,
|
|
91
108
|
onChange: handleChange,
|
|
@@ -100,7 +117,8 @@ const Select = (props, context) => {
|
|
|
100
117
|
export const SelectOptionPropTypes = {
|
|
101
118
|
name: PropTypes.string.isRequired,
|
|
102
119
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
103
|
-
selected: PropTypes.bool
|
|
120
|
+
selected: PropTypes.bool,
|
|
121
|
+
validOption: PropTypes.bool
|
|
104
122
|
};
|
|
105
123
|
Select.contextTypes = {
|
|
106
124
|
skin: Provider.childContextTypes.skin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/atom/select/index.js"],"names":["React","useMemo","PropTypes","classnames","NovaCompositionNavigationArrowDown","ArrowDown","Provider","getClassState","style","themeStyle","filter","invalid","header","mooc","question","sort","thematiques","template","Select","props","context","name","options","className","borderClassName","onChange","multiple","disabled","required","description","theme","modified","error","title","propTitle","skin","optionList","map","option","index","value","titleView","selected","selectedLabel","handleChange","e","target","selectedOptions","black","color","skinColor","arrowView","arrow","behaviourClassName","default","composedClassName","unselected","label","SelectOptionPropTypes","string","isRequired","oneOfType","number","bool","contextTypes","childContextTypes","propTypes","func","oneOf","arrayOf","shape"],"mappings":";;;;;AAAA,OAAOA,KAAP,IAAeC,OAAf,QAA6B,OAA7B;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,SAAQC,kCAAkC,IAAIC,SAA9C,QAA8D,0BAA9D;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,KAAP,MAAkB,aAAlB;AAEA,MAAMC,UAAU,GAAG;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CAAC2D,SAAV,CAAoB,CAAC3D,SAAS,CAACyD,MAAX,EAAmBzD,SAAS,CAAC4D,MAA7B,CAApB,CAF4B;AAGnCpB,EAAAA,QAAQ,EAAExC,SAAS,CAAC6D;AAHe,CAA9B;AAMP7C,MAAM,CAAC8C,YAAP,GAAsB;AACpB7B,EAAAA,IAAI,EAAE7B,QAAQ,CAAC2D,iBAAT,CAA2B9B;AADb,CAAtB;AAIAjB,MAAM,CAACgD,SAAP,2CAAmB;AACjBjC,EAAAA,KAAK,EAAE/B,SAAS,CAACyD,MADA;AAEjBtC,EAAAA,IAAI,EAAEnB,SAAS,CAACyD,MAFC;AAGjBpC,EAAAA,SAAS,EAAErB,SAAS,CAACyD,MAHJ;AAIjBnC,EAAAA,eAAe,EAAEtB,SAAS,CAACyD,MAJV;AAKjBhC,EAAAA,QAAQ,EAAEzB,SAAS,CAAC6D,IALH;AAMjBrC,EAAAA,QAAQ,EAAExB,SAAS,CAAC6D,IANH;AAOjBlC,EAAAA,WAAW,EAAE3B,SAAS,CAACyD,MAPN;AAQjB/B,EAAAA,QAAQ,EAAE1B,SAAS,CAAC6D,IARH;AASjBtC,EAAAA,QAAQ,EAAEvB,SAAS,CAACiE,IATH;AAUjBrC,EAAAA,KAAK,EAAE5B,SAAS,CAACkE,KAAV,CAAgB,MAAK3D,UAAL,CAAhB,CAVU;AAWjBa,EAAAA,OAAO,EAAEpB,SAAS,CAACmE,OAAV,CAAkBnE,SAAS,CAACoE,KAAV,CAAgBZ,qBAAhB,CAAlB,CAXQ;AAYjB3B,EAAAA,QAAQ,EAAE7B,SAAS,CAAC6D,IAZH;AAajB/B,EAAAA,KAAK,EAAE9B,SAAS,CAAC6D;AAbA,CAAnB;AAgBA,eAAe7C,MAAf","sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport {find, keys, map, get, filter} from 'lodash/fp';\nimport {NovaCompositionNavigationArrowDown as ArrowDown} from '@coorpacademy/nova-icons';\nimport Provider from '../provider';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst themeStyle = {\n filter: style.filter,\n invalid: style.invalid,\n header: style.header,\n mooc: style.mooc,\n question: style.question,\n sort: style.sort,\n thematiques: style.thematiques,\n template: style.template\n};\n\nconst Select = (props, context) => {\n const {\n name,\n options = [],\n className,\n borderClassName,\n onChange,\n multiple = false,\n disabled,\n required,\n description,\n theme,\n modified = false,\n error = false,\n title: propTitle\n } = props;\n\n const {skin} = context;\n\n const title = propTitle ? `${propTitle}${required ? '*' : ''}` : null;\n\n const optionList =\n options &&\n options.map((option, index) => {\n return (\n <option key={index} value={option.value}>\n {option.name}\n </option>\n );\n });\n\n const titleView = title ? <span className={style.title}>{title} </span> : null;\n\n const selected = multiple\n ? map(get('value'), filter({selected: true}, options))\n : get('value', find({selected: true}, options));\n const selectedLabel = multiple\n ? map(get('name'), filter({selected: true}, options))\n : get('name', find({selected: true}, options));\n\n const handleChange = useMemo(\n () =>\n multiple\n ? e => {\n onChange(map(get('value'), e.target.selectedOptions));\n }\n : e => {\n onChange(e.target.value);\n },\n [onChange, multiple]\n );\n\n const black = get('common.black', skin);\n const color = get('common.primary', skin);\n const skinColor = {\n color: selected && (theme === 'question' || theme === 'template') ? color : null\n };\n\n const arrowView = !multiple ? (\n <ArrowDown\n color={selected && (theme === 'question' || theme === 'template') ? color : black}\n className={style.arrow}\n />\n ) : null;\n const behaviourClassName = getClassState(\n style.default,\n style.modified,\n style.error,\n modified,\n error\n );\n const composedClassName = classnames(\n theme ? themeStyle[theme] : behaviourClassName,\n selected ? style.selected : style.unselected,\n className\n );\n\n return (\n <div className={composedClassName}>\n <label style={skinColor}>\n {titleView}\n <span className={classnames(style.label, borderClassName)}>{selectedLabel}</span>\n {arrowView}\n <select\n title={selectedLabel}\n name={name}\n onChange={handleChange}\n value={selected}\n multiple={multiple}\n disabled={disabled}\n >\n {optionList}\n </select>\n </label>\n <div className={style.description}>{description}</div>\n </div>\n );\n};\n\nexport const SelectOptionPropTypes = {\n name: PropTypes.string.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n selected: PropTypes.bool\n};\n\nSelect.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nSelect.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n className: PropTypes.string,\n borderClassName: PropTypes.string,\n disabled: PropTypes.bool,\n multiple: PropTypes.bool,\n description: PropTypes.string,\n required: PropTypes.bool,\n onChange: PropTypes.func,\n theme: PropTypes.oneOf(keys(themeStyle)),\n options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),\n modified: PropTypes.bool,\n error: PropTypes.bool\n};\n\nexport default Select;\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/atom/select/index.js"],"names":["React","useMemo","PropTypes","classnames","NovaCompositionNavigationArrowDown","ArrowDown","Provider","getClassState","style","themeStyle","filter","invalid","header","mooc","question","sort","thematiques","player","template","Select","props","context","name","options","className","borderClassName","onChange","multiple","disabled","required","description","theme","modified","error","title","propTitle","skin","optionList","map","option","index","value","selectOption","titleView","selected","selectedLabel","isSelectedInValidOption","validOption","handleChange","e","target","selectedOptions","black","color","shouldUseSkinFontColor","arrowView","arrow","behaviourClassName","default","composedClassName","unselected","labelSize","isLongLabel","selectWrapper","selectSpan","noLabelCommon","longLabel","selectBox","SelectOptionPropTypes","string","isRequired","oneOfType","number","bool","contextTypes","childContextTypes","propTypes","func","oneOf","arrayOf","shape"],"mappings":";;;;;;;;;;;AAAA,OAAOA,KAAP,IAAeC,OAAf,QAA6B,OAA7B;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,SAAQC,kCAAkC,IAAIC,SAA9C,QAA8D,0BAA9D;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,KAAP,MAAkB,aAAlB;AAEA,MAAMC,UAAU,GAAG;AACjBC,EAA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7E,SAAS,CAAC8E,KAAV,CAAgBZ,qBAAhB,CAAlB,CAXQ;AAYjBpC,EAAAA,QAAQ,EAAE9B,SAAS,CAACuE,IAZH;AAajBxC,EAAAA,KAAK,EAAE/B,SAAS,CAACuE;AAbA,CAAnB;AAgBA,eAAetD,MAAf","sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport {find, keys, map, get, getOr, filter, includes, size} from 'lodash/fp';\nimport {NovaCompositionNavigationArrowDown as ArrowDown} from '@coorpacademy/nova-icons';\nimport Provider from '../provider';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst themeStyle = {\n filter: style.filter,\n invalid: style.invalid,\n header: style.header,\n mooc: style.mooc,\n question: style.question,\n sort: style.sort,\n thematiques: style.thematiques,\n player: style.player,\n template: style.template // we keep template in case it is used anywhere else?\n};\n\nconst Select = (props, context) => {\n const {\n name,\n options = [],\n className,\n borderClassName,\n onChange,\n multiple = false,\n disabled,\n required,\n description,\n theme,\n modified = false,\n error = false,\n title: propTitle\n } = props;\n\n const {skin} = context;\n\n const title = useMemo(() => (propTitle ? `${propTitle}${required ? '*' : ''}` : null), [\n propTitle,\n required\n ]);\n\n const optionList =\n options &&\n options.map((option, index) => {\n return (\n <option key={index} value={option.value} className={style.selectOption}>\n {option.name}\n </option>\n );\n });\n\n const titleView = title ? <span className={style.title}>{title} </span> : null;\n\n const selected = useMemo(\n () =>\n multiple\n ? map(get('value'), filter({selected: true}, options))\n : get('value', find({selected: true}, options)),\n [multiple, options]\n );\n const selectedLabel = useMemo(\n () =>\n multiple\n ? map(get('name'), filter({selected: true}, options))\n : get('name', find({selected: true}, options)),\n [multiple, options]\n );\n\n const isSelectedInValidOption = useMemo(\n () =>\n theme === 'player' &&\n getOr(false, 'name', find({validOption: false, selected: true}, options)),\n [options, theme]\n );\n\n const handleChange = useMemo(\n () =>\n multiple\n ? e => {\n onChange(map(get('value'), e.target.selectedOptions));\n }\n : e => {\n onChange(e.target.value);\n },\n [onChange, multiple]\n );\n\n const black = useMemo(() => getOr('#14171A', 'common.black', skin), [skin]);\n const color = useMemo(() => getOr('#00B0FF', 'common.primary', skin), [skin]);\n const shouldUseSkinFontColor = useMemo(\n () =>\n !isSelectedInValidOption && selected && includes(theme, ['question', 'template', 'player']),\n [isSelectedInValidOption, selected, theme]\n );\n\n const arrowView = !multiple ? (\n <ArrowDown\n color={selected && (theme === 'question' || theme === 'template') ? color : black}\n className={style.arrow}\n />\n ) : null;\n const behaviourClassName = useMemo(\n () => getClassState(style.default, style.modified, style.error, modified, error),\n [error, modified]\n );\n const composedClassName = useMemo(\n () =>\n classnames(\n theme ? themeStyle[theme] : behaviourClassName,\n selected ? style.selected : style.unselected,\n className\n ),\n [behaviourClassName, className, selected, theme]\n );\n\n const labelSize = useMemo(() => size(selectedLabel), [selectedLabel]);\n\n const isLongLabel = useMemo(() => labelSize >= 65, [labelSize]);\n\n return (\n <div className={composedClassName}>\n <label\n data-name=\"select-wrapper\"\n style={{\n ...(shouldUseSkinFontColor && {\n color\n })\n }}\n className={style.selectWrapper}\n >\n {titleView}\n <span\n data-name=\"select-span\"\n className={classnames(\n style.selectSpan,\n includes(theme, ['player', 'invalid', 'question', 'thematiques', 'template'])\n ? style.noLabelCommon\n : null,\n borderClassName,\n isLongLabel ? style.longLabel : null\n )}\n >\n {selectedLabel}\n </span>\n {arrowView}\n <select\n data-name=\"native-select\"\n className={style.selectBox}\n title={selectedLabel}\n name={name}\n onChange={handleChange}\n value={selected}\n multiple={multiple}\n disabled={disabled}\n >\n {optionList}\n </select>\n </label>\n <div className={style.description}>{description}</div>\n </div>\n );\n};\n\nexport const SelectOptionPropTypes = {\n name: PropTypes.string.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n selected: PropTypes.bool,\n validOption: PropTypes.bool\n};\n\nSelect.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nSelect.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n className: PropTypes.string,\n borderClassName: PropTypes.string,\n disabled: PropTypes.bool,\n multiple: PropTypes.bool,\n description: PropTypes.string,\n required: PropTypes.bool,\n onChange: PropTypes.func,\n theme: PropTypes.oneOf(keys(themeStyle)),\n options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),\n modified: PropTypes.bool,\n error: PropTypes.bool\n};\n\nexport default Select;\n"],"file":"index.js"}
|
package/es/atom/select/style.css
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
@value white from colors;
|
|
11
11
|
@value xtraLightGrey from colors;
|
|
12
12
|
@value transparent from colors;
|
|
13
|
+
@value box_shadow_light_dark from colors;
|
|
14
|
+
@value cm_blue_900 from colors;
|
|
13
15
|
|
|
14
16
|
.default {
|
|
15
17
|
display: flex;
|
|
@@ -23,7 +25,11 @@
|
|
|
23
25
|
composes: default;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
.
|
|
28
|
+
.selectWrapper {
|
|
29
|
+
position: relative;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.default .selectWrapper {
|
|
27
33
|
display: flex;
|
|
28
34
|
align-items: center;
|
|
29
35
|
height: 50px;
|
|
@@ -41,20 +47,16 @@
|
|
|
41
47
|
width: 180px;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
.
|
|
50
|
+
.selectSpan {
|
|
45
51
|
display: none;
|
|
46
|
-
position:
|
|
52
|
+
position: relative;
|
|
53
|
+
z-index: 10;
|
|
47
54
|
white-space: nowrap;
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
left: 0;
|
|
50
|
-
right: 0;
|
|
51
|
-
bottom: 0;
|
|
52
55
|
pointer-events: none;
|
|
53
|
-
text-overflow: ellipsis;
|
|
54
56
|
height: 18px;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
.default
|
|
59
|
+
.default .selectBox {
|
|
58
60
|
font-family: "Gilroy";
|
|
59
61
|
text-transform: none;
|
|
60
62
|
padding: 0 15px;
|
|
@@ -68,6 +70,21 @@
|
|
|
68
70
|
outline: none;
|
|
69
71
|
appearance: none;
|
|
70
72
|
cursor: pointer;
|
|
73
|
+
position: absolute;
|
|
74
|
+
left: 0;
|
|
75
|
+
right: 0;
|
|
76
|
+
bottom: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.selectOption,
|
|
80
|
+
.no-label .selectWrapper{
|
|
81
|
+
min-width: min-content;
|
|
82
|
+
height: min-content;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.player .selectWrapper {
|
|
86
|
+
min-width: min-content;
|
|
87
|
+
height: min-content;
|
|
71
88
|
}
|
|
72
89
|
|
|
73
90
|
.modified select {
|
|
@@ -112,6 +129,7 @@
|
|
|
112
129
|
pointer-events: none;
|
|
113
130
|
width: 12px;
|
|
114
131
|
height: 12px;
|
|
132
|
+
z-index: 11;
|
|
115
133
|
}
|
|
116
134
|
|
|
117
135
|
@media mobile {
|
|
@@ -121,7 +139,7 @@
|
|
|
121
139
|
}
|
|
122
140
|
}
|
|
123
141
|
|
|
124
|
-
.default
|
|
142
|
+
.default .selectBox[multiple] {
|
|
125
143
|
padding: 0;
|
|
126
144
|
height: 80px;
|
|
127
145
|
}
|
|
@@ -130,7 +148,7 @@
|
|
|
130
148
|
Filter
|
|
131
149
|
*/
|
|
132
150
|
|
|
133
|
-
.filter
|
|
151
|
+
.filter .selectWrapper {
|
|
134
152
|
display: flex;
|
|
135
153
|
align-items: center;
|
|
136
154
|
position: relative;
|
|
@@ -140,7 +158,7 @@
|
|
|
140
158
|
margin: 0;
|
|
141
159
|
}
|
|
142
160
|
|
|
143
|
-
.filter .
|
|
161
|
+
.filter .selectSpan {
|
|
144
162
|
display: block;
|
|
145
163
|
padding: 15px 30px 15px 15px;
|
|
146
164
|
font-size: 12px;
|
|
@@ -157,7 +175,9 @@
|
|
|
157
175
|
margin-bottom: 10px;
|
|
158
176
|
}
|
|
159
177
|
|
|
160
|
-
.filter
|
|
178
|
+
.filter .selectBox {
|
|
179
|
+
position: absolute;
|
|
180
|
+
top: 27px;
|
|
161
181
|
display: block;
|
|
162
182
|
width: 100%;
|
|
163
183
|
height: 50px;
|
|
@@ -186,57 +206,112 @@
|
|
|
186
206
|
position: relative;
|
|
187
207
|
}
|
|
188
208
|
|
|
189
|
-
.no-label
|
|
209
|
+
.no-label .selectWrapper {
|
|
190
210
|
display: flex;
|
|
191
211
|
align-items: center;
|
|
192
|
-
height:
|
|
212
|
+
min-height: 54px;
|
|
193
213
|
position: relative;
|
|
194
214
|
flex-grow: 0;
|
|
195
215
|
}
|
|
196
216
|
|
|
197
|
-
.
|
|
217
|
+
.noLabelCommon {
|
|
198
218
|
display: block;
|
|
199
219
|
padding: 0 30px 0 10px;
|
|
200
220
|
font-size: 14px;
|
|
221
|
+
height: 54px;
|
|
222
|
+
line-height: 52px;
|
|
223
|
+
box-sizing: border-box;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
div.default label.selectWrapper span.longLabel {
|
|
227
|
+
min-width: 230px;
|
|
228
|
+
max-width: 280px;
|
|
229
|
+
white-space: pre-wrap;
|
|
230
|
+
line-height: 22px;
|
|
231
|
+
padding-top: 15px;
|
|
232
|
+
padding-bottom: 15px;
|
|
233
|
+
height: auto;
|
|
234
|
+
border: none;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
div:not(.player) .noLabelCommon.selectSpan {
|
|
201
238
|
border: 1px solid light;
|
|
202
239
|
background: white;
|
|
203
240
|
border-radius: 2px;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
241
|
+
min-width: min-content;
|
|
242
|
+
width: 100%;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
div.player .noLabelCommon.selectSpan {
|
|
246
|
+
box-shadow: 0px 4px 16px box_shadow_light_dark;
|
|
247
|
+
border-radius: 8px;
|
|
248
|
+
min-width: min-content;
|
|
249
|
+
width: 100%;
|
|
207
250
|
white-space: nowrap;
|
|
208
|
-
text-overflow: ellipsis;
|
|
209
251
|
}
|
|
210
252
|
|
|
211
|
-
.no-label
|
|
253
|
+
.no-label .selectBox {
|
|
212
254
|
font-family: "Gilroy";
|
|
213
255
|
text-transform: none;
|
|
214
256
|
padding: 0 15px;
|
|
215
|
-
height:
|
|
257
|
+
height: 54px;
|
|
216
258
|
border-radius: 2px;
|
|
217
|
-
font-size:
|
|
259
|
+
font-size: 14px;
|
|
218
260
|
color: black;
|
|
219
261
|
font-weight: normal;
|
|
220
262
|
margin-left: 0;
|
|
221
263
|
width: 230px;
|
|
264
|
+
max-width: 280px;
|
|
222
265
|
cursor: pointer;
|
|
223
266
|
background: white;
|
|
224
267
|
border: 2px solid xtraLightGrey;
|
|
225
268
|
}
|
|
226
269
|
|
|
227
270
|
@media mobile {
|
|
228
|
-
.
|
|
229
|
-
|
|
230
|
-
|
|
271
|
+
div.player .selectBox {
|
|
272
|
+
min-width: 0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.no-label .selectBox {
|
|
231
276
|
margin-left: 0;
|
|
232
277
|
border-radius: 0;
|
|
278
|
+
position: absolute;
|
|
279
|
+
left: 0;
|
|
280
|
+
right: 0;
|
|
281
|
+
bottom: 0;
|
|
233
282
|
}
|
|
234
283
|
|
|
235
|
-
.no-label
|
|
284
|
+
.no-label .selectWrapper {
|
|
236
285
|
display: block;
|
|
237
286
|
margin-right: 0;
|
|
238
287
|
width: 100%;
|
|
239
|
-
height: 44px;
|
|
288
|
+
min-height: 44px;
|
|
289
|
+
height: min-content;
|
|
290
|
+
min-width: 250px;
|
|
291
|
+
max-width: 280px;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.player .noLabelCommon {
|
|
295
|
+
height: min-content;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
div.player .noLabelCommon.selectSpan {
|
|
299
|
+
min-width: 250px;
|
|
300
|
+
max-width: 280px;
|
|
301
|
+
white-space: pre-wrap;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.noLabelCommon.longLabel {
|
|
305
|
+
line-height: 22px;
|
|
306
|
+
height: 100%;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.player.default .selectBox {
|
|
310
|
+
position: absolute;
|
|
311
|
+
top: 0px;
|
|
312
|
+
left: 0px;
|
|
313
|
+
width: 100%;
|
|
314
|
+
height: 100%;
|
|
240
315
|
}
|
|
241
316
|
}
|
|
242
317
|
|
|
@@ -248,12 +323,16 @@
|
|
|
248
323
|
composes: no-label;
|
|
249
324
|
}
|
|
250
325
|
|
|
251
|
-
.invalid
|
|
326
|
+
.invalid .player {
|
|
327
|
+
color: cm_blue_900;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.invalid .selectWrapper {
|
|
252
331
|
height: 54px;
|
|
253
332
|
color: black;
|
|
254
333
|
}
|
|
255
334
|
|
|
256
|
-
.invalid .
|
|
335
|
+
.invalid .selectSpan {
|
|
257
336
|
font-size: 15px;
|
|
258
337
|
font-weight: 700;
|
|
259
338
|
border: 2px solid;
|
|
@@ -271,10 +350,11 @@
|
|
|
271
350
|
width: 150px;
|
|
272
351
|
}
|
|
273
352
|
|
|
274
|
-
.mooc
|
|
353
|
+
.mooc .selectWrapper {
|
|
275
354
|
margin: 0;
|
|
276
355
|
height: 35px;
|
|
277
356
|
border: 0;
|
|
357
|
+
width: inherit;
|
|
278
358
|
}
|
|
279
359
|
|
|
280
360
|
.mooc select {
|
|
@@ -307,11 +387,11 @@
|
|
|
307
387
|
composes: no-label;
|
|
308
388
|
}
|
|
309
389
|
|
|
310
|
-
.question
|
|
390
|
+
.question .selectWrapper {
|
|
311
391
|
height: 54px;
|
|
312
392
|
}
|
|
313
393
|
|
|
314
|
-
.question .
|
|
394
|
+
.question .selectSpan {
|
|
315
395
|
font-size: 15px;
|
|
316
396
|
font-weight: 700;
|
|
317
397
|
border: 2px solid;
|
|
@@ -328,7 +408,7 @@
|
|
|
328
408
|
margin-bottom: 10px;
|
|
329
409
|
}
|
|
330
410
|
|
|
331
|
-
.sort
|
|
411
|
+
.sort .selectWrapper {
|
|
332
412
|
display: flex;
|
|
333
413
|
align-items: center;
|
|
334
414
|
position: relative;
|
|
@@ -338,7 +418,7 @@
|
|
|
338
418
|
margin: 0;
|
|
339
419
|
}
|
|
340
420
|
|
|
341
|
-
.sort .
|
|
421
|
+
.sort .selectSpan {
|
|
342
422
|
display: block;
|
|
343
423
|
padding: 15px 30px 15px 15px;
|
|
344
424
|
font-size: 12px;
|
|
@@ -379,16 +459,48 @@
|
|
|
379
459
|
composes: no-label;
|
|
380
460
|
}
|
|
381
461
|
|
|
462
|
+
/*
|
|
463
|
+
Player
|
|
464
|
+
*/
|
|
465
|
+
|
|
466
|
+
.player {
|
|
467
|
+
composes: no-label;
|
|
468
|
+
}
|
|
469
|
+
|
|
382
470
|
/*
|
|
383
471
|
Header
|
|
384
472
|
*/
|
|
385
473
|
|
|
386
474
|
.header {
|
|
387
475
|
composes: mooc;
|
|
388
|
-
width: auto;
|
|
389
476
|
}
|
|
390
477
|
|
|
391
|
-
.header
|
|
478
|
+
.header .selectBox {
|
|
479
|
+
margin-left: 0;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.default .selectWrapper select.selectBox {
|
|
483
|
+
max-width: 280px;
|
|
484
|
+
width: inherit;
|
|
485
|
+
border-radius: 8px;
|
|
486
|
+
padding: 0;
|
|
487
|
+
height: 100%;
|
|
488
|
+
top: 0;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
.header .title,
|
|
492
|
+
.header .selectWrapper span.selectSpan {
|
|
493
|
+
min-width: 150px;
|
|
494
|
+
color: transparent;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.header .selectWrapper select.selectBox {
|
|
498
|
+
padding-left: 10px;
|
|
499
|
+
border-radius: 2px;
|
|
500
|
+
padding-right: 30px;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.header .selectBox {
|
|
392
504
|
background-color: light;
|
|
393
505
|
border: 0;
|
|
394
506
|
font-weight: 700;
|
|
@@ -420,7 +532,7 @@
|
|
|
420
532
|
composes: no-label;
|
|
421
533
|
}
|
|
422
534
|
|
|
423
|
-
.template
|
|
535
|
+
.template .selectBox {
|
|
424
536
|
width: auto;
|
|
425
537
|
height: 54px;
|
|
426
538
|
padding: 0 50px 0 0;
|
|
@@ -428,22 +540,22 @@
|
|
|
428
540
|
max-width: 100%;
|
|
429
541
|
}
|
|
430
542
|
|
|
431
|
-
.template .
|
|
543
|
+
.template .selectSpan {
|
|
432
544
|
font-size: 15px;
|
|
433
545
|
font-weight: 700;
|
|
434
546
|
height: 54px;
|
|
435
547
|
line-height: 52px;
|
|
436
548
|
}
|
|
437
549
|
|
|
438
|
-
.selected.template .
|
|
550
|
+
.selected.template .selectSpan {
|
|
439
551
|
border: 1px solid;
|
|
440
552
|
}
|
|
441
553
|
|
|
442
|
-
.unselected.template .
|
|
554
|
+
.unselected.template .selectSpan {
|
|
443
555
|
border: 1px solid color(black lightness(85%));
|
|
444
556
|
}
|
|
445
557
|
|
|
446
|
-
.template
|
|
558
|
+
.template .selectWrapper {
|
|
447
559
|
display: block;
|
|
448
560
|
width: auto;
|
|
449
561
|
margin-right: 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/atom/select/test/fixtures/player.js"],"names":["Default","props","theme"],"mappings":";AACA,OAAOA,OAAP,MAAoB,WAApB;AAEA,MAAM;AAACC,EAAAA;AAAD,IAAUD,OAAhB;AAEA,eAAe;AACbC,EAAAA,KAAK,EAAE,cAAaA,KAAb,EAAoB;AACzBC,IAAAA,KAAK,EAAE;AADkB,GAApB;AADM,CAAf","sourcesContent":["import {defaultsDeep} from 'lodash/fp';\nimport Default from './default';\n\nconst {props} = Default;\n\nexport default {\n props: defaultsDeep(props, {\n theme: 'player'\n })\n};\n"],"file":"player.js"}
|
|
@@ -11,6 +11,7 @@ import fixtureModified from './fixtures/modified';
|
|
|
11
11
|
import fixtureMooc from './fixtures/mooc';
|
|
12
12
|
import fixtureMultipleSelected from './fixtures/multiple-selected';
|
|
13
13
|
import fixtureMultiple from './fixtures/multiple';
|
|
14
|
+
import fixturePlayer from './fixtures/player';
|
|
14
15
|
import fixtureQuestion from './fixtures/question';
|
|
15
16
|
import fixtureRequiredWithTitle from './fixtures/required-with-title';
|
|
16
17
|
import fixtureRequired from './fixtures/required';
|
|
@@ -33,6 +34,7 @@ test('Atom › AtomSelect › Modified › should be rendered', renderComponentM
|
|
|
33
34
|
test('Atom › AtomSelect › Mooc › should be rendered', renderComponentMacro, AtomSelect, fixtureMooc);
|
|
34
35
|
test('Atom › AtomSelect › MultipleSelected › should be rendered', renderComponentMacro, AtomSelect, fixtureMultipleSelected);
|
|
35
36
|
test('Atom › AtomSelect › Multiple › should be rendered', renderComponentMacro, AtomSelect, fixtureMultiple);
|
|
37
|
+
test('Atom › AtomSelect › Player › should be rendered', renderComponentMacro, AtomSelect, fixturePlayer);
|
|
36
38
|
test('Atom › AtomSelect › Question › should be rendered', renderComponentMacro, AtomSelect, fixtureQuestion);
|
|
37
39
|
test('Atom › AtomSelect › RequiredWithTitle › should be rendered', renderComponentMacro, AtomSelect, fixtureRequiredWithTitle);
|
|
38
40
|
test('Atom › AtomSelect › Required › should be rendered', renderComponentMacro, AtomSelect, fixtureRequired);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/atom/select/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","AtomSelect","fixtureDefault","fixtureDisabled","fixtureError","fixtureFilter","fixtureInvalid","fixtureModified","fixtureMooc","fixtureMultipleSelected","fixtureMultiple","fixtureQuestion","fixtureRequiredWithTitle","fixtureRequired","fixtureSort","fixtureTemplate","fixtureThematiquesLong","fixtureThematiques","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,UAAP,MAAuB,IAAvB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,wBAAP,MAAqC,gCAArC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;
|
|
1
|
+
{"version":3,"sources":["../../../../src/atom/select/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","AtomSelect","fixtureDefault","fixtureDisabled","fixtureError","fixtureFilter","fixtureInvalid","fixtureModified","fixtureMooc","fixtureMultipleSelected","fixtureMultiple","fixturePlayer","fixtureQuestion","fixtureRequiredWithTitle","fixtureRequired","fixtureSort","fixtureTemplate","fixtureThematiquesLong","fixtureThematiques","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,UAAP,MAAuB,IAAvB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,uBAAP,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,EAAgGQ,uBAAhG,CAAJ;AACAX,IAAI,CAAC,mDAAD,EAAsDE,oBAAtD,EAA4EC,UAA5E,EAAwFS,eAAxF,CAAJ;AACAZ,IAAI,CAAC,iDAAD,EAAoDE,oBAApD,EAA0EC,UAA1E,EAAsFU,aAAtF,CAAJ;AACAb,IAAI,CAAC,mDAAD,EAAsDE,oBAAtD,EAA4EC,UAA5E,EAAwFW,eAAxF,CAAJ;AACAd,IAAI,CAAC,4DAAD,EAA+DE,oBAA/D,EAAqFC,UAArF,EAAiGY,wBAAjG,CAAJ;AACAf,IAAI,CAAC,mDAAD,EAAsDE,oBAAtD,EAA4EC,UAA5E,EAAwFa,eAAxF,CAAJ;AACAhB,IAAI,CAAC,+CAAD,EAAkDE,oBAAlD,EAAwEC,UAAxE,EAAoFc,WAApF,CAAJ;AACAjB,IAAI,CAAC,mDAAD,EAAsDE,oBAAtD,EAA4EC,UAA5E,EAAwFe,eAAxF,CAAJ;AACAlB,IAAI,CAAC,0DAAD,EAA6DE,oBAA7D,EAAmFC,UAAnF,EAA+FgB,sBAA/F,CAAJ;AACAnB,IAAI,CAAC,sDAAD,EAAyDE,oBAAzD,EAA+EC,UAA/E,EAA2FiB,kBAA3F,CAAJ","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport AtomSelect from '..';\nimport fixtureDefault from './fixtures/default';\nimport fixtureDisabled from './fixtures/disabled';\nimport fixtureError from './fixtures/error';\nimport fixtureFilter from './fixtures/filter';\nimport fixtureInvalid from './fixtures/invalid';\nimport fixtureModified from './fixtures/modified';\nimport fixtureMooc from './fixtures/mooc';\nimport fixtureMultipleSelected from './fixtures/multiple-selected';\nimport fixtureMultiple from './fixtures/multiple';\nimport fixturePlayer from './fixtures/player';\nimport fixtureQuestion from './fixtures/question';\nimport fixtureRequiredWithTitle from './fixtures/required-with-title';\nimport fixtureRequired from './fixtures/required';\nimport fixtureSort from './fixtures/sort';\nimport fixtureTemplate from './fixtures/template';\nimport fixtureThematiquesLong from './fixtures/thematiques-long';\nimport fixtureThematiques from './fixtures/thematiques';\n\ntest('Atom › AtomSelect > should have valid propTypes', t => {\n t.pass();\n forEach(AtomSelect.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Atom.AtomSelect.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Atom › AtomSelect › Default › should be rendered', renderComponentMacro, AtomSelect, fixtureDefault);\ntest('Atom › AtomSelect › Disabled › should be rendered', renderComponentMacro, AtomSelect, fixtureDisabled);\ntest('Atom › AtomSelect › Error › should be rendered', renderComponentMacro, AtomSelect, fixtureError);\ntest('Atom › AtomSelect › Filter › should be rendered', renderComponentMacro, AtomSelect, fixtureFilter);\ntest('Atom › AtomSelect › Invalid › should be rendered', renderComponentMacro, AtomSelect, fixtureInvalid);\ntest('Atom › AtomSelect › Modified › should be rendered', renderComponentMacro, AtomSelect, fixtureModified);\ntest('Atom › AtomSelect › Mooc › should be rendered', renderComponentMacro, AtomSelect, fixtureMooc);\ntest('Atom › AtomSelect › MultipleSelected › should be rendered', renderComponentMacro, AtomSelect, fixtureMultipleSelected);\ntest('Atom › AtomSelect › Multiple › should be rendered', renderComponentMacro, AtomSelect, fixtureMultiple);\ntest('Atom › AtomSelect › Player › should be rendered', renderComponentMacro, AtomSelect, fixturePlayer);\ntest('Atom › AtomSelect › Question › should be rendered', renderComponentMacro, AtomSelect, fixtureQuestion);\ntest('Atom › AtomSelect › RequiredWithTitle › should be rendered', renderComponentMacro, AtomSelect, fixtureRequiredWithTitle);\ntest('Atom › AtomSelect › Required › should be rendered', renderComponentMacro, AtomSelect, fixtureRequired);\ntest('Atom › AtomSelect › Sort › should be rendered', renderComponentMacro, AtomSelect, fixtureSort);\ntest('Atom › AtomSelect › Template › should be rendered', renderComponentMacro, AtomSelect, fixtureTemplate);\ntest('Atom › AtomSelect › ThematiquesLong › should be rendered', renderComponentMacro, AtomSelect, fixtureThematiquesLong);\ntest('Atom › AtomSelect › Thematiques › should be rendered', renderComponentMacro, AtomSelect, fixtureThematiques);\n"],"file":"fixtures.js"}
|
|
@@ -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
|