next-recomponents 2.0.24 → 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 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;
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;
package/dist/index.js CHANGED
@@ -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, onClose, maxWidth: "xl", fullWidth: true, children: [
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: "text-gray-500 hover:text-gray-800 text-xl font-bold p-5",
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
  ) }),
@@ -35868,10 +35868,12 @@ function useColumns(rows, currentCoin, options, colSize) {
35868
35868
  editable: (_b = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _b : false,
35869
35869
  type: typeof rows[0][key] === "number" ? "number" : "string",
35870
35870
  renderCell: (buttons == null ? void 0 : buttons[key]) ? (params) => {
35871
- var _a2, _b2;
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];
35872
35873
  return import_react4.default.cloneElement(buttons[key], {
35873
- className: `${(_a2 = params == null ? void 0 : params.className) != null ? _a2 : ""} m-auto text-xs`,
35874
- children: (_b2 = params == null ? void 0 : params.row) == null ? void 0 : _b2[key],
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,
35875
35877
  onClick: async (e) => {
35876
35878
  var _a3, _b3;
35877
35879
  e.row = params == null ? void 0 : params.row;
@@ -35915,6 +35917,7 @@ function IHTable({
35915
35917
  editableFields,
35916
35918
  onSave,
35917
35919
  onSelect,
35920
+ onCloseModal,
35918
35921
  buttons,
35919
35922
  exportName,
35920
35923
  modal,
@@ -35947,6 +35950,8 @@ function IHTable({
35947
35950
  setOpen(true);
35948
35951
  };
35949
35952
  const handleClose = () => {
35953
+ const pass = onCloseModal ? onCloseModal == null ? void 0 : onCloseModal(modalRow) : true;
35954
+ if (!pass) return;
35950
35955
  setOpen(false);
35951
35956
  setModalRow(void 0);
35952
35957
  };
package/dist/index.mjs CHANGED
@@ -35754,12 +35754,12 @@ function CustomFooter({
35754
35754
  }) });
35755
35755
  }
35756
35756
  function ModalDialog({ open, onClose, modal, selectedRow }) {
35757
- return /* @__PURE__ */ jsxs5(Dialog, { open, onClose, maxWidth: "xl", fullWidth: true, children: [
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: "text-gray-500 hover:text-gray-800 text-xl font-bold p-5",
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
  ) }),
@@ -35848,10 +35848,12 @@ function useColumns(rows, currentCoin, options, colSize) {
35848
35848
  editable: (_b = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _b : false,
35849
35849
  type: typeof rows[0][key] === "number" ? "number" : "string",
35850
35850
  renderCell: (buttons == null ? void 0 : buttons[key]) ? (params) => {
35851
- var _a2, _b2;
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];
35852
35853
  return React3.cloneElement(buttons[key], {
35853
- className: `${(_a2 = params == null ? void 0 : params.className) != null ? _a2 : ""} m-auto text-xs`,
35854
- children: (_b2 = params == null ? void 0 : params.row) == null ? void 0 : _b2[key],
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,
35855
35857
  onClick: async (e) => {
35856
35858
  var _a3, _b3;
35857
35859
  e.row = params == null ? void 0 : params.row;
@@ -35895,6 +35897,7 @@ function IHTable({
35895
35897
  editableFields,
35896
35898
  onSave,
35897
35899
  onSelect,
35900
+ onCloseModal,
35898
35901
  buttons,
35899
35902
  exportName,
35900
35903
  modal,
@@ -35927,6 +35930,8 @@ function IHTable({
35927
35930
  setOpen(true);
35928
35931
  };
35929
35932
  const handleClose = () => {
35933
+ const pass = onCloseModal ? onCloseModal == null ? void 0 : onCloseModal(modalRow) : true;
35934
+ if (!pass) return;
35930
35935
  setOpen(false);
35931
35936
  setModalRow(void 0);
35932
35937
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.24",
3
+ "version": "2.0.25",
4
4
  "description": "description nueva",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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;
@@ -167,11 +168,11 @@ interface ModalDialogProps {
167
168
 
168
169
  function ModalDialog({ open, onClose, modal, selectedRow }: ModalDialogProps) {
169
170
  return (
170
- <Dialog open={open} onClose={onClose} maxWidth="xl" fullWidth>
171
+ <Dialog open={open} maxWidth="xl" fullWidth>
171
172
  <div className="flex justify-end">
172
173
  <button
173
174
  onClick={onClose}
174
- className="text-gray-500 hover:text-gray-800 text-xl font-bold p-5"
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"
175
176
  >
176
177
  &times;
177
178
  </button>
@@ -317,10 +318,14 @@ function useColumns(
317
318
  editable: editableFields?.includes(key) ?? false,
318
319
  type: typeof rows[0][key] === "number" ? "number" : "string",
319
320
  renderCell: buttons?.[key]
320
- ? (params: any) =>
321
- React.cloneElement(buttons[key], {
321
+ ? (params: any) => {
322
+ const children =
323
+ buttons?.[key]?.type == "input" ? null : params?.row?.[key];
324
+
325
+ return React.cloneElement(buttons[key], {
322
326
  className: `${params?.className ?? ""} m-auto text-xs`,
323
- children: params?.row?.[key],
327
+ children,
328
+ row: params?.row,
324
329
  onClick: async (e: TableButtonProps) => {
325
330
  e.row = params?.row;
326
331
  if (buttons[key]?.props?.onClick) {
@@ -329,7 +334,8 @@ function useColumns(
329
334
  if (newVal) handleRowUpdate({ ...e.row, newVal });
330
335
  }
331
336
  },
332
- })
337
+ });
338
+ }
333
339
  : null,
334
340
  }));
335
341
 
@@ -366,6 +372,7 @@ function IHTable({
366
372
  editableFields,
367
373
  onSave,
368
374
  onSelect,
375
+ onCloseModal,
369
376
  buttons,
370
377
  exportName,
371
378
  modal,
@@ -402,6 +409,9 @@ function IHTable({
402
409
  setOpen(true);
403
410
  };
404
411
  const handleClose = () => {
412
+ const pass = onCloseModal ? onCloseModal?.(modalRow) : true;
413
+
414
+ if (!pass) return;
405
415
  setOpen(false);
406
416
  setModalRow(undefined);
407
417
  };