Genesis
@beta

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

Import
Subpath export: @marktiderman/genesis-ui/data
import { CustomView } from "@marktiderman/genesis-ui/data";
Components
Auto-generated from TypeScript source via 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.

PropTypeDefaultDescription
view*ResourceView<ResourceContract<any>, T & DataRow>—
boardOmit<UseViewBoardOptions<T>, "live" | "filters" | "select" | "enabled">—`board`: the board block over the view's, and its write options.
calendarOmit<UseViewCalendarRangeOptions, "live" | "filters" | "select" | "enabled">—`calendar`: the calendar block's fields, limit and clock over the view's.
canViewScreenCan<T>—The screen's own rule; it only narrows the view's guards.
filterReadonly<Record<string, Scalar | readonly (string | number)[]>>—
liveboolean | LiveOptions—
perPagenumber—`list`: rows per page.
presetstring—
rangeViewCalendarRange—`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—
scopedboolean—
searchstring—`list`: the first search.
sortSortParam | null—`list`: the first sort (default the view's `orderBy`).
typeenum—Default `list`. Fixed for the component's life: give the component a `key` per type to switch.
urlStateSearchParamsAdapter | 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-…`.

PropTypeDefaultDescription
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>—
boardOmit<UseViewBoardOptions<T>, "live" | "filters" | "select" | "enabled">—`board`: the board block over the view's, and its write options.
calendarOmit<UseViewCalendarRangeOptions, "live" | "filters" | "select" | "enabled">—`calendar`: the calendar block's fields, limit and clock over the view's.
canViewScreenCan<T>—The screen's own rule; it only narrows the view's guards.
classNamestring—
emptyReactNode—Replaces the empty state. `false` hands an empty view to `children` too (a calendar that still draws its days).
errorReactNode | ((error: unknown, retry: () => void) => ReactNode)—Replaces the error state; a function gets the error and a retry.
filterReadonly<Record<string, Scalar | readonly (string | number)[]>>—
liveboolean | LiveOptions—
loadingReactNode—Replaces the loading state.
perPagenumber—`list`: rows per page.
presetstring—
rangeViewCalendarRange—`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—
scopedboolean—
searchstring—`list`: the first search.
sortSortParam | null—`list`: the first sort (default the view's `orderBy`).
testIDstring—
typeenum—Default `list`. Fixed for the component's life: give the component a `key` per type to switch.
urlStateSearchParamsAdapter | ResourceUrlStateOptions—`list`: keep page, sort, search and the open record in the URL (ResourcePage's `urlState`).
Storybook
Storybook hosts the canonical visual reference with controls for every variant.