mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-14 16:19:15 +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
28 lines
853 B
TypeScript
28 lines
853 B
TypeScript
import type { TriggerProps } from '@rc-component/trigger';
|
|
import MockTrigger from '@rc-component/trigger/lib/mock';
|
|
import * as React from 'react';
|
|
import { TriggerMockContext } from '../../shared/demoTestContext';
|
|
|
|
let OriginTrigger = jest.requireActual('@rc-component/trigger');
|
|
OriginTrigger = OriginTrigger.default ?? OriginTrigger;
|
|
|
|
const ForwardTrigger = React.forwardRef<any, TriggerProps>((props, ref) => {
|
|
const context = React.useContext(TriggerMockContext);
|
|
|
|
const mergedPopupVisible = context?.popupVisible ?? props.popupVisible;
|
|
(global as any).triggerProps = props;
|
|
|
|
const mergedProps = {
|
|
...props,
|
|
ref,
|
|
popupVisible: mergedPopupVisible as boolean,
|
|
};
|
|
|
|
if (context?.mock === false) {
|
|
return <OriginTrigger {...mergedProps} />;
|
|
}
|
|
return <MockTrigger {...mergedProps} />;
|
|
});
|
|
|
|
export default ForwardTrigger;
|