@chayns-components/core 5.3.8 → 5.3.9
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 +6 -1
- package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
- package/lib/cjs/components/list/list-item/ListItem.styles.js +7 -4
- package/lib/cjs/components/list/list-item/ListItem.styles.js.map +1 -1
- package/lib/cjs/hooks/element.js +12 -1
- package/lib/cjs/hooks/element.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.js +6 -1
- package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.styles.js +7 -4
- package/lib/esm/components/list/list-item/ListItem.styles.js.map +1 -1
- package/lib/esm/hooks/element.js +10 -0
- package/lib/esm/hooks/element.js.map +1 -1
- package/lib/types/components/list/list-item/ListItem.d.ts +4 -0
- package/lib/types/components/list/list-item/ListItem.styles.d.ts +6 -2
- package/lib/types/hooks/element.d.ts +1 -0
- package/package.json +2 -2
|
@@ -14,6 +14,7 @@ var _ListItemBody = _interopRequireDefault(require("./list-item-body/ListItemBod
|
|
|
14
14
|
var _ListItemHead = _interopRequireDefault(require("./list-item-head/ListItemHead"));
|
|
15
15
|
var _ListItem = require("./ListItem.styles");
|
|
16
16
|
var _Tooltip = _interopRequireDefault(require("../../tooltip/Tooltip"));
|
|
17
|
+
var _element = require("../../../hooks/element");
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
20
|
const ListItem = /*#__PURE__*/(0, _react2.forwardRef)(({
|
|
@@ -52,7 +53,8 @@ const ListItem = /*#__PURE__*/(0, _react2.forwardRef)(({
|
|
|
52
53
|
onSizeChange,
|
|
53
54
|
titleElement,
|
|
54
55
|
shouldDisableAnimation = false,
|
|
55
|
-
cornerElement
|
|
56
|
+
cornerElement,
|
|
57
|
+
isSelected = false
|
|
56
58
|
}, ref) => {
|
|
57
59
|
const {
|
|
58
60
|
isAnyItemExpandable,
|
|
@@ -66,6 +68,7 @@ const ListItem = /*#__PURE__*/(0, _react2.forwardRef)(({
|
|
|
66
68
|
const areaProvider = (0, _react2.useContext)(_AreaContextProvider.AreaContext);
|
|
67
69
|
const isInitialRenderRef = (0, _react2.useRef)(true);
|
|
68
70
|
const listItemRef = (0, _react2.useRef)(null);
|
|
71
|
+
const isInDialog = (0, _element.useIsInsideDialog)(listItemRef);
|
|
69
72
|
const uuid = (0, _uuid.useUuid)();
|
|
70
73
|
const isExpandable = children !== undefined;
|
|
71
74
|
const isItemOpen = isOpen ?? openItemUuid === uuid;
|
|
@@ -144,6 +147,8 @@ const ListItem = /*#__PURE__*/(0, _react2.forwardRef)(({
|
|
|
144
147
|
$isInAccordion: typeof isParentAccordionWrapped === 'boolean' && !areaProvider.shouldDisableListItemPadding,
|
|
145
148
|
$isOpen: isItemOpen,
|
|
146
149
|
$isWrapped: isWrapped,
|
|
150
|
+
$isInDialog: isInDialog,
|
|
151
|
+
$isSelected: isSelected,
|
|
147
152
|
$shouldChangeColor: areaProvider.shouldChangeColor,
|
|
148
153
|
$shouldForceBackground: shouldForceBackground,
|
|
149
154
|
$shouldForceBottomLine: shouldForceBottomLine,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["_react","require","_react2","_interopRequireWildcard","_uuid","_Accordion","_AreaContextProvider","_List","_ListItemBody","_interopRequireDefault","_ListItemHead","_ListItem","_Tooltip","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","titleElement","shouldDisableAnimation","cornerElement","ref","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","useContext","ListContext","isParentAccordionWrapped","AccordionContext","areaProvider","AreaContext","isInitialRenderRef","useRef","listItemRef","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","createElement","StyledListItem","as","motion","div","animate","height","opacity","className","exit","initial","key","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","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 CSSProperties,\n forwardRef,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem, StyledListItemTooltip } from './ListItem.styles';\nimport Tooltip from '../../tooltip/Tooltip';\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 * 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\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 titleElement,\n shouldDisableAnimation = false,\n cornerElement,\n },\n ref,\n ) => {\n const { isAnyItemExpandable, isWrapped, openItemUuid, updateOpenItemUuid } =\n useContext(ListContext);\n\n const { isWrapped: isParentAccordionWrapped } = useContext(AccordionContext);\n\n const areaProvider = useContext(AreaContext);\n\n const isInitialRenderRef = useRef(true);\n\n const listItemRef = useRef<HTMLDivElement>(null);\n\n const uuid = useUuid();\n\n const isExpandable = children !== undefined;\n const isItemOpen = isOpen ?? openItemUuid === uuid;\n\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n\n const [shouldEnableTooltip, setShouldEnableTooltip] = useState(false);\n 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 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 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 $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n >\n <Tooltip\n shouldUseFullWidth\n isDisabled={!shouldShowTooltipOnTitleOverflow || !shouldEnableTooltip}\n item={\n <StyledListItemTooltip\n style={{ cursor: 'default' }}\n key={`list-item-tooltip-${uuid}`}\n >\n {title}\n </StyledListItemTooltip>\n }\n >\n <ListItemHead\n hoverItem={hoverItem}\n careOfLocationId={careOfLocationId}\n cornerElement={cornerElement}\n cornerImage={cornerImage}\n icons={icons}\n imageBackground={imageBackground}\n images={images}\n isAnyItemExpandable={isAnyItemExpandable}\n isExpandable={isExpandable}\n isOpen={isItemOpen}\n isTitleGreyed={isTitleGreyed}\n leftElements={leftElements}\n onClick={isClickable ? handleHeadClick : undefined}\n onLongPress={onLongPress}\n shouldForceHover={shouldForceHover}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n onTitleWidthChange={handleTitleWidthChange}\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>\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AAY;IACTgI,EAAE,EAAE3D,IAAK;IACToC,GAAG,EAAE,gBAAgBpC,IAAI,EAAG;IAC5B4D,cAAc,EAAEpF,kBAAkB,IAAI,CAAC4B;EAAW,gBAElDtF,OAAA,CAAAa,OAAA,CAAA8F,aAAA,CAACvG,oBAAA,CAAAS,OAAmB,QAAEqB,QAA8B,CAC1C,CAEL,CACL,CAAC;AAEzB,CACJ,CAAC;AAEDJ,QAAQ,CAACiH,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAApI,OAAA,GAEnBiB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItem.js","names":["_react","require","_react2","_interopRequireWildcard","_uuid","_Accordion","_AreaContextProvider","_List","_ListItemBody","_interopRequireDefault","_ListItemHead","_ListItem","_Tooltip","_element","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","titleElement","shouldDisableAnimation","cornerElement","isSelected","ref","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","useContext","ListContext","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","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","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 CSSProperties,\n forwardRef,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem, StyledListItemTooltip } from './ListItem.styles';\nimport Tooltip from '../../tooltip/Tooltip';\nimport { useIsInsideDialog } from '../../../hooks/element';\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\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 titleElement,\n shouldDisableAnimation = false,\n cornerElement,\n isSelected = false,\n },\n ref,\n ) => {\n const { isAnyItemExpandable, isWrapped, openItemUuid, updateOpenItemUuid } =\n useContext(ListContext);\n\n const { isWrapped: isParentAccordionWrapped } = useContext(AccordionContext);\n\n const areaProvider = useContext(AreaContext);\n\n const isInitialRenderRef = useRef(true);\n\n const listItemRef = useRef<HTMLDivElement>(null);\n\n const 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 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 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 >\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={shouldForceHover}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n onTitleWidthChange={handleTitleWidthChange}\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;AAcA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAH,uBAAA,CAAAF,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,aAAA,GAAAD,sBAAA,CAAAR,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,QAAA,GAAAH,sBAAA,CAAAR,OAAA;AACA,IAAAY,QAAA,GAAAZ,OAAA;AAA2D,SAAAQ,uBAAAK,CAAA,WAAAA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10 +22,12 @@ const StyledListItem = exports.StyledListItem = _styledComponents.default.div`
|
|
|
22
22
|
$isOpen,
|
|
23
23
|
$shouldChangeColor,
|
|
24
24
|
$shouldForceBackground,
|
|
25
|
-
theme
|
|
26
|
-
|
|
25
|
+
theme,
|
|
26
|
+
$isInDialog,
|
|
27
|
+
$isSelected
|
|
28
|
+
}) => (!$isInAccordion && $isOpen || $shouldForceBackground || $isSelected) && (0, _styledComponents.css)`
|
|
27
29
|
background-color: rgba(
|
|
28
|
-
${$shouldChangeColor ? theme['102-rgb'] : theme['100-rgb']},
|
|
30
|
+
${$shouldChangeColor || $isInDialog ? theme['102-rgb'] : theme['100-rgb']},
|
|
29
31
|
${theme.cardBackgroundOpacity}
|
|
30
32
|
);
|
|
31
33
|
`}
|
|
@@ -43,11 +45,12 @@ const StyledListItem = exports.StyledListItem = _styledComponents.default.div`
|
|
|
43
45
|
$isClickable,
|
|
44
46
|
$isInAccordion,
|
|
45
47
|
$shouldChangeColor,
|
|
48
|
+
$isInDialog,
|
|
46
49
|
theme
|
|
47
50
|
}) => $isClickable && !$isInAccordion && (0, _styledComponents.css)`
|
|
48
51
|
&&:hover {
|
|
49
52
|
background-color: rgba(
|
|
50
|
-
${$shouldChangeColor ? theme['102-rgb'] : theme['100-rgb']},
|
|
53
|
+
${$shouldChangeColor || $isInDialog ? theme['102-rgb'] : theme['100-rgb']},
|
|
51
54
|
${theme.cardBackgroundOpacity}
|
|
52
55
|
);
|
|
53
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledListItem","exports","styled","div","$isInAccordion","$shouldHideIndicator","css","$isOpen","$shouldChangeColor","$shouldForceBackground","theme","cardBackgroundOpacity","$backgroundColor","$isClickable","$isWrapped","$shouldHideBottomLine","$shouldForceBottomLine","$shouldShowSeparatorBelow","accordionLines","undefined","StyledListItemTooltip"],"sources":["../../../../../src/components/list/list-item/ListItem.styles.ts"],"sourcesContent":["import type { HTMLMotionProps } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport type { Theme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { CSSProperties } from 'react';\n\ntype StyledListItemProps = HTMLMotionProps<'div'> & {\n $backgroundColor?: CSSProperties['backgroundColor'];\n $isClickable: boolean;\n $isInAccordion: boolean;\n $isOpen: boolean;\n $isWrapped: boolean;\n $shouldChangeColor?: boolean;\n $shouldForceBackground?: boolean;\n $shouldForceBottomLine?: boolean;\n $shouldHideBottomLine: boolean;\n $shouldHideIndicator: boolean;\n $shouldShowSeparatorBelow: boolean;\n};\n\nexport const StyledListItem = styled.div<StyledListItemProps>`\n overflow: hidden;\n transition: background-color 0.3s ease;\n\n ${({ $isInAccordion, $shouldHideIndicator }: StyledListItemProps) =>\n $isInAccordion &&\n css`\n padding-left: ${$shouldHideIndicator ? '16px' : '8px'};\n `}\n\n ${({\n $isInAccordion,\n $isOpen,\n $shouldChangeColor,\n $shouldForceBackground,\n theme,\n }: StyledListItemProps & {\n theme: Theme;\n }) =>\n ((!$isInAccordion && $isOpen) || $shouldForceBackground) &&\n css`\n background-color: rgba(\n ${$shouldChangeColor ? theme['102-rgb'] : theme['100-rgb']},\n ${theme.cardBackgroundOpacity}\n );\n `}\n\n ${({ $backgroundColor, $isInAccordion, $isOpen, $shouldForceBackground }) =>\n $backgroundColor &&\n ((!$isInAccordion && $isOpen) || $shouldForceBackground) &&\n css`\n background-color: ${$backgroundColor} !important;\n `}\n\n ${({\n $isClickable,\n $isInAccordion,\n $shouldChangeColor,\n theme,\n }: StyledListItemProps & {\n theme: Theme;\n }) =>\n $isClickable &&\n !$isInAccordion &&\n css`\n &&:hover {\n background-color: rgba(\n ${$shouldChangeColor ? theme['102-rgb'] : theme['100-rgb']},\n ${theme.cardBackgroundOpacity}\n );\n }\n `}\n\n ${({\n $isInAccordion,\n $isOpen,\n $isWrapped,\n $shouldHideBottomLine,\n $shouldForceBottomLine,\n $shouldShowSeparatorBelow,\n theme,\n }: StyledListItemProps & { theme: Theme }) => {\n if (\n $shouldShowSeparatorBelow ||\n ((!$isOpen || $isWrapped || $isInAccordion) &&\n theme.accordionLines &&\n !$shouldHideBottomLine)\n ) {\n if ($shouldForceBottomLine) {\n return css`\n border-bottom: ${$shouldShowSeparatorBelow ? '4px' : '1px'} solid\n rgba(${theme['headline-rgb']}, 1);\n `;\n }\n\n return css`\n &&:not(:last-child) {\n border-bottom: ${$shouldShowSeparatorBelow ? '4px' : '1px'} solid\n rgba(${theme['headline-rgb']}, 1);\n }\n `;\n }\n\n return undefined;\n }}\n\n ${({ $isWrapped }) =>\n $isWrapped &&\n css`\n padding-left: 26px;\n `}\n`;\n\nexport const StyledListItemTooltip = styled.div`\n padding: 6px;\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"ListItem.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledListItem","exports","styled","div","$isInAccordion","$shouldHideIndicator","css","$isOpen","$shouldChangeColor","$shouldForceBackground","theme","$isInDialog","$isSelected","cardBackgroundOpacity","$backgroundColor","$isClickable","$isWrapped","$shouldHideBottomLine","$shouldForceBottomLine","$shouldShowSeparatorBelow","accordionLines","undefined","StyledListItemTooltip"],"sources":["../../../../../src/components/list/list-item/ListItem.styles.ts"],"sourcesContent":["import type { HTMLMotionProps } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport type { Theme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { CSSProperties } from 'react';\n\ntype StyledListItemProps = HTMLMotionProps<'div'> & {\n $backgroundColor?: CSSProperties['backgroundColor'];\n $isClickable: boolean;\n $isInAccordion: boolean;\n $isOpen: boolean;\n $isWrapped: boolean;\n $shouldChangeColor?: boolean;\n $shouldForceBackground?: boolean;\n $shouldForceBottomLine?: boolean;\n $shouldHideBottomLine: boolean;\n $shouldHideIndicator: boolean;\n $shouldShowSeparatorBelow: boolean;\n $isInDialog: boolean;\n $isSelected: boolean;\n};\n\nexport const StyledListItem = styled.div<StyledListItemProps>`\n overflow: hidden;\n transition: background-color 0.3s ease;\n\n ${({ $isInAccordion, $shouldHideIndicator }: StyledListItemProps) =>\n $isInAccordion &&\n css`\n padding-left: ${$shouldHideIndicator ? '16px' : '8px'};\n `}\n\n ${({\n $isInAccordion,\n $isOpen,\n $shouldChangeColor,\n $shouldForceBackground,\n theme,\n $isInDialog,\n $isSelected,\n }: StyledListItemProps & {\n theme: Theme;\n }) =>\n ((!$isInAccordion && $isOpen) || $shouldForceBackground || $isSelected) &&\n css`\n background-color: rgba(\n ${$shouldChangeColor || $isInDialog ? theme['102-rgb'] : theme['100-rgb']},\n ${theme.cardBackgroundOpacity}\n );\n `}\n\n ${({ $backgroundColor, $isInAccordion, $isOpen, $shouldForceBackground }) =>\n $backgroundColor &&\n ((!$isInAccordion && $isOpen) || $shouldForceBackground) &&\n css`\n background-color: ${$backgroundColor} !important;\n `}\n\n ${({\n $isClickable,\n $isInAccordion,\n $shouldChangeColor,\n $isInDialog,\n theme,\n }: StyledListItemProps & {\n theme: Theme;\n }) =>\n $isClickable &&\n !$isInAccordion &&\n css`\n &&:hover {\n background-color: rgba(\n ${$shouldChangeColor || $isInDialog ? theme['102-rgb'] : theme['100-rgb']},\n ${theme.cardBackgroundOpacity}\n );\n }\n `}\n\n ${({\n $isInAccordion,\n $isOpen,\n $isWrapped,\n $shouldHideBottomLine,\n $shouldForceBottomLine,\n $shouldShowSeparatorBelow,\n theme,\n }: StyledListItemProps & { theme: Theme }) => {\n if (\n $shouldShowSeparatorBelow ||\n ((!$isOpen || $isWrapped || $isInAccordion) &&\n theme.accordionLines &&\n !$shouldHideBottomLine)\n ) {\n if ($shouldForceBottomLine) {\n return css`\n border-bottom: ${$shouldShowSeparatorBelow ? '4px' : '1px'} solid\n rgba(${theme['headline-rgb']}, 1);\n `;\n }\n\n return css`\n &&:not(:last-child) {\n border-bottom: ${$shouldShowSeparatorBelow ? '4px' : '1px'} solid\n rgba(${theme['headline-rgb']}, 1);\n }\n `;\n }\n\n return undefined;\n }}\n\n ${({ $isWrapped }) =>\n $isWrapped &&\n css`\n pad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,sBAAsB,EAAE;MACxB,OAAO,IAAAZ,qBAAG;AAC1B,qCAAqCa,yBAAyB,GAAG,KAAK,GAAG,KAAK;AAC9E,+BAA+BT,KAAK,CAAC,cAAc,CAAC;AACpD,iBAAiB;IACL;IAEA,OAAO,IAAAJ,qBAAG;AACtB;AACA,qCAAqCa,yBAAyB,GAAG,KAAK,GAAG,KAAK;AAC9E,+BAA+BT,KAAK,CAAC,cAAc,CAAC;AACpD;AACA,aAAa;EACL;EAEA,OAAOW,SAAS;AACpB,CAAC;AACL;AACA,MAAM,CAAC;EAAEL;AAAW,CAAC,KACbA,UAAU,IACV,IAAAV,qBAAG;AACX;AACA,SAAS;AACT,CAAC;AAEM,MAAMgB,qBAAqB,GAAArB,OAAA,CAAAqB,qBAAA,GAAGpB,yBAAM,CAACC,GAAG;AAC/C;AACA,CAAC","ignoreList":[]}
|
package/lib/cjs/hooks/element.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useMeasuredClone = exports.useIsMeasuredClone = exports.useElementSize = void 0;
|
|
6
|
+
exports.useMeasuredClone = exports.useIsMeasuredClone = exports.useIsInsideDialog = exports.useElementSize = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
9
|
const isSameRect = (a, b) => {
|
|
@@ -169,4 +169,15 @@ const useIsMeasuredClone = () => {
|
|
|
169
169
|
return [isClone, ref];
|
|
170
170
|
};
|
|
171
171
|
exports.useIsMeasuredClone = useIsMeasuredClone;
|
|
172
|
+
const useIsInsideDialog = ref => {
|
|
173
|
+
const [isInsideDialog, setIsInsideDialog] = (0, _react.useState)(false);
|
|
174
|
+
(0, _react.useEffect)(() => {
|
|
175
|
+
if (!ref.current) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
setIsInsideDialog(ref.current.closest('.dialog-inner') !== null);
|
|
179
|
+
}, [ref]);
|
|
180
|
+
return isInsideDialog;
|
|
181
|
+
};
|
|
182
|
+
exports.useIsInsideDialog = useIsInsideDialog;
|
|
172
183
|
//# sourceMappingURL=element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":["_react","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","isSameRect","a","b","width","height","x","y","useElementSize","ref","shouldUseChildElement","shouldUseParentElement","size","setSize","useState","useEffect","target","current","_ref$current","parentElement","_ref$current2","firstElementChild","undefined","frameId","updateSize","nextSize","window","cancelAnimationFrame","requestAnimationFrame","currentSize","getBoundingClientRect","observer","ResizeObserver","entry","contentRect","observe","disconnect","exports","cloneWithTabIndex","node","isValidElement","element","type","React","Fragment","children","Children","map","props","cloneElement","displayName","createElement","tabIndex","getClonedElement","content","preventEvents","onClick","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","useMeasuredClone","shouldPreventTextWrapping","useRef","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","userSelect","zIndex","visibility","inert","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute"],"sources":["../../../src/hooks/element.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n HTMLAttributes,\n isValidElement,\n MutableRefObject,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n shouldUseParentElement?: boolean;\n}\n\nconst isSameRect = (a?: DOMRectReadOnly, b?: DOMRectReadOnly) => {\n if (!a || !b) return false;\n\n return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;\n};\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false, shouldUseParentElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n useEffect(() => {\n let target: HTMLElement | null = ref.current;\n\n if (shouldUseParentElement) {\n target = ref.current?.parentElement ?? null;\n }\n\n if (shouldUseChildElement) {\n target = ref.current?.firstElementChild as HTMLElement | null;\n }\n\n if (!target) return undefined;\n\n let frameId: number | undefined;\n\n const updateSize = (nextSize: DOMRectReadOnly) => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n frameId = window.requestAnimationFrame(() => {\n setSize((currentSize) =>\n isSameRect(currentSize, nextSize) ? currentSize : nextSize,\n );\n });\n };\n\n updateSize(target.getBoundingClientRect());\n\n const observer = new ResizeObserver(([entry]) => {\n if (!entry || entry.target !== target) return;\n\n updateSize(entry.contentRect);\n });\n\n observer.observe(target);\n\n return () => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n observer.disconnect();\n };\n }, [ref, shouldUseChildElement, shouldUseParentElement]);\n\n return size;\n};\n\nconst cloneWithTabIndex = (node: ReactNode): ReactNode => {\n if (!isValidElement(node)) return node;\n\n const element = node as ReactElement;\n\n if (element.type === React.Fragment) {\n const children = Children.map(element.props.children, cloneWithTabIndex);\n\n return cloneElement(element, {\n ...element.props,\n children,\n });\n }\n\n const children = element.props.children\n ? Children.map(element.props.children, cloneWithTabIndex)\n : element.props.children;\n\n if ((element.type as any).displayName === 'Button') {\n return (\n // eslint-disable-next-line react/button-has-type\n <button tabIndex={-1}>{children}</button>\n );\n }\n\n return cloneElement(element, {\n ...element.props,\n tabIndex: -1,\n children,\n });\n};\n\nconst getClonedElement = (content: ReactNode) => {\n const preventEvents: Partial<HTMLAttributes<never>> = {\n onClick: (e) => e.stopPropagation(),\n onMouseDown: (e) => e.stopPropagation(),\n onMouseUp: (e) => e.stopPropagation(),\n onKeyDown: (e) => e.stopPropagation(),\n onKeyUp: (e) => e.stopPropagation(),\n onFocus: (e) => e.stopPropagation(),\n onBlur: (e) => e.stopPropagation(),\n };\n\n if (typeof content === 'string') {\n return (\n <span tabIndex={-1} data-measured-clone>\n {content}\n </span>\n );\n }\n\n if (isValidElement(content)) {\n return cloneWithTabIndex(\n cloneElement(content, {\n ...preventEvents,\n 'data-measured-clone': true,\n }),\n );\n }\n\n return content;\n};\n\ninterface UseMeasuredCloneOptions {\n content: ReactNode;\n shouldPreventTextWrapping?: boolean;\n}\n\nexport const useMeasuredClone = ({\n content,\n shouldPreventTextWrapping = true,\n}: UseMeasuredCloneOptions) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const clonedElement = getClonedElement(content);\n\n useEffect(() => {\n const measure = () => {\n if (!ref.current) return;\n\n const { offsetWidth: width, offsetHeight: height } = ref.current;\n\n setSize({ width: width + (shouldPreventTextWrapping ? 10 : 0), height });\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n\n if (ref.current) observer.observe(ref.current);\n\n return () => observer.disconnect();\n }, [shouldPreventTextWrapping]);\n\n const measuredElement = (\n <div\n data-measured-clone=\"true\"\n ref={ref}\n style={{\n position: 'fixed',\n opacity: 0,\n pointerEvents: 'none',\n userSelect: 'none',\n zIndex: -1,\n height: 'auto',\n width: 'auto',\n visibility: 'hidden',\n }}\n inert=\"true\"\n tabIndex={-1}\n >\n {clonedElement}\n </div>\n );\n\n return {\n measuredElement,\n width: size.width,\n height: size.height,\n };\n};\n\nexport const useIsMeasuredClone = <T extends HTMLElement>() => {\n const ref = useRef<T | null>(null);\n\n const [isClone, setIsClone] = useState(false);\n\n useEffect(() => {\n if (!ref.current) return;\n\n let el: HTMLElement | null = ref.current;\n\n while (el) {\n if (el.hasAttribute('data-measured-clone')) {\n setIsClone(true);\n\n return;\n }\n\n el = el.parentElement;\n }\n\n setIsClone(false);\n }, []);\n\n return [isClone, ref] as const;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWe,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,E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,EAAE,OAAO;MACjBC,OAAO,EAAE,CAAC;MACVC,aAAa,EAAE,MAAM;MACrBC,UAAU,EAAE,MAAM;MAClBC,MAAM,EAAE,CAAC,CAAC;MACVxE,MAAM,EAAE,MAAM;MACdD,KAAK,EAAE,MAAM;MACb0E,UAAU,EAAE;IAChB,CAAE;IACFC,KAAK,EAAC,MAAM;IACZ3B,QAAQ,EAAE,CAAC;EAAE,GAEZe,aACA,CACR;EAED,OAAO;IACHI,eAAe;IACfnE,KAAK,EAAEQ,IAAI,CAACR,KAAK;IACjBC,MAAM,EAAEO,IAAI,CAACP;EACjB,CAAC;AACL,CAAC;AAACgC,OAAA,CAAA2B,gBAAA,GAAAA,gBAAA;AAEK,MAAMgB,kBAAkB,GAAGA,CAAA,KAA6B;EAC3D,MAAMvE,GAAG,GAAG,IAAAyD,aAAM,EAAW,IAAI,CAAC;EAElC,MAAM,CAACe,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAApE,eAAQ,EAAC,KAAK,CAAC;EAE7C,IAAAC,gBAAS,EAAC,MAAM;IACZ,IAAI,CAACN,GAAG,CAACQ,OAAO,EAAE;IAElB,IAAIkE,EAAsB,GAAG1E,GAAG,CAACQ,OAAO;IAExC,OAAOkE,EAAE,EAAE;MACP,IAAIA,EAAE,CAACC,YAAY,CAAC,qBAAqB,CAAC,EAAE;QACxCF,UAAU,CAAC,IAAI,CAAC;QAEhB;MACJ;MAEAC,EAAE,GAAGA,EAAE,CAAChE,aAAa;IACzB;IAEA+D,UAAU,CAAC,KAAK,CAAC;EACrB,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACD,OAAO,EAAExE,GAAG,CAAC;AACzB,CAAC;AAAC4B,OAAA,CAAA2C,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"element.js","names":["_react","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","isSameRect","a","b","width","height","x","y","useElementSize","ref","shouldUseChildElement","shouldUseParentElement","size","setSize","useState","useEffect","target","current","_ref$current","parentElement","_ref$current2","firstElementChild","undefined","frameId","updateSize","nextSize","window","cancelAnimationFrame","requestAnimationFrame","currentSize","getBoundingClientRect","observer","ResizeObserver","entry","contentRect","observe","disconnect","exports","cloneWithTabIndex","node","isValidElement","element","type","React","Fragment","children","Children","map","props","cloneElement","displayName","createElement","tabIndex","getClonedElement","content","preventEvents","onClick","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","useMeasuredClone","shouldPreventTextWrapping","useRef","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","userSelect","zIndex","visibility","inert","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute","useIsInsideDialog","isInsideDialog","setIsInsideDialog","closest"],"sources":["../../../src/hooks/element.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n HTMLAttributes,\n isValidElement,\n MutableRefObject,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n shouldUseParentElement?: boolean;\n}\n\nconst isSameRect = (a?: DOMRectReadOnly, b?: DOMRectReadOnly) => {\n if (!a || !b) return false;\n\n return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;\n};\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false, shouldUseParentElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n useEffect(() => {\n let target: HTMLElement | null = ref.current;\n\n if (shouldUseParentElement) {\n target = ref.current?.parentElement ?? null;\n }\n\n if (shouldUseChildElement) {\n target = ref.current?.firstElementChild as HTMLElement | null;\n }\n\n if (!target) return undefined;\n\n let frameId: number | undefined;\n\n const updateSize = (nextSize: DOMRectReadOnly) => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n frameId = window.requestAnimationFrame(() => {\n setSize((currentSize) =>\n isSameRect(currentSize, nextSize) ? currentSize : nextSize,\n );\n });\n };\n\n updateSize(target.getBoundingClientRect());\n\n const observer = new ResizeObserver(([entry]) => {\n if (!entry || entry.target !== target) return;\n\n updateSize(entry.contentRect);\n });\n\n observer.observe(target);\n\n return () => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n observer.disconnect();\n };\n }, [ref, shouldUseChildElement, shouldUseParentElement]);\n\n return size;\n};\n\nconst cloneWithTabIndex = (node: ReactNode): ReactNode => {\n if (!isValidElement(node)) return node;\n\n const element = node as ReactElement;\n\n if (element.type === React.Fragment) {\n const children = Children.map(element.props.children, cloneWithTabIndex);\n\n return cloneElement(element, {\n ...element.props,\n children,\n });\n }\n\n const children = element.props.children\n ? Children.map(element.props.children, cloneWithTabIndex)\n : element.props.children;\n\n if ((element.type as any).displayName === 'Button') {\n return (\n // eslint-disable-next-line react/button-has-type\n <button tabIndex={-1}>{children}</button>\n );\n }\n\n return cloneElement(element, {\n ...element.props,\n tabIndex: -1,\n children,\n });\n};\n\nconst getClonedElement = (content: ReactNode) => {\n const preventEvents: Partial<HTMLAttributes<never>> = {\n onClick: (e) => e.stopPropagation(),\n onMouseDown: (e) => e.stopPropagation(),\n onMouseUp: (e) => e.stopPropagation(),\n onKeyDown: (e) => e.stopPropagation(),\n onKeyUp: (e) => e.stopPropagation(),\n onFocus: (e) => e.stopPropagation(),\n onBlur: (e) => e.stopPropagation(),\n };\n\n if (typeof content === 'string') {\n return (\n <span tabIndex={-1} data-measured-clone>\n {content}\n </span>\n );\n }\n\n if (isValidElement(content)) {\n return cloneWithTabIndex(\n cloneElement(content, {\n ...preventEvents,\n 'data-measured-clone': true,\n }),\n );\n }\n\n return content;\n};\n\ninterface UseMeasuredCloneOptions {\n content: ReactNode;\n shouldPreventTextWrapping?: boolean;\n}\n\nexport const useMeasuredClone = ({\n content,\n shouldPreventTextWrapping = true,\n}: UseMeasuredCloneOptions) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const clonedElement = getClonedElement(content);\n\n useEffect(() => {\n const measure = () => {\n if (!ref.current) return;\n\n const { offsetWidth: width, offsetHeight: height } = ref.current;\n\n setSize({ width: width + (shouldPreventTextWrapping ? 10 : 0), height });\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n\n if (ref.current) observer.observe(ref.current);\n\n return () => observer.disconnect();\n }, [shouldPreventTextWrapping]);\n\n const measuredElement = (\n <div\n data-measured-clone=\"true\"\n ref={ref}\n style={{\n position: 'fixed',\n opacity: 0,\n pointerEvents: 'none',\n userSelect: 'none',\n zIndex: -1,\n height: 'auto',\n width: 'auto',\n visibility: 'hidden',\n }}\n inert=\"true\"\n tabIndex={-1}\n >\n {clonedElement}\n </div>\n );\n\n return {\n measuredElement,\n width: size.width,\n height: size.height,\n };\n};\n\nexport const useIsMeasuredClone = <T extends HTMLElement>() => {\n const ref = useRef<T | null>(null);\n\n const [isClone, setIsClone] = useState(false);\n\n useEffect(() => {\n if (!ref.current) return;\n\n let el: HTMLElement | null = ref.current;\n\n while (el) {\n if (el.hasAttribute('data-measured-clone')) {\n setIsClone(true);\n\n return;\n }\n\n el = el.parentElement;\n }\n\n setIsClone(false);\n }, []);\n\n return [isClone, ref] as const;\n};\n\nexport const useIsInsideDialog = <T extends HTMLElement>(ref: MutableRefObject<T | null>) => {\n const [isInsideDialog, setIsInsideDialog] = useState(false);\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n setIsInsideDialog(ref.current.closest('.dialog-inner') !== null);\n }, [ref]);\n\n return isInsideDialog;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWe,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,O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
|
|
9
9
|
import { StyledListItem, StyledListItemTooltip } from './ListItem.styles';
|
|
10
10
|
import Tooltip from '../../tooltip/Tooltip';
|
|
11
|
+
import { useIsInsideDialog } from '../../../hooks/element';
|
|
11
12
|
const ListItem = /*#__PURE__*/forwardRef(({
|
|
12
13
|
backgroundColor,
|
|
13
14
|
careOfLocationId,
|
|
@@ -44,7 +45,8 @@ const ListItem = /*#__PURE__*/forwardRef(({
|
|
|
44
45
|
onSizeChange,
|
|
45
46
|
titleElement,
|
|
46
47
|
shouldDisableAnimation = false,
|
|
47
|
-
cornerElement
|
|
48
|
+
cornerElement,
|
|
49
|
+
isSelected = false
|
|
48
50
|
}, ref) => {
|
|
49
51
|
const {
|
|
50
52
|
isAnyItemExpandable,
|
|
@@ -58,6 +60,7 @@ const ListItem = /*#__PURE__*/forwardRef(({
|
|
|
58
60
|
const areaProvider = useContext(AreaContext);
|
|
59
61
|
const isInitialRenderRef = useRef(true);
|
|
60
62
|
const listItemRef = useRef(null);
|
|
63
|
+
const isInDialog = useIsInsideDialog(listItemRef);
|
|
61
64
|
const uuid = useUuid();
|
|
62
65
|
const isExpandable = children !== undefined;
|
|
63
66
|
const isItemOpen = isOpen ?? openItemUuid === uuid;
|
|
@@ -136,6 +139,8 @@ const ListItem = /*#__PURE__*/forwardRef(({
|
|
|
136
139
|
$isInAccordion: typeof isParentAccordionWrapped === 'boolean' && !areaProvider.shouldDisableListItemPadding,
|
|
137
140
|
$isOpen: isItemOpen,
|
|
138
141
|
$isWrapped: isWrapped,
|
|
142
|
+
$isInDialog: isInDialog,
|
|
143
|
+
$isSelected: isSelected,
|
|
139
144
|
$shouldChangeColor: areaProvider.shouldChangeColor,
|
|
140
145
|
$shouldForceBackground: shouldForceBackground,
|
|
141
146
|
$shouldForceBottomLine: shouldForceBottomLine,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["AnimatePresence","motion","React","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useRef","useState","useUuid","AccordionContext","AreaContextProvider","AreaContext","ListContext","ListItemBody","ListItemHead","StyledListItem","StyledListItemTooltip","Tooltip","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","titleElement","shouldDisableAnimation","cornerElement","ref","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","isParentAccordionWrapped","areaProvider","isInitialRenderRef","listItemRef","uuid","isExpandable","undefined","isItemOpen","onCloseRef","onOpenRef","shouldEnableTooltip","setShouldEnableTooltip","titleWidth","setTitleWidth","titleMaxWidth","setTitleMaxWidth","current","handleHeadClick","event","shouldOnlyOpen","isClickable","handleTitleWidthChange","width","maxWidth","createElement","as","div","animate","height","opacity","className","exit","initial","key","layout","$backgroundColor","$isClickable","$isInAccordion","shouldDisableListItemPadding","$isOpen","$isWrapped","$shouldChangeColor","shouldChangeColor","$shouldForceBackground","$shouldForceBottomLine","$shouldHideBottomLine","$shouldHideIndicator","$shouldShowSeparatorBelow","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 CSSProperties,\n forwardRef,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem, StyledListItemTooltip } from './ListItem.styles';\nimport Tooltip from '../../tooltip/Tooltip';\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 * 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\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 titleElement,\n shouldDisableAnimation = false,\n cornerElement,\n },\n ref,\n ) => {\n const { isAnyItemExpandable, isWrapped, openItemUuid, updateOpenItemUuid } =\n useContext(ListContext);\n\n const { isWrapped: isParentAccordionWrapped } = useContext(AccordionContext);\n\n const areaProvider = useContext(AreaContext);\n\n const isInitialRenderRef = useRef(true);\n\n const listItemRef = useRef<HTMLDivElement>(null);\n\n const uuid = useUuid();\n\n const isExpandable = children !== undefined;\n const isItemOpen = isOpen ?? openItemUuid === uuid;\n\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n\n const [shouldEnableTooltip, setShouldEnableTooltip] = useState(false);\n 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 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 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 $shouldChangeColor={areaProvider.shouldChangeColor}\n $shouldForceBackground={shouldForceBackground}\n $shouldForceBottomLine={shouldForceBottomLine}\n $shouldHideBottomLine={shouldHideBottomLine}\n $shouldHideIndicator={shouldHideIndicator}\n $shouldShowSeparatorBelow={shouldShowSeparatorBelow}\n >\n <Tooltip\n shouldUseFullWidth\n isDisabled={!shouldShowTooltipOnTitleOverflow || !shouldEnableTooltip}\n item={\n <StyledListItemTooltip\n style={{ cursor: 'default' }}\n key={`list-item-tooltip-${uuid}`}\n >\n {title}\n </StyledListItemTooltip>\n }\n >\n <ListItemHead\n hoverItem={hoverItem}\n careOfLocationId={careOfLocationId}\n cornerElement={cornerElement}\n cornerImage={cornerImage}\n icons={icons}\n imageBackground={imageBackground}\n images={images}\n isAnyItemExpandable={isAnyItemExpandable}\n isExpandable={isExpandable}\n isOpen={isItemOpen}\n isTitleGreyed={isTitleGreyed}\n leftElements={leftElements}\n onClick={isClickable ? handleHeadClick : undefined}\n onLongPress={onLongPress}\n shouldForceHover={shouldForceHover}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n onTitleWidthChange={handleTitleWidthChange}\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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,CAC1C,CAEL,CACL,CAAC;AAEzB,CACJ,CAAC;AAEDH,QAAQ,CAACkG,WAAW,GAAG,UAAU;AAEjC,eAAelG,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListItem.js","names":["AnimatePresence","motion","React","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useRef","useState","useUuid","AccordionContext","AreaContextProvider","AreaContext","ListContext","ListItemBody","ListItemHead","StyledListItem","StyledListItemTooltip","Tooltip","useIsInsideDialog","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","titleElement","shouldDisableAnimation","cornerElement","isSelected","ref","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","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","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","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 CSSProperties,\n forwardRef,\n MouseEventHandler,\n ReactNode,\n SyntheticEvent,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport type { IListItemRightElements } from '../../../types/list';\nimport { AccordionContext } from '../../accordion/Accordion';\nimport AreaContextProvider, { AreaContext } from '../../area-provider/AreaContextProvider';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem, StyledListItemTooltip } from './ListItem.styles';\nimport Tooltip from '../../tooltip/Tooltip';\nimport { useIsInsideDialog } from '../../../hooks/element';\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\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 titleElement,\n shouldDisableAnimation = false,\n cornerElement,\n isSelected = false,\n },\n ref,\n ) => {\n const { isAnyItemExpandable, isWrapped, openItemUuid, updateOpenItemUuid } =\n useContext(ListContext);\n\n const { isWrapped: isParentAccordionWrapped } = useContext(AccordionContext);\n\n const areaProvider = useContext(AreaContext);\n\n const isInitialRenderRef = useRef(true);\n\n const listItemRef = useRef<HTMLDivElement>(null);\n\n const 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 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 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 >\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={shouldForceHover}\n rightElements={rightElements}\n shouldHideImageOrIconBackground={shouldHideImageOrIconBackground}\n shouldHideIndicator={shouldHideIndicator}\n shouldOpenImageOnClick={shouldOpenImageOnClick}\n shouldShowRoundImageOrIcon={shouldShowRoundImageOrIcon}\n subtitle={subtitle}\n title={title}\n onTitleWidthChange={handleTitleWidthChange}\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,KAAK,IAERC,UAAU,EAKVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,OAAO,QAAQ,qBAAqB;AAE7C,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,mBAAmB,IAAIC,WAAW,QAAQ,yCAAyC;AAC1F,SAASC,WAAW,QAAQ,SAAS;AACrC,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;AAgL1D,MAAMC,QAAQ,gBAAGlB,UAAU,CACvB,CACI;EACImB,eAAe;EACfC,gBAAgB;EAChBC,QAAQ;EACRC,WAAW;EACXC,SAAS;EACTC,KAAK;EACLC,eAAe;EACfC,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,aAAa;EACbC,YAAY;EACZC,OAAO;EACPC,OAAO;EACPC,WAAW;EACXC,MAAM;EACNC,aAAa;EACbC,gCAAgC,GAAG,KAAK;EACxCC,qBAAqB,GAAG,KAAK;EAC7BC,qBAAqB,GAAG,KAAK;EAC7BC,gBAAgB,GAAG,KAAK;EACx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B,EAAEA,0BAA2B;IACvDE,QAAQ,EAAEA,QAAS;IACnBC,KAAK,EAAEA,KAAM;IACboE,kBAAkB,EAAElC,sBAAuB;IAC3C/B,YAAY,EAAEA,YAAa;IAC3BqB,sBAAsB,EAAEA,sBAAuB;IAC/CpB,sBAAsB,EAAEA,sBAAuB;IAC/CH,YAAY,EAAEA;EAAa,CAC9B,CACI,CAAC,eACVnD,KAAA,CAAAuF,aAAA,CAACzF,eAAe;IAACiG,OAAO,EAAE;EAAM,GAC3B3B,YAAY,KAAKE,UAAU,IAAIxB,kBAAkB,CAAC,iBAC/C9C,KAAA,CAAAuF,aAAA,CAAC1E,YAAY;IACT0G,EAAE,EAAEpD,IAAK;IACT6B,GAAG,EAAE,gBAAgB7B,IAAI,EAAG;IAC5BqD,cAAc,EAAE1E,kBAAkB,IAAI,CAACwB;EAAW,gBAElDtE,KAAA,CAAAuF,aAAA,CAAC7E,mBAAmB,QAAEY,QAA8B,CAC1C,CAEL,CACL,CAAC;AAEzB,CACJ,CAAC;AAEDH,QAAQ,CAACsG,WAAW,GAAG,UAAU;AAEjC,eAAetG,QAAQ","ignoreList":[]}
|
|
@@ -15,10 +15,12 @@ export const StyledListItem = styled.div`
|
|
|
15
15
|
$isOpen,
|
|
16
16
|
$shouldChangeColor,
|
|
17
17
|
$shouldForceBackground,
|
|
18
|
-
theme
|
|
19
|
-
|
|
18
|
+
theme,
|
|
19
|
+
$isInDialog,
|
|
20
|
+
$isSelected
|
|
21
|
+
}) => (!$isInAccordion && $isOpen || $shouldForceBackground || $isSelected) && css`
|
|
20
22
|
background-color: rgba(
|
|
21
|
-
${$shouldChangeColor ? theme['102-rgb'] : theme['100-rgb']},
|
|
23
|
+
${$shouldChangeColor || $isInDialog ? theme['102-rgb'] : theme['100-rgb']},
|
|
22
24
|
${theme.cardBackgroundOpacity}
|
|
23
25
|
);
|
|
24
26
|
`}
|
|
@@ -36,11 +38,12 @@ export const StyledListItem = styled.div`
|
|
|
36
38
|
$isClickable,
|
|
37
39
|
$isInAccordion,
|
|
38
40
|
$shouldChangeColor,
|
|
41
|
+
$isInDialog,
|
|
39
42
|
theme
|
|
40
43
|
}) => $isClickable && !$isInAccordion && css`
|
|
41
44
|
&&:hover {
|
|
42
45
|
background-color: rgba(
|
|
43
|
-
${$shouldChangeColor ? theme['102-rgb'] : theme['100-rgb']},
|
|
46
|
+
${$shouldChangeColor || $isInDialog ? theme['102-rgb'] : theme['100-rgb']},
|
|
44
47
|
${theme.cardBackgroundOpacity}
|
|
45
48
|
);
|
|
46
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.styles.js","names":["styled","css","StyledListItem","div","$isInAccordion","$shouldHideIndicator","$isOpen","$shouldChangeColor","$shouldForceBackground","theme","cardBackgroundOpacity","$backgroundColor","$isClickable","$isWrapped","$shouldHideBottomLine","$shouldForceBottomLine","$shouldShowSeparatorBelow","accordionLines","undefined","StyledListItemTooltip"],"sources":["../../../../../src/components/list/list-item/ListItem.styles.ts"],"sourcesContent":["import type { HTMLMotionProps } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport type { Theme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { CSSProperties } from 'react';\n\ntype StyledListItemProps = HTMLMotionProps<'div'> & {\n $backgroundColor?: CSSProperties['backgroundColor'];\n $isClickable: boolean;\n $isInAccordion: boolean;\n $isOpen: boolean;\n $isWrapped: boolean;\n $shouldChangeColor?: boolean;\n $shouldForceBackground?: boolean;\n $shouldForceBottomLine?: boolean;\n $shouldHideBottomLine: boolean;\n $shouldHideIndicator: boolean;\n $shouldShowSeparatorBelow: boolean;\n};\n\nexport const StyledListItem = styled.div<StyledListItemProps>`\n overflow: hidden;\n transition: background-color 0.3s ease;\n\n ${({ $isInAccordion, $shouldHideIndicator }: StyledListItemProps) =>\n $isInAccordion &&\n css`\n padding-left: ${$shouldHideIndicator ? '16px' : '8px'};\n `}\n\n ${({\n $isInAccordion,\n $isOpen,\n $shouldChangeColor,\n $shouldForceBackground,\n theme,\n }: StyledListItemProps & {\n theme: Theme;\n }) =>\n ((!$isInAccordion && $isOpen) || $shouldForceBackground) &&\n css`\n background-color: rgba(\n ${$shouldChangeColor ? theme['102-rgb'] : theme['100-rgb']},\n ${theme.cardBackgroundOpacity}\n );\n `}\n\n ${({ $backgroundColor, $isInAccordion, $isOpen, $shouldForceBackground }) =>\n $backgroundColor &&\n ((!$isInAccordion && $isOpen) || $shouldForceBackground) &&\n css`\n background-color: ${$backgroundColor} !important;\n `}\n\n ${({\n $isClickable,\n $isInAccordion,\n $shouldChangeColor,\n theme,\n }: StyledListItemProps & {\n theme: Theme;\n }) =>\n $isClickable &&\n !$isInAccordion &&\n css`\n &&:hover {\n background-color: rgba(\n ${$shouldChangeColor ? theme['102-rgb'] : theme['100-rgb']},\n ${theme.cardBackgroundOpacity}\n );\n }\n `}\n\n ${({\n $isInAccordion,\n $isOpen,\n $isWrapped,\n $shouldHideBottomLine,\n $shouldForceBottomLine,\n $shouldShowSeparatorBelow,\n theme,\n }: StyledListItemProps & { theme: Theme }) => {\n if (\n $shouldShowSeparatorBelow ||\n ((!$isOpen || $isWrapped || $isInAccordion) &&\n theme.accordionLines &&\n !$shouldHideBottomLine)\n ) {\n if ($shouldForceBottomLine) {\n return css`\n border-bottom: ${$shouldShowSeparatorBelow ? '4px' : '1px'} solid\n rgba(${theme['headline-rgb']}, 1);\n `;\n }\n\n return css`\n &&:not(:last-child) {\n border-bottom: ${$shouldShowSeparatorBelow ? '4px' : '1px'} solid\n rgba(${theme['headline-rgb']}, 1);\n }\n `;\n }\n\n return undefined;\n }}\n\n ${({ $isWrapped }) =>\n $isWrapped &&\n css`\n padding-left: 26px;\n `}\n`;\n\nexport const StyledListItemTooltip = styled.div`\n padding: 6px;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;
|
|
1
|
+
{"version":3,"file":"ListItem.styles.js","names":["styled","css","StyledListItem","div","$isInAccordion","$shouldHideIndicator","$isOpen","$shouldChangeColor","$shouldForceBackground","theme","$isInDialog","$isSelected","cardBackgroundOpacity","$backgroundColor","$isClickable","$isWrapped","$shouldHideBottomLine","$shouldForceBottomLine","$shouldShowSeparatorBelow","accordionLines","undefined","StyledListItemTooltip"],"sources":["../../../../../src/components/list/list-item/ListItem.styles.ts"],"sourcesContent":["import type { HTMLMotionProps } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport type { Theme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { CSSProperties } from 'react';\n\ntype StyledListItemProps = HTMLMotionProps<'div'> & {\n $backgroundColor?: CSSProperties['backgroundColor'];\n $isClickable: boolean;\n $isInAccordion: boolean;\n $isOpen: boolean;\n $isWrapped: boolean;\n $shouldChangeColor?: boolean;\n $shouldForceBackground?: boolean;\n $shouldForceBottomLine?: boolean;\n $shouldHideBottomLine: boolean;\n $shouldHideIndicator: boolean;\n $shouldShowSeparatorBelow: boolean;\n $isInDialog: boolean;\n $isSelected: boolean;\n};\n\nexport const StyledListItem = styled.div<StyledListItemProps>`\n overflow: hidden;\n transition: background-color 0.3s ease;\n\n ${({ $isInAccordion, $shouldHideIndicator }: StyledListItemProps) =>\n $isInAccordion &&\n css`\n padding-left: ${$shouldHideIndicator ? '16px' : '8px'};\n `}\n\n ${({\n $isInAccordion,\n $isOpen,\n $shouldChangeColor,\n $shouldForceBackground,\n theme,\n $isInDialog,\n $isSelected,\n }: StyledListItemProps & {\n theme: Theme;\n }) =>\n ((!$isInAccordion && $isOpen) || $shouldForceBackground || $isSelected) &&\n css`\n background-color: rgba(\n ${$shouldChangeColor || $isInDialog ? theme['102-rgb'] : theme['100-rgb']},\n ${theme.cardBackgroundOpacity}\n );\n `}\n\n ${({ $backgroundColor, $isInAccordion, $isOpen, $shouldForceBackground }) =>\n $backgroundColor &&\n ((!$isInAccordion && $isOpen) || $shouldForceBackground) &&\n css`\n background-color: ${$backgroundColor} !important;\n `}\n\n ${({\n $isClickable,\n $isInAccordion,\n $shouldChangeColor,\n $isInDialog,\n theme,\n }: StyledListItemProps & {\n theme: Theme;\n }) =>\n $isClickable &&\n !$isInAccordion &&\n css`\n &&:hover {\n background-color: rgba(\n ${$shouldChangeColor || $isInDialog ? theme['102-rgb'] : theme['100-rgb']},\n ${theme.cardBackgroundOpacity}\n );\n }\n `}\n\n ${({\n $isInAccordion,\n $isOpen,\n $isWrapped,\n $shouldHideBottomLine,\n $shouldForceBottomLine,\n $shouldShowSeparatorBelow,\n theme,\n }: StyledListItemProps & { theme: Theme }) => {\n if (\n $shouldShowSeparatorBelow ||\n ((!$isOpen || $isWrapped || $isInAccordion) &&\n theme.accordionLines &&\n !$shouldHideBottomLine)\n ) {\n if ($shouldForceBottomLine) {\n return css`\n border-bottom: ${$shouldShowSeparatorBelow ? '4px' : '1px'} solid\n rgba(${theme['headline-rgb']}, 1);\n `;\n }\n\n return css`\n &&:not(:last-child) {\n border-bottom: ${$shouldShowSeparatorBelow ? '4px' : '1px'} solid\n rgba(${theme['headline-rgb']}, 1);\n }\n `;\n }\n\n return undefined;\n }}\n\n ${({ $isWrapped }) =>\n $isWrapped &&\n css`\n padding-left: 26px;\n `}\n`;\n\nexport const StyledListItemTooltip = styled.div`\n padding: 6px;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAoB/C,OAAO,MAAMC,cAAc,GAAGF,MAAM,CAACG,GAAwB;AAC7D;AACA;AACA;AACA,MAAM,CAAC;EAAEC,cAAc;EAAEC;AAA0C,CAAC,KAC5DD,cAAc,IACdH,GAAG;AACX,4BAA4BI,oBAAoB,GAAG,MAAM,GAAG,KAAK;AACjE,SAAS;AACT;AACA,MAAM,CAAC;EACCD,cAAc;EACdE,OAAO;EACPC,kBAAkB;EAClBC,sBAAsB;EACtBC,KAAK;EACLC,WAAW;EACXC;AAGJ,CAAC,KACG,CAAE,CAACP,cAAc,IAAIE,OAAO,IAAKE,sBAAsB,IAAIG,WAAW,KACtEV,GAAG;AAC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AC;AACL;AACA,MAAM,CAAC;EAAEL;AAAW,CAAC,KACbA,UAAU,IACVd,GAAG;AACX;AACA,SAAS;AACT,CAAC;AAED,OAAO,MAAMoB,qBAAqB,GAAGrB,MAAM,CAACG,GAAG;AAC/C;AACA,CAAC","ignoreList":[]}
|
package/lib/esm/hooks/element.js
CHANGED
|
@@ -157,4 +157,14 @@ export const useIsMeasuredClone = () => {
|
|
|
157
157
|
}, []);
|
|
158
158
|
return [isClone, ref];
|
|
159
159
|
};
|
|
160
|
+
export const useIsInsideDialog = ref => {
|
|
161
|
+
const [isInsideDialog, setIsInsideDialog] = useState(false);
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (!ref.current) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
setIsInsideDialog(ref.current.closest('.dialog-inner') !== null);
|
|
167
|
+
}, [ref]);
|
|
168
|
+
return isInsideDialog;
|
|
169
|
+
};
|
|
160
170
|
//# sourceMappingURL=element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":["React","Children","cloneElement","isValidElement","useEffect","useRef","useState","isSameRect","a","b","width","height","x","y","useElementSize","ref","shouldUseChildElement","shouldUseParentElement","size","setSize","target","current","parentElement","firstElementChild","undefined","frameId","updateSize","nextSize","window","cancelAnimationFrame","requestAnimationFrame","currentSize","getBoundingClientRect","observer","ResizeObserver","entry","contentRect","observe","disconnect","cloneWithTabIndex","node","element","type","Fragment","children","map","props","displayName","createElement","tabIndex","getClonedElement","content","preventEvents","onClick","e","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","useMeasuredClone","shouldPreventTextWrapping","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","userSelect","zIndex","visibility","inert","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute"],"sources":["../../../src/hooks/element.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n HTMLAttributes,\n isValidElement,\n MutableRefObject,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n shouldUseParentElement?: boolean;\n}\n\nconst isSameRect = (a?: DOMRectReadOnly, b?: DOMRectReadOnly) => {\n if (!a || !b) return false;\n\n return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;\n};\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false, shouldUseParentElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n useEffect(() => {\n let target: HTMLElement | null = ref.current;\n\n if (shouldUseParentElement) {\n target = ref.current?.parentElement ?? null;\n }\n\n if (shouldUseChildElement) {\n target = ref.current?.firstElementChild as HTMLElement | null;\n }\n\n if (!target) return undefined;\n\n let frameId: number | undefined;\n\n const updateSize = (nextSize: DOMRectReadOnly) => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n frameId = window.requestAnimationFrame(() => {\n setSize((currentSize) =>\n isSameRect(currentSize, nextSize) ? currentSize : nextSize,\n );\n });\n };\n\n updateSize(target.getBoundingClientRect());\n\n const observer = new ResizeObserver(([entry]) => {\n if (!entry || entry.target !== target) return;\n\n updateSize(entry.contentRect);\n });\n\n observer.observe(target);\n\n return () => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n observer.disconnect();\n };\n }, [ref, shouldUseChildElement, shouldUseParentElement]);\n\n return size;\n};\n\nconst cloneWithTabIndex = (node: ReactNode): ReactNode => {\n if (!isValidElement(node)) return node;\n\n const element = node as ReactElement;\n\n if (element.type === React.Fragment) {\n const children = Children.map(element.props.children, cloneWithTabIndex);\n\n return cloneElement(element, {\n ...element.props,\n children,\n });\n }\n\n const children = element.props.children\n ? Children.map(element.props.children, cloneWithTabIndex)\n : element.props.children;\n\n if ((element.type as any).displayName === 'Button') {\n return (\n // eslint-disable-next-line react/button-has-type\n <button tabIndex={-1}>{children}</button>\n );\n }\n\n return cloneElement(element, {\n ...element.props,\n tabIndex: -1,\n children,\n });\n};\n\nconst getClonedElement = (content: ReactNode) => {\n const preventEvents: Partial<HTMLAttributes<never>> = {\n onClick: (e) => e.stopPropagation(),\n onMouseDown: (e) => e.stopPropagation(),\n onMouseUp: (e) => e.stopPropagation(),\n onKeyDown: (e) => e.stopPropagation(),\n onKeyUp: (e) => e.stopPropagation(),\n onFocus: (e) => e.stopPropagation(),\n onBlur: (e) => e.stopPropagation(),\n };\n\n if (typeof content === 'string') {\n return (\n <span tabIndex={-1} data-measured-clone>\n {content}\n </span>\n );\n }\n\n if (isValidElement(content)) {\n return cloneWithTabIndex(\n cloneElement(content, {\n ...preventEvents,\n 'data-measured-clone': true,\n }),\n );\n }\n\n return content;\n};\n\ninterface UseMeasuredCloneOptions {\n content: ReactNode;\n shouldPreventTextWrapping?: boolean;\n}\n\nexport const useMeasuredClone = ({\n content,\n shouldPreventTextWrapping = true,\n}: UseMeasuredCloneOptions) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const clonedElement = getClonedElement(content);\n\n useEffect(() => {\n const measure = () => {\n if (!ref.current) return;\n\n const { offsetWidth: width, offsetHeight: height } = ref.current;\n\n setSize({ width: width + (shouldPreventTextWrapping ? 10 : 0), height });\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n\n if (ref.current) observer.observe(ref.current);\n\n return () => observer.disconnect();\n }, [shouldPreventTextWrapping]);\n\n const measuredElement = (\n <div\n data-measured-clone=\"true\"\n ref={ref}\n style={{\n position: 'fixed',\n opacity: 0,\n pointerEvents: 'none',\n userSelect: 'none',\n zIndex: -1,\n height: 'auto',\n width: 'auto',\n visibility: 'hidden',\n }}\n inert=\"true\"\n tabIndex={-1}\n >\n {clonedElement}\n </div>\n );\n\n return {\n measuredElement,\n width: size.width,\n height: size.height,\n };\n};\n\nexport const useIsMeasuredClone = <T extends HTMLElement>() => {\n const ref = useRef<T | null>(null);\n\n const [isClone, setIsClone] = useState(false);\n\n useEffect(() => {\n if (!ref.current) return;\n\n let el: HTMLElement | null = ref.current;\n\n while (el) {\n if (el.hasAttribute('data-measured-clone')) {\n setIsClone(true);\n\n return;\n }\n\n el = el.parentElement;\n }\n\n setIsClone(false);\n }, []);\n\n return [isClone, ref] as const;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,QAAQ,EACRC,YAAY,EAEZC,cAAc,EAIdC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACL,OAAO;AAOd,MAAMC,UAAU,GAAGA,CAACC,CAAmB,EAAEC,CAAmB,KAAK;EAC7D,IAAI,CAACD,CAAC,IAAI,CAACC,CAAC,EAAE,OAAO,KAAK;EAE1B,OAAOD,CAAC,CAACE,KAAK,KAAKD,CAAC,CAACC,KAAK,IAAIF,CAAC,CAACG,MAAM,KAAKF,CAAC,CAACE,MAAM,IAAIH,CAAC,CAACI,CAAC,KAAKH,CAAC,CAACG,CAAC,IAAIJ,CAAC,CAACK,CAAC,KAAKJ,CAAC,CAACI,CAAC;AACrF,CAAC;AAED,OAAO,MAAMC,cAAc,GAAGA,CAC1BC,GAA+D,EAC/D;EAAEC,qBAAqB,GAAG,KAAK;EAAEC,sBAAsB,GAAG;AAA6B,CAAC,GAAG,CAAC,CAAC,KAC/D;EAC9B,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGb,QAAQ,CAAkB,CAAC;EAEnDF,SAAS,CAAC,MAAM;IACZ,IAAIgB,MAA0B,GAAGL,GAAG,CAACM,OAAO;IAE5C,IAAIJ,sBAAsB,EAAE;MACxBG,MAAM,GAAGL,GAAG,CAACM,OAAO,EAAEC,aAAa,IAAI,IAAI;IAC/C;IAEA,IAAIN,qBAAqB,EAAE;MACvBI,MAAM,GAAGL,GAAG,CAACM,OAAO,EAAEE,iBAAuC;IACjE;IAEA,IAAI,CAACH,MAAM,EAAE,OAAOI,SAAS;IAE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;IAC1BjC,GAAG,EAAEA,GAAI;IACTsD,KAAK,EAAE;MACHC,QAAQ,EAAE,OAAO;MACjBC,OAAO,EAAE,CAAC;MACVC,aAAa,EAAE,MAAM;MACrBC,UAAU,EAAE,MAAM;MAClBC,MAAM,EAAE,CAAC,CAAC;MACV/D,MAAM,EAAE,MAAM;MACdD,KAAK,EAAE,MAAM;MACbiE,UAAU,EAAE;IAChB,CAAE;IACFC,KAAK,EAAC,MAAM;IACZ3B,QAAQ,EAAE,CAAC;EAAE,GAEZe,aACA,CACR;EAED,OAAO;IACHI,eAAe;IACf1D,KAAK,EAAEQ,IAAI,CAACR,KAAK;IACjBC,MAAM,EAAEO,IAAI,CAACP;EACjB,CAAC;AACL,CAAC;AAED,OAAO,MAAMkE,kBAAkB,GAAGA,CAAA,KAA6B;EAC3D,MAAM9D,GAAG,GAAGV,MAAM,CAAW,IAAI,CAAC;EAElC,MAAM,CAACyE,OAAO,EAAEC,UAAU,CAAC,GAAGzE,QAAQ,CAAC,KAAK,CAAC;EAE7CF,SAAS,CAAC,MAAM;IACZ,IAAI,CAACW,GAAG,CAACM,OAAO,EAAE;IAElB,IAAI2D,EAAsB,GAAGjE,GAAG,CAACM,OAAO;IAExC,OAAO2D,EAAE,EAAE;MACP,IAAIA,EAAE,CAACC,YAAY,CAAC,qBAAqB,CAAC,EAAE;QACxCF,UAAU,CAAC,IAAI,CAAC;QAEhB;MACJ;MAEAC,EAAE,GAAGA,EAAE,CAAC1D,aAAa;IACzB;IAEAyD,UAAU,CAAC,KAAK,CAAC;EACrB,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACD,OAAO,EAAE/D,GAAG,CAAC;AACzB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"element.js","names":["React","Children","cloneElement","isValidElement","useEffect","useRef","useState","isSameRect","a","b","width","height","x","y","useElementSize","ref","shouldUseChildElement","shouldUseParentElement","size","setSize","target","current","parentElement","firstElementChild","undefined","frameId","updateSize","nextSize","window","cancelAnimationFrame","requestAnimationFrame","currentSize","getBoundingClientRect","observer","ResizeObserver","entry","contentRect","observe","disconnect","cloneWithTabIndex","node","element","type","Fragment","children","map","props","displayName","createElement","tabIndex","getClonedElement","content","preventEvents","onClick","e","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","useMeasuredClone","shouldPreventTextWrapping","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","userSelect","zIndex","visibility","inert","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute","useIsInsideDialog","isInsideDialog","setIsInsideDialog","closest"],"sources":["../../../src/hooks/element.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n HTMLAttributes,\n isValidElement,\n MutableRefObject,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n shouldUseParentElement?: boolean;\n}\n\nconst isSameRect = (a?: DOMRectReadOnly, b?: DOMRectReadOnly) => {\n if (!a || !b) return false;\n\n return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;\n};\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false, shouldUseParentElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n useEffect(() => {\n let target: HTMLElement | null = ref.current;\n\n if (shouldUseParentElement) {\n target = ref.current?.parentElement ?? null;\n }\n\n if (shouldUseChildElement) {\n target = ref.current?.firstElementChild as HTMLElement | null;\n }\n\n if (!target) return undefined;\n\n let frameId: number | undefined;\n\n const updateSize = (nextSize: DOMRectReadOnly) => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n frameId = window.requestAnimationFrame(() => {\n setSize((currentSize) =>\n isSameRect(currentSize, nextSize) ? currentSize : nextSize,\n );\n });\n };\n\n updateSize(target.getBoundingClientRect());\n\n const observer = new ResizeObserver(([entry]) => {\n if (!entry || entry.target !== target) return;\n\n updateSize(entry.contentRect);\n });\n\n observer.observe(target);\n\n return () => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n observer.disconnect();\n };\n }, [ref, shouldUseChildElement, shouldUseParentElement]);\n\n return size;\n};\n\nconst cloneWithTabIndex = (node: ReactNode): ReactNode => {\n if (!isValidElement(node)) return node;\n\n const element = node as ReactElement;\n\n if (element.type === React.Fragment) {\n const children = Children.map(element.props.children, cloneWithTabIndex);\n\n return cloneElement(element, {\n ...element.props,\n children,\n });\n }\n\n const children = element.props.children\n ? Children.map(element.props.children, cloneWithTabIndex)\n : element.props.children;\n\n if ((element.type as any).displayName === 'Button') {\n return (\n // eslint-disable-next-line react/button-has-type\n <button tabIndex={-1}>{children}</button>\n );\n }\n\n return cloneElement(element, {\n ...element.props,\n tabIndex: -1,\n children,\n });\n};\n\nconst getClonedElement = (content: ReactNode) => {\n const preventEvents: Partial<HTMLAttributes<never>> = {\n onClick: (e) => e.stopPropagation(),\n onMouseDown: (e) => e.stopPropagation(),\n onMouseUp: (e) => e.stopPropagation(),\n onKeyDown: (e) => e.stopPropagation(),\n onKeyUp: (e) => e.stopPropagation(),\n onFocus: (e) => e.stopPropagation(),\n onBlur: (e) => e.stopPropagation(),\n };\n\n if (typeof content === 'string') {\n return (\n <span tabIndex={-1} data-measured-clone>\n {content}\n </span>\n );\n }\n\n if (isValidElement(content)) {\n return cloneWithTabIndex(\n cloneElement(content, {\n ...preventEvents,\n 'data-measured-clone': true,\n }),\n );\n }\n\n return content;\n};\n\ninterface UseMeasuredCloneOptions {\n content: ReactNode;\n shouldPreventTextWrapping?: boolean;\n}\n\nexport const useMeasuredClone = ({\n content,\n shouldPreventTextWrapping = true,\n}: UseMeasuredCloneOptions) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const clonedElement = getClonedElement(content);\n\n useEffect(() => {\n const measure = () => {\n if (!ref.current) return;\n\n const { offsetWidth: width, offsetHeight: height } = ref.current;\n\n setSize({ width: width + (shouldPreventTextWrapping ? 10 : 0), height });\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n\n if (ref.current) observer.observe(ref.current);\n\n return () => observer.disconnect();\n }, [shouldPreventTextWrapping]);\n\n const measuredElement = (\n <div\n data-measured-clone=\"true\"\n ref={ref}\n style={{\n position: 'fixed',\n opacity: 0,\n pointerEvents: 'none',\n userSelect: 'none',\n zIndex: -1,\n height: 'auto',\n width: 'auto',\n visibility: 'hidden',\n }}\n inert=\"true\"\n tabIndex={-1}\n >\n {clonedElement}\n </div>\n );\n\n return {\n measuredElement,\n width: size.width,\n height: size.height,\n };\n};\n\nexport const useIsMeasuredClone = <T extends HTMLElement>() => {\n const ref = useRef<T | null>(null);\n\n const [isClone, setIsClone] = useState(false);\n\n useEffect(() => {\n if (!ref.current) return;\n\n let el: HTMLElement | null = ref.current;\n\n while (el) {\n if (el.hasAttribute('data-measured-clone')) {\n setIsClone(true);\n\n return;\n }\n\n el = el.parentElement;\n }\n\n setIsClone(false);\n }, []);\n\n return [isClone, ref] as const;\n};\n\nexport const useIsInsideDialog = <T extends HTMLElement>(ref: MutableRefObject<T | null>) => {\n const [isInsideDialog, setIsInsideDialog] = useState(false);\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n setIsInsideDialog(ref.current.closest('.dialog-inner') !== null);\n }, [ref]);\n\n return isInsideDialog;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,QAAQ,EACRC,YAAY,EAEZC,cAAc,EAIdC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACL,OAAO;AAOd,MAAMC,UAAU,GAAGA,CAACC,CAAmB,EAAEC,CAAmB,KAAK;EAC7D,IAAI,CAACD,CAAC,IAAI,CAACC,CAAC,EAAE,OAAO,KAAK;EAE1B,OAAOD,CAAC,CAACE,KAAK,KAAKD,CAAC,CAACC,KAAK,IAAIF,CAAC,CAACG,MAAM,K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ACyE,OAAO,EAAEC,UAAU,CAAC,GAAGzE,QAAQ,CAAC,KAAK,CAAC;EAE7CF,SAAS,CAAC,MAAM;IACZ,IAAI,CAACW,GAAG,CAACM,OAAO,EAAE;IAElB,IAAI2D,EAAsB,GAAGjE,GAAG,CAACM,OAAO;IAExC,OAAO2D,EAAE,EAAE;MACP,IAAIA,EAAE,CAACC,YAAY,CAAC,qBAAqB,CAAC,EAAE;QACxCF,UAAU,CAAC,IAAI,CAAC;QAEhB;MACJ;MAEAC,EAAE,GAAGA,EAAE,CAAC1D,aAAa;IACzB;IAEAyD,UAAU,CAAC,KAAK,CAAC;EACrB,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACD,OAAO,EAAE/D,GAAG,CAAC;AACzB,CAAC;AAED,OAAO,MAAMmE,iBAAiB,GAA2BnE,GAA+B,IAAK;EACzF,MAAM,CAACoE,cAAc,EAAEC,iBAAiB,CAAC,GAAG9E,QAAQ,CAAC,KAAK,CAAC;EAE3DF,SAAS,CAAC,MAAM;IACZ,IAAI,CAACW,GAAG,CAACM,OAAO,EAAE;MACd;IACJ;IAEA+D,iBAAiB,CAACrE,GAAG,CAACM,OAAO,CAACgE,OAAO,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;EACpE,CAAC,EAAE,CAACtE,GAAG,CAAC,CAAC;EAET,OAAOoE,cAAc;AACzB,CAAC","ignoreList":[]}
|
|
@@ -56,6 +56,10 @@ export type ListItemProps = {
|
|
|
56
56
|
* Whether the ListItem locks disabled but has full functionality.
|
|
57
57
|
*/
|
|
58
58
|
isTitleGreyed?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the item is selected.
|
|
61
|
+
*/
|
|
62
|
+
isSelected?: boolean;
|
|
59
63
|
/**
|
|
60
64
|
* Elements that are displayed on the left side of the header. If multiple
|
|
61
65
|
* elements are specified, they are displayed one aside the other.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
-
export declare const StyledListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "slot" | "title" | "content" | "tabIndex" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "exportparts" | "part" | "inert" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | keyof React.ClassAttributes<HTMLDivElement> | "$backgroundColor" | keyof import("motion/react").MotionProps | "$isWrapped" | "$isOpen" | "$shouldForceBackground" | "$shouldHideBottomLine" | "$shouldChangeColor" | "$isClickable" | "$isInAccordion" | "$shouldForceBottomLine" | "$shouldHideIndicator" | "$shouldShowSeparatorBelow"> & {
|
|
2
|
+
export declare const StyledListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "slot" | "title" | "content" | "tabIndex" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "exportparts" | "part" | "inert" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | keyof React.ClassAttributes<HTMLDivElement> | "$backgroundColor" | keyof import("motion/react").MotionProps | "$isWrapped" | "$isOpen" | "$shouldForceBackground" | "$shouldHideBottomLine" | "$isSelected" | "$shouldChangeColor" | "$isClickable" | "$isInAccordion" | "$shouldForceBottomLine" | "$shouldHideIndicator" | "$shouldShowSeparatorBelow" | "$isInDialog"> & {
|
|
3
3
|
ref?: React.LegacyRef<HTMLDivElement> | undefined;
|
|
4
4
|
slot?: string | undefined;
|
|
5
5
|
title?: string | undefined;
|
|
@@ -275,7 +275,9 @@ export declare const StyledListItem: import("styled-components/dist/types").ISty
|
|
|
275
275
|
$shouldHideBottomLine: boolean;
|
|
276
276
|
$shouldHideIndicator: boolean;
|
|
277
277
|
$shouldShowSeparatorBelow: boolean;
|
|
278
|
-
|
|
278
|
+
$isInDialog: boolean;
|
|
279
|
+
$isSelected: boolean;
|
|
280
|
+
}, never> & Partial<Pick<import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "slot" | "title" | "content" | "tabIndex" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "exportparts" | "part" | "inert" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | keyof React.ClassAttributes<HTMLDivElement> | "$backgroundColor" | keyof import("motion/react").MotionProps | "$isWrapped" | "$isOpen" | "$shouldForceBackground" | "$shouldHideBottomLine" | "$isSelected" | "$shouldChangeColor" | "$isClickable" | "$isInAccordion" | "$shouldForceBottomLine" | "$shouldHideIndicator" | "$shouldShowSeparatorBelow" | "$isInDialog"> & {
|
|
279
281
|
ref?: React.LegacyRef<HTMLDivElement> | undefined;
|
|
280
282
|
slot?: string | undefined;
|
|
281
283
|
title?: string | undefined;
|
|
@@ -551,5 +553,7 @@ export declare const StyledListItem: import("styled-components/dist/types").ISty
|
|
|
551
553
|
$shouldHideBottomLine: boolean;
|
|
552
554
|
$shouldHideIndicator: boolean;
|
|
553
555
|
$shouldShowSeparatorBelow: boolean;
|
|
556
|
+
$isInDialog: boolean;
|
|
557
|
+
$isSelected: boolean;
|
|
554
558
|
}, never>>> & string;
|
|
555
559
|
export declare const StyledListItemTooltip: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
|
|
@@ -14,4 +14,5 @@ export declare const useMeasuredClone: ({ content, shouldPreventTextWrapping, }:
|
|
|
14
14
|
height: number;
|
|
15
15
|
};
|
|
16
16
|
export declare const useIsMeasuredClone: <T extends HTMLElement>() => readonly [boolean, React.MutableRefObject<T | null>];
|
|
17
|
+
export declare const useIsInsideDialog: <T extends HTMLElement>(ref: MutableRefObject<T | null>) => boolean;
|
|
17
18
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.9",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "d47204bde2d504689320e48b9f2520bd90338ba6"
|
|
92
92
|
}
|