@hashrytech/quick-components-kit 0.20.3 → 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,17 @@
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
+
9
+ ## 0.20.4
10
+
11
+ ### Patch Changes
12
+
13
+ - add: new showErrorText property
14
+
3
15
  ## 0.20.3
4
16
 
5
17
  ### Patch Changes
@@ -42,7 +42,8 @@
42
42
  disabled?: boolean;
43
43
  required?: boolean;
44
44
  pattern?: string;
45
- error?: string;
45
+ error?: string;
46
+ showErrorText?: boolean;
46
47
  labelClass?: ClassNameValue;
47
48
  firstDivClass?: ClassNameValue;
48
49
  secondDivClass?: ClassNameValue;
@@ -54,6 +55,7 @@
54
55
  step?: number;
55
56
  debounceDelay?: number;
56
57
  forcePositiveNumber?: boolean;
58
+ maxDecimalPlaces?: number;
57
59
  onInput?: (value: string|number|null) => void;
58
60
  onchange?: (event: Event) => void;
59
61
  onmouseup?: () => void;
@@ -83,6 +85,7 @@
83
85
  required=false,
84
86
  pattern,
85
87
  error,
88
+ showErrorText=true,
86
89
  firstDivClass,
87
90
  secondDivClass,
88
91
  thirdDivClass,
@@ -93,6 +96,7 @@
93
96
  step,
94
97
  debounceDelay=300, //ms
95
98
  forcePositiveNumber=false,
99
+ maxDecimalPlaces=-1,
96
100
  onchange,
97
101
  onInput,
98
102
  onmouseup,
@@ -137,6 +141,15 @@
137
141
  (e.target as HTMLInputElement).value = localValue; // reflect sanitized value in the UI
138
142
  }
139
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
+
140
153
  if(max && max > 0){
141
154
  if(Number(value) > max){
142
155
  localValue = String(max);
@@ -201,7 +214,7 @@
201
214
 
202
215
  </div>
203
216
 
204
- {#if error}
217
+ {#if error && showErrorText}
205
218
  <p class="text-sm text-red-500 mt-0.5 bg-red-100/30 px-2 rounded-primary">{error}</p>
206
219
  {/if}
207
220
 
@@ -40,6 +40,7 @@ export type TextInputProps = {
40
40
  required?: boolean;
41
41
  pattern?: string;
42
42
  error?: string;
43
+ showErrorText?: boolean;
43
44
  labelClass?: ClassNameValue;
44
45
  firstDivClass?: ClassNameValue;
45
46
  secondDivClass?: ClassNameValue;
@@ -51,6 +52,7 @@ export type TextInputProps = {
51
52
  step?: number;
52
53
  debounceDelay?: number;
53
54
  forcePositiveNumber?: boolean;
55
+ maxDecimalPlaces?: number;
54
56
  onInput?: (value: string | number | null) => void;
55
57
  onchange?: (event: Event) => void;
56
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.3",
8
+ "version": "0.20.5",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [