Skip to content

Releases

v0.6.1

Choose a tag to compare

@anthony-liddle anthony-liddle released this 27 Oct 17:44
9593c13

A patch for the minor findings from the 0.5.1 and 0.6.0 reviews. No API changes.

Fixed

  • A negative or non-finite total, such as an API's -1 for unknown, counts as no total: the footer shows the page's own range and leaves out "Page N of M". 0.5.1 read a negative total as one page, while the range still said "Showing 0-0 of -5 results". A total that arrives as a numeric string, as node-postgres returns count(*), still counts as its number.
  • A table where every column is pinned (alwaysVisible) no longer shows a settings button that opens an empty panel.
  • In a table rendered into a popout window or an iframe, a drag now ends when you release the mouse anywhere in that window, and it clears text selection there rather than in the main page. Before, a release off the rows left the drag active, and a later release on a row selected a range.
  • The column id warning names a column without a header by its position ("column 4.1"), and reports an id that isn't a string as "Not a string" instead of "Missing".

Docs

  • A Shift range or a drag calls onToggleRow once for each row it changes, in a single event. If you keep the selection in your own state, update it from its previous value (setSelected(prev => ...)). useTableSelection already does.
  • usePagination enables Next from the total, so it needs the real one. With an unknown total, use useCursorPagination for a cursor API, or build the pagination prop yourself.

v0.6.0

Choose a tag to compare

@anthony-liddle anthony-liddle released this 25 Oct 17:56
4a60a4e

Pinned columns that stay pinned, dark sections that reach into menus, and a keyboard path for range selection. No breaking API changes; two visible ones, under Changed.

New

  • Shift+click a row checkbox, or press Shift+Space on a focused one, to set every row from the last checkbox you toggled to the same state. Disabled rows are skipped.

Fixed

  • alwaysVisible columns are pinned: they can't be hidden or moved, and they stay out of the column panel, with single or grouped headers. Reordering the other columns leaves pinned ones where they are.
  • A layout saved before a column was pinned, or by 0.5.1's panel, no longer moves a pinned column or hides it. onVisibleColumnsChange always reports pinned columns as visible.
  • The column panel lists columns in the table's current order, including after a restored layout.
  • .dark on the table's own element switches it to the dark defaults, as on an ancestor.
  • Menus and the column panel copy .dark from the table's section when they open, so they no longer render light inside a dark page section.

Changed

  • Every menu item is 32px tall (plain items were 48px, link items 44px), and every label sits 0.5rem from its icon (link items, submenu triggers and submenu items had 1rem). Open menus look shorter.
  • Table and pagination text take the theme's foreground colour, so text in a .dark section stays readable without a theme. A color you set on a wrapper or on body no longer reaches the cells or a standalone Pagination; set it on .rdt-table or .rdt-pagination, or through --foreground.

Docs

  • Clickable rows: rows don't take focus, so put a link in the row's main cell for keyboard and screen reader users and keep onRowClick as the mouse shortcut. The new Clickable Rows story shows it.

v0.5.1

Choose a tag to compare

@anthony-liddle anthony-liddle released this 24 Oct 22:15
5aedcad

A patch for the minor findings from the 0.5.0 reviews.

Fixed

  • The expand chevron's hit area covers its whole cell. A click beside the chevron toggles the row instead of firing onRowClick. With selectOnRowClick, a click in that cell's padding now toggles the row rather than selecting it.
  • Row clicks count in a table that your React renders into an iframe.
  • A table without a total keeps its page range while loading, instead of reading "Showing 0-0".
  • A negative total reads as one page.
  • Persisted filters ignore stored values that aren't their own strings.

New

  • DataTable logs one console.error when column ids are missing or repeated, since those silently break saved layouts and the column panel. It's the package's first console output, so a test setup that fails on console errors will now flag tables with duplicate ids.

v0.5.0

Choose a tag to compare

@anthony-liddle anthony-liddle released this 24 Oct 16:49
7932b5c

0.5.0 is the last round of breaking changes before the API settles. Every change, with what to do, is in MIGRATION.md.

New

  • Multi-column sort, opt-in with useTableSort({ multiSort: true }). Shift+click a header to add it as the next sort key, or press Shift+Enter or Shift+Space on a focused header. While two or more columns are sorted, each header shows its place, and screen readers hear it ("sort priority 2, descending").
  • Row expansion with a real button. renderExpandedRow adds a leading expand column with a disclosure button per row. It works by keyboard and screen reader, with aria-expanded and aria-controls. The table keeps the open rows itself, or you hold them with useTableExpansion. expandOnRowClick toggles a row from a click anywhere on it.
  • One persistence scheme. Give the table and its hooks the same persistKey.
    • URL params are namespaced (members.sort=name,-team&members.page=3), so two persisted tables can share a page, and a copied link reproduces the view it came from.
    • Storage keys are versioned (rdt:1:members:sort).
    • Restoring never causes a hydration mismatch, and every hook returns isRestored.
  • Pagination without a total, for cursor APIs. Leave totalCount out, and the footer shows the page's range while Next follows hasNextPage.
  • Every accessible name is translatable. labels now covers every string the table announces, and each row menu is named after its row.

Breaking

  • TableColumn.id is required, and getColumnId is gone.
  • sort is { sortBy, onSort }, and useTableSort returns it as it is.
  • useTableSelection returns the selection prop as it is.
  • usePagination, useCursorPagination and usePersistedFilters take or return options objects.
  • renderExpandedRow returns content only.
  • Persistence keys and URL params changed, and 0.4 saved state is ignored.
  • Several renames and removals:
    • callbackAction is now onSelect.
    • The column className is now headerClassName, and its rowClassName is now cellClassName.
    • PaginationClient is now Pagination.
    • page and of are now pageOf.
    • --drag-selection is now --rdt-drag-selection.
    • SortOrder and uppercase sort directions are gone.

See MIGRATION.md for the full list.

Fixed

  • Choosing a plain action-menu item with Enter or Space closed the menu without running it.
  • Clicks on a row's controls (its checkbox, links, buttons) also fired onRowClick.
  • Without an action menu, each row's last cell spanned two columns. With an action menu, the empty and expanded rows counted one column too many.
  • Checkbox ids repeated across tables, and a page element with the same id as a column could take over that column's label in the panel.

v0.4.0

Choose a tag to compare

@anthony-liddle anthony-liddle released this 23 Oct 21:48
8244600

The table ships its own CSS. Tailwind is no longer needed, every element the table renders has a documented rdt- class, and the stylesheet comes as an unlayered and a layered copy. This is a breaking release; the steps below take a 0.3.0 app across.

Upgrading from 0.3.0

1. Swap the Tailwind wiring for the layered stylesheet

0.3.0 needed your Tailwind to scan the package. Remove that line:

@source "../node_modules/@anthony-liddle/react-data-table/dist"; /* delete */

Then load the layered copy from your CSS entry, after a line that orders the layers, in place of the styles.css import:

@layer theme, base, react-data-table, components, utilities;
@import "tailwindcss";
@import "@anthony-liddle/react-data-table/styles.layer.css";

With Tailwind, use the layered copy, not styles.css. Tailwind's utilities live in a layer, and an unlayered stylesheet beats every layer, so with styles.css a utility you pass through className (a column's text-right, PaginationClient's px-4) would lose to the table's own rules. Import it from CSS rather than JavaScript so the order line always comes first: a layer used before it is ordered sinks below preflight, and the table loses its padding and borders.

Apps without Tailwind or cascade layers keep the single import, import '@anthony-liddle/react-data-table/styles.css'.

2. Check your theme tokens

0.3.0 declared default tokens on :root as bare HSL triplets (--card: 0 0% 100%). 0.4.0 declares none. It reads each token as a full colour and falls back to its own default when you haven't set one.

  • A current shadcn/ui theme (full colours such as --card: oklch(1 0 0)) works as it is.
  • A theme written as triplets: change the values and your own reads together. Write each value as a full colour (--card: hsl(0 0% 100%)), and change every hsl(var(--card)) in your CSS to var(--card), including a Tailwind @theme inline mapping (--color-card: var(--card)). Changing only the values gives hsl(hsl(...)), which is invalid, and every colour that reads the token breaks.
  • No theme of your own, but your app's CSS used the tokens the package declared: they are gone, so declare them yourself. The 0.3.0 defaults, as full colours, are listed in the package's .storybook/preview.css.
  • --drag-selection follows the same rule: 216 100% 58.4% becomes hsl(216 100% 58.4%).

3. Update anything that targets the old classes

0.3.0 0.4.0
.data-table-con .rdt-table
.data-table .rdt-table__table
.data-table-sticky .rdt-table__cell--sticky, .rdt-table__header-cell--sticky, .rdt-sort-header--sticky
.data-table-no-highlight .rdt-table__cell--actions, .rdt-table__expanded-row
.drag-selection-range, -start, -end data-drag-range, data-drag-start, data-drag-end on .rdt-table__row
.drag-selection-dragging data-dragging on .rdt-table__table
.table-row-selected, .modal-table, .data-table-tight, .data-table-no-auto-hover Removed. The package never applied them.

