{"version":3,"file":"ListItemLayout.mjs","names":[],"sources":["../../../../src/components/ListItemLayout/ListItemLayout.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport type {\n  ComponentProps,\n  ComponentType,\n  ElementType,\n  HTMLAttributes,\n  ReactNode,\n} from 'react';\nimport React from 'react';\n\nexport type ListItemLayoutRootElement = Extract<\n  keyof React.JSX.IntrinsicElements,\n  keyof HTMLElementTagNameMap\n>;\n\nexport type ListItemLayoutBaseProps = {\n  ContentSlot?: ComponentType<ListItemLayoutContentProps>;\n  contentClassName?: string;\n  description?: ReactNode;\n  descriptionClassName?: string;\n  destructive?: boolean;\n  LeadingIcon?: ComponentType;\n  LeadingSlot?: ComponentType;\n  selected?: boolean;\n  subtitle?: ReactNode;\n  subtitleClassName?: string;\n  title: ReactNode;\n  titleClassName?: string;\n  TrailingIcon?: ComponentType;\n  TrailingSlot?: ComponentType;\n};\n\nexport type ListItemLayoutProps<RootElement extends ListItemLayoutRootElement = 'div'> =\n  ListItemLayoutBaseProps & {\n    RootElement?: RootElement;\n    rootProps?: Omit<ComponentProps<RootElement>, 'children'>;\n  };\n\nexport const ListItemLayout = <RootElement extends ListItemLayoutRootElement = 'div'>({\n  ContentSlot = ListItemLayoutContent,\n  contentClassName,\n  description,\n  descriptionClassName,\n  destructive,\n  LeadingIcon,\n  LeadingSlot,\n  RootElement,\n  rootProps,\n  selected,\n  subtitle,\n  subtitleClassName,\n  title,\n  titleClassName,\n  TrailingIcon,\n  TrailingSlot,\n}: ListItemLayoutProps<RootElement>) => {\n  // The inner container is the interactive element. The outer wrapper only adds spacing, so the\n  // container's focus ring (2px offset) neither overlaps neighbors nor gets clipped by an ancestor.\n  const ContainerComponent = (RootElement ?? 'div') as ElementType<\n    HTMLAttributes<HTMLElement>\n  >;\n  const containerProps = {\n    ...(ContainerComponent === 'button' ? { type: 'button' } : undefined),\n    ...rootProps,\n    className: clsx(\n      'str-chat__list-item-layout__container',\n      rootProps?.className,\n      destructive && 'str-chat__list-item-layout__container--destructive',\n      selected && 'str-chat__list-item-layout__container--selected',\n    ),\n  } as HTMLAttributes<HTMLElement>;\n\n  return (\n    <div className='str-chat__list-item-layout'>\n      <ContainerComponent {...containerProps}>\n        {LeadingIcon && (\n          <div className='str-chat__list-item-layout__leading-icon'>\n            <LeadingIcon />\n          </div>\n        )}\n        {LeadingSlot && <LeadingSlot />}\n        <ContentSlot\n          className={contentClassName}\n          description={description}\n          descriptionClassName={descriptionClassName}\n          subtitle={subtitle}\n          subtitleClassName={subtitleClassName}\n          title={title}\n          titleClassName={titleClassName}\n        />\n        {TrailingIcon && (\n          <div className='str-chat__list-item-layout__trailing-icon'>\n            <TrailingIcon />\n          </div>\n        )}\n        {TrailingSlot && <TrailingSlot />}\n      </ContainerComponent>\n    </div>\n  );\n};\n\nexport type ListItemLayoutContentProps = Omit<ComponentProps<'div'>, 'title'> & {\n  description?: ReactNode;\n  descriptionClassName?: string;\n  subtitle?: ReactNode;\n  subtitleClassName?: string;\n  title: ReactNode;\n  titleClassName?: string;\n};\n\nexport const ListItemLayoutContent = ({\n  className,\n  description,\n  descriptionClassName,\n  subtitle,\n  subtitleClassName,\n  title,\n  titleClassName,\n  ...props\n}: ListItemLayoutContentProps) => (\n  <div\n    {...props}\n    className={clsx('str-chat__list-item-layout__content', className, {\n      'str-chat__list-item-layout__content--withDescription': description,\n      'str-chat__list-item-layout__content--withSubtitle': subtitle,\n      'str-chat__list-item-layout__content--withTitle': title,\n    })}\n  >\n    {title && (\n      <div className={clsx('str-chat__list-item-layout__title', titleClassName)}>\n        {title}\n      </div>\n    )}\n    {subtitle && (\n      <div className={clsx('str-chat__list-item-layout__subtitle', subtitleClassName)}>\n        {subtitle}\n      </div>\n    )}\n    {description && (\n      <div\n        className={clsx('str-chat__list-item-layout__description', descriptionClassName)}\n      >\n        {description}\n      </div>\n    )}\n  </div>\n);\n"],"mappings":";;;;AAsCA,IAAa,kBAAyE,EACpF,cAAc,uBACd,kBACA,aACA,sBACA,aACA,aACA,aACA,aACA,WACA,UACA,UACA,mBACA,OACA,gBACA,cACA,mBACsC;CAGtC,MAAM,qBAAsB,eAAe;CAc3C,OACE,oBAAC,OAAD;EAAK,WAAU;YACb,qBAAC,oBAAD;GAZF,GAAI,uBAAuB,WAAW,EAAE,MAAM,SAAS,IAAI,KAAA;GAC3D,GAAG;GACH,WAAW,KACT,yCACA,WAAW,WACX,eAAe,sDACf,YAAY,iDACd;aAKE;IACG,eACC,oBAAC,OAAD;KAAK,WAAU;eACb,oBAAC,aAAD,CAAc,CAAA;IACX,CAAA;IAEN,eAAe,oBAAC,aAAD,CAAc,CAAA;IAC9B,oBAAC,aAAD;KACE,WAAW;KACE;KACS;KACZ;KACS;KACZ;KACS;IACjB,CAAA;IACA,gBACC,oBAAC,OAAD;KAAK,WAAU;eACb,oBAAC,cAAD,CAAe,CAAA;IACZ,CAAA;IAEN,gBAAgB,oBAAC,cAAD,CAAe,CAAA;GACd;;CACjB,CAAA;AAET;AAWA,IAAa,yBAAyB,EACpC,WACA,aACA,sBACA,UACA,mBACA,OACA,gBACA,GAAG,YAEH,qBAAC,OAAD;CACE,GAAI;CACJ,WAAW,KAAK,uCAAuC,WAAW;EAChE,wDAAwD;EACxD,qDAAqD;EACrD,kDAAkD;CACpD,CAAC;WANH;EAQG,SACC,oBAAC,OAAD;GAAK,WAAW,KAAK,qCAAqC,cAAc;aACrE;EACE,CAAA;EAEN,YACC,oBAAC,OAAD;GAAK,WAAW,KAAK,wCAAwC,iBAAiB;aAC3E;EACE,CAAA;EAEN,eACC,oBAAC,OAAD;GACE,WAAW,KAAK,2CAA2C,oBAAoB;aAE9E;EACE,CAAA;CAEJ"}