next-recomponents 2.0.18 → 2.0.20

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.d.mts CHANGED
@@ -81,6 +81,7 @@ interface TableProps {
81
81
  hideColumns?: string[];
82
82
  footer?: FooterType;
83
83
  symbols?: any;
84
+ currentCoin?: string;
84
85
  [key: string]: any;
85
86
  }
86
87
  declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -81,6 +81,7 @@ interface TableProps {
81
81
  hideColumns?: string[];
82
82
  footer?: FooterType;
83
83
  symbols?: any;
84
+ currentCoin?: string;
84
85
  [key: string]: any;
85
86
  }
86
87
  declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -35822,7 +35822,7 @@ function Toolbar({
35822
35822
  ) : onSave && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { onClick: () => onSave(rows.map(stripMeta)), children: "Guardar" })
35823
35823
  ] });
35824
35824
  }
35825
- function useColumns(rows, options) {
35825
+ function useColumns(rows, currentCoin, options) {
35826
35826
  const {
35827
35827
  flex,
35828
35828
  editableFields,
@@ -35841,12 +35841,19 @@ function useColumns(rows, options) {
35841
35841
  headerName: key,
35842
35842
  valueFormatter: (value) => {
35843
35843
  if (value == null || value === "") return "";
35844
- const num = parseFloat(value);
35845
- if (isNaN(num)) return value;
35846
- return num.toLocaleString("en-US", {
35847
- minimumFractionDigits: num % 1 !== 0 ? 2 : 0,
35848
- maximumFractionDigits: num % 1 !== 0 ? 2 : 0
35849
- });
35844
+ const isDate = /(\d{4}-\d{2}-\d{2})(T[\d:,.+-]*(Z)?)?/;
35845
+ if (`${value}`.match(isDate)) {
35846
+ return value.toString().split("T")[0].split("-").reverse().join("/");
35847
+ }
35848
+ const isNumber = typeof value === "number";
35849
+ if (isNumber) {
35850
+ if (isNaN(value)) return value;
35851
+ return currentCoin + " " + value.toLocaleString("en-US", {
35852
+ minimumFractionDigits: value % 1 !== 0 ? 2 : 0,
35853
+ maximumFractionDigits: value % 1 !== 0 ? 2 : 0
35854
+ });
35855
+ }
35856
+ return value;
35850
35857
  },
35851
35858
  flex,
35852
35859
  editable: (_a = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _a : false,
@@ -35905,7 +35912,8 @@ function IHTable({
35905
35912
  width = "100%",
35906
35913
  header,
35907
35914
  hideColumns = [],
35908
- footer = {}
35915
+ footer = {},
35916
+ currentCoin = "$"
35909
35917
  }) {
35910
35918
  var _a;
35911
35919
  if (modal && onSelect)
@@ -35946,7 +35954,7 @@ function IHTable({
35946
35954
  }
35947
35955
  return [];
35948
35956
  }, [selectedRows, rows]);
35949
- const columns = useColumns(rows, {
35957
+ const columns = useColumns(rows, currentCoin, {
35950
35958
  flex,
35951
35959
  editableFields,
35952
35960
  buttons: resolvedButtons,
@@ -36012,11 +36020,11 @@ function IHTable({
36012
36020
  pageSizeOptions: [5, 10],
36013
36021
  hideFooter: rows.length <= Object.keys(HEIGHT_MAP).length
36014
36022
  }
36015
- ),
36016
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CustomFooter, { footer, rows })
36023
+ )
36017
36024
  ]
36018
36025
  }
36019
- )
36026
+ ),
36027
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CustomFooter, { footer, rows })
36020
36028
  ] });
36021
36029
  }
36022
36030
  function Table(props) {
package/dist/index.mjs CHANGED
@@ -35802,7 +35802,7 @@ function Toolbar({
35802
35802
  ) : onSave && /* @__PURE__ */ jsx6(Button, { onClick: () => onSave(rows.map(stripMeta)), children: "Guardar" })
35803
35803
  ] });
35804
35804
  }
