@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
|
@@ -80,7 +80,8 @@ const InputSwitch = props => {
|
|
|
80
80
|
"aria-labelledby": `title-view-${dataName}`
|
|
81
81
|
}), /*#__PURE__*/React.createElement("label", {
|
|
82
82
|
htmlFor: idSwitch,
|
|
83
|
-
"data-name": "input-switch-label"
|
|
83
|
+
"data-name": "input-switch-label",
|
|
84
|
+
tabIndex: 0
|
|
84
85
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
85
86
|
className: !details ? style.alignedTextContainer : null
|
|
86
87
|
}, titlePosition === 'right' ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","getClassState","style","InputSwitch","props","title","name","id","value","disabled","onChange","description","modified","theme","titlePosition","details","requiredSelection","dataName","idSwitch","isDisabled","handleChange","e","target","checked","titleView","descriptionView","getClass","defaultClass","coorpmanager","modifiedClass","coorpmanagerModified","partielUncheck","default","className","btnSwitchContainer","checkbox","alignedTextContainer","detailsTxt","propTypes","string","bool","func","oneOf"],"sources":["../../../src/atom/input-switch/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {noop, uniqueId} from 'lodash/fp';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst InputSwitch = props => {\n const {\n title,\n name,\n id,\n value,\n disabled,\n onChange = noop,\n description,\n modified = false,\n theme = 'default',\n titlePosition = 'left',\n details = '',\n requiredSelection = false,\n 'data-name': dataName\n } = props;\n\n const idSwitch = id || uniqueId('input-switch-');\n const isDisabled = disabled ? 'disabled' : '';\n const handleChange = useMemo(() => e => onChange(e.target.checked), [onChange]);\n\n const titleView = title ? <span className={style.title}>{`${title} `}</span> : null;\n\n const descriptionView = description ? (\n <div className={style.description}>{description}</div>\n ) : null;\n\n const getClass = () => {\n switch (theme) {\n case 'coorpmanager':\n return {\n defaultClass: style.coorpmanager,\n modifiedClass: style.coorpmanagerModified\n };\n case 'mooc':\n return {\n defaultClass: style.partielUncheck,\n modifiedClass: style.coorpmanagerModified\n };\n default:\n return {defaultClass: style.default, modifiedClass: style.modified};\n }\n };\n const {defaultClass, modifiedClass} = getClass();\n const className = getClassState(defaultClass, modifiedClass, null, modified);\n\n return (\n <div className={className} data-name={`switch-input-${theme}${dataName}`}>\n {titlePosition === 'left' ? <div id={`title-view-${dataName}`}>{titleView} </div> : null}\n <div className={requiredSelection ? style.requiredSelection : null}>\n <div className={style.btnSwitchContainer}>\n <input\n type=\"checkbox\"\n id={idSwitch}\n name={name}\n onChange={handleChange}\n checked={value}\n disabled={isDisabled}\n className={style.checkbox}\n aria-labelledby={`title-view-${dataName}`}\n />\n <label htmlFor={idSwitch} data-name=\"input-switch-label\" />\n </div>\n </div>\n <div className={!details ? style.alignedTextContainer : null}>\n {titlePosition === 'right' ? <div id={`title-view-${dataName}`}>{titleView} </div> : null}\n {details ? <div className={style.detailsTxt}>{details}</div> : null}\n </div>\n {descriptionView}\n </div>\n );\n};\n\nInputSwitch.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n id: PropTypes.string,\n value: PropTypes.bool,\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n description: PropTypes.string,\n modified: PropTypes.bool,\n titlePosition: PropTypes.oneOf(['right', 'left']),\n theme: PropTypes.oneOf(['default', 'coorpmanager', 'mooc']),\n details: PropTypes.string,\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O;UACLH,YAAY,EAAEzB,KAAK,CAAC6B,cADf;UAELF,aAAa,EAAE3B,KAAK,CAAC4B;QAFhB,CAAP;;MAIF;QACE,OAAO;UAACH,YAAY,EAAEzB,KAAK,CAAC8B,OAArB;UAA8BH,aAAa,EAAE3B,KAAK,CAACU;QAAnD,CAAP;IAZJ;EAcD,CAfD;;EAgBA,MAAM;IAACe,YAAD;IAAeE;EAAf,IAAgCH,QAAQ,EAA9C;EACA,MAAMO,SAAS,GAAGhC,aAAa,CAAC0B,YAAD,EAAeE,aAAf,EAA8B,IAA9B,EAAoCjB,QAApC,CAA/B;EAEA,oBACE;IAAK,SAAS,EAAEqB,SAAhB;IAA2B,aAAY,gBAAepB,KAAM,GAAEI,QAAS;EAAvE,GACGH,aAAa,KAAK,MAAlB,gBAA2B;IAAK,EAAE,EAAG,cAAaG,QAAS;EAAhC,GAAoCO,SAApC,MAA3B,GAAmF,IADtF,eAEE;IAAK,SAAS,EAAER,iBAAiB,GAAGd,KAAK,CAACc,iBAAT,GAA6B;EAA9D,gBACE;IAAK,SAAS,EAAEd,KAAK,CAACgC;EAAtB,gBACE;IACE,IAAI,EAAC,UADP;IAEE,EAAE,EAAEhB,QAFN;IAGE,IAAI,EAAEZ,IAHR;IAIE,QAAQ,EAAEc,YAJZ;IAKE,OAAO,EAAEZ,KALX;IAME,QAAQ,EAAEW,UANZ;IAOE,SAAS,EAAEjB,KAAK,CAACiC,QAPnB;IAQE,mBAAkB,cAAalB,QAAS;EAR1C,EADF,eAWE;IAAO,OAAO,EAAEC,QAAhB;IAA0B,aAAU;
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","getClassState","style","InputSwitch","props","title","name","id","value","disabled","onChange","description","modified","theme","titlePosition","details","requiredSelection","dataName","idSwitch","isDisabled","handleChange","e","target","checked","titleView","descriptionView","getClass","defaultClass","coorpmanager","modifiedClass","coorpmanagerModified","partielUncheck","default","className","btnSwitchContainer","checkbox","alignedTextContainer","detailsTxt","propTypes","string","bool","func","oneOf"],"sources":["../../../src/atom/input-switch/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {noop, uniqueId} from 'lodash/fp';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst InputSwitch = props => {\n const {\n title,\n name,\n id,\n value,\n disabled,\n onChange = noop,\n description,\n modified = false,\n theme = 'default',\n titlePosition = 'left',\n details = '',\n requiredSelection = false,\n 'data-name': dataName\n } = props;\n\n const idSwitch = id || uniqueId('input-switch-');\n const isDisabled = disabled ? 'disabled' : '';\n const handleChange = useMemo(() => e => onChange(e.target.checked), [onChange]);\n\n const titleView = title ? <span className={style.title}>{`${title} `}</span> : null;\n\n const descriptionView = description ? (\n <div className={style.description}>{description}</div>\n ) : null;\n\n const getClass = () => {\n switch (theme) {\n case 'coorpmanager':\n return {\n defaultClass: style.coorpmanager,\n modifiedClass: style.coorpmanagerModified\n };\n case 'mooc':\n return {\n defaultClass: style.partielUncheck,\n modifiedClass: style.coorpmanagerModified\n };\n default:\n return {defaultClass: style.default, modifiedClass: style.modified};\n }\n };\n const {defaultClass, modifiedClass} = getClass();\n const className = getClassState(defaultClass, modifiedClass, null, modified);\n\n return (\n <div className={className} data-name={`switch-input-${theme}${dataName}`}>\n {titlePosition === 'left' ? <div id={`title-view-${dataName}`}>{titleView} </div> : null}\n <div className={requiredSelection ? style.requiredSelection : null}>\n <div className={style.btnSwitchContainer}>\n <input\n type=\"checkbox\"\n id={idSwitch}\n name={name}\n onChange={handleChange}\n checked={value}\n disabled={isDisabled}\n className={style.checkbox}\n aria-labelledby={`title-view-${dataName}`}\n />\n <label htmlFor={idSwitch} data-name=\"input-switch-label\" tabIndex={0} />\n </div>\n </div>\n <div className={!details ? style.alignedTextContainer : null}>\n {titlePosition === 'right' ? <div id={`title-view-${dataName}`}>{titleView} </div> : null}\n {details ? <div className={style.detailsTxt}>{details}</div> : null}\n </div>\n {descriptionView}\n </div>\n );\n};\n\nInputSwitch.propTypes = {\n title: PropTypes.string,\n name: PropTypes.string,\n id: PropTypes.string,\n value: PropTypes.bool,\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n description: PropTypes.string,\n modified: PropTypes.bool,\n titlePosition: PropTypes.oneOf(['right', 'left']),\n theme: PropTypes.oneOf(['default', 'coorpmanager', 'mooc']),\n details: PropTypes.string,\n 'data-name': PropTypes.string,\n requiredSelection: PropTypes.bool\n};\nexport default InputSwitch;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,OAAf,QAA6B,OAA7B;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,WAAW,GAAGC,KAAK,IAAI;EAC3B,MAAM;IACJC,KADI;IAEJC,IAFI;IAGJC,EAHI;IAIJC,KAJI;IAKJC,QALI;IAMJC,QAAQ,QANJ;IAOJC,WAPI;IAQJC,QAAQ,GAAG,KARP;IASJC,KAAK,GAAG,SATJ;IAUJC,aAAa,GAAG,MAVZ;IAWJC,OAAO,GAAG,EAXN;IAYJC,iBAAiB,GAAG,KAZhB;IAaJ,aAAaC;EAbT,IAcFb,KAdJ;;EAgBA,MAAMc,QAAQ,GAAGX,EAAE,IAAI,UAAS,eAAT,CAAvB;;EACA,MAAMY,UAAU,GAAGV,QAAQ,GAAG,UAAH,GAAgB,EAA3C;EACA,MAAMW,YAAY,GAAGrB,OAAO,CAAC,MAAMsB,CAAC,IAAIX,QAAQ,CAACW,CAAC,CAACC,MAAF,CAASC,OAAV,CAApB,EAAwC,CAACb,QAAD,CAAxC,CAA5B;EAEA,MAAMc,SAAS,GAAGnB,KAAK,gBAAG;IAAM,SAAS,EAAEH,KAAK,CAACG;EAAvB,GAAgC,GAAEA,KAAM,GAAxC,CAAH,GAAwD,IAA/E;EAEA,MAAMoB,eAAe,GAAGd,WAAW,gBACjC;IAAK,SAAS,EAAET,KAAK,CAACS;EAAtB,GAAoCA,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,EAXF,CADF,CAFF,eAiBE;IAAK,SAAS,EAAE,CAACH,OAAD,GAAWb,KAAK,CAACkC,oBAAjB,GAAwC;EAAxD,GACGtB,aAAa,KAAK,OAAlB,gBAA4B;IAAK,EAAE,EAAG,cAAaG,QAAS;EAAhC,GAAoCO,SAApC,MAA5B,GAAoF,IADvF,EAEGT,OAAO,gBAAG;IAAK,SAAS,EAAEb,KAAK,CAACmC;EAAtB,GAAmCtB,OAAnC,CAAH,GAAuD,IAFjE,CAjBF,EAqBGU,eArBH,CADF;AAyBD,CAvED;;AAyEAtB,WAAW,CAACmC,SAAZ,2CAAwB;EACtBjC,KAAK,EAAEL,SAAS,CAACuC,MADK;EAEtBjC,IAAI,EAAEN,SAAS,CAACuC,MAFM;EAGtBhC,EAAE,EAAEP,SAAS,CAACuC,MAHQ;EAItB/B,KAAK,EAAER,SAAS,CAACwC,IAJK;EAKtB/B,QAAQ,EAAET,SAAS,CAACwC,IALE;EAMtB9B,QAAQ,EAAEV,SAAS,CAACyC,IANE;EAOtB9B,WAAW,EAAEX,SAAS,CAACuC,MAPD;EAQtB3B,QAAQ,EAAEZ,SAAS,CAACwC,IARE;EAStB1B,aAAa,EAAEd,SAAS,CAAC0C,KAAV,CAAgB,CAAC,OAAD,EAAU,MAAV,CAAhB,CATO;EAUtB7B,KAAK,EAAEb,SAAS,CAAC0C,KAAV,CAAgB,CAAC,SAAD,EAAY,cAAZ,EAA4B,MAA5B,CAAhB,CAVe;EAWtB3B,OAAO,EAAEf,SAAS,CAACuC,MAXG;EAYtB,aAAavC,SAAS,CAACuC,MAZD;EAatBvB,iBAAiB,EAAEhB,SAAS,CAACwC;AAbP,CAAxB;AAeA,eAAerC,WAAf"}
|
package/es/atom/link/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default Link;
|
|
2
|
-
declare
|
|
3
|
-
|
|
2
|
+
declare function Link(props: any, legacyContext: any): JSX.Element;
|
|
3
|
+
declare namespace Link {
|
|
4
|
+
const propTypes: {
|
|
4
5
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
5
6
|
className: PropTypes.Requireable<string>;
|
|
6
7
|
href: PropTypes.Requireable<string>;
|
|
@@ -15,8 +16,8 @@ declare class Link extends React.Component<any, any, any> {
|
|
|
15
16
|
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
17
|
style: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
-
skin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
19
|
+
namespace contextTypes {
|
|
20
|
+
const skin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
20
21
|
common: PropTypes.Requireable<{
|
|
21
22
|
[x: string]: any;
|
|
22
23
|
}>;
|
|
@@ -37,20 +38,11 @@ declare class Link extends React.Component<any, any, any> {
|
|
|
37
38
|
[x: string]: any;
|
|
38
39
|
}>;
|
|
39
40
|
}>>;
|
|
40
|
-
history: PropTypes.Requireable<PropTypes.InferProps<{
|
|
41
|
+
const history: PropTypes.Requireable<PropTypes.InferProps<{
|
|
41
42
|
createHref: PropTypes.Requireable<(...args: any[]) => any>;
|
|
42
43
|
push: PropTypes.Requireable<(...args: any[]) => any>;
|
|
43
44
|
}>>;
|
|
44
|
-
}
|
|
45
|
-
constructor(props: any);
|
|
46
|
-
state: {
|
|
47
|
-
hovered: boolean;
|
|
48
|
-
};
|
|
49
|
-
handleMouseEnter: () => void;
|
|
50
|
-
handleMouseLeave: () => void;
|
|
51
|
-
handleOnClick: (e: any) => void;
|
|
52
|
-
render(): JSX.Element;
|
|
45
|
+
}
|
|
53
46
|
}
|
|
54
|
-
import React from "react";
|
|
55
47
|
import PropTypes from "prop-types";
|
|
56
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/link/index.js"],"names":[],"mappings":";AAMA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/link/index.js"],"names":[],"mappings":";AAMA,mEA+EC"}
|
package/es/atom/link/index.js
CHANGED
|
@@ -7,107 +7,77 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
7
7
|
|
|
8
8
|
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; }
|
|
9
9
|
|
|
10
|
-
import React from 'react';
|
|
10
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import Provider from '../provider';
|
|
12
|
+
import Provider, { GetSkinFromContext } from '../provider';
|
|
13
13
|
import pushToHistory from '../../util/navigation';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
children
|
|
80
|
-
} = this.props;
|
|
81
|
-
const {
|
|
82
|
-
hovered
|
|
83
|
-
} = this.state;
|
|
84
|
-
|
|
85
|
-
const _style = href || onClick ? null : {
|
|
86
|
-
pointerEvents: 'none'
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const _hoverStyle = skinHover && hovered ? {
|
|
90
|
-
color: hoverColor
|
|
91
|
-
} : null;
|
|
92
|
-
|
|
93
|
-
return /*#__PURE__*/React.createElement("a", _extends({}, aProps, {
|
|
94
|
-
"data-name": dataName,
|
|
95
|
-
"aria-label": ariaLabel,
|
|
96
|
-
href: href ? createHref(href) : undefined,
|
|
97
|
-
onClick: this.handleOnClick,
|
|
98
|
-
onMouseEnter: this.handleMouseEnter,
|
|
99
|
-
onMouseLeave: this.handleMouseLeave,
|
|
100
|
-
className: className,
|
|
101
|
-
style: _extends({}, propsStyle, _style, _hoverStyle)
|
|
102
|
-
}), children);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
Link.contextTypes = {
|
|
108
|
-
skin: Provider.childContextTypes.skin,
|
|
109
|
-
history: Provider.childContextTypes.history
|
|
15
|
+
const Link = (props, legacyContext) => {
|
|
16
|
+
const skin = GetSkinFromContext(legacyContext);
|
|
17
|
+
const [hovered, setHovered] = useState(false);
|
|
18
|
+
const {
|
|
19
|
+
history: {
|
|
20
|
+
createHref = _identity
|
|
21
|
+
} = {}
|
|
22
|
+
} = legacyContext;
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
skinHover,
|
|
26
|
+
hoverColor = _getOr('#00B0FF', 'common.primary', skin),
|
|
27
|
+
'data-name': dataName = 'link',
|
|
28
|
+
'aria-label': ariaLabel
|
|
29
|
+
} = props,
|
|
30
|
+
linKElementProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
href,
|
|
34
|
+
onClick = _noop,
|
|
35
|
+
className,
|
|
36
|
+
style: propsStyle,
|
|
37
|
+
children,
|
|
38
|
+
onMouseLeave = _noop,
|
|
39
|
+
onMouseEnter = _noop,
|
|
40
|
+
download
|
|
41
|
+
} = props;
|
|
42
|
+
const handleMouseEnter = useCallback(() => {
|
|
43
|
+
setHovered(true);
|
|
44
|
+
onMouseEnter();
|
|
45
|
+
}, [onMouseEnter]);
|
|
46
|
+
const handleMouseLeave = useCallback(() => {
|
|
47
|
+
setHovered(false);
|
|
48
|
+
onMouseLeave();
|
|
49
|
+
}, [onMouseLeave]);
|
|
50
|
+
const navigate = useMemo(() => pushToHistory(legacyContext)({
|
|
51
|
+
href
|
|
52
|
+
}), [href, legacyContext]);
|
|
53
|
+
const handleOnClick = useCallback(e => {
|
|
54
|
+
onClick(e);
|
|
55
|
+
|
|
56
|
+
if (!download) {
|
|
57
|
+
navigate(e);
|
|
58
|
+
}
|
|
59
|
+
}, [download, navigate, onClick]);
|
|
60
|
+
|
|
61
|
+
const _style = href || onClick ? null : {
|
|
62
|
+
pointerEvents: 'none'
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const _hoverStyle = skinHover && hovered ? {
|
|
66
|
+
color: hoverColor
|
|
67
|
+
} : null;
|
|
68
|
+
|
|
69
|
+
return /*#__PURE__*/React.createElement("a", _extends({}, linKElementProps, {
|
|
70
|
+
"data-name": dataName,
|
|
71
|
+
"aria-label": ariaLabel,
|
|
72
|
+
href: href ? createHref(href) : undefined,
|
|
73
|
+
onClick: handleOnClick,
|
|
74
|
+
onMouseEnter: handleMouseEnter,
|
|
75
|
+
onMouseLeave: handleMouseLeave,
|
|
76
|
+
className: className,
|
|
77
|
+
style: _extends({}, propsStyle, _style, _hoverStyle)
|
|
78
|
+
}), children);
|
|
110
79
|
};
|
|
80
|
+
|
|
111
81
|
Link.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
112
82
|
children: PropTypes.node,
|
|
113
83
|
className: PropTypes.string,
|
|
@@ -123,5 +93,9 @@ Link.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
123
93
|
onMouseLeave: PropTypes.func,
|
|
124
94
|
style: PropTypes.shape({})
|
|
125
95
|
} : {};
|
|
96
|
+
Link.contextTypes = {
|
|
97
|
+
skin: Provider.childContextTypes.skin,
|
|
98
|
+
history: Provider.childContextTypes.history
|
|
99
|
+
};
|
|
126
100
|
export default Link;
|
|
127
101
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useMemo","useState","PropTypes","Provider","GetSkinFromContext","pushToHistory","Link","props","legacyContext","skin","hovered","setHovered","history","createHref","skinHover","hoverColor","dataName","ariaLabel","linKElementProps","href","onClick","className","style","propsStyle","children","onMouseLeave","onMouseEnter","download","handleMouseEnter","handleMouseLeave","navigate","handleOnClick","e","_style","pointerEvents","_hoverStyle","color","undefined","propTypes","node","string","target","oneOf","bool","func","shape","contextTypes","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,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,OAA5B,EAAqCC,QAArC,QAAoD,OAApD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,QAAP,IAAkBC,kBAAlB,QAA2C,aAA3C;AACA,OAAOC,aAAP,MAA0B,uBAA1B;;AAEA,MAAMC,IAAI,GAAG,CAACC,KAAD,EAAQC,aAAR,KAA0B;EACrC,MAAMC,IAAI,GAAGL,kBAAkB,CAACI,aAAD,CAA/B;EACA,MAAM,CAACE,OAAD,EAAUC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,IAAf"}
|
|
@@ -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"}
|
package/es/atom/tooltip/index.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import React, { isValidElement, useState, useCallback, useMemo } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import ReactTooltip from 'react-tooltip';
|
|
4
5
|
import isString from 'lodash/fp/isString';
|
|
5
6
|
import { NovaCompositionCoorpacademyInformationIcon as InformationIcon } from '@coorpacademy/nova-icons';
|
|
6
7
|
import style from './style.css';
|
|
8
|
+
const FontSizes = {
|
|
9
|
+
12: style.tooltipContentFontSize12,
|
|
10
|
+
14: style.tooltipContentFontSize14
|
|
11
|
+
};
|
|
7
12
|
|
|
8
13
|
const ToolTipWrapper = ({
|
|
9
14
|
toolTipIsVisible,
|
|
10
15
|
anchorId,
|
|
11
16
|
closeToolTipInformationTextAriaLabel,
|
|
12
|
-
content
|
|
17
|
+
content,
|
|
18
|
+
handleContentMouseOver
|
|
13
19
|
}) => {
|
|
14
20
|
if (!toolTipIsVisible) return null;
|
|
15
21
|
|
|
@@ -26,7 +32,8 @@ const ToolTipWrapper = ({
|
|
|
26
32
|
return /*#__PURE__*/React.createElement("div", {
|
|
27
33
|
className: style.toolTip,
|
|
28
34
|
"data-testid": "tooltip",
|
|
29
|
-
"aria-label": closeToolTipInformationTextAriaLabel
|
|
35
|
+
"aria-label": closeToolTipInformationTextAriaLabel,
|
|
36
|
+
onMouseOver: handleContentMouseOver
|
|
30
37
|
}, content);
|
|
31
38
|
}
|
|
32
39
|
};
|
|
@@ -35,7 +42,8 @@ ToolTipWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
35
42
|
toolTipIsVisible: PropTypes.bool,
|
|
36
43
|
anchorId: PropTypes.string,
|
|
37
44
|
closeToolTipInformationTextAriaLabel: PropTypes.string.isRequired,
|
|
38
|
-
content: PropTypes.node
|
|
45
|
+
content: PropTypes.node,
|
|
46
|
+
handleContentMouseOver: PropTypes.func
|
|
39
47
|
} : {};
|
|
40
48
|
export const toggleStateOnKeyPress = (state, setState, ref) => event => {
|
|
41
49
|
if (event.key === 'Enter') {
|
|
@@ -54,38 +62,49 @@ const ToolTip = ({
|
|
|
54
62
|
'aria-label': ariaLabel,
|
|
55
63
|
'data-testid': dataTestId,
|
|
56
64
|
closeToolTipInformationTextAriaLabel,
|
|
57
|
-
toolTipIsVisible: _toolTipIsVisible
|
|
65
|
+
toolTipIsVisible: _toolTipIsVisible,
|
|
66
|
+
iconContainerClassName,
|
|
67
|
+
delayHide = 250,
|
|
68
|
+
fontSize = 14
|
|
58
69
|
}) => {
|
|
59
70
|
const isComponent = useMemo(() => !isString(TooltipContent) && /*#__PURE__*/isValidElement(TooltipContent()), [TooltipContent]);
|
|
60
71
|
const [toolTipIsVisible, setToolTipIsVisible] = useState(false);
|
|
72
|
+
const [mouseLeaveTimer, setMouseLeaveTimer] = useState(undefined);
|
|
61
73
|
const handleKeyPress = useCallback(event => {
|
|
62
74
|
toggleStateOnKeyPress(toolTipIsVisible, setToolTipIsVisible)(event);
|
|
63
75
|
}, [toolTipIsVisible]);
|
|
76
|
+
const handleContentMouseOver = useCallback(() => {
|
|
77
|
+
mouseLeaveTimer &&
|
|
78
|
+
/* istanbul ignore next */
|
|
79
|
+
clearTimeout(mouseLeaveTimer);
|
|
80
|
+
}, [mouseLeaveTimer]);
|
|
64
81
|
const handleMouseOver = useCallback(() => {
|
|
82
|
+
mouseLeaveTimer && clearTimeout(mouseLeaveTimer);
|
|
65
83
|
setToolTipIsVisible(true);
|
|
66
|
-
}, []);
|
|
84
|
+
}, [mouseLeaveTimer]);
|
|
67
85
|
const handleMouseLeave = useCallback(() => {
|
|
68
|
-
setToolTipIsVisible(false);
|
|
69
|
-
}, []);
|
|
86
|
+
setMouseLeaveTimer(setTimeout(() => setToolTipIsVisible(false), delayHide));
|
|
87
|
+
}, [delayHide]);
|
|
70
88
|
const content = useMemo(() => {
|
|
71
89
|
return isComponent ? /*#__PURE__*/React.createElement(TooltipContent, null) : /*#__PURE__*/React.createElement("p", {
|
|
72
|
-
className: style.tooltipContent
|
|
90
|
+
className: classnames([style.tooltipContent, FontSizes[fontSize]])
|
|
73
91
|
}, TooltipContent);
|
|
74
|
-
}, [TooltipContent, isComponent]);
|
|
92
|
+
}, [TooltipContent, fontSize, isComponent]);
|
|
75
93
|
return anchorId ? /*#__PURE__*/React.createElement(ToolTipWrapper, {
|
|
76
94
|
toolTipIsVisible: _toolTipIsVisible,
|
|
77
95
|
anchorId: anchorId,
|
|
78
96
|
closeToolTipInformationTextAriaLabel: closeToolTipInformationTextAriaLabel,
|
|
79
97
|
content: content,
|
|
80
98
|
onMouseLeave: handleMouseLeave,
|
|
81
|
-
onMouseOver: handleMouseOver
|
|
99
|
+
onMouseOver: handleMouseOver,
|
|
100
|
+
fontSize: fontSize
|
|
82
101
|
}) : /*#__PURE__*/React.createElement("div", {
|
|
83
102
|
className: style.tooltipContainer,
|
|
84
103
|
onMouseLeave: handleMouseLeave,
|
|
85
104
|
onMouseOver: handleMouseOver
|
|
86
105
|
}, /*#__PURE__*/React.createElement("button", {
|
|
87
106
|
type: "button",
|
|
88
|
-
className: style.tooltipIconContainer,
|
|
107
|
+
className: classnames([style.tooltipIconContainer, iconContainerClassName]),
|
|
89
108
|
"data-testid": dataTestId,
|
|
90
109
|
onKeyDown: handleKeyPress,
|
|
91
110
|
tabIndex: 0
|
|
@@ -98,7 +117,9 @@ const ToolTip = ({
|
|
|
98
117
|
toolTipIsVisible: toolTipIsVisible,
|
|
99
118
|
anchorId: anchorId,
|
|
100
119
|
closeToolTipInformationTextAriaLabel: closeToolTipInformationTextAriaLabel,
|
|
101
|
-
content: content
|
|
120
|
+
content: content,
|
|
121
|
+
handleContentMouseOver: handleContentMouseOver,
|
|
122
|
+
fontSize: fontSize
|
|
102
123
|
}));
|
|
103
124
|
};
|
|
104
125
|
|
|
@@ -107,8 +128,12 @@ ToolTip.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
107
128
|
'data-testid': PropTypes.string,
|
|
108
129
|
'aria-label': PropTypes.string,
|
|
109
130
|
closeToolTipInformationTextAriaLabel: PropTypes.string.isRequired,
|
|
110
|
-
// ----------
|
|
111
|
-
|
|
131
|
+
// ---------- Regular Tooltip exclusive --------------
|
|
132
|
+
iconContainerClassName: PropTypes.string,
|
|
133
|
+
delayHide: PropTypes.number,
|
|
134
|
+
fontSize: PropTypes.oneOf([12, 14]),
|
|
135
|
+
// ---------- React Tooltip exclusive --------------
|
|
136
|
+
// externalHandling: if passed down, React Tooltip is used instead, due to limitations on
|
|
112
137
|
// parents overflow hidden controls
|
|
113
138
|
anchorId: PropTypes.string,
|
|
114
139
|
toolTipIsVisible: PropTypes.bool
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","isValidElement","useState","useCallback","useMemo","PropTypes","ReactTooltip","isString","NovaCompositionCoorpacademyInformationIcon","InformationIcon","style","ToolTipWrapper","toolTipIsVisible","anchorId","closeToolTipInformationTextAriaLabel","content","toolTipReact","toolTip","propTypes","bool","string","isRequired","node","toggleStateOnKeyPress","state","setState","ref","event","key","current","focus","stopPropagation","preventDefault","ToolTip","TooltipContent","ariaLabel","dataTestId","_toolTipIsVisible","isComponent","setToolTipIsVisible","handleKeyPress","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,OAAOA,KAAP,IAAeC,cAAf,EAA+BC,QAA/B,EAAyCC,WAAzC,EAAsDC,OAAtD,QAAoE,OAApE;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,YAAP,MAAyB,eAAzB;AACA,OAAOC,QAAP,MAAqB,oBAArB;AACA,SAAQC,0CAA0C,IAAIC,eAAtD,QAA4E,0BAA5E;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,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,oBAAC,YAAD;MACE,EAAE,EAAEA,QADN;MAEE,SAAS,EAAEH,KAAK,CAACM,YAFnB;MAGE,kBAAe,OAHjB;MAIE,KAAK,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F,eAmBE,oBAAC,cAAD;IACE,gBAAgB,EAAEvB,gBADpB;IAEE,QAAQ,EAAEC,QAFZ;IAGE,oCAAoC,EAAEC,oCAHxC;IAIE,OAAO,EAAEC;EAJX,EAnBF,CAVF;AAqCD,CA3ED;;AA6EAkB,OAAO,CAACf,SAAR,2CAAoB;EAClBgB,cAAc,EAAE7B,SAAS,CAAC0C,SAAV,CAAoB,CAAC1C,SAAS,CAAC2C,IAAX,EAAiB3C,SAAS,CAACiB,IAA3B,EAAiCjB,SAAS,CAACe,MAA3C,CAApB,CADE;EAElB,eAAef,SAAS,CAACe,MAFP;EAGlB,cAAcf,SAAS,CAACe,MAHN;EAIlBN,oCAAoC,EAAET,SAAS,CAACe,MAAV,CAAiBC,UAJrC;EAKlB;EACA;EACA;EACAR,QAAQ,EAAER,SAAS,CAACe,MARF;EASlBR,gBAAgB,EAAEP,SAAS,CAACc;AATV,CAApB;AAYA,eAAec,OAAf"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","isValidElement","useState","useCallback","useMemo","classnames","PropTypes","ReactTooltip","isString","NovaCompositionCoorpacademyInformationIcon","InformationIcon","style","FontSizes","tooltipContentFontSize12","tooltipContentFontSize14","ToolTipWrapper","toolTipIsVisible","anchorId","closeToolTipInformationTextAriaLabel","content","handleContentMouseOver","toolTipReact","toolTip","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","setToolTipIsVisible","mouseLeaveTimer","setMouseLeaveTimer","undefined","handleKeyPress","clearTimeout","handleMouseOver","handleMouseLeave","setTimeout","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,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,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,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,oBAAC,YAAD;MACE,EAAE,EAAEA,QADN;MAEE,SAAS,EAAEN,KAAK,CAACU,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,EAAER,KAAK,CAACW,OADnB;MAEE,eAAY,SAFd;MAGE,cAAYJ,oCAHd;MAIE,WAAW,EAAEE;IAJf,GAMGD,OANH,CADF;EAUD;AACF,CAjCD;;AAmCAJ,cAAc,CAACQ,SAAf,2CA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}
|
|
@@ -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"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _isEmpty from "lodash/fp/isEmpty";
|
|
2
|
-
import _map from "lodash/fp/map";
|
|
3
1
|
const _excluded = ["label", "description", "moreInfoAriaLabel"];
|
|
4
2
|
|
|
5
3
|
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); }
|
|
@@ -8,11 +6,16 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
8
6
|
|
|
9
7
|
import React from 'react';
|
|
10
8
|
import PropTypes from 'prop-types';
|
|
11
|
-
import
|
|
9
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
10
|
+
import map from 'lodash/fp/map';
|
|
11
|
+
import { GetTranslateFromContext } from '../../atom/provider';
|
|
12
|
+
import ToolTip from '../../atom/tooltip';
|
|
12
13
|
import InputSwitch from '../../atom/input-switch';
|
|
13
14
|
import style from './style.css';
|
|
14
15
|
|
|
15
16
|
const Settings = props => {
|
|
17
|
+
const translate = GetTranslateFromContext();
|
|
18
|
+
|
|
16
19
|
const {
|
|
17
20
|
label,
|
|
18
21
|
description,
|
|
@@ -23,19 +26,16 @@ const Settings = props => {
|
|
|
23
26
|
return /*#__PURE__*/React.createElement("div", {
|
|
24
27
|
className: style.settings
|
|
25
28
|
}, /*#__PURE__*/React.createElement(InputSwitch, settings), /*#__PURE__*/React.createElement("span", {
|
|
26
|
-
className: style.label
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
37
|
-
className: style.descriptionLabel
|
|
38
|
-
}, description))));
|
|
29
|
+
className: style.label,
|
|
30
|
+
tabIndex: 0
|
|
31
|
+
}, label), isEmpty(description) ? null : /*#__PURE__*/React.createElement(ToolTip, {
|
|
32
|
+
TooltipContent: description,
|
|
33
|
+
closeToolTipInformationTextAriaLabel: translate('Press the escape key to close the information text'),
|
|
34
|
+
"data-testid": "user-preferences-tooltip",
|
|
35
|
+
"aria-label": moreInfoAriaLabel,
|
|
36
|
+
iconContainerClassName: style.infoIconTooltip,
|
|
37
|
+
fontSize: 12
|
|
38
|
+
}));
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
Settings.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, InputSwitch.propTypes, {
|
|
@@ -45,15 +45,16 @@ Settings.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, InputS
|
|
|
45
45
|
|
|
46
46
|
const UserPreferences = props => {
|
|
47
47
|
const {
|
|
48
|
-
preferences
|
|
48
|
+
preferences,
|
|
49
49
|
moreInfoAriaLabel,
|
|
50
50
|
groupAriaLabel
|
|
51
51
|
} = props;
|
|
52
52
|
return /*#__PURE__*/React.createElement("form", null, /*#__PURE__*/React.createElement("div", {
|
|
53
53
|
className: style.preferences,
|
|
54
54
|
role: "group",
|
|
55
|
-
"aria-label": groupAriaLabel
|
|
56
|
-
|
|
55
|
+
"aria-label": groupAriaLabel,
|
|
56
|
+
tabIndex: 0
|
|
57
|
+
}, map(settings => /*#__PURE__*/React.createElement(Settings, _extends({}, settings, {
|
|
57
58
|
key: settings.label,
|
|
58
59
|
moreInfoAriaLabel: moreInfoAriaLabel
|
|
59
60
|
})), preferences)));
|