π 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)
prependModeCharacterToInputgetModeFromInputgetValueFromInputisInputModeCharacter
π 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 === '!'
}