consortium
Version:
Remote control and session sharing CLI for AI coding agents
33 lines (30 loc) • 1.17 kB
JavaScript
import React, { useState } from 'react';
import { useInput, Box, Text } from 'ink';
const EmailInput = ({
onSubmit,
onCancel,
prompt = "Enter your email:"
}) => {
const [email, setEmail] = useState("");
useInput((input, key) => {
if (key.escape) {
onCancel();
return;
}
if (key.return) {
if (email.includes("@") && email.includes(".")) {
onSubmit(email);
}
return;
}
if (key.backspace || key.delete) {
setEmail((prev) => prev.slice(0, -1));
return;
}
if (input && !key.ctrl && !key.meta) {
setEmail((prev) => prev + input);
}
});
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingY: 1 }, /* @__PURE__ */ React.createElement(Text, null, prompt), /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, { color: "cyan" }, email), /* @__PURE__ */ React.createElement(Text, { color: "gray" }, "\u2588")), /* @__PURE__ */ React.createElement(Box, { marginTop: 1 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "Press Enter to continue, Escape to cancel")));
};
export { EmailInput as E };