@mui/styled-engine-sc 6.4.3 → 7.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts DELETED
@@ -1,408 +0,0 @@
1
- import * as React from 'react';
2
- import * as CSS from 'csstype';
3
- import * as hoistNonReactStatics from 'hoist-non-react-statics';
4
-
5
- type WithOptionalTheme<P extends { theme?: T | undefined }, T> = OmitU<P, 'theme'> & {
6
- theme?: T | undefined;
7
- };
8
-
9
- // Helper type operators
10
- // Pick that distributes over union types
11
- export type PickU<T, K extends keyof T> = T extends any ? { [P in K]: T[P] } : never;
12
- export type OmitU<T, K extends keyof T> = T extends any ? PickU<T, Exclude<keyof T, K>> : never;
13
-
14
- // Any prop that has a default prop becomes optional, but its type is unchanged
15
- // Undeclared default props are augmented into the resulting allowable attributes
16
- // If declared props have indexed properties, ignore default props entirely as keyof gets widened
17
- // Wrap in an outer-level conditional type to allow distribution over props that are unions
18
- type Defaultize<P, D> = P extends any
19
- ? string extends keyof P
20
- ? P
21
- : PickU<P, Exclude<keyof P, keyof D>> &
22
- Partial<PickU<P, Extract<keyof P, keyof D>>> &
23
- Partial<PickU<D, Exclude<keyof D, keyof P>>>
24
- : never;
25
-
26
- export type IntrinsicElementsKeys = keyof React.JSX.IntrinsicElements;
27
- type ReactDefaultizedProps<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D> : P;
28
-
29
- type MakeAttrsOptional<
30
- C extends string | React.ComponentType<any>,
31
- O extends object,
32
- A extends keyof P,
33
- P = React.ComponentPropsWithRef<
34
- C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never
35
- >,
36
- > =
37
- // Distribute unions early to avoid quadratic expansion
38
- P extends any ? OmitU<ReactDefaultizedProps<C, P> & O, A> & Partial<PickU<P & O, A>> : never;
39
-
40
- export type StyledComponentProps<
41
- // The Component from whose props are derived
42
- C extends string | React.ComponentType<any>,
43
- // The Theme from the current context
44
- T extends object,
45
- // The other props added by the template
46
- O extends object,
47
- // The props that are made optional by .attrs
48
- A extends keyof any,
49
- // The Component passed with "forwardedAs" prop
50
- FAsC extends string | React.ComponentType<any> = C,
51
- > =
52
- // Distribute O if O is a union type
53
- O extends object
54
- ? WithOptionalTheme<MakeAttrsOptional<C, O, A> & MakeAttrsOptional<FAsC, O, A>, T>
55
- : never;
56
-
57
- export interface ThemeProps<T> {
58
- theme: T;
59
- }
60
-
61
- export type ThemedStyledProps<P, T> = P & ThemeProps<T>;
62
-
63
- export interface Keyframes {
64
- getName(): string;
65
- }
66
-
67
- export * from 'styled-components';
68
- export { default } from 'styled-components';
69
-
70
- export { default as StyledEngineProvider } from './StyledEngineProvider';
71
-
72
- export { default as GlobalStyles } from './GlobalStyles';
73
- export * from './GlobalStyles';
74
-
75
- /**
76
- * For internal usage in `@mui/system` package
77
- */
78
- // eslint-disable-next-line @typescript-eslint/naming-convention
79
- export function internal_mutateStyles(
80
- tag: React.ElementType,
81
- processor: (styles: any) => any,
82
- ): void;
83
-
84
- // Not needed anymore, but fixes https://github.com/mui/material-ui/issues/44112
85
- // TODO: Remove it in v7
86
- // eslint-disable-next-line @typescript-eslint/naming-convention
87
- export function internal_processStyles(
88
- tag: React.ElementType,
89
- processor: (styles: any) => any,
90
- ): void;
91
-
92
- // eslint-disable-next-line @typescript-eslint/naming-convention
93
- export function internal_serializeStyles<P>(styles: Interpolation<P>): object;
94
-
95
- // These are the same as the ones in @mui/styled-engine
96
- // CSS.PropertiesFallback are necessary so that we support spreading of the mixins. For example:
97
- // '@font-face'?: Fontface | Fontface[]
98
- export type CSSProperties = CSS.PropertiesFallback<number | string>;
99
- export type CSSPropertiesWithMultiValues = {
100
- [K in keyof CSSProperties]: CSSProperties[K] | Array<Extract<CSSProperties[K], string>>;
101
- };
102
- export type CSSPseudos = { [K in CSS.Pseudos]?: unknown | CSSObject };
103
-
104
- export interface CSSOthersObject {
105
- [propertiesName: string]: unknown | CSSInterpolation;
106
- }
107
- export type CSSPseudosForCSSObject = { [K in CSS.Pseudos]?: CSSObject };
108
-
109
- export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {}
110
-
111
- export interface CSSOthersObjectForCSSObject {
112
- [propertiesName: string]: CSSInterpolation;
113
- }
114
-
115
- // Omit variants as a key, because we have a special handling for it
116
- export interface CSSObject
117
- extends CSSPropertiesWithMultiValues,
118
- CSSPseudos,
119
- Omit<CSSOthersObject, 'variants'> {}
120
-
121
- interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
122
- variants: Array<{
123
- props: Props | ((props: Props) => boolean);
124
- style:
125
- | CSSObject
126
- | ((args: Props extends { theme: any } ? { theme: Props['theme'] } : any) => CSSObject);
127
- }>;
128
- }
129
-
130
- export type FalseyValue = undefined | null | false;
131
- export type Interpolation<P> =
132
- | InterpolationValue
133
- | CSSObjectWithVariants<P>
134
- | InterpolationFunction<P>
135
- | FlattenInterpolation<P>;
136
- // cannot be made a self-referential interface, breaks WithPropNested
137
- // see https://github.com/microsoft/TypeScript/issues/34796
138
- export type FlattenInterpolation<P> = ReadonlyArray<Interpolation<P>>;
139
- export type InterpolationValue =
140
- | string
141
- | number
142
- | FalseyValue
143
- | Keyframes
144
- | StyledComponentInterpolation
145
- | CSSObject;
146
- export type SimpleInterpolation = InterpolationValue | FlattenSimpleInterpolation;
147
- // adapter for compatibility with @mui/styled-engine
148
- export type CSSInterpolation = SimpleInterpolation;
149
- export type FlattenSimpleInterpolation = ReadonlyArray<SimpleInterpolation>;
150
-
151
- export type InterpolationFunction<P> = (props: P) => Interpolation<P>;
152
-
153
- // abuse Pick to strip the call signature from ForwardRefExoticComponent
154
- type ForwardRefExoticBase<P> = PickU<
155
- React.ForwardRefExoticComponent<P>,
156
- keyof React.ForwardRefExoticComponent<any>
157
- >;
158
-
159
- type StyledComponentPropsWithAs<
160
- C extends string | React.ComponentType<any>,
161
- T extends object,
162
- O extends object,
163
- A extends keyof any,
164
- AsC extends string | React.ComponentType<any> = C,
165
- FAsC extends string | React.ComponentType<any> = C,
166
- > = StyledComponentProps<C, T, O, A, FAsC> & {
167
- as?: AsC | undefined;
168
- forwardedAs?: FAsC | undefined;
169
- };
170
-
171
- export type StyledComponent<
172
- C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>,
173
- T extends object = {},
174
- O extends object = {},
175
- A extends keyof any = never,
176
- > = // the "string" allows this to be used as an object key
177
- // I really want to avoid this if possible but it's the only way to use nesting with object styles...
178
- string &
179
- StyledComponentBase<C, T, O, A> &
180
- hoistNonReactStatics.NonReactStatics<C extends React.ComponentType<any> ? C : never>;
181
-
182
- // any doesn't count as assignable to never in the extends clause, and we default A to never
183
- export type AnyStyledComponent =
184
- | StyledComponent<any, any, any, any>
185
- | StyledComponent<any, any, any>
186
- | React.FunctionComponent<any>
187
- | React.ComponentType<any>;
188
-
189
- export type StyledComponentInnerComponent<C extends AnyStyledComponent> =
190
- C extends StyledComponent<infer I, any, any, any>
191
- ? I
192
- : C extends StyledComponent<infer I, any, any>
193
- ? I
194
- : C;
195
-
196
- export type StyledComponentInnerOtherProps<C extends AnyStyledComponent> =
197
- C extends StyledComponent<any, any, infer O, any>
198
- ? O
199
- : C extends StyledComponent<any, any, infer O>
200
- ? O
201
- : never;
202
- export type StyledComponentInnerAttrs<C extends AnyStyledComponent> =
203
- C extends StyledComponent<any, any, any, infer A> ? A : never;
204
-
205
- export interface StyledComponentBase<
206
- C extends string | React.ComponentType<any>,
207
- T extends object,
208
- O extends object = {},
209
- A extends keyof any = never,
210
- > extends ForwardRefExoticBase<StyledComponentProps<C, T, O, A>> {
211
- // add our own fake call signature to implement the polymorphic 'as' prop
212
- (
213
- props: StyledComponentProps<C, T, O, A> & {
214
- as?: never | undefined;
215
- forwardedAs?: never | undefined;
216
- },
217
- ): React.ReactElement<StyledComponentProps<C, T, O, A>>;
218
- <
219
- AsC extends string | React.ComponentType<any> = C,
220
- FAsC extends string | React.ComponentType<any> = AsC,
221
- >(
222
- props: StyledComponentPropsWithAs<AsC, T, O, A, AsC, FAsC>,
223
- ): React.ReactElement<StyledComponentPropsWithAs<AsC, T, O, A, AsC, FAsC>>;
224
-
225
- withComponent<WithC extends AnyStyledComponent>(
226
- component: WithC,
227
- ): StyledComponent<
228
- StyledComponentInnerComponent<WithC>,
229
- T,
230
- O & StyledComponentInnerOtherProps<WithC>,
231
- A | StyledComponentInnerAttrs<WithC>
232
- >;
233
- withComponent<WithC extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>>(
234
- component: WithC,
235
- ): StyledComponent<WithC, T, O, A>;
236
- }
237
-
238
- // remove the call signature from StyledComponent so Interpolation can still infer InterpolationFunction
239
- type StyledComponentInterpolation =
240
- | Pick<StyledComponentBase<any, any, any, any>, keyof StyledComponentBase<any, any>>
241
- | Pick<StyledComponentBase<any, any, any>, keyof StyledComponentBase<any, any>>;
242
-
243
- // These are typings coming from styled-components
244
- // They are adjusted to accept the extended options coming from mui
245
- type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
246
-
247
- type ThemedStyledComponentFactories<T extends object> = {
248
- [TTag in keyof React.JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T>;
249
- };
250
-
251
- export type StyledComponentPropsWithRef<
252
- C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>,
253
- > = C extends AnyStyledComponent
254
- ? React.ComponentPropsWithRef<StyledComponentInnerComponent<C>>
255
- : React.ComponentPropsWithRef<C>;
256
-
257
- // Same as in styled-components, but copied here so that it would use the Interpolation & CSS typings from above
258
- export interface ThemedStyledFunctionBase<
259
- C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>,
260
- T extends object,
261
- O extends object = {},
262
- A extends keyof any = never,
263
- > {
264
- (first: TemplateStringsArray): StyledComponent<C, T, O, A>;
265
- (
266
- first:
267
- | TemplateStringsArray
268
- | CSSObject
269
- | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>,
270
- ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>>
271
- ): StyledComponent<C, T, O, A>;
272
- <U extends object>(
273
- first:
274
- | TemplateStringsArray
275
- | CSSObject
276
- | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>,
277
- ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>>
278
- ): StyledComponent<C, T, O & U, A>;
279
- }
280
-
281
- // same as ThemedStyledFunction in styled-components, but without attrs, and withConfig
282
- export interface ThemedStyledFunction<
283
- C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>,
284
- T extends object,
285
- O extends object = {},
286
- A extends keyof any = never,
287
- > extends ThemedStyledFunctionBase<C, T, O, A> {}
288
-
289
- export type CreateStyledComponent<
290
- ComponentProps extends {},
291
- SpecificComponentProps extends {} = {},
292
- JSXProps extends {} = {},
293
- T extends object = {},
294
- > = ThemedStyledFunction<React.ComponentType<ComponentProps>, T, SpecificComponentProps & JSXProps>;
295
-
296
- // Config to be used with withConfig
297
- export interface StyledConfig<O extends object = {}> {
298
- // TODO: Add all types from the original StyledComponentWrapperProperties
299
- componentId?: string;
300
- displayName?: string;
301
- label?: string;
302
- target?: string;
303
- shouldForwardProp?:
304
- | ((prop: keyof O, defaultValidatorFn: (prop: keyof O) => boolean) => boolean)
305
- | undefined;
306
- }
307
-
308
- /** Same as StyledConfig but shouldForwardProp must be a type guard */
309
- export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Props = keyof Props> {
310
- componentId?: string;
311
- displayName?: string;
312
- label?: string;
313
- shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps;
314
- target?: string;
315
- }
316
-
317
- // same as ThemedBaseStyledInterface in styled-components, but with added options & common props for MUI components
318
- export interface ThemedBaseStyledInterface<
319
- MUIStyledCommonProps extends object,
320
- MuiStyledOptions extends object,
321
- Theme extends object,
322
- > extends ThemedStyledComponentFactories<Theme> {
323
- <
324
- C extends React.ComponentClass<React.ComponentProps<C>>,
325
- ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>,
326
- >(
327
- component: C,
328
- options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps> & MuiStyledOptions,
329
- ): CreateStyledComponent<
330
- Pick<PropsOf<C>, ForwardedProps> & MUIStyledCommonProps,
331
- {},
332
- {
333
- ref?: React.Ref<InstanceType<C>>;
334
- },
335
- Theme
336
- >;
337
-
338
- <C extends React.ComponentClass<React.ComponentProps<C>>>(
339
- component: C,
340
- options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions,
341
- ): CreateStyledComponent<
342
- PropsOf<C> & MUIStyledCommonProps,
343
- {},
344
- {
345
- ref?: React.Ref<InstanceType<C>>;
346
- },
347
- Theme
348
- >;
349
-
350
- <
351
- C extends React.JSXElementConstructor<React.ComponentProps<C>>,
352
- ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>,
353
- >(
354
- component: C,
355
- options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps> & MuiStyledOptions,
356
- ): CreateStyledComponent<Pick<PropsOf<C>, ForwardedProps> & MUIStyledCommonProps, {}, {}, Theme>;
357
-
358
- <C extends React.JSXElementConstructor<React.ComponentProps<C>>>(
359
- component: C,
360
- options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions,
361
- ): CreateStyledComponent<PropsOf<C> & MUIStyledCommonProps, {}, {}, Theme>;
362
-
363
- <
364
- Tag extends keyof React.JSX.IntrinsicElements,
365
- ForwardedProps extends
366
- keyof React.JSX.IntrinsicElements[Tag] = keyof React.JSX.IntrinsicElements[Tag],
367
- >(
368
- tag: Tag,
369
- options: FilteringStyledOptions<React.JSX.IntrinsicElements[Tag], ForwardedProps> &
370
- MuiStyledOptions,
371
- ): CreateStyledComponent<
372
- MUIStyledCommonProps,
373
- Pick<React.JSX.IntrinsicElements[Tag], ForwardedProps>,
374
- {},
375
- Theme
376
- >;
377
-
378
- <Tag extends keyof React.JSX.IntrinsicElements>(
379
- tag: Tag,
380
- options?: StyledConfig<MUIStyledCommonProps> & MuiStyledOptions,
381
- ): CreateStyledComponent<MUIStyledCommonProps, React.JSX.IntrinsicElements[Tag], {}, Theme>;
382
- }
383
-
384
- export type CreateMUIStyled<
385
- MUIStyledCommonProps extends object = {},
386
- MuiStyledOptions extends object = {},
387
- T extends object = {},
388
- > = ThemedBaseStyledInterface<MUIStyledCommonProps, MuiStyledOptions, AnyIfEmpty<T>>;
389
-
390
- export type PropsOf<
391
- C extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>,
392
- > = React.JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>;
393
-
394
- export interface MUIStyledComponent<
395
- ComponentProps extends {},
396
- SpecificComponentProps extends {} = {},
397
- JSXProps extends {} = {},
398
- > extends React.FC<ComponentProps & SpecificComponentProps & JSXProps> {
399
- withComponent<C extends React.ComponentClass<React.ComponentProps<C>>>(
400
- component: C,
401
- ): MUIStyledComponent<ComponentProps & PropsOf<C>, {}, { ref?: React.Ref<InstanceType<C>> }>;
402
- withComponent<C extends React.ComponentType<React.ComponentProps<C>>>(
403
- component: C,
404
- ): MUIStyledComponent<ComponentProps & PropsOf<C>>;
405
- withComponent<Tag extends keyof React.JSX.IntrinsicElements>(
406
- tag: Tag,
407
- ): MUIStyledComponent<ComponentProps, React.JSX.IntrinsicElements[Tag]>;
408
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _styledComponents = require("styled-components");
10
- function isEmpty(obj) {
11
- return obj === undefined || obj === null || Object.keys(obj).length === 0;
12
- }
13
- const GlobalStyles = (0, _styledComponents.createGlobalStyle)(props => {
14
- const {
15
- styles,
16
- defaultTheme = {}
17
- } = props;
18
- if (typeof styles === 'function') {
19
- return styles(isEmpty(props.theme) ? defaultTheme : props.theme);
20
- }
21
- return styles;
22
- });
23
- var _default = exports.default = GlobalStyles;
24
- GlobalStyles.propTypes = {
25
- defaultTheme: _propTypes.default.object,
26
- styles: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.string, _propTypes.default.object, _propTypes.default.func])
27
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "default", {
8
- enumerable: true,
9
- get: function () {
10
- return _GlobalStyles.default;
11
- }
12
- });
13
- var _GlobalStyles = _interopRequireDefault(require("./GlobalStyles"));
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "default", {
8
- enumerable: true,
9
- get: function () {
10
- return _StyledEngineProvider.default;
11
- }
12
- });
13
- var _StyledEngineProvider = _interopRequireDefault(require("./StyledEngineProvider"));