next-recomponents 2.0.29 → 2.0.30

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
@@ -112,6 +112,14 @@ interface TableProps {
112
112
  * - "comfortable" → padding generoso, fácil de leer
113
113
  */
114
114
  density?: GridDensity;
115
+ /**
116
+ * Cuando es true, el alto del contenedor se ajusta automáticamente
117
+ * al contenido de la tabla, eliminando el scroll vertical.
118
+ * Compatible con `wrapText` (filas de alto variable) y con
119
+ * cualquier valor de `density`. Cuando está activo, las props
120
+ * `height` y `HEIGHT_MAP` se ignoran.
121
+ */
122
+ autoHeight?: boolean;
115
123
  [key: string]: any;
116
124
  }
117
125
  declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -112,6 +112,14 @@ interface TableProps {
112
112
  * - "comfortable" → padding generoso, fácil de leer
113
113
  */
114
114
  density?: GridDensity;
115
+ /**
116
+ * Cuando es true, el alto del contenedor se ajusta automáticamente
117
+ * al contenido de la tabla, eliminando el scroll vertical.
118
+ * Compatible con `wrapText` (filas de alto variable) y con
119
+ * cualquier valor de `density`. Cuando está activo, las props
120
+ * `height` y `HEIGHT_MAP` se ignoran.
121
+ */
122
+ autoHeight?: boolean;
115
123
  [key: string]: any;
116
124
  }
117
125
  declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -36084,7 +36084,8 @@ function IHTable({
36084
36084
  rowHeight,
36085
36085
  wrapText = false,
36086
36086
  density = "standard",
36087
- searchable = false
36087
+ searchable = false,
36088
+ autoHeight = false
36088
36089
  }) {
36089
36090
  var _a;
36090
36091
  if (modal && onSelect)
@@ -36149,6 +36150,8 @@ function IHTable({
36149
36150
  );
36150
36151
  if (!rows.length) return null;
36151
36152
  const rowHeightProps = wrapText ? { getRowHeight: () => "auto" } : rowHeight != null ? { rowHeight } : {};
36153
+ const containerHeight = autoHeight ? void 0 : (_a = HEIGHT_MAP[displayRows.length]) != null ? _a : height;
36154
+ const hideFooter = autoHeight || displayRows.length <= Object.keys(HEIGHT_MAP).length;
36152
36155
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "m-2", children: [
36153
36156
  header && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-bold p-2 ", children: header }),
36154
36157
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex justify-between", children: [
@@ -36170,7 +36173,8 @@ function IHTable({
36170
36173
  sx: {
36171
36174
  display: "flex",
36172
36175
  flexDirection: "column",
36173
- height: (_a = HEIGHT_MAP[displayRows.length]) != null ? _a : height,
36176
+ // undefined height lets the child DataGrid size itself freely
36177
+ height: containerHeight,
36174
36178
  width,
36175
36179
  zIndex: 999999999
36176
36180
  },
@@ -36191,6 +36195,7 @@ function IHTable({
36191
36195
  rows: displayRows,
36192
36196
  columns,
36193
36197
  density,
36198
+ autoHeight,
36194
36199
  checkboxSelection: Boolean(onSelect),
36195
36200
  rowSelectionModel: selectedRows,
36196
36201
  onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
@@ -36232,7 +36237,7 @@ function IHTable({
36232
36237
  editMode: "row",
36233
36238
  processRowUpdate: handleRowUpdate,
36234
36239
  pageSizeOptions: [5, 10],
36235
- hideFooter: displayRows.length <= Object.keys(HEIGHT_MAP).length
36240
+ hideFooter
36236
36241
  }
36237
36242
  )
36238
36243
  ]
package/dist/index.mjs CHANGED
@@ -36064,7 +36064,8 @@ function IHTable({
36064
36064
  rowHeight,
36065
36065
  wrapText = false,
36066
36066
  density = "standard",
36067
- searchable = false
36067
+ searchable = false,
36068
+ autoHeight = false
36068
36069
  }) {
36069
36070
  var _a;
36070
36071
  if (modal && onSelect)
@@ -36129,6 +36130,8 @@ function IHTable({
36129
36130
  );
36130
36131
  if (!rows.length) return null;
36131
36132
  const rowHeightProps = wrapText ? { getRowHeight: () => "auto" } : rowHeight != null ? { rowHeight } : {};
36133
+ const containerHeight = autoHeight ? void 0 : (_a = HEIGHT_MAP[displayRows.length]) != null ? _a : height;
36134
+ const hideFooter = autoHeight || displayRows.length <= Object.keys(HEIGHT_MAP).length;
36132
36135
  return /* @__PURE__ */ jsxs5("div", { className: "m-2", children: [
36133
36136
  header && /* @__PURE__ */ jsx6("div", { className: "font-bold p-2 ", children: header }),
36134
36137
  /* @__PURE__ */ jsxs5("div", { className: "flex justify-between", children: [
@@ -36150,7 +36153,8 @@ function IHTable({
36150
36153
  sx: {
36151
36154
  display: "flex",
36152
36155
  flexDirection: "column",
36153
- height: (_a = HEIGHT_MAP[displayRows.length]) != null ? _a : height,
36156
+ // undefined height lets the child DataGrid size itself freely
36157
+ height: containerHeight,
36154
36158
  width,
36155
36159
  zIndex: 999999999
36156
36160
  },
@@ -36171,6 +36175,7 @@ function IHTable({
36171
36175
  rows: displayRows,
36172
36176
  columns,
36173
36177
  density,
36178
+ autoHeight,
36174
36179
  checkboxSelection: Boolean(onSelect),
36175
36180
  rowSelectionModel: selectedRows,
36176
36181
  onRowSelectionModelChange: !modal ? setSelectedRows : void 0,
@@ -36212,7 +36217,7 @@ function IHTable({
36212
36217
  editMode: "row",
36213
36218
  processRowUpdate: handleRowUpdate,
36214
36219
  pageSizeOptions: [5, 10],
36215
- hideFooter: displayRows.length <= Object.keys(HEIGHT_MAP).length
36220
+ hideFooter
36216
36221
  }
36217
36222
  )
36218
36223
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.29",
3
+ "version": "2.0.30",
4
4
  "description": "description nueva",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -70,6 +70,14 @@ interface TableProps {
70
70
  * - "comfortable" → padding generoso, fácil de leer
71
71
  */
72
72
  density?: GridDensity;
73
+ /**
74
+ * Cuando es true, el alto del contenedor se ajusta automáticamente
75
+ * al contenido de la tabla, eliminando el scroll vertical.
76
+ * Compatible con `wrapText` (filas de alto variable) y con
77
+ * cualquier valor de `density`. Cuando está activo, las props
78
+ * `height` y `HEIGHT_MAP` se ignoran.
79
+ */
80
+ autoHeight?: boolean;
73
81
  [key: string]: any;
74
82
  }
75
83
 
@@ -500,6 +508,7 @@ function IHTable({
500
508
  wrapText = false,
501
509
  density = "standard",
502
510
  searchable = false,
511
+ autoHeight = false,
503
512
  }: TableProps) {
504
513
  if (modal && onSelect)
505
514
  throw new Error("Solo se puede usar modal o onSelect por separado");
@@ -576,13 +585,30 @@ function IHTable({
576
585
 
577
586
  if (!rows.length) return null;
578
587
 
579
- // When wrapText is active we must use getRowHeight; rowHeight prop is ignored.
588
+ // ─── Row height props ──────────────────────────────────────────────────────
589
+ // Priority: wrapText always wins (variable row height).
590
+ // autoHeight delegates height control to MUI; rowHeight prop is still
591
+ // respected when neither wrapText nor autoHeight forces auto sizing.
580
592
  const rowHeightProps = wrapText
581
593
  ? { getRowHeight: () => "auto" as const }
582
594
  : rowHeight != null
583
595
  ? { rowHeight }
584
596
  : {};
585
597
 
598
+ // ─── Container height ──────────────────────────────────────────────────────
599
+ // When autoHeight is active the Box must NOT constrain the height so that
600
+ // MUI's own autoHeight can expand the grid to fit all rows without scroll.
601
+ // We still honour HEIGHT_MAP for small datasets when autoHeight is off,
602
+ // falling back to the explicit `height` prop for larger ones.
603
+ const containerHeight = autoHeight
604
+ ? undefined // let MUI decide
605
+ : (HEIGHT_MAP[displayRows.length] ?? height);
606
+
607
+ // Whether to hide MUI's built-in pagination footer.
608
+ // With autoHeight all rows are visible, so pagination is never needed.
609
+ const hideFooter =
610
+ autoHeight || displayRows.length <= Object.keys(HEIGHT_MAP).length;
611
+
586
612
  return (
587
613
  <div className="m-2">
588
614
  {header && <div className="font-bold p-2 ">{header}</div>}
@@ -603,7 +629,8 @@ function IHTable({
603
629
  sx={{
604
630
  display: "flex",
605
631
  flexDirection: "column",
606
- height: HEIGHT_MAP[displayRows.length] ?? height,
632
+ // undefined height lets the child DataGrid size itself freely
633
+ height: containerHeight,
607
634
  width,
608
635
  zIndex: 999999999,
609
636
  }}
@@ -622,6 +649,9 @@ function IHTable({
622
649
  rows={displayRows}
623
650
  columns={columns as any}
624
651
  density={density}
652
+ // MUI's native autoHeight prop — renders all rows and sizes the
653
+ // grid to fit them, regardless of density or wrapText.
654
+ autoHeight={autoHeight}
625
655
  checkboxSelection={Boolean(onSelect)}
626
656
  rowSelectionModel={selectedRows}
627
657
  onRowSelectionModelChange={!modal ? setSelectedRows : undefined}
@@ -663,7 +693,7 @@ function IHTable({
663
693
  editMode="row"
664
694
  processRowUpdate={handleRowUpdate}
665
695
  pageSizeOptions={[5, 10]}
666
- hideFooter={displayRows.length <= Object.keys(HEIGHT_MAP).length}
696
+ hideFooter={hideFooter}
667
697
  />
668
698
  </Box>
669
699
  <CustomFooter footer={footer} rows={displayRows} />