Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync upstream #3

Merged
merged 29 commits into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
387ebc1
fix(module:auto-complete): close the panel when tapping scrollb… (#4551)
hsuanxyz Jan 17, 2020
f005565
chore: bump Angular to 9.0.0-rc.9 (#4700)
hsuanxyz Jan 18, 2020
5133c3f
chore: sync ant-design v4.0.0-rc.2 (#4716)
ng-zorro-bot Jan 23, 2020
cc10237
chore(module:menu): refactor menu
Jan 14, 2020
4c8032b
fix(module:menu): fix menu overflow detection & replace ul with div
Jan 27, 2020
51fbf5e
feat(module:menu): auto nzInlineCollapsed when sider collapsed
Jan 27, 2020
7560563
feat(module:menu): menu with nzMatchRouter work with CanDeactivate
Jan 28, 2020
49dd17c
test(module:menu): fix menu testing
Jan 28, 2020
9f951f8
fix(module:layout): fix responsive sider not work
Jan 29, 2020
d928a8c
fix(module:dropdown): fix menu group style in dropdown
Jan 29, 2020
39487f1
fix(module:dropdown): fix ghost menu with contextmenu
Feb 3, 2020
41c4860
feat(module:pagination): nzItemRender support prev_5 and next_5 (#4754)
Feb 6, 2020
9f6bd51
chore: bump to Angular 9.0.0 (#4756)
Feb 7, 2020
da8821a
perf(module:checkbox): use css empty selector instead of observeConte…
Feb 9, 2020
bfe089f
feat(module:input-number): support nzPrecisionMode mode (#4185)
renxia Feb 9, 2020
86f3fa2
chore: sync ant-design v4.0.0-rc.4 (#4762)
ng-zorro-bot Feb 9, 2020
7af643b
perf(module:input): improve input-group perf
Feb 10, 2020
0af9242
feat(module:input): support textarea with clear icon
Feb 10, 2020
b50e9c2
chore(module:statistic): refactor (#4722)
Feb 10, 2020
df8c125
feat(module:tree-select): support `nzDropdownClassName` property (#4552)
hsuanxyz Feb 11, 2020
299ba6d
feat(module:input-number): trigger ngModelChange at once (#4769)
Feb 11, 2020
423a382
perf(module:radio): refactor radio group data flow (#4770)
Feb 11, 2020
6dc85c8
chore(module:switch): refactor switch (#4771)
Feb 12, 2020
6d2a80e
chore(module:spin): refactor spin (#4772)
Feb 12, 2020
048902e
chore(module:empty): refactor (#4726)
Feb 12, 2020
7f1a76c
refactor(module:card): refactor card (#4778)
Feb 13, 2020
51eb8bd
refactor(module:divider): refactor divider (#4780)
Feb 13, 2020
4544e16
refactor(module:alert): refactor alert (#4779)
Feb 13, 2020
760512a
feat(module:collapse): support nzExpandIconPosition (#4781)
Feb 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.13.1
12.14.1
146 changes: 146 additions & 0 deletions components/alert/alert.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* 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
*/

import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
EventEmitter,
Input,
OnChanges,
OnDestroy,
Output,
SimpleChanges,
TemplateRef,
ViewEncapsulation
} from '@angular/core';
import { InputBoolean, NzConfigService, slideAlertMotion, WithConfig } from 'ng-zorro-antd/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

const NZ_CONFIG_COMPONENT_NAME = 'alert';

@Component({
selector: 'nz-alert',
exportAs: 'nzAlert',
animations: [slideAlertMotion],
template: `
<div
*ngIf="!closed"
class="ant-alert"
[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"
[@slideAlertMotion]
(@slideAlertMotion.done)="onFadeAnimationDone()"
>
<ng-container *ngIf="nzShowIcon">
<i nz-icon class="ant-alert-icon" [nzType]="nzIconType || inferredIconType" [nzTheme]="iconTheme"></i>
</ng-container>
<span class="ant-alert-message" *ngIf="nzMessage">
<ng-container *nzStringTemplateOutlet="nzMessage">{{ nzMessage }}</ng-container>
</span>
<span class="ant-alert-description" *ngIf="nzDescription">
<ng-container *nzStringTemplateOutlet="nzDescription">{{ nzDescription }}</ng-container>
</span>
<button type="button" tabindex="0" *ngIf="nzCloseable || nzCloseText" class="ant-alert-close-icon" (click)="closeAlert()">
<ng-template #closeDefaultTemplate>
<i nz-icon nzType="close"></i>
</ng-template>
<ng-container *ngIf="nzCloseText; else closeDefaultTemplate">
<ng-container *nzStringTemplateOutlet="nzCloseText">
<span class="ant-alert-close-text">{{ nzCloseText }}</span>
</ng-container>
</ng-container>
</button>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false
})
export class NzAlertComponent implements OnChanges, OnDestroy {
@Input() nzCloseText: string | TemplateRef<void> | null = null;
@Input() nzIconType: string | null = null;
@Input() nzMessage: string | TemplateRef<void> | null = null;
@Input() nzDescription: string | TemplateRef<void> | null = null;
@Input() nzType: 'success' | 'info' | 'warning' | 'error' = 'info';
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzCloseable: boolean;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, false) @InputBoolean() nzShowIcon: boolean;
@Input() @InputBoolean() nzBanner = false;
@Output() readonly nzOnClose = new EventEmitter<boolean>();
closed = false;
iconTheme: 'outline' | 'fill' = 'fill';
inferredIconType: string = 'info-circle';
private isTypeSet = false;
private isShowIconSet = false;
private destroy$ = new Subject();

constructor(public nzConfigService: NzConfigService, private cdr: ChangeDetectorRef) {
this.nzConfigService
.getConfigChangeEventForComponent(NZ_CONFIG_COMPONENT_NAME)
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.cdr.markForCheck();
});
}

closeAlert(): void {
this.closed = true;
}

onFadeAnimationDone(): void {
if (this.closed) {
this.nzOnClose.emit(true);
}
}

ngOnChanges(changes: SimpleChanges): void {
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;
}
}
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { NzAddOnModule } from 'ng-zorro-antd/core';
import { NzOutletModule } from 'ng-zorro-antd/core';
import { NzIconModule } from 'ng-zorro-antd/icon';

import { NzAlertComponent } from './nz-alert.component';
import { NzAlertComponent } from './alert.component';

@NgModule({
declarations: [NzAlertComponent],
exports: [NzAlertComponent],
imports: [CommonModule, NzIconModule, NzAddOnModule]
imports: [CommonModule, NzIconModule, NzOutletModule]
})
export class NzAlertModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { Component, DebugElement, TemplateRef, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { NzIconTestModule } from 'ng-zorro-antd/icon/testing';

import { NzAlertComponent } from './nz-alert.component';
import { NzAlertModule } from './nz-alert.module';
import { NzAlertComponent } from './alert.component';
import { NzAlertModule } from './alert.module';

describe('alert', () => {
beforeEach(fakeAsync(() => {
Expand Down
2 changes: 1 addition & 1 deletion components/alert/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ import { NzAlertModule } from 'ng-zorro-antd/alert';
| `[nzDescription]` | Additional content of Alert | `string \| TemplateRef<void>` | - |
| `[nzMessage]` | Content of Alert | `string \| TemplateRef<void>` | - |
| `[nzShowIcon]` | Whether to show icon, in `nzBanner` mode default is `true` | `boolean` | `false` | ✅ |
| `[nzIconType]` | Icon type, effective when `nzShowIcon` is `true` | `string \| string[] \| Set<string> \| { [klass: string]: any; }` | - |
| `[nzIconType]` | Icon type, effective when `nzShowIcon` is `true` | `string` | - |
| `[nzType]` | Type of Alert styles, in `nzBanner` mode default is `'warning'` | `'success' \| 'info' \| 'warning' \| 'error'` | `'info'` |
| `(nzOnClose)` | Callback when Alert is closed | `EventEmitter<void>` | - |
2 changes: 1 addition & 1 deletion components/alert/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ import { NzAlertModule } from 'ng-zorro-antd/alert';
| `[nzDescription]` | 警告提示的辅助性文字介绍 | `string \| TemplateRef<void>` | - |
| `[nzMessage]` | 警告提示内容 | `string \| TemplateRef<void>` | - |
| `[nzShowIcon]` | 是否显示辅助图标,`nzBanner` 模式下默认值为 `true` | `boolean` | `false` | ✅ |
| `[nzIconType]` | 自定义图标类型,`nzShowIcon` 为 `true` 时有效 | `string \| string[] \| Set<string> \| { [klass: string]: any; }` | - |
| `[nzIconType]` | 自定义图标类型,`nzShowIcon` 为 `true` 时有效 | `string` | - |
| `[nzType]` | 指定警告提示的样式,`nzBanner` 模式下默认值为 `'warning'` | `'success' \| 'info' \| 'warning' \| 'error'` | `'info'` |
| `(nzOnClose)` | 关闭时触发的回调函数 | `EventEmitter<void>` | - |
39 changes: 0 additions & 39 deletions components/alert/nz-alert.component.html

This file was deleted.

121 changes: 0 additions & 121 deletions components/alert/nz-alert.component.ts

This file was deleted.

4 changes: 2 additions & 2 deletions components/alert/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export * from './nz-alert.component';
export * from './nz-alert.module';
export * from './alert.component';
export * from './alert.module';
1 change: 1 addition & 0 deletions components/alert/style/entry.less
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import './index.less';
@import './patch.less';
3 changes: 3 additions & 0 deletions components/alert/style/patch.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nz-alert {
display: block;
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnD
}

handleBlur(): void {
this.closePanel();
this._onTouched();
}

Expand Down
Loading