@burojs/react 0.2.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,10 +13,17 @@ pnpm add @burojs/react @burojs/core
13
13
  ## Usage
14
14
 
15
15
  ```tsx
16
- import { BuroProvider, useResourceList } from '@burojs/react';
16
+ import { BuroProvider, RouterAdapterProvider, useResourceList } from '@burojs/react';
17
17
 
18
- function Root({ app, children }) {
19
- return <BuroProvider app={app}>{children}</BuroProvider>;
18
+ // `adapter` binds your router — `RouterAdapterProvider`'s docblock has the
19
+ // react-router and Next App Router ones. It is required, and goes above
20
+ // <BuroProvider>: without it no route matches.
21
+ function Root({ app, adapter, children }) {
22
+ return (
23
+ <RouterAdapterProvider adapter={adapter}>
24
+ <BuroProvider app={app}>{children}</BuroProvider>
25
+ </RouterAdapterProvider>
26
+ );
20
27
  }
21
28
 
22
29
  function MyList() {
@@ -33,11 +40,13 @@ function MyList() {
33
40
 
34
41
  ## Main exports
35
42
 
43
+ - **`BuroProvider`** — mounts the app runtime, i18n, the data runtime, and the interaction layer: an action dispatcher with a default for every effect (`refetch` invalidates the framework's queries, `notify` reaches the notification sink a toaster registers, `redirect` pushes through your `RouterAdapter` and skips the page already on screen, `setClipboard`, `download`, `modal`), overridable per key with `effects`; the unsaved-changes navigation guard; and the notification sink. Nested scopes and tests use **`DispatcherProvider`** / **`useDispatcher`**.
44
+ - **`resolveRoute` / `useRouteNavigate`** — the one navigation seam: a `RouteDescriptor` resolved against the registry and pushed through the mounted `RouterAdapter` (a document navigation without one). Mount `RouterAdapterProvider` **above** `<BuroProvider>`: the default `redirect` and the navigation guard's "Leave" read the adapter from where `BuroProvider` sits, so one mounted inside it is invisible to them and they fall back to full page loads. **`useNavigationBlocker`**, **`useRegisterNavigationGuardDialog`**, **`useRegisterNotificationSink`** are the hooks a UI kit's form, dialog and toaster use. A hook whose job is to register is named `useRegister<Thing>`, and the most recently registered, still-mounted registrant wins: one toaster receives notifications, one dialog answers a held navigation.
36
45
  - **`useResourceList`** — the data-connected list controller: rows, pagination (including the unknown-total contract), filters, search, sorting, columns, selection, saved views, routing hrefs, and the on-demand row count. **`ResourceListProvider` / `useResourceListContext`** expose it to override slots, so a custom list body is testable against a stub controller with no runtime or Next mocking.
37
46
  - **`useApp` / `useCurrentResource` / `useCtx`** — registry and context access.
38
- - **`useAction`** — invoke a declared action and apply its `ActionResult`.
39
- - **`useCapability` / `useCapabilityResolver`** — the deny-wins capability engine gating fields, actions and tabs.
40
- - **`useComponent` / `mergeComponents` / `ComponentsContext`** — the component registry behind override slots (`list.body.<resource>`, `list.filters.<resource>`, `show.banner.<resource>`, …).
47
+ - **`useAction`** (from `@burojs/react/flows`) — run a declared flow from code: its state, and `run()`.
48
+ - **`useCapability` / `useCapabilityResolver`** — the deny-wins capability engine gating fields, actions and columns.
49
+ - **`useComponent` / `mergeComponents` / `ComponentsContext`** — the component registry behind override slots (`list.filters.<resource>`, `list.cell.<resource>`, `record.<action>.<resource>`, `layout.<key>`), keys dotted with the canonical resource last.
41
50
  - **`useT` / `useLocale` / `I18nContext`**, plus the built-in **`en` / `ru`** locale bundles — render-time i18n with a live language switch (no reload).
42
51
  - **`TestIdBuilder` / `TestIdContext`** — the stable test-id surface shared with `@burojs/test-helpers`.
43
52