import { Model, Components } from '@singularsystems/neo-core'; import { IInputSpecificProps } from './Input'; import DropDown, { IDropDownSpecificProps } from './DropDown/DropDown'; import NumberInput, { INumberInputSpecificProps } from './NumberInput'; import DatePicker from './DatePicker'; import Input from './Input'; import RadioList, { IRadioListSpecificProps } from './RadioList'; import * as React from 'react'; import { TransformMetaType } from '@singularsystems/neo-core/dist/Model/IModelBase'; import PropertyInfo from '@singularsystems/neo-core/dist/Model/PropertyInfo'; import { IComponentBase } from './ComponentBase'; import FileInput, { IFileEditorProps } from './FileManager/FileInput'; import { FormContextParams } from './FormContext'; export type ItemCallback = (item: T, meta: TransformMetaType, isHeader: boolean, index: number) => React.ReactNode; export declare enum ControlType { Date = 0, Number = 1, DropDown = 2, Text = 3, File = 4, RadioList = 5 } export declare enum CheckboxType { None = 0, Checkbox = 1, Switch = 2 } export interface ICommonEditorProps { /** True if the editor should be readonly. This is set automatically if you use display instead of bind on a FormGroup / Column. */ isReadOnly?: boolean; /** True if the editor should be readonly. This is set automatically if you use display instead of bind on a FormGroup / Column. */ readOnly?: boolean; /** True if the editor should be disabled */ isDisabled?: boolean; /** True if the editor should be disabled */ disabled?: boolean; /** Will show this text in a block before the input */ prependText?: string; /** Will show this text in a block after the input */ appendText?: string; /** Additional element to include before the input element */ prepend?: (() => React.ReactNode) | React.ReactNode | null; /** Additional element to include after the input element */ append?: (() => React.ReactNode) | React.ReactNode | null; /** Icon name or component */ prependIcon?: any; /** Icon name or component */ appendIcon?: any; /** True if append / prepend is set, which means this must be an editor as part of a bs editor group. */ requiresGroup?: boolean; /** Reference to the input dom element */ inputElement?: React.RefObject; } export interface IBindableEditorPropsNoBase extends ICommonEditorProps { bind: Model.IPropertyInstance; placeholder?: string | boolean; } export interface IBindableEditorProps extends IBindableEditorPropsNoBase, React.HTMLProps { /** * HTML Placeholder to display when the input control has no value. * Value of true results in the readable property name being used. */ placeholder?: any; children?: any; } interface IEditorSelectorProps { /** Drop down props if this editor must be a drop down */ select?: IDropDownSpecificProps; /** Input props if this editor is a text / check input */ input?: IInputSpecificProps; /** Number props if this editor is a numeric editor */ numProps?: INumberInputSpecificProps; /** Date props if this editor is a date editor */ dateProps?: Components.IPartialDateProps; /** Radio list props if this is a radio button list. */ radioList?: IRadioListSpecificProps; /** File props if this editor is a file editor */ fileProps?: IFileEditorProps; } interface ICommonContainerOwnProps { /** Label / header text */ label?: string | React.ReactNode; /** True if the editor / display value should be suppressed. Children will still be rendered. */ suppressDefaultContent?: boolean; /** * Allows use of a custom component in a form group / column. * Child components can read information from the container using the EditorContainerContext. * suppressDefaultContent will be set to true if unset. */ bindContext?: Model.IPropertyInstance; /** * Tooltip to display on hover of the editor. */ editorTooltip?: string | Components.Tooltip.ITooltipOptions; /** * Classname to add to the editor. */ editorClassName?: string; /** * Styles to apply to the editor. */ editorStyle?: React.CSSProperties; } interface IEditorAndSelectorProps extends IBindableEditorProps, IEditorSelectorProps { } export interface IEditorContainerProps extends Partial>, ICommonContainerOwnProps { label?: Components.ElementOrText; /** Bind property if you want the editor to be readonly. */ display?: Model.IPropertyInstance; /** Dom properties to apply to the underlying editor. */ editorProps?: React.HTMLProps; /** Id for the editor element. */ id?: string; } export interface IEditorNormalisedProps extends IEditorSelectorProps { bind: Model.IPropertyInstance; editor: IBindableEditorProps; editorDom: TDom; /** True if the editor is in a form group with a label and error display. */ inGroup: boolean; /** Unique id for the editor and label. */ uniqueID: string; isBootstrap: boolean; } export interface IEditorContainerNormalisedProps extends IEditorNormalisedProps { container: ICommonContainerOwnProps; containerDom: TDom; } export declare class BindPropsHelper { static readonly DataFieldName = "data-field-name"; private static _config; private static get config(); /** * Gets the correct input control type based on the props. E.g. Input / DatePicker / Select * @param props Props passed to a multi type input container. E.g. FormGroup / Column */ static getFormControl(props: IEditorNormalisedProps): React.CElement | React.CElement | React.CElement, DropDown> | React.CElement | React.CElement | React.CElement, RadioList>; static getControlType(props: IEditorNormalisedProps): ControlType; static getCheckBoxType(props: IEditorNormalisedProps, instance?: any): CheckboxType; /** * Get the main bind property from a props object */ static getBindProperty(allProps: IEditorContainerProps): Model.IPropertyInstance; static splitCommonEditorProps(props: T): { editor: ICommonEditorProps; rest: Omit; }; static normaliseContainerProps, TData = any>(component: IComponentBase, props: IEditorContainerProps, inGroup: boolean, isBootstrap?: boolean): IEditorContainerNormalisedProps; static normaliseEditorProps>(component: IComponentBase, props: (IEditorAndSelectorProps & TDom) | IEditorNormalisedProps): IEditorNormalisedProps; static getUniqueId(bindProperty: Model.IPropertyInstance, component: IComponentBase): string; static getPlaceholderText(placeholder: string | boolean | undefined, property: PropertyInfo): string | undefined; static autoSetDomProperties>(props: IEditorNormalisedProps, formContext: FormContextParams, componentBlurFn?: (e: React.FocusEvent) => void, componentFocusFn?: (e: React.FocusEvent) => void): TDom; static isReadOnly(editorProps: ICommonEditorProps, formContext: FormContextParams): boolean; static isDisabled(editorProps: ICommonEditorProps, formContext: FormContextParams): boolean; /** * Intercept the user specified blur event, and run the validation onBlur logic first. * @param props Props specified on component. * @param blurFn Blur function used internally by component. */ private static blurIntercept; } export {};