@festo-ui/react 9.0.0-dev.659 → 9.0.0-dev.662
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/lib/components/popovers/popover/Popover.d.ts +3 -1
- package/lib/components/popovers/popover/Popover.js +20 -14
- package/lib/forms/text-area/TextArea.d.ts +4 -3
- package/lib/forms/text-area/TextArea.js +9 -7
- package/lib/forms/text-input/TextInput.d.ts +4 -2
- package/lib/forms/text-input/TextInput.js +7 -8
- package/node/lib/components/popovers/popover/Popover.js +19 -13
- package/node/lib/forms/text-area/TextArea.js +9 -7
- package/node/lib/forms/text-input/TextInput.js +7 -10
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ export interface PopoverProps extends ClassNamePropsWithChildren {
|
|
|
6
6
|
popoverContent: React.ReactNode;
|
|
7
7
|
position?: Placement;
|
|
8
8
|
fallbackPositions?: Placement[];
|
|
9
|
+
defaultOpen?: boolean;
|
|
9
10
|
open?: boolean;
|
|
10
11
|
onStatusChange?: (status: boolean) => void;
|
|
11
12
|
wrapper?: (children: React.ReactNode) => React.ReactNode;
|
|
@@ -13,6 +14,7 @@ export interface PopoverProps extends ClassNamePropsWithChildren {
|
|
|
13
14
|
containerClassName?: string;
|
|
14
15
|
stopPropagation?: boolean;
|
|
15
16
|
arrow?: boolean;
|
|
17
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
16
18
|
}
|
|
17
|
-
declare function Popover({ popoverContent, children, position, fallbackPositions, open, onStatusChange, wrapper, className, flip, containerClassName, stopPropagation, arrow, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
declare function Popover({ popoverContent, children, position, fallbackPositions, defaultOpen, open, onStatusChange, wrapper, className, flip, containerClassName, stopPropagation, arrow, onClick, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
18
20
|
export default Popover;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
2
|
import { usePopper } from "react-popper";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import useOnClickOutside from "../../../helper/useOnClickOutside.js";
|
|
5
5
|
import useForkRef from "../../../helper/useForkRef.js";
|
|
6
|
+
import useControlled from "../../../helper/useControlled.js";
|
|
6
7
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
8
|
function Popover(_ref) {
|
|
8
9
|
let {
|
|
@@ -10,28 +11,27 @@ function Popover(_ref) {
|
|
|
10
11
|
children,
|
|
11
12
|
position,
|
|
12
13
|
fallbackPositions,
|
|
13
|
-
|
|
14
|
+
defaultOpen = false,
|
|
15
|
+
open,
|
|
14
16
|
onStatusChange,
|
|
15
17
|
wrapper,
|
|
16
18
|
className,
|
|
17
19
|
flip = true,
|
|
18
20
|
containerClassName,
|
|
19
21
|
stopPropagation,
|
|
20
|
-
arrow = true
|
|
22
|
+
arrow = true,
|
|
23
|
+
onClick
|
|
21
24
|
} = _ref;
|
|
22
|
-
const [showPopper, setShowPopper] =
|
|
25
|
+
const [showPopper, setShowPopper] = useControlled({
|
|
26
|
+
controlled: open,
|
|
27
|
+
default: defaultOpen
|
|
28
|
+
});
|
|
23
29
|
const [popperElement, setPopperElement] = useState(null);
|
|
24
30
|
const [arrowElement, setArrowElement] = useState(null);
|
|
25
31
|
const referenceElement = useRef(null);
|
|
26
32
|
const popperElRef = useRef(null);
|
|
27
33
|
const combinedRef = useForkRef(popperElRef, setPopperElement);
|
|
28
34
|
const classes = classNames(className);
|
|
29
|
-
const isControlled = onStatusChange !== undefined;
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (isControlled) {
|
|
32
|
-
setShowPopper(open);
|
|
33
|
-
}
|
|
34
|
-
}, [open, isControlled]);
|
|
35
35
|
const {
|
|
36
36
|
styles,
|
|
37
37
|
attributes
|
|
@@ -59,9 +59,7 @@ function Popover(_ref) {
|
|
|
59
59
|
e?.stopPropagation();
|
|
60
60
|
e?.preventDefault();
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
setShowPopper(status);
|
|
64
|
-
}
|
|
62
|
+
setShowPopper(status);
|
|
65
63
|
onStatusChange?.(status);
|
|
66
64
|
};
|
|
67
65
|
function closePopover(event) {
|
|
@@ -81,6 +79,14 @@ function Popover(_ref) {
|
|
|
81
79
|
handleChange(undefined, true);
|
|
82
80
|
}
|
|
83
81
|
}
|
|
82
|
+
function handleTriggerClick(event) {
|
|
83
|
+
onClick?.(event);
|
|
84
|
+
if (event.defaultPrevented) {
|
|
85
|
+
setShowPopper(!showPopper);
|
|
86
|
+
} else {
|
|
87
|
+
handleChange(event, !showPopper);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
84
90
|
const childrenWrapper = /*#__PURE__*/_jsx("div", {
|
|
85
91
|
tabIndex: 0,
|
|
86
92
|
role: "button",
|
|
@@ -88,7 +94,7 @@ function Popover(_ref) {
|
|
|
88
94
|
ref: referenceElement,
|
|
89
95
|
onKeyDown: handleKeyDown,
|
|
90
96
|
onKeyUp: handleKeyUp,
|
|
91
|
-
onClick:
|
|
97
|
+
onClick: handleTriggerClick,
|
|
92
98
|
children: children
|
|
93
99
|
});
|
|
94
100
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ClassNameProps } from "../../helper/types";
|
|
2
|
+
import type { ClassNameProps } from "../../helper/types";
|
|
3
3
|
import "./TextArea.scss";
|
|
4
|
-
interface TextAreaProps extends ClassNameProps {
|
|
4
|
+
export interface TextAreaProps extends ClassNameProps {
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
required?: boolean;
|
|
7
7
|
readonly?: boolean;
|
|
@@ -14,9 +14,10 @@ interface TextAreaProps extends ClassNameProps {
|
|
|
14
14
|
error?: string;
|
|
15
15
|
value?: string;
|
|
16
16
|
defaultValue?: string;
|
|
17
|
+
name?: string;
|
|
17
18
|
rows?: number;
|
|
18
19
|
maxLength?: number;
|
|
19
20
|
id?: string;
|
|
20
21
|
}
|
|
21
|
-
declare function TextArea({ disabled, onBlur, onChange, onFocus, onInput, readonly, required, label, error, hint, value, rows, maxLength, className, id: idProps,
|
|
22
|
+
declare function TextArea({ disabled, onBlur, onChange, onFocus, onInput, readonly, required, label, error, hint, value, defaultValue, name, rows, maxLength, className, id: idProps, }: Readonly<TextAreaProps>): import("react/jsx-runtime").JSX.Element;
|
|
22
23
|
export default TextArea;
|
|
@@ -15,11 +15,12 @@ function TextArea(_ref) {
|
|
|
15
15
|
error,
|
|
16
16
|
hint,
|
|
17
17
|
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
name,
|
|
18
20
|
rows,
|
|
19
|
-
maxLength
|
|
21
|
+
maxLength,
|
|
20
22
|
className,
|
|
21
|
-
id: idProps
|
|
22
|
-
defaultValue
|
|
23
|
+
id: idProps
|
|
23
24
|
} = _ref;
|
|
24
25
|
const controlled = value !== undefined;
|
|
25
26
|
const [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
|
|
@@ -43,7 +44,7 @@ function TextArea(_ref) {
|
|
|
43
44
|
const newHeight = Math.max(minRows * 24, shadow.scrollHeight);
|
|
44
45
|
setHeight(newHeight + 4 + 4 + 1);
|
|
45
46
|
}
|
|
46
|
-
}, [
|
|
47
|
+
}, []);
|
|
47
48
|
function handleChange(event) {
|
|
48
49
|
if (!controlled) {
|
|
49
50
|
setInnerValue(event.target.value);
|
|
@@ -63,6 +64,7 @@ function TextArea(_ref) {
|
|
|
63
64
|
})
|
|
64
65
|
},
|
|
65
66
|
ref: ref,
|
|
67
|
+
name: name,
|
|
66
68
|
className: classNames("fr-textarea", `fwe-row-${rows}`),
|
|
67
69
|
disabled: disabled,
|
|
68
70
|
readOnly: readonly,
|
|
@@ -73,8 +75,8 @@ function TextArea(_ref) {
|
|
|
73
75
|
onInput: onInput,
|
|
74
76
|
onBlur: onBlur,
|
|
75
77
|
maxLength: maxLength,
|
|
76
|
-
defaultValue:
|
|
77
|
-
value:
|
|
78
|
+
defaultValue: defaultValue,
|
|
79
|
+
value: value,
|
|
78
80
|
id: id
|
|
79
81
|
}), /*#__PURE__*/_jsx("textarea", {
|
|
80
82
|
style: {
|
|
@@ -98,7 +100,7 @@ function TextArea(_ref) {
|
|
|
98
100
|
}), error !== undefined && /*#__PURE__*/_jsx("span", {
|
|
99
101
|
className: "fwe-input-text-invalid",
|
|
100
102
|
children: error
|
|
101
|
-
}), maxLength
|
|
103
|
+
}), !!maxLength && innerValue !== undefined && /*#__PURE__*/_jsxs("span", {
|
|
102
104
|
className: "fwe-input-text-count",
|
|
103
105
|
children: [innerValue.length, " /", maxLength]
|
|
104
106
|
})]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface TextInputProps {
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export interface TextInputProps {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
required?: boolean;
|
|
5
5
|
readonly?: boolean;
|
|
@@ -9,6 +9,8 @@ interface TextInputProps {
|
|
|
9
9
|
min?: number;
|
|
10
10
|
max?: number;
|
|
11
11
|
value?: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
name?: string;
|
|
12
14
|
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
13
15
|
onInput?: (event: React.FormEvent<HTMLInputElement>) => void;
|
|
14
16
|
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { forwardRef, useEffect, useRef } from "react";
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import useId from "../../helper/useId.js";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -16,6 +16,8 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
16
16
|
step,
|
|
17
17
|
type,
|
|
18
18
|
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
name,
|
|
19
21
|
error,
|
|
20
22
|
hint,
|
|
21
23
|
label,
|
|
@@ -26,11 +28,7 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
26
28
|
...props
|
|
27
29
|
} = _ref;
|
|
28
30
|
const id = useId(idProps);
|
|
29
|
-
const [innerValue, setInnerValue] = useState(value);
|
|
30
31
|
const inputRef = useRef(null);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
setInnerValue(value);
|
|
33
|
-
}, [value]);
|
|
34
32
|
|
|
35
33
|
// Programmatically focus the input instead of using autoFocus attribute
|
|
36
34
|
useEffect(() => {
|
|
@@ -44,13 +42,12 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
44
42
|
return undefined;
|
|
45
43
|
}, [autoFocus]);
|
|
46
44
|
const supported = ["text", "number", "password", "datetime-local"];
|
|
47
|
-
const innerType = type && supported.
|
|
45
|
+
const innerType = type && supported.includes(type) ? type : "text";
|
|
48
46
|
const labelClasses = classNames("fwe-input-text", {
|
|
49
47
|
"fwe-input-text-icon": icon
|
|
50
48
|
}, labelClassName);
|
|
51
49
|
const hintClasses = classNames("fwe-input-text-info");
|
|
52
50
|
function handleChange(e) {
|
|
53
|
-
setInnerValue(e.target.value);
|
|
54
51
|
if (props.onChange) {
|
|
55
52
|
props.onChange(e);
|
|
56
53
|
}
|
|
@@ -60,6 +57,7 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
60
57
|
htmlFor: id,
|
|
61
58
|
ref: ref,
|
|
62
59
|
children: [/*#__PURE__*/_jsx("input", {
|
|
60
|
+
name: name,
|
|
63
61
|
disabled: disabled,
|
|
64
62
|
required: required,
|
|
65
63
|
readOnly: readonly,
|
|
@@ -73,7 +71,8 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
73
71
|
onFocus: onFocus,
|
|
74
72
|
onInput: onInput,
|
|
75
73
|
type: innerType,
|
|
76
|
-
value:
|
|
74
|
+
value: value,
|
|
75
|
+
defaultValue: defaultValue,
|
|
77
76
|
id: id,
|
|
78
77
|
ref: inputRef,
|
|
79
78
|
...props
|
|
@@ -9,6 +9,7 @@ var _reactPopper = require("react-popper");
|
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _useOnClickOutside = _interopRequireDefault(require("../../../helper/useOnClickOutside.js"));
|
|
11
11
|
var _useForkRef = _interopRequireDefault(require("../../../helper/useForkRef.js"));
|
|
12
|
+
var _useControlled = _interopRequireDefault(require("../../../helper/useControlled.js"));
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -19,28 +20,27 @@ function Popover(_ref) {
|
|
|
19
20
|
children,
|
|
20
21
|
position,
|
|
21
22
|
fallbackPositions,
|
|
22
|
-
|
|
23
|
+
defaultOpen = false,
|
|
24
|
+
open,
|
|
23
25
|
onStatusChange,
|
|
24
26
|
wrapper,
|
|
25
27
|
className,
|
|
26
28
|
flip = true,
|
|
27
29
|
containerClassName,
|
|
28
30
|
stopPropagation,
|
|
29
|
-
arrow = true
|
|
31
|
+
arrow = true,
|
|
32
|
+
onClick
|
|
30
33
|
} = _ref;
|
|
31
|
-
const [showPopper, setShowPopper] = (0,
|
|
34
|
+
const [showPopper, setShowPopper] = (0, _useControlled.default)({
|
|
35
|
+
controlled: open,
|
|
36
|
+
default: defaultOpen
|
|
37
|
+
});
|
|
32
38
|
const [popperElement, setPopperElement] = (0, _react.useState)(null);
|
|
33
39
|
const [arrowElement, setArrowElement] = (0, _react.useState)(null);
|
|
34
40
|
const referenceElement = (0, _react.useRef)(null);
|
|
35
41
|
const popperElRef = (0, _react.useRef)(null);
|
|
36
42
|
const combinedRef = (0, _useForkRef.default)(popperElRef, setPopperElement);
|
|
37
43
|
const classes = (0, _classnames.default)(className);
|
|
38
|
-
const isControlled = onStatusChange !== undefined;
|
|
39
|
-
(0, _react.useEffect)(() => {
|
|
40
|
-
if (isControlled) {
|
|
41
|
-
setShowPopper(open);
|
|
42
|
-
}
|
|
43
|
-
}, [open, isControlled]);
|
|
44
44
|
const {
|
|
45
45
|
styles,
|
|
46
46
|
attributes
|
|
@@ -68,9 +68,7 @@ function Popover(_ref) {
|
|
|
68
68
|
e?.stopPropagation();
|
|
69
69
|
e?.preventDefault();
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
setShowPopper(status);
|
|
73
|
-
}
|
|
71
|
+
setShowPopper(status);
|
|
74
72
|
onStatusChange?.(status);
|
|
75
73
|
};
|
|
76
74
|
function closePopover(event) {
|
|
@@ -90,6 +88,14 @@ function Popover(_ref) {
|
|
|
90
88
|
handleChange(undefined, true);
|
|
91
89
|
}
|
|
92
90
|
}
|
|
91
|
+
function handleTriggerClick(event) {
|
|
92
|
+
onClick?.(event);
|
|
93
|
+
if (event.defaultPrevented) {
|
|
94
|
+
setShowPopper(!showPopper);
|
|
95
|
+
} else {
|
|
96
|
+
handleChange(event, !showPopper);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
93
99
|
const childrenWrapper = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
94
100
|
tabIndex: 0,
|
|
95
101
|
role: "button",
|
|
@@ -97,7 +103,7 @@ function Popover(_ref) {
|
|
|
97
103
|
ref: referenceElement,
|
|
98
104
|
onKeyDown: handleKeyDown,
|
|
99
105
|
onKeyUp: handleKeyUp,
|
|
100
|
-
onClick:
|
|
106
|
+
onClick: handleTriggerClick,
|
|
101
107
|
children: children
|
|
102
108
|
});
|
|
103
109
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
@@ -24,11 +24,12 @@ function TextArea(_ref) {
|
|
|
24
24
|
error,
|
|
25
25
|
hint,
|
|
26
26
|
value,
|
|
27
|
+
defaultValue,
|
|
28
|
+
name,
|
|
27
29
|
rows,
|
|
28
|
-
maxLength
|
|
30
|
+
maxLength,
|
|
29
31
|
className,
|
|
30
|
-
id: idProps
|
|
31
|
-
defaultValue
|
|
32
|
+
id: idProps
|
|
32
33
|
} = _ref;
|
|
33
34
|
const controlled = value !== undefined;
|
|
34
35
|
const [innerValue, setInnerValue] = (0, _react.useState)(controlled ? value : defaultValue);
|
|
@@ -52,7 +53,7 @@ function TextArea(_ref) {
|
|
|
52
53
|
const newHeight = Math.max(minRows * 24, shadow.scrollHeight);
|
|
53
54
|
setHeight(newHeight + 4 + 4 + 1);
|
|
54
55
|
}
|
|
55
|
-
}, [
|
|
56
|
+
}, []);
|
|
56
57
|
function handleChange(event) {
|
|
57
58
|
if (!controlled) {
|
|
58
59
|
setInnerValue(event.target.value);
|
|
@@ -72,6 +73,7 @@ function TextArea(_ref) {
|
|
|
72
73
|
})
|
|
73
74
|
},
|
|
74
75
|
ref: ref,
|
|
76
|
+
name: name,
|
|
75
77
|
className: (0, _classnames.default)("fr-textarea", `fwe-row-${rows}`),
|
|
76
78
|
disabled: disabled,
|
|
77
79
|
readOnly: readonly,
|
|
@@ -82,8 +84,8 @@ function TextArea(_ref) {
|
|
|
82
84
|
onInput: onInput,
|
|
83
85
|
onBlur: onBlur,
|
|
84
86
|
maxLength: maxLength,
|
|
85
|
-
defaultValue:
|
|
86
|
-
value:
|
|
87
|
+
defaultValue: defaultValue,
|
|
88
|
+
value: value,
|
|
87
89
|
id: id
|
|
88
90
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
|
|
89
91
|
style: {
|
|
@@ -107,7 +109,7 @@ function TextArea(_ref) {
|
|
|
107
109
|
}), error !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
108
110
|
className: "fwe-input-text-invalid",
|
|
109
111
|
children: error
|
|
110
|
-
}), maxLength
|
|
112
|
+
}), !!maxLength && innerValue !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
111
113
|
className: "fwe-input-text-count",
|
|
112
114
|
children: [innerValue.length, " /", maxLength]
|
|
113
115
|
})]
|
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = require("react");
|
|
8
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
9
|
var _useId = _interopRequireDefault(require("../../helper/useId.js"));
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
12
|
const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
15
13
|
let {
|
|
16
14
|
disabled,
|
|
@@ -25,6 +23,8 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
25
23
|
step,
|
|
26
24
|
type,
|
|
27
25
|
value,
|
|
26
|
+
defaultValue,
|
|
27
|
+
name,
|
|
28
28
|
error,
|
|
29
29
|
hint,
|
|
30
30
|
label,
|
|
@@ -35,11 +35,7 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
35
35
|
...props
|
|
36
36
|
} = _ref;
|
|
37
37
|
const id = (0, _useId.default)(idProps);
|
|
38
|
-
const [innerValue, setInnerValue] = (0, _react.useState)(value);
|
|
39
38
|
const inputRef = (0, _react.useRef)(null);
|
|
40
|
-
(0, _react.useEffect)(() => {
|
|
41
|
-
setInnerValue(value);
|
|
42
|
-
}, [value]);
|
|
43
39
|
|
|
44
40
|
// Programmatically focus the input instead of using autoFocus attribute
|
|
45
41
|
(0, _react.useEffect)(() => {
|
|
@@ -53,13 +49,12 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
53
49
|
return undefined;
|
|
54
50
|
}, [autoFocus]);
|
|
55
51
|
const supported = ["text", "number", "password", "datetime-local"];
|
|
56
|
-
const innerType = type && supported.
|
|
52
|
+
const innerType = type && supported.includes(type) ? type : "text";
|
|
57
53
|
const labelClasses = (0, _classnames.default)("fwe-input-text", {
|
|
58
54
|
"fwe-input-text-icon": icon
|
|
59
55
|
}, labelClassName);
|
|
60
56
|
const hintClasses = (0, _classnames.default)("fwe-input-text-info");
|
|
61
57
|
function handleChange(e) {
|
|
62
|
-
setInnerValue(e.target.value);
|
|
63
58
|
if (props.onChange) {
|
|
64
59
|
props.onChange(e);
|
|
65
60
|
}
|
|
@@ -69,6 +64,7 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
69
64
|
htmlFor: id,
|
|
70
65
|
ref: ref,
|
|
71
66
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
67
|
+
name: name,
|
|
72
68
|
disabled: disabled,
|
|
73
69
|
required: required,
|
|
74
70
|
readOnly: readonly,
|
|
@@ -82,7 +78,8 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
82
78
|
onFocus: onFocus,
|
|
83
79
|
onInput: onInput,
|
|
84
80
|
type: innerType,
|
|
85
|
-
value:
|
|
81
|
+
value: value,
|
|
82
|
+
defaultValue: defaultValue,
|
|
86
83
|
id: id,
|
|
87
84
|
ref: inputRef,
|
|
88
85
|
...props
|
package/package.json
CHANGED