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

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, addComponentsDir } from '@nuxt/kit';
3
3
  import * as onyx from 'sit-onyx';
4
4
 
5
5
  const module$1 = defineNuxtModule({
@@ -58,6 +58,13 @@ 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
+ ]);
67
+ addComponentsDir({ path: resolve("./runtime/components") });
61
68
  }
62
69
  });
63
70
  function getModuleIndex(modules, ...moduleNames) {
@@ -0,0 +1,7 @@
1
+ type ErrorLike = Pick<Error, "message">;
2
+ type __VLS_Props = {
3
+ error: ErrorLike;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,51 @@
1
+ <script setup>
2
+ import { useLocalePath } from "#i18n";
3
+ import { clearError } from "#imports";
4
+ const props = defineProps({
5
+ error: { type: Object, required: true }
6
+ });
7
+ const localePath = useLocalePath();
8
+ const handleBackHome = () => clearError({ redirect: localePath("/") });
9
+ </script>
10
+
11
+ <template>
12
+ <div class="onyx-error onyx-component">
13
+ <OnyxErrorSVG class="onyx-error__image" />
14
+
15
+ <div class="onyx-error__headline">
16
+ <OnyxHeadline is="h1">{{ props.error.message }}</OnyxHeadline>
17
+ <OnyxButton :label="$t('onyx.errors.backToHome')" @click="handleBackHome" />
18
+ </div>
19
+
20
+ <OnyxAccordion>
21
+ <OnyxAccordionItem value="details">
22
+ <template #header>{{ $t("onyx.errors.technicalDetails") }}</template>
23
+ <pre class="onyx-error__details">{{ JSON.stringify(props.error, null, 2) }}</pre>
24
+ </OnyxAccordionItem>
25
+ </OnyxAccordion>
26
+ </div>
27
+ </template>
28
+
29
+ <style scoped>
30
+ .onyx-error {
31
+ display: flex;
32
+ flex-direction: column;
33
+ align-items: center;
34
+ gap: var(--onyx-density-3xl);
35
+ }
36
+ .onyx-error__image {
37
+ width: 32rem;
38
+ display: block;
39
+ }
40
+ .onyx-error__headline {
41
+ display: flex;
42
+ flex-direction: column;
43
+ align-items: center;
44
+ gap: var(--onyx-density-md);
45
+ }
46
+ .onyx-error__details {
47
+ white-space: pre-wrap;
48
+ overflow-wrap: anywhere;
49
+ font-family: var(--onyx-font-family-mono);
50
+ }
51
+ </style>
@@ -0,0 +1,7 @@
1
+ type ErrorLike = Pick<Error, "message">;
2
+ type __VLS_Props = {
3
+ error: ErrorLike;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -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-20261015154043",
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-20261015154043",
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-20261015154043"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=20"