Data view
vig-data-view
import { DataView, DataViewItem } from '@vigdx/ui/data-view';Basic
items and an ng-template vigDataViewItem ; bind the same items to vigDataViewItemOf so let-product is typed. Each item renders in an <li> of a <ul role="list"> .
- $65.00
Bamboo watch
Accessories
- $72.00
Black watch
Accessories
- $79.00
Blue band
Fitness
- $29.00
Blue T-shirt
Clothing
List and grid
[(layout)] is list or grid ; layoutToggle adds a list/grid vig-select-button to the header, next to any [vigDataViewHeader] content. The template gets layout in its context. The grid fills columns of at least --vig-data-view-item-min-width (15rem) and drops to one column in a narrow container; items stretch to the row height, so cards line up.
Accessories
Bamboo watch
Accessories
$65.00
Black watch
Accessories
$72.00
Bracelet
Accessories
$15.00
Brown purse
Accessories
$120.00
Chakra bracelet
Accessories
$32.00
Galaxy earrings
Accessories
$34.00
Layout: grid
Sorting and paging
sort is typed against the items: { by: (item) => value } (empty values first, numbers and dates numerically, text by the locale's collator) or { compare: (a, b) => number } , with direction asc or desc ; sorting is stable. A new sort goes back to the first page and, with a label , is announced once with the item count. paginator adds a vig-paginator ( true , or { position, rowsPerPageOptions, jumpToPage, size } ), named by labels.paginatorAriaLabel ("Item pages"), bound to [(first)] and [(rows)] . itemId keeps each item's element across sorts and new arrays.
Bamboo watch
5 / 5$65.00Black watch
4 / 5$72.00Blue band
3 / 5$79.00Blue T-shirt
5 / 5$29.00Bracelet
4 / 5$15.00
Empty and loading
vig-empty-state (heading labels.emptyLabel ), or your ng-template vigDataViewEmpty . loading shows skeleton placeholders (a page's worth with the paginator, at most 12, else 3), or one vigDataViewLoading template per placeholder, and disables the paginator.
Bamboo watch
Accessories
Black watch
Accessories
Blue band
Fitness
Server-side paging
Set totalRecords to the server's count: items is then the page at first and is shown as given. Load from the bound models, e.g. with a resource whose params read first() and rows(), and set loading while a page is on its way. Sort on the server too: in this mode sort only describes the order of items and is not applied again, but a new sort still goes back to the first page and is announced, with totalRecords as the count, once the page has loaded.
Every item on the page is rendered: there is no virtual scrolling. Page long lists, or show very long ones in vig-table with virtualScroll.
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="data-view"][data-part="header"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="data-view"]
| Part | Element | data-state |
|---|---|---|
header | [vigDataViewHeader] content and the layout toggle. | — |
layout-toggle | vig-select-button ; style its [data-scope="select-button"] parts. | — |
status | — | |
list | <ul role="list"> of the items, as a list or a grid. | — |
item | <li> around an item template. | — |
empty | vigDataViewEmpty template. | — |
loading | loading ). | — |
placeholder | vigDataViewLoading placeholder. | — |
paginator | vig-paginator ( paginator ); style its own parts. | — |
Accessibility
- Items render as a list in both layouts (
role="list"keeps list semantics in Safari, which drops them for unstyled lists), so screen readers announce the count and each position. Give items a heading of the right level for the page and real controls: the data view adds no keyboard handling of its own, so Tab moves through the items' controls. - The layout toggle is a radio group named "Layout" (
labels.layoutAriaLabel); its options carry visually hidden text next to the icons. - Sorting moves the existing elements (tracked by
itemId), keeping focus inside an item. A sort with alabelis announced once through a polite status ("Sorted by Price, low to high"), and so isloading; the placeholders are hidden from screen readers.
API
DataView
vig-data-viewItems of any type rendered through your own template, as a list or a responsive grid, with optional sorting, paging, a layout toggle, an empty state and loading placeholders.
Example :<vig-data-view [items]="products" [(layout)]="layout" layoutToggle paginator>
<ng-template vigDataViewItem [vigDataViewItemOf]="products" let-product>
<h3>{{ product.name }}</h3>
</ng-template>
</vig-data-view>Items render in a <ul role="list">, one <li> each, in both layouts;
headings and controls inside an item are the template's. The grid fills
columns of at least --vig-data-view-item-min-width (15rem), one column
on a narrow container. sort orders the items in memory; paginator
shows a vig-paginator and pages them, or — with totalRecords — shows
items as the current page of a server-side list, whose first and
rows you load from. Every item is rendered: page long lists, or use
vig-table's virtual scrolling for very long ones.
| Name | Type | Default | Description |
|---|---|---|---|
first | number | 0 | Zero-based index of the first item on the page. |
itemId | ((item: T) => unknown) | undefined | undefined | Identity of an item, so its element survives sorting and new arrays; the item itself by default. |
items | readonly T[] | [] | The items. With |
labels | Partial<DataViewLabels> | — | Texts (i18n); locale defaults. |
layout | DataViewLayout | 'list' |
|
layoutToggle | boolean | false | Shows a list/grid toggle in the header. |
loading | boolean | false | Shows placeholders instead of the items, and a "Loading" status. |
paginator | DataViewPaginatorOptions | null | null | Pages the items with a |
rows | number | 10 | Page size. |
sort | DataViewSort<T> | null | undefined | undefined | The order of the items: an accessor ( |
totalRecords | number | undefined | undefined | Total count of a server-side list: |
| Name | Payload | Description |
|---|---|---|
firstChange | number | Zero-based index of the first item on the page. |
layoutChange | DataViewLayout |
|
rowsChange | number | Page size. |
DataViewItem
ng-template[vigDataViewItem]Renders each item of vig-data-view; layout in the context tells list
from grid. Bind the items to vigDataViewItemOf to type let-item:
<ng-template vigDataViewItem [vigDataViewItemOf]="products" let-product let-layout="layout">
…
</ng-template>| Name | Type | Default | Description |
|---|---|---|---|
vigDataViewItemOf | readonly T[] | null | undefined | undefined | Type-only: the items the template renders, so |
Templates and directives
| Selector | Export | Description |
|---|---|---|
ng-template[vigDataViewEmpty] | DataViewEmpty | Replaces the default empty state of |
ng-template[vigDataViewLoading] | DataViewLoading | One loading placeholder of |
[vigDataViewHeader] | DataViewHeader | Marks projected content (a heading, a sort select) for the data view's header row. |