PurePanel.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 classNames from 'classnames';
  12. import { Panel } from 'rc-dialog';
  13. import { withPureRenderTheme } from '../_util/PurePanel';
  14. import { ConfigContext } from '../config-provider';
  15. import useCSSVarCls from '../config-provider/hooks/useCSSVarCls';
  16. import { ConfirmContent } from './ConfirmDialog';
  17. import { Footer, renderCloseIcon } from './shared';
  18. import useStyle from './style';
  19. const PurePanel = props => {
  20. const {
  21. prefixCls: customizePrefixCls,
  22. className,
  23. closeIcon,
  24. closable,
  25. type,
  26. title,
  27. children,
  28. footer
  29. } = props,
  30. restProps = __rest(props, ["prefixCls", "className", "closeIcon", "closable", "type", "title", "children", "footer"]);
  31. const {
  32. getPrefixCls
  33. } = React.useContext(ConfigContext);
  34. const rootPrefixCls = getPrefixCls();
  35. const prefixCls = customizePrefixCls || getPrefixCls('modal');
  36. const rootCls = useCSSVarCls(rootPrefixCls);
  37. const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootCls);
  38. const confirmPrefixCls = `${prefixCls}-confirm`;
  39. // Choose target props by confirm mark
  40. let additionalProps = {};
  41. if (type) {
  42. additionalProps = {
  43. closable: closable !== null && closable !== void 0 ? closable : false,
  44. title: '',
  45. footer: '',
  46. children: (/*#__PURE__*/React.createElement(ConfirmContent, Object.assign({}, props, {
  47. prefixCls: prefixCls,
  48. confirmPrefixCls: confirmPrefixCls,
  49. rootPrefixCls: rootPrefixCls,
  50. content: children
  51. })))
  52. };
  53. } else {
  54. additionalProps = {
  55. closable: closable !== null && closable !== void 0 ? closable : true,
  56. title,
  57. footer: footer !== null && /*#__PURE__*/React.createElement(Footer, Object.assign({}, props)),
  58. children
  59. };
  60. }
  61. return wrapCSSVar(/*#__PURE__*/React.createElement(Panel, Object.assign({
  62. prefixCls: prefixCls,
  63. className: classNames(hashId, `${prefixCls}-pure-panel`, type && confirmPrefixCls, type && `${confirmPrefixCls}-${type}`, className, cssVarCls, rootCls)
  64. }, restProps, {
  65. closeIcon: renderCloseIcon(prefixCls, closeIcon),
  66. closable: closable
  67. }, additionalProps)));
  68. };
  69. export default withPureRenderTheme(PurePanel);