import { ElementRef, Renderer2, EventEmitter, ViewContainerRef, OnInit, Injector, AfterContentInit, OnDestroy } from '@angular/core'; import { ControlValueAccessor, NgControl } from '@angular/forms'; import { TemplateService } from '../utils/template.service'; import { TableEditorConfig } from '../utils/config.service'; export declare enum CellState { Inputified = 0, Cellified = 1 } export declare enum CellDisabledState { Disabled = 0, Enabled = 1 } /** @internal */ export declare enum InputPromiseState { Pending = 0, Resolved = 1, Canceled = 2 } /** * This is the abstract ControlValueAccessor class which is implemented by the [DateCell]{@link DateCellContolValueAccessor}, [TextCell]{@link TextCellContolValueAccessor} and [NumberCell]{@link NumberCellControlValueAccessor} directives. Do not inject this class anywhere. * You should either use one of the implementing classes mentioned above, or implement your own `CellControlValueAccessor` class as described [in the README of this page]{@link /documentation/injectables/AbstractTableCell.html#readme}. * * For usage see [the examples]{@link demo/#/examples/basic}. * */ export declare abstract class AbstractTableCell implements OnInit, ControlValueAccessor, AfterContentInit, OnDestroy { private config; protected el: ElementRef; protected renderer: Renderer2; protected viewContainer: ViewContainerRef; protected injector: Injector; /** * Use this `Input` attribute to select choose a `ControlValueAccessor`. * @param boolean value The supported types are `date`, `text`, `number`. For additional types, install `ngx-table-editor/extra`. It contains support for `typeahead`. */ type: string; /** * Use this `Input` attribute to enable or disable a table cell in a declarative way at the level of the template. * For example: ` .... `. * @param boolean value A variable to disable or enable editor mode for this cell. */ teDisabled: boolean; disabled: CellDisabledState; teCellClick: EventEmitter; teBlockNavigationEventEmitter: EventEmitter; protected onBlurEventEmitter: EventEmitter; protected onKeyUpEventEmitter: EventEmitter; protected ngControl: NgControl; /** @internal */ private inputTemplateRef; /** @internal */ private innerViewContainer; /** @internal */ private resolveElementFn; /** @internal */ private inputPromise; /** @internal */ private inputPromiseState; /** @internal */ private inputElement; /** @internal */ private unlistenFnCollection; /** @internal */ private state; /** @internal */ private cellAnchor; /** @internal */ private class; constructor(ts: TemplateService, config: TableEditorConfig, el: ElementRef, renderer: Renderer2, viewContainer: ViewContainerRef, injector: Injector); protected onClick(event: MouseEvent): void; /** This method needs to be implemented for Angulars built-in [ControlValueAccessor interface]{@link https://angular.io/api/forms/ControlValueAccessor}. See the docs on how to implement one. */ abstract writeValue(modelValue: any): void; /** This method needs to be implemented for Angulars built-in [ControlValueAccessor interface]{@link https://angular.io/api/forms/ControlValueAccessor}. See the docs on how to implement one.*/ abstract registerOnChange(fn: any): void; /** This method needs to be implemented for Angulars built-in [ControlValueAccessor interface]{@link https://angular.io/api/forms/ControlValueAccessor}. See the docs on how to implement one.*/ abstract registerOnTouched(fn: any): void; /** * This method needs to be implemented to tell the ControlValueAccessor how to parse the string value from an inputfield to the model (input -> model). This is useful for example in the implementation of [DateCell]{@link DateCellContolValueAccessor}, where the `inputValue` will be a string representation of the Date, whereas we want to store native `Date` objects in the model. * @param string inputValue The `value` attribute of the native `HTMLInputElement`. * @returns any */ abstract parser(inputValue: string): any; /** * This method needs to be implemented to tell the ControlValueAccessor how to format a the value in a table cell with state `Cellified` * (model -> cellView). * @param any modelValue The value as in `NgControl`. * @returns string */ abstract cellValueFormatter(modelValue: any): string; /** * This method needs to be implemented to tell the ControlValueAccessor how to format the value in a input field within a table cell with state `Inputified` (model -> inputView). * @param any modelValue The value as in `NgControl`. * @returns string */ abstract inputValueFormatter(modelValue: any): string; /** * Programmatically set the inner text of a tableCell. Only works when the [cell state is cellified]{@link AbstractTableCell#state}. This method is used internally to set the initial inner text table cell when cellified. The method can be used to override the inner text of the table cell. * @param string value? When no value is given as an argument, the most recent value of `ngControl` is converted using the [cellValueFormatter]{@link cellValueFormatter}. * @returns void */ protected setCellValue(value: any): void; /** * Programmatically set the value of the inputfield within a tableCell. Only works when the [cell state is inputified]{@link AbstractTableCell#state}. This method is used internally to set the initial value of the input field when inputified. The method can be used to override the value of the input field in other moments of the lifecycle. * @param string value? When no value is given as an argument, the most recent value of `ngControl` is converted using the [inputValueFormatter]{@link inputValueFormatter}. Calling this method directly thus makes it possible to render to the input field avoiding the inputValueFormatter. * @returns void */ protected setInputValue(value?: string): void; /** * Override this method to execute some code right after a cell is inputified. This can be used for example to override the initial value of the input field, using {@link AbstractTableCell#setInputValue}. * @returns void */ protected teAfterInputify(): void; /** @internal This method is exposed publically because it is used internally by `TableEditorRowDirective` to inputify a cell. It should not be called manually. It is asynchronous because exposing the native `HTMLInputElement` is done using an `Observable`.*/ inputify(): Promise; /** @internal This method is exposed publically because it is used internally by `TableEditorRowDirective` to cellify a cell. It should not be called manually. */ cellify(): void; /** @internal This method is exposed publically because it is used internally by `TableEditorDirective` to set focus on a cell. It should not be called manually. */ focus(): Promise; /** @internal */ private formatCell; /** @internal */ private clearText; /** @internal */ private inputPromiseFactory; /** @internal */ ngOnDestroy(): void; /** @internal */ ngAfterContentInit(): void; /** @internal */ ngOnInit(): void; }