@chayns-components/core 5.0.0-beta.592 → 5.0.0-beta.594
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/combobox/ComboBox.js +14 -12
- package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
- package/lib/cjs/components/combobox/ComboBox.styles.js +2 -2
- package/lib/cjs/components/combobox/ComboBox.styles.js.map +1 -1
- package/lib/cjs/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +0 -4
- package/lib/cjs/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
- package/lib/cjs/utils/calculate.js +20 -6
- package/lib/cjs/utils/calculate.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.js +15 -13
- package/lib/esm/components/combobox/ComboBox.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.styles.js +2 -2
- package/lib/esm/components/combobox/ComboBox.styles.js.map +1 -1
- package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +0 -4
- package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
- package/lib/esm/utils/calculate.js +18 -5
- package/lib/esm/utils/calculate.js.map +1 -1
- package/lib/types/components/accordion/Accordion.styles.d.ts +1 -1
- package/lib/types/components/accordion/accordion-body/AccordionBody.styles.d.ts +2 -2
- package/lib/types/components/accordion/accordion-content/AccordionContent.styles.d.ts +1 -1
- package/lib/types/components/accordion/accordion-head/AccordionHead.styles.d.ts +21 -21
- package/lib/types/components/accordion/accordion-intro/AccordionIntro.styles.d.ts +1 -1
- package/lib/types/components/accordion/accordion-item/AccordionItem.styles.d.ts +1 -1
- package/lib/types/components/amount-control/AmountControl.styles.d.ts +5 -5
- package/lib/types/components/badge/Badge.styles.d.ts +1 -1
- package/lib/types/components/button/Button.styles.d.ts +7 -7
- package/lib/types/components/checkbox/Checkbox.styles.d.ts +3 -3
- package/lib/types/components/combobox/ComboBox.styles.d.ts +9 -9
- package/lib/types/components/combobox/combobox-item/ComboBoxItem.styles.d.ts +2 -2
- package/lib/types/components/content-card/ContentCard.styles.d.ts +1 -1
- package/lib/types/components/context-menu/ContextMenu.styles.d.ts +1 -1
- package/lib/types/components/context-menu/context-menu-content/ContextMenuContent.styles.d.ts +6 -6
- package/lib/types/components/file-input/FileInput.styles.d.ts +8 -8
- package/lib/types/components/file-input/file-list/FileListItem.styles.d.ts +1 -1
- package/lib/types/components/filter-buttons/FilterButtons.styles.d.ts +1 -1
- package/lib/types/components/filter-buttons/filter-button/FilterButton.styles.d.ts +9 -9
- package/lib/types/components/grid-image/GridImage.styles.d.ts +4 -4
- package/lib/types/components/icon/Icon.styles.d.ts +2 -2
- package/lib/types/components/input/Input.styles.d.ts +11 -11
- package/lib/types/components/list/list-item/ListItem.styles.d.ts +2 -2
- package/lib/types/components/list/list-item/list-item-body/ListItemBody.styles.d.ts +2 -2
- package/lib/types/components/list/list-item/list-item-content/ListItemContent.styles.d.ts +1 -1
- package/lib/types/components/list/list-item/list-item-head/ListItemHead.styles.d.ts +20 -20
- package/lib/types/components/list/list-item/list-item-head/list-item-icon/ListItemIcon.styles.d.ts +1 -1
- package/lib/types/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.d.ts +2 -2
- package/lib/types/components/mention-finder/MentionFinder.styles.d.ts +3 -3
- package/lib/types/components/mention-finder/mention-finder-item/MentionFinderItem.styles.d.ts +5 -5
- package/lib/types/components/popup/Popup.styles.d.ts +3 -3
- package/lib/types/components/popup/popup-content/PopupContent.styles.d.ts +1 -1
- package/lib/types/components/popup/popup-content-wrapper/PopupContentWrapper.styles.d.ts +2 -2
- package/lib/types/components/progress-bar/ProgressBar.styles.d.ts +8 -8
- package/lib/types/components/radio-button/RadioButton.styles.d.ts +9 -9
- package/lib/types/components/scroll-view/ScrollView.styles.d.ts +1 -1
- package/lib/types/components/search-box/SearchBox.styles.d.ts +3 -3
- package/lib/types/components/search-box/group-name/GroupName.styles.d.ts +1 -1
- package/lib/types/components/search-box/search-box-item/SearchBoxItem.styles.d.ts +5 -5
- package/lib/types/components/search-input/SearchInput.styles.d.ts +6 -6
- package/lib/types/components/select-button/SelectButton.styles.d.ts +1 -1
- package/lib/types/components/setup-wizard/SetupWizard.styles.d.ts +1 -1
- package/lib/types/components/setup-wizard/setup-wizard-item/SetupWizardItem.styles.d.ts +1 -1
- package/lib/types/components/sharing-bar/SharingBar.styles.d.ts +4 -4
- package/lib/types/components/signature/Signature.styles.d.ts +5 -5
- package/lib/types/components/slider/Slider.styles.d.ts +7 -7
- package/lib/types/components/slider-button/SliderButton.styles.d.ts +4 -4
- package/lib/types/components/small-wait-cursor/SmallWaitCursor.styles.d.ts +4 -4
- package/lib/types/components/tag-input/TagInput.styles.d.ts +6 -6
- package/lib/types/components/text-area/TextArea.styles.d.ts +5 -5
- package/lib/types/components/tooltip/Tooltip.styles.d.ts +1 -1
- package/lib/types/components/tooltip/tooltip-item/TooltipItem.styles.d.ts +7 -7
- package/lib/types/components/truncation/Truncation.styles.d.ts +6 -6
- package/lib/types/utils/calculate.d.ts +2 -0
- package/package.json +12 -12
|
@@ -19,7 +19,7 @@ const ComboBox = ({
|
|
|
19
19
|
direction = _comboBox.ComboBoxDirection.BOTTOM,
|
|
20
20
|
isDisabled = false,
|
|
21
21
|
list,
|
|
22
|
-
maxHeight = '
|
|
22
|
+
maxHeight = '280px',
|
|
23
23
|
onSelect,
|
|
24
24
|
placeholder,
|
|
25
25
|
selectedItem,
|
|
@@ -28,19 +28,19 @@ const ComboBox = ({
|
|
|
28
28
|
const [item, setItem] = (0, _react.useState)();
|
|
29
29
|
const [isAnimating, setIsAnimating] = (0, _react.useState)(false);
|
|
30
30
|
const [minWidth, setMinWidth] = (0, _react.useState)(0);
|
|
31
|
-
const [height, setHeight] = (0, _react.useState)(0);
|
|
32
31
|
const [focusedIndex, setFocusedIndex] = (0, _react.useState)(null);
|
|
33
|
-
const
|
|
32
|
+
const [overflowY, setOverflowY] = (0, _react.useState)('hidden');
|
|
33
|
+
const styledComboBoxElementRef = (0, _react.useRef)(null);
|
|
34
34
|
const contentRef = (0, _react.useRef)(null);
|
|
35
35
|
const {
|
|
36
36
|
browser
|
|
37
37
|
} = (0, _chaynsApi.getDevice)();
|
|
38
38
|
const isMobile = (0, _environment.getIsMobile)();
|
|
39
39
|
const handleClick = (0, _react.useCallback)(event => {
|
|
40
|
-
if (
|
|
40
|
+
if (styledComboBoxElementRef.current && !styledComboBoxElementRef.current.contains(event.target)) {
|
|
41
41
|
setIsAnimating(false);
|
|
42
42
|
}
|
|
43
|
-
}, [
|
|
43
|
+
}, [styledComboBoxElementRef]);
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* This function adds an event listener to the document to close the combobox when the user clicks outside of it
|
|
@@ -50,7 +50,7 @@ const ComboBox = ({
|
|
|
50
50
|
return () => {
|
|
51
51
|
document.removeEventListener('click', handleClick);
|
|
52
52
|
};
|
|
53
|
-
}, [handleClick,
|
|
53
|
+
}, [handleClick, styledComboBoxElementRef]);
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* This function sets the selected item
|
|
@@ -113,7 +113,9 @@ const ComboBox = ({
|
|
|
113
113
|
const textArray = list.map(({
|
|
114
114
|
text
|
|
115
115
|
}) => text);
|
|
116
|
-
|
|
116
|
+
const contentHeight = (0, _calculate.calculateContentHeight)(textArray);
|
|
117
|
+
const maxHeightInPixels = (0, _calculate.getMaxHeightInPixels)(maxHeight, styledComboBoxElementRef.current ?? document.body);
|
|
118
|
+
setOverflowY(contentHeight > maxHeightInPixels ? 'scroll' : 'hidden');
|
|
117
119
|
textArray.push(placeholder);
|
|
118
120
|
|
|
119
121
|
// 45px = padding left + padding right + border left + border right + arrow icon width + arrow icon margin left
|
|
@@ -122,7 +124,7 @@ const ComboBox = ({
|
|
|
122
124
|
text: placeholder,
|
|
123
125
|
value: 'placeholder'
|
|
124
126
|
}]) + 45 + (isAtLeastOneItemWithImageGiven ? 32 : 0));
|
|
125
|
-
}, [list, placeholder]);
|
|
127
|
+
}, [list, maxHeight, placeholder]);
|
|
126
128
|
|
|
127
129
|
/**
|
|
128
130
|
* This function sets the external selected item
|
|
@@ -192,7 +194,7 @@ const ComboBox = ({
|
|
|
192
194
|
return /*#__PURE__*/_react.default.createElement(_ComboBox.StyledMotionComboBoxBody, {
|
|
193
195
|
$browser: browser === null || browser === void 0 ? void 0 : browser.name,
|
|
194
196
|
animate: animate,
|
|
195
|
-
$
|
|
197
|
+
$overflowY: overflowY,
|
|
196
198
|
initial: {
|
|
197
199
|
height: 0,
|
|
198
200
|
opacity: 0
|
|
@@ -207,9 +209,9 @@ const ComboBox = ({
|
|
|
207
209
|
tabIndex: 0,
|
|
208
210
|
ref: contentRef
|
|
209
211
|
}, items);
|
|
210
|
-
}, [browser === null || browser === void 0 ? void 0 : browser.name, direction, handleSetSelectedItem,
|
|
212
|
+
}, [browser === null || browser === void 0 ? void 0 : browser.name, direction, handleSetSelectedItem, isAnimating, list, maxHeight, minWidth, overflowY, selectedItem, shouldShowRoundImage]);
|
|
211
213
|
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBox, {
|
|
212
|
-
ref:
|
|
214
|
+
ref: styledComboBoxElementRef
|
|
213
215
|
}, direction === _comboBox.ComboBoxDirection.TOP && comboBoxBody, /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxHeader, {
|
|
214
216
|
$direction: direction,
|
|
215
217
|
$minWidth: minWidth,
|
|
@@ -222,7 +224,7 @@ const ComboBox = ({
|
|
|
222
224
|
shouldShowRoundImage: shouldShowRoundImage
|
|
223
225
|
}), placeholderText, item && item.suffixElement && item.suffixElement), /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxIconWrapper, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
224
226
|
icons: ['fa fa-chevron-down']
|
|
225
|
-
}))), direction === _comboBox.ComboBoxDirection.BOTTOM && comboBoxBody), [comboBoxBody, direction, handleHeaderClick, isAnimating, isDisabled, isMobile, minWidth, placeholderImageUrl, placeholderText, shouldShowRoundImage]);
|
|
227
|
+
}))), direction === _comboBox.ComboBoxDirection.BOTTOM && comboBoxBody), [comboBoxBody, direction, handleHeaderClick, isAnimating, isDisabled, isMobile, item, minWidth, placeholderImageUrl, placeholderText, shouldShowRoundImage]);
|
|
226
228
|
};
|
|
227
229
|
ComboBox.displayName = 'ComboBox';
|
|
228
230
|
var _default = exports.default = ComboBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_comboBox","_calculate","_environment","_Icon","_interopRequireDefault","_ComboBoxItem","_ComboBox","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ComboBox","direction","ComboBoxDirection","BOTTOM","isDisabled","list","maxHeight","onSelect","placeholder","selectedItem","shouldShowRoundImage","item","setItem","useState","isAnimating","setIsAnimating","minWidth","setMinWidth","height","setHeight","focusedIndex","setFocusedIndex","ref","useRef","contentRef","browser","getDevice","isMobile","getIsMobile","handleClick","useCallback","event","current","contains","target","useEffect","document","addEventListener","removeEventListener","handleSetSelectedItem","itemToSelect","handleKeyDown","key","_contentRef$current","preventDefault","children","length","newIndex","prevElement","tabIndex","newElement","focus","_contentRef$current2","element","id","newSelectedItem","find","value","String","replace","isAtLeastOneItemWithImageGiven","some","imageUrl","textArray","map","text","calculateContentHeight","push","calculateContentWidth","placeholderImageUrl","useMemo","undefined","placeholderText","handleHeaderClick","prevState","comboBoxBody","items","suffixElement","createElement","isSelected","animate","opacity","style","TOP","transform","StyledMotionComboBoxBody","$browser","name","$height","initial","$maxHeight","$minWidth","$direction","transition","duration","StyledComboBox","StyledComboBoxHeader","onClick","$isOpen","$isMobile","$isDisabled","StyledComboBoxPlaceholder","StyledComboBoxPlaceholderImage","src","StyledComboBoxIconWrapper","icons","displayName","_default","exports"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { getDevice } from 'chayns-api';\nimport React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { ComboBoxDirection } from '../../types/comboBox';\nimport { calculateContentHeight, calculateContentWidth } from '../../utils/calculate';\nimport { getIsMobile } from '../../utils/environment';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledMotionComboBoxBody,\n} from './ComboBox.styles';\n\nexport interface IComboBoxItem {\n imageUrl?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n}\n\nexport type ComboBoxProps = {\n /**\n * The direction in which the combobox should open.\n */\n direction?: ComboBoxDirection;\n /**\n * Whether the combobox should be disabled.\n */\n isDisabled?: boolean;\n /**\n * The list of the items that should be displayed.\n */\n list: IComboBoxItem[];\n /**\n * The maximum height of the combobox content.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * Function that should be executed when an item is selected.\n */\n onSelect?: (comboboxItem: IComboBoxItem) => void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * An item that should be preselected.\n */\n selectedItem?: IComboBoxItem;\n /**\n * If true, the images of the items are displayed in a round shape.\n */\n shouldShowRoundImage?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n direction = ComboBoxDirection.BOTTOM,\n isDisabled = false,\n list,\n maxHeight = '300px',\n onSelect,\n placeholder,\n selectedItem,\n shouldShowRoundImage,\n}) => {\n const [item, setItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n const ref = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const { browser } = getDevice();\n\n const isMobile = getIsMobile();\n\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsAnimating(false);\n }\n },\n [ref],\n );\n\n /**\n * This function adds an event listener to the document to close the combobox when the user clicks outside of it\n */\n useEffect(() => {\n document.addEventListener('click', handleClick);\n\n return () => {\n document.removeEventListener('click', handleClick);\n };\n }, [handleClick, ref]);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect: IComboBoxItem) => {\n setItem(itemToSelect);\n setIsAnimating(false);\n\n if (onSelect) {\n onSelect(itemToSelect);\n }\n },\n [onSelect],\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n const children = contentRef.current?.children;\n if (children && children.length > 0) {\n const newIndex =\n focusedIndex !== null\n ? (focusedIndex + (e.key === 'ArrowUp' ? -1 : 1) + children.length) %\n children.length\n : 0;\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const newElement = children[newIndex] as HTMLDivElement;\n newElement.tabIndex = 0;\n newElement.focus();\n }\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) {\n return;\n }\n\n const { id } = element;\n\n const newSelectedItem = list.find(\n ({ value }) => String(value) === id.replace('combobox-item__', ''),\n );\n\n if (!newSelectedItem) {\n return;\n }\n\n handleSetSelectedItem(newSelectedItem);\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [focusedIndex, handleSetSelectedItem, list]);\n\n /**\n * This function calculates the greatest width\n */\n useEffect(() => {\n const isAtLeastOneItemWithImageGiven = list.some(({ imageUrl }) => imageUrl);\n\n const textArray = list.map(({ text }) => text);\n\n setHeight(calculateContentHeight(textArray));\n\n textArray.push(placeholder);\n\n // 45px = padding left + padding right + border left + border right + arrow icon width + arrow icon margin left\n // 32px = image width + flex gap\n setMinWidth(\n calculateContentWidth([...list, { text: placeholder, value: 'placeholder' }]) +\n 45 +\n (isAtLeastOneItemWithImageGiven ? 32 : 0),\n );\n }, [list, placeholder]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n setIsAnimating(false);\n setItem(selectedItem);\n }, [selectedItem]);\n\n const placeholderImageUrl = useMemo(() => {\n if (selectedItem) {\n return selectedItem.imageUrl;\n }\n\n if (item) {\n return item.imageUrl;\n }\n\n return undefined;\n }, [item, selectedItem]);\n\n /**\n * This function resets the placeholder\n */\n const placeholderText = useMemo(() => {\n let text = placeholder;\n\n if (selectedItem) {\n text = selectedItem.text;\n } else if (item) {\n text = item.text;\n }\n\n return text;\n }, [item, placeholder, selectedItem]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = useCallback(() => {\n if (!isDisabled) {\n setIsAnimating((prevState) => !prevState);\n }\n }, [isDisabled]);\n\n const comboBoxBody = useMemo(() => {\n const items = list.map(({ imageUrl, suffixElement, text, value }) => (\n <ComboBoxItem\n imageUrl={imageUrl}\n isSelected={selectedItem ? value === selectedItem.value : false}\n key={value}\n id={value}\n onSelect={handleSetSelectedItem}\n shouldShowRoundImage={shouldShowRoundImage}\n suffixElement={suffixElement}\n text={text}\n value={value}\n />\n ));\n\n const animate = isAnimating\n ? { height: 'fit-content', opacity: 1 }\n : { height: 0, opacity: 0 };\n\n const style =\n direction === ComboBoxDirection.TOP ? { transform: 'translateY(-100%)' } : undefined;\n\n return (\n <StyledMotionComboBoxBody\n $browser={browser?.name}\n animate={animate}\n $height={height}\n initial={{ height: 0, opacity: 0 }}\n $maxHeight={maxHeight}\n $minWidth={minWidth}\n style={style}\n $direction={direction}\n transition={{ duration: 0.2 }}\n tabIndex={0}\n ref={contentRef}\n >\n {items}\n </StyledMotionComboBoxBody>\n );\n }, [\n browser?.name,\n direction,\n handleSetSelectedItem,\n height,\n isAnimating,\n list,\n maxHeight,\n minWidth,\n selectedItem,\n shouldShowRoundImage,\n ]);\n\n return useMemo(\n () => (\n <StyledComboBox ref={ref}>\n {direction === ComboBoxDirection.TOP && comboBoxBody}\n <StyledComboBoxHeader\n $direction={direction}\n $minWidth={minWidth}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isMobile={isMobile}\n $isDisabled={isDisabled}\n >\n <StyledComboBoxPlaceholder>\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n {placeholderText}\n {item && item.suffixElement && item.suffixElement}\n </StyledComboBoxPlaceholder>\n <StyledComboBoxIconWrapper>\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n </StyledComboBoxHeader>\n {direction === ComboBoxDirection.BOTTOM && comboBoxBody}\n </StyledComboBox>\n ),\n [\n comboBoxBody,\n direction,\n handleHeaderClick,\n isAnimating,\n isDisabled,\n isMobile,\n minWidth,\n placeholderImageUrl,\n placeholderText,\n shouldShowRoundImage,\n ],\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAUA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAO2B,SAAAO,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA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wE,YAC/B,CACnB,EACD,CACIA,YAAY,EACZ1E,SAAS,EACTwE,iBAAiB,EACjB3D,WAAW,EACXV,UAAU,EACVuB,QAAQ,EACRX,QAAQ,EACRqD,mBAAmB,EACnBG,eAAe,EACf9D,oBAAoB,CAE5B,CAAC;AACL,CAAC;AAEDV,QAAQ,CAAC0G,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA/H,OAAA,GAEnBmB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ComboBox.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_comboBox","_calculate","_environment","_Icon","_interopRequireDefault","_ComboBoxItem","_ComboBox","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ComboBox","direction","ComboBoxDirection","BOTTOM","isDisabled","list","maxHeight","onSelect","placeholder","selectedItem","shouldShowRoundImage","item","setItem","useState","isAnimating","setIsAnimating","minWidth","setMinWidth","focusedIndex","setFocusedIndex","overflowY","setOverflowY","styledComboBoxElementRef","useRef","contentRef","browser","getDevice","isMobile","getIsMobile","handleClick","useCallback","event","current","contains","target","useEffect","document","addEventListener","removeEventListener","handleSetSelectedItem","itemToSelect","handleKeyDown","key","_contentRef$current","preventDefault","children","length","newIndex","prevElement","tabIndex","newElement","focus","_contentRef$current2","element","id","newSelectedItem","find","value","String","replace","isAtLeastOneItemWithImageGiven","some","imageUrl","textArray","map","text","contentHeight","calculateContentHeight","maxHeightInPixels","getMaxHeightInPixels","body","push","calculateContentWidth","placeholderImageUrl","useMemo","undefined","placeholderText","handleHeaderClick","prevState","comboBoxBody","items","suffixElement","createElement","isSelected","animate","height","opacity","style","TOP","transform","StyledMotionComboBoxBody","$browser","name","$overflowY","initial","$maxHeight","$minWidth","$direction","transition","duration","ref","StyledComboBox","StyledComboBoxHeader","onClick","$isOpen","$isMobile","$isDisabled","StyledComboBoxPlaceholder","StyledComboBoxPlaceholderImage","src","StyledComboBoxIconWrapper","icons","displayName","_default","exports"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { getDevice } from 'chayns-api';\nimport React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { ComboBoxDirection } from '../../types/comboBox';\nimport {\n calculateContentHeight,\n calculateContentWidth,\n getMaxHeightInPixels,\n} from '../../utils/calculate';\nimport { getIsMobile } from '../../utils/environment';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledMotionComboBoxBody,\n} from './ComboBox.styles';\n\nexport interface IComboBoxItem {\n imageUrl?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n}\n\nexport type ComboBoxProps = {\n /**\n * The direction in which the combobox should open.\n */\n direction?: ComboBoxDirection;\n /**\n * Whether the combobox should be disabled.\n */\n isDisabled?: boolean;\n /**\n * The list of the items that should be displayed.\n */\n list: IComboBoxItem[];\n /**\n * The maximum height of the combobox content.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * Function that should be executed when an item is selected.\n */\n onSelect?: (comboboxItem: IComboBoxItem) => void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * An item that should be preselected.\n */\n selectedItem?: IComboBoxItem;\n /**\n * If true, the images of the items are displayed in a round shape.\n */\n shouldShowRoundImage?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n direction = ComboBoxDirection.BOTTOM,\n isDisabled = false,\n list,\n maxHeight = '280px',\n onSelect,\n placeholder,\n selectedItem,\n shouldShowRoundImage,\n}) => {\n const [item, setItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n const [overflowY, setOverflowY] = useState<CSSProperties['overflowY']>('hidden');\n\n const styledComboBoxElementRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const { browser } = getDevice();\n\n const isMobile = getIsMobile();\n\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (\n styledComboBoxElementRef.current &&\n !styledComboBoxElementRef.current.contains(event.target as Node)\n ) {\n setIsAnimating(false);\n }\n },\n [styledComboBoxElementRef],\n );\n\n /**\n * This function adds an event listener to the document to close the combobox when the user clicks outside of it\n */\n useEffect(() => {\n document.addEventListener('click', handleClick);\n\n return () => {\n document.removeEventListener('click', handleClick);\n };\n }, [handleClick, styledComboBoxElementRef]);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect: IComboBoxItem) => {\n setItem(itemToSelect);\n setIsAnimating(false);\n\n if (onSelect) {\n onSelect(itemToSelect);\n }\n },\n [onSelect],\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n const children = contentRef.current?.children;\n if (children && children.length > 0) {\n const newIndex =\n focusedIndex !== null\n ? (focusedIndex + (e.key === 'ArrowUp' ? -1 : 1) + children.length) %\n children.length\n : 0;\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const newElement = children[newIndex] as HTMLDivElement;\n newElement.tabIndex = 0;\n newElement.focus();\n }\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) {\n return;\n }\n\n const { id } = element;\n\n const newSelectedItem = list.find(\n ({ value }) => String(value) === id.replace('combobox-item__', ''),\n );\n\n if (!newSelectedItem) {\n return;\n }\n\n handleSetSelectedItem(newSelectedItem);\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [focusedIndex, handleSetSelectedItem, list]);\n\n /**\n * This function calculates the greatest width\n */\n useEffect(() => {\n const isAtLeastOneItemWithImageGiven = list.some(({ imageUrl }) => imageUrl);\n\n const textArray = list.map(({ text }) => text);\n\n const contentHeight = calculateContentHeight(textArray);\n\n const maxHeightInPixels = getMaxHeightInPixels(\n maxHeight,\n styledComboBoxElementRef.current ?? document.body,\n );\n\n setOverflowY(contentHeight > maxHeightInPixels ? 'scroll' : 'hidden');\n\n textArray.push(placeholder);\n\n // 45px = padding left + padding right + border left + border right + arrow icon width + arrow icon margin left\n // 32px = image width + flex gap\n setMinWidth(\n calculateContentWidth([...list, { text: placeholder, value: 'placeholder' }]) +\n 45 +\n (isAtLeastOneItemWithImageGiven ? 32 : 0),\n );\n }, [list, maxHeight, placeholder]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n setIsAnimating(false);\n setItem(selectedItem);\n }, [selectedItem]);\n\n const placeholderImageUrl = useMemo(() => {\n if (selectedItem) {\n return selectedItem.imageUrl;\n }\n\n if (item) {\n return item.imageUrl;\n }\n\n return undefined;\n }, [item, selectedItem]);\n\n /**\n * This function resets the placeholder\n */\n const placeholderText = useMemo(() => {\n let text = placeholder;\n\n if (selectedItem) {\n text = selectedItem.text;\n } else if (item) {\n text = item.text;\n }\n\n return text;\n }, [item, placeholder, selectedItem]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = useCallback(() => {\n if (!isDisabled) {\n setIsAnimating((prevState) => !prevState);\n }\n }, [isDisabled]);\n\n const comboBoxBody = useMemo(() => {\n const items = list.map(({ imageUrl, suffixElement, text, value }) => (\n <ComboBoxItem\n imageUrl={imageUrl}\n isSelected={selectedItem ? value === selectedItem.value : false}\n key={value}\n id={value}\n onSelect={handleSetSelectedItem}\n shouldShowRoundImage={shouldShowRoundImage}\n suffixElement={suffixElement}\n text={text}\n value={value}\n />\n ));\n\n const animate = isAnimating\n ? { height: 'fit-content', opacity: 1 }\n : { height: 0, opacity: 0 };\n\n const style =\n direction === ComboBoxDirection.TOP ? { transform: 'translateY(-100%)' } : undefined;\n\n return (\n <StyledMotionComboBoxBody\n $browser={browser?.name}\n animate={animate}\n $overflowY={overflowY}\n initial={{ height: 0, opacity: 0 }}\n $maxHeight={maxHeight}\n $minWidth={minWidth}\n style={style}\n $direction={direction}\n transition={{ duration: 0.2 }}\n tabIndex={0}\n ref={contentRef}\n >\n {items}\n </StyledMotionComboBoxBody>\n );\n }, [\n browser?.name,\n direction,\n handleSetSelectedItem,\n isAnimating,\n list,\n maxHeight,\n minWidth,\n overflowY,\n selectedItem,\n shouldShowRoundImage,\n ]);\n\n return useMemo(\n () => (\n <StyledComboBox ref={styledComboBoxElementRef}>\n {direction === ComboBoxDirection.TOP && comboBoxBody}\n <StyledComboBoxHeader\n $direction={direction}\n $minWidth={minWidth}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isMobile={isMobile}\n $isDisabled={isDisabled}\n >\n <StyledComboBoxPlaceholder>\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n {placeholderText}\n {item && item.suffixElement && item.suffixElement}\n </StyledComboBoxPlaceholder>\n <StyledComboBoxIconWrapper>\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n </StyledComboBoxHeader>\n {direction === ComboBoxDirection.BOTTOM && comboBoxBody}\n </StyledComboBox>\n ),\n [\n comboBoxBody,\n direction,\n handleHeaderClick,\n isAnimating,\n isDisabled,\n isMobile,\n item,\n minWidth,\n placeholderImageUrl,\n placeholderText,\n shouldShowRoundImage,\n ],\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,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,OAAA,CAAAqG,aAAA,CAACxG,SAAA,CAAAiI,yBAAyB,QACrBlC,mBAAmB,iBAChBvG,MAAA,CAAAW,OAAA,CAAAqG,aAAA,CAACxG,SAAA,CAAAkI,8BAA8B;IAC3BC,GAAG,EAAEpC,mBAAoB;IACzB/D,oBAAoB,EAAEA;EAAqB,CAC9C,CACJ,EACAkE,eAAe,EACfjE,IAAI,IAAIA,IAAI,CAACsE,aAAa,IAAItE,IAAI,CAACsE,aACb,CAAC,eAC5B/G,MAAA,CAAAW,OAAA,CAAAqG,aAAA,CAACxG,SAAA,CAAAoI,yBAAyB,qBACtB5I,MAAA,CAAAW,OAAA,CAAAqG,aAAA,CAAC3G,KAAA,CAAAM,OAAI;IAACkI,KAAK,EAAE,CAAC,oBAAoB;EAAE,CAAE,CACf,CACT,CAAC,EACtB9G,SAAS,KAAKC,2BAAiB,CAACC,MAAM,IAAI4E,YAC/B,CACnB,EACD,CACIA,YAAY,EACZ9E,SAAS,EACT4E,iBAAiB,EACjB/D,WAAW,EACXV,UAAU,EACVuB,QAAQ,EACRhB,IAAI,EACJK,QAAQ,EACRyD,mBAAmB,EACnBG,eAAe,EACflE,oBAAoB,CAE5B,CAAC;AACL,CAAC;AAEDV,QAAQ,CAACgH,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAArI,OAAA,GAEnBmB,QAAQ","ignoreList":[]}
|
|
@@ -108,8 +108,8 @@ const StyledMotionComboBoxBody = exports.StyledMotionComboBoxBody = (0, _styledC
|
|
|
108
108
|
$maxHeight
|
|
109
109
|
}) => $maxHeight};
|
|
110
110
|
overflow-y: ${({
|
|
111
|
-
$
|
|
112
|
-
}) => $
|
|
111
|
+
$overflowY
|
|
112
|
+
}) => $overflowY};
|
|
113
113
|
|
|
114
114
|
${({
|
|
115
115
|
$direction,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_comboBox","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledComboBox","exports","styled","div","StyledComboBoxHeader","$isDisabled","theme","$minWidth","$isOpen","$direction","ComboBoxDirection","BOTTOM","css","$isMobile","StyledComboBoxPlaceholder","text","StyledComboBoxPlaceholderImage","img","shouldShowRoundImage","StyledComboBoxIconWrapper","StyledMotionComboBoxBody","motion","$maxHeight","$
|
|
1
|
+
{"version":3,"file":"ComboBox.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_comboBox","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledComboBox","exports","styled","div","StyledComboBoxHeader","$isDisabled","theme","$minWidth","$isOpen","$direction","ComboBoxDirection","BOTTOM","css","$isMobile","StyledComboBoxPlaceholder","text","StyledComboBoxPlaceholderImage","img","shouldShowRoundImage","StyledComboBoxIconWrapper","StyledMotionComboBoxBody","motion","$maxHeight","$overflowY","$browser"],"sources":["../../../../src/components/combobox/ComboBox.styles.ts"],"sourcesContent":["import type { Browser } from 'detect-browser';\nimport { motion } from 'framer-motion';\nimport type { CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\nimport { ComboBoxDirection } from '../../types/comboBox';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { ComboBoxItemProps } from './combobox-item/ComboBoxItem';\n\nexport const StyledComboBox = styled.div`\n user-select: none;\n width: fit-content;\n`;\n\ntype StyledComboBoxHeaderProps = WithTheme<{\n $isMobile: boolean;\n $isOpen: boolean;\n $minWidth: number;\n $direction: ComboBoxDirection;\n $isDisabled?: boolean;\n}>;\n\nexport const StyledComboBoxHeader = styled.div<StyledComboBoxHeaderProps>`\n display: flex;\n justify-content: space-between;\n border: 1px solid rgba(160, 160, 160, 0.3);\n padding: 4px 10px;\n cursor: ${({ $isDisabled }) => (!$isDisabled ? 'pointer' : 'default')};\n background: ${({ theme }: StyledComboBoxHeaderProps) => theme['001']};\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n min-width: ${({ $minWidth }) => $minWidth}px;\n max-width: ${({ $minWidth }) => $minWidth}px;\n transition: background-color 0.2s ease-in-out;\n\n ${({ $isOpen, $direction }) => {\n if ($isOpen) {\n return $direction === ComboBoxDirection.BOTTOM\n ? css`\n border-top-left-radius: 3px;\n border-top-right-radius: 3px;\n `\n : css`\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n `;\n }\n\n return css`\n border-radius: 3px;\n `;\n }}\n\n ${({ $isMobile, $isDisabled, theme }: StyledComboBoxHeaderProps) =>\n !$isMobile &&\n !$isDisabled &&\n css`\n &:hover {\n background-color: ${theme['secondary-102']};\n }\n `}\n`;\n\ntype StyledComboBoxPlaceholderProps = WithTheme<unknown>;\n\nexport const StyledComboBoxPlaceholder = styled.div<StyledComboBoxPlaceholderProps>`\n align-items: center;\n color: ${({ theme }: StyledComboBoxPlaceholderProps) => theme.text};\n display: flex;\n gap: 10px;\n`;\n\ntype StyledComboBoxPlaceholderImageProps = WithTheme<\n Pick<ComboBoxItemProps, 'shouldShowRoundImage'>\n>;\n\nexport const StyledComboBoxPlaceholderImage = styled.img<StyledComboBoxPlaceholderImageProps>`\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledComboBoxPlaceholderImageProps) => theme['009-rgb']}, 0.15);\n height: 22px;\n width: 22px;\n\n ${({ shouldShowRoundImage }) =>\n shouldShowRoundImage &&\n css`\n border-radius: 50%;\n `}\n`;\n\nexport const StyledComboBoxIconWrapper = styled.div`\n margin-left: 5px;\n`;\n\ntype StyledComboBoxBodyProps = WithTheme<{\n $overflowY: CSSProperties['overflowY'];\n $minWidth: number;\n $maxHeight: CSSProperties['maxHeight'];\n $direction: ComboBoxDirection;\n $browser: Browser | 'bot' | null | undefined;\n}>;\n\nexport const StyledMotionComboBoxBody = styled(motion.div)<StyledComboBoxBodyProps>`\n background: ${({ theme }: StyledComboBoxBodyProps) => theme['101']};\n display: flex;\n position: absolute;\n z-index: 4;\n flex-direction: column;\n border: 1px solid rgba(160, 160, 160, 0.3);\n cursor: pointer;\n min-width: ${({ $minWidth }) => $minWidth}px;\n max-width: ${({ $minWidth }) => $minWidth}px;\n max-height: ${({ $maxHeight }) => $maxHeight};\n overflow-y: ${({ $overflowY }) => $overflowY};\n\n ${({ $direction, theme }) => {\n if ($direction === ComboBoxDirection.BOTTOM) {\n return css`\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n box-shadow: 0 2px 8px 2px rgba(${theme['009-rgb']}, 0.15);\n `;\n }\n\n return css`\n border-top-left-radius: 3px;\n border-top-right-radius: 3px;\n box-shadow: 0 -2px 8px 2px rgba(${theme['009-rgb']}, 0.15);\n `;\n }}\n\n // Styles for custom scrollbar\n ${({ $browser, theme }: StyledComboBoxBodyProps) =>\n $browser === 'firefox'\n ? css`\n scrollbar-color: rgba(${theme['text-rgb']}, 0.15) transparent;\n scrollbar-width: thin;\n `\n : css`\n &::-webkit-scrollbar {\n width: 5px;\n }\n\n &::-webkit-scrollbar-track {\n background-color: transparent;\n }\n\n &::-webkit-scrollbar-button {\n background-color: transparent;\n height: 5px;\n }\n\n &::-webkit-scrollbar-thumb {\n background-color: rgba(${theme['text-rgb']}, 0.15);\n border-radius: 20px;\n }\n `}\n`;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAAyD,SAAAI,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,SAAAH,wBAAAG,C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,GAAAnB,OAAA,CAAAmB,wBAAA,GAAG,IAAAlB,yBAAM,EAACmB,oBAAM,CAAClB,GAAG,CAA2B;AACpF,kBAAkB,CAAC;EAAEG;AAA+B,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAE;AACvE;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,CAAC;EAAEC;AAAU,CAAC,KAAKA,SAAU;AAC9C,iBAAiB,CAAC;EAAEA;AAAU,CAAC,KAAKA,SAAU;AAC9C,kBAAkB,CAAC;EAAEe;AAAW,CAAC,KAAKA,UAAW;AACjD,kBAAkB,CAAC;EAAEC;AAAW,CAAC,KAAKA,UAAW;AACjD;AACA,MAAM,CAAC;EAAEd,UAAU;EAAEH;AAAM,CAAC,KAAK;EACzB,IAAIG,UAAU,KAAKC,2BAAiB,CAACC,MAAM,EAAE;IACzC,OAAO,IAAAC,qBAAG,CAAC;AACvB;AACA;AACA,iDAAiDN,KAAK,CAAC,SAAS,CAAE;AAClE,aAAa;EACL;EAEA,OAAO,IAAAM,qBAAG,CAAC;AACnB;AACA;AACA,8CAA8CN,KAAK,CAAC,SAAS,CAAE;AAC/D,SAAS;AACL,CAAE;AACN;AACA;AACA,MAAM,CAAC;EAAEkB,QAAQ;EAAElB;AAA+B,CAAC,KAC3CkB,QAAQ,KAAK,SAAS,GAChB,IAAAZ,qBAAG,CAAC;AAClB,0CAA0CN,KAAK,CAAC,UAAU,CAAE;AAC5D;AACA,eAAe,GACD,IAAAM,qBAAG,CAAC;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+CN,KAAK,CAAC,UAAU,CAAE;AACjE;AACA;AACA,eAAgB;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupContentWrapper.styles.js","names":["_chaynsApi","require","_framerMotion","_styledComponents","_interopRequireWildcard","_popup","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledMotionPopupContentWrapper","exports","styled","motion","div","theme","$colorMode","ColorMode","Dark","text","$position","$offset","PopupAlignment","TopLeft","css","BottomLeft","TopRight","BottomRight","undefined"],"sources":["../../../../../src/components/popup/popup-content-wrapper/PopupContentWrapper.styles.ts"],"sourcesContent":["import { ColorMode } from 'chayns-api';\nimport { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport { PopupAlignment } from '../../../types/popup';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledMotionPopupContentWrapperProps = WithTheme<{\n $position: PopupAlignment;\n $colorMode: ColorMode;\n $offset: number;\n}>;\n\nexport const StyledMotionPopupContentWrapper = styled(\n motion.div,\n)<StyledMotionPopupContentWrapperProps>`\n background-color: ${({ theme, $colorMode }: StyledMotionPopupContentWrapperProps) =>\n $colorMode === ColorMode.Dark ? theme['003'] : theme['001']};\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n color: ${({ theme }: StyledMotionPopupContentWrapperProps) => theme.text};\n z-index: 100;\n position: fixed;\n\n
|
|
1
|
+
{"version":3,"file":"PopupContentWrapper.styles.js","names":["_chaynsApi","require","_framerMotion","_styledComponents","_interopRequireWildcard","_popup","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledMotionPopupContentWrapper","exports","styled","motion","div","theme","$colorMode","ColorMode","Dark","text","$position","$offset","PopupAlignment","TopLeft","css","BottomLeft","TopRight","BottomRight","undefined"],"sources":["../../../../../src/components/popup/popup-content-wrapper/PopupContentWrapper.styles.ts"],"sourcesContent":["import { ColorMode } from 'chayns-api';\nimport { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport { PopupAlignment } from '../../../types/popup';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledMotionPopupContentWrapperProps = WithTheme<{\n $position: PopupAlignment;\n $colorMode: ColorMode;\n $offset: number;\n}>;\n\nexport const StyledMotionPopupContentWrapper = styled(\n motion.div,\n)<StyledMotionPopupContentWrapperProps>`\n background-color: ${({ theme, $colorMode }: StyledMotionPopupContentWrapperProps) =>\n $colorMode === ColorMode.Dark ? theme['003'] : theme['001']};\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n color: ${({ theme }: StyledMotionPopupContentWrapperProps) => theme.text};\n z-index: 100;\n position: fixed;\n\n &::after {\n background-color: inherit;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-right: 1px solid rgba(0, 0, 0, 0.1);\n box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);\n content: '';\n height: 14px;\n position: absolute;\n width: 14px;\n z-index: -2;\n\n ${({ $position, $offset }) => {\n switch ($position) {\n case PopupAlignment.TopLeft:\n return css`\n bottom: -7px;\n right: ${13 + $offset}px;\n transform: rotate(45deg);\n `;\n case PopupAlignment.BottomLeft:\n return css`\n top: -7px;\n right: ${13 + $offset}px;\n transform: rotate(225deg);\n `;\n case PopupAlignment.TopRight:\n return css`\n transform: rotate(45deg);\n bottom: -7px;\n left: ${13 + $offset}px;\n `;\n case PopupAlignment.BottomRight:\n return css`\n transform: rotate(225deg);\n top: -7px;\n left: ${13 + $offset}px;\n `;\n default:\n return undefined;\n }\n }}\n }\n\n &::before {\n background-color: inherit;\n border-radius: 3px;\n bottom: 0;\n content: '';\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAAsD,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,O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,CAAC,GAAGA,KAAK,CAAC,KAAK,CAAE;AACpE;AACA;AACA,aAAa,CAAC;EAAEA;AAA4C,CAAC,KAAKA,KAAK,CAACI,IAAK;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,CAAC;EAAEC,SAAS;EAAEC;AAAQ,CAAC,KAAK;EAC1B,QAAQD,SAAS;IACb,KAAKE,qBAAc,CAACC,OAAO;MACvB,OAAO,IAAAC,qBAAG,CAAC;AAC/B;AACA,iCAAiC,EAAE,GAAGH,OAAQ;AAC9C;AACA,qBAAqB;IACL,KAAKC,qBAAc,CAACG,UAAU;MAC1B,OAAO,IAAAD,qBAAG,CAAC;AAC/B;AACA,iCAAiC,EAAE,GAAGH,OAAQ;AAC9C;AACA,qBAAqB;IACL,KAAKC,qBAAc,CAACI,QAAQ;MACxB,OAAO,IAAAF,qBAAG,CAAC;AAC/B;AACA;AACA,gCAAgC,EAAE,GAAGH,OAAQ;AAC7C,qBAAqB;IACL,KAAKC,qBAAc,CAACK,WAAW;MAC3B,OAAO,IAAAH,qBAAG,CAAC;AAC/B;AACA;AACA,gCAAgC,EAAE,GAAGH,OAAQ;AAC7C,qBAAqB;IACL;MACI,OAAOO,SAAS;EACxB;AACJ,CAAE;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getHeightOfSingleTextLine = exports.calculateContentWidth = exports.calculateContentHeight = exports.calculateBiggestWidth = void 0;
|
|
6
|
+
exports.getMaxHeightInPixels = exports.getHeightOfSingleTextLine = exports.calculateContentWidth = exports.calculateContentHeight = exports.calculateBiggestWidth = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _server = require("react-dom/server");
|
|
9
9
|
var _ColorSchemeProvider = _interopRequireDefault(require("../components/color-scheme-provider/ColorSchemeProvider"));
|
|
@@ -61,20 +61,20 @@ const calculateBiggestWidth = elements => {
|
|
|
61
61
|
};
|
|
62
62
|
exports.calculateBiggestWidth = calculateBiggestWidth;
|
|
63
63
|
const calculateContentHeight = elements => {
|
|
64
|
-
const
|
|
64
|
+
const heights = [];
|
|
65
65
|
elements.forEach(element => {
|
|
66
|
-
const div = document.createElement('
|
|
66
|
+
const div = document.createElement('div');
|
|
67
67
|
div.style.visibility = 'hidden';
|
|
68
68
|
div.style.position = 'absolute';
|
|
69
69
|
div.style.width = 'auto';
|
|
70
|
-
div.style.
|
|
70
|
+
div.style.padding = '4px 10px';
|
|
71
71
|
div.style.whiteSpace = 'nowrap';
|
|
72
72
|
document.body.appendChild(div);
|
|
73
73
|
div.innerText = element;
|
|
74
|
-
|
|
74
|
+
heights.push(div.offsetHeight);
|
|
75
75
|
document.body.removeChild(div);
|
|
76
76
|
});
|
|
77
|
-
return
|
|
77
|
+
return heights.reduce((partialSum, a) => partialSum + a, 0);
|
|
78
78
|
};
|
|
79
79
|
exports.calculateContentHeight = calculateContentHeight;
|
|
80
80
|
const getHeightOfSingleTextLine = () => {
|
|
@@ -86,4 +86,18 @@ const getHeightOfSingleTextLine = () => {
|
|
|
86
86
|
return height;
|
|
87
87
|
};
|
|
88
88
|
exports.getHeightOfSingleTextLine = getHeightOfSingleTextLine;
|
|
89
|
+
const getMaxHeightInPixels = (maxHeight, rootElement) => {
|
|
90
|
+
const tempElement = document.createElement('div');
|
|
91
|
+
tempElement.style.position = 'absolute';
|
|
92
|
+
tempElement.style.visibility = 'hidden';
|
|
93
|
+
tempElement.style.height = '100vh';
|
|
94
|
+
tempElement.style.maxHeight = maxHeight;
|
|
95
|
+
rootElement.appendChild(tempElement);
|
|
96
|
+
const {
|
|
97
|
+
height
|
|
98
|
+
} = tempElement.getBoundingClientRect();
|
|
99
|
+
rootElement.removeChild(tempElement);
|
|
100
|
+
return height;
|
|
101
|
+
};
|
|
102
|
+
exports.getMaxHeightInPixels = getMaxHeightInPixels;
|
|
89
103
|
//# sourceMappingURL=calculate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate.js","names":["_react","_interopRequireDefault","require","_server","_ColorSchemeProvider","obj","__esModule","default","calculateContentWidth","list","length","forEach","suffixElement","text","div","document","createElement","style","display","gap","position","visibility","whiteSpace","width","body","appendChild","innerText","innerHTML","renderToString","color","colorMode","push","offsetWidth","removeChild","Math","max","apply","exports","calculateBiggestWidth","elements","container","padding","id","element","accessKey","calculateContentHeight","
|
|
1
|
+
{"version":3,"file":"calculate.js","names":["_react","_interopRequireDefault","require","_server","_ColorSchemeProvider","obj","__esModule","default","calculateContentWidth","list","length","forEach","suffixElement","text","div","document","createElement","style","display","gap","position","visibility","whiteSpace","width","body","appendChild","innerText","innerHTML","renderToString","color","colorMode","push","offsetWidth","removeChild","Math","max","apply","exports","calculateBiggestWidth","elements","container","padding","id","element","accessKey","calculateContentHeight","heights","offsetHeight","reduce","partialSum","a","getHeightOfSingleTextLine","span","height","getMaxHeightInPixels","maxHeight","rootElement","tempElement","getBoundingClientRect"],"sources":["../../../src/utils/calculate.tsx"],"sourcesContent":["import React, { type CSSProperties } from 'react';\nimport { renderToString } from 'react-dom/server';\nimport ColorSchemeProvider from '../components/color-scheme-provider/ColorSchemeProvider';\nimport type { IComboBoxItem } from '../components/combobox/ComboBox';\nimport type { SliderButtonItem } from '../types/slider-button';\n\nexport const calculateContentWidth = (list: IComboBoxItem[]) => {\n const length: number[] = [];\n\n list.forEach(({ suffixElement, text }) => {\n const div = document.createElement('div');\n\n div.style.display = 'flex';\n div.style.gap = '10px';\n div.style.position = 'absolute';\n div.style.visibility = 'hidden';\n div.style.whiteSpace = 'nowrap';\n div.style.width = 'auto';\n\n document.body.appendChild(div);\n\n div.innerText = text;\n\n if (suffixElement) {\n // ColorSchemeProvider is used to prevent missing scheme context error.\n // Due to the fact that the element is never rendered visible, the values are irrelevant.\n div.innerHTML += renderToString(\n <ColorSchemeProvider color=\"#005EB8\" colorMode={0}>\n {suffixElement}\n </ColorSchemeProvider>,\n );\n }\n\n length.push(div.offsetWidth);\n\n document.body.removeChild(div);\n });\n\n return Math.max.apply(null, length);\n};\n\nexport const calculateBiggestWidth = (elements: SliderButtonItem[]) => {\n const container = document.createElement('div');\n\n container.style.visibility = 'hidden';\n container.style.position = 'absolute';\n container.style.width = 'auto';\n container.style.whiteSpace = 'nowrap';\n container.style.padding = '7px 12px';\n container.style.display = 'block';\n\n elements.forEach(({ text, id }) => {\n const element = document.createElement('div');\n\n element.accessKey = `slider-button-pseudo--${id}`;\n element.innerText = text;\n\n container.appendChild(element);\n });\n\n document.body.appendChild(container);\n\n const width = container.offsetWidth;\n\n document.body.removeChild(container);\n\n return width;\n};\n\nexport const calculateContentHeight = (elements: string[]) => {\n const heights: number[] = [];\n\n elements.forEach((element: string) => {\n const div = document.createElement('div');\n\n div.style.visibility = 'hidden';\n div.style.position = 'absolute';\n div.style.width = 'auto';\n div.style.padding = '4px 10px';\n div.style.whiteSpace = 'nowrap';\n\n document.body.appendChild(div);\n\n div.innerText = element;\n\n heights.push(div.offsetHeight);\n\n document.body.removeChild(div);\n });\n\n return heights.reduce((partialSum, a) => partialSum + a, 0);\n};\n\nexport const getHeightOfSingleTextLine = () => {\n const span = document.createElement('span');\n\n span.innerText = 'A';\n\n document.body.appendChild(span);\n\n const height = span.offsetHeight;\n\n document.body.removeChild(span);\n\n return height;\n};\n\nexport const getMaxHeightInPixels = (\n maxHeight: CSSProperties['maxHeight'],\n rootElement: HTMLElement,\n): number => {\n const tempElement = document.createElement('div');\n\n tempElement.style.position = 'absolute';\n tempElement.style.visibility = 'hidden';\n tempElement.style.height = '100vh';\n tempElement.style.maxHeight = maxHeight as string;\n\n rootElement.appendChild(tempElement);\n\n const { height } = tempElement.getBoundingClientRect();\n\n rootElement.removeChild(tempElement);\n\n return height;\n};\n"],"mapp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CAAC;EAEjDyC,WAAW,CAACxC,KAAK,CAACG,QAAQ,GAAG,UAAU;EACvCqC,WAAW,CAACxC,KAAK,CAACI,UAAU,GAAG,QAAQ;EACvCoC,WAAW,CAACxC,KAAK,CAACoC,MAAM,GAAG,OAAO;EAClCI,WAAW,CAACxC,KAAK,CAACsC,SAAS,GAAGA,SAAmB;EAEjDC,WAAW,CAAC/B,WAAW,CAACgC,WAAW,CAAC;EAEpC,MAAM;IAAEJ;EAAO,CAAC,GAAGI,WAAW,CAACC,qBAAqB,CAAC,CAAC;EAEtDF,WAAW,CAACvB,WAAW,CAACwB,WAAW,CAAC;EAEpC,OAAOJ,MAAM;AACjB,CAAC;AAAChB,OAAA,CAAAiB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getDevice } from 'chayns-api';
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { ComboBoxDirection } from '../../types/comboBox';
|
|
4
|
-
import { calculateContentHeight, calculateContentWidth } from '../../utils/calculate';
|
|
4
|
+
import { calculateContentHeight, calculateContentWidth, getMaxHeightInPixels } from '../../utils/calculate';
|
|
5
5
|
import { getIsMobile } from '../../utils/environment';
|
|
6
6
|
import Icon from '../icon/Icon';
|
|
7
7
|
import ComboBoxItem from './combobox-item/ComboBoxItem';
|
|
@@ -11,7 +11,7 @@ const ComboBox = _ref => {
|
|
|
11
11
|
direction = ComboBoxDirection.BOTTOM,
|
|
12
12
|
isDisabled = false,
|
|
13
13
|
list,
|
|
14
|
-
maxHeight = '
|
|
14
|
+
maxHeight = '280px',
|
|
15
15
|
onSelect,
|
|
16
16
|
placeholder,
|
|
17
17
|
selectedItem,
|
|
@@ -20,19 +20,19 @@ const ComboBox = _ref => {
|
|
|
20
20
|
const [item, setItem] = useState();
|
|
21
21
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
22
22
|
const [minWidth, setMinWidth] = useState(0);
|
|
23
|
-
const [height, setHeight] = useState(0);
|
|
24
23
|
const [focusedIndex, setFocusedIndex] = useState(null);
|
|
25
|
-
const
|
|
24
|
+
const [overflowY, setOverflowY] = useState('hidden');
|
|
25
|
+
const styledComboBoxElementRef = useRef(null);
|
|
26
26
|
const contentRef = useRef(null);
|
|
27
27
|
const {
|
|
28
28
|
browser
|
|
29
29
|
} = getDevice();
|
|
30
30
|
const isMobile = getIsMobile();
|
|
31
31
|
const handleClick = useCallback(event => {
|
|
32
|
-
if (
|
|
32
|
+
if (styledComboBoxElementRef.current && !styledComboBoxElementRef.current.contains(event.target)) {
|
|
33
33
|
setIsAnimating(false);
|
|
34
34
|
}
|
|
35
|
-
}, [
|
|
35
|
+
}, [styledComboBoxElementRef]);
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* This function adds an event listener to the document to close the combobox when the user clicks outside of it
|
|
@@ -42,7 +42,7 @@ const ComboBox = _ref => {
|
|
|
42
42
|
return () => {
|
|
43
43
|
document.removeEventListener('click', handleClick);
|
|
44
44
|
};
|
|
45
|
-
}, [handleClick,
|
|
45
|
+
}, [handleClick, styledComboBoxElementRef]);
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* This function sets the selected item
|
|
@@ -112,7 +112,9 @@ const ComboBox = _ref => {
|
|
|
112
112
|
} = _ref4;
|
|
113
113
|
return text;
|
|
114
114
|
});
|
|
115
|
-
|
|
115
|
+
const contentHeight = calculateContentHeight(textArray);
|
|
116
|
+
const maxHeightInPixels = getMaxHeightInPixels(maxHeight, styledComboBoxElementRef.current ?? document.body);
|
|
117
|
+
setOverflowY(contentHeight > maxHeightInPixels ? 'scroll' : 'hidden');
|
|
116
118
|
textArray.push(placeholder);
|
|
117
119
|
|
|
118
120
|
// 45px = padding left + padding right + border left + border right + arrow icon width + arrow icon margin left
|
|
@@ -121,7 +123,7 @@ const ComboBox = _ref => {
|
|
|
121
123
|
text: placeholder,
|
|
122
124
|
value: 'placeholder'
|
|
123
125
|
}]) + 45 + (isAtLeastOneItemWithImageGiven ? 32 : 0));
|
|
124
|
-
}, [list, placeholder]);
|
|
126
|
+
}, [list, maxHeight, placeholder]);
|
|
125
127
|
|
|
126
128
|
/**
|
|
127
129
|
* This function sets the external selected item
|
|
@@ -194,7 +196,7 @@ const ComboBox = _ref => {
|
|
|
194
196
|
return /*#__PURE__*/React.createElement(StyledMotionComboBoxBody, {
|
|
195
197
|
$browser: browser?.name,
|
|
196
198
|
animate: animate,
|
|
197
|
-
$
|
|
199
|
+
$overflowY: overflowY,
|
|
198
200
|
initial: {
|
|
199
201
|
height: 0,
|
|
200
202
|
opacity: 0
|
|
@@ -209,9 +211,9 @@ const ComboBox = _ref => {
|
|
|
209
211
|
tabIndex: 0,
|
|
210
212
|
ref: contentRef
|
|
211
213
|
}, items);
|
|
212
|
-
}, [browser?.name, direction, handleSetSelectedItem,
|
|
214
|
+
}, [browser?.name, direction, handleSetSelectedItem, isAnimating, list, maxHeight, minWidth, overflowY, selectedItem, shouldShowRoundImage]);
|
|
213
215
|
return useMemo(() => /*#__PURE__*/React.createElement(StyledComboBox, {
|
|
214
|
-
ref:
|
|
216
|
+
ref: styledComboBoxElementRef
|
|
215
217
|
}, direction === ComboBoxDirection.TOP && comboBoxBody, /*#__PURE__*/React.createElement(StyledComboBoxHeader, {
|
|
216
218
|
$direction: direction,
|
|
217
219
|
$minWidth: minWidth,
|
|
@@ -224,7 +226,7 @@ const ComboBox = _ref => {
|
|
|
224
226
|
shouldShowRoundImage: shouldShowRoundImage
|
|
225
227
|
}), placeholderText, item && item.suffixElement && item.suffixElement), /*#__PURE__*/React.createElement(StyledComboBoxIconWrapper, null, /*#__PURE__*/React.createElement(Icon, {
|
|
226
228
|
icons: ['fa fa-chevron-down']
|
|
227
|
-
}))), direction === ComboBoxDirection.BOTTOM && comboBoxBody), [comboBoxBody, direction, handleHeaderClick, isAnimating, isDisabled, isMobile, minWidth, placeholderImageUrl, placeholderText, shouldShowRoundImage]);
|
|
229
|
+
}))), direction === ComboBoxDirection.BOTTOM && comboBoxBody), [comboBoxBody, direction, handleHeaderClick, isAnimating, isDisabled, isMobile, item, minWidth, placeholderImageUrl, placeholderText, shouldShowRoundImage]);
|
|
228
230
|
};
|
|
229
231
|
ComboBox.displayName = 'ComboBox';
|
|
230
232
|
export default ComboBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.js","names":["getDevice","React","useCallback","useEffect","useMemo","useRef","useState","ComboBoxDirection","calculateContentHeight","calculateContentWidth","getIsMobile","Icon","ComboBoxItem","StyledComboBox","StyledComboBoxHeader","StyledComboBoxIconWrapper","StyledComboBoxPlaceholder","StyledComboBoxPlaceholderImage","StyledMotionComboBoxBody","ComboBox","_ref","direction","BOTTOM","isDisabled","list","maxHeight","onSelect","placeholder","selectedItem","shouldShowRoundImage","item","setItem","isAnimating","setIsAnimating","minWidth","setMinWidth","height","setHeight","focusedIndex","setFocusedIndex","ref","contentRef","browser","isMobile","handleClick","event","current","contains","target","document","addEventListener","removeEventListener","handleSetSelectedItem","itemToSelect","handleKeyDown","e","key","preventDefault","children","length","newIndex","prevElement","tabIndex","newElement","focus","element","id","newSelectedItem","find","_ref2","value","String","replace","isAtLeastOneItemWithImageGiven","some","_ref3","imageUrl","textArray","map","_ref4","text","push","placeholderImageUrl","undefined","placeholderText","handleHeaderClick","prevState","comboBoxBody","items","_ref5","suffixElement","createElement","isSelected","animate","opacity","style","TOP","transform","$browser","name","$height","initial","$maxHeight","$minWidth","$direction","transition","duration","onClick","$isOpen","$isMobile","$isDisabled","src","icons","displayName"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { getDevice } from 'chayns-api';\nimport React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { ComboBoxDirection } from '../../types/comboBox';\nimport { calculateContentHeight, calculateContentWidth } from '../../utils/calculate';\nimport { getIsMobile } from '../../utils/environment';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledMotionComboBoxBody,\n} from './ComboBox.styles';\n\nexport interface IComboBoxItem {\n imageUrl?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n}\n\nexport type ComboBoxProps = {\n /**\n * The direction in which the combobox should open.\n */\n direction?: ComboBoxDirection;\n /**\n * Whether the combobox should be disabled.\n */\n isDisabled?: boolean;\n /**\n * The list of the items that should be displayed.\n */\n list: IComboBoxItem[];\n /**\n * The maximum height of the combobox content.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * Function that should be executed when an item is selected.\n */\n onSelect?: (comboboxItem: IComboBoxItem) => void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * An item that should be preselected.\n */\n selectedItem?: IComboBoxItem;\n /**\n * If true, the images of the items are displayed in a round shape.\n */\n shouldShowRoundImage?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n direction = ComboBoxDirection.BOTTOM,\n isDisabled = false,\n list,\n maxHeight = '300px',\n onSelect,\n placeholder,\n selectedItem,\n shouldShowRoundImage,\n}) => {\n const [item, setItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n const ref = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const { browser } = getDevice();\n\n const isMobile = getIsMobile();\n\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsAnimating(false);\n }\n },\n [ref],\n );\n\n /**\n * This function adds an event listener to the document to close the combobox when the user clicks outside of it\n */\n useEffect(() => {\n document.addEventListener('click', handleClick);\n\n return () => {\n document.removeEventListener('click', handleClick);\n };\n }, [handleClick, ref]);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect: IComboBoxItem) => {\n setItem(itemToSelect);\n setIsAnimating(false);\n\n if (onSelect) {\n onSelect(itemToSelect);\n }\n },\n [onSelect],\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n const children = contentRef.current?.children;\n if (children && children.length > 0) {\n const newIndex =\n focusedIndex !== null\n ? (focusedIndex + (e.key === 'ArrowUp' ? -1 : 1) + children.length) %\n children.length\n : 0;\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const newElement = children[newIndex] as HTMLDivElement;\n newElement.tabIndex = 0;\n newElement.focus();\n }\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) {\n return;\n }\n\n const { id } = element;\n\n const newSelectedItem = list.find(\n ({ value }) => String(value) === id.replace('combobox-item__', ''),\n );\n\n if (!newSelectedItem) {\n return;\n }\n\n handleSetSelectedItem(newSelectedItem);\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [focusedIndex, handleSetSelectedItem, list]);\n\n /**\n * This function calculates the greatest width\n */\n useEffect(() => {\n const isAtLeastOneItemWithImageGiven = list.some(({ imageUrl }) => imageUrl);\n\n const textArray = list.map(({ text }) => text);\n\n setHeight(calculateContentHeight(textArray));\n\n textArray.push(placeholder);\n\n // 45px = padding left + padding right + border left + border right + arrow icon width + arrow icon margin left\n // 32px = image width + flex gap\n setMinWidth(\n calculateContentWidth([...list, { text: placeholder, value: 'placeholder' }]) +\n 45 +\n (isAtLeastOneItemWithImageGiven ? 32 : 0),\n );\n }, [list, placeholder]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n setIsAnimating(false);\n setItem(selectedItem);\n }, [selectedItem]);\n\n const placeholderImageUrl = useMemo(() => {\n if (selectedItem) {\n return selectedItem.imageUrl;\n }\n\n if (item) {\n return item.imageUrl;\n }\n\n return undefined;\n }, [item, selectedItem]);\n\n /**\n * This function resets the placeholder\n */\n const placeholderText = useMemo(() => {\n let text = placeholder;\n\n if (selectedItem) {\n text = selectedItem.text;\n } else if (item) {\n text = item.text;\n }\n\n return text;\n }, [item, placeholder, selectedItem]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = useCallback(() => {\n if (!isDisabled) {\n setIsAnimating((prevState) => !prevState);\n }\n }, [isDisabled]);\n\n const comboBoxBody = useMemo(() => {\n const items = list.map(({ imageUrl, suffixElement, text, value }) => (\n <ComboBoxItem\n imageUrl={imageUrl}\n isSelected={selectedItem ? value === selectedItem.value : false}\n key={value}\n id={value}\n onSelect={handleSetSelectedItem}\n shouldShowRoundImage={shouldShowRoundImage}\n suffixElement={suffixElement}\n text={text}\n value={value}\n />\n ));\n\n const animate = isAnimating\n ? { height: 'fit-content', opacity: 1 }\n : { height: 0, opacity: 0 };\n\n const style =\n direction === ComboBoxDirection.TOP ? { transform: 'translateY(-100%)' } : undefined;\n\n return (\n <StyledMotionComboBoxBody\n $browser={browser?.name}\n animate={animate}\n $height={height}\n initial={{ height: 0, opacity: 0 }}\n $maxHeight={maxHeight}\n $minWidth={minWidth}\n style={style}\n $direction={direction}\n transition={{ duration: 0.2 }}\n tabIndex={0}\n ref={contentRef}\n >\n {items}\n </StyledMotionComboBoxBody>\n );\n }, [\n browser?.name,\n direction,\n handleSetSelectedItem,\n height,\n isAnimating,\n list,\n maxHeight,\n minWidth,\n selectedItem,\n shouldShowRoundImage,\n ]);\n\n return useMemo(\n () => (\n <StyledComboBox ref={ref}>\n {direction === ComboBoxDirection.TOP && comboBoxBody}\n <StyledComboBoxHeader\n $direction={direction}\n $minWidth={minWidth}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isMobile={isMobile}\n $isDisabled={isDisabled}\n >\n <StyledComboBoxPlaceholder>\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n {placeholderText}\n {item && item.suffixElement && item.suffixElement}\n </StyledComboBoxPlaceholder>\n <StyledComboBoxIconWrapper>\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n </StyledComboBoxHeader>\n {direction === ComboBoxDirection.BOTTOM && comboBoxBody}\n </StyledComboBox>\n ),\n [\n comboBoxBody,\n direction,\n handleHeaderClick,\n isAnimating,\n isDisabled,\n isMobile,\n minWidth,\n placeholderImageUrl,\n placeholderText,\n shouldShowRoundImage,\n ],\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,OAAOC,KAAK,IAERC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGL,OAAO;AACd,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,sBAAsB,EAAEC,qBAAqB,QAAQ,uBAAuB;AACrF,SAASC,WAAW,QAAQ,yBAAyB;AACrD,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SACIC,cAAc,EACdC,oBAAoB,EACpBC,yBAAyB,EACzBC,yBAAyB,EACzBC,8BAA8B,EAC9BC,wBAAwB,QACrB,mBAAmB;AA4C1B,MAAMC,QAA2B,GAAGC,IAAA,IAS9B;EAAA,IAT+B;IACjCC,SAAS,GAAGd,iBAAiB,CAACe,MAAM;IACpCC,UAAU,GAAG,KAAK;IAClBC,IAAI;IACJC,SAAS,GAAG,OAAO;IACnBC,QAAQ;IACRC,WAAW;IACXC,YAAY;IACZC;EACJ,CAAC,GAAAT,IAAA;EACG,MAAM,CAACU,IAAI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CAAA0F,aAAA,CAAC9E,cAAc;IAAC2B,GAAG,EAAEA;EAAI,GACpBnB,SAAS,KAAKd,iBAAiB,CAACyF,GAAG,IAAIT,YAAY,eACpDtF,KAAA,CAAA0F,aAAA,CAAC7E,oBAAoB;IACjB0F,UAAU,EAAEnF,SAAU;IACtBkF,SAAS,EAAErE,QAAS;IACpByE,OAAO,EAAEtB,iBAAkB;IAC3BuB,OAAO,EAAE5E,WAAY;IACrB6E,SAAS,EAAElE,QAAS;IACpBmE,WAAW,EAAEvF;EAAW,gBAExBtB,KAAA,CAAA0F,aAAA,CAAC3E,yBAAyB,QACrBkE,mBAAmB,iBAChBjF,KAAA,CAAA0F,aAAA,CAAC1E,8BAA8B;IAC3B8F,GAAG,EAAE7B,mBAAoB;IACzBrD,oBAAoB,EAAEA;EAAqB,CAC9C,CACJ,EACAuD,eAAe,EACftD,IAAI,IAAIA,IAAI,CAAC4D,aAAa,IAAI5D,IAAI,CAAC4D,aACb,CAAC,eAC5BzF,KAAA,CAAA0F,aAAA,CAAC5E,yBAAyB,qBACtBd,KAAA,CAAA0F,aAAA,CAAChF,IAAI;IAACqG,KAAK,EAAE,CAAC,oBAAoB;EAAE,CAAE,CACf,CACT,CAAC,EACtB3F,SAAS,KAAKd,iBAAiB,CAACe,MAAM,IAAIiE,YAC/B,CACnB,EACD,CACIA,YAAY,EACZlE,SAAS,EACTgE,iBAAiB,EACjBrD,WAAW,EACXT,UAAU,EACVoB,QAAQ,EACRT,QAAQ,EACRgD,mBAAmB,EACnBE,eAAe,EACfvD,oBAAoB,CAE5B,CAAC;AACL,CAAC;AAEDV,QAAQ,CAAC8F,WAAW,GAAG,UAAU;AAEjC,eAAe9F,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ComboBox.js","names":["getDevice","React","useCallback","useEffect","useMemo","useRef","useState","ComboBoxDirection","calculateContentHeight","calculateContentWidth","getMaxHeightInPixels","getIsMobile","Icon","ComboBoxItem","StyledComboBox","StyledComboBoxHeader","StyledComboBoxIconWrapper","StyledComboBoxPlaceholder","StyledComboBoxPlaceholderImage","StyledMotionComboBoxBody","ComboBox","_ref","direction","BOTTOM","isDisabled","list","maxHeight","onSelect","placeholder","selectedItem","shouldShowRoundImage","item","setItem","isAnimating","setIsAnimating","minWidth","setMinWidth","focusedIndex","setFocusedIndex","overflowY","setOverflowY","styledComboBoxElementRef","contentRef","browser","isMobile","handleClick","event","current","contains","target","document","addEventListener","removeEventListener","handleSetSelectedItem","itemToSelect","handleKeyDown","e","key","preventDefault","children","length","newIndex","prevElement","tabIndex","newElement","focus","element","id","newSelectedItem","find","_ref2","value","String","replace","isAtLeastOneItemWithImageGiven","some","_ref3","imageUrl","textArray","map","_ref4","text","contentHeight","maxHeightInPixels","body","push","placeholderImageUrl","undefined","placeholderText","handleHeaderClick","prevState","comboBoxBody","items","_ref5","suffixElement","createElement","isSelected","animate","height","opacity","style","TOP","transform","$browser","name","$overflowY","initial","$maxHeight","$minWidth","$direction","transition","duration","ref","onClick","$isOpen","$isMobile","$isDisabled","src","icons","displayName"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { getDevice } from 'chayns-api';\nimport React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { ComboBoxDirection } from '../../types/comboBox';\nimport {\n calculateContentHeight,\n calculateContentWidth,\n getMaxHeightInPixels,\n} from '../../utils/calculate';\nimport { getIsMobile } from '../../utils/environment';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledMotionComboBoxBody,\n} from './ComboBox.styles';\n\nexport interface IComboBoxItem {\n imageUrl?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n}\n\nexport type ComboBoxProps = {\n /**\n * The direction in which the combobox should open.\n */\n direction?: ComboBoxDirection;\n /**\n * Whether the combobox should be disabled.\n */\n isDisabled?: boolean;\n /**\n * The list of the items that should be displayed.\n */\n list: IComboBoxItem[];\n /**\n * The maximum height of the combobox content.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * Function that should be executed when an item is selected.\n */\n onSelect?: (comboboxItem: IComboBoxItem) => void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * An item that should be preselected.\n */\n selectedItem?: IComboBoxItem;\n /**\n * If true, the images of the items are displayed in a round shape.\n */\n shouldShowRoundImage?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n direction = ComboBoxDirection.BOTTOM,\n isDisabled = false,\n list,\n maxHeight = '280px',\n onSelect,\n placeholder,\n selectedItem,\n shouldShowRoundImage,\n}) => {\n const [item, setItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n const [overflowY, setOverflowY] = useState<CSSProperties['overflowY']>('hidden');\n\n const styledComboBoxElementRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const { browser } = getDevice();\n\n const isMobile = getIsMobile();\n\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (\n styledComboBoxElementRef.current &&\n !styledComboBoxElementRef.current.contains(event.target as Node)\n ) {\n setIsAnimating(false);\n }\n },\n [styledComboBoxElementRef],\n );\n\n /**\n * This function adds an event listener to the document to close the combobox when the user clicks outside of it\n */\n useEffect(() => {\n document.addEventListener('click', handleClick);\n\n return () => {\n document.removeEventListener('click', handleClick);\n };\n }, [handleClick, styledComboBoxElementRef]);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect: IComboBoxItem) => {\n setItem(itemToSelect);\n setIsAnimating(false);\n\n if (onSelect) {\n onSelect(itemToSelect);\n }\n },\n [onSelect],\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n const children = contentRef.current?.children;\n if (children && children.length > 0) {\n const newIndex =\n focusedIndex !== null\n ? (focusedIndex + (e.key === 'ArrowUp' ? -1 : 1) + children.length) %\n children.length\n : 0;\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const newElement = children[newIndex] as HTMLDivElement;\n newElement.tabIndex = 0;\n newElement.focus();\n }\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) {\n return;\n }\n\n const { id } = element;\n\n const newSelectedItem = list.find(\n ({ value }) => String(value) === id.replace('combobox-item__', ''),\n );\n\n if (!newSelectedItem) {\n return;\n }\n\n handleSetSelectedItem(newSelectedItem);\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [focusedIndex, handleSetSelectedItem, list]);\n\n /**\n * This function calculates the greatest width\n */\n useEffect(() => {\n const isAtLeastOneItemWithImageGiven = list.some(({ imageUrl }) => imageUrl);\n\n const textArray = list.map(({ text }) => text);\n\n const contentHeight = calculateContentHeight(textArray);\n\n const maxHeightInPixels = getMaxHeightInPixels(\n maxHeight,\n styledComboBoxElementRef.current ?? document.body,\n );\n\n setOverflowY(contentHeight > maxHeightInPixels ? 'scroll' : 'hidden');\n\n textArray.push(placeholder);\n\n // 45px = padding left + padding right + border left + border right + arrow icon width + arrow icon margin left\n // 32px = image width + flex gap\n setMinWidth(\n calculateContentWidth([...list, { text: placeholder, value: 'placeholder' }]) +\n 45 +\n (isAtLeastOneItemWithImageGiven ? 32 : 0),\n );\n }, [list, maxHeight, placeholder]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n setIsAnimating(false);\n setItem(selectedItem);\n }, [selectedItem]);\n\n const placeholderImageUrl = useMemo(() => {\n if (selectedItem) {\n return selectedItem.imageUrl;\n }\n\n if (item) {\n return item.imageUrl;\n }\n\n return undefined;\n }, [item, selectedItem]);\n\n /**\n * This function resets the placeholder\n */\n const placeholderText = useMemo(() => {\n let text = placeholder;\n\n if (selectedItem) {\n text = selectedItem.text;\n } else if (item) {\n text = item.text;\n }\n\n return text;\n }, [item, placeholder, selectedItem]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = useCallback(() => {\n if (!isDisabled) {\n setIsAnimating((prevState) => !prevState);\n }\n }, [isDisabled]);\n\n const comboBoxBody = useMemo(() => {\n const items = list.map(({ imageUrl, suffixElement, text, value }) => (\n <ComboBoxItem\n imageUrl={imageUrl}\n isSelected={selectedItem ? value === selectedItem.value : false}\n key={value}\n id={value}\n onSelect={handleSetSelectedItem}\n shouldShowRoundImage={shouldShowRoundImage}\n suffixElement={suffixElement}\n text={text}\n value={value}\n />\n ));\n\n const animate = isAnimating\n ? { height: 'fit-content', opacity: 1 }\n : { height: 0, opacity: 0 };\n\n const style =\n direction === ComboBoxDirection.TOP ? { transform: 'translateY(-100%)' } : undefined;\n\n return (\n <StyledMotionComboBoxBody\n $browser={browser?.name}\n animate={animate}\n $overflowY={overflowY}\n initial={{ height: 0, opacity: 0 }}\n $maxHeight={maxHeight}\n $minWidth={minWidth}\n style={style}\n $direction={direction}\n transition={{ duration: 0.2 }}\n tabIndex={0}\n ref={contentRef}\n >\n {items}\n </StyledMotionComboBoxBody>\n );\n }, [\n browser?.name,\n direction,\n handleSetSelectedItem,\n isAnimating,\n list,\n maxHeight,\n minWidth,\n overflowY,\n selectedItem,\n shouldShowRoundImage,\n ]);\n\n return useMemo(\n () => (\n <StyledComboBox ref={styledComboBoxElementRef}>\n {direction === ComboBoxDirection.TOP && comboBoxBody}\n <StyledComboBoxHeader\n $direction={direction}\n $minWidth={minWidth}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isMobile={isMobile}\n $isDisabled={isDisabled}\n >\n <StyledComboBoxPlaceholder>\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n {placeholderText}\n {item && item.suffixElement && item.suffixElement}\n </StyledComboBoxPlaceholder>\n <StyledComboBoxIconWrapper>\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n </StyledComboBoxHeader>\n {direction === ComboBoxDirection.BOTTOM && comboBoxBody}\n </StyledComboBox>\n ),\n [\n comboBoxBody,\n direction,\n handleHeaderClick,\n isAnimating,\n isDisabled,\n isMobile,\n item,\n minWidth,\n placeholderImageUrl,\n placeholderText,\n shouldShowRoundImage,\n ],\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,OAAOC,KAAK,IAERC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGL,OAAO;AACd,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SACIC,sBAAsB,EACtBC,qBAAqB,EACrBC,oBAAoB,QACjB,uBAAuB;AAC9B,SAASC,WAAW,QAAQ,yBAAyB;AACrD,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SACIC,cAAc,EACdC,oBAAoB,EACpBC,yBAAyB,EACzBC,yBAAyB,EACzBC,8BAA8B,EAC9BC,wBAAwB,QACrB,mBAAmB;AA4C1B,MAAMC,QAA2B,GAAGC,IAAA,IAS9B;EAAA,IAT+B;IACjCC,SAAS,GAAGf,iBAAiB,CAACgB,MAAM;IACpCC,UAAU,GAAG,KAAK;IAClBC,IAAI;IACJC,SAAS,GAAG,OAAO;IACnBC,QAAQ;IACRC,WAAW;IACXC,YAAY;IACZC;EACJ,CAAC,GAAAT,IAAA;EACG,MAAM,CAACU,IAAI,EAAEC,OAAO,CAAC,GAAG1B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AEjC,eAAenG,QAAQ","ignoreList":[]}
|
|
@@ -141,9 +141,9 @@ export const StyledMotionComboBoxBody = styled(motion.div)`
|
|
|
141
141
|
}};
|
|
142
142
|
overflow-y: ${_ref15 => {
|
|
143
143
|
let {
|
|
144
|
-
$
|
|
144
|
+
$overflowY
|
|
145
145
|
} = _ref15;
|
|
146
|
-
return $
|
|
146
|
+
return $overflowY;
|
|
147
147
|
}};
|
|
148
148
|
|
|
149
149
|
${_ref16 => {
|