@expressms/smartapp-ui 1.0.4 → 1.0.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/build/main/assets/icons/icon-eye-off.svg +1 -0
- package/build/main/assets/icons/icon-eye.svg +1 -0
- package/build/main/constants/constants.d.ts +2 -0
- package/build/main/constants/constants.js +2 -0
- package/build/main/styles/stories.module.scss +48 -21
- package/build/main/styles/styles.min.css +1 -1
- package/build/main//321/201omponents/Input/Input.d.ts +1 -1
- package/build/main//321/201omponents/Input/Input.js +20 -2
- package/build/main//321/201omponents/Input/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IInputProps } from './types';
|
|
2
2
|
import '../../styles/stories.module.scss';
|
|
3
|
-
declare const Input: ({ onChange, title, placeholder, defaultValue, error, width, className }: IInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare const Input: ({ onChange, title, placeholder, defaultValue, error, width, className, autoFocus }: IInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default Input;
|
|
@@ -10,11 +10,29 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useRef, useState, useEffect } from 'react';
|
|
13
14
|
import classNames from 'classnames';
|
|
15
|
+
import { ReactComponent as IconEye } from '../../assets/icons/icon-eye.svg';
|
|
16
|
+
import { ReactComponent as IconEyeClosed } from '../../assets/icons/icon-eye-off.svg';
|
|
17
|
+
import { INPUT_TYPE_PASSWORD, INPUT_TYPE_TEXT } from '../../constants';
|
|
14
18
|
import '../../styles/stories.module.scss';
|
|
15
19
|
var Input = function (_a) {
|
|
16
20
|
var _b;
|
|
17
|
-
var onChange = _a.onChange, title = _a.title, placeholder = _a.placeholder, defaultValue = _a.defaultValue, error = _a.error, _c = _a.width, width = _c === void 0 ? 100 : _c, _d = _a.className, className = _d === void 0 ? '' : _d;
|
|
18
|
-
|
|
21
|
+
var onChange = _a.onChange, title = _a.title, placeholder = _a.placeholder, defaultValue = _a.defaultValue, error = _a.error, _c = _a.width, width = _c === void 0 ? 100 : _c, _d = _a.className, className = _d === void 0 ? '' : _d, _e = _a.autoFocus, autoFocus = _e === void 0 ? false : _e;
|
|
22
|
+
var _f = useState(false), isPasswordShown = _f[0], setPasswordShown = _f[1];
|
|
23
|
+
var inputRef = useRef(null);
|
|
24
|
+
useEffect(function () {
|
|
25
|
+
var _a;
|
|
26
|
+
var inputElement = inputRef.current;
|
|
27
|
+
if (inputElement) {
|
|
28
|
+
var textLength = inputElement.value.length;
|
|
29
|
+
inputElement.selectionStart = textLength;
|
|
30
|
+
inputElement.selectionEnd = textLength;
|
|
31
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
32
|
+
}
|
|
33
|
+
}, [isPasswordShown]);
|
|
34
|
+
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: isPasswordShown ? INPUT_TYPE_TEXT : INPUT_TYPE_PASSWORD, defaultValue: defaultValue, autoFocus: autoFocus, placeholder: placeholder, onChange: function (e) { return onChange(e.target.value); } }), _jsx("button", __assign({ className: "smartapp-input__container--eye-button", type: "button", onClick: function () {
|
|
35
|
+
setPasswordShown(!isPasswordShown);
|
|
36
|
+
} }, { children: isPasswordShown ? _jsx(IconEye, {}) : _jsx(IconEyeClosed, {}) }))] })), error && _jsx("div", __assign({ className: "smartapp-input__error" }, { children: error }))] })));
|
|
19
37
|
};
|
|
20
38
|
export default Input;
|