@chayns-components/core 5.0.0-beta.669 → 5.0.0-beta.670
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/lib/cjs/components/button/Button.js +8 -6
- package/lib/cjs/components/button/Button.js.map +1 -1
- package/lib/cjs/components/button/Button.styles.js +8 -5
- package/lib/cjs/components/button/Button.styles.js.map +1 -1
- package/lib/cjs/components/select-button/SelectButton.js +1 -1
- package/lib/cjs/components/select-button/SelectButton.js.map +1 -1
- package/lib/esm/components/button/Button.js +8 -6
- package/lib/esm/components/button/Button.js.map +1 -1
- package/lib/esm/components/button/Button.styles.js +8 -5
- package/lib/esm/components/button/Button.styles.js.map +1 -1
- package/lib/esm/components/select-button/SelectButton.js +1 -1
- package/lib/esm/components/select-button/SelectButton.js.map +1 -1
- package/lib/types/components/button/Button.d.ts +5 -1
- package/lib/types/components/button/Button.styles.d.ts +2 -1
- package/package.json +2 -2
|
@@ -23,7 +23,8 @@ const Button = ({
|
|
|
23
23
|
onClick,
|
|
24
24
|
shouldShowWaitCursor,
|
|
25
25
|
shouldStopPropagation,
|
|
26
|
-
|
|
26
|
+
shouldShowAsSelectButton = false,
|
|
27
|
+
shouldShowTextAsRobotoMedium = true
|
|
27
28
|
}) => {
|
|
28
29
|
const handleClick = event => {
|
|
29
30
|
if (shouldStopPropagation) {
|
|
@@ -41,7 +42,7 @@ const Button = ({
|
|
|
41
42
|
}, [isSecondary, theme.buttonBackgroundColor, theme.buttonColor, theme.buttonDesign, theme.text]);
|
|
42
43
|
const backgroundColor = (0, _react.useMemo)(() => {
|
|
43
44
|
let color;
|
|
44
|
-
if (isSecondary) {
|
|
45
|
+
if (isSecondary || shouldShowAsSelectButton) {
|
|
45
46
|
color = theme['202'];
|
|
46
47
|
} else {
|
|
47
48
|
color = theme.buttonBackgroundColor ?? theme['408'];
|
|
@@ -50,17 +51,17 @@ const Button = ({
|
|
|
50
51
|
color = `rgba(${theme['102-rgb'] ?? ''}, 0)`;
|
|
51
52
|
}
|
|
52
53
|
return color;
|
|
53
|
-
}, [isSecondary, theme]);
|
|
54
|
+
}, [isSecondary, shouldShowAsSelectButton, theme]);
|
|
54
55
|
const tapStyles = (0, _react.useMemo)(() => {
|
|
55
56
|
if (theme.buttonDesign === '2') {
|
|
56
57
|
return {
|
|
57
|
-
backgroundColor: isSecondary ? `rgba(${theme['202-rgb'] ?? ''}, 0.7)` : `${theme.buttonBackgroundColor ?? ''}40`
|
|
58
|
+
backgroundColor: isSecondary || shouldShowAsSelectButton ? `rgba(${theme['202-rgb'] ?? ''}, 0.7)` : `${theme.buttonBackgroundColor ?? ''}40`
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
return {
|
|
61
62
|
opacity: 0.6
|
|
62
63
|
};
|
|
63
|
-
}, [isSecondary, theme]);
|
|
64
|
+
}, [isSecondary, shouldShowAsSelectButton, theme]);
|
|
64
65
|
const hoverStyles = (0, _react.useMemo)(() => {
|
|
65
66
|
if (theme.buttonDesign === '2') {
|
|
66
67
|
return {
|
|
@@ -72,7 +73,8 @@ const Button = ({
|
|
|
72
73
|
};
|
|
73
74
|
}, [theme]);
|
|
74
75
|
return /*#__PURE__*/_react.default.createElement(_Button.StyledMotionButton, {
|
|
75
|
-
$
|
|
76
|
+
$shouldShowTextAsRobotoMedium: shouldShowTextAsRobotoMedium,
|
|
77
|
+
$shouldShowAsSelectButton: shouldShowAsSelectButton,
|
|
76
78
|
className: buttonClasses,
|
|
77
79
|
disabled: isDisabled,
|
|
78
80
|
$isDisabled: isDisabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["_clsx","_interopRequireDefault","require","_framerMotion","_react","_interopRequireWildcard","_styledComponents","_Icon","_Button","_WaitCursor","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Button","children","className","icon","isDisabled","isSecondary","onClick","shouldShowWaitCursor","shouldStopPropagation","ShouldShowTextAsRobotoMedium","handleClick","event","stopPropagation","buttonClasses","clsx","theme","useTheme","iconColor","useMemo","text","buttonDesign","buttonColor","buttonBackgroundColor","backgroundColor","color","tapStyles","opacity","hoverStyles","createElement","StyledMotionButton","$ShouldShowTextAsRobotoMedium","disabled","$isDisabled","$hasChildren","$hasIcon","$isSecondary","animate","whileTap","whileHover","AnimatePresence","initial","StyledIconWrapper","icons","StyledMotionWaitCursorWrapper","width","exit","key","style","overflow","transition","duration","shouldHideBackground","StyledMotionChildrenWrapper","displayName","_default","exports"],"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, MouseEventHandler, ReactNode, useMemo } from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledIconWrapper,\n StyledMotionButton,\n StyledMotionChildrenWrapper,\n StyledMotionWaitCursorWrapper,\n} from './Button.styles';\nimport WaitCursor from './wait-cursor/WaitCursor';\n\nexport type ButtonProps = {\n /**\n * The label of the button\n */\n children?: ReactNode;\n /**\n * Additional class names for the button element\n */\n className?: string;\n /**\n * An icon that is displayed on the left-hand side of the button text\n */\n icon?: string;\n /**\n * Disables the button so that it cannot be clicked anymore\n */\n isDisabled?: boolean;\n /**\n * Displays the button in the secondary style\n */\n isSecondary?: boolean;\n /**\n * Function to be executed when the button is clicked\n */\n onClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * Whether the text should be 'Roboto Medium'\n */\n ShouldShowTextAsRobotoMedium?: boolean;\n /**\n * Shows a wait cursor instead of button text\n */\n shouldShowWaitCursor?: boolean;\n /**\n * Stops event propagation on click\n */\n shouldStopPropagation?: boolean;\n};\n\nconst Button: FC<ButtonProps> = ({\n children,\n className,\n icon,\n isDisabled,\n isSecondary,\n onClick,\n shouldShowWaitCursor,\n shouldStopPropagation,\n ShouldShowTextAsRobotoMedium = true,\n}) => {\n const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {\n if (shouldStopPropagation) {\n event.stopPropagation();\n }\n\n onClick(event);\n };\n\n const buttonClasses = clsx('beta-chayns-button ellipsis', className);\n\n const theme: Theme = useTheme();\n\n const iconColor = useMemo(() => {\n if (isSecondary) {\n return theme.text;\n }\n\n return theme.buttonDesign === '2'\n ? theme.buttonColor ?? theme.buttonBackgroundColor ?? 'white'\n : theme.buttonColor ?? 'white';\n }, [\n isSecondary,\n theme.buttonBackgroundColor,\n theme.buttonColor,\n theme.buttonDesign,\n theme.text,\n ]);\n\n const backgroundColor = useMemo(() => {\n let color;\n\n if (isSecondary) {\n color = theme['202'];\n } else {\n color = theme.buttonBackgroundColor ?? theme['408'];\n }\n\n if (theme.buttonDesign === '2') {\n color = `rgba(${theme['102-rgb'] ?? ''}, 0)`;\n }\n\n return color;\n }, [isSecondary, theme]);\n\n const tapStyles = useMemo(() => {\n if (theme.buttonDesign === '2') {\n return {\n backgroundColor: isSecondary\n ? `rgba(${theme['202-rgb'] ?? ''}, 0.7)`\n : `${theme.buttonBackgroundColor ?? ''}40`,\n };\n }\n\n return {\n opacity: 0.6,\n };\n }, [isSecondary, theme]);\n\n const hoverStyles = useMemo(() => {\n if (theme.buttonDesign === '2') {\n return {\n backgroundColor: `rgba(${theme['102-rgb'] ?? ''}, 0.5)`,\n };\n }\n\n return {\n opacity: 1,\n };\n }, [theme]);\n\n return (\n <StyledMotionButton\n $ShouldShowTextAsRobotoMedium={ShouldShowTextAsRobotoMedium}\n className={buttonClasses}\n disabled={isDisabled}\n $isDisabled={isDisabled}\n $hasChildren={!!children}\n $hasIcon={typeof icon === 'string' && icon !== ''}\n $isSecondary={isSecondary}\n onClick={handleClick}\n animate={{ backgroundColor }}\n whileTap={isDisabled ? {} : { ...tapStyles }}\n whileHover={isDisabled ? {} : { ...hoverStyles }}\n >\n <AnimatePresence initial={false}>\n {icon && (\n <StyledIconWrapper>\n <Icon color={iconColor} icons={[icon]} />\n </StyledIconWrapper>\n )}\n {shouldShowWaitCursor && (\n <StyledMotionWaitCursorWrapper\n animate={{ opacity: 1, width: 40 }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"wait-cursor\"\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n <WaitCursor color={iconColor ?? 'white'} shouldHideBackground />\n </StyledMotionWaitCursorWrapper>\n )}\n {!shouldShowWaitCursor && children && (\n <StyledMotionChildrenWrapper\n animate={{ opacity: 1, width: 'auto' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"children\"\n // style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n {children}\n </StyledMotionChildrenWrapper>\n )}\n </AnimatePresence>\n </StyledMotionButton>\n );\n};\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAMA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAkD,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,Q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_styledComponents","_Icon","_Button","_WaitCursor","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Button","children","className","icon","isDisabled","isSecondary","onClick","shouldShowWaitCursor","shouldStopPropagation","shouldShowAsSelectButton","shouldShowTextAsRobotoMedium","handleClick","event","stopPropagation","buttonClasses","clsx","theme","useTheme","iconColor","useMemo","text","buttonDesign","buttonColor","buttonBackgroundColor","backgroundColor","color","tapStyles","opacity","hoverStyles","createElement","StyledMotionButton","$shouldShowTextAsRobotoMedium","$shouldShowAsSelectButton","disabled","$isDisabled","$hasChildren","$hasIcon","$isSecondary","animate","whileTap","whileHover","AnimatePresence","initial","StyledIconWrapper","icons","StyledMotionWaitCursorWrapper","width","exit","key","style","overflow","transition","duration","shouldHideBackground","StyledMotionChildrenWrapper","displayName","_default","exports"],"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, MouseEventHandler, ReactNode, useMemo } from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledIconWrapper,\n StyledMotionButton,\n StyledMotionChildrenWrapper,\n StyledMotionWaitCursorWrapper,\n} from './Button.styles';\nimport WaitCursor from './wait-cursor/WaitCursor';\n\nexport type ButtonProps = {\n /**\n * The label of the button\n */\n children?: ReactNode;\n /**\n * Additional class names for the button element\n */\n className?: string;\n /**\n * An icon that is displayed on the left-hand side of the button text\n */\n icon?: string;\n /**\n * Disables the button so that it cannot be clicked anymore\n */\n isDisabled?: boolean;\n /**\n * Displays the button in the secondary style\n */\n isSecondary?: boolean;\n /**\n * Function to be executed when the button is clicked\n */\n onClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * Whether the button should be displayed as a selectButton.\n */\n shouldShowAsSelectButton?: boolean;\n /**\n * Whether the text should be 'Roboto Medium'\n */\n shouldShowTextAsRobotoMedium?: boolean;\n /**\n * Shows a wait cursor instead of button text\n */\n shouldShowWaitCursor?: boolean;\n /**\n * Stops event propagation on click\n */\n shouldStopPropagation?: boolean;\n};\n\nconst Button: FC<ButtonProps> = ({\n children,\n className,\n icon,\n isDisabled,\n isSecondary,\n onClick,\n shouldShowWaitCursor,\n shouldStopPropagation,\n shouldShowAsSelectButton = false,\n shouldShowTextAsRobotoMedium = true,\n}) => {\n const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {\n if (shouldStopPropagation) {\n event.stopPropagation();\n }\n\n onClick(event);\n };\n\n const buttonClasses = clsx('beta-chayns-button ellipsis', className);\n\n const theme: Theme = useTheme();\n\n const iconColor = useMemo(() => {\n if (isSecondary) {\n return theme.text;\n }\n\n return theme.buttonDesign === '2'\n ? theme.buttonColor ?? theme.buttonBackgroundColor ?? 'white'\n : theme.buttonColor ?? 'white';\n }, [\n isSecondary,\n theme.buttonBackgroundColor,\n theme.buttonColor,\n theme.buttonDesign,\n theme.text,\n ]);\n\n const backgroundColor = useMemo(() => {\n let color;\n\n if (isSecondary || shouldShowAsSelectButton) {\n color = theme['202'];\n } else {\n color = theme.buttonBackgroundColor ?? theme['408'];\n }\n\n if (theme.buttonDesign === '2') {\n color = `rgba(${theme['102-rgb'] ?? ''}, 0)`;\n }\n\n return color;\n }, [isSecondary, shouldShowAsSelectButton, theme]);\n\n const tapStyles = useMemo(() => {\n if (theme.buttonDesign === '2') {\n return {\n backgroundColor:\n isSecondary || shouldShowAsSelectButton\n ? `rgba(${theme['202-rgb'] ?? ''}, 0.7)`\n : `${theme.buttonBackgroundColor ?? ''}40`,\n };\n }\n\n return {\n opacity: 0.6,\n };\n }, [isSecondary, shouldShowAsSelectButton, theme]);\n\n const hoverStyles = useMemo(() => {\n if (theme.buttonDesign === '2') {\n return {\n backgroundColor: `rgba(${theme['102-rgb'] ?? ''}, 0.5)`,\n };\n }\n\n return {\n opacity: 1,\n };\n }, [theme]);\n\n return (\n <StyledMotionButton\n $shouldShowTextAsRobotoMedium={shouldShowTextAsRobotoMedium}\n $shouldShowAsSelectButton={shouldShowAsSelectButton}\n className={buttonClasses}\n disabled={isDisabled}\n $isDisabled={isDisabled}\n $hasChildren={!!children}\n $hasIcon={typeof icon === 'string' && icon !== ''}\n $isSecondary={isSecondary}\n onClick={handleClick}\n animate={{ backgroundColor }}\n whileTap={isDisabled ? {} : { ...tapStyles }}\n whileHover={isDisabled ? {} : { ...hoverStyles }}\n >\n <AnimatePresence initial={false}>\n {icon && (\n <StyledIconWrapper>\n <Icon color={iconColor} icons={[icon]} />\n </StyledIconWrapper>\n )}\n {shouldShowWaitCursor && (\n <StyledMotionWaitCursorWrapper\n animate={{ opacity: 1, width: 40 }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"wait-cursor\"\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n <WaitCursor color={iconColor ?? 'white'} shouldHideBackground />\n </StyledMotionWaitCursorWrapper>\n )}\n {!shouldShowWaitCursor && children && (\n <StyledMotionChildrenWrapper\n animate={{ opacity: 1, width: 'auto' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"children\"\n // style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n {children}\n </StyledMotionChildrenWrapper>\n )}\n </AnimatePresence>\n </StyledMotionButton>\n );\n};\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAMA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAA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AE;IAAO,CAAE;IACvCC,IAAI,EAAE;MAAEpB,OAAO,EAAE,CAAC;MAAEmB,KAAK,EAAE;IAAE,CAAE;IAC/BJ,OAAO,EAAE;MAAEf,OAAO,EAAE,CAAC;MAAEmB,KAAK,EAAE;IAAE,CAAE;IAClCE,GAAG,EAAC;IACJ;IAAA;IACAG,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,GAE7BnD,QACwB,CAEpB,CACD,CAAC;AAE7B,CAAC;AAEDD,MAAM,CAACuD,WAAW,GAAG,QAAQ;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAvE,OAAA,GAEfc,MAAM","ignoreList":[]}
|
|
@@ -10,8 +10,9 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
const StyledMotionButton = exports.StyledMotionButton = (0, _styledComponents.default)(_framerMotion.motion.button)`
|
|
12
12
|
${({
|
|
13
|
-
$
|
|
14
|
-
|
|
13
|
+
$shouldShowTextAsRobotoMedium,
|
|
14
|
+
$shouldShowAsSelectButton
|
|
15
|
+
}) => $shouldShowTextAsRobotoMedium && !$shouldShowAsSelectButton && (0, _styledComponents.css)`
|
|
15
16
|
font-size: 110%;
|
|
16
17
|
font-family: 'Roboto Medium', serif;
|
|
17
18
|
`}
|
|
@@ -20,9 +21,10 @@ const StyledMotionButton = exports.StyledMotionButton = (0, _styledComponents.de
|
|
|
20
21
|
|
|
21
22
|
${({
|
|
22
23
|
$isSecondary,
|
|
24
|
+
$shouldShowAsSelectButton,
|
|
23
25
|
theme
|
|
24
26
|
}) => {
|
|
25
|
-
if ($isSecondary) {
|
|
27
|
+
if ($isSecondary || $shouldShowAsSelectButton) {
|
|
26
28
|
return (0, _styledComponents.css)`
|
|
27
29
|
color: ${theme.text};
|
|
28
30
|
`;
|
|
@@ -34,9 +36,10 @@ const StyledMotionButton = exports.StyledMotionButton = (0, _styledComponents.de
|
|
|
34
36
|
|
|
35
37
|
${({
|
|
36
38
|
theme,
|
|
37
|
-
$isSecondary
|
|
39
|
+
$isSecondary,
|
|
40
|
+
$shouldShowAsSelectButton
|
|
38
41
|
}) => {
|
|
39
|
-
if (theme.buttonDesign === '2') {
|
|
42
|
+
if (theme.buttonDesign === '2' && !$shouldShowAsSelectButton) {
|
|
40
43
|
return (0, _styledComponents.css)`
|
|
41
44
|
border: 1px solid ${$isSecondary ? theme['202'] : theme.buttonBackgroundColor};
|
|
42
45
|
box-shadow: none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledMotionButton","exports","styled","motion","button","$
|
|
1
|
+
{"version":3,"file":"Button.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledMotionButton","exports","styled","motion","button","$shouldShowTextAsRobotoMedium","$shouldShowAsSelectButton","css","$isSecondary","theme","text","buttonDesign","buttonColor","buttonBackgroundColor","$isDisabled","$hasIcon","$hasChildren","StyledIconWrapper","span","StyledMotionChildrenWrapper","div","StyledMotionWaitCursorWrapper"],"sources":["../../../../src/components/button/Button.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledButtonProps = WithTheme<{\n $hasIcon: boolean;\n $hasChildren: boolean;\n $isDisabled?: boolean;\n $isSecondary?: boolean;\n $shouldShowTextAsRobotoMedium: boolean;\n $shouldShowAsSelectButton: boolean;\n}>;\n\nexport const StyledMotionButton = styled(motion.button)<StyledButtonProps>`\n ${({ $shouldShowTextAsRobotoMedium, $shouldShowAsSelectButton }) =>\n $shouldShowTextAsRobotoMedium &&\n !$shouldShowAsSelectButton &&\n css`\n font-size: 110%;\n font-family: 'Roboto Medium', serif;\n `}\n\n align-items: center;\n\n ${({ $isSecondary, $shouldShowAsSelectButton, theme }: StyledButtonProps) => {\n if ($isSecondary || $shouldShowAsSelectButton) {\n return css`\n color: ${theme.text};\n `;\n }\n\n return css`\n color: ${theme.buttonDesign === '2'\n ? theme.buttonColor ?? theme.buttonBackgroundColor ?? 'white'\n : theme.buttonColor ?? 'white'};\n `;\n }}\n\n ${({ theme, $isSecondary, $shouldShowAsSelectButton }: StyledButtonProps) => {\n if (theme.buttonDesign === '2' && !$shouldShowAsSelectButton) {\n return css`\n border: 1px solid ${$isSecondary ? theme['202'] : theme.buttonBackgroundColor};\n box-shadow: none;\n `;\n }\n\n return css`\n border: none;\n box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.2);\n `;\n }}\n\n border-radius: 3px;\n cursor: ${({ $isDisabled }) => ($isDisabled ? 'default' : 'pointer')};\n display: inline-flex;\n line-height: 1.15;\n min-height: 32px;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n position: relative;\n user-select: none;\n transition: opacity 0.3s ease;\n\n ${({ $hasIcon, $hasChildren }) => {\n if ($hasIcon) {\n if ($hasChildren) {\n return css`\n padding: 7px 12px 7px 42px;\n `;\n }\n return css`\n padding: 7px 12px 7px 18px;\n `;\n }\n return css`\n padding: 7px 12px 7px 12px;\n `;\n }}\n`;\n\nexport const StyledIconWrapper = styled.span`\n align-items: center;\n background-color: rgba(255, 255, 255, 0.2);\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n position: absolute;\n top: 0;\n width: 30px;\n`;\n\nexport const StyledMotionChildrenWrapper = styled(motion.div)<FramerMotionBugFix>``;\n\nexport const StyledMotionWaitCursorWrapper = styled(motion.div)<FramerMotionBugFix>`\n align-items: center;\n display: flex;\n justify-content: center;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAgD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IA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,cAAc,CAAC;EAAEO;AAAY,CAAC,KAAMA,WAAW,GAAG,SAAS,GAAG,SAAU;AACxE;AACA;AACA;AACA,eAAe,CAAC;EAAEA;AAAY,CAAC,KAAMA,WAAW,GAAG,GAAG,GAAG,CAAE;AAC3D;AACA;AACA;AACA;AACA,MAAM,CAAC;EAAEC,QAAQ;EAAEC;AAAa,CAAC,KAAK;EAC9B,IAAID,QAAQ,EAAE;IACV,IAAIC,YAAY,EAAE;MACd,OAAO,IAAAT,qBAAG;AAC1B;AACA,iBAAiB;IACL;IACA,OAAO,IAAAA,qBAAG;AACtB;AACA,aAAa;EACL;EACA,OAAO,IAAAA,qBAAG;AAClB;AACA,SAAS;AACL,CAAC;AACL,CAAC;AAEM,MAAMU,iBAAiB,GAAAhB,OAAA,CAAAgB,iBAAA,GAAGf,yBAAM,CAACgB,IAAI;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,2BAA2B,GAAAlB,OAAA,CAAAkB,2BAAA,GAAG,IAAAjB,yBAAM,EAACC,oBAAM,CAACiB,GAAG,CAAqB,EAAE;AAE5E,MAAMC,6BAA6B,GAAApB,OAAA,CAAAoB,6BAAA,GAAG,IAAAnB,yBAAM,EAACC,oBAAM,CAACiB,GAAG,CAAqB;AACnF;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -72,7 +72,7 @@ const SelectButton = ({
|
|
|
72
72
|
onClick: handleClick,
|
|
73
73
|
isDisabled: isDisabled,
|
|
74
74
|
isSecondary: true,
|
|
75
|
-
|
|
75
|
+
shouldShowTextAsRobotoMedium: false
|
|
76
76
|
}, selectedItemText ?? buttonText));
|
|
77
77
|
};
|
|
78
78
|
SelectButton.displayName = 'SelectButton';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectButton.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_Button","_interopRequireDefault","_SelectButton","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SelectButton","onSelect","selectedItemIds","shouldAllowMultiSelect","buttonText","shouldShowSearch","list","isDisabled","itemList","useMemo","items","forEach","text","id","isSelected","includes","push","name","selectedItemText","length","newText","handleClick","createDialog","type","DialogType","SELECT","multiselect","quickfind","open","then","result","buttonType","map","Number","createElement","StyledSelectButton","onClick","isSecondary","
|
|
1
|
+
{"version":3,"file":"SelectButton.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_Button","_interopRequireDefault","_SelectButton","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SelectButton","onSelect","selectedItemIds","shouldAllowMultiSelect","buttonText","shouldShowSearch","list","isDisabled","itemList","useMemo","items","forEach","text","id","isSelected","includes","push","name","selectedItemText","length","newText","handleClick","createDialog","type","DialogType","SELECT","multiselect","quickfind","open","then","result","buttonType","map","Number","createElement","StyledSelectButton","onClick","isSecondary","shouldShowTextAsRobotoMedium","displayName","_default","exports"],"sources":["../../../../src/components/select-button/SelectButton.tsx"],"sourcesContent":["import { createDialog, DialogType, type DialogSelectListItemType } from 'chayns-api';\nimport React, { useMemo, type FC } from 'react';\nimport type { SelectButtonItem } from '../../types/selectButton';\nimport Button from '../button/Button';\nimport { StyledSelectButton } from './SelectButton.styles';\n\nexport type SelectButtonProps = {\n /**\n * The text that should be displayed inside the button.\n */\n buttonText: string;\n /**\n * Whether the button should be disabled.\n */\n isDisabled?: boolean;\n /**\n * A list of item that could be selected.\n */\n list: SelectButtonItem[];\n /**\n * Function to be executed after an item is selected.\n */\n onSelect?: (ids: number[]) => void;\n /**\n * The id of an item that should be preselected.\n */\n selectedItemIds?: number[];\n /**\n * Whether more than one item should be selectable.\n */\n shouldAllowMultiSelect?: boolean;\n /**\n * Whether the search should be displayed inside the dialog.\n */\n shouldShowSearch?: boolean;\n};\n\nconst SelectButton: FC<SelectButtonProps> = ({\n onSelect,\n selectedItemIds,\n shouldAllowMultiSelect,\n buttonText,\n shouldShowSearch,\n list,\n isDisabled,\n}) => {\n const itemList = useMemo(() => {\n const items: DialogSelectListItemType[] = [];\n\n list.forEach(({ text, id }) => {\n const isSelected = selectedItemIds ? selectedItemIds.includes(id) : false;\n\n items.push({\n name: text,\n id,\n isSelected,\n });\n });\n\n return items;\n }, [list, selectedItemIds]);\n\n const selectedItemText = useMemo(() => {\n if (!selectedItemIds || selectedItemIds.length === 0) {\n return null;\n }\n\n let newText = '';\n\n list.forEach(({ text, id }) => {\n if (selectedItemIds?.includes(id)) {\n newText += newText.length === 0 ? `${text}` : `, ${text}`;\n }\n });\n\n return newText;\n }, [list, selectedItemIds]);\n\n const handleClick = () => {\n void createDialog({\n type: DialogType.SELECT,\n list: itemList,\n multiselect: shouldAllowMultiSelect,\n quickfind: shouldShowSearch,\n })\n .open()\n .then((result) => {\n // Ignore because there is no type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (result && result.buttonType === 1 && typeof onSelect === 'function') {\n // Ignore because there is no type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n onSelect((result.result as string[]).map(Number));\n }\n });\n };\n\n return (\n <StyledSelectButton>\n <Button\n onClick={handleClick}\n isDisabled={isDisabled}\n isSecondary\n shouldShowTextAsRobotoMedium={false}\n >\n {selectedItemText ?? buttonText}\n </Button>\n </StyledSelectButton>\n );\n};\n\nSelectButton.displayName = 'SelectButton';\n\nexport default SelectButton;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAA2D,SAAAI,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,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ACNC,IAAI,CAAEC,MAAM,IAAK;MACd;MACA;MACA;MACA,IAAIA,MAAM,IAAIA,MAAM,CAACC,UAAU,KAAK,CAAC,IAAI,OAAO9B,QAAQ,KAAK,UAAU,EAAE;QACrE;QACA;QACA;QACAA,QAAQ,CAAE6B,MAAM,CAACA,MAAM,CAAcE,GAAG,CAACC,MAAM,CAAC,CAAC;MACrD;IACJ,CAAC,CAAC;EACV,CAAC;EAED,oBACI1D,MAAA,CAAAO,OAAA,CAAAoD,aAAA,CAACvD,aAAA,CAAAwD,kBAAkB,qBACf5D,MAAA,CAAAO,OAAA,CAAAoD,aAAA,CAACzD,OAAA,CAAAK,OAAM;IACHsD,OAAO,EAAEf,WAAY;IACrBd,UAAU,EAAEA,UAAW;IACvB8B,WAAW;IACXC,4BAA4B,EAAE;EAAM,GAEnCpB,gBAAgB,IAAId,UACjB,CACQ,CAAC;AAE7B,CAAC;AAEDJ,YAAY,CAACuC,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3D,OAAA,GAE3BkB,YAAY","ignoreList":[]}
|
|
@@ -15,7 +15,8 @@ const Button = _ref => {
|
|
|
15
15
|
onClick,
|
|
16
16
|
shouldShowWaitCursor,
|
|
17
17
|
shouldStopPropagation,
|
|
18
|
-
|
|
18
|
+
shouldShowAsSelectButton = false,
|
|
19
|
+
shouldShowTextAsRobotoMedium = true
|
|
19
20
|
} = _ref;
|
|
20
21
|
const handleClick = event => {
|
|
21
22
|
if (shouldStopPropagation) {
|
|
@@ -33,7 +34,7 @@ const Button = _ref => {
|
|
|
33
34
|
}, [isSecondary, theme.buttonBackgroundColor, theme.buttonColor, theme.buttonDesign, theme.text]);
|
|
34
35
|
const backgroundColor = useMemo(() => {
|
|
35
36
|
let color;
|
|
36
|
-
if (isSecondary) {
|
|
37
|
+
if (isSecondary || shouldShowAsSelectButton) {
|
|
37
38
|
color = theme['202'];
|
|
38
39
|
} else {
|
|
39
40
|
color = theme.buttonBackgroundColor ?? theme['408'];
|
|
@@ -42,17 +43,17 @@ const Button = _ref => {
|
|
|
42
43
|
color = `rgba(${theme['102-rgb'] ?? ''}, 0)`;
|
|
43
44
|
}
|
|
44
45
|
return color;
|
|
45
|
-
}, [isSecondary, theme]);
|
|
46
|
+
}, [isSecondary, shouldShowAsSelectButton, theme]);
|
|
46
47
|
const tapStyles = useMemo(() => {
|
|
47
48
|
if (theme.buttonDesign === '2') {
|
|
48
49
|
return {
|
|
49
|
-
backgroundColor: isSecondary ? `rgba(${theme['202-rgb'] ?? ''}, 0.7)` : `${theme.buttonBackgroundColor ?? ''}40`
|
|
50
|
+
backgroundColor: isSecondary || shouldShowAsSelectButton ? `rgba(${theme['202-rgb'] ?? ''}, 0.7)` : `${theme.buttonBackgroundColor ?? ''}40`
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
return {
|
|
53
54
|
opacity: 0.6
|
|
54
55
|
};
|
|
55
|
-
}, [isSecondary, theme]);
|
|
56
|
+
}, [isSecondary, shouldShowAsSelectButton, theme]);
|
|
56
57
|
const hoverStyles = useMemo(() => {
|
|
57
58
|
if (theme.buttonDesign === '2') {
|
|
58
59
|
return {
|
|
@@ -64,7 +65,8 @@ const Button = _ref => {
|
|
|
64
65
|
};
|
|
65
66
|
}, [theme]);
|
|
66
67
|
return /*#__PURE__*/React.createElement(StyledMotionButton, {
|
|
67
|
-
$
|
|
68
|
+
$shouldShowTextAsRobotoMedium: shouldShowTextAsRobotoMedium,
|
|
69
|
+
$shouldShowAsSelectButton: shouldShowAsSelectButton,
|
|
68
70
|
className: buttonClasses,
|
|
69
71
|
disabled: isDisabled,
|
|
70
72
|
$isDisabled: isDisabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["clsx","AnimatePresence","React","useMemo","useTheme","Icon","StyledIconWrapper","StyledMotionButton","StyledMotionChildrenWrapper","StyledMotionWaitCursorWrapper","WaitCursor","Button","_ref","children","className","icon","isDisabled","isSecondary","onClick","shouldShowWaitCursor","shouldStopPropagation","ShouldShowTextAsRobotoMedium","handleClick","event","stopPropagation","buttonClasses","theme","iconColor","text","buttonDesign","buttonColor","buttonBackgroundColor","backgroundColor","color","tapStyles","opacity","hoverStyles","createElement","$ShouldShowTextAsRobotoMedium","disabled","$isDisabled","$hasChildren","$hasIcon","$isSecondary","animate","whileTap","whileHover","initial","icons","width","exit","key","style","overflow","transition","duration","shouldHideBackground","displayName"],"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, MouseEventHandler, ReactNode, useMemo } from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledIconWrapper,\n StyledMotionButton,\n StyledMotionChildrenWrapper,\n StyledMotionWaitCursorWrapper,\n} from './Button.styles';\nimport WaitCursor from './wait-cursor/WaitCursor';\n\nexport type ButtonProps = {\n /**\n * The label of the button\n */\n children?: ReactNode;\n /**\n * Additional class names for the button element\n */\n className?: string;\n /**\n * An icon that is displayed on the left-hand side of the button text\n */\n icon?: string;\n /**\n * Disables the button so that it cannot be clicked anymore\n */\n isDisabled?: boolean;\n /**\n * Displays the button in the secondary style\n */\n isSecondary?: boolean;\n /**\n * Function to be executed when the button is clicked\n */\n onClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * Whether the text should be 'Roboto Medium'\n */\n ShouldShowTextAsRobotoMedium?: boolean;\n /**\n * Shows a wait cursor instead of button text\n */\n shouldShowWaitCursor?: boolean;\n /**\n * Stops event propagation on click\n */\n shouldStopPropagation?: boolean;\n};\n\nconst Button: FC<ButtonProps> = ({\n children,\n className,\n icon,\n isDisabled,\n isSecondary,\n onClick,\n shouldShowWaitCursor,\n shouldStopPropagation,\n ShouldShowTextAsRobotoMedium = true,\n}) => {\n const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {\n if (shouldStopPropagation) {\n event.stopPropagation();\n }\n\n onClick(event);\n };\n\n const buttonClasses = clsx('beta-chayns-button ellipsis', className);\n\n const theme: Theme = useTheme();\n\n const iconColor = useMemo(() => {\n if (isSecondary) {\n return theme.text;\n }\n\n return theme.buttonDesign === '2'\n ? theme.buttonColor ?? theme.buttonBackgroundColor ?? 'white'\n : theme.buttonColor ?? 'white';\n }, [\n isSecondary,\n theme.buttonBackgroundColor,\n theme.buttonColor,\n theme.buttonDesign,\n theme.text,\n ]);\n\n const backgroundColor = useMemo(() => {\n let color;\n\n if (isSecondary) {\n color = theme['202'];\n } else {\n color = theme.buttonBackgroundColor ?? theme['408'];\n }\n\n if (theme.buttonDesign === '2') {\n color = `rgba(${theme['102-rgb'] ?? ''}, 0)`;\n }\n\n return color;\n }, [isSecondary, theme]);\n\n const tapStyles = useMemo(() => {\n if (theme.buttonDesign === '2') {\n return {\n backgroundColor: isSecondary\n ? `rgba(${theme['202-rgb'] ?? ''}, 0.7)`\n : `${theme.buttonBackgroundColor ?? ''}40`,\n };\n }\n\n return {\n opacity: 0.6,\n };\n }, [isSecondary, theme]);\n\n const hoverStyles = useMemo(() => {\n if (theme.buttonDesign === '2') {\n return {\n backgroundColor: `rgba(${theme['102-rgb'] ?? ''}, 0.5)`,\n };\n }\n\n return {\n opacity: 1,\n };\n }, [theme]);\n\n return (\n <StyledMotionButton\n $ShouldShowTextAsRobotoMedium={ShouldShowTextAsRobotoMedium}\n className={buttonClasses}\n disabled={isDisabled}\n $isDisabled={isDisabled}\n $hasChildren={!!children}\n $hasIcon={typeof icon === 'string' && icon !== ''}\n $isSecondary={isSecondary}\n onClick={handleClick}\n animate={{ backgroundColor }}\n whileTap={isDisabled ? {} : { ...tapStyles }}\n whileHover={isDisabled ? {} : { ...hoverStyles }}\n >\n <AnimatePresence initial={false}>\n {icon && (\n <StyledIconWrapper>\n <Icon color={iconColor} icons={[icon]} />\n </StyledIconWrapper>\n )}\n {shouldShowWaitCursor && (\n <StyledMotionWaitCursorWrapper\n animate={{ opacity: 1, width: 40 }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"wait-cursor\"\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n <WaitCursor color={iconColor ?? 'white'} shouldHideBackground />\n </StyledMotionWaitCursorWrapper>\n )}\n {!shouldShowWaitCursor && children && (\n <StyledMotionChildrenWrapper\n animate={{ opacity: 1, width: 'auto' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"children\"\n // style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n {children}\n </StyledMotionChildrenWrapper>\n )}\n </AnimatePresence>\n </StyledMotionButton>\n );\n};\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAAsCC,OAAO,QAAQ,OAAO;AACxE,SAASC,QAAQ,QAAQ,mBAAmB;AAE5C,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,iBAAiB,EACjBC,kBAAkB,EAClBC,2BAA2B,EAC3BC,6BAA6B,QAC1B,iBAAiB;AACxB,OAAOC,UAAU,MAAM,0BAA0B;AAyCjD,MAAMC,MAAuB,GAAGC,IAAA,IAU1B;EAAA,IAV2B;IAC7BC,QAAQ;IACRC,SAAS;IACTC,IAAI;IACJC,UAAU;IACVC,WAAW;IACXC,OAAO;IACPC,oBAAoB;IACpBC,qBAAqB;IACrBC,4BAA4B,GAAG;EACnC,CAAC,GAAAT,IAAA;EACG,MAAMU,WAAiD,GAAIC,KAAK,IAAK;IACjE,IAAIH,qBAAqB,EAAE;MACvBG,KAAK,CAACC,eAAe,CAAC,CAAC;IAC3B;IAEAN,OAAO,CAACK,KAAK,CAAC;EAClB,CAAC;EAED,MAAME,aAAa,GAAGzB,IAAI,CAAC,6BAA6B,EAAEc,SAAS,CAAC;EAEpE,MAAMY,KAAY,G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AAC;MAAEc,KAAK,EAAE;IAAE,CAAE;IAC/BF,OAAO,EAAE;MAAEZ,OAAO,EAAE,CAAC;MAAEc,KAAK,EAAE;IAAE,CAAE;IAClCE,GAAG,EAAC,aAAa;IACjBC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAS,CAAE;IAC9BC,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,gBAE9BrD,KAAA,CAAAmC,aAAA,CAAC3B,UAAU;IAACuB,KAAK,EAAEN,SAAS,IAAI,OAAQ;IAAC6B,oBAAoB;EAAA,CAAE,CACpC,CAClC,EACA,CAACrC,oBAAoB,IAAIN,QAAQ,iBAC9BX,KAAA,CAAAmC,aAAA,CAAC7B,2BAA2B;IACxBoC,OAAO,EAAE;MAAET,OAAO,EAAE,CAAC;MAAEc,KAAK,EAAE;IAAO,CAAE;IACvCC,IAAI,EAAE;MAAEf,OAAO,EAAE,CAAC;MAAEc,KAAK,EAAE;IAAE,CAAE;IAC/BF,OAAO,EAAE;MAAEZ,OAAO,EAAE,CAAC;MAAEc,KAAK,EAAE;IAAE,CAAE;IAClCE,GAAG,EAAC;IACJ;IAAA;IACAG,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,GAE7B1C,QACwB,CAEpB,CACD,CAAC;AAE7B,CAAC;AAEDF,MAAM,CAAC8C,WAAW,GAAG,QAAQ;AAE7B,eAAe9C,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Button.js","names":["clsx","AnimatePresence","React","useMemo","useTheme","Icon","StyledIconWrapper","StyledMotionButton","StyledMotionChildrenWrapper","StyledMotionWaitCursorWrapper","WaitCursor","Button","_ref","children","className","icon","isDisabled","isSecondary","onClick","shouldShowWaitCursor","shouldStopPropagation","shouldShowAsSelectButton","shouldShowTextAsRobotoMedium","handleClick","event","stopPropagation","buttonClasses","theme","iconColor","text","buttonDesign","buttonColor","buttonBackgroundColor","backgroundColor","color","tapStyles","opacity","hoverStyles","createElement","$shouldShowTextAsRobotoMedium","$shouldShowAsSelectButton","disabled","$isDisabled","$hasChildren","$hasIcon","$isSecondary","animate","whileTap","whileHover","initial","icons","width","exit","key","style","overflow","transition","duration","shouldHideBackground","displayName"],"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { AnimatePresence } from 'framer-motion';\nimport React, { FC, MouseEventHandler, ReactNode, useMemo } from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledIconWrapper,\n StyledMotionButton,\n StyledMotionChildrenWrapper,\n StyledMotionWaitCursorWrapper,\n} from './Button.styles';\nimport WaitCursor from './wait-cursor/WaitCursor';\n\nexport type ButtonProps = {\n /**\n * The label of the button\n */\n children?: ReactNode;\n /**\n * Additional class names for the button element\n */\n className?: string;\n /**\n * An icon that is displayed on the left-hand side of the button text\n */\n icon?: string;\n /**\n * Disables the button so that it cannot be clicked anymore\n */\n isDisabled?: boolean;\n /**\n * Displays the button in the secondary style\n */\n isSecondary?: boolean;\n /**\n * Function to be executed when the button is clicked\n */\n onClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * Whether the button should be displayed as a selectButton.\n */\n shouldShowAsSelectButton?: boolean;\n /**\n * Whether the text should be 'Roboto Medium'\n */\n shouldShowTextAsRobotoMedium?: boolean;\n /**\n * Shows a wait cursor instead of button text\n */\n shouldShowWaitCursor?: boolean;\n /**\n * Stops event propagation on click\n */\n shouldStopPropagation?: boolean;\n};\n\nconst Button: FC<ButtonProps> = ({\n children,\n className,\n icon,\n isDisabled,\n isSecondary,\n onClick,\n shouldShowWaitCursor,\n shouldStopPropagation,\n shouldShowAsSelectButton = false,\n shouldShowTextAsRobotoMedium = true,\n}) => {\n const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {\n if (shouldStopPropagation) {\n event.stopPropagation();\n }\n\n onClick(event);\n };\n\n const buttonClasses = clsx('beta-chayns-button ellipsis', className);\n\n const theme: Theme = useTheme();\n\n const iconColor = useMemo(() => {\n if (isSecondary) {\n return theme.text;\n }\n\n return theme.buttonDesign === '2'\n ? theme.buttonColor ?? theme.buttonBackgroundColor ?? 'white'\n : theme.buttonColor ?? 'white';\n }, [\n isSecondary,\n theme.buttonBackgroundColor,\n theme.buttonColor,\n theme.buttonDesign,\n theme.text,\n ]);\n\n const backgroundColor = useMemo(() => {\n let color;\n\n if (isSecondary || shouldShowAsSelectButton) {\n color = theme['202'];\n } else {\n color = theme.buttonBackgroundColor ?? theme['408'];\n }\n\n if (theme.buttonDesign === '2') {\n color = `rgba(${theme['102-rgb'] ?? ''}, 0)`;\n }\n\n return color;\n }, [isSecondary, shouldShowAsSelectButton, theme]);\n\n const tapStyles = useMemo(() => {\n if (theme.buttonDesign === '2') {\n return {\n backgroundColor:\n isSecondary || shouldShowAsSelectButton\n ? `rgba(${theme['202-rgb'] ?? ''}, 0.7)`\n : `${theme.buttonBackgroundColor ?? ''}40`,\n };\n }\n\n return {\n opacity: 0.6,\n };\n }, [isSecondary, shouldShowAsSelectButton, theme]);\n\n const hoverStyles = useMemo(() => {\n if (theme.buttonDesign === '2') {\n return {\n backgroundColor: `rgba(${theme['102-rgb'] ?? ''}, 0.5)`,\n };\n }\n\n return {\n opacity: 1,\n };\n }, [theme]);\n\n return (\n <StyledMotionButton\n $shouldShowTextAsRobotoMedium={shouldShowTextAsRobotoMedium}\n $shouldShowAsSelectButton={shouldShowAsSelectButton}\n className={buttonClasses}\n disabled={isDisabled}\n $isDisabled={isDisabled}\n $hasChildren={!!children}\n $hasIcon={typeof icon === 'string' && icon !== ''}\n $isSecondary={isSecondary}\n onClick={handleClick}\n animate={{ backgroundColor }}\n whileTap={isDisabled ? {} : { ...tapStyles }}\n whileHover={isDisabled ? {} : { ...hoverStyles }}\n >\n <AnimatePresence initial={false}>\n {icon && (\n <StyledIconWrapper>\n <Icon color={iconColor} icons={[icon]} />\n </StyledIconWrapper>\n )}\n {shouldShowWaitCursor && (\n <StyledMotionWaitCursorWrapper\n animate={{ opacity: 1, width: 40 }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"wait-cursor\"\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n <WaitCursor color={iconColor ?? 'white'} shouldHideBackground />\n </StyledMotionWaitCursorWrapper>\n )}\n {!shouldShowWaitCursor && children && (\n <StyledMotionChildrenWrapper\n animate={{ opacity: 1, width: 'auto' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"children\"\n // style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2 }}\n >\n {children}\n </StyledMotionChildrenWrapper>\n )}\n </AnimatePresence>\n </StyledMotionButton>\n );\n};\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAAsCC,OAAO,QAAQ,OAAO;AACxE,SAASC,QAAQ,QAAQ,mBAAmB;AAE5C,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,iBAAiB,EACjBC,kBAAkB,EAClBC,2BAA2B,EAC3BC,6BAA6B,QAC1B,iBAAiB;AACxB,OAAOC,UAAU,MAAM,0BAA0B;AA6CjD,MAAMC,MAAuB,GAAGC,IAAA,IAW1B;EAAA,IAX2B;IAC7BC,QAAQ;IACRC,SAAS;IACTC,IAAI;IACJC,UAAU;IACVC,WAAW;IACXC,OAAO;IACPC,oBAAoB;IACpBC,qBAAqB;IACrBC,wBAAwB,GAAG,KAAK;IAChCC,4BAA4B,GAAG;EACnC,CAAC,GAAAV,IAAA;EACG,MAAMW,WAAiD,GAAIC,KAAK,IAAK;IACjE,IAAIJ,qBAAqB,EAAE;MACvBI,KAAK,CAACC,eAAe,CAAC,CAAC;IAC3B;IAEAP,OAAO,CAACM,KAAK,CAAC;EAClB,CAAC;EAED,MAAME,aAAa,GAAG1B,I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,KAAA,CAAAoC,aAAA,CAAC7B,6BAA6B;IAC1BqC,OAAO,EAAE;MAAEV,OAAO,EAAE,CAAC;MAAEe,KAAK,EAAE;IAAG,CAAE;IACnCC,IAAI,EAAE;MAAEhB,OAAO,EAAE,CAAC;MAAEe,KAAK,EAAE;IAAE,CAAE;IAC/BF,OAAO,EAAE;MAAEb,OAAO,EAAE,CAAC;MAAEe,KAAK,EAAE;IAAE,CAAE;IAClCE,GAAG,EAAC,aAAa;IACjBC,KAAK,EAAE;MAAEC,QAAQ,EAAE;IAAS,CAAE;IAC9BC,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,gBAE9BvD,KAAA,CAAAoC,aAAA,CAAC5B,UAAU;IAACwB,KAAK,EAAEN,SAAS,IAAI,OAAQ;IAAC8B,oBAAoB;EAAA,CAAE,CACpC,CAClC,EACA,CAACvC,oBAAoB,IAAIN,QAAQ,iBAC9BX,KAAA,CAAAoC,aAAA,CAAC9B,2BAA2B;IACxBsC,OAAO,EAAE;MAAEV,OAAO,EAAE,CAAC;MAAEe,KAAK,EAAE;IAAO,CAAE;IACvCC,IAAI,EAAE;MAAEhB,OAAO,EAAE,CAAC;MAAEe,KAAK,EAAE;IAAE,CAAE;IAC/BF,OAAO,EAAE;MAAEb,OAAO,EAAE,CAAC;MAAEe,KAAK,EAAE;IAAE,CAAE;IAClCE,GAAG,EAAC;IACJ;IAAA;IACAG,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,GAE7B5C,QACwB,CAEpB,CACD,CAAC;AAE7B,CAAC;AAEDF,MAAM,CAACgD,WAAW,GAAG,QAAQ;AAE7B,eAAehD,MAAM","ignoreList":[]}
|
|
@@ -3,9 +3,10 @@ import styled, { css } from 'styled-components';
|
|
|
3
3
|
export const StyledMotionButton = styled(motion.button)`
|
|
4
4
|
${_ref => {
|
|
5
5
|
let {
|
|
6
|
-
$
|
|
6
|
+
$shouldShowTextAsRobotoMedium,
|
|
7
|
+
$shouldShowAsSelectButton
|
|
7
8
|
} = _ref;
|
|
8
|
-
return $
|
|
9
|
+
return $shouldShowTextAsRobotoMedium && !$shouldShowAsSelectButton && css`
|
|
9
10
|
font-size: 110%;
|
|
10
11
|
font-family: 'Roboto Medium', serif;
|
|
11
12
|
`;
|
|
@@ -16,9 +17,10 @@ export const StyledMotionButton = styled(motion.button)`
|
|
|
16
17
|
${_ref2 => {
|
|
17
18
|
let {
|
|
18
19
|
$isSecondary,
|
|
20
|
+
$shouldShowAsSelectButton,
|
|
19
21
|
theme
|
|
20
22
|
} = _ref2;
|
|
21
|
-
if ($isSecondary) {
|
|
23
|
+
if ($isSecondary || $shouldShowAsSelectButton) {
|
|
22
24
|
return css`
|
|
23
25
|
color: ${theme.text};
|
|
24
26
|
`;
|
|
@@ -31,9 +33,10 @@ export const StyledMotionButton = styled(motion.button)`
|
|
|
31
33
|
${_ref3 => {
|
|
32
34
|
let {
|
|
33
35
|
theme,
|
|
34
|
-
$isSecondary
|
|
36
|
+
$isSecondary,
|
|
37
|
+
$shouldShowAsSelectButton
|
|
35
38
|
} = _ref3;
|
|
36
|
-
if (theme.buttonDesign === '2') {
|
|
39
|
+
if (theme.buttonDesign === '2' && !$shouldShowAsSelectButton) {
|
|
37
40
|
return css`
|
|
38
41
|
border: 1px solid ${$isSecondary ? theme['202'] : theme.buttonBackgroundColor};
|
|
39
42
|
box-shadow: none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.styles.js","names":["motion","styled","css","StyledMotionButton","button","_ref","$
|
|
1
|
+
{"version":3,"file":"Button.styles.js","names":["motion","styled","css","StyledMotionButton","button","_ref","$shouldShowTextAsRobotoMedium","$shouldShowAsSelectButton","_ref2","$isSecondary","theme","text","buttonDesign","buttonColor","buttonBackgroundColor","_ref3","_ref4","$isDisabled","_ref5","_ref6","$hasIcon","$hasChildren","StyledIconWrapper","span","StyledMotionChildrenWrapper","div","StyledMotionWaitCursorWrapper"],"sources":["../../../../src/components/button/Button.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledButtonProps = WithTheme<{\n $hasIcon: boolean;\n $hasChildren: boolean;\n $isDisabled?: boolean;\n $isSecondary?: boolean;\n $shouldShowTextAsRobotoMedium: boolean;\n $shouldShowAsSelectButton: boolean;\n}>;\n\nexport const StyledMotionButton = styled(motion.button)<StyledButtonProps>`\n ${({ $shouldShowTextAsRobotoMedium, $shouldShowAsSelectButton }) =>\n $shouldShowTextAsRobotoMedium &&\n !$shouldShowAsSelectButton &&\n css`\n font-size: 110%;\n font-family: 'Roboto Medium', serif;\n `}\n\n align-items: center;\n\n ${({ $isSecondary, $shouldShowAsSelectButton, theme }: StyledButtonProps) => {\n if ($isSecondary || $shouldShowAsSelectButton) {\n return css`\n color: ${theme.text};\n `;\n }\n\n return css`\n color: ${theme.buttonDesign === '2'\n ? theme.buttonColor ?? theme.buttonBackgroundColor ?? 'white'\n : theme.buttonColor ?? 'white'};\n `;\n }}\n\n ${({ theme, $isSecondary, $shouldShowAsSelectButton }: StyledButtonProps) => {\n if (theme.buttonDesign === '2' && !$shouldShowAsSelectButton) {\n return css`\n border: 1px solid ${$isSecondary ? theme['202'] : theme.buttonBackgroundColor};\n box-shadow: none;\n `;\n }\n\n return css`\n border: none;\n box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.2);\n `;\n }}\n\n border-radius: 3px;\n cursor: ${({ $isDisabled }) => ($isDisabled ? 'default' : 'pointer')};\n display: inline-flex;\n line-height: 1.15;\n min-height: 32px;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n position: relative;\n user-select: none;\n transition: opacity 0.3s ease;\n\n ${({ $hasIcon, $hasChildren }) => {\n if ($hasIcon) {\n if ($hasChildren) {\n return css`\n padding: 7px 12px 7px 42px;\n `;\n }\n return css`\n padding: 7px 12px 7px 18px;\n `;\n }\n return css`\n padding: 7px 12px 7px 12px;\n `;\n }}\n`;\n\nexport const StyledIconWrapper = styled.span`\n align-items: center;\n background-color: rgba(255, 255, 255, 0.2);\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n position: absolute;\n top: 0;\n width: 30px;\n`;\n\nexport const StyledMotionChildrenWrapper = styled(motion.div)<FramerMotionBugFix>``;\n\nexport const StyledMotionWaitCursorWrapper = styled(motion.div)<FramerMotionBugFix>`\n align-items: center;\n display: flex;\n justify-content: center;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAY/C,OAAO,MAAMC,kBAAkB,GAAGF,MAAM,CAACD,MAAM,CAACI,MAAM,CAAoB;AAC1E,MAAMC,IAAA;EAAA,IAAC;IAAEC,6BAA6B;IAAEC;EAA0B,CAAC,GAAAF,IAAA;EAAA,OAC3DC,6BAA6B,IAC7B,CAACC,yBAAyB,IAC1BL,GAAG;AACX;AACA;AACA,SAAS;AAAA;AACT;AACA;AACA;AACA,MAAMM,KAAA,IAA2E;EAAA,IAA1E;IAAEC,YAAY;IAAEF,yBAAyB;IAAEG;EAAyB,CAAC,GAAAF,KAAA;EACpE,IAAIC,YAAY,IAAIF,yBAAyB,EAAE;IAC3C,OAAOL,GAAG;AACtB,yBAAyBQ,KAAK,CAACC,IAAI;AACnC,aAAa;EACL;EAEA,OAAOT,GAAG;AAClB,qBAAqBQ,KAAK,CAACE,YAAY,KAAK,GAAG,GAC7BF,KAAK,CAACG,WAAW,IAAIH,KAAK,CAACI,qBAAqB,IAAI,OAAO,GAC3DJ,KAAK,CAACG,WAAW,IAAI,OAAO;AAC9C,SAAS;AACL,CAAC;AACL;AACA,MAAME,KAAA,IAA2E;EAAA,IAA1E;IAAEL,KAAK;IAAED,YAAY;IAAEF;EAA6C,CAAC,GAAAQ,KAAA;EACpE,IAAIL,KAAK,CAACE,YAAY,KAAK,GAAG,IAAI,CAACL,yBAAyB,EAAE;IAC1D,OAAOL,GAAG;AACtB,oCAAoCO,YAAY,GAAGC,KAAK,CAAC,KAAK,CAAC,GAAGA,KAAK,CAACI,qBAAqB;AAC7F;AACA,aAAa;EACL;EAEA,OAAOZ,GAAG;AAClB;AACA;AACA,SAAS;AACL,CAAC;AACL;AACA;AACA,cAAcc,KAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,KAAA;EAAA,OAAMC,WAAW,GAAG,SAAS,GAAG,SAAS;AAAA,CAAC;AACxE;AACA;AACA;AACA,eAAeC,KAAA;EAAA,IAAC;IAAED;EAAY,CAAC,GAAAC,KAAA;EAAA,OAAMD,WAAW,GAAG,GAAG,GAAG,CAAC;AAAA,CAAC;AAC3D;AACA;AACA;AACA;AACA,MAAME,KAAA,IAAgC;EAAA,IAA/B;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAAF,KAAA;EACzB,IAAIC,QAAQ,EAAE;IACV,IAAIC,YAAY,EAAE;MACd,OAAOnB,GAAG;AAC1B;AACA,iBAAiB;IACL;IACA,OAAOA,GAAG;AACtB;AACA,aAAa;EACL;EACA,OAAOA,GAAG;AAClB;AACA,SAAS;AACL,CAAC;AACL,CAAC;AAED,OAAO,MAAMoB,iBAAiB,GAAGrB,MAAM,CAACsB,IAAI;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAGvB,MAAM,CAACD,MAAM,CAACyB,GAAG,CAAqB,EAAE;AAEnF,OAAO,MAAMC,6BAA6B,GAAGzB,MAAM,CAACD,MAAM,CAACyB,GAAG,CAAqB;AACnF;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -66,7 +66,7 @@ const SelectButton = _ref => {
|
|
|
66
66
|
onClick: handleClick,
|
|
67
67
|
isDisabled: isDisabled,
|
|
68
68
|
isSecondary: true,
|
|
69
|
-
|
|
69
|
+
shouldShowTextAsRobotoMedium: false
|
|
70
70
|
}, selectedItemText ?? buttonText));
|
|
71
71
|
};
|
|
72
72
|
SelectButton.displayName = 'SelectButton';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectButton.js","names":["createDialog","DialogType","React","useMemo","Button","StyledSelectButton","SelectButton","_ref","onSelect","selectedItemIds","shouldAllowMultiSelect","buttonText","shouldShowSearch","list","isDisabled","itemList","items","forEach","_ref2","text","id","isSelected","includes","push","name","selectedItemText","length","newText","_ref3","handleClick","type","SELECT","multiselect","quickfind","open","then","result","buttonType","map","Number","createElement","onClick","isSecondary","
|
|
1
|
+
{"version":3,"file":"SelectButton.js","names":["createDialog","DialogType","React","useMemo","Button","StyledSelectButton","SelectButton","_ref","onSelect","selectedItemIds","shouldAllowMultiSelect","buttonText","shouldShowSearch","list","isDisabled","itemList","items","forEach","_ref2","text","id","isSelected","includes","push","name","selectedItemText","length","newText","_ref3","handleClick","type","SELECT","multiselect","quickfind","open","then","result","buttonType","map","Number","createElement","onClick","isSecondary","shouldShowTextAsRobotoMedium","displayName"],"sources":["../../../../src/components/select-button/SelectButton.tsx"],"sourcesContent":["import { createDialog, DialogType, type DialogSelectListItemType } from 'chayns-api';\nimport React, { useMemo, type FC } from 'react';\nimport type { SelectButtonItem } from '../../types/selectButton';\nimport Button from '../button/Button';\nimport { StyledSelectButton } from './SelectButton.styles';\n\nexport type SelectButtonProps = {\n /**\n * The text that should be displayed inside the button.\n */\n buttonText: string;\n /**\n * Whether the button should be disabled.\n */\n isDisabled?: boolean;\n /**\n * A list of item that could be selected.\n */\n list: SelectButtonItem[];\n /**\n * Function to be executed after an item is selected.\n */\n onSelect?: (ids: number[]) => void;\n /**\n * The id of an item that should be preselected.\n */\n selectedItemIds?: number[];\n /**\n * Whether more than one item should be selectable.\n */\n shouldAllowMultiSelect?: boolean;\n /**\n * Whether the search should be displayed inside the dialog.\n */\n shouldShowSearch?: boolean;\n};\n\nconst SelectButton: FC<SelectButtonProps> = ({\n onSelect,\n selectedItemIds,\n shouldAllowMultiSelect,\n buttonText,\n shouldShowSearch,\n list,\n isDisabled,\n}) => {\n const itemList = useMemo(() => {\n const items: DialogSelectListItemType[] = [];\n\n list.forEach(({ text, id }) => {\n const isSelected = selectedItemIds ? selectedItemIds.includes(id) : false;\n\n items.push({\n name: text,\n id,\n isSelected,\n });\n });\n\n return items;\n }, [list, selectedItemIds]);\n\n const selectedItemText = useMemo(() => {\n if (!selectedItemIds || selectedItemIds.length === 0) {\n return null;\n }\n\n let newText = '';\n\n list.forEach(({ text, id }) => {\n if (selectedItemIds?.includes(id)) {\n newText += newText.length === 0 ? `${text}` : `, ${text}`;\n }\n });\n\n return newText;\n }, [list, selectedItemIds]);\n\n const handleClick = () => {\n void createDialog({\n type: DialogType.SELECT,\n list: itemList,\n multiselect: shouldAllowMultiSelect,\n quickfind: shouldShowSearch,\n })\n .open()\n .then((result) => {\n // Ignore because there is no type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (result && result.buttonType === 1 && typeof onSelect === 'function') {\n // Ignore because there is no type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n onSelect((result.result as string[]).map(Number));\n }\n });\n };\n\n return (\n <StyledSelectButton>\n <Button\n onClick={handleClick}\n isDisabled={isDisabled}\n isSecondary\n shouldShowTextAsRobotoMedium={false}\n >\n {selectedItemText ?? buttonText}\n </Button>\n </StyledSelectButton>\n );\n};\n\nSelectButton.displayName = 'SelectButton';\n\nexport default SelectButton;\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,UAAU,QAAuC,YAAY;AACpF,OAAOC,KAAK,IAAIC,OAAO,QAAiB,OAAO;AAE/C,OAAOC,MAAM,MAAM,kBAAkB;AACrC,SAASC,kBAAkB,QAAQ,uBAAuB;AAiC1D,MAAMC,YAAmC,GAAGC,IAAA,IAQtC;EAAA,IARuC;IACzCC,QAAQ;IACRC,eAAe;IACfC,sBAAsB;IACtBC,UAAU;IACVC,gBAAgB;IAChBC,IAAI;IACJC;EACJ,CAAC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IAAI,CAAC,CAAC,CACNC,IAAI,CAAEC,MAAM,IAAK;MACd;MACA;MACA;MACA,IAAIA,MAAM,IAAIA,MAAM,CAACC,UAAU,KAAK,CAAC,IAAI,OAAO7B,QAAQ,KAAK,UAAU,EAAE;QACrE;QACA;QACA;QACAA,QAAQ,CAAE4B,MAAM,CAACA,MAAM,CAAcE,GAAG,CAACC,MAAM,CAAC,CAAC;MACrD;IACJ,CAAC,CAAC;EACV,CAAC;EAED,oBACIrC,KAAA,CAAAsC,aAAA,CAACnC,kBAAkB,qBACfH,KAAA,CAAAsC,aAAA,CAACpC,MAAM;IACHqC,OAAO,EAAEZ,WAAY;IACrBf,UAAU,EAAEA,UAAW;IACvB4B,WAAW;IACXC,4BAA4B,EAAE;EAAM,GAEnClB,gBAAgB,IAAId,UACjB,CACQ,CAAC;AAE7B,CAAC;AAEDL,YAAY,CAACsC,WAAW,GAAG,cAAc;AAEzC,eAAetC,YAAY","ignoreList":[]}
|
|
@@ -24,10 +24,14 @@ export type ButtonProps = {
|
|
|
24
24
|
* Function to be executed when the button is clicked
|
|
25
25
|
*/
|
|
26
26
|
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the button should be displayed as a selectButton.
|
|
29
|
+
*/
|
|
30
|
+
shouldShowAsSelectButton?: boolean;
|
|
27
31
|
/**
|
|
28
32
|
* Whether the text should be 'Roboto Medium'
|
|
29
33
|
*/
|
|
30
|
-
|
|
34
|
+
shouldShowTextAsRobotoMedium?: boolean;
|
|
31
35
|
/**
|
|
32
36
|
* Shows a wait cursor instead of button text
|
|
33
37
|
*/
|
|
@@ -6,7 +6,8 @@ type StyledButtonProps = WithTheme<{
|
|
|
6
6
|
$hasChildren: boolean;
|
|
7
7
|
$isDisabled?: boolean;
|
|
8
8
|
$isSecondary?: boolean;
|
|
9
|
-
$
|
|
9
|
+
$shouldShowTextAsRobotoMedium: boolean;
|
|
10
|
+
$shouldShowAsSelectButton: boolean;
|
|
10
11
|
}>;
|
|
11
12
|
export declare const StyledMotionButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<{
|
|
12
13
|
form?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.670",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "0be66bf9f4db571cbb155b1d8ad058e7d957037c"
|
|
89
89
|
}
|