@molecule/app-routing-react-router 1.2.2 → 1.2.4
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 +39 -9
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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-09T07:07:09.138Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-routing-react-router
|
|
@@ -162,6 +162,25 @@ const topics = useListRoute({
|
|
|
162
162
|
// onPageChange={topics.setPage}; custom links use topics.href({ page: next }).
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
+
One feed page on `/`, `/?view=following` and `/topics/:topic`: mount it on both routes
|
|
166
|
+
with ONE config, so every tab link comes from `href`. With a separate config per route,
|
|
167
|
+
the topic page cannot build the "all" link, and a hand-written one tends to keep the topic.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
const feed = useListRoute({
|
|
171
|
+
pageSize: 10,
|
|
172
|
+
selections: {
|
|
173
|
+
all: { path: '/', query: { view: undefined } },
|
|
174
|
+
following: { path: '/', query: { view: 'following' } },
|
|
175
|
+
topic: { path: '/topics/:topic' },
|
|
176
|
+
},
|
|
177
|
+
defaultSelection: 'all',
|
|
178
|
+
})
|
|
179
|
+
// On /topics/design?page=2: feed.selection is 'topic', feed.params.topic is 'design',
|
|
180
|
+
// feed.href({ selection: 'all' }) is '/', feed.href({ page: 3 }) is '/topics/design?page=3'.
|
|
181
|
+
// A topic link names its topic: feed.href({ selection: 'topic', params: { topic: name } }).
|
|
182
|
+
```
|
|
183
|
+
|
|
165
184
|
## Type
|
|
166
185
|
|
|
167
186
|
`provider`
|
|
@@ -412,18 +431,22 @@ interface RouteLocation {
|
|
|
412
431
|
* Current pathname.
|
|
413
432
|
*/
|
|
414
433
|
pathname: string
|
|
434
|
+
|
|
415
435
|
/**
|
|
416
436
|
* Query string (including leading ?).
|
|
417
437
|
*/
|
|
418
438
|
search: string
|
|
439
|
+
|
|
419
440
|
/**
|
|
420
441
|
* Hash (including leading #).
|
|
421
442
|
*/
|
|
422
443
|
hash: string
|
|
444
|
+
|
|
423
445
|
/**
|
|
424
446
|
* State data passed with navigation.
|
|
425
447
|
*/
|
|
426
448
|
state?: unknown
|
|
449
|
+
|
|
427
450
|
/**
|
|
428
451
|
* Unique key for this location.
|
|
429
452
|
*/
|
|
@@ -441,14 +464,17 @@ interface RouteMatch<Params extends RouteParams = RouteParams> {
|
|
|
441
464
|
* Route path pattern.
|
|
442
465
|
*/
|
|
443
466
|
path: string
|
|
467
|
+
|
|
444
468
|
/**
|
|
445
469
|
* Matched URL pathname.
|
|
446
470
|
*/
|
|
447
471
|
pathname: string
|
|
472
|
+
|
|
448
473
|
/**
|
|
449
474
|
* Route parameters.
|
|
450
475
|
*/
|
|
451
476
|
params: Params
|
|
477
|
+
|
|
452
478
|
/**
|
|
453
479
|
* Whether this is an exact match.
|
|
454
480
|
*/
|
|
@@ -466,14 +492,17 @@ interface NavigateOptions {
|
|
|
466
492
|
* Replace current history entry instead of pushing.
|
|
467
493
|
*/
|
|
468
494
|
replace?: boolean
|
|
495
|
+
|
|
469
496
|
/**
|
|
470
497
|
* State to pass with navigation.
|
|
471
498
|
*/
|
|
472
499
|
state?: unknown
|
|
500
|
+
|
|
473
501
|
/**
|
|
474
502
|
* Preserve current query params.
|
|
475
503
|
*/
|
|
476
504
|
preserveQuery?: boolean
|
|
505
|
+
|
|
477
506
|
/**
|
|
478
507
|
* Preserve current hash.
|
|
479
508
|
*/
|
|
@@ -491,26 +520,32 @@ interface RouteDefinition {
|
|
|
491
520
|
* Route path pattern.
|
|
492
521
|
*/
|
|
493
522
|
path: string
|
|
523
|
+
|
|
494
524
|
/**
|
|
495
525
|
* Route name (for named routes).
|
|
496
526
|
*/
|
|
497
527
|
name?: string
|
|
528
|
+
|
|
498
529
|
/**
|
|
499
530
|
* Whether the route requires exact matching.
|
|
500
531
|
*/
|
|
501
532
|
exact?: boolean
|
|
533
|
+
|
|
502
534
|
/**
|
|
503
535
|
* Whether the route requires authentication.
|
|
504
536
|
*/
|
|
505
537
|
requiresAuth?: boolean
|
|
538
|
+
|
|
506
539
|
/**
|
|
507
540
|
* Required roles/permissions.
|
|
508
541
|
*/
|
|
509
542
|
roles?: string[]
|
|
543
|
+
|
|
510
544
|
/**
|
|
511
545
|
* Route metadata.
|
|
512
546
|
*/
|
|
513
547
|
meta?: Record<string, unknown>
|
|
548
|
+
|
|
514
549
|
/**
|
|
515
550
|
* Child routes.
|
|
516
551
|
*/
|
|
@@ -528,10 +563,12 @@ interface RouterConfig {
|
|
|
528
563
|
* Router mode.
|
|
529
564
|
*/
|
|
530
565
|
mode?: 'history' | 'hash' | 'memory'
|
|
566
|
+
|
|
531
567
|
/**
|
|
532
568
|
* Base path.
|
|
533
569
|
*/
|
|
534
570
|
basePath?: string
|
|
571
|
+
|
|
535
572
|
/**
|
|
536
573
|
* Initial routes.
|
|
537
574
|
*/
|
|
@@ -618,14 +655,7 @@ type QueryParams = Record<string, string | string[] | undefined>
|
|
|
618
655
|
Navigation guard result.
|
|
619
656
|
|
|
620
657
|
```typescript
|
|
621
|
-
type GuardResult =
|
|
622
|
-
| boolean
|
|
623
|
-
| string
|
|
624
|
-
| {
|
|
625
|
-
path: string
|
|
626
|
-
replace?: boolean
|
|
627
|
-
}
|
|
628
|
-
| void
|
|
658
|
+
type GuardResult = boolean | string | { path: string; replace?: boolean } | void
|
|
629
659
|
```
|
|
630
660
|
|
|
631
661
|
#### `NavigationGuard`
|
package/dist/index.d.ts
CHANGED
|
@@ -122,6 +122,26 @@
|
|
|
122
122
|
* // onPageChange={topics.setPage}; custom links use topics.href({ page: next }).
|
|
123
123
|
* ```
|
|
124
124
|
*
|
|
125
|
+
* @example
|
|
126
|
+
* One feed page on `/`, `/?view=following` and `/topics/:topic`: mount it on both routes
|
|
127
|
+
* with ONE config, so every tab link comes from `href`. With a separate config per route,
|
|
128
|
+
* the topic page cannot build the "all" link, and a hand-written one tends to keep the topic.
|
|
129
|
+
*
|
|
130
|
+
* ```tsx
|
|
131
|
+
* const feed = useListRoute({
|
|
132
|
+
* pageSize: 10,
|
|
133
|
+
* selections: {
|
|
134
|
+
* all: { path: '/', query: { view: undefined } },
|
|
135
|
+
* following: { path: '/', query: { view: 'following' } },
|
|
136
|
+
* topic: { path: '/topics/:topic' },
|
|
137
|
+
* },
|
|
138
|
+
* defaultSelection: 'all',
|
|
139
|
+
* })
|
|
140
|
+
* // On /topics/design?page=2: feed.selection is 'topic', feed.params.topic is 'design',
|
|
141
|
+
* // feed.href({ selection: 'all' }) is '/', feed.href({ page: 3 }) is '/topics/design?page=3'.
|
|
142
|
+
* // A topic link names its topic: feed.href({ selection: 'topic', params: { topic: name } }).
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
125
145
|
* @remarks
|
|
126
146
|
* - `useListRoute` derives state from the URL on every render, including Back/Forward.
|
|
127
147
|
* Do not mirror selection/page in local state or rewrite an explicit public view
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmLG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,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
|
@@ -122,6 +122,26 @@
|
|
|
122
122
|
* // onPageChange={topics.setPage}; custom links use topics.href({ page: next }).
|
|
123
123
|
* ```
|
|
124
124
|
*
|
|
125
|
+
* @example
|
|
126
|
+
* One feed page on `/`, `/?view=following` and `/topics/:topic`: mount it on both routes
|
|
127
|
+
* with ONE config, so every tab link comes from `href`. With a separate config per route,
|
|
128
|
+
* the topic page cannot build the "all" link, and a hand-written one tends to keep the topic.
|
|
129
|
+
*
|
|
130
|
+
* ```tsx
|
|
131
|
+
* const feed = useListRoute({
|
|
132
|
+
* pageSize: 10,
|
|
133
|
+
* selections: {
|
|
134
|
+
* all: { path: '/', query: { view: undefined } },
|
|
135
|
+
* following: { path: '/', query: { view: 'following' } },
|
|
136
|
+
* topic: { path: '/topics/:topic' },
|
|
137
|
+
* },
|
|
138
|
+
* defaultSelection: 'all',
|
|
139
|
+
* })
|
|
140
|
+
* // On /topics/design?page=2: feed.selection is 'topic', feed.params.topic is 'design',
|
|
141
|
+
* // feed.href({ selection: 'all' }) is '/', feed.href({ page: 3 }) is '/topics/design?page=3'.
|
|
142
|
+
* // A topic link names its topic: feed.href({ selection: 'topic', params: { topic: name } }).
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
125
145
|
* @remarks
|
|
126
146
|
* - `useListRoute` derives state from the URL on every render, including Back/Forward.
|
|
127
147
|
* Do not mirror selection/page in local state or rewrite an explicit public view
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmLG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAe5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
|