"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringFloatingFilter = void 0;
var aurelia_framework_1 = require("aurelia-framework");
var aurelia_i18n_1 = require("aurelia-i18n");
var base_floating_filter_1 = __importDefault(require("../base-floating-filter"));
var string_filter_helper_1 = require("./string-filter-helper");
var StringFloatingFilter = (function (_super) {
    __extends(StringFloatingFilter, _super);
    function StringFloatingFilter() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    StringFloatingFilter.prototype.init = function (params) {
        var _this = this;
        var _a, _b;
        this.filterHelper = new string_filter_helper_1.StringFilterHelper((_a = params.searchMinLength) !== null && _a !== void 0 ? _a : 0, (_b = params.isMultiple) !== null && _b !== void 0 ? _b : true, function () { return _this.textDisplayedChanged(); });
        _super.prototype.init.call(this, params);
        this.showInputField = true;
        this.showDropdown = false;
        this.i18n = aurelia_framework_1.Container.instance.get(aurelia_i18n_1.I18N);
        _super.prototype.setupGui.call(this);
    };
    StringFloatingFilter.prototype.setupContentGui = function () {
        return "<div class=\"floating-filter__body__search\">\n              <ui-input type=\"text\" value.bind=\"filterHelper.textDisplayed & debounce:500\" t=\"[placeholder]common:grid.searchShort\" autofocus.one-time=\"true\" allow-clear.one-time=\"true\">\n                <ui-input-addon icon=\"digi-search\"></ui-input-addon>\n              </ui-input>\n              <div class=\"ui-check__wrapper\" if.bind=\"showEmptyFieldsCheckbox\">\n                <ui-checkbox checked.bind=\"filterHelper.displayEmptyFields\">${ 'grid.displayEmptyFields' | t }</ui-checkbox>\n              </div>\n            </div>";
    };
    StringFloatingFilter.prototype.setupInputField = function () {
        return "<input value.bind='filterHelper.textDisplayed & debounce:500' style='display: inline-flex; margin: 0; height: 100%;'>";
    };
    StringFloatingFilter.prototype.textDisplayedChanged = function () {
        var _this = this;
        this.params.parentFilterInstance(function (instance) {
            instance.setModel({ filterType: 'text', type: 'contains', filter: _this.filterHelper.text, isMultiple: _this.filterHelper.isMultiple, displayEmptyFields: _this.filterHelper.displayEmptyFields });
        });
    };
    StringFloatingFilter.prototype.resetFilter = function () {
        this.filterHelper.resetFilter();
    };
    StringFloatingFilter.prototype.onParentModelChanged = function (parentModel, filterChangedEvent) {
        this.filterHelper.textDisplayed = ((parentModel && parentModel.filter) ? parentModel.filter : null);
    };
    StringFloatingFilter.prototype.getModelAsString = function () {
        return this.filterHelper.getModelAsString();
    };
    StringFloatingFilter.prototype.setupContentGuiSideFilter = function () {
        return this.filterHelper.setupContentGuiSideFilter();
    };
    StringFloatingFilter.prototype.applyObservers = function () {
        this.dispose();
        this.disposables.push(this.bindingEngine.propertyObserver(this.filterHelper, 'displayEmptyFields').subscribe(this.textDisplayedChanged.bind(this)));
    };
    return StringFloatingFilter;
}(base_floating_filter_1.default));
exports.StringFloatingFilter = StringFloatingFilter;

//# sourceMappingURL=string-floating-filter.js.map
