import type { IFieldBase } from './field.types'; import { FieldBase } from './field.types'; export interface IText extends IFieldBase { placeholder?: string; readonly?: boolean; disabled?: boolean; rows: number; cols: number; debounceFor: number; } export class TextModel extends FieldBase implements IText { type = 'text'; subType = "singleLine"; placeholder = 'Placeholder text'; readonly = false; disabled = false; rows = 4; cols = 50; debounceFor = 300; constructor(input: Partial) { super(input); this.subType = input.subType || this.subType; this.placeholder = input.placeholder || this.placeholder; this.disabled = input.disabled ?? this.disabled; this.readonly = input.readonly ?? this.readonly; this.rows = input.rows ?? this.rows; this.cols = input.cols ?? this.cols; this.debounceFor = input.debounceFor ?? this.debounceFor; } } // SCHEMA // export interface TextStateScaffold { // idle: any; // typing: { }; // } // export interface TextStates extends TextStateScaffold { // idle: {}; // typing: {}; // } // // EVENTS that the machine handles // export type Text_Event_Keystroke = { type: 'KEYSTROKE'; value: any } // export type Text_Event_Stopped = { type: 'STOPPED'; value: any } // export type Text_Event_Focus = { type: 'FOCUS'; value: any } // export type TextEvent = // Text_Event_Keystroke // | Text_Event_Stopped // | Text_Event_Focus // export interface TextEventsScaffold { // 'KEYSTROKE': Function, // 'STOPPED': Function, // 'FOCUS': Function // } // // CONTEXT // export interface TextContext { // debounceMachine: any; // field: IText; // } // interface TextContextUndefined { // debounceMachine: any; // field: undefined; // } // export interface TextStateSchema { initial: string; context: TextContext; states: TextStates }; // export type TextState = // { // value: 'idle'; // context: TextContext & TextContextUndefined; // } | // { // value: 'typing'; // context: TextContext & TextContextUndefined; // };