Skip to content

feat(data_table): Hotwire-first DataTable component family#353

Open
djalmaaraujo wants to merge 5 commits intomainfrom
da-datatable-hotwire
Open

feat(data_table): Hotwire-first DataTable component family#353
djalmaaraujo wants to merge 5 commits intomainfrom
da-datatable-hotwire

Conversation

@djalmaaraujo
Copy link
Copy Markdown
Contributor

@djalmaaraujo djalmaaraujo commented Mar 21, 2026

Summary

WhatsApp.Video.2026-04-24.at.17.06.57.mp4

Adds a server-first DataTable component family to the gem. Same surface as PR ruby-ui/web#457 but at the source-of-truth layer. 14 components, 3 Stimulus controllers, 3 pagination adapters, docs view, tests.

  • 14 new components under `lib/ruby_ui/data_table/`
  • 3 Stimulus controllers (root selection+expand delegator, column visibility, debounced search)
  • 3 pagination adapters (Manual, Pagy, Kaminari — duck-typed, no gem deps)
  • Form-first bulk actions: row checkboxes are ``, bulk submit buttons use HTML5 `form=` + `formaction=`
  • Tests via ComponentTest + Phlex::Kit
  • dependencies.yml entry added

Companion PR

Docs site wiring: ruby-ui/web#457

@djalmaaraujo djalmaaraujo force-pushed the da-datatable-hotwire branch from 99af161 to 9b18785 Compare March 22, 2026 00:20
@djalmaaraujo djalmaaraujo changed the title feat: DataTable component with Hotwire (sorting, filtering, pagination) [Feature] DataTable component with Hotwire (sorting, filtering, pagination) Mar 22, 2026
@konung
Copy link
Copy Markdown

konung commented Mar 30, 2026

Nice exactly what I was looking for - instead of using datatables/grid.js

Ports the complete DataTable component family from the web repo:
- DataTable (Turbo Frame wrapper + data-controller)
- DataTableBulkActions, DataTableToolbar, DataTablePaginationBar
- DataTableForm (CSRF-aware form wrapper)
- DataTableSearch (debounced GET form via Stimulus)
- DataTablePerPageSelect (requestSubmit on change)
- DataTableSelectAllCheckbox, DataTableRowCheckbox
- DataTableSelectionSummary
- DataTableSortHead (server-side sort links with inline SVG icons)
- DataTableColumnToggle (client-side visibility via DropdownMenu)
- DataTableExpandToggle (accessible row expand button)
- DataTablePagination (windowed page links + adapter resolution)

Three Stimulus controllers: ruby-ui--data-table (selection + expand
delegate), ruby-ui--data-table-column-visibility, ruby-ui--data-table-search
(debounced input with focus-restore across Turbo Frame swaps).

Inline SVGs replace view_context.lucide_icon calls (chevron-up/down,
chevrons-up-down, chevron-right, chevron-down). CGI::escape replaces
ActiveSupport's to_query and Hash#except replaces reject-based exclusion.
Three duck-typed adapters exposing current_page, total_pages, total_count,
and per_page. No runtime gem dependencies: Manual takes raw integers,
Pagy wraps a pagy object (pages/items), Kaminari wraps a collection
(total_pages/limit_value). A custom adapter (with:) is also supported.
Covers: server-driven sort/search/pagination, selection + bulk actions,
column visibility toggle, and expandable rows. Uses static sample rows
(no backend dependency) following the accordion_docs pattern.
Converted from ActiveSupport::TestCase to ComponentTest: test blocks to
def test_* methods, assert_no_match to refute_match (no ActiveSupport),
plain "TEXT" to "TEXT" string literals in Phlex blocks, render_component
to phlex { RubyUI.X(...) }. Adapter tests require their subjects explicitly
since the test_helper glob only autoloads top-level RubyUI:: constants.

157 runs, 656 assertions, 0 failures, 0 errors.
Lists component dependencies: Table, Checkbox, NativeSelect, Pagination,
DropdownMenu, Input, Button.
@djalmaaraujo djalmaaraujo force-pushed the da-datatable-hotwire branch from 3b26f02 to d89170c Compare April 24, 2026 21:13
@djalmaaraujo djalmaaraujo changed the title [Feature] DataTable component with Hotwire (sorting, filtering, pagination) feat(data_table): Hotwire-first DataTable component family Apr 24, 2026
@djalmaaraujo djalmaaraujo marked this pull request as ready for review April 24, 2026 21:21
@djalmaaraujo djalmaaraujo requested a review from cirdes as a code owner April 24, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants