@inglorious/ui 9.6.0 → 9.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/ui",
3
- "version": "9.6.0",
3
+ "version": "9.7.0",
4
4
  "description": "A design system for Inglorious Web with render-function components and customizable themes",
5
5
  "author": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -314,21 +314,21 @@
314
314
  "**/*.css"
315
315
  ],
316
316
  "peerDependencies": {
317
- "@inglorious/store": "12.0.0",
317
+ "@inglorious/store": "12.1.0",
318
318
  "@inglorious/utils": "5.1.0",
319
- "@inglorious/web": "6.9.1"
319
+ "@inglorious/web": "6.10.0"
320
320
  },
321
321
  "devDependencies": {
322
322
  "@iconify-icons/fa7-brands": "^2.0.0",
323
323
  "@iconify-icons/fa7-regular": "^2.0.0",
324
324
  "@iconify-icons/fa7-solid": "^2.0.0",
325
325
  "@iconify-icons/material-symbols": "^2.0.6",
326
- "@inglorious/charts": "12.2.2",
326
+ "@inglorious/charts": "12.2.3",
327
327
  "@inglorious/eslint-config": "1.2.0",
328
- "@inglorious/store": "12.0.0",
328
+ "@inglorious/store": "12.1.0",
329
329
  "@inglorious/vite-plugin-jsx": "2.0.5",
330
330
  "@inglorious/vite-plugin-vue": "1.0.6",
331
- "@inglorious/web": "6.9.1",
331
+ "@inglorious/web": "6.10.0",
332
332
  "@storybook/addon-docs": "^10.6.0",
333
333
  "@storybook/web-components-vite": "^10.6.0",
334
334
  "happy-dom": "^20.14.0",
@@ -2,10 +2,11 @@
2
2
  * @typedef {import("../../../types/navigation/view-transitions").TransitionsStore} Store
3
3
  * @typedef {import("../../../types/navigation/view-transitions").ViewTransitionType} ViewTransitionType
4
4
  * @typedef {import("../../../types/navigation/view-transitions").TransitionsOptions} TransitionsOptions
5
+ * @typedef {(store: Store) => Store} Middleware
5
6
  */
6
7
 
7
8
  /**
8
- * Wraps a store so that the renders which follow a navigation are run inside a
9
+ * A store middleware that runs the renders which follow a navigation inside a
9
10
  * view transition, tagged with the direction they navigated in. Pair it with
10
11
  * `style.css` from this package, which turns those tags into a slide.
11
12
  *
@@ -20,7 +21,7 @@
20
21
  * import { withTransitions } from "@inglorious/ui/view-transitions"
21
22
  * import "@inglorious/ui/view-transitions.css"
22
23
  *
23
- * mount(withTransitions(store), renderApp, document.getElementById("root"))
24
+ * const store = createStore({ types, entities, middlewares: [withTransitions()] })
24
25
  *
25
26
  * Pass `routes` to choose which navigations animate; the rest change page
26
27
  * without a transition. A list of route names animates every navigation into
@@ -30,20 +31,23 @@
30
31
  *
31
32
  * @example
32
33
  * // Slide into and out of detail pages; switch tabs instantly.
33
- * withTransitions(store, { routes: ["eventDetail", "userDetail"] })
34
+ * withTransitions({ routes: ["eventDetail", "userDetail"] })
34
35
  *
35
36
  * @example
36
37
  * // Slide only when going deeper or coming back up, never sideways.
37
- * withTransitions(store, {
38
+ * withTransitions({
38
39
  * routes: ({ from, to }) => from.path.startsWith(to.path) || to.path.startsWith(from.path),
39
40
  * })
40
41
  *
41
- * @param {Store} store - The store to wrap.
42
42
  * @param {TransitionsOptions} [options]
43
- * @returns {Store} The same store, with a wrapped `subscribe`.
44
- * @throws {Error} If the store has no `Router` type.
43
+ * @returns {Middleware} The middleware, which returns the store it is given with a
44
+ * wrapped `subscribe`, and throws if the store has no `Router` type.
45
45
  */
46
- export function withTransitions(store, { routes } = {}) {
46
+ export function withTransitions({ routes } = {}) {
47
+ return (store) => wrapStore(store, routes)
48
+ }
49
+
50
+ function wrapStore(store, routes) {
47
51
  if (!store.getType("Router")) {
48
52
  throw new Error(
49
53
  '[withTransitions] Requires the "Router" type from @inglorious/web. The ' +
@@ -33,11 +33,10 @@ export interface TransitionsOptions {
33
33
  }
34
34
 
35
35
  export interface WithTransitions {
36
- /** Returns the store it was given, so it still fits wherever the store did, such as `mount`. */
37
- <Store extends TransitionsStore<any>>(
38
- store: Store,
36
+ /** A store middleware, for the `middlewares` of `createStore`. It returns the store it is given. */
37
+ (
39
38
  options?: TransitionsOptions,
40
- ): Store
39
+ ): <Store extends TransitionsStore<any>>(store: Store) => Store
41
40
  }
42
41
 
43
42
  export declare const withTransitions: WithTransitions