πŸ“„ File detail

components/PromptInput/inputModes.ts

🧩 .tsπŸ“ 34 linesπŸ’Ύ 731 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œcomponents/”, which covers shared React UI pieces. On the API surface it exposes prependModeCharacterToInput, getModeFromInput, getValueFromInput, and isInputModeCharacter β€” mainly functions, hooks, or classes. Dependencies touch src.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

import type { HistoryMode } from 'src/hooks/useArrowKeyHistory.js' import type { PromptInputMode } from 'src/types/textInputTypes.js' export function prependModeCharacterToInput( input: string,

πŸ“€ Exports (heuristic)

  • prependModeCharacterToInput
  • getModeFromInput
  • getValueFromInput
  • isInputModeCharacter

πŸ“š External import roots

Package roots from from "…" (relative paths omitted).

  • src

πŸ–₯️ Source preview

import type { HistoryMode } from 'src/hooks/useArrowKeyHistory.js'
import type { PromptInputMode } from 'src/types/textInputTypes.js'

export function prependModeCharacterToInput(
  input: string,
  mode: PromptInputMode,
): string {
  switch (mode) {
    case 'bash':
      return `!${input}`
    default:
      return input
  }
}

export function getModeFromInput(input: string): HistoryMode {
  if (input.startsWith('!')) {
    return 'bash'
  }
  return 'prompt'
}

export function getValueFromInput(input: string): string {
  const mode = getModeFromInput(input)
  if (mode === 'prompt') {
    return input
  }
  return input.slice(1)
}

export function isInputModeCharacter(input: string): boolean {
  return input === '!'
}