Repository navigation
v1.0.0
Major Changes
-
60d41c1: 1.0: a declaration that reads once and makes sense without the documentation.
Breaking changes, each one rewritten bynpx react-resource-view migrateor
explained step by step inMIGRATION-1.0.md;migrations/1.0.jsonis the same
list as data, for a script or an AI to apply.- One place per notion.
viewis gone: what every action shares —form,
fullWidth,titleField,components,description— sits at the root of
the resource; what belongs to one action sits inviews.list | read | create | update | delete, each typed with only the options that have an effect there.
Root, action and layout are merged deeply, soviews.updatesays only what
differs, andinputs: { notes: false }removes an inherited field. Actions
are plain strings (views.update,rowActions: ["read"]);ActionListis
still accepted. - Permissions.
canRead,canList,canCreate,canUpdate,canDelete
andbehavior.canExportbecome onepermissionsobject —"all",
"readonly", a list of actions, or a boolean or a function per action.
Everything is allowed by default, so the shortest declaration has all its
buttons. A function is told the record (({ item }) => item.status !== "done")
and may answer asynchronously; answers are cached per record while a list is
on screen. A refused action also protects its route:/books/update/1draws
the scope'sforbiddenFallbackinstead of the form.canListis now read for
the list (it was ignored).usePermission(action, item)and
useAllowedActions(actions, item)are added;permissionResourcetakes
{ item, context }and may return a promise. behavioris gone, each option moved to where it has an effect:
openIn→views.<action>.open("page","dialog","drawer");
closeAfterUpdate,refreshDataAfterUpdate,redirectToAfterUpdate→ one
afterSave: "close" | "stay" | "reload" | { redirect: (item) => string };
rowActions→views.list.rowActions;eventSourced→realtimeat the
root;openRecordIn→views.read.open;selectable,bulkActions→
views.list.selectable,views.list.bulkActions, for every layout of the
list (bulkActionsalso takes"delete").- Layouts.
viewVariantsbecomesviews.list.layouts, and the seven
factories onelayoutnamespace:layout.table(),layout.cards({ columns }),
layout.board({ groupBy, columns }),layout.calendar({ dateField }),
layout.timeline({ startField, endField, groupBy }),layout.split({ readInList }),
layout.items()andlayout.custom()for one's own (read its options with
useLayout()). Field options are checked against the resource's item type —
a typo is a TypeScript error — and share one suffix:titleField,
dateField,colorField,statusField. A layout's URL id is its type, so a
new label breaks no shared link;fieldspicks a layout's columns. - Data. Without
path,storage: "local"must be declared: a forgotten
path no longer turns into localStorage silently.preGetCollection,
preGetItem,preCreate,preUpdatebecomehooks.beforeList,
beforeRead,beforeCreate,beforeUpdate, joined bybeforeDelete,
afterSaveandafterDelete; hooks may be asynchronous and always receive
the view context — creations and updates used to lose it on the way to the
repository. Hand-written repository methods move torepository: { … }.
limitbecomesquota: { get, fallback }(useLimit→useQuota). - Titles and components.
nameis declared once; titles are derived and
overridden withviews.<action>.title, a button's text withbuttonLabel.
viewComponentand the otherxxxComponentkeys, anddecoratorComponent,
become onecomponentsobject (view,wrapper,top,bottom,empty
— exnoResult—,pagination,navigation,title,actions). - Tabs.
subViewResourcebecomesviews.read | update.tabs: { orientation, aside, items }, a tab being{ id, label, resource, filter: ({ item }) => … }
instead of anonInitViewResourcereturning the whole context. - Scopes and defaults. A resource no longer names its
scope: the scope's
resourcesties them, andmenu: "auto"(or a list mixing resources, links
and groups) builds the navigation.setResourceConfig({ defaultResource })
becomesconfigureResourceView({ defaults }), merged deeply into every
resource, including those declared before it is called. - Types.
ResourceDefinitionis what one writes,ViewResourcewhat the
library builds;ViewResourceInterface,ResourceOptionInterface,
ViewInterfaceand the factory option interfaces are replaced. - Optimistic writes. Every write going through a resource's repository —
a form saved, a row deleted, a cell edited in place, a card moved, the
writes of a bulk action made through its newmutationargument — is drawn
before the API answers: the row changes at once (a created one appears,
marked as being saved), the API's answer replaces it as soon as it comes,
and a refusal puts it back with a toast — a form keeps the API's violations
on its fields. Several writes to one record show the last one; a list read
again while a write is in flight (a realtime push) keeps the row as
written. On by default — a change of perceived behaviour —, turned off with
optimistic: falseat the root or per action
(views.delete: { optimistic: false }).useResourceMutation(resource)
gives an application's own actions the same optimism and rollback
(create,update,remove,mutate,isPending), andRowInterface
gainspending. Built on the library's own state rather than React 19's
useOptimistic: no new requirement on the React version. - One routed opening.
views.<action>.openis resolved once, and anything
but"page"is written into the URL under the view it was opened from
(…/tasks/list/tasks/update/12, filter and layout kept): a row's button —
now a real link —, a board's card and a link typed by hand open the same
frame, Back closes it, a reload opens it again over the same list, and a
save closes it by going back to that URL. A list reads itself again once per
save, instead of once per button of its rows.layout.board({ openRecord, expandable })is gone: a card opens the record'sreadview where
views.read.opensays — on its page by default, where it used to open
nothing. - Frames of one's own.
open.custom({ type, placement, component }), on
the model oflayout.custom(): the component receives the title, the view,
closeand the link to the full page.placement: "inline"draws the view
under the row that opened it in a table, a plain list or a card grid — a
layout.custom()says it can withsupports: ["inline"]and draws
<InlineChildView row={row} />— and falls back to a dialog elsewhere, with
a warning in development.configureResourceView({ open: { accordion } })
registers a frame under a name, typed through theOpenFramesinterface. - "Open in full page". A
readorupdateview opened in a frame has a
link to the same view on its page beside the close button, a real
<a href>that Ctrl/Cmd+click opens in a new tab.expandable: falseon
the view takes it away;createanddeletedo not have it unless they say
expandable: true. - Checked in development.
createViewResourceandlayout.*throw on a key
they do not read — with the closest key, or the exact 1.0 rewrite of a 0.x
one — on a resource with no data source, a board withoutgroupBy, two
layouts sharing a URL id, and warn about a title identical to the derived
one. Nothing is checked in production. - Command line.
npx react-resource-view migrate [paths]rewrites 0.x
declarations (--dry-run,--check);create-view-variantwrites a
layout.custom()file;initstarts on the 1.0 syntax.
- One place per notion.
Minor Changes
-
29ce470: feat(views): a list sorts by its column headers, selects its records in every layout and says when it could not load, not only on the board and not with an empty list
views.list.sort: { fields, initial }: the table's headers of the fields named sort ascending, then descending, then not at all (aria-sort); the sort goes to the API through the dialect, into the URL, and survives "Clear the search".useSort()gives the same to a layout of one's own.- Breaking (1.0):
selectableandbulkActionsleavelayout.board()forviews.list, and reach every layout: checkboxes on the table's rows (and "Select all" in its header), the cards and the items.bulkActionsaccepts"delete", which deletes the selection after a confirmation, as far aspermissions.deleteallows.selectabledefaults totrueon a board and wherever bulk actions are declared.npx react-resource-view migraterewrites both (RV1-BEHAV-006, RV1-LAYOUT-014). - A view whose records could not be loaded draws what the API answered and "Try again" (
components.errorreplaces it), rather than "An error occurred" in a list, or an empty form that could be saved over the record.loadErroron the view context holds what the request threw.
-
e7e7654: Moving to another view shows that the click was heard, instead of nothing until
the next view appears at once: a thin bar runs along the top of the screen, in
the theme's primary colour, until the new view has its data, and the view fades
in, sliding up a few pixels. No new dependency.- The bar waits 150 ms, so an instant navigation flashes nothing, then stays
300 ms at least; it runs quickly, then slower, and fills up when the view is
there. The loading view is markedaria-busy, the bar has
role="progressbar", and neither takes the focus. - Under
prefers-reduced-motion: reduce, the view fades without moving. ResourceViewProvidertakesnavigationLoader— a node, a component
receiving{ isNavigating }, orfalsefor nothing — andviewTransition
(trueby default).- Any router works: a navigation counts from a click on a link of the library,
or a call to itsnavigate, until the new view has loaded. The navigation
port takes an optionaluseIsNavigating, which the TanStack adapter reads
fromuseRouterState. useIsNavigating(),useDelayedVisibility()andNavigationProgressBarare
exported, for an indicator drawn elsewhere.
- The bar waits 150 ms, so an instant navigation flashes nothing, then stays