@coorpacademy/components 11.40.13 → 11.40.14-alpha.11
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/checkbox-with-title/index.d.ts +24 -1
- package/es/atom/checkbox-with-title/index.d.ts.map +1 -1
- package/es/atom/checkbox-with-title/index.js +16 -2
- package/es/atom/checkbox-with-title/index.js.map +1 -1
- package/es/atom/chip/index.d.ts.map +1 -1
- package/es/atom/chip/index.js +4 -4
- package/es/atom/chip/index.js.map +1 -1
- package/es/atom/input-switch/index.d.ts +24 -1
- package/es/atom/input-switch/index.d.ts.map +1 -1
- package/es/atom/input-switch/index.js +16 -2
- package/es/atom/input-switch/index.js.map +1 -1
- package/es/atom/range/index.d.ts +33 -3
- package/es/atom/range/index.d.ts.map +1 -1
- package/es/atom/range/index.js +88 -20
- package/es/atom/range/index.js.map +1 -1
- package/es/atom/range/style.css +38 -0
- package/es/molecule/multi-filter-panel/index.d.ts +41 -0
- package/es/molecule/multi-filter-panel/index.d.ts.map +1 -1
- package/es/molecule/multi-filter-panel/index.js +28 -13
- package/es/molecule/multi-filter-panel/index.js.map +1 -1
- package/es/molecule/multi-filter-panel/prop-types.d.ts +31 -5
- package/es/molecule/multi-filter-panel/prop-types.d.ts.map +1 -1
- package/es/molecule/multi-filter-panel/prop-types.js +4 -0
- package/es/molecule/multi-filter-panel/prop-types.js.map +1 -1
- package/es/molecule/questions/question-range/index.d.ts +4 -1
- package/es/molecule/quick-filters/index.js +3 -1
- package/es/molecule/quick-filters/index.js.map +1 -1
- package/es/molecule/quick-filters/style.css +2 -0
- package/es/organism/content-skill-modal/index.d.ts +20 -0
- package/es/organism/content-skill-modal/index.d.ts.map +1 -1
- package/es/organism/content-skill-modal/types.d.ts +20 -0
- package/es/organism/content-skill-modal/types.d.ts.map +1 -1
- package/es/organism/filter-checkbox-and-search/index.d.ts +21 -0
- package/es/organism/filter-checkbox-and-search/index.d.ts.map +1 -1
- package/es/organism/filter-checkbox-and-search/index.js +13 -2
- package/es/organism/filter-checkbox-and-search/index.js.map +1 -1
- package/es/organism/filter-chip/index.d.ts +21 -0
- package/es/organism/filter-chip/index.d.ts.map +1 -1
- package/es/organism/filter-chip/index.js +14 -2
- package/es/organism/filter-chip/index.js.map +1 -1
- package/es/organism/filter-range/index.d.ts +28 -0
- package/es/organism/filter-range/index.d.ts.map +1 -0
- package/es/organism/filter-range/index.js +89 -0
- package/es/organism/filter-range/index.js.map +1 -0
- package/es/organism/filter-range/prop-types.d.ts +38 -0
- package/es/organism/filter-range/prop-types.d.ts.map +1 -0
- package/es/organism/filter-range/prop-types.js +20 -0
- package/es/organism/filter-range/prop-types.js.map +1 -0
- package/es/organism/filter-range/style.css +15 -0
- package/es/organism/filter-switch/index.d.ts +22 -0
- package/es/organism/filter-switch/index.d.ts.map +1 -1
- package/es/organism/filter-switch/index.js +18 -3
- package/es/organism/filter-switch/index.js.map +1 -1
- package/es/organism/filter-switch/prop-types.d.ts +2 -0
- package/es/organism/filter-switch/prop-types.d.ts.map +1 -1
- package/es/organism/filter-switch/prop-types.js +2 -1
- package/es/organism/filter-switch/prop-types.js.map +1 -1
- package/es/template/back-office/brand-update/index.d.ts +20 -0
- package/es/template/common/search-page/index.d.ts +36 -0
- package/es/template/common/search-page/index.d.ts.map +1 -1
- package/es/template/common/search-page/index.js +45 -6
- package/es/template/common/search-page/index.js.map +1 -1
- package/es/template/common/search-page/style.css +27 -1
- package/es/variables/colors.css +1 -0
- package/lib/atom/checkbox-with-title/index.d.ts +24 -1
- package/lib/atom/checkbox-with-title/index.d.ts.map +1 -1
- package/lib/atom/checkbox-with-title/index.js +16 -2
- package/lib/atom/checkbox-with-title/index.js.map +1 -1
- package/lib/atom/chip/index.d.ts.map +1 -1
- package/lib/atom/chip/index.js +4 -4
- package/lib/atom/chip/index.js.map +1 -1
- package/lib/atom/input-switch/index.d.ts +24 -1
- package/lib/atom/input-switch/index.d.ts.map +1 -1
- package/lib/atom/input-switch/index.js +16 -2
- package/lib/atom/input-switch/index.js.map +1 -1
- package/lib/atom/range/index.d.ts +33 -3
- package/lib/atom/range/index.d.ts.map +1 -1
- package/lib/atom/range/index.js +88 -20
- package/lib/atom/range/index.js.map +1 -1
- package/lib/atom/range/style.css +38 -0
- package/lib/molecule/multi-filter-panel/index.d.ts +41 -0
- package/lib/molecule/multi-filter-panel/index.d.ts.map +1 -1
- package/lib/molecule/multi-filter-panel/index.js +28 -13
- package/lib/molecule/multi-filter-panel/index.js.map +1 -1
- package/lib/molecule/multi-filter-panel/prop-types.d.ts +31 -5
- package/lib/molecule/multi-filter-panel/prop-types.d.ts.map +1 -1
- package/lib/molecule/multi-filter-panel/prop-types.js +4 -0
- package/lib/molecule/multi-filter-panel/prop-types.js.map +1 -1
- package/lib/molecule/questions/question-range/index.d.ts +4 -1
- package/lib/molecule/quick-filters/index.js +3 -1
- package/lib/molecule/quick-filters/index.js.map +1 -1
- package/lib/molecule/quick-filters/style.css +2 -0
- package/lib/organism/content-skill-modal/index.d.ts +20 -0
- package/lib/organism/content-skill-modal/index.d.ts.map +1 -1
- package/lib/organism/content-skill-modal/types.d.ts +20 -0
- package/lib/organism/content-skill-modal/types.d.ts.map +1 -1
- package/lib/organism/filter-checkbox-and-search/index.d.ts +21 -0
- package/lib/organism/filter-checkbox-and-search/index.d.ts.map +1 -1
- package/lib/organism/filter-checkbox-and-search/index.js +13 -2
- package/lib/organism/filter-checkbox-and-search/index.js.map +1 -1
- package/lib/organism/filter-chip/index.d.ts +21 -0
- package/lib/organism/filter-chip/index.d.ts.map +1 -1
- package/lib/organism/filter-chip/index.js +14 -2
- package/lib/organism/filter-chip/index.js.map +1 -1
- package/lib/organism/filter-range/index.d.ts +28 -0
- package/lib/organism/filter-range/index.d.ts.map +1 -0
- package/lib/organism/filter-range/index.js +96 -0
- package/lib/organism/filter-range/index.js.map +1 -0
- package/lib/organism/filter-range/prop-types.d.ts +38 -0
- package/lib/organism/filter-range/prop-types.d.ts.map +1 -0
- package/lib/organism/filter-range/prop-types.js +25 -0
- package/lib/organism/filter-range/prop-types.js.map +1 -0
- package/lib/organism/filter-range/style.css +15 -0
- package/lib/organism/filter-switch/index.d.ts +22 -0
- package/lib/organism/filter-switch/index.d.ts.map +1 -1
- package/lib/organism/filter-switch/index.js +18 -3
- package/lib/organism/filter-switch/index.js.map +1 -1
- package/lib/organism/filter-switch/prop-types.d.ts +2 -0
- package/lib/organism/filter-switch/prop-types.d.ts.map +1 -1
- package/lib/organism/filter-switch/prop-types.js +2 -1
- package/lib/organism/filter-switch/prop-types.js.map +1 -1
- package/lib/template/back-office/brand-update/index.d.ts +20 -0
- package/lib/template/common/search-page/index.d.ts +36 -0
- package/lib/template/common/search-page/index.d.ts.map +1 -1
- package/lib/template/common/search-page/index.js +45 -6
- package/lib/template/common/search-page/index.js.map +1 -1
- package/lib/template/common/search-page/style.css +27 -1
- package/lib/variables/colors.css +1 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default CheckboxWithTitle;
|
|
2
|
-
declare function CheckboxWithTitle(props: any): JSX.Element;
|
|
2
|
+
declare function CheckboxWithTitle(props: any, context: any): JSX.Element;
|
|
3
3
|
declare namespace CheckboxWithTitle {
|
|
4
4
|
const propTypes: {
|
|
5
5
|
title: PropTypes.Requireable<string>;
|
|
@@ -17,6 +17,29 @@ declare namespace CheckboxWithTitle {
|
|
|
17
17
|
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
18
18
|
}>;
|
|
19
19
|
};
|
|
20
|
+
namespace contextTypes {
|
|
21
|
+
const skin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
22
|
+
common: PropTypes.Requireable<{
|
|
23
|
+
[x: string]: any;
|
|
24
|
+
}>;
|
|
25
|
+
images: PropTypes.Requireable<PropTypes.InferProps<{
|
|
26
|
+
'logo-mobile': PropTypes.Requireable<any>;
|
|
27
|
+
logo: PropTypes.Requireable<any>;
|
|
28
|
+
'logo-email': PropTypes.Requireable<any>;
|
|
29
|
+
login: PropTypes.Requireable<any>;
|
|
30
|
+
}>>;
|
|
31
|
+
icons: PropTypes.Requireable<{
|
|
32
|
+
[x: string]: any;
|
|
33
|
+
}>;
|
|
34
|
+
mod: PropTypes.Requireable<{
|
|
35
|
+
[x: string]: any;
|
|
36
|
+
}>;
|
|
37
|
+
courses: PropTypes.Requireable<any[]>;
|
|
38
|
+
texts: PropTypes.Requireable<{
|
|
39
|
+
[x: string]: any;
|
|
40
|
+
}>;
|
|
41
|
+
}>>;
|
|
42
|
+
}
|
|
20
43
|
}
|
|
21
44
|
import PropTypes from "prop-types";
|
|
22
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/checkbox-with-title/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/checkbox-with-title/index.js"],"names":[],"mappings":";AAUA,0EA+DC"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import _uniqueId from "lodash/fp/uniqueId";
|
|
2
2
|
import _noop from "lodash/fp/noop";
|
|
3
|
+
import _getOr from "lodash/fp/getOr";
|
|
3
4
|
import React, { useMemo } from 'react';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import FaIcon from '../icon';
|
|
7
|
+
import { COLORS } from '../../variables/colors';
|
|
8
|
+
import Provider from '../provider';
|
|
6
9
|
import style from './style.css';
|
|
7
10
|
const DEFAULT_ICON_STYLE = {
|
|
8
11
|
padding: '0',
|
|
9
12
|
width: '20px',
|
|
10
13
|
height: '20px'
|
|
11
14
|
};
|
|
12
|
-
const CheckboxWithTitle = props => {
|
|
15
|
+
const CheckboxWithTitle = (props, context) => {
|
|
13
16
|
const {
|
|
14
17
|
title,
|
|
15
18
|
name,
|
|
@@ -24,6 +27,10 @@ const CheckboxWithTitle = props => {
|
|
|
24
27
|
},
|
|
25
28
|
customStyle = {}
|
|
26
29
|
} = props;
|
|
30
|
+
const {
|
|
31
|
+
skin
|
|
32
|
+
} = context;
|
|
33
|
+
const primaryColor = _getOr(COLORS.cm_primary_blue, 'common.primary', skin);
|
|
27
34
|
const {
|
|
28
35
|
iconName,
|
|
29
36
|
iconColor,
|
|
@@ -48,7 +55,11 @@ const CheckboxWithTitle = props => {
|
|
|
48
55
|
"data-name": dataName,
|
|
49
56
|
"aria-label": ariaLabel
|
|
50
57
|
}), /*#__PURE__*/React.createElement("div", {
|
|
51
|
-
className: style.label
|
|
58
|
+
className: style.label,
|
|
59
|
+
style: checked ? {
|
|
60
|
+
background: primaryColor,
|
|
61
|
+
borderColor: primaryColor
|
|
62
|
+
} : null
|
|
52
63
|
}, checked ? /*#__PURE__*/React.createElement(FaIcon, {
|
|
53
64
|
className: style.icon,
|
|
54
65
|
iconName: iconName,
|
|
@@ -82,5 +93,8 @@ CheckboxWithTitle.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
82
93
|
}),
|
|
83
94
|
customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))
|
|
84
95
|
} : {};
|
|
96
|
+
CheckboxWithTitle.contextTypes = {
|
|
97
|
+
skin: Provider.childContextTypes.skin
|
|
98
|
+
};
|
|
85
99
|
export default CheckboxWithTitle;
|
|
86
100
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","FaIcon","style","DEFAULT_ICON_STYLE","padding","width","height","CheckboxWithTitle","props","title","name","checked","onChange","_noop","dataName","ariaLabel","icon","iconName","iconColor","preset","customStyle","idCheckbox","_uniqueId","handleChange","e","target","createElement","className","container","htmlFor","type","id","checkbox","label","dangerouslySetInnerHTML","__html","propTypes","process","env","NODE_ENV","string","bool","func","shape","objectOf","oneOfType","number"],"sources":["../../../src/atom/checkbox-with-title/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {noop, uniqueId} from 'lodash/fp';\nimport FaIcon from '../icon';\nimport style from './style.css';\n\nconst DEFAULT_ICON_STYLE = {padding: '0', width: '20px', height: '20px'};\n\nconst CheckboxWithTitle = props => {\n const {\n title,\n name,\n checked,\n onChange = noop,\n 'data-name': dataName,\n 'aria-label': ariaLabel,\n icon = {iconName: 'check', iconColor: 'white', preset: 's'},\n customStyle = {}\n } = props;\n const {iconName, iconColor, preset} = icon;\n const idCheckbox = useMemo(() => uniqueId('input-checkbox-'), []);\n const handleChange = useMemo(() => e => onChange(e.target.checked), [onChange]);\n\n return (\n <div className={style.container} style={{...customStyle}}>\n {onChange !== noop ? (\n <label htmlFor={idCheckbox}>\n <input\n type=\"checkbox\"\n id={idCheckbox}\n name={name}\n onChange={handleChange}\n checked={checked}\n className={style.checkbox}\n data-name={dataName}\n aria-label={ariaLabel}\n />\n <div
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","FaIcon","COLORS","Provider","style","DEFAULT_ICON_STYLE","padding","width","height","CheckboxWithTitle","props","context","title","name","checked","onChange","_noop","dataName","ariaLabel","icon","iconName","iconColor","preset","customStyle","skin","primaryColor","_getOr","cm_primary_blue","idCheckbox","_uniqueId","handleChange","e","target","createElement","className","container","htmlFor","type","id","checkbox","label","background","borderColor","dangerouslySetInnerHTML","__html","propTypes","process","env","NODE_ENV","string","bool","func","shape","objectOf","oneOfType","number","contextTypes","childContextTypes"],"sources":["../../../src/atom/checkbox-with-title/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {getOr, noop, uniqueId} from 'lodash/fp';\nimport FaIcon from '../icon';\nimport {COLORS} from '../../variables/colors';\nimport Provider from '../provider';\nimport style from './style.css';\n\nconst DEFAULT_ICON_STYLE = {padding: '0', width: '20px', height: '20px'};\n\nconst CheckboxWithTitle = (props, context) => {\n const {\n title,\n name,\n checked,\n onChange = noop,\n 'data-name': dataName,\n 'aria-label': ariaLabel,\n icon = {iconName: 'check', iconColor: 'white', preset: 's'},\n customStyle = {}\n } = props;\n const {skin} = context;\n const primaryColor = getOr(COLORS.cm_primary_blue, 'common.primary', skin);\n const {iconName, iconColor, preset} = icon;\n const idCheckbox = useMemo(() => uniqueId('input-checkbox-'), []);\n const handleChange = useMemo(() => e => onChange(e.target.checked), [onChange]);\n\n return (\n <div className={style.container} style={{...customStyle}}>\n {onChange !== noop ? (\n <label htmlFor={idCheckbox}>\n <input\n type=\"checkbox\"\n id={idCheckbox}\n name={name}\n onChange={handleChange}\n checked={checked}\n className={style.checkbox}\n data-name={dataName}\n aria-label={ariaLabel}\n />\n <div\n className={style.label}\n style={checked ? {background: primaryColor, borderColor: primaryColor} : null}\n >\n {checked ? (\n <FaIcon\n className={style.icon}\n iconName={iconName}\n iconColor={iconColor}\n preset={preset}\n customStyle={DEFAULT_ICON_STYLE}\n />\n ) : (\n <FaIcon\n className={style.icon}\n iconName={'square'}\n iconColor={'transparent'}\n preset=\"s\"\n customStyle={DEFAULT_ICON_STYLE}\n />\n )}\n </div>\n </label>\n ) : null}\n {title ? (\n <span\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: title}}\n />\n ) : null}\n </div>\n );\n};\n\nCheckboxWithTitle.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n checked: PropTypes.bool,\n onChange: PropTypes.func,\n 'aria-label': PropTypes.string,\n 'data-name': PropTypes.string,\n icon: PropTypes.shape({\n iconName: PropTypes.string,\n iconColor: PropTypes.string,\n preset: PropTypes.string\n }),\n customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))\n};\n\nCheckboxWithTitle.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\nexport default CheckboxWithTitle;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAGC,OAAO,QAAO,OAAO;AACpC,OAAOC,SAAS,MAAM,YAAY;AAElC,OAAOC,MAAM,MAAM,SAAS;AAC5B,SAAQC,MAAM,QAAO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M;EAC9B,WAAW,EAAEjD,SAAS,CAACiD,MAAM;EAC7B9B,IAAI,EAAEnB,SAAS,CAACoD,KAAK,CAAC;IACpBhC,QAAQ,EAAEpB,SAAS,CAACiD,MAAM;IAC1B5B,SAAS,EAAErB,SAAS,CAACiD,MAAM;IAC3B3B,MAAM,EAAEtB,SAAS,CAACiD;EACpB,CAAC,CAAC;EACF1B,WAAW,EAAEvB,SAAS,CAACqD,QAAQ,CAACrD,SAAS,CAACsD,SAAS,CAAC,CAACtD,SAAS,CAACiD,MAAM,EAAEjD,SAAS,CAACuD,MAAM,CAAC,CAAC;AAC3F,CAAC;AAED9C,iBAAiB,CAAC+C,YAAY,GAAG;EAC/BhC,IAAI,EAAErB,QAAQ,CAACsD,iBAAiB,CAACjC;AACnC,CAAC;AACD,eAAef,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/chip/index.js"],"names":[],"mappings":"AAmBO,qGAG0E;;AAGjF,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/chip/index.js"],"names":[],"mappings":"AAmBO,qGAG0E;;AAGjF,6DA0EC"}
|
package/es/atom/chip/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo, useState, useCallback } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import
|
|
4
|
+
import getOr from 'lodash/fp/getOr';
|
|
5
5
|
import { convert } from 'css-color-function';
|
|
6
6
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
7
|
import { fas } from '@fortawesome/pro-solid-svg-icons';
|
|
@@ -27,14 +27,14 @@ const Chip = (props, context) => {
|
|
|
27
27
|
customIcon,
|
|
28
28
|
onClick,
|
|
29
29
|
leftIcon,
|
|
30
|
-
backgroundColor
|
|
30
|
+
backgroundColor,
|
|
31
31
|
customStyle
|
|
32
32
|
} = props;
|
|
33
33
|
const {
|
|
34
34
|
skin
|
|
35
35
|
} = context;
|
|
36
|
-
const skinColor =
|
|
37
|
-
const selectedBgColor = backgroundColor === 'skin' && skinColor ? skinColor : backgroundColor;
|
|
36
|
+
const skinColor = getOr(DEFAULT_BACKGROUND_COLOR, 'common.primary', skin);
|
|
37
|
+
const selectedBgColor = backgroundColor === 'skin' && skinColor ? skinColor : backgroundColor || DEFAULT_BACKGROUND_COLOR;
|
|
38
38
|
const hoveredSelectedBgColor = calculateHoveredSelectedBgColor(selectedBgColor);
|
|
39
39
|
const [isHovered, setIsHovered] = useState(false);
|
|
40
40
|
const handleClick = useMemo(() => onClick, [onClick]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","useState","useCallback","PropTypes","classnames","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useMemo","useState","useCallback","PropTypes","classnames","getOr","convert","FontAwesomeIcon","fas","library","Provider","COLORS","style","add","LUMINOSITY_DELTA","cm_primary_blue","DEFAULT_BACKGROUND_COLOR","ICON_SIZE","calculateHoveredSelectedBgColor","selectedBgColor","luminosityDelta","Chip","props","context","text","subText","textColor","cm_grey_700","selected","customIcon","onClick","leftIcon","backgroundColor","customStyle","skin","skinColor","hoveredSelectedBgColor","isHovered","setIsHovered","handleClick","handleMouseEnter","handleMouseLeave","hoverStyle","defaultIcon","showIcon","color","white","createElement","className","container","unselected","onMouseEnter","onMouseLeave","left","icon","fontSize","title","contextTypes","childContextTypes","propTypes","process","env","NODE_ENV","string","bool","func","objectOf","oneOfType","number"],"sources":["../../../src/atom/chip/index.js"],"sourcesContent":["import React, {useMemo, useState, useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\n\nimport getOr from 'lodash/fp/getOr';\nimport {convert} from 'css-color-function';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {fas} from '@fortawesome/pro-solid-svg-icons';\nimport {library} from '@fortawesome/fontawesome-svg-core';\nimport Provider from '../provider';\nimport {COLORS} from '../../variables/colors';\nimport style from './style.css';\n\nlibrary.add(fas);\n\nconst LUMINOSITY_DELTA = 0.08;\nconst {cm_primary_blue: DEFAULT_BACKGROUND_COLOR} = COLORS;\nconst ICON_SIZE = '12px';\n\nexport const calculateHoveredSelectedBgColor = (\n selectedBgColor,\n luminosityDelta = LUMINOSITY_DELTA\n) => convert(`hsl(from ${selectedBgColor} h s calc(l*(1 - ${luminosityDelta})))`);\n// note: luminosity decrease is relative to the selected color\n\nconst Chip = (props, context) => {\n const {\n text,\n subText,\n textColor = COLORS.cm_grey_700,\n selected = false,\n customIcon,\n onClick,\n leftIcon,\n backgroundColor,\n customStyle\n } = props;\n const {skin} = context;\n const skinColor = getOr(DEFAULT_BACKGROUND_COLOR, 'common.primary', skin);\n const selectedBgColor =\n backgroundColor === 'skin' && skinColor\n ? skinColor\n : backgroundColor || DEFAULT_BACKGROUND_COLOR;\n const hoveredSelectedBgColor = calculateHoveredSelectedBgColor(selectedBgColor);\n\n const [isHovered, setIsHovered] = useState(false);\n\n const handleClick = useMemo(() => onClick, [onClick]);\n\n const handleMouseEnter = useCallback(() => {\n setIsHovered(true);\n }, []);\n\n const handleMouseLeave = useCallback(() => {\n setIsHovered(false);\n }, []);\n\n const hoverStyle = isHovered ? {backgroundColor: hoveredSelectedBgColor} : {};\n\n const defaultIcon = selected ? 'fa-check' : 'fa-plus';\n const showIcon = customIcon !== 'none';\n const color = selected ? COLORS.white : textColor;\n\n return (\n <div\n className={classnames(style.container, !selected && style.unselected)}\n style={{\n ...(selected && selectedBgColor ? {backgroundColor: selectedBgColor} : {}),\n ...(selected && hoverStyle),\n ...customStyle\n }}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-label={text}\n data-name={`chip-${text}`}\n >\n <div className={style.left}>\n {leftIcon ? <FontAwesomeIcon style={{color}} icon={leftIcon} fontSize={ICON_SIZE} /> : null}\n <div title={text}>\n <span className={style.text} style={{color}}>\n {text}\n </span>\n {subText ? (\n <span className={style.subText} style={{color}}>\n {subText}\n </span>\n ) : null}\n </div>\n </div>\n {showIcon ? (\n <FontAwesomeIcon\n style={{color}}\n icon={customIcon ? `fa-${customIcon}` : defaultIcon}\n fontSize={ICON_SIZE}\n />\n ) : null}\n </div>\n );\n};\n\nChip.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nChip.propTypes = {\n text: PropTypes.string,\n subText: PropTypes.string,\n textColor: PropTypes.string,\n selected: PropTypes.bool,\n customIcon: PropTypes.string,\n backgroundColor: PropTypes.string,\n onClick: PropTypes.func,\n leftIcon: PropTypes.string,\n customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))\n};\n\nexport default Chip;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAGC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,QAAO,OAAO;AAC3D,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AAEnC,OAAOC,KAAK,MAAM,iBAAiB;AACnC,SAAQC,OAAO,QAAO,oBAAoB;AAC1C,SAAQC,eAAe,QAAO,gCAAgC;AAC9D,SAAQC,GAAG,QAAO,kCAAkC;AACpD,SAAQC,OAAO,QAAO,mCAAmC;AACzD,OAAOC,QAAQ,MAAM,aAAa;AAClC,SAAQC,MAAM,QAAO,wBAAwB;AAC7C,OAAOC,KAAK,MAAM,aAAa;AAE/BH,OAAO,CAACI,GAAG,CAACL,GAAG,CAAC;AAEhB,MAAMM,gBAAgB,GAAG,IAAI;AAC7B,MAAM;EAACC,eAAe,EAAEC;AAAwB,CAAC,GAAGL,MAAM;AAC1D,MAAMM,SAAS,GAAG,MAAM;AAExB,OAAO,MAAMC,+BAA+B,GAAGA,CAC7CC,eAAe,EACfC,eAAe,GAAGN,gBAAgB,KAC/BR,OAAO,CAAC,YAAYa,eAAe,oBAAoBC,eAAe,KAAK,CAAC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EV,CAAC;AAEDI,IAAI,CAACoC,YAAY,GAAG;EAClBvB,IAAI,EAAExB,QAAQ,CAACgD,iBAAiB,CAACxB;AACnC,CAAC;AAEDb,IAAI,CAACsC,SAAS,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAG;EACftC,IAAI,EAAErB,SAAS,CAAC4D,MAAM;EACtBtC,OAAO,EAAEtB,SAAS,CAAC4D,MAAM;EACzBrC,SAAS,EAAEvB,SAAS,CAAC4D,MAAM;EAC3BnC,QAAQ,EAAEzB,SAAS,CAAC6D,IAAI;EACxBnC,UAAU,EAAE1B,SAAS,CAAC4D,MAAM;EAC5B/B,eAAe,EAAE7B,SAAS,CAAC4D,MAAM;EACjCjC,OAAO,EAAE3B,SAAS,CAAC8D,IAAI;EACvBlC,QAAQ,EAAE5B,SAAS,CAAC4D,MAAM;EAC1B9B,WAAW,EAAE9B,SAAS,CAAC+D,QAAQ,CAAC/D,SAAS,CAACgE,SAAS,CAAC,CAAChE,SAAS,CAAC4D,MAAM,EAAE5D,SAAS,CAACiE,MAAM,CAAC,CAAC;AAC3F,CAAC;AAED,eAAe/C,IAAI","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default InputSwitch;
|
|
2
|
-
declare function InputSwitch(props: any): JSX.Element;
|
|
2
|
+
declare function InputSwitch(props: any, context: any): JSX.Element;
|
|
3
3
|
declare namespace InputSwitch {
|
|
4
4
|
const propTypes: {
|
|
5
5
|
title: PropTypes.Requireable<string>;
|
|
@@ -19,6 +19,29 @@ declare namespace InputSwitch {
|
|
|
19
19
|
requiredSelection: PropTypes.Requireable<boolean>;
|
|
20
20
|
icon: PropTypes.Requireable<string>;
|
|
21
21
|
};
|
|
22
|
+
namespace contextTypes {
|
|
23
|
+
const skin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
24
|
+
common: PropTypes.Requireable<{
|
|
25
|
+
[x: string]: any;
|
|
26
|
+
}>;
|
|
27
|
+
images: PropTypes.Requireable<PropTypes.InferProps<{
|
|
28
|
+
'logo-mobile': PropTypes.Requireable<any>;
|
|
29
|
+
logo: PropTypes.Requireable<any>;
|
|
30
|
+
'logo-email': PropTypes.Requireable<any>;
|
|
31
|
+
login: PropTypes.Requireable<any>;
|
|
32
|
+
}>>;
|
|
33
|
+
icons: PropTypes.Requireable<{
|
|
34
|
+
[x: string]: any;
|
|
35
|
+
}>;
|
|
36
|
+
mod: PropTypes.Requireable<{
|
|
37
|
+
[x: string]: any;
|
|
38
|
+
}>;
|
|
39
|
+
courses: PropTypes.Requireable<any[]>;
|
|
40
|
+
texts: PropTypes.Requireable<{
|
|
41
|
+
[x: string]: any;
|
|
42
|
+
}>;
|
|
43
|
+
}>>;
|
|
44
|
+
}
|
|
22
45
|
}
|
|
23
46
|
import PropTypes from "prop-types";
|
|
24
47
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/input-switch/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/input-switch/index.js"],"names":[],"mappings":";AAUA,oEAqGC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import _uniqueId from "lodash/fp/uniqueId";
|
|
2
2
|
import _noop from "lodash/fp/noop";
|
|
3
|
+
import _getOr from "lodash/fp/getOr";
|
|
3
4
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
5
|
import React, { useMemo } from 'react';
|
|
5
6
|
import PropTypes from 'prop-types';
|
|
6
7
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
8
|
import classNames from 'classnames';
|
|
8
9
|
import getClassState from '../../util/get-class-state';
|
|
10
|
+
import { COLORS } from '../../variables/colors';
|
|
11
|
+
import Provider from '../provider';
|
|
9
12
|
import style from './style.css';
|
|
10
|
-
const InputSwitch = props => {
|
|
13
|
+
const InputSwitch = (props, context) => {
|
|
11
14
|
const {
|
|
12
15
|
title,
|
|
13
16
|
name,
|
|
@@ -26,6 +29,10 @@ const InputSwitch = props => {
|
|
|
26
29
|
'aria-label': ariaLabel,
|
|
27
30
|
icon
|
|
28
31
|
} = props;
|
|
32
|
+
const {
|
|
33
|
+
skin
|
|
34
|
+
} = context;
|
|
35
|
+
const primaryColor = _getOr(COLORS.cm_primary_blue, 'common.primary', skin);
|
|
29
36
|
const idSwitch = id || _uniqueId('input-switch-');
|
|
30
37
|
const isDisabled = disabled ? 'disabled' : '';
|
|
31
38
|
const handleChange = useMemo(() => e => onChange(e.target.checked), [onChange]);
|
|
@@ -97,7 +104,11 @@ const InputSwitch = props => {
|
|
|
97
104
|
"data-name": "input-switch-label",
|
|
98
105
|
tabIndex: 0,
|
|
99
106
|
"aria-label": ariaLabel,
|
|
100
|
-
title: ariaLabel
|
|
107
|
+
title: ariaLabel,
|
|
108
|
+
style: value ? {
|
|
109
|
+
background: primaryColor,
|
|
110
|
+
borderColor: primaryColor
|
|
111
|
+
} : null
|
|
101
112
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
102
113
|
className: !details ? style.alignedTextContainer : null
|
|
103
114
|
}, titlePosition === 'right' ? titleView : null, details ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -122,5 +133,8 @@ InputSwitch.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
122
133
|
requiredSelection: PropTypes.bool,
|
|
123
134
|
icon: PropTypes.string
|
|
124
135
|
} : {};
|
|
136
|
+
InputSwitch.contextTypes = {
|
|
137
|
+
skin: Provider.childContextTypes.skin
|
|
138
|
+
};
|
|
125
139
|
export default InputSwitch;
|
|
126
140
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","FontAwesomeIcon","classNames","getClassState","style","InputSwitch","props","title","name","id","value","disabled","onChange","_noop","description","modified","theme","titlePosition","details","requiredSelection","dataName","ariaLabelledBy","ariaLabel","icon","idSwitch","_uniqueId","isDisabled","handleChange","e","target","checked","titleView","createElement","className","titleContainer","newMoocTitleContainer","descriptionView","getClass","defaultClass","coorpmanager","modifiedClass","coorpmanagerModified","newMooc","newMoocModified","partielUncheck","defaultStyle","btnSwitchContainer","_extends","type","checkbox","htmlFor","tabIndex","alignedTextContainer","detailsTxt","propTypes","process","env","NODE_ENV","string","bool","func","oneOf"],"sources":["../../../src/atom/input-switch/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {noop, uniqueId} from 'lodash/fp';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport classNames from 'classnames';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst InputSwitch = props => {\n const {\n title,\n name,\n id,\n value,\n disabled,\n onChange = noop,\n description,\n modified = false,\n theme = 'default',\n titlePosition = 'left',\n details = '',\n requiredSelection = false,\n 'data-name': dataName,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-label': ariaLabel,\n icon\n } = props;\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","FontAwesomeIcon","classNames","getClassState","COLORS","Provider","style","InputSwitch","props","context","title","name","id","value","disabled","onChange","_noop","description","modified","theme","titlePosition","details","requiredSelection","dataName","ariaLabelledBy","ariaLabel","icon","skin","primaryColor","_getOr","cm_primary_blue","idSwitch","_uniqueId","isDisabled","handleChange","e","target","checked","titleView","createElement","className","titleContainer","newMoocTitleContainer","descriptionView","getClass","defaultClass","coorpmanager","modifiedClass","coorpmanagerModified","newMooc","newMoocModified","partielUncheck","defaultStyle","btnSwitchContainer","_extends","type","checkbox","htmlFor","tabIndex","background","borderColor","alignedTextContainer","detailsTxt","propTypes","process","env","NODE_ENV","string","bool","func","oneOf","contextTypes","childContextTypes"],"sources":["../../../src/atom/input-switch/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {getOr, noop, uniqueId} from 'lodash/fp';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport classNames from 'classnames';\nimport getClassState from '../../util/get-class-state';\nimport {COLORS} from '../../variables/colors';\nimport Provider from '../provider';\nimport style from './style.css';\n\nconst InputSwitch = (props, context) => {\n const {\n title,\n name,\n id,\n value,\n disabled,\n onChange = noop,\n description,\n modified = false,\n theme = 'default',\n titlePosition = 'left',\n details = '',\n requiredSelection = false,\n 'data-name': dataName,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-label': ariaLabel,\n icon\n } = props;\n const {skin} = context;\n const primaryColor = getOr(COLORS.cm_primary_blue, 'common.primary', skin);\n const idSwitch = id || uniqueId('input-switch-');\n const isDisabled = disabled ? 'disabled' : '';\n const handleChange = useMemo(() => e => onChange(e.target.checked), [onChange]);\n const titleView = title ? (\n <div\n className={classNames(\n icon ? style.titleContainer : null,\n theme === 'newMooc' ? style.newMoocTitleContainer : null\n )}\n >\n {icon ? <FontAwesomeIcon icon={icon} className={style.icon} /> : null}\n <span id={`title-view-${dataName}`} className={style.title}>\n {title}\n </span>\n </div>\n ) : null;\n\n const descriptionView = description ? (\n <div className={style.description}>{description}</div>\n ) : null;\n\n const getClass = () => {\n switch (theme) {\n case 'coorpmanager':\n return {\n defaultClass: style.coorpmanager,\n modifiedClass: style.coorpmanagerModified\n };\n case 'newMooc':\n return {\n defaultClass: style.newMooc,\n modifiedClass: style.newMoocModified\n };\n case 'mooc':\n return {\n defaultClass: style.partielUncheck,\n modifiedClass: style.coorpmanagerModified\n };\n default:\n return {defaultClass: style.defaultStyle, modifiedClass: style.modified};\n }\n };\n const {defaultClass, modifiedClass} = getClass();\n const className = getClassState(defaultClass, modifiedClass, null, modified);\n\n return (\n <div className={className} data-name={`switch-input-${theme}${dataName}`}>\n {titlePosition === 'left' ? titleView : null}\n <div className={requiredSelection ? style.requiredSelection : null}>\n <div className={style.btnSwitchContainer}>\n <input\n {...(ariaLabelledBy ? {'aria-labelledby': ariaLabelledBy} : {})}\n {...(title ? {'aria-labelledby': `title-view-${dataName}`} : {})}\n {...(ariaLabel && !ariaLabelledBy && !title ? {'aria-label': ariaLabel} : {})}\n type=\"checkbox\"\n id={idSwitch}\n name={name}\n onChange={handleChange}\n checked={value}\n disabled={isDisabled}\n className={style.checkbox}\n aria-labelledby={ariaLabelledBy}\n />\n <label\n htmlFor={idSwitch}\n data-name=\"input-switch-label\"\n tabIndex={0}\n aria-label={ariaLabel}\n title={ariaLabel}\n style={value ? {background: primaryColor, borderColor: primaryColor} : null}\n />\n </div>\n </div>\n <div className={!details ? style.alignedTextContainer : null}>\n {titlePosition === 'right' ? titleView : null}\n {details ? <div className={style.detailsTxt}>{details}</div> : null}\n </div>\n {descriptionView}\n </div>\n );\n};\n\nInputSwitch.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n id: PropTypes.string,\n value: PropTypes.bool,\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n description: PropTypes.string,\n 'aria-labelledby': PropTypes.string,\n 'aria-label': PropTypes.string,\n modified: PropTypes.bool,\n titlePosition: PropTypes.oneOf(['right', 'left']),\n theme: PropTypes.oneOf(['default', 'coorpmanager', 'mooc', 'newMooc']),\n details: PropTypes.string,\n 'data-name': PropTypes.string,\n requiredSelection: PropTypes.bool,\n icon: PropTypes.string\n};\n\nInputSwitch.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nexport default InputSwitch;\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IAAGC,OAAO,QAAO,OAAO;AACpC,OAAOC,SAAS,MAAM,YAAY;AAElC,SAAQC,eAAe,QAAO,gCAAgC;AAC9D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,aAAa,MAAM,4BAA4B;AACtD,SAAQC,MAAM,QAAO,wBAAwB;AAC7C,OAAOC,QAAQ,MAAM,aAAa;AA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D,SAAS,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAG;EACtBxD,KAAK,EAAEV,SAAS,CAACmE,MAAM;EACvBxD,IAAI,EAAEX,SAAS,CAACmE,MAAM;EACtBvD,EAAE,EAAEZ,SAAS,CAACmE,MAAM;EACpBtD,KAAK,EAAEb,SAAS,CAACoE,IAAI;EACrBtD,QAAQ,EAAEd,SAAS,CAACoE,IAAI;EACxBrD,QAAQ,EAAEf,SAAS,CAACqE,IAAI;EACxBpD,WAAW,EAAEjB,SAAS,CAACmE,MAAM;EAC7B,iBAAiB,EAAEnE,SAAS,CAACmE,MAAM;EACnC,YAAY,EAAEnE,SAAS,CAACmE,MAAM;EAC9BjD,QAAQ,EAAElB,SAAS,CAACoE,IAAI;EACxBhD,aAAa,EAAEpB,SAAS,CAACsE,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;EACjDnD,KAAK,EAAEnB,SAAS,CAACsE,KAAK,CAAC,CAAC,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;EACtEjD,OAAO,EAAErB,SAAS,CAACmE,MAAM;EACzB,WAAW,EAAEnE,SAAS,CAACmE,MAAM;EAC7B7C,iBAAiB,EAAEtB,SAAS,CAACoE,IAAI;EACjC1C,IAAI,EAAE1B,SAAS,CAACmE;AAClB,CAAC;AAED5D,WAAW,CAACgE,YAAY,GAAG;EACzB5C,IAAI,EAAEtB,QAAQ,CAACmE,iBAAiB,CAAC7C;AACnC,CAAC;AAED,eAAepB,WAAW","ignoreList":[]}
|
package/es/atom/range/index.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ declare class Range extends React.Component<any, any, any> {
|
|
|
4
4
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
5
5
|
onChangeEnd: PropTypes.Requireable<(...args: any[]) => any>;
|
|
6
6
|
multi: PropTypes.Requireable<boolean>;
|
|
7
|
+
theme: PropTypes.Requireable<string>;
|
|
8
|
+
min: PropTypes.Requireable<number>;
|
|
9
|
+
max: PropTypes.Requireable<number>;
|
|
10
|
+
step: PropTypes.Requireable<number>;
|
|
11
|
+
minLabel: PropTypes.Requireable<string>;
|
|
12
|
+
maxLabel: PropTypes.Requireable<string>;
|
|
7
13
|
HammerForTestingMin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
8
14
|
on: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
15
|
destroy: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -14,17 +20,39 @@ declare class Range extends React.Component<any, any, any> {
|
|
|
14
20
|
destroy: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
21
|
stop: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
22
|
}>>;
|
|
17
|
-
|
|
23
|
+
};
|
|
24
|
+
static contextTypes: {
|
|
25
|
+
skin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
26
|
+
common: PropTypes.Requireable<{
|
|
27
|
+
[x: string]: any;
|
|
28
|
+
}>;
|
|
29
|
+
images: PropTypes.Requireable<PropTypes.InferProps<{
|
|
30
|
+
'logo-mobile': PropTypes.Requireable<any>;
|
|
31
|
+
logo: PropTypes.Requireable<any>;
|
|
32
|
+
'logo-email': PropTypes.Requireable<any>;
|
|
33
|
+
login: PropTypes.Requireable<any>;
|
|
34
|
+
}>>;
|
|
35
|
+
icons: PropTypes.Requireable<{
|
|
36
|
+
[x: string]: any;
|
|
37
|
+
}>;
|
|
38
|
+
mod: PropTypes.Requireable<{
|
|
39
|
+
[x: string]: any;
|
|
40
|
+
}>;
|
|
41
|
+
courses: PropTypes.Requireable<any[]>;
|
|
42
|
+
texts: PropTypes.Requireable<{
|
|
43
|
+
[x: string]: any;
|
|
44
|
+
}>;
|
|
45
|
+
}>>;
|
|
18
46
|
};
|
|
19
47
|
static getDerivedStateFromProps(props: any, state: any): {
|
|
20
48
|
multi: any;
|
|
21
|
-
value:
|
|
49
|
+
value: number | (number | number[])[];
|
|
22
50
|
} | null;
|
|
23
51
|
constructor(props: any, context: any);
|
|
24
52
|
state: {
|
|
25
53
|
pending: boolean;
|
|
26
54
|
multi: any;
|
|
27
|
-
value:
|
|
55
|
+
value: number | (number | number[])[];
|
|
28
56
|
};
|
|
29
57
|
handleClick(e: any): void;
|
|
30
58
|
setRefTrack(track: any): void;
|
|
@@ -33,6 +61,8 @@ declare class Range extends React.Component<any, any, any> {
|
|
|
33
61
|
handleMinChangeEnd(e: any): void;
|
|
34
62
|
handleMaxChangeEnd(e: any): void;
|
|
35
63
|
track: any;
|
|
64
|
+
normalizedToActual(normalizedValue: any): any;
|
|
65
|
+
roundToStep(value: any): number;
|
|
36
66
|
handleChange(value: any, valueIndex: any, pending: any): void;
|
|
37
67
|
triggerChange(newValues: any, pending: any): any;
|
|
38
68
|
render(): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/range/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/range/index.js"],"names":[],"mappings":";AAyFA;IACE;;;;;;;;;;;;;;;;;;;;MAYE;IAEF;;;;;;;;;;;;;;;;;;;;;;MAEE;IAEF;;;aAIC;IAED,sCAYC;IAVC;;;;MAGC;IAuEH,0BAkBC;IAhFD,8BAEC;IAYD,8BAKC;IAED,8BAKC;IAED,iCAKC;IAED,iCAKC;IAvCC,WAAkB;IAGpB,8CAGC;IAED,gCAGC;IA8BD,8DAWC;IAED,iDAKC;IAsBD,sBAmFC;CACF"}
|
package/es/atom/range/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import _getOr from "lodash/fp/getOr";
|
|
1
2
|
import _clamp from "lodash/fp/clamp";
|
|
2
3
|
import _set from "lodash/fp/set";
|
|
3
4
|
import _noop from "lodash/fp/noop";
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import PropTypes from 'prop-types';
|
|
7
|
+
import Provider from '../provider';
|
|
6
8
|
import Handle from './handle';
|
|
7
9
|
import style from './style.css';
|
|
8
10
|
const valueOnTrack = (track, x) => {
|
|
@@ -15,11 +17,20 @@ const valueOnTrack = (track, x) => {
|
|
|
15
17
|
const extractStateFromProps = props => {
|
|
16
18
|
const {
|
|
17
19
|
multi = false,
|
|
18
|
-
value = multi ? [0, 1] : 0
|
|
20
|
+
value = multi ? [0, 1] : 0,
|
|
21
|
+
min = 0,
|
|
22
|
+
max = 100
|
|
19
23
|
} = props;
|
|
24
|
+
const toNormalized = actualValue => (actualValue - min) / (max - min);
|
|
25
|
+
let normalizedValue;
|
|
26
|
+
if (multi) {
|
|
27
|
+
normalizedValue = Array.isArray(value) ? value.map(toNormalized) : [toNormalized(0), toNormalized(value)];
|
|
28
|
+
} else {
|
|
29
|
+
normalizedValue = toNormalized(value);
|
|
30
|
+
}
|
|
20
31
|
return {
|
|
21
32
|
multi,
|
|
22
|
-
value: multi ?
|
|
33
|
+
value: multi ? normalizedValue : [0, normalizedValue]
|
|
23
34
|
};
|
|
24
35
|
};
|
|
25
36
|
const RenderHandles = props => {
|
|
@@ -72,6 +83,9 @@ RenderHandles.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
72
83
|
HammerForTestingMax: Handle.propTypes.HammerForTesting
|
|
73
84
|
} : {};
|
|
74
85
|
class Range extends React.Component {
|
|
86
|
+
static contextTypes = {
|
|
87
|
+
skin: Provider.childContextTypes.skin
|
|
88
|
+
};
|
|
75
89
|
static getDerivedStateFromProps(props, state) {
|
|
76
90
|
const {
|
|
77
91
|
pending
|
|
@@ -95,6 +109,19 @@ class Range extends React.Component {
|
|
|
95
109
|
setRefTrack(track) {
|
|
96
110
|
this.track = track;
|
|
97
111
|
}
|
|
112
|
+
normalizedToActual(normalizedValue) {
|
|
113
|
+
const {
|
|
114
|
+
min = 0,
|
|
115
|
+
max = 100
|
|
116
|
+
} = this.props;
|
|
117
|
+
return min + normalizedValue * (max - min);
|
|
118
|
+
}
|
|
119
|
+
roundToStep(value) {
|
|
120
|
+
const {
|
|
121
|
+
step = 1
|
|
122
|
+
} = this.props;
|
|
123
|
+
return Math.round(value / step) * step;
|
|
124
|
+
}
|
|
98
125
|
handleMinChange(e) {
|
|
99
126
|
e.srcEvent.stopPropagation();
|
|
100
127
|
e.srcEvent.preventDefault();
|
|
@@ -139,7 +166,8 @@ class Range extends React.Component {
|
|
|
139
166
|
multi = false
|
|
140
167
|
} = this.props;
|
|
141
168
|
const handle = pending ? onChange : onChangeEnd;
|
|
142
|
-
|
|
169
|
+
const actualValues = newValues.map(val => this.roundToStep(this.normalizedToActual(val)));
|
|
170
|
+
return handle(multi ? actualValues : actualValues[1]);
|
|
143
171
|
}
|
|
144
172
|
handleClick(e) {
|
|
145
173
|
e.stopPropagation();
|
|
@@ -148,8 +176,7 @@ class Range extends React.Component {
|
|
|
148
176
|
value: [left, right],
|
|
149
177
|
multi
|
|
150
178
|
} = this.state;
|
|
151
|
-
const
|
|
152
|
-
const newValue = valueOnTrack(this.track, x);
|
|
179
|
+
const newValue = valueOnTrack(this.track, e.clientX);
|
|
153
180
|
if (!multi) return this.handleChange(newValue, 1, false);
|
|
154
181
|
if (left === right) {
|
|
155
182
|
const isClickToTheLeft = left - newValue > 0;
|
|
@@ -164,22 +191,30 @@ class Range extends React.Component {
|
|
|
164
191
|
value: [left, right],
|
|
165
192
|
pending
|
|
166
193
|
} = this.state;
|
|
194
|
+
const {
|
|
195
|
+
theme = 'default',
|
|
196
|
+
minLabel = 'Min',
|
|
197
|
+
maxLabel = 'Max',
|
|
198
|
+
HammerForTestingMin,
|
|
199
|
+
HammerForTestingMax
|
|
200
|
+
} = this.props;
|
|
167
201
|
const railWidth = right - left;
|
|
168
202
|
const railLeft = left;
|
|
169
|
-
const
|
|
170
|
-
|
|
203
|
+
const {
|
|
204
|
+
skin
|
|
205
|
+
} = this.context;
|
|
206
|
+
const primaryColor = _getOr('#00B0FF', 'common.primary', skin);
|
|
207
|
+
const railStyle = theme === 'mooc' ? {
|
|
208
|
+
backgroundColor: primaryColor,
|
|
209
|
+
width: `${railWidth * 100}%`,
|
|
210
|
+
left: `${railLeft * 100}%`
|
|
211
|
+
} : {
|
|
171
212
|
width: `${railWidth * 100}%`,
|
|
172
213
|
left: `${railLeft * 100}%`
|
|
173
214
|
};
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
} = this.props;
|
|
178
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
179
|
-
"data-testid": "slider",
|
|
180
|
-
className: style.containerWrapper,
|
|
181
|
-
onClick: this.handleClick
|
|
182
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
215
|
+
const minActualValue = this.roundToStep(this.normalizedToActual(left));
|
|
216
|
+
const maxActualValue = this.roundToStep(this.normalizedToActual(right));
|
|
217
|
+
const sliderComponent = /*#__PURE__*/React.createElement("div", {
|
|
183
218
|
className: style.container
|
|
184
219
|
}, /*#__PURE__*/React.createElement("div", {
|
|
185
220
|
"data-testid": "track",
|
|
@@ -200,17 +235,50 @@ class Range extends React.Component {
|
|
|
200
235
|
onHandleMinChangeEnd: this.handleMinChangeEnd,
|
|
201
236
|
onHandleMaxChange: this.handleMaxChange,
|
|
202
237
|
onHandleMaxChangeEnd: this.handleMaxChangeEnd
|
|
203
|
-
}))
|
|
238
|
+
}));
|
|
239
|
+
if (theme === 'mooc') {
|
|
240
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
241
|
+
"data-testid": "slider",
|
|
242
|
+
className: style.containerWrapper
|
|
243
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
onClick: this.handleClick
|
|
245
|
+
}, sliderComponent), /*#__PURE__*/React.createElement("div", {
|
|
246
|
+
className: style.inputsRow
|
|
247
|
+
}, multi ? /*#__PURE__*/React.createElement("div", {
|
|
248
|
+
className: style.moocInput,
|
|
249
|
+
"data-testid": "min-value"
|
|
250
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
251
|
+
className: style.inputHint
|
|
252
|
+
}, minLabel), /*#__PURE__*/React.createElement("span", {
|
|
253
|
+
className: style.inputValue
|
|
254
|
+
}, minActualValue)) : null, /*#__PURE__*/React.createElement("div", {
|
|
255
|
+
className: style.moocInput,
|
|
256
|
+
"data-testid": "max-value"
|
|
257
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
258
|
+
className: style.inputHint
|
|
259
|
+
}, maxLabel), /*#__PURE__*/React.createElement("span", {
|
|
260
|
+
className: style.inputValue
|
|
261
|
+
}, maxActualValue))));
|
|
262
|
+
}
|
|
263
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
264
|
+
"data-testid": "slider",
|
|
265
|
+
className: style.containerWrapper,
|
|
266
|
+
onClick: this.handleClick
|
|
267
|
+
}, sliderComponent);
|
|
204
268
|
}
|
|
205
269
|
}
|
|
206
270
|
Range.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
207
271
|
onChange: PropTypes.func,
|
|
208
272
|
onChangeEnd: PropTypes.func,
|
|
209
273
|
multi: PropTypes.bool,
|
|
274
|
+
theme: PropTypes.oneOf(['default', 'mooc']),
|
|
275
|
+
min: PropTypes.number,
|
|
276
|
+
max: PropTypes.number,
|
|
277
|
+
step: PropTypes.number,
|
|
278
|
+
minLabel: PropTypes.string,
|
|
279
|
+
maxLabel: PropTypes.string,
|
|
210
280
|
HammerForTestingMin: RenderHandles.propTypes.HammerForTestingMin,
|
|
211
|
-
HammerForTestingMax: RenderHandles.propTypes.HammerForTestingMax
|
|
212
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
213
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)])
|
|
281
|
+
HammerForTestingMax: RenderHandles.propTypes.HammerForTestingMax
|
|
214
282
|
} : {};
|
|
215
283
|
export default Range;
|
|
216
284
|
//# sourceMappingURL=index.js.map
|