next-recomponents 2.0.15 → 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 +75 -62
- package/dist/index.mjs +75 -62
- package/package.json +1 -1
- package/src/modal/index.tsx +11 -6
- package/src/table/index.tsx +53 -42
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
|
-
|
|
35947
|
-
|
|
35948
|
-
|
|
35949
|
-
|
|
35950
|
-
|
|
35951
|
-
|
|
35952
|
-
|
|
35953
|
-
|
|
35954
|
-
|
|
35955
|
-
|
|
35956
|
-
|
|
35957
|
-
|
|
35958
|
-
|
|
35959
|
-
|
|
35960
|
-
|
|
35961
|
-
|
|
35962
|
-
|
|
35963
|
-
|
|
35964
|
-
|
|
35965
|
-
|
|
35966
|
-
|
|
35967
|
-
|
|
35968
|
-
|
|
35969
|
-
|
|
35970
|
-
|
|
35971
|
-
|
|
35972
|
-
|
|
35973
|
-
|
|
35974
|
-
|
|
35975
|
-
|
|
35976
|
-
|
|
35977
|
-
|
|
35978
|
-
|
|
35979
|
-
|
|
35980
|
-
|
|
35981
|
-
|
|
35982
|
-
|
|
35983
|
-
|
|
35984
|
-
|
|
35985
|
-
|
|
35986
|
-
|
|
35987
|
-
|
|
35988
|
-
|
|
35989
|
-
|
|
35990
|
-
|
|
35991
|
-
|
|
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
|
-
|
|
35996
|
-
|
|
35997
|
-
|
|
35998
|
-
|
|
35999
|
-
|
|
36000
|
-
|
|
36001
|
-
|
|
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)) {
|
|
@@ -37123,16 +37134,18 @@ function Modal({
|
|
|
37123
37134
|
color = "primary"
|
|
37124
37135
|
}) {
|
|
37125
37136
|
const pop = usePopup();
|
|
37137
|
+
const hide = () => pop.close(false);
|
|
37138
|
+
const childrenWithHide = (0, import_react10.cloneElement)(children, { hide });
|
|
37126
37139
|
(0, import_react10.useEffect)(() => {
|
|
37127
|
-
pop.updateMessage(
|
|
37140
|
+
pop.updateMessage(childrenWithHide);
|
|
37128
37141
|
}, [children]);
|
|
37129
|
-
const props =
|
|
37142
|
+
const props = button == null ? void 0 : button.props;
|
|
37130
37143
|
const onClick = props == null ? void 0 : props.onClick;
|
|
37131
37144
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
37132
37145
|
(0, import_react10.cloneElement)(button, {
|
|
37133
37146
|
onClick: (e) => {
|
|
37134
37147
|
onClick == null ? void 0 : onClick(e);
|
|
37135
|
-
pop.modal(
|
|
37148
|
+
pop.modal(childrenWithHide, color, false, true);
|
|
37136
37149
|
}
|
|
37137
37150
|
}),
|
|
37138
37151
|
pop.PopupComponent
|
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
|
-
|
|
35927
|
-
|
|
35928
|
-
|
|
35929
|
-
|
|
35930
|
-
|
|
35931
|
-
|
|
35932
|
-
|
|
35933
|
-
|
|
35934
|
-
|
|
35935
|
-
|
|
35936
|
-
|
|
35937
|
-
|
|
35938
|
-
|
|
35939
|
-
|
|
35940
|
-
|
|
35941
|
-
|
|
35942
|
-
|
|
35943
|
-
|
|
35944
|
-
|
|
35945
|
-
|
|
35946
|
-
|
|
35947
|
-
|
|
35948
|
-
|
|
35949
|
-
|
|
35950
|
-
|
|
35951
|
-
|
|
35952
|
-
|
|
35953
|
-
|
|
35954
|
-
|
|
35955
|
-
|
|
35956
|
-
|
|
35957
|
-
|
|
35958
|
-
|
|
35959
|
-
|
|
35960
|
-
|
|
35961
|
-
|
|
35962
|
-
|
|
35963
|
-
|
|
35964
|
-
|
|
35965
|
-
|
|
35966
|
-
|
|
35967
|
-
|
|
35968
|
-
|
|
35969
|
-
|
|
35970
|
-
|
|
35971
|
-
|
|
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
|
-
|
|
35976
|
-
|
|
35977
|
-
|
|
35978
|
-
|
|
35979
|
-
|
|
35980
|
-
|
|
35981
|
-
|
|
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)) {
|
|
@@ -37109,16 +37120,18 @@ function Modal({
|
|
|
37109
37120
|
color = "primary"
|
|
37110
37121
|
}) {
|
|
37111
37122
|
const pop = usePopup();
|
|
37123
|
+
const hide = () => pop.close(false);
|
|
37124
|
+
const childrenWithHide = cloneElement2(children, { hide });
|
|
37112
37125
|
useEffect6(() => {
|
|
37113
|
-
pop.updateMessage(
|
|
37126
|
+
pop.updateMessage(childrenWithHide);
|
|
37114
37127
|
}, [children]);
|
|
37115
|
-
const props =
|
|
37128
|
+
const props = button == null ? void 0 : button.props;
|
|
37116
37129
|
const onClick = props == null ? void 0 : props.onClick;
|
|
37117
37130
|
return /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
37118
37131
|
cloneElement2(button, {
|
|
37119
37132
|
onClick: (e) => {
|
|
37120
37133
|
onClick == null ? void 0 : onClick(e);
|
|
37121
|
-
pop.modal(
|
|
37134
|
+
pop.modal(childrenWithHide, color, false, true);
|
|
37122
37135
|
}
|
|
37123
37136
|
}),
|
|
37124
37137
|
pop.PopupComponent
|
package/package.json
CHANGED
package/src/modal/index.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Modal.tsx
|
|
2
2
|
import React, { ReactElement, cloneElement, useEffect } from "react";
|
|
3
3
|
import usePopup from "../pop";
|
|
4
|
+
|
|
4
5
|
export type PopupColor =
|
|
5
6
|
| "white"
|
|
6
7
|
| "primary"
|
|
@@ -22,20 +23,24 @@ export default function Modal({
|
|
|
22
23
|
color?: PopupColor;
|
|
23
24
|
}) {
|
|
24
25
|
const pop = usePopup();
|
|
26
|
+
const hide = () => pop.close(false);
|
|
27
|
+
|
|
28
|
+
// Inyectamos hide en children
|
|
29
|
+
const childrenWithHide = cloneElement(children, { hide });
|
|
25
30
|
|
|
26
|
-
// ✅ Cada vez que children cambia (estado del padre actualizado),
|
|
27
|
-
// propagamos el nuevo ReactNode al modal si está abierto
|
|
28
31
|
useEffect(() => {
|
|
29
|
-
pop.updateMessage(
|
|
30
|
-
}, [children]);
|
|
31
|
-
|
|
32
|
+
pop.updateMessage(childrenWithHide);
|
|
33
|
+
}, [children]); // children como dep para detectar cambios del padre
|
|
34
|
+
|
|
35
|
+
const props = button?.props;
|
|
32
36
|
const onClick = props?.onClick;
|
|
37
|
+
|
|
33
38
|
return (
|
|
34
39
|
<>
|
|
35
40
|
{cloneElement(button, {
|
|
36
41
|
onClick: (e) => {
|
|
37
42
|
onClick?.(e as any);
|
|
38
|
-
pop.modal(
|
|
43
|
+
pop.modal(childrenWithHide, color, false, true);
|
|
39
44
|
},
|
|
40
45
|
})}
|
|
41
46
|
{pop.PopupComponent}
|
package/src/table/index.tsx
CHANGED
|
@@ -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
|
-
<
|
|
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
|
-
<
|
|
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
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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
|
-
|
|
446
|
-
|
|
455
|
+
<CustomFooter footer={footer} rows={rows} />
|
|
456
|
+
</Box>
|
|
457
|
+
</div>
|
|
447
458
|
);
|
|
448
459
|
}
|
|
449
460
|
|