Skip to content

Commit

Permalink
fix(theme:modal): removed `nzComponentParams
Browse files Browse the repository at this point in the history
  • Loading branch information
devcui committed Aug 22, 2023
1 parent ac4632f commit 6507ead
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/theme/src/services/modal/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ Your body content
| `exact` | Exact match return value, default is `true`, If the return value is not null (`null` or `undefined`) is considered successful, otherwise it is considered error. | `boolean` | `true` |
| `includeTabs` | Whether to wrap the tab page | `boolean` | `false` |
| `drag` | Drag | `boolean, ModalHelperDragOptions` | - |
| `useNzData` | Whether it is mandatory to use `nzData` to pass parameters. If it is `false`, it means that the parameters will be directly mapped to the component instance, and other values ​​can only be obtained through `NZ_MODAL_DATA`. | `boolean` | `false` |
| `modalOptions` | nz-modal raw parameters [ModalOptions](https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/components/modal/modal-types.ts) | `ModalOptions` | - |
1 change: 1 addition & 0 deletions packages/theme/src/services/modal/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ Your body content
| `exact` | 是否精准(默认:`true`),若返回值非空值(`null``undefined`)视为成功,否则视为错误 | `boolean` | `true` |
| `includeTabs` | 是否包裹标签页 | `boolean` | `false` |
| `drag` | 支持拖动 | `boolean, ModalHelperDragOptions` | - |
| `useNzData` | 是否强制使用 `nzData` 传递参数,若为 `false` 表示参数会直接映射到组件实例中,其他值只能通过 `NZ_MODAL_DATA` 的方式来获取参数 | `boolean` | `false` |
| `modalOptions` | 对话框 [ModalOptions](https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/components/modal/modal-types.ts) 参数 | `ModalOptions` | - |
10 changes: 9 additions & 1 deletion packages/theme/src/services/modal/modal.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export interface ModalHelperOptions {
* 是否支持拖动,默认是通过标题来触发
*/
drag?: ModalHelperDragOptions | boolean;
/**
* 是否强制使用 `nzData` 传递参数,若为 `false` 表示参数会直接映射到组件实例中,其他值只能通过 `NZ_MODAL_DATA` 的方式来获取参数,默认:`false`
*/
useNzData?: boolean;
}

export interface ModalHelperDragOptions {
Expand Down Expand Up @@ -86,7 +90,7 @@ export class ModalHelper {
options
);
return new Observable((observer: Observer<NzSafeAny>) => {
const { size, includeTabs, modalOptions, drag } = options as ModalHelperOptions;
const { size, includeTabs, modalOptions, drag, useNzData } = options as ModalHelperOptions;
let cls = '';
let width = '';
if (size) {
Expand Down Expand Up @@ -121,6 +125,10 @@ export class ModalHelper {
nzData: params
};
const subject = this.srv.create({ ...defaultOptions, ...modalOptions });
// 保留 nzComponentParams 原有风格,但依然可以通过 @Inject(NZ_MODAL_DATA) 获取
if (useNzData !== true) {
Object.assign(subject.componentInstance, params);
}
subject.afterOpen
.pipe(
take(1),
Expand Down

0 comments on commit 6507ead

Please sign in to comment.