@chayns-components/core 5.2.8-alpha.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/lib/cjs/components/combobox/ComboBox.constants.js +15 -0
  2. package/lib/cjs/components/combobox/ComboBox.constants.js.map +1 -0
  3. package/lib/cjs/components/combobox/ComboBox.js +28 -78
  4. package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
  5. package/lib/cjs/components/combobox/ComboBox.styles.js +16 -11
  6. package/lib/cjs/components/combobox/ComboBox.styles.js.map +1 -1
  7. package/lib/cjs/components/combobox/ComboBox.types.js +24 -0
  8. package/lib/cjs/components/combobox/ComboBox.types.js.map +1 -1
  9. package/lib/cjs/components/combobox/ComboBox.utils.js +88 -0
  10. package/lib/cjs/components/combobox/ComboBox.utils.js.map +1 -0
  11. package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.js +10 -7
  12. package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.js.map +1 -1
  13. package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.js +10 -4
  14. package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.js.map +1 -1
  15. package/lib/cjs/components/filter/filter-content/FilterContent.constants.js +8 -0
  16. package/lib/cjs/components/filter/filter-content/FilterContent.constants.js.map +1 -0
  17. package/lib/cjs/components/filter/filter-content/FilterContent.js +6 -27
  18. package/lib/cjs/components/filter/filter-content/FilterContent.js.map +1 -1
  19. package/lib/cjs/components/filter/filter-content/FilterContent.styles.js +10 -24
  20. package/lib/cjs/components/filter/filter-content/FilterContent.styles.js.map +1 -1
  21. package/lib/cjs/components/filter/filter-content/FilterContent.types.js +6 -0
  22. package/lib/cjs/components/filter/filter-content/FilterContent.types.js.map +1 -0
  23. package/lib/cjs/components/filter/filter-content/FilterContent.utils.js +17 -0
  24. package/lib/cjs/components/filter/filter-content/FilterContent.utils.js.map +1 -0
  25. package/lib/cjs/components/search-box/SearchBox.js +0 -1
  26. package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
  27. package/lib/cjs/components/skeleton/base-skeleton/BaseSkeleton.styles.js +0 -2
  28. package/lib/cjs/components/skeleton/base-skeleton/BaseSkeleton.styles.js.map +1 -1
  29. package/lib/cjs/types/filter.js +24 -0
  30. package/lib/cjs/types/filter.js.map +1 -1
  31. package/lib/esm/components/combobox/ComboBox.constants.js +9 -0
  32. package/lib/esm/components/combobox/ComboBox.constants.js.map +1 -0
  33. package/lib/esm/components/combobox/ComboBox.js +28 -77
  34. package/lib/esm/components/combobox/ComboBox.js.map +1 -1
  35. package/lib/esm/components/combobox/ComboBox.styles.js +16 -11
  36. package/lib/esm/components/combobox/ComboBox.styles.js.map +1 -1
  37. package/lib/esm/components/combobox/ComboBox.types.js +29 -0
  38. package/lib/esm/components/combobox/ComboBox.types.js.map +1 -1
  39. package/lib/esm/components/combobox/ComboBox.utils.js +81 -0
  40. package/lib/esm/components/combobox/ComboBox.utils.js.map +1 -0
  41. package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.js +11 -8
  42. package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.js.map +1 -1
  43. package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.js +10 -4
  44. package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.js.map +1 -1
  45. package/lib/esm/components/filter/filter-content/FilterContent.constants.js +2 -0
  46. package/lib/esm/components/filter/filter-content/FilterContent.constants.js.map +1 -0
  47. package/lib/esm/components/filter/filter-content/FilterContent.js +8 -29
  48. package/lib/esm/components/filter/filter-content/FilterContent.js.map +1 -1
  49. package/lib/esm/components/filter/filter-content/FilterContent.styles.js +9 -23
  50. package/lib/esm/components/filter/filter-content/FilterContent.styles.js.map +1 -1
  51. package/lib/esm/components/filter/filter-content/FilterContent.types.js +2 -0
  52. package/lib/esm/components/filter/filter-content/FilterContent.types.js.map +1 -0
  53. package/lib/esm/components/filter/filter-content/FilterContent.utils.js +10 -0
  54. package/lib/esm/components/filter/filter-content/FilterContent.utils.js.map +1 -0
  55. package/lib/esm/components/search-box/SearchBox.js +0 -1
  56. package/lib/esm/components/search-box/SearchBox.js.map +1 -1
  57. package/lib/esm/components/skeleton/base-skeleton/BaseSkeleton.styles.js +0 -2
  58. package/lib/esm/components/skeleton/base-skeleton/BaseSkeleton.styles.js.map +1 -1
  59. package/lib/esm/types/filter.js +31 -0
  60. package/lib/esm/types/filter.js.map +1 -1
  61. package/lib/types/components/combobox/ComboBox.constants.d.ts +8 -0
  62. package/lib/types/components/combobox/ComboBox.styles.d.ts +4 -8
  63. package/lib/types/components/combobox/ComboBox.types.d.ts +102 -0
  64. package/lib/types/components/combobox/ComboBox.utils.d.ts +23 -0
  65. package/lib/types/components/dropdown-body-wrapper/DropdownBodyWrapper.d.ts +2 -2
  66. package/lib/types/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.d.ts +2 -2
  67. package/lib/types/components/filter/filter-content/FilterContent.constants.d.ts +1 -0
  68. package/lib/types/components/filter/filter-content/FilterContent.d.ts +1 -9
  69. package/lib/types/components/filter/filter-content/FilterContent.styles.d.ts +3 -14
  70. package/lib/types/components/filter/filter-content/FilterContent.types.d.ts +30 -0
  71. package/lib/types/components/filter/filter-content/FilterContent.utils.d.ts +3 -0
  72. package/lib/types/types/filter.d.ts +51 -0
  73. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownBodyWrapper.js","names":["React","useCallback","useEffect","useRef","useState","StyledDropdownBodyWrapper","StyledDropdownBodyWrapperContent","createPortal","DropdownDirection","DelayedDropdownContent","useDropdown","useDropdownListener","ContainerAnchor","useContainer","DropdownBodyWrapper","anchorElement","bodyWidth","children","container","containerProp","contentHeight","direction","BOTTOM_RIGHT","maxHeight","minBodyWidth","onClose","onOutsideClick","onMeasure","shouldCaptureEvents","shouldShowDropdown","isInChaynsWalletRef","measuredContentHeight","setMeasuredContentHeight","measuredContentWidth","setMeasuredContentWidth","portal","setPortal","ref","shouldPreventClickRef","touchTimeoutRef","undefined","transform","width","coordinates","contentWidth","handleClose","handleClick","event","current","contains","target","preventDefault","stopPropagation","shouldPreventCloseOnClick","handleContentMeasure","measurements","height","handleTouchEnd","clearTimeout","handleTouchStart","window","setTimeout","onClick","onTouchEnd","onTouchStart","isBottomDirection","BOTTOM","BOTTOM_LEFT","includes","reservationWrapperElement","closest","RESERVATION_WRAPPER","availableHeight","innerHeight","getBoundingClientRect","bottom","additionalNeededSpace","style","marginBottom","createElement","shouldShowContent","$width","$minWidth","$maxHeight","$direction","displayName"],"sources":["../../../../src/components/dropdown-body-wrapper/DropdownBodyWrapper.tsx"],"sourcesContent":["import React, { FC, ReactNode, ReactPortal, useCallback, useEffect, useRef, useState } from 'react';\nimport {\n StyledDropdownBodyWrapper,\n StyledDropdownBodyWrapperContent,\n} from './DropdownBodyWrapper.styles';\nimport { createPortal } from 'react-dom';\nimport { DropdownDirection, DropdownMeasurements } from '../../types/dropdown';\nimport DelayedDropdownContent, {\n DelayedDropdownContentProps,\n} from './delayed-dropdown-content/DelayedDropdownContent';\nimport { useDropdown, useDropdownListener } from '../../hooks/dropdown';\nimport { ContainerAnchor, useContainer } from '../../hooks/container';\n\ninterface DropdownBodyWrapperProps {\n /**\n * The anchor element of the dropdown.\n */\n anchorElement: Element;\n /**\n * The width of the Body.\n */\n bodyWidth?: number;\n /**\n * The content of the dropdown body.\n */\n children: ReactNode;\n /**\n * The element where the content should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The height of the content\n */\n contentHeight?: number;\n /**\n * The direction of the dropdown.\n */\n direction?: DropdownDirection;\n /**\n * The max height of the dropdown.\n */\n maxHeight?: number;\n /**\n * The minimum width of the body.\n */\n minBodyWidth?: number;\n /**\n * Function to be executed when the body is closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the user clicks outside the dropdown.\n * If the function returns `true`, the dropdown will not be closed.\n */\n onOutsideClick?: () => boolean | void;\n /**\n * Function to be executed when the content is measured.\n */\n onMeasure?: DelayedDropdownContentProps['onMeasure'];\n /**\n * Whether the dropdown should be visible.\n */\n shouldShowDropdown: boolean;\n /**\n * Whether the outside events should be captured.\n */\n shouldCaptureEvents?: boolean;\n}\n\nconst DropdownBodyWrapper: FC<DropdownBodyWrapperProps> = ({\n anchorElement,\n bodyWidth,\n children,\n container: containerProp,\n contentHeight = 0,\n direction = DropdownDirection.BOTTOM_RIGHT,\n maxHeight = 300,\n minBodyWidth = 0,\n onClose,\n onOutsideClick,\n onMeasure,\n shouldCaptureEvents = true,\n shouldShowDropdown,\n}) => {\n const isInChaynsWalletRef = useRef(false);\n\n const [measuredContentHeight, setMeasuredContentHeight] = useState<number>(0);\n const [measuredContentWidth, setMeasuredContentWidth] = useState<number>(0);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const ref = useRef<HTMLDivElement>(null);\n const shouldPreventClickRef = useRef<boolean>(false);\n const touchTimeoutRef = useRef<number | undefined>(undefined);\n\n const container = useContainer({ anchorElement, container: containerProp });\n\n const { transform, width, coordinates } = useDropdown({\n anchorElement,\n container,\n contentHeight,\n contentWidth: bodyWidth ?? measuredContentWidth,\n direction,\n shouldShowDropdown,\n });\n\n const handleClose = useCallback(() => {\n if (typeof onClose === 'function') {\n onClose();\n }\n }, [onClose]);\n\n /**\n * This function closes the body\n */\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (\n ref.current &&\n shouldShowDropdown &&\n !anchorElement.contains(event.target as Node) &&\n !ref.current.contains(event.target as Node)\n ) {\n event.preventDefault();\n event.stopPropagation();\n\n const shouldPreventCloseOnClick = onOutsideClick?.() ?? false;\n\n if (!shouldPreventClickRef.current && !shouldPreventCloseOnClick) {\n handleClose();\n }\n }\n\n shouldPreventClickRef.current = false;\n },\n [anchorElement, handleClose, onOutsideClick, shouldShowDropdown],\n );\n\n const handleContentMeasure = useCallback(\n (measurements: DropdownMeasurements) => {\n // Measurements are only needed if the content is shown in the chayns wallet. To prevent\n // unnecessary renders, we only set the height if the content is shown in the wallet.\n if (isInChaynsWalletRef.current) {\n setMeasuredContentHeight(measurements.height);\n }\n\n setMeasuredContentWidth(measurements.width);\n\n if (typeof onMeasure === 'function') {\n onMeasure(measurements);\n }\n },\n [onMeasure],\n );\n\n const handleTouchEnd = useCallback(() => {\n clearTimeout(touchTimeoutRef.current);\n }, []);\n\n const handleTouchStart = useCallback(() => {\n touchTimeoutRef.current = window.setTimeout(() => {\n shouldPreventClickRef.current = true;\n }, 500);\n }, []);\n\n /**\n * This hook listens for clicks\n */\n useDropdownListener({\n onClick: handleClick,\n onClose: handleClose,\n onTouchEnd: handleTouchEnd,\n onTouchStart: handleTouchStart,\n shouldCaptureEvents,\n });\n\n useEffect(() => {\n const isBottomDirection = [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes(direction);\n\n const reservationWrapperElement = anchorElement.closest<HTMLDivElement>(\n ContainerAnchor.RESERVATION_WRAPPER,\n );\n\n isInChaynsWalletRef.current =\n !!(reservationWrapperElement && reservationWrapperElement.contains(anchorElement)) ||\n true;\n\n // This effect checks if additional space is needed to show dropdown content in chayns cards.\n if (\n isBottomDirection &&\n isInChaynsWalletRef.current &&\n measuredContentHeight > 0 &&\n reservationWrapperElement &&\n shouldShowDropdown\n ) {\n const availableHeight =\n window.innerHeight - anchorElement.getBoundingClientRect().bottom;\n\n // If the content height is greater than the available height, we need to add additional space.\n // This is to ensure that the dropdown content is fully visible. The 16 pixels are a buffer for shadows.\n const additionalNeededSpace = measuredContentHeight + 16 - availableHeight;\n\n if (additionalNeededSpace > 0) {\n // Add margin bottom to the reservation wrapper to ensure the dropdown content is fully visible.\n reservationWrapperElement.style.marginBottom = `${additionalNeededSpace}px`;\n } else {\n // Reset the margin bottom if no additional space is needed.\n reservationWrapperElement.style.marginBottom = '0px';\n }\n }\n\n if (isInChaynsWalletRef.current && reservationWrapperElement && !shouldShowDropdown) {\n // Reset the margin bottom when the dropdown is closed.\n reservationWrapperElement.style.marginBottom = '0px';\n }\n\n return () => {\n if (reservationWrapperElement) {\n reservationWrapperElement.style.marginBottom = '0px';\n }\n };\n }, [anchorElement, direction, measuredContentHeight, shouldShowDropdown]);\n\n useEffect(() => {\n if (!container) return;\n\n setPortal(() =>\n createPortal(\n <DelayedDropdownContent\n coordinates={coordinates}\n onMeasure={handleContentMeasure}\n shouldShowContent={shouldShowDropdown}\n transform={transform}\n >\n <StyledDropdownBodyWrapperContent\n $width={width}\n $minWidth={minBodyWidth}\n $maxHeight={maxHeight}\n $direction={direction}\n ref={ref}\n >\n {children}\n </StyledDropdownBodyWrapperContent>\n </DelayedDropdownContent>,\n container,\n ),\n );\n }, [\n children,\n container,\n coordinates,\n direction,\n handleContentMeasure,\n maxHeight,\n minBodyWidth,\n shouldShowDropdown,\n transform,\n width,\n ]);\n\n return <StyledDropdownBodyWrapper>{portal}</StyledDropdownBodyWrapper>;\n};\n\nDropdownBodyWrapper.displayName = 'DropdownBodyWrapper';\n\nexport default DropdownBodyWrapper;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAgCC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnG,SACIC,yBAAyB,EACzBC,gCAAgC,QAC7B,8BAA8B;AACrC,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,iBAAiB,QAA8B,sBAAsB;AAC9E,OAAOC,sBAAsB,MAEtB,mDAAmD;AAC1D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,sBAAsB;AACvE,SAASC,eAAe,EAAEC,YAAY,QAAQ,uBAAuB;AA0DrE,MAAMC,mBAAiD,GAAGA,CAAC;EACvDC,aAAa;EACbC,SAAS;EACTC,QAAQ;EACRC,SAAS,EAAEC,aAAa;EACxBC,aAAa,GAAG,CAAC;EACjBC,SAAS,GAAGb,iBAAiB,CAACc,YAAY;EAC1CC,SAAS,GAAG,GAAG;EACfC,YAAY,GAAG,CA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,CAAC/D,aAAa,EAAEM,SAAS,EAAEU,qBAAqB,EAAEF,kBAAkB,CAAC,CAAC;EAEzE3B,SAAS,CAAC,MAAM;IACZ,IAAI,CAACgB,SAAS,EAAE;IAEhBkB,SAAS,CAAC,mBACN7B,YAAY,cACRP,KAAA,CAAA+E,aAAA,CAACtE,sBAAsB;MACnBkC,WAAW,EAAEA,WAAY;MACzBhB,SAAS,EAAE2B,oBAAqB;MAChC0B,iBAAiB,EAAEnD,kBAAmB;MACtCY,SAAS,EAAEA;IAAU,gBAErBzC,KAAA,CAAA+E,aAAA,CAACzE,gCAAgC;MAC7B2E,MAAM,EAAEvC,KAAM;MACdwC,SAAS,EAAE1D,YAAa;MACxB2D,UAAU,EAAE5D,SAAU;MACtB6D,UAAU,EAAE/D,SAAU;MACtBgB,GAAG,EAAEA;IAAI,GAERpB,QAC6B,CACd,CAAC,EACzBC,SACJ,CACJ,CAAC;EACL,CAAC,EAAE,CACCD,QAAQ,EACRC,SAAS,EACTyB,WAAW,EACXtB,SAAS,EACTiC,oBAAoB,EACpB/B,SAAS,EACTC,YAAY,EACZK,kBAAkB,EAClBY,SAAS,EACTC,KAAK,CACR,CAAC;EAEF,oBAAO1C,KAAA,CAAA+E,aAAA,CAAC1E,yBAAyB,QAAE8B,MAAkC,CAAC;AAC1E,CAAC;AAEDrB,mBAAmB,CAACuE,WAAW,GAAG,qBAAqB;AAEvD,eAAevE,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"DropdownBodyWrapper.js","names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","StyledDropdownBodyWrapper","StyledDropdownBodyWrapperContent","createPortal","DropdownDirection","DelayedDropdownContent","useDropdown","useDropdownListener","ContainerAnchor","useContainer","DropdownBodyWrapper","anchorElement","bodyWidth","children","container","containerProp","contentHeight","direction","BOTTOM_RIGHT","maxHeight","minBodyWidth","onClose","onOutsideClick","onMeasure","shouldCaptureEvents","shouldShowDropdown","ref","isInChaynsWalletRef","measuredContentHeight","setMeasuredContentHeight","measuredContentWidth","setMeasuredContentWidth","portal","setPortal","contentRef","shouldPreventClickRef","touchTimeoutRef","undefined","transform","width","coordinates","contentWidth","handleClose","handleClick","event","current","contains","target","preventDefault","stopPropagation","shouldPreventCloseOnClick","handleContentMeasure","measurements","height","handleTouchEnd","clearTimeout","handleTouchStart","window","setTimeout","onClick","onTouchEnd","onTouchStart","isBottomDirection","BOTTOM","BOTTOM_LEFT","includes","reservationWrapperElement","closest","RESERVATION_WRAPPER","availableHeight","innerHeight","getBoundingClientRect","bottom","additionalNeededSpace","style","marginBottom","createElement","shouldShowContent","$width","$minWidth","$maxHeight","$direction","className","tabIndex","displayName"],"sources":["../../../../src/components/dropdown-body-wrapper/DropdownBodyWrapper.tsx"],"sourcesContent":["import React, {\n forwardRef,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledDropdownBodyWrapper,\n StyledDropdownBodyWrapperContent,\n} from './DropdownBodyWrapper.styles';\nimport { createPortal } from 'react-dom';\nimport { DropdownDirection, DropdownMeasurements } from '../../types/dropdown';\nimport DelayedDropdownContent, {\n DelayedDropdownContentProps,\n} from './delayed-dropdown-content/DelayedDropdownContent';\nimport { useDropdown, useDropdownListener } from '../../hooks/dropdown';\nimport { ContainerAnchor, useContainer } from '../../hooks/container';\n\ninterface DropdownBodyWrapperProps {\n /**\n * The anchor element of the dropdown.\n */\n anchorElement: Element;\n /**\n * The width of the Body.\n */\n bodyWidth?: number;\n /**\n * The content of the dropdown body.\n */\n children: ReactNode;\n /**\n * The element where the content should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The height of the content\n */\n contentHeight?: number;\n /**\n * The direction of the dropdown.\n */\n direction?: DropdownDirection;\n /**\n * The max height of the dropdown.\n */\n maxHeight?: number;\n /**\n * The minimum width of the body.\n */\n minBodyWidth?: number;\n /**\n * Function to be executed when the body is closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the user clicks outside the dropdown.\n * If the function returns `true`, the dropdown will not be closed.\n */\n onOutsideClick?: () => boolean | void;\n /**\n * Function to be executed when the content is measured.\n */\n onMeasure?: DelayedDropdownContentProps['onMeasure'];\n /**\n * Whether the dropdown should be visible.\n */\n shouldShowDropdown: boolean;\n /**\n * Whether the outside events should be captured.\n */\n shouldCaptureEvents?: boolean;\n}\n\nconst DropdownBodyWrapper = forwardRef<HTMLDivElement, DropdownBodyWrapperProps>(\n (\n {\n anchorElement,\n bodyWidth,\n children,\n container: containerProp,\n contentHeight = 0,\n direction = DropdownDirection.BOTTOM_RIGHT,\n maxHeight,\n minBodyWidth = 0,\n onClose,\n onOutsideClick,\n onMeasure,\n shouldCaptureEvents = true,\n shouldShowDropdown,\n },\n ref,\n ) => {\n const isInChaynsWalletRef = useRef(false);\n\n const [measuredContentHeight, setMeasuredContentHeight] = useState<number>(0);\n const [measuredContentWidth, setMeasuredContentWidth] = useState<number>(0);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const contentRef = useRef<HTMLDivElement>(null);\n const shouldPreventClickRef = useRef<boolean>(false);\n const touchTimeoutRef = useRef<number | undefined>(undefined);\n\n const container = useContainer({ anchorElement, container: containerProp });\n\n const { transform, width, coordinates } = useDropdown({\n anchorElement,\n container,\n contentHeight,\n contentWidth: bodyWidth ?? measuredContentWidth,\n direction,\n shouldShowDropdown,\n });\n\n const handleClose = useCallback(() => {\n if (typeof onClose === 'function') {\n onClose();\n }\n }, [onClose]);\n\n /**\n * This function closes the body\n */\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (\n contentRef.current &&\n shouldShowDropdown &&\n !anchorElement.contains(event.target as Node) &&\n !contentRef.current.contains(event.target as Node)\n ) {\n event.preventDefault();\n event.stopPropagation();\n\n const shouldPreventCloseOnClick = onOutsideClick?.() ?? false;\n\n if (!shouldPreventClickRef.current && !shouldPreventCloseOnClick) {\n handleClose();\n }\n }\n\n shouldPreventClickRef.current = false;\n },\n [anchorElement, handleClose, onOutsideClick, shouldShowDropdown],\n );\n\n const handleContentMeasure = useCallback(\n (measurements: DropdownMeasurements) => {\n // Measurements are only needed if the content is shown in the chayns wallet. To prevent\n // unnecessary renders, we only set the height if the content is shown in the wallet.\n if (isInChaynsWalletRef.current) {\n setMeasuredContentHeight(measurements.height);\n }\n\n setMeasuredContentWidth(measurements.width);\n\n if (typeof onMeasure === 'function') {\n onMeasure(measurements);\n }\n },\n [onMeasure],\n );\n\n const handleTouchEnd = useCallback(() => {\n clearTimeout(touchTimeoutRef.current);\n }, []);\n\n const handleTouchStart = useCallback(() => {\n touchTimeoutRef.current = window.setTimeout(() => {\n shouldPreventClickRef.current = true;\n }, 500);\n }, []);\n\n /**\n * This hook listens for clicks\n */\n useDropdownListener({\n onClick: handleClick,\n onClose: handleClose,\n onTouchEnd: handleTouchEnd,\n onTouchStart: handleTouchStart,\n shouldCaptureEvents,\n });\n\n useEffect(() => {\n const isBottomDirection = [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes(direction);\n\n const reservationWrapperElement = anchorElement.closest<HTMLDivElement>(\n ContainerAnchor.RESERVATION_WRAPPER,\n );\n\n isInChaynsWalletRef.current =\n !!(\n reservationWrapperElement && reservationWrapperElement.contains(anchorElement)\n ) || true;\n\n // This effect checks if additional space is needed to show dropdown content in chayns cards.\n if (\n isBottomDirection &&\n isInChaynsWalletRef.current &&\n measuredContentHeight > 0 &&\n reservationWrapperElement &&\n shouldShowDropdown\n ) {\n const availableHeight =\n window.innerHeight - anchorElement.getBoundingClientRect().bottom;\n\n // If the content height is greater than the available height, we need to add additional space.\n // This is to ensure that the dropdown content is fully visible. The 16 pixels are a buffer for shadows.\n const additionalNeededSpace = measuredContentHeight + 16 - availableHeight;\n\n if (additionalNeededSpace > 0) {\n // Add margin bottom to the reservation wrapper to ensure the dropdown content is fully visible.\n reservationWrapperElement.style.marginBottom = `${additionalNeededSpace}px`;\n } else {\n // Reset the margin bottom if no additional space is needed.\n reservationWrapperElement.style.marginBottom = '0px';\n }\n }\n\n if (isInChaynsWalletRef.current && reservationWrapperElement && !shouldShowDropdown) {\n // Reset the margin bottom when the dropdown is closed.\n reservationWrapperElement.style.marginBottom = '0px';\n }\n\n return () => {\n if (reservationWrapperElement) {\n reservationWrapperElement.style.marginBottom = '0px';\n }\n };\n }, [anchorElement, direction, measuredContentHeight, shouldShowDropdown]);\n\n useEffect(() => {\n if (!container) return;\n\n setPortal(() =>\n createPortal(\n <DelayedDropdownContent\n coordinates={coordinates}\n onMeasure={handleContentMeasure}\n shouldShowContent={shouldShowDropdown}\n transform={transform}\n >\n <StyledDropdownBodyWrapperContent\n $width={width}\n $minWidth={minBodyWidth}\n $maxHeight={maxHeight}\n $direction={direction}\n ref={contentRef}\n className={\n typeof maxHeight === 'number' ? 'chayns-scrollbar' : undefined\n }\n tabIndex={0}\n >\n {children}\n </StyledDropdownBodyWrapperContent>\n </DelayedDropdownContent>,\n container,\n ),\n );\n }, [\n children,\n container,\n coordinates,\n direction,\n handleContentMeasure,\n maxHeight,\n minBodyWidth,\n shouldShowDropdown,\n transform,\n width,\n ]);\n\n useImperativeHandle(ref, () => contentRef.current!, []);\n\n return <StyledDropdownBodyWrapper>{portal}</StyledDropdownBodyWrapper>;\n },\n);\n\nDropdownBodyWrapper.displayName = 'DropdownBodyWrapper';\n\nexport default DropdownBodyWrapper;\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,UAAU,EAGVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SACIC,yBAAyB,EACzBC,gCAAgC,QAC7B,8BAA8B;AACrC,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,iBAAiB,QAA8B,sBAAsB;AAC9E,OAAOC,sBAAsB,MAEtB,mDAAmD;AAC1D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,sBAAsB;AACvE,SAASC,eAAe,EAAEC,YAAY,QAAQ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ACJ,CAAC;AAEDtB,mBAAmB,CAAC0E,WAAW,GAAG,qBAAqB;AAEvD,eAAe1E,mBAAmB","ignoreList":[]}
@@ -5,19 +5,25 @@ export const StyledDropdownBodyWrapperContent = styled.div`
5
5
  width: ${({
6
6
  $width
7
7
  }) => $width}px;
8
- max-height: ${({
9
- $maxHeight
10
- }) => $maxHeight}px;
11
8
  min-width: ${({
12
9
  $minWidth
13
10
  }) => $minWidth}px;
14
11
 
12
+ overflow: hidden;
13
+
14
+ ${({
15
+ $maxHeight
16
+ }) => typeof $maxHeight === 'number' && css`
17
+ max-height: ${$maxHeight}px;
18
+ overflow-y: auto;
19
+ overflow-x: hidden;
20
+ `}
21
+
15
22
  // Basic styles
16
23
  background: ${({
17
24
  theme
18
25
  }) => theme['000']};
19
26
  border: 1px solid rgba(160, 160, 160, 0.3);
20
- overflow: hidden;
21
27
  box-shadow: 0 0 0 1px
22
28
  rgba(${({
23
29
  theme
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownBodyWrapper.styles.js","names":["styled","css","DropdownDirection","StyledDropdownBodyWrapper","div","StyledDropdownBodyWrapperContent","$width","$maxHeight","$minWidth","theme","$direction","BOTTOM","BOTTOM_LEFT","BOTTOM_RIGHT","includes"],"sources":["../../../../src/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { DropdownDirection } from '../../types/dropdown';\n\nexport const StyledDropdownBodyWrapper = styled.div``;\n\ntype StyledDropdownBodyWrapperContentProps = WithTheme<{\n $width: number;\n $maxHeight: number;\n $minWidth: number;\n $direction: DropdownDirection;\n}>;\n\nexport const StyledDropdownBodyWrapperContent = styled.div<StyledDropdownBodyWrapperContentProps>`\n width: ${({ $width }) => $width}px;\n max-height: ${({ $maxHeight }) => $maxHeight}px;\n min-width: ${({ $minWidth }) => $minWidth}px;\n\n // Basic styles\n background: ${({ theme }: StyledDropdownBodyWrapperContentProps) => theme['000']};\n border: 1px solid rgba(160, 160, 160, 0.3);\n overflow: hidden;\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledDropdownBodyWrapperContentProps) => theme['009-rgb']}, 0.08) inset;\n\n ${({ $direction }) => {\n if (\n [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes($direction)\n ) {\n return css`\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.2);\n `;\n }\n\n return css`\n border-top-left-radius: 3px;\n border-top-right-radius: 3px;\n box-shadow: 0 -3px 10px 0 rgba(0, 0, 0, 0.2);\n `;\n }}\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAE/C,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,OAAO,MAAMC,yBAAyB,GAAGH,MAAM,CAACI,GAAG,EAAE;AASrD,OAAO,MAAMC,gCAAgC,GAAGL,MAAM,CAACI,GAA0C;AACjG,aAAa,CAAC;EAAEE;AAAO,CAAC,KAAKA,MAAM;AACnC,kBAAkB,CAAC;EAAEC;AAAW,CAAC,KAAKA,UAAU;AAChD,iBAAiB,CAAC;EAAEC;AAAU,CAAC,KAAKA,SAAS;AAC7C;AACA;AACA,kBAAkB,CAAC;EAAEC;AAA6C,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACpF;AACA;AACA;AACA,eAAe,CAAC;EAAEA;AAA6C,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AACrF;AACA,MAAM,CAAC;EAAEC;AAAW,CAAC,KAAK;EAClB,IACI,CACIR,iBAAiB,CAACS,MAAM,EACxBT,iBAAiB,CAACU,WAAW,EAC7BV,iBAAiB,CAACW,YAAY,CACjC,CAACC,QAAQ,CAACJ,UAAU,CAAC,EACxB;IACE,OAAOT,GAAG;AACtB;AACA;AACA;AACA,aAAa;EACL;EAEA,OAAOA,GAAG;AAClB;AACA;AACA;AACA,SAAS;AACL,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"DropdownBodyWrapper.styles.js","names":["styled","css","DropdownDirection","StyledDropdownBodyWrapper","div","StyledDropdownBodyWrapperContent","$width","$minWidth","$maxHeight","theme","$direction","BOTTOM","BOTTOM_LEFT","BOTTOM_RIGHT","includes"],"sources":["../../../../src/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { DropdownDirection } from '../../types/dropdown';\n\nexport const StyledDropdownBodyWrapper = styled.div``;\n\ntype StyledDropdownBodyWrapperContentProps = WithTheme<{\n $width: number;\n $maxHeight?: number;\n $minWidth: number;\n $direction: DropdownDirection;\n}>;\n\nexport const StyledDropdownBodyWrapperContent = styled.div<StyledDropdownBodyWrapperContentProps>`\n width: ${({ $width }) => $width}px;\n min-width: ${({ $minWidth }) => $minWidth}px;\n\n overflow: hidden;\n\n ${({ $maxHeight }) =>\n typeof $maxHeight === 'number' &&\n css`\n max-height: ${$maxHeight}px;\n overflow-y: auto;\n overflow-x: hidden;\n `}\n\n // Basic styles\n background: ${({ theme }: StyledDropdownBodyWrapperContentProps) => theme['000']};\n border: 1px solid rgba(160, 160, 160, 0.3);\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledDropdownBodyWrapperContentProps) => theme['009-rgb']}, 0.08) inset;\n\n ${({ $direction }) => {\n if (\n [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes($direction)\n ) {\n return css`\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.2);\n `;\n }\n\n return css`\n border-top-left-radius: 3px;\n border-top-right-radius: 3px;\n box-shadow: 0 -3px 10px 0 rgba(0, 0, 0, 0.2);\n `;\n }}\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAE/C,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,OAAO,MAAMC,yBAAyB,GAAGH,MAAM,CAACI,GAAG,EAAE;AASrD,OAAO,MAAMC,gCAAgC,GAAGL,MAAM,CAACI,GAA0C;AACjG,aAAa,CAAC;EAAEE;AAAO,CAAC,KAAKA,MAAM;AACnC,iBAAiB,CAAC;EAAEC;AAAU,CAAC,KAAKA,SAAS;AAC7C;AACA;AACA;AACA,MAAM,CAAC;EAAEC;AAAW,CAAC,KACb,OAAOA,UAAU,KAAK,QAAQ,IAC9BP,GAAG;AACX,0BAA0BO,UAAU;AACpC;AACA;AACA,SAAS;AACT;AACA;AACA,kBAAkB,CAAC;EAAEC;AAA6C,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACpF;AACA;AACA,eAAe,CAAC;EAAEA;AAA6C,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AACrF;AACA,MAAM,CAAC;EAAEC;AAAW,CAAC,KAAK;EAClB,IACI,CACIR,iBAAiB,CAACS,MAAM,EACxBT,iBAAiB,CAACU,WAAW,EAC7BV,iBAAiB,CAACW,YAAY,CACjC,CAACC,QAAQ,CAACJ,UAAU,CAAC,EACxB;IACE,OAAOT,GAAG;AACtB;AACA;AACA;AACA,aAAa;EACL;EAEA,OAAOA,GAAG;AAClB;AACA;AACA;AACA,SAAS;AACL,CAAC;AACL,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export const FILTER_CONTENT_ROW_GAP_PX = 10;
2
+ //# sourceMappingURL=FilterContent.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterContent.constants.js","names":["FILTER_CONTENT_ROW_GAP_PX"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.constants.ts"],"sourcesContent":["export const FILTER_CONTENT_ROW_GAP_PX = 10;\n"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,GAAG,EAAE","ignoreList":[]}
@@ -1,6 +1,5 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { StyledFilterComboboxInline, StyledFilterComboboxInlineComboboxWrapper, StyledFilterComboboxInlineLabel, StyledFilterComboboxWrapper, StyledFilterContent, StyledFilterSort, StyledFilterSortText } from './FilterContent.styles';
1
+ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
2
+ import { StyledFilterContentControlWrapper, StyledFilterContentLabel, StyledFilterContentLabeledRow, StyledFilterContent } from './FilterContent.styles';
4
3
  import Input from '../../input/Input';
5
4
  import Icon from '../../icon/Icon';
6
5
  import FilterButtons from '../../filter-buttons/FilterButtons';
@@ -8,6 +7,7 @@ import ComboBox from '../../combobox/ComboBox';
8
7
  import Checkbox from '../../checkbox/Checkbox';
9
8
  import { Textstring, TextstringProvider, ttsToITextString } from '@chayns-components/textstring';
10
9
  import textStrings from '../../../constants/textStrings';
10
+ import { getSortComboBoxLists } from './FilterContent.utils';
11
11
  const FilterContent = ({
12
12
  searchConfig,
13
13
  sortConfig,
@@ -16,9 +16,7 @@ const FilterContent = ({
16
16
  comboboxConfig,
17
17
  shouldAutoFocus
18
18
  }) => {
19
- const sortTextRef = useRef(null);
20
19
  const searchRef = useRef(null);
21
- const [sortTextWidth, setSortTextWidth] = useState(0);
22
20
  const ts = textStrings.components.filter.filterContent;
23
21
  const handleSelectSortItem = useCallback(item => {
24
22
  if (!item) {
@@ -35,11 +33,6 @@ const FilterContent = ({
35
33
  });
36
34
  }
37
35
  }, [sortConfig]);
38
- useEffect(() => {
39
- if (sortTextRef.current) {
40
- setSortTextWidth(sortTextRef.current.clientWidth + 20);
41
- }
42
- }, []);
43
36
  useEffect(() => {
44
37
  if (shouldAutoFocus) {
45
38
  searchRef.current?.focus();
@@ -58,34 +51,20 @@ const FilterContent = ({
58
51
  leftElement: /*#__PURE__*/React.createElement(Icon, {
59
52
  icons: ['fa fa-search']
60
53
  })
61
- }), filterButtonConfig && /*#__PURE__*/React.createElement(FilterButtons, filterButtonConfig), sortConfig && /*#__PURE__*/React.createElement(StyledFilterSort, null, /*#__PURE__*/React.createElement(StyledFilterSortText, {
62
- ref: sortTextRef
63
- }, /*#__PURE__*/React.createElement(Textstring, {
54
+ }), filterButtonConfig && /*#__PURE__*/React.createElement(FilterButtons, filterButtonConfig), sortConfig && /*#__PURE__*/React.createElement(StyledFilterContentLabeledRow, null, /*#__PURE__*/React.createElement(StyledFilterContentLabel, null, /*#__PURE__*/React.createElement(Textstring, {
64
55
  textstring: ttsToITextString(ts.sort)
65
- })), /*#__PURE__*/React.createElement(StyledFilterComboboxWrapper, {
66
- $textWidth: sortTextWidth
67
- }, /*#__PURE__*/React.createElement(ComboBox, {
68
- lists: [{
69
- list: sortConfig.items.map(({
70
- text,
71
- id
72
- }) => ({
73
- text,
74
- value: id
75
- }))
76
- }],
56
+ })), /*#__PURE__*/React.createElement(StyledFilterContentControlWrapper, null, /*#__PURE__*/React.createElement(ComboBox, {
57
+ lists: getSortComboBoxLists(sortConfig),
77
58
  placeholder: "",
78
59
  selectedItem: {
79
60
  text: sortConfig.selectedItem.text,
80
61
  value: sortConfig.selectedItem.id
81
62
  },
82
63
  onSelect: handleSelectSortItem
83
- }))), comboboxConfig && /*#__PURE__*/React.createElement(StyledFilterComboboxInline, null, /*#__PURE__*/React.createElement(StyledFilterComboboxInlineLabel, null, comboboxConfig.label), /*#__PURE__*/React.createElement(StyledFilterComboboxInlineComboboxWrapper, null, /*#__PURE__*/React.createElement(ComboBox, _extends({
84
- shouldUseCurrentItemWidth: true
85
- }, comboboxConfig)))), checkboxConfig &&
64
+ }))), comboboxConfig && /*#__PURE__*/React.createElement(StyledFilterContentLabeledRow, null, /*#__PURE__*/React.createElement(StyledFilterContentLabel, null, comboboxConfig.label), /*#__PURE__*/React.createElement(StyledFilterContentControlWrapper, null, /*#__PURE__*/React.createElement(ComboBox, comboboxConfig))), checkboxConfig &&
86
65
  /*#__PURE__*/
87
66
  // eslint-disable-next-line react/jsx-props-no-spreading
88
- React.createElement(Checkbox, checkboxConfig))), [checkboxConfig, comboboxConfig, filterButtonConfig, handleSelectSortItem, searchConfig, sortConfig, sortTextWidth, ts.input.placeholder, ts.sort]);
67
+ React.createElement(Checkbox, checkboxConfig))), [checkboxConfig, comboboxConfig, filterButtonConfig, handleSelectSortItem, searchConfig, sortConfig, ts.input.placeholder, ts.sort]);
89
68
  };
