@steroidsjs/core 3.0.0-beta.76 → 3.0.0-beta.78

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.
@@ -12965,7 +12965,7 @@
12965
12965
  {
12966
12966
  "name": "autoFocus",
12967
12967
  "decorators": [],
12968
- "description": "Если в форме есть элементы \\<input\\>, то произойдет автоматическая фокусировка на первом из них",
12968
+ "description": "Если в форме есть элементы input, то произойдет автоматическая фокусировка на первом из них",
12969
12969
  "required": false,
12970
12970
  "type": "boolean",
12971
12971
  "example": "true"
package/en.json CHANGED
@@ -458,7 +458,7 @@
458
458
  "Url на который будет отправлена форма": "URL to which the form will be submitted.",
459
459
  "Синхронизация значений формы с адресной строкой": "Synchronize form values with the address bar.",
460
460
  "Очищать ли данные формы с redux хранилища при размонтировании компонента. По-умолчанию - false": "Whether to clear form data from the Redux store when the component is unmounted. Default is false.",
461
- "Если в форме есть элементы \\<input\\>, то произойдет автоматическая фокусировка на первом из них": "If there are \\ <input\\> elements in the form, automatic focus will occur on the first one.",
461
+ "Если в форме есть элементы input, то произойдет автоматическая фокусировка на первом из них": "If there are \\ <input\\> elements in the form, automatic focus will occur on the first one.",
462
462
  "Сохраняет значения полей формы в LocalStorage": "Saves form field values to LocalStorage.",
463
463
  "Автоматически стартовать 2fa аутентификацию (отправлять код)": "Automatically start 2FA authentication (send code).",
464
464
  "Название действия, которое передаётся в API Google reCAPTCHA v3, для более детального анализа\nповедения пользователя (https://developers.google.com/recaptcha/docs/v3)": "The name of the action that is passed to the Google reCAPTCHA v3 API for more detailed analysis of user behavior.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "3.0.0-beta.76",
3
+ "version": "3.0.0-beta.78",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -1,6 +1,10 @@
1
1
  import { ChangeEvent } from 'react';
2
2
  import { IBaseFieldProps } from '../InputField/InputField';
3
3
  import { IFieldWrapperOutputProps } from '../Field/fieldWrapper';
4
+ export declare enum InputType {
5
+ TEXT = "text",
6
+ PASSWORD = "password"
7
+ }
4
8
  /**
5
9
  * PasswordField
6
10
  *
@@ -27,10 +31,9 @@ export interface IPasswordFieldViewProps extends IPasswordFieldProps, IFieldWrap
27
31
  placeholder: string;
28
32
  disabled: boolean;
29
33
  };
34
+ onShowButtonClick: () => void;
30
35
  onClear?: () => void;
31
36
  securityLevel?: 'success' | 'warning' | 'danger';
32
- onShowPassword: () => void;
33
- onHidePassword: () => void;
34
37
  }
35
38
  export declare const checkPassword: (password: any) => "success" | "warning" | "danger";
36
39
  declare const _default: import("../Field/fieldWrapper").FieldWrapperComponent<IPasswordFieldProps>;
@@ -14,10 +14,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  exports.__esModule = true;
17
- exports.checkPassword = void 0;
17
+ exports.checkPassword = exports.InputType = void 0;
18
+ /* eslint-disable no-unused-expressions */
18
19
  var react_1 = require("react");
19
20
  var hooks_1 = require("../../../hooks");
20
21
  var fieldWrapper_1 = __importDefault(require("../Field/fieldWrapper"));
22
+ var InputType;
23
+ (function (InputType) {
24
+ InputType["TEXT"] = "text";
25
+ InputType["PASSWORD"] = "password";
26
+ })(InputType = exports.InputType || (exports.InputType = {}));
21
27
  var checkPassword = function (password) {
22
28
  if (!password) {
23
29
  return null;
@@ -47,18 +53,17 @@ var checkPassword = function (password) {
47
53
  };
48
54
  exports.checkPassword = checkPassword;
49
55
  function PasswordField(props) {
50
- var _a = (0, react_1.useState)('password'), type = _a[0], setType = _a[1];
56
+ var _a = (0, react_1.useState)(InputType.PASSWORD), type = _a[0], setType = _a[1];
51
57
  var components = (0, hooks_1.useComponents)();
52
58
  var onClear = (0, react_1.useCallback)(function () { return props.input.onChange(''); }, [props.input]);
53
- props.inputProps = (0, react_1.useMemo)(function () {
59
+ var onShowButtonClick = (0, react_1.useCallback)(function () {
60
+ type === InputType.PASSWORD ? setType(InputType.TEXT) : setType(InputType.PASSWORD);
61
+ }, [type]);
62
+ var inputProps = (0, react_1.useMemo)(function () {
54
63
  var _a;
55
64
  return (__assign({ name: props.input.name, defaultValue: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onChange: function (value) { return props.input.onChange(value); }, type: type, placeholder: props.placeholder, disabled: props.disabled }, props.inputProps));
56
65
  }, [props.disabled, props.input, props.inputProps, props.placeholder, type]);
57
- props.securityLevel = props.showSecurityBar ? (0, exports.checkPassword)(props.input.value) : null;
58
- props.onShowPassword = function () { return setType('text'); };
59
- props.onHidePassword = function () { return setType('password'); };
60
- props.onClear = onClear;
61
- return components.ui.renderView(props.view || 'form.PasswordFieldView' || 'form.InputFieldView', props);
66
+ return components.ui.renderView(props.view || 'form.PasswordFieldView' || 'form.InputFieldView', __assign(__assign({}, props), { inputProps: inputProps, securityLevel: props.showSecurityBar ? (0, exports.checkPassword)(props.input.value) : null, onClear: onClear, onShowButtonClick: onShowButtonClick }));
62
67
  }
63
68
  PasswordField.defaultProps = {
64
69
  disabled: false,