'use client'; import React, { Ref, forwardRef, useMemo } from 'react'; import { mergeProps, useFocusRing } from 'react-aria'; import { useBreakpoint } from '../../hook/breakpoints.hook.js'; import { resolveResponsiveVariant } from '../../utils/breakpoint.util.js'; import { ArrowRightIcon } from '../icon/index.js'; import { FlexiCellAdornment, FlexiCellBody } from './components/index.js'; import { styles as flexiCellStyles } from './flexi-cell.styles.js'; import { type FlexiCellProps } from './flexi-cell.types.js'; function FlexiCellBase( { className, tag: Tag = 'div', children, before, after, withArrow, withBorder = false, href, dualAction = false, topBadge: TopBadge, size = 'default', disabled, tabIndex, body = true, ...props }: FlexiCellProps, ref: Ref, ) { const { isFocusVisible, focusProps } = useFocusRing(); const breakpoint = useBreakpoint(); const styles = flexiCellStyles({ className, isLink: !!href, isFocusVisible, shouldHoverEffect: !withBorder && !dualAction, withBorder: resolveResponsiveVariant(withBorder, breakpoint), size: resolveResponsiveVariant(size, breakpoint), }); const content = useMemo(() => { if (dualAction && href) { return ( {children} ); } return body ? {children} :
{children}
; }, [body, children, dualAction, href]); return ( {TopBadge && (
)} {before} {content} {after} {withArrow && ( )}
); } export const FlexiCell = forwardRef(FlexiCellBase); FlexiCell.displayName = 'FlexiCell';