import { ChangeDetectorRef, Component, ContentChild, ElementRef, HostBinding, Input, Renderer2 } from '@angular/core';
import { FormControlComponent } from './form-control.component';
import { FormLabelComponent } from './form-label.component';
import * as i0 from "@angular/core";
export class FormItemComponent {
    constructor(elementRef, renderer, cdr) {
        // FIXME: 循环依赖，打包后将不可用：FormItemComponent -> FormDirective -> DFormControlRuleDirective -> FormItemComponent
        // @Optional() @Host() @SkipSelf() private _dForm: FormDirective,
        this.cdr = cdr;
        this._hasErrorMsg = false;
        this.dHasFeedback = false;
        renderer.addClass(elementRef.nativeElement, 'devui-form-item');
    }
    ngOnInit() { }
    updateFeedback(status, updateMessage) {
        this._hasErrorMsg = !!updateMessage;
        const feedbackType = this.dFeedbackType;
        if (feedbackType === 'label' && this.labelInstance) {
            this.labelInstance.updateFeedbackStatus(status);
        }
        else if ((feedbackType === 'control' || this.dHasFeedback) && this.controlInstance) {
            this.controlInstance.updateFeedbackStatus(status);
        }
        if (this.controlInstance) {
            this.controlInstance.updateErrorMessage(updateMessage);
        }
        this.cdr.detectChanges();
    }
}
FormItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: FormItemComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
FormItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: FormItemComponent, selector: "d-form-item", inputs: { dFeedbackType: "dFeedbackType", dHasFeedback: "dHasFeedback" }, host: { properties: { "class.devui-form-has-error-msg": "this._hasErrorMsg" } }, queries: [{ propertyName: "controlInstance", first: true, predicate: FormControlComponent, descendants: true }, { propertyName: "labelInstance", first: true, predicate: FormLabelComponent, descendants: true }], ngImport: i0, template: ` <ng-content></ng-content> `, isInline: true, styles: [".mr-content-spacing{margin-right:4px}.padding-element-spacing{padding:16px!important}.ml-element-spacing{margin-left:16px}.mr-element-spacing{margin-right:16px}.mt-element-spacing{margin-top:16px}.mb-element-spacing{margin-bottom:16px}.mlr-element-spacing{margin-left:16px;margin-right:16px}.mtb-element-spacing{margin-top:16px;margin-bottom:16px}.m-element-spacing{margin:16px}.grid{letter-spacing:-.31em;*letter-spacing: normal;word-spacing:-.43em}.u,.u-1,.u-1-2,.u-1-3,.u-2-3,.u-1-4,.u-3-4,.u-1-5,.u-2-5,.u-3-5,.u-4-5,.u-1-6,.u-5-6,.u-1-8,.u-3-8,.u-5-8,.u-7-8,.u-1-12,.u-5-12,.u-7-12,.u-11-12,.u-1-24,.u-5-24,.u-7-24,.u-11-24,.u-13-24,.u-17-24,.u-19-24,.u-23-24{display:inline-block;*display: inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top}.u-1{display:block}.u-1-2{width:49.99999%}.u-1-3{width:33.33333%}.u-2-3{width:66.66666%}.u-1-4{width:24.99999%}.u-3-4{width:74.99999%}.u-1-5{width:19.99999%}.u-2-5{width:39.99999%}.u-3-5{width:59.99999%}.u-4-5{width:79.99999%}.u-1-6{width:16.64999%}.u-5-6{width:83.33333%}.u-1-8{width:12.49999%}.u-3-8{width:37.49999%}.u-5-8{width:62.49999%}.u-7-8{width:87.49999%}.u-1-12{width:8.33333%}.u-5-12{width:41.66666%}.u-7-12{width:58.33333%}.u-11-12{width:91.66666%}.u-1-24{width:4.16666%}.u-5-24{width:20.83333%}.u-7-24{width:29.16666%}.u-11-24{width:45.83333%}.u-13-24{width:54.16666%}.u-17-24{width:70.83333%}.u-19-24{width:79.16666%}.u-23-24{width:95.83333%}.u-content{padding:0 0 10px 10px}.devui-form-horizontal :host.devui-form-item{margin-bottom:20px;display:flex;align-items:center}.devui-form-horizontal :host.devui-form-item.devui-form-has-error-msg{margin-bottom:0}.devui-form-vertical :host.devui-form-item{display:flex;margin-bottom:20px;flex-direction:column}.devui-form-vertical :host.devui-form-item.devui-form-has-error-msg{margin-bottom:0}.devui-form-columns :host.devui-form-item{display:flex;flex-direction:column;align-items:flex-start;margin-right:16px;margin-bottom:20px}.devui-form-columns :host.devui-form-item.devui-form-has-error-msg{margin-bottom:0}\n"] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: FormItemComponent, decorators: [{
            type: Component,
            args: [{ selector: 'd-form-item', template: ` <ng-content></ng-content> `, preserveWhitespaces: false, styles: [".mr-content-spacing{margin-right:4px}.padding-element-spacing{padding:16px!important}.ml-element-spacing{margin-left:16px}.mr-element-spacing{margin-right:16px}.mt-element-spacing{margin-top:16px}.mb-element-spacing{margin-bottom:16px}.mlr-element-spacing{margin-left:16px;margin-right:16px}.mtb-element-spacing{margin-top:16px;margin-bottom:16px}.m-element-spacing{margin:16px}.grid{letter-spacing:-.31em;*letter-spacing: normal;word-spacing:-.43em}.u,.u-1,.u-1-2,.u-1-3,.u-2-3,.u-1-4,.u-3-4,.u-1-5,.u-2-5,.u-3-5,.u-4-5,.u-1-6,.u-5-6,.u-1-8,.u-3-8,.u-5-8,.u-7-8,.u-1-12,.u-5-12,.u-7-12,.u-11-12,.u-1-24,.u-5-24,.u-7-24,.u-11-24,.u-13-24,.u-17-24,.u-19-24,.u-23-24{display:inline-block;*display: inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top}.u-1{display:block}.u-1-2{width:49.99999%}.u-1-3{width:33.33333%}.u-2-3{width:66.66666%}.u-1-4{width:24.99999%}.u-3-4{width:74.99999%}.u-1-5{width:19.99999%}.u-2-5{width:39.99999%}.u-3-5{width:59.99999%}.u-4-5{width:79.99999%}.u-1-6{width:16.64999%}.u-5-6{width:83.33333%}.u-1-8{width:12.49999%}.u-3-8{width:37.49999%}.u-5-8{width:62.49999%}.u-7-8{width:87.49999%}.u-1-12{width:8.33333%}.u-5-12{width:41.66666%}.u-7-12{width:58.33333%}.u-11-12{width:91.66666%}.u-1-24{width:4.16666%}.u-5-24{width:20.83333%}.u-7-24{width:29.16666%}.u-11-24{width:45.83333%}.u-13-24{width:54.16666%}.u-17-24{width:70.83333%}.u-19-24{width:79.16666%}.u-23-24{width:95.83333%}.u-content{padding:0 0 10px 10px}.devui-form-horizontal :host.devui-form-item{margin-bottom:20px;display:flex;align-items:center}.devui-form-horizontal :host.devui-form-item.devui-form-has-error-msg{margin-bottom:0}.devui-form-vertical :host.devui-form-item{display:flex;margin-bottom:20px;flex-direction:column}.devui-form-vertical :host.devui-form-item.devui-form-has-error-msg{margin-bottom:0}.devui-form-columns :host.devui-form-item{display:flex;flex-direction:column;align-items:flex-start;margin-right:16px;margin-bottom:20px}.devui-form-columns :host.devui-form-item.devui-form-has-error-msg{margin-bottom:0}\n"] }]
        }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { _hasErrorMsg: [{
                type: HostBinding,
                args: ['class.devui-form-has-error-msg']
            }], dFeedbackType: [{
                type: Input
            }], dHasFeedback: [{
                type: Input
            }], controlInstance: [{
                type: ContentChild,
                args: [FormControlComponent]
            }], labelInstance: [{
                type: ContentChild,
                args: [FormLabelComponent]
            }] } });
//# sourceMappingURL=data:application/json;base64, 