next-recomponents 2.0.19 → 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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -9
- package/dist/index.mjs +17 -9
- package/package.json +1 -1
- package/src/table/index.tsx +28 -8
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
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,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,
|
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,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,
|
package/package.json
CHANGED
package/src/table/index.tsx
CHANGED
|
@@ -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
|
|
275
|
-
if (
|
|
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
|
+
}
|
|
284
|
+
|
|
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
|
+
}
|
|
276
298
|
|
|
277
|
-
return
|
|
278
|
-
minimumFractionDigits: num % 1 !== 0 ? 2 : 0,
|
|
279
|
-
maximumFractionDigits: num % 1 !== 0 ? 2 : 0,
|
|
280
|
-
});
|
|
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,
|