@chayns-components/core 5.0.0-beta.1238 → 5.0.0-beta.1241
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 +9 -0
- package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
- package/lib/cjs/components/select-button/SelectButton.js +1 -1
- package/lib/cjs/components/select-button/SelectButton.js.map +1 -1
- package/lib/cjs/hooks/element.js +12 -4
- package/lib/cjs/hooks/element.js.map +1 -1
- package/lib/cjs/types/selectButton.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.js +9 -0
- package/lib/esm/components/combobox/ComboBox.js.map +1 -1
- package/lib/esm/components/select-button/SelectButton.js +1 -1
- package/lib/esm/components/select-button/SelectButton.js.map +1 -1
- package/lib/esm/hooks/element.js +10 -3
- package/lib/esm/hooks/element.js.map +1 -1
- package/lib/esm/types/selectButton.js.map +1 -1
- package/lib/types/components/select-button/SelectButton.d.ts +2 -2
- package/lib/types/hooks/element.d.ts +2 -1
- package/lib/types/types/selectButton.d.ts +1 -1
- package/package.json +2 -2
|
@@ -14,6 +14,7 @@ var _ComboBoxItem = _interopRequireDefault(require("./combobox-item/ComboBoxItem
|
|
|
14
14
|
var _ComboBox = require("./ComboBox.styles");
|
|
15
15
|
var _DropdownBodyWrapper = _interopRequireDefault(require("../dropdown-body-wrapper/DropdownBodyWrapper"));
|
|
16
16
|
var _dropdown = require("../../types/dropdown");
|
|
17
|
+
var _element = require("../../hooks/element");
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
20
|
const ComboBox = ({
|
|
@@ -46,6 +47,9 @@ const ComboBox = ({
|
|
|
46
47
|
const isInputFocused = (0, _react.useRef)(false);
|
|
47
48
|
const styledComboBoxElementRef = (0, _react.useRef)(null);
|
|
48
49
|
const contentRef = (0, _react.useRef)(null);
|
|
50
|
+
const parentSize = (0, _element.useElementSize)(styledComboBoxElementRef, {
|
|
51
|
+
shouldUseParentElement: true
|
|
52
|
+
});
|
|
49
53
|
const functions = (0, _chaynsApi.useFunctions)();
|
|
50
54
|
const values = (0, _chaynsApi.useValues)();
|
|
51
55
|
const isTouch = (0, _environment.getIsTouch)();
|
|
@@ -53,6 +57,11 @@ const ComboBox = ({
|
|
|
53
57
|
browser
|
|
54
58
|
} = (0, _chaynsApi.useDevice)();
|
|
55
59
|
const areaProvider = (0, _react.useContext)(_AreaContextProvider.AreaContext);
|
|
60
|
+
(0, _react.useEffect)(() => {
|
|
61
|
+
if (shouldUseFullWidth && parentSize) {
|
|
62
|
+
setMinWidth(parentSize.width);
|
|
63
|
+
}
|
|
64
|
+
}, [parentSize, shouldUseFullWidth]);
|
|
56
65
|
const shouldChangeColor = (0, _react.useMemo)(() => areaProvider.shouldChangeColor ?? false, [areaProvider.shouldChangeColor]);
|
|
57
66
|
const shouldDisableActions = (0, _react.useMemo)(() => {
|
|
58
67
|
if (!selectedItem) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_calculate","_environment","_AreaContextProvider","_Icon","_interopRequireDefault","_ComboBoxItem","_ComboBox","_DropdownBodyWrapper","_dropdown","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ComboBox","bodyWidth","direction","DropdownDirection","RIGHT","isDisabled","lists","maxHeight","onSelect","placeholder","prefix","container","selectedItem","shouldShowBigImage","shouldShowClearIcon","shouldShowRoundImage","onInputFocus","shouldUseFullWidth","onInputChange","shouldUseCurrentItemWidth","onInputBlur","inputValue","shouldDropDownUseMaxItemWidth","internalSelectedItem","setInternalSelectedItem","useState","isAnimating","setIsAnimating","minWidth","setMinWidth","undefined","bodyMinWidth","setBodyMinWidth","focusedIndex","setFocusedIndex","isInputFocused","useRef","styledComboBoxElementRef","contentRef","functions","useFunctions","values","useValues","isTouch","getIsTouch","browser","useDevice","areaProvider","useContext","AreaContext","shouldChangeColor","useMemo","shouldDisableActions","combinedLists","flatMap","list","length","some","item","value","contentHeight","flatItems","result","handleInputFocus","useCallback","event","current","handleInputBlur","handleOpen","handleClose","handleSetSelectedItem","itemToSelect","onSelectResult","Promise","then","shouldPreventSelection","handleClear","preventDefault","stopPropagation","useEffect","handleKeyDown","key","_contentRef$current","children","stepDirection","newIndex","attempts","newElement","shouldSkip","id","startsWith","endsWith","prevElement","tabIndex","focusedElement","focus","_contentRef$current2","element","newSelectedItem","find","String","replace","document","addEventListener","removeEventListener","_styledComboBoxElemen","allItems","baseWidth","calculateContentWidth","text","hasImage","imageUrl","hasIcon","icons","parentWidth","parentElement","getBoundingClientRect","width","paddingWidth","imageWidth","iconWidth","prefixWidth","prefixTextWidth","Math","max","calculatedWidth","tmpMinWidth","tmpBodyMinWidth","itemWidth","placeholderImageUrl","placeholderIcon","placeholderText","shouldShowRoundPlaceholderImage","selectedItemList","handleHeaderClick","comboBoxGroups","map","createElement","Fragment","groupName","StyledComboBoxTopic","isSelected","StyledComboBox","ref","$minWidth","$shouldUseFullWidth","$shouldUseCurrentItemWidth","StyledComboBoxHeader","$direction","onClick","$isOpen","$isTouch","$isDisabled","$shouldChangeColor","$shouldShowBigImage","StyledComboBoxPrefixAndPlaceholderWrapper","StyledComboBoxPrefix","StyledComboBoxPlaceholder","$shouldReduceOpacity","StyledComboBoxPlaceholderImage","src","$shouldShowRoundImage","StyledComboBoxInput","disabled","onChange","onBlur","onFocus","StyledComboBoxPlaceholderText","suffixElement","StyledComboBoxClearIconWrapper","StyledComboBoxIconWrapper","$shouldShowBorderLeft","anchorElement","onClose","shouldShowDropdown","minBodyWidth","StyledComboBoxBody","$maxHeight","$browser","name","displayName","_default","exports"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { useDevice, useFunctions, useValues } from 'chayns-api';\nimport React, {\n ChangeEventHandler,\n type CSSProperties,\n FC,\n FocusEventHandler,\n Fragment,\n ReactHTML,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { BrowserName } from '../../types/chayns';\nimport { calculateContentWidth } from '../../utils/calculate';\nimport { getIsTouch } from '../../utils/environment';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxBody,\n StyledComboBoxClearIconWrapper,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxInput,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledComboBoxPlaceholderText,\n StyledComboBoxPrefix,\n StyledComboBoxPrefixAndPlaceholderWrapper,\n StyledComboBoxTopic,\n} from './ComboBox.styles';\nimport DropdownBodyWrapper from '../dropdown-body-wrapper/DropdownBodyWrapper';\nimport { DropdownDirection } from '../../types/dropdown';\n\nexport interface IComboBoxItems {\n groupName?: string;\n list: Array<IComboBoxItem>;\n shouldShowRoundImage?: boolean;\n}\n\nexport interface ComboBoxTextStyles {\n tagName?: keyof ReactHTML;\n styles?: CSSProperties;\n}\n\nexport interface IComboBoxItem {\n icons?: string[];\n imageBackground?: CSSProperties['background'];\n imageUrl?: string;\n isDisabled?: boolean;\n rightElement?: ReactNode;\n subtext?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n textStyles?: ComboBoxTextStyles;\n}\n\nexport type ComboBoxProps = {\n /**\n * The width of the body.\n */\n bodyWidth?: number;\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?: DropdownDirection;\n /**\n * The value of the optional input.\n */\n inputValue?: string;\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?: number;\n /**\n * Function to be executed when the value of the optional input is changed.\n */\n onInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the optional input lost its focus.\n */\n onInputBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the optional input gets its focus.\n */\n onInputFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that should be executed when an item is selected. If the function returns false, the item will not be selected.\n */\n onSelect?: (comboboxItem?: IComboBoxItem) => Promise<boolean> | boolean | void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * A prefix that should be displayed before the placeholder.\n */\n prefix?: 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 bigger shape. This prop will automatically be set to true if the subtext of an item is given.\n */\n shouldShowBigImage?: boolean;\n /**\n * If true, a clear icon is displayed at the end of the combo box if an item is selected.\n */\n shouldShowClearIcon?: boolean;\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 current item.\n */\n shouldUseCurrentItemWidth?: 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 * If true, the dropdown will use the maximum width of the items.\n */\n shouldDropDownUseMaxItemWidth?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n bodyWidth,\n direction = DropdownDirection.RIGHT,\n isDisabled = false,\n lists,\n maxHeight = 280,\n onSelect,\n placeholder,\n prefix,\n container,\n selectedItem,\n shouldShowBigImage,\n shouldShowClearIcon,\n shouldShowRoundImage,\n onInputFocus,\n shouldUseFullWidth = false,\n onInputChange,\n shouldUseCurrentItemWidth = false,\n onInputBlur,\n inputValue,\n shouldDropDownUseMaxItemWidth = false,\n}) => {\n const [internalSelectedItem, setInternalSelectedItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState<number | undefined>(undefined);\n const [bodyMinWidth, setBodyMinWidth] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n const isInputFocused = useRef(false);\n\n const styledComboBoxElementRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const functions = useFunctions();\n const values = useValues();\n\n const isTouch = getIsTouch();\n\n const { browser } = useDevice();\n\n const areaProvider = useContext(AreaContext);\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const shouldDisableActions = useMemo(() => {\n if (!selectedItem) {\n return false;\n }\n\n const combinedLists = lists.flatMap((list) => list.list);\n\n return (\n combinedLists.length === 1 &&\n combinedLists.some((item) => item.value === selectedItem.value)\n );\n }, [lists, selectedItem]);\n\n const contentHeight = useMemo(() => {\n const flatItems = lists.flatMap((list) => list.list);\n\n let result = flatItems.length * 36;\n\n if (lists.length > 1) {\n result += lists.length * 36;\n }\n\n if (maxHeight < result) {\n result = maxHeight;\n }\n\n return result;\n }, [lists, maxHeight]);\n\n const handleInputFocus: FocusEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n isInputFocused.current = true;\n onInputFocus?.(event);\n },\n [onInputFocus],\n );\n\n const handleInputBlur: FocusEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n isInputFocused.current = false;\n onInputBlur?.(event);\n },\n [onInputBlur],\n );\n\n const handleOpen = useCallback(() => {\n setIsAnimating(true);\n }, []);\n\n const handleClose = useCallback(() => {\n setIsAnimating(false);\n }, []);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect?: IComboBoxItem) => {\n if (typeof onSelect === 'function') {\n const onSelectResult = onSelect(itemToSelect);\n\n if (onSelectResult === false) {\n return;\n }\n\n if (onSelectResult instanceof Promise) {\n void onSelectResult.then((shouldPreventSelection) => {\n if (shouldPreventSelection) return;\n\n setInternalSelectedItem(itemToSelect);\n setIsAnimating(false);\n });\n\n return;\n }\n }\n\n setInternalSelectedItem(itemToSelect);\n setIsAnimating(false);\n },\n [onSelect],\n );\n\n const handleClear = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n event.preventDefault();\n event.stopPropagation();\n\n handleSetSelectedItem(undefined);\n },\n [handleSetSelectedItem],\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (!isAnimating) return;\n\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n\n const children = contentRef.current?.children;\n\n if (!children || children.length === 0) return;\n\n const stepDirection = e.key === 'ArrowUp' ? -1 : 1;\n\n let newIndex = focusedIndex ?? -1;\n\n let attempts = 0;\n\n do {\n newIndex = (newIndex + stepDirection + children.length) % children.length;\n\n const newElement = children[newIndex] as HTMLDivElement;\n\n let shouldSkip = false;\n\n if (\n newElement.id.startsWith('combobox-group--') ||\n newElement.id.endsWith('--disabled-item')\n ) {\n shouldSkip = true;\n }\n\n if (!shouldSkip) break;\n\n attempts++;\n } while (attempts < children.length);\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const focusedElement = children[newIndex] as HTMLDivElement;\n\n focusedElement.tabIndex = 0;\n\n focusedElement.focus();\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) return;\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\n return !!newSelectedItem;\n });\n\n if (newSelectedItem) {\n handleSetSelectedItem(newSelectedItem);\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => document.removeEventListener('keydown', handleKeyDown);\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 let baseWidth = calculateContentWidth(\n [\n ...allItems,\n { text: placeholder, value: 'placeholder' },\n ...(selectedItem ? [selectedItem] : []),\n ],\n functions,\n values,\n );\n\n if (shouldDropDownUseMaxItemWidth) {\n baseWidth += 20 + 2; // 20px padding left and right and 2px border\n setBodyMinWidth(baseWidth);\n setMinWidth(baseWidth);\n return;\n }\n\n const hasImage = [selectedItem, ...allItems].some((item) => item?.imageUrl);\n const hasIcon = [selectedItem, ...allItems].some((item) => item?.icons);\n\n const parentWidth =\n styledComboBoxElementRef.current?.parentElement?.getBoundingClientRect().width ?? 0;\n\n const paddingWidth = 20 + 2 + 40 + 40; // padding + border + arrow icon + optional clear icon\n const imageWidth = hasImage ? 32 : 0; // image width + gap if images present\n const iconWidth = hasIcon ? 40 : 0; // icon width + gap if icons present\n\n let prefixWidth = 0;\n\n if (prefix) {\n const prefixTextWidth =\n calculateContentWidth([{ text: prefix, value: 'prefix' }], functions, values) + 5;\n\n prefixWidth = Math.max(prefixTextWidth, 32);\n }\n\n const calculatedWidth = baseWidth + paddingWidth + imageWidth + iconWidth + prefixWidth;\n\n let tmpMinWidth = calculatedWidth;\n let tmpBodyMinWidth = calculatedWidth;\n\n // Full width settings\n if (shouldUseFullWidth) {\n tmpMinWidth = parentWidth;\n\n tmpBodyMinWidth =\n parentWidth < calculatedWidth - 20 ? calculatedWidth - 20 : parentWidth;\n }\n // Current item width settings\n else if (shouldUseCurrentItemWidth && internalSelectedItem) {\n const itemWidth =\n calculateContentWidth([internalSelectedItem], functions, values) +\n paddingWidth +\n imageWidth +\n iconWidth +\n prefixWidth;\n\n tmpMinWidth = itemWidth;\n\n tmpBodyMinWidth = itemWidth < calculatedWidth - 20 ? calculatedWidth - 20 : itemWidth;\n }\n\n if (tmpMinWidth > parentWidth) {\n tmpMinWidth = parentWidth;\n }\n\n if (tmpBodyMinWidth > parentWidth) {\n tmpBodyMinWidth = parentWidth;\n }\n\n setMinWidth(tmpMinWidth);\n setBodyMinWidth(shouldUseCurrentItemWidth ? tmpMinWidth : tmpBodyMinWidth);\n }, [\n lists,\n placeholder,\n shouldUseFullWidth,\n shouldUseCurrentItemWidth,\n internalSelectedItem,\n prefix,\n selectedItem,\n functions,\n values,\n shouldDropDownUseMaxItemWidth,\n ]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n setIsAnimating(false);\n setInternalSelectedItem(selectedItem);\n }, [selectedItem]);\n\n const placeholderImageUrl = useMemo(() => {\n if (selectedItem) {\n return selectedItem.imageUrl;\n }\n\n if (internalSelectedItem) {\n return internalSelectedItem.imageUrl;\n }\n\n return undefined;\n }, [internalSelectedItem, selectedItem]);\n\n const placeholderIcon = useMemo(() => {\n if (selectedItem) {\n return selectedItem.icons;\n }\n\n if (internalSelectedItem) {\n return internalSelectedItem.icons;\n }\n\n return undefined;\n }, [internalSelectedItem, 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 (internalSelectedItem) {\n text = internalSelectedItem.text;\n }\n\n return text;\n }, [internalSelectedItem, placeholder, selectedItem]);\n\n const shouldShowRoundPlaceholderImage = useMemo(() => {\n const selectedItemList = lists.find((list) =>\n list.list.some(\n ({ value }) => value === (selectedItem?.value ?? internalSelectedItem?.value),\n ),\n );\n\n return selectedItemList?.shouldShowRoundImage ?? shouldShowRoundImage;\n }, [internalSelectedItem?.value, lists, selectedItem?.value, shouldShowRoundImage]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = useCallback(() => {\n if (!isDisabled && !isInputFocused.current) {\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((list) => (\n <Fragment key={list.groupName ?? 'default-group'}>\n {list.groupName && lists.length > 1 && (\n <StyledComboBoxTopic id={`combobox-group--${list.groupName}`}>\n {list.groupName}\n </StyledComboBoxTopic>\n )}\n {list.list.map((item) => (\n <ComboBoxItem\n item={item}\n isSelected={selectedItem ? item.value === selectedItem.value : false}\n onSelect={handleSetSelectedItem}\n shouldShowBigImage={shouldShowBigImage}\n shouldShowRoundImage={list.shouldShowRoundImage ?? shouldShowRoundImage}\n />\n ))}\n </Fragment>\n )),\n [handleSetSelectedItem, lists, selectedItem, shouldShowBigImage, shouldShowRoundImage],\n );\n\n return useMemo(\n () => (\n <StyledComboBox\n ref={styledComboBoxElementRef}\n $minWidth={minWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n $shouldUseCurrentItemWidth={shouldUseCurrentItemWidth}\n >\n <StyledComboBoxHeader\n $direction={direction}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isTouch={isTouch}\n $isDisabled={isDisabled}\n $shouldChangeColor={shouldChangeColor}\n $shouldShowBigImage={shouldShowBigImage}\n >\n <StyledComboBoxPrefixAndPlaceholderWrapper>\n {prefix && <StyledComboBoxPrefix>{prefix}</StyledComboBoxPrefix>}\n <StyledComboBoxPlaceholder\n $shouldReduceOpacity={!selectedItem && !internalSelectedItem}\n >\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n $shouldShowBigImage={shouldShowBigImage}\n $shouldShowRoundImage={shouldShowRoundPlaceholderImage}\n />\n )}\n {placeholderIcon && <Icon icons={placeholderIcon} />}\n {typeof inputValue === 'string' ? (\n <StyledComboBoxInput\n disabled={isDisabled}\n value={inputValue}\n onChange={onInputChange}\n onBlur={handleInputBlur}\n onFocus={handleInputFocus}\n placeholder={placeholderText}\n />\n ) : (\n <StyledComboBoxPlaceholderText>\n {placeholderText}\n </StyledComboBoxPlaceholderText>\n )}\n {internalSelectedItem &&\n internalSelectedItem.suffixElement &&\n internalSelectedItem.suffixElement}\n </StyledComboBoxPlaceholder>\n </StyledComboBoxPrefixAndPlaceholderWrapper>\n {shouldShowClearIcon && internalSelectedItem && (\n <StyledComboBoxClearIconWrapper onClick={handleClear}>\n <Icon icons={['fa fa-times']} />\n </StyledComboBoxClearIconWrapper>\n )}\n {!shouldDisableActions && (\n <StyledComboBoxIconWrapper\n $shouldShowBorderLeft={\n shouldShowClearIcon === true && internalSelectedItem !== undefined\n }\n >\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n )}\n </StyledComboBoxHeader>\n {styledComboBoxElementRef.current && (\n <DropdownBodyWrapper\n anchorElement={styledComboBoxElementRef.current}\n bodyWidth={bodyWidth}\n contentHeight={contentHeight}\n onClose={handleClose}\n direction={direction}\n container={container}\n shouldShowDropdown={isAnimating}\n minBodyWidth={bodyWidth ?? bodyMinWidth}\n maxHeight={maxHeight}\n >\n <StyledComboBoxBody\n $shouldUseCurrentItemWidth={shouldUseCurrentItemWidth}\n $maxHeight={maxHeight}\n $minWidth={bodyWidth ?? bodyMinWidth}\n $browser={browser?.name as BrowserName}\n ref={contentRef}\n tabIndex={0}\n >\n {comboBoxGroups}\n </StyledComboBoxBody>\n </DropdownBodyWrapper>\n )}\n </StyledComboBox>\n ),\n [\n minWidth,\n shouldUseFullWidth,\n shouldUseCurrentItemWidth,\n direction,\n handleHeaderClick,\n isAnimating,\n isTouch,\n isDisabled,\n shouldChangeColor,\n shouldShowBigImage,\n prefix,\n selectedItem,\n internalSelectedItem,\n placeholderImageUrl,\n shouldShowRoundPlaceholderImage,\n placeholderIcon,\n inputValue,\n onInputChange,\n handleInputBlur,\n handleInputFocus,\n placeholderText,\n shouldShowClearIcon,\n handleClear,\n shouldDisableActions,\n bodyWidth,\n contentHeight,\n handleClose,\n container,\n bodyMinWidth,\n maxHeight,\n browser?.name,\n comboBoxGroups,\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;AAgBA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAcA,IAAAU,oBAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,SAAA,GAAAX,OAAA;AAAyD,SAAAO,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAd,uBAAA,YAAAA,CAAAU,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,C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0B,EAAE/H,yBAA0B;IACtD8J,UAAU,EAAE1K,SAAU;IACtByI,SAAS,EAAE/I,SAAS,IAAI8B,YAAa;IACrCmJ,QAAQ,EAAErI,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEsI,IAAoB;IACvCpC,GAAG,EAAEzG,UAAW;IAChBuD,QAAQ,EAAE;EAAE,GAEX0C,cACe,CACH,CAEb,CACnB,EACD,CACI3G,QAAQ,EACRX,kBAAkB,EAClBE,yBAAyB,EACzBjB,SAAS,EACToI,iBAAiB,EACjB5G,WAAW,EACXiB,OAAO,EACPtC,UAAU,EACV6C,iBAAiB,EACjBrC,kBAAkB,EAClBH,MAAM,EACNE,YAAY,EACZW,oBAAoB,EACpB0G,mBAAmB,EACnBG,+BAA+B,EAC/BF,eAAe,EACf7G,UAAU,EACVH,aAAa,EACbiD,eAAe,EACfJ,gBAAgB,EAChBoE,eAAe,EACfrH,mBAAmB,EACnB8D,WAAW,EACXxB,oBAAoB,EACpBnD,SAAS,EACT2D,aAAa,EACbS,WAAW,EACX1D,SAAS,EACToB,YAAY,EACZxB,SAAS,EACTsC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEsI,IAAI,EACb5C,cAAc,CAEtB,CAAC;AACL,CAAC;AAEDvI,QAAQ,CAACoL,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAvM,OAAA,GAEnBiB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ComboBox.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_calculate","_environment","_AreaContextProvider","_Icon","_interopRequireDefault","_ComboBoxItem","_ComboBox","_DropdownBodyWrapper","_dropdown","_element","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ComboBox","bodyWidth","direction","DropdownDirection","RIGHT","isDisabled","lists","maxHeight","onSelect","placeholder","prefix","container","selectedItem","shouldShowBigImage","shouldShowClearIcon","shouldShowRoundImage","onInputFocus","shouldUseFullWidth","onInputChange","shouldUseCurrentItemWidth","onInputBlur","inputValue","shouldDropDownUseMaxItemWidth","internalSelectedItem","setInternalSelectedItem","useState","isAnimating","setIsAnimating","minWidth","setMinWidth","undefined","bodyMinWidth","setBodyMinWidth","focusedIndex","setFocusedIndex","isInputFocused","useRef","styledComboBoxElementRef","contentRef","parentSize","useElementSize","shouldUseParentElement","functions","useFunctions","values","useValues","isTouch","getIsTouch","browser","useDevice","areaProvider","useContext","AreaContext","useEffect","width","shouldChangeColor","useMemo","shouldDisableActions","combinedLists","flatMap","list","length","some","item","value","contentHeight","flatItems","result","handleInputFocus","useCallback","event","current","handleInputBlur","handleOpen","handleClose","handleSetSelectedItem","itemToSelect","onSelectResult","Promise","then","shouldPreventSelection","handleClear","preventDefault","stopPropagation","handleKeyDown","key","_contentRef$current","children","stepDirection","newIndex","attempts","newElement","shouldSkip","id","startsWith","endsWith","prevElement","tabIndex","focusedElement","focus","_contentRef$current2","element","newSelectedItem","find","String","replace","document","addEventListener","removeEventListener","_styledComboBoxElemen","allItems","baseWidth","calculateContentWidth","text","hasImage","imageUrl","hasIcon","icons","parentWidth","parentElement","getBoundingClientRect","paddingWidth","imageWidth","iconWidth","prefixWidth","prefixTextWidth","Math","max","calculatedWidth","tmpMinWidth","tmpBodyMinWidth","itemWidth","placeholderImageUrl","placeholderIcon","placeholderText","shouldShowRoundPlaceholderImage","selectedItemList","handleHeaderClick","comboBoxGroups","map","createElement","Fragment","groupName","StyledComboBoxTopic","isSelected","StyledComboBox","ref","$minWidth","$shouldUseFullWidth","$shouldUseCurrentItemWidth","StyledComboBoxHeader","$direction","onClick","$isOpen","$isTouch","$isDisabled","$shouldChangeColor","$shouldShowBigImage","StyledComboBoxPrefixAndPlaceholderWrapper","StyledComboBoxPrefix","StyledComboBoxPlaceholder","$shouldReduceOpacity","StyledComboBoxPlaceholderImage","src","$shouldShowRoundImage","StyledComboBoxInput","disabled","onChange","onBlur","onFocus","StyledComboBoxPlaceholderText","suffixElement","StyledComboBoxClearIconWrapper","StyledComboBoxIconWrapper","$shouldShowBorderLeft","anchorElement","onClose","shouldShowDropdown","minBodyWidth","StyledComboBoxBody","$maxHeight","$browser","name","displayName","_default","exports"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { useDevice, useFunctions, useValues } from 'chayns-api';\nimport React, {\n ChangeEventHandler,\n type CSSProperties,\n FC,\n FocusEventHandler,\n Fragment,\n ReactHTML,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { BrowserName } from '../../types/chayns';\nimport { calculateContentWidth } from '../../utils/calculate';\nimport { getIsTouch } from '../../utils/environment';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxBody,\n StyledComboBoxClearIconWrapper,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxInput,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledComboBoxPlaceholderText,\n StyledComboBoxPrefix,\n StyledComboBoxPrefixAndPlaceholderWrapper,\n StyledComboBoxTopic,\n} from './ComboBox.styles';\nimport DropdownBodyWrapper from '../dropdown-body-wrapper/DropdownBodyWrapper';\nimport { DropdownDirection } from '../../types/dropdown';\nimport { useElementSize } from '../../hooks/element';\n\nexport interface IComboBoxItems {\n groupName?: string;\n list: Array<IComboBoxItem>;\n shouldShowRoundImage?: boolean;\n}\n\nexport interface ComboBoxTextStyles {\n tagName?: keyof ReactHTML;\n styles?: CSSProperties;\n}\n\nexport interface IComboBoxItem {\n icons?: string[];\n imageBackground?: CSSProperties['background'];\n imageUrl?: string;\n isDisabled?: boolean;\n rightElement?: ReactNode;\n subtext?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n textStyles?: ComboBoxTextStyles;\n}\n\nexport type ComboBoxProps = {\n /**\n * The width of the body.\n */\n bodyWidth?: number;\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?: DropdownDirection;\n /**\n * The value of the optional input.\n */\n inputValue?: string;\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?: number;\n /**\n * Function to be executed when the value of the optional input is changed.\n */\n onInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the optional input lost its focus.\n */\n onInputBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the optional input gets its focus.\n */\n onInputFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that should be executed when an item is selected. If the function returns false, the item will not be selected.\n */\n onSelect?: (comboboxItem?: IComboBoxItem) => Promise<boolean> | boolean | void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * A prefix that should be displayed before the placeholder.\n */\n prefix?: 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 bigger shape. This prop will automatically be set to true if the subtext of an item is given.\n */\n shouldShowBigImage?: boolean;\n /**\n * If true, a clear icon is displayed at the end of the combo box if an item is selected.\n */\n shouldShowClearIcon?: boolean;\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 current item.\n */\n shouldUseCurrentItemWidth?: 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 * If true, the dropdown will use the maximum width of the items.\n */\n shouldDropDownUseMaxItemWidth?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n bodyWidth,\n direction = DropdownDirection.RIGHT,\n isDisabled = false,\n lists,\n maxHeight = 280,\n onSelect,\n placeholder,\n prefix,\n container,\n selectedItem,\n shouldShowBigImage,\n shouldShowClearIcon,\n shouldShowRoundImage,\n onInputFocus,\n shouldUseFullWidth = false,\n onInputChange,\n shouldUseCurrentItemWidth = false,\n onInputBlur,\n inputValue,\n shouldDropDownUseMaxItemWidth = false,\n}) => {\n const [internalSelectedItem, setInternalSelectedItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState<number | undefined>(undefined);\n const [bodyMinWidth, setBodyMinWidth] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n const isInputFocused = useRef(false);\n\n const styledComboBoxElementRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const parentSize = useElementSize(styledComboBoxElementRef, { shouldUseParentElement: true });\n\n const functions = useFunctions();\n const values = useValues();\n\n const isTouch = getIsTouch();\n\n const { browser } = useDevice();\n\n const areaProvider = useContext(AreaContext);\n\n useEffect(() => {\n if (shouldUseFullWidth && parentSize) {\n setMinWidth(parentSize.width);\n }\n }, [parentSize, shouldUseFullWidth]);\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const shouldDisableActions = useMemo(() => {\n if (!selectedItem) {\n return false;\n }\n\n const combinedLists = lists.flatMap((list) => list.list);\n\n return (\n combinedLists.length === 1 &&\n combinedLists.some((item) => item.value === selectedItem.value)\n );\n }, [lists, selectedItem]);\n\n const contentHeight = useMemo(() => {\n const flatItems = lists.flatMap((list) => list.list);\n\n let result = flatItems.length * 36;\n\n if (lists.length > 1) {\n result += lists.length * 36;\n }\n\n if (maxHeight < result) {\n result = maxHeight;\n }\n\n return result;\n }, [lists, maxHeight]);\n\n const handleInputFocus: FocusEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n isInputFocused.current = true;\n onInputFocus?.(event);\n },\n [onInputFocus],\n );\n\n const handleInputBlur: FocusEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n isInputFocused.current = false;\n onInputBlur?.(event);\n },\n [onInputBlur],\n );\n\n const handleOpen = useCallback(() => {\n setIsAnimating(true);\n }, []);\n\n const handleClose = useCallback(() => {\n setIsAnimating(false);\n }, []);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect?: IComboBoxItem) => {\n if (typeof onSelect === 'function') {\n const onSelectResult = onSelect(itemToSelect);\n\n if (onSelectResult === false) {\n return;\n }\n\n if (onSelectResult instanceof Promise) {\n void onSelectResult.then((shouldPreventSelection) => {\n if (shouldPreventSelection) return;\n\n setInternalSelectedItem(itemToSelect);\n setIsAnimating(false);\n });\n\n return;\n }\n }\n\n setInternalSelectedItem(itemToSelect);\n setIsAnimating(false);\n },\n [onSelect],\n );\n\n const handleClear = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n event.preventDefault();\n event.stopPropagation();\n\n handleSetSelectedItem(undefined);\n },\n [handleSetSelectedItem],\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (!isAnimating) return;\n\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n\n const children = contentRef.current?.children;\n\n if (!children || children.length === 0) return;\n\n const stepDirection = e.key === 'ArrowUp' ? -1 : 1;\n\n let newIndex = focusedIndex ?? -1;\n\n let attempts = 0;\n\n do {\n newIndex = (newIndex + stepDirection + children.length) % children.length;\n\n const newElement = children[newIndex] as HTMLDivElement;\n\n let shouldSkip = false;\n\n if (\n newElement.id.startsWith('combobox-group--') ||\n newElement.id.endsWith('--disabled-item')\n ) {\n shouldSkip = true;\n }\n\n if (!shouldSkip) break;\n\n attempts++;\n } while (attempts < children.length);\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const focusedElement = children[newIndex] as HTMLDivElement;\n\n focusedElement.tabIndex = 0;\n\n focusedElement.focus();\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) return;\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\n return !!newSelectedItem;\n });\n\n if (newSelectedItem) {\n handleSetSelectedItem(newSelectedItem);\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => document.removeEventListener('keydown', handleKeyDown);\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 let baseWidth = calculateContentWidth(\n [\n ...allItems,\n { text: placeholder, value: 'placeholder' },\n ...(selectedItem ? [selectedItem] : []),\n ],\n functions,\n values,\n );\n\n if (shouldDropDownUseMaxItemWidth) {\n baseWidth += 20 + 2; // 20px padding left and right and 2px border\n setBodyMinWidth(baseWidth);\n setMinWidth(baseWidth);\n return;\n }\n\n const hasImage = [selectedItem, ...allItems].some((item) => item?.imageUrl);\n const hasIcon = [selectedItem, ...allItems].some((item) => item?.icons);\n\n const parentWidth =\n styledComboBoxElementRef.current?.parentElement?.getBoundingClientRect().width ?? 0;\n\n const paddingWidth = 20 + 2 + 40 + 40; // padding + border + arrow icon + optional clear icon\n const imageWidth = hasImage ? 32 : 0; // image width + gap if images present\n const iconWidth = hasIcon ? 40 : 0; // icon width + gap if icons present\n\n let prefixWidth = 0;\n\n if (prefix) {\n const prefixTextWidth =\n calculateContentWidth([{ text: prefix, value: 'prefix' }], functions, values) + 5;\n\n prefixWidth = Math.max(prefixTextWidth, 32);\n }\n\n const calculatedWidth = baseWidth + paddingWidth + imageWidth + iconWidth + prefixWidth;\n\n let tmpMinWidth = calculatedWidth;\n let tmpBodyMinWidth = calculatedWidth;\n\n // Full width settings\n if (shouldUseFullWidth) {\n tmpMinWidth = parentWidth;\n\n tmpBodyMinWidth =\n parentWidth < calculatedWidth - 20 ? calculatedWidth - 20 : parentWidth;\n }\n // Current item width settings\n else if (shouldUseCurrentItemWidth && internalSelectedItem) {\n const itemWidth =\n calculateContentWidth([internalSelectedItem], functions, values) +\n paddingWidth +\n imageWidth +\n iconWidth +\n prefixWidth;\n\n tmpMinWidth = itemWidth;\n\n tmpBodyMinWidth = itemWidth < calculatedWidth - 20 ? calculatedWidth - 20 : itemWidth;\n }\n\n if (tmpMinWidth > parentWidth) {\n tmpMinWidth = parentWidth;\n }\n\n if (tmpBodyMinWidth > parentWidth) {\n tmpBodyMinWidth = parentWidth;\n }\n\n setMinWidth(tmpMinWidth);\n setBodyMinWidth(shouldUseCurrentItemWidth ? tmpMinWidth : tmpBodyMinWidth);\n }, [\n lists,\n placeholder,\n shouldUseFullWidth,\n shouldUseCurrentItemWidth,\n internalSelectedItem,\n prefix,\n selectedItem,\n functions,\n values,\n shouldDropDownUseMaxItemWidth,\n ]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n setIsAnimating(false);\n setInternalSelectedItem(selectedItem);\n }, [selectedItem]);\n\n const placeholderImageUrl = useMemo(() => {\n if (selectedItem) {\n return selectedItem.imageUrl;\n }\n\n if (internalSelectedItem) {\n return internalSelectedItem.imageUrl;\n }\n\n return undefined;\n }, [internalSelectedItem, selectedItem]);\n\n const placeholderIcon = useMemo(() => {\n if (selectedItem) {\n return selectedItem.icons;\n }\n\n if (internalSelectedItem) {\n return internalSelectedItem.icons;\n }\n\n return undefined;\n }, [internalSelectedItem, 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 (internalSelectedItem) {\n text = internalSelectedItem.text;\n }\n\n return text;\n }, [internalSelectedItem, placeholder, selectedItem]);\n\n const shouldShowRoundPlaceholderImage = useMemo(() => {\n const selectedItemList = lists.find((list) =>\n list.list.some(\n ({ value }) => value === (selectedItem?.value ?? internalSelectedItem?.value),\n ),\n );\n\n return selectedItemList?.shouldShowRoundImage ?? shouldShowRoundImage;\n }, [internalSelectedItem?.value, lists, selectedItem?.value, shouldShowRoundImage]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = useCallback(() => {\n if (!isDisabled && !isInputFocused.current) {\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((list) => (\n <Fragment key={list.groupName ?? 'default-group'}>\n {list.groupName && lists.length > 1 && (\n <StyledComboBoxTopic id={`combobox-group--${list.groupName}`}>\n {list.groupName}\n </StyledComboBoxTopic>\n )}\n {list.list.map((item) => (\n <ComboBoxItem\n item={item}\n isSelected={selectedItem ? item.value === selectedItem.value : false}\n onSelect={handleSetSelectedItem}\n shouldShowBigImage={shouldShowBigImage}\n shouldShowRoundImage={list.shouldShowRoundImage ?? shouldShowRoundImage}\n />\n ))}\n </Fragment>\n )),\n [handleSetSelectedItem, lists, selectedItem, shouldShowBigImage, shouldShowRoundImage],\n );\n\n return useMemo(\n () => (\n <StyledComboBox\n ref={styledComboBoxElementRef}\n $minWidth={minWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n $shouldUseCurrentItemWidth={shouldUseCurrentItemWidth}\n >\n <StyledComboBoxHeader\n $direction={direction}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isTouch={isTouch}\n $isDisabled={isDisabled}\n $shouldChangeColor={shouldChangeColor}\n $shouldShowBigImage={shouldShowBigImage}\n >\n <StyledComboBoxPrefixAndPlaceholderWrapper>\n {prefix && <StyledComboBoxPrefix>{prefix}</StyledComboBoxPrefix>}\n <StyledComboBoxPlaceholder\n $shouldReduceOpacity={!selectedItem && !internalSelectedItem}\n >\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n $shouldShowBigImage={shouldShowBigImage}\n $shouldShowRoundImage={shouldShowRoundPlaceholderImage}\n />\n )}\n {placeholderIcon && <Icon icons={placeholderIcon} />}\n {typeof inputValue === 'string' ? (\n <StyledComboBoxInput\n disabled={isDisabled}\n value={inputValue}\n onChange={onInputChange}\n onBlur={handleInputBlur}\n onFocus={handleInputFocus}\n placeholder={placeholderText}\n />\n ) : (\n <StyledComboBoxPlaceholderText>\n {placeholderText}\n </StyledComboBoxPlaceholderText>\n )}\n {internalSelectedItem &&\n internalSelectedItem.suffixElement &&\n internalSelectedItem.suffixElement}\n </StyledComboBoxPlaceholder>\n </StyledComboBoxPrefixAndPlaceholderWrapper>\n {shouldShowClearIcon && internalSelectedItem && (\n <StyledComboBoxClearIconWrapper onClick={handleClear}>\n <Icon icons={['fa fa-times']} />\n </StyledComboBoxClearIconWrapper>\n )}\n {!shouldDisableActions && (\n <StyledComboBoxIconWrapper\n $shouldShowBorderLeft={\n shouldShowClearIcon === true && internalSelectedItem !== undefined\n }\n >\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n )}\n </StyledComboBoxHeader>\n {styledComboBoxElementRef.current && (\n <DropdownBodyWrapper\n anchorElement={styledComboBoxElementRef.current}\n bodyWidth={bodyWidth}\n contentHeight={contentHeight}\n onClose={handleClose}\n direction={direction}\n container={container}\n shouldShowDropdown={isAnimating}\n minBodyWidth={bodyWidth ?? bodyMinWidth}\n maxHeight={maxHeight}\n >\n <StyledComboBoxBody\n $shouldUseCurrentItemWidth={shouldUseCurrentItemWidth}\n $maxHeight={maxHeight}\n $minWidth={bodyWidth ?? bodyMinWidth}\n $browser={browser?.name as BrowserName}\n ref={contentRef}\n tabIndex={0}\n >\n {comboBoxGroups}\n </StyledComboBoxBody>\n </DropdownBodyWrapper>\n )}\n </StyledComboBox>\n ),\n [\n minWidth,\n shouldUseFullWidth,\n shouldUseCurrentItemWidth,\n direction,\n handleHeaderClick,\n isAnimating,\n isTouch,\n isDisabled,\n shouldChangeColor,\n shouldShowBigImage,\n prefix,\n selectedItem,\n internalSelectedItem,\n placeholderImageUrl,\n shouldShowRoundPlaceholderImage,\n placeholderIcon,\n inputValue,\n onInputChange,\n handleInputBlur,\n handleInputFocus,\n placeholderText,\n shouldShowClearIcon,\n handleClear,\n shouldDisableActions,\n bodyWidth,\n contentHeight,\n handleClose,\n container,\n bodyMinWidth,\n maxHeight,\n browser?.name,\n comboBoxGroups,\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;AAgBA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAcA,IAAAU,oBAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,SAAA,GAAAX,OAAA;AACA,IAAAY,QAAA,GAAAZ,OAAA;AAAqD,SAAAO,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAf,uBAAA,YAAAA,CAAAW,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG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,QAAA,GAAAC,OAAA,CAAA1M,OAAA,GAEnBiB,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectButton.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_Button","_interopRequireDefault","_SelectButton","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SelectButton","buttonText","isDisabled","list","onSelect","selectedItemIds","shouldAllowMultiSelect","shouldShowButtonTextWithSelection","maxDisplayedItems","additionalText","shouldShowSearch","selectAllText","title","itemList","useMemo","items","forEach","text","id","isSelected","includes","push","name","internalButtonText","length","addedCount","newText","additionalCount","replace","String","handleClick","createDialog","undefined","type","DialogType","SELECT","multiselect","quickfind","selectAllCheckbox","open","then","result","buttonType","
|
|
1
|
+
{"version":3,"file":"SelectButton.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_Button","_interopRequireDefault","_SelectButton","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SelectButton","buttonText","isDisabled","list","onSelect","selectedItemIds","shouldAllowMultiSelect","shouldShowButtonTextWithSelection","maxDisplayedItems","additionalText","shouldShowSearch","selectAllText","title","itemList","useMemo","items","forEach","text","id","isSelected","includes","push","name","internalButtonText","length","addedCount","newText","additionalCount","replace","String","handleClick","createDialog","undefined","type","DialogType","SELECT","multiselect","quickfind","selectAllCheckbox","open","then","result","buttonType","createElement","StyledSelectButton","onClick","isSecondary","shouldShowTextAsRobotoMedium","displayName","_default","exports"],"sources":["../../../../src/components/select-button/SelectButton.tsx"],"sourcesContent":["import { createDialog, DialogType, type DialogSelectListItemType } from 'chayns-api';\nimport React, { useMemo, type FC } from 'react';\nimport type { SelectButtonItem } from '../../types/selectButton';\nimport Button from '../button/Button';\nimport { StyledSelectButton } from './SelectButton.styles';\n\nexport type SelectButtonProps = {\n /**\n * Text used when there are more selected items than maxDisplayedItems. '##count##' will be displayed with the additional count.\n */\n additionalText?: string;\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 * The maximum number of items displayed in the button text.\n */\n maxDisplayedItems?: number;\n /**\n * Function to be executed after an item is selected.\n */\n onSelect?: (ids: (number | string)[]) => void;\n /**\n * If a string is given and `shouldAllowMultiSelect` is true, the dialog displays a checkbox to select all items at once.\n */\n selectAllText?: string;\n /**\n * The id of an item that should be preselected.\n */\n selectedItemIds?: (number | string)[];\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 maxDisplayedItems = 3,\n additionalText = ', ##count## weitere',\n shouldShowSearch,\n selectAllText,\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 - maxDisplayedItems;\n\n list.forEach(({ text, id }) => {\n if (addedCount < maxDisplayedItems && selectedItemIds?.includes(id)) {\n addedCount++;\n newText += newText.length === 0 ? `${text}` : `, ${text}`;\n }\n });\n\n if (additionalCount >= 1) {\n newText += additionalText.replace('##count##', String(additionalCount));\n }\n\n return newText;\n }, [\n additionalText,\n buttonText,\n list,\n maxDisplayedItems,\n selectedItemIds,\n shouldShowButtonTextWithSelection,\n ]);\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 selectAllCheckbox: selectAllText,\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);\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,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAA2D,SAAAI,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,CAAAI,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QA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AAE9B,sBAAsB;MACnC+B,SAAS,EAAE3B,gBAAgB;MAC3B4B,iBAAiB,EAAE3B;IACvB,CAAC,CAAC,CACG4B,IAAI,CAAC,CAAC,CACNC,IAAI,CAAEC,MAAM,IAAK;MACd;MACA;MACA;MACA,IAAIA,MAAM,IAAIA,MAAM,CAACC,UAAU,KAAK,CAAC,IAAI,OAAOtC,QAAQ,KAAK,UAAU,EAAE;QACrE;QACA;QACA;QACAA,QAAQ,CAACqC,MAAM,CAACA,MAAM,CAAC;MAC3B;IACJ,CAAC,CAAC;EACV,CAAC;EAED,oBACIjE,MAAA,CAAAO,OAAA,CAAA4D,aAAA,CAAC/D,aAAA,CAAAgE,kBAAkB,qBACfpE,MAAA,CAAAO,OAAA,CAAA4D,aAAA,CAACjE,OAAA,CAAAK,OAAM;IACH8D,OAAO,EAAEf,WAAY;IACrB5B,UAAU,EAAEA,UAAW;IACvB4C,WAAW;IACXC,4BAA4B,EAAE;EAAM,GAEnCxB,kBACG,CACQ,CAAC;AAE7B,CAAC;AAEDvB,YAAY,CAACgD,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnE,OAAA,GAE3BiB,YAAY","ignoreList":[]}
|
package/lib/cjs/hooks/element.js
CHANGED
|
@@ -7,12 +7,20 @@ exports.useMeasuredClone = exports.useIsMeasuredClone = exports.useElementSize =
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
9
|
const useElementSize = (ref, {
|
|
10
|
-
shouldUseChildElement = false
|
|
10
|
+
shouldUseChildElement = false,
|
|
11
|
+
shouldUseParentElement = false
|
|
11
12
|
} = {}) => {
|
|
12
13
|
const [size, setSize] = (0, _react.useState)();
|
|
13
14
|
(0, _react.useEffect)(() => {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
let target = ref.current;
|
|
16
|
+
if (shouldUseParentElement) {
|
|
17
|
+
var _ref$current;
|
|
18
|
+
target = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentElement;
|
|
19
|
+
}
|
|
20
|
+
if (shouldUseChildElement) {
|
|
21
|
+
var _ref$current2;
|
|
22
|
+
target = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.firstElementChild;
|
|
23
|
+
}
|
|
16
24
|
if (!target) return () => {};
|
|
17
25
|
const updateSize = () => setSize(target.getBoundingClientRect());
|
|
18
26
|
updateSize();
|
|
@@ -25,7 +33,7 @@ const useElementSize = (ref, {
|
|
|
25
33
|
});
|
|
26
34
|
observer.observe(target);
|
|
27
35
|
return () => observer.disconnect();
|
|
28
|
-
}, [ref, shouldUseChildElement]);
|
|
36
|
+
}, [ref, shouldUseChildElement, shouldUseParentElement]);
|
|
29
37
|
return size;
|
|
30
38
|
};
|
|
31
39
|
exports.useElementSize = useElementSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":["_react","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useElementSize","ref","shouldUseChildElement","size","setSize","useState","useEffect","_ref$current","
|
|
1
|
+
{"version":3,"file":"element.js","names":["_react","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useElementSize","ref","shouldUseChildElement","shouldUseParentElement","size","setSize","useState","useEffect","target","current","_ref$current","parentElement","_ref$current2","firstElementChild","updateSize","getBoundingClientRect","observer","ResizeObserver","entries","forEach","entry","contentRect","observe","disconnect","exports","getClonedElement","content","preventEvents","onClick","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","props","isValidElement","cloneElement","createElement","useMeasuredClone","useRef","width","height","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","zIndex","visibility","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute"],"sources":["../../../src/hooks/element.tsx"],"sourcesContent":["import React, {\n cloneElement,\n HTMLAttributes,\n isValidElement,\n MutableRefObject,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n shouldUseParentElement?: boolean;\n}\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false, shouldUseParentElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n useEffect(() => {\n let target = ref.current as HTMLElement | null;\n\n if (shouldUseParentElement) {\n target = ref.current?.parentElement as HTMLElement | null;\n }\n\n if (shouldUseChildElement) {\n target = ref.current?.firstElementChild as HTMLElement | null;\n }\n\n if (!target) return () => {};\n\n const updateSize = () => setSize(target.getBoundingClientRect());\n\n updateSize();\n\n const observer = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n if (entry.target === target) {\n setSize(entry.contentRect);\n }\n });\n });\n\n observer.observe(target);\n\n return () => observer.disconnect();\n }, [ref, shouldUseChildElement, shouldUseParentElement]);\n\n return size;\n};\n\nconst getClonedElement = (content: ReactNode) => {\n const preventEvents: Partial<HTMLAttributes<any>> = {\n onClick: (e) => e.stopPropagation(),\n onMouseDown: (e) => e.stopPropagation(),\n onMouseUp: (e) => e.stopPropagation(),\n onKeyDown: (e) => e.stopPropagation(),\n onKeyUp: (e) => e.stopPropagation(),\n onFocus: (e) => e.stopPropagation(),\n onBlur: (e) => e.stopPropagation(),\n };\n\n const props = {\n ...preventEvents,\n 'data-measured-clone': true,\n };\n\n if (isValidElement(content)) {\n return cloneElement(content as unknown as ReactElement, props);\n }\n\n if (typeof content === 'string') {\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <span {...props}>{content}</span>;\n }\n\n return content;\n};\n\ninterface UseMeasuredCloneOptions {\n content: ReactNode;\n}\n\nexport const useMeasuredClone = ({ content }: UseMeasuredCloneOptions) => {\n const ref = useRef<HTMLDivElement>(null);\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const clonedElement = getClonedElement(content);\n\n useEffect(() => {\n const measure = () => {\n if (!ref.current) return;\n const { offsetWidth: width, offsetHeight: height } = ref.current;\n setSize({ width: width + 10, height });\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n\n if (ref.current) observer.observe(ref.current);\n\n return () => observer.disconnect();\n }, []);\n\n const measuredElement = (\n <div\n data-measured-clone=\"true\"\n ref={ref}\n style={{\n position: 'fixed',\n opacity: 0,\n pointerEvents: 'none',\n zIndex: -1,\n height: 'auto',\n width: 'auto',\n visibility: 'hidden',\n }}\n >\n {clonedElement}\n </div>\n );\n\n return {\n measuredElement,\n width: size.width,\n height: size.height,\n };\n};\n\nexport const useIsMeasuredClone = <T extends HTMLElement>() => {\n const ref = useRef<T | null>(null);\n\n const [isClone, setIsClone] = useState(false);\n\n useEffect(() => {\n if (!ref.current) return;\n\n let el: HTMLElement | null = ref.current;\n\n while (el) {\n if (el.hasAttribute('data-measured-clone')) {\n setIsClone(true);\n\n return;\n }\n\n el = el.parentElement;\n }\n\n setIsClone(false);\n }, []);\n\n return [isClone, ref] as const;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAUe,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAA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A8C,UAAU,CAAC,KAAK,CAAC;EACrB,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACD,OAAO,EAAEvD,GAAG,CAAC;AACzB,CAAC;AAACuB,OAAA,CAAA+B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectButton.js","names":[],"sources":["../../../src/types/selectButton.ts"],"sourcesContent":["export interface SelectButtonItem {\n text: string;\n id: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"selectButton.js","names":[],"sources":["../../../src/types/selectButton.ts"],"sourcesContent":["export interface SelectButtonItem {\n text: string;\n id: number | string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ import ComboBoxItem from './combobox-item/ComboBoxItem';
|
|
|
8
8
|
import { StyledComboBox, StyledComboBoxBody, StyledComboBoxClearIconWrapper, StyledComboBoxHeader, StyledComboBoxIconWrapper, StyledComboBoxInput, StyledComboBoxPlaceholder, StyledComboBoxPlaceholderImage, StyledComboBoxPlaceholderText, StyledComboBoxPrefix, StyledComboBoxPrefixAndPlaceholderWrapper, StyledComboBoxTopic } from './ComboBox.styles';
|
|
9
9
|
import DropdownBodyWrapper from '../dropdown-body-wrapper/DropdownBodyWrapper';
|
|
10
10
|
import { DropdownDirection } from '../../types/dropdown';
|
|
11
|
+
import { useElementSize } from '../../hooks/element';
|
|
11
12
|
const ComboBox = ({
|
|
12
13
|
bodyWidth,
|
|
13
14
|
direction = DropdownDirection.RIGHT,
|
|
@@ -38,6 +39,9 @@ const ComboBox = ({
|
|
|
38
39
|
const isInputFocused = useRef(false);
|
|
39
40
|
const styledComboBoxElementRef = useRef(null);
|
|
40
41
|
const contentRef = useRef(null);
|
|
42
|
+
const parentSize = useElementSize(styledComboBoxElementRef, {
|
|
43
|
+
shouldUseParentElement: true
|
|
44
|
+
});
|
|
41
45
|
const functions = useFunctions();
|
|
42
46
|
const values = useValues();
|
|
43
47
|
const isTouch = getIsTouch();
|
|
@@ -45,6 +49,11 @@ const ComboBox = ({
|
|
|
45
49
|
browser
|
|
46
50
|
} = useDevice();
|
|
47
51
|
const areaProvider = useContext(AreaContext);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (shouldUseFullWidth && parentSize) {
|
|
54
|
+
setMinWidth(parentSize.width);
|
|
55
|
+
}
|
|
56
|
+
}, [parentSize, shouldUseFullWidth]);
|
|
48
57
|
const shouldChangeColor = useMemo(() => areaProvider.shouldChangeColor ?? false, [areaProvider.shouldChangeColor]);
|
|
49
58
|
const shouldDisableActions = useMemo(() => {
|
|
50
59
|
if (!selectedItem) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.js","names":["useDevice","useFunctions","useValues","React","Fragment","useCallback","useContext","useEffect","useMemo","useRef","useState","calculateContentWidth","getIsTouch","AreaContext","Icon","ComboBoxItem","StyledComboBox","StyledComboBoxBody","StyledComboBoxClearIconWrapper","StyledComboBoxHeader","StyledComboBoxIconWrapper","StyledComboBoxInput","StyledComboBoxPlaceholder","StyledComboBoxPlaceholderImage","StyledComboBoxPlaceholderText","StyledComboBoxPrefix","StyledComboBoxPrefixAndPlaceholderWrapper","StyledComboBoxTopic","DropdownBodyWrapper","DropdownDirection","ComboBox","bodyWidth","direction","RIGHT","isDisabled","lists","maxHeight","onSelect","placeholder","prefix","container","selectedItem","shouldShowBigImage","shouldShowClearIcon","shouldShowRoundImage","onInputFocus","shouldUseFullWidth","onInputChange","shouldUseCurrentItemWidth","onInputBlur","inputValue","shouldDropDownUseMaxItemWidth","internalSelectedItem","setInternalSelectedItem","isAnimating","setIsAnimating","minWidth","setMinWidth","undefined","bodyMinWidth","setBodyMinWidth","focusedIndex","setFocusedIndex","isInputFocused","styledComboBoxElementRef","contentRef","functions","values","isTouch","browser","areaProvider","shouldChangeColor","shouldDisableActions","combinedLists","flatMap","list","length","some","item","value","contentHeight","flatItems","result","handleInputFocus","event","current","handleInputBlur","handleOpen","handleClose","handleSetSelectedItem","itemToSelect","onSelectResult","Promise","then","shouldPreventSelection","handleClear","preventDefault","stopPropagation","handleKeyDown","e","key","children","stepDirection","newIndex","attempts","newElement","shouldSkip","id","startsWith","endsWith","prevElement","tabIndex","focusedElement","focus","element","newSelectedItem","find","String","replace","document","addEventListener","removeEventListener","allItems","baseWidth","text","hasImage","imageUrl","hasIcon","icons","parentWidth","parentElement","getBoundingClientRect","width","paddingWidth","imageWidth","iconWidth","prefixWidth","prefixTextWidth","Math","max","calculatedWidth","tmpMinWidth","tmpBodyMinWidth","itemWidth","placeholderImageUrl","placeholderIcon","placeholderText","shouldShowRoundPlaceholderImage","selectedItemList","handleHeaderClick","comboBoxGroups","map","createElement","groupName","isSelected","ref","$minWidth","$shouldUseFullWidth","$shouldUseCurrentItemWidth","$direction","onClick","$isOpen","$isTouch","$isDisabled","$shouldChangeColor","$shouldShowBigImage","$shouldReduceOpacity","src","$shouldShowRoundImage","disabled","onChange","onBlur","onFocus","suffixElement","$shouldShowBorderLeft","anchorElement","onClose","shouldShowDropdown","minBodyWidth","$maxHeight","$browser","name","displayName"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { useDevice, useFunctions, useValues } from 'chayns-api';\nimport React, {\n ChangeEventHandler,\n type CSSProperties,\n FC,\n FocusEventHandler,\n Fragment,\n ReactHTML,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { BrowserName } from '../../types/chayns';\nimport { calculateContentWidth } from '../../utils/calculate';\nimport { getIsTouch } from '../../utils/environment';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxBody,\n StyledComboBoxClearIconWrapper,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxInput,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledComboBoxPlaceholderText,\n StyledComboBoxPrefix,\n StyledComboBoxPrefixAndPlaceholderWrapper,\n StyledComboBoxTopic,\n} from './ComboBox.styles';\nimport DropdownBodyWrapper from '../dropdown-body-wrapper/DropdownBodyWrapper';\nimport { DropdownDirection } from '../../types/dropdown';\n\nexport interface IComboBoxItems {\n groupName?: string;\n list: Array<IComboBoxItem>;\n shouldShowRoundImage?: boolean;\n}\n\nexport interface ComboBoxTextStyles {\n tagName?: keyof ReactHTML;\n styles?: CSSProperties;\n}\n\nexport interface IComboBoxItem {\n icons?: string[];\n imageBackground?: CSSProperties['background'];\n imageUrl?: string;\n isDisabled?: boolean;\n rightElement?: ReactNode;\n subtext?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n textStyles?: ComboBoxTextStyles;\n}\n\nexport type ComboBoxProps = {\n /**\n * The width of the body.\n */\n bodyWidth?: number;\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?: DropdownDirection;\n /**\n * The value of the optional input.\n */\n inputValue?: string;\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?: number;\n /**\n * Function to be executed when the value of the optional input is changed.\n */\n onInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the optional input lost its focus.\n */\n onInputBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the optional input gets its focus.\n */\n onInputFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that should be executed when an item is selected. If the function returns false, the item will not be selected.\n */\n onSelect?: (comboboxItem?: IComboBoxItem) => Promise<boolean> | boolean | void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * A prefix that should be displayed before the placeholder.\n */\n prefix?: 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 bigger shape. This prop will automatically be set to true if the subtext of an item is given.\n */\n shouldShowBigImage?: boolean;\n /**\n * If true, a clear icon is displayed at the end of the combo box if an item is selected.\n */\n shouldShowClearIcon?: boolean;\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 current item.\n */\n shouldUseCurrentItemWidth?: 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 * If true, the dropdown will use the maximum width of the items.\n */\n shouldDropDownUseMaxItemWidth?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n bodyWidth,\n direction = DropdownDirection.RIGHT,\n isDisabled = false,\n lists,\n maxHeight = 280,\n onSelect,\n placeholder,\n prefix,\n container,\n selectedItem,\n shouldShowBigImage,\n shouldShowClearIcon,\n shouldShowRoundImage,\n onInputFocus,\n shouldUseFullWidth = false,\n onInputChange,\n shouldUseCurrentItemWidth = false,\n onInputBlur,\n inputValue,\n shouldDropDownUseMaxItemWidth = false,\n}) => {\n const [internalSelectedItem, setInternalSelectedItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState<number | undefined>(undefined);\n const [bodyMinWidth, setBodyMinWidth] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n const isInputFocused = useRef(false);\n\n const styledComboBoxElementRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const functions = useFunctions();\n const values = useValues();\n\n const isTouch = getIsTouch();\n\n const { browser } = useDevice();\n\n const areaProvider = useContext(AreaContext);\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const shouldDisableActions = useMemo(() => {\n if (!selectedItem) {\n return false;\n }\n\n const combinedLists = lists.flatMap((list) => list.list);\n\n return (\n combinedLists.length === 1 &&\n combinedLists.some((item) => item.value === selectedItem.value)\n );\n }, [lists, selectedItem]);\n\n const contentHeight = useMemo(() => {\n const flatItems = lists.flatMap((list) => list.list);\n\n let result = flatItems.length * 36;\n\n if (lists.length > 1) {\n result += lists.length * 36;\n }\n\n if (maxHeight < result) {\n result = maxHeight;\n }\n\n return result;\n }, [lists, maxHeight]);\n\n const handleInputFocus: FocusEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n isInputFocused.current = true;\n onInputFocus?.(event);\n },\n [onInputFocus],\n );\n\n const handleInputBlur: FocusEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n isInputFocused.current = false;\n onInputBlur?.(event);\n },\n [onInputBlur],\n );\n\n const handleOpen = useCallback(() => {\n setIsAnimating(true);\n }, []);\n\n const handleClose = useCallback(() => {\n setIsAnimating(false);\n }, []);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect?: IComboBoxItem) => {\n if (typeof onSelect === 'function') {\n const onSelectResult = onSelect(itemToSelect);\n\n if (onSelectResult === false) {\n return;\n }\n\n if (onSelectResult instanceof Promise) {\n void onSelectResult.then((shouldPreventSelection) => {\n if (shouldPreventSelection) return;\n\n setInternalSelectedItem(itemToSelect);\n setIsAnimating(false);\n });\n\n return;\n }\n }\n\n setInternalSelectedItem(itemToSelect);\n setIsAnimating(false);\n },\n [onSelect],\n );\n\n const handleClear = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n event.preventDefault();\n event.stopPropagation();\n\n handleSetSelectedItem(undefined);\n },\n [handleSetSelectedItem],\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (!isAnimating) return;\n\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n\n const children = contentRef.current?.children;\n\n if (!children || children.length === 0) return;\n\n const stepDirection = e.key === 'ArrowUp' ? -1 : 1;\n\n let newIndex = focusedIndex ?? -1;\n\n let attempts = 0;\n\n do {\n newIndex = (newIndex + stepDirection + children.length) % children.length;\n\n const newElement = children[newIndex] as HTMLDivElement;\n\n let shouldSkip = false;\n\n if (\n newElement.id.startsWith('combobox-group--') ||\n newElement.id.endsWith('--disabled-item')\n ) {\n shouldSkip = true;\n }\n\n if (!shouldSkip) break;\n\n attempts++;\n } while (attempts < children.length);\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const focusedElement = children[newIndex] as HTMLDivElement;\n\n focusedElement.tabIndex = 0;\n\n focusedElement.focus();\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) return;\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\n return !!newSelectedItem;\n });\n\n if (newSelectedItem) {\n handleSetSelectedItem(newSelectedItem);\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => document.removeEventListener('keydown', handleKeyDown);\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 let baseWidth = calculateContentWidth(\n [\n ...allItems,\n { text: placeholder, value: 'placeholder' },\n ...(selectedItem ? [selectedItem] : []),\n ],\n functions,\n values,\n );\n\n if (shouldDropDownUseMaxItemWidth) {\n baseWidth += 20 + 2; // 20px padding left and right and 2px border\n setBodyMinWidth(baseWidth);\n setMinWidth(baseWidth);\n return;\n }\n\n const hasImage = [selectedItem, ...allItems].some((item) => item?.imageUrl);\n const hasIcon = [selectedItem, ...allItems].some((item) => item?.icons);\n\n const parentWidth =\n styledComboBoxElementRef.current?.parentElement?.getBoundingClientRect().width ?? 0;\n\n const paddingWidth = 20 + 2 + 40 + 40; // padding + border + arrow icon + optional clear icon\n const imageWidth = hasImage ? 32 : 0; // image width + gap if images present\n const iconWidth = hasIcon ? 40 : 0; // icon width + gap if icons present\n\n let prefixWidth = 0;\n\n if (prefix) {\n const prefixTextWidth =\n calculateContentWidth([{ text: prefix, value: 'prefix' }], functions, values) + 5;\n\n prefixWidth = Math.max(prefixTextWidth, 32);\n }\n\n const calculatedWidth = baseWidth + paddingWidth + imageWidth + iconWidth + prefixWidth;\n\n let tmpMinWidth = calculatedWidth;\n let tmpBodyMinWidth = calculatedWidth;\n\n // Full width settings\n if (shouldUseFullWidth) {\n tmpMinWidth = parentWidth;\n\n tmpBodyMinWidth =\n parentWidth < calculatedWidth - 20 ? calculatedWidth - 20 : parentWidth;\n }\n // Current item width settings\n else if (shouldUseCurrentItemWidth && internalSelectedItem) {\n const itemWidth =\n calculateContentWidth([internalSelectedItem], functions, values) +\n paddingWidth +\n imageWidth +\n iconWidth +\n prefixWidth;\n\n tmpMinWidth = itemWidth;\n\n tmpBodyMinWidth = itemWidth < calculatedWidth - 20 ? calculatedWidth - 20 : itemWidth;\n }\n\n if (tmpMinWidth > parentWidth) {\n tmpMinWidth = parentWidth;\n }\n\n if (tmpBodyMinWidth > parentWidth) {\n tmpBodyMinWidth = parentWidth;\n }\n\n setMinWidth(tmpMinWidth);\n setBodyMinWidth(shouldUseCurrentItemWidth ? tmpMinWidth : tmpBodyMinWidth);\n }, [\n lists,\n placeholder,\n shouldUseFullWidth,\n shouldUseCurrentItemWidth,\n internalSelectedItem,\n prefix,\n selectedItem,\n functions,\n values,\n shouldDropDownUseMaxItemWidth,\n ]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n setIsAnimating(false);\n setInternalSelectedItem(selectedItem);\n }, [selectedItem]);\n\n const placeholderImageUrl = useMemo(() => {\n if (selectedItem) {\n return selectedItem.imageUrl;\n }\n\n if (internalSelectedItem) {\n return internalSelectedItem.imageUrl;\n }\n\n return undefined;\n }, [internalSelectedItem, selectedItem]);\n\n const placeholderIcon = useMemo(() => {\n if (selectedItem) {\n return selectedItem.icons;\n }\n\n if (internalSelectedItem) {\n return internalSelectedItem.icons;\n }\n\n return undefined;\n }, [internalSelectedItem, 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 (internalSelectedItem) {\n text = internalSelectedItem.text;\n }\n\n return text;\n }, [internalSelectedItem, placeholder, selectedItem]);\n\n const shouldShowRoundPlaceholderImage = useMemo(() => {\n const selectedItemList = lists.find((list) =>\n list.list.some(\n ({ value }) => value === (selectedItem?.value ?? internalSelectedItem?.value),\n ),\n );\n\n return selectedItemList?.shouldShowRoundImage ?? shouldShowRoundImage;\n }, [internalSelectedItem?.value, lists, selectedItem?.value, shouldShowRoundImage]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = useCallback(() => {\n if (!isDisabled && !isInputFocused.current) {\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((list) => (\n <Fragment key={list.groupName ?? 'default-group'}>\n {list.groupName && lists.length > 1 && (\n <StyledComboBoxTopic id={`combobox-group--${list.groupName}`}>\n {list.groupName}\n </StyledComboBoxTopic>\n )}\n {list.list.map((item) => (\n <ComboBoxItem\n item={item}\n isSelected={selectedItem ? item.value === selectedItem.value : false}\n onSelect={handleSetSelectedItem}\n shouldShowBigImage={shouldShowBigImage}\n shouldShowRoundImage={list.shouldShowRoundImage ?? shouldShowRoundImage}\n />\n ))}\n </Fragment>\n )),\n [handleSetSelectedItem, lists, selectedItem, shouldShowBigImage, shouldShowRoundImage],\n );\n\n return useMemo(\n () => (\n <StyledComboBox\n ref={styledComboBoxElementRef}\n $minWidth={minWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n $shouldUseCurrentItemWidth={shouldUseCurrentItemWidth}\n >\n <StyledComboBoxHeader\n $direction={direction}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isTouch={isTouch}\n $isDisabled={isDisabled}\n $shouldChangeColor={shouldChangeColor}\n $shouldShowBigImage={shouldShowBigImage}\n >\n <StyledComboBoxPrefixAndPlaceholderWrapper>\n {prefix && <StyledComboBoxPrefix>{prefix}</StyledComboBoxPrefix>}\n <StyledComboBoxPlaceholder\n $shouldReduceOpacity={!selectedItem && !internalSelectedItem}\n >\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n $shouldShowBigImage={shouldShowBigImage}\n $shouldShowRoundImage={shouldShowRoundPlaceholderImage}\n />\n )}\n {placeholderIcon && <Icon icons={placeholderIcon} />}\n {typeof inputValue === 'string' ? (\n <StyledComboBoxInput\n disabled={isDisabled}\n value={inputValue}\n onChange={onInputChange}\n onBlur={handleInputBlur}\n onFocus={handleInputFocus}\n placeholder={placeholderText}\n />\n ) : (\n <StyledComboBoxPlaceholderText>\n {placeholderText}\n </StyledComboBoxPlaceholderText>\n )}\n {internalSelectedItem &&\n internalSelectedItem.suffixElement &&\n internalSelectedItem.suffixElement}\n </StyledComboBoxPlaceholder>\n </StyledComboBoxPrefixAndPlaceholderWrapper>\n {shouldShowClearIcon && internalSelectedItem && (\n <StyledComboBoxClearIconWrapper onClick={handleClear}>\n <Icon icons={['fa fa-times']} />\n </StyledComboBoxClearIconWrapper>\n )}\n {!shouldDisableActions && (\n <StyledComboBoxIconWrapper\n $shouldShowBorderLeft={\n shouldShowClearIcon === true && internalSelectedItem !== undefined\n }\n >\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n )}\n </StyledComboBoxHeader>\n {styledComboBoxElementRef.current && (\n <DropdownBodyWrapper\n anchorElement={styledComboBoxElementRef.current}\n bodyWidth={bodyWidth}\n contentHeight={contentHeight}\n onClose={handleClose}\n direction={direction}\n container={container}\n shouldShowDropdown={isAnimating}\n minBodyWidth={bodyWidth ?? bodyMinWidth}\n maxHeight={maxHeight}\n >\n <StyledComboBoxBody\n $shouldUseCurrentItemWidth={shouldUseCurrentItemWidth}\n $maxHeight={maxHeight}\n $minWidth={bodyWidth ?? bodyMinWidth}\n $browser={browser?.name as BrowserName}\n ref={contentRef}\n tabIndex={0}\n >\n {comboBoxGroups}\n </StyledComboBoxBody>\n </DropdownBodyWrapper>\n )}\n </StyledComboBox>\n ),\n [\n minWidth,\n shouldUseFullWidth,\n shouldUseCurrentItemWidth,\n direction,\n handleHeaderClick,\n isAnimating,\n isTouch,\n isDisabled,\n shouldChangeColor,\n shouldShowBigImage,\n prefix,\n selectedItem,\n internalSelectedItem,\n placeholderImageUrl,\n shouldShowRoundPlaceholderImage,\n placeholderIcon,\n inputValue,\n onInputChange,\n handleInputBlur,\n handleInputFocus,\n placeholderText,\n shouldShowClearIcon,\n handleClear,\n shouldDisableActions,\n bodyWidth,\n contentHeight,\n handleClose,\n container,\n bodyMinWidth,\n maxHeight,\n browser?.name,\n comboBoxGroups,\n ],\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,YAAY,EAAEC,SAAS,QAAQ,YAAY;AAC/D,OAAOC,KAAK,IAKRC,QAAQ,EAGRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AAEd,SAASC,qBAAqB,QAAQ,uBAAuB;AAC7D,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,WAAW,QAAQ,sCAAsC;AAClE,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SACIC,cAAc,EACdC,kBAAkB,EAClBC,8BAA8B,EAC9BC,oBAAoB,EACpBC,yBAAyB,EACzBC,mBAAmB,EACnBC,yBAAyB,EACzBC,8BAA8B,EAC9BC,6BAA6B,EAC7BC,oBAAoB,EACpBC,yCAAyC,EACzCC,mBAAmB,QA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jB/F,WAAW,EACXc,OAAO,EACPlC,UAAU,EACVqC,iBAAiB,EACjB7B,kBAAkB,EAClBH,MAAM,EACNE,YAAY,EACZW,oBAAoB,EACpB4F,mBAAmB,EACnBG,+BAA+B,EAC/BF,eAAe,EACf/F,UAAU,EACVH,aAAa,EACbuC,eAAe,EACfH,gBAAgB,EAChB+D,eAAe,EACfvG,mBAAmB,EACnBoD,WAAW,EACXvB,oBAAoB,EACpBzC,SAAS,EACTiD,aAAa,EACbQ,WAAW,EACXhD,SAAS,EACTmB,YAAY,EACZvB,SAAS,EACTiC,OAAO,EAAEgH,IAAI,EACb/B,cAAc,CAEtB,CAAC;AACL,CAAC;AAEDxH,QAAQ,CAACwJ,WAAW,GAAG,UAAU;AAEjC,eAAexJ,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ComboBox.js","names":["useDevice","useFunctions","useValues","React","Fragment","useCallback","useContext","useEffect","useMemo","useRef","useState","calculateContentWidth","getIsTouch","AreaContext","Icon","ComboBoxItem","StyledComboBox","StyledComboBoxBody","StyledComboBoxClearIconWrapper","StyledComboBoxHeader","StyledComboBoxIconWrapper","StyledComboBoxInput","StyledComboBoxPlaceholder","StyledComboBoxPlaceholderImage","StyledComboBoxPlaceholderText","StyledComboBoxPrefix","StyledComboBoxPrefixAndPlaceholderWrapper","StyledComboBoxTopic","DropdownBodyWrapper","DropdownDirection","useElementSize","ComboBox","bodyWidth","direction","RIGHT","isDisabled","lists","maxHeight","onSelect","placeholder","prefix","container","selectedItem","shouldShowBigImage","shouldShowClearIcon","shouldShowRoundImage","onInputFocus","shouldUseFullWidth","onInputChange","shouldUseCurrentItemWidth","onInputBlur","inputValue","shouldDropDownUseMaxItemWidth","internalSelectedItem","setInternalSelectedItem","isAnimating","setIsAnimating","minWidth","setMinWidth","undefined","bodyMinWidth","setBodyMinWidth","focusedIndex","setFocusedIndex","isInputFocused","styledComboBoxElementRef","contentRef","parentSize","shouldUseParentElement","functions","values","isTouch","browser","areaProvider","width","shouldChangeColor","shouldDisableActions","combinedLists","flatMap","list","length","some","item","value","contentHeight","flatItems","result","handleInputFocus","event","current","handleInputBlur","handleOpen","handleClose","handleSetSelectedItem","itemToSelect","onSelectResult","Promise","then","shouldPreventSelection","handleClear","preventDefault","stopPropagation","handleKeyDown","e","key","children","stepDirection","newIndex","attempts","newElement","shouldSkip","id","startsWith","endsWith","prevElement","tabIndex","focusedElement","focus","element","newSelectedItem","find","String","replace","document","addEventListener","removeEventListener","allItems","baseWidth","text","hasImage","imageUrl","hasIcon","icons","parentWidth","parentElement","getBoundingClientRect","paddingWidth","imageWidth","iconWidth","prefixWidth","prefixTextWidth","Math","max","calculatedWidth","tmpMinWidth","tmpBodyMinWidth","itemWidth","placeholderImageUrl","placeholderIcon","placeholderText","shouldShowRoundPlaceholderImage","selectedItemList","handleHeaderClick","comboBoxGroups","map","createElement","groupName","isSelected","ref","$minWidth","$shouldUseFullWidth","$shouldUseCurrentItemWidth","$direction","onClick","$isOpen","$isTouch","$isDisabled","$shouldChangeColor","$shouldShowBigImage","$shouldReduceOpacity","src","$shouldShowRoundImage","disabled","onChange","onBlur","onFocus","suffixElement","$shouldShowBorderLeft","anchorElement","onClose","shouldShowDropdown","minBodyWidth","$maxHeight","$browser","name","displayName"],"sources":["../../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import { useDevice, useFunctions, useValues } from 'chayns-api';\nimport React, {\n ChangeEventHandler,\n type CSSProperties,\n FC,\n FocusEventHandler,\n Fragment,\n ReactHTML,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { BrowserName } from '../../types/chayns';\nimport { calculateContentWidth } from '../../utils/calculate';\nimport { getIsTouch } from '../../utils/environment';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxBody,\n StyledComboBoxClearIconWrapper,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxInput,\n StyledComboBoxPlaceholder,\n StyledComboBoxPlaceholderImage,\n StyledComboBoxPlaceholderText,\n StyledComboBoxPrefix,\n StyledComboBoxPrefixAndPlaceholderWrapper,\n StyledComboBoxTopic,\n} from './ComboBox.styles';\nimport DropdownBodyWrapper from '../dropdown-body-wrapper/DropdownBodyWrapper';\nimport { DropdownDirection } from '../../types/dropdown';\nimport { useElementSize } from '../../hooks/element';\n\nexport interface IComboBoxItems {\n groupName?: string;\n list: Array<IComboBoxItem>;\n shouldShowRoundImage?: boolean;\n}\n\nexport interface ComboBoxTextStyles {\n tagName?: keyof ReactHTML;\n styles?: CSSProperties;\n}\n\nexport interface IComboBoxItem {\n icons?: string[];\n imageBackground?: CSSProperties['background'];\n imageUrl?: string;\n isDisabled?: boolean;\n rightElement?: ReactNode;\n subtext?: string;\n suffixElement?: ReactNode;\n text: string;\n value: string | number;\n textStyles?: ComboBoxTextStyles;\n}\n\nexport type ComboBoxProps = {\n /**\n * The width of the body.\n */\n bodyWidth?: number;\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?: DropdownDirection;\n /**\n * The value of the optional input.\n */\n inputValue?: string;\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?: number;\n /**\n * Function to be executed when the value of the optional input is changed.\n */\n onInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the optional input lost its focus.\n */\n onInputBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the optional input gets its focus.\n */\n onInputFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that should be executed when an item is selected. If the function returns false, the item will not be selected.\n */\n onSelect?: (comboboxItem?: IComboBoxItem) => Promise<boolean> | boolean | void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * A prefix that should be displayed before the placeholder.\n */\n prefix?: 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 bigger shape. This prop will automatically be set to true if the subtext of an item is given.\n */\n shouldShowBigImage?: boolean;\n /**\n * If true, a clear icon is displayed at the end of the combo box if an item is selected.\n */\n shouldShowClearIcon?: boolean;\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 current item.\n */\n shouldUseCurrentItemWidth?: 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 * If true, the dropdown will use the maximum width of the items.\n */\n shouldDropDownUseMaxItemWidth?: boolean;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({\n bodyWidth,\n direction = DropdownDirection.RIGHT,\n isDisabled = false,\n lists,\n maxHeight = 280,\n onSelect,\n placeholder,\n prefix,\n container,\n selectedItem,\n shouldShowBigImage,\n shouldShowClearIcon,\n shouldShowRoundImage,\n onInputFocus,\n shouldUseFullWidth = false,\n onInputChange,\n shouldUseCurrentItemWidth = false,\n onInputBlur,\n inputValue,\n shouldDropDownUseMaxItemWidth = false,\n}) => {\n const [internalSelectedItem, setInternalSelectedItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState<number | undefined>(undefined);\n const [bodyMinWidth, setBodyMinWidth] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n const isInputFocused = useRef(false);\n\n const styledComboBoxElementRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const parentSize = useElementSize(styledComboBoxElementRef, { shouldUseParentElement: true });\n\n const functions = useFunctions();\n const values = useValues();\n\n const isTouch = getIsTouch();\n\n const { browser } = useDevice();\n\n const areaProvider = useContext(AreaContext);\n\n useEffect(() => {\n if (shouldUseFullWidth && parentSize) {\n setMinWidth(parentSize.width);\n }\n }, [parentSize, shouldUseFullWidth]);\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const shouldDisableActions = useMemo(() => {\n if (!selectedItem) {\n return false;\n }\n\n const combinedLists = lists.flatMap((list) => list.list);\n\n return (\n combinedLists.length === 1 &&\n combinedLists.some((item) => item.value === selectedItem.value)\n );\n }, [lists, selectedItem]);\n\n const contentHeight = useMemo(() => {\n const flatItems = lists.flatMap((list) => list.list);\n\n let result = flatItems.length * 36;\n\n if (lists.length > 1) {\n result += lists.length * 36;\n }\n\n if (maxHeight < result) {\n result = maxHeight;\n }\n\n return result;\n }, [lists, maxHeight]);\n\n const handleInputFocus: FocusEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n isInputFocused.current = true;\n onInputFocus?.(event);\n },\n [onInputFocus],\n );\n\n const handleInputBlur: FocusEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n isInputFocused.current = false;\n onInputBlur?.(event);\n },\n [onInputBlur],\n );\n\n const handleOpen = useCallback(() => {\n setIsAnimating(true);\n }, []);\n\n const handleClose = useCallback(() => {\n setIsAnimating(false);\n }, []);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect?: IComboBoxItem) => {\n if (typeof onSelect === 'function') {\n const onSelectResult = onSelect(itemToSelect);\n\n if (onSelectResult === false) {\n return;\n }\n\n if (onSelectResult instanceof Promise) {\n void onSelectResult.then((shouldPreventSelection) => {\n if (shouldPreventSelection) return;\n\n setInternalSelectedItem(itemToSelect);\n setIsAnimating(false);\n });\n\n return;\n }\n }\n\n setInternalSelectedItem(itemToSelect);\n setIsAnimating(false);\n },\n [onSelect],\n );\n\n const handleClear = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n event.preventDefault();\n event.stopPropagation();\n\n handleSetSelectedItem(undefined);\n },\n [handleSetSelectedItem],\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (!isAnimating) return;\n\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n\n const children = contentRef.current?.children;\n\n if (!children || children.length === 0) return;\n\n const stepDirection = e.key === 'ArrowUp' ? -1 : 1;\n\n let newIndex = focusedIndex ?? -1;\n\n let attempts = 0;\n\n do {\n newIndex = (newIndex + stepDirection + children.length) % children.length;\n\n const newElement = children[newIndex] as HTMLDivElement;\n\n let shouldSkip = false;\n\n if (\n newElement.id.startsWith('combobox-group--') ||\n newElement.id.endsWith('--disabled-item')\n ) {\n shouldSkip = true;\n }\n\n if (!shouldSkip) break;\n\n attempts++;\n } while (attempts < children.length);\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const focusedElement = children[newIndex] as HTMLDivElement;\n\n focusedElement.tabIndex = 0;\n\n focusedElement.focus();\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) return;\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\n return !!newSelectedItem;\n });\n\n if (newSelectedItem) {\n handleSetSelectedItem(newSelectedItem);\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => document.removeEventListener('keydown', handleKeyDown);\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 let baseWidth = calculateContentWidth(\n [\n ...allItems,\n { text: placeholder, value: 'placeholder' },\n ...(selectedItem ? [selectedItem] : []),\n ],\n functions,\n values,\n );\n\n if (shouldDropDownUseMaxItemWidth) {\n baseWidth += 20 + 2; // 20px padding left and right and 2px border\n setBodyMinWidth(baseWidth);\n setMinWidth(baseWidth);\n return;\n }\n\n const hasImage = [selectedItem, ...allItems].some((item) => item?.imageUrl);\n const hasIcon = [selectedItem, ...allItems].some((item) => item?.icons);\n\n const parentWidth =\n styledComboBoxElementRef.current?.parentElement?.getBoundingClientRect().width ?? 0;\n\n const paddingWidth = 20 + 2 + 40 + 40; // padding + border + arrow icon + optional clear icon\n const imageWidth = hasImage ? 32 : 0; // image width + gap if images present\n const iconWidth = hasIcon ? 40 : 0; // icon width + gap if icons present\n\n let prefixWidth = 0;\n\n if (prefix) {\n const prefixTextWidth =\n calculateContentWidth([{ text: prefix, value: 'prefix' }], functions, values) + 5;\n\n prefixWidth = Math.max(prefixTextWidth, 32);\n }\n\n const calculatedWidth = baseWidth + paddingWidth + imageWidth + iconWidth + prefixWidth;\n\n let tmpMinWidth = calculatedWidth;\n let tmpBodyMinWidth = calculatedWidth;\n\n // Full width settings\n if (shouldUseFullWidth) {\n tmpMinWidth = parentWidth;\n\n tmpBodyMinWidth =\n parentWidth < calculatedWidth - 20 ? calculatedWidth - 20 : parentWidth;\n }\n // Current item width settings\n else if (shouldUseCurrentItemWidth && internalSelectedItem) {\n const itemWidth =\n calculateContentWidth([internalSelectedItem], functions, values) +\n paddingWidth +\n imageWidth +\n iconWidth +\n prefixWidth;\n\n tmpMinWidth = itemWidth;\n\n tmpBodyMinWidth = itemWidth < calculatedWidth - 20 ? calculatedWidth - 20 : itemWidth;\n }\n\n if (tmpMinWidth > parentWidth) {\n tmpMinWidth = parentWidth;\n }\n\n if (tmpBodyMinWidth > parentWidth) {\n tmpBodyMinWidth = parentWidth;\n }\n\n setMinWidth(tmpMinWidth);\n setBodyMinWidth(shouldUseCurrentItemWidth ? tmpMinWidth : tmpBodyMinWidth);\n }, [\n lists,\n placeholder,\n shouldUseFullWidth,\n shouldUseCurrentItemWidth,\n internalSelectedItem,\n prefix,\n selectedItem,\n functions,\n values,\n shouldDropDownUseMaxItemWidth,\n ]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n setIsAnimating(false);\n setInternalSelectedItem(selectedItem);\n }, [selectedItem]);\n\n const placeholderImageUrl = useMemo(() => {\n if (selectedItem) {\n return selectedItem.imageUrl;\n }\n\n if (internalSelectedItem) {\n return internalSelectedItem.imageUrl;\n }\n\n return undefined;\n }, [internalSelectedItem, selectedItem]);\n\n const placeholderIcon = useMemo(() => {\n if (selectedItem) {\n return selectedItem.icons;\n }\n\n if (internalSelectedItem) {\n return internalSelectedItem.icons;\n }\n\n return undefined;\n }, [internalSelectedItem, 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 (internalSelectedItem) {\n text = internalSelectedItem.text;\n }\n\n return text;\n }, [internalSelectedItem, placeholder, selectedItem]);\n\n const shouldShowRoundPlaceholderImage = useMemo(() => {\n const selectedItemList = lists.find((list) =>\n list.list.some(\n ({ value }) => value === (selectedItem?.value ?? internalSelectedItem?.value),\n ),\n );\n\n return selectedItemList?.shouldShowRoundImage ?? shouldShowRoundImage;\n }, [internalSelectedItem?.value, lists, selectedItem?.value, shouldShowRoundImage]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = useCallback(() => {\n if (!isDisabled && !isInputFocused.current) {\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((list) => (\n <Fragment key={list.groupName ?? 'default-group'}>\n {list.groupName && lists.length > 1 && (\n <StyledComboBoxTopic id={`combobox-group--${list.groupName}`}>\n {list.groupName}\n </StyledComboBoxTopic>\n )}\n {list.list.map((item) => (\n <ComboBoxItem\n item={item}\n isSelected={selectedItem ? item.value === selectedItem.value : false}\n onSelect={handleSetSelectedItem}\n shouldShowBigImage={shouldShowBigImage}\n shouldShowRoundImage={list.shouldShowRoundImage ?? shouldShowRoundImage}\n />\n ))}\n </Fragment>\n )),\n [handleSetSelectedItem, lists, selectedItem, shouldShowBigImage, shouldShowRoundImage],\n );\n\n return useMemo(\n () => (\n <StyledComboBox\n ref={styledComboBoxElementRef}\n $minWidth={minWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n $shouldUseCurrentItemWidth={shouldUseCurrentItemWidth}\n >\n <StyledComboBoxHeader\n $direction={direction}\n onClick={handleHeaderClick}\n $isOpen={isAnimating}\n $isTouch={isTouch}\n $isDisabled={isDisabled}\n $shouldChangeColor={shouldChangeColor}\n $shouldShowBigImage={shouldShowBigImage}\n >\n <StyledComboBoxPrefixAndPlaceholderWrapper>\n {prefix && <StyledComboBoxPrefix>{prefix}</StyledComboBoxPrefix>}\n <StyledComboBoxPlaceholder\n $shouldReduceOpacity={!selectedItem && !internalSelectedItem}\n >\n {placeholderImageUrl && (\n <StyledComboBoxPlaceholderImage\n src={placeholderImageUrl}\n $shouldShowBigImage={shouldShowBigImage}\n $shouldShowRoundImage={shouldShowRoundPlaceholderImage}\n />\n )}\n {placeholderIcon && <Icon icons={placeholderIcon} />}\n {typeof inputValue === 'string' ? (\n <StyledComboBoxInput\n disabled={isDisabled}\n value={inputValue}\n onChange={onInputChange}\n onBlur={handleInputBlur}\n onFocus={handleInputFocus}\n placeholder={placeholderText}\n />\n ) : (\n <StyledComboBoxPlaceholderText>\n {placeholderText}\n </StyledComboBoxPlaceholderText>\n )}\n {internalSelectedItem &&\n internalSelectedItem.suffixElement &&\n internalSelectedItem.suffixElement}\n </StyledComboBoxPlaceholder>\n </StyledComboBoxPrefixAndPlaceholderWrapper>\n {shouldShowClearIcon && internalSelectedItem && (\n <StyledComboBoxClearIconWrapper onClick={handleClear}>\n <Icon icons={['fa fa-times']} />\n </StyledComboBoxClearIconWrapper>\n )}\n {!shouldDisableActions && (\n <StyledComboBoxIconWrapper\n $shouldShowBorderLeft={\n shouldShowClearIcon === true && internalSelectedItem !== undefined\n }\n >\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n )}\n </StyledComboBoxHeader>\n {styledComboBoxElementRef.current && (\n <DropdownBodyWrapper\n anchorElement={styledComboBoxElementRef.current}\n bodyWidth={bodyWidth}\n contentHeight={contentHeight}\n onClose={handleClose}\n direction={direction}\n container={container}\n shouldShowDropdown={isAnimating}\n minBodyWidth={bodyWidth ?? bodyMinWidth}\n maxHeight={maxHeight}\n >\n <StyledComboBoxBody\n $shouldUseCurrentItemWidth={shouldUseCurrentItemWidth}\n $maxHeight={maxHeight}\n $minWidth={bodyWidth ?? bodyMinWidth}\n $browser={browser?.name as BrowserName}\n ref={contentRef}\n tabIndex={0}\n >\n {comboBoxGroups}\n </StyledComboBoxBody>\n </DropdownBodyWrapper>\n )}\n </StyledComboBox>\n ),\n [\n minWidth,\n shouldUseFullWidth,\n shouldUseCurrentItemWidth,\n direction,\n handleHeaderClick,\n isAnimating,\n isTouch,\n isDisabled,\n shouldChangeColor,\n shouldShowBigImage,\n prefix,\n selectedItem,\n internalSelectedItem,\n placeholderImageUrl,\n shouldShowRoundPlaceholderImage,\n placeholderIcon,\n inputValue,\n onInputChange,\n handleInputBlur,\n handleInputFocus,\n placeholderText,\n shouldShowClearIcon,\n handleClear,\n shouldDisableActions,\n bodyWidth,\n contentHeight,\n handleClose,\n container,\n bodyMinWidth,\n maxHeight,\n browser?.name,\n comboBoxGroups,\n ],\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,YAAY,EAAEC,SAAS,QAAQ,YAAY;AAC/D,OAAOC,KAAK,IAKRC,QAAQ,EAGRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AAEd,SAASC,qBAAqB,QAAQ,uBAAuB;AAC7D,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,WAAW,QAAQ,sCAAsC;AAClE,OAAOC,I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D,aAAa,EAAEA,aAAc;IAC7B+F,OAAO,EAAEvF,WAAY;IACrB3D,SAAS,EAAEA,SAAU;IACrBQ,SAAS,EAAEA,SAAU;IACrB2I,kBAAkB,EAAE7H,WAAY;IAChC8H,YAAY,EAAErJ,SAAS,IAAI4B,YAAa;IACxCvB,SAAS,EAAEA;EAAU,gBAErBlC,KAAA,CAAAwJ,aAAA,CAAC1I,kBAAkB;IACfgJ,0BAA0B,EAAEhH,yBAA0B;IACtDqI,UAAU,EAAEjJ,SAAU;IACtB0H,SAAS,EAAE/H,SAAS,IAAI4B,YAAa;IACrC2H,QAAQ,EAAE/G,OAAO,EAAEgH,IAAoB;IACvC1B,GAAG,EAAE5F,UAAW;IAChBiD,QAAQ,EAAE;EAAE,GAEXsC,cACe,CACH,CAEb,CACnB,EACD,CACIhG,QAAQ,EACRV,kBAAkB,EAClBE,yBAAyB,EACzBhB,SAAS,EACTuH,iBAAiB,EACjBjG,WAAW,EACXgB,OAAO,EACPpC,UAAU,EACVwC,iBAAiB,EACjBhC,kBAAkB,EAClBH,MAAM,EACNE,YAAY,EACZW,oBAAoB,EACpB8F,mBAAmB,EACnBG,+BAA+B,EAC/BF,eAAe,EACfjG,UAAU,EACVH,aAAa,EACb0C,eAAe,EACfH,gBAAgB,EAChB8D,eAAe,EACfzG,mBAAmB,EACnBuD,WAAW,EACXvB,oBAAoB,EACpB5C,SAAS,EACToD,aAAa,EACbQ,WAAW,EACXnD,SAAS,EACTmB,YAAY,EACZvB,SAAS,EACTmC,OAAO,EAAEgH,IAAI,EACb/B,cAAc,CAEtB,CAAC;AACL,CAAC;AAED1H,QAAQ,CAAC0J,WAAW,GAAG,UAAU;AAEjC,eAAe1J,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectButton.js","names":["createDialog","DialogType","React","useMemo","Button","StyledSelectButton","SelectButton","buttonText","isDisabled","list","onSelect","selectedItemIds","shouldAllowMultiSelect","shouldShowButtonTextWithSelection","maxDisplayedItems","additionalText","shouldShowSearch","selectAllText","title","itemList","items","forEach","text","id","isSelected","includes","push","name","internalButtonText","length","addedCount","newText","additionalCount","replace","String","handleClick","undefined","type","SELECT","multiselect","quickfind","selectAllCheckbox","open","then","result","buttonType","
|
|
1
|
+
{"version":3,"file":"SelectButton.js","names":["createDialog","DialogType","React","useMemo","Button","StyledSelectButton","SelectButton","buttonText","isDisabled","list","onSelect","selectedItemIds","shouldAllowMultiSelect","shouldShowButtonTextWithSelection","maxDisplayedItems","additionalText","shouldShowSearch","selectAllText","title","itemList","items","forEach","text","id","isSelected","includes","push","name","internalButtonText","length","addedCount","newText","additionalCount","replace","String","handleClick","undefined","type","SELECT","multiselect","quickfind","selectAllCheckbox","open","then","result","buttonType","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 * Text used when there are more selected items than maxDisplayedItems. '##count##' will be displayed with the additional count.\n */\n additionalText?: string;\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 * The maximum number of items displayed in the button text.\n */\n maxDisplayedItems?: number;\n /**\n * Function to be executed after an item is selected.\n */\n onSelect?: (ids: (number | string)[]) => void;\n /**\n * If a string is given and `shouldAllowMultiSelect` is true, the dialog displays a checkbox to select all items at once.\n */\n selectAllText?: string;\n /**\n * The id of an item that should be preselected.\n */\n selectedItemIds?: (number | string)[];\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 maxDisplayedItems = 3,\n additionalText = ', ##count## weitere',\n shouldShowSearch,\n selectAllText,\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 - maxDisplayedItems;\n\n list.forEach(({ text, id }) => {\n if (addedCount < maxDisplayedItems && selectedItemIds?.includes(id)) {\n addedCount++;\n newText += newText.length === 0 ? `${text}` : `, ${text}`;\n }\n });\n\n if (additionalCount >= 1) {\n newText += additionalText.replace('##count##', String(additionalCount));\n }\n\n return newText;\n }, [\n additionalText,\n buttonText,\n list,\n maxDisplayedItems,\n selectedItemIds,\n shouldShowButtonTextWithSelection,\n ]);\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 selectAllCheckbox: selectAllText,\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);\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,kBAAkB;AACrC,SAASC,kBAAkB,QAAQ,uBAAuB;AAqD1D,MAAMC,YAAmC,GAAGA,CAAC;EACzCC,UAAU;EACVC,UAAU;EACVC,IAAI;EACJC,QAAQ;EACRC,eAAe;EACfC,sBAAsB;EACtBC,iCAAiC;EACjCC,iBAAiB,GAAG,CAAC;EACrBC,cAAc,GAAG,qBAAqB;EACtCC,gBAAgB;EAChBC,aAAa;EACbC;AACJ,CAAC,KAAK;EACF,MAAMC,QAAQ,GAAGhB,OAAO,CAAC,MAAM;IAC3B,MAAMiB,KAAiC,GAAG,EAAE;IAE5CX,IAAI,CAACY,OAAO,CAAC,CAAC;MAAEC,IAAI;MAAEC;IAAG,CAAC,KAAK;MAC3B,MAAMC,UAAU,GAAGb,eAAe,GAAGA,eAAe,CAACc,QAAQ,CAACF,EAAE,CAAC,GAAG,KAAK;MAEzEH,KAAK,CAACM,IAAI,CAAC;QACPC,IAAI,EAAEL,IAAI;QACVC,EAAE;QACFC;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,OAAOJ,KAAK;EAChB,CAAC,EAAE,CAACX,IAAI,EAAEE,eAAe,CAAC,CAAC;EAE3B,MAAMiB,kBAAkB,GAAGzB,OAAO,CAAC,MAAM;IACrC,IAAIU,iCAAiC,IAAI,CAACF,eAAe,IAAIA,eAAe,CAACkB,MAAM,KAAK,CAAC,EAAE;MACvF,OAAOtB,UAAU;IACrB;IAEA,IAAIuB,UAAU,GAAG,CAAC;IAClB,IAAIC,OAA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,KAAA,CAAA4C,aAAA,CAACzC,kBAAkB,qBACfH,KAAA,CAAA4C,aAAA,CAAC1C,MAAM;IACH2C,OAAO,EAAEZ,WAAY;IACrB3B,UAAU,EAAEA,UAAW;IACvBwC,WAAW;IACXC,4BAA4B,EAAE;EAAM,GAEnCrB,kBACG,CACQ,CAAC;AAE7B,CAAC;AAEDtB,YAAY,CAAC4C,WAAW,GAAG,cAAc;AAEzC,eAAe5C,YAAY","ignoreList":[]}
|
package/lib/esm/hooks/element.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React, { cloneElement, isValidElement, useEffect, useRef, useState } from 'react';
|
|
2
2
|
export const useElementSize = (ref, {
|
|
3
|
-
shouldUseChildElement = false
|
|
3
|
+
shouldUseChildElement = false,
|
|
4
|
+
shouldUseParentElement = false
|
|
4
5
|
} = {}) => {
|
|
5
6
|
const [size, setSize] = useState();
|
|
6
7
|
useEffect(() => {
|
|
7
|
-
|
|
8
|
+
let target = ref.current;
|
|
9
|
+
if (shouldUseParentElement) {
|
|
10
|
+
target = ref.current?.parentElement;
|
|
11
|
+
}
|
|
12
|
+
if (shouldUseChildElement) {
|
|
13
|
+
target = ref.current?.firstElementChild;
|
|
14
|
+
}
|
|
8
15
|
if (!target) return () => {};
|
|
9
16
|
const updateSize = () => setSize(target.getBoundingClientRect());
|
|
10
17
|
updateSize();
|
|
@@ -17,7 +24,7 @@ export const useElementSize = (ref, {
|
|
|
17
24
|
});
|
|
18
25
|
observer.observe(target);
|
|
19
26
|
return () => observer.disconnect();
|
|
20
|
-
}, [ref, shouldUseChildElement]);
|
|
27
|
+
}, [ref, shouldUseChildElement, shouldUseParentElement]);
|
|
21
28
|
return size;
|
|
22
29
|
};
|
|
23
30
|
const getClonedElement = content => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":["React","cloneElement","isValidElement","useEffect","useRef","useState","useElementSize","ref","shouldUseChildElement","size","setSize","target","current","firstElementChild","updateSize","getBoundingClientRect","observer","ResizeObserver","entries","forEach","entry","contentRect","observe","disconnect","getClonedElement","content","preventEvents","onClick","e","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","props","createElement","useMeasuredClone","width","height","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","zIndex","visibility","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute"
|
|
1
|
+
{"version":3,"file":"element.js","names":["React","cloneElement","isValidElement","useEffect","useRef","useState","useElementSize","ref","shouldUseChildElement","shouldUseParentElement","size","setSize","target","current","parentElement","firstElementChild","updateSize","getBoundingClientRect","observer","ResizeObserver","entries","forEach","entry","contentRect","observe","disconnect","getClonedElement","content","preventEvents","onClick","e","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","props","createElement","useMeasuredClone","width","height","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","zIndex","visibility","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute"],"sources":["../../../src/hooks/element.tsx"],"sourcesContent":["import React, {\n cloneElement,\n HTMLAttributes,\n isValidElement,\n MutableRefObject,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n shouldUseParentElement?: boolean;\n}\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false, shouldUseParentElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n useEffect(() => {\n let target = ref.current as HTMLElement | null;\n\n if (shouldUseParentElement) {\n target = ref.current?.parentElement as HTMLElement | null;\n }\n\n if (shouldUseChildElement) {\n target = ref.current?.firstElementChild as HTMLElement | null;\n }\n\n if (!target) return () => {};\n\n const updateSize = () => setSize(target.getBoundingClientRect());\n\n updateSize();\n\n const observer = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n if (entry.target === target) {\n setSize(entry.contentRect);\n }\n });\n });\n\n observer.observe(target);\n\n return () => observer.disconnect();\n }, [ref, shouldUseChildElement, shouldUseParentElement]);\n\n return size;\n};\n\nconst getClonedElement = (content: ReactNode) => {\n const preventEvents: Partial<HTMLAttributes<any>> = {\n onClick: (e) => e.stopPropagation(),\n onMouseDown: (e) => e.stopPropagation(),\n onMouseUp: (e) => e.stopPropagation(),\n onKeyDown: (e) => e.stopPropagation(),\n onKeyUp: (e) => e.stopPropagation(),\n onFocus: (e) => e.stopPropagation(),\n onBlur: (e) => e.stopPropagation(),\n };\n\n const props = {\n ...preventEvents,\n 'data-measured-clone': true,\n };\n\n if (isValidElement(content)) {\n return cloneElement(content as unknown as ReactElement, props);\n }\n\n if (typeof content === 'string') {\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <span {...props}>{content}</span>;\n }\n\n return content;\n};\n\ninterface UseMeasuredCloneOptions {\n content: ReactNode;\n}\n\nexport const useMeasuredClone = ({ content }: UseMeasuredCloneOptions) => {\n const ref = useRef<HTMLDivElement>(null);\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const clonedElement = getClonedElement(content);\n\n useEffect(() => {\n const measure = () => {\n if (!ref.current) return;\n const { offsetWidth: width, offsetHeight: height } = ref.current;\n setSize({ width: width + 10, height });\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n\n if (ref.current) observer.observe(ref.current);\n\n return () => observer.disconnect();\n }, []);\n\n const measuredElement = (\n <div\n data-measured-clone=\"true\"\n ref={ref}\n style={{\n position: 'fixed',\n opacity: 0,\n pointerEvents: 'none',\n zIndex: -1,\n height: 'auto',\n width: 'auto',\n visibility: 'hidden',\n }}\n >\n {clonedElement}\n </div>\n );\n\n return {\n measuredElement,\n width: size.width,\n height: size.height,\n };\n};\n\nexport const useIsMeasuredClone = <T extends HTMLElement>() => {\n const ref = useRef<T | null>(null);\n\n const [isClone, setIsClone] = useState(false);\n\n useEffect(() => {\n if (!ref.current) return;\n\n let el: HTMLElement | null = ref.current;\n\n while (el) {\n if (el.hasAttribute('data-measured-clone')) {\n setIsClone(true);\n\n return;\n }\n\n el = el.parentElement;\n }\n\n setIsClone(false);\n }, []);\n\n return [isClone, ref] as const;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,YAAY,EAEZC,cAAc,EAIdC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACL,OAAO;AAOd,OAAO,MAAMC,cAAc,GAAGA,CAC1BC,GAA+D,EAC/D;EAAEC,qBAAqB,GAAG,KAAK;EAAEC,sBAAsB,GAAG;AAA6B,CAAC,GAAG,CAAC,CAAC,KAC/D;EAC9B,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGN,QAAQ,CAAkB,CAAC;EAEnDF,SAAS,CAAC,MAAM;IACZ,IAAIS,MAAM,GAAGL,GAAG,CAACM,OAA6B;IAE9C,IAAIJ,sBAAsB,EAAE;MACxBG,MAAM,GAAGL,GAAG,CAACM,OAAO,EAAEC,aAAmC;IAC7D;IAEA,IAAIN,qBAAqB,EAAE;MACvBI,MAAM,GAAGL,GAAG,CAACM,OAAO,EAAEE,iBAAuC;IACjE;IAEA,IAAI,CAACH,MAAM,EAAE,OAAO,MAAM,CAAC,CAAC;IAE5B,MAAMI,UAAU,GAAGA,CAAA,KAAML,OAAO,CAACC,MAAM,CAACK,qBAAqB,CAAC,CAAC,CAAC;IAEhED,UAAU,CAAC,CAAC;IAEZ,MAAME,QAAQ,GAAG,IAAIC,cAAc,CAAEC,OAAO,IAAK;MAC7CA,OAAO,CAACC,OAAO,CAAEC,KAAK,IAAK;QACvB,IAAIA,KAAK,CAACV,MAAM,KAAKA,MAAM,EAAE;UACzBD,OAAO,CAACW,KAAK,CAACC,WAAW,CAAC;QAC9B;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;IAEFL,QAAQ,CAACM,OAAO,CAACZ,MAAM,CAAC;IAExB,OAAO,MAAMM,QAAQ,CAACO,UAAU,C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AAC;EAE7CF,SAAS,CAAC,MAAM;IACZ,IAAI,CAACI,GAAG,CAACM,OAAO,EAAE;IAElB,IAAI4C,EAAsB,GAAGlD,GAAG,CAACM,OAAO;IAExC,OAAO4C,EAAE,EAAE;MACP,IAAIA,EAAE,CAACC,YAAY,CAAC,qBAAqB,CAAC,EAAE;QACxCF,UAAU,CAAC,IAAI,CAAC;QAEhB;MACJ;MAEAC,EAAE,GAAGA,EAAE,CAAC3C,aAAa;IACzB;IAEA0C,UAAU,CAAC,KAAK,CAAC;EACrB,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACD,OAAO,EAAEhD,GAAG,CAAC;AACzB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectButton.js","names":[],"sources":["../../../src/types/selectButton.ts"],"sourcesContent":["export interface SelectButtonItem {\n text: string;\n id: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"selectButton.js","names":[],"sources":["../../../src/types/selectButton.ts"],"sourcesContent":["export interface SelectButtonItem {\n text: string;\n id: number | string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -24,7 +24,7 @@ export type SelectButtonProps = {
|
|
|
24
24
|
/**
|
|
25
25
|
* Function to be executed after an item is selected.
|
|
26
26
|
*/
|
|
27
|
-
onSelect?: (ids: number[]) => void;
|
|
27
|
+
onSelect?: (ids: (number | string)[]) => void;
|
|
28
28
|
/**
|
|
29
29
|
* If a string is given and `shouldAllowMultiSelect` is true, the dialog displays a checkbox to select all items at once.
|
|
30
30
|
*/
|
|
@@ -32,7 +32,7 @@ export type SelectButtonProps = {
|
|
|
32
32
|
/**
|
|
33
33
|
* The id of an item that should be preselected.
|
|
34
34
|
*/
|
|
35
|
-
selectedItemIds?: number[];
|
|
35
|
+
selectedItemIds?: (number | string)[];
|
|
36
36
|
/**
|
|
37
37
|
* Whether more than one item should be selectable.
|
|
38
38
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { MutableRefObject, ReactNode } from 'react';
|
|
2
2
|
interface UseElementSizeOptions {
|
|
3
3
|
shouldUseChildElement?: boolean;
|
|
4
|
+
shouldUseParentElement?: boolean;
|
|
4
5
|
}
|
|
5
|
-
export declare const useElementSize: (ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>, { shouldUseChildElement }?: UseElementSizeOptions) => DOMRectReadOnly | undefined;
|
|
6
|
+
export declare const useElementSize: (ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>, { shouldUseChildElement, shouldUseParentElement }?: UseElementSizeOptions) => DOMRectReadOnly | undefined;
|
|
6
7
|
interface UseMeasuredCloneOptions {
|
|
7
8
|
content: ReactNode;
|
|
8
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.1241",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "57b1a1f001a7c5fb5b8dc6ff2bc67088c4f4e48f"
|
|
89
89
|
}
|