Skip to content
Permalink
Browse files

feat(module:*): support global config (#3613)

* feat(module:*): global config

* feat(module:*): global config

* fix: lint

* fix: lint

* fix: rebase error

* fix: make some properties not configurable

* fix: tslint

* docs: fix version

* fix: progress component
  • Loading branch information...
wendzhue authored and hsuanxyz committed Sep 9, 2019
1 parent cc9a0c5 commit 6eb041a9b1df597e58fb7cfb7d324e4dd40623b0
Showing with 1,719 additions and 672 deletions.
  1. +4 −4 components/affix/doc/index.en-US.md
  2. +4 −4 components/affix/doc/index.zh-CN.md
  3. +39 −5 components/affix/nz-affix.component.ts
  4. +4 −4 components/alert/doc/index.en-US.md
  5. +4 −4 components/alert/doc/index.zh-CN.md
  6. +5 −3 components/alert/nz-alert.component.ts
  7. +5 −5 components/anchor/doc/index.en-US.md
  8. +5 −5 components/anchor/doc/index.zh-CN.md
  9. +13 −3 components/anchor/nz-anchor.component.ts
  10. +4 −4 components/avatar/doc/index.en-US.md
  11. +4 −4 components/avatar/doc/index.zh-CN.md
  12. +11 −10 components/avatar/nz-avatar.component.ts
  13. +3 −3 components/back-top/doc/index.en-US.md
  14. +3 −3 components/back-top/doc/index.zh-CN.md
  15. +3 −12 components/back-top/nz-back-top.component.ts
  16. +4 −4 components/badge/doc/index.en-US.md
  17. +4 −4 components/badge/doc/index.zh-CN.md
  18. +5 −4 components/badge/nz-badge.component.ts
  19. +5 −5 components/button/doc/index.en-US.md
  20. +5 −5 components/button/doc/index.zh-CN.md
  21. +24 −10 components/button/nz-button.component.ts
  22. +9 −9 components/card/doc/index.en-US.md
  23. +8 −8 components/card/doc/index.zh-CN.md
  24. +5 −5 components/card/nz-card.component.ts
  25. +10 −10 components/carousel/doc/index.en-US.md
  26. +10 −10 components/carousel/doc/index.zh-CN.md
  27. +1 −1 components/carousel/nz-carousel-definitions.ts
  28. +18 −8 components/carousel/nz-carousel.component.ts
  29. +6 −6 components/cascader/doc/index.en-US.md
  30. +6 −6 components/cascader/doc/index.zh-CN.md
  31. +13 −2 components/cascader/nz-cascader.component.ts
  32. +5 −5 components/collapse/doc/index.en-US.md
  33. +5 −5 components/collapse/doc/index.zh-CN.md
  34. +3 −2 components/collapse/nz-collapse-panel.component.ts
  35. +5 −3 components/collapse/nz-collapse.component.ts
  36. +115 −0 components/core/config/config.service.ts
  37. +128 −0 components/core/config/config.spec.ts
  38. +242 −0 components/core/config/config.ts
  39. +9 −0 components/core/config/index.ts
  40. +10 −0 components/core/config/public-api.ts
  41. +1 −0 components/core/public-api.ts
  42. +4 −2 components/core/responsive/{break-point.ts → nz-breakpoint.ts}
  43. +1 −1 components/core/responsive/public-api.ts
  44. +3 −0 components/core/types/direction.ts
  45. +1 −0 components/core/types/public-api.ts
  46. +9 −0 components/core/types/shape.ts
  47. +1 −0 components/core/types/size.ts
  48. +13 −11 components/core/util/convert.ts
  49. +2 −4 components/date-picker/lib/calendar/calendar-input.component.html
  50. +1 −1 components/date-picker/picker.component.html
  51. +6 −6 components/descriptions/doc/index.en-US.md
  52. +6 −6 components/descriptions/doc/index.zh-CN.md
  53. +18 −9 components/descriptions/nz-descriptions.component.ts
  54. +5 −5 components/drawer/doc/index.en-US.md
  55. +6 −6 components/drawer/doc/index.zh-CN.md
  56. +1 −1 components/drawer/nz-drawer.component.html
  57. +5 −4 components/drawer/nz-drawer.component.ts
  58. +4 −4 components/empty/demo/config.ts
  59. +14 −1 components/empty/demo/module
  60. +7 −6 components/empty/doc/index.en-US.md
  61. +8 −8 components/empty/doc/index.zh-CN.md
  62. +33 −4 components/empty/nz-empty.service.ts
  63. +3 −3 components/form/doc/index.en-US.md
  64. +3 −3 components/form/doc/index.zh-CN.md
  65. +3 −2 components/form/nz-form.directive.ts
  66. +6 −6 components/grid/doc/index.en-US.md
  67. +6 −6 components/grid/doc/index.zh-CN.md
  68. +7 −7 components/grid/nz-row.directive.ts
  69. +18 −22 components/icon/doc/index.en-US.md
  70. +24 −30 components/icon/doc/index.zh-CN.md
  71. +29 −2 components/icon/nz-icon.directive.ts
  72. +55 −9 components/icon/nz-icon.service.ts
  73. +45 −1 components/icon/nz-icon.spec.ts
  74. +1 −1 components/icon/page/index.ts
  75. +1 −1 components/input-number/nz-input-number.component.html
  76. +1 −3 components/layout/nz-sider.component.ts
  77. +1 −1 components/menu/nz-submenu.component.html
  78. +2 −2 components/message/nz-message-base.service.ts
  79. +9 −5 components/message/nz-message-config.ts
  80. +33 −8 components/message/nz-message-container.component.ts
  81. +2 −2 components/message/nz-message.service.ts
  82. +18 −2 components/message/nz-message.spec.ts
  83. +4 −28 components/modal/doc/index.en-US.md
  84. +6 −29 components/modal/doc/index.zh-CN.md
  85. +18 −3 components/modal/nz-modal.component.ts
  86. +7 −4 components/notification/nz-notification-config.ts
  87. +31 −8 components/notification/nz-notification-container.component.ts
  88. +1 −1 components/notification/nz-notification.component.html
  89. +2 −2 components/notification/nz-notification.service.ts
  90. +2 −2 components/progress/demo/round.ts
  91. +7 −7 components/progress/doc/index.en-US.md
  92. +7 −7 components/progress/doc/index.zh-CN.md
  93. +59 −15 components/progress/nz-progress.component.ts
  94. +4 −4 components/rate/doc/index.en-US.md
  95. +4 −4 components/rate/doc/index.zh-CN.md
  96. +19 −5 components/rate/nz-rate.component.ts
  97. +3 −3 components/switch/doc/index.en-US.md
  98. +3 −3 components/switch/doc/index.zh-CN.md
  99. +1 −1 components/switch/nz-switch.component.html
  100. +7 −3 components/switch/nz-switch.component.ts
  101. +8 −8 components/table/doc/index.en-US.md
  102. +8 −8 components/table/doc/index.zh-CN.md
  103. +15 −7 components/table/nz-table.component.ts
  104. +9 −9 components/tabs/doc/index.en-US.md
  105. +9 −9 components/tabs/doc/index.zh-CN.md
  106. +17 −7 components/tabs/nz-tabset.component.ts
  107. +10 −10 components/time-picker/doc/index.en-US.md
  108. +10 −10 components/time-picker/doc/index.zh-CN.md
  109. +17 −9 components/time-picker/nz-time-picker.component.ts
  110. +2 −2 components/timeline/doc/index.en-US.md
  111. +1 −1 components/transfer/nz-transfer.component.html
  112. +8 −8 components/tree-select/doc/index.en-US.md
  113. +8 −8 components/tree-select/doc/index.zh-CN.md
  114. +13 −10 components/tree-select/nz-tree-select.component.ts
  115. +8 −8 components/tree/doc/index.en-US.md
  116. +10 −10 components/tree/doc/index.zh-CN.md
  117. +9 −6 components/tree/nz-tree.component.ts
  118. +13 −13 components/typography/doc/index.en-US.md
  119. +3 −3 components/typography/doc/index.zh-CN.md
  120. +6 −2 components/typography/nz-typography.component.ts
  121. +2 −2 docs/animations.en-US.md
  122. +2 −2 docs/animations.zh-CN.md
  123. +1 −1 docs/changelog.en-US.md
  124. +1 −1 docs/changelog.zh-CN.md
  125. +1 −1 docs/contributing.en-US.md
  126. +1 −1 docs/contributing.zh-CN.md
  127. +1 −1 docs/faq.en-US.md
  128. +1 −1 docs/faq.zh-CN.md
  129. +75 −0 docs/global-config.en-US.md
  130. +78 −0 docs/global-config.zh-CN.md
  131. +1 −1 docs/recommendation.en-US.md
  132. +1 −1 docs/recommendation.zh-CN.md
  133. +1 −1 scripts/site/_site/doc/app/app.component.html
  134. +2 −2 scripts/site/_site/doc/app/app.module.ts
@@ -24,10 +24,10 @@ import { NzAffixModule } from 'ng-zorro-antd/affix';


### nz-affix ### nz-affix


| Property | Description | Type | Default | | Property | Description | Type | Default | Global Config |
| -------- | ----------- | ---- | ------- | | -------- | ----------- | ---- | ------- | ------------- |
| `[nzOffsetBottom]` | Pixels to offset from bottom when calculating position of scroll | `number` | - | | `[nzOffsetBottom]` | Pixels to offset from bottom when calculating position of scroll | `number` | - | ✅ |
| `[nzOffsetTop]` | Pixels to offset from top when calculating position of scroll | `number` | `0` | | `[nzOffsetTop]` | Pixels to offset from top when calculating position of scroll | `number` | `0` | ✅ |
| `[nzTarget]` | specifies the scrollable area dom node | `string \| HTMLElement` | `window` | | `[nzTarget]` | specifies the scrollable area dom node | `string \| HTMLElement` | `window` |
| `(nzChange)` | Callback for when affix state is changed | `EventEmitter<boolean>` | - | | `(nzChange)` | Callback for when affix state is changed | `EventEmitter<boolean>` | - |


@@ -26,10 +26,10 @@ import { NzAffixModule } from 'ng-zorro-antd/affix';


### nz-affix ### nz-affix


| 成员 | 说明 | 类型 | 默认值 | | 成员 | 说明 | 类型 | 默认值 | 全局配置 |
| --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| `[nzOffsetBottom]` | 距离窗口底部达到指定偏移量后触发 | `number` | - | | `[nzOffsetBottom]` | 距离窗口底部达到指定偏移量后触发 | `number` | - | ✅ |
| `[nzOffsetTop]` | 距离窗口顶部达到指定偏移量后触发 | `number` | `0` | | `[nzOffsetTop]` | 距离窗口顶部达到指定偏移量后触发 | `number` | `0` | ✅ |
| `[nzTarget]` | 设置 `nz-affix` 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | `string \| HTMLElement` | `window` | | `[nzTarget]` | 设置 `nz-affix` 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | `string \| HTMLElement` | `window` |
| `(nzChange)` | 固定状态改变时触发的回调函数 | `EventEmitter<boolean>` | - | | `(nzChange)` | 固定状态改变时触发的回调函数 | `EventEmitter<boolean>` | - |


@@ -24,10 +24,18 @@ import {
ViewChild, ViewChild,
ViewEncapsulation ViewEncapsulation
} from '@angular/core'; } from '@angular/core';
import { shallowEqual, toNumber, NgStyleInterface, NzScrollService } from 'ng-zorro-antd/core';
import { fromEvent, merge, Subscription } from 'rxjs'; import { fromEvent, merge, Subscription } from 'rxjs';
import { auditTime } from 'rxjs/operators'; import { auditTime } from 'rxjs/operators';


