@expressms/smartapp-ui 1.0.5 → 1.0.6

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,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, autoFocus }: IInputProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const Input: ({ onChange, title, placeholder, defaultValue, error, width, className, autoFocus, isPassword, }: IInputProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default Input;
@@ -18,8 +18,8 @@ import { INPUT_TYPE_PASSWORD, INPUT_TYPE_TEXT } from '../../constants';
18
18
  import '../../styles/stories.module.scss';
19
19
  var Input = function (_a) {
20
20
  var _b;
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];
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, _f = _a.isPassword, isPassword = _f === void 0 ? false : _f;
22
+ var _g = useState(false), isPasswordShown = _g[0], setPasswordShown = _g[1];
23
23
  var inputRef = useRef(null);
24
24
  useEffect(function () {
25
25
  var _a;
@@ -31,8 +31,14 @@ var Input = function (_a) {
31
31
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
32
32
  }
33
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 () {
34
+ var getInputType = function () {
35
+ if (isPassword) {
36
+ return isPasswordShown ? INPUT_TYPE_TEXT : INPUT_TYPE_PASSWORD;
37
+ }
38
+ return INPUT_TYPE_TEXT;
39
+ };
40
+ 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 () {
35
41
  setPasswordShown(!isPasswordShown);
36
- } }, { children: isPasswordShown ? _jsx(IconEye, {}) : _jsx(IconEyeClosed, {}) }))] })), error && _jsx("div", __assign({ className: "smartapp-input__error" }, { children: error }))] })));
42
+ } }, { children: isPasswordShown ? _jsx(IconEye, {}) : _jsx(IconEyeClosed, {}) })))] })), error && _jsx("div", __assign({ className: "smartapp-input__error" }, { children: error }))] })));
37
43
  };
38
44
  export default Input;
@@ -8,4 +8,5 @@ export interface IInputProps {
8
8
  error?: string;
9
9
  width?: IntRange<1, 101>;
10
10
  className?: string;
11
+ isPassword?: boolean;
11
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressms/smartapp-ui",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "SmartApp UI library",
5
5
  "license": "MIT",
6
6
  "main": "build/main/index.js",