Genesis
@beta

defineViewType

A view type an app adds (ADR 0021): a name and the component that draws a view that way. Register it once at start-up with {@link registerViewType}. ```tsx export const timelineType = defineViewType({ id: "timeline", label: "Timeline", render: Timeline }); registerViewType(timelineType); <ResourceView view={sessionsView} type="timeline" />; ``` Throws for an id that isn't lowercase letters, digits and hyphens, or a `render` that isn't a component.

packages/ui/src/components/data/resource-view/view-types.tsx

Import
Subpath export: @marktiderman/genesis-ui/data
import { defineViewType } from "@marktiderman/genesis-ui/data";
Components
Auto-generated from TypeScript source via react-docgen-typescript.

defineViewType

A view type an app adds (ADR 0021): a name and the component that draws a view that way. Register it once at start-up with {@link registerViewType}. ```tsx export const timelineType = defineViewType({ id: "timeline", label: "Timeline", render: Timeline }); registerViewType(timelineType); <ResourceView view={sessionsView} type="timeline" />; ``` Throws for an id that isn't lowercase letters, digits and hyphens, or a `render` that isn't a component.

PropTypeDefaultDescription
id*string—Lowercase letters, digits and hyphens: `"timeline"`.
render*ComponentType<ResourceViewProps<any>>—Draws a view as this type. It gets the screen's ResourceView props (the view, `filter`, `preset`, `open`, `cells`…); `useViewListParams`, `useViewList`, `useViewBoard` and `useViewCalendarRange` give it the view's data, scope and permissions, and `<CustomView>` its loading, empty and error states.
labelstring—Its name in words, for a type switcher. Default the id in title case.

registerViewType

Make a view type available to every `<ResourceView type>` in the app. Returns a function that removes it again (tests, a module unloaded). Registering a second type under a taken id throws unless `replace` is set; a built-in type can't be replaced.

No declared props.

registerBuiltInViewType

Genesis's own types, registered by ResourceView.

PropTypeDefaultDescription
id*string—Lowercase letters, digits and hyphens: `"timeline"`.
render*ComponentType<ResourceViewProps<any>>—Draws a view as this type. It gets the screen's ResourceView props (the view, `filter`, `preset`, `open`, `cells`…); `useViewListParams`, `useViewList`, `useViewBoard` and `useViewCalendarRange` give it the view's data, scope and permissions, and `<CustomView>` its loading, empty and error states.
labelstring—Its name in words, for a type switcher. Default the id in title case.

resolveViewType

A registered view type by name, or undefined.

No declared props.

listViewTypes

Every registered view type, built-ins first, in the order registered.

No declared props.