hi-tm 0.19.8 → 0.20.1

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.
@@ -41,8 +41,11 @@ const InputCurrency = (0, react_1.forwardRef)(({ placeholder, value, required, c
41
41
  // Combine the external ref with the internal ref
42
42
  react_1.default.useImperativeHandle(ref, () => internalRef.current);
43
43
  (0, react_1.useEffect)(() => {
44
- if (value !== null) {
45
- setInputValue(value?.toString());
44
+ if (value !== null && value !== undefined) {
45
+ setInputValue(value.toString());
46
+ }
47
+ else {
48
+ setInputValue('');
46
49
  }
47
50
  }, [value]);
48
51
  (0, react_1.useEffect)(() => {
@@ -81,7 +84,10 @@ const InputCurrency = (0, react_1.forwardRef)(({ placeholder, value, required, c
81
84
  value: rawValue
82
85
  }
83
86
  };
84
- onChangeValueHandler(syntheticEvent);
87
+ // Use an if statement instead of a logical expression
88
+ if (onChangeValueHandler) {
89
+ onChangeValueHandler(syntheticEvent);
90
+ }
85
91
  }
86
92
  };
87
93
  const handleKeyDown = (event) => {
@@ -1 +1 @@
1
- export declare const formatWithCommas: (num: number | string) => string;
1
+ export declare const formatWithCommas: (value: string) => string;
@@ -1,8 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatWithCommas = void 0;
4
- const formatWithCommas = (num) => {
5
- // Change type to any
6
- return String(num).replace(/\B(?=(\d{3})+(?!\d))/g, ','); // Convert to string
4
+ const formatWithCommas = (value) => {
5
+ if (!value)
6
+ return "";
7
+ // Remove any non-digit characters except decimal point
8
+ const numericValue = value.replace(/[^\d.]/g, "");
9
+ if (numericValue === "")
10
+ return "";
11
+ // Split the number into integer and decimal parts
12
+ const [integerPart, decimalPart] = numericValue.split(".");
13
+ // Format the integer part with commas
14
+ const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
15
+ // Return the formatted value with decimal part if it exists
16
+ return decimalPart !== undefined
17
+ ? `${formattedInteger}.${decimalPart}`
18
+ : formattedInteger;
7
19
  };
8
20
  exports.formatWithCommas = formatWithCommas;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hi-tm",
3
- "version": "0.19.8",
3
+ "version": "0.20.1",
4
4
  "styles": "dist/styles/globals.css",
5
5
  "main": "dist/index.js",
6
6
  "exports": {