Repository URL to install this package:
|
Version:
0.4.48 ▾
|
import React from "react";
import { Box, Text, useInput } from "ink";
export function TextInput({ value, onChange, onSubmit, onCancel, placeholder, prompt }) {
useInput((input, key) => {
if (key.escape) {
onCancel();
return;
}
if (key.return) {
onSubmit(value);
return;
}
if (key.backspace || key.delete) {
onChange(value.slice(0, -1));
return;
}
if (!key.ctrl && !key.meta && input) {
onChange(value + input);
}
});
return (React.createElement(Box, null,
prompt ? React.createElement(Text, { color: "cyan" },
prompt,
" ") : null,
React.createElement(Text, null, value || (placeholder ? React.createElement(Text, { color: "gray" }, placeholder) : "")),
React.createElement(Text, { color: "cyan" }, "_")));
}
//# sourceMappingURL=TextInput.js.map