@molecule/app-routing-react-router 1.3.0 → 1.4.1
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 +109 -1
- package/dist/ListRouteNav.d.ts +52 -0
- package/dist/ListRouteNav.d.ts.map +1 -0
- package/dist/ListRouteNav.js +48 -0
- package/dist/ListRouteNav.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-16T11:33:37.438Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-routing-react-router
|
|
@@ -33,12 +33,44 @@ their order, with page last. Page one omits `page`; unrelated queries and hash
|
|
|
33
33
|
survive. Add `path` when changing path params, or `selections` when linking views.
|
|
34
34
|
It works under ordinary `BrowserRouter` without a data router or an extra provider.
|
|
35
35
|
|
|
36
|
+
**URL-selected tabs or filters? Render `ListRouteNav`.** Declare each view's label,
|
|
37
|
+
path and query together. It renders every declared choice on every route, builds
|
|
38
|
+
each destination through `useListRoute`, resets pagination on selection, and derives
|
|
39
|
+
the active link from the URL. Keep this declaration shared by the related routes.
|
|
40
|
+
Use the UI package's `Tabs` for panels whose selection is genuinely local state.
|
|
41
|
+
|
|
36
42
|
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
37
43
|
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
38
44
|
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
39
45
|
|
|
40
46
|
## Quick Start
|
|
41
47
|
|
|
48
|
+
```tsx
|
|
49
|
+
import { ListRouteNav } from '@molecule/app-routing-react-router'
|
|
50
|
+
import { useTranslation } from '@molecule/app-react'
|
|
51
|
+
|
|
52
|
+
function OrderViews() {
|
|
53
|
+
const { t } = useTranslation()
|
|
54
|
+
return (
|
|
55
|
+
<ListRouteNav
|
|
56
|
+
aria-label={t('orders.views', undefined, { defaultValue: 'Order views' })}
|
|
57
|
+
selections={{
|
|
58
|
+
all: {
|
|
59
|
+
path: '/orders',
|
|
60
|
+
query: { view: undefined },
|
|
61
|
+
label: t('orders.all', undefined, { defaultValue: 'All orders' }),
|
|
62
|
+
},
|
|
63
|
+
open: {
|
|
64
|
+
path: '/orders',
|
|
65
|
+
query: { view: 'open' },
|
|
66
|
+
label: t('orders.open', undefined, { defaultValue: 'Open orders' }),
|
|
67
|
+
},
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
42
74
|
```tsx
|
|
43
75
|
import { Routes, Route } from 'react-router'
|
|
44
76
|
import { BrowserRouter, MoleculeRouterProvider } from '@molecule/app-routing-react-router'
|
|
@@ -202,6 +234,60 @@ npm install -D @types/react
|
|
|
202
234
|
|
|
203
235
|
### Interfaces
|
|
204
236
|
|
|
237
|
+
#### `ListRouteNavItem`
|
|
238
|
+
|
|
239
|
+
A named list view and its navigation label.
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
interface ListRouteNavItem extends ListRouteSelection {
|
|
243
|
+
/** Translated label, optionally including an icon. */
|
|
244
|
+
label: ReactNode
|
|
245
|
+
/** Path parameters for this destination; current route parameters are otherwise retained. */
|
|
246
|
+
params?: RouteParams
|
|
247
|
+
/** Keep the choice visible but prevent navigation. Authorization still belongs in the route. */
|
|
248
|
+
disabled?: boolean
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### `ListRouteNavItemState`
|
|
253
|
+
|
|
254
|
+
URL-derived state available to the app's link styling.
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
interface ListRouteNavItemState<Selection extends string = string> {
|
|
258
|
+
/** The app-owned selection key. */
|
|
259
|
+
selection: Selection
|
|
260
|
+
/** Whether the current URL selects this view. */
|
|
261
|
+
active: boolean
|
|
262
|
+
/** Whether navigation is disabled for this choice. */
|
|
263
|
+
disabled: boolean
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
#### `ListRouteNavProps`
|
|
268
|
+
|
|
269
|
+
Props for URL-backed list navigation; local content panels use the UI package's Tabs instead.
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
interface ListRouteNavProps<Selection extends string = string> extends Omit<
|
|
273
|
+
ComponentPropsWithoutRef<'nav'>,
|
|
274
|
+
'children'
|
|
275
|
+
> {
|
|
276
|
+
/** Accessible navigation name, translated by the app. */
|
|
277
|
+
'aria-label': string
|
|
278
|
+
/** Every declared view stays visible on every route; labels and targets share one declaration. */
|
|
279
|
+
selections: Record<Selection, ListRouteNavItem>
|
|
280
|
+
/** Tie-breaker or fallback, with the same meaning as useListRoute's defaultSelection. */
|
|
281
|
+
defaultSelection?: NoInfer<Selection>
|
|
282
|
+
/** Pagination query key to remove on selection, defaulting to page. */
|
|
283
|
+
pageParam?: string
|
|
284
|
+
/** Required for protected selections, with the same readiness rules as useListRoute. */
|
|
285
|
+
auth?: ListRouteAuth
|
|
286
|
+
/** App-owned styling, resolved from its class map. */
|
|
287
|
+
linkClassName?: string | ((state: ListRouteNavItemState<Selection>) => string | undefined)
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
205
291
|
#### `MoleculeRouterProviderProps`
|
|
206
292
|
|
|
207
293
|
Provider props.
|
|
@@ -690,6 +776,28 @@ type RouteChangeListener = (location: RouteLocation, action: NavigationAction) =
|
|
|
690
776
|
|
|
691
777
|
### Functions
|
|
692
778
|
|
|
779
|
+
#### `ListRouteNav(props)`
|
|
780
|
+
|
|
781
|
+
Render every declared list view as a router link. The URL selects the active choice, and
|
|
782
|
+
selecting any view resets pagination through useListRoute. Native link behavior (new-tab
|
|
783
|
+
clicks, keyboard activation and history) is preserved. This is a navigation landmark,
|
|
784
|
+
not an ARIA tablist with local panels. No active-value state or change handler is needed.
|
|
785
|
+
|
|
786
|
+
```typescript
|
|
787
|
+
function ListRouteNav<Selection extends string>({
|
|
788
|
+
selections,
|
|
789
|
+
defaultSelection,
|
|
790
|
+
pageParam,
|
|
791
|
+
auth,
|
|
792
|
+
linkClassName,
|
|
793
|
+
...rest
|
|
794
|
+
}: ListRouteNavProps<Selection>): JSX.Element
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
- `props` — Named destinations, translated labels, optional auth and native nav attributes.
|
|
798
|
+
|
|
799
|
+
**Returns:** The navigation landmark and all its declared choices.
|
|
800
|
+
|
|
693
801
|
#### `MoleculeRouterProvider(props)`
|
|
694
802
|
|
|
695
803
|
Provider component that creates ONE molecule Router over React Router for its whole
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navigation between URL-backed list views, using the same declaration for labels and destinations.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { ComponentPropsWithoutRef, JSX, ReactNode } from 'react';
|
|
7
|
+
import type { RouteParams } from '@molecule/app-routing';
|
|
8
|
+
import type { ListRouteAuth, ListRouteSelection } from './list-types.js';
|
|
9
|
+
/** A named list view and its navigation label. */
|
|
10
|
+
export interface ListRouteNavItem extends ListRouteSelection {
|
|
11
|
+
/** Translated label, optionally including an icon. */
|
|
12
|
+
label: ReactNode;
|
|
13
|
+
/** Path parameters for this destination; current route parameters are otherwise retained. */
|
|
14
|
+
params?: RouteParams;
|
|
15
|
+
/** Keep the choice visible but prevent navigation. Authorization still belongs in the route. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** URL-derived state available to the app's link styling. */
|
|
19
|
+
export interface ListRouteNavItemState<Selection extends string = string> {
|
|
20
|
+
/** The app-owned selection key. */
|
|
21
|
+
selection: Selection;
|
|
22
|
+
/** Whether the current URL selects this view. */
|
|
23
|
+
active: boolean;
|
|
24
|
+
/** Whether navigation is disabled for this choice. */
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Props for URL-backed list navigation; local content panels use the UI package's Tabs instead. */
|
|
28
|
+
export interface ListRouteNavProps<Selection extends string = string> extends Omit<ComponentPropsWithoutRef<'nav'>, 'children'> {
|
|
29
|
+
/** Accessible navigation name, translated by the app. */
|
|
30
|
+
'aria-label': string;
|
|
31
|
+
/** Every declared view stays visible on every route; labels and targets share one declaration. */
|
|
32
|
+
selections: Record<Selection, ListRouteNavItem>;
|
|
33
|
+
/** Tie-breaker or fallback, with the same meaning as useListRoute's defaultSelection. */
|
|
34
|
+
defaultSelection?: NoInfer<Selection>;
|
|
35
|
+
/** Pagination query key to remove on selection, defaulting to page. */
|
|
36
|
+
pageParam?: string;
|
|
37
|
+
/** Required for protected selections, with the same readiness rules as useListRoute. */
|
|
38
|
+
auth?: ListRouteAuth;
|
|
39
|
+
/** App-owned styling, resolved from its class map. */
|
|
40
|
+
linkClassName?: string | ((state: ListRouteNavItemState<Selection>) => string | undefined);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Render every declared list view as a router link. The URL selects the active choice, and
|
|
44
|
+
* selecting any view resets pagination through useListRoute. Native link behavior (new-tab
|
|
45
|
+
* clicks, keyboard activation and history) is preserved. This is a navigation landmark,
|
|
46
|
+
* not an ARIA tablist with local panels. No active-value state or change handler is needed.
|
|
47
|
+
*
|
|
48
|
+
* @param props - Named destinations, translated labels, optional auth and native nav attributes.
|
|
49
|
+
* @returns The navigation landmark and all its declared choices.
|
|
50
|
+
*/
|
|
51
|
+
export declare function ListRouteNav<Selection extends string>({ selections, defaultSelection, pageParam, auth, linkClassName, ...rest }: ListRouteNavProps<Selection>): JSX.Element;
|
|
52
|
+
//# sourceMappingURL=ListRouteNav.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListRouteNav.d.ts","sourceRoot":"","sources":["../src/ListRouteNav.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGxD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGxE,kDAAkD;AAClD,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IAC1D,sDAAsD;IACtD,KAAK,EAAE,SAAS,CAAA;IAChB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,6DAA6D;AAC7D,MAAM,WAAW,qBAAqB,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM;IACtE,mCAAmC;IACnC,SAAS,EAAE,SAAS,CAAA;IACpB,iDAAiD;IACjD,MAAM,EAAE,OAAO,CAAA;IACf,sDAAsD;IACtD,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,oGAAoG;AACpG,MAAM,WAAW,iBAAiB,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CAChF,wBAAwB,CAAC,KAAK,CAAC,EAC/B,UAAU,CACX;IACC,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAA;IACpB,kGAAkG;IAClG,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IAC/C,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IACrC,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wFAAwF;IACxF,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,qBAAqB,CAAC,SAAS,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC,CAAA;CAC3F;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,SAAS,SAAS,MAAM,EAAE,EACrD,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,aAAa,EACb,GAAG,IAAI,EACR,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CA+C5C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Link, useParams } from 'react-router';
|
|
3
|
+
import { generatePath } from '@molecule/app-routing';
|
|
4
|
+
import { useListRoute } from './useListRoute.js';
|
|
5
|
+
/**
|
|
6
|
+
* Render every declared list view as a router link. The URL selects the active choice, and
|
|
7
|
+
* selecting any view resets pagination through useListRoute. Native link behavior (new-tab
|
|
8
|
+
* clicks, keyboard activation and history) is preserved. This is a navigation landmark,
|
|
9
|
+
* not an ARIA tablist with local panels. No active-value state or change handler is needed.
|
|
10
|
+
*
|
|
11
|
+
* @param props - Named destinations, translated labels, optional auth and native nav attributes.
|
|
12
|
+
* @returns The navigation landmark and all its declared choices.
|
|
13
|
+
*/
|
|
14
|
+
export function ListRouteNav({ selections, defaultSelection, pageParam, auth, linkClassName, ...rest }) {
|
|
15
|
+
const routeParams = useParams();
|
|
16
|
+
const currentParams = {};
|
|
17
|
+
for (const [name, value] of Object.entries(routeParams)) {
|
|
18
|
+
if (value !== undefined)
|
|
19
|
+
currentParams[name] = value;
|
|
20
|
+
}
|
|
21
|
+
// Resolve per-choice params before matching as well as before building links:
|
|
22
|
+
// two choices can share /folders/:folder while naming different folders.
|
|
23
|
+
const destinations = { ...selections };
|
|
24
|
+
for (const [selection, item] of Object.entries(selections)) {
|
|
25
|
+
if (item.params) {
|
|
26
|
+
destinations[selection] = {
|
|
27
|
+
...item,
|
|
28
|
+
path: generatePath(item.path, { ...currentParams, ...item.params }),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const list = useListRoute({ selections: destinations, defaultSelection, pageParam, auth });
|
|
33
|
+
return (_jsx("nav", { ...rest, children: Object.entries(selections).map(([selection, item]) => {
|
|
34
|
+
const active = list.selection === selection;
|
|
35
|
+
const disabled = item.disabled === true;
|
|
36
|
+
const className = typeof linkClassName === 'function'
|
|
37
|
+
? linkClassName({ selection, active, disabled })
|
|
38
|
+
: linkClassName;
|
|
39
|
+
const attrs = {
|
|
40
|
+
className,
|
|
41
|
+
'data-state': active ? 'active' : 'inactive',
|
|
42
|
+
'data-mol-id': `list-route-${selection}`,
|
|
43
|
+
'aria-current': active ? 'page' : undefined,
|
|
44
|
+
};
|
|
45
|
+
return disabled ? (_jsx("span", { ...attrs, role: "link", "aria-disabled": "true", children: item.label }, selection)) : (_jsx(Link, { ...attrs, to: list.href({ selection }), children: item.label }, selection));
|
|
46
|
+
}) }));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ListRouteNav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListRouteNav.js","sourceRoot":"","sources":["../src/ListRouteNav.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAyChD;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAA2B,EACrD,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,aAAa,EACb,GAAG,IAAI,EACsB;IAC7B,MAAM,WAAW,GAAG,SAAS,EAAE,CAAA;IAC/B,MAAM,aAAa,GAAgB,EAAE,CAAA;IACrC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACxD,IAAI,KAAK,KAAK,SAAS;YAAE,aAAa,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IACtD,CAAC;IACD,8EAA8E;IAC9E,yEAAyE;IACzE,MAAM,YAAY,GAAG,EAAE,GAAG,UAAU,EAAE,CAAA;IACtC,KAAK,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAoC,EAAE,CAAC;QAC9F,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,YAAY,CAAC,SAAS,CAAC,GAAG;gBACxB,GAAG,IAAI;gBACP,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;aACpE,CAAA;QACH,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,YAAY,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAE1F,OAAO,CACL,iBAAS,IAAI,YACT,MAAM,CAAC,OAAO,CAAC,UAAU,CAAqC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;YACzF,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,KAAK,SAAS,CAAA;YAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAA;YACvC,MAAM,SAAS,GACb,OAAO,aAAa,KAAK,UAAU;gBACjC,CAAC,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;gBAChD,CAAC,CAAC,aAAa,CAAA;YACnB,MAAM,KAAK,GAAG;gBACZ,SAAS;gBACT,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU;gBAC5C,aAAa,EAAE,cAAc,SAAS,EAAE;gBACxC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAE,MAAgB,CAAC,CAAC,CAAC,SAAS;aACvD,CAAA;YAED,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,kBAA0B,KAAK,EAAE,IAAI,EAAC,MAAM,mBAAe,MAAM,YAC9D,IAAI,CAAC,KAAK,IADF,SAAS,CAEb,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,OAAqB,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,YAC1D,IAAI,CAAC,KAAK,IADF,SAAS,CAEb,CACR,CAAA;QACH,CAAC,CAAC,GACE,CACP,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,33 @@
|
|
|
24
24
|
* survive. Add `path` when changing path params, or `selections` when linking views.
|
|
25
25
|
* It works under ordinary `BrowserRouter` without a data router or an extra provider.
|
|
26
26
|
*
|
|
27
|
+
* **URL-selected tabs or filters? Render `ListRouteNav`.** Declare each view's label,
|
|
28
|
+
* path and query together. It renders every declared choice on every route, builds
|
|
29
|
+
* each destination through `useListRoute`, resets pagination on selection, and derives
|
|
30
|
+
* the active link from the URL. Keep this declaration shared by the related routes.
|
|
31
|
+
* Use the UI package's `Tabs` for panels whose selection is genuinely local state.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { ListRouteNav } from '@molecule/app-routing-react-router'
|
|
36
|
+
* import { useTranslation } from '@molecule/app-react'
|
|
37
|
+
*
|
|
38
|
+
* function OrderViews() {
|
|
39
|
+
* const { t } = useTranslation()
|
|
40
|
+
* return (
|
|
41
|
+
* <ListRouteNav
|
|
42
|
+
* aria-label={t('orders.views', undefined, { defaultValue: 'Order views' })}
|
|
43
|
+
* selections={{
|
|
44
|
+
* all: { path: '/orders', query: { view: undefined },
|
|
45
|
+
* label: t('orders.all', undefined, { defaultValue: 'All orders' }) },
|
|
46
|
+
* open: { path: '/orders', query: { view: 'open' },
|
|
47
|
+
* label: t('orders.open', undefined, { defaultValue: 'Open orders' }) },
|
|
48
|
+
* }}
|
|
49
|
+
* />
|
|
50
|
+
* )
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
27
54
|
* @example
|
|
28
55
|
* ```tsx
|
|
29
56
|
* import { Routes, Route } from 'react-router'
|
|
@@ -187,6 +214,7 @@
|
|
|
187
214
|
export * from './hooks.js';
|
|
188
215
|
export * from './lazyPage.js';
|
|
189
216
|
export * from './list-types.js';
|
|
217
|
+
export * from './ListRouteNav.js';
|
|
190
218
|
export * from './provider.js';
|
|
191
219
|
export * from './routers.js';
|
|
192
220
|
export type { GuardResult, NavigateOptions, NavigationGuard, QueryParams, ReactRouterConfig, ReactRouterHooks, RouteChangeListener, RouteDefinition, RouteLocation, RouteMatch, RouteParams, RouterConfig, } from './types.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoNG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,YAAY,EACV,WAAW,EACX,eAAe,EACf,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAA;AACnB,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,33 @@
|
|
|
24
24
|
* survive. Add `path` when changing path params, or `selections` when linking views.
|
|
25
25
|
* It works under ordinary `BrowserRouter` without a data router or an extra provider.
|
|
26
26
|
*
|
|
27
|
+
* **URL-selected tabs or filters? Render `ListRouteNav`.** Declare each view's label,
|
|
28
|
+
* path and query together. It renders every declared choice on every route, builds
|
|
29
|
+
* each destination through `useListRoute`, resets pagination on selection, and derives
|
|
30
|
+
* the active link from the URL. Keep this declaration shared by the related routes.
|
|
31
|
+
* Use the UI package's `Tabs` for panels whose selection is genuinely local state.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { ListRouteNav } from '@molecule/app-routing-react-router'
|
|
36
|
+
* import { useTranslation } from '@molecule/app-react'
|
|
37
|
+
*
|
|
38
|
+
* function OrderViews() {
|
|
39
|
+
* const { t } = useTranslation()
|
|
40
|
+
* return (
|
|
41
|
+
* <ListRouteNav
|
|
42
|
+
* aria-label={t('orders.views', undefined, { defaultValue: 'Order views' })}
|
|
43
|
+
* selections={{
|
|
44
|
+
* all: { path: '/orders', query: { view: undefined },
|
|
45
|
+
* label: t('orders.all', undefined, { defaultValue: 'All orders' }) },
|
|
46
|
+
* open: { path: '/orders', query: { view: 'open' },
|
|
47
|
+
* label: t('orders.open', undefined, { defaultValue: 'Open orders' }) },
|
|
48
|
+
* }}
|
|
49
|
+
* />
|
|
50
|
+
* )
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
27
54
|
* @example
|
|
28
55
|
* ```tsx
|
|
29
56
|
* import { Routes, Route } from 'react-router'
|
|
@@ -187,6 +214,7 @@
|
|
|
187
214
|
export * from './hooks.js';
|
|
188
215
|
export * from './lazyPage.js';
|
|
189
216
|
export * from './list-types.js';
|
|
217
|
+
export * from './ListRouteNav.js';
|
|
190
218
|
export * from './provider.js';
|
|
191
219
|
export * from './routers.js';
|
|
192
220
|
export * from './useListRoute.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoNG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAe5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-routing-react-router",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "React Router
|
|
3
|
+
"version": "1.4.1",
|
|
4
|
+
"description": "React Router provider with URL-backed list pagination, filters, path/query selections and auth readiness",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
56
|
-
"@molecule/app-i18n": "1.2.
|
|
57
|
-
"@molecule/app-query": "1.1
|
|
58
|
-
"@molecule/app-query-memory": "1.0
|
|
59
|
-
"@molecule/app-query-react": "1.
|
|
56
|
+
"@molecule/app-i18n": "1.2.2",
|
|
57
|
+
"@molecule/app-query": "1.3.1",
|
|
58
|
+
"@molecule/app-query-memory": "1.1.0",
|
|
59
|
+
"@molecule/app-query-react": "1.7.0",
|
|
60
60
|
"@testing-library/react": "16.3.3",
|
|
61
61
|
"@types/node": "26.6.5",
|
|
62
62
|
"@types/react": "19.3.0",
|