ng-zorro-antd-mobile
Version:
An enterprise-class mobile UI components based on Ant Design and Angular
242 lines (235 loc) • 13.5 kB
JavaScript
import * as i0 from '@angular/core';
import { EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, HostBinding, HostListener, forwardRef, NgModule } from '@angular/core';
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i1$1 from 'ng-zorro-antd-mobile/list';
import { ListModule } from 'ng-zorro-antd-mobile/list';
class CheckboxComponent {
get checked() {
return this._checked;
}
set checked(value) {
this._checked = value;
this.updateClassMap();
}
get disabled() {
return this._disabled;
}
set disabled(value) {
this._disabled = value;
this.updateClassMap();
}
onClick(event) {
event.preventDefault();
if (!this._disabled) {
this.updateValue(!this.checked);
}
}
constructor() {
this.prefixCls = 'am-checkbox';
this.classMap = {
[this.prefixCls]: true,
[`${this.prefixCls}-checked`]: false,
[`${this.prefixCls}-disabled`]: false
};
this._checked = false;
this._disabled = false;
this.onChange = new EventEmitter();
this.checkBoxWrapper = true;
}
updateValue(value) {
this.checked = value;
this.onChange.emit({
name: this.name,
value: this.value,
checked: value
});
}
ngOnInit() {
this.updateClassMap();
}
updateClassMap() {
this.classMap = {
[this.prefixCls]: true,
[`${this.prefixCls}-checked`]: this.checked,
[`${this.prefixCls}-disabled`]: this.disabled
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: CheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: CheckboxComponent, selector: "[Checkbox], [nzm-checkbox]", inputs: { name: "name", value: "value", checked: "checked", disabled: "disabled" }, outputs: { onChange: "onChange" }, host: { listeners: { "click": "onClick($event)" }, properties: { "class.am-checkbox-wrapper": "this.checkBoxWrapper" } }, ngImport: i0, template: "<span [ngClass]=\"classMap\">\n <input\n type=\"checkbox\"\n class=\"{{ prefixCls }}-input\"\n [attr.name]=\"name\"\n [attr.value]=\"value\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n />\n <span class=\"{{ prefixCls }}-inner\"></span>\n</span>\n<ng-content></ng-content>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: CheckboxComponent, decorators: [{
type: Component,
args: [{ selector: '[Checkbox], [nzm-checkbox]', preserveWhitespaces: false, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<span [ngClass]=\"classMap\">\n <input\n type=\"checkbox\"\n class=\"{{ prefixCls }}-input\"\n [attr.name]=\"name\"\n [attr.value]=\"value\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n />\n <span class=\"{{ prefixCls }}-inner\"></span>\n</span>\n<ng-content></ng-content>\n" }]
}], ctorParameters: () => [], propDecorators: { name: [{
type: Input
}], value: [{
type: Input
}], checked: [{
type: Input
}], disabled: [{
type: Input
}], onChange: [{
type: Output
}], checkBoxWrapper: [{
type: HostBinding,
args: ['class.am-checkbox-wrapper']
}], onClick: [{
type: HostListener,
args: ['click', ['$event']]
}] } });
class AgreeItemComponent {
get disabled() {
return this._disabled;
}
set disabled(value) {
this._disabled = value;
}
constructor(cdr) {
this.cdr = cdr;
this.prefixCls = 'am-checkbox';
this.checked = false;
this._disabled = false;
this.onChange = new EventEmitter();
this.checkboxAgree = true;
}
change(event) {
this.checked = event.checked;
this._ngModelOnChange(event.checked);
this.onChange.emit(event);
}
writeValue(value) {
this.checked = value;
this.cdr.markForCheck();
}
registerOnChange(fn) {
this._ngModelOnChange = fn;
}
registerOnTouched(fn) {
this._ngModelOnTouched = fn;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: AgreeItemComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: AgreeItemComponent, selector: "AgreeItem, nzm-agree-item", inputs: { name: "name", value: "value", disabled: "disabled" }, outputs: { onChange: "onChange" }, host: { properties: { "class.am-checkbox-agree": "this.checkboxAgree" } }, providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => AgreeItemComponent),
multi: true
}
], ngImport: i0, template: "<label\n Checkbox\n class=\"{{ prefixCls }}-agree-label\"\n [name]=\"name\"\n [value]=\"value\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n (onChange)=\"change($event)\"\n>\n <ng-content></ng-content>\n</label>\n", dependencies: [{ kind: "component", type: CheckboxComponent, selector: "[Checkbox], [nzm-checkbox]", inputs: ["name", "value", "checked", "disabled"], outputs: ["onChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: AgreeItemComponent, decorators: [{
type: Component,
args: [{ selector: 'AgreeItem, nzm-agree-item', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => AgreeItemComponent),
multi: true
}
], template: "<label\n Checkbox\n class=\"{{ prefixCls }}-agree-label\"\n [name]=\"name\"\n [value]=\"value\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n (onChange)=\"change($event)\"\n>\n <ng-content></ng-content>\n</label>\n" }]
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { name: [{
type: Input
}], value: [{
type: Input
}], disabled: [{
type: Input
}], onChange: [{
type: Output
}], checkboxAgree: [{
type: HostBinding,
args: ['class.am-checkbox-agree']
}] } });
class CheckboxItemComponent {
get disabled() {
return this._disabled;
}
set disabled(value) {
this._disabled = value;
}
constructor(cdr) {
this.cdr = cdr;
this.prefixCls = 'am-checkbox';
this.checked = false;
this._disabled = false;
this.wrap = false;
this.error = false;
this.multipleLine = false;
this.platform = 'ios';
this.align = 'middle';
this.onChange = new EventEmitter();
}
onCheckboxClick(event) { }
change(event) {
this.checked = event.checked;
this._ngModelOnChange(event.checked);
this.onChange.emit(event);
}
writeValue(value) {
this.checked = value;
this.cdr.markForCheck();
}
registerOnChange(fn) {
this._ngModelOnChange = fn;
}
registerOnTouched(fn) {
this._ngModelOnTouched = fn;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: CheckboxItemComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: CheckboxItemComponent, selector: "CheckboxItem, nzm-checkbox-item", inputs: { name: "name", value: "value", arrow: "arrow", extra: "extra", wrap: "wrap", error: "error", multipleLine: "multipleLine", platform: "platform", align: "align", disabled: "disabled" }, outputs: { onChange: "onChange" }, providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => CheckboxItemComponent),
multi: true
}
], ngImport: i0, template: "<ListItem\n [className]=\"'am-checkbox-item ' + (disabled ? 'am-checkbox-item-disabled' : '')\"\n [wrap]=\"wrap\"\n [align]=\"align\"\n [arrow]=\"arrow\"\n [error]=\"error\"\n [extra]=\"extra\"\n [thumb]=\"checkbox\"\n [disabled]=\"disabled\"\n [platform]=\"platform\"\n [multipleLine]=\"multipleLine\"\n (onClick)=\"onCheckboxClick($event)\"\n>\n <ng-content></ng-content>\n</ListItem>\n<ng-template #checkbox>\n <label Checkbox [name]=\"name\" [value]=\"value\" [checked]=\"checked\" [disabled]=\"disabled\" (onChange)=\"change($event)\">\n </label>\n</ng-template>\n", dependencies: [{ kind: "component", type: i1$1.ListItemComponent, selector: "ListItem, nzm-list-item", inputs: ["extra", "className", "arrow", "multipleLine", "error", "wrap", "align", "platform", "disabled", "thumb"], outputs: ["onClick"] }, { kind: "component", type: CheckboxComponent, selector: "[Checkbox], [nzm-checkbox]", inputs: ["name", "value", "checked", "disabled"], outputs: ["onChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: CheckboxItemComponent, decorators: [{
type: Component,
args: [{ selector: 'CheckboxItem, nzm-checkbox-item', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => CheckboxItemComponent),
multi: true
}
], template: "<ListItem\n [className]=\"'am-checkbox-item ' + (disabled ? 'am-checkbox-item-disabled' : '')\"\n [wrap]=\"wrap\"\n [align]=\"align\"\n [arrow]=\"arrow\"\n [error]=\"error\"\n [extra]=\"extra\"\n [thumb]=\"checkbox\"\n [disabled]=\"disabled\"\n [platform]=\"platform\"\n [multipleLine]=\"multipleLine\"\n (onClick)=\"onCheckboxClick($event)\"\n>\n <ng-content></ng-content>\n</ListItem>\n<ng-template #checkbox>\n <label Checkbox [name]=\"name\" [value]=\"value\" [checked]=\"checked\" [disabled]=\"disabled\" (onChange)=\"change($event)\">\n </label>\n</ng-template>\n" }]
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { name: [{
type: Input
}], value: [{
type: Input
}], arrow: [{
type: Input
}], extra: [{
type: Input
}], wrap: [{
type: Input
}], error: [{
type: Input
}], multipleLine: [{
type: Input
}], platform: [{
type: Input
}], align: [{
type: Input
}], disabled: [{
type: Input
}], onChange: [{
type: Output
}] } });
class CheckboxModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: CheckboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: CheckboxModule, declarations: [CheckboxComponent, CheckboxItemComponent, AgreeItemComponent], imports: [CommonModule, FormsModule, ListModule], exports: [CheckboxComponent, CheckboxItemComponent, AgreeItemComponent] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: CheckboxModule, imports: [CommonModule, FormsModule, ListModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: CheckboxModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule, FormsModule, ListModule],
declarations: [CheckboxComponent, CheckboxItemComponent, AgreeItemComponent],
exports: [CheckboxComponent, CheckboxItemComponent, AgreeItemComponent]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { AgreeItemComponent, CheckboxComponent, CheckboxItemComponent, CheckboxModule };
//# sourceMappingURL=ng-zorro-antd-mobile-checkbox.mjs.map