@coorpacademy/components 11.32.3 → 11.32.5
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/battle-opponent/index.d.ts.map +1 -1
- package/es/atom/battle-opponent/index.js +1 -1
- package/es/atom/battle-opponent/index.js.map +1 -1
- package/es/molecule/base-modal/index.d.ts +24 -1
- package/es/molecule/base-modal/index.d.ts.map +1 -1
- package/es/molecule/base-modal/index.js +26 -5
- package/es/molecule/base-modal/index.js.map +1 -1
- package/es/molecule/card/favorite.d.ts.map +1 -1
- package/es/molecule/card/favorite.js +1 -1
- package/es/molecule/card/favorite.js.map +1 -1
- package/es/molecule/discipline-associated-skills/index.d.ts +17 -0
- package/es/molecule/discipline-associated-skills/index.d.ts.map +1 -0
- package/es/molecule/discipline-associated-skills/index.js +73 -0
- package/es/molecule/discipline-associated-skills/index.js.map +1 -0
- package/es/molecule/discipline-associated-skills/style.css +71 -0
- package/es/molecule/learner-skill-card/index.d.ts +22 -0
- package/es/molecule/learner-skill-card/index.d.ts.map +1 -1
- package/es/molecule/learner-skill-card/index.js +7 -6
- package/es/molecule/learner-skill-card/index.js.map +1 -1
- package/es/molecule/learning-profile-radar-chart/index.d.ts +28 -1
- package/es/molecule/learning-profile-radar-chart/index.d.ts.map +1 -1
- package/es/molecule/learning-profile-radar-chart/index.js +115 -28
- package/es/molecule/learning-profile-radar-chart/index.js.map +1 -1
- package/es/molecule/learning-profile-radar-chart/style.css +14 -0
- package/es/molecule/learning-profile-radar-chart/types.d.ts +2 -0
- package/es/molecule/learning-profile-radar-chart/types.d.ts.map +1 -1
- package/es/molecule/learning-profile-radar-chart/types.js +2 -1
- package/es/molecule/learning-profile-radar-chart/types.js.map +1 -1
- package/es/molecule/review-correction-popin/index.d.ts.map +1 -1
- package/es/molecule/review-correction-popin/index.js +1 -1
- package/es/molecule/review-correction-popin/index.js.map +1 -1
- package/es/molecule/skill-picker-modal/index.d.ts.map +1 -1
- package/es/molecule/skill-picker-modal/index.js +2 -1
- package/es/molecule/skill-picker-modal/index.js.map +1 -1
- package/es/organism/user-preferences/index.d.ts.map +1 -1
- package/es/organism/user-preferences/index.js +1 -1
- package/es/organism/user-preferences/index.js.map +1 -1
- package/es/template/activity/engine-stars.d.ts.map +1 -1
- package/es/template/activity/engine-stars.js +1 -1
- package/es/template/activity/engine-stars.js.map +1 -1
- package/es/template/common/discipline/index.d.ts +6 -0
- package/es/template/common/discipline/index.d.ts.map +1 -1
- package/es/template/common/discipline/index.js +17 -2
- package/es/template/common/discipline/index.js.map +1 -1
- package/es/template/common/discipline/style.css +4 -1
- package/es/template/my-learning/index.d.ts +21 -0
- package/es/template/my-learning/index.d.ts.map +1 -1
- package/es/template/my-learning/index.js +41 -15
- package/es/template/my-learning/index.js.map +1 -1
- package/es/template/my-learning/style.css +6 -1
- package/lib/atom/battle-opponent/index.d.ts.map +1 -1
- package/lib/atom/battle-opponent/index.js +1 -1
- package/lib/atom/battle-opponent/index.js.map +1 -1
- package/lib/molecule/base-modal/index.d.ts +24 -1
- package/lib/molecule/base-modal/index.d.ts.map +1 -1
- package/lib/molecule/base-modal/index.js +26 -4
- package/lib/molecule/base-modal/index.js.map +1 -1
- package/lib/molecule/card/favorite.d.ts.map +1 -1
- package/lib/molecule/card/favorite.js +1 -1
- package/lib/molecule/card/favorite.js.map +1 -1
- package/lib/molecule/discipline-associated-skills/index.d.ts +17 -0
- package/lib/molecule/discipline-associated-skills/index.d.ts.map +1 -0
- package/lib/molecule/discipline-associated-skills/index.js +94 -0
- package/lib/molecule/discipline-associated-skills/index.js.map +1 -0
- package/lib/molecule/discipline-associated-skills/style.css +71 -0
- package/lib/molecule/learner-skill-card/index.d.ts +22 -0
- package/lib/molecule/learner-skill-card/index.d.ts.map +1 -1
- package/lib/molecule/learner-skill-card/index.js +7 -7
- package/lib/molecule/learner-skill-card/index.js.map +1 -1
- package/lib/molecule/learning-profile-radar-chart/index.d.ts +28 -1
- package/lib/molecule/learning-profile-radar-chart/index.d.ts.map +1 -1
- package/lib/molecule/learning-profile-radar-chart/index.js +117 -28
- package/lib/molecule/learning-profile-radar-chart/index.js.map +1 -1
- package/lib/molecule/learning-profile-radar-chart/style.css +14 -0
- package/lib/molecule/learning-profile-radar-chart/types.d.ts +2 -0
- package/lib/molecule/learning-profile-radar-chart/types.d.ts.map +1 -1
- package/lib/molecule/learning-profile-radar-chart/types.js +2 -1
- package/lib/molecule/learning-profile-radar-chart/types.js.map +1 -1
- package/lib/molecule/review-correction-popin/index.d.ts.map +1 -1
- package/lib/molecule/review-correction-popin/index.js +1 -1
- package/lib/molecule/review-correction-popin/index.js.map +1 -1
- package/lib/molecule/skill-picker-modal/index.d.ts.map +1 -1
- package/lib/molecule/skill-picker-modal/index.js +2 -1
- package/lib/molecule/skill-picker-modal/index.js.map +1 -1
- package/lib/organism/user-preferences/index.d.ts.map +1 -1
- package/lib/organism/user-preferences/index.js +1 -1
- package/lib/organism/user-preferences/index.js.map +1 -1
- package/lib/template/activity/engine-stars.d.ts.map +1 -1
- package/lib/template/activity/engine-stars.js +1 -1
- package/lib/template/activity/engine-stars.js.map +1 -1
- package/lib/template/common/discipline/index.d.ts +6 -0
- package/lib/template/common/discipline/index.d.ts.map +1 -1
- package/lib/template/common/discipline/index.js +18 -2
- package/lib/template/common/discipline/index.js.map +1 -1
- package/lib/template/common/discipline/style.css +4 -1
- package/lib/template/my-learning/index.d.ts +21 -0
- package/lib/template/my-learning/index.d.ts.map +1 -1
- package/lib/template/my-learning/index.js +39 -15
- package/lib/template/my-learning/index.js.map +1 -1
- package/lib/template/my-learning/style.css +6 -1
- package/locales/bs/global.json +3 -1
- package/locales/cs/global.json +4 -2
- package/locales/de/global.json +3 -1
- package/locales/en/global.json +3 -1
- package/locales/es/global.json +3 -1
- package/locales/et/global.json +3 -1
- package/locales/fi/global.json +3 -1
- package/locales/fr/global.json +3 -1
- package/locales/hr/global.json +3 -1
- package/locales/hu/global.json +3 -1
- package/locales/hy/global.json +3 -1
- package/locales/it/global.json +3 -1
- package/locales/ja/global.json +3 -1
- package/locales/ko/global.json +3 -1
- package/locales/nl/global.json +3 -1
- package/locales/pl/global.json +3 -1
- package/locales/pt/global.json +3 -1
- package/locales/ro/global.json +3 -1
- package/locales/ru/global.json +3 -1
- package/locales/sk/global.json +3 -1
- package/locales/sl/global.json +3 -1
- package/locales/sv/global.json +3 -1
- package/locales/th/global.json +1 -1
- package/locales/tl/global.json +4 -2
- package/locales/tr/global.json +3 -1
- package/locales/uk/global.json +3 -1
- package/locales/vi/global.json +4 -2
- package/locales/zh/global.json +3 -1
- package/locales/zh_TW/global.json +3 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/battle-opponent/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AACzD,OAAkB,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAG5D,QAAA,MAAM,cAAc;gHASf,mBAAmB,iBACP,gBAAgB;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/battle-opponent/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AACzD,OAAkB,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAG5D,QAAA,MAAM,cAAc;gHASf,mBAAmB,iBACP,gBAAgB;;;;;;;;;;;;;CAyGhC,CAAC;AAQF,eAAe,cAAc,CAAC"}
|
|
@@ -90,7 +90,7 @@ const BattleOpponent = ({
|
|
|
90
90
|
anchorId: battleOpponentInfoId,
|
|
91
91
|
toolTipIsVisible: toolTipIsVisible,
|
|
92
92
|
TooltipContent: TooltipContent,
|
|
93
|
-
closeToolTipInformationTextAriaLabel: translate('
|
|
93
|
+
closeToolTipInformationTextAriaLabel: translate('close_tooltip_information')
|
|
94
94
|
}))) : /*#__PURE__*/React.createElement(ArrowRight, {
|
|
95
95
|
className: style.rightArrow,
|
|
96
96
|
width: 16,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useMemo","useState","useRef","classnames","v5","uuidV5","has","NovaCompositionNavigationArrowRight","ArrowRight","NovaCompositionCoorpacademyInformationIcon","InformationIcon","ToolTip","toggleStateOnKeyPress","Provider","GetTranslateFromContext","propTypes","style","BattleOpponent","isAlreadyEngaged","isRandom","userAvatarSrc","onClick","displayName","tooltipText","ariaLabel","legacyContext","translate","wrapperClassnames","card","random","displayNameClassnames","name","alreadyEngaged","mouseLeaveTimer","setMouseLeaveTimer","undefined","toolTipIsVisible","setToolTipIsVisible","battleOpponentInfoId","URL","buttonRef","handleMouseOver","clearTimeout","current","focus","handleMouseLeave","setTimeout","blur","handleKeyPress","event","TooltipContent","_props","avatar","tooltipIconContainer","informationIcon","toolTipWrapper","rightArrow","contextTypes","childContextTypes"],"sources":["../../../src/atom/battle-opponent/index.tsx"],"sourcesContent":["import React, {useCallback, useMemo, useState, useRef} from 'react';\nimport classnames from 'classnames';\nimport {v5 as uuidV5} from 'uuid';\nimport has from 'lodash/fp/has';\nimport {\n NovaCompositionNavigationArrowRight as ArrowRight,\n NovaCompositionCoorpacademyInformationIcon as InformationIcon\n} from '@coorpacademy/nova-icons';\nimport ToolTip, {toggleStateOnKeyPress} from '../tooltip';\nimport Provider, {GetTranslateFromContext} from '../provider';\nimport {WebContextValues} from '../provider/web-context';\nimport propTypes, {BattleOpponentProps} from './prop-types';\nimport style from './style.css';\n\nconst BattleOpponent = (\n {\n isAlreadyEngaged,\n isRandom,\n userAvatarSrc,\n onClick,\n displayName,\n tooltipText,\n 'aria-label': ariaLabel\n }: BattleOpponentProps,\n legacyContext: WebContextValues\n) => {\n const translate: Required<WebContextValues>['translate'] = GetTranslateFromContext(legacyContext);\n const wrapperClassnames = useMemo(\n () => classnames(style.card, style['opponent-card'], isRandom ? style.random : null),\n [isRandom]\n );\n\n const displayNameClassnames = useMemo(\n () => classnames(style.name, isAlreadyEngaged ? style.alreadyEngaged : null),\n [isAlreadyEngaged]\n );\n\n const [mouseLeaveTimer, setMouseLeaveTimer] = useState<number | undefined>(undefined);\n const [toolTipIsVisible, setToolTipIsVisible] = useState(false);\n\n // to be replaced by useId when React17 is bumped to React18\n const [battleOpponentInfoId] = useState(\n isAlreadyEngaged ? uuidV5('engaged-battle-', uuidV5.URL) : undefined\n );\n\n const buttonRef = useRef(null);\n\n const handleMouseOver = useCallback(() => {\n mouseLeaveTimer && clearTimeout(mouseLeaveTimer);\n // @ts-expect-error (error: focus does not exists on type never)\n /* istanbul ignore next */ has(['current', 'focus'], buttonRef) && buttonRef.current.focus();\n setToolTipIsVisible(true);\n }, [mouseLeaveTimer]);\n\n const handleMouseLeave = useCallback(() => {\n setMouseLeaveTimer(\n setTimeout(() => {\n setToolTipIsVisible(false);\n // @ts-expect-error (error: blur does not exists on type never)\n /* istanbul ignore next */ has(['current', 'blur'], buttonRef) && buttonRef.current.blur();\n }, 500) as unknown as number\n );\n }, []);\n\n const handleKeyPress = useCallback(\n event => {\n toggleStateOnKeyPress(toolTipIsVisible, setToolTipIsVisible, buttonRef)(event);\n },\n [toolTipIsVisible]\n );\n\n const TooltipContent = useCallback(\n _props => (\n <p\n {..._props}\n onMouseOver={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n data-testid=\"battle-opponent-tooltip-content\"\n >\n {tooltipText}\n </p>\n ),\n [handleMouseLeave, handleMouseOver, tooltipText]\n );\n\n return (\n <li\n {...(!isAlreadyEngaged && {onClick})}\n className={wrapperClassnames}\n data-testid=\"battle-opponent-wrapper\"\n tabIndex={0}\n >\n <div className={style.avatar}>{isRandom ? null : <img src={userAvatarSrc} alt=\"\" />}</div>\n <p className={displayNameClassnames} tabIndex={0}>\n {displayName}\n </p>\n {isAlreadyEngaged ? (\n <>\n <button\n ref={buttonRef}\n tabIndex={0}\n type=\"button\"\n className={style.tooltipIconContainer}\n data-testid=\"battle-engaged-opponent-information-button\"\n onKeyDown={handleKeyPress}\n onMouseLeave={handleMouseLeave}\n onMouseOver={handleMouseOver}\n data-for={battleOpponentInfoId}\n data-tooltip-place=\"left\"\n data-tip={isAlreadyEngaged}\n aria-label={ariaLabel}\n >\n <InformationIcon className={style.informationIcon} width={20} height={20} />\n </button>\n <span className={style.toolTipWrapper}>\n <ToolTip\n fontSize={12}\n anchorId={battleOpponentInfoId}\n toolTipIsVisible={toolTipIsVisible}\n TooltipContent={TooltipContent}\n closeToolTipInformationTextAriaLabel={translate(
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useMemo","useState","useRef","classnames","v5","uuidV5","has","NovaCompositionNavigationArrowRight","ArrowRight","NovaCompositionCoorpacademyInformationIcon","InformationIcon","ToolTip","toggleStateOnKeyPress","Provider","GetTranslateFromContext","propTypes","style","BattleOpponent","isAlreadyEngaged","isRandom","userAvatarSrc","onClick","displayName","tooltipText","ariaLabel","legacyContext","translate","wrapperClassnames","card","random","displayNameClassnames","name","alreadyEngaged","mouseLeaveTimer","setMouseLeaveTimer","undefined","toolTipIsVisible","setToolTipIsVisible","battleOpponentInfoId","URL","buttonRef","handleMouseOver","clearTimeout","current","focus","handleMouseLeave","setTimeout","blur","handleKeyPress","event","TooltipContent","_props","avatar","tooltipIconContainer","informationIcon","toolTipWrapper","rightArrow","contextTypes","childContextTypes"],"sources":["../../../src/atom/battle-opponent/index.tsx"],"sourcesContent":["import React, {useCallback, useMemo, useState, useRef} from 'react';\nimport classnames from 'classnames';\nimport {v5 as uuidV5} from 'uuid';\nimport has from 'lodash/fp/has';\nimport {\n NovaCompositionNavigationArrowRight as ArrowRight,\n NovaCompositionCoorpacademyInformationIcon as InformationIcon\n} from '@coorpacademy/nova-icons';\nimport ToolTip, {toggleStateOnKeyPress} from '../tooltip';\nimport Provider, {GetTranslateFromContext} from '../provider';\nimport {WebContextValues} from '../provider/web-context';\nimport propTypes, {BattleOpponentProps} from './prop-types';\nimport style from './style.css';\n\nconst BattleOpponent = (\n {\n isAlreadyEngaged,\n isRandom,\n userAvatarSrc,\n onClick,\n displayName,\n tooltipText,\n 'aria-label': ariaLabel\n }: BattleOpponentProps,\n legacyContext: WebContextValues\n) => {\n const translate: Required<WebContextValues>['translate'] = GetTranslateFromContext(legacyContext);\n const wrapperClassnames = useMemo(\n () => classnames(style.card, style['opponent-card'], isRandom ? style.random : null),\n [isRandom]\n );\n\n const displayNameClassnames = useMemo(\n () => classnames(style.name, isAlreadyEngaged ? style.alreadyEngaged : null),\n [isAlreadyEngaged]\n );\n\n const [mouseLeaveTimer, setMouseLeaveTimer] = useState<number | undefined>(undefined);\n const [toolTipIsVisible, setToolTipIsVisible] = useState(false);\n\n // to be replaced by useId when React17 is bumped to React18\n const [battleOpponentInfoId] = useState(\n isAlreadyEngaged ? uuidV5('engaged-battle-', uuidV5.URL) : undefined\n );\n\n const buttonRef = useRef(null);\n\n const handleMouseOver = useCallback(() => {\n mouseLeaveTimer && clearTimeout(mouseLeaveTimer);\n // @ts-expect-error (error: focus does not exists on type never)\n /* istanbul ignore next */ has(['current', 'focus'], buttonRef) && buttonRef.current.focus();\n setToolTipIsVisible(true);\n }, [mouseLeaveTimer]);\n\n const handleMouseLeave = useCallback(() => {\n setMouseLeaveTimer(\n setTimeout(() => {\n setToolTipIsVisible(false);\n // @ts-expect-error (error: blur does not exists on type never)\n /* istanbul ignore next */ has(['current', 'blur'], buttonRef) && buttonRef.current.blur();\n }, 500) as unknown as number\n );\n }, []);\n\n const handleKeyPress = useCallback(\n event => {\n toggleStateOnKeyPress(toolTipIsVisible, setToolTipIsVisible, buttonRef)(event);\n },\n [toolTipIsVisible]\n );\n\n const TooltipContent = useCallback(\n _props => (\n <p\n {..._props}\n onMouseOver={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n data-testid=\"battle-opponent-tooltip-content\"\n >\n {tooltipText}\n </p>\n ),\n [handleMouseLeave, handleMouseOver, tooltipText]\n );\n\n return (\n <li\n {...(!isAlreadyEngaged && {onClick})}\n className={wrapperClassnames}\n data-testid=\"battle-opponent-wrapper\"\n tabIndex={0}\n >\n <div className={style.avatar}>{isRandom ? null : <img src={userAvatarSrc} alt=\"\" />}</div>\n <p className={displayNameClassnames} tabIndex={0}>\n {displayName}\n </p>\n {isAlreadyEngaged ? (\n <>\n <button\n ref={buttonRef}\n tabIndex={0}\n type=\"button\"\n className={style.tooltipIconContainer}\n data-testid=\"battle-engaged-opponent-information-button\"\n onKeyDown={handleKeyPress}\n onMouseLeave={handleMouseLeave}\n onMouseOver={handleMouseOver}\n data-for={battleOpponentInfoId}\n data-tooltip-place=\"left\"\n data-tip={isAlreadyEngaged}\n aria-label={ariaLabel}\n >\n <InformationIcon className={style.informationIcon} width={20} height={20} />\n </button>\n <span className={style.toolTipWrapper}>\n <ToolTip\n fontSize={12}\n anchorId={battleOpponentInfoId}\n toolTipIsVisible={toolTipIsVisible}\n TooltipContent={TooltipContent}\n closeToolTipInformationTextAriaLabel={translate('close_tooltip_information')}\n />\n </span>\n </>\n ) : (\n <ArrowRight className={style.rightArrow} width={16} height={16} />\n )}\n </li>\n );\n};\n\nBattleOpponent.propTypes = propTypes;\n\nBattleOpponent.contextTypes = {\n translate: Provider.childContextTypes.translate\n};\n\nexport default BattleOpponent;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,OAA5B,EAAqCC,QAArC,EAA+CC,MAA/C,QAA4D,OAA5D;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAAQC,EAAE,IAAIC,MAAd,QAA2B,MAA3B;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,SACEC,mCAAmC,IAAIC,UADzC,EAEEC,0CAA0C,IAAIC,eAFhD,QAGO,0BAHP;AAIA,OAAOC,OAAP,IAAiBC,qBAAjB,QAA6C,YAA7C;AACA,OAAOC,QAAP,IAAkBC,uBAAlB,QAAgD,aAAhD;AAEA,OAAOC,SAAP,MAA6C,cAA7C;AAC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E,QAAQ,EAAE,CAFZ;IAGE,IAAI,EAAC,QAHP;IAIE,SAAS,EAAExB,KAAK,CAACqC,oBAJnB;IAKE,eAAY,4CALd;IAME,SAAS,EAAEL,cANb;IAOE,YAAY,EAAEH,gBAPhB;IAQE,WAAW,EAAEJ,eARf;IASE,YAAUH,oBATZ;IAUE,sBAAmB,MAVrB;IAWE,YAAUpB,gBAXZ;IAYE,cAAYM;EAZd,gBAcE,oBAAC,eAAD;IAAiB,SAAS,EAAER,KAAK,CAACsC,eAAlC;IAAmD,KAAK,EAAE,EAA1D;IAA8D,MAAM,EAAE;EAAtE,EAdF,CADF,eAiBE;IAAM,SAAS,EAAEtC,KAAK,CAACuC;EAAvB,gBACE,oBAAC,OAAD;IACE,QAAQ,EAAE,EADZ;IAEE,QAAQ,EAAEjB,oBAFZ;IAGE,gBAAgB,EAAEF,gBAHpB;IAIE,cAAc,EAAEc,cAJlB;IAKE,oCAAoC,EAAExB,SAAS,CAAC,2BAAD;EALjD,EADF,CAjBF,CADe,gBA6Bf,oBAAC,UAAD;IAAY,SAAS,EAAEV,KAAK,CAACwC,UAA7B;IAAyC,KAAK,EAAE,EAAhD;IAAoD,MAAM,EAAE;EAA5D,EAvCJ,CADF;AA4CD,CAnHD;;AAqHAvC,cAAc,CAACF,SAAf,2CAA2BA,SAA3B;AAEAE,cAAc,CAACwC,YAAf,GAA8B;EAC5B/B,SAAS,EAAEb,QAAQ,CAAC6C,iBAAT,CAA2BhC;AADV,CAA9B;AAIA,eAAeT,cAAf"}
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
export default BaseModal;
|
|
2
|
-
declare function BaseModal(props: any): JSX.Element | null;
|
|
2
|
+
declare function BaseModal(props: any, context: any): JSX.Element | null;
|
|
3
3
|
declare namespace BaseModal {
|
|
4
|
+
namespace contextTypes {
|
|
5
|
+
const skin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
+
common: PropTypes.Requireable<{
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
}>;
|
|
9
|
+
images: PropTypes.Requireable<PropTypes.InferProps<{
|
|
10
|
+
'logo-mobile': PropTypes.Requireable<any>;
|
|
11
|
+
logo: PropTypes.Requireable<any>;
|
|
12
|
+
'logo-email': PropTypes.Requireable<any>;
|
|
13
|
+
login: PropTypes.Requireable<any>;
|
|
14
|
+
}>>;
|
|
15
|
+
icons: PropTypes.Requireable<{
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
}>;
|
|
18
|
+
mod: PropTypes.Requireable<{
|
|
19
|
+
[x: string]: any;
|
|
20
|
+
}>;
|
|
21
|
+
courses: PropTypes.Requireable<any[]>;
|
|
22
|
+
texts: PropTypes.Requireable<{
|
|
23
|
+
[x: string]: any;
|
|
24
|
+
}>;
|
|
25
|
+
}>>;
|
|
26
|
+
}
|
|
4
27
|
namespace propTypes {
|
|
5
28
|
const title: PropTypes.Requireable<string>;
|
|
6
29
|
const headerIcon: PropTypes.Requireable<PropTypes.InferProps<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/base-modal/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/base-modal/index.js"],"names":[],"mappings":";AASA,yEAgHC"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import _get from "lodash/fp/get";
|
|
1
2
|
import _isEmpty from "lodash/fp/isEmpty";
|
|
2
3
|
|
|
3
4
|
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); }
|
|
4
5
|
|
|
5
|
-
import React, { useCallback } from 'react';
|
|
6
|
+
import React, { useCallback, useState } from 'react';
|
|
6
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import { convert } from 'css-color-function';
|
|
9
|
+
import Provider from '../../atom/provider';
|
|
7
10
|
import Icon from '../../atom/icon';
|
|
8
11
|
import ButtonLink from '../../atom/button-link';
|
|
9
12
|
import style from './style.css';
|
|
10
13
|
|
|
11
|
-
const BaseModal = props => {
|
|
14
|
+
const BaseModal = (props, context) => {
|
|
12
15
|
const {
|
|
13
16
|
title,
|
|
14
17
|
description,
|
|
@@ -18,6 +21,12 @@ const BaseModal = props => {
|
|
|
18
21
|
footer,
|
|
19
22
|
onClose
|
|
20
23
|
} = props;
|
|
24
|
+
const {
|
|
25
|
+
skin
|
|
26
|
+
} = context;
|
|
27
|
+
const [hovered, setHovered] = useState(false);
|
|
28
|
+
const handleMouseOver = useCallback(() => setHovered(true), [setHovered]);
|
|
29
|
+
const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);
|
|
21
30
|
const Footer = useCallback(() => {
|
|
22
31
|
if (_isEmpty(footer)) return null;
|
|
23
32
|
if (typeof footer === 'function') return footer();
|
|
@@ -38,6 +47,9 @@ const BaseModal = props => {
|
|
|
38
47
|
disabled: confirmDisabled,
|
|
39
48
|
iconName
|
|
40
49
|
} = confirmButton || {};
|
|
50
|
+
|
|
51
|
+
const primarySkinColor = _get('common.primary', skin);
|
|
52
|
+
|
|
41
53
|
return /*#__PURE__*/React.createElement("div", {
|
|
42
54
|
className: style.footer
|
|
43
55
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -48,7 +60,13 @@ const BaseModal = props => {
|
|
|
48
60
|
onClick: onCancel,
|
|
49
61
|
label: cancelLabel,
|
|
50
62
|
disabled: cancelDisabled
|
|
51
|
-
}) : null, onConfirm && confirmLabel ? /*#__PURE__*/React.createElement(
|
|
63
|
+
}) : null, onConfirm && confirmLabel ? /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
onMouseOver: handleMouseOver,
|
|
65
|
+
onMouseLeave: handleMouseLeave
|
|
66
|
+
}, /*#__PURE__*/React.createElement(ButtonLink, _extends({
|
|
67
|
+
customStyle: {
|
|
68
|
+
backgroundColor: hovered ? convert(`hsl(from ${primarySkinColor} h s calc(l*(1 - 0.08)))`) : primarySkinColor
|
|
69
|
+
},
|
|
52
70
|
className: style.footerConfirmButton,
|
|
53
71
|
type: 'primary',
|
|
54
72
|
onClick: onConfirm,
|
|
@@ -63,10 +81,10 @@ const BaseModal = props => {
|
|
|
63
81
|
size: 16
|
|
64
82
|
}
|
|
65
83
|
}
|
|
66
|
-
} : {})) : null), text ? /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
} : {}))) : null), text ? /*#__PURE__*/React.createElement("div", {
|
|
67
85
|
className: `${style.footerDescription} ${isError ? style.footerDescriptionError : ''}`
|
|
68
86
|
}, text) : null);
|
|
69
|
-
}, [footer]);
|
|
87
|
+
}, [footer, hovered, handleMouseOver, handleMouseLeave, skin]);
|
|
70
88
|
if (!isOpen || !title || !children) return null;
|
|
71
89
|
|
|
72
90
|
function handleOnClose(e) {
|
|
@@ -111,6 +129,9 @@ const BaseModal = props => {
|
|
|
111
129
|
}, children), /*#__PURE__*/React.createElement(Footer, null)));
|
|
112
130
|
};
|
|
113
131
|
|
|
132
|
+
BaseModal.contextTypes = {
|
|
133
|
+
skin: Provider.childContextTypes.skin
|
|
134
|
+
};
|
|
114
135
|
BaseModal.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
115
136
|
title: PropTypes.string,
|
|
116
137
|
headerIcon: PropTypes.shape({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","PropTypes","Icon","ButtonLink","style","BaseModal","props","title","description","headerIcon","children","isOpen","footer","onClose","Footer","cancelButton","confirmButton","text","isError","label","cancelLabel","onCancel","disabled","cancelDisabled","confirmLabel","onConfirm","confirmDisabled","iconName","footerCTAWrapper","className","footerCancelButton","type","onClick","footerConfirmButton","icon","position","faIcon","name","color","size","footerDescription","footerDescriptionError","handleOnClose","e","stopPropagation","modalWrapper","modal","header","backgroundColor","faSize","wrapperSize","headerContent","headerTitle","headerDescription","headerCloseIcon","body","propTypes","string","shape","node","bool","oneOfType","func","boolean"],"sources":["../../../src/molecule/base-modal/index.js"],"sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport {isEmpty} from 'lodash/fp';\nimport Icon from '../../atom/icon';\nimport ButtonLink from '../../atom/button-link';\nimport style from './style.css';\n\nconst BaseModal = props => {\n const {title, description, headerIcon, children, isOpen, footer, onClose} = props;\n\n const Footer = useCallback(() => {\n if (isEmpty(footer)) return null;\n if (typeof footer === 'function') return footer();\n\n const {cancelButton, confirmButton, text, isError} = footer;\n const {label: cancelLabel, onCancel, disabled: cancelDisabled} = cancelButton || {};\n const {\n label: confirmLabel,\n onConfirm,\n disabled: confirmDisabled,\n iconName\n } = confirmButton || {};\n\n return (\n <div className={style.footer}>\n <div className={style.footerCTAWrapper}>\n {onCancel && cancelLabel ? (\n <ButtonLink\n {...{\n className: style.footerCancelButton,\n type: 'secondary',\n onClick: onCancel,\n label: cancelLabel,\n disabled: cancelDisabled\n }}\n />\n ) : null}\n {onConfirm && confirmLabel ? (\n <ButtonLink\n {...{\n className: style.footerConfirmButton,\n type: 'primary',\n onClick: onConfirm,\n label: confirmLabel,\n disabled: confirmDisabled,\n ...(iconName\n ? {\n icon: {\n position: 'left',\n faIcon: {\n name: iconName,\n color: '#FFFFFF',\n size: 16\n }\n }\n }\n : {})\n }}\n />\n ) : null}\n </div>\n {text ? (\n <div\n className={`${style.footerDescription} ${isError ? style.footerDescriptionError : ''}`}\n >\n {text}\n </div>\n ) : null}\n </div>\n );\n }, [footer]);\n\n if (!isOpen || !title || !children) return null;\n\n function handleOnClose(e) {\n e?.stopPropagation();\n onClose();\n }\n\n return (\n <div className={style.modalWrapper}>\n <div className={style.modal}>\n <header className={style.header}>\n {headerIcon?.name ? (\n <div className={style.headerIcon}>\n <Icon\n iconName={headerIcon.name}\n iconColor={headerIcon.color}\n backgroundColor={headerIcon.backgroundColor}\n size={{faSize: 20, wrapperSize: 48}}\n />\n </div>\n ) : null}\n <div className={style.headerContent}>\n <div className={style.headerTitle}>{title}</div>\n {description ? <div className={style.headerDescription}>{description}</div> : null}\n </div>\n <div className={style.headerCloseIcon} onClick={handleOnClose}>\n <Icon iconName=\"close\" backgroundColor=\"#F4F4F5\" size={{faSize: 14, wrapperSize: 28}} />\n </div>\n </header>\n <div className={style.body}>{children}</div>\n <Footer />\n </div>\n </div>\n );\n};\n\nBaseModal.propTypes = {\n title: PropTypes.string,\n headerIcon: PropTypes.shape({\n name: PropTypes.string,\n color: PropTypes.string,\n backgroundColor: PropTypes.string\n }),\n description: PropTypes.string,\n children: PropTypes.node,\n isOpen: PropTypes.bool,\n footer: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({\n text: PropTypes.string,\n isError: PropTypes.boolean,\n cancelButton: PropTypes.shape({\n label: PropTypes.string,\n onCancel: PropTypes.func,\n disabled: PropTypes.bool\n }),\n confirmButton: PropTypes.shape({\n label: PropTypes.string,\n onConfirm: PropTypes.func,\n iconName: PropTypes.string,\n disabled: PropTypes.bool\n })\n })\n ]),\n onClose: PropTypes.func\n};\n\nexport default BaseModal;\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAeC,WAAf,QAAiC,OAAjC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,IAAP,MAAiB,iBAAjB;AACA,OAAOC,UAAP,MAAuB,wBAAvB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,SAAS,GAAGC,KAAK,IAAI;EACzB,MAAM;IAACC,KAAD;IAAQC,WAAR;IAAqBC,UAArB;IAAiCC,QAAjC;IAA2CC,MAA3C;IAAmDC,MAAnD;IAA2DC;EAA3D,IAAsEP,KAA5E;EAEA,MAAMQ,MAAM,GAAGd,WAAW,CAAC,MAAM;IAC/B,IAAI,SAAQY,MAAR,CAAJ,EAAqB,OAAO,IAAP;IACrB,IAAI,OAAOA,MAAP,KAAkB,UAAtB,EAAkC,OAAOA,MAAM,EAAb;IAElC,MAAM;MAAC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AsB;EACpBjD,KAAK,EAAEN,SAAS,CAACwD,MADG;EAEpBhD,UAAU,EAAER,SAAS,CAACyD,KAAV,CAAgB;IAC1BrB,IAAI,EAAEpC,SAAS,CAACwD,MADU;IAE1BnB,KAAK,EAAErC,SAAS,CAACwD,MAFS;IAG1BT,eAAe,EAAE/C,SAAS,CAACwD;EAHD,CAAhB,CAFQ;EAOpBjD,WAAW,EAAEP,SAAS,CAACwD,MAPH;EAQpB/C,QAAQ,EAAET,SAAS,CAAC0D,IARA;EASpBhD,MAAM,EAAEV,SAAS,CAAC2D,IATE;EAUpBhD,MAAM,EAAEX,SAAS,CAAC4D,SAAV,CAAoB,CAC1B5D,SAAS,CAAC6D,IADgB,EAE1B7D,SAAS,CAACyD,KAAV,CAAgB;IACdzC,IAAI,EAAEhB,SAAS,CAACwD,MADF;IAEdvC,OAAO,EAAEjB,SAAS,CAAC8D,OAFL;IAGdhD,YAAY,EAAEd,SAAS,CAACyD,KAAV,CAAgB;MAC5BvC,KAAK,EAAElB,SAAS,CAACwD,MADW;MAE5BpC,QAAQ,EAAEpB,SAAS,CAAC6D,IAFQ;MAG5BxC,QAAQ,EAAErB,SAAS,CAAC2D;IAHQ,CAAhB,CAHA;IAQd5C,aAAa,EAAEf,SAAS,CAACyD,KAAV,CAAgB;MAC7BvC,KAAK,EAAElB,SAAS,CAACwD,MADY;MAE7BhC,SAAS,EAAExB,SAAS,CAAC6D,IAFQ;MAG7BnC,QAAQ,EAAE1B,SAAS,CAACwD,MAHS;MAI7BnC,QAAQ,EAAErB,SAAS,CAAC2D;IAJS,CAAhB;EARD,CAAhB,CAF0B,CAApB,CAVY;EA4BpB/C,OAAO,EAAEZ,SAAS,CAAC6D;AA5BC,CAAtB;AA+BA,eAAezD,SAAf"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useState","PropTypes","convert","Provider","Icon","ButtonLink","style","BaseModal","props","context","title","description","headerIcon","children","isOpen","footer","onClose","skin","hovered","setHovered","handleMouseOver","handleMouseLeave","Footer","cancelButton","confirmButton","text","isError","label","cancelLabel","onCancel","disabled","cancelDisabled","confirmLabel","onConfirm","confirmDisabled","iconName","primarySkinColor","footerCTAWrapper","className","footerCancelButton","type","onClick","customStyle","backgroundColor","footerConfirmButton","icon","position","faIcon","name","color","size","footerDescription","footerDescriptionError","handleOnClose","e","stopPropagation","modalWrapper","modal","header","faSize","wrapperSize","headerContent","headerTitle","headerDescription","headerCloseIcon","body","contextTypes","childContextTypes","propTypes","string","shape","node","bool","oneOfType","func","boolean"],"sources":["../../../src/molecule/base-modal/index.js"],"sourcesContent":["import React, {useCallback, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport {isEmpty, get} from 'lodash/fp';\nimport {convert} from 'css-color-function';\nimport Provider from '../../atom/provider';\nimport Icon from '../../atom/icon';\nimport ButtonLink from '../../atom/button-link';\nimport style from './style.css';\n\nconst BaseModal = (props, context) => {\n const {title, description, headerIcon, children, isOpen, footer, onClose} = props;\n const {skin} = context;\n\n const [hovered, setHovered] = useState(false);\n const handleMouseOver = useCallback(() => setHovered(true), [setHovered]);\n const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);\n\n const Footer = useCallback(() => {\n if (isEmpty(footer)) return null;\n if (typeof footer === 'function') return footer();\n\n const {cancelButton, confirmButton, text, isError} = footer;\n const {label: cancelLabel, onCancel, disabled: cancelDisabled} = cancelButton || {};\n const {\n label: confirmLabel,\n onConfirm,\n disabled: confirmDisabled,\n iconName\n } = confirmButton || {};\n const primarySkinColor = get('common.primary', skin);\n\n return (\n <div className={style.footer}>\n <div className={style.footerCTAWrapper}>\n {onCancel && cancelLabel ? (\n <ButtonLink\n {...{\n className: style.footerCancelButton,\n type: 'secondary',\n onClick: onCancel,\n label: cancelLabel,\n disabled: cancelDisabled\n }}\n />\n ) : null}\n {onConfirm && confirmLabel ? (\n <div onMouseOver={handleMouseOver} onMouseLeave={handleMouseLeave}>\n <ButtonLink\n {...{\n customStyle: {\n backgroundColor: hovered\n ? convert(`hsl(from ${primarySkinColor} h s calc(l*(1 - 0.08)))`)\n : primarySkinColor\n },\n className: style.footerConfirmButton,\n type: 'primary',\n onClick: onConfirm,\n label: confirmLabel,\n disabled: confirmDisabled,\n ...(iconName\n ? {\n icon: {\n position: 'left',\n faIcon: {\n name: iconName,\n color: '#FFFFFF',\n size: 16\n }\n }\n }\n : {})\n }}\n />\n </div>\n ) : null}\n </div>\n {text ? (\n <div\n className={`${style.footerDescription} ${isError ? style.footerDescriptionError : ''}`}\n >\n {text}\n </div>\n ) : null}\n </div>\n );\n }, [footer, hovered, handleMouseOver, handleMouseLeave, skin]);\n\n if (!isOpen || !title || !children) return null;\n\n function handleOnClose(e) {\n e?.stopPropagation();\n onClose();\n }\n\n return (\n <div className={style.modalWrapper}>\n <div className={style.modal}>\n <header className={style.header}>\n {headerIcon?.name ? (\n <div className={style.headerIcon}>\n <Icon\n iconName={headerIcon.name}\n iconColor={headerIcon.color}\n backgroundColor={headerIcon.backgroundColor}\n size={{faSize: 20, wrapperSize: 48}}\n />\n </div>\n ) : null}\n <div className={style.headerContent}>\n <div className={style.headerTitle}>{title}</div>\n {description ? <div className={style.headerDescription}>{description}</div> : null}\n </div>\n <div className={style.headerCloseIcon} onClick={handleOnClose}>\n <Icon iconName=\"close\" backgroundColor=\"#F4F4F5\" size={{faSize: 14, wrapperSize: 28}} />\n </div>\n </header>\n <div className={style.body}>{children}</div>\n <Footer />\n </div>\n </div>\n );\n};\n\nBaseModal.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nBaseModal.propTypes = {\n title: PropTypes.string,\n headerIcon: PropTypes.shape({\n name: PropTypes.string,\n color: PropTypes.string,\n backgroundColor: PropTypes.string\n }),\n description: PropTypes.string,\n children: PropTypes.node,\n isOpen: PropTypes.bool,\n footer: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({\n text: PropTypes.string,\n isError: PropTypes.boolean,\n cancelButton: PropTypes.shape({\n label: PropTypes.string,\n onCancel: PropTypes.func,\n disabled: PropTypes.bool\n }),\n confirmButton: PropTypes.shape({\n label: PropTypes.string,\n onConfirm: PropTypes.func,\n iconName: PropTypes.string,\n disabled: PropTypes.bool\n })\n })\n ]),\n onClose: PropTypes.func\n};\n\nexport default BaseModal;\n"],"mappings":";;;;;AAAA,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,QAA5B,QAA2C,OAA3C;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,SAAQC,OAAR,QAAsB,oBAAtB;AACA,OAAOC,QAAP,MAAqB,qBAArB;AACA,OAAOC,IAAP,MAAiB,iBAAjB;AACA,OAAOC,UAAP,MAAuB,wBAAvB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,SAAS,GAAG,CAACC,KAAD,EAAQC,OAAR,KAAoB;EACpC,MAAM;IAACC,KAAD;IAAQC,WAAR;IAAqBC,UAArB;IAAiCC,QAAjC;IAA2CC,MAA3C;IAAmDC,MAAnD;IAA2DC;EAA3D,IAAsER,KAA5E;EACA,MAAM;IAACS;EAAD,IAASR,OAAf;EAEA,MAAM,CAACS,OAAD,EAAUC,UAAV,IAAwBnB,QAAQ,CAAC,KAAD,CAAtC;EACA,MAAMoB,eAAe,GAAGrB,WAAW,CAAC,MAAMoB,UAAU,CAAC,IAAD,CAAjB,EAAyB,CAACA,UAAD,CAAzB,CAAnC;EACA,MAAME,gBAAgB,GAAGtB,WAAW,CAAC,MAAMoB,UAAU,CAAC,KAAD,CAAjB,EAA0B,CAACA,UAAD,CAA1B,CAApC;EAEA,MAAMG,MAAM,GAAGvB,WAAW,CAAC,MAAM;IAC/B,IAAI,SAAQgB,MAAR,CAAJ,EAAqB,OAAO,IAAP;IACrB,IAAI,OAAOA,MAAP,KAAkB,UAAtB,EAAkC,OAAOA,MAAM,EAAb;IAElC,MAAM;MAACQ,YAAD;MAAeC,aAAf;MAA8BC,IAA9B;MAAoCC;IAApC,IAA+CX,MAArD;IACA,MAAM;MAACY,KAAK,EAAEC,WAAR;MAAq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;MAI7BvC,QAAQ,EAAE7B,SAAS,CAACuE;IAJS,CAAhB;EARD,CAAhB,CAF0B,CAApB,CAVY;EA4BpBxD,OAAO,EAAEf,SAAS,CAACyE;AA5BC,CAAtB;AA+BA,eAAenE,SAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"favorite.d.ts","sourceRoot":"","sources":["../../../src/molecule/card/favorite.js"],"names":[],"mappings":";AAcA;;;;;;;;
|
|
1
|
+
{"version":3,"file":"favorite.d.ts","sourceRoot":"","sources":["../../../src/molecule/card/favorite.js"],"names":[],"mappings":";AAcA;;;;;;;;oCAwIC"}
|
|
@@ -111,7 +111,7 @@ const Favorite = ({
|
|
|
111
111
|
anchorId: favoriteButtonAnchorId,
|
|
112
112
|
toolTipIsVisible: toolTipIsVisible,
|
|
113
113
|
TooltipContent: toolTipContent,
|
|
114
|
-
closeToolTipInformationTextAriaLabel: translate('
|
|
114
|
+
closeToolTipInformationTextAriaLabel: translate('close_tooltip_information'),
|
|
115
115
|
stickyOnKeyboardNavigation: true
|
|
116
116
|
}));
|
|
117
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"favorite.js","names":["React","useCallback","useMemo","useRef","useState","PropTypes","classnames","v5","uuidV5","NovaCompositionNavigationMore","MoreIcon","NovaCompositionCoorpacademyCheck","CheckIcon","Provider","GetSkinFromContext","GetTranslateFromContext","ToolTip","toggleStateOnKeyPress","Button","style","Favorite","favorite","addFavoriteToolTip","removeFavoriteToolTip","className","ariaLabel","onFavoriteClick","disabled","legacyContext","skin","translate","handleFavoriteClick","e","stopPropagation","preventDefault","primaryColor","darkColor","brandColor","buttonRef","allowToolTip","favoriteButtonAnchorId","URL","undefined","toolTipContent","mouseLeaveTimer","setMouseLeaveTimer","toolTipIsVisible","setToolTipIsVisible","handleMouseOver","clearTimeout","current","focus","handleMouseLeave","setTimeout","blur","handleKeyPress","event","iconWrapperClassName","selected","icon","checkIcon","color","removeFromFavorite","moreIcon","addToFavorite","favoriteWrapper","propTypes","string","bool","func","shape","contextTypes","childContextTypes"],"sources":["../../../src/molecule/card/favorite.js"],"sourcesContent":["import React, {useCallback, useMemo, useRef, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport {v5 as uuidV5} from 'uuid';\nimport {get, has, isEmpty, noop} from 'lodash/fp';\nimport {\n NovaCompositionNavigationMore as MoreIcon,\n NovaCompositionCoorpacademyCheck as CheckIcon\n} from '@coorpacademy/nova-icons';\nimport Provider, {GetSkinFromContext, GetTranslateFromContext} from '../../atom/provider';\nimport ToolTip, {toggleStateOnKeyPress} from '../../atom/tooltip';\nimport Button from '../../atom/button';\nimport style from './favorite.css';\n\nconst Favorite = (\n {\n favorite,\n addFavoriteToolTip,\n removeFavoriteToolTip,\n className,\n 'aria-label': ariaLabel = {},\n onFavoriteClick = noop,\n disabled\n },\n legacyContext\n) => {\n const skin = GetSkinFromContext(legacyContext);\n const translate = GetTranslateFromContext(legacyContext);\n const handleFavoriteClick = useCallback(\n e => {\n e.stopPropagation();\n e.preventDefault();\n if (!disabled) onFavoriteClick(e);\n },\n [disabled, onFavoriteClick]\n );\n\n const primaryColor = get('common.primary', skin);\n const darkColor = get('common.dark', skin);\n const brandColor = get('common.brand', skin);\n\n const buttonRef = useRef(null);\n\n const allowToolTip = useMemo(\n () => !isEmpty(removeFavoriteToolTip) && !isEmpty(addFavoriteToolTip),\n [addFavoriteToolTip, removeFavoriteToolTip]\n );\n\n // to be replaced by useId when React17 is bumped to React18\n const [favoriteButtonAnchorId] = useState(\n allowToolTip ? uuidV5('engaged-battle-', uuidV5.URL) : undefined\n );\n\n const toolTipContent = useMemo(\n // eslint-disable-next-line no-nested-ternary\n () => (allowToolTip ? (favorite ? removeFavoriteToolTip : addFavoriteToolTip) : null),\n [addFavoriteToolTip, favorite, removeFavoriteToolTip, allowToolTip]\n );\n\n const [mouseLeaveTimer, setMouseLeaveTimer] = useState(undefined);\n\n const [toolTipIsVisible, setToolTipIsVisible] = useState(false);\n\n const handleMouseOver = useCallback(() => {\n mouseLeaveTimer && clearTimeout(mouseLeaveTimer);\n /* istanbul ignore next */ has(['current', 'focus'], buttonRef) && buttonRef.current.focus();\n setToolTipIsVisible(true);\n }, [mouseLeaveTimer]);\n\n const handleMouseLeave = useCallback(() => {\n setMouseLeaveTimer(\n setTimeout(() => {\n setToolTipIsVisible(false);\n // @ts-expect-error (error: blur does not exists on type never)\n /* istanbul ignore next */ has(['current', 'blur'], buttonRef) && buttonRef.current.blur();\n }, 500)\n );\n }, []);\n\n const handleKeyPress = useCallback(\n event => {\n toggleStateOnKeyPress(toolTipIsVisible, setToolTipIsVisible, buttonRef)(event);\n },\n [toolTipIsVisible]\n );\n\n const iconWrapperClassName = useMemo(\n () => classnames(style.favorite, className, favorite && style.selected),\n [className, favorite]\n );\n const icon = useMemo(\n () =>\n favorite ? (\n <CheckIcon\n // eslint-disable-next-line css-modules/no-undef-class\n className={style.checkIcon}\n style={{color: brandColor}}\n width={13}\n height={13}\n data-testid=\"favorite-check-icon\"\n aria-label={ariaLabel.removeFromFavorite}\n />\n ) : (\n <MoreIcon\n className={style.moreIcon}\n style={{color: darkColor}}\n width={13}\n height={13}\n data-testid=\"favorite-add-icon\"\n aria-label={ariaLabel.addToFavorite}\n />\n ),\n [ariaLabel.addToFavorite, ariaLabel.removeFromFavorite, brandColor, darkColor, favorite]\n );\n\n return (\n <div className={style.favoriteWrapper} data-testid=\"favorite-wrapper\">\n <Button\n buttonRef={buttonRef}\n type=\"button\"\n data-for={favoriteButtonAnchorId}\n data-tooltip-place=\"left\"\n data-tip={allowToolTip}\n data-name=\"favorite\"\n data-testid=\"favorite-button\"\n aria-label={ariaLabel.favorite}\n buttonContentClassName={iconWrapperClassName}\n onClick={handleFavoriteClick}\n style={{\n color: primaryColor\n }}\n onKeyDown={handleKeyPress}\n onMouseLeave={handleMouseLeave}\n onMouseOver={handleMouseOver}\n tabIndex={0}\n useButtonTag\n useWrapper={false}\n >\n {icon}\n </Button>\n <ToolTip\n fontSize={12}\n anchorId={favoriteButtonAnchorId}\n toolTipIsVisible={toolTipIsVisible}\n TooltipContent={toolTipContent}\n closeToolTipInformationTextAriaLabel={translate(\n 'Press the escape key to close the information text'\n )}\n stickyOnKeyboardNavigation\n />\n </div>\n );\n};\n\nFavorite.propTypes = {\n className: PropTypes.string,\n favorite: PropTypes.bool,\n disabled: PropTypes.bool,\n addFavoriteToolTip: PropTypes.string,\n removeFavoriteToolTip: PropTypes.string,\n onFavoriteClick: PropTypes.func,\n 'aria-label': PropTypes.shape({\n favorite: PropTypes.string,\n addToFavorite: PropTypes.string,\n removeFromFavorite: PropTypes.string\n })\n};\n\nFavorite.contextTypes = {\n skin: Provider.childContextTypes.skin,\n translate: Provider.childContextTypes.translate\n};\n\nexport default Favorite;\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,OAA5B,EAAqCC,MAArC,EAA6CC,QAA7C,QAA4D,OAA5D;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAAQC,EAAE,IAAIC,MAAd,QAA2B,MAA3B;AAEA,SACEC,6BAA6B,IAAIC,QADnC,EAEEC,gCAAgC,IAAIC,SAFtC,QAGO,0BAHP;AAIA,OAAOC,QAAP,IAAkBC,kBAAlB,EAAsCC,uBAAtC,QAAoE,qBAApE;AACA,OAAOC,OAAP,IAAiBC,qBAAjB,QAA6C,oBAA7C;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,OAAOC,KAAP,MAAkB,gBAAlB;;AAEA,MAAMC,QAAQ,GAAG,CACf;EACEC,QADF;EAEEC,kBAFF;EAGEC,qBAHF;EAIEC,SAJF;EAKE,cAAcC,SAAS,GAAG,EAL5B;EAMEC,eAAe,QANjB;EAOEC;AAPF,CADe,EAUfC,aAVe,KAWZ;EACH,MAAMC,IAAI,GAAGf,kBAAkB,CAACc,aAAD,CAA/B;EACA,MAAME,SAAS,GAA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BzC,QAAQ,EAAEtB,SAAS,CAAC+D,IAHD;EAInB9C,kBAAkB,EAAEjB,SAAS,CAAC8D,MAJX;EAKnB5C,qBAAqB,EAAElB,SAAS,CAAC8D,MALd;EAMnBzC,eAAe,EAAErB,SAAS,CAACgE,IANR;EAOnB,cAAchE,SAAS,CAACiE,KAAV,CAAgB;IAC5BjD,QAAQ,EAAEhB,SAAS,CAAC8D,MADQ;IAE5BH,aAAa,EAAE3D,SAAS,CAAC8D,MAFG;IAG5BL,kBAAkB,EAAEzD,SAAS,CAAC8D;EAHF,CAAhB;AAPK,CAArB;AAcA/C,QAAQ,CAACmD,YAAT,GAAwB;EACtB1C,IAAI,EAAEhB,QAAQ,CAAC2D,iBAAT,CAA2B3C,IADX;EAEtBC,SAAS,EAAEjB,QAAQ,CAAC2D,iBAAT,CAA2B1C;AAFhB,CAAxB;AAKA,eAAeV,QAAf"}
|
|
1
|
+
{"version":3,"file":"favorite.js","names":["React","useCallback","useMemo","useRef","useState","PropTypes","classnames","v5","uuidV5","NovaCompositionNavigationMore","MoreIcon","NovaCompositionCoorpacademyCheck","CheckIcon","Provider","GetSkinFromContext","GetTranslateFromContext","ToolTip","toggleStateOnKeyPress","Button","style","Favorite","favorite","addFavoriteToolTip","removeFavoriteToolTip","className","ariaLabel","onFavoriteClick","disabled","legacyContext","skin","translate","handleFavoriteClick","e","stopPropagation","preventDefault","primaryColor","darkColor","brandColor","buttonRef","allowToolTip","favoriteButtonAnchorId","URL","undefined","toolTipContent","mouseLeaveTimer","setMouseLeaveTimer","toolTipIsVisible","setToolTipIsVisible","handleMouseOver","clearTimeout","current","focus","handleMouseLeave","setTimeout","blur","handleKeyPress","event","iconWrapperClassName","selected","icon","checkIcon","color","removeFromFavorite","moreIcon","addToFavorite","favoriteWrapper","propTypes","string","bool","func","shape","contextTypes","childContextTypes"],"sources":["../../../src/molecule/card/favorite.js"],"sourcesContent":["import React, {useCallback, useMemo, useRef, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport {v5 as uuidV5} from 'uuid';\nimport {get, has, isEmpty, noop} from 'lodash/fp';\nimport {\n NovaCompositionNavigationMore as MoreIcon,\n NovaCompositionCoorpacademyCheck as CheckIcon\n} from '@coorpacademy/nova-icons';\nimport Provider, {GetSkinFromContext, GetTranslateFromContext} from '../../atom/provider';\nimport ToolTip, {toggleStateOnKeyPress} from '../../atom/tooltip';\nimport Button from '../../atom/button';\nimport style from './favorite.css';\n\nconst Favorite = (\n {\n favorite,\n addFavoriteToolTip,\n removeFavoriteToolTip,\n className,\n 'aria-label': ariaLabel = {},\n onFavoriteClick = noop,\n disabled\n },\n legacyContext\n) => {\n const skin = GetSkinFromContext(legacyContext);\n const translate = GetTranslateFromContext(legacyContext);\n const handleFavoriteClick = useCallback(\n e => {\n e.stopPropagation();\n e.preventDefault();\n if (!disabled) onFavoriteClick(e);\n },\n [disabled, onFavoriteClick]\n );\n\n const primaryColor = get('common.primary', skin);\n const darkColor = get('common.dark', skin);\n const brandColor = get('common.brand', skin);\n\n const buttonRef = useRef(null);\n\n const allowToolTip = useMemo(\n () => !isEmpty(removeFavoriteToolTip) && !isEmpty(addFavoriteToolTip),\n [addFavoriteToolTip, removeFavoriteToolTip]\n );\n\n // to be replaced by useId when React17 is bumped to React18\n const [favoriteButtonAnchorId] = useState(\n allowToolTip ? uuidV5('engaged-battle-', uuidV5.URL) : undefined\n );\n\n const toolTipContent = useMemo(\n // eslint-disable-next-line no-nested-ternary\n () => (allowToolTip ? (favorite ? removeFavoriteToolTip : addFavoriteToolTip) : null),\n [addFavoriteToolTip, favorite, removeFavoriteToolTip, allowToolTip]\n );\n\n const [mouseLeaveTimer, setMouseLeaveTimer] = useState(undefined);\n\n const [toolTipIsVisible, setToolTipIsVisible] = useState(false);\n\n const handleMouseOver = useCallback(() => {\n mouseLeaveTimer && clearTimeout(mouseLeaveTimer);\n /* istanbul ignore next */ has(['current', 'focus'], buttonRef) && buttonRef.current.focus();\n setToolTipIsVisible(true);\n }, [mouseLeaveTimer]);\n\n const handleMouseLeave = useCallback(() => {\n setMouseLeaveTimer(\n setTimeout(() => {\n setToolTipIsVisible(false);\n // @ts-expect-error (error: blur does not exists on type never)\n /* istanbul ignore next */ has(['current', 'blur'], buttonRef) && buttonRef.current.blur();\n }, 500)\n );\n }, []);\n\n const handleKeyPress = useCallback(\n event => {\n toggleStateOnKeyPress(toolTipIsVisible, setToolTipIsVisible, buttonRef)(event);\n },\n [toolTipIsVisible]\n );\n\n const iconWrapperClassName = useMemo(\n () => classnames(style.favorite, className, favorite && style.selected),\n [className, favorite]\n );\n const icon = useMemo(\n () =>\n favorite ? (\n <CheckIcon\n // eslint-disable-next-line css-modules/no-undef-class\n className={style.checkIcon}\n style={{color: brandColor}}\n width={13}\n height={13}\n data-testid=\"favorite-check-icon\"\n aria-label={ariaLabel.removeFromFavorite}\n />\n ) : (\n <MoreIcon\n className={style.moreIcon}\n style={{color: darkColor}}\n width={13}\n height={13}\n data-testid=\"favorite-add-icon\"\n aria-label={ariaLabel.addToFavorite}\n />\n ),\n [ariaLabel.addToFavorite, ariaLabel.removeFromFavorite, brandColor, darkColor, favorite]\n );\n\n return (\n <div className={style.favoriteWrapper} data-testid=\"favorite-wrapper\">\n <Button\n buttonRef={buttonRef}\n type=\"button\"\n data-for={favoriteButtonAnchorId}\n data-tooltip-place=\"left\"\n data-tip={allowToolTip}\n data-name=\"favorite\"\n data-testid=\"favorite-button\"\n aria-label={ariaLabel.favorite}\n buttonContentClassName={iconWrapperClassName}\n onClick={handleFavoriteClick}\n style={{\n color: primaryColor\n }}\n onKeyDown={handleKeyPress}\n onMouseLeave={handleMouseLeave}\n onMouseOver={handleMouseOver}\n tabIndex={0}\n useButtonTag\n useWrapper={false}\n >\n {icon}\n </Button>\n <ToolTip\n fontSize={12}\n anchorId={favoriteButtonAnchorId}\n toolTipIsVisible={toolTipIsVisible}\n TooltipContent={toolTipContent}\n closeToolTipInformationTextAriaLabel={translate('close_tooltip_information')}\n stickyOnKeyboardNavigation\n />\n </div>\n );\n};\n\nFavorite.propTypes = {\n className: PropTypes.string,\n favorite: PropTypes.bool,\n disabled: PropTypes.bool,\n addFavoriteToolTip: PropTypes.string,\n removeFavoriteToolTip: PropTypes.string,\n onFavoriteClick: PropTypes.func,\n 'aria-label': PropTypes.shape({\n favorite: PropTypes.string,\n addToFavorite: PropTypes.string,\n removeFromFavorite: PropTypes.string\n })\n};\n\nFavorite.contextTypes = {\n skin: Provider.childContextTypes.skin,\n translate: Provider.childContextTypes.translate\n};\n\nexport default Favorite;\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,OAA5B,EAAqCC,MAArC,EAA6CC,QAA7C,QAA4D,OAA5D;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAAQC,EAAE,IAAIC,MAAd,QAA2B,MAA3B;AAEA,SACEC,6BAA6B,IAAIC,QADnC,EAEEC,gCAAgC,IAAIC,SAFtC,QAGO,0BAHP;AAIA,OAAOC,QAAP,IAAkBC,kBAAlB,EAAsCC,uBAAtC,QAAoE,qBAApE;AACA,OAAOC,OAAP,IAAiBC,qBAAjB,QAA6C,oBAA7C;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,OAAOC,KAAP,MAAkB,gBAAlB;;AAEA,MAAMC,QAAQ,GAAG,CACf;EACEC,QADF;EAEEC,kBAFF;EAGEC,qBAHF;EAIEC,SAJF;EAKE,cAAcC,SAAS,GAAG,EAL5B;EAMEC,eAAe,QANjB;EAOEC;AAPF,CADe,EAUfC,aAVe,KAWZ;EACH,MAAMC,IAAI,GAAGf,kBAAkB,CAACc,aAAD,CAA/B;EACA,MAAME,SAAS,GAAGf,uBAAuB,CAACa,aAAD,CAAzC;EACA,MAAMG,mBAAmB,GAAG9B,WAAW,CACrC+B,CAAC,IAAI;IACHA,CAAC,CAACC,eAAF;IACAD,CAAC,CAACE,cAAF;IACA,IAAI,CAACP,QAAL,EAAe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IANR;EAOnB,cAAchE,SAAS,CAACiE,KAAV,CAAgB;IAC5BjD,QAAQ,EAAEhB,SAAS,CAAC8D,MADQ;IAE5BH,aAAa,EAAE3D,SAAS,CAAC8D,MAFG;IAG5BL,kBAAkB,EAAEzD,SAAS,CAAC8D;EAHF,CAAhB;AAPK,CAArB;AAcA/C,QAAQ,CAACmD,YAAT,GAAwB;EACtB1C,IAAI,EAAEhB,QAAQ,CAAC2D,iBAAT,CAA2B3C,IADX;EAEtBC,SAAS,EAAEjB,QAAQ,CAAC2D,iBAAT,CAA2B1C;AAFhB,CAAxB;AAKA,eAAeV,QAAf"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default DisciplineAssociatedSkills;
|
|
2
|
+
declare function DisciplineAssociatedSkills(props: any, context: any): JSX.Element | null;
|
|
3
|
+
declare namespace DisciplineAssociatedSkills {
|
|
4
|
+
namespace contextTypes {
|
|
5
|
+
const translate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
6
|
+
}
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
const skills: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
9
|
+
ref: PropTypes.Requireable<string>;
|
|
10
|
+
locale: PropTypes.Requireable<string>;
|
|
11
|
+
focused: PropTypes.Requireable<boolean>;
|
|
12
|
+
}> | null | undefined)[]>;
|
|
13
|
+
const onSkillClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
import PropTypes from "prop-types";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/discipline-associated-skills/index.js"],"names":[],"mappings":";AAUA,0FA0DC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _uniqueId from "lodash/fp/uniqueId";
|
|
2
|
+
import _isEmpty from "lodash/fp/isEmpty";
|
|
3
|
+
import React, { useCallback } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
import Icon from '../../atom/icon';
|
|
7
|
+
import ToolTip from '../../atom/tooltip';
|
|
8
|
+
import Provider from '../../atom/provider';
|
|
9
|
+
import CatalogSection from '../../atom/catalog-section';
|
|
10
|
+
import style from './style.css';
|
|
11
|
+
|
|
12
|
+
const DisciplineAssociatedSkills = (props, context) => {
|
|
13
|
+
const {
|
|
14
|
+
translate
|
|
15
|
+
} = context;
|
|
16
|
+
const {
|
|
17
|
+
skills = [],
|
|
18
|
+
onSkillClick
|
|
19
|
+
} = props;
|
|
20
|
+
const AnchorElement = useCallback(skill => /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: style.chipFocusedContent
|
|
22
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
23
|
+
iconName: "bullseye-arrow",
|
|
24
|
+
backgroundColor: "#DDD1FF",
|
|
25
|
+
size: {
|
|
26
|
+
faSize: 12,
|
|
27
|
+
wrapperSize: 12
|
|
28
|
+
}
|
|
29
|
+
}), skill), []);
|
|
30
|
+
return !_isEmpty(skills) ? /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
"data-name": "discipline-associated-skills",
|
|
32
|
+
className: style.associatedSkillsWrapper
|
|
33
|
+
}, /*#__PURE__*/React.createElement(CatalogSection, {
|
|
34
|
+
title: translate('associated_skills')
|
|
35
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: style.chipsWrapper
|
|
37
|
+
}, skills.map(skill => {
|
|
38
|
+
function handleSkillClick() {
|
|
39
|
+
return onSkillClick(skill.ref);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function handleAnchorElement() {
|
|
43
|
+
return AnchorElement(skill.locale);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
key: _uniqueId(),
|
|
48
|
+
className: classnames(style.chipWrapper, skill.focused && style.chipWrapperFocused),
|
|
49
|
+
onClick: handleSkillClick
|
|
50
|
+
}, skill.focused ? /*#__PURE__*/React.createElement(ToolTip, {
|
|
51
|
+
AnchorElement: handleAnchorElement,
|
|
52
|
+
fontSize: 12,
|
|
53
|
+
iconContainerClassName: style.infoIconTooltip,
|
|
54
|
+
tooltipClassName: style.tooltip,
|
|
55
|
+
TooltipContent: translate('skill_focused_chip_tooltip'),
|
|
56
|
+
closeToolTipInformationTextAriaLabel: translate('close_tooltip_information')
|
|
57
|
+
}) : skill.locale);
|
|
58
|
+
})))) : null;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
DisciplineAssociatedSkills.contextTypes = {
|
|
62
|
+
translate: Provider.childContextTypes.translate
|
|
63
|
+
};
|
|
64
|
+
DisciplineAssociatedSkills.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
65
|
+
skills: PropTypes.arrayOf(PropTypes.shape({
|
|
66
|
+
ref: PropTypes.string,
|
|
67
|
+
locale: PropTypes.string,
|
|
68
|
+
focused: PropTypes.bool
|
|
69
|
+
})),
|
|
70
|
+
onSkillClick: PropTypes.func
|
|
71
|
+
} : {};
|
|
72
|
+
export default DisciplineAssociatedSkills;
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","PropTypes","classnames","Icon","ToolTip","Provider","CatalogSection","style","DisciplineAssociatedSkills","props","context","translate","skills","onSkillClick","AnchorElement","skill","chipFocusedContent","faSize","wrapperSize","associatedSkillsWrapper","chipsWrapper","map","handleSkillClick","ref","handleAnchorElement","locale","chipWrapper","focused","chipWrapperFocused","infoIconTooltip","tooltip","contextTypes","childContextTypes","propTypes","arrayOf","shape","string","bool","func"],"sources":["../../../src/molecule/discipline-associated-skills/index.js"],"sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport {isEmpty, uniqueId} from 'lodash/fp';\nimport Icon from '../../atom/icon';\nimport ToolTip from '../../atom/tooltip';\nimport Provider from '../../atom/provider';\nimport CatalogSection from '../../atom/catalog-section';\nimport style from './style.css';\n\nconst DisciplineAssociatedSkills = (props, context) => {\n const {translate} = context;\n\n const {skills = [], onSkillClick} = props;\n\n const AnchorElement = useCallback(\n skill => (\n <div className={style.chipFocusedContent}>\n <Icon\n iconName=\"bullseye-arrow\"\n backgroundColor=\"#DDD1FF\"\n size={{\n faSize: 12,\n wrapperSize: 12\n }}\n />\n {skill}\n </div>\n ),\n []\n );\n\n return !isEmpty(skills) ? (\n <div data-name=\"discipline-associated-skills\" className={style.associatedSkillsWrapper}>\n <CatalogSection title={translate('associated_skills')}>\n <div className={style.chipsWrapper}>\n {skills.map(skill => {\n function handleSkillClick() {\n return onSkillClick(skill.ref);\n }\n function handleAnchorElement() {\n return AnchorElement(skill.locale);\n }\n return (\n <div\n key={uniqueId()}\n className={classnames(style.chipWrapper, skill.focused && style.chipWrapperFocused)}\n onClick={handleSkillClick}\n >\n {skill.focused ? (\n <ToolTip\n AnchorElement={handleAnchorElement}\n fontSize={12}\n iconContainerClassName={style.infoIconTooltip}\n tooltipClassName={style.tooltip}\n TooltipContent={translate('skill_focused_chip_tooltip')}\n closeToolTipInformationTextAriaLabel={translate('close_tooltip_information')}\n />\n ) : (\n skill.locale\n )}\n </div>\n );\n })}\n </div>\n </CatalogSection>\n </div>\n ) : null;\n};\n\nDisciplineAssociatedSkills.contextTypes = {\n translate: Provider.childContextTypes.translate\n};\n\nDisciplineAssociatedSkills.propTypes = {\n skills: PropTypes.arrayOf(\n PropTypes.shape({\n ref: PropTypes.string,\n locale: PropTypes.string,\n focused: PropTypes.bool\n })\n ),\n onSkillClick: PropTypes.func\n};\n\nexport default DisciplineAssociatedSkills;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAeC,WAAf,QAAiC,OAAjC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,OAAOC,IAAP,MAAiB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Aa,EAAEH,mBADjB;MAEE,QAAQ,EAAE,EAFZ;MAGE,sBAAsB,EAAEjB,KAAK,CAACsB,eAHhC;MAIE,gBAAgB,EAAEtB,KAAK,CAACuB,OAJ1B;MAKE,cAAc,EAAEnB,SAAS,CAAC,4BAAD,CAL3B;MAME,oCAAoC,EAAEA,SAAS,CAAC,2BAAD;IANjD,EADD,GAUCI,KAAK,CAACU,MAfV,CADF;EAoBD,CA3BA,CADH,CADF,CADF,CADK,GAmCH,IAnCJ;AAoCD,CA1DD;;AA4DAjB,0BAA0B,CAACuB,YAA3B,GAA0C;EACxCpB,SAAS,EAAEN,QAAQ,CAAC2B,iBAAT,CAA2BrB;AADE,CAA1C;AAIAH,0BAA0B,CAACyB,SAA3B,2CAAuC;EACrCrB,MAAM,EAAEX,SAAS,CAACiC,OAAV,CACNjC,SAAS,CAACkC,KAAV,CAAgB;IACdZ,GAAG,EAAEtB,SAAS,CAACmC,MADD;IAEdX,MAAM,EAAExB,SAAS,CAACmC,MAFJ;IAGdT,OAAO,EAAE1B,SAAS,CAACoC;EAHL,CAAhB,CADM,CAD6B;EAQrCxB,YAAY,EAAEZ,SAAS,CAACqC;AARa,CAAvC;AAWA,eAAe9B,0BAAf"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@value colors: "../../variables/colors.css";
|
|
2
|
+
@value breakpoints: "../../variables/breakpoints.css";
|
|
3
|
+
@value desktop from breakpoints;
|
|
4
|
+
@value cm_grey_100 from colors;
|
|
5
|
+
@value cm_grey_200 from colors;
|
|
6
|
+
@value cm_grey_700 from colors;
|
|
7
|
+
|
|
8
|
+
.associatedSkillsWrapper {
|
|
9
|
+
margin-bottom: 12px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.chipsWrapper {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
gap: 8px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.chipWrapper {
|
|
19
|
+
width: fit-content;
|
|
20
|
+
border-radius: 8px;
|
|
21
|
+
padding: 4px 8px;
|
|
22
|
+
background-color: cm_grey_200;
|
|
23
|
+
color: cm_grey_700;
|
|
24
|
+
font-family: 'Gilroy';
|
|
25
|
+
font-style: normal;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
line-height: 20px;
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
text-overflow: ellipsis;
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.chipWrapperFocused {
|
|
34
|
+
background-color: #DDD1FF;
|
|
35
|
+
color: #3900D6;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.chipFocusedContent {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 4px;
|
|
42
|
+
|
|
43
|
+
div {
|
|
44
|
+
padding: 0 !important;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.infoIconTooltip {
|
|
49
|
+
background-color: transparent;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.tooltip {
|
|
53
|
+
width: fit-content;
|
|
54
|
+
color: #FFF;
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
font-style: normal;
|
|
57
|
+
line-height: 16px;
|
|
58
|
+
right: -28px;
|
|
59
|
+
top: -48px;
|
|
60
|
+
|
|
61
|
+
p {
|
|
62
|
+
padding: 8px 8px;
|
|
63
|
+
margin: 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@media desktop {
|
|
68
|
+
.associatedSkillsWrapper {
|
|
69
|
+
margin-top: 24px;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -2,6 +2,27 @@ export default LearnerSkillCard;
|
|
|
2
2
|
declare function LearnerSkillCard(props: any, context: any): JSX.Element;
|
|
3
3
|
declare namespace LearnerSkillCard {
|
|
4
4
|
namespace contextTypes {
|
|
5
|
+
const skin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
+
common: PropTypes.Requireable<{
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
}>;
|
|
9
|
+
images: PropTypes.Requireable<PropTypes.InferProps<{
|
|
10
|
+
'logo-mobile': PropTypes.Requireable<any>;
|
|
11
|
+
logo: PropTypes.Requireable<any>;
|
|
12
|
+
'logo-email': PropTypes.Requireable<any>;
|
|
13
|
+
login: PropTypes.Requireable<any>;
|
|
14
|
+
}>>;
|
|
15
|
+
icons: PropTypes.Requireable<{
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
}>;
|
|
18
|
+
mod: PropTypes.Requireable<{
|
|
19
|
+
[x: string]: any;
|
|
20
|
+
}>;
|
|
21
|
+
courses: PropTypes.Requireable<any[]>;
|
|
22
|
+
texts: PropTypes.Requireable<{
|
|
23
|
+
[x: string]: any;
|
|
24
|
+
}>;
|
|
25
|
+
}>>;
|
|
5
26
|
const translate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
6
27
|
}
|
|
7
28
|
const propTypes: {
|
|
@@ -10,6 +31,7 @@ declare namespace LearnerSkillCard {
|
|
|
10
31
|
skillAriaLabel: PropTypes.Requireable<string>;
|
|
11
32
|
focus: PropTypes.Requireable<boolean>;
|
|
12
33
|
metrics: PropTypes.Requireable<PropTypes.InferProps<{
|
|
34
|
+
score: PropTypes.Requireable<number>;
|
|
13
35
|
skillCourses: PropTypes.Requireable<number>;
|
|
14
36
|
skillQuestions: PropTypes.Requireable<number>;
|
|
15
37
|
completedCourses: PropTypes.Requireable<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/learner-skill-card/index.js"],"names":[],"mappings":";AASA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/learner-skill-card/index.js"],"names":[],"mappings":";AASA,yEAwJC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _getOr from "lodash/fp/getOr";
|
|
2
1
|
import _get from "lodash/fp/get";
|
|
3
2
|
import React, { useCallback, useState } from 'react';
|
|
4
3
|
import { convert } from 'css-color-function';
|
|
@@ -20,6 +19,7 @@ const LearnerSkillCard = (props, context) => {
|
|
|
20
19
|
onExploreClick
|
|
21
20
|
} = props;
|
|
22
21
|
const {
|
|
22
|
+
score,
|
|
23
23
|
skillCourses,
|
|
24
24
|
skillQuestions,
|
|
25
25
|
completedCourses = 0
|
|
@@ -30,7 +30,7 @@ const LearnerSkillCard = (props, context) => {
|
|
|
30
30
|
} = context;
|
|
31
31
|
const [hovered, setHovered] = useState(false);
|
|
32
32
|
|
|
33
|
-
const primarySkinColor =
|
|
33
|
+
const primarySkinColor = _get('common.primary', skin);
|
|
34
34
|
|
|
35
35
|
const reviewLocale = translate('Review');
|
|
36
36
|
const exploreLocale = translate('Explore');
|
|
@@ -71,13 +71,12 @@ const LearnerSkillCard = (props, context) => {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
const completedPercentage = skillCourses && Number.parseInt(completedCourses / skillCourses * 100);
|
|
75
74
|
const ProgressBar = useCallback(() => {
|
|
76
75
|
if (!skillCourses) return null;
|
|
77
76
|
const progressBarColor = '#3EC483';
|
|
78
77
|
const inlineProgressValueStyle = {
|
|
79
78
|
backgroundColor: progressBarColor,
|
|
80
|
-
width: `${
|
|
79
|
+
width: `${score}%`
|
|
81
80
|
};
|
|
82
81
|
return /*#__PURE__*/React.createElement("div", {
|
|
83
82
|
className: style.progressWrapper
|
|
@@ -88,7 +87,7 @@ const LearnerSkillCard = (props, context) => {
|
|
|
88
87
|
role: "progressbar",
|
|
89
88
|
"aria-label": _get('progression', ariaLabel)
|
|
90
89
|
}));
|
|
91
|
-
}, [
|
|
90
|
+
}, [score, ariaLabel, skillCourses]);
|
|
92
91
|
return /*#__PURE__*/React.createElement("div", {
|
|
93
92
|
className: style.learnerSkillCardWrapper,
|
|
94
93
|
"data-name": "learner-skill-card-wrapper",
|
|
@@ -132,7 +131,7 @@ const LearnerSkillCard = (props, context) => {
|
|
|
132
131
|
"data-name": "completed-percentage"
|
|
133
132
|
}, /*#__PURE__*/React.createElement("span", {
|
|
134
133
|
className: style.progressInformationNumber
|
|
135
|
-
},
|
|
134
|
+
}, score, "%")))), /*#__PURE__*/React.createElement("div", {
|
|
136
135
|
className: style.ctaWrapper,
|
|
137
136
|
"data-name": "cta-wrapper"
|
|
138
137
|
}, /*#__PURE__*/React.createElement(ButtonLink, buttonReviewProps), /*#__PURE__*/React.createElement("div", {
|
|
@@ -144,6 +143,7 @@ const LearnerSkillCard = (props, context) => {
|
|
|
144
143
|
};
|
|
145
144
|
|
|
146
145
|
LearnerSkillCard.contextTypes = {
|
|
146
|
+
skin: Provider.childContextTypes.skin,
|
|
147
147
|
translate: Provider.childContextTypes.translate
|
|
148
148
|
};
|
|
149
149
|
LearnerSkillCard.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
@@ -152,6 +152,7 @@ LearnerSkillCard.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
152
152
|
skillAriaLabel: PropTypes.string,
|
|
153
153
|
focus: PropTypes.bool,
|
|
154
154
|
metrics: PropTypes.shape({
|
|
155
|
+
score: PropTypes.number,
|
|
155
156
|
skillCourses: PropTypes.number,
|
|
156
157
|
skillQuestions: PropTypes.number,
|
|
157
158
|
completedCourses: PropTypes.number
|