import { GlobalCfgRenderCtx, PColumnDataUniversal } from "../render/internal.js"; import { DataColumnRecipe } from "./data_column.js"; import { ColumnRecipe } from "./column_recipes/index.js"; import { ColumnUniversalId, ColumnValueId, PColumn, PFrameHandle, PObjectId } from "@milaboratories/pl-model-common"; /** Drop-down option for a value of a column — column-value-id valued. */ export type ColumnValueOption = { readonly value: ColumnValueId; readonly label: string; }; /** A column a value picker offers the values of, or labels them by. */ export type ColumnValueOptionsColumn = ColumnUniversalId | PColumn | DataColumnRecipe | ColumnRecipe; /** * What a UI reads the options of a value picker from: a frame holding the value column, and the * label column while there is one, as long as the value column is there. `valueColumn` is the * column the options are values of, so the UI can tell a model that still describes an earlier * pick. `frameColumns` names both columns as the frame holds them. */ export type ColumnValueOptionsModel = { readonly type: "resolving"; readonly valueColumn: ColumnUniversalId; } | { readonly type: "absent"; readonly valueColumn: ColumnUniversalId; } | { readonly type: "present"; readonly valueColumn: ColumnUniversalId; readonly frame: PFrameHandle; readonly frameColumns: { readonly value: PObjectId; /** `null` when the values label themselves. */ readonly label: PObjectId | null; }; }; /** * The model of a value picker over the values of `valueColumn`, for a model output; the UI reads * the options through it (`usePlColumnValueOptions`, `PlColumnValueDropdown`). Each option is a * value of `valueColumn`, labelled by the value of `labelColumn` in the same row, or by the value * itself when no label column is given. * * `absent` once the value column is gone: a stored id may name a column its upstream block no * longer produces. A label column that is gone leaves the values to label themselves; one that is * still resolving keeps the model resolving. */ export declare function createColumnValueOptions(columns: { readonly valueColumn: ColumnValueOptionsColumn; readonly labelColumn?: ColumnValueOptionsColumn; }, deps?: { readonly ctx?: GlobalCfgRenderCtx; }): ColumnValueOptionsModel; /** * Distinct `values` of `column` as options, each a column value id naming the column, labelled * by the value itself and ordered naturally by label ("R2" before "R10"). Empty values are not * offered. */ export declare function deriveColumnValueOptions(column: ColumnUniversalId, values: readonly string[]): ColumnValueOption[]; /** * Distinct values of `column` among `rows` as options, each a column value id naming the column, * labelled by the label of the first row holding the value, and ordered naturally by label ("R2" * before "R10"). Empty values are not offered; a value whose label is empty labels itself. */ export declare function deriveLabelledColumnValueOptions(column: ColumnUniversalId, rows: readonly { readonly value: string; readonly label: string; }[]): ColumnValueOption[]; //# sourceMappingURL=column_values.d.ts.map