@chayns-components/core 5.5.51 → 5.5.52
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/list/list-item/ListItem.js +3 -1
- package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
- package/lib/cjs/components/list/list-item/ListItem.test.js +137 -0
- package/lib/cjs/components/list/list-item/ListItem.test.js.map +1 -0
- package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js +2 -1
- package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.js +3 -1
- package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.test.js +133 -0
- package/lib/esm/components/list/list-item/ListItem.test.js.map +1 -0
- package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js +2 -1
- package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
- package/lib/types/components/list/list-item/ListItem.d.ts +17 -0
- package/lib/types/components/list/list-item/list-item-head/ListItemHead.d.ts +1 -0
- package/package.json +2 -2
|
@@ -49,6 +49,7 @@ const ListItem = /*#__PURE__*/(0, _react2.forwardRef)(({
|
|
|
49
49
|
shouldOpenImageOnClick = false,
|
|
50
50
|
shouldHideImageOrIconBackground,
|
|
51
51
|
shouldHideIndicator = false,
|
|
52
|
+
shouldAnimateLayout = false,
|
|
52
53
|
shouldPreventLayoutAnimation = false,
|
|
53
54
|
shouldRenderClosed = false,
|
|
54
55
|
shouldShowRoundImageOrIcon,
|
|
@@ -230,7 +231,7 @@ const ListItem = /*#__PURE__*/(0, _react2.forwardRef)(({
|
|
|
230
231
|
key: `list-item-${uuid}`,
|
|
231
232
|
ref: listItemRef,
|
|
232
233
|
"data-uuid": `${listGroupUuid ?? ''}---${uuid}`,
|
|
233
|
-
layout: shouldPreventLayoutAnimation
|
|
234
|
+
layout: shouldAnimateLayout && !shouldPreventLayoutAnimation && !shouldDisableAnimation ? 'position' : undefined,
|
|
234
235
|
$backgroundColor: backgroundColor,
|
|
235
236
|
$isClickable: isClickable,
|
|
236
237
|
$isInAccordion: typeof isParentAccordionWrapped === 'boolean' && !areaProvider.shouldDisableListItemPadding,
|
|
@@ -287,6 +288,7 @@ const ListItem = /*#__PURE__*/(0, _react2.forwardRef)(({
|
|
|
287
288
|
titleElement: titleElement,
|
|
288
289
|
setShouldEnableTooltip: setShouldEnableTooltip,
|
|
289
290
|
shouldDisableAnimation: shouldDisableAnimation,
|
|
291
|
+
shouldAnimateLayout: shouldAnimateLayout && !shouldPreventLayoutAnimation && !shouldDisableAnimation,
|
|
290
292
|
onImageError: onImageError
|
|
291
293
|
})), /*#__PURE__*/_react2.default.createElement(_react.AnimatePresence, {
|
|
292
294
|
initial: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["_react","require","_react2","_interopRequireWildcard","_styledComponents","_uuid","_Accordion","_AreaContextProvider","_ColorSchemeProvider","_List","_List2","_ListItemBody","_interopRequireDefault","_ListItemHead","_ListItem","_Tooltip","_element","_useFocusRingPortal","_useKeyboardFocusHighlighting","_useListItemFocus","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ListItem","forwardRef","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","onImageError","onSizeChange","onTitleInputChange","titleElement","titleInputProps","shouldDisableAnimation","cornerElement","isSelected","shouldEnableKeyboardHighlighting","shouldEnableKeyboardHighlightingProp","ref","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","shouldEnableKeyboardHighlightingContext","listGroupUuid","listItemUuids","registerListItemUuid","unregisterListItemUuid","activeListItemUuid","updateActiveListItemUuid","useContext","ListContext","colorScheme","useColorScheme","theme","useTheme","isInsideListContext","isParentAccordionWrapped","AccordionContext","areaProvider","AreaContext","isInitialRenderRef","useRef","listItemRef","isInDialog","useIsInsideDialog","uuid","useUuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","useState","titleWidth","setTitleWidth","titleMaxWidth","setTitleMaxWidth","useEffect","current","handleHeadClick","useCallback","event","shouldOnlyOpen","isClickable","useImperativeHandle","handleTitleWidthChange","width","maxWidth","shouldShowKeyboardHighlighting","useKeyboardFocusHighlighting","useFocusRingPortal","isEnabled","borderRadius","cardBorderRadius","isInKeyboardNavigationGroup","tabIndex","useMemo","handleKeyDown","isCurrentListItemTarget","currentTarget","target","currentListItemElement","targetElement","handleHorizontalArrowNavigation","handleListItemTabNavigation","currentUuid","handleVerticalListGroupNavigation","handleListItemToggleKey","toggleItem","some","handleKey","isFocusWithinListItem","handleFocus","handleBlur","useListItemFocus","shouldForceHoverItem","createElement","StyledListItem","as","motion","div","animate","height","opacity","className","exit","initial","key","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$isInDialog","$isSelected","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","onKeyDown","onFocus","onBlur","shouldUseFullWidth","isDisabled","item","StyledListItemTooltip","style","cursor","onTitleWidthChange","AnimatePresence","id","shouldHideBody","displayName","_default","exports"],"sources":["../../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence, motion } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport type { InputProps } from '../../input/Input';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { type Theme, useColorScheme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { ListContext } from '../List';\nimport {\n handleHorizontalArrowNavigation,\n handleListItemTabNavigation,\n handleListItemToggleKey,\n handleVerticalListGroupNavigation,\n} from '../List.utils';\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 { useIsInsideDialog } from '../../../hooks/element';\nimport { useFocusRingPortal } from '../../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../../hooks/useKeyboardFocusHighlighting';\nimport { useListItemFocus } from './useListItemFocus';\n\nexport type ListItemElements = [ReactNode, ...ReactNode[]];\n\nexport interface ListItemSize {\n titleWidth: number;\n titleMaxWidth: number;\n}\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 * Whether the item is selected.\n */\n isSelected?: 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 * 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 * Function to be executed if the size are changed.\n */\n onSizeChange?: (sizes: ListItemSize) => void;\n /**\n * Enables keyboard-only focus highlighting. Overrides the value from the List context.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n /**\n * Function that is executed when the text of the title input changes.\n * When this function is given, the title is displayed as an input.\n */\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * The props of the title input.\n */\n titleInputProps?: InputProps;\n};\n\nexport type ListItemRef = ListItemSize;\n\nconst ListItem = forwardRef<ListItemRef, ListItemProps>(\n (\n {\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 onImageError,\n onSizeChange,\n onTitleInputChange,\n titleElement,\n titleInputProps,\n shouldDisableAnimation = false,\n cornerElement,\n isSelected = false,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingProp,\n },\n ref,\n ) => {\n const {\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingContext,\n listGroupUuid,\n listItemUuids,\n registerListItemUuid,\n unregisterListItemUuid,\n activeListItemUuid,\n updateActiveListItemUuid,\n } = useContext(ListContext);\n const colorScheme = useColorScheme();\n const theme = useTheme() as Theme;\n const isInsideListContext = typeof listGroupUuid === 'string';\n\n const shouldEnableKeyboardHighlighting =\n shouldEnableKeyboardHighlightingProp ??\n (isInsideListContext\n ? shouldEnableKeyboardHighlightingContext\n : (colorScheme?.shouldEnableKeyboardHighlighting ?? false));\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 isInDialog = useIsInsideDialog<HTMLDivElement>(listItemRef);\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 const [titleWidth, setTitleWidth] = useState(0);\n const [titleMaxWidth, setTitleMaxWidth] = useState(0);\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 (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n const isClickable = typeof onClick === 'function' || isExpandable;\n\n useEffect(() => {\n if (typeof onSizeChange === 'function') {\n onSizeChange({\n titleWidth,\n titleMaxWidth,\n });\n }\n }, [onSizeChange, titleMaxWidth, titleWidth]);\n\n useImperativeHandle(\n ref,\n () => ({\n titleWidth,\n titleMaxWidth,\n }),\n [titleMaxWidth, titleWidth],\n );\n\n const handleTitleWidthChange = useCallback((width: number, maxWidth: number) => {\n setTitleWidth(width);\n setTitleMaxWidth(maxWidth);\n }, []);\n\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlighting,\n );\n useFocusRingPortal(listItemRef, {\n isEnabled: shouldShowKeyboardHighlighting,\n borderRadius: `${theme.cardBorderRadius}px`,\n });\n\n const isInKeyboardNavigationGroup =\n shouldEnableKeyboardHighlighting &&\n typeof listGroupUuid === 'string' &&\n typeof updateActiveListItemUuid === 'function';\n\n useEffect(() => {\n if (\n shouldEnableKeyboardHighlighting &&\n typeof registerListItemUuid === 'function' &&\n typeof unregisterListItemUuid === 'function'\n ) {\n registerListItemUuid(uuid);\n\n return () => {\n unregisterListItemUuid(uuid);\n };\n }\n\n return undefined;\n }, [shouldEnableKeyboardHighlighting, registerListItemUuid, unregisterListItemUuid, uuid]);\n\n const tabIndex = useMemo(\n () => (shouldEnableKeyboardHighlighting ? 0 : -1),\n [shouldEnableKeyboardHighlighting],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n const isCurrentListItemTarget = event.currentTarget === event.target;\n const currentListItemElement = event.currentTarget as HTMLDivElement;\n const targetElement = event.target as HTMLElement | null;\n\n [\n () =>\n shouldEnableKeyboardHighlighting &&\n handleHorizontalArrowNavigation({\n event,\n currentListItemElement,\n targetElement,\n isCurrentListItemTarget,\n }),\n () =>\n handleListItemTabNavigation({\n event,\n currentListItemElement,\n targetElement,\n isCurrentListItemTarget,\n isInKeyboardNavigationGroup,\n listItemUuids,\n currentUuid: uuid,\n listGroupUuid,\n updateActiveListItemUuid,\n }),\n () =>\n handleVerticalListGroupNavigation({\n event,\n isCurrentListItemTarget,\n isInKeyboardNavigationGroup,\n listItemUuids,\n currentUuid: uuid,\n listGroupUuid,\n updateActiveListItemUuid,\n }),\n () =>\n handleListItemToggleKey({\n event,\n isCurrentListItemTarget,\n isExpandable,\n isItemOpen,\n shouldEnableKeyboardHighlighting,\n toggleItem: () =>\n handleHeadClick(\n event as unknown as React.MouseEvent<HTMLDivElement>,\n ),\n }),\n ].some((handleKey) => handleKey());\n },\n [\n handleHeadClick,\n isExpandable,\n isInKeyboardNavigationGroup,\n isItemOpen,\n listGroupUuid,\n listItemUuids,\n shouldEnableKeyboardHighlighting,\n updateActiveListItemUuid,\n uuid,\n ],\n );\n\n const { isFocusWithinListItem, handleFocus, handleBlur } = useListItemFocus({\n uuid,\n listGroupUuid,\n isInKeyboardNavigationGroup,\n updateActiveListItemUuid,\n });\n const shouldForceHoverItem = shouldForceHover || isFocusWithinListItem;\n\n useEffect(() => {\n if (\n isInKeyboardNavigationGroup &&\n activeListItemUuid == null &&\n typeof updateActiveListItemUuid === 'function' &&\n listItemUuids?.[0] === uuid\n ) {\n updateActiveListItemUuid(uuid);\n }\n }, [\n activeListItemUuid,\n isInKeyboardNavigationGroup,\n listItemUuids,\n updateActiveListItemUuid,\n uuid,\n ]);\n\n return (\n <StyledListItem\n as={shouldDisableAnimation ? undefined : motion.div}\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 data-uuid={`${listGroupUuid ?? ''}---${uuid}`}\n layout={\n shouldPreventLayoutAnimation || shouldDisableAnimation ? undefined : 'position'\n }\n $backgroundColor={backgroundColor}\n $isClickable={isClickable}\n $isInAccordion={\n typeof isParentAccordionWrapped === 'boolean' &&\n !areaProvider.shouldDisableListItemPadding\n }\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n $isInDialog={isInDialog}\n $isSelected={isSelected}\n $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n data-should-show-keyboard-highlighting={\n shouldShowKeyboardHighlighting ? 'true' : undefined\n }\n tabIndex={tabIndex}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\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 <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={shouldForceHoverItem}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n onTitleInputChange={onTitleInputChange}\n onTitleWidthChange={handleTitleWidthChange}\n titleInputProps={titleInputProps}\n titleElement={titleElement}\n setShouldEnableTooltip={setShouldEnableTooltip}\n shouldDisableAnimation={shouldDisableAnimation}\n onImageError={onImageError}\n />\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);\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAiBA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAGA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAJ,uBAAA,CAAAF,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAMA,IAAAU,aAAA,GAAAC,sBAAA,CAAAX,OAAA;AACA,IAAAY,aAAA,GAAAD,sBAAA,CAAAX,OAAA;AACA,IAAAa,SAAA,GAAAb,OAAA;AACA,IAAAc,QAAA,GAAAH,sBAAA,CAAAX,OAAA;AACA,IAAAe,QAAA,GAAAf,OAAA;A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EAAEA,sBAAuB;IAC/CK,0BAA0B,EAAEA,0BAA2B;IACvDE,QAAQ,EAAEA,QAAS;IACnBC,KAAK,EAAEA,KAAM;IACbG,kBAAkB,EAAEA,kBAAmB;IACvC8H,kBAAkB,EAAEpE,sBAAuB;IAC3CxD,eAAe,EAAEA,eAAgB;IACjCD,YAAY,EAAEA,YAAa;IAC3B2C,sBAAsB,EAAEA,sBAAuB;IAC/CzC,sBAAsB,EAAEA,sBAAuB;IAC/CL,YAAY,EAAEA;EAAa,CAC9B,CACI,CAAC,eACVtE,OAAA,CAAAoB,OAAA,CAAA6I,aAAA,CAACnK,MAAA,CAAAyM,eAAe;IAAC5B,OAAO,EAAE;EAAM,GAC3B7D,YAAY,KAAKE,UAAU,IAAI/C,kBAAkB,CAAC,iBAC/CjE,OAAA,CAAAoB,OAAA,CAAA6I,aAAA,CAACxJ,aAAA,CAAAW,OAAY;IACToL,EAAE,EAAE5F,IAAK;IACTgE,GAAG,EAAE,gBAAgBhE,IAAI,EAAG;IAC5B6F,cAAc,EAAExI,kBAAkB,IAAI,CAAC+C;EAAW,gBAElDhH,OAAA,CAAAoB,OAAA,CAAA6I,aAAA,CAAC5J,oBAAA,CAAAe,OAAmB,QAAEqB,QAA8B,CAC1C,CAEL,CACL,CAAC;AAEzB,CACJ,CAAC;AAEDJ,QAAQ,CAACqK,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxL,OAAA,GAEnBiB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItem.js","names":["_react","require","_react2","_interopRequireWildcard","_styledComponents","_uuid","_Accordion","_AreaContextProvider","_ColorSchemeProvider","_List","_List2","_ListItemBody","_interopRequireDefault","_ListItemHead","_ListItem","_Tooltip","_element","_useFocusRingPortal","_useKeyboardFocusHighlighting","_useListItemFocus","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ListItem","forwardRef","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","shouldAnimateLayout","shouldPreventLayoutAnimation","shouldRenderClosed","shouldShowRoundImageOrIcon","shouldShowSeparatorBelow","subtitle","title","onImageError","onSizeChange","onTitleInputChange","titleElement","titleInputProps","shouldDisableAnimation","cornerElement","isSelected","shouldEnableKeyboardHighlighting","shouldEnableKeyboardHighlightingProp","ref","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","shouldEnableKeyboardHighlightingContext","listGroupUuid","listItemUuids","registerListItemUuid","unregisterListItemUuid","activeListItemUuid","updateActiveListItemUuid","useContext","ListContext","colorScheme","useColorScheme","theme","useTheme","isInsideListContext","isParentAccordionWrapped","AccordionContext","areaProvider","AreaContext","isInitialRenderRef","useRef","listItemRef","isInDialog","useIsInsideDialog","uuid","useUuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","useState","titleWidth","setTitleWidth","titleMaxWidth","setTitleMaxWidth","useEffect","current","handleHeadClick","useCallback","event","shouldOnlyOpen","isClickable","useImperativeHandle","handleTitleWidthChange","width","maxWidth","shouldShowKeyboardHighlighting","useKeyboardFocusHighlighting","useFocusRingPortal","isEnabled","borderRadius","cardBorderRadius","isInKeyboardNavigationGroup","tabIndex","useMemo","handleKeyDown","isCurrentListItemTarget","currentTarget","target","currentListItemElement","targetElement","handleHorizontalArrowNavigation","handleListItemTabNavigation","currentUuid","handleVerticalListGroupNavigation","handleListItemToggleKey","toggleItem","some","handleKey","isFocusWithinListItem","handleFocus","handleBlur","useListItemFocus","shouldForceHoverItem","createElement","StyledListItem","as","motion","div","animate","height","opacity","className","exit","initial","key","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$isInDialog","$isSelected","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","onKeyDown","onFocus","onBlur","shouldUseFullWidth","isDisabled","item","StyledListItemTooltip","style","cursor","onTitleWidthChange","AnimatePresence","id","shouldHideBody","displayName","_default","exports"],"sources":["../../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence, motion } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport type { InputProps } from '../../input/Input';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { type Theme, useColorScheme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { ListContext } from '../List';\nimport {\n handleHorizontalArrowNavigation,\n handleListItemTabNavigation,\n handleListItemToggleKey,\n handleVerticalListGroupNavigation,\n} from '../List.utils';\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 { useIsInsideDialog } from '../../../hooks/element';\nimport { useFocusRingPortal } from '../../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../../hooks/useKeyboardFocusHighlighting';\nimport { useListItemFocus } from './useListItemFocus';\n\nexport type ListItemElements = [ReactNode, ...ReactNode[]];\n\nexport interface ListItemSize {\n titleWidth: number;\n titleMaxWidth: number;\n}\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 * Whether the item is selected.\n */\n isSelected?: 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 framer-motion layout projection (`layout=\"position\"`) should be\n * enabled. This animates the `ListItem` smoothly into its new position when\n * sibling items are reordered, expanded or resized.\n *\n * This is opt-in and disabled by default, because framer-motions layout\n * projection is viewport-global: every layout change anywhere in the document\n * (window resize, height animation, ...) forces a re-measurement of **all**\n * layout-projection nodes via `getBoundingClientRect`. In lists with many\n * `ListItem`s this scales linearly and causes noticeable layout thrash. The\n * enter/exit height/opacity animation is unaffected and stays enabled.\n */\n shouldAnimateLayout?: 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 * @deprecated The layout projection is now disabled by default. Use\n * `shouldAnimateLayout` to opt into it instead. When set to `true`, this\n * prop keeps forcing the layout projection off.\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 * 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 * Function to be executed if the size are changed.\n */\n onSizeChange?: (sizes: ListItemSize) => void;\n /**\n * Enables keyboard-only focus highlighting. Overrides the value from the List context.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n /**\n * Function that is executed when the text of the title input changes.\n * When this function is given, the title is displayed as an input.\n */\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * The props of the title input.\n */\n titleInputProps?: InputProps;\n};\n\nexport type ListItemRef = ListItemSize;\n\nconst ListItem = forwardRef<ListItemRef, ListItemProps>(\n (\n {\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 shouldAnimateLayout = false,\n shouldPreventLayoutAnimation = false,\n shouldRenderClosed = false,\n shouldShowRoundImageOrIcon,\n shouldShowSeparatorBelow = false,\n subtitle,\n title,\n onImageError,\n onSizeChange,\n onTitleInputChange,\n titleElement,\n titleInputProps,\n shouldDisableAnimation = false,\n cornerElement,\n isSelected = false,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingProp,\n },\n ref,\n ) => {\n const {\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingContext,\n listGroupUuid,\n listItemUuids,\n registerListItemUuid,\n unregisterListItemUuid,\n activeListItemUuid,\n updateActiveListItemUuid,\n } = useContext(ListContext);\n const colorScheme = useColorScheme();\n const theme = useTheme() as Theme;\n const isInsideListContext = typeof listGroupUuid === 'string';\n\n const shouldEnableKeyboardHighlighting =\n shouldEnableKeyboardHighlightingProp ??\n (isInsideListContext\n ? shouldEnableKeyboardHighlightingContext\n : (colorScheme?.shouldEnableKeyboardHighlighting ?? false));\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 isInDialog = useIsInsideDialog<HTMLDivElement>(listItemRef);\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 const [titleWidth, setTitleWidth] = useState(0);\n const [titleMaxWidth, setTitleMaxWidth] = useState(0);\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 (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n const isClickable = typeof onClick === 'function' || isExpandable;\n\n useEffect(() => {\n if (typeof onSizeChange === 'function') {\n onSizeChange({\n titleWidth,\n titleMaxWidth,\n });\n }\n }, [onSizeChange, titleMaxWidth, titleWidth]);\n\n useImperativeHandle(\n ref,\n () => ({\n titleWidth,\n titleMaxWidth,\n }),\n [titleMaxWidth, titleWidth],\n );\n\n const handleTitleWidthChange = useCallback((width: number, maxWidth: number) => {\n setTitleWidth(width);\n setTitleMaxWidth(maxWidth);\n }, []);\n\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlighting,\n );\n useFocusRingPortal(listItemRef, {\n isEnabled: shouldShowKeyboardHighlighting,\n borderRadius: `${theme.cardBorderRadius}px`,\n });\n\n const isInKeyboardNavigationGroup =\n shouldEnableKeyboardHighlighting &&\n typeof listGroupUuid === 'string' &&\n typeof updateActiveListItemUuid === 'function';\n\n useEffect(() => {\n if (\n shouldEnableKeyboardHighlighting &&\n typeof registerListItemUuid === 'function' &&\n typeof unregisterListItemUuid === 'function'\n ) {\n registerListItemUuid(uuid);\n\n return () => {\n unregisterListItemUuid(uuid);\n };\n }\n\n return undefined;\n }, [shouldEnableKeyboardHighlighting, registerListItemUuid, unregisterListItemUuid, uuid]);\n\n const tabIndex = useMemo(\n () => (shouldEnableKeyboardHighlighting ? 0 : -1),\n [shouldEnableKeyboardHighlighting],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n const isCurrentListItemTarget = event.currentTarget === event.target;\n const currentListItemElement = event.currentTarget as HTMLDivElement;\n const targetElement = event.target as HTMLElement | null;\n\n [\n () =>\n shouldEnableKeyboardHighlighting &&\n handleHorizontalArrowNavigation({\n event,\n currentListItemElement,\n targetElement,\n isCurrentListItemTarget,\n }),\n () =>\n handleListItemTabNavigation({\n event,\n currentListItemElement,\n targetElement,\n isCurrentListItemTarget,\n isInKeyboardNavigationGroup,\n listItemUuids,\n currentUuid: uuid,\n listGroupUuid,\n updateActiveListItemUuid,\n }),\n () =>\n handleVerticalListGroupNavigation({\n event,\n isCurrentListItemTarget,\n isInKeyboardNavigationGroup,\n listItemUuids,\n currentUuid: uuid,\n listGroupUuid,\n updateActiveListItemUuid,\n }),\n () =>\n handleListItemToggleKey({\n event,\n isCurrentListItemTarget,\n isExpandable,\n isItemOpen,\n shouldEnableKeyboardHighlighting,\n toggleItem: () =>\n handleHeadClick(\n event as unknown as React.MouseEvent<HTMLDivElement>,\n ),\n }),\n ].some((handleKey) => handleKey());\n },\n [\n handleHeadClick,\n isExpandable,\n isInKeyboardNavigationGroup,\n isItemOpen,\n listGroupUuid,\n listItemUuids,\n shouldEnableKeyboardHighlighting,\n updateActiveListItemUuid,\n uuid,\n ],\n );\n\n const { isFocusWithinListItem, handleFocus, handleBlur } = useListItemFocus({\n uuid,\n listGroupUuid,\n isInKeyboardNavigationGroup,\n updateActiveListItemUuid,\n });\n const shouldForceHoverItem = shouldForceHover || isFocusWithinListItem;\n\n useEffect(() => {\n if (\n isInKeyboardNavigationGroup &&\n activeListItemUuid == null &&\n typeof updateActiveListItemUuid === 'function' &&\n listItemUuids?.[0] === uuid\n ) {\n updateActiveListItemUuid(uuid);\n }\n }, [\n activeListItemUuid,\n isInKeyboardNavigationGroup,\n listItemUuids,\n updateActiveListItemUuid,\n uuid,\n ]);\n\n return (\n <StyledListItem\n as={shouldDisableAnimation ? undefined : motion.div}\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 data-uuid={`${listGroupUuid ?? ''}---${uuid}`}\n layout={\n shouldAnimateLayout && !shouldPreventLayoutAnimation && !shouldDisableAnimation\n ? 'position'\n : undefined\n }\n $backgroundColor={backgroundColor}\n $isClickable={isClickable}\n $isInAccordion={\n typeof isParentAccordionWrapped === 'boolean' &&\n !areaProvider.shouldDisableListItemPadding\n }\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n $isInDialog={isInDialog}\n $isSelected={isSelected}\n $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n data-should-show-keyboard-highlighting={\n shouldShowKeyboardHighlighting ? 'true' : undefined\n }\n tabIndex={tabIndex}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\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 <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={shouldForceHoverItem}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n onTitleInputChange={onTitleInputChange}\n onTitleWidthChange={handleTitleWidthChange}\n titleInputProps={titleInputProps}\n titleElement={titleElement}\n setShouldEnableTooltip={setShouldEnableTooltip}\n shouldDisableAnimation={shouldDisableAnimation}\n shouldAnimateLayout={\n shouldAnimateLayout &&\n !shouldPreventLayoutAnimation &&\n !shouldDisableAnimation\n }\n onImageError={onImageError}\n />\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);\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAiBA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAGA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAJ,uBAAA,CAAAF,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAMA,IAAAU,aAAA,GAAAC,sBAAA,CAAAX,OAAA;AACA,IAAAY,aAAA,GAAAD,sBAAA,CAAAX,OAAA;AACA,IAAAa,SAAA,GAAAb,OAAA;AACA,IAAAc,QAAA,GAAAH,sBAAA,CAAAX,OAAA;AACA,IAAAe,QAAA,GAAAf,OAAA;AACA,IAAAgB,mBAAA,GAAAhB,OAAA;AACA,IAAAiB,6BAAA,GAAAjB,OAAA;AACA,IAAAkB,iBAAA,GAAAlB,OAAA;AAAsD,SAAAW,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAjB,wBAAAiB,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,O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sBAAsB,EAAEA,sBAAuB;IAC/CzC,sBAAsB,EAAEA,sBAAuB;IAC/CZ,mBAAmB,EACfA,mBAAmB,IACnB,CAACC,4BAA4B,IAC7B,CAACW,sBACJ;IACDL,YAAY,EAAEA;EAAa,CAC9B,CACI,CAAC,eACVvE,OAAA,CAAAoB,OAAA,CAAA8I,aAAA,CAACpK,MAAA,CAAA0M,eAAe;IAAC5B,OAAO,EAAE;EAAM,GAC3B7D,YAAY,KAAKE,UAAU,IAAI/C,kBAAkB,CAAC,iBAC/ClE,OAAA,CAAAoB,OAAA,CAAA8I,aAAA,CAACzJ,aAAA,CAAAW,OAAY;IACTqL,EAAE,EAAE5F,IAAK;IACTgE,GAAG,EAAE,gBAAgBhE,IAAI,EAAG;IAC5B6F,cAAc,EAAExI,kBAAkB,IAAI,CAAC+C;EAAW,gBAElDjH,OAAA,CAAAoB,OAAA,CAAA8I,aAAA,CAAC7J,oBAAA,CAAAe,OAAmB,QAAEqB,QAA8B,CAC1C,CAEL,CACL,CAAC;AAEzB,CACJ,CAAC;AAEDJ,QAAQ,CAACsK,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzL,OAAA,GAEnBiB,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
var _react2 = require("motion/react");
|
|
5
|
+
var _react3 = _interopRequireDefault(require("react"));
|
|
6
|
+
var _styledComponents = require("styled-components");
|
|
7
|
+
var _vitest = require("vitest");
|
|
8
|
+
var _List = _interopRequireDefault(require("../List"));
|
|
9
|
+
var _ListItem = _interopRequireDefault(require("./ListItem"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
12
|
+
|
|
13
|
+
_vitest.vi.mock('@chayns/textstrings', () => ({
|
|
14
|
+
useTranslation: () => ({
|
|
15
|
+
t: textString => typeof textString === 'string' ? textString : textString.fallback
|
|
16
|
+
})
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Regression guard for the framer-motion layout-projection thrash.
|
|
21
|
+
*
|
|
22
|
+
* framer-motions layout projection (`layout` / `layout="position"`) is
|
|
23
|
+
* viewport-global: all layout-projection nodes share a single projection tree, so
|
|
24
|
+
* a layout change on *any* node forces a re-measurement of *all* nodes via
|
|
25
|
+
* `getBoundingClientRect`. With many `ListItem`s this scales linearly with N.
|
|
26
|
+
*
|
|
27
|
+
* The tests below render a projection node (`motion.div layout`) *outside* the
|
|
28
|
+
* list and change its layout. They then count how many `getBoundingClientRect`
|
|
29
|
+
* calls hit the rendered `ListItem` elements:
|
|
30
|
+
* - default (no `shouldAnimateLayout`): the items are not projection nodes, so
|
|
31
|
+
* the external change does not re-measure them (reads === 0).
|
|
32
|
+
* - `shouldAnimateLayout`: the items join the shared projection tree, so they are
|
|
33
|
+
* re-measured by the unrelated external change (reads > 0).
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const ITEM_COUNT = 20;
|
|
37
|
+
let boundingRectCalls;
|
|
38
|
+
let originalGetBoundingClientRect;
|
|
39
|
+
const isInsideList = element => Boolean(element.closest('.beta-chayns-list-item'));
|
|
40
|
+
(0, _vitest.beforeEach)(() => {
|
|
41
|
+
boundingRectCalls = 0;
|
|
42
|
+
originalGetBoundingClientRect = Element.prototype.getBoundingClientRect;
|
|
43
|
+
Element.prototype.getBoundingClientRect = function getBoundingClientRect() {
|
|
44
|
+
if (isInsideList(this)) {
|
|
45
|
+
boundingRectCalls += 1;
|
|
46
|
+
}
|
|
47
|
+
return originalGetBoundingClientRect.apply(this);
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
(0, _vitest.afterEach)(() => {
|
|
51
|
+
Element.prototype.getBoundingClientRect = originalGetBoundingClientRect;
|
|
52
|
+
});
|
|
53
|
+
const theme = {
|
|
54
|
+
'100-rgb': '255, 255, 255',
|
|
55
|
+
'102-rgb': '255, 255, 255',
|
|
56
|
+
'headline-rgb': '0, 0, 0',
|
|
57
|
+
cardBackgroundOpacity: 1,
|
|
58
|
+
accordionLines: true,
|
|
59
|
+
accordionIcon: 'fa-chevron-right',
|
|
60
|
+
iconStyle: 'fa-regular'
|
|
61
|
+
};
|
|
62
|
+
const Harness = ({
|
|
63
|
+
shouldAnimateLayout,
|
|
64
|
+
isExternalExpanded
|
|
65
|
+
}) => /*#__PURE__*/_react3.default.createElement(_styledComponents.ThemeProvider, {
|
|
66
|
+
theme: theme
|
|
67
|
+
}, /*#__PURE__*/_react3.default.createElement(_react2.motion.div, {
|
|
68
|
+
layout: true,
|
|
69
|
+
"data-testid": "outside",
|
|
70
|
+
style: {
|
|
71
|
+
height: isExternalExpanded ? 500 : 100
|
|
72
|
+
}
|
|
73
|
+
}), /*#__PURE__*/_react3.default.createElement(_List.default, null, Array.from({
|
|
74
|
+
length: ITEM_COUNT
|
|
75
|
+
}, (_, index) => /*#__PURE__*/_react3.default.createElement(_ListItem.default, {
|
|
76
|
+
key: index,
|
|
77
|
+
title: `Item ${index}`,
|
|
78
|
+
shouldAnimateLayout: shouldAnimateLayout
|
|
79
|
+
}))));
|
|
80
|
+
const flushFrames = async () => {
|
|
81
|
+
await (0, _react.act)(async () => {
|
|
82
|
+
await new Promise(resolve => {
|
|
83
|
+
requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined)));
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Render the list, then trigger a layout change on the external projection node
|
|
90
|
+
* and return the number of `getBoundingClientRect` calls that hit the list items.
|
|
91
|
+
*/
|
|
92
|
+
const measureExternalLayoutChange = async shouldAnimateLayout => {
|
|
93
|
+
const {
|
|
94
|
+
rerender
|
|
95
|
+
} = (0, _react.render)(/*#__PURE__*/_react3.default.createElement(Harness, {
|
|
96
|
+
shouldAnimateLayout: shouldAnimateLayout,
|
|
97
|
+
isExternalExpanded: false
|
|
98
|
+
}));
|
|
99
|
+
await flushFrames();
|
|
100
|
+
boundingRectCalls = 0;
|
|
101
|
+
rerender(/*#__PURE__*/_react3.default.createElement(Harness, {
|
|
102
|
+
shouldAnimateLayout: shouldAnimateLayout,
|
|
103
|
+
isExternalExpanded: true
|
|
104
|
+
}));
|
|
105
|
+
await flushFrames();
|
|
106
|
+
return boundingRectCalls;
|
|
107
|
+
};
|
|
108
|
+
(0, _vitest.describe)('ListItem layout projection', () => {
|
|
109
|
+
(0, _vitest.it)('does not re-measure items on external layout changes by default', async () => {
|
|
110
|
+
const reads = await measureExternalLayoutChange(false);
|
|
111
|
+
(0, _vitest.expect)(reads).toBe(0);
|
|
112
|
+
});
|
|
113
|
+
(0, _vitest.it)('re-measures items on external layout changes when shouldAnimateLayout is set', async () => {
|
|
114
|
+
const reads = await measureExternalLayoutChange(true);
|
|
115
|
+
(0, _vitest.expect)(reads).toBeGreaterThan(0);
|
|
116
|
+
});
|
|
117
|
+
(0, _vitest.it)('keeps the enter/exit animation for added/removed items without layout projection', async () => {
|
|
118
|
+
const renderItems = titles => /*#__PURE__*/_react3.default.createElement(_styledComponents.ThemeProvider, {
|
|
119
|
+
theme: theme
|
|
120
|
+
}, /*#__PURE__*/_react3.default.createElement(_List.default, null, titles.map(title => /*#__PURE__*/_react3.default.createElement(_ListItem.default, {
|
|
121
|
+
key: title,
|
|
122
|
+
title: title
|
|
123
|
+
}))));
|
|
124
|
+
const {
|
|
125
|
+
rerender,
|
|
126
|
+
queryByText
|
|
127
|
+
} = (0, _react.render)(renderItems(['A', 'B', 'C']));
|
|
128
|
+
await flushFrames();
|
|
129
|
+
|
|
130
|
+
// Remove the first item. AnimatePresence must keep it mounted while its
|
|
131
|
+
// exit (height/opacity) animation runs -- this is independent of the
|
|
132
|
+
// (disabled) layout projection.
|
|
133
|
+
rerender(renderItems(['B', 'C']));
|
|
134
|
+
(0, _vitest.expect)(queryByText('A')).not.toBeNull();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=ListItem.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListItem.test.js","names":["_react","require","_react2","_react3","_interopRequireDefault","_styledComponents","_vitest","_List","_ListItem","e","__esModule","default","vi","mock","useTranslation","t","textString","fallback","ITEM_COUNT","boundingRectCalls","originalGetBoundingClientRect","isInsideList","element","Boolean","closest","beforeEach","Element","prototype","getBoundingClientRect","apply","afterEach","theme","cardBackgroundOpacity","accordionLines","accordionIcon","iconStyle","Harness","shouldAnimateLayout","isExternalExpanded","createElement","ThemeProvider","motion","div","layout","style","height","Array","from","length","_","index","key","title","flushFrames","act","Promise","resolve","requestAnimationFrame","undefined","measureExternalLayoutChange","rerender","render","describe","it","reads","expect","toBe","toBeGreaterThan","renderItems","titles","map","queryByText","not","toBeNull"],"sources":["../../../../../src/components/list/list-item/ListItem.test.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { act, render } from '@testing-library/react';\nimport { motion } from 'motion/react';\nimport React from 'react';\nimport { ThemeProvider } from 'styled-components';\nimport { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';\nimport type { Theme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport List from '../List';\nimport ListItem from './ListItem';\n\nvi.mock('@chayns/textstrings', () => ({\n useTranslation: () => ({\n t: (textString: { fallback?: string } | string) =>\n typeof textString === 'string' ? textString : textString.fallback,\n }),\n}));\n\n/**\n * Regression guard for the framer-motion layout-projection thrash.\n *\n * framer-motions layout projection (`layout` / `layout=\"position\"`) is\n * viewport-global: all layout-projection nodes share a single projection tree, so\n * a layout change on *any* node forces a re-measurement of *all* nodes via\n * `getBoundingClientRect`. With many `ListItem`s this scales linearly with N.\n *\n * The tests below render a projection node (`motion.div layout`) *outside* the\n * list and change its layout. They then count how many `getBoundingClientRect`\n * calls hit the rendered `ListItem` elements:\n * - default (no `shouldAnimateLayout`): the items are not projection nodes, so\n * the external change does not re-measure them (reads === 0).\n * - `shouldAnimateLayout`: the items join the shared projection tree, so they are\n * re-measured by the unrelated external change (reads > 0).\n */\n\nconst ITEM_COUNT = 20;\n\nlet boundingRectCalls: number;\nlet originalGetBoundingClientRect: typeof Element.prototype.getBoundingClientRect;\n\nconst isInsideList = (element: Element) => Boolean(element.closest('.beta-chayns-list-item'));\n\nbeforeEach(() => {\n boundingRectCalls = 0;\n originalGetBoundingClientRect = Element.prototype.getBoundingClientRect;\n\n Element.prototype.getBoundingClientRect = function getBoundingClientRect(\n this: Element,\n ): DOMRect {\n if (isInsideList(this)) {\n boundingRectCalls += 1;\n }\n\n return originalGetBoundingClientRect.apply(this) as DOMRect;\n };\n});\n\nafterEach(() => {\n Element.prototype.getBoundingClientRect = originalGetBoundingClientRect;\n});\n\nconst theme = {\n '100-rgb': '255, 255, 255',\n '102-rgb': '255, 255, 255',\n 'headline-rgb': '0, 0, 0',\n cardBackgroundOpacity: 1,\n accordionLines: true,\n accordionIcon: 'fa-chevron-right',\n iconStyle: 'fa-regular',\n} as unknown as Theme;\n\ntype HarnessProps = {\n shouldAnimateLayout: boolean;\n isExternalExpanded: boolean;\n};\n\nconst Harness = ({ shouldAnimateLayout, isExternalExpanded }: HarnessProps) => (\n <ThemeProvider theme={theme}>\n {/* A layout-projection node completely outside of the list. */}\n <motion.div\n layout\n data-testid=\"outside\"\n style={{ height: isExternalExpanded ? 500 : 100 }}\n />\n <List>\n {Array.from({ length: ITEM_COUNT }, (_, index) => (\n <ListItem\n key={index}\n title={`Item ${index}`}\n shouldAnimateLayout={shouldAnimateLayout}\n />\n ))}\n </List>\n </ThemeProvider>\n);\n\nconst flushFrames = async () => {\n await act(async () => {\n await new Promise((resolve) => {\n requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined)));\n });\n });\n};\n\n/**\n * Render the list, then trigger a layout change on the external projection node\n * and return the number of `getBoundingClientRect` calls that hit the list items.\n */\nconst measureExternalLayoutChange = async (shouldAnimateLayout: boolean) => {\n const { rerender } = render(\n <Harness shouldAnimateLayout={shouldAnimateLayout} isExternalExpanded={false} />,\n );\n\n await flushFrames();\n\n boundingRectCalls = 0;\n\n rerender(<Harness shouldAnimateLayout={shouldAnimateLayout} isExternalExpanded />);\n\n await flushFrames();\n\n return boundingRectCalls;\n};\n\ndescribe('ListItem layout projection', () => {\n it('does not re-measure items on external layout changes by default', async () => {\n const reads = await measureExternalLayoutChange(false);\n\n expect(reads).toBe(0);\n });\n\n it('re-measures items on external layout changes when shouldAnimateLayout is set', async () => {\n const reads = await measureExternalLayoutChange(true);\n\n expect(reads).toBeGreaterThan(0);\n });\n\n it('keeps the enter/exit animation for added/removed items without layout projection', async () => {\n const renderItems = (titles: string[]) => (\n <ThemeProvider theme={theme}>\n <List>\n {titles.map((title) => (\n <ListItem key={title} title={title} />\n ))}\n </List>\n </ThemeProvider>\n );\n\n const { rerender, queryByText } = render(renderItems(['A', 'B', 'C']));\n\n await flushFrames();\n\n // Remove the first item. AnimatePresence must keep it mounted while its\n // exit (height/opacity) animation runs -- this is independent of the\n // (disabled) layout projection.\n rerender(renderItems(['B', 'C']));\n\n expect(queryByText('A')).not.toBeNull();\n });\n});\n"],"mappings":";;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,KAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,SAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAAkC,SAAAG,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AARlC;;AAUAG,UAAE,CAACC,IAAI,CAAC,qBAAqB,EAAE,OAAO;EAClCC,cAAc,EAAEA,CAAA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CAAC;IAEjC,IAAAH,cAAM,EAACM,WAAW,CAAC,GAAG,CAAC,CAAC,CAACC,GAAG,CAACC,QAAQ,CAAC,CAAC;EAC3C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -45,6 +45,7 @@ const ListItemHead = ({
|
|
|
45
45
|
titleElement,
|
|
46
46
|
setShouldEnableTooltip,
|
|
47
47
|
shouldDisableAnimation = false,
|
|
48
|
+
shouldAnimateLayout = false,
|
|
48
49
|
cornerElement,
|
|
49
50
|
onTitleWidthChange,
|
|
50
51
|
onImageError,
|
|
@@ -165,7 +166,7 @@ const ListItemHead = ({
|
|
|
165
166
|
$isOpen: isOpen
|
|
166
167
|
}, /*#__PURE__*/_react2.default.createElement(_react.LayoutGroup, null, /*#__PURE__*/_react2.default.createElement(_ListItemHead.StyledListItemHeadTitle, {
|
|
167
168
|
as: shouldDisableAnimation ? undefined : _react.motion.div,
|
|
168
|
-
layout:
|
|
169
|
+
layout: shouldAnimateLayout ? 'position' : undefined
|
|
169
170
|
}, hasTitleInput ?
|
|
170
171
|
/*#__PURE__*/
|
|
171
172
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemHead.js","names":["_react","require","_react2","_interopRequireWildcard","_ListItemIcon","_interopRequireDefault","_ListItemImage","_ListItemHead","_ListItemTitle","_ListItemSubtitle","_ListItemRightElement","_styledComponents","_Icon","_icon","_Input","_AreaContextProvider","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","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","onTitleWidthChange","onImageError","onTitleInputChange","titleInputProps","shouldShowHoverItem","setShouldShowHoverItem","useState","titleMaxWidth","setTitleMaxWidth","titleWidth","setTitleWidth","longPressTimeoutRef","useRef","resizeSkipRef","leftElementRef","theme","useTheme","areaProvider","useContext","AreaContext","hasTitleInput","shouldShowSubtitleRow","shouldShowMultilineTitle","useMemo","useEffect","window","setTimeout","current","handleShowTooltipResize","useCallback","entries","_entries$","_entries$2","target","clientWidth","el","scrollWidth","handleMouseEnter","handleMouseLeave","handleTouchStart","event","handleTouchEnd","clearTimeout","handleTitleWidthChange","width","shouldShowHoverItemContent","handleInputClick","stopPropagation","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","undefined","expandIcon","internalIcon","getIsExpandableIcon","accordionIcon","internalIconStyle","iconStyle","StyledUnicodeIcon","$icon","className","StyledListItemHead","as","motion","div","animate","opacity","initial","transition","duration","type","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","StyledListItemHeadLeftWrapper","StyledListItemHeadIndicator","rotate","StyledListItemHeadLeftElements","ref","StyledListItemHeadContent","$isIconOrImageGiven","$isOpen","LayoutGroup","StyledListItemHeadTitle","layout","Provider","value","shouldChangeColor","StyledListItemHeadTitleInputWrapper","onChange","onResize","StyledListItemHeadSubtitle","StyledMotionListItemHeadHoverItemWrapper","marginLeft","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 ChangeEventHandler,\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 type { IListItemRightElements } from '../../../../types/list';\nimport type { InputProps } from '../../../input/Input';\nimport ListItemIcon from './list-item-icon/ListItemIcon';\nimport ListItemImage from './list-item-image/ListItemImage';\nimport {\n StyledListItemHead,\n StyledListItemHeadContent,\n StyledListItemHeadIndicator,\n StyledListItemHeadLeftElements,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadTitle,\n StyledListItemHeadTitleInputWrapper,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadHoverItemWrapper,\n} from './ListItemHead.styles';\nimport ListItemTitle from './list-item-title/ListItemTitle';\nimport ListItemSubtitle from './list-item-subtitle/ListItemSubtitle';\nimport ListItemRightElement from './list-item-right-element/ListItemRightElement';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../../../color-scheme-provider/ColorSchemeProvider';\nimport { StyledUnicodeIcon } from '../../../icon/Icon.styles';\nimport { getIsExpandableIcon } from '../../../../utils/icon';\nimport Input from '../../../input/Input';\nimport { AreaContext } from '../../../area-provider/AreaContextProvider';\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 onTitleWidthChange: (titleWidth: number, titleMaxWidth: number) => void;\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n titleInputProps?: InputProps;\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 onTitleWidthChange,\n onImageError,\n onTitleInputChange,\n titleInputProps,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n const [titleMaxWidth, setTitleMaxWidth] = useState(0);\n const [titleWidth, setTitleWidth] = useState(0);\n\n const longPressTimeoutRef = useRef<number>();\n const resizeSkipRef = useRef(true);\n const leftElementRef = useRef<HTMLDivElement>(null);\n\n const theme = useTheme() as Theme;\n const areaProvider = useContext(AreaContext);\n\n const hasTitleInput = typeof onTitleInputChange === 'function';\n\n const shouldShowSubtitleRow =\n (!hasTitleInput && (subtitle || typeof subtitle === 'string')) ||\n (typeof rightElements === 'object' && rightElements && 'bottom' in rightElements);\n\n const shouldShowMultilineTitle = useMemo(\n () => !subtitle && !hasTitleInput,\n [hasTitleInput, subtitle],\n );\n\n useEffect(() => {\n window.setTimeout(() => {\n resizeSkipRef.current = false;\n }, 200);\n }, []);\n\n useEffect(() => {\n onTitleWidthChange(titleWidth, titleMaxWidth);\n }, [onTitleWidthChange, titleMaxWidth, titleWidth]);\n\n const handleShowTooltipResize = useCallback(\n (entries: ResizeObserverEntry[]) => {\n setTitleWidth(entries[0]?.target.clientWidth ?? 0);\n\n if (resizeSkipRef.current) {\n return;\n }\n\n const el = entries[0]?.target;\n if (!el) return;\n setShouldEnableTooltip(el.scrollWidth > el.clientWidth);\n },\n [setShouldEnableTooltip],\n );\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 handleTitleWidthChange = useCallback((width: number) => {\n setTitleMaxWidth(width);\n }, []);\n const shouldShowHoverItemContent = !!(shouldForceHover || shouldShowHoverItem);\n\n const handleInputClick = useCallback<MouseEventHandler<HTMLDivElement>>((event) => {\n event.stopPropagation();\n }, []);\n\n const iconOrImageElement = useMemo(() => {\n if (icons) {\n return (\n <ListItemIcon\n icons={icons}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundIcon={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n if (images) {\n return (\n <ListItemImage\n cornerElement={cornerElement}\n imageBackground={imageBackground}\n careOfLocationId={careOfLocationId}\n cornerImage={cornerImage}\n images={images}\n onImageError={onImageError}\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 onImageError,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n const expandIcon = useMemo(() => {\n const internalIcon = getIsExpandableIcon(theme.accordionIcon);\n const internalIconStyle = theme?.iconStyle ? theme.iconStyle : 'fa-regular';\n return <StyledUnicodeIcon $icon={internalIcon} className={internalIconStyle} />;\n }, [theme.accordionIcon, theme.iconStyle]);\n\n return (\n <StyledListItemHead\n as={shouldDisableAnimation ? undefined : motion.div}\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={shouldDisableAnimation ? undefined : motion.div}\n animate={shouldDisableAnimation ? undefined : { rotate: isOpen ? 90 : 0 }}\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && expandIcon}\n </StyledListItemHeadIndicator>\n )}\n {leftElements && (\n <StyledListItemHeadLeftElements ref={leftElementRef} data-left-element=\"true\">\n {leftElements}\n </StyledListItemHeadLeftElements>\n )}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $isOpen={isOpen}\n >\n <LayoutGroup>\n <StyledListItemHeadTitle\n as={shouldDisableAnimation ? undefined : motion.div}\n layout=\"position\"\n >\n {hasTitleInput ? (\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n <AreaContext.Provider\n value={{ ...areaProvider, shouldChangeColor: true }}\n >\n <StyledListItemHeadTitleInputWrapper onClick={handleInputClick}>\n <Input\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...titleInputProps}\n value={typeof title === 'string' ? title : undefined}\n onChange={onTitleInputChange}\n />\n </StyledListItemHeadTitleInputWrapper>\n </AreaContext.Provider>\n ) : (\n <ListItemTitle\n title={title}\n titleElement={titleElement}\n isOpen={isOpen}\n shouldShowMultilineTitle={shouldShowMultilineTitle}\n rightElements={rightElements}\n onTitleWidthChange={handleTitleWidthChange}\n onResize={handleShowTooltipResize}\n />\n )}\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <ListItemSubtitle\n subtitle={subtitle}\n isOpen={isOpen}\n rightElements={rightElements}\n />\n </StyledListItemHeadSubtitle>\n )}\n </LayoutGroup>\n </StyledListItemHeadContent>\n <ListItemRightElement rightElements={rightElements} />\n {hoverItem && shouldShowHoverItemContent && (\n <StyledMotionListItemHeadHoverItemWrapper\n className=\"beta-chayns-list-item-hover-item\"\n animate={{\n marginLeft: 8,\n opacity: 1,\n width: 'auto',\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;AAiBA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAYA,IAAAO,cAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,iBAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,qBAAA,GAAAL,sBAAA,CAAAJ,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AAEA,IAAAW,KAAA,GAAAX,OAAA;AACA,IAAAY,KAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAT,sBAAA,CAAAJ,OAAA;AACA,IAAAc,oBAAA,GAAAd,OAAA;AAAyE,SAAAI,uBAAAW,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAA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AuB;IAC3CoD,QAAQ,EAAEnE;EAAwB,CACrC,CAEgB,CAAC,EACzBP,qBAAqB,iBAClBtF,OAAA,CAAAgB,OAAA,CAAAkG,aAAA,CAAC7G,aAAA,CAAA4J,0BAA0B,qBACvBjK,OAAA,CAAAgB,OAAA,CAAAkG,aAAA,CAAC3G,iBAAA,CAAAS,OAAgB;IACb0C,QAAQ,EAAEA,QAAS;IACnBV,MAAM,EAAEA,MAAO;IACfK,aAAa,EAAEA;EAAc,CAChC,CACuB,CAEvB,CACU,CAAC,eAC5BrD,OAAA,CAAAgB,OAAA,CAAAkG,aAAA,CAAC1G,qBAAA,CAAAQ,OAAoB;IAACqC,aAAa,EAAEA;EAAc,CAAE,CAAC,EACrDX,SAAS,IAAIoE,0BAA0B,iBACpC9G,OAAA,CAAAgB,OAAA,CAAAkG,aAAA,CAAC7G,aAAA,CAAA6J,wCAAwC;IACrCnC,SAAS,EAAC,kCAAkC;IAC5CK,OAAO,EAAE;MACL+B,UAAU,EAAE,CAAC;MACb9B,OAAO,EAAE,CAAC;MACVxB,KAAK,EAAE;IACX,CAAE;IACFyB,OAAO,EAAE,KAAM;IACfC,UAAU,EAAE;MAAEC,QAAQ,EAAE,IAAI;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9CzI,OAAA,CAAAgB,OAAA,CAAAkG,aAAA,CAAC7G,aAAA,CAAA+J,iCAAiC,QAC7B1H,SAC8B,CACG,CAE9B,CAAC;AAE7B,CAAC;AAEDH,YAAY,CAAC8H,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAvJ,OAAA,GAE3BuB,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItemHead.js","names":["_react","require","_react2","_interopRequireWildcard","_ListItemIcon","_interopRequireDefault","_ListItemImage","_ListItemHead","_ListItemTitle","_ListItemSubtitle","_ListItemRightElement","_styledComponents","_Icon","_icon","_Input","_AreaContextProvider","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","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","shouldAnimateLayout","cornerElement","onTitleWidthChange","onImageError","onTitleInputChange","titleInputProps","shouldShowHoverItem","setShouldShowHoverItem","useState","titleMaxWidth","setTitleMaxWidth","titleWidth","setTitleWidth","longPressTimeoutRef","useRef","resizeSkipRef","leftElementRef","theme","useTheme","areaProvider","useContext","AreaContext","hasTitleInput","shouldShowSubtitleRow","shouldShowMultilineTitle","useMemo","useEffect","window","setTimeout","current","handleShowTooltipResize","useCallback","entries","_entries$","_entries$2","target","clientWidth","el","scrollWidth","handleMouseEnter","handleMouseLeave","handleTouchStart","event","handleTouchEnd","clearTimeout","handleTitleWidthChange","width","shouldShowHoverItemContent","handleInputClick","stopPropagation","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","undefined","expandIcon","internalIcon","getIsExpandableIcon","accordionIcon","internalIconStyle","iconStyle","StyledUnicodeIcon","$icon","className","StyledListItemHead","as","motion","div","animate","opacity","initial","transition","duration","type","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","StyledListItemHeadLeftWrapper","StyledListItemHeadIndicator","rotate","StyledListItemHeadLeftElements","ref","StyledListItemHeadContent","$isIconOrImageGiven","$isOpen","LayoutGroup","StyledListItemHeadTitle","layout","Provider","value","shouldChangeColor","StyledListItemHeadTitleInputWrapper","onChange","onResize","StyledListItemHeadSubtitle","StyledMotionListItemHeadHoverItemWrapper","marginLeft","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 ChangeEventHandler,\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 type { IListItemRightElements } from '../../../../types/list';\nimport type { InputProps } from '../../../input/Input';\nimport ListItemIcon from './list-item-icon/ListItemIcon';\nimport ListItemImage from './list-item-image/ListItemImage';\nimport {\n StyledListItemHead,\n StyledListItemHeadContent,\n StyledListItemHeadIndicator,\n StyledListItemHeadLeftElements,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadTitle,\n StyledListItemHeadTitleInputWrapper,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadHoverItemWrapper,\n} from './ListItemHead.styles';\nimport ListItemTitle from './list-item-title/ListItemTitle';\nimport ListItemSubtitle from './list-item-subtitle/ListItemSubtitle';\nimport ListItemRightElement from './list-item-right-element/ListItemRightElement';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../../../color-scheme-provider/ColorSchemeProvider';\nimport { StyledUnicodeIcon } from '../../../icon/Icon.styles';\nimport { getIsExpandableIcon } from '../../../../utils/icon';\nimport Input from '../../../input/Input';\nimport { AreaContext } from '../../../area-provider/AreaContextProvider';\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 shouldAnimateLayout?: boolean;\n cornerElement?: ReactNode;\n onTitleWidthChange: (titleWidth: number, titleMaxWidth: number) => void;\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n titleInputProps?: InputProps;\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 shouldAnimateLayout = false,\n cornerElement,\n onTitleWidthChange,\n onImageError,\n onTitleInputChange,\n titleInputProps,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n const [titleMaxWidth, setTitleMaxWidth] = useState(0);\n const [titleWidth, setTitleWidth] = useState(0);\n\n const longPressTimeoutRef = useRef<number>();\n const resizeSkipRef = useRef(true);\n const leftElementRef = useRef<HTMLDivElement>(null);\n\n const theme = useTheme() as Theme;\n const areaProvider = useContext(AreaContext);\n\n const hasTitleInput = typeof onTitleInputChange === 'function';\n\n const shouldShowSubtitleRow =\n (!hasTitleInput && (subtitle || typeof subtitle === 'string')) ||\n (typeof rightElements === 'object' && rightElements && 'bottom' in rightElements);\n\n const shouldShowMultilineTitle = useMemo(\n () => !subtitle && !hasTitleInput,\n [hasTitleInput, subtitle],\n );\n\n useEffect(() => {\n window.setTimeout(() => {\n resizeSkipRef.current = false;\n }, 200);\n }, []);\n\n useEffect(() => {\n onTitleWidthChange(titleWidth, titleMaxWidth);\n }, [onTitleWidthChange, titleMaxWidth, titleWidth]);\n\n const handleShowTooltipResize = useCallback(\n (entries: ResizeObserverEntry[]) => {\n setTitleWidth(entries[0]?.target.clientWidth ?? 0);\n\n if (resizeSkipRef.current) {\n return;\n }\n\n const el = entries[0]?.target;\n if (!el) return;\n setShouldEnableTooltip(el.scrollWidth > el.clientWidth);\n },\n [setShouldEnableTooltip],\n );\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 handleTitleWidthChange = useCallback((width: number) => {\n setTitleMaxWidth(width);\n }, []);\n const shouldShowHoverItemContent = !!(shouldForceHover || shouldShowHoverItem);\n\n const handleInputClick = useCallback<MouseEventHandler<HTMLDivElement>>((event) => {\n event.stopPropagation();\n }, []);\n\n const iconOrImageElement = useMemo(() => {\n if (icons) {\n return (\n <ListItemIcon\n icons={icons}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundIcon={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n if (images) {\n return (\n <ListItemImage\n cornerElement={cornerElement}\n imageBackground={imageBackground}\n careOfLocationId={careOfLocationId}\n cornerImage={cornerImage}\n images={images}\n onImageError={onImageError}\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 onImageError,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n const expandIcon = useMemo(() => {\n const internalIcon = getIsExpandableIcon(theme.accordionIcon);\n const internalIconStyle = theme?.iconStyle ? theme.iconStyle : 'fa-regular';\n return <StyledUnicodeIcon $icon={internalIcon} className={internalIconStyle} />;\n }, [theme.accordionIcon, theme.iconStyle]);\n\n return (\n <StyledListItemHead\n as={shouldDisableAnimation ? undefined : motion.div}\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={shouldDisableAnimation ? undefined : motion.div}\n animate={shouldDisableAnimation ? undefined : { rotate: isOpen ? 90 : 0 }}\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && expandIcon}\n </StyledListItemHeadIndicator>\n )}\n {leftElements && (\n <StyledListItemHeadLeftElements ref={leftElementRef} data-left-element=\"true\">\n {leftElements}\n </StyledListItemHeadLeftElements>\n )}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $isOpen={isOpen}\n >\n <LayoutGroup>\n <StyledListItemHeadTitle\n as={shouldDisableAnimation ? undefined : motion.div}\n layout={shouldAnimateLayout ? 'position' : undefined}\n >\n {hasTitleInput ? (\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n <AreaContext.Provider\n value={{ ...areaProvider, shouldChangeColor: true }}\n >\n <StyledListItemHeadTitleInputWrapper onClick={handleInputClick}>\n <Input\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...titleInputProps}\n value={typeof title === 'string' ? title : undefined}\n onChange={onTitleInputChange}\n />\n </StyledListItemHeadTitleInputWrapper>\n </AreaContext.Provider>\n ) : (\n <ListItemTitle\n title={title}\n titleElement={titleElement}\n isOpen={isOpen}\n shouldShowMultilineTitle={shouldShowMultilineTitle}\n rightElements={rightElements}\n onTitleWidthChange={handleTitleWidthChange}\n onResize={handleShowTooltipResize}\n />\n )}\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <ListItemSubtitle\n subtitle={subtitle}\n isOpen={isOpen}\n rightElements={rightElements}\n />\n </StyledListItemHeadSubtitle>\n )}\n </LayoutGroup>\n </StyledListItemHeadContent>\n <ListItemRightElement rightElements={rightElements} />\n {hoverItem && shouldShowHoverItemContent && (\n <StyledMotionListItemHeadHoverItemWrapper\n className=\"beta-chayns-list-item-hover-item\"\n animate={{\n marginLeft: 8,\n opacity: 1,\n width: 'auto',\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;AAiBA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAYA,IAAAO,cAAA,GAAAH,sBAAA,CAAAJ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AmG,aAAA,CAAC9G,aAAA,CAAAgK,iCAAiC,QAC7B3H,SAC8B,CACG,CAE9B,CAAC;AAE7B,CAAC;AAEDH,YAAY,CAAC+H,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxJ,OAAA,GAE3BuB,YAAY","ignoreList":[]}
|
|
@@ -41,6 +41,7 @@ const ListItem = /*#__PURE__*/forwardRef(({
|
|
|
41
41
|
shouldOpenImageOnClick = false,
|
|
42
42
|
shouldHideImageOrIconBackground,
|
|
43
43
|
shouldHideIndicator = false,
|
|
44
|
+
shouldAnimateLayout = false,
|
|
44
45
|
shouldPreventLayoutAnimation = false,
|
|
45
46
|
shouldRenderClosed = false,
|
|
46
47
|
shouldShowRoundImageOrIcon,
|
|
@@ -222,7 +223,7 @@ const ListItem = /*#__PURE__*/forwardRef(({
|
|
|
222
223
|
key: `list-item-${uuid}`,
|
|
223
224
|
ref: listItemRef,
|
|
224
225
|
"data-uuid": `${listGroupUuid ?? ''}---${uuid}`,
|
|
225
|
-
layout: shouldPreventLayoutAnimation
|
|
226
|
+
layout: shouldAnimateLayout && !shouldPreventLayoutAnimation && !shouldDisableAnimation ? 'position' : undefined,
|
|
226
227
|
$backgroundColor: backgroundColor,
|
|
227
228
|
$isClickable: isClickable,
|
|
228
229
|
$isInAccordion: typeof isParentAccordionWrapped === 'boolean' && !areaProvider.shouldDisableListItemPadding,
|
|
@@ -279,6 +280,7 @@ const ListItem = /*#__PURE__*/forwardRef(({
|
|
|
279
280
|
titleElement: titleElement,
|
|
280
281
|
setShouldEnableTooltip: setShouldEnableTooltip,
|
|
281
282
|
shouldDisableAnimation: shouldDisableAnimation,
|
|
283
|
+
shouldAnimateLayout: shouldAnimateLayout && !shouldPreventLayoutAnimation && !shouldDisableAnimation,
|
|
282
284
|
onImageError: onImageError
|
|
283
285
|
})), /*#__PURE__*/React.createElement(AnimatePresence, {
|
|
284
286
|
initial: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["AnimatePresence","motion","React","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useMemo","useRef","useState","useTheme","useUuid","AccordionContext","AreaContextProvider","AreaContext","useColorScheme","ListContext","handleHorizontalArrowNavigation","handleListItemTabNavigation","handleListItemToggleKey","handleVerticalListGroupNavigation","ListItemBody","ListItemHead","StyledListItem","StyledListItemTooltip","Tooltip","useIsInsideDialog","useFocusRingPortal","useKeyboardFocusHighlighting","useListItemFocus","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","onImageError","onSizeChange","onTitleInputChange","titleElement","titleInputProps","shouldDisableAnimation","cornerElement","isSelected","shouldEnableKeyboardHighlighting","shouldEnableKeyboardHighlightingProp","ref","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","shouldEnableKeyboardHighlightingContext","listGroupUuid","listItemUuids","registerListItemUuid","unregisterListItemUuid","activeListItemUuid","updateActiveListItemUuid","colorScheme","theme","isInsideListContext","isParentAccordionWrapped","areaProvider","isInitialRenderRef","listItemRef","isInDialog","uuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","titleWidth","setTitleWidth","titleMaxWidth","setTitleMaxWidth","current","handleHeadClick","event","shouldOnlyOpen","isClickable","handleTitleWidthChange","width","maxWidth","shouldShowKeyboardHighlighting","isEnabled","borderRadius","cardBorderRadius","isInKeyboardNavigationGroup","tabIndex","handleKeyDown","isCurrentListItemTarget","currentTarget","target","currentListItemElement","targetElement","currentUuid","toggleItem","some","handleKey","isFocusWithinListItem","handleFocus","handleBlur","shouldForceHoverItem","createElement","as","div","animate","height","opacity","className","exit","initial","key","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$isInDialog","$isSelected","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","onKeyDown","onFocus","onBlur","shouldUseFullWidth","isDisabled","item","style","cursor","onTitleWidthChange","id","shouldHideBody","displayName"],"sources":["../../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence, motion } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport type { InputProps } from '../../input/Input';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { type Theme, useColorScheme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { ListContext } from '../List';\nimport {\n handleHorizontalArrowNavigation,\n handleListItemTabNavigation,\n handleListItemToggleKey,\n handleVerticalListGroupNavigation,\n} from '../List.utils';\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 { useIsInsideDialog } from '../../../hooks/element';\nimport { useFocusRingPortal } from '../../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../../hooks/useKeyboardFocusHighlighting';\nimport { useListItemFocus } from './useListItemFocus';\n\nexport type ListItemElements = [ReactNode, ...ReactNode[]];\n\nexport interface ListItemSize {\n titleWidth: number;\n titleMaxWidth: number;\n}\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 * Whether the item is selected.\n */\n isSelected?: 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 * 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 * Function to be executed if the size are changed.\n */\n onSizeChange?: (sizes: ListItemSize) => void;\n /**\n * Enables keyboard-only focus highlighting. Overrides the value from the List context.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n /**\n * Function that is executed when the text of the title input changes.\n * When this function is given, the title is displayed as an input.\n */\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * The props of the title input.\n */\n titleInputProps?: InputProps;\n};\n\nexport type ListItemRef = ListItemSize;\n\nconst ListItem = forwardRef<ListItemRef, ListItemProps>(\n (\n {\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 onImageError,\n onSizeChange,\n onTitleInputChange,\n titleElement,\n titleInputProps,\n shouldDisableAnimation = false,\n cornerElement,\n isSelected = false,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingProp,\n },\n ref,\n ) => {\n const {\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingContext,\n listGroupUuid,\n listItemUuids,\n registerListItemUuid,\n unregisterListItemUuid,\n activeListItemUuid,\n updateActiveListItemUuid,\n } = useContext(ListContext);\n const colorScheme = useColorScheme();\n const theme = useTheme() as Theme;\n const isInsideListContext = typeof listGroupUuid === 'string';\n\n const shouldEnableKeyboardHighlighting =\n shouldEnableKeyboardHighlightingProp ??\n (isInsideListContext\n ? shouldEnableKeyboardHighlightingContext\n : (colorScheme?.shouldEnableKeyboardHighlighting ?? false));\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 isInDialog = useIsInsideDialog<HTMLDivElement>(listItemRef);\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 const [titleWidth, setTitleWidth] = useState(0);\n const [titleMaxWidth, setTitleMaxWidth] = useState(0);\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 (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n const isClickable = typeof onClick === 'function' || isExpandable;\n\n useEffect(() => {\n if (typeof onSizeChange === 'function') {\n onSizeChange({\n titleWidth,\n titleMaxWidth,\n });\n }\n }, [onSizeChange, titleMaxWidth, titleWidth]);\n\n useImperativeHandle(\n ref,\n () => ({\n titleWidth,\n titleMaxWidth,\n }),\n [titleMaxWidth, titleWidth],\n );\n\n const handleTitleWidthChange = useCallback((width: number, maxWidth: number) => {\n setTitleWidth(width);\n setTitleMaxWidth(maxWidth);\n }, []);\n\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlighting,\n );\n useFocusRingPortal(listItemRef, {\n isEnabled: shouldShowKeyboardHighlighting,\n borderRadius: `${theme.cardBorderRadius}px`,\n });\n\n const isInKeyboardNavigationGroup =\n shouldEnableKeyboardHighlighting &&\n typeof listGroupUuid === 'string' &&\n typeof updateActiveListItemUuid === 'function';\n\n useEffect(() => {\n if (\n shouldEnableKeyboardHighlighting &&\n typeof registerListItemUuid === 'function' &&\n typeof unregisterListItemUuid === 'function'\n ) {\n registerListItemUuid(uuid);\n\n return () => {\n unregisterListItemUuid(uuid);\n };\n }\n\n return undefined;\n }, [shouldEnableKeyboardHighlighting, registerListItemUuid, unregisterListItemUuid, uuid]);\n\n const tabIndex = useMemo(\n () => (shouldEnableKeyboardHighlighting ? 0 : -1),\n [shouldEnableKeyboardHighlighting],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n const isCurrentListItemTarget = event.currentTarget === event.target;\n const currentListItemElement = event.currentTarget as HTMLDivElement;\n const targetElement = event.target as HTMLElement | null;\n\n [\n () =>\n shouldEnableKeyboardHighlighting &&\n handleHorizontalArrowNavigation({\n event,\n currentListItemElement,\n targetElement,\n isCurrentListItemTarget,\n }),\n () =>\n handleListItemTabNavigation({\n event,\n currentListItemElement,\n targetElement,\n isCurrentListItemTarget,\n isInKeyboardNavigationGroup,\n listItemUuids,\n currentUuid: uuid,\n listGroupUuid,\n updateActiveListItemUuid,\n }),\n () =>\n handleVerticalListGroupNavigation({\n event,\n isCurrentListItemTarget,\n isInKeyboardNavigationGroup,\n listItemUuids,\n currentUuid: uuid,\n listGroupUuid,\n updateActiveListItemUuid,\n }),\n () =>\n handleListItemToggleKey({\n event,\n isCurrentListItemTarget,\n isExpandable,\n isItemOpen,\n shouldEnableKeyboardHighlighting,\n toggleItem: () =>\n handleHeadClick(\n event as unknown as React.MouseEvent<HTMLDivElement>,\n ),\n }),\n ].some((handleKey) => handleKey());\n },\n [\n handleHeadClick,\n isExpandable,\n isInKeyboardNavigationGroup,\n isItemOpen,\n listGroupUuid,\n listItemUuids,\n shouldEnableKeyboardHighlighting,\n updateActiveListItemUuid,\n uuid,\n ],\n );\n\n const { isFocusWithinListItem, handleFocus, handleBlur } = useListItemFocus({\n uuid,\n listGroupUuid,\n isInKeyboardNavigationGroup,\n updateActiveListItemUuid,\n });\n const shouldForceHoverItem = shouldForceHover || isFocusWithinListItem;\n\n useEffect(() => {\n if (\n isInKeyboardNavigationGroup &&\n activeListItemUuid == null &&\n typeof updateActiveListItemUuid === 'function' &&\n listItemUuids?.[0] === uuid\n ) {\n updateActiveListItemUuid(uuid);\n }\n }, [\n activeListItemUuid,\n isInKeyboardNavigationGroup,\n listItemUuids,\n updateActiveListItemUuid,\n uuid,\n ]);\n\n return (\n <StyledListItem\n as={shouldDisableAnimation ? undefined : motion.div}\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 data-uuid={`${listGroupUuid ?? ''}---${uuid}`}\n layout={\n shouldPreventLayoutAnimation || shouldDisableAnimation ? undefined : 'position'\n }\n $backgroundColor={backgroundColor}\n $isClickable={isClickable}\n $isInAccordion={\n typeof isParentAccordionWrapped === 'boolean' &&\n !areaProvider.shouldDisableListItemPadding\n }\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n $isInDialog={isInDialog}\n $isSelected={isSelected}\n $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n data-should-show-keyboard-highlighting={\n shouldShowKeyboardHighlighting ? 'true' : undefined\n }\n tabIndex={tabIndex}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\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 <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={shouldForceHoverItem}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n onTitleInputChange={onTitleInputChange}\n onTitleWidthChange={handleTitleWidthChange}\n titleInputProps={titleInputProps}\n titleElement={titleElement}\n setShouldEnableTooltip={setShouldEnableTooltip}\n shouldDisableAnimation={shouldDisableAnimation}\n onImageError={onImageError}\n />\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);\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,MAAM,QAAQ,cAAc;AACtD,OAAOC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AnimatePresence","motion","React","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useMemo","useRef","useState","useTheme","useUuid","AccordionContext","AreaContextProvider","AreaContext","useColorScheme","ListContext","handleHorizontalArrowNavigation","handleListItemTabNavigation","handleListItemToggleKey","handleVerticalListGroupNavigation","ListItemBody","ListItemHead","StyledListItem","StyledListItemTooltip","Tooltip","useIsInsideDialog","useFocusRingPortal","useKeyboardFocusHighlighting","useListItemFocus","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","shouldAnimateLayout","shouldPreventLayoutAnimation","shouldRenderClosed","shouldShowRoundImageOrIcon","shouldShowSeparatorBelow","subtitle","title","onImageError","onSizeChange","onTitleInputChange","titleElement","titleInputProps","shouldDisableAnimation","cornerElement","isSelected","shouldEnableKeyboardHighlighting","shouldEnableKeyboardHighlightingProp","ref","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","shouldEnableKeyboardHighlightingContext","listGroupUuid","listItemUuids","registerListItemUuid","unregisterListItemUuid","activeListItemUuid","updateActiveListItemUuid","colorScheme","theme","isInsideListContext","isParentAccordionWrapped","areaProvider","isInitialRenderRef","listItemRef","isInDialog","uuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","titleWidth","setTitleWidth","titleMaxWidth","setTitleMaxWidth","current","handleHeadClick","event","shouldOnlyOpen","isClickable","handleTitleWidthChange","width","maxWidth","shouldShowKeyboardHighlighting","isEnabled","borderRadius","cardBorderRadius","isInKeyboardNavigationGroup","tabIndex","handleKeyDown","isCurrentListItemTarget","currentTarget","target","currentListItemElement","targetElement","currentUuid","toggleItem","some","handleKey","isFocusWithinListItem","handleFocus","handleBlur","shouldForceHoverItem","createElement","as","div","animate","height","opacity","className","exit","initial","key","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$isInDialog","$isSelected","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","onKeyDown","onFocus","onBlur","shouldUseFullWidth","isDisabled","item","style","cursor","onTitleWidthChange","id","shouldHideBody","displayName"],"sources":["../../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence, motion } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n forwardRef,\n KeyboardEvent,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport type { InputProps } from '../../input/Input';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { type Theme, useColorScheme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { ListContext } from '../List';\nimport {\n handleHorizontalArrowNavigation,\n handleListItemTabNavigation,\n handleListItemToggleKey,\n handleVerticalListGroupNavigation,\n} from '../List.utils';\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 { useIsInsideDialog } from '../../../hooks/element';\nimport { useFocusRingPortal } from '../../../hooks/useFocusRingPortal';\nimport { useKeyboardFocusHighlighting } from '../../../hooks/useKeyboardFocusHighlighting';\nimport { useListItemFocus } from './useListItemFocus';\n\nexport type ListItemElements = [ReactNode, ...ReactNode[]];\n\nexport interface ListItemSize {\n titleWidth: number;\n titleMaxWidth: number;\n}\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 * Whether the item is selected.\n */\n isSelected?: 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 framer-motion layout projection (`layout=\"position\"`) should be\n * enabled. This animates the `ListItem` smoothly into its new position when\n * sibling items are reordered, expanded or resized.\n *\n * This is opt-in and disabled by default, because framer-motions layout\n * projection is viewport-global: every layout change anywhere in the document\n * (window resize, height animation, ...) forces a re-measurement of **all**\n * layout-projection nodes via `getBoundingClientRect`. In lists with many\n * `ListItem`s this scales linearly and causes noticeable layout thrash. The\n * enter/exit height/opacity animation is unaffected and stays enabled.\n */\n shouldAnimateLayout?: 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 * @deprecated The layout projection is now disabled by default. Use\n * `shouldAnimateLayout` to opt into it instead. When set to `true`, this\n * prop keeps forcing the layout projection off.\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 * 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 * Function to be executed if the size are changed.\n */\n onSizeChange?: (sizes: ListItemSize) => void;\n /**\n * Enables keyboard-only focus highlighting. Overrides the value from the List context.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n /**\n * Function that is executed when the text of the title input changes.\n * When this function is given, the title is displayed as an input.\n */\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * The props of the title input.\n */\n titleInputProps?: InputProps;\n};\n\nexport type ListItemRef = ListItemSize;\n\nconst ListItem = forwardRef<ListItemRef, ListItemProps>(\n (\n {\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 shouldAnimateLayout = false,\n shouldPreventLayoutAnimation = false,\n shouldRenderClosed = false,\n shouldShowRoundImageOrIcon,\n shouldShowSeparatorBelow = false,\n subtitle,\n title,\n onImageError,\n onSizeChange,\n onTitleInputChange,\n titleElement,\n titleInputProps,\n shouldDisableAnimation = false,\n cornerElement,\n isSelected = false,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingProp,\n },\n ref,\n ) => {\n const {\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingContext,\n listGroupUuid,\n listItemUuids,\n registerListItemUuid,\n unregisterListItemUuid,\n activeListItemUuid,\n updateActiveListItemUuid,\n } = useContext(ListContext);\n const colorScheme = useColorScheme();\n const theme = useTheme() as Theme;\n const isInsideListContext = typeof listGroupUuid === 'string';\n\n const shouldEnableKeyboardHighlighting =\n shouldEnableKeyboardHighlightingProp ??\n (isInsideListContext\n ? shouldEnableKeyboardHighlightingContext\n : (colorScheme?.shouldEnableKeyboardHighlighting ?? false));\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 isInDialog = useIsInsideDialog<HTMLDivElement>(listItemRef);\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 const [titleWidth, setTitleWidth] = useState(0);\n const [titleMaxWidth, setTitleMaxWidth] = useState(0);\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 (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n const isClickable = typeof onClick === 'function' || isExpandable;\n\n useEffect(() => {\n if (typeof onSizeChange === 'function') {\n onSizeChange({\n titleWidth,\n titleMaxWidth,\n });\n }\n }, [onSizeChange, titleMaxWidth, titleWidth]);\n\n useImperativeHandle(\n ref,\n () => ({\n titleWidth,\n titleMaxWidth,\n }),\n [titleMaxWidth, titleWidth],\n );\n\n const handleTitleWidthChange = useCallback((width: number, maxWidth: number) => {\n setTitleWidth(width);\n setTitleMaxWidth(maxWidth);\n }, []);\n\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlighting,\n );\n useFocusRingPortal(listItemRef, {\n isEnabled: shouldShowKeyboardHighlighting,\n borderRadius: `${theme.cardBorderRadius}px`,\n });\n\n const isInKeyboardNavigationGroup =\n shouldEnableKeyboardHighlighting &&\n typeof listGroupUuid === 'string' &&\n typeof updateActiveListItemUuid === 'function';\n\n useEffect(() => {\n if (\n shouldEnableKeyboardHighlighting &&\n typeof registerListItemUuid === 'function' &&\n typeof unregisterListItemUuid === 'function'\n ) {\n registerListItemUuid(uuid);\n\n return () => {\n unregisterListItemUuid(uuid);\n };\n }\n\n return undefined;\n }, [shouldEnableKeyboardHighlighting, registerListItemUuid, unregisterListItemUuid, uuid]);\n\n const tabIndex = useMemo(\n () => (shouldEnableKeyboardHighlighting ? 0 : -1),\n [shouldEnableKeyboardHighlighting],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n const isCurrentListItemTarget = event.currentTarget === event.target;\n const currentListItemElement = event.currentTarget as HTMLDivElement;\n const targetElement = event.target as HTMLElement | null;\n\n [\n () =>\n shouldEnableKeyboardHighlighting &&\n handleHorizontalArrowNavigation({\n event,\n currentListItemElement,\n targetElement,\n isCurrentListItemTarget,\n }),\n () =>\n handleListItemTabNavigation({\n event,\n currentListItemElement,\n targetElement,\n isCurrentListItemTarget,\n isInKeyboardNavigationGroup,\n listItemUuids,\n currentUuid: uuid,\n listGroupUuid,\n updateActiveListItemUuid,\n }),\n () =>\n handleVerticalListGroupNavigation({\n event,\n isCurrentListItemTarget,\n isInKeyboardNavigationGroup,\n listItemUuids,\n currentUuid: uuid,\n listGroupUuid,\n updateActiveListItemUuid,\n }),\n () =>\n handleListItemToggleKey({\n event,\n isCurrentListItemTarget,\n isExpandable,\n isItemOpen,\n shouldEnableKeyboardHighlighting,\n toggleItem: () =>\n handleHeadClick(\n event as unknown as React.MouseEvent<HTMLDivElement>,\n ),\n }),\n ].some((handleKey) => handleKey());\n },\n [\n handleHeadClick,\n isExpandable,\n isInKeyboardNavigationGroup,\n isItemOpen,\n listGroupUuid,\n listItemUuids,\n shouldEnableKeyboardHighlighting,\n updateActiveListItemUuid,\n uuid,\n ],\n );\n\n const { isFocusWithinListItem, handleFocus, handleBlur } = useListItemFocus({\n uuid,\n listGroupUuid,\n isInKeyboardNavigationGroup,\n updateActiveListItemUuid,\n });\n const shouldForceHoverItem = shouldForceHover || isFocusWithinListItem;\n\n useEffect(() => {\n if (\n isInKeyboardNavigationGroup &&\n activeListItemUuid == null &&\n typeof updateActiveListItemUuid === 'function' &&\n listItemUuids?.[0] === uuid\n ) {\n updateActiveListItemUuid(uuid);\n }\n }, [\n activeListItemUuid,\n isInKeyboardNavigationGroup,\n listItemUuids,\n updateActiveListItemUuid,\n uuid,\n ]);\n\n return (\n <StyledListItem\n as={shouldDisableAnimation ? undefined : motion.div}\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 data-uuid={`${listGroupUuid ?? ''}---${uuid}`}\n layout={\n shouldAnimateLayout && !shouldPreventLayoutAnimation && !shouldDisableAnimation\n ? 'position'\n : undefined\n }\n $backgroundColor={backgroundColor}\n $isClickable={isClickable}\n $isInAccordion={\n typeof isParentAccordionWrapped === 'boolean' &&\n !areaProvider.shouldDisableListItemPadding\n }\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n $isInDialog={isInDialog}\n $isSelected={isSelected}\n $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n data-should-show-keyboard-highlighting={\n shouldShowKeyboardHighlighting ? 'true' : undefined\n }\n tabIndex={tabIndex}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\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 <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={shouldForceHoverItem}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n onTitleInputChange={onTitleInputChange}\n onTitleWidthChange={handleTitleWidthChange}\n titleInputProps={titleInputProps}\n titleElement={titleElement}\n setShouldEnableTooltip={setShouldEnableTooltip}\n shouldDisableAnimation={shouldDisableAnimation}\n shouldAnimateLayout={\n shouldAnimateLayout &&\n !shouldPreventLayoutAnimation &&\n !shouldDisableAnimation\n }\n onImageError={onImageError}\n />\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);\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,MAAM,QAAQ,cAAc;AACtD,OAAOC,KAAK,IAGRC,UAAU,EAMVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,OAAO,QAAQ,qBAAqB;AAG7C,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,mBAAmB,IAAIC,WAAW,QAAQ,yCAAyC;AAC1F,SAAqBC,cAAc,QAAQ,iDAAiD;AAC5F,SAASC,WAAW,QAAQ,SAAS;AACrC,SACIC,+BAA+B,EAC/BC,2BAA2B,EAC3BC,uBAAuB,EACvBC,iCAAiC,QAC9B,eAAe;AACtB,OAAOC,YAAY,MAAM,+BAA+B;AACxD,OAAOC,YAAY,MAAM,+BAA+B;AACxD,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,mBAAmB;AACzE,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,kBAAkB,QAAQ,mCAAmC;AACtE,SAASC,4BAA4B,QAAQ,6CAA6C;AAC1F,SAASC,gBAAgB,QAAQ,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AEA,sBAAuB;IAC/CZ,mBAAmB,EACfA,mBAAmB,IACnB,CAACC,4BAA4B,IAC7B,CAACW,sBACJ;IACDL,YAAY,EAAEA;EAAa,CAC9B,CACI,CAAC,eACV9D,KAAA,CAAAoI,aAAA,CAACtI,eAAe;IAAC8I,OAAO,EAAE;EAAM,GAC3B/C,YAAY,KAAKE,UAAU,IAAItC,kBAAkB,CAAC,iBAC/CzD,KAAA,CAAAoI,aAAA,CAAChH,YAAY;IACTmJ,EAAE,EAAE3E,IAAK;IACTiD,GAAG,EAAE,gBAAgBjD,IAAI,EAAG;IAC5B4E,cAAc,EAAE/G,kBAAkB,IAAI,CAACsC;EAAW,gBAElD/F,KAAA,CAAAoI,aAAA,CAACxH,mBAAmB,QAAEoB,QAA8B,CAC1C,CAEL,CACL,CAAC;AAEzB,CACJ,CAAC;AAEDH,QAAQ,CAAC4I,WAAW,GAAG,UAAU;AAEjC,eAAe5I,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
2
|
+
import { act, render } from '@testing-library/react';
|
|
3
|
+
import { motion } from 'motion/react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { ThemeProvider } from 'styled-components';
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
7
|
+
import List from '../List';
|
|
8
|
+
import ListItem from './ListItem';
|
|
9
|
+
vi.mock('@chayns/textstrings', () => ({
|
|
10
|
+
useTranslation: () => ({
|
|
11
|
+
t: textString => typeof textString === 'string' ? textString : textString.fallback
|
|
12
|
+
})
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Regression guard for the framer-motion layout-projection thrash.
|
|
17
|
+
*
|
|
18
|
+
* framer-motions layout projection (`layout` / `layout="position"`) is
|
|
19
|
+
* viewport-global: all layout-projection nodes share a single projection tree, so
|
|
20
|
+
* a layout change on *any* node forces a re-measurement of *all* nodes via
|
|
21
|
+
* `getBoundingClientRect`. With many `ListItem`s this scales linearly with N.
|
|
22
|
+
*
|
|
23
|
+
* The tests below render a projection node (`motion.div layout`) *outside* the
|
|
24
|
+
* list and change its layout. They then count how many `getBoundingClientRect`
|
|
25
|
+
* calls hit the rendered `ListItem` elements:
|
|
26
|
+
* - default (no `shouldAnimateLayout`): the items are not projection nodes, so
|
|
27
|
+
* the external change does not re-measure them (reads === 0).
|
|
28
|
+
* - `shouldAnimateLayout`: the items join the shared projection tree, so they are
|
|
29
|
+
* re-measured by the unrelated external change (reads > 0).
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
const ITEM_COUNT = 20;
|
|
33
|
+
let boundingRectCalls;
|
|
34
|
+
let originalGetBoundingClientRect;
|
|
35
|
+
const isInsideList = element => Boolean(element.closest('.beta-chayns-list-item'));
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
boundingRectCalls = 0;
|
|
38
|
+
originalGetBoundingClientRect = Element.prototype.getBoundingClientRect;
|
|
39
|
+
Element.prototype.getBoundingClientRect = function getBoundingClientRect() {
|
|
40
|
+
if (isInsideList(this)) {
|
|
41
|
+
boundingRectCalls += 1;
|
|
42
|
+
}
|
|
43
|
+
return originalGetBoundingClientRect.apply(this);
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
Element.prototype.getBoundingClientRect = originalGetBoundingClientRect;
|
|
48
|
+
});
|
|
49
|
+
const theme = {
|
|
50
|
+
'100-rgb': '255, 255, 255',
|
|
51
|
+
'102-rgb': '255, 255, 255',
|
|
52
|
+
'headline-rgb': '0, 0, 0',
|
|
53
|
+
cardBackgroundOpacity: 1,
|
|
54
|
+
accordionLines: true,
|
|
55
|
+
accordionIcon: 'fa-chevron-right',
|
|
56
|
+
iconStyle: 'fa-regular'
|
|
57
|
+
};
|
|
58
|
+
const Harness = ({
|
|
59
|
+
shouldAnimateLayout,
|
|
60
|
+
isExternalExpanded
|
|
61
|
+
}) => /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
62
|
+
theme: theme
|
|
63
|
+
}, /*#__PURE__*/React.createElement(motion.div, {
|
|
64
|
+
layout: true,
|
|
65
|
+
"data-testid": "outside",
|
|
66
|
+
style: {
|
|
67
|
+
height: isExternalExpanded ? 500 : 100
|
|
68
|
+
}
|
|
69
|
+
}), /*#__PURE__*/React.createElement(List, null, Array.from({
|
|
70
|
+
length: ITEM_COUNT
|
|
71
|
+
}, (_, index) => /*#__PURE__*/React.createElement(ListItem, {
|
|
72
|
+
key: index,
|
|
73
|
+
title: `Item ${index}`,
|
|
74
|
+
shouldAnimateLayout: shouldAnimateLayout
|
|
75
|
+
}))));
|
|
76
|
+
const flushFrames = async () => {
|
|
77
|
+
await act(async () => {
|
|
78
|
+
await new Promise(resolve => {
|
|
79
|
+
requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined)));
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Render the list, then trigger a layout change on the external projection node
|
|
86
|
+
* and return the number of `getBoundingClientRect` calls that hit the list items.
|
|
87
|
+
*/
|
|
88
|
+
const measureExternalLayoutChange = async shouldAnimateLayout => {
|
|
89
|
+
const {
|
|
90
|
+
rerender
|
|
91
|
+
} = render(/*#__PURE__*/React.createElement(Harness, {
|
|
92
|
+
shouldAnimateLayout: shouldAnimateLayout,
|
|
93
|
+
isExternalExpanded: false
|
|
94
|
+
}));
|
|
95
|
+
await flushFrames();
|
|
96
|
+
boundingRectCalls = 0;
|
|
97
|
+
rerender(/*#__PURE__*/React.createElement(Harness, {
|
|
98
|
+
shouldAnimateLayout: shouldAnimateLayout,
|
|
99
|
+
isExternalExpanded: true
|
|
100
|
+
}));
|
|
101
|
+
await flushFrames();
|
|
102
|
+
return boundingRectCalls;
|
|
103
|
+
};
|
|
104
|
+
describe('ListItem layout projection', () => {
|
|
105
|
+
it('does not re-measure items on external layout changes by default', async () => {
|
|
106
|
+
const reads = await measureExternalLayoutChange(false);
|
|
107
|
+
expect(reads).toBe(0);
|
|
108
|
+
});
|
|
109
|
+
it('re-measures items on external layout changes when shouldAnimateLayout is set', async () => {
|
|
110
|
+
const reads = await measureExternalLayoutChange(true);
|
|
111
|
+
expect(reads).toBeGreaterThan(0);
|
|
112
|
+
});
|
|
113
|
+
it('keeps the enter/exit animation for added/removed items without layout projection', async () => {
|
|
114
|
+
const renderItems = titles => /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
115
|
+
theme: theme
|
|
116
|
+
}, /*#__PURE__*/React.createElement(List, null, titles.map(title => /*#__PURE__*/React.createElement(ListItem, {
|
|
117
|
+
key: title,
|
|
118
|
+
title: title
|
|
119
|
+
}))));
|
|
120
|
+
const {
|
|
121
|
+
rerender,
|
|
122
|
+
queryByText
|
|
123
|
+
} = render(renderItems(['A', 'B', 'C']));
|
|
124
|
+
await flushFrames();
|
|
125
|
+
|
|
126
|
+
// Remove the first item. AnimatePresence must keep it mounted while its
|
|
127
|
+
// exit (height/opacity) animation runs -- this is independent of the
|
|
128
|
+
// (disabled) layout projection.
|
|
129
|
+
rerender(renderItems(['B', 'C']));
|
|
130
|
+
expect(queryByText('A')).not.toBeNull();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=ListItem.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListItem.test.js","names":["act","render","motion","React","ThemeProvider","afterEach","beforeEach","describe","expect","it","vi","List","ListItem","mock","useTranslation","t","textString","fallback","ITEM_COUNT","boundingRectCalls","originalGetBoundingClientRect","isInsideList","element","Boolean","closest","Element","prototype","getBoundingClientRect","apply","theme","cardBackgroundOpacity","accordionLines","accordionIcon","iconStyle","Harness","shouldAnimateLayout","isExternalExpanded","createElement","div","layout","style","height","Array","from","length","_","index","key","title","flushFrames","Promise","resolve","requestAnimationFrame","undefined","measureExternalLayoutChange","rerender","reads","toBe","toBeGreaterThan","renderItems","titles","map","queryByText","not","toBeNull"],"sources":["../../../../../src/components/list/list-item/ListItem.test.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { act, render } from '@testing-library/react';\nimport { motion } from 'motion/react';\nimport React from 'react';\nimport { ThemeProvider } from 'styled-components';\nimport { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';\nimport type { Theme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport List from '../List';\nimport ListItem from './ListItem';\n\nvi.mock('@chayns/textstrings', () => ({\n useTranslation: () => ({\n t: (textString: { fallback?: string } | string) =>\n typeof textString === 'string' ? textString : textString.fallback,\n }),\n}));\n\n/**\n * Regression guard for the framer-motion layout-projection thrash.\n *\n * framer-motions layout projection (`layout` / `layout=\"position\"`) is\n * viewport-global: all layout-projection nodes share a single projection tree, so\n * a layout change on *any* node forces a re-measurement of *all* nodes via\n * `getBoundingClientRect`. With many `ListItem`s this scales linearly with N.\n *\n * The tests below render a projection node (`motion.div layout`) *outside* the\n * list and change its layout. They then count how many `getBoundingClientRect`\n * calls hit the rendered `ListItem` elements:\n * - default (no `shouldAnimateLayout`): the items are not projection nodes, so\n * the external change does not re-measure them (reads === 0).\n * - `shouldAnimateLayout`: the items join the shared projection tree, so they are\n * re-measured by the unrelated external change (reads > 0).\n */\n\nconst ITEM_COUNT = 20;\n\nlet boundingRectCalls: number;\nlet originalGetBoundingClientRect: typeof Element.prototype.getBoundingClientRect;\n\nconst isInsideList = (element: Element) => Boolean(element.closest('.beta-chayns-list-item'));\n\nbeforeEach(() => {\n boundingRectCalls = 0;\n originalGetBoundingClientRect = Element.prototype.getBoundingClientRect;\n\n Element.prototype.getBoundingClientRect = function getBoundingClientRect(\n this: Element,\n ): DOMRect {\n if (isInsideList(this)) {\n boundingRectCalls += 1;\n }\n\n return originalGetBoundingClientRect.apply(this) as DOMRect;\n };\n});\n\nafterEach(() => {\n Element.prototype.getBoundingClientRect = originalGetBoundingClientRect;\n});\n\nconst theme = {\n '100-rgb': '255, 255, 255',\n '102-rgb': '255, 255, 255',\n 'headline-rgb': '0, 0, 0',\n cardBackgroundOpacity: 1,\n accordionLines: true,\n accordionIcon: 'fa-chevron-right',\n iconStyle: 'fa-regular',\n} as unknown as Theme;\n\ntype HarnessProps = {\n shouldAnimateLayout: boolean;\n isExternalExpanded: boolean;\n};\n\nconst Harness = ({ shouldAnimateLayout, isExternalExpanded }: HarnessProps) => (\n <ThemeProvider theme={theme}>\n {/* A layout-projection node completely outside of the list. */}\n <motion.div\n layout\n data-testid=\"outside\"\n style={{ height: isExternalExpanded ? 500 : 100 }}\n />\n <List>\n {Array.from({ length: ITEM_COUNT }, (_, index) => (\n <ListItem\n key={index}\n title={`Item ${index}`}\n shouldAnimateLayout={shouldAnimateLayout}\n />\n ))}\n </List>\n </ThemeProvider>\n);\n\nconst flushFrames = async () => {\n await act(async () => {\n await new Promise((resolve) => {\n requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined)));\n });\n });\n};\n\n/**\n * Render the list, then trigger a layout change on the external projection node\n * and return the number of `getBoundingClientRect` calls that hit the list items.\n */\nconst measureExternalLayoutChange = async (shouldAnimateLayout: boolean) => {\n const { rerender } = render(\n <Harness shouldAnimateLayout={shouldAnimateLayout} isExternalExpanded={false} />,\n );\n\n await flushFrames();\n\n boundingRectCalls = 0;\n\n rerender(<Harness shouldAnimateLayout={shouldAnimateLayout} isExternalExpanded />);\n\n await flushFrames();\n\n return boundingRectCalls;\n};\n\ndescribe('ListItem layout projection', () => {\n it('does not re-measure items on external layout changes by default', async () => {\n const reads = await measureExternalLayoutChange(false);\n\n expect(reads).toBe(0);\n });\n\n it('re-measures items on external layout changes when shouldAnimateLayout is set', async () => {\n const reads = await measureExternalLayoutChange(true);\n\n expect(reads).toBeGreaterThan(0);\n });\n\n it('keeps the enter/exit animation for added/removed items without layout projection', async () => {\n const renderItems = (titles: string[]) => (\n <ThemeProvider theme={theme}>\n <List>\n {titles.map((title) => (\n <ListItem key={title} title={title} />\n ))}\n </List>\n </ThemeProvider>\n );\n\n const { rerender, queryByText } = render(renderItems(['A', 'B', 'C']));\n\n await flushFrames();\n\n // Remove the first item. AnimatePresence must keep it mounted while its\n // exit (height/opacity) animation runs -- this is independent of the\n // (disabled) layout projection.\n rerender(renderItems(['B', 'C']));\n\n expect(queryByText('A')).not.toBeNull();\n });\n});\n"],"mappings":"AAAA;AACA,SAASA,GAAG,EAAEC,MAAM,QAAQ,wBAAwB;AACpD,SAASC,MAAM,QAAQ,cAAc;AACrC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAExE,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,QAAQ,MAAM,YAAY;AAEjCF,EAAE,CAACG,IAAI,CAAC,qBAAqB,EAAE,OAAO;EAClCC,cAAc,EAAEA,CAAA,MAAO;IACnBC,CAAC,EAAGC,UAA0C,IAC1C,OAAOA,UAAU,KAAK,QAAQ,GAAGA,UAAU,GAAGA,UAAU,CAACC;EACjE,CAAC;AACL,CAAC,CAAC,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,UAAU,GAAG,EAAE;AAErB,IAAIC,iBAAyB;AAC7B,IAAIC,6BAA6E;AAEjF,MAAMC,YAAY,GAAIC,OAAgB,IAAKC,OAAO,CAACD,OAAO,CAACE,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAE7FlB,UAAU,CAAC,MAAM;EACba,iBAAiB,GAAG,CAAC;EACrBC,6BAA6B,GAAGK,OAAO,CAACC,SAAS,CAACC,qBAAqB;EAEvEF,OAAO,CAACC,SAAS,CAACC,qBAAqB,GAAG,SAASA,qBAAqBA,CAAA,EAE7D;IACP,IAAIN,YAAY,CAAC,IAAI,CAAC,EAAE;MACp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AAQ;MAACmC,GAAG,EAAEC,KAAM;MAACA,KAAK,EAAEA;IAAM,CAAE,CACxC,CACC,CACK,CAClB;IAED,MAAM;MAAEO,QAAQ;MAAEO;IAAY,CAAC,GAAG7D,MAAM,CAAC0D,WAAW,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAEtE,MAAMV,WAAW,CAAC,CAAC;;IAEnB;IACA;IACA;IACAM,QAAQ,CAACI,WAAW,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjCnD,MAAM,CAACsD,WAAW,CAAC,GAAG,CAAC,CAAC,CAACC,GAAG,CAACC,QAAQ,CAAC,CAAC;EAC3C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -37,6 +37,7 @@ const ListItemHead = ({
|
|
|
37
37
|
titleElement,
|
|
38
38
|
setShouldEnableTooltip,
|
|
39
39
|
shouldDisableAnimation = false,
|
|
40
|
+
shouldAnimateLayout = false,
|
|
40
41
|
cornerElement,
|
|
41
42
|
onTitleWidthChange,
|
|
42
43
|
onImageError,
|
|
@@ -156,7 +157,7 @@ const ListItemHead = ({
|
|
|
156
157
|
$isOpen: isOpen
|
|
157
158
|
}, /*#__PURE__*/React.createElement(LayoutGroup, null, /*#__PURE__*/React.createElement(StyledListItemHeadTitle, {
|
|
158
159
|
as: shouldDisableAnimation ? undefined : motion.div,
|
|
159
|
-
layout:
|
|
160
|
+
layout: shouldAnimateLayout ? 'position' : undefined
|
|
160
161
|
}, hasTitleInput ?
|
|
161
162
|
/*#__PURE__*/
|
|
162
163
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemHead.js","names":["LayoutGroup","motion","React","useCallback","useContext","useEffect","useMemo","useRef","useState","ListItemIcon","ListItemImage","StyledListItemHead","StyledListItemHeadContent","StyledListItemHeadIndicator","StyledListItemHeadLeftElements","StyledListItemHeadLeftWrapper","StyledListItemHeadSubtitle","StyledListItemHeadTitle","StyledListItemHeadTitleInputWrapper","StyledMotionListItemHeadHoverItem","StyledMotionListItemHeadHoverItemWrapper","ListItemTitle","ListItemSubtitle","ListItemRightElement","useTheme","StyledUnicodeIcon","getIsExpandableIcon","Input","AreaContext","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","onTitleWidthChange","onImageError","onTitleInputChange","titleInputProps","shouldShowHoverItem","setShouldShowHoverItem","titleMaxWidth","setTitleMaxWidth","titleWidth","setTitleWidth","longPressTimeoutRef","resizeSkipRef","leftElementRef","theme","areaProvider","hasTitleInput","shouldShowSubtitleRow","shouldShowMultilineTitle","window","setTimeout","current","handleShowTooltipResize","entries","target","clientWidth","el","scrollWidth","handleMouseEnter","handleMouseLeave","handleTouchStart","event","handleTouchEnd","clearTimeout","handleTitleWidthChange","width","shouldShowHoverItemContent","handleInputClick","stopPropagation","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","undefined","expandIcon","internalIcon","accordionIcon","internalIconStyle","iconStyle","$icon","className","as","div","animate","opacity","initial","transition","duration","type","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rotate","ref","$isIconOrImageGiven","$isOpen","layout","Provider","value","shouldChangeColor","_extends","onChange","onResize","marginLeft","displayName"],"sources":["../../../../../../src/components/list/list-item/list-item-head/ListItemHead.tsx"],"sourcesContent":["import { LayoutGroup, motion } from 'motion/react';\nimport React, {\n ChangeEventHandler,\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 type { IListItemRightElements } from '../../../../types/list';\nimport type { InputProps } from '../../../input/Input';\nimport ListItemIcon from './list-item-icon/ListItemIcon';\nimport ListItemImage from './list-item-image/ListItemImage';\nimport {\n StyledListItemHead,\n StyledListItemHeadContent,\n StyledListItemHeadIndicator,\n StyledListItemHeadLeftElements,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadTitle,\n StyledListItemHeadTitleInputWrapper,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadHoverItemWrapper,\n} from './ListItemHead.styles';\nimport ListItemTitle from './list-item-title/ListItemTitle';\nimport ListItemSubtitle from './list-item-subtitle/ListItemSubtitle';\nimport ListItemRightElement from './list-item-right-element/ListItemRightElement';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../../../color-scheme-provider/ColorSchemeProvider';\nimport { StyledUnicodeIcon } from '../../../icon/Icon.styles';\nimport { getIsExpandableIcon } from '../../../../utils/icon';\nimport Input from '../../../input/Input';\nimport { AreaContext } from '../../../area-provider/AreaContextProvider';\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 onTitleWidthChange: (titleWidth: number, titleMaxWidth: number) => void;\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n titleInputProps?: InputProps;\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 onTitleWidthChange,\n onImageError,\n onTitleInputChange,\n titleInputProps,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n const [titleMaxWidth, setTitleMaxWidth] = useState(0);\n const [titleWidth, setTitleWidth] = useState(0);\n\n const longPressTimeoutRef = useRef<number>();\n const resizeSkipRef = useRef(true);\n const leftElementRef = useRef<HTMLDivElement>(null);\n\n const theme = useTheme() as Theme;\n const areaProvider = useContext(AreaContext);\n\n const hasTitleInput = typeof onTitleInputChange === 'function';\n\n const shouldShowSubtitleRow =\n (!hasTitleInput && (subtitle || typeof subtitle === 'string')) ||\n (typeof rightElements === 'object' && rightElements && 'bottom' in rightElements);\n\n const shouldShowMultilineTitle = useMemo(\n () => !subtitle && !hasTitleInput,\n [hasTitleInput, subtitle],\n );\n\n useEffect(() => {\n window.setTimeout(() => {\n resizeSkipRef.current = false;\n }, 200);\n }, []);\n\n useEffect(() => {\n onTitleWidthChange(titleWidth, titleMaxWidth);\n }, [onTitleWidthChange, titleMaxWidth, titleWidth]);\n\n const handleShowTooltipResize = useCallback(\n (entries: ResizeObserverEntry[]) => {\n setTitleWidth(entries[0]?.target.clientWidth ?? 0);\n\n if (resizeSkipRef.current) {\n return;\n }\n\n const el = entries[0]?.target;\n if (!el) return;\n setShouldEnableTooltip(el.scrollWidth > el.clientWidth);\n },\n [setShouldEnableTooltip],\n );\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 handleTitleWidthChange = useCallback((width: number) => {\n setTitleMaxWidth(width);\n }, []);\n const shouldShowHoverItemContent = !!(shouldForceHover || shouldShowHoverItem);\n\n const handleInputClick = useCallback<MouseEventHandler<HTMLDivElement>>((event) => {\n event.stopPropagation();\n }, []);\n\n const iconOrImageElement = useMemo(() => {\n if (icons) {\n return (\n <ListItemIcon\n icons={icons}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundIcon={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n if (images) {\n return (\n <ListItemImage\n cornerElement={cornerElement}\n imageBackground={imageBackground}\n careOfLocationId={careOfLocationId}\n cornerImage={cornerImage}\n images={images}\n onImageError={onImageError}\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 onImageError,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n const expandIcon = useMemo(() => {\n const internalIcon = getIsExpandableIcon(theme.accordionIcon);\n const internalIconStyle = theme?.iconStyle ? theme.iconStyle : 'fa-regular';\n return <StyledUnicodeIcon $icon={internalIcon} className={internalIconStyle} />;\n }, [theme.accordionIcon, theme.iconStyle]);\n\n return (\n <StyledListItemHead\n as={shouldDisableAnimation ? undefined : motion.div}\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={shouldDisableAnimation ? undefined : motion.div}\n animate={shouldDisableAnimation ? undefined : { rotate: isOpen ? 90 : 0 }}\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && expandIcon}\n </StyledListItemHeadIndicator>\n )}\n {leftElements && (\n <StyledListItemHeadLeftElements ref={leftElementRef} data-left-element=\"true\">\n {leftElements}\n </StyledListItemHeadLeftElements>\n )}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $isOpen={isOpen}\n >\n <LayoutGroup>\n <StyledListItemHeadTitle\n as={shouldDisableAnimation ? undefined : motion.div}\n layout=\"position\"\n >\n {hasTitleInput ? (\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n <AreaContext.Provider\n value={{ ...areaProvider, shouldChangeColor: true }}\n >\n <StyledListItemHeadTitleInputWrapper onClick={handleInputClick}>\n <Input\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...titleInputProps}\n value={typeof title === 'string' ? title : undefined}\n onChange={onTitleInputChange}\n />\n </StyledListItemHeadTitleInputWrapper>\n </AreaContext.Provider>\n ) : (\n <ListItemTitle\n title={title}\n titleElement={titleElement}\n isOpen={isOpen}\n shouldShowMultilineTitle={shouldShowMultilineTitle}\n rightElements={rightElements}\n onTitleWidthChange={handleTitleWidthChange}\n onResize={handleShowTooltipResize}\n />\n )}\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <ListItemSubtitle\n subtitle={subtitle}\n isOpen={isOpen}\n rightElements={rightElements}\n />\n </StyledListItemHeadSubtitle>\n )}\n </LayoutGroup>\n </StyledListItemHeadContent>\n <ListItemRightElement rightElements={rightElements} />\n {hoverItem && shouldShowHoverItemContent && (\n <StyledMotionListItemHeadHoverItemWrapper\n className=\"beta-chayns-list-item-hover-item\"\n animate={{\n marginLeft: 8,\n opacity: 1,\n width: 'auto',\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,IAQRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AAGd,OAAOC,YAAY,MAAM,+BAA+B;AACxD,OAAOC,aAAa,MAAM,iCAAiC;AAC3D,SACIC,kBAAkB,EAClBC,yBAAyB,EACzBC,2BAA2B,EAC3BC,8BAA8B,EAC9BC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,uBAAuB,EACvBC,mCAAmC,EACnCC,iCAAiC,EACjCC,wCAAwC,QACrC,uBAAuB;AAC9B,OAAOC,aAAa,MAAM,iCAAiC;AAC3D,OAAOC,gBAAgB,MAAM,uCAAuC;AACpE,OAAOC,oBAAoB,MAAM,gDA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;EAAE,gBAE9C/G,KAAA,CAAA4F,aAAA,CAAC3E,iCAAiC,QAC7Ba,SAC8B,CACG,CAE9B,CAAC;AAE7B,CAAC;AAEDH,YAAY,CAACuG,WAAW,GAAG,cAAc;AAEzC,eAAevG,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItemHead.js","names":["LayoutGroup","motion","React","useCallback","useContext","useEffect","useMemo","useRef","useState","ListItemIcon","ListItemImage","StyledListItemHead","StyledListItemHeadContent","StyledListItemHeadIndicator","StyledListItemHeadLeftElements","StyledListItemHeadLeftWrapper","StyledListItemHeadSubtitle","StyledListItemHeadTitle","StyledListItemHeadTitleInputWrapper","StyledMotionListItemHeadHoverItem","StyledMotionListItemHeadHoverItemWrapper","ListItemTitle","ListItemSubtitle","ListItemRightElement","useTheme","StyledUnicodeIcon","getIsExpandableIcon","Input","AreaContext","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","shouldAnimateLayout","cornerElement","onTitleWidthChange","onImageError","onTitleInputChange","titleInputProps","shouldShowHoverItem","setShouldShowHoverItem","titleMaxWidth","setTitleMaxWidth","titleWidth","setTitleWidth","longPressTimeoutRef","resizeSkipRef","leftElementRef","theme","areaProvider","hasTitleInput","shouldShowSubtitleRow","shouldShowMultilineTitle","window","setTimeout","current","handleShowTooltipResize","entries","target","clientWidth","el","scrollWidth","handleMouseEnter","handleMouseLeave","handleTouchStart","event","handleTouchEnd","clearTimeout","handleTitleWidthChange","width","shouldShowHoverItemContent","handleInputClick","stopPropagation","iconOrImageElement","createElement","shouldHideBackground","shouldShowRoundIcon","shouldShowRoundImage","undefined","expandIcon","internalIcon","accordionIcon","internalIconStyle","iconStyle","$icon","className","as","div","animate","opacity","initial","transition","duration","type","$isClickable","$isAnyItemExpandable","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rotate","ref","$isIconOrImageGiven","$isOpen","layout","Provider","value","shouldChangeColor","_extends","onChange","onResize","marginLeft","displayName"],"sources":["../../../../../../src/components/list/list-item/list-item-head/ListItemHead.tsx"],"sourcesContent":["import { LayoutGroup, motion } from 'motion/react';\nimport React, {\n ChangeEventHandler,\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 type { IListItemRightElements } from '../../../../types/list';\nimport type { InputProps } from '../../../input/Input';\nimport ListItemIcon from './list-item-icon/ListItemIcon';\nimport ListItemImage from './list-item-image/ListItemImage';\nimport {\n StyledListItemHead,\n StyledListItemHeadContent,\n StyledListItemHeadIndicator,\n StyledListItemHeadLeftElements,\n StyledListItemHeadLeftWrapper,\n StyledListItemHeadSubtitle,\n StyledListItemHeadTitle,\n StyledListItemHeadTitleInputWrapper,\n StyledMotionListItemHeadHoverItem,\n StyledMotionListItemHeadHoverItemWrapper,\n} from './ListItemHead.styles';\nimport ListItemTitle from './list-item-title/ListItemTitle';\nimport ListItemSubtitle from './list-item-subtitle/ListItemSubtitle';\nimport ListItemRightElement from './list-item-right-element/ListItemRightElement';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../../../color-scheme-provider/ColorSchemeProvider';\nimport { StyledUnicodeIcon } from '../../../icon/Icon.styles';\nimport { getIsExpandableIcon } from '../../../../utils/icon';\nimport Input from '../../../input/Input';\nimport { AreaContext } from '../../../area-provider/AreaContextProvider';\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 shouldAnimateLayout?: boolean;\n cornerElement?: ReactNode;\n onTitleWidthChange: (titleWidth: number, titleMaxWidth: number) => void;\n onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;\n onTitleInputChange?: ChangeEventHandler<HTMLInputElement>;\n titleInputProps?: InputProps;\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 shouldAnimateLayout = false,\n cornerElement,\n onTitleWidthChange,\n onImageError,\n onTitleInputChange,\n titleInputProps,\n}) => {\n const [shouldShowHoverItem, setShouldShowHoverItem] = useState(false);\n const [titleMaxWidth, setTitleMaxWidth] = useState(0);\n const [titleWidth, setTitleWidth] = useState(0);\n\n const longPressTimeoutRef = useRef<number>();\n const resizeSkipRef = useRef(true);\n const leftElementRef = useRef<HTMLDivElement>(null);\n\n const theme = useTheme() as Theme;\n const areaProvider = useContext(AreaContext);\n\n const hasTitleInput = typeof onTitleInputChange === 'function';\n\n const shouldShowSubtitleRow =\n (!hasTitleInput && (subtitle || typeof subtitle === 'string')) ||\n (typeof rightElements === 'object' && rightElements && 'bottom' in rightElements);\n\n const shouldShowMultilineTitle = useMemo(\n () => !subtitle && !hasTitleInput,\n [hasTitleInput, subtitle],\n );\n\n useEffect(() => {\n window.setTimeout(() => {\n resizeSkipRef.current = false;\n }, 200);\n }, []);\n\n useEffect(() => {\n onTitleWidthChange(titleWidth, titleMaxWidth);\n }, [onTitleWidthChange, titleMaxWidth, titleWidth]);\n\n const handleShowTooltipResize = useCallback(\n (entries: ResizeObserverEntry[]) => {\n setTitleWidth(entries[0]?.target.clientWidth ?? 0);\n\n if (resizeSkipRef.current) {\n return;\n }\n\n const el = entries[0]?.target;\n if (!el) return;\n setShouldEnableTooltip(el.scrollWidth > el.clientWidth);\n },\n [setShouldEnableTooltip],\n );\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 handleTitleWidthChange = useCallback((width: number) => {\n setTitleMaxWidth(width);\n }, []);\n const shouldShowHoverItemContent = !!(shouldForceHover || shouldShowHoverItem);\n\n const handleInputClick = useCallback<MouseEventHandler<HTMLDivElement>>((event) => {\n event.stopPropagation();\n }, []);\n\n const iconOrImageElement = useMemo(() => {\n if (icons) {\n return (\n <ListItemIcon\n icons={icons}\n shouldHideBackground={!!shouldHideImageOrIconBackground}\n shouldShowRoundIcon={!!shouldShowRoundImageOrIcon}\n />\n );\n }\n\n if (images) {\n return (\n <ListItemImage\n cornerElement={cornerElement}\n imageBackground={imageBackground}\n careOfLocationId={careOfLocationId}\n cornerImage={cornerImage}\n images={images}\n onImageError={onImageError}\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 onImageError,\n shouldHideImageOrIconBackground,\n shouldOpenImageOnClick,\n shouldShowRoundImageOrIcon,\n ]);\n\n const expandIcon = useMemo(() => {\n const internalIcon = getIsExpandableIcon(theme.accordionIcon);\n const internalIconStyle = theme?.iconStyle ? theme.iconStyle : 'fa-regular';\n return <StyledUnicodeIcon $icon={internalIcon} className={internalIconStyle} />;\n }, [theme.accordionIcon, theme.iconStyle]);\n\n return (\n <StyledListItemHead\n as={shouldDisableAnimation ? undefined : motion.div}\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={shouldDisableAnimation ? undefined : motion.div}\n animate={shouldDisableAnimation ? undefined : { rotate: isOpen ? 90 : 0 }}\n initial={shouldDisableAnimation ? undefined : false}\n transition={shouldDisableAnimation ? undefined : { type: 'tween' }}\n >\n {isExpandable && !shouldHideIndicator && expandIcon}\n </StyledListItemHeadIndicator>\n )}\n {leftElements && (\n <StyledListItemHeadLeftElements ref={leftElementRef} data-left-element=\"true\">\n {leftElements}\n </StyledListItemHeadLeftElements>\n )}\n {iconOrImageElement}\n </StyledListItemHeadLeftWrapper>\n <StyledListItemHeadContent\n $isIconOrImageGiven={iconOrImageElement !== undefined}\n $isOpen={isOpen}\n >\n <LayoutGroup>\n <StyledListItemHeadTitle\n as={shouldDisableAnimation ? undefined : motion.div}\n layout={shouldAnimateLayout ? 'position' : undefined}\n >\n {hasTitleInput ? (\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n <AreaContext.Provider\n value={{ ...areaProvider, shouldChangeColor: true }}\n >\n <StyledListItemHeadTitleInputWrapper onClick={handleInputClick}>\n <Input\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...titleInputProps}\n value={typeof title === 'string' ? title : undefined}\n onChange={onTitleInputChange}\n />\n </StyledListItemHeadTitleInputWrapper>\n </AreaContext.Provider>\n ) : (\n <ListItemTitle\n title={title}\n titleElement={titleElement}\n isOpen={isOpen}\n shouldShowMultilineTitle={shouldShowMultilineTitle}\n rightElements={rightElements}\n onTitleWidthChange={handleTitleWidthChange}\n onResize={handleShowTooltipResize}\n />\n )}\n </StyledListItemHeadTitle>\n {shouldShowSubtitleRow && (\n <StyledListItemHeadSubtitle>\n <ListItemSubtitle\n subtitle={subtitle}\n isOpen={isOpen}\n rightElements={rightElements}\n />\n </StyledListItemHeadSubtitle>\n )}\n </LayoutGroup>\n </StyledListItemHeadContent>\n <ListItemRightElement rightElements={rightElements} />\n {hoverItem && shouldShowHoverItemContent && (\n <StyledMotionListItemHeadHoverItemWrapper\n className=\"beta-chayns-list-item-hover-item\"\n animate={{\n marginLeft: 8,\n opacity: 1,\n width: 'auto',\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,IAQRC,WAAW,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QAAQ,EAAEA,QAAS;IACnBV,MAAM,EAAEA,MAAO;IACfK,aAAa,EAAEA;EAAc,CAChC,CACuB,CAEvB,CACU,CAAC,eAC5BzC,KAAA,CAAA6F,aAAA,CAACxE,oBAAoB;IAACoB,aAAa,EAAEA;EAAc,CAAE,CAAC,EACrDX,SAAS,IAAI2D,0BAA0B,iBACpCzF,KAAA,CAAA6F,aAAA,CAAC3E,wCAAwC;IACrCsF,SAAS,EAAC,kCAAkC;IAC5CG,OAAO,EAAE;MACLuB,UAAU,EAAE,CAAC;MACbtB,OAAO,EAAE,CAAC;MACVpB,KAAK,EAAE;IACX,CAAE;IACFqB,OAAO,EAAE,KAAM;IACfC,UAAU,EAAE;MAAEC,QAAQ,EAAE,IAAI;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBAE9ChH,KAAA,CAAA6F,aAAA,CAAC5E,iCAAiC,QAC7Ba,SAC8B,CACG,CAE9B,CAAC;AAE7B,CAAC;AAEDH,YAAY,CAACwG,WAAW,GAAG,cAAc;AAEzC,eAAexG,YAAY","ignoreList":[]}
|
|
@@ -119,10 +119,27 @@ export type ListItemProps = {
|
|
|
119
119
|
* Whether the image should be opened on click.
|
|
120
120
|
*/
|
|
121
121
|
shouldOpenImageOnClick?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the framer-motion layout projection (`layout="position"`) should be
|
|
124
|
+
* enabled. This animates the `ListItem` smoothly into its new position when
|
|
125
|
+
* sibling items are reordered, expanded or resized.
|
|
126
|
+
*
|
|
127
|
+
* This is opt-in and disabled by default, because framer-motions layout
|
|
128
|
+
* projection is viewport-global: every layout change anywhere in the document
|
|
129
|
+
* (window resize, height animation, ...) forces a re-measurement of **all**
|
|
130
|
+
* layout-projection nodes via `getBoundingClientRect`. In lists with many
|
|
131
|
+
* `ListItem`s this scales linearly and causes noticeable layout thrash. The
|
|
132
|
+
* enter/exit height/opacity animation is unaffected and stays enabled.
|
|
133
|
+
*/
|
|
134
|
+
shouldAnimateLayout?: boolean;
|
|
122
135
|
/**
|
|
123
136
|
* Whether the layout animation should be prevented. This is useful when the
|
|
124
137
|
* `ListItem` is used in a list with a lot of items and the layout animation
|
|
125
138
|
* is not desired.
|
|
139
|
+
*
|
|
140
|
+
* @deprecated The layout projection is now disabled by default. Use
|
|
141
|
+
* `shouldAnimateLayout` to opt into it instead. When set to `true`, this
|
|
142
|
+
* prop keeps forcing the layout projection off.
|
|
126
143
|
*/
|
|
127
144
|
shouldPreventLayoutAnimation?: boolean;
|
|
128
145
|
/**
|
|
@@ -26,6 +26,7 @@ type ListItemHeadProps = {
|
|
|
26
26
|
shouldForceHover?: boolean;
|
|
27
27
|
setShouldEnableTooltip: (value: boolean) => void;
|
|
28
28
|
shouldDisableAnimation?: boolean;
|
|
29
|
+
shouldAnimateLayout?: boolean;
|
|
29
30
|
cornerElement?: ReactNode;
|
|
30
31
|
onTitleWidthChange: (titleWidth: number, titleMaxWidth: number) => void;
|
|
31
32
|
onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.52",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "39253e6054b50233279b8105e09e6319171bc4ad"
|
|
97
97
|
}
|