9
9
ThemedBaseStyledInterface ,
10
10
ThemedStyledFunction ,
11
11
} from 'styled-components'
12
- import { createCssFunction , XCSSFunction } from './createCssFunction'
12
+ import { XCSSFunction } from './createCssFunction'
13
13
import { ReactNativeStyledInterface } from 'styled-components/native'
14
14
15
15
type BoxStyledTags < TProps extends object > = {
@@ -24,11 +24,10 @@ export interface XStyled<TGen extends StyleGenerator>
24
24
extends ThemedBaseStyledInterface < Theme > ,
25
25
BoxStyledTags < StyleGeneratorProps < TGen > > { }
26
26
27
- export type StyledFunctions < XObj > = {
27
+ export type StyledFunctions < XStyledInterface > = {
28
28
scStyled : StyledInterface | ReactNativeStyledInterface < Theme >
29
- styled ?: XObj
30
- xstyled ?: XObj
31
- x ?: XObj
29
+ styled : XStyledInterface
30
+ xstyled : XStyledInterface
32
31
}
33
32
34
33
const createShouldForwardProp = (
@@ -75,11 +74,11 @@ const getCreateStyle = (
75
74
return createStyle
76
75
}
77
76
78
- export const createBaseStyled = < XObj , TGen extends StyleGenerator > (
77
+ export const createBaseStyled = < XStyledInterface , TGen extends StyleGenerator > (
79
78
scStyled : StyledInterface | ReactNativeStyledInterface < Theme > ,
80
79
css : XCSSFunction ,
81
80
generator ?: TGen ,
82
- ) : XObj => {
81
+ ) : XStyledInterface => {
83
82
const config = generator
84
83
? {
85
84
shouldForwardProp : createShouldForwardProp ( generator ) ,
@@ -92,30 +91,33 @@ export const createBaseStyled = <XObj, TGen extends StyleGenerator>(
92
91
css ,
93
92
generator ,
94
93
)
95
- } ) as unknown as XObj
94
+ } ) as unknown as XStyledInterface
96
95
}
97
96
98
97
export const createStyled = <
99
- SCFN extends StyledInterface | ReactNativeStyledInterface < Theme > ,
100
- SCCSSFN extends ReturnType < typeof createCssFunction > ,
101
- XObj ,
98
+ StyledFunction extends StyledInterface | ReactNativeStyledInterface < Theme > ,
99
+ XStyledInterface ,
102
100
TGen extends StyleGenerator ,
103
101
> (
104
- scStyled : SCFN ,
105
- cssFunction : SCCSSFN ,
102
+ scStyled : StyledFunction ,
103
+ cssFunction : XCSSFunction ,
106
104
generator : TGen ,
107
- ) : StyledFunctions < XObj > => {
108
- const styled = createBaseStyled < XObj , TGen > ( scStyled , cssFunction )
109
- const xstyled = createBaseStyled < XObj , TGen > ( scStyled , cssFunction , generator )
105
+ ) : StyledFunctions < XStyledInterface > => {
106
+ const styled = createBaseStyled < XStyledInterface , TGen > ( scStyled , cssFunction )
107
+ const xstyled = createBaseStyled < XStyledInterface , TGen > (
108
+ scStyled ,
109
+ cssFunction ,
110
+ generator ,
111
+ )
110
112
111
113
return { scStyled, styled, xstyled }
112
114
}
113
115
114
- export const defineStyledInterface = < XObj > ( {
116
+ export const defineStyledInterface = < XStyledInterface > ( {
115
117
scStyled,
116
118
styled,
117
119
xstyled,
118
- } : StyledFunctions < XObj > ) : XObj => {
120
+ } : StyledFunctions < XStyledInterface > ) : XStyledInterface => {
119
121
//@ts -ignore
120
122
styled . box = xstyled ( 'div' )
121
123
@@ -127,18 +129,18 @@ export const defineStyledInterface = <XObj>({
127
129
styled [ `${ tag } Box` ] = xstyled ( tag )
128
130
} )
129
131
130
- return styled as XObj
132
+ return styled
131
133
}
132
134
133
- export const defineXStyledInterface = < XObj > ( {
135
+ export const defineXStyledInterface = < XStyledInterface > ( {
134
136
scStyled,
135
137
styled,
136
138
xstyled,
137
- } : StyledFunctions < XObj > ) : XObj => {
139
+ } : StyledFunctions < XStyledInterface > ) : XStyledInterface => {
138
140
Object . keys ( scStyled ) . forEach ( ( tag ) => {
139
141
//@ts -ignore
140
142
styled [ tag ] = xstyled ( tag ) ``
141
143
} )
142
144
143
- return styled as XObj
145
+ return styled
144
146
}
0 commit comments