Skip to content

feat: add Table control - #47

Merged
AdamMusa merged 2 commits into
mainfrom
feat/table
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
mainfrom
feat/table

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Adds the Ruby side of Table and its TableRow child type (Work Package F, item F5).

Engine counterpart (renderer): AdamMusa/ruflet-engine#33

Usage

table(border_color: "outlineVariant", cell_padding: 8,
      column_widths: { 0 => { type: "flex", value: 2 }, 2 => { type: "fixed", value: 80 } },
      rows: items.map { |i| table_row([text(i.name), text(i.qty.to_s), text(money(i.total))]) })

table(default_vertical_alignment: "middle") do
  table_row(bgcolor: "surfaceVariant") do
    text("Item")
    text("Qty")
  end
  table_row { text("Apple"); text("3") }
end

API

  • controls/shared/table_control.rb: TableControl, TYPE table, WIRE Table.
    • KEYWORDS: border_color border_radius border_width cell_padding column_widths controls default_column_width default_vertical_alignment inner_borders rows plus the common layout keywords.
    • Events: on_animation_end, on_size_change.
  • controls/shared/tablerow_control.rb: TableRowControl, TYPE tablerow, WIRE TableRow.
    • KEYWORDS: bgcolor controls data key visible.
  • CLASS_MAP has table, table_row and tablerow in the shared and top-level registries.
  • DSL helpers table(rows = nil, **props, &block), table_row(children = nil, **props, &block) and tablerow are in material_control_methods.rb, shared_control_forwarders.rb and dsl.rb.
    • Block children of table are sent as controls; Dart reads rows, then controls.
    • table_row children are its cells.
  • column_widths integer keys are serialized as strings ("0"), which Dart parses. The Ruby side sends no defaults.

Notes for review

  • Because ruflet_rails turns every CLASS_MAP key into a view helper, Rails views gain table, table_row and tablerow helpers.
    • table emits a <table> tag, which the HTML transformer already maps with its own HTML-table builder, so plain HTML tables behave as before.
    • ruflet_rails tests pass unchanged.
  • Kernel#table is private, like every other forwarder, so it does not change respond_to?.

Tests

  • New test/table_compatibility_test.rb (6 runs). It covers:
    • _c, rows, nested cells, row bgcolor, column_widths key stringification, and every keyword;
    • block children for table and table_row;
    • Ruflet.control(:table), :table_row, the tablerow alias and the Ruflet::DSL helpers;
    • no defaults are sent;
    • layout event handlers;
    • unknown keywords and events raise for both classes.
  • verify_pr.sh with RUBY_PKGS="ruflet_core ruflet_rails": ruflet_core 146/146 files, 624 runs; ruflet_rails 15/15 files, 278 runs. The engine pair passes too (+732 tests, analyze clean). The wire-key audit shows 0 new findings.

Add table, table_row and tablerow helpers with the Table and TableRow wire types. Block children of table become rows; table_row children are its cells.
@AdamMusa
AdamMusa merged commit 6a11ead into main Oct 29, 2026
5 checks passed
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.

1 participant