@hashrytech/quick-components-kit 0.20.4 → 0.20.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.20.5
4
+
5
+ ### Patch Changes
6
+
7
+ - add: Adding max decimal places property
8
+
3
9
  ## 0.20.4
4
10
 
5
11
  ### Patch Changes
@@ -55,6 +55,7 @@
55
55
  step?: number;
56
56
  debounceDelay?: number;
57
57
  forcePositiveNumber?: boolean;
58
+ maxDecimalPlaces?: number;
58
59
  onInput?: (value: string|number|null) => void;
59
60
  onchange?: (event: Event) => void;
60
61
  onmouseup?: () => void;
@@ -95,6 +96,7 @@
95
96
  step,
96
97
  debounceDelay=300, //ms
97
98
  forcePositiveNumber=false,
99
+ maxDecimalPlaces=-1,
98
100
  onchange,
99
101
  onInput,
100
102
  onmouseup,
@@ -139,6 +141,15 @@
139
141
  (e.target as HTMLInputElement).value = localValue; // reflect sanitized value in the UI
140
142
  }
141
143
 
144
+ if(maxDecimalPlaces > -1){
145
+ const parts = localValue.split(".");
146
+ if(parts.length > 1){
147
+ parts[1] = parts[1].slice(0, maxDecimalPlaces); // limit to maxDecimalPlaces decimal places
148
+ localValue = parts.join(".");
149
+ (e.target as HTMLInputElement).value = localValue; // reflect limited decimal places in the UI
150
+ }
151
+ }
152
+
142
153
  if(max && max > 0){
143
154
  if(Number(value) > max){
144
155
  localValue = String(max);
@@ -52,6 +52,7 @@ export type TextInputProps = {
52
52
  step?: number;
53
53
  debounceDelay?: number;
54
54
  forcePositiveNumber?: boolean;
55
+ maxDecimalPlaces?: number;
55
56
  onInput?: (value: string | number | null) => void;
56
57
  onchange?: (event: Event) => void;
57
58
  onmouseup?: () => void;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hashrytech/quick-components-kit.git"
7
7
  },
8
- "version": "0.20.4",
8
+ "version": "0.20.5",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [