@symply.io/basic-components 1.5.5-alpha.5 → 1.5.5-alpha.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.
@@ -42,6 +42,6 @@ function NumberInput(props) {
42
42
  onChange: onChange
43
43
  }), typing = _f.typing, exceedError = _f.exceedError, tooltipOpen = _f.tooltipOpen, roundedValue = _f.roundedValue, handleBlur = _f.handleBlur, handleFocus = _f.handleFocus, handleChange = _f.handleChange, onOpenTooltip = _f.onOpenTooltip, onCloseTooltip = _f.onCloseTooltip, handleKeyboardEvent = _f.handleKeyboardEvent;
44
44
  var valueDisplay = useMemo(function () { return (typing ? value : roundedValue); }, [typing, value, roundedValue]);
45
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ arrow: true, placement: "top", title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: "number", value: value === undefined || value === null ? "" : valueDisplay, onMouseEnter: onOpenTooltip, onMouseLeave: onCloseTooltip, onBlur: handleBlur, onFocus: handleFocus, onChange: handleChange, error: error || exceedError, helperText: helperText || (exceedError ? EXCEED_ERROR : ""), inputProps: { onKeyDown: handleKeyboardEvent } }, rest)) })) })));
45
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ arrow: true, placement: "top", title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: "text", value: value === undefined || value === null ? "" : valueDisplay, onMouseEnter: onOpenTooltip, onMouseLeave: onCloseTooltip, onBlur: handleBlur, onFocus: handleFocus, onChange: handleChange, error: error || exceedError, helperText: helperText || (exceedError ? EXCEED_ERROR : ""), inputProps: { onKeyDown: handleKeyboardEvent } }, rest)) })) })));
46
46
  }
47
47
  export default NumberInput;
@@ -26,8 +26,7 @@ function useInteractions(props) {
26
26
  }, [value, decimals]);
27
27
  var exceedError = useMemo(function () { return !!value && (Number(value) < minValue || Number(value) > maxValue); }, [value, minValue, maxValue]);
28
28
  var handleKeyboardEvent = useCallback(function (event) {
29
- var _a, _b;
30
- var key = event.key;
29
+ var key = event.key, currentTarget = event.currentTarget;
31
30
  if (key === "e") {
32
31
  event.preventDefault();
33
32
  }
@@ -44,16 +43,16 @@ function useInteractions(props) {
44
43
  event.preventDefault();
45
44
  }
46
45
  else if (String(value).includes(".") && decimals > 0) {
47
- var cursorPos = ((_b = (_a = document.getSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0)) === null || _b === void 0 ? void 0 : _b.startOffset) || 0;
46
+ var selectionStart = currentTarget.selectionStart;
48
47
  var decimalPointIndex = String(value).lastIndexOf(".");
49
48
  var decimalStrLen = String(value).split(".")[1].length;
50
49
  console.log({
51
50
  cursorIndex: cursorIndex,
52
51
  decimalPointIndex: decimalPointIndex,
53
52
  decimalStrLen: decimalStrLen,
54
- cursorPos: cursorPos
53
+ selectionStart: selectionStart
55
54
  });
56
- if (cursorIndex && decimalPointIndex <= cursorIndex) {
55
+ if (selectionStart && decimalPointIndex <= selectionStart) {
57
56
  if (![
58
57
  "Backspace",
59
58
  "ArrowUp",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.5.5-alpha.5",
3
+ "version": "1.5.5-alpha.7",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",