import React from "react";
import { render, Box, Text, useFocus, useInput, useFocusManager } from "#/index.ts";
function Focus() {
const { focus } = useFocusManager();
useInput((input) => {
if (input === "1") {
focus("1");
}
if (input === "2") {
focus("2");
}
if (input === "3") {
focus("3");
}
});
return (
Press Tab to focus next element, Shift+Tab to focus previous element, Esc to reset focus.
);
}
type ItemProperties = {
readonly id: string;
readonly label: string;
};
function Item({ label, id }: ItemProperties) {
const { isFocused } = useFocus({ id });
return (
{label} {isFocused ? (focused) : null}
);
}
render();