@molecule/app-routing-react-router 1.2.3 → 1.2.5

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
@@ -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-08T06:10:19.355Z
6
+ Generated: 2026-11-09T16:18:22.180Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-routing-react-router
@@ -23,8 +23,14 @@ so multiple consumers cannot overwrite the global router bond.
23
23
 
24
24
  **Paginated or filtered page? Use `useListRoute` for its URL state.** It reads
25
25
  page, filters and selected views from the current URL; builds links that retain
26
- the current path/filters; and resets page when a filter or view changes. Declare
27
- path variants explicitly instead of translating API filters into browser URLs.
26
+ the current path/filters; and resets page when a filter or view changes.
27
+ Start with `const pages = useListRoute()`; `filters` and `selections` are optional.
28
+ On `/category/books` matched by `/category/:slug`, `pages.href({ page: 2 })` is
29
+ `/category/books?page=2` and `pages.params.slug` is `'books'`. The route's path
30
+ params need no extra config and never become duplicate query filters. On
31
+ `/?view=mine`, the same call is `/?view=mine&page=2`: existing query keys keep
32
+ their order, with page last. Page one omits `page`; unrelated queries and hash
33
+ survive. Add `path` when changing path params, or `selections` when linking views.
28
34
  It works under ordinary `BrowserRouter` without a data router or an extra provider.
29
35
 
30
36
  > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
