@chayns-components/core 5.0.0-beta.1206 → 5.0.0-beta.1208
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/grouped-image/GroupedImage.js +4 -2
- package/lib/cjs/components/grouped-image/GroupedImage.js.map +1 -1
- package/lib/cjs/components/list/list-item/ListItem.js +5 -3
- package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
- package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js +4 -2
- 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 +4 -2
- package/lib/cjs/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map +1 -1
- package/lib/cjs/utils/pageProvider.js +4 -0
- package/lib/cjs/utils/pageProvider.js.map +1 -1
- package/lib/esm/components/grouped-image/GroupedImage.js +4 -2
- package/lib/esm/components/grouped-image/GroupedImage.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.js +5 -3
- package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
- package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js +4 -2
- 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 +4 -2
- package/lib/esm/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map +1 -1
- package/lib/esm/utils/pageProvider.js +4 -0
- package/lib/esm/utils/pageProvider.js.map +1 -1
- package/lib/types/components/grouped-image/GroupedImage.d.ts +5 -1
- 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/package.json +2 -2
|
@@ -15,7 +15,8 @@ const GroupedImage = ({
|
|
|
15
15
|
onClick,
|
|
16
16
|
shouldPreventBackground = false,
|
|
17
17
|
shouldShowRoundImage = false,
|
|
18
|
-
cornerElement
|
|
18
|
+
cornerElement,
|
|
19
|
+
onImageError
|
|
19
20
|
}) => {
|
|
20
21
|
const hasCornerImage = Boolean(cornerImage);
|
|
21
22
|
const hasCornerElement = Boolean(cornerElement);
|
|
@@ -36,7 +37,8 @@ const GroupedImage = ({
|
|
|
36
37
|
// eslint-disable-next-line react/no-array-index-key
|
|
37
38
|
,
|
|
38
39
|
key: index,
|
|
39
|
-
src: src
|
|
40
|
+
src: src,
|
|
41
|
+
onError: event => typeof onImageError === 'function' && onImageError(event, index)
|
|
40
42
|
}));
|
|
41
43
|
return /*#__PURE__*/_react.default.createElement(_GroupedImage.StyledGroupedImage, {
|
|
42
44
|
onClick: onClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupedImage.js","names":["_react","_interopRequireWildcard","require","_GroupedImage","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","GroupedImage","cornerImage","height","imageBackground","images","onClick","shouldPreventBackground","shouldShowRoundImage","cornerElement","hasCornerImage","Boolean","hasCornerElement","hasMultipleImages","length","imageSize","useMemo","ImageSize","GroupedSmall","Small","Grouped","Full","imageElements","slice","map","src","index","createElement","StyledGroupImageElement","$background","$imageSize","$isSecondImage","$shouldPreventBackground","$shouldShowRoundImage","key","StyledGroupedImage","$height","StyledCornerImage","StyledCornerElement","displayName","_default","exports"],"sources":["../../../../src/components/grouped-image/GroupedImage.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"GroupedImage.js","names":["_react","_interopRequireWildcard","require","_GroupedImage","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","GroupedImage","cornerImage","height","imageBackground","images","onClick","shouldPreventBackground","shouldShowRoundImage","cornerElement","onImageError","hasCornerImage","Boolean","hasCornerElement","hasMultipleImages","length","imageSize","useMemo","ImageSize","GroupedSmall","Small","Grouped","Full","imageElements","slice","map","src","index","createElement","StyledGroupImageElement","$background","$imageSize","$isSecondImage","$shouldPreventBackground","$shouldShowRoundImage","key","onError","event","StyledGroupedImage","$height","StyledCornerImage","StyledCornerElement","displayName","_default","exports"],"sources":["../../../../src/components/grouped-image/GroupedImage.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n useMemo,\n} from 'react';\nimport {\n ImageSize,\n StyledCornerElement,\n StyledCornerImage,\n StyledGroupedImage,\n StyledGroupImageElement,\n} from './GroupedImage.styles';\n\ntype GroupedImageProps = {\n /**\n * Optional image to display in the bottom right corner of the grouped image.\n */\n cornerImage?: string;\n /**\n * Height of the grouped image container.\n */\n height?: CSSProperties['height'];\n /**\n * Background for the single images.\n */\n imageBackground?: CSSProperties['background'];\n /**\n * Array of image URLs to display in the grouped image. If only one image is provided, it will be displayed as a full image.\n */\n images: string[];\n /**\n * Optional click handler for the grouped image.\n */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /**\n * Whether to prevent the background of the images from being set.\n */\n shouldPreventBackground?: boolean;\n /**\n * Whether to show the images in a round shape.\n */\n shouldShowRoundImage?: boolean;\n /**\n * Optional Element to display in the right corner of the image\n */\n cornerElement?: ReactNode;\n /**\n * Optional handler for image load errors.\n */\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n};\n\nconst GroupedImage: FC<GroupedImageProps> = ({\n cornerImage,\n height = '40px',\n imageBackground,\n images,\n onClick,\n shouldPreventBackground = false,\n shouldShowRoundImage = false,\n cornerElement,\n onImageError,\n}) => {\n const hasCornerImage = Boolean(cornerImage);\n const hasCornerElement = Boolean(cornerElement);\n const hasMultipleImages = images.length > 1;\n\n const imageSize = useMemo(() => {\n if (hasCornerImage) {\n return hasMultipleImages ? ImageSize.GroupedSmall : ImageSize.Small;\n }\n\n return hasMultipleImages ? ImageSize.Grouped : ImageSize.Full;\n }, [hasCornerImage, hasMultipleImages]);\n\n const imageElements = images\n .slice(0, 2) // Limit to 2 images for grouping\n .map((src, index) => (\n <StyledGroupImageElement\n $background={imageBackground}\n $imageSize={imageSize}\n $isSecondImage={index === 1}\n $shouldPreventBackground={shouldPreventBackground}\n $shouldShowRoundImage={shouldShowRoundImage}\n // eslint-disable-next-line react/no-array-index-key\n key={index}\n src={src}\n onError={(event) =>\n typeof onImageError === 'function' && onImageError(event, index)\n }\n />\n ));\n\n return (\n <StyledGroupedImage onClick={onClick} $height={height}>\n {imageElements}\n {hasCornerImage && (\n <StyledCornerImage\n $background={imageBackground}\n $shouldPreventBackground={shouldPreventBackground}\n src={cornerImage}\n key=\"corner-image\"\n />\n )}\n {hasCornerElement && <StyledCornerElement>{cornerElement}</StyledCornerElement>}\n </StyledGroupedImage>\n );\n};\n\nGroupedImage.displayName = 'GroupedImage';\n\nexport default GroupedImage;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAQA,IAAAC,aAAA,GAAAD,OAAA;AAM+B,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAA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AAC/C,aAAA,CAAAgD,uBAAuB;IACpBC,WAAW,EAAE1B,eAAgB;IAC7B2B,UAAU,EAAEf,SAAU;IACtBgB,cAAc,EAAEL,KAAK,KAAK,CAAE;IAC5BM,wBAAwB,EAAE1B,uBAAwB;IAClD2B,qBAAqB,EAAE1B;IACvB;IAAA;IACA2B,GAAG,EAAER,KAAM;IACXD,GAAG,EAAEA,GAAI;IACTU,OAAO,EAAGC,KAAK,IACX,OAAO3B,YAAY,KAAK,UAAU,IAAIA,YAAY,CAAC2B,KAAK,EAAEV,KAAK;EAClE,CACJ,CACJ,CAAC;EAEN,oBACIjD,MAAA,CAAAc,OAAA,CAAAoC,aAAA,CAAC/C,aAAA,CAAAyD,kBAAkB;IAAChC,OAAO,EAAEA,OAAQ;IAACiC,OAAO,EAAEpC;EAAO,GACjDoB,aAAa,EACbZ,cAAc,iBACXjC,MAAA,CAAAc,OAAA,CAAAoC,aAAA,CAAC/C,aAAA,CAAA2D,iBAAiB;IACdV,WAAW,EAAE1B,eAAgB;IAC7B6B,wBAAwB,EAAE1B,uBAAwB;IAClDmB,GAAG,EAAExB,WAAY;IACjBiC,GAAG,EAAC;EAAc,CACrB,CACJ,EACAtB,gBAAgB,iBAAInC,MAAA,CAAAc,OAAA,CAAAoC,aAAA,CAAC/C,aAAA,CAAA4D,mBAAmB,QAAEhC,aAAmC,CAC9D,CAAC;AAE7B,CAAC;AAEDR,YAAY,CAACyC,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAApD,OAAA,GAE3BS,YAAY","ignoreList":[]}
|
|
@@ -51,7 +51,8 @@ const ListItem = ({
|
|
|
51
51
|
title,
|
|
52
52
|
titleElement,
|
|
53
53
|
shouldDisableAnimation = false,
|
|
54
|
-
cornerElement
|
|
54
|
+
cornerElement,
|
|
55
|
+
onImageError
|
|
55
56
|
}) => {
|
|
56
57
|
const {
|
|
57
58
|
incrementExpandableItemCount,
|
|
@@ -136,8 +137,9 @@ const ListItem = ({
|
|
|
136
137
|
title: title,
|
|
137
138
|
titleElement: titleElement,
|
|
138
139
|
setShouldEnableTooltip: setShouldEnableTooltip,
|
|
139
|
-
shouldDisableAnimation: shouldDisableAnimation
|
|
140
|
-
|
|
140
|
+
shouldDisableAnimation: shouldDisableAnimation,
|
|
141
|
+
onImageError: onImageError
|
|
142
|
+
}), [hoverItem, careOfLocationId, cornerElement, cornerImage, icons, imageBackground, images, isAnyItemExpandable, isExpandable, isItemOpen, isTitleGreyed, leftElements, isClickable, handleHeadClick, onLongPress, shouldForceHover, rightElements, shouldHideImageOrIconBackground, shouldHideIndicator, shouldOpenImageOnClick, shouldShowRoundImageOrIcon, subtitle, title, titleElement, shouldDisableAnimation, onImageError]);
|
|
141
143
|
return /*#__PURE__*/_react2.default.createElement(_ListItem.StyledListItem, {
|
|
142
144
|
as: shouldDisableAnimation ? undefined : _react.motion[_list.LIST_ITEM_HTML_TAG],
|
|
143
145
|
animate: shouldDisableAnimation ? undefined : {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["_react","require","_react2","_interopRequireWildcard","_uuid","_Accordion","_AreaContextProvider","_List","_ListItemBody","_interopRequireDefault","_ListItemHead","_ListItem","_Tooltip","_list","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ListItem","backgroundColor","careOfLocationId","children","cornerImage","hoverItem","icons","imageBackground","images","isDefaultOpen","isOpen","isTitleGreyed","leftElements","onClick","onClose","onLongPress","onOpen","rightElements","shouldShowTooltipOnTitleOverflow","shouldForceBackground","shouldForceBottomLine","shouldForceHover","shouldHideBottomLine","shouldOpenImageOnClick","shouldHideImageOrIconBackground","shouldHideIndicator","shouldPreventLayoutAnimation","shouldRenderClosed","shouldShowRoundImageOrIcon","shouldShowSeparatorBelow","subtitle","title","titleElement","shouldDisableAnimation","cornerElement","incrementExpandableItemCount","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","useContext","ListContext","isParentAccordionWrapped","AccordionContext","areaProvider","AreaContext","isInitialRenderRef","useRef","listItemRef","uuid","useUuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","useState","useEffect","current","handleHeadClick","useCallback","event","shouldOnlyOpen","isClickable","headContent","useMemo","createElement","StyledListItem","as","motion","LIST_ITEM_HTML_TAG","animate","height","opacity","className","exit","initial","key","ref","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","shouldUseFullWidth","isDisabled","item","StyledListItemTooltip","style","cursor","AnimatePresence","id","shouldHideBody","displayName","_default","exports"],"sources":["../../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence, motion } from 'motion/react';\nimport React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem, StyledListItemTooltip } from './ListItem.styles';\nimport Tooltip from '../../tooltip/Tooltip';\nimport { LIST_ITEM_HTML_TAG } from '../../../constants/list';\n\nexport type ListItemElements = [ReactNode, ...ReactNode[]];\n\nexport type ListItemProps = {\n /**\n * The background color of the `ListItem`.\n */\n backgroundColor?: CSSProperties['backgroundColor'];\n /**\n * DEPRECATED: Use `cornerImage` instead.\n */\n careOfLocationId?: number;\n /**\n * The content of the `ListItem` body. When the `ListItem` has children,\n * it can be opened and also gets an icon as an indicator automatically.\n */\n children?: ReactNode;\n /**\n * The image that is displayed in the bottom right corner of the grouped image of list item.\n */\n cornerImage?: string;\n /**\n * Element that is displayed when hovering over the `ListItem` on the right\n * side. On mobile devices, this element is not displayed.\n */\n hoverItem?: ReactNode;\n /**\n * The FontAwesome or tobit icons to render like an image on the left side\n * of the header. Multiple icons are stacked. See the `Icon` component\n * documentation for more information.\n */\n icons?: string[];\n /**\n * The background of the image. This is only used if images are passed.\n */\n imageBackground?: CSSProperties['background'];\n /**\n * A list of image URLs that are displayed on the left side of the header.\n * If multiple URLs are passed, the image is assembled from the first three\n * image URLs as a puzzle.\n */\n images?: string[];\n /**\n * This can be used to automatically expand the `ListItem` during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This overrides the internal opening state of the item and makes it controlled.\n */\n isOpen?: boolean;\n /**\n * Whether the ListItem locks disabled but has full functionality.\n */\n isTitleGreyed?: boolean;\n /**\n * Elements that are displayed on the left side of the header. If multiple\n * elements are specified, they are displayed one aside the other.\n */\n leftElements?: ListItemElements;\n /**\n * Function to be executed when the header of the `ListItem` was clicked\n */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the ListItem is closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the header of the `ListItem` is pressed for\n * 400 milliseconds.\n */\n onLongPress?: TouchEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the ListItem is opened.\n */\n onOpen?: VoidFunction;\n /**\n * Elements that are displayed on the right side of the header. If multiple\n * elements are specified, they are displayed one below the other.\n */\n rightElements?: IListItemRightElements;\n /**\n * This will force the background color of the ListItem to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * Whether the line should be forced, e.g., so that it is also displayed if the item is the last element in the list.\n */\n shouldForceBottomLine?: boolean;\n /**\n * Whether the hover item should be forced.\n */\n shouldForceHover?: boolean;\n /**\n * Whether the bottom line should be hidden.\n */\n shouldHideBottomLine?: boolean;\n /**\n * Whether the background and border of the shape on which the image or icon of the element is displayed should be\n * hidden.\n */\n shouldHideImageOrIconBackground?: boolean;\n /**\n * If the `ListItem` is expandable, the indicator is displayed on the left\n * side of the header. If this property is set to true, the indicator is\n * hidden.\n */\n shouldHideIndicator?: boolean;\n /**\n * Whether the image should be opened on click.\n */\n shouldOpenImageOnClick?: boolean;\n /**\n * Whether the layout animation should be prevented. This is useful when the\n * `ListItem` is used in a list with a lot of items and the layout animation\n * is not desired.\n */\n shouldPreventLayoutAnimation?: boolean;\n /**\n * This will render the ListItem closed on the first render.\n */\n shouldRenderClosed?: boolean;\n /**\n * Whether the image or icon should be displayed in a round shape. This should always be used for images of persons.\n */\n shouldShowRoundImageOrIcon?: boolean;\n /**\n * Whether a separator should be displayed below this item. In this case, the border is displayed thicker than normal.\n */\n shouldShowSeparatorBelow?: boolean;\n /**\n * Whether a Tooltip should be displayed on hover if the title is cut.\n */\n shouldShowTooltipOnTitleOverflow?: boolean;\n /**\n * Subtitle of the `ListItem` displayed in the head below the title\n */\n subtitle?: ReactNode;\n /**\n * Title of the `ListItem` displayed in the head\n */\n title: ReactNode;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n\n /**\n * Whether the ListItem Animation should be disabled.\n */\n shouldDisableAnimation?: boolean;\n /**\n * Optional Element to display in the right corner of the image\n */\n cornerElement?: ReactNode;\n};\n\nconst ListItem: FC<ListItemProps> = ({\n backgroundColor,\n careOfLocationId,\n children,\n cornerImage,\n hoverItem,\n icons,\n imageBackground,\n images,\n isDefaultOpen,\n isOpen,\n isTitleGreyed,\n leftElements,\n onClick,\n onClose,\n onLongPress,\n onOpen,\n rightElements,\n shouldShowTooltipOnTitleOverflow = false,\n shouldForceBackground = false,\n shouldForceBottomLine = false,\n shouldForceHover = false,\n shouldHideBottomLine = false,\n shouldOpenImageOnClick = false,\n shouldHideImageOrIconBackground,\n shouldHideIndicator = false,\n shouldPreventLayoutAnimation = false,\n shouldRenderClosed = false,\n shouldShowRoundImageOrIcon,\n shouldShowSeparatorBelow = false,\n subtitle,\n title,\n titleElement,\n shouldDisableAnimation = false,\n cornerElement,\n}) => {\n const {\n incrementExpandableItemCount,\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n } = useContext(ListContext);\n\n const { isWrapped: isParentAccordionWrapped } = useContext(AccordionContext);\n\n const areaProvider = useContext(AreaContext);\n\n const isInitialRenderRef = useRef(true);\n\n const listItemRef = useRef<HTMLDivElement>(null);\n\n const uuid = useUuid();\n\n const isExpandable = children !== undefined;\n const isItemOpen = isOpen ?? openItemUuid === uuid;\n\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n\n const [shouldEnableTooltip, setShouldEnableTooltip] = useState(false);\n\n useEffect(() => {\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [isOpen, onClose, onOpen]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isItemOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isItemOpen]);\n\n const handleHeadClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n if (isExpandable) {\n updateOpenItemUuid(uuid);\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n },\n [isExpandable, onClick, updateOpenItemUuid, uuid],\n );\n\n useEffect(() => {\n if (isExpandable && !shouldHideIndicator) {\n // The incrementExpandableItemCount function returns a cleanup\n // function to decrement expandableItemCount if component unmounts\n return incrementExpandableItemCount();\n }\n\n return undefined;\n }, [incrementExpandableItemCount, isExpandable, shouldHideIndicator]);\n\n useEffect(() => {\n if (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n const isClickable = typeof onClick === 'function' || isExpandable;\n\n const headContent = useMemo(\n () => (\n <ListItemHead\n hoverItem={hoverItem}\n careOfLocationId={careOfLocationId}\n cornerElement={cornerElement}\n cornerImage={cornerImage}\n icons={icons}\n imageBackground={imageBackground}\n images={images}\n isAnyItemExpandable={isAnyItemExpandable}\n isExpandable={isExpandable}\n isOpen={isItemOpen}\n isTitleGreyed={isTitleGreyed}\n leftElements={leftElements}\n onClick={isClickable ? handleHeadClick : undefined}\n onLongPress={onLongPress}\n shouldForceHover={shouldForceHover}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n titleElement={titleElement}\n setShouldEnableTooltip={setShouldEnableTooltip}\n shouldDisableAnimation={shouldDisableAnimation}\n />\n ),\n [\n careOfLocationId,\n cornerElement,\n cornerImage,\n handleHeadClick,\n hoverItem,\n icons,\n imageBackground,\n images,\n isAnyItemExpandable,\n isClickable,\n isExpandable,\n isItemOpen,\n isTitleGreyed,\n leftElements,\n onLongPress,\n rightElements,\n shouldForceHover,\n shouldHideImageOrIconBackground,\n shouldHideIndicator,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n subtitle,\n title,\n titleElement,\n shouldDisableAnimation,\n ],\n );\n\n return (\n <StyledListItem\n as={shouldDisableAnimation ? undefined : motion[LIST_ITEM_HTML_TAG]}\n animate={shouldDisableAnimation ? undefined : { height: 'auto', opacity: 1 }}\n className=\"beta-chayns-list-item\"\n exit={shouldDisableAnimation ? undefined : { height: 0, opacity: 0 }}\n initial={shouldDisableAnimation ? undefined : { height: 0, opacity: 0 }}\n key={`list-item-${uuid}`}\n ref={listItemRef}\n layout={shouldPreventLayoutAnimation || shouldDisableAnimation ? undefined : 'position'}\n $backgroundColor={backgroundColor}\n $isClickable={isClickable}\n $isInAccordion={\n typeof isParentAccordionWrapped === 'boolean' &&\n !areaProvider.shouldDisableListItemPadding\n }\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n >\n <Tooltip\n shouldUseFullWidth\n isDisabled={!shouldShowTooltipOnTitleOverflow || !shouldEnableTooltip}\n item={\n <StyledListItemTooltip\n style={{ cursor: 'default' }}\n key={`list-item-tooltip-${uuid}`}\n >\n {title}\n </StyledListItemTooltip>\n }\n >\n {headContent}\n </Tooltip>\n <AnimatePresence initial={false}>\n {isExpandable && (isItemOpen || shouldRenderClosed) && (\n <ListItemBody\n id={uuid}\n key={`listItemBody-${uuid}`}\n shouldHideBody={shouldRenderClosed && !isItemOpen}\n >\n <AreaContextProvider>{children}</AreaContextProvider>\n </ListItemBody>\n )}\n </AnimatePresence>\n </StyledListItem>\n );\n};\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAaA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAH,uBAAA,CAAAF,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,aAAA,GAAAD,sBAAA,CAAAR,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,QAAA,GAAAH,sBAAA,CAAAR,OAAA;AACA,IAAAY,KAAA,GAAAZ,OAAA;AAA6D,SAAAQ,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAX,wBAAA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E,gCAAgC,IAAI,CAACsC,mBAAoB;IACtEyC,IAAI,eACAhI,OAAA,CAAAc,OAAA,CAAAqF,aAAA,CAAC1F,SAAA,CAAAwH,qBAAqB;MAClBC,KAAK,EAAE;QAAEC,MAAM,EAAE;MAAU,CAAE;MAC7BrB,GAAG,EAAE,qBAAqB9B,IAAI;IAAG,GAEhClB,KACkB;EAC1B,GAEAmC,WACI,CAAC,eACVjG,OAAA,CAAAc,OAAA,CAAAqF,aAAA,CAACrG,MAAA,CAAAsI,eAAe;IAACvB,OAAO,EAAE;EAAM,GAC3B3B,YAAY,KAAKE,UAAU,IAAI1B,kBAAkB,CAAC,iBAC/C1D,OAAA,CAAAc,OAAA,CAAAqF,aAAA,CAAC7F,aAAA,CAAAQ,OAAY;IACTuH,EAAE,EAAErD,IAAK;IACT8B,GAAG,EAAE,gBAAgB9B,IAAI,EAAG;IAC5BsD,cAAc,EAAE5E,kBAAkB,IAAI,CAAC0B;EAAW,gBAElDpF,OAAA,CAAAc,OAAA,CAAAqF,aAAA,CAAC/F,oBAAA,CAAAU,OAAmB,QAAEoB,QAA8B,CAC1C,CAEL,CACL,CAAC;AAEzB,CAAC;AAEDH,QAAQ,CAACwG,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3H,OAAA,GAEnBiB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItem.js","names":["_react","require","_react2","_interopRequireWildcard","_uuid","_Accordion","_AreaContextProvider","_List","_ListItemBody","_interopRequireDefault","_ListItemHead","_ListItem","_Tooltip","_list","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ListItem","backgroundColor","careOfLocationId","children","cornerImage","hoverItem","icons","imageBackground","images","isDefaultOpen","isOpen","isTitleGreyed","leftElements","onClick","onClose","onLongPress","onOpen","rightElements","shouldShowTooltipOnTitleOverflow","shouldForceBackground","shouldForceBottomLine","shouldForceHover","shouldHideBottomLine","shouldOpenImageOnClick","shouldHideImageOrIconBackground","shouldHideIndicator","shouldPreventLayoutAnimation","shouldRenderClosed","shouldShowRoundImageOrIcon","shouldShowSeparatorBelow","subtitle","title","titleElement","shouldDisableAnimation","cornerElement","onImageError","incrementExpandableItemCount","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","useContext","ListContext","isParentAccordionWrapped","AccordionContext","areaProvider","AreaContext","isInitialRenderRef","useRef","listItemRef","uuid","useUuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","useState","useEffect","current","handleHeadClick","useCallback","event","shouldOnlyOpen","isClickable","headContent","useMemo","createElement","StyledListItem","as","motion","LIST_ITEM_HTML_TAG","animate","height","opacity","className","exit","initial","key","ref","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","shouldUseFullWidth","isDisabled","item","StyledListItemTooltip","style","cursor","AnimatePresence","id","shouldHideBody","displayName","_default","exports"],"sources":["../../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence, motion } from 'motion/react';\nimport React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem, StyledListItemTooltip } from './ListItem.styles';\nimport Tooltip from '../../tooltip/Tooltip';\nimport { LIST_ITEM_HTML_TAG } from '../../../constants/list';\n\nexport type ListItemElements = [ReactNode, ...ReactNode[]];\n\nexport type ListItemProps = {\n /**\n * The background color of the `ListItem`.\n */\n backgroundColor?: CSSProperties['backgroundColor'];\n /**\n * DEPRECATED: Use `cornerImage` instead.\n */\n careOfLocationId?: number;\n /**\n * The content of the `ListItem` body. When the `ListItem` has children,\n * it can be opened and also gets an icon as an indicator automatically.\n */\n children?: ReactNode;\n /**\n * The image that is displayed in the bottom right corner of the grouped image of list item.\n */\n cornerImage?: string;\n /**\n * Element that is displayed when hovering over the `ListItem` on the right\n * side. On mobile devices, this element is not displayed.\n */\n hoverItem?: ReactNode;\n /**\n * The FontAwesome or tobit icons to render like an image on the left side\n * of the header. Multiple icons are stacked. See the `Icon` component\n * documentation for more information.\n */\n icons?: string[];\n /**\n * The background of the image. This is only used if images are passed.\n */\n imageBackground?: CSSProperties['background'];\n /**\n * A list of image URLs that are displayed on the left side of the header.\n * If multiple URLs are passed, the image is assembled from the first three\n * image URLs as a puzzle.\n */\n images?: string[];\n /**\n * This can be used to automatically expand the `ListItem` during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This overrides the internal opening state of the item and makes it controlled.\n */\n isOpen?: boolean;\n /**\n * Whether the ListItem locks disabled but has full functionality.\n */\n isTitleGreyed?: boolean;\n /**\n * Elements that are displayed on the left side of the header. If multiple\n * elements are specified, they are displayed one aside the other.\n */\n leftElements?: ListItemElements;\n /**\n * Function to be executed when the header of the `ListItem` was clicked\n */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the ListItem is closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the header of the `ListItem` is pressed for\n * 400 milliseconds.\n */\n onLongPress?: TouchEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the ListItem is opened.\n */\n onOpen?: VoidFunction;\n /**\n * Elements that are displayed on the right side of the header. If multiple\n * elements are specified, they are displayed one below the other.\n */\n rightElements?: IListItemRightElements;\n /**\n * This will force the background color of the ListItem to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * Whether the line should be forced, e.g., so that it is also displayed if the item is the last element in the list.\n */\n shouldForceBottomLine?: boolean;\n /**\n * Whether the hover item should be forced.\n */\n shouldForceHover?: boolean;\n /**\n * Whether the bottom line should be hidden.\n */\n shouldHideBottomLine?: boolean;\n /**\n * Whether the background and border of the shape on which the image or icon of the element is displayed should be\n * hidden.\n */\n shouldHideImageOrIconBackground?: boolean;\n /**\n * If the `ListItem` is expandable, the indicator is displayed on the left\n * side of the header. If this property is set to true, the indicator is\n * hidden.\n */\n shouldHideIndicator?: boolean;\n /**\n * Whether the image should be opened on click.\n */\n shouldOpenImageOnClick?: boolean;\n /**\n * Whether the layout animation should be prevented. This is useful when the\n * `ListItem` is used in a list with a lot of items and the layout animation\n * is not desired.\n */\n shouldPreventLayoutAnimation?: boolean;\n /**\n * This will render the ListItem closed on the first render.\n */\n shouldRenderClosed?: boolean;\n /**\n * Whether the image or icon should be displayed in a round shape. This should always be used for images of persons.\n */\n shouldShowRoundImageOrIcon?: boolean;\n /**\n * Whether a separator should be displayed below this item. In this case, the border is displayed thicker than normal.\n */\n shouldShowSeparatorBelow?: boolean;\n /**\n * Whether a Tooltip should be displayed on hover if the title is cut.\n */\n shouldShowTooltipOnTitleOverflow?: boolean;\n /**\n * Subtitle of the `ListItem` displayed in the head below the title\n */\n subtitle?: ReactNode;\n /**\n * Title of the `ListItem` displayed in the head\n */\n title: ReactNode;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n\n /**\n * Whether the ListItem Animation should be disabled.\n */\n shouldDisableAnimation?: boolean;\n /**\n * Optional Element to display in the right corner of the image\n */\n cornerElement?: ReactNode;\n /**\n * Optional handler for image load errors.\n */\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n};\n\nconst ListItem: FC<ListItemProps> = ({\n backgroundColor,\n careOfLocationId,\n children,\n cornerImage,\n hoverItem,\n icons,\n imageBackground,\n images,\n isDefaultOpen,\n isOpen,\n isTitleGreyed,\n leftElements,\n onClick,\n onClose,\n onLongPress,\n onOpen,\n rightElements,\n shouldShowTooltipOnTitleOverflow = false,\n shouldForceBackground = false,\n shouldForceBottomLine = false,\n shouldForceHover = false,\n shouldHideBottomLine = false,\n shouldOpenImageOnClick = false,\n shouldHideImageOrIconBackground,\n shouldHideIndicator = false,\n shouldPreventLayoutAnimation = false,\n shouldRenderClosed = false,\n shouldShowRoundImageOrIcon,\n shouldShowSeparatorBelow = false,\n subtitle,\n title,\n titleElement,\n shouldDisableAnimation = false,\n cornerElement,\n onImageError,\n}) => {\n const {\n incrementExpandableItemCount,\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n } = useContext(ListContext);\n\n const { isWrapped: isParentAccordionWrapped } = useContext(AccordionContext);\n\n const areaProvider = useContext(AreaContext);\n\n const isInitialRenderRef = useRef(true);\n\n const listItemRef = useRef<HTMLDivElement>(null);\n\n const uuid = useUuid();\n\n const isExpandable = children !== undefined;\n const isItemOpen = isOpen ?? openItemUuid === uuid;\n\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n\n const [shouldEnableTooltip, setShouldEnableTooltip] = useState(false);\n\n useEffect(() => {\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [isOpen, onClose, onOpen]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isItemOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isItemOpen]);\n\n const handleHeadClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n if (isExpandable) {\n updateOpenItemUuid(uuid);\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n },\n [isExpandable, onClick, updateOpenItemUuid, uuid],\n );\n\n useEffect(() => {\n if (isExpandable && !shouldHideIndicator) {\n // The incrementExpandableItemCount function returns a cleanup\n // function to decrement expandableItemCount if component unmounts\n return incrementExpandableItemCount();\n }\n\n return undefined;\n }, [incrementExpandableItemCount, isExpandable, shouldHideIndicator]);\n\n useEffect(() => {\n if (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n const isClickable = typeof onClick === 'function' || isExpandable;\n\n const headContent = useMemo(\n () => (\n <ListItemHead\n hoverItem={hoverItem}\n careOfLocationId={careOfLocationId}\n cornerElement={cornerElement}\n cornerImage={cornerImage}\n icons={icons}\n imageBackground={imageBackground}\n images={images}\n isAnyItemExpandable={isAnyItemExpandable}\n isExpandable={isExpandable}\n isOpen={isItemOpen}\n isTitleGreyed={isTitleGreyed}\n leftElements={leftElements}\n onClick={isClickable ? handleHeadClick : undefined}\n onLongPress={onLongPress}\n shouldForceHover={shouldForceHover}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n titleElement={titleElement}\n setShouldEnableTooltip={setShouldEnableTooltip}\n shouldDisableAnimation={shouldDisableAnimation}\n onImageError={onImageError}\n />\n ),\n [\n hoverItem,\n careOfLocationId,\n cornerElement,\n cornerImage,\n icons,\n imageBackground,\n images,\n isAnyItemExpandable,\n isExpandable,\n isItemOpen,\n isTitleGreyed,\n leftElements,\n isClickable,\n handleHeadClick,\n onLongPress,\n shouldForceHover,\n rightElements,\n shouldHideImageOrIconBackground,\n shouldHideIndicator,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n subtitle,\n title,\n titleElement,\n shouldDisableAnimation,\n onImageError,\n ],\n );\n\n return (\n <StyledListItem\n as={shouldDisableAnimation ? undefined : motion[LIST_ITEM_HTML_TAG]}\n animate={shouldDisableAnimation ? undefined : { height: 'auto', opacity: 1 }}\n className=\"beta-chayns-list-item\"\n exit={shouldDisableAnimation ? undefined : { height: 0, opacity: 0 }}\n initial={shouldDisableAnimation ? undefined : { height: 0, opacity: 0 }}\n key={`list-item-${uuid}`}\n ref={listItemRef}\n layout={shouldPreventLayoutAnimation || shouldDisableAnimation ? undefined : 'position'}\n $backgroundColor={backgroundColor}\n $isClickable={isClickable}\n $isInAccordion={\n typeof isParentAccordionWrapped === 'boolean' &&\n !areaProvider.shouldDisableListItemPadding\n }\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n >\n <Tooltip\n shouldUseFullWidth\n isDisabled={!shouldShowTooltipOnTitleOverflow || !shouldEnableTooltip}\n item={\n <StyledListItemTooltip\n style={{ cursor: 'default' }}\n key={`list-item-tooltip-${uuid}`}\n >\n {title}\n </StyledListItemTooltip>\n }\n >\n {headContent}\n </Tooltip>\n <AnimatePresence initial={false}>\n {isExpandable && (isItemOpen || shouldRenderClosed) && (\n <ListItemBody\n id={uuid}\n key={`listItemBody-${uuid}`}\n shouldHideBody={shouldRenderClosed && !isItemOpen}\n >\n <AreaContextProvider>{children}</AreaContextProvider>\n </ListItemBody>\n )}\n </AnimatePresence>\n </StyledListItem>\n );\n};\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAcA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAH,uBAAA,CAAAF,OAAA;AACA,IAAAM,KAAA,GAAAN,OA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7 +40,8 @@ const ListItemHead = ({
|
|
|
40
40
|
titleElement,
|
|
41
41
|
setShouldEnableTooltip,
|
|
42
42
|
shouldDisableAnimation = false,
|
|
43
|
-
cornerElement
|
|
43
|
+
cornerElement,
|
|
44
|
+
onImageError
|
|
44
45
|
}) => {
|
|
45
46
|
const [shouldShowHoverItem, setShouldShowHoverItem] = (0, _react2.useState)(false);
|
|
46
47
|
const titleWrapperRef = (0, _react2.useRef)(null);
|
|
@@ -106,7 +107,8 @@ const ListItemHead = ({
|
|
|
106
107
|
images: images,
|
|
107
108
|
shouldOpenImageOnClick: shouldOpenImageOnClick,
|
|
108
109
|
shouldHideBackground: !!shouldHideImageOrIconBackground,
|
|
109
|
-
shouldShowRoundImage: !!shouldShowRoundImageOrIcon
|
|
110
|
+
shouldShowRoundImage: !!shouldShowRoundImageOrIcon,
|
|
111
|
+
onImageError: onImageError
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemHead.js","names":["_react","require","_react2","_interopRequireWildcard","_accordion","_Icon","_interopRequireDefault","_ListItemIcon","_ListItemImage","_ListItemRightElements","_ListItemHead","_list","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ListItemHead","careOfLocationId","cornerImage","hoverItem","icons","imageBackground","images","isAnyItemExpandable","isExpandable","isOpen","isTitleGreyed","leftElements","onClick","onLongPress","rightElements","shouldHideImageOrIconBackground","shouldHideIndicator","shouldOpenImageOnClick","shouldShowRoundImageOrIcon","subtitle","shouldForceHover","title","titleElement","setShouldEnableTooltip","shouldDisableAnimation","cornerElement","shouldShowHoverItem","setShouldShowHoverItem","useState","titleWrapperRef","useRef","longPressTimeoutRef","shouldShowSubtitleRow","shouldShowMultilineTitle","useMemo","handleShowTooltipResize","useCallback","entries","_entries$","el","target","scrollWidth","clientWidth","useEffect","element","current","undefined","resizeObserver","ResizeObserver","observe","disconnect","handleMouseEnter","handleMouseLeave","handleTouchStart","event","window","setTimeout","handleTouchEnd","clearTimeout","shouldPreventRightElementClick","bottom","getElementClickEvent","center","top","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","StyledListItemHead","as","motion","LIST_ITEM_HEAD_HTML_TAG","animate","opacity","initial","transition","duration","type","className","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","StyledListItemHeadLeftWrapper","StyledListItemHeadIndicator","LIST_ITEM_HEAD_INDICATOR_HTML_TAG","rotate","StyledListItemHeadContent","$isIconOrImageGiven","$isOpen","LayoutGroup","StyledListItemHeadTitle","LIST_ITEM_HEAD_TITLE_HTML_TAG","layout","StyledListItemHeadTitleContent","StyledListItemHeadTitleText","$isEllipsis","ref","$shouldShowMultilineTitle","StyledListItemHeadTitleElement","StyledListItemHeadSubtitle","StyledListItemHeadSubtitleText","StyledMotionListItemHeadHoverItemWrapper","marginLeft","width","StyledMotionListItemHeadHoverItem","displayName","_default","exports"],"sources":["../../../../../../src/components/list/list-item/list-item-head/ListItemHead.tsx"],"sourcesContent":["import { LayoutGroup, motion } from 'motion/react';\nimport 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 type { IListItemRightElements } from '../../../../types/list';\nimport { getElementClickEvent } from '../../../../utils/accordion';\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 StyledListItemHeadContent,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadSubtitleText,\n StyledListItemHeadTitleContent,\n StyledListItemHeadTitleElement,\n StyledListItemHeadTitleText,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadHoverItemWrapper,\n StyledListItemHead,\n StyledListItemHeadIndicator,\n StyledListItemHeadTitle,\n} from './ListItemHead.styles';\nimport {\n LIST_ITEM_HEAD_HTML_TAG,\n LIST_ITEM_HEAD_INDICATOR_HTML_TAG,\n LIST_ITEM_HEAD_TITLE_HTML_TAG,\n} from '../../../../constants/list';\n\ntype ListItemHeadProps = {\n careOfLocationId?: number;\n cornerImage?: string;\n hoverItem?: ReactNode;\n icons?: string[];\n imageBackground?: CSSProperties['background'];\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 shouldForceHover?: boolean;\n setShouldEnableTooltip: (value: boolean) => void;\n shouldDisableAnimation?: boolean;\n cornerElement?: ReactNode;\n};\n\nconst ListItemHead: FC<ListItemHeadProps> = ({\n careOfLocationId,\n cornerImage,\n hoverItem,\n icons,\n imageBackground,\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 shouldForceHover,\n title,\n titleElement,\n setShouldEnableTooltip,\n shouldDisableAnimation = false,\n cornerElement,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n\n const titleWrapperRef = useRef<HTMLDivElement>(null);\n\n const longPressTimeoutRef = useRef<number>();\n\n const shouldShowSubtitleRow = subtitle || typeof subtitle === 'string';\n\n const shouldShowMultilineTitle = useMemo(() => !subtitle, [subtitle]);\n\n const handleShowTooltipResize = useCallback(\n (entries: ResizeObserverEntry[]) => {\n const el = entries[0]?.target;\n if (!el) return;\n setShouldEnableTooltip(el.scrollWidth > el.clientWidth);\n },\n [setShouldEnableTooltip],\n );\n\n useEffect(() => {\n const element = titleWrapperRef?.current;\n if (!element) return undefined;\n\n const resizeObserver = new ResizeObserver(handleShowTooltipResize);\n resizeObserver.observe(element);\n\n return () => resizeObserver.disconnect();\n }, [handleShowTooltipResize]);\n\n const handleMouseEnter = useCallback(() => setShouldShowHoverItem(true), []);\n\n const handleMouseLeave = useCallback(() => setShouldShowHoverItem(false), []);\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 shouldPreventRightElementClick = useMemo(() => {\n if (!rightElements) return false;\n\n if (\n typeof rightElements === 'object' &&\n ('bottom' in rightElements || 'center' in rightElements || 'top' in rightElements)\n ) {\n if (rightElements.bottom && getElementClickEvent(rightElements.bottom)) {\n return true;\n }\n\n if (rightElements.center && getElementClickEvent(rightElements.center)) {\n return true;\n }\n\n if (rightElements.top && getElementClickEvent(rightElements.top)) {\n return true;\n }\n } else {\n return getElementClickEvent(rightElements as ReactNode);\n }\n\n return false;\n }, [rightElements]);\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 cornerElement={cornerElement}\n imageBackground={imageBackground}\n careOfLocationId={careOfLocationId}\n cornerImage={cornerImage}\n images={images}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundImage={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n return undefined;\n }, [\n careOfLocationId,\n cornerElement,\n cornerImage,\n icons,\n imageBackground,\n images,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n return (\n <StyledListItemHead\n as={shouldDisableAnimation ? undefined : motion[LIST_ITEM_HEAD_HTML_TAG]}\n animate={\n shouldDisableAnimation\n ? undefined\n : {\n opacity: isTitleGreyed ? 0.5 : 1,\n }\n }\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { 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 <StyledListItemHeadIndicator\n as={\n shouldDisableAnimation\n ? undefined\n : motion[LIST_ITEM_HEAD_INDICATOR_HTML_TAG]\n }\n animate={shouldDisableAnimation ? undefined : { rotate: isOpen ? 90 : 0 }}\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && (\n <Icon icons={['fa fa-chevron-right']} />\n )}\n </StyledListItemHeadIndicator>\n )}\n {leftElements}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $isOpen={isOpen}\n >\n <LayoutGroup>\n <StyledListItemHeadTitle\n as={\n shouldDisableAnimation\n ? undefined\n : motion[LIST_ITEM_HEAD_TITLE_HTML_TAG]\n }\n layout=\"position\"\n >\n <StyledListItemHeadTitleContent>\n <StyledListItemHeadTitleText\n $isEllipsis={!isOpen}\n ref={titleWrapperRef}\n $shouldShowMultilineTitle={shouldShowMultilineTitle}\n >\n {title}\n </StyledListItemHeadTitleText>\n <StyledListItemHeadTitleElement>\n {titleElement}\n </StyledListItemHeadTitleElement>\n </StyledListItemHeadTitleContent>\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <StyledListItemHeadSubtitleText $isOpen={isOpen}>\n {subtitle}\n </StyledListItemHeadSubtitleText>\n </StyledListItemHeadSubtitle>\n )}\n </LayoutGroup>\n </StyledListItemHeadContent>\n {rightElements && (\n <ListItemRightElements\n rightElements={rightElements}\n shouldPreventRightElementClick={shouldPreventRightElementClick}\n />\n )}\n {hoverItem && (\n <StyledMotionListItemHeadHoverItemWrapper\n className=\"beta-chayns-list-item-hover-item\"\n animate={{\n marginLeft: shouldForceHover || shouldShowHoverItem ? 8 : 0,\n opacity: shouldForceHover || shouldShowHoverItem ? 1 : 0,\n width: shouldForceHover || shouldShowHoverItem ? 'auto' : 0,\n }}\n initial={false}\n transition={{ duration: 0.15, type: 'tween' }}\n >\n <StyledMotionListItemHeadHoverItem>\n {hoverItem}\n </StyledMotionListItemHeadHoverItem>\n </StyledMotionListItemHeadHoverItemWrapper>\n )}\n </StyledListItemHead>\n );\n};\n\nListItemHead.displayName = 'ListItemHead';\n\nexport default ListItemHead;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAaA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,cAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,sBAAA,GAAAH,sBAAA,CAAAL,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AAcA,IA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OAAA,CAAAY,OAAA,CAAAkF,aAAA,CAACtF,aAAA,CAAA8H,wCAAwC;IACrC1B,SAAS,EAAC,kCAAkC;IAC5CN,OAAO,EAAE;MACLiC,UAAU,EAAEtF,gBAAgB,IAAIM,mBAAmB,GAAG,CAAC,GAAG,CAAC;MAC3DgD,OAAO,EAAEtD,gBAAgB,IAAIM,mBAAmB,GAAG,CAAC,GAAG,CAAC;MACxDiF,KAAK,EAAEvF,gBAAgB,IAAIM,mBAAmB,GAAG,MAAM,GAAG;IAC9D,CAAE;IACFiD,OAAO,EAAE,KAAM;IACfC,UAAU,EAAE;MAAEC,QAAQ,EAAE,IAAI;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9C3G,OAAA,CAAAY,OAAA,CAAAkF,aAAA,CAACtF,aAAA,CAAAiI,iCAAiC,QAC7BzG,SAC8B,CACG,CAE9B,CAAC;AAE7B,CAAC;AAEDH,YAAY,CAAC6G,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhI,OAAA,GAE3BiB,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItemHead.js","names":["_react","require","_react2","_interopRequireWildcard","_accordion","_Icon","_interopRequireDefault","_ListItemIcon","_ListItemImage","_ListItemRightElements","_ListItemHead","_list","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ListItemHead","careOfLocationId","cornerImage","hoverItem","icons","imageBackground","images","isAnyItemExpandable","isExpandable","isOpen","isTitleGreyed","leftElements","onClick","onLongPress","rightElements","shouldHideImageOrIconBackground","shouldHideIndicator","shouldOpenImageOnClick","shouldShowRoundImageOrIcon","subtitle","shouldForceHover","title","titleElement","setShouldEnableTooltip","shouldDisableAnimation","cornerElement","onImageError","shouldShowHoverItem","setShouldShowHoverItem","useState","titleWrapperRef","useRef","longPressTimeoutRef","shouldShowSubtitleRow","shouldShowMultilineTitle","useMemo","handleShowTooltipResize","useCallback","entries","_entries$","el","target","scrollWidth","clientWidth","useEffect","element","current","undefined","resizeObserver","ResizeObserver","observe","disconnect","handleMouseEnter","handleMouseLeave","handleTouchStart","event","window","setTimeout","handleTouchEnd","clearTimeout","shouldPreventRightElementClick","bottom","getElementClickEvent","center","top","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","StyledListItemHead","as","motion","LIST_ITEM_HEAD_HTML_TAG","animate","opacity","initial","transition","duration","type","className","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","StyledListItemHeadLeftWrapper","StyledListItemHeadIndicator","LIST_ITEM_HEAD_INDICATOR_HTML_TAG","rotate","StyledListItemHeadContent","$isIconOrImageGiven","$isOpen","LayoutGroup","StyledListItemHeadTitle","LIST_ITEM_HEAD_TITLE_HTML_TAG","layout","StyledListItemHeadTitleContent","StyledListItemHeadTitleText","$isEllipsis","ref","$shouldShowMultilineTitle","StyledListItemHeadTitleElement","StyledListItemHeadSubtitle","StyledListItemHeadSubtitleText","StyledMotionListItemHeadHoverItemWrapper","marginLeft","width","StyledMotionListItemHeadHoverItem","displayName","_default","exports"],"sources":["../../../../../../src/components/list/list-item/list-item-head/ListItemHead.tsx"],"sourcesContent":["import { LayoutGroup, motion } from 'motion/react';\nimport React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { IListItemRightElements } from '../../../../types/list';\nimport { getElementClickEvent } from '../../../../utils/accordion';\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 StyledListItemHeadContent,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadSubtitleText,\n StyledListItemHeadTitleContent,\n StyledListItemHeadTitleElement,\n StyledListItemHeadTitleText,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadHoverItemWrapper,\n StyledListItemHead,\n StyledListItemHeadIndicator,\n StyledListItemHeadTitle,\n} from './ListItemHead.styles';\nimport {\n LIST_ITEM_HEAD_HTML_TAG,\n LIST_ITEM_HEAD_INDICATOR_HTML_TAG,\n LIST_ITEM_HEAD_TITLE_HTML_TAG,\n} from '../../../../constants/list';\n\ntype ListItemHeadProps = {\n careOfLocationId?: number;\n cornerImage?: string;\n hoverItem?: ReactNode;\n icons?: string[];\n imageBackground?: CSSProperties['background'];\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 shouldForceHover?: boolean;\n setShouldEnableTooltip: (value: boolean) => void;\n shouldDisableAnimation?: boolean;\n cornerElement?: ReactNode;\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n};\n\nconst ListItemHead: FC<ListItemHeadProps> = ({\n careOfLocationId,\n cornerImage,\n hoverItem,\n icons,\n imageBackground,\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 shouldForceHover,\n title,\n titleElement,\n setShouldEnableTooltip,\n shouldDisableAnimation = false,\n cornerElement,\n onImageError,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n\n const titleWrapperRef = useRef<HTMLDivElement>(null);\n\n const longPressTimeoutRef = useRef<number>();\n\n const shouldShowSubtitleRow = subtitle || typeof subtitle === 'string';\n\n const shouldShowMultilineTitle = useMemo(() => !subtitle, [subtitle]);\n\n const handleShowTooltipResize = useCallback(\n (entries: ResizeObserverEntry[]) => {\n const el = entries[0]?.target;\n if (!el) return;\n setShouldEnableTooltip(el.scrollWidth > el.clientWidth);\n },\n [setShouldEnableTooltip],\n );\n\n useEffect(() => {\n const element = titleWrapperRef?.current;\n if (!element) return undefined;\n\n const resizeObserver = new ResizeObserver(handleShowTooltipResize);\n resizeObserver.observe(element);\n\n return () => resizeObserver.disconnect();\n }, [handleShowTooltipResize]);\n\n const handleMouseEnter = useCallback(() => setShouldShowHoverItem(true), []);\n\n const handleMouseLeave = useCallback(() => setShouldShowHoverItem(false), []);\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 shouldPreventRightElementClick = useMemo(() => {\n if (!rightElements) return false;\n\n if (\n typeof rightElements === 'object' &&\n ('bottom' in rightElements || 'center' in rightElements || 'top' in rightElements)\n ) {\n if (rightElements.bottom && getElementClickEvent(rightElements.bottom)) {\n return true;\n }\n\n if (rightElements.center && getElementClickEvent(rightElements.center)) {\n return true;\n }\n\n if (rightElements.top && getElementClickEvent(rightElements.top)) {\n return true;\n }\n } else {\n return getElementClickEvent(rightElements as ReactNode);\n }\n\n return false;\n }, [rightElements]);\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 cornerElement={cornerElement}\n imageBackground={imageBackground}\n careOfLocationId={careOfLocationId}\n cornerImage={cornerImage}\n images={images}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundImage={!!shouldShowRoundImageOrIcon}\n onImageError={onImageError}\n />\n );\n }\n\n return undefined;\n }, [\n careOfLocationId,\n cornerElement,\n cornerImage,\n icons,\n imageBackground,\n images,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n return (\n <StyledListItemHead\n as={shouldDisableAnimation ? undefined : motion[LIST_ITEM_HEAD_HTML_TAG]}\n animate={\n shouldDisableAnimation\n ? undefined\n : {\n opacity: isTitleGreyed ? 0.5 : 1,\n }\n }\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { 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 <StyledListItemHeadIndicator\n as={\n shouldDisableAnimation\n ? undefined\n : motion[LIST_ITEM_HEAD_INDICATOR_HTML_TAG]\n }\n animate={shouldDisableAnimation ? undefined : { rotate: isOpen ? 90 : 0 }}\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && (\n <Icon icons={['fa fa-chevron-right']} />\n )}\n </StyledListItemHeadIndicator>\n )}\n {leftElements}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $isOpen={isOpen}\n >\n <LayoutGroup>\n <StyledListItemHeadTitle\n as={\n shouldDisableAnimation\n ? undefined\n : motion[LIST_ITEM_HEAD_TITLE_HTML_TAG]\n }\n layout=\"position\"\n >\n <StyledListItemHeadTitleContent>\n <StyledListItemHeadTitleText\n $isEllipsis={!isOpen}\n ref={titleWrapperRef}\n $shouldShowMultilineTitle={shouldShowMultilineTitle}\n >\n {title}\n </StyledListItemHeadTitleText>\n <StyledListItemHeadTitleElement>\n {titleElement}\n </StyledListItemHeadTitleElement>\n </StyledListItemHeadTitleContent>\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <StyledListItemHeadSubtitleText $isOpen={isOpen}>\n {subtitle}\n </StyledListItemHeadSubtitleText>\n </StyledListItemHeadSubtitle>\n )}\n </LayoutGroup>\n </StyledListItemHeadContent>\n {rightElements && (\n <ListItemRightElements\n rightElements={rightElements}\n shouldPreventRightElementClick={shouldPreventRightElementClick}\n />\n )}\n {hoverItem && (\n <StyledMotionListItemHeadHoverItemWrapper\n className=\"beta-chayns-list-item-hover-item\"\n animate={{\n marginLeft: shouldForceHover || shouldShowHoverItem ? 8 : 0,\n opacity: shouldForceHover || shouldShowHoverItem ? 1 : 0,\n width: shouldForceHover || shouldShowHoverItem ? 'auto' : 0,\n }}\n initial={false}\n transition={{ duration: 0.15, type: 'tween' }}\n >\n <StyledMotionListItemHeadHoverItem>\n {hoverItem}\n </StyledMotionListItemHeadHoverItem>\n </StyledMotionListItemHeadHoverItemWrapper>\n )}\n </StyledListItemHead>\n );\n};\n\nListItemHead.displayName = 'ListItemHead';\n\nexport default ListItemHead;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAcA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAD,sBAAA,C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AAC,EAC3BL,aAAa,iBACV3C,OAAA,CAAAY,OAAA,CAAAmF,aAAA,CAACxF,sBAAA,CAAAK,OAAqB;IAClB+B,aAAa,EAAEA,aAAc;IAC7B8C,8BAA8B,EAAEA;EAA+B,CAClE,CACJ,EACAzD,SAAS,iBACNhC,OAAA,CAAAY,OAAA,CAAAmF,aAAA,CAACvF,aAAA,CAAA+H,wCAAwC;IACrC1B,SAAS,EAAC,kCAAkC;IAC5CN,OAAO,EAAE;MACLiC,UAAU,EAAEvF,gBAAgB,IAAIO,mBAAmB,GAAG,CAAC,GAAG,CAAC;MAC3DgD,OAAO,EAAEvD,gBAAgB,IAAIO,mBAAmB,GAAG,CAAC,GAAG,CAAC;MACxDiF,KAAK,EAAExF,gBAAgB,IAAIO,mBAAmB,GAAG,MAAM,GAAG;IAC9D,CAAE;IACFiD,OAAO,EAAE,KAAM;IACfC,UAAU,EAAE;MAAEC,QAAQ,EAAE,IAAI;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9C5G,OAAA,CAAAY,OAAA,CAAAmF,aAAA,CAACvF,aAAA,CAAAkI,iCAAiC,QAC7B1G,SAC8B,CACG,CAE9B,CAAC;AAE7B,CAAC;AAEDH,YAAY,CAAC8G,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjI,OAAA,GAE3BiB,YAAY","ignoreList":[]}
|
|
@@ -17,7 +17,8 @@ const ListItemImage = ({
|
|
|
17
17
|
shouldHideBackground,
|
|
18
18
|
shouldShowRoundImage,
|
|
19
19
|
shouldOpenImageOnClick,
|
|
20
|
-
cornerElement
|
|
20
|
+
cornerElement,
|
|
21
|
+
onImageError
|
|
21
22
|
}) => {
|
|
22
23
|
const handleImageClick = (0, _react.useCallback)(event => {
|
|
23
24
|
if (!shouldOpenImageOnClick) {
|
|
@@ -46,7 +47,8 @@ const ListItemImage = ({
|
|
|
46
47
|
images: images,
|
|
47
48
|
onClick: handleImageClick,
|
|
48
49
|
shouldPreventBackground: shouldHideBackground,
|
|
49
|
-
shouldShowRoundImage: shouldShowRoundImage
|
|
50
|
+
shouldShowRoundImage: shouldShowRoundImage,
|
|
51
|
+
onImageError: onImageError
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
return null;
|
package/lib/cjs/components/list/list-item/list-item-head/list-item-image/ListItemImage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemImage.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_GroupedImage","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ListItemImage","careOfLocationId","cornerImage","imageBackground","images","shouldHideBackground","shouldShowRoundImage","shouldOpenImageOnClick","cornerElement","handleImageClick","useCallback","event","preventDefault","stopPropagation","items","map","image","url","mediaType","MediaType","IMAGE","openMedia","startIndex","careOfImage","undefined","createElement","onClick","shouldPreventBackground","displayName","_default","exports"],"sources":["../../../../../../../src/components/list/list-item/list-item-head/list-item-image/ListItemImage.tsx"],"sourcesContent":["import { MediaType, openMedia, OpenMediaItem } from 'chayns-api';\nimport React, {
|
|
1
|
+
{"version":3,"file":"ListItemImage.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_GroupedImage","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ListItemImage","careOfLocationId","cornerImage","imageBackground","images","shouldHideBackground","shouldShowRoundImage","shouldOpenImageOnClick","cornerElement","onImageError","handleImageClick","useCallback","event","preventDefault","stopPropagation","items","map","image","url","mediaType","MediaType","IMAGE","openMedia","startIndex","careOfImage","undefined","createElement","onClick","shouldPreventBackground","displayName","_default","exports"],"sources":["../../../../../../../src/components/list/list-item/list-item-head/list-item-image/ListItemImage.tsx"],"sourcesContent":["import { MediaType, openMedia, OpenMediaItem } from 'chayns-api';\nimport React, {\n CSSProperties,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n useCallback,\n} from 'react';\nimport GroupedImage from '../../../../grouped-image/GroupedImage';\n\ntype ListItemImageProps = {\n careOfLocationId?: number;\n cornerImage?: string;\n imageBackground?: CSSProperties['background'];\n images: string[];\n shouldHideBackground: boolean;\n shouldShowRoundImage: boolean;\n shouldOpenImageOnClick: boolean;\n cornerElement?: ReactNode;\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n};\n\nconst ListItemImage: React.FC<ListItemImageProps> = ({\n careOfLocationId,\n cornerImage,\n imageBackground,\n images,\n shouldHideBackground,\n shouldShowRoundImage,\n shouldOpenImageOnClick,\n cornerElement,\n onImageError,\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]) {\n const careOfImage = careOfLocationId\n ? `https://sub60.tobit.com/l/${careOfLocationId}?size=128`\n : undefined;\n\n return (\n <GroupedImage\n cornerElement={cornerElement}\n cornerImage={cornerImage ?? careOfImage}\n imageBackground={imageBackground}\n images={images}\n onClick={handleImageClick}\n shouldPreventBackground={shouldHideBackground}\n shouldShowRoundImage={shouldShowRoundImage}\n onImageError={onImageError}\n />\n );\n }\n\n return null;\n};\n\nListItemImage.displayName = 'ListItemImage';\n\nexport default ListItemImage;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAOA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAkE,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,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useWindowMetrics)();
|
|
32
33
|
usableHeight = windowHeight;
|
|
@@ -36,6 +37,9 @@ const useUsableHeight = () => {
|
|
|
36
37
|
if (offsetTop) {
|
|
37
38
|
usableHeight -= offsetTop;
|
|
38
39
|
}
|
|
40
|
+
if (topBarHeight) {
|
|
41
|
+
usableHeight -= topBarHeight;
|
|
42
|
+
}
|
|
39
43
|
return usableHeight;
|
|
40
44
|
};
|
|
41
45
|
exports.useUsableHeight = useUsableHeight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageProvider.js","names":["_chaynsApi","require","getUsableHeight","usableHeight","bottomBarHeight","offsetTop","windowHeight","getWindowMetrics","exports","useUsableHeight","useWindowMetrics"],"sources":["../../../src/utils/pageProvider.ts"],"sourcesContent":["import { getWindowMetrics, useWindowMetrics } from 'chayns-api';\n\nexport const getUsableHeight = async () => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = await getWindowMetrics();\n\n usableHeight = windowHeight;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n\nexport const useUsableHeight = () => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = useWindowMetrics();\n usableHeight = windowHeight;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAAY;EACvC,IAAIC,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAG,MAAM,IAAAC,2BAAgB,EAAC,CAAC;EAE7EJ,YAAY,GAAGG,YAAY;EAE3B,IAAIF,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC;AAACK,OAAA,CAAAN,eAAA,GAAAA,eAAA;AAEK,MAAMO,eAAe,GAAGA,CAAA,KAAM;EACjC,IAAIN,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;
|
|
1
|
+
{"version":3,"file":"pageProvider.js","names":["_chaynsApi","require","getUsableHeight","usableHeight","bottomBarHeight","offsetTop","windowHeight","getWindowMetrics","exports","useUsableHeight","topBarHeight","useWindowMetrics"],"sources":["../../../src/utils/pageProvider.ts"],"sourcesContent":["import { getWindowMetrics, useWindowMetrics } from 'chayns-api';\n\nexport const getUsableHeight = async () => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = await getWindowMetrics();\n\n usableHeight = windowHeight;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n\nexport const useUsableHeight = () => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, topBarHeight, windowHeight } = useWindowMetrics();\n\n usableHeight = windowHeight;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n if (topBarHeight) {\n usableHeight -= topBarHeight;\n }\n\n return usableHeight;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAAY;EACvC,IAAIC,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAG,MAAM,IAAAC,2BAAgB,EAAC,CAAC;EAE7EJ,YAAY,GAAGG,YAAY;EAE3B,IAAIF,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC;AAACK,OAAA,CAAAN,eAAA,GAAAA,eAAA;AAEK,MAAMO,eAAe,GAAGA,CAAA,KAAM;EACjC,IAAIN,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEK,YAAY;IAAEJ;EAAa,CAAC,GAAG,IAAAK,2BAAgB,EAAC,CAAC;EAErFR,YAAY,GAAGG,YAAY;EAE3B,IAAIF,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,IAAIK,YAAY,EAAE;IACdP,YAAY,IAAIO,YAAY;EAChC;EAEA,OAAOP,YAAY;AACvB,CAAC;AAACK,OAAA,CAAAC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -8,7 +8,8 @@ const GroupedImage = ({
|
|
|
8
8
|
onClick,
|
|
9
9
|
shouldPreventBackground = false,
|
|
10
10
|
shouldShowRoundImage = false,
|
|
11
|
-
cornerElement
|
|
11
|
+
cornerElement,
|
|
12
|
+
onImageError
|
|
12
13
|
}) => {
|
|
13
14
|
const hasCornerImage = Boolean(cornerImage);
|
|
14
15
|
const hasCornerElement = Boolean(cornerElement);
|
|
@@ -29,7 +30,8 @@ const GroupedImage = ({
|
|
|
29
30
|
// eslint-disable-next-line react/no-array-index-key
|
|
30
31
|
,
|
|
31
32
|
key: index,
|
|
32
|
-
src: src
|
|
33
|
+
src: src,
|
|
34
|
+
onError: event => typeof onImageError === 'function' && onImageError(event, index)
|
|
33
35
|
}));
|
|
34
36
|
return /*#__PURE__*/React.createElement(StyledGroupedImage, {
|
|
35
37
|
onClick: onClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupedImage.js","names":["React","useMemo","ImageSize","StyledCornerElement","StyledCornerImage","StyledGroupedImage","StyledGroupImageElement","GroupedImage","cornerImage","height","imageBackground","images","onClick","shouldPreventBackground","shouldShowRoundImage","cornerElement","hasCornerImage","Boolean","hasCornerElement","hasMultipleImages","length","imageSize","GroupedSmall","Small","Grouped","Full","imageElements","slice","map","src","index","createElement","$background","$imageSize","$isSecondImage","$shouldPreventBackground","$shouldShowRoundImage","key","$height","displayName"],"sources":["../../../../src/components/grouped-image/GroupedImage.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"GroupedImage.js","names":["React","useMemo","ImageSize","StyledCornerElement","StyledCornerImage","StyledGroupedImage","StyledGroupImageElement","GroupedImage","cornerImage","height","imageBackground","images","onClick","shouldPreventBackground","shouldShowRoundImage","cornerElement","onImageError","hasCornerImage","Boolean","hasCornerElement","hasMultipleImages","length","imageSize","GroupedSmall","Small","Grouped","Full","imageElements","slice","map","src","index","createElement","$background","$imageSize","$isSecondImage","$shouldPreventBackground","$shouldShowRoundImage","key","onError","event","$height","displayName"],"sources":["../../../../src/components/grouped-image/GroupedImage.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n useMemo,\n} from 'react';\nimport {\n ImageSize,\n StyledCornerElement,\n StyledCornerImage,\n StyledGroupedImage,\n StyledGroupImageElement,\n} from './GroupedImage.styles';\n\ntype GroupedImageProps = {\n /**\n * Optional image to display in the bottom right corner of the grouped image.\n */\n cornerImage?: string;\n /**\n * Height of the grouped image container.\n */\n height?: CSSProperties['height'];\n /**\n * Background for the single images.\n */\n imageBackground?: CSSProperties['background'];\n /**\n * Array of image URLs to display in the grouped image. If only one image is provided, it will be displayed as a full image.\n */\n images: string[];\n /**\n * Optional click handler for the grouped image.\n */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /**\n * Whether to prevent the background of the images from being set.\n */\n shouldPreventBackground?: boolean;\n /**\n * Whether to show the images in a round shape.\n */\n shouldShowRoundImage?: boolean;\n /**\n * Optional Element to display in the right corner of the image\n */\n cornerElement?: ReactNode;\n /**\n * Optional handler for image load errors.\n */\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n};\n\nconst GroupedImage: FC<GroupedImageProps> = ({\n cornerImage,\n height = '40px',\n imageBackground,\n images,\n onClick,\n shouldPreventBackground = false,\n shouldShowRoundImage = false,\n cornerElement,\n onImageError,\n}) => {\n const hasCornerImage = Boolean(cornerImage);\n const hasCornerElement = Boolean(cornerElement);\n const hasMultipleImages = images.length > 1;\n\n const imageSize = useMemo(() => {\n if (hasCornerImage) {\n return hasMultipleImages ? ImageSize.GroupedSmall : ImageSize.Small;\n }\n\n return hasMultipleImages ? ImageSize.Grouped : ImageSize.Full;\n }, [hasCornerImage, hasMultipleImages]);\n\n const imageElements = images\n .slice(0, 2) // Limit to 2 images for grouping\n .map((src, index) => (\n <StyledGroupImageElement\n $background={imageBackground}\n $imageSize={imageSize}\n $isSecondImage={index === 1}\n $shouldPreventBackground={shouldPreventBackground}\n $shouldShowRoundImage={shouldShowRoundImage}\n // eslint-disable-next-line react/no-array-index-key\n key={index}\n src={src}\n onError={(event) =>\n typeof onImageError === 'function' && onImageError(event, index)\n }\n />\n ));\n\n return (\n <StyledGroupedImage onClick={onClick} $height={height}>\n {imageElements}\n {hasCornerImage && (\n <StyledCornerImage\n $background={imageBackground}\n $shouldPreventBackground={shouldPreventBackground}\n src={cornerImage}\n key=\"corner-image\"\n />\n )}\n {hasCornerElement && <StyledCornerElement>{cornerElement}</StyledCornerElement>}\n </StyledGroupedImage>\n );\n};\n\nGroupedImage.displayName = 'GroupedImage';\n\nexport default GroupedImage;\n"],"mappings":"AAAA,OAAOA,KAAK,IAMRC,OAAO,QACJ,OAAO;AACd,SACIC,SAAS,EACTC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,QACpB,uBAAuB;AAyC9B,MAAMC,YAAmC,GAAGA,CAAC;EACzCC,WAAW;EACXC,MAAM,GAAG,MAAM;EACfC,eAAe;EACfC,MAAM;EACNC,OAAO;EACPC,uBAAuB,GAAG,KAAK;EAC/BC,oBAAoB,GAAG,KAAK;EAC5BC,aAAa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EAAEvB,uBAAwB;IAClDiB,GAAG,EAAEtB,WAAY;IACjB8B,GAAG,EAAC;EAAc,CACrB,CACJ,EACAnB,gBAAgB,iBAAInB,KAAA,CAAAgC,aAAA,CAAC7B,mBAAmB,QAAEY,aAAmC,CAC9D,CAAC;AAE7B,CAAC;AAEDR,YAAY,CAACmC,WAAW,GAAG,cAAc;AAEzC,eAAenC,YAAY","ignoreList":[]}
|
|
@@ -43,7 +43,8 @@ const ListItem = ({
|
|
|
43
43
|
title,
|
|
44
44
|
titleElement,
|
|
45
45
|
shouldDisableAnimation = false,
|
|
46
|
-
cornerElement
|
|
46
|
+
cornerElement,
|
|
47
|
+
onImageError
|
|
47
48
|
}) => {
|
|
48
49
|
const {
|
|
49
50
|
incrementExpandableItemCount,
|
|
@@ -128,8 +129,9 @@ const ListItem = ({
|
|
|
128
129
|
title: title,
|
|
129
130
|
titleElement: titleElement,
|
|
130
131
|
setShouldEnableTooltip: setShouldEnableTooltip,
|
|
131
|
-
shouldDisableAnimation: shouldDisableAnimation
|
|
132
|
-
|
|
132
|
+
shouldDisableAnimation: shouldDisableAnimation,
|
|
133
|
+
onImageError: onImageError
|
|
134
|
+
}), [hoverItem, careOfLocationId, cornerElement, cornerImage, icons, imageBackground, images, isAnyItemExpandable, isExpandable, isItemOpen, isTitleGreyed, leftElements, isClickable, handleHeadClick, onLongPress, shouldForceHover, rightElements, shouldHideImageOrIconBackground, shouldHideIndicator, shouldOpenImageOnClick, shouldShowRoundImageOrIcon, subtitle, title, titleElement, shouldDisableAnimation, onImageError]);
|
|
133
135
|
return /*#__PURE__*/React.createElement(StyledListItem, {
|
|
134
136
|
as: shouldDisableAnimation ? undefined : motion[LIST_ITEM_HTML_TAG],
|
|
135
137
|
animate: shouldDisableAnimation ? undefined : {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["AnimatePresence","motion","React","useCallback","useContext","useEffect","useMemo","useRef","useState","useUuid","AccordionContext","AreaContextProvider","AreaContext","ListContext","ListItemBody","ListItemHead","StyledListItem","StyledListItemTooltip","Tooltip","LIST_ITEM_HTML_TAG","ListItem","backgroundColor","careOfLocationId","children","cornerImage","hoverItem","icons","imageBackground","images","isDefaultOpen","isOpen","isTitleGreyed","leftElements","onClick","onClose","onLongPress","onOpen","rightElements","shouldShowTooltipOnTitleOverflow","shouldForceBackground","shouldForceBottomLine","shouldForceHover","shouldHideBottomLine","shouldOpenImageOnClick","shouldHideImageOrIconBackground","shouldHideIndicator","shouldPreventLayoutAnimation","shouldRenderClosed","shouldShowRoundImageOrIcon","shouldShowSeparatorBelow","subtitle","title","titleElement","shouldDisableAnimation","cornerElement","incrementExpandableItemCount","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","isParentAccordionWrapped","areaProvider","isInitialRenderRef","listItemRef","uuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","current","handleHeadClick","event","shouldOnlyOpen","isClickable","headContent","createElement","as","animate","height","opacity","className","exit","initial","key","ref","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","shouldUseFullWidth","isDisabled","item","style","cursor","id","shouldHideBody","displayName"],"sources":["../../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence, motion } from 'motion/react';\nimport React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem, StyledListItemTooltip } from './ListItem.styles';\nimport Tooltip from '../../tooltip/Tooltip';\nimport { LIST_ITEM_HTML_TAG } from '../../../constants/list';\n\nexport type ListItemElements = [ReactNode, ...ReactNode[]];\n\nexport type ListItemProps = {\n /**\n * The background color of the `ListItem`.\n */\n backgroundColor?: CSSProperties['backgroundColor'];\n /**\n * DEPRECATED: Use `cornerImage` instead.\n */\n careOfLocationId?: number;\n /**\n * The content of the `ListItem` body. When the `ListItem` has children,\n * it can be opened and also gets an icon as an indicator automatically.\n */\n children?: ReactNode;\n /**\n * The image that is displayed in the bottom right corner of the grouped image of list item.\n */\n cornerImage?: string;\n /**\n * Element that is displayed when hovering over the `ListItem` on the right\n * side. On mobile devices, this element is not displayed.\n */\n hoverItem?: ReactNode;\n /**\n * The FontAwesome or tobit icons to render like an image on the left side\n * of the header. Multiple icons are stacked. See the `Icon` component\n * documentation for more information.\n */\n icons?: string[];\n /**\n * The background of the image. This is only used if images are passed.\n */\n imageBackground?: CSSProperties['background'];\n /**\n * A list of image URLs that are displayed on the left side of the header.\n * If multiple URLs are passed, the image is assembled from the first three\n * image URLs as a puzzle.\n */\n images?: string[];\n /**\n * This can be used to automatically expand the `ListItem` during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This overrides the internal opening state of the item and makes it controlled.\n */\n isOpen?: boolean;\n /**\n * Whether the ListItem locks disabled but has full functionality.\n */\n isTitleGreyed?: boolean;\n /**\n * Elements that are displayed on the left side of the header. If multiple\n * elements are specified, they are displayed one aside the other.\n */\n leftElements?: ListItemElements;\n /**\n * Function to be executed when the header of the `ListItem` was clicked\n */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the ListItem is closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the header of the `ListItem` is pressed for\n * 400 milliseconds.\n */\n onLongPress?: TouchEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the ListItem is opened.\n */\n onOpen?: VoidFunction;\n /**\n * Elements that are displayed on the right side of the header. If multiple\n * elements are specified, they are displayed one below the other.\n */\n rightElements?: IListItemRightElements;\n /**\n * This will force the background color of the ListItem to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * Whether the line should be forced, e.g., so that it is also displayed if the item is the last element in the list.\n */\n shouldForceBottomLine?: boolean;\n /**\n * Whether the hover item should be forced.\n */\n shouldForceHover?: boolean;\n /**\n * Whether the bottom line should be hidden.\n */\n shouldHideBottomLine?: boolean;\n /**\n * Whether the background and border of the shape on which the image or icon of the element is displayed should be\n * hidden.\n */\n shouldHideImageOrIconBackground?: boolean;\n /**\n * If the `ListItem` is expandable, the indicator is displayed on the left\n * side of the header. If this property is set to true, the indicator is\n * hidden.\n */\n shouldHideIndicator?: boolean;\n /**\n * Whether the image should be opened on click.\n */\n shouldOpenImageOnClick?: boolean;\n /**\n * Whether the layout animation should be prevented. This is useful when the\n * `ListItem` is used in a list with a lot of items and the layout animation\n * is not desired.\n */\n shouldPreventLayoutAnimation?: boolean;\n /**\n * This will render the ListItem closed on the first render.\n */\n shouldRenderClosed?: boolean;\n /**\n * Whether the image or icon should be displayed in a round shape. This should always be used for images of persons.\n */\n shouldShowRoundImageOrIcon?: boolean;\n /**\n * Whether a separator should be displayed below this item. In this case, the border is displayed thicker than normal.\n */\n shouldShowSeparatorBelow?: boolean;\n /**\n * Whether a Tooltip should be displayed on hover if the title is cut.\n */\n shouldShowTooltipOnTitleOverflow?: boolean;\n /**\n * Subtitle of the `ListItem` displayed in the head below the title\n */\n subtitle?: ReactNode;\n /**\n * Title of the `ListItem` displayed in the head\n */\n title: ReactNode;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n\n /**\n * Whether the ListItem Animation should be disabled.\n */\n shouldDisableAnimation?: boolean;\n /**\n * Optional Element to display in the right corner of the image\n */\n cornerElement?: ReactNode;\n};\n\nconst ListItem: FC<ListItemProps> = ({\n backgroundColor,\n careOfLocationId,\n children,\n cornerImage,\n hoverItem,\n icons,\n imageBackground,\n images,\n isDefaultOpen,\n isOpen,\n isTitleGreyed,\n leftElements,\n onClick,\n onClose,\n onLongPress,\n onOpen,\n rightElements,\n shouldShowTooltipOnTitleOverflow = false,\n shouldForceBackground = false,\n shouldForceBottomLine = false,\n shouldForceHover = false,\n shouldHideBottomLine = false,\n shouldOpenImageOnClick = false,\n shouldHideImageOrIconBackground,\n shouldHideIndicator = false,\n shouldPreventLayoutAnimation = false,\n shouldRenderClosed = false,\n shouldShowRoundImageOrIcon,\n shouldShowSeparatorBelow = false,\n subtitle,\n title,\n titleElement,\n shouldDisableAnimation = false,\n cornerElement,\n}) => {\n const {\n incrementExpandableItemCount,\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n } = useContext(ListContext);\n\n const { isWrapped: isParentAccordionWrapped } = useContext(AccordionContext);\n\n const areaProvider = useContext(AreaContext);\n\n const isInitialRenderRef = useRef(true);\n\n const listItemRef = useRef<HTMLDivElement>(null);\n\n const uuid = useUuid();\n\n const isExpandable = children !== undefined;\n const isItemOpen = isOpen ?? openItemUuid === uuid;\n\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n\n const [shouldEnableTooltip, setShouldEnableTooltip] = useState(false);\n\n useEffect(() => {\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [isOpen, onClose, onOpen]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isItemOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isItemOpen]);\n\n const handleHeadClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n if (isExpandable) {\n updateOpenItemUuid(uuid);\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n },\n [isExpandable, onClick, updateOpenItemUuid, uuid],\n );\n\n useEffect(() => {\n if (isExpandable && !shouldHideIndicator) {\n // The incrementExpandableItemCount function returns a cleanup\n // function to decrement expandableItemCount if component unmounts\n return incrementExpandableItemCount();\n }\n\n return undefined;\n }, [incrementExpandableItemCount, isExpandable, shouldHideIndicator]);\n\n useEffect(() => {\n if (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n const isClickable = typeof onClick === 'function' || isExpandable;\n\n const headContent = useMemo(\n () => (\n <ListItemHead\n hoverItem={hoverItem}\n careOfLocationId={careOfLocationId}\n cornerElement={cornerElement}\n cornerImage={cornerImage}\n icons={icons}\n imageBackground={imageBackground}\n images={images}\n isAnyItemExpandable={isAnyItemExpandable}\n isExpandable={isExpandable}\n isOpen={isItemOpen}\n isTitleGreyed={isTitleGreyed}\n leftElements={leftElements}\n onClick={isClickable ? handleHeadClick : undefined}\n onLongPress={onLongPress}\n shouldForceHover={shouldForceHover}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n titleElement={titleElement}\n setShouldEnableTooltip={setShouldEnableTooltip}\n shouldDisableAnimation={shouldDisableAnimation}\n />\n ),\n [\n careOfLocationId,\n cornerElement,\n cornerImage,\n handleHeadClick,\n hoverItem,\n icons,\n imageBackground,\n images,\n isAnyItemExpandable,\n isClickable,\n isExpandable,\n isItemOpen,\n isTitleGreyed,\n leftElements,\n onLongPress,\n rightElements,\n shouldForceHover,\n shouldHideImageOrIconBackground,\n shouldHideIndicator,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n subtitle,\n title,\n titleElement,\n shouldDisableAnimation,\n ],\n );\n\n return (\n <StyledListItem\n as={shouldDisableAnimation ? undefined : motion[LIST_ITEM_HTML_TAG]}\n animate={shouldDisableAnimation ? undefined : { height: 'auto', opacity: 1 }}\n className=\"beta-chayns-list-item\"\n exit={shouldDisableAnimation ? undefined : { height: 0, opacity: 0 }}\n initial={shouldDisableAnimation ? undefined : { height: 0, opacity: 0 }}\n key={`list-item-${uuid}`}\n ref={listItemRef}\n layout={shouldPreventLayoutAnimation || shouldDisableAnimation ? undefined : 'position'}\n $backgroundColor={backgroundColor}\n $isClickable={isClickable}\n $isInAccordion={\n typeof isParentAccordionWrapped === 'boolean' &&\n !areaProvider.shouldDisableListItemPadding\n }\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n >\n <Tooltip\n shouldUseFullWidth\n isDisabled={!shouldShowTooltipOnTitleOverflow || !shouldEnableTooltip}\n item={\n <StyledListItemTooltip\n style={{ cursor: 'default' }}\n key={`list-item-tooltip-${uuid}`}\n >\n {title}\n </StyledListItemTooltip>\n }\n >\n {headContent}\n </Tooltip>\n <AnimatePresence initial={false}>\n {isExpandable && (isItemOpen || shouldRenderClosed) && (\n <ListItemBody\n id={uuid}\n key={`listItemBody-${uuid}`}\n shouldHideBody={shouldRenderClosed && !isItemOpen}\n >\n <AreaContextProvider>{children}</AreaContextProvider>\n </ListItemBody>\n )}\n </AnimatePresence>\n </StyledListItem>\n );\n};\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,MAAM,QAAQ,cAAc;AACtD,OAAOC,KAAK,IAMRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,OAAO,QAAQ,qBAAqB;AAE7C,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D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AC7C,CAACC,YAAY,CAAC+B,4BACjB;IACDC,OAAO,EAAE1B,UAAW;IACpB2B,UAAU,EAAErC,SAAU;IACtBsC,kBAAkB,EAAElC,YAAY,CAACmC,iBAAkB;IACnDC,sBAAsB,EAAE1D,qBAAsB;IAC9C2D,sBAAsB,EAAE1D,qBAAsB;IAC9C2D,qBAAqB,EAAEzD,oBAAqB;IAC5C0D,oBAAoB,EAAEvD,mBAAoB;IAC1CwD,yBAAyB,EAAEpD;EAAyB,gBAEpD/C,KAAA,CAAA4E,aAAA,CAAC5D,OAAO;IACJoF,kBAAkB;IAClBC,UAAU,EAAE,CAACjE,gCAAgC,IAAI,CAACgC,mBAAoB;IACtEkC,IAAI,eACAtG,KAAA,CAAA4E,aAAA,CAAC7D,qBAAqB;MAClBwF,KAAK,EAAE;QAAEC,MAAM,EAAE;MAAU,CAAE;MAC7BpB,GAAG,EAAE,qBAAqBtB,IAAI;IAAG,GAEhCb,KACkB;EAC1B,GAEA0B,WACI,CAAC,eACV3E,KAAA,CAAA4E,aAAA,CAAC9E,eAAe;IAACqF,OAAO,EAAE;EAAM,GAC3BpB,YAAY,KAAKE,UAAU,IAAIpB,kBAAkB,CAAC,iBAC/C7C,KAAA,CAAA4E,aAAA,CAAChE,YAAY;IACT6F,EAAE,EAAE3C,IAAK;IACTsB,GAAG,EAAE,gBAAgBtB,IAAI,EAAG;IAC5B4C,cAAc,EAAE7D,kBAAkB,IAAI,CAACoB;EAAW,gBAElDjE,KAAA,CAAA4E,aAAA,CAACnE,mBAAmB,QAAEY,QAA8B,CAC1C,CAEL,CACL,CAAC;AAEzB,CAAC;AAEDH,QAAQ,CAACyF,WAAW,GAAG,UAAU;AAEjC,eAAezF,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItem.js","names":["AnimatePresence","motion","React","useCallback","useContext","useEffect","useMemo","useRef","useState","useUuid","AccordionContext","AreaContextProvider","AreaContext","ListContext","ListItemBody","ListItemHead","StyledListItem","StyledListItemTooltip","Tooltip","LIST_ITEM_HTML_TAG","ListItem","backgroundColor","careOfLocationId","children","cornerImage","hoverItem","icons","imageBackground","images","isDefaultOpen","isOpen","isTitleGreyed","leftElements","onClick","onClose","onLongPress","onOpen","rightElements","shouldShowTooltipOnTitleOverflow","shouldForceBackground","shouldForceBottomLine","shouldForceHover","shouldHideBottomLine","shouldOpenImageOnClick","shouldHideImageOrIconBackground","shouldHideIndicator","shouldPreventLayoutAnimation","shouldRenderClosed","shouldShowRoundImageOrIcon","shouldShowSeparatorBelow","subtitle","title","titleElement","shouldDisableAnimation","cornerElement","onImageError","incrementExpandableItemCount","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","isParentAccordionWrapped","areaProvider","isInitialRenderRef","listItemRef","uuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","current","handleHeadClick","event","shouldOnlyOpen","isClickable","headContent","createElement","as","animate","height","opacity","className","exit","initial","key","ref","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","shouldUseFullWidth","isDisabled","item","style","cursor","id","shouldHideBody","displayName"],"sources":["../../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence, motion } from 'motion/react';\nimport React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem, StyledListItemTooltip } from './ListItem.styles';\nimport Tooltip from '../../tooltip/Tooltip';\nimport { LIST_ITEM_HTML_TAG } from '../../../constants/list';\n\nexport type ListItemElements = [ReactNode, ...ReactNode[]];\n\nexport type ListItemProps = {\n /**\n * The background color of the `ListItem`.\n */\n backgroundColor?: CSSProperties['backgroundColor'];\n /**\n * DEPRECATED: Use `cornerImage` instead.\n */\n careOfLocationId?: number;\n /**\n * The content of the `ListItem` body. When the `ListItem` has children,\n * it can be opened and also gets an icon as an indicator automatically.\n */\n children?: ReactNode;\n /**\n * The image that is displayed in the bottom right corner of the grouped image of list item.\n */\n cornerImage?: string;\n /**\n * Element that is displayed when hovering over the `ListItem` on the right\n * side. On mobile devices, this element is not displayed.\n */\n hoverItem?: ReactNode;\n /**\n * The FontAwesome or tobit icons to render like an image on the left side\n * of the header. Multiple icons are stacked. See the `Icon` component\n * documentation for more information.\n */\n icons?: string[];\n /**\n * The background of the image. This is only used if images are passed.\n */\n imageBackground?: CSSProperties['background'];\n /**\n * A list of image URLs that are displayed on the left side of the header.\n * If multiple URLs are passed, the image is assembled from the first three\n * image URLs as a puzzle.\n */\n images?: string[];\n /**\n * This can be used to automatically expand the `ListItem` during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This overrides the internal opening state of the item and makes it controlled.\n */\n isOpen?: boolean;\n /**\n * Whether the ListItem locks disabled but has full functionality.\n */\n isTitleGreyed?: boolean;\n /**\n * Elements that are displayed on the left side of the header. If multiple\n * elements are specified, they are displayed one aside the other.\n */\n leftElements?: ListItemElements;\n /**\n * Function to be executed when the header of the `ListItem` was clicked\n */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the ListItem is closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the header of the `ListItem` is pressed for\n * 400 milliseconds.\n */\n onLongPress?: TouchEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the ListItem is opened.\n */\n onOpen?: VoidFunction;\n /**\n * Elements that are displayed on the right side of the header. If multiple\n * elements are specified, they are displayed one below the other.\n */\n rightElements?: IListItemRightElements;\n /**\n * This will force the background color of the ListItem to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * Whether the line should be forced, e.g., so that it is also displayed if the item is the last element in the list.\n */\n shouldForceBottomLine?: boolean;\n /**\n * Whether the hover item should be forced.\n */\n shouldForceHover?: boolean;\n /**\n * Whether the bottom line should be hidden.\n */\n shouldHideBottomLine?: boolean;\n /**\n * Whether the background and border of the shape on which the image or icon of the element is displayed should be\n * hidden.\n */\n shouldHideImageOrIconBackground?: boolean;\n /**\n * If the `ListItem` is expandable, the indicator is displayed on the left\n * side of the header. If this property is set to true, the indicator is\n * hidden.\n */\n shouldHideIndicator?: boolean;\n /**\n * Whether the image should be opened on click.\n */\n shouldOpenImageOnClick?: boolean;\n /**\n * Whether the layout animation should be prevented. This is useful when the\n * `ListItem` is used in a list with a lot of items and the layout animation\n * is not desired.\n */\n shouldPreventLayoutAnimation?: boolean;\n /**\n * This will render the ListItem closed on the first render.\n */\n shouldRenderClosed?: boolean;\n /**\n * Whether the image or icon should be displayed in a round shape. This should always be used for images of persons.\n */\n shouldShowRoundImageOrIcon?: boolean;\n /**\n * Whether a separator should be displayed below this item. In this case, the border is displayed thicker than normal.\n */\n shouldShowSeparatorBelow?: boolean;\n /**\n * Whether a Tooltip should be displayed on hover if the title is cut.\n */\n shouldShowTooltipOnTitleOverflow?: boolean;\n /**\n * Subtitle of the `ListItem` displayed in the head below the title\n */\n subtitle?: ReactNode;\n /**\n * Title of the `ListItem` displayed in the head\n */\n title: ReactNode;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n\n /**\n * Whether the ListItem Animation should be disabled.\n */\n shouldDisableAnimation?: boolean;\n /**\n * Optional Element to display in the right corner of the image\n */\n cornerElement?: ReactNode;\n /**\n * Optional handler for image load errors.\n */\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n};\n\nconst ListItem: FC<ListItemProps> = ({\n backgroundColor,\n careOfLocationId,\n children,\n cornerImage,\n hoverItem,\n icons,\n imageBackground,\n images,\n isDefaultOpen,\n isOpen,\n isTitleGreyed,\n leftElements,\n onClick,\n onClose,\n onLongPress,\n onOpen,\n rightElements,\n shouldShowTooltipOnTitleOverflow = false,\n shouldForceBackground = false,\n shouldForceBottomLine = false,\n shouldForceHover = false,\n shouldHideBottomLine = false,\n shouldOpenImageOnClick = false,\n shouldHideImageOrIconBackground,\n shouldHideIndicator = false,\n shouldPreventLayoutAnimation = false,\n shouldRenderClosed = false,\n shouldShowRoundImageOrIcon,\n shouldShowSeparatorBelow = false,\n subtitle,\n title,\n titleElement,\n shouldDisableAnimation = false,\n cornerElement,\n onImageError,\n}) => {\n const {\n incrementExpandableItemCount,\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n } = useContext(ListContext);\n\n const { isWrapped: isParentAccordionWrapped } = useContext(AccordionContext);\n\n const areaProvider = useContext(AreaContext);\n\n const isInitialRenderRef = useRef(true);\n\n const listItemRef = useRef<HTMLDivElement>(null);\n\n const uuid = useUuid();\n\n const isExpandable = children !== undefined;\n const isItemOpen = isOpen ?? openItemUuid === uuid;\n\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n\n const [shouldEnableTooltip, setShouldEnableTooltip] = useState(false);\n\n useEffect(() => {\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [isOpen, onClose, onOpen]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isItemOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isItemOpen]);\n\n const handleHeadClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n if (isExpandable) {\n updateOpenItemUuid(uuid);\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n },\n [isExpandable, onClick, updateOpenItemUuid, uuid],\n );\n\n useEffect(() => {\n if (isExpandable && !shouldHideIndicator) {\n // The incrementExpandableItemCount function returns a cleanup\n // function to decrement expandableItemCount if component unmounts\n return incrementExpandableItemCount();\n }\n\n return undefined;\n }, [incrementExpandableItemCount, isExpandable, shouldHideIndicator]);\n\n useEffect(() => {\n if (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n const isClickable = typeof onClick === 'function' || isExpandable;\n\n const headContent = useMemo(\n () => (\n <ListItemHead\n hoverItem={hoverItem}\n careOfLocationId={careOfLocationId}\n cornerElement={cornerElement}\n cornerImage={cornerImage}\n icons={icons}\n imageBackground={imageBackground}\n images={images}\n isAnyItemExpandable={isAnyItemExpandable}\n isExpandable={isExpandable}\n isOpen={isItemOpen}\n isTitleGreyed={isTitleGreyed}\n leftElements={leftElements}\n onClick={isClickable ? handleHeadClick : undefined}\n onLongPress={onLongPress}\n shouldForceHover={shouldForceHover}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n titleElement={titleElement}\n setShouldEnableTooltip={setShouldEnableTooltip}\n shouldDisableAnimation={shouldDisableAnimation}\n onImageError={onImageError}\n />\n ),\n [\n hoverItem,\n careOfLocationId,\n cornerElement,\n cornerImage,\n icons,\n imageBackground,\n images,\n isAnyItemExpandable,\n isExpandable,\n isItemOpen,\n isTitleGreyed,\n leftElements,\n isClickable,\n handleHeadClick,\n onLongPress,\n shouldForceHover,\n rightElements,\n shouldHideImageOrIconBackground,\n shouldHideIndicator,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n subtitle,\n title,\n titleElement,\n shouldDisableAnimation,\n onImageError,\n ],\n );\n\n return (\n <StyledListItem\n as={shouldDisableAnimation ? undefined : motion[LIST_ITEM_HTML_TAG]}\n animate={shouldDisableAnimation ? undefined : { height: 'auto', opacity: 1 }}\n className=\"beta-chayns-list-item\"\n exit={shouldDisableAnimation ? undefined : { height: 0, opacity: 0 }}\n initial={shouldDisableAnimation ? undefined : { height: 0, opacity: 0 }}\n key={`list-item-${uuid}`}\n ref={listItemRef}\n layout={shouldPreventLayoutAnimation || shouldDisableAnimation ? undefined : 'position'}\n $backgroundColor={backgroundColor}\n $isClickable={isClickable}\n $isInAccordion={\n typeof isParentAccordionWrapped === 'boolean' &&\n !areaProvider.shouldDisableListItemPadding\n }\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n >\n <Tooltip\n shouldUseFullWidth\n isDisabled={!shouldShowTooltipOnTitleOverflow || !shouldEnableTooltip}\n item={\n <StyledListItemTooltip\n style={{ cursor: 'default' }}\n key={`list-item-tooltip-${uuid}`}\n >\n {title}\n </StyledListItemTooltip>\n }\n >\n {headContent}\n </Tooltip>\n <AnimatePresence initial={false}>\n {isExpandable && (isItemOpen || shouldRenderClosed) && (\n <ListItemBody\n id={uuid}\n key={`listItemBody-${uuid}`}\n shouldHideBody={shouldRenderClosed && !isItemOpen}\n >\n <AreaContextProvider>{children}</AreaContextProvider>\n </ListItemBody>\n )}\n </AnimatePresence>\n </StyledListItem>\n );\n};\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,MAAM,QAAQ,cAAc;AACtD,OAAOC,KAAK,IAORC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;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emHead = ({
|
|
|
32
32
|
titleElement,
|
|
33
33
|
setShouldEnableTooltip,
|
|
34
34
|
shouldDisableAnimation = false,
|
|
35
|
-
cornerElement
|
|
35
|
+
cornerElement,
|
|
36
|
+
onImageError
|
|
36
37
|
}) => {
|
|
37
38
|
const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);
|
|
38
39
|
const titleWrapperRef = useRef(null);
|
|
@@ -97,7 +98,8 @@ const ListItemHead = ({
|
|
|
97
98
|
images: images,
|
|
98
99
|
shouldOpenImageOnClick: shouldOpenImageOnClick,
|
|
99
100
|
shouldHideBackground: !!shouldHideImageOrIconBackground,
|
|
100
|
-
shouldShowRoundImage: !!shouldShowRoundImageOrIcon
|
|
101
|
+
shouldShowRoundImage: !!shouldShowRoundImageOrIcon,
|
|
102
|
+
onImageError: onImageError
|
|
101
103
|
});
|
|
102
104
|
}
|
|
103
105
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemHead.js","names":["LayoutGroup","motion","React","useCallback","useEffect","useMemo","useRef","useState","getElementClickEvent","Icon","ListItemIcon","ListItemImage","ListItemRightElements","StyledListItemHeadContent","StyledListItemHeadLeftWrapper","StyledListItemHeadSubtitle","StyledListItemHeadSubtitleText","StyledListItemHeadTitleContent","StyledListItemHeadTitleElement","StyledListItemHeadTitleText","StyledMotionListItemHeadHoverItem","StyledMotionListItemHeadHoverItemWrapper","StyledListItemHead","StyledListItemHeadIndicator","StyledListItemHeadTitle","LIST_ITEM_HEAD_HTML_TAG","LIST_ITEM_HEAD_INDICATOR_HTML_TAG","LIST_ITEM_HEAD_TITLE_HTML_TAG","ListItemHead","careOfLocationId","cornerImage","hoverItem","icons","imageBackground","images","isAnyItemExpandable","isExpandable","isOpen","isTitleGreyed","leftElements","onClick","onLongPress","rightElements","shouldHideImageOrIconBackground","shouldHideIndicator","shouldOpenImageOnClick","shouldShowRoundImageOrIcon","subtitle","shouldForceHover","title","titleElement","setShouldEnableTooltip","shouldDisableAnimation","cornerElement","shouldShowHoverItem","setShouldShowHoverItem","titleWrapperRef","longPressTimeoutRef","shouldShowSubtitleRow","shouldShowMultilineTitle","handleShowTooltipResize","entries","el","target","scrollWidth","clientWidth","element","current","undefined","resizeObserver","ResizeObserver","observe","disconnect","handleMouseEnter","handleMouseLeave","handleTouchStart","event","window","setTimeout","handleTouchEnd","clearTimeout","shouldPreventRightElementClick","bottom","center","top","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","as","animate","opacity","initial","transition","duration","type","className","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rotate","$isIconOrImageGiven","$isOpen","layout","$isEllipsis","ref","$shouldShowMultilineTitle","marginLeft","width","displayName"],"sources":["../../../../../../src/components/list/list-item/list-item-head/ListItemHead.tsx"],"sourcesContent":["import { LayoutGroup, motion } from 'motion/react';\nimport 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 type { IListItemRightElements } from '../../../../types/list';\nimport { getElementClickEvent } from '../../../../utils/accordion';\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 StyledListItemHeadContent,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadSubtitleText,\n StyledListItemHeadTitleContent,\n StyledListItemHeadTitleElement,\n StyledListItemHeadTitleText,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadHoverItemWrapper,\n StyledListItemHead,\n StyledListItemHeadIndicator,\n StyledListItemHeadTitle,\n} from './ListItemHead.styles';\nimport {\n LIST_ITEM_HEAD_HTML_TAG,\n LIST_ITEM_HEAD_INDICATOR_HTML_TAG,\n LIST_ITEM_HEAD_TITLE_HTML_TAG,\n} from '../../../../constants/list';\n\ntype ListItemHeadProps = {\n careOfLocationId?: number;\n cornerImage?: string;\n hoverItem?: ReactNode;\n icons?: string[];\n imageBackground?: CSSProperties['background'];\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 shouldForceHover?: boolean;\n setShouldEnableTooltip: (value: boolean) => void;\n shouldDisableAnimation?: boolean;\n cornerElement?: ReactNode;\n};\n\nconst ListItemHead: FC<ListItemHeadProps> = ({\n careOfLocationId,\n cornerImage,\n hoverItem,\n icons,\n imageBackground,\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 shouldForceHover,\n title,\n titleElement,\n setShouldEnableTooltip,\n shouldDisableAnimation = false,\n cornerElement,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n\n const titleWrapperRef = useRef<HTMLDivElement>(null);\n\n const longPressTimeoutRef = useRef<number>();\n\n const shouldShowSubtitleRow = subtitle || typeof subtitle === 'string';\n\n const shouldShowMultilineTitle = useMemo(() => !subtitle, [subtitle]);\n\n const handleShowTooltipResize = useCallback(\n (entries: ResizeObserverEntry[]) => {\n const el = entries[0]?.target;\n if (!el) return;\n setShouldEnableTooltip(el.scrollWidth > el.clientWidth);\n },\n [setShouldEnableTooltip],\n );\n\n useEffect(() => {\n const element = titleWrapperRef?.current;\n if (!element) return undefined;\n\n const resizeObserver = new ResizeObserver(handleShowTooltipResize);\n resizeObserver.observe(element);\n\n return () => resizeObserver.disconnect();\n }, [handleShowTooltipResize]);\n\n const handleMouseEnter = useCallback(() => setShouldShowHoverItem(true), []);\n\n const handleMouseLeave = useCallback(() => setShouldShowHoverItem(false), []);\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 shouldPreventRightElementClick = useMemo(() => {\n if (!rightElements) return false;\n\n if (\n typeof rightElements === 'object' &&\n ('bottom' in rightElements || 'center' in rightElements || 'top' in rightElements)\n ) {\n if (rightElements.bottom && getElementClickEvent(rightElements.bottom)) {\n return true;\n }\n\n if (rightElements.center && getElementClickEvent(rightElements.center)) {\n return true;\n }\n\n if (rightElements.top && getElementClickEvent(rightElements.top)) {\n return true;\n }\n } else {\n return getElementClickEvent(rightElements as ReactNode);\n }\n\n return false;\n }, [rightElements]);\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 cornerElement={cornerElement}\n imageBackground={imageBackground}\n careOfLocationId={careOfLocationId}\n cornerImage={cornerImage}\n images={images}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundImage={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n return undefined;\n }, [\n careOfLocationId,\n cornerElement,\n cornerImage,\n icons,\n imageBackground,\n images,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n return (\n <StyledListItemHead\n as={shouldDisableAnimation ? undefined : motion[LIST_ITEM_HEAD_HTML_TAG]}\n animate={\n shouldDisableAnimation\n ? undefined\n : {\n opacity: isTitleGreyed ? 0.5 : 1,\n }\n }\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { 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 <StyledListItemHeadIndicator\n as={\n shouldDisableAnimation\n ? undefined\n : motion[LIST_ITEM_HEAD_INDICATOR_HTML_TAG]\n }\n animate={shouldDisableAnimation ? undefined : { rotate: isOpen ? 90 : 0 }}\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && (\n <Icon icons={['fa fa-chevron-right']} />\n )}\n </StyledListItemHeadIndicator>\n )}\n {leftElements}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $isOpen={isOpen}\n >\n <LayoutGroup>\n <StyledListItemHeadTitle\n as={\n shouldDisableAnimation\n ? undefined\n : motion[LIST_ITEM_HEAD_TITLE_HTML_TAG]\n }\n layout=\"position\"\n >\n <StyledListItemHeadTitleContent>\n <StyledListItemHeadTitleText\n $isEllipsis={!isOpen}\n ref={titleWrapperRef}\n $shouldShowMultilineTitle={shouldShowMultilineTitle}\n >\n {title}\n </StyledListItemHeadTitleText>\n <StyledListItemHeadTitleElement>\n {titleElement}\n </StyledListItemHeadTitleElement>\n </StyledListItemHeadTitleContent>\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <StyledListItemHeadSubtitleText $isOpen={isOpen}>\n {subtitle}\n </StyledListItemHeadSubtitleText>\n </StyledListItemHeadSubtitle>\n )}\n </LayoutGroup>\n </StyledListItemHeadContent>\n {rightElements && (\n <ListItemRightElements\n rightElements={rightElements}\n shouldPreventRightElementClick={shouldPreventRightElementClick}\n />\n )}\n {hoverItem && (\n <StyledMotionListItemHeadHoverItemWrapper\n className=\"beta-chayns-list-item-hover-item\"\n animate={{\n marginLeft: shouldForceHover || shouldShowHoverItem ? 8 : 0,\n opacity: shouldForceHover || shouldShowHoverItem ? 1 : 0,\n width: shouldForceHover || shouldShowHoverItem ? 'auto' : 0,\n }}\n initial={false}\n transition={{ duration: 0.15, type: 'tween' }}\n >\n <StyledMotionListItemHeadHoverItem>\n {hoverItem}\n </StyledMotionListItemHeadHoverItem>\n </StyledMotionListItemHeadHoverItemWrapper>\n )}\n </StyledListItemHead>\n );\n};\n\nListItemHead.displayName = 'ListItemHead';\n\nexport default ListItemHead;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,cAAc;AAClD,OAAOC,KAAK,IAMRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AAEd,SAASC,oBAAoB,QAAQ,6BAA6B;AAClE,OAAOC,IAAI,MAAM,oBAAoB;AACrC,OAAOC,YAAY,MAAM,+BAA+B;AACxD,OAAOC,aAAa,MAAM,iCAAiC;AAC3D,OAAOC,qBAAqB,MAAM,kDAAkD;AACpF,SACIC,yBAAyB,EACzBC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,2BAA2B,EAC3BC,iCAAiC,EACjCC,wCAAwC,EACxCC,kBAAkB,EAClBC,2BAA2B,EAC3BC,uBAAuB,QACpB,uBAAuB;AAC9B,S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AAE,IAAI;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9C9F,KAAA,CAAAoF,aAAA,CAAClE,iCAAiC,QAC7BW,SAC8B,CACG,CAE9B,CAAC;AAE7B,CAAC;AAEDH,YAAY,CAACqF,WAAW,GAAG,cAAc;AAEzC,eAAerF,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItemHead.js","names":["LayoutGroup","motion","React","useCallback","useEffect","useMemo","useRef","useState","getElementClickEvent","Icon","ListItemIcon","ListItemImage","ListItemRightElements","StyledListItemHeadContent","StyledListItemHeadLeftWrapper","StyledListItemHeadSubtitle","StyledListItemHeadSubtitleText","StyledListItemHeadTitleContent","StyledListItemHeadTitleElement","StyledListItemHeadTitleText","StyledMotionListItemHeadHoverItem","StyledMotionListItemHeadHoverItemWrapper","StyledListItemHead","StyledListItemHeadIndicator","StyledListItemHeadTitle","LIST_ITEM_HEAD_HTML_TAG","LIST_ITEM_HEAD_INDICATOR_HTML_TAG","LIST_ITEM_HEAD_TITLE_HTML_TAG","ListItemHead","careOfLocationId","cornerImage","hoverItem","icons","imageBackground","images","isAnyItemExpandable","isExpandable","isOpen","isTitleGreyed","leftElements","onClick","onLongPress","rightElements","shouldHideImageOrIconBackground","shouldHideIndicator","shouldOpenImageOnClick","shouldShowRoundImageOrIcon","subtitle","shouldForceHover","title","titleElement","setShouldEnableTooltip","shouldDisableAnimation","cornerElement","onImageError","shouldShowHoverItem","setShouldShowHoverItem","titleWrapperRef","longPressTimeoutRef","shouldShowSubtitleRow","shouldShowMultilineTitle","handleShowTooltipResize","entries","el","target","scrollWidth","clientWidth","element","current","undefined","resizeObserver","ResizeObserver","observe","disconnect","handleMouseEnter","handleMouseLeave","handleTouchStart","event","window","setTimeout","handleTouchEnd","clearTimeout","shouldPreventRightElementClick","bottom","center","top","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","as","animate","opacity","initial","transition","duration","type","className","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rotate","$isIconOrImageGiven","$isOpen","layout","$isEllipsis","ref","$shouldShowMultilineTitle","marginLeft","width","displayName"],"sources":["../../../../../../src/components/list/list-item/list-item-head/ListItemHead.tsx"],"sourcesContent":["import { LayoutGroup, motion } from 'motion/react';\nimport React, {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { IListItemRightElements } from '../../../../types/list';\nimport { getElementClickEvent } from '../../../../utils/accordion';\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 StyledListItemHeadContent,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadSubtitleText,\n StyledListItemHeadTitleContent,\n StyledListItemHeadTitleElement,\n StyledListItemHeadTitleText,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadHoverItemWrapper,\n StyledListItemHead,\n StyledListItemHeadIndicator,\n StyledListItemHeadTitle,\n} from './ListItemHead.styles';\nimport {\n LIST_ITEM_HEAD_HTML_TAG,\n LIST_ITEM_HEAD_INDICATOR_HTML_TAG,\n LIST_ITEM_HEAD_TITLE_HTML_TAG,\n} from '../../../../constants/list';\n\ntype ListItemHeadProps = {\n careOfLocationId?: number;\n cornerImage?: string;\n hoverItem?: ReactNode;\n icons?: string[];\n imageBackground?: CSSProperties['background'];\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 shouldForceHover?: boolean;\n setShouldEnableTooltip: (value: boolean) => void;\n shouldDisableAnimation?: boolean;\n cornerElement?: ReactNode;\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n};\n\nconst ListItemHead: FC<ListItemHeadProps> = ({\n careOfLocationId,\n cornerImage,\n hoverItem,\n icons,\n imageBackground,\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 shouldForceHover,\n title,\n titleElement,\n setShouldEnableTooltip,\n shouldDisableAnimation = false,\n cornerElement,\n onImageError,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n\n const titleWrapperRef = useRef<HTMLDivElement>(null);\n\n const longPressTimeoutRef = useRef<number>();\n\n const shouldShowSubtitleRow = subtitle || typeof subtitle === 'string';\n\n const shouldShowMultilineTitle = useMemo(() => !subtitle, [subtitle]);\n\n const handleShowTooltipResize = useCallback(\n (entries: ResizeObserverEntry[]) => {\n const el = entries[0]?.target;\n if (!el) return;\n setShouldEnableTooltip(el.scrollWidth > el.clientWidth);\n },\n [setShouldEnableTooltip],\n );\n\n useEffect(() => {\n const element = titleWrapperRef?.current;\n if (!element) return undefined;\n\n const resizeObserver = new ResizeObserver(handleShowTooltipResize);\n resizeObserver.observe(element);\n\n return () => resizeObserver.disconnect();\n }, [handleShowTooltipResize]);\n\n const handleMouseEnter = useCallback(() => setShouldShowHoverItem(true), []);\n\n const handleMouseLeave = useCallback(() => setShouldShowHoverItem(false), []);\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 shouldPreventRightElementClick = useMemo(() => {\n if (!rightElements) return false;\n\n if (\n typeof rightElements === 'object' &&\n ('bottom' in rightElements || 'center' in rightElements || 'top' in rightElements)\n ) {\n if (rightElements.bottom && getElementClickEvent(rightElements.bottom)) {\n return true;\n }\n\n if (rightElements.center && getElementClickEvent(rightElements.center)) {\n return true;\n }\n\n if (rightElements.top && getElementClickEvent(rightElements.top)) {\n return true;\n }\n } else {\n return getElementClickEvent(rightElements as ReactNode);\n }\n\n return false;\n }, [rightElements]);\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 cornerElement={cornerElement}\n imageBackground={imageBackground}\n careOfLocationId={careOfLocationId}\n cornerImage={cornerImage}\n images={images}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundImage={!!shouldShowRoundImageOrIcon}\n onImageError={onImageError}\n />\n );\n }\n\n return undefined;\n }, [\n careOfLocationId,\n cornerElement,\n cornerImage,\n icons,\n imageBackground,\n images,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n return (\n <StyledListItemHead\n as={shouldDisableAnimation ? undefined : motion[LIST_ITEM_HEAD_HTML_TAG]}\n animate={\n shouldDisableAnimation\n ? undefined\n : {\n opacity: isTitleGreyed ? 0.5 : 1,\n }\n }\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { 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 <StyledListItemHeadIndicator\n as={\n shouldDisableAnimation\n ? undefined\n : motion[LIST_ITEM_HEAD_INDICATOR_HTML_TAG]\n }\n animate={shouldDisableAnimation ? undefined : { rotate: isOpen ? 90 : 0 }}\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && (\n <Icon icons={['fa fa-chevron-right']} />\n )}\n </StyledListItemHeadIndicator>\n )}\n {leftElements}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $isOpen={isOpen}\n >\n <LayoutGroup>\n <StyledListItemHeadTitle\n as={\n shouldDisableAnimation\n ? undefined\n : motion[LIST_ITEM_HEAD_TITLE_HTML_TAG]\n }\n layout=\"position\"\n >\n <StyledListItemHeadTitleContent>\n <StyledListItemHeadTitleText\n $isEllipsis={!isOpen}\n ref={titleWrapperRef}\n $shouldShowMultilineTitle={shouldShowMultilineTitle}\n >\n {title}\n </StyledListItemHeadTitleText>\n <StyledListItemHeadTitleElement>\n {titleElement}\n </StyledListItemHeadTitleElement>\n </StyledListItemHeadTitleContent>\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <StyledListItemHeadSubtitleText $isOpen={isOpen}>\n {subtitle}\n </StyledListItemHeadSubtitleText>\n </StyledListItemHeadSubtitle>\n )}\n </LayoutGroup>\n </StyledListItemHeadContent>\n {rightElements && (\n <ListItemRightElements\n rightElements={rightElements}\n shouldPreventRightElementClick={shouldPreventRightElementClick}\n />\n )}\n {hoverItem && (\n <StyledMotionListItemHeadHoverItemWrapper\n className=\"beta-chayns-list-item-hover-item\"\n animate={{\n marginLeft: shouldForceHover || shouldShowHoverItem ? 8 : 0,\n opacity: shouldForceHover || shouldShowHoverItem ? 1 : 0,\n width: shouldForceHover || shouldShowHoverItem ? 'auto' : 0,\n }}\n initial={false}\n transition={{ duration: 0.15, type: 'tween' }}\n >\n <StyledMotionListItemHeadHoverItem>\n {hoverItem}\n </StyledMotionListItemHeadHoverItem>\n </StyledMotionListItemHeadHoverItemWrapper>\n )}\n </StyledListItemHead>\n );\n};\n\nListItemHead.displayName = 'ListItemHead';\n\nexport default ListItemHead;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,cAAc;AAClD,OAAOC,KAAK,IAORC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AAEd,SAASC,oBAAoB,QAAQ,6BAA6B;AAClE,OAAOC,IAAI,MAAM,oBAAoB;AACrC,OAAOC,YAAY,MAAM,+BAA+B;AACxD,OAAOC,aAAa,MAAM,iCAAiC;AAC3D,OAAOC,qBAAqB,MAAM,kDAAkD;AACpF,SACIC,yBAAyB,EACzBC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,2BAA2B,EAC3BC,iCAAiC,EACjCC,wCAAwC,EACxCC,kBAAkB,EAClBC,2BAA2B,EAC3BC,uBAAuB,QACpB,uBAAuB;AAC9B,SACIC,uBAAuB,EACvBC,iCAAiC,EACjCC,6BAA6B,QAC1B,4BAA4B;AA+BnC,MAAMC,YAAmC,GAAGA,CAAC;EACzCC,gBAAgB;EAChBC,WAAW;EACXC,SAAS;EACTC,KAAK;EACLC,eAAe;EACfC,MAAM;EACNC,mBAAmB;EACnBC,YAAY;EACZC,MAAM;EACNC,aAAa;EACbC,YAAY;EACZC,OAAO;EACPC,WAAW;EACXC,aAAa;EACbC,+BAA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Image = ({
|
|
|
9
9
|
shouldHideBackground,
|
|
10
10
|
shouldShowRoundImage,
|
|
11
11
|
shouldOpenImageOnClick,
|
|
12
|
-
cornerElement
|
|
12
|
+
cornerElement,
|
|
13
|
+
onImageError
|
|
13
14
|
}) => {
|
|
14
15
|
const handleImageClick = useCallback(event => {
|
|
15
16
|
if (!shouldOpenImageOnClick) {
|
|
@@ -38,7 +39,8 @@ const ListItemImage = ({
|
|
|
38
39
|
images: images,
|
|
39
40
|
onClick: handleImageClick,
|
|
40
41
|
shouldPreventBackground: shouldHideBackground,
|
|
41
|
-
shouldShowRoundImage: shouldShowRoundImage
|
|
42
|
+
shouldShowRoundImage: shouldShowRoundImage,
|
|
43
|
+
onImageError: onImageError
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
return null;
|
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","GroupedImage","ListItemImage","careOfLocationId","cornerImage","imageBackground","images","shouldHideBackground","shouldShowRoundImage","shouldOpenImageOnClick","cornerElement","handleImageClick","event","preventDefault","stopPropagation","items","map","image","url","mediaType","IMAGE","startIndex","careOfImage","undefined","createElement","onClick","shouldPreventBackground","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, {
|
|
1
|
+
{"version":3,"file":"ListItemImage.js","names":["MediaType","openMedia","React","useCallback","GroupedImage","ListItemImage","careOfLocationId","cornerImage","imageBackground","images","shouldHideBackground","shouldShowRoundImage","shouldOpenImageOnClick","cornerElement","onImageError","handleImageClick","event","preventDefault","stopPropagation","items","map","image","url","mediaType","IMAGE","startIndex","careOfImage","undefined","createElement","onClick","shouldPreventBackground","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, {\n CSSProperties,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n useCallback,\n} from 'react';\nimport GroupedImage from '../../../../grouped-image/GroupedImage';\n\ntype ListItemImageProps = {\n careOfLocationId?: number;\n cornerImage?: string;\n imageBackground?: CSSProperties['background'];\n images: string[];\n shouldHideBackground: boolean;\n shouldShowRoundImage: boolean;\n shouldOpenImageOnClick: boolean;\n cornerElement?: ReactNode;\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n};\n\nconst ListItemImage: React.FC<ListItemImageProps> = ({\n careOfLocationId,\n cornerImage,\n imageBackground,\n images,\n shouldHideBackground,\n shouldShowRoundImage,\n shouldOpenImageOnClick,\n cornerElement,\n onImageError,\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]) {\n const careOfImage = careOfLocationId\n ? `https://sub60.tobit.com/l/${careOfLocationId}?size=128`\n : undefined;\n\n return (\n <GroupedImage\n cornerElement={cornerElement}\n cornerImage={cornerImage ?? careOfImage}\n imageBackground={imageBackground}\n images={images}\n onClick={handleImageClick}\n shouldPreventBackground={shouldHideBackground}\n shouldShowRoundImage={shouldShowRoundImage}\n onImageError={onImageError}\n />\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,IAKRC,WAAW,QACR,OAAO;AACd,OAAOC,YAAY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@ export const useUsableHeight = () => {
|
|
|
20
20
|
const {
|
|
21
21
|
bottomBarHeight,
|
|
22
22
|
offsetTop,
|
|
23
|
+
topBarHeight,
|
|
23
24
|
windowHeight
|
|
24
25
|
} = useWindowMetrics();
|
|
25
26
|
usableHeight = windowHeight;
|
|
@@ -29,6 +30,9 @@ export const useUsableHeight = () => {
|
|
|
29
30
|
if (offsetTop) {
|
|
30
31
|
usableHeight -= offsetTop;
|
|
31
32
|
}
|
|
33
|
+
if (topBarHeight) {
|
|
34
|
+
usableHeight -= topBarHeight;
|
|
35
|
+
}
|
|
32
36
|
return usableHeight;
|
|
33
37
|
};
|
|
34
38
|
//# sourceMappingURL=pageProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageProvider.js","names":["getWindowMetrics","useWindowMetrics","getUsableHeight","usableHeight","bottomBarHeight","offsetTop","windowHeight","useUsableHeight"],"sources":["../../../src/utils/pageProvider.ts"],"sourcesContent":["import { getWindowMetrics, useWindowMetrics } from 'chayns-api';\n\nexport const getUsableHeight = async () => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = await getWindowMetrics();\n\n usableHeight = windowHeight;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n\nexport const useUsableHeight = () => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = useWindowMetrics();\n usableHeight = windowHeight;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,gBAAgB,QAAQ,YAAY;AAE/D,OAAO,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAAY;EACvC,IAAIC,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAG,MAAMN,gBAAgB,CAAC,CAAC;EAE7EG,YAAY,GAAGG,YAAY;EAE3B,IAAIF,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC;AAED,OAAO,MAAMI,eAAe,GAAGA,CAAA,KAAM;EACjC,IAAIJ,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;
|
|
1
|
+
{"version":3,"file":"pageProvider.js","names":["getWindowMetrics","useWindowMetrics","getUsableHeight","usableHeight","bottomBarHeight","offsetTop","windowHeight","useUsableHeight","topBarHeight"],"sources":["../../../src/utils/pageProvider.ts"],"sourcesContent":["import { getWindowMetrics, useWindowMetrics } from 'chayns-api';\n\nexport const getUsableHeight = async () => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = await getWindowMetrics();\n\n usableHeight = windowHeight;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n\nexport const useUsableHeight = () => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, topBarHeight, windowHeight } = useWindowMetrics();\n\n usableHeight = windowHeight;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n if (topBarHeight) {\n usableHeight -= topBarHeight;\n }\n\n return usableHeight;\n};\n"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,gBAAgB,QAAQ,YAAY;AAE/D,OAAO,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAAY;EACvC,IAAIC,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAG,MAAMN,gBAAgB,CAAC,CAAC;EAE7EG,YAAY,GAAGG,YAAY;EAE3B,IAAIF,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC;AAED,OAAO,MAAMI,eAAe,GAAGA,CAAA,KAAM;EACjC,IAAIJ,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEG,YAAY;IAAEF;EAAa,CAAC,GAAGL,gBAAgB,CAAC,CAAC;EAErFE,YAAY,GAAGG,YAAY;EAE3B,IAAIF,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,IAAIG,YAAY,EAAE;IACdL,YAAY,IAAIK,YAAY;EAChC;EAEA,OAAOL,YAAY;AACvB,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, FC, MouseEventHandler, ReactNode } from 'react';
|
|
1
|
+
import { CSSProperties, FC, MouseEventHandler, ReactNode, SyntheticEvent } from 'react';
|
|
2
2
|
type GroupedImageProps = {
|
|
3
3
|
/**
|
|
4
4
|
* Optional image to display in the bottom right corner of the grouped image.
|
|
@@ -32,6 +32,10 @@ type GroupedImageProps = {
|
|
|
32
32
|
* Optional Element to display in the right corner of the image
|
|
33
33
|
*/
|
|
34
34
|
cornerElement?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Optional handler for image load errors.
|
|
37
|
+
*/
|
|
38
|
+
onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;
|
|
35
39
|
};
|
|
36
40
|
declare const GroupedImage: FC<GroupedImageProps>;
|
|
37
41
|
export default GroupedImage;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, FC, MouseEventHandler, ReactNode, TouchEventHandler } from 'react';
|
|
1
|
+
import { CSSProperties, FC, MouseEventHandler, ReactNode, SyntheticEvent, TouchEventHandler } from 'react';
|
|
2
2
|
import type { IListItemRightElements } from '../../../types/list';
|
|
3
3
|
export type ListItemElements = [ReactNode, ...ReactNode[]];
|
|
4
4
|
export type ListItemProps = {
|
|
@@ -152,6 +152,10 @@ export type ListItemProps = {
|
|
|
152
152
|
* Optional Element to display in the right corner of the image
|
|
153
153
|
*/
|
|
154
154
|
cornerElement?: ReactNode;
|
|
155
|
+
/**
|
|
156
|
+
* Optional handler for image load errors.
|
|
157
|
+
*/
|
|
158
|
+
onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;
|
|
155
159
|
};
|
|
156
160
|
declare const ListItem: FC<ListItemProps>;
|
|
157
161
|
export default ListItem;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, FC, MouseEventHandler, ReactNode, TouchEventHandler } from 'react';
|
|
1
|
+
import { CSSProperties, FC, MouseEventHandler, ReactNode, SyntheticEvent, TouchEventHandler } from 'react';
|
|
2
2
|
import type { IListItemRightElements } from '../../../../types/list';
|
|
3
3
|
type ListItemHeadProps = {
|
|
4
4
|
careOfLocationId?: number;
|
|
@@ -26,6 +26,7 @@ type ListItemHeadProps = {
|
|
|
26
26
|
setShouldEnableTooltip: (value: boolean) => void;
|
|
27
27
|
shouldDisableAnimation?: boolean;
|
|
28
28
|
cornerElement?: ReactNode;
|
|
29
|
+
onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;
|
|
29
30
|
};
|
|
30
31
|
declare const ListItemHead: FC<ListItemHeadProps>;
|
|
31
32
|
export default ListItemHead;
|
package/lib/types/components/list/list-item/list-item-head/list-item-image/ListItemImage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { CSSProperties, ReactNode } from 'react';
|
|
1
|
+
import React, { CSSProperties, ReactNode, SyntheticEvent } from 'react';
|
|
2
2
|
type ListItemImageProps = {
|
|
3
3
|
careOfLocationId?: number;
|
|
4
4
|
cornerImage?: string;
|
|
@@ -8,6 +8,7 @@ type ListItemImageProps = {
|
|
|
8
8
|
shouldShowRoundImage: boolean;
|
|
9
9
|
shouldOpenImageOnClick: boolean;
|
|
10
10
|
cornerElement?: ReactNode;
|
|
11
|
+
onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;
|
|
11
12
|
};
|
|
12
13
|
declare const ListItemImage: React.FC<ListItemImageProps>;
|
|
13
14
|
export default ListItemImage;
|
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.1208",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "9943256cdaf3e07b1d1dd122df026470c9ae2662"
|
|
89
89
|
}
|