35805
- function useColumns(rows, options) {
35805
+ function useColumns(rows, currentCoin, options) {
35806
35806
  const {
35807
35807
  flex,
35808
35808
  editableFields,
@@ -35821,12 +35821,19 @@ function useColumns(rows, options) {
35821
35821
  headerName: key,
35822
35822
  valueFormatter: (value) => {
35823
35823
  if (value == null || value === "") return "";
35824
- const num = parseFloat(value);
35825
- if (isNaN(num)) return value;
35826
- return num.toLocaleString("en-US", {
35827
- minimumFractionDigits: num % 1 !== 0 ? 2 : 0,
35828
- maximumFractionDigits: num % 1 !== 0 ? 2 : 0
35829
- });
35824
+ const isDate = /(\d{4}-\d{2}-\d{2})(T[\d:,.+-]*(Z)?)?/;
35825
+ if (`${value}`.match(isDate)) {
35826
+ return value.toString().split("T")[0].split("-").reverse().join("/");
35827
+ }
35828
+ const isNumber = typeof value === "number";
35829
+ if (isNumber) {
35830
+ if (isNaN(value)) return value;
35831
+ return currentCoin + " " + value.toLocaleString("en-US", {
35832
+ minimumFractionDigits: value % 1 !== 0 ? 2 : 0,
35833
+ maximumFractionDigits: value % 1 !== 0 ? 2 : 0
35834
+ });
35835
+ }
35836
+ return value;
35830
35837
  },
35831
35838
  flex,
35832
35839
  editable: (_a = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _a : false,
@@ -35885,7 +35892,8 @@ function IHTable({
35885
35892
  width = "100%",
35886
35893
  header,
35887
35894
  hideColumns = [],
35888
- footer = {}
35895
+ footer = {},
35896
+ currentCoin = "$"
35889
35897
  }) {
35890
35898
  var _a;
35891
35899
  if (modal && onSelect)
@@ -35926,7 +35934,7 @@ function IHTable({
35926
35934
  }
35927
35935
  return [];
35928
35936
  }, [selectedRows, rows]);
35929
- const columns = useColumns(rows, {
35937
+ const columns = useColumns(rows, currentCoin, {
35930
35938
  flex,
35931
35939
  editableFields,
35932
35940
  buttons: resolvedButtons,
@@ -35992,11 +36000,11 @@ function IHTable({
35992
36000
  pageSizeOptions: [5, 10],
35993
36001
  hideFooter: rows.length <= Object.keys(HEIGHT_MAP).length
35994
36002
  }
35995
- ),
35996
- /* @__PURE__ */ jsx6(CustomFooter, { footer, rows })
36003
+ )
35997
36004
  ]
35998
36005
  }
35999
- )
36006
+ ),
36007
+ /* @__PURE__ */ jsx6(CustomFooter, { footer, rows })
36000
36008
  ] });
36001
36009
  }
36002
36010
  function Table(props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.18",
3
+ "version": "2.0.20",
4
4
  "description": "description nueva",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,6 +36,7 @@ interface TableProps {
36
36
  hideColumns?: string[];
37
37
  footer?: FooterType;
38
38
  symbols?: any;
39
+ currentCoin?: string;
39
40
  [key: string]: any;
40
41
  }
41
42
 
@@ -241,6 +242,7 @@ function Toolbar({
241
242
 
242
243
  function useColumns(
243
244
  rows: GridValidRowModel[],
245
+ currentCoin: string,
244
246
  options: {
245
247
  flex: number;
246
248
  editableFields?: string[];
@@ -260,7 +262,6 @@ function useColumns(
260
262
  handleRowUpdate,
261
263
  onModalOpen,
262
264
  } = options;
263
-
264
265
  return useMemo(() => {
265
266
  if (!rows.length) return [];
266
267
 
@@ -271,13 +272,31 @@ function useColumns(
271
272
  headerName: key,
272
273
  valueFormatter: (value: any) => {
273
274
  if (value == null || value === "") return "";
274
- const num = parseFloat(value);
275
- if (isNaN(num)) return value;
275
+ const isDate = /(\d{4}-\d{2}-\d{2})(T[\d:,.+-]*(Z)?)?/;
276
+ if (`${value}`.match(isDate)) {
277
+ return value
278
+ .toString()
279
+ .split("T")[0]
280
+ .split("-")
281
+ .reverse()
282
+ .join("/");
283
+ }
276
284
 
277
- return num.toLocaleString("en-US", {
278
- minimumFractionDigits: num % 1 !== 0 ? 2 : 0,
279
- maximumFractionDigits: num % 1 !== 0 ? 2 : 0,
280
- });
285
+ const isNumber = typeof value === "number";
286
+
287
+ if (isNumber) {
288
+ if (isNaN(value)) return value;
289
+ return (
290
+ currentCoin +
291
+ " " +
292
+ value.toLocaleString("en-US", {
293
+ minimumFractionDigits: value % 1 !== 0 ? 2 : 0,
294
+ maximumFractionDigits: value % 1 !== 0 ? 2 : 0,
295
+ })
296
+ );
297
+ }
298
+
299
+ return value;
281
300
  },
282
301
  flex,
283
302
  editable: editableFields?.includes(key) ?? false,
@@ -339,6 +358,7 @@ function IHTable({
339
358
  header,
340
359
  hideColumns = [],
341
360
  footer = {},
361
+ currentCoin = "$",
342
362
  }: TableProps) {
343
363
  if (modal && onSelect)
344
364
  throw new Error("Solo se puede usar modal o onSelect por separado");
@@ -386,7 +406,7 @@ function IHTable({
386
406
  return [];
387
407
  }, [selectedRows, rows]);
388
408
 
389
- const columns = useColumns(rows, {
409
+ const columns = useColumns(rows, currentCoin, {
390
410
  flex,
391
411
  editableFields,
392
412
  buttons: resolvedButtons,
@@ -449,9 +469,8 @@ function IHTable({
449
469
  pageSizeOptions={[5, 10]}
450
470
  hideFooter={rows.length <= Object.keys(HEIGHT_MAP).length}
451
471
  />
452
-
453
- <CustomFooter footer={footer} rows={rows} />
454
472
  </Box>
473
+ <CustomFooter footer={footer} rows={rows} />
455
474
  </div>
456
475
  );
457
476
  }