@chayns-components/core 5.0.0-beta.974 → 5.0.0-beta.976
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 +1 -0
- package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
- package/lib/cjs/components/combobox/combobox-item/ComboBoxItem.js +3 -1
- package/lib/cjs/components/combobox/combobox-item/ComboBoxItem.js.map +1 -1
- package/lib/cjs/components/combobox/combobox-item/ComboBoxItem.styles.js +4 -0
- package/lib/cjs/components/combobox/combobox-item/ComboBoxItem.styles.js.map +1 -1
- package/lib/cjs/components/grid-image/GridImage.js +2 -0
- package/lib/cjs/components/grid-image/GridImage.js.map +1 -1
- package/lib/cjs/components/grid-image/GridImage.styles.js +3 -2
- package/lib/cjs/components/grid-image/GridImage.styles.js.map +1 -1
- package/lib/cjs/components/list/list-item/ListItem.js +2 -0
- package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
- package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js +3 -1
- package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
- package/lib/cjs/components/list/list-item/list-item-head/list-item-image/ListItemImage.js +3 -0
- package/lib/cjs/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map +1 -1
- package/lib/cjs/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js +4 -0
- package/lib/cjs/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js.map +1 -1
- package/lib/cjs/components/popup/Popup.js +11 -5
- package/lib/cjs/components/popup/Popup.js.map +1 -1
- package/lib/cjs/components/tooltip/Tooltip.js +5 -1
- package/lib/cjs/components/tooltip/Tooltip.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.js +1 -0
- package/lib/esm/components/combobox/ComboBox.js.map +1 -1
- package/lib/esm/components/combobox/combobox-item/ComboBoxItem.js +3 -1
- package/lib/esm/components/combobox/combobox-item/ComboBoxItem.js.map +1 -1
- package/lib/esm/components/combobox/combobox-item/ComboBoxItem.styles.js +17 -10
- package/lib/esm/components/combobox/combobox-item/ComboBoxItem.styles.js.map +1 -1
- package/lib/esm/components/grid-image/GridImage.js +2 -0
- package/lib/esm/components/grid-image/GridImage.js.map +1 -1
- package/lib/esm/components/grid-image/GridImage.styles.js +4 -3
- package/lib/esm/components/grid-image/GridImage.styles.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.js +2 -0
- package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
- package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js +3 -1
- package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
- package/lib/esm/components/list/list-item/list-item-head/list-item-image/ListItemImage.js +3 -0
- package/lib/esm/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map +1 -1
- package/lib/esm/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js +9 -2
- package/lib/esm/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js.map +1 -1
- package/lib/esm/components/popup/Popup.js +11 -5
- package/lib/esm/components/popup/Popup.js.map +1 -1
- package/lib/esm/components/tooltip/Tooltip.js +5 -1
- package/lib/esm/components/tooltip/Tooltip.js.map +1 -1
- package/lib/types/components/combobox/ComboBox.d.ts +1 -0
- package/lib/types/components/combobox/combobox-item/ComboBoxItem.d.ts +1 -0
- package/lib/types/components/combobox/combobox-item/ComboBoxItem.styles.d.ts +2 -0
- package/lib/types/components/grid-image/GridImage.d.ts +7 -5
- package/lib/types/components/grid-image/GridImage.styles.d.ts +2 -0
- package/lib/types/components/list/list-item/ListItem.d.ts +5 -1
- package/lib/types/components/list/list-item/list-item-head/ListItemHead.d.ts +2 -1
- package/lib/types/components/list/list-item/list-item-head/list-item-image/ListItemImage.d.ts +2 -1
- package/lib/types/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.d.ts +4 -2
- package/lib/types/components/popup/Popup.d.ts +4 -0
- package/lib/types/components/tooltip/Tooltip.d.ts +8 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemHead.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","useElementSize","Icon","ListItemIcon","ListItemImage","ListItemRightElements","StyledListItemHead","StyledListItemHeadContent","StyledListItemHeadLeftWrapper","StyledListItemHeadSubtitle","StyledListItemHeadSubtitleText","StyledListItemHeadSubtitleTextPseudo","StyledListItemHeadTitle","StyledListItemHeadTitleContent","StyledListItemHeadTitleElement","StyledListItemHeadTitleText","StyledListItemHeadTitleTextPseudo","StyledMotionListItemHeadHoverItem","StyledMotionListItemHeadIndicator","ListItemHead","_ref","hoverItem","icons","images","isAnyItemExpandable","isExpandable","isOpen","isTitleGreyed","leftElements","onClick","onLongPress","rightElements","shouldHideImageOrIconBackground","shouldHideIndicator","shouldOpenImageOnClick","shouldShowRoundImageOrIcon","subtitle","title","titleElement","shouldShowHoverItem","setShouldShowHoverItem","headHeight","setHeadHeight","closed","open","setIsFirstRender","longPressTimeoutRef","pseudoTitleOpenRef","pseudoTitleClosedRef","pseudoSubtitleOpenRef","pseudoSubtitleClosedRef","closedTitle","openedTitle","closedSubtitle","openedSubtitle","shouldShowSubtitleRow","height","handleMouseEnter","handleMouseLeave","marginTop","handleTouchStart","event","current","window","setTimeout","handleTouchEnd","clearTimeout","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","undefined","animate","opacity","initial","transition","duration","type","className","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rotate","$isIconOrImageGiven","$marginTop","$isOpen","ref","$width","width","marginLeft","displayName"],"sources":["../../../../../../src/components/list/list-item/list-item-head/ListItemHead.tsx"],"sourcesContent":["import React, {\n FC,\n MouseEventHandler,\n ReactNode,\n TouchEventHandler,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useElementSize } from '../../../../hooks/useElementSize';\nimport type { IListItemRightElements } from '../../../../types/list';\nimport Icon from '../../../icon/Icon';\nimport ListItemIcon from './list-item-icon/ListItemIcon';\nimport ListItemImage from './list-item-image/ListItemImage';\nimport ListItemRightElements from './list-item-right-elements/ListItemRightElements';\nimport {\n StyledListItemHead,\n StyledListItemHeadContent,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadSubtitleText,\n StyledListItemHeadSubtitleTextPseudo,\n StyledListItemHeadTitle,\n StyledListItemHeadTitleContent,\n StyledListItemHeadTitleElement,\n StyledListItemHeadTitleText,\n StyledListItemHeadTitleTextPseudo,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadIndicator,\n} from './ListItemHead.styles';\n\ninterface HeadHeight {\n closed: number;\n open: number;\n}\n\ntype ListItemHeadProps = {\n hoverItem?: ReactNode;\n icons?: string[];\n images?: string[];\n isAnyItemExpandable: boolean;\n isExpandable: boolean;\n isOpen: boolean;\n isTitleGreyed?: boolean;\n leftElements?: ReactNode;\n onClick?: MouseEventHandler<HTMLDivElement>;\n onLongPress?: TouchEventHandler<HTMLDivElement>;\n rightElements?: IListItemRightElements;\n shouldHideImageOrIconBackground?: boolean;\n shouldHideIndicator?: boolean;\n shouldOpenImageOnClick: boolean;\n shouldShowRoundImageOrIcon?: boolean;\n subtitle?: ReactNode;\n title: ReactNode;\n titleElement?: ReactNode;\n};\n\nconst ListItemHead: FC<ListItemHeadProps> = ({\n hoverItem,\n icons,\n images,\n isAnyItemExpandable,\n isExpandable,\n isOpen,\n isTitleGreyed,\n leftElements,\n onClick,\n onLongPress,\n rightElements,\n shouldHideImageOrIconBackground,\n shouldHideIndicator,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n subtitle,\n title,\n titleElement,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n const [headHeight, setHeadHeight] = useState<HeadHeight>({\n closed: 40,\n open: 40,\n });\n const [, setIsFirstRender] = useState(false);\n\n const longPressTimeoutRef = useRef<number>();\n const pseudoTitleOpenRef = useRef<HTMLDivElement>(null);\n const pseudoTitleClosedRef = useRef<HTMLDivElement>(null);\n const pseudoSubtitleOpenRef = useRef<HTMLDivElement>(null);\n const pseudoSubtitleClosedRef = useRef<HTMLDivElement>(null);\n\n const closedTitle = useElementSize(pseudoTitleClosedRef);\n const openedTitle = useElementSize(pseudoTitleOpenRef);\n const closedSubtitle = useElementSize(pseudoSubtitleClosedRef);\n const openedSubtitle = useElementSize(pseudoSubtitleOpenRef);\n\n const shouldShowSubtitleRow = subtitle || typeof subtitle === 'string';\n\n useEffect(() => {\n if (closedTitle && openedTitle) {\n setHeadHeight({\n closed:\n shouldShowSubtitleRow && closedSubtitle\n ? closedSubtitle.height + 4 + closedTitle.height + 24\n : closedTitle.height + 24,\n open:\n shouldShowSubtitleRow && openedSubtitle\n ? openedSubtitle.height + 4 + openedTitle.height + 24\n : openedTitle.height + 24,\n });\n }\n }, [closedSubtitle, closedTitle, openedSubtitle, openedTitle, shouldShowSubtitleRow]);\n\n // This is used to trigger a rerender, so the head height can be calculated\n useEffect(() => {\n setIsFirstRender(true);\n }, []);\n\n const handleMouseEnter = useCallback(() => setShouldShowHoverItem(true), []);\n\n const handleMouseLeave = useCallback(() => setShouldShowHoverItem(false), []);\n\n const marginTop = useMemo(() => {\n const height = headHeight[isOpen ? 'open' : 'closed'];\n\n if (height < 64) {\n return (64 - height) / 2;\n }\n\n return 0;\n }, [headHeight, isOpen]);\n\n const handleTouchStart = useCallback<TouchEventHandler<HTMLDivElement>>(\n (event) => {\n longPressTimeoutRef.current = window.setTimeout(() => {\n if (typeof onLongPress === 'function') {\n onLongPress(event);\n }\n }, 400);\n },\n [onLongPress],\n );\n\n const handleTouchEnd = useCallback(() => {\n clearTimeout(longPressTimeoutRef.current);\n }, []);\n\n const iconOrImageElement = useMemo(() => {\n if (icons) {\n return (\n <ListItemIcon\n icons={icons}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundIcon={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n if (images) {\n return (\n <ListItemImage\n images={images}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundImage={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n return undefined;\n }, [\n icons,\n images,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n return (\n <StyledListItemHead\n animate={{\n height: isOpen ? headHeight.open : headHeight.closed,\n opacity: isTitleGreyed ? 0.5 : 1,\n }}\n initial={false}\n transition={{ duration: 0.2, type: 'tween' }}\n className=\"beta-chayns-list-item-head\"\n $isClickable={typeof onClick === 'function' || isExpandable}\n $isAnyItemExpandable={isAnyItemExpandable}\n onClick={onClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onTouchStart={typeof onLongPress === 'function' ? handleTouchStart : undefined}\n onTouchEnd={typeof onLongPress === 'function' ? handleTouchEnd : undefined}\n >\n <StyledListItemHeadLeftWrapper>\n {isAnyItemExpandable && (\n <StyledMotionListItemHeadIndicator\n animate={{ rotate: isOpen ? 90 : 0 }}\n initial={false}\n transition={{ type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && (\n <Icon icons={['fa fa-chevron-right']} />\n )}\n </StyledMotionListItemHeadIndicator>\n )}\n {leftElements}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $marginTop={marginTop}\n $isOpen={isOpen}\n >\n <StyledListItemHeadTitle>\n <StyledListItemHeadTitleContent>\n <StyledListItemHeadTitleTextPseudo ref={pseudoTitleOpenRef} $isOpen>\n {title}\n </StyledListItemHeadTitleTextPseudo>\n <StyledListItemHeadTitleTextPseudo\n ref={pseudoTitleClosedRef}\n $isOpen={false}\n >\n {title}\n </StyledListItemHeadTitleTextPseudo>\n <StyledListItemHeadTitleText\n $isOpen={isOpen}\n $width={openedTitle?.width ?? 0}\n >\n {title}\n </StyledListItemHeadTitleText>\n <StyledListItemHeadTitleElement>\n {titleElement}\n </StyledListItemHeadTitleElement>\n </StyledListItemHeadTitleContent>\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <StyledListItemHeadSubtitleTextPseudo ref={pseudoSubtitleOpenRef} $isOpen>\n {subtitle}\n </StyledListItemHeadSubtitleTextPseudo>\n <StyledListItemHeadSubtitleTextPseudo\n ref={pseudoSubtitleClosedRef}\n $isOpen={false}\n >\n {subtitle}\n </StyledListItemHeadSubtitleTextPseudo>\n <StyledListItemHeadSubtitleText $isOpen={isOpen}>\n {subtitle}\n </StyledListItemHeadSubtitleText>\n </StyledListItemHeadSubtitle>\n )}\n </StyledListItemHeadContent>\n {rightElements && <ListItemRightElements rightElements={rightElements} />}\n {hoverItem && (\n <StyledMotionListItemHeadHoverItem\n animate={{\n marginLeft: shouldShowHoverItem ? 8 : 0,\n opacity: shouldShowHoverItem ? 1 : 0,\n width: shouldShowHoverItem ? 'auto' : 0,\n }}\n initial={false}\n transition={{ duration: 0.15, type: 'tween' }}\n >\n {hoverItem}\n </StyledMotionListItemHeadHoverItem>\n )}\n </StyledListItemHead>\n );\n};\n\nListItemHead.displayName = 'ListItemHead';\n\nexport default ListItemHead;\n"],"mappings":"AAAA,OAAOA,KAAK,IAKRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,cAAc,QAAQ,kCAAkC;AAEjE,OAAOC,IAAI,MAAM,oBAAoB;AACrC,OAAOC,YAAY,MAAM,+BAA+B;AACxD,OAAOC,aAAa,MAAM,iCAAiC;AAC3D,OAAOC,qBAAqB,MAAM,kDAAkD;AACpF,SACIC,kBAAkB,EAClBC,yBAAyB,EACzBC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,oCAAoC,EACpCC,uBAAuB,EACvBC,8BAA8B,EAC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Ac;AAEzC,eAAe3E,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItemHead.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","useElementSize","Icon","ListItemIcon","ListItemImage","ListItemRightElements","StyledListItemHead","StyledListItemHeadContent","StyledListItemHeadLeftWrapper","StyledListItemHeadSubtitle","StyledListItemHeadSubtitleText","StyledListItemHeadSubtitleTextPseudo","StyledListItemHeadTitle","StyledListItemHeadTitleContent","StyledListItemHeadTitleElement","StyledListItemHeadTitleText","StyledListItemHeadTitleTextPseudo","StyledMotionListItemHeadHoverItem","StyledMotionListItemHeadIndicator","ListItemHead","_ref","hoverItem","icons","imageBackgroundColor","images","isAnyItemExpandable","isExpandable","isOpen","isTitleGreyed","leftElements","onClick","onLongPress","rightElements","shouldHideImageOrIconBackground","shouldHideIndicator","shouldOpenImageOnClick","shouldShowRoundImageOrIcon","subtitle","title","titleElement","shouldShowHoverItem","setShouldShowHoverItem","headHeight","setHeadHeight","closed","open","setIsFirstRender","longPressTimeoutRef","pseudoTitleOpenRef","pseudoTitleClosedRef","pseudoSubtitleOpenRef","pseudoSubtitleClosedRef","closedTitle","openedTitle","closedSubtitle","openedSubtitle","shouldShowSubtitleRow","height","handleMouseEnter","handleMouseLeave","marginTop","handleTouchStart","event","current","window","setTimeout","handleTouchEnd","clearTimeout","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","undefined","animate","opacity","initial","transition","duration","type","className","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rotate","$isIconOrImageGiven","$marginTop","$isOpen","ref","$width","width","marginLeft","displayName"],"sources":["../../../../../../src/components/list/list-item/list-item-head/ListItemHead.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n TouchEventHandler,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useElementSize } from '../../../../hooks/useElementSize';\nimport type { IListItemRightElements } from '../../../../types/list';\nimport Icon from '../../../icon/Icon';\nimport ListItemIcon from './list-item-icon/ListItemIcon';\nimport ListItemImage from './list-item-image/ListItemImage';\nimport ListItemRightElements from './list-item-right-elements/ListItemRightElements';\nimport {\n StyledListItemHead,\n StyledListItemHeadContent,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadSubtitleText,\n StyledListItemHeadSubtitleTextPseudo,\n StyledListItemHeadTitle,\n StyledListItemHeadTitleContent,\n StyledListItemHeadTitleElement,\n StyledListItemHeadTitleText,\n StyledListItemHeadTitleTextPseudo,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadIndicator,\n} from './ListItemHead.styles';\n\ninterface HeadHeight {\n closed: number;\n open: number;\n}\n\ntype ListItemHeadProps = {\n hoverItem?: ReactNode;\n icons?: string[];\n imageBackgroundColor?: CSSProperties['backgroundColor'];\n images?: string[];\n isAnyItemExpandable: boolean;\n isExpandable: boolean;\n isOpen: boolean;\n isTitleGreyed?: boolean;\n leftElements?: ReactNode;\n onClick?: MouseEventHandler<HTMLDivElement>;\n onLongPress?: TouchEventHandler<HTMLDivElement>;\n rightElements?: IListItemRightElements;\n shouldHideImageOrIconBackground?: boolean;\n shouldHideIndicator?: boolean;\n shouldOpenImageOnClick: boolean;\n shouldShowRoundImageOrIcon?: boolean;\n subtitle?: ReactNode;\n title: ReactNode;\n titleElement?: ReactNode;\n};\n\nconst ListItemHead: FC<ListItemHeadProps> = ({\n hoverItem,\n icons,\n imageBackgroundColor,\n images,\n isAnyItemExpandable,\n isExpandable,\n isOpen,\n isTitleGreyed,\n leftElements,\n onClick,\n onLongPress,\n rightElements,\n shouldHideImageOrIconBackground,\n shouldHideIndicator,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n subtitle,\n title,\n titleElement,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n const [headHeight, setHeadHeight] = useState<HeadHeight>({\n closed: 40,\n open: 40,\n });\n const [, setIsFirstRender] = useState(false);\n\n const longPressTimeoutRef = useRef<number>();\n const pseudoTitleOpenRef = useRef<HTMLDivElement>(null);\n const pseudoTitleClosedRef = useRef<HTMLDivElement>(null);\n const pseudoSubtitleOpenRef = useRef<HTMLDivElement>(null);\n const pseudoSubtitleClosedRef = useRef<HTMLDivElement>(null);\n\n const closedTitle = useElementSize(pseudoTitleClosedRef);\n const openedTitle = useElementSize(pseudoTitleOpenRef);\n const closedSubtitle = useElementSize(pseudoSubtitleClosedRef);\n const openedSubtitle = useElementSize(pseudoSubtitleOpenRef);\n\n const shouldShowSubtitleRow = subtitle || typeof subtitle === 'string';\n\n useEffect(() => {\n if (closedTitle && openedTitle) {\n setHeadHeight({\n closed:\n shouldShowSubtitleRow && closedSubtitle\n ? closedSubtitle.height + 4 + closedTitle.height + 24\n : closedTitle.height + 24,\n open:\n shouldShowSubtitleRow && openedSubtitle\n ? openedSubtitle.height + 4 + openedTitle.height + 24\n : openedTitle.height + 24,\n });\n }\n }, [closedSubtitle, closedTitle, openedSubtitle, openedTitle, shouldShowSubtitleRow]);\n\n // This is used to trigger a rerender, so the head height can be calculated\n useEffect(() => {\n setIsFirstRender(true);\n }, []);\n\n const handleMouseEnter = useCallback(() => setShouldShowHoverItem(true), []);\n\n const handleMouseLeave = useCallback(() => setShouldShowHoverItem(false), []);\n\n const marginTop = useMemo(() => {\n const height = headHeight[isOpen ? 'open' : 'closed'];\n\n if (height < 64) {\n return (64 - height) / 2;\n }\n\n return 0;\n }, [headHeight, isOpen]);\n\n const handleTouchStart = useCallback<TouchEventHandler<HTMLDivElement>>(\n (event) => {\n longPressTimeoutRef.current = window.setTimeout(() => {\n if (typeof onLongPress === 'function') {\n onLongPress(event);\n }\n }, 400);\n },\n [onLongPress],\n );\n\n const handleTouchEnd = useCallback(() => {\n clearTimeout(longPressTimeoutRef.current);\n }, []);\n\n const iconOrImageElement = useMemo(() => {\n if (icons) {\n return (\n <ListItemIcon\n icons={icons}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundIcon={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n if (images) {\n return (\n <ListItemImage\n imageBackgroundColor={imageBackgroundColor}\n images={images}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundImage={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n return undefined;\n }, [\n icons,\n imageBackgroundColor,\n images,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n return (\n <StyledListItemHead\n animate={{\n height: isOpen ? headHeight.open : headHeight.closed,\n opacity: isTitleGreyed ? 0.5 : 1,\n }}\n initial={false}\n transition={{ duration: 0.2, type: 'tween' }}\n className=\"beta-chayns-list-item-head\"\n $isClickable={typeof onClick === 'function' || isExpandable}\n $isAnyItemExpandable={isAnyItemExpandable}\n onClick={onClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onTouchStart={typeof onLongPress === 'function' ? handleTouchStart : undefined}\n onTouchEnd={typeof onLongPress === 'function' ? handleTouchEnd : undefined}\n >\n <StyledListItemHeadLeftWrapper>\n {isAnyItemExpandable && (\n <StyledMotionListItemHeadIndicator\n animate={{ rotate: isOpen ? 90 : 0 }}\n initial={false}\n transition={{ type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && (\n <Icon icons={['fa fa-chevron-right']} />\n )}\n </StyledMotionListItemHeadIndicator>\n )}\n {leftElements}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $marginTop={marginTop}\n $isOpen={isOpen}\n >\n <StyledListItemHeadTitle>\n <StyledListItemHeadTitleContent>\n <StyledListItemHeadTitleTextPseudo ref={pseudoTitleOpenRef} $isOpen>\n {title}\n </StyledListItemHeadTitleTextPseudo>\n <StyledListItemHeadTitleTextPseudo\n ref={pseudoTitleClosedRef}\n $isOpen={false}\n >\n {title}\n </StyledListItemHeadTitleTextPseudo>\n <StyledListItemHeadTitleText\n $isOpen={isOpen}\n $width={openedTitle?.width ?? 0}\n >\n {title}\n </StyledListItemHeadTitleText>\n <StyledListItemHeadTitleElement>\n {titleElement}\n </StyledListItemHeadTitleElement>\n </StyledListItemHeadTitleContent>\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <StyledListItemHeadSubtitleTextPseudo ref={pseudoSubtitleOpenRef} $isOpen>\n {subtitle}\n </StyledListItemHeadSubtitleTextPseudo>\n <StyledListItemHeadSubtitleTextPseudo\n ref={pseudoSubtitleClosedRef}\n $isOpen={false}\n >\n {subtitle}\n </StyledListItemHeadSubtitleTextPseudo>\n <StyledListItemHeadSubtitleText $isOpen={isOpen}>\n {subtitle}\n </StyledListItemHeadSubtitleText>\n </StyledListItemHeadSubtitle>\n )}\n </StyledListItemHeadContent>\n {rightElements && <ListItemRightElements rightElements={rightElements} />}\n {hoverItem && (\n <StyledMotionListItemHeadHoverItem\n animate={{\n marginLeft: shouldShowHoverItem ? 8 : 0,\n opacity: shouldShowHoverItem ? 1 : 0,\n width: shouldShowHoverItem ? 'auto' : 0,\n }}\n initial={false}\n transition={{ duration: 0.15, type: 'tween' }}\n >\n {hoverItem}\n </StyledMotionListItemHeadHoverItem>\n )}\n </StyledListItemHead>\n );\n};\n\nListItemHead.displayName = 'ListItemHead';\n\nexport default ListItemHead;\n"],"mappings":"AAAA,OAAOA,KAAK,IAMRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,cAAc,QAAQ,kCAAkC;AAEjE,OAAOC,IAAI,MAAM,oBAAoB;AACrC,OAAOC,YAAY,MAAM,+BAA+B;AACxD,OAAOC,aAAa,MAAM,iCAAiC;AAC3D,OAAOC,qBAAqB,MAAM,kDAAkD;AACpF,SACIC,kBAAkB,EAClBC,yB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EAAE,KAAM;IACfC,UAAU,EAAE;MAAEC,QAAQ,EAAE,IAAI;MAAEC,IAAI,EAAE;IAAQ;EAAE,GAE7C1D,SAC8B,CAEvB,CAAC;AAE7B,CAAC;AAEDF,YAAY,CAAC4E,WAAW,GAAG,cAAc;AAEzC,eAAe5E,YAAY","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ import GridImage from '../../../../grid-image/GridImage';
|
|
|
4
4
|
import { StyledListItemHeadImage, StyledListItemHeadImageWrapper } from './ListItemImage.styles';
|
|
5
5
|
const ListItemImage = _ref => {
|
|
6
6
|
let {
|
|
7
|
+
imageBackgroundColor,
|
|
7
8
|
images,
|
|
8
9
|
shouldHideBackground,
|
|
9
10
|
shouldShowRoundImage,
|
|
@@ -34,6 +35,7 @@ const ListItemImage = _ref => {
|
|
|
34
35
|
if (images && images[0] && images[1] && images[2]) {
|
|
35
36
|
const gridImages = [images[0], images[1], images[2]];
|
|
36
37
|
return /*#__PURE__*/React.createElement(GridImage, {
|
|
38
|
+
backgroundColor: imageBackgroundColor,
|
|
37
39
|
images: gridImages,
|
|
38
40
|
shouldShowRoundImage: shouldShowRoundImage,
|
|
39
41
|
size: 40,
|
|
@@ -46,6 +48,7 @@ const ListItemImage = _ref => {
|
|
|
46
48
|
$shouldHideBackground: shouldHideBackground,
|
|
47
49
|
$shouldShowRoundImage: shouldShowRoundImage
|
|
48
50
|
}, /*#__PURE__*/React.createElement(StyledListItemHeadImage, {
|
|
51
|
+
$backgroundColor: imageBackgroundColor,
|
|
49
52
|
$isHidden: !hasLoadedImage,
|
|
50
53
|
onLoad: handleImageLoaded,
|
|
51
54
|
src: images[0]
|
package/lib/esm/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemImage.js","names":["MediaType","openMedia","React","useCallback","useState","GridImage","StyledListItemHeadImage","StyledListItemHeadImageWrapper","ListItemImage","_ref","images","shouldHideBackground","shouldShowRoundImage","shouldOpenImageOnClick","hasLoadedImage","setHasLoadedImage","handleImageLoaded","handleImageClick","event","preventDefault","stopPropagation","items","map","image","url","mediaType","IMAGE","startIndex","gridImages","createElement","size","onClick","$shouldHideBackground","$shouldShowRoundImage","$isHidden","onLoad","src","displayName"],"sources":["../../../../../../../src/components/list/list-item/list-item-head/list-item-image/ListItemImage.tsx"],"sourcesContent":["import { MediaType, openMedia, OpenMediaItem } from 'chayns-api';\nimport React, { MouseEventHandler, useCallback, useState } from 'react';\nimport GridImage from '../../../../grid-image/GridImage';\nimport { StyledListItemHeadImage, StyledListItemHeadImageWrapper } from './ListItemImage.styles';\n\ntype ListItemImageProps = {\n images: string[];\n shouldHideBackground: boolean;\n shouldShowRoundImage: boolean;\n shouldOpenImageOnClick: boolean;\n};\n\nconst ListItemImage: React.FC<ListItemImageProps> = ({\n images,\n shouldHideBackground,\n shouldShowRoundImage,\n shouldOpenImageOnClick,\n}) => {\n const [hasLoadedImage, setHasLoadedImage] = useState(false);\n const handleImageLoaded = useCallback(() => {\n setHasLoadedImage(true);\n }, []);\n\n const handleImageClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n if (!shouldOpenImageOnClick) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n const items: OpenMediaItem[] = images.map((image) => ({\n url: image,\n mediaType: MediaType.IMAGE,\n }));\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n void openMedia({ items, startIndex: 0 });\n },\n [images, shouldOpenImageOnClick],\n );\n\n if (images && images[0] && images[1] && images[2]) {\n const gridImages = [images[0], images[1], images[2]];\n\n return (\n <GridImage\n images={gridImages}\n shouldShowRoundImage={shouldShowRoundImage}\n size={40}\n onClick={handleImageClick}\n />\n );\n }\n\n if (images && images[0]) {\n return (\n <StyledListItemHeadImageWrapper\n onClick={handleImageClick}\n $shouldHideBackground={shouldHideBackground}\n $shouldShowRoundImage={shouldShowRoundImage}\n >\n <StyledListItemHeadImage\n $isHidden={!hasLoadedImage}\n onLoad={handleImageLoaded}\n src={images[0]}\n />\n </StyledListItemHeadImageWrapper>\n );\n }\n\n return null;\n};\n\nListItemImage.displayName = 'ListItemImage';\n\nexport default ListItemImage;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,SAAS,QAAuB,YAAY;AAChE,OAAOC,KAAK,
|
|
1
|
+
{"version":3,"file":"ListItemImage.js","names":["MediaType","openMedia","React","useCallback","useState","GridImage","StyledListItemHeadImage","StyledListItemHeadImageWrapper","ListItemImage","_ref","imageBackgroundColor","images","shouldHideBackground","shouldShowRoundImage","shouldOpenImageOnClick","hasLoadedImage","setHasLoadedImage","handleImageLoaded","handleImageClick","event","preventDefault","stopPropagation","items","map","image","url","mediaType","IMAGE","startIndex","gridImages","createElement","backgroundColor","size","onClick","$shouldHideBackground","$shouldShowRoundImage","$backgroundColor","$isHidden","onLoad","src","displayName"],"sources":["../../../../../../../src/components/list/list-item/list-item-head/list-item-image/ListItemImage.tsx"],"sourcesContent":["import { MediaType, openMedia, OpenMediaItem } from 'chayns-api';\nimport React, { CSSProperties, MouseEventHandler, useCallback, useState } from 'react';\nimport GridImage from '../../../../grid-image/GridImage';\nimport { StyledListItemHeadImage, StyledListItemHeadImageWrapper } from './ListItemImage.styles';\n\ntype ListItemImageProps = {\n imageBackgroundColor?: CSSProperties['backgroundColor'];\n images: string[];\n shouldHideBackground: boolean;\n shouldShowRoundImage: boolean;\n shouldOpenImageOnClick: boolean;\n};\n\nconst ListItemImage: React.FC<ListItemImageProps> = ({\n imageBackgroundColor,\n images,\n shouldHideBackground,\n shouldShowRoundImage,\n shouldOpenImageOnClick,\n}) => {\n const [hasLoadedImage, setHasLoadedImage] = useState(false);\n const handleImageLoaded = useCallback(() => {\n setHasLoadedImage(true);\n }, []);\n\n const handleImageClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n if (!shouldOpenImageOnClick) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n const items: OpenMediaItem[] = images.map((image) => ({\n url: image,\n mediaType: MediaType.IMAGE,\n }));\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n void openMedia({ items, startIndex: 0 });\n },\n [images, shouldOpenImageOnClick],\n );\n\n if (images && images[0] && images[1] && images[2]) {\n const gridImages = [images[0], images[1], images[2]];\n\n return (\n <GridImage\n backgroundColor={imageBackgroundColor}\n images={gridImages}\n shouldShowRoundImage={shouldShowRoundImage}\n size={40}\n onClick={handleImageClick}\n />\n );\n }\n\n if (images && images[0]) {\n return (\n <StyledListItemHeadImageWrapper\n onClick={handleImageClick}\n $shouldHideBackground={shouldHideBackground}\n $shouldShowRoundImage={shouldShowRoundImage}\n >\n <StyledListItemHeadImage\n $backgroundColor={imageBackgroundColor}\n $isHidden={!hasLoadedImage}\n onLoad={handleImageLoaded}\n src={images[0]}\n />\n </StyledListItemHeadImageWrapper>\n );\n }\n\n return null;\n};\n\nListItemImage.displayName = 'ListItemImage';\n\nexport default ListItemImage;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,SAAS,QAAuB,YAAY;AAChE,OAAOC,KAAK,IAAsCC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACtF,OAAOC,SAAS,MAAM,kCAAkC;AACxD,SAASC,uBAAuB,EAAEC,8BAA8B,QAAQ,wBAAwB;AAUhG,MAAMC,aAA2C,GAAGC,IAAA,IAM9C;EAAA,IAN+C;IACjDC,oBAAoB;IACpBC,MAAM;IACNC,oBAAoB;IACpBC,oBAAoB;IACpBC;EACJ,CAAC,GAAAL,IAAA;EACG,MAAM,CAACM,cAAc,EAAEC,iBAAiB,CAAC,GAAGZ,QAAQ,CAAC,KAAK,CAAC;EAC3D,MAAMa,iBAAiB,GAAGd,WAAW,CAAC,MAAM;IACxCa,iBAAiB,CAAC,IAAI,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAEN,MAAME,gBAAgB,GAAGf,WAAW,CAC/BgB,KAAK,IAAK;IACP,IAAI,CA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,MAAM,CAAC,CAAC;IAAE,CAClB,CAC2B,CAAC;EAEzC;EAEA,OAAO,IAAI;AACf,CAAC;AAEDH,aAAa,CAACgC,WAAW,GAAG,eAAe;AAE3C,eAAehC,aAAa","ignoreList":[]}
|
package/lib/esm/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js
CHANGED
|
@@ -42,12 +42,19 @@ export const StyledListItemHeadImageWrapper = styled.div`
|
|
|
42
42
|
}}
|
|
43
43
|
`;
|
|
44
44
|
export const StyledListItemHeadImage = styled.img`
|
|
45
|
+
background-color: ${_ref5 => {
|
|
46
|
+
let {
|
|
47
|
+
$backgroundColor,
|
|
48
|
+
theme
|
|
49
|
+
} = _ref5;
|
|
50
|
+
return $backgroundColor || `rgba(${theme['text-rgb'] ?? '0,0,0'}, 0.1)`;
|
|
51
|
+
}};
|
|
45
52
|
height: 100%;
|
|
46
53
|
object-fit: cover;
|
|
47
|
-
opacity: ${
|
|
54
|
+
opacity: ${_ref6 => {
|
|
48
55
|
let {
|
|
49
56
|
$isHidden
|
|
50
|
-
} =
|
|
57
|
+
} = _ref6;
|
|
51
58
|
return $isHidden ? 0 : 1;
|
|
52
59
|
}};
|
|
53
60
|
transition: opacity 0.4s ease;
|
package/lib/esm/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemImage.styles.js","names":["styled","css","StyledListItemHeadImageWrapper","div","_ref","$shouldShowRoundImage","undefined","_ref2","$shouldHideBackground","_ref3","theme","_ref4","StyledListItemHeadImage","img","_ref5","$isHidden"],"sources":["../../../../../../../src/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledListItemHeadImageWrapperProps = WithTheme<{\n $shouldHideBackground?: boolean;\n $shouldShowRoundImage?: boolean;\n}>;\n\nexport const StyledListItemHeadImageWrapper = styled.div<StyledListItemHeadImageWrapperProps>`\n flex: 0 0 auto;\n height: 40px;\n overflow: hidden;\n transition:\n background-color 0.3s ease,\n border-radius 0.3s ease,\n box-shadow 0.3s ease;\n width: 40px;\n\n border-radius: ${({ $shouldShowRoundImage }) => ($shouldShowRoundImage ? '50%' : undefined)};\n\n ${({ $shouldHideBackground }) =>\n !$shouldHideBackground &&\n css`\n background-color: rgba(\n ${({ theme }: StyledListItemHeadImageWrapperProps) => theme['text-rgb']},\n 0.1\n );\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledListItemHeadImageWrapperProps) => theme['009-rgb']}, 0.08)\n inset;\n `}\n`;\n\ntype StyledListItemHeadImageProps = {\n $isHidden: boolean;\n}
|
|
1
|
+
{"version":3,"file":"ListItemImage.styles.js","names":["styled","css","StyledListItemHeadImageWrapper","div","_ref","$shouldShowRoundImage","undefined","_ref2","$shouldHideBackground","_ref3","theme","_ref4","StyledListItemHeadImage","img","_ref5","$backgroundColor","_ref6","$isHidden"],"sources":["../../../../../../../src/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.ts"],"sourcesContent":["import { CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledListItemHeadImageWrapperProps = WithTheme<{\n $shouldHideBackground?: boolean;\n $shouldShowRoundImage?: boolean;\n}>;\n\nexport const StyledListItemHeadImageWrapper = styled.div<StyledListItemHeadImageWrapperProps>`\n flex: 0 0 auto;\n height: 40px;\n overflow: hidden;\n transition:\n background-color 0.3s ease,\n border-radius 0.3s ease,\n box-shadow 0.3s ease;\n width: 40px;\n\n border-radius: ${({ $shouldShowRoundImage }) => ($shouldShowRoundImage ? '50%' : undefined)};\n\n ${({ $shouldHideBackground }) =>\n !$shouldHideBackground &&\n css`\n background-color: rgba(\n ${({ theme }: StyledListItemHeadImageWrapperProps) => theme['text-rgb']},\n 0.1\n );\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledListItemHeadImageWrapperProps) => theme['009-rgb']}, 0.08)\n inset;\n `}\n`;\n\ntype StyledListItemHeadImageProps = WithTheme<{\n $backgroundColor?: CSSProperties['backgroundColor'];\n $isHidden: boolean;\n}>;\n\nexport const StyledListItemHeadImage = styled.img<StyledListItemHeadImageProps>`\n background-color: ${({ $backgroundColor, theme }: StyledListItemHeadImageProps) =>\n $backgroundColor || `rgba(${theme['text-rgb'] ?? '0,0,0'}, 0.1)`};\n height: 100%;\n object-fit: cover;\n opacity: ${({ $isHidden }) => ($isHidden ? 0 : 1)};\n transition: opacity 0.4s ease;\n width: 100%;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAQ/C,OAAO,MAAMC,8BAA8B,GAAGF,MAAM,CAACG,GAAwC;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqBC,IAAA;EAAA,IAAC;IAAEC;EAAsB,CAAC,GAAAD,IAAA;EAAA,OAAMC,qBAAqB,GAAG,KAAK,GAAGC,SAAS;AAAA,CAAC;AAC/F;AACA,MAAMC,KAAA;EAAA,IAAC;IAAEC;EAAsB,CAAC,GAAAD,KAAA;EAAA,OACxB,CAACC,qBAAqB,IACtBP,GAAG;AACX;AACA,kBAAkBQ,KAAA;IAAA,IAAC;MAAEC;IAA2C,CAAC,GAAAD,KAAA;IAAA,OAAKC,KAAK,CAAC,UAAU,CAAC;EAAA;AACvF;AACA;AACA;AACA,uBAAuBC,KAAA;IAAA,IAAC;MAAED;IAA2C,CAAC,GAAAC,KAAA;IAAA,OAAKD,KAAK,CAAC,SAAS,CAAC;EAAA;AAC3F;AACA,SAAS;AAAA;AACT,CAAC;AAOD,OAAO,MAAME,uBAAuB,GAAGZ,MAAM,CAACa,GAAiC;AAC/E,wBAAwBC,KAAA;EAAA,IAAC;IAAEC,gBAAgB;IAAEL;EAAoC,CAAC,GAAAI,KAAA;EAAA,OAC1EC,gBAAgB,IAAI,QAAQL,KAAK,CAAC,UAAU,CAAC,IAAI,OAAO,QAAQ;AAAA;AACxE;AACA;AACA,eAAeM,KAAA;EAAA,IAAC;IAAEC;EAAU,CAAC,GAAAD,KAAA;EAAA,OAAMC,SAAS,GAAG,CAAC,GAAG,CAAC;AAAA,CAAC;AACrD;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ const Popup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
14
14
|
container,
|
|
15
15
|
onHide,
|
|
16
16
|
children,
|
|
17
|
+
shouldHideOnChildrenLeave,
|
|
17
18
|
shouldShowOnHover = false,
|
|
18
19
|
shouldUseChildrenWidth = true,
|
|
19
20
|
yOffset = 0
|
|
@@ -89,6 +90,7 @@ const Popup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
89
90
|
top: childrenTop,
|
|
90
91
|
width: childrenWidth
|
|
91
92
|
} = popupRef.current.getBoundingClientRect();
|
|
93
|
+
const containerRect = newContainer?.getBoundingClientRect();
|
|
92
94
|
if (pseudoHeight > childrenTop - 25) {
|
|
93
95
|
let isRight = false;
|
|
94
96
|
if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {
|
|
@@ -97,8 +99,8 @@ const Popup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
97
99
|
} else {
|
|
98
100
|
setAlignment(PopupAlignment.BottomLeft);
|
|
99
101
|
}
|
|
100
|
-
const x = childrenLeft + childrenWidth / 2;
|
|
101
|
-
const y = childrenTop + childrenHeight + yOffset;
|
|
102
|
+
const x = childrenLeft - (containerRect?.left ?? 0) + childrenWidth / 2;
|
|
103
|
+
const y = childrenTop - (containerRect?.top ?? 0) + childrenHeight + yOffset;
|
|
102
104
|
let newOffset;
|
|
103
105
|
if (isRight) {
|
|
104
106
|
newOffset = x + pseudoWidth >= window.innerWidth ? x + pseudoWidth - window.innerWidth : 0;
|
|
@@ -121,8 +123,8 @@ const Popup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
121
123
|
} else {
|
|
122
124
|
setAlignment(PopupAlignment.TopLeft);
|
|
123
125
|
}
|
|
124
|
-
const x = childrenLeft + childrenWidth / 2;
|
|
125
|
-
const y = childrenTop - yOffset;
|
|
126
|
+
const x = childrenLeft - (containerRect?.left ?? 0) + childrenWidth / 2;
|
|
127
|
+
const y = childrenTop - (containerRect?.top ?? 0) - yOffset;
|
|
126
128
|
let newOffset;
|
|
127
129
|
if (isRight) {
|
|
128
130
|
newOffset = x + pseudoWidth >= window.innerWidth ? x + pseudoWidth - window.innerWidth : 0;
|
|
@@ -157,10 +159,14 @@ const Popup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
157
159
|
if (!shouldShowOnHover) {
|
|
158
160
|
return;
|
|
159
161
|
}
|
|
162
|
+
if (shouldHideOnChildrenLeave) {
|
|
163
|
+
handleHide();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
160
166
|
timeout.current = window.setTimeout(() => {
|
|
161
167
|
handleHide();
|
|
162
168
|
}, 500);
|
|
163
|
-
}, [handleHide, shouldShowOnHover]);
|
|
169
|
+
}, [handleHide, shouldHideOnChildrenLeave, shouldShowOnHover]);
|
|
164
170
|
const handleDocumentClick = useCallback(event => {
|
|
165
171
|
if (!popupContentRef.current?.contains(event.target)) {
|
|
166
172
|
handleHide();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popup.js","names":["getWindowMetrics","AnimatePresence","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","createPortal","useUuid","PopupAlignment","AreaContextProvider","PopupContentWrapper","StyledPopup","StyledPopupPseudo","Popup","_ref","ref","content","onShow","container","onHide","children","shouldShowOnHover","shouldUseChildrenWidth","yOffset","coordinates","setCoordinates","x","y","alignment","setAlignment","TopLeft","offset","setOffset","isOpen","setIsOpen","portal","setPortal","menuHeight","setMenuHeight","isMeasuring","setIsMeasuring","pseudoSize","setPseudoSize","newContainer","setNewContainer","timeout","uuid","popupContentRef","popupPseudoContentRef","popupRef","current","el","element","closest","Element","measureHeight","height","offsetHeight","width","offsetWidth","handleResize","setTimeout","window","addEventListener","removeEventListener","handleShow","pseudoHeight","pseudoWidth","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","isRight","BottomRight","BottomLeft","newOffset","innerWidth","right","newX","TopRight","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","handleDocumentClick","event","contains","target","hide","show","then","result","topBarHeight","document","createElement","initial","key","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","$menuHeight","onClick","$shouldUseChildrenWidth","displayName"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { getWindowMetrics } from 'chayns-api';\nimport { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup, StyledPopupPseudo } from './Popup.styles';\n\nexport type PopupProps = {\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The element where the content of the `Popup` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The content that should be displayed inside the popup.\n */\n content: ReactNode;\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n /**\n * Whether the popup should be opened on hover. If not, the popup will be opened on click.\n */\n shouldShowOnHover?: boolean;\n /**\n * Whether the width of the children should be used.\n */\n shouldUseChildrenWidth?: boolean;\n /**\n * The Y offset of the popup to the children.\n */\n yOffset?: number;\n};\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n content,\n onShow,\n container,\n onHide,\n children,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n yOffset = 0,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [alignment, setAlignment] = useState<PopupAlignment>(PopupAlignment.TopLeft);\n const [offset, setOffset] = useState<number>(0);\n const [isOpen, setIsOpen] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n const [menuHeight, setMenuHeight] = useState(0);\n const [isMeasuring, setIsMeasuring] = useState(true);\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n\n const timeout = useRef<number>();\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupPseudoContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element =\n el.closest('.dialog-inner') ||\n el.closest('.page-provider') ||\n el.closest('.tapp') ||\n el.closest('body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if(container instanceof Element){\n setNewContainer(container)\n }\n }, [container]);\n\n const measureHeight = () => {\n if (popupPseudoContentRef.current) {\n const height = popupPseudoContentRef.current.offsetHeight;\n const width = popupPseudoContentRef.current.offsetWidth + 1;\n\n setPseudoSize({ height, width });\n }\n };\n\n useEffect(() => {\n measureHeight();\n\n setIsMeasuring(false);\n }, []);\n\n useEffect(() => {\n const handleResize = () => {\n setIsMeasuring(true);\n\n setTimeout(() => {\n measureHeight();\n setIsMeasuring(false);\n }, 0);\n };\n\n window.addEventListener('resize', handleResize);\n\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n }, []);\n\n const handleShow = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n if (pseudoHeight > childrenTop - 25) {\n let isRight = false;\n\n if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.BottomRight);\n\n isRight = true;\n } else {\n setAlignment(PopupAlignment.BottomLeft);\n }\n\n const x = childrenLeft + childrenWidth / 2;\n const y = childrenTop + childrenHeight + yOffset;\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n x + pseudoWidth >= window.innerWidth\n ? x + pseudoWidth - window.innerWidth\n : 0;\n } else {\n newOffset = 0;\n\n const right = window.innerWidth - (childrenLeft + childrenWidth / 2);\n\n newOffset =\n right + pseudoWidth >= window.innerWidth\n ? right + pseudoWidth - window.innerWidth\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX < 23 ? 23 : newX,\n y: y - yOffset,\n });\n } else {\n let isRight = false;\n\n if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.TopRight);\n\n isRight = true;\n } else {\n setAlignment(PopupAlignment.TopLeft);\n }\n\n const x = childrenLeft + childrenWidth / 2;\n const y = childrenTop - yOffset;\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n x + pseudoWidth >= window.innerWidth\n ? x + pseudoWidth - window.innerWidth\n : 0;\n } else {\n newOffset = 0;\n\n const right = window.innerWidth - (childrenLeft + childrenWidth / 2);\n\n newOffset =\n right + pseudoWidth >= window.innerWidth\n ? right + pseudoWidth - window.innerWidth\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX < 23 ? 23 : newX,\n y: y - yOffset,\n });\n }\n\n setIsOpen(true);\n }\n }, [pseudoSize, yOffset]);\n\n const handleChildrenClick = () => {\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleMouseEnter = useCallback(() => {\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (!shouldShowOnHover) {\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\n },\n [handleHide],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n void getWindowMetrics().then((result) => {\n if (result.topBarHeight) {\n setMenuHeight(result.topBarHeight);\n }\n });\n }, []);\n\n useEffect(() => {\n if (isOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isOpen, onHide, onShow]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n alignment={alignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor={false}>\n {content}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n alignment,\n newContainer,\n content,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isOpen,\n offset,\n pseudoSize?.width,\n uuid,\n ]);\n\n return (\n <>\n {isMeasuring && (\n <StyledPopupPseudo ref={popupPseudoContentRef} $menuHeight={menuHeight}>\n {content}\n </StyledPopupPseudo>\n )}\n <StyledPopup\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IACRC,UAAU,EAGVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,cAAc,QAAoC,mBAAmB;AAC9E,OAAOC,mBAAmB,MAAM,sCAAsC;AACtE,OAAOC,mBAAmB,MAAM,6CAA6C;AAC7E,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,gBAAgB;AAqC/D,MAAMC,KAAK,gBAAGb,UAAU,CACpB,CAAAc,IAAA,EAWIC,GAAG,KACF;EAAA,IAXD;IACIC,OAAO;IACPC,MAAM;IACNC,SAAS;IACTC,MAAM;IACNC,QAAQ;IACRC,iBAAiB,GAAG,KAAK;IACzBC,sBAAsB,GAAG,IAAI;IAC7BC,OAAO,GAAG;EACd,CAAC,GAAAT,IAAA;EAGD,MAAM,CAACU,WAAW,EAAEC,cAAc,CAAC,GAAGpB,QAAQ,CAAmB;IAC7DqB,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE;EACP,CAAC,CAAC;EAEF,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGxB,QAAQ,CAAiBG,cAAc,CAACsB,OAAO,CAAC;EAClF,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG3B,QAAQ,CAAS,CAAC,CAAC;EAC/C,MAAM,CAAC4B,MAAM,EAA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EACjBZ,IAAI,CACP,CAAC;EAEF,oBACI/C,KAAA,CAAAmG,aAAA,CAAAnG,KAAA,CAAAyG,QAAA,QACKjE,WAAW,iBACRxC,KAAA,CAAAmG,aAAA,CAACtF,iBAAiB;IAACG,GAAG,EAAEiC,qBAAsB;IAACyD,WAAW,EAAEpE;EAAW,GAClErB,OACc,CACtB,eACDjB,KAAA,CAAAmG,aAAA,CAACvF,WAAW;IACRI,GAAG,EAAEkC,QAAS;IACdyD,OAAO,EAAEvB,mBAAoB;IAC7BkB,YAAY,EAAEd,gBAAiB;IAC/Be,YAAY,EAAEjB,gBAAiB;IAC/BsB,uBAAuB,EAAErF;EAAuB,GAE/CF,QACQ,CAAC,EACbe,MACH,CAAC;AAEX,CACJ,CAAC;AAEDtB,KAAK,CAAC+F,WAAW,GAAG,OAAO;AAE3B,eAAe/F,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Popup.js","names":["getWindowMetrics","AnimatePresence","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","createPortal","useUuid","PopupAlignment","AreaContextProvider","PopupContentWrapper","StyledPopup","StyledPopupPseudo","Popup","_ref","ref","content","onShow","container","onHide","children","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","yOffset","coordinates","setCoordinates","x","y","alignment","setAlignment","TopLeft","offset","setOffset","isOpen","setIsOpen","portal","setPortal","menuHeight","setMenuHeight","isMeasuring","setIsMeasuring","pseudoSize","setPseudoSize","newContainer","setNewContainer","timeout","uuid","popupContentRef","popupPseudoContentRef","popupRef","current","el","element","closest","Element","measureHeight","height","offsetHeight","width","offsetWidth","handleResize","setTimeout","window","addEventListener","removeEventListener","handleShow","pseudoHeight","pseudoWidth","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","containerRect","isRight","BottomRight","BottomLeft","newOffset","innerWidth","right","newX","TopRight","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","handleDocumentClick","event","contains","target","hide","show","then","result","topBarHeight","document","createElement","initial","key","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","$menuHeight","onClick","$shouldUseChildrenWidth","displayName"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { getWindowMetrics } from 'chayns-api';\nimport { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup, StyledPopupPseudo } from './Popup.styles';\n\nexport type PopupProps = {\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The element where the content of the `Popup` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The content that should be displayed inside the popup.\n */\n content: ReactNode;\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n /**\n * Whether the tooltip should be hidden after the children is not hovered.\n */\n shouldHideOnChildrenLeave?: boolean;\n /**\n * Whether the popup should be opened on hover. If not, the popup will be opened on click.\n */\n shouldShowOnHover?: boolean;\n /**\n * Whether the width of the children should be used.\n */\n shouldUseChildrenWidth?: boolean;\n /**\n * The Y offset of the popup to the children.\n */\n yOffset?: number;\n};\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n content,\n onShow,\n container,\n onHide,\n children,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n yOffset = 0,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [alignment, setAlignment] = useState<PopupAlignment>(PopupAlignment.TopLeft);\n const [offset, setOffset] = useState<number>(0);\n const [isOpen, setIsOpen] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n const [menuHeight, setMenuHeight] = useState(0);\n const [isMeasuring, setIsMeasuring] = useState(true);\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n\n const timeout = useRef<number>();\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupPseudoContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element =\n el.closest('.dialog-inner') ||\n el.closest('.page-provider') ||\n el.closest('.tapp') ||\n el.closest('body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n const measureHeight = () => {\n if (popupPseudoContentRef.current) {\n const height = popupPseudoContentRef.current.offsetHeight;\n const width = popupPseudoContentRef.current.offsetWidth + 1;\n\n setPseudoSize({ height, width });\n }\n };\n\n useEffect(() => {\n measureHeight();\n\n setIsMeasuring(false);\n }, []);\n\n useEffect(() => {\n const handleResize = () => {\n setIsMeasuring(true);\n\n setTimeout(() => {\n measureHeight();\n setIsMeasuring(false);\n }, 0);\n };\n\n window.addEventListener('resize', handleResize);\n\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n }, []);\n\n const handleShow = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const containerRect = newContainer?.getBoundingClientRect();\n\n if (pseudoHeight > childrenTop - 25) {\n let isRight = false;\n\n if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.BottomRight);\n\n isRight = true;\n } else {\n setAlignment(PopupAlignment.BottomLeft);\n }\n\n const x = childrenLeft - (containerRect?.left ?? 0) + childrenWidth / 2;\n const y = childrenTop - (containerRect?.top ?? 0) + childrenHeight + yOffset;\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n x + pseudoWidth >= window.innerWidth\n ? x + pseudoWidth - window.innerWidth\n : 0;\n } else {\n newOffset = 0;\n\n const right = window.innerWidth - (childrenLeft + childrenWidth / 2);\n\n newOffset =\n right + pseudoWidth >= window.innerWidth\n ? right + pseudoWidth - window.innerWidth\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX < 23 ? 23 : newX,\n y: y - yOffset,\n });\n } else {\n let isRight = false;\n\n if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.TopRight);\n\n isRight = true;\n } else {\n setAlignment(PopupAlignment.TopLeft);\n }\n\n const x = childrenLeft - (containerRect?.left ?? 0) + childrenWidth / 2;\n const y = childrenTop - (containerRect?.top ?? 0) - yOffset;\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n x + pseudoWidth >= window.innerWidth\n ? x + pseudoWidth - window.innerWidth\n : 0;\n } else {\n newOffset = 0;\n\n const right = window.innerWidth - (childrenLeft + childrenWidth / 2);\n\n newOffset =\n right + pseudoWidth >= window.innerWidth\n ? right + pseudoWidth - window.innerWidth\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX < 23 ? 23 : newX,\n y: y - yOffset,\n });\n }\n\n setIsOpen(true);\n }\n }, [pseudoSize, yOffset]);\n\n const handleChildrenClick = () => {\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleMouseEnter = useCallback(() => {\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\n },\n [handleHide],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n void getWindowMetrics().then((result) => {\n if (result.topBarHeight) {\n setMenuHeight(result.topBarHeight);\n }\n });\n }, []);\n\n useEffect(() => {\n if (isOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isOpen, onHide, onShow]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n alignment={alignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor={false}>\n {content}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n alignment,\n newContainer,\n content,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isOpen,\n offset,\n pseudoSize?.width,\n uuid,\n ]);\n\n return (\n <>\n {isMeasuring && (\n <StyledPopupPseudo ref={popupPseudoContentRef} $menuHeight={menuHeight}>\n {content}\n </StyledPopupPseudo>\n )}\n <StyledPopup\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IACRC,UAAU,EAGVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,cAAc,QAAoC,mBAAmB;AAC9E,OAAOC,mBAAmB,MAAM,sCAAsC;AACtE,OAAOC,mBAAmB,MAAM,6CAA6C;AAC7E,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,gBAAgB;AAyC/D,MAAMC,KAAK,gBAAGb,UAAU,CACpB,CAAAc,IAAA,EAYIC,GAAG,KACF;EAAA,IAZD;IACIC,OAAO;IACPC,MAAM;IACNC,SAAS;IACTC,MAAM;IACNC,QAAQ;IACRC,yBAAyB;IACzBC,iBAAiB,GAAG,KAAK;IACzBC,sBAAsB,GAAG,IAAI;IAC7BC,OAAO,GAAG;EACd,CAAC,GAAAV,IAAA;EAGD,MAAM,CAACW,WAAW,EAAEC,cAAc,CAAC,GAAGrB,QAAQ,CAAmB;IAC7DsB,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE;EACP,CAAC,CAAC;EAEF,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGzB,QAAQ,CAAiBG,cAAc,CAACuB,OAAO,CAAC;EAClF,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG5B,QAAQ,CAAS,CAAC,CAAC;EAC/C,MAAM,CAAC6B,MAAM,EAAEC,SAAS,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AC/Be,YAAY,EAAEjB;IAAiB,gBAE/BxF,KAAA,CAAAqG,aAAA,CAAC3F,mBAAmB;MAACgG,iBAAiB,EAAE;IAAM,GACzCzF,OACgB,CACJ,CAEZ,CAAC,EAClB4B,YACJ,CACJ,CAAC;EACL,CAAC,EAAE,CACCf,SAAS,EACTe,YAAY,EACZ5B,OAAO,EACPS,WAAW,EACX8D,gBAAgB,EAChBE,gBAAgB,EAChBvD,MAAM,EACNF,MAAM,EACNU,UAAU,EAAEiB,KAAK,EACjBZ,IAAI,CACP,CAAC;EAEF,oBACIhD,KAAA,CAAAqG,aAAA,CAAArG,KAAA,CAAA2G,QAAA,QACKlE,WAAW,iBACRzC,KAAA,CAAAqG,aAAA,CAACxF,iBAAiB;IAACG,GAAG,EAAEkC,qBAAsB;IAAC0D,WAAW,EAAErE;EAAW,GAClEtB,OACc,CACtB,eACDjB,KAAA,CAAAqG,aAAA,CAACzF,WAAW;IACRI,GAAG,EAAEmC,QAAS;IACd0D,OAAO,EAAEvB,mBAAoB;IAC7BkB,YAAY,EAAEd,gBAAiB;IAC/Be,YAAY,EAAEjB,gBAAiB;IAC/BsB,uBAAuB,EAAEtF;EAAuB,GAE/CH,QACQ,CAAC,EACbgB,MACH,CAAC;AAEX,CACJ,CAAC;AAEDvB,KAAK,CAACiG,WAAW,GAAG,OAAO;AAE3B,eAAejG,KAAK","ignoreList":[]}
|
|
@@ -9,6 +9,8 @@ const Tooltip = _ref => {
|
|
|
9
9
|
children,
|
|
10
10
|
container,
|
|
11
11
|
isDisabled,
|
|
12
|
+
shouldHideOnChildrenLeave,
|
|
13
|
+
yOffset,
|
|
12
14
|
itemWidth,
|
|
13
15
|
shouldUseChildrenWidth = true
|
|
14
16
|
} = _ref;
|
|
@@ -30,14 +32,16 @@ const Tooltip = _ref => {
|
|
|
30
32
|
$shouldUseChildrenWidth: shouldUseChildrenWidth
|
|
31
33
|
}, children) : /*#__PURE__*/React.createElement(Popup, {
|
|
32
34
|
shouldShowOnHover: true,
|
|
35
|
+
shouldHideOnChildrenLeave: shouldHideOnChildrenLeave,
|
|
33
36
|
content: content,
|
|
34
37
|
ref: tooltipRef,
|
|
35
38
|
container: container,
|
|
39
|
+
yOffset: yOffset,
|
|
36
40
|
shouldUseChildrenWidth: shouldUseChildrenWidth
|
|
37
41
|
}, /*#__PURE__*/React.createElement(StyledTooltipChildren, {
|
|
38
42
|
$isOnlyText: isTextOnlyElement(children),
|
|
39
43
|
$shouldUseChildrenWidth: shouldUseChildrenWidth
|
|
40
|
-
}, children))), [isDisabled, children, shouldUseChildrenWidth, content, container]);
|
|
44
|
+
}, children))), [isDisabled, children, shouldUseChildrenWidth, shouldHideOnChildrenLeave, content, container, yOffset]);
|
|
41
45
|
};
|
|
42
46
|
Tooltip.displayName = 'Tooltip';
|
|
43
47
|
export default Tooltip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["React","isValidElement","useMemo","useRef","isTextOnlyElement","Popup","TooltipItem","StyledTooltip","StyledTooltipChildren","Tooltip","_ref","item","children","container","isDisabled","itemWidth","shouldUseChildrenWidth","tooltipRef","content","createElement","width","text","headline","imageUrl","button","$isOnlyText","$shouldUseChildrenWidth","shouldShowOnHover","ref","displayName"],"sources":["../../../../src/components/tooltip/Tooltip.tsx"],"sourcesContent":["import React, { FC, isValidElement, ReactNode, useMemo, useRef, type CSSProperties } from 'react';\nimport type { PopupRef } from '../../types/popup';\nimport type { ITooltipItem } from '../../types/tooltip';\nimport { isTextOnlyElement } from '../../utils/tooltip';\nimport Popup from '../popup/Popup';\nimport TooltipItem from './tooltip-item/TooltipItem';\nimport { StyledTooltip, StyledTooltipChildren } from './Tooltip.styles';\n\nexport type TooltipProps = {\n /**\n * The elements that the tooltip should surround.\n */\n children: ReactNode;\n /**\n * The element where the content of the `Tooltip` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The content that should be displayed.\n */\n item: ITooltipItem | ReactNode;\n /**\n * The width of an item.\n */\n itemWidth?: CSSProperties['width'];\n /**\n * whether the tooltip should be shown.\n */\n isDisabled?: boolean;\n /**\n * Whether the width of the children should be used.\n */\n shouldUseChildrenWidth?: boolean;\n};\n\nconst Tooltip: FC<TooltipProps> = ({\n item,\n children,\n container,\n isDisabled,\n itemWidth,\n shouldUseChildrenWidth = true,\n}) => {\n const tooltipRef = useRef<PopupRef>(null);\n\n const content = useMemo(() => {\n if (isValidElement(item)) {\n return item;\n }\n\n return (\n <TooltipItem\n width={itemWidth}\n text={(item as ITooltipItem).text}\n headline={(item as ITooltipItem).headline}\n imageUrl={(item as ITooltipItem).imageUrl}\n button={(item as ITooltipItem).button}\n />\n );\n }, [item, itemWidth]);\n\n return useMemo(\n () => (\n <StyledTooltip>\n {isDisabled ? (\n <StyledTooltipChildren\n $isOnlyText={isTextOnlyElement(children)}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n >\n {children}\n </StyledTooltipChildren>\n ) : (\n <Popup\n shouldShowOnHover\n content={content}\n ref={tooltipRef}\n container={container}\n shouldUseChildrenWidth={shouldUseChildrenWidth}\n >\n <StyledTooltipChildren\n $isOnlyText={isTextOnlyElement(children)}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n >\n {children}\n </StyledTooltipChildren>\n </Popup>\n )}\n </StyledTooltip>\n ),\n [isDisabled
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["React","isValidElement","useMemo","useRef","isTextOnlyElement","Popup","TooltipItem","StyledTooltip","StyledTooltipChildren","Tooltip","_ref","item","children","container","isDisabled","shouldHideOnChildrenLeave","yOffset","itemWidth","shouldUseChildrenWidth","tooltipRef","content","createElement","width","text","headline","imageUrl","button","$isOnlyText","$shouldUseChildrenWidth","shouldShowOnHover","ref","displayName"],"sources":["../../../../src/components/tooltip/Tooltip.tsx"],"sourcesContent":["import React, { FC, isValidElement, ReactNode, useMemo, useRef, type CSSProperties } from 'react';\nimport type { PopupRef } from '../../types/popup';\nimport type { ITooltipItem } from '../../types/tooltip';\nimport { isTextOnlyElement } from '../../utils/tooltip';\nimport Popup from '../popup/Popup';\nimport TooltipItem from './tooltip-item/TooltipItem';\nimport { StyledTooltip, StyledTooltipChildren } from './Tooltip.styles';\n\nexport type TooltipProps = {\n /**\n * The elements that the tooltip should surround.\n */\n children: ReactNode;\n /**\n * The element where the content of the `Tooltip` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The content that should be displayed.\n */\n item: ITooltipItem | ReactNode;\n /**\n * The width of an item.\n */\n itemWidth?: CSSProperties['width'];\n /**\n * whether the tooltip should be shown.\n */\n isDisabled?: boolean;\n /**\n * Whether the tooltip should be hidden after the children is not hovered.\n */\n shouldHideOnChildrenLeave?: boolean;\n /**\n * Whether the width of the children should be used.\n */\n shouldUseChildrenWidth?: boolean;\n /**\n * The Y offset of the tooltip to the children.\n */\n yOffset?: number;\n};\n\nconst Tooltip: FC<TooltipProps> = ({\n item,\n children,\n container,\n isDisabled,\n shouldHideOnChildrenLeave,\n yOffset,\n itemWidth,\n shouldUseChildrenWidth = true,\n}) => {\n const tooltipRef = useRef<PopupRef>(null);\n\n const content = useMemo(() => {\n if (isValidElement(item)) {\n return item;\n }\n\n return (\n <TooltipItem\n width={itemWidth}\n text={(item as ITooltipItem).text}\n headline={(item as ITooltipItem).headline}\n imageUrl={(item as ITooltipItem).imageUrl}\n button={(item as ITooltipItem).button}\n />\n );\n }, [item, itemWidth]);\n\n return useMemo(\n () => (\n <StyledTooltip>\n {isDisabled ? (\n <StyledTooltipChildren\n $isOnlyText={isTextOnlyElement(children)}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n >\n {children}\n </StyledTooltipChildren>\n ) : (\n <Popup\n shouldShowOnHover\n shouldHideOnChildrenLeave={shouldHideOnChildrenLeave}\n content={content}\n ref={tooltipRef}\n container={container}\n yOffset={yOffset}\n shouldUseChildrenWidth={shouldUseChildrenWidth}\n >\n <StyledTooltipChildren\n $isOnlyText={isTextOnlyElement(children)}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n >\n {children}\n </StyledTooltipChildren>\n </Popup>\n )}\n </StyledTooltip>\n ),\n [\n isDisabled,\n children,\n shouldUseChildrenWidth,\n shouldHideOnChildrenLeave,\n content,\n container,\n yOffset,\n ],\n );\n};\n\nTooltip.displayName = 'Tooltip';\n\nexport default Tooltip;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAQC,cAAc,EAAaC,OAAO,EAAEC,MAAM,QAA4B,OAAO;AAGjG,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,OAAOC,KAAK,MAAM,gBAAgB;AAClC,OAAOC,WAAW,MAAM,4BAA4B;AACpD,SAASC,aAAa,EAAEC,qBAAqB,QAAQ,kBAAkB;AAqCvE,MAAMC,OAAyB,GAAGC,IAAA,IAS5B;EAAA,IAT6B;IAC/BC,IAAI;IACJC,QAAQ;IACRC,SAAS;IACTC,UAAU;IACVC,yBAAyB;IACzBC,OAAO;IACPC,SAAS;IACTC,sBAAsB,GAAG;EAC7B,CAAC,GAAAR,IAAA;EACG,MAAMS,UAAU,GAAGhB,MAAM,CAAW,IAAI,CAAC;EAEzC,MAAMiB,OAAO,GAAGlB,OAAO,CAAC,MAAM;IAC1B,iBAAID,cAAc,CAACU,IAAI,CAAC,EAAE;MACtB,OAAOA,IAAI;IACf;IAEA,oBACIX,KAAA,CAAAqB,aAAA,CAACf,WAAW;MACRgB,KAAK,EAAEL,SAAU;MACjBM,IAAI,EAAGZ,IAAI,CAAkBY,IAAK;MAClCC,QAAQ,EAAGb,IAAI,CAAkBa,QAAS;MAC1CC,QAAQ,EAAGd,IAAI,CAAkBc,QAAS;MAC1CC,MAAM,EAAGf,IAAI,CAAkBe;IAAO,CACzC,CAAC;EAEV,CAAC,EAAE,CAACf,IAAI,EAAEM,SAAS,CAAC,CAAC;EAErB,OAAOf,OAAO,CACV,mBACIF,KAAA,CAAAqB,aAAA,CAACd,aAAa,QACTO,UAAU,gBACPd,KAAA,CAAAqB,aAAA,CAACb,qBAAqB;IAClBmB,WAAW,EAAEvB,iBAAiB,CAACQ,QAAQ,CAAE;IACzCgB,uBAAuB,EAAEV;EAAuB,GAE/CN,QACkB,CAAC,gBAExBZ,KAAA,CAAAqB,aAAA,CAAChB,KAAK;IACFwB,iBAAiB;IACjBd,yBAAyB,EAAEA,yBAA0B;IACrDK,OAAO,EAAEA,OAAQ;IACjBU,GAAG,EAAEX,UAAW;IAChBN,SAAS,EAAEA,SAAU;IACrBG,OAAO,EAAEA,OAAQ;IACjBE,sBAAsB,EAAEA;EAAuB,gBAE/ClB,KAAA,CAAAqB,aAAA,CAACb,qBAAqB;IAClBmB,WAAW,EAAEvB,iBAAiB,CAACQ,QAAQ,CAAE;IACzCgB,uBAAuB,EAAEV;EAAuB,GAE/CN,QACkB,CACpB,CAEA,CAClB,EACD,CACIE,UAAU,EACVF,QAAQ,EACRM,sBAAsB,EACtBH,yBAAyB,EACzBK,OAAO,EACPP,SAAS,EACTG,OAAO,CAEf,CAAC;AACL,CAAC;AAEDP,OAAO,CAACsB,WAAW,GAAG,SAAS;AAE/B,eAAetB,OAAO","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@ import type { ComboBoxProps, IComboBoxItem } from '../ComboBox';
|
|
|
3
3
|
export type ComboBoxItemProps = {
|
|
4
4
|
icons?: IComboBoxItem['icons'];
|
|
5
5
|
id: IComboBoxItem['value'];
|
|
6
|
+
imageBackgroundColor?: IComboBoxItem['imageBackgroundColor'];
|
|
6
7
|
imageUrl: IComboBoxItem['imageUrl'];
|
|
7
8
|
isDisabled?: IComboBoxItem['isDisabled'];
|
|
8
9
|
isSelected: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
1
2
|
import type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';
|
|
2
3
|
type StyledComboBoxItemProps = WithTheme<{
|
|
3
4
|
$isDisabled?: boolean;
|
|
@@ -6,6 +7,7 @@ type StyledComboBoxItemProps = WithTheme<{
|
|
|
6
7
|
}>;
|
|
7
8
|
export declare const StyledComboBoxItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledComboBoxItemProps>> & string;
|
|
8
9
|
type StyledComboBoxItemImageProps = WithTheme<{
|
|
10
|
+
$backgroundColor?: CSSProperties['backgroundColor'];
|
|
9
11
|
$shouldShowBigImage?: boolean;
|
|
10
12
|
$shouldShowRoundImage?: boolean;
|
|
11
13
|
}>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { FC, MouseEventHandler } from 'react';
|
|
1
|
+
import { CSSProperties, FC, MouseEventHandler } from 'react';
|
|
2
2
|
type GridImageProps = {
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
5
|
-
|
|
4
|
+
* The background color of the image.
|
|
5
|
+
*/
|
|
6
|
+
backgroundColor?: CSSProperties['backgroundColor'];
|
|
7
|
+
/**
|
|
8
|
+
* The images to be displayed in the `GridImage`. Only the first three images are displayed.
|
|
6
9
|
*/
|
|
7
10
|
images: string[];
|
|
8
11
|
/**
|
|
@@ -10,8 +13,7 @@ type GridImageProps = {
|
|
|
10
13
|
*/
|
|
11
14
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
12
15
|
/**
|
|
13
|
-
* Images of users should always be displayed in a round shape. Therefore
|
|
14
|
-
* this property can be set to true.
|
|
16
|
+
* Images of users should always be displayed in a round shape. Therefore, this property can be set to true.
|
|
15
17
|
*/
|
|
16
18
|
shouldShowRoundImage?: boolean;
|
|
17
19
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
1
2
|
import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
|
|
2
3
|
type StyledGridImageProps = WithTheme<{
|
|
4
|
+
$backgroundColor?: CSSProperties['backgroundColor'];
|
|
3
5
|
$shouldShowRoundImage?: boolean;
|
|
4
6
|
$size: number;
|
|
5
7
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC, MouseEventHandler, ReactNode, TouchEventHandler } from 'react';
|
|
1
|
+
import { CSSProperties, FC, MouseEventHandler, ReactNode, TouchEventHandler } from 'react';
|
|
2
2
|
import type { IListItemRightElements } from '../../../types/list';
|
|
3
3
|
export type ListItemElements = [ReactNode, ...ReactNode[]];
|
|
4
4
|
export type ListItemProps = {
|
|
@@ -18,6 +18,10 @@ export type ListItemProps = {
|
|
|
18
18
|
* documentation for more information.
|
|
19
19
|
*/
|
|
20
20
|
icons?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* The background color of the image. This is only used if images are passed.
|
|
23
|
+
*/
|
|
24
|
+
imageBackgroundColor?: CSSProperties['backgroundColor'];
|
|
21
25
|
/**
|
|
22
26
|
* A list of image URLs that are displayed on the left side of the header.
|
|
23
27
|
* If multiple URLs are passed, the image is assembled from the first three
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { FC, MouseEventHandler, ReactNode, TouchEventHandler } from 'react';
|
|
1
|
+
import { CSSProperties, FC, MouseEventHandler, ReactNode, TouchEventHandler } from 'react';
|
|
2
2
|
import type { IListItemRightElements } from '../../../../types/list';
|
|
3
3
|
type ListItemHeadProps = {
|
|
4
4
|
hoverItem?: ReactNode;
|
|
5
5
|
icons?: string[];
|
|
6
|
+
imageBackgroundColor?: CSSProperties['backgroundColor'];
|
|
6
7
|
images?: string[];
|
|
7
8
|
isAnyItemExpandable: boolean;
|
|
8
9
|
isExpandable: boolean;
|
package/lib/types/components/list/list-item/list-item-head/list-item-image/ListItemImage.styles.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
1
2
|
import type { WithTheme } from '../../../../color-scheme-provider/ColorSchemeProvider';
|
|
2
3
|
type StyledListItemHeadImageWrapperProps = WithTheme<{
|
|
3
4
|
$shouldHideBackground?: boolean;
|
|
4
5
|
$shouldShowRoundImage?: boolean;
|
|
5
6
|
}>;
|
|
6
7
|
export declare const StyledListItemHeadImageWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledListItemHeadImageWrapperProps>> & string;
|
|
7
|
-
type StyledListItemHeadImageProps = {
|
|
8
|
+
type StyledListItemHeadImageProps = WithTheme<{
|
|
9
|
+
$backgroundColor?: CSSProperties['backgroundColor'];
|
|
8
10
|
$isHidden: boolean;
|
|
9
|
-
}
|
|
11
|
+
}>;
|
|
10
12
|
export declare const StyledListItemHeadImage: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, StyledListItemHeadImageProps>> & string;
|
|
11
13
|
export {};
|
|
@@ -21,6 +21,10 @@ export type PopupProps = {
|
|
|
21
21
|
* Function to be executed when the content of the Context menu has been shown.
|
|
22
22
|
*/
|
|
23
23
|
onShow?: VoidFunction;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the tooltip should be hidden after the children is not hovered.
|
|
26
|
+
*/
|
|
27
|
+
shouldHideOnChildrenLeave?: boolean;
|
|
24
28
|
/**
|
|
25
29
|
* Whether the popup should be opened on hover. If not, the popup will be opened on click.
|
|
26
30
|
*/
|
|
@@ -21,10 +21,18 @@ export type TooltipProps = {
|
|
|
21
21
|
* whether the tooltip should be shown.
|
|
22
22
|
*/
|
|
23
23
|
isDisabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the tooltip should be hidden after the children is not hovered.
|
|
26
|
+
*/
|
|
27
|
+
shouldHideOnChildrenLeave?: boolean;
|
|
24
28
|
/**
|
|
25
29
|
* Whether the width of the children should be used.
|
|
26
30
|
*/
|
|
27
31
|
shouldUseChildrenWidth?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The Y offset of the tooltip to the children.
|
|
34
|
+
*/
|
|
35
|
+
yOffset?: number;
|
|
28
36
|
};
|
|
29
37
|
declare const Tooltip: FC<TooltipProps>;
|
|
30
38
|
export default Tooltip;
|
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.976",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "5ff0d9298451b1b13ccb1e44a166132529b6a083"
|
|
91
91
|
}
|