import * as React from 'react';
import CheckCircleFilled from '@ant-design/icons/CheckCircleFilled';
import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';
import ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled';
import InfoCircleFilled from '@ant-design/icons/InfoCircleFilled';
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
import classNames from 'classnames';
import { Notice } from '@rc-component/notification';
import type { NoticeProps } from '@rc-component/notification/lib/Notice';
import { cloneElement } from '../_util/reactNode';
import { useComponentConfig } from '../config-provider/context';
import useCSSVarCls from '../config-provider/hooks/useCSSVarCls';
import type { NoticeType, SemanticName } from './interface';
import useStyle from './style';
export const TypeIcon = {
info: ,
success: ,
error: ,
warning: ,
loading: ,
};
export interface PureContentProps {
prefixCls: string;
type?: NoticeType;
icon?: React.ReactNode;
children: React.ReactNode;
classNames?: Partial>;
styles?: Partial>;
}
export const PureContent: React.FC = ({
prefixCls,
type,
icon,
children,
classNames: pureContentClassNames,
styles,
}) => {
const iconElement = icon || (type && TypeIcon[type]);
const iconNode: React.ReactNode = cloneElement(iconElement, (currentProps) => ({
className: classNames(currentProps.className, pureContentClassNames?.icon),
style: { ...currentProps.style, ...styles?.icon },
}));
return (
{iconNode}
{children}
);
};
export interface PurePanelProps
extends Omit,
Omit {
prefixCls?: string;
classNames?: Partial>;
styles?: Partial>;
}
/** @private Internal Component. Do not use in your production. */
const PurePanel: React.FC = (props) => {
const {
prefixCls: staticPrefixCls,
className,
style,
type,
icon,
content,
classNames: messageClassNames,
styles,
...restProps
} = props;
const {
getPrefixCls,
className: contextClassName,
style: contextStyle,
classNames: contextClassNames,
styles: contextStyles,
} = useComponentConfig('message');
const prefixCls = staticPrefixCls || getPrefixCls('message');
const rootCls = useCSSVarCls(prefixCls);
const [hashId, cssVarCls] = useStyle(prefixCls, rootCls);
return (
{content}
}
/>
);
};
export default PurePanel;