123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- import * as i1 from '@angular/cdk/a11y';
- import { FocusMonitor } from '@angular/cdk/a11y';
- import * as i2 from '@angular/cdk/bidi';
- import { Directionality } from '@angular/cdk/bidi';
- import * as i0 from '@angular/core';
- import { EventEmitter, Output, ViewEncapsulation, ChangeDetectionStrategy, Component, InjectionToken, inject, effect, forwardRef, booleanAttribute, Input, ViewChild, input, signal, linkedSignal, computed, ElementRef, DestroyRef, afterNextRender, untracked, NgModule } from '@angular/core';
- import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
- import * as i3 from '@angular/forms';
- import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
- import { Subject } from 'rxjs';
- import { takeUntil } from 'rxjs/operators';
- import { NzFormStatusService } from 'ng-zorro-antd/core/form';
- import { fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
- /**
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
- */
- /**
- * @deprecated Deprecated in v19.0.0. It is recommended to use `<nz-checkbox-group>`.
- */
- class NzCheckboxWrapperComponent {
- nzOnChange = new EventEmitter();
- checkboxList = [];
- addCheckbox(value) {
- this.checkboxList.push(value);
- }
- removeCheckbox(value) {
- this.checkboxList.splice(this.checkboxList.indexOf(value), 1);
- }
- onChange() {
- const listOfCheckedValue = this.checkboxList.filter(item => item.nzChecked).map(item => item.nzValue);
- this.nzOnChange.emit(listOfCheckedValue);
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzCheckboxWrapperComponent, isStandalone: true, selector: "nz-checkbox-wrapper", outputs: { nzOnChange: "nzOnChange" }, host: { classAttribute: "ant-checkbox-group" }, exportAs: ["nzCheckboxWrapper"], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxWrapperComponent, decorators: [{
- type: Component,
- args: [{
- selector: 'nz-checkbox-wrapper',
- exportAs: 'nzCheckboxWrapper',
- template: `<ng-content></ng-content>`,
- preserveWhitespaces: false,
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- host: {
- class: 'ant-checkbox-group'
- }
- }]
- }], propDecorators: { nzOnChange: [{
- type: Output
- }] } });
- /**
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
- */
- const NZ_CHECKBOX_GROUP = new InjectionToken('NZ_CHECKBOX_GROUP');
- class NzCheckboxComponent {
- ngZone;
- elementRef;
- cdr;
- focusMonitor;
- directionality;
- dir = 'ltr';
- destroy$ = new Subject();
- isNzDisableFirstChange = true;
- onChange = () => { };
- onTouched = () => { };
- inputElement;
- nzCheckedChange = new EventEmitter();
- nzValue = null;
- nzAutoFocus = false;
- nzDisabled = false;
- nzIndeterminate = false;
- nzChecked = false;
- nzId = null;
- nzName = null;
- innerCheckedChange(checked) {
- if (!this.nzDisabled && !this.checkboxGroupComponent?.finalDisabled()) {
- this.setValue(checked);
- this.nzCheckboxWrapperComponent?.onChange();
- this.checkboxGroupComponent?.onCheckedChange(this.nzValue, checked);
- }
- }
- writeValue(value) {
- this.nzChecked = value;
- this.cdr.markForCheck();
- }
- registerOnChange(fn) {
- this.onChange = fn;
- }
- registerOnTouched(fn) {
- this.onTouched = fn;
- }
- setDisabledState(disabled) {
- this.nzDisabled = (this.isNzDisableFirstChange && this.nzDisabled) || disabled;
- this.isNzDisableFirstChange = false;
- this.cdr.markForCheck();
- }
- focus() {
- this.focusMonitor.focusVia(this.inputElement, 'keyboard');
- }
- blur() {
- this.inputElement.nativeElement.blur();
- }
- /** @deprecated */
- nzCheckboxWrapperComponent = inject(NzCheckboxWrapperComponent, { optional: true });
- checkboxGroupComponent = inject(NZ_CHECKBOX_GROUP, { optional: true });
- nzFormStatusService = inject(NzFormStatusService, { optional: true });
- constructor(ngZone, elementRef, cdr, focusMonitor, directionality) {
- this.ngZone = ngZone;
- this.elementRef = elementRef;
- this.cdr = cdr;
- this.focusMonitor = focusMonitor;
- this.directionality = directionality;
- if (this.checkboxGroupComponent) {
- effect(() => {
- const values = this.checkboxGroupComponent.value() || [];
- this.setValue(values.includes(this.nzValue));
- this.cdr.markForCheck();
- });
- }
- }
- ngOnInit() {
- this.focusMonitor
- .monitor(this.elementRef, true)
- .pipe(takeUntil(this.destroy$))
- .subscribe(focusOrigin => {
- if (!focusOrigin) {
- Promise.resolve().then(() => this.onTouched());
- }
- });
- this.nzCheckboxWrapperComponent?.addCheckbox(this);
- this.directionality.change.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
- this.dir = direction;
- this.cdr.detectChanges();
- });
- this.dir = this.directionality.value;
- fromEventOutsideAngular(this.elementRef.nativeElement, 'click')
- .pipe(takeUntil(this.destroy$))
- .subscribe(event => {
- event.preventDefault();
- this.focus();
- if (this.nzDisabled) {
- return;
- }
- this.ngZone.run(() => {
- this.innerCheckedChange(!this.nzChecked);
- this.cdr.markForCheck();
- });
- });
- fromEventOutsideAngular(this.inputElement.nativeElement, 'click')
- .pipe(takeUntil(this.destroy$))
- .subscribe(event => event.stopPropagation());
- }
- ngAfterViewInit() {
- if (this.nzAutoFocus) {
- this.focus();
- }
- }
- ngOnDestroy() {
- this.focusMonitor.stopMonitoring(this.elementRef);
- this.nzCheckboxWrapperComponent?.removeCheckbox(this);
- this.destroy$.next();
- this.destroy$.complete();
- }
- setValue(value) {
- this.nzChecked = value;
- this.onChange(value);
- this.nzCheckedChange.emit(value);
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxComponent, deps: [{ token: i0.NgZone }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.FocusMonitor }, { token: i2.Directionality }], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.2", type: NzCheckboxComponent, isStandalone: true, selector: "[nz-checkbox]", inputs: { nzValue: "nzValue", nzAutoFocus: ["nzAutoFocus", "nzAutoFocus", booleanAttribute], nzDisabled: ["nzDisabled", "nzDisabled", booleanAttribute], nzIndeterminate: ["nzIndeterminate", "nzIndeterminate", booleanAttribute], nzChecked: ["nzChecked", "nzChecked", booleanAttribute], nzId: "nzId", nzName: "nzName" }, outputs: { nzCheckedChange: "nzCheckedChange" }, host: { properties: { "class.ant-checkbox-group-item": "!!checkboxGroupComponent", "class.ant-checkbox-wrapper-in-form-item": "!!nzFormStatusService", "class.ant-checkbox-wrapper-checked": "nzChecked", "class.ant-checkbox-wrapper-disabled": "nzDisabled || checkboxGroupComponent?.finalDisabled()", "class.ant-checkbox-rtl": "dir === 'rtl'" }, classAttribute: "ant-checkbox-wrapper" }, providers: [
- {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(() => NzCheckboxComponent),
- multi: true
- }
- ], viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true, static: true }], exportAs: ["nzCheckbox"], ngImport: i0, template: `
- <span
- class="ant-checkbox"
- [class.ant-checkbox-checked]="nzChecked && !nzIndeterminate"
- [class.ant-checkbox-disabled]="nzDisabled || checkboxGroupComponent?.finalDisabled()"
- [class.ant-checkbox-indeterminate]="nzIndeterminate"
- >
- <input
- #inputElement
- type="checkbox"
- class="ant-checkbox-input"
- [attr.autofocus]="nzAutoFocus ? 'autofocus' : null"
- [attr.id]="nzId"
- [attr.name]="nzName || checkboxGroupComponent?.nzName()"
- [checked]="nzChecked"
- [ngModel]="nzChecked"
- [disabled]="nzDisabled || (checkboxGroupComponent?.finalDisabled() ?? false)"
- (ngModelChange)="innerCheckedChange($event)"
- />
- <span class="ant-checkbox-inner"></span>
- </span>
- <span><ng-content></ng-content></span>
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: 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 || checkboxGroupComponent?.finalDisabled()"
- [class.ant-checkbox-indeterminate]="nzIndeterminate"
- >
- <input
- #inputElement
- type="checkbox"
- class="ant-checkbox-input"
- [attr.autofocus]="nzAutoFocus ? 'autofocus' : null"
- [attr.id]="nzId"
- [attr.name]="nzName || checkboxGroupComponent?.nzName()"
- [checked]="nzChecked"
- [ngModel]="nzChecked"
- [disabled]="nzDisabled || (checkboxGroupComponent?.finalDisabled() ?? false)"
- (ngModelChange)="innerCheckedChange($event)"
- />
- <span class="ant-checkbox-inner"></span>
- </span>
- <span><ng-content></ng-content></span>
- `,
- providers: [
- {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(() => NzCheckboxComponent),
- multi: true
- }
- ],
- host: {
- class: 'ant-checkbox-wrapper',
- '[class.ant-checkbox-group-item]': '!!checkboxGroupComponent',
- '[class.ant-checkbox-wrapper-in-form-item]': '!!nzFormStatusService',
- '[class.ant-checkbox-wrapper-checked]': 'nzChecked',
- '[class.ant-checkbox-wrapper-disabled]': 'nzDisabled || checkboxGroupComponent?.finalDisabled()',
- '[class.ant-checkbox-rtl]': `dir === 'rtl'`
- },
- imports: [FormsModule]
- }]
- }], ctorParameters: () => [{ type: i0.NgZone }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.FocusMonitor }, { type: i2.Directionality }], propDecorators: { inputElement: [{
- type: ViewChild,
- args: ['inputElement', { static: true }]
- }], nzCheckedChange: [{
- type: Output
- }], nzValue: [{
- type: Input
- }], nzAutoFocus: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], nzDisabled: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], nzIndeterminate: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], nzChecked: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], nzId: [{
- type: Input
- }], nzName: [{
- type: Input
- }] } });
- /**
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
- */
- class NzCheckboxGroupComponent {
- onChange = () => { };
- onTouched = () => { };
- isDisabledFirstChange = true;
- directionality = inject(Directionality);
- nzName = input(null);
- nzDisabled = input(false, { transform: booleanAttribute });
- nzOptions = input([]);
- value = signal(null);
- finalDisabled = linkedSignal(() => this.nzDisabled());
- dir = toSignal(this.directionality.change, { initialValue: this.directionality.value });
- normalizedOptions = computed(() => normalizeOptions(this.nzOptions()));
- constructor() {
- const elementRef = inject(ElementRef);
- const focusMonitor = inject(FocusMonitor);
- const destroyRef = inject(DestroyRef);
- afterNextRender(() => {
- focusMonitor
- .monitor(elementRef, true)
- .pipe(takeUntilDestroyed(destroyRef))
- .subscribe(focusOrigin => {
- if (!focusOrigin) {
- this.onTouched();
- }
- });
- destroyRef.onDestroy(() => {
- focusMonitor.stopMonitoring(elementRef);
- });
- });
- }
- writeValue(value) {
- untracked(() => {
- this.value.set(value);
- });
- }
- registerOnChange(fn) {
- this.onChange = fn;
- }
- registerOnTouched(fn) {
- this.onTouched = fn;
- }
- setDisabledState(disabled) {
- untracked(() => {
- this.finalDisabled.set((this.isDisabledFirstChange && this.nzDisabled()) || disabled);
- });
- this.isDisabledFirstChange = false;
- }
- onCheckedChange(optionValue, checked) {
- if (this.finalDisabled())
- return;
- this.value.update(value => {
- if (checked) {
- return value?.concat(optionValue) || [optionValue];
- }
- else {
- return value?.filter(val => val !== optionValue) || [];
- }
- });
- this.onChange(this.value());
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzCheckboxGroupComponent, isStandalone: true, selector: "nz-checkbox-group", inputs: { nzName: { classPropertyName: "nzName", publicName: "nzName", isSignal: true, isRequired: false, transformFunction: null }, nzDisabled: { classPropertyName: "nzDisabled", publicName: "nzDisabled", isSignal: true, isRequired: false, transformFunction: null }, nzOptions: { classPropertyName: "nzOptions", publicName: "nzOptions", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.ant-checkbox-group-rtl": "dir() === 'rtl'" }, classAttribute: "ant-checkbox-group" }, providers: [
- {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(() => NzCheckboxGroupComponent),
- multi: true
- },
- {
- provide: NZ_CHECKBOX_GROUP,
- useExisting: forwardRef(() => NzCheckboxGroupComponent)
- }
- ], exportAs: ["nzCheckboxGroup"], ngImport: i0, template: `
- <ng-content>
- @for (option of normalizedOptions(); track option.value) {
- <label
- nz-checkbox
- [nzValue]="option.value"
- [nzName]="nzName()"
- [nzDisabled]="option.disabled || finalDisabled()"
- >
- {{ option.label }}
- </label>
- }
- </ng-content>
- `, isInline: true, dependencies: [{ kind: "component", type: NzCheckboxComponent, selector: "[nz-checkbox]", inputs: ["nzValue", "nzAutoFocus", "nzDisabled", "nzIndeterminate", "nzChecked", "nzId", "nzName"], outputs: ["nzCheckedChange"], exportAs: ["nzCheckbox"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxGroupComponent, decorators: [{
- type: Component,
- args: [{
- selector: 'nz-checkbox-group',
- exportAs: 'nzCheckboxGroup',
- imports: [NzCheckboxComponent],
- template: `
- <ng-content>
- @for (option of normalizedOptions(); track option.value) {
- <label
- nz-checkbox
- [nzValue]="option.value"
- [nzName]="nzName()"
- [nzDisabled]="option.disabled || finalDisabled()"
- >
- {{ option.label }}
- </label>
- }
- </ng-content>
- `,
- providers: [
- {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(() => NzCheckboxGroupComponent),
- multi: true
- },
- {
- provide: NZ_CHECKBOX_GROUP,
- useExisting: forwardRef(() => NzCheckboxGroupComponent)
- }
- ],
- host: {
- class: 'ant-checkbox-group',
- '[class.ant-checkbox-group-rtl]': `dir() === 'rtl'`
- },
- encapsulation: ViewEncapsulation.None,
- changeDetection: ChangeDetectionStrategy.OnPush
- }]
- }], ctorParameters: () => [] });
- function normalizeOptions(value) {
- return value.map(item => {
- if (typeof item === 'string' || typeof item === 'number') {
- return {
- label: `${item}`,
- value: item
- };
- }
- return item;
- });
- }
- /**
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
- */
- class NzCheckboxModule {
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxModule, imports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent], exports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent] });
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxModule, imports: [NzCheckboxComponent, NzCheckboxGroupComponent] });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCheckboxModule, decorators: [{
- type: NgModule,
- args: [{
- imports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent],
- exports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent]
- }]
- }] });
- /**
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
- */
- /**
- * Generated bundle index. Do not edit.
- */
- export { NZ_CHECKBOX_GROUP, NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxModule, NzCheckboxWrapperComponent };
- //# sourceMappingURL=ng-zorro-antd-checkbox.mjs.map
|