-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathsystem.types.tsx
More file actions
85 lines (75 loc) · 2.03 KB
/
Copy pathsystem.types.tsx
File metadata and controls
85 lines (75 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import type {
ResponsiveValue,
SystemProps,
SystemStyleObject,
} from "@chakra-ui/styled-system"
import type { Interpolation } from "@emotion/react"
export interface ChakraProps extends SystemProps {
/**
* Used to truncate text at a specific number of lines
*/
noOfLines?: ResponsiveValue<number>
/**
* Used for internal css management
* @private
*/
__css?: SystemStyleObject
/**
* Used to pass theme-aware style props.
* NB: This is the public API for user-land
*/
sx?: SystemStyleObject
/**
* The emotion's css style object
*/
css?: Interpolation<{}>
}
export type As = React.ElementType
/**
* Extract the props of a React element or component
*/
export type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {
as?: As
}
export type OmitCommonProps<
Target,
OmitAdditionalProps extends keyof any = never,
> = Omit<
Target,
"transition" | "as" | "color" | "translate" | OmitAdditionalProps
> & {
htmlTranslate?: "yes" | "no" | undefined
}
export type RightJoinProps<
SourceProps extends object = {},
OverrideProps extends object = {},
> = OmitCommonProps<SourceProps, keyof OverrideProps> & OverrideProps
type Assign<T, U> = Omit<T, keyof U> & U
export type MergeWithAs<
ComponentProps extends object,
AsProps extends object,
AdditionalProps extends object = {},
AsComponent extends As = As,
> = (
| RightJoinProps<ComponentProps, AdditionalProps>
| RightJoinProps<AsProps, AdditionalProps>
) & {
as?: AsComponent
}
export type ComponentWithAs<Component extends As, Props extends object = {}> = {
<AsComponent extends As = Component>(
props: MergeWithAs<
React.ComponentProps<Component>,
React.ComponentProps<AsComponent>,
Props,
AsComponent
>,
): JSX.Element
displayName?: string
propTypes?: React.WeakValidationMap<any>
contextTypes?: React.ValidationMap<any>
defaultProps?: Partial<any>
id?: string
}
export interface ChakraComponent<T extends As, P extends object = {}>
extends ComponentWithAs<T, Assign<ChakraProps, P>> {}