2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2024-03-08 21:31:27 +08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
import useClosable from '../_util/hooks/useClosable';
|
|
|
|
import { withPureRenderTheme } from '../_util/PurePanel';
|
|
|
|
import { cloneElement } from '../_util/reactNode';
|
2022-11-03 00:43:26 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
|
|
|
import { RawPurePanel as PopoverRawPurePanel } from '../popover/PurePanel';
|
2023-02-13 14:30:08 +08:00
|
|
|
import type { TourStepProps } from './interface';
|
|
|
|
import TourPanel from './panelRender';
|
2022-11-03 00:43:26 +08:00
|
|
|
import useStyle from './style';
|
|
|
|
|
|
|
|
export interface PurePanelProps extends TourStepProps {}
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const PurePanel: React.FC<PurePanelProps> = (props) => {
|
2022-11-03 00:43:26 +08:00
|
|
|
const {
|
|
|
|
prefixCls: customizePrefixCls,
|
|
|
|
current = 0,
|
|
|
|
total = 6,
|
|
|
|
className,
|
|
|
|
style,
|
|
|
|
type,
|
2024-03-08 21:31:27 +08:00
|
|
|
closable,
|
|
|
|
closeIcon,
|
2022-11-03 00:43:26 +08:00
|
|
|
...restProps
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const prefixCls = getPrefixCls('tour', customizePrefixCls);
|
|
|
|
|
2023-12-14 14:58:53 +08:00
|
|
|
const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
|
2022-11-03 00:43:26 +08:00
|
|
|
|
2024-03-31 11:56:55 +08:00
|
|
|
const [mergedClosable, mergedCloseIcon] = useClosable({ closable, closeIcon }, null, {
|
|
|
|
closable: true,
|
|
|
|
closeIconRender: (icon) =>
|
2024-03-08 21:31:27 +08:00
|
|
|
React.isValidElement(icon)
|
|
|
|
? cloneElement(icon, {
|
|
|
|
className: classNames(icon.props.className, `${prefixCls}-close-icon`),
|
|
|
|
})
|
|
|
|
: icon,
|
|
|
|
});
|
|
|
|
|
2023-11-08 14:56:15 +08:00
|
|
|
return wrapCSSVar(
|
2022-11-03 00:43:26 +08:00
|
|
|
<PopoverRawPurePanel
|
|
|
|
prefixCls={prefixCls}
|
|
|
|
hashId={hashId}
|
2023-12-14 14:58:53 +08:00
|
|
|
className={classNames(
|
|
|
|
className,
|
|
|
|
`${prefixCls}-pure`,
|
|
|
|
type && `${prefixCls}-${type}`,
|
|
|
|
cssVarCls,
|
|
|
|
)}
|
2022-11-03 00:43:26 +08:00
|
|
|
style={style}
|
|
|
|
>
|
2024-03-08 21:31:27 +08:00
|
|
|
<TourPanel
|
|
|
|
stepProps={{
|
|
|
|
...restProps,
|
|
|
|
prefixCls,
|
|
|
|
total,
|
|
|
|
closable: mergedClosable ? { closeIcon: mergedCloseIcon } : undefined,
|
|
|
|
}}
|
|
|
|
current={current}
|
|
|
|
type={type}
|
|
|
|
/>
|
2022-11-03 00:43:26 +08:00
|
|
|
</PopoverRawPurePanel>,
|
|
|
|
);
|
2022-11-05 14:55:34 +08:00
|
|
|
};
|
|
|
|
|
2023-08-08 19:48:41 +08:00
|
|
|
export default withPureRenderTheme(PurePanel);
|