import "./guided_run.css"; import type * as React from "react"; import type { ReactNode } from "react"; import { useRender } from "@base-ui/react/use-render"; import type { DisplayFile } from "./file_thumbnail"; import { type StyleProps } from "./style_props"; import type { ShapeBaseProps, Stage, TextSlot } from "./shape_frame"; /** * WHAT ONE STEP TAKES BEFORE IT IS DONE — the `capture` slot, in the three * vocabularies a model states one in. A discriminated union rather than three * optional props: a step captures ONE thing, and three slots would leave nothing * saying which of them Next is gated on. */ export type GuidedCapture = { /** A `measure` — a reading the step is taken to get. */ kind: "measure"; label: string; value: (row: T) => number | null; /** What the figure is counted in, named beside the field — never inside * the value, which is what the field will have to read back. */ unit?: string; /** * THROWING KEEPS THE DRAFT and states the reason at the field: a figure * the reader typed and the server refused must not be replaced by the old * one under a toast they may not be looking at. */ onCapture: (row: T, value: number | null) => void | Promise; } | { /** A `verdict` — the step passed, or it did not. */ kind: "verdict"; label: string; value: (row: T) => boolean | null; onCapture: (row: T, value: boolean) => void; } | { /** An `expected_set` — every entry the step owes, ticked off. */ kind: "set"; label: string; /** What the step is required to hold, in the field's own order. */ required: readonly Stage[]; value: (row: T) => readonly string[]; onCapture: (row: T, keys: readonly string[]) => void; }; /** * THE STEP'S OWN OUTCOME — the `verdict` slot, answered apart from whatever the * step captured. A reading is what the step WENT AND GOT, and the gate is whether * that reading passes; an entity carries at most one `verdict` field. */ export interface GuidedGate { label: string; value: (row: T) => boolean | null; /** Absent, the gate is read and not answered here. */ onAnswer?: (row: T, value: boolean) => void; } /** * THE GUIDED RUN — an ordered sequence completed a step at a time: a pick run, a * QC inspection, an inbound check. *"What do I do next, and what does it need * from me?"* * * THE RUN IS THE RECORD. One step is on screen with the sequence beside it, the * clock over both, and Next gated on whatever that step has to capture. The * controls are the step's whole column rather than a cell's width, because the * hands holding the device are usually holding something else too. * * It composes devices and NOT `ShapeFrame`: the frame's anatomy is a register, * and a run has no set on screen to narrow. Its rows are the steps of ONE thing. * * THE RUN RESUMES. Where the reader left off and when they started are remembered * per browser under `resume`. Storage is a convenience (`usePersistedState`): * everything the work depends on is in the steps themselves. */ export interface GuidedRunProps extends Pick, "rows" | "rowKey" | "loading" | "error" | "labels">, StyleProps { /** The `identity` role — what this step IS, in the imperative the work uses. */ step: TextSlot; /** The supporting line under the step's name — how the step is done where a * surface has those words, the key it is filed under where it does not. */ caption?: (row: T) => string; /** * The `slot` role — where in the sequence this step falls. THE RUN IS SORTED BY * IT: a sequence drawn in whatever order the read answered with is a list. * Unbound, the rows stand in the order they arrived. */ sequence?: { label: string; value: (row: T) => number | null; }; /** What this step has to capture, and what Next is gated on. */ capture?: GuidedCapture; /** The step's own pass/fail. */ gate?: GuidedGate; /** The `mark` role — the pictures the step is worked against. */ media?: (row: T) => readonly DisplayFile[]; /** * The key this reader's place in THIS run is remembered under — the run's own * identity, so two runs of the same procedure do not resume into each other. */ resume: string; /** The step's own verbs beside Next — raise an exception off a failed step, * preview what the run will write. ONE reach, so the bar stays readable. */ actions?: (row: T) => ReactNode; /** The door onto the step's own record. A PAGE: the run is the surface, so a * panel over it would be a second place to stand. */ record?: { onOpen: (row: T) => void; }; /** The run's last press, offered once the reader is past the final step. */ commit?: { label: string; onPress: () => void; running?: boolean; }; /** What day and hour it is — the clock the elapsed reading counts to. */ now?: Date; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } export declare function GuidedRun(props: GuidedRunProps): React.ReactElement>;