/*!
 * Copyright 2019-2020 VMware, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */
import { EventEmitter, OnInit } from '@angular/core';
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
import { ClrDropdown } from '@clr/angular';
import { LazyString, TranslationService } from '@vcd/i18n';
import { SubscriptionTracker } from '../common/subscription/subscription-tracker';
import { CsvExporterService } from './csv-exporter.service';
import * as i0 from "@angular/core";
/**
 * Identifiers for each column that user is allowed to select
 */
export interface ExportColumn {
    /**
     * Displayed in the list of columns. If there is no displayName, the default value is fieldName
     */
    displayName?: string;
    /**
     * The name of the field in the JSON that is returned and converted to a viewable format
     */
    fieldName: string;
}
/**
 * Information passed to the caller so they can fetch the data
 */
export interface DataExportRequestEvent {
    /**
     * Call this to indicate a new value to be displayed in the progress indicator.
     * @param progress A number from 0 to 1 indicating download progress. Passing -1 will make it an indeterminate
     */
    updateProgress: (progress: number) => void;
    /**
     * Call this when all records have been fetched to initiate the CSV creation.
     * This should only be called once after all data fetching is finished
     * @param records Records to be converted into a csv file
     * @return a promise of the resulting CSV to indicate when this potentially lengthy process is over
     */
    exportData: (records: object[]) => Promise<string>;
    /**
     * Columns selected by the user.
     */
    selectedColumns: ExportColumn[];
}
export declare const DataUi: {
    /** The label for each check box in the column selection menu */
    columnSelectionMenuOptions: string;
    /** Where the selected columns are displayed, if select all is disabled  */
    columnSelectionBubbles: string;
    cancelButton: string;
    exportButton: string;
    /** The label on the checkbox to select all columns */
    selectAllToggleLabel: string;
    /** The label on the checkbox to enable friendly names */
    friendlyNamesToggleLabel: string;
    /** The progress HTML element containing the value which can be queried for amount of progress     */
    progressInput: string;
    /** The arrow next to Select All columns that lets you collapse the dropdown without checking the box */
    columnCheckboxArrow: string;
    /** The x buttons to close the column bubbles */
    columnBubblesX: string;
};
/**
 * A dialog to export data
 *
 *  - Allows the UI to select columns to be exported
 *  - Provides a progress indicator
 *  - Converts the data that is fetched by the caller into a CSV
 */
