import m from 'mithril'; import { Component, ComponentAttributes } from '../common/Component'; import { ValidEventTypes } from '../event-emitter/EventEmitter'; import './editor.style.css'; import { SizeType } from '../common/Types'; import { TooltipAttrs } from '../messages/Tooltip'; import { Button } from '..'; declare type LabelAttributes = { text?: string; }; export declare type EditorAttributes = ComponentAttributes & { /** * Specifies wheather control is disabled or not to input value there by the user */ disabled?: boolean; /** * Specifies wheather control's value is required in order to get validation successed */ required?: boolean; /** * Text to place next to the control editor as label. It could be passed and simple text with default options or more complex object with detailed configuration of the label */ label?: string | LabelAttributes; /** * Specifies default value of the control */ value?: T; /** * Specifies default sizes of the control like min, max and defaults width and height */ sizes?: SizeType; /** * Specifies short text message placed below editor control with smaller font size and gray color */ description?: string; /** * Specifies configuration of tooltip to show it on mouse over the control */ tooltip?: TooltipAttrs; /** * Specifies wheather there is clear button visible next to the control. Button allows to clear input's value by single click on it. That setting overrides default setting saved in global configuration */ showClearButton?: boolean; /** * Name of css class to use as editor's icon. Icon is placed on the left side of the control. Icon narrows editor. */ icon?: string; }; export declare type EditorEventTypes = ValidEventTypes & { mouseover: (e: PointerEvent) => void; mouseout: (e: PointerEvent) => void; afterEnable: () => void; afterDisable: () => void; afterValidate: (status: boolean, messages: string[]) => void; afterChange: (value?: T) => void; }; export declare abstract class Editor, E extends EditorEventTypes> extends Component { protected _focused: boolean; protected _validationStatus?: boolean; protected _validationMessages: string[]; protected _editingValue?: string; private _btnClear; protected editorNode?: HTMLElement; constructor(attrs?: A); /** * Returns true/false specifies wheather control is disabled or not to input there value manually by the user * @returns true if control is disabled */ isDisabled(): boolean; /** * Change state of control's disabling. Set it to true to disallow user to input value into control directly, or make it falsy to allow to input values manually * @param disabled new state of control disabling * @returns true if state was changed, otherwise false */ setDisabled(disabled: boolean): boolean; /** * Returns information that control's value is required in order to successed validation * @returns true if control's value is required */ isRequired(): boolean; /** * Change state of control's requirement, then validate it. When state is true, then validation function can success only if value is not empty. * @param required new state of control requirement * @returns true if state was changed, otherwise false */ setRequired(required: boolean): boolean; /** * Get current value of the control * @returns current value of the control of unformatted style */ getValue(): T | undefined; /** * Sets current value of the control, then validates control * @param value new value to set * @param suppressEvents when true, then change event does not emit */ setValue(value?: T, suppressEvents?: boolean): void; /** * Clears current value of the control. It is equivalent to "setValue(undefined)" */ clear(): void; /** * Checks that value of the control is correct or not and changes style of the control depends on the validation result * @param value value to validate control by with * @param suppressEvents true to suppress "afterValidate" event emission * @returns true if validation is successed or false in case of failure */ validate(value?: T, suppressEvents?: boolean): boolean; view(): m.Children | m.Vnode; protected _setEditingValue(value?: string): void; protected _getButtons(): Button[]; protected abstract controlView(): m.Children | m.Vnode; protected _getEditorContentAttrs(attrs: m.Attributes): m.Attributes; protected _getEditorAttrs(attrs: m.Attributes): m.Attributes; private _getSizes; private _getDescription; private _getLabel; protected _setFocus(focus: boolean): void; } export {}; //# sourceMappingURL=Editor.d.ts.map