From 1319d73e9f75740f72b655c7fc2f914f3a67d3da Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Mon, 19 Dec 2022 10:27:43 +0700 Subject: [PATCH 1/4] add experimental_sx with error --- docs/public/static/error-codes.json | 7 +++++-- packages/mui-material/src/styles/index.d.ts | 3 +++ packages/mui-material/src/styles/index.js | 10 ++++++++++ packages/mui-system/src/index.d.ts | 4 ++++ packages/mui-system/src/index.js | 10 ++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/public/static/error-codes.json b/docs/public/static/error-codes.json index 0cc6f9b9a9db27..97df381dd88a3e 100644 --- a/docs/public/static/error-codes.json +++ b/docs/public/static/error-codes.json @@ -17,5 +17,8 @@ "16": "MUI: withTheme is no longer exported from @mui/material/styles.\nYou have to import it from @mui/styles.\nSee https://mui.com/r/migration-v4/#mui-material-styles for more details.", "17": "MUI: Expected valid input target. Did you use a custom `slots.input` and forget to forward refs? See https://mui.com/r/input-component-ref-interface for more info.", "18": "MUI: `vars` is a private field used for CSS variables support.\nPlease use another name.", - "19": "MUI: `useColorScheme` must be called under " -} + "19": "MUI: `useColorScheme` must be called under ", + "20": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.For more details, see https://github.com/mui/material-ui/pull/35150", + "21": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.To migrate, see https://mui.com/material-ui/customization/theme-components/#the-sx-syntax-experimental", + "22": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.You should remove the import and replace the usage with `theme.unstable_sx(…same value you pass to experimental_sx)` instead." +} \ No newline at end of file diff --git a/packages/mui-material/src/styles/index.d.ts b/packages/mui-material/src/styles/index.d.ts index f7d1a625424649..7b97e384404e37 100644 --- a/packages/mui-material/src/styles/index.d.ts +++ b/packages/mui-material/src/styles/index.d.ts @@ -65,6 +65,9 @@ export { StyledEngineProvider, SxProps, } from '@mui/system'; +// TODO: Remove this function in v6. +// eslint-disable-next-line @typescript-eslint/naming-convention +export function experimental_sx(): any; export { default as useTheme } from './useTheme'; export { default as useThemeProps } from './useThemeProps'; export * from './useThemeProps'; diff --git a/packages/mui-material/src/styles/index.js b/packages/mui-material/src/styles/index.js index c87fa88993319e..ad6b09150cbea7 100644 --- a/packages/mui-material/src/styles/index.js +++ b/packages/mui-material/src/styles/index.js @@ -1,3 +1,5 @@ +import MuiError from '@mui/utils/macros/MuiError.macro'; + export { default as adaptV4Theme } from './adaptV4Theme'; export { hexToRgb, @@ -14,6 +16,14 @@ export { css, keyframes, } from '@mui/system'; +// TODO: Remove this function in v6. +// eslint-disable-next-line @typescript-eslint/naming-convention +export function experimental_sx() { + throw new MuiError( + 'MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.' + + 'To migrate, see https://mui.com/material-ui/customization/theme-components/#the-sx-syntax-experimental', + ); +} export { default as createTheme, createMuiTheme } from './createTheme'; export { default as unstable_createMuiStrictModeTheme } from './createMuiStrictModeTheme'; export { default as createStyles } from './createStyles'; diff --git a/packages/mui-system/src/index.d.ts b/packages/mui-system/src/index.d.ts index 2f2a9d6b838bdb..6187f48d589ddf 100644 --- a/packages/mui-system/src/index.d.ts +++ b/packages/mui-system/src/index.d.ts @@ -123,6 +123,10 @@ export { } from './styleFunctionSx'; export * from './styleFunctionSx'; +// TODO: Remove this function in v6. +// eslint-disable-next-line @typescript-eslint/naming-convention +export function experimental_sx(): any; + export { default as Box } from './Box'; export * from './Box'; diff --git a/packages/mui-system/src/index.js b/packages/mui-system/src/index.js index a3bf2528a8cc89..9c224b3f89329a 100644 --- a/packages/mui-system/src/index.js +++ b/packages/mui-system/src/index.js @@ -1,3 +1,5 @@ +import MuiError from '@mui/utils/macros/MuiError.macro'; + export { css, keyframes, GlobalStyles, StyledEngineProvider } from '@mui/styled-engine'; export { default as borders } from './borders'; export * from './borders'; @@ -31,6 +33,14 @@ export { extendSxProp as unstable_extendSxProp, unstable_defaultSxConfig, } from './styleFunctionSx'; +// TODO: Remove this function in v6 +// eslint-disable-next-line @typescript-eslint/naming-convention +export function experimental_sx() { + throw new MuiError( + 'MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.' + + 'You should remove the import and replace the usage with `theme.unstable_sx(…same value you pass to experimental_sx)` instead.', + ); +} export { default as unstable_getThemeValue } from './getThemeValue'; export { default as Box } from './Box'; export { default as createBox } from './createBox'; From a302eeda12f3b43b20172563dfb6615b6776dba5 Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Mon, 19 Dec 2022 10:52:30 +0700 Subject: [PATCH 2/4] prettier --- docs/public/static/error-codes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/public/static/error-codes.json b/docs/public/static/error-codes.json index 97df381dd88a3e..fa0c5b5598e2c8 100644 --- a/docs/public/static/error-codes.json +++ b/docs/public/static/error-codes.json @@ -21,4 +21,4 @@ "20": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.For more details, see https://github.com/mui/material-ui/pull/35150", "21": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.To migrate, see https://mui.com/material-ui/customization/theme-components/#the-sx-syntax-experimental", "22": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.You should remove the import and replace the usage with `theme.unstable_sx(…same value you pass to experimental_sx)` instead." -} \ No newline at end of file +} From 118938bc269003bee06005baab4e3e20353b9fff Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Mon, 19 Dec 2022 20:45:52 +0700 Subject: [PATCH 3/4] use the same message --- docs/public/static/error-codes.json | 5 +++-- packages/mui-material/src/styles/index.js | 2 +- packages/mui-system/src/index.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/public/static/error-codes.json b/docs/public/static/error-codes.json index fa0c5b5598e2c8..3b007ea84e4b77 100644 --- a/docs/public/static/error-codes.json +++ b/docs/public/static/error-codes.json @@ -20,5 +20,6 @@ "19": "MUI: `useColorScheme` must be called under ", "20": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.For more details, see https://github.com/mui/material-ui/pull/35150", "21": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.To migrate, see https://mui.com/material-ui/customization/theme-components/#the-sx-syntax-experimental", - "22": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.You should remove the import and replace the usage with `theme.unstable_sx(…same value you pass to experimental_sx)` instead." -} + "22": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.You should remove the import and replace the usage with `theme.unstable_sx(…same value you pass to experimental_sx)` instead.", + "23": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.For more details, see https://github.com/mui/material-ui/pull/35150." +} \ No newline at end of file diff --git a/packages/mui-material/src/styles/index.js b/packages/mui-material/src/styles/index.js index ad6b09150cbea7..b1801a34a373ac 100644 --- a/packages/mui-material/src/styles/index.js +++ b/packages/mui-material/src/styles/index.js @@ -21,7 +21,7 @@ export { export function experimental_sx() { throw new MuiError( 'MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.' + - 'To migrate, see https://mui.com/material-ui/customization/theme-components/#the-sx-syntax-experimental', + 'For more details, see https://github.com/mui/material-ui/pull/35150.', ); } export { default as createTheme, createMuiTheme } from './createTheme'; diff --git a/packages/mui-system/src/index.js b/packages/mui-system/src/index.js index 9c224b3f89329a..fa438972642b9b 100644 --- a/packages/mui-system/src/index.js +++ b/packages/mui-system/src/index.js @@ -38,7 +38,7 @@ export { export function experimental_sx() { throw new MuiError( 'MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.' + - 'You should remove the import and replace the usage with `theme.unstable_sx(…same value you pass to experimental_sx)` instead.', + 'For more details, see https://github.com/mui/material-ui/pull/35150.', ); } export { default as unstable_getThemeValue } from './getThemeValue'; From 1349d74a17d76f1e5c40843ef4f0d99d7e7af1c2 Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Tue, 20 Dec 2022 09:49:10 +0700 Subject: [PATCH 4/4] remove unused code --- docs/public/static/error-codes.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/public/static/error-codes.json b/docs/public/static/error-codes.json index 3b007ea84e4b77..a6486f38f45d49 100644 --- a/docs/public/static/error-codes.json +++ b/docs/public/static/error-codes.json @@ -18,8 +18,5 @@ "17": "MUI: Expected valid input target. Did you use a custom `slots.input` and forget to forward refs? See https://mui.com/r/input-component-ref-interface for more info.", "18": "MUI: `vars` is a private field used for CSS variables support.\nPlease use another name.", "19": "MUI: `useColorScheme` must be called under ", - "20": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.For more details, see https://github.com/mui/material-ui/pull/35150", - "21": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.To migrate, see https://mui.com/material-ui/customization/theme-components/#the-sx-syntax-experimental", - "22": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.You should remove the import and replace the usage with `theme.unstable_sx(…same value you pass to experimental_sx)` instead.", - "23": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.For more details, see https://github.com/mui/material-ui/pull/35150." -} \ No newline at end of file + "20": "MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.For more details, see https://github.com/mui/material-ui/pull/35150." +}