@blinkk/selective-edit
Version:
Selective structured text editor.
51 lines (50 loc) • 1.86 kB
TypeScript
import { FieldConfig } from './field';
export interface AutoFieldsConfig {
ignoreKeys?: Array<string>;
ignorePatterns?: Array<string>;
}
export interface AutoFieldsComponent {
config: AutoFieldsConfig;
/**
* Use the provided data to guess what types of field to use
* to edit the data.
*
* @param key Key to use in the configuration.
* @param data Data to use for guessing field configurations.
*/
guessField(key: string, data: any): FieldConfig;
/**
* Use the provided data to guess what types of fields to use
* to edit the data.
*
* @param data Data to use for guessing field configurations.
*/
guessFields(data: any): Array<FieldConfig>;
}
export interface AutoFieldsConstructor {
new (config: AutoFieldsConfig): AutoFieldsComponent;
}
export declare class AutoFields implements AutoFieldsComponent {
config: AutoFieldsConfig;
constructor(config?: AutoFieldsConfig);
protected deepGuess(data: any, keyBase?: Array<string>): Array<FieldConfig>;
protected deepGuessArray(data: Array<any>, keyBase?: Array<string>): Array<FieldConfig>;
protected deepGuessObject(data: Record<string, any>, keyBase?: Array<string>): FieldConfig[];
protected deepGuessSimple(data: any, keyBase?: Array<string>): FieldConfig;
guessField(key: string, data: any): FieldConfig;
guessFields(data: any): Array<FieldConfig>;
/**
* Guess the type of field to use based on the key and value.
*
* @param key Key to guess the type of field.
* @param data Data to use for guessing field type.
*/
guessType(key: string, data: any): string;
protected isIgnoredKey(key: string): boolean;
}
/**
* From the key guess the label of the field.
*
* ex: key.subKey => Key SubKey
*/
export declare function guessLabel(key: string): string;