next-recomponents 2.0.16 → 2.0.17

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.js CHANGED
@@ -35834,6 +35834,15 @@ function useColumns(rows, options) {
35834
35834
  return {
35835
35835
  field: key,
35836
35836
  headerName: key,
35837
+ valueFormatter: (value) => {
35838
+ if (value == null || value === "") return "";
35839
+ const num = parseFloat(value);
35840
+ if (isNaN(num)) return value;
35841
+ return num.toLocaleString("en-US", {
35842
+ minimumFractionDigits: num % 1 !== 0 ? 2 : 0,
35843
+ maximumFractionDigits: num % 1 !== 0 ? 2 : 0
35844
+ });
35845
+ },
35837
35846
  flex,
35838
35847
  editable: (_a = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _a : false,
35839
35848
  type: typeof rows[0][key] === "number" ? "number" : "string",
@@ -35942,66 +35951,68 @@ function IHTable({
35942
35951
  onModalOpen: handleModalOpen
35943
35952
  });
35944
35953
  if (!rows.length) return null;
35945
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
35946
- import_material.Box,
35947
- {
35948
- sx: {
35949
- display: "flex",
35950
- flexDirection: "column",
35951
- height: (_a = HEIGHT_MAP[rows.length]) != null ? _a : height,
35952
- width,
35953
- zIndex: 999999999
35954
- },
35955
- children: [
35956
- modal && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35957
- ModalDialog,
35958
- {
35959
- open,
35960
- onClose: handleClose,
35961
- modal,
35962
- selectedRow: modalRow
35963
- }
35964
- ),
35965
- header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-bold text-xl p-2 bg-blue-500 text-white border shadow rounded", children: header }),
35966
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35967
- Toolbar,
35968
- {
35969
- exportName,
35970
- onSave,
35971
- onSelect,
35972
- rows,
35973
- filteredRows
35974
- }
35975
- ),
35976
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35977
- import_x_data_grid.DataGrid,
35978
- {
35979
- rows,
35980
- columns,
35981
- checkboxSelection: Boolean(onSelect),
35982
- rowSelectionModel: selectedRows,
35983
- onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
35984
- sx: {
35985
- "& .MuiDataGrid-cell--editable": {
35986
- backgroundColor: "#c6d8f0",
35987
- fontWeight: 500
35988
- },
35989
- ...rows.length <= Object.keys(HEIGHT_MAP).length && {
35990
- "& .MuiDataGrid-filler": {
35991
- display: "none"
35954
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
35955
+ header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-bold text-xl p-2 bg-blue-500 text-white border shadow rounded", children: header }),
35956
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35957
+ Toolbar,
35958
+ {
35959
+ exportName,
35960
+ onSave,
35961
+ onSelect,
35962
+ rows,
35963
+ filteredRows
35964
+ }
35965
+ ),
35966
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
35967
+ import_material.Box,
35968
+ {
35969
+ sx: {
35970
+ display: "flex",
35971
+ flexDirection: "column",
35972
+ height: (_a = HEIGHT_MAP[rows.length]) != null ? _a : height,
35973
+ width,
35974
+ zIndex: 999999999
35975
+ },
35976
+ children: [
35977
+ modal && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35978
+ ModalDialog,
35979
+ {
35980
+ open,
35981
+ onClose: handleClose,
35982
+ modal,
35983
+ selectedRow: modalRow
35984
+ }
35985
+ ),
35986
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
35987
+ import_x_data_grid.DataGrid,
35988
+ {
35989
+ rows,
35990
+ columns,
35991
+ checkboxSelection: Boolean(onSelect),
35992
+ rowSelectionModel: selectedRows,
35993
+ onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
35994
+ sx: {
35995
+ "& .MuiDataGrid-cell--editable": {
35996
+ backgroundColor: "#c6d8f0",
35997
+ fontWeight: 500
35998
+ },
35999
+ ...rows.length <= Object.keys(HEIGHT_MAP).length && {
36000
+ "& .MuiDataGrid-filler": {
36001
+ display: "none"
36002
+ }
35992
36003
  }
35993
- }
35994
- },
35995
- editMode: "row",
35996
- processRowUpdate: handleRowUpdate,
35997
- pageSizeOptions: [5, 10],
35998
- hideFooter: rows.length <= Object.keys(HEIGHT_MAP).length
35999
- }
36000
- ),
36001
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CustomFooter, { footer, rows })
36002
- ]
36003
- }
36004
- );
36004
+ },
36005
+ editMode: "row",
36006
+ processRowUpdate: handleRowUpdate,
36007
+ pageSizeOptions: [5, 10],
36008
+ hideFooter: rows.length <= Object.keys(HEIGHT_MAP).length
36009
+ }
36010
+ ),
36011
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CustomFooter, { footer, rows })
36012
+ ]
36013
+ }
36014
+ )
36015
+ ] });
36005
36016
  }