@@ -162,6 +168,25 @@ const topics = useListRoute({
162
168
  // onPageChange={topics.setPage}; custom links use topics.href({ page: next }).
163
169
  ```
164
170
 
171
+ One feed page on `/`, `/?view=following` and `/topics/:topic`: mount it on both routes
172
+ with ONE config, so every tab link comes from `href`. With a separate config per route,
173
+ the topic page cannot build the "all" link, and a hand-written one tends to keep the topic.
174
+
175
+ ```tsx
176
+ const feed = useListRoute({
177
+ pageSize: 10,
178
+ selections: {
179
+ all: { path: '/', query: { view: undefined } },
180
+ following: { path: '/', query: { view: 'following' } },
181
+ topic: { path: '/topics/:topic' },
182
+ },
183
+ defaultSelection: 'all',
184
+ })
185
+ // On /topics/design?page=2: feed.selection is 'topic', feed.params.topic is 'design',
186
+ // feed.href({ selection: 'all' }) is '/', feed.href({ page: 3 }) is '/topics/design?page=3'.
187
+ // A topic link names its topic: feed.href({ selection: 'topic', params: { topic: name } }).
188
+ ```
189
+
165
190
  ## Type
166
191
 
167
192
  `provider`
package/dist/index.d.ts CHANGED
@@ -14,8 +14,14 @@
14
14
  *
15
15
  * **Paginated or filtered page? Use `useListRoute` for its URL state.** It reads
16
16
  * page, filters and selected views from the current URL; builds links that retain
17
- * the current path/filters; and resets page when a filter or view changes. Declare
18
- * path variants explicitly instead of translating API filters into browser URLs.
17
+ * the current path/filters; and resets page when a filter or view changes.
18
+ * Start with `const pages = useListRoute()`; `filters` and `selections` are optional.
19
+ * On `/category/books` matched by `/category/:slug`, `pages.href({ page: 2 })` is
20
+ * `/category/books?page=2` and `pages.params.slug` is `'books'`. The route's path
21
+ * params need no extra config and never become duplicate query filters. On
22
+ * `/?view=mine`, the same call is `/?view=mine&page=2`: existing query keys keep
23
+ * their order, with page last. Page one omits `page`; unrelated queries and hash
24
+ * survive. Add `path` when changing path params, or `selections` when linking views.
19
25
  * It works under ordinary `BrowserRouter` without a data router or an extra provider.
20
26
  *
21
27
  * @example
@@ -122,6 +128,26 @@
122
128
  * // onPageChange={topics.setPage}; custom links use topics.href({ page: next }).
123
129
  * ```
124
130
  *
131
+ * @example
132
+ * One feed page on `/`, `/?view=following` and `/topics/:topic`: mount it on both routes
133
+ * with ONE config, so every tab link comes from `href`. With a separate config per route,
134
+ * the topic page cannot build the "all" link, and a hand-written one tends to keep the topic.
135
+ *
136
+ * ```tsx
137
+ * const feed = useListRoute({
138
+ * pageSize: 10,
139
+ * selections: {
140
+ * all: { path: '/', query: { view: undefined } },
141
+ * following: { path: '/', query: { view: 'following' } },
142
+ * topic: { path: '/topics/:topic' },
143
+ * },
144
+ * defaultSelection: 'all',
145
+ * })
146
+ * // On /topics/design?page=2: feed.selection is 'topic', feed.params.topic is 'design',
147
+ * // feed.href({ selection: 'all' }) is '/', feed.href({ page: 3 }) is '/topics/design?page=3'.
148
+ * // A topic link names its topic: feed.href({ selection: 'topic', params: { topic: name } }).
149
+ * ```
150
+ *
125
151
  * @remarks
126
152
  * - `useListRoute` derives state from the URL on every render, including Back/Forward.
127
153
  * Do not mirror selection/page in local state or rewrite an explicit public view
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+JG;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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyLG;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
@@ -14,8 +14,14 @@
14
14
  *
15
15
  * **Paginated or filtered page? Use `useListRoute` for its URL state.** It reads
16
16
  * page, filters and selected views from the current URL; builds links that retain
17
- * the current path/filters; and resets page when a filter or view changes. Declare
18
- * path variants explicitly instead of translating API filters into browser URLs.
17
+ * the current path/filters; and resets page when a filter or view changes.
18
+ * Start with `const pages = useListRoute()`; `filters` and `selections` are optional.
19
+ * On `/category/books` matched by `/category/:slug`, `pages.href({ page: 2 })` is
20
+ * `/category/books?page=2` and `pages.params.slug` is `'books'`. The route's path
21
+ * params need no extra config and never become duplicate query filters. On
22
+ * `/?view=mine`, the same call is `/?view=mine&page=2`: existing query keys keep
23
+ * their order, with page last. Page one omits `page`; unrelated queries and hash
24
+ * survive. Add `path` when changing path params, or `selections` when linking views.
19
25
  * It works under ordinary `BrowserRouter` without a data router or an extra provider.
20
26
  *
21
27
  * @example
@@ -122,6 +128,26 @@
122
128
  * // onPageChange={topics.setPage}; custom links use topics.href({ page: next }).
123
129
  * ```
124
130
  *
131
+ * @example
132
+ * One feed page on `/`, `/?view=following` and `/topics/:topic`: mount it on both routes
133
+ * with ONE config, so every tab link comes from `href`. With a separate config per route,
134
+ * the topic page cannot build the "all" link, and a hand-written one tends to keep the topic.
135
+ *
136
+ * ```tsx
137
+ * const feed = useListRoute({
138
+ * pageSize: 10,
139
+ * selections: {
140
+ * all: { path: '/', query: { view: undefined } },
141
+ * following: { path: '/', query: { view: 'following' } },
142
+ * topic: { path: '/topics/:topic' },
143
+ * },
144
+ * defaultSelection: 'all',
145
+ * })
146
+ * // On /topics/design?page=2: feed.selection is 'topic', feed.params.topic is 'design',
147
+ * // feed.href({ selection: 'all' }) is '/', feed.href({ page: 3 }) is '/topics/design?page=3'.
148
+ * // A topic link names its topic: feed.href({ selection: 'topic', params: { topic: name } }).
149
+ * ```
150
+ *
125
151
  * @remarks
126
152
  * - `useListRoute` derives state from the URL on every render, including Back/Forward.
127
153
  * 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+JG;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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyLG;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-routing-react-router",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "React Router v7 provider for @molecule/app-routing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",