This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions
+349
View File
@@ -0,0 +1,349 @@
import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality, BidiModule } from '@angular/cdk/bidi';
import { Platform, PlatformModule } from '@angular/cdk/platform';
import * as i0 from '@angular/core';
import { inject, Renderer2, ChangeDetectorRef, DestroyRef, EventEmitter, ElementRef, DOCUMENT, Output, Input, ViewChild, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Subscription, ReplaySubject, merge } from 'rxjs';
import { map, throttleTime } from 'rxjs/operators';
import { NzResizeObserver } from 'ng-zorro-antd/cdk/resize-observer';
import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
import { NzScrollService } from 'ng-zorro-antd/core/services';
import { fromEventOutsideAngular, shallowEqual, getStyleAsText, numberAttributeWithZeroFallback } 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
*/
var AffixRespondEvents;
(function (AffixRespondEvents) {
AffixRespondEvents["resize"] = "resize";
AffixRespondEvents["scroll"] = "scroll";
AffixRespondEvents["touchstart"] = "touchstart";
AffixRespondEvents["touchmove"] = "touchmove";
AffixRespondEvents["touchend"] = "touchend";
AffixRespondEvents["pageshow"] = "pageshow";
AffixRespondEvents["load"] = "LOAD";
})(AffixRespondEvents || (AffixRespondEvents = {}));
/**
* 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
*/
function isTargetWindow(target) {
return typeof window !== 'undefined' && target === window;
}
function getTargetRect(target) {
return !isTargetWindow(target)
? target.getBoundingClientRect()
: {
top: 0,
left: 0,
bottom: 0
};
}
const NZ_CONFIG_MODULE_NAME = 'affix';
const NZ_AFFIX_CLS_PREFIX = 'ant-affix';
const NZ_AFFIX_DEFAULT_SCROLL_TIME = 20;
let NzAffixComponent = (() => {
let _nzOffsetTop_decorators;
let _nzOffsetTop_initializers = [];
let _nzOffsetTop_extraInitializers = [];
let _nzOffsetBottom_decorators;
let _nzOffsetBottom_initializers = [];
let _nzOffsetBottom_extraInitializers = [];
return class NzAffixComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzOffsetTop_decorators = [WithConfig()];
_nzOffsetBottom_decorators = [WithConfig()];
__esDecorate(null, null, _nzOffsetTop_decorators, { kind: "field", name: "nzOffsetTop", static: false, private: false, access: { has: obj => "nzOffsetTop" in obj, get: obj => obj.nzOffsetTop, set: (obj, value) => { obj.nzOffsetTop = value; } }, metadata: _metadata }, _nzOffsetTop_initializers, _nzOffsetTop_extraInitializers);
__esDecorate(null, null, _nzOffsetBottom_decorators, { kind: "field", name: "nzOffsetBottom", static: false, private: false, access: { has: obj => "nzOffsetBottom" in obj, get: obj => obj.nzOffsetBottom, set: (obj, value) => { obj.nzOffsetBottom = value; } }, metadata: _metadata }, _nzOffsetBottom_initializers, _nzOffsetBottom_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
nzConfigService = inject(NzConfigService);
scrollSrv = inject(NzScrollService);
platform = inject(Platform);
renderer = inject(Renderer2);
nzResizeObserver = inject(NzResizeObserver);
cdr = inject(ChangeDetectorRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
fixedEl;
nzTarget;
nzOffsetTop = __runInitializers(this, _nzOffsetTop_initializers, void 0);
nzOffsetBottom = (__runInitializers(this, _nzOffsetTop_extraInitializers), __runInitializers(this, _nzOffsetBottom_initializers, void 0));
nzChange = (__runInitializers(this, _nzOffsetBottom_extraInitializers), new EventEmitter());
dir = 'ltr';
placeholderNode = inject((ElementRef)).nativeElement;
affixStyle;
placeholderStyle;
positionChangeSubscription = Subscription.EMPTY;
offsetChanged$ = new ReplaySubject(1);
timeout;
document = inject(DOCUMENT);
get target() {
const el = this.nzTarget;
return (typeof el === 'string' ? this.document.querySelector(el) : el) || window;
}
constructor() {
this.destroyRef.onDestroy(() => {
this.removeListeners();
});
}
ngOnInit() {
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((direction) => {
this.dir = direction;
this.registerListeners();
this.updatePosition({});
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
}
ngOnChanges(changes) {
const { nzOffsetBottom, nzOffsetTop, nzTarget } = changes;
if (nzOffsetBottom || nzOffsetTop) {
this.offsetChanged$.next();
}
if (nzTarget) {
this.registerListeners();
}
}
ngAfterViewInit() {
this.registerListeners();
}
registerListeners() {
if (!this.platform.isBrowser) {
return;
}
this.removeListeners();
const el = this.target === window ? this.document.body : this.target;
this.positionChangeSubscription = merge(...Object.keys(AffixRespondEvents).map(evName => fromEventOutsideAngular(this.target, evName)), this.offsetChanged$.pipe(map(() => ({}))), this.nzResizeObserver.observe(el))
.pipe(throttleTime(NZ_AFFIX_DEFAULT_SCROLL_TIME, undefined, { trailing: true }), takeUntilDestroyed(this.destroyRef))
.subscribe(e => this.updatePosition(e));
this.timeout = setTimeout(() => this.updatePosition({}));
}
removeListeners() {
clearTimeout(this.timeout);
this.positionChangeSubscription.unsubscribe();
}
getOffset(element, target) {
const elemRect = element.getBoundingClientRect();
const targetRect = getTargetRect(target);
const scrollTop = this.scrollSrv.getScroll(target, true);
const scrollLeft = this.scrollSrv.getScroll(target, false);
const docElem = this.document.body;
const clientTop = docElem.clientTop || 0;
const clientLeft = docElem.clientLeft || 0;
return {
top: elemRect.top - targetRect.top + scrollTop - clientTop,
left: elemRect.left - targetRect.left + scrollLeft - clientLeft,
width: elemRect.width,
height: elemRect.height
};
}
setAffixStyle(e, affixStyle) {
const originalAffixStyle = this.affixStyle;
const isWindow = this.target === window;
if (e.type === 'scroll' && originalAffixStyle && affixStyle && isWindow) {
return;
}
if (shallowEqual(originalAffixStyle, affixStyle)) {
return;
}
const fixed = !!affixStyle;
const wrapEl = this.fixedEl.nativeElement;
this.renderer.setStyle(wrapEl, 'cssText', getStyleAsText(affixStyle));
this.affixStyle = affixStyle;
if (fixed) {
wrapEl.classList.add(NZ_AFFIX_CLS_PREFIX);
}
else {
wrapEl.classList.remove(NZ_AFFIX_CLS_PREFIX);
}
this.updateRtlClass();
if ((affixStyle && !originalAffixStyle) || (!affixStyle && originalAffixStyle)) {
this.nzChange.emit(fixed);
}
}
setPlaceholderStyle(placeholderStyle) {
const originalPlaceholderStyle = this.placeholderStyle;
if (shallowEqual(placeholderStyle, originalPlaceholderStyle)) {
return;
}
this.renderer.setStyle(this.placeholderNode, 'cssText', getStyleAsText(placeholderStyle));
this.placeholderStyle = placeholderStyle;
}
syncPlaceholderStyle(e) {
if (!this.affixStyle) {
return;
}
this.renderer.setStyle(this.placeholderNode, 'cssText', '');
this.placeholderStyle = undefined;
const styleObj = {
width: this.placeholderNode.offsetWidth,
height: this.fixedEl.nativeElement.offsetHeight
};
this.setAffixStyle(e, {
...this.affixStyle,
...styleObj
});
this.setPlaceholderStyle(styleObj);
}
updatePosition(e) {
if (!this.platform.isBrowser) {
return;
}
const targetNode = this.target;
let offsetTop = this.nzOffsetTop;
const scrollTop = this.scrollSrv.getScroll(targetNode, true);
const elemOffset = this.getOffset(this.placeholderNode, targetNode);
const fixedNode = this.fixedEl.nativeElement;
const elemSize = {
width: fixedNode.offsetWidth,
height: fixedNode.offsetHeight
};
const offsetMode = {
top: false,
bottom: false
};
// Default to `offsetTop=0`.
if (typeof offsetTop !== 'number' && typeof this.nzOffsetBottom !== 'number') {
offsetMode.top = true;
offsetTop = 0;
}
else {
offsetMode.top = typeof offsetTop === 'number';
offsetMode.bottom = typeof this.nzOffsetBottom === 'number';
}
const targetRect = getTargetRect(targetNode);
const targetInnerHeight = targetNode.innerHeight || targetNode.clientHeight;
if (scrollTop >= elemOffset.top - offsetTop && offsetMode.top) {
const width = elemOffset.width;
const top = targetRect.top + offsetTop;
this.setAffixStyle(e, {
position: 'fixed',
top,
left: targetRect.left + elemOffset.left,
width
});
this.setPlaceholderStyle({
width,
height: elemSize.height
});
}
else if (scrollTop <= elemOffset.top + elemSize.height + this.nzOffsetBottom - targetInnerHeight &&
offsetMode.bottom) {
const targetBottomOffset = targetNode === window ? 0 : window.innerHeight - targetRect.bottom;
const width = elemOffset.width;
this.setAffixStyle(e, {
position: 'fixed',
bottom: targetBottomOffset + this.nzOffsetBottom,
left: targetRect.left + elemOffset.left,
width
});
this.setPlaceholderStyle({
width,
height: elemOffset.height
});
}
else {
if (e.type === AffixRespondEvents.resize &&
this.affixStyle &&
this.affixStyle.position === 'fixed' &&
this.placeholderNode.offsetWidth) {
this.setAffixStyle(e, {
...this.affixStyle,
width: this.placeholderNode.offsetWidth
});
}
else {
this.setAffixStyle(e);
}
this.setPlaceholderStyle();
}
if (e.type === 'resize') {
this.syncPlaceholderStyle(e);
}
}
updateRtlClass() {
const wrapEl = this.fixedEl.nativeElement;
if (this.dir === 'rtl') {
if (wrapEl.classList.contains(NZ_AFFIX_CLS_PREFIX)) {
wrapEl.classList.add(`${NZ_AFFIX_CLS_PREFIX}-rtl`);
}
else {
wrapEl.classList.remove(`${NZ_AFFIX_CLS_PREFIX}-rtl`);
}
}
else {
wrapEl.classList.remove(`${NZ_AFFIX_CLS_PREFIX}-rtl`);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAffixComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "20.3.0", type: NzAffixComponent, isStandalone: true, selector: "nz-affix", inputs: { nzTarget: "nzTarget", nzOffsetTop: ["nzOffsetTop", "nzOffsetTop", numberAttributeWithZeroFallback], nzOffsetBottom: ["nzOffsetBottom", "nzOffsetBottom", numberAttributeWithZeroFallback] }, outputs: { nzChange: "nzChange" }, viewQueries: [{ propertyName: "fixedEl", first: true, predicate: ["fixedEl"], descendants: true, static: true }], exportAs: ["nzAffix"], usesOnChanges: true, ngImport: i0, template: `
<div #fixedEl>
<ng-content></ng-content>
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: BidiModule }, { kind: "ngmodule", type: PlatformModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAffixComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-affix',
exportAs: 'nzAffix',
imports: [BidiModule, PlatformModule],
template: `
<div #fixedEl>
<ng-content></ng-content>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
}]
}], ctorParameters: () => [], propDecorators: { fixedEl: [{
type: ViewChild,
args: ['fixedEl', { static: true }]
}], nzTarget: [{
type: Input
}], nzOffsetTop: [{
type: Input,
args: [{ transform: numberAttributeWithZeroFallback }]
}], nzOffsetBottom: [{
type: Input,
args: [{ transform: numberAttributeWithZeroFallback }]
}], nzChange: [{
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 NzAffixModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAffixModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzAffixModule, imports: [NzAffixComponent], exports: [NzAffixComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAffixModule, imports: [NzAffixComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAffixModule, decorators: [{
type: NgModule,
args: [{
exports: [NzAffixComponent],
imports: [NzAffixComponent]
}]
}] });
/**
* 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 { NzAffixComponent, NzAffixModule };
//# sourceMappingURL=ng-zorro-antd-affix.mjs.map
File diff suppressed because one or more lines are too long
+298
View File
@@ -0,0 +1,298 @@
import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality } from '@angular/cdk/bidi';
import * as i0 from '@angular/core';
import { inject, ChangeDetectorRef, DestroyRef, EventEmitter, booleanAttribute, Output, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { slideAlertMotion } from 'ng-zorro-antd/core/animation';
import { WithConfig, onConfigChangeEventForComponent } from 'ng-zorro-antd/core/config';
import * as i2 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import * as i1 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
const NZ_CONFIG_MODULE_NAME = 'alert';
let NzAlertComponent = (() => {
let _nzCloseable_decorators;
let _nzCloseable_initializers = [];
let _nzCloseable_extraInitializers = [];
let _nzShowIcon_decorators;
let _nzShowIcon_initializers = [];
let _nzShowIcon_extraInitializers = [];
return class NzAlertComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzCloseable_decorators = [WithConfig()];
_nzShowIcon_decorators = [WithConfig()];
__esDecorate(null, null, _nzCloseable_decorators, { kind: "field", name: "nzCloseable", static: false, private: false, access: { has: obj => "nzCloseable" in obj, get: obj => obj.nzCloseable, set: (obj, value) => { obj.nzCloseable = value; } }, metadata: _metadata }, _nzCloseable_initializers, _nzCloseable_extraInitializers);
__esDecorate(null, null, _nzShowIcon_decorators, { kind: "field", name: "nzShowIcon", static: false, private: false, access: { has: obj => "nzShowIcon" in obj, get: obj => obj.nzShowIcon, set: (obj, value) => { obj.nzShowIcon = value; } }, metadata: _metadata }, _nzShowIcon_initializers, _nzShowIcon_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
cdr = inject(ChangeDetectorRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
nzAction = null;
nzCloseText = null;
nzIconType = null;
nzMessage = null;
nzDescription = null;
nzType = 'info';
nzCloseable = __runInitializers(this, _nzCloseable_initializers, false);
nzShowIcon = (__runInitializers(this, _nzCloseable_extraInitializers), __runInitializers(this, _nzShowIcon_initializers, false));
nzBanner = (__runInitializers(this, _nzShowIcon_extraInitializers), false);
nzNoAnimation = false;
nzIcon = null;
nzOnClose = new EventEmitter();
closed = false;
iconTheme = 'fill';
inferredIconType = 'info-circle';
dir = 'ltr';
isTypeSet = false;
isShowIconSet = false;
constructor() {
onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME, () => this.cdr.markForCheck());
}
ngOnInit() {
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((direction) => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
}
closeAlert() {
this.closed = true;
}
onFadeAnimationDone() {
if (this.closed) {
this.nzOnClose.emit(true);
}
}
ngOnChanges(changes) {
const { nzShowIcon, nzDescription, nzType, nzBanner } = changes;
if (nzShowIcon) {
this.isShowIconSet = true;
}
if (nzType) {
this.isTypeSet = true;
switch (this.nzType) {
case 'error':
this.inferredIconType = 'close-circle';
break;
case 'success':
this.inferredIconType = 'check-circle';
break;
case 'info':
this.inferredIconType = 'info-circle';
break;
case 'warning':
this.inferredIconType = 'exclamation-circle';
break;
}
}
if (nzDescription) {
this.iconTheme = this.nzDescription ? 'outline' : 'fill';
}
if (nzBanner) {
if (!this.isTypeSet) {
this.nzType = 'warning';
}
if (!this.isShowIconSet) {
this.nzShowIcon = true;
}
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzAlertComponent, isStandalone: true, selector: "nz-alert", inputs: { nzAction: "nzAction", nzCloseText: "nzCloseText", nzIconType: "nzIconType", nzMessage: "nzMessage", nzDescription: "nzDescription", nzType: "nzType", nzCloseable: ["nzCloseable", "nzCloseable", booleanAttribute], nzShowIcon: ["nzShowIcon", "nzShowIcon", booleanAttribute], nzBanner: ["nzBanner", "nzBanner", booleanAttribute], nzNoAnimation: ["nzNoAnimation", "nzNoAnimation", booleanAttribute], nzIcon: "nzIcon" }, outputs: { nzOnClose: "nzOnClose" }, exportAs: ["nzAlert"], usesOnChanges: true, ngImport: i0, template: `
@if (!closed) {
<div
class="ant-alert"
[class.ant-alert-rtl]="dir === 'rtl'"
[class.ant-alert-success]="nzType === 'success'"
[class.ant-alert-info]="nzType === 'info'"
[class.ant-alert-warning]="nzType === 'warning'"
[class.ant-alert-error]="nzType === 'error'"
[class.ant-alert-no-icon]="!nzShowIcon"
[class.ant-alert-banner]="nzBanner"
[class.ant-alert-closable]="nzCloseable"
[class.ant-alert-with-description]="!!nzDescription"
[@.disabled]="nzNoAnimation"
[@slideAlertMotion]
(@slideAlertMotion.done)="onFadeAnimationDone()"
>
@if (nzShowIcon) {
<div class="ant-alert-icon">
@if (nzIcon) {
<ng-container *nzStringTemplateOutlet="nzIcon"></ng-container>
} @else {
<nz-icon [nzType]="nzIconType || inferredIconType" [nzTheme]="iconTheme" />
}
</div>
}
@if (nzMessage || nzDescription) {
<div class="ant-alert-content">
@if (nzMessage) {
<span class="ant-alert-message">
<ng-container *nzStringTemplateOutlet="nzMessage">{{ nzMessage }}</ng-container>
</span>
}
@if (nzDescription) {
<span class="ant-alert-description">
<ng-container *nzStringTemplateOutlet="nzDescription">{{ nzDescription }}</ng-container>
</span>
}
</div>
}
@if (nzAction) {
<div class="ant-alert-action">
<ng-container *nzStringTemplateOutlet="nzAction">{{ nzAction }}</ng-container>
</div>
}
@if (nzCloseable || nzCloseText) {
<button type="button" tabindex="0" class="ant-alert-close-icon" (click)="closeAlert()">
@if (nzCloseText) {
<ng-container *nzStringTemplateOutlet="nzCloseText">
<span class="ant-alert-close-text">{{ nzCloseText }}</span>
</ng-container>
} @else {
<nz-icon nzType="close" />
}
</button>
}
</div>
}
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i2.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], animations: [slideAlertMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAlertComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-alert',
exportAs: 'nzAlert',
animations: [slideAlertMotion],
imports: [NzIconModule, NzOutletModule],
template: `
@if (!closed) {
<div
class="ant-alert"
[class.ant-alert-rtl]="dir === 'rtl'"
[class.ant-alert-success]="nzType === 'success'"
[class.ant-alert-info]="nzType === 'info'"
[class.ant-alert-warning]="nzType === 'warning'"
[class.ant-alert-error]="nzType === 'error'"
[class.ant-alert-no-icon]="!nzShowIcon"
[class.ant-alert-banner]="nzBanner"
[class.ant-alert-closable]="nzCloseable"
[class.ant-alert-with-description]="!!nzDescription"
[@.disabled]="nzNoAnimation"
[@slideAlertMotion]
(@slideAlertMotion.done)="onFadeAnimationDone()"
>
@if (nzShowIcon) {
<div class="ant-alert-icon">
@if (nzIcon) {
<ng-container *nzStringTemplateOutlet="nzIcon"></ng-container>
} @else {
<nz-icon [nzType]="nzIconType || inferredIconType" [nzTheme]="iconTheme" />
}
</div>
}
@if (nzMessage || nzDescription) {
<div class="ant-alert-content">
@if (nzMessage) {
<span class="ant-alert-message">
<ng-container *nzStringTemplateOutlet="nzMessage">{{ nzMessage }}</ng-container>
</span>
}
@if (nzDescription) {
<span class="ant-alert-description">
<ng-container *nzStringTemplateOutlet="nzDescription">{{ nzDescription }}</ng-container>
</span>
}
</div>
}
@if (nzAction) {
<div class="ant-alert-action">
<ng-container *nzStringTemplateOutlet="nzAction">{{ nzAction }}</ng-container>
</div>
}
@if (nzCloseable || nzCloseText) {
<button type="button" tabindex="0" class="ant-alert-close-icon" (click)="closeAlert()">
@if (nzCloseText) {
<ng-container *nzStringTemplateOutlet="nzCloseText">
<span class="ant-alert-close-text">{{ nzCloseText }}</span>
</ng-container>
} @else {
<nz-icon nzType="close" />
}
</button>
}
</div>
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
}]
}], ctorParameters: () => [], propDecorators: { nzAction: [{
type: Input
}], nzCloseText: [{
type: Input
}], nzIconType: [{
type: Input
}], nzMessage: [{
type: Input
}], nzDescription: [{
type: Input
}], nzType: [{
type: Input
}], nzCloseable: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzShowIcon: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzBanner: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzNoAnimation: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzIcon: [{
type: Input
}], nzOnClose: [{
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 NzAlertModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAlertModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzAlertModule, imports: [NzAlertComponent], exports: [NzAlertComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAlertModule, imports: [NzAlertComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAlertModule, decorators: [{
type: NgModule,
args: [{
exports: [NzAlertComponent],
imports: [NzAlertComponent]
}]
}] });
/**
* 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 { NzAlertComponent, NzAlertModule };
//# sourceMappingURL=ng-zorro-antd-alert.mjs.map
File diff suppressed because one or more lines are too long
+467
View File
@@ -0,0 +1,467 @@
import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';
import { NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { inject, ChangeDetectorRef, Renderer2, DOCUMENT, DestroyRef, EventEmitter, numberAttribute, booleanAttribute, Output, Input, ViewChild, ChangeDetectionStrategy, ViewEncapsulation, Component, ElementRef, TemplateRef, ContentChild, NgModule } from '@angular/core';
import { __esDecorate, __runInitializers } from 'tslib';
import { Subject } from 'rxjs';
import { throttleTime, takeUntil } from 'rxjs/operators';
import * as i1 from 'ng-zorro-antd/affix';
import { NzAffixModule } from 'ng-zorro-antd/affix';
import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
import { NzScrollService } from 'ng-zorro-antd/core/services';
import { fromEventOutsideAngular, numberAttributeWithZeroFallback } 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
*/
function getOffsetTop(element, container) {
if (!element || !element.getClientRects().length) {
return 0;
}
const rect = element.getBoundingClientRect();
if (rect.width || rect.height) {
if (container === window) {
const documentElement = element.ownerDocument.documentElement;
return rect.top - documentElement.clientTop;
}
return rect.top - container.getBoundingClientRect().top;
}
return rect.top;
}
const VISIBLE_CLASSNAME = 'ant-anchor-ink-ball-visible';
const NZ_CONFIG_MODULE_NAME = 'anchor';
const sharpMatcherRegx = /#([^#]+)$/;
const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
let NzAnchorComponent = (() => {
let _nzShowInkInFixed_decorators;
let _nzShowInkInFixed_initializers = [];
let _nzShowInkInFixed_extraInitializers = [];
let _nzBounds_decorators;
let _nzBounds_initializers = [];
let _nzBounds_extraInitializers = [];
let _nzOffsetTop_decorators;
let _nzOffsetTop_initializers = [];
let _nzOffsetTop_extraInitializers = [];
let _nzTargetOffset_decorators;
let _nzTargetOffset_initializers = [];
let _nzTargetOffset_extraInitializers = [];
return class NzAnchorComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzShowInkInFixed_decorators = [WithConfig()];
_nzBounds_decorators = [WithConfig()];
_nzOffsetTop_decorators = [WithConfig()];
_nzTargetOffset_decorators = [WithConfig()];
__esDecorate(null, null, _nzShowInkInFixed_decorators, { kind: "field", name: "nzShowInkInFixed", static: false, private: false, access: { has: obj => "nzShowInkInFixed" in obj, get: obj => obj.nzShowInkInFixed, set: (obj, value) => { obj.nzShowInkInFixed = value; } }, metadata: _metadata }, _nzShowInkInFixed_initializers, _nzShowInkInFixed_extraInitializers);
__esDecorate(null, null, _nzBounds_decorators, { kind: "field", name: "nzBounds", static: false, private: false, access: { has: obj => "nzBounds" in obj, get: obj => obj.nzBounds, set: (obj, value) => { obj.nzBounds = value; } }, metadata: _metadata }, _nzBounds_initializers, _nzBounds_extraInitializers);
__esDecorate(null, null, _nzOffsetTop_decorators, { kind: "field", name: "nzOffsetTop", static: false, private: false, access: { has: obj => "nzOffsetTop" in obj, get: obj => obj.nzOffsetTop, set: (obj, value) => { obj.nzOffsetTop = value; } }, metadata: _metadata }, _nzOffsetTop_initializers, _nzOffsetTop_extraInitializers);
__esDecorate(null, null, _nzTargetOffset_decorators, { kind: "field", name: "nzTargetOffset", static: false, private: false, access: { has: obj => "nzTargetOffset" in obj, get: obj => obj.nzTargetOffset, set: (obj, value) => { obj.nzTargetOffset = value; } }, metadata: _metadata }, _nzTargetOffset_initializers, _nzTargetOffset_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
nzConfigService = inject(NzConfigService);
scrollSrv = inject(NzScrollService);
cdr = inject(ChangeDetectorRef);
platform = inject(Platform);
renderer = inject(Renderer2);
doc = inject(DOCUMENT);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
ink;
nzAffix = true;
nzShowInkInFixed = __runInitializers(this, _nzShowInkInFixed_initializers, false);
nzBounds = (__runInitializers(this, _nzShowInkInFixed_extraInitializers), __runInitializers(this, _nzBounds_initializers, 5));
nzOffsetTop = (__runInitializers(this, _nzBounds_extraInitializers), __runInitializers(this, _nzOffsetTop_initializers, undefined));
nzTargetOffset = (__runInitializers(this, _nzOffsetTop_extraInitializers), __runInitializers(this, _nzTargetOffset_initializers, undefined));
nzContainer = __runInitializers(this, _nzTargetOffset_extraInitializers);
nzCurrentAnchor;
nzDirection = 'vertical';
nzClick = new EventEmitter();
nzChange = new EventEmitter();
nzScroll = new EventEmitter();
visible = false;
wrapperStyle = { 'max-height': '100vh' };
container;
activeLink;
links = [];
animating = false;
destroy$ = new Subject();
handleScrollTimeoutID;
constructor() {
this.destroyRef.onDestroy(() => {
clearTimeout(this.handleScrollTimeoutID);
this.destroy$.next(true);
this.destroy$.complete();
});
}
registerLink(link) {
this.links.push(link);
}
unregisterLink(link) {
this.links.splice(this.links.indexOf(link), 1);
}
getContainer() {
return this.container || window;
}
ngAfterViewInit() {
this.registerScrollEvent();
}
registerScrollEvent() {
if (!this.platform.isBrowser) {
return;
}
this.destroy$.next(true);
fromEventOutsideAngular(this.getContainer(), 'scroll', passiveEventListenerOptions)
.pipe(throttleTime(50), takeUntil(this.destroy$))
.subscribe(() => this.handleScroll());
// Browser would maintain the scrolling position when refreshing.
// So we have to delay calculation in avoid of getting a incorrect result.
this.handleScrollTimeoutID = setTimeout(() => this.handleScroll());
}
handleScroll() {
if (typeof document === 'undefined' || this.animating) {
return;
}
const sections = [];
const offsetTop = this.nzTargetOffset ? this.nzTargetOffset : this.nzOffsetTop || 0;
const scope = offsetTop + this.nzBounds;
this.links.forEach(comp => {
const sharpLinkMatch = sharpMatcherRegx.exec(comp.nzHref.toString());
if (!sharpLinkMatch) {
return;
}
const target = this.doc.getElementById(sharpLinkMatch[1]);
if (target) {
const top = getOffsetTop(target, this.getContainer());
if (top < scope) {
sections.push({
top,
comp
});
}
}
});
this.visible = !!sections.length;
if (!this.visible) {
this.clearActive();
this.cdr.detectChanges();
}
else {
const maxSection = sections.reduce((prev, curr) => (curr.top > prev.top ? curr : prev));
this.handleActive(maxSection.comp);
}
this.setVisible();
}
clearActive() {
this.links.forEach(i => {
i.unsetActive();
});
}
setActive(comp) {
const originalActiveLink = this.activeLink;
const targetComp = (this.nzCurrentAnchor && this.links.find(n => n.nzHref === this.nzCurrentAnchor)) || comp;
if (!targetComp)
return;
targetComp.setActive();
const linkNode = targetComp.getLinkTitleElement();
if (this.nzDirection === 'vertical') {
this.ink.nativeElement.style.top = `${linkNode.offsetTop + linkNode.clientHeight / 2 - 4.5}px`;
}
else {
this.ink.nativeElement.style.left = `${linkNode.offsetLeft + linkNode.clientWidth / 2}px`;
}
this.activeLink = (comp || targetComp).nzHref;
if (originalActiveLink !== this.activeLink) {
this.nzChange.emit(this.activeLink);
}
}
handleActive(comp) {
this.clearActive();
this.setActive(comp);
this.visible = true;
this.setVisible();
this.nzScroll.emit(comp);
}
setVisible() {
if (this.ink) {
const visible = this.visible;
if (visible) {
this.renderer.addClass(this.ink.nativeElement, VISIBLE_CLASSNAME);
}
else {
this.renderer.removeClass(this.ink.nativeElement, VISIBLE_CLASSNAME);
}
}
}
handleScrollTo(linkComp) {
const el = this.doc.querySelector(linkComp.nzHref);
if (!el) {
return;
}
this.animating = true;
const containerScrollTop = this.scrollSrv.getScroll(this.getContainer());
const elOffsetTop = getOffsetTop(el, this.getContainer());
let targetScrollTop = containerScrollTop + elOffsetTop;
targetScrollTop -= this.nzTargetOffset !== undefined ? this.nzTargetOffset : this.nzOffsetTop || 0;
this.scrollSrv.scrollTo(this.getContainer(), targetScrollTop, {
callback: () => {
this.animating = false;
this.handleActive(linkComp);
}
});
this.nzClick.emit(linkComp.nzHref);
}
ngOnChanges(changes) {
const { nzOffsetTop, nzContainer, nzCurrentAnchor } = changes;
if (nzOffsetTop) {
this.wrapperStyle = {
'max-height': `calc(100vh - ${this.nzOffsetTop}px)`
};
}
if (nzContainer) {
const container = this.nzContainer;
this.container = typeof container === 'string' ? this.doc.querySelector(container) : container;
this.registerScrollEvent();
}
if (nzCurrentAnchor) {
this.setActive();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAnchorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzAnchorComponent, isStandalone: true, selector: "nz-anchor", inputs: { nzAffix: ["nzAffix", "nzAffix", booleanAttribute], nzShowInkInFixed: ["nzShowInkInFixed", "nzShowInkInFixed", booleanAttribute], nzBounds: ["nzBounds", "nzBounds", numberAttribute], nzOffsetTop: ["nzOffsetTop", "nzOffsetTop", numberAttributeWithZeroFallback], nzTargetOffset: ["nzTargetOffset", "nzTargetOffset", numberAttributeWithZeroFallback], nzContainer: "nzContainer", nzCurrentAnchor: "nzCurrentAnchor", nzDirection: "nzDirection" }, outputs: { nzClick: "nzClick", nzChange: "nzChange", nzScroll: "nzScroll" }, viewQueries: [{ propertyName: "ink", first: true, predicate: ["ink"], descendants: true }], exportAs: ["nzAnchor"], usesOnChanges: true, ngImport: i0, template: `
@if (nzAffix) {
<nz-affix [nzOffsetTop]="nzOffsetTop" [nzTarget]="container">
<ng-template [ngTemplateOutlet]="content"></ng-template>
</nz-affix>
} @else {
<ng-template [ngTemplateOutlet]="content"></ng-template>
}
<ng-template #content>
<div
class="ant-anchor-wrapper"
[class]="{ 'ant-anchor-wrapper-horizontal': nzDirection === 'horizontal' }"
[style]="wrapperStyle"
>
<div class="ant-anchor" [class]="{ 'ant-anchor-fixed': !nzAffix && !nzShowInkInFixed }">
<div class="ant-anchor-ink">
<div class="ant-anchor-ink-ball" #ink></div>
</div>
<ng-content></ng-content>
</div>
</div>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzAffixModule }, { kind: "component", type: i1.NzAffixComponent, selector: "nz-affix", inputs: ["nzTarget", "nzOffsetTop", "nzOffsetBottom"], outputs: ["nzChange"], exportAs: ["nzAffix"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAnchorComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-anchor',
exportAs: 'nzAnchor',
imports: [NgTemplateOutlet, NzAffixModule],
template: `
@if (nzAffix) {
<nz-affix [nzOffsetTop]="nzOffsetTop" [nzTarget]="container">
<ng-template [ngTemplateOutlet]="content"></ng-template>
</nz-affix>
} @else {
<ng-template [ngTemplateOutlet]="content"></ng-template>
}
<ng-template #content>
<div
class="ant-anchor-wrapper"
[class]="{ 'ant-anchor-wrapper-horizontal': nzDirection === 'horizontal' }"
[style]="wrapperStyle"
>
<div class="ant-anchor" [class]="{ 'ant-anchor-fixed': !nzAffix && !nzShowInkInFixed }">
<div class="ant-anchor-ink">
<div class="ant-anchor-ink-ball" #ink></div>
</div>
<ng-content></ng-content>
</div>
</div>
</ng-template>
`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
}]
}], ctorParameters: () => [], propDecorators: { ink: [{
type: ViewChild,
args: ['ink', { static: false }]
}], nzAffix: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzShowInkInFixed: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzBounds: [{
type: Input,
args: [{ transform: numberAttribute }]
}], nzOffsetTop: [{
type: Input,
args: [{ transform: numberAttributeWithZeroFallback }]
}], nzTargetOffset: [{
type: Input,
args: [{ transform: numberAttributeWithZeroFallback }]
}], nzContainer: [{
type: Input
}], nzCurrentAnchor: [{
type: Input
}], nzDirection: [{
type: Input
}], nzClick: [{
type: Output
}], nzChange: [{
type: Output
}], nzScroll: [{
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 NzAnchorLinkComponent {
elementRef = inject((ElementRef));
anchorComp = inject(NzAnchorComponent);
platform = inject(Platform);
renderer = inject(Renderer2);
destroyRef = inject(DestroyRef);
nzHref = '#';
nzTarget;
titleStr = '';
titleTpl;
nzDirection = 'vertical';
set nzTitle(value) {
if (value instanceof TemplateRef) {
this.titleStr = null;
this.titleTpl = value;
}
else {
this.titleStr = value;
}
}
nzTemplate;
linkTitle;
constructor() {
this.destroyRef.onDestroy(() => {
this.anchorComp.unregisterLink(this);
});
}
ngOnInit() {
this.anchorComp.registerLink(this);
this.nzDirection = this.anchorComp.nzDirection;
}
getLinkTitleElement() {
return this.linkTitle.nativeElement;
}
setActive() {
this.renderer.addClass(this.elementRef.nativeElement, 'ant-anchor-link-active');
}
unsetActive() {
this.renderer.removeClass(this.elementRef.nativeElement, 'ant-anchor-link-active');
}
goToClick(e) {
e.preventDefault();
e.stopPropagation();
if (this.platform.isBrowser) {
this.anchorComp.handleScrollTo(this);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAnchorLinkComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzAnchorLinkComponent, isStandalone: true, selector: "nz-link", inputs: { nzHref: "nzHref", nzTarget: "nzTarget", nzTitle: "nzTitle" }, host: { classAttribute: "ant-anchor-link" }, queries: [{ propertyName: "nzTemplate", first: true, predicate: ["nzTemplate"], descendants: true }], viewQueries: [{ propertyName: "linkTitle", first: true, predicate: ["linkTitle"], descendants: true }], exportAs: ["nzLink"], ngImport: i0, template: `
<a
#linkTitle
class="ant-anchor-link-title"
[href]="nzHref"
[attr.title]="titleStr"
[target]="nzTarget"
(click)="goToClick($event)"
>
@if (titleStr) {
<span>{{ titleStr }}</span>
} @else {
<ng-template [ngTemplateOutlet]="titleTpl || nzTemplate" />
}
</a>
@if (nzDirection === 'vertical') {
<ng-content></ng-content>
}
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAnchorLinkComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-link',
exportAs: 'nzLink',
imports: [NgTemplateOutlet],
template: `
<a
#linkTitle
class="ant-anchor-link-title"
[href]="nzHref"
[attr.title]="titleStr"
[target]="nzTarget"
(click)="goToClick($event)"
>
@if (titleStr) {
<span>{{ titleStr }}</span>
} @else {
<ng-template [ngTemplateOutlet]="titleTpl || nzTemplate" />
}
</a>
@if (nzDirection === 'vertical') {
<ng-content></ng-content>
}
`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'ant-anchor-link'
}
}]
}], ctorParameters: () => [], propDecorators: { nzHref: [{
type: Input
}], nzTarget: [{
type: Input
}], nzTitle: [{
type: Input
}], nzTemplate: [{
type: ContentChild,
args: ['nzTemplate', { static: false }]
}], linkTitle: [{
type: ViewChild,
args: ['linkTitle']
}] } });
/**
* 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 NzAnchorModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAnchorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzAnchorModule, imports: [NzAnchorComponent, NzAnchorLinkComponent], exports: [NzAnchorComponent, NzAnchorLinkComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAnchorModule, imports: [NzAnchorComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAnchorModule, decorators: [{
type: NgModule,
args: [{
exports: [NzAnchorComponent, NzAnchorLinkComponent],
imports: [NzAnchorComponent, NzAnchorLinkComponent]
}]
}] });
/**
* 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 { NzAnchorComponent, NzAnchorLinkComponent, NzAnchorModule };
//# sourceMappingURL=ng-zorro-antd-anchor.mjs.map
File diff suppressed because one or more lines are too long
+831
View File
@@ -0,0 +1,831 @@
import * as i0 from '@angular/core';
import { Input, ViewEncapsulation, ChangeDetectionStrategy, Component, inject, NgZone, ChangeDetectorRef, ElementRef, DestroyRef, EventEmitter, booleanAttribute, Output, forwardRef, Injector, ViewContainerRef, DOCUMENT, Directive, TemplateRef, ViewChild, ViewChildren, ContentChildren, NgModule } from '@angular/core';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { filter, tap, delay, switchMap } from 'rxjs/operators';
import { fromEventOutsideAngular, scrollIntoView, numberAttributeWithZeroFallback } from 'ng-zorro-antd/core/util';
import { UP_ARROW, DOWN_ARROW, ESCAPE, TAB, ENTER } from '@angular/cdk/keycodes';
import { createOverlayRef, createRepositionScrollStrategy, createFlexibleConnectedPositionStrategy, ConnectionPositionPair } from '@angular/cdk/overlay';
import { TemplatePortal } from '@angular/cdk/portal';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzInputGroupWhitSuffixOrPrefixDirective } from 'ng-zorro-antd/input';
import { Directionality } from '@angular/cdk/bidi';
import { NgTemplateOutlet } from '@angular/common';
import { Subscription, defer, merge } from 'rxjs';
import { slideMotion } from 'ng-zorro-antd/core/animation';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { NZ_AFTER_NEXT_RENDER$ } from 'ng-zorro-antd/core/render';
/**
* 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 NzAutocompleteOptgroupComponent {
nzLabel;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteOptgroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzAutocompleteOptgroupComponent, isStandalone: true, selector: "nz-auto-optgroup", inputs: { nzLabel: "nzLabel" }, exportAs: ["nzAutoOptgroup"], ngImport: i0, template: `
<div class="ant-select-item ant-select-item-group">
<ng-container *nzStringTemplateOutlet="nzLabel">{{ nzLabel }}</ng-container>
</div>
<ng-content select="nz-auto-option"></ng-content>
`, 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: "20.3.0", ngImport: i0, type: NzAutocompleteOptgroupComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-auto-optgroup',
exportAs: 'nzAutoOptgroup',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
imports: [NzOutletModule],
template: `
<div class="ant-select-item ant-select-item-group">
<ng-container *nzStringTemplateOutlet="nzLabel">{{ nzLabel }}</ng-container>
</div>
<ng-content select="nz-auto-option"></ng-content>
`
}]
}], 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 NzOptionSelectionChange {
source;
isUserInput;
constructor(source, isUserInput = false) {
this.source = source;
this.isUserInput = isUserInput;
}
}
class NzAutocompleteOptionComponent {
ngZone = inject(NgZone);
changeDetectorRef = inject(ChangeDetectorRef);
element = inject((ElementRef));
destroyRef = inject(DestroyRef);
nzValue;
nzLabel;
nzDisabled = false;
selectionChange = new EventEmitter();
mouseEntered = new EventEmitter();
active = false;
selected = false;
nzAutocompleteOptgroupComponent = inject(NzAutocompleteOptgroupComponent, { optional: true });
ngOnInit() {
fromEventOutsideAngular(this.element.nativeElement, 'mouseenter')
.pipe(filter(() => this.mouseEntered.observers.length > 0), takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.ngZone.run(() => this.mouseEntered.emit(this));
});
fromEventOutsideAngular(this.element.nativeElement, 'mousedown')
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(event => event.preventDefault());
}
select(emit = true) {
this.selected = true;
this.changeDetectorRef.markForCheck();
if (emit) {
this.emitSelectionChangeEvent();
}
}
deselect() {
this.selected = false;
this.changeDetectorRef.markForCheck();
this.emitSelectionChangeEvent();
}
/** Git display label */
getLabel() {
return this.nzLabel || this.nzValue.toString();
}
/** Set active (only styles) */
setActiveStyles() {
if (!this.active) {
this.active = true;
this.changeDetectorRef.markForCheck();
}
}
/** Unset active (only styles) */
setInactiveStyles() {
if (this.active) {
this.active = false;
this.changeDetectorRef.markForCheck();
}
}
scrollIntoViewIfNeeded() {
scrollIntoView(this.element.nativeElement);
}
selectViaInteraction() {
if (!this.nzDisabled) {
this.selected = !this.selected;
if (this.selected) {
this.setActiveStyles();
}
else {
this.setInactiveStyles();
}
this.emitSelectionChangeEvent(true);
this.changeDetectorRef.markForCheck();
}
}
emitSelectionChangeEvent(isUserInput = false) {
this.selectionChange.emit(new NzOptionSelectionChange(this, isUserInput));
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteOptionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "20.3.0", type: NzAutocompleteOptionComponent, isStandalone: true, selector: "nz-auto-option", inputs: { nzValue: "nzValue", nzLabel: "nzLabel", nzDisabled: ["nzDisabled", "nzDisabled", booleanAttribute] }, outputs: { selectionChange: "selectionChange", mouseEntered: "mouseEntered" }, host: { attributes: { "role": "menuitem" }, listeners: { "click": "selectViaInteraction()" }, properties: { "class.ant-select-item-option-grouped": "nzAutocompleteOptgroupComponent", "class.ant-select-item-option-selected": "selected", "class.ant-select-item-option-active": "active", "class.ant-select-item-option-disabled": "nzDisabled", "attr.aria-selected": "selected.toString()", "attr.aria-disabled": "nzDisabled.toString()" }, classAttribute: "ant-select-item ant-select-item-option" }, exportAs: ["nzAutoOption"], ngImport: i0, template: `
<div class="ant-select-item-option-content">
<ng-content></ng-content>
</div>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteOptionComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-auto-option',
exportAs: 'nzAutoOption',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: `
<div class="ant-select-item-option-content">
<ng-content></ng-content>
</div>
`,
host: {
role: 'menuitem',
class: 'ant-select-item ant-select-item-option',
'[class.ant-select-item-option-grouped]': 'nzAutocompleteOptgroupComponent',
'[class.ant-select-item-option-selected]': 'selected',
'[class.ant-select-item-option-active]': 'active',
'[class.ant-select-item-option-disabled]': 'nzDisabled',
'[attr.aria-selected]': 'selected.toString()',
'[attr.aria-disabled]': 'nzDisabled.toString()',
'(click)': 'selectViaInteraction()'
}
}]
}], propDecorators: { nzValue: [{
type: Input
}], nzLabel: [{
type: Input
}], nzDisabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], selectionChange: [{
type: Output
}], mouseEntered: [{
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
*/
/**
* @deprecated Internally used, will be removed in v21, please do not use it.
*/
const NZ_AUTOCOMPLETE_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NzAutocompleteTriggerDirective),
multi: true
};
/**
* @deprecated Internally used, will not be exported in v21, please do not use it.
*/
function getNzAutocompleteMissingPanelError() {
return Error('Attempting to open an undefined instance of `nz-autocomplete`. ' +
'Make sure that the id passed to the `nzAutocomplete` is correct and that ' +
"you're attempting to open it after the ngAfterContentInit hook.");
}
class NzAutocompleteTriggerDirective {
injector = inject(Injector);
ngZone = inject(NgZone);
elementRef = inject((ElementRef));
viewContainerRef = inject(ViewContainerRef);
destroyRef = inject(DestroyRef);
/** Bind nzAutocomplete component */
nzAutocomplete;
onChange = () => { };
onTouched = () => { };
panelOpen = false;
/** Current active option */
get activeOption() {
if (this.nzAutocomplete && this.nzAutocomplete.options.length) {
return this.nzAutocomplete.activeItem;
}
else {
return null;
}
}
overlayRef = null;
portal = null;
positionStrategy;
previousValue = null;
selectionChangeSubscription;
optionsChangeSubscription;
overlayOutsideClickSubscription;
document = inject(DOCUMENT);
nzInputGroupWhitSuffixOrPrefixDirective = inject(NzInputGroupWhitSuffixOrPrefixDirective, { optional: true });
constructor() {
this.destroyRef.onDestroy(() => {
this.destroyPanel();
});
}
ngAfterViewInit() {
if (this.nzAutocomplete) {
this.nzAutocomplete.animationStateChange.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(event => {
if (event.toState === 'void') {
if (this.overlayRef) {
this.overlayRef.dispose();
this.overlayRef = null;
}
}
});
}
}
writeValue(value) {
this.ngZone.runOutsideAngular(() => {
Promise.resolve(null).then(() => this.setTriggerValue(value));
});
}
registerOnChange(fn) {
this.onChange = fn;
}
registerOnTouched(fn) {
this.onTouched = fn;
}
setDisabledState(isDisabled) {
const element = this.elementRef.nativeElement;
element.disabled = isDisabled;
this.closePanel();
}
openPanel() {
this.previousValue = this.elementRef.nativeElement.value;
this.attachOverlay();
this.updateStatus();
}
closePanel() {
if (this.panelOpen) {
this.nzAutocomplete.isOpen = this.panelOpen = false;
if (this.overlayRef && this.overlayRef.hasAttached()) {
this.overlayRef.detach();
this.selectionChangeSubscription.unsubscribe();
this.overlayOutsideClickSubscription.unsubscribe();
this.optionsChangeSubscription.unsubscribe();
this.portal = null;
}
}
}
handleKeydown(event) {
const keyCode = event.keyCode;
const isArrowKey = keyCode === UP_ARROW || keyCode === DOWN_ARROW;
if (keyCode === ESCAPE) {
event.preventDefault();
}
if (this.panelOpen && (keyCode === ESCAPE || keyCode === TAB)) {
// Reset value when tab / ESC close
if (this.activeOption && this.activeOption.getLabel() !== this.previousValue) {
this.setTriggerValue(this.previousValue);
}
this.closePanel();
}
else if (this.panelOpen && keyCode === ENTER) {
if (this.nzAutocomplete.showPanel) {
event.preventDefault();
if (this.activeOption) {
this.activeOption.selectViaInteraction();
}
else {
this.closePanel();
}
}
}
else if (this.panelOpen && isArrowKey && this.nzAutocomplete.showPanel) {
event.stopPropagation();
event.preventDefault();
if (keyCode === UP_ARROW) {
this.nzAutocomplete.setPreviousItemActive();
}
else {
this.nzAutocomplete.setNextItemActive();
}
if (this.activeOption) {
this.activeOption.scrollIntoViewIfNeeded();
}
this.doBackfill();
}
}
handleInput(event) {
const target = event.target;
const document = this.document;
let value = target.value;
if (target.type === 'number') {
value = value === '' ? null : parseFloat(value);
}
if (this.previousValue !== value) {
this.previousValue = value;
this.onChange(value);
if (this.canOpen() && document.activeElement === event.target) {
this.openPanel();
}
}
}
handleFocus() {
if (this.canOpen()) {
this.openPanel();
}
}
handleClick() {
if (this.canOpen() && !this.panelOpen) {
this.openPanel();
}
}
handleBlur() {
this.onTouched();
}
/**
* Subscription data source changes event
*/
subscribeOptionsChange() {
const optionChanges = this.nzAutocomplete.options.changes.pipe(tap(() => this.positionStrategy.reapplyLastPosition()), delay(0));
return optionChanges.subscribe(() => {
this.resetActiveItem();
if (this.panelOpen) {
this.overlayRef.updatePosition();
}
});
}
/**
* Subscription option changes event and set the value
*/
subscribeSelectionChange() {
return this.nzAutocomplete.selectionChange.subscribe((option) => {
this.setValueAndClose(option);
});
}
subscribeOverlayOutsideClick() {
return this.overlayRef.outsidePointerEvents()
.pipe(filter((e) => !this.elementRef.nativeElement.contains(e.target)))
.subscribe(() => {
this.closePanel();
});
}
attachOverlay() {
if (!this.nzAutocomplete) {
throw getNzAutocompleteMissingPanelError();
}
if (!this.portal && this.nzAutocomplete.template) {
this.portal = new TemplatePortal(this.nzAutocomplete.template, this.viewContainerRef);
}
if (!this.overlayRef) {
this.overlayRef = createOverlayRef(this.injector, {
positionStrategy: this.getOverlayPosition(),
disposeOnNavigation: true,
scrollStrategy: createRepositionScrollStrategy(this.injector),
// default host element width
width: this.nzAutocomplete.nzWidth || this.getHostWidth()
});
}
if (this.overlayRef && !this.overlayRef.hasAttached()) {
this.overlayRef.attach(this.portal);
this.selectionChangeSubscription = this.subscribeSelectionChange();
this.optionsChangeSubscription = this.subscribeOptionsChange();
this.overlayOutsideClickSubscription = this.subscribeOverlayOutsideClick();
this.overlayRef
.detachments()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.closePanel();
});
}
this.nzAutocomplete.isOpen = this.panelOpen = true;
}
updateStatus() {
if (this.overlayRef) {
this.overlayRef.updateSize({ width: this.nzAutocomplete.nzWidth || this.getHostWidth() });
}
this.nzAutocomplete.setVisibility();
this.resetActiveItem();
if (this.activeOption) {
this.activeOption.scrollIntoViewIfNeeded();
}
}
destroyPanel() {
if (this.overlayRef) {
this.closePanel();
}
}
getConnectedElement() {
return this.nzInputGroupWhitSuffixOrPrefixDirective?.elementRef ?? this.elementRef;
}
getOverlayPosition() {
return (this.positionStrategy = createFlexibleConnectedPositionStrategy(this.injector, this.getConnectedElement())
.withFlexibleDimensions(false)
.withPush(false)
.withPositions([
new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'top' }),
new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' })
])
.withTransformOriginOn('.ant-select-dropdown'));
}
getHostWidth() {
return this.getConnectedElement().nativeElement.getBoundingClientRect().width;
}
resetActiveItem() {
const index = this.nzAutocomplete.getOptionIndex(this.previousValue);
this.nzAutocomplete.clearSelectedOptions(null, true);
if (index !== -1) {
this.nzAutocomplete.setActiveItem(index);
this.nzAutocomplete.activeItem.select(false);
}
else {
this.nzAutocomplete.setActiveItem(this.nzAutocomplete.nzDefaultActiveFirstOption ? 0 : -1);
}
}
setValueAndClose(option) {
const value = option.nzValue;
this.setTriggerValue(option.getLabel());
this.onChange(value);
this.elementRef.nativeElement.focus();
this.closePanel();
}
setTriggerValue(value) {
const option = this.nzAutocomplete.getOption(value);
const displayValue = option ? option.getLabel() : value;
this.elementRef.nativeElement.value = displayValue != null ? displayValue : '';
if (!this.nzAutocomplete.nzBackfill) {
this.previousValue = displayValue;
}
}
doBackfill() {
if (this.nzAutocomplete.nzBackfill && this.nzAutocomplete.activeItem) {
this.setTriggerValue(this.nzAutocomplete.activeItem.getLabel());
}
}
canOpen() {
const element = this.elementRef.nativeElement;
return !element.readOnly && !element.disabled;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzAutocompleteTriggerDirective, isStandalone: true, selector: "input[nzAutocomplete], textarea[nzAutocomplete]", inputs: { nzAutocomplete: "nzAutocomplete" }, host: { attributes: { "autocomplete": "off", "aria-autocomplete": "list" }, listeners: { "focusin": "handleFocus()", "blur": "handleBlur()", "input": "handleInput($any($event))", "keydown": "handleKeydown($any($event))", "click": "handleClick()" } }, providers: [NZ_AUTOCOMPLETE_VALUE_ACCESSOR], exportAs: ["nzAutocompleteTrigger"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteTriggerDirective, decorators: [{
type: Directive,
args: [{
selector: `input[nzAutocomplete], textarea[nzAutocomplete]`,
exportAs: 'nzAutocompleteTrigger',
providers: [NZ_AUTOCOMPLETE_VALUE_ACCESSOR],
host: {
autocomplete: 'off',
'aria-autocomplete': 'list',
'(focusin)': 'handleFocus()',
'(blur)': 'handleBlur()',
'(input)': 'handleInput($any($event))',
'(keydown)': 'handleKeydown($any($event))',
'(click)': 'handleClick()'
}
}]
}], ctorParameters: () => [], propDecorators: { nzAutocomplete: [{
type: Input
}] } });
function normalizeDataSource(value) {
return value?.map(item => {
if (typeof item === 'number' || typeof item === 'string') {
return {
label: item.toString(),
value: item.toString()
};
}
return item;
});
}
class NzAutocompleteComponent {
changeDetectorRef = inject(ChangeDetectorRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
nzWidth;
nzOverlayClassName = '';
nzOverlayStyle = {};
nzDefaultActiveFirstOption = true;
nzBackfill = false;
compareWith = (o1, o2) => o1 === o2;
nzDataSource;
selectionChange = new EventEmitter();
showPanel = true;
isOpen = false;
activeItem = null;
dir = 'ltr';
normalizedDataSource = [];
animationStateChange = new EventEmitter();
/**
* Options accessor, its source may be content or dataSource
*/
get options() {
// first dataSource
if (this.nzDataSource) {
return this.fromDataSourceOptions;
}
else {
return this.fromContentOptions;
}
}
/** Provided by content */
fromContentOptions;
/** Provided by dataSource */
fromDataSourceOptions;
/** cdk-overlay */
template;
panel;
content;
activeItemIndex = -1;
selectionChangeSubscription = Subscription.EMPTY;
optionMouseEnterSubscription = Subscription.EMPTY;
dataSourceChangeSubscription = Subscription.EMPTY;
/** Options changes listener */
optionSelectionChanges = defer(() => {
if (this.options) {
return merge(...this.options.map(option => option.selectionChange));
}
return this.afterNextRender$.pipe(switchMap(() => this.optionSelectionChanges));
});
optionMouseEnter = defer(() => {
if (this.options) {
return merge(...this.options.map(option => option.mouseEntered));
}
return this.afterNextRender$.pipe(switchMap(() => this.optionMouseEnter));
});
afterNextRender$ = inject(NZ_AFTER_NEXT_RENDER$);
noAnimation = inject(NzNoAnimationDirective, { host: true, optional: true });
constructor() {
this.destroyRef.onDestroy(() => {
this.dataSourceChangeSubscription.unsubscribe();
this.selectionChangeSubscription.unsubscribe();
this.optionMouseEnterSubscription.unsubscribe();
// Caretaker note: we have to set these subscriptions to `null` since these will be closed subscriptions, but they
// still keep references to destinations (which are `SafeSubscriber`s). Destinations keep referencing `next` functions,
// which we pass, for instance, to `this.optionSelectionChanges.subscribe(...)`.
this.dataSourceChangeSubscription = this.selectionChangeSubscription = this.optionMouseEnterSubscription = null;
});
}
ngOnInit() {
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((direction) => {
this.dir = direction;
this.changeDetectorRef.detectChanges();
});
this.dir = this.directionality.value;
}
ngOnChanges(changes) {
const { nzDataSource } = changes;
if (nzDataSource) {
this.normalizedDataSource = normalizeDataSource(nzDataSource.currentValue);
}
}
onAnimationEvent(event) {
this.animationStateChange.emit(event);
}
ngAfterContentInit() {
if (!this.nzDataSource) {
this.optionsInit();
}
}
ngAfterViewInit() {
if (this.nzDataSource) {
this.optionsInit();
}
}
setVisibility() {
this.showPanel = !!this.options.length;
this.changeDetectorRef.markForCheck();
}
setActiveItem(index) {
const activeItem = this.options.get(index);
if (activeItem && !activeItem.active) {
this.activeItem = activeItem;
this.activeItemIndex = index;
this.clearSelectedOptions(this.activeItem);
this.activeItem.setActiveStyles();
}
else {
this.activeItem = null;
this.activeItemIndex = -1;
this.clearSelectedOptions();
}
this.changeDetectorRef.markForCheck();
}
setNextItemActive() {
const nextIndex = this.activeItemIndex + 1 <= this.options.length - 1 ? this.activeItemIndex + 1 : 0;
this.setActiveItem(nextIndex);
}
setPreviousItemActive() {
const previousIndex = this.activeItemIndex - 1 < 0 ? this.options.length - 1 : this.activeItemIndex - 1;
this.setActiveItem(previousIndex);
}
getOptionIndex(value) {
return this.options.reduce((result, current, index) => result === -1 ? (this.compareWith(value, current.nzValue) ? index : -1) : result, -1);
}
getOption(value) {
return this.options.find(item => this.compareWith(value, item.nzValue)) || null;
}
optionsInit() {
this.setVisibility();
this.subscribeOptionChanges();
const changes = this.nzDataSource ? this.fromDataSourceOptions.changes : this.fromContentOptions.changes;
// async
this.dataSourceChangeSubscription = changes.subscribe(e => {
if (!e.dirty && this.isOpen) {
setTimeout(() => this.setVisibility());
}
this.subscribeOptionChanges();
});
}
/**
* Clear the status of options
*/
clearSelectedOptions(skip, deselect = false) {
this.options.forEach(option => {
if (option !== skip) {
if (deselect) {
option.deselect();
}
option.setInactiveStyles();
}
});
}
subscribeOptionChanges() {
this.selectionChangeSubscription.unsubscribe();
this.selectionChangeSubscription = this.optionSelectionChanges
.pipe(filter((event) => event.isUserInput))
.subscribe((event) => {
event.source.select();
event.source.setActiveStyles();
this.activeItem = event.source;
this.activeItemIndex = this.getOptionIndex(this.activeItem.nzValue);
this.clearSelectedOptions(event.source, true);
this.selectionChange.emit(event.source);
});
this.optionMouseEnterSubscription.unsubscribe();
this.optionMouseEnterSubscription = this.optionMouseEnter.subscribe((event) => {
event.setActiveStyles();
this.activeItem = event;
this.activeItemIndex = this.getOptionIndex(this.activeItem.nzValue);
this.clearSelectedOptions(event);
});
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzAutocompleteComponent, isStandalone: true, selector: "nz-autocomplete", inputs: { nzWidth: ["nzWidth", "nzWidth", numberAttributeWithZeroFallback], nzOverlayClassName: "nzOverlayClassName", nzOverlayStyle: "nzOverlayStyle", nzDefaultActiveFirstOption: ["nzDefaultActiveFirstOption", "nzDefaultActiveFirstOption", booleanAttribute], nzBackfill: ["nzBackfill", "nzBackfill", booleanAttribute], compareWith: "compareWith", nzDataSource: "nzDataSource" }, outputs: { selectionChange: "selectionChange" }, queries: [{ propertyName: "fromContentOptions", predicate: NzAutocompleteOptionComponent, descendants: true }], viewQueries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }, { propertyName: "panel", first: true, predicate: ["panel"], descendants: true }, { propertyName: "content", first: true, predicate: ["content"], descendants: true }, { propertyName: "fromDataSourceOptions", predicate: NzAutocompleteOptionComponent, descendants: true }], exportAs: ["nzAutocomplete"], usesOnChanges: true, ngImport: i0, template: `
<ng-template>
<div
#panel
class="ant-select-dropdown ant-select-dropdown-placement-bottomLeft"
[class.ant-select-dropdown-hidden]="!showPanel"
[class.ant-select-dropdown-rtl]="dir === 'rtl'"
[class]="nzOverlayClassName"
[style]="nzOverlayStyle"
[nzNoAnimation]="noAnimation?.nzNoAnimation"
@slideMotion
(@slideMotion.done)="onAnimationEvent($event)"
[@.disabled]="!!noAnimation?.nzNoAnimation"
>
<div class="ant-select-dropdown-content-wrapper">
<div class="ant-select-dropdown-content">
<ng-template *ngTemplateOutlet="nzDataSource ? optionsTemplate : contentTemplate"></ng-template>
</div>
</div>
</div>
<ng-template #contentTemplate>
<ng-content></ng-content>
</ng-template>
<ng-template #optionsTemplate>
@for (option of normalizedDataSource; track option.value) {
<nz-auto-option [nzValue]="option.value" [nzLabel]="option.label">
{{ option.label }}
</nz-auto-option>
}
</ng-template>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: NzAutocompleteOptionComponent, selector: "nz-auto-option", inputs: ["nzValue", "nzLabel", "nzDisabled"], outputs: ["selectionChange", "mouseEntered"], exportAs: ["nzAutoOption"] }, { kind: "directive", type: NzNoAnimationDirective, selector: "[nzNoAnimation]", inputs: ["nzNoAnimation"], exportAs: ["nzNoAnimation"] }], animations: [slideMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-autocomplete',
exportAs: 'nzAutocomplete',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
imports: [NgTemplateOutlet, NzAutocompleteOptionComponent, NzNoAnimationDirective],
template: `
<ng-template>
<div
#panel
class="ant-select-dropdown ant-select-dropdown-placement-bottomLeft"
[class.ant-select-dropdown-hidden]="!showPanel"
[class.ant-select-dropdown-rtl]="dir === 'rtl'"
[class]="nzOverlayClassName"
[style]="nzOverlayStyle"
[nzNoAnimation]="noAnimation?.nzNoAnimation"
@slideMotion
(@slideMotion.done)="onAnimationEvent($event)"
[@.disabled]="!!noAnimation?.nzNoAnimation"
>
<div class="ant-select-dropdown-content-wrapper">
<div class="ant-select-dropdown-content">
<ng-template *ngTemplateOutlet="nzDataSource ? optionsTemplate : contentTemplate"></ng-template>
</div>
</div>
</div>
<ng-template #contentTemplate>
<ng-content></ng-content>
</ng-template>
<ng-template #optionsTemplate>
@for (option of normalizedDataSource; track option.value) {
<nz-auto-option [nzValue]="option.value" [nzLabel]="option.label">
{{ option.label }}
</nz-auto-option>
}
</ng-template>
</ng-template>
`,
animations: [slideMotion]
}]
}], ctorParameters: () => [], propDecorators: { nzWidth: [{
type: Input,
args: [{ transform: numberAttributeWithZeroFallback }]
}], nzOverlayClassName: [{
type: Input
}], nzOverlayStyle: [{
type: Input
}], nzDefaultActiveFirstOption: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzBackfill: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], compareWith: [{
type: Input
}], nzDataSource: [{
type: Input
}], selectionChange: [{
type: Output
}], fromContentOptions: [{
type: ContentChildren,
args: [NzAutocompleteOptionComponent, { descendants: true }]
}], fromDataSourceOptions: [{
type: ViewChildren,
args: [NzAutocompleteOptionComponent]
}], template: [{
type: ViewChild,
args: [TemplateRef, { static: false }]
}], panel: [{
type: ViewChild,
args: ['panel', { static: false }]
}], content: [{
type: ViewChild,
args: ['content', { 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 NzAutocompleteModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteModule, imports: [NzAutocompleteComponent,
NzAutocompleteOptionComponent,
NzAutocompleteTriggerDirective,
NzAutocompleteOptgroupComponent], exports: [NzAutocompleteComponent,
NzAutocompleteOptionComponent,
NzAutocompleteTriggerDirective,
NzAutocompleteOptgroupComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteModule, imports: [NzAutocompleteOptgroupComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAutocompleteModule, decorators: [{
type: NgModule,
args: [{
exports: [
NzAutocompleteComponent,
NzAutocompleteOptionComponent,
NzAutocompleteTriggerDirective,
NzAutocompleteOptgroupComponent
],
imports: [
NzAutocompleteComponent,
NzAutocompleteOptionComponent,
NzAutocompleteTriggerDirective,
NzAutocompleteOptgroupComponent
]
}]
}] });
/**
* 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_AUTOCOMPLETE_VALUE_ACCESSOR, NzAutocompleteComponent, NzAutocompleteModule, NzAutocompleteOptgroupComponent, NzAutocompleteOptionComponent, NzAutocompleteTriggerDirective, NzOptionSelectionChange, getNzAutocompleteMissingPanelError };
//# sourceMappingURL=ng-zorro-antd-auto-complete.mjs.map
File diff suppressed because one or more lines are too long
+235
View File
@@ -0,0 +1,235 @@
import { __esDecorate, __runInitializers } from 'tslib';
import * as i0 from '@angular/core';
import { input, EventEmitter, inject, ElementRef, ChangeDetectorRef, afterEveryRender, numberAttribute, ViewChild, Output, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { WithConfig } from 'ng-zorro-antd/core/config';
import { toCssPixel } from 'ng-zorro-antd/core/util';
import * as i1 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
const NZ_CONFIG_MODULE_NAME = 'avatar';
let NzAvatarComponent = (() => {
let _nzShape_decorators;
let _nzShape_initializers = [];
let _nzShape_extraInitializers = [];
let _nzSize_decorators;
let _nzSize_initializers = [];
let _nzSize_extraInitializers = [];
let _nzGap_decorators;
let _nzGap_initializers = [];
let _nzGap_extraInitializers = [];
return class NzAvatarComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzShape_decorators = [WithConfig()];
_nzSize_decorators = [WithConfig()];
_nzGap_decorators = [WithConfig()];
__esDecorate(null, null, _nzShape_decorators, { kind: "field", name: "nzShape", static: false, private: false, access: { has: obj => "nzShape" in obj, get: obj => obj.nzShape, set: (obj, value) => { obj.nzShape = value; } }, metadata: _metadata }, _nzShape_initializers, _nzShape_extraInitializers);
__esDecorate(null, null, _nzSize_decorators, { kind: "field", name: "nzSize", static: false, private: false, access: { has: obj => "nzSize" in obj, get: obj => obj.nzSize, set: (obj, value) => { obj.nzSize = value; } }, metadata: _metadata }, _nzSize_initializers, _nzSize_extraInitializers);
__esDecorate(null, null, _nzGap_decorators, { kind: "field", name: "nzGap", static: false, private: false, access: { has: obj => "nzGap" in obj, get: obj => obj.nzGap, set: (obj, value) => { obj.nzGap = value; } }, metadata: _metadata }, _nzGap_initializers, _nzGap_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
_nzModuleName = NZ_CONFIG_MODULE_NAME;
nzShape = __runInitializers(this, _nzShape_initializers, 'circle');
nzSize = (__runInitializers(this, _nzShape_extraInitializers), __runInitializers(this, _nzSize_initializers, 'default'));
nzGap = (__runInitializers(this, _nzSize_extraInitializers), __runInitializers(this, _nzGap_initializers, 4));
nzText = __runInitializers(this, _nzGap_extraInitializers);
nzSrc;
nzSrcSet;
nzAlt;
nzIcon;
nzLoading = input(...(ngDevMode ? [undefined, { debugName: "nzLoading" }] : []));
nzFetchPriority = input(...(ngDevMode ? [undefined, { debugName: "nzFetchPriority" }] : []));
nzError = new EventEmitter();
hasText = false;
hasSrc = true;
hasIcon = false;
customSize = null;
textEl;
el = inject(ElementRef).nativeElement;
cdr = inject(ChangeDetectorRef);
constructor() {
afterEveryRender(() => this.calcStringSize());
}
imgError(event) {
this.nzError.emit(event);
if (!event.defaultPrevented) {
this.hasSrc = false;
this.hasIcon = false;
this.hasText = false;
if (this.nzIcon) {
this.hasIcon = true;
}
else if (this.nzText) {
this.hasText = true;
}
this.cdr.detectChanges();
this.setSizeStyle();
this.calcStringSize();
}
}
ngOnChanges() {
this.hasText = !this.nzSrc && !!this.nzText;
this.hasIcon = !this.nzSrc && !!this.nzIcon;
this.hasSrc = !!this.nzSrc;
this.setSizeStyle();
this.calcStringSize();
}
calcStringSize() {
if (!this.hasText || !this.textEl) {
return;
}
const textEl = this.textEl.nativeElement;
const childrenWidth = textEl.offsetWidth;
const avatarWidth = this.el.getBoundingClientRect?.().width ?? 0;
const offset = this.nzGap * 2 < avatarWidth ? this.nzGap * 2 : 8;
const scale = avatarWidth - offset < childrenWidth ? (avatarWidth - offset) / childrenWidth : 1;
textEl.style.transform = `scale(${scale}) translateX(-50%)`;
textEl.style.lineHeight = this.customSize || '';
}
setSizeStyle() {
if (typeof this.nzSize === 'number') {
this.customSize = toCssPixel(this.nzSize);
}
else {
this.customSize = null;
}
this.cdr.markForCheck();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzAvatarComponent, isStandalone: true, selector: "nz-avatar", inputs: { nzShape: { classPropertyName: "nzShape", publicName: "nzShape", isSignal: false, isRequired: false, transformFunction: null }, nzSize: { classPropertyName: "nzSize", publicName: "nzSize", isSignal: false, isRequired: false, transformFunction: null }, nzGap: { classPropertyName: "nzGap", publicName: "nzGap", isSignal: false, isRequired: false, transformFunction: numberAttribute }, nzText: { classPropertyName: "nzText", publicName: "nzText", isSignal: false, isRequired: false, transformFunction: null }, nzSrc: { classPropertyName: "nzSrc", publicName: "nzSrc", isSignal: false, isRequired: false, transformFunction: null }, nzSrcSet: { classPropertyName: "nzSrcSet", publicName: "nzSrcSet", isSignal: false, isRequired: false, transformFunction: null }, nzAlt: { classPropertyName: "nzAlt", publicName: "nzAlt", isSignal: false, isRequired: false, transformFunction: null }, nzIcon: { classPropertyName: "nzIcon", publicName: "nzIcon", isSignal: false, isRequired: false, transformFunction: null }, nzLoading: { classPropertyName: "nzLoading", publicName: "nzLoading", isSignal: true, isRequired: false, transformFunction: null }, nzFetchPriority: { classPropertyName: "nzFetchPriority", publicName: "nzFetchPriority", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nzError: "nzError" }, host: { properties: { "class.ant-avatar-lg": "nzSize === 'large'", "class.ant-avatar-sm": "nzSize === 'small'", "class.ant-avatar-square": "nzShape === 'square'", "class.ant-avatar-circle": "nzShape === 'circle'", "class.ant-avatar-icon": "nzIcon", "class.ant-avatar-image": "hasSrc ", "style.width": "customSize", "style.height": "customSize", "style.line-height": "customSize", "style.font-size.px": "(hasIcon && customSize) ? $any(nzSize) / 2 : null" }, classAttribute: "ant-avatar" }, viewQueries: [{ propertyName: "textEl", first: true, predicate: ["textEl"], descendants: true }], exportAs: ["nzAvatar"], usesOnChanges: true, ngImport: i0, template: `
@if (nzIcon && hasIcon) {
<nz-icon [nzType]="nzIcon" />
} @else if (nzSrc && hasSrc) {
<img
[src]="nzSrc"
[attr.srcset]="nzSrcSet"
[attr.alt]="nzAlt"
[attr.loading]="nzLoading() || 'eager'"
[attr.fetchpriority]="nzFetchPriority() || 'auto'"
(error)="imgError($event)"
/>
} @else if (nzText && hasText) {
<span class="ant-avatar-string" #textEl>{{ nzText }}</span>
}
<ng-content></ng-content>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1.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: "20.3.0", ngImport: i0, type: NzAvatarComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-avatar',
exportAs: 'nzAvatar',
imports: [NzIconModule],
template: `
@if (nzIcon && hasIcon) {
<nz-icon [nzType]="nzIcon" />
} @else if (nzSrc && hasSrc) {
<img
[src]="nzSrc"
[attr.srcset]="nzSrcSet"
[attr.alt]="nzAlt"
[attr.loading]="nzLoading() || 'eager'"
[attr.fetchpriority]="nzFetchPriority() || 'auto'"
(error)="imgError($event)"
/>
} @else if (nzText && hasText) {
<span class="ant-avatar-string" #textEl>{{ nzText }}</span>
}
<ng-content></ng-content>
`,
host: {
class: 'ant-avatar',
'[class.ant-avatar-lg]': `nzSize === 'large'`,
'[class.ant-avatar-sm]': `nzSize === 'small'`,
'[class.ant-avatar-square]': `nzShape === 'square'`,
'[class.ant-avatar-circle]': `nzShape === 'circle'`,
'[class.ant-avatar-icon]': `nzIcon`,
'[class.ant-avatar-image]': `hasSrc `,
'[style.width]': 'customSize',
'[style.height]': 'customSize',
'[style.line-height]': 'customSize',
// nzSize type is number when customSize is true
'[style.font-size.px]': '(hasIcon && customSize) ? $any(nzSize) / 2 : null'
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
}]
}], ctorParameters: () => [], propDecorators: { nzShape: [{
type: Input
}], nzSize: [{
type: Input
}], nzGap: [{
type: Input,
args: [{ transform: numberAttribute }]
}], nzText: [{
type: Input
}], nzSrc: [{
type: Input
}], nzSrcSet: [{
type: Input
}], nzAlt: [{
type: Input
}], nzIcon: [{
type: Input
}], nzError: [{
type: Output
}], textEl: [{
type: ViewChild,
args: ['textEl', { 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 NzAvatarGroupComponent {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAvatarGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzAvatarGroupComponent, isStandalone: true, selector: "nz-avatar-group", host: { classAttribute: "ant-avatar-group" }, exportAs: ["nzAvatarGroup"], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAvatarGroupComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-avatar-group',
exportAs: 'nzAvatarGroup',
template: `<ng-content></ng-content>`,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'ant-avatar-group'
}
}]
}] });
/**
* 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 NzAvatarModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAvatarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzAvatarModule, imports: [NzAvatarComponent, NzAvatarGroupComponent], exports: [NzAvatarComponent, NzAvatarGroupComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAvatarModule, imports: [NzAvatarComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzAvatarModule, decorators: [{
type: NgModule,
args: [{
exports: [NzAvatarComponent, NzAvatarGroupComponent],
imports: [NzAvatarComponent, NzAvatarGroupComponent]
}]
}] });
/**
* 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
*/
/**
* 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 { NzAvatarComponent, NzAvatarGroupComponent, NzAvatarModule };
//# sourceMappingURL=ng-zorro-antd-avatar.mjs.map
File diff suppressed because one or more lines are too long
+194
View File
@@ -0,0 +1,194 @@
import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality } from '@angular/cdk/bidi';
import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';
import { NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { inject, NgZone, ChangeDetectorRef, DestroyRef, EventEmitter, DOCUMENT, numberAttribute, ViewChild, Output, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Subject, Subscription } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { fadeMotion } from 'ng-zorro-antd/core/animation';
import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
import { NzScrollService } from 'ng-zorro-antd/core/services';
import { fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
import * as i1 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
const NZ_CONFIG_MODULE_NAME = 'backTop';
const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
/**
* @deprecated Will be removed in v21. It is recommended to use `<nz-float-button-top>` instead.
*/
let NzBackTopComponent = (() => {
let _nzVisibilityHeight_decorators;
let _nzVisibilityHeight_initializers = [];
let _nzVisibilityHeight_extraInitializers = [];
return class NzBackTopComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzVisibilityHeight_decorators = [WithConfig()];
__esDecorate(null, null, _nzVisibilityHeight_decorators, { kind: "field", name: "nzVisibilityHeight", static: false, private: false, access: { has: obj => "nzVisibilityHeight" in obj, get: obj => obj.nzVisibilityHeight, set: (obj, value) => { obj.nzVisibilityHeight = value; } }, metadata: _metadata }, _nzVisibilityHeight_initializers, _nzVisibilityHeight_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
nzConfigService = inject(NzConfigService);
scrollSrv = inject(NzScrollService);
platform = inject(Platform);
zone = inject(NgZone);
cdr = inject(ChangeDetectorRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
scrollListenerDestroy$ = new Subject();
target = null;
visible = false;
dir = this.directionality.value || 'ltr';
nzTemplate;
nzVisibilityHeight = __runInitializers(this, _nzVisibilityHeight_initializers, 400);
nzTarget = __runInitializers(this, _nzVisibilityHeight_extraInitializers);
nzDuration = 450;
nzClick = new EventEmitter();
set backTop(backTop) {
if (backTop) {
this.backTopClickSubscription.unsubscribe();
this.backTopClickSubscription = fromEventOutsideAngular(backTop.nativeElement, 'click')
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.scrollSrv.scrollTo(this.getTarget(), 0, { duration: this.nzDuration });
if (this.nzClick.observers.length) {
this.zone.run(() => this.nzClick.emit(true));
}
});
}
}
backTopClickSubscription = Subscription.EMPTY;
doc = inject(DOCUMENT);
constructor() {
this.destroyRef.onDestroy(() => {
this.scrollListenerDestroy$.next(true);
this.scrollListenerDestroy$.complete();
});
}
ngOnInit() {
this.registerScrollEvent();
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((direction) => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
}
getTarget() {
return this.target || window;
}
handleScroll() {
const newVisible = this.scrollSrv.getScroll(this.getTarget()) > this.nzVisibilityHeight;
if (this.visible !== newVisible) {
this.visible = newVisible;
this.cdr.detectChanges();
}
}
registerScrollEvent() {
if (!this.platform.isBrowser) {
return;
}
this.scrollListenerDestroy$.next(true);
this.handleScroll();
fromEventOutsideAngular(this.getTarget(), 'scroll', passiveEventListenerOptions)
.pipe(debounceTime(50), takeUntil(this.scrollListenerDestroy$))
.subscribe(() => this.handleScroll());
}
ngOnChanges(changes) {
const { nzTarget } = changes;
if (nzTarget) {
this.target = typeof this.nzTarget === 'string' ? this.doc.querySelector(this.nzTarget) : this.nzTarget;
this.registerScrollEvent();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBackTopComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzBackTopComponent, isStandalone: true, selector: "nz-back-top", inputs: { nzTemplate: "nzTemplate", nzVisibilityHeight: ["nzVisibilityHeight", "nzVisibilityHeight", numberAttribute], nzTarget: "nzTarget", nzDuration: ["nzDuration", "nzDuration", numberAttribute] }, outputs: { nzClick: "nzClick" }, viewQueries: [{ propertyName: "backTop", first: true, predicate: ["backTop"], descendants: true }], exportAs: ["nzBackTop"], usesOnChanges: true, ngImport: i0, template: `
@if (visible) {
<div #backTop class="ant-back-top" [class.ant-back-top-rtl]="dir === 'rtl'" @fadeMotion>
<ng-template #defaultContent>
<div class="ant-back-top-content">
<div class="ant-back-top-icon">
<nz-icon nzType="vertical-align-top" />
</div>
</div>
</ng-template>
<ng-template [ngTemplateOutlet]="nzTemplate || defaultContent"></ng-template>
</div>
}
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }], animations: [fadeMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBackTopComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-back-top',
exportAs: 'nzBackTop',
animations: [fadeMotion],
imports: [NgTemplateOutlet, NzIconModule],
template: `
@if (visible) {
<div #backTop class="ant-back-top" [class.ant-back-top-rtl]="dir === 'rtl'" @fadeMotion>
<ng-template #defaultContent>
<div class="ant-back-top-content">
<div class="ant-back-top-icon">
<nz-icon nzType="vertical-align-top" />
</div>
</div>
</ng-template>
<ng-template [ngTemplateOutlet]="nzTemplate || defaultContent"></ng-template>
</div>
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
}]
}], ctorParameters: () => [], propDecorators: { nzTemplate: [{
type: Input
}], nzVisibilityHeight: [{
type: Input,
args: [{ transform: numberAttribute }]
}], nzTarget: [{
type: Input
}], nzDuration: [{
type: Input,
args: [{ transform: numberAttribute }]
}], nzClick: [{
type: Output
}], backTop: [{
type: ViewChild,
args: ['backTop', { 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
*/
/**
* @deprecated Will be removed in v21. It is recommended to use `<nz-float-button-top>` instead.
*/
class NzBackTopModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBackTopModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzBackTopModule, imports: [NzBackTopComponent], exports: [NzBackTopComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBackTopModule, imports: [NzBackTopComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBackTopModule, decorators: [{
type: NgModule,
args: [{
exports: [NzBackTopComponent],
imports: [NzBackTopComponent]
}]
}] });
/**
* 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 { NzBackTopComponent, NzBackTopModule };
//# sourceMappingURL=ng-zorro-antd-back-top.mjs.map
File diff suppressed because one or more lines are too long
+424
View File
@@ -0,0 +1,424 @@
import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality } from '@angular/cdk/bidi';
import * as i0 from '@angular/core';
import { booleanAttribute, numberAttribute, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, inject, NgModule } from '@angular/core';
import { zoomBadgeMotion } from 'ng-zorro-antd/core/animation';
import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
/**
* 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 NzBadgeSupComponent {
nzOffset;
nzTitle;
nzStyle = null;
nzDot = false;
nzOverflowCount = 99;
disableAnimation = false;
nzCount;
noAnimation = false;
nzSize = 'default';
isPresetColor = false;
nzColor;
maxNumberArray = [];
countArray = [];
count = 0;
countSingleArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
generateMaxNumberArray() {
this.maxNumberArray = this.nzOverflowCount
.toString()
.split('')
.map((value, index) => `${value}-${index}`);
}
ngOnInit() {
this.generateMaxNumberArray();
}
ngOnChanges(changes) {
const { nzOverflowCount, nzCount } = changes;
if (nzCount && typeof nzCount.currentValue === 'number') {
this.count = Math.max(0, nzCount.currentValue);
this.countArray = this.count
.toString()
.split('')
.map(item => +item);
}
if (nzOverflowCount) {
this.generateMaxNumberArray();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBadgeSupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzBadgeSupComponent, isStandalone: true, selector: "nz-badge-sup", inputs: { nzOffset: "nzOffset", nzTitle: "nzTitle", nzStyle: "nzStyle", nzDot: "nzDot", nzOverflowCount: ["nzOverflowCount", "nzOverflowCount", numberAttribute], disableAnimation: "disableAnimation", nzCount: "nzCount", noAnimation: "noAnimation", nzSize: "nzSize", isPresetColor: ["isPresetColor", "isPresetColor", booleanAttribute], nzColor: "nzColor" }, host: { properties: { "class": "isPresetColor ? ('ant-badge-status-' + nzColor) : ''", "@.disabled": "disableAnimation", "@zoomBadgeMotion": "", "attr.title": "nzTitle === null ? '' : nzTitle || nzCount", "style": "nzStyle", "style.right.px": "nzOffset && nzOffset[0] ? -nzOffset[0] : null", "style.margin-top.px": "nzOffset && nzOffset[1] ? nzOffset[1] : null", "class.ant-badge-count": "!nzDot", "class.ant-badge-count-sm": "nzSize === 'small'", "class.ant-badge-dot": "nzDot", "class.ant-badge-multiple-words": "countArray.length >= 2" }, classAttribute: "ant-scroll-number" }, exportAs: ["nzBadgeSup"], usesOnChanges: true, ngImport: i0, template: `
@if (count <= nzOverflowCount) {
@for (n of maxNumberArray; track n; let i = $index) {
<span
[nzNoAnimation]="noAnimation"
class="ant-scroll-number-only"
[style.transform]="'translateY(' + -countArray[i] * 100 + '%)'"
>
@if (!nzDot && countArray[i] !== undefined) {
@for (p of countSingleArray; track p) {
<p class="ant-scroll-number-only-unit" [class.current]="p === countArray[i]">
{{ p }}
</p>
}
}
</span>
}
} @else {
{{ nzOverflowCount }}+
}
`, isInline: true, dependencies: [{ kind: "directive", type: NzNoAnimationDirective, selector: "[nzNoAnimation]", inputs: ["nzNoAnimation"], exportAs: ["nzNoAnimation"] }], animations: [zoomBadgeMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBadgeSupComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-badge-sup',
exportAs: 'nzBadgeSup',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [zoomBadgeMotion],
imports: [NzNoAnimationDirective],
template: `
@if (count <= nzOverflowCount) {
@for (n of maxNumberArray; track n; let i = $index) {
<span
[nzNoAnimation]="noAnimation"
class="ant-scroll-number-only"
[style.transform]="'translateY(' + -countArray[i] * 100 + '%)'"
>
@if (!nzDot && countArray[i] !== undefined) {
@for (p of countSingleArray; track p) {
<p class="ant-scroll-number-only-unit" [class.current]="p === countArray[i]">
{{ p }}
</p>
}
}
</span>
}
} @else {
{{ nzOverflowCount }}+
}
`,
host: {
class: 'ant-scroll-number',
'[class]': `isPresetColor ? ('ant-badge-status-' + nzColor) : ''`,
'[@.disabled]': `disableAnimation`,
'[@zoomBadgeMotion]': '',
'[attr.title]': `nzTitle === null ? '' : nzTitle || nzCount`,
'[style]': `nzStyle`,
'[style.right.px]': `nzOffset && nzOffset[0] ? -nzOffset[0] : null`,
'[style.margin-top.px]': `nzOffset && nzOffset[1] ? nzOffset[1] : null`,
'[class.ant-badge-count]': `!nzDot`,
'[class.ant-badge-count-sm]': `nzSize === 'small'`,
'[class.ant-badge-dot]': `nzDot`,
'[class.ant-badge-multiple-words]': `countArray.length >= 2`
}
}]
}], propDecorators: { nzOffset: [{
type: Input
}], nzTitle: [{
type: Input
}], nzStyle: [{
type: Input
}], nzDot: [{
type: Input
}], nzOverflowCount: [{
type: Input,
args: [{ transform: numberAttribute }]
}], disableAnimation: [{
type: Input
}], nzCount: [{
type: Input
}], noAnimation: [{
type: Input
}], nzSize: [{
type: Input
}], isPresetColor: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzColor: [{
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
*/
const badgePresetColors = [
'pink',
'red',
'yellow',
'orange',
'cyan',
'green',
'blue',
'purple',
'geekblue',
'magenta',
'volcano',
'gold',
'lime'
];
const NZ_CONFIG_MODULE_NAME = 'badge';
let NzBadgeComponent = (() => {
let _nzOverflowCount_decorators;
let _nzOverflowCount_initializers = [];
let _nzOverflowCount_extraInitializers = [];
let _nzColor_decorators;
let _nzColor_initializers = [];
let _nzColor_extraInitializers = [];
return class NzBadgeComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzOverflowCount_decorators = [WithConfig()];
_nzColor_decorators = [WithConfig()];
__esDecorate(null, null, _nzOverflowCount_decorators, { kind: "field", name: "nzOverflowCount", static: false, private: false, access: { has: obj => "nzOverflowCount" in obj, get: obj => obj.nzOverflowCount, set: (obj, value) => { obj.nzOverflowCount = value; } }, metadata: _metadata }, _nzOverflowCount_initializers, _nzOverflowCount_extraInitializers);
__esDecorate(null, null, _nzColor_decorators, { kind: "field", name: "nzColor", static: false, private: false, access: { has: obj => "nzColor" in obj, get: obj => obj.nzColor, set: (obj, value) => { obj.nzColor = value; } }, metadata: _metadata }, _nzColor_initializers, _nzColor_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
nzConfigService = inject(NzConfigService);
dir = inject(Directionality).valueSignal;
noAnimation = inject(NzNoAnimationDirective, { host: true, optional: true });
_nzModuleName = NZ_CONFIG_MODULE_NAME;
showSup = false;
presetColor = null;
nzShowZero = false;
nzShowDot = true;
nzStandalone = false;
nzDot = false;
nzOverflowCount = __runInitializers(this, _nzOverflowCount_initializers, 99);
nzColor = (__runInitializers(this, _nzOverflowCount_extraInitializers), __runInitializers(this, _nzColor_initializers, void 0));
nzStyle = (__runInitializers(this, _nzColor_extraInitializers), null);
nzText = null;
nzTitle;
nzStatus;
nzCount;
nzOffset;
nzSize = 'default';
get mergedStyle() {
return { backgroundColor: !this.presetColor && this.nzColor, ...(this.nzStyle ?? {}) };
}
ngOnChanges(changes) {
const { nzColor, nzShowDot, nzDot, nzCount, nzShowZero } = changes;
if (nzColor) {
this.presetColor = this.nzColor && badgePresetColors.indexOf(this.nzColor) !== -1 ? this.nzColor : null;
}
if (nzShowDot || nzDot || nzCount || nzShowZero) {
this.showSup =
(this.nzShowDot && this.nzDot) || (typeof this.nzCount === 'number' && (this.nzCount > 0 || this.nzShowZero));
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBadgeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzBadgeComponent, isStandalone: true, selector: "nz-badge", inputs: { nzShowZero: ["nzShowZero", "nzShowZero", booleanAttribute], nzShowDot: ["nzShowDot", "nzShowDot", booleanAttribute], nzStandalone: ["nzStandalone", "nzStandalone", booleanAttribute], nzDot: ["nzDot", "nzDot", booleanAttribute], nzOverflowCount: "nzOverflowCount", nzColor: "nzColor", nzStyle: "nzStyle", nzText: "nzText", nzTitle: "nzTitle", nzStatus: "nzStatus", nzCount: "nzCount", nzOffset: "nzOffset", nzSize: "nzSize" }, host: { properties: { "class.ant-badge-status": "nzStatus", "class.ant-badge-not-a-wrapper": "!!(nzStandalone || ((nzStatus || nzColor) && !showSup && !nzCount))", "class.ant-badge-rtl": "dir() === \"rtl\"" }, classAttribute: "ant-badge" }, exportAs: ["nzBadge"], usesOnChanges: true, ngImport: i0, template: `
@if ((nzStatus || nzColor) && !showSup && !nzCount) {
<span
class="ant-badge-status-dot"
[class]="(nzStatus || presetColor) && 'ant-badge-status-' + (nzStatus || presetColor)"
[style]="mergedStyle"
></span>
<span class="ant-badge-status-text">
<ng-container *nzStringTemplateOutlet="nzText">{{ nzText }}</ng-container>
</span>
}
<ng-content />
<ng-container *nzStringTemplateOutlet="nzCount">
@if (showSup) {
<nz-badge-sup
[isPresetColor]="nzStatus || presetColor"
[nzColor]="nzStatus || presetColor || nzColor"
[nzOffset]="nzOffset"
[nzSize]="nzSize"
[nzTitle]="nzTitle"
[nzStyle]="nzStyle"
[nzDot]="nzDot"
[nzCount]="nzCount"
[nzOverflowCount]="nzOverflowCount"
[disableAnimation]="!!(nzStandalone || nzStatus || nzColor || noAnimation?.nzNoAnimation)"
[noAnimation]="!!noAnimation?.nzNoAnimation"
/>
}
</ng-container>
`, isInline: true, dependencies: [{ kind: "component", type: NzBadgeSupComponent, selector: "nz-badge-sup", inputs: ["nzOffset", "nzTitle", "nzStyle", "nzDot", "nzOverflowCount", "disableAnimation", "nzCount", "noAnimation", "nzSize", "isPresetColor", "nzColor"], exportAs: ["nzBadgeSup"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], animations: [zoomBadgeMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBadgeComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-badge',
exportAs: 'nzBadge',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [zoomBadgeMotion],
imports: [NzBadgeSupComponent, NzOutletModule],
template: `
@if ((nzStatus || nzColor) && !showSup && !nzCount) {
<span
class="ant-badge-status-dot"
[class]="(nzStatus || presetColor) && 'ant-badge-status-' + (nzStatus || presetColor)"
[style]="mergedStyle"
></span>
<span class="ant-badge-status-text">
<ng-container *nzStringTemplateOutlet="nzText">{{ nzText }}</ng-container>
</span>
}
<ng-content />
<ng-container *nzStringTemplateOutlet="nzCount">
@if (showSup) {
<nz-badge-sup
[isPresetColor]="nzStatus || presetColor"
[nzColor]="nzStatus || presetColor || nzColor"
[nzOffset]="nzOffset"
[nzSize]="nzSize"
[nzTitle]="nzTitle"
[nzStyle]="nzStyle"
[nzDot]="nzDot"
[nzCount]="nzCount"
[nzOverflowCount]="nzOverflowCount"
[disableAnimation]="!!(nzStandalone || nzStatus || nzColor || noAnimation?.nzNoAnimation)"
[noAnimation]="!!noAnimation?.nzNoAnimation"
/>
}
</ng-container>
`,
host: {
class: 'ant-badge',
'[class.ant-badge-status]': 'nzStatus',
'[class.ant-badge-not-a-wrapper]': '!!(nzStandalone || ((nzStatus || nzColor) && !showSup && !nzCount))',
'[class.ant-badge-rtl]': 'dir() === "rtl"'
}
}]
}], propDecorators: { nzShowZero: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzShowDot: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzStandalone: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzDot: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzOverflowCount: [{
type: Input
}], nzColor: [{
type: Input
}], nzStyle: [{
type: Input
}], nzText: [{
type: Input
}], nzTitle: [{
type: Input
}], nzStatus: [{
type: Input
}], nzCount: [{
type: Input
}], nzOffset: [{
type: Input
}], nzSize: [{
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 NzRibbonComponent {
nzColor;
nzPlacement = 'end';
nzText = null;
presetColor = null;
ngOnChanges(changes) {
const { nzColor } = changes;
if (nzColor) {
this.presetColor = this.nzColor && badgePresetColors.indexOf(this.nzColor) !== -1 ? this.nzColor : null;
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzRibbonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzRibbonComponent, isStandalone: true, selector: "nz-ribbon", inputs: { nzColor: "nzColor", nzPlacement: "nzPlacement", nzText: "nzText" }, host: { classAttribute: "ant-ribbon-wrapper" }, exportAs: ["nzRibbon"], usesOnChanges: true, ngImport: i0, template: `
<ng-content />
<div
class="ant-ribbon"
[class]="presetColor && 'ant-ribbon-color-' + presetColor"
[class.ant-ribbon-placement-end]="nzPlacement === 'end'"
[class.ant-ribbon-placement-start]="nzPlacement === 'start'"
[style.background-color]="!presetColor && nzColor"
>
<ng-container *nzStringTemplateOutlet="nzText">
<span class="ant-ribbon-text">{{ nzText }}</span>
</ng-container>
<div class="ant-ribbon-corner" [style.color]="!presetColor && nzColor"></div>
</div>
`, 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: "20.3.0", ngImport: i0, type: NzRibbonComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-ribbon',
exportAs: 'nzRibbon',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NzOutletModule],
template: `
<ng-content />
<div
class="ant-ribbon"
[class]="presetColor && 'ant-ribbon-color-' + presetColor"
[class.ant-ribbon-placement-end]="nzPlacement === 'end'"
[class.ant-ribbon-placement-start]="nzPlacement === 'start'"
[style.background-color]="!presetColor && nzColor"
>
<ng-container *nzStringTemplateOutlet="nzText">
<span class="ant-ribbon-text">{{ nzText }}</span>
</ng-container>
<div class="ant-ribbon-corner" [style.color]="!presetColor && nzColor"></div>
</div>
`,
host: { class: 'ant-ribbon-wrapper' }
}]
}], propDecorators: { nzColor: [{
type: Input
}], nzPlacement: [{
type: Input
}], nzText: [{
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 NzBadgeModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBadgeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzBadgeModule, imports: [NzBadgeComponent, NzRibbonComponent], exports: [NzBadgeComponent, NzRibbonComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBadgeModule, imports: [NzBadgeComponent, NzRibbonComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBadgeModule, decorators: [{
type: NgModule,
args: [{
exports: [NzBadgeComponent, NzRibbonComponent],
imports: [NzBadgeComponent, NzRibbonComponent]
}]
}] });
/**
* 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
*/
/**
* 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 { NzBadgeComponent, NzBadgeModule, NzRibbonComponent };
//# sourceMappingURL=ng-zorro-antd-badge.mjs.map
File diff suppressed because one or more lines are too long
+285
View File
@@ -0,0 +1,285 @@
import { NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { Component, inject, Input, ViewEncapsulation, ChangeDetectionStrategy, Injector, ChangeDetectorRef, ElementRef, Renderer2, DestroyRef, forwardRef, booleanAttribute, NgModule } from '@angular/core';
import * as i3 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import * as i1 from 'ng-zorro-antd/dropdown';
import { NzDropDownModule } from 'ng-zorro-antd/dropdown';
import * as i2 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { Directionality } from '@angular/cdk/bidi';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Router, ActivatedRoute, NavigationEnd, PRIMARY_OUTLET } from '@angular/router';
import { filter, startWith } from 'rxjs/operators';
import { PREFIX } from 'ng-zorro-antd/core/logger';
/**
* 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
*/
/**
* https://angular.io/errors/NG3003
* An intermediate interface for {@link NzBreadCrumbComponent} & {@link NzBreadCrumbItemComponent}
*/
class NzBreadcrumb {
}
/**
* 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 NzBreadCrumbSeparatorComponent {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbSeparatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzBreadCrumbSeparatorComponent, isStandalone: true, selector: "nz-breadcrumb-separator", host: { classAttribute: "ant-breadcrumb-separator" }, exportAs: ["nzBreadcrumbSeparator"], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbSeparatorComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-breadcrumb-separator',
exportAs: 'nzBreadcrumbSeparator',
template: `<ng-content></ng-content>`,
host: {
class: 'ant-breadcrumb-separator'
}
}]
}] });
/**
* 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 NzBreadCrumbItemComponent {
nzBreadCrumbComponent = inject(NzBreadcrumb);
/**
* Dropdown content of a breadcrumb item.
*/
nzOverlay;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzBreadCrumbItemComponent, isStandalone: true, selector: "nz-breadcrumb-item", inputs: { nzOverlay: "nzOverlay" }, exportAs: ["nzBreadcrumbItem"], ngImport: i0, template: `
@if (!!nzOverlay) {
<span class="ant-breadcrumb-overlay-link" nz-dropdown [nzDropdownMenu]="nzOverlay">
<ng-template [ngTemplateOutlet]="noMenuTpl"></ng-template>
<nz-icon nzType="down" />
</span>
} @else {
<ng-template [ngTemplateOutlet]="noMenuTpl" />
}
@if (nzBreadCrumbComponent.nzSeparator) {
<nz-breadcrumb-separator>
<ng-container *nzStringTemplateOutlet="nzBreadCrumbComponent.nzSeparator">
{{ nzBreadCrumbComponent.nzSeparator }}
</ng-container>
</nz-breadcrumb-separator>
}
<ng-template #noMenuTpl>
<span class="ant-breadcrumb-link">
<ng-content />
</span>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: NzBreadCrumbSeparatorComponent, selector: "nz-breadcrumb-separator", exportAs: ["nzBreadcrumbSeparator"] }, { kind: "ngmodule", type: NzDropDownModule }, { kind: "directive", type: i1.NzDropDownDirective, selector: "[nz-dropdown]", inputs: ["nzDropdownMenu", "nzTrigger", "nzMatchWidthElement", "nzBackdrop", "nzClickHide", "nzDisabled", "nzVisible", "nzArrow", "nzOverlayClassName", "nzOverlayStyle", "nzPlacement"], outputs: ["nzVisibleChange"], exportAs: ["nzDropdown"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbItemComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-breadcrumb-item',
exportAs: 'nzBreadcrumbItem',
imports: [NgTemplateOutlet, NzBreadCrumbSeparatorComponent, NzDropDownModule, NzIconModule, NzOutletModule],
template: `
@if (!!nzOverlay) {
<span class="ant-breadcrumb-overlay-link" nz-dropdown [nzDropdownMenu]="nzOverlay">
<ng-template [ngTemplateOutlet]="noMenuTpl"></ng-template>
<nz-icon nzType="down" />
</span>
} @else {
<ng-template [ngTemplateOutlet]="noMenuTpl" />
}
@if (nzBreadCrumbComponent.nzSeparator) {
<nz-breadcrumb-separator>
<ng-container *nzStringTemplateOutlet="nzBreadCrumbComponent.nzSeparator">
{{ nzBreadCrumbComponent.nzSeparator }}
</ng-container>
</nz-breadcrumb-separator>
}
<ng-template #noMenuTpl>
<span class="ant-breadcrumb-link">
<ng-content />
</span>
</ng-template>
`
}]
}], propDecorators: { nzOverlay: [{
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 NzBreadCrumbComponent {
injector = inject(Injector);
cdr = inject(ChangeDetectorRef);
elementRef = inject((ElementRef));
renderer = inject(Renderer2);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
nzAutoGenerate = false;
nzSeparator = '/';
nzRouteLabel = 'breadcrumb';
nzRouteLabelFn = label => label;
nzRouteFn = route => route;
breadcrumbs = [];
dir = 'ltr';
ngOnInit() {
if (this.nzAutoGenerate) {
this.registerRouterChange();
}
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((direction) => {
this.dir = direction;
this.prepareComponentForRtl();
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
this.prepareComponentForRtl();
}
navigate(url, e) {
e.preventDefault();
this.injector.get(Router).navigateByUrl(url);
}
registerRouterChange() {
try {
const router = this.injector.get(Router);
const activatedRoute = this.injector.get(ActivatedRoute);
router.events
.pipe(filter(e => e instanceof NavigationEnd), takeUntilDestroyed(this.destroyRef), startWith(true) // trigger initial render
)
.subscribe(() => {
this.breadcrumbs = this.getBreadcrumbs(activatedRoute.root);
this.cdr.markForCheck();
});
}
catch {
throw new Error(`${PREFIX} You should import RouterModule if you want to use 'NzAutoGenerate'.`);
}
}
getBreadcrumbs(route, url = '', breadcrumbs = []) {
const children = route.children;
// If there's no sub root, then stop the recurse and returns the generated breadcrumbs.
if (children.length === 0) {
return breadcrumbs;
}
for (const child of children) {
if (child.outlet === PRIMARY_OUTLET) {
// Only parse components in primary router-outlet (in another word, router-outlet without a specific name).
// Parse this layer and generate a breadcrumb item.
const routeUrl = child.snapshot.url
.map(segment => segment.path)
.filter(path => path)
.join('/');
// Do not change nextUrl if routeUrl is falsy. This happens when it's a route lazy loading other modules.
const nextUrl = routeUrl ? `${url}/${routeUrl}` : url;
const breadcrumbLabel = this.nzRouteLabelFn(child.snapshot.data[this.nzRouteLabel]);
const shapedUrl = this.nzRouteFn(nextUrl);
// If have data, go to generate a breadcrumb for it.
if (routeUrl && breadcrumbLabel) {
const breadcrumb = {
label: breadcrumbLabel,
params: child.snapshot.params,
url: shapedUrl
};
breadcrumbs.push(breadcrumb);
}
return this.getBreadcrumbs(child, nextUrl, breadcrumbs);
}
}
return breadcrumbs;
}
prepareComponentForRtl() {
if (this.dir === 'rtl') {
this.renderer.addClass(this.elementRef.nativeElement, 'ant-breadcrumb-rtl');
}
else {
this.renderer.removeClass(this.elementRef.nativeElement, 'ant-breadcrumb-rtl');
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzBreadCrumbComponent, isStandalone: true, selector: "nz-breadcrumb", inputs: { nzAutoGenerate: ["nzAutoGenerate", "nzAutoGenerate", booleanAttribute], nzSeparator: "nzSeparator", nzRouteLabel: "nzRouteLabel", nzRouteLabelFn: "nzRouteLabelFn", nzRouteFn: "nzRouteFn" }, host: { classAttribute: "ant-breadcrumb" }, providers: [{ provide: NzBreadcrumb, useExisting: forwardRef(() => NzBreadCrumbComponent) }], exportAs: ["nzBreadcrumb"], ngImport: i0, template: `
<ng-content />
@if (nzAutoGenerate && breadcrumbs.length) {
@for (breadcrumb of breadcrumbs; track breadcrumb.url) {
<nz-breadcrumb-item>
<a [attr.href]="breadcrumb.url" (click)="navigate(breadcrumb.url, $event)">{{ breadcrumb.label }}</a>
</nz-breadcrumb-item>
}
}
`, isInline: true, dependencies: [{ kind: "component", type: NzBreadCrumbItemComponent, selector: "nz-breadcrumb-item", inputs: ["nzOverlay"], exportAs: ["nzBreadcrumbItem"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-breadcrumb',
exportAs: 'nzBreadcrumb',
providers: [{ provide: NzBreadcrumb, useExisting: forwardRef(() => NzBreadCrumbComponent) }],
imports: [NzBreadCrumbItemComponent],
template: `
<ng-content />
@if (nzAutoGenerate && breadcrumbs.length) {
@for (breadcrumb of breadcrumbs; track breadcrumb.url) {
<nz-breadcrumb-item>
<a [attr.href]="breadcrumb.url" (click)="navigate(breadcrumb.url, $event)">{{ breadcrumb.label }}</a>
</nz-breadcrumb-item>
}
}
`,
host: {
class: 'ant-breadcrumb'
}
}]
}], propDecorators: { nzAutoGenerate: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzSeparator: [{
type: Input
}], nzRouteLabel: [{
type: Input
}], nzRouteLabelFn: [{
type: Input
}], nzRouteFn: [{
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 NzBreadCrumbModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbModule, imports: [NzBreadCrumbComponent, NzBreadCrumbItemComponent, NzBreadCrumbSeparatorComponent], exports: [NzBreadCrumbComponent, NzBreadCrumbItemComponent, NzBreadCrumbSeparatorComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbModule, imports: [NzBreadCrumbComponent, NzBreadCrumbItemComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreadCrumbModule, decorators: [{
type: NgModule,
args: [{
imports: [NzBreadCrumbComponent, NzBreadCrumbItemComponent, NzBreadCrumbSeparatorComponent],
exports: [NzBreadCrumbComponent, NzBreadCrumbItemComponent, NzBreadCrumbSeparatorComponent]
}]
}] });
/**
* 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 { NzBreadCrumbComponent, NzBreadCrumbItemComponent, NzBreadCrumbModule, NzBreadCrumbSeparatorComponent };
//# sourceMappingURL=ng-zorro-antd-breadcrumb.mjs.map
File diff suppressed because one or more lines are too long
+242
View File
@@ -0,0 +1,242 @@
import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality } from '@angular/cdk/bidi';
import * as i0 from '@angular/core';
import { inject, ElementRef, ChangeDetectorRef, Renderer2, DestroyRef, signal, computed, contentChild, viewChild, afterEveryRender, booleanAttribute, Input, ContentChild, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Subject } from 'rxjs';
import { startWith, filter } from 'rxjs/operators';
import { WithConfig, onConfigChangeEventForComponent } from 'ng-zorro-antd/core/config';
import { fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
import * as i2 from 'ng-zorro-antd/icon';
import { NzIconDirective, NzIconModule } from 'ng-zorro-antd/icon';
import * as i1 from 'ng-zorro-antd/space';
import { NZ_SPACE_COMPACT_SIZE, NZ_SPACE_COMPACT_ITEM_TYPE, NzSpaceCompactItemDirective } from 'ng-zorro-antd/space';
import { ɵNzTransitionPatchModule as _NzTransitionPatchModule } from 'ng-zorro-antd/core/transition-patch';
import { NzWaveModule } from 'ng-zorro-antd/core/wave';
const NZ_CONFIG_MODULE_NAME = 'button';
let NzButtonComponent = (() => {
let _nzSize_decorators;
let _nzSize_initializers = [];
let _nzSize_extraInitializers = [];
return class NzButtonComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzSize_decorators = [WithConfig()];
__esDecorate(null, null, _nzSize_decorators, { kind: "field", name: "nzSize", static: false, private: false, access: { has: obj => "nzSize" in obj, get: obj => obj.nzSize, set: (obj, value) => { obj.nzSize = value; } }, metadata: _metadata }, _nzSize_initializers, _nzSize_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
elementRef = inject(ElementRef);
cdr = inject(ChangeDetectorRef);
renderer = inject(Renderer2);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
nzIconDirectiveElement;
nzBlock = false;
nzGhost = false;
/**
* @deprecated Will be removed in v22.0.0. Please use `nz-input-search` instead.
*/
nzSearch = false;
nzLoading = false;
nzDanger = false;
disabled = false;
tabIndex = null;
nzType = null;
nzShape = null;
nzSize = __runInitializers(this, _nzSize_initializers, 'default');
dir = (__runInitializers(this, _nzSize_extraInitializers), 'ltr');
elementOnly = signal(false, ...(ngDevMode ? [{ debugName: "elementOnly" }] : []));
size = signal(this.nzSize, ...(ngDevMode ? [{ debugName: "size" }] : []));
compactSize = inject(NZ_SPACE_COMPACT_SIZE, { optional: true });
loading$ = new Subject();
finalSize = computed(() => {
if (this.compactSize) {
return this.compactSize();
}
return this.size();
}, ...(ngDevMode ? [{ debugName: "finalSize" }] : []));
iconDir = contentChild(NzIconDirective, ...(ngDevMode ? [{ debugName: "iconDir" }] : []));
loadingIconDir = viewChild(NzIconDirective, ...(ngDevMode ? [{ debugName: "loadingIconDir" }] : []));
iconOnly = computed(() => this.elementOnly() && (!!this.iconDir() || !!this.loadingIconDir()), ...(ngDevMode ? [{ debugName: "iconOnly" }] : []));
insertSpan(nodes, renderer) {
nodes.forEach(node => {
if (node.nodeType === Node.TEXT_NODE && node.textContent.trim().length > 0) {
const span = renderer.createElement('span');
const parent = renderer.parentNode(node);
renderer.insertBefore(parent, span, node);
renderer.appendChild(span, node);
}
});
}
constructor() {
onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME, () => {
this.size.set(this.nzSize);
this.cdr.markForCheck();
});
let elementOnly = false;
afterEveryRender({
read: () => {
const { childNodes, children } = this.elementRef.nativeElement;
const hasText = Array.from(childNodes).some(node => node.nodeType === Node.TEXT_NODE && node.textContent.trim().length > 0);
const visibleElementCount = Array.from(children).filter(element => element.style.display !== 'none').length;
elementOnly = !hasText && visibleElementCount === 1;
},
write: () => this.elementOnly.set(elementOnly)
});
}
ngOnInit() {
this.size.set(this.nzSize);
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((direction) => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
// Caretaker note: this event listener could've been added through `host.click` or `HostListener`.
// The compiler generates the `ɵɵlistener` instruction which wraps the actual listener internally into the
// function, which runs `markDirty()` before running the actual listener (the decorated class method).
// Since we're preventing the default behavior and stopping event propagation this doesn't require Angular to run the change detection.
fromEventOutsideAngular(this.elementRef.nativeElement, 'click', { capture: true })
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(event => {
if ((this.disabled && event.target?.tagName === 'A') || this.nzLoading) {
event.preventDefault();
event.stopImmediatePropagation();
}
});
}
ngOnChanges({ nzLoading, nzSize }) {
if (nzLoading) {
this.loading$.next(this.nzLoading);
}
if (nzSize) {
this.size.set(nzSize.currentValue);
}
}
ngAfterViewInit() {
this.insertSpan(this.elementRef.nativeElement.childNodes, this.renderer);
}
ngAfterContentInit() {
this.loading$
.pipe(startWith(this.nzLoading), filter(() => !!this.nzIconDirectiveElement), takeUntilDestroyed(this.destroyRef))
.subscribe(loading => {
const nativeElement = this.nzIconDirectiveElement.nativeElement;
if (loading) {
this.renderer.setStyle(nativeElement, 'display', 'none');
}
else {
this.renderer.removeStyle(nativeElement, 'display');
}
});
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzButtonComponent, isStandalone: true, selector: "button[nz-button], a[nz-button]", inputs: { nzBlock: ["nzBlock", "nzBlock", booleanAttribute], nzGhost: ["nzGhost", "nzGhost", booleanAttribute], nzSearch: ["nzSearch", "nzSearch", booleanAttribute], nzLoading: ["nzLoading", "nzLoading", booleanAttribute], nzDanger: ["nzDanger", "nzDanger", booleanAttribute], disabled: ["disabled", "disabled", booleanAttribute], tabIndex: "tabIndex", nzType: "nzType", nzShape: "nzShape", nzSize: "nzSize" }, host: { properties: { "class.ant-btn-default": "nzType === 'default'", "class.ant-btn-primary": "nzType === 'primary'", "class.ant-btn-dashed": "nzType === 'dashed'", "class.ant-btn-link": "nzType === 'link'", "class.ant-btn-text": "nzType === 'text'", "class.ant-btn-circle": "nzShape === 'circle'", "class.ant-btn-round": "nzShape === 'round'", "class.ant-btn-lg": "finalSize() === 'large'", "class.ant-btn-sm": "finalSize() === 'small'", "class.ant-btn-dangerous": "nzDanger", "class.ant-btn-loading": "nzLoading", "class.ant-btn-background-ghost": "nzGhost", "class.ant-btn-block": "nzBlock", "class.ant-input-search-button": "nzSearch", "class.ant-btn-rtl": "dir === 'rtl'", "class.ant-btn-icon-only": "iconOnly()", "attr.tabindex": "disabled ? -1 : (tabIndex === null ? null : tabIndex)", "attr.disabled": "disabled || null" }, classAttribute: "ant-btn" }, providers: [{ provide: NZ_SPACE_COMPACT_ITEM_TYPE, useValue: 'btn' }], queries: [{ propertyName: "iconDir", first: true, predicate: NzIconDirective, descendants: true, isSignal: true }, { propertyName: "nzIconDirectiveElement", first: true, predicate: NzIconDirective, descendants: true, read: ElementRef }], viewQueries: [{ propertyName: "loadingIconDir", first: true, predicate: NzIconDirective, descendants: true, isSignal: true }], exportAs: ["nzButton"], usesOnChanges: true, hostDirectives: [{ directive: i1.NzSpaceCompactItemDirective }], ngImport: i0, template: `
@if (nzLoading) {
<span class="ant-btn-icon ant-btn-loading-icon">
<nz-icon nzType="loading" />
</span>
}
<ng-content></ng-content>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.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: "20.3.0", ngImport: i0, type: NzButtonComponent, decorators: [{
type: Component,
args: [{
selector: 'button[nz-button], a[nz-button]',
exportAs: 'nzButton',
imports: [NzIconModule],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: `
@if (nzLoading) {
<span class="ant-btn-icon ant-btn-loading-icon">
<nz-icon nzType="loading" />
</span>
}
<ng-content></ng-content>
`,
host: {
class: 'ant-btn',
'[class.ant-btn-default]': `nzType === 'default'`,
'[class.ant-btn-primary]': `nzType === 'primary'`,
'[class.ant-btn-dashed]': `nzType === 'dashed'`,
'[class.ant-btn-link]': `nzType === 'link'`,
'[class.ant-btn-text]': `nzType === 'text'`,
'[class.ant-btn-circle]': `nzShape === 'circle'`,
'[class.ant-btn-round]': `nzShape === 'round'`,
'[class.ant-btn-lg]': `finalSize() === 'large'`,
'[class.ant-btn-sm]': `finalSize() === 'small'`,
'[class.ant-btn-dangerous]': `nzDanger`,
'[class.ant-btn-loading]': `nzLoading`,
'[class.ant-btn-background-ghost]': `nzGhost`,
'[class.ant-btn-block]': `nzBlock`,
'[class.ant-input-search-button]': `nzSearch`,
'[class.ant-btn-rtl]': `dir === 'rtl'`,
'[class.ant-btn-icon-only]': `iconOnly()`,
'[attr.tabindex]': 'disabled ? -1 : (tabIndex === null ? null : tabIndex)',
'[attr.disabled]': 'disabled || null'
},
hostDirectives: [NzSpaceCompactItemDirective],
providers: [{ provide: NZ_SPACE_COMPACT_ITEM_TYPE, useValue: 'btn' }]
}]
}], ctorParameters: () => [], propDecorators: { nzIconDirectiveElement: [{
type: ContentChild,
args: [NzIconDirective, { read: ElementRef }]
}], nzBlock: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzGhost: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzSearch: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzLoading: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzDanger: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], disabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], tabIndex: [{
type: Input
}], nzType: [{
type: Input
}], nzShape: [{
type: Input
}], nzSize: [{
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 NzButtonModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzButtonModule, imports: [NzButtonComponent], exports: [NzButtonComponent, _NzTransitionPatchModule, NzWaveModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzButtonModule, imports: [NzButtonComponent, _NzTransitionPatchModule, NzWaveModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzButtonModule, decorators: [{
type: NgModule,
args: [{
imports: [NzButtonComponent],
exports: [NzButtonComponent, _NzTransitionPatchModule, NzWaveModule]
}]
}] });
/**
* 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 { NzButtonComponent, NzButtonModule };
//# sourceMappingURL=ng-zorro-antd-button.mjs.map
File diff suppressed because one or more lines are too long
+530
View File
@@ -0,0 +1,530 @@
import * as i0 from '@angular/core';
import { Directive, inject, EventEmitter, booleanAttribute, Output, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, ChangeDetectorRef, DestroyRef, TemplateRef, forwardRef, ContentChild, NgModule } from '@angular/core';
import * as i2 from '@angular/forms';
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzStringTemplateOutletDirective } from 'ng-zorro-antd/core/outlet';
import { CandyDate } from 'ng-zorro-antd/core/time';
import { DateHelperService, NzI18nService } from 'ng-zorro-antd/i18n';
import * as i3 from 'ng-zorro-antd/radio';
import { NzRadioModule } from 'ng-zorro-antd/radio';
import * as i1 from 'ng-zorro-antd/select';
import { NzSelectModule } from 'ng-zorro-antd/select';
import { Directionality } from '@angular/cdk/bidi';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import * as i1$1 from 'ng-zorro-antd/date-picker';
import { LibPackerModule } from 'ng-zorro-antd/date-picker';
/**
* 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 NzDateCellDirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDateCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzDateCellDirective, isStandalone: true, selector: "[nzDateCell]", exportAs: ["nzDateCell"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDateCellDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzDateCell]',
exportAs: 'nzDateCell'
}]
}] });
class NzMonthCellDirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzMonthCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzMonthCellDirective, isStandalone: true, selector: "[nzMonthCell]", exportAs: ["nzMonthCell"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzMonthCellDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzMonthCell]',
exportAs: 'nzMonthCell'
}]
}] });
class NzDateFullCellDirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDateFullCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzDateFullCellDirective, isStandalone: true, selector: "[nzDateFullCell]", exportAs: ["nzDateFullCell"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDateFullCellDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzDateFullCell]',
exportAs: 'nzDateFullCell'
}]
}] });
class NzMonthFullCellDirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzMonthFullCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzMonthFullCellDirective, isStandalone: true, selector: "[nzMonthFullCell]", exportAs: ["nzMonthFullCell"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzMonthFullCellDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzMonthFullCell]',
exportAs: 'nzMonthFullCell'
}]
}] });
/**
* 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 NzCalendarHeaderComponent {
dateHelper = inject(DateHelperService);
i18n = inject(NzI18nService);
mode = 'month';
fullscreen = true;
activeDate = new CandyDate();
nzCustomHeader;
modeChange = new EventEmitter();
yearChange = new EventEmitter();
monthChange = new EventEmitter();
yearOffset = 10;
yearTotal = 20;
years = [];
months = [];
get activeYear() {
return this.activeDate.getYear();
}
get activeMonth() {
return this.activeDate.getMonth();
}
get size() {
return this.fullscreen ? 'default' : 'small';
}
get yearTypeText() {
return this.i18n.getLocale().Calendar.lang.year;
}
get monthTypeText() {
return this.i18n.getLocale().Calendar.lang.month;
}
ngOnInit() {
this.setUpYears();
this.setUpMonths();
}
ngOnChanges(changes) {
if (changes['activeDate']) {
const previousActiveDate = changes['activeDate'].previousValue;
const currentActiveDate = changes['activeDate'].currentValue;
if (previousActiveDate?.getYear() !== currentActiveDate?.getYear()) {
this.setUpYears();
}
}
}
updateYear(year) {
this.yearChange.emit(year);
this.setUpYears(year);
}
setUpYears(year) {
const start = (year || this.activeYear) - this.yearOffset;
const end = start + this.yearTotal;
this.years = [];
for (let i = start; i < end; i++) {
this.years.push({ label: `${i}`, value: i });
}
}
setUpMonths() {
this.months = [];
for (let i = 0; i < 12; i++) {
const dateInMonth = this.activeDate.setMonth(i);
const monthText = this.dateHelper.format(dateInMonth.nativeDate, 'MMM');
this.months.push({ label: monthText, value: i });
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCalendarHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCalendarHeaderComponent, isStandalone: true, selector: "nz-calendar-header", inputs: { mode: "mode", fullscreen: ["fullscreen", "fullscreen", booleanAttribute], activeDate: "activeDate", nzCustomHeader: "nzCustomHeader" }, outputs: { modeChange: "modeChange", yearChange: "yearChange", monthChange: "monthChange" }, host: { properties: { "style.display": "'block'" }, classAttribute: "ant-fullcalendar-header" }, exportAs: ["nzCalendarHeader"], usesOnChanges: true, ngImport: i0, template: `
@if (nzCustomHeader) {
<ng-container *nzStringTemplateOutlet="nzCustomHeader">{{ nzCustomHeader }}</ng-container>
} @else {
<div class="ant-picker-calendar-header">
<nz-select
class="ant-picker-calendar-year-select"
[nzSize]="size"
[nzDropdownMatchSelectWidth]="false"
[ngModel]="activeYear"
(ngModelChange)="updateYear($event)"
>
@for (year of years; track year.value) {
<nz-option [nzLabel]="year.label" [nzValue]="year.value" />
}
</nz-select>
@if (mode === 'month') {
<nz-select
class="ant-picker-calendar-month-select"
[nzSize]="size"
[nzDropdownMatchSelectWidth]="false"
[ngModel]="activeMonth"
(ngModelChange)="monthChange.emit($event)"
>
@for (month of months; track month.value) {
<nz-option [nzLabel]="month.label" [nzValue]="month.value" />
}
</nz-select>
}
<nz-radio-group
class="ant-picker-calendar-mode-switch"
[(ngModel)]="mode"
(ngModelChange)="modeChange.emit($event)"
[nzSize]="size"
>
<label nz-radio-button nzValue="month">{{ monthTypeText }}</label>
<label nz-radio-button nzValue="year">{{ yearTypeText }}</label>
</nz-radio-group>
</div>
}
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzSelectModule }, { kind: "component", type: i1.NzOptionComponent, selector: "nz-option", inputs: ["nzTitle", "nzLabel", "nzValue", "nzKey", "nzDisabled", "nzHide", "nzCustomContent"], exportAs: ["nzOption"] }, { kind: "component", type: i1.NzSelectComponent, selector: "nz-select", inputs: ["nzId", "nzSize", "nzStatus", "nzVariant", "nzOptionHeightPx", "nzOptionOverflowSize", "nzDropdownClassName", "nzDropdownMatchSelectWidth", "nzDropdownStyle", "nzNotFoundContent", "nzPlaceHolder", "nzPlacement", "nzMaxTagCount", "nzDropdownRender", "nzCustomTemplate", "nzPrefix", "nzSuffixIcon", "nzClearIcon", "nzRemoveIcon", "nzMenuItemSelectedIcon", "nzTokenSeparators", "nzMaxTagPlaceholder", "nzMaxMultipleCount", "nzMode", "nzFilterOption", "compareWith", "nzAllowClear", "nzBorderless", "nzShowSearch", "nzLoading", "nzAutoFocus", "nzAutoClearSearchValue", "nzServerSearch", "nzDisabled", "nzOpen", "nzSelectOnTab", "nzBackdrop", "nzOptions", "nzShowArrow"], outputs: ["nzOnSearch", "nzScrollToBottom", "nzOpenChange", "nzBlur", "nzFocus", "nzOnClear"], exportAs: ["nzSelect"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: NzRadioModule }, { kind: "component", type: i3.NzRadioComponent, selector: "[nz-radio],[nz-radio-button]", inputs: ["nzValue", "nzDisabled", "nzAutoFocus", "nz-radio-button"], exportAs: ["nzRadio"] }, { kind: "component", type: i3.NzRadioGroupComponent, selector: "nz-radio-group", inputs: ["nzDisabled", "nzButtonStyle", "nzSize", "nzName"], exportAs: ["nzRadioGroup"] }, { kind: "directive", type: NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCalendarHeaderComponent, decorators: [{
type: Component,
args: [{
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'nz-calendar-header',
exportAs: 'nzCalendarHeader',
template: `
@if (nzCustomHeader) {
<ng-container *nzStringTemplateOutlet="nzCustomHeader">{{ nzCustomHeader }}</ng-container>
} @else {
<div class="ant-picker-calendar-header">
<nz-select
class="ant-picker-calendar-year-select"
[nzSize]="size"
[nzDropdownMatchSelectWidth]="false"
[ngModel]="activeYear"
(ngModelChange)="updateYear($event)"
>
@for (year of years; track year.value) {
<nz-option [nzLabel]="year.label" [nzValue]="year.value" />
}
</nz-select>
@if (mode === 'month') {
<nz-select
class="ant-picker-calendar-month-select"
[nzSize]="size"
[nzDropdownMatchSelectWidth]="false"
[ngModel]="activeMonth"
(ngModelChange)="monthChange.emit($event)"
>
@for (month of months; track month.value) {
<nz-option [nzLabel]="month.label" [nzValue]="month.value" />
}
</nz-select>
}
<nz-radio-group
class="ant-picker-calendar-mode-switch"
[(ngModel)]="mode"
(ngModelChange)="modeChange.emit($event)"
[nzSize]="size"
>
<label nz-radio-button nzValue="month">{{ monthTypeText }}</label>
<label nz-radio-button nzValue="year">{{ yearTypeText }}</label>
</nz-radio-group>
</div>
}
`,
host: {
class: 'ant-fullcalendar-header',
'[style.display]': `'block'`
},
imports: [NzSelectModule, FormsModule, NzRadioModule, NzStringTemplateOutletDirective]
}]
}], propDecorators: { mode: [{
type: Input
}], fullscreen: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], activeDate: [{
type: Input
}], nzCustomHeader: [{
type: Input
}], modeChange: [{
type: Output
}], yearChange: [{
type: Output
}], monthChange: [{
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 NzCalendarComponent {
cdr = inject(ChangeDetectorRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
activeDate = new CandyDate();
prefixCls = 'ant-picker-calendar';
dir = 'ltr';
onChangeFn = () => { };
onTouchFn = () => { };
nzMode = 'month';
nzValue;
nzDisabledDate;
nzModeChange = new EventEmitter();
nzPanelChange = new EventEmitter();
nzSelectChange = new EventEmitter();
nzValueChange = new EventEmitter();
/**
* Cannot use @Input and @ContentChild on one variable
* because { static: false } will make @Input property get delayed
**/
nzDateCell;
nzDateCellChild;
get dateCell() {
return (this.nzDateCell || this.nzDateCellChild);
}
nzDateFullCell;
nzDateFullCellChild;
get dateFullCell() {
return (this.nzDateFullCell || this.nzDateFullCellChild);
}
nzMonthCell;
nzMonthCellChild;
get monthCell() {
return (this.nzMonthCell || this.nzMonthCellChild);
}
nzMonthFullCell;
nzMonthFullCellChild;
get monthFullCell() {
return (this.nzMonthFullCell || this.nzMonthFullCellChild);
}
nzCustomHeader;
nzFullscreen = true;
ngOnInit() {
this.dir = this.directionality.value;
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
this.dir = this.directionality.value;
});
}
onModeChange(mode) {
this.nzModeChange.emit(mode);
this.nzPanelChange.emit({ date: this.activeDate.nativeDate, mode });
}
onYearSelect(year) {
const date = this.activeDate.setYear(year);
this.updateDate(date);
}
onMonthSelect(month) {
const date = this.activeDate.setMonth(month);
this.updateDate(date);
}
onDateSelect(date) {
// Only activeDate is enough in calendar
// this.value = date;
this.updateDate(date);
}
writeValue(value) {
this.updateDate(new CandyDate(value), false);
this.cdr.markForCheck();
}
registerOnChange(fn) {
this.onChangeFn = fn;
}
registerOnTouched(fn) {
this.onTouchFn = fn;
}
updateDate(date, touched = true) {
this.activeDate = date;
if (touched) {
this.onChangeFn(date.nativeDate);
this.onTouchFn();
this.nzSelectChange.emit(date.nativeDate);
this.nzValueChange.emit(date.nativeDate);
}
}
ngOnChanges(changes) {
if (changes.nzValue) {
this.updateDate(new CandyDate(this.nzValue), false);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCalendarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCalendarComponent, isStandalone: true, selector: "nz-calendar", inputs: { nzMode: "nzMode", nzValue: "nzValue", nzDisabledDate: "nzDisabledDate", nzDateCell: "nzDateCell", nzDateFullCell: "nzDateFullCell", nzMonthCell: "nzMonthCell", nzMonthFullCell: "nzMonthFullCell", nzCustomHeader: "nzCustomHeader", nzFullscreen: ["nzFullscreen", "nzFullscreen", booleanAttribute] }, outputs: { nzModeChange: "nzModeChange", nzPanelChange: "nzPanelChange", nzSelectChange: "nzSelectChange", nzValueChange: "nzValueChange" }, host: { properties: { "class.ant-picker-calendar-full": "nzFullscreen", "class.ant-picker-calendar-mini": "!nzFullscreen", "class.ant-picker-calendar-rtl": "dir === 'rtl'" }, classAttribute: "ant-picker-calendar" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NzCalendarComponent), multi: true }], queries: [{ propertyName: "nzDateCellChild", first: true, predicate: NzDateCellDirective, descendants: true, read: TemplateRef }, { propertyName: "nzDateFullCellChild", first: true, predicate: NzDateFullCellDirective, descendants: true, read: TemplateRef }, { propertyName: "nzMonthCellChild", first: true, predicate: NzMonthCellDirective, descendants: true, read: TemplateRef }, { propertyName: "nzMonthFullCellChild", first: true, predicate: NzMonthFullCellDirective, descendants: true, read: TemplateRef }], exportAs: ["nzCalendar"], usesOnChanges: true, ngImport: i0, template: `
<nz-calendar-header
[fullscreen]="nzFullscreen"
[activeDate]="activeDate"
[nzCustomHeader]="nzCustomHeader"
[(mode)]="nzMode"
(modeChange)="onModeChange($event)"
(yearChange)="onYearSelect($event)"
(monthChange)="onMonthSelect($event)"
></nz-calendar-header>
<div class="ant-picker-panel">
<div class="ant-picker-{{ nzMode === 'month' ? 'date' : 'month' }}-panel">
<div class="ant-picker-body">
@if (nzMode === 'month') {
<!-- TODO(@wenqi73) [cellRender] [fullCellRender] -->
<date-table
[prefixCls]="prefixCls"
[value]="activeDate"
[activeDate]="activeDate"
[cellRender]="$any(dateCell)"
[fullCellRender]="$any(dateFullCell)"
[disabledDate]="nzDisabledDate"
(valueChange)="onDateSelect($event)"
></date-table>
} @else {
<month-table
[prefixCls]="prefixCls"
[value]="activeDate"
[activeDate]="activeDate"
[cellRender]="$any(monthCell)"
[fullCellRender]="$any(monthFullCell)"
(valueChange)="onDateSelect($event)"
></month-table>
}
</div>
</div>
</div>
`, isInline: true, dependencies: [{ kind: "component", type: NzCalendarHeaderComponent, selector: "nz-calendar-header", inputs: ["mode", "fullscreen", "activeDate", "nzCustomHeader"], outputs: ["modeChange", "yearChange", "monthChange"], exportAs: ["nzCalendarHeader"] }, { kind: "ngmodule", type: LibPackerModule }, { kind: "component", type: i1$1.ɵDateTableComponent, selector: "date-table", inputs: ["format"] }, { kind: "component", type: i1$1.ɵMonthTableComponent, selector: "month-table" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCalendarComponent, decorators: [{
type: Component,
args: [{
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'nz-calendar',
exportAs: 'nzCalendar',
template: `
<nz-calendar-header
[fullscreen]="nzFullscreen"
[activeDate]="activeDate"
[nzCustomHeader]="nzCustomHeader"
[(mode)]="nzMode"
(modeChange)="onModeChange($event)"
(yearChange)="onYearSelect($event)"
(monthChange)="onMonthSelect($event)"
></nz-calendar-header>
<div class="ant-picker-panel">
<div class="ant-picker-{{ nzMode === 'month' ? 'date' : 'month' }}-panel">
<div class="ant-picker-body">
@if (nzMode === 'month') {
<!-- TODO(@wenqi73) [cellRender] [fullCellRender] -->
<date-table
[prefixCls]="prefixCls"
[value]="activeDate"
[activeDate]="activeDate"
[cellRender]="$any(dateCell)"
[fullCellRender]="$any(dateFullCell)"
[disabledDate]="nzDisabledDate"
(valueChange)="onDateSelect($event)"
></date-table>
} @else {
<month-table
[prefixCls]="prefixCls"
[value]="activeDate"
[activeDate]="activeDate"
[cellRender]="$any(monthCell)"
[fullCellRender]="$any(monthFullCell)"
(valueChange)="onDateSelect($event)"
></month-table>
}
</div>
</div>
</div>
`,
host: {
class: 'ant-picker-calendar',
'[class.ant-picker-calendar-full]': 'nzFullscreen',
'[class.ant-picker-calendar-mini]': '!nzFullscreen',
'[class.ant-picker-calendar-rtl]': `dir === 'rtl'`
},
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NzCalendarComponent), multi: true }],
imports: [NzCalendarHeaderComponent, LibPackerModule]
}]
}], propDecorators: { nzMode: [{
type: Input
}], nzValue: [{
type: Input
}], nzDisabledDate: [{
type: Input
}], nzModeChange: [{
type: Output
}], nzPanelChange: [{
type: Output
}], nzSelectChange: [{
type: Output
}], nzValueChange: [{
type: Output
}], nzDateCell: [{
type: Input
}], nzDateCellChild: [{
type: ContentChild,
args: [NzDateCellDirective, { static: false, read: TemplateRef }]
}], nzDateFullCell: [{
type: Input
}], nzDateFullCellChild: [{
type: ContentChild,
args: [NzDateFullCellDirective, { static: false, read: TemplateRef }]
}], nzMonthCell: [{
type: Input
}], nzMonthCellChild: [{
type: ContentChild,
args: [NzMonthCellDirective, { static: false, read: TemplateRef }]
}], nzMonthFullCell: [{
type: Input
}], nzMonthFullCellChild: [{
type: ContentChild,
args: [NzMonthFullCellDirective, { static: false, read: TemplateRef }]
}], nzCustomHeader: [{
type: Input
}], nzFullscreen: [{
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 NzCalendarModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCalendarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCalendarModule, imports: [NzCalendarHeaderComponent,
NzCalendarComponent,
NzDateCellDirective,
NzDateFullCellDirective,
NzMonthCellDirective,
NzMonthFullCellDirective], exports: [NzCalendarComponent,
NzDateCellDirective,
NzDateFullCellDirective,
NzMonthCellDirective,
NzMonthFullCellDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCalendarModule, imports: [NzCalendarHeaderComponent,
NzCalendarComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCalendarModule, decorators: [{
type: NgModule,
args: [{
imports: [
NzCalendarHeaderComponent,
NzCalendarComponent,
NzDateCellDirective,
NzDateFullCellDirective,
NzMonthCellDirective,
NzMonthFullCellDirective
],
exports: [
NzCalendarComponent,
NzDateCellDirective,
NzDateFullCellDirective,
NzMonthCellDirective,
NzMonthFullCellDirective
]
}]
}] });
/**
* 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 { NzCalendarComponent, NzCalendarHeaderComponent, NzCalendarModule, NzDateCellDirective, NzDateFullCellDirective, NzMonthCellDirective, NzMonthFullCellDirective };
//# sourceMappingURL=ng-zorro-antd-calendar.mjs.map
File diff suppressed because one or more lines are too long
+358
View File
@@ -0,0 +1,358 @@
import * as i0 from '@angular/core';
import { booleanAttribute, Input, Directive, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, ViewChild, inject, ChangeDetectorRef, DestroyRef, ContentChildren, ContentChild, NgModule } from '@angular/core';
import { NgTemplateOutlet } from '@angular/common';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality, BidiModule } from '@angular/cdk/bidi';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { WithConfig, onConfigChangeEventForComponent } from 'ng-zorro-antd/core/config';
import * as i2 from 'ng-zorro-antd/skeleton';
import { NzSkeletonModule } from 'ng-zorro-antd/skeleton';
/**
* 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 NzCardGridDirective {
nzHoverable = true;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardGridDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.3.0", type: NzCardGridDirective, isStandalone: true, selector: "[nz-card-grid]", inputs: { nzHoverable: ["nzHoverable", "nzHoverable", booleanAttribute] }, host: { properties: { "class.ant-card-hoverable": "nzHoverable" }, classAttribute: "ant-card-grid" }, exportAs: ["nzCardGrid"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardGridDirective, decorators: [{
type: Directive,
args: [{
selector: '[nz-card-grid]',
exportAs: 'nzCardGrid',
host: {
class: 'ant-card-grid',
'[class.ant-card-hoverable]': 'nzHoverable'
}
}]
}], propDecorators: { nzHoverable: [{
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 NzCardMetaComponent {
nzTitle = null;
nzDescription = null;
nzAvatar = null;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardMetaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCardMetaComponent, isStandalone: true, selector: "nz-card-meta", inputs: { nzTitle: "nzTitle", nzDescription: "nzDescription", nzAvatar: "nzAvatar" }, host: { classAttribute: "ant-card-meta" }, exportAs: ["nzCardMeta"], ngImport: i0, template: `
@if (nzAvatar) {
<div class="ant-card-meta-avatar">
<ng-template [ngTemplateOutlet]="nzAvatar" />
</div>
}
@if (nzTitle || nzDescription) {
<div class="ant-card-meta-detail">
@if (nzTitle) {
<div class="ant-card-meta-title">
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
</div>
}
@if (nzDescription) {
<div class="ant-card-meta-description">
<ng-container *nzStringTemplateOutlet="nzDescription">{{ nzDescription }}</ng-container>
</div>
}
</div>
}
`, 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardMetaComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-card-meta',
exportAs: 'nzCardMeta',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: `
@if (nzAvatar) {
<div class="ant-card-meta-avatar">
<ng-template [ngTemplateOutlet]="nzAvatar" />
</div>
}
@if (nzTitle || nzDescription) {
<div class="ant-card-meta-detail">
@if (nzTitle) {
<div class="ant-card-meta-title">
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
</div>
}
@if (nzDescription) {
<div class="ant-card-meta-description">
<ng-container *nzStringTemplateOutlet="nzDescription">{{ nzDescription }}</ng-container>
</div>
}
</div>
}
`,
host: { class: 'ant-card-meta' },
imports: [NgTemplateOutlet, NzOutletModule]
}]
}], propDecorators: { nzTitle: [{
type: Input
}], nzDescription: [{
type: Input
}], nzAvatar: [{
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 NzCardTabComponent {
template;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardTabComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzCardTabComponent, isStandalone: true, selector: "nz-card-tab", viewQueries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true, static: true }], exportAs: ["nzCardTab"], 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: "20.3.0", ngImport: i0, type: NzCardTabComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-card-tab',
exportAs: 'nzCardTab',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-template>
<ng-content></ng-content>
</ng-template>
`
}]
}], propDecorators: { template: [{
type: ViewChild,
args: [TemplateRef, { static: true }]
}] } });
const NZ_CONFIG_MODULE_NAME = 'card';
let NzCardComponent = (() => {
let _nzBordered_decorators;
let _nzBordered_initializers = [];
let _nzBordered_extraInitializers = [];
let _nzHoverable_decorators;
let _nzHoverable_initializers = [];
let _nzHoverable_extraInitializers = [];
let _nzSize_decorators;
let _nzSize_initializers = [];
let _nzSize_extraInitializers = [];
return class NzCardComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzBordered_decorators = [WithConfig()];
_nzHoverable_decorators = [WithConfig()];
_nzSize_decorators = [WithConfig()];
__esDecorate(null, null, _nzBordered_decorators, { kind: "field", name: "nzBordered", static: false, private: false, access: { has: obj => "nzBordered" in obj, get: obj => obj.nzBordered, set: (obj, value) => { obj.nzBordered = value; } }, metadata: _metadata }, _nzBordered_initializers, _nzBordered_extraInitializers);
__esDecorate(null, null, _nzHoverable_decorators, { kind: "field", name: "nzHoverable", static: false, private: false, access: { has: obj => "nzHoverable" in obj, get: obj => obj.nzHoverable, set: (obj, value) => { obj.nzHoverable = value; } }, metadata: _metadata }, _nzHoverable_initializers, _nzHoverable_extraInitializers);
__esDecorate(null, null, _nzSize_decorators, { kind: "field", name: "nzSize", static: false, private: false, access: { has: obj => "nzSize" in obj, get: obj => obj.nzSize, set: (obj, value) => { obj.nzSize = value; } }, metadata: _metadata }, _nzSize_initializers, _nzSize_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
cdr = inject(ChangeDetectorRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
nzBordered = __runInitializers(this, _nzBordered_initializers, true);
nzLoading = (__runInitializers(this, _nzBordered_extraInitializers), false);
nzHoverable = __runInitializers(this, _nzHoverable_initializers, false);
nzBodyStyle = (__runInitializers(this, _nzHoverable_extraInitializers), null);
nzCover;
nzActions = [];
nzType = null;
nzSize = __runInitializers(this, _nzSize_initializers, 'default');
nzTitle = __runInitializers(this, _nzSize_extraInitializers);
nzExtra;
listOfNzCardTabComponent;
listOfNzCardGridDirective;
dir = 'ltr';
constructor() {
onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME, () => this.cdr.markForCheck());
}
ngOnInit() {
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((direction) => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCardComponent, isStandalone: true, selector: "nz-card", inputs: { nzBordered: ["nzBordered", "nzBordered", booleanAttribute], nzLoading: ["nzLoading", "nzLoading", booleanAttribute], nzHoverable: ["nzHoverable", "nzHoverable", booleanAttribute], nzBodyStyle: "nzBodyStyle", nzCover: "nzCover", nzActions: "nzActions", nzType: "nzType", nzSize: "nzSize", nzTitle: "nzTitle", nzExtra: "nzExtra" }, host: { properties: { "class.ant-card-loading": "nzLoading", "class.ant-card-bordered": "nzBordered", "class.ant-card-hoverable": "nzHoverable", "class.ant-card-small": "nzSize === \"small\"", "class.ant-card-contain-grid": "listOfNzCardGridDirective && listOfNzCardGridDirective.length", "class.ant-card-type-inner": "nzType === \"inner\"", "class.ant-card-contain-tabs": "!!listOfNzCardTabComponent", "class.ant-card-rtl": "dir === 'rtl'" }, classAttribute: "ant-card" }, queries: [{ propertyName: "listOfNzCardTabComponent", first: true, predicate: NzCardTabComponent, descendants: true }, { propertyName: "listOfNzCardGridDirective", predicate: NzCardGridDirective }], exportAs: ["nzCard"], ngImport: i0, template: `
@if (nzTitle || nzExtra || listOfNzCardTabComponent) {
<div class="ant-card-head">
<div class="ant-card-head-wrapper">
@if (nzTitle) {
<div class="ant-card-head-title">
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
</div>
}
@if (nzExtra) {
<div class="ant-card-extra">
<ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
</div>
}
</div>
@if (listOfNzCardTabComponent) {
<ng-template [ngTemplateOutlet]="listOfNzCardTabComponent.template" />
}
</div>
}
@if (nzCover) {
<div class="ant-card-cover">
<ng-template [ngTemplateOutlet]="nzCover" />
</div>
}
<div class="ant-card-body" [style]="nzBodyStyle">
@if (nzLoading) {
<nz-skeleton [nzActive]="true" [nzTitle]="false" [nzParagraph]="{ rows: 4 }"></nz-skeleton>
} @else {
<ng-content />
}
</div>
@if (nzActions.length) {
<ul class="ant-card-actions">
@for (action of nzActions; track $index) {
<li [style.width.%]="100 / nzActions.length">
<span><ng-template [ngTemplateOutlet]="action" /></span>
</li>
}
</ul>
}
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzSkeletonModule }, { kind: "component", type: i2.NzSkeletonComponent, selector: "nz-skeleton", inputs: ["nzActive", "nzLoading", "nzRound", "nzTitle", "nzAvatar", "nzParagraph"], exportAs: ["nzSkeleton"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-card',
exportAs: 'nzCard',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: `
@if (nzTitle || nzExtra || listOfNzCardTabComponent) {
<div class="ant-card-head">
<div class="ant-card-head-wrapper">
@if (nzTitle) {
<div class="ant-card-head-title">
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
</div>
}
@if (nzExtra) {
<div class="ant-card-extra">
<ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
</div>
}
</div>
@if (listOfNzCardTabComponent) {
<ng-template [ngTemplateOutlet]="listOfNzCardTabComponent.template" />
}
</div>
}
@if (nzCover) {
<div class="ant-card-cover">
<ng-template [ngTemplateOutlet]="nzCover" />
</div>
}
<div class="ant-card-body" [style]="nzBodyStyle">
@if (nzLoading) {
<nz-skeleton [nzActive]="true" [nzTitle]="false" [nzParagraph]="{ rows: 4 }"></nz-skeleton>
} @else {
<ng-content />
}
</div>
@if (nzActions.length) {
<ul class="ant-card-actions">
@for (action of nzActions; track $index) {
<li [style.width.%]="100 / nzActions.length">
<span><ng-template [ngTemplateOutlet]="action" /></span>
</li>
}
</ul>
}
`,
host: {
class: 'ant-card',
'[class.ant-card-loading]': 'nzLoading',
'[class.ant-card-bordered]': 'nzBordered',
'[class.ant-card-hoverable]': 'nzHoverable',
'[class.ant-card-small]': 'nzSize === "small"',
'[class.ant-card-contain-grid]': 'listOfNzCardGridDirective && listOfNzCardGridDirective.length',
'[class.ant-card-type-inner]': 'nzType === "inner"',
'[class.ant-card-contain-tabs]': '!!listOfNzCardTabComponent',
'[class.ant-card-rtl]': `dir === 'rtl'`
},
imports: [NzOutletModule, NgTemplateOutlet, NzSkeletonModule]
}]
}], ctorParameters: () => [], propDecorators: { nzBordered: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzLoading: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzHoverable: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzBodyStyle: [{
type: Input
}], nzCover: [{
type: Input
}], nzActions: [{
type: Input
}], nzType: [{
type: Input
}], nzSize: [{
type: Input
}], nzTitle: [{
type: Input
}], nzExtra: [{
type: Input
}], listOfNzCardTabComponent: [{
type: ContentChild,
args: [NzCardTabComponent, { static: false }]
}], listOfNzCardGridDirective: [{
type: ContentChildren,
args: [NzCardGridDirective]
}] } });
/**
* 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 NzCardModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCardModule, imports: [NzCardComponent, NzCardGridDirective, NzCardMetaComponent, NzCardTabComponent], exports: [BidiModule, NzCardComponent, NzCardGridDirective, NzCardMetaComponent, NzCardTabComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardModule, imports: [NzCardComponent, NzCardMetaComponent, BidiModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCardModule, decorators: [{
type: NgModule,
args: [{
imports: [NzCardComponent, NzCardGridDirective, NzCardMetaComponent, NzCardTabComponent],
exports: [BidiModule, NzCardComponent, NzCardGridDirective, NzCardMetaComponent, NzCardTabComponent]
}]
}] });
/**
* 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 { NzCardComponent, NzCardGridDirective, NzCardMetaComponent, NzCardModule, NzCardTabComponent };
//# sourceMappingURL=ng-zorro-antd-card.mjs.map
File diff suppressed because one or more lines are too long
+929
View File
@@ -0,0 +1,929 @@
import * as i0 from '@angular/core';
import { inject, Renderer2, ElementRef, Directive, InjectionToken, NgZone, ChangeDetectorRef, DestroyRef, EventEmitter, booleanAttribute, numberAttribute, Output, Input, ViewChild, ContentChildren, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality } from '@angular/cdk/bidi';
import { LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes';
import { Platform } from '@angular/cdk/platform';
import { NgTemplateOutlet } from '@angular/common';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { NzResizeObserver } from 'ng-zorro-antd/cdk/resize-observer';
import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
import { NzResizeService, NzDragService } from 'ng-zorro-antd/core/services';
import { fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
import { Subject } from 'rxjs';
/**
* 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 NzCarouselContentDirective {
renderer = inject(Renderer2);
el = inject((ElementRef)).nativeElement;
set isActive(value) {
this._active = value;
if (this.isActive) {
this.renderer.addClass(this.el, 'slick-active');
}
else {
this.renderer.removeClass(this.el, 'slick-active');
}
}
get isActive() {
return this._active;
}
_active = false;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCarouselContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzCarouselContentDirective, isStandalone: true, selector: "[nz-carousel-content]", host: { classAttribute: "slick-slide" }, exportAs: ["nzCarouselContent"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCarouselContentDirective, decorators: [{
type: Directive,
args: [{
selector: '[nz-carousel-content]',
exportAs: 'nzCarouselContent',
host: {
class: 'slick-slide'
}
}]
}] });
/**
* 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 NzCarouselBaseStrategy {
cdr;
renderer;
platform;
options;
// Properties that strategies may want to use.
carouselComponent;
contents;
slickListEl;
slickTrackEl;
length;
unitWidth;
unitHeight;
get maxIndex() {
return this.length - 1;
}
get firstEl() {
return this.contents[0].el;
}
get lastEl() {
return this.contents[this.maxIndex].el;
}
constructor(carouselComponent, cdr, renderer, platform, options) {
this.cdr = cdr;
this.renderer = renderer;
this.platform = platform;
this.options = options;
this.carouselComponent = carouselComponent;
}
/**
* Initialize dragging sequences.
*
* @param contents
*/
withCarouselContents(contents) {
const carousel = this.carouselComponent;
this.slickListEl = carousel.slickListEl;
this.slickTrackEl = carousel.slickTrackEl;
this.contents = contents?.toArray() || [];
this.length = this.contents.length;
if (this.platform.isBrowser) {
const rect = carousel.el.getBoundingClientRect();
this.unitWidth = rect.width;
this.unitHeight = rect.height;
}
else {
// Since we cannot call getBoundingClientRect in server, we just hide all items except for the first one.
contents?.forEach((content, index) => {
if (index === 0) {
this.renderer.setStyle(content.el, 'width', '100%');
}
else {
this.renderer.setStyle(content.el, 'display', 'none');
}
});
}
}
/**
* When user drag the carousel component.
*
* @optional
*/
dragging(_vector) { }
/**
* Destroy a scroll strategy.
*/
dispose() { }
getFromToInBoundary(f, t) {
const length = this.maxIndex + 1;
return { from: (f + length) % length, to: (t + length) % length };
}
}
/**
* 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 NzCarouselOpacityStrategy extends NzCarouselBaseStrategy {
withCarouselContents(contents) {
super.withCarouselContents(contents);
if (this.contents) {
this.slickTrackEl.style.width = `${this.length * this.unitWidth}px`;
this.contents.forEach((content, i) => {
this.renderer.setStyle(content.el, 'opacity', this.carouselComponent.activeIndex === i ? '1' : '0');
this.renderer.setStyle(content.el, 'position', 'relative');
this.renderer.setStyle(content.el, 'width', `${this.unitWidth}px`);
this.renderer.setStyle(content.el, 'left', `${-this.unitWidth * i}px`);
this.renderer.setStyle(content.el, 'transition', ['opacity 500ms ease 0s', 'visibility 500ms ease 0s']);
});
}
}
switch(_f, _t) {
const { to: t } = this.getFromToInBoundary(_f, _t);
const complete$ = new Subject();
this.contents.forEach((content, i) => {
this.renderer.setStyle(content.el, 'opacity', t === i ? '1' : '0');
});
setTimeout(() => {
complete$.next();
complete$.complete();
}, this.carouselComponent.nzTransitionSpeed);
return complete$;
}
dispose() {
this.contents.forEach((content) => {
this.renderer.setStyle(content.el, 'transition', null);
this.renderer.setStyle(content.el, 'opacity', null);
this.renderer.setStyle(content.el, 'width', null);
this.renderer.setStyle(content.el, 'left', null);
});
super.dispose();
}
}
/**
* 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 NzCarouselTransformStrategy extends NzCarouselBaseStrategy {
isDragging = false;
isTransitioning = false;
get vertical() {
return this.carouselComponent.vertical;
}
constructor(carouselComponent, cdr, renderer, platform, options) {
super(carouselComponent, cdr, renderer, platform, options);
}
dispose() {
super.dispose();
this.renderer.setStyle(this.slickTrackEl, 'transform', null);
}
withCarouselContents(contents) {
super.withCarouselContents(contents);
const carousel = this.carouselComponent;
const activeIndex = carousel.activeIndex;
// We only do when we are in browser.
if (this.platform.isBrowser && this.contents.length) {
this.renderer.setStyle(this.slickListEl, 'height', `${this.unitHeight}px`);
if (this.vertical) {
this.renderer.setStyle(this.slickTrackEl, 'width', `${this.unitWidth}px`);
this.renderer.setStyle(this.slickTrackEl, 'height', `${this.length * this.unitHeight}px`);
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(0, ${-activeIndex * this.unitHeight}px, 0)`);
}
else {
this.renderer.setStyle(this.slickTrackEl, 'height', `${this.unitHeight}px`);
this.renderer.setStyle(this.slickTrackEl, 'width', `${this.length * this.unitWidth}px`);
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(${-activeIndex * this.unitWidth}px, 0, 0)`);
}
this.contents.forEach((content) => {
this.renderer.setStyle(content.el, 'position', 'relative');
this.renderer.setStyle(content.el, 'width', `${this.unitWidth}px`);
this.renderer.setStyle(content.el, 'height', `${this.unitHeight}px`);
});
}
}
switch(_f, _t) {
const { to: t } = this.getFromToInBoundary(_f, _t);
const complete$ = new Subject();
this.renderer.setStyle(this.slickTrackEl, 'transition', `transform ${this.carouselComponent.nzTransitionSpeed}ms ease`);
if (this.vertical) {
this.verticalTransform(_f, _t);
}
else {
this.horizontalTransform(_f, _t);
}
this.isTransitioning = true;
this.isDragging = false;
// TODO: use transitionEnd event instead of setTimeout
setTimeout(() => {
this.renderer.setStyle(this.slickTrackEl, 'transition', null);
this.contents.forEach((content) => {
this.renderer.setStyle(content.el, this.vertical ? 'top' : 'left', null);
});
if (this.vertical) {
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(0, ${-t * this.unitHeight}px, 0)`);
}
else {
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(${-t * this.unitWidth}px, 0, 0)`);
}
this.isTransitioning = false;
complete$.next();
complete$.complete();
}, this.carouselComponent.nzTransitionSpeed);
return complete$.asObservable();
}
dragging(_vector) {
if (this.isTransitioning) {
return;
}
const activeIndex = this.carouselComponent.activeIndex;
if (this.carouselComponent.vertical) {
if (!this.isDragging && this.length > 2) {
if (activeIndex === this.maxIndex) {
this.prepareVerticalContext(true);
}
else if (activeIndex === 0) {
this.prepareVerticalContext(false);
}
}
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(0, ${-activeIndex * this.unitHeight + _vector.x}px, 0)`);
}
else {
if (!this.isDragging && this.length > 2) {
if (activeIndex === this.maxIndex) {
this.prepareHorizontalContext(true);
}
else if (activeIndex === 0) {
this.prepareHorizontalContext(false);
}
}
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(${-activeIndex * this.unitWidth + _vector.x}px, 0, 0)`);
}
this.isDragging = true;
}
verticalTransform(_f, _t) {
const { from: f, to: t } = this.getFromToInBoundary(_f, _t);
const needToAdjust = this.length > 2 && _t !== t;
if (needToAdjust) {
this.prepareVerticalContext(t < f);
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(0, ${-_t * this.unitHeight}px, 0)`);
}
else {
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(0, ${-t * this.unitHeight}px, 0`);
}
}
horizontalTransform(_f, _t) {
const { from: f, to: t } = this.getFromToInBoundary(_f, _t);
const needToAdjust = this.length > 2 && _t !== t;
if (needToAdjust) {
this.prepareHorizontalContext(t < f);
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(${-_t * this.unitWidth}px, 0, 0)`);
}
else {
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(${-t * this.unitWidth}px, 0, 0`);
}
}
prepareVerticalContext(lastToFirst) {
if (lastToFirst) {
this.renderer.setStyle(this.firstEl, 'top', `${this.length * this.unitHeight}px`);
this.renderer.setStyle(this.lastEl, 'top', null);
}
else {
this.renderer.setStyle(this.firstEl, 'top', null);
this.renderer.setStyle(this.lastEl, 'top', `${-this.unitHeight * this.length}px`);
}
}
prepareHorizontalContext(lastToFirst) {
if (lastToFirst) {
this.renderer.setStyle(this.firstEl, 'left', `${this.length * this.unitWidth}px`);
this.renderer.setStyle(this.lastEl, 'left', null);
}
else {
this.renderer.setStyle(this.firstEl, 'left', null);
this.renderer.setStyle(this.lastEl, 'left', `${-this.unitWidth * this.length}px`);
}
}
}
/**
* 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_CAROUSEL_CUSTOM_STRATEGIES = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'nz-carousel-custom-strategies' : '');
const NZ_CONFIG_MODULE_NAME = 'carousel';
let NzCarouselComponent = (() => {
let _nzEffect_decorators;
let _nzEffect_initializers = [];
let _nzEffect_extraInitializers = [];
let _nzEnableSwipe_decorators;
let _nzEnableSwipe_initializers = [];
let _nzEnableSwipe_extraInitializers = [];
let _nzDots_decorators;
let _nzDots_initializers = [];
let _nzDots_extraInitializers = [];
let _nzAutoPlay_decorators;
let _nzAutoPlay_initializers = [];
let _nzAutoPlay_extraInitializers = [];
let _nzAutoPlaySpeed_decorators;
let _nzAutoPlaySpeed_initializers = [];
let _nzAutoPlaySpeed_extraInitializers = [];
let _nzLoop_decorators;
let _nzLoop_initializers = [];
let _nzLoop_extraInitializers = [];
let _nzDotPosition_decorators;
let _nzDotPosition_initializers = [];
let _nzDotPosition_extraInitializers = [];
return class NzCarouselComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzEffect_decorators = [WithConfig()];
_nzEnableSwipe_decorators = [WithConfig()];
_nzDots_decorators = [WithConfig()];
_nzAutoPlay_decorators = [WithConfig()];
_nzAutoPlaySpeed_decorators = [WithConfig()];
_nzLoop_decorators = [WithConfig()];
_nzDotPosition_decorators = [WithConfig()];
__esDecorate(null, null, _nzEffect_decorators, { kind: "field", name: "nzEffect", static: false, private: false, access: { has: obj => "nzEffect" in obj, get: obj => obj.nzEffect, set: (obj, value) => { obj.nzEffect = value; } }, metadata: _metadata }, _nzEffect_initializers, _nzEffect_extraInitializers);
__esDecorate(null, null, _nzEnableSwipe_decorators, { kind: "field", name: "nzEnableSwipe", static: false, private: false, access: { has: obj => "nzEnableSwipe" in obj, get: obj => obj.nzEnableSwipe, set: (obj, value) => { obj.nzEnableSwipe = value; } }, metadata: _metadata }, _nzEnableSwipe_initializers, _nzEnableSwipe_extraInitializers);
__esDecorate(null, null, _nzDots_decorators, { kind: "field", name: "nzDots", static: false, private: false, access: { has: obj => "nzDots" in obj, get: obj => obj.nzDots, set: (obj, value) => { obj.nzDots = value; } }, metadata: _metadata }, _nzDots_initializers, _nzDots_extraInitializers);
__esDecorate(null, null, _nzAutoPlay_decorators, { kind: "field", name: "nzAutoPlay", static: false, private: false, access: { has: obj => "nzAutoPlay" in obj, get: obj => obj.nzAutoPlay, set: (obj, value) => { obj.nzAutoPlay = value; } }, metadata: _metadata }, _nzAutoPlay_initializers, _nzAutoPlay_extraInitializers);
__esDecorate(null, null, _nzAutoPlaySpeed_decorators, { kind: "field", name: "nzAutoPlaySpeed", static: false, private: false, access: { has: obj => "nzAutoPlaySpeed" in obj, get: obj => obj.nzAutoPlaySpeed, set: (obj, value) => { obj.nzAutoPlaySpeed = value; } }, metadata: _metadata }, _nzAutoPlaySpeed_initializers, _nzAutoPlaySpeed_extraInitializers);
__esDecorate(null, null, _nzLoop_decorators, { kind: "field", name: "nzLoop", static: false, private: false, access: { has: obj => "nzLoop" in obj, get: obj => obj.nzLoop, set: (obj, value) => { obj.nzLoop = value; } }, metadata: _metadata }, _nzLoop_initializers, _nzLoop_extraInitializers);
__esDecorate(null, null, _nzDotPosition_decorators, { kind: "field", name: "nzDotPosition", static: false, private: false, access: { has: obj => "nzDotPosition" in obj, get: obj => obj.nzDotPosition, set: (obj, value) => { obj.nzDotPosition = value; } }, metadata: _metadata }, _nzDotPosition_initializers, _nzDotPosition_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
_nzModuleName = NZ_CONFIG_MODULE_NAME;
nzConfigService = inject(NzConfigService);
ngZone = inject(NgZone);
renderer = inject(Renderer2);
cdr = inject(ChangeDetectorRef);
platform = inject(Platform);
resizeService = inject(NzResizeService);
nzDragService = inject(NzDragService);
nzResizeObserver = inject(NzResizeObserver);
destroyRef = inject(DestroyRef);
carouselContents;
slickList;
slickTrack;
nzDotRender;
nzEffect = __runInitializers(this, _nzEffect_initializers, 'scrollx');
nzEnableSwipe = (__runInitializers(this, _nzEffect_extraInitializers), __runInitializers(this, _nzEnableSwipe_initializers, true));
nzDots = (__runInitializers(this, _nzEnableSwipe_extraInitializers), __runInitializers(this, _nzDots_initializers, true));
nzAutoPlay = (__runInitializers(this, _nzDots_extraInitializers), __runInitializers(this, _nzAutoPlay_initializers, false));
nzAutoPlaySpeed = (__runInitializers(this, _nzAutoPlay_extraInitializers), __runInitializers(this, _nzAutoPlaySpeed_initializers, 3000));
nzTransitionSpeed = (__runInitializers(this, _nzAutoPlaySpeed_extraInitializers), 500);
nzLoop = __runInitializers(this, _nzLoop_initializers, true);
nzArrows = (__runInitializers(this, _nzLoop_extraInitializers), false);
/**
* this property is passed directly to an NzCarouselBaseStrategy
*/
nzStrategyOptions = undefined;
nzDotPosition = __runInitializers(this, _nzDotPosition_initializers, 'bottom');
nzBeforeChange = (__runInitializers(this, _nzDotPosition_extraInitializers), new EventEmitter());
nzAfterChange = new EventEmitter();
activeIndex = 0;
el = inject((ElementRef)).nativeElement;
slickListEl;
slickTrackEl;
strategy;
vertical = false;
transitionInProgress;
dir = 'ltr';
gestureRect = null;
pointerDelta = null;
isTransiting = false;
isDragging = false;
directionality = inject(Directionality);
customStrategies = inject(NZ_CAROUSEL_CUSTOM_STRATEGIES, { optional: true });
constructor() {
this.nzDotPosition = 'bottom';
this.destroyRef.onDestroy(() => {
this.clearScheduledTransition();
this.strategy?.dispose();
});
}
ngOnInit() {
this.slickListEl = this.slickList.nativeElement;
this.slickTrackEl = this.slickTrack.nativeElement;
this.dir = this.directionality.value;
this.directionality.change.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
this.dir = direction;
this.markContentActive(this.activeIndex);
this.cdr.detectChanges();
});
fromEventOutsideAngular(this.slickListEl, 'keydown')
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(event => {
const { keyCode } = event;
if (keyCode !== LEFT_ARROW && keyCode !== RIGHT_ARROW) {
return;
}
event.preventDefault();
this.ngZone.run(() => {
if (keyCode === LEFT_ARROW) {
this.pre();
}
else {
this.next();
}
this.cdr.markForCheck();
});
});
this.nzResizeObserver
.observe(this.el)
.pipe(debounceTime(100), distinctUntilChanged(), takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.layout());
}
ngAfterContentInit() {
this.markContentActive(0);
}
ngAfterViewInit() {
this.carouselContents.changes.subscribe(() => {
this.markContentActive(0);
this.layout();
});
this.resizeService
.connect()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.layout());
this.switchStrategy();
this.markContentActive(0);
this.layout();
// If embedded in an entry component, it may do initial render at an inappropriate time.
// ngZone.onStable won't do this trick
// TODO: need to change this.
Promise.resolve().then(() => this.layout());
}
ngOnChanges(changes) {
const { nzEffect, nzDotPosition } = changes;
if (nzEffect && !nzEffect.isFirstChange()) {
this.switchStrategy();
this.markContentActive(0);
this.layout();
}
if (nzDotPosition) {
this.vertical = nzDotPosition.currentValue === 'left' || nzDotPosition.currentValue === 'right';
if (!nzDotPosition.isFirstChange()) {
this.switchStrategy();
this.markContentActive(0);
this.layout();
}
}
if (!this.nzAutoPlay || !this.nzAutoPlaySpeed) {
this.clearScheduledTransition();
}
else {
this.scheduleNextTransition();
}
}
next() {
this.goTo(this.activeIndex + 1);
}
pre() {
this.goTo(this.activeIndex - 1);
}
goTo(index) {
if (this.carouselContents &&
this.carouselContents.length &&
!this.isTransiting &&
(this.nzLoop || (index >= 0 && index < this.carouselContents.length))) {
const length = this.carouselContents.length;
const from = this.activeIndex;
const to = (index + length) % length;
this.isTransiting = true;
this.nzBeforeChange.emit({ from, to });
this.strategy.switch(this.activeIndex, index).subscribe(() => {
this.scheduleNextTransition();
this.nzAfterChange.emit(to);
this.isTransiting = false;
});
this.markContentActive(to);
this.cdr.markForCheck();
}
}
switchStrategy() {
if (this.strategy) {
this.strategy.dispose();
}
// Load custom strategies first.
const customStrategy = this.customStrategies ? this.customStrategies.find(s => s.name === this.nzEffect) : null;
if (customStrategy) {
this.strategy = new customStrategy.strategy(this, this.cdr, this.renderer, this.platform);
return;
}
this.strategy =
this.nzEffect === 'scrollx'
? new NzCarouselTransformStrategy(this, this.cdr, this.renderer, this.platform)
: new NzCarouselOpacityStrategy(this, this.cdr, this.renderer, this.platform);
}
scheduleNextTransition() {
this.clearScheduledTransition();
if (this.nzAutoPlay && this.nzAutoPlaySpeed > 0 && this.platform.isBrowser) {
this.transitionInProgress = setTimeout(() => {
this.goTo(this.activeIndex + 1);
}, this.nzAutoPlaySpeed);
}
}
clearScheduledTransition() {
if (this.transitionInProgress) {
clearTimeout(this.transitionInProgress);
this.transitionInProgress = undefined;
}
}
markContentActive(index) {
this.activeIndex = index;
this.carouselContents?.forEach((slide, i) => (slide.isActive = index === i));
this.cdr.markForCheck();
}
/**
* Drag carousel.
*/
pointerDown = (event) => {
if (!this.isDragging && !this.isTransiting && this.nzEnableSwipe) {
this.clearScheduledTransition();
this.gestureRect = this.slickListEl.getBoundingClientRect();
this.nzDragService.requestDraggingSequence(event).subscribe({
next: delta => {
this.pointerDelta = delta;
this.isDragging = true;
this.strategy?.dragging(this.pointerDelta);
},
complete: () => {
if (this.nzEnableSwipe && this.isDragging) {
const xDelta = this.pointerDelta ? this.pointerDelta.x : 0;
// Switch to another slide if delta is bigger than third of the width.
if (Math.abs(xDelta) > this.gestureRect.width / 3 &&
(this.nzLoop ||
(xDelta <= 0 && this.activeIndex + 1 < this.carouselContents.length) ||
(xDelta > 0 && this.activeIndex > 0))) {
this.goTo(xDelta > 0 ? this.activeIndex - 1 : this.activeIndex + 1);
}
else {
this.goTo(this.activeIndex);
}
this.gestureRect = null;
this.pointerDelta = null;
}
this.isDragging = false;
}
});
}
};
layout() {
this.strategy?.withCarouselContents(this.carouselContents);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCarouselComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCarouselComponent, isStandalone: true, selector: "nz-carousel", inputs: { nzDotRender: "nzDotRender", nzEffect: "nzEffect", nzEnableSwipe: ["nzEnableSwipe", "nzEnableSwipe", booleanAttribute], nzDots: ["nzDots", "nzDots", booleanAttribute], nzAutoPlay: ["nzAutoPlay", "nzAutoPlay", booleanAttribute], nzAutoPlaySpeed: ["nzAutoPlaySpeed", "nzAutoPlaySpeed", numberAttribute], nzTransitionSpeed: ["nzTransitionSpeed", "nzTransitionSpeed", numberAttribute], nzLoop: "nzLoop", nzArrows: ["nzArrows", "nzArrows", booleanAttribute], nzStrategyOptions: "nzStrategyOptions", nzDotPosition: "nzDotPosition" }, outputs: { nzBeforeChange: "nzBeforeChange", nzAfterChange: "nzAfterChange" }, host: { properties: { "class.ant-carousel-vertical": "vertical", "class.ant-carousel-rtl": "dir === 'rtl'" }, classAttribute: "ant-carousel" }, queries: [{ propertyName: "carouselContents", predicate: NzCarouselContentDirective }], viewQueries: [{ propertyName: "slickList", first: true, predicate: ["slickList"], descendants: true, static: true }, { propertyName: "slickTrack", first: true, predicate: ["slickTrack"], descendants: true, static: true }], exportAs: ["nzCarousel"], usesOnChanges: true, ngImport: i0, template: `
<div
class="slick-initialized slick-slider"
[class.slick-vertical]="nzDotPosition === 'left' || nzDotPosition === 'right'"
[dir]="'ltr'"
>
@if (nzArrows) {
<button
type="button"
aria-label="prev"
class="slick-prev slick-arrow"
[class.slick-disabled]="this.activeIndex === 0"
(click)="pre()"
></button>
}
<div
#slickList
class="slick-list"
tabindex="-1"
(mousedown)="pointerDown($event)"
(touchstart)="pointerDown($event)"
>
<!-- Render carousel items. -->
<div class="slick-track" #slickTrack>
<ng-content></ng-content>
</div>
</div>
@if (nzArrows) {
<button
type="button"
aria-label="next"
class="slick-next slick-arrow"
[class.slick-disabled]="this.activeIndex === this.carouselContents.length - 1"
(click)="next()"
></button>
}
<!-- Render dots. -->
@if (nzDots) {
<ul
class="slick-dots"
[class.slick-dots-top]="nzDotPosition === 'top'"
[class.slick-dots-bottom]="nzDotPosition === 'bottom'"
[class.slick-dots-left]="nzDotPosition === 'left'"
[class.slick-dots-right]="nzDotPosition === 'right'"
>
@for (content of carouselContents; track content) {
<li [class.slick-active]="$index === activeIndex" (click)="goTo($index)">
<ng-template
[ngTemplateOutlet]="nzDotRender || renderDotTemplate"
[ngTemplateOutletContext]="{ $implicit: $index }"
></ng-template>
</li>
}
</ul>
}
</div>
<ng-template #renderDotTemplate let-index>
<button>{{ index + 1 }}</button>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCarouselComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-carousel',
exportAs: 'nzCarousel',
template: `
<div
class="slick-initialized slick-slider"
[class.slick-vertical]="nzDotPosition === 'left' || nzDotPosition === 'right'"
[dir]="'ltr'"
>
@if (nzArrows) {
<button
type="button"
aria-label="prev"
class="slick-prev slick-arrow"
[class.slick-disabled]="this.activeIndex === 0"
(click)="pre()"
></button>
}
<div
#slickList
class="slick-list"
tabindex="-1"
(mousedown)="pointerDown($event)"
(touchstart)="pointerDown($event)"
>
<!-- Render carousel items. -->
<div class="slick-track" #slickTrack>
<ng-content></ng-content>
</div>
</div>
@if (nzArrows) {
<button
type="button"
aria-label="next"
class="slick-next slick-arrow"
[class.slick-disabled]="this.activeIndex === this.carouselContents.length - 1"
(click)="next()"
></button>
}
<!-- Render dots. -->
@if (nzDots) {
<ul
class="slick-dots"
[class.slick-dots-top]="nzDotPosition === 'top'"
[class.slick-dots-bottom]="nzDotPosition === 'bottom'"
[class.slick-dots-left]="nzDotPosition === 'left'"
[class.slick-dots-right]="nzDotPosition === 'right'"
>
@for (content of carouselContents; track content) {
<li [class.slick-active]="$index === activeIndex" (click)="goTo($index)">
<ng-template
[ngTemplateOutlet]="nzDotRender || renderDotTemplate"
[ngTemplateOutletContext]="{ $implicit: $index }"
></ng-template>
</li>
}
</ul>
}
</div>
<ng-template #renderDotTemplate let-index>
<button>{{ index + 1 }}</button>
</ng-template>
`,
host: {
class: 'ant-carousel',
'[class.ant-carousel-vertical]': 'vertical',
'[class.ant-carousel-rtl]': `dir === 'rtl'`
},
imports: [NgTemplateOutlet]
}]
}], ctorParameters: () => [], propDecorators: { carouselContents: [{
type: ContentChildren,
args: [NzCarouselContentDirective]
}], slickList: [{
type: ViewChild,
args: ['slickList', { static: true }]
}], slickTrack: [{
type: ViewChild,
args: ['slickTrack', { static: true }]
}], nzDotRender: [{
type: Input
}], nzEffect: [{
type: Input
}], nzEnableSwipe: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzDots: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzAutoPlay: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzAutoPlaySpeed: [{
type: Input,
args: [{ transform: numberAttribute }]
}], nzTransitionSpeed: [{
type: Input,
args: [{ transform: numberAttribute }]
}], nzLoop: [{
type: Input
}], nzArrows: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzStrategyOptions: [{
type: Input
}], nzDotPosition: [{
type: Input
}], nzBeforeChange: [{
type: Output
}], nzAfterChange: [{
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 NzCarouselModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCarouselModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCarouselModule, imports: [NzCarouselComponent, NzCarouselContentDirective], exports: [NzCarouselComponent, NzCarouselContentDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCarouselModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCarouselModule, decorators: [{
type: NgModule,
args: [{
imports: [NzCarouselComponent, NzCarouselContentDirective],
exports: [NzCarouselComponent, NzCarouselContentDirective]
}]
}] });
/**
* 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
*/
/**
* this strategy is very much like NzCarouselTransformStrategy, but it doesn't loop between the first and the last one
*/
class NzCarouselTransformNoLoopStrategy extends NzCarouselBaseStrategy {
isTransitioning = false;
get vertical() {
return this.carouselComponent.vertical;
}
constructor(carouselComponent, cdr, renderer, platform, options) {
super(carouselComponent, cdr, renderer, platform, options);
}
dispose() {
this.renderer.setStyle(this.slickTrackEl, 'transform', null);
super.dispose();
}
withCarouselContents(contents) {
super.withCarouselContents(contents);
const carousel = this.carouselComponent;
const activeIndex = carousel.activeIndex;
if (this.platform.isBrowser && this.contents.length) {
this.renderer.setStyle(this.slickListEl, 'height', `${this.unitHeight}px`);
if (this.platform.isBrowser && this.contents.length) {
this.renderer.setStyle(this.slickListEl, 'height', `${this.unitHeight}px`);
if (this.vertical) {
this.renderer.setStyle(this.slickTrackEl, 'width', `${this.unitWidth}px`);
this.renderer.setStyle(this.slickTrackEl, 'height', `${this.length * this.unitHeight}px`);
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(0, ${-activeIndex * this.unitHeight}px, 0)`);
}
else {
this.renderer.setStyle(this.slickTrackEl, 'height', `${this.unitHeight}px`);
this.renderer.setStyle(this.slickTrackEl, 'width', `${this.length * this.unitWidth}px`);
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(${-activeIndex * this.unitWidth}px, 0, 0)`);
}
this.contents.forEach((content) => {
this.renderer.setStyle(content.el, 'position', 'relative');
this.renderer.setStyle(content.el, 'width', `${this.unitWidth}px`);
this.renderer.setStyle(content.el, 'height', `${this.unitHeight}px`);
});
}
}
}
switch(_f, _t) {
const to = (_t + this.length) % this.length;
const transitionSpeed = this.carouselComponent.nzTransitionSpeed;
const complete$ = new Subject();
this.renderer.setStyle(this.slickTrackEl, 'transition', `transform ${transitionSpeed}ms ease`);
if (this.vertical) {
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(0, ${-to * this.unitHeight}px, 0)`);
}
else {
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(${-to * this.unitWidth}px, 0, 0)`);
}
this.isTransitioning = true;
setTimeout(() => {
// this strategy don't need to do a following adjust
this.isTransitioning = false;
complete$.next();
complete$.complete();
}, transitionSpeed);
return complete$.asObservable();
}
dragging(vector) {
if (this.isTransitioning) {
return;
}
const activeIndex = this.carouselComponent.activeIndex;
if (this.vertical) {
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(0, ${-activeIndex * this.unitHeight + vector.x}px, 0)`);
}
else {
this.renderer.setStyle(this.slickTrackEl, 'transform', `translate3d(${-activeIndex * this.unitWidth + vector.x}px, 0, 0)`);
}
}
}
/**
* 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 NzCarouselFlipStrategy extends NzCarouselBaseStrategy {
withCarouselContents(contents) {
super.withCarouselContents(contents);
if (this.contents) {
this.renderer.setStyle(this.slickListEl, 'width', `${this.unitWidth}px`);
this.renderer.setStyle(this.slickTrackEl, 'width', `${this.length * this.unitWidth}px`);
this.contents.forEach((content, i) => {
const cur = this.carouselComponent.activeIndex === i;
this.renderer.setStyle(content.el, 'transform', cur ? 'rotateY(0deg)' : 'rotateY(180deg)');
this.renderer.setStyle(content.el, 'position', 'relative');
this.renderer.setStyle(content.el, 'width', `${this.unitWidth}px`);
this.renderer.setStyle(content.el, 'left', `${-this.unitWidth * i}px`);
this.renderer.setStyle(content.el, 'transform-style', 'preserve-3d');
this.renderer.setStyle(content.el, 'backface-visibility', 'hidden');
});
const { carouselComponent } = this;
carouselComponent.ngZone.runOutsideAngular(() => {
setTimeout(() => {
this.contents.forEach(c => this.renderer.setStyle(c.el, 'transition', ['transform 500ms ease 0s']));
}, carouselComponent.nzTransitionSpeed);
});
}
}
switch(rawF, rawT) {
const { from, to } = this.getFromToInBoundary(rawF, rawT);
const complete$ = new Subject();
const speed = this.carouselComponent.nzTransitionSpeed;
setTimeout(() => {
complete$.next();
complete$.complete();
}, speed);
if (rawF === rawT) {
return complete$;
}
this.contents.forEach((content, i) => {
if (i === from) {
this.renderer.setStyle(content.el, 'transform', 'rotateY(180deg)');
}
else if (i === to) {
this.renderer.setStyle(content.el, 'transform', 'rotateY(0deg)');
}
});
return complete$.asObservable();
}
dispose() {
this.contents.forEach((content) => {
this.renderer.setStyle(content.el, 'transition', null);
this.renderer.setStyle(content.el, 'transform', null);
this.renderer.setStyle(content.el, 'width', null);
this.renderer.setStyle(content.el, 'left', null);
this.renderer.setStyle(content.el, 'transform-style', null);
this.renderer.setStyle(content.el, 'backface-visibility', null);
});
super.dispose();
}
}
/**
* 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_CAROUSEL_CUSTOM_STRATEGIES, NzCarouselBaseStrategy, NzCarouselComponent, NzCarouselContentDirective, NzCarouselFlipStrategy, NzCarouselModule, NzCarouselOpacityStrategy, NzCarouselTransformNoLoopStrategy, NzCarouselTransformStrategy };
//# sourceMappingURL=ng-zorro-antd-carousel.mjs.map
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+284
View File
@@ -0,0 +1,284 @@
import * as i0 from '@angular/core';
import { inject, ElementRef, ChangeDetectorRef, Directive, DestroyRef, ContentChild, ContentChildren, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Subject, ReplaySubject, BehaviorSubject, combineLatest } from 'rxjs';
import { map, distinctUntilChanged, startWith, tap, pairwise, withLatestFrom, switchMap, filter } from 'rxjs/operators';
import { NzResizeObserver } from 'ng-zorro-antd/cdk/resize-observer';
/**
* 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 NzOverflowItemDirective {
nzResizeObserver = inject(NzResizeObserver);
elementRef = inject(ElementRef);
cdr = inject(ChangeDetectorRef);
overflowStyle = undefined;
itemWidth$ = this.nzResizeObserver.observe(this.elementRef.nativeElement).pipe(map(([item]) => item.target.offsetWidth), distinctUntilChanged(), startWith(undefined), tap(width => {
this.itemWidth = width;
}));
itemWidth = undefined;
setItemStyle(display, order) {
const mergedHidden = !display;
this.overflowStyle = {
opacity: mergedHidden ? 0 : 1,
height: mergedHidden ? 0 : undefined,
overflowY: mergedHidden ? 'hidden' : undefined,
order: order,
pointerEvents: mergedHidden ? 'none' : undefined,
position: mergedHidden ? 'absolute' : undefined
};
this.cdr.detectChanges();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzOverflowItemDirective, isStandalone: true, selector: "[nzOverflowItem]", host: { properties: { "style": "overflowStyle" } }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowItemDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzOverflowItem]',
host: {
'[style]': 'overflowStyle'
}
}]
}] });
/**
* 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 NzOverflowRestDirective {
nzResizeObserver = inject(NzResizeObserver);
elementRef = inject(ElementRef);
cdr = inject(ChangeDetectorRef);
restStyle = undefined;
restWidth$ = this.nzResizeObserver.observe(this.elementRef.nativeElement).pipe(map(([item]) => item.target.offsetWidth), startWith(0), tap(width => (this.restWidth = width)));
restWidth = 0;
setRestStyle(display, order) {
const mergedHidden = !display;
this.restStyle = {
opacity: mergedHidden ? 0 : 1,
height: mergedHidden ? 0 : undefined,
overflowY: mergedHidden ? 'hidden' : undefined,
order: order,
pointerEvents: mergedHidden ? 'none' : undefined,
position: mergedHidden ? 'absolute' : undefined
};
this.cdr.detectChanges();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowRestDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzOverflowRestDirective, isStandalone: true, selector: "[nzOverflowRest]", host: { properties: { "style": "restStyle" } }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowRestDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzOverflowRest]',
host: {
'[style]': 'restStyle'
}
}]
}] });
/**
* 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 NzOverflowSuffixDirective {
nzResizeObserver = inject(NzResizeObserver);
elementRef = inject(ElementRef);
cdr = inject(ChangeDetectorRef);
suffixStyle = {};
suffixWidth$ = this.nzResizeObserver.observe(this.elementRef.nativeElement).pipe(map(([item]) => item.target.offsetWidth), tap(width => (this.suffixWidth = width)));
suffixWidth = 0;
setSuffixStyle(start, order) {
if (start !== null) {
this.suffixStyle = {
position: 'absolute',
left: `${start}px`,
top: 0,
opacity: 1,
order: order
};
}
else {
this.suffixStyle = {
opacity: 1,
order: order
};
}
this.cdr.detectChanges();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowSuffixDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzOverflowSuffixDirective, isStandalone: true, selector: "[nzOverflowSuffix]", host: { properties: { "style": "suffixStyle" } }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowSuffixDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzOverflowSuffix]',
host: {
'[style]': 'suffixStyle'
}
}]
}] });
/**
* 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 NzOverflowContainerComponent {
nzResizeObserver = inject(NzResizeObserver);
elementRef = inject(ElementRef);
cdr = inject(ChangeDetectorRef);
destroyRef = inject(DestroyRef);
contentInit$ = new Subject();
overflowItems = undefined;
overflowSuffix = undefined;
overflowRest = undefined;
overflowItems$ = new ReplaySubject(1);
containerWidth$ = this.nzResizeObserver
.observe(this.elementRef.nativeElement)
.pipe(map(([item]) => item.target.clientWidth || 0));
restWidth$ = new BehaviorSubject(0);
suffixWidth$ = new BehaviorSubject(0);
suffixFixedStart$ = new BehaviorSubject(null);
displayCount$ = new BehaviorSubject(Number.MAX_SAFE_INTEGER);
restReady$ = new BehaviorSubject(false);
maxRestWith$ = this.restWidth$.pipe(pairwise(), map(([prevRestWidth, restWidth]) => Math.max(prevRestWidth, restWidth)));
omittedItems$ = combineLatest([this.overflowItems$, this.displayCount$]).pipe(withLatestFrom(this.contentInit$), map(([[overflowItems, displayCount]]) => overflowItems.toArray().slice(displayCount + 1)));
displayRest$ = combineLatest([this.restReady$, this.omittedItems$]).pipe(map(([restReady, omittedItems]) => restReady && !!omittedItems.length));
updateDisplayCount(count, notReady) {
this.displayCount$.next(count);
if (this.overflowItems && !notReady) {
this.restReady$.next(count < this.overflowItems.length - 1);
}
}
ngOnInit() {
const overflowItemsWidth$ = this.overflowItems$.pipe(switchMap(items => combineLatest(items.map(item => item.itemWidth$))));
this.overflowItems$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(overflowItems => {
if (!overflowItems.length) {
this.displayCount$.next(0);
this.suffixFixedStart$.next(null);
}
});
combineLatest([overflowItemsWidth$, this.containerWidth$, this.maxRestWith$, this.restWidth$, this.suffixWidth$])
.pipe(filter(([, containerWidth, maxRestWith]) => !!(containerWidth && maxRestWith)), takeUntilDestroyed(this.destroyRef))
.subscribe(([overflowItemsWidth, containerWidth, maxRestWith, restWidth, suffixWidth]) => {
let totalWidth = suffixWidth;
const len = overflowItemsWidth.length;
const lastIndex = len - 1;
for (let i = 0; i < len; i += 1) {
const currentItemWidth = overflowItemsWidth[i];
// Break since data not ready
if (currentItemWidth === undefined) {
this.updateDisplayCount(i - 1, true);
break;
}
else {
// Find best match
totalWidth += currentItemWidth;
if (
// Only one means `totalWidth` is the final width
(lastIndex === 0 && totalWidth <= containerWidth) ||
// Last two width will be the final width
(i === lastIndex - 1 &&
overflowItemsWidth[lastIndex] !== undefined &&
totalWidth + overflowItemsWidth[lastIndex] <= containerWidth)) {
// Additional check if match the end
this.updateDisplayCount(lastIndex);
this.suffixFixedStart$.next(null);
break;
}
else if (totalWidth + maxRestWith > containerWidth) {
// Can not hold all the content to show rest
this.updateDisplayCount(i - 1);
this.suffixFixedStart$.next(totalWidth - currentItemWidth - suffixWidth + restWidth);
break;
}
this.cdr.detectChanges();
}
}
if (this.overflowSuffix &&
overflowItemsWidth[0] !== undefined &&
overflowItemsWidth[0] + suffixWidth > containerWidth) {
this.suffixFixedStart$.next(null);
}
this.cdr.detectChanges();
});
combineLatest([this.suffixFixedStart$, this.displayCount$])
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(([suffixFixedStart, displayCount]) => {
this.overflowSuffix?.setSuffixStyle(suffixFixedStart, displayCount);
});
combineLatest([this.displayCount$, this.overflowItems$])
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(([displayCount, overflowItems]) => overflowItems.forEach((item, index) => item.setItemStyle(index <= displayCount, index)));
combineLatest([this.displayRest$, this.displayCount$])
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(([displayRest, displayCount]) => {
this.overflowRest?.setRestStyle(displayRest, displayRest ? displayCount : Number.MAX_SAFE_INTEGER);
});
}
ngAfterContentInit() {
this.overflowItems?.changes.pipe(startWith(this.overflowItems)).subscribe(this.overflowItems$);
this.overflowSuffix?.suffixWidth$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(this.suffixWidth$);
this.overflowRest?.restWidth$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(this.restWidth$);
this.contentInit$.next();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzOverflowContainerComponent, isStandalone: true, selector: "nz-overflow-container", providers: [NzResizeObserver], queries: [{ propertyName: "overflowSuffix", first: true, predicate: NzOverflowSuffixDirective, descendants: true }, { propertyName: "overflowRest", first: true, predicate: NzOverflowRestDirective, descendants: true }, { propertyName: "overflowItems", predicate: NzOverflowItemDirective }], ngImport: i0, template: `
<ng-content></ng-content>
<ng-content select="[appOverflowRest]"></ng-content>
<ng-content select="[appOverflowSuffix]"></ng-content>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowContainerComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-overflow-container',
template: `
<ng-content></ng-content>
<ng-content select="[appOverflowRest]"></ng-content>
<ng-content select="[appOverflowSuffix]"></ng-content>
`,
providers: [NzResizeObserver],
changeDetection: ChangeDetectionStrategy.OnPush
}]
}], propDecorators: { overflowItems: [{
type: ContentChildren,
args: [NzOverflowItemDirective]
}], overflowSuffix: [{
type: ContentChild,
args: [NzOverflowSuffixDirective]
}], overflowRest: [{
type: ContentChild,
args: [NzOverflowRestDirective]
}] } });
/**
* 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 NzOverflowModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowModule, imports: [NzOverflowContainerComponent, NzOverflowItemDirective, NzOverflowRestDirective, NzOverflowSuffixDirective], exports: [NzOverflowContainerComponent, NzOverflowItemDirective, NzOverflowRestDirective, NzOverflowSuffixDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverflowModule, decorators: [{
type: NgModule,
args: [{
imports: [NzOverflowContainerComponent, NzOverflowItemDirective, NzOverflowRestDirective, NzOverflowSuffixDirective],
exports: [NzOverflowContainerComponent, NzOverflowItemDirective, NzOverflowRestDirective, NzOverflowSuffixDirective]
}]
}] });
/**
* 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 { NzOverflowContainerComponent, NzOverflowItemDirective, NzOverflowModule, NzOverflowRestDirective, NzOverflowSuffixDirective };
//# sourceMappingURL=ng-zorro-antd-cdk-overflow.mjs.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,173 @@
import * as i0 from '@angular/core';
import { Injectable, inject, DestroyRef, ElementRef, EventEmitter, booleanAttribute, Input, Output, Directive, NgModule } from '@angular/core';
import { coerceElement } from '@angular/cdk/coercion';
import { Observable, Subject } from 'rxjs';
/**
* 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
*/
/**
* Factory that creates a new ResizeObserver and allows us to stub it out in unit tests.
*/
class NzResizeObserverFactory {
create(callback) {
return typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(callback);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverFactory, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverFactory, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}] });
/** An injectable service that allows watching elements for changes to their content. */
class NzResizeObserver {
nzResizeObserverFactory = inject(NzResizeObserverFactory);
destroyRef = inject(DestroyRef);
/** Keeps track of the existing ResizeObservers so they can be reused. */
observedElements = new Map();
constructor() {
this.destroyRef.onDestroy(() => this.observedElements.forEach((_, element) => this.cleanupObserver(element)));
}
observe(elementOrRef) {
const element = coerceElement(elementOrRef);
return new Observable((observer) => {
const stream = this.observeElement(element);
const subscription = stream.subscribe(observer);
return () => {
subscription.unsubscribe();
this.unobserveElement(element);
};
});
}
/**
* Observes the given element by using the existing ResizeObserver if available, or creating a
* new one if not.
*/
observeElement(element) {
if (!this.observedElements.has(element)) {
const stream = new Subject();
const observer = this.nzResizeObserverFactory.create((mutations) => stream.next(mutations));
if (observer) {
observer.observe(element);
}
this.observedElements.set(element, { observer, stream, count: 1 });
}
else {
this.observedElements.get(element).count++;
}
return this.observedElements.get(element).stream;
}
/**
* Un-observes the given element and cleans up the underlying ResizeObserver if nobody else is
* observing this element.
*/
unobserveElement(element) {
if (this.observedElements.has(element)) {
this.observedElements.get(element).count--;
if (!this.observedElements.get(element).count) {
this.cleanupObserver(element);
}
}
}
/** Clean up the underlying ResizeObserver for the specified element. */
cleanupObserver(element) {
if (this.observedElements.has(element)) {
const { observer, stream } = this.observedElements.get(element);
if (observer) {
observer.disconnect();
}
stream.complete();
this.observedElements.delete(element);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserver, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserver, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}], ctorParameters: () => [] });
/**
* 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 NzResizeObserverDirective {
nzResizeObserver = inject(NzResizeObserver);
elementRef = inject((ElementRef));
destroyRef = inject(DestroyRef);
nzResizeObserve = new EventEmitter();
nzResizeObserverDisabled = false;
currentSubscription = null;
subscribe() {
this.unsubscribe();
this.currentSubscription = this.nzResizeObserver.observe(this.elementRef).subscribe(this.nzResizeObserve);
}
unsubscribe() {
this.currentSubscription?.unsubscribe();
}
constructor() {
this.destroyRef.onDestroy(() => this.unsubscribe());
}
ngAfterContentInit() {
if (!this.currentSubscription && !this.nzResizeObserverDisabled) {
this.subscribe();
}
}
ngOnChanges(changes) {
const { nzResizeObserve } = changes;
if (nzResizeObserve) {
if (this.nzResizeObserverDisabled) {
this.unsubscribe();
}
else {
this.subscribe();
}
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.3.0", type: NzResizeObserverDirective, isStandalone: true, selector: "[nzResizeObserver]", inputs: { nzResizeObserverDisabled: ["nzResizeObserverDisabled", "nzResizeObserverDisabled", booleanAttribute] }, outputs: { nzResizeObserve: "nzResizeObserve" }, providers: [NzResizeObserverFactory], usesOnChanges: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzResizeObserver]',
providers: [NzResizeObserverFactory]
}]
}], ctorParameters: () => [], propDecorators: { nzResizeObserve: [{
type: Output
}], nzResizeObserverDisabled: [{
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 NzResizeObserverModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverModule, imports: [NzResizeObserverDirective], exports: [NzResizeObserverDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeObserverModule, decorators: [{
type: NgModule,
args: [{
imports: [NzResizeObserverDirective],
exports: [NzResizeObserverDirective]
}]
}] });
/**
* 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 { NzResizeObserver, NzResizeObserverDirective, NzResizeObserverFactory, NzResizeObserverModule };
//# sourceMappingURL=ng-zorro-antd-cdk-resize-observer.mjs.map
File diff suppressed because one or more lines are too long
+385
View File
@@ -0,0 +1,385 @@
import { DecimalPipe } from '@angular/common';
import * as i0 from '@angular/core';
import { ViewEncapsulation, ChangeDetectionStrategy, Component, input, output, signal, computed, linkedSignal, inject, NgModule } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { map } from 'rxjs/operators';
import * as i3 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { NzI18nService } from 'ng-zorro-antd/i18n';
import * as i1 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
import * as i1$1 from 'ng-zorro-antd/popover';
import { NzPopoverModule } from 'ng-zorro-antd/popover';
import * as i8 from '@angular/forms';
import { FormsModule } from '@angular/forms';
import * as i5 from 'ng-zorro-antd/button';
import { NzButtonModule } from 'ng-zorro-antd/button';
import * as i4 from 'ng-zorro-antd/checkbox';
import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
import * as i2 from 'ng-zorro-antd/progress';
import { NzProgressModule } from 'ng-zorro-antd/progress';
import * as i6 from 'ng-zorro-antd/core/transition-patch';
import * as i7 from 'ng-zorro-antd/core/wave';
/**
* 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
*/
/**
* 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 NzCheckListButtonComponent {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzCheckListButtonComponent, isStandalone: true, selector: "nz-check-list-button", host: { classAttribute: "ant-btn ant-btn-primary ant-check-list-button" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListButtonComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-check-list-button',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: `<ng-content></ng-content>`,
host: {
class: 'ant-btn ant-btn-primary ant-check-list-button'
}
}]
}] });
/**
* 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 NzCheckListContentComponent {
locale = input.required(...(ngDevMode ? [{ debugName: "locale" }] : []));
items = input([], ...(ngDevMode ? [{ debugName: "items" }] : []));
index = input(0, ...(ngDevMode ? [{ debugName: "index" }] : []));
progress = input(true, ...(ngDevMode ? [{ debugName: "progress" }] : []));
title = input(null, ...(ngDevMode ? [{ debugName: "title" }] : []));
footer = input(null, ...(ngDevMode ? [{ debugName: "footer" }] : []));
closePopover = output();
hide = output();
checked = false;
visible = signal(true, ...(ngDevMode ? [{ debugName: "visible" }] : []));
progressPercent = computed(() => {
const index = Math.min(Math.max(this.index() - 1, 0), this.items().length);
return (index / this.items().length) * 100;
}, ...(ngDevMode ? [{ debugName: "progressPercent" }] : []));
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCheckListContentComponent, isStandalone: true, selector: "nz-check-list-content", inputs: { locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: true, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null }, progress: { classPropertyName: "progress", publicName: "progress", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, footer: { classPropertyName: "footer", publicName: "footer", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closePopover: "closePopover", hide: "hide" }, host: { classAttribute: "ant-check-list-content" }, ngImport: i0, template: `
@let i18n = locale();
@if (visible()) {
@if (progressPercent() === 100) {
<div class="ant-check-list-header-finish">
<nz-icon nzType="check-circle" nzTheme="outline" class="ant-check-list-header-finish-icon" />
<h3 class="ant-check-list-header-finish-title">{{ i18n.checkListFinish }}</h3>
<button nz-button nzType="primary" [style.margin.px]="24" (click)="closePopover.emit(false)">
{{ i18n.checkListClose }}
</button>
</div>
} @else {
<div class="ant-check-list-header">
<div class="ant-check-list-header-title">
@if (!!title()) {
<ng-container *nzStringTemplateOutlet="title()">{{ title() }}</ng-container>
} @else {
{{ i18n.checkList }}
}
</div>
<div class="ant-check-list-header-extra">
<nz-icon nzType="down" nzTheme="outline" (click)="closePopover.emit(false)" />
</div>
</div>
@if (progress()) {
<div class="ant-check-list-progressBar">
<div class="ant-check-list-progressBar-progress">
<nz-progress [nzPercent]="progressPercent() | number: '1.0-0'"></nz-progress>
</div>
</div>
}
}
<div class="ant-check-list-steps-content">
@for (item of items(); track item.key || item.description; let i = $index) {
@let itemHighlight = index() === i + 1;
<div
class="ant-check-list-steps"
[class.ant-check-list-highlight]="itemHighlight"
[class.ant-check-list-checked]="item?.checked"
>
<div class="ant-check-list-steps-item">
<div class="ant-check-list-steps-item-circle">
@if (item?.checked) {
<nz-icon nzType="check" nzTheme="outline" class="ant-check-list-steps-checkoutlined" />
} @else {
<div class="ant-check-list-steps-number">{{ i + 1 }}</div>
}
</div>
<div class="ant-check-list-steps-item-description">{{ item.description }}</div>
</div>
@if (itemHighlight && !!item?.onClick) {
<nz-icon
nzType="arrow-right"
nzTheme="outline"
class="ant-check-list-steps-item-arrows"
(click)="item.onClick?.(item)"
/>
}
</div>
}
</div>
<div class="ant-check-list-footer" (click)="visible.set(false)">
@if (!!footer()) {
<ng-container *nzStringTemplateOutlet="footer()">{{ footer() }}</ng-container>
} @else {
{{ i18n.checkListFooter }}
}
</div>
} @else {
<div class="ant-check-list-close-check">
<div class="ant-check-list-close-check-title">{{ i18n.checkListCheck }}</div>
<div class="ant-check-list-close-check-action">
<button nz-button nzType="primary" (click)="visible.set(false); hide.emit(checked)">{{ i18n.ok }}</button>
<button nz-button (click)="visible.set(true)">{{ i18n.cancel }}</button>
</div>
<div class="ant-check-list-close-check-other">
<label nz-checkbox [(ngModel)]="checked">{{ i18n.checkListCheckOther }}</label>
</div>
</div>
}
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzProgressModule }, { kind: "component", type: i2.NzProgressComponent, selector: "nz-progress", inputs: ["nzShowInfo", "nzWidth", "nzStrokeColor", "nzSize", "nzFormat", "nzSuccessPercent", "nzPercent", "nzStrokeWidth", "nzGapDegree", "nzStatus", "nzType", "nzGapPosition", "nzStrokeLinecap", "nzSteps"], exportAs: ["nzProgress"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "ngmodule", type: NzCheckboxModule }, { kind: "component", type: i4.NzCheckboxComponent, selector: "[nz-checkbox]", inputs: ["nzValue", "nzAutoFocus", "nzDisabled", "nzIndeterminate", "nzChecked", "nzId", "nzName"], outputs: ["nzCheckedChange"], exportAs: ["nzCheckbox"] }, { kind: "ngmodule", type: NzButtonModule }, { kind: "component", type: i5.NzButtonComponent, selector: "button[nz-button], a[nz-button]", inputs: ["nzBlock", "nzGhost", "nzSearch", "nzLoading", "nzDanger", "disabled", "tabIndex", "nzType", "nzShape", "nzSize"], exportAs: ["nzButton"] }, { kind: "directive", type: i6.ɵNzTransitionPatchDirective, selector: "[nz-button], [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { kind: "directive", type: i7.NzWaveDirective, selector: "[nz-wave],button[nz-button]:not([nzType=\"link\"]):not([nzType=\"text\"])", inputs: ["nzWaveExtraNode"], exportAs: ["nzWave"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i8.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i8.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "pipe", type: DecimalPipe, name: "number" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListContentComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-check-list-content',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
imports: [NzIconModule, NzProgressModule, NzOutletModule, NzCheckboxModule, NzButtonModule, FormsModule, DecimalPipe],
template: `
@let i18n = locale();
@if (visible()) {
@if (progressPercent() === 100) {
<div class="ant-check-list-header-finish">
<nz-icon nzType="check-circle" nzTheme="outline" class="ant-check-list-header-finish-icon" />
<h3 class="ant-check-list-header-finish-title">{{ i18n.checkListFinish }}</h3>
<button nz-button nzType="primary" [style.margin.px]="24" (click)="closePopover.emit(false)">
{{ i18n.checkListClose }}
</button>
</div>
} @else {
<div class="ant-check-list-header">
<div class="ant-check-list-header-title">
@if (!!title()) {
<ng-container *nzStringTemplateOutlet="title()">{{ title() }}</ng-container>
} @else {
{{ i18n.checkList }}
}
</div>
<div class="ant-check-list-header-extra">
<nz-icon nzType="down" nzTheme="outline" (click)="closePopover.emit(false)" />
</div>
</div>
@if (progress()) {
<div class="ant-check-list-progressBar">
<div class="ant-check-list-progressBar-progress">
<nz-progress [nzPercent]="progressPercent() | number: '1.0-0'"></nz-progress>
</div>
</div>
}
}
<div class="ant-check-list-steps-content">
@for (item of items(); track item.key || item.description; let i = $index) {
@let itemHighlight = index() === i + 1;
<div
class="ant-check-list-steps"
[class.ant-check-list-highlight]="itemHighlight"
[class.ant-check-list-checked]="item?.checked"
>
<div class="ant-check-list-steps-item">
<div class="ant-check-list-steps-item-circle">
@if (item?.checked) {
<nz-icon nzType="check" nzTheme="outline" class="ant-check-list-steps-checkoutlined" />
} @else {
<div class="ant-check-list-steps-number">{{ i + 1 }}</div>
}
</div>
<div class="ant-check-list-steps-item-description">{{ item.description }}</div>
</div>
@if (itemHighlight && !!item?.onClick) {
<nz-icon
nzType="arrow-right"
nzTheme="outline"
class="ant-check-list-steps-item-arrows"
(click)="item.onClick?.(item)"
/>
}
</div>
}
</div>
<div class="ant-check-list-footer" (click)="visible.set(false)">
@if (!!footer()) {
<ng-container *nzStringTemplateOutlet="footer()">{{ footer() }}</ng-container>
} @else {
{{ i18n.checkListFooter }}
}
</div>
} @else {
<div class="ant-check-list-close-check">
<div class="ant-check-list-close-check-title">{{ i18n.checkListCheck }}</div>
<div class="ant-check-list-close-check-action">
<button nz-button nzType="primary" (click)="visible.set(false); hide.emit(checked)">{{ i18n.ok }}</button>
<button nz-button (click)="visible.set(true)">{{ i18n.cancel }}</button>
</div>
<div class="ant-check-list-close-check-other">
<label nz-checkbox [(ngModel)]="checked">{{ i18n.checkListCheckOther }}</label>
</div>
</div>
}
`,
host: {
class: 'ant-check-list-content'
}
}]
}] });
/**
* 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 NzCheckListComponent {
nzItems = input([], ...(ngDevMode ? [{ debugName: "nzItems" }] : []));
nzVisible = input(false, ...(ngDevMode ? [{ debugName: "nzVisible" }] : []));
nzIndex = input(1, ...(ngDevMode ? [{ debugName: "nzIndex" }] : []));
nzProgress = input(true, ...(ngDevMode ? [{ debugName: "nzProgress" }] : []));
nzTriggerRender = input(null, ...(ngDevMode ? [{ debugName: "nzTriggerRender" }] : []));
nzTitle = input(null, ...(ngDevMode ? [{ debugName: "nzTitle" }] : []));
nzFooter = input(null, ...(ngDevMode ? [{ debugName: "nzFooter" }] : []));
nzHide = output();
unfinished = computed(() => {
this.visible();
return this.nzItems().filter(item => !item?.checked).length;
}, ...(ngDevMode ? [{ debugName: "unfinished" }] : []));
visible = linkedSignal(this.nzVisible);
i18n = inject(NzI18nService);
locale = toSignal(this.i18n.localeChange.pipe(map(() => this.i18n.getLocaleData('CheckList'))), { requireSync: true });
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCheckListComponent, isStandalone: true, selector: "nz-check-list", inputs: { nzItems: { classPropertyName: "nzItems", publicName: "nzItems", isSignal: true, isRequired: false, transformFunction: null }, nzVisible: { classPropertyName: "nzVisible", publicName: "nzVisible", isSignal: true, isRequired: false, transformFunction: null }, nzIndex: { classPropertyName: "nzIndex", publicName: "nzIndex", isSignal: true, isRequired: false, transformFunction: null }, nzProgress: { classPropertyName: "nzProgress", publicName: "nzProgress", isSignal: true, isRequired: false, transformFunction: null }, nzTriggerRender: { classPropertyName: "nzTriggerRender", publicName: "nzTriggerRender", isSignal: true, isRequired: false, transformFunction: null }, nzTitle: { classPropertyName: "nzTitle", publicName: "nzTitle", isSignal: true, isRequired: false, transformFunction: null }, nzFooter: { classPropertyName: "nzFooter", publicName: "nzFooter", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nzHide: "nzHide" }, host: { classAttribute: "ant-check-list" }, ngImport: i0, template: `
<nz-check-list-button
nz-popover
[nzPopoverContent]="checklistTemplate"
nzPopoverTrigger="click"
nzPopoverPlacement="topRight"
[nzPopoverOverlayClickable]="false"
[nzPopoverVisible]="visible()"
(nzPopoverVisibleChange)="visible.set($event)"
>
@if (!!nzTriggerRender()) {
<ng-container *nzStringTemplateOutlet="nzTriggerRender()">{{ nzTriggerRender() }}</ng-container>
} @else {
<nz-icon nzType="check-circle" nzTheme="outline" class="ant-check-list-icon" />
<div class="ant-check-list-description">{{ locale().checkList }}</div>
}
@if (!visible() && !!unfinished()) {
<div class="ant-check-list-trigger-dot">
<div class="ant-check-list-trigger-dot-text">{{ unfinished() | number: '1.0-0' }}</div>
</div>
}
</nz-check-list-button>
<ng-template #checklistTemplate>
<nz-check-list-content
[locale]="locale()"
[items]="nzItems()"
[index]="nzIndex()"
[title]="nzTitle()"
[progress]="nzProgress()"
[footer]="nzFooter()"
(closePopover)="visible.set($event)"
(hide)="visible.set($event); nzHide.emit($event)"
></nz-check-list-content>
</ng-template>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzPopoverModule }, { kind: "directive", type: i1$1.NzPopoverDirective, selector: "[nz-popover]", inputs: ["nzPopoverArrowPointAtCenter", "nzPopoverTitle", "nzPopoverTitleContext", "nzPopoverContent", "nzPopoverContentContext", "nz-popover", "nzPopoverTrigger", "nzPopoverPlacement", "nzPopoverOrigin", "nzPopoverVisible", "nzPopoverMouseEnterDelay", "nzPopoverMouseLeaveDelay", "nzPopoverOverlayClassName", "nzPopoverOverlayStyle", "nzPopoverOverlayClickable", "nzPopoverBackdrop"], outputs: ["nzPopoverVisibleChange"], exportAs: ["nzPopover"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "component", type: NzCheckListButtonComponent, selector: "nz-check-list-button" }, { kind: "component", type: NzCheckListContentComponent, selector: "nz-check-list-content", inputs: ["locale", "items", "index", "progress", "title", "footer"], outputs: ["closePopover", "hide"] }, { kind: "pipe", type: DecimalPipe, name: "number" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-check-list',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
imports: [
NzPopoverModule,
NzIconModule,
NzOutletModule,
NzCheckListButtonComponent,
NzCheckListContentComponent,
DecimalPipe
],
template: `
<nz-check-list-button
nz-popover
[nzPopoverContent]="checklistTemplate"
nzPopoverTrigger="click"
nzPopoverPlacement="topRight"
[nzPopoverOverlayClickable]="false"
[nzPopoverVisible]="visible()"
(nzPopoverVisibleChange)="visible.set($event)"
>
@if (!!nzTriggerRender()) {
<ng-container *nzStringTemplateOutlet="nzTriggerRender()">{{ nzTriggerRender() }}</ng-container>
} @else {
<nz-icon nzType="check-circle" nzTheme="outline" class="ant-check-list-icon" />
<div class="ant-check-list-description">{{ locale().checkList }}</div>
}
@if (!visible() && !!unfinished()) {
<div class="ant-check-list-trigger-dot">
<div class="ant-check-list-trigger-dot-text">{{ unfinished() | number: '1.0-0' }}</div>
</div>
}
</nz-check-list-button>
<ng-template #checklistTemplate>
<nz-check-list-content
[locale]="locale()"
[items]="nzItems()"
[index]="nzIndex()"
[title]="nzTitle()"
[progress]="nzProgress()"
[footer]="nzFooter()"
(closePopover)="visible.set($event)"
(hide)="visible.set($event); nzHide.emit($event)"
></nz-check-list-content>
</ng-template>
`,
host: {
class: 'ant-check-list'
}
}]
}] });
/**
* 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 NzCheckListModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListModule, imports: [NzCheckListComponent], exports: [NzCheckListComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListModule, imports: [NzCheckListComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckListModule, decorators: [{
type: NgModule,
args: [{
imports: [NzCheckListComponent],
exports: [NzCheckListComponent]
}]
}] });
/**
* 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 { NzCheckListComponent, NzCheckListModule };
//# sourceMappingURL=ng-zorro-antd-check-list.mjs.map
File diff suppressed because one or more lines are too long
+440
View File
@@ -0,0 +1,440 @@
import { FocusMonitor } from '@angular/cdk/a11y';
import { Directionality } from '@angular/cdk/bidi';
import * as i0 from '@angular/core';
import { EventEmitter, Output, ViewEncapsulation, ChangeDetectionStrategy, Component, InjectionToken, inject, NgZone, ElementRef, ChangeDetectorRef, DestroyRef, effect, forwardRef, booleanAttribute, Input, ViewChild, input, signal, linkedSignal, computed, afterNextRender, untracked, NgModule } from '@angular/core';
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
import * as i1 from '@angular/forms';
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Subject } from 'rxjs';
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 Will be removed in v21. 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: "20.3.0", ngImport: i0, type: NzCheckboxWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", 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: "20.3.0", ngImport: i0, type: NzCheckboxWrapperComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-checkbox-wrapper',
exportAs: 'nzCheckboxWrapper',
template: `<ng-content></ng-content>`,
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(typeof ngDevMode !== 'undefined' && ngDevMode ? 'nz-checkbox-group' : '');
/**
* 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 NzCheckboxComponent {
ngZone = inject(NgZone);
elementRef = inject((ElementRef));
cdr = inject(ChangeDetectorRef);
focusMonitor = inject(FocusMonitor);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
checkboxGroupComponent = inject(NZ_CHECKBOX_GROUP, { optional: true });
nzFormStatusService = inject(NzFormStatusService, { optional: true });
/** @deprecated */
nzCheckboxWrapperComponent = inject(NzCheckboxWrapperComponent, { optional: true });
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();
}
constructor() {
this.destroyRef.onDestroy(() => {
this.focusMonitor.stopMonitoring(this.elementRef);
this.nzCheckboxWrapperComponent?.removeCheckbox(this);
});
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(takeUntilDestroyed(this.destroyRef))
.subscribe(focusOrigin => {
if (!focusOrigin) {
Promise.resolve().then(() => this.onTouched());
}
});
this.nzCheckboxWrapperComponent?.addCheckbox(this);
this.directionality.change.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
fromEventOutsideAngular(this.elementRef.nativeElement, 'click')
.pipe(takeUntilDestroyed(this.destroyRef))
.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(takeUntilDestroyed(this.destroyRef))
.subscribe(event => event.stopPropagation());
}
ngAfterViewInit() {
if (this.nzAutoFocus) {
this.focus();
}
}
setValue(value) {
this.nzChecked = value;
this.onChange(value);
this.nzCheckedChange.emit(value);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "20.3.0", 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: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.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: "20.3.0", ngImport: i0, type: NzCheckboxComponent, decorators: [{
type: Component,
args: [{
selector: '[nz-checkbox]',
exportAs: 'nzCheckbox',
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: () => [], 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, ...(ngDevMode ? [{ debugName: "nzName" }] : []));
nzDisabled = input(false, ...(ngDevMode ? [{ debugName: "nzDisabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
nzOptions = input([], ...(ngDevMode ? [{ debugName: "nzOptions" }] : []));
value = signal(null, ...(ngDevMode ? [{ debugName: "value" }] : []));
finalDisabled = linkedSignal(() => this.nzDisabled());
dir = toSignal(this.directionality.change, { initialValue: this.directionality.value });
normalizedOptions = computed(() => normalizeOptions(this.nzOptions()), ...(ngDevMode ? [{ debugName: "normalizedOptions" }] : []));
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: "20.3.0", ngImport: i0, type: NzCheckboxGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", 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: "20.3.0", 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: "20.3.0", ngImport: i0, type: NzCheckboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCheckboxModule, imports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent], exports: [NzCheckboxComponent, NzCheckboxGroupComponent, NzCheckboxWrapperComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCheckboxModule, imports: [NzCheckboxComponent, NzCheckboxGroupComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", 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
File diff suppressed because one or more lines are too long
+463
View File
@@ -0,0 +1,463 @@
import { Platform } from '@angular/cdk/platform';
import { NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { inject, DOCUMENT, Injectable, NgZone, DestroyRef, EventEmitter, ElementRef, forwardRef, booleanAttribute, Output, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { ReplaySubject, BehaviorSubject, of, Subject, combineLatest } from 'rxjs';
import { tap, map, debounceTime, filter, distinctUntilChanged } from 'rxjs/operators';
import { warn, PREFIX } from 'ng-zorro-antd/core/logger';
import { inNextTick, fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
import { NzSpinComponent } from 'ng-zorro-antd/spin';
import { NzConfigService, onConfigChangeEventForComponent } from 'ng-zorro-antd/core/config';
/**
* 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 NzCodeEditorLoadingStatus = {
UNLOAD: 'unload',
LOADING: 'loading',
LOADED: 'LOADED'
};
/**
* 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_CONFIG_MODULE_NAME = 'codeEditor';
function tryTriggerFunc(fn) {
return (...args) => {
if (fn) {
fn(...args);
}
};
}
// Caretaker note: previously, these were `NzCodeEditorService` properties.
// They're kept as static variables because this will allow loading Monaco only once.
// This applies to micro frontend apps with multiple Angular apps or a single Angular app
// that can be bootstrapped and destroyed multiple times (e.g. using Webpack module federation).
// Root providers are re-initialized each time the app is bootstrapped. Platform providers aren't.
// We can't make the `NzCodeEditorService` to be a platform provider (`@Injectable({ providedIn: 'platform' })`)
// since it depends on other root providers.
const loaded$ = new ReplaySubject(1);
let loadingStatus = NzCodeEditorLoadingStatus.UNLOAD;
class NzCodeEditorService {
nzConfigService = inject(NzConfigService);
document = inject(DOCUMENT);
firstEditorInitialized = false;
option = {};
config;
option$ = new BehaviorSubject(this.option);
constructor() {
const globalConfig = this.nzConfigService.getConfigForComponent(NZ_CONFIG_MODULE_NAME);
this.config = { ...globalConfig };
if (this.config.monacoEnvironment) {
window.MonacoEnvironment = { ...this.config.monacoEnvironment };
}
this.option = this.config.defaultEditorOption || {};
onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME, () => {
const newGlobalConfig = this.nzConfigService.getConfigForComponent(NZ_CONFIG_MODULE_NAME);
if (newGlobalConfig) {
this._updateDefaultOption(newGlobalConfig.defaultEditorOption);
}
});
}
_updateDefaultOption(option) {
this.option = { ...this.option, ...option };
this.option$.next(this.option);
if ('theme' in option && option.theme) {
monaco.editor.setTheme(option.theme);
}
}
requestToInit() {
if (loadingStatus === NzCodeEditorLoadingStatus.LOADED) {
this.onInit();
return of(this.getLatestOption());
}
if (loadingStatus === NzCodeEditorLoadingStatus.UNLOAD) {
if (this.config.useStaticLoading && typeof monaco === 'undefined') {
warn('You choose to use static loading but it seems that you forget ' +
'to config webpack plugin correctly. Please refer to our official website' +
'for more details about static loading.');
}
else {
this.loadMonacoScript();
}
}
return loaded$.pipe(tap(() => this.onInit()), map(() => this.getLatestOption()));
}
loadMonacoScript() {
if (this.config.useStaticLoading) {
Promise.resolve().then(() => this.onLoad());
return;
}
if (loadingStatus === NzCodeEditorLoadingStatus.LOADING) {
return;
}
loadingStatus = NzCodeEditorLoadingStatus.LOADING;
const assetsRoot = this.config.assetsRoot;
const vs = assetsRoot ? `${assetsRoot}/vs` : 'assets/vs';
const windowAsAny = window;
const loadScript = this.document.createElement('script');
loadScript.type = 'text/javascript';
loadScript.src = `${vs}/loader.js`;
const onLoad = () => {
cleanup();
windowAsAny.require.config({
paths: { vs },
...this.config.extraConfig
});
windowAsAny.require(['vs/editor/editor.main'], () => {
this.onLoad();
});
};
const onError = () => {
cleanup();
throw new Error(`${PREFIX} cannot load assets of monaco editor from source "${vs}".`);
};
const cleanup = () => {
// Caretaker note: we have to remove these listeners once the `<script>` is loaded successfully
// or not since the `onLoad` listener captures `this`, which will prevent the `NzCodeEditorService`
// from being garbage collected.
loadScript.removeEventListener('load', onLoad);
loadScript.removeEventListener('error', onError);
// We don't need to keep the `<script>` element within the `<body>` since JavaScript has
// been executed and Monaco is available globally. E.g. Webpack, always removes `<script>`
// elements after loading chunks (see its `LoadScriptRuntimeModule`).
this.document.documentElement.removeChild(loadScript);
};
loadScript.addEventListener('load', onLoad);
loadScript.addEventListener('error', onError);
this.document.documentElement.appendChild(loadScript);
}
onLoad() {
loadingStatus = NzCodeEditorLoadingStatus.LOADED;
loaded$.next(true);
loaded$.complete();
tryTriggerFunc(this.config.onLoad)();
}
onInit() {
if (!this.firstEditorInitialized) {
this.firstEditorInitialized = true;
tryTriggerFunc(this.config.onFirstEditorInit)();
}
tryTriggerFunc(this.config.onInit)();
}
getLatestOption() {
return { ...this.option };
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: () => [] });
/**
* 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 NzCodeEditorComponent {
nzCodeEditorService = inject(NzCodeEditorService);
ngZone = inject(NgZone);
platform = inject(Platform);
destroyRef = inject(DestroyRef);
nzEditorMode = 'normal';
nzOriginalText = '';
nzLoading = false;
nzFullControl = false;
nzToolkit;
set nzEditorOption(value) {
this.editorOption$.next(value);
}
nzEditorInitialized = new EventEmitter();
editorOptionCached = {};
el = inject((ElementRef)).nativeElement;
resize$ = new Subject();
editorOption$ = new BehaviorSubject({});
editorInstance = null;
value = '';
modelSet = false;
onDidChangeContentDisposable = null;
constructor() {
this.el.classList.add('ant-code-editor');
this.destroyRef.onDestroy(() => {
if (this.onDidChangeContentDisposable) {
this.onDidChangeContentDisposable.dispose();
this.onDidChangeContentDisposable = null;
}
if (this.editorInstance) {
this.editorInstance.dispose();
this.editorInstance = null;
}
});
}
/**
* Initialize a monaco editor instance.
*/
ngAfterViewInit() {
if (!this.platform.isBrowser) {
return;
}
this.nzCodeEditorService
.requestToInit()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(option => this.setup(option));
}
writeValue(value) {
this.value = value;
this.setValue();
}
registerOnChange(fn) {
this.onChange = fn;
}
registerOnTouched(fn) {
this.onTouch = fn;
}
onChange = (_value) => { };
onTouch = () => { };
layout() {
this.resize$.next();
}
setup(option) {
// The `setup()` is invoked when the Monaco editor is loaded. This may happen asynchronously for the first
// time, and it'll always happen synchronously afterwards. The first `setup()` invokation is outside the Angular
// zone, but further invokations will happen within the Angular zone. We call the `setModel()` on the editor
// instance, which tells Monaco to add event listeners lazily internally (`mousemove`, `mouseout`, etc.).
// We should avoid adding them within the Angular zone since this will drastically affect the performance.
this.ngZone.runOutsideAngular(() => inNextTick()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.editorOptionCached = option;
this.registerOptionChanges();
this.initMonacoEditorInstance();
this.registerResizeChange();
this.setValue();
if (!this.nzFullControl) {
this.setValueEmitter();
}
if (this.nzEditorInitialized.observers.length) {
this.ngZone.run(() => this.nzEditorInitialized.emit(this.editorInstance));
}
}));
}
registerOptionChanges() {
combineLatest([this.editorOption$, this.nzCodeEditorService.option$])
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(([selfOpt, defaultOpt]) => {
this.editorOptionCached = {
...this.editorOptionCached,
...defaultOpt,
...selfOpt
};
this.updateOptionToMonaco();
});
}
initMonacoEditorInstance() {
this.ngZone.runOutsideAngular(() => {
this.editorInstance =
this.nzEditorMode === 'normal'
? monaco.editor.create(this.el, { ...this.editorOptionCached })
: monaco.editor.createDiffEditor(this.el, {
...this.editorOptionCached
});
});
}
registerResizeChange() {
fromEventOutsideAngular(window, 'resize')
.pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.layout();
});
this.resize$
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !!this.editorInstance), map(() => ({
width: this.el.clientWidth,
height: this.el.clientHeight
})), distinctUntilChanged((a, b) => a.width === b.width && a.height === b.height), debounceTime(50))
.subscribe(() => {
this.editorInstance.layout();
});
}
setValue() {
if (!this.editorInstance) {
return;
}
if (this.nzFullControl && this.value) {
warn(`should not set value when you are using full control mode! It would result in ambiguous data flow!`);
return;
}
if (this.nzEditorMode === 'normal') {
if (this.modelSet) {
const model = this.editorInstance.getModel();
this.preservePositionAndSelections(() => model.setValue(this.value));
}
else {
this.editorInstance.setModel(monaco.editor.createModel(this.value, this.editorOptionCached.language));
this.modelSet = true;
}
}
else {
if (this.modelSet) {
const model = this.editorInstance.getModel();
this.preservePositionAndSelections(() => {
model.modified.setValue(this.value);
model.original.setValue(this.nzOriginalText);
});
}
else {
const language = this.editorOptionCached.language;
this.editorInstance.setModel({
original: monaco.editor.createModel(this.nzOriginalText, language),
modified: monaco.editor.createModel(this.value, language)
});
this.modelSet = true;
}
}
}
/**
* {@link editor.ICodeEditor}#setValue resets the cursor position to the start of the document.
* This helper memorizes the cursor position and selections and restores them after the given
* function has been called.
*/
preservePositionAndSelections(fn) {
if (!this.editorInstance) {
fn();
return;
}
const position = this.editorInstance.getPosition();
const selections = this.editorInstance.getSelections();
fn();
if (position) {
this.editorInstance.setPosition(position);
}
if (selections) {
this.editorInstance.setSelections(selections);
}
}
setValueEmitter() {
const model = (this.nzEditorMode === 'normal'
? this.editorInstance.getModel()
: this.editorInstance.getModel().modified);
// The `onDidChangeContent` returns a disposable object (an object with `dispose()` method) which will cleanup
// the listener. The callback, that we pass to `onDidChangeContent`, captures `this`. This leads to a circular reference
// (`nz-code-editor -> monaco -> nz-code-editor`) and prevents the `nz-code-editor` from being GC'd.
this.onDidChangeContentDisposable = model.onDidChangeContent(() => {
this.emitValue(model.getValue());
});
}
emitValue(value) {
if (this.value === value) {
// If the value didn't change there's no reason to send an update.
// Specifically this may happen during an update from the model (writeValue) where sending an update to the model would actually be incorrect.
return;
}
this.value = value;
// We're re-entering the Angular zone only if the value has been changed since there's a `return` expression previously.
// This won't cause "dead" change detections (basically when the `tick()` has been run, but there's nothing to update).
this.ngZone.run(() => {
this.onChange(value);
});
}
updateOptionToMonaco() {
if (this.editorInstance) {
this.editorInstance.updateOptions({ ...this.editorOptionCached });
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCodeEditorComponent, isStandalone: true, selector: "nz-code-editor", inputs: { nzEditorMode: "nzEditorMode", nzOriginalText: "nzOriginalText", nzLoading: ["nzLoading", "nzLoading", booleanAttribute], nzFullControl: ["nzFullControl", "nzFullControl", booleanAttribute], nzToolkit: "nzToolkit", nzEditorOption: "nzEditorOption" }, outputs: { nzEditorInitialized: "nzEditorInitialized" }, providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NzCodeEditorComponent),
multi: true
}
], exportAs: ["nzCodeEditor"], ngImport: i0, template: `
@if (nzLoading) {
<div class="ant-code-editor-loading">
<nz-spin />
</div>
}
@if (nzToolkit) {
<div class="ant-code-editor-toolkit">
<ng-template [ngTemplateOutlet]="nzToolkit" />
</div>
}
`, isInline: true, dependencies: [{ kind: "component", type: NzSpinComponent, selector: "nz-spin", inputs: ["nzIndicator", "nzSize", "nzTip", "nzDelay", "nzSimple", "nzSpinning"], exportAs: ["nzSpin"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-code-editor',
exportAs: 'nzCodeEditor',
template: `
@if (nzLoading) {
<div class="ant-code-editor-loading">
<nz-spin />
</div>
}
@if (nzToolkit) {
<div class="ant-code-editor-toolkit">
<ng-template [ngTemplateOutlet]="nzToolkit" />
</div>
}
`,
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NzCodeEditorComponent),
multi: true
}
],
imports: [NzSpinComponent, NgTemplateOutlet]
}]
}], ctorParameters: () => [], propDecorators: { nzEditorMode: [{
type: Input
}], nzOriginalText: [{
type: Input
}], nzLoading: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzFullControl: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzToolkit: [{
type: Input
}], nzEditorOption: [{
type: Input
}], nzEditorInitialized: [{
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 NzCodeEditorModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorModule, imports: [NzCodeEditorComponent], exports: [NzCodeEditorComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorModule, imports: [NzCodeEditorComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCodeEditorModule, decorators: [{
type: NgModule,
args: [{
imports: [NzCodeEditorComponent],
exports: [NzCodeEditorComponent]
}]
}] });
/**
* 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 { NzCodeEditorComponent, NzCodeEditorLoadingStatus, NzCodeEditorModule, NzCodeEditorService };
//# sourceMappingURL=ng-zorro-antd-code-editor.mjs.map
File diff suppressed because one or more lines are too long
+320
View File
@@ -0,0 +1,320 @@
import { __esDecorate, __runInitializers } from 'tslib';
import * as i0 from '@angular/core';
import { inject, ChangeDetectorRef, DestroyRef, booleanAttribute, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgZone, EventEmitter, ViewChild, Output, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { filter } from 'rxjs/operators';
import { collapseMotion } from 'ng-zorro-antd/core/animation';
import { WithConfig, onConfigChangeEventForComponent } from 'ng-zorro-antd/core/config';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
import * as i2 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { Directionality } from '@angular/cdk/bidi';
const NZ_CONFIG_MODULE_NAME$1 = 'collapse';
let NzCollapseComponent = (() => {
let _nzAccordion_decorators;
let _nzAccordion_initializers = [];
let _nzAccordion_extraInitializers = [];
let _nzBordered_decorators;
let _nzBordered_initializers = [];
let _nzBordered_extraInitializers = [];
let _nzGhost_decorators;
let _nzGhost_initializers = [];
let _nzGhost_extraInitializers = [];
return class NzCollapseComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzAccordion_decorators = [WithConfig()];
_nzBordered_decorators = [WithConfig()];
_nzGhost_decorators = [WithConfig()];
__esDecorate(null, null, _nzAccordion_decorators, { kind: "field", name: "nzAccordion", static: false, private: false, access: { has: obj => "nzAccordion" in obj, get: obj => obj.nzAccordion, set: (obj, value) => { obj.nzAccordion = value; } }, metadata: _metadata }, _nzAccordion_initializers, _nzAccordion_extraInitializers);
__esDecorate(null, null, _nzBordered_decorators, { kind: "field", name: "nzBordered", static: false, private: false, access: { has: obj => "nzBordered" in obj, get: obj => obj.nzBordered, set: (obj, value) => { obj.nzBordered = value; } }, metadata: _metadata }, _nzBordered_initializers, _nzBordered_extraInitializers);
__esDecorate(null, null, _nzGhost_decorators, { kind: "field", name: "nzGhost", static: false, private: false, access: { has: obj => "nzGhost" in obj, get: obj => obj.nzGhost, set: (obj, value) => { obj.nzGhost = value; } }, metadata: _metadata }, _nzGhost_initializers, _nzGhost_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
cdr = inject(ChangeDetectorRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME$1;
nzAccordion = __runInitializers(this, _nzAccordion_initializers, false);
nzBordered = (__runInitializers(this, _nzAccordion_extraInitializers), __runInitializers(this, _nzBordered_initializers, true));
nzGhost = (__runInitializers(this, _nzBordered_extraInitializers), __runInitializers(this, _nzGhost_initializers, false));
nzExpandIconPosition = (__runInitializers(this, _nzGhost_extraInitializers), 'start');
nzSize = 'middle';
dir = 'ltr';
listOfNzCollapsePanelComponent = [];
constructor() {
onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME$1, () => this.cdr.markForCheck());
}
ngOnInit() {
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
}
addPanel(value) {
this.listOfNzCollapsePanelComponent.push(value);
}
removePanel(value) {
this.listOfNzCollapsePanelComponent.splice(this.listOfNzCollapsePanelComponent.indexOf(value), 1);
}
click(collapse) {
if (this.nzAccordion && !collapse.nzActive) {
this.listOfNzCollapsePanelComponent
.filter(item => item !== collapse)
.forEach(item => {
if (item.nzActive) {
item.nzActive = false;
item.nzActiveChange.emit(item.nzActive);
item.markForCheck();
}
});
}
collapse.nzActive = !collapse.nzActive;
collapse.nzActiveChange.emit(collapse.nzActive);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCollapseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "20.3.0", type: NzCollapseComponent, isStandalone: true, selector: "nz-collapse", inputs: { nzAccordion: ["nzAccordion", "nzAccordion", booleanAttribute], nzBordered: ["nzBordered", "nzBordered", booleanAttribute], nzGhost: ["nzGhost", "nzGhost", booleanAttribute], nzExpandIconPosition: "nzExpandIconPosition", nzSize: "nzSize" }, host: { properties: { "class.ant-collapse-icon-position-start": "nzExpandIconPosition === 'start'", "class.ant-collapse-icon-position-end": "nzExpandIconPosition === 'end'", "class.ant-collapse-ghost": "nzGhost", "class.ant-collapse-borderless": "!nzBordered", "class.ant-collapse-rtl": "dir === 'rtl'", "class.ant-collapse-small": "nzSize === 'small'", "class.ant-collapse-large": "nzSize === 'large'" }, classAttribute: "ant-collapse" }, exportAs: ["nzCollapse"], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCollapseComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-collapse',
exportAs: 'nzCollapse',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: `<ng-content></ng-content>`,
host: {
class: 'ant-collapse',
'[class.ant-collapse-icon-position-start]': `nzExpandIconPosition === 'start'`,
'[class.ant-collapse-icon-position-end]': `nzExpandIconPosition === 'end'`,
'[class.ant-collapse-ghost]': `nzGhost`,
'[class.ant-collapse-borderless]': '!nzBordered',
'[class.ant-collapse-rtl]': "dir === 'rtl'",
'[class.ant-collapse-small]': `nzSize === 'small'`,
'[class.ant-collapse-large]': `nzSize === 'large'`
}
}]
}], ctorParameters: () => [], propDecorators: { nzAccordion: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzBordered: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzGhost: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzExpandIconPosition: [{
type: Input
}], nzSize: [{
type: Input
}] } });
const NZ_CONFIG_MODULE_NAME = 'collapsePanel';
let NzCollapsePanelComponent = (() => {
let _nzShowArrow_decorators;
let _nzShowArrow_initializers = [];
let _nzShowArrow_extraInitializers = [];
return class NzCollapsePanelComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzShowArrow_decorators = [WithConfig()];
__esDecorate(null, null, _nzShowArrow_decorators, { kind: "field", name: "nzShowArrow", static: false, private: false, access: { has: obj => "nzShowArrow" in obj, get: obj => obj.nzShowArrow, set: (obj, value) => { obj.nzShowArrow = value; } }, metadata: _metadata }, _nzShowArrow_initializers, _nzShowArrow_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
ngZone = inject(NgZone);
cdr = inject(ChangeDetectorRef);
destroyRef = inject(DestroyRef);
nzCollapseComponent = inject(NzCollapseComponent, { host: true });
noAnimation = inject(NzNoAnimationDirective, { optional: true });
_nzModuleName = NZ_CONFIG_MODULE_NAME;
nzActive = false;
/**
* @deprecated Use `nzCollapsible` instead with the value `'disabled'`.
*/
nzDisabled = false;
nzShowArrow = __runInitializers(this, _nzShowArrow_initializers, true);
nzExtra = __runInitializers(this, _nzShowArrow_extraInitializers);
nzHeader;
nzExpandedIcon;
nzCollapsible;
nzActiveChange = new EventEmitter();
collapseHeader;
collapseIcon;
markForCheck() {
this.cdr.markForCheck();
}
constructor() {
onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME, () => this.cdr.markForCheck());
this.destroyRef.onDestroy(() => {
this.nzCollapseComponent.removePanel(this);
});
}
ngOnInit() {
this.nzCollapseComponent.addPanel(this);
}
ngAfterViewInit() {
let fromEvent$ = fromEventOutsideAngular(this.collapseHeader.nativeElement, 'click');
if (this.nzShowArrow && this.nzCollapsible === 'icon' && this.collapseIcon) {
fromEvent$ = fromEventOutsideAngular(this.collapseIcon.nativeElement, 'click');
}
fromEvent$
.pipe(filter(() => !this.nzDisabled && this.nzCollapsible !== 'disabled'), takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.ngZone.run(() => {
this.nzCollapseComponent.click(this);
this.cdr.markForCheck();
});
});
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCollapsePanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCollapsePanelComponent, isStandalone: true, selector: "nz-collapse-panel", inputs: { nzActive: ["nzActive", "nzActive", booleanAttribute], nzDisabled: ["nzDisabled", "nzDisabled", booleanAttribute], nzShowArrow: ["nzShowArrow", "nzShowArrow", booleanAttribute], nzExtra: "nzExtra", nzHeader: "nzHeader", nzExpandedIcon: "nzExpandedIcon", nzCollapsible: "nzCollapsible" }, outputs: { nzActiveChange: "nzActiveChange" }, host: { properties: { "class.ant-collapse-no-arrow": "!nzShowArrow", "class.ant-collapse-item-active": "nzActive", "class.ant-collapse-item-disabled": "nzDisabled || nzCollapsible === \"disabled\"" }, classAttribute: "ant-collapse-item" }, viewQueries: [{ propertyName: "collapseHeader", first: true, predicate: ["collapseHeader"], descendants: true }, { propertyName: "collapseIcon", first: true, predicate: ["collapseIcon"], descendants: true }], exportAs: ["nzCollapsePanel"], ngImport: i0, template: `
<div
#collapseHeader
role="button"
[attr.aria-expanded]="nzActive"
class="ant-collapse-header"
[class.ant-collapse-icon-collapsible-only]="nzCollapsible === 'icon'"
[class.ant-collapse-header-collapsible-only]="nzCollapsible === 'header'"
>
@if (nzShowArrow) {
<div role="button" #collapseIcon class="ant-collapse-expand-icon">
<ng-container *nzStringTemplateOutlet="nzExpandedIcon; let expandedIcon">
<nz-icon [nzType]="expandedIcon || 'right'" class="ant-collapse-arrow" [nzRotate]="nzActive ? 90 : 0" />
</ng-container>
</div>
}
<span class="ant-collapse-header-text">
<ng-container *nzStringTemplateOutlet="nzHeader">{{ nzHeader }}</ng-container>
</span>
@if (nzExtra) {
<div class="ant-collapse-extra">
<ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
</div>
}
</div>
<div
class="ant-collapse-content"
[class.ant-collapse-content-active]="nzActive"
[@.disabled]="!!noAnimation?.nzNoAnimation"
[@collapseMotion]="nzActive ? 'expanded' : 'hidden'"
>
<div class="ant-collapse-content-box">
<ng-content></ng-content>
</div>
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }], animations: [collapseMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCollapsePanelComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-collapse-panel',
exportAs: 'nzCollapsePanel',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
animations: [collapseMotion],
template: `
<div
#collapseHeader
role="button"
[attr.aria-expanded]="nzActive"
class="ant-collapse-header"
[class.ant-collapse-icon-collapsible-only]="nzCollapsible === 'icon'"
[class.ant-collapse-header-collapsible-only]="nzCollapsible === 'header'"
>
@if (nzShowArrow) {
<div role="button" #collapseIcon class="ant-collapse-expand-icon">
<ng-container *nzStringTemplateOutlet="nzExpandedIcon; let expandedIcon">
<nz-icon [nzType]="expandedIcon || 'right'" class="ant-collapse-arrow" [nzRotate]="nzActive ? 90 : 0" />
</ng-container>
</div>
}
<span class="ant-collapse-header-text">
<ng-container *nzStringTemplateOutlet="nzHeader">{{ nzHeader }}</ng-container>
</span>
@if (nzExtra) {
<div class="ant-collapse-extra">
<ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
</div>
}
</div>
<div
class="ant-collapse-content"
[class.ant-collapse-content-active]="nzActive"
[@.disabled]="!!noAnimation?.nzNoAnimation"
[@collapseMotion]="nzActive ? 'expanded' : 'hidden'"
>
<div class="ant-collapse-content-box">
<ng-content></ng-content>
</div>
</div>
`,
host: {
class: 'ant-collapse-item',
'[class.ant-collapse-no-arrow]': '!nzShowArrow',
'[class.ant-collapse-item-active]': 'nzActive',
'[class.ant-collapse-item-disabled]': 'nzDisabled || nzCollapsible === "disabled"'
},
imports: [NzOutletModule, NzIconModule]
}]
}], ctorParameters: () => [], propDecorators: { nzActive: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzDisabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzShowArrow: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzExtra: [{
type: Input
}], nzHeader: [{
type: Input
}], nzExpandedIcon: [{
type: Input
}], nzCollapsible: [{
type: Input
}], nzActiveChange: [{
type: Output
}], collapseHeader: [{
type: ViewChild,
args: ['collapseHeader']
}], collapseIcon: [{
type: ViewChild,
args: ['collapseIcon']
}] } });
/**
* 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 NzCollapseModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCollapseModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCollapseModule, imports: [NzCollapsePanelComponent, NzCollapseComponent], exports: [NzCollapsePanelComponent, NzCollapseComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCollapseModule, imports: [NzCollapsePanelComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCollapseModule, decorators: [{
type: NgModule,
args: [{
imports: [NzCollapsePanelComponent, NzCollapseComponent],
exports: [NzCollapsePanelComponent, NzCollapseComponent]
}]
}] });
/**
* 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 { NzCollapseComponent, NzCollapseModule, NzCollapsePanelComponent };
//# sourceMappingURL=ng-zorro-antd-collapse.mjs.map
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+236
View File
@@ -0,0 +1,236 @@
import * as i0 from '@angular/core';
import { Directive, Input, inject, ViewContainerRef, TemplateRef, ViewChild, ChangeDetectionStrategy, ViewEncapsulation, Component, DestroyRef, ChangeDetectorRef, ContentChildren, NgModule } from '@angular/core';
import { CdkPortalOutlet, TemplatePortal } from '@angular/cdk/portal';
import { Directionality } from '@angular/cdk/bidi';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
/**
* 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 NzCommentAvatarDirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentAvatarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzCommentAvatarDirective, isStandalone: true, selector: "nz-avatar[nz-comment-avatar]", exportAs: ["nzCommentAvatar"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentAvatarDirective, decorators: [{
type: Directive,
args: [{
selector: 'nz-avatar[nz-comment-avatar]',
exportAs: 'nzCommentAvatar'
}]
}] });
class NzCommentContentDirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzCommentContentDirective, isStandalone: true, selector: "nz-comment-content, [nz-comment-content]", host: { classAttribute: "ant-comment-content-detail" }, exportAs: ["nzCommentContent"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentContentDirective, decorators: [{
type: Directive,
args: [{
selector: 'nz-comment-content, [nz-comment-content]',
exportAs: 'nzCommentContent',
host: { class: 'ant-comment-content-detail' }
}]
}] });
class NzCommentActionHostDirective extends CdkPortalOutlet {
nzCommentActionHost;
ngOnInit() {
super.ngOnInit();
}
ngOnDestroy() {
super.ngOnDestroy();
}
ngAfterViewInit() {
this.attach(this.nzCommentActionHost);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentActionHostDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzCommentActionHostDirective, isStandalone: true, selector: "[nzCommentActionHost]", inputs: { nzCommentActionHost: "nzCommentActionHost" }, exportAs: ["nzCommentActionHost"], usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentActionHostDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzCommentActionHost]',
exportAs: 'nzCommentActionHost'
}]
}], propDecorators: { nzCommentActionHost: [{
type: Input
}] } });
class NzCommentActionComponent {
implicitContent;
viewContainerRef = inject(ViewContainerRef);
contentPortal = null;
get content() {
return this.contentPortal;
}
ngOnInit() {
this.contentPortal = new TemplatePortal(this.implicitContent, this.viewContainerRef);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzCommentActionComponent, isStandalone: true, selector: "nz-comment-action", viewQueries: [{ propertyName: "implicitContent", first: true, predicate: TemplateRef, descendants: true, static: true }], exportAs: ["nzCommentAction"], ngImport: i0, template: '<ng-template><ng-content /></ng-template>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentActionComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-comment-action',
exportAs: 'nzCommentAction',
template: '<ng-template><ng-content /></ng-template>',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
}]
}], propDecorators: { implicitContent: [{
type: ViewChild,
args: [TemplateRef, { 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 NzCommentComponent {
destroyRef = inject(DestroyRef);
cdr = inject(ChangeDetectorRef);
directionality = inject(Directionality);
nzAuthor;
nzDatetime;
dir = 'ltr';
actions;
ngOnInit() {
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCommentComponent, isStandalone: true, selector: "nz-comment", inputs: { nzAuthor: "nzAuthor", nzDatetime: "nzDatetime" }, host: { properties: { "class.ant-comment": "true", "class.ant-comment-rtl": "dir === \"rtl\"" } }, queries: [{ propertyName: "actions", predicate: NzCommentActionComponent }], exportAs: ["nzComment"], ngImport: i0, template: `
<div class="ant-comment-inner">
<div class="ant-comment-avatar">
<ng-content select="nz-avatar[nz-comment-avatar]"></ng-content>
</div>
<div class="ant-comment-content">
<div class="ant-comment-content-author">
@if (nzAuthor) {
<span class="ant-comment-content-author-name">
<ng-container *nzStringTemplateOutlet="nzAuthor">{{ nzAuthor }}</ng-container>
</span>
}
@if (nzDatetime) {
<span class="ant-comment-content-author-time">
<ng-container *nzStringTemplateOutlet="nzDatetime">{{ nzDatetime }}</ng-container>
</span>
}
</div>
<ng-content select="nz-comment-content" />
@if (actions?.length) {
<ul class="ant-comment-actions">
@for (action of actions; track action) {
<li>
<span><ng-template [nzCommentActionHost]="action.content" /></span>
</li>
}
</ul>
}
</div>
</div>
<div class="ant-comment-nested">
<ng-content />
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "directive", type: NzCommentActionHostDirective, selector: "[nzCommentActionHost]", inputs: ["nzCommentActionHost"], exportAs: ["nzCommentActionHost"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-comment',
exportAs: 'nzComment',
template: `
<div class="ant-comment-inner">
<div class="ant-comment-avatar">
<ng-content select="nz-avatar[nz-comment-avatar]"></ng-content>
</div>
<div class="ant-comment-content">
<div class="ant-comment-content-author">
@if (nzAuthor) {
<span class="ant-comment-content-author-name">
<ng-container *nzStringTemplateOutlet="nzAuthor">{{ nzAuthor }}</ng-container>
</span>
}
@if (nzDatetime) {
<span class="ant-comment-content-author-time">
<ng-container *nzStringTemplateOutlet="nzDatetime">{{ nzDatetime }}</ng-container>
</span>
}
</div>
<ng-content select="nz-comment-content" />
@if (actions?.length) {
<ul class="ant-comment-actions">
@for (action of actions; track action) {
<li>
<span><ng-template [nzCommentActionHost]="action.content" /></span>
</li>
}
</ul>
}
</div>
</div>
<div class="ant-comment-nested">
<ng-content />
</div>
`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[class.ant-comment]': `true`,
'[class.ant-comment-rtl]': `dir === "rtl"`
},
imports: [NzOutletModule, NzCommentActionHostDirective]
}]
}], propDecorators: { nzAuthor: [{
type: Input
}], nzDatetime: [{
type: Input
}], actions: [{
type: ContentChildren,
args: [NzCommentActionComponent]
}] } });
/**
* 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_COMMENT_CELLS = [
NzCommentAvatarDirective,
NzCommentContentDirective,
NzCommentActionComponent,
NzCommentActionHostDirective
];
class NzCommentModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCommentModule, imports: [NzCommentComponent, NzCommentAvatarDirective,
NzCommentContentDirective,
NzCommentActionComponent,
NzCommentActionHostDirective], exports: [NzCommentComponent, NzCommentAvatarDirective,
NzCommentContentDirective,
NzCommentActionComponent,
NzCommentActionHostDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentModule, imports: [NzCommentComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCommentModule, decorators: [{
type: NgModule,
args: [{
imports: [NzCommentComponent, ...NZ_COMMENT_CELLS],
exports: [NzCommentComponent, ...NZ_COMMENT_CELLS]
}]
}] });
/**
* 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 { NzCommentActionComponent, NzCommentActionHostDirective, NzCommentAvatarDirective, NzCommentComponent, NzCommentContentDirective, NzCommentModule };
//# sourceMappingURL=ng-zorro-antd-comment.mjs.map
File diff suppressed because one or more lines are too long
+295
View File
@@ -0,0 +1,295 @@
import { trigger, state, transition, style, animate, query, stagger } from '@angular/animations';
/**
* 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 AnimationDuration {
static SLOW = '0.3s'; // Modal
static BASE = '0.2s';
static FAST = '0.1s'; // Tooltip
}
class AnimationCurves {
static EASE_BASE_OUT = 'cubic-bezier(0.7, 0.3, 0.1, 1)';
static EASE_BASE_IN = 'cubic-bezier(0.9, 0, 0.3, 0.7)';
static EASE_OUT = 'cubic-bezier(0.215, 0.61, 0.355, 1)';
static EASE_IN = 'cubic-bezier(0.55, 0.055, 0.675, 0.19)';
static EASE_IN_OUT = 'cubic-bezier(0.645, 0.045, 0.355, 1)';
static EASE_OUT_BACK = 'cubic-bezier(0.12, 0.4, 0.29, 1.46)';
static EASE_IN_BACK = 'cubic-bezier(0.71, -0.46, 0.88, 0.6)';
static EASE_IN_OUT_BACK = 'cubic-bezier(0.71, -0.46, 0.29, 1.46)';
static EASE_OUT_CIRC = 'cubic-bezier(0.08, 0.82, 0.17, 1)';
static EASE_IN_CIRC = 'cubic-bezier(0.6, 0.04, 0.98, 0.34)';
static EASE_IN_OUT_CIRC = 'cubic-bezier(0.78, 0.14, 0.15, 0.86)';
static EASE_OUT_QUINT = 'cubic-bezier(0.23, 1, 0.32, 1)';
static EASE_IN_QUINT = 'cubic-bezier(0.755, 0.05, 0.855, 0.06)';
static EASE_IN_OUT_QUINT = 'cubic-bezier(0.86, 0, 0.07, 1)';
}
/**
* 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 collapseMotion = trigger('collapseMotion', [
state('expanded', style({ height: '*' })),
state('collapsed', style({ height: 0, overflow: 'hidden' })),
state('hidden', style({ height: 0, overflow: 'hidden', borderTopWidth: '0' })),
transition('expanded => collapsed', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('expanded => hidden', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('collapsed => expanded', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('hidden => expanded', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`))
]);
const treeCollapseMotion = trigger('treeCollapseMotion', [
transition('* => *', [
query('nz-tree-node:leave,nz-tree-builtin-node:leave', [
style({ overflow: 'hidden' }),
stagger(0, [
animate(`150ms ${AnimationCurves.EASE_IN_OUT}`, style({ height: 0, opacity: 0, 'padding-bottom': 0 }))
])
], {
optional: true
}),
query('nz-tree-node:enter,nz-tree-builtin-node:enter', [
style({ overflow: 'hidden', height: 0, opacity: 0, 'padding-bottom': 0 }),
stagger(0, [
animate(`150ms ${AnimationCurves.EASE_IN_OUT}`, style({ overflow: 'hidden', height: '*', opacity: '*', 'padding-bottom': '*' }))
])
], {
optional: 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
*/
const drawerMaskMotion = trigger('drawerMaskMotion', [
transition(':enter', [style({ opacity: 0 }), animate(`${AnimationDuration.SLOW}`, style({ opacity: 1 }))]),
transition(':leave', [style({ opacity: 1 }), animate(`${AnimationDuration.SLOW}`, style({ opacity: 0 }))])
]);
/**
* 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 fadeMotion = trigger('fadeMotion', [
transition('* => enter', [style({ opacity: 0 }), animate(`${AnimationDuration.BASE}`, style({ opacity: 1 }))]),
transition('* => leave, :leave', [style({ opacity: 1 }), animate(`${AnimationDuration.BASE}`, style({ opacity: 0 }))])
]);
/**
* 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 helpMotion = trigger('helpMotion', [
transition(':enter', [
style({
opacity: 0,
transform: 'translateY(-5px)'
}),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_IN_OUT}`, style({
opacity: 1,
transform: 'translateY(0)'
}))
]),
transition(':leave', [
style({
opacity: 1,
transform: 'translateY(0)'
}),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_IN_OUT}`, style({
opacity: 0,
transform: 'translateY(-5px)'
}))
])
]);
/**
* 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 moveUpMotion = trigger('moveUpMotion', [
transition('* => enter', [
style({
transformOrigin: '0 0',
transform: 'translateY(-100%)',
opacity: 0
}),
animate(`${AnimationDuration.BASE}`, style({
transformOrigin: '0 0',
transform: 'translateY(0%)',
opacity: 1
}))
]),
transition('* => leave', [
style({
transformOrigin: '0 0',
transform: 'translateY(0%)',
opacity: 1
}),
animate(`${AnimationDuration.BASE}`, style({
transformOrigin: '0 0',
transform: 'translateY(-100%)',
opacity: 0
}))
])
]);
/**
* 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 notificationMotion = trigger('notificationMotion', [
state('enterRight', style({ opacity: 1, transform: 'translateX(0)' })),
transition('* => enterRight', [style({ opacity: 0, transform: 'translateX(5%)' }), animate('100ms linear')]),
state('enterLeft', style({ opacity: 1, transform: 'translateX(0)' })),
transition('* => enterLeft', [style({ opacity: 0, transform: 'translateX(-5%)' }), animate('100ms linear')]),
state('enterTop', style({ opacity: 1, transform: 'translateY(0)' })),
transition('* => enterTop', [style({ opacity: 0, transform: 'translateY(-5%)' }), animate('100ms linear')]),
state('enterBottom', style({ opacity: 1, transform: 'translateY(0)' })),
transition('* => enterBottom', [style({ opacity: 0, transform: 'translateY(5%)' }), animate('100ms linear')]),
state('leave', style({
opacity: 0,
transform: 'scaleY(0.8)',
transformOrigin: '0% 0%'
})),
transition('* => leave', [
style({
opacity: 1,
transform: 'scaleY(1)',
transformOrigin: '0% 0%'
}),
animate('100ms linear')
])
]);
/**
* 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 ANIMATION_TRANSITION_IN = `${AnimationDuration.BASE} ${AnimationCurves.EASE_OUT_QUINT}`;
const ANIMATION_TRANSITION_OUT = `${AnimationDuration.BASE} ${AnimationCurves.EASE_IN_QUINT}`;
const slideMotion = trigger('slideMotion', [
state('void', style({
opacity: 0,
transform: 'scaleY(0.8)'
})),
state('enter', style({
opacity: 1,
transform: 'scaleY(1)'
})),
transition('void => *', [animate(ANIMATION_TRANSITION_IN)]),
transition('* => void', [animate(ANIMATION_TRANSITION_OUT)])
]);
const slideAlertMotion = trigger('slideAlertMotion', [
transition(':leave', [
style({ opacity: 1, transform: 'scaleY(1)', transformOrigin: '0% 0%' }),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_IN_OUT_CIRC}`, style({
opacity: 0,
transform: 'scaleY(0)',
transformOrigin: '0% 0%'
}))
])
]);
/**
* 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 tabSwitchMotion = trigger('tabSwitchMotion', [
state('leave', style({
display: 'none'
})),
transition('* => enter', [
style({
display: 'block',
opacity: 0
}),
animate(AnimationDuration.SLOW)
]),
transition('* => leave, :leave', [
style({
position: 'absolute',
top: 0,
left: 0,
width: '100%'
}),
animate(AnimationDuration.SLOW, style({
opacity: 0
})),
style({
display: 'none'
})
])
]);
/**
* 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 thumbMotion = trigger('thumbMotion', [
state('from', style({ transform: 'translateX({{ transform }}px)', width: '{{ width }}px' }), {
params: { transform: 0, width: 0 }
}),
state('to', style({ transform: 'translateX({{ transform }}px)', width: '{{ width }}px' }), {
params: { transform: 100, width: 0 }
}),
state('fromVertical', style({ transform: 'translateY({{ transform }}px)', width: '{{ width }}px', height: '{{ height }}px' }), {
params: { transform: 0, width: 0, height: 0 }
}),
state('toVertical', style({ transform: 'translateY({{ transform }}px)', width: '{{ width }}px', height: '{{ height }}px' }), {
params: { transform: 100, width: 0, height: 0 }
}),
transition('from => to', animate(`300ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('fromVertical => toVertical', animate(`300ms ${AnimationCurves.EASE_IN_OUT}`))
]);
/**
* 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 zoomBigMotion = trigger('zoomBigMotion', [
transition('void => active', [
style({ opacity: 0, transform: 'scale(0.8)' }),
animate(`${AnimationDuration.BASE} ${AnimationCurves.EASE_OUT_CIRC}`, style({
opacity: 1,
transform: 'scale(1)'
}))
]),
transition('active => void', [
style({ opacity: 1, transform: 'scale(1)' }),
animate(`${AnimationDuration.BASE} ${AnimationCurves.EASE_IN_OUT_CIRC}`, style({
opacity: 0,
transform: 'scale(0.8)'
}))
])
]);
const zoomBadgeMotion = trigger('zoomBadgeMotion', [
transition(':enter', [
style({ opacity: 0, transform: 'scale(0) translate(50%, -50%)' }),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_OUT_BACK}`, style({
opacity: 1,
transform: 'scale(1) translate(50%, -50%)'
}))
]),
transition(':leave', [
style({ opacity: 1, transform: 'scale(1) translate(50%, -50%)' }),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_IN_BACK}`, style({
opacity: 0,
transform: 'scale(0) translate(50%, -50%)'
}))
])
]);
/**
* 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 { AnimationCurves, AnimationDuration, collapseMotion, drawerMaskMotion, fadeMotion, helpMotion, moveUpMotion, notificationMotion, slideAlertMotion, slideMotion, tabSwitchMotion, thumbMotion, treeCollapseMotion, zoomBadgeMotion, zoomBigMotion };
//# sourceMappingURL=ng-zorro-antd-core-animation.mjs.map
File diff suppressed because one or more lines are too long
+180
View File
@@ -0,0 +1,180 @@
import { rgbToHsv, rgbToHex, inputToRGB } from '@ctrl/tinycolor';
/**
* 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 statusColors = ['success', 'processing', 'error', 'default', 'warning'];
const presetColors = [
'pink',
'red',
'yellow',
'orange',
'cyan',
'green',
'blue',
'purple',
'geekblue',
'magenta',
'volcano',
'gold',
'lime'
];
function isPresetColor(color) {
return presetColors.indexOf(color) !== -1;
}
function isStatusColor(color) {
return statusColors.indexOf(color) !== -1;
}
/**
* 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
*/
/**
* Sync from @ant-design/colors(https://github.com/ant-design/ant-design-colors)
*/
const hueStep = 2; // 色相阶梯
const saturationStep = 0.16; // 饱和度阶梯,浅色部分
const saturationStep2 = 0.05; // 饱和度阶梯,深色部分
const brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
const brightnessStep2 = 0.15; // 亮度阶梯,深色部分
const lightColorCount = 5; // 浅色数量,主色上
const darkColorCount = 4; // 深色数量,主色下
// 暗色主题颜色映射关系表
const darkColorMap = [
{ index: 7, opacity: 0.15 },
{ index: 6, opacity: 0.25 },
{ index: 5, opacity: 0.3 },
{ index: 5, opacity: 0.45 },
{ index: 5, opacity: 0.65 },
{ index: 5, opacity: 0.85 },
{ index: 4, opacity: 0.9 },
{ index: 3, opacity: 0.95 },
{ index: 2, opacity: 0.97 },
{ index: 1, opacity: 0.98 }
];
// Wrapper function ported from TinyColor.prototype.toHsv
// Keep it here because of `hsv.h * 360`
function toHsv({ r, g, b }) {
const hsv = rgbToHsv(r, g, b);
return { h: hsv.h * 360, s: hsv.s, v: hsv.v };
}
// Wrapper function ported from TinyColor.prototype.toHexString
// Keep it here because of the prefix `#`
function toHex({ r, g, b }) {
return `#${rgbToHex(r, g, b, false)}`;
}
// Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
// Amount in range [0, 1]
// Assume color1 & color2 has no alpha, since the following src code did so.
function mix(rgb1, rgb2, amount) {
const p = amount / 100;
const rgb = {
r: (rgb2.r - rgb1.r) * p + rgb1.r,
g: (rgb2.g - rgb1.g) * p + rgb1.g,
b: (rgb2.b - rgb1.b) * p + rgb1.b
};
return rgb;
}
function getHue(hsv, i, light) {
let hue;
// 根据色相不同,色相转向不同
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
}
else {
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
}
if (hue < 0) {
hue += 360;
}
else if (hue >= 360) {
hue -= 360;
}
return hue;
}
function getSaturation(hsv, i, light) {
// grey color don't change saturation
if (hsv.h === 0 && hsv.s === 0) {
return hsv.s;
}
let saturation;
if (light) {
saturation = hsv.s - saturationStep * i;
}
else if (i === darkColorCount) {
saturation = hsv.s + saturationStep;
}
else {
saturation = hsv.s + saturationStep2 * i;
}
// 边界值修正
if (saturation > 1) {
saturation = 1;
}
// 第一格的 s 限制在 0.06-0.1 之间
if (light && i === lightColorCount && saturation > 0.1) {
saturation = 0.1;
}
if (saturation < 0.06) {
saturation = 0.06;
}
return Number(saturation.toFixed(2));
}
function getValue(hsv, i, light) {
let value;
if (light) {
value = hsv.v + brightnessStep1 * i;
}
else {
value = hsv.v - brightnessStep2 * i;
}
if (value > 1) {
value = 1;
}
return Number(value.toFixed(2));
}
function generate(color, opts = {}) {
const patterns = [];
const pColor = inputToRGB(color);
for (let i = lightColorCount; i > 0; i -= 1) {
const hsv = toHsv(pColor);
const colorString = toHex(inputToRGB({
h: getHue(hsv, i, true),
s: getSaturation(hsv, i, true),
v: getValue(hsv, i, true)
}));
patterns.push(colorString);
}
patterns.push(toHex(pColor));
for (let i = 1; i <= darkColorCount; i += 1) {
const hsv = toHsv(pColor);
const colorString = toHex(inputToRGB({
h: getHue(hsv, i),
s: getSaturation(hsv, i),
v: getValue(hsv, i)
}));
patterns.push(colorString);
}
// dark theme patterns
if (opts.theme === 'dark') {
return darkColorMap.map(({ index, opacity }) => {
const darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100));
return darkColorString;
});
}
return patterns;
}
/**
* 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 { generate, isPresetColor, isStatusColor, presetColors, statusColors };
//# sourceMappingURL=ng-zorro-antd-core-color.mjs.map
File diff suppressed because one or more lines are too long
+284
View File
@@ -0,0 +1,284 @@
import * as i0 from '@angular/core';
import { InjectionToken, makeEnvironmentProviders, inject, CSP_NONCE, signal, Injectable, assertInInjectionContext, DestroyRef, afterNextRender, computed } from '@angular/core';
import { SIGNAL } from '@angular/core/primitives/signals';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Subject } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { TinyColor } from '@ctrl/tinycolor';
import { generate } from 'ng-zorro-antd/core/color';
import { warn } from 'ng-zorro-antd/core/logger';
import { canUseDom, updateCSS } 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
*/
/**
* User should provide an object implements this interface to set global configurations.
*/
const NZ_CONFIG = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'nz-config' : '');
function provideNzConfig(config) {
return makeEnvironmentProviders([{ provide: NZ_CONFIG, useValue: config }]);
}
/**
* 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
*/
/**
* Sync from @ant-design/colors(https://github.com/ant-design/ant-design-colors)
*/
const dynamicStyleMark = `-ant-${Date.now()}-${Math.random()}`;
function getStyle(globalPrefixCls, theme) {
const variables = {};
const formatColor = (color, updater) => {
let clone = color.clone();
clone = updater?.(clone) || clone;
return clone.toRgbString();
};
const fillColor = (colorVal, type) => {
const baseColor = new TinyColor(colorVal);
const colorPalettes = generate(baseColor.toRgbString());
variables[`${type}-color`] = formatColor(baseColor);
variables[`${type}-color-disabled`] = colorPalettes[1];
variables[`${type}-color-hover`] = colorPalettes[4];
variables[`${type}-color-active`] = colorPalettes[7];
variables[`${type}-color-outline`] = baseColor.clone().setAlpha(0.2).toRgbString();
variables[`${type}-color-deprecated-bg`] = colorPalettes[1];
variables[`${type}-color-deprecated-border`] = colorPalettes[3];
};
// ================ Primary Color ================
if (theme.primaryColor) {
fillColor(theme.primaryColor, 'primary');
const primaryColor = new TinyColor(theme.primaryColor);
const primaryColors = generate(primaryColor.toRgbString());
// Legacy - We should use semantic naming standard
primaryColors.forEach((color, index) => {
variables[`primary-${index + 1}`] = color;
});
// Deprecated
variables['primary-color-deprecated-l-35'] = formatColor(primaryColor, c => c.lighten(35));
variables['primary-color-deprecated-l-20'] = formatColor(primaryColor, c => c.lighten(20));
variables['primary-color-deprecated-t-20'] = formatColor(primaryColor, c => c.tint(20));
variables['primary-color-deprecated-t-50'] = formatColor(primaryColor, c => c.tint(50));
variables['primary-color-deprecated-f-12'] = formatColor(primaryColor, c => c.setAlpha(c.getAlpha() * 0.12));
const primaryActiveColor = new TinyColor(primaryColors[0]);
variables['primary-color-active-deprecated-f-30'] = formatColor(primaryActiveColor, c => c.setAlpha(c.getAlpha() * 0.3));
variables['primary-color-active-deprecated-d-02'] = formatColor(primaryActiveColor, c => c.darken(2));
}
// ================ Success Color ================
if (theme.successColor) {
fillColor(theme.successColor, 'success');
}
// ================ Warning Color ================
if (theme.warningColor) {
fillColor(theme.warningColor, 'warning');
}
// ================= Error Color =================
if (theme.errorColor) {
fillColor(theme.errorColor, 'error');
}
// ================= Info Color ==================
if (theme.infoColor) {
fillColor(theme.infoColor, 'info');
}
// Convert to css variables
const cssList = Object.keys(variables).map(key => `--${globalPrefixCls}-${key}: ${variables[key]};`);
return `
:root {
${cssList.join('\n')}
}
`.trim();
}
function registerTheme(globalPrefixCls, theme, cspNonce) {
const style = getStyle(globalPrefixCls, theme);
if (canUseDom()) {
updateCSS(style, `${dynamicStyleMark}-dynamic-theme`, { cspNonce });
}
else {
warn(`NzConfigService: SSR do not support dynamic theme with css variables.`);
}
}
/**
* 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
*/
function isDefined(value) {
return value !== undefined;
}
const defaultPrefixCls = 'ant';
class NzConfigService {
configUpdated$ = new Subject();
/**
* Sharing config signals for all components, used for {@link withConfigFactory}
* @internal
* @todo use nested signal to refactor the whole config service
*/
_configMap = new Map();
/** Global config holding property. */
config = inject(NZ_CONFIG, { optional: true }) || {};
cspNonce = inject(CSP_NONCE, { optional: true });
constructor() {
if (this.config.theme) {
// If theme is set with NZ_CONFIG, register theme to make sure css variables work
registerTheme(this.getConfig().prefixCls?.prefixCls || defaultPrefixCls, this.config.theme, this.cspNonce);
}
}
_getConfigValue(componentName) {
let configValue = this._configMap.get(componentName);
if (configValue) {
return configValue;
}
configValue = signal(this.config[componentName]);
this._configMap.set(componentName, configValue);
return configValue;
}
getConfig() {
return this.config;
}
getConfigForComponent(componentName) {
return this.config[componentName];
}
getConfigChangeEventForComponent(componentName) {
return this.configUpdated$.pipe(filter(n => n === componentName), map(() => undefined));
}
set(componentName, value) {
this.config[componentName] = { ...this.config[componentName], ...value };
this._configMap.get(componentName)?.set(this.config[componentName]);
if (componentName === 'theme' && this.config.theme) {
registerTheme(this.getConfig().prefixCls?.prefixCls || defaultPrefixCls, this.config.theme, this.cspNonce);
}
this.configUpdated$.next(componentName);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzConfigService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzConfigService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: () => [] });
/**
* Subscribes to configuration change events for a specific NZ component after the next render cycle.
*
* This utility is intended for use within Angular injection contexts and handles automatic
* unsubscription via `DestroyRef`. It returns a cleanup function that can be manually called
* to unsubscribe early if needed.
*
* @param componentName - The name of the component (as defined in `NzConfigKey`) to listen for config changes.
* @param callback - A function to invoke when the component's configuration changes.
* @returns A cleanup function that destroys the post-render effect and unsubscribes from the config event.
*
* @throws If called outside of an Angular injection context (in dev mode).
*/
function onConfigChangeEventForComponent(componentName, callback) {
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
assertInInjectionContext(onConfigChangeEventForComponent);
}
const destroyRef = inject(DestroyRef);
const nzConfigService = inject(NzConfigService);
let subscription = null;
const ref = afterNextRender(() => {
subscription = nzConfigService
.getConfigChangeEventForComponent(componentName)
.pipe(takeUntilDestroyed(destroyRef))
.subscribe(callback);
});
return () => {
ref.destroy();
subscription?.unsubscribe();
};
}
/**
* This decorator is used to decorate class field. If a class field is decorated and unassigned, it would try to load default value from `NZ_CONFIG`
*
* @note that the class must have `_nzModuleName`({@link NzConfigKey}) property.
* @example
* ```ts
* class ExampleComponent {
* private readonly _nzModuleName: NzConfigKey = 'button';
* @WithConfig() size: string = 'default';
* }
* ```
*/
function WithConfig() {
return function (_value, context) {
context.addInitializer(function () {
const nzConfigService = inject(NzConfigService);
const originalValue = this[context.name];
let value;
let assignedByUser = false;
Object.defineProperty(this, context.name, {
get: () => {
const configValue = nzConfigService.getConfigForComponent(this['_nzModuleName'])?.[context.name];
if (assignedByUser) {
return value;
}
if (isDefined(configValue)) {
return configValue;
}
return originalValue;
},
set: (newValue) => {
// if the newValue is undefined, we also consider it as not assigned by user
assignedByUser = isDefined(newValue);
value = newValue;
},
enumerable: true,
configurable: true
});
});
};
}
/**
* Generate a `withConfig` function for a specific component, which would try to load default value from `NZ_CONFIG`
* if the `input` property is not assigned by user.
*
* @param componentName The name of component (as defined in {@link NzConfigKey}) to listen for config changes.
* @example
* ```ts
* const withConfig = withConfigFactory('button');
*
* class ExampleComponent {
* readonly nzSize = input<NzButtonSize>('default');
* protected readonly size = withConfig('nzSize', this.nzSize);
* }
* ```
*/
function withConfigFactory(componentName) {
/**
* @param name The name of input property.
* @param inputSignal The input signal.
* @param defaultValue The default value.
*/
return (name, inputSignal, defaultValue) => {
const configValueSignal = inject(NzConfigService)['_getConfigValue'](componentName);
return computed(() => {
const configValue = configValueSignal()?.[name];
const inputValue = inputSignal();
// if the version of the inputSignal is 0 or the inputValue is undefined, we consider it as not assigned by user
const assignedByUser = inputSignal[SIGNAL].version > 0 && isDefined(inputValue);
if (assignedByUser) {
return inputValue;
}
if (isDefined(configValue)) {
return configValue;
}
return defaultValue;
});
};
}
/**
* 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_CONFIG, NzConfigService, WithConfig, getStyle, onConfigChangeEventForComponent, provideNzConfig, registerTheme, withConfigFactory };
//# sourceMappingURL=ng-zorro-antd-core-config.mjs.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,54 @@
import * as i0 from '@angular/core';
import { inject, ElementRef, Directive, NgModule } from '@angular/core';
/**
* 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
*/
/**
* A patch directive to select the element of a component.
*/
class NzElementPatchDirective {
elementRef = inject((ElementRef));
get nativeElement() {
return this.elementRef.nativeElement;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzElementPatchDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzElementPatchDirective, isStandalone: true, selector: "[nzElement], [nz-element]", exportAs: ["nzElement"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzElementPatchDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzElement], [nz-element]',
exportAs: 'nzElement'
}]
}] });
/**
* 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 NzElementPatchModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzElementPatchModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzElementPatchModule, imports: [NzElementPatchDirective], exports: [NzElementPatchDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzElementPatchModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzElementPatchModule, decorators: [{
type: NgModule,
args: [{
imports: [NzElementPatchDirective],
exports: [NzElementPatchDirective]
}]
}] });
/**
* 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 { NzElementPatchDirective, NzElementPatchModule };
//# sourceMappingURL=ng-zorro-antd-core-element-patch.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-element-patch.mjs","sources":["../../components/core/element-patch/element-patch.directive.ts","../../components/core/element-patch/element-patch.module.ts","../../components/core/element-patch/public-api.ts","../../components/core/element-patch/ng-zorro-antd-core-element-patch.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Directive, ElementRef, inject } from '@angular/core';\n\nimport { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n/**\n * A patch directive to select the element of a component.\n */\n@Directive({\n selector: '[nzElement], [nz-element]',\n exportAs: 'nzElement'\n})\nexport class NzElementPatchDirective {\n public elementRef = inject(ElementRef<HTMLElement>);\n get nativeElement(): NzSafeAny {\n return this.elementRef.nativeElement;\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { NgModule } from '@angular/core';\n\nimport { NzElementPatchDirective } from './element-patch.directive';\n\n@NgModule({\n imports: [NzElementPatchDirective],\n exports: [NzElementPatchDirective]\n})\nexport class NzElementPatchModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './element-patch.directive';\nexport * from './element-patch.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;AAGG;AAMH;;AAEG;MAKU,uBAAuB,CAAA;AAC3B,IAAA,UAAU,GAAG,MAAM,EAAC,UAAuB,EAAC;AACnD,IAAA,IAAI,aAAa,GAAA;AACf,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa;IACtC;uGAJW,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAvB,uBAAuB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,2BAAA,EAAA,QAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAJnC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,2BAA2B;AACrC,oBAAA,QAAQ,EAAE;AACX,iBAAA;;;ACfD;;;AAGG;MAUU,oBAAoB,CAAA;uGAApB,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAApB,oBAAoB,EAAA,OAAA,EAAA,CAHrB,uBAAuB,CAAA,EAAA,OAAA,EAAA,CACvB,uBAAuB,CAAA,EAAA,CAAA;wGAEtB,oBAAoB,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAJhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,uBAAuB,CAAC;oBAClC,OAAO,EAAE,CAAC,uBAAuB;AAClC,iBAAA;;;ACZD;;;AAGG;;ACHH;;AAEG;;;;"}
@@ -0,0 +1,19 @@
/**
* 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 environment = {
isTestMode: 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
*/
/**
* Generated bundle index. Do not edit.
*/
export { environment };
//# sourceMappingURL=ng-zorro-antd-core-environments.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-environments.mjs","sources":["../../components/core/environments/environment.ts","../../components/core/environments/public-api.ts","../../components/core/environments/ng-zorro-antd-core-environments.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport const environment = {\n isTestMode: false\n};\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './environment';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;AAGG;AAEI,MAAM,WAAW,GAAG;AACzB,IAAA,UAAU,EAAE;;;ACNd;;;AAGG;;ACHH;;AAEG;;;;"}
+100
View File
@@ -0,0 +1,100 @@
import * as i0 from '@angular/core';
import { Injectable, inject, ChangeDetectorRef, Input, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
import { ReplaySubject, BehaviorSubject } from 'rxjs';
import * as i1 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
/**
* 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 NzFormStatusService {
formStatusChanges = new ReplaySubject(1);
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzFormStatusService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzFormStatusService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzFormStatusService, decorators: [{
type: Injectable
}] });
/**
* 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
*/
// Used in input-group/input-number-group to make sure components in addon work well
/**
* @deprecated Will be removed in v22.0.0. This service will be removed along with input-group/input-number-group.
*/
class NzFormNoStatusService {
noFormStatus = new BehaviorSubject(false);
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzFormNoStatusService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzFormNoStatusService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzFormNoStatusService, decorators: [{
type: Injectable
}] });
/**
* 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 iconTypeMap = {
error: 'close-circle-fill',
validating: 'loading',
success: 'check-circle-fill',
warning: 'exclamation-circle-fill'
};
class NzFormItemFeedbackIconComponent {
cdr = inject(ChangeDetectorRef);
status = '';
iconType = null;
ngOnChanges(_changes) {
this.updateIcon();
}
updateIcon() {
this.iconType = this.status ? iconTypeMap[this.status] : null;
this.cdr.markForCheck();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzFormItemFeedbackIconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzFormItemFeedbackIconComponent, isStandalone: true, selector: "nz-form-item-feedback-icon", inputs: { status: "status" }, host: { properties: { "class.ant-form-item-feedback-icon-error": "status===\"error\"", "class.ant-form-item-feedback-icon-warning": "status===\"warning\"", "class.ant-form-item-feedback-icon-success": "status===\"success\"", "class.ant-form-item-feedback-icon-validating": "status===\"validating\"" }, classAttribute: "ant-form-item-feedback-icon" }, exportAs: ["nzFormFeedbackIcon"], usesOnChanges: true, ngImport: i0, template: `
@if (iconType) {
<nz-icon [nzType]="iconType" />
}
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1.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: "20.3.0", ngImport: i0, type: NzFormItemFeedbackIconComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-form-item-feedback-icon',
exportAs: 'nzFormFeedbackIcon',
imports: [NzIconModule],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@if (iconType) {
<nz-icon [nzType]="iconType" />
}
`,
host: {
class: 'ant-form-item-feedback-icon',
'[class.ant-form-item-feedback-icon-error]': 'status==="error"',
'[class.ant-form-item-feedback-icon-warning]': 'status==="warning"',
'[class.ant-form-item-feedback-icon-success]': 'status==="success"',
'[class.ant-form-item-feedback-icon-validating]': 'status==="validating"'
}
}]
}], propDecorators: { status: [{
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
*/
/**
* Generated bundle index. Do not edit.
*/
export { NzFormItemFeedbackIconComponent, NzFormNoStatusService, NzFormStatusService };
//# sourceMappingURL=ng-zorro-antd-core-form.mjs.map
File diff suppressed because one or more lines are too long
+62
View File
@@ -0,0 +1,62 @@
import * as i0 from '@angular/core';
import { Pipe, NgModule } from '@angular/core';
import { encodeEntities } 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
*/
class NzHighlightPipe {
UNIQUE_WRAPPERS = ['##==-open_tag-==##', '##==-close_tag-==##'];
transform(value, highlightValue, flags, klass) {
if (!highlightValue) {
return value;
}
// Escapes regex keyword to interpret these characters literally
const searchValue = new RegExp(highlightValue.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$&'), flags);
const wrapValue = value.replace(searchValue, `${this.UNIQUE_WRAPPERS[0]}$&${this.UNIQUE_WRAPPERS[1]}`);
return encodeEntities(wrapValue)
.replace(new RegExp(this.UNIQUE_WRAPPERS[0], 'g'), klass ? `<span class="${klass}">` : '<span>')
.replace(new RegExp(this.UNIQUE_WRAPPERS[1], 'g'), '</span>');
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzHighlightPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzHighlightPipe, isStandalone: true, name: "nzHighlight" });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzHighlightPipe, decorators: [{
type: Pipe,
args: [{
name: 'nzHighlight'
}]
}] });
/**
* 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 Will be removed in v21, use `NzHighlightPipe` directly instead.
*/
class NzHighlightModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzHighlightModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzHighlightModule, imports: [NzHighlightPipe], exports: [NzHighlightPipe] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzHighlightModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzHighlightModule, decorators: [{
type: NgModule,
args: [{
imports: [NzHighlightPipe],
exports: [NzHighlightPipe]
}]
}] });
/**
* 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 { NzHighlightModule, NzHighlightPipe };
//# sourceMappingURL=ng-zorro-antd-core-highlight.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-highlight.mjs","sources":["../../components/core/highlight/highlight.pipe.ts","../../components/core/highlight/highlight.module.ts","../../components/core/highlight/public-api.ts","../../components/core/highlight/ng-zorro-antd-core-highlight.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Pipe, PipeTransform } from '@angular/core';\n\nimport { encodeEntities } from 'ng-zorro-antd/core/util';\n\n@Pipe({\n name: 'nzHighlight'\n})\nexport class NzHighlightPipe implements PipeTransform {\n private UNIQUE_WRAPPERS: [string, string] = ['##==-open_tag-==##', '##==-close_tag-==##'];\n\n transform(value: string, highlightValue: string, flags?: string, klass?: string): string | null {\n if (!highlightValue) {\n return value;\n }\n\n // Escapes regex keyword to interpret these characters literally\n const searchValue = new RegExp(highlightValue.replace(/([.*+?^=!:${}()|[\\]/\\\\])/g, '\\\\$&'), flags);\n const wrapValue = value.replace(searchValue, `${this.UNIQUE_WRAPPERS[0]}$&${this.UNIQUE_WRAPPERS[1]}`);\n return encodeEntities(wrapValue)\n .replace(new RegExp(this.UNIQUE_WRAPPERS[0], 'g'), klass ? `<span class=\"${klass}\">` : '<span>')\n .replace(new RegExp(this.UNIQUE_WRAPPERS[1], 'g'), '</span>');\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { NgModule } from '@angular/core';\n\nimport { NzHighlightPipe } from './highlight.pipe';\n\n/**\n * @deprecated Will be removed in v21, use `NzHighlightPipe` directly instead.\n */\n@NgModule({\n imports: [NzHighlightPipe],\n exports: [NzHighlightPipe]\n})\nexport class NzHighlightModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './highlight.pipe';\nexport * from './highlight.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;MASU,eAAe,CAAA;AAClB,IAAA,eAAe,GAAqB,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;AAEzF,IAAA,SAAS,CAAC,KAAa,EAAE,cAAsB,EAAE,KAAc,EAAE,KAAc,EAAA;QAC7E,IAAI,CAAC,cAAc,EAAE;AACnB,YAAA,OAAO,KAAK;QACd;;AAGA,QAAA,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,2BAA2B,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC;QAClG,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAA,EAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA,EAAA,EAAK,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;QACtG,OAAO,cAAc,CAAC,SAAS;aAC5B,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,CAAA,aAAA,EAAgB,KAAK,CAAA,EAAA,CAAI,GAAG,QAAQ;AAC9F,aAAA,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC;IACjE;uGAdW,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;qGAAf,eAAe,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,aAAA,EAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE;AACP,iBAAA;;;ACXD;;;AAGG;AAMH;;AAEG;MAKU,iBAAiB,CAAA;uGAAjB,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAjB,iBAAiB,EAAA,OAAA,EAAA,CAHlB,eAAe,CAAA,EAAA,OAAA,EAAA,CACf,eAAe,CAAA,EAAA,CAAA;wGAEd,iBAAiB,EAAA,CAAA;;2FAAjB,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAJ7B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,eAAe,CAAC;oBAC1B,OAAO,EAAE,CAAC,eAAe;AAC1B,iBAAA;;;ACfD;;;AAGG;;ACHH;;AAEG;;;;"}
+54
View File
@@ -0,0 +1,54 @@
import { isDevMode } from '@angular/core';
import { environment } from 'ng-zorro-antd/core/environments';
/**
* 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 record = {};
const PREFIX = '[NG-ZORRO]:';
function notRecorded(...args) {
const asRecord = args.reduce((acc, c) => acc + c.toString(), '');
if (record[asRecord]) {
return false;
}
else {
record[asRecord] = true;
return true;
}
}
function consoleCommonBehavior(consoleFunc, ...args) {
if (environment.isTestMode || (isDevMode() && notRecorded(...args))) {
consoleFunc(...args);
}
}
// Warning should only be printed in dev mode and only once.
const warn = (...args) => consoleCommonBehavior((...arg) => console.warn(PREFIX, ...arg), ...args);
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const warnDeprecation = (...args) => {
if (!environment.isTestMode) {
const stack = new Error().stack;
return consoleCommonBehavior((...arg) => console.warn(PREFIX, 'deprecated:', ...arg, stack), ...args);
}
else {
return () => { };
}
};
// Log should only be printed in dev mode.
const log = (...args) => {
if (isDevMode()) {
console.log(PREFIX, ...args);
}
};
/**
* 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 { PREFIX, log, warn, warnDeprecation };
//# sourceMappingURL=ng-zorro-antd-core-logger.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-logger.mjs","sources":["../../components/core/logger/logger.ts","../../components/core/logger/public-api.ts","../../components/core/logger/ng-zorro-antd-core-logger.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { isDevMode } from '@angular/core';\n\nimport { environment } from 'ng-zorro-antd/core/environments';\nimport { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nconst record: Record<string, boolean> = {};\n\nexport const PREFIX = '[NG-ZORRO]:';\n\nfunction notRecorded(...args: NzSafeAny[]): boolean {\n const asRecord = args.reduce((acc, c) => acc + c.toString(), '');\n\n if (record[asRecord]) {\n return false;\n } else {\n record[asRecord] = true;\n return true;\n }\n}\n\nfunction consoleCommonBehavior(consoleFunc: (...args: NzSafeAny) => void, ...args: NzSafeAny[]): void {\n if (environment.isTestMode || (isDevMode() && notRecorded(...args))) {\n consoleFunc(...args);\n }\n}\n\n// Warning should only be printed in dev mode and only once.\nexport const warn = (...args: NzSafeAny[]): void =>\n consoleCommonBehavior((...arg: NzSafeAny[]) => console.warn(PREFIX, ...arg), ...args);\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport const warnDeprecation = (...args: NzSafeAny[]) => {\n if (!environment.isTestMode) {\n const stack = new Error().stack;\n return consoleCommonBehavior((...arg: NzSafeAny[]) => console.warn(PREFIX, 'deprecated:', ...arg, stack), ...args);\n } else {\n return () => {};\n }\n};\n\n// Log should only be printed in dev mode.\nexport const log = (...args: NzSafeAny[]): void => {\n if (isDevMode()) {\n console.log(PREFIX, ...args);\n }\n};\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './logger';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;AAGG;AAOH,MAAM,MAAM,GAA4B,EAAE;AAEnC,MAAM,MAAM,GAAG;AAEtB,SAAS,WAAW,CAAC,GAAG,IAAiB,EAAA;IACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC;AAEhE,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE;AACpB,QAAA,OAAO,KAAK;IACd;SAAO;AACL,QAAA,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI;AACvB,QAAA,OAAO,IAAI;IACb;AACF;AAEA,SAAS,qBAAqB,CAAC,WAAyC,EAAE,GAAG,IAAiB,EAAA;AAC5F,IAAA,IAAI,WAAW,CAAC,UAAU,KAAK,SAAS,EAAE,IAAI,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE;AACnE,QAAA,WAAW,CAAC,GAAG,IAAI,CAAC;IACtB;AACF;AAEA;AACO,MAAM,IAAI,GAAG,CAAC,GAAG,IAAiB,KACvC,qBAAqB,CAAC,CAAC,GAAG,GAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,IAAI;AAEtF;MACa,eAAe,GAAG,CAAC,GAAG,IAAiB,KAAI;AACtD,IAAA,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;AAC3B,QAAA,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK;QAC/B,OAAO,qBAAqB,CAAC,CAAC,GAAG,GAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC;IACpH;SAAO;AACL,QAAA,OAAO,MAAK,EAAE,CAAC;IACjB;AACF;AAEA;MACa,GAAG,GAAG,CAAC,GAAG,IAAiB,KAAU;IAChD,IAAI,SAAS,EAAE,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;IAC9B;AACF;;AClDA;;;AAGG;;ACHH;;AAEG;;;;"}
@@ -0,0 +1,56 @@
import * as i0 from '@angular/core';
import { inject, booleanAttribute, Input, Directive, NgModule } from '@angular/core';
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
/**
* 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 NzNoAnimationDirective {
animationType = inject(ANIMATION_MODULE_TYPE, { optional: true });
nzNoAnimation = false;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzNoAnimationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.3.0", type: NzNoAnimationDirective, isStandalone: true, selector: "[nzNoAnimation]", inputs: { nzNoAnimation: ["nzNoAnimation", "nzNoAnimation", booleanAttribute] }, host: { properties: { "class.nz-animate-disabled": "nzNoAnimation || animationType === 'NoopAnimations'" } }, exportAs: ["nzNoAnimation"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzNoAnimationDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzNoAnimation]',
exportAs: 'nzNoAnimation',
host: {
'[class.nz-animate-disabled]': `nzNoAnimation || animationType === 'NoopAnimations'`
}
}]
}], propDecorators: { nzNoAnimation: [{
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 NzNoAnimationModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzNoAnimationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzNoAnimationModule, imports: [NzNoAnimationDirective], exports: [NzNoAnimationDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzNoAnimationModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzNoAnimationModule, decorators: [{
type: NgModule,
args: [{
imports: [NzNoAnimationDirective],
exports: [NzNoAnimationDirective]
}]
}] });
/**
* 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 { NzNoAnimationDirective, NzNoAnimationModule };
//# sourceMappingURL=ng-zorro-antd-core-no-animation.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-no-animation.mjs","sources":["../../components/core/no-animation/nz-no-animation.directive.ts","../../components/core/no-animation/nz-no-animation.module.ts","../../components/core/no-animation/public-api.ts","../../components/core/no-animation/ng-zorro-antd-core-no-animation.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Directive, Input, booleanAttribute, inject } from '@angular/core';\nimport { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';\n\n@Directive({\n selector: '[nzNoAnimation]',\n exportAs: 'nzNoAnimation',\n host: {\n '[class.nz-animate-disabled]': `nzNoAnimation || animationType === 'NoopAnimations'`\n }\n})\nexport class NzNoAnimationDirective {\n animationType = inject(ANIMATION_MODULE_TYPE, { optional: true });\n @Input({ transform: booleanAttribute }) nzNoAnimation: boolean = false;\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { NgModule } from '@angular/core';\n\nimport { NzNoAnimationDirective } from './nz-no-animation.directive';\n\n@NgModule({\n imports: [NzNoAnimationDirective],\n exports: [NzNoAnimationDirective]\n})\nexport class NzNoAnimationModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport { NzNoAnimationModule } from './nz-no-animation.module';\nexport { NzNoAnimationDirective } from './nz-no-animation.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;MAYU,sBAAsB,CAAA;IACjC,aAAa,GAAG,MAAM,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzB,aAAa,GAAY,KAAK;uGAF3D,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAtB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,sBAAsB,+GAEb,gBAAgB,CAAA,EAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,2BAAA,EAAA,qDAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,eAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAFzB,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAPlC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,iBAAiB;AAC3B,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,IAAI,EAAE;AACJ,wBAAA,6BAA6B,EAAE,CAAA,mDAAA;AAChC;AACF,iBAAA;8BAGyC,aAAa,EAAA,CAAA;sBAApD,KAAK;uBAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE;;;ACjBxC;;;AAGG;MAUU,mBAAmB,CAAA;uGAAnB,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAnB,mBAAmB,EAAA,OAAA,EAAA,CAHpB,sBAAsB,CAAA,EAAA,OAAA,EAAA,CACtB,sBAAsB,CAAA,EAAA,CAAA;wGAErB,mBAAmB,EAAA,CAAA;;2FAAnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAJ/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,sBAAsB,CAAC;oBACjC,OAAO,EAAE,CAAC,sBAAsB;AACjC,iBAAA;;;ACZD;;;AAGG;;ACHH;;AAEG;;;;"}
+123
View File
@@ -0,0 +1,123 @@
import * as i0 from '@angular/core';
import { inject, ViewContainerRef, TemplateRef, Input, Directive, NgModule } from '@angular/core';
import { isTemplateRef } 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
*/
class NzStringTemplateOutletDirective {
viewContainer = inject(ViewContainerRef);
templateRef = inject((TemplateRef));
embeddedViewRef = null;
context = new NzStringTemplateOutletContext();
nzStringTemplateOutletContext = null;
nzStringTemplateOutlet = null;
static ngTemplateContextGuard(_dir, _ctx) {
return true;
}
recreateView() {
this.viewContainer.clear();
if (isTemplateRef(this.nzStringTemplateOutlet)) {
this.embeddedViewRef = this.viewContainer.createEmbeddedView(this.nzStringTemplateOutlet, this.nzStringTemplateOutletContext);
}
else {
this.embeddedViewRef = this.viewContainer.createEmbeddedView(this.templateRef, this.context);
}
}
updateContext() {
const newCtx = isTemplateRef(this.nzStringTemplateOutlet) ? this.nzStringTemplateOutletContext : this.context;
const oldCtx = this.embeddedViewRef.context;
if (newCtx) {
for (const propName of Object.keys(newCtx)) {
oldCtx[propName] = newCtx[propName];
}
}
}
ngOnChanges(changes) {
const { nzStringTemplateOutletContext, nzStringTemplateOutlet } = changes;
const shouldRecreateView = () => {
let shouldOutletRecreate = false;
if (nzStringTemplateOutlet) {
shouldOutletRecreate =
nzStringTemplateOutlet.firstChange ||
isTemplateRef(nzStringTemplateOutlet.previousValue) ||
isTemplateRef(nzStringTemplateOutlet.currentValue);
}
const hasContextShapeChanged = (ctxChange) => {
const prevCtxKeys = Object.keys(ctxChange.previousValue || {});
const currCtxKeys = Object.keys(ctxChange.currentValue || {});
if (prevCtxKeys.length === currCtxKeys.length) {
for (const propName of currCtxKeys) {
if (prevCtxKeys.indexOf(propName) === -1) {
return true;
}
}
return false;
}
else {
return true;
}
};
const shouldContextRecreate = nzStringTemplateOutletContext && hasContextShapeChanged(nzStringTemplateOutletContext);
return shouldContextRecreate || shouldOutletRecreate;
};
if (nzStringTemplateOutlet) {
this.context.$implicit = nzStringTemplateOutlet.currentValue;
}
const recreateView = shouldRecreateView();
if (recreateView) {
/** recreate view when context shape or outlet change **/
this.recreateView();
}
else {
/** update context **/
this.updateContext();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzStringTemplateOutletDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzStringTemplateOutletDirective, isStandalone: true, selector: "[nzStringTemplateOutlet]", inputs: { nzStringTemplateOutletContext: "nzStringTemplateOutletContext", nzStringTemplateOutlet: "nzStringTemplateOutlet" }, exportAs: ["nzStringTemplateOutlet"], usesOnChanges: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzStringTemplateOutletDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzStringTemplateOutlet]',
exportAs: 'nzStringTemplateOutlet'
}]
}], propDecorators: { nzStringTemplateOutletContext: [{
type: Input
}], nzStringTemplateOutlet: [{
type: Input
}] } });
class NzStringTemplateOutletContext {
$implicit;
}
/**
* 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 NzOutletModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOutletModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzOutletModule, imports: [NzStringTemplateOutletDirective], exports: [NzStringTemplateOutletDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOutletModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOutletModule, decorators: [{
type: NgModule,
args: [{
imports: [NzStringTemplateOutletDirective],
exports: [NzStringTemplateOutletDirective]
}]
}] });
/**
* 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 { NzOutletModule, NzStringTemplateOutletDirective };
//# sourceMappingURL=ng-zorro-antd-core-outlet.mjs.map
File diff suppressed because one or more lines are too long
+222
View File
@@ -0,0 +1,222 @@
import { ConnectionPositionPair, CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
import * as i0 from '@angular/core';
import { inject, ElementRef, booleanAttribute, Input, Directive, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
/**
* 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 POSITION_MAP = {
top: new ConnectionPositionPair({ originX: 'center', originY: 'top' }, { overlayX: 'center', overlayY: 'bottom' }),
topCenter: new ConnectionPositionPair({ originX: 'center', originY: 'top' }, { overlayX: 'center', overlayY: 'bottom' }),
topLeft: new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' }),
topRight: new ConnectionPositionPair({ originX: 'end', originY: 'top' }, { overlayX: 'end', overlayY: 'bottom' }),
right: new ConnectionPositionPair({ originX: 'end', originY: 'center' }, { overlayX: 'start', overlayY: 'center' }),
rightTop: new ConnectionPositionPair({ originX: 'end', originY: 'top' }, { overlayX: 'start', overlayY: 'top' }),
rightBottom: new ConnectionPositionPair({ originX: 'end', originY: 'bottom' }, { overlayX: 'start', overlayY: 'bottom' }),
bottom: new ConnectionPositionPair({ originX: 'center', originY: 'bottom' }, { overlayX: 'center', overlayY: 'top' }),
bottomCenter: new ConnectionPositionPair({ originX: 'center', originY: 'bottom' }, { overlayX: 'center', overlayY: 'top' }),
bottomLeft: new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'top' }),
bottomRight: new ConnectionPositionPair({ originX: 'end', originY: 'bottom' }, { overlayX: 'end', overlayY: 'top' }),
left: new ConnectionPositionPair({ originX: 'start', originY: 'center' }, { overlayX: 'end', overlayY: 'center' }),
leftTop: new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'end', overlayY: 'top' }),
leftBottom: new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'end', overlayY: 'bottom' })
};
/**
* @internal
* @param offset offset in pixels which should not be less than 0.
* The default value is `12`, which means `(arrow-size / 2) + 4`
*/
const positionOffsetMapFactory = (offset = 12) => ({
top: [0, -offset],
topCenter: [0, -offset],
topLeft: [0, -offset],
topRight: [0, -offset],
right: [offset, 0],
rightTop: [offset, 0],
rightBottom: [offset, 0],
bottom: [0, offset],
bottomCenter: [0, offset],
bottomLeft: [0, offset],
bottomRight: [0, offset],
left: [-offset, 0],
leftTop: [-offset, 0],
leftBottom: [-offset, 0]
});
const TOOLTIP_OFFSET_MAP = positionOffsetMapFactory();
const DEFAULT_TOOLTIP_POSITIONS = [
setConnectedPositionOffset(POSITION_MAP.top, TOOLTIP_OFFSET_MAP.top),
setConnectedPositionOffset(POSITION_MAP.right, TOOLTIP_OFFSET_MAP.right),
setConnectedPositionOffset(POSITION_MAP.bottom, TOOLTIP_OFFSET_MAP.bottom),
setConnectedPositionOffset(POSITION_MAP.left, TOOLTIP_OFFSET_MAP.left)
];
const DEFAULT_CASCADER_POSITIONS = [
POSITION_MAP.bottomLeft,
POSITION_MAP.bottomRight,
POSITION_MAP.topLeft,
POSITION_MAP.topRight
];
const DEFAULT_MENTION_TOP_POSITIONS = [
new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'bottom' }),
new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'end', overlayY: 'bottom' })
];
const DEFAULT_MENTION_BOTTOM_POSITIONS = [
POSITION_MAP.bottomLeft,
new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'end', overlayY: 'top' })
];
function getPlacementName(position) {
for (const placement in POSITION_MAP) {
if (position.connectionPair.originX === POSITION_MAP[placement].originX &&
position.connectionPair.originY === POSITION_MAP[placement].originY &&
position.connectionPair.overlayX === POSITION_MAP[placement].overlayX &&
position.connectionPair.overlayY === POSITION_MAP[placement].overlayY) {
return placement;
}
}
return undefined;
}
const DATE_PICKER_POSITION_MAP = {
bottomLeft: new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'top' }, undefined, 2),
topLeft: new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' }, undefined, -2),
bottomRight: new ConnectionPositionPair({ originX: 'end', originY: 'bottom' }, { overlayX: 'end', overlayY: 'top' }, undefined, 2),
topRight: new ConnectionPositionPair({ originX: 'end', originY: 'top' }, { overlayX: 'end', overlayY: 'bottom' }, undefined, -2)
};
const DEFAULT_DATE_PICKER_POSITIONS = [
DATE_PICKER_POSITION_MAP.bottomLeft,
DATE_PICKER_POSITION_MAP.topLeft,
DATE_PICKER_POSITION_MAP.bottomRight,
DATE_PICKER_POSITION_MAP.topRight
];
function normalizeConnectedPositionOffset(offset) {
return Array.isArray(offset) ? offset : [offset, offset];
}
function setConnectedPositionOffset(position, offset) {
const [offsetX, offsetY] = normalizeConnectedPositionOffset(offset);
// return new object
return {
...position,
offsetX: offsetX,
offsetY: offsetY
};
}
/**
* 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 NzConnectedOverlayDirective {
cdkConnectedOverlay = inject(CdkConnectedOverlay);
nzArrowPointAtCenter = false;
constructor() {
this.cdkConnectedOverlay.backdropClass = 'nz-overlay-transparent-backdrop';
this.cdkConnectedOverlay.positionChange.pipe(takeUntilDestroyed()).subscribe(position => {
if (this.nzArrowPointAtCenter) {
this.updateArrowPosition(position);
}
});
}
updateArrowPosition(position) {
const originRect = this.getOriginRect();
const placement = getPlacementName(position);
let offsetX = 0;
let offsetY = 0;
if (placement === 'topLeft' || placement === 'bottomLeft') {
offsetX = originRect.width / 2 - 14;
}
else if (placement === 'topRight' || placement === 'bottomRight') {
offsetX = -(originRect.width / 2 - 14);
}
else if (placement === 'leftTop' || placement === 'rightTop') {
offsetY = originRect.height / 2 - 10;
}
else if (placement === 'leftBottom' || placement === 'rightBottom') {
offsetY = -(originRect.height / 2 - 10);
}
if (this.cdkConnectedOverlay.offsetX !== offsetX || this.cdkConnectedOverlay.offsetY !== offsetY) {
this.cdkConnectedOverlay.offsetY = offsetY;
this.cdkConnectedOverlay.offsetX = offsetX;
this.cdkConnectedOverlay.overlayRef.updatePosition();
}
}
getFlexibleConnectedPositionStrategyOrigin() {
if (this.cdkConnectedOverlay.origin instanceof CdkOverlayOrigin) {
return this.cdkConnectedOverlay.origin.elementRef;
}
else {
return this.cdkConnectedOverlay.origin;
}
}
getOriginRect() {
const origin = this.getFlexibleConnectedPositionStrategyOrigin();
if (origin instanceof ElementRef) {
return origin.nativeElement.getBoundingClientRect();
}
// Check for Element so SVG elements are also supported.
if (origin instanceof Element) {
return origin.getBoundingClientRect();
}
const width = origin.width || 0;
const height = origin.height || 0;
// If the origin is a point, return a client rect as if it was a 0x0 element at the point.
return {
top: origin.y,
bottom: origin.y + height,
left: origin.x,
right: origin.x + width,
height,
width
};
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzConnectedOverlayDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.3.0", type: NzConnectedOverlayDirective, isStandalone: true, selector: "[cdkConnectedOverlay][nzConnectedOverlay]", inputs: { nzArrowPointAtCenter: ["nzArrowPointAtCenter", "nzArrowPointAtCenter", booleanAttribute] }, exportAs: ["nzConnectedOverlay"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzConnectedOverlayDirective, decorators: [{
type: Directive,
args: [{
selector: '[cdkConnectedOverlay][nzConnectedOverlay]',
exportAs: 'nzConnectedOverlay'
}]
}], ctorParameters: () => [], propDecorators: { nzArrowPointAtCenter: [{
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 NzOverlayModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverlayModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzOverlayModule, imports: [NzConnectedOverlayDirective], exports: [NzConnectedOverlayDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverlayModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzOverlayModule, decorators: [{
type: NgModule,
args: [{
imports: [NzConnectedOverlayDirective],
exports: [NzConnectedOverlayDirective]
}]
}] });
/**
* 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
*/
function overlayZIndexSetter(overlayRef, zIndex) {
if (!zIndex)
return;
overlayRef['_host'].style.zIndex = `${zIndex}`;
}
/**
* 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 { DATE_PICKER_POSITION_MAP, DEFAULT_CASCADER_POSITIONS, DEFAULT_DATE_PICKER_POSITIONS, DEFAULT_MENTION_BOTTOM_POSITIONS, DEFAULT_MENTION_TOP_POSITIONS, DEFAULT_TOOLTIP_POSITIONS, NzConnectedOverlayDirective, NzOverlayModule, POSITION_MAP, TOOLTIP_OFFSET_MAP, getPlacementName, normalizeConnectedPositionOffset, overlayZIndexSetter, setConnectedPositionOffset };
//# sourceMappingURL=ng-zorro-antd-core-overlay.mjs.map
File diff suppressed because one or more lines are too long
+59
View File
@@ -0,0 +1,59 @@
import * as i0 from '@angular/core';
import { Pipe, NgModule } from '@angular/core';
import { timeUnits } from 'ng-zorro-antd/core/time';
import { padStart } 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
*/
class NzTimeRangePipe {
transform(value, format = 'HH:mm:ss') {
let duration = Number(value || 0);
return timeUnits.reduce((current, [name, unit]) => {
if (current.indexOf(name) !== -1) {
const v = Math.floor(duration / unit);
duration -= v * unit;
return current.replace(new RegExp(`${name}+`, 'g'), (match) => padStart(v.toString(), match.length, '0'));
}
return current;
}, format);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTimeRangePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzTimeRangePipe, isStandalone: true, name: "nzTimeRange" });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTimeRangePipe, decorators: [{
type: Pipe,
args: [{
name: 'nzTimeRange'
}]
}] });
/**
* 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 NzPipesModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzPipesModule, imports: [NzTimeRangePipe], exports: [NzTimeRangePipe] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzPipesModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzPipesModule, decorators: [{
type: NgModule,
args: [{
imports: [NzTimeRangePipe],
exports: [NzTimeRangePipe]
}]
}] });
/**
* 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 { NzPipesModule, NzTimeRangePipe };
//# sourceMappingURL=ng-zorro-antd-core-pipe.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-pipe.mjs","sources":["../../components/core/pipe/time-range.pipe.ts","../../components/core/pipe/nz-pipe.module.ts","../../components/core/pipe/public-api.ts","../../components/core/pipe/ng-zorro-antd-core-pipe.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Pipe, PipeTransform } from '@angular/core';\n\nimport { timeUnits } from 'ng-zorro-antd/core/time';\nimport { padStart } from 'ng-zorro-antd/core/util';\n\n@Pipe({\n name: 'nzTimeRange'\n})\nexport class NzTimeRangePipe implements PipeTransform {\n transform(value: string | number, format: string = 'HH:mm:ss'): string {\n let duration = Number(value || 0);\n\n return timeUnits.reduce((current, [name, unit]) => {\n if (current.indexOf(name) !== -1) {\n const v = Math.floor(duration / unit);\n duration -= v * unit;\n return current.replace(new RegExp(`${name}+`, 'g'), (match: string) =>\n padStart(v.toString(), match.length, '0')\n );\n }\n return current;\n }, format);\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { NgModule } from '@angular/core';\n\nimport { NzTimeRangePipe } from './time-range.pipe';\n\n@NgModule({\n imports: [NzTimeRangePipe],\n exports: [NzTimeRangePipe]\n})\nexport class NzPipesModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './nz-pipe.module';\nexport * from './time-range.pipe';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;MAUU,eAAe,CAAA;AAC1B,IAAA,SAAS,CAAC,KAAsB,EAAE,MAAA,GAAiB,UAAU,EAAA;QAC3D,IAAI,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;AAEjC,QAAA,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,KAAI;YAChD,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;gBAChC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;AACrC,gBAAA,QAAQ,IAAI,CAAC,GAAG,IAAI;AACpB,gBAAA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,CAAA,EAAG,IAAI,CAAA,CAAA,CAAG,EAAE,GAAG,CAAC,EAAE,CAAC,KAAa,KAChE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAC1C;YACH;AACA,YAAA,OAAO,OAAO;QAChB,CAAC,EAAE,MAAM,CAAC;IACZ;uGAdW,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;qGAAf,eAAe,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,aAAA,EAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE;AACP,iBAAA;;;ACZD;;;AAGG;MAUU,aAAa,CAAA;uGAAb,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAb,aAAa,EAAA,OAAA,EAAA,CAHd,eAAe,CAAA,EAAA,OAAA,EAAA,CACf,eAAe,CAAA,EAAA,CAAA;wGAEd,aAAa,EAAA,CAAA;;2FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBAJzB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,eAAe,CAAC;oBAC1B,OAAO,EAAE,CAAC,eAAe;AAC1B,iBAAA;;;ACZD;;;AAGG;;ACHH;;AAEG;;;;"}
+22
View File
@@ -0,0 +1,22 @@
/**
* 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
*/
// Note: This falls back to `setTimeout` if `requestAnimationFrame` is
// unintentionally called on the server, but ideally, we should never attempt
// to call `requestAnimationFrame` on the server — all invocations should be
// wrapped with isBrowser.
const requestAnimationFrame = typeof globalThis.requestAnimationFrame === 'function' ? globalThis.requestAnimationFrame : globalThis.setTimeout;
const cancelAnimationFrame = typeof globalThis.requestAnimationFrame === 'function' ? globalThis.cancelAnimationFrame : globalThis.clearTimeout;
/**
* 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 { cancelAnimationFrame, requestAnimationFrame };
//# sourceMappingURL=ng-zorro-antd-core-polyfill.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-polyfill.mjs","sources":["../../components/core/polyfill/request-animation.ts","../../components/core/polyfill/public-api.ts","../../components/core/polyfill/ng-zorro-antd-core-polyfill.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\n// Note: This falls back to `setTimeout` if `requestAnimationFrame` is\n// unintentionally called on the server, but ideally, we should never attempt\n// to call `requestAnimationFrame` on the server — all invocations should be\n// wrapped with isBrowser.\nexport const requestAnimationFrame =\n typeof globalThis.requestAnimationFrame === 'function' ? globalThis.requestAnimationFrame : globalThis.setTimeout;\n\nexport const cancelAnimationFrame =\n typeof globalThis.requestAnimationFrame === 'function' ? globalThis.cancelAnimationFrame : globalThis.clearTimeout;\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './request-animation';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;AAGG;AAEH;AACA;AACA;AACA;MACa,qBAAqB,GAChC,OAAO,UAAU,CAAC,qBAAqB,KAAK,UAAU,GAAG,UAAU,CAAC,qBAAqB,GAAG,UAAU,CAAC;MAE5F,oBAAoB,GAC/B,OAAO,UAAU,CAAC,qBAAqB,KAAK,UAAU,GAAG,UAAU,CAAC,oBAAoB,GAAG,UAAU,CAAC;;ACbxG;;;AAGG;;ACHH;;AAEG;;;;"}
+38
View File
@@ -0,0 +1,38 @@
import { InjectionToken, inject, Injector, afterNextRender } from '@angular/core';
import { Observable } from 'rxjs';
/**
* 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
*/
/**
* An injection token representing `afterNextRender` as an observable rather
* than a callback-based API has been added. This might be necessary in code
* where streams of data are already being used and we need to wait until
* the change detection ends before performing any tasks.
*/
const NZ_AFTER_NEXT_RENDER$ = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'nz-after-next-render' : '', {
providedIn: 'root',
factory: () => {
const injector = inject(Injector);
return new Observable(subscriber => {
const ref = afterNextRender(() => {
subscriber.next();
subscriber.complete();
}, { injector });
return () => ref.destroy();
});
}
});
/**
* 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_AFTER_NEXT_RENDER$ };
//# sourceMappingURL=ng-zorro-antd-core-render.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-render.mjs","sources":["../../components/core/render/after-next-render.ts","../../components/core/render/public-api.ts","../../components/core/render/ng-zorro-antd-core-render.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { InjectionToken, Injector, afterNextRender, inject } from '@angular/core';\nimport { Observable } from 'rxjs';\n\n/**\n * An injection token representing `afterNextRender` as an observable rather\n * than a callback-based API has been added. This might be necessary in code\n * where streams of data are already being used and we need to wait until\n * the change detection ends before performing any tasks.\n */\nexport const NZ_AFTER_NEXT_RENDER$ = new InjectionToken<Observable<void>>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'nz-after-next-render' : '',\n {\n providedIn: 'root',\n factory: () => {\n const injector = inject(Injector);\n\n return new Observable<void>(subscriber => {\n const ref = afterNextRender(\n () => {\n subscriber.next();\n subscriber.complete();\n },\n { injector }\n );\n\n return () => ref.destroy();\n });\n }\n }\n);\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './after-next-render';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;AAGG;AAKH;;;;;AAKG;MACU,qBAAqB,GAAG,IAAI,cAAc,CACrD,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,GAAG,sBAAsB,GAAG,EAAE,EAC3E;AACE,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAK;AACZ,QAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAEjC,QAAA,OAAO,IAAI,UAAU,CAAO,UAAU,IAAG;AACvC,YAAA,MAAM,GAAG,GAAG,eAAe,CACzB,MAAK;gBACH,UAAU,CAAC,IAAI,EAAE;gBACjB,UAAU,CAAC,QAAQ,EAAE;AACvB,YAAA,CAAC,EACD,EAAE,QAAQ,EAAE,CACb;AAED,YAAA,OAAO,MAAM,GAAG,CAAC,OAAO,EAAE;AAC5B,QAAA,CAAC,CAAC;IACJ;AACD,CAAA;;ACjCH;;;AAGG;;ACHH;;AAEG;;;;"}
+491
View File
@@ -0,0 +1,491 @@
import * as i0 from '@angular/core';
import { inject, NgZone, DestroyRef, RendererFactory2, Injectable, DOCUMENT } from '@angular/core';
import { Subject } from 'rxjs';
import { auditTime, finalize, map, filter, startWith, distinctUntilChanged } from 'rxjs/operators';
import { environment } from 'ng-zorro-antd/core/environments';
import { getEventPosition, isTouchEvent } from 'ng-zorro-antd/core/util';
import { requestAnimationFrame } from 'ng-zorro-antd/core/polyfill';
import { MediaMatcher } from '@angular/cdk/layout';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Platform } from '@angular/cdk/platform';
/**
* 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 NOOP = () => { };
class NzResizeService {
ngZone = inject(NgZone);
destroyRef = inject(DestroyRef);
resizeSource$ = new Subject();
listeners = 0;
renderer = inject(RendererFactory2).createRenderer(null, null);
disposeHandle = NOOP;
handler = () => {
this.ngZone.run(() => {
this.resizeSource$.next();
});
};
constructor() {
this.destroyRef.onDestroy(() => {
// Caretaker note: the `handler` is an instance property (it's not defined on the class prototype).
this.handler = NOOP;
});
}
connect() {
this.registerListener();
return this.resizeSource$.pipe(auditTime(16), finalize(() => this.unregisterListener()));
}
disconnet() {
this.unregisterListener();
}
registerListener() {
if (this.listeners === 0) {
this.ngZone.runOutsideAngular(() => {
this.disposeHandle = this.renderer.listen('window', 'resize', this.handler);
});
}
this.listeners += 1;
}
unregisterListener() {
this.listeners -= 1;
if (this.listeners === 0) {
this.disposeHandle();
this.disposeHandle = NOOP;
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzResizeService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: () => [] });
/**
* 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
*/
/**
* When running in test, singletons should not be destroyed. So we keep references of singletons
* in this global variable.
*/
const testSingleRegistry = new Map();
/**
* Some singletons should have life cycle that is same to Angular's. This service make sure that
* those singletons get destroyed in HMR.
*/
class NzSingletonService {
get singletonRegistry() {
return environment.isTestMode ? testSingleRegistry : this._singletonRegistry;
}
/**
* This registry is used to register singleton in dev mode.
* So that singletons get destroyed when hot module reload happens.
*
* This works in prod mode too but with no specific effect.
*/
_singletonRegistry = new Map();
registerSingletonWithKey(key, target) {
const alreadyHave = this.singletonRegistry.has(key);
const item = alreadyHave ? this.singletonRegistry.get(key) : this.withNewTarget(target);
if (!alreadyHave) {
this.singletonRegistry.set(key, item);
}
}
unregisterSingletonWithKey(key) {
if (this.singletonRegistry.has(key)) {
this.singletonRegistry.delete(key);
}
}
getSingletonWithKey(key) {
return this.singletonRegistry.has(key) ? this.singletonRegistry.get(key).target : null;
}
withNewTarget(target) {
return {
target
};
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzSingletonService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzSingletonService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzSingletonService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
/**
* 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
*/
function getPagePosition(event) {
const e = getEventPosition(event);
return {
x: e.pageX,
y: e.pageY
};
}
/**
* This module provide a global dragging service to other components.
*/
class NzDragService {
draggingThreshold = 5;
currentDraggingSequence = null;
currentStartingPoint = null;
handleRegistry = new Set();
renderer = inject(RendererFactory2).createRenderer(null, null);
requestDraggingSequence(event) {
if (!this.handleRegistry.size) {
this.registerDraggingHandler(isTouchEvent(event));
}
// Complete last dragging sequence if a new target is dragged.
if (this.currentDraggingSequence) {
this.currentDraggingSequence.complete();
}
this.currentStartingPoint = getPagePosition(event);
this.currentDraggingSequence = new Subject();
return this.currentDraggingSequence.pipe(map((e) => ({
x: e.pageX - this.currentStartingPoint.x,
y: e.pageY - this.currentStartingPoint.y
})), filter((e) => Math.abs(e.x) > this.draggingThreshold || Math.abs(e.y) > this.draggingThreshold), finalize(() => this.teardownDraggingSequence()));
}
registerDraggingHandler(isTouch) {
if (isTouch) {
this.handleRegistry.add({
teardown: this.renderer.listen('document', 'touchmove', (e) => {
if (this.currentDraggingSequence) {
this.currentDraggingSequence.next(e.touches[0] || e.changedTouches[0]);
}
})
});
this.handleRegistry.add({
teardown: this.renderer.listen('document', 'touchend', () => {
if (this.currentDraggingSequence) {
this.currentDraggingSequence.complete();
}
})
});
}
else {
this.handleRegistry.add({
teardown: this.renderer.listen('document', 'mousemove', e => {
if (this.currentDraggingSequence) {
this.currentDraggingSequence.next(e);
}
})
});
this.handleRegistry.add({
teardown: this.renderer.listen('document', 'mouseup', () => {
if (this.currentDraggingSequence) {
this.currentDraggingSequence.complete();
}
})
});
}
}
teardownDraggingSequence() {
this.currentDraggingSequence = null;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDragService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDragService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDragService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
/**
* 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
*/
function easeInOutCubic(t, b, c, d) {
const cc = c - b;
let tt = t / (d / 2);
if (tt < 1) {
return (cc / 2) * tt * tt * tt + b;
}
else {
return (cc / 2) * ((tt -= 2) * tt * tt + 2) + b;
}
}
class NzScrollService {
doc = inject(DOCUMENT);
ngZone = inject(NgZone);
/** Set the position of the scroll bar of `el`. */
setScrollTop(el, topValue = 0) {
if (el === window) {
this.doc.body.scrollTop = topValue;
this.doc.documentElement.scrollTop = topValue;
}
else {
el.scrollTop = topValue;
}
}
/** Get position of `el` against window. */
getOffset(el) {
const ret = {
top: 0,
left: 0
};
if (!el || !el.getClientRects().length) {
return ret;
}
const rect = el.getBoundingClientRect();
if (rect.width || rect.height) {
const doc = el.ownerDocument.documentElement;
ret.top = rect.top - doc.clientTop;
ret.left = rect.left - doc.clientLeft;
}
else {
ret.top = rect.top;
ret.left = rect.left;
}
return ret;
}
/** Get the position of the scoll bar of `el`. */
// TODO: remove '| Window' as the fallback already happens here
getScroll(target, top = true) {
if (typeof window === 'undefined') {
return 0;
}
const method = top ? 'scrollTop' : 'scrollLeft';
let result = 0;
if (this.isWindow(target)) {
result = target[top ? 'pageYOffset' : 'pageXOffset'];
}
else if (target instanceof Document) {
result = target.documentElement[method];
}
else if (target) {
result = target[method];
}
if (target && !this.isWindow(target) && typeof result !== 'number') {
result = (target.ownerDocument || target).documentElement[method];
}
return result;
}
isWindow(obj) {
return obj !== null && obj !== undefined && obj === obj.window;
}
/**
* Scroll `el` to some position with animation.
*
* @param containerEl container, `window` by default
* @param y Scroll to `top`, 0 by default
* @param options Scroll animation options
*/
scrollTo(containerEl, y = 0, options = {}) {
const target = containerEl ? containerEl : window;
const scrollTop = this.getScroll(target);
const startTime = Date.now();
const { easing, callback, duration = 450 } = options;
const frameFunc = () => {
const timestamp = Date.now();
const time = timestamp - startTime;
const nextScrollTop = (easing || easeInOutCubic)(time > duration ? duration : time, scrollTop, y, duration);
if (this.isWindow(target)) {
target.scrollTo(window.pageXOffset, nextScrollTop);
}
else if (target instanceof HTMLDocument || target.constructor.name === 'HTMLDocument') {
target.documentElement.scrollTop = nextScrollTop;
}
else {
target.scrollTop = nextScrollTop;
}
if (time < duration) {
requestAnimationFrame(frameFunc);
}
else if (typeof callback === 'function') {
// Caretaker note: the `frameFunc` is called within the `<root>` zone, but we have to re-enter
// the Angular zone when calling custom callback to be backwards-compatible.
this.ngZone.run(callback);
}
};
// Caretaker note: the `requestAnimationFrame` triggers change detection, but updating a `scrollTop` property or
// calling `window.scrollTo` doesn't require Angular to run `ApplicationRef.tick()`.
this.ngZone.runOutsideAngular(() => requestAnimationFrame(frameFunc));
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzScrollService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzScrollService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzScrollService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
/**
* 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
*/
var NzBreakpointEnum;
(function (NzBreakpointEnum) {
NzBreakpointEnum["xxl"] = "xxl";
NzBreakpointEnum["xl"] = "xl";
NzBreakpointEnum["lg"] = "lg";
NzBreakpointEnum["md"] = "md";
NzBreakpointEnum["sm"] = "sm";
NzBreakpointEnum["xs"] = "xs";
})(NzBreakpointEnum || (NzBreakpointEnum = {}));
const gridResponsiveMap = {
xs: '(max-width: 575px)',
sm: '(min-width: 576px)',
md: '(min-width: 768px)',
lg: '(min-width: 992px)',
xl: '(min-width: 1200px)',
xxl: '(min-width: 1600px)'
};
const siderResponsiveMap = {
xs: '(max-width: 479.98px)',
sm: '(max-width: 575.98px)',
md: '(max-width: 767.98px)',
lg: '(max-width: 991.98px)',
xl: '(max-width: 1199.98px)',
xxl: '(max-width: 1599.98px)'
};
class NzBreakpointService {
resizeService = inject(NzResizeService);
mediaMatcher = inject(MediaMatcher);
constructor() {
this.resizeService
.connect()
.pipe(takeUntilDestroyed())
.subscribe(() => { });
}
subscribe(breakpointMap, fullMap) {
if (fullMap) {
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const get = () => this.matchMedia(breakpointMap, true);
return this.resizeService.connect().pipe(map(get), startWith(get()), distinctUntilChanged((x, y) => x[0] === y[0]), map(x => x[1]));
}
else {
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const get = () => this.matchMedia(breakpointMap);
return this.resizeService.connect().pipe(map(get), startWith(get()), distinctUntilChanged());
}
}
matchMedia(breakpointMap, fullMap) {
let bp = NzBreakpointEnum.md;
const breakpointBooleanMap = {};
Object.keys(breakpointMap).map(breakpoint => {
const castBP = breakpoint;
const matched = this.mediaMatcher.matchMedia(gridResponsiveMap[castBP]).matches;
breakpointBooleanMap[breakpoint] = matched;
if (matched) {
bp = castBP;
}
});
if (fullMap) {
return [bp, breakpointBooleanMap];
}
else {
return bp;
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreakpointService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreakpointService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzBreakpointService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: () => [] });
/**
* 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 NzDestroyService extends Subject {
ngOnDestroy() {
this.next();
this.complete();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDestroyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDestroyService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDestroyService, decorators: [{
type: Injectable
}] });
/**
* 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 ImagePreloadService {
counter = new Map();
linkRefs = new Map();
document = inject(DOCUMENT);
platform = inject(Platform);
addPreload(option) {
if (this.platform.isBrowser) {
return () => void 0;
}
const uniqueKey = `${option.src}${option.srcset}`;
let currentCount = this.counter.get(uniqueKey) || 0;
currentCount++;
this.counter.set(uniqueKey, currentCount);
if (!this.linkRefs.has(uniqueKey)) {
const linkNode = this.appendPreloadLink(option);
this.linkRefs.set(uniqueKey, linkNode);
}
return () => {
if (this.counter.has(uniqueKey)) {
let count = this.counter.get(uniqueKey);
count--;
if (count === 0) {
const linkNode = this.linkRefs.get(uniqueKey);
this.removePreloadLink(linkNode);
this.counter.delete(uniqueKey);
this.linkRefs.delete(uniqueKey);
}
else {
this.counter.set(uniqueKey, count);
}
}
};
}
appendPreloadLink(option) {
const linkNode = this.document.createElement('link');
linkNode.setAttribute('rel', 'preload');
linkNode.setAttribute('as', 'image');
linkNode.setAttribute('href', option.src);
if (option.srcset) {
linkNode.setAttribute('imagesrcset', option.srcset);
}
this.document.head.appendChild(linkNode);
return linkNode;
}
removePreloadLink(linkNode) {
if (this.document.head.contains(linkNode)) {
this.document.head.removeChild(linkNode);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ImagePreloadService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ImagePreloadService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ImagePreloadService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
/**
* 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 { ImagePreloadService, NzBreakpointEnum, NzBreakpointService, NzDestroyService, NzDragService, NzResizeService, NzScrollService, NzSingletonService, gridResponsiveMap, siderResponsiveMap };
//# sourceMappingURL=ng-zorro-antd-core-services.mjs.map
File diff suppressed because one or more lines are too long
+154
View File
@@ -0,0 +1,154 @@
import * as i0 from '@angular/core';
import { NgZone, EventEmitter, Injectable } from '@angular/core';
/**
* 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
*/
/** Creates a browser MouseEvent with the specified options. */
function createMouseEvent(type, x = 0, y = 0, button = 0) {
const event = document.createEvent('MouseEvent');
event.initMouseEvent(type, true /* canBubble */, false /* cancelable */, window /* view */, 0 /* detail */, x /* screenX */, y /* screenY */, x /* clientX */, y /* clientY */, false /* ctrlKey */, false /* altKey */, false /* shiftKey */, false /* metaKey */, button /* button */, null /* relatedTarget */);
// `initMouseEvent` doesn't allow us to pass the `buttons` and
// defaults it to 0 which looks like a fake event.
Object.defineProperty(event, 'buttons', { get: () => 1 });
return event;
}
/** Creates a browser TouchEvent with the specified pointer coordinates. */
function createTouchEvent(type, pageX = 0, pageY = 0) {
// In favor of creating events that work for most of the browsers, the event is created
// as a basic UI Event. The necessary details for the event will be set manually.
const event = new UIEvent(type, { detail: 0, view: window });
const touchDetails = { pageX, pageY, clientX: pageX, clientY: pageY };
// Most of the browsers don't have a "initTouchEvent" method that can be used to define
// the touch details.
Object.defineProperties(event, {
touches: { value: [touchDetails] },
targetTouches: { value: [touchDetails] },
changedTouches: { value: [touchDetails] }
});
return event;
}
/** Dispatches a keydown event from an element. */
function createKeyboardEvent(type, keyCode, target, key, ctrlKey, metaKey, shiftKey) {
const event = document.createEvent('KeyboardEvent');
const originalPreventDefault = event.preventDefault;
// Firefox does not support `initKeyboardEvent`, but supports `initKeyEvent`.
if (event.initKeyEvent) {
event.initKeyEvent(type, true, true, window, 0, 0, 0, 0, 0, keyCode);
}
else {
event.initKeyboardEvent(type, true, true, window, 0, key, 0, '', false);
}
// Webkit Browsers don't set the keyCode when calling the init function.
// See related bug https://bugs.webkit.org/show_bug.cgi?id=16735
Object.defineProperties(event, {
keyCode: { get: () => keyCode },
key: { get: () => key },
target: { get: () => target },
ctrlKey: { get: () => ctrlKey },
metaKey: { get: () => metaKey },
shiftKey: { get: () => shiftKey }
});
// IE won't set `defaultPrevented` on synthetic events so we need to do it manually.
event.preventDefault = function () {
Object.defineProperty(event, 'defaultPrevented', { get: () => true, configurable: true });
// eslint-disable-next-line prefer-rest-params
return originalPreventDefault.apply(this, arguments);
};
return event;
}
/** Creates a fake event object with any desired event type. */
function createFakeEvent(type, canBubble = true, cancelable = true) {
const event = document.createEvent('Event');
event.initEvent(type, canBubble, cancelable);
return event;
}
/**
* 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
*/
/** Utility to dispatch any event on a Node. */
function dispatchEvent(node, event) {
node.dispatchEvent(event);
return event;
}
/** Shorthand to dispatch a fake event on a specified node. */
function dispatchFakeEvent(node, type, canBubble) {
return dispatchEvent(node, createFakeEvent(type, canBubble));
}
/** Shorthand to dispatch a keyboard event with a specified key code. */
function dispatchKeyboardEvent(node, type, keyCode, target) {
return dispatchEvent(node, createKeyboardEvent(type, keyCode, target));
}
/** Shorthand to dispatch a mouse event on the specified coordinates. */
function dispatchMouseEvent(node, type, x = 0, y = 0, event = createMouseEvent(type, x, y)) {
return dispatchEvent(node, event);
}
/** Shorthand to dispatch a touch event on the specified coordinates. */
function dispatchTouchEvent(node, type, x = 0, y = 0) {
return dispatchEvent(node, createTouchEvent(type, x, y));
}
/**
* 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
*/
/**
* Focuses an input, sets its value and dispatches
* the `input` event, simulating the user typing.
*
* @param value Value to be set on the input.
* @param element Element onto which to set the value.
*/
function typeInElement(value, element) {
element.focus();
element.value = value;
dispatchFakeEvent(element, '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
*/
/**
* Mock synchronous NgZone implementation that can be used
* to flush out `onStable` subscriptions in tests.
*
* via: https://github.com/angular/angular/blob/master/packages/core/testing/src/ng_zone_mock.ts
*
* @docs-private
*/
class MockNgZone extends NgZone {
onStable = new EventEmitter(false);
constructor() {
super({ enableLongStackTrace: false });
}
run(fn) {
return fn();
}
runOutsideAngular(fn) {
return fn();
}
simulateZoneExit() {
this.onStable.emit(null);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MockNgZone, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MockNgZone });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MockNgZone, decorators: [{
type: Injectable
}], ctorParameters: () => [] });
/**
* 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 { MockNgZone, createFakeEvent, createKeyboardEvent, createMouseEvent, createTouchEvent, dispatchEvent, dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent, dispatchTouchEvent, typeInElement };
//# sourceMappingURL=ng-zorro-antd-core-testing.mjs.map
File diff suppressed because one or more lines are too long
+426
View File
@@ -0,0 +1,426 @@
import { startOfWeek, startOfMonth, setYear, addYears, setMonth, addMonths, setDay, getQuarter, setQuarter, isSameDay, isSameSecond, isSameMinute, isSameHour, isSameMonth, isSameQuarter, isSameYear, differenceInCalendarDays, differenceInSeconds, differenceInMinutes, differenceInHours, differenceInCalendarMonths, differenceInCalendarQuarters, differenceInCalendarYears, isToday, isValid, isFirstDayOfMonth, isLastDayOfMonth } from 'date-fns';
import { warn } from 'ng-zorro-antd/core/logger';
import { getLocaleDayPeriods, FormStyle, TranslationWidth } from '@angular/common';
import { isNotNil } 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
*/
function wrongSortOrder(rangeValue) {
const [start, end] = rangeValue;
return !!start && !!end && end.isBeforeDay(start);
}
function normalizeRangeValue(value, hasTimePicker, type = 'month', activePart = 'left') {
const [start, end] = value;
let newStart = start || new CandyDate();
let newEnd = end || (hasTimePicker ? newStart : newStart.add(1, type));
if (start && !end) {
newStart = start;
newEnd = hasTimePicker ? start : start.add(1, type);
}
else if (!start && end) {
newStart = hasTimePicker ? end : end.add(-1, type);
newEnd = end;
}
else if (start && end && !hasTimePicker) {
if (start.isSame(end, type)) {
newEnd = newStart.add(1, type);
}
else {
if (activePart === 'left') {
newEnd = newStart.add(1, type);
}
else {
newStart = newEnd.add(-1, type);
}
}
}
return [newStart, newEnd];
}
function cloneDate(value) {
if (Array.isArray(value)) {
return value.map(v => (v instanceof CandyDate ? v.clone() : null));
}
else {
return value instanceof CandyDate ? value.clone() : null;
}
}
/**
* Wrapping kind APIs for date operating and unify
* NOTE: every new API return new CandyDate object without side effects to the former Date object
* NOTE: most APIs are based on local time other than customized locale id (this needs tobe support in future)
* TODO: support format() against to angular's core API
*/
class CandyDate {
nativeDate;
// locale: string; // Custom specified locale ID
constructor(date) {
if (date) {
if (date instanceof Date) {
this.nativeDate = date;
}
else if (typeof date === 'string' || typeof date === 'number') {
warn('The string type is not recommended for date-picker, use "Date" type');
this.nativeDate = new Date(date);
}
else {
throw new Error('The input date type is not supported ("Date" is now recommended)');
}
}
else {
this.nativeDate = new Date();
}
}
calendarStart(options) {
return new CandyDate(startOfWeek(startOfMonth(this.nativeDate), options));
}
// ---------------------------------------------------------------------
// | Native shortcuts
// -----------------------------------------------------------------------------\
getYear() {
return this.nativeDate.getFullYear();
}
getMonth() {
return this.nativeDate.getMonth();
}
getDay() {
return this.nativeDate.getDay();
}
getTime() {
return this.nativeDate.getTime();
}
getDate() {
return this.nativeDate.getDate();
}
getHours() {
return this.nativeDate.getHours();
}
getMinutes() {
return this.nativeDate.getMinutes();
}
getSeconds() {
return this.nativeDate.getSeconds();
}
getMilliseconds() {
return this.nativeDate.getMilliseconds();
}
// ---------------------------------------------------------------------
// | New implementing APIs
// ---------------------------------------------------------------------
clone() {
return new CandyDate(new Date(this.nativeDate));
}
setHms(hour, minute, second) {
const newDate = new Date(this.nativeDate.setHours(hour, minute, second));
return new CandyDate(newDate);
}
setYear(year) {
return new CandyDate(setYear(this.nativeDate, year));
}
addYears(amount) {
return new CandyDate(addYears(this.nativeDate, amount));
}
// NOTE: month starts from 0
// NOTE: Don't use the native API for month manipulation as it not restrict the date when it overflows, eg. (new Date('2018-7-31')).setMonth(1) will be date of 2018-3-03 instead of 2018-2-28
setMonth(month) {
return new CandyDate(setMonth(this.nativeDate, month));
}
addMonths(amount) {
return new CandyDate(addMonths(this.nativeDate, amount));
}
setDay(day, options) {
return new CandyDate(setDay(this.nativeDate, day, options));
}
setDate(amount) {
const date = new Date(this.nativeDate);
date.setDate(amount);
return new CandyDate(date);
}
getQuarter() {
return getQuarter(this.nativeDate);
}
setQuarter(quarter) {
return new CandyDate(setQuarter(this.nativeDate, quarter));
}
addDays(amount) {
return this.setDate(this.getDate() + amount);
}
add(amount, mode) {
switch (mode) {
case 'decade':
return this.addYears(amount * 10);
case 'year':
return this.addYears(amount);
case 'month':
return this.addMonths(amount);
default:
return this.addMonths(amount);
}
}
isSame(date, grain = 'day') {
let fn;
switch (grain) {
case 'decade':
fn = (pre, next) => Math.abs(pre.getFullYear() - next.getFullYear()) < 11;
break;
case 'year':
fn = isSameYear;
break;
case 'quarter':
fn = isSameQuarter;
break;
case 'month':
fn = isSameMonth;
break;
case 'day':
fn = isSameDay;
break;
case 'hour':
fn = isSameHour;
break;
case 'minute':
fn = isSameMinute;
break;
case 'second':
fn = isSameSecond;
break;
default:
fn = isSameDay;
break;
}
return fn(this.nativeDate, this.toNativeDate(date));
}
isSameYear(date) {
return this.isSame(date, 'year');
}
isSameQuarter(date) {
return this.isSame(date, 'quarter');
}
isSameMonth(date) {
return this.isSame(date, 'month');
}
isSameDay(date) {
return this.isSame(date, 'day');
}
isSameHour(date) {
return this.isSame(date, 'hour');
}
isSameMinute(date) {
return this.isSame(date, 'minute');
}
isSameSecond(date) {
return this.isSame(date, 'second');
}
isBefore(date, grain = 'day') {
if (date === null) {
return false;
}
let fn;
switch (grain) {
case 'year':
fn = differenceInCalendarYears;
break;
case 'quarter':
fn = differenceInCalendarQuarters;
break;
case 'month':
fn = differenceInCalendarMonths;
break;
case 'day':
fn = differenceInCalendarDays;
break;
case 'hour':
fn = differenceInHours;
break;
case 'minute':
fn = differenceInMinutes;
break;
case 'second':
fn = differenceInSeconds;
break;
default:
fn = differenceInCalendarDays;
break;
}
return fn(this.nativeDate, this.toNativeDate(date)) < 0;
}
isBeforeYear(date) {
return this.isBefore(date, 'year');
}
isBeforeQuarter(date) {
return this.isBefore(date, 'quarter');
}
isBeforeMonth(date) {
return this.isBefore(date, 'month');
}
isBeforeDay(date) {
return this.isBefore(date, 'day');
}
// Equal to today accurate to "day"
isToday() {
return isToday(this.nativeDate);
}
isValid() {
return isValid(this.nativeDate);
}
isFirstDayOfMonth() {
return isFirstDayOfMonth(this.nativeDate);
}
isLastDayOfMonth() {
return isLastDayOfMonth(this.nativeDate);
}
toNativeDate(date) {
return date instanceof CandyDate ? date.nativeDate : date;
}
}
/**
* 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 timeUnits = [
['Y', 1000 * 60 * 60 * 24 * 365], // years
['M', 1000 * 60 * 60 * 24 * 30], // months
['D', 1000 * 60 * 60 * 24], // days
['H', 1000 * 60 * 60], // hours
['m', 1000 * 60], // minutes
['s', 1000], // seconds
['S', 1] // million seconds
];
/**
* 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
*/
// from https://github.com/hsuanxyz/ng-time-parser
class NgTimeParser {
format;
localeId;
regex = null;
matchMap = {
hour: null,
minute: null,
second: null,
periodNarrow: null,
periodWide: null,
periodAbbreviated: null
};
constructor(format, localeId) {
this.format = format;
this.localeId = localeId;
this.genRegexp();
}
toDate(str) {
const result = this.getTimeResult(str);
const time = new Date();
if (isNotNil(result?.hour)) {
time.setHours(result.hour);
}
if (isNotNil(result?.minute)) {
time.setMinutes(result.minute);
}
if (isNotNil(result?.second)) {
time.setSeconds(result.second);
}
if (result?.period === 1 && time.getHours() < 12) {
time.setHours(time.getHours() + 12);
}
return time;
}
getTimeResult(str) {
const match = this.regex.exec(str);
let period = null;
if (match) {
if (isNotNil(this.matchMap.periodNarrow)) {
period = getLocaleDayPeriods(this.localeId, FormStyle.Format, TranslationWidth.Narrow).indexOf(match[this.matchMap.periodNarrow + 1]);
}
if (isNotNil(this.matchMap.periodWide)) {
period = getLocaleDayPeriods(this.localeId, FormStyle.Format, TranslationWidth.Wide).indexOf(match[this.matchMap.periodWide + 1]);
}
if (isNotNil(this.matchMap.periodAbbreviated)) {
period = getLocaleDayPeriods(this.localeId, FormStyle.Format, TranslationWidth.Abbreviated).indexOf(match[this.matchMap.periodAbbreviated + 1]);
}
return {
hour: isNotNil(this.matchMap.hour) ? Number.parseInt(match[this.matchMap.hour + 1], 10) : null,
minute: isNotNil(this.matchMap.minute) ? Number.parseInt(match[this.matchMap.minute + 1], 10) : null,
second: isNotNil(this.matchMap.second) ? Number.parseInt(match[this.matchMap.second + 1], 10) : null,
period
};
}
else {
return null;
}
}
genRegexp() {
let regexStr = this.format.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$&');
const hourRegex = /h{1,2}/i;
const minuteRegex = /m{1,2}/;
const secondRegex = /s{1,2}/;
const periodNarrow = /aaaaa/;
const periodWide = /aaaa/;
const periodAbbreviated = /a{1,3}/;
const hourMatch = hourRegex.exec(this.format);
const minuteMatch = minuteRegex.exec(this.format);
const secondMatch = secondRegex.exec(this.format);
const periodNarrowMatch = periodNarrow.exec(this.format);
let periodWideMatch = null;
let periodAbbreviatedMatch = null;
if (!periodNarrowMatch) {
periodWideMatch = periodWide.exec(this.format);
}
if (!periodWideMatch && !periodNarrowMatch) {
periodAbbreviatedMatch = periodAbbreviated.exec(this.format);
}
const matchs = [hourMatch, minuteMatch, secondMatch, periodNarrowMatch, periodWideMatch, periodAbbreviatedMatch]
.filter(m => !!m)
.sort((a, b) => a.index - b.index);
matchs.forEach((match, index) => {
switch (match) {
case hourMatch:
this.matchMap.hour = index;
regexStr = regexStr.replace(hourRegex, '(\\d{1,2})');
break;
case minuteMatch:
this.matchMap.minute = index;
regexStr = regexStr.replace(minuteRegex, '(\\d{1,2})');
break;
case secondMatch:
this.matchMap.second = index;
regexStr = regexStr.replace(secondRegex, '(\\d{1,2})');
break;
case periodNarrowMatch: {
this.matchMap.periodNarrow = index;
const periodsNarrow = getLocaleDayPeriods(this.localeId, FormStyle.Format, TranslationWidth.Narrow).join('|');
regexStr = regexStr.replace(periodNarrow, `(${periodsNarrow})`);
break;
}
case periodWideMatch: {
this.matchMap.periodWide = index;
const periodsWide = getLocaleDayPeriods(this.localeId, FormStyle.Format, TranslationWidth.Wide).join('|');
regexStr = regexStr.replace(periodWide, `(${periodsWide})`);
break;
}
case periodAbbreviatedMatch: {
this.matchMap.periodAbbreviated = index;
const periodsAbbreviated = getLocaleDayPeriods(this.localeId, FormStyle.Format, TranslationWidth.Abbreviated).join('|');
regexStr = regexStr.replace(periodAbbreviated, `(${periodsAbbreviated})`);
break;
}
}
});
this.regex = new RegExp(regexStr);
}
}
/**
* 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 { CandyDate, cloneDate, normalizeRangeValue, timeUnits, wrongSortOrder, NgTimeParser as ɵNgTimeParser };
//# sourceMappingURL=ng-zorro-antd-core-time.mjs.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,52 @@
import * as i0 from '@angular/core';
import { Directive, NgModule } from '@angular/core';
/**
* 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 NzTransButtonDirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzTransButtonDirective, isStandalone: true, selector: "button[nz-trans-button]", host: { properties: { "style.border": "\"0\"", "style.background": "\"transparent\"", "style.padding": "\"0\"", "style.line-height": "\"inherit\"" } }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransButtonDirective, decorators: [{
type: Directive,
args: [{
selector: 'button[nz-trans-button]',
host: {
'[style.border]': '"0"',
'[style.background]': '"transparent"',
'[style.padding]': '"0"',
'[style.line-height]': '"inherit"'
}
}]
}] });
/**
* 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 NzTransButtonModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzTransButtonModule, imports: [NzTransButtonDirective], exports: [NzTransButtonDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransButtonModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransButtonModule, decorators: [{
type: NgModule,
args: [{
imports: [NzTransButtonDirective],
exports: [NzTransButtonDirective]
}]
}] });
/**
* 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 { NzTransButtonDirective, NzTransButtonModule };
//# sourceMappingURL=ng-zorro-antd-core-trans-button.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-trans-button.mjs","sources":["../../components/core/trans-button/nz-trans-button.directive.ts","../../components/core/trans-button/nz-trans-button.module.ts","../../components/core/trans-button/public-api.ts","../../components/core/trans-button/ng-zorro-antd-core-trans-button.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Directive } from '@angular/core';\n\n@Directive({\n selector: 'button[nz-trans-button]',\n host: {\n '[style.border]': '\"0\"',\n '[style.background]': '\"transparent\"',\n '[style.padding]': '\"0\"',\n '[style.line-height]': '\"inherit\"'\n }\n})\nexport class NzTransButtonDirective {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { NgModule } from '@angular/core';\n\nimport { NzTransButtonDirective } from './nz-trans-button.directive';\n\n@NgModule({\n imports: [NzTransButtonDirective],\n exports: [NzTransButtonDirective]\n})\nexport class NzTransButtonModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport { NzTransButtonModule } from './nz-trans-button.module';\nexport { NzTransButtonDirective } from './nz-trans-button.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;AAGG;MAaU,sBAAsB,CAAA;uGAAtB,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAtB,sBAAsB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,yBAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,cAAA,EAAA,OAAA,EAAA,kBAAA,EAAA,iBAAA,EAAA,eAAA,EAAA,OAAA,EAAA,mBAAA,EAAA,aAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAtB,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBATlC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,yBAAyB;AACnC,oBAAA,IAAI,EAAE;AACJ,wBAAA,gBAAgB,EAAE,KAAK;AACvB,wBAAA,oBAAoB,EAAE,eAAe;AACrC,wBAAA,iBAAiB,EAAE,KAAK;AACxB,wBAAA,qBAAqB,EAAE;AACxB;AACF,iBAAA;;;ACfD;;;AAGG;MAUU,mBAAmB,CAAA;uGAAnB,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAnB,mBAAmB,EAAA,OAAA,EAAA,CAHpB,sBAAsB,CAAA,EAAA,OAAA,EAAA,CACtB,sBAAsB,CAAA,EAAA,CAAA;wGAErB,mBAAmB,EAAA,CAAA;;2FAAnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAJ/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,sBAAsB,CAAC;oBACjC,OAAO,EAAE,CAAC,sBAAsB;AACjC,iBAAA;;;ACZD;;;AAGG;;ACHH;;AAEG;;;;"}
@@ -0,0 +1,78 @@
import * as i0 from '@angular/core';
import { inject, ElementRef, Renderer2, Input, Directive, NgModule } from '@angular/core';
/**
* 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
*/
/**
* hack the bug
* angular router change with unexpected transition trigger after calling applicationRef.attachView
* https://github.com/angular/angular/issues/34718
*/
class NzTransitionPatchDirective {
elementRef = inject((ElementRef));
renderer = inject(Renderer2);
hidden = null;
setHiddenAttribute() {
if (this.hidden) {
if (typeof this.hidden === 'string') {
this.renderer.setAttribute(this.elementRef.nativeElement, 'hidden', this.hidden);
}
else {
this.renderer.setAttribute(this.elementRef.nativeElement, 'hidden', '');
}
}
else {
this.renderer.removeAttribute(this.elementRef.nativeElement, 'hidden');
}
}
constructor() {
this.renderer.setAttribute(this.elementRef.nativeElement, 'hidden', '');
}
ngOnChanges() {
this.setHiddenAttribute();
}
ngAfterViewInit() {
this.setHiddenAttribute();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransitionPatchDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzTransitionPatchDirective, isStandalone: true, selector: "[nz-button], [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: { hidden: "hidden" }, usesOnChanges: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransitionPatchDirective, decorators: [{
type: Directive,
args: [{
selector: '[nz-button], [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group'
}]
}], ctorParameters: () => [], propDecorators: { hidden: [{
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 NzTransitionPatchModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransitionPatchModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzTransitionPatchModule, imports: [NzTransitionPatchDirective], exports: [NzTransitionPatchDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransitionPatchModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzTransitionPatchModule, decorators: [{
type: NgModule,
args: [{
imports: [NzTransitionPatchDirective],
exports: [NzTransitionPatchDirective]
}]
}] });
/**
* 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 { NzTransitionPatchDirective as ɵNzTransitionPatchDirective, NzTransitionPatchModule as ɵNzTransitionPatchModule };
//# sourceMappingURL=ng-zorro-antd-core-transition-patch.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ng-zorro-antd-core-transition-patch.mjs","sources":["../../components/core/transition-patch/transition-patch.directive.ts","../../components/core/transition-patch/transition-patch.module.ts","../../components/core/transition-patch/public-api.ts","../../components/core/transition-patch/ng-zorro-antd-core-transition-patch.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { AfterViewInit, Directive, ElementRef, inject, Input, OnChanges, Renderer2 } from '@angular/core';\n\nimport { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n/**\n * hack the bug\n * angular router change with unexpected transition trigger after calling applicationRef.attachView\n * https://github.com/angular/angular/issues/34718\n */\n@Directive({\n selector:\n '[nz-button], [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group'\n})\nexport class NzTransitionPatchDirective implements AfterViewInit, OnChanges {\n private elementRef = inject(ElementRef<HTMLElement>);\n private renderer = inject(Renderer2);\n @Input() hidden: NzSafeAny = null;\n setHiddenAttribute(): void {\n if (this.hidden) {\n if (typeof this.hidden === 'string') {\n this.renderer.setAttribute(this.elementRef.nativeElement, 'hidden', this.hidden);\n } else {\n this.renderer.setAttribute(this.elementRef.nativeElement, 'hidden', '');\n }\n } else {\n this.renderer.removeAttribute(this.elementRef.nativeElement, 'hidden');\n }\n }\n\n constructor() {\n this.renderer.setAttribute(this.elementRef.nativeElement, 'hidden', '');\n }\n\n ngOnChanges(): void {\n this.setHiddenAttribute();\n }\n\n ngAfterViewInit(): void {\n this.setHiddenAttribute();\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { NgModule } from '@angular/core';\n\nimport { NzTransitionPatchDirective } from './transition-patch.directive';\n\n@NgModule({\n imports: [NzTransitionPatchDirective],\n exports: [NzTransitionPatchDirective]\n})\nexport class NzTransitionPatchModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport { NzTransitionPatchModule as ɵNzTransitionPatchModule } from './transition-patch.module';\nexport { NzTransitionPatchDirective as ɵNzTransitionPatchDirective } from './transition-patch.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;AAGG;AAMH;;;;AAIG;MAKU,0BAA0B,CAAA;AAC7B,IAAA,UAAU,GAAG,MAAM,EAAC,UAAuB,EAAC;AAC5C,IAAA,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC;IAC3B,MAAM,GAAc,IAAI;IACjC,kBAAkB,GAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;AACf,YAAA,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE;AACnC,gBAAA,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC;YAClF;iBAAO;AACL,gBAAA,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC;YACzE;QACF;aAAO;AACL,YAAA,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC;QACxE;IACF;AAEA,IAAA,WAAA,GAAA;AACE,QAAA,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC;IACzE;IAEA,WAAW,GAAA;QACT,IAAI,CAAC,kBAAkB,EAAE;IAC3B;IAEA,eAAe,GAAA;QACb,IAAI,CAAC,kBAAkB,EAAE;IAC3B;uGA1BW,0BAA0B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAA1B,0BAA0B,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,6HAAA,EAAA,MAAA,EAAA,EAAA,MAAA,EAAA,QAAA,EAAA,EAAA,aAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAA1B,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBAJtC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EACN;AACH,iBAAA;wDAIU,MAAM,EAAA,CAAA;sBAAd;;;ACrBH;;;AAGG;MAUU,uBAAuB,CAAA;uGAAvB,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAvB,uBAAuB,EAAA,OAAA,EAAA,CAHxB,0BAA0B,CAAA,EAAA,OAAA,EAAA,CAC1B,0BAA0B,CAAA,EAAA,CAAA;wGAEzB,uBAAuB,EAAA,CAAA;;2FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAJnC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,0BAA0B,CAAC;oBACrC,OAAO,EAAE,CAAC,0BAA0B;AACrC,iBAAA;;;ACZD;;;AAGG;;ACHH;;AAEG;;;;"}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+87
View File
@@ -0,0 +1,87 @@
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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 tuple = (...args) => args;
/**
* 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
*/
/**
* 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
*/
/**
* 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 { tuple };
//# sourceMappingURL=ng-zorro-antd-core-types.mjs.map
File diff suppressed because one or more lines are too long
+954
View File
@@ -0,0 +1,954 @@
import { TemplateRef, numberAttribute } from '@angular/core';
import { coerceBooleanProperty, coerceNumberProperty, coerceCssPixelValue } from '@angular/cdk/coercion';
import { warn } from 'ng-zorro-antd/core/logger';
import { Subject, isObservable, Observable, of, EMPTY, fromEvent } from 'rxjs';
import { take } from 'rxjs/operators';
/**
* 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
*/
function toArray(value) {
let ret;
if (value == null) {
ret = [];
}
else if (!Array.isArray(value)) {
ret = [value];
}
else {
ret = value;
}
return ret;
}
function arraysEqual(array1, array2) {
if (!array1 || !array2 || array1.length !== array2.length) {
return false;
}
const len = array1.length;
for (let i = 0; i < len; i++) {
if (array1[i] !== array2[i]) {
return false;
}
}
return true;
}
function shallowCopyArray(source) {
return source.slice();
}
/**
* 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
*/
function isNotNil(value) {
return typeof value !== 'undefined' && value !== null;
}
function isNil(value) {
return typeof value === 'undefined' || value === null;
}
/**
* Examine if two objects are shallowly equaled.
*/
function shallowEqual(objA, objB) {
if (objA === objB) {
return true;
}
if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
return false;
}
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let idx = 0; idx < keysA.length; idx++) {
const key = keysA[idx];
if (!bHasOwnProperty(key)) {
return false;
}
if (objA[key] !== objB[key]) {
return false;
}
}
return true;
}
function isNonEmptyString(value) {
return typeof value === 'string' && value !== '';
}
function isTemplateRef(value) {
return value instanceof TemplateRef;
}
/**
* 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
*/
function toBoolean(value) {
return coerceBooleanProperty(value);
}
function numberAttributeWithZeroFallback(value) {
return numberAttribute(value, 0);
}
function numberAttributeWithOneFallback(value) {
return numberAttribute(value, 1);
}
function numberAttributeWithInfinityFallback(value) {
return numberAttribute(value, Infinity);
}
function toNumber(value, fallbackValue = 0) {
return coerceNumberProperty(value, fallbackValue);
}
function toCssPixel(value) {
return coerceCssPixelValue(value);
}
// eslint-disable no-invalid-this
/**
* Get the function-property type's value
*/
function valueFunctionProp(prop, ...args) {
return typeof prop === 'function' ? prop(...args) : prop;
}
function propDecoratorFactory(name, fallback) {
function propDecorator(target, propName, originalDescriptor) {
const privatePropName = `$$__zorroPropDecorator__${propName}`;
if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
warn(`The prop "${privatePropName}" is already exist, it will be overrided by ${name} decorator.`);
}
Object.defineProperty(target, privatePropName, {
configurable: true,
writable: true
});
return {
get() {
return originalDescriptor && originalDescriptor.get
? originalDescriptor.get.bind(this)()
: this[privatePropName];
},
set(value) {
if (originalDescriptor && originalDescriptor.set) {
originalDescriptor.set.bind(this)(fallback(value));
}
this[privatePropName] = fallback(value);
}
};
}
return propDecorator;
}
/**
* @deprecated Use input transform instead: `@Input({ transform })`
*
* Input decorator that handle a prop to do get/set automatically with toBoolean
*
* Why not using @InputBoolean alone without @Input? AOT needs @Input to be visible
*
* @howToUse
* ```
* @Input() @InputBoolean() visible: boolean = false;
*
* // Act as below:
* // @Input()
* // get visible() { return this.__visible; }
* // set visible(value) { this.__visible = value; }
* // __visible = false;
* ```
*/
function InputBoolean() {
return propDecoratorFactory('InputBoolean', toBoolean);
}
/**
* @deprecated Use input transform instead: `@Input({ transform })`
*/
function InputCssPixel() {
return propDecoratorFactory('InputCssPixel', toCssPixel);
}
/**
* @deprecated Use input transform instead: `@Input({ transform })`
*/
function InputNumber(fallbackValue) {
return propDecoratorFactory('InputNumber', (value) => toNumber(value, fallbackValue));
}
/**
* 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
*/
/**
* Silent an event by stopping and preventing it.
*/
function silentEvent(e) {
e.stopPropagation();
e.preventDefault();
}
function getElementOffset(elem) {
if (!elem.getClientRects().length) {
return { top: 0, left: 0 };
}
const rect = elem.getBoundingClientRect();
const win = elem.ownerDocument.defaultView;
return {
top: rect.top + win.pageYOffset,
left: rect.left + win.pageXOffset
};
}
/**
* Investigate if an event is a `TouchEvent`.
*/
function isTouchEvent(event) {
return event.type.startsWith('touch');
}
function getEventPosition(event) {
return isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] : event;
}
/**
* 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
*/
function getRegExp(prefix) {
const prefixArray = Array.isArray(prefix) ? prefix : [prefix];
let prefixToken = prefixArray.join('').replace(/(\$|\^)/g, '\\$1');
if (prefixArray.length > 1) {
prefixToken = `[${prefixToken}]`;
}
return new RegExp(`(\\s|^)(${prefixToken})[^\\s]*`, 'g');
}
function getMentions(value, prefix = '@') {
if (typeof value !== 'string') {
return [];
}
const regex = getRegExp(prefix);
const mentions = value.match(regex);
return mentions !== null ? mentions.map(e => e.trim()) : [];
}
/**
* 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
*/
/**
* Much like lodash.
*/
function padStart(toPad, length, element) {
if (toPad.length > length) {
return toPad;
}
const joined = `${getRepeatedElement(length, element)}${toPad}`;
return joined.slice(joined.length - length, joined.length);
}
function padEnd(toPad, length, element) {
const joined = `${toPad}${getRepeatedElement(length, element)}`;
return joined.slice(0, length);
}
function getRepeatedElement(length, element) {
return Array(length).fill(element).join('');
}
/**
* 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
*/
function isPromise(obj) {
return !!obj && typeof obj.then === 'function' && typeof obj.catch === 'function';
}
/**
* 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
*/
function getPercent(min, max, value) {
return ((value - min) / (max - min)) * 100;
}
function getPrecision(num) {
const numStr = num.toString();
const dotIndex = numStr.indexOf('.');
return dotIndex >= 0 ? numStr.length - dotIndex - 1 : 0;
}
function ensureNumberInRange(num, min, max) {
if (isNaN(num) || num < min) {
return min;
}
else if (num > max) {
return max;
}
else {
return num;
}
}
function isNumberFinite(value) {
return typeof value === 'number' && isFinite(value);
}
function toDecimal(value, decimal) {
return Math.round(value * Math.pow(10, decimal)) / Math.pow(10, decimal);
}
function sum(input, initial = 0) {
return input.reduce((previous, current) => previous + current, initial);
}
/**
* 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
*/
function scrollIntoView(node) {
const nodeAsAny = node;
if (nodeAsAny.scrollIntoViewIfNeeded) {
nodeAsAny.scrollIntoViewIfNeeded(false);
return;
}
if (node.scrollIntoView) {
node.scrollIntoView(false);
return;
}
}
/**
* 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
*/
// from https://github.com/component/textarea-caret-position
// We'll copy the properties below into the mirror div.
// Note that some browsers, such as Firefox, do not concatenate properties
// into their shorthand (e.g. padding-top, padding-bottom etc. -> padding),
// so we have to list every single property explicitly.
const properties = [
'direction', // RTL support
'boxSizing',
'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does
'height',
'overflowX',
'overflowY', // copy the scrollbar for IE
'borderTopWidth',
'borderRightWidth',
'borderBottomWidth',
'borderLeftWidth',
'borderStyle',
'paddingTop',
'paddingRight',
'paddingBottom',
'paddingLeft',
// https://developer.mozilla.org/en-US/docs/Web/CSS/font
'fontStyle',
'fontVariant',
'fontWeight',
'fontStretch',
'fontSize',
'fontSizeAdjust',
'lineHeight',
'fontFamily',
'textAlign',
'textTransform',
'textIndent',
'textDecoration', // might not make a difference, but better be safe
'letterSpacing',
'wordSpacing',
'tabSize',
'MozTabSize'
];
const isBrowser = typeof window !== 'undefined';
const isFirefox = isBrowser && window.mozInnerScreenX != null;
const _parseInt = (str) => parseInt(str, 10);
function getCaretCoordinates(element, position, options) {
if (!isBrowser) {
throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');
}
const debug = (options && options.debug) || false;
if (debug) {
const el = document.querySelector('#input-textarea-caret-position-mirror-div');
if (el) {
el.parentNode.removeChild(el);
}
}
// The mirror div will replicate the textarea's style
const div = document.createElement('div');
div.id = 'input-textarea-caret-position-mirror-div';
document.body.appendChild(div);
const style = div.style;
const computed = window.getComputedStyle ? window.getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9
const isInput = element.nodeName === 'INPUT';
// Default textarea styles
style.whiteSpace = 'pre-wrap';
if (!isInput) {
style.wordWrap = 'break-word'; // only for textarea-s
}
// Position off-screen
style.position = 'absolute'; // required to return coordinates properly
if (!debug) {
style.visibility = 'hidden';
} // not 'display: none' because we want rendering
// Transfer the element's properties to the div
properties.forEach((prop) => {
if (isInput && prop === 'lineHeight') {
// Special case for <input>s because text is rendered centered and line height may be != height
style.lineHeight = computed.height;
}
else {
// @ts-ignore
style[prop] = computed[prop];
}
});
if (isFirefox) {
// Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275
if (element.scrollHeight > _parseInt(computed.height)) {
style.overflowY = 'scroll';
}
}
else {
style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'
}
div.textContent = element.value.substring(0, position);
// The second special handling for input type="text" vs textarea:
// spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037
if (isInput) {
div.textContent = div.textContent.replace(/\s/g, '\u00a0');
}
const span = document.createElement('span');
// Wrapping must be replicated *exactly*, including when a long word gets
// onto the next line, with whitespace at the end of the line before (#7).
// The *only* reliable way to do that is to copy the *entire* rest of the
// textarea's content into the <span> created at the caret position.
// For inputs, just '.' would be enough, but no need to bother.
span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all
div.appendChild(span);
const coordinates = {
top: span.offsetTop + _parseInt(computed.borderTopWidth),
left: span.offsetLeft + _parseInt(computed.borderLeftWidth),
height: _parseInt(computed.lineHeight)
};
if (debug) {
span.style.backgroundColor = '#eee';
createDebugEle(element, coordinates);
}
else {
document.body.removeChild(div);
}
return coordinates;
}
function createDebugEle(element, coordinates) {
const fontSize = getComputedStyle(element).getPropertyValue('font-size');
const rect = document.querySelector('#DEBUG') || document.createElement('div');
document.body.appendChild(rect);
rect.id = 'DEBUG';
rect.style.position = 'absolute';
rect.style.backgroundColor = 'red';
rect.style.height = fontSize;
rect.style.width = '1px';
rect.style.top = `${element.getBoundingClientRect().top - element.scrollTop + window.pageYOffset + coordinates.top}px`;
rect.style.left = `${element.getBoundingClientRect().left - element.scrollLeft + window.pageXOffset + coordinates.left}px`;
}
/**
* 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
*/
function isStyleSupport(styleName) {
if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
const styleNameList = Array.isArray(styleName) ? styleName : [styleName];
const { documentElement } = window.document;
return styleNameList.some(name => name in documentElement.style);
}
return false;
}
function getStyleAsText(styles) {
if (!styles) {
return '';
}
return Object.keys(styles)
.map(key => {
const val = styles[key];
return `${key}:${typeof val === 'string' ? val : `${val}px`}`;
})
.join(';');
}
/**
* 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
*/
// We only handle element & text node.
const ELEMENT_NODE = 1;
const TEXT_NODE = 3;
const COMMENT_NODE = 8;
let ellipsisContainer;
const wrapperStyle = {
padding: '0',
margin: '0',
display: 'inline',
lineHeight: 'inherit'
};
function pxToNumber(value) {
if (!value) {
return 0;
}
const match = value.match(/^\d*(\.\d*)?/);
return match ? Number(match[0]) : 0;
}
function styleToObject(style) {
// There are some different behavior between Firefox & Chrome.
// We have to handle this ourself.
const styles = {};
const styleNames = Array.prototype.slice.apply(style);
for (const name of styleNames) {
styles[name] = style.getPropertyValue(name);
}
return styles;
}
function mergeChildren(children) {
const childList = [];
children.forEach((child) => {
const prevChild = childList[childList.length - 1];
if (prevChild && child.nodeType === TEXT_NODE && prevChild.nodeType === TEXT_NODE) {
prevChild.data += child.data;
}
else {
childList.push(child);
}
});
return childList;
}
function measure(originEle, rows, contentNodes, fixedContent, ellipsisStr, suffixStr = '') {
if (!ellipsisContainer) {
ellipsisContainer = document.createElement('div');
ellipsisContainer.setAttribute('aria-hidden', 'true');
document.body.appendChild(ellipsisContainer);
}
// Get origin style
const originStyle = window.getComputedStyle(originEle);
const originCSS = styleToObject(originStyle);
const lineHeight = pxToNumber(originStyle.lineHeight);
const maxHeight = Math.round(lineHeight * (rows + 1) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom));
// Set shadow
for (const [name, value] of Object.entries(originCSS)) {
// setAttribute('style', ...) is not allowed when strict CSP is in place.
ellipsisContainer.style.setProperty(name, value);
}
ellipsisContainer.style.position = 'fixed';
ellipsisContainer.style.left = '0';
ellipsisContainer.style.height = 'auto';
ellipsisContainer.style.minHeight = 'auto';
ellipsisContainer.style.maxHeight = 'auto';
ellipsisContainer.style.top = '-999999px';
ellipsisContainer.style.zIndex = '-1000';
// clean up css overflow
ellipsisContainer.style.textOverflow = 'clip';
ellipsisContainer.style.whiteSpace = 'normal';
ellipsisContainer.style.webkitLineClamp = 'none';
const contentList = mergeChildren(contentNodes);
const container = document.createElement('div');
const contentContainer = document.createElement('span');
const suffixContainer = document.createTextNode(suffixStr);
const fixedContainer = document.createElement('span');
// Add styles in container
Object.assign(container.style, wrapperStyle);
Object.assign(contentContainer.style, wrapperStyle);
Object.assign(fixedContainer.style, wrapperStyle);
contentList.forEach(n => {
contentContainer.appendChild(n);
});
contentContainer.appendChild(suffixContainer);
fixedContent.forEach(node => {
fixedContainer.appendChild(node.cloneNode(true));
});
container.appendChild(contentContainer);
container.appendChild(fixedContainer);
// Render in the fake container
ellipsisContainer.appendChild(container);
// Check if ellipsis in measure div is height enough for content
function inRange() {
return ellipsisContainer.offsetHeight < maxHeight;
}
if (inRange()) {
const text = ellipsisContainer.innerHTML;
ellipsisContainer.removeChild(container);
return { contentNodes, text, ellipsis: false };
}
// We should clone the childNode since they're controlled by React and we can't reuse it without warning
const childNodes = Array.prototype.slice
.apply(ellipsisContainer.childNodes[0].childNodes[0].cloneNode(true).childNodes)
.filter(({ nodeType }) => nodeType !== COMMENT_NODE);
const fixedNodes = Array.prototype.slice.apply(ellipsisContainer.childNodes[0].childNodes[1].cloneNode(true).childNodes);
ellipsisContainer.removeChild(container);
// ========================= Find match ellipsis content =========================
ellipsisContainer.innerHTML = '';
// Create origin content holder
const ellipsisContentHolder = document.createElement('span');
ellipsisContainer.appendChild(ellipsisContentHolder);
const ellipsisTextNode = document.createTextNode(ellipsisStr + suffixStr);
ellipsisContentHolder.appendChild(ellipsisTextNode);
fixedNodes.forEach(childNode => {
ellipsisContainer.appendChild(childNode);
});
// Append before fixed nodes
function appendChildNode(node) {
ellipsisContentHolder.insertBefore(node, ellipsisTextNode);
}
// Get maximum text
function measureText(textNode, fullText, startLoc = 0, endLoc = fullText.length, lastSuccessLoc = 0) {
const midLoc = Math.floor((startLoc + endLoc) / 2);
textNode.textContent = fullText.slice(0, midLoc);
if (startLoc >= endLoc - 1) {
// Loop when step is small
for (let step = endLoc; step >= startLoc; step -= 1) {
const currentStepText = fullText.slice(0, step);
textNode.textContent = currentStepText;
if (inRange() || !currentStepText) {
return step === fullText.length
? {
finished: false,
node: document.createTextNode(fullText)
}
: {
finished: true,
node: document.createTextNode(currentStepText)
};
}
}
}
if (inRange()) {
return measureText(textNode, fullText, midLoc, endLoc, midLoc);
}
else {
return measureText(textNode, fullText, startLoc, midLoc, lastSuccessLoc);
}
}
function measureNode(childNode, index) {
const type = childNode.nodeType;
if (type === ELEMENT_NODE) {
// We don't split element, it will keep if whole element can be displayed.
// appendChildNode(childNode);
if (inRange()) {
return {
finished: false,
node: contentList[index]
};
}
// Clean up if can not pull in
ellipsisContentHolder.removeChild(childNode);
return {
finished: true,
node: null
};
}
else if (type === TEXT_NODE) {
const fullText = childNode.textContent || '';
const textNode = document.createTextNode(fullText);
appendChildNode(textNode);
return measureText(textNode, fullText);
}
// Not handle other type of content
// PS: This code should not be attached after react 16
return {
finished: false,
node: null
};
}
const ellipsisNodes = [];
childNodes.some((childNode, index) => {
const { finished, node } = measureNode(childNode, index);
if (node) {
ellipsisNodes.push(node);
}
return finished;
});
const result = {
contentNodes: ellipsisNodes,
text: ellipsisContainer.innerHTML,
ellipsis: true
};
while (ellipsisContainer.firstChild) {
ellipsisContainer.removeChild(ellipsisContainer.firstChild);
}
return result;
}
/**
* 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
*/
let scrollbarVerticalSize;
let scrollbarHorizontalSize;
// Measure scrollbar width for padding body during modal show/hide
const scrollbarMeasure = {
position: 'absolute',
top: '-9999px',
width: '50px',
height: '50px'
};
function measureScrollbar(direction = 'vertical', prefix = 'ant') {
if (typeof document === 'undefined' || typeof window === 'undefined') {
return 0;
}
const isVertical = direction === 'vertical';
if (isVertical && scrollbarVerticalSize) {
return scrollbarVerticalSize;
}
else if (!isVertical && scrollbarHorizontalSize) {
return scrollbarHorizontalSize;
}
const scrollDiv = document.createElement('div');
Object.keys(scrollbarMeasure).forEach(scrollProp => {
// @ts-ignore
scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp];
});
// apply hide scrollbar className ahead
scrollDiv.className = `${prefix}-hide-scrollbar scroll-div-append-to-body`;
// Append related overflow style
if (isVertical) {
scrollDiv.style.overflowY = 'scroll';
}
else {
scrollDiv.style.overflowX = 'scroll';
}
document.body.appendChild(scrollDiv);
let size = 0;
if (isVertical) {
size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
scrollbarVerticalSize = size;
}
else {
size = scrollDiv.offsetHeight - scrollDiv.clientHeight;
scrollbarHorizontalSize = size;
}
document.body.removeChild(scrollDiv);
return size;
}
/**
* 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
*/
function ensureInBounds(value, boundValue) {
return value ? (value < boundValue ? value : boundValue) : boundValue;
}
/**
* 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
*/
function inNextTick() {
const timer = new Subject();
Promise.resolve().then(() => timer.next());
return timer.pipe(take(1));
}
/**
* 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
*/
function wrapIntoObservable(value) {
if (isObservable(value)) {
return value;
}
if (isPromise(value)) {
// Not using `from()` because it includes support for many input types
// (iterables, async generators, observables, etc.),
// which increases bundle size. We're only handling Promises here, so a
// minimal wrapper is used instead.
return new Observable(subscriber => {
// Use `Promise.resolve()` to wrap promise-like instances.
Promise.resolve(value)
.then(result => {
subscriber.next(result);
subscriber.complete();
})
.catch(error => subscriber.error(error));
});
}
return of(value);
}
/**
* 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
*/
/**
* Sync from rc-util [https://github.com/react-component/util]
*/
function canUseDom() {
return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
}
/**
* 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
*/
/**
* Sync from rc-util [https://github.com/react-component/util]
*/
const MARK_KEY = `rc-util-key`;
function getMark({ mark } = {}) {
if (mark) {
return mark.startsWith('data-') ? mark : `data-${mark}`;
}
return MARK_KEY;
}
function getContainer(option) {
if (option.attachTo) {
return option.attachTo;
}
const head = document.querySelector('head');
return head || document.body;
}
function injectCSS(css, options = {}) {
if (!canUseDom()) {
return null;
}
const styleNode = document.createElement('style');
if (options.cspNonce) {
styleNode.nonce = options.cspNonce;
}
styleNode.innerHTML = css;
const container = getContainer(options);
const { firstChild } = container;
if (options.prepend && container.prepend) {
// Use `prepend` first
container.prepend(styleNode);
}
else if (options.prepend && firstChild) {
// Fallback to `insertBefore` like IE not support `prepend`
container.insertBefore(styleNode, firstChild);
}
else {
container.appendChild(styleNode);
}
return styleNode;
}
const containerCache = new Map();
function findExistNode(key, option = {}) {
const container = getContainer(option);
return Array.from(containerCache.get(container)?.children || []).find(node => node.tagName === 'STYLE' && node.getAttribute(getMark(option)) === key);
}
function removeCSS(key, option = {}) {
const existNode = findExistNode(key, option);
existNode?.parentNode?.removeChild(existNode);
}
function updateCSS(css, key, options = {}) {
const container = getContainer(options);
// Get real parent
if (!containerCache.has(container)) {
const placeholderStyle = injectCSS('', options);
// @ts-ignore
const { parentNode } = placeholderStyle;
containerCache.set(container, parentNode);
parentNode.removeChild(placeholderStyle);
}
const existNode = findExistNode(key, options);
if (existNode) {
if (options.cspNonce && existNode.nonce !== options.cspNonce) {
existNode.nonce = options.cspNonce;
}
if (existNode.innerHTML !== css) {
existNode.innerHTML = css;
}
return existNode;
}
const newNode = injectCSS(css, options);
newNode?.setAttribute(getMark(options), key);
return newNode;
}
/**
* 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
*/
function getStatusClassNames(prefixCls, status, hasFeedback) {
return {
[`${prefixCls}-status-success`]: status === 'success',
[`${prefixCls}-status-warning`]: status === 'warning',
[`${prefixCls}-status-error`]: status === 'error',
[`${prefixCls}-status-validating`]: status === 'validating',
[`${prefixCls}-has-feedback`]: hasFeedback
};
}
/**
* 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
*/
function runOutsideAngular(fn) {
// The function that does the same job as `NgZone.runOutsideAngular`.
// The difference is that we don't need to rely on the `NgZone` service,
// allowing `fromEventOutsideAngular` to function without requiring an explicit
// injection context (where we might otherwise call `inject(NgZone)`).
return typeof Zone !== 'undefined' ? Zone.root.run(fn) : fn();
}
/**
* This function replaces `runOutsideAngular` with `fromEvent`, introducing a
* lot of boilerplate where we need to inject the `NgZone` service and then subscribe
* to `fromEvent` within the `runOutsideAngular` callback.
*/
function fromEventOutsideAngular(target, name, options) {
// Allow the event target to be nullable to avoid requiring callers to check
// if the target exists. We simply complete the observable immediately,
// as this might potentially be used within a `switchMap`.
if (!target) {
return EMPTY;
}
return new Observable(subscriber => {
// Note that we're wrapping fromEvent with an observable because `fromEvent`
// is eager and only calls `addEventListener` when a new subscriber comes in.
// Therefore, we're wrapping the subscription with `runOutsideAngular` to ensure
// that `addEventListener` is also called outside of Angular when there's a subscriber.
return runOutsideAngular(() =>
// Casting because the inferred overload is incorrect :(
fromEvent(target, name, options).subscribe(subscriber));
});
}
/**
* 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
*/
function getVariantClassNames(prefixCls, variant, borderless) {
return {
[`${prefixCls}-borderless`]: variant === 'borderless' || (variant === 'outlined' && borderless),
[`${prefixCls}-filled`]: variant === 'filled',
[`${prefixCls}-underlined`]: variant === 'underlined'
};
}
/**
* 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 SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
// ! to ~ is the ASCII range.
const NON_ALPHANUMERIC_REGEXP = /([^#-~ |!])/g;
/**
* Escapes all potentially dangerous characters, so that the
* resulting string can be safely inserted into attribute or
* element text.
*/
function encodeEntities(value) {
return value
.replace(/&/g, '&amp;')
.replace(SURROGATE_PAIR_REGEXP, (match) => {
const hi = match.charCodeAt(0);
const low = match.charCodeAt(1);
return `&#${(hi - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000};`;
})
.replace(NON_ALPHANUMERIC_REGEXP, (match) => `&#${match.charCodeAt(0)};`)
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
/**
* 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
*/
function generateClassName(prefix, suffix) {
return `${prefix}-${suffix}`;
}
/**
* 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 { InputBoolean, InputCssPixel, InputNumber, arraysEqual, canUseDom, createDebugEle, encodeEntities, ensureInBounds, ensureNumberInRange, fromEventOutsideAngular, generateClassName, getCaretCoordinates, getElementOffset, getEventPosition, getMentions, getPercent, getPrecision, getRegExp, getRepeatedElement, getStatusClassNames, getStyleAsText, getVariantClassNames, inNextTick, injectCSS, isNil, isNonEmptyString, isNotNil, isNumberFinite, isPromise, isStyleSupport, isTemplateRef, isTouchEvent, measure, measureScrollbar, numberAttributeWithInfinityFallback, numberAttributeWithOneFallback, numberAttributeWithZeroFallback, padEnd, padStart, properties, pxToNumber, removeCSS, scrollIntoView, shallowCopyArray, shallowEqual, silentEvent, sum, toArray, toBoolean, toCssPixel, toDecimal, toNumber, updateCSS, valueFunctionProp, wrapIntoObservable };
//# sourceMappingURL=ng-zorro-antd-core-util.mjs.map
File diff suppressed because one or more lines are too long
+238
View File
@@ -0,0 +1,238 @@
import { Platform } from '@angular/cdk/platform';
import * as i0 from '@angular/core';
import { InjectionToken, makeEnvironmentProviders, inject, CSP_NONCE, NgZone, ElementRef, Input, Directive, NgModule } from '@angular/core';
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
/**
* 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 NzWaveRenderer {
triggerElement;
ngZone;
insertExtraNode;
platform;
cspNonce;
waveTransitionDuration = 400;
styleForPseudo = null;
extraNode = null;
lastTime = 0;
clickHandler;
get waveAttributeName() {
return this.insertExtraNode ? 'ant-click-animating' : 'ant-click-animating-without-extra-node';
}
constructor(triggerElement, ngZone, insertExtraNode, platform, cspNonce) {
this.triggerElement = triggerElement;
this.ngZone = ngZone;
this.insertExtraNode = insertExtraNode;
this.platform = platform;
this.cspNonce = cspNonce;
this.clickHandler = this.onClick.bind(this);
this.bindTriggerEvent();
}
onClick = (event) => {
if (!this.triggerElement ||
!this.triggerElement.getAttribute ||
this.triggerElement.getAttribute('disabled') ||
event.target.tagName === 'INPUT' ||
this.triggerElement.className.indexOf('disabled') >= 0) {
return;
}
this.fadeOutWave();
};
bindTriggerEvent() {
if (this.platform.isBrowser) {
this.ngZone.runOutsideAngular(() => {
this.removeTriggerEvent();
if (this.triggerElement) {
this.triggerElement.addEventListener('click', this.clickHandler, true);
}
});
}
}
removeTriggerEvent() {
if (this.triggerElement) {
this.triggerElement.removeEventListener('click', this.clickHandler, true);
}
}
removeStyleAndExtraNode() {
if (this.styleForPseudo && document.body.contains(this.styleForPseudo)) {
document.body.removeChild(this.styleForPseudo);
this.styleForPseudo = null;
}
if (this.insertExtraNode && this.triggerElement.contains(this.extraNode)) {
this.triggerElement.removeChild(this.extraNode);
}
}
destroy() {
this.removeTriggerEvent();
this.removeStyleAndExtraNode();
}
fadeOutWave() {
const node = this.triggerElement;
const waveColor = this.getWaveColor(node);
node.setAttribute(this.waveAttributeName, 'true');
if (Date.now() < this.lastTime + this.waveTransitionDuration) {
return;
}
if (this.isValidColor(waveColor)) {
if (!this.styleForPseudo) {
this.styleForPseudo = document.createElement('style');
if (this.cspNonce) {
this.styleForPseudo.nonce = this.cspNonce;
}
}
this.styleForPseudo.innerHTML = `
[ant-click-animating-without-extra-node='true']::after, .ant-click-animating-node {
--antd-wave-shadow-color: ${waveColor};
}`;
document.body.appendChild(this.styleForPseudo);
}
if (this.insertExtraNode) {
if (!this.extraNode) {
this.extraNode = document.createElement('div');
}
this.extraNode.className = 'ant-click-animating-node';
node.appendChild(this.extraNode);
}
this.lastTime = Date.now();
this.runTimeoutOutsideZone(() => {
node.removeAttribute(this.waveAttributeName);
this.removeStyleAndExtraNode();
}, this.waveTransitionDuration);
}
isValidColor(color) {
return (!!color &&
color !== '#ffffff' &&
color !== 'rgb(255, 255, 255)' &&
this.isNotGrey(color) &&
!/rgba\(\d*, \d*, \d*, 0\)/.test(color) &&
color !== 'transparent');
}
isNotGrey(color) {
const match = color.match(/rgba?\((\d*), (\d*), (\d*)(, [.\d]*)?\)/);
if (match && match[1] && match[2] && match[3]) {
return !(match[1] === match[2] && match[2] === match[3]);
}
return true;
}
getWaveColor(node) {
const nodeStyle = getComputedStyle(node);
return (nodeStyle.getPropertyValue('border-top-color') || // Firefox Compatible
nodeStyle.getPropertyValue('border-color') ||
nodeStyle.getPropertyValue('background-color'));
}
runTimeoutOutsideZone(fn, delay) {
this.ngZone.runOutsideAngular(() => setTimeout(fn, delay));
}
}
/**
* 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_WAVE_GLOBAL_DEFAULT_CONFIG = {
disabled: false
};
const NZ_WAVE_GLOBAL_CONFIG = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'nz-wave-global-options' : '');
function provideNzWave(config) {
return makeEnvironmentProviders([{ provide: NZ_WAVE_GLOBAL_CONFIG, useValue: config }]);
}
class NzWaveDirective {
nzWaveExtraNode = false;
waveRenderer;
waveDisabled = false;
get disabled() {
return this.waveDisabled;
}
get rendererRef() {
return this.waveRenderer;
}
cspNonce = inject(CSP_NONCE, { optional: true });
platform = inject(Platform);
config = inject(NZ_WAVE_GLOBAL_CONFIG, { optional: true });
animationType = inject(ANIMATION_MODULE_TYPE, { optional: true });
ngZone = inject(NgZone);
elementRef = inject((ElementRef));
constructor() {
this.waveDisabled = this.isConfigDisabled();
}
isConfigDisabled() {
let disabled = false;
if (this.config && typeof this.config.disabled === 'boolean') {
disabled = this.config.disabled;
}
if (this.animationType === 'NoopAnimations') {
disabled = true;
}
return disabled;
}
ngOnDestroy() {
if (this.waveRenderer) {
this.waveRenderer.destroy();
}
}
ngOnInit() {
this.renderWaveIfEnabled();
}
renderWaveIfEnabled() {
if (!this.waveDisabled && this.elementRef.nativeElement) {
this.waveRenderer = new NzWaveRenderer(this.elementRef.nativeElement, this.ngZone, this.nzWaveExtraNode, this.platform, this.cspNonce);
}
}
disable() {
this.waveDisabled = true;
if (this.waveRenderer) {
this.waveRenderer.removeTriggerEvent();
this.waveRenderer.removeStyleAndExtraNode();
}
}
enable() {
// config priority
this.waveDisabled = this.isConfigDisabled() || false;
if (this.waveRenderer) {
this.waveRenderer.bindTriggerEvent();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzWaveDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzWaveDirective, isStandalone: true, selector: "[nz-wave],button[nz-button]:not([nzType=\"link\"]):not([nzType=\"text\"])", inputs: { nzWaveExtraNode: "nzWaveExtraNode" }, exportAs: ["nzWave"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzWaveDirective, decorators: [{
type: Directive,
args: [{
selector: '[nz-wave],button[nz-button]:not([nzType="link"]):not([nzType="text"])',
exportAs: 'nzWave'
}]
}], ctorParameters: () => [], propDecorators: { nzWaveExtraNode: [{
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 NzWaveModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzWaveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzWaveModule, imports: [NzWaveDirective], exports: [NzWaveDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzWaveModule, providers: [provideNzWave(NZ_WAVE_GLOBAL_DEFAULT_CONFIG)] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzWaveModule, decorators: [{
type: NgModule,
args: [{
imports: [NzWaveDirective],
exports: [NzWaveDirective],
providers: [provideNzWave(NZ_WAVE_GLOBAL_DEFAULT_CONFIG)]
}]
}] });
/**
* 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_WAVE_GLOBAL_CONFIG, NZ_WAVE_GLOBAL_DEFAULT_CONFIG, NzWaveDirective, NzWaveModule, NzWaveRenderer, provideNzWave };
//# sourceMappingURL=ng-zorro-antd-core-wave.mjs.map
File diff suppressed because one or more lines are too long
+595
View File
@@ -0,0 +1,595 @@
import { NgTemplateOutlet, DatePipe } from '@angular/common';
import * as i0 from '@angular/core';
import { EventEmitter, booleanAttribute, Output, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, inject, ChangeDetectorRef, DestroyRef, forwardRef, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import * as i2 from '@angular/forms';
import { FormsModule, FormBuilder, Validators, NG_ASYNC_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms';
import { of } from 'rxjs';
import { parseExpression } from 'cron-parser';
import { NzI18nService } from 'ng-zorro-antd/i18n';
import * as i1 from 'ng-zorro-antd/input';
import { NzInputModule } from 'ng-zorro-antd/input';
import * as i1$1 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
/**
* 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
*/
/**
* 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 NzCronExpressionInputComponent {
value = '0';
label = 'second';
disabled = false;
focusEffect = new EventEmitter();
blurEffect = new EventEmitter();
getValue = new EventEmitter();
focusInputEffect(event) {
this.focusEffect.emit(this.label);
event.target.select();
}
blurInputEffect() {
this.blurEffect.emit();
}
setValue() {
this.getValue.emit({ label: this.label, value: this.value });
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "20.3.0", type: NzCronExpressionInputComponent, isStandalone: true, selector: "nz-cron-expression-input", inputs: { value: "value", label: "label", disabled: ["disabled", "disabled", booleanAttribute] }, outputs: { focusEffect: "focusEffect", blurEffect: "blurEffect", getValue: "getValue" }, exportAs: ["nzCronExpressionInput"], ngImport: i0, template: `
<div class="ant-cron-expression-input">
<input
nz-input
[(ngModel)]="value"
[name]="label"
[disabled]="disabled"
(focus)="focusInputEffect($event)"
(blur)="blurInputEffect()"
(ngModelChange)="setValue()"
/>
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzInputModule }, { kind: "directive", type: i1.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzVariant", "nzSize", "nzStepperless", "nzStatus", "disabled", "readonly"], exportAs: ["nzInput"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.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: "20.3.0", ngImport: i0, type: NzCronExpressionInputComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-cron-expression-input',
exportAs: 'nzCronExpressionInput',
template: `
<div class="ant-cron-expression-input">
<input
nz-input
[(ngModel)]="value"
[name]="label"
[disabled]="disabled"
(focus)="focusInputEffect($event)"
(blur)="blurInputEffect()"
(ngModelChange)="setValue()"
/>
</div>
`,
imports: [NzInputModule, FormsModule]
}]
}], propDecorators: { value: [{
type: Input
}], label: [{
type: Input
}], disabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], focusEffect: [{
type: Output
}], blurEffect: [{
type: Output
}], getValue: [{
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 NzCronExpressionLabelComponent {
type = 'second';
locale;
labelFocus = null;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: NzCronExpressionLabelComponent, isStandalone: true, selector: "nz-cron-expression-label", inputs: { type: "type", locale: "locale", labelFocus: "labelFocus" }, exportAs: ["nzCronExpressionLabel"], ngImport: i0, template: `
<div class="ant-cron-expression-label" [class.ant-cron-expression-label-foucs]="labelFocus === type">
<label>
{{ locale[type] }}
</label>
</div>
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionLabelComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-cron-expression-label',
exportAs: 'nzCronExpressionLabel',
template: `
<div class="ant-cron-expression-label" [class.ant-cron-expression-label-foucs]="labelFocus === type">
<label>
{{ locale[type] }}
</label>
</div>
`
}]
}], propDecorators: { type: [{
type: Input
}], locale: [{
type: Input
}], labelFocus: [{
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 NzCronExpressionPreviewComponent {
cdr = inject(ChangeDetectorRef);
TimeList = [];
visible = true;
locale;
nzSemantic = null;
loadMorePreview = new EventEmitter();
isExpand = true;
setExpand() {
this.isExpand = !this.isExpand;
this.cdr.markForCheck();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionPreviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCronExpressionPreviewComponent, isStandalone: true, selector: "nz-cron-expression-preview", inputs: { TimeList: "TimeList", visible: ["visible", "visible", booleanAttribute], locale: "locale", nzSemantic: "nzSemantic" }, outputs: { loadMorePreview: "loadMorePreview" }, exportAs: ["nzCronExpressionPreview"], ngImport: i0, template: `
<div class="ant-collapse ant-collapse-borderless ant-cron-expression-preview">
<div class="ant-cron-expression-preview-dateTime" [class.ant-cron-expression-preview-dateTime-center]="!isExpand">
@if (visible) {
@if (!nzSemantic) {
{{ TimeList[0] | date: 'yyyy-MM-dd HH:mm:ss' }}
} @else {
<ng-template [ngTemplateOutlet]="nzSemantic" />
}
} @else {
{{ locale.cronError }}
}
</div>
@if (visible && !isExpand) {
<div class="ant-cron-expression-preview-content">
<ul class="ant-cron-expression-preview-list">
@for (item of TimeList; track item) {
<li>
{{ item | date: 'yyyy-MM-dd HH:mm:ss' }}
</li>
}
<li><a (click)="loadMorePreview.emit()">···</a></li>
</ul>
</div>
}
<ul class="ant-cron-expression-preview-icon">
@if (isExpand) {
<li><nz-icon nzType="down" nzTheme="outline" (click)="setExpand()" /></li>
} @else {
<li><nz-icon nzType="up" nzTheme="outline" (click)="setExpand()" /></li>
}
</ul>
</div>
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1$1.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "pipe", type: DatePipe, name: "date" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionPreviewComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-cron-expression-preview',
exportAs: 'nzCronExpressionPreview',
template: `
<div class="ant-collapse ant-collapse-borderless ant-cron-expression-preview">
<div class="ant-cron-expression-preview-dateTime" [class.ant-cron-expression-preview-dateTime-center]="!isExpand">
@if (visible) {
@if (!nzSemantic) {
{{ TimeList[0] | date: 'yyyy-MM-dd HH:mm:ss' }}
} @else {
<ng-template [ngTemplateOutlet]="nzSemantic" />
}
} @else {
{{ locale.cronError }}
}
</div>
@if (visible && !isExpand) {
<div class="ant-cron-expression-preview-content">
<ul class="ant-cron-expression-preview-list">
@for (item of TimeList; track item) {
<li>
{{ item | date: 'yyyy-MM-dd HH:mm:ss' }}
</li>
}
<li><a (click)="loadMorePreview.emit()">···</a></li>
</ul>
</div>
}
<ul class="ant-cron-expression-preview-icon">
@if (isExpand) {
<li><nz-icon nzType="down" nzTheme="outline" (click)="setExpand()" /></li>
} @else {
<li><nz-icon nzType="up" nzTheme="outline" (click)="setExpand()" /></li>
}
</ul>
</div>
`,
imports: [NgTemplateOutlet, DatePipe, NzIconModule]
}]
}], propDecorators: { TimeList: [{
type: Input
}], visible: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], locale: [{
type: Input
}], nzSemantic: [{
type: Input
}], loadMorePreview: [{
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
*/
function labelsOfType(type) {
if (type === 'spring') {
return ['second', 'minute', 'hour', 'day', 'month', 'week'];
}
return ['minute', 'hour', 'day', 'month', 'week'];
}
class NzCronExpressionComponent {
formBuilder = inject(FormBuilder);
cdr = inject(ChangeDetectorRef);
i18n = inject(NzI18nService);
destroyRef = inject(DestroyRef);
nzSize = 'default';
nzType = 'linux';
nzCollapseDisable = false;
nzExtra = null;
nzSemantic = null;
nzBorderless = false;
nzDisabled = false;
locale;
focus = false;
labelFocus = null;
labels = labelsOfType(this.nzType);
interval;
nextTimeList = [];
isNzDisableFirstChange = true;
validateForm;
onChange = () => { };
onTouch = () => null;
convertFormat(value) {
const values = value.split(' ');
const valueObject = this.labels.reduce((obj, label, idx) => {
obj[label] = values[idx];
return obj;
}, {});
this.validateForm.patchValue(valueObject);
}
writeValue(value) {
if (value) {
this.convertFormat(value);
}
}
registerOnChange(fn) {
this.onChange = fn;
}
registerOnTouched(fn) {
this.onTouch = fn;
}
validate() {
if (this.validateForm.valid) {
return of(null);
}
else {
return of({ error: true });
}
}
setDisabledState(isDisabled) {
this.nzDisabled = (this.isNzDisableFirstChange && this.nzDisabled) || isDisabled;
this.isNzDisableFirstChange = false;
this.cdr.markForCheck();
}
constructor() {
this.validateForm = this.formBuilder.nonNullable.group({
second: ['0', Validators.required],
minute: ['*', Validators.required],
hour: ['*', Validators.required],
day: ['*', Validators.required],
month: ['*', Validators.required],
week: ['*', Validators.required]
}, { validators: this.checkValid });
}
ngOnInit() {
this.i18n.localeChange.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
this.locale = this.i18n.getLocaleData('CronExpression');
this.cdr.markForCheck();
});
this.cronFormType();
this.previewDate(this.validateForm.value);
this.validateForm.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => {
this.onChange(Object.values(value).join(' '));
this.previewDate(value);
this.cdr.markForCheck();
});
}
ngOnChanges(changes) {
const { nzType } = changes;
if (nzType) {
this.labels = labelsOfType(this.nzType);
this.cronFormType();
}
}
cronFormType() {
if (this.nzType === 'spring') {
this.validateForm.controls.second.enable();
}
else {
this.validateForm.controls.second.disable();
}
}
previewDate(value) {
try {
this.interval = parseExpression(Object.values(value).join(' '));
this.nextTimeList = [
this.interval.next().toDate(),
this.interval.next().toDate(),
this.interval.next().toDate(),
this.interval.next().toDate(),
this.interval.next().toDate()
];
}
catch {
return;
}
}
loadMorePreview() {
this.nextTimeList = [
...this.nextTimeList,
this.interval.next().toDate(),
this.interval.next().toDate(),
this.interval.next().toDate(),
this.interval.next().toDate(),
this.interval.next().toDate()
];
this.cdr.markForCheck();
}
focusEffect(value) {
this.focus = true;
this.labelFocus = value;
this.cdr.markForCheck();
}
blurEffect() {
this.focus = false;
this.labelFocus = null;
this.cdr.markForCheck();
}
getValue(item) {
this.validateForm.controls[item.label].patchValue(item.value);
this.cdr.markForCheck();
}
checkValid = (control) => {
if (control.value) {
try {
const cron = [];
this.labels.forEach(label => cron.push(control.value[label]));
parseExpression(cron.join(' '));
}
catch {
return { error: true };
}
}
return null;
};
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzCronExpressionComponent, isStandalone: true, selector: "nz-cron-expression", inputs: { nzSize: "nzSize", nzType: "nzType", nzCollapseDisable: ["nzCollapseDisable", "nzCollapseDisable", booleanAttribute], nzExtra: "nzExtra", nzSemantic: "nzSemantic", nzBorderless: ["nzBorderless", "nzBorderless", booleanAttribute], nzDisabled: ["nzDisabled", "nzDisabled", booleanAttribute] }, providers: [
{
provide: NG_ASYNC_VALIDATORS,
useExisting: forwardRef(() => NzCronExpressionComponent),
multi: true
},
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NzCronExpressionComponent),
multi: true
}
], exportAs: ["nzCronExpression"], usesOnChanges: true, ngImport: i0, template: `
<div class="ant-cron-expression">
<div class="ant-cron-expression-content">
<div
class="ant-input ant-cron-expression-input-group"
[class.ant-input-lg]="nzSize === 'large'"
[class.ant-input-sm]="nzSize === 'small'"
[class.ant-input-borderless]="nzBorderless"
[class.ant-cron-expression-input-group-focus]="focus && !nzBorderless"
[class.ant-input-status-error]="!validateForm.valid && !nzBorderless"
[class.ant-cron-expression-input-group-error-focus]="!validateForm.valid && focus && !nzBorderless"
[class.ant-input-disabled]="nzDisabled"
>
@for (label of labels; track label) {
<nz-cron-expression-input
[value]="this.validateForm.controls[label].value"
[label]="label"
[disabled]="nzDisabled"
(focusEffect)="focusEffect($event)"
(blurEffect)="blurEffect()"
(getValue)="getValue($event)"
/>
}
</div>
<div
class="ant-cron-expression-label-group"
[class.ant-input-lg]="nzSize === 'large'"
[class.ant-cron-expression-label-group-default]="nzSize === 'default'"
[class.ant-input-sm]="nzSize === 'small'"
>
@for (label of labels; track label) {
<nz-cron-expression-label [type]="label" [labelFocus]="labelFocus" [locale]="locale" />
}
</div>
@if (!nzCollapseDisable) {
<nz-cron-expression-preview
[TimeList]="nextTimeList"
[visible]="validateForm.valid"
[locale]="locale"
[nzSemantic]="nzSemantic"
(loadMorePreview)="loadMorePreview()"
/>
}
</div>
@if (nzExtra) {
<div class="ant-cron-expression-map">
<ng-template [ngTemplateOutlet]="nzExtra" />
</div>
}
</div>
`, isInline: true, dependencies: [{ kind: "component", type: NzCronExpressionInputComponent, selector: "nz-cron-expression-input", inputs: ["value", "label", "disabled"], outputs: ["focusEffect", "blurEffect", "getValue"], exportAs: ["nzCronExpressionInput"] }, { kind: "component", type: NzCronExpressionLabelComponent, selector: "nz-cron-expression-label", inputs: ["type", "locale", "labelFocus"], exportAs: ["nzCronExpressionLabel"] }, { kind: "component", type: NzCronExpressionPreviewComponent, selector: "nz-cron-expression-preview", inputs: ["TimeList", "visible", "locale", "nzSemantic"], outputs: ["loadMorePreview"], exportAs: ["nzCronExpressionPreview"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-cron-expression',
exportAs: 'nzCronExpression',
template: `
<div class="ant-cron-expression">
<div class="ant-cron-expression-content">
<div
class="ant-input ant-cron-expression-input-group"
[class.ant-input-lg]="nzSize === 'large'"
[class.ant-input-sm]="nzSize === 'small'"
[class.ant-input-borderless]="nzBorderless"
[class.ant-cron-expression-input-group-focus]="focus && !nzBorderless"
[class.ant-input-status-error]="!validateForm.valid && !nzBorderless"
[class.ant-cron-expression-input-group-error-focus]="!validateForm.valid && focus && !nzBorderless"
[class.ant-input-disabled]="nzDisabled"
>
@for (label of labels; track label) {
<nz-cron-expression-input
[value]="this.validateForm.controls[label].value"
[label]="label"
[disabled]="nzDisabled"
(focusEffect)="focusEffect($event)"
(blurEffect)="blurEffect()"
(getValue)="getValue($event)"
/>
}
</div>
<div
class="ant-cron-expression-label-group"
[class.ant-input-lg]="nzSize === 'large'"
[class.ant-cron-expression-label-group-default]="nzSize === 'default'"
[class.ant-input-sm]="nzSize === 'small'"
>
@for (label of labels; track label) {
<nz-cron-expression-label [type]="label" [labelFocus]="labelFocus" [locale]="locale" />
}
</div>
@if (!nzCollapseDisable) {
<nz-cron-expression-preview
[TimeList]="nextTimeList"
[visible]="validateForm.valid"
[locale]="locale"
[nzSemantic]="nzSemantic"
(loadMorePreview)="loadMorePreview()"
/>
}
</div>
@if (nzExtra) {
<div class="ant-cron-expression-map">
<ng-template [ngTemplateOutlet]="nzExtra" />
</div>
}
</div>
`,
providers: [
{
provide: NG_ASYNC_VALIDATORS,
useExisting: forwardRef(() => NzCronExpressionComponent),
multi: true
},
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NzCronExpressionComponent),
multi: true
}
],
imports: [
NzCronExpressionInputComponent,
NzCronExpressionLabelComponent,
NzCronExpressionPreviewComponent,
NgTemplateOutlet
]
}]
}], ctorParameters: () => [], propDecorators: { nzSize: [{
type: Input
}], nzType: [{
type: Input
}], nzCollapseDisable: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzExtra: [{
type: Input
}], nzSemantic: [{
type: Input
}], nzBorderless: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzDisabled: [{
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 NzCronExpressionModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionModule, imports: [NzCronExpressionComponent,
NzCronExpressionLabelComponent,
NzCronExpressionInputComponent,
NzCronExpressionPreviewComponent], exports: [NzCronExpressionComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionModule, imports: [NzCronExpressionComponent,
NzCronExpressionInputComponent,
NzCronExpressionPreviewComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzCronExpressionModule, decorators: [{
type: NgModule,
args: [{
imports: [
NzCronExpressionComponent,
NzCronExpressionLabelComponent,
NzCronExpressionInputComponent,
NzCronExpressionPreviewComponent
],
exports: [NzCronExpressionComponent]
}]
}] });
/**
* 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 { NzCronExpressionComponent, NzCronExpressionModule };
//# sourceMappingURL=ng-zorro-antd-cron-expression.mjs.map
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+461
View File
@@ -0,0 +1,461 @@
import * as i0 from '@angular/core';
import { TemplateRef, numberAttribute, Input, ViewChild, ViewEncapsulation, ChangeDetectionStrategy, Component, inject, ChangeDetectorRef, DestroyRef, booleanAttribute, ContentChildren, NgModule } from '@angular/core';
import { Subject, merge } from 'rxjs';
import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality } from '@angular/cdk/bidi';
import { NgTemplateOutlet } from '@angular/common';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { startWith, switchMap, auditTime, tap } from 'rxjs/operators';
import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
import { warn } from 'ng-zorro-antd/core/logger';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { NzBreakpointService, NzBreakpointEnum, gridResponsiveMap } from 'ng-zorro-antd/core/services';
/**
* 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 NzDescriptionsItemComponent {
content;
nzSpan = 1;
nzTitle = '';
inputChange$ = new Subject();
ngOnChanges() {
this.inputChange$.next();
}
ngOnDestroy() {
this.inputChange$.complete();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDescriptionsItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "20.3.0", type: NzDescriptionsItemComponent, isStandalone: true, selector: "nz-descriptions-item", inputs: { nzSpan: ["nzSpan", "nzSpan", numberAttribute], nzTitle: "nzTitle" }, viewQueries: [{ propertyName: "content", first: true, predicate: TemplateRef, descendants: true, static: true }], exportAs: ["nzDescriptionsItem"], 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: "20.3.0", ngImport: i0, type: NzDescriptionsItemComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-descriptions-item',
template: `
<ng-template>
<ng-content></ng-content>
</ng-template>
`,
exportAs: 'nzDescriptionsItem'
}]
}], propDecorators: { content: [{
type: ViewChild,
args: [TemplateRef, { static: true }]
}], nzSpan: [{
type: Input,
args: [{ transform: numberAttribute }]
}], nzTitle: [{
type: Input
}] } });
const NZ_CONFIG_MODULE_NAME = 'descriptions';
const defaultColumnMap = {
xxl: 3,
xl: 3,
lg: 3,
md: 3,
sm: 2,
xs: 1
};
let NzDescriptionsComponent = (() => {
let _nzBordered_decorators;
let _nzBordered_initializers = [];
let _nzBordered_extraInitializers = [];
let _nzColumn_decorators;
let _nzColumn_initializers = [];
let _nzColumn_extraInitializers = [];
let _nzSize_decorators;
let _nzSize_initializers = [];
let _nzSize_extraInitializers = [];
let _nzColon_decorators;
let _nzColon_initializers = [];
let _nzColon_extraInitializers = [];
return class NzDescriptionsComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzBordered_decorators = [WithConfig()];
_nzColumn_decorators = [WithConfig()];
_nzSize_decorators = [WithConfig()];
_nzColon_decorators = [WithConfig()];
__esDecorate(null, null, _nzBordered_decorators, { kind: "field", name: "nzBordered", static: false, private: false, access: { has: obj => "nzBordered" in obj, get: obj => obj.nzBordered, set: (obj, value) => { obj.nzBordered = value; } }, metadata: _metadata }, _nzBordered_initializers, _nzBordered_extraInitializers);
__esDecorate(null, null, _nzColumn_decorators, { kind: "field", name: "nzColumn", static: false, private: false, access: { has: obj => "nzColumn" in obj, get: obj => obj.nzColumn, set: (obj, value) => { obj.nzColumn = value; } }, metadata: _metadata }, _nzColumn_initializers, _nzColumn_extraInitializers);
__esDecorate(null, null, _nzSize_decorators, { kind: "field", name: "nzSize", static: false, private: false, access: { has: obj => "nzSize" in obj, get: obj => obj.nzSize, set: (obj, value) => { obj.nzSize = value; } }, metadata: _metadata }, _nzSize_initializers, _nzSize_extraInitializers);
__esDecorate(null, null, _nzColon_decorators, { kind: "field", name: "nzColon", static: false, private: false, access: { has: obj => "nzColon" in obj, get: obj => obj.nzColon, set: (obj, value) => { obj.nzColon = value; } }, metadata: _metadata }, _nzColon_initializers, _nzColon_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
nzConfigService = inject(NzConfigService);
cdr = inject(ChangeDetectorRef);
breakpointService = inject(NzBreakpointService);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
items;
nzBordered = __runInitializers(this, _nzBordered_initializers, false);
nzLayout = (__runInitializers(this, _nzBordered_extraInitializers), 'horizontal');
nzColumn = __runInitializers(this, _nzColumn_initializers, defaultColumnMap);
nzSize = (__runInitializers(this, _nzColumn_extraInitializers), __runInitializers(this, _nzSize_initializers, 'default'));
nzTitle = (__runInitializers(this, _nzSize_extraInitializers), '');
nzExtra;
nzColon = __runInitializers(this, _nzColon_initializers, true);
itemMatrix = (__runInitializers(this, _nzColon_extraInitializers), []);
realColumn = 3;
dir = 'ltr';
breakpoint = NzBreakpointEnum.md;
ngOnInit() {
this.dir = this.directionality.value;
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((direction) => {
this.dir = direction;
});
}
ngOnChanges(changes) {
if (changes.nzColumn) {
this.prepareMatrix();
}
}
ngAfterContentInit() {
const contentChange$ = this.items.changes.pipe(startWith(this.items));
merge(contentChange$, contentChange$.pipe(switchMap(() => merge(...this.items.map(i => i.inputChange$)).pipe(auditTime(16)))), this.breakpointService.subscribe(gridResponsiveMap).pipe(tap(bp => (this.breakpoint = bp))))
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.prepareMatrix();
this.cdr.markForCheck();
});
}
/**
* Prepare the render matrix according to description items' spans.
*/
prepareMatrix() {
if (!this.items) {
return;
}
let currentRow = [];
let width = 0;
const column = (this.realColumn = this.getColumn());
const items = this.items.toArray();
const length = items.length;
const matrix = [];
const flushRow = () => {
matrix.push(currentRow);
currentRow = [];
width = 0;
};
for (let i = 0; i < length; i++) {
const item = items[i];
const { nzTitle: title, content, nzSpan: span } = item;
width += span;
// If the last item make the row's length exceeds `nzColumn`, the last
// item should take all the space left. This logic is implemented in the template.
// Warn user about that.
if (width >= column) {
if (width > column) {
warn(`"nzColumn" is ${column} but we have row length ${width}`);
}
currentRow.push({ title, content, span: column - (width - span) });
flushRow();
}
else if (i === length - 1) {
currentRow.push({ title, content, span: column - (width - span) });
flushRow();
}
else {
currentRow.push({ title, content, span });
}
}
this.itemMatrix = matrix;
}
getColumn() {
if (typeof this.nzColumn !== 'number') {
return this.nzColumn[this.breakpoint];
}
return this.nzColumn;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDescriptionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzDescriptionsComponent, isStandalone: true, selector: "nz-descriptions", inputs: { nzBordered: ["nzBordered", "nzBordered", booleanAttribute], nzLayout: "nzLayout", nzColumn: "nzColumn", nzSize: "nzSize", nzTitle: "nzTitle", nzExtra: "nzExtra", nzColon: ["nzColon", "nzColon", booleanAttribute] }, host: { properties: { "class.ant-descriptions-bordered": "nzBordered", "class.ant-descriptions-middle": "nzSize === \"middle\"", "class.ant-descriptions-small": "nzSize === \"small\"", "class.ant-descriptions-rtl": "dir === \"rtl\"" }, classAttribute: "ant-descriptions" }, queries: [{ propertyName: "items", predicate: NzDescriptionsItemComponent }], exportAs: ["nzDescriptions"], usesOnChanges: true, ngImport: i0, template: `
@if (nzTitle || nzExtra) {
<div class="ant-descriptions-header">
@if (nzTitle) {
<div class="ant-descriptions-title">
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
</div>
}
@if (nzExtra) {
<div class="ant-descriptions-extra">
<ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
</div>
}
</div>
}
<div class="ant-descriptions-view">
<table>
<tbody>
@if (nzLayout === 'horizontal') {
@for (row of itemMatrix; track row; let i = $index) {
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
@if (!nzBordered) {
<td class="ant-descriptions-item" [colSpan]="item.span">
<div class="ant-descriptions-item-container">
<span class="ant-descriptions-item-label" [class.ant-descriptions-item-no-colon]="!nzColon">
<ng-container *nzStringTemplateOutlet="item.title">
{{ item.title }}
</ng-container>
</span>
<span class="ant-descriptions-item-content">
<ng-template [ngTemplateOutlet]="item.content"></ng-template>
</span>
</div>
</td>
} @else {
<td class="ant-descriptions-item-label">
<ng-container *nzStringTemplateOutlet="item.title">
{{ item.title }}
</ng-container>
</td>
<td class="ant-descriptions-item-content" [colSpan]="item.span * 2 - 1">
<ng-template [ngTemplateOutlet]="item.content"></ng-template>
</td>
}
}
</tr>
}
}
@if (nzLayout === 'vertical') {
@if (!nzBordered) {
@for (row of itemMatrix; track row; let i = $index) {
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
<td class="ant-descriptions-item" [colSpan]="item.span">
<div class="ant-descriptions-item-container">
<span class="ant-descriptions-item-label" [class.ant-descriptions-item-no-colon]="!nzColon">
<ng-container *nzStringTemplateOutlet="item.title">
{{ item.title }}
</ng-container>
</span>
</div>
</td>
}
</tr>
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
<td class="ant-descriptions-item" [colSpan]="item.span">
<div class="ant-descriptions-item-container">
<span class="ant-descriptions-item-content">
<ng-template [ngTemplateOutlet]="item.content" />
</span>
</div>
</td>
}
</tr>
}
} @else {
@for (row of itemMatrix; track row; let i = $index) {
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
<td class="ant-descriptions-item-label" [colSpan]="item.span">
<ng-container *nzStringTemplateOutlet="item.title">
{{ item.title }}
</ng-container>
</td>
}
</tr>
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
<td class="ant-descriptions-item-content" [colSpan]="item.span">
<ng-template [ngTemplateOutlet]="item.content" />
</td>
}
</tr>
}
}
}
</tbody>
</table>
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDescriptionsComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-descriptions',
exportAs: 'nzDescriptions',
template: `
@if (nzTitle || nzExtra) {
<div class="ant-descriptions-header">
@if (nzTitle) {
<div class="ant-descriptions-title">
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
</div>
}
@if (nzExtra) {
<div class="ant-descriptions-extra">
<ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
</div>
}
</div>
}
<div class="ant-descriptions-view">
<table>
<tbody>
@if (nzLayout === 'horizontal') {
@for (row of itemMatrix; track row; let i = $index) {
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
@if (!nzBordered) {
<td class="ant-descriptions-item" [colSpan]="item.span">
<div class="ant-descriptions-item-container">
<span class="ant-descriptions-item-label" [class.ant-descriptions-item-no-colon]="!nzColon">
<ng-container *nzStringTemplateOutlet="item.title">
{{ item.title }}
</ng-container>
</span>
<span class="ant-descriptions-item-content">
<ng-template [ngTemplateOutlet]="item.content"></ng-template>
</span>
</div>
</td>
} @else {
<td class="ant-descriptions-item-label">
<ng-container *nzStringTemplateOutlet="item.title">
{{ item.title }}
</ng-container>
</td>
<td class="ant-descriptions-item-content" [colSpan]="item.span * 2 - 1">
<ng-template [ngTemplateOutlet]="item.content"></ng-template>
</td>
}
}
</tr>
}
}
@if (nzLayout === 'vertical') {
@if (!nzBordered) {
@for (row of itemMatrix; track row; let i = $index) {
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
<td class="ant-descriptions-item" [colSpan]="item.span">
<div class="ant-descriptions-item-container">
<span class="ant-descriptions-item-label" [class.ant-descriptions-item-no-colon]="!nzColon">
<ng-container *nzStringTemplateOutlet="item.title">
{{ item.title }}
</ng-container>
</span>
</div>
</td>
}
</tr>
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
<td class="ant-descriptions-item" [colSpan]="item.span">
<div class="ant-descriptions-item-container">
<span class="ant-descriptions-item-content">
<ng-template [ngTemplateOutlet]="item.content" />
</span>
</div>
</td>
}
</tr>
}
} @else {
@for (row of itemMatrix; track row; let i = $index) {
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
<td class="ant-descriptions-item-label" [colSpan]="item.span">
<ng-container *nzStringTemplateOutlet="item.title">
{{ item.title }}
</ng-container>
</td>
}
</tr>
<tr class="ant-descriptions-row">
@for (item of row; track item; let isLast = $last) {
<td class="ant-descriptions-item-content" [colSpan]="item.span">
<ng-template [ngTemplateOutlet]="item.content" />
</td>
}
</tr>
}
}
}
</tbody>
</table>
</div>
`,
host: {
class: 'ant-descriptions',
'[class.ant-descriptions-bordered]': 'nzBordered',
'[class.ant-descriptions-middle]': 'nzSize === "middle"',
'[class.ant-descriptions-small]': 'nzSize === "small"',
'[class.ant-descriptions-rtl]': 'dir === "rtl"'
},
imports: [NzOutletModule, NgTemplateOutlet]
}]
}], propDecorators: { items: [{
type: ContentChildren,
args: [NzDescriptionsItemComponent]
}], nzBordered: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzLayout: [{
type: Input
}], nzColumn: [{
type: Input
}], nzSize: [{
type: Input
}], nzTitle: [{
type: Input
}], nzExtra: [{
type: Input
}], nzColon: [{
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 NzDescriptionsModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDescriptionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzDescriptionsModule, imports: [NzDescriptionsComponent, NzDescriptionsItemComponent], exports: [NzDescriptionsComponent, NzDescriptionsItemComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDescriptionsModule, imports: [NzDescriptionsComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDescriptionsModule, decorators: [{
type: NgModule,
args: [{
imports: [NzDescriptionsComponent, NzDescriptionsItemComponent],
exports: [NzDescriptionsComponent, NzDescriptionsItemComponent]
}]
}] });
/**
* 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
*/
/**
* 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 { NzDescriptionsComponent, NzDescriptionsItemComponent, NzDescriptionsModule };
//# sourceMappingURL=ng-zorro-antd-descriptions.mjs.map
File diff suppressed because one or more lines are too long
+102
View File
@@ -0,0 +1,102 @@
import * as i0 from '@angular/core';
import { booleanAttribute, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule } from '@angular/core';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
/**
* 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 NzDividerComponent {
nzText;
nzType = 'horizontal';
nzOrientation = 'center';
nzVariant = 'solid';
nzSize;
nzDashed = false;
nzPlain = false;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDividerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzDividerComponent, isStandalone: true, selector: "nz-divider", inputs: { nzText: "nzText", nzType: "nzType", nzOrientation: "nzOrientation", nzVariant: "nzVariant", nzSize: "nzSize", nzDashed: ["nzDashed", "nzDashed", booleanAttribute], nzPlain: ["nzPlain", "nzPlain", booleanAttribute] }, host: { properties: { "class.ant-divider-horizontal": "nzType === 'horizontal'", "class.ant-divider-vertical": "nzType === 'vertical'", "class.ant-divider-with-text": "nzText", "class.ant-divider-plain": "nzPlain", "class.ant-divider-with-text-left": "nzText && nzOrientation === 'left'", "class.ant-divider-with-text-right": "nzText && nzOrientation === 'right'", "class.ant-divider-with-text-center": "nzText && nzOrientation === 'center'", "class.ant-divider-dashed": "nzDashed || nzVariant === 'dashed'", "class.ant-divider-dotted": "nzVariant === 'dotted'", "class.ant-divider-sm": "nzSize === 'small'", "class.ant-divider-md": "nzSize === 'middle'" }, classAttribute: "ant-divider" }, exportAs: ["nzDivider"], ngImport: i0, template: `
@if (nzText) {
<span class="ant-divider-inner-text">
<ng-container *nzStringTemplateOutlet="nzText">{{ nzText }}</ng-container>
</span>
}
`, 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: "20.3.0", ngImport: i0, type: NzDividerComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-divider',
exportAs: 'nzDivider',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@if (nzText) {
<span class="ant-divider-inner-text">
<ng-container *nzStringTemplateOutlet="nzText">{{ nzText }}</ng-container>
</span>
}
`,
host: {
class: 'ant-divider',
'[class.ant-divider-horizontal]': `nzType === 'horizontal'`,
'[class.ant-divider-vertical]': `nzType === 'vertical'`,
'[class.ant-divider-with-text]': `nzText`,
'[class.ant-divider-plain]': `nzPlain`,
'[class.ant-divider-with-text-left]': `nzText && nzOrientation === 'left'`,
'[class.ant-divider-with-text-right]': `nzText && nzOrientation === 'right'`,
'[class.ant-divider-with-text-center]': `nzText && nzOrientation === 'center'`,
'[class.ant-divider-dashed]': `nzDashed || nzVariant === 'dashed'`,
'[class.ant-divider-dotted]': `nzVariant === 'dotted'`,
'[class.ant-divider-sm]': `nzSize === 'small'`,
'[class.ant-divider-md]': `nzSize === 'middle'`
},
imports: [NzOutletModule]
}]
}], propDecorators: { nzText: [{
type: Input
}], nzType: [{
type: Input
}], nzOrientation: [{
type: Input
}], nzVariant: [{
type: Input
}], nzSize: [{
type: Input
}], nzDashed: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzPlain: [{
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 NzDividerModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDividerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzDividerModule, imports: [NzDividerComponent], exports: [NzDividerComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDividerModule, imports: [NzDividerComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDividerModule, decorators: [{
type: NgModule,
args: [{
imports: [NzDividerComponent],
exports: [NzDividerComponent]
}]
}] });
/**
* 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 { NzDividerComponent, NzDividerModule };
//# sourceMappingURL=ng-zorro-antd-divider.mjs.map
File diff suppressed because one or more lines are too long
+724
View File
@@ -0,0 +1,724 @@
import * as i0 from '@angular/core';
import { inject, TemplateRef, Directive, InjectionToken, ChangeDetectorRef, Renderer2, Injector, ViewContainerRef, DestroyRef, EventEmitter, DOCUMENT, Type, booleanAttribute, ContentChild, ViewChild, Output, Input, ChangeDetectionStrategy, Component, Injectable, NgModule } from '@angular/core';
import { __esDecorate, __runInitializers } from 'tslib';
import { FocusTrapFactory } from '@angular/cdk/a11y';
import { Directionality } from '@angular/cdk/bidi';
import { ESCAPE } from '@angular/cdk/keycodes';
import { OverlayKeyboardDispatcher, createOverlayRef, createBlockScrollStrategy, createGlobalPositionStrategy, CdkScrollable } from '@angular/cdk/overlay';
import * as i3 from '@angular/cdk/portal';
import { ComponentPortal, TemplatePortal, PortalModule, CdkPortalOutlet } from '@angular/cdk/portal';
import { NgTemplateOutlet } from '@angular/common';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Subject } from 'rxjs';
import { drawerMaskMotion } from 'ng-zorro-antd/core/animation';
import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { overlayZIndexSetter } from 'ng-zorro-antd/core/overlay';
import { isTemplateRef, toCssPixel } from 'ng-zorro-antd/core/util';
import * as i2 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { takeUntil } from 'rxjs/operators';
/**
* 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 NzDrawerContentDirective {
templateRef = inject((TemplateRef));
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzDrawerContentDirective, isStandalone: true, selector: "[nzDrawerContent]", exportAs: ["nzDrawerContent"], ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerContentDirective, decorators: [{
type: Directive,
args: [{
selector: '[nzDrawerContent]',
exportAs: 'nzDrawerContent'
}]
}] });
/**
* 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 DRAWER_DEFAULT_SIZE = 378;
const DRAWER_LARGE_SIZE = 736;
const NZ_DRAWER_DATA = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'nz-drawer-data' : '');
/**
* 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 NzDrawerRef {
}
const DRAWER_ANIMATE_DURATION = 300;
const NZ_CONFIG_MODULE_NAME = 'drawer';
let NzDrawerComponent = (() => {
let _classSuper = NzDrawerRef;
let _nzMaskClosable_decorators;
let _nzMaskClosable_initializers = [];
let _nzMaskClosable_extraInitializers = [];
let _nzMask_decorators;
let _nzMask_initializers = [];
let _nzMask_extraInitializers = [];
let _nzCloseOnNavigation_decorators;
let _nzCloseOnNavigation_initializers = [];
let _nzCloseOnNavigation_extraInitializers = [];
let _nzDirection_decorators;
let _nzDirection_initializers = [];
let _nzDirection_extraInitializers = [];
return class NzDrawerComponent extends _classSuper {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
_nzMaskClosable_decorators = [WithConfig()];
_nzMask_decorators = [WithConfig()];
_nzCloseOnNavigation_decorators = [WithConfig()];
_nzDirection_decorators = [WithConfig()];
__esDecorate(null, null, _nzMaskClosable_decorators, { kind: "field", name: "nzMaskClosable", static: false, private: false, access: { has: obj => "nzMaskClosable" in obj, get: obj => obj.nzMaskClosable, set: (obj, value) => { obj.nzMaskClosable = value; } }, metadata: _metadata }, _nzMaskClosable_initializers, _nzMaskClosable_extraInitializers);
__esDecorate(null, null, _nzMask_decorators, { kind: "field", name: "nzMask", static: false, private: false, access: { has: obj => "nzMask" in obj, get: obj => obj.nzMask, set: (obj, value) => { obj.nzMask = value; } }, metadata: _metadata }, _nzMask_initializers, _nzMask_extraInitializers);
__esDecorate(null, null, _nzCloseOnNavigation_decorators, { kind: "field", name: "nzCloseOnNavigation", static: false, private: false, access: { has: obj => "nzCloseOnNavigation" in obj, get: obj => obj.nzCloseOnNavigation, set: (obj, value) => { obj.nzCloseOnNavigation = value; } }, metadata: _metadata }, _nzCloseOnNavigation_initializers, _nzCloseOnNavigation_extraInitializers);
__esDecorate(null, null, _nzDirection_decorators, { kind: "field", name: "nzDirection", static: false, private: false, access: { has: obj => "nzDirection" in obj, get: obj => obj.nzDirection, set: (obj, value) => { obj.nzDirection = value; } }, metadata: _metadata }, _nzDirection_initializers, _nzDirection_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
cdr = inject(ChangeDetectorRef);
nzConfigService = inject(NzConfigService);
renderer = inject(Renderer2);
injector = inject(Injector);
changeDetectorRef = inject(ChangeDetectorRef);
focusTrapFactory = inject(FocusTrapFactory);
viewContainerRef = inject(ViewContainerRef);
overlayKeyboardDispatcher = inject(OverlayKeyboardDispatcher);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
nzContent;
nzCloseIcon = 'close';
nzClosable = true;
nzMaskClosable = __runInitializers(this, _nzMaskClosable_initializers, true);
nzMask = (__runInitializers(this, _nzMaskClosable_extraInitializers), __runInitializers(this, _nzMask_initializers, true));
nzCloseOnNavigation = (__runInitializers(this, _nzMask_extraInitializers), __runInitializers(this, _nzCloseOnNavigation_initializers, true));
nzNoAnimation = (__runInitializers(this, _nzCloseOnNavigation_extraInitializers), false);
nzKeyboard = true;
nzTitle;
nzExtra;
nzFooter;
nzPlacement = 'right';
nzSize = 'default';
nzMaskStyle = {};
nzBodyStyle = {};
nzWrapClassName;
nzWidth;
nzHeight;
nzZIndex = 1000;
nzOffsetX = 0;
nzOffsetY = 0;
componentInstance = null;
componentRef = null;
set nzVisible(value) {
this.isOpen = value;
}
get nzVisible() {
return this.isOpen;
}
nzOnViewInit = new EventEmitter();
nzOnClose = new EventEmitter();
nzVisibleChange = new EventEmitter();
drawerTemplate;
bodyPortalOutlet;
contentFromContentChild;
previouslyFocusedElement;
placementChanging = false;
placementChangeTimeoutId;
nzContentParams; // only service
nzData;
overlayRef;
portal;
focusTrap;
isOpen = false;
inAnimation = false;
templateContext = {
$implicit: undefined,
drawerRef: this
};
isTemplateRef = isTemplateRef;
get offsetTransform() {
if (!this.isOpen || this.nzOffsetX + this.nzOffsetY === 0) {
return null;
}
switch (this.nzPlacement) {
case 'left':
return `translateX(${this.nzOffsetX}px)`;
case 'right':
return `translateX(-${this.nzOffsetX}px)`;
case 'top':
return `translateY(${this.nzOffsetY}px)`;
case 'bottom':
return `translateY(-${this.nzOffsetY}px)`;
}
}
get transform() {
if (this.isOpen) {
return null;
}
switch (this.nzPlacement) {
case 'left':
return `translateX(-100%)`;
case 'right':
return `translateX(100%)`;
case 'top':
return `translateY(-100%)`;
case 'bottom':
return `translateY(100%)`;
}
}
get width() {
if (this.isLeftOrRight) {
const defaultWidth = this.nzSize === 'large' ? DRAWER_LARGE_SIZE : DRAWER_DEFAULT_SIZE;
return this.nzWidth === undefined ? toCssPixel(defaultWidth) : toCssPixel(this.nzWidth);
}
return null;
}
get height() {
if (!this.isLeftOrRight) {
const defaultHeight = this.nzSize === 'large' ? DRAWER_LARGE_SIZE : DRAWER_DEFAULT_SIZE;
return this.nzHeight === undefined ? toCssPixel(defaultHeight) : toCssPixel(this.nzHeight);
}
return null;
}
get isLeftOrRight() {
return this.nzPlacement === 'left' || this.nzPlacement === 'right';
}
nzAfterOpen = new Subject();
nzAfterClose = new Subject();
get afterOpen() {
return this.nzAfterOpen.asObservable();
}
get afterClose() {
return this.nzAfterClose.asObservable();
}
get isNzContentTemplateRef() {
return isTemplateRef(this.nzContent);
}
// from service config
nzDirection = __runInitializers(this, _nzDirection_initializers, undefined);
dir = (__runInitializers(this, _nzDirection_extraInitializers), 'ltr');
document = inject(DOCUMENT);
constructor() {
super();
this.destroyRef.onDestroy(() => {
clearTimeout(this.placementChangeTimeoutId);
this.disposeOverlay();
});
}
ngOnInit() {
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.nzDirection || this.directionality.value;
this.attachOverlay();
this.updateOverlayStyle();
this.updateBodyOverflow();
this.templateContext = { $implicit: this.nzData || this.nzContentParams, drawerRef: this };
this.changeDetectorRef.detectChanges();
}
ngAfterViewInit() {
this.attachBodyContent();
// The `setTimeout` triggers change detection. There's no sense to schedule the DOM timer if anyone is
// listening to the `nzOnViewInit` event inside the template, for instance `<nz-drawer (nzOnViewInit)="...">`.
if (this.nzOnViewInit.observers.length) {
setTimeout(() => {
this.nzOnViewInit.emit();
});
}
}
ngOnChanges(changes) {
const { nzPlacement, nzVisible } = changes;
if (nzVisible) {
const value = changes.nzVisible.currentValue;
if (value) {
this.open();
}
else {
this.close();
}
}
if (nzPlacement && !nzPlacement.isFirstChange()) {
this.triggerPlacementChangeCycleOnce();
}
}
getAnimationDuration() {
return this.nzNoAnimation ? 0 : DRAWER_ANIMATE_DURATION;
}
// Disable the transition animation temporarily when the placement changing
triggerPlacementChangeCycleOnce() {
if (!this.nzNoAnimation) {
this.placementChanging = true;
this.changeDetectorRef.markForCheck();
clearTimeout(this.placementChangeTimeoutId);
this.placementChangeTimeoutId = setTimeout(() => {
this.placementChanging = false;
this.changeDetectorRef.markForCheck();
}, this.getAnimationDuration());
}
}
close(result) {
this.isOpen = false;
this.inAnimation = true;
this.nzVisibleChange.emit(false);
this.updateOverlayStyle();
this.overlayKeyboardDispatcher.remove(this.overlayRef);
this.changeDetectorRef.detectChanges();
setTimeout(() => {
this.updateBodyOverflow();
this.restoreFocus();
this.inAnimation = false;
this.nzAfterClose.next(result);
this.nzAfterClose.complete();
this.componentInstance = null;
this.componentRef = null;
}, this.getAnimationDuration());
}
open() {
this.attachOverlay();
this.isOpen = true;
this.inAnimation = true;
this.nzVisibleChange.emit(true);
this.overlayKeyboardDispatcher.add(this.overlayRef);
this.updateOverlayStyle();
this.updateBodyOverflow();
this.savePreviouslyFocusedElement();
this.trapFocus();
this.changeDetectorRef.detectChanges();
setTimeout(() => {
this.inAnimation = false;
this.changeDetectorRef.detectChanges();
this.nzAfterOpen.next();
}, this.getAnimationDuration());
}
getContentComponent() {
return this.componentInstance;
}
getContentComponentRef() {
return this.componentRef;
}
closeClick() {
this.nzOnClose.emit();
}
maskClick() {
if (this.nzMaskClosable && this.nzMask) {
this.nzOnClose.emit();
}
}
attachBodyContent() {
this.bodyPortalOutlet.dispose();
if (this.nzContent instanceof Type) {
const childInjector = Injector.create({
parent: this.injector,
providers: [
{ provide: NzDrawerRef, useValue: this },
{ provide: NZ_DRAWER_DATA, useValue: this.nzData }
]
});
const componentPortal = new ComponentPortal(this.nzContent, null, childInjector);
this.componentRef = this.bodyPortalOutlet.attachComponentPortal(componentPortal);
this.componentInstance = this.componentRef.instance;
/**TODO
* When nzContentParam will be remove in the next major version, we have to remove the following line
* **/
Object.assign(this.componentRef.instance, this.nzData || this.nzContentParams);
this.componentRef.changeDetectorRef.detectChanges();
}
}
attachOverlay() {
if (!this.overlayRef) {
this.portal = new TemplatePortal(this.drawerTemplate, this.viewContainerRef);
this.overlayRef = createOverlayRef(this.injector, {
disposeOnNavigation: this.nzCloseOnNavigation,
positionStrategy: createGlobalPositionStrategy(this.injector),
scrollStrategy: createBlockScrollStrategy(this.injector)
});
overlayZIndexSetter(this.overlayRef, this.nzZIndex);
}
if (this.overlayRef && !this.overlayRef.hasAttached()) {
this.overlayRef.attach(this.portal);
this.overlayRef.keydownEvents()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((event) => {
if (event.keyCode === ESCAPE && this.isOpen && this.nzKeyboard) {
this.nzOnClose.emit();
}
});
this.overlayRef
.detachments()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.close();
this.disposeOverlay();
});
}
}
disposeOverlay() {
this.overlayRef?.dispose();
this.overlayRef = null;
}
updateOverlayStyle() {
if (this.overlayRef && this.overlayRef.overlayElement) {
this.renderer.setStyle(this.overlayRef.overlayElement, 'pointer-events', this.isOpen ? 'auto' : 'none');
}
}
updateBodyOverflow() {
if (this.overlayRef) {
if (this.isOpen) {
this.overlayRef.getConfig().scrollStrategy.enable();
}
else {
this.overlayRef.getConfig().scrollStrategy.disable();
}
}
}
savePreviouslyFocusedElement() {
if (this.document && !this.previouslyFocusedElement) {
this.previouslyFocusedElement = this.document.activeElement;
// We need the extra check, because IE's svg element has no blur method.
if (this.previouslyFocusedElement && typeof this.previouslyFocusedElement.blur === 'function') {
this.previouslyFocusedElement.blur();
}
}
}
trapFocus() {
if (!this.focusTrap && this.overlayRef && this.overlayRef.overlayElement) {
this.focusTrap = this.focusTrapFactory.create(this.overlayRef.overlayElement);
this.focusTrap.focusInitialElement();
}
}
restoreFocus() {
// We need the extra check, because IE can set the `activeElement` to null in some cases.
if (this.previouslyFocusedElement && typeof this.previouslyFocusedElement.focus === 'function') {
this.previouslyFocusedElement.focus();
this.previouslyFocusedElement = undefined;
}
if (this.focusTrap) {
this.focusTrap.destroy();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzDrawerComponent, isStandalone: true, selector: "nz-drawer", inputs: { nzContent: "nzContent", nzCloseIcon: "nzCloseIcon", nzClosable: ["nzClosable", "nzClosable", booleanAttribute], nzMaskClosable: ["nzMaskClosable", "nzMaskClosable", booleanAttribute], nzMask: ["nzMask", "nzMask", booleanAttribute], nzCloseOnNavigation: ["nzCloseOnNavigation", "nzCloseOnNavigation", booleanAttribute], nzNoAnimation: ["nzNoAnimation", "nzNoAnimation", booleanAttribute], nzKeyboard: ["nzKeyboard", "nzKeyboard", booleanAttribute], nzTitle: "nzTitle", nzExtra: "nzExtra", nzFooter: "nzFooter", nzPlacement: "nzPlacement", nzSize: "nzSize", nzMaskStyle: "nzMaskStyle", nzBodyStyle: "nzBodyStyle", nzWrapClassName: "nzWrapClassName", nzWidth: "nzWidth", nzHeight: "nzHeight", nzZIndex: "nzZIndex", nzOffsetX: "nzOffsetX", nzOffsetY: "nzOffsetY", nzVisible: ["nzVisible", "nzVisible", booleanAttribute] }, outputs: { nzOnViewInit: "nzOnViewInit", nzOnClose: "nzOnClose", nzVisibleChange: "nzVisibleChange" }, queries: [{ propertyName: "contentFromContentChild", first: true, predicate: NzDrawerContentDirective, descendants: true, read: TemplateRef, static: true }], viewQueries: [{ propertyName: "drawerTemplate", first: true, predicate: ["drawerTemplate"], descendants: true, static: true }, { propertyName: "bodyPortalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true }], exportAs: ["nzDrawer"], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
<ng-template #drawerTemplate>
<div
class="ant-drawer"
[nzNoAnimation]="nzNoAnimation"
[class.ant-drawer-rtl]="dir === 'rtl'"
[class.ant-drawer-open]="isOpen"
[class.no-mask]="!nzMask"
[class.ant-drawer-top]="nzPlacement === 'top'"
[class.ant-drawer-bottom]="nzPlacement === 'bottom'"
[class.ant-drawer-right]="nzPlacement === 'right'"
[class.ant-drawer-left]="nzPlacement === 'left'"
[style.transform]="offsetTransform"
[style.transition]="placementChanging ? 'none' : null"
[style.zIndex]="nzZIndex"
>
@if (nzMask && isOpen) {
<div @drawerMaskMotion class="ant-drawer-mask" (click)="maskClick()" [style]="nzMaskStyle"></div>
}
<div
class="ant-drawer-content-wrapper {{ nzWrapClassName }}"
[style.width]="width"
[style.height]="height"
[style.transform]="transform"
[style.transition]="placementChanging ? 'none' : null"
>
<div class="ant-drawer-content">
<div class="ant-drawer-wrapper-body" [style.height]="isLeftOrRight ? '100%' : null">
@if (nzTitle || nzClosable) {
<div class="ant-drawer-header" [class.ant-drawer-header-close-only]="!nzTitle">
<div class="ant-drawer-header-title">
@if (nzClosable) {
<button (click)="closeClick()" aria-label="Close" class="ant-drawer-close">
<ng-container *nzStringTemplateOutlet="nzCloseIcon; let closeIcon">
<nz-icon [nzType]="closeIcon" />
</ng-container>
</button>
}
@if (nzTitle) {
<div class="ant-drawer-title">
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
</div>
}
</div>
@if (nzExtra) {
<div class="ant-drawer-extra">
<ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
</div>
}
</div>
}
<div class="ant-drawer-body" [style]="nzBodyStyle" cdkScrollable>
<ng-template cdkPortalOutlet />
@if (nzContent) {
@if (isTemplateRef(nzContent)) {
<ng-container *ngTemplateOutlet="nzContent; context: templateContext" />
}
} @else {
@if (contentFromContentChild && (isOpen || inAnimation)) {
<ng-template [ngTemplateOutlet]="contentFromContentChild" />
}
}
</div>
@if (nzFooter) {
<div class="ant-drawer-footer">
<ng-container *nzStringTemplateOutlet="nzFooter">{{ nzFooter }}</ng-container>
</div>
}
</div>
</div>
</div>
</div>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NzNoAnimationDirective, selector: "[nzNoAnimation]", inputs: ["nzNoAnimation"], exportAs: ["nzNoAnimation"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i3.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CdkScrollable, selector: "[cdk-scrollable], [cdkScrollable]" }], animations: [drawerMaskMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerComponent, decorators: [{
type: Component,
args: [{
selector: 'nz-drawer',
exportAs: 'nzDrawer',
template: `
<ng-template #drawerTemplate>
<div
class="ant-drawer"
[nzNoAnimation]="nzNoAnimation"
[class.ant-drawer-rtl]="dir === 'rtl'"
[class.ant-drawer-open]="isOpen"
[class.no-mask]="!nzMask"
[class.ant-drawer-top]="nzPlacement === 'top'"
[class.ant-drawer-bottom]="nzPlacement === 'bottom'"
[class.ant-drawer-right]="nzPlacement === 'right'"
[class.ant-drawer-left]="nzPlacement === 'left'"
[style.transform]="offsetTransform"
[style.transition]="placementChanging ? 'none' : null"
[style.zIndex]="nzZIndex"
>
@if (nzMask && isOpen) {
<div @drawerMaskMotion class="ant-drawer-mask" (click)="maskClick()" [style]="nzMaskStyle"></div>
}
<div
class="ant-drawer-content-wrapper {{ nzWrapClassName }}"
[style.width]="width"
[style.height]="height"
[style.transform]="transform"
[style.transition]="placementChanging ? 'none' : null"
>
<div class="ant-drawer-content">
<div class="ant-drawer-wrapper-body" [style.height]="isLeftOrRight ? '100%' : null">
@if (nzTitle || nzClosable) {
<div class="ant-drawer-header" [class.ant-drawer-header-close-only]="!nzTitle">
<div class="ant-drawer-header-title">
@if (nzClosable) {
<button (click)="closeClick()" aria-label="Close" class="ant-drawer-close">
<ng-container *nzStringTemplateOutlet="nzCloseIcon; let closeIcon">
<nz-icon [nzType]="closeIcon" />
</ng-container>
</button>
}
@if (nzTitle) {
<div class="ant-drawer-title">
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
</div>
}
</div>
@if (nzExtra) {
<div class="ant-drawer-extra">
<ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
</div>
}
</div>
}
<div class="ant-drawer-body" [style]="nzBodyStyle" cdkScrollable>
<ng-template cdkPortalOutlet />
@if (nzContent) {
@if (isTemplateRef(nzContent)) {
<ng-container *ngTemplateOutlet="nzContent; context: templateContext" />
}
} @else {
@if (contentFromContentChild && (isOpen || inAnimation)) {
<ng-template [ngTemplateOutlet]="contentFromContentChild" />
}
}
</div>
@if (nzFooter) {
<div class="ant-drawer-footer">
<ng-container *nzStringTemplateOutlet="nzFooter">{{ nzFooter }}</ng-container>
</div>
}
</div>
</div>
</div>
</div>
</ng-template>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [drawerMaskMotion],
imports: [NzNoAnimationDirective, NzOutletModule, NzIconModule, PortalModule, NgTemplateOutlet, CdkScrollable]
}]
}], ctorParameters: () => [], propDecorators: { nzContent: [{
type: Input
}], nzCloseIcon: [{
type: Input
}], nzClosable: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzMaskClosable: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzMask: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzCloseOnNavigation: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzNoAnimation: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzKeyboard: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzTitle: [{
type: Input
}], nzExtra: [{
type: Input
}], nzFooter: [{
type: Input
}], nzPlacement: [{
type: Input
}], nzSize: [{
type: Input
}], nzMaskStyle: [{
type: Input
}], nzBodyStyle: [{
type: Input
}], nzWrapClassName: [{
type: Input
}], nzWidth: [{
type: Input
}], nzHeight: [{
type: Input
}], nzZIndex: [{
type: Input
}], nzOffsetX: [{
type: Input
}], nzOffsetY: [{
type: Input
}], nzVisible: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzOnViewInit: [{
type: Output
}], nzOnClose: [{
type: Output
}], nzVisibleChange: [{
type: Output
}], drawerTemplate: [{
type: ViewChild,
args: ['drawerTemplate', { static: true }]
}], bodyPortalOutlet: [{
type: ViewChild,
args: [CdkPortalOutlet, { static: false }]
}], contentFromContentChild: [{
type: ContentChild,
args: [NzDrawerContentDirective, { static: true, read: TemplateRef }]
}], nzDirection: [] } });
/**
* 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 DrawerBuilderForService {
overlayRef;
options;
drawerRef;
unsubscribe$ = new Subject();
constructor(overlayRef, options) {
this.overlayRef = overlayRef;
this.options = options;
/** pick {@link NzDrawerOptions.nzOnCancel} and omit this option */
const { nzOnCancel, ...componentOption } = this.options;
this.drawerRef = this.overlayRef.attach(new ComponentPortal(NzDrawerComponent)).instance;
this.updateOptions(componentOption);
// Prevent repeatedly open drawer when tap focus element.
this.drawerRef.savePreviouslyFocusedElement();
this.drawerRef.nzOnViewInit.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
this.drawerRef.open();
});
this.drawerRef.nzOnClose.subscribe(() => {
if (nzOnCancel) {
nzOnCancel().then(canClose => {
if (canClose !== false) {
this.drawerRef.close();
}
});
}
else {
this.drawerRef.close();
}
});
this.drawerRef.afterClose.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
this.overlayRef.dispose();
this.drawerRef = null;
this.unsubscribe$.next();
this.unsubscribe$.complete();
});
}
getInstance() {
return this.drawerRef;
}
updateOptions(options) {
Object.assign(this.drawerRef, options);
}
}
class NzDrawerService {
injector = inject(Injector);
create(options) {
return new DrawerBuilderForService(createOverlayRef(this.injector), options).getInstance();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerService, decorators: [{
type: Injectable
}] });
/**
* 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 NzDrawerModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerModule, imports: [NzDrawerComponent, NzDrawerContentDirective], exports: [NzDrawerComponent, NzDrawerContentDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerModule, providers: [NzDrawerService], imports: [NzDrawerComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDrawerModule, decorators: [{
type: NgModule,
args: [{
imports: [NzDrawerComponent, NzDrawerContentDirective],
providers: [NzDrawerService],
exports: [NzDrawerComponent, NzDrawerContentDirective]
}]
}] });
/**
* 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 { DRAWER_ANIMATE_DURATION, DRAWER_DEFAULT_SIZE, DRAWER_LARGE_SIZE, DrawerBuilderForService, NZ_DRAWER_DATA, NzDrawerComponent, NzDrawerContentDirective, NzDrawerModule, NzDrawerRef, NzDrawerService };
//# sourceMappingURL=ng-zorro-antd-drawer.mjs.map
File diff suppressed because one or more lines are too long
+525
View File
@@ -0,0 +1,525 @@
import { __esDecorate, __runInitializers } from 'tslib';
import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
import { createFlexibleConnectedPositionStrategy, createOverlayRef, createRepositionScrollStrategy, ConnectionPositionPair, createCloseScrollStrategy } from '@angular/cdk/overlay';
import { Platform } from '@angular/cdk/platform';
import { TemplatePortal } from '@angular/cdk/portal';
import * as i0 from '@angular/core';
import { inject, Renderer2, ViewContainerRef, DestroyRef, ElementRef, Injector, EventEmitter, booleanAttribute, Output, Input, Directive, NgModule, ChangeDetectorRef, TemplateRef, ViewChild, ChangeDetectionStrategy, ViewEncapsulation, Component, NgZone, Injectable } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { BehaviorSubject, Subject, merge, fromEvent, EMPTY, combineLatest, Subscription } from 'rxjs';
import { map, switchMap, filter, auditTime, distinctUntilChanged, first } from 'rxjs/operators';
import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
import { getPlacementName, setConnectedPositionOffset, POSITION_MAP, TOOLTIP_OFFSET_MAP } from 'ng-zorro-antd/core/overlay';
import { MenuService, NzIsMenuInsideDropDownToken, NzMenuModule } from 'ng-zorro-antd/menu';
import { Directionality } from '@angular/cdk/bidi';
import { slideMotion } from 'ng-zorro-antd/core/animation';
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
const NZ_CONFIG_MODULE_NAME = 'dropDown';
const listOfPositions = ['bottomLeft', 'bottomRight', 'topRight', 'topLeft'];
const normalizePlacementForClass = (p) => {
// Map center placements to generic top/bottom classes for styling
if (p === 'topCenter') {
return 'top';
}
if (p === 'bottomCenter') {
return 'bottom';
}
return p;
};
let NzDropDownDirective = (() => {
let _nzBackdrop_decorators;
let _nzBackdrop_initializers = [];
let _nzBackdrop_extraInitializers = [];
return class NzDropDownDirective {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzBackdrop_decorators = [WithConfig()];
__esDecorate(null, null, _nzBackdrop_decorators, { kind: "field", name: "nzBackdrop", static: false, private: false, access: { has: obj => "nzBackdrop" in obj, get: obj => obj.nzBackdrop, set: (obj, value) => { obj.nzBackdrop = value; } }, metadata: _metadata }, _nzBackdrop_initializers, _nzBackdrop_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
nzConfigService = inject(NzConfigService);
renderer = inject(Renderer2);
viewContainerRef = inject(ViewContainerRef);
platform = inject(Platform);
destroyRef = inject(DestroyRef);
_nzModuleName = NZ_CONFIG_MODULE_NAME;
elementRef = inject(ElementRef);
injector = inject(Injector);
portal;
overlayRef = null;
positionStrategy = createFlexibleConnectedPositionStrategy(this.injector, this.elementRef.nativeElement)
.withLockedPosition()
.withTransformOriginOn('.ant-dropdown');
inputVisible$ = new BehaviorSubject(false);
nzTrigger$ = new BehaviorSubject('hover');
overlayClose$ = new Subject();
nzDropdownMenu = null;
nzTrigger = 'hover';
nzMatchWidthElement = null;
nzBackdrop = __runInitializers(this, _nzBackdrop_initializers, false);
nzClickHide = (__runInitializers(this, _nzBackdrop_extraInitializers), true);
nzDisabled = false;
nzVisible = false;
nzArrow = false;
nzOverlayClassName = '';
nzOverlayStyle = {};
nzPlacement = 'bottomLeft';
nzVisibleChange = new EventEmitter();
constructor() {
this.destroyRef.onDestroy(() => {
this.overlayRef?.dispose();
this.overlayRef = null;
});
}
setDropdownMenuValue(key, value) {
if (this.nzDropdownMenu) {
this.nzDropdownMenu.setValue(key, value);
}
}
ngAfterViewInit() {
if (this.nzDropdownMenu) {
const nativeElement = this.elementRef.nativeElement;
/** host mouse state **/
const hostMouseState$ = merge(fromEvent(nativeElement, 'mouseenter').pipe(map(() => true)), fromEvent(nativeElement, 'mouseleave').pipe(map(() => false)));
/** menu mouse state **/
const menuMouseState$ = this.nzDropdownMenu.mouseState$;
/** merged mouse state **/
const mergedMouseState$ = merge(menuMouseState$, hostMouseState$);
/** host click state **/
const hostClickState$ = fromEvent(nativeElement, 'click').pipe(map(() => !this.nzVisible));
/** visible state switch by nzTrigger **/
const visibleStateByTrigger$ = this.nzTrigger$.pipe(switchMap(trigger => {
if (trigger === 'hover') {
return mergedMouseState$;
}
else if (trigger === 'click') {
return hostClickState$;
}
else {
return EMPTY;
}
}));
const descendantMenuItemClick$ = this.nzDropdownMenu.descendantMenuItemClick$.pipe(filter(() => this.nzClickHide), map(() => false));
const domTriggerVisible$ = merge(visibleStateByTrigger$, descendantMenuItemClick$, this.overlayClose$).pipe(filter(() => !this.nzDisabled));
const visible$ = merge(this.inputVisible$, domTriggerVisible$);
combineLatest([visible$, this.nzDropdownMenu.isChildSubMenuOpen$])
.pipe(map(([visible, sub]) => visible || sub), auditTime(150), distinctUntilChanged(), filter(() => this.platform.isBrowser), takeUntilDestroyed(this.destroyRef))
.subscribe((visible) => {
const element = this.nzMatchWidthElement ? this.nzMatchWidthElement.nativeElement : nativeElement;
const triggerWidth = element.getBoundingClientRect().width;
if (this.nzVisible !== visible) {
this.nzVisibleChange.emit(visible);
}
this.nzVisible = visible;
if (visible) {
/** set up overlayRef **/
if (!this.overlayRef) {
/** new overlay **/
this.overlayRef = createOverlayRef(this.injector, {
positionStrategy: this.positionStrategy,
minWidth: triggerWidth,
disposeOnNavigation: true,
hasBackdrop: this.nzBackdrop && this.nzTrigger === 'click',
scrollStrategy: createRepositionScrollStrategy(this.injector)
});
// Listen for placement changes to update the menu classes (arrow position)
this.positionStrategy.positionChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(change => {
const placement = getPlacementName(change);
if (placement) {
this.setDropdownMenuValue('placement', normalizePlacementForClass(placement));
}
});
merge(this.overlayRef.backdropClick(), this.overlayRef.detachments(), this.overlayRef
.outsidePointerEvents()
.pipe(filter((e) => !this.elementRef.nativeElement.contains(e.target))), this.overlayRef.keydownEvents().pipe(filter(e => e.keyCode === ESCAPE && !hasModifierKey(e))))
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.overlayClose$.next(false);
});
}
else {
/** update overlay config **/
const overlayConfig = this.overlayRef.getConfig();
overlayConfig.minWidth = triggerWidth;
}
/** open dropdown with animation **/
const positions = [this.nzPlacement, ...listOfPositions].map(position => {
return this.nzArrow
? setConnectedPositionOffset(POSITION_MAP[position], TOOLTIP_OFFSET_MAP[position])
: POSITION_MAP[position];
});
this.positionStrategy.withPositions(positions);
/** reset portal if needed **/
if (!this.portal || this.portal.templateRef !== this.nzDropdownMenu.templateRef) {
this.portal = new TemplatePortal(this.nzDropdownMenu.templateRef, this.viewContainerRef);
}
// Initialize arrow and placement on open
this.setDropdownMenuValue('nzArrow', this.nzArrow);
this.setDropdownMenuValue('placement', normalizePlacementForClass(this.nzPlacement));
this.overlayRef.attach(this.portal);
}
else {
/** detach overlayRef if needed **/
if (this.overlayRef) {
this.overlayRef.detach();
}
}
});
this.nzDropdownMenu.animationStateChange$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(event => {
if (event.toState === 'void') {
if (this.overlayRef) {
this.overlayRef.dispose();
}
this.overlayRef = null;
}
});
}
}
ngOnChanges(changes) {
const { nzVisible, nzDisabled, nzOverlayClassName, nzOverlayStyle, nzTrigger, nzArrow, nzPlacement } = changes;
if (nzTrigger) {
this.nzTrigger$.next(this.nzTrigger);
}
if (nzVisible) {
this.inputVisible$.next(this.nzVisible);
}
if (nzDisabled) {
const nativeElement = this.elementRef.nativeElement;
if (this.nzDisabled) {
this.renderer.setAttribute(nativeElement, 'disabled', '');
this.inputVisible$.next(false);
}
else {
this.renderer.removeAttribute(nativeElement, 'disabled');
}
}
if (nzOverlayClassName) {
this.setDropdownMenuValue('nzOverlayClassName', this.nzOverlayClassName);
}
if (nzOverlayStyle) {
this.setDropdownMenuValue('nzOverlayStyle', this.nzOverlayStyle);
}
if (nzArrow) {
this.setDropdownMenuValue('nzArrow', this.nzArrow);
}
if (nzPlacement) {
this.setDropdownMenuValue('placement', normalizePlacementForClass(this.nzPlacement));
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropDownDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.3.0", type: NzDropDownDirective, isStandalone: true, selector: "[nz-dropdown]", inputs: { nzDropdownMenu: "nzDropdownMenu", nzTrigger: "nzTrigger", nzMatchWidthElement: "nzMatchWidthElement", nzBackdrop: ["nzBackdrop", "nzBackdrop", booleanAttribute], nzClickHide: ["nzClickHide", "nzClickHide", booleanAttribute], nzDisabled: ["nzDisabled", "nzDisabled", booleanAttribute], nzVisible: ["nzVisible", "nzVisible", booleanAttribute], nzArrow: ["nzArrow", "nzArrow", booleanAttribute], nzOverlayClassName: "nzOverlayClassName", nzOverlayStyle: "nzOverlayStyle", nzPlacement: "nzPlacement" }, outputs: { nzVisibleChange: "nzVisibleChange" }, host: { classAttribute: "ant-dropdown-trigger" }, exportAs: ["nzDropdown"], usesOnChanges: true, ngImport: i0 });
};
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropDownDirective, decorators: [{
type: Directive,
args: [{
selector: '[nz-dropdown]',
exportAs: 'nzDropdown',
host: {
class: 'ant-dropdown-trigger'
}
}]
}], ctorParameters: () => [], propDecorators: { nzDropdownMenu: [{
type: Input
}], nzTrigger: [{
type: Input
}], nzMatchWidthElement: [{
type: Input
}], nzBackdrop: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzClickHide: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzDisabled: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzVisible: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzArrow: [{
type: Input,
args: [{ transform: booleanAttribute }]
}], nzOverlayClassName: [{
type: Input
}], nzOverlayStyle: [{
type: Input
}], nzPlacement: [{
type: Input
}], nzVisibleChange: [{
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 NzContextMenuServiceModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzContextMenuServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzContextMenuServiceModule });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzContextMenuServiceModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzContextMenuServiceModule, decorators: [{
type: NgModule
}] });
/**
* 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 NzDropDownADirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropDownADirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzDropDownADirective, isStandalone: true, selector: "a[nz-dropdown]", host: { classAttribute: "ant-dropdown-link" }, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropDownADirective, decorators: [{
type: Directive,
args: [{
selector: 'a[nz-dropdown]',
host: {
class: 'ant-dropdown-link'
}
}]
}] });
/**
* 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 Will be removed in v21, because it is not used anymore.
*/
class NzDropdownButtonDirective {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropdownButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: NzDropdownButtonDirective, isStandalone: true, selector: "[nz-button][nz-dropdown]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropdownButtonDirective, decorators: [{
type: Directive,
args: [{
selector: '[nz-button][nz-dropdown]'
}]
}] });
class NzDropdownMenuComponent {
cdr = inject(ChangeDetectorRef);
elementRef = inject(ElementRef);
renderer = inject(Renderer2);
viewContainerRef = inject(ViewContainerRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
mouseState$ = new BehaviorSubject(false);
nzMenuService = inject(MenuService);
isChildSubMenuOpen$ = this.nzMenuService.isChildSubMenuOpen$;
descendantMenuItemClick$ = this.nzMenuService.descendantMenuItemClick$;
animationStateChange$ = new EventEmitter();
nzOverlayClassName = '';
nzOverlayStyle = {};
nzArrow = false;
placement = 'bottomLeft';
templateRef;
dir = 'ltr';
onAnimationEvent(event) {
this.animationStateChange$.emit(event);
}
setMouseState(visible) {
this.mouseState$.next(visible);
}
setValue(key, value) {
this[key] = value;
this.cdr.markForCheck();
}
noAnimation = inject(NzNoAnimationDirective, { host: true, optional: true });
ngOnInit() {
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
}
ngAfterContentInit() {
this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement), this.elementRef.nativeElement);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropdownMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzDropdownMenuComponent, isStandalone: true, selector: "nz-dropdown-menu", providers: [
MenuService,
/** menu is inside dropdown-menu component **/
{
provide: NzIsMenuInsideDropDownToken,
useValue: true
}
], viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true, static: true }], exportAs: ["nzDropdownMenu"], ngImport: i0, template: `
<ng-template>
<div
class="ant-dropdown"
[class.ant-dropdown-rtl]="dir === 'rtl'"
[class.ant-dropdown-show-arrow]="nzArrow"
[class.ant-dropdown-placement-bottomLeft]="placement === 'bottomLeft'"
[class.ant-dropdown-placement-bottomRight]="placement === 'bottomRight'"
[class.ant-dropdown-placement-bottom]="placement === 'bottom'"
[class.ant-dropdown-placement-topLeft]="placement === 'topLeft'"
[class.ant-dropdown-placement-topRight]="placement === 'topRight'"
[class.ant-dropdown-placement-top]="placement === 'top'"
[class]="nzOverlayClassName"
[style]="nzOverlayStyle"
@slideMotion
(@slideMotion.done)="onAnimationEvent($event)"
[@.disabled]="!!noAnimation?.nzNoAnimation"
[nzNoAnimation]="noAnimation?.nzNoAnimation"
(mouseenter)="setMouseState(true)"
(mouseleave)="setMouseState(false)"
>
@if (nzArrow) {
<div class="ant-dropdown-arrow"></div>
}
<ng-content></ng-content>
</div>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: NzNoAnimationDirective, selector: "[nzNoAnimation]", inputs: ["nzNoAnimation"], exportAs: ["nzNoAnimation"] }], animations: [slideMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropdownMenuComponent, decorators: [{
type: Component,
args: [{
selector: `nz-dropdown-menu`,
exportAs: `nzDropdownMenu`,
animations: [slideMotion],
providers: [
MenuService,
/** menu is inside dropdown-menu component **/
{
provide: NzIsMenuInsideDropDownToken,
useValue: true
}
],
template: `
<ng-template>
<div
class="ant-dropdown"
[class.ant-dropdown-rtl]="dir === 'rtl'"
[class.ant-dropdown-show-arrow]="nzArrow"
[class.ant-dropdown-placement-bottomLeft]="placement === 'bottomLeft'"
[class.ant-dropdown-placement-bottomRight]="placement === 'bottomRight'"
[class.ant-dropdown-placement-bottom]="placement === 'bottom'"
[class.ant-dropdown-placement-topLeft]="placement === 'topLeft'"
[class.ant-dropdown-placement-topRight]="placement === 'topRight'"
[class.ant-dropdown-placement-top]="placement === 'top'"
[class]="nzOverlayClassName"
[style]="nzOverlayStyle"
@slideMotion
(@slideMotion.done)="onAnimationEvent($event)"
[@.disabled]="!!noAnimation?.nzNoAnimation"
[nzNoAnimation]="noAnimation?.nzNoAnimation"
(mouseenter)="setMouseState(true)"
(mouseleave)="setMouseState(false)"
>
@if (nzArrow) {
<div class="ant-dropdown-arrow"></div>
}
<ng-content></ng-content>
</div>
</ng-template>
`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NzNoAnimationDirective]
}]
}], propDecorators: { templateRef: [{
type: ViewChild,
args: [TemplateRef, { 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 NzDropDownModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropDownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: NzDropDownModule, imports: [NzDropDownDirective,
NzDropDownADirective,
NzDropdownMenuComponent,
NzDropdownButtonDirective,
NzContextMenuServiceModule], exports: [NzMenuModule, NzDropDownDirective, NzDropDownADirective, NzDropdownMenuComponent, NzDropdownButtonDirective] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropDownModule, imports: [NzContextMenuServiceModule, NzMenuModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzDropDownModule, decorators: [{
type: NgModule,
args: [{
imports: [
NzDropDownDirective,
NzDropDownADirective,
NzDropdownMenuComponent,
NzDropdownButtonDirective,
NzContextMenuServiceModule
],
exports: [NzMenuModule, NzDropDownDirective, NzDropDownADirective, NzDropdownMenuComponent, NzDropdownButtonDirective]
}]
}] });
/**
* 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 LIST_OF_POSITIONS = [
new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'top' }),
new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' }),
new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'end', overlayY: 'bottom' }),
new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'end', overlayY: 'top' })
];
class NzContextMenuService {
ngZone = inject(NgZone);
injector = inject(Injector);
overlayRef = null;
closeSubscription = Subscription.EMPTY;
create($event, nzDropdownMenuComponent) {
this.close(true);
const { x, y } = $event;
if ($event instanceof MouseEvent) {
$event.preventDefault();
}
this.overlayRef = createOverlayRef(this.injector, {
positionStrategy: createFlexibleConnectedPositionStrategy(this.injector, { x, y })
.withPositions(LIST_OF_POSITIONS)
.withTransformOriginOn('.ant-dropdown'),
disposeOnNavigation: true,
scrollStrategy: createCloseScrollStrategy(this.injector)
});
this.closeSubscription = new Subscription();
this.closeSubscription.add(nzDropdownMenuComponent.descendantMenuItemClick$.subscribe(() => this.close()));
this.closeSubscription.add(merge(fromEventOutsideAngular(document, 'click').pipe(filter(event => !!this.overlayRef && !this.overlayRef.overlayElement.contains(event.target)),
/** handle firefox contextmenu event **/
filter(event => event.button !== 2)), fromEventOutsideAngular(document, 'keydown').pipe(filter(event => event.key === 'Escape')))
.pipe(first())
.subscribe(() => this.ngZone.run(() => this.close())));
return this.overlayRef.attach(new TemplatePortal(nzDropdownMenuComponent.templateRef, nzDropdownMenuComponent.viewContainerRef));
}
close(clear = false) {
if (this.overlayRef) {
this.overlayRef.detach();
if (clear) {
this.overlayRef.dispose();
}
this.overlayRef = null;
this.closeSubscription.unsubscribe();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzContextMenuService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzContextMenuService, providedIn: NzContextMenuServiceModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzContextMenuService, decorators: [{
type: Injectable,
args: [{
providedIn: NzContextMenuServiceModule
}]
}] });
/**
* 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 { NzContextMenuService, NzContextMenuServiceModule, NzDropDownADirective, NzDropDownDirective, NzDropDownModule, NzDropdownButtonDirective, NzDropdownMenuComponent };
//# sourceMappingURL=ng-zorro-antd-dropdown.mjs.map
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More