PurePanel.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 useClosable from '../_util/hooks/useClosable';
  13. import { withPureRenderTheme } from '../_util/PurePanel';
  14. import { cloneElement } from '../_util/reactNode';
  15. import { ConfigContext } from '../config-provider';
  16. import { RawPurePanel as PopoverRawPurePanel } from '../popover/PurePanel';
  17. import TourPanel from './panelRender';
  18. import useStyle from './style';
  19. const PurePanel = props => {
  20. const {
  21. prefixCls: customizePrefixCls,
  22. current = 0,
  23. total = 6,
  24. className,
  25. style,
  26. type,
  27. closable,
  28. closeIcon
  29. } = props,
  30. restProps = __rest(props, ["prefixCls", "current", "total", "className", "style", "type", "closable", "closeIcon"]);
  31. const {
  32. getPrefixCls
  33. } = React.useContext(ConfigContext);
  34. const prefixCls = getPrefixCls('tour', customizePrefixCls);
  35. const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
  36. const [mergedClosable, mergedCloseIcon] = useClosable({
  37. closable,
  38. closeIcon
  39. }, null, {
  40. closable: true,
  41. closeIconRender: icon => {
  42. var _a;
  43. return /*#__PURE__*/React.isValidElement(icon) ? cloneElement(icon, {
  44. className: classNames((_a = icon.props) === null || _a === void 0 ? void 0 : _a.className, `${prefixCls}-close-icon`)
  45. }) : icon;
  46. }
  47. });
  48. return wrapCSSVar(/*#__PURE__*/React.createElement(PopoverRawPurePanel, {
  49. prefixCls: prefixCls,
  50. hashId: hashId,
  51. className: classNames(className, `${prefixCls}-pure`, type && `${prefixCls}-${type}`, cssVarCls),
  52. style: style
  53. }, /*#__PURE__*/React.createElement(TourPanel, {
  54. stepProps: Object.assign(Object.assign({}, restProps), {
  55. prefixCls,
  56. total,
  57. closable: mergedClosable ? {
  58. closeIcon: mergedCloseIcon
  59. } : undefined
  60. }),
  61. current: current,
  62. type: type
  63. })));
  64. };
  65. export default withPureRenderTheme(PurePanel);