@rjsf/mui 6.2.4 → 6.2.5
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.
- package/dist/index.cjs +27 -13
- package/dist/index.cjs.map +3 -3
- package/dist/mui.esm.js +27 -13
- package/dist/mui.esm.js.map +2 -2
- package/dist/mui.umd.js +27 -13
- package/lib/BaseInputTemplate/BaseInputTemplate.js +23 -13
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +35 -18
package/package.json
CHANGED
|
@@ -51,23 +51,28 @@ export default function BaseInputTemplate<
|
|
|
51
51
|
errorSchema,
|
|
52
52
|
registry,
|
|
53
53
|
InputLabelProps,
|
|
54
|
+
InputProps,
|
|
55
|
+
slotProps,
|
|
54
56
|
...textFieldProps
|
|
55
57
|
} = props;
|
|
56
58
|
const { ClearButton } = registry.templates.ButtonTemplates;
|
|
57
|
-
const inputProps = getInputProps<T, S, F>(schema, type, options);
|
|
58
59
|
// Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
59
|
-
const { step, min, max, accept, ...rest } =
|
|
60
|
-
const htmlInputProps = {
|
|
60
|
+
const { step, min, max, accept, ...rest } = getInputProps<T, S, F>(schema, type, options);
|
|
61
|
+
const htmlInputProps = {
|
|
62
|
+
...slotProps?.htmlInput,
|
|
63
|
+
step,
|
|
64
|
+
min,
|
|
65
|
+
max,
|
|
66
|
+
accept,
|
|
67
|
+
...(schema.examples ? { list: examplesId(id) } : undefined),
|
|
68
|
+
};
|
|
61
69
|
const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
|
|
62
70
|
onChange(value === '' ? options.emptyValue : value);
|
|
63
71
|
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
|
|
64
72
|
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
65
73
|
const DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type)
|
|
66
|
-
? {
|
|
67
|
-
|
|
68
|
-
shrink: true,
|
|
69
|
-
}
|
|
70
|
-
: InputLabelProps;
|
|
74
|
+
? { ...slotProps?.inputLabel, ...InputLabelProps, shrink: true }
|
|
75
|
+
: { ...slotProps?.inputLabel, ...InputLabelProps };
|
|
71
76
|
const _onClear = useCallback(
|
|
72
77
|
(e: MouseEvent) => {
|
|
73
78
|
e.preventDefault();
|
|
@@ -76,6 +81,22 @@ export default function BaseInputTemplate<
|
|
|
76
81
|
},
|
|
77
82
|
[onChange, options.emptyValue],
|
|
78
83
|
);
|
|
84
|
+
const inputProps = { ...InputProps, ...slotProps?.input };
|
|
85
|
+
if (options.allowClearTextInputs && value && !readonly && !disabled) {
|
|
86
|
+
const clearAdornment = (
|
|
87
|
+
<InputAdornment position='end'>
|
|
88
|
+
<ClearButton registry={registry} onClick={_onClear} />
|
|
89
|
+
</InputAdornment>
|
|
90
|
+
);
|
|
91
|
+
inputProps.endAdornment = !inputProps.endAdornment ? (
|
|
92
|
+
clearAdornment
|
|
93
|
+
) : (
|
|
94
|
+
<>
|
|
95
|
+
{inputProps.endAdornment}
|
|
96
|
+
{clearAdornment}
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
79
100
|
|
|
80
101
|
return (
|
|
81
102
|
<>
|
|
@@ -87,7 +108,12 @@ export default function BaseInputTemplate<
|
|
|
87
108
|
autoFocus={autofocus}
|
|
88
109
|
required={required}
|
|
89
110
|
disabled={disabled || readonly}
|
|
90
|
-
slotProps={{
|
|
111
|
+
slotProps={{
|
|
112
|
+
...slotProps,
|
|
113
|
+
input: inputProps,
|
|
114
|
+
htmlInput: htmlInputProps,
|
|
115
|
+
inputLabel: DisplayInputLabelProps,
|
|
116
|
+
}}
|
|
91
117
|
{...rest}
|
|
92
118
|
value={value || value === 0 ? value : ''}
|
|
93
119
|
error={rawErrors.length > 0}
|
|
@@ -96,15 +122,6 @@ export default function BaseInputTemplate<
|
|
|
96
122
|
onFocus={_onFocus}
|
|
97
123
|
{...(textFieldProps as TextFieldProps)}
|
|
98
124
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
99
|
-
InputProps={{
|
|
100
|
-
...textFieldProps.InputProps,
|
|
101
|
-
endAdornment:
|
|
102
|
-
options.allowClearTextInputs && value && !readonly && !disabled ? (
|
|
103
|
-
<InputAdornment position='end'>
|
|
104
|
-
<ClearButton registry={registry} onClick={_onClear} />
|
|
105
|
-
</InputAdornment>
|
|
106
|
-
) : undefined,
|
|
107
|
-
}}
|
|
108
125
|
/>
|
|
109
126
|
{Array.isArray(schema.examples) && (
|
|
110
127
|
<datalist id={examplesId(id)}>
|