next-recomponents 2.0.23 → 2.0.24

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
@@ -84,6 +84,7 @@ interface TableProps {
84
84
  currentCoin?: string;
85
85
  className?: string;
86
86
  fontSize?: string;
87
+ colSize?: Record<string, number>;
87
88
  [key: string]: any;
88
89
  }
89
90
  declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -84,6 +84,7 @@ interface TableProps {
84
84
  currentCoin?: string;
85
85
  className?: string;
86
86
  fontSize?: string;
87
+ colSize?: Record<string, number>;
87
88
  [key: string]: any;
88
89
  }
89
90
  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: "20px",
35719
- width: "20px",
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
  }
@@ -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,19 @@ function useColumns(rows, currentCoin, options) {
35863
35863
  }
35864
35864
  return value;
35865
35865
  },
35866
- flex,
35867
- editable: (_a = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _a : false,
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, _b;
35871
+ var _a2, _b2;
35871
35872
  return import_react4.default.cloneElement(buttons[key], {
35872
35873
  className: `${(_a2 = params == null ? void 0 : params.className) != null ? _a2 : ""} m-auto text-xs`,
35873
- children: (_b = params == null ? void 0 : params.row) == null ? void 0 : _b[key],
35874
+ children: (_b2 = params == null ? void 0 : params.row) == null ? void 0 : _b2[key],
35874
35875
  onClick: async (e) => {
35875
- var _a3, _b2;
35876
+ var _a3, _b3;
35876
35877
  e.row = params == null ? void 0 : params.row;
35877
- if ((_b2 = (_a3 = buttons[key]) == null ? void 0 : _a3.props) == null ? void 0 : _b2.onClick) {
35878
+ if ((_b3 = (_a3 = buttons[key]) == null ? void 0 : _a3.props) == null ? void 0 : _b3.onClick) {
35878
35879
  const newVal = await buttons[key].props.onClick(e);
35879
35880
  if (newVal) handleRowUpdate({ ...e.row, newVal });
35880
35881
  }
@@ -35887,9 +35888,10 @@ function useColumns(rows, currentCoin, options) {
35887
35888
  cols.unshift({
35888
35889
  field: "Modal",
35889
35890
  headerName: "Modal",
35890
- flex,
35891
+ // flex,
35891
35892
  editable: false,
35892
35893
  type: "string",
35894
+ width: 10,
35893
35895
  renderCell: (params) => {
35894
35896
  var _a;
35895
35897
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -35923,7 +35925,8 @@ function IHTable({
35923
35925
  footer = {},
35924
35926
  currentCoin = "$",
35925
35927
  fontSize = "1rem",
35926
- className
35928
+ className,
35929
+ colSize
35927
35930
  }) {
35928
35931
  var _a;
35929
35932
  if (modal && onSelect)
@@ -35964,15 +35967,20 @@ function IHTable({
35964
35967
  }
35965
35968
  return [];
35966
35969
  }, [selectedRows, rows]);
35967
- const columns = useColumns(rows, currentCoin, {
35968
- flex,
35969
- editableFields,
35970
- buttons: resolvedButtons,
35971
- hideColumns,
35972
- modal,
35973
- handleRowUpdate,
35974
- onModalOpen: handleModalOpen
35975
- });
35970
+ const columns = useColumns(
35971
+ rows,
35972
+ currentCoin,
35973
+ {
35974
+ flex,
35975
+ editableFields,
35976
+ buttons: resolvedButtons,
35977
+ hideColumns,
35978
+ modal,
35979
+ handleRowUpdate,
35980
+ onModalOpen: handleModalOpen
35981
+ },
35982
+ colSize
35983
+ );
35976
35984
  if (!rows.length) return null;
35977
35985
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "m-2", children: [
35978
35986
  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: "20px",
35699
- width: "20px",
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
  }
@@ -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,19 @@ function useColumns(rows, currentCoin, options) {
35843
35843
  }
35844
35844
  return value;
35845
35845
  },
35846
- flex,
35847
- editable: (_a = editableFields == null ? void 0 : editableFields.includes(key)) != null ? _a : false,
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, _b;
35851
+ var _a2, _b2;
35851
35852
  return React3.cloneElement(buttons[key], {
35852
35853
  className: `${(_a2 = params == null ? void 0 : params.className) != null ? _a2 : ""} m-auto text-xs`,
35853
- children: (_b = params == null ? void 0 : params.row) == null ? void 0 : _b[key],
35854
+ children: (_b2 = params == null ? void 0 : params.row) == null ? void 0 : _b2[key],
35854
35855
  onClick: async (e) => {
35855
- var _a3, _b2;
35856
+ var _a3, _b3;
35856
35857
  e.row = params == null ? void 0 : params.row;
35857
- if ((_b2 = (_a3 = buttons[key]) == null ? void 0 : _a3.props) == null ? void 0 : _b2.onClick) {
35858
+ if ((_b3 = (_a3 = buttons[key]) == null ? void 0 : _a3.props) == null ? void 0 : _b3.onClick) {
35858
35859
  const newVal = await buttons[key].props.onClick(e);
35859
35860
  if (newVal) handleRowUpdate({ ...e.row, newVal });
35860
35861
  }
@@ -35867,9 +35868,10 @@ function useColumns(rows, currentCoin, options) {
35867
35868
  cols.unshift({
35868
35869
  field: "Modal",
35869
35870
  headerName: "Modal",
35870
- flex,
35871
+ // flex,
35871
35872
  editable: false,
35872
35873
  type: "string",
35874
+ width: 10,
35873
35875
  renderCell: (params) => {
35874
35876
  var _a;
35875
35877
  return /* @__PURE__ */ jsx6(
@@ -35903,7 +35905,8 @@ function IHTable({
35903
35905
  footer = {},
35904
35906
  currentCoin = "$",
35905
35907
  fontSize = "1rem",
35906
- className
35908
+ className,
35909
+ colSize
35907
35910
  }) {
35908
35911
  var _a;
35909
35912
  if (modal && onSelect)
@@ -35944,15 +35947,20 @@ function IHTable({
35944
35947
  }
35945
35948
  return [];
35946
35949
  }, [selectedRows, rows]);
35947
- const columns = useColumns(rows, currentCoin, {
35948
- flex,
35949
- editableFields,
35950
- buttons: resolvedButtons,
35951
- hideColumns,
35952
- modal,
35953
- handleRowUpdate,
35954
- onModalOpen: handleModalOpen
35955
- });
35950
+ const columns = useColumns(
35951
+ rows,
35952
+ currentCoin,
35953
+ {
35954
+ flex,
35955
+ editableFields,
35956
+ buttons: resolvedButtons,
35957
+ hideColumns,
35958
+ modal,
35959
+ handleRowUpdate,
35960
+ onModalOpen: handleModalOpen
35961
+ },
35962
+ colSize
35963
+ );
35956
35964
  if (!rows.length) return null;
35957
35965
  return /* @__PURE__ */ jsxs5("div", { className: "m-2", children: [
35958
35966
  header && /* @__PURE__ */ jsx6("div", { className: "font-bold p-2 ", children: header }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.23",
3
+ "version": "2.0.24",
4
4
  "description": "description nueva",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,6 +40,7 @@ interface TableProps {
40
40
  currentCoin?: string;
41
41
  className?: string;
42
42
  fontSize?: string;
43
+ colSize?: Record<string, number>;
43
44
  [key: string]: any;
44
45
  }
45
46
 
@@ -67,8 +68,8 @@ function EditIcon() {
67
68
  fill="currentColor"
68
69
  strokeWidth="0"
69
70
  viewBox="0 0 576 512"
70
- height="20px"
71
- width="20px"
71
+ height="12px"
72
+ width="12px"
72
73
  xmlns="http://www.w3.org/2000/svg"
73
74
  >
74
75
  <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" />
@@ -255,6 +256,7 @@ function useColumns(
255
256
  handleRowUpdate: (row: GridRowModel) => GridRowModel;
256
257
  onModalOpen: (row: GridValidRowModel) => void;
257
258
  },
259
+ colSize?: Record<string, number>,
258
260
  ) {
259
261
  const {
260
262
  flex,
@@ -310,7 +312,8 @@ function useColumns(
310
312
 
311
313
  return value;
312
314
  },
313
- flex,
315
+ flex: key == "id" ? false : !colSize?.[key],
316
+ width: key == "id" ? 80 : (colSize?.[key] ?? undefined),
314
317
  editable: editableFields?.includes(key) ?? false,
315
318
  type: typeof rows[0][key] === "number" ? "number" : "string",
316
319
  renderCell: buttons?.[key]
@@ -334,9 +337,10 @@ function useColumns(
334
337
  cols.unshift({
335
338
  field: "Modal",
336
339
  headerName: "Modal",
337
- flex,
340
+ // flex,
338
341
  editable: false,
339
342
  type: "string",
343
+ width: 10,
340
344
  renderCell: (params: any) =>
341
345
  (
342
346
  <Button
@@ -373,6 +377,7 @@ function IHTable({
373
377
  currentCoin = "$",
374
378
  fontSize = "1rem",
375
379
  className,
380
+ colSize,
376
381
  }: TableProps) {
377
382
  if (modal && onSelect)
378
383
  throw new Error("Solo se puede usar modal o onSelect por separado");
@@ -420,15 +425,20 @@ function IHTable({
420
425
  return [];
421
426
  }, [selectedRows, rows]);
422
427
 
423
- const columns = useColumns(rows, currentCoin, {
424
- flex,
425
- editableFields,
426
- buttons: resolvedButtons,
427
- hideColumns,
428
- modal,
429
- handleRowUpdate,
430
- onModalOpen: handleModalOpen,
431
- });
428
+ const columns = useColumns(
429
+ rows,
430
+ currentCoin,
431
+ {
432
+ flex,
433
+ editableFields,
434
+ buttons: resolvedButtons,
435
+ hideColumns,
436
+ modal,
437
+ handleRowUpdate,
438
+ onModalOpen: handleModalOpen,
439
+ },
440
+ colSize,
441
+ );
432
442
 
433
443
  if (!rows.length) return null;
434
444