(props, inputClasses);
const ownerState = {
...props,
@@ -257,39 +228,12 @@ const Input = React.forwardRef(function Input(inProps, ref) {
error: errorState,
focused,
formControlContext: formControlContext!,
- type,
size,
variant,
};
- const rootStateClasses = {
- [inputClasses.disabled]: disabledState,
- [inputClasses.error]: errorState,
- [inputClasses.focused]: focused,
- [inputClasses.formControl]: Boolean(formControlContext),
- };
-
- const inputStateClasses = {
- [inputClasses.disabled]: disabledState,
- };
-
const classes = useUtilityClasses(ownerState);
- const propsToForward = {
- 'aria-describedby': ariaDescribedby,
- 'aria-label': ariaLabel,
- 'aria-labelledby': ariaLabelledby,
- autoComplete,
- autoFocus,
- id,
- onKeyDown,
- onKeyUp,
- name,
- placeholder,
- readOnly,
- type,
- };
-
const rootProps = useSlotProps({
elementType: InputRoot,
getSlotProps: getRootProps,
@@ -300,7 +244,7 @@ const Input = React.forwardRef(function Input(inProps, ref) {
as: component,
},
ownerState,
- className: [classes.root, rootStateClasses, className],
+ className: [classes.root, rootStateClasses],
});
const inputProps = useSlotProps({
@@ -341,33 +285,15 @@ Input.propTypes /* remove-proptypes */ = {
/**
* @ignore
*/
- 'aria-describedby': PropTypes.string,
- /**
- * @ignore
- */
- 'aria-label': PropTypes.string,
- /**
- * @ignore
- */
- 'aria-labelledby': PropTypes.string,
- /**
- * This prop helps users to fill forms faster, especially on mobile devices.
- * The name can be confusing, as it's more like an autofill.
- * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
- */
autoComplete: PropTypes.string,
/**
- * If `true`, the `input` element is focused during the first mount.
+ * @ignore
*/
autoFocus: PropTypes.bool,
/**
* @ignore
*/
children: PropTypes.node,
- /**
- * Override or extend the styles applied to the component.
- */
- classes: PropTypes.object,
/**
* Class name applied to the root element.
*/
@@ -380,11 +306,6 @@ Input.propTypes /* remove-proptypes */ = {
PropTypes.oneOf(['danger', 'info', 'neutral', 'primary', 'success', 'warning']),
PropTypes.string,
]),
- /**
- * The component used for the root node.
- * Either a string to use a HTML element or a component.
- */
- component: PropTypes.elementType,
/**
* The props used for each slot inside the Input.
* @default {}
@@ -394,12 +315,15 @@ Input.propTypes /* remove-proptypes */ = {
root: PropTypes.object,
}),
/**
- * The default value. Use when the component is not controlled.
+ * @ignore
*/
- defaultValue: PropTypes.any,
+ defaultValue: PropTypes.oneOfType([
+ PropTypes.arrayOf(PropTypes.string),
+ PropTypes.number,
+ PropTypes.string,
+ ]),
/**
- * If `true`, the component is disabled.
- * The prop defaults to the value (`false`) inherited from the parent FormControl component.
+ * @ignore
*/
disabled: PropTypes.bool,
/**
@@ -417,17 +341,13 @@ Input.propTypes /* remove-proptypes */ = {
*/
fullWidth: PropTypes.bool,
/**
- * The id of the `input` element.
+ * @ignore
*/
id: PropTypes.string,
- /**
- * Name attribute of the `input` element.
- */
- name: PropTypes.string,
/**
* @ignore
*/
- onBlur: PropTypes.func,
+ name: PropTypes.string,
/**
* @ignore
*/
@@ -435,31 +355,13 @@ Input.propTypes /* remove-proptypes */ = {
/**
* @ignore
*/
- onClick: PropTypes.func,
- /**
- * @ignore
- */
- onFocus: PropTypes.func,
- /**
- * @ignore
- */
- onKeyDown: PropTypes.func,
- /**
- * @ignore
- */
- onKeyUp: PropTypes.func,
- /**
- * The short hint displayed in the `input` before the user enters a value.
- */
placeholder: PropTypes.string,
/**
- * It prevents the user from changing the value of the field
- * (not from interacting with the field).
+ * @ignore
*/
readOnly: PropTypes.bool,
/**
- * If `true`, the `input` element is required.
- * The prop defaults to the value (`false`) inherited from the parent FormControl component.
+ * @ignore
*/
required: PropTypes.bool,
/**
@@ -483,14 +385,13 @@ Input.propTypes /* remove-proptypes */ = {
PropTypes.object,
]),
/**
- * Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
- * @default 'plain'
- */
- type: PropTypes.string,
- /**
- * The value of the `input` element, required for a controlled component.
+ * @ignore
*/
- value: PropTypes.any,
+ value: PropTypes.oneOfType([
+ PropTypes.arrayOf(PropTypes.string),
+ PropTypes.number,
+ PropTypes.string,
+ ]),
/**
* The variant to use.
* @default 'outlined'
diff --git a/packages/mui-joy/src/Input/InputProps.ts b/packages/mui-joy/src/Input/InputProps.ts
index c137c5ebcb0e3b..7331d9f2d9c7a7 100644
--- a/packages/mui-joy/src/Input/InputProps.ts
+++ b/packages/mui-joy/src/Input/InputProps.ts
@@ -1,7 +1,5 @@
import React from 'react';
import { OverridableStringUnion, OverrideProps } from '@mui/types';
-import { UseInputParameters } from '@mui/base/InputUnstyled';
-import { InputClasses } from './inputClasses';
import { ColorPaletteProp, VariantProp, SxProps } from '../styles/types';
export type InputSlot = 'root' | 'input' | 'startDecorator' | 'endDecorator';
@@ -14,28 +12,30 @@ export interface InputPropsSizeOverrides {}
export interface InputTypeMap {
props: P &
- Omit & {
- 'aria-describedby'?: string;
- 'aria-label'?: string;
- 'aria-labelledby'?: string;
- /**
- * This prop helps users to fill forms faster, especially on mobile devices.
- * The name can be confusing, as it's more like an autofill.
- * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
- */
- autoComplete?: string;
- /**
- * If `true`, the `input` element is focused during the first mount.
- */
- autoFocus?: boolean;
+ Pick<
+ React.InputHTMLAttributes,
+ | 'autoComplete'
+ | 'autoFocus'
+ | 'onClick'
+ | 'onChange'
+ | 'onKeyDown'
+ | 'onKeyUp'
+ | 'onFocus'
+ | 'onBlur'
+ | 'defaultValue'
+ | 'value'
+ | 'type'
+ | 'placeholder'
+ | 'readOnly'
+ | 'required'
+ | 'name'
+ | 'id'
+ | 'disabled'
+ > & {
/**
* Class name applied to the root element.
*/
className?: string;
- /**
- * Override or extend the styles applied to the component.
- */
- classes?: Partial;
/**
* The color of the component. It supports those theme colors that make sense for this component.
* @default 'neutral'
@@ -56,30 +56,16 @@ export interface InputTypeMap {
* Trailing adornment for this input.
*/
endDecorator?: React.ReactNode;
+ /**
+ * If `true`, the `input` will indicate an error.
+ * The prop defaults to the value (`false`) inherited from the parent FormControl component.
+ */
+ error?: boolean;
/**
* If `true`, the button will take up the full width of its container.
* @default false
*/
fullWidth?: boolean;
- /**
- * The id of the `input` element.
- */
- id?: string;
- /**
- * Name attribute of the `input` element.
- */
- name?: string;
- onKeyDown?: React.KeyboardEventHandler;
- onKeyUp?: React.KeyboardEventHandler;
- /**
- * The short hint displayed in the `input` before the user enters a value.
- */
- placeholder?: string;
- /**
- * It prevents the user from changing the value of the field
- * (not from interacting with the field).
- */
- readOnly?: boolean;
/**
* Leading adornment for this input.
*/
@@ -93,15 +79,6 @@ export interface InputTypeMap {
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps;
- /**
- * Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types).
- * @default 'plain'
- */
- type?: string;
- /**
- * The value of the `input` element, required for a controlled component.
- */
- value?: unknown;
/**
* The variant to use.
* @default 'outlined'
diff --git a/packages/mui-joy/src/Input/useForwardedInput.ts b/packages/mui-joy/src/Input/useForwardedInput.ts
new file mode 100644
index 00000000000000..ca45113fae4837
--- /dev/null
+++ b/packages/mui-joy/src/Input/useForwardedInput.ts
@@ -0,0 +1,88 @@
+import { useInput } from '@mui/base/InputUnstyled';
+
+export default function useForwardedInput