@vertigis/react-ui 19.0.1 → 19.0.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
2
|
+
import { forwardRef, useMemo } from "react";
|
|
3
3
|
import FormControl from "../FormControl/index.js";
|
|
4
4
|
import FormHelperText from "../FormHelperText/index.js";
|
|
5
5
|
import FormLabel from "../FormLabel/index.js";
|
|
@@ -11,17 +11,45 @@ import { useId } from "../utils/react.js";
|
|
|
11
11
|
* for inline help.
|
|
12
12
|
*/
|
|
13
13
|
const FormLabelTextField = forwardRef((props, ref) => {
|
|
14
|
-
const { autoComplete, autoFocus = false, children, defaultValue, FormHelperTextProps, fullWidth = false, helperText, id: idProp, InputLabelProps, inputProps, InputProps, inputRef, label, maxRows, minRows, multiline = false, name, nativeSelect = false, onBlur, onChange, onFocus, placeholder, rows, select = false, SelectProps, type, value, ...other } = props;
|
|
14
|
+
const { autoComplete, autoFocus = false, children, defaultValue, FormHelperTextProps, fullWidth = false, helperText, id: idProp, InputLabelProps, inputProps, InputProps, inputRef, label, maxRows, minRows, multiline = false, name, nativeSelect = false, onBlur, onChange, onFocus, placeholder, rows, select = false, SelectProps, slotProps, type, value, ...other } = props;
|
|
15
15
|
const id = useId(idProp);
|
|
16
16
|
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
17
17
|
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
18
|
-
const
|
|
18
|
+
const { formHelperTextProps, inputLabelProps, htmlInputProps, propsForInput, selectProps } = useMemo(() => {
|
|
19
|
+
const formHelperTextProps = (slotProps?.formHelperText ??
|
|
20
|
+
FormHelperTextProps ??
|
|
21
|
+
{});
|
|
22
|
+
const htmlInputProps = slotProps?.htmlInput ?? inputProps;
|
|
23
|
+
const inputLabelProps = (slotProps?.inputLabel ??
|
|
24
|
+
InputLabelProps ??
|
|
25
|
+
{});
|
|
26
|
+
const propsForInput = (slotProps?.input ??
|
|
27
|
+
InputProps ??
|
|
28
|
+
{});
|
|
29
|
+
const selectProps = (slotProps?.select ??
|
|
30
|
+
SelectProps ??
|
|
31
|
+
{});
|
|
32
|
+
return {
|
|
33
|
+
formHelperTextProps,
|
|
34
|
+
htmlInputProps,
|
|
35
|
+
inputLabelProps,
|
|
36
|
+
propsForInput,
|
|
37
|
+
selectProps,
|
|
38
|
+
};
|
|
39
|
+
}, [
|
|
40
|
+
FormHelperTextProps,
|
|
41
|
+
InputLabelProps,
|
|
42
|
+
inputProps,
|
|
43
|
+
InputProps,
|
|
44
|
+
SelectProps,
|
|
45
|
+
slotProps,
|
|
46
|
+
]);
|
|
19
47
|
if (select || nativeSelect) {
|
|
20
48
|
// Unset defaults from textbox inputs.
|
|
21
|
-
if (!
|
|
22
|
-
|
|
49
|
+
if (!selectProps || (!selectProps.native && !nativeSelect)) {
|
|
50
|
+
propsForInput.id = undefined;
|
|
23
51
|
}
|
|
24
|
-
|
|
52
|
+
propsForInput["aria-describedby"] = undefined;
|
|
25
53
|
}
|
|
26
54
|
const InputElement = (_jsx(Input
|
|
27
55
|
// All of the properties fron here down to `InputProps` can be overridden by it.
|
|
@@ -34,7 +62,7 @@ const FormLabelTextField = forwardRef((props, ref) => {
|
|
|
34
62
|
// if it exists rather than set it.
|
|
35
63
|
//
|
|
36
64
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
37
|
-
autoFocus: autoFocus, defaultValue: defaultValue, fullWidth: fullWidth, inputProps:
|
|
38
|
-
return (_jsxs(FormControl, { fullWidth: fullWidth, ref: ref, ...other, children: [label && (_jsx(FormLabel, { htmlFor: id, id: inputLabelId, children: label })), helperText && (_jsx(FormHelperText, { ...
|
|
65
|
+
autoFocus: autoFocus, defaultValue: defaultValue, fullWidth: fullWidth, inputProps: htmlInputProps, inputRef: inputRef, maxRows: maxRows, minRows: minRows, multiline: multiline, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, placeholder: placeholder, rows: rows, type: type, value: value, ...propsForInput, "aria-describedby": helperTextId, id: id }));
|
|
66
|
+
return (_jsxs(FormControl, { fullWidth: fullWidth, ref: ref, ...other, children: [label && (_jsx(FormLabel, { ...inputLabelProps, htmlFor: id, id: inputLabelId, children: label })), helperText && (_jsx(FormHelperText, { ...formHelperTextProps, id: helperTextId, children: helperText })), select || nativeSelect ? (_jsx(Select, { "aria-describedby": helperTextId, id: id, labelId: inputLabelId, value: value, input: InputElement, ...selectProps, ...(nativeSelect && { native: true }), children: children })) : (InputElement)] }));
|
|
39
67
|
});
|
|
40
68
|
export default FormLabelTextField;
|