{"version":3,"file":"UserItem.mjs","names":[],"sources":["../../../../../../src/components/TextareaComposer/SuggestionList/MentionItem/UserItem.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, { useMemo } from 'react';\nimport type { UserSuggestion } from 'stream-chat';\nimport { Avatar as DefaultAvatar } from '../../../Avatar';\nimport { extractDisplayInfo as defaultExtractDisplayInfo } from '../../../Avatar/utils';\nimport { ListItemLayout } from '../../../ListItemLayout';\nimport { useComponentContext } from '../../../../context';\nimport type { MentionItemComponentProps } from './types';\nimport {\n  type TokenizedSuggestionDisplayName,\n  TokenizedSuggestionParts,\n} from '../TokenizedSuggestionParts';\n\ntype LegacyUserSuggestionEntity = {\n  tokenizedDisplayName: TokenizedSuggestionDisplayName;\n  id?: string;\n  image?: string;\n  mentionType?: 'user';\n  name?: string;\n};\n\nexport type UserItemProps = MentionItemComponentProps<\n  LegacyUserSuggestionEntity | UserSuggestion\n>;\n\n/** User row of the mention suggestion list. */\nexport const UserItem = ({ entity, focused, ...buttonProps }: UserItemProps) => {\n  const { Avatar = DefaultAvatar, extractDisplayInfo = defaultExtractDisplayInfo } =\n    useComponentContext();\n  const hasEntity = !!Object.keys(entity).length;\n\n  const titleAttribute = entity.name || entity.id || '';\n  const LeadingSlot = useMemo(() => {\n    const displayInfo = extractDisplayInfo({ user: entity });\n\n    return function UserItemAvatar() {\n      // Decorative: the option's accessible name already carries the user's name.\n      return <Avatar {...displayInfo} aria-hidden size='md' />;\n    };\n  }, [Avatar, entity, extractDisplayInfo]);\n\n  if (!hasEntity) return null;\n\n  return (\n    <ListItemLayout\n      contentClassName='str-chat__context-menu__button__label'\n      LeadingSlot={LeadingSlot}\n      RootElement='button'\n      rootProps={{\n        ...buttonProps,\n        className: clsx(\n          'str-chat__context-menu__button',\n          'str-chat__user-context-menu__button',\n          buttonProps.className,\n          'str-chat__suggestion-list__mention',\n        ),\n        role: buttonProps.role ?? 'menuitem',\n        title: titleAttribute,\n      }}\n      selected={focused}\n      title={\n        <TokenizedSuggestionParts tokenizedDisplayName={entity.tokenizedDisplayName} />\n      }\n      titleClassName='str-chat__suggestion-list__mention-item-title'\n    />\n  );\n};\n"],"mappings":";;;;;;;;;;AA0BA,IAAa,YAAY,EAAE,QAAQ,SAAS,GAAG,kBAAiC;CAC9E,MAAM,EAAE,QAAA,WAAS,QAAe,oBAAA,uBAAqB,uBACnD,oBAAoB;CACtB,MAAM,YAAY,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC;CAExC,MAAM,iBAAiB,OAAO,QAAQ,OAAO,MAAM;CACnD,MAAM,cAAc,cAAc;EAChC,MAAM,cAAc,qBAAmB,EAAE,MAAM,OAAO,CAAC;EAEvD,OAAO,SAAS,iBAAiB;GAE/B,OAAO,oBAAC,UAAD;IAAQ,GAAI;IAAa,eAAA;IAAY,MAAK;GAAM,CAAA;EACzD;CACF,GAAG;EAAC;EAAQ;EAAQ;CAAkB,CAAC;CAEvC,IAAI,CAAC,WAAW,OAAO;CAEvB,OACE,oBAAC,gBAAD;EACE,kBAAiB;EACJ;EACb,aAAY;EACZ,WAAW;GACT,GAAG;GACH,WAAW,KACT,kCACA,uCACA,YAAY,WACZ,oCACF;GACA,MAAM,YAAY,QAAQ;GAC1B,OAAO;EACT;EACA,UAAU;EACV,OACE,oBAAC,0BAAD,EAA0B,sBAAsB,OAAO,qBAAuB,CAAA;EAEhF,gBAAe;CAChB,CAAA;AAEL"}