UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

554 lines (546 loc) 15.6 kB
import { __decorate, __metadata } from 'tslib'; import { FocusMonitor, A11yModule } from '@angular/cdk/a11y'; import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Renderer2, ElementRef, Output, forwardRef, Optional, ChangeDetectorRef, ViewChild, Input, NgModule } from '@angular/core'; import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms'; import { InputBoolean } from 'ng-zorro-antd/core/util'; import { CommonModule } from '@angular/common'; /** * @fileoverview added by tsickle * Generated from: checkbox-wrapper.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzCheckboxWrapperComponent { /** * @param {?} renderer * @param {?} elementRef */ constructor(renderer, elementRef) { this.nzOnChange = new EventEmitter(); this.checkboxList = []; renderer.addClass(elementRef.nativeElement, 'ant-checkbox-group'); } /** * @param {?} value * @return {?} */ addCheckbox(value) { this.checkboxList.push(value); } /** * @param {?} value * @return {?} */ removeCheckbox(value) { this.checkboxList.splice(this.checkboxList.indexOf(value), 1); } /** * @return {?} */ onChange() { /** @type {?} */ const listOfCheckedValue = this.checkboxList.filter((/** * @param {?} item * @return {?} */ item => item.nzChecked)).map((/** * @param {?} item * @return {?} */ item => item.nzValue)); this.nzOnChange.emit(listOfCheckedValue); } } NzCheckboxWrapperComponent.decorators = [ { type: Component, args: [{ selector: 'nz-checkbox-wrapper', exportAs: 'nzCheckboxWrapper', preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: ` <ng-content></ng-content> ` }] } ]; /** @nocollapse */ NzCheckboxWrapperComponent.ctorParameters = () => [ { type: Renderer2 }, { type: ElementRef } ]; NzCheckboxWrapperComponent.propDecorators = { nzOnChange: [{ type: Output }] }; if (false) { /** @type {?} */ NzCheckboxWrapperComponent.prototype.nzOnChange; /** * @type {?} * @private */ NzCheckboxWrapperComponent.prototype.checkboxList; } /** * @fileoverview added by tsickle * Generated from: checkbox.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzCheckboxComponent { /** * @param {?} elementRef * @param {?} nzCheckboxWrapperComponent * @param {?} cdr * @param {?} focusMonitor */ constructor(elementRef, nzCheckboxWrapperComponent, cdr, focusMonitor) { this.elementRef = elementRef; this.nzCheckboxWrapperComponent = nzCheckboxWrapperComponent; this.cdr = cdr; this.focusMonitor = focusMonitor; this.onChange = (/** * @return {?} */ () => { }); this.onTouched = (/** * @return {?} */ () => { }); this.nzCheckedChange = new EventEmitter(); this.nzValue = null; this.nzAutoFocus = false; this.nzDisabled = false; this.nzIndeterminate = false; this.nzChecked = false; } /** * @param {?} e * @return {?} */ hostClick(e) { e.preventDefault(); this.focus(); this.innerCheckedChange(!this.nzChecked); } /** * @param {?} checked * @return {?} */ innerCheckedChange(checked) { if (!this.nzDisabled) { this.nzChecked = checked; this.onChange(this.nzChecked); this.nzCheckedChange.emit(this.nzChecked); if (this.nzCheckboxWrapperComponent) { this.nzCheckboxWrapperComponent.onChange(); } } } /** * @param {?} value * @return {?} */ writeValue(value) { this.nzChecked = value; this.cdr.markForCheck(); } /** * @param {?} fn * @return {?} */ registerOnChange(fn) { this.onChange = fn; } /** * @param {?} fn * @return {?} */ registerOnTouched(fn) { this.onTouched = fn; } /** * @param {?} disabled * @return {?} */ setDisabledState(disabled) { this.nzDisabled = disabled; this.cdr.markForCheck(); } /** * @return {?} */ focus() { this.focusMonitor.focusVia(this.inputElement, 'keyboard'); } /** * @return {?} */ blur() { this.inputElement.nativeElement.blur(); } /** * @return {?} */ ngOnInit() { this.focusMonitor.monitor(this.elementRef, true).subscribe((/** * @param {?} focusOrigin * @return {?} */ focusOrigin => { if (!focusOrigin) { Promise.resolve().then((/** * @return {?} */ () => this.onTouched())); } })); if (this.nzCheckboxWrapperComponent) { this.nzCheckboxWrapperComponent.addCheckbox(this); } } /** * @return {?} */ ngAfterViewInit() { if (this.nzAutoFocus) { this.focus(); } } /** * @return {?} */ ngOnDestroy() { this.focusMonitor.stopMonitoring(this.elementRef); if (this.nzCheckboxWrapperComponent) { this.nzCheckboxWrapperComponent.removeCheckbox(this); } } } NzCheckboxComponent.decorators = [ { type: Component, args: [{ selector: '[nz-checkbox]', exportAs: 'nzCheckbox', preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: ` <span class="ant-checkbox" [class.ant-checkbox-checked]="nzChecked && !nzIndeterminate" [class.ant-checkbox-disabled]="nzDisabled" [class.ant-checkbox-indeterminate]="nzIndeterminate" > <input #inputElement type="checkbox" class="ant-checkbox-input" [attr.autofocus]="nzAutoFocus ? 'autofocus' : null" [checked]="nzChecked" [ngModel]="nzChecked" [disabled]="nzDisabled" (ngModelChange)="innerCheckedChange($event)" (click)="$event.stopPropagation()" /> <span class="ant-checkbox-inner"></span> </span> <span><ng-content></ng-content></span> `, providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((/** * @return {?} */ () => NzCheckboxComponent)), multi: true } ], host: { '[class.ant-checkbox-wrapper]': 'true', '[class.ant-checkbox-wrapper-checked]': 'nzChecked', '(click)': 'hostClick($event)' } }] } ]; /** @nocollapse */ NzCheckboxComponent.ctorParameters = () => [ { type: ElementRef }, { type: NzCheckboxWrapperComponent, decorators: [{ type: Optional }] }, { type: ChangeDetectorRef }, { type: FocusMonitor } ]; NzCheckboxComponent.propDecorators = { inputElement: [{ type: ViewChild, args: ['inputElement', { static: true },] }], nzCheckedChange: [{ type: Output }], nzValue: [{ type: Input }], nzAutoFocus: [{ type: Input }], nzDisabled: [{ type: Input }], nzIndeterminate: [{ type: Input }], nzChecked: [{ type: Input }] }; __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzCheckboxComponent.prototype, "nzAutoFocus", void 0); __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzCheckboxComponent.prototype, "nzDisabled", void 0); __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzCheckboxComponent.prototype, "nzIndeterminate", void 0); __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzCheckboxComponent.prototype, "nzChecked", void 0); if (false) { /** @type {?} */ NzCheckboxComponent.ngAcceptInputType_nzAutoFocus; /** @type {?} */ NzCheckboxComponent.ngAcceptInputType_nzDisabled; /** @type {?} */ NzCheckboxComponent.ngAcceptInputType_nzIndeterminate; /** @type {?} */ NzCheckboxComponent.ngAcceptInputType_nzChecked; /** @type {?} */ NzCheckboxComponent.prototype.onChange; /** @type {?} */ NzCheckboxComponent.prototype.onTouched; /** * @type {?} * @private */ NzCheckboxComponent.prototype.inputElement; /** @type {?} */ NzCheckboxComponent.prototype.nzCheckedChange; /** @type {?} */ NzCheckboxComponent.prototype.nzValue; /** @type {?} */ NzCheckboxComponent.prototype.nzAutoFocus; /** @type {?} */ NzCheckboxComponent.prototype.nzDisabled; /** @type {?} */ NzCheckboxComponent.prototype.nzIndeterminate; /** @type {?} */ NzCheckboxComponent.prototype.nzChecked; /** * @type {?} * @private */ NzCheckboxComponent.prototype.elementRef; /** * @type {?} * @private */ NzCheckboxComponent.prototype.nzCheckboxWrapperComponent; /** * @type {?} * @private */ NzCheckboxComponent.prototype.cdr; /** * @type {?} * @private */ NzCheckboxComponent.prototype.focusMonitor; } /** * @fileoverview added by tsickle * Generated from: checkbox-group.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function NzCheckBoxOptionInterface() { } if (false) { /** @type {?} */ NzCheckBoxOptionInterface.prototype.label; /** @type {?} */ NzCheckBoxOptionInterface.prototype.value; /** @type {?|undefined} */ NzCheckBoxOptionInterface.prototype.checked; /** @type {?|undefined} */ NzCheckBoxOptionInterface.prototype.disabled; } class NzCheckboxGroupComponent { /** * @param {?} elementRef * @param {?} focusMonitor * @param {?} cdr */ constructor(elementRef, focusMonitor, cdr) { this.elementRef = elementRef; this.focusMonitor = focusMonitor; this.cdr = cdr; this.onChange = (/** * @return {?} */ () => { }); this.onTouched = (/** * @return {?} */ () => { }); this.options = []; this.nzDisabled = false; } /** * @param {?} _ * @param {?} option * @return {?} */ trackByOption(_, option) { return option.value; } /** * @return {?} */ ngOnInit() { this.focusMonitor.monitor(this.elementRef, true).subscribe((/** * @param {?} focusOrigin * @return {?} */ focusOrigin => { if (!focusOrigin) { Promise.resolve().then((/** * @return {?} */ () => this.onTouched())); } })); } /** * @return {?} */ ngOnDestroy() { this.focusMonitor.stopMonitoring(this.elementRef); } /** * @param {?} value * @return {?} */ writeValue(value) { this.options = value; this.cdr.markForCheck(); } /** * @param {?} fn * @return {?} */ registerOnChange(fn) { this.onChange = fn; } /** * @param {?} fn * @return {?} */ registerOnTouched(fn) { this.onTouched = fn; } /** * @param {?} disabled * @return {?} */ setDisabledState(disabled) { this.nzDisabled = disabled; this.cdr.markForCheck(); } } NzCheckboxGroupComponent.decorators = [ { type: Component, args: [{ selector: 'nz-checkbox-group', exportAs: 'nzCheckboxGroup', preserveWhitespaces: false, encapsulation: ViewEncapsulation.None, template: ` <label nz-checkbox class="ant-checkbox-group-item" *ngFor="let o of options; trackBy: trackByOption" [nzDisabled]="o.disabled || nzDisabled" [(nzChecked)]="o.checked" (nzCheckedChange)="onChange(options)" > <span>{{ o.label }}</span> </label> `, providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((/** * @return {?} */ () => NzCheckboxGroupComponent)), multi: true } ], host: { '[class.ant-checkbox-group]': 'true' } }] } ]; /** @nocollapse */ NzCheckboxGroupComponent.ctorParameters = () => [ { type: ElementRef }, { type: FocusMonitor }, { type: ChangeDetectorRef } ]; NzCheckboxGroupComponent.propDecorators = { nzDisabled: [{ type: Input }] }; __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzCheckboxGroupComponent.prototype, "nzDisabled", void 0); if (false) { /** @type {?} */ NzCheckboxGroupComponent.ngAcceptInputType_nzDisabled; /** @type {?} */ NzCheckboxGroupComponent.prototype.onChange; /** @type {?} */ NzCheckboxGroupComponent.prototype.onTouched; /** @type {?} */ NzCheckboxGroupComponent.prototype.options; /** @type {?} */ NzCheckboxGroupComponent.prototype.nzDisabled; /** * @type {?} * @private */ NzCheckboxGroupComponent.prototype.elementRef; /** * @type {?} * @private */ NzCheckboxGroupComponent.prototype.focusMonitor; /** * @type {?} * @private */ NzCheckboxGroupComponent.prototype.cdr; } /** * @fileoverview added by tsickle * Generated from: checkbox.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzCheckboxModule { } NzCheckboxModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, FormsModule, A11yModule], declarations: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent], exports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent] },] } ]; /** * @fileoverview added by tsickle * Generated from: public-api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: ng-zorro-antd-checkbox.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxModule, NzCheckboxWrapperComponent }; //# sourceMappingURL=ng-zorro-antd-checkbox.js.map