@ntbjs/react-components 2.0.2-rc.11 → 2.0.2-rc.13
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/build/data/Badge/Badge.js +6 -6
- package/build/data/Badge/Badge.js.map +1 -1
- package/build/data/Badge/Badge.styled.js +11 -10
- package/build/data/Badge/Badge.styled.js.map +1 -1
- package/build/inputs/MultiSelect/MultiSelect.js +204 -209
- package/build/inputs/MultiSelect/MultiSelect.js.map +1 -1
- package/build/inputs/MultiSelect/MultiSelect.styled.js +38 -187
- package/build/inputs/MultiSelect/MultiSelect.styled.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.js +8 -8
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.styled.js +2 -2
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.styled.js.map +1 -1
- package/package.json +1 -1
|
@@ -37,17 +37,17 @@ const Badge = React__default.forwardRef(function Badge({
|
|
|
37
37
|
$backgroundColors: backgroundColors,
|
|
38
38
|
$colors: colors,
|
|
39
39
|
$elevated: elevated,
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
fontSize: fontSize,
|
|
41
|
+
fontWeight: fontWeight,
|
|
42
42
|
$lineHeight: lineHeight,
|
|
43
43
|
$active: active,
|
|
44
44
|
$error: error,
|
|
45
45
|
$warning: warning,
|
|
46
|
-
$
|
|
46
|
+
$elevatedverticalPadding: verticalPadding,
|
|
47
47
|
$horizontalPadding: horizontalPadding,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
height: height,
|
|
49
|
+
minHeight: minHeight,
|
|
50
|
+
width: width,
|
|
51
51
|
$minWidth: minWidth
|
|
52
52
|
}, badgeIcon && React__default.createElement(BadgeIcon, {
|
|
53
53
|
$useGutter: !!badgeContent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sources":["../../../src/components/data/Badge/Badge.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport * as S from './Badge.styled';\n\n/**\n * Badges show a bubble containing a `number` or a `string`. It may be used by itself or with children passed as props\n * (to display a badge on top of an icon, for example, pass the icon as the child).\n *\n * If the badge content is passed as a `float`, it will be rounded up to the nearest `integer`,\n * and if the number is higher than 1 000 or 1 000 000 it will be abbreviated to for example \"1.4K\" or \"1.4M\" respectively.\n * If you need to display a `float` instead of a rounded `integer`, pass it as a `string` instead (e.g. \"1,4\").\n *\n * ### Import\n *\n * ``` js\n * import { Badge } from '@ntbjs/react-components/data'\n * // or\n * import Badge from '@ntbjs/react-components/data/Badge'\n * ```\n * ## Props\n * ```\n * Pass `badgeIcon={<svg></svg>}` to display an icon.\n * Pass a number or string to the badgeContent to display it alongside the icon.\n * Pass `align={\"left\"}`or `align={\"center\"}` to align content.\n * Pass `elevated={true}` to display the badge on top of the children\n * Pass `active={true}` to reflect the active status of the badge\n * Pass `error={true}` to reflect the error status of the badge\n * Pass `warning={true}` to reflect the warning status of the badge\n * Pass `fontSize={15}` to set the font size of the badge in pixel\n * Pass `fontWeight={500}` to set the font weight of the badge\n * Pass `lineHeight={12}` to set the line height of the badge in pixel\n * Pass `colors={[#ffffff, #000000]}` to set the font color of the badge\n * Pass `backgroundColors={[#ffffff, #000000]}` to set the background color of the badge\n * Pass `verticalPadding={15}` to set the bottom and top padding of the badge in pixel\n * Pass `horizontalPadding={20}` to set the left and right padding of the badge in pixel\n * Pass `height={24}` to set the height of the badge in pixel\n * Pass `minHeight={24}` to set the minimum height of the badge in pixel\n * Pass `width={50}` to set the width of the badge in pixel\n * Pass `minWidth={32}` to set the minimum width of the badge in pixel\n * ```\n */\nconst Badge = React.forwardRef(function Badge(\n {\n badgeContent,\n badgeIcon,\n children,\n elevated,\n fontSize,\n fontWeight,\n lineHeight,\n active,\n error,\n warning,\n backgroundColors,\n colors,\n verticalPadding,\n horizontalPadding,\n height,\n minHeight,\n width,\n minWidth,\n ...props\n },\n forwardedRef\n) {\n if (typeof badgeContent === 'number') {\n badgeContent = Intl.NumberFormat('en', { notation: 'compact' }).format(badgeContent);\n }\n\n return (\n <S.Badge ref={forwardedRef} $elevated={elevated} $hasChildren={Boolean(children)} {...props}>\n {children && <S.BadgeChildrenContainer>{children}</S.BadgeChildrenContainer>}\n {(badgeIcon || badgeContent) && (\n <S.BadgeLabel\n $backgroundColors={backgroundColors}\n $colors={colors}\n $elevated={elevated}\n
|
|
1
|
+
{"version":3,"file":"Badge.js","sources":["../../../src/components/data/Badge/Badge.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport * as S from './Badge.styled';\n\n/**\n * Badges show a bubble containing a `number` or a `string`. It may be used by itself or with children passed as props\n * (to display a badge on top of an icon, for example, pass the icon as the child).\n *\n * If the badge content is passed as a `float`, it will be rounded up to the nearest `integer`,\n * and if the number is higher than 1 000 or 1 000 000 it will be abbreviated to for example \"1.4K\" or \"1.4M\" respectively.\n * If you need to display a `float` instead of a rounded `integer`, pass it as a `string` instead (e.g. \"1,4\").\n *\n * ### Import\n *\n * ``` js\n * import { Badge } from '@ntbjs/react-components/data'\n * // or\n * import Badge from '@ntbjs/react-components/data/Badge'\n * ```\n * ## Props\n * ```\n * Pass `badgeIcon={<svg></svg>}` to display an icon.\n * Pass a number or string to the badgeContent to display it alongside the icon.\n * Pass `align={\"left\"}`or `align={\"center\"}` to align content.\n * Pass `elevated={true}` to display the badge on top of the children\n * Pass `active={true}` to reflect the active status of the badge\n * Pass `error={true}` to reflect the error status of the badge\n * Pass `warning={true}` to reflect the warning status of the badge\n * Pass `fontSize={15}` to set the font size of the badge in pixel\n * Pass `fontWeight={500}` to set the font weight of the badge\n * Pass `lineHeight={12}` to set the line height of the badge in pixel\n * Pass `colors={[#ffffff, #000000]}` to set the font color of the badge\n * Pass `backgroundColors={[#ffffff, #000000]}` to set the background color of the badge\n * Pass `verticalPadding={15}` to set the bottom and top padding of the badge in pixel\n * Pass `horizontalPadding={20}` to set the left and right padding of the badge in pixel\n * Pass `height={24}` to set the height of the badge in pixel\n * Pass `minHeight={24}` to set the minimum height of the badge in pixel\n * Pass `width={50}` to set the width of the badge in pixel\n * Pass `minWidth={32}` to set the minimum width of the badge in pixel\n * ```\n */\nconst Badge = React.forwardRef(function Badge(\n {\n badgeContent,\n badgeIcon,\n children,\n elevated,\n fontSize,\n fontWeight,\n lineHeight,\n active,\n error,\n warning,\n backgroundColors,\n colors,\n verticalPadding,\n horizontalPadding,\n height,\n minHeight,\n width,\n minWidth,\n ...props\n },\n forwardedRef\n) {\n if (typeof badgeContent === 'number') {\n badgeContent = Intl.NumberFormat('en', { notation: 'compact' }).format(badgeContent);\n }\n\n return (\n <S.Badge ref={forwardedRef} $elevated={elevated} $hasChildren={Boolean(children)} {...props}>\n {children && <S.BadgeChildrenContainer>{children}</S.BadgeChildrenContainer>}\n {(badgeIcon || badgeContent) && (\n <S.BadgeLabel\n $backgroundColors={backgroundColors}\n $colors={colors}\n $elevated={elevated}\n fontSize={fontSize}\n fontWeight={fontWeight}\n $lineHeight={lineHeight}\n $active={active}\n $error={error}\n $warning={warning}\n $elevatedverticalPadding={verticalPadding}\n $horizontalPadding={horizontalPadding}\n height={height}\n minHeight={minHeight}\n width={width}\n $minWidth={minWidth}\n >\n {badgeIcon && <S.BadgeIcon $useGutter={!!badgeContent}>{badgeIcon}</S.BadgeIcon>}\n {badgeContent}\n </S.BadgeLabel>\n )}\n </S.Badge>\n );\n});\n\nBadge.propTypes = {\n /**\n * An Icon to show in the badge alongside with a text\n */\n badgeIcon: PropTypes.node,\n\n /**\n * Content to be showed in the badge – e.g. number of results.\n */\n badgeContent: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.number,\n PropTypes.func,\n PropTypes.element\n ]),\n\n /**\n * The element(s) for which the badge will be displayed – e.g. an icon or a text.\n */\n children: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),\n\n /**\n * Whether the badge should be displayed in an elevated position on top of the child element(s) or not.\n */\n elevated: PropTypes.bool,\n\n /**\n * Whether the element is active or not (e.g. the currently selected menu item). This changes the color of the badge.\n */\n active: PropTypes.bool,\n\n /**\n * There is an error present – 'error be prioritized over warnings if both are set to `true`.\n */\n error: PropTypes.bool,\n\n /**\n * There is a warning present.\n */\n warning: PropTypes.bool,\n /**\n * Font size for the badge\n */\n fontSize: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /**\n * Font weight for the badge\n */\n fontWeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /**\n * Line weight for the badge\n */\n lineHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /**\n * Colors of the font in the manner of [darkThemeColor, lightThemeColor]\n */\n colors: PropTypes.arrayOf(PropTypes.string),\n /**\n * Background colors for the badge in the manner of [darkThemeColor, lightThemeColor]\n */\n backgroundColors: PropTypes.arrayOf(PropTypes.string),\n /**\n * Top and bottom padding for the badge\n */\n verticalPadding: PropTypes.number,\n /**\n * Left and right padding for the badge\n */\n horizontalPadding: PropTypes.number,\n /**\n * Height of the badge\n */\n height: PropTypes.number,\n /**\n * Minimum height of the badge\n */\n minHeight: PropTypes.number,\n /**\n * Width of the badge\n */\n width: PropTypes.number,\n /**\n * Minimum width of the badge\n */\n minWidth: PropTypes.number\n};\n\nBadge.defaultProps = {\n elevated: false,\n active: false,\n error: false,\n warning: false,\n badgeIcon: null,\n fontWeight: 'normal',\n lineHeight: 'normal'\n};\n\nexport default Badge;\n"],"names":["Badge","React","forwardRef","badgeContent","badgeIcon","children","elevated","fontSize","fontWeight","lineHeight","active","error","warning","backgroundColors","colors","verticalPadding","horizontalPadding","height","minHeight","width","minWidth","props","forwardedRef","Intl","NumberFormat","notation","format","createElement","S","_extends","ref","$elevated","$hasChildren","Boolean","$backgroundColors","$colors","$lineHeight","$active","$error","$warning","$elevatedverticalPadding","$horizontalPadding","$minWidth","$useGutter","propTypes","process","env","NODE_ENV","PropTypes","node","oneOfType","string","number","func","element","bool","arrayOf","defaultProps"],"mappings":";;;;;AAyCMA,MAAAA,KAAK,GAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,KAAKA,CAC3C;EACEG,YAAY;EACZC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,UAAU;EACVC,UAAU;EACVC,MAAM;EACNC,KAAK;EACLC,OAAO;EACPC,gBAAgB;EAChBC,MAAM;EACNC,eAAe;EACfC,iBAAiB;EACjBC,MAAM;EACNC,SAAS;EACTC,KAAK;EACLC,QAAQ;EACR,GAAGC,KAAAA;AACL,CAAC,EACDC,YAAY,EACZ;AACA,EAAA,IAAI,OAAOnB,YAAY,KAAK,QAAQ,EAAE;AACpCA,IAAAA,YAAY,GAAGoB,IAAI,CAACC,YAAY,CAAC,IAAI,EAAE;AAAEC,MAAAA,QAAQ,EAAE,SAAA;AAAU,KAAC,CAAC,CAACC,MAAM,CAACvB,YAAY,CAAC,CAAA;AACtF,GAAA;EAEA,OACEF,cAAA,CAAA0B,aAAA,CAACC,OAAO,EAAAC,QAAA,CAAA;AAACC,IAAAA,GAAG,EAAER,YAAa;AAACS,IAAAA,SAAS,EAAEzB,QAAS;IAAC0B,YAAY,EAAEC,OAAO,CAAC5B,QAAQ,CAAA;GAAOgB,EAAAA,KAAK,CACxFhB,EAAAA,QAAQ,IAAIJ,cAAA,CAAA0B,aAAA,CAACC,sBAAwB,EAAEvB,IAAAA,EAAAA,QAAmC,CAAC,EAC3E,CAACD,SAAS,IAAID,YAAY,KACzBF,cAAA,CAAA0B,aAAA,CAACC,UAAY,EAAA;AACXM,IAAAA,iBAAiB,EAAErB,gBAAiB;AACpCsB,IAAAA,OAAO,EAAErB,MAAO;AAChBiB,IAAAA,SAAS,EAAEzB,QAAS;AACpBC,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAA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,SAAS,CAACG,MAAM,CAAC,CAAC;AAInE3C,EAAAA,UAAU,EAAEwC,SAAS,CAACE,SAAS,CAAC,CAACF,SAAS,CAACI,MAAM,EAAEJ,SAAS,CAACG,MAAM,CAAC,CAAC;AAIrE1C,EAAAA,UAAU,EAAEuC,SAAS,CAACE,SAAS,CAAC,CAACF,SAAS,CAACI,MAAM,EAAEJ,SAAS,CAACG,MAAM,CAAC,CAAC;EAIrErC,MAAM,EAAEkC,SAAS,CAACQ,OAAO,CAACR,SAAS,CAACG,MAAM,CAAC;EAI3CtC,gBAAgB,EAAEmC,SAAS,CAACQ,OAAO,CAACR,SAAS,CAACG,MAAM,CAAC;EAIrDpC,eAAe,EAAEiC,SAAS,CAACI,MAAM;EAIjCpC,iBAAiB,EAAEgC,SAAS,CAACI,MAAM;EAInCnC,MAAM,EAAE+B,SAAS,CAACI,MAAM;EAIxBlC,SAAS,EAAE8B,SAAS,CAACI,MAAM;EAI3BjC,KAAK,EAAE6B,SAAS,CAACI,MAAM;EAIvBhC,QAAQ,EAAE4B,SAAS,CAACI,MAAAA;AACtB,CAAC,GAAA,EAAA,CAAA;AAEDpD,KAAK,CAACyD,YAAY,GAAG;AACnBnD,EAAAA,QAAQ,EAAE,KAAK;AACfI,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,KAAK,EAAE,KAAK;AACZC,EAAAA,OAAO,EAAE,KAAK;AACdR,EAAAA,SAAS,EAAE,IAAI;AACfI,EAAAA,UAAU,EAAE,QAAQ;AACpBC,EAAAA,UAAU,EAAE,QAAA;AACd,CAAC;;;;"}
|
|
@@ -33,35 +33,36 @@ const BadgeLabel = styled.span.withConfig({
|
|
|
33
33
|
box-sizing: border-box;
|
|
34
34
|
|
|
35
35
|
font-size: ${props => {
|
|
36
|
-
if (props
|
|
37
|
-
return `${props
|
|
36
|
+
if (props.fontSize) {
|
|
37
|
+
return `${props.fontSize}px`;
|
|
38
38
|
} else {
|
|
39
|
-
return props
|
|
39
|
+
return props.elevated ? '0.625rem' : '0.750rem';
|
|
40
40
|
}
|
|
41
41
|
}};
|
|
42
|
-
font-weight: ${props => props
|
|
42
|
+
font-weight: ${props => props.fontWeight ? props.fontWeight : 'normal'};
|
|
43
43
|
line-height: ${props => props.$lineHeight ? `${props.$lineHeight}px` : 'normal'};
|
|
44
|
-
height: ${props => props
|
|
44
|
+
height: ${props => props.height ? `${props.height}px` : 'fit-content'};
|
|
45
45
|
letter-spacing: 0.32px;
|
|
46
46
|
margin-left: ${props => props.$elevated ? '15px' : 'auto'};
|
|
47
47
|
position: ${props => props.$elevated ? 'absolute' : 'initial'};
|
|
48
48
|
right: 0;
|
|
49
49
|
transform: ${props => props.$elevated ? 'translate(33%, -8px)' : 'initial'};
|
|
50
50
|
|
|
51
|
-
${props => props
|
|
52
|
-
width: ${props
|
|
51
|
+
${props => props.width ? css`
|
|
52
|
+
width: ${props.width}px;
|
|
53
53
|
` : null}
|
|
54
54
|
|
|
55
55
|
${props => props.$minWidth ? css`
|
|
56
56
|
min-width: ${props.$minWidth}px;
|
|
57
57
|
` : null}
|
|
58
58
|
|
|
59
|
-
${props => props
|
|
60
|
-
min-height: ${props
|
|
59
|
+
${props => props.minHeight ? css`
|
|
60
|
+
min-height: ${props.minHeight}px;
|
|
61
61
|
` : null}
|
|
62
|
+
|
|
62
63
|
|
|
63
64
|
${props => {
|
|
64
|
-
const verticalPadding = props
|
|
65
|
+
const verticalPadding = props.verticalPadding ? `${props.verticalPadding}px` : props.$elevated ? '4px' : '6px';
|
|
65
66
|
const horizontalPadding = props.$horizontalPadding ? `${props.$horizontalPadding}px` : props.$elevated ? '7px' : '10px';
|
|
66
67
|
return css`
|
|
67
68
|
padding: ${verticalPadding} ${horizontalPadding};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.styled.js","sources":["../../../src/components/data/Badge/Badge.styled.js"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { applyDefaultTheme } from '../../../utils/defaultTheme';\n\nconst shouldForwardProp = prop => {\n return prop !== 'theme' && !prop.startsWith('$');\n};\n\nexport const Badge = styled.span\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n align-content: center;\n display: ${props => (props.$elevated || !props.$hasChildren ? 'inline-flex' : 'flex')};\n font-family: ${props => props.theme.primaryFontFamily};\n font-size: 1rem;\n font-weight: 500;\n min-height: 24px;\n position: relative;\n width: ${props => (props.$elevated ? 'fit-content' : 'initial')};\n`;\n\nexport const BadgeChildrenContainer = styled.span\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n align-self: center;\n height: fit-content;\n margin-right: 8px;\n`;\n\nexport const BadgeLabel = styled.span\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n border-radius: ${props => (props.$elevated ? '12px' : '14px')};\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n\n font-size: ${props => {\n if (props.$fontSize) {\n return `${props.$fontSize}px`;\n } else {\n return props.$elevated ? '0.625rem' : '0.750rem';\n }\n }};\n font-weight: ${props => (props.$fontWeight ? props.$fontWeight : 'normal')};\n line-height: ${props => (props.$lineHeight ? `${props.$lineHeight}px` : 'normal')};\n height: ${props => (props.$height ? `${props.$height}px` : 'fit-content')};\n letter-spacing: 0.32px;\n margin-left: ${props => (props.$elevated ? '15px' : 'auto')};\n position: ${props => (props.$elevated ? 'absolute' : 'initial')};\n right: 0;\n transform: ${props => (props.$elevated ? 'translate(33%, -8px)' : 'initial')};\n\n ${props =>\n props.$width\n ? css`\n width: ${props.$width}px;\n `\n : null}\n\n ${props =>\n props.$minWidth\n ? css`\n min-width: ${props.$minWidth}px;\n `\n : null}\n\n ${props =>\n props.$minHeight\n ? css`\n min-height: ${props.$minHeight}px;\n `\n : null}\n\n ${props => {\n const verticalPadding = props.$verticalPadding\n ? `${props.$verticalPadding}px`\n : props.$elevated\n ? '4px'\n : '6px';\n const horizontalPadding = props.$horizontalPadding\n ? `${props.$horizontalPadding}px`\n : props.$elevated\n ? '7px'\n : '10px';\n return css`\n padding: ${verticalPadding} ${horizontalPadding};\n `;\n }}\n\n ${props =>\n props.theme.themeProp(\n 'background',\n () => {\n const active = props.$active;\n const error = props.$error;\n const warning = props.$warning;\n\n const defaultBgColor = props?.backgroundColors?.[0] ?? props.theme.getColor('gray-600');\n\n switch (true) {\n case !error && !warning && !active:\n return defaultBgColor;\n\n case !error && !warning && active:\n return props.theme.getColor('gray-700');\n\n case error && active:\n return props.theme.getColor('red-500');\n\n case error:\n return props.theme.getColor('red-200');\n\n case warning && active:\n return props.theme.getColor('signal-yellow-500');\n\n case warning:\n return props.theme.getColor('signal-yellow-400');\n\n default:\n return props.theme.getColor('gray-600');\n }\n },\n () => {\n const active = props.$active;\n const error = props.$error;\n const warning = props.$warning;\n\n const defaultBgColor = props?.$backgroundColors?.[1] ?? props.theme.getColor('gray-200');\n\n switch (true) {\n case !error && !warning && !active:\n return defaultBgColor;\n\n case !error && !warning && active:\n return props.theme.getColor('white');\n\n case error && active:\n return props.theme.getColor('red-500');\n\n case error:\n return props.theme.getColor('red-200');\n\n case warning && active:\n return props.theme.getColor('signal-yellow-500');\n\n case warning:\n return props.theme.getColor('signal-yellow-400');\n\n default:\n return props.theme.getColor('gray-200');\n }\n }\n )}\n\n ${props =>\n props.theme.themeProp(\n 'color',\n () => {\n const defaultColor = props?.$colors?.[0] ?? props.theme.getColor('white');\n if ((props.$warning && !props.$error) || (props.error && !props.$active)) {\n return props.theme.getColor('gray-900');\n } else {\n return defaultColor;\n }\n },\n () => {\n const defaultColor = props?.$colors?.[1] ?? props.theme.getColor('gray-900');\n if (props.$error && props.$active) {\n return props.theme.getColor('white');\n } else {\n return defaultColor;\n }\n }\n )}\n`;\n\nexport const BadgeIcon = styled.span\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n display: flex;\n align-items: center;\n margin-right: ${props => (props.$useGutter ? '4px' : 0)};\n svg {\n height: 12px;\n }\n`;\n"],"names":["shouldForwardProp","prop","startsWith","Badge","styled","span","withConfig","attrs","applyDefaultTheme","props","$elevated","$hasChildren","theme","primaryFontFamily","BadgeChildrenContainer","BadgeLabel","$fontSize","$fontWeight","$lineHeight","$height","$width","css","$minWidth","$minHeight","verticalPadding","$verticalPadding","horizontalPadding","$horizontalPadding","themeProp","active","$active","error","$error","warning","$warning","defaultBgColor","backgroundColors","getColor","$backgroundColors","defaultColor","$colors","BadgeIcon","$useGutter"],"mappings":";;;AAGA,MAAMA,iBAAiB,GAAGC,IAAI,IAAI;EAChC,OAAOA,IAAI,KAAK,OAAO,IAAI,CAACA,IAAI,CAACC,UAAU,CAAC,GAAG,CAAC,CAAA;AAClD,CAAC,CAAA;AAEM,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAC7BC,UAAU,CAAC;AACVN,EAAAA,iBAAAA;AACF,CAAC,CAAC,CACDO,KAAK,CAACC,iBAAiB,CAAC,CAAA;AAC3B;AACA,WAAA,EAAaC,KAAK,IAAKA,KAAK,CAACC,SAAS,IAAI,CAACD,KAAK,CAACE,YAAY,GAAG,aAAa,GAAG,MAAO,CAAA;AACvF,eAAA,EAAiBF,KAAK,IAAIA,KAAK,CAACG,KAAK,CAACC,iBAAiB,CAAA;AACvD;AACA;AACA;AACA;AACA,SAAWJ,EAAAA,KAAK,IAAKA,KAAK,CAACC,SAAS,GAAG,aAAa,GAAG,SAAU,CAAA;AACjE,EAAC;AAEM,MAAMI,sBAAsB,GAAGV,MAAM,CAACC,IAAI,CAC9CC,UAAU,CAAC;AACVN,EAAAA,iBAAAA;AACF,CAAC,CAAC,CACDO,KAAK,CAACC,iBAAiB,CAAC,CAAA;AAC3B;AACA;AACA;AACA,EAAC;AAEM,MAAMO,UAAU,GAAGX,MAAM,CAACC,IAAI,CAClCC,UAAU,CAAC;AACVN,EAAAA,iBAAAA;AACF,CAAC,CAAC,CACDO,KAAK,CAACC,iBAAiB,CAAC,CAAA;AAC3B,iBAAmBC,EAAAA,KAAK,IAAKA,KAAK,CAAC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E,EAAA,IAAI5B,KAAK,CAACuB,MAAM,IAAIvB,KAAK,CAACqB,OAAO,EAAE;AACjC,IAAA,OAAOrB,KAAK,CAACG,KAAK,CAACyB,QAAQ,CAAC,OAAO,CAAC,CAAA;AACtC,GAAC,MAAM;AACL,IAAA,OAAOE,YAAY,CAAA;AACrB,GAAA;AACF,CACF,CAAC,CAAA;AACP,EAAC;AAEM,MAAME,SAAS,GAAGrC,MAAM,CAACC,IAAI,CACjCC,UAAU,CAAC;AACVN,EAAAA,iBAAAA;AACF,CAAC,CAAC,CACDO,KAAK,CAACC,iBAAiB,CAAC,CAAA;AAC3B;AACA;AACA,gBAAkBC,EAAAA,KAAK,IAAKA,KAAK,CAACiC,UAAU,GAAG,KAAK,GAAG,CAAE,CAAA;AACzD;AACA;AACA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"Badge.styled.js","sources":["../../../src/components/data/Badge/Badge.styled.js"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { applyDefaultTheme } from '../../../utils/defaultTheme';\n\nconst shouldForwardProp = prop => {\n return prop !== 'theme' && !prop.startsWith('$');\n};\n\nexport const Badge = styled.span\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n align-content: center;\n display: ${props => (props.$elevated || !props.$hasChildren ? 'inline-flex' : 'flex')};\n font-family: ${props => props.theme.primaryFontFamily};\n font-size: 1rem;\n font-weight: 500;\n min-height: 24px;\n position: relative;\n width: ${props => (props.$elevated ? 'fit-content' : 'initial')};\n`;\n\nexport const BadgeChildrenContainer = styled.span\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n align-self: center;\n height: fit-content;\n margin-right: 8px;\n`;\n\nexport const BadgeLabel = styled.span\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n border-radius: ${props => (props.$elevated ? '12px' : '14px')};\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n\n font-size: ${props => {\n if (props.fontSize) {\n return `${props.fontSize}px`;\n } else {\n return props.elevated ? '0.625rem' : '0.750rem';\n }\n }};\n font-weight: ${props => (props.fontWeight ? props.fontWeight : 'normal')};\n line-height: ${props => (props.$lineHeight ? `${props.$lineHeight}px` : 'normal')};\n height: ${props => (props.height ? `${props.height}px` : 'fit-content')};\n letter-spacing: 0.32px;\n margin-left: ${props => (props.$elevated ? '15px' : 'auto')};\n position: ${props => (props.$elevated ? 'absolute' : 'initial')};\n right: 0;\n transform: ${props => (props.$elevated ? 'translate(33%, -8px)' : 'initial')};\n\n ${props =>\n props.width\n ? css`\n width: ${props.width}px;\n `\n : null}\n\n ${props =>\n props.$minWidth\n ? css`\n min-width: ${props.$minWidth}px;\n `\n : null}\n\n ${props =>\n props.minHeight\n ? css`\n min-height: ${props.minHeight}px;\n `\n : null}\n \n\n ${props => {\n const verticalPadding = props.verticalPadding\n ? `${props.verticalPadding}px`\n : props.$elevated\n ? '4px'\n : '6px';\n const horizontalPadding = props.$horizontalPadding\n ? `${props.$horizontalPadding}px`\n : props.$elevated\n ? '7px'\n : '10px';\n return css`\n padding: ${verticalPadding} ${horizontalPadding};\n `;\n }}\n\n ${props =>\n props.theme.themeProp(\n 'background',\n () => {\n const active = props.$active;\n const error = props.$error;\n const warning = props.$warning;\n\n const defaultBgColor = props?.backgroundColors?.[0] ?? props.theme.getColor('gray-600');\n\n switch (true) {\n case !error && !warning && !active:\n return defaultBgColor;\n\n case !error && !warning && active:\n return props.theme.getColor('gray-700');\n\n case error && active:\n return props.theme.getColor('red-500');\n\n case error:\n return props.theme.getColor('red-200');\n\n case warning && active:\n return props.theme.getColor('signal-yellow-500');\n\n case warning:\n return props.theme.getColor('signal-yellow-400');\n\n default:\n return props.theme.getColor('gray-600');\n }\n },\n () => {\n const active = props.$active;\n const error = props.$error;\n const warning = props.$warning;\n\n const defaultBgColor = props?.$backgroundColors?.[1] ?? props.theme.getColor('gray-200');\n\n switch (true) {\n case !error && !warning && !active:\n return defaultBgColor;\n\n case !error && !warning && active:\n return props.theme.getColor('white');\n\n case error && active:\n return props.theme.getColor('red-500');\n\n case error:\n return props.theme.getColor('red-200');\n\n case warning && active:\n return props.theme.getColor('signal-yellow-500');\n\n case warning:\n return props.theme.getColor('signal-yellow-400');\n\n default:\n return props.theme.getColor('gray-200');\n }\n }\n )}\n\n ${props =>\n props.theme.themeProp(\n 'color',\n () => {\n const defaultColor = props?.$colors?.[0] ?? props.theme.getColor('white');\n if ((props.$warning && !props.$error) || (props.error && !props.$active)) {\n return props.theme.getColor('gray-900');\n } else {\n return defaultColor;\n }\n },\n () => {\n const defaultColor = props?.$colors?.[1] ?? props.theme.getColor('gray-900');\n if (props.$error && props.$active) {\n return props.theme.getColor('white');\n } else {\n return defaultColor;\n }\n }\n )}\n`;\n\nexport const BadgeIcon = styled.span\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n display: flex;\n align-items: center;\n margin-right: ${props => (props.$useGutter ? '4px' : 0)};\n svg {\n height: 12px;\n }\n`;\n"],"names":["shouldForwardProp","prop","startsWith","Badge","styled","span","withConfig","attrs","applyDefaultTheme","props","$elevated","$hasChildren","theme","primaryFontFamily","BadgeChildrenContainer","BadgeLabel","fontSize","elevated","fontWeight","$lineHeight","height","width","css","$minWidth","minHeight","verticalPadding","horizontalPadding","$horizontalPadding","themeProp","active","$active","error","$error","warning","$warning","defaultBgColor","backgroundColors","getColor","$backgroundColors","defaultColor","$colors","BadgeIcon","$useGutter"],"mappings":";;;AAGA,MAAMA,iBAAiB,GAAGC,IAAI,IAAI;EAChC,OAAOA,IAAI,KAAK,OAAO,IAAI,CAACA,IAAI,CAACC,UAAU,CAAC,GAAG,CAAC,CAAA;AAClD,CAAC,CAAA;AAEM,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAC7BC,UAAU,CAAC;AACVN,EAAAA,iBAAAA;AACF,CAAC,CAAC,CACDO,KAAK,CAACC,iBAAiB,CAAC,CAAA;AAC3B;AACA,WAAA,EAAaC,KAAK,IAAKA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AACG,KAAK,CAACgB,SAAS,CACnB,OAAO,EACP,MAAM;AACJ,EAAA,MAAMW,YAAY,GAAG9B,KAAK,EAAE+B,OAAO,GAAG,CAAC,CAAC,IAAI/B,KAAK,CAACG,KAAK,CAACyB,QAAQ,CAAC,OAAO,CAAC,CAAA;AACzE,EAAA,IAAK5B,KAAK,CAACyB,QAAQ,IAAI,CAACzB,KAAK,CAACuB,MAAM,IAAMvB,KAAK,CAACsB,KAAK,IAAI,CAACtB,KAAK,CAACqB,OAAQ,EAAE;AACxE,IAAA,OAAOrB,KAAK,CAACG,KAAK,CAACyB,QAAQ,CAAC,UAAU,CAAC,CAAA;AACzC,GAAC,MAAM;AACL,IAAA,OAAOE,YAAY,CAAA;AACrB,GAAA;AACF,CAAC,EACD,MAAM;AACJ,EAAA,MAAMA,YAAY,GAAG9B,KAAK,EAAE+B,OAAO,GAAG,CAAC,CAAC,IAAI/B,KAAK,CAACG,KAAK,CAACyB,QAAQ,CAAC,UAAU,CAAC,CAAA;AAC5E,EAAA,IAAI5B,KAAK,CAACuB,MAAM,IAAIvB,KAAK,CAACqB,OAAO,EAAE;AACjC,IAAA,OAAOrB,KAAK,CAACG,KAAK,CAACyB,QAAQ,CAAC,OAAO,CAAC,CAAA;AACtC,GAAC,MAAM;AACL,IAAA,OAAOE,YAAY,CAAA;AACrB,GAAA;AACF,CACF,CAAC,CAAA;AACP,EAAC;AAEM,MAAME,SAAS,GAAGrC,MAAM,CAACC,IAAI,CACjCC,UAAU,CAAC;AACVN,EAAAA,iBAAAA;AACF,CAAC,CAAC,CACDO,KAAK,CAACC,iBAAiB,CAAC,CAAA;AAC3B;AACA;AACA,gBAAkBC,EAAAA,KAAK,IAAKA,KAAK,CAACiC,UAAU,GAAG,KAAK,GAAG,CAAE,CAAA;AACzD;AACA;AACA;AACA;;;;"}
|
|
@@ -1,240 +1,236 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React__default, { useState, useRef, useEffect, useMemo } from 'react';
|
|
1
|
+
import React__default, { useState, useEffect, useMemo } from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import { nanoid } from 'nanoid';
|
|
5
4
|
import { components } from 'react-select';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { colors } from '../../styles/utils/colors-export.js';
|
|
6
|
+
import { AsyncCreatableMultiSelect, AsyncMultiSelect, CreatableMultiSelect, MultiSelect as MultiSelect$1, MultiSelectWrapper, Label, InnerWrapper, ShowMoreWrapper, ShowMoreOverlay, ShowMoreText, ErrorMessage, DropdownOptionDeleteIcon, MultiValueWrapper } from './MultiSelect.styled.js';
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
warning,
|
|
31
|
-
onMultiValueClick,
|
|
32
|
-
showMore,
|
|
33
|
-
showMoreText = 'Show more',
|
|
34
|
-
displayTotalOnShowMore = true,
|
|
35
|
-
noOptionsMessageFunc,
|
|
36
|
-
...props
|
|
37
|
-
}, forwardedRef) {
|
|
8
|
+
const showMoreHeight = 114;
|
|
9
|
+
const MultiSelect = React__default.forwardRef((props, forwardedRef) => {
|
|
10
|
+
const {
|
|
11
|
+
label,
|
|
12
|
+
selectedOptions = [],
|
|
13
|
+
availableOptions,
|
|
14
|
+
loadOptions,
|
|
15
|
+
onUpdateCallback,
|
|
16
|
+
editText,
|
|
17
|
+
creatable,
|
|
18
|
+
readOnly,
|
|
19
|
+
disabled,
|
|
20
|
+
error,
|
|
21
|
+
warning,
|
|
22
|
+
onMultiValueClick,
|
|
23
|
+
showMore,
|
|
24
|
+
showMoreText = 'Show more',
|
|
25
|
+
displayTotalOnShowMore = true,
|
|
26
|
+
hidden,
|
|
27
|
+
...rest
|
|
28
|
+
} = props;
|
|
38
29
|
const [uniqueId] = useState(nanoid());
|
|
39
30
|
const [selected, setSelected] = useState(selectedOptions);
|
|
40
|
-
const [focused, setFocused] = useState(false);
|
|
41
|
-
const [displayShowMore, setDisplayShowMore] = useState(error || warning ? false : showMore);
|
|
42
31
|
const [cacheUnique, setCacheUnique] = useState(0);
|
|
43
|
-
const [
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
useEffect(() =>
|
|
47
|
-
setSelected(selectedOptions);
|
|
48
|
-
}, [selectedOptions]);
|
|
32
|
+
const [displayShowMore, setDisplayShowMore] = useState(showMore && !error && !warning);
|
|
33
|
+
const [focused, setFocused] = useState(false);
|
|
34
|
+
const [isDarkMode, setIsDarkMode] = useState(() => document.body.classList.contains('dark-theme'));
|
|
35
|
+
useEffect(() => setSelected(selectedOptions), [selectedOptions]);
|
|
49
36
|
useEffect(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
37
|
+
const observer = new MutationObserver(() => {
|
|
38
|
+
setIsDarkMode(document.body.classList.contains('dark-theme'));
|
|
39
|
+
});
|
|
40
|
+
observer.observe(document.body, {
|
|
41
|
+
attributes: true,
|
|
42
|
+
attributeFilter: ['class']
|
|
43
|
+
});
|
|
44
|
+
return () => observer.disconnect();
|
|
59
45
|
}, []);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (onMultiValueClick && data && !(e.target.role === 'button' || e.target instanceof SVGElement)) {
|
|
86
|
-
e.stopPropagation();
|
|
87
|
-
onMultiValueClick(data);
|
|
88
|
-
}
|
|
46
|
+
const selectStyles = useMemo(() => {
|
|
47
|
+
const getThemeColor = (darkKey, lightKey) => {
|
|
48
|
+
const prefersDark = !document.body.classList.contains('light-theme') && !document.body.classList.contains('dark-theme') && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
49
|
+
const key = isDarkMode || prefersDark ? darkKey : lightKey;
|
|
50
|
+
return colors[key] || colors['gray-500'];
|
|
51
|
+
};
|
|
52
|
+
const errorColor = colors['red-500'];
|
|
53
|
+
const warningColor = colors['orange-500'];
|
|
54
|
+
const menuBg = getThemeColor('gray-600', 'white');
|
|
55
|
+
const textColor = getThemeColor('gray-100', 'gray-900');
|
|
56
|
+
const placeholderColor = getThemeColor('gray-400', 'gray-500');
|
|
57
|
+
const multiValueBg = getThemeColor('gray-600', 'gray-800');
|
|
58
|
+
return {
|
|
59
|
+
control: base => ({
|
|
60
|
+
...base,
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
background: 'transparent',
|
|
63
|
+
border: error ? `1px solid ${errorColor}` : warning ? `1px solid ${warningColor}` : 'none',
|
|
64
|
+
borderRadius: '3px',
|
|
65
|
+
boxShadow: 'none',
|
|
66
|
+
minHeight: '38px',
|
|
67
|
+
opacity: disabled ? 0.5 : 1,
|
|
68
|
+
pointerEvents: 'auto',
|
|
69
|
+
'&:hover': {
|
|
70
|
+
border: error ? `1px solid ${errorColor}` : warning ? `1px solid ${warningColor}` : 'none'
|
|
89
71
|
}
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
...base,
|
|
132
|
-
backgroundColor: 'transparent',
|
|
133
|
-
boxShadow: 'none'
|
|
134
|
-
}),
|
|
135
|
-
menuList: base => ({
|
|
136
|
-
...base,
|
|
137
|
-
backgroundColor: 'transparent'
|
|
138
|
-
}),
|
|
139
|
-
option: base => ({
|
|
140
|
-
...base,
|
|
141
|
-
backgroundColor: 'transparent',
|
|
142
|
-
color: 'inherit'
|
|
143
|
-
}),
|
|
144
|
-
multiValue: base => ({
|
|
145
|
-
...base,
|
|
146
|
-
margin: 0,
|
|
147
|
-
border: 'none',
|
|
148
|
-
background: 'none',
|
|
149
|
-
cursor: readOnly || disabled ? 'default' : 'pointer'
|
|
150
|
-
}),
|
|
151
|
-
multiValueLabel: base => ({
|
|
152
|
-
...base,
|
|
153
|
-
padding: 0,
|
|
154
|
-
cursor: readOnly || disabled ? 'default' : 'pointer'
|
|
155
|
-
}),
|
|
156
|
-
multiValueRemove: base => ({
|
|
157
|
-
...base,
|
|
158
|
-
padding: 0,
|
|
159
|
-
cursor: readOnly || disabled ? 'default' : 'pointer'
|
|
160
|
-
})
|
|
161
|
-
}), [error, warning, displayShowMore, readOnly, disabled]);
|
|
162
|
-
const sharedProps = {
|
|
163
|
-
...props,
|
|
164
|
-
ref: node => {
|
|
165
|
-
selectRef.current = node;
|
|
166
|
-
if (forwardedRef) {
|
|
167
|
-
if (typeof forwardedRef === 'function') {
|
|
168
|
-
forwardedRef(node);
|
|
169
|
-
} else {
|
|
170
|
-
forwardedRef.current = node;
|
|
72
|
+
}),
|
|
73
|
+
valueContainer: base => ({
|
|
74
|
+
...base,
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
gap: '8px',
|
|
77
|
+
padding: '0 8px',
|
|
78
|
+
maxHeight: displayShowMore ? error || warning ? '100%' : `${showMoreHeight + 16}px` : '100%',
|
|
79
|
+
overflow: 'hidden'
|
|
80
|
+
}),
|
|
81
|
+
multiValue: base => ({
|
|
82
|
+
...base,
|
|
83
|
+
backgroundColor: multiValueBg,
|
|
84
|
+
borderRadius: '3px',
|
|
85
|
+
margin: '0',
|
|
86
|
+
display: 'flex',
|
|
87
|
+
alignItems: 'stretch',
|
|
88
|
+
minHeight: '26px',
|
|
89
|
+
overflow: 'hidden',
|
|
90
|
+
opacity: disabled ? 0.7 : 1
|
|
91
|
+
}),
|
|
92
|
+
multiValueLabel: base => ({
|
|
93
|
+
...base,
|
|
94
|
+
color: colors['white'],
|
|
95
|
+
fontSize: '12px',
|
|
96
|
+
padding: disabled || readOnly ? '0 8px' : '0 3px 0 8px',
|
|
97
|
+
display: 'flex',
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
cursor: disabled ? 'not-allowed' : readOnly ? 'default' : 'pointer'
|
|
100
|
+
}),
|
|
101
|
+
multiValueRemove: base => ({
|
|
102
|
+
...base,
|
|
103
|
+
color: 'white',
|
|
104
|
+
padding: '0 8px 0 5px',
|
|
105
|
+
display: disabled || readOnly ? 'none' : 'flex',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
alignSelf: 'stretch',
|
|
108
|
+
borderRadius: '0',
|
|
109
|
+
cursor: 'pointer',
|
|
110
|
+
'&:hover': {
|
|
111
|
+
backgroundColor: errorColor,
|
|
112
|
+
color: 'white'
|
|
171
113
|
}
|
|
114
|
+
}),
|
|
115
|
+
menu: base => ({
|
|
116
|
+
...base,
|
|
117
|
+
backgroundColor: menuBg,
|
|
118
|
+
boxShadow: '0 4px 12px rgba(0,0,0,0.5)',
|
|
119
|
+
zIndex: 999,
|
|
120
|
+
marginTop: '4px',
|
|
121
|
+
border: `1px solid ${getThemeColor('gray-500', 'gray-300')}`
|
|
122
|
+
}),
|
|
123
|
+
menuList: base => ({
|
|
124
|
+
...base,
|
|
125
|
+
backgroundColor: 'transparent',
|
|
126
|
+
padding: 0
|
|
127
|
+
}),
|
|
128
|
+
option: (base, state) => ({
|
|
129
|
+
...base,
|
|
130
|
+
backgroundColor: state.isFocused ? getThemeColor('gray-500', 'gray-100') : 'transparent',
|
|
131
|
+
color: textColor,
|
|
132
|
+
cursor: 'pointer',
|
|
133
|
+
fontSize: '14px',
|
|
134
|
+
padding: '8px 12px',
|
|
135
|
+
':active': {
|
|
136
|
+
backgroundColor: getThemeColor('gray-400', 'gray-200')
|
|
137
|
+
}
|
|
138
|
+
}),
|
|
139
|
+
input: (base, state) => ({
|
|
140
|
+
...base,
|
|
141
|
+
display: 'inline-grid',
|
|
142
|
+
whiteSpace: 'nowrap',
|
|
143
|
+
color: textColor,
|
|
144
|
+
margin: 0,
|
|
145
|
+
padding: 0,
|
|
146
|
+
':before': !focused && editText && !state.value ? {
|
|
147
|
+
content: `"${editText}"`,
|
|
148
|
+
color: placeholderColor,
|
|
149
|
+
marginRight: '8px',
|
|
150
|
+
lineHeight: '26px',
|
|
151
|
+
gridArea: '1 / 1'
|
|
152
|
+
} : {}
|
|
153
|
+
}),
|
|
154
|
+
noOptionsMessage: base => ({
|
|
155
|
+
...base,
|
|
156
|
+
color: textColor,
|
|
157
|
+
backgroundColor: 'transparent'
|
|
158
|
+
}),
|
|
159
|
+
loadingMessage: base => ({
|
|
160
|
+
...base,
|
|
161
|
+
color: textColor,
|
|
162
|
+
backgroundColor: 'transparent'
|
|
163
|
+
}),
|
|
164
|
+
placeholder: () => ({
|
|
165
|
+
display: 'none'
|
|
166
|
+
}),
|
|
167
|
+
indicatorsContainer: () => ({
|
|
168
|
+
display: 'none'
|
|
169
|
+
})
|
|
170
|
+
};
|
|
171
|
+
}, [error, warning, displayShowMore, disabled, readOnly, editText, focused, isDarkMode, onMultiValueClick]);
|
|
172
|
+
const innerComponents = {
|
|
173
|
+
Option: optProps => React__default.createElement(components.Option, optProps, React__default.createElement("div", {
|
|
174
|
+
style: {
|
|
175
|
+
display: 'flex',
|
|
176
|
+
justifyContent: 'space-between',
|
|
177
|
+
width: '100%',
|
|
178
|
+
alignItems: 'center'
|
|
172
179
|
}
|
|
173
|
-
},
|
|
180
|
+
}, React__default.createElement("span", null, optProps.label), optProps.isSelected && React__default.createElement(DropdownOptionDeleteIcon, null))),
|
|
181
|
+
MultiValue: mvProps => React__default.createElement(MultiValueWrapper, {
|
|
182
|
+
onMouseDown: e => {
|
|
183
|
+
if (onMultiValueClick && !readOnly && !disabled && !e.target.closest('.multi-select__multi-value__remove')) {
|
|
184
|
+
e.stopPropagation();
|
|
185
|
+
onMultiValueClick(mvProps.data);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, React__default.createElement(components.MultiValue, mvProps))
|
|
189
|
+
};
|
|
190
|
+
const sharedSelectProps = {
|
|
191
|
+
...rest,
|
|
192
|
+
ref: forwardedRef,
|
|
193
|
+
id: uniqueId,
|
|
174
194
|
classNamePrefix: 'multi-select',
|
|
195
|
+
styles: selectStyles,
|
|
196
|
+
components: innerComponents,
|
|
175
197
|
value: selected,
|
|
176
198
|
options: loadOptions ? undefined : availableOptions,
|
|
177
199
|
loadOptions,
|
|
178
|
-
loadingMessage: loadingMessageFunc,
|
|
179
|
-
theme: reactSelectTheme,
|
|
180
|
-
styles: selectStyles,
|
|
181
|
-
components: innerComponents,
|
|
182
200
|
isMulti: true,
|
|
183
|
-
|
|
184
|
-
placeholder: null,
|
|
185
|
-
isDisabled: disabled,
|
|
186
|
-
readOnly: readOnly,
|
|
201
|
+
isDisabled: disabled || readOnly,
|
|
187
202
|
closeMenuOnSelect: false,
|
|
188
203
|
hideSelectedOptions: false,
|
|
189
204
|
openMenuOnClick: true,
|
|
190
|
-
openMenuOnFocus: true,
|
|
191
|
-
blurInputOnSelect: false,
|
|
192
|
-
menuIsOpen: isMenuOpen ? true : undefined,
|
|
193
|
-
cacheUniqs: loadOptions ? [cacheUnique] : undefined,
|
|
194
|
-
onMenuOpen: () => {
|
|
195
|
-
setIsMenuOpen(true);
|
|
196
|
-
},
|
|
197
|
-
onMenuClose: () => {
|
|
198
|
-
setIsMenuOpen(false);
|
|
199
|
-
},
|
|
200
205
|
onFocus: () => setFocused(true),
|
|
201
206
|
onBlur: () => setFocused(false),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}) => getNoOptionsMessage(inputValue),
|
|
205
|
-
onChange: (selectedOptions, actionMeta) => {
|
|
206
|
-
if (props.onChange) {
|
|
207
|
-
props.onChange(selectedOptions, actionMeta);
|
|
208
|
-
}
|
|
207
|
+
onChange: (newValue, actionMeta) => {
|
|
208
|
+
setSelected(newValue);
|
|
209
209
|
if (onUpdateCallback) {
|
|
210
|
-
const
|
|
211
|
-
onUpdateCallback(actionMeta.action,
|
|
210
|
+
const item = actionMeta.option || actionMeta.removedValue;
|
|
211
|
+
onUpdateCallback(actionMeta.action, item);
|
|
212
212
|
}
|
|
213
|
-
setSelected(selectedOptions);
|
|
214
213
|
if (actionMeta.action === 'create-option' && loadOptions) {
|
|
215
|
-
setCacheUnique(
|
|
214
|
+
setCacheUnique(c => c + 1);
|
|
216
215
|
}
|
|
217
|
-
}
|
|
216
|
+
},
|
|
217
|
+
cacheUniqs: loadOptions ? [cacheUnique] : undefined
|
|
218
218
|
};
|
|
219
|
+
const SelectComponent = useMemo(() => {
|
|
220
|
+
if (loadOptions) return creatable ? AsyncCreatableMultiSelect : AsyncMultiSelect;
|
|
221
|
+
return creatable ? CreatableMultiSelect : MultiSelect$1;
|
|
222
|
+
}, [loadOptions, creatable]);
|
|
219
223
|
if (hidden) return null;
|
|
220
|
-
return React__default.createElement(MultiSelectWrapper, {
|
|
221
|
-
ref: wrapperRef,
|
|
222
|
-
onClick: handleWrapperClick
|
|
223
|
-
}, label && React__default.createElement(Label, {
|
|
224
|
+
return React__default.createElement(MultiSelectWrapper, null, label && React__default.createElement(Label, {
|
|
224
225
|
htmlFor: uniqueId
|
|
225
|
-
}, label), React__default.createElement(InnerWrapper, {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
setDisplayShowMore(false);
|
|
232
|
-
}
|
|
233
|
-
}, React__default.createElement(ShowMoreOverlay, null), React__default.createElement(ShowMoreText, null, showMoreText, " ", displayTotalOnShowMore && `(${selected.length})`)), (typeof error === 'string' || typeof warning === 'string') && React__default.createElement(ErrorMessage, {
|
|
234
|
-
$error: error,
|
|
235
|
-
$warning: warning
|
|
236
|
-
}, error ? error : warning));
|
|
226
|
+
}, label), React__default.createElement(InnerWrapper, null, React__default.createElement(SelectComponent, sharedSelectProps)), displayShowMore && React__default.createElement(ShowMoreWrapper, {
|
|
227
|
+
onClick: () => setDisplayShowMore(false)
|
|
228
|
+
}, React__default.createElement(ShowMoreOverlay, null), React__default.createElement(ShowMoreText, null, showMoreText, " ", displayTotalOnShowMore && `(${selected.length})`)), (error || warning) && React__default.createElement(ErrorMessage, {
|
|
229
|
+
$error: !!error,
|
|
230
|
+
$warning: !!warning
|
|
231
|
+
}, error || warning));
|
|
237
232
|
});
|
|
233
|
+
MultiSelect.displayName = 'MultiSelect';
|
|
238
234
|
MultiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
239
235
|
label: PropTypes.string,
|
|
240
236
|
availableOptions: PropTypes.arrayOf(PropTypes.object),
|
|
@@ -254,8 +250,7 @@ MultiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
254
250
|
hidden: PropTypes.bool,
|
|
255
251
|
disabled: PropTypes.bool,
|
|
256
252
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
257
|
-
warning: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
|
|
258
|
-
onChange: PropTypes.func
|
|
253
|
+
warning: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
|
|
259
254
|
} : {};
|
|
260
255
|
MultiSelect.defaultProps = {
|
|
261
256
|
noOptionsMessageFunc: inputValue => {
|