/// import * as React from "react"; import * as ActionEmitter from "action-emitter"; import * as PropTypes from "prop-types"; import { CoreFieldProps, FieldValue, FieldContext, FieldStoreState, FieldChildContext } from "../contracts/field"; import { FormStore } from "../stores/form-store"; import { FormStoreStateRecord } from "../contracts/form-store"; import { ModifierValue } from "../contracts/value"; export interface CoreFieldState { FormStoreState: FormStoreStateRecord; Value?: FieldValue; } export declare abstract class CoreField extends React.Component { context: FieldContext; static contextTypes: PropTypes.ValidationMap; static childContextTypes: PropTypes.ValidationMap; getChildContext(): FieldChildContext; static defaultProps: CoreFieldProps; protected readonly DestroyOnUnmount: boolean; protected readonly DefaultModifiers: JSX.Element[]; protected readonly DefaultNormalizers: JSX.Element[]; protected readonly FormId: string; protected readonly FormStore: FormStore; protected readonly FieldId: string; protected readonly FieldsGroupId: string; protected readonly FieldState: FieldStoreState; protected readonly Name: string; protected StoreEventSubscription: ActionEmitter.EventSubscription; componentWillMount(): void; componentWillReceiveProps(nextProps: TProps): void; componentWillUnmount(): void; /** * ======================== * Protected methods * ======================== */ /** * Is field currently controlled. */ protected readonly abstract IsControlled: boolean; /** * Current or default field value. */ protected readonly Value: FieldValue; protected readonly abstract ControlledValue: FieldValue; protected ProcessValueBeforeStore(value: FieldValue): ModifierValue; protected ProcessValueFromStore(value: FieldValue): FieldValue; protected ParseValue(value: ModifierValue): ModifierValue; protected FormatValue(value: FieldValue): FieldValue; protected NormalizeValue(value: FieldValue): FieldValue; protected ChildrenToRender(): void; protected OnStoreUpdated(): void; protected OnValueChange(newValue: FieldValue, processValue?: boolean): void; protected Focus(): void; protected Blur(): void; protected readonly IsInFieldsArray: boolean; /** * ======================== * Abstract methods * ======================== */ /** * React Component's render method */ abstract render(): JSX.Element | null; /** * Default field value. */ protected abstract GetRawDefaultValue(props: TProps): FieldValue; /** * Initial value. */ protected abstract GetRawInitialValue(props: TProps): FieldValue; /** * Value before render. * Most common usage is for getting value from field props. */ protected abstract GetRawValue(props: TProps): FieldValue; /** * ======================== * Local helper methods * ======================== */ private processedOrEmptyModifierValue(value, processor); /** * Registers a field in FormStore or throws if the field was already registered */ private registerFieldInFormStore(); private updateFormStoreFieldValues(defaultValue, initialValue, value); }