@coorpacademy/components 11.14.22 → 11.14.24-alpha.10
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/autocomplete/index.d.ts +3 -1
- package/es/atom/autocomplete/index.d.ts.map +1 -1
- package/es/atom/autocomplete/index.js +55 -19
- package/es/atom/autocomplete/index.js.map +1 -1
- package/es/atom/autocomplete/style.css +223 -0
- package/es/atom/input-switch/index.d.ts.map +1 -1
- package/es/atom/input-switch/index.js +3 -1
- package/es/atom/input-switch/index.js.map +1 -1
- package/es/molecule/brand-form-group/index.d.ts +3 -1
- package/es/molecule/select-multiple/index.d.ts +0 -1
- package/es/molecule/select-multiple/index.d.ts.map +1 -1
- package/es/molecule/select-multiple/index.js +14 -29
- package/es/molecule/select-multiple/index.js.map +1 -1
- package/es/molecule/select-multiple/style.css +1 -1
- package/es/organism/brand-form/index.d.ts +4 -1
- package/es/organism/brand-form/index.d.ts.map +1 -1
- package/es/organism/brand-form/index.js +17 -7
- package/es/organism/brand-form/index.js.map +1 -1
- package/es/organism/user-preferences/index.js +3 -1
- package/es/organism/user-preferences/index.js.map +1 -1
- package/es/organism/wizard-contents/index.d.ts +4 -1
- package/es/template/back-office/brand-update/index.d.ts +4 -1
- package/lib/atom/autocomplete/index.d.ts +3 -1
- package/lib/atom/autocomplete/index.d.ts.map +1 -1
- package/lib/atom/autocomplete/index.js +58 -18
- package/lib/atom/autocomplete/index.js.map +1 -1
- package/lib/atom/autocomplete/style.css +223 -0
- package/lib/atom/input-switch/index.d.ts.map +1 -1
- package/lib/atom/input-switch/index.js +3 -1
- package/lib/atom/input-switch/index.js.map +1 -1
- package/lib/molecule/brand-form-group/index.d.ts +3 -1
- package/lib/molecule/select-multiple/index.d.ts +0 -1
- package/lib/molecule/select-multiple/index.d.ts.map +1 -1
- package/lib/molecule/select-multiple/index.js +15 -33
- package/lib/molecule/select-multiple/index.js.map +1 -1
- package/lib/molecule/select-multiple/style.css +1 -1
- package/lib/organism/brand-form/index.d.ts +4 -1
- package/lib/organism/brand-form/index.d.ts.map +1 -1
- package/lib/organism/brand-form/index.js +18 -7
- package/lib/organism/brand-form/index.js.map +1 -1
- package/lib/organism/user-preferences/index.js +3 -1
- package/lib/organism/user-preferences/index.js.map +1 -1
- package/lib/organism/wizard-contents/index.d.ts +4 -1
- package/lib/template/back-office/brand-update/index.d.ts +4 -1
- package/locales/.mtslconfig.json +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useState","useEffect","useRef","useCallback","PropTypes","classnames","NovaCompositionNavigationArrowDown","ArrowDown","NovaSolidStatusClose","ErrorIcon","NovaCompositionCoorpacademyInformationIcon","InfoIcon","TitledCheckbox","Provider","Checkbox","getClassState","style","themeStyle","setup","cockpit","sidebar","coorpmanager","useChoices","options","choicesRef","current","getChoices","setChoices","choice","choices","i","selected","filter","c","CMMultipleView","multiple","onChange","handleChange","checked","item","name","SelectMultiple","title","theme","placeholder","description","hint","onError","modified","error","disabled","skin","isOpened","updateIsOpened","nodeRef","defaultColor","black","handleOnClick","e","preventDefault","stopPropagation","prev","closeHandle","contains","target","document","addEventListener","removeEventListener","isCMTheme","handleOnClickOnListElement","lines","convert","cap","selection","isActive","titleView","titleWithSelection","noValue","active","infoIconWrapper","infoIcon","descriptionLabel","hintView","hideHint","__html","mainClass","default","showPlaceholder","behaviourClassName","errorIconView","errorIcon","select","noselection","iconsWrapper","flex","clicked","color","arrow","down","activeChoices","list","contextTypes","childContextTypes","propTypes","bool","func","string","arrayOf","oneOf"],"sources":["../../../src/molecule/select-multiple/index.js"],"sourcesContent":["import React, {useState, useEffect, useRef, useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport {map, pipe, join, filter, get, set, keys, isEmpty} from 'lodash/fp';\nimport {\n NovaCompositionNavigationArrowDown as ArrowDown,\n NovaSolidStatusClose as ErrorIcon,\n NovaCompositionCoorpacademyInformationIcon as InfoIcon\n} from '@coorpacademy/nova-icons';\nimport TitledCheckbox from '../titled-checkbox';\nimport Provider from '../../atom/provider';\nimport Checkbox from '../../atom/input-checkbox';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst themeStyle = {\n setup: style.setup,\n cockpit: style.cockpit,\n sidebar: style.sidebar,\n coorpmanager: style.coorpmanager\n};\n\nexport const useChoices = options => {\n const choicesRef = {current: options};\n\n const getChoices = () => {\n return choicesRef.current;\n };\n\n const setChoices = choice => {\n const choices = set(`[${choice.i}].selected`, !choice.selected, getChoices());\n\n choicesRef.current = choices.filter(c => c.selected);\n };\n\n return [getChoices, setChoices];\n};\n\nconst CMMultipleView = ({multiple, choice, onChange}) => {\n const handleChange = useCallback(\n checked => {\n return onChange({...choice, selected: checked});\n },\n [onChange, choice]\n );\n\n return multiple ? (\n <div className={style.item}>\n <Checkbox\n titleStyle=\"inherit\"\n checked={choice.selected}\n onChange={handleChange}\n noLabelMargins\n title={choice.name}\n />\n </div>\n ) : (\n <span className={style.item} title={choice.name} data-name={`${choice.name}-language`}>\n {choice.name}\n </span>\n );\n};\n\nconst SelectMultiple = (\n {\n title,\n options,\n theme,\n placeholder,\n description,\n hint,\n multiple,\n onChange,\n onError,\n modified = false,\n error = '',\n disabled = false\n },\n {skin}\n) => {\n const [isOpened, updateIsOpened] = useState(false);\n const [getChoices, setChoices] = useChoices(options);\n const nodeRef = useRef(null);\n\n const defaultColor = get('common.primary', skin);\n const black = get('common.black', skin);\n\n const handleOnClick = useCallback(\n e => {\n if (disabled) return;\n\n e.preventDefault();\n e.stopPropagation();\n\n updateIsOpened(prev => !prev);\n },\n [disabled]\n );\n\n const closeHandle = useCallback(e => {\n if (nodeRef && nodeRef.current && !nodeRef.current.contains(e.target)) {\n updateIsOpened(false);\n }\n }, []);\n\n const handleChange = useCallback(\n choice => {\n // if multiple prop is turned on\n // we return all selected choices\n if (multiple) {\n setChoices(choice);\n return onChange(getChoices());\n }\n updateIsOpened(false);\n return onChange(choice);\n },\n [multiple, onChange, setChoices, getChoices]\n );\n\n useEffect(() => {\n document.addEventListener('click', closeHandle);\n document.addEventListener('touchstart', closeHandle);\n\n return () => {\n document.removeEventListener('click', closeHandle);\n document.removeEventListener('touchstart', closeHandle);\n };\n }, [closeHandle]);\n\n const isCMTheme = theme === 'coorpmanager';\n\n const handleOnClickOnListElement = choice => () => handleChange(choice);\n\n const lines = map.convert({cap: false})((choice, i) => {\n return (\n <li\n key={i}\n className={style.choice}\n onClick={isCMTheme && !multiple ? handleOnClickOnListElement({...choice, i}) : null}\n >\n {isCMTheme ? (\n <CMMultipleView multiple={multiple} choice={{...choice, i}} onChange={handleChange} />\n ) : (\n <TitledCheckbox\n onToggle={handleChange}\n choice={{...choice, i}}\n background={defaultColor}\n />\n )}\n </li>\n );\n }, options);\n\n const selection = pipe(filter({selected: true}), map('name'), join(', '))(options);\n\n const isActive = isOpened === true;\n\n const titleView = title ? (\n <span\n className={classnames(\n style.title,\n isCMTheme && selection && style.titleWithSelection,\n isCMTheme && isEmpty(selection) && style.noValue,\n isActive && style.active\n )}\n >\n {title}\n {isCMTheme ? (\n <div className={style.infoIconWrapper}>\n <InfoIcon className={style.infoIcon} />\n <div className={style.descriptionLabel}>{description}</div>\n </div>\n ) : null}\n </span>\n ) : null;\n\n const hintView = isCMTheme ? (\n <div\n className={classnames(style.hint, isActive && style.hideHint)}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: error || hint}}\n />\n ) : null;\n\n const mainClass = theme ? themeStyle[theme] : style.default;\n const showPlaceholder = isCMTheme && isActive;\n const behaviourClassName = getClassState(\n style.default,\n style.modified,\n style.error,\n modified,\n error\n );\n\n const errorIconView = error ? <ErrorIcon onClick={onError} className={style.errorIcon} /> : null;\n\n return (\n <div\n className={classnames(mainClass, behaviourClassName, disabled && style.disabled)}\n ref={nodeRef}\n >\n <label>\n {!isCMTheme && titleView}\n <div\n className={style.select}\n title={selection || placeholder}\n data-name={`select-languages`}\n onClick={handleOnClick}\n >\n {isCMTheme && titleView}\n <span\n className={classnames(\n style.selection,\n isCMTheme && isEmpty(selection) && style.noselection\n )}\n >\n {selection || !isCMTheme || (showPlaceholder && placeholder) || null}\n </span>\n {isCMTheme ? (\n <div className={style.iconsWrapper}>\n <div className={style.flex}>{errorIconView}</div>\n <div className={classnames(style.flex, isActive && style.clicked)}>\n <ArrowDown\n style={{color: black}}\n className={classnames(style.arrow, {[style.down]: isActive})}\n />\n </div>\n </div>\n ) : (\n <ArrowDown\n style={{color: black}}\n className={classnames(style.arrow, {[style.down]: isActive})}\n />\n )}\n </div>\n <div className={classnames(style.choices, isActive && style.activeChoices)}>\n <ul className={style.list}>{lines}</ul>\n </div>\n </label>\n {!isCMTheme ? <div className={style.description}>{description}</div> : null}\n {hintView}\n </div>\n );\n};\n\nSelectMultiple.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nCMMultipleView.propTypes = {\n multiple: PropTypes.bool,\n choice: TitledCheckbox.propTypes.choice,\n onChange: PropTypes.func\n};\n\nSelectMultiple.propTypes = {\n title: PropTypes.string,\n placeholder: PropTypes.string,\n description: PropTypes.string,\n hint: PropTypes.string,\n options: PropTypes.arrayOf(TitledCheckbox.propTypes.choice),\n onChange: PropTypes.func,\n onError: PropTypes.func,\n multiple: PropTypes.bool,\n modified: PropTypes.bool,\n disabled: PropTypes.bool,\n error: PropTypes.string,\n theme: PropTypes.oneOf(keys(themeStyle))\n};\n\nexport default SelectMultiple;\n"],"mappings":";;;;;;;;;;;AAAA,OAAOA,KAAP,IAAeC,QAAf,EAAyBC,SAAzB,EAAoCC,MAApC,EAA4CC,WAA5C,QAA8D,OAA9D;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,SACEC,kCAAkC,IAAIC,SADxC,EAEEC,oBAAoB,IAAIC,SAF1B,EAGEC,0CAA0C,IAAIC,QAHhD,QAIO,0BAJP;AAKA,OAAOC,cAAP,MAA2B,o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EzC,SAAS,CAACsG,MAHE;EAIzB5D,IAAI,EAAE1C,SAAS,CAACsG,MAJS;EAKzBnF,OAAO,EAAEnB,SAAS,CAACuG,OAAV,CAAkB/F,cAAc,CAAC2F,SAAf,CAAyB3E,MAA3C,CALgB;EAMzBQ,QAAQ,EAAEhC,SAAS,CAACqG,IANK;EAOzB1D,OAAO,EAAE3C,SAAS,CAACqG,IAPM;EAQzBtE,QAAQ,EAAE/B,SAAS,CAACoG,IARK;EASzBxD,QAAQ,EAAE5C,SAAS,CAACoG,IATK;EAUzBtD,QAAQ,EAAE9C,SAAS,CAACoG,IAVK;EAWzBvD,KAAK,EAAE7C,SAAS,CAACsG,MAXQ;EAYzB/D,KAAK,EAAEvC,SAAS,CAACwG,KAAV,CAAgB,MAAK3F,UAAL,CAAhB;AAZkB,CAA3B;AAeA,eAAewB,cAAf"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useState","useEffect","useRef","useCallback","PropTypes","classnames","NovaCompositionNavigationArrowDown","ArrowDown","NovaSolidStatusClose","ErrorIcon","NovaCompositionCoorpacademyInformationIcon","InfoIcon","TitledCheckbox","Provider","Checkbox","getClassState","style","themeStyle","setup","cockpit","sidebar","coorpmanager","CMMultipleView","multiple","choice","onChange","handleChange","checked","selected","item","name","SelectMultiple","title","options","theme","placeholder","description","hint","onError","modified","error","disabled","skin","isOpened","updateIsOpened","nodeRef","defaultColor","black","handleOnClick","e","preventDefault","stopPropagation","prev","closeHandle","current","contains","target","document","addEventListener","removeEventListener","isCMTheme","handleOnClickOnListElement","lines","convert","cap","i","selection","isActive","titleView","titleWithSelection","noValue","active","infoIconWrapper","infoIcon","descriptionLabel","hintView","hideHint","__html","mainClass","default","showPlaceholder","behaviourClassName","errorIconView","errorIcon","select","noselection","iconsWrapper","flex","clicked","color","arrow","down","choices","activeChoices","list","contextTypes","childContextTypes","propTypes","bool","func","string","arrayOf","oneOf"],"sources":["../../../src/molecule/select-multiple/index.js"],"sourcesContent":["import React, {useState, useEffect, useRef, useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport {map, pipe, join, filter, get, set, keys, isEmpty} from 'lodash/fp';\nimport {\n NovaCompositionNavigationArrowDown as ArrowDown,\n NovaSolidStatusClose as ErrorIcon,\n NovaCompositionCoorpacademyInformationIcon as InfoIcon\n} from '@coorpacademy/nova-icons';\nimport TitledCheckbox from '../titled-checkbox';\nimport Provider from '../../atom/provider';\nimport Checkbox from '../../atom/input-checkbox';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst themeStyle = {\n setup: style.setup,\n cockpit: style.cockpit,\n sidebar: style.sidebar,\n coorpmanager: style.coorpmanager\n};\n\n// export const useChoices = options => {\n// const choicesRef = {current: options};\n\n// const getChoices = () => {\n// return choicesRef.current;\n// };\n\n// const setChoices = choice => {\n// const choices = set(`[${choice.i}].selected`, !choice.selected, getChoices());\n\n// choicesRef.current = choices.filter(c => c.selected);\n// };\n\n// return [getChoices, setChoices];\n// };\n\nconst CMMultipleView = ({multiple, choice, onChange}) => {\n const handleChange = useCallback(\n checked => {\n return onChange({...choice, selected: checked});\n },\n [onChange, choice]\n );\n\n return multiple ? (\n <div className={style.item}>\n <Checkbox\n titleStyle=\"inherit\"\n checked={choice.selected}\n onChange={handleChange}\n noLabelMargins\n title={choice.name}\n />\n </div>\n ) : (\n <span className={style.item} title={choice.name} data-name={`${choice.name}-language`}>\n {choice.name}\n </span>\n );\n};\n\nconst SelectMultiple = (\n {\n title,\n options,\n theme,\n placeholder,\n description,\n hint,\n multiple,\n onChange,\n onError,\n modified = false,\n error = '',\n disabled = false\n },\n {skin}\n) => {\n const [isOpened, updateIsOpened] = useState(false);\n // const [getChoices, setChoices] = useChoices(options);\n const nodeRef = useRef(null);\n\n const defaultColor = get('common.primary', skin);\n const black = get('common.black', skin);\n\n const handleOnClick = useCallback(\n e => {\n if (disabled) return;\n\n e.preventDefault();\n e.stopPropagation();\n\n updateIsOpened(prev => !prev);\n },\n [disabled]\n );\n\n const closeHandle = useCallback(e => {\n if (nodeRef && nodeRef.current && !nodeRef.current.contains(e.target)) {\n updateIsOpened(false);\n }\n }, []);\n\n const handleChange = useCallback(\n choice => {\n updateIsOpened(false);\n return onChange(choice);\n },\n [onChange]\n );\n\n useEffect(() => {\n document.addEventListener('click', closeHandle);\n document.addEventListener('touchstart', closeHandle);\n\n return () => {\n document.removeEventListener('click', closeHandle);\n document.removeEventListener('touchstart', closeHandle);\n };\n }, [closeHandle]);\n\n const isCMTheme = theme === 'coorpmanager';\n\n const handleOnClickOnListElement = choice => () => handleChange(choice);\n\n const lines = map.convert({cap: false})((choice, i) => {\n return (\n <li\n key={i}\n className={style.choice}\n onClick={isCMTheme && !multiple ? handleOnClickOnListElement({...choice, i}) : null}\n >\n {isCMTheme ? (\n <CMMultipleView multiple={multiple} choice={{...choice, i}} onChange={handleChange} />\n ) : (\n <TitledCheckbox\n onToggle={handleChange}\n choice={{...choice, i}}\n background={defaultColor}\n />\n )}\n </li>\n );\n }, options);\n\n const selection = pipe(filter({selected: true}), map('name'), join(', '))(options);\n\n const isActive = isOpened === true;\n\n const titleView = title ? (\n <span\n className={classnames(\n style.title,\n isCMTheme && selection && style.titleWithSelection,\n isCMTheme && isEmpty(selection) && style.noValue,\n isActive && style.active\n )}\n >\n {title}\n {isCMTheme ? (\n <div className={style.infoIconWrapper}>\n <InfoIcon className={style.infoIcon} />\n <div className={style.descriptionLabel}>{description}</div>\n </div>\n ) : null}\n </span>\n ) : null;\n\n const hintView = isCMTheme ? (\n <div\n className={classnames(style.hint, isActive && style.hideHint)}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: error || hint}}\n />\n ) : null;\n\n const mainClass = theme ? themeStyle[theme] : style.default;\n const showPlaceholder = isCMTheme && isActive;\n const behaviourClassName = getClassState(\n style.default,\n style.modified,\n style.error,\n modified,\n error\n );\n\n const errorIconView = error ? <ErrorIcon onClick={onError} className={style.errorIcon} /> : null;\n\n return (\n <div\n className={classnames(mainClass, behaviourClassName, disabled && style.disabled)}\n ref={nodeRef}\n >\n <label>\n {!isCMTheme && titleView}\n <div\n className={style.select}\n title={selection || placeholder}\n data-name={`select-languages`}\n onClick={handleOnClick}\n >\n {isCMTheme && titleView}\n <span\n className={classnames(\n style.selection,\n isCMTheme && isEmpty(selection) && style.noselection\n )}\n >\n {selection || !isCMTheme || (showPlaceholder && placeholder) || null}\n </span>\n {isCMTheme ? (\n <div className={style.iconsWrapper}>\n <div className={style.flex}>{errorIconView}</div>\n <div className={classnames(style.flex, isActive && style.clicked)}>\n <ArrowDown\n style={{color: black}}\n className={classnames(style.arrow, {[style.down]: isActive})}\n />\n </div>\n </div>\n ) : (\n <ArrowDown\n style={{color: black}}\n className={classnames(style.arrow, {[style.down]: isActive})}\n />\n )}\n </div>\n <div className={classnames(style.choices, isActive && style.activeChoices)}>\n <ul className={style.list}>{lines}</ul>\n </div>\n </label>\n {!isCMTheme ? <div className={style.description}>{description}</div> : null}\n {hintView}\n </div>\n );\n};\n\nSelectMultiple.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nCMMultipleView.propTypes = {\n multiple: PropTypes.bool,\n choice: TitledCheckbox.propTypes.choice,\n onChange: PropTypes.func\n};\n\nSelectMultiple.propTypes = {\n title: PropTypes.string,\n placeholder: PropTypes.string,\n description: PropTypes.string,\n hint: PropTypes.string,\n options: PropTypes.arrayOf(TitledCheckbox.propTypes.choice),\n onChange: PropTypes.func,\n onError: PropTypes.func,\n multiple: PropTypes.bool,\n modified: PropTypes.bool,\n disabled: PropTypes.bool,\n error: PropTypes.string,\n theme: PropTypes.oneOf(keys(themeStyle))\n};\n\nexport default SelectMultiple;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAP,IAAeC,QAAf,EAAyBC,SAAzB,EAAoCC,MAApC,EAA4CC,WAA5C,QAA8D,OAA9D;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,SACEC,kCAAkC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
|
|
63
63
|
required: PropTypes.Requireable<boolean>;
|
|
64
64
|
modified: PropTypes.Requireable<boolean>;
|
|
65
65
|
error: PropTypes.Requireable<boolean>;
|
|
66
|
+
errorMessage: PropTypes.Requireable<string>;
|
|
66
67
|
suggestions: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
67
68
|
name: PropTypes.Requireable<string>;
|
|
68
69
|
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
69
70
|
}> | null | undefined)[]>;
|
|
70
|
-
|
|
71
|
+
theme: PropTypes.Requireable<string>;
|
|
72
|
+
onInput: PropTypes.Requireable<(...args: any[]) => any>;
|
|
71
73
|
onFetch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
72
74
|
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
73
75
|
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -510,6 +512,7 @@ declare namespace BrandForm {
|
|
|
510
512
|
}>>;
|
|
511
513
|
export { tooltip_1 as tooltip };
|
|
512
514
|
export const isLoading: PropTypes.Requireable<boolean>;
|
|
515
|
+
export const theme: PropTypes.Requireable<string>;
|
|
513
516
|
}
|
|
514
517
|
}
|
|
515
518
|
import PropTypes from "prop-types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/organism/brand-form/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/organism/brand-form/index.js"],"names":[],"mappings":";AA6DA,kEA+EC"}
|
|
@@ -5,11 +5,12 @@ import { NovaCompositionNavigationArrowLeft as ArrowLeft } from '@coorpacademy/n
|
|
|
5
5
|
import BrandFormGroup from '../../molecule/brand-form-group';
|
|
6
6
|
import Provider from '../../atom/provider';
|
|
7
7
|
import Button from '../../atom/button';
|
|
8
|
+
import ButtonLink from '../../atom/button-link';
|
|
8
9
|
import Link from '../../atom/link';
|
|
9
10
|
import Loader from '../../atom/loader';
|
|
10
11
|
import style from './style.css';
|
|
11
12
|
|
|
12
|
-
const buildButtonSection = (onSubmit, submitValue, onReset, resetValue, tooltip, disabled, isModified, isPending, darkColor) => {
|
|
13
|
+
const buildButtonSection = (onSubmit, submitValue, onReset, resetValue, tooltip, disabled, isModified, isPending, darkColor, theme) => {
|
|
13
14
|
if (!onSubmit && !onReset) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
@@ -19,7 +20,14 @@ const buildButtonSection = (onSubmit, submitValue, onReset, resetValue, tooltip,
|
|
|
19
20
|
"data-tip": tooltip.title,
|
|
20
21
|
"data-for": "submitButton",
|
|
21
22
|
className: style.saveButton
|
|
22
|
-
}, /*#__PURE__*/React.createElement(
|
|
23
|
+
}, theme === 'coorpmanager' ? /*#__PURE__*/React.createElement(ButtonLink, {
|
|
24
|
+
type: "primary",
|
|
25
|
+
label: submitValue,
|
|
26
|
+
disabled: disabledSubmit,
|
|
27
|
+
"data-testid": "submit-button",
|
|
28
|
+
buttonType: "submit",
|
|
29
|
+
onClick: onSubmit
|
|
30
|
+
}) : /*#__PURE__*/React.createElement(Button, {
|
|
23
31
|
type: "submit",
|
|
24
32
|
disabled: disabledSubmit,
|
|
25
33
|
submitValue: submitValue
|
|
@@ -39,7 +47,7 @@ const buildButtonSection = (onSubmit, submitValue, onReset, resetValue, tooltip,
|
|
|
39
47
|
}, submitButton, resetButton);
|
|
40
48
|
};
|
|
41
49
|
|
|
42
|
-
|
|
50
|
+
const BrandForm = (props, context) => {
|
|
43
51
|
const {
|
|
44
52
|
groups,
|
|
45
53
|
disabled,
|
|
@@ -51,7 +59,8 @@ function BrandForm(props, context) {
|
|
|
51
59
|
resetValue,
|
|
52
60
|
back,
|
|
53
61
|
tooltip,
|
|
54
|
-
isLoading
|
|
62
|
+
isLoading,
|
|
63
|
+
theme
|
|
55
64
|
} = props;
|
|
56
65
|
const {
|
|
57
66
|
skin
|
|
@@ -76,7 +85,7 @@ function BrandForm(props, context) {
|
|
|
76
85
|
key: index
|
|
77
86
|
}, /*#__PURE__*/React.createElement(BrandFormGroup, group));
|
|
78
87
|
});
|
|
79
|
-
const buttonSection = buildButtonSection(onSubmit, submitValue, onReset, resetValue, tooltip, disabled, isModified, isPending, darkColor);
|
|
88
|
+
const buttonSection = buildButtonSection(onSubmit, submitValue, onReset, resetValue, tooltip, disabled, isModified, isPending, darkColor, theme);
|
|
80
89
|
const handleSubmit = useMemo(() => e => {
|
|
81
90
|
e.preventDefault();
|
|
82
91
|
return onSubmit(e);
|
|
@@ -95,7 +104,7 @@ function BrandForm(props, context) {
|
|
|
95
104
|
onReset: handleReset,
|
|
96
105
|
className: style.form
|
|
97
106
|
}, brandGroups, buttonSection));
|
|
98
|
-
}
|
|
107
|
+
};
|
|
99
108
|
|
|
100
109
|
BrandForm.contextTypes = {
|
|
101
110
|
skin: Provider.childContextTypes.skin
|
|
@@ -123,7 +132,8 @@ BrandForm.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
123
132
|
title: PropTypes.string,
|
|
124
133
|
place: PropTypes.string
|
|
125
134
|
}),
|
|
126
|
-
isLoading: PropTypes.bool
|
|
135
|
+
isLoading: PropTypes.bool,
|
|
136
|
+
theme: PropTypes.string
|
|
127
137
|
} : {};
|
|
128
138
|
export default BrandForm;
|
|
129
139
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","NovaCompositionNavigationArrowLeft","ArrowLeft","BrandFormGroup","Provider","Button","Link","Loader","style","buildButtonSection","onSubmit","submitValue","onReset","resetValue","tooltip","disabled","isModified","isPending","darkColor","disabledSubmit","submitButton","title","saveButton","cancelBackground","backgroundColor","resetButton","buttons","BrandForm","props","context","groups","back","isLoading","skin","backView","color","arrowBack","link","backDesc","desc","brandGroups","map","group","index","buttonSection","handleSubmit","e","preventDefault","handleReset","loaderContainer","loader","form","contextTypes","childContextTypes","defaultProps","place","propTypes","arrayOf","shape","isRequired","bool","func","children","href","string"],"sources":["../../../src/organism/brand-form/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {get} from 'lodash/fp';\nimport {NovaCompositionNavigationArrowLeft as ArrowLeft} from '@coorpacademy/nova-icons';\nimport BrandFormGroup from '../../molecule/brand-form-group';\nimport Provider from '../../atom/provider';\nimport Button from '../../atom/button';\nimport Link from '../../atom/link';\nimport Loader from '../../atom/loader';\nimport style from './style.css';\n\nconst buildButtonSection = (\n onSubmit,\n submitValue,\n onReset,\n resetValue,\n tooltip,\n disabled,\n isModified,\n isPending,\n darkColor\n) => {\n if (!onSubmit && !onReset) {\n return null;\n }\n\n const disabledSubmit = disabled || isPending || !isModified;\n const submitButton = onSubmit ? (\n <div data-tip={tooltip.title} data-for=\"submitButton\" className={style.saveButton}>\n <Button type=\"submit\" disabled={disabledSubmit} submitValue={submitValue} />\n </div>\n ) : null;\n\n const cancelBackground = {backgroundColor: darkColor};\n\n const resetButton = onReset ? (\n <div className={style.resetButton}>\n <Button type=\"reset\" submitValue={resetValue} style={cancelBackground} />\n </div>\n ) : null;\n\n return (\n <div className={style.buttons}>\n {submitButton}\n {resetButton}\n </div>\n );\n};\
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useMemo","PropTypes","NovaCompositionNavigationArrowLeft","ArrowLeft","BrandFormGroup","Provider","Button","ButtonLink","Link","Loader","style","buildButtonSection","onSubmit","submitValue","onReset","resetValue","tooltip","disabled","isModified","isPending","darkColor","theme","disabledSubmit","submitButton","title","saveButton","cancelBackground","backgroundColor","resetButton","buttons","BrandForm","props","context","groups","back","isLoading","skin","backView","color","arrowBack","link","backDesc","desc","brandGroups","map","group","index","buttonSection","handleSubmit","e","preventDefault","handleReset","loaderContainer","loader","form","contextTypes","childContextTypes","defaultProps","place","propTypes","arrayOf","shape","isRequired","bool","func","children","href","string"],"sources":["../../../src/organism/brand-form/index.js"],"sourcesContent":["import React, {useMemo} from 'react';\nimport PropTypes from 'prop-types';\nimport {get} from 'lodash/fp';\nimport {NovaCompositionNavigationArrowLeft as ArrowLeft} from '@coorpacademy/nova-icons';\nimport BrandFormGroup from '../../molecule/brand-form-group';\nimport Provider from '../../atom/provider';\nimport Button from '../../atom/button';\nimport ButtonLink from '../../atom/button-link';\nimport Link from '../../atom/link';\nimport Loader from '../../atom/loader';\nimport style from './style.css';\n\nconst buildButtonSection = (\n onSubmit,\n submitValue,\n onReset,\n resetValue,\n tooltip,\n disabled,\n isModified,\n isPending,\n darkColor,\n theme\n) => {\n if (!onSubmit && !onReset) {\n return null;\n }\n\n const disabledSubmit = disabled || isPending || !isModified;\n const submitButton = onSubmit ? (\n <div data-tip={tooltip.title} data-for=\"submitButton\" className={style.saveButton}>\n {theme === 'coorpmanager' ? (\n <ButtonLink\n type=\"primary\"\n label={submitValue}\n disabled={disabledSubmit}\n data-testid=\"submit-button\"\n buttonType=\"submit\"\n onClick={onSubmit}\n />\n ) : (\n <Button type=\"submit\" disabled={disabledSubmit} submitValue={submitValue} />\n )}\n </div>\n ) : null;\n\n const cancelBackground = {backgroundColor: darkColor};\n\n const resetButton = onReset ? (\n <div className={style.resetButton}>\n <Button type=\"reset\" submitValue={resetValue} style={cancelBackground} />\n </div>\n ) : null;\n\n return (\n <div className={style.buttons}>\n {submitButton}\n {resetButton}\n </div>\n );\n};\nconst BrandForm = (props, context) => {\n const {\n groups,\n disabled,\n isModified,\n isPending,\n onSubmit,\n submitValue,\n onReset,\n resetValue,\n back,\n tooltip,\n isLoading,\n theme\n } = props;\n const {skin} = context;\n const darkColor = get('common.dark', skin);\n\n const backView = back ? (\n <p className={style.back}>\n <ArrowLeft style={{color: darkColor}} className={style.arrowBack} />\n <Link href={back.link} className={style.backDesc}>\n {back.desc}\n </Link>\n </p>\n ) : null;\n\n const brandGroups = groups.map((group, index) => {\n return (\n <div className={style.group} key={index}>\n <BrandFormGroup {...group} />\n </div>\n );\n });\n\n const buttonSection = buildButtonSection(\n onSubmit,\n submitValue,\n onReset,\n resetValue,\n tooltip,\n disabled,\n isModified,\n isPending,\n darkColor,\n theme\n );\n\n const handleSubmit = useMemo(\n () => e => {\n e.preventDefault();\n return onSubmit(e);\n },\n [onSubmit]\n );\n\n const handleReset = useMemo(\n () => e => {\n e.preventDefault();\n return onReset(e);\n },\n [onReset]\n );\n\n return (\n <div>\n {backView}\n {isLoading ? (\n <div className={style.loaderContainer}>\n <Loader className={style.loader} theme=\"coorpmanager\" />\n </div>\n ) : (\n <form onSubmit={handleSubmit} onReset={handleReset} className={style.form}>\n {brandGroups}\n {buttonSection}\n </form>\n )}\n </div>\n );\n};\n\nBrandForm.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nBrandForm.defaultProps = {\n tooltip: {\n title: '',\n place: 'top'\n }\n};\n\nBrandForm.propTypes = {\n groups: PropTypes.arrayOf(PropTypes.shape(BrandFormGroup.propTypes)).isRequired,\n disabled: PropTypes.bool,\n isModified: PropTypes.bool,\n isPending: PropTypes.bool,\n onSubmit: PropTypes.func,\n submitValue: Button.propTypes.submitValue,\n onReset: PropTypes.func,\n resetValue: Button.propTypes.submitValue,\n back: PropTypes.shape({\n desc: Link.propTypes.children,\n link: Link.propTypes.href\n }),\n tooltip: PropTypes.shape({\n title: PropTypes.string,\n place: PropTypes.string\n }),\n isLoading: PropTypes.bool,\n theme: PropTypes.string\n};\n\nexport default BrandForm;\n"],"mappings":";AAAA,OAAOA,KAAP,IAAeC,OAAf,QAA6B,OAA7B;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,SAAQC,kCAAkC,IAAIC,SAA9C,QAA8D,0BAA9D;AACA,OAAOC,cAAP,MAA2B,iCAA3B;AACA,OAAOC,QAAP,MAAqB,qBAArB;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,OAAOC,UAAP,MAAuB,wBAAvB;AACA,OAAOC,IAAP,MAAiB,iBAAjB;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,kBAA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I,CAACmD,SAAL,CAAeM,QADD;IAEpBzB,IAAI,EAAEhC,IAAI,CAACmD,SAAL,CAAeO;EAFD,CAAhB,CATc;EAapBlD,OAAO,EAAEf,SAAS,CAAC4D,KAAV,CAAgB;IACvBrC,KAAK,EAAEvB,SAAS,CAACkE,MADM;IAEvBT,KAAK,EAAEzD,SAAS,CAACkE;EAFM,CAAhB,CAbW;EAiBpBhC,SAAS,EAAElC,SAAS,CAAC8D,IAjBD;EAkBpB1C,KAAK,EAAEpB,SAAS,CAACkE;AAlBG,CAAtB;AAqBA,eAAerC,SAAf"}
|
|
@@ -25,7 +25,9 @@ const Settings = (props, legacyContext) => {
|
|
|
25
25
|
|
|
26
26
|
return /*#__PURE__*/React.createElement("div", {
|
|
27
27
|
className: style.settings
|
|
28
|
-
}, /*#__PURE__*/React.createElement(InputSwitch,
|
|
28
|
+
}, /*#__PURE__*/React.createElement(InputSwitch, _extends({}, settings, {
|
|
29
|
+
'aria-label': label
|
|
30
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
29
31
|
className: style.label,
|
|
30
32
|
tabIndex: 0
|
|
31
33
|
}, label), isEmpty(description) ? null : /*#__PURE__*/React.createElement(ToolTip, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PropTypes","isEmpty","map","Provider","GetTranslateFromContext","ToolTip","InputSwitch","style","Settings","props","legacyContext","translate","label","description","moreInfoAriaLabel","settings","infoIconTooltip","propTypes","string","isRequired","contextTypes","childContextTypes","UserPreferences","preferences","groupAriaLabel","arrayOf","shape"],"sources":["../../../src/organism/user-preferences/index.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isEmpty from 'lodash/fp/isEmpty';\nimport map from 'lodash/fp/map';\nimport Provider, {GetTranslateFromContext} from '../../atom/provider';\nimport ToolTip from '../../atom/tooltip';\nimport InputSwitch from '../../atom/input-switch';\nimport style from './style.css';\n\nconst Settings = (props, legacyContext) => {\n const translate = GetTranslateFromContext(legacyContext);\n const {label, description, moreInfoAriaLabel, ...settings} = props;\n return (\n <div className={style.settings}>\n <InputSwitch {...settings} />\n <span className={style.label} tabIndex={0}>\n {label}\n </span>\n {isEmpty(description) ? null : (\n <ToolTip\n TooltipContent={description}\n closeToolTipInformationTextAriaLabel={translate(\n 'Press the escape key to close the information text'\n )}\n data-testid=\"user-preferences-tooltip\"\n aria-label={moreInfoAriaLabel}\n iconContainerClassName={style.infoIconTooltip}\n fontSize={12}\n />\n )}\n </div>\n );\n};\n\nSettings.propTypes = {\n ...InputSwitch.propTypes,\n label: PropTypes.string.isRequired,\n description: PropTypes.string\n};\n\nSettings.contextTypes = {\n translate: Provider.childContextTypes.translate\n};\n\nconst UserPreferences = props => {\n const {preferences, moreInfoAriaLabel, groupAriaLabel} = props;\n\n return (\n <form>\n <div className={style.preferences} role=\"group\" aria-label={groupAriaLabel} tabIndex={0}>\n {map(\n settings => (\n <Settings {...settings} key={settings.label} moreInfoAriaLabel={moreInfoAriaLabel} />\n ),\n preferences\n )}\n </div>\n </form>\n );\n};\n\nUserPreferences.propTypes = {\n preferences: PropTypes.arrayOf(PropTypes.shape(Settings.propTypes)),\n moreInfoAriaLabel: PropTypes.string,\n groupAriaLabel: PropTypes.string\n};\n\nexport default UserPreferences;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,OAAP,MAAoB,mBAApB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,QAAP,IAAkBC,uBAAlB,QAAgD,qBAAhD;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,QAAQ,GAAG,CAACC,KAAD,EAAQC,aAAR,KAA0B;EACzC,MAAMC,SAAS,GAAGP,uBAAuB,CAACM,aAAD,CAAzC;;EACA,MAAM;IAACE,KAAD;IAAQC,WAAR;IAAqBC;EAArB,IAAuDL,KAA7D;EAAA,MAAiDM,QAAjD,iCAA6DN,KAA7D;;EACA,oBACE;IAAK,SAAS,EAAEF,KAAK,CAACQ;EAAtB,gBACE,oBAAC,WAAD,
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","isEmpty","map","Provider","GetTranslateFromContext","ToolTip","InputSwitch","style","Settings","props","legacyContext","translate","label","description","moreInfoAriaLabel","settings","infoIconTooltip","propTypes","string","isRequired","contextTypes","childContextTypes","UserPreferences","preferences","groupAriaLabel","arrayOf","shape"],"sources":["../../../src/organism/user-preferences/index.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isEmpty from 'lodash/fp/isEmpty';\nimport map from 'lodash/fp/map';\nimport Provider, {GetTranslateFromContext} from '../../atom/provider';\nimport ToolTip from '../../atom/tooltip';\nimport InputSwitch from '../../atom/input-switch';\nimport style from './style.css';\n\nconst Settings = (props, legacyContext) => {\n const translate = GetTranslateFromContext(legacyContext);\n const {label, description, moreInfoAriaLabel, ...settings} = props;\n return (\n <div className={style.settings}>\n <InputSwitch {...{...settings, 'aria-label': label}} />\n <span className={style.label} tabIndex={0}>\n {label}\n </span>\n {isEmpty(description) ? null : (\n <ToolTip\n TooltipContent={description}\n closeToolTipInformationTextAriaLabel={translate(\n 'Press the escape key to close the information text'\n )}\n data-testid=\"user-preferences-tooltip\"\n aria-label={moreInfoAriaLabel}\n iconContainerClassName={style.infoIconTooltip}\n fontSize={12}\n />\n )}\n </div>\n );\n};\n\nSettings.propTypes = {\n ...InputSwitch.propTypes,\n label: PropTypes.string.isRequired,\n description: PropTypes.string\n};\n\nSettings.contextTypes = {\n translate: Provider.childContextTypes.translate\n};\n\nconst UserPreferences = props => {\n const {preferences, moreInfoAriaLabel, groupAriaLabel} = props;\n\n return (\n <form>\n <div className={style.preferences} role=\"group\" aria-label={groupAriaLabel} tabIndex={0}>\n {map(\n settings => (\n <Settings {...settings} key={settings.label} moreInfoAriaLabel={moreInfoAriaLabel} />\n ),\n preferences\n )}\n </div>\n </form>\n );\n};\n\nUserPreferences.propTypes = {\n preferences: PropTypes.arrayOf(PropTypes.shape(Settings.propTypes)),\n moreInfoAriaLabel: PropTypes.string,\n groupAriaLabel: PropTypes.string\n};\n\nexport default UserPreferences;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,OAAP,MAAoB,mBAApB;AACA,OAAOC,GAAP,MAAgB,eAAhB;AACA,OAAOC,QAAP,IAAkBC,uBAAlB,QAAgD,qBAAhD;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,QAAQ,GAAG,CAACC,KAAD,EAAQC,aAAR,KAA0B;EACzC,MAAMC,SAAS,GAAGP,uBAAuB,CAACM,aAAD,CAAzC;;EACA,MAAM;IAACE,KAAD;IAAQC,WAAR;IAAqBC;EAArB,IAAuDL,KAA7D;EAAA,MAAiDM,QAAjD,iCAA6DN,KAA7D;;EACA,oBACE;IAAK,SAAS,EAAEF,KAAK,CAACQ;EAAtB,gBACE,oBAAC,WAAD,eAAqBA,QAArB;IAA+B,cAAcH;EAA7C,GADF,eAEE;IAAM,SAAS,EAAEL,KAAK,CAACK,KAAvB;IAA8B,QAAQ,EAAE;EAAxC,GACGA,KADH,CAFF,EAKGX,OAAO,CAACY,WAAD,CAAP,GAAuB,IAAvB,gBACC,oBAAC,OAAD;IACE,cAAc,EAAEA,WADlB;IAEE,oCAAoC,EAAEF,SAAS,CAC7C,oDAD6C,CAFjD;IAKE,eAAY,0BALd;IAME,cAAYG,iBANd;IAOE,sBAAsB,EAAEP,KAAK,CAACS,eAPhC;IAQE,QAAQ,EAAE;EARZ,EANJ,CADF;AAoBD,CAvBD;;AAyBAR,QAAQ,CAACS,SAAT,wDACKX,WAAW,CAACW,SADjB;EAEEL,KAAK,EAAEZ,SAAS,CAACkB,MAAV,CAAiBC,UAF1B;EAGEN,WAAW,EAAEb,SAAS,CAACkB;AAHzB;AAMAV,QAAQ,CAACY,YAAT,GAAwB;EACtBT,SAAS,EAAER,QAAQ,CAACkB,iBAAT,CAA2BV;AADhB,CAAxB;;AAIA,MAAMW,eAAe,GAAGb,KAAK,IAAI;EAC/B,MAAM;IAACc,WAAD;IAAcT,iBAAd;IAAiCU;EAAjC,IAAmDf,KAAzD;EAEA,oBACE,+CACE;IAAK,SAAS,EAAEF,KAAK,CAACgB,WAAtB;IAAmC,IAAI,EAAC,OAAxC;IAAgD,cAAYC,cAA5D;IAA4E,QAAQ,EAAE;EAAtF,GACGtB,GAAG,CACFa,QAAQ,iBACN,oBAAC,QAAD,eAAcA,QAAd;IAAwB,GAAG,EAAEA,QAAQ,CAACH,KAAtC;IAA6C,iBAAiB,EAAEE;EAAhE,GAFA,EAIFS,WAJE,CADN,CADF,CADF;AAYD,CAfD;;AAiBAD,eAAe,CAACL,SAAhB,2CAA4B;EAC1BM,WAAW,EAAEvB,SAAS,CAACyB,OAAV,CAAkBzB,SAAS,CAAC0B,KAAV,CAAgBlB,QAAQ,CAACS,SAAzB,CAAlB,CADa;EAE1BH,iBAAiB,EAAEd,SAAS,CAACkB,MAFH;EAG1BM,cAAc,EAAExB,SAAS,CAACkB;AAHA,CAA5B;AAMA,eAAeI,eAAf"}
|
|
@@ -80,11 +80,13 @@ declare namespace WizardContents {
|
|
|
80
80
|
required: PropTypes.Requireable<boolean>;
|
|
81
81
|
modified: PropTypes.Requireable<boolean>;
|
|
82
82
|
error: PropTypes.Requireable<boolean>;
|
|
83
|
+
errorMessage: PropTypes.Requireable<string>;
|
|
83
84
|
suggestions: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
84
85
|
name: PropTypes.Requireable<string>;
|
|
85
86
|
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
86
87
|
}> | null | undefined)[]>;
|
|
87
|
-
|
|
88
|
+
theme: PropTypes.Requireable<string>;
|
|
89
|
+
onInput: PropTypes.Requireable<(...args: any[]) => any>;
|
|
88
90
|
onFetch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
89
91
|
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
90
92
|
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -526,6 +528,7 @@ declare namespace WizardContents {
|
|
|
526
528
|
place: PropTypes.Requireable<string>;
|
|
527
529
|
}>>;
|
|
528
530
|
isLoading: PropTypes.Requireable<boolean>;
|
|
531
|
+
theme: PropTypes.Requireable<string>;
|
|
529
532
|
}> | PropTypes.InferProps<{
|
|
530
533
|
type: PropTypes.Requireable<string>;
|
|
531
534
|
languageTabs: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
@@ -165,11 +165,13 @@ declare namespace BrandUpdate {
|
|
|
165
165
|
required: PropTypes.Requireable<boolean>;
|
|
166
166
|
modified: PropTypes.Requireable<boolean>;
|
|
167
167
|
error: PropTypes.Requireable<boolean>;
|
|
168
|
+
errorMessage: PropTypes.Requireable<string>;
|
|
168
169
|
suggestions: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
169
170
|
name: PropTypes.Requireable<string>;
|
|
170
171
|
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
171
172
|
}> | null | undefined)[]>;
|
|
172
|
-
|
|
173
|
+
theme: PropTypes.Requireable<string>;
|
|
174
|
+
onInput: PropTypes.Requireable<(...args: any[]) => any>;
|
|
173
175
|
onFetch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
174
176
|
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
175
177
|
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -611,6 +613,7 @@ declare namespace BrandUpdate {
|
|
|
611
613
|
place: PropTypes.Requireable<string>;
|
|
612
614
|
}>>;
|
|
613
615
|
isLoading: PropTypes.Requireable<boolean>;
|
|
616
|
+
theme: PropTypes.Requireable<string>;
|
|
614
617
|
}> | PropTypes.InferProps<{
|
|
615
618
|
key: PropTypes.Requireable<string>;
|
|
616
619
|
type: PropTypes.Requireable<string>;
|
|
@@ -9,11 +9,13 @@ declare namespace Autocomplete {
|
|
|
9
9
|
const required: PropTypes.Requireable<boolean>;
|
|
10
10
|
const modified: PropTypes.Requireable<boolean>;
|
|
11
11
|
const error: PropTypes.Requireable<boolean>;
|
|
12
|
+
const errorMessage: PropTypes.Requireable<string>;
|
|
12
13
|
const suggestions: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
13
14
|
name: PropTypes.Requireable<string>;
|
|
14
15
|
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
15
16
|
}> | null | undefined)[]>;
|
|
16
|
-
const
|
|
17
|
+
const theme: PropTypes.Requireable<string>;
|
|
18
|
+
const onInput: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
19
|
const onFetch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
20
|
const onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
21
|
const onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/autocomplete/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/autocomplete/index.js"],"names":[],"mappings":";AAmBA,uDA8GC"}
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
|
|
6
|
+
var _keys2 = _interopRequireDefault(require("lodash/fp/keys"));
|
|
7
|
+
|
|
8
|
+
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
|
|
9
|
+
|
|
6
10
|
var _isNil2 = _interopRequireDefault(require("lodash/fp/isNil"));
|
|
7
11
|
|
|
8
12
|
var _noop2 = _interopRequireDefault(require("lodash/fp/noop"));
|
|
@@ -15,6 +19,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
19
|
|
|
16
20
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
21
|
|
|
22
|
+
var _novaIcons = require("@coorpacademy/nova-icons");
|
|
23
|
+
|
|
18
24
|
var _getClassState = _interopRequireDefault(require("../../util/get-class-state"));
|
|
19
25
|
|
|
20
26
|
var _style = _interopRequireDefault(require("./style.css"));
|
|
@@ -25,6 +31,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
25
31
|
|
|
26
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
33
|
|
|
34
|
+
const THEME_STYLE = {
|
|
35
|
+
coorpmanager: _style.default.coorpmanager,
|
|
36
|
+
default: _style.default.default
|
|
37
|
+
};
|
|
38
|
+
|
|
28
39
|
const renderSuggestion = suggestion => /*#__PURE__*/_react.default.createElement("span", null, suggestion.name);
|
|
29
40
|
|
|
30
41
|
const Autocomplete = props => {
|
|
@@ -35,32 +46,61 @@ const Autocomplete = props => {
|
|
|
35
46
|
required,
|
|
36
47
|
modified = false,
|
|
37
48
|
error = false,
|
|
49
|
+
errorMessage,
|
|
38
50
|
suggestions = [],
|
|
39
|
-
|
|
51
|
+
onInput = _noop2.default,
|
|
40
52
|
onFetch = _noop2.default,
|
|
41
53
|
onClear = _noop2.default,
|
|
42
54
|
onBlur = _noop2.default,
|
|
43
55
|
onSuggestionSelected = _noop2.default,
|
|
44
|
-
title: propsTitle
|
|
56
|
+
title: propsTitle,
|
|
57
|
+
theme = 'default'
|
|
45
58
|
} = props;
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
59
|
+
const mainClass = THEME_STYLE[theme];
|
|
60
|
+
const title = (0, _react.useMemo)(() => `${propsTitle}${required ? '*' : ''}`, [propsTitle, required]);
|
|
61
|
+
const className = (0, _react.useMemo)(() => (0, _getClassState.default)(_style.default.default, _style.default.modified, _style.default.error, modified, error), [modified, error]);
|
|
62
|
+
const handleInput = (0, _react.useCallback)(e => {
|
|
63
|
+
onInput(e);
|
|
64
|
+
}, [onInput]);
|
|
65
|
+
const handleBlur = (0, _react.useCallback)((e, selectedSuggestion) => onBlur(e, selectedSuggestion), [onBlur]);
|
|
66
|
+
const handleSuggestionsFetchRequested = (0, _react.useCallback)(e => onFetch(e), [onFetch]);
|
|
67
|
+
const handleSuggestionsClearRequested = (0, _react.useCallback)(e => onClear(e), [onClear]);
|
|
68
|
+
const handleSuggestionsSelected = (0, _react.useCallback)((e, data) => onSuggestionSelected(data), [onSuggestionSelected]);
|
|
53
69
|
const inputProps = {
|
|
54
70
|
placeholder,
|
|
55
71
|
value,
|
|
56
|
-
onChange:
|
|
57
|
-
onBlur: handleBlur
|
|
72
|
+
onChange: _noop2.default,
|
|
73
|
+
onBlur: handleBlur,
|
|
74
|
+
onInput: handleInput,
|
|
75
|
+
'data-testid': 'autocomplete-input'
|
|
58
76
|
};
|
|
77
|
+
const descriptionView = description && theme !== 'coorpmanager' ? /*#__PURE__*/_react.default.createElement("div", {
|
|
78
|
+
className: _style.default.description
|
|
79
|
+
}, description) : null;
|
|
80
|
+
const toolTipView = description && theme === 'coorpmanager' ? /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
+
className: _style.default.infoIconWrapper
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyInformationIcon, {
|
|
83
|
+
className: _style.default.infoIcon
|
|
84
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
85
|
+
className: _style.default.descriptionLabel
|
|
86
|
+
}, description)) : null;
|
|
87
|
+
const errorIconView = theme === 'coorpmanager' && error ? /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidStatusClose, {
|
|
88
|
+
className: _style.default.leftIcon
|
|
89
|
+
}) : null;
|
|
90
|
+
const errorText = theme === 'coorpmanager' && error ? /*#__PURE__*/_react.default.createElement("div", {
|
|
91
|
+
className: _style.default.errorText // eslint-disable-next-line react/no-danger
|
|
92
|
+
,
|
|
93
|
+
dangerouslySetInnerHTML: {
|
|
94
|
+
__html: errorMessage
|
|
95
|
+
}
|
|
96
|
+
}) : null;
|
|
59
97
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
60
|
-
className: (0, _classnames.default)(className, (0, _isNil2.default)(
|
|
98
|
+
className: (0, _classnames.default)(mainClass, className, (0, _isNil2.default)(propsTitle) && _style.default.isNoTitle)
|
|
61
99
|
}, /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("span", {
|
|
62
|
-
className: _style.default.title
|
|
63
|
-
}, title), /*#__PURE__*/_react.default.createElement("div",
|
|
100
|
+
className: (0, _classnames.default)(_style.default.title, (0, _isEmpty2.default)(value) && _style.default.noValue)
|
|
101
|
+
}, title, toolTipView), /*#__PURE__*/_react.default.createElement("div", {
|
|
102
|
+
className: _style.default.inputContainer
|
|
103
|
+
}, /*#__PURE__*/_react.default.createElement(_reactAutosuggest.default, {
|
|
64
104
|
theme: {
|
|
65
105
|
container: _style.default.container,
|
|
66
106
|
input: _style.default.input,
|
|
@@ -78,9 +118,7 @@ const Autocomplete = props => {
|
|
|
78
118
|
inputProps: inputProps,
|
|
79
119
|
focusInputOnSuggestionClick: false,
|
|
80
120
|
onSuggestionSelected: handleSuggestionsSelected
|
|
81
|
-
}))),
|
|
82
|
-
className: _style.default.description
|
|
83
|
-
}, description));
|
|
121
|
+
}), errorIconView, errorText)), descriptionView);
|
|
84
122
|
};
|
|
85
123
|
|
|
86
124
|
Autocomplete.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
@@ -91,11 +129,13 @@ Autocomplete.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
91
129
|
required: _propTypes.default.bool,
|
|
92
130
|
modified: _propTypes.default.bool,
|
|
93
131
|
error: _propTypes.default.bool,
|
|
132
|
+
errorMessage: _propTypes.default.string,
|
|
94
133
|
suggestions: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
95
134
|
name: _propTypes.default.string,
|
|
96
135
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
|
|
97
136
|
})),
|
|
98
|
-
|
|
137
|
+
theme: _propTypes.default.oneOf((0, _keys2.default)(THEME_STYLE)),
|
|
138
|
+
onInput: _propTypes.default.func,
|
|
99
139
|
onFetch: _propTypes.default.func,
|
|
100
140
|
onClear: _propTypes.default.func,
|
|
101
141
|
onBlur: _propTypes.default.func,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["renderSuggestion","suggestion","name","Autocomplete","props","placeholder","value","description","required","modified","error","suggestions","
|
|
1
|
+
{"version":3,"file":"index.js","names":["THEME_STYLE","coorpmanager","style","default","renderSuggestion","suggestion","name","Autocomplete","props","placeholder","value","description","required","modified","error","errorMessage","suggestions","onInput","onFetch","onClear","onBlur","onSuggestionSelected","title","propsTitle","theme","mainClass","useMemo","className","getClassState","handleInput","useCallback","e","handleBlur","selectedSuggestion","handleSuggestionsFetchRequested","handleSuggestionsClearRequested","handleSuggestionsSelected","data","inputProps","onChange","descriptionView","toolTipView","infoIconWrapper","infoIcon","descriptionLabel","errorIconView","leftIcon","errorText","__html","classnames","isNoTitle","noValue","inputContainer","container","input","suggestionsContainer","suggestionsContainerOpen","suggestionsList","suggestionHighlighted","propTypes","PropTypes","string","bool","arrayOf","shape","oneOfType","number","oneOf","func"],"sources":["../../../src/atom/autocomplete/index.js"],"sourcesContent":["import React, {useCallback, useMemo} from 'react';\nimport Autosuggest from 'react-autosuggest';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport {noop, isNil, isEmpty, keys} from 'lodash/fp';\nimport {\n NovaSolidStatusClose as ErrorIcon,\n NovaCompositionCoorpacademyInformationIcon as InfoIcon\n} from '@coorpacademy/nova-icons';\nimport getClassState from '../../util/get-class-state';\nimport style from './style.css';\n\nconst THEME_STYLE = {\n coorpmanager: style.coorpmanager,\n default: style.default\n};\n\nconst renderSuggestion = suggestion => <span>{suggestion.name}</span>;\n\nconst Autocomplete = props => {\n const {\n placeholder = '',\n value,\n description,\n required,\n modified = false,\n error = false,\n errorMessage,\n suggestions = [],\n onInput = noop,\n onFetch = noop,\n onClear = noop,\n onBlur = noop,\n onSuggestionSelected = noop,\n title: propsTitle,\n theme = 'default'\n } = props;\n\n const mainClass = THEME_STYLE[theme];\n const title = useMemo(() => `${propsTitle}${required ? '*' : ''}`, [propsTitle, required]);\n const className = useMemo(\n () => getClassState(style.default, style.modified, style.error, modified, error),\n [modified, error]\n );\n\n const handleInput = useCallback(\n e => {\n onInput(e);\n },\n [onInput]\n );\n const handleBlur = useCallback(\n (e, selectedSuggestion) => onBlur(e, selectedSuggestion),\n [onBlur]\n );\n const handleSuggestionsFetchRequested = useCallback(e => onFetch(e), [onFetch]);\n const handleSuggestionsClearRequested = useCallback(e => onClear(e), [onClear]);\n const handleSuggestionsSelected = useCallback(\n (e, data) => onSuggestionSelected(data),\n [onSuggestionSelected]\n );\n\n const inputProps = {\n placeholder,\n value,\n onChange: noop,\n onBlur: handleBlur,\n onInput: handleInput,\n 'data-testid': 'autocomplete-input'\n };\n\n const descriptionView =\n description && theme !== 'coorpmanager' ? (\n <div className={style.description}>{description}</div>\n ) : null;\n\n const toolTipView =\n description && theme === 'coorpmanager' ? (\n <div className={style.infoIconWrapper}>\n <InfoIcon className={style.infoIcon} />\n <div className={style.descriptionLabel}>{description}</div>\n </div>\n ) : null;\n\n const errorIconView =\n theme === 'coorpmanager' && error ? <ErrorIcon className={style.leftIcon} /> : null;\n\n const errorText =\n theme === 'coorpmanager' && error ? (\n <div\n className={style.errorText}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: errorMessage}}\n />\n ) : null;\n return (\n <div className={classnames(mainClass, className, isNil(propsTitle) && style.isNoTitle)}>\n <label>\n <span className={classnames(style.title, isEmpty(value) && style.noValue)}>\n {title}\n {toolTipView}\n </span>\n <div className={style.inputContainer}>\n <Autosuggest\n theme={{\n container: style.container,\n input: style.input,\n suggestionsContainer: style.suggestionsContainer,\n suggestionsContainerOpen: style.suggestionsContainerOpen,\n suggestionsList: style.suggestionsList,\n suggestion: style.suggestion,\n suggestionHighlighted: style.suggestionHighlighted\n }}\n suggestions={suggestions}\n onSuggestionsFetchRequested={handleSuggestionsFetchRequested}\n onSuggestionsClearRequested={handleSuggestionsClearRequested}\n getSuggestionValue={noop}\n renderSuggestion={renderSuggestion}\n inputProps={inputProps}\n focusInputOnSuggestionClick={false}\n onSuggestionSelected={handleSuggestionsSelected}\n />\n {errorIconView}\n {errorText}\n </div>\n </label>\n {descriptionView}\n </div>\n );\n};\n\nAutocomplete.propTypes = {\n title: PropTypes.string,\n placeholder: PropTypes.string,\n value: PropTypes.string,\n description: PropTypes.string,\n required: PropTypes.bool,\n modified: PropTypes.bool,\n error: PropTypes.bool,\n errorMessage: PropTypes.string,\n suggestions: PropTypes.arrayOf(\n PropTypes.shape({\n name: PropTypes.string,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])\n })\n ),\n theme: PropTypes.oneOf(keys(THEME_STYLE)),\n onInput: PropTypes.func,\n onFetch: PropTypes.func,\n onClear: PropTypes.func,\n onBlur: PropTypes.func,\n onSuggestionSelected: PropTypes.func\n};\n\nexport default Autocomplete;\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AAIA;;AACA;;;;;;;;AAEA,MAAMA,WAAW,GAAG;EAClBC,YAAY,EAAEC,cAAA,CAAMD,YADF;EAElBE,OAAO,EAAED,cAAA,CAAMC;AAFG,CAApB;;AAKA,MAAMC,gBAAgB,GAAGC,UAAU,iBAAI,2CAAOA,UAAU,CAACC,IAAlB,CAAvC;;AAEA,MAAMC,YAAY,GAAGC,KAAK,IAAI;EAC5B,MAAM;IACJC,WAAW,GAAG,EADV;IAEJC,KAFI;IAGJC,WA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