36006
36017
  function Table(props) {
36007
36018
  if (Array.isArray(props.data)) {
package/dist/index.mjs CHANGED
@@ -35814,6 +35814,15 @@ function useColumns(rows, options) {
35814
35814
  return {
35815
35815
  field: key,
35816
35816
  headerName: key,
35817
+ valueFormatter: (value) => {
35818
+ if (value == null || value === "") return "";
35819
+ const num = parseFloat(value);
35820
+ if (isNaN(num)) return value;
35821
+ return num.toLocaleString("en-US", {
35822
+ minimumFractionDigits: num % 1 !== 0 ? 2 : 0,
35823
+ maximumFractionDigits: num % 1 !== 0 ? 2 : 0
35824
+ });
35825
+ },
35817
35826
  flex,
35818
35827
  editable: (_a = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _a : false,
35819
35828
  type: typeof rows[0][key] === "number" ? "number" : "string",
@@ -35922,66 +35931,68 @@ function IHTable({
35922
35931
  onModalOpen: handleModalOpen
35923
35932
  });
35924
35933
  if (!rows.length) return null;
35925
- return /* @__PURE__ */ jsxs5(
35926
- Box,
35927
- {
35928
- sx: {
35929
- display: "flex",
35930
- flexDirection: "column",
35931
- height: (_a = HEIGHT_MAP[rows.length]) != null ? _a : height,
35932
- width,
35933
- zIndex: 999999999
35934
- },
35935
- children: [
35936
- modal && /* @__PURE__ */ jsx6(
35937
- ModalDialog,
35938
- {
35939
- open,
35940
- onClose: handleClose,
35941
- modal,
35942
- selectedRow: modalRow
35943
- }
35944
- ),
35945
- header && /* @__PURE__ */ jsx6("div", { className: "font-bold text-xl p-2 bg-blue-500 text-white border shadow rounded", children: header }),
35946
- /* @__PURE__ */ jsx6(
35947
- Toolbar,
35948
- {
35949
- exportName,
35950
- onSave,
35951
- onSelect,
35952
- rows,
35953
- filteredRows
35954
- }
35955
- ),
35956
- /* @__PURE__ */ jsx6(
35957
- DataGrid,
35958
- {
35959
- rows,
35960
- columns,
35961
- checkboxSelection: Boolean(onSelect),
35962
- rowSelectionModel: selectedRows,
35963
- onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
35964
- sx: {
35965
- "& .MuiDataGrid-cell--editable": {
35966
- backgroundColor: "#c6d8f0",
35967
- fontWeight: 500
35968
- },
35969
- ...rows.length <= Object.keys(HEIGHT_MAP).length && {
35970
- "& .MuiDataGrid-filler": {
35971
- display: "none"
35934
+ return /* @__PURE__ */ jsxs5("div", { children: [
35935
+ header && /* @__PURE__ */ jsx6("div", { className: "font-bold text-xl p-2 bg-blue-500 text-white border shadow rounded", children: header }),
35936
+ /* @__PURE__ */ jsx6(
35937
+ Toolbar,
35938
+ {
35939
+ exportName,
35940
+ onSave,
35941
+ onSelect,
35942
+ rows,
35943
+ filteredRows
35944
+ }
35945
+ ),
35946
+ /* @__PURE__ */ jsxs5(
35947
+ Box,
35948
+ {
35949
+ sx: {
35950
+ display: "flex",
35951
+ flexDirection: "column",
35952
+ height: (_a = HEIGHT_MAP[rows.length]) != null ? _a : height,
35953
+ width,
35954
+ zIndex: 999999999
35955
+ },
35956
+ children: [
35957
+ modal && /* @__PURE__ */ jsx6(
35958
+ ModalDialog,
35959
+ {
35960
+ open,
35961
+ onClose: handleClose,
35962
+ modal,
35963
+ selectedRow: modalRow
35964
+ }
35965
+ ),
35966
+ /* @__PURE__ */ jsx6(
35967
+ DataGrid,
35968
+ {
35969
+ rows,
35970
+ columns,
35971
+ checkboxSelection: Boolean(onSelect),
35972
+ rowSelectionModel: selectedRows,
35973
+ onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
35974
+ sx: {
35975
+ "& .MuiDataGrid-cell--editable": {
35976
+ backgroundColor: "#c6d8f0",
35977
+ fontWeight: 500
35978
+ },
35979
+ ...rows.length <= Object.keys(HEIGHT_MAP).length && {
35980
+ "& .MuiDataGrid-filler": {
35981
+ display: "none"
35982
+ }
35972
35983
  }
35973
- }
35974
- },
35975
- editMode: "row",
35976
- processRowUpdate: handleRowUpdate,
35977
- pageSizeOptions: [5, 10],
35978
- hideFooter: rows.length <= Object.keys(HEIGHT_MAP).length
35979
- }
35980
- ),
35981
- /* @__PURE__ */ jsx6(CustomFooter, { footer, rows })
35982
- ]
35983
- }
35984
- );
35984
+ },
35985
+ editMode: "row",
35986
+ processRowUpdate: handleRowUpdate,
35987
+ pageSizeOptions: [5, 10],
35988
+ hideFooter: rows.length <= Object.keys(HEIGHT_MAP).length
35989
+ }
35990
+ ),
35991
+ /* @__PURE__ */ jsx6(CustomFooter, { footer, rows })
35992
+ ]
35993
+ }
35994
+ )
35995
+ ] });
35985
35996
  }
35986
35997
  function Table(props) {
35987
35998
  if (Array.isArray(props.data)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.16",
3
+ "version": "2.0.17",
4
4
  "description": "description nueva",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -267,6 +267,16 @@ function useColumns(
267
267
  .map((key) => ({
268
268
  field: key,
269
269
  headerName: key,
270
+ valueFormatter: (value: any) => {
271
+ if (value == null || value === "") return "";
272
+ const num = parseFloat(value);
273
+ if (isNaN(num)) return value;
274
+
275
+ return num.toLocaleString("en-US", {
276
+ minimumFractionDigits: num % 1 !== 0 ? 2 : 0,
277
+ maximumFractionDigits: num % 1 !== 0 ? 2 : 0,
278
+ });
279
+ },
270
280
  flex,
271
281
  editable: editableFields?.includes(key) ?? false,
272
282
  type: typeof rows[0][key] === "number" ? "number" : "string",
@@ -304,7 +314,7 @@ function useColumns(
304
314
  {params?.row?.["Modal"]}
305
315
  </Button>
306
316
  ) as any,
307
- });
317
+ } as any);
308
318
  }
309
319
 
310
320
  return cols;
@@ -387,30 +397,12 @@ function IHTable({
387
397
  if (!rows.length) return null;
388
398
 
389
399
  return (
390
- <Box
391
- sx={{
392
- display: "flex",
393
- flexDirection: "column",
394
- height: HEIGHT_MAP[rows.length] ?? height,
395
- width,
396
- zIndex: 999999999,
397
- }}
398
- >
399
- {modal && (
400
- <ModalDialog
401
- open={open}
402
- onClose={handleClose}
403
- modal={modal}
404
- selectedRow={modalRow}
405
- />
406
- )}
407
-
400
+ <div>
408
401
  {header && (
409
402
  <div className="font-bold text-xl p-2 bg-blue-500 text-white border shadow rounded">
410
403
  {header}
411
404
  </div>
412
405
  )}
413
-
414
406
  <Toolbar
415
407
  exportName={exportName}
416
408
  onSave={onSave}
@@ -419,31 +411,50 @@ function IHTable({
419
411
  filteredRows={filteredRows}
420
412
  />
421
413
 
422
- <DataGrid
423
- rows={rows}
424
- columns={columns as any}
425
- checkboxSelection={Boolean(onSelect)}
426
- rowSelectionModel={selectedRows}
427
- onRowSelectionModelChange={!modal ? setSelectedRows : undefined}
414
+ <Box
428
415
  sx={{
429
- "& .MuiDataGrid-cell--editable": {
430
- backgroundColor: "#c6d8f0",
431
- fontWeight: 500,
432
- },
433
- ...(rows.length <= Object.keys(HEIGHT_MAP).length && {
434
- "& .MuiDataGrid-filler": {
435
- display: "none",
436
- },
437
- }),
416
+ display: "flex",
417
+ flexDirection: "column",
418
+ height: HEIGHT_MAP[rows.length] ?? height,
419
+ width,
420
+ zIndex: 999999999,
438
421
  }}
439
- editMode="row"
440
- processRowUpdate={handleRowUpdate}
441
- pageSizeOptions={[5, 10]}
442
- hideFooter={rows.length <= Object.keys(HEIGHT_MAP).length}
443
- />
422
+ >
423
+ {modal && (
424
+ <ModalDialog
425
+ open={open}
426
+ onClose={handleClose}
427
+ modal={modal}
428
+ selectedRow={modalRow}
429
+ />
430
+ )}
431
+
432
+ <DataGrid
433
+ rows={rows}
434
+ columns={columns as any}
435
+ checkboxSelection={Boolean(onSelect)}
436
+ rowSelectionModel={selectedRows}
437
+ onRowSelectionModelChange={!modal ? setSelectedRows : undefined}
438
+ sx={{
439
+ "& .MuiDataGrid-cell--editable": {
440
+ backgroundColor: "#c6d8f0",
441
+ fontWeight: 500,
442
+ },
443
+ ...(rows.length <= Object.keys(HEIGHT_MAP).length && {
444
+ "& .MuiDataGrid-filler": {
445
+ display: "none",
446
+ },
447
+ }),
448
+ }}
449
+ editMode="row"
450
+ processRowUpdate={handleRowUpdate}
451
+ pageSizeOptions={[5, 10]}
452
+ hideFooter={rows.length <= Object.keys(HEIGHT_MAP).length}
453
+ />
444
454
 
445
- <CustomFooter footer={footer} rows={rows} />
446
- </Box>
455
+ <CustomFooter footer={footer} rows={rows} />
456
+ </Box>
457
+ </div>
447
458
  );
448
459
  }
449
460