@sit-onyx/nuxt 1.1.2 → 1.2.0-dev-20261015143348

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/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { stat } from 'node:fs/promises';
2
- import { defineNuxtModule, useLogger, createResolver, addComponent, addPlugin } from '@nuxt/kit';
2
+ import { defineNuxtModule, useLogger, createResolver, addComponent, addPlugin, addImports } from '@nuxt/kit';
3
3
  import * as onyx from 'sit-onyx';
4
4
 
5
5
  const module$1 = defineNuxtModule({
@@ -58,6 +58,12 @@ const module$1 = defineNuxtModule({
58
58
  nuxt.hook("i18n:registerModule", registerOnyxLocales);
59
59
  }
60
60
  addPlugin({ src: resolve("./runtime/plugins/onyx") });
61
+ addImports([
62
+ {
63
+ from: resolve("./runtime/utils/scroll-behavior"),
64
+ name: "createOnyxScrollBehavior"
65
+ }
66
+ ]);
61
67
  }
62
68
  });
63
69
  function getModuleIndex(modules, ...moduleNames) {
@@ -0,0 +1,13 @@
1
+ import type { RouterConfig } from "nuxt/schema";
2
+ type CreateOnyxScrollBehaviorOptions = {
3
+ onBeforeScroll?: (scrollContainer: HTMLElement, ...params: Parameters<NonNullable<RouterConfig["scrollBehavior"]>>) => Promise<void>;
4
+ };
5
+ /**
6
+ * Creates a Vue Router scrollBehavior for applying router scroll behavior when using the onyx
7
+ * design system. Note: The default Vue Router scroll behavior does not work because onyx uses a
8
+ * different scroll container (.onyx-page__main) instead of the html/body element.
9
+ *
10
+ * Will make sure the scrolling is done after the async page is ready.
11
+ */
12
+ export declare function createOnyxScrollBehavior(options?: CreateOnyxScrollBehaviorOptions): RouterConfig["scrollBehavior"];
13
+ export {};
@@ -0,0 +1,29 @@
1
+ import { nextTick, useNuxtApp } from "#imports";
2
+ export function createOnyxScrollBehavior(options) {
3
+ return (to, from, savedPosition) => {
4
+ const nuxtApp = useNuxtApp();
5
+ return new Promise((resolve) => {
6
+ nuxtApp.hooks.hookOnce("page:finish", async () => {
7
+ await nextTick();
8
+ const scrollContainer = document.querySelector(".onyx-page__main");
9
+ if (!scrollContainer) {
10
+ resolve(false);
11
+ return;
12
+ }
13
+ await options?.onBeforeScroll?.(scrollContainer, to, from, savedPosition);
14
+ const behavior = "instant";
15
+ const hash = to.hash || window.location.hash || void 0;
16
+ const hashElement = hash ? scrollContainer.querySelector(hash) : void 0;
17
+ if (hashElement) {
18
+ return hashElement.scrollIntoView({ block: "start", behavior });
19
+ }
20
+ if (savedPosition) {
21
+ scrollContainer.scrollTo(savedPosition);
22
+ } else {
23
+ scrollContainer.scrollTo({ left: 0, top: 0, behavior });
24
+ }
25
+ resolve(false);
26
+ });
27
+ });
28
+ };
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sit-onyx/nuxt",
3
- "version": "1.1.2",
3
+ "version": "1.2.0-dev-20261015143348",
4
4
  "description": "A Nuxt module to easily integrate onyx into Nuxt projects",
5
5
  "homepage": "https://onyx.schwarz",
6
6
  "bugs": {
@@ -25,21 +25,21 @@
25
25
  }
26
26
  },
27
27
  "devDependencies": {
28
- "@nuxt/devtools": "^3.4.1",
29
- "@nuxt/kit": "^4.5.2",
28
+ "@nuxt/devtools": "^3.4.2",
29
+ "@nuxt/kit": "^4.6.1",
30
30
  "@nuxt/module-builder": "^1.0.3",
31
- "@nuxt/schema": "^4.5.2",
32
- "@nuxt/test-utils": "^4.1.0",
31
+ "@nuxt/schema": "^4.6.1",
32
+ "@nuxt/test-utils": "^4.3.3",
33
33
  "@nuxtjs/i18n": "^10.6.0",
34
+ "@sit-onyx/shared": "^0.1.0",
34
35
  "nuxt": "4.5.2",
36
+ "sit-onyx": "^1.21.1-dev-20261015143348",
35
37
  "typescript": "6.0.3",
36
38
  "unbuild": "^3.6.1",
37
- "vue-i18n": "^11.4.8",
38
- "@sit-onyx/shared": "^0.1.0",
39
- "sit-onyx": "^1.19.0"
39
+ "vue-i18n": "^11.4.14"
40
40
  },
41
41
  "peerDependencies": {
42
- "sit-onyx": "^1.19.0"
42
+ "sit-onyx": "^1.21.1-dev-20261015143348"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=20"