Skip to content

Commit dbc6406

Browse files
authored
Merge pull request #4911 from GeekyAnts/fix/ref-typing
Fix/ref typing
2 parents 6b3063c + afab920 commit dbc6406

File tree

10 files changed

+34
-12
lines changed

10 files changed

+34
-12
lines changed

example/storybook/stories/components/composites/Alert/knobEnabled.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Alert, Box, CloseIcon, IconButton } from 'native-base';
2+
import { Alert, Box, CloseIcon, IconButton, Text } from 'native-base';
33
import { select } from '@storybook/addon-knobs';
44

55
export const Example = () => {
@@ -21,8 +21,8 @@ export const Example = () => {
2121
actionProps={{ alignSelf: 'center' }}
2222
>
2323
<Alert.Icon />
24-
<Alert.Title>Error Alert</Alert.Title>
25-
<Alert.Description>Description </Alert.Description>
24+
<Text>Error Alert</Text>
25+
<Text>Description </Text>
2626
</Alert>
2727
</Box>
2828
);

src/components/basic/FlatList/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { StyledProps } from '../../../theme/types';
22
import type { FlatListProps } from 'react-native';
33
import type { CustomProps, PlatformProps } from '../../types';
4+
import type { MutableRefObject } from 'react';
45

56
export interface InterfaceFlatListProps<ItemT>
67
extends FlatListProps<ItemT>,
@@ -10,6 +11,8 @@ export interface InterfaceFlatListProps<ItemT>
1011
* pass props to contentContainerStyle, and this also resolved NB tokens.
1112
*/
1213
_contentContainerStyle?: Partial<IFlatListProps<ItemT>>;
14+
15+
ref?: MutableRefObject<any>;
1316
}
1417

1518
export type IFlatListProps<ItemT> = InterfaceFlatListProps<ItemT> &

src/components/basic/SectionList/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import type { StyledProps } from '../../../theme/types';
22
import type { SectionListProps } from 'react-native';
33
import type { CustomProps, PlatformProps } from '../../types';
4+
import type { MutableRefObject } from 'react';
45
type DefaultSectionT = {
56
[key: string]: any;
67
};
78
// TODO: any need to fixed
89
export interface InterfaceSectionListProps<ItemT, sectionT = DefaultSectionT>
910
extends SectionListProps<ItemT, sectionT>,
1011
StyledProps,
11-
PlatformProps<ISectionListProps<ItemT, sectionT>> {}
12+
PlatformProps<ISectionListProps<ItemT, sectionT>> {
13+
ref?: MutableRefObject<any>;
14+
}
1215

1316
export type ISectionListProps<
1417
ItemT,

src/components/composites/AlertDialog/AlertDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const AlertDialog = (
7070
onRequestClose={handleClose}
7171
isKeyboardDismissable={isKeyboardDismissable}
7272
useRNModalOnAndroid
73+
unmountOnExit
7374
>
7475
<AlertDialogContext.Provider
7576
value={{

src/components/composites/AlertDialog/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { IBoxProps } from '../../primitives/Box';
1+
import type { IBoxProps, InterfaceBoxProps } from '../../primitives/Box';
22
import type { IIconButtonProps } from '../IconButton';
33
import type { MutableRefObject } from 'react';
44
import type { IFadeProps, ISlideProps } from '../Transitions';
@@ -7,7 +7,8 @@ import type {
77
ThemeComponentSizeType,
88
} from '../../../components/types/utils';
99

10-
export interface InterfaceAlertDialogProps extends IBoxProps {
10+
export interface InterfaceAlertDialogProps
11+
extends InterfaceBoxProps<IAlertDialogProps> {
1112
/**
1213
* If true, the AlertDialog will open. Useful for controllable state behaviour
1314
*/

src/components/composites/IconButton/types.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import type { InterfacePressableProps } from '../../primitives/Pressable/types';
22
import type { IIconProps } from '../../primitives/Icon';
3-
import type { ColorSchemeType } from '../../../components/types';
3+
import type { ColorSchemeType, PlatformProps } from '../../../components/types';
44

55
import type { CustomProps, VariantType } from '../../types';
66
import type { ThemeComponentSizeType } from '../../../components/types/utils';
77
export interface InterfaceIconButtonProps
8-
extends Omit<InterfacePressableProps, 'children' | 'color'>,
8+
extends Omit<
9+
InterfacePressableProps,
10+
'children' | 'color' | '_light' | '_dark' | '_web' | '_android' | '_ios'
11+
>,
912
Omit<
1013
IIconProps,
1114
| 'delayLongPress'
@@ -22,7 +25,8 @@ export interface InterfaceIconButtonProps
2225
| '_web'
2326
| '_android'
2427
| '_ios'
25-
> {
28+
>,
29+
PlatformProps<IIconButtonProps> {
2630
/**
2731
* The color of the radio when it's checked. This should be one of the color keys in the theme (e.g."green", "red").
2832
* @default 'primary'

src/components/primitives/Icon/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { CustomProps, ThemeComponentSizeType } from '../../types/utils';
99
export interface InterfaceIconProps
1010
extends Omit<
1111
SvgProps,
12-
'opacity' | 'fill' | 'stroke' | 'height' | 'width' | 'transform' | 'color'
12+
'opacity' | 'stroke' | 'height' | 'width' | 'transform' | 'color'
1313
>,
1414
StyledProps,
1515
PlatformProps<IIconProps> {

src/components/primitives/Input/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import type { ResponsiveValue, ColorType } from '../../../components/types';
1010
import type { ISizes } from '../../../theme/base/sizes';
1111
import type { CustomProps } from '../../types';
1212
import type { IStackProps } from '../Stack/Stack';
13+
import type { MutableRefObject } from 'react';
1314

1415
export interface InterfaceInputProps
15-
extends PlatformProps<any>,
16+
extends PlatformProps<IInputProps>,
1617
Omit<TextInputProps, 'textAlign'>,
1718
StyledProps {
1819
/**
@@ -110,6 +111,7 @@ export interface InterfaceInputProps
110111
focusOutlineColor?: ColorType;
111112
/** This prop allow you to change outlineColor when input is in focused state*/
112113
inValidOutlineColor?: ColorType;
114+
ref?: MutableRefObject<any>;
113115
}
114116

115117
export interface IInputGroupProps extends InterfaceBoxProps<IInputGroupProps> {

src/components/primitives/Radio/types.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ export interface InterfaceRadioProps extends InterfaceBoxProps<IRadioProps> {
106106
* You can style interaction box around the checkbox using this.
107107
*/
108108
_interactionBox?: Omit<Partial<IRadioProps>, '_interactionBox'>;
109+
110+
ref?: MutableRefObject<any>;
109111
}
110112
export interface IRadioGroupProps extends IStackProps {
111113
/**

src/components/primitives/TextArea/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { usePropsResolution } from '../../../hooks/useThemeProps';
55
import { useHasResponsiveProps } from '../../../hooks/useHasResponsiveProps';
66
import { useHover } from '@react-native-aria/interactions';
77
import { mergeRefs } from '../../../utils';
8-
export interface ITextAreaProps extends InterfaceInputProps {
8+
import type { PlatformProps } from '../../../components/types';
9+
export interface ITextAreaProps
10+
extends Omit<
11+
InterfaceInputProps,
12+
'_web' | '_android' | '_ios' | '_light' | '_dark'
13+
>,
14+
PlatformProps<ITextAreaProps> {
915
/**
1016
* Maps to react-native TextInput's numberOfLines.
1117
*/

0 commit comments

Comments
 (0)