Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
610 additions
and
503 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
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
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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
import React from 'react'; | ||
import React, {ComponentType, ForwardedRef} from 'react'; | ||
import hoistStatics from 'hoist-non-react-statics'; | ||
|
||
export interface ForwardRefInjectedProps { | ||
export interface ForwardRefInjectedProps<T = any> { | ||
/** | ||
* The forwarded ref of the containing element | ||
*/ | ||
forwardedRef: any; | ||
forwardedRef: ForwardedRef<T>; | ||
} | ||
|
||
export default function forwardRef<P = any, STATICS = {}>(WrappedComponent: React.ComponentType<P>): React.ComponentType<P> & STATICS { | ||
function forwardRef(props: P, ref: any) { | ||
export default function forwardRef<P, STATICS = {}, RefInterface = any>(WrappedComponent: ComponentType<P & ForwardRefInjectedProps<RefInterface>>) { | ||
function forwardRef(props: P, ref: ForwardedRef<RefInterface>) { | ||
return <WrappedComponent {...props} forwardedRef={ref}/>; | ||
} | ||
|
||
const ForwardedComponent = React.forwardRef(forwardRef); | ||
const ForwardedComponent = React.forwardRef<RefInterface, P>(forwardRef); | ||
|
||
hoistStatics(ForwardedComponent, WrappedComponent); | ||
//@ts-ignore | ||
ForwardedComponent.displayName = WrappedComponent.displayName; | ||
//@ts-ignore | ||
ForwardedComponent.propTypes = WrappedComponent.propTypes; | ||
//@ts-ignore | ||
ForwardedComponent.defaultProps = WrappedComponent.defaultProps; | ||
|
||
return ForwardedComponent as any; | ||
return ForwardedComponent as typeof ForwardedComponent & STATICS; | ||
} |
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,26 @@ | ||
import {ButtonProps} from './ButtonTypes'; | ||
import {useComponentDriver, ComponentProps, usePressableDriver, TextDriver, ImageDriver} from '../../testkit'; | ||
|
||
export const ButtonDriver = (props: ComponentProps) => { | ||
const driver = usePressableDriver<ButtonProps>(useComponentDriver(props)); | ||
|
||
const labelDriver = TextDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}.label` | ||
}); | ||
|
||
const iconDriver = ImageDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}.icon` | ||
}); | ||
|
||
const getLabel = () => { | ||
return labelDriver; | ||
}; | ||
|
||
const getIcon = () => { | ||
return iconDriver; | ||
}; | ||
|
||
return {getLabel, getIcon, ...driver}; | ||
}; |
Oops, something went wrong.