UNPKG

ng-zorro-antd

Version:

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

590 lines (582 loc) 18.4 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 */ var NzCheckboxWrapperComponent = /** @class */ (function () { function NzCheckboxWrapperComponent(renderer, elementRef) { this.nzOnChange = new EventEmitter(); this.checkboxList = []; renderer.addClass(elementRef.nativeElement, 'ant-checkbox-group'); } /** * @param {?} value * @return {?} */ NzCheckboxWrapperComponent.prototype.addCheckbox = /** * @param {?} value * @return {?} */ function (value) { this.checkboxList.push(value); }; /** * @param {?} value * @return {?} */ NzCheckboxWrapperComponent.prototype.removeCheckbox = /** * @param {?} value * @return {?} */ function (value) { this.checkboxList.splice(this.checkboxList.indexOf(value), 1); }; /** * @return {?} */ NzCheckboxWrapperComponent.prototype.onChange = /** * @return {?} */ function () { /** @type {?} */ var listOfCheckedValue = this.checkboxList.filter((/** * @param {?} item * @return {?} */ function (item) { return item.nzChecked; })).map((/** * @param {?} item * @return {?} */ function (item) { return 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: "\n <ng-content></ng-content>\n " }] } ]; /** @nocollapse */ NzCheckboxWrapperComponent.ctorParameters = function () { return [ { type: Renderer2 }, { type: ElementRef } ]; }; NzCheckboxWrapperComponent.propDecorators = { nzOnChange: [{ type: Output }] }; return NzCheckboxWrapperComponent; }()); 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 */ var NzCheckboxComponent = /** @class */ (function () { function NzCheckboxComponent(elementRef, nzCheckboxWrapperComponent, cdr, focusMonitor) { this.elementRef = elementRef; this.nzCheckboxWrapperComponent = nzCheckboxWrapperComponent; this.cdr = cdr; this.focusMonitor = focusMonitor; this.onChange = (/** * @return {?} */ function () { }); this.onTouched = (/** * @return {?} */ function () { }); this.nzCheckedChange = new EventEmitter(); this.nzValue = null; this.nzAutoFocus = false; this.nzDisabled = false; this.nzIndeterminate = false; this.nzChecked = false; } /** * @param {?} e * @return {?} */ NzCheckboxComponent.prototype.hostClick = /** * @param {?} e * @return {?} */ function (e) { e.preventDefault(); this.focus(); this.innerCheckedChange(!this.nzChecked); }; /** * @param {?} checked * @return {?} */ NzCheckboxComponent.prototype.innerCheckedChange = /** * @param {?} checked * @return {?} */ function (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 {?} */ NzCheckboxComponent.prototype.writeValue = /** * @param {?} value * @return {?} */ function (value) { this.nzChecked = value; this.cdr.markForCheck(); }; /** * @param {?} fn * @return {?} */ NzCheckboxComponent.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ NzCheckboxComponent.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this.onTouched = fn; }; /** * @param {?} disabled * @return {?} */ NzCheckboxComponent.prototype.setDisabledState = /** * @param {?} disabled * @return {?} */ function (disabled) { this.nzDisabled = disabled; this.cdr.markForCheck(); }; /** * @return {?} */ NzCheckboxComponent.prototype.focus = /** * @return {?} */ function () { this.focusMonitor.focusVia(this.inputElement, 'keyboard'); }; /** * @return {?} */ NzCheckboxComponent.prototype.blur = /** * @return {?} */ function () { this.inputElement.nativeElement.blur(); }; /** * @return {?} */ NzCheckboxComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this.focusMonitor.monitor(this.elementRef, true).subscribe((/** * @param {?} focusOrigin * @return {?} */ function (focusOrigin) { if (!focusOrigin) { Promise.resolve().then((/** * @return {?} */ function () { return _this.onTouched(); })); } })); if (this.nzCheckboxWrapperComponent) { this.nzCheckboxWrapperComponent.addCheckbox(this); } }; /** * @return {?} */ NzCheckboxComponent.prototype.ngAfterViewInit = /** * @return {?} */ function () { if (this.nzAutoFocus) { this.focus(); } }; /** * @return {?} */ NzCheckboxComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { 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: "\n <span\n class=\"ant-checkbox\"\n [class.ant-checkbox-checked]=\"nzChecked && !nzIndeterminate\"\n [class.ant-checkbox-disabled]=\"nzDisabled\"\n [class.ant-checkbox-indeterminate]=\"nzIndeterminate\"\n >\n <input\n #inputElement\n type=\"checkbox\"\n class=\"ant-checkbox-input\"\n [attr.autofocus]=\"nzAutoFocus ? 'autofocus' : null\"\n [checked]=\"nzChecked\"\n [ngModel]=\"nzChecked\"\n [disabled]=\"nzDisabled\"\n (ngModelChange)=\"innerCheckedChange($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n <span class=\"ant-checkbox-inner\"></span>\n </span>\n <span><ng-content></ng-content></span>\n ", providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((/** * @return {?} */ function () { return NzCheckboxComponent; })), multi: true } ], host: { '[class.ant-checkbox-wrapper]': 'true', '[class.ant-checkbox-wrapper-checked]': 'nzChecked', '(click)': 'hostClick($event)' } }] } ]; /** @nocollapse */ NzCheckboxComponent.ctorParameters = function () { return [ { 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); return NzCheckboxComponent; }()); 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; } var NzCheckboxGroupComponent = /** @class */ (function () { function NzCheckboxGroupComponent(elementRef, focusMonitor, cdr) { this.elementRef = elementRef; this.focusMonitor = focusMonitor; this.cdr = cdr; this.onChange = (/** * @return {?} */ function () { }); this.onTouched = (/** * @return {?} */ function () { }); this.options = []; this.nzDisabled = false; } /** * @param {?} _ * @param {?} option * @return {?} */ NzCheckboxGroupComponent.prototype.trackByOption = /** * @param {?} _ * @param {?} option * @return {?} */ function (_, option) { return option.value; }; /** * @return {?} */ NzCheckboxGroupComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this.focusMonitor.monitor(this.elementRef, true).subscribe((/** * @param {?} focusOrigin * @return {?} */ function (focusOrigin) { if (!focusOrigin) { Promise.resolve().then((/** * @return {?} */ function () { return _this.onTouched(); })); } })); }; /** * @return {?} */ NzCheckboxGroupComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.focusMonitor.stopMonitoring(this.elementRef); }; /** * @param {?} value * @return {?} */ NzCheckboxGroupComponent.prototype.writeValue = /** * @param {?} value * @return {?} */ function (value) { this.options = value; this.cdr.markForCheck(); }; /** * @param {?} fn * @return {?} */ NzCheckboxGroupComponent.prototype.registerOnChange = /** * @param {?} fn * @return {?} */ function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ NzCheckboxGroupComponent.prototype.registerOnTouched = /** * @param {?} fn * @return {?} */ function (fn) { this.onTouched = fn; }; /** * @param {?} disabled * @return {?} */ NzCheckboxGroupComponent.prototype.setDisabledState = /** * @param {?} disabled * @return {?} */ function (disabled) { this.nzDisabled = disabled; this.cdr.markForCheck(); }; NzCheckboxGroupComponent.decorators = [ { type: Component, args: [{ selector: 'nz-checkbox-group', exportAs: 'nzCheckboxGroup', preserveWhitespaces: false, encapsulation: ViewEncapsulation.None, template: "\n <label\n nz-checkbox\n class=\"ant-checkbox-group-item\"\n *ngFor=\"let o of options; trackBy: trackByOption\"\n [nzDisabled]=\"o.disabled || nzDisabled\"\n [(nzChecked)]=\"o.checked\"\n (nzCheckedChange)=\"onChange(options)\"\n >\n <span>{{ o.label }}</span>\n </label>\n ", providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((/** * @return {?} */ function () { return NzCheckboxGroupComponent; })), multi: true } ], host: { '[class.ant-checkbox-group]': 'true' } }] } ]; /** @nocollapse */ NzCheckboxGroupComponent.ctorParameters = function () { return [ { type: ElementRef }, { type: FocusMonitor }, { type: ChangeDetectorRef } ]; }; NzCheckboxGroupComponent.propDecorators = { nzDisabled: [{ type: Input }] }; __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzCheckboxGroupComponent.prototype, "nzDisabled", void 0); return NzCheckboxGroupComponent; }()); 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 */ var NzCheckboxModule = /** @class */ (function () { function NzCheckboxModule() { } NzCheckboxModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, FormsModule, A11yModule], declarations: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent], exports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent] },] } ]; return NzCheckboxModule; }()); /** * @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