import React from "react"; import { render, useApp, useInput, Box, Text } from "#/index.ts"; import { Link, MemoryRouter, Outlet, Route, Routes, useNavigate, useNavigationStack, useParams, } from "#/router/index.ts"; const users = [ { id: "1", name: "Ada Lovelace" }, { id: "2", name: "Grace Hopper" }, { id: "3", name: "Katherine Johnson" }, ]; function Layout() { const { exit } = useApp(); const navigate = useNavigate(); const { canGoBack } = useNavigationStack(); useInput((input, key) => { if (input === "q") { exit(); } if (key.escape && canGoBack) { navigate(-1); } }); return ( Home Users Tab to move focus, Enter to follow a link, Esc to go back, q to quit. ); } function Home() { return Welcome! Head over to the users screen.; } function UserList() { return ( {users.map((user) => ( {user.name} ))} ); } function UserDetails() { const { id } = useParams(); const user = users.find((candidate) => candidate.id === id); return ( Viewing {user?.name ?? "an unknown user"} (id: {id}) ); } function App() { return ( }> } /> } /> } /> ); } render();