@gpa-gemstone/application-typings
Version:
Application typings for GPA products
183 lines (182 loc) • 7.07 kB
TypeScript
import * as React from 'react';
declare namespace Gemstone {
namespace TSX {
namespace Types {
type BulkUploadStep = ('Upload' | 'Process' | 'Review' | 'Complete');
type Accuracy = ('minute' | 'second' | 'millisecond');
type ScreenSize = 'xs' | "sm" | 'md' | 'lg' | 'xl';
type QuickSelectRange = 'cycles' | 'short' | 'medium' | 'long' | 'full';
type DateUnit = 'datetime-local' | 'date' | 'time';
}
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 ICSVFieldEditContext<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: 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: React.Dispatch<React.SetStateAction<string[]>>;
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;
}
interface ILabelValue<T> {
Label: string;
Value: T;
}
interface AbortablePromise<T> extends PromiseLike<T> {
abort?: () => void;
}
interface IDecisionNodeOption {
Label: string;
NextNodeKey: string;
}
interface IDecisionTreeNode {
Prompt: string | JSX.Element;
/** Branch options (if absent or empty, this will be treated as a result node) */
Options?: IDecisionNodeOption[];
/** RecommendedValue (only for result nodes) */
RecommendedValue?: any;
}
interface IDecisionTreeData {
/** Mapping of node IDs to nodes */
Nodes: Record<string, IDecisionTreeNode>;
/** Starting node ID */
RootId: string;
}
}
}
}
export default Gemstone;