Skip to content

Commit be762de

Browse files
committed
* messager: enhance content handling in MessagerItem by supporting message and html properties for dynamic content rendering.
1 parent b17a06c commit be762de

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

lib/messager/src/component/messager-item.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,30 @@ function getAnimationFromPlacement(placement?: MessagerPlacement): string {
1919

2020
export class MessagerItem extends ReactComponent<MessagerItemOptions> {
2121
render(props: MessagerItemOptions) {
22-
const {margin,
22+
const {
23+
margin,
2324
type,
2425
placement,
2526
animation,
2627
show,
2728
className,
29+
message,
30+
html,
31+
content,
2832
time,
29-
...alertOptions} = props;
30-
if (typeof alertOptions.html === 'string') {
31-
alertOptions.content = {html: alertOptions.html};
32-
delete alertOptions.html;
33+
...alertOptions
34+
} = props;
35+
const contents = content ? [content] : [];
36+
if (typeof html === 'string') {
37+
contents.push({html});
38+
}
39+
if (message) {
40+
contents.push(message);
3341
}
3442
return (
3543
<Alert
3644
className={classes('messager', className, type, animation === true ? getAnimationFromPlacement(placement) : animation, show ? 'in' : '')}
45+
content={contents}
3746
{...alertOptions}
3847
/>
3948
);
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import {AlertOptions} from '@zui/alert/src/types';
2-
import {MessagerPlacement} from './messager-placement';
1+
import type {CustomContentType} from '@zui/core';
2+
import type {AlertOptions} from '@zui/alert/src/types';
3+
import type {MessagerPlacement} from './messager-placement';
34

45
export interface MessagerOptions extends AlertOptions {
56
margin?: number;
@@ -8,4 +9,5 @@ export interface MessagerOptions extends AlertOptions {
89
animation?: boolean | string;
910
time?: number;
1011
html?: string;
12+
message?: CustomContentType;
1113
}

0 commit comments

Comments
 (0)