import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "../click-outside.directive";
import * as i3 from "../pipes/pascal.pipe";
export class CsSelectComponentUI {
    constructor() {
        this.selectedData = new EventEmitter();
        this.selectedValueChange = new EventEmitter();
        this.dropdownOption = false;
        this.activeDoropdown = false;
    }
    set content(content) {
        if (content) {
            // initially setter gets called with undefined
            this.optionList = content;
        }
    }
    ngOnChanges(changes) {
        if (changes['selectedValue']) {
            this.selectedValue = this.selectedValue || '--';
        }
    }
    openDropdown(event) {
        this.dropdownOption = true;
        setTimeout(() => {
            const dropdown = event.target.getBoundingClientRect();
            const selectOption = this.optionList.nativeElement.offsetHeight;
            if (dropdown.top + selectOption * 2 > window.innerHeight) {
                this.getTop = dropdown.top - selectOption;
            }
            else {
                this.getTop = dropdown.top + dropdown.height;
            }
            this.getLeft = dropdown.left;
            this.getWidth = dropdown.width;
            this.maxWidth = dropdown.width * 1.25;
        }, 10);
        setTimeout(() => {
            this.activeDoropdown = true;
        }, 100);
    }
    selectOption(selectedData) {
        if (typeof selectedData === 'object') {
            this.selectedValue = selectedData[this.displayProperty];
            this.colorSelected = selectedData[this.colorProperty];
        }
        else {
            this.selectedValue = selectedData;
        }
        this.selectedData.emit(selectedData);
        this.dropdownOption = false;
    }
    closeDropdown() {
        this.dropdownOption = false;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CsSelectComponentUI, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: CsSelectComponentUI, selector: "app-cs-select", inputs: { dataList: "dataList", dropdownLabel: "dropdownLabel", displayProperty: "displayProperty", selectedValue: "selectedValue", isRequired: "isRequired", dropdownSubLabel: "dropdownSubLabel", disabled: "disabled", placeholder: "placeholder", stylex: "stylex", valueKey: "valueKey", multipleSelect: "multipleSelect", colorProperty: "colorProperty", colorSelected: "colorSelected" }, outputs: { selectedData: "selectedData", selectedValueChange: "selectedValueChange" }, viewQueries: [{ propertyName: "option", first: true, predicate: ["option"], descendants: true }, { propertyName: "content", first: true, predicate: ["optionList"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"input-group\" (clickOutside)=\"dropdownOption = false\">\n  <label *ngIf=\"dropdownLabel != undefined\">\n    {{ dropdownLabel }} <span class=\"sub-label\">{{ dropdownSubLabel }}</span> <span class=\"required\" *ngIf=\"isRequired\">*</span></label\n  >\n  <div class=\"custom-select-box\" [class.disabled]=\"disabled\">\n    <input\n      type=\"text\"\n      [class.line]=\"stylex\"\n      [placeholder]=\"placeholder\"\n      [value]=\"selectedValue | pascal\"\n      readonly\n      (click)=\"openDropdown($event)\"\n      (keyup.enter)=\"openDropdown($event)\"\n      (keyup.arrowup)=\"openDropdown($event)\"\n      (keyup.arrowdown)=\"openDropdown($event)\"\n      *ngIf=\"!colorProperty\"\n    />\n    <span class=\"show-label\" *ngIf=\"colorProperty\" (click)=\"openDropdown($event)\">\n      <span class=\"label\" [innerHTML]=\"selectedValue\" [style.backgroundColor]=\"colorSelected + '1A'\" [style.color]=\"colorSelected\"></span>\n    </span>\n    <!-- <span class=\"arrow\" [class.line]=\"stylex\">\n      <i class=\"icons\">&#xe9e8;</i>\n    </span> -->\n    <div class=\"overlay active\" *ngIf=\"dropdownOption === true\" (click)=\"closeDropdown()\"></div>\n    <ul\n      class=\"list-of-option\"\n      *ngIf=\"dropdownOption === true && !colorProperty\"\n      #optionList\n      (keyup.Escape)=\"closeDropdown()\"\n      [style.top.px]=\"getTop\"\n      [style.left.px]=\"getLeft\"\n      [style.min-width.px]=\"getWidth\"\n      [style.max-width.px]=\"maxWidth\"\n      [class.active]=\"activeDoropdown\"\n    >\n      <li *ngFor=\"let data of dataList\">\n        <label>\n          <input type=\"radio\" [value]=\"data[valueKey]\" name=\"sliceLabel\" (change)=\"selectOption(data)\" #option (keyup.enter)=\"closeDropdown()\" class=\"pointer-none\" />\n          <span (click)=\"closeDropdown(); selectOption(data)\" *ngIf=\"displayProperty && displayProperty !== ''\" class=\"value\">{{ data[displayProperty] }}</span>\n          <span (click)=\"closeDropdown(); selectOption(data)\" *ngIf=\"!displayProperty || displayProperty === ''\" class=\"value\">{{ data }}</span>\n        </label>\n      </li>\n    </ul>\n    <ul\n      class=\"list-of-option\"\n      *ngIf=\"dropdownOption === true && colorProperty\"\n      #optionList\n      (keyup.Escape)=\"closeDropdown()\"\n      [style.top.px]=\"getTop\"\n      [style.left.px]=\"getLeft\"\n      [style.min-width.px]=\"getWidth\"\n      [style.max-width.px]=\"maxWidth\"\n      [class.active]=\"activeDoropdown\"\n    >\n      <li *ngFor=\"let data of dataList\">\n        <label class=\"colors\">\n          <input type=\"radio\" [value]=\"data[valueKey]\" name=\"sliceLabel\" (click)=\"selectOption(data)\" #option (keyup.enter)=\"closeDropdown()\" class=\"pointer-none\" />\n          <span\n            (click)=\"selectOption(data)\"\n            *ngIf=\"displayProperty && displayProperty !== ''\"\n            class=\"value\"\n            [ngStyle]=\"{ color: data.segment_color }\"\n            [style.backgroundColor]=\"data.segment_color + '1A'\"\n            >{{ data[displayProperty] }}</span\n          >\n          <span\n            (click)=\"selectOption(data)\"\n            *ngIf=\"!displayProperty || displayProperty === ''\"\n            class=\"value\"\n            [ngStyle]=\"{ color: data.segment_color }\"\n            [style.backgroundColor]=\"data.segment_color + '1A'\"\n            >{{ data }}</span\n          >\n        </label>\n      </li>\n    </ul>\n  </div>\n</div>\n", styles: [".input-group{position:relative;margin-bottom:0}.input-group label{font-size:11px;color:#161b2f;font-weight:500;line-height:16px;margin-bottom:5px;text-transform:uppercase;display:block}.input-group label span.required{color:#eb2424;font-size:14px}.input-group label span.sub-label{color:#747576;font-size:11px;font-weight:400;margin-left:3px}.input-group input[type=text],.input-group .show-label{height:36px;line-height:16px;font-size:13px;color:#747576;font-weight:400;background:#fff;border:1px solid #dbdbdb;border-radius:4px;width:100%;padding:10px 13px;display:block;outline:none;overflow:hidden;text-overflow:ellipsis}.input-group input[type=text].line,.input-group .show-label.line{border:none;border-bottom:1px solid #dbdbdb;border-radius:0;padding-left:0}.input-group .show-label{display:flex;padding:6px;padding-right:25px!important;cursor:pointer}.input-group .show-label .label{white-space:nowrap;padding:2px 5px;height:100%;overflow:hidden;text-overflow:ellipsis;display:block;width:100%;text-transform:uppercase;font-size:11px;font-weight:600;line-height:15px;pointer-events:none}.input-group:focus-within input[type=text]{border-color:#1e5dd3;box-shadow:0 3px 6px #1e5dd333}.input-group:focus-within input[type=text].line{box-shadow:none}.input-group .custom-select-box{background:#fff;position:relative;z-index:1}.input-group .custom-select-box:after{border-bottom-style:solid;border-bottom-width:1px;border-right-style:solid;border-right-width:1px;border-color:#707070;content:\"\";display:inline-block;right:15px;position:absolute;top:calc(50% - 4px);width:5px;height:5px;transform:rotate(45deg);z-index:-1}.input-group .custom-select-box input[type=text],.input-group .custom-select-box .input{cursor:pointer;padding-right:30px;background:transparent}.input-group .custom-select-box input[type=text].line,.input-group .custom-select-box .input.line{padding-right:20px}.input-group .custom-select-box.disabled{filter:grayscale(1);pointer-events:none}.input-group .arrow{position:absolute;right:17px;color:#747576;bottom:8px;font-size:10px;pointer-events:none}.input-group .arrow.line{right:5px}ul.list-of-option{position:fixed;overflow:auto;max-height:200px;padding:0;margin:0;display:block;border:1px solid #dbdbdb;box-shadow:0 3px 6px #1e5dd333;z-index:2147483002;background:#fff;border-radius:2px;opacity:0}ul.list-of-option.reset{top:inherit;bottom:100%;box-shadow:0 -3px 6px #1e5dd333}ul.list-of-option.active{opacity:1}ul.list-of-option li{width:100%;display:block;margin-bottom:0;padding:0;height:auto}ul.list-of-option li label{line-height:23px;font-size:13px;font-weight:400;border-radius:4px;display:flex;position:relative;margin:0;align-items:center}ul.list-of-option li label input[type=radio]{position:absolute;margin:0;height:100%;width:100%;opacity:0;left:0;cursor:pointer}ul.list-of-option li label input[type=radio]:checked+span,ul.list-of-option li label input[type=radio]:hover+span{background:#dcdcdc}ul.list-of-option li label span.value{color:#747576;font-size:14px;line-height:21px;font-weight:400;max-width:100%;white-space:nowrap;overflow:hidden;display:block;text-overflow:ellipsis;padding:5px 15px;width:100%;text-transform:none;cursor:pointer;text-align:left}ul.list-of-option li label.multiselect{padding:0 15px}ul.list-of-option li label.multiselect span.checkbox{display:inline-block;border:1px solid #dbdbdb;border-radius:2px;height:16px;width:16px;position:relative;padding:2px}ul.list-of-option li label input[type=checkbox]{position:absolute;margin:0;height:100%;width:100%;opacity:0;cursor:pointer}ul.list-of-option li label input[type=checkbox]:checked+span{background:#dcdcdc}ul.list-of-option li label input[type=checkbox]:checked+span.checkbox{border-color:#34aa44;background:#34aa44}ul.list-of-option li label input[type=checkbox]:checked+span.checkbox:after{width:8px;height:3px;border-bottom:2px solid #ffffff;border-left:2px solid #ffffff;transform:rotate(-45deg);content:\"\";position:absolute;top:3px;left:2px}ul.list-of-option li label.colors{padding:3px 5px}ul.list-of-option li label.colors span.value{padding:3px 6px;line-height:16px;font-size:11px;font-weight:600}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i2.ClickOutsideDirective, selector: "[clickOutside]", outputs: ["clickOutside"] }, { kind: "pipe", type: i3.PascalPipe, name: "pascal" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CsSelectComponentUI, decorators: [{
            type: Component,
            args: [{ selector: 'app-cs-select', template: "<div class=\"input-group\" (clickOutside)=\"dropdownOption = false\">\n  <label *ngIf=\"dropdownLabel != undefined\">\n    {{ dropdownLabel }} <span class=\"sub-label\">{{ dropdownSubLabel }}</span> <span class=\"required\" *ngIf=\"isRequired\">*</span></label\n  >\n  <div class=\"custom-select-box\" [class.disabled]=\"disabled\">\n    <input\n      type=\"text\"\n      [class.line]=\"stylex\"\n      [placeholder]=\"placeholder\"\n      [value]=\"selectedValue | pascal\"\n      readonly\n      (click)=\"openDropdown($event)\"\n      (keyup.enter)=\"openDropdown($event)\"\n      (keyup.arrowup)=\"openDropdown($event)\"\n      (keyup.arrowdown)=\"openDropdown($event)\"\n      *ngIf=\"!colorProperty\"\n    />\n    <span class=\"show-label\" *ngIf=\"colorProperty\" (click)=\"openDropdown($event)\">\n      <span class=\"label\" [innerHTML]=\"selectedValue\" [style.backgroundColor]=\"colorSelected + '1A'\" [style.color]=\"colorSelected\"></span>\n    </span>\n    <!-- <span class=\"arrow\" [class.line]=\"stylex\">\n      <i class=\"icons\">&#xe9e8;</i>\n    </span> -->\n    <div class=\"overlay active\" *ngIf=\"dropdownOption === true\" (click)=\"closeDropdown()\"></div>\n    <ul\n      class=\"list-of-option\"\n      *ngIf=\"dropdownOption === true && !colorProperty\"\n      #optionList\n      (keyup.Escape)=\"closeDropdown()\"\n      [style.top.px]=\"getTop\"\n      [style.left.px]=\"getLeft\"\n      [style.min-width.px]=\"getWidth\"\n      [style.max-width.px]=\"maxWidth\"\n      [class.active]=\"activeDoropdown\"\n    >\n      <li *ngFor=\"let data of dataList\">\n        <label>\n          <input type=\"radio\" [value]=\"data[valueKey]\" name=\"sliceLabel\" (change)=\"selectOption(data)\" #option (keyup.enter)=\"closeDropdown()\" class=\"pointer-none\" />\n          <span (click)=\"closeDropdown(); selectOption(data)\" *ngIf=\"displayProperty && displayProperty !== ''\" class=\"value\">{{ data[displayProperty] }}</span>\n          <span (click)=\"closeDropdown(); selectOption(data)\" *ngIf=\"!displayProperty || displayProperty === ''\" class=\"value\">{{ data }}</span>\n        </label>\n      </li>\n    </ul>\n    <ul\n      class=\"list-of-option\"\n      *ngIf=\"dropdownOption === true && colorProperty\"\n      #optionList\n      (keyup.Escape)=\"closeDropdown()\"\n      [style.top.px]=\"getTop\"\n      [style.left.px]=\"getLeft\"\n      [style.min-width.px]=\"getWidth\"\n      [style.max-width.px]=\"maxWidth\"\n      [class.active]=\"activeDoropdown\"\n    >\n      <li *ngFor=\"let data of dataList\">\n        <label class=\"colors\">\n          <input type=\"radio\" [value]=\"data[valueKey]\" name=\"sliceLabel\" (click)=\"selectOption(data)\" #option (keyup.enter)=\"closeDropdown()\" class=\"pointer-none\" />\n          <span\n            (click)=\"selectOption(data)\"\n            *ngIf=\"displayProperty && displayProperty !== ''\"\n            class=\"value\"\n            [ngStyle]=\"{ color: data.segment_color }\"\n            [style.backgroundColor]=\"data.segment_color + '1A'\"\n            >{{ data[displayProperty] }}</span\n          >\n          <span\n            (click)=\"selectOption(data)\"\n            *ngIf=\"!displayProperty || displayProperty === ''\"\n            class=\"value\"\n            [ngStyle]=\"{ color: data.segment_color }\"\n            [style.backgroundColor]=\"data.segment_color + '1A'\"\n            >{{ data }}</span\n          >\n        </label>\n      </li>\n    </ul>\n  </div>\n</div>\n", styles: [".input-group{position:relative;margin-bottom:0}.input-group label{font-size:11px;color:#161b2f;font-weight:500;line-height:16px;margin-bottom:5px;text-transform:uppercase;display:block}.input-group label span.required{color:#eb2424;font-size:14px}.input-group label span.sub-label{color:#747576;font-size:11px;font-weight:400;margin-left:3px}.input-group input[type=text],.input-group .show-label{height:36px;line-height:16px;font-size:13px;color:#747576;font-weight:400;background:#fff;border:1px solid #dbdbdb;border-radius:4px;width:100%;padding:10px 13px;display:block;outline:none;overflow:hidden;text-overflow:ellipsis}.input-group input[type=text].line,.input-group .show-label.line{border:none;border-bottom:1px solid #dbdbdb;border-radius:0;padding-left:0}.input-group .show-label{display:flex;padding:6px;padding-right:25px!important;cursor:pointer}.input-group .show-label .label{white-space:nowrap;padding:2px 5px;height:100%;overflow:hidden;text-overflow:ellipsis;display:block;width:100%;text-transform:uppercase;font-size:11px;font-weight:600;line-height:15px;pointer-events:none}.input-group:focus-within input[type=text]{border-color:#1e5dd3;box-shadow:0 3px 6px #1e5dd333}.input-group:focus-within input[type=text].line{box-shadow:none}.input-group .custom-select-box{background:#fff;position:relative;z-index:1}.input-group .custom-select-box:after{border-bottom-style:solid;border-bottom-width:1px;border-right-style:solid;border-right-width:1px;border-color:#707070;content:\"\";display:inline-block;right:15px;position:absolute;top:calc(50% - 4px);width:5px;height:5px;transform:rotate(45deg);z-index:-1}.input-group .custom-select-box input[type=text],.input-group .custom-select-box .input{cursor:pointer;padding-right:30px;background:transparent}.input-group .custom-select-box input[type=text].line,.input-group .custom-select-box .input.line{padding-right:20px}.input-group .custom-select-box.disabled{filter:grayscale(1);pointer-events:none}.input-group .arrow{position:absolute;right:17px;color:#747576;bottom:8px;font-size:10px;pointer-events:none}.input-group .arrow.line{right:5px}ul.list-of-option{position:fixed;overflow:auto;max-height:200px;padding:0;margin:0;display:block;border:1px solid #dbdbdb;box-shadow:0 3px 6px #1e5dd333;z-index:2147483002;background:#fff;border-radius:2px;opacity:0}ul.list-of-option.reset{top:inherit;bottom:100%;box-shadow:0 -3px 6px #1e5dd333}ul.list-of-option.active{opacity:1}ul.list-of-option li{width:100%;display:block;margin-bottom:0;padding:0;height:auto}ul.list-of-option li label{line-height:23px;font-size:13px;font-weight:400;border-radius:4px;display:flex;position:relative;margin:0;align-items:center}ul.list-of-option li label input[type=radio]{position:absolute;margin:0;height:100%;width:100%;opacity:0;left:0;cursor:pointer}ul.list-of-option li label input[type=radio]:checked+span,ul.list-of-option li label input[type=radio]:hover+span{background:#dcdcdc}ul.list-of-option li label span.value{color:#747576;font-size:14px;line-height:21px;font-weight:400;max-width:100%;white-space:nowrap;overflow:hidden;display:block;text-overflow:ellipsis;padding:5px 15px;width:100%;text-transform:none;cursor:pointer;text-align:left}ul.list-of-option li label.multiselect{padding:0 15px}ul.list-of-option li label.multiselect span.checkbox{display:inline-block;border:1px solid #dbdbdb;border-radius:2px;height:16px;width:16px;position:relative;padding:2px}ul.list-of-option li label input[type=checkbox]{position:absolute;margin:0;height:100%;width:100%;opacity:0;cursor:pointer}ul.list-of-option li label input[type=checkbox]:checked+span{background:#dcdcdc}ul.list-of-option li label input[type=checkbox]:checked+span.checkbox{border-color:#34aa44;background:#34aa44}ul.list-of-option li label input[type=checkbox]:checked+span.checkbox:after{width:8px;height:3px;border-bottom:2px solid #ffffff;border-left:2px solid #ffffff;transform:rotate(-45deg);content:\"\";position:absolute;top:3px;left:2px}ul.list-of-option li label.colors{padding:3px 5px}ul.list-of-option li label.colors span.value{padding:3px 6px;line-height:16px;font-size:11px;font-weight:600}\n"] }]
        }], propDecorators: { dataList: [{
                type: Input
            }], dropdownLabel: [{
                type: Input
            }], displayProperty: [{
                type: Input
            }], selectedValue: [{
                type: Input
            }], isRequired: [{
                type: Input
            }], dropdownSubLabel: [{
                type: Input
            }], disabled: [{
                type: Input
            }], option: [{
                type: ViewChild,
                args: ['option']
            }], selectedData: [{
                type: Output
            }], selectedValueChange: [{
                type: Output
            }], placeholder: [{
                type: Input
            }], stylex: [{
                type: Input
            }], valueKey: [{
                type: Input
            }], multipleSelect: [{
                type: Input
            }], colorProperty: [{
                type: Input
            }], colorSelected: [{
                type: Input
            }], content: [{
                type: ViewChild,
                args: ['optionList']
            }] } });
//# sourceMappingURL=data:application/json;base64, 