ant-design/components/tour/index.tsx
黑雨 1eaf125528
fix: Fix tour step type (#39382)
* feat: fix-step-type

* feat: fix-step-type

* feat: add test

* feat: update test

* feat: update test snapshots

* feat: update test snapshots

* feat: update test snapshots

* fix: PurePanel style

* test: update snapshot

* feat: update package

* feat: fix-step-type

* feat: fix-step-type

* feat: add test

* feat: update test

* feat: update test snapshots

* feat: update test snapshots

* feat: update test snapshots

* feat: update package

* fix: PurePanel style

* test: update snapshot

* feat: update for checks

Co-authored-by: 二货机器人 <smith3816@gmail.com>
2022-12-19 11:34:36 +08:00

57 lines
1.5 KiB
TypeScript

import React, { useContext } from 'react';
import RCTour from '@rc-component/tour';
import classNames from 'classnames';
import panelRender from './panelRender';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigContext } from '../config-provider';
import useStyle from './style';
import type { TourProps, TourStepProps } from './interface';
import PurePanel from './PurePanel';
const Tour: React.ForwardRefRenderFunction<HTMLDivElement, TourProps> & {
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
} = (props) => {
const {
prefixCls: customizePrefixCls,
steps,
current,
type,
rootClassName,
...restProps
} = props;
const { getPrefixCls, direction } = useContext<ConfigConsumerProps>(ConfigContext);
const prefixCls = getPrefixCls('tour', customizePrefixCls);
const [wrapSSR, hashId] = useStyle(prefixCls);
const customClassName = classNames(
{
[`${prefixCls}-rtl`]: direction === 'rtl',
},
hashId,
rootClassName,
);
const mergedRenderPanel = (stepProps: TourStepProps, stepCurrent: number) =>
panelRender(stepProps, stepCurrent, type);
return wrapSSR(
<RCTour
{...restProps}
rootClassName={customClassName}
prefixCls={prefixCls}
steps={steps}
current={current}
animated
renderPanel={mergedRenderPanel}
/>,
);
};
if (process.env.NODE_ENV !== 'production') {
Tour.displayName = 'Tour';
}
Tour._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
export default Tour;