UNPKG

@gpa-gemstone/application-typings

Version:
154 lines (153 loc) 5.82 kB
declare namespace Gemstone { namespace TSX { namespace Types { type BulkUploadStep = ('Upload' | 'Process' | 'Review' | 'Complete'); } namespace Interfaces { interface IBaseFormProps<T> { /** * Record to be used in form * @type {T} */ Record: T; /** * Field of the record to be edited * @type {keyof T} */ Field: keyof T; /** * Label to display for the form, defaults to the Field prop * @type {string | JSX.Element} * @optional */ Label?: string | JSX.Element; /** * Setter function to update the Record * @param record - Updated Record */ Setter: (record: T) => void; /** * Help message or element to display * @type {string | JSX.Element} * @optional */ Help?: string | JSX.Element; /** * Flag to disable the input field * @type {boolean} * @optional */ Disabled?: boolean; } interface IElementPosition { Top: number; Left: number; Width: number; Height: number; } interface ICSVFieldEditProps<T> { Value: string; SetValue: (val: string) => void; Validate: ((value: string) => boolean) | ((value: string) => Promise<[boolean, () => void]>); Feedback?: string; AllRecordValues: Partial<Record<keyof T, string>>; SelectOptions?: { Label: string; Value: string | number; }[]; } interface ICSVField<T> { /** * The field in the record this definition applies to. * @type {keyof T} */ Field: keyof T; /** * The label for the field, used for select element. * @type {string} */ Label: string; /** * Function to validate the field value. * @param {string} value - The value to validate. * @returns {boolean | Promise<[boolean, () => void]>} */ Validate: ((value: string) => boolean) | ((value: string) => Promise<[boolean, () => void]>); /** * Component for editing the field value. */ EditComponent: (props: ICSVFieldEditProps<T>) => JSX.Element; /** * Optional help text for the select element. * @type {string} * @optional */ Help?: string; /** * Optional feedback for the EditComponent * @type {string} * @optional */ Feedback?: string; /** * Function to process the field value and update the record. * @param {string} val - The value to process. * @param {T} record - The record to update. * @param {keyof T} field - The field of the record to update. * @returns {T} */ Process: (val: string, record: T, field: keyof T) => T; /** * Flag indicating if the field is required. * @type {boolean} */ Required: boolean; /** * Flag indicating if the field can be empty. * @type {boolean} */ AllowEmpty: boolean; /** * Flag indicating if the field values must be unique. * @type {boolean} */ Unique: boolean; /** * Flag indicating if the field values should be the same for all rows. * @type {boolean} */ SameValueForAllRows?: boolean; SelectOptions?: { Label: string; Value: string | number; }[]; } interface ISearchFilter<T> { FieldName: keyof T; SearchParameter: string; Operator: ('=' | '<>' | '>' | '<' | '>=' | '<=' | 'LIKE' | 'NOT LIKE' | 'IN' | 'NOT IN'); } interface IPipelineStepProps<T, U = null> { RawFileData: string | null; Data: T[]; SetData: (data: T[]) => void; CurrentPipelineStep: number; SetPipelineStep: (step: number) => void; Errors: string[]; SetErrors: (errors: string[]) => void; AdditionalProps?: U; } interface IPipelineSteps<T, U = null> { Label: string; UI: (props: IPipelineStepProps<T, U>) => JSX.Element; AdditionalProps?: U; } interface IPipeline<T, U = null> { Select: (mimeType: string, fileExtension: string) => boolean; Steps: IPipelineSteps<T, U>[]; AdditionalUploadUI?: JSX.Element; } } } } export default Gemstone;