@mui/styled-engine-sc 7.0.0-alpha.2 → 7.0.0-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 7.0.0-beta.1
4
+
5
+ <!-- generated comparing v7.0.0-beta.0..master -->
6
+
7
+ _Feb 27, 2025_
8
+
9
+ This release fixes incorrect build output from the previous release (`beta.0`).
10
+
11
+ ### Core
12
+
13
+ - [code-infra] Fix build:types script omitting folders with a dot in their name (#45422) @Janpot
14
+ - [release] Fix versions (#45420) @mj12albert
15
+
16
+ All contributors of this release in alphabetical order: @Janpot, @mj12albert
17
+
18
+ ## 7.0.0-beta.0
19
+
20
+ <!-- generated comparing v7.0.0-alpha.2..master -->
21
+
22
+ _Feb 26, 2025_
23
+
24
+ A big thanks to the 8 contributors who made this release possible.
25
+
26
+ ### `@mui/material@7.0.0-beta.0`
27
+
28
+ - [Modal][Dialog] Remove deprecated `onBackdropClick` (#45395) @DiegoAndai
29
+ - [Grid] Improve Grid2 upgrade experience (#45304) @DiegoAndai
30
+ - [Grid] Rename to GridLegacy (#45363) @DiegoAndai
31
+ - [Grid2] Rename to Grid (#45381) @DiegoAndai
32
+ - Remove SvgIcon data-testid in production (#45333) @Janpot
33
+ - Allow nested theme creation with `vars` (#45335) @siriwatknp
34
+ - [Rating] Deprecate \*Props and complete `slots`, `slotProps` (#45295) @harry-whorlow
35
+ - [Slider] Fix css class selector in migration guide (#45402) @sai6855
36
+ - [Slider] Fix spacings in .md files (#45388) @sai6855
37
+ - [styles] Remove deprecated exports (#45397) @DiegoAndai
38
+ - [Menu] Deprecate \*Props and complete `slots`, `slotProps` (#44913) @siriwatknp
39
+ - [StepButton] Remove StepIconButton type (#45396) @DiegoAndai
40
+
41
+ ### Docs
42
+
43
+ - [Autocomplete] Remove unnecessary renderTags prop from Sizes demo (#45401) @ZeeshanTamboli
44
+ - Add `overriding-component-structure` doc to Material UI (#45186) @siriwatknp
45
+ - Fix typo in slider docs (#45390) @sai6855
46
+ - Fix Context Menu selection lost on Safari (#44903) @NooBat
47
+
48
+ ### Core
49
+
50
+ - [code-infra] Fix types for @mui/styled-engine (#45413) @Janpot
51
+ - [docs-infra] Fix theme toggle call (#45400) @siriwatknp
52
+ - [docs-infra] Add `color-scheme` to document in iframe demos (#45406) @KenanYusuf
53
+ - [docs-infra] Revert to use deprecated `CssVarsProvider` for MUI X (#45371) @siriwatknp
54
+ - [docs-infra] Fix dark mode flicker for API pages (#45354) @siriwatknp
55
+ - [examples] Remove unnecessary comma in Material UI Vite JS example (#45370) @ZeeshanTamboli
56
+ - [test] Remove unused renderTags prop and fix key warning in Autocomplete regression test (#45410) @ZeeshanTamboli
57
+
58
+ All contributors of this release in alphabetical order: @DiegoAndai, @harry-whorlow, @Janpot, @KenanYusuf, @NooBat, @sai6855, @siriwatknp, @ZeeshanTamboli
59
+
3
60
  ## 7.0.0-alpha.2
4
61
 
5
62
  <!-- generated comparing v7.0.0-alpha.1..master -->
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { CSSObject, StyleFunction } from 'styled-components';
3
+ export interface GlobalStylesProps<Theme extends object = {}> {
4
+ defaultTheme?: object;
5
+ styles: string | CSSObject | StyleFunction<Theme>;
6
+ }
7
+ export default function Global<Theme extends object = {}>(props: GlobalStylesProps<Theme>): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./GlobalStyles.js";
2
+ export * from "./GlobalStyles.js";
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ export interface StyledEngineProviderProps {
3
+ children?: React.ReactNode;
4
+ injectFirst?: boolean;
5
+ }
6
+ export default function StyledEngineProvider(props: StyledEngineProviderProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./StyledEngineProvider.js";
2
+ export * from "./StyledEngineProvider.js";
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { CSSObject, StyleFunction } from 'styled-components';
3
+ export interface GlobalStylesProps<Theme extends object = {}> {
4
+ defaultTheme?: object;
5
+ styles: string | CSSObject | StyleFunction<Theme>;
6
+ }
7
+ export default function Global<Theme extends object = {}>(props: GlobalStylesProps<Theme>): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./GlobalStyles.js";
2
+ export * from "./GlobalStyles.js";
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ export interface StyledEngineProviderProps {
3
+ children?: React.ReactNode;
4
+ injectFirst?: boolean;
5
+ }
6
+ export default function StyledEngineProvider(props: StyledEngineProviderProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./StyledEngineProvider.js";
2
+ export * from "./StyledEngineProvider.js";
package/esm/index.d.ts ADDED
@@ -0,0 +1,193 @@
1
+ import * as React from 'react';
2
+ import * as CSS from 'csstype';
3
+ import * as hoistNonReactStatics from 'hoist-non-react-statics';
4
+ type WithOptionalTheme<P extends {
5
+ theme?: T | undefined;
6
+ }, T> = OmitU<P, 'theme'> & {
7
+ theme?: T | undefined;
8
+ };
9
+
10
+ // Helper type operators
11
+ // Pick that distributes over union types
12
+ export type PickU<T, K extends keyof T> = T extends any ? { [P in K]: T[P] } : never;
13
+ 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
+ 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
+ export type IntrinsicElementsKeys = keyof React.JSX.IntrinsicElements;
21
+ type ReactDefaultizedProps<C, P> = C extends {
22
+ defaultProps: infer D;
23
+ } ? 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;
40
+ export interface ThemeProps<T> {
41
+ theme: T;
42
+ }
43
+ export type ThemedStyledProps<P, T> = P & ThemeProps<T>;
44
+ export interface Keyframes {
45
+ getName(): string;
46
+ }
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
+
53
+ /**
54
+ * For internal usage in `@mui/system` package
55
+ */
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[]
70
+ export type CSSProperties = CSS.PropertiesFallback<number | string>;
71
+ export type CSSPropertiesWithMultiValues = { [K in keyof CSSProperties]: CSSProperties[K] | Array<Extract<CSSProperties[K], string>> };
72
+ export type CSSPseudos = { [K in CSS.Pseudos]?: unknown | CSSObject };
73
+ export interface CSSOthersObject {
74
+ [propertiesName: string]: unknown | CSSInterpolation;
75
+ }
76
+ export type CSSPseudosForCSSObject = { [K in CSS.Pseudos]?: CSSObject };
77
+ export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {}
78
+ export interface CSSOthersObjectForCSSObject {
79
+ [propertiesName: string]: CSSInterpolation;
80
+ }
81
+
82
+ // Omit variants as a key, because we have a special handling for it
83
+ export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, Omit<CSSOthersObject, 'variants'> {}
84
+ interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
85
+ variants: Array<{
86
+ props: Props | ((props: Props) => boolean);
87
+ style: CSSObject | ((args: Props extends {
88
+ theme: any;
89
+ } ? {
90
+ theme: Props['theme'];
91
+ } : any) => CSSObject);
92
+ }>;
93
+ }
94
+ export type FalseyValue = undefined | null | false;
95
+ 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
+ export type FlattenInterpolation<P> = ReadonlyArray<Interpolation<P>>;
99
+ export type InterpolationValue = string | number | FalseyValue | Keyframes | StyledComponentInterpolation | CSSObject;
100
+ export type SimpleInterpolation = InterpolationValue | FlattenSimpleInterpolation;
101
+ // adapter for compatibility with @mui/styled-engine
102
+ export type CSSInterpolation = SimpleInterpolation;
103
+ export type FlattenSimpleInterpolation = ReadonlyArray<SimpleInterpolation>;
104
+ export type InterpolationFunction<P> = (props: P) => Interpolation<P>;
105
+
106
+ // abuse Pick to strip the call signature from ForwardRefExoticComponent
107
+ type ForwardRefExoticBase<P> = PickU<React.ForwardRefExoticComponent<P>, keyof React.ForwardRefExoticComponent<any>>;
108
+ 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
+ as?: AsC | undefined;
110
+ forwardedAs?: FAsC | undefined;
111
+ };
112
+ export type StyledComponent<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object = {}, O extends object = {}, A extends keyof any = never> =
113
+ // 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
+ 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
+ export type AnyStyledComponent = StyledComponent<any, any, any, any> | StyledComponent<any, any, any> | React.FunctionComponent<any> | React.ComponentType<any>;
119
+ 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
+ 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
+ export type StyledComponentInnerAttrs<C extends AnyStyledComponent> = C extends StyledComponent<any, any, any, infer A> ? A : never;
122
+ 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
+ (props: StyledComponentProps<C, T, O, A> & {
125
+ as?: never | undefined;
126
+ forwardedAs?: never | undefined;
127
+ }): React.ReactElement<StyledComponentProps<C, T, O, A>>;
128
+ <AsC extends string | React.ComponentType<any> = C, FAsC extends string | React.ComponentType<any> = AsC>(props: StyledComponentPropsWithAs<AsC, T, O, A, AsC, FAsC>): React.ReactElement<StyledComponentPropsWithAs<AsC, T, O, A, AsC, FAsC>>;
129
+ withComponent<WithC extends AnyStyledComponent>(component: WithC): StyledComponent<StyledComponentInnerComponent<WithC>, T, O & StyledComponentInnerOtherProps<WithC>, A | StyledComponentInnerAttrs<WithC>>;
130
+ withComponent<WithC extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>>(component: WithC): StyledComponent<WithC, T, O, A>;
131
+ }
132
+
133
+ // remove the call signature from StyledComponent so Interpolation can still infer InterpolationFunction
134
+ 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
+ type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
139
+ type ThemedStyledComponentFactories<T extends object> = { [TTag in keyof React.JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T> };
140
+ 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
+ export interface ThemedStyledFunctionBase<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> {
144
+ (first: TemplateStringsArray): StyledComponent<C, T, O, A>;
145
+ (first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>, ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>>): StyledComponent<C, T, O, A>;
146
+ <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
+ }
148
+
149
+ // same as ThemedStyledFunction in styled-components, but without attrs, and withConfig
150
+ 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
+ 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
+ export interface StyledConfig<O extends object = {}> {
155
+ // TODO: Add all types from the original StyledComponentWrapperProperties
156
+ componentId?: string;
157
+ displayName?: string;
158
+ label?: string;
159
+ target?: string;
160
+ shouldForwardProp?: ((prop: keyof O, defaultValidatorFn: (prop: keyof O) => boolean) => boolean) | undefined;
161
+ }
162
+
163
+ /** Same as StyledConfig but shouldForwardProp must be a type guard */
164
+ export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Props = keyof Props> {
165
+ componentId?: string;
166
+ displayName?: string;
167
+ label?: string;
168
+ shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps;
169
+ target?: string;
170
+ }
171
+
172
+ // same as ThemedBaseStyledInterface in styled-components, but with added options & common props for MUI components
173
+ export interface ThemedBaseStyledInterface<MUIStyledCommonProps extends object, MuiStyledOptions extends object, Theme extends object> extends ThemedStyledComponentFactories<Theme> {
174
+ <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
+ ref?: React.Ref<InstanceType<C>>;
176
+ }, Theme>;
177
+ <C extends React.ComponentClass<React.ComponentProps<C>>>(component: C, options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<PropsOf<C> & MUIStyledCommonProps, {}, {
178
+ ref?: React.Ref<InstanceType<C>>;
179
+ }, Theme>;
180
+ <C extends React.JSXElementConstructor<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, {}, {}, Theme>;
181
+ <C extends React.JSXElementConstructor<React.ComponentProps<C>>>(component: C, options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<PropsOf<C> & MUIStyledCommonProps, {}, {}, Theme>;
182
+ <Tag extends keyof React.JSX.IntrinsicElements, ForwardedProps extends keyof React.JSX.IntrinsicElements[Tag] = keyof React.JSX.IntrinsicElements[Tag]>(tag: Tag, options: FilteringStyledOptions<React.JSX.IntrinsicElements[Tag], ForwardedProps> & MuiStyledOptions): CreateStyledComponent<MUIStyledCommonProps, Pick<React.JSX.IntrinsicElements[Tag], ForwardedProps>, {}, Theme>;
183
+ <Tag extends keyof React.JSX.IntrinsicElements>(tag: Tag, options?: StyledConfig<MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<MUIStyledCommonProps, React.JSX.IntrinsicElements[Tag], {}, Theme>;
184
+ }
185
+ export type CreateMUIStyled<MUIStyledCommonProps extends object = {}, MuiStyledOptions extends object = {}, T extends object = {}> = ThemedBaseStyledInterface<MUIStyledCommonProps, MuiStyledOptions, AnyIfEmpty<T>>;
186
+ export type PropsOf<C extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>> = React.JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>;
187
+ export interface MUIStyledComponent<ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {}> extends React.FC<ComponentProps & SpecificComponentProps & JSXProps> {
188
+ withComponent<C extends React.ComponentClass<React.ComponentProps<C>>>(component: C): MUIStyledComponent<ComponentProps & PropsOf<C>, {}, {
189
+ ref?: React.Ref<InstanceType<C>>;
190
+ }>;
191
+ withComponent<C extends React.ComponentType<React.ComponentProps<C>>>(component: C): MUIStyledComponent<ComponentProps & PropsOf<C>>;
192
+ withComponent<Tag extends keyof React.JSX.IntrinsicElements>(tag: Tag): MUIStyledComponent<ComponentProps, React.JSX.IntrinsicElements[Tag]>;
193
+ }
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine-sc v7.0.0-alpha.2
2
+ * @mui/styled-engine-sc v7.0.0-beta.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.d.ts ADDED
@@ -0,0 +1,193 @@
1
+ import * as React from 'react';
2
+ import * as CSS from 'csstype';
3
+ import * as hoistNonReactStatics from 'hoist-non-react-statics';
4
+ type WithOptionalTheme<P extends {
5
+ theme?: T | undefined;
6
+ }, T> = OmitU<P, 'theme'> & {
7
+ theme?: T | undefined;
8
+ };
9
+
10
+ // Helper type operators
11
+ // Pick that distributes over union types
12
+ export type PickU<T, K extends keyof T> = T extends any ? { [P in K]: T[P] } : never;
13
+ 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
+ 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
+ export type IntrinsicElementsKeys = keyof React.JSX.IntrinsicElements;
21
+ type ReactDefaultizedProps<C, P> = C extends {
22
+ defaultProps: infer D;
23
+ } ? 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;
40
+ export interface ThemeProps<T> {
41
+ theme: T;
42
+ }
43
+ export type ThemedStyledProps<P, T> = P & ThemeProps<T>;
44
+ export interface Keyframes {
45
+ getName(): string;
46
+ }
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
+
53
+ /**
54
+ * For internal usage in `@mui/system` package
55
+ */
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[]
70
+ export type CSSProperties = CSS.PropertiesFallback<number | string>;
71
+ export type CSSPropertiesWithMultiValues = { [K in keyof CSSProperties]: CSSProperties[K] | Array<Extract<CSSProperties[K], string>> };
72
+ export type CSSPseudos = { [K in CSS.Pseudos]?: unknown | CSSObject };
73
+ export interface CSSOthersObject {
74
+ [propertiesName: string]: unknown | CSSInterpolation;
75
+ }
76
+ export type CSSPseudosForCSSObject = { [K in CSS.Pseudos]?: CSSObject };
77
+ export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {}
78
+ export interface CSSOthersObjectForCSSObject {
79
+ [propertiesName: string]: CSSInterpolation;
80
+ }
81
+
82
+ // Omit variants as a key, because we have a special handling for it
83
+ export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, Omit<CSSOthersObject, 'variants'> {}
84
+ interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
85
+ variants: Array<{
86
+ props: Props | ((props: Props) => boolean);
87
+ style: CSSObject | ((args: Props extends {
88
+ theme: any;
89
+ } ? {
90
+ theme: Props['theme'];
91
+ } : any) => CSSObject);
92
+ }>;
93
+ }
94
+ export type FalseyValue = undefined | null | false;
95
+ 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
+ export type FlattenInterpolation<P> = ReadonlyArray<Interpolation<P>>;
99
+ export type InterpolationValue = string | number | FalseyValue | Keyframes | StyledComponentInterpolation | CSSObject;
100
+ export type SimpleInterpolation = InterpolationValue | FlattenSimpleInterpolation;
101
+ // adapter for compatibility with @mui/styled-engine
102
+ export type CSSInterpolation = SimpleInterpolation;
103
+ export type FlattenSimpleInterpolation = ReadonlyArray<SimpleInterpolation>;
104
+ export type InterpolationFunction<P> = (props: P) => Interpolation<P>;
105
+
106
+ // abuse Pick to strip the call signature from ForwardRefExoticComponent
107
+ type ForwardRefExoticBase<P> = PickU<React.ForwardRefExoticComponent<P>, keyof React.ForwardRefExoticComponent<any>>;
108
+ 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
+ as?: AsC | undefined;
110
+ forwardedAs?: FAsC | undefined;
111
+ };
112
+ export type StyledComponent<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object = {}, O extends object = {}, A extends keyof any = never> =
113
+ // 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
+ 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
+ export type AnyStyledComponent = StyledComponent<any, any, any, any> | StyledComponent<any, any, any> | React.FunctionComponent<any> | React.ComponentType<any>;
119
+ 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
+ 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
+ export type StyledComponentInnerAttrs<C extends AnyStyledComponent> = C extends StyledComponent<any, any, any, infer A> ? A : never;
122
+ 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
+ (props: StyledComponentProps<C, T, O, A> & {
125
+ as?: never | undefined;
126
+ forwardedAs?: never | undefined;
127
+ }): React.ReactElement<StyledComponentProps<C, T, O, A>>;
128
+ <AsC extends string | React.ComponentType<any> = C, FAsC extends string | React.ComponentType<any> = AsC>(props: StyledComponentPropsWithAs<AsC, T, O, A, AsC, FAsC>): React.ReactElement<StyledComponentPropsWithAs<AsC, T, O, A, AsC, FAsC>>;
129
+ withComponent<WithC extends AnyStyledComponent>(component: WithC): StyledComponent<StyledComponentInnerComponent<WithC>, T, O & StyledComponentInnerOtherProps<WithC>, A | StyledComponentInnerAttrs<WithC>>;
130
+ withComponent<WithC extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>>(component: WithC): StyledComponent<WithC, T, O, A>;
131
+ }
132
+
133
+ // remove the call signature from StyledComponent so Interpolation can still infer InterpolationFunction
134
+ 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
+ type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
139
+ type ThemedStyledComponentFactories<T extends object> = { [TTag in keyof React.JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T> };
140
+ 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
+ export interface ThemedStyledFunctionBase<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> {
144
+ (first: TemplateStringsArray): StyledComponent<C, T, O, A>;
145
+ (first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>, ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>>): StyledComponent<C, T, O, A>;
146
+ <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
+ }
148
+
149
+ // same as ThemedStyledFunction in styled-components, but without attrs, and withConfig
150
+ 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
+ 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
+ export interface StyledConfig<O extends object = {}> {
155
+ // TODO: Add all types from the original StyledComponentWrapperProperties
156
+ componentId?: string;
157
+ displayName?: string;
158
+ label?: string;
159
+ target?: string;
160
+ shouldForwardProp?: ((prop: keyof O, defaultValidatorFn: (prop: keyof O) => boolean) => boolean) | undefined;
161
+ }
162
+
163
+ /** Same as StyledConfig but shouldForwardProp must be a type guard */
164
+ export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Props = keyof Props> {
165
+ componentId?: string;
166
+ displayName?: string;
167
+ label?: string;
168
+ shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps;
169
+ target?: string;
170
+ }
171
+
172
+ // same as ThemedBaseStyledInterface in styled-components, but with added options & common props for MUI components
173
+ export interface ThemedBaseStyledInterface<MUIStyledCommonProps extends object, MuiStyledOptions extends object, Theme extends object> extends ThemedStyledComponentFactories<Theme> {
174
+ <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
+ ref?: React.Ref<InstanceType<C>>;
176
+ }, Theme>;
177
+ <C extends React.ComponentClass<React.ComponentProps<C>>>(component: C, options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<PropsOf<C> & MUIStyledCommonProps, {}, {
178
+ ref?: React.Ref<InstanceType<C>>;
179
+ }, Theme>;
180
+ <C extends React.JSXElementConstructor<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, {}, {}, Theme>;
181
+ <C extends React.JSXElementConstructor<React.ComponentProps<C>>>(component: C, options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<PropsOf<C> & MUIStyledCommonProps, {}, {}, Theme>;
182
+ <Tag extends keyof React.JSX.IntrinsicElements, ForwardedProps extends keyof React.JSX.IntrinsicElements[Tag] = keyof React.JSX.IntrinsicElements[Tag]>(tag: Tag, options: FilteringStyledOptions<React.JSX.IntrinsicElements[Tag], ForwardedProps> & MuiStyledOptions): CreateStyledComponent<MUIStyledCommonProps, Pick<React.JSX.IntrinsicElements[Tag], ForwardedProps>, {}, Theme>;
183
+ <Tag extends keyof React.JSX.IntrinsicElements>(tag: Tag, options?: StyledConfig<MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<MUIStyledCommonProps, React.JSX.IntrinsicElements[Tag], {}, Theme>;
184
+ }
185
+ export type CreateMUIStyled<MUIStyledCommonProps extends object = {}, MuiStyledOptions extends object = {}, T extends object = {}> = ThemedBaseStyledInterface<MUIStyledCommonProps, MuiStyledOptions, AnyIfEmpty<T>>;
186
+ export type PropsOf<C extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>> = React.JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>;
187
+ export interface MUIStyledComponent<ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {}> extends React.FC<ComponentProps & SpecificComponentProps & JSXProps> {
188
+ withComponent<C extends React.ComponentClass<React.ComponentProps<C>>>(component: C): MUIStyledComponent<ComponentProps & PropsOf<C>, {}, {
189
+ ref?: React.Ref<InstanceType<C>>;
190
+ }>;
191
+ withComponent<C extends React.ComponentType<React.ComponentProps<C>>>(component: C): MUIStyledComponent<ComponentProps & PropsOf<C>>;
192
+ withComponent<Tag extends keyof React.JSX.IntrinsicElements>(tag: Tag): MUIStyledComponent<ComponentProps, React.JSX.IntrinsicElements[Tag]>;
193
+ }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine-sc v7.0.0-alpha.2
2
+ * @mui/styled-engine-sc v7.0.0-beta.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { CSSObject, StyleFunction } from 'styled-components';
3
+ export interface GlobalStylesProps<Theme extends object = {}> {
4
+ defaultTheme?: object;
5
+ styles: string | CSSObject | StyleFunction<Theme>;
6
+ }
7
+ export default function Global<Theme extends object = {}>(props: GlobalStylesProps<Theme>): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./GlobalStyles.js";
2
+ export * from "./GlobalStyles.js";
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ export interface StyledEngineProviderProps {
3
+ children?: React.ReactNode;
4
+ injectFirst?: boolean;
5
+ }
6
+ export default function StyledEngineProvider(props: StyledEngineProviderProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./StyledEngineProvider.js";
2
+ export * from "./StyledEngineProvider.js";
@@ -0,0 +1,193 @@
1
+ import * as React from 'react';
2
+ import * as CSS from 'csstype';
3
+ import * as hoistNonReactStatics from 'hoist-non-react-statics';
4
+ type WithOptionalTheme<P extends {
5
+ theme?: T | undefined;
6
+ }, T> = OmitU<P, 'theme'> & {
7
+ theme?: T | undefined;
8
+ };
9
+
10
+ // Helper type operators
11
+ // Pick that distributes over union types
12
+ export type PickU<T, K extends keyof T> = T extends any ? { [P in K]: T[P] } : never;
13
+ 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
+ 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
+ export type IntrinsicElementsKeys = keyof React.JSX.IntrinsicElements;
21
+ type ReactDefaultizedProps<C, P> = C extends {
22
+ defaultProps: infer D;
23
+ } ? 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;
40
+ export interface ThemeProps<T> {
41
+ theme: T;
42
+ }
43
+ export type ThemedStyledProps<P, T> = P & ThemeProps<T>;
44
+ export interface Keyframes {
45
+ getName(): string;
46
+ }
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
+
53
+ /**
54
+ * For internal usage in `@mui/system` package
55
+ */
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[]
70
+ export type CSSProperties = CSS.PropertiesFallback<number | string>;
71
+ export type CSSPropertiesWithMultiValues = { [K in keyof CSSProperties]: CSSProperties[K] | Array<Extract<CSSProperties[K], string>> };
72
+ export type CSSPseudos = { [K in CSS.Pseudos]?: unknown | CSSObject };
73
+ export interface CSSOthersObject {
74
+ [propertiesName: string]: unknown | CSSInterpolation;
75
+ }
76
+ export type CSSPseudosForCSSObject = { [K in CSS.Pseudos]?: CSSObject };
77
+ export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {}
78
+ export interface CSSOthersObjectForCSSObject {
79
+ [propertiesName: string]: CSSInterpolation;
80
+ }
81
+
82
+ // Omit variants as a key, because we have a special handling for it
83
+ export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, Omit<CSSOthersObject, 'variants'> {}
84
+ interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
85
+ variants: Array<{
86
+ props: Props | ((props: Props) => boolean);
87
+ style: CSSObject | ((args: Props extends {
88
+ theme: any;
89
+ } ? {
90
+ theme: Props['theme'];
91
+ } : any) => CSSObject);
92
+ }>;
93
+ }
94
+ export type FalseyValue = undefined | null | false;
95
+ 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
+ export type FlattenInterpolation<P> = ReadonlyArray<Interpolation<P>>;
99
+ export type InterpolationValue = string | number | FalseyValue | Keyframes | StyledComponentInterpolation | CSSObject;
100
+ export type SimpleInterpolation = InterpolationValue | FlattenSimpleInterpolation;
101
+ // adapter for compatibility with @mui/styled-engine
102
+ export type CSSInterpolation = SimpleInterpolation;
103
+ export type FlattenSimpleInterpolation = ReadonlyArray<SimpleInterpolation>;
104
+ export type InterpolationFunction<P> = (props: P) => Interpolation<P>;
105
+
106
+ // abuse Pick to strip the call signature from ForwardRefExoticComponent
107
+ type ForwardRefExoticBase<P> = PickU<React.ForwardRefExoticComponent<P>, keyof React.ForwardRefExoticComponent<any>>;
108
+ 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
+ as?: AsC | undefined;
110
+ forwardedAs?: FAsC | undefined;
111
+ };
112
+ export type StyledComponent<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object = {}, O extends object = {}, A extends keyof any = never> =
113
+ // 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
+ 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
+ export type AnyStyledComponent = StyledComponent<any, any, any, any> | StyledComponent<any, any, any> | React.FunctionComponent<any> | React.ComponentType<any>;
119
+ 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
+ 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
+ export type StyledComponentInnerAttrs<C extends AnyStyledComponent> = C extends StyledComponent<any, any, any, infer A> ? A : never;
122
+ 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
+ (props: StyledComponentProps<C, T, O, A> & {
125
+ as?: never | undefined;
126
+ forwardedAs?: never | undefined;
127
+ }): React.ReactElement<StyledComponentProps<C, T, O, A>>;
128
+ <AsC extends string | React.ComponentType<any> = C, FAsC extends string | React.ComponentType<any> = AsC>(props: StyledComponentPropsWithAs<AsC, T, O, A, AsC, FAsC>): React.ReactElement<StyledComponentPropsWithAs<AsC, T, O, A, AsC, FAsC>>;
129
+ withComponent<WithC extends AnyStyledComponent>(component: WithC): StyledComponent<StyledComponentInnerComponent<WithC>, T, O & StyledComponentInnerOtherProps<WithC>, A | StyledComponentInnerAttrs<WithC>>;
130
+ withComponent<WithC extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>>(component: WithC): StyledComponent<WithC, T, O, A>;
131
+ }
132
+
133
+ // remove the call signature from StyledComponent so Interpolation can still infer InterpolationFunction
134
+ 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
+ type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
139
+ type ThemedStyledComponentFactories<T extends object> = { [TTag in keyof React.JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T> };
140
+ 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
+ export interface ThemedStyledFunctionBase<C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> {
144
+ (first: TemplateStringsArray): StyledComponent<C, T, O, A>;
145
+ (first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>, ...other: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O, T>>>): StyledComponent<C, T, O, A>;
146
+ <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
+ }
148
+
149
+ // same as ThemedStyledFunction in styled-components, but without attrs, and withConfig
150
+ 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
+ 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
+ export interface StyledConfig<O extends object = {}> {
155
+ // TODO: Add all types from the original StyledComponentWrapperProperties
156
+ componentId?: string;
157
+ displayName?: string;
158
+ label?: string;
159
+ target?: string;
160
+ shouldForwardProp?: ((prop: keyof O, defaultValidatorFn: (prop: keyof O) => boolean) => boolean) | undefined;
161
+ }
162
+
163
+ /** Same as StyledConfig but shouldForwardProp must be a type guard */
164
+ export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Props = keyof Props> {
165
+ componentId?: string;
166
+ displayName?: string;
167
+ label?: string;
168
+ shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps;
169
+ target?: string;
170
+ }
171
+
172
+ // same as ThemedBaseStyledInterface in styled-components, but with added options & common props for MUI components
173
+ export interface ThemedBaseStyledInterface<MUIStyledCommonProps extends object, MuiStyledOptions extends object, Theme extends object> extends ThemedStyledComponentFactories<Theme> {
174
+ <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
+ ref?: React.Ref<InstanceType<C>>;
176
+ }, Theme>;
177
+ <C extends React.ComponentClass<React.ComponentProps<C>>>(component: C, options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<PropsOf<C> & MUIStyledCommonProps, {}, {
178
+ ref?: React.Ref<InstanceType<C>>;
179
+ }, Theme>;
180
+ <C extends React.JSXElementConstructor<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, {}, {}, Theme>;
181
+ <C extends React.JSXElementConstructor<React.ComponentProps<C>>>(component: C, options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<PropsOf<C> & MUIStyledCommonProps, {}, {}, Theme>;
182
+ <Tag extends keyof React.JSX.IntrinsicElements, ForwardedProps extends keyof React.JSX.IntrinsicElements[Tag] = keyof React.JSX.IntrinsicElements[Tag]>(tag: Tag, options: FilteringStyledOptions<React.JSX.IntrinsicElements[Tag], ForwardedProps> & MuiStyledOptions): CreateStyledComponent<MUIStyledCommonProps, Pick<React.JSX.IntrinsicElements[Tag], ForwardedProps>, {}, Theme>;
183
+ <Tag extends keyof React.JSX.IntrinsicElements>(tag: Tag, options?: StyledConfig<MUIStyledCommonProps> & MuiStyledOptions): CreateStyledComponent<MUIStyledCommonProps, React.JSX.IntrinsicElements[Tag], {}, Theme>;
184
+ }
185
+ export type CreateMUIStyled<MUIStyledCommonProps extends object = {}, MuiStyledOptions extends object = {}, T extends object = {}> = ThemedBaseStyledInterface<MUIStyledCommonProps, MuiStyledOptions, AnyIfEmpty<T>>;
186
+ export type PropsOf<C extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>> = React.JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>;
187
+ export interface MUIStyledComponent<ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {}> extends React.FC<ComponentProps & SpecificComponentProps & JSXProps> {
188
+ withComponent<C extends React.ComponentClass<React.ComponentProps<C>>>(component: C): MUIStyledComponent<ComponentProps & PropsOf<C>, {}, {
189
+ ref?: React.Ref<InstanceType<C>>;
190
+ }>;
191
+ withComponent<C extends React.ComponentType<React.ComponentProps<C>>>(component: C): MUIStyledComponent<ComponentProps & PropsOf<C>>;
192
+ withComponent<Tag extends keyof React.JSX.IntrinsicElements>(tag: Tag): MUIStyledComponent<ComponentProps, React.JSX.IntrinsicElements[Tag]>;
193
+ }
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine-sc v7.0.0-alpha.2
2
+ * @mui/styled-engine-sc v7.0.0-beta.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/styled-engine-sc",
3
- "version": "7.0.0-alpha.2",
3
+ "version": "7.0.0-beta.1",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "styled() API wrapper package for styled-components.",
@@ -75,5 +75,6 @@
75
75
  },
76
76
  "./esm": null,
77
77
  "./modern": null
78
- }
78
+ },
79
+ "types": "./index.d.ts"
79
80
  }