@blinkk/selective-edit
Version:
Selective structured text editor.
80 lines (79 loc) • 2.77 kB
TypeScript
import { DeepObject } from '../../utility/deepObject';
import { Field, FieldConfig } from '../field';
import { GlobalConfig, SelectiveEditor } from '../editor';
import { TemplateResult } from 'lit-html';
import { FieldsComponent } from '../fields';
import { Types } from '../types';
export interface VariantOptionConfig {
/**
* Fields to show when the variant is in use.
*/
fields: Array<FieldConfig>;
/**
* Label for the variant option.
*/
label?: string;
/**
* Help text to explain the variant.
*/
help?: string;
}
export interface VariantFieldConfig extends FieldConfig {
/**
* Label for presenting the variants as options.
*/
variantLabel?: string;
/**
* Variant options the user are allowed to select from.
*/
variants: Record<string, VariantOptionConfig>;
}
export declare class VariantField extends Field {
config: VariantFieldConfig;
fields?: FieldsComponent;
usingAutoFields: boolean;
variant?: string;
constructor(types: Types, config: VariantFieldConfig, globalConfig: GlobalConfig, fieldType?: string);
protected createFields(): FieldsComponent | undefined;
protected ensureFields(): void;
handleVariantClick(evt: Event): void;
handleVariantClear(evt: Event): void;
get isClean(): boolean;
/**
* Check if the data format is invalid for what the field expects to edit.
*/
get isDataFormatValid(): boolean;
get isValid(): boolean;
/**
* Template for rendering the field input.
*
* The help text is part of the input template so complex inputs can
* use zones for the help text.
*
* @param editor Selective editor used to render the template.
* @param data Data provided to render the template.
*/
templateInput(editor: SelectiveEditor, data: DeepObject): TemplateResult;
/**
* Template for rendering the field input structure.
*
* @param editor Selective editor used to render the template.
* @param data Data provided to render the template.
*/
templateInputStructure(editor: SelectiveEditor, data: DeepObject): TemplateResult;
/**
* Template for rendering the variant options.
*
* @param editor Selective editor used to render the template.
* @param data Data provided to render the template.
*/
templateVariants(editor: SelectiveEditor, data: DeepObject): TemplateResult;
/**
* Template for rendering the field wrapper.
*
* @param editor Selective editor used to render the template.
* @param data Data provided to render the template.
*/
templateWrapper(editor: SelectiveEditor, data: DeepObject): TemplateResult;
get value(): Record<string, any>;
}