PurePanel.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "use client";
  2. var __rest = this && this.__rest || function (s, e) {
  3. var t = {};
  4. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  6. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  7. }
  8. return t;
  9. };
  10. import * as React from 'react';
  11. import CheckCircleFilled from "@ant-design/icons/es/icons/CheckCircleFilled";
  12. import CloseCircleFilled from "@ant-design/icons/es/icons/CloseCircleFilled";
  13. import ExclamationCircleFilled from "@ant-design/icons/es/icons/ExclamationCircleFilled";
  14. import InfoCircleFilled from "@ant-design/icons/es/icons/InfoCircleFilled";
  15. import LoadingOutlined from "@ant-design/icons/es/icons/LoadingOutlined";
  16. import classNames from 'classnames';
  17. import { Notice } from 'rc-notification';
  18. import { ConfigContext } from '../config-provider';
  19. import useCSSVarCls from '../config-provider/hooks/useCSSVarCls';
  20. import useStyle from './style';
  21. export const TypeIcon = {
  22. info: /*#__PURE__*/React.createElement(InfoCircleFilled, null),
  23. success: /*#__PURE__*/React.createElement(CheckCircleFilled, null),
  24. error: /*#__PURE__*/React.createElement(CloseCircleFilled, null),
  25. warning: /*#__PURE__*/React.createElement(ExclamationCircleFilled, null),
  26. loading: /*#__PURE__*/React.createElement(LoadingOutlined, null)
  27. };
  28. export const PureContent = ({
  29. prefixCls,
  30. type,
  31. icon,
  32. children
  33. }) => (/*#__PURE__*/React.createElement("div", {
  34. className: classNames(`${prefixCls}-custom-content`, `${prefixCls}-${type}`)
  35. }, icon || TypeIcon[type], /*#__PURE__*/React.createElement("span", null, children)));
  36. /** @private Internal Component. Do not use in your production. */
  37. const PurePanel = props => {
  38. const {
  39. prefixCls: staticPrefixCls,
  40. className,
  41. type,
  42. icon,
  43. content
  44. } = props,
  45. restProps = __rest(props, ["prefixCls", "className", "type", "icon", "content"]);
  46. const {
  47. getPrefixCls
  48. } = React.useContext(ConfigContext);
  49. const prefixCls = staticPrefixCls || getPrefixCls('message');
  50. const rootCls = useCSSVarCls(prefixCls);
  51. const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootCls);
  52. return wrapCSSVar(/*#__PURE__*/React.createElement(Notice, Object.assign({}, restProps, {
  53. prefixCls: prefixCls,
  54. className: classNames(className, hashId, `${prefixCls}-notice-pure-panel`, cssVarCls, rootCls),
  55. eventKey: "pure",
  56. duration: null,
  57. content: /*#__PURE__*/React.createElement(PureContent, {
  58. prefixCls: prefixCls,
  59. type: type,
  60. icon: icon
  61. }, content)
  62. })));
  63. };
  64. export default PurePanel;