@helpwave/hightide 0.1.12 → 0.1.13

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.
@@ -23,9 +23,9 @@ type TableProps<T> = {
23
23
  initialState?: Omit<InitialTableState, 'columnSizing' | 'columnSizingInfo'>;
24
24
  className?: string;
25
25
  onRowClick?: (row: Row<T>, table: Table$1<T>) => void;
26
- state: Omit<TableState, 'columnSizing' | 'columnSizingInfo'>;
26
+ state?: Omit<TableState, 'columnSizing' | 'columnSizingInfo'>;
27
27
  tableClassName?: string;
28
- } & Partial<TableOptions<T>>;
28
+ } & TableOptions<T>;
29
29
  /**
30
30
  * The standard table
31
31
  */
@@ -23,9 +23,9 @@ type TableProps<T> = {
23
23
  initialState?: Omit<InitialTableState, 'columnSizing' | 'columnSizingInfo'>;
24
24
  className?: string;
25
25
  onRowClick?: (row: Row<T>, table: Table$1<T>) => void;
26
- state: Omit<TableState, 'columnSizing' | 'columnSizingInfo'>;
26
+ state?: Omit<TableState, 'columnSizing' | 'columnSizingInfo'>;
27
27
  tableClassName?: string;
28
- } & Partial<TableOptions<T>>;
28
+ } & TableOptions<T>;
29
29
  /**
30
30
  * The standard table
31
31
  */
@@ -710,7 +710,7 @@ var Pagination = ({
710
710
  };
711
711
 
712
712
  // src/components/table/Table.tsx
713
- var import_clsx9 = __toESM(require("clsx"));
713
+ var import_clsx10 = __toESM(require("clsx"));
714
714
  var import_react_table = require("@tanstack/react-table");
715
715
 
716
716
  // src/util/array.ts
@@ -1143,8 +1143,18 @@ var useResizeCallbackWrapper = (callback) => {
1143
1143
  }, [callback]);
1144
1144
  };
1145
1145
 
1146
- // src/components/table/Table.tsx
1146
+ // src/components/table/TableCell.tsx
1147
+ var import_clsx9 = require("clsx");
1147
1148
  var import_jsx_runtime11 = require("react/jsx-runtime");