import {
shallowEqual,
toNumber,
NgStyleInterface,
NzConfigService,
NzScrollService,
WithConfig
} from 'ng-zorro-antd/core';

export const NZ_AFFIX_DEFAULT_SCROLL_TIME = 20; export const NZ_AFFIX_DEFAULT_SCROLL_TIME = 20;


@Component({ @Component({
@@ -46,8 +54,35 @@ export const NZ_AFFIX_DEFAULT_SCROLL_TIME = 20;
}) })
export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy { export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy {
@Input() nzTarget: string | Element | Window; @Input() nzTarget: string | Element | Window;
@Input() nzOffsetTop: number | null;
@Input() nzOffsetBottom: number | null; @Input()
@WithConfig<number | null>()
set nzOffsetTop(value: number | null) {
if (value === undefined || value === null) {
return;
}
this._offsetTop = toNumber(value, null);
this.updatePosition({} as Event);
}

get nzOffsetTop(): number | null {
return this._offsetTop;
}

private _offsetTop: number | null;

@Input()
@WithConfig<number>()
set nzOffsetBottom(value: number) {
if (typeof value === 'undefined') {
return;
}
this._offsetBottom = toNumber(value, null);
this.updatePosition({} as Event);
}

private _offsetBottom: number | null;

@Output() readonly nzChange = new EventEmitter<boolean>(); @Output() readonly nzChange = new EventEmitter<boolean>();
@ViewChild('fixedEl', { static: true }) private fixedEl: ElementRef<HTMLDivElement>; @ViewChild('fixedEl', { static: true }) private fixedEl: ElementRef<HTMLDivElement>;


@@ -57,8 +92,6 @@ export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy {
private readonly placeholderNode: HTMLElement; private readonly placeholderNode: HTMLElement;
private affixStyle: NgStyleInterface | undefined; private affixStyle: NgStyleInterface | undefined;
private placeholderStyle: NgStyleInterface | undefined; private placeholderStyle: NgStyleInterface | undefined;
private _offsetTop: number | null;
private _offsetBottom: number | null;


private get target(): Element | Window { private get target(): Element | Window {
const el = this.nzTarget; const el = this.nzTarget;
@@ -67,6 +100,7 @@ export class NzAffixComponent implements AfterViewInit, OnChanges, OnDestroy {


constructor( constructor(
_el: ElementRef, _el: ElementRef,
public nzConfigService: NzConfigService,
private scrollSrv: NzScrollService, private scrollSrv: NzScrollService,
// tslint:disable-next-line:no-any // tslint:disable-next-line:no-any
@Inject(DOCUMENT) private doc: any, @Inject(DOCUMENT) private doc: any,
@@ -23,14 +23,14 @@ import { NzAlertModule } from 'ng-zorro-antd/alert';


### nz-alert ### nz-alert


| Property | Description | Type | Default | | Property | Description | Type | Default | Global Config |
| -------- | ----------- | ---- | ------- | | -------- | ----------- | ---- | ------- | ------------- |
| `[nzBanner]` | Whether to show as banner | `boolean` | `false` | | `[nzBanner]` | Whether to show as banner | `boolean` | `false` |
| `[nzCloseable]` | Whether Alert can be closed | `boolean` | - | | `[nzCloseable]` | Whether Alert can be closed | `boolean` | - | ✅ |
| `[nzCloseText]` | Close text to show | `string \| TemplateRef<void>` | - | | `[nzCloseText]` | Close text to show | `string \| TemplateRef<void>` | - |
| `[nzDescription]` | Additional content of Alert | `string \| TemplateRef<void>` | - | | `[nzDescription]` | Additional content of Alert | `string \| TemplateRef<void>` | - |
| `[nzMessage]` | 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` | | `[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 \| string[] \| Set<string> \| { [klass: string]: any; }` | - |
| `[nzType]` | Type of Alert styles, in `nzBanner` mode default is `'warning'` | `'success' \| 'info' \| 'warning' \| 'error'` | `'info'` | | `[nzType]` | Type of Alert styles, in `nzBanner` mode default is `'warning'` | `'success' \| 'info' \| 'warning' \| 'error'` | `'info'` |
| `(nzOnClose)` | Callback when Alert is closed | `EventEmitter<void>` | - | | `(nzOnClose)` | Callback when Alert is closed | `EventEmitter<void>` | - |
@@ -24,14 +24,14 @@ import { NzAlertModule } from 'ng-zorro-antd/alert';


### nz-alert ### nz-alert


| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 | 全局配置 |
| --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| `[nzBanner]` | 是否用作顶部公告 | `boolean` | `false` | | `[nzBanner]` | 是否用作顶部公告 | `boolean` | `false` |
| `[nzCloseable]` | 默认不显示关闭按钮 | `boolean` | - | | `[nzCloseable]` | 默认不显示关闭按钮 | `boolean` | - | ✅ |
| `[nzCloseText]` | 自定义关闭按钮 | `string \| TemplateRef<void>` | - | | `[nzCloseText]` | 自定义关闭按钮 | `string \| TemplateRef<void>` | - |
| `[nzDescription]` | 警告提示的辅助性文字介绍 | `string \| TemplateRef<void>` | - | | `[nzDescription]` | 警告提示的辅助性文字介绍 | `string \| TemplateRef<void>` | - |
| `[nzMessage]` | 警告提示内容 | `string \| TemplateRef<void>` | - | | `[nzMessage]` | 警告提示内容 | `string \| TemplateRef<void>` | - |
| `[nzShowIcon]` | 是否显示辅助图标,`nzBanner` 模式下默认值为 `true` | `boolean` | `false` | | `[nzShowIcon]` | 是否显示辅助图标,`nzBanner` 模式下默认值为 `true` | `boolean` | `false` | ✅ |
| `[nzIconType]` | 自定义图标类型,`nzShowIcon` 为 `true` 时有效 | `string \| string[] \| Set<string> \| { [klass: string]: any; }` | - | | `[nzIconType]` | 自定义图标类型,`nzShowIcon` 为 `true` 时有效 | `string \| string[] \| Set<string> \| { [klass: string]: any; }` | - |
| `[nzType]` | 指定警告提示的样式,`nzBanner` 模式下默认值为 `'warning'` | `'success' \| 'info' \| 'warning' \| 'error'` | `'info'` | | `[nzType]` | 指定警告提示的样式,`nzBanner` 模式下默认值为 `'warning'` | `'success' \| 'info' \| 'warning' \| 'error'` | `'info'` |
| `(nzOnClose)` | 关闭时触发的回调函数 | `EventEmitter<void>` | - | | `(nzOnClose)` | 关闭时触发的回调函数 | `EventEmitter<void>` | - |
@@ -17,7 +17,7 @@ import {
TemplateRef, TemplateRef,
ViewEncapsulation ViewEncapsulation
} from '@angular/core'; } from '@angular/core';
import { slideAlertMotion, InputBoolean, NgClassType } from 'ng-zorro-antd/core'; import { slideAlertMotion, InputBoolean, NgClassType, NzConfigService, WithConfig } from 'ng-zorro-antd/core';


@Component({ @Component({
selector: 'nz-alert', selector: 'nz-alert',
@@ -41,8 +41,8 @@ export class NzAlertComponent implements OnChanges {
@Input() nzMessage: string | TemplateRef<void>; @Input() nzMessage: string | TemplateRef<void>;
@Input() nzDescription: string | TemplateRef<void>; @Input() nzDescription: string | TemplateRef<void>;
@Input() nzType: 'success' | 'info' | 'warning' | 'error' = 'info'; @Input() nzType: 'success' | 'info' | 'warning' | 'error' = 'info';
@Input() @InputBoolean() nzCloseable = false; @Input() @WithConfig(false) @InputBoolean() nzCloseable: boolean;
@Input() @InputBoolean() nzShowIcon = false; @Input() @WithConfig(false) @InputBoolean() nzShowIcon: boolean;
@Input() @InputBoolean() nzBanner = false; @Input() @InputBoolean() nzBanner = false;
@Output() readonly nzOnClose = new EventEmitter<boolean>(); @Output() readonly nzOnClose = new EventEmitter<boolean>();


@@ -58,6 +58,8 @@ export class NzAlertComponent implements OnChanges {
private isShowIconSet = false; private isShowIconSet = false;
private inferredIconType: string = 'info-circle'; private inferredIconType: string = 'info-circle';


constructor(public nzConfigService: NzConfigService) {}

closeAlert(): void { closeAlert(): void {
this.destroy = true; this.destroy = true;
} }
@@ -22,12 +22,12 @@ import { NzAnchorModule } from 'ng-zorro-antd/anchor';


### nz-anchor ### nz-anchor


| Property | Description | Type | Default | | Property | Description | Type | Default | Global Config |
| -------- | ----------- | ---- | ------- | | -------- | ----------- | ---- | ------- | ------------- |
| `[nzAffix]` | Fixed mode of Anchor | `boolean` | `true` | | `[nzAffix]` | Fixed mode of Anchor | `boolean` | `true` |
| `[nzBounds]` | Bounding distance of anchor area, unit: px | `number` | `5` | | `[nzBounds]` | Bounding distance of anchor area, unit: px | `number` | `5` | ✅ |
| `[nzOffsetTop]` | Pixels to offset from top when calculating position of scroll | `number` | `0` | | `[nzOffsetTop]` | Pixels to offset from top when calculating position of scroll | `number` | `0` | ✅ |
| `[nzShowInkInFixed]` | Whether show ink-balls in Fixed mode | `boolean` | `false` | | `[nzShowInkInFixed]` | Whether show ink-balls in Fixed mode | `boolean` | `false` | ✅ |
| `[nzTarget]` | Scrolling container | `string \| HTMLElement` | `window` | | `[nzTarget]` | Scrolling container | `string \| HTMLElement` | `window` |
| `(nzClick)` | Click of Anchor item | `EventEmitter<string>` | - | | `(nzClick)` | Click of Anchor item | `EventEmitter<string>` | - |
| `(nzScroll)` | The scroll function that is triggered when scrolling to an anchor. | `EventEmitter<NzAnchorLinkComponent>` | - | | `(nzScroll)` | The scroll function that is triggered when scrolling to an anchor. | `EventEmitter<NzAnchorLinkComponent>` | - |
@@ -24,12 +24,12 @@ import { NzAnchorModule } from 'ng-zorro-antd/anchor';


### nz-anchor ### nz-anchor


| 成员 | 说明 | 类型 | 默认值 | | 成员 | 说明 | 类型 | 默认值 | 全局配置 |
| --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| `[nzAffix]` | 固定模式 | `boolean` | `true` | | `[nzAffix]` | 固定模式 | `boolean` | `true` |
| `[nzBounds]` | 锚点区域边界,单位:px | `number` | `5` | | `[nzBounds]` | 锚点区域边界,单位:px | `number` | `5` | ✅ |
| `[nzOffsetTop]` | 距离窗口顶部达到指定偏移量后触发 | `number` | - | | `[nzOffsetTop]` | 距离窗口顶部达到指定偏移量后触发 | `number` | - | ✅ |
| `[nzShowInkInFixed]` | 固定模式是否显示小圆点 | `boolean` | `false` | | `[nzShowInkInFixed]` | 固定模式是否显示小圆点 | `boolean` | `false` | ✅ |
| `[nzTarget]` | 指定滚动的容器 | `string \| HTMLElement` | `window` | | `[nzTarget]` | 指定滚动的容器 | `string \| HTMLElement` | `window` |
| `(nzClick)` | 点击项触发 | `EventEmitter<string>` | - | | `(nzClick)` | 点击项触发 | `EventEmitter<string>` | - |
| `(nzScroll)` | 滚动至某锚点时触发 | `EventEmitter<NzAnchorLinkComponent>` | - | | `(nzScroll)` | 滚动至某锚点时触发 | `EventEmitter<NzAnchorLinkComponent>` | - |
@@ -25,7 +25,15 @@ import {
import { fromEvent, Subscription } from 'rxjs'; import { fromEvent, Subscription } from 'rxjs';
import { distinctUntilChanged, throttleTime } from 'rxjs/operators'; import { distinctUntilChanged, throttleTime } from 'rxjs/operators';


import { toNumber, InputBoolean, InputNumber, NgStyleInterface, NzScrollService } from 'ng-zorro-antd/core'; import {
toNumber,
InputBoolean,
InputNumber,
NgStyleInterface,
NzConfigService,
NzScrollService,
WithConfig
} from 'ng-zorro-antd/core';


import { NzAnchorLinkComponent } from './nz-anchor-link.component'; import { NzAnchorLinkComponent } from './nz-anchor-link.component';


@@ -48,10 +56,11 @@ export class NzAnchorComponent implements OnDestroy, AfterViewInit {
@ViewChild('ink', { static: false }) private ink: ElementRef; @ViewChild('ink', { static: false }) private ink: ElementRef;


@Input() @InputBoolean() nzAffix = true; @Input() @InputBoolean() nzAffix = true;
@Input() @InputBoolean() nzShowInkInFixed = false; @Input() @WithConfig(false) @InputBoolean() nzShowInkInFixed: boolean;
@Input() @InputNumber() nzBounds: number = 5; @Input() @WithConfig(5) @InputNumber() nzBounds: number;


@Input() @Input()
@WithConfig<number>()
set nzOffsetTop(value: number) { set nzOffsetTop(value: number) {
this._offsetTop = toNumber(value, 0); this._offsetTop = toNumber(value, 0);
this.wrapperStyle = { this.wrapperStyle = {
@@ -84,6 +93,7 @@ export class NzAnchorComponent implements OnDestroy, AfterViewInit {
private destroyed = false; private destroyed = false;


constructor( constructor(
public nzConfigService: NzConfigService,
private scrollSrv: NzScrollService, private scrollSrv: NzScrollService,
/* tslint:disable-next-line:no-any */ /* tslint:disable-next-line:no-any */
@Inject(DOCUMENT) private doc: any, @Inject(DOCUMENT) private doc: any,
@@ -18,11 +18,11 @@ import { NzAvatarModule } from 'ng-zorro-antd/avatar';


### nz-avatar ### nz-avatar


| Property | Description | Type | Default | | Property | Description | Type | Default | Global Config |
| -------- | ----------- | ---- | ------- | | -------- | ----------- | ---- | ------- | ------------- |
| `[nzIcon]` | the `Icon` type for an icon avatar, see `Icon` | `string` | - | | `[nzIcon]` | the `Icon` type for an icon avatar, see `Icon` | `string` | - |
| `[nzShape]` | the shape of avatar | `'circle' \| 'square'` | `'circle'` | | `[nzShape]` | the shape of avatar | `'circle' \| 'square'` | `'circle'` | ✅ |
| `[nzSize]` | the size of the avatar | `'large' \| 'small' \| 'default' \| number` | `'default'` | | `[nzSize]` | the size of the avatar | `'large' \| 'small' \| 'default' \| number` | `'default'` | ✅ |
| `[nzSrc]` | the address of the image for an image avatar | `string` | - | | `[nzSrc]` | the address of the image for an image avatar | `string` | - |
| `[nzSrcSet]` | a list of sources to use for different screen resolutions | string | - | | `[nzSrcSet]` | a list of sources to use for different screen resolutions | string | - |
| `[nzAlt]` | This attribute defines the alternative text describing the image | string | - | | `[nzAlt]` | This attribute defines the alternative text describing the image | string | - |
@@ -19,11 +19,11 @@ import { NzAvatarModule } from 'ng-zorro-antd/avatar';


### nz-avatar ### nz-avatar


| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 | 全局配置 |
| --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| `[nzIcon]` | 设置头像的图标类型,参考 `Icon` | `string` | - | | `[nzIcon]` | 设置头像的图标类型,参考 `Icon` | `string` | - |
| `[nzShape]` | 指定头像的形状 | `'circle' \| 'square'` | `'circle'` | | `[nzShape]` | 指定头像的形状 | `'circle' \| 'square'` | `'circle'` | ✅ |
| `[nzSize]` | 设置头像的大小 | `'large' \| 'small' \| 'default' \| number` | `'default'` | | `[nzSize]` | 设置头像的大小 | `'large' \| 'small' \| 'default' \| number` | `'default'` | ✅ |
| `[nzSrc]` | 图片类头像的资源地址 | `string` | - | | `[nzSrc]` | 图片类头像的资源地址 | `string` | - |
| `[nzSrcSet]` | 设置图片类头像响应式资源地址 | string | - | | `[nzSrcSet]` | 设置图片类头像响应式资源地址 | string | - |
| `[nzAlt]` | 图像无法显示时的替代文本 | string | - | | `[nzAlt]` | 图像无法显示时的替代文本 | string | - |
@@ -22,14 +22,14 @@ import {
ViewEncapsulation ViewEncapsulation
} from '@angular/core'; } from '@angular/core';


import { NzSizeLDSType, NzSizeMap, NzUpdateHostClassService } from 'ng-zorro-antd/core'; import {

NzConfigService,
export type NzAvatarShape = 'square' | 'circle'; NzShapeSCType,
export type NzAvatarSize = NzSizeLDSType | number; NzSizeLDSType,

NzSizeMap,
export interface NzAvatarSizeMap { NzUpdateHostClassService,
[size: string]: string; WithConfig
} } from 'ng-zorro-antd/core';


@Component({ @Component({
selector: 'nz-avatar', selector: 'nz-avatar',
@@ -41,8 +41,8 @@ export interface NzAvatarSizeMap {
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class NzAvatarComponent implements OnChanges { export class NzAvatarComponent implements OnChanges {
@Input() nzShape: NzAvatarShape = 'circle'; @Input() @WithConfig('circle') nzShape: NzShapeSCType;
@Input() nzSize: NzAvatarSize = 'default'; @Input() @WithConfig('default') nzSize: NzSizeLDSType | number;
@Input() nzText: string; @Input() nzText: string;
@Input() nzSrc: string; @Input() nzSrc: string;
@Input() nzSrcSet: string; @Input() nzSrcSet: string;
@@ -63,6 +63,7 @@ export class NzAvatarComponent implements OnChanges {
private sizeMap: NzSizeMap = { large: 'lg', small: 'sm' }; private sizeMap: NzSizeMap = { large: 'lg', small: 'sm' };


constructor( constructor(
public nzConfigService: NzConfigService,
private elementRef: ElementRef, private elementRef: ElementRef,
private cd: ChangeDetectorRef, private cd: ChangeDetectorRef,
private updateHostClassService: NzUpdateHostClassService, private updateHostClassService: NzUpdateHostClassService,
@@ -26,10 +26,10 @@ import { NzBackTopModule } from 'ng-zorro-antd/back-top';
> The distance to the bottom is set to `50px` by default, which is overridable. > The distance to the bottom is set to `50px` by default, which is overridable.
> If you decide to use custom styles, please note the size limit: no more than `40px * 40px`. > If you decide to use custom styles, please note the size limit: no more than `40px * 40px`.
| Property | Description | Type | Default | | Property | Description | Type | Default | Global Config |
| --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| `[nzTemplate]` | custom content | `TemplateRef<void>` | - | | `[nzTemplate]` | custom content | `TemplateRef<void>` | - |
| `[nzVisibilityHeight]` | the `nz-back-top` button will not show until the scroll height reaches this value | `number` | `400` | | `[nzVisibilityHeight]` | the `nz-back-top` button will not show until the scroll height reaches this value | `number` | `400` | ✅ |
| `[nzTarget]` | specifies the scrollable area dom node | `string \| Element` | `window` | | `[nzTarget]` | specifies the scrollable area dom node | `string \| Element` | `window` |
| `(nzClick)` | a callback function, which can be executed when you click the button | `EventEmitter<boolean>` | - | | `(nzClick)` | a callback function, which can be executed when you click the button | `EventEmitter<boolean>` | - |


@@ -27,9 +27,9 @@ import { NzBackTopModule } from 'ng-zorro-antd/back-top';
> 有默认样式,距离底部 `50px`,可覆盖。 > 有默认样式,距离底部 `50px`,可覆盖。
> 自定义样式宽高不大于 `40px * 40px`。 > 自定义样式宽高不大于 `40px * 40px`。
| 成员 | 说明 | 类型 | 默认值 | | 成员 | 说明 | 类型 | 默认值 | 全局配置 |
| --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| `[nzTemplate]` | 自定义内容,见示例 | `TemplateRef<void>` | - | | `[nzTemplate]` | 自定义内容,见示例 | `TemplateRef<void>` | - |
| `[nzVisibilityHeight]` | 滚动高度达到此参数值才出现 `nz-back-top` | `number` | `400` | | `[nzVisibilityHeight]` | 滚动高度达到此参数值才出现 `nz-back-top` | `number` | `400` | ✅ |
| `[nzTarget]` | 设置需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | `string \| Element` | `window` | | `[nzTarget]` | 设置需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | `string \| Element` | `window` |
| `(nzClick)` | 点击按钮的回调函数 | `EventEmitter<boolean>` | - | | `(nzClick)` | 点击按钮的回调函数 | `EventEmitter<boolean>` | - |
@@ -22,7 +22,7 @@ import {
ViewEncapsulation ViewEncapsulation
} from '@angular/core'; } from '@angular/core';


import { fadeMotion, toNumber, NzScrollService } from 'ng-zorro-antd/core'; import { fadeMotion, InputNumber, NzConfigService, NzScrollService, WithConfig } from 'ng-zorro-antd/core';
import { fromEvent, Subscription } from 'rxjs'; import { fromEvent, Subscription } from 'rxjs';
import { distinctUntilChanged, throttleTime } from 'rxjs/operators'; import { distinctUntilChanged, throttleTime } from 'rxjs/operators';


@@ -42,17 +42,7 @@ export class NzBackTopComponent implements OnInit, OnDestroy {
visible: boolean = false; visible: boolean = false;


@Input() nzTemplate: TemplateRef<void>; @Input() nzTemplate: TemplateRef<void>;

@Input() @WithConfig(400) @InputNumber() nzVisibilityHeight: number;
private _visibilityHeight: number = 400;

@Input()
set nzVisibilityHeight(value: number) {
this._visibilityHeight = toNumber(value, 400);
}

get nzVisibilityHeight(): number {
return this._visibilityHeight;
}


@Input() @Input()
set nzTarget(el: string | HTMLElement) { set nzTarget(el: string | HTMLElement) {
@@ -63,6 +53,7 @@ export class NzBackTopComponent implements OnInit, OnDestroy {
@Output() readonly nzClick: EventEmitter<boolean> = new EventEmitter(); @Output() readonly nzClick: EventEmitter<boolean> = new EventEmitter();


constructor( constructor(
public nzConfigService: NzConfigService,
private scrollSrv: NzScrollService, private scrollSrv: NzScrollService,
// tslint:disable-next-line:no-any // tslint:disable-next-line:no-any
@Inject(DOCUMENT) private doc: any, @Inject(DOCUMENT) private doc: any,

0 comments on commit 6eb041a

Please sign in to comment.
You can’t perform that action at this time.