next-recomponents 2.0.23 → 2.0.25
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +37 -24
- package/dist/index.mjs +37 -24
- package/package.json +1 -1
- package/src/table/index.tsx +39 -19
package/dist/index.d.mts
CHANGED
|
@@ -72,6 +72,7 @@ interface TableProps {
|
|
|
72
72
|
editableFields?: string[];
|
|
73
73
|
onSelect?: (data: GridValidRowModel[]) => void;
|
|
74
74
|
onSave?: (data: GridValidRowModel[]) => void;
|
|
75
|
+
onCloseModal?: (data: GridValidRowModel | undefined) => boolean;
|
|
75
76
|
buttons?: Record<string, any>;
|
|
76
77
|
exportName?: string;
|
|
77
78
|
modal?: React$1.ReactNode;
|
|
@@ -84,6 +85,7 @@ interface TableProps {
|
|
|
84
85
|
currentCoin?: string;
|
|
85
86
|
className?: string;
|
|
86
87
|
fontSize?: string;
|
|
88
|
+
colSize?: Record<string, number>;
|
|
87
89
|
[key: string]: any;
|
|
88
90
|
}
|
|
89
91
|
declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ interface TableProps {
|
|
|
72
72
|
editableFields?: string[];
|
|
73
73
|
onSelect?: (data: GridValidRowModel[]) => void;
|
|
74
74
|
onSave?: (data: GridValidRowModel[]) => void;
|
|
75
|
+
onCloseModal?: (data: GridValidRowModel | undefined) => boolean;
|
|
75
76
|
buttons?: Record<string, any>;
|
|
76
77
|
exportName?: string;
|
|
77
78
|
modal?: React$1.ReactNode;
|
|
@@ -84,6 +85,7 @@ interface TableProps {
|
|
|
84
85
|
currentCoin?: string;
|
|
85
86
|
className?: string;
|
|
86
87
|
fontSize?: string;
|
|
88
|
+
colSize?: Record<string, number>;
|
|
87
89
|
[key: string]: any;
|
|
88
90
|
}
|
|
89
91
|
declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -35715,8 +35715,8 @@ function EditIcon() {
|
|
|
35715
35715
|
fill: "currentColor",
|
|
35716
35716
|
strokeWidth: "0",
|
|
35717
35717
|
viewBox: "0 0 576 512",
|
|
35718
|
-
height: "
|
|
35719
|
-
width: "
|
|
35718
|
+
height: "12px",
|
|
35719
|
+
width: "12px",
|
|
35720
35720
|
xmlns: "http://www.w3.org/2000/svg",
|
|
35721
35721
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z" })
|
|
35722
35722
|
}
|
|
@@ -35774,12 +35774,12 @@ function CustomFooter({
|
|
|
35774
35774
|
}) });
|
|
35775
35775
|
}
|
|
35776
35776
|
function ModalDialog({ open, onClose, modal, selectedRow }) {
|
|
35777
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_material.Dialog, { open,
|
|
35777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_material.Dialog, { open, maxWidth: "xl", fullWidth: true, children: [
|
|
35778
35778
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
35779
35779
|
"button",
|
|
35780
35780
|
{
|
|
35781
35781
|
onClick: onClose,
|
|
35782
|
-
className: "
|
|
35782
|
+
className: " font-bold p-1 m-5 w-[30px] h-[30px] flex items-center justify-center hover:animate-pulse border shadow rounded bg-red-500 text-white",
|
|
35783
35783
|
children: "\xD7"
|
|
35784
35784
|
}
|
|
35785
35785
|
) }),
|
|
@@ -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, currentCoin, options) {
|
|
35825
|
+
function useColumns(rows, currentCoin, options, colSize) {
|
|
35826
35826
|
const {
|
|
35827
35827
|
flex,
|
|
35828
35828
|
editableFields,
|
|
@@ -35835,7 +35835,7 @@ function useColumns(rows, currentCoin, options) {
|
|
|
35835
35835
|
return (0, import_react4.useMemo)(() => {
|
|
35836
35836
|
if (!rows.length) return [];
|
|
35837
35837
|
const cols = Object.keys(rows[0]).filter((key) => !key.startsWith("_") && !hideColumns.includes(key)).map((key) => {
|
|
35838
|
-
var _a;
|
|
35838
|
+
var _a, _b;
|
|
35839
35839
|
return {
|
|
35840
35840
|
field: key,
|
|
35841
35841
|
headerName: key,
|
|
@@ -35863,18 +35863,21 @@ function useColumns(rows, currentCoin, options) {
|
|
|
35863
35863
|
}
|
|
35864
35864
|
return value;
|
|
35865
35865
|
},
|
|
35866
|
-
flex,
|
|
35867
|
-
|
|
35866
|
+
flex: key == "id" ? false : !(colSize == null ? void 0 : colSize[key]),
|
|
35867
|
+
width: key == "id" ? 80 : (_a = colSize == null ? void 0 : colSize[key]) != null ? _a : void 0,
|
|
35868
|
+
editable: (_b = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _b : false,
|
|
35868
35869
|
type: typeof rows[0][key] === "number" ? "number" : "string",
|
|
35869
35870
|
renderCell: (buttons == null ? void 0 : buttons[key]) ? (params) => {
|
|
35870
|
-
var _a2,
|
|
35871
|
+
var _a2, _b2, _c;
|
|
35872
|
+
const children = ((_a2 = buttons == null ? void 0 : buttons[key]) == null ? void 0 : _a2.type) == "input" ? null : (_b2 = params == null ? void 0 : params.row) == null ? void 0 : _b2[key];
|
|
35871
35873
|
return import_react4.default.cloneElement(buttons[key], {
|
|
35872
|
-
className: `${(
|
|
35873
|
-
children
|
|
35874
|
+
className: `${(_c = params == null ? void 0 : params.className) != null ? _c : ""} m-auto text-xs`,
|
|
35875
|
+
children,
|
|
35876
|
+
row: params == null ? void 0 : params.row,
|
|
35874
35877
|
onClick: async (e) => {
|
|
35875
|
-
var _a3,
|
|
35878
|
+
var _a3, _b3;
|
|
35876
35879
|
e.row = params == null ? void 0 : params.row;
|
|
35877
|
-
if ((
|
|
35880
|
+
if ((_b3 = (_a3 = buttons[key]) == null ? void 0 : _a3.props) == null ? void 0 : _b3.onClick) {
|
|
35878
35881
|
const newVal = await buttons[key].props.onClick(e);
|
|
35879
35882
|
if (newVal) handleRowUpdate({ ...e.row, newVal });
|
|
35880
35883
|
}
|
|
@@ -35887,9 +35890,10 @@ function useColumns(rows, currentCoin, options) {
|
|
|
35887
35890
|
cols.unshift({
|
|
35888
35891
|
field: "Modal",
|
|
35889
35892
|
headerName: "Modal",
|
|
35890
|
-
flex,
|
|
35893
|
+
// flex,
|
|
35891
35894
|
editable: false,
|
|
35892
35895
|
type: "string",
|
|
35896
|
+
width: 10,
|
|
35893
35897
|
renderCell: (params) => {
|
|
35894
35898
|
var _a;
|
|
35895
35899
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -35913,6 +35917,7 @@ function IHTable({
|
|
|
35913
35917
|
editableFields,
|
|
35914
35918
|
onSave,
|
|
35915
35919
|
onSelect,
|
|
35920
|
+
onCloseModal,
|
|
35916
35921
|
buttons,
|
|
35917
35922
|
exportName,
|
|
35918
35923
|
modal,
|
|
@@ -35923,7 +35928,8 @@ function IHTable({
|
|
|
35923
35928
|
footer = {},
|
|
35924
35929
|
currentCoin = "$",
|
|
35925
35930
|
fontSize = "1rem",
|
|
35926
|
-
className
|
|
35931
|
+
className,
|
|
35932
|
+
colSize
|
|
35927
35933
|
}) {
|
|
35928
35934
|
var _a;
|
|
35929
35935
|
if (modal && onSelect)
|
|
@@ -35944,6 +35950,8 @@ function IHTable({
|
|
|
35944
35950
|
setOpen(true);
|
|
35945
35951
|
};
|
|
35946
35952
|
const handleClose = () => {
|
|
35953
|
+
const pass = onCloseModal ? onCloseModal == null ? void 0 : onCloseModal(modalRow) : true;
|
|
35954
|
+
if (!pass) return;
|
|
35947
35955
|
setOpen(false);
|
|
35948
35956
|
setModalRow(void 0);
|
|
35949
35957
|
};
|
|
@@ -35964,15 +35972,20 @@ function IHTable({
|
|
|
35964
35972
|
}
|
|
35965
35973
|
return [];
|
|
35966
35974
|
}, [selectedRows, rows]);
|
|
35967
|
-
const columns = useColumns(
|
|
35968
|
-
|
|
35969
|
-
|
|
35970
|
-
|
|
35971
|
-
|
|
35972
|
-
|
|
35973
|
-
|
|
35974
|
-
|
|
35975
|
-
|
|
35975
|
+
const columns = useColumns(
|
|
35976
|
+
rows,
|
|
35977
|
+
currentCoin,
|
|
35978
|
+
{
|
|
35979
|
+
flex,
|
|
35980
|
+
editableFields,
|
|
35981
|
+
buttons: resolvedButtons,
|
|
35982
|
+
hideColumns,
|
|
35983
|
+
modal,
|
|
35984
|
+
handleRowUpdate,
|
|
35985
|
+
onModalOpen: handleModalOpen
|
|
35986
|
+
},
|
|
35987
|
+
colSize
|
|
35988
|
+
);
|
|
35976
35989
|
if (!rows.length) return null;
|
|
35977
35990
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "m-2", children: [
|
|
35978
35991
|
header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-bold p-2 ", children: header }),
|
package/dist/index.mjs
CHANGED
|
@@ -35695,8 +35695,8 @@ function EditIcon() {
|
|
|
35695
35695
|
fill: "currentColor",
|
|
35696
35696
|
strokeWidth: "0",
|
|
35697
35697
|
viewBox: "0 0 576 512",
|
|
35698
|
-
height: "
|
|
35699
|
-
width: "
|
|
35698
|
+
height: "12px",
|
|
35699
|
+
width: "12px",
|
|
35700
35700
|
xmlns: "http://www.w3.org/2000/svg",
|
|
35701
35701
|
children: /* @__PURE__ */ jsx6("path", { d: "M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z" })
|
|
35702
35702
|
}
|
|
@@ -35754,12 +35754,12 @@ function CustomFooter({
|
|
|
35754
35754
|
}) });
|
|
35755
35755
|
}
|
|
35756
35756
|
function ModalDialog({ open, onClose, modal, selectedRow }) {
|
|
35757
|
-
return /* @__PURE__ */ jsxs5(Dialog, { open,
|
|
35757
|
+
return /* @__PURE__ */ jsxs5(Dialog, { open, maxWidth: "xl", fullWidth: true, children: [
|
|
35758
35758
|
/* @__PURE__ */ jsx6("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx6(
|
|
35759
35759
|
"button",
|
|
35760
35760
|
{
|
|
35761
35761
|
onClick: onClose,
|
|
35762
|
-
className: "
|
|
35762
|
+
className: " font-bold p-1 m-5 w-[30px] h-[30px] flex items-center justify-center hover:animate-pulse border shadow rounded bg-red-500 text-white",
|
|
35763
35763
|
children: "\xD7"
|
|
35764
35764
|
}
|
|
35765
35765
|
) }),
|
|
@@ -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, currentCoin, options) {
|
|
35805
|
+
function useColumns(rows, currentCoin, options, colSize) {
|
|
35806
35806
|
const {
|
|
35807
35807
|
flex,
|
|
35808
35808
|
editableFields,
|
|
@@ -35815,7 +35815,7 @@ function useColumns(rows, currentCoin, options) {
|
|
|
35815
35815
|
return useMemo(() => {
|
|
35816
35816
|
if (!rows.length) return [];
|
|
35817
35817
|
const cols = Object.keys(rows[0]).filter((key) => !key.startsWith("_") && !hideColumns.includes(key)).map((key) => {
|
|
35818
|
-
var _a;
|
|
35818
|
+
var _a, _b;
|
|
35819
35819
|
return {
|
|
35820
35820
|
field: key,
|
|
35821
35821
|
headerName: key,
|
|
@@ -35843,18 +35843,21 @@ function useColumns(rows, currentCoin, options) {
|
|
|
35843
35843
|
}
|
|
35844
35844
|
return value;
|
|
35845
35845
|
},
|
|
35846
|
-
flex,
|
|
35847
|
-
|
|
35846
|
+
flex: key == "id" ? false : !(colSize == null ? void 0 : colSize[key]),
|
|
35847
|
+
width: key == "id" ? 80 : (_a = colSize == null ? void 0 : colSize[key]) != null ? _a : void 0,
|
|
35848
|
+
editable: (_b = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _b : false,
|
|
35848
35849
|
type: typeof rows[0][key] === "number" ? "number" : "string",
|
|
35849
35850
|
renderCell: (buttons == null ? void 0 : buttons[key]) ? (params) => {
|
|
35850
|
-
var _a2,
|
|
35851
|
+
var _a2, _b2, _c;
|
|
35852
|
+
const children = ((_a2 = buttons == null ? void 0 : buttons[key]) == null ? void 0 : _a2.type) == "input" ? null : (_b2 = params == null ? void 0 : params.row) == null ? void 0 : _b2[key];
|
|
35851
35853
|
return React3.cloneElement(buttons[key], {
|
|
35852
|
-
className: `${(
|
|
35853
|
-
children
|
|
35854
|
+
className: `${(_c = params == null ? void 0 : params.className) != null ? _c : ""} m-auto text-xs`,
|
|
35855
|
+
children,
|
|
35856
|
+
row: params == null ? void 0 : params.row,
|
|
35854
35857
|
onClick: async (e) => {
|
|
35855
|
-
var _a3,
|
|
35858
|
+
var _a3, _b3;
|
|
35856
35859
|
e.row = params == null ? void 0 : params.row;
|
|
35857
|
-
if ((
|
|
35860
|
+
if ((_b3 = (_a3 = buttons[key]) == null ? void 0 : _a3.props) == null ? void 0 : _b3.onClick) {
|
|
35858
35861
|
const newVal = await buttons[key].props.onClick(e);
|
|
35859
35862
|
if (newVal) handleRowUpdate({ ...e.row, newVal });
|
|
35860
35863
|
}
|
|
@@ -35867,9 +35870,10 @@ function useColumns(rows, currentCoin, options) {
|
|
|
35867
35870
|
cols.unshift({
|
|
35868
35871
|
field: "Modal",
|
|
35869
35872
|
headerName: "Modal",
|
|
35870
|
-
flex,
|
|
35873
|
+
// flex,
|
|
35871
35874
|
editable: false,
|
|
35872
35875
|
type: "string",
|
|
35876
|
+
width: 10,
|
|
35873
35877
|
renderCell: (params) => {
|
|
35874
35878
|
var _a;
|
|
35875
35879
|
return /* @__PURE__ */ jsx6(
|
|
@@ -35893,6 +35897,7 @@ function IHTable({
|
|
|
35893
35897
|
editableFields,
|
|
35894
35898
|
onSave,
|
|
35895
35899
|
onSelect,
|
|
35900
|
+
onCloseModal,
|
|
35896
35901
|
buttons,
|
|
35897
35902
|
exportName,
|
|
35898
35903
|
modal,
|
|
@@ -35903,7 +35908,8 @@ function IHTable({
|
|
|
35903
35908
|
footer = {},
|
|
35904
35909
|
currentCoin = "$",
|
|
35905
35910
|
fontSize = "1rem",
|
|
35906
|
-
className
|
|
35911
|
+
className,
|
|
35912
|
+
colSize
|
|
35907
35913
|
}) {
|
|
35908
35914
|
var _a;
|
|
35909
35915
|
if (modal && onSelect)
|
|
@@ -35924,6 +35930,8 @@ function IHTable({
|
|
|
35924
35930
|
setOpen(true);
|
|
35925
35931
|
};
|
|
35926
35932
|
const handleClose = () => {
|
|
35933
|
+
const pass = onCloseModal ? onCloseModal == null ? void 0 : onCloseModal(modalRow) : true;
|
|
35934
|
+
if (!pass) return;
|
|
35927
35935
|
setOpen(false);
|
|
35928
35936
|
setModalRow(void 0);
|
|
35929
35937
|
};
|
|
@@ -35944,15 +35952,20 @@ function IHTable({
|
|
|
35944
35952
|
}
|
|
35945
35953
|
return [];
|
|
35946
35954
|
}, [selectedRows, rows]);
|
|
35947
|
-
const columns = useColumns(
|
|
35948
|
-
|
|
35949
|
-
|
|
35950
|
-
|
|
35951
|
-
|
|
35952
|
-
|
|
35953
|
-
|
|
35954
|
-
|
|
35955
|
-
|
|
35955
|
+
const columns = useColumns(
|
|
35956
|
+
rows,
|
|
35957
|
+
currentCoin,
|
|
35958
|
+
{
|
|
35959
|
+
flex,
|
|
35960
|
+
editableFields,
|
|
35961
|
+
buttons: resolvedButtons,
|
|
35962
|
+
hideColumns,
|
|
35963
|
+
modal,
|
|
35964
|
+
handleRowUpdate,
|
|
35965
|
+
onModalOpen: handleModalOpen
|
|
35966
|
+
},
|
|
35967
|
+
colSize
|
|
35968
|
+
);
|
|
35956
35969
|
if (!rows.length) return null;
|
|
35957
35970
|
return /* @__PURE__ */ jsxs5("div", { className: "m-2", children: [
|
|
35958
35971
|
header && /* @__PURE__ */ jsx6("div", { className: "font-bold p-2 ", children: header }),
|
package/package.json
CHANGED
package/src/table/index.tsx
CHANGED
|
@@ -28,6 +28,7 @@ interface TableProps {
|
|
|
28
28
|
editableFields?: string[];
|
|
29
29
|
onSelect?: (data: GridValidRowModel[]) => void;
|
|
30
30
|
onSave?: (data: GridValidRowModel[]) => void;
|
|
31
|
+
onCloseModal?: (data: GridValidRowModel | undefined) => boolean;
|
|
31
32
|
buttons?: Record<string, any>;
|
|
32
33
|
exportName?: string;
|
|
33
34
|
modal?: React.ReactNode;
|
|
@@ -40,6 +41,7 @@ interface TableProps {
|
|
|
40
41
|
currentCoin?: string;
|
|
41
42
|
className?: string;
|
|
42
43
|
fontSize?: string;
|
|
44
|
+
colSize?: Record<string, number>;
|
|
43
45
|
[key: string]: any;
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -67,8 +69,8 @@ function EditIcon() {
|
|
|
67
69
|
fill="currentColor"
|
|
68
70
|
strokeWidth="0"
|
|
69
71
|
viewBox="0 0 576 512"
|
|
70
|
-
height="
|
|
71
|
-
width="
|
|
72
|
+
height="12px"
|
|
73
|
+
width="12px"
|
|
72
74
|
xmlns="http://www.w3.org/2000/svg"
|
|
73
75
|
>
|
|
74
76
|
<path d="M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z" />
|
|
@@ -166,11 +168,11 @@ interface ModalDialogProps {
|
|
|
166
168
|
|
|
167
169
|
function ModalDialog({ open, onClose, modal, selectedRow }: ModalDialogProps) {
|
|
168
170
|
return (
|
|
169
|
-
<Dialog open={open}
|
|
171
|
+
<Dialog open={open} maxWidth="xl" fullWidth>
|
|
170
172
|
<div className="flex justify-end">
|
|
171
173
|
<button
|
|
172
174
|
onClick={onClose}
|
|
173
|
-
className="
|
|
175
|
+
className=" font-bold p-1 m-5 w-[30px] h-[30px] flex items-center justify-center hover:animate-pulse border shadow rounded bg-red-500 text-white"
|
|
174
176
|
>
|
|
175
177
|
×
|
|
176
178
|
</button>
|
|
@@ -255,6 +257,7 @@ function useColumns(
|
|
|
255
257
|
handleRowUpdate: (row: GridRowModel) => GridRowModel;
|
|
256
258
|
onModalOpen: (row: GridValidRowModel) => void;
|
|
257
259
|
},
|
|
260
|
+
colSize?: Record<string, number>,
|
|
258
261
|
) {
|
|
259
262
|
const {
|
|
260
263
|
flex,
|
|
@@ -310,14 +313,19 @@ function useColumns(
|
|
|
310
313
|
|
|
311
314
|
return value;
|
|
312
315
|
},
|
|
313
|
-
flex,
|
|
316
|
+
flex: key == "id" ? false : !colSize?.[key],
|
|
317
|
+
width: key == "id" ? 80 : (colSize?.[key] ?? undefined),
|
|
314
318
|
editable: editableFields?.includes(key) ?? false,
|
|
315
319
|
type: typeof rows[0][key] === "number" ? "number" : "string",
|
|
316
320
|
renderCell: buttons?.[key]
|
|
317
|
-
? (params: any) =>
|
|
318
|
-
|
|
321
|
+
? (params: any) => {
|
|
322
|
+
const children =
|
|
323
|
+
buttons?.[key]?.type == "input" ? null : params?.row?.[key];
|
|
324
|
+
|
|
325
|
+
return React.cloneElement(buttons[key], {
|
|
319
326
|
className: `${params?.className ?? ""} m-auto text-xs`,
|
|
320
|
-
children
|
|
327
|
+
children,
|
|
328
|
+
row: params?.row,
|
|
321
329
|
onClick: async (e: TableButtonProps) => {
|
|
322
330
|
e.row = params?.row;
|
|
323
331
|
if (buttons[key]?.props?.onClick) {
|
|
@@ -326,7 +334,8 @@ function useColumns(
|
|
|
326
334
|
if (newVal) handleRowUpdate({ ...e.row, newVal });
|
|
327
335
|
}
|
|
328
336
|
},
|
|
329
|
-
})
|
|
337
|
+
});
|
|
338
|
+
}
|
|
330
339
|
: null,
|
|
331
340
|
}));
|
|
332
341
|
|
|
@@ -334,9 +343,10 @@ function useColumns(
|
|
|
334
343
|
cols.unshift({
|
|
335
344
|
field: "Modal",
|
|
336
345
|
headerName: "Modal",
|
|
337
|
-
flex,
|
|
346
|
+
// flex,
|
|
338
347
|
editable: false,
|
|
339
348
|
type: "string",
|
|
349
|
+
width: 10,
|
|
340
350
|
renderCell: (params: any) =>
|
|
341
351
|
(
|
|
342
352
|
<Button
|
|
@@ -362,6 +372,7 @@ function IHTable({
|
|
|
362
372
|
editableFields,
|
|
363
373
|
onSave,
|
|
364
374
|
onSelect,
|
|
375
|
+
onCloseModal,
|
|
365
376
|
buttons,
|
|
366
377
|
exportName,
|
|
367
378
|
modal,
|
|
@@ -373,6 +384,7 @@ function IHTable({
|
|
|
373
384
|
currentCoin = "$",
|
|
374
385
|
fontSize = "1rem",
|
|
375
386
|
className,
|
|
387
|
+
colSize,
|
|
376
388
|
}: TableProps) {
|
|
377
389
|
if (modal && onSelect)
|
|
378
390
|
throw new Error("Solo se puede usar modal o onSelect por separado");
|
|
@@ -397,6 +409,9 @@ function IHTable({
|
|
|
397
409
|
setOpen(true);
|
|
398
410
|
};
|
|
399
411
|
const handleClose = () => {
|
|
412
|
+
const pass = onCloseModal ? onCloseModal?.(modalRow) : true;
|
|
413
|
+
|
|
414
|
+
if (!pass) return;
|
|
400
415
|
setOpen(false);
|
|
401
416
|
setModalRow(undefined);
|
|
402
417
|
};
|
|
@@ -420,15 +435,20 @@ function IHTable({
|
|
|
420
435
|
return [];
|
|
421
436
|
}, [selectedRows, rows]);
|
|
422
437
|
|
|
423
|
-
const columns = useColumns(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
438
|
+
const columns = useColumns(
|
|
439
|
+
rows,
|
|
440
|
+
currentCoin,
|
|
441
|
+
{
|
|
442
|
+
flex,
|
|
443
|
+
editableFields,
|
|
444
|
+
buttons: resolvedButtons,
|
|
445
|
+
hideColumns,
|
|
446
|
+
modal,
|
|
447
|
+
handleRowUpdate,
|
|
448
|
+
onModalOpen: handleModalOpen,
|
|
449
|
+
},
|
|
450
|
+
colSize,
|
|
451
|
+
);
|
|
432
452
|
|
|
433
453
|
if (!rows.length) return null;
|
|
434
454
|
|