From ccdf28d8448dc0254cb240ed5293cdddc67be59d Mon Sep 17 00:00:00 2001 From: mickaelaustoni Date: Tue, 13 Dec 2022 14:49:04 +0100 Subject: [PATCH 1/6] Add InputLabel props size overrides --- packages/mui-material/src/InputLabel/InputLabel.d.ts | 5 ++++- packages/mui-material/src/InputLabel/InputLabel.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/mui-material/src/InputLabel/InputLabel.d.ts b/packages/mui-material/src/InputLabel/InputLabel.d.ts index 70254ebc615996..8ec7ccc092c21a 100644 --- a/packages/mui-material/src/InputLabel/InputLabel.d.ts +++ b/packages/mui-material/src/InputLabel/InputLabel.d.ts @@ -1,10 +1,13 @@ import * as React from 'react'; import { SxProps } from '@mui/system'; +import { OverridableStringUnion } from '@mui/types'; import { InternalStandardProps as StandardProps } from '..'; import { FormLabelProps } from '../FormLabel'; import { Theme } from '../styles'; import { InputLabelClasses } from './inputLabelClasses'; +export interface InputLabelPropsSizeOverrides {} + export interface InputLabelProps extends StandardProps { /** * The content of the component. @@ -49,7 +52,7 @@ export interface InputLabelProps extends StandardProps { * The size of the component. * @default 'normal' */ - size?: 'small' | 'normal'; + size?: OverridableStringUnion<'small' | 'normal', InputLabelPropsSizeOverrides>; /** * The system prop that allows defining system overrides as well as additional CSS styles. */ diff --git a/packages/mui-material/src/InputLabel/InputLabel.js b/packages/mui-material/src/InputLabel/InputLabel.js index 6f255af7f7950e..38afef6adc300f 100644 --- a/packages/mui-material/src/InputLabel/InputLabel.js +++ b/packages/mui-material/src/InputLabel/InputLabel.js @@ -210,7 +210,10 @@ InputLabel.propTypes /* remove-proptypes */ = { * The size of the component. * @default 'normal' */ - size: PropTypes.oneOf(['normal', 'small']), + size: PropTypes.oneOfType([ + PropTypes.oneOf(['normal', 'small']), + PropTypes.string, + ]), /** * The system prop that allows defining system overrides as well as additional CSS styles. */ From 28ed8ed424dfc3c0c79a13e209578bb2f72a3cc6 Mon Sep 17 00:00:00 2001 From: mickaelaustoni Date: Tue, 13 Dec 2022 14:54:58 +0100 Subject: [PATCH 2/6] fix typescript-to-proptypes-ignore --- packages/mui-material/src/InputLabel/InputLabel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mui-material/src/InputLabel/InputLabel.js b/packages/mui-material/src/InputLabel/InputLabel.js index 38afef6adc300f..035cc13bf23801 100644 --- a/packages/mui-material/src/InputLabel/InputLabel.js +++ b/packages/mui-material/src/InputLabel/InputLabel.js @@ -210,7 +210,7 @@ InputLabel.propTypes /* remove-proptypes */ = { * The size of the component. * @default 'normal' */ - size: PropTypes.oneOfType([ + size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([ PropTypes.oneOf(['normal', 'small']), PropTypes.string, ]), From b30a838e1a64047932895661d39d68cc6512dec4 Mon Sep 17 00:00:00 2001 From: mickaelaustoni Date: Thu, 15 Dec 2022 07:42:12 +0100 Subject: [PATCH 3/6] update docs --- docs/pages/material-ui/api/input-label.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/pages/material-ui/api/input-label.json b/docs/pages/material-ui/api/input-label.json index a0c99198d65752..60ede4065e70a7 100644 --- a/docs/pages/material-ui/api/input-label.json +++ b/docs/pages/material-ui/api/input-label.json @@ -16,7 +16,10 @@ "required": { "type": { "name": "bool" } }, "shrink": { "type": { "name": "bool" } }, "size": { - "type": { "name": "enum", "description": "'normal'
| 'small'" }, + "type": { + "name": "union", + "description": "'medium'
| 'small'
| string" + }, "default": "'normal'" }, "sx": { From ec69e945d87aeb9c46315f1038615848618d08a1 Mon Sep 17 00:00:00 2001 From: mickaelaustoni Date: Thu, 15 Dec 2022 08:04:52 +0100 Subject: [PATCH 4/6] add test --- .../InputLabelCustomProps.spec.tsx | 13 +++++++++++++ .../InputLabelCustomProps.tsconfig.json | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx create mode 100644 packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.tsconfig.json diff --git a/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx new file mode 100644 index 00000000000000..b24d633768bbb8 --- /dev/null +++ b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx @@ -0,0 +1,13 @@ +import * as React from 'react'; +import { InputLabel } from '@mui/material'; + +declare module '@mui/material/InputLabel' { + interface InputLabelPropsSizeOverrides { + customSize: true; + } +} + +; + +// @ts-expect-error unknown size +; diff --git a/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.tsconfig.json b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.tsconfig.json new file mode 100644 index 00000000000000..f53a33cae0908f --- /dev/null +++ b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../../../tsconfig", + "files": ["InputLabelCustomProps.spec.tsx"] +} From fb33dbabbe2260b195130e177dd9b74e3eb7906a Mon Sep 17 00:00:00 2001 From: mickaelaustoni Date: Thu, 15 Dec 2022 08:26:34 +0100 Subject: [PATCH 5/6] docs --- docs/pages/material-ui/api/input-label.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/material-ui/api/input-label.json b/docs/pages/material-ui/api/input-label.json index 60ede4065e70a7..e7d399998a1e21 100644 --- a/docs/pages/material-ui/api/input-label.json +++ b/docs/pages/material-ui/api/input-label.json @@ -18,7 +18,7 @@ "size": { "type": { "name": "union", - "description": "'medium'
| 'small'
| string" + "description": "'normal'
| 'small'
| string" }, "default": "'normal'" }, From 80b9d24df53af5d94bb926ae6d62f3c865e8be2e Mon Sep 17 00:00:00 2001 From: mickaelaustoni Date: Thu, 15 Dec 2022 08:52:15 +0100 Subject: [PATCH 6/6] change path import --- .../moduleAugmentation/InputLabelCustomProps.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx index b24d633768bbb8..42d25f1922ff95 100644 --- a/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx +++ b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { InputLabel } from '@mui/material'; +import InputLabel from '@mui/material/InputLabel'; declare module '@mui/material/InputLabel' { interface InputLabelPropsSizeOverrides {