CustomView
A screen an app draws itself over a view (ADR 0019): Genesis loads the view's data with its scope, filters, URL state, live updates and permissions, and draws loading, empty and error; the app draws the rest. ```tsx <CustomView view={playersView} sort={{ field: "points", order: "desc" }} perPage={10} live> {({ rows, reducedMotion }) => <Leaderboard players={rows} animate={!reducedMotion} />} </CustomView> ``` Parts: `custom-view` (with `data-view-type` and `data-state`), `custom-view-loading`, `custom-view-empty` and `custom-view-error`. An app's own parts inside are named `app-…`.
packages/ui/src/components/data/resource-view/CustomView.tsx
@marktiderman/genesis-ui/dataimport { CustomView } from "@marktiderman/genesis-ui/data";react-docgen-typescript.useCustomView
A custom view's data and states, headless (ADR 0019). `<CustomView>` calls it and draws the states; call it yourself only to draw them yourself too, and the doctor's `custom-view-states` rule will ask why.
| Prop | Type | Default | Description |
|---|---|---|---|
| view* | ResourceView<ResourceContract<any>, T & DataRow> | — | |
| board | Omit<UseViewBoardOptions<T>, "live" | "filters" | "select" | "enabled"> | — | `board`: the board block over the view's, and its write options. |
| calendar | Omit<UseViewCalendarRangeOptions, "live" | "filters" | "select" | "enabled"> | — | `calendar`: the calendar block's fields, limit and clock over the view's. |
| can | ViewScreenCan<T> | — | The screen's own rule; it only narrows the view's guards. |
| filter | Readonly<Record<string, Scalar | readonly (string | number)[]>> | — | |
| live | boolean | LiveOptions | — | |
| perPage | number | — | `list`: rows per page. |
| preset | string | — | |
| range | ViewCalendarRange | — | `calendar`: the days to load. Default this month's grid on the viewer's clock. |
| resourceOptions | { defaultFilters?: FilterParam[]; select?: string; enabled?: boolean | undefined; live?: boolean | LiveOptions | undefined; } | undefined | — | |
| scoped | boolean | — | |
| search | string | — | `list`: the first search. |
| sort | SortParam | null | — | `list`: the first sort (default the view's `orderBy`). |
| type | enum | — | Default `list`. Fixed for the component's life: give the component a `key` per type to switch. |
| urlState | SearchParamsAdapter | ResourceUrlStateOptions | — | `list`: keep page, sort, search and the open record in the URL (ResourcePage's `urlState`). |
CustomView
A screen an app draws itself over a view (ADR 0019): Genesis loads the view's data with its scope, filters, URL state, live updates and permissions, and draws loading, empty and error; the app draws the rest. ```tsx <CustomView view={playersView} sort={{ field: "points", order: "desc" }} perPage={10} live> {({ rows, reducedMotion }) => <Leaderboard players={rows} animate={!reducedMotion} />} </CustomView> ``` Parts: `custom-view` (with `data-view-type` and `data-state`), `custom-view-loading`, `custom-view-empty` and `custom-view-error`. An app's own parts inside are named `app-…`.
| Prop | Type | Default | Description |
|---|---|---|---|
| children* | (state: CustomViewState<T>) => ReactNode | — | Draws the view once there's something to show. Genesis draws loading, empty and error. |
| view* | ResourceView<ResourceContract<any>, T & DataRow> | — | |
| board | Omit<UseViewBoardOptions<T>, "live" | "filters" | "select" | "enabled"> | — | `board`: the board block over the view's, and its write options. |
| calendar | Omit<UseViewCalendarRangeOptions, "live" | "filters" | "select" | "enabled"> | — | `calendar`: the calendar block's fields, limit and clock over the view's. |
| can | ViewScreenCan<T> | — | The screen's own rule; it only narrows the view's guards. |
| className | string | — | |
| empty | ReactNode | — | Replaces the empty state. `false` hands an empty view to `children` too (a calendar that still draws its days). |
| error | ReactNode | ((error: unknown, retry: () => void) => ReactNode) | — | Replaces the error state; a function gets the error and a retry. |
| filter | Readonly<Record<string, Scalar | readonly (string | number)[]>> | — | |
| live | boolean | LiveOptions | — | |
| loading | ReactNode | — | Replaces the loading state. |
| perPage | number | — | `list`: rows per page. |
| preset | string | — | |
| range | ViewCalendarRange | — | `calendar`: the days to load. Default this month's grid on the viewer's clock. |
| resourceOptions | { defaultFilters?: FilterParam[]; select?: string; enabled?: boolean | undefined; live?: boolean | LiveOptions | undefined; } | undefined | — | |
| scoped | boolean | — | |
| search | string | — | `list`: the first search. |
| sort | SortParam | null | — | `list`: the first sort (default the view's `orderBy`). |
| testID | string | — | |
| type | enum | — | Default `list`. Fixed for the component's life: give the component a `key` per type to switch. |
| urlState | SearchParamsAdapter | ResourceUrlStateOptions | — | `list`: keep page, sort, search and the open record in the URL (ResourcePage's `urlState`). |