{"version":3,"file":"TextareaComposer.mjs","names":[],"sources":["../../../../src/components/TextareaComposer/TextareaComposer.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, {\n  type ChangeEventHandler,\n  type SyntheticEvent,\n  type TextareaHTMLAttributes,\n  type UIEventHandler,\n  useCallback,\n  useEffect,\n  useLayoutEffect,\n  useRef,\n  useState,\n} from 'react';\nimport Textarea from 'react-textarea-autosize';\nimport { useCooldownRemaining } from '../MessageComposer/hooks/useCooldownRemaining';\nimport { useMessageComposerCommands } from '../MessageComposer/hooks/useMessageComposerCommands';\nimport { useMessageComposerController } from '../MessageComposer/hooks/useMessageComposerController';\nimport type {\n  AttachmentManagerState,\n  MessageComposerConfig,\n  MessageComposerState,\n  SearchSourceState,\n  TextComposerState,\n} from 'stream-chat';\nimport {\n  useComponentContext,\n  useMessageComposerContext,\n  useTranslationContext,\n} from '../../context';\nimport { useStateStore } from '../../store';\nimport { useStableId } from '../UtilityComponents/useStableId';\nimport {\n  SuggestionList as DefaultSuggestionList,\n  hasEnabledCommandSuggestions,\n} from './SuggestionList';\nimport { useTextareaPlaceholder } from './hooks/useTextareaPlaceholder';\nimport { useAriaLiveAnnouncer, useInteractionAnnouncements } from '../Accessibility';\nimport { useMessageComposerHasSendableData } from '../MessageComposer/hooks/useMessageComposerHasSendableData';\nimport { useMessageComposerSubmitFn } from '../MessageComposer/hooks/useMessageComposerSubmitFn';\n\nconst textComposerStateSelector = (state: TextComposerState) => ({\n  selection: state.selection,\n  suggestions: state.suggestions,\n  text: state.text,\n});\n\nconst searchSourceStateSelector = (state: SearchSourceState) => ({\n  isLoadingItems: state.isLoading,\n  items: state.items,\n});\n\nconst configStateSelector = (state: MessageComposerConfig) => ({\n  enabled: state.text.enabled,\n});\n\nconst messageComposerStateSelector = (state: MessageComposerState) => ({\n  quotedMessage: state.quotedMessage,\n});\n\nconst attachmentManagerStateSelector = (state: AttachmentManagerState) => ({\n  attachments: state.attachments,\n});\n\n/**\n * Enter without Shift submits. The `isComposing` check prevents double submissions while an IME\n * composes text, e.g. in Korean\n * (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing).\n */\nconst defaultShouldSubmit = (event: React.KeyboardEvent<HTMLTextAreaElement>) =>\n  event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing;\n\nexport const shouldBackspaceExitCommandMode = (text: string) => text.length === 0;\n\nexport type TextareaComposerProps = Omit<\n  TextareaHTMLAttributes<HTMLTextAreaElement>,\n  'style' | 'defaultValue' | 'disabled' | 'value'\n> & {\n  closeSuggestionsOnClickOutside?: boolean;\n  containerClassName?: string;\n  listClassName?: string;\n  maxRows?: number;\n  minRows?: number;\n  shouldSubmit?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => boolean;\n};\n\n/**\n * Textarea of the message composer, with autocomplete suggestions and screen reader announcements.\n * Announcements go to the nearest `AriaLiveOutlet`: the root outlet in `Chat`, or a modal outlet\n * inside an `aria-modal` dialog, because assistive technologies ignore live regions outside the\n * active modal.\n */\nexport const TextareaComposer = (props: TextareaComposerProps) => (\n  <TextareaComposerWithLiveAnnouncements {...props} />\n);\n\nconst TextareaComposerWithLiveAnnouncements = ({\n  className,\n  closeSuggestionsOnClickOutside,\n  containerClassName,\n  listClassName,\n  maxRows: maxRowsProp,\n  minRows: minRowsProp,\n  onBlur,\n  onChange,\n  onKeyDown,\n  onPaste: onPasteProp,\n  onScroll,\n  onSelect,\n  placeholder: placeholderProp,\n  shouldSubmit: shouldSubmitProp,\n  ...restTextareaProps\n}: TextareaComposerProps) => {\n  const { AutocompleteSuggestionList = DefaultSuggestionList } = useComponentContext();\n  const {\n    additionalTextareaProps,\n    focus,\n    maxRows: maxRowsContext,\n    minRows: minRowsContext,\n    onPaste,\n    shouldSubmit: shouldSubmitContext,\n    textareaRef,\n  } = useMessageComposerContext();\n  const cooldownRemaining = useCooldownRemaining();\n\n  const { t } = useTranslationContext();\n  const placeholder = useTextareaPlaceholder({ placeholder: placeholderProp });\n  const announce = useAriaLiveAnnouncer();\n  const { announceInteraction } = useInteractionAnnouncements();\n\n  const maxRows = maxRowsProp ?? maxRowsContext ?? 10;\n  const minRows = minRowsProp ?? minRowsContext;\n\n  const shouldSubmit = shouldSubmitProp ?? shouldSubmitContext ?? defaultShouldSubmit;\n\n  const messageComposer = useMessageComposerController();\n  // Read through the hook, not off the composer, so Enter-to-submit agrees with the send button.\n  const hasSendableData = useMessageComposerHasSendableData();\n  const { textComposer } = messageComposer;\n  const { selection, suggestions, text } = useStateStore(\n    textComposer.state,\n    textComposerStateSelector,\n  );\n  // Explicit accessible name, so the field does not inherit an unrelated one from an ancestor.\n  // Empty: the visible placeholder. With content: a stable label, because the placeholder may be a\n  // command-specific template that would be re-announced as a stale name.\n  const ariaLabel = text\n    ? t('textareaComposer.messageInput.ariaLabel', 'Message input')\n    : placeholder;\n\n  // react-textarea-autosize can measure the placeholder as multi-line in narrow layouts, inflating\n  // the initial height. Clamp to one row while empty unless `minRows` is set.\n  const autosizeRows = !text && minRows == null ? 1 : undefined;\n  const textareaStyle = text\n    ? undefined\n    : ({\n        overflow: 'hidden',\n        textOverflow: 'ellipsis',\n        whiteSpace: 'nowrap',\n      } satisfies React.CSSProperties);\n  const submitMessage = useMessageComposerSubmitFn();\n\n  const { enabled } = useStateStore(messageComposer.configState, configStateSelector);\n  const { quotedMessage } = useStateStore(\n    messageComposer.state,\n    messageComposerStateSelector,\n  );\n  const { attachments } = useStateStore(\n    messageComposer.attachmentManager.state,\n    attachmentManagerStateSelector,\n  );\n\n  const { isLoadingItems, items } =\n    useStateStore(suggestions?.searchSource.state, searchSourceStateSelector) ?? {};\n\n  const containerRef = useRef<HTMLDivElement>(null);\n  const [focusedItemIndex, setFocusedItemIndex] = useState(0);\n  // Whether the active option was reached with the arrow keys in the current suggestion session.\n  // Filtering resets `focusedItemIndex` to 0 on every keystroke, so always exposing\n  // `aria-activedescendant` would make screen readers re-read the first option per character. It is\n  // cleared on typing (see `changeHandler`), and the debounced suggestion count covers typing.\n  const [activeOptionFromKeyboard, setActiveOptionFromKeyboard] = useState(false);\n\n  // The list is a `listbox` whose active `option` this field tracks through `aria-controls` and\n  // `aria-activedescendant`, with no `role=\"combobox\"` or `aria-expanded` because axe rejects them\n  // on a multiline textarea. `aria-controls` is set while the list is open, `aria-activedescendant`\n  // only after keyboard navigation. \"Open\" matches what `SuggestionList` renders, so neither\n  // attribute dangles. `listboxId` lives here because the attributes are on the textarea; the list\n  // derives option IDs as `{listboxId}-option-{index}`.\n  const listboxId = useStableId();\n  const commands = useMessageComposerCommands();\n  const suggestionsOpen = !!(\n    suggestions &&\n    items?.length &&\n    hasEnabledCommandSuggestions({ commands, type: suggestions?.searchSource.type })\n  );\n  const activeDescendantId =\n    suggestionsOpen && activeOptionFromKeyboard\n      ? `${listboxId}-option-${focusedItemIndex}`\n      : undefined;\n\n  const [isComposing, setIsComposing] = useState(false);\n\n  const changeHandler: ChangeEventHandler<HTMLTextAreaElement> = useCallback(\n    (e) => {\n      // Typing resets the highlight to the first item; stop exposing the active option until the\n      // next arrow key so screen readers do not re-read it on every keystroke.\n      setActiveOptionFromKeyboard(false);\n      if (onChange) {\n        onChange(e);\n        return;\n      }\n      if (!textareaRef.current) return;\n      textComposer.handleChange({\n        selection: {\n          end: textareaRef.current.selectionEnd,\n          start: textareaRef.current.selectionStart,\n        },\n        text: e.target.value,\n      });\n    },\n    [onChange, textComposer, textareaRef],\n  );\n\n  const onCompositionEnd = useCallback(() => {\n    setIsComposing(false);\n  }, []);\n\n  const onCompositionStart = useCallback(() => {\n    setIsComposing(true);\n  }, []);\n\n  const keyDownHandler = useCallback(\n    (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n      if (onKeyDown) {\n        onKeyDown(event);\n        return;\n      }\n\n      // The composer state is a step behind, so read the textarea value directly.\n      const textareaValue = textareaRef.current?.value ?? event.currentTarget.value;\n\n      if (\n        textComposer.suggestions &&\n        textComposer.suggestions.searchSource.items?.length\n      ) {\n        if (event.key === 'Escape') return textComposer.closeSuggestions();\n        // `focusedItemIndex` indexes the same `searchSource.items` array the list renders, so the\n        // option announced to screen readers is the one Enter inserts.\n        const loadedItems = textComposer.suggestions.searchSource.items;\n        if (event.key === 'Enter') {\n          event.preventDefault();\n          const selectedItem = loadedItems[focusedItemIndex];\n          if (selectedItem) {\n            textComposer.handleSelect(selectedItem);\n          }\n        }\n        if (event.key === 'ArrowUp') {\n          event.preventDefault();\n          setActiveOptionFromKeyboard(true);\n          setFocusedItemIndex((prev) => {\n            let nextIndex = prev - 1;\n            if (nextIndex < 0) {\n              nextIndex = loadedItems.length - 1;\n            }\n            return nextIndex;\n          });\n        }\n        if (event.key === 'ArrowDown') {\n          event.preventDefault();\n          setActiveOptionFromKeyboard(true);\n          setFocusedItemIndex((prev) => {\n            let nextIndex = prev + 1;\n            if (nextIndex >= loadedItems.length) {\n              nextIndex = 0;\n            }\n\n            return nextIndex;\n          });\n        }\n      } else if (\n        textComposer.command &&\n        (event.key === 'Escape' ||\n          (event.key === 'Backspace' && shouldBackspaceExitCommandMode(textareaValue)))\n      ) {\n        event.preventDefault();\n        textComposer.clearCommand();\n      } else if (shouldSubmit(event) && textareaRef.current && hasSendableData) {\n        if (event.key === 'Enter') {\n          // prevent inserting a newline when submitting with Enter\n          event.preventDefault();\n        }\n        submitMessage();\n      }\n    },\n    [\n      focusedItemIndex,\n      hasSendableData,\n      onKeyDown,\n      shouldSubmit,\n      submitMessage,\n      textComposer,\n      textareaRef,\n    ],\n  );\n\n  // A custom `onPaste` (the prop, else `additionalTextareaProps.onPaste`) runs first; calling\n  // `event.preventDefault()` in it skips the default handling.\n  const customOnPaste = onPasteProp ?? additionalTextareaProps?.onPaste;\n  const pasteHandler = useCallback(\n    (event: React.ClipboardEvent<HTMLTextAreaElement>) => {\n      customOnPaste?.(event);\n      if (event.isDefaultPrevented()) return;\n      onPaste(event);\n    },\n    [customOnPaste, onPaste],\n  );\n\n  const scrollHandler: UIEventHandler<HTMLTextAreaElement> = useCallback(\n    (event) => {\n      if (onScroll) {\n        onScroll(event);\n      } else {\n        textComposer.closeSuggestions();\n      }\n    },\n    [onScroll, textComposer],\n  );\n\n  const setSelection = useCallback(\n    (e: SyntheticEvent<HTMLTextAreaElement>) => {\n      onSelect?.(e);\n      textComposer.setSelection({\n        end: (e.target as HTMLTextAreaElement).selectionEnd,\n        start: (e.target as HTMLTextAreaElement).selectionStart,\n      });\n    },\n    [onSelect, textComposer],\n  );\n\n  useEffect(() => {\n    if (textComposer.suggestions) {\n      setFocusedItemIndex(0);\n    }\n  }, [textComposer.suggestions]);\n\n  useEffect(() => {\n    const suggestionItems = suggestions?.searchSource.items;\n    if (!suggestionItems?.length) return;\n\n    setFocusedItemIndex((prev) =>\n      prev >= suggestionItems.length ? suggestionItems.length - 1 : prev,\n    );\n  }, [suggestions?.searchSource.items]);\n\n  useEffect(() => {\n    const textareaIsFocused = textareaRef.current?.matches(':focus');\n    if (!textareaRef.current || textareaIsFocused || !focus) return;\n    textareaRef.current.focus();\n  }, [attachments, focus, quotedMessage, textareaRef]);\n\n  // Announces command activation (e.g. `/giphy`) only while the textarea is focused: otherwise the\n  // focus shift that follows already makes assistive technology re-announce the field. Subscribed\n  // synchronously so the `activeElement` check runs before that `focus()` call, and deferred to\n  // `requestAnimationFrame` so the DOM already carries the command-specific placeholder.\n  useEffect(() => {\n    const pendingFrames = new Set<number>();\n    const unsubscribe = textComposer.state.subscribeWithSelector(\n      (state) => ({ commandName: state.command?.name ?? null }),\n      ({ commandName }, previous) => {\n        if (!previous) return;\n        if (!commandName || commandName === previous.commandName) return;\n        if (document.activeElement !== textareaRef.current) return;\n\n        const frame = window.requestAnimationFrame(() => {\n          pendingFrames.delete(frame);\n          const label = textareaRef.current?.placeholder;\n          if (label) announce(label, { priority: 'polite' });\n        });\n        pendingFrames.add(frame);\n      },\n    );\n    return () => {\n      unsubscribe();\n      pendingFrames.forEach(window.cancelAnimationFrame);\n    };\n  }, [announce, textComposer.state, textareaRef]);\n\n  // Announces a user picked from the @-mention autocomplete, only when a new user is appended. The\n  // count lives in a ref because the listener can run more than once per selection, and the\n  // per-call `previous` would make each run see growth and announce twice.\n  const lastMentionCountRef = useRef<number | null>(null);\n  useEffect(() => {\n    lastMentionCountRef.current =\n      textComposer.state.getLatestValue().mentionedUsers?.length ?? 0;\n    const unsubscribe = textComposer.state.subscribeWithSelector(\n      (state) => ({ mentionedUsers: state.mentionedUsers }),\n      ({ mentionedUsers }) => {\n        const previousCount = lastMentionCountRef.current ?? mentionedUsers.length;\n        lastMentionCountRef.current = mentionedUsers.length;\n        if (mentionedUsers.length <= previousCount) return;\n        const addedUser = mentionedUsers[mentionedUsers.length - 1];\n        if (!addedUser) return;\n        announceInteraction('user.selected', { user: addedUser.name ?? addedUser.id });\n      },\n    );\n    return unsubscribe;\n  }, [announceInteraction, textComposer.state]);\n\n  useLayoutEffect(() => {\n    // Set the text and then the range in the same effect, or the cursor resets to the end.\n    const textarea = textareaRef.current;\n    if (!textarea || isComposing) return;\n\n    // The value is set here, not through a `value` prop: that would stop `compositionend` from\n    // firing and block composed characters (ô), while no override at all would drop text changes\n    // from middleware (e.g. replacing characters with emojis).\n    if (textarea.value !== text) {\n      textarea.value = text;\n    }\n\n    const length = textarea.value.length;\n    const start = Math.max(0, Math.min(selection.start, length));\n    const end = Math.max(start, Math.min(selection.end, length));\n\n    if (textarea.selectionStart === start && textarea.selectionEnd === end) return;\n\n    textarea.setSelectionRange(start, end, 'forward');\n  }, [text, selection.start, selection.end, isComposing, textareaRef]);\n\n  return (\n    <div\n      className={clsx('rta', 'str-chat__textarea', containerClassName, {\n        ['rta--loading']: isLoadingItems,\n      })}\n      ref={containerRef}\n    >\n      <Textarea\n        {...{ ...additionalTextareaProps, ...restTextareaProps }}\n        aria-activedescendant={activeDescendantId}\n        aria-autocomplete='list'\n        aria-controls={suggestionsOpen ? listboxId : undefined}\n        aria-label={ariaLabel}\n        className={clsx(\n          'rta__textarea',\n          'str-chat__textarea__textarea str-chat__message-textarea',\n          additionalTextareaProps?.className,\n          className,\n        )}\n        data-testid='message-input'\n        disabled={!enabled || !!cooldownRemaining}\n        maxRows={autosizeRows ?? maxRows}\n        minRows={autosizeRows ?? minRows}\n        onBlur={onBlur}\n        onChange={changeHandler}\n        onCompositionEnd={onCompositionEnd}\n        onCompositionStart={onCompositionStart}\n        onKeyDown={keyDownHandler}\n        onPaste={pasteHandler}\n        onScroll={scrollHandler}\n        onSelect={setSelection}\n        placeholder={placeholder}\n        ref={(ref) => {\n          textareaRef.current = ref;\n        }}\n        style={textareaStyle}\n      />\n      {/* todo: X document the layout change for the accessibility purpose (tabIndex) */}\n      {!isComposing && (\n        <AutocompleteSuggestionList\n          className={listClassName}\n          closeOnClickOutside={closeSuggestionsOnClickOutside}\n          focusedItemIndex={focusedItemIndex}\n          listboxId={listboxId}\n          setFocusedItemIndex={setFocusedItemIndex}\n        />\n      )}\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,IAAM,6BAA6B,WAA8B;CAC/D,WAAW,MAAM;CACjB,aAAa,MAAM;CACnB,MAAM,MAAM;AACd;AAEA,IAAM,6BAA6B,WAA8B;CAC/D,gBAAgB,MAAM;CACtB,OAAO,MAAM;AACf;AAEA,IAAM,uBAAuB,WAAkC,EAC7D,SAAS,MAAM,KAAK,QACtB;AAEA,IAAM,gCAAgC,WAAiC,EACrE,eAAe,MAAM,cACvB;AAEA,IAAM,kCAAkC,WAAmC,EACzE,aAAa,MAAM,YACrB;;;;;;AAOA,IAAM,uBAAuB,UAC3B,MAAM,QAAQ,WAAW,CAAC,MAAM,YAAY,CAAC,MAAM,YAAY;AAEjE,IAAa,kCAAkC,SAAiB,KAAK,WAAW;;;;;;;AAoBhF,IAAa,oBAAoB,UAC/B,oBAAC,uCAAD,EAAuC,GAAI,MAAQ,CAAA;AAGrD,IAAM,yCAAyC,EAC7C,WACA,gCACA,oBACA,eACA,SAAS,aACT,SAAS,aACT,QACA,UACA,WACA,SAAS,aACT,UACA,UACA,aAAa,iBACb,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