import "./FilterBuilder.css"; import { type FilterTree, type SavedFilter } from "@olenbetong/appframe-core"; import { type NamedFilterType } from "@olenbetong/appframe-react"; import type { SaveFilterInput } from "@olenbetong/appframe-react"; import type { DataObject } from "@olenbetong/appframe-data"; import { type ReactNode } from "react"; import type { FilterEditorSize, GetFieldOptions } from "./types.js"; import type { FieldMetadata } from "@olenbetong/appframe-core"; export type FilterBuilderProps = { /** The fields the user can filter on. Fields with `excludeFromFilter` are hidden. */ fields: FieldMetadata[]; /** * The view the filter applies to. Used both for conversion and, unless * `dbObjectId` is set, as the key saved filters are stored under. */ viewName?: string; /** Overrides `viewName` as the key saved filters are stored under. */ dbObjectId?: string; /** Loads the filters saved for a report instead of for a view. */ reportId?: string; getFieldOptions?: GetFieldOptions; /** * `"dialog"` wraps the builder in a modal, `"inline"` renders it in place. * @default "dialog" */ variant?: "dialog" | "inline"; /** Whether the dialog is open. Ignored when `variant` is `"inline"`. */ open?: boolean; /** Called when the dialog is dismissed, and after the filter is applied. */ onClose?: () => void; /** The filter tree. Use together with `onChange` for a controlled component. */ value?: FilterTree | null; /** The initial filter tree when uncontrolled. */ defaultValue?: FilterTree | null; /** Called on every edit. */ onChange?: (filter: FilterTree) => void; /** * Called when the user applies the filter. The tree is pruned, so incomplete * conditions are dropped and an empty filter is reported as `null`. */ onApply?: (filter: FilterTree | null, filterString: string) => void; /** * Applies the filter to a data object when the user confirms. The filter is * written to a named slot, so it composes with other filter providers on the * same data object instead of overwriting them. */ dataObject?: DataObject; /** * Parameter the filter is applied to. * @default "filterObject" */ filterType?: NamedFilterType; /** * Name of the slot the filter is applied to. * @default "filterBuilder" */ slotName?: string; /** * Shows the filter string below the tree. * @default true */ showFilterString?: boolean; /** Called whenever the filter string is reconverted. */ onFilterStringChange?: (filterString: string) => void; /** Called when a saved filter is selected, and with `null` for "New Filter". */ onSelect?: (filter: SavedFilter | null) => void; /** * Extra columns written along with the filter when it is saved. The report * launcher stores its header text, its hide-criteria flag and its parameter * values here. */ saveValues?: SavedFilterValues; /** * Hides the OK/Cancel row, for callers that supply their own actions. The * saved-filter toolbar stays. */ hideActions?: boolean; /** * Replaces the OK/Cancel buttons, so a caller's own actions share the row * with the buttons acting on the selected saved filter. */ actions?: ReactNode; /** * Wraps the criteria editor, for callers that put it beside content of their * own — the report launcher puts it in a tab next to the report parameters. * Whatever is returned fills the column next to the saved-filter list. */ renderMain?: (editor: ReactNode) => ReactNode; /** Hides the saved-filter list, leaving just the criteria editor. */ hideSavedFilters?: boolean; className?: string; "data-size"?: FilterEditorSize; }; /** The parts of a saved filter the builder writes on behalf of a caller. */ export type SavedFilterValues = Pick; /** * The web port of the Windows filter builder: the saved-filter list, the * criteria editor and the save/share toolbar. * * Saved filters are stored as criteria strings, so selecting one round-trips * through the conversion endpoint to rebuild the tree, and saving converts the * tree back. * * @example * ```jsx * setOpen(false)} * /> * ``` */ export declare function FilterBuilder({ fields, viewName, dbObjectId, reportId, getFieldOptions, variant, open, onClose, value, defaultValue, onChange, onApply, dataObject, filterType, slotName, showFilterString, onFilterStringChange, onSelect, saveValues, hideActions, actions, renderMain, hideSavedFilters, className, "data-size": size, }: FilterBuilderProps): import("react").JSX.Element;