dp-widgets-framework 1.3.9 → 1.4.0

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/dist/index.esm.js CHANGED
@@ -17662,19 +17662,25 @@ function DataGrid({ title, data, className }) {
17662
17662
  }
17663
17663
  setExpandedGroups(newExpanded);
17664
17664
  };
17665
+ const formatWithCommas = (value) => {
17666
+ if (value == null || value === "")
17667
+ return "";
17668
+ let str = value.toString().trim();
17669
+ let num = Number(str);
17670
+ if (isNaN(num))
17671
+ return str;
17672
+ let [integer, decimal] = str.split(".");
17673
+ integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
17674
+ return decimal ? `${integer}.${decimal}` : integer;
17675
+ };
17665
17676
  const formatValueWithUnit = (value, columnIndex) => {
17666
17677
  if (value === null || value === undefined)
17667
17678
  return "—";
17668
17679
  const unit = units === null || units === void 0 ? void 0 : units[columnIndex];
17669
- console.log('value==>', value, unit);
17670
17680
  // Format the value with commas if it's a number or numeric string
17671
17681
  let valueStr;
17672
- if (typeof value === 'number') {
17673
- valueStr = value.toLocaleString();
17674
- }
17675
- else {
17676
- valueStr = String(value);
17677
- }
17682
+ valueStr = formatWithCommas(value);
17683
+ console.log('value==>', valueStr, unit);
17678
17684
  // If no unit or unit length > 3, return value only
17679
17685
  if (!unit || unit.length > 3) {
17680
17686
  return valueStr;
package/dist/index.js CHANGED
@@ -17689,19 +17689,25 @@ function DataGrid({ title, data, className }) {
17689
17689
  }
17690
17690
  setExpandedGroups(newExpanded);
17691
17691
  };
17692
+ const formatWithCommas = (value) => {
17693
+ if (value == null || value === "")
17694
+ return "";
17695
+ let str = value.toString().trim();
17696
+ let num = Number(str);
17697
+ if (isNaN(num))
17698
+ return str;
17699
+ let [integer, decimal] = str.split(".");
17700
+ integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
17701
+ return decimal ? `${integer}.${decimal}` : integer;
17702
+ };
17692
17703
  const formatValueWithUnit = (value, columnIndex) => {
17693
17704
  if (value === null || value === undefined)
17694
17705
  return "—";
17695
17706
  const unit = units === null || units === void 0 ? void 0 : units[columnIndex];
17696
- console.log('value==>', value, unit);
17697
17707
  // Format the value with commas if it's a number or numeric string
17698
17708
  let valueStr;
17699
- if (typeof value === 'number') {
17700
- valueStr = value.toLocaleString();
17701
- }
17702
- else {
17703
- valueStr = String(value);
17704
- }
17709
+ valueStr = formatWithCommas(value);
17710
+ console.log('value==>', valueStr, unit);
17705
17711
  // If no unit or unit length > 3, return value only
17706
17712
  if (!unit || unit.length > 3) {
17707
17713
  return valueStr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dp-widgets-framework",
3
- "version": "1.3.9",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"