@mui/styled-engine-sc 9.0.0 → 9.1.0

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.
@@ -1,7 +1,8 @@
1
- import * as React from 'react';
2
- import { CSSObject, StyleFunction } from 'styled-components';
1
+ import type * as React from 'react';
2
+ import { type CSSObject, type StyleFunction } from 'styled-components';
3
3
  export interface GlobalStylesProps<Theme extends object = {}> {
4
4
  defaultTheme?: object | undefined;
5
5
  styles: string | CSSObject | StyleFunction<Theme>;
6
6
  }
7
- export default function Global<Theme extends object = {}>(props: GlobalStylesProps<Theme>): React.JSX.Element;
7
+ declare const GlobalStyles: <Theme extends object = {}>(props: GlobalStylesProps<Theme>) => React.JSX.Element;
8
+ export default GlobalStyles;
@@ -1,7 +1,8 @@
1
- import * as React from 'react';
2
- import { CSSObject, StyleFunction } from 'styled-components';
1
+ import type * as React from 'react';
2
+ import { type CSSObject, type StyleFunction } from 'styled-components';
3
3
  export interface GlobalStylesProps<Theme extends object = {}> {
4
4
  defaultTheme?: object | undefined;
5
5
  styles: string | CSSObject | StyleFunction<Theme>;
6
6
  }
7
- export default function Global<Theme extends object = {}>(props: GlobalStylesProps<Theme>): React.JSX.Element;
7
+ declare const GlobalStyles: <Theme extends object = {}>(props: GlobalStylesProps<Theme>) => React.JSX.Element;
8
+ export default GlobalStyles;
@@ -21,7 +21,7 @@ const GlobalStyles = (0, _styledComponents.createGlobalStyle)(props => {
21
21
  return styles;
22
22
  });
23
23
  var _default = exports.default = GlobalStyles;
24
- GlobalStyles.propTypes = {
24
+ process.env.NODE_ENV !== "production" ? GlobalStyles.propTypes /* remove-proptypes */ = {
25
25
  defaultTheme: _propTypes.default.object,
26
26
  styles: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.string, _propTypes.default.object, _propTypes.default.func])
27
- };
27
+ } : void 0;
@@ -14,7 +14,7 @@ const GlobalStyles = createGlobalStyle(props => {
14
14
  return styles;
15
15
  });
16
16
  export default GlobalStyles;
17
- GlobalStyles.propTypes = {
17
+ process.env.NODE_ENV !== "production" ? GlobalStyles.propTypes /* remove-proptypes */ = {
18
18
  defaultTheme: PropTypes.object,
19
19
  styles: PropTypes.oneOfType([PropTypes.array, PropTypes.string, PropTypes.object, PropTypes.func])
20
- };
20
+ } : void 0;
@@ -1,2 +1,2 @@
1
1
  export { default } from "./GlobalStyles.mjs";
2
- export * from "./GlobalStyles.mjs";
2
+ export type * from "./GlobalStyles.mjs";
@@ -1,2 +1,2 @@
1
1
  export { default } from "./GlobalStyles.js";
2
- export * from "./GlobalStyles.js";
2
+ export type * from "./GlobalStyles.js";
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
3
  Copyright (c) 2014 Call-Em-All