90
69
  FilterContent.displayName = 'FilterContent';
91
70
  export default FilterContent;
@@ -1 +1 @@
1
- {"version":3,"file":"FilterContent.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","StyledFilterComboboxInline","StyledFilterComboboxInlineComboboxWrapper","StyledFilterComboboxInlineLabel","StyledFilterComboboxWrapper","StyledFilterContent","StyledFilterSort","StyledFilterSortText","Input","Icon","FilterButtons","ComboBox","Checkbox","Textstring","TextstringProvider","ttsToITextString","textStrings","FilterContent","searchConfig","sortConfig","filterButtonConfig","checkboxConfig","comboboxConfig","shouldAutoFocus","sortTextRef","searchRef","sortTextWidth","setSortTextWidth","ts","components","filter","filterContent","handleSelectSortItem","item","text","value","onSortChange","id","current","clientWidth","focus","createElement","libraryName","ref","onChange","ev","onSearchChange","target","placeholder","textstring","input","searchValue","shouldShowClearIcon","length","leftElement","icons","sort","$textWidth","lists","list","items","map","selectedItem","onSelect","label","_extends","shouldUseCurrentItemWidth","displayName"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n StyledFilterComboboxInline,\n StyledFilterComboboxInlineComboboxWrapper,\n StyledFilterComboboxInlineLabel,\n StyledFilterComboboxWrapper,\n StyledFilterContent,\n StyledFilterSort,\n StyledFilterSortText,\n} from './FilterContent.styles';\nimport Input, { InputRef } from '../../input/Input';\nimport Icon from '../../icon/Icon';\nimport FilterButtons from '../../filter-buttons/FilterButtons';\nimport {\n CheckboxConfig,\n ComboboxConfig,\n FilterButtonConfig,\n SearchConfig,\n SortConfig,\n} from '../../../types/filter';\nimport ComboBox from '../../combobox/ComboBox';\nimport Checkbox from '../../checkbox/Checkbox';\nimport { IComboBoxItem } from '../../combobox/ComboBox.types';\nimport { Textstring, TextstringProvider, ttsToITextString } from '@chayns-components/textstring';\nimport textStrings from '../../../constants/textStrings';\n\nexport type FilterContentProps = {\n searchConfig?: SearchConfig;\n filterButtonConfig?: FilterButtonConfig;\n sortConfig?: SortConfig;\n checkboxConfig?: CheckboxConfig;\n comboboxConfig?: ComboboxConfig;\n shouldAutoFocus: boolean;\n};\n\nconst FilterContent: FC<FilterContentProps> = ({\n searchConfig,\n sortConfig,\n filterButtonConfig,\n checkboxConfig,\n comboboxConfig,\n shouldAutoFocus,\n}) => {\n const sortTextRef = useRef<HTMLDivElement>(null);\n const searchRef = useRef<InputRef>(null);\n\n const [sortTextWidth, setSortTextWidth] = useState(0);\n\n const ts = textStrings.components.filter.filterContent;\n\n const handleSelectSortItem = useCallback(\n (item: IComboBoxItem | undefined) => {\n if (!item) {\n return;\n }\n\n const { text, value } = item;\n\n if (sortConfig) {\n sortConfig.onSortChange({ text, id: value });\n }\n },\n [sortConfig],\n );\n\n useEffect(() => {\n if (sortTextRef.current) {\n setSortTextWidth(sortTextRef.current.clientWidth + 20);\n }\n }, []);\n\n useEffect(() => {\n if (shouldAutoFocus) {\n searchRef.current?.focus();\n }\n }, [shouldAutoFocus]);\n\n return useMemo(\n () => (\n <TextstringProvider libraryName=\"@chayns-components-core\">\n <StyledFilterContent>\n {searchConfig && (\n <Input\n ref={searchRef}\n onChange={(ev) => searchConfig.onSearchChange(ev.target.value)}\n placeholder={\n <Textstring textstring={ttsToITextString(ts.input.placeholder)} />\n }\n value={searchConfig.searchValue}\n shouldShowClearIcon={searchConfig.searchValue.length > 0}\n leftElement={<Icon icons={['fa fa-search']} />}\n />\n )}\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n {filterButtonConfig && <FilterButtons {...filterButtonConfig} />}\n {sortConfig && (\n <StyledFilterSort>\n <StyledFilterSortText ref={sortTextRef}>\n <Textstring textstring={ttsToITextString(ts.sort)} />\n </StyledFilterSortText>\n <StyledFilterComboboxWrapper $textWidth={sortTextWidth}>\n <ComboBox\n lists={[\n {\n list: sortConfig.items.map(({ text, id }) => ({\n text,\n value: id,\n })),\n },\n ]}\n placeholder=\"\"\n selectedItem={{\n text: sortConfig.selectedItem.text,\n value: sortConfig.selectedItem.id,\n }}\n onSelect={handleSelectSortItem}\n />\n </StyledFilterComboboxWrapper>\n </StyledFilterSort>\n )}\n {comboboxConfig && (\n <StyledFilterComboboxInline>\n <StyledFilterComboboxInlineLabel>\n {comboboxConfig.label}\n </StyledFilterComboboxInlineLabel>\n <StyledFilterComboboxInlineComboboxWrapper>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <ComboBox shouldUseCurrentItemWidth {...comboboxConfig} />\n </StyledFilterComboboxInlineComboboxWrapper>\n </StyledFilterComboboxInline>\n )}\n {checkboxConfig && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <Checkbox {...checkboxConfig} />\n )}\n </StyledFilterContent>\n </TextstringProvider>\n ),\n [\n checkboxConfig,\n comboboxConfig,\n filterButtonConfig,\n handleSelectSortItem,\n searchConfig,\n sortConfig,\n sortTextWidth,\n ts.input.placeholder,\n ts.sort,\n ],\n );\n};\n\nFilterContent.displayName = 'FilterContent';\n\nexport default FilterContent;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAQC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACpF,SACIC,0BAA0B,EAC1BC,yCAAyC,EACzCC,+BAA+B,EAC/BC,2BAA2B,EAC3BC,mBAAmB,E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aAAA,CAAC9B,QAAQ;IACL+C,KAAK,EAAE,CACH;MACIC,IAAI,EAAExC,UAAU,CAACyC,KAAK,CAACC,GAAG,CAAC,CAAC;QAAE3B,IAAI;QAAEG;MAAG,CAAC,MAAM;QAC1CH,IAAI;QACJC,KAAK,EAAEE;MACX,CAAC,CAAC;IACN,CAAC,CACH;IACFW,WAAW,EAAC,EAAE;IACdc,YAAY,EAAE;MACV5B,IAAI,EAAEf,UAAU,CAAC2C,YAAY,CAAC5B,IAAI;MAClCC,KAAK,EAAEhB,UAAU,CAAC2C,YAAY,CAACzB;IACnC,CAAE;IACF0B,QAAQ,EAAE/B;EAAqB,CAClC,CACwB,CACf,CACrB,EACAV,cAAc,iBACX3B,KAAA,CAAA8C,aAAA,CAACxC,0BAA0B,qBACvBN,KAAA,CAAA8C,aAAA,CAACtC,+BAA+B,QAC3BmB,cAAc,CAAC0C,KACa,CAAC,eAClCrE,KAAA,CAAA8C,aAAA,CAACvC,yCAAyC,qBAEtCP,KAAA,CAAA8C,aAAA,CAAC9B,QAAQ,EAAAsD,QAAA;IAACC,yBAAyB;EAAA,GAAK5C,cAAc,CAAG,CAClB,CACnB,CAC/B,EACAD,cAAc;EAAA;EACX;EACA1B,KAAA,CAAA8C,aAAA,CAAC7B,QAAQ,EAAKS,cAAiB,CAElB,CACL,CACvB,EACD,CACIA,cAAc,EACdC,cAAc,EACdF,kBAAkB,EAClBY,oBAAoB,EACpBd,YAAY,EACZC,UAAU,EACVO,aAAa,EACbE,EAAE,CAACsB,KAAK,CAACF,WAAW,EACpBpB,EAAE,CAAC4B,IAAI,CAEf,CAAC;AACL,CAAC;AAEDvC,aAAa,CAACkD,WAAW,GAAG,eAAe;AAE3C,eAAelD,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"FilterContent.js","names":["React","useCallback","useEffect","useMemo","useRef","StyledFilterContentControlWrapper","StyledFilterContentLabel","StyledFilterContentLabeledRow","StyledFilterContent","Input","Icon","FilterButtons","ComboBox","Checkbox","Textstring","TextstringProvider","ttsToITextString","textStrings","getSortComboBoxLists","FilterContent","searchConfig","sortConfig","filterButtonConfig","checkboxConfig","comboboxConfig","shouldAutoFocus","searchRef","ts","components","filter","filterContent","handleSelectSortItem","item","text","value","onSortChange","id","current","focus","createElement","libraryName","ref","onChange","ev","onSearchChange","target","placeholder","textstring","input","searchValue","shouldShowClearIcon","length","leftElement","icons","sort","lists","selectedItem","onSelect","label","displayName"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo, useRef } from 'react';\nimport {\n StyledFilterContentControlWrapper,\n StyledFilterContentLabel,\n StyledFilterContentLabeledRow,\n StyledFilterContent,\n} from './FilterContent.styles';\nimport Input, { InputRef } from '../../input/Input';\nimport Icon from '../../icon/Icon';\nimport FilterButtons from '../../filter-buttons/FilterButtons';\nimport ComboBox from '../../combobox/ComboBox';\nimport Checkbox from '../../checkbox/Checkbox';\nimport { Textstring, TextstringProvider, ttsToITextString } from '@chayns-components/textstring';\nimport textStrings from '../../../constants/textStrings';\nimport type { IComboBoxItem } from '../../combobox/ComboBox.types';\nimport type { FilterContentProps } from './FilterContent.types';\nimport { getSortComboBoxLists } from './FilterContent.utils';\n\nconst FilterContent: FC<FilterContentProps> = ({\n searchConfig,\n sortConfig,\n filterButtonConfig,\n checkboxConfig,\n comboboxConfig,\n shouldAutoFocus,\n}) => {\n const searchRef = useRef<InputRef>(null);\n\n const ts = textStrings.components.filter.filterContent;\n\n const handleSelectSortItem = useCallback(\n (item: IComboBoxItem | undefined) => {\n if (!item) {\n return;\n }\n\n const { text, value } = item;\n\n if (sortConfig) {\n sortConfig.onSortChange({ text, id: value });\n }\n },\n [sortConfig],\n );\n\n useEffect(() => {\n if (shouldAutoFocus) {\n searchRef.current?.focus();\n }\n }, [shouldAutoFocus]);\n\n return useMemo(\n () => (\n <TextstringProvider libraryName=\"@chayns-components-core\">\n <StyledFilterContent>\n {searchConfig && (\n <Input\n ref={searchRef}\n onChange={(ev) => searchConfig.onSearchChange(ev.target.value)}\n placeholder={\n <Textstring textstring={ttsToITextString(ts.input.placeholder)} />\n }\n value={searchConfig.searchValue}\n shouldShowClearIcon={searchConfig.searchValue.length > 0}\n leftElement={<Icon icons={['fa fa-search']} />}\n />\n )}\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n {filterButtonConfig && <FilterButtons {...filterButtonConfig} />}\n {sortConfig && (\n <StyledFilterContentLabeledRow>\n <StyledFilterContentLabel>\n <Textstring textstring={ttsToITextString(ts.sort)} />\n </StyledFilterContentLabel>\n <StyledFilterContentControlWrapper>\n <ComboBox\n lists={getSortComboBoxLists(sortConfig)}\n placeholder=\"\"\n selectedItem={{\n text: sortConfig.selectedItem.text,\n value: sortConfig.selectedItem.id,\n }}\n onSelect={handleSelectSortItem}\n />\n </StyledFilterContentControlWrapper>\n </StyledFilterContentLabeledRow>\n )}\n {comboboxConfig && (\n <StyledFilterContentLabeledRow>\n <StyledFilterContentLabel>\n {comboboxConfig.label}\n </StyledFilterContentLabel>\n <StyledFilterContentControlWrapper>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <ComboBox {...comboboxConfig} />\n </StyledFilterContentControlWrapper>\n </StyledFilterContentLabeledRow>\n )}\n {checkboxConfig && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <Checkbox {...checkboxConfig} />\n )}\n </StyledFilterContent>\n </TextstringProvider>\n ),\n [\n checkboxConfig,\n comboboxConfig,\n filterButtonConfig,\n handleSelectSortItem,\n searchConfig,\n sortConfig,\n ts.input.placeholder,\n ts.sort,\n ],\n );\n};\n\nFilterContent.displayName = 'FilterContent';\n\nexport default FilterContent;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAQC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC1E,SACIC,iCAAiC,EACjCC,wBAAwB,EACxBC,6BAA6B,EAC7BC,mBAAmB,QAChB,wBAAwB;AAC/B,OAAOC,K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BkB,cAAc,CAACkC,KACM,CAAC,eAC3B1D,KAAA,CAAAuC,aAAA,CAAClC,iCAAiC,qBAE9BL,KAAA,CAAAuC,aAAA,CAAC3B,QAAQ,EAAKY,cAAiB,CACA,CACR,CAClC,EACAD,cAAc;EAAA;EACX;EACAvB,KAAA,CAAAuC,aAAA,CAAC1B,QAAQ,EAAKU,cAAiB,CAElB,CACL,CACvB,EACD,CACIA,cAAc,EACdC,cAAc,EACdF,kBAAkB,EAClBS,oBAAoB,EACpBX,YAAY,EACZC,UAAU,EACVM,EAAE,CAACqB,KAAK,CAACF,WAAW,EACpBnB,EAAE,CAAC2B,IAAI,CAEf,CAAC;AACL,CAAC;AAEDnC,aAAa,CAACwC,WAAW,GAAG,eAAe;AAE3C,eAAexC,aAAa","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import styled from 'styled-components';
2
+ import { FILTER_CONTENT_ROW_GAP_PX } from './FilterContent.constants';
2
3
  export const StyledFilterContent = styled.div`
3
4
  background-color: ${({
4
5
  theme
@@ -10,36 +11,21 @@ export const StyledFilterContent = styled.div`
10
11
  flex-direction: column;
11
12
  gap: 10px;
12
13
  `;
13
- export const StyledFilterSort = styled.div`
14
+ export const StyledFilterContentLabeledRow = styled.div`
14
15
  display: flex;
15
16
  align-items: center;
16
- justify-content: space-between;
17
- gap: 10px;
18
- `;
19
- export const StyledFilterSortText = styled.div`
20
- flex: 0 0 auto;
21
- `;
22
- export const StyledFilterComboboxWrapper = styled.div`
23
- display: flex;
24
- justify-content: end;
25
-
26
- width: ${({
27
- $textWidth
28
- }) => `calc(100% - ${$textWidth}px)`}}
29
- `;
30
- export const StyledFilterComboboxInline = styled.div`
31
- display: flex;
32
- justify-content: space-between;
33
- align-items: center;
34
- gap: 10px;
17
+ gap: ${FILTER_CONTENT_ROW_GAP_PX}px;
18
+ width: 100%;
19
+ min-width: 0;
35
20
  `;
36
- export const StyledFilterComboboxInlineLabel = styled.div`
21
+ export const StyledFilterContentLabel = styled.div`
37
22
  flex: 0 0 auto;
23
+ white-space: nowrap;
38
24
  `;
39
- export const StyledFilterComboboxInlineComboboxWrapper = styled.div`
25
+ export const StyledFilterContentControlWrapper = styled.div`
40
26
  display: flex;
41
- justify-content: end;
42
27
  flex: 1 1 auto;
43
28
  min-width: 0;
29
+ justify-content: flex-end;
44
30
  `;
45
31
  //# sourceMappingURL=FilterContent.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterContent.styles.js","names":["styled","StyledFilterContent","div","theme","StyledFilterSort","StyledFilterSortText","StyledFilterComboboxWrapper","$textWidth","StyledFilterComboboxInline","StyledFilterComboboxInlineLabel","StyledFilterComboboxInlineComboboxWrapper"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledFilterContentProps = WithTheme<unknown>;\n\nexport const StyledFilterContent = styled.div<StyledFilterContentProps>`\n background-color: ${({ theme }) => theme['100']};\n\n padding: 12px;\n\n display: flex;\n flex-direction: column;\n gap: 10px;\n`;\n\nexport const StyledFilterSort = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n`;\n\nexport const StyledFilterSortText = styled.div`\n flex: 0 0 auto;\n`;\n\ntype StyledFilterComboboxWrapperProps = WithTheme<{\n $textWidth: number;\n}>;\n\nexport const StyledFilterComboboxWrapper = styled.div<StyledFilterComboboxWrapperProps>`\n display: flex;\n justify-content: end;\n \n width: ${({ $textWidth }) => `calc(100% - ${$textWidth}px)`}}\n`;\n\nexport const StyledFilterComboboxInline = styled.div`\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 10px;\n`;\n\nexport const StyledFilterComboboxInlineLabel = styled.div`\n flex: 0 0 auto;\n`;\n\nexport const StyledFilterComboboxInlineComboboxWrapper = styled.div`\n display: flex;\n justify-content: end;\n flex: 1 1 auto;\n min-width: 0;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAKtC,OAAO,MAAMC,mBAAmB,GAAGD,MAAM,CAACE,GAA6B;AACvE,wBAAwB,CAAC;EAAEC;AAAM,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAGJ,MAAM,CAACE,GAAG;AAC1C;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMG,oBAAoB,GAAGL,MAAM,CAACE,GAAG;AAC9C;AACA,CAAC;AAMD,OAAO,MAAMI,2BAA2B,GAAGN,MAAM,CAACE,GAAqC;AACvF;AACA;AACA;AACA,aAAa,CAAC;EAAEK;AAAW,CAAC,KAAK,eAAeA,UAAU,KAAK;AAC/D,CAAC;AAED,OAAO,MAAMC,0BAA0B,GAAGR,MAAM,CAACE,GAAG;AACpD;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMO,+BAA+B,GAAGT,MAAM,CAACE,GAAG;AACzD;AACA,CAAC;AAED,OAAO,MAAMQ,yCAAyC,GAAGV,MAAM,CAACE,GAAG;AACnE;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"FilterContent.styles.js","names":["styled","FILTER_CONTENT_ROW_GAP_PX","StyledFilterContent","div","theme","StyledFilterContentLabeledRow","StyledFilterContentLabel","StyledFilterContentControlWrapper"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { FILTER_CONTENT_ROW_GAP_PX } from './FilterContent.constants';\n\ntype StyledFilterContentProps = WithTheme<unknown>;\n\nexport const StyledFilterContent = styled.div<StyledFilterContentProps>`\n background-color: ${({ theme }) => theme['100']};\n\n padding: 12px;\n\n display: flex;\n flex-direction: column;\n gap: 10px;\n`;\n\nexport const StyledFilterContentLabeledRow = styled.div`\n display: flex;\n align-items: center;\n gap: ${FILTER_CONTENT_ROW_GAP_PX}px;\n width: 100%;\n min-width: 0;\n`;\n\nexport const StyledFilterContentLabel = styled.div`\n flex: 0 0 auto;\n white-space: nowrap;\n`;\n\nexport const StyledFilterContentControlWrapper = styled.div`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n justify-content: flex-end;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,SAASC,yBAAyB,QAAQ,2BAA2B;AAIrE,OAAO,MAAMC,mBAAmB,GAAGF,MAAM,CAACG,GAA6B;AACvE,wBAAwB,CAAC;EAAEC;AAAM,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,6BAA6B,GAAGL,MAAM,CAACG,GAAG;AACvD;AACA;AACA,WAAWF,yBAAyB;AACpC;AACA;AACA,CAAC;AAED,OAAO,MAAMK,wBAAwB,GAAGN,MAAM,CAACG,GAAG;AAClD;AACA;AACA,CAAC;AAED,OAAO,MAAMI,iCAAiC,GAAGP,MAAM,CAACG,GAAG;AAC3D;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FilterContent.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterContent.types.js","names":[],"sources":["../../../../../src/components/filter/filter-content/FilterContent.types.ts"],"sourcesContent":["import type {\n CheckboxConfig,\n ComboboxConfig,\n FilterButtonConfig,\n SearchConfig,\n SortConfig,\n} from '../../../types/filter';\n\n/**\n * Props for the `FilterContent` component.\n */\nexport type FilterContentProps = {\n /**\n * Search configuration for the optional search input.\n */\n searchConfig?: SearchConfig;\n /**\n * Configuration for the optional filter button group.\n */\n filterButtonConfig?: FilterButtonConfig;\n /**\n * Configuration for the optional sort combobox.\n */\n sortConfig?: SortConfig;\n /**\n * Configuration for the optional checkbox.\n */\n checkboxConfig?: CheckboxConfig;\n /**\n * Configuration for the optional labeled combobox.\n */\n comboboxConfig?: ComboboxConfig;\n /**\n * Whether the search input should receive focus when the filter opens.\n */\n shouldAutoFocus: boolean;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ export const getSortComboBoxLists = sortConfig => [{
2
+ list: sortConfig.items.map(({
3
+ text,
4
+ id
5
+ }) => ({
6
+ text,
7
+ value: id
8
+ }))
9
+ }];
10
+ //# sourceMappingURL=FilterContent.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterContent.utils.js","names":["getSortComboBoxLists","sortConfig","list","items","map","text","id","value"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.utils.ts"],"sourcesContent":["import type { IComboBoxItems } from '../../combobox/ComboBox.types';\nimport type { SortConfig } from '../../../types/filter';\n\nexport const getSortComboBoxLists = (sortConfig: SortConfig): IComboBoxItems[] => [\n {\n list: sortConfig.items.map(({ text, id }) => ({\n text,\n value: id,\n })),\n },\n];\n"],"mappings":"AAGA,OAAO,MAAMA,oBAAoB,GAAIC,UAAsB,IAAuB,CAC9E;EACIC,IAAI,EAAED,UAAU,CAACE,KAAK,CAACC,GAAG,CAAC,CAAC;IAAEC,IAAI;IAAEC;EAAG,CAAC,MAAM;IAC1CD,IAAI;IACJE,KAAK,EAAED;EACX,CAAC,CAAC;AACN,CAAC,CACJ","ignoreList":[]}
@@ -565,7 +565,6 @@ const SearchBox = /*#__PURE__*/forwardRef(({
565
565
  anchorElement: boxRef.current,
566
566
  container: container,
567
567
  direction: dropdownDirection,
568
- maxHeight: 300,
569
568
  onClose: handleClose,
570
569
  onOutsideClick: handleDropdownOutsideClick,
571
570
  shouldShowDropdown: shouldShowDropdown