/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Keeping the keyboard in a region as the control it is on goes (#1398): an * inspector's Delete, Unplace, Remove or Place takes away what its view shows, * and a link in it selects something else — the view the control was pressed * in is drawn no more, and the focus, on a control that went with it, would * fall to the page's body, where the next Tab starts again at the page's top. * The region keeps it: once what it shows has been drawn again, the focus * lands on its view's home ({@link FOCUS_HOME}) — its heading, focusable by * script and out of the tab order — which names what the region shows now, so * a screen reader says where the keyboard is and the next Tab goes on from * there. A focus that left the region — for another element, for the page with * the control it was on still there, or a press anywhere outside it — is let * be. So is one on its way to another of the region's controls, still there — * a click into it, a Tab to it — though what the region shows is drawn again * meanwhile, as a field commits its edit while the keyboard leaves it: it * lands where it was given (#1585). * * Every builder's Details is such a region: the Schematic's, the Flowchart's, * the Plan's, the Calendar's, the Roster's and the Allocation's. A view's home * is its head; a view with none — the Plan's Nothing selected, the Calendar's * empty state — is its own. * * A region shows a subject at a time, and a new one is shown from the start of * the pane it scrolls in, as one opened afresh: its heading, the home, in view * (#1680's review). The pane keeps its scroll from one subject to the next, and * a link's Details opened under where a job's long form was left scrolled hid * the link's heading. The subject is the key its view is drawn under * ({@link viewSubject}), which draws the next subject's view afresh too. * * @packageDocumentation */ import { type FocusEvent, type ReactNode, type RefObject } from "react"; /** What marks a region's home: the element the keyboard lands on as the control it was on goes. */ export declare const FOCUS_HOME = "data-focus-home"; /** * The subject a region's view shows, by the key it is drawn under: what draws the next subject's view afresh. * * @param view - The view the region draws * @returns Its key; `null` for a view drawn under none — several picked, nothing picked */ export declare function viewSubject(view: ReactNode): string | null; /** A home's attributes, as a view's heading spreads them: out of the tab order, focusable by script. */ export declare const FOCUS_HOME_PROPS: { readonly tabIndex: -1; readonly "data-focus-home": ""; }; /** What a region's element spreads: its ref, and its focus and blur listeners. */ export interface FocusHomeRegion { /** The region's element. */ readonly ref: RefObject; /** Hears the focus enter the region, or move within it. */ readonly onFocus: () => void; /** Hears the focus leave an element of the region. */ readonly onBlur: (event: FocusEvent) => void; } /** * Keeps the keyboard in a region, and shows a new subject from its pane's start (see the module docs). * * @param subject - What the region shows ({@link viewSubject}); left out, the pane keeps its scroll * @returns What the region's element spreads */ export declare function useFocusHome(subject?: string | null): FocusHomeRegion; //# sourceMappingURL=focus-home.d.ts.map