Macaw.Builtin.Table (macaw v0.6.0)

Copy Markdown View Source

The built-in table (spec/05 §6.1), "macaw.table": an HTML <table> of whole rows, of kind :content, :pure.

  • parameters: caption (text, "Table"); identity (text, ""), the field naming each row, "" for rows that can't be selected; sort (text, "", bindable), the field rows are sorted by; order ("asc" or "desc", bindable); first (number, 0, bindable), the first row a live table's range shows; remove (text, ""), the words of each row's remove control, "" for none;
  • declarations: one slot, rows, whose optional columns role names the fields shown, in order (any type, many), when unbound every column in the delivered table's order (Macaw.Data.Table.names/1: name order for rows given as maps); events "sort", "select", "range" and "remove"; default actions on sort setting sort and order from the event's value, so it sorts with no declarations, and on range setting first; it writes selection as an identity; it observes :activate and :select; reading load :scan;
  • budget: the rows its declared height shows at 32 px a row, times four, at least 10;
  • range: in :live, the rows its height shows and an overscan of half as many on each side, from its first row, the rest counted by an empty <tbody class="mw-gap" data-mw-gap="N"> before and after them; its range event's default action sets first, which its request never reads, so moving it fetches nothing;
  • markup: a capped or stale table draws its notice above its rows; a caption, a header of scoped <th> each holding a real button that emits sort with the next sort as its value (%{"sort" => field, "order" => next}, "desc" on the column sorted ascending, else "asc"), the sorted column's aria-sort, a row per delivered row sorted when sort names a column (nil last, ties in delivered order), and with an identity field a select button in each row's first cell and the row's id from its identity; handed a selection in its context (spec/03 §1.7.7), the row holding it mw-selected with aria-current, every other mw-muted; with an identity and remove words, each row ends in a cell holding its remove control (spec/05 §6.8), a button emitting remove with the row's identity as its value, its accessible name the words and the identity ("Remove Hyacinth"), or with no socket and the host's links a POST form sending the same event; none where the core says the viewer may not change the rows;
  • keyed rows: a table's render is Macaw.Builtin.Table.Rows, its head, each row as {key, version, markup}, its tail and its scope, safe HTML that flattens to the markup above in every mode, each row keyed by its identity's spelling, else its position in the delivery, so a runtime placing rows by key sends only the rows that changed, and versioned by its chunk's version, its place there and its mark, so a runtime can keep a row's markup by scope and version; handed the rows its runtime holds (macaw_component's held assign), a row held by the render's scope and its version takes the held markup and isn't drawn, the bytes unchanged (#465);
  • stylesheet: stylesheet/0, served at stylesheet_path/0, its content address.

Summary

Functions

The table's one static stylesheet: the table, its caption, cells, header and select buttons, the sorted column's mark and the selected and muted rows, every color a theme custom property with the default theme's value as its fallback. It loads and imports nothing.

The stylesheet's path, its content address (Macaw.Component.Stylesheet.path/1).

Functions

stylesheet()

@spec stylesheet() :: String.t()

The table's one static stylesheet: the table, its caption, cells, header and select buttons, the sorted column's mark and the selected and muted rows, every color a theme custom property with the default theme's value as its fallback. It loads and imports nothing.

stylesheet_path()

@spec stylesheet_path() :: String.t()

The stylesheet's path, its content address (Macaw.Component.Stylesheet.path/1).