@expressms/smartapp-ui 1.0.6 → 1.0.7
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.
|
@@ -22,13 +22,12 @@ var Input = function (_a) {
|
|
|
22
22
|
var _g = useState(false), isPasswordShown = _g[0], setPasswordShown = _g[1];
|
|
23
23
|
var inputRef = useRef(null);
|
|
24
24
|
useEffect(function () {
|
|
25
|
-
var _a;
|
|
26
25
|
var inputElement = inputRef.current;
|
|
27
|
-
if (inputElement) {
|
|
26
|
+
if (inputElement && inputElement.value.length) {
|
|
28
27
|
var textLength = inputElement.value.length;
|
|
29
28
|
inputElement.selectionStart = textLength;
|
|
30
29
|
inputElement.selectionEnd = textLength;
|
|
31
|
-
|
|
30
|
+
inputElement.focus();
|
|
32
31
|
}
|
|
33
32
|
}, [isPasswordShown]);
|
|
34
33
|
var getInputType = function () {
|
|
@@ -37,8 +36,11 @@ var Input = function (_a) {
|
|
|
37
36
|
}
|
|
38
37
|
return INPUT_TYPE_TEXT;
|
|
39
38
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
var onClickButton = function () {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
setPasswordShown(!isPasswordShown);
|
|
42
|
+
!((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value.length) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
43
|
+
};
|
|
44
|
+
return (_jsxs("div", __assign({ style: { width: "".concat(width, "%") }, className: classNames((_b = { 'smartapp-input': true }, _b[className] = className, _b)) }, { children: [title && _jsx("p", __assign({ className: "smartapp-input__title" }, { children: title })), _jsxs("div", __assign({ className: "smartapp-input__container" }, { children: [_jsx("input", { ref: inputRef, className: "smartapp-input__container--field", type: getInputType(), defaultValue: defaultValue, autoFocus: autoFocus, placeholder: placeholder, onChange: function (e) { return onChange(e.target.value); } }), isPassword && (_jsx("button", __assign({ className: "smartapp-input__container--eye-button", type: "button", onClick: function () { return onClickButton(); } }, { children: isPasswordShown ? _jsx(IconEye, {}) : _jsx(IconEyeClosed, {}) })))] })), error && _jsx("div", __assign({ className: "smartapp-input__error" }, { children: error }))] })));
|
|
43
45
|
};
|
|
44
46
|
export default Input;
|