File tree 3 files changed +14
-11
lines changed
3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -182,17 +182,16 @@ export declare const If: FC<PropsWithChildren<IfProps>>;
182
182
## ` <Switch /> ` ` <Case /> ` ` <Default /> ` Props
183
183
184
184
``` tsx
185
- import { type FC , type PropsWithChildren } from ' react' ;
186
- export declare const Switch: FC <PropsWithChildren <{}>>;
187
-
185
+ import type { FC , PropsWithChildren } from ' react' ;
186
+ export const Switch: FC <PropsWithChildren <{}>>;
188
187
type TagType = React .ElementType | keyof JSX .IntrinsicElements ;
189
188
interface CaseElementProps <T extends TagType > {
190
189
as? : T ;
191
190
readonly condition? : boolean ;
192
191
}
193
192
export type CaseProps <T extends TagType > = CaseElementProps <T > & React .ComponentPropsWithoutRef <T >;
194
- export declare const Case: <T extends TagType >(props : CaseProps <T >) => null ;
195
- export declare const Default: <T extends TagType >(props : CaseProps <T >) => null ;
193
+ export const Case: <T extends TagType >(props : CaseProps <T >) => any ;
194
+ export const Default: <T extends TagType >(props : Omit < CaseProps <T >, ' condition ' > ) => import ( " react/jsx-runtime " ). JSX . Element ;
196
195
```
197
196
198
197
## Development
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export const Switch: FC<PropsWithChildren<{}>> = ({ children }) => {
20
20
}
21
21
return false ;
22
22
} ) ;
23
- return < > { matchChild ?? defaultCase ?? null } </ > ;
23
+ return matchChild ?? defaultCase ?? null ;
24
24
} ;
25
25
26
26
type TagType = React . ElementType | keyof JSX . IntrinsicElements ;
@@ -37,4 +37,6 @@ export const Case = <T extends TagType>(props: CaseProps<T>) => {
37
37
return Elm ? < Elm { ...reset } > { children } </ Elm > : children ;
38
38
} ;
39
39
40
- export const Default = < T extends TagType > ( props : CaseProps < T > ) => < Case { ...props } /> ;
40
+ export const Default = < T extends TagType > ( props : Omit < CaseProps < T > , 'condition' > ) => (
41
+ < Case { ...( { ...props } as CaseProps < T > ) } />
42
+ ) ;
Original file line number Diff line number Diff line change 1
1
declare module '@uiw/react-only-when/switch' {
2
- import { FC , PropsWithChildren } from 'react' ;
3
- export declare const Switch : < T extends TagType > ( { children } : PropsWithChildren ) => null ;
2
+ import type { FC , PropsWithChildren } from 'react' ;
3
+ export const Switch : FC < PropsWithChildren < { } > > ;
4
4
type TagType = React . ElementType | keyof JSX . IntrinsicElements ;
5
5
interface CaseElementProps < T extends TagType > {
6
6
as ?: T ;
7
7
readonly condition ?: boolean ;
8
8
}
9
9
export type CaseProps < T extends TagType > = CaseElementProps < T > & React . ComponentPropsWithoutRef < T > ;
10
- export declare const Case : < T extends TagType > ( props : CaseProps < T > ) => any ;
11
- export declare const Default : < T extends TagType > ( props : CaseProps < T > ) => any ;
10
+ export const Case : < T extends TagType > ( props : CaseProps < T > ) => any ;
11
+ export const Default : < T extends TagType > (
12
+ props : Omit < CaseProps < T > , 'condition' > ,
13
+ ) => import ( 'react/jsx-runtime' ) . JSX . Element ;
12
14
}
You can’t perform that action at this time.
0 commit comments