@coorpacademy/components 11.10.3 → 11.10.4-alpha.1
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/input-switch/index.js +2 -1
- package/es/atom/input-switch/index.js.map +1 -1
- package/es/atom/link/index.d.ts +7 -15
- package/es/atom/link/index.d.ts.map +1 -1
- package/es/atom/link/index.js +71 -97
- package/es/atom/link/index.js.map +1 -1
- package/es/atom/tooltip/index.d.ts +7 -1
- package/es/atom/tooltip/index.d.ts.map +1 -1
- package/es/atom/tooltip/index.js +39 -14
- package/es/atom/tooltip/index.js.map +1 -1
- package/es/atom/tooltip/style.css +9 -0
- package/es/organism/user-preferences/index.d.ts.map +1 -1
- package/es/organism/user-preferences/index.js +20 -19
- package/es/organism/user-preferences/index.js.map +1 -1
- package/es/organism/user-preferences/style.css +5 -56
- package/es/organism/wizard-contents/index.d.ts +2 -2
- package/es/organism/wizard-contents/index.d.ts.map +1 -1
- package/es/organism/wizard-contents/index.js +32 -13
- package/es/organism/wizard-contents/index.js.map +1 -1
- package/es/organism/wizard-contents/style.css +46 -6
- package/es/template/activity/progression-item.d.ts +1 -1
- package/es/template/activity/progression-item.d.ts.map +1 -1
- package/es/template/activity/progression-item.js +3 -5
- package/es/template/activity/progression-item.js.map +1 -1
- package/es/template/back-office/brand-update/index.d.ts +2 -2
- package/lib/atom/input-switch/index.js +2 -1
- package/lib/atom/input-switch/index.js.map +1 -1
- package/lib/atom/link/index.d.ts +7 -15
- package/lib/atom/link/index.d.ts.map +1 -1
- package/lib/atom/link/index.js +75 -97
- package/lib/atom/link/index.js.map +1 -1
- package/lib/atom/tooltip/index.d.ts +7 -1
- package/lib/atom/tooltip/index.d.ts.map +1 -1
- package/lib/atom/tooltip/index.js +41 -14
- package/lib/atom/tooltip/index.js.map +1 -1
- package/lib/atom/tooltip/style.css +9 -0
- package/lib/organism/user-preferences/index.d.ts.map +1 -1
- package/lib/organism/user-preferences/index.js +23 -21
- package/lib/organism/user-preferences/index.js.map +1 -1
- package/lib/organism/user-preferences/style.css +5 -56
- package/lib/organism/wizard-contents/index.d.ts +2 -2
- package/lib/organism/wizard-contents/index.d.ts.map +1 -1
- package/lib/organism/wizard-contents/index.js +34 -13
- package/lib/organism/wizard-contents/index.js.map +1 -1
- package/lib/organism/wizard-contents/style.css +46 -6
- package/lib/template/activity/progression-item.d.ts +1 -1
- package/lib/template/activity/progression-item.d.ts.map +1 -1
- package/lib/template/activity/progression-item.js +3 -5
- package/lib/template/activity/progression-item.js.map +1 -1
- package/lib/template/back-office/brand-update/index.d.ts +2 -2
- package/package.json +2 -2
package/lib/atom/link/index.js
CHANGED
|
@@ -9,118 +9,92 @@ var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
|
|
|
9
9
|
|
|
10
10
|
var _identity2 = _interopRequireDefault(require("lodash/fp/identity"));
|
|
11
11
|
|
|
12
|
-
var _react =
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
15
|
|
|
16
|
-
var _provider =
|
|
16
|
+
var _provider = _interopRequireWildcard(require("../provider"));
|
|
17
17
|
|
|
18
18
|
var _navigation = _interopRequireDefault(require("../../util/navigation"));
|
|
19
19
|
|
|
20
20
|
const _excluded = ["skinHover", "hoverColor", "data-name", "aria-label"];
|
|
21
21
|
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
22
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
27
|
|
|
24
28
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
25
29
|
|
|
26
30
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
children
|
|
93
|
-
} = this.props;
|
|
94
|
-
const {
|
|
95
|
-
hovered
|
|
96
|
-
} = this.state;
|
|
97
|
-
|
|
98
|
-
const _style = href || onClick ? null : {
|
|
99
|
-
pointerEvents: 'none'
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const _hoverStyle = skinHover && hovered ? {
|
|
103
|
-
color: hoverColor
|
|
104
|
-
} : null;
|
|
105
|
-
|
|
106
|
-
return /*#__PURE__*/_react.default.createElement("a", _extends({}, aProps, {
|
|
107
|
-
"data-name": dataName,
|
|
108
|
-
"aria-label": ariaLabel,
|
|
109
|
-
href: href ? createHref(href) : undefined,
|
|
110
|
-
onClick: this.handleOnClick,
|
|
111
|
-
onMouseEnter: this.handleMouseEnter,
|
|
112
|
-
onMouseLeave: this.handleMouseLeave,
|
|
113
|
-
className: className,
|
|
114
|
-
style: _extends({}, propsStyle, _style, _hoverStyle)
|
|
115
|
-
}), children);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
Link.contextTypes = {
|
|
121
|
-
skin: _provider.default.childContextTypes.skin,
|
|
122
|
-
history: _provider.default.childContextTypes.history
|
|
32
|
+
const Link = (props, legacyContext) => {
|
|
33
|
+
const skin = (0, _provider.GetSkinFromContext)(legacyContext);
|
|
34
|
+
const [hovered, setHovered] = (0, _react.useState)(false);
|
|
35
|
+
const {
|
|
36
|
+
history: {
|
|
37
|
+
createHref = _identity2.default
|
|
38
|
+
} = {}
|
|
39
|
+
} = legacyContext;
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
skinHover,
|
|
43
|
+
hoverColor = (0, _getOr2.default)('#00B0FF', 'common.primary', skin),
|
|
44
|
+
'data-name': dataName = 'link',
|
|
45
|
+
'aria-label': ariaLabel
|
|
46
|
+
} = props,
|
|
47
|
+
linKElementProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
href,
|
|
51
|
+
onClick = _noop2.default,
|
|
52
|
+
className,
|
|
53
|
+
style: propsStyle,
|
|
54
|
+
children,
|
|
55
|
+
onMouseLeave = _noop2.default,
|
|
56
|
+
onMouseEnter = _noop2.default,
|
|
57
|
+
download
|
|
58
|
+
} = props;
|
|
59
|
+
const handleMouseEnter = (0, _react.useCallback)(() => {
|
|
60
|
+
setHovered(true);
|
|
61
|
+
onMouseEnter();
|
|
62
|
+
}, [onMouseEnter]);
|
|
63
|
+
const handleMouseLeave = (0, _react.useCallback)(() => {
|
|
64
|
+
setHovered(false);
|
|
65
|
+
onMouseLeave();
|
|
66
|
+
}, [onMouseLeave]);
|
|
67
|
+
const navigate = (0, _react.useMemo)(() => (0, _navigation.default)(legacyContext)({
|
|
68
|
+
href
|
|
69
|
+
}), [href, legacyContext]);
|
|
70
|
+
const handleOnClick = (0, _react.useCallback)(e => {
|
|
71
|
+
onClick(e);
|
|
72
|
+
|
|
73
|
+
if (!download) {
|
|
74
|
+
navigate(e);
|
|
75
|
+
}
|
|
76
|
+
}, [download, navigate, onClick]);
|
|
77
|
+
|
|
78
|
+
const _style = href || onClick ? null : {
|
|
79
|
+
pointerEvents: 'none'
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const _hoverStyle = skinHover && hovered ? {
|
|
83
|
+
color: hoverColor
|
|
84
|
+
} : null;
|
|
85
|
+
|
|
86
|
+
return /*#__PURE__*/_react.default.createElement("a", _extends({}, linKElementProps, {
|
|
87
|
+
"data-name": dataName,
|
|
88
|
+
"aria-label": ariaLabel,
|
|
89
|
+
href: href ? createHref(href) : undefined,
|
|
90
|
+
onClick: handleOnClick,
|
|
91
|
+
onMouseEnter: handleMouseEnter,
|
|
92
|
+
onMouseLeave: handleMouseLeave,
|
|
93
|
+
className: className,
|
|
94
|
+
style: _extends({}, propsStyle, _style, _hoverStyle)
|
|
95
|
+
}), children);
|
|
123
96
|
};
|
|
97
|
+
|
|
124
98
|
Link.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
125
99
|
children: _propTypes.default.node,
|
|
126
100
|
className: _propTypes.default.string,
|
|
@@ -136,6 +110,10 @@ Link.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
136
110
|
onMouseLeave: _propTypes.default.func,
|
|
137
111
|
style: _propTypes.default.shape({})
|
|
138
112
|
} : {};
|
|
113
|
+
Link.contextTypes = {
|
|
114
|
+
skin: _provider.default.childContextTypes.skin,
|
|
115
|
+
history: _provider.default.childContextTypes.history
|
|
116
|
+
};
|
|
139
117
|
var _default = Link;
|
|
140
118
|
exports.default = _default;
|
|
141
119
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Link","
|
|
1
|
+
{"version":3,"file":"index.js","names":["Link","props","legacyContext","skin","GetSkinFromContext","hovered","setHovered","useState","history","createHref","skinHover","hoverColor","dataName","ariaLabel","linKElementProps","href","onClick","className","style","propsStyle","children","onMouseLeave","onMouseEnter","download","handleMouseEnter","useCallback","handleMouseLeave","navigate","useMemo","pushToHistory","handleOnClick","e","_style","pointerEvents","_hoverStyle","color","undefined","propTypes","PropTypes","node","string","target","oneOf","bool","func","shape","contextTypes","Provider","childContextTypes"],"sources":["../../../src/atom/link/index.js"],"sourcesContent":["import React, {useCallback, useMemo, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport {identity, getOr, noop} from 'lodash/fp';\nimport Provider, {GetSkinFromContext} from '../provider';\nimport pushToHistory from '../../util/navigation';\n\nconst Link = (props, legacyContext) => {\n const skin = GetSkinFromContext(legacyContext);\n const [hovered, setHovered] = useState(false);\n const {history: {createHref = identity} = {}} = legacyContext;\n const {\n skinHover,\n hoverColor = getOr('#00B0FF', 'common.primary', skin),\n 'data-name': dataName = 'link',\n 'aria-label': ariaLabel,\n ...linKElementProps\n } = props;\n const {\n href,\n onClick = noop,\n className,\n style: propsStyle,\n children,\n onMouseLeave = noop,\n onMouseEnter = noop,\n download\n } = props;\n\n const handleMouseEnter = useCallback(() => {\n setHovered(true);\n\n onMouseEnter();\n }, [onMouseEnter]);\n\n const handleMouseLeave = useCallback(() => {\n setHovered(false);\n\n onMouseLeave();\n }, [onMouseLeave]);\n\n const navigate = useMemo(() => pushToHistory(legacyContext)({href}), [href, legacyContext]);\n\n const handleOnClick = useCallback(\n e => {\n onClick(e);\n\n if (!download) {\n navigate(e);\n }\n },\n [download, navigate, onClick]\n );\n\n const _style =\n href || onClick\n ? null\n : {\n pointerEvents: 'none'\n };\n const _hoverStyle =\n skinHover && hovered\n ? {\n color: hoverColor\n }\n : null;\n\n return (\n <a\n {...linKElementProps}\n data-name={dataName}\n aria-label={ariaLabel}\n href={href ? createHref(href) : undefined}\n onClick={handleOnClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n className={className}\n style={{\n ...propsStyle,\n ..._style,\n ..._hoverStyle\n }}\n >\n {children}\n </a>\n );\n};\n\nLink.propTypes = {\n children: PropTypes.node,\n className: PropTypes.string,\n href: PropTypes.string,\n 'data-name': PropTypes.string,\n 'aria-label': PropTypes.string,\n target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),\n skinHover: PropTypes.bool,\n hoverColor: PropTypes.string,\n download: PropTypes.bool,\n onClick: PropTypes.func,\n onMouseEnter: PropTypes.func,\n onMouseLeave: PropTypes.func,\n style: PropTypes.shape({})\n};\n\nLink.contextTypes = {\n skin: Provider.childContextTypes.skin,\n history: Provider.childContextTypes.history\n};\n\nexport default Link;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;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V,CAAgB,EAAhB;AAbQ,CAAjB;AAgBA7C,IAAI,CAAC8C,YAAL,GAAoB;EAClB3C,IAAI,EAAE4C,iBAAA,CAASC,iBAAT,CAA2B7C,IADf;EAElBK,OAAO,EAAEuC,iBAAA,CAASC,iBAAT,CAA2BxC;AAFlB,CAApB;eAKeR,I"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export function toggleStateOnKeyPress(state: any, setState: any, ref: any): (event: any) => void;
|
|
2
2
|
export default ToolTip;
|
|
3
|
-
declare function ToolTip({ anchorId, TooltipContent, "aria-label": ariaLabel, "data-testid": dataTestId, closeToolTipInformationTextAriaLabel, toolTipIsVisible: _toolTipIsVisible }: {
|
|
3
|
+
declare function ToolTip({ anchorId, TooltipContent, "aria-label": ariaLabel, "data-testid": dataTestId, closeToolTipInformationTextAriaLabel, toolTipIsVisible: _toolTipIsVisible, iconContainerClassName, delayHide, fontSize }: {
|
|
4
4
|
anchorId: any;
|
|
5
5
|
TooltipContent: any;
|
|
6
6
|
"aria-label": any;
|
|
7
7
|
"data-testid": any;
|
|
8
8
|
closeToolTipInformationTextAriaLabel: any;
|
|
9
9
|
toolTipIsVisible: any;
|
|
10
|
+
iconContainerClassName: any;
|
|
11
|
+
delayHide?: number | undefined;
|
|
12
|
+
fontSize?: number | undefined;
|
|
10
13
|
}): JSX.Element;
|
|
11
14
|
declare namespace ToolTip {
|
|
12
15
|
const propTypes: {
|
|
@@ -14,6 +17,9 @@ declare namespace ToolTip {
|
|
|
14
17
|
'data-testid': PropTypes.Requireable<string>;
|
|
15
18
|
'aria-label': PropTypes.Requireable<string>;
|
|
16
19
|
closeToolTipInformationTextAriaLabel: PropTypes.Validator<string>;
|
|
20
|
+
iconContainerClassName: PropTypes.Requireable<string>;
|
|
21
|
+
delayHide: PropTypes.Requireable<number>;
|
|
22
|
+
fontSize: PropTypes.Requireable<number>;
|
|
17
23
|
anchorId: PropTypes.Requireable<string>;
|
|
18
24
|
toolTipIsVisible: PropTypes.Requireable<boolean>;
|
|
19
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/tooltip/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/tooltip/index.js"],"names":[],"mappings":"AAwDO,iGASN;;AAED;;;;;;;;;;gBAwFC"}
|
|
@@ -5,6 +5,8 @@ exports.toggleStateOnKeyPress = exports.default = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
|
|
8
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
11
|
|
|
10
12
|
var _reactTooltip = _interopRequireDefault(require("react-tooltip"));
|
|
@@ -21,11 +23,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
21
23
|
|
|
22
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
25
|
|
|
26
|
+
const FontSizes = {
|
|
27
|
+
12: _style.default.tooltipContentFontSize12,
|
|
28
|
+
14: _style.default.tooltipContentFontSize14
|
|
29
|
+
};
|
|
30
|
+
|
|
24
31
|
const ToolTipWrapper = ({
|
|
25
32
|
toolTipIsVisible,
|
|
26
33
|
anchorId,
|
|
27
34
|
closeToolTipInformationTextAriaLabel,
|
|
28
|
-
content
|
|
35
|
+
content,
|
|
36
|
+
handleContentMouseOver
|
|
29
37
|
}) => {
|
|
30
38
|
if (!toolTipIsVisible) return null;
|
|
31
39
|
|
|
@@ -42,7 +50,8 @@ const ToolTipWrapper = ({
|
|
|
42
50
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
43
51
|
className: _style.default.toolTip,
|
|
44
52
|
"data-testid": "tooltip",
|
|
45
|
-
"aria-label": closeToolTipInformationTextAriaLabel
|
|
53
|
+
"aria-label": closeToolTipInformationTextAriaLabel,
|
|
54
|
+
onMouseOver: handleContentMouseOver
|
|
46
55
|
}, content);
|
|
47
56
|
}
|
|
48
57
|
};
|
|
@@ -51,7 +60,8 @@ ToolTipWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
51
60
|
toolTipIsVisible: _propTypes.default.bool,
|
|
52
61
|
anchorId: _propTypes.default.string,
|
|
53
62
|
closeToolTipInformationTextAriaLabel: _propTypes.default.string.isRequired,
|
|
54
|
-
content: _propTypes.default.node
|
|
63
|
+
content: _propTypes.default.node,
|
|
64
|
+
handleContentMouseOver: _propTypes.default.func
|
|
55
65
|
} : {};
|
|
56
66
|
|
|
57
67
|
const toggleStateOnKeyPress = (state, setState, ref) => event => {
|
|
@@ -73,38 +83,49 @@ const ToolTip = ({
|
|
|
73
83
|
'aria-label': ariaLabel,
|
|
74
84
|
'data-testid': dataTestId,
|
|
75
85
|
closeToolTipInformationTextAriaLabel,
|
|
76
|
-
toolTipIsVisible: _toolTipIsVisible
|
|
86
|
+
toolTipIsVisible: _toolTipIsVisible,
|
|
87
|
+
iconContainerClassName,
|
|
88
|
+
delayHide = 250,
|
|
89
|
+
fontSize = 14
|
|
77
90
|
}) => {
|
|
78
91
|
const isComponent = (0, _react.useMemo)(() => !(0, _isString.default)(TooltipContent) && /*#__PURE__*/(0, _react.isValidElement)(TooltipContent()), [TooltipContent]);
|
|
79
92
|
const [toolTipIsVisible, setToolTipIsVisible] = (0, _react.useState)(false);
|
|
93
|
+
const [mouseLeaveTimer, setMouseLeaveTimer] = (0, _react.useState)(undefined);
|
|
80
94
|
const handleKeyPress = (0, _react.useCallback)(event => {
|
|
81
95
|
toggleStateOnKeyPress(toolTipIsVisible, setToolTipIsVisible)(event);
|
|
82
96
|
}, [toolTipIsVisible]);
|
|
97
|
+
const handleContentMouseOver = (0, _react.useCallback)(() => {
|
|
98
|
+
mouseLeaveTimer &&
|
|
99
|
+
/* istanbul ignore next */
|
|
100
|
+
clearTimeout(mouseLeaveTimer);
|
|
101
|
+
}, [mouseLeaveTimer]);
|
|
83
102
|
const handleMouseOver = (0, _react.useCallback)(() => {
|
|
103
|
+
mouseLeaveTimer && clearTimeout(mouseLeaveTimer);
|
|
84
104
|
setToolTipIsVisible(true);
|
|
85
|
-
}, []);
|
|
105
|
+
}, [mouseLeaveTimer]);
|
|
86
106
|
const handleMouseLeave = (0, _react.useCallback)(() => {
|
|
87
|
-
setToolTipIsVisible(false);
|
|
88
|
-
}, []);
|
|
107
|
+
setMouseLeaveTimer(setTimeout(() => setToolTipIsVisible(false), delayHide));
|
|
108
|
+
}, [delayHide]);
|
|
89
109
|
const content = (0, _react.useMemo)(() => {
|
|
90
110
|
return isComponent ? /*#__PURE__*/_react.default.createElement(TooltipContent, null) : /*#__PURE__*/_react.default.createElement("p", {
|
|
91
|
-
className: _style.default.tooltipContent
|
|
111
|
+
className: (0, _classnames.default)([_style.default.tooltipContent, FontSizes[fontSize]])
|
|
92
112
|
}, TooltipContent);
|
|
93
|
-
}, [TooltipContent, isComponent]);
|
|
113
|
+
}, [TooltipContent, fontSize, isComponent]);
|
|
94
114
|
return anchorId ? /*#__PURE__*/_react.default.createElement(ToolTipWrapper, {
|
|
95
115
|
toolTipIsVisible: _toolTipIsVisible,
|
|
96
116
|
anchorId: anchorId,
|
|
97
117
|
closeToolTipInformationTextAriaLabel: closeToolTipInformationTextAriaLabel,
|
|
98
118
|
content: content,
|
|
99
119
|
onMouseLeave: handleMouseLeave,
|
|
100
|
-
onMouseOver: handleMouseOver
|
|
120
|
+
onMouseOver: handleMouseOver,
|
|
121
|
+
fontSize: fontSize
|
|
101
122
|
}) : /*#__PURE__*/_react.default.createElement("div", {
|
|
102
123
|
className: _style.default.tooltipContainer,
|
|
103
124
|
onMouseLeave: handleMouseLeave,
|
|
104
125
|
onMouseOver: handleMouseOver
|
|
105
126
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
106
127
|
type: "button",
|
|
107
|
-
className: _style.default.tooltipIconContainer,
|
|
128
|
+
className: (0, _classnames.default)([_style.default.tooltipIconContainer, iconContainerClassName]),
|
|
108
129
|
"data-testid": dataTestId,
|
|
109
130
|
onKeyDown: handleKeyPress,
|
|
110
131
|
tabIndex: 0
|
|
@@ -117,7 +138,9 @@ const ToolTip = ({
|
|
|
117
138
|
toolTipIsVisible: toolTipIsVisible,
|
|
118
139
|
anchorId: anchorId,
|
|
119
140
|
closeToolTipInformationTextAriaLabel: closeToolTipInformationTextAriaLabel,
|
|
120
|
-
content: content
|
|
141
|
+
content: content,
|
|
142
|
+
handleContentMouseOver: handleContentMouseOver,
|
|
143
|
+
fontSize: fontSize
|
|
121
144
|
}));
|
|
122
145
|
};
|
|
123
146
|
|
|
@@ -126,8 +149,12 @@ ToolTip.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
126
149
|
'data-testid': _propTypes.default.string,
|
|
127
150
|
'aria-label': _propTypes.default.string,
|
|
128
151
|
closeToolTipInformationTextAriaLabel: _propTypes.default.string.isRequired,
|
|
129
|
-
// ----------
|
|
130
|
-
|
|
152
|
+
// ---------- Regular Tooltip exclusive --------------
|
|
153
|
+
iconContainerClassName: _propTypes.default.string,
|
|
154
|
+
delayHide: _propTypes.default.number,
|
|
155
|
+
fontSize: _propTypes.default.oneOf([12, 14]),
|
|
156
|
+
// ---------- React Tooltip exclusive --------------
|
|
157
|
+
// externalHandling: if passed down, React Tooltip is used instead, due to limitations on
|
|
131
158
|
// parents overflow hidden controls
|
|
132
159
|
anchorId: _propTypes.default.string,
|
|
133
160
|
toolTipIsVisible: _propTypes.default.bool
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ToolTipWrapper","toolTipIsVisible","anchorId","closeToolTipInformationTextAriaLabel","content","style","toolTipReact","toolTip","propTypes","PropTypes","bool","string","isRequired","node","toggleStateOnKeyPress","state","setState","ref","event","key","current","focus","stopPropagation","preventDefault","ToolTip","TooltipContent","ariaLabel","dataTestId","_toolTipIsVisible","isComponent","useMemo","isString","isValidElement","setToolTipIsVisible","useState","handleKeyPress","useCallback","handleMouseOver","handleMouseLeave","tooltipContent","tooltipContainer","tooltipIconContainer","informationIcon","oneOfType","func"],"sources":["../../../src/atom/tooltip/index.js"],"sourcesContent":["import React, {isValidElement, useState, useCallback, useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport ReactTooltip from 'react-tooltip';\nimport isString from 'lodash/fp/isString';\nimport {NovaCompositionCoorpacademyInformationIcon as InformationIcon} from '@coorpacademy/nova-icons';\nimport style from './style.css';\n\nconst ToolTipWrapper = ({\n toolTipIsVisible,\n anchorId,\n closeToolTipInformationTextAriaLabel,\n content\n}) => {\n if (!toolTipIsVisible) return null;\n if (anchorId) {\n return (\n <ReactTooltip\n id={anchorId}\n className={style.toolTipReact}\n data-event-off=\"click\"\n place=\"left\"\n effect=\"solid\"\n aria-label={closeToolTipInformationTextAriaLabel}\n >\n {content}\n </ReactTooltip>\n );\n } else {\n return (\n <div\n className={style.toolTip}\n data-testid=\"tooltip\"\n aria-label={closeToolTipInformationTextAriaLabel}\n >\n {content}\n </div>\n );\n }\n};\n\nToolTipWrapper.propTypes = {\n toolTipIsVisible: PropTypes.bool,\n anchorId: PropTypes.string,\n closeToolTipInformationTextAriaLabel: PropTypes.string.isRequired,\n content: PropTypes.node\n};\n\nexport const toggleStateOnKeyPress = (state, setState, ref) => event => {\n if (event.key === 'Enter') {\n if (ref) ref.current.focus();\n event.stopPropagation();\n event.preventDefault();\n setState(!state);\n } else if (event.key === 'Tab' || event.key === 'Escape') {\n setState(false);\n }\n};\n\nconst ToolTip = ({\n anchorId,\n TooltipContent,\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n closeToolTipInformationTextAriaLabel,\n toolTipIsVisible: _toolTipIsVisible\n}) => {\n const isComponent = useMemo(\n () => !isString(TooltipContent) && isValidElement(TooltipContent()),\n [TooltipContent]\n );\n\n const [toolTipIsVisible, setToolTipIsVisible] = useState(false);\n\n const handleKeyPress = useCallback(\n event => {\n toggleStateOnKeyPress(toolTipIsVisible, setToolTipIsVisible)(event);\n },\n [toolTipIsVisible]\n );\n\n const handleMouseOver = useCallback(() => {\n setToolTipIsVisible(true);\n }, []);\n\n const handleMouseLeave = useCallback(() => {\n setToolTipIsVisible(false);\n }, []);\n\n const content = useMemo(() => {\n return isComponent ? (\n <TooltipContent />\n ) : (\n <p className={style.tooltipContent}>{TooltipContent}</p>\n );\n }, [TooltipContent, isComponent]);\n\n return anchorId ? (\n <ToolTipWrapper\n toolTipIsVisible={_toolTipIsVisible}\n anchorId={anchorId}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n content={content}\n onMouseLeave={handleMouseLeave}\n onMouseOver={handleMouseOver}\n />\n ) : (\n <div\n className={style.tooltipContainer}\n onMouseLeave={handleMouseLeave}\n onMouseOver={handleMouseOver}\n >\n <button\n type=\"button\"\n className={style.tooltipIconContainer}\n data-testid={dataTestId}\n onKeyDown={handleKeyPress}\n tabIndex={0}\n >\n <InformationIcon\n className={style.informationIcon}\n width={12}\n height={12}\n aria-label={ariaLabel}\n />\n </button>\n <ToolTipWrapper\n toolTipIsVisible={toolTipIsVisible}\n anchorId={anchorId}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n content={content}\n />\n </div>\n );\n};\n\nToolTip.propTypes = {\n TooltipContent: PropTypes.oneOfType([PropTypes.func, PropTypes.node, PropTypes.string]),\n 'data-testid': PropTypes.string,\n 'aria-label': PropTypes.string,\n closeToolTipInformationTextAriaLabel: PropTypes.string.isRequired,\n // ---------- externalHandling --------------\n // if passed down, React Tooltip is used instead, due to limitations on\n // parents overflow hidden controls\n anchorId: PropTypes.string,\n toolTipIsVisible: PropTypes.bool\n};\n\nexport default ToolTip;\n"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,MAAMA,cAAc,GAAG,CAAC;EACtBC,gBADsB;EAEtBC,QAFsB;EAGtBC,oCAHsB;EAItBC;AAJsB,CAAD,KAKjB;EACJ,IAAI,CAACH,gBAAL,EAAuB,OAAO,IAAP;;EACvB,IAAIC,QAAJ,EAAc;IACZ,oBACE,6BAAC,qBAAD;MACE,EAAE,EAAEA,QADN;MAEE,SAAS,EAAEG,cAAA,CAAMC,YAFnB;MAGE,kBAAe,OAHjB;MAIE,KAAK,EAAC,MAJR;MAKE,MAAM,EAAC,OALT;MAME,cAAYH;IANd,GAQGC,OARH,CADF;EAYD,CAbD,MAaO;IACL,oBACE;MACE,SAAS,EAAEC,cAAA,CAAME,OADnB;MAEE,eAAY,SAFd;MAGE,cAAYJ;IAHd,GAKGC,OALH,CADF;EASD;AACF,CA/BD;;AAiCAJ,cAAc,CAACQ,SAAf,2CAA2B;EACzBP,gBAAgB,EAAEQ,kBAAA,CAAUC,IADH;EAEzBR,QAAQ,EAAEO,kBAAA,CAAUE,MAFK;EAGzBR,oCAAoC,EAAEM,kBAAA,CAAUE,MAAV,CAAiBC,UAH9B;EAIzBR,OAAO,EAAEK,kBAAA,CAAUI;AAJM,CAA3B;;AAOO,MAAMC,qBAAqB,GAAG,CAACC,KAAD,EAAQC,QAAR,EAAkBC,GAAlB,KAA0BC,KAAK,IAAI;EACtE,IAAIA,KAAK,CAACC,GAAN,KAAc,OAAlB,EAA2B;IACzB,IAAIF,GAAJ,EAASA,GAAG,CAACG,OAAJ,CAAYC,KAAZ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ApB;eAYec,O"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["FontSizes","style","tooltipContentFontSize12","tooltipContentFontSize14","ToolTipWrapper","toolTipIsVisible","anchorId","closeToolTipInformationTextAriaLabel","content","handleContentMouseOver","toolTipReact","toolTip","propTypes","PropTypes","bool","string","isRequired","node","func","toggleStateOnKeyPress","state","setState","ref","event","key","current","focus","stopPropagation","preventDefault","ToolTip","TooltipContent","ariaLabel","dataTestId","_toolTipIsVisible","iconContainerClassName","delayHide","fontSize","isComponent","useMemo","isString","isValidElement","setToolTipIsVisible","useState","mouseLeaveTimer","setMouseLeaveTimer","undefined","handleKeyPress","useCallback","clearTimeout","handleMouseOver","handleMouseLeave","setTimeout","classnames","tooltipContent","tooltipContainer","tooltipIconContainer","informationIcon","oneOfType","number","oneOf"],"sources":["../../../src/atom/tooltip/index.js"],"sourcesContent":["import React, {isValidElement, useState, useCallback, useMemo} from 'react';\nimport classnames from 'classnames';\nimport PropTypes from 'prop-types';\nimport ReactTooltip from 'react-tooltip';\nimport isString from 'lodash/fp/isString';\nimport {NovaCompositionCoorpacademyInformationIcon as InformationIcon} from '@coorpacademy/nova-icons';\nimport style from './style.css';\n\nconst FontSizes = {\n 12: style.tooltipContentFontSize12,\n 14: style.tooltipContentFontSize14\n};\n\nconst ToolTipWrapper = ({\n toolTipIsVisible,\n anchorId,\n closeToolTipInformationTextAriaLabel,\n content,\n handleContentMouseOver\n}) => {\n if (!toolTipIsVisible) return null;\n if (anchorId) {\n return (\n <ReactTooltip\n id={anchorId}\n className={style.toolTipReact}\n data-event-off=\"click\"\n place=\"left\"\n effect=\"solid\"\n aria-label={closeToolTipInformationTextAriaLabel}\n >\n {content}\n </ReactTooltip>\n );\n } else {\n return (\n <div\n className={style.toolTip}\n data-testid=\"tooltip\"\n aria-label={closeToolTipInformationTextAriaLabel}\n onMouseOver={handleContentMouseOver}\n >\n {content}\n </div>\n );\n }\n};\n\nToolTipWrapper.propTypes = {\n toolTipIsVisible: PropTypes.bool,\n anchorId: PropTypes.string,\n closeToolTipInformationTextAriaLabel: PropTypes.string.isRequired,\n content: PropTypes.node,\n handleContentMouseOver: PropTypes.func\n};\n\nexport const toggleStateOnKeyPress = (state, setState, ref) => event => {\n if (event.key === 'Enter') {\n if (ref) ref.current.focus();\n event.stopPropagation();\n event.preventDefault();\n setState(!state);\n } else if (event.key === 'Tab' || event.key === 'Escape') {\n setState(false);\n }\n};\n\nconst ToolTip = ({\n anchorId,\n TooltipContent,\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n closeToolTipInformationTextAriaLabel,\n toolTipIsVisible: _toolTipIsVisible,\n iconContainerClassName,\n delayHide = 250,\n fontSize = 14\n}) => {\n const isComponent = useMemo(\n () => !isString(TooltipContent) && isValidElement(TooltipContent()),\n [TooltipContent]\n );\n\n const [toolTipIsVisible, setToolTipIsVisible] = useState(false);\n\n const [mouseLeaveTimer, setMouseLeaveTimer] = useState(undefined);\n\n const handleKeyPress = useCallback(\n event => {\n toggleStateOnKeyPress(toolTipIsVisible, setToolTipIsVisible)(event);\n },\n [toolTipIsVisible]\n );\n\n const handleContentMouseOver = useCallback(() => {\n mouseLeaveTimer && /* istanbul ignore next */ clearTimeout(mouseLeaveTimer);\n }, [mouseLeaveTimer]);\n\n const handleMouseOver = useCallback(() => {\n mouseLeaveTimer && clearTimeout(mouseLeaveTimer);\n setToolTipIsVisible(true);\n }, [mouseLeaveTimer]);\n\n const handleMouseLeave = useCallback(() => {\n setMouseLeaveTimer(setTimeout(() => setToolTipIsVisible(false), delayHide));\n }, [delayHide]);\n\n const content = useMemo(() => {\n return isComponent ? (\n <TooltipContent />\n ) : (\n <p className={classnames([style.tooltipContent, FontSizes[fontSize]])}>{TooltipContent}</p>\n );\n }, [TooltipContent, fontSize, isComponent]);\n\n return anchorId ? (\n <ToolTipWrapper\n toolTipIsVisible={_toolTipIsVisible}\n anchorId={anchorId}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n content={content}\n onMouseLeave={handleMouseLeave}\n onMouseOver={handleMouseOver}\n fontSize={fontSize}\n />\n ) : (\n <div\n className={style.tooltipContainer}\n onMouseLeave={handleMouseLeave}\n onMouseOver={handleMouseOver}\n >\n <button\n type=\"button\"\n className={classnames([style.tooltipIconContainer, iconContainerClassName])}\n data-testid={dataTestId}\n onKeyDown={handleKeyPress}\n tabIndex={0}\n >\n <InformationIcon\n className={style.informationIcon}\n width={12}\n height={12}\n aria-label={ariaLabel}\n />\n </button>\n <ToolTipWrapper\n toolTipIsVisible={toolTipIsVisible}\n anchorId={anchorId}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n content={content}\n handleContentMouseOver={handleContentMouseOver}\n fontSize={fontSize}\n />\n </div>\n );\n};\n\nToolTip.propTypes = {\n TooltipContent: PropTypes.oneOfType([PropTypes.func, PropTypes.node, PropTypes.string]),\n 'data-testid': PropTypes.string,\n 'aria-label': PropTypes.string,\n closeToolTipInformationTextAriaLabel: PropTypes.string.isRequired,\n // ---------- Regular Tooltip exclusive --------------\n iconContainerClassName: PropTypes.string,\n delayHide: PropTypes.number,\n fontSize: PropTypes.oneOf([12, 14]),\n // ---------- React Tooltip exclusive --------------\n // externalHandling: if passed down, React Tooltip is used instead, due to limitations on\n // parents overflow hidden controls\n anchorId: PropTypes.string,\n toolTipIsVisible: PropTypes.bool\n};\n\nexport default ToolTip;\n"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,MAAMA,SAAS,GAAG;EAChB,IAAIC,cAAA,CAAMC,wBADM;EAEhB,IAAID,cAAA,CAAME;AAFM,CAAlB;;AAKA,MAAMC,cAAc,GAAG,CAAC;EACtBC,gBADsB;EAEtBC,QAFsB;EAGtBC,oCAHsB;EAItBC,OAJsB;EAKtBC;AALsB,CAAD,KAMjB;EACJ,IAAI,CAACJ,gBAAL,EAAuB,OAAO,IAAP;;EACvB,IAAIC,QAAJ,EAAc;IACZ,oBACE,6BAAC,q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A3C,CAApB,CADE;EAElB,eAAeF,kBAAA,CAAUE,MAFP;EAGlB,cAAcF,kBAAA,CAAUE,MAHN;EAIlBR,oCAAoC,EAAEM,kBAAA,CAAUE,MAAV,CAAiBC,UAJrC;EAKlB;EACAkB,sBAAsB,EAAErB,kBAAA,CAAUE,MANhB;EAOlBoB,SAAS,EAAEtB,kBAAA,CAAU6C,MAPH;EAQlBtB,QAAQ,EAAEvB,kBAAA,CAAU8C,KAAV,CAAgB,CAAC,EAAD,EAAK,EAAL,CAAhB,CARQ;EASlB;EACA;EACA;EACArD,QAAQ,EAAEO,kBAAA,CAAUE,MAZF;EAalBV,gBAAgB,EAAEQ,kBAAA,CAAUC;AAbV,CAApB;eAgBee,O"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/organism/user-preferences/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/organism/user-preferences/index.js"],"names":[],"mappings":";AAwCA,0DAeC"}
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
|
|
6
|
-
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
|
|
7
|
-
|
|
8
|
-
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
|
|
9
|
-
|
|
10
6
|
var _react = _interopRequireDefault(require("react"));
|
|
11
7
|
|
|
12
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
9
|
|
|
14
|
-
var
|
|
10
|
+
var _isEmpty = _interopRequireDefault(require("lodash/fp/isEmpty"));
|
|
11
|
+
|
|
12
|
+
var _map = _interopRequireDefault(require("lodash/fp/map"));
|
|
13
|
+
|
|
14
|
+
var _provider = require("../../atom/provider");
|
|
15
|
+
|
|
16
|
+
var _tooltip = _interopRequireDefault(require("../../atom/tooltip"));
|
|
15
17
|
|
|
16
18
|
var _inputSwitch = _interopRequireDefault(require("../../atom/input-switch"));
|
|
17
19
|
|
|
@@ -26,6 +28,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
26
28
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
27
29
|
|
|
28
30
|
const Settings = props => {
|
|
31
|
+
const translate = (0, _provider.GetTranslateFromContext)();
|
|
32
|
+
|
|
29
33
|
const {
|
|
30
34
|
label,
|
|
31
35
|
description,
|
|
@@ -36,19 +40,16 @@ const Settings = props => {
|
|
|
36
40
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
37
41
|
className: _style.default.settings
|
|
38
42
|
}, /*#__PURE__*/_react.default.createElement(_inputSwitch.default, settings), /*#__PURE__*/_react.default.createElement("span", {
|
|
39
|
-
className: _style.default.label
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
50
|
-
className: _style.default.descriptionLabel
|
|
51
|
-
}, description))));
|
|
43
|
+
className: _style.default.label,
|
|
44
|
+
tabIndex: 0
|
|
45
|
+
}, label), (0, _isEmpty.default)(description) ? null : /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
46
|
+
TooltipContent: description,
|
|
47
|
+
closeToolTipInformationTextAriaLabel: translate('Press the escape key to close the information text'),
|
|
48
|
+
"data-testid": "user-preferences-tooltip",
|
|
49
|
+
"aria-label": moreInfoAriaLabel,
|
|
50
|
+
iconContainerClassName: _style.default.infoIconTooltip,
|
|
51
|
+
fontSize: 12
|
|
52
|
+
}));
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
Settings.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, _inputSwitch.default.propTypes, {
|
|
@@ -58,15 +59,16 @@ Settings.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, _input
|
|
|
58
59
|
|
|
59
60
|
const UserPreferences = props => {
|
|
60
61
|
const {
|
|
61
|
-
preferences
|
|
62
|
+
preferences,
|
|
62
63
|
moreInfoAriaLabel,
|
|
63
64
|
groupAriaLabel
|
|
64
65
|
} = props;
|
|
65
66
|
return /*#__PURE__*/_react.default.createElement("form", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
66
67
|
className: _style.default.preferences,
|
|
67
68
|
role: "group",
|
|
68
|
-
"aria-label": groupAriaLabel
|
|
69
|
-
|
|
69
|
+
"aria-label": groupAriaLabel,
|
|
70
|
+
tabIndex: 0
|
|
71
|
+
}, (0, _map.default)(settings => /*#__PURE__*/_react.default.createElement(Settings, _extends({}, settings, {
|
|
70
72
|
key: settings.label,
|
|
71
73
|
moreInfoAriaLabel: moreInfoAriaLabel
|
|
72
74
|
})), preferences)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Settings","props","
|
|
1
|
+
{"version":3,"file":"index.js","names":["Settings","props","translate","GetTranslateFromContext","label","description","moreInfoAriaLabel","settings","style","isEmpty","infoIconTooltip","propTypes","InputSwitch","PropTypes","string","isRequired","UserPreferences","preferences","groupAriaLabel","map","arrayOf","shape"],"sources":["../../../src/organism/user-preferences/index.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isEmpty from 'lodash/fp/isEmpty';\nimport map from 'lodash/fp/map';\nimport {GetTranslateFromContext} from '../../atom/provider';\nimport ToolTip from '../../atom/tooltip';\nimport InputSwitch from '../../atom/input-switch';\nimport style from './style.css';\n\nconst Settings = props => {\n const translate = GetTranslateFromContext();\n const {label, description, moreInfoAriaLabel, ...settings} = props;\n return (\n <div className={style.settings}>\n <InputSwitch {...settings} />\n <span className={style.label} tabIndex={0}>\n {label}\n </span>\n {isEmpty(description) ? null : (\n <ToolTip\n TooltipContent={description}\n closeToolTipInformationTextAriaLabel={translate(\n 'Press the escape key to close the information text'\n )}\n data-testid=\"user-preferences-tooltip\"\n aria-label={moreInfoAriaLabel}\n iconContainerClassName={style.infoIconTooltip}\n fontSize={12}\n />\n )}\n </div>\n );\n};\n\nSettings.propTypes = {\n ...InputSwitch.propTypes,\n label: PropTypes.string.isRequired,\n description: PropTypes.string\n};\n\nconst UserPreferences = props => {\n const {preferences, moreInfoAriaLabel, groupAriaLabel} = props;\n\n return (\n <form>\n <div className={style.preferences} role=\"group\" aria-label={groupAriaLabel} tabIndex={0}>\n {map(\n settings => (\n <Settings {...settings} key={settings.label} moreInfoAriaLabel={moreInfoAriaLabel} />\n ),\n preferences\n )}\n </div>\n </form>\n );\n};\n\nUserPreferences.propTypes = {\n preferences: PropTypes.arrayOf(PropTypes.shape(Settings.propTypes)),\n moreInfoAriaLabel: PropTypes.string,\n groupAriaLabel: PropTypes.string\n};\n\nexport default UserPreferences;\n"],"mappings":";;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,QAAQ,GAAGC,KAAK,IAAI;EACxB,MAAMC,SAAS,GAAG,IAAAC,iCAAA,GAAlB;;EACA,MAAM;IAACC,KAAD;IAAQC,WAAR;IAAqBC;EAArB,IAAuDL,KAA7D;EAAA,MAAiDM,QAAjD,iCAA6DN,KAA7D;;EACA,oBACE;IAAK,SAAS,EAAEO,cAAA,CAAMD;EAAtB,gBACE,6BAAC,oBAAD,EAAiBA,QAAjB,CADF,eAEE;IAAM,SAAS,EAAEC,cAAA,CAAMJ,KAAvB;IAA8B,QAAQ,EAAE;EAAxC,GACGA,KADH,CAFF,EAKG,IAAAK,gBAAA,EAAQJ,WAAR,IAAuB,IAAvB,gBACC,6BAAC,gBAAD;IACE,cAAc,EAAEA,WADlB;IAEE,oCAAoC,EAAEH,SAAS,CAC7C,oDAD6C,CAFjD;IAKE,eAAY,0BALd;I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