@symply.io/basic-components 1.5.7-alpha.3 → 1.5.7-alpha.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.
@@ -38,27 +38,26 @@ function useInteractions(props) {
38
38
  event.preventDefault();
39
39
  }
40
40
  }
41
- else if (String(val) === "0" && key !== ".") {
42
- event.preventDefault();
43
- }
44
41
  else {
45
42
  if (key === "-") {
46
43
  event.preventDefault();
47
44
  }
48
- else if (String(val).includes(".") && decimals > 0) {
45
+ else {
49
46
  var selectionStart = currentTarget.selectionStart;
50
- var decimalPointIndex = String(val).lastIndexOf(".");
51
- var decimalStrLen = String(val).split(".")[1].length;
52
- if (selectionStart && decimalPointIndex < selectionStart) {
53
- if (![
54
- "Backspace",
55
- "ArrowUp",
56
- "ArrowDown",
57
- "ArrowLeft",
58
- "ArrowRight"
59
- ].includes(key) &&
60
- decimalStrLen >= decimals) {
61
- event.preventDefault();
47
+ if (String(val).includes(".") && decimals > 0) {
48
+ var decimalPointIndex = String(val).lastIndexOf(".");
49
+ var decimalStrLen = String(val).split(".")[1].length;
50
+ if (selectionStart && decimalPointIndex < selectionStart) {
51
+ if (![
52
+ "Backspace",
53
+ "ArrowUp",
54
+ "ArrowDown",
55
+ "ArrowLeft",
56
+ "ArrowRight"
57
+ ].includes(key) &&
58
+ decimalStrLen >= decimals) {
59
+ event.preventDefault();
60
+ }
62
61
  }
63
62
  }
64
63
  }
@@ -100,6 +99,10 @@ function useInteractions(props) {
100
99
  else if (excludedValue.includes(strVal)) {
101
100
  onChange("");
102
101
  }
102
+ else if (strVal.startsWith("0")) {
103
+ var newValue = strVal.replace(/^(0+)(?=((0|[1-9])\d*\.))/g, "");
104
+ onChange(newValue);
105
+ }
103
106
  }, [value, onChange]);
104
107
  var onOpenTooltip = useCallback(function () {
105
108
  setTooltipOpen(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.5.7-alpha.3",
3
+ "version": "1.5.7-alpha.5",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",