@nbxx/nb-input
Version:
Angular - nbinput
68 lines • 3.28 kB
JavaScript
import { Component, forwardRef, Input } from '@angular/core';
import { NbFieldType, NbinputConfig } from "./nbinput.entity";
import { NG_VALUE_ACCESSOR } from "@angular/forms";
export class NbinputViewerComponent {
constructor() {
this.FieldType = NbFieldType;
this.onTouchedCallback = () => { };
this.onChangeCallback = (_) => { };
this.onBlur = () => this.onTouchedCallback();
this.type = NbFieldType.Text;
this.config = new NbinputConfig();
}
registerOnChange(fn) { if (fn) {
this.onChangeCallback = fn;
} }
registerOnTouched(fn) { if (fn) {
this.onTouchedCallback = fn;
} }
setDisabledState(isDisabled) { }
writeValue(obj) { this.data = obj; }
}
NbinputViewerComponent.decorators = [
{ type: Component, args: [{
selector: 'nbinput-viewer',
template: `
<ng-container [ngSwitch]="true">
<ng-container *ngSwitchCase="type==FieldType.Text || type==FieldType.Area">
<nbinput-text [type]="type" [readonly]="true" [data]="data"></nbinput-text>
</ng-container>
<ng-container *ngSwitchCase="type==FieldType.Number || type==FieldType.Percentage || type==FieldType.PercentageFen || type==FieldType.Currency || type==FieldType.CurrencyFen">
<nbinput-number [type]="type" [readonly]="true" [data]="data"></nbinput-number>
</ng-container>
<ng-container *ngSwitchCase="type==FieldType.Datetime || type==FieldType.Date || type==FieldType.Month || type==FieldType.Time">
<nbinput-date [readonly]="true" [format]="config.format" [data]="data" [type]="type"></nbinput-date>
</ng-container>
<ng-container *ngSwitchCase="type==FieldType.Massive || type==FieldType.Option || type==FieldType.Multiple || type==FieldType.Switch || type==FieldType.Radio || type==FieldType.Checkbox">
<nbinput-select [readonly]="true" [data]="data" [type]="type" [options]="options"></nbinput-select>
</ng-container>
<ng-container *ngSwitchCase="type==FieldType.Image || type==FieldType.Signature || type==FieldType.Images">
<nbinput-gallery [data]="data" [config]="config"></nbinput-gallery>
</ng-container>
<ng-container *ngSwitchCase="type==FieldType.File">
<nbinput-file [readonly]="true" [data]="data" [type]="type"></nbinput-file>
</ng-container>
<ng-container *ngSwitchCase="type==FieldType.Html">
<nbinput-froala [readonly]="true" [data]="data" [type]="type"></nbinput-froala>
</ng-container>
<ng-container *ngSwitchDefault>
<nbinput-label [data]="data" [type]="type"></nbinput-label>
</ng-container>
</ng-container>
`,
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NbinputViewerComponent),
multi: true
}
]
},] },
];
NbinputViewerComponent.propDecorators = {
data: [{ type: Input }],
options: [{ type: Input }],
type: [{ type: Input }],
config: [{ type: Input }]
};
//# sourceMappingURL=nbinput-viewer.component.js.map