next-recomponents 2.0.19 → 2.0.21
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 +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +28 -9
- package/dist/index.mjs +28 -9
- package/package.json +1 -1
- package/src/table/index.tsx +40 -8
package/dist/index.d.mts
CHANGED
|
@@ -81,6 +81,9 @@ interface TableProps {
|
|
|
81
81
|
hideColumns?: string[];
|
|
82
82
|
footer?: FooterType;
|
|
83
83
|
symbols?: any;
|
|
84
|
+
currentCoin?: string;
|
|
85
|
+
className?: string;
|
|
86
|
+
fontSize?: string;
|
|
84
87
|
[key: string]: any;
|
|
85
88
|
}
|
|
86
89
|
declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,9 @@ interface TableProps {
|
|
|
81
81
|
hideColumns?: string[];
|
|
82
82
|
footer?: FooterType;
|
|
83
83
|
symbols?: any;
|
|
84
|
+
currentCoin?: string;
|
|
85
|
+
className?: string;
|
|
86
|
+
fontSize?: string;
|
|
84
87
|
[key: string]: any;
|
|
85
88
|
}
|
|
86
89
|
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
|
|
35845
|
-
if (
|
|
35846
|
-
|
|
35847
|
-
|
|
35848
|
-
|
|
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,10 @@ function IHTable({
|
|
|
35905
35912
|
width = "100%",
|
|
35906
35913
|
header,
|
|
35907
35914
|
hideColumns = [],
|
|
35908
|
-
footer = {}
|
|
35915
|
+
footer = {},
|
|
35916
|
+
currentCoin = "$",
|
|
35917
|
+
fontSize = "1rem",
|
|
35918
|
+
className
|
|
35909
35919
|
}) {
|
|
35910
35920
|
var _a;
|
|
35911
35921
|
if (modal && onSelect)
|
|
@@ -35946,7 +35956,7 @@ function IHTable({
|
|
|
35946
35956
|
}
|
|
35947
35957
|
return [];
|
|
35948
35958
|
}, [selectedRows, rows]);
|
|
35949
|
-
const columns = useColumns(rows, {
|
|
35959
|
+
const columns = useColumns(rows, currentCoin, {
|
|
35950
35960
|
flex,
|
|
35951
35961
|
editableFields,
|
|
35952
35962
|
buttons: resolvedButtons,
|
|
@@ -35991,12 +36001,21 @@ function IHTable({
|
|
|
35991
36001
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
35992
36002
|
import_x_data_grid.DataGrid,
|
|
35993
36003
|
{
|
|
36004
|
+
className,
|
|
35994
36005
|
rows,
|
|
35995
36006
|
columns,
|
|
35996
36007
|
checkboxSelection: Boolean(onSelect),
|
|
35997
36008
|
rowSelectionModel: selectedRows,
|
|
35998
36009
|
onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
|
|
35999
36010
|
sx: {
|
|
36011
|
+
fontSize,
|
|
36012
|
+
// equivalente a text-xs
|
|
36013
|
+
"& .MuiDataGrid-cell": {
|
|
36014
|
+
fontSize
|
|
36015
|
+
},
|
|
36016
|
+
"& .MuiDataGrid-columnHeader": {
|
|
36017
|
+
fontSize
|
|
36018
|
+
},
|
|
36000
36019
|
"& .MuiDataGrid-cell--editable": {
|
|
36001
36020
|
backgroundColor: "#c6d8f0",
|
|
36002
36021
|
fontWeight: 500
|
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
|
|
35825
|
-
if (
|
|
35826
|
-
|
|
35827
|
-
|
|
35828
|
-
|
|
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,10 @@ function IHTable({
|
|
|
35885
35892
|
width = "100%",
|
|
35886
35893
|
header,
|
|
35887
35894
|
hideColumns = [],
|
|
35888
|
-
footer = {}
|
|
35895
|
+
footer = {},
|
|
35896
|
+
currentCoin = "$",
|
|
35897
|
+
fontSize = "1rem",
|
|
35898
|
+
className
|
|
35889
35899
|
}) {
|
|
35890
35900
|
var _a;
|
|
35891
35901
|
if (modal && onSelect)
|
|
@@ -35926,7 +35936,7 @@ function IHTable({
|
|
|
35926
35936
|
}
|
|
35927
35937
|
return [];
|
|
35928
35938
|
}, [selectedRows, rows]);
|
|
35929
|
-
const columns = useColumns(rows, {
|
|
35939
|
+
const columns = useColumns(rows, currentCoin, {
|
|
35930
35940
|
flex,
|
|
35931
35941
|
editableFields,
|
|
35932
35942
|
buttons: resolvedButtons,
|
|
@@ -35971,12 +35981,21 @@ function IHTable({
|
|
|
35971
35981
|
/* @__PURE__ */ jsx6(
|
|
35972
35982
|
DataGrid,
|
|
35973
35983
|
{
|
|
35984
|
+
className,
|
|
35974
35985
|
rows,
|
|
35975
35986
|
columns,
|
|
35976
35987
|
checkboxSelection: Boolean(onSelect),
|
|
35977
35988
|
rowSelectionModel: selectedRows,
|
|
35978
35989
|
onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
|
|
35979
35990
|
sx: {
|
|
35991
|
+
fontSize,
|
|
35992
|
+
// equivalente a text-xs
|
|
35993
|
+
"& .MuiDataGrid-cell": {
|
|
35994
|
+
fontSize
|
|
35995
|
+
},
|
|
35996
|
+
"& .MuiDataGrid-columnHeader": {
|
|
35997
|
+
fontSize
|
|
35998
|
+
},
|
|
35980
35999
|
"& .MuiDataGrid-cell--editable": {
|
|
35981
36000
|
backgroundColor: "#c6d8f0",
|
|
35982
36001
|
fontWeight: 500
|
package/package.json
CHANGED
package/src/table/index.tsx
CHANGED
|
@@ -36,6 +36,9 @@ interface TableProps {
|
|
|
36
36
|
hideColumns?: string[];
|
|
37
37
|
footer?: FooterType;
|
|
38
38
|
symbols?: any;
|
|
39
|
+
currentCoin?: string;
|
|
40
|
+
className?: string;
|
|
41
|
+
fontSize?: string;
|
|
39
42
|
[key: string]: any;
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -241,6 +244,7 @@ function Toolbar({
|
|
|
241
244
|
|
|
242
245
|
function useColumns(
|
|
243
246
|
rows: GridValidRowModel[],
|
|
247
|
+
currentCoin: string,
|
|
244
248
|
options: {
|
|
245
249
|
flex: number;
|
|
246
250
|
editableFields?: string[];
|
|
@@ -260,7 +264,6 @@ function useColumns(
|
|
|
260
264
|
handleRowUpdate,
|
|
261
265
|
onModalOpen,
|
|
262
266
|
} = options;
|
|
263
|
-
|
|
264
267
|
return useMemo(() => {
|
|
265
268
|
if (!rows.length) return [];
|
|
266
269
|
|
|
@@ -271,13 +274,31 @@ function useColumns(
|
|
|
271
274
|
headerName: key,
|
|
272
275
|
valueFormatter: (value: any) => {
|
|
273
276
|
if (value == null || value === "") return "";
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
277
|
+
const isDate = /(\d{4}-\d{2}-\d{2})(T[\d:,.+-]*(Z)?)?/;
|
|
278
|
+
if (`${value}`.match(isDate)) {
|
|
279
|
+
return value
|
|
280
|
+
.toString()
|
|
281
|
+
.split("T")[0]
|
|
282
|
+
.split("-")
|
|
283
|
+
.reverse()
|
|
284
|
+
.join("/");
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const isNumber = typeof value === "number";
|
|
288
|
+
|
|
289
|
+
if (isNumber) {
|
|
290
|
+
if (isNaN(value)) return value;
|
|
291
|
+
return (
|
|
292
|
+
currentCoin +
|
|
293
|
+
" " +
|
|
294
|
+
value.toLocaleString("en-US", {
|
|
295
|
+
minimumFractionDigits: value % 1 !== 0 ? 2 : 0,
|
|
296
|
+
maximumFractionDigits: value % 1 !== 0 ? 2 : 0,
|
|
297
|
+
})
|
|
298
|
+
);
|
|
299
|
+
}
|
|
276
300
|
|
|
277
|
-
return
|
|
278
|
-
minimumFractionDigits: num % 1 !== 0 ? 2 : 0,
|
|
279
|
-
maximumFractionDigits: num % 1 !== 0 ? 2 : 0,
|
|
280
|
-
});
|
|
301
|
+
return value;
|
|
281
302
|
},
|
|
282
303
|
flex,
|
|
283
304
|
editable: editableFields?.includes(key) ?? false,
|
|
@@ -339,6 +360,9 @@ function IHTable({
|
|
|
339
360
|
header,
|
|
340
361
|
hideColumns = [],
|
|
341
362
|
footer = {},
|
|
363
|
+
currentCoin = "$",
|
|
364
|
+
fontSize = "1rem",
|
|
365
|
+
className,
|
|
342
366
|
}: TableProps) {
|
|
343
367
|
if (modal && onSelect)
|
|
344
368
|
throw new Error("Solo se puede usar modal o onSelect por separado");
|
|
@@ -386,7 +410,7 @@ function IHTable({
|
|
|
386
410
|
return [];
|
|
387
411
|
}, [selectedRows, rows]);
|
|
388
412
|
|
|
389
|
-
const columns = useColumns(rows, {
|
|
413
|
+
const columns = useColumns(rows, currentCoin, {
|
|
390
414
|
flex,
|
|
391
415
|
editableFields,
|
|
392
416
|
buttons: resolvedButtons,
|
|
@@ -428,12 +452,20 @@ function IHTable({
|
|
|
428
452
|
)}
|
|
429
453
|
|
|
430
454
|
<DataGrid
|
|
455
|
+
className={className}
|
|
431
456
|
rows={rows}
|
|
432
457
|
columns={columns as any}
|
|
433
458
|
checkboxSelection={Boolean(onSelect)}
|
|
434
459
|
rowSelectionModel={selectedRows}
|
|
435
460
|
onRowSelectionModelChange={!modal ? setSelectedRows : undefined}
|
|
436
461
|
sx={{
|
|
462
|
+
fontSize, // equivalente a text-xs
|
|
463
|
+
"& .MuiDataGrid-cell": {
|
|
464
|
+
fontSize,
|
|
465
|
+
},
|
|
466
|
+
"& .MuiDataGrid-columnHeader": {
|
|
467
|
+
fontSize,
|
|
468
|
+
},
|
|
437
469
|
"& .MuiDataGrid-cell--editable": {
|
|
438
470
|
backgroundColor: "#c6d8f0",
|
|
439
471
|
fontWeight: 500,
|