import type { IFieldBase } from './field.types'; import { FieldBase } from './field.types'; export interface CsvStateScaffold { idle: any; wrangling: any; success: any; failure: any; } export interface CsvStates extends CsvStateScaffold { idle: {}; wrangling: {}; success: {}; failure: {}; } // EVENTS that the machine handles export type Csv_Event_FileLoad = { type: 'FILE_LOADING' }; export type Csv_Event_FileChange = { type: 'FILE_CHANGE' }; export type Csv_Event_CsvLoaded = { type: 'CSV_LOADED'; files: any }; export type Csv_Event_Failure = { type: 'CSV_FAILURE' }; export type Csv_Event_Reset = { type: 'CSV_RESET' }; export type CsvEvent = | Csv_Event_FileLoad | Csv_Event_FileChange | Csv_Event_CsvLoaded | Csv_Event_Failure | Csv_Event_Reset export interface CsvEventsScaffold { 'FILE_LOADING': Function, 'FILE_CHANGE': Function, 'CSV_LOADED': Function, 'CSV_FAILURE': Function } export type CsvContext = { field: CsvModel; files: File[]; data: any; }; export type CsvContextUndefined = { field: undefined; fileMachine: undefined; files: undefined; data: undefined; }; export interface CsvStateSchema { initial: string; context: CsvContext; states: CsvStates }; export type CsvState = { value: 'idle'; context: CsvContext; } | { value: 'wrangling'; context: CsvContext; } | { value: 'success'; context: CsvContext; } | { value: 'failure'; context: CsvContext; }; export interface ICsv extends IFieldBase { } export class CsvModel extends FieldBase implements ICsv { type = "csv"; subType = "csv" constructor(csv: Partial) { super(csv); } }