@coorpacademy/components 11.40.0 → 11.40.1-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/button-link/index.d.ts.map +1 -1
- package/es/atom/button-link/index.js +7 -5
- package/es/atom/button-link/index.js.map +1 -1
- package/es/atom/button-link/style.css +1 -1
- package/es/atom/button-link/types.d.ts +3 -0
- package/es/atom/button-link/types.d.ts.map +1 -1
- package/es/atom/button-link/types.js.map +1 -1
- package/es/atom/select-icon/index.d.ts.map +1 -1
- package/es/atom/select-icon/index.js +3 -9
- package/es/atom/select-icon/index.js.map +1 -1
- package/es/molecule/icon-picker-modal/index.d.ts.map +1 -1
- package/es/molecule/icon-picker-modal/index.js +32 -26
- package/es/molecule/icon-picker-modal/index.js.map +1 -1
- package/es/molecule/quick-filters/index.d.ts +68 -0
- package/es/molecule/quick-filters/index.d.ts.map +1 -0
- package/es/molecule/quick-filters/index.js +179 -0
- package/es/molecule/quick-filters/index.js.map +1 -0
- package/es/molecule/quick-filters/style.css +119 -0
- package/es/molecule/quick-filters/types.d.ts +91 -0
- package/es/molecule/quick-filters/types.d.ts.map +1 -0
- package/es/molecule/quick-filters/types.js +25 -0
- package/es/molecule/quick-filters/types.js.map +1 -0
- package/lib/atom/button-link/index.d.ts.map +1 -1
- package/lib/atom/button-link/index.js +7 -5
- package/lib/atom/button-link/index.js.map +1 -1
- package/lib/atom/button-link/style.css +1 -1
- package/lib/atom/button-link/types.d.ts +3 -0
- package/lib/atom/button-link/types.d.ts.map +1 -1
- package/lib/atom/button-link/types.js.map +1 -1
- package/lib/atom/select-icon/index.d.ts.map +1 -1
- package/lib/atom/select-icon/index.js +3 -9
- package/lib/atom/select-icon/index.js.map +1 -1
- package/lib/molecule/icon-picker-modal/index.d.ts.map +1 -1
- package/lib/molecule/icon-picker-modal/index.js +32 -26
- package/lib/molecule/icon-picker-modal/index.js.map +1 -1
- package/lib/molecule/quick-filters/index.d.ts +68 -0
- package/lib/molecule/quick-filters/index.d.ts.map +1 -0
- package/lib/molecule/quick-filters/index.js +187 -0
- package/lib/molecule/quick-filters/index.js.map +1 -0
- package/lib/molecule/quick-filters/style.css +119 -0
- package/lib/molecule/quick-filters/types.d.ts +91 -0
- package/lib/molecule/quick-filters/types.d.ts.map +1 -0
- package/lib/molecule/quick-filters/types.js +30 -0
- package/lib/molecule/quick-filters/types.js.map +1 -0
- package/locales/lt/global.json +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/index.tsx"],"names":[],"mappings":";AAQA,OAAkB,EAAC,eAAe,EAAW,MAAM,SAAS,CAAC;AA8D7D,QAAA,MAAM,UAAU;YAAW,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqJzC,CAAC;AAIF,eAAe,UAAU,CAAC"}
|
|
@@ -6,9 +6,10 @@ import Link from '../link';
|
|
|
6
6
|
import FaIcon, { DEFAULT_ICON_COLOR } from '../icon';
|
|
7
7
|
import { ICONS } from '../../util/button-icons';
|
|
8
8
|
import ToolTip from '../tooltip';
|
|
9
|
+
import Tag from '../tag';
|
|
9
10
|
import propTypes from './types';
|
|
10
11
|
import style from './style.css';
|
|
11
|
-
const getButtonContent = (icon, content, hovered, hoverBackgroundColor, hoverColor, customLabelClassName) => {
|
|
12
|
+
const getButtonContent = (icon, content, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag) => {
|
|
12
13
|
const {
|
|
13
14
|
type,
|
|
14
15
|
faIcon,
|
|
@@ -50,7 +51,7 @@ const getButtonContent = (icon, content, hovered, hoverBackgroundColor, hoverCol
|
|
|
50
51
|
className: style.buttonContent
|
|
51
52
|
}, position === 'left' ? iconComponent : null, content ? /*#__PURE__*/React.createElement("span", {
|
|
52
53
|
className: style.label
|
|
53
|
-
}, content) : null, position === 'right' ? iconComponent : null);
|
|
54
|
+
}, content) : null, tag ? /*#__PURE__*/React.createElement(Tag, tag) : null, position === 'right' ? iconComponent : null);
|
|
54
55
|
};
|
|
55
56
|
const ButtonLink = props => {
|
|
56
57
|
const {
|
|
@@ -73,7 +74,8 @@ const ButtonLink = props => {
|
|
|
73
74
|
className,
|
|
74
75
|
customStyle,
|
|
75
76
|
useTitle = true,
|
|
76
|
-
customLabelClassName
|
|
77
|
+
customLabelClassName,
|
|
78
|
+
tag
|
|
77
79
|
} = props;
|
|
78
80
|
const styleButton = classnames(link && style.link, className, style.button, !label && style.iconButton, type === 'primary' && style.primary, type === 'secondary' && style.secondary, type === 'tertiary' && style.tertiary, type === 'text' && style.text, type === 'dangerous' && style.dangerous, disabled && style.disabled);
|
|
79
81
|
const [hovered, setHovered] = useState(false);
|
|
@@ -121,7 +123,7 @@ const ButtonLink = props => {
|
|
|
121
123
|
hoverBackgroundColor: hoverBackgroundColor,
|
|
122
124
|
onMouseEnter: handleMouseOver,
|
|
123
125
|
onMouseLeave: handleMouseLeave
|
|
124
|
-
}), getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor, customLabelClassName), renderToolTip());
|
|
126
|
+
}), getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag), renderToolTip());
|
|
125
127
|
}
|
|
126
128
|
return /*#__PURE__*/React.createElement("button", _extends({}, useTitle && {
|
|
127
129
|
title: ariaLabel || label
|
|
@@ -142,7 +144,7 @@ const ButtonLink = props => {
|
|
|
142
144
|
onMouseLeave: handleMouseLeave,
|
|
143
145
|
tabIndex: 0,
|
|
144
146
|
disabled: disabled
|
|
145
|
-
}), getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor), renderToolTip());
|
|
147
|
+
}), getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor, customLabelClassName, tag), renderToolTip());
|
|
146
148
|
};
|
|
147
149
|
ButtonLink.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
148
150
|
export default ButtonLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useState","useMemo","classnames","Link","FaIcon","DEFAULT_ICON_COLOR","ICONS","ToolTip","propTypes","style","getButtonContent","icon","content","hovered","hoverBackgroundColor","hoverColor","customLabelClassName","type","faIcon","position","Icon","createElement","className","buttonContent","label","dangerouslySetInnerHTML","__html","iconComponent","iconName","name","iconColor","color","backgroundColor","size","faSize","wrapperSize","customStyle","theme","ButtonLink","props","usage","disabled","dataName","dataTestId","ariaLabel","tooltipText","tooltipPlacement","link","onClick","_noop","onKeyDown","useTitle","styleButton","button","iconButton","primary","secondary","tertiary","text","dangerous","setHovered","handleOnClick","event","handleOnKeyDown","handleMouseOver","handleMouseLeave","TooltipContent","tooltipContentWrapper","renderToolTip","closeToolTipInformationTextAriaLabel","fontSize","anchorId","toolTipIsVisible","placement","_customStyle","_extends","title","onMouseEnter","onMouseLeave","onMouseOver","tabIndex","process","env","NODE_ENV"],"sources":["../../../src/atom/button-link/index.tsx"],"sourcesContent":["import React, {useCallback, useState, useMemo} from 'react';\nimport {noop} from 'lodash/fp';\nimport classnames from 'classnames';\nimport Link from '../link';\nimport FaIcon, {DEFAULT_ICON_COLOR, IconProps} from '../icon';\nimport {ICONS} from '../../util/button-icons';\nimport ToolTip from '../tooltip';\nimport propTypes, {ButtonLinkProps, IconType} from './types';\nimport style from './style.css';\n\nconst getButtonContent = (\n icon?: IconType,\n content?: string | React.ReactNode,\n hovered?: boolean,\n hoverBackgroundColor?: string,\n hoverColor?: string,\n customLabelClassName?: string\n) => {\n const {type, faIcon, position} = icon || {type: '', position: ''};\n const Icon = type && ICONS[type];\n\n if (!Icon && !faIcon) {\n return (\n <div className={(style.buttonContent, customLabelClassName)}>\n {typeof content === 'string' ? (\n <span\n className={(style.label, customLabelClassName)}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: content}}\n />\n ) : (\n <span className={(style.label, customLabelClassName)}>{content}</span>\n )}\n </div>\n );\n }\n\n const iconComponent = faIcon ? (\n <FaIcon\n {...({\n iconName: faIcon.name,\n iconColor: hovered && hoverColor ? hoverColor : faIcon.color ?? DEFAULT_ICON_COLOR,\n // eslint-disable-next-line no-nested-ternary\n backgroundColor: !faIcon?.backgroundColor\n ? null\n : hovered && hoverBackgroundColor\n ? hoverBackgroundColor\n : faIcon.backgroundColor,\n size: {\n faSize: faIcon.size,\n wrapperSize: faIcon.size\n },\n customStyle: faIcon.customStyle\n } as IconProps)}\n />\n ) : (\n <Icon className={style.icon} theme=\"coorpmanager\" />\n );\n\n return (\n <div className={style.buttonContent}>\n {position === 'left' ? iconComponent : null}\n {content ? <span className={style.label}>{content}</span> : null}\n {position === 'right' ? iconComponent : null}\n </div>\n );\n};\n\nconst ButtonLink = (props: ButtonLinkProps) => {\n const {\n type,\n usage = 'button',\n label,\n content,\n hoverBackgroundColor,\n hoverColor,\n disabled = false,\n icon,\n 'data-name': dataName,\n 'data-testid': dataTestId = 'button-link',\n 'aria-label': ariaLabel,\n tooltipText,\n tooltipPlacement = 'left',\n link,\n onClick = noop,\n onKeyDown = noop,\n className,\n customStyle,\n useTitle = true,\n customLabelClassName\n } = props;\n const styleButton = classnames(\n link && style.link,\n className,\n style.button,\n !label && style.iconButton,\n type === 'primary' && style.primary,\n type === 'secondary' && style.secondary,\n type === 'tertiary' && style.tertiary,\n type === 'text' && style.text,\n type === 'dangerous' && style.dangerous,\n disabled && style.disabled\n );\n\n const [hovered, setHovered] = useState(false);\n\n const handleOnClick = useCallback(event => onClick(event), [onClick]);\n\n const handleOnKeyDown = useCallback(event => onKeyDown(event), [onKeyDown]);\n\n const handleMouseOver = useCallback(() => {\n setHovered(true);\n }, [setHovered]);\n\n const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);\n\n const TooltipContent = useCallback(\n () => <span className={style.tooltipContentWrapper}>{tooltipText || ariaLabel}</span>,\n [tooltipText, ariaLabel]\n );\n\n const renderToolTip = () => {\n const closeToolTipInformationTextAriaLabel = tooltipText || ariaLabel;\n if (!closeToolTipInformationTextAriaLabel) return null;\n return (\n <ToolTip\n fontSize={12}\n anchorId=\"button-icon\"\n toolTipIsVisible={hovered}\n placement={tooltipPlacement}\n TooltipContent={TooltipContent}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n />\n );\n };\n\n const _customStyle = useMemo(() => {\n return {\n ...customStyle,\n ...((hoverBackgroundColor || hoverColor) && hovered\n ? {\n backgroundColor: hoverBackgroundColor,\n color: hoverColor\n }\n : null)\n };\n }, [hoverBackgroundColor, hoverColor, hovered, customStyle]);\n\n if (link) {\n return (\n <Link\n {...link}\n {...(useTitle && {\n title: ariaLabel || label\n })}\n className={styleButton}\n style={customStyle}\n data-name={dataName}\n data-testid={dataTestId}\n onClick={handleOnClick}\n aria-label={ariaLabel || label}\n hoverColor={hoverColor}\n hoverBackgroundColor={hoverBackgroundColor}\n onMouseEnter={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n >\n {getButtonContent(\n icon,\n content ?? label,\n hovered,\n hoverBackgroundColor,\n hoverColor,\n customLabelClassName\n )}\n {renderToolTip()}\n </Link>\n );\n }\n\n return (\n <button\n {...(useTitle && {\n title: ariaLabel || label\n })}\n {...(ariaLabel && !label\n ? {\n 'data-for': 'button-icon',\n 'data-tip': hovered\n }\n : {})}\n // eslint-disable-next-line react/button-has-type\n type={usage}\n aria-label={ariaLabel || label}\n data-name={dataName}\n data-testid={dataTestId}\n style={_customStyle}\n className={styleButton}\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n onMouseOver={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n tabIndex={0}\n disabled={disabled}\n >\n {getButtonContent(icon, content ?? label, hovered, hoverBackgroundColor, hoverColor)}\n {renderToolTip()}\n </button>\n );\n};\n\nButtonLink.propTypes = propTypes;\n\nexport default ButtonLink;\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C,UAAU,EACVC,oBACF,CAAC,EACAoD,aAAa,CAAC,CACX,CAAC;EAEX;EAEA,oBACEtE,KAAA,CAAAuB,aAAA,WAAAsD,QAAA,KACOxB,QAAQ,IAAI;IACfyB,KAAK,EAAEhC,SAAS,IAAIpB;EACtB,CAAC,EACIoB,SAAS,IAAI,CAACpB,KAAK,GACpB;IACE,UAAU,EAAE,aAAa;IACzB,UAAU,EAAEX;EACd,CAAC,GACD,CAAC,CAAC;IACN;IACAI,IAAI,EAAEuB,KAAM;IACZ,cAAYI,SAAS,IAAIpB,KAAM;IAC/B,aAAWkB,QAAS;IACpB,eAAaC,UAAW;IACxBlC,KAAK,EAAEiE,YAAa;IACpBpD,SAAS,EAAE8B,WAAY;IACvBJ,OAAO,EAAEa,aAAc;IACvBX,SAAS,EAAEa,eAAgB;IAC3BgB,WAAW,EAAEf,eAAgB;IAC7Bc,YAAY,EAAEb,gBAAiB;IAC/Be,QAAQ,EAAE,CAAE;IACZvC,QAAQ,EAAEA;EAAS,IAElB/B,gBAAgB,CAACC,IAAI,EAAEC,OAAO,IAAIY,KAAK,EAAEX,OAAO,EAAEC,oBAAoB,EAAEC,UAAU,CAAC,EACnFqD,aAAa,CAAC,CACT,CAAC;AAEb,CAAC;AAED9B,UAAU,CAAC9B,SAAS,GAAAyE,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAG3E,SAAS;AAEhC,eAAe8B,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useState","useMemo","classnames","Link","FaIcon","DEFAULT_ICON_COLOR","ICONS","ToolTip","Tag","propTypes","style","getButtonContent","icon","content","hovered","hoverBackgroundColor","hoverColor","customLabelClassName","tag","type","faIcon","position","Icon","createElement","className","buttonContent","label","dangerouslySetInnerHTML","__html","iconComponent","iconName","name","iconColor","color","backgroundColor","size","faSize","wrapperSize","customStyle","theme","ButtonLink","props","usage","disabled","dataName","dataTestId","ariaLabel","tooltipText","tooltipPlacement","link","onClick","_noop","onKeyDown","useTitle","styleButton","button","iconButton","primary","secondary","tertiary","text","dangerous","setHovered","handleOnClick","event","handleOnKeyDown","handleMouseOver","handleMouseLeave","TooltipContent","tooltipContentWrapper","renderToolTip","closeToolTipInformationTextAriaLabel","fontSize","anchorId","toolTipIsVisible","placement","_customStyle","_extends","title","onMouseEnter","onMouseLeave","onMouseOver","tabIndex","process","env","NODE_ENV"],"sources":["../../../src/atom/button-link/index.tsx"],"sourcesContent":["import React, {useCallback, useState, useMemo} from 'react';\nimport {noop} from 'lodash/fp';\nimport classnames from 'classnames';\nimport Link from '../link';\nimport FaIcon, {DEFAULT_ICON_COLOR, IconProps} from '../icon';\nimport {ICONS} from '../../util/button-icons';\nimport ToolTip from '../tooltip';\nimport Tag from '../tag';\nimport propTypes, {ButtonLinkProps, IconType} from './types';\nimport style from './style.css';\n\nconst getButtonContent = (\n icon?: IconType,\n content?: string | React.ReactNode,\n hovered?: boolean,\n hoverBackgroundColor?: string,\n hoverColor?: string,\n customLabelClassName?: string,\n tag?: React.ComponentProps<typeof Tag>\n) => {\n const {type, faIcon, position} = icon || {type: '', position: ''};\n const Icon = type && ICONS[type];\n\n if (!Icon && !faIcon) {\n return (\n <div className={(style.buttonContent, customLabelClassName)}>\n {typeof content === 'string' ? (\n <span\n className={(style.label, customLabelClassName)}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{__html: content}}\n />\n ) : (\n <span className={(style.label, customLabelClassName)}>{content}</span>\n )}\n </div>\n );\n }\n\n const iconComponent = faIcon ? (\n <FaIcon\n {...({\n iconName: faIcon.name,\n iconColor: hovered && hoverColor ? hoverColor : faIcon.color ?? DEFAULT_ICON_COLOR,\n // eslint-disable-next-line no-nested-ternary\n backgroundColor: !faIcon?.backgroundColor\n ? null\n : hovered && hoverBackgroundColor\n ? hoverBackgroundColor\n : faIcon.backgroundColor,\n size: {\n faSize: faIcon.size,\n wrapperSize: faIcon.size\n },\n customStyle: faIcon.customStyle\n } as IconProps)}\n />\n ) : (\n <Icon className={style.icon} theme=\"coorpmanager\" />\n );\n return (\n <div className={style.buttonContent}>\n {position === 'left' ? iconComponent : null}\n {content ? <span className={style.label}>{content}</span> : null}\n {tag ? <Tag {...tag} /> : null}\n {position === 'right' ? iconComponent : null}\n </div>\n );\n};\n\nconst ButtonLink = (props: ButtonLinkProps) => {\n const {\n type,\n usage = 'button',\n label,\n content,\n hoverBackgroundColor,\n hoverColor,\n disabled = false,\n icon,\n 'data-name': dataName,\n 'data-testid': dataTestId = 'button-link',\n 'aria-label': ariaLabel,\n tooltipText,\n tooltipPlacement = 'left',\n link,\n onClick = noop,\n onKeyDown = noop,\n className,\n customStyle,\n useTitle = true,\n customLabelClassName,\n tag\n } = props;\n const styleButton = classnames(\n link && style.link,\n className,\n style.button,\n !label && style.iconButton,\n type === 'primary' && style.primary,\n type === 'secondary' && style.secondary,\n type === 'tertiary' && style.tertiary,\n type === 'text' && style.text,\n type === 'dangerous' && style.dangerous,\n disabled && style.disabled\n );\n\n const [hovered, setHovered] = useState(false);\n\n const handleOnClick = useCallback(event => onClick(event), [onClick]);\n\n const handleOnKeyDown = useCallback(event => onKeyDown(event), [onKeyDown]);\n\n const handleMouseOver = useCallback(() => {\n setHovered(true);\n }, [setHovered]);\n\n const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);\n\n const TooltipContent = useCallback(\n () => <span className={style.tooltipContentWrapper}>{tooltipText || ariaLabel}</span>,\n [tooltipText, ariaLabel]\n );\n\n const renderToolTip = () => {\n const closeToolTipInformationTextAriaLabel = tooltipText || ariaLabel;\n if (!closeToolTipInformationTextAriaLabel) return null;\n return (\n <ToolTip\n fontSize={12}\n anchorId=\"button-icon\"\n toolTipIsVisible={hovered}\n placement={tooltipPlacement}\n TooltipContent={TooltipContent}\n closeToolTipInformationTextAriaLabel={closeToolTipInformationTextAriaLabel}\n />\n );\n };\n const _customStyle = useMemo(() => {\n return {\n ...customStyle,\n ...((hoverBackgroundColor || hoverColor) && hovered\n ? {\n backgroundColor: hoverBackgroundColor,\n color: hoverColor\n }\n : null)\n };\n }, [hoverBackgroundColor, hoverColor, hovered, customStyle]);\n\n if (link) {\n return (\n <Link\n {...link}\n {...(useTitle && {\n title: ariaLabel || label\n })}\n className={styleButton}\n style={customStyle}\n data-name={dataName}\n data-testid={dataTestId}\n onClick={handleOnClick}\n aria-label={ariaLabel || label}\n hoverColor={hoverColor}\n hoverBackgroundColor={hoverBackgroundColor}\n onMouseEnter={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n >\n {getButtonContent(\n icon,\n content ?? label,\n hovered,\n hoverBackgroundColor,\n hoverColor,\n customLabelClassName,\n tag\n )}\n {renderToolTip()}\n </Link>\n );\n }\n\n return (\n <button\n {...(useTitle && {\n title: ariaLabel || label\n })}\n {...(ariaLabel && !label\n ? {\n 'data-for': 'button-icon',\n 'data-tip': hovered\n }\n : {})}\n // eslint-disable-next-line react/button-has-type\n type={usage}\n aria-label={ariaLabel || label}\n data-name={dataName}\n data-testid={dataTestId}\n style={_customStyle}\n className={styleButton}\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n onMouseOver={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n tabIndex={0}\n disabled={disabled}\n >\n {getButtonContent(\n icon,\n content ?? label,\n hovered,\n hoverBackgroundColor,\n hoverColor,\n customLabelClassName,\n tag\n )}\n {renderToolTip()}\n </button>\n );\n};\n\nButtonLink.propTypes = propTypes;\n\nexport default ButtonLink;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAGC,WAAW,EAAEC,QAAQ,EAAEC,OAAO,QAAO,OAAO;AAE3D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,MAAM,IAAGC,kBAAkB,QAAkB,SAAS;AAC7D,SAAQC,KAAK,QAAO,yBAAyB;AAC7C,OAAOC,OAAO,MAAM,YAAY;AAChC,OAAOC,GAAG,MAAM,QAAQ;AACxB,OAAOC,SAAS,MAAmC,SAAS;AA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B;EACtB,CAAC,EACIoB,SAAS,IAAI,CAACpB,KAAK,GACpB;IACE,UAAU,EAAE,aAAa;IACzB,UAAU,EAAEZ;EACd,CAAC,GACD,CAAC,CAAC;IACN;IACAK,IAAI,EAAEuB,KAAM;IACZ,cAAYI,SAAS,IAAIpB,KAAM;IAC/B,aAAWkB,QAAS;IACpB,eAAaC,UAAW;IACxBnC,KAAK,EAAEkE,YAAa;IACpBpD,SAAS,EAAE8B,WAAY;IACvBJ,OAAO,EAAEa,aAAc;IACvBX,SAAS,EAAEa,eAAgB;IAC3BgB,WAAW,EAAEf,eAAgB;IAC7Bc,YAAY,EAAEb,gBAAiB;IAC/Be,QAAQ,EAAE,CAAE;IACZvC,QAAQ,EAAEA;EAAS,IAElBhC,gBAAgB,CACfC,IAAI,EACJC,OAAO,IAAIa,KAAK,EAChBZ,OAAO,EACPC,oBAAoB,EACpBC,UAAU,EACVC,oBAAoB,EACpBC,GACF,CAAC,EACAoD,aAAa,CAAC,CACT,CAAC;AAEb,CAAC;AAED9B,UAAU,CAAC/B,SAAS,GAAA0E,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAG5E,SAAS;AAEhC,eAAe+B,UAAU","ignoreList":[]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import PropTypes from 'prop-types';
|
|
2
3
|
import { ICONS } from '../../util/button-icons';
|
|
4
|
+
import Tag from '../tag';
|
|
3
5
|
export declare const iconPropTypes: {
|
|
4
6
|
position: PropTypes.Requireable<string>;
|
|
5
7
|
type: PropTypes.Requireable<string>;
|
|
@@ -89,6 +91,7 @@ export declare type ButtonLinkProps = {
|
|
|
89
91
|
customStyle?: Record<string, string | number>;
|
|
90
92
|
useTitle?: boolean;
|
|
91
93
|
customLabelClassName?: string;
|
|
94
|
+
tag?: React.ComponentProps<typeof Tag>;
|
|
92
95
|
};
|
|
93
96
|
export declare type Fixture = {
|
|
94
97
|
props: ButtonLinkProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/types.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,KAAK,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atom/button-link/types.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,KAAK,EAAC,MAAM,yBAAyB,CAAC;AAC9C,OAAO,GAAG,MAAM,QAAQ,CAAC;AAUzB,eAAO,MAAM,aAAa;;;;;;;;;;;;CAIzB,CAAC;AAEF,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBd,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC/C,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,OAAO,KAAK,CAAC;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;IACnE,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;KAClD,CAAC;IACF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,GAAG,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,CAAC;CACxC,CAAC;AAEF,oBAAY,OAAO,GAAG;IAAC,KAAK,EAAE,eAAe,CAAA;CAAC,CAAC;AAE/C,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["PropTypes","ICONS","faIconPropTypes","name","string","isRequired","color","backgroundColor","size","number","customStyle","objectOf","oneOfType","iconPropTypes","position","oneOf","type","_keys","faIcon","shape","propTypes","usage","label","content","node","tooltipText","tooltipPlacement","icon","onClick","func","link","href","download","bool","target","hoverBackgroundColor","hoverColor","disabled","className","useTitle","customLabelClassName"],"sources":["../../../src/atom/button-link/types.ts"],"sourcesContent":["import PropTypes from 'prop-types';\nimport {keys} from 'lodash/fp';\nimport {ICONS} from '../../util/button-icons';\n\nconst faIconPropTypes = {\n name: PropTypes.string.isRequired,\n color: PropTypes.string,\n backgroundColor: PropTypes.string,\n size: PropTypes.number,\n customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))\n};\n\nexport const iconPropTypes = {\n position: PropTypes.oneOf(['right', 'left']),\n type: PropTypes.oneOf(keys(ICONS)),\n faIcon: PropTypes.shape(faIconPropTypes)\n};\n\nconst propTypes = {\n type: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'text', 'dangerous']),\n usage: PropTypes.oneOf(['button', 'submit', 'reset']),\n label: PropTypes.string,\n content: PropTypes.node,\n 'aria-label': PropTypes.string,\n tooltipText: PropTypes.string,\n tooltipPlacement: PropTypes.oneOf(['left', 'right', 'top', 'bottom']),\n 'data-name': PropTypes.string,\n 'data-testid': PropTypes.string,\n icon: PropTypes.shape(iconPropTypes),\n onClick: PropTypes.func,\n link: PropTypes.shape({\n href: PropTypes.string,\n download: PropTypes.bool,\n target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top'])\n }),\n hoverBackgroundColor: PropTypes.string,\n hoverColor: PropTypes.string,\n disabled: PropTypes.bool,\n className: PropTypes.string,\n customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),\n useTitle: PropTypes.bool,\n customLabelClassName: PropTypes.string\n};\n\nexport type FaIconType = {\n name: string;\n color?: string;\n backgroundColor?: string;\n size?: number;\n customStyle?: Record<string, number | string>;\n};\n\nexport type IconType = {\n position: 'right' | 'left';\n type?: keyof typeof ICONS;\n faIcon?: FaIconType;\n};\n\nexport type ButtonLinkProps = {\n type?: 'primary' | 'secondary' | 'tertiary' | 'text' | 'dangerous';\n usage?: 'button' | 'submit' | 'reset';\n label?: string;\n content?: PropTypes.ReactNodeLike;\n 'aria-label'?: string;\n tooltipText?: string;\n tooltipPlacement?: 'left' | 'right' | 'top' | 'bottom';\n 'data-name'?: string;\n 'data-testid'?: string;\n icon?: IconType;\n onClick?: () => void;\n onKeyDown?: () => void;\n link?: {\n href?: string;\n download?: boolean;\n target?: '_self' | '_blank' | '_parent' | '_top';\n };\n hoverBackgroundColor?: string;\n hoverColor?: string;\n disabled?: boolean;\n className?: string;\n customStyle?: Record<string, string | number>;\n useTitle?: boolean;\n customLabelClassName?: string;\n};\n\nexport type Fixture = {props: ButtonLinkProps};\n\nexport default propTypes;\n"],"mappings":";AAAA,OAAOA,SAAS,MAAM,YAAY;AAElC,SAAQC,KAAK,QAAO,yBAAyB;
|
|
1
|
+
{"version":3,"file":"types.js","names":["PropTypes","ICONS","faIconPropTypes","name","string","isRequired","color","backgroundColor","size","number","customStyle","objectOf","oneOfType","iconPropTypes","position","oneOf","type","_keys","faIcon","shape","propTypes","usage","label","content","node","tooltipText","tooltipPlacement","icon","onClick","func","link","href","download","bool","target","hoverBackgroundColor","hoverColor","disabled","className","useTitle","customLabelClassName"],"sources":["../../../src/atom/button-link/types.ts"],"sourcesContent":["import PropTypes from 'prop-types';\nimport {keys} from 'lodash/fp';\nimport {ICONS} from '../../util/button-icons';\nimport Tag from '../tag';\n\nconst faIconPropTypes = {\n name: PropTypes.string.isRequired,\n color: PropTypes.string,\n backgroundColor: PropTypes.string,\n size: PropTypes.number,\n customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))\n};\n\nexport const iconPropTypes = {\n position: PropTypes.oneOf(['right', 'left']),\n type: PropTypes.oneOf(keys(ICONS)),\n faIcon: PropTypes.shape(faIconPropTypes)\n};\n\nconst propTypes = {\n type: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'text', 'dangerous']),\n usage: PropTypes.oneOf(['button', 'submit', 'reset']),\n label: PropTypes.string,\n content: PropTypes.node,\n 'aria-label': PropTypes.string,\n tooltipText: PropTypes.string,\n tooltipPlacement: PropTypes.oneOf(['left', 'right', 'top', 'bottom']),\n 'data-name': PropTypes.string,\n 'data-testid': PropTypes.string,\n icon: PropTypes.shape(iconPropTypes),\n onClick: PropTypes.func,\n link: PropTypes.shape({\n href: PropTypes.string,\n download: PropTypes.bool,\n target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top'])\n }),\n hoverBackgroundColor: PropTypes.string,\n hoverColor: PropTypes.string,\n disabled: PropTypes.bool,\n className: PropTypes.string,\n customStyle: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),\n useTitle: PropTypes.bool,\n customLabelClassName: PropTypes.string\n};\n\nexport type FaIconType = {\n name: string;\n color?: string;\n backgroundColor?: string;\n size?: number;\n customStyle?: Record<string, number | string>;\n};\n\nexport type IconType = {\n position: 'right' | 'left';\n type?: keyof typeof ICONS;\n faIcon?: FaIconType;\n};\n\nexport type ButtonLinkProps = {\n type?: 'primary' | 'secondary' | 'tertiary' | 'text' | 'dangerous';\n usage?: 'button' | 'submit' | 'reset';\n label?: string;\n content?: PropTypes.ReactNodeLike;\n 'aria-label'?: string;\n tooltipText?: string;\n tooltipPlacement?: 'left' | 'right' | 'top' | 'bottom';\n 'data-name'?: string;\n 'data-testid'?: string;\n icon?: IconType;\n onClick?: () => void;\n onKeyDown?: () => void;\n link?: {\n href?: string;\n download?: boolean;\n target?: '_self' | '_blank' | '_parent' | '_top';\n };\n hoverBackgroundColor?: string;\n hoverColor?: string;\n disabled?: boolean;\n className?: string;\n customStyle?: Record<string, string | number>;\n useTitle?: boolean;\n customLabelClassName?: string;\n tag?: React.ComponentProps<typeof Tag>;\n};\n\nexport type Fixture = {props: ButtonLinkProps};\n\nexport default propTypes;\n"],"mappings":";AAAA,OAAOA,SAAS,MAAM,YAAY;AAElC,SAAQC,KAAK,QAAO,yBAAyB;AAG7C,MAAMC,eAAe,GAAG;EACtBC,IAAI,EAAEH,SAAS,CAACI,MAAM,CAACC,UAAU;EACjCC,KAAK,EAAEN,SAAS,CAACI,MAAM;EACvBG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E/B,SAAS,CAACI,MAAM;IACtB4B,QAAQ,EAAEhC,SAAS,CAACiC,IAAI;IACxBC,MAAM,EAAElC,SAAS,CAACe,KAAK,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAChE,CAAC,CAAC;EACFoB,oBAAoB,EAAEnC,SAAS,CAACI,MAAM;EACtCgC,UAAU,EAAEpC,SAAS,CAACI,MAAM;EAC5BiC,QAAQ,EAAErC,SAAS,CAACiC,IAAI;EACxBK,SAAS,EAAEtC,SAAS,CAACI,MAAM;EAC3BM,WAAW,EAAEV,SAAS,CAACW,QAAQ,CAACX,SAAS,CAACY,SAAS,CAAC,CAACZ,SAAS,CAACI,MAAM,EAAEJ,SAAS,CAACS,MAAM,CAAC,CAAC,CAAC;EAC1F8B,QAAQ,EAAEvC,SAAS,CAACiC,IAAI;EACxBO,oBAAoB,EAAExC,SAAS,CAACI;AAClC,CAAC;AA8CD,eAAegB,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/select-icon/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/select-icon/index.js"],"names":[],"mappings":";AA6CA,qDA0BC"}
|
|
@@ -18,10 +18,7 @@ const getButtonContent = (faIcon, options = {}) => {
|
|
|
18
18
|
} = options;
|
|
19
19
|
return /*#__PURE__*/React.createElement("div", {
|
|
20
20
|
className: style.contentWrapper
|
|
21
|
-
}, isSelected ?
|
|
22
|
-
/*#__PURE__*/
|
|
23
|
-
/* checkbox icon */
|
|
24
|
-
React.createElement("div", {
|
|
21
|
+
}, isSelected ? /*#__PURE__*/React.createElement("div", {
|
|
25
22
|
className: style.checkIcon
|
|
26
23
|
}, /*#__PURE__*/React.createElement(FaIcon, {
|
|
27
24
|
iconName: CHECK_ICON_NAME_MAP[selectionMode],
|
|
@@ -31,10 +28,7 @@ const getButtonContent = (faIcon, options = {}) => {
|
|
|
31
28
|
faSize: 16,
|
|
32
29
|
wrapperSize: 16
|
|
33
30
|
}
|
|
34
|
-
})) : null,
|
|
35
|
-
/*#__PURE__*/
|
|
36
|
-
/* selection tick (L18) / icon */
|
|
37
|
-
React.createElement("div", {
|
|
31
|
+
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
38
32
|
className: style.iconWrapper
|
|
39
33
|
}, /*#__PURE__*/React.createElement("div", {
|
|
40
34
|
className: style.icon
|
|
@@ -70,7 +64,7 @@ const SelectIcon = props => {
|
|
|
70
64
|
"data-testid": `button-${dataName}`,
|
|
71
65
|
className: styleButton,
|
|
72
66
|
onClick: handleOnClick
|
|
73
|
-
}, contentView), [ariaLabel, contentView, dataName, handleOnClick
|
|
67
|
+
}, contentView), [ariaLabel, contentView, dataName, handleOnClick]);
|
|
74
68
|
return /*#__PURE__*/React.createElement(IconButton, null);
|
|
75
69
|
};
|
|
76
70
|
SelectIcon.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","PropTypes","classnames","FaIcon","COLORS","style","ICON_COLOR","cm_primary_blue","BACKGROUND_COLOR","white","CHECK_ICON_NAME_MAP","single","multi","getButtonContent","faIcon","options","selectionMode","isSelected","iconColor","createElement","className","contentWrapper","checkIcon","iconName","backgroundColor","size","faSize","wrapperSize","iconWrapper","icon","iconText","SelectIcon","props","dataName","ariaLabel","onClick","contentView","styleButton","defaultStyle","selected","handleOnClick","IconButton","type","propTypes","process","env","NODE_ENV","string","func","shape","oneOf","bool"],"sources":["../../../src/atom/select-icon/index.js"],"sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport FaIcon from '../icon';\n\nimport {COLORS} from '../../variables/colors';\nimport style from './style.css';\n\nconst ICON_COLOR = COLORS.cm_primary_blue;\nconst BACKGROUND_COLOR = COLORS.white;\nconst CHECK_ICON_NAME_MAP = {\n single: 'circle-check',\n multi: 'square-check'\n};\n\nconst getButtonContent = (faIcon, options = {}) => {\n const {selectionMode = 'single', isSelected = false, iconColor = ICON_COLOR} = options;\n\n return (\n <div className={style.contentWrapper}>\n {isSelected ? (\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","PropTypes","classnames","FaIcon","COLORS","style","ICON_COLOR","cm_primary_blue","BACKGROUND_COLOR","white","CHECK_ICON_NAME_MAP","single","multi","getButtonContent","faIcon","options","selectionMode","isSelected","iconColor","createElement","className","contentWrapper","checkIcon","iconName","backgroundColor","size","faSize","wrapperSize","iconWrapper","icon","iconText","SelectIcon","props","dataName","ariaLabel","onClick","contentView","styleButton","defaultStyle","selected","handleOnClick","IconButton","type","propTypes","process","env","NODE_ENV","string","func","shape","oneOf","bool"],"sources":["../../../src/atom/select-icon/index.js"],"sourcesContent":["import React, {useCallback} from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport FaIcon from '../icon';\n\nimport {COLORS} from '../../variables/colors';\nimport style from './style.css';\n\nconst ICON_COLOR = COLORS.cm_primary_blue;\nconst BACKGROUND_COLOR = COLORS.white;\nconst CHECK_ICON_NAME_MAP = {\n single: 'circle-check',\n multi: 'square-check'\n};\n\nconst getButtonContent = (faIcon, options = {}) => {\n const {selectionMode = 'single', isSelected = false, iconColor = ICON_COLOR} = options;\n\n return (\n <div className={style.contentWrapper}>\n {isSelected ? (\n <div className={style.checkIcon}>\n <FaIcon\n iconName={CHECK_ICON_NAME_MAP[selectionMode]}\n iconColor={iconColor}\n backgroundColor={BACKGROUND_COLOR}\n size={{faSize: 16, wrapperSize: 16}}\n />\n </div>\n ) : null}\n\n <div className={style.iconWrapper}>\n <div className={style.icon}>\n <FaIcon\n iconName={faIcon}\n iconColor={isSelected ? iconColor : ''}\n size={{faSize: 32, wrapperSize: 32}}\n />\n </div>\n <div className={style.iconText}>{faIcon}</div>\n </div>\n </div>\n );\n};\n\nconst SelectIcon = props => {\n const {faIcon, 'data-name': dataName, 'aria-label': ariaLabel, onClick, options = {}} = props;\n\n const {isSelected = false} = options;\n\n const contentView = getButtonContent(faIcon, options);\n const styleButton = classnames(style.defaultStyle, isSelected && style.selected);\n const handleOnClick = useCallback(() => onClick(), [onClick]);\n\n const IconButton = useCallback(\n () => (\n <button\n type=\"button\"\n aria-label={ariaLabel}\n data-name={dataName}\n data-testid={`button-${dataName}`}\n className={styleButton}\n onClick={handleOnClick}\n >\n {contentView}\n </button>\n ),\n [ariaLabel, contentView, dataName, handleOnClick]\n );\n\n return <IconButton />;\n};\n\nSelectIcon.propTypes = {\n 'aria-label': PropTypes.string,\n 'data-name': PropTypes.string,\n faIcon: PropTypes.string,\n onClick: PropTypes.func,\n options: PropTypes.shape({\n selectionMode: PropTypes.oneOf(['single', 'multi']),\n isSelected: PropTypes.bool,\n iconColor: PropTypes.string\n })\n};\n\nexport default SelectIcon;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAGC,WAAW,QAAO,OAAO;AACxC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,MAAM,MAAM,SAAS;AAE5B,SAAQC,MAAM,QAAO,wBAAwB;AAC7C,OAAOC,KAAK,MAAM,aAAa;AAE/B,MAAMC,UAAU,GAAGF,MAAM,CAACG,eAAe;AACzC,MAAMC,gBAAgB,GAAGJ,MAAM,CAACK,KAAK;AACrC,MAAMC,mBAAmB,GAAG;EAC1BC,MAAM,EAAE,cAAc;EACtBC,KAAK,EAAE;AACT,CAAC;AAED,MAAMC,gBAAgB,GAAGA,CAACC,MAAM,EAAEC,OAAO,GAAG,CAAC,CAAC,KAAK;EACjD,MAAM;IAACC,aAAa,GAAG,QAAQ;IAAEC,UAAU,GAAG,KAAK;IAAEC,SAAS,GAAGZ;EAAU,CAAC,GAAGS,OAAO;EAEtF,oBACEhB,KAAA,CAAAoB,aAAA;IAAKC,SAAS,EAAEf,KAAK,CAACgB;EAAe,G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Aa,GAAGxC,WAAW,CAAC,MAAMmC,OAAO,CAAC,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAE7D,MAAMM,UAAU,GAAGzC,WAAW,CAC5B,mBACED,KAAA,CAAAoB,aAAA;IACEuB,IAAI,EAAC,QAAQ;IACb,cAAYR,SAAU;IACtB,aAAWD,QAAS;IACpB,eAAa,UAAUA,QAAQ,EAAG;IAClCb,SAAS,EAAEiB,WAAY;IACvBF,OAAO,EAAEK;EAAc,GAEtBJ,WACK,CACT,EACD,CAACF,SAAS,EAAEE,WAAW,EAAEH,QAAQ,EAAEO,aAAa,CAClD,CAAC;EAED,oBAAOzC,KAAA,CAAAoB,aAAA,CAACsB,UAAU,MAAE,CAAC;AACvB,CAAC;AAEDV,UAAU,CAACY,SAAS,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAG;EACrB,YAAY,EAAE7C,SAAS,CAAC8C,MAAM;EAC9B,WAAW,EAAE9C,SAAS,CAAC8C,MAAM;EAC7BjC,MAAM,EAAEb,SAAS,CAAC8C,MAAM;EACxBZ,OAAO,EAAElC,SAAS,CAAC+C,IAAI;EACvBjC,OAAO,EAAEd,SAAS,CAACgD,KAAK,CAAC;IACvBjC,aAAa,EAAEf,SAAS,CAACiD,KAAK,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnDjC,UAAU,EAAEhB,SAAS,CAACkD,IAAI;IAC1BjC,SAAS,EAAEjB,SAAS,CAAC8C;EACvB,CAAC;AACH,CAAC;AAED,eAAehB,UAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/icon-picker-modal/index.js"],"names":[],"mappings":";AAcA,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/icon-picker-modal/index.js"],"names":[],"mappings":";AAcA,+EAsIC"}
|
|
@@ -27,10 +27,11 @@ const IconPickerModal = (props, context) => {
|
|
|
27
27
|
const {
|
|
28
28
|
translate
|
|
29
29
|
} = context;
|
|
30
|
-
const [selectedIcon, setSelectedIcon] = useState(null);
|
|
31
|
-
const [displayedIcons, setDisplayedIcons] = useState([]);
|
|
32
|
-
const [currentIndex, setCurrentIndex] = useState(0);
|
|
33
30
|
const allIcons = useMemo(() => _pipe(_values, _map(_get('iconName')), _uniq)(fas), []);
|
|
31
|
+
const [selectedIcon, setSelectedIcon] = useState(null);
|
|
32
|
+
const [displayedIcons, setDisplayedIcons] = useState(_slice(0, ICONS_PER_LOAD, allIcons));
|
|
33
|
+
// const [currentIndex, setCurrentIndex] = useState(ICONS_PER_LOAD);
|
|
34
|
+
|
|
34
35
|
const {
|
|
35
36
|
searchValue,
|
|
36
37
|
searchResults,
|
|
@@ -44,32 +45,36 @@ const IconPickerModal = (props, context) => {
|
|
|
44
45
|
onClose();
|
|
45
46
|
}, [onClose]);
|
|
46
47
|
const handleIconClick = useCallback(iconName => () => {
|
|
48
|
+
console.log('in handleIconClick ----->');
|
|
47
49
|
setSelectedIcon(prevSelectedIcon => prevSelectedIcon === iconName ? null : iconName);
|
|
48
50
|
}, []);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
|
|
52
|
+
// const loadMoreIcons = useCallback(() => {
|
|
53
|
+
// const nextIndex = currentIndex + ICONS_PER_LOAD;
|
|
54
|
+
// const newIcons = slice(currentIndex, nextIndex, searchResults);
|
|
55
|
+
// setDisplayedIcons(prevIcons => [...prevIcons, ...newIcons]);
|
|
56
|
+
// setCurrentIndex(nextIndex);
|
|
57
|
+
// }, [currentIndex, searchResults]);
|
|
58
|
+
|
|
55
59
|
useEffect(() => {
|
|
56
60
|
setDisplayedIcons(() => _slice(0, ICONS_PER_LOAD, searchResults));
|
|
57
|
-
setCurrentIndex(ICONS_PER_LOAD);
|
|
61
|
+
// setCurrentIndex(ICONS_PER_LOAD);
|
|
58
62
|
}, [searchResults]);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
|
|
64
|
+
// const handleScroll = useCallback(
|
|
65
|
+
// event => {
|
|
66
|
+
// const {scrollTop, clientHeight, scrollHeight} = event.currentTarget;
|
|
67
|
+
// if (scrollHeight - scrollTop <= clientHeight + 1) {
|
|
68
|
+
// loadMoreIcons();
|
|
69
|
+
// }
|
|
70
|
+
// },
|
|
71
|
+
// [loadMoreIcons]
|
|
72
|
+
// );
|
|
73
|
+
|
|
69
74
|
const icons = useMemo(() => _pipe(_entries, _map(([index, iconName]) => /*#__PURE__*/React.createElement(SelectIcon, {
|
|
70
|
-
key:
|
|
75
|
+
key: iconName,
|
|
71
76
|
size: "responsive",
|
|
72
|
-
"data-name":
|
|
77
|
+
"data-name": iconName,
|
|
73
78
|
"aria-label": iconName,
|
|
74
79
|
faIcon: iconName,
|
|
75
80
|
onClick: handleIconClick(iconName),
|
|
@@ -101,8 +106,9 @@ const IconPickerModal = (props, context) => {
|
|
|
101
106
|
title: translate('icon_picker_title'),
|
|
102
107
|
description: translate('icon_picker_description'),
|
|
103
108
|
isOpen: isOpen,
|
|
104
|
-
onClose: handleClose
|
|
105
|
-
onScroll
|
|
109
|
+
onClose: handleClose
|
|
110
|
+
// onScroll={handleScroll}
|
|
111
|
+
,
|
|
106
112
|
footer: footer,
|
|
107
113
|
headerIcon: {
|
|
108
114
|
name: 'arrows-rotate',
|
|
@@ -110,7 +116,7 @@ const IconPickerModal = (props, context) => {
|
|
|
110
116
|
}
|
|
111
117
|
}, /*#__PURE__*/React.createElement("div", {
|
|
112
118
|
className: style.iconPicker
|
|
113
|
-
}, /*#__PURE__*/React.createElement(
|
|
119
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
114
120
|
className: style.searchWrapper
|
|
115
121
|
}, /*#__PURE__*/React.createElement(SearchForm, {
|
|
116
122
|
search: {
|
|
@@ -133,7 +139,7 @@ const IconPickerModal = (props, context) => {
|
|
|
133
139
|
onClick: handleReset
|
|
134
140
|
}, translate('empty_search_result_clear_search'))) : /*#__PURE__*/React.createElement("div", {
|
|
135
141
|
className: style.iconsListWrapper
|
|
136
|
-
}, icons)))
|
|
142
|
+
}, icons)));
|
|
137
143
|
};
|
|
138
144
|
IconPickerModal.contextTypes = {
|
|
139
145
|
translate: Provider.childContextTypes.translate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","useState","useCallback","useEffect","PropTypes","fas","BaseModal","SelectIcon","Provider","SearchForm","COLORS","style","useIconSearch","ICONS_PER_LOAD","IconPickerModal","props","context","isOpen","onCancel","onConfirm","onClose","translate","selectedIcon","setSelectedIcon","displayedIcons","setDisplayedIcons","currentIndex","setCurrentIndex","allIcons","_pipe","_values","_map","_get","_uniq","searchValue","searchResults","handleSearch","handleReset","handleCancel","handleClose","handleIconClick","iconName","prevSelectedIcon","loadMoreIcons","nextIndex","newIcons","_slice","prevIcons","handleScroll","event","scrollTop","clientHeight","scrollHeight","currentTarget","icons","_entries","index","createElement","key","size","faIcon","onClick","options","isSelected","footer","cancelButton","label","confirmButton","disabled","color","cm_primary_blue","title","description","onScroll","headerIcon","name","backgroundColor","className","iconPicker","Fragment","searchWrapper","search","placeholder","value","onChange","onReset","dataTestId","_size","emptySearchResultContainer","emptySearchResultTitle","emptySearchResultDescription","emptySearchResultClearSearch","iconsListWrapper","contextTypes","childContextTypes","propTypes","process","env","NODE_ENV","bool","func"],"sources":["../../../src/molecule/icon-picker-modal/index.js"],"sourcesContent":["import React, {useMemo, useState, useCallback, useEffect} from 'react';\nimport PropTypes from 'prop-types';\nimport {fas} from '@fortawesome/pro-solid-svg-icons';\nimport {entries, map, pipe, get, values, slice, size, uniq} from 'lodash/fp';\nimport BaseModal from '../base-modal';\nimport SelectIcon from '../../atom/select-icon';\nimport Provider from '../../atom/provider';\nimport SearchForm from '../search-form';\nimport {COLORS} from '../../variables/colors';\nimport style from './style.css';\nimport useIconSearch from './use-icon-search';\n\nconst ICONS_PER_LOAD = 48;\n\nconst IconPickerModal = (props, context) => {\n const {isOpen, onCancel, onConfirm, onClose} = props;\n const {translate} = context;\n\n const [selectedIcon, setSelectedIcon] = useState(null);\n const [displayedIcons, setDisplayedIcons] = useState([]);\n const [currentIndex, setCurrentIndex] = useState(0);\n\n const allIcons = useMemo(() => pipe(values, map(get('iconName')), uniq)(fas), []);\n const {searchValue, searchResults, handleSearch, handleReset} = useIconSearch(allIcons);\n\n const handleCancel = useCallback(() => {\n onCancel();\n }, [onCancel]);\n\n const handleClose = useCallback(() => {\n onClose();\n }, [onClose]);\n\n const handleIconClick = useCallback(\n iconName => () => {\n setSelectedIcon(prevSelectedIcon => (prevSelectedIcon === iconName ? null : iconName));\n },\n []\n );\n\n const loadMoreIcons = useCallback(() => {\n const nextIndex = currentIndex + ICONS_PER_LOAD;\n const newIcons = slice(currentIndex, nextIndex, searchResults);\n setDisplayedIcons(prevIcons => [...prevIcons, ...newIcons]);\n setCurrentIndex(nextIndex);\n }, [currentIndex, searchResults]);\n\n useEffect(() => {\n setDisplayedIcons(() => slice(0, ICONS_PER_LOAD, searchResults));\n setCurrentIndex(ICONS_PER_LOAD);\n }, [searchResults]);\n\n const handleScroll = useCallback(\n event => {\n const {scrollTop, clientHeight, scrollHeight} = event.currentTarget;\n if (scrollHeight - scrollTop <= clientHeight + 1) {\n loadMoreIcons();\n }\n },\n [loadMoreIcons]\n );\n\n const icons = useMemo(\n () =>\n pipe(\n entries,\n map(([index, iconName]) => (\n <SelectIcon\n key={`icon-${index}`}\n size=\"responsive\"\n data-name={`icon-${index}`}\n aria-label={iconName}\n faIcon={iconName}\n onClick={handleIconClick(iconName)}\n options={{isSelected: selectedIcon === iconName}}\n />\n ))\n )(displayedIcons),\n [displayedIcons, selectedIcon, handleIconClick]\n );\n\n const footer = useMemo(() => {\n return {\n cancelButton: {\n onCancel: handleCancel,\n label: translate('cancel')\n },\n confirmButton: {\n onConfirm: () => {\n onConfirm(selectedIcon);\n setSelectedIcon(null);\n onClose();\n },\n label: translate('confirm'),\n iconName: 'plus',\n disabled: selectedIcon === null,\n color: COLORS.cm_primary_blue\n }\n };\n }, [handleCancel, onConfirm, onClose, translate, selectedIcon]);\n\n if (!isOpen) return null;\n\n return (\n <BaseModal\n title={translate('icon_picker_title')}\n description={translate('icon_picker_description')}\n isOpen={isOpen}\n onClose={handleClose}\n onScroll={handleScroll}\n footer={footer}\n headerIcon={{\n name: 'arrows-rotate',\n backgroundColor: '#D6E6FF'\n }}\n >\n <div className={style.iconPicker}>\n {\n <>\n <div className={style.searchWrapper}>\n <SearchForm\n search={{\n placeholder: translate('search_place_holder'),\n value: searchValue,\n onChange: handleSearch\n }}\n onReset={handleReset}\n dataTestId=\"search-input\"\n />\n </div>\n {searchValue && size(searchResults) === 0 ? (\n <div className={style.emptySearchResultContainer}>\n <div className={style.emptySearchResultTitle}>\n {translate('empty_search_result_title', {searchValue})}\n </div>\n <div className={style.emptySearchResultDescription}>\n {translate('empty_search_result_description')}\n </div>\n <div className={style.emptySearchResultClearSearch} onClick={handleReset}>\n {translate('empty_search_result_clear_search')}\n </div>\n </div>\n ) : (\n <div className={style.iconsListWrapper}>{icons}</div>\n )}\n </>\n }\n </div>\n </BaseModal>\n );\n};\n\nIconPickerModal.contextTypes = {\n translate: Provider.childContextTypes.translate\n};\n\nIconPickerModal.propTypes = {\n isOpen: PropTypes.bool,\n onCancel: PropTypes.func,\n onConfirm: PropTypes.func,\n onClose: PropTypes.func\n};\n\nexport default IconPickerModal;\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAK,IAAGC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,QAAO,OAAO;AACtE,OAAOC,SAAS,MAAM,YAAY;AAClC,SAAQC,GAAG,QAAO,kCAAkC;AAEpD,OAAOC,SAAS,MAAM,eAAe;AACrC,OAAOC,UA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AM,EAAEb,SAAS,CAAC+F,IAAI;EACtBjF,QAAQ,EAAEd,SAAS,CAACgG,IAAI;EACxBjF,SAAS,EAAEf,SAAS,CAACgG,IAAI;EACzBhF,OAAO,EAAEhB,SAAS,CAACgG;AACrB,CAAC;AAED,eAAetF,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useMemo","useState","useCallback","useEffect","PropTypes","fas","BaseModal","SelectIcon","Provider","SearchForm","COLORS","style","useIconSearch","ICONS_PER_LOAD","IconPickerModal","props","context","isOpen","onCancel","onConfirm","onClose","translate","allIcons","_pipe","_values","_map","_get","_uniq","selectedIcon","setSelectedIcon","displayedIcons","setDisplayedIcons","_slice","searchValue","searchResults","handleSearch","handleReset","handleCancel","handleClose","handleIconClick","iconName","console","log","prevSelectedIcon","icons","_entries","index","createElement","key","size","faIcon","onClick","options","isSelected","footer","cancelButton","label","confirmButton","disabled","color","cm_primary_blue","title","description","headerIcon","name","backgroundColor","className","iconPicker","searchWrapper","search","placeholder","value","onChange","onReset","dataTestId","_size","emptySearchResultContainer","emptySearchResultTitle","emptySearchResultDescription","emptySearchResultClearSearch","iconsListWrapper","contextTypes","childContextTypes","propTypes","process","env","NODE_ENV","bool","func"],"sources":["../../../src/molecule/icon-picker-modal/index.js"],"sourcesContent":["import React, {useMemo, useState, useCallback, useEffect} from 'react';\nimport PropTypes from 'prop-types';\nimport {fas} from '@fortawesome/pro-solid-svg-icons';\nimport {entries, map, pipe, get, values, slice, size, uniq} from 'lodash/fp';\nimport BaseModal from '../base-modal';\nimport SelectIcon from '../../atom/select-icon';\nimport Provider from '../../atom/provider';\nimport SearchForm from '../search-form';\nimport {COLORS} from '../../variables/colors';\nimport style from './style.css';\nimport useIconSearch from './use-icon-search';\n\nconst ICONS_PER_LOAD = 48;\n\nconst IconPickerModal = (props, context) => {\n const {isOpen, onCancel, onConfirm, onClose} = props;\n const {translate} = context;\n\n const allIcons = useMemo(() => pipe(values, map(get('iconName')), uniq)(fas), []);\n\n const [selectedIcon, setSelectedIcon] = useState(null);\n const [displayedIcons, setDisplayedIcons] = useState(slice(0, ICONS_PER_LOAD, allIcons));\n // const [currentIndex, setCurrentIndex] = useState(ICONS_PER_LOAD);\n\n const {searchValue, searchResults, handleSearch, handleReset} = useIconSearch(allIcons);\n\n const handleCancel = useCallback(() => {\n onCancel();\n }, [onCancel]);\n\n const handleClose = useCallback(() => {\n onClose();\n }, [onClose]);\n\n const handleIconClick = useCallback(\n iconName => () => {\n console.log('in handleIconClick ----->');\n setSelectedIcon(prevSelectedIcon => (prevSelectedIcon === iconName ? null : iconName));\n },\n []\n );\n\n // const loadMoreIcons = useCallback(() => {\n // const nextIndex = currentIndex + ICONS_PER_LOAD;\n // const newIcons = slice(currentIndex, nextIndex, searchResults);\n // setDisplayedIcons(prevIcons => [...prevIcons, ...newIcons]);\n // setCurrentIndex(nextIndex);\n // }, [currentIndex, searchResults]);\n\n useEffect(() => {\n setDisplayedIcons(() => slice(0, ICONS_PER_LOAD, searchResults));\n // setCurrentIndex(ICONS_PER_LOAD);\n }, [searchResults]);\n\n // const handleScroll = useCallback(\n // event => {\n // const {scrollTop, clientHeight, scrollHeight} = event.currentTarget;\n // if (scrollHeight - scrollTop <= clientHeight + 1) {\n // loadMoreIcons();\n // }\n // },\n // [loadMoreIcons]\n // );\n\n const icons = useMemo(\n () =>\n pipe(\n entries,\n map(([index, iconName]) => (\n <SelectIcon\n key={iconName}\n size=\"responsive\"\n data-name={iconName}\n aria-label={iconName}\n faIcon={iconName}\n onClick={handleIconClick(iconName)}\n options={{isSelected: selectedIcon === iconName}}\n />\n ))\n )(displayedIcons),\n [displayedIcons, selectedIcon, handleIconClick]\n );\n\n const footer = useMemo(() => {\n return {\n cancelButton: {\n onCancel: handleCancel,\n label: translate('cancel')\n },\n confirmButton: {\n onConfirm: () => {\n onConfirm(selectedIcon);\n setSelectedIcon(null);\n onClose();\n },\n label: translate('confirm'),\n iconName: 'plus',\n disabled: selectedIcon === null,\n color: COLORS.cm_primary_blue\n }\n };\n }, [handleCancel, onConfirm, onClose, translate, selectedIcon]);\n\n if (!isOpen) return null;\n\n return (\n <BaseModal\n title={translate('icon_picker_title')}\n description={translate('icon_picker_description')}\n isOpen={isOpen}\n onClose={handleClose}\n // onScroll={handleScroll}\n footer={footer}\n headerIcon={{\n name: 'arrows-rotate',\n backgroundColor: '#D6E6FF'\n }}\n >\n <div className={style.iconPicker}>\n <div className={style.searchWrapper}>\n <SearchForm\n search={{\n placeholder: translate('search_place_holder'),\n value: searchValue,\n onChange: handleSearch\n }}\n onReset={handleReset}\n dataTestId=\"search-input\"\n />\n </div>\n {searchValue && size(searchResults) === 0 ? (\n <div className={style.emptySearchResultContainer}>\n <div className={style.emptySearchResultTitle}>\n {translate('empty_search_result_title', {searchValue})}\n </div>\n <div className={style.emptySearchResultDescription}>\n {translate('empty_search_result_description')}\n </div>\n <div className={style.emptySearchResultClearSearch} onClick={handleReset}>\n {translate('empty_search_result_clear_search')}\n </div>\n </div>\n ) : (\n <div className={style.iconsListWrapper}>{icons}</div>\n )}\n </div>\n </BaseModal>\n );\n};\n\nIconPickerModal.contextTypes = {\n translate: Provider.childContextTypes.translate\n};\n\nIconPickerModal.propTypes = {\n isOpen: PropTypes.bool,\n onCancel: PropTypes.func,\n onConfirm: PropTypes.func,\n onClose: PropTypes.func\n};\n\nexport default IconPickerModal;\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAK,IAAGC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,QAAO,OAAO;AACtE,OAAOC,SAAS,MAAM,YAAY;AAClC,SAAQC,GAAG,QAAO,kCAAkC;AAEpD,OAAOC,SAAS,MAAM,eAAe;AACrC,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,OAAOC,QAAQ,MAAM,qBAAqB;AAC1C,OAAOC,UAAU,MAAM,gBAAgB;AACvC,SAAQC,MAAM,QAAO,wBAAwB;AAC7C,OAAOC,KAAK,MAAM,aAAa;AAC/B,OA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4BAA6B;IAAC5B,OAAO,EAAEf;EAAY,GACtEf,SAAS,CAAC,kCAAkC,CAC1C,CACF,CAAC,gBAENtB,KAAA,CAAAgD,aAAA;IAAKmB,SAAS,EAAEvD,KAAK,CAACqE;EAAiB,GAAEpC,KAAW,CAEnD,CACI,CAAC;AAEhB,CAAC;AAED9B,eAAe,CAACmE,YAAY,GAAG;EAC7B5D,SAAS,EAAEb,QAAQ,CAAC0E,iBAAiB,CAAC7D;AACxC,CAAC;AAEDP,eAAe,CAACqE,SAAS,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAG;EAC1BrE,MAAM,EAAEb,SAAS,CAACmF,IAAI;EACtBrE,QAAQ,EAAEd,SAAS,CAACoF,IAAI;EACxBrE,SAAS,EAAEf,SAAS,CAACoF,IAAI;EACzBpE,OAAO,EAAEhB,SAAS,CAACoF;AACrB,CAAC;AAED,eAAe1E,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QuickFiltersProps } from './types';
|
|
3
|
+
export declare const handleScroll: (direction: number, listRef: React.RefObject<HTMLDivElement>) => void;
|
|
4
|
+
declare const QuickFilters: {
|
|
5
|
+
({ primaryOption, filterOptions, filterButton, nextFilterAriaLabel, previousFilterAriaLabel, filterOptionsAriaLabel }: QuickFiltersProps): JSX.Element;
|
|
6
|
+
propTypes: {
|
|
7
|
+
primaryOption: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
8
|
+
defaultLabel: import("prop-types").Requireable<string>;
|
|
9
|
+
defaultValue: import("prop-types").Requireable<string>;
|
|
10
|
+
defaultIconName: import("prop-types").Requireable<string>;
|
|
11
|
+
defaultSelected: import("prop-types").Requireable<boolean>;
|
|
12
|
+
defaultAriaLabel: import("prop-types").Requireable<string>;
|
|
13
|
+
onDefaultClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
14
|
+
}>>;
|
|
15
|
+
nextFilterAriaLabel: import("prop-types").Requireable<string>;
|
|
16
|
+
previousFilterAriaLabel: import("prop-types").Requireable<string>;
|
|
17
|
+
filterOptionsAriaLabel: import("prop-types").Requireable<string>;
|
|
18
|
+
filterOptions: import("prop-types").Requireable<(import("prop-types").InferProps<{
|
|
19
|
+
iconName: import("prop-types").Requireable<string>;
|
|
20
|
+
label: import("prop-types").Requireable<string>;
|
|
21
|
+
value: import("prop-types").Requireable<string>;
|
|
22
|
+
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
23
|
+
selected: import("prop-types").Requireable<boolean>;
|
|
24
|
+
ariaLabel: import("prop-types").Requireable<string>;
|
|
25
|
+
}> | null | undefined)[]>;
|
|
26
|
+
filterButton: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
27
|
+
type: import("prop-types").Requireable<string>;
|
|
28
|
+
usage: import("prop-types").Requireable<string>;
|
|
29
|
+
label: import("prop-types").Requireable<string>;
|
|
30
|
+
content: import("prop-types").Requireable<import("prop-types").ReactNodeLike>;
|
|
31
|
+
'aria-label': import("prop-types").Requireable<string>;
|
|
32
|
+
tooltipText: import("prop-types").Requireable<string>;
|
|
33
|
+
tooltipPlacement: import("prop-types").Requireable<string>;
|
|
34
|
+
'data-name': import("prop-types").Requireable<string>;
|
|
35
|
+
'data-testid': import("prop-types").Requireable<string>;
|
|
36
|
+
icon: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
37
|
+
position: import("prop-types").Requireable<string>;
|
|
38
|
+
type: import("prop-types").Requireable<string>;
|
|
39
|
+
faIcon: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
40
|
+
name: import("prop-types").Validator<string>;
|
|
41
|
+
color: import("prop-types").Requireable<string>;
|
|
42
|
+
backgroundColor: import("prop-types").Requireable<string>;
|
|
43
|
+
size: import("prop-types").Requireable<number>;
|
|
44
|
+
customStyle: import("prop-types").Requireable<{
|
|
45
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
}>>;
|
|
48
|
+
}>>;
|
|
49
|
+
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
50
|
+
link: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
51
|
+
href: import("prop-types").Requireable<string>;
|
|
52
|
+
download: import("prop-types").Requireable<boolean>;
|
|
53
|
+
target: import("prop-types").Requireable<string>;
|
|
54
|
+
}>>;
|
|
55
|
+
hoverBackgroundColor: import("prop-types").Requireable<string>;
|
|
56
|
+
hoverColor: import("prop-types").Requireable<string>;
|
|
57
|
+
disabled: import("prop-types").Requireable<boolean>;
|
|
58
|
+
className: import("prop-types").Requireable<string>;
|
|
59
|
+
customStyle: import("prop-types").Requireable<{
|
|
60
|
+
[x: string]: NonNullable<string | number | null | undefined> | null | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
useTitle: import("prop-types").Requireable<boolean>;
|
|
63
|
+
customLabelClassName: import("prop-types").Requireable<string>;
|
|
64
|
+
}>>;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export default QuickFilters;
|
|
68
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/quick-filters/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAO5D,OAAO,EAAC,iBAAiB,EAAY,MAAM,SAAS,CAAC;AAIrD,eAAO,MAAM,YAAY,cAAe,MAAM,WAAW,MAAM,SAAS,CAAC,cAAc,CAAC,SAOvF,CAAC;AA0BF,QAAA,MAAM,YAAY;2HAOf,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8GnB,CAAC;AAGF,eAAe,YAAY,CAAC"}
|