The components no longer carry Tailwind utility classes. The README's Styling section lists every class, state attribute and custom property.

4. If you call useTableDragSelection yourself

getRowClassName(rowIndex) is replaced by getRowDragState(rowIndex), which returns { inRange, isStart, isEnd }, plus an isDragActive flag. DataTable turns these into attributes for you.

Also new

  • styles.layer.css, the same rules inside @layer react-data-table.
  • Custom properties: --rdt-radius, --rdt-font-size, --rdt-header-font-size, --rdt-cell-padding-x, --rdt-cell-padding-y, --rdt-row-selected and --rdt-skeleton. Set them on :root, on any ancestor, or on one row through rowClassName.
  • Selected rows are marked by a 3px bar in the primary colour on their first cell, and carry data-selected. Set --rdt-row-selected to tint them as well.
  • The stylesheet sets everything its own parts rely on, so a global button rule or a CSS reset no longer changes the table's controls.
  • clsx, tailwind-merge, class-variance-authority and @radix-ui/react-slot are no longer dependencies.

Fixes

  • Expanded rows get the light muted tint their markup asked for, and no longer take the row hover highlight.
  • Submenu borders use the border colour, matching the main menu, instead of the text colour.
  • Alignment classes on a column take effect in its cells and in its sortable header. The package's own rules used to beat them.

Full change: #12

v0.3.0

Choose a tag to compare

@anthony-liddle anthony-liddle released this 23 Oct 18:58
412e8c2

The hooks no longer assume a GraphQL API, and the Storybook no longer plays its interactions when a story opens.

Breaking changes

usePagination is page-based

usePagination(pageSize) returns the offset and limit for the current page. Send them to your API, or slice an array with them. getPagination(totalCount) builds DataTable's pagination prop from the total, which usually arrives with the page you fetched:

const { offset, limit, getPagination, reset } = usePagination(25);
const { items, total } = useMembers({ offset, limit });

<DataTable columns={columns} data={items} pagination={getPagination(total)} />;

Call reset() when the sort or filters change. On the last page, Next does nothing.

The cursor hook for GraphQL connection queries works the same as before, under a new name:

  • usePagination(n) is now useCursorPagination(n)
  • PaginationInput is now CursorPaginationInput

useTableSort reports lowercase directions

direction is now 'asc' or 'desc' instead of 'ASC' or 'DESC'. Inputs accept both cases: defaultSortDirection, setSortDirection, and the sort prop all take either, so SortOrder values still work going in. If your API wants uppercase, send direction?.toUpperCase().

Saved sorts carry over. The URL and localStorage already stored lowercase.

Storybook

Opening a story no longer runs its interaction test, so tables stay still until you use them. The tests now live on hidden twin stories and still run in CI, with axe checking every visible story.

Full change: #11

v0.2.0

Choose a tag to compare

@anthony-liddle anthony-liddle released this 23 Oct 15:39
2fb83fe

Added

  • getRowLabel on DataTable. getRowLabel?: (row) => string names each row's selection checkbox "Select ⟨label⟩", so a screen reader hears "Select Ada Yilmaz" instead of a raw id. Without it, the name falls back to "Select row ⟨id⟩", as in 0.1.0, so this is not a breaking change.

    <DataTable columns={columns} data={members} selection={selection} getRowLabel={row => row.name} />

Other changes

  • Docs: README props table and accessibility notes for getRowLabel; punctuation-only fixes in source comments.
  • Tooling (no effect on the published package): vite 8, happy-dom 21, Storybook 10.6.2, Vitest 5.0.5, and a CI guard against em dashes. Runtime dependency ranges are unchanged.
npm install @anthony-liddle/react-data-table@0.2.0

Storybook: https://anthony-liddle.github.io/react-data-table/ (see Features › Row Selection for both the labelled and id-fallback checkboxes).

Published from CI through npm trusted publishing, with provenance.

v0.1.0

Choose a tag to compare

@anthony-liddle anthony-liddle released this 23 Oct 02:50
8877418

First public release of @anthony-liddle/react-data-table.

A data-dense React table:

  • sorting, with keyboard-operable headers and aria-sort
  • grouped columns
  • row and drag selection
  • column management (show, hide, and reorder by mouse or keyboard)
  • pagination
  • URL + localStorage persistence
npm install @anthony-liddle/react-data-table

Storybook: https://anthony-liddle.github.io/react-data-table/

Published from CI through npm trusted publishing, with provenance.