Files
fidoca/.ui-order.mjs
2026-09-25 05:37:09 +02:00

30 lines
756 B
JavaScript

import { createElement as h, useState } from 'react';
import { render, Box, useInput } from 'ink';
import TextInput from 'ink-text-input';
const order = [];
function Gate() {
useInput((input, key) => {
if (key.ctrl && input === 'o') order.push('gate');
});
return null;
}
function App() {
const [v, setV] = useState('');
return h(
Box,
null,
h(Gate, { key: 'g' }),
h(TextInput, {
key: 't',
value: v,
onChange: (nv) => { order.push('onChange:' + JSON.stringify(nv)); setV(nv); },
}),
);
}
render(h(App), { exitOnCtrlC: false });
setTimeout(() => {
process.stdout.write('\nORDER=' + JSON.stringify(order) + '\n');
process.exit(0);
}, 1200);