import { Component, Input, Output, EventEmitter, ViewEncapsulation, ViewChild, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NSBaseComponent } from '../ns-base';
import * as i0 from "@angular/core";
export class NSNumericTextBoxAngular extends NSBaseComponent {
    set setting(value) {
        this.__setting = value;
        if (value && this.__input) {
            const setting = this.setting;
            value.input = this.__input.nativeElement;
            this.__nsTextBox = new NSNumericTextBox(value);
        }
    }
    get setting() {
        return this.__setting;
    }
    constructor() {
        super();
        this.disabled = false;
        this.modelChanged = new EventEmitter();
        this.formatValueChanged = new EventEmitter();
        this.spin = new EventEmitter();
        this.valueChanged = new EventEmitter();
        this.initializeScripts(['NSNumericTextBox']);
    }
    ngOnInit() {
        this.initializeEvents([NSNumericTextBox.SPIN,
            NSNumericTextBox.VALUE_CHANGED
        ]);
    }
    ngAfterViewInit() {
        if (this.setting && this.__input && !this.__nsTextBox) {
            const setting = this.setting;
            setting.input = this.__input.nativeElement;
            this.__nsTextBox = new NSNumericTextBox(setting);
            if (this.__pendingValue !== undefined) {
                this.setValue(this.__pendingValue, false);
                this.__pendingValue = undefined;
            }
        }
    }
    ngOnDestroy() {
        if (this.__nsTextBox) {
            this.__nsTextBox.remove();
        }
    }
    writeValue(value) {
        if (this.__nsTextBox) {
            this.setValue(value, false);
        }
        else {
            this.__pendingValue = value;
        }
    }
    registerOnChange(fn) {
        this.__onChange = fn;
    }
    registerOnTouched(fn) {
        this.__onTouch = fn;
    }
    getTextBox() {
        return this.__input;
    }
    setValue(text, fireEvent) {
        this.__nsTextBox.setValue(text, fireEvent);
    }
    getValue() {
        return this.__nsTextBox.getValue();
    }
    getFormattedValue() {
        return this.__nsTextBox.getFormattedValue();
    }
    setTheme(theme) {
        this.__nsTextBox.setTheme(theme);
    }
    eventListener(event, eventName) {
        if (event.type === NSNumericTextBox.VALUE_CHANGED) {
            const newValue = event.detail.newValue;
            if (this.__onChange) {
                this.__onChange(newValue);
                this.__onTouch();
                this.modelChanged.emit(newValue);
                this.formatValueChanged.emit(this.getFormattedValue());
            }
        }
        super.eventListener(event, eventName);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NSNumericTextBoxAngular, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: NSNumericTextBoxAngular, selector: "ns-numeric-textbox-angular", inputs: { setting: "setting", disabled: "disabled", __setting: "__setting" }, outputs: { modelChanged: "modelChanged", formatValueChanged: "formatValueChanged", spin: "spin", valueChanged: "valueChanged" }, providers: [
            {
                provide: NG_VALUE_ACCESSOR,
                useExisting: forwardRef(() => NSNumericTextBoxAngular),
                multi: true
            },
        ], viewQueries: [{ propertyName: "__input", first: true, predicate: ["txtRef"], descendants: true }], usesInheritance: true, ngImport: i0, template: `<input type="text" [disabled]="disabled" #txtRef>`, isInline: true, styles: [".nsNumericTextBoxContainer{position:relative;display:inline-block;width:100%;overflow:visible;border-width:0;vertical-align:middle;box-sizing:content-box;line-height:normal;background-color:transparent;background-image:none;white-space:nowrap}.nsNumericTextBoxContainer .nsNumericTextBoxParent{position:relative;display:block;cursor:default;height:2.42em;box-sizing:content-box;background-repeat:repeat;background-position:50% 50%;border-color:#e6e6e6;border-width:1px;border-style:solid;transition:box-shadow .15s ease-out}.nsNumericTextBoxContainer .nsNumericTextBoxParent.nsNumericTextBoxParentWithSpinner{padding:0 38.86px 0 0}.nsNumericTextBoxContainer.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent{cursor:default!important;pointer-events:none;outline:0;opacity:.6}.nsNumericTextBoxContainer .nsNumericTextBoxParent.nsNumericTextBoxParentHover{box-shadow:0 1px #fff3;background-color:#fff;background-image:none;background-position:50% 50%;border-color:#f5f5f5}.nsNumericTextBoxContainer .nsNumericTextBox{width:100%;height:100%;box-sizing:border-box;padding:2.86px 0;text-indent:12.8px;border:0;margin:0;overflow:hidden;text-overflow:ellipsis;font-size:100%;outline:0}.nsNumericTextBoxContainer .nsNumericTextBox::-ms-clear{display:none}.nsNumericTextBoxContainer .nsNumericTextBoxSpinnerContainer{position:absolute;top:0;right:0;width:2.42em;height:100%;display:inline-block;vertical-align:baseline;text-decoration:none;text-align:center;padding:0;border-radius:0 2px 2px 0}.nsNumericTextBoxContainer .nsNumericTextBoxSpinContainer{display:block;height:50%;cursor:pointer;line-height:1em;vertical-align:middle;border-width:0;outline:0;color:inherit;padding:0;border-radius:0 1px 0 0}.nsNumericTextBoxContainer .nsNumericTextBoxSpinner{width:0px;height:0px;border-style:solid;position:relative;display:block;overflow:hidden;cursor:pointer;margin-left:calc(50% - 6px)}.nsNumericTextBoxContainer .nsNumericTextBoxIncSpinnerContainer .nsNumericTextBoxIncSpinner{border-width:0 5px 10px 5px;border-color:transparent transparent #2f2f2f transparent;margin-top:5px}.nsNumericTextBoxContainer .nsNumericTextBoxDecSpinnerContainer .nsNumericTextBoxDecSpinner{border-width:10px 5px 0 5px;border-color:#2f2f2f transparent transparent transparent;margin-bottom:5px}.nsNumericTextBoxContainerWhite{color:#444;border-color:#e6e6e6}.nsNumericTextBoxContainerWhite .nsNumericTextBoxParent{color:#444;background-color:#fafafa;border-color:#f0f0f0}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent{color:#999;background-color:#fafafa}.nsNumericTextBoxContainerWhite .nsNumericTextBoxParent.nsNumericTextBoxParentHover{background-color:#fff;border-color:#f5f5f5;box-shadow:0 2px 6px #0003,0 2px 3px #0000000d}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent .nsNumericTextBox{background-color:#fafafa}.nsNumericTextBoxContainerWhite .nsNumericTextBox:hover{background-color:#fff;color:#444}.nsNumericTextBoxContainerWhite .nsNumericTextBoxSpinnerContainer{background-color:#fff;border-color:#fff}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent .nsNumericTextBoxSpinnerContainer{background-color:#fafafa}.nsNumericTextBoxContainerWhite .nsNumericTextBoxParentHover .nsNumericTextBoxSpinnerContainer{background-color:#ebebeb}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent .nsNumericTextBoxSpinnerContainer{background-color:#fafafa;border-color:#fafafa}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent .nsNumericTextBoxSpinContainer{color:#999}.nsNumericTextBoxContainerWhite .nsNumericTextBoxSpinner.nsNumericTextBoxSpinnerSelected{background-color:#ebebeb}\n"], encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NSNumericTextBoxAngular, decorators: [{
            type: Component,
            args: [{ selector: 'ns-numeric-textbox-angular', template: `<input type="text" [disabled]="disabled" #txtRef>`, providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => NSNumericTextBoxAngular),
                            multi: true
                        },
                    ], encapsulation: ViewEncapsulation.None, styles: [".nsNumericTextBoxContainer{position:relative;display:inline-block;width:100%;overflow:visible;border-width:0;vertical-align:middle;box-sizing:content-box;line-height:normal;background-color:transparent;background-image:none;white-space:nowrap}.nsNumericTextBoxContainer .nsNumericTextBoxParent{position:relative;display:block;cursor:default;height:2.42em;box-sizing:content-box;background-repeat:repeat;background-position:50% 50%;border-color:#e6e6e6;border-width:1px;border-style:solid;transition:box-shadow .15s ease-out}.nsNumericTextBoxContainer .nsNumericTextBoxParent.nsNumericTextBoxParentWithSpinner{padding:0 38.86px 0 0}.nsNumericTextBoxContainer.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent{cursor:default!important;pointer-events:none;outline:0;opacity:.6}.nsNumericTextBoxContainer .nsNumericTextBoxParent.nsNumericTextBoxParentHover{box-shadow:0 1px #fff3;background-color:#fff;background-image:none;background-position:50% 50%;border-color:#f5f5f5}.nsNumericTextBoxContainer .nsNumericTextBox{width:100%;height:100%;box-sizing:border-box;padding:2.86px 0;text-indent:12.8px;border:0;margin:0;overflow:hidden;text-overflow:ellipsis;font-size:100%;outline:0}.nsNumericTextBoxContainer .nsNumericTextBox::-ms-clear{display:none}.nsNumericTextBoxContainer .nsNumericTextBoxSpinnerContainer{position:absolute;top:0;right:0;width:2.42em;height:100%;display:inline-block;vertical-align:baseline;text-decoration:none;text-align:center;padding:0;border-radius:0 2px 2px 0}.nsNumericTextBoxContainer .nsNumericTextBoxSpinContainer{display:block;height:50%;cursor:pointer;line-height:1em;vertical-align:middle;border-width:0;outline:0;color:inherit;padding:0;border-radius:0 1px 0 0}.nsNumericTextBoxContainer .nsNumericTextBoxSpinner{width:0px;height:0px;border-style:solid;position:relative;display:block;overflow:hidden;cursor:pointer;margin-left:calc(50% - 6px)}.nsNumericTextBoxContainer .nsNumericTextBoxIncSpinnerContainer .nsNumericTextBoxIncSpinner{border-width:0 5px 10px 5px;border-color:transparent transparent #2f2f2f transparent;margin-top:5px}.nsNumericTextBoxContainer .nsNumericTextBoxDecSpinnerContainer .nsNumericTextBoxDecSpinner{border-width:10px 5px 0 5px;border-color:#2f2f2f transparent transparent transparent;margin-bottom:5px}.nsNumericTextBoxContainerWhite{color:#444;border-color:#e6e6e6}.nsNumericTextBoxContainerWhite .nsNumericTextBoxParent{color:#444;background-color:#fafafa;border-color:#f0f0f0}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent{color:#999;background-color:#fafafa}.nsNumericTextBoxContainerWhite .nsNumericTextBoxParent.nsNumericTextBoxParentHover{background-color:#fff;border-color:#f5f5f5;box-shadow:0 2px 6px #0003,0 2px 3px #0000000d}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent .nsNumericTextBox{background-color:#fafafa}.nsNumericTextBoxContainerWhite .nsNumericTextBox:hover{background-color:#fff;color:#444}.nsNumericTextBoxContainerWhite .nsNumericTextBoxSpinnerContainer{background-color:#fff;border-color:#fff}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent .nsNumericTextBoxSpinnerContainer{background-color:#fafafa}.nsNumericTextBoxContainerWhite .nsNumericTextBoxParentHover .nsNumericTextBoxSpinnerContainer{background-color:#ebebeb}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent .nsNumericTextBoxSpinnerContainer{background-color:#fafafa;border-color:#fafafa}.nsNumericTextBoxContainerWhite.nsNumericTextBoxContainerDisabled .nsNumericTextBoxParent .nsNumericTextBoxSpinContainer{color:#999}.nsNumericTextBoxContainerWhite .nsNumericTextBoxSpinner.nsNumericTextBoxSpinnerSelected{background-color:#ebebeb}\n"] }]
        }], ctorParameters: () => [], propDecorators: { setting: [{
                type: Input
            }], __input: [{
                type: ViewChild,
                args: ['txtRef', { static: false }]
            }], disabled: [{
                type: Input
            }], __setting: [{
                type: Input
            }], modelChanged: [{
                type: Output
            }], formatValueChanged: [{
                type: Output
            }], spin: [{
                type: Output
            }], valueChanged: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 