-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate @rc-component/trigger (#226)
* test: migrate rc-dropdown tests * test: skip tests about offset * chore: bump rc-trigger * test: fix part * test: clean up * chore: update ci node ver * chore: update ci node ver * chore: add jest-environment-jsdom * fix: handle ref * chore: code clean * chore: code clena * chore: add husky * test: add test cov --------- Co-authored-by: 二货机器人 <smith3816@gmail.com> Co-authored-by: MadCcc <1075746765@qq.com>
- Loading branch information
1 parent
b41847c
commit 2562c9b
Showing
17 changed files
with
846 additions
and
710 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { forwardRef, ReactElement, useMemo } from 'react'; | ||
import type { DropdownProps } from './Dropdown'; | ||
import { composeRef, supportRef } from 'rc-util/lib/ref'; | ||
|
||
export type OverlayProps = Pick<DropdownProps, 'overlay' | 'arrow' | 'prefixCls'> | ||
|
||
const Overlay = forwardRef<HTMLElement, OverlayProps>((props, ref) => { | ||
const {overlay, arrow, prefixCls} = props; | ||
|
||
const overlayNode = useMemo(() => { | ||
let overlayElement: React.ReactElement; | ||
if (typeof overlay === 'function') { | ||
overlayElement = overlay(); | ||
} else { | ||
overlayElement = overlay; | ||
} | ||
return overlayElement; | ||
}, [overlay]); | ||
|
||
const composedRef = composeRef(ref, (overlayNode as ReactElement & {ref: React.Ref<HTMLElement>})?.ref); | ||
|
||
return ( | ||
<> | ||
{arrow && <div className={`${prefixCls}-arrow`} />} | ||
{React.cloneElement(overlayNode, { ref: supportRef(overlayNode) ? composedRef : undefined })} | ||
</> | ||
) | ||
}); | ||
|
||
export default Overlay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Trigger from '@rc-component/trigger/lib/mock'; | ||
|
||
export default Trigger; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.