@coorpacademy/components 11.13.2 → 11.13.3-alpha.2
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/button-link/index.d.ts +2 -0
- package/es/atom/button-link/index.d.ts.map +1 -1
- package/es/atom/button-link/index.js +18 -9
- package/es/atom/button-link/index.js.map +1 -1
- package/es/atom/tooltip/index.d.ts +5 -1
- package/es/atom/tooltip/index.d.ts.map +1 -1
- package/es/atom/tooltip/index.js +36 -18
- package/es/atom/tooltip/index.js.map +1 -1
- package/es/atom/tooltip/style.css +1 -1
- package/es/molecule/brand-form-group/index.d.ts +2 -0
- package/es/molecule/review-correction-popin/index.d.ts.map +1 -1
- package/es/molecule/review-correction-popin/index.js +38 -14
- package/es/molecule/review-correction-popin/index.js.map +1 -1
- package/es/molecule/review-correction-popin/style.css +11 -53
- package/es/organism/brand-form/index.d.ts +2 -0
- package/es/organism/list-items/index.d.ts +2 -0
- package/es/organism/setup-header/index.d.ts +8 -0
- package/es/organism/wizard-contents/index.d.ts +2 -0
- package/es/template/activity/engine-stars.d.ts.map +1 -1
- package/es/template/activity/engine-stars.js +2 -1
- package/es/template/activity/engine-stars.js.map +1 -1
- package/es/template/back-office/brand-create/index.d.ts +8 -0
- package/es/template/back-office/brand-create/index.d.ts.map +1 -1
- package/es/template/back-office/brand-list/index.d.ts +8 -0
- package/es/template/back-office/brand-list/index.d.ts.map +1 -1
- package/es/template/back-office/brand-update/index.d.ts +14 -0
- package/es/template/back-office/dashboard-preview/index.d.ts +8 -0
- package/es/template/back-office/layout/index.d.ts +8 -0
- package/es/template/back-office/layout/index.d.ts.map +1 -1
- package/lib/atom/button-link/index.d.ts +2 -0
- package/lib/atom/button-link/index.d.ts.map +1 -1
- package/lib/atom/button-link/index.js +18 -9
- package/lib/atom/button-link/index.js.map +1 -1
- package/lib/atom/tooltip/index.d.ts +5 -1
- package/lib/atom/tooltip/index.d.ts.map +1 -1
- package/lib/atom/tooltip/index.js +38 -18
- package/lib/atom/tooltip/index.js.map +1 -1
- package/lib/atom/tooltip/style.css +1 -1
- package/lib/molecule/brand-form-group/index.d.ts +2 -0
- package/lib/molecule/review-correction-popin/index.d.ts.map +1 -1
- package/lib/molecule/review-correction-popin/index.js +44 -14
- package/lib/molecule/review-correction-popin/index.js.map +1 -1
- package/lib/molecule/review-correction-popin/style.css +11 -53
- package/lib/organism/brand-form/index.d.ts +2 -0
- package/lib/organism/list-items/index.d.ts +2 -0
- package/lib/organism/setup-header/index.d.ts +8 -0
- package/lib/organism/wizard-contents/index.d.ts +2 -0
- package/lib/template/activity/engine-stars.d.ts.map +1 -1
- package/lib/template/activity/engine-stars.js +2 -1
- package/lib/template/activity/engine-stars.js.map +1 -1
- package/lib/template/back-office/brand-create/index.d.ts +8 -0
- package/lib/template/back-office/brand-create/index.d.ts.map +1 -1
- package/lib/template/back-office/brand-list/index.d.ts +8 -0
- package/lib/template/back-office/brand-list/index.d.ts.map +1 -1
- package/lib/template/back-office/brand-update/index.d.ts +14 -0
- package/lib/template/back-office/dashboard-preview/index.d.ts +8 -0
- package/lib/template/back-office/layout/index.d.ts +8 -0
- package/lib/template/back-office/layout/index.d.ts.map +1 -1
- package/locales/en/global.json +1 -0
- package/package.json +2 -2
|
@@ -12,6 +12,7 @@ declare namespace ButtonLink {
|
|
|
12
12
|
type: PropTypes.Requireable<string>;
|
|
13
13
|
}>>;
|
|
14
14
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
16
|
link: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
17
|
href: PropTypes.Requireable<string>;
|
|
17
18
|
download: PropTypes.Requireable<boolean>;
|
|
@@ -20,6 +21,7 @@ declare namespace ButtonLink {
|
|
|
20
21
|
disabled: PropTypes.Requireable<boolean>;
|
|
21
22
|
className: PropTypes.Requireable<string>;
|
|
22
23
|
customStyle: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
24
|
+
useTitle: PropTypes.Requireable<boolean>;
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
import PropTypes from "prop-types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/index.js"],"names":[],"mappings":";AA6BA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/index.js"],"names":[],"mappings":";AA6BA,qDAqEC"}
|
|
@@ -49,34 +49,41 @@ const ButtonLink = props => {
|
|
|
49
49
|
'aria-label': ariaLabel,
|
|
50
50
|
link,
|
|
51
51
|
onClick = _noop,
|
|
52
|
+
onKeyDown = _noop,
|
|
52
53
|
className,
|
|
53
|
-
customStyle
|
|
54
|
+
customStyle,
|
|
55
|
+
useTitle = true
|
|
54
56
|
} = props;
|
|
55
57
|
const contentView = getButtonContent(icon, label);
|
|
56
58
|
const styleButton = classnames(className, style.button, type === 'primary' && style.primary, type === 'secondary' && style.secondary, type === 'tertiary' && style.tertiary, type === 'text' && style.text, type === 'dangerous' && style.dangerous, link && style.link, disabled && style.disabled);
|
|
57
59
|
const handleOnClick = useCallback(() => onClick(), [onClick]);
|
|
60
|
+
const handleOnKeyDown = useCallback(event => onKeyDown(event), [onKeyDown]);
|
|
58
61
|
|
|
59
62
|
if (link) {
|
|
60
|
-
return /*#__PURE__*/React.createElement(Link, _extends({}, link, {
|
|
63
|
+
return /*#__PURE__*/React.createElement(Link, _extends({}, link, useTitle && {
|
|
64
|
+
title: ariaLabel || label
|
|
65
|
+
}, {
|
|
61
66
|
style: customStyle,
|
|
62
67
|
className: styleButton,
|
|
63
68
|
"data-name": dataName,
|
|
64
69
|
"data-testid": dataTestId,
|
|
65
|
-
"aria-label": ariaLabel || label
|
|
66
|
-
title: ariaLabel || label
|
|
70
|
+
"aria-label": ariaLabel || label
|
|
67
71
|
}), contentView);
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
74
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, useTitle && {
|
|
75
|
+
title: ariaLabel || label
|
|
76
|
+
}, {
|
|
71
77
|
type: "button",
|
|
72
78
|
"aria-label": ariaLabel || label,
|
|
73
|
-
title: ariaLabel || label,
|
|
74
79
|
"data-name": dataName,
|
|
75
80
|
"data-testid": dataTestId,
|
|
76
81
|
style: customStyle,
|
|
77
82
|
className: styleButton,
|
|
78
|
-
onClick: handleOnClick
|
|
79
|
-
|
|
83
|
+
onClick: handleOnClick,
|
|
84
|
+
onKeyDown: handleOnKeyDown,
|
|
85
|
+
tabIndex: 0
|
|
86
|
+
}), contentView);
|
|
80
87
|
};
|
|
81
88
|
|
|
82
89
|
ButtonLink.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
@@ -90,6 +97,7 @@ ButtonLink.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
90
97
|
type: PropTypes.oneOf(_keys(ICONS))
|
|
91
98
|
}),
|
|
92
99
|
onClick: PropTypes.func,
|
|
100
|
+
onKeyDown: PropTypes.func,
|
|
93
101
|
link: PropTypes.shape({
|
|
94
102
|
href: PropTypes.string,
|
|
95
103
|
download: PropTypes.bool,
|
|
@@ -97,7 +105,8 @@ ButtonLink.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
97
105
|
}),
|
|
98
106
|
disabled: PropTypes.bool,
|
|
99
107
|
className: PropTypes.string,
|
|
100
|
-
customStyle: PropTypes.shape({})
|
|
108
|
+
customStyle: PropTypes.shape({}),
|
|
109
|
+
useTitle: PropTypes.bool
|
|
101
110
|
} : {};
|
|
102
111
|
export default ButtonLink;
|
|
103
112
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","PropTypes","classnames","Link","ICONS","style","getButtonContent","icon","label","type","position","Icon","buttonContent","ButtonLink","props","disabled","dataName","dataTestId","ariaLabel","link","onClick","className","customStyle","contentView","styleButton","button","primary","secondary","tertiary","text","dangerous","handleOnClick","propTypes","oneOf","string","shape","func","href","download","bool","target"],"sources":["../../../src/atom/button-link/index.js"],"sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport {getOr, keys, noop} from 'lodash/fp';\nimport classnames from 'classnames';\nimport Link from '../link';\nimport {ICONS} from '../../util/button-icons';\nimport style from './style.css';\n\nconst getButtonContent = (icon, label) => {\n const {type, position} = icon;\n const Icon = getOr(null, type, ICONS);\n\n if (!Icon) {\n return (\n <div className={style.buttonContent}>\n <span className={style.label}>{label}</span>\n </div>\n );\n }\n\n return (\n <div className={style.buttonContent}>\n {position === 'left' ? <Icon className={style.icon} /> : null}\n <span className={style.label}>{label}</span>\n {position === 'right' ? <Icon className={style.icon} /> : null}\n </div>\n );\n};\n\nconst ButtonLink = props => {\n const {\n type,\n label,\n disabled,\n icon = {},\n 'data-name': dataName,\n 'data-testid': dataTestId = 'button-link',\n 'aria-label': ariaLabel,\n link,\n onClick = noop,\n className,\n customStyle\n } = props;\n const contentView = getButtonContent(icon, label);\n const styleButton = classnames(\n className,\n style.button,\n type === 'primary' && style.primary,\n type === 'secondary' && style.secondary,\n type === 'tertiary' && style.tertiary,\n type === 'text' && style.text,\n type === 'dangerous' && style.dangerous,\n link && style.link,\n disabled && style.disabled\n );\n\n const handleOnClick = useCallback(() => onClick(), [onClick]);\n\n if (link) {\n return (\n <Link\n {...link}\n style={customStyle}\n className={styleButton}\n data-name={dataName}\n data-testid={dataTestId}\n aria-label={ariaLabel || label}\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","PropTypes","classnames","Link","ICONS","style","getButtonContent","icon","label","type","position","Icon","buttonContent","ButtonLink","props","disabled","dataName","dataTestId","ariaLabel","link","onClick","onKeyDown","className","customStyle","useTitle","contentView","styleButton","button","primary","secondary","tertiary","text","dangerous","handleOnClick","handleOnKeyDown","event","title","propTypes","oneOf","string","shape","func","href","download","bool","target"],"sources":["../../../src/atom/button-link/index.js"],"sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport {getOr, keys, noop} from 'lodash/fp';\nimport classnames from 'classnames';\nimport Link from '../link';\nimport {ICONS} from '../../util/button-icons';\nimport style from './style.css';\n\nconst getButtonContent = (icon, label) => {\n const {type, position} = icon;\n const Icon = getOr(null, type, ICONS);\n\n if (!Icon) {\n return (\n <div className={style.buttonContent}>\n <span className={style.label}>{label}</span>\n </div>\n );\n }\n\n return (\n <div className={style.buttonContent}>\n {position === 'left' ? <Icon className={style.icon} /> : null}\n <span className={style.label}>{label}</span>\n {position === 'right' ? <Icon className={style.icon} /> : null}\n </div>\n );\n};\n\nconst ButtonLink = props => {\n const {\n type,\n label,\n disabled,\n icon = {},\n 'data-name': dataName,\n 'data-testid': dataTestId = 'button-link',\n 'aria-label': ariaLabel,\n link,\n onClick = noop,\n onKeyDown = noop,\n className,\n customStyle,\n useTitle = true\n } = props;\n const contentView = getButtonContent(icon, label);\n const styleButton = classnames(\n className,\n style.button,\n type === 'primary' && style.primary,\n type === 'secondary' && style.secondary,\n type === 'tertiary' && style.tertiary,\n type === 'text' && style.text,\n type === 'dangerous' && style.dangerous,\n link && style.link,\n disabled && style.disabled\n );\n\n const handleOnClick = useCallback(() => onClick(), [onClick]);\n\n const handleOnKeyDown = useCallback(event => onKeyDown(event), [onKeyDown]);\n\n if (link) {\n return (\n <Link\n {...link}\n {...(useTitle && {\n title: ariaLabel || label\n })}\n style={customStyle}\n className={styleButton}\n data-name={dataName}\n data-testid={dataTestId}\n aria-label={ariaLabel || label}\n >\n {contentView}\n </Link>\n );\n }\n\n return (\n <button\n {...(useTitle && {\n title: ariaLabel || label\n })}\n type=\"button\"\n aria-label={ariaLabel || label}\n data-name={dataName}\n data-testid={dataTestId}\n style={customStyle}\n className={styleButton}\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n tabIndex={0}\n >\n {contentView}\n </button>\n );\n};\n\nButtonLink.propTypes = {\n type: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'text', 'dangerous']),\n label: PropTypes.string,\n 'aria-label': PropTypes.string,\n 'data-name': PropTypes.string,\n 'data-testid': PropTypes.string,\n icon: PropTypes.shape({\n position: PropTypes.oneOf(['right', 'left']),\n type: PropTypes.oneOf(keys(ICONS))\n }),\n onClick: PropTypes.func,\n onKeyDown: PropTypes.func,\n link: PropTypes.shape({\n href: PropTypes.string,\n download: PropTypes.bool,\n target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top'])\n }),\n disabled: PropTypes.bool,\n className: PropTypes.string,\n customStyle: PropTypes.shape({}),\n useTitle: PropTypes.bool\n};\n\nexport default ButtonLink;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAeC,WAAf,QAAiC,OAAjC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAAQC,KAAR,QAAoB,yBAApB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,gBAAgB,GAAG,CAACC,IAAD,EAAOC,KAAP,KAAiB;EACxC,MAAM;IAACC,IAAD;IAAOC;EAAP,IAAmBH,IAAzB;;EACA,MAAMI,IAAI,GAAG,OAAM,IAAN,EAAYF,IAAZ,EAAkBL,KAAlB,CAAb;;EAEA,IAAI,CAACO,IAAL,EAAW;IACT,oBACE;MAAK,SAAS,EAAEN,KAAK,CAACO;IAAtB,gBACE;MAAM,SAAS,EAAEP,KAAK,CAACG;IAAvB,GAA+BA,KAA/B,CADF,CADF;EAKD;;EAED,oBACE;IAAK,SAAS,EAAEH,KAAK,CAACO;EAAtB,GACGF,QAAQ,KAAK,MAAb,gBAAsB,oBAAC,IAAD;IAAM,SAAS,EAAEL,KAAK,CAACE;EAAvB,EAAtB,GAAwD,IAD3D,eAEE;IAAM,SAAS,EAAEF,KAAK,CAACG;EAAvB,GAA+BA,KAA/B,CAFF,EAGGE,QA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C,SAAS,CAAC2C,IAFA;IAGpBC,MAAM,EAAE5C,SAAS,CAACqC,KAAV,CAAgB,CAAC,OAAD,EAAU,QAAV,EAAoB,SAApB,EAA+B,MAA/B,CAAhB;EAHY,CAAhB,CAZe;EAiBrBvB,QAAQ,EAAEd,SAAS,CAAC2C,IAjBC;EAkBrBtB,SAAS,EAAErB,SAAS,CAACsC,MAlBA;EAmBrBhB,WAAW,EAAEtB,SAAS,CAACuC,KAAV,CAAgB,EAAhB,CAnBQ;EAoBrBhB,QAAQ,EAAEvB,SAAS,CAAC2C;AApBC,CAAvB;AAuBA,eAAe/B,UAAf"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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, iconContainerClassName, delayHide, fontSize, iconSize }: {
|
|
3
|
+
declare function ToolTip({ anchorId, TooltipContent, "aria-label": ariaLabel, "data-testid": dataTestId, closeToolTipInformationTextAriaLabel, toolTipIsVisible: _toolTipIsVisible, iconContainerClassName, delayHide, fontSize, iconSize, AnchorElement, tooltipClassName }: {
|
|
4
4
|
anchorId: any;
|
|
5
5
|
TooltipContent: any;
|
|
6
6
|
"aria-label": any;
|
|
@@ -11,6 +11,8 @@ declare function ToolTip({ anchorId, TooltipContent, "aria-label": ariaLabel, "d
|
|
|
11
11
|
delayHide?: number | undefined;
|
|
12
12
|
fontSize?: number | undefined;
|
|
13
13
|
iconSize?: string | undefined;
|
|
14
|
+
AnchorElement: any;
|
|
15
|
+
tooltipClassName: any;
|
|
14
16
|
}): JSX.Element;
|
|
15
17
|
declare namespace ToolTip {
|
|
16
18
|
const propTypes: {
|
|
@@ -18,6 +20,8 @@ declare namespace ToolTip {
|
|
|
18
20
|
'data-testid': PropTypes.Requireable<string>;
|
|
19
21
|
'aria-label': PropTypes.Requireable<string>;
|
|
20
22
|
closeToolTipInformationTextAriaLabel: PropTypes.Validator<string>;
|
|
23
|
+
AnchorElement: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
|
+
tooltipClassName: PropTypes.Requireable<string>;
|
|
21
25
|
iconContainerClassName: PropTypes.Requireable<string>;
|
|
22
26
|
delayHide: PropTypes.Requireable<number>;
|
|
23
27
|
fontSize: PropTypes.Requireable<number>;
|
|
@@ -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":"AA4EO,iGAUN;;AAED;;;;;;;;;;;;;gBAwGC"}
|
package/es/atom/tooltip/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import classnames from 'classnames';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import ReactTooltip from 'react-tooltip';
|
|
5
5
|
import isString from 'lodash/fp/isString';
|
|
6
|
+
import has from 'lodash/fp/has';
|
|
7
|
+
import isNil from 'lodash/fp/isNil';
|
|
6
8
|
import keys from 'lodash/fp/keys';
|
|
7
9
|
import { NovaCompositionCoorpacademyInformationIcon as InformationIcon } from '@coorpacademy/nova-icons';
|
|
8
10
|
import style from './style.css';
|
|
@@ -21,9 +23,12 @@ const ToolTipWrapper = ({
|
|
|
21
23
|
closeToolTipInformationTextAriaLabel,
|
|
22
24
|
content,
|
|
23
25
|
handleContentMouseOver,
|
|
24
|
-
iconSize
|
|
26
|
+
iconSize,
|
|
27
|
+
tooltipClassName,
|
|
28
|
+
usesAnchorElement
|
|
25
29
|
}) => {
|
|
26
|
-
const coorpToolTipClasses = classnames(style.toolTip,
|
|
30
|
+
const coorpToolTipClasses = classnames(style.toolTip, tooltipClassName, // eslint-disable-next-line no-nested-ternary
|
|
31
|
+
usesAnchorElement ? null : iconSize === 'big' ? style.bigIconToolTip : style.smallIconToolTip);
|
|
27
32
|
if (!toolTipIsVisible) return null;
|
|
28
33
|
|
|
29
34
|
if (anchorId) {
|
|
@@ -51,10 +56,12 @@ ToolTipWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
51
56
|
closeToolTipInformationTextAriaLabel: PropTypes.string.isRequired,
|
|
52
57
|
content: PropTypes.node,
|
|
53
58
|
handleContentMouseOver: PropTypes.func,
|
|
54
|
-
iconSize: PropTypes.oneOf(keys(IconSizes))
|
|
59
|
+
iconSize: PropTypes.oneOf(keys(IconSizes)),
|
|
60
|
+
tooltipClassName: PropTypes.string,
|
|
61
|
+
usesAnchorElement: PropTypes.bool
|
|
55
62
|
} : {};
|
|
56
63
|
export const toggleStateOnKeyPress = (state, setState, ref) => event => {
|
|
57
|
-
if (event.key === 'Enter') {
|
|
64
|
+
if (!has('key', event)) return;else if (event.key === 'Enter') {
|
|
58
65
|
if (ref) ref.current.focus();
|
|
59
66
|
event.stopPropagation();
|
|
60
67
|
event.preventDefault();
|
|
@@ -74,7 +81,9 @@ const ToolTip = ({
|
|
|
74
81
|
iconContainerClassName,
|
|
75
82
|
delayHide = 250,
|
|
76
83
|
fontSize = 14,
|
|
77
|
-
iconSize = 'small'
|
|
84
|
+
iconSize = 'small',
|
|
85
|
+
AnchorElement,
|
|
86
|
+
tooltipClassName
|
|
78
87
|
}) => {
|
|
79
88
|
const isComponent = useMemo(() => !isString(TooltipContent) && /*#__PURE__*/isValidElement(TooltipContent()), [TooltipContent]);
|
|
80
89
|
const [toolTipIsVisible, setToolTipIsVisible] = useState(false);
|
|
@@ -99,6 +108,20 @@ const ToolTip = ({
|
|
|
99
108
|
className: classnames([style.tooltipContent, FontSizes[fontSize]])
|
|
100
109
|
}, TooltipContent);
|
|
101
110
|
}, [TooltipContent, fontSize, isComponent]);
|
|
111
|
+
const anchorElement = useMemo(() => AnchorElement ? /*#__PURE__*/React.createElement(AnchorElement, {
|
|
112
|
+
onKeyDown: handleKeyPress
|
|
113
|
+
}) : /*#__PURE__*/React.createElement("button", {
|
|
114
|
+
type: "button",
|
|
115
|
+
className: classnames([style.tooltipIconContainer, iconContainerClassName]),
|
|
116
|
+
"data-testid": dataTestId,
|
|
117
|
+
onKeyDown: handleKeyPress,
|
|
118
|
+
tabIndex: 0
|
|
119
|
+
}, /*#__PURE__*/React.createElement(InformationIcon, {
|
|
120
|
+
className: style.informationIcon,
|
|
121
|
+
width: IconSizes[iconSize],
|
|
122
|
+
height: IconSizes[iconSize],
|
|
123
|
+
"aria-label": ariaLabel
|
|
124
|
+
})), [AnchorElement, ariaLabel, dataTestId, handleKeyPress, iconContainerClassName, iconSize]);
|
|
102
125
|
return anchorId ? /*#__PURE__*/React.createElement(ToolTipWrapper, {
|
|
103
126
|
toolTipIsVisible: _toolTipIsVisible,
|
|
104
127
|
anchorId: anchorId,
|
|
@@ -111,25 +134,16 @@ const ToolTip = ({
|
|
|
111
134
|
className: style.tooltipContainer,
|
|
112
135
|
onMouseLeave: handleMouseLeave,
|
|
113
136
|
onMouseOver: handleMouseOver
|
|
114
|
-
}, /*#__PURE__*/React.createElement(
|
|
115
|
-
type: "button",
|
|
116
|
-
className: classnames([style.tooltipIconContainer, iconContainerClassName]),
|
|
117
|
-
"data-testid": dataTestId,
|
|
118
|
-
onKeyDown: handleKeyPress,
|
|
119
|
-
tabIndex: 0
|
|
120
|
-
}, /*#__PURE__*/React.createElement(InformationIcon, {
|
|
121
|
-
className: style.informationIcon,
|
|
122
|
-
width: IconSizes[iconSize],
|
|
123
|
-
height: IconSizes[iconSize],
|
|
124
|
-
"aria-label": ariaLabel
|
|
125
|
-
})), /*#__PURE__*/React.createElement(ToolTipWrapper, {
|
|
137
|
+
}, anchorElement, /*#__PURE__*/React.createElement(ToolTipWrapper, {
|
|
126
138
|
toolTipIsVisible: toolTipIsVisible,
|
|
127
139
|
anchorId: anchorId,
|
|
128
140
|
closeToolTipInformationTextAriaLabel: closeToolTipInformationTextAriaLabel,
|
|
129
141
|
content: content,
|
|
130
142
|
handleContentMouseOver: handleContentMouseOver,
|
|
131
143
|
fontSize: fontSize,
|
|
132
|
-
iconSize: iconSize
|
|
144
|
+
iconSize: iconSize,
|
|
145
|
+
tooltipClassName: tooltipClassName,
|
|
146
|
+
usesAnchorElement: !isNil(AnchorElement)
|
|
133
147
|
}));
|
|
134
148
|
};
|
|
135
149
|
|
|
@@ -139,6 +153,10 @@ ToolTip.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
139
153
|
'aria-label': PropTypes.string,
|
|
140
154
|
closeToolTipInformationTextAriaLabel: PropTypes.string.isRequired,
|
|
141
155
|
// ---------- Regular Tooltip exclusive --------------
|
|
156
|
+
// If using an Anchor element w/ the regular Tooltip
|
|
157
|
+
AnchorElement: PropTypes.func,
|
|
158
|
+
tooltipClassName: PropTypes.string,
|
|
159
|
+
//
|
|
142
160
|
iconContainerClassName: PropTypes.string,
|
|
143
161
|
delayHide: PropTypes.number,
|
|
144
162
|
fontSize: PropTypes.oneOf([12, 14]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","isValidElement","useState","useCallback","useMemo","classnames","PropTypes","ReactTooltip","isString","keys","NovaCompositionCoorpacademyInformationIcon","InformationIcon","style","FontSizes","tooltipContentFontSize12","tooltipContentFontSize14","IconSizes","small","big","ToolTipWrapper","toolTipIsVisible","anchorId","closeToolTipInformationTextAriaLabel","content","handleContentMouseOver","iconSize","coorpToolTipClasses","toolTip","bigIconToolTip","smallIconToolTip","toolTipReact","propTypes","bool","string","isRequired","node","func","oneOf","toggleStateOnKeyPress","state","setState","ref","event","key","current","focus","stopPropagation","preventDefault","ToolTip","TooltipContent","ariaLabel","dataTestId","_toolTipIsVisible","iconContainerClassName","delayHide","fontSize","isComponent","setToolTipIsVisible","mouseLeaveTimer","setMouseLeaveTimer","undefined","handleKeyPress","clearTimeout","handleMouseOver","handleMouseLeave","setTimeout","tooltipContent","tooltipContainer","tooltipIconContainer","informationIcon","oneOfType","number"],"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 keys from 'lodash/fp/keys';\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 IconSizes = {\n small: 12,\n big: 20\n};\n\nconst ToolTipWrapper = ({\n toolTipIsVisible,\n anchorId,\n closeToolTipInformationTextAriaLabel,\n content,\n handleContentMouseOver,\n iconSize\n}) => {\n const coorpToolTipClasses = classnames(\n style.toolTip,\n iconSize === 'big' ? style.bigIconToolTip : style.smallIconToolTip\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={coorpToolTipClasses}\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 iconSize: PropTypes.oneOf(keys(IconSizes))\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 iconSize = 'small'\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={IconSizes[iconSize]}\n height={IconSizes[iconSize]}\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 iconSize={iconSize}\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 iconSize: PropTypes.oneOf(keys(IconSizes)),\n // ---------- React Tooltip exclusive --------------\n // externalHandling: if passed down, React Tooltip is used instead, due to limitations on\n // parents overflow hidden controls\n // data-for={anchorId} && data-tooltip-place=\"left\" are needed on the anchored component\n anchorId: PropTypes.string,\n toolTipIsVisible: PropTypes.bool\n};\n\nexport default ToolTip;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,cAAf,EAA+BC,QAA/B,EAAyCC,WAAzC,EAAsDC,OAAtD,QAAoE,OAApE;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,YAAP,MAAyB,eAAzB;AACA,OAAOC,QAAP,MAAqB,oBAArB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,SAAQC,0CAA0C,IAAIC,eAAtD,QAA4E,0BAA5E;AACA,OAAOC,KAAP,MAAkB,aAAlB;AAEA,MAAMC,SAAS,GAAG;EAChB,IAAID,KAAK,CAACE,wBADM;EAEhB,IAAIF,KAAK,CAACG;AAFM,CAAlB;AAKA,MAAMC,SAAS,GAAG;EAChBC,KAAK,EAAE,EADS;EAEhBC,GAAG,EAAE;AAFW,CAAlB;;AAK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M,EAAET,SAAS,CAACS,QAAD,CAHnB;IAIE,cAAYyB;EAJd,EAPF,CALF,eAmBE,oBAAC,cAAD;IACE,gBAAgB,EAAE9B,gBADpB;IAEE,QAAQ,EAAEC,QAFZ;IAGE,oCAAoC,EAAEC,oCAHxC;IAIE,OAAO,EAAEC,OAJX;IAKE,sBAAsB,EAAEC,sBAL1B;IAME,QAAQ,EAAE+B,QANZ;IAOE,QAAQ,EAAE9B;EAPZ,EAnBF,CAXF;AAyCD,CA1FD;;AA4FAuB,OAAO,CAACjB,SAAR,2CAAoB;EAClBkB,cAAc,EAAE3C,SAAS,CAACgE,SAAV,CAAoB,CAAChE,SAAS,CAAC8B,IAAX,EAAiB9B,SAAS,CAAC6B,IAA3B,EAAiC7B,SAAS,CAAC2B,MAA3C,CAApB,CADE;EAElB,eAAe3B,SAAS,CAAC2B,MAFP;EAGlB,cAAc3B,SAAS,CAAC2B,MAHN;EAIlBX,oCAAoC,EAAEhB,SAAS,CAAC2B,MAAV,CAAiBC,UAJrC;EAKlB;EACAmB,sBAAsB,EAAE/C,SAAS,CAAC2B,MANhB;EAOlBqB,SAAS,EAAEhD,SAAS,CAACiE,MAPH;EAQlBhB,QAAQ,EAAEjD,SAAS,CAAC+B,KAAV,CAAgB,CAAC,EAAD,EAAK,EAAL,CAAhB,CARQ;EASlBZ,QAAQ,EAAEnB,SAAS,CAAC+B,KAAV,CAAgB5B,IAAI,CAACO,SAAD,CAApB,CATQ;EAUlB;EACA;EACA;EACA;EACAK,QAAQ,EAAEf,SAAS,CAAC2B,MAdF;EAelBb,gBAAgB,EAAEd,SAAS,CAAC0B;AAfV,CAApB;AAkBA,eAAegB,OAAf"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","isValidElement","useState","useCallback","useMemo","classnames","PropTypes","ReactTooltip","isString","has","isNil","keys","NovaCompositionCoorpacademyInformationIcon","InformationIcon","style","FontSizes","tooltipContentFontSize12","tooltipContentFontSize14","IconSizes","small","big","ToolTipWrapper","toolTipIsVisible","anchorId","closeToolTipInformationTextAriaLabel","content","handleContentMouseOver","iconSize","tooltipClassName","usesAnchorElement","coorpToolTipClasses","toolTip","bigIconToolTip","smallIconToolTip","toolTipReact","propTypes","bool","string","isRequired","node","func","oneOf","toggleStateOnKeyPress","state","setState","ref","event","key","current","focus","stopPropagation","preventDefault","ToolTip","TooltipContent","ariaLabel","dataTestId","_toolTipIsVisible","iconContainerClassName","delayHide","fontSize","AnchorElement","isComponent","setToolTipIsVisible","mouseLeaveTimer","setMouseLeaveTimer","undefined","handleKeyPress","clearTimeout","handleMouseOver","handleMouseLeave","setTimeout","tooltipContent","anchorElement","tooltipIconContainer","informationIcon","tooltipContainer","oneOfType","number"],"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 has from 'lodash/fp/has';\nimport isNil from 'lodash/fp/isNil';\nimport keys from 'lodash/fp/keys';\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 IconSizes = {\n small: 12,\n big: 20\n};\n\nconst ToolTipWrapper = ({\n toolTipIsVisible,\n anchorId,\n closeToolTipInformationTextAriaLabel,\n content,\n handleContentMouseOver,\n iconSize,\n tooltipClassName,\n usesAnchorElement\n}) => {\n const coorpToolTipClasses = classnames(\n style.toolTip,\n tooltipClassName,\n // eslint-disable-next-line no-nested-ternary\n usesAnchorElement ? null : iconSize === 'big' ? style.bigIconToolTip : style.smallIconToolTip\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={coorpToolTipClasses}\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 iconSize: PropTypes.oneOf(keys(IconSizes)),\n tooltipClassName: PropTypes.string,\n usesAnchorElement: PropTypes.bool\n};\n\nexport const toggleStateOnKeyPress = (state, setState, ref) => event => {\n if (!has('key', event)) return;\n else 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 iconSize = 'small',\n AnchorElement,\n tooltipClassName\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 const anchorElement = useMemo(\n () =>\n AnchorElement ? (\n <AnchorElement onKeyDown={handleKeyPress} />\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={IconSizes[iconSize]}\n height={IconSizes[iconSize]}\n aria-label={ariaLabel}\n />\n </button>\n ),\n [AnchorElement, ariaLabel, dataTestId, handleKeyPress, iconContainerClassName, iconSize]\n );\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 {anchorElement}\n <ToolTipWrapper\n toolTipIsVisible={toolTipIsVisible}\n anchorId={anchorId}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n content={content}\n handleContentMouseOver={handleContentMouseOver}\n fontSize={fontSize}\n iconSize={iconSize}\n tooltipClassName={tooltipClassName}\n usesAnchorElement={!isNil(AnchorElement)}\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 // If using an Anchor element w/ the regular Tooltip\n AnchorElement: PropTypes.func,\n tooltipClassName: PropTypes.string,\n //\n iconContainerClassName: PropTypes.string,\n delayHide: PropTypes.number,\n fontSize: PropTypes.oneOf([12, 14]),\n iconSize: PropTypes.oneOf(keys(IconSizes)),\n // ---------- React Tooltip exclusive --------------\n // externalHandling: if passed down, React Tooltip is used instead, due to limitations on\n // parents overflow hidden controls\n // data-for={anchorId} && data-tooltip-place=\"left\" are needed on the anchored component\n anchorId: PropTypes.string,\n toolTipIsVisible: PropTypes.bool\n};\n\nexport default ToolTip;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,cAAf,EAA+BC,QAA/B,EAAyCC,WAAzC,EAAsDC,OAAtD,QAAoE,OAApE;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,YAAP,MAAyB,eAAzB;AACA,OAAOC,QAAP,MAAqB,oBAArB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,KAAP,MAAkB,iBAAlB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,SAAQC,0CAA0C,IAAIC,eAAtD,QAA4E,0BAA5E;AACA,OAAOC,KAAP,MAAkB,aAAlB;AAEA,MAAMC,SAAS,GAAG;EAChB,IAAID,KAAK,CAACE,wBADM;EAEhB,IAAIF,KAAK,CAACG;AAFM,CAAlB;AAKA,MAAMC,SAAS,GAAG;EAChBC,KAAK,EAAE,EADS;EAEhBC,GAAG,EAAE;AAFW,CAAlB;;AAKA,MAAMC,cAAc,GAAG,CAAC;EACtBC,gBADsB;EAEtBC,QAFsB;EAGtBC,oCAHsB;EAItBC,OAJsB;EAKtBC,sBALsB;EAMtBC,QANsB;EAOtBC,gBAPsB;EAQtBC;AARsB,CAAD,KASjB;EACJ,MAAMC,mBAAmB,GAAGzB,UAAU,CACpCS,KAAK,CAACiB,OAD8B,EAEpCH,gBAFoC,EAGpC;EACAC,iBAAiB,GAAG,IAAH,GAAUF,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AErB,SAAS,CAACmC,KAAV,CAAgB9B,IAAI,CAACO,SAAD,CAApB,CAbQ;EAclB;EACA;EACA;EACA;EACAK,QAAQ,EAAEjB,SAAS,CAAC+B,MAlBF;EAmBlBf,gBAAgB,EAAEhB,SAAS,CAAC8B;AAnBV,CAApB;AAsBA,eAAegB,OAAf"}
|
|
@@ -419,6 +419,7 @@ declare namespace BrandFormGroup {
|
|
|
419
419
|
type: PropTypes.Requireable<string>;
|
|
420
420
|
}>>;
|
|
421
421
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
422
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
422
423
|
link: PropTypes.Requireable<PropTypes.InferProps<{
|
|
423
424
|
href: PropTypes.Requireable<string>;
|
|
424
425
|
download: PropTypes.Requireable<boolean>;
|
|
@@ -427,6 +428,7 @@ declare namespace BrandFormGroup {
|
|
|
427
428
|
disabled: PropTypes.Requireable<boolean>;
|
|
428
429
|
className: PropTypes.Requireable<string>;
|
|
429
430
|
customStyle: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
431
|
+
useTitle: PropTypes.Requireable<boolean>;
|
|
430
432
|
}> | PropTypes.InferProps<{
|
|
431
433
|
type: PropTypes.Requireable<string>;
|
|
432
434
|
title: PropTypes.Requireable<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/review-correction-popin/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/review-correction-popin/index.js"],"names":[],"mappings":";AA+EA,gEAqDC"}
|
|
@@ -1,36 +1,58 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useCallback, useMemo } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { NovaCompositionCoorpacademyCheck as RightIcon, NovaSolidStatusClose as WrongIcon } from '@coorpacademy/nova-icons';
|
|
6
6
|
import ButtonLink from '../../atom/button-link';
|
|
7
|
+
import Provider, { GetTranslateFromContext } from '../../atom/provider';
|
|
8
|
+
import Tooltip from '../../atom/tooltip';
|
|
7
9
|
import style from './style.css';
|
|
8
10
|
import propTypes from './prop-types';
|
|
9
11
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
+
const KlfButton = ({
|
|
13
|
+
klf
|
|
14
|
+
}, legacyContext) => {
|
|
15
|
+
const translate = GetTranslateFromContext(legacyContext);
|
|
16
|
+
const klfButtonProps = useMemo(() => _extends({}, klf, {
|
|
12
17
|
icon: {
|
|
13
18
|
position: 'left',
|
|
14
19
|
type: 'key'
|
|
15
20
|
},
|
|
16
21
|
type: 'primary'
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
}), [klf]);
|
|
23
|
+
const AnchorButton = useCallback(({
|
|
24
|
+
onKeyDown
|
|
25
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
22
26
|
className: style.klfButtonContainer
|
|
23
27
|
}, /*#__PURE__*/React.createElement(ButtonLink, _extends({}, klfButtonProps, {
|
|
24
|
-
className: style.klfButton
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
+
className: style.klfButton,
|
|
29
|
+
onKeyDown: onKeyDown,
|
|
30
|
+
useTitle: false
|
|
31
|
+
}))), [klfButtonProps]);
|
|
32
|
+
const TooltipContent = useCallback(() => /*#__PURE__*/React.createElement("span", {
|
|
28
33
|
className: style.tooltipText // eslint-disable-next-line react/no-danger
|
|
29
34
|
,
|
|
30
35
|
dangerouslySetInnerHTML: {
|
|
31
36
|
__html: klf.tooltip
|
|
32
37
|
}
|
|
33
|
-
}))
|
|
38
|
+
}), [klf.tooltip]);
|
|
39
|
+
const toolTipProps = useMemo(() => ({
|
|
40
|
+
closeToolTipInformationTextAriaLabel: translate('Press the escape key to close the information text'),
|
|
41
|
+
AnchorElement: AnchorButton,
|
|
42
|
+
TooltipContent,
|
|
43
|
+
'aria-label': translate('More details'),
|
|
44
|
+
tooltipClassName: style.toolTipCustomization
|
|
45
|
+
}), [AnchorButton, TooltipContent, translate]);
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
className: style.klfContainer
|
|
48
|
+
}, /*#__PURE__*/React.createElement(Tooltip, toolTipProps));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
KlfButton.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
52
|
+
klf: propTypes.klf
|
|
53
|
+
} : {};
|
|
54
|
+
KlfButton.contextTypes = {
|
|
55
|
+
translate: Provider.childContextTypes.translate
|
|
34
56
|
};
|
|
35
57
|
|
|
36
58
|
const ReviewCorrectionPopin = props => {
|
|
@@ -46,7 +68,9 @@ const ReviewCorrectionPopin = props => {
|
|
|
46
68
|
type: 'primary'
|
|
47
69
|
});
|
|
48
70
|
|
|
49
|
-
const cta = type === 'wrong' ?
|
|
71
|
+
const cta = type === 'wrong' ? /*#__PURE__*/React.createElement(KlfButton, {
|
|
72
|
+
klf: klf
|
|
73
|
+
}) : null;
|
|
50
74
|
const ICONS = {
|
|
51
75
|
right: RightIcon,
|
|
52
76
|
wrong: WrongIcon
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","classnames","NovaCompositionCoorpacademyCheck","RightIcon","NovaSolidStatusClose","WrongIcon","ButtonLink","style","propTypes","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useMemo","classnames","NovaCompositionCoorpacademyCheck","RightIcon","NovaSolidStatusClose","WrongIcon","ButtonLink","Provider","GetTranslateFromContext","Tooltip","style","propTypes","KlfButton","klf","legacyContext","translate","klfButtonProps","icon","position","type","AnchorButton","onKeyDown","klfButtonContainer","klfButton","TooltipContent","tooltipText","__html","tooltip","toolTipProps","closeToolTipInformationTextAriaLabel","AnchorElement","tooltipClassName","toolTipCustomization","klfContainer","contextTypes","childContextTypes","ReviewCorrectionPopin","props","information","resultLabel","next","nextQuestionButtonProps","cta","ICONS","right","wrong","Icon","wrapper","popin","correctionSection","iconCircle","iconRight","iconWrong","feedbackSection","labelContainer","label","message","actions","actionsWrong","nextQuestionContainer","nextQuestionButton"],"sources":["../../../src/molecule/review-correction-popin/index.js"],"sourcesContent":["import React, {useCallback, useMemo} from 'react';\nimport classnames from 'classnames';\nimport {\n NovaCompositionCoorpacademyCheck as RightIcon,\n NovaSolidStatusClose as WrongIcon\n} from '@coorpacademy/nova-icons';\nimport ButtonLink from '../../atom/button-link';\nimport Provider, {GetTranslateFromContext} from '../../atom/provider';\nimport Tooltip from '../../atom/tooltip';\nimport style from './style.css';\nimport propTypes from './prop-types';\n\nconst KlfButton = ({klf}, legacyContext) => {\n const translate = GetTranslateFromContext(legacyContext);\n const klfButtonProps = useMemo(\n () => ({\n ...klf,\n icon: {\n position: 'left',\n type: 'key'\n },\n type: 'primary'\n }),\n [klf]\n );\n\n const AnchorButton = useCallback(\n ({onKeyDown}) => (\n <div className={style.klfButtonContainer}>\n <ButtonLink\n {...klfButtonProps}\n className={style.klfButton}\n onKeyDown={onKeyDown}\n useTitle={false}\n />\n </div>\n ),\n [klfButtonProps]\n );\n\n const TooltipContent = useCallback(\n () => (\n <span\n className={style.tooltipText}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: klf.tooltip}}\n />\n ),\n [klf.tooltip]\n );\n\n const toolTipProps = useMemo(\n () => ({\n closeToolTipInformationTextAriaLabel: translate(\n 'Press the escape key to close the information text'\n ),\n AnchorElement: AnchorButton,\n TooltipContent,\n 'aria-label': translate('More details'),\n tooltipClassName: style.toolTipCustomization\n }),\n [AnchorButton, TooltipContent, translate]\n );\n\n return (\n <div className={style.klfContainer}>\n <Tooltip {...toolTipProps} />\n </div>\n );\n};\n\nKlfButton.propTypes = {\n klf: propTypes.klf\n};\n\nKlfButton.contextTypes = {\n translate: Provider.childContextTypes.translate\n};\n\nconst ReviewCorrectionPopin = props => {\n const {information, resultLabel, type, klf, next} = props;\n\n const nextQuestionButtonProps = {\n ...next,\n type: 'primary'\n };\n\n const cta = type === 'wrong' ? <KlfButton klf={klf} /> : null;\n\n const ICONS = {\n right: RightIcon,\n wrong: WrongIcon\n };\n const Icon = ICONS[type];\n\n return (\n <div className={style.wrapper} data-testid=\"review-correction-popin\">\n <div className={classnames(style.popin, type === 'right' ? style.right : style.wrong)}>\n <div className={style.correctionSection}>\n <div className={style.iconCircle}>\n <Icon className={type === 'right' ? style.iconRight : style.iconWrong} />\n </div>\n <div className={style.resultLabel}>\n <span aria-label={resultLabel} role=\"status\">\n {resultLabel}\n </span>\n </div>\n </div>\n <div className={style.feedbackSection}>\n <div className={style.information} aria-label=\"answer-information\">\n <div className={style.labelContainer}>\n <span className={style.label} aria-label={information.label}>\n {information.label}\n </span>\n </div>\n <span\n className={style.message}\n aria-label={information.message}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: information.message}}\n />\n </div>\n </div>\n <div className={type === 'right' ? style.actions : style.actionsWrong}>\n {cta}\n <div className={style.nextQuestionContainer} data-testid=\"next-question-button-container\">\n <ButtonLink {...nextQuestionButtonProps} className={style.nextQuestionButton} />\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nReviewCorrectionPopin.propTypes = propTypes;\n\nexport default ReviewCorrectionPopin;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,OAA5B,QAA0C,OAA1C;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SACEC,gCAAgC,IAAIC,SADtC,EAEEC,oBAAoB,IAAIC,SAF1B,QAGO,0BAHP;AAIA,OAAOC,UAAP,MAAuB,wBAAv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,SAAS,EAAE1C,KAAK,CAAC6B;EAAtB,gBACE;IAAM,cAAYA,WAAlB;IAA+B,IAAI,EAAC;EAApC,GACGA,WADH,CADF,CAJF,CADF,eAWE;IAAK,SAAS,EAAE7B,KAAK,CAAC2C;EAAtB,gBACE;IAAK,SAAS,EAAE3C,KAAK,CAAC4B,WAAtB;IAAmC,cAAW;EAA9C,gBACE;IAAK,SAAS,EAAE5B,KAAK,CAAC4C;EAAtB,gBACE;IAAM,SAAS,EAAE5C,KAAK,CAAC6C,KAAvB;IAA8B,cAAYjB,WAAW,CAACiB;EAAtD,GACGjB,WAAW,CAACiB,KADf,CADF,CADF,eAME;IACE,SAAS,EAAE7C,KAAK,CAAC8C,OADnB;IAEE,cAAYlB,WAAW,CAACkB,OAF1B,CAGE;IAHF;IAIE,uBAAuB,EAAE;MAAC9B,MAAM,EAAEY,WAAW,CAACkB;IAArB;EAJ3B,EANF,CADF,CAXF,eA0BE;IAAK,SAAS,EAAErC,IAAI,KAAK,OAAT,GAAmBT,KAAK,CAAC+C,OAAzB,GAAmC/C,KAAK,CAACgD;EAAzD,GACGhB,GADH,eAEE;IAAK,SAAS,EAAEhC,KAAK,CAACiD,qBAAtB;IAA6C,eAAY;EAAzD,gBACE,oBAAC,UAAD,eAAgBlB,uBAAhB;IAAyC,SAAS,EAAE/B,KAAK,CAACkD;EAA1D,GADF,CAFF,CA1BF,CADF,CADF;AAqCD,CArDD;;AAuDAxB,qBAAqB,CAACzB,SAAtB,2CAAkCA,SAAlC;AAEA,eAAeyB,qBAAf"}
|
|
@@ -137,34 +137,6 @@
|
|
|
137
137
|
flex: 0 1 auto;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
.toolTip {
|
|
141
|
-
visibility: hidden;
|
|
142
|
-
opacity: 0;
|
|
143
|
-
transition: opacity 0.4s;
|
|
144
|
-
position: absolute;
|
|
145
|
-
width: 142%;
|
|
146
|
-
border-radius: 15px;
|
|
147
|
-
background-color: white;
|
|
148
|
-
right: 0px;
|
|
149
|
-
bottom: 55px;
|
|
150
|
-
filter: drop-shadow(0px 4px 16px rgba(0, 0, 0, 0.32));
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.toolTip::before {
|
|
154
|
-
content: '';
|
|
155
|
-
display: inline-block;
|
|
156
|
-
visibility: hidden;
|
|
157
|
-
opacity: 0;
|
|
158
|
-
width: 15px;
|
|
159
|
-
height: 15px;
|
|
160
|
-
transform: rotate(-45deg);
|
|
161
|
-
transition: opacity 0.4s;
|
|
162
|
-
background-color: white;
|
|
163
|
-
position: inherit;
|
|
164
|
-
bottom: -7px;
|
|
165
|
-
right: 10%;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
140
|
.tooltipText {
|
|
169
141
|
display: inline-block;
|
|
170
142
|
margin: 16px;
|
|
@@ -184,16 +156,6 @@
|
|
|
184
156
|
position: relative;
|
|
185
157
|
}
|
|
186
158
|
|
|
187
|
-
.klfButtonContainer:hover ~ .toolTip {
|
|
188
|
-
visibility: visible;
|
|
189
|
-
opacity: 1;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.klfButtonContainer:hover ~ .toolTip::before {
|
|
193
|
-
visibility: visible;
|
|
194
|
-
opacity: 1;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
159
|
.klfButtonContainer {
|
|
198
160
|
width: 100%;
|
|
199
161
|
margin-right: 16px;
|
|
@@ -225,6 +187,13 @@
|
|
|
225
187
|
background: linear-gradient(0deg, rgba(0, 0, 0, 0.07), rgba(0, 0, 0, 0.07)), #FFFFFF;
|
|
226
188
|
}
|
|
227
189
|
|
|
190
|
+
.toolTipCustomization {
|
|
191
|
+
right: 0;
|
|
192
|
+
bottom: 52px;
|
|
193
|
+
background-color: white;
|
|
194
|
+
filter: drop-shadow(0px 4px 16px rgba(0, 0, 0, 0.32));
|
|
195
|
+
}
|
|
196
|
+
|
|
228
197
|
@media tablet {
|
|
229
198
|
.resultLabel {
|
|
230
199
|
display: none;
|
|
@@ -248,6 +217,10 @@
|
|
|
248
217
|
}
|
|
249
218
|
|
|
250
219
|
@media mobile {
|
|
220
|
+
.toolTipCustomization {
|
|
221
|
+
right: 90px;
|
|
222
|
+
}
|
|
223
|
+
|
|
251
224
|
.popin {
|
|
252
225
|
width: 100%;
|
|
253
226
|
min-height: 100px;
|
|
@@ -305,19 +278,4 @@
|
|
|
305
278
|
.klfButtonContainer {
|
|
306
279
|
margin: 0;
|
|
307
280
|
}
|
|
308
|
-
|
|
309
|
-
.toolTip {
|
|
310
|
-
width: 106%;
|
|
311
|
-
right: -3%;
|
|
312
|
-
top: auto;
|
|
313
|
-
bottom: 52px;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
.toolTip::before {
|
|
317
|
-
right: 50%
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
.tooltipText {
|
|
321
|
-
max-width: none;
|
|
322
|
-
}
|
|
323
281
|
}
|
|
@@ -449,6 +449,7 @@ declare namespace BrandForm {
|
|
|
449
449
|
type: PropTypes.Requireable<string>;
|
|
450
450
|
}>>;
|
|
451
451
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
452
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
452
453
|
link: PropTypes.Requireable<PropTypes.InferProps<{
|
|
453
454
|
href: PropTypes.Requireable<string>;
|
|
454
455
|
download: PropTypes.Requireable<boolean>;
|
|
@@ -457,6 +458,7 @@ declare namespace BrandForm {
|
|
|
457
458
|
disabled: PropTypes.Requireable<boolean>;
|
|
458
459
|
className: PropTypes.Requireable<string>;
|
|
459
460
|
customStyle: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
461
|
+
useTitle: PropTypes.Requireable<boolean>;
|
|
460
462
|
}> | PropTypes.InferProps<{
|
|
461
463
|
type: PropTypes.Requireable<string>;
|
|
462
464
|
title: PropTypes.Requireable<string>;
|
|
@@ -20,6 +20,7 @@ declare namespace ListItems {
|
|
|
20
20
|
type: PropTypes.Requireable<string>;
|
|
21
21
|
}>>;
|
|
22
22
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
24
|
link: PropTypes.Requireable<PropTypes.InferProps<{
|
|
24
25
|
href: PropTypes.Requireable<string>;
|
|
25
26
|
download: PropTypes.Requireable<boolean>;
|
|
@@ -28,6 +29,7 @@ declare namespace ListItems {
|
|
|
28
29
|
disabled: PropTypes.Requireable<boolean>;
|
|
29
30
|
className: PropTypes.Requireable<string>;
|
|
30
31
|
customStyle: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
32
|
+
useTitle: PropTypes.Requireable<boolean>;
|
|
31
33
|
}>>;
|
|
32
34
|
items: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
33
35
|
bulletPointMenuButton: PropTypes.Requireable<PropTypes.InferProps<{
|