tabler-react-2 0.1.154 → 0.1.155

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.
@@ -14,6 +14,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
14
14
  // TableV2.jsx
15
15
  // TanStack Table v8 styled like the Original component's Tabler look.
16
16
  // Adds `dense` mode for a compact layout.
17
+ // Supports null/empty cells without layout shift via placeholder rendering.
17
18
  // Controlled (server-side) pagination & sorting. ES modules, named exports, arrow functions only.
18
19
 
19
20
  /** Small utilities */
@@ -136,7 +137,13 @@ var TableV2 = exports.TableV2 = function TableV2(_ref5) {
136
137
  _ref5$showPagination = _ref5.showPagination,
137
138
  showPagination = _ref5$showPagination === void 0 ? true : _ref5$showPagination,
138
139
  _ref5$pageSizeOptions = _ref5.pageSizeOptions,
139
- pageSizeOptions = _ref5$pageSizeOptions === void 0 ? [10, 25, 50, 100] : _ref5$pageSizeOptions;
140
+ pageSizeOptions = _ref5$pageSizeOptions === void 0 ? [10, 25, 50, 100] : _ref5$pageSizeOptions,
141
+ _ref5$emptyCellPlaceh = _ref5.emptyCellPlaceholder,
142
+ emptyCellPlaceholder = _ref5$emptyCellPlaceh === void 0 ? "" : _ref5$emptyCellPlaceh,
143
+ _ref5$treatEmptyStrin = _ref5.treatEmptyStringAsNull,
144
+ treatEmptyStringAsNull = _ref5$treatEmptyStrin === void 0 ? false : _ref5$treatEmptyStrin,
145
+ _ref5$fixedLayout = _ref5.fixedLayout,
146
+ fixedLayout = _ref5$fixedLayout === void 0 ? true : _ref5$fixedLayout;
140
147
  var table = (0, _reactTable.useReactTable)({
141
148
  data: data,
142
149
  columns: columns,
@@ -184,6 +191,25 @@ var TableV2 = exports.TableV2 = function TableV2(_ref5) {
184
191
  state: sortState || false
185
192
  }));
186
193
  };
194
+
195
+ // Helper: render a stable placeholder for empty cells
196
+ var renderCellContent = function renderCellContent(cell) {
197
+ var _cell$getValue;
198
+ // Prefer the raw value to detect emptiness; custom renderers still run for non-empty values
199
+ var raw = (_cell$getValue = cell.getValue) === null || _cell$getValue === void 0 ? void 0 : _cell$getValue.call(cell);
200
+ var isEmpty = raw === null || raw === undefined || treatEmptyStringAsNull && raw === "";
201
+ if (isEmpty) {
202
+ // Use an invisible placeholder to keep height without adding visual noise.
203
+ // Wrap in inline-block so the cell keeps a minimal box even in dense mode.
204
+ return /*#__PURE__*/_react["default"].createElement("span", {
205
+ className: "d-inline-block",
206
+ "aria-label": "empty"
207
+ }, /*#__PURE__*/_react["default"].createElement("span", {
208
+ className: "opacity-0"
209
+ }, emptyCellPlaceholder));
210
+ }
211
+ return (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext());
212
+ };
187
213
  var content = (0, _react.useMemo)(function () {
188
214
  if (!loading && data.length === 0) {
189
215
  return /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", {
@@ -199,17 +225,20 @@ var TableV2 = exports.TableV2 = function TableV2(_ref5) {
199
225
  return /*#__PURE__*/_react["default"].createElement("td", {
200
226
  key: cell.id,
201
227
  className: [cell.column.columnDef.className || "", dense ? "py-1" : ""].filter(Boolean).join(" ")
202
- }, (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext()));
228
+ }, renderCellContent(cell));
203
229
  }));
204
230
  });
205
- }, [data, loading, emptyState, table, dense]);
231
+ }, [data, loading, emptyState, table, dense, treatEmptyStringAsNull, emptyCellPlaceholder]);
206
232
  var total = totalRows !== null && totalRows !== void 0 ? totalRows : 0;
207
233
  return /*#__PURE__*/_react["default"].createElement("div", {
208
234
  className: parentClassName
209
235
  }, /*#__PURE__*/_react["default"].createElement("div", {
210
236
  className: "table-responsive ".concat(nowrap ? "table-nowrap" : "", " ").concat(className)
211
237
  }, /*#__PURE__*/_react["default"].createElement("table", {
212
- className: ["table table-vcenter", stickyHeader ? "sticky-top" : "", dense ? "table-sm" : "", tableClassName].filter(Boolean).join(" ")
238
+ className: ["table table-vcenter", stickyHeader ? "sticky-top" : "", dense ? "table-sm" : "", tableClassName].filter(Boolean).join(" "),
239
+ style: fixedLayout ? {
240
+ tableLayout: "fixed"
241
+ } : undefined
213
242
  }, /*#__PURE__*/_react["default"].createElement("thead", null, table.getHeaderGroups().map(function (hg) {
214
243
  return /*#__PURE__*/_react["default"].createElement("tr", {
215
244
  key: hg.id
@@ -305,13 +334,16 @@ TableV2.propTypes = {
305
334
  loading: _propTypes["default"].bool,
306
335
  showPagination: _propTypes["default"].bool,
307
336
  pageSizeOptions: _propTypes["default"].arrayOf(_propTypes["default"].number),
308
- dense: _propTypes["default"].bool // <<< NEW
337
+ dense: _propTypes["default"].bool,
338
+ emptyCellPlaceholder: _propTypes["default"].node,
339
+ treatEmptyStringAsNull: _propTypes["default"].bool,
340
+ fixedLayout: _propTypes["default"].bool
309
341
  };
310
342
 
311
343
  /** Usage (server-side)
312
344
  *
313
345
  * <TableV2
314
- * dense // compact mode
346
+ * dense
315
347
  * columns={columns}
316
348
  * data={data}
317
349
  * totalRows={total}
@@ -324,5 +356,9 @@ TableV2.propTypes = {
324
356
  * loading={loading}
325
357
  * nowrap
326
358
  * stickyHeader
359
+ * // NEW props for null-safe cells:
360
+ * emptyCellPlaceholder="—"
361
+ * treatEmptyStringAsNull
362
+ * fixedLayout
327
363
  * />
328
364
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.154",
3
+ "version": "0.1.155",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {