View Options
The Display popover of a collection: layout, grouping, ordering on several levels, Show switches and visible properties, reported as one plain value.
c2-view-options is the Display button of Linear, Notion and GitHub Projects. Its panel chooses the layout, what the collection is grouped and sub-grouped by, how it is ordered (one level per row, Add sort for more), which kinds of items it includes and which properties each item shows. Filtering is not part of it: pair it with c2-filter-builder.
The component holds no data and draws no items. It edits one value, { layout, groupBy, subGroupBy, orderBy, show, properties }, and fires view-change with the whole value after every edit. Your app applies it to whatever renders the collection, so how an item looks stays entirely yours. orderBy is c2-table’s own sortModel, groupBy feeds its group-by, and properties maps onto its columns’ hidden.
Describe the fields with c2-view-field children (groupable, orderable, property say where each one is offered) or with a fields array, which replaces the children and shares id, label and icon with c2-filter-builder’s fields. The Show switches are c2-view-toggle children or a toggles array. layouts lists the layout ids; list, board, table, gallery, calendar and timeline come with an icon, and on a board Grouping and Sub-grouping read Columns and Rows. max-sorts caps the ordering levels (3 by default, 1 for a single sort).
The component stores nothing. Keep value wherever your app keeps settings. With default-value set, Reset returns to it and the host matches :state(changed) while the value differs; can-set-default adds Set as default, which fires default-request and leaves saving to you.
Import
import '@c2n/components/view-options'