@mui/types 7.1.3 → 7.2.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.
@@ -0,0 +1,44 @@
1
+ import * as React from 'react';
2
+
3
+ declare module '@mui/types' {
4
+ /**
5
+ * A component whose root component can be controlled via a `component` prop.
6
+ *
7
+ * Adjusts valid props based on the type of `component`.
8
+ */
9
+ interface OverridableComponent<M extends OverridableTypeMap> {
10
+ <C extends React.ElementType>(
11
+ props: {
12
+ /**
13
+ * The component used for the root node.
14
+ * Either a string to use a HTML element or a component.
15
+ */
16
+ component: C;
17
+ } & OverridePropsVer2<M, C>,
18
+ ): JSX.Element;
19
+ (props: DefaultComponentPropsVer2<M>): JSX.Element;
20
+ propTypes?: any;
21
+ }
22
+
23
+ /**
24
+ * Props of the component if `component={Component}` is used.
25
+ */
26
+ // prettier-ignore
27
+ type OverridePropsVer2<
28
+ M extends OverridableTypeMap,
29
+ C extends React.ElementType
30
+ > = (
31
+ & BaseProps<M>
32
+ & DistributiveOmit<React.ComponentPropsWithoutRef<C>, keyof BaseProps<M>>
33
+ & { ref?: React.Ref<Element> }
34
+ );
35
+
36
+ /**
37
+ * Props if `component={Component}` is NOT used.
38
+ */
39
+ // prettier-ignore
40
+ type DefaultComponentPropsVer2<M extends OverridableTypeMap> =
41
+ & BaseProps<M>
42
+ & DistributiveOmit<React.ComponentPropsWithoutRef<M['defaultComponent']>, keyof BaseProps<M>>
43
+ & { ref?: React.Ref<Element> };
44
+ }
package/index.d.ts CHANGED
@@ -67,7 +67,7 @@ type GenerateStringUnion<T> = Extract<
67
67
  >;
68
68
 
69
69
  // https://stackoverflow.com/questions/53807517/how-to-test-if-two-types-are-exactly-the-same
70
- type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <
70
+ export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <
71
71
  G,
72
72
  >() => G extends U ? 1 : 2
73
73
  ? Y
@@ -92,6 +92,10 @@ export function expectType<Expected, Actual>(actual: IfEquals<Actual, Expected,
92
92
  * Adjusts valid props based on the type of `component`.
93
93
  */
94
94
  export interface OverridableComponent<M extends OverridableTypeMap> {
95
+ // If you make any changes to this interface, please make sure to update the
96
+ // `OverridableComponent` type in `mui-material/src/OverridableComponent.d.ts` as well.
97
+ // Also, there are types in MUI Base that have a similar shape to this interface
98
+ // (e.g. SelectUnstyledType, OptionUnstyledType, etc.).
95
99
  <C extends React.ElementType>(
96
100
  props: {
97
101
  /**
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@mui/types",
3
- "version": "7.1.3",
3
+ "version": "7.2.0",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility types for MUI.",
7
7
  "types": "./index.d.ts",
8
8
  "files": [
9
- "index.d.ts"
9
+ "index.d.ts",
10
+ "OverridableComponentAugmentation.ts"
10
11
  ],
11
12
  "keywords": [
12
13
  "react",