export declare class DataExporterComponent implements OnInit {
    private csvExporterService;
    private translationService;
    private subscriptionTracker;
    DataUi: {
        /** The label for each check box in the column selection menu */
        columnSelectionMenuOptions: string;
        /** Where the selected columns are displayed, if select all is disabled  */
        columnSelectionBubbles: string;
        cancelButton: string;
        exportButton: string;
        /** The label on the checkbox to select all columns */
        selectAllToggleLabel: string;
        /** The label on the checkbox to enable friendly names */
        friendlyNamesToggleLabel: string;
        /** The progress HTML element containing the value which can be queried for amount of progress     */
        progressInput: string;
        /** The arrow next to Select All columns that lets you collapse the dropdown without checking the box */
        columnCheckboxArrow: string;
        /** The x buttons to close the column bubbles */
        columnBubblesX: string;
    };
    constructor(csvExporterService: CsvExporterService, translationService: TranslationService, subscriptionTracker: SubscriptionTracker);
    set columnDropdown(columnDropdown: ClrDropdown);
    private _columnDropdown;
    _columns: ExportColumn[];
    /**
     * List of columns that can be exported, user may deselect some before sending the download request.
     * Display name defaults to field name if there is no displayName
     */
    set columns(cols: ExportColumn[]);
    get columns(): ExportColumn[];
    /**
     * The name of the file to be downloaded
     */
    fileName: string;
    /**
     * Text for the Dialog Header
     */
    dialogHeader: LazyString;
    /**
     * Text for the cancel button.
     */
    cancelText: LazyString;
    /**
     * Text for the export all button.
     */
    exportAllText: LazyString;
    /**
     * Text for the select columns dropdown button.
     */
    selectColumnsText: LazyString;
    /**
     * Text for the export button.
     */
    exportText: LazyString;
    /**
     * Text for the yes button.
     */
    yesText: LazyString;
    /**
     * Text for the yes button.
     */
    noText: LazyString;
    /**
     * Text label that is next to the friendly field names checkbox.
     */
    friendlyNamesCheckboxLabel: LazyString;
    /**
     * Text the info message next to the friendly field names checkbox.
     */
    friendlyNamesInfoMessage: LazyString;
    /**
     * Text the hint message below the friendly field names checkbox.
     */
    friendlyNamesHint: LazyString;
    /**
     * Text label that is next to the sanitize checkbox.
     */
    sanitizeCheckboxLabel: LazyString;
    /**
     * Hint message that is below the sanitize checkbox.
     */
    sanitizeCheckboxHint: LazyString;
    /**
     * Text the info message next to the sanitize checkbox.
     */
    sanitizeInfoMessage: LazyString;
    /**
     * The message that is displayed while the data is downloading.
     */
    downloadingMessage: LazyString;
    /**
     * The message that is displayed while the data is writing to file.
     */
    writingMessage: LazyString;
    /**
     * Whether the dialog is open
     */
    set open(value: boolean);
    get open(): boolean;
    private _open;
    /**
     * Fires when {@link _open} changes. Its parameter indicates the new state.
     */
    openChange: EventEmitter<boolean>;
    /**
     * Called when the export is ready to be created
     */
    dataExportRequest: EventEmitter<DataExportRequestEvent>;
    /**
     * True between the time {@link dataExportRequest} fires and {@link DataExportRequestEvent.exportData} is called
     * or an error is thrown
     */
    get isRequestPending(): boolean;
    private _isRequestPending;
    /**
     * Number between 0-1, used for displaying the progress bar.
     */
    get progress(): number;
    private _progress;
    private fieldNameMap;
    formGroup: FormGroup<{
        [key: string]: AbstractControl<boolean>;
    }>;
    exportStage: LazyString;
    optionsFormGroup: FormGroup<{
        selectAll: FormControl<boolean>;
        friendlyNames: FormControl<boolean>;
        sanitize: FormControl<boolean>;
    }>;
    /**
     * Says if the column selection dropdown is open.
     */
    isDropdownOpen: boolean;
    onClickExport(): void;
    get selectAllControl(): FormControl;
    get sanitizeControl(): FormControl;
    get friendlyFieldsControl(): FormControl;
    get isExportEnabled(): boolean;
    get shouldShowBubbles(): boolean;
    /**
     * Gives a list of all the columns that are selected.
     */
    get selectedColumns(): ExportColumn[];
    /**
     * Sets the selected value of the given column.
     */
    selectColumn(column: ExportColumn, selected?: boolean): void;
    /**
     * Gives the selection status of the given column.
     */
    getColumnSelection(column: ExportColumn): boolean;
    ngOnInit(): void;
    private exportData;
    downloadData(data: any[][], shouldSanitize?: boolean): Promise<string>;
    private updateProgress;
    private getDisplayNameForField;
    getDisplayNameForColumn(col: ExportColumn): string;
    private updateFieldNameMap;
    static ɵfac: i0.ɵɵFactoryDeclaration<DataExporterComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<DataExporterComponent, "vcd-data-exporter", never, { "columns": "columns"; "fileName": "fileName"; "dialogHeader": "dialogHeader"; "cancelText": "cancelText"; "exportAllText": "exportAllText"; "selectColumnsText": "selectColumnsText"; "exportText": "exportText"; "yesText": "yesText"; "noText": "noText"; "friendlyNamesCheckboxLabel": "friendlyNamesCheckboxLabel"; "friendlyNamesInfoMessage": "friendlyNamesInfoMessage"; "friendlyNamesHint": "friendlyNamesHint"; "sanitizeCheckboxLabel": "sanitizeCheckboxLabel"; "sanitizeCheckboxHint": "sanitizeCheckboxHint"; "sanitizeInfoMessage": "sanitizeInfoMessage"; "downloadingMessage": "downloadingMessage"; "writingMessage": "writingMessage"; "open": "open"; }, { "openChange": "openChange"; "dataExportRequest": "dataExportRequest"; }, never, never, false, never>;
}
