=
layout === 'phone number' || layout === 'number' || layout === 'card number'
? {
inputMode: layout === 'phone number' ? 'tel' : 'numeric',
...(layout === 'phone number' ? { pattern: '^(?:\\+\\d{12}|\\d{10})$' } : {}),
onKeyDown: handleNumericKeyDown,
...(layout === 'phone number' ? { onInput: handlePhoneInput } : {}),
}
: {};
const consumerInputProps =
typeof consumerSlotProps?.input === 'object' && consumerSlotProps?.input !== null
? (consumerSlotProps.input as InputProps)
: undefined;
const inputSlotProps: InputProps = {
...legacyInputProps,
...consumerInputProps,
className: clsx(
'rds-input__field',
legacyInputProps?.className,
consumerInputProps?.className,
),
classes: {
root: active ? 'Mui-focused' : '',
focused: active ? 'Mui-focused' : '',
...legacyInputProps?.classes,
...consumerInputProps?.classes,
},
startAdornment:
iconPosition === 'start' && showIcon
? renderIcon()
: consumerInputProps?.startAdornment ?? legacyInputProps?.startAdornment,
endAdornment:
iconPosition === 'end' && showIcon
? renderIcon()
: consumerInputProps?.endAdornment ?? legacyInputProps?.endAdornment,
};
return (
{titlePosition === 'title-above' && label && (
)}
{ setIsFocused(true); onFocus?.(e); }}
onBlur={(e) => { setIsFocused(false); onBlur?.(e); }}
slotProps={{
...consumerSlotProps,
input: inputSlotProps,
htmlInput: {
...numericInputProps,
...consumerSlotProps?.htmlInput,
},
}}
{...props}
/>
);
};
RdsInput.displayName = 'RdsInput';
export default RdsInput;