4
4
 
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import type * as React from 'react';
2
2
  export interface StyledEngineProviderProps {
3
3
  children?: React.ReactNode;
4
4
  injectFirst?: boolean | undefined;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import type * as React from 'react';
2
2
  export interface StyledEngineProviderProps {
3
3
  children?: React.ReactNode;
4
4
  injectFirst?: boolean | undefined;
@@ -21,7 +21,7 @@ function StyledEngineProvider(props) {
21
21
  }
22
22
  return children;
23
23
  }
24
- StyledEngineProvider.propTypes = {
24
+ process.env.NODE_ENV !== "production" ? StyledEngineProvider.propTypes /* remove-proptypes */ = {
25
25
  /**
26
26
  * Your component tree.
27
27
  */
@@ -32,4 +32,4 @@ StyledEngineProvider.propTypes = {
32
32
  * If you want to override MUI's styles, set this prop.
33
33
  */
34
34
  injectFirst: _propTypes.default.bool
35
- };
35
+ } : void 0;
@@ -14,7 +14,7 @@ export default function StyledEngineProvider(props) {
14
14
  }
15
15
  return children;
16
16
  }
17
- StyledEngineProvider.propTypes = {
17
+ process.env.NODE_ENV !== "production" ? StyledEngineProvider.propTypes /* remove-proptypes */ = {
18
18
  /**
19
19
  * Your component tree.
20
20
  */
@@ -25,4 +25,4 @@ StyledEngineProvider.propTypes = {
25
25
  * If you want to override MUI's styles, set this prop.
26
26
  */
27
27
  injectFirst: PropTypes.bool
28
- };
28
+ } : void 0;
@@ -1,2 +1,2 @@
1
1
  export { default } from "./StyledEngineProvider.mjs";
2
- export * from "./StyledEngineProvider.mjs";
2
+ export type * from "./StyledEngineProvider.mjs";
@@ -1,2 +1,2 @@
1
1
  export { default } from "./StyledEngineProvider.js";
2
- export * from "./StyledEngineProvider.js";
2
+ export type * from "./StyledEngineProvider.js";
package/index.d.mts CHANGED
@@ -1,42 +1,22 @@
1
- import * as React from 'react';
2
- import * as CSS from 'csstype';
3
- import * as hoistNonReactStatics from 'hoist-non-react-statics';
1
+ import { styled as scStyled } from 'styled-components';
2
+ import type * as React from 'react';
3
+ import type * as CSS from 'csstype';
4
+ import type * as hoistNonReactStatics from 'hoist-non-react-statics';
5
+ export type * from 'styled-components';
4
6
  type WithOptionalTheme<P extends {
5
7
  theme?: T | undefined;
6
8
  }, T> = OmitU<P, 'theme'> & {
7
9
  theme?: T | undefined;
8
10
  };
9
-
10
- // Helper type operators
11
- // Pick that distributes over union types
12
11
  export type PickU<T, K extends keyof T> = T extends any ? { [P in K]: T[P] } : never;
13
12
  export type OmitU<T, K extends keyof T> = T extends any ? PickU<T, Exclude<keyof T, K>> : never;
14
-
15
- // Any prop that has a default prop becomes optional, but its type is unchanged
16
- // Undeclared default props are augmented into the resulting allowable attributes
17
- // If declared props have indexed properties, ignore default props entirely as keyof gets widened
18
- // Wrap in an outer-level conditional type to allow distribution over props that are unions
19
13
  type Defaultize<P, D> = P extends any ? string extends keyof P ? P : PickU<P, Exclude<keyof P, keyof D>> & Partial<PickU<P, Extract<keyof P, keyof D>>> & Partial<PickU<D, Exclude<keyof D, keyof P>>> : never;
20
14
  export type IntrinsicElementsKeys = keyof React.JSX.IntrinsicElements;
21
15
  type ReactDefaultizedProps<C, P> = C extends {
22
16
  defaultProps: infer D;
23
17
  } ? Defaultize<P, D> : P;
24
- type MakeAttrsOptional<C extends string | React.ComponentType<any>, O extends object, A extends keyof P, P = React.ComponentPropsWithRef<C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never>> =
25
- // Distribute unions early to avoid quadratic expansion
26
- P extends any ? OmitU<ReactDefaultizedProps<C, P> & O, A> & Partial<PickU<P & O, A>> : never;
27
- export type StyledComponentProps<
28
- // The Component from whose props are derived
29
- C extends string | React.ComponentType<any>,
30
- // The Theme from the current context
31
- T extends object,
32
- // The other props added by the template
33
- O extends object,
34
- // The props that are made optional by .attrs
35
- A extends keyof any,
36
- // The Component passed with "forwardedAs" prop
37
- FAsC extends string | React.ComponentType<any> = C> =
38
- // Distribute O if O is a union type
39
- O extends object ? WithOptionalTheme<MakeAttrsOptional<C, O, A> & MakeAttrsOptional<FAsC, O, A>, T> : never;
18
+ type MakeAttrsOptional<C extends string | React.ComponentType<any>, O extends object, A extends keyof P, P = React.ComponentPropsWithRef<C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never>> = P extends any ? OmitU<ReactDefaultizedProps<C, P> & O, A> & Partial<PickU<P & O, A>> : never;
19
+ export type StyledComponentProps<C extends string | React.ComponentType<any>, T extends object, O extends object, A extends keyof any, FAsC extends string | React.ComponentType<any> = C> = O extends object ? WithOptionalTheme<MakeAttrsOptional<C, O, A> & MakeAttrsOptional<FAsC, O, A>, T> : never;
40
20
  export interface ThemeProps<T> {
41
21
  theme: T;
42
22
  }
@@ -44,29 +24,18 @@ export type ThemedStyledProps<P, T> = P & ThemeProps<T>;
44
24
  export interface Keyframes {
45
25
  getName(): string;
46
26
  }
47
- export * from 'styled-components';
48
- export { default } from 'styled-components';
49
- export { default as StyledEngineProvider } from "./StyledEngineProvider/index.mjs";
50
- export { default as GlobalStyles } from "./GlobalStyles/index.mjs";
51
- export * from "./GlobalStyles/index.mjs";
52
-
27
+ declare const _default: typeof scStyled;
28
+ export default _default;
53
29
  /**
54
30
  * For internal usage in `@mui/system` package
55
31
  */
56
- // eslint-disable-next-line @typescript-eslint/naming-convention
57
- export function internal_mutateStyles(tag: React.ElementType, processor: (styles: any) => any): void;
58
-
59
- // Not needed anymore, but fixes https://github.com/mui/material-ui/issues/44112
60
- // TODO: Remove it in v7
61
- // eslint-disable-next-line @typescript-eslint/naming-convention
62
- export function internal_processStyles(tag: React.ElementType, processor: (styles: any) => any): void;
63
-
64
- // eslint-disable-next-line @typescript-eslint/naming-convention
65
- export function internal_serializeStyles<P>(styles: Interpolation<P>): object;
66
-
67
- // These are the same as the ones in @mui/styled-engine
68
- // CSS.PropertiesFallback are necessary so that we support spreading of the mixins. For example:
69
- // '@font-face'?: Fontface | Fontface[]
32
+ export declare function internal_mutateStyles(tag: React.ElementType, processor: (styles: any) => any): void;
33
+ export declare function internal_processStyles(tag: React.ElementType, processor: (styles: any) => any): void;
34
+ export declare function internal_serializeStyles<P>(styles: Interpolation<P>): object;
35
+ export { ThemeContext, keyframes, css } from 'styled-components';
36
+ export { default as StyledEngineProvider } from "./StyledEngineProvider/index.mjs";
37
+ export { default as GlobalStyles } from "./GlobalStyles/index.mjs";
38
+ export type { GlobalStylesProps } from "./GlobalStyles/index.mjs";
70
39
  export type CSSProperties = CSS.PropertiesFallback<number | string>;
71
40
  export type CSSPropertiesWithMultiValues = { [K in keyof CSSProperties]: CSSProperties[K] | Array<Extract<CSSProperties[K], string>> };
72
41
  export type CSSPseudos = { [K in CSS.Pseudos]?: unknown | CSSObject };
@@ -78,8 +47,6 @@ export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {}
78
47
  export interface CSSOthersObjectForCSSObject {
79
48
  [propertiesName: string]: CSSInterpolation;
80
49
  }
81
-
82
- // Omit variants as a key, because we have a special handling for it
83
50
  export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, Omit<CSSOthersObject, 'variants'> {}
84
51
  interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
85
52
  variants: Array<{
@@ -93,17 +60,12 @@ interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
93
60
  }
94
61
  export type FalseyValue = undefined | null | false;
95
62
  export type Interpolation<P> = InterpolationValue | CSSObjectWithVariants<P> | InterpolationFunction<P> | FlattenInterpolation<P>;
96
- // cannot be made a self-referential interface, breaks WithPropNested
97
- // see https://github.com/microsoft/TypeScript/issues/34796
98
63
  export type FlattenInterpolation<P> = ReadonlyArray<Interpolation<P>>;
99
64
  export type InterpolationValue = string | number | FalseyValue | Keyframes | StyledComponentInterpolation | CSSObject;
100
65
  export type SimpleInterpolation = InterpolationValue | FlattenSimpleInterpolation;
101
- // adapter for compatibility with @mui/styled-engine
102
66
  export type CSSInterpolation = SimpleInterpolation;
103
67
  export type FlattenSimpleInterpolation = ReadonlyArray<SimpleInterpolation>;
104
68
  export type InterpolationFunction<P> = (props: P) => Interpolation<P>;
105
-
106
- // abuse Pick to strip the call signature from ForwardRefExoticComponent
107
69
  type ForwardRefExoticBase<P> = PickU<React.ForwardRefExoticComponent<P>, keyof React.ForwardRefExoticComponent<any>>;
108
70
  type StyledComponentPropsWithAs<C extends string | React.ComponentType<any>, T extends object, O extends object, A extends keyof any, AsC extends string | React.ComponentType<any> = C, FAsC extends string | React.ComponentType<any> = C> = StyledComponentProps<C, T, O, A, FAsC> & {
109
71
  as?: AsC | undefined;
@@ -111,16 +73,12 @@ type StyledComponentPropsWithAs<C extends string | React.ComponentType<any>, T e
111
73
  };
112
74
  export type StyledComponent<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object = {}, O extends object = {}, A extends keyof any = never> =
113
75
  // the "string" allows this to be used as an object key
114
- // I really want to avoid this if possible but it's the only way to use nesting with object styles...
115
76
  string & StyledComponentBase<C, T, O, A> & hoistNonReactStatics.NonReactStatics<C extends React.ComponentType<any> ? C : never>;
116
-
117
- // any doesn't count as assignable to never in the extends clause, and we default A to never
118
77
  export type AnyStyledComponent = StyledComponent<any, any, any, any> | StyledComponent<any, any, any> | React.FunctionComponent<any> | React.ComponentType<any>;
119
78
  export type StyledComponentInnerComponent<C extends AnyStyledComponent> = C extends StyledComponent<infer I, any, any, any> ? I : C extends StyledComponent<infer I, any, any> ? I : C;
120
79
  export type StyledComponentInnerOtherProps<C extends AnyStyledComponent> = C extends StyledComponent<any, any, infer O, any> ? O : C extends StyledComponent<any, any, infer O> ? O : never;
121
80
  export type StyledComponentInnerAttrs<C extends AnyStyledComponent> = C extends StyledComponent<any, any, any, infer A> ? A : never;
122
81
  export interface StyledComponentBase<C extends string | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> extends ForwardRefExoticBase<StyledComponentProps<C, T, O, A>> {
123
- // add our own fake call signature to implement the polymorphic 'as' prop
124
82
  (props: StyledComponentProps<C, T, O, A> & {
125
83
  as?: never | undefined;
126
84
  forwardedAs?: never | undefined;
@@ -129,37 +87,24 @@ export interface StyledComponentBase<C extends string | React.ComponentType<any>
129
87
  withComponent<WithC extends AnyStyledComponent>(component: WithC): StyledComponent<StyledComponentInnerComponent<WithC>, T, O & StyledComponentInnerOtherProps<WithC>, A | StyledComponentInnerAttrs<WithC>>;
130
88
  withComponent<WithC extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>>(component: WithC): StyledComponent<WithC, T, O, A>;
131
89
  }
132
-
133
- // remove the call signature from StyledComponent so Interpolation can still infer InterpolationFunction
134
90
  type StyledComponentInterpolation = Pick<StyledComponentBase<any, any, any, any>, keyof StyledComponentBase<any, any>> | Pick<StyledComponentBase<any, any, any>, keyof StyledComponentBase<any, any>>;
135
-
136
- // These are typings coming from styled-components
137
- // They are adjusted to accept the extended options coming from mui
138
91
  type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
139
92
  type ThemedStyledComponentFactories<T extends object> = { [TTag in keyof React.JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T> };
140
93
  export type StyledComponentPropsWithRef<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>> = C extends AnyStyledComponent ? React.ComponentPropsWithRef<StyledComponentInnerComponent<C>> : React.ComponentPropsWithRef<C>;
141
-
142
- // Same as in styled-components, but copied here so that it would use the Interpolation & CSS typings from above
143
94
  export interface ThemedStyledFunctionBase<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> {
144
95
  (first: TemplateStringsArray): StyledComponent<C, T, O, A>;
145
96
  (first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>, ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>>): StyledComponent<C, T, O, A>;
146
97
  <U extends object>(first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>, ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>>): StyledComponent<C, T, O & U, A>;
147
98
  }
148
-
149
- // same as ThemedStyledFunction in styled-components, but without attrs, and withConfig
150
99
  export interface ThemedStyledFunction<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> extends ThemedStyledFunctionBase<C, T, O, A> {}
151
100
  export type CreateStyledComponent<ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {}, T extends object = {}> = ThemedStyledFunction<React.ComponentType<ComponentProps>, T, SpecificComponentProps & JSXProps>;
152
-
153
- // Config to be used with withConfig
154
101
  export interface StyledConfig<O extends object = {}> {
155
- // TODO: Add all types from the original StyledComponentWrapperProperties
156
102
  componentId?: string | undefined;
157
103
  displayName?: string | undefined;
158
104
  label?: string | undefined;
159
105
  target?: string | undefined;
160
106
  shouldForwardProp?: ((prop: keyof O, defaultValidatorFn: (prop: keyof O) => boolean) => boolean) | undefined;
161
107
  }
162
-
163
108
  /** Same as StyledConfig but shouldForwardProp must be a type guard */
164
109
  export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Props = keyof Props> {
165
110
  componentId?: string | undefined;
@@ -168,8 +113,6 @@ export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Prop
168
113
  shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps;
169
114
  target?: string | undefined;
170
115
  }
171
-
172
- // same as ThemedBaseStyledInterface in styled-components, but with added options & common props for MUI components
173
116
  export interface ThemedBaseStyledInterface<MUIStyledCommonProps extends object, MuiStyledOptions extends object, Theme extends object> extends ThemedStyledComponentFactories<Theme> {
174
117
  <C extends React.ComponentClass<React.ComponentProps<C>>, ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>>(component: C, options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps> & MuiStyledOptions): CreateStyledComponent<Pick<PropsOf<C>, ForwardedProps> & MUIStyledCommonProps, {}, {
175
118
  ref?: React.Ref<InstanceType<C>> | undefined;
package/index.d.ts CHANGED
@@ -1,42 +1,22 @@
1
- import * as React from 'react';
2
- import * as CSS from 'csstype';
3
- import * as hoistNonReactStatics from 'hoist-non-react-statics';
1
+ import { styled as scStyled } from 'styled-components';
2
+ import type * as React from 'react';
3
+ import type * as CSS from 'csstype';
4
+ import type * as hoistNonReactStatics from 'hoist-non-react-statics';
5
+ export type * from 'styled-components';
4
6
  type WithOptionalTheme<P extends {
5
7
  theme?: T | undefined;
6
8
  }, T> = OmitU<P, 'theme'> & {
7
9
  theme?: T | undefined;
8
10
  };
9
-
10
- // Helper type operators
11
- // Pick that distributes over union types
12
11
  export type PickU<T, K extends keyof T> = T extends any ? { [P in K]: T[P] } : never;
13
12
  export type OmitU<T, K extends keyof T> = T extends any ? PickU<T, Exclude<keyof T, K>> : never;
14
-
15
- // Any prop that has a default prop becomes optional, but its type is unchanged
16
- // Undeclared default props are augmented into the resulting allowable attributes
17
- // If declared props have indexed properties, ignore default props entirely as keyof gets widened
18
- // Wrap in an outer-level conditional type to allow distribution over props that are unions
19
13
  type Defaultize<P, D> = P extends any ? string extends keyof P ? P : PickU<P, Exclude<keyof P, keyof D>> & Partial<PickU<P, Extract<keyof P, keyof D>>> & Partial<PickU<D, Exclude<keyof D, keyof P>>> : never;
20
14
  export type IntrinsicElementsKeys = keyof React.JSX.IntrinsicElements;
21
15
  type ReactDefaultizedProps<C, P> = C extends {
22
16
  defaultProps: infer D;
23
17
  } ? Defaultize<P, D> : P;
24
- type MakeAttrsOptional<C extends string | React.ComponentType<any>, O extends object, A extends keyof P, P = React.ComponentPropsWithRef<C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never>> =
25
- // Distribute unions early to avoid quadratic expansion
26
- P extends any ? OmitU<ReactDefaultizedProps<C, P> & O, A> & Partial<PickU<P & O, A>> : never;
27
- export type StyledComponentProps<
28
- // The Component from whose props are derived
29
- C extends string | React.ComponentType<any>,
30
- // The Theme from the current context
31
- T extends object,
32
- // The other props added by the template
33
- O extends object,
34
- // The props that are made optional by .attrs
35
- A extends keyof any,
36
- // The Component passed with "forwardedAs" prop
37
- FAsC extends string | React.ComponentType<any> = C> =
38
- // Distribute O if O is a union type
39
- O extends object ? WithOptionalTheme<MakeAttrsOptional<C, O, A> & MakeAttrsOptional<FAsC, O, A>, T> : never;
18
+ type MakeAttrsOptional<C extends string | React.ComponentType<any>, O extends object, A extends keyof P, P = React.ComponentPropsWithRef<C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never>> = P extends any ? OmitU<ReactDefaultizedProps<C, P> & O, A> & Partial<PickU<P & O, A>> : never;
19
+ export type StyledComponentProps<C extends string | React.ComponentType<any>, T extends object, O extends object, A extends keyof any, FAsC extends string | React.ComponentType<any> = C> = O extends object ? WithOptionalTheme<MakeAttrsOptional<C, O, A> & MakeAttrsOptional<FAsC, O, A>, T> : never;
40
20
  export interface ThemeProps<T> {
41
21
  theme: T;
42
22
  }
@@ -44,29 +24,18 @@ export type ThemedStyledProps<P, T> = P & ThemeProps<T>;
44
24
  export interface Keyframes {
45
25
  getName(): string;
46
26
  }
47
- export * from 'styled-components';
48
- export { default } from 'styled-components';
49
- export { default as StyledEngineProvider } from "./StyledEngineProvider/index.js";
50
- export { default as GlobalStyles } from "./GlobalStyles/index.js";
51
- export * from "./GlobalStyles/index.js";
52
-
27
+ declare const _default: typeof scStyled;
28
+ export default _default;
53
29
  /**
54
30
  * For internal usage in `@mui/system` package
55
31
  */
56
- // eslint-disable-next-line @typescript-eslint/naming-convention
57
- export function internal_mutateStyles(tag: React.ElementType, processor: (styles: any) => any): void;
58
-
59
- // Not needed anymore, but fixes https://github.com/mui/material-ui/issues/44112
60
- // TODO: Remove it in v7
61
- // eslint-disable-next-line @typescript-eslint/naming-convention
62
- export function internal_processStyles(tag: React.ElementType, processor: (styles: any) => any): void;
63
-
64
- // eslint-disable-next-line @typescript-eslint/naming-convention
65
- export function internal_serializeStyles<P>(styles: Interpolation<P>): object;
66
-
67
- // These are the same as the ones in @mui/styled-engine
68
- // CSS.PropertiesFallback are necessary so that we support spreading of the mixins. For example:
69
- // '@font-face'?: Fontface | Fontface[]
32
+ export declare function internal_mutateStyles(tag: React.ElementType, processor: (styles: any) => any): void;
33
+ export declare function internal_processStyles(tag: React.ElementType, processor: (styles: any) => any): void;
34
+ export declare function internal_serializeStyles<P>(styles: Interpolation<P>): object;
35
+ export { ThemeContext, keyframes, css } from 'styled-components';
36
+ export { default as StyledEngineProvider } from "./StyledEngineProvider/index.js";
37
+ export { default as GlobalStyles } from "./GlobalStyles/index.js";
38
+ export type { GlobalStylesProps } from "./GlobalStyles/index.js";
70
39
  export type CSSProperties = CSS.PropertiesFallback<number | string>;
71
40
  export type CSSPropertiesWithMultiValues = { [K in keyof CSSProperties]: CSSProperties[K] | Array<Extract<CSSProperties[K], string>> };
72
41
  export type CSSPseudos = { [K in CSS.Pseudos]?: unknown | CSSObject };
@@ -78,8 +47,6 @@ export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {}
78
47
  export interface CSSOthersObjectForCSSObject {
79
48
  [propertiesName: string]: CSSInterpolation;
80
49
  }
81
-
82
- // Omit variants as a key, because we have a special handling for it
83
50
  export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, Omit<CSSOthersObject, 'variants'> {}
84
51
  interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
85
52
  variants: Array<{
@@ -93,17 +60,12 @@ interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
93
60
  }
94
61
  export type FalseyValue = undefined | null | false;
95
62
  export type Interpolation<P> = InterpolationValue | CSSObjectWithVariants<P> | InterpolationFunction<P> | FlattenInterpolation<P>;
96
- // cannot be made a self-referential interface, breaks WithPropNested
97
- // see https://github.com/microsoft/TypeScript/issues/34796
98
63
  export type FlattenInterpolation<P> = ReadonlyArray<Interpolation<P>>;
99
64
  export type InterpolationValue = string | number | FalseyValue | Keyframes | StyledComponentInterpolation | CSSObject;
100
65
  export type SimpleInterpolation = InterpolationValue | FlattenSimpleInterpolation;
101
- // adapter for compatibility with @mui/styled-engine
102
66
  export type CSSInterpolation = SimpleInterpolation;
103
67
  export type FlattenSimpleInterpolation = ReadonlyArray<SimpleInterpolation>;
104
68
  export type InterpolationFunction<P> = (props: P) => Interpolation<P>;
105
-
106
- // abuse Pick to strip the call signature from ForwardRefExoticComponent
107
69
  type ForwardRefExoticBase<P> = PickU<React.ForwardRefExoticComponent<P>, keyof React.ForwardRefExoticComponent<any>>;
108
70
  type StyledComponentPropsWithAs<C extends string | React.ComponentType<any>, T extends object, O extends object, A extends keyof any, AsC extends string | React.ComponentType<any> = C, FAsC extends string | React.ComponentType<any> = C> = StyledComponentProps<C, T, O, A, FAsC> & {
109
71
  as?: AsC | undefined;
@@ -111,16 +73,12 @@ type StyledComponentPropsWithAs<C extends string | React.ComponentType<any>, T e
111
73
  };
112
74
  export type StyledComponent<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object = {}, O extends object = {}, A extends keyof any = never> =
113
75
  // the "string" allows this to be used as an object key
114
- // I really want to avoid this if possible but it's the only way to use nesting with object styles...
115
76
  string & StyledComponentBase<C, T, O, A> & hoistNonReactStatics.NonReactStatics<C extends React.ComponentType<any> ? C : never>;
116
-
117
- // any doesn't count as assignable to never in the extends clause, and we default A to never
118
77
  export type AnyStyledComponent = StyledComponent<any, any, any, any> | StyledComponent<any, any, any> | React.FunctionComponent<any> | React.ComponentType<any>;
119
78
  export type StyledComponentInnerComponent<C extends AnyStyledComponent> = C extends StyledComponent<infer I, any, any, any> ? I : C extends StyledComponent<infer I, any, any> ? I : C;
120
79
  export type StyledComponentInnerOtherProps<C extends AnyStyledComponent> = C extends StyledComponent<any, any, infer O, any> ? O : C extends StyledComponent<any, any, infer O> ? O : never;
121
80
  export type StyledComponentInnerAttrs<C extends AnyStyledComponent> = C extends StyledComponent<any, any, any, infer A> ? A : never;
122
81
  export interface StyledComponentBase<C extends string | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> extends ForwardRefExoticBase<StyledComponentProps<C, T, O, A>> {
123
- // add our own fake call signature to implement the polymorphic 'as' prop
124
82
  (props: StyledComponentProps<C, T, O, A> & {
125
83
  as?: never | undefined;
126
84
  forwardedAs?: never | undefined;
@@ -129,37 +87,24 @@ export interface StyledComponentBase<C extends string | React.ComponentType<any>
129
87
  withComponent<WithC extends AnyStyledComponent>(component: WithC): StyledComponent<StyledComponentInnerComponent<WithC>, T, O & StyledComponentInnerOtherProps<WithC>, A | StyledComponentInnerAttrs<WithC>>;
130
88
  withComponent<WithC extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>>(component: WithC): StyledComponent<WithC, T, O, A>;
131
89
  }
132
-
133
- // remove the call signature from StyledComponent so Interpolation can still infer InterpolationFunction
134
90
  type StyledComponentInterpolation = Pick<StyledComponentBase<any, any, any, any>, keyof StyledComponentBase<any, any>> | Pick<StyledComponentBase<any, any, any>, keyof StyledComponentBase<any, any>>;
135
-
136
- // These are typings coming from styled-components
137
- // They are adjusted to accept the extended options coming from mui
138
91
  type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
139
92
  type ThemedStyledComponentFactories<T extends object> = { [TTag in keyof React.JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T> };
140
93
  export type StyledComponentPropsWithRef<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>> = C extends AnyStyledComponent ? React.ComponentPropsWithRef<StyledComponentInnerComponent<C>> : React.ComponentPropsWithRef<C>;
141
-
142
- // Same as in styled-components, but copied here so that it would use the Interpolation & CSS typings from above
143
94
  export interface ThemedStyledFunctionBase<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> {
144
95
  (first: TemplateStringsArray): StyledComponent<C, T, O, A>;
145
96
  (first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>, ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>>): StyledComponent<C, T, O, A>;
146
97
  <U extends object>(first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>, ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>>): StyledComponent<C, T, O & U, A>;
147
98
  }
148
-
149
- // same as ThemedStyledFunction in styled-components, but without attrs, and withConfig
150
99
  export interface ThemedStyledFunction<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> extends ThemedStyledFunctionBase<C, T, O, A> {}
151
100
  export type CreateStyledComponent<ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {}, T extends object = {}> = ThemedStyledFunction<React.ComponentType<ComponentProps>, T, SpecificComponentProps & JSXProps>;
152
-
153
- // Config to be used with withConfig
154
101
  export interface StyledConfig<O extends object = {}> {
155
- // TODO: Add all types from the original StyledComponentWrapperProperties
156
102
  componentId?: string | undefined;
157
103
  displayName?: string | undefined;
158
104
  label?: string | undefined;
159
105
  target?: string | undefined;
160
106
  shouldForwardProp?: ((prop: keyof O, defaultValidatorFn: (prop: keyof O) => boolean) => boolean) | undefined;
161
107
  }
162
-
163
108
  /** Same as StyledConfig but shouldForwardProp must be a type guard */
164
109
  export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Props = keyof Props> {
165
110
  componentId?: string | undefined;
@@ -168,8 +113,6 @@ export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Prop
168
113
  shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps;
169
114
  target?: string | undefined;
170
115
  }
171
-
172
- // same as ThemedBaseStyledInterface in styled-components, but with added options & common props for MUI components
173
116
  export interface ThemedBaseStyledInterface<MUIStyledCommonProps extends object, MuiStyledOptions extends object, Theme extends object> extends ThemedStyledComponentFactories<Theme> {
174
117
  <C extends React.ComponentClass<React.ComponentProps<C>>, ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>>(component: C, options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps> & MuiStyledOptions): CreateStyledComponent<Pick<PropsOf<C>, ForwardedProps> & MUIStyledCommonProps, {}, {
175
118
  ref?: React.Ref<InstanceType<C>> | undefined;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine-sc v9.0.0
2
+ * @mui/styled-engine-sc v9.1.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -8,7 +8,6 @@
8
8
  "use strict";
9
9
 
10
10
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
11
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
12
11
  Object.defineProperty(exports, "__esModule", {
13
12
  value: true
14
13
  });
@@ -36,7 +35,7 @@ Object.defineProperty(exports, "css", {
36
35
  return _styledComponents.css;
37
36
  }
38
37
  });
39
- exports.default = styled;
38
+ exports.default = void 0;
40
39
  exports.internal_mutateStyles = internal_mutateStyles;
41
40
  exports.internal_processStyles = internal_processStyles;
42
41
  exports.internal_serializeStyles = internal_serializeStyles;
@@ -46,18 +45,34 @@ Object.defineProperty(exports, "keyframes", {
46
45
  return _styledComponents.keyframes;
47
46
  }
48
47
  });
49
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
48
+ var _styledComponents = require("styled-components");
50
49
  var _StyledEngineProvider = _interopRequireDefault(require("./StyledEngineProvider"));
51
50
  var _GlobalStyles = _interopRequireDefault(require("./GlobalStyles"));
51
+ /* eslint-disable @typescript-eslint/naming-convention */
52
+
53
+ // Re-export the full `styled-components` *type* surface, matching the
54
+ // hand-written `.d.ts` that this conversion replaces. Type-only: emits
55
+ // nothing at runtime. Local declarations below intentionally shadow some
56
+ // styled-components names (`Keyframes`, `Interpolation`, `StyledComponent`,
57
+ // `CSSObject`, …) — local declarations win over re-exports.
58
+
59
+ // Helper type operators
60
+ // Pick that distributes over union types
61
+
62
+ // Any prop that has a default prop becomes optional, but its type is unchanged
63
+ // Undeclared default props are augmented into the resulting allowable attributes
64
+ // If declared props have indexed properties, ignore default props entirely as keyof gets widened
65
+ // Wrap in an outer-level conditional type to allow distribution over props that are unions
66
+
52
67
  function styled(tag, options) {
53
68
  let stylesFactory;
54
69
  if (options) {
55
- stylesFactory = (0, _styledComponents.default)(tag).withConfig({
70
+ stylesFactory = (0, _styledComponents.styled)(tag).withConfig({
56
71
  displayName: options.label,
57
72
  shouldForwardProp: options.shouldForwardProp
58
73
  });
59
74
  } else {
60
- stylesFactory = (0, _styledComponents.default)(tag);
75
+ stylesFactory = (0, _styledComponents.styled)(tag);
61
76
  }
62
77
  if (process.env.NODE_ENV !== 'production') {
63
78
  const fn = (...styles) => {
@@ -74,8 +89,10 @@ function styled(tag, options) {
74
89
  }
75
90
  return stylesFactory;
76
91
  }
77
-
78
- // eslint-disable-next-line @typescript-eslint/naming-convention
92
+ var _default = exports.default = styled;
93
+ /**
94
+ * For internal usage in `@mui/system` package
95
+ */
79
96
  function internal_mutateStyles(tag, processor) {
80
97
  // Styled-components attaches an instance to `componentStyle`.
81
98
  // https://github.com/styled-components/styled-components/blob/da8151762dcf72735ffba358173d4c097f6d5888/packages/styled-components/src/models/StyledComponent.ts#L257
@@ -89,12 +106,39 @@ function internal_mutateStyles(tag, processor) {
89
106
 
90
107
  // Not needed anymore, but fixes https://github.com/mui/material-ui/issues/44112
91
108
  // TODO: Remove it in v7
92
- // eslint-disable-next-line @typescript-eslint/naming-convention
93
109
  function internal_processStyles(tag, processor) {
94
110
  return internal_mutateStyles(tag, processor);
95
111
  }
96
-
97
- // eslint-disable-next-line @typescript-eslint/naming-convention
98
112
  function internal_serializeStyles(styles) {
99
113
  return styles;
100
- }
114
+ }
115
+
116
+ // These are the same as the ones in @mui/styled-engine
117
+ // CSS.PropertiesFallback are necessary so that we support spreading of the mixins. For example:
118
+ // '@font-face'?: Fontface | Fontface[]
119
+
120
+ // Omit variants as a key, because we have a special handling for it
121
+
122
+ // cannot be made a self-referential interface, breaks WithPropNested
123
+ // see https://github.com/microsoft/TypeScript/issues/34796
124
+
125
+ // adapter for compatibility with @mui/styled-engine
126
+
127
+ // abuse Pick to strip the call signature from ForwardRefExoticComponent
128
+
129
+ // any doesn't count as assignable to never in the extends clause, and we default A to never
130
+
131
+ // remove the call signature from StyledComponent so Interpolation can still infer InterpolationFunction
132
+
133
+ // These are typings coming from styled-components
134
+ // They are adjusted to accept the extended options coming from mui
135
+
136
+ // Same as in styled-components, but copied here so that it would use the Interpolation & CSS typings from above
137
+
138
+ // same as ThemedStyledFunction in styled-components, but without attrs, and withConfig
139
+
140
+ // Config to be used with withConfig
141
+
142
+ /** Same as StyledConfig but shouldForwardProp must be a type guard */
143
+
144
+ // same as ThemedBaseStyledInterface in styled-components, but with added options & common props for MUI components