@llui/transitions 0.0.14 → 0.0.15

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.
@@ -11,19 +11,43 @@ export interface RouteTransitionOptions {
11
11
  }
12
12
  /**
13
13
  * Convenience wrapper that returns `{ enter, leave }` hooks suitable for
14
- * spreading into a `branch()` call to animate page transitions.
14
+ * animating page-to-page transitions. Used in two ways:
15
15
  *
16
- * Can be called two ways:
16
+ * **Manual branch-based routing:** spread the result into a `branch()`
17
+ * call that switches on the current route key. The runtime invokes
18
+ * `enter` / `leave` as the branch swaps cases.
17
19
  *
18
- * 1. With route-specific options (produces a fade + optional slide):
19
- * ```ts
20
- * branch({ on, cases, ...routeTransition({ duration: 200 }) })
21
- * ```
20
+ * ```ts
21
+ * branch({
22
+ * on: (s) => s.route,
23
+ * cases: { '/': home, '/about': about },
24
+ * ...routeTransition({ duration: 200 }),
25
+ * })
26
+ * ```
22
27
  *
23
- * 2. With a pre-built `TransitionOptions` (e.g. from any preset):
24
- * ```ts
25
- * branch({ on, cases, ...routeTransition(fade({ duration: 200 })) })
26
- * ```
28
+ * **Vike filesystem routing (`@llui/vike`):** Vike's `onRenderClient`
29
+ * doesn't consume `{ enter, leave }` directly because each page is its
30
+ * own component and the swap goes through dispose + clear + mount. Use
31
+ * `fromTransition` from `@llui/vike/client` to adapt the transition to
32
+ * the `onLeave` / `onEnter` hook shape:
33
+ *
34
+ * ```ts
35
+ * // pages/+onRenderClient.ts
36
+ * import { createOnRenderClient, fromTransition } from '@llui/vike/client'
37
+ * import { routeTransition } from '@llui/transitions'
38
+ *
39
+ * export const onRenderClient = createOnRenderClient({
40
+ * ...fromTransition(routeTransition({ duration: 200 })),
41
+ * })
42
+ * ```
43
+ *
44
+ * The vike variant operates on the container element itself (the `#app`
45
+ * div) — its opacity / transform fades out the whole page, then the new
46
+ * page fades in when it mounts.
47
+ *
48
+ * Both call forms also accept a pre-built `TransitionOptions` from any
49
+ * preset (`fade`, `slide`, `scale`, …) — `routeTransition` will pass it
50
+ * through unchanged.
27
51
  */
28
52
  export declare function routeTransition(opts?: RouteTransitionOptions | TransitionOptions): TransitionOptions;
29
53
  //# sourceMappingURL=route-transition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route-transition.d.ts","sourceRoot":"","sources":["../src/route-transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAKlD,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,IAAI,CAAC,EAAE,sBAAsB,GAAG,iBAAiB,GAChD,iBAAiB,CAyBnB"}
