// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
import { TableSelectionType } from '../../../../Types/TableSelectionType';
// #endregion
/**
 * The `DataTableElementValueAccessor` class.
 *
 * @public
 */
export class DataTableElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * @public
     */
    hostConnected() {
        this.host.on('tableSelectionChanged', (e) => {
            if (this.host.selectionType === TableSelectionType.Cell) {
                this.writeValue(e.detail.selectedCells);
            }
            else {
                this.writeValue(e.detail.selectedRows);
            }
        });
        this.host.on('blur', () => this.onTouched());
    }
    /**
     * @public
     * @override
     */
    writeValue(value) {
        super.writeValue(value ?? []);
    }
    /**
     * @public
     * @override
     */
    resetValue() {
        super.resetValue();
    }
}
/**
 * The `dataTableElementValueAccessor` function for the `DataTableElement`.
 * This accessor can be bind to form field controls.
 *
 * @public
 */
export const dataTableElementValueAccessor = (host) => new DataTableElementValueAccessor(host);
//# sourceMappingURL=DataTableElementValueAccessor.js.map