/*!
 *
 * carbon-angular v0.0.5 | table-toolbar.component.js
 *
 * Copyright 2014, 2019 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import { TableModel } from "../table-model.class";
import { Component, Input } from "@angular/core";
import { I18n } from "../../i18n/i18n.module";
/**
 * The table toolbar is reserved for global table actions such as table settings, complex filter, export, or editing table data.
 *
 * ## Basic usage
 *
 * ```html
 * <ibm-table-toolbar [model]="model">
 *		<ibm-table-toolbar-actions>
 *			<button ibmButton="primary">
 *				Delete
 *				<ibm-icon-delete16 class="bx--btn__icon"></ibm-icon-delete16>
 *			</button>
 *			<button ibmButton="primary">
 *				Save
 *				<ibm-icon-save16 class="bx--btn__icon"></ibm-icon-save16>
 *			</button>
 *			<button ibmButton="primary">
 *				Download
 *				<ibm-icon-download16 class="bx--btn__icon"></ibm-icon-download16>
 *			</button>
 *		</ibm-table-toolbar-actions>
 *			<ibm-table-toolbar-content>
 *			<ibm-table-toolbar-search [expandable]="true"></ibm-table-toolbar-search>
 *			<button ibmButton="toolbar-action">
 *				<ibm-icon-settings16 class="bx--toolbar-action__icon"></ibm-icon-settings16>
 *			</button>
 *			<button ibmButton="primary" size="sm">
 *				Primary Button
 *				<ibm-icon-add20 class="bx--btn__icon"></ibm-icon-add20>
 *			</button>
 *		</ibm-table-toolbar-content>
 *	</ibm-table-toolbar>
 * ```
 *
 */
var TableToolbar = /** @class */ (function () {
    function TableToolbar(i18n) {
        this.i18n = i18n;
        this.actionBarLabel = this.i18n.getOverridable("TABLE_TOOLBAR.ACTION_BAR");
        this._cancelText = this.i18n.getOverridable("TABLE_TOOLBAR.CANCEL");
    }
    Object.defineProperty(TableToolbar.prototype, "ariaLabel", {
        set: function (value) {
            this.actionBarLabel.override(value.ACTION_BAR);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TableToolbar.prototype, "cancelText", {
        get: function () {
            return { CANCEL: this._cancelText.value };
        },
        set: function (value) {
            this._cancelText.override(value.CANCEL);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TableToolbar.prototype, "count", {
        get: function () {
            return this.model.totalDataLength > 0 ? this.model.rowsSelected.reduce(function (previous, current) { return previous + (current ? 1 : 0); }, 0) : 0;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TableToolbar.prototype, "selected", {
        get: function () {
            return this.model.totalDataLength > 0 ? this.model.rowsSelected.some(function (item) { return item; }) : false;
        },
        enumerable: true,
        configurable: true
    });
    TableToolbar.prototype.onCancel = function () {
        for (var i = 0; i < this.model.rowsSelected.length; i++) {
            this.model.selectRow(i, false);
        }
    };
    TableToolbar.decorators = [
        { type: Component, args: [{
                    selector: "ibm-table-toolbar",
                    template: "\n\t<section class=\"bx--table-toolbar\">\n\t\t<div\n\t\t\tclass=\"bx--batch-actions\"\n\t\t\t[ngClass]=\"{\n\t\t\t\t'bx--batch-actions--active': selected\n\t\t\t}\"\n\t\t\t[attr.aria-label]=\"actionBarLabel.subject | async\">\n\t\t\t<div class=\"bx--action-list\">\n\t\t\t\t<ng-content select=\"ibm-table-toolbar-actions\"></ng-content>\n\t\t\t\t<button ibmButton=\"primary\" class=\"bx--batch-summary__cancel\" (click)=\"onCancel()\">{{_cancelText.subject | async}}</button>\n\t\t\t</div>\n\t\t\t<div class=\"bx--batch-summary\">\n\t\t\t\t<p class=\"bx--batch-summary__para\">\n\t\t\t\t\t<span>{{count}}</span> items selected\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t</div>\n\t\t<ng-content></ng-content>\n\t</section>\n\t"
                },] },
    ];
    /** @nocollapse */
    TableToolbar.ctorParameters = function () { return [
        { type: I18n }
    ]; };
    TableToolbar.propDecorators = {
        model: [{ type: Input }],
        ariaLabel: [{ type: Input }],
        cancelText: [{ type: Input }]
    };
    return TableToolbar;
}());
export { TableToolbar };
//# sourceMappingURL=table-toolbar.component.js.map