1
+ {"version":3,"file":"route-transition.d.ts","sourceRoot":"","sources":["../src/route-transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAKlD,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,eAAe,CAC7B,IAAI,CAAC,EAAE,sBAAsB,GAAG,iBAAiB,GAChD,iBAAiB,CAyBnB"}
@@ -3,19 +3,43 @@ import { slide } from './presets.js';
3
3
  import { mergeTransitions } from './flip.js';
4
4
  /**
5
5
  * Convenience wrapper that returns `{ enter, leave }` hooks suitable for
6
- * spreading into a `branch()` call to animate page transitions.
6
+ * animating page-to-page transitions. Used in two ways:
7
7
  *
8
- * Can be called two ways:
8
+ * **Manual branch-based routing:** spread the result into a `branch()`
9
+ * call that switches on the current route key. The runtime invokes
10
+ * `enter` / `leave` as the branch swaps cases.
9
11
  *
10
- * 1. With route-specific options (produces a fade + optional slide):
11
- * ```ts
12
- * branch({ on, cases, ...routeTransition({ duration: 200 }) })
13
- * ```
12
+ * ```ts
13
+ * branch({
14
+ * on: (s) => s.route,
15
+ * cases: { '/': home, '/about': about },
16
+ * ...routeTransition({ duration: 200 }),
17
+ * })
18
+ * ```
14
19
  *
15
- * 2. With a pre-built `TransitionOptions` (e.g. from any preset):
16
- * ```ts
17
- * branch({ on, cases, ...routeTransition(fade({ duration: 200 })) })
18
- * ```
20
+ * **Vike filesystem routing (`@llui/vike`):** Vike's `onRenderClient`
21
+ * doesn't consume `{ enter, leave }` directly because each page is its
22
+ * own component and the swap goes through dispose + clear + mount. Use
23
+ * `fromTransition` from `@llui/vike/client` to adapt the transition to
24
+ * the `onLeave` / `onEnter` hook shape:
25
+ *
26
+ * ```ts
27
+ * // pages/+onRenderClient.ts
28
+ * import { createOnRenderClient, fromTransition } from '@llui/vike/client'
29
+ * import { routeTransition } from '@llui/transitions'
30
+ *
31
+ * export const onRenderClient = createOnRenderClient({
32
+ * ...fromTransition(routeTransition({ duration: 200 })),
33
+ * })
34
+ * ```
35
+ *
36
+ * The vike variant operates on the container element itself (the `#app`
37
+ * div) — its opacity / transform fades out the whole page, then the new
38
+ * page fades in when it mounts.
39
+ *
40
+ * Both call forms also accept a pre-built `TransitionOptions` from any
41
+ * preset (`fade`, `slide`, `scale`, …) — `routeTransition` will pass it
42
+ * through unchanged.
19
43
  */
20
44
  export function routeTransition(opts) {
21
45
  // If opts already has enter/leave, treat it as a pre-built TransitionOptions.
@@ -1 +1 @@
1
- {"version":3,"file":"route-transition.js","sourceRoot":"","sources":["../src/route-transition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAa5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAiD;IAEjD,8EAA8E;IAC9E,IAAI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC;QACjD,OAAO,IAAyB,CAAA;IAClC,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,IAAI,IAAI,EAAE,CAA2B,CAAA;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAA;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,UAAU,CAAA;IAC1C,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,KAAK,KAAK,CAAA;IACxC,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,EAAE,CAAA;IAEhD,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAExC,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAA;IAE5B,MAAM,MAAM,GAAG,KAAK,CAAC;QACnB,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,aAAa;QACvB,QAAQ;QACR,MAAM;QACN,IAAI,EAAE,KAAK;KACZ,CAAC,CAAA;IAEF,OAAO,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AACxC,CAAC","sourcesContent":["import type { TransitionOptions } from '@llui/dom'\nimport { fade } from './presets.js'\nimport { slide } from './presets.js'\nimport { mergeTransitions } from './flip.js'\n\nexport interface RouteTransitionOptions {\n /** Duration in milliseconds (default: 250). */\n duration?: number\n /** Easing function (default: 'ease-out'). */\n easing?: string\n /** Enable a slight vertical slide alongside the fade (default: true). */\n slide?: boolean\n /** Slide distance in pixels (default: 12). */\n slideDistance?: number\n}\n\n/**\n * Convenience wrapper that returns `{ enter, leave }` hooks suitable for\n * spreading into a `branch()` call to animate page transitions.\n *\n * Can be called two ways:\n *\n * 1. With route-specific options (produces a fade + optional slide):\n * ```ts\n * branch({ on, cases, ...routeTransition({ duration: 200 }) })\n * ```\n *\n * 2. With a pre-built `TransitionOptions` (e.g. from any preset):\n * ```ts\n * branch({ on, cases, ...routeTransition(fade({ duration: 200 })) })\n * ```\n */\nexport function routeTransition(\n opts?: RouteTransitionOptions | TransitionOptions,\n): TransitionOptions {\n // If opts already has enter/leave, treat it as a pre-built TransitionOptions.\n if (opts && ('enter' in opts || 'leave' in opts)) {\n return opts as TransitionOptions\n }\n\n const config = (opts ?? {}) as RouteTransitionOptions\n const duration = config.duration ?? 250\n const easing = config.easing ?? 'ease-out'\n const withSlide = config.slide !== false\n const slideDistance = config.slideDistance ?? 12\n\n const fadeT = fade({ duration, easing })\n\n if (!withSlide) return fadeT\n\n const slideT = slide({\n direction: 'up',\n distance: slideDistance,\n duration,\n easing,\n fade: false,\n })\n\n return mergeTransitions(fadeT, slideT)\n}\n"]}
1
+ {"version":3,"file":"route-transition.js","sourceRoot":"","sources":["../src/route-transition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAa5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAiD;IAEjD,8EAA8E;IAC9E,IAAI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC;QACjD,OAAO,IAAyB,CAAA;IAClC,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,IAAI,IAAI,EAAE,CAA2B,CAAA;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAA;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,UAAU,CAAA;IAC1C,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,KAAK,KAAK,CAAA;IACxC,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,EAAE,CAAA;IAEhD,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAExC,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAA;IAE5B,MAAM,MAAM,GAAG,KAAK,CAAC;QACnB,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,aAAa;QACvB,QAAQ;QACR,MAAM;QACN,IAAI,EAAE,KAAK;KACZ,CAAC,CAAA;IAEF,OAAO,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AACxC,CAAC","sourcesContent":["import type { TransitionOptions } from '@llui/dom'\nimport { fade } from './presets.js'\nimport { slide } from './presets.js'\nimport { mergeTransitions } from './flip.js'\n\nexport interface RouteTransitionOptions {\n /** Duration in milliseconds (default: 250). */\n duration?: number\n /** Easing function (default: 'ease-out'). */\n easing?: string\n /** Enable a slight vertical slide alongside the fade (default: true). */\n slide?: boolean\n /** Slide distance in pixels (default: 12). */\n slideDistance?: number\n}\n\n/**\n * Convenience wrapper that returns `{ enter, leave }` hooks suitable for\n * animating page-to-page transitions. Used in two ways:\n *\n * **Manual branch-based routing:** spread the result into a `branch()`\n * call that switches on the current route key. The runtime invokes\n * `enter` / `leave` as the branch swaps cases.\n *\n * ```ts\n * branch({\n * on: (s) => s.route,\n * cases: { '/': home, '/about': about },\n * ...routeTransition({ duration: 200 }),\n * })\n * ```\n *\n * **Vike filesystem routing (`@llui/vike`):** Vike's `onRenderClient`\n * doesn't consume `{ enter, leave }` directly because each page is its\n * own component and the swap goes through dispose + clear + mount. Use\n * `fromTransition` from `@llui/vike/client` to adapt the transition to\n * the `onLeave` / `onEnter` hook shape:\n *\n * ```ts\n * // pages/+onRenderClient.ts\n * import { createOnRenderClient, fromTransition } from '@llui/vike/client'\n * import { routeTransition } from '@llui/transitions'\n *\n * export const onRenderClient = createOnRenderClient({\n * ...fromTransition(routeTransition({ duration: 200 })),\n * })\n * ```\n *\n * The vike variant operates on the container element itself (the `#app`\n * div) — its opacity / transform fades out the whole page, then the new\n * page fades in when it mounts.\n *\n * Both call forms also accept a pre-built `TransitionOptions` from any\n * preset (`fade`, `slide`, `scale`, …) — `routeTransition` will pass it\n * through unchanged.\n */\nexport function routeTransition(\n opts?: RouteTransitionOptions | TransitionOptions,\n): TransitionOptions {\n // If opts already has enter/leave, treat it as a pre-built TransitionOptions.\n if (opts && ('enter' in opts || 'leave' in opts)) {\n return opts as TransitionOptions\n }\n\n const config = (opts ?? {}) as RouteTransitionOptions\n const duration = config.duration ?? 250\n const easing = config.easing ?? 'ease-out'\n const withSlide = config.slide !== false\n const slideDistance = config.slideDistance ?? 12\n\n const fadeT = fade({ duration, easing })\n\n if (!withSlide) return fadeT\n\n const slideT = slide({\n direction: 'up',\n distance: slideDistance,\n duration,\n easing,\n fade: false,\n })\n\n return mergeTransitions(fadeT, slideT)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llui/transitions",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,12 +11,12 @@
11
11
  }
12
12
  },
13
13
  "peerDependencies": {
14
- "@llui/dom": "^0.0.14"
14
+ "@llui/dom": "^0.0.15"
15
15
  },
16
16
  "devDependencies": {
17
17
  "typescript": "^6.0.0",
18
18
  "vitest": "^4.1.2",
19
- "@llui/dom": "0.0.14"
19
+ "@llui/dom": "0.0.15"
20
20
  },
21
21
  "sideEffects": false,
22
22
  "description": "LLui animation helpers — transition(), fade, slide, scale, collapse for branch/show/each",