The router glue every Capsomer React part needs, in one place.
Anatomy
import { RouterConfirmModal, routerRenderForm, revalidateUnlessOnly, useRouterRowForm } from "capsomer/react/router";
import { onlyParamsChanged } from "capsomer/behavior/router";
API
RouterConfirmModal
Prop
Type
Required
Does
hidden
Record<string, string | readonly string[]>
A list value is one hidden field per item, under one name (the ticked ids).
title
string
Yes
Names the action and the object: "Delete example.com?"
children
ReactNode
More fields for the form, beside hidden: a list a server renders as its own inputs.
error
ReactNode
What the server found wrong the last time (the typed word did not match, no reason): shown in the alert box beside the buttons, so the page works with no script.
reason
{ label?: string; note?: string }
Asks for a reason, required, that the audit row carries. Posted as reason.
action
string
Where the form posts, and the fields it carries with it (the intent, the ids, a return address). Left out, it posts to the page it is on.
method
"post" | "get"
lead
ReactNode
body
string[]
What will change, one line each, from the server's own preview.
action_label
string
The perform button's label, named for the action: "Delete site".
cancelHref
string
Yes
Where Cancel goes: a link, so it works with no script.
cancelLabel
string
typeToConfirm
string
For what cannot be recovered: the short word to type. Checked by the browser (required and pattern) and again by the server.
media
boolean
The icon tile beside the title. Default: shown.
onCancel
() => void
Cancel for a dialog opened from the page's state rather than its address. Without it, Cancel goes to cancelHref and keeps the scroll position, since the page behind the dialog is where the reader still is.
Functions
Function
Signature
Does
useRouterRowForm
(): RowForm
A row's own fetcher, as a part's useRowForm: <NeedsList useRowForm={useRouterRowForm} />. Each row calls it once, so each row has its own fetcher.
True when the only change between two addresses is in the named display parameters (a view, a grouping, a size): the same path, every other parameter the same, and at least one named one different. A route's shouldRevalidate then skips the loader, because nothing it reads changed. A missing parameter reads as its default, so ?view=grid and the bare address are the same state when grid is the default. Identical addresses are false: a revalidation after an action has the same address on both sides, and skipping it would hide the write. From dustinedwards.info's media library (app/lib/media/view.mjs, onlyDisplayChanged).