/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The inspector pane (#1188, `Sheet Builder Spec.md` §5.3, §8, §9.9, * SB46–SB53, SB58): the Sheet's end pane, when it is given one (#1216), its * tabs Details and Issues — Issues with its count — and, collapsed, a rail * with its icon, the issue count and what is selected. * * Details shows what the ring and the range select: * * - **one row or line** (SB47): its number and id, a Pending or New chip, * the lock of a row owned upstream, its issues, every field of its type * through `FieldForm` (the payload's form: a column's kind its field's * editor, a field with no column by its type — and each member of a column * from data a line of its own, its cell, #1561), its sub rows read only, then * Duplicate and Delete. A link or set field shows its halves as the grid * draws them, with Edit in sheet, which puts the ring on its cell (SB48). An * edit is one transaction, as typing in the cell is: a field with a column * is written through its cell — the cells a patch of it sets, or a custom * column's text read by its own parse — and asks the copilot again when its * column is a trigger; a field with none is set on the draft (SB52). A * number's box emptied is its cell emptied, as emptying the cell is: blank, * the field then not set, where its column takes a clear. An edit its cell * refuses — a clear of a value that is never empty — leaves the field * showing what the row holds, the reason under it as the footer's line says * it. A field the drafts changed is tinted against what the source holds. * A number its field's bounds don't hold is said once, in its help line — * a phone's stepper's too — in the tone the row's Save stands in (#1585): a * warning while the row is as stored, an error once its change holds Save. * With the author's own Details (SB58), a complete row shows what they return in * place of the form, and their `update` is one transaction; a row still * missing a field, or holding one unreadable, shows the form until it is * complete; * - **a band** (SB49): its group's own fields, its line count and its issues, * then Add line, Duplicate with its lines, Delete with its lines; * - **several rows** (SB50): their count, a column set or cleared across * them, Duplicate and Delete — each one transaction; * - **nothing** (SB51): the rows, the pending drafts and the issues counted, * over a record its last commit and who made it, and three hints. * * Issues (SB53) lists every issue of the batch by row — a field still * missing or unreadable, an author's check, an Apply's conflict or refusal — * each a control that goes to its cell, seeking its row on a paged sheet. An * issue whose row the rail's filters hide says so, and by which once e3 has * said — `hidden by Status: Ready — picking it clears that filter` — and a * click clears them and goes to the row (the hidden pick, `hidden.ts`). * * Styles are the `sheetInspector` recipe's, the form's `fieldForm`'s and a * link cell's the `sheet` recipe's; the pane — its tab row, its collapse * control and its rail — is the Dock's. * * A host with a view of its own (#1534) — the Record's — draws Details for one * row and for nothing in the Sheet's place ({@link SheetInspectorHost}), a * phone's drawer's among them, over the same reads and writes, the form's own * (`useTargetForm`) among them, and names an issue's row in the Issues tab in * its own words. Several rows stay the Sheet's; so does a complete row given * the author's own Details. * * @packageDocumentation */ import { type ComponentType, type ReactNode } from "react"; import { type SystemStyleObject } from "@chakra-ui/react"; import { type StructType } from "@elaraai/east"; import type { FieldSpecValue } from "@elaraai/east-ui/internal"; import { type sheetKeys } from "@elaraai/e3-ui/internal"; import { type BuilderFrameDock, type EditIssue, type FieldOption } from "@elaraai/east-ui-components"; import { type SheetCellEditorAt, type SheetInspect, type SheetInspectPlace, type SheetInspectTarget, type SheetSelected } from "../index.js"; import { type SheetWords } from "../words.js"; import type { SheetValue } from "./index.js"; /** * What the inspector reads of its payload: the grid's root, the inspector pane and the record's history — a Sheet's, * or a Record's (#1531), which mounts it over the same parts. */ export type SheetInspectorValue = Pick; /** The inspector pane, decoded: its forms, and the author's own Details. */ export type PaneValue = Extract["value"]; /** One inspector form, decoded: its struct, its fields, the fields its columns write and show, and `encode`. */ export type FormValue = PaneValue["forms"]["row"]; /** What the author's own Details return for a complete row (SB58): the UI drawn in the form's place. */ export type AuthorDetails = ReturnType["value"]>; /** The names the sheet keeps its viewer's state under. */ type SheetKeys = ReturnType; type Styles = Record; /** The record's last commit, as the footer and the inspector say it (SB22, SB51). */ export interface SheetLastCommit { /** When — the day's time when it was today, in full otherwise. */ when: string; /** Who made it: the commit's actor. */ by: string; } /** Props of {@link useSheetInspector}. */ export interface SheetInspectorProps { /** The payload: its inspector pane, the sheet's registers and editing, and whether it is over a record. */ value: SheetInspectorValue; /** The names the sheet keeps its viewer's state under. */ keys: SheetKeys; /** The sheet's words. */ words: SheetWords; /** The columns this viewer hides: a link field's Edit in sheet waits for its column to show. */ hidden: ReadonlySet; /** The record's last commit, when it has one. */ lastCommit: SheetLastCommit | undefined; /** What a host draws in the Sheet's place (#1534): its own Details, and its words for an issue's row; absent, the Sheet's. */ host?: SheetInspectorHost | undefined; } /** * What a host draws in the inspector in the Sheet's place (#1534) — the Record's: Details for one row and for nothing, * and the words an issue's line names its row by. */ export interface SheetInspectorHost { /** * Details while the ring selects one place — a row, a line or a band — or nothing: in a phone's drawer too, where * they draw at touch size, as the Sheet's own do there (SH12). Several rows are the Sheet's. A complete row given * the author's own Details shows them in the form's place ({@link useAuthorDetails}). */ Details: ComponentType; /** * How an issue's line in the Issues tab names its row, given where the row stands among the rows drawn — * `undefined` for one the sheet does not draw; absent, by its entry, a line by its place in its group. */ where?: ((issue: EditIssue, place: SheetInspectPlace | undefined) => string) | undefined; } /** What a host's Details is given ({@link SheetInspectorHost.Details}). */ export interface SheetInspectorDetailsProps { /** The payload: the grid's root, the inspector pane and the record's history. */ value: SheetInspectorValue; /** The pane: its forms, and the author's own Details. */ pane: PaneValue; /** The names the sheet keeps its viewer's state under. */ keys: SheetKeys; /** The sheet's words. */ words: SheetWords; /** The columns this viewer hides. */ hidden: ReadonlySet; /** The host's word for a group. */ noun: string; /** What the ring selects: one row's place, or nothing. */ selected: Exclude; } /** * What the inspector shows, as its head and its rail name it — `row 3`, `line 2 of WO-2201`, `order 4`. * * @param place - Where it stands * @param words - The sheet's words * @param noun - The host's word for a group * @returns Its name */ export declare function whatOf(place: SheetInspectPlace, words: SheetWords, noun: string): string; /** * The inspector pane, as `BuilderFrame` draws it — see the module docs. * * @param props - The payload, the sheet's keys, the words, the columns hidden, the last commit, and what a host draws in the Sheet's place * @returns The pane — its tabs Details and Issues, 320px wide, its collapsed state kept per viewer (SB24) — or `undefined`, no pane, when the sheet is given no inspector */ export declare function useSheetInspector({ value, keys, words, hidden, lastCommit, host }: SheetInspectorProps): BuilderFrameDock | undefined; /** Props of the Details tab and its views. */ interface DetailsProps extends SheetInspectorProps { /** The pane: its forms, and the author's own Details. */ pane: PaneValue; /** The host's word for a group. */ noun: string; } /** Props of {@link TargetDetails}. */ interface PlaceProps extends DetailsProps { styles: Styles; inspect: SheetInspect; place: SheetInspectPlace; form: FormValue; } /** Props of {@link TargetView}. */ interface TargetProps extends Omit { target: SheetInspectTarget; } /** One target's form, as {@link useTargetForm} reads it: what `FieldForm` draws it with. */ export interface TargetForm { /** The specs at this row: the form's fields, then each member of a column from data a line of its own (#1561). */ specs: FieldSpecValue[]; /** The column each spec is read and written through, in the specs' order, by key — a member's line its column's; `undefined` for a field the draft holds alone. */ columns: (string | undefined)[]; /** Each select's members at this row, by the field's path. */ options: Record; /** The form's value: the draft's fields. */ formValue: Record; /** What the record holds, as the value holds the draft: a field that differs is tinted. */ baseline: Record; /** An edit of a field, written as typing in the grid writes it: why its cell refused it, in the Sheet's words, where it did. */ onChange: (path: readonly string[], next: unknown) => string | void; /** The controls the form takes from the grid: a link's or a set's halves, an action's state, a member's label. */ renderControl: (spec: FieldSpecValue) => ReactNode | undefined; /** The form's struct. */ struct: StructType; } /** * The form's specs, values and edits for one target — the payload's form at * this row: a quantity's unit and a date's level from its row, a select's * members as its column's options rule offers them, a custom column's text * by its print and a read-only column's value from its cell, and each edit * written as typing in the grid writes it — each one step of the history, or, * given `joins`, one step with the edits before it under that key (a phone's * cell editor, SH10.1). A host's Details draws its form from it (#1534). * * Each member of a column from data is a line of its own after the form's * fields (#1561), whose field the form leaves out: the member's cell at the * column's key, read as the grid reads it at the day, tinted where it differs * from the cell the record holds, and written as typing in the cell writes it * — through the column's `write`, over the field as drafted so far. An age's * shows no line, as a column's age shows no field. * * @param input - The payload, the words, the columns hidden, the `sheetInspector` styles, the sheet's reads and writes, the target and its form — and the key its edits join under, if they are one step * @returns The form, as `FieldForm` draws it */ export declare function useTargetForm({ value, words, hidden, styles, inspect, target, form, joins }: Pick & { joins?: string | undefined; }): TargetForm; /** One issue of a target, as Details lists it. */ export interface TargetIssue { /** Its place among the batch's issues: the list's key. */ key: string; /** The field it names, by its label — a member's cell of a column from data by its column's header — else its name; `undefined` for an issue of the whole row. */ field: string | undefined; /** The field's name, as the form keys it; `undefined` for an issue of the whole row. */ name: string | undefined; /** What is wrong, in the sheet's words. */ text: string; /** A field still missing, or one refused; or a stored row's number outside its bounds, which warns (#1585). */ kind: "incomplete" | "invalid" | "warning"; } /** * A target's issues, by field: each its field's label — else the header of the column it names, as one of a column * from data's cells is named by its column key, which no form field holds — else its name, and its text in the sheet's * words. * * @param target - The row, line or band * @param inspect - The sheet's reads: the batch's issues, and the columns at the target's row * @param form - The target's form: its fields' labels * @param words - The sheet's words * @returns Its issues, in the batch's order */ export declare function targetIssues(target: SheetInspectTarget, inspect: SheetInspect, form: FormValue, words: SheetWords): TargetIssue[]; /** * A target's issues by the field each names, as its form keys it, each field with what its issues say of it, in their * order: what a host that washes the fields its issues name hands the form (`FieldForm`'s `issues`), which then says * each field's words under it (ruled 13 Nov 2026) — the Record's Details (IN3). An issue of the whole row names none. * * @param issues - The target's issues ({@link targetIssues}) * @returns Each field they name, and the words under it */ export declare function issuesByField(issues: readonly TargetIssue[]): ReadonlyMap; /** * The author's own Details for a complete row (SB58): what their function returns for the row as bytes, its edit * written back as one transaction — every field its columns write through them at once, a field with none on the * draft. `undefined` for a band, for a row still missing a field or holding one unreadable, for a pane with no Details * of the author's, and where their function fails: the form shows there. A host's Details draws them too (#1534). * * @param input - The payload, the pane, the sheet's reads and writes, the target, its form and the form's struct * @returns What the author's function returns, drawn in the form's place */ export declare function useAuthorDetails({ value, pane, inspect, target, form, struct }: { value: SheetInspectorValue; pane: PaneValue; inspect: SheetInspect; target: SheetInspectTarget; form: FormValue; struct: StructType; }): AuthorDetails | undefined; /** * A phone's cell editor for a sheet given an inspector (SH10, R9): what the * Sheet's bottom container shows for the ring's cell — the pane's form at * touch size, the field the cell's column writes — or `undefined` where the * sheet has no inspector, or its form no field for that column, and the * docked strip shows. * * @param value - The payload: its inspector's forms * @param words - The sheet's words * @param hidden - The columns this viewer hides * @returns The editor for a cell, as `SheetHost.cellEditor` takes it */ export declare function sheetCellEditor(value: SheetInspectorValue, words: SheetWords, hidden: ReadonlySet): (at: SheetCellEditorAt) => ReactNode | undefined; export {}; //# sourceMappingURL=inspector.d.ts.map