ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,018 lines (1,007 loc) • 115 kB
JavaScript
import * as i0 from '@angular/core';
import { Input, ChangeDetectionStrategy, ViewEncapsulation, Component, EventEmitter, booleanAttribute, Output, inject, NgZone, PLATFORM_ID, ViewChild, TemplateRef, DestroyRef, ElementRef, numberAttribute, computed, signal, forwardRef, ContentChildren, NgModule } from '@angular/core';
import { Subject, BehaviorSubject, of, combineLatest, merge } from 'rxjs';
import { OverlayModule, CdkOverlayOrigin, CdkConnectedOverlay } from '@angular/cdk/overlay';
import * as i2 from '@angular/cdk/scrolling';
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { NgTemplateOutlet, isPlatformBrowser } from '@angular/common';
import * as i7 from 'ng-zorro-antd/core/overlay';
import { NzOverlayModule, getPlacementName, POSITION_MAP } from 'ng-zorro-antd/core/overlay';
import * as i1$3 from 'ng-zorro-antd/empty';
import { NzEmptyModule } from 'ng-zorro-antd/empty';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { takeUntil, startWith, distinctUntilChanged, withLatestFrom, map, switchMap } from 'rxjs/operators';
import * as i1$1 from 'ng-zorro-antd/core/services';
import { NzDestroyService } from 'ng-zorro-antd/core/services';
import { fromEventOutsideAngular, numberAttributeWithInfinityFallback, isNotNil, getStatusClassNames } from 'ng-zorro-antd/core/util';
import * as i1$2 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { __esDecorate, __runInitializers } from 'tslib';
import { BACKSPACE, ESCAPE, TAB, SPACE, ENTER, DOWN_ARROW, UP_ARROW } from '@angular/cdk/keycodes';
import * as i3 from '@angular/cdk/platform';
import { _getEventTarget } from '@angular/cdk/platform';
import * as i2$1 from '@angular/forms';
import { FormsModule, COMPOSITION_BUFFER_MODE, NG_VALUE_ACCESSOR } from '@angular/forms';
import { slideMotion } from 'ng-zorro-antd/core/animation';
import * as i2$2 from 'ng-zorro-antd/core/config';
import { WithConfig } from 'ng-zorro-antd/core/config';
import { NzFormStatusService, NzFormNoStatusService, NzFormItemFeedbackIconComponent } from 'ng-zorro-antd/core/form';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { reqAnimFrame, cancelRequestAnimationFrame } from 'ng-zorro-antd/core/polyfill';
import * as i6 from 'ng-zorro-antd/space';
import { NZ_SPACE_COMPACT_SIZE, NZ_SPACE_COMPACT_ITEM_TYPE, NzSpaceCompactItemDirective } from 'ng-zorro-antd/space';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import * as i1$4 from '@angular/cdk/a11y';
import * as i5 from '@angular/cdk/bidi';
/**
* 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 NzOptionGroupComponent {
nzLabel = null;
changes = new Subject();
ngOnChanges() {
this.changes.next();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzOptionGroupComponent, isStandalone: true, selector: "nz-option-group", inputs: { nzLabel: "nzLabel" }, exportAs: ["nzOptionGroup"], usesOnChanges: true, 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: NzOptionGroupComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-option-group',
exportAs: 'nzOptionGroup',
template: `<ng-content></ng-content>`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
}]
}], propDecorators: { nzLabel: [{
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 NzOptionItemGroupComponent {
nzLabel = null;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionItemGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzOptionItemGroupComponent, isStandalone: true, selector: "nz-option-item-group", inputs: { nzLabel: "nzLabel" }, host: { classAttribute: "ant-select-item ant-select-item-group" }, ngImport: i0, template: ` <ng-container *nzStringTemplateOutlet="nzLabel">{{ nzLabel }}</ng-container> `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionItemGroupComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-option-item-group',
template: ` <ng-container *nzStringTemplateOutlet="nzLabel">{{ nzLabel }}</ng-container> `,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
class: 'ant-select-item ant-select-item-group'
},
imports: [NzOutletModule]
}]
}], propDecorators: { nzLabel: [{
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 NzOptionItemComponent {
elementRef;
ngZone;
destroy$;
selected = false;
activated = false;
grouped = false;
customContent = false;
template = null;
disabled = false;
showState = false;
title;
label = null;
value = null;
activatedValue = null;
listOfSelectedValue = [];
icon = null;
compareWith;
itemClick = new EventEmitter();
itemHover = new EventEmitter();
constructor(elementRef, ngZone, destroy$) {
this.elementRef = elementRef;
this.ngZone = ngZone;
this.destroy$ = destroy$;
}
ngOnChanges(changes) {
const { value, activatedValue, listOfSelectedValue } = changes;
if (value || listOfSelectedValue) {
this.selected = this.listOfSelectedValue.some(v => this.compareWith(v, this.value));
}
if (value || activatedValue) {
this.activated = this.compareWith(this.activatedValue, this.value);
}
}
ngOnInit() {
fromEventOutsideAngular(this.elementRef.nativeElement, 'click')
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
if (!this.disabled) {
this.ngZone.run(() => this.itemClick.emit(this.value));
}
});
fromEventOutsideAngular(this.elementRef.nativeElement, 'mouseenter')
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
if (!this.disabled) {
this.ngZone.run(() => this.itemHover.emit(this.value));
}
});
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionItemComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i1$1.NzDestroyService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzOptionItemComponent, isStandalone: true, selector: "nz-option-item", inputs: { grouped: "grouped", customContent: ["customContent", "customContent", booleanAttribute], template: "template", disabled: "disabled", showState: "showState", title: "title", label: "label", value: "value", activatedValue: "activatedValue", listOfSelectedValue: "listOfSelectedValue", icon: "icon", compareWith: "compareWith" }, outputs: { itemClick: "itemClick", itemHover: "itemHover" }, host: { properties: { "attr.title": "title", "class.ant-select-item-option-grouped": "grouped", "class.ant-select-item-option-selected": "selected && !disabled", "class.ant-select-item-option-disabled": "disabled", "class.ant-select-item-option-active": "activated && !disabled" }, classAttribute: "ant-select-item ant-select-item-option" }, providers: [NzDestroyService], usesOnChanges: true, ngImport: i0, template: `
<div class="ant-select-item-option-content">
@if (customContent) {
<ng-template [ngTemplateOutlet]="template"></ng-template>
} @else {
{{ label }}
}
</div>
@if (showState && selected) {
<div class="ant-select-item-option-state" unselectable="on">
@if (!icon) {
<nz-icon nzType="check" class="ant-select-selected-icon" />
} @else {
<ng-template [ngTemplateOutlet]="icon"></ng-template>
}
</div>
}
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1$2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionItemComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-option-item',
template: `
<div class="ant-select-item-option-content">
@if (customContent) {
<ng-template [ngTemplateOutlet]="template"></ng-template>
} @else {
{{ label }}
}
</div>
@if (showState && selected) {
<div class="ant-select-item-option-state" unselectable="on">
@if (!icon) {
<nz-icon nzType="check" class="ant-select-selected-icon" />
} @else {
<ng-template [ngTemplateOutlet]="icon"></ng-template>
}
</div>
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
class: 'ant-select-item ant-select-item-option',
'[attr.title]': 'title',
'[class.ant-select-item-option-grouped]': 'grouped',
'[class.ant-select-item-option-selected]': 'selected && !disabled',
'[class.ant-select-item-option-disabled]': 'disabled',
'[class.ant-select-item-option-active]': 'activated && !disabled'
},
providers: [NzDestroyService],
imports: [NgTemplateOutlet, NzIconModule]
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i1$1.NzDestroyService }], propDecorators: { grouped: [{
type: Input
}], customContent: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], template: [{
type: Input
}], disabled: [{
type: Input
}], showState: [{
type: Input
}], title: [{
type: Input
}], label: [{
type: Input
}], value: [{
type: Input
}], activatedValue: [{
type: Input
}], listOfSelectedValue: [{
type: Input
}], icon: [{
type: Input
}], compareWith: [{
type: Input
}], itemClick: [{
type: Output
}], itemHover: [{
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
*/
class NzOptionContainerComponent {
notFoundContent = undefined;
menuItemSelectedIcon = null;
dropdownRender = null;
activatedValue = null;
listOfSelectedValue = [];
compareWith;
mode = 'default';
matchWidth = true;
itemSize = 32;
maxItemLength = 8;
isMaxMultipleCountReached = false;
listOfContainerItem = [];
itemClick = new EventEmitter();
scrollToBottom = new EventEmitter();
cdkVirtualScrollViewport;
scrolledIndex = 0;
ngZone = inject(NgZone);
platformId = inject(PLATFORM_ID);
onItemClick(value) {
this.itemClick.emit(value);
}
onItemHover(value) {
// TODO: keydown.enter won't activate this value
this.activatedValue = value;
}
trackValue(_index, option) {
return option.key;
}
onScrolledIndexChange(index) {
this.scrolledIndex = index;
if (index === this.listOfContainerItem.length - this.maxItemLength - 1) {
this.scrollToBottom.emit();
}
}
scrollToActivatedValue() {
const index = this.listOfContainerItem.findIndex(item => this.compareWith(item.key, this.activatedValue));
if (index < this.scrolledIndex || index >= this.scrolledIndex + this.maxItemLength) {
this.cdkVirtualScrollViewport.scrollToIndex(index || 0);
}
}
ngOnChanges(changes) {
const { listOfContainerItem, activatedValue } = changes;
if (listOfContainerItem || activatedValue) {
this.scrollToActivatedValue();
}
}
ngAfterViewInit() {
if (isPlatformBrowser(this.platformId)) {
this.ngZone.runOutsideAngular(() => setTimeout(() => this.scrollToActivatedValue()));
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzOptionContainerComponent, isStandalone: true, selector: "nz-option-container", inputs: { notFoundContent: "notFoundContent", menuItemSelectedIcon: "menuItemSelectedIcon", dropdownRender: "dropdownRender", activatedValue: "activatedValue", listOfSelectedValue: "listOfSelectedValue", compareWith: "compareWith", mode: "mode", matchWidth: "matchWidth", itemSize: "itemSize", maxItemLength: "maxItemLength", isMaxMultipleCountReached: "isMaxMultipleCountReached", listOfContainerItem: "listOfContainerItem" }, outputs: { itemClick: "itemClick", scrollToBottom: "scrollToBottom" }, host: { classAttribute: "ant-select-dropdown" }, viewQueries: [{ propertyName: "cdkVirtualScrollViewport", first: true, predicate: CdkVirtualScrollViewport, descendants: true, static: true }], exportAs: ["nzOptionContainer"], usesOnChanges: true, ngImport: i0, template: `
<div>
@if (listOfContainerItem.length === 0) {
<div class="ant-select-item-empty">
<nz-embed-empty nzComponentName="select" [specificContent]="notFoundContent!"></nz-embed-empty>
</div>
}
<cdk-virtual-scroll-viewport
[class.full-width]="!matchWidth"
[itemSize]="itemSize"
[maxBufferPx]="itemSize * maxItemLength"
[minBufferPx]="itemSize * maxItemLength"
(scrolledIndexChange)="onScrolledIndexChange($event)"
[style.height.px]="listOfContainerItem.length * itemSize"
[style.max-height.px]="itemSize * maxItemLength"
>
<ng-template
cdkVirtualFor
[cdkVirtualForOf]="listOfContainerItem"
[cdkVirtualForTrackBy]="trackValue"
[cdkVirtualForTemplateCacheSize]="0"
let-item
>
@switch (item.type) {
@case ('group') {
<nz-option-item-group [nzLabel]="item.groupLabel ?? null"></nz-option-item-group>
}
@case ('item') {
<nz-option-item
[icon]="menuItemSelectedIcon"
[customContent]="item.nzCustomContent"
[template]="item.template ?? null"
[grouped]="!!item.groupLabel"
[disabled]="
item.nzDisabled || (isMaxMultipleCountReached && !listOfSelectedValue.includes(item['nzValue']))
"
[showState]="mode === 'tags' || mode === 'multiple'"
[title]="item.nzTitle"
[label]="item.nzLabel"
[compareWith]="compareWith"
[activatedValue]="activatedValue"
[listOfSelectedValue]="listOfSelectedValue"
[value]="item.nzValue"
(itemHover)="onItemHover($event)"
(itemClick)="onItemClick($event)"
></nz-option-item>
}
}
</ng-template>
</cdk-virtual-scroll-viewport>
<ng-template [ngTemplateOutlet]="dropdownRender"></ng-template>
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzEmptyModule }, { kind: "component", type: i1$3.NzEmbedEmptyComponent, selector: "nz-embed-empty", inputs: ["nzComponentName", "specificContent"], exportAs: ["nzEmbedEmpty"] }, { kind: "component", type: NzOptionItemGroupComponent, selector: "nz-option-item-group", inputs: ["nzLabel"] }, { kind: "component", type: NzOptionItemComponent, selector: "nz-option-item", inputs: ["grouped", "customContent", "template", "disabled", "showState", "title", "label", "value", "activatedValue", "listOfSelectedValue", "icon", "compareWith"], outputs: ["itemClick", "itemHover"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i2.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i2.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i2.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "ngmodule", type: NzOverlayModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionContainerComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-option-container',
exportAs: 'nzOptionContainer',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
template: `
<div>
@if (listOfContainerItem.length === 0) {
<div class="ant-select-item-empty">
<nz-embed-empty nzComponentName="select" [specificContent]="notFoundContent!"></nz-embed-empty>
</div>
}
<cdk-virtual-scroll-viewport
[class.full-width]="!matchWidth"
[itemSize]="itemSize"
[maxBufferPx]="itemSize * maxItemLength"
[minBufferPx]="itemSize * maxItemLength"
(scrolledIndexChange)="onScrolledIndexChange($event)"
[style.height.px]="listOfContainerItem.length * itemSize"
[style.max-height.px]="itemSize * maxItemLength"
>
<ng-template
cdkVirtualFor
[cdkVirtualForOf]="listOfContainerItem"
[cdkVirtualForTrackBy]="trackValue"
[cdkVirtualForTemplateCacheSize]="0"
let-item
>
@switch (item.type) {
@case ('group') {
<nz-option-item-group [nzLabel]="item.groupLabel ?? null"></nz-option-item-group>
}
@case ('item') {
<nz-option-item
[icon]="menuItemSelectedIcon"
[customContent]="item.nzCustomContent"
[template]="item.template ?? null"
[grouped]="!!item.groupLabel"
[disabled]="
item.nzDisabled || (isMaxMultipleCountReached && !listOfSelectedValue.includes(item['nzValue']))
"
[showState]="mode === 'tags' || mode === 'multiple'"
[title]="item.nzTitle"
[label]="item.nzLabel"
[compareWith]="compareWith"
[activatedValue]="activatedValue"
[listOfSelectedValue]="listOfSelectedValue"
[value]="item.nzValue"
(itemHover)="onItemHover($event)"
(itemClick)="onItemClick($event)"
></nz-option-item>
}
}
</ng-template>
</cdk-virtual-scroll-viewport>
<ng-template [ngTemplateOutlet]="dropdownRender"></ng-template>
</div>
`,
host: { class: 'ant-select-dropdown' },
imports: [
NzEmptyModule,
NzOptionItemGroupComponent,
NzOptionItemComponent,
NgTemplateOutlet,
OverlayModule,
NzOverlayModule
]
}]
}], propDecorators: { notFoundContent: [{
type: Input
}], menuItemSelectedIcon: [{
type: Input
}], dropdownRender: [{
type: Input
}], activatedValue: [{
type: Input
}], listOfSelectedValue: [{
type: Input
}], compareWith: [{
type: Input
}], mode: [{
type: Input
}], matchWidth: [{
type: Input
}], itemSize: [{
type: Input
}], maxItemLength: [{
type: Input
}], isMaxMultipleCountReached: [{
type: Input
}], listOfContainerItem: [{
type: Input
}], itemClick: [{
type: Output
}], scrollToBottom: [{
type: Output
}], cdkVirtualScrollViewport: [{
type: ViewChild,
args: [CdkVirtualScrollViewport, { static: true }]
}] } });
/**
* 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 NzOptionComponent {
destroy$;
changes = new Subject();
groupLabel = null;
template;
nzTitle;
nzLabel = null;
nzValue = null;
nzKey;
nzDisabled = false;
nzHide = false;
nzCustomContent = false;
nzOptionGroupComponent = inject(NzOptionGroupComponent, { optional: true });
constructor(destroy$) {
this.destroy$ = destroy$;
}
ngOnInit() {
if (this.nzOptionGroupComponent) {
this.nzOptionGroupComponent.changes.pipe(startWith(true), takeUntil(this.destroy$)).subscribe(() => {
this.groupLabel = this.nzOptionGroupComponent?.nzLabel;
});
}
}
ngOnChanges() {
this.changes.next();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionComponent, deps: [{ token: i1$1.NzDestroyService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.2", type: NzOptionComponent, isStandalone: true, selector: "nz-option", inputs: { nzTitle: "nzTitle", nzLabel: "nzLabel", nzValue: "nzValue", nzKey: "nzKey", nzDisabled: ["nzDisabled", "nzDisabled", booleanAttribute], nzHide: ["nzHide", "nzHide", booleanAttribute], nzCustomContent: ["nzCustomContent", "nzCustomContent", booleanAttribute] }, providers: [NzDestroyService], viewQueries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true, static: true }], exportAs: ["nzOption"], usesOnChanges: true, ngImport: i0, template: `
<ng-template>
<ng-content></ng-content>
</ng-template>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzOptionComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-option',
exportAs: 'nzOption',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [NzDestroyService],
template: `
<ng-template>
<ng-content></ng-content>
</ng-template>
`
}]
}], ctorParameters: () => [{ type: i1$1.NzDestroyService }], propDecorators: { template: [{
type: ViewChild,
args: [TemplateRef, { static: true }]
}], nzTitle: [{
type: Input
}], nzLabel: [{
type: Input
}], nzValue: [{
type: Input
}], nzKey: [{
type: Input
}], nzDisabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzHide: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzCustomContent: [{
type: Input,
args: [{ transform: booleanAttribute }]
}] } });
/**
* 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 NzSelectArrowComponent {
listOfValue = [];
loading = false;
search = false;
showArrow = false;
isMaxMultipleCountSet = false;
suffixIcon = null;
feedbackIcon = null;
nzMaxMultipleCount = Infinity;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectArrowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzSelectArrowComponent, isStandalone: true, selector: "nz-select-arrow", inputs: { listOfValue: "listOfValue", loading: "loading", search: "search", showArrow: "showArrow", isMaxMultipleCountSet: "isMaxMultipleCountSet", suffixIcon: "suffixIcon", feedbackIcon: "feedbackIcon", nzMaxMultipleCount: ["nzMaxMultipleCount", "nzMaxMultipleCount", numberAttributeWithInfinityFallback] }, host: { properties: { "class.ant-select-arrow-loading": "loading" }, classAttribute: "ant-select-arrow" }, ngImport: i0, template: `
@if (isMaxMultipleCountSet) {
<span>{{ listOfValue.length }} / {{ nzMaxMultipleCount }}</span>
}
@if (loading) {
<nz-icon nzType="loading" />
} @else {
@if (showArrow && !suffixIcon) {
@if (search) {
<nz-icon nzType="search" />
} @else {
<nz-icon nzType="down" />
}
} @else {
<ng-container *nzStringTemplateOutlet="suffixIcon; let suffixIcon">
@if (suffixIcon) {
<nz-icon [nzType]="suffixIcon" />
}
</ng-container>
}
}
<ng-container *nzStringTemplateOutlet="feedbackIcon">{{ feedbackIcon }}</ng-container>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1$2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectArrowComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-select-arrow',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@if (isMaxMultipleCountSet) {
<span>{{ listOfValue.length }} / {{ nzMaxMultipleCount }}</span>
}
@if (loading) {
<nz-icon nzType="loading" />
} @else {
@if (showArrow && !suffixIcon) {
@if (search) {
<nz-icon nzType="search" />
} @else {
<nz-icon nzType="down" />
}
} @else {
<ng-container *nzStringTemplateOutlet="suffixIcon; let suffixIcon">
@if (suffixIcon) {
<nz-icon [nzType]="suffixIcon" />
}
</ng-container>
}
}
<ng-container *nzStringTemplateOutlet="feedbackIcon">{{ feedbackIcon }}</ng-container>
`,
host: {
class: 'ant-select-arrow',
'[class.ant-select-arrow-loading]': 'loading'
},
imports: [NzIconModule, NzOutletModule]
}]
}], propDecorators: { listOfValue: [{
type: Input
}], loading: [{
type: Input
}], search: [{
type: Input
}], showArrow: [{
type: Input
}], isMaxMultipleCountSet: [{
type: Input
}], suffixIcon: [{
type: Input
}], feedbackIcon: [{
type: Input
}], nzMaxMultipleCount: [{
type: Input,
args: [{ transform: numberAttributeWithInfinityFallback }]
}] } });
/**
* 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 NzSelectClearComponent {
clearIcon = null;
clear = new EventEmitter();
onClick(e) {
e.preventDefault();
e.stopPropagation();
this.clear.emit(e);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectClearComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzSelectClearComponent, isStandalone: true, selector: "nz-select-clear", inputs: { clearIcon: "clearIcon" }, outputs: { clear: "clear" }, host: { listeners: { "click": "onClick($event)" }, classAttribute: "ant-select-clear" }, ngImport: i0, template: `
@if (clearIcon) {
<ng-template [ngTemplateOutlet]="clearIcon"></ng-template>
} @else {
<nz-icon nzType="close-circle" nzTheme="fill" class="ant-select-close-icon" />
}
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1$2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectClearComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-select-clear',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@if (clearIcon) {
<ng-template [ngTemplateOutlet]="clearIcon"></ng-template>
} @else {
<nz-icon nzType="close-circle" nzTheme="fill" class="ant-select-close-icon" />
}
`,
host: {
class: 'ant-select-clear',
'(click)': 'onClick($event)'
},
imports: [NgTemplateOutlet, NzIconModule]
}]
}], propDecorators: { clearIcon: [{
type: Input
}], clear: [{
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
*/
class NzSelectItemComponent {
disabled = false;
label = null;
deletable = false;
removeIcon = null;
contentTemplateOutletContext = null;
contentTemplateOutlet = null;
delete = new EventEmitter();
get templateOutletContext() {
return {
$implicit: this.contentTemplateOutletContext,
...this.contentTemplateOutletContext
};
}
onDelete(e) {
e.preventDefault();
e.stopPropagation();
if (!this.disabled) {
this.delete.next(e);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzSelectItemComponent, isStandalone: true, selector: "nz-select-item", inputs: { disabled: "disabled", label: "label", deletable: "deletable", removeIcon: "removeIcon", contentTemplateOutletContext: "contentTemplateOutletContext", contentTemplateOutlet: "contentTemplateOutlet" }, outputs: { delete: "delete" }, host: { properties: { "attr.title": "label", "class.ant-select-selection-item-disabled": "disabled" }, classAttribute: "ant-select-selection-item" }, ngImport: i0, template: `
<ng-container *nzStringTemplateOutlet="contentTemplateOutlet; context: templateOutletContext">
@if (deletable) {
<div class="ant-select-selection-item-content">{{ label }}</div>
} @else {
{{ label }}
}
</ng-container>
@if (deletable && !disabled) {
<span class="ant-select-selection-item-remove" (click)="onDelete($event)">
@if (!removeIcon) {
<nz-icon nzType="close" />
} @else {
<ng-template [ngTemplateOutlet]="removeIcon"></ng-template>
}
</span>
}
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1$2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectItemComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-select-item',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-container *nzStringTemplateOutlet="contentTemplateOutlet; context: templateOutletContext">
@if (deletable) {
<div class="ant-select-selection-item-content">{{ label }}</div>
} @else {
{{ label }}
}
</ng-container>
@if (deletable && !disabled) {
<span class="ant-select-selection-item-remove" (click)="onDelete($event)">
@if (!removeIcon) {
<nz-icon nzType="close" />
} @else {
<ng-template [ngTemplateOutlet]="removeIcon"></ng-template>
}
</span>
}
`,
host: {
class: 'ant-select-selection-item',
'[attr.title]': 'label',
'[class.ant-select-selection-item-disabled]': 'disabled'
},
imports: [NgTemplateOutlet, NzOutletModule, NzIconModule]
}]
}], propDecorators: { disabled: [{
type: Input
}], label: [{
type: Input
}], deletable: [{
type: Input
}], removeIcon: [{
type: Input
}], contentTemplateOutletContext: [{
type: Input
}], contentTemplateOutlet: [{
type: Input
}], delete: [{
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
*/
class NzSelectPlaceholderComponent {
placeholder = null;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectPlaceholderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzSelectPlaceholderComponent, isStandalone: true, selector: "nz-select-placeholder", inputs: { placeholder: "placeholder" }, host: { classAttribute: "ant-select-selection-placeholder" }, ngImport: i0, template: `
<ng-container *nzStringTemplateOutlet="placeholder">
{{ placeholder }}
</ng-container>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectPlaceholderComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-select-placeholder',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-container *nzStringTemplateOutlet="placeholder">
{{ placeholder }}
</ng-container>
`,
host: { class: 'ant-select-selection-placeholder' },
imports: [NzOutletModule]
}]
}], propDecorators: { placeholder: [{
type: Input
}] } });
class NzSelectSearchComponent {
elementRef;
renderer;
focusMonitor;
nzId = null;
disabled = false;
mirrorSync = false;
showInput = true;
focusTrigger = false;
value = '';
autofocus = false;
valueChange = new EventEmitter();
isComposingChange = new EventEmitter();
inputElement;
mirrorElement;
setCompositionState(isComposing) {
this.isComposingChange.next(isComposing);
}
onValueChange(value) {
this.value = value;
this.valueChange.next(value);
if (this.mirrorSync) {
this.syncMirrorWidth();
}
}
clearInputValue() {
const inputDOM = this.inputElement.nativeElement;
inputDOM.value = '';
this.onValueChange('');
}
syncMirrorWidth() {
reqAnimFrame(() => {
const mirrorDOM = this.mirrorElement.nativeElement;
const hostDOM = this.elementRef.nativeElement;
const inputDOM = this.inputElement.nativeElement;
this.renderer.removeStyle(hostDOM, 'width');
this.renderer.setProperty(mirrorDOM, 'textContent', `${inputDOM.value}\u00a0`);
this.renderer.setStyle(hostDOM, 'width', `${mirrorDOM.scrollWidth}px`);
});
}
focus() {
this.focusMonitor.focusVia(this.inputElement, 'keyboard');
}
blur() {
this.inputElement.nativeElement.blur();
}
constructor(elementRef, renderer, focusMonitor) {
this.elementRef = elementRef;
this.renderer = renderer;
this.focusMonitor = focusMonitor;
}
ngOnChanges(changes) {
const inputDOM = this.inputElement.nativeElement;
const { focusTrigger, showInput } = changes;
if (showInput) {
if (this.showInput) {
this.renderer.removeAttribute(inputDOM, 'readonly');
}
else {
this.renderer.setAttribute(inputDOM, 'readonly', 'readonly');
}
}
// IE11 cannot input value if focused before removing readonly
if (focusTrigger && focusTrigger.currentValue === true && focusTrigger.previousValue === false) {
inputDOM.focus();
}
}
ngAfterViewInit() {
if (this.mirrorSync) {
this.syncMirrorWidth();
}
if (this.autofocus) {
this.focus();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSelectSearchComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1$4.FocusMonitor }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzSelectSearchComponent, isStandalone: true, selector: "nz-select-search", inputs: { nzId: "nzId", disabled: "disabled", mirrorSync: "mirrorSync", showInput: "showInput", focusTrigger: "focusTrigger", value: "value", autofocus: "autofocus" }, outputs: { valueChange: "valueChange", isComposingChange: "isComposingChange" }, host: { classAttribute: "ant-select-selection-search" }, providers: [{ provide: COMPOSITION_BUFFER_MODE, useValue: false }], viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["inputElement"], descendants: true, static: true }, { propertyName: "mirrorElement", first: true, predicate: ["mirrorElement"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
<input
#inputElement
[attr.id]="nzId"
autocomplete="off"
class="ant-select-selection-search-input"
[ngModel]="value"
[attr.autofocus]="autofocus ? 'autofocus' : null"
[disabled]="disabled"
[style.opacity]="showInput ? null : 0"
(ngModelChange)="onValueChange($event)"
(compositionstart)="setCompositionState(true)"
(compositionend)="setCompositionState(false)"
/>
@if (mirrorSync) {
<span #mirrorElement class="ant-select-selection-search-mirror"></span>
}
`, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.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: NzSelectSearchComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-select-search',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<input
#inputElement
[attr.id]="nzId"
autocomplete="off"
class="ant-select-selection-search-input"
[ngModel]="value"
[attr.autofocus]="autofocus ? 'autofocus' : null"
[disabled]="disabled"
[style.opacity]="showInput ? null : 0"
(ngModelChange)="onValueChange($event)"
(compositionstart)="setCompositionState(true)"
(compositionend)="setCompositionState(false)"
/>
@if (mirrorSync) {
<span #mirrorElement class="ant-select-selection-search-mirror"></span>
}
`,
host: { class: 'ant-select-selection-search' },
providers: [{ provide: COMPOSITION_BUFFER_MODE, useValue: false }],
imports: [FormsModule]
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1$4.FocusMonitor }], propDecorators: { nzId: [{
type: Input
}], disabled: [{
type: Input
}], mirrorSync: [{
type: Input
}], showInput: [{
type: Input
}], focusTrigger: [{
type: Input
}], value: [{
type: Input
}], autofocus: [{
type: Input
}], valueChange: [{
type: Output
}], isComposingChange: [{
type: Output
}], inputElement: [{
type: ViewChild,
args: ['inputElement', { static: true }]
}], mirrorElement: [{
type: ViewChild,
args: ['mirrorElement', { static: false }]
}] } });
/**
* 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 NzSelectTopControlComponent {
nzId = null;
showSearch = false;
placeHolder = null;
open = false;
maxTagCount = Infinity;
autofocus = false;
disabled = false;
mode = 'default';
customTemplate = null;
maxTagPlaceholder = null;
removeIcon = null;
listOfTopItem = [];
tokenSeparators = [];
tokenize = new EventEmitter();
inputValueChange = new EventEmitter();
deleteItem = new EventEmitter();
nzSelectSearchComponent;
listOfSlicedItem = [];
isShowPlaceholder = true;
isShowSingleLabel = false;
isComposing = false;
inputValue = null;
updateTemplateVariable() {
const isSelectedValueEmpty = this.listOfTopItem.length === 0;
this.isShowPlaceholder = isSelectedValueEmpty && !this.isComposing && !this.inputValue;
this.isShowSingleLabel = !isSelectedValueEmpty && !this.isComposing && !this.inputValue;
}
isComposingChange(isComposing) {
this.isComposing = isComposing;
this.updateTemplateVariable();
}
onInputValueChange(value) {
if (value !== this.inputValue) {
this.inputValue = value;
this.updateTemplateVariable();
this.inputValueChange.emit(value);
this.tokenSeparate(value, this.tokenSeparators);
}
}
tokenSeparate(inputValue, tokenSeparators) {
const includesSeparators = (str, separators) => {
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < separators.length; ++i) {
if (str.lastIndexOf(separators[i]) > 0) {
return true;
}
}
return false;
};
const splitBySeparators = (str, separators) => {
const reg = new RegExp(`[${separators.join()}]`);
const array = str.split(reg).filter(token => token);
return [...new Set(array)];
};
if (inputValue &&
inputValue.length &&
tokenSeparators.length &&
this.mode !== 'default' &&
includesSeparators(inputValue, tokenSeparators)) {
const listOfLabel = splitBySeparators(inputValue, tokenSeparators);
this.tokenize.next(listOfLabel);
}
}
clearInputValue() {
if (this.nzSelectSearchComponent) {
this.nzSelectSearchComponent.clearInputValue();
}
}
focus() {
if (this.nzSelectSearchComponent) {
this.nzSelectSearchComponent.focus();
}
}
blur() {
if (this.nzSelectSearchComponent) {
this.nzSelectSearchComponent.blur();
}
}
onDeleteItem(item) {
if (!this.disabled && !item.nzDisabled) {
this.deleteItem.next(item);
}
}
destroyRef = inject(DestroyRef);
elementRef = inject((ElementRef));
ngZone = inject(NgZone);
n