forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPurePanel.tsx
79 lines (72 loc) · 2.22 KB
/
PurePanel.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import Notice from '../vc-notification/Notice';
import type { NoticeProps } from '../vc-notification/Notice';
import useStyle from './style';
import type { NoticeType } from './interface';
import {
CheckCircleFilled,
CloseCircleFilled,
ExclamationCircleFilled,
InfoCircleFilled,
LoadingOutlined,
} from '@ant-design/icons-vue';
import type { VueNode } from '../_util/type';
import classNames from '../_util/classNames';
import { useConfigContextInject } from '../config-provider/context';
import { computed, defineComponent } from 'vue';
export const TypeIcon = {
info: <InfoCircleFilled />,
success: <CheckCircleFilled />,
error: <CloseCircleFilled />,
warning: <ExclamationCircleFilled />,
loading: <LoadingOutlined />,
};
export interface PureContentProps {
prefixCls: string;
type?: NoticeType;
icon?: VueNode;
children: VueNode;
}
export const PureContent = defineComponent({
name: 'PureContent',
inheritAttrs: false,
props: ['prefixCls', 'type', 'icon'] as any,
setup(props, { slots }) {
return () => (
<div
class={classNames(`${props.prefixCls}-custom-content`, `${props.prefixCls}-${props.type}`)}
>
{props.icon || TypeIcon[props.type!]}
<span>{slots.default?.()}</span>
</div>
);
},
});
export interface PurePanelProps
extends Omit<NoticeProps, 'prefixCls' | 'eventKey'>,
Omit<PureContentProps, 'prefixCls' | 'children'> {
prefixCls?: string;
}
/** @private Internal Component. Do not use in your production. */
export default defineComponent({
name: 'PurePanel',
inheritAttrs: false,
props: ['prefixCls', 'class', 'type', 'icon', 'content'] as any,
setup(props, { slots, attrs }) {
const { getPrefixCls } = useConfigContextInject();
const prefixCls = computed(() => props.staticPrefixCls || getPrefixCls('message'));
const [, hashId] = useStyle(prefixCls);
return (
<Notice
{...attrs}
prefixCls={prefixCls.value}
class={classNames(hashId, `${prefixCls.value}-notice-pure-panel`)}
noticeKey="pure"
duration={null}
>
<PureContent prefixCls={props.prefixCls} type={props.type} icon={props.icon}>
{slots.default?.()}
</PureContent>
</Notice>
);
},
});