@chayns-components/core 5.0.0-beta.761 → 5.0.0-beta.762

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.
Files changed (26) hide show
  1. package/lib/cjs/components/combobox/ComboBox.js +11 -5
  2. package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
  3. package/lib/cjs/components/combobox/ComboBox.styles.js +19 -1
  4. package/lib/cjs/components/combobox/ComboBox.styles.js.map +1 -1
  5. package/lib/cjs/components/combobox/combobox-item/ComboBoxItem.js +8 -3
  6. package/lib/cjs/components/combobox/combobox-item/ComboBoxItem.js.map +1 -1
  7. package/lib/cjs/components/combobox/combobox-item/ComboBoxItem.styles.js +36 -26
  8. package/lib/cjs/components/combobox/combobox-item/ComboBoxItem.styles.js.map +1 -1
  9. package/lib/cjs/components/select-button/SelectButton.js +16 -9
  10. package/lib/cjs/components/select-button/SelectButton.js.map +1 -1
  11. package/lib/esm/components/combobox/ComboBox.js +18 -9
  12. package/lib/esm/components/combobox/ComboBox.js.map +1 -1
  13. package/lib/esm/components/combobox/ComboBox.styles.js +24 -0
  14. package/lib/esm/components/combobox/ComboBox.styles.js.map +1 -1
  15. package/lib/esm/components/combobox/combobox-item/ComboBoxItem.js +9 -4
  16. package/lib/esm/components/combobox/combobox-item/ComboBoxItem.js.map +1 -1
  17. package/lib/esm/components/combobox/combobox-item/ComboBoxItem.styles.js +47 -34
  18. package/lib/esm/components/combobox/combobox-item/ComboBoxItem.styles.js.map +1 -1
  19. package/lib/esm/components/select-button/SelectButton.js +16 -9
  20. package/lib/esm/components/select-button/SelectButton.js.map +1 -1
  21. package/lib/types/components/combobox/ComboBox.d.ts +2 -0
  22. package/lib/types/components/combobox/ComboBox.styles.d.ts +1 -0
  23. package/lib/types/components/combobox/combobox-item/ComboBoxItem.d.ts +4 -2
  24. package/lib/types/components/combobox/combobox-item/ComboBoxItem.styles.d.ts +9 -1
  25. package/lib/types/components/select-button/SelectButton.d.ts +4 -0
  26. package/package.json +2 -2
@@ -7,8 +7,7 @@ import { calculateContentHeight, calculateContentWidth, getMaxHeightInPixels } f
7
7
  import { getIsTouch } from '../../utils/environment';
8
8
  import Icon from '../icon/Icon';
9
9
  import ComboBoxItem from './combobox-item/ComboBoxItem';
10
- import { StyledComboBoxTopic } from './combobox-item/ComboBoxItem.styles';
11
- import { StyledComboBox, StyledComboBoxHeader, StyledComboBoxIconWrapper, StyledComboBoxPlaceholder, StyledComboBoxPlaceholderImage, StyledMotionComboBoxBody } from './ComboBox.styles';
10
+ import { StyledComboBox, StyledComboBoxHeader, StyledComboBoxIconWrapper, StyledComboBoxPlaceholder, StyledComboBoxPlaceholderImage, StyledComboBoxTopic, StyledMotionComboBoxBody } from './ComboBox.styles';
12
11
  const ComboBox = _ref => {
13
12
  let {
14
13
  direction = ComboBoxDirection.BOTTOM,
@@ -159,7 +158,13 @@ const ComboBox = _ref => {
159
158
  } = _ref5;
160
159
  return text;
161
160
  });
162
- const contentHeight = calculateContentHeight(textArray);
161
+ const groupNames = lists.map(_ref6 => {
162
+ let {
163
+ groupName
164
+ } = _ref6;
165
+ return groupName || 'Unnamed';
166
+ });
167
+ const contentHeight = calculateContentHeight([...textArray, ...groupNames]);
163
168
  const maxHeightInPixels = getMaxHeightInPixels(maxHeight, styledComboBoxElementRef.current ?? document.body);
164
169
  setOverflowY(contentHeight > maxHeightInPixels ? 'scroll' : 'hidden');
165
170
  textArray.push(placeholder);
@@ -225,29 +230,33 @@ const ComboBox = _ref => {
225
230
  }
226
231
  }
227
232
  }, [handleClose, handleOpen, isAnimating, isDisabled]);
228
- const comboBoxGroups = useMemo(() => lists.map(_ref6 => {
233
+ const comboBoxGroups = useMemo(() => lists.map(_ref7 => {
229
234
  let {
230
235
  groupName,
231
236
  list
232
- } = _ref6;
237
+ } = _ref7;
233
238
  return /*#__PURE__*/React.createElement("div", {
234
239
  key: groupName ?? 'default-group'
235
- }, groupName && lists.length > 1 && /*#__PURE__*/React.createElement(StyledComboBoxTopic, null, groupName), list.map(_ref7 => {
240
+ }, groupName && lists.length > 1 && /*#__PURE__*/React.createElement(StyledComboBoxTopic, null, groupName), list.map(_ref8 => {
236
241
  let {
237
242
  imageUrl,
238
243
  icons,
244
+ rightElement,
245
+ subtext,
239
246
  suffixElement,
240
247
  text,
241
248
  value
242
- } = _ref7;
249
+ } = _ref8;
243
250
  return /*#__PURE__*/React.createElement(ComboBoxItem, {
244
- imageUrl: imageUrl,
245
251
  icons: icons,
252
+ id: value,
253
+ imageUrl: imageUrl,
246
254
  isSelected: selectedItem ? value === selectedItem.value : false,
247
255
  key: value,
248
- id: value,
249
256
  onSelect: handleSetSelectedItem,
257
+ rightElement: rightElement,
250
258
  shouldShowRoundImage: shouldShowRoundImage,
259
+ subtext: subtext,
251
260
  suffixElement: suffixElement,
252
261
  text: text,
253
262
  value: value
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.js","names":["useDevice","AnimatePresence","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","ComboBoxDirection","calculateContentHeight","calculateContentWidth","getMaxHeightInPixels","getIsTouch","Icon","ComboBoxItem","StyledComboBoxTopic","StyledComboBox","StyledComboBoxHeader","StyledComboBoxIconWrapper","StyledComboBoxPlaceholder","StyledComboBoxPlaceholderImage","StyledMotionComboBoxBody","ComboBox","_ref","direction","BOTTOM","isDisabled","lists","maxHeight","onSelect","placeholder","container","document","body","selectedItem","shouldShowRoundImage","shouldUseFullWidth","item","setItem","isAnimating","setIsAnimating","minWidth","setMinWidth","focusedIndex","setFocusedIndex","overflowY","setOverflowY","portal","setPortal","internalCoordinates","setInternalCoordinates","x","y","styledComboBoxElementRef","contentRef","browser","isTouch","handleClick","event","current","contains","target","handleOpen","left","comboBoxLeft","top","comboBoxTop","height","getBoundingClientRect","containerLeft","containerTop","scrollLeft","scrollTop","TOP","handleClose","addEventListener","removeEventListener","handleSetSelectedItem","itemToSelect","handleKeyDown","e","key","preventDefault","children","length","newIndex","prevElement","tabIndex","newElement","focus","element","id","newSelectedItem","some","list","find","_ref2","value","String","replace","allItems","flatMap","isAtLeastOneItemWithImageGiven","_ref3","imageUrl","isAtLeastOneItemWithIconGiven","_ref4","icons","textArray","map","_ref5","text","contentHeight","maxHeightInPixels","push","width","placeholderImageUrl","undefined","placeholderIcon","placeholderText","handleHeaderClick","comboBoxGroups","_ref6","groupName","createElement","_ref7","suffixElement","isSelected","bodyStyles","styles","transform","initial","$browser","name","animate","opacity","$overflowY","exit","$maxHeight","$minWidth","style","$direction","transition","duration","ref","$shouldUseFullWidth","onClick","$isOpen","$isTouch","$isDisabled","src","displayName"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { useDevice } from 'chayns-api';\nimport { AnimatePresence } from 'framer-motion';\nimport React, {\n FC,\n ReactPortal,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { ComboBoxDirection } from '../../types/comboBox';\nimport {\n calculateContentHeight,\n calculateContentWidth,\n getMaxHeightInPixels,\n} from '../../utils/calculate';\nimport { getIsTouch } from '../../utils/environment';\nimport type { ContextMenuCoordinates } from '../context-menu/ContextMenu';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport { StyledComboBoxTopic } from './combobox-item/ComboBoxItem.styles';\nimport {\n StyledComboBox,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledMotionComboBoxBody,\n} from './ComboBox.styles';\n\nexport interface IComboBoxItems {\n groupName?: string;\n list: Array<IComboBoxItem>;\n}\n\nexport interface IComboBoxItem {\n icons?: string[];\n imageUrl?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n}\n\nexport type ComboBoxProps = {\n /**\n * The element where the content of the `ComboBox` should be rendered via React Portal.\n */\n container?: Element;\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 lists: IComboBoxItems[];\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 * Whether the width of the 'ComboBox' should be the width of the parent or of the widest item.\n */\n shouldUseFullWidth?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n direction = ComboBoxDirection.BOTTOM,\n isDisabled = false,\n lists,\n maxHeight = '280px',\n onSelect,\n placeholder,\n container = document.body,\n selectedItem,\n shouldShowRoundImage,\n shouldUseFullWidth = false,\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 const [portal, setPortal] = useState<ReactPortal>();\n const [internalCoordinates, setInternalCoordinates] = useState<ContextMenuCoordinates>({\n x: 0,\n y: 0,\n });\n\n const styledComboBoxElementRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const { browser } = useDevice();\n\n const isTouch = getIsTouch();\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 const handleOpen = useCallback(() => {\n if (styledComboBoxElementRef.current) {\n const {\n left: comboBoxLeft,\n top: comboBoxTop,\n height,\n } = styledComboBoxElementRef.current.getBoundingClientRect();\n const { left: containerLeft, top: containerTop } = container.getBoundingClientRect();\n\n const x = comboBoxLeft - containerLeft + container.scrollLeft;\n const y = comboBoxTop - containerTop + container.scrollTop;\n\n setInternalCoordinates({\n x,\n y: direction === ComboBoxDirection.TOP ? y : y + height,\n });\n\n setIsAnimating(true);\n }\n }, [container, direction]);\n\n const handleClose = useCallback(() => {\n setIsAnimating(false);\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 (!isAnimating) {\n return;\n }\n\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 let newSelectedItem: IComboBoxItem | undefined;\n\n lists.some((list) => {\n newSelectedItem = list.list.find(\n ({ value }) => String(value) === id.replace('combobox-item__', ''),\n );\n return !!newSelectedItem;\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, isAnimating, lists]);\n\n /**\n * This function calculates the greatest width\n */\n useEffect(() => {\n const allItems = lists.flatMap((list) => list.list);\n\n const isAtLeastOneItemWithImageGiven = allItems.some(({ imageUrl }) => imageUrl);\n const isAtLeastOneItemWithIconGiven = allItems.some(({ icons }) => icons);\n\n const textArray = allItems?.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 const width = styledComboBoxElementRef.current?.getBoundingClientRect().width ?? 0;\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 // 40px = icon width + flex gap\n setMinWidth(\n shouldUseFullWidth\n ? width\n : calculateContentWidth([\n ...allItems,\n { text: placeholder, value: 'placeholder' },\n ]) +\n 45 +\n (isAtLeastOneItemWithImageGiven ? 32 : 0) +\n (isAtLeastOneItemWithIconGiven ? 40 : 0),\n );\n }, [lists, maxHeight, placeholder, shouldUseFullWidth]);\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 const placeholderIcon = useMemo(() => {\n if (selectedItem) {\n return selectedItem.icons;\n }\n\n if (item) {\n return item.icons;\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 if (isAnimating) {\n handleClose();\n } else {\n handleOpen();\n }\n }\n }, [handleClose, handleOpen, isAnimating, isDisabled]);\n\n const comboBoxGroups = useMemo(\n () =>\n lists.map(({ groupName, list }) => (\n <div key={groupName ?? 'default-group'}>\n {groupName && lists.length > 1 && (\n <StyledComboBoxTopic>{groupName}</StyledComboBoxTopic>\n )}\n {list.map(({ imageUrl, icons, suffixElement, text, value }) => (\n <ComboBoxItem\n imageUrl={imageUrl}\n icons={icons}\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 </div>\n )),\n [handleSetSelectedItem, lists, selectedItem, shouldShowRoundImage],\n );\n\n const bodyStyles = useMemo(() => {\n let styles: CSSProperties = { left: internalCoordinates.x, top: internalCoordinates.y };\n\n if (direction === ComboBoxDirection.TOP) {\n styles = { ...styles, transform: 'translateY(-100%)' };\n }\n\n return styles;\n }, [direction, internalCoordinates.x, internalCoordinates.y]);\n\n useEffect(() => {\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isAnimating && (\n <StyledMotionComboBoxBody\n $browser={browser?.name}\n animate={{ height: 'fit-content', opacity: 1 }}\n $overflowY={overflowY}\n initial={{ height: 0, opacity: 0 }}\n exit={{ height: 0, opacity: 0 }}\n $maxHeight={maxHeight}\n $minWidth={minWidth}\n style={bodyStyles}\n $direction={direction}\n transition={{ duration: 0.2 }}\n tabIndex={0}\n ref={contentRef}\n >\n {comboBoxGroups}\n </StyledMotionComboBoxBody>\n )}\n </AnimatePresence>,\n container,\n ),\n );\n }, [\n bodyStyles,\n browser?.name,\n comboBoxGroups,\n container,\n direction,\n isAnimating,\n maxHeight,\n minWidth,\n overflowY,\n ]);\n\n return useMemo(\n () => (\n <StyledComboBox\n ref={styledComboBoxElementRef}\n $shouldUseFullWidth={shouldUseFullWidth}\n $minWidth={minWidth}\n >\n <StyledComboBoxHeader\n $direction={direction}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isTouch={isTouch}\n $isDisabled={isDisabled}\n >\n <StyledComboBoxPlaceholder>\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n {placeholderIcon && <Icon icons={placeholderIcon} />}\n {placeholderText}\n {item && item.suffixElement && item.suffixElement}\n </StyledComboBoxPlaceholder>\n <StyledComboBoxIconWrapper>\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n </StyledComboBoxHeader>\n {portal}\n </StyledComboBox>\n ),\n [\n direction,\n handleHeaderClick,\n isAnimating,\n isDisabled,\n isTouch,\n item,\n minWidth,\n placeholderIcon,\n placeholderImageUrl,\n placeholderText,\n portal,\n shouldShowRoundImage,\n shouldUseFullWidth,\n ],\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAGRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGL,OAAO;AACd,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SACIC,sBAAsB,EACtBC,qBAAqB,EACrBC,oBAAoB,QACjB,uBAAuB;AAC9B,SAASC,UAAU,QAAQ,yBAAyB;AAEpD,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SAASC,mBAAmB,QAAQ,qCAAqC;AACzE,SACIC,cAAc,EACdC,oBAAoB,EACpBC,yBAAyB,EACzBC,yBAAyB,EACzBC,8BAA8B,EAC9BC,wBAAwB,QACrB,mBAAmB;AA0D1B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AAA,CAAA2H,aAAA,CAACzG,yBAAyB,QACrBiG,mBAAmB,iBAChBnH,KAAA,CAAA2H,aAAA,CAACxG,8BAA8B;IAC3BkI,GAAG,EAAElC,mBAAoB;IACzBjF,oBAAoB,EAAEA;EAAqB,CAC9C,CACJ,EACAmF,eAAe,iBAAIrH,KAAA,CAAA2H,aAAA,CAAC/G,IAAI;IAAC8F,KAAK,EAAEW;EAAgB,CAAE,CAAC,EACnDC,eAAe,EACflF,IAAI,IAAIA,IAAI,CAACyF,aAAa,IAAIzF,IAAI,CAACyF,aACb,CAAC,eAC5B7H,KAAA,CAAA2H,aAAA,CAAC1G,yBAAyB,qBACtBjB,KAAA,CAAA2H,aAAA,CAAC/G,IAAI;IAAC8F,KAAK,EAAE,CAAC,oBAAoB;EAAE,CAAE,CACf,CACT,CAAC,EACtB5D,MACW,CACnB,EACD,CACIvB,SAAS,EACTgG,iBAAiB,EACjBjF,WAAW,EACXb,UAAU,EACV8B,OAAO,EACPnB,IAAI,EACJI,QAAQ,EACR6E,eAAe,EACfF,mBAAmB,EACnBG,eAAe,EACfxE,MAAM,EACNZ,oBAAoB,EACpBC,kBAAkB,CAE1B,CAAC;AACL,CAAC;AAEDd,QAAQ,CAACiI,WAAW,GAAG,UAAU;AAEjC,eAAejI,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"ComboBox.js","names":["useDevice","AnimatePresence","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","ComboBoxDirection","calculateContentHeight","calculateContentWidth","getMaxHeightInPixels","getIsTouch","Icon","ComboBoxItem","StyledComboBox","StyledComboBoxHeader","StyledComboBoxIconWrapper","StyledComboBoxPlaceholder","StyledComboBoxPlaceholderImage","StyledComboBoxTopic","StyledMotionComboBoxBody","ComboBox","_ref","direction","BOTTOM","isDisabled","lists","maxHeight","onSelect","placeholder","container","document","body","selectedItem","shouldShowRoundImage","shouldUseFullWidth","item","setItem","isAnimating","setIsAnimating","minWidth","setMinWidth","focusedIndex","setFocusedIndex","overflowY","setOverflowY","portal","setPortal","internalCoordinates","setInternalCoordinates","x","y","styledComboBoxElementRef","contentRef","browser","isTouch","handleClick","event","current","contains","target","handleOpen","left","comboBoxLeft","top","comboBoxTop","height","getBoundingClientRect","containerLeft","containerTop","scrollLeft","scrollTop","TOP","handleClose","addEventListener","removeEventListener","handleSetSelectedItem","itemToSelect","handleKeyDown","e","key","preventDefault","children","length","newIndex","prevElement","tabIndex","newElement","focus","element","id","newSelectedItem","some","list","find","_ref2","value","String","replace","allItems","flatMap","isAtLeastOneItemWithImageGiven","_ref3","imageUrl","isAtLeastOneItemWithIconGiven","_ref4","icons","textArray","map","_ref5","text","groupNames","_ref6","groupName","contentHeight","maxHeightInPixels","push","width","placeholderImageUrl","undefined","placeholderIcon","placeholderText","handleHeaderClick","comboBoxGroups","_ref7","createElement","_ref8","rightElement","subtext","suffixElement","isSelected","bodyStyles","styles","transform","initial","$browser","name","animate","opacity","$overflowY","exit","$maxHeight","$minWidth","style","$direction","transition","duration","ref","$shouldUseFullWidth","onClick","$isOpen","$isTouch","$isDisabled","src","displayName"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { useDevice } from 'chayns-api';\nimport { AnimatePresence } from 'framer-motion';\nimport React, {\n FC,\n ReactPortal,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { ComboBoxDirection } from '../../types/comboBox';\nimport {\n calculateContentHeight,\n calculateContentWidth,\n getMaxHeightInPixels,\n} from '../../utils/calculate';\nimport { getIsTouch } from '../../utils/environment';\nimport type { ContextMenuCoordinates } from '../context-menu/ContextMenu';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledComboBoxTopic,\n StyledMotionComboBoxBody,\n} from './ComboBox.styles';\n\nexport interface IComboBoxItems {\n groupName?: string;\n list: Array<IComboBoxItem>;\n}\n\nexport interface IComboBoxItem {\n icons?: string[];\n imageUrl?: string;\n rightElement?: ReactNode;\n subtext?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n}\n\nexport type ComboBoxProps = {\n /**\n * The element where the content of the `ComboBox` should be rendered via React Portal.\n */\n container?: Element;\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 lists: IComboBoxItems[];\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 * Whether the width of the 'ComboBox' should be the width of the parent or of the widest item.\n */\n shouldUseFullWidth?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n direction = ComboBoxDirection.BOTTOM,\n isDisabled = false,\n lists,\n maxHeight = '280px',\n onSelect,\n placeholder,\n container = document.body,\n selectedItem,\n shouldShowRoundImage,\n shouldUseFullWidth = false,\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 const [portal, setPortal] = useState<ReactPortal>();\n const [internalCoordinates, setInternalCoordinates] = useState<ContextMenuCoordinates>({\n x: 0,\n y: 0,\n });\n\n const styledComboBoxElementRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const { browser } = useDevice();\n\n const isTouch = getIsTouch();\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 const handleOpen = useCallback(() => {\n if (styledComboBoxElementRef.current) {\n const {\n left: comboBoxLeft,\n top: comboBoxTop,\n height,\n } = styledComboBoxElementRef.current.getBoundingClientRect();\n const { left: containerLeft, top: containerTop } = container.getBoundingClientRect();\n\n const x = comboBoxLeft - containerLeft + container.scrollLeft;\n const y = comboBoxTop - containerTop + container.scrollTop;\n\n setInternalCoordinates({\n x,\n y: direction === ComboBoxDirection.TOP ? y : y + height,\n });\n\n setIsAnimating(true);\n }\n }, [container, direction]);\n\n const handleClose = useCallback(() => {\n setIsAnimating(false);\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 (!isAnimating) {\n return;\n }\n\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 let newSelectedItem: IComboBoxItem | undefined;\n\n lists.some((list) => {\n newSelectedItem = list.list.find(\n ({ value }) => String(value) === id.replace('combobox-item__', ''),\n );\n return !!newSelectedItem;\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, isAnimating, lists]);\n\n /**\n * This function calculates the greatest width\n */\n useEffect(() => {\n const allItems = lists.flatMap((list) => list.list);\n\n const isAtLeastOneItemWithImageGiven = allItems.some(({ imageUrl }) => imageUrl);\n const isAtLeastOneItemWithIconGiven = allItems.some(({ icons }) => icons);\n\n const textArray = allItems?.map(({ text }) => text);\n\n const groupNames = lists.map(({ groupName }) => groupName || 'Unnamed');\n\n const contentHeight = calculateContentHeight([...textArray, ...groupNames]);\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 const width = styledComboBoxElementRef.current?.getBoundingClientRect().width ?? 0;\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 // 40px = icon width + flex gap\n setMinWidth(\n shouldUseFullWidth\n ? width\n : calculateContentWidth([\n ...allItems,\n { text: placeholder, value: 'placeholder' },\n ]) +\n 45 +\n (isAtLeastOneItemWithImageGiven ? 32 : 0) +\n (isAtLeastOneItemWithIconGiven ? 40 : 0),\n );\n }, [lists, maxHeight, placeholder, shouldUseFullWidth]);\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 const placeholderIcon = useMemo(() => {\n if (selectedItem) {\n return selectedItem.icons;\n }\n\n if (item) {\n return item.icons;\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 if (isAnimating) {\n handleClose();\n } else {\n handleOpen();\n }\n }\n }, [handleClose, handleOpen, isAnimating, isDisabled]);\n\n const comboBoxGroups = useMemo(\n () =>\n lists.map(({ groupName, list }) => (\n <div key={groupName ?? 'default-group'}>\n {groupName && lists.length > 1 && (\n <StyledComboBoxTopic>{groupName}</StyledComboBoxTopic>\n )}\n {list.map(\n ({\n imageUrl,\n icons,\n rightElement,\n subtext,\n suffixElement,\n text,\n value,\n }) => (\n <ComboBoxItem\n icons={icons}\n id={value}\n imageUrl={imageUrl}\n isSelected={selectedItem ? value === selectedItem.value : false}\n key={value}\n onSelect={handleSetSelectedItem}\n rightElement={rightElement}\n shouldShowRoundImage={shouldShowRoundImage}\n subtext={subtext}\n suffixElement={suffixElement}\n text={text}\n value={value}\n />\n ),\n )}\n </div>\n )),\n [handleSetSelectedItem, lists, selectedItem, shouldShowRoundImage],\n );\n\n const bodyStyles = useMemo(() => {\n let styles: CSSProperties = { left: internalCoordinates.x, top: internalCoordinates.y };\n\n if (direction === ComboBoxDirection.TOP) {\n styles = { ...styles, transform: 'translateY(-100%)' };\n }\n\n return styles;\n }, [direction, internalCoordinates.x, internalCoordinates.y]);\n\n useEffect(() => {\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isAnimating && (\n <StyledMotionComboBoxBody\n $browser={browser?.name}\n animate={{ height: 'fit-content', opacity: 1 }}\n $overflowY={overflowY}\n initial={{ height: 0, opacity: 0 }}\n exit={{ height: 0, opacity: 0 }}\n $maxHeight={maxHeight}\n $minWidth={minWidth}\n style={bodyStyles}\n $direction={direction}\n transition={{ duration: 0.2 }}\n tabIndex={0}\n ref={contentRef}\n >\n {comboBoxGroups}\n </StyledMotionComboBoxBody>\n )}\n </AnimatePresence>,\n container,\n ),\n );\n }, [\n bodyStyles,\n browser?.name,\n comboBoxGroups,\n container,\n direction,\n isAnimating,\n maxHeight,\n minWidth,\n overflowY,\n ]);\n\n return useMemo(\n () => (\n <StyledComboBox\n ref={styledComboBoxElementRef}\n $shouldUseFullWidth={shouldUseFullWidth}\n $minWidth={minWidth}\n >\n <StyledComboBoxHeader\n $direction={direction}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isTouch={isTouch}\n $isDisabled={isDisabled}\n >\n <StyledComboBoxPlaceholder>\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n {placeholderIcon && <Icon icons={placeholderIcon} />}\n {placeholderText}\n {item && item.suffixElement && item.suffixElement}\n </StyledComboBoxPlaceholder>\n <StyledComboBoxIconWrapper>\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n </StyledComboBoxHeader>\n {portal}\n </StyledComboBox>\n ),\n [\n direction,\n handleHeaderClick,\n isAnimating,\n isDisabled,\n isTouch,\n item,\n minWidth,\n placeholderIcon,\n placeholderImageUrl,\n placeholderText,\n portal,\n shouldShowRoundImage,\n shouldUseFullWidth,\n ],\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAGRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAA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EACjBpF,WAAW,EACXb,UAAU,EACV8B,OAAO,EACPnB,IAAI,EACJI,QAAQ,EACRgF,eAAe,EACfF,mBAAmB,EACnBG,eAAe,EACf3E,MAAM,EACNZ,oBAAoB,EACpBC,kBAAkB,CAE1B,CAAC;AACL,CAAC;AAEDd,QAAQ,CAACqI,WAAW,GAAG,UAAU;AAEjC,eAAerI,QAAQ","ignoreList":[]}
@@ -197,4 +197,28 @@ export const StyledMotionComboBoxBody = styled(motion.div)`
197
197
  `;
198
198
  }}
199
199
  `;
200
+ export const StyledComboBoxTopic = styled.div`
201
+ align-items: center;
202
+ color: rgba(${_ref17 => {
203
+ let {
204
+ theme
205
+ } = _ref17;
206
+ return theme['text-rgb'];
207
+ }}, 0.65);
208
+ position: sticky;
209
+ top: 0;
210
+ border: black 5px;
211
+ cursor: default;
212
+ font-weight: bold;
213
+ display: flex;
214
+ gap: 10px;
215
+ z-index: 10;
216
+ padding: 4px 10px;
217
+ background-color: ${_ref18 => {
218
+ let {
219
+ theme
220
+ } = _ref18;
221
+ return theme['secondary-101'];
222
+ }};
223
+ `;
200
224
  //# sourceMappingURL=ComboBox.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.styles.js","names":["motion","styled","css","ComboBoxDirection","StyledComboBox","div","_ref","$shouldUseFullWidth","$minWidth","StyledComboBoxHeader","_ref2","$isDisabled","_ref3","theme","_ref4","_ref5","$isOpen","$direction","BOTTOM","_ref6","$isTouch","StyledComboBoxPlaceholder","_ref7","text","StyledComboBoxPlaceholderImage","img","_ref8","_ref9","shouldShowRoundImage","StyledComboBoxIconWrapper","StyledMotionComboBoxBody","_ref10","_ref11","$maxHeight","_ref12","$overflowY","_ref13","_ref14","_ref15","_ref16","$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\ntype StyledComboBoxProps = WithTheme<{\n $shouldUseFullWidth: boolean;\n $minWidth: number;\n}>;\n\nexport const StyledComboBox = styled.div<StyledComboBoxProps>`\n user-select: none;\n position: relative;\n\n ${({ $shouldUseFullWidth, $minWidth }) =>\n $shouldUseFullWidth\n ? css`\n min-width: ${$minWidth}px;\n width: 100%;\n `\n : css`\n min-width: ${$minWidth}px;\n max-width: ${$minWidth}px;\n `}\n`;\n\ntype StyledComboBoxHeaderProps = WithTheme<{\n $isTouch: boolean;\n $isOpen: boolean;\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 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 ${({ $isTouch, $isDisabled, theme }: StyledComboBoxHeaderProps) =>\n !$isTouch &&\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 $maxHeight: CSSProperties['maxHeight'];\n $direction: ComboBoxDirection;\n $browser: Browser | 'bot' | null | undefined;\n $minWidth: number;\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 max-height: ${({ $maxHeight }) => $maxHeight};\n overflow-y: ${({ $overflowY }) => $overflowY};\n\n min-width: ${({ $minWidth }) => $minWidth - 2}px;\n max-width: ${({ $minWidth }) => $minWidth - 2}px;\n\n ${({ $direction }) => {\n if ($direction === ComboBoxDirection.BOTTOM) {\n return css`\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.2);\n `;\n }\n\n return css`\n border-top-left-radius: 3px;\n border-top-right-radius: 3px;\n box-shadow: 0 -3px 10px 0 rgba(0, 0, 0, 0.2);\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,SAASA,MAAM,QAAQ,eAAe;AAEtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAC/C,SAASC,iBAAiB,QAAQ,sBAAsB;AASxD,OAAO,MAAMC,cAAc,GAAGH,MAAM,CAACI,GAAwB;AAC7D;AACA;AACA;AACA,MAAMC,IAAA;EAAA,IAAC;IAAEC,mBAAmB;IAAEC;EAAU,CAAC,GAAAF,IAAA;EAAA,OACjCC,mBAAmB,GACbL,GAAG;AACjB,+BAA+BM,SAAS;AACxC;AACA,eAAe,GACDN,GAAG;AACjB,+BAA+BM,SAAS;AACxC,+BAA+BA,SAAS;AACxC,eAAe;AAAA;AACf,CAAC;AASD,OAAO,MAAMC,oBAAoB,GAAGR,MAAM,CAACI,GAA8B;AACzE;AACA;AACA;AACA;AACA,cAAcK,KAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,KAAA;EAAA,OAAM,CAACC,WAAW,GAAG,SAAS,GAAG,SAAS;AAAA,CAAC;AACzE,kBAAkBC,KAAA;EAAA,IAAC;IAAEC;EAAiC,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA;AACxE,eAAeC,KAAA;EAAA,IAAC;IAAEH;EAAY,CAAC,GAAAG,KAAA;EAAA,OAAMH,WAAW,GAAG,GAAG,GAAG,CAAC;AAAA,CAAC;AAC3D;AACA;AACA,MAAMI,KAAA,IAA6B;EAAA,IAA5B;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAAF,KAAA;EACtB,IAAIC,OAAO,EAAE;IACT,OAAOC,UAAU,KAAKd,iBAAiB,CAACe,MAAM,GACxChB,GAAG;AACrB;AACA;A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AA;EAAA,IAAC;IAAEC;EAAW,CAAC,GAAAD,MAAA;EAAA,OAAKC,UAAU;AAAA;AAChD;AACA,iBAAiBC,MAAA;EAAA,IAAC;IAAE5B;EAAU,CAAC,GAAA4B,MAAA;EAAA,OAAK5B,SAAS,GAAG,CAAC;AAAA;AACjD,iBAAiB6B,MAAA;EAAA,IAAC;IAAE7B;EAAU,CAAC,GAAA6B,MAAA;EAAA,OAAK7B,SAAS,GAAG,CAAC;AAAA;AACjD;AACA,MAAM8B,MAAA,IAAoB;EAAA,IAAnB;IAAErB;EAAW,CAAC,GAAAqB,MAAA;EACb,IAAIrB,UAAU,KAAKd,iBAAiB,CAACe,MAAM,EAAE;IACzC,OAAOhB,GAAG;AACtB;AACA;AACA;AACA,aAAa;EACL;EAEA,OAAOA,GAAG;AAClB;AACA;AACA;AACA,SAAS;AACL,CAAC;AACL;AACA;AACA,MAAMqC,MAAA;EAAA,IAAC;IAAEC,QAAQ;IAAE3B;EAA+B,CAAC,GAAA0B,MAAA;EAAA,OAC3CC,QAAQ,KAAK,SAAS,GAChBtC,GAAG;AACjB,0CAA0CW,KAAK,CAAC,UAAU,CAAC;AAC3D;AACA,eAAe,GACDX,GAAG;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+CW,KAAK,CAAC,UAAU,CAAC;AAChE;AACA;AACA,eAAe;AAAA;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ComboBox.styles.js","names":["motion","styled","css","ComboBoxDirection","StyledComboBox","div","_ref","$shouldUseFullWidth","$minWidth","StyledComboBoxHeader","_ref2","$isDisabled","_ref3","theme","_ref4","_ref5","$isOpen","$direction","BOTTOM","_ref6","$isTouch","StyledComboBoxPlaceholder","_ref7","text","StyledComboBoxPlaceholderImage","img","_ref8","_ref9","shouldShowRoundImage","StyledComboBoxIconWrapper","StyledMotionComboBoxBody","_ref10","_ref11","$maxHeight","_ref12","$overflowY","_ref13","_ref14","_ref15","_ref16","$browser","StyledComboBoxTopic","_ref17","_ref18"],"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\ntype StyledComboBoxProps = WithTheme<{\n $shouldUseFullWidth: boolean;\n $minWidth: number;\n}>;\n\nexport const StyledComboBox = styled.div<StyledComboBoxProps>`\n user-select: none;\n position: relative;\n\n ${({ $shouldUseFullWidth, $minWidth }) =>\n $shouldUseFullWidth\n ? css`\n min-width: ${$minWidth}px;\n width: 100%;\n `\n : css`\n min-width: ${$minWidth}px;\n max-width: ${$minWidth}px;\n `}\n`;\n\ntype StyledComboBoxHeaderProps = WithTheme<{\n $isTouch: boolean;\n $isOpen: boolean;\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 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 ${({ $isTouch, $isDisabled, theme }: StyledComboBoxHeaderProps) =>\n !$isTouch &&\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 $maxHeight: CSSProperties['maxHeight'];\n $direction: ComboBoxDirection;\n $browser: Browser | 'bot' | null | undefined;\n $minWidth: number;\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 max-height: ${({ $maxHeight }) => $maxHeight};\n overflow-y: ${({ $overflowY }) => $overflowY};\n\n min-width: ${({ $minWidth }) => $minWidth - 2}px;\n max-width: ${({ $minWidth }) => $minWidth - 2}px;\n\n ${({ $direction }) => {\n if ($direction === ComboBoxDirection.BOTTOM) {\n return css`\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.2);\n `;\n }\n\n return css`\n border-top-left-radius: 3px;\n border-top-right-radius: 3px;\n box-shadow: 0 -3px 10px 0 rgba(0, 0, 0, 0.2);\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\ntype StyledComboBoxTopicProps = WithTheme<unknown>;\n\nexport const StyledComboBoxTopic = styled.div`\n align-items: center;\n color: rgba(${({ theme }: StyledComboBoxTopicProps) => theme['text-rgb']}, 0.65);\n position: sticky;\n top: 0;\n border: black 5px;\n cursor: default;\n font-weight: bold;\n display: flex;\n gap: 10px;\n z-index: 10;\n padding: 4px 10px;\n background-color: ${({ theme }: StyledComboBoxTopicProps) => theme['secondary-101']};\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AAEtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAC/C,SAASC,iBAAiB,QAAQ,sBAAsB;AASxD,OAAO,MAAMC,cAAc,GAAGH,MAAM,CAACI,GAAwB;AAC7D;AACA;AACA;AACA,MAAMC,IAAA;EAAA,IAAC;IAAEC,mBAAmB;IAAEC;EAAU,CAAC,GAAAF,IAAA;EAAA,OACjCC,mBAAmB,GACbL,GAAG;AACjB,+BAA+BM,SAAS;AACxC;AACA,eAAe,GACDN,GAAG;AACjB,+BAA+BM,SAAS;AACxC,+BAA+BA,SAAS;AACxC,eAAe;AAAA;AACf,CAAC;AASD,OAAO,MAAMC,oBAAoB,GAAGR,MAAM,CAACI,GAA8B;AACzE;AACA;AACA;AACA;AACA,cAAcK,KAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,KAAA;E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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+CW,KAAK,CAAC,UAAU,CAAC;AAChE;AACA;AACA,eAAe;AAAA;AACf,CAAC;AAID,OAAO,MAAM4B,mBAAmB,GAAGxC,MAAM,CAACI,GAAG;AAC7C;AACA,kBAAkBqC,MAAA;EAAA,IAAC;IAAE7B;EAAgC,CAAC,GAAA6B,MAAA;EAAA,OAAK7B,KAAK,CAAC,UAAU,CAAC;AAAA;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB8B,MAAA;EAAA,IAAC;IAAE9B;EAAgC,CAAC,GAAA8B,MAAA;EAAA,OAAK9B,KAAK,CAAC,eAAe,CAAC;AAAA;AACvF,CAAC","ignoreList":[]}
@@ -1,17 +1,19 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
2
  import { getIsTouch } from '../../../utils/environment';
3
3
  import Icon from '../../icon/Icon';
4
- import { StyledComboBoxItem, StyledComboBoxItemImage } from './ComboBoxItem.styles';
4
+ import { StyledComboBoxItem, StyledComboBoxItemContent, StyledComboBoxItemContentHeader, StyledComboBoxItemContentHeaderRightElement, StyledComboBoxItemContentHeaderText, StyledComboBoxItemContentSubtext, StyledComboBoxItemImage } from './ComboBoxItem.styles';
5
5
  const ComboBoxItem = _ref => {
6
6
  let {
7
+ icons,
8
+ id,
7
9
  imageUrl,
8
10
  isSelected,
9
- icons,
10
11
  onSelect,
12
+ rightElement,
11
13
  shouldShowRoundImage,
14
+ subtext,
12
15
  suffixElement,
13
16
  text,
14
- id,
15
17
  value
16
18
  } = _ref;
17
19
  const handleItemClick = useCallback(() => {
@@ -30,10 +32,13 @@ const ComboBoxItem = _ref => {
30
32
  $isSelected: isSelected
31
33
  }, imageUrl && /*#__PURE__*/React.createElement(StyledComboBoxItemImage, {
32
34
  src: imageUrl,
35
+ $shouldShowBigImage: typeof subtext === 'string',
33
36
  $shouldShowRoundImage: shouldShowRoundImage
34
37
  }), icons && /*#__PURE__*/React.createElement(Icon, {
35
38
  icons: icons
36
- }), text, suffixElement), [handleItemClick, icons, id, imageUrl, isSelected, isTouch, shouldShowRoundImage, suffixElement, text]);
39
+ }), /*#__PURE__*/React.createElement(StyledComboBoxItemContent, null, /*#__PURE__*/React.createElement(StyledComboBoxItemContentHeader, null, /*#__PURE__*/React.createElement(StyledComboBoxItemContentHeaderText, {
40
+ $shouldShowBoldText: typeof subtext === 'string'
41
+ }, text, suffixElement), /*#__PURE__*/React.createElement(StyledComboBoxItemContentHeaderRightElement, null, rightElement)), /*#__PURE__*/React.createElement(StyledComboBoxItemContentSubtext, null, subtext))), [handleItemClick, icons, id, imageUrl, isSelected, isTouch, rightElement, shouldShowRoundImage, subtext, suffixElement, text]);
37
42
  };
38
43
  ComboBoxItem.displayName = 'ComboBoxItem';
39
44
  export default ComboBoxItem;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBoxItem.js","names":["React","useCallback","useMemo","getIsTouch","Icon","StyledComboBoxItem","StyledComboBoxItemImage","ComboBoxItem","_ref","imageUrl","isSelected","icons","onSelect","shouldShowRoundImage","suffixElement","text","id","value","handleItemClick","isTouch","createElement","String","onClick","$isTouch","$isSelected","src","$shouldShowRoundImage","displayName"],"sources":["../../../../../src/components/combobox/combobox-item/ComboBoxItem.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useMemo } from 'react';\nimport { getIsTouch } from '../../../utils/environment';\nimport Icon from '../../icon/Icon';\nimport type { ComboBoxProps, IComboBoxItem } from '../ComboBox';\nimport { StyledComboBoxItem, StyledComboBoxItemImage } from './ComboBoxItem.styles';\n\nexport type ComboBoxItemProps = {\n imageUrl: IComboBoxItem['imageUrl'];\n isSelected: boolean;\n onSelect: (itemToSelect: IComboBoxItem) => void;\n shouldShowRoundImage: ComboBoxProps['shouldShowRoundImage'];\n icons?: IComboBoxItem['icons'];\n suffixElement?: ReactNode;\n text: IComboBoxItem['text'];\n value: IComboBoxItem['value'];\n id: IComboBoxItem['value'];\n};\n\nconst ComboBoxItem: FC<ComboBoxItemProps> = ({\n imageUrl,\n isSelected,\n icons,\n onSelect,\n shouldShowRoundImage,\n suffixElement,\n text,\n id,\n value,\n}) => {\n const handleItemClick = useCallback(() => {\n onSelect({ text, value, suffixElement, imageUrl });\n }, [imageUrl, onSelect, suffixElement, text, value]);\n\n const isTouch = getIsTouch();\n\n return useMemo(\n () => (\n <StyledComboBoxItem\n id={`combobox-item__${typeof id === 'number' ? String(id) : id}`}\n onClick={handleItemClick}\n $isTouch={isTouch}\n $isSelected={isSelected}\n >\n {imageUrl && (\n <StyledComboBoxItemImage\n src={imageUrl}\n $shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n {icons && <Icon icons={icons} />}\n {text}\n {suffixElement}\n </StyledComboBoxItem>\n ),\n [\n handleItemClick,\n icons,\n id,\n imageUrl,\n isSelected,\n isTouch,\n shouldShowRoundImage,\n suffixElement,\n text,\n ],\n );\n};\n\nComboBoxItem.displayName = 'ComboBoxItem';\n\nexport default ComboBoxItem;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAmBC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAClE,SAASC,UAAU,QAAQ,4BAA4B;AACvD,OAAOC,IAAI,MAAM,iBAAiB;AAElC,SAASC,kBAAkB,EAAEC,uBAAuB,QAAQ,uBAAuB;AAcnF,MAAMC,YAAmC,GAAGC,IAAA,IAUtC;EAAA,IAVuC;IACzCC,QAAQ;IACRC,UAAU;IACVC,KAAK;IACLC,QAAQ;IACRC,oBAAoB;IACpBC,aAAa;IACbC,IAAI;IACJC,EAAE;IACFC;EACJ,CAAC,GAAAT,IAAA;EACG,MAAMU,eAAe,GAAGjB,WAAW,CAAC,MAAM;IACtCW,QAAQ,CAAC;MAAEG,IAAI;MAAEE,KAAK;MAAEH,aAAa;MAAEL;IAAS,CAAC,CAAC;EACtD,CAAC,EAAE,CAACA,QAAQ,EAAEG,QAAQ,EAAEE,aAAa,EAAEC,IAAI,EAAEE,KAAK,CAAC,CAAC;EAEpD,MAAME,OAAO,GAAGhB,UAAU,CAAC,CAAC;EAE5B,OAAOD,OAAO,CACV,mBACIF,KAAA,CAAAoB,aAAA,CAACf,kBAAkB;IACfW,EAAE,EAAE,kBAAkB,OAAOA,EAAE,KAAK,QAAQ,GAAGK,MAAM,CAACL,EAAE,CAAC,GAAGA,EAAE,EAAG;IACjEM,OAAO,EAAEJ,eAAgB;IACzBK,QAAQ,EAAEJ,OAAQ;IAClBK,WAAW,EAAEd;EAAW,GAEvBD,QAAQ,iBACLT,KAAA,CAAAoB,aAAA,CAACd,uBAAuB;IACpBmB,GAAG,EAAEhB,QAAS;IACdiB,qBAAqB,EAAEb;EAAqB,CAC/C,CACJ,EACAF,KAAK,iBAAIX,KAAA,CAAAoB,aAAA,CAAChB,IAAI;IAACO,KAAK,EAAEA;EAAM,CAAE,CAAC,EAC/BI,IAAI,EACJD,aACe,CACvB,EACD,CACII,eAAe,EACfP,KAAK,EACLK,EAAE,EACFP,QAAQ,EACRC,UAAU,EACVS,OAAO,EACPN,oBAAoB,EACpBC,aAAa,EACbC,IAAI,CAEZ,CAAC;AACL,CAAC;AAEDR,YAAY,CAACoB,WAAW,GAAG,cAAc;AAEzC,eAAepB,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"ComboBoxItem.js","names":["React","useCallback","useMemo","getIsTouch","Icon","StyledComboBoxItem","StyledComboBoxItemContent","StyledComboBoxItemContentHeader","StyledComboBoxItemContentHeaderRightElement","StyledComboBoxItemContentHeaderText","StyledComboBoxItemContentSubtext","StyledComboBoxItemImage","ComboBoxItem","_ref","icons","id","imageUrl","isSelected","onSelect","rightElement","shouldShowRoundImage","subtext","suffixElement","text","value","handleItemClick","isTouch","createElement","String","onClick","$isTouch","$isSelected","src","$shouldShowBigImage","$shouldShowRoundImage","$shouldShowBoldText","displayName"],"sources":["../../../../../src/components/combobox/combobox-item/ComboBoxItem.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useMemo } from 'react';\nimport { getIsTouch } from '../../../utils/environment';\nimport Icon from '../../icon/Icon';\nimport type { ComboBoxProps, IComboBoxItem } from '../ComboBox';\nimport {\n StyledComboBoxItem,\n StyledComboBoxItemContent,\n StyledComboBoxItemContentHeader,\n StyledComboBoxItemContentHeaderRightElement,\n StyledComboBoxItemContentHeaderText,\n StyledComboBoxItemContentSubtext,\n StyledComboBoxItemImage,\n} from './ComboBoxItem.styles';\n\nexport type ComboBoxItemProps = {\n icons?: IComboBoxItem['icons'];\n id: IComboBoxItem['value'];\n imageUrl: IComboBoxItem['imageUrl'];\n isSelected: boolean;\n onSelect: (itemToSelect: IComboBoxItem) => void;\n rightElement: IComboBoxItem['rightElement'];\n shouldShowRoundImage: ComboBoxProps['shouldShowRoundImage'];\n subtext: IComboBoxItem['subtext'];\n suffixElement?: ReactNode;\n text: IComboBoxItem['text'];\n value: IComboBoxItem['value'];\n};\n\nconst ComboBoxItem: FC<ComboBoxItemProps> = ({\n icons,\n id,\n imageUrl,\n isSelected,\n onSelect,\n rightElement,\n shouldShowRoundImage,\n subtext,\n suffixElement,\n text,\n value,\n}) => {\n const handleItemClick = useCallback(() => {\n onSelect({ text, value, suffixElement, imageUrl });\n }, [imageUrl, onSelect, suffixElement, text, value]);\n\n const isTouch = getIsTouch();\n\n return useMemo(\n () => (\n <StyledComboBoxItem\n id={`combobox-item__${typeof id === 'number' ? String(id) : id}`}\n onClick={handleItemClick}\n $isTouch={isTouch}\n $isSelected={isSelected}\n >\n {imageUrl && (\n <StyledComboBoxItemImage\n src={imageUrl}\n $shouldShowBigImage={typeof subtext === 'string'}\n $shouldShowRoundImage={shouldShowRoundImage}\n />\n )}\n {icons && <Icon icons={icons} />}\n <StyledComboBoxItemContent>\n <StyledComboBoxItemContentHeader>\n <StyledComboBoxItemContentHeaderText\n $shouldShowBoldText={typeof subtext === 'string'}\n >\n {text}\n {suffixElement}\n </StyledComboBoxItemContentHeaderText>\n <StyledComboBoxItemContentHeaderRightElement>\n {rightElement}\n </StyledComboBoxItemContentHeaderRightElement>\n </StyledComboBoxItemContentHeader>\n <StyledComboBoxItemContentSubtext>{subtext}</StyledComboBoxItemContentSubtext>\n </StyledComboBoxItemContent>\n </StyledComboBoxItem>\n ),\n [\n handleItemClick,\n icons,\n id,\n imageUrl,\n isSelected,\n isTouch,\n rightElement,\n shouldShowRoundImage,\n subtext,\n suffixElement,\n text,\n ],\n );\n};\n\nComboBoxItem.displayName = 'ComboBoxItem';\n\nexport default ComboBoxItem;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAmBC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAClE,SAASC,UAAU,QAAQ,4BAA4B;AACvD,OAAOC,IAAI,MAAM,iBAAiB;AAElC,SACIC,kBAAkB,EAClBC,yBAAyB,EACzBC,+BAA+B,EAC/BC,2CAA2C,EAC3CC,mCAAmC,EACnCC,gCAAgC,EAChCC,uBAAuB,QACpB,uBAAuB;AAgB9B,MAAMC,YAAmC,GAAGC,IAAA,IAYtC;EAAA,IAZuC;IACzCC,KAAK;IACLC,EAAE;IACFC,QAAQ;IACRC,UAAU;IACVC,QAAQ;IACRC,YAAY;IACZC,oBAAoB;IACpBC,OAAO;IACPC,aAAa;IACbC,IAAI;IACJC;EACJ,CAAC,GAAAX,IAAA;EACG,MAAMY,eAAe,GAAGxB,WAAW,CAAC,MAAM;IACtCiB,QAAQ,CAAC;MAAEK,IAAI;MAAEC,KAAK;MAAEF,aAAa;MAAEN;IAAS,CAAC,CAAC;EACtD,CAAC,EAAE,CAACA,QAAQ,EAAEE,QAAQ,EAAEI,aAAa,EAAEC,IAAI,EAAEC,KAAK,CAAC,CAAC;EAEpD,MAAME,OAAO,GAAGvB,UAAU,CAAC,CAAC;EAE5B,OAAOD,OAAO,CACV,mBACIF,KAAA,CAAA2B,aAAA,CAACtB,kBAAkB;IACfU,EAAE,EAAE,kBAAkB,OAAOA,EAAE,KAAK,QAAQ,GAAGa,MAAM,CAACb,EAAE,CAAC,GAAGA,EAAE,EAAG;IACjEc,OAAO,EAAEJ,eAAgB;IACzBK,QAAQ,EAAEJ,OAAQ;IAClBK,WAAW,EAAEd;EAAW,GAEvBD,QAAQ,iBACLhB,KAAA,CAAA2B,aAAA,CAAChB,uBAAuB;IACpBqB,GAAG,EAAEhB,QAAS;IACdiB,mBAAmB,EAAE,OAAOZ,OAAO,KAAK,QAAS;IACjDa,qBAAqB,EAAEd;EAAqB,CAC/C,CACJ,EACAN,KAAK,iBAAId,KAAA,CAAA2B,aAAA,CAACvB,IAAI;IAACU,KAAK,EAAEA;EAAM,CAAE,CAAC,eAChCd,KAAA,CAAA2B,aAAA,CAACrB,yBAAyB,qBACtBN,KAAA,CAAA2B,aAAA,CAACpB,+BAA+B,qBAC5BP,KAAA,CAAA2B,aAAA,CAAClB,mCAAmC;IAChC0B,mBAAmB,EAAE,OAAOd,OAAO,KAAK;EAAS,GAEhDE,IAAI,EACJD,aACgC,CAAC,eACtCtB,KAAA,CAAA2B,aAAA,CAACnB,2CAA2C,QACvCW,YACwC,CAChB,CAAC,eAClCnB,KAAA,CAAA2B,aAAA,CAACjB,gCAAgC,QAAEW,OAA0C,CACtD,CACX,CACvB,EACD,CACII,eAAe,EACfX,KAAK,EACLC,EAAE,EACFC,QAAQ,EACRC,UAAU,EACVS,OAAO,EACPP,YAAY,EACZC,oBAAoB,EACpBC,OAAO,EACPC,aAAa,EACbC,IAAI,CAEZ,CAAC;AACL,CAAC;AAEDX,YAAY,CAACwB,WAAW,GAAG,cAAc;AAEzC,eAAexB,YAAY","ignoreList":[]}
@@ -35,48 +35,61 @@ export const StyledComboBoxItem = styled.div`
35
35
  `;
36
36
  }}
37
37
  `;
38
- export const StyledComboBoxTopic = styled.div`
39
- align-items: center;
40
- color: ${_ref4 => {
38
+ export const StyledComboBoxItemImage = styled.img`
39
+ ${_ref4 => {
41
40
  let {
42
- theme
41
+ $shouldShowRoundImage
43
42
  } = _ref4;
44
- return theme.text;
45
- }};
46
- position: sticky;
47
- top: 0;
48
- border: black 5px;
49
- cursor: default;
50
- font-weight: bold;
51
- display: flex;
52
- gap: 10px;
53
- z-index: 10;
54
- padding: 4px 10px;
55
- background-color: ${_ref5 => {
56
- let {
57
- theme
58
- } = _ref5;
59
- return theme['secondary-101'];
60
- }};
61
- `;
62
- export const StyledComboBoxItemImage = styled.img`
43
+ return $shouldShowRoundImage && css`
44
+ border-radius: 50%;
45
+ `;
46
+ }}
47
+
63
48
  box-shadow: 0 0 0 1px
64
- rgba(${_ref6 => {
49
+ rgba(${_ref5 => {
65
50
  let {
66
51
  theme
67
- } = _ref6;
52
+ } = _ref5;
68
53
  return theme['009-rgb'];
69
54
  }}, 0.15);
70
- height: 22px;
71
- width: 22px;
72
-
73
- ${_ref7 => {
55
+ flex: 0 0 auto;
56
+ height: ${_ref6 => {
74
57
  let {
75
- $shouldShowRoundImage
58
+ $shouldShowBigImage
59
+ } = _ref6;
60
+ return $shouldShowBigImage ? '40px' : '22px';
61
+ }};
62
+ width: ${_ref7 => {
63
+ let {
64
+ $shouldShowBigImage
76
65
  } = _ref7;
77
- return $shouldShowRoundImage && css`
78
- border-radius: 50%;
79
- `;
80
- }}
66
+ return $shouldShowBigImage ? '40px' : '22px';
67
+ }};
68
+ `;
69
+ export const StyledComboBoxItemContent = styled.div`
70
+ display: flex;
71
+ flex: 1 1 auto;
72
+ flex-direction: column;
73
+ line-height: normal;
74
+ `;
75
+ export const StyledComboBoxItemContentHeader = styled.div`
76
+ display: flex;
77
+ justify-content: space-between;
78
+ `;
79
+ export const StyledComboBoxItemContentHeaderText = styled.div`
80
+ display: flex;
81
+ font-weight: ${_ref8 => {
82
+ let {
83
+ $shouldShowBoldText
84
+ } = _ref8;
85
+ return $shouldShowBoldText ? 'bold' : 'normal';
86
+ }};
87
+ gap: 4px;
88
+ `;
89
+ export const StyledComboBoxItemContentHeaderRightElement = styled.div``;
90
+ export const StyledComboBoxItemContentSubtext = styled.div`
91
+ font-size: 85%;
92
+ margin-top: 2px;
93
+ opacity: 0.85;
81
94
  `;
82
95
  //# sourceMappingURL=ComboBoxItem.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBoxItem.styles.js","names":["styled","css","StyledComboBoxItem","div","_ref","theme","$isSelected","_ref2","text","_ref3","$isTouch","StyledComboBoxTopic","_ref4","_ref5","StyledComboBoxItemImage","img","_ref6","_ref7","$shouldShowRoundImage"],"sources":["../../../../../src/components/combobox/combobox-item/ComboBoxItem.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledComboBoxItemProps = WithTheme<{\n $isTouch: boolean;\n $isSelected: boolean;\n}>;\n\nexport const StyledComboBoxItem = styled.div<StyledComboBoxItemProps>`\n align-items: center;\n background-color: ${({ theme, $isSelected }: StyledComboBoxItemProps) =>\n $isSelected && theme['secondary-103']};\n color: ${({ theme }: StyledComboBoxItemProps) => theme.text};\n display: flex;\n gap: 10px;\n padding: 4px 10px;\n transition: background-color 0.2s ease-in-out;\n\n ${({ $isTouch, theme }: StyledComboBoxItemProps) =>\n !$isTouch &&\n css`\n &:hover {\n background-color: ${theme['secondary-102']};\n }\n\n &:focus {\n background-color: ${theme['secondary-102']};\n }\n `}\n`;\n\nexport const StyledComboBoxTopic = styled.div`\n align-items: center;\n color: ${({ theme }) => theme.text};\n position: sticky;\n top: 0;\n border: black 5px;\n cursor: default;\n font-weight: bold;\n display: flex;\n gap: 10px;\n z-index: 10;\n padding: 4px 10px;\n background-color: ${({ theme }) => theme['secondary-101']};\n`;\n\ntype StyledComboBoxItemImageProps = WithTheme<{ $shouldShowRoundImage?: boolean }>;\n\nexport const StyledComboBoxItemImage = styled.img<StyledComboBoxItemImageProps>`\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledComboBoxItemImageProps) => theme['009-rgb']}, 0.15);\n height: 22px;\n width: 22px;\n\n ${({ $shouldShowRoundImage }) =>\n $shouldShowRoundImage &&\n css`\n border-radius: 50%;\n `}\n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B,IACrBjB,GAAG;AACX;AACA,SAAS;AAAA;AACT,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ComboBoxItem.styles.js","names":["styled","css","StyledComboBoxItem","div","_ref","theme","$isSelected","_ref2","text","_ref3","$isTouch","StyledComboBoxItemImage","img","_ref4","$shouldShowRoundImage","_ref5","_ref6","$shouldShowBigImage","_ref7","StyledComboBoxItemContent","StyledComboBoxItemContentHeader","StyledComboBoxItemContentHeaderText","_ref8","$shouldShowBoldText","StyledComboBoxItemContentHeaderRightElement","StyledComboBoxItemContentSubtext"],"sources":["../../../../../src/components/combobox/combobox-item/ComboBoxItem.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledComboBoxItemProps = WithTheme<{\n $isTouch: boolean;\n $isSelected: boolean;\n}>;\n\nexport const StyledComboBoxItem = styled.div<StyledComboBoxItemProps>`\n align-items: center;\n background-color: ${({ theme, $isSelected }: StyledComboBoxItemProps) =>\n $isSelected && theme['secondary-103']};\n color: ${({ theme }: StyledComboBoxItemProps) => theme.text};\n display: flex;\n gap: 10px;\n padding: 4px 10px;\n transition: background-color 0.2s ease-in-out;\n\n ${({ $isTouch, theme }: StyledComboBoxItemProps) =>\n !$isTouch &&\n css`\n &:hover {\n background-color: ${theme['secondary-102']};\n }\n\n &:focus {\n background-color: ${theme['secondary-102']};\n }\n `}\n`;\n\ntype StyledComboBoxItemImageProps = WithTheme<{\n $shouldShowBigImage?: boolean;\n $shouldShowRoundImage?: boolean;\n}>;\n\nexport const StyledComboBoxItemImage = styled.img<StyledComboBoxItemImageProps>`\n ${({ $shouldShowRoundImage }) =>\n $shouldShowRoundImage &&\n css`\n border-radius: 50%;\n `}\n\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledComboBoxItemImageProps) => theme['009-rgb']}, 0.15);\n flex: 0 0 auto;\n height: ${({ $shouldShowBigImage }) => ($shouldShowBigImage ? '40px' : '22px')};\n width: ${({ $shouldShowBigImage }) => ($shouldShowBigImage ? '40px' : '22px')};\n`;\n\nexport const StyledComboBoxItemContent = styled.div`\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n line-height: normal;\n`;\n\nexport const StyledComboBoxItemContentHeader = styled.div`\n display: flex;\n justify-content: space-between;\n`;\n\ntype StyledComboBoxItemContentHeaderTextProps = WithTheme<{ $shouldShowBoldText?: boolean }>;\n\nexport const StyledComboBoxItemContentHeaderText = styled.div<StyledComboBoxItemContentHeaderTextProps>`\n display: flex;\n font-weight: ${({ $shouldShowBoldText }) => ($shouldShowBoldText ? 'bold' : 'normal')};\n gap: 4px;\n`;\n\nexport const StyledComboBoxItemContentHeaderRightElement = styled.div``;\n\nexport const StyledComboBoxItemContentSubtext = styled.div`\n font-size: 85%;\n margin-top: 2px;\n opacity: 0.85;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAQ/C,OAAO,MAAMC,kBAAkB,GAAGF,MAAM,CAACG,GAA4B;AACrE;AACA,wBAAwBC,IAAA;EAAA,IAAC;IAAEC,KAAK;IAAEC;EAAqC,CAAC,GAAAF,IAAA;EAAA,OAChEE,WAAW,IAAID,KAAK,CAAC,eAAe,CAAC;AAAA;AAC7C,aAAaE,KAAA;EAAA,IAAC;IAAEF;EAA+B,CAAC,GAAAE,KAAA;EAAA,OAAKF,KAAK,CAACG,IAAI;AAAA;AAC/D;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAA;EAAA,IAAC;IAAEC,QAAQ;IAAEL;EAA+B,CAAC,GAAAI,KAAA;EAAA,OAC3C,CAACC,QAAQ,IACTT,GAAG;AACX;AACA,oCAAoCI,KAAK,CAAC,eAAe,CAAC;AAC1D;AACA;AACA;AACA,oCAAoCA,KAAK,CAAC,eAAe,CAAC;AAC1D;AACA,SAAS;AAAA;AACT,CAAC;AAOD,OAAO,MAAMM,uBAAuB,GAAGX,MAAM,CAACY,GAAiC;AAC/E,MAAMC,KAAA;EAAA,IAAC;IAAEC;EAAsB,CAAC,GAAAD,KAAA;EAAA,OACxBC,qBAAqB,IACrBb,GAAG;AACX;AACA,SAAS;AAAA;AACT;AACA;AACA,eAAec,KAAA;EAAA,IAAC;IAAEV;EAAoC,CAAC,GAAAU,KAAA;EAAA,OAAKV,KAAK,CAAC,SAAS,CAAC;AAAA;AAC5E;AACA,cAAcW,KAAA;EAAA,IAAC;IAAEC;EAAoB,CAAC,GAAAD,KAAA;EAAA,OAAMC,mBAAmB,GAAG,MAAM,GAAG,MAAM;AAAA,CAAC;AAClF,aAAaC,KAAA;EAAA,IAAC;IAAED;EAAoB,CAAC,GAAAC,KAAA;EAAA,OAAMD,mBAAmB,GAAG,MAAM,GAAG,MAAM;AAAA,CAAC;AACjF,CAAC;AAED,OAAO,MAAME,yBAAyB,GAAGnB,MAAM,CAACG,GAAG;AACnD;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMiB,+BAA+B,GAAGpB,MAAM,CAACG,GAAG;AACzD;AACA;AACA,CAAC;AAID,OAAO,MAAMkB,mCAAmC,GAAGrB,MAAM,CAACG,GAA6C;AACvG;AACA,mBAAmBmB,KAAA;EAAA,IAAC;IAAEC;EAAoB,CAAC,GAAAD,KAAA;EAAA,OAAMC,mBAAmB,GAAG,MAAM,GAAG,QAAQ;AAAA,CAAC;AACzF;AACA,CAAC;AAED,OAAO,MAAMC,2CAA2C,GAAGxB,MAAM,CAACG,GAAG,EAAE;AAEvE,OAAO,MAAMsB,gCAAgC,GAAGzB,MAAM,CAACG,GAAG;AAC1D;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -4,13 +4,14 @@ import Button from '../button/Button';
4
4
  import { StyledSelectButton } from './SelectButton.styles';
5
5
  const SelectButton = _ref => {
6
6
  let {
7
+ buttonText,
8
+ isDisabled,
9
+ list,
7
10
  onSelect,
8
11
  selectedItemIds,
9
12
  shouldAllowMultiSelect,
10
- buttonText,
13
+ shouldShowButtonTextWithSelection,
11
14
  shouldShowSearch,
12
- list,
13
- isDisabled,
14
15
  title
15
16
  } = _ref;
16
17
  const itemList = useMemo(() => {
@@ -29,22 +30,28 @@ const SelectButton = _ref => {
29
30
  });
30
31
  return items;
31
32
  }, [list, selectedItemIds]);
32
- const selectedItemText = useMemo(() => {
33
- if (!selectedItemIds || selectedItemIds.length === 0) {
34
- return null;
33
+ const internalButtonText = useMemo(() => {
34
+ if (shouldShowButtonTextWithSelection || !selectedItemIds || selectedItemIds.length === 0) {
35
+ return buttonText;
35
36
  }
37
+ let addedCount = 0;
36
38
  let newText = '';
39
+ const additionalCount = selectedItemIds.length - 2;
37
40
  list.forEach(_ref3 => {
38
41
  let {
39
42
  text,
40
43
  id
41
44
  } = _ref3;
42
- if (selectedItemIds?.includes(id)) {
45
+ if ((addedCount < 2 || additionalCount <= 1) && selectedItemIds?.includes(id)) {
46
+ addedCount += 1;
43
47
  newText += newText.length === 0 ? `${text}` : `, ${text}`;
44
48
  }
45
49
  });
50
+ if (additionalCount > 1) {
51
+ newText += `, ${additionalCount} weitere`;
52
+ }
46
53
  return newText;
47
- }, [list, selectedItemIds]);
54
+ }, [buttonText, list, selectedItemIds, shouldShowButtonTextWithSelection]);
48
55
  const handleClick = () => {
49
56
  void createDialog({
50
57
  text: title ? `[h1]${title}[/h1]` : undefined,
@@ -69,7 +76,7 @@ const SelectButton = _ref => {
69
76
  isDisabled: isDisabled,
70
77
  isSecondary: true,
71
78
  shouldShowTextAsRobotoMedium: false
72
- }, selectedItemText ?? buttonText));
79
+ }, internalButtonText));
73
80
  };
74
81
  SelectButton.displayName = 'SelectButton';
75
82
  export default 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","title","itemList","items","forEach","_ref2","text","id","isSelected","includes","push","name","selectedItemText","length","newText","_ref3","handleClick","undefined","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 * The title of the dialog.\n */\n title?: string;\n};\n\nconst SelectButton: FC<SelectButtonProps> = ({\n onSelect,\n selectedItemIds,\n shouldAllowMultiSelect,\n buttonText,\n shouldShowSearch,\n list,\n isDisabled,\n title,\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 text: title ? `[h1]${title}[/h1]` : undefined,\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;AAqC1D,MAAMC,YAAmC,GAAGC,IAAA,IAStC;EAAA,IATuC;IACzCC,QAAQ;IACRC,eAAe;IACfC,sBAAsB;IACtBC,UAAU;IACVC,gBAAgB;IAChBC,IAAI;IACJC,UAAU;IACVC;EACJ,CAAC,GAAAR,IAAA;EACG,MAAMS,QAAQ,GAAGb,OAAO,CAAC,MAAM;IAC3B,MAAMc,KAAiC,GAAG,EAAE;IAE5CJ,IAAI,CAACK,OAAO,CAACC,KAAA,IAAkB;MAAA,IAAjB;QAAEC,IAAI;QAAEC;MAAG,CAAC,GAAAF,KAAA;MACtB,MAAMG,UAAU,GAAGb,eAAe,GAAGA,eAAe,CAACc,QAAQ,CAACF,EAAE,CAAC,GAAG,KAAK;MAEzEJ,KAAK,CAACO,IAAI,CAAC;QACPC,IAAI,EAAEL,IAAI;QACVC,EAAE;QACFC;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,OAAOL,KAAK;EAChB,CAAC,EAAE,CAACJ,IAAI,EAAEJ,eAAe,CAAC,CAA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hB,UAAU,EAAEA,UAAW;IACvB8B,WAAW;IACXC,4BAA4B,EAAE;EAAM,GAEnCnB,gBAAgB,IAAIf,UACjB,CACQ,CAAC;AAE7B,CAAC;AAEDL,YAAY,CAACwC,WAAW,GAAG,cAAc;AAEzC,eAAexC,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"SelectButton.js","names":["createDialog","DialogType","React","useMemo","Button","StyledSelectButton","SelectButton","_ref","buttonText","isDisabled","list","onSelect","selectedItemIds","shouldAllowMultiSelect","shouldShowButtonTextWithSelection","shouldShowSearch","title","itemList","items","forEach","_ref2","text","id","isSelected","includes","push","name","internalButtonText","length","addedCount","newText","additionalCount","_ref3","handleClick","undefined","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 button text should be displayed also if items are selected.\n */\n shouldShowButtonTextWithSelection?: boolean;\n /**\n * Whether the search should be displayed inside the dialog.\n */\n shouldShowSearch?: boolean;\n /**\n * The title of the dialog.\n */\n title?: string;\n};\n\nconst SelectButton: FC<SelectButtonProps> = ({\n buttonText,\n isDisabled,\n list,\n onSelect,\n selectedItemIds,\n shouldAllowMultiSelect,\n shouldShowButtonTextWithSelection,\n shouldShowSearch,\n title,\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 internalButtonText = useMemo(() => {\n if (shouldShowButtonTextWithSelection || !selectedItemIds || selectedItemIds.length === 0) {\n return buttonText;\n }\n\n let addedCount = 0;\n let newText = '';\n\n const additionalCount = selectedItemIds.length - 2;\n\n list.forEach(({ text, id }) => {\n if ((addedCount < 2 || additionalCount <= 1) && selectedItemIds?.includes(id)) {\n addedCount += 1;\n newText += newText.length === 0 ? `${text}` : `, ${text}`;\n }\n });\n\n if (additionalCount > 1) {\n newText += `, ${additionalCount} weitere`;\n }\n\n return newText;\n }, [buttonText, list, selectedItemIds, shouldShowButtonTextWithSelection]);\n\n const handleClick = () => {\n void createDialog({\n text: title ? `[h1]${title}[/h1]` : undefined,\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 {internalButtonText}\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,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
8
8
  icons?: string[];
9
9
  imageUrl?: string;
10
+ rightElement?: ReactNode;
11
+ subtext?: string;
10
12
  suffixElement?: ReactNode;
11
13
  text: string;
12
14
  value: string | number;
@@ -291,4 +291,5 @@ export declare const StyledMotionComboBoxBody: import("styled-components/dist/ty
291
291
  } & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
292
292
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
293
293
  }, StyledComboBoxBodyProps>> & string & Omit<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
294
+ export declare const StyledComboBoxTopic: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
294
295
  export {};
@@ -1,15 +1,17 @@
1
1
  import { FC, ReactNode } from 'react';
2
2
  import type { ComboBoxProps, IComboBoxItem } from '../ComboBox';
3
3
  export type ComboBoxItemProps = {
4
+ icons?: IComboBoxItem['icons'];
5
+ id: IComboBoxItem['value'];
4
6
  imageUrl: IComboBoxItem['imageUrl'];
5
7
  isSelected: boolean;
6
8
  onSelect: (itemToSelect: IComboBoxItem) => void;
9
+ rightElement: IComboBoxItem['rightElement'];
7
10
  shouldShowRoundImage: ComboBoxProps['shouldShowRoundImage'];
8
- icons?: IComboBoxItem['icons'];
11
+ subtext: IComboBoxItem['subtext'];
9
12
  suffixElement?: ReactNode;
10
13
  text: IComboBoxItem['text'];
11
14
  value: IComboBoxItem['value'];
12
- id: IComboBoxItem['value'];
13
15
  };
14
16
  declare const ComboBoxItem: FC<ComboBoxItemProps>;
15
17
  export default ComboBoxItem;