mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
86b5c50cb4
* chore: adjust doc * chore: simplify arrow offset * chore: auto adjust shift * docs: adjust demo * chore: update snapshot * chore: provide ref * test: prepare * chore: update deps * test: fix part test * test: fix part test * test: fix part test * test: fix part test * test: fix part test * test: update snapshot * fix: missing pure render * fix: Popover pure panel * test: update snapshot * test: update tour snapshot * chore: bump trigger ver * test: fix render ssr logic * test: skip unnecessary case * test: fix test case * test: update snapshot * test: update snapshot * test: update snapshot * test: update snapshot * test: update snapshot * test: fix test case * test: fix test case * chore: clean up useless warning * test: add check for placement * chore: ignore default
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import RCTour from '@rc-component/tour';
|
|
import classNames from 'classnames';
|
|
import React, { useContext } from 'react';
|
|
import type { ConfigConsumerProps } from '../config-provider';
|
|
import { ConfigContext } from '../config-provider';
|
|
import theme from '../theme';
|
|
import getPlacements from '../_util/placements';
|
|
import type { TourProps, TourStepProps } from './interface';
|
|
import TourPanel from './panelRender';
|
|
import PurePanel from './PurePanel';
|
|
import useStyle from './style';
|
|
|
|
const Tour: React.FC<TourProps> & { _InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel } = (
|
|
props,
|
|
) => {
|
|
const {
|
|
prefixCls: customizePrefixCls,
|
|
steps,
|
|
current,
|
|
type,
|
|
rootClassName,
|
|
indicatorsRender,
|
|
...restProps
|
|
} = props;
|
|
const { getPrefixCls, direction } = useContext<ConfigConsumerProps>(ConfigContext);
|
|
const prefixCls = getPrefixCls('tour', customizePrefixCls);
|
|
const [wrapSSR, hashId] = useStyle(prefixCls);
|
|
const { token } = theme.useToken();
|
|
|
|
const builtinPlacements = getPlacements({
|
|
arrowPointAtCenter: true,
|
|
autoAdjustOverflow: true,
|
|
offset: token.marginXXS,
|
|
arrowWidth: token.sizePopupArrow,
|
|
borderRadius: token.borderRadius,
|
|
});
|
|
|
|
const customClassName = classNames(
|
|
{
|
|
[`${prefixCls}-rtl`]: direction === 'rtl',
|
|
},
|
|
hashId,
|
|
rootClassName,
|
|
);
|
|
|
|
const mergedRenderPanel = (stepProps: TourStepProps, stepCurrent: number): React.ReactNode => (
|
|
<TourPanel
|
|
type={type}
|
|
stepProps={stepProps}
|
|
current={stepCurrent}
|
|
indicatorsRender={indicatorsRender}
|
|
/>
|
|
);
|
|
|
|
return wrapSSR(
|
|
<RCTour
|
|
{...restProps}
|
|
rootClassName={customClassName}
|
|
prefixCls={prefixCls}
|
|
steps={steps}
|
|
current={current}
|
|
animated
|
|
renderPanel={mergedRenderPanel}
|
|
builtinPlacements={builtinPlacements}
|
|
/>,
|
|
);
|
|
};
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
Tour.displayName = 'Tour';
|
|
}
|
|
|
|
Tour._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
|
|
|
|
export default Tour;
|