1149
+ var TableCell = ({
1150
+ children,
1151
+ className
1152
+ }) => {
1153
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: (0, import_clsx9.clsx)("block max-w-full overflow-ellipsis truncate", className), children });
1154
+ };
1155
+
1156
+ // src/components/table/Table.tsx
1157
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1148
1158
  var Table = ({
1149
1159
  data,
1150
1160
  fillerRow,
@@ -1262,6 +1272,9 @@ var Table = ({
1262
1272
  defaultColumn: {
1263
1273
  minSize: 60,
1264
1274
  maxSize: 700,
1275
+ cell: ({ cell }) => {
1276
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableCell, { children: cell.getValue() });
1277
+ },
1265
1278
  ...defaultColumn
1266
1279
  },
1267
1280
  columns,
@@ -1345,18 +1358,18 @@ var Table = ({
1345
1358
  }
1346
1359
  return colSizes;
1347
1360
  }, [table.getState().columnSizingInfo, table.getState().columnSizing]);
1348
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ref, className: (0, import_clsx9.default)("col gap-y-4", className), children: [
1349
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_custom_scrollbars_2.Scrollbars, { autoHeight: true, autoHeightMax: tableRef.current?.offsetHeight, autoHide: true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1361
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ref, className: (0, import_clsx10.default)("col gap-y-4", className), children: [
1362
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_custom_scrollbars_2.Scrollbars, { autoHeight: true, autoHeightMax: tableRef.current?.offsetHeight, autoHide: true, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1350
1363
  "table",
1351
1364
  {
1352
1365
  ref: tableRef,
1353
- className: (0, import_clsx9.default)(tableClassName),
1366
+ className: (0, import_clsx10.default)(tableClassName),
1354
1367
  style: {
1355
1368
  ...columnSizeVars,
1356
1369
  width: Math.max(table.getTotalSize(), ref.current?.offsetWidth ?? table.getTotalSize())
1357
1370
  },
1358
1371
  children: [
1359
- table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("colgroup", { children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1372
+ table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("colgroup", { children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1360
1373
  "col",
1361
1374
  {
1362
1375
  style: {
@@ -1367,22 +1380,22 @@ var Table = ({
1367
1380
  },
1368
1381
  header.id
1369
1382
  )) }, headerGroup.id)),
1370
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("thead", { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tr", { className: table.options.meta?.headerRowClassName, children: headerGroup.headers.map((header) => {
1371
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1383
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: table.options.meta?.headerRowClassName, children: headerGroup.headers.map((header) => {
1384
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1372
1385
  "th",
1373
1386
  {
1374
1387
  colSpan: header.colSpan,
1375
- className: (0, import_clsx9.default)("relative group", header.column.columnDef.meta?.className),
1388
+ className: (0, import_clsx10.default)("relative group", header.column.columnDef.meta?.className),
1376
1389
  children: [
1377
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "row w-full", children: header.isPlaceholder ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "row gap-x-1 items-center", children: [
1378
- header.column.getCanSort() && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1390
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "row w-full", children: header.isPlaceholder ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "row gap-x-1 items-center", children: [
1391
+ header.column.getCanSort() && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1379
1392
  TableSortButton,
1380
1393
  {
1381
1394
  sortDirection: header.column.getIsSorted(),
1382
1395
  onClick: () => header.column.toggleSorting()
1383
1396
  }
1384
1397
  ),
1385
- header.column.getCanFilter() && header.column.columnDef.meta?.filterType ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1398
+ header.column.getCanFilter() && header.column.columnDef.meta?.filterType ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1386
1399
  TableFilterButton,
1387
1400
  {
1388
1401
  column: header.column,
@@ -1394,7 +1407,7 @@ var Table = ({
1394
1407
  header.getContext()
1395
1408
  )
1396
1409
  ] }) }),
1397
- header.column.getCanResize() && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1410
+ header.column.getCanResize() && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1398
1411
  "div",
1399
1412
  {
1400
1413
  onMouseDown: header.getResizeHandler(),
@@ -1413,25 +1426,25 @@ var Table = ({
1413
1426
  header.id
1414
1427
  );
1415
1428
  }) }, headerGroup.id)) }),
1416
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tbody", { children: [
1429
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("tbody", { children: [
1417
1430
  table.getRowModel().rows.map((row) => {
1418
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tr", { onClick: () => onRowClick(row, table), className: table.options.meta?.bodyRowClassName, children: row.getVisibleCells().map((cell) => {
1419
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { children: (0, import_react_table.flexRender)(
1431
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { onClick: () => onRowClick(row, table), className: table.options.meta?.bodyRowClassName, children: row.getVisibleCells().map((cell) => {
1432
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { children: (0, import_react_table.flexRender)(
1420
1433
  cell.column.columnDef.cell,
1421
1434
  cell.getContext()
1422
1435
  ) }, cell.id);
1423
1436
  }) }, row.id);
1424
1437
  }),
1425
1438
  range(table.getState().pagination.pageSize - table.getRowModel().rows.length, { allowEmptyRange: true }).map((row, index) => {
1426
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tr", { children: columns.map((column) => {
1427
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { children: fillerRow ? fillerRow(column.id, table) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FillerRowElement, {}) }, column.id);
1439
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { children: columns.map((column) => {
1440
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { children: fillerRow ? fillerRow(column.id, table) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FillerRowElement, {}) }, column.id);
1428
1441
  }) }, "filler-row-" + index);
1429
1442
  })
1430
1443
  ] })
1431
1444
  ]
1432
1445
  }
1433
1446
  ) }),
1434
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "row justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1447
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "row justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1435
1448
  Pagination,
1436
1449
  {
1437
1450
  pageIndex: table.getState().pagination.pageIndex,
@@ -1446,7 +1459,7 @@ var TableUncontrolled = ({ data, ...props }) => {
1446
1459
  (0, import_react14.useEffect)(() => {
1447
1460
  setUsedData(data);
1448
1461
  }, [data]);
1449
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1462
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1450
1463
  Table,
1451
1464
  {
1452
1465
  ...props,
@@ -1469,7 +1482,7 @@ var TableWithSelection = ({
1469
1482
  {
1470
1483
  id: selectionRowId,
1471
1484
  header: ({ table }) => {
1472
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1485
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1473
1486
  Checkbox,
1474
1487
  {
1475
1488
  checked: table.getIsSomeRowsSelected() ? "indeterminate" : table.getIsAllRowsSelected(),
@@ -1482,7 +1495,7 @@ var TableWithSelection = ({
1482
1495
  );
1483
1496
  },
1484
1497
  cell: ({ row }) => {
1485
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1498
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1486
1499
  Checkbox,
1487
1500
  {
1488
1501
  disabled: !row.getCanSelect(),
@@ -1501,15 +1514,15 @@ var TableWithSelection = ({
1501
1514
  ...columns
1502
1515
  ];
1503
1516
  }, [columns, selectionRowId]);
1504
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1517
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1505
1518
  Table,
1506
1519
  {
1507
1520
  columns: columnsWithSelection,
1508
1521
  fillerRow: (columnId, table) => {
1509
1522
  if (columnId === selectionRowId) {
1510
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Checkbox, { checked: false, disabled: true, containerClassName: "max-w-6" });
1523
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Checkbox, { checked: false, disabled: true, containerClassName: "max-w-6" });
1511
1524
  }
1512
- return fillerRow ? fillerRow(columnId, table) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FillerRowElement, {});
1525
+ return fillerRow ? fillerRow(columnId, table) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FillerRowElement, {});
1513
1526
  },
1514
1527
  state: {
1515
1528
  rowSelection,