@steroidsjs/core 3.0.0-beta.105 → 3.0.0-beta.106

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.
@@ -21,8 +21,10 @@ function useSaveCursorPosition(inputParams) {
21
21
  var onChange = react_1["default"].useCallback(function (event, value) {
22
22
  var _a, _b;
23
23
  if (value === void 0) { value = null; }
24
- setCursor((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.selectionStart);
25
- inputParams.onChange(value || ((_b = event.target) === null || _b === void 0 ? void 0 : _b.value));
24
+ if (event) {
25
+ setCursor((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.selectionStart);
26
+ }
27
+ inputParams.onChange.call(null, value || ((_b = event === null || event === void 0 ? void 0 : event.target) === null || _b === void 0 ? void 0 : _b.value));
26
28
  }, [inputParams]);
27
29
  return {
28
30
  inputRef: inputRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "3.0.0-beta.105",
3
+ "version": "3.0.0-beta.106",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -97,11 +97,18 @@ function InputField(props) {
97
97
  }
98
98
  }, [inputRef, maskedInputRef]);
99
99
  (0, useInputFieldWarningByType_1.useInputFieldWarningByType)(props.type);
100
- var onClear = React.useCallback(function () { return props.input.onChange(''); }, [props.input]);
100
+ var onChangeHandle = (0, react_1.useCallback)(function (e, value) {
101
+ var _a;
102
+ var currentValue = value !== null && value !== void 0 ? value : (_a = e.target) === null || _a === void 0 ? void 0 : _a.value;
103
+ if (props.onChange) {
104
+ props.onChange(e, currentValue);
105
+ }
106
+ }, [props]);
107
+ var onClear = React.useCallback(function () { return onChangeHandle(null, ''); }, [onChangeHandle]);
101
108
  var inputProps = (0, react_1.useMemo)(function () {
102
109
  var _a;
103
- return (__assign({ type: props.type, name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onInput: onChange, placeholder: props.placeholder, disabled: props.disabled }, props.inputProps));
104
- }, [onChange, props.disabled, props.input.name, props.input.value, props.inputProps, props.placeholder, props.type]);
110
+ return (__assign({ type: props.type, name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onInput: onChangeHandle, placeholder: props.placeholder, disabled: props.disabled }, props.inputProps));
111
+ }, [onChangeHandle, props.disabled, props.input.name, props.input.value, props.inputProps, props.placeholder, props.type]);
105
112
  // No render for hidden input
106
113
  if (props.type === 'hidden') {
107
114
  return null;