Skip to content

Commit 8d22bd2

Browse files
authored
Merge pull request #4798 from GeekyAnts/fix/typing-custom-props
Fix/typing custom props
2 parents e8f5fb0 + 608a4fd commit 8d22bd2

File tree

64 files changed

+549
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+549
-217
lines changed

example/storybook/stories/components/Wrapper.tsx

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,47 @@ const myTheme = extendTheme({
2121
space: {
2222
mySpace: '29px',
2323
},
24+
2425
components: {
26+
Link: {
27+
sizes: {
28+
mysize: 10,
29+
},
30+
},
2531
Button: {
32+
variants: {
33+
myBtn: {
34+
padding: 10,
35+
},
36+
myNewButton: ({ myPadding }: { myPadding: number }) => {
37+
return {
38+
padding: myPadding,
39+
};
40+
},
41+
},
42+
sizes: {
43+
newsize: ({ mySize }: { mySize: number }) => {
44+
return {
45+
padding: mySize,
46+
};
47+
},
48+
},
49+
},
50+
51+
Checkbox: {
52+
sizes: {
53+
myBtn: {
54+
padding: 10,
55+
},
56+
myNewButton: ({ myPadding }: { myPadding: any }) => {
57+
return {
58+
padding: myPadding,
59+
};
60+
},
61+
},
62+
},
63+
64+
Box: {
2665
variants: {
2766
myBtn: {
2867
padding: 10,
@@ -74,8 +113,11 @@ function MyWrapper({ children }: any) {
74113
export function RenderTestButton() {
75114
const [state, setState] = React.useState(1);
76115
return (
77-
<Box style={{ position: 'absolute', top: 10, left: 20 }}>
78-
<Button title={state.toString()} onPress={() => setState(state + 1)} />
116+
<Box style={{ position: 'absolute', top: 10, left: 20 }} m={2} bg="red.100">
117+
<Button
118+
// title={state.toString()}
119+
onPress={() => setState(state + 1)}
120+
/>
79121
</Box>
80122
);
81123
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"prettier --write"
3737
]
3838
},
39-
"version": "3.3.8-alpha.4",
39+
"version": "3.3.8-alpha.6",
4040
"license": "MIT",
4141
"private": false,
4242
"main": "lib/commonjs/index",

src/components/composites/Accordion/types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { IBoxProps, IIconProps } from '../../primitives';
1+
import type { IIconProps } from '../../primitives';
22
import type { ICollapseProps } from '../../composites/Collapse';
33
import type { MutableRefObject } from 'react';
4+
import type { InterfaceBoxProps } from '../../primitives/Box/types';
45

56
export type IAccordionProps = ICollapseProps & {
67
allowMultiple?: boolean;
@@ -9,13 +10,13 @@ export type IAccordionProps = ICollapseProps & {
910
defaultIndex?: number[];
1011
onChange?: (index?: number[]) => void;
1112
};
12-
export type IAccordionItemProps = IBoxProps<IAccordionItemProps> & {
13+
export type IAccordionItemProps = InterfaceBoxProps<IAccordionItemProps> & {
1314
index?: number;
1415
defaultIsOpen?: boolean;
1516
isDisabled?: boolean;
1617
id?: number;
1718
};
18-
export type IAccordionSummaryProps = IBoxProps<IAccordionSummaryProps> & {
19+
export type IAccordionSummaryProps = InterfaceBoxProps<IAccordionSummaryProps> & {
1920
_expanded?: Omit<IAccordionSummaryProps, '_expanded'>;
2021
_disabled?: Omit<IAccordionSummaryProps, '_disabled'>;
2122
_hover?: Omit<IAccordionSummaryProps, '_hover'>;

src/components/composites/Actionsheet/types.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import type { IButtonProps } from '../../primitives/Button';
1+
import type { InterfaceButtonProps } from '../../primitives/Button/types';
22
import type { IBoxProps } from '../../primitives/Box';
33
import type { MutableRefObject } from 'react';
4+
import type { CustomProps } from '../../../components/types';
45

5-
export interface IActionsheetProps extends IBoxProps<IActionsheetProps> {
6+
export interface InterfaceActionsheetProps
7+
extends IBoxProps<IActionsheetProps> {
68
/**
79
* If true, the ActionSheet will open. Useful for controllable state behaviour
810
*/
@@ -33,7 +35,7 @@ export interface IActionsheetFooterProps
3335
extends IBoxProps<IActionsheetFooterProps> {}
3436
export interface IActionsheetHeaderProps
3537
extends IBoxProps<IActionsheetHeaderProps> {}
36-
export interface IActionsheetItemProps extends IButtonProps {}
38+
export interface IActionsheetItemProps extends InterfaceButtonProps {}
3739

3840
export type IActionsheetComponentType = ((
3941
props: IActionsheetProps & { ref?: MutableRefObject<any> }
@@ -59,3 +61,7 @@ export type IActionsheetComponentType = ((
5961
) => JSX.Element
6062
>;
6163
};
64+
65+
export type IActionsheetProps =
66+
| InterfaceActionsheetProps
67+
| CustomProps<'Actionsheet'>;

src/components/composites/Alert/types.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { MutableRefObject } from 'react';
22
import type { IBoxProps, IIconProps } from '../../primitives';
3-
import type { VariantType } from '../../types';
3+
import type { CustomProps, VariantType } from '../../types';
44

5-
export interface IAlertProps extends IBoxProps<IAlertProps> {
5+
export interface InterfaceAlertProps extends IBoxProps<IAlertProps> {
66
/** The status of the alert
77
* @default info
88
*/
@@ -31,3 +31,5 @@ export type IAlertComponentType = ((
3131
(props: IAlertIconProps & { ref?: MutableRefObject<any> }) => JSX.Element
3232
>;
3333
};
34+
35+
export type IAlertProps = InterfaceAlertProps | CustomProps<'Alert'>;

src/components/composites/AlertDialog/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { IBoxProps } from '../../primitives/Box';
22
import type { IIconButtonProps } from '../IconButton';
33
import type { MutableRefObject } from 'react';
4+
import type { CustomProps } from 'src/components/types';
45

5-
export interface IAlertDialogProps extends IBoxProps {
6+
export interface InterfaceAlertDialogProps extends IBoxProps {
67
/**
78
* If true, the AlertDialog will open. Useful for controllable state behaviour
89
*/
@@ -81,3 +82,7 @@ export type IAlertDialogComponentType = ((
8182
(props: IBoxProps & { ref?: MutableRefObject<any> }) => JSX.Element
8283
>;
8384
};
85+
86+
export type IAlertDialogProps =
87+
| InterfaceAlertDialogProps
88+
| CustomProps<'AlertDialog'>;
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import type { IStackProps } from '../../primitives';
1+
import type { InterfaceStackProps } from '../../primitives/Stack/Stack';
22

3-
export type IAppBarProps = IStackProps & {
3+
export type IAppBarProps = InterfaceStackProps & {
44
colorScheme?: string;
55
statusBarHeight?: number;
66
space?: number;
77
};
88

99
export type IAppBarComponentType = ((props: IAppBarProps) => JSX.Element) & {
10-
Left: React.MemoExoticComponent<(props: IStackProps) => JSX.Element>;
11-
Right: React.MemoExoticComponent<(props: IStackProps) => JSX.Element>;
12-
Content: React.MemoExoticComponent<(props: IStackProps) => JSX.Element>;
10+
Left: React.MemoExoticComponent<(props: InterfaceStackProps) => JSX.Element>;
11+
Right: React.MemoExoticComponent<(props: InterfaceStackProps) => JSX.Element>;
12+
Content: React.MemoExoticComponent<
13+
(props: InterfaceStackProps) => JSX.Element
14+
>;
1315
};
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import type { IBoxProps } from '../../primitives/Box';
2-
import type { ResponsiveValue } from '../../../components/types';
2+
import type { CustomProps, ResponsiveValue } from '../../../components/types';
33

4-
export interface IAspectRatioProps extends IBoxProps<IAspectRatioProps> {
4+
export interface InterfaceAspectRatioProps
5+
extends IBoxProps<IAspectRatioProps> {
56
/**
67
* The aspect ratio of the container. Some examples are `16/9`, `16/10`, `9/16`, `4/3`
78
* @default 4/3
89
*/
910
ratio?: ResponsiveValue<number>;
1011
}
12+
13+
export type IAspectRatioProps =
14+
| InterfaceAspectRatioProps
15+
| CustomProps<'AspectRatio'>;

src/components/composites/Avatar/types.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { IBoxProps } from '../../primitives/Box';
22
import type { ImageSourcePropType } from 'react-native';
33
import type { MutableRefObject } from 'react';
4-
import type { ResponsiveValue } from '../../../components/types';
4+
import type { CustomProps, ResponsiveValue } from '../../../components/types';
55
import type { ISizes } from '../../../theme/base/sizes';
66

7-
export interface IAvatarProps extends IBoxProps<IAvatarProps> {
7+
export interface InterfaceAvatarProps extends IBoxProps<IAvatarProps> {
88
/**
99
* The image source of the avatar.
1010
*/
@@ -47,3 +47,5 @@ export type IAvatarComponentType = ((
4747
(props: IAvatarBadgeProps & { ref?: MutableRefObject<any> }) => JSX.Element
4848
>;
4949
};
50+
51+
export type IAvatarProps = InterfaceAvatarProps | CustomProps<'Avatar'>;

src/components/composites/Badge/types.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { VariantType } from '../../types';
1+
import type { CustomProps, VariantType } from '../../types';
22
import type { IBoxProps } from '../../primitives';
33

4-
export interface IBadgeProps extends IBoxProps<IBadgeProps> {
4+
export interface InterfaceBadgeProps extends IBoxProps<IBadgeProps> {
55
/**
66
* The style variant of the badge.
77
* @default subtle
@@ -12,3 +12,5 @@ export interface IBadgeProps extends IBoxProps<IBadgeProps> {
1212
*/
1313
colorScheme?: string;
1414
}
15+
16+
export type IBadgeProps = InterfaceBadgeProps | CustomProps<'Badge'>;

0 commit comments

Comments
 (0)