@mui/styled-engine-sc 6.0.0-alpha.8 → 6.0.0-beta.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.
@@ -8,4 +8,4 @@ export interface GlobalStylesProps<Theme extends object = {}> {
8
8
 
9
9
  export default function Global<Theme extends object = {}>(
10
10
  props: GlobalStylesProps<Theme>,
11
- ): React.ReactElement;
11
+ ): React.ReactElement<any>;
package/README.md CHANGED
@@ -7,4 +7,4 @@ It's designed for developers who would like to use `styled-components` as the ma
7
7
 
8
8
  <!-- #default-branch-switch -->
9
9
 
10
- Visit [https://mui.com/material-ui/guides/styled-components/](https://mui.com/material-ui/guides/styled-components/) to view the full documentation.
10
+ Visit [https://next.mui.com/material-ui/integrations/styled-components/](https://next.mui.com/material-ui/integrations/styled-components/) to view the full documentation.
@@ -5,4 +5,4 @@ export interface StyledEngineProviderProps {
5
5
  injectFirst?: boolean;
6
6
  }
7
7
 
8
- export default function StyledEngineProvider(props: StyledEngineProviderProps): JSX.Element;
8
+ export default function StyledEngineProvider(props: StyledEngineProviderProps): React.JSX.Element;
package/index.d.ts CHANGED
@@ -23,7 +23,7 @@ type Defaultize<P, D> = P extends any
23
23
  Partial<PickU<D, Exclude<keyof D, keyof P>>>
24
24
  : never;
25
25
 
26
- export type IntrinsicElementsKeys = keyof JSX.IntrinsicElements;
26
+ export type IntrinsicElementsKeys = keyof React.JSX.IntrinsicElements;
27
27
  type ReactDefaultizedProps<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D> : P;
28
28
 
29
29
  type MakeAttrsOptional<
@@ -108,7 +108,10 @@ export interface CSSObject
108
108
  Omit<CSSOthersObject, 'variants'> {}
109
109
 
110
110
  interface CSSObjectWithVariants<Props> extends Omit<CSSObject, 'variants'> {
111
- variants: Array<{ props: Props; variants: CSSObject }>;
111
+ variants: Array<{
112
+ props: Props | ((props: Props) => boolean);
113
+ style: CSSObject;
114
+ }>;
112
115
  }
113
116
 
114
117
  export type FalseyValue = undefined | null | false;
@@ -153,7 +156,7 @@ type StyledComponentPropsWithAs<
153
156
  };
154
157
 
155
158
  export type StyledComponent<
156
- C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
159
+ C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>,
157
160
  T extends object = {},
158
161
  O extends object = {},
159
162
  A extends keyof any = never,
@@ -170,31 +173,21 @@ export type AnyStyledComponent =
170
173
  | React.FunctionComponent<any>
171
174
  | React.ComponentType<any>;
172
175
 
173
- export type StyledComponentInnerComponent<C extends AnyStyledComponent> = C extends StyledComponent<
174
- infer I,
175
- any,
176
- any,
177
- any
178
- >
179
- ? I
180
- : C extends StyledComponent<infer I, any, any>
181
- ? I
182
- : C;
176
+ export type StyledComponentInnerComponent<C extends AnyStyledComponent> =
177
+ C extends StyledComponent<infer I, any, any, any>
178
+ ? I
179
+ : C extends StyledComponent<infer I, any, any>
180
+ ? I
181
+ : C;
183
182
 
184
183
  export type StyledComponentInnerOtherProps<C extends AnyStyledComponent> =
185
184
  C extends StyledComponent<any, any, infer O, any>
186
185
  ? O
187
186
  : C extends StyledComponent<any, any, infer O>
188
- ? O
189
- : never;
190
- export type StyledComponentInnerAttrs<C extends AnyStyledComponent> = C extends StyledComponent<
191
- any,
192
- any,
193
- any,
194
- infer A
195
- >
196
- ? A
197
- : never;
187
+ ? O
188
+ : never;
189
+ export type StyledComponentInnerAttrs<C extends AnyStyledComponent> =
190
+ C extends StyledComponent<any, any, any, infer A> ? A : never;
198
191
 
199
192
  export interface StyledComponentBase<
200
193
  C extends string | React.ComponentType<any>,
@@ -224,7 +217,7 @@ export interface StyledComponentBase<
224
217
  O & StyledComponentInnerOtherProps<WithC>,
225
218
  A | StyledComponentInnerAttrs<WithC>
226
219
  >;
227
- withComponent<WithC extends keyof JSX.IntrinsicElements | React.ComponentType<any>>(
220
+ withComponent<WithC extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>>(
228
221
  component: WithC,
229
222
  ): StyledComponent<WithC, T, O, A>;
230
223
  }
@@ -239,18 +232,18 @@ type StyledComponentInterpolation =
239
232
  type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
240
233
 
241
234
  type ThemedStyledComponentFactories<T extends object> = {
242
- [TTag in keyof JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T>;
235
+ [TTag in keyof React.JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T>;
243
236
  };
244
237
 
245
238
  export type StyledComponentPropsWithRef<
246
- C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
239
+ C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>,
247
240
  > = C extends AnyStyledComponent
248
241
  ? React.ComponentPropsWithRef<StyledComponentInnerComponent<C>>
249
242
  : React.ComponentPropsWithRef<C>;
250
243
 
251
244
  // Same as in styled-components, but copied here so that it would use the Interpolation & CSS typings from above
252
245
  export interface ThemedStyledFunctionBase<
253
- C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
246
+ C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>,
254
247
  T extends object,
255
248
  O extends object = {},
256
249
  A extends keyof any = never,
@@ -274,7 +267,7 @@ export interface ThemedStyledFunctionBase<
274
267
 
275
268
  // same as ThemedStyledFunction in styled-components, but without attrs, and withConfig
276
269
  export interface ThemedStyledFunction<
277
- C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
270
+ C extends keyof React.JSX.IntrinsicElements | React.ComponentType<any>,
278
271
  T extends object,
279
272
  O extends object = {},
280
273
  A extends keyof any = never,
@@ -292,32 +285,87 @@ export interface StyledConfig<O extends object = {}> {
292
285
  // TODO: Add all types from the original StyledComponentWrapperProperties
293
286
  componentId?: string;
294
287
  displayName?: string;
288
+ label?: string;
289
+ target?: string;
295
290
  shouldForwardProp?:
296
291
  | ((prop: keyof O, defaultValidatorFn: (prop: keyof O) => boolean) => boolean)
297
292
  | undefined;
298
293
  }
299
294
 
295
+ /** Same as StyledConfig but shouldForwardProp must be a type guard */
296
+ export interface FilteringStyledOptions<Props, ForwardedProps extends keyof Props = keyof Props> {
297
+ componentId?: string;
298
+ displayName?: string;
299
+ label?: string;
300
+ shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps;
301
+ target?: string;
302
+ }
303
+
300
304
  // same as ThemedBaseStyledInterface in styled-components, but with added options & common props for MUI components
301
305
  export interface ThemedBaseStyledInterface<
302
306
  MUIStyledCommonProps extends object,
303
307
  MuiStyledOptions extends object,
304
- T extends object,
305
- > extends ThemedStyledComponentFactories<T> {
306
- <C extends AnyStyledComponent>(
308
+ Theme extends object,
309
+ > extends ThemedStyledComponentFactories<Theme> {
310
+ <
311
+ C extends React.ComponentClass<React.ComponentProps<C>>,
312
+ ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>,
313
+ >(
307
314
  component: C,
308
- options?: StyledConfig<any> & MuiStyledOptions,
309
- ): ThemedStyledFunction<
310
- StyledComponentInnerComponent<C>,
311
- T,
312
- StyledComponentInnerOtherProps<C> & MUIStyledCommonProps,
313
- StyledComponentInnerAttrs<C>
315
+ options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps> & MuiStyledOptions,
316
+ ): CreateStyledComponent<
317
+ Pick<PropsOf<C>, ForwardedProps> & MUIStyledCommonProps,
318
+ {},
319
+ {
320
+ ref?: React.Ref<InstanceType<C>>;
321
+ },
322
+ Theme
323
+ >;
324
+
325
+ <C extends React.ComponentClass<React.ComponentProps<C>>>(
326
+ component: C,
327
+ options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions,
328
+ ): CreateStyledComponent<
329
+ PropsOf<C> & MUIStyledCommonProps,
330
+ {},
331
+ {
332
+ ref?: React.Ref<InstanceType<C>>;
333
+ },
334
+ Theme
314
335
  >;
315
- <C extends keyof JSX.IntrinsicElements | React.ComponentType<any>>(
316
- // unfortunately using a conditional type to validate that it can receive a `theme?: Theme`
317
- // causes tests to fail in TS 3.1
336
+
337
+ <
338
+ C extends React.JSXElementConstructor<React.ComponentProps<C>>,
339
+ ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>,
340
+ >(
341
+ component: C,
342
+ options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps> & MuiStyledOptions,
343
+ ): CreateStyledComponent<Pick<PropsOf<C>, ForwardedProps> & MUIStyledCommonProps, {}, {}, Theme>;
344
+
345
+ <C extends React.JSXElementConstructor<React.ComponentProps<C>>>(
318
346
  component: C,
319
- options?: StyledConfig<any> & MuiStyledOptions,
320
- ): ThemedStyledFunction<C, T, MUIStyledCommonProps>;
347
+ options?: StyledConfig<PropsOf<C> & MUIStyledCommonProps> & MuiStyledOptions,
348
+ ): CreateStyledComponent<PropsOf<C> & MUIStyledCommonProps, {}, {}, Theme>;
349
+
350
+ <
351
+ Tag extends keyof React.JSX.IntrinsicElements,
352
+ ForwardedProps extends
353
+ keyof React.JSX.IntrinsicElements[Tag] = keyof React.JSX.IntrinsicElements[Tag],
354
+ >(
355
+ tag: Tag,
356
+ options: FilteringStyledOptions<React.JSX.IntrinsicElements[Tag], ForwardedProps> &
357
+ MuiStyledOptions,
358
+ ): CreateStyledComponent<
359
+ MUIStyledCommonProps,
360
+ Pick<React.JSX.IntrinsicElements[Tag], ForwardedProps>,
361
+ {},
362
+ Theme
363
+ >;
364
+
365
+ <Tag extends keyof React.JSX.IntrinsicElements>(
366
+ tag: Tag,
367
+ options?: StyledConfig<MUIStyledCommonProps> & MuiStyledOptions,
368
+ ): CreateStyledComponent<MUIStyledCommonProps, React.JSX.IntrinsicElements[Tag], {}, Theme>;
321
369
  }
322
370
 
323
371
  export type CreateMUIStyled<
@@ -326,8 +374,9 @@ export type CreateMUIStyled<
326
374
  T extends object = {},
327
375
  > = ThemedBaseStyledInterface<MUIStyledCommonProps, MuiStyledOptions, AnyIfEmpty<T>>;
328
376
 
329
- export type PropsOf<C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> =
330
- JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>;
377
+ export type PropsOf<
378
+ C extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>,
379
+ > = React.JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>;
331
380
 
332
381
  export interface MUIStyledComponent<
333
382
  ComponentProps extends {},
@@ -340,7 +389,7 @@ export interface MUIStyledComponent<
340
389
  withComponent<C extends React.ComponentType<React.ComponentProps<C>>>(
341
390
  component: C,
342
391
  ): MUIStyledComponent<ComponentProps & PropsOf<C>>;
343
- withComponent<Tag extends keyof JSX.IntrinsicElements>(
392
+ withComponent<Tag extends keyof React.JSX.IntrinsicElements>(
344
393
  tag: Tag,
345
- ): MUIStyledComponent<ComponentProps, JSX.IntrinsicElements[Tag]>;
394
+ ): MUIStyledComponent<ComponentProps, React.JSX.IntrinsicElements[Tag]>;
346
395
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine-sc v6.0.0-alpha.8
2
+ * @mui/styled-engine-sc v6.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine-sc v6.0.0-alpha.8
2
+ * @mui/styled-engine-sc v6.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine-sc v6.0.0-alpha.8
2
+ * @mui/styled-engine-sc v6.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -47,7 +47,7 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
47
47
  var _StyledEngineProvider = _interopRequireDefault(require("./StyledEngineProvider"));
48
48
  var _GlobalStyles = _interopRequireDefault(require("./GlobalStyles"));
49
49
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
50
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
50
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
51
51
  function styled(tag, options) {
52
52
  let stylesFactory;
53
53
  if (options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/styled-engine-sc",
3
- "version": "6.0.0-alpha.8",
3
+ "version": "6.0.0-beta.0",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "styled() API wrapper package for styled-components.",
@@ -20,14 +20,14 @@
20
20
  "bugs": {
21
21
  "url": "https://github.com/mui/material-ui/issues"
22
22
  },
23
- "homepage": "https://mui.com/material-ui/guides/styled-components/",
23
+ "homepage": "https://mui.com/material-ui/integrations/styled-components/",
24
24
  "funding": {
25
25
  "type": "opencollective",
26
26
  "url": "https://opencollective.com/mui-org"
27
27
  },
28
28
  "dependencies": {
29
- "@babel/runtime": "^7.23.5",
30
- "csstype": "^3.1.2",
29
+ "@babel/runtime": "^7.24.7",
30
+ "csstype": "^3.1.3",
31
31
  "hoist-non-react-statics": "^3.3.2",
32
32
  "prop-types": "^15.8.1"
33
33
  },
@@ -36,7 +36,8 @@
36
36
  },
37
37
  "sideEffects": false,
38
38
  "publishConfig": {
39
- "access": "public"
39
+ "access": "public",
40
+ "directory": "build"
40
41
  },
41
42
  "engines": {
42
43
  "node": ">=12.0.0"
@@ -1,19 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import { createGlobalStyle } from 'styled-components';
3
- function isEmpty(obj) {
4
- return obj === undefined || obj === null || Object.keys(obj).length === 0;
5
- }
6
- var GlobalStyles = createGlobalStyle(function (props) {
7
- var styles = props.styles,
8
- _props$defaultTheme = props.defaultTheme,
9
- defaultTheme = _props$defaultTheme === void 0 ? {} : _props$defaultTheme;
10
- if (typeof styles === 'function') {
11
- return styles(isEmpty(props.theme) ? defaultTheme : props.theme);
12
- }
13
- return styles;
14
- });
15
- export default GlobalStyles;
16
- GlobalStyles.propTypes = {
17
- defaultTheme: PropTypes.object,
18
- styles: PropTypes.oneOfType([PropTypes.array, PropTypes.string, PropTypes.object, PropTypes.func])
19
- };
@@ -1 +0,0 @@
1
- export { default } from './GlobalStyles';
@@ -1,26 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- export default function StyledEngineProvider(props) {
3
- var injectFirst = props.injectFirst,
4
- children = props.children;
5
- if (injectFirst && typeof window !== 'undefined') {
6
- var head = document.head;
7
- if (!head.querySelector('[data-styled="active"]')) {
8
- var injectFirstNode = document.createElement('style');
9
- injectFirstNode.setAttribute('data-styled', 'active');
10
- head.insertBefore(injectFirstNode, head.firstChild);
11
- }
12
- }
13
- return children;
14
- }
15
- StyledEngineProvider.propTypes = {
16
- /**
17
- * Your component tree.
18
- */
19
- children: PropTypes.node,
20
- /**
21
- * By default, the styles are injected last in the <head> element of the page.
22
- * As a result, they gain more specificity than any other style sheet.
23
- * If you want to override MUI's styles, set this prop.
24
- */
25
- injectFirst: PropTypes.bool
26
- };
@@ -1 +0,0 @@
1
- export { default } from './StyledEngineProvider';
package/legacy/index.js DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * @mui/styled-engine-sc v6.0.0-alpha.8
3
- *
4
- * @license MIT
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- import scStyled from 'styled-components';
9
- export default function styled(tag, options) {
10
- var stylesFactory;
11
- if (options) {
12
- stylesFactory = scStyled(tag).withConfig({
13
- displayName: options.label,
14
- shouldForwardProp: options.shouldForwardProp
15
- });
16
- } else {
17
- stylesFactory = scStyled(tag);
18
- }
19
- if (process.env.NODE_ENV !== 'production') {
20
- var fn = function fn() {
21
- var component = typeof tag === 'string' ? "\"".concat(tag, "\"") : 'component';
22
- for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
23
- styles[_key] = arguments[_key];
24
- }
25
- if (styles.length === 0) {
26
- console.error(["MUI: Seems like you called `styled(".concat(component, ")()` without a `style` argument."), 'You must provide a `styles` argument: `styled("div")(styleYouForgotToPass)`.'].join('\n'));
27
- } else if (styles.some(function (style) {
28
- return style === undefined;
29
- })) {
30
- console.error("MUI: the styled(".concat(component, ")(...args) API requires all its args to be defined."));
31
- }
32
- return stylesFactory.apply(void 0, styles);
33
- };
34
- fn.withConfig = stylesFactory.withConfig;
35
- return fn;
36
- }
37
- return stylesFactory;
38
- }
39
-
40
- // eslint-disable-next-line @typescript-eslint/naming-convention
41
- export var internal_processStyles = function internal_processStyles(tag, processor) {
42
- // Styled-components attaches an instance to `componentStyle`.
43
- // https://github.com/styled-components/styled-components/blob/da8151762dcf72735ffba358173d4c097f6d5888/packages/styled-components/src/models/StyledComponent.ts#L257
44
- //
45
- // The instance contains `rules` (the styles)
46
- // https://github.com/styled-components/styled-components/blob/da8151762dcf72735ffba358173d4c097f6d5888/packages/styled-components/src/models/ComponentStyle.ts#L23
47
- if (tag.componentStyle) {
48
- tag.componentStyle.rules = processor(tag.componentStyle.rules);
49
- }
50
- };
51
- export { ThemeContext, keyframes, css } from 'styled-components';
52
- export { default as StyledEngineProvider } from './StyledEngineProvider';
53
- export { default as GlobalStyles } from './GlobalStyles';