/
Box.d.ts
228 lines (206 loc) · 5.36 KB
/
Box.d.ts
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
import * as React from 'react';
import { OverridableComponent, OverrideProps } from '@mui/types';
import { Theme as SystemTheme } from '../createTheme';
import {
SxProps,
AllSystemCSSProperties,
ResponsiveStyleValue,
OverwriteCSSProperties,
AliasesCSSProperties,
} from '../styleFunctionSx';
export type PropsFor<SomeStyleFunction> =
SomeStyleFunction extends StyleFunction<infer Props> ? Props : never;
export type StyleFunction<Props> = (props: Props) => any;
export type SimpleStyleFunction<PropKey extends keyof any> = StyleFunction<
Partial<Record<PropKey, any>>
> & { filterProps: string[] };
// borders.js
export declare const borders: SimpleStyleFunction<
| 'border'
| 'borderTop'
| 'borderRight'
| 'borderBottom'
| 'borderLeft'
| 'borderColor'
| 'borderRadius'
>;
export declare const display: SimpleStyleFunction<
'display' | 'displayPrint' | 'overflow' | 'textOverflow' | 'visibility' | 'whiteSpace'
>;
export declare const flexbox: SimpleStyleFunction<
| 'flexBasis'
| 'flexDirection'
| 'flexWrap'
| 'justifyContent'
| 'alignItems'
| 'alignContent'
| 'order'
| 'flex'
| 'flexGrow'
| 'flexShrink'
| 'alignSelf'
| 'justifyItems'
| 'justifySelf'
>;
export declare const grid: SimpleStyleFunction<
| 'gap'
| 'columnGap'
| 'rowGap'
| 'gridColumn'
| 'gridRow'
| 'gridAutoFlow'
| 'gridAutoColumns'
| 'gridAutoRows'
| 'gridTemplateColumns'
| 'gridTemplateRows'
| 'gridTemplateAreas'
| 'gridArea'
>;
export declare const palette: SimpleStyleFunction<'bgcolor' | 'color'>;
export declare const positions: SimpleStyleFunction<
'zIndex' | 'position' | 'top' | 'right' | 'bottom' | 'left'
>;
export declare const shadows: SimpleStyleFunction<'boxShadow'>;
export declare const sizing: SimpleStyleFunction<
| 'width'
| 'maxWidth'
| 'minWidth'
| 'height'
| 'maxHeight'
| 'minHeight'
| 'sizeWidth'
| 'sizeHeight'
| 'boxSizing'
>;
export declare const spacing: SimpleStyleFunction<
| 'm'
| 'mt'
| 'mr'
| 'mb'
| 'ml'
| 'mx'
| 'my'
| 'p'
| 'pt'
| 'pr'
| 'pb'
| 'pl'
| 'px'
| 'py'
| 'margin'
| 'marginTop'
| 'marginRight'
| 'marginBottom'
| 'marginLeft'
| 'marginX'
| 'marginY'
| 'marginInline'
| 'marginInlineStart'
| 'marginInlineEnd'
| 'marginBlock'
| 'marginBlockStart'
| 'marginBlockEnd'
| 'padding'
| 'paddingTop'
| 'paddingRight'
| 'paddingBottom'
| 'paddingLeft'
| 'paddingX'
| 'paddingY'
| 'paddingInline'
| 'paddingInlineStart'
| 'paddingInlineEnd'
| 'paddingBlock'
| 'paddingBlockStart'
| 'paddingBlockEnd'
>;
export declare const typography: SimpleStyleFunction<
| 'typography'
| 'fontFamily'
| 'fontSize'
| 'fontStyle'
| 'fontWeight'
| 'letterSpacing'
| 'lineHeight'
| 'textAlign'
| 'textTransform'
>;
// compose.js
/**
* given a list of StyleFunction return the intersection of the props each individual
* StyleFunction requires.
*
* If `firstFn` requires { color: string } and `secondFn` requires { spacing: number }
* their composed function requires { color: string, spacing: number }
*/
type ComposedArg<T> = T extends Array<(arg: infer P) => any> ? P : never;
type ComposedOwnerState<T> = ComposedArg<T>;
export type ComposedStyleFunction<T extends Array<StyleFunction<any>>> = StyleFunction<
ComposedOwnerState<T>
> & { filterProps: string[] };
export interface CustomSystemProps extends AliasesCSSProperties, OverwriteCSSProperties {}
export type SimpleSystemKeys = keyof PropsFor<
ComposedStyleFunction<
[
typeof borders,
typeof display,
typeof flexbox,
typeof grid,
typeof palette,
typeof positions,
typeof shadows,
typeof sizing,
typeof spacing,
typeof typography,
]
>
>;
// The SimpleSystemKeys are subset of the AllSystemCSSProperties, so this should be ok
// This is needed as these are used as keys inside AllSystemCSSProperties
type StandardSystemKeys = Extract<SimpleSystemKeys, keyof AllSystemCSSProperties>;
export type SystemProps<Theme extends object = {}> = {
[K in StandardSystemKeys]?:
| ResponsiveStyleValue<AllSystemCSSProperties[K]>
| ((theme: Theme) => ResponsiveStyleValue<AllSystemCSSProperties[K]>);
};
export interface BoxOwnProps<Theme extends object = SystemTheme> extends SystemProps<Theme> {
children?: React.ReactNode;
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component?: React.ElementType;
ref?: React.Ref<unknown>;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
}
export interface BoxTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = 'div',
Theme extends object = SystemTheme,
> {
props: AdditionalProps & BoxOwnProps<Theme>;
defaultComponent: RootComponent;
}
/**
*
* Demos:
*
* - [Box (Joy UI)](https://mui.com/joy-ui/react-box/)
* - [Box (Material UI)](https://mui.com/material-ui/react-box/)
* - [Box (MUI System)](https://mui.com/system/react-box/)
*
* API:
*
* - [Box API](https://mui.com/system/api/box/)
*/
declare const Box: OverridableComponent<BoxTypeMap>;
export type BoxProps<
RootComponent extends React.ElementType = BoxTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<BoxTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType;
};
export default Box;