import type { InputHTMLAttributes, CSSProperties } from "@agyemanjp/fxui"; import { type Rec, Vector, Tuple } from "@agyemanjp/standard"; import type { Validator } from "./_validators"; import type { Primitive } from "../base"; /** Gets ordered named field specs */ export declare function getOrderedNamedFieldSpecs>(fields: FieldSpecs): Vector & { fieldName: string; }>; /** Record of field specs for a record type T */ export type FieldSpecs> = { [k in keyof T]?: FieldSpec; } | Tuple>[]; /** Specs that define fundamental UI-related properties of a field */ export type FieldSpec = (T extends Date ? (DateField) : T extends string ? (TextField | EmailField | PasswordField | AddressField | ChoiceField | MultiChoiceField | MediaField) : T extends number ? (NumericField | NumericChoiceField | NumericMultiChoiceField | TimeOfDayField) : T extends boolean ? (ToggleField) : never); /** Field for choosing a boolean value, as a toggle * (i.e. a value is always chosen, there is no undefined state) */ export type ToggleField = FieldSpecBase & { type: "toggle"; defaultValue: boolean; }; /** Field for choosing a value from two or more values */ export type ChoiceField = FieldSpecBase & { type: "choice"; domain: "get-from-provider" | Tuple[]; }; /** Field for choosing a value from two or more values */ export type NumericChoiceField = FieldSpecBase & { type: "num-choice"; domain: "get-from-provider" | Tuple[]; }; /** Field for choosing multiple values (stored & read as comma-separated values) from two or more values. */ export type MultiChoiceField = FieldSpecBase & { type: "multi-choice"; domain: "get-from-provider" | Tuple[]; }; /** Field for choosing multiple values (stored & read as comma-separated values) from two or more values. */ export type NumericMultiChoiceField = FieldSpecBase & { type: "num-multi-choice"; domain: "get-from-provider" | Tuple[]; }; /** Field for selecting media, stored & read as JSON formatted string of arrays of media items */ export type MediaField = FieldSpecBase & { type: "media"; /** Maximum size of individual media items accepted by field */ maxItemSizeKb?: number; /** Maximum number of media items needed for this field to have a valid value */ maxItemsCount?: number; /** Minimum number of media items needed for this field to have a valid value */ minItemsCount?: number; /** Comma-separated list of media types accepted, e.g., 'image/*,video/*,etc' */ mediaTypesAllowed?: InputHTMLAttributes["accept"]; }; /** Field for a single image, stored & read as a uRL string */ export type ImageField = FieldSpecBase & { type: "image"; /** Maximum size of image file accepted */ maxItemSizeKb?: number; }; export type NumericField = FieldSpecBase & { type: "number"; }; /** Date field based on ISO 8601 (yyyy-mm-dd) string values */ export type DateField = FieldSpecBase & { type: "date"; }; /** Date-time-stamp field based Unix/JS epochs */ export type DateTimeStampField = FieldSpecBase & { type: "date-time-stamp"; }; /** Time field based on number of minutes since start of day */ export type TimeOfDayField = FieldSpecBase & { type: "time-of-day"; }; export type TextField = FieldSpecBase & { type: "text"; isLong?: boolean; }; export type PasswordField = FieldSpecBase & { type: "password"; }; export type EmailField = FieldSpecBase & { type: "email"; }; export type AddressField = FieldSpecBase & { type: "address"; }; export type FieldSpecBase = { /** Optional name that overrides the field key in a FieldSpecs record */ customName?: string; /** Optional title for the field, used for captions, etc */ title?: string; isRequired?: boolean; /** Optional default value */ defaultValue?: T; /** Validators (in addition to the type-based defaults) */ validators?: Validator[]; /** Formatter (overrides the type-based default */ formatter?: (val: T) => string; /** Ordinal position of this field for display */ ordinal?: number; style?: CSSProperties; };