{"version":3,"file":"AttachmentSelector.mjs","names":[],"sources":["../../../../../src/components/MessageComposer/AttachmentSelector/AttachmentSelector.tsx"],"sourcesContent":["import React, {\n  type ComponentType,\n  forwardRef,\n  useCallback,\n  useEffect,\n  useMemo,\n  useRef,\n  useState,\n} from 'react';\nimport {\n  useAttachmentManagerState,\n  useMessageComposerCommands,\n  useMessageComposerController,\n} from '../hooks';\nimport { CHANNEL_CONTAINER_ID } from '../../Channel/constants';\nimport {\n  ContextMenu,\n  ContextMenuButton,\n  type ContextMenuHeaderComponent,\n  type ContextMenuSubmenu,\n  useContextMenuContext,\n  useDialogIsOpen,\n  useDialogOnNearestManager,\n} from '../../Dialog';\nimport { GlobalModal } from '../../Modal';\nimport { ShareLocationDialog as DefaultLocationDialog } from '../../Location';\nimport { PollCreationDialog as DefaultPollCreationDialog } from '../../Poll';\nimport { Portal } from '../../Portal/Portal';\nimport { UploadFileInput } from '../../ReactFileUtilities';\nimport {\n  useComponentContext,\n  useComponentContextIcons,\n  useTranslationContext,\n} from '../../../context';\nimport {\n  AttachmentSelectorContextProvider,\n  useAttachmentSelectorContext,\n} from '../../../context/AttachmentSelectorContext';\nimport { useStableId } from '../../UtilityComponents/useStableId';\nimport { useInertWhenHidden } from '../../Accessibility';\nimport { useStateStore } from '../../../store';\nimport type { TextComposerState } from 'stream-chat';\nimport clsx from 'clsx';\nimport { Button, type ButtonProps } from '../../Button';\nimport { useIsCooldownActive } from '../hooks/useIsCooldownActive';\nimport {\n  CommandsMenu,\n  CommandsMenuClassName,\n  CommandsSubmenuHeader,\n} from './CommandsMenu';\nimport { useChannelCapabilities } from '../../Channel/hooks/useChannelCapabilities';\nimport type { ChannelConfig } from 'stream-chat';\nimport {\n  type AttachmentSelectorActionAvailabilityContext,\n  canUploadFiles,\n  isAttachmentSelectorActionAvailable,\n} from './attachmentSelectorActionAvailability';\n\nconst availableCommandsStateSelector = ({ availableCommands }: ChannelConfig) => ({\n  availableCommands,\n});\n\nconst textComposerStateSelector = ({ command }: TextComposerState) => ({ command });\n\n/** Collects what the action availability rules read, subscribed so that a change re-renders. */\nconst useAttachmentSelectorActionAvailabilityContext =\n  (): AttachmentSelectorActionAvailabilityContext => {\n    const { attachmentsEnabled, customCdn, locationEnabled, pollsEnabled } =\n      useAttachmentManagerState();\n    const messageComposer = useMessageComposerController();\n    const channelCapabilities = useChannelCapabilities({\n      cid: messageComposer.channel.cid,\n    });\n    const { availableCommands } = useStateStore(\n      messageComposer.channel.configState,\n      availableCommandsStateSelector,\n    );\n\n    return useMemo(\n      () => ({\n        attachmentsEnabled,\n        availableCommands,\n        channelCapabilities,\n        customCdn: !!customCdn,\n        locationEnabled,\n        messageComposer,\n        pollsEnabled,\n      }),\n      [\n        attachmentsEnabled,\n        availableCommands,\n        channelCapabilities,\n        customCdn,\n        locationEnabled,\n        messageComposer,\n        pollsEnabled,\n      ],\n    );\n  };\n\nconst AttachmentSelectorMenuInitButtonIcon = ({ className }: { className?: string }) => {\n  const { AttachmentSelectorInitiationButtonContents } = useComponentContext();\n  const { IconPlus } = useComponentContextIcons();\n\n  if (AttachmentSelectorInitiationButtonContents) {\n    return (\n      <span className={className}>\n        <AttachmentSelectorInitiationButtonContents />\n      </span>\n    );\n  }\n\n  return (\n    <IconPlus\n      className={clsx('str-chat__attachment-selector__menu-button__icon', className)}\n    />\n  );\n};\n\nexport const AttachmentSelectorButton = forwardRef<\n  HTMLButtonElement,\n  ButtonProps & { iconClassName?: string }\n>(function AttachmentSelectorButton({ className, iconClassName, ...props }, ref) {\n  return (\n    <Button\n      appearance='outline'\n      circular\n      className={clsx('str-chat__attachment-selector__menu-button', className)}\n      data-testid='invoke-attachment-selector-button'\n      size='lg'\n      variant='secondary'\n      {...props}\n      ref={ref}\n    >\n      <AttachmentSelectorMenuInitButtonIcon className={iconClassName} />\n    </Button>\n  );\n});\n\nexport type AttachmentSelectorStandaloneButtonProps = {\n  /**\n   * The selector's `buttonProps`, with `disabled` replaced by whether the send cooldown is\n   * active.\n   */\n  buttonProps?: Omit<ButtonProps, 'onClick'>;\n};\n\ntype SimpleAttachmentSelectorProps = AttachmentSelectorStandaloneButtonProps;\n\n/**\n * A button that opens the file picker, rendered whether or not uploads are available and\n * disabled once the message holds as many files as allowed. The default `StandaloneButton` of an\n * `uploadFile` action.\n */\nexport const FileUploadButton = ({\n  buttonProps,\n}: AttachmentSelectorStandaloneButtonProps) => {\n  const { t } = useTranslationContext();\n  const { hasAvailableUploadSlots } = useAttachmentManagerState();\n  const inputRef = useRef<HTMLInputElement | null>(null);\n  const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(null);\n  const id = useStableId();\n\n  useEffect(() => {\n    if (!buttonElement) return;\n    const handleKeyUp = (event: KeyboardEvent) => {\n      if (![' ', 'Enter'].includes(event.key) || !inputRef.current) return;\n      event.preventDefault();\n      inputRef.current.click();\n    };\n    buttonElement.addEventListener('keyup', handleKeyUp);\n    return () => {\n      buttonElement.removeEventListener('keyup', handleKeyUp);\n    };\n  }, [buttonElement]);\n\n  return (\n    <>\n      <AttachmentSelectorButton\n        {...buttonProps}\n        aria-label={t(\n          'messageComposer.attachmentSelector.openAttachmentSelector.ariaLabel',\n          'Open Attachment Selector',\n        )}\n        disabled={buttonProps?.disabled || !hasAvailableUploadSlots}\n        onClick={() => inputRef.current?.click()}\n        ref={setButtonElement}\n      />\n      <UploadFileInput id={id} ref={inputRef} />\n    </>\n  );\n};\n\n/**\n * Renders a lone button in the selector's root element (`.str-chat__attachment-selector`), which\n * the composer layout sizes and hides while a command is active. The button is disabled during\n * the send cooldown.\n */\nconst StandaloneButtonSlot = ({\n  buttonProps,\n  StandaloneButton,\n}: AttachmentSelectorStandaloneButtonProps & {\n  StandaloneButton: ComponentType<AttachmentSelectorStandaloneButtonProps>;\n}) => {\n  const isCooldownActive = useIsCooldownActive();\n  const messageComposer = useMessageComposerController();\n  const { command } = useStateStore(\n    messageComposer.textComposer.state,\n    textComposerStateSelector,\n  );\n  // Hidden by a CSS transition while a command is active. Inert keeps it out of the a11y tree\n  // and tab order without `display: none`, which would break the transition.\n  const inertProps = useInertWhenHidden(!!command, { setHiddenAttribute: false });\n\n  return (\n    <div className='str-chat__attachment-selector' {...inertProps}>\n      <StandaloneButton buttonProps={{ ...buttonProps, disabled: isCooldownActive }} />\n    </div>\n  );\n};\n\n/**\n * A single button that opens the file picker, rendered while files can be uploaded and disabled\n * once the message holds as many files as allowed.\n */\nexport const SimpleAttachmentSelector = ({\n  buttonProps,\n}: SimpleAttachmentSelectorProps = {}) => {\n  const availabilityContext = useAttachmentSelectorActionAvailabilityContext();\n\n  if (!canUploadFiles(availabilityContext)) return null;\n\n  return (\n    <StandaloneButtonSlot buttonProps={buttonProps} StandaloneButton={FileUploadButton} />\n  );\n};\n\nexport type AttachmentSelectorModalContentProps = {\n  close: () => void;\n};\n\nexport type AttachmentSelectorAction = {\n  ActionButton: ComponentType<AttachmentSelectorActionProps>;\n  id?: string;\n  ModalContent?: React.ComponentType<AttachmentSelectorModalContentProps>;\n  Submenu?: ContextMenuSubmenu;\n  Header?: ContextMenuHeaderComponent;\n  /**\n   * Rendered in place of the menu when this is the only action offered, inside the selector's\n   * root element but with no menu or modal. Without it, a lone action is the only item of the\n   * menu. An `uploadFile` action defaults to `FileUploadButton`.\n   */\n  StandaloneButton?: ComponentType<AttachmentSelectorStandaloneButtonProps>;\n  type: 'uploadFile' | 'createPoll' | 'addLocation' | 'selectCommand' | (string & {});\n};\n\nexport type AttachmentSelectorActionProps = {\n  openModalForAction: (actionType: AttachmentSelectorAction['type']) => void;\n  submenuItems?: ContextMenuSubmenu;\n  submenuHeader?: ContextMenuHeaderComponent;\n};\n\nexport const DefaultAttachmentSelectorComponents = {\n  Command({ submenuHeader, submenuItems }: AttachmentSelectorActionProps) {\n    const { t } = useTranslationContext();\n    const { IconCommand } = useComponentContextIcons();\n    const { openSubmenu } = useContextMenuContext();\n    const commands = useMessageComposerCommands();\n    const hasEnabledCommands = commands.some(({ enabled }) => enabled);\n    const hasSubmenu = !!submenuItems;\n\n    return (\n      <ContextMenuButton\n        className='str-chat__attachment-selector-actions-menu__button str-chat__attachment-selector-actions-menu__commands-button'\n        disabled={!hasEnabledCommands}\n        hasSubMenu={hasSubmenu}\n        Icon={IconCommand}\n        onClick={(event) => {\n          if (!hasSubmenu) return;\n          openSubmenu({\n            focusReturnTarget: event.currentTarget,\n            Header: submenuHeader,\n            menuClassName: CommandsMenuClassName,\n            Submenu: submenuItems,\n          });\n        }}\n      >\n        {t('messageComposer.attachmentSelector.commands.text', 'Commands')}\n      </ContextMenuButton>\n    );\n  },\n  File() {\n    const { t } = useTranslationContext();\n    const { IconAttachment } = useComponentContextIcons();\n    const { fileInput } = useAttachmentSelectorContext();\n    const { closeMenu } = useContextMenuContext();\n    const { hasAvailableUploadSlots } = useAttachmentManagerState();\n\n    return (\n      <ContextMenuButton\n        className='str-chat__attachment-selector-actions-menu__button str-chat__attachment-selector-actions-menu__upload-file-button'\n        disabled={!hasAvailableUploadSlots}\n        Icon={IconAttachment}\n        onClick={() => {\n          fileInput?.click();\n          closeMenu();\n        }}\n      >\n        {t('messageComposer.attachmentSelector.file.text', 'File')}\n      </ContextMenuButton>\n    );\n  },\n  Location({ openModalForAction }: AttachmentSelectorActionProps) {\n    const { t } = useTranslationContext();\n    const { IconLocation } = useComponentContextIcons();\n    const { closeMenu } = useContextMenuContext();\n    return (\n      <ContextMenuButton\n        className='str-chat__attachment-selector-actions-menu__button str-chat__attachment-selector-actions-menu__add-location-button'\n        Icon={IconLocation}\n        onClick={() => {\n          openModalForAction('addLocation');\n          closeMenu();\n        }}\n      >\n        {t('common.location.text', 'Location')}\n      </ContextMenuButton>\n    );\n  },\n  Poll({ openModalForAction }: AttachmentSelectorActionProps) {\n    const { t } = useTranslationContext();\n    const { IconPoll } = useComponentContextIcons();\n    const { closeMenu } = useContextMenuContext();\n    return (\n      <ContextMenuButton\n        className='str-chat__attachment-selector-actions-menu__button str-chat__attachment-selector-actions-menu__create-poll-button'\n        Icon={IconPoll}\n        onClick={() => {\n          openModalForAction('createPoll');\n          closeMenu();\n        }}\n      >\n        {t('common.poll.label', 'Poll')}\n      </ContextMenuButton>\n    );\n  },\n};\n\n/** Default actions of the attachment selector menu, listed from the top of the menu down. */\nexport const defaultAttachmentSelectorActionSet: AttachmentSelectorAction[] = [\n  {\n    ActionButton: DefaultAttachmentSelectorComponents.File,\n    type: 'uploadFile',\n  },\n  {\n    ActionButton: DefaultAttachmentSelectorComponents.Poll,\n    type: 'createPoll',\n  },\n  {\n    ActionButton: DefaultAttachmentSelectorComponents.Location,\n    type: 'addLocation',\n  },\n  {\n    ActionButton: DefaultAttachmentSelectorComponents.Command,\n    Header: CommandsSubmenuHeader,\n    Submenu: CommandsMenu,\n    type: 'selectCommand',\n  },\n];\n\nexport type AttachmentSelectorProps = {\n  attachmentSelectorActionSet?: AttachmentSelectorAction[];\n  buttonProps?: Omit<ButtonProps, 'onClick'>;\n  getModalPortalDestination?: () => HTMLElement | null;\n};\n\nconst useAttachmentSelectorActionsFiltered = (original: AttachmentSelectorAction[]) => {\n  const {\n    PollCreationDialog = DefaultPollCreationDialog,\n    ShareLocationDialog = DefaultLocationDialog,\n  } = useComponentContext();\n  const availabilityContext = useAttachmentSelectorActionAvailabilityContext();\n\n  return useMemo(\n    () =>\n      original\n        .filter((action) =>\n          isAttachmentSelectorActionAvailable(action, availabilityContext),\n        )\n        .map((action) => {\n          if (action.type === 'createPoll' && !action.ModalContent) {\n            return { ...action, ModalContent: PollCreationDialog };\n          }\n          if (action.type === 'addLocation' && !action.ModalContent) {\n            return { ...action, ModalContent: ShareLocationDialog };\n          }\n          if (action.type === 'uploadFile' && !action.StandaloneButton) {\n            return { ...action, StandaloneButton: FileUploadButton };\n          }\n          return action;\n        }),\n    [PollCreationDialog, ShareLocationDialog, availabilityContext, original],\n  );\n};\n\nexport const AttachmentSelector = ({\n  attachmentSelectorActionSet = defaultAttachmentSelectorActionSet,\n  buttonProps,\n  getModalPortalDestination,\n}: AttachmentSelectorProps) => {\n  const { t } = useTranslationContext();\n  const { ContextMenu: ContextMenuComponent = ContextMenu, Modal = GlobalModal } =\n    useComponentContext();\n  const messageComposer = useMessageComposerController();\n  const isCooldownActive = useIsCooldownActive();\n  const { command } = useStateStore(\n    messageComposer.textComposer.state,\n    textComposerStateSelector,\n  );\n  // Hidden by a CSS transition while a command is active. Inert keeps it out of the a11y tree\n  // and tab order without `display: none`, which would break the transition.\n  const inertProps = useInertWhenHidden(!!command, { setHiddenAttribute: false });\n  const actions = useAttachmentSelectorActionsFiltered(attachmentSelectorActionSet);\n\n  const menuDialogId = `attachment-actions-menu${messageComposer.threadId ? '-thread' : ''}`;\n  const { dialog: menuDialog, dialogManager } = useDialogOnNearestManager({\n    id: menuDialogId,\n  });\n  const menuDialogIsOpen = useDialogIsOpen(menuDialogId, dialogManager?.id);\n\n  const [modalContentAction, setModalContentActionAction] =\n    useState<AttachmentSelectorAction>();\n  const shouldRestoreFocusToTriggerRef = useRef(false);\n  const openModalForAction = useCallback(\n    (actionType: AttachmentSelectorAction['type']) => {\n      const action = actions.find((a) => a.type === actionType);\n      if (!action?.ModalContent) return;\n      // Reset on open, not on close, so each open starts from a fresh form and cleared fields\n      // do not flash before the modal unmounts.\n      if (actionType === 'createPoll') {\n        messageComposer.pollComposer.initState();\n      }\n      setModalContentActionAction(action);\n    },\n    [actions, messageComposer],\n  );\n\n  const closeModal = useCallback(() => {\n    shouldRestoreFocusToTriggerRef.current = true;\n    setModalContentActionAction(undefined);\n  }, []);\n\n  const StandaloneButton = actions.length === 1 ? actions[0].StandaloneButton : undefined;\n  const rendersMenu = actions.length > 0 && !StandaloneButton;\n\n  // The modal belongs to the menu: it closes once the menu is not rendered or no longer offers\n  // the modal's action, so it does not reappear when the menu returns.\n  useEffect(() => {\n    if (!modalContentAction) return;\n    const modalActionIsOffered =\n      rendersMenu && actions.some(({ type }) => type === modalContentAction.type);\n    if (!modalActionIsOffered) setModalContentActionAction(undefined);\n  }, [actions, modalContentAction, rendersMenu]);\n\n  const [fileInput, setFileInput] = useState<HTMLInputElement | null>(null);\n  const menuButtonRef = useRef<HTMLButtonElement>(null);\n\n  useEffect(() => {\n    if (modalContentAction || !shouldRestoreFocusToTriggerRef.current) return;\n\n    const frame = requestAnimationFrame(() => {\n      shouldRestoreFocusToTriggerRef.current = false;\n      // Restore focus to the trigger only if it fell to <body> when the dialog closed (cancel or\n      // escape). When the content moved focus on purpose, e.g. the poll dialog returning it to\n      // the composer after a send, leave it there so focus does not blip through the trigger.\n      const active = document.activeElement;\n      if (active && active !== document.body) return;\n      menuButtonRef.current?.focus();\n    });\n\n    return () => cancelAnimationFrame(frame);\n  }, [modalContentAction]);\n\n  const contextMenuItems = useMemo(\n    () =>\n      actions.map((action) => (\n        <action.ActionButton\n          key={action.type}\n          openModalForAction={openModalForAction}\n          submenuHeader={action.Header}\n          submenuItems={action.Submenu}\n        />\n      )),\n    [actions, openModalForAction],\n  );\n\n  const getDefaultPortalDestination = useCallback(\n    () => document.getElementById(CHANNEL_CONTAINER_ID),\n    [],\n  );\n\n  if (actions.length === 0) return null;\n\n  // The actions are already filtered by the availability rules, so the StandaloneButton renders\n  // without checking availability again.\n  if (StandaloneButton)\n    return (\n      <StandaloneButtonSlot\n        buttonProps={buttonProps}\n        StandaloneButton={StandaloneButton}\n      />\n    );\n\n  const ModalContent = modalContentAction?.ModalContent;\n  const modalIsOpen = !!ModalContent;\n  return (\n    <AttachmentSelectorContextProvider value={{ fileInput }}>\n      <div className='str-chat__attachment-selector' {...inertProps}>\n        <UploadFileInput ref={setFileInput} />\n        <AttachmentSelectorButton\n          {...buttonProps}\n          aria-expanded={menuDialogIsOpen}\n          aria-haspopup='true'\n          aria-label={t(\n            'messageComposer.attachmentSelector.openAttachmentSelector.ariaLabel',\n            'Open Attachment Selector',\n          )}\n          disabled={isCooldownActive}\n          iconClassName={clsx('str-chat__prepare-rotate45', {\n            'str-chat__rotate45': menuDialogIsOpen,\n          })}\n          onClick={() => menuDialog?.toggle()}\n          ref={menuButtonRef}\n        />\n        <ContextMenuComponent\n          allowFlip\n          aria-label={t(\n            'messageComposer.attachmentSelector.attachmentActions.ariaLabel',\n            'Attachment Actions',\n          )}\n          backLabel={t('common.back.label', 'Back')}\n          className='str-chat__attachment-selector-actions-menu'\n          data-testid='attachment-selector-actions-menu'\n          dialogManagerId={dialogManager?.id}\n          id={menuDialogId}\n          onClose={menuDialog.close}\n          placement='top-start'\n          referenceElement={menuButtonRef.current}\n          tabIndex={-1}\n        >\n          {contextMenuItems}\n        </ContextMenuComponent>\n        <Portal\n          getPortalDestination={getModalPortalDestination ?? getDefaultPortalDestination}\n          isOpen={modalIsOpen}\n        >\n          <Modal\n            className={clsx({\n              'str-chat__create-poll-modal': modalContentAction?.type === 'createPoll',\n              'str-chat__share-location-modal':\n                modalContentAction?.type === 'addLocation',\n            })}\n            // Focus the dialog surface on open, not a field: a field's focus would supersede the\n            // screen reader's dialog announcement. Enter steps into the default field\n            // (`[data-autofocus]`, handled by GlobalModal).\n            initialFocusStrategy='dialog'\n            onClose={closeModal}\n            open={modalIsOpen}\n          >\n            {ModalContent && <ModalContent close={closeModal} />}\n          </Modal>\n        </Portal>\n      </div>\n    </AttachmentSelectorContextProvider>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,IAAM,kCAAkC,EAAE,yBAAwC,EAChF,kBACF;AAEA,IAAM,6BAA6B,EAAE,eAAkC,EAAE,QAAQ;;AAGjF,IAAM,uDAC+C;CACjD,MAAM,EAAE,oBAAoB,WAAW,iBAAiB,iBACtD,0BAA0B;CAC5B,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,sBAAsB,uBAAuB,EACjD,KAAK,gBAAgB,QAAQ,IAC/B,CAAC;CACD,MAAM,EAAE,sBAAsB,cAC5B,gBAAgB,QAAQ,aACxB,8BACF;CAEA,OAAO,eACE;EACL;EACA;EACA;EACA,WAAW,CAAC,CAAC;EACb;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;E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