/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * A step card's parts (#936) — #934's `CardPart`s and `CardLine`s as the * Query tab draws them (`Query Editor Spec.md` §4.3): words, with joiners in * a fixed column so conditions line up; slots, each the `select` trigger — * dashed while empty, the danger ink with a problem — which open the * autocomplete; inputs, which edit on leaving; chips with their ×; adds, * dashed in a row and quiet in a foot; a row's ×; a jq step's code; groups * with their own head; and the problem lines under the rows that caused * them, with the checker's own sentence on hover and its fixes as buttons. * * Every part says what it was asked to do through {@link PartActions}; the * Query tab makes each one gesture of the editing session. State reaches the * styles through data attributes on the `queryBuilder` recipe's slots. * * @packageDocumentation */ import { type ReactElement, type ReactNode } from "react"; import { type SystemStyleObject } from "@chakra-ui/react"; import { type IconDefinition } from "@fortawesome/free-solid-svg-icons"; import type { CardLine, CardPart, ProblemLine } from "./model/cards.js"; import type { ActionRef, InputRef, RemoveRef, SlotRef } from "./model/refs.js"; import type { QueryWords } from "./model/words.js"; import type { StepFix } from "./steps/check.js"; /** A recipe's styles, by slot. */ export type Styles = Record; /** What the parts ask of the Query tab. */ export interface PartActions { /** The key of the slot whose autocomplete is open. */ readonly openSlot: string | undefined; /** Opens a slot's autocomplete, hanging from its element. */ readonly onSlot: (slot: SlotRef, anchor: HTMLElement) => void; /** An input typed in and left. */ readonly onInput: (input: InputRef, raw: string) => void; /** A × pressed. */ readonly onRemove: (ref: RemoveRef) => void; /** An add pressed: one that adds, or one that opens a slot, hanging from its element. */ readonly onAction: (ref: ActionRef, anchor: HTMLElement) => void; /** A problem's fix taken. */ readonly onFix: (fix: StepFix, label: string) => void; } /** What drawing the parts needs: the styles of the recipes they are made of, and the words. */ export interface PartStyles { /** The `queryBuilder` recipe's. */ readonly styles: Styles; /** The `select` recipe's, small: a slot is its trigger. */ readonly select: Styles; /** The `input` recipe's, small. */ readonly input: SystemStyleObject; /** The `iconButton` recipe's, quiet and extra small. */ readonly icon: SystemStyleObject; /** The `codeBlock` recipe's. */ readonly code: Styles; /** The words. */ readonly words: QueryWords; } /** * The parts' styles: the `queryBuilder` recipe's, and the core recipes' a * part is made of. * * @param words - The words * @returns The styles, and the words */ export declare function usePartStyles(words: QueryWords): PartStyles; /** * A slot's key: what its element carries as `data-slot-key`, so the slot a * pick opens next is found after the query renders again. * * @param slot - The slot * @returns Its key */ export declare function slotKey(slot: SlotRef): string; /** * A tooltip over a control: the design system's, after a moment's hover. * * @param props - The words it shows, and the control * @returns The control, with its tooltip */ export declare function Tip({ label, children }: { label: string; children: ReactElement; }): import("react/jsx-runtime").JSX.Element; /** * An icon button, named for a screen reader and by its tooltip. * * @param props - Its name, its icon, whether it is off, what it does, and its styles * @returns The button */ export declare function IconPart({ label, icon, disabled, css, onClick }: { label: string; icon: IconDefinition; disabled?: boolean; css: SystemStyleObject | SystemStyleObject[]; onClick: () => void; }): import("react/jsx-runtime").JSX.Element; /** An input of a step card: typed in, and edited on leaving. */ export declare const InputPart: import("react").MemoExoticComponent<({ part, ps, actions }: { part: Extract; ps: PartStyles; actions: PartActions; }) => import("react/jsx-runtime").JSX.Element>; /** * A row's parts, in order. * * @param props - The parts, their styles and what they ask * @returns The parts */ export declare function Parts({ parts, ps, actions, ghost }: { parts: readonly CardPart[]; ps: PartStyles; actions: PartActions; ghost?: boolean; }): ReactNode; /** * The problems under a row: each in its severity's ink, the checker's own * sentence on hover, and its fixes as buttons. * * @param props - The problems, their styles and what a fix asks * @returns The problem lines */ export declare function Problems({ problems, ps, actions }: { problems: readonly ProblemLine[]; ps: PartStyles; actions: PartActions; }): ReactNode; /** * A card's lines: rows, groups with their head and lines, feet, notes and a * jq step's code, each with the problems under it. * * @param props - The lines, their styles and what they ask * @returns The lines */ export declare function Lines({ lines, ps, actions }: { lines: readonly CardLine[]; ps: PartStyles; actions: PartActions; }): ReactNode; //# sourceMappingURL=parts.d.ts.map