@sit-onyx/nuxt 1.0.0-alpha.4 → 1.0.0-alpha.40

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
@@ -10,10 +10,10 @@
10
10
 
11
11
  # @sit-onyx/nuxt
12
12
 
13
- A Nuxt module to easily integrate onyx into [Nuxt Js](https://nuxt.com/) projects.
13
+ A Nuxt module to easily integrate onyx into [Nuxt](https://nuxt.com/) projects.
14
14
  Created by [Schwarz IT](https://it.schwarz).
15
15
 
16
- ## Adding it to a nuxt project
16
+ ## Adding it to a Nuxt project
17
17
 
18
18
  Install the module in your Nuxt application with one command:
19
19
 
package/dist/module.d.mts CHANGED
@@ -1,6 +1,16 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
+ /**
5
+ * By default, the global onyx styles (`global.css` file) will be included
6
+ * which applies some global styles like background color and font styles.
7
+ * This is recommended when building a whole application with onyx.
8
+ *
9
+ * You can set this option to `true` to disable this.
10
+ *
11
+ * @see https://onyx.schwarz/development/#installation
12
+ */
13
+ disableGlobalStyles?: boolean;
4
14
  }
5
15
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
6
16
 
package/dist/module.d.ts CHANGED
@@ -1,6 +1,16 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
+ /**
5
+ * By default, the global onyx styles (`global.css` file) will be included
6
+ * which applies some global styles like background color and font styles.
7
+ * This is recommended when building a whole application with onyx.
8
+ *
9
+ * You can set this option to `true` to disable this.
10
+ *
11
+ * @see https://onyx.schwarz/development/#installation
12
+ */
13
+ disableGlobalStyles?: boolean;
4
14
  }
5
15
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
6
16
 
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "name": "onyx-nuxt",
2
+ "name": "@sit-onyx/nuxt",
3
3
  "configKey": "onyx",
4
- "version": "1.0.0-alpha.3",
4
+ "version": "1.0.0-alpha.39",
5
5
  "builder": {
6
- "@nuxt/module-builder": "0.7.0",
6
+ "@nuxt/module-builder": "0.8.0",
7
7
  "unbuild": "unknown"
8
8
  }
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,15 +1,20 @@
1
- import { defineNuxtModule, addComponent } from '@nuxt/kit';
1
+ import { defineNuxtModule, useLogger, createResolver, addComponent, addPlugin } from '@nuxt/kit';
2
2
  import * as onyx from 'sit-onyx';
3
3
 
4
4
  const module = defineNuxtModule({
5
5
  meta: {
6
- name: "onyx-nuxt",
6
+ name: "@sit-onyx/nuxt",
7
7
  configKey: "onyx"
8
8
  },
9
9
  defaults: {},
10
- setup(_options, nuxt) {
10
+ setup(options, nuxt) {
11
+ const logger = useLogger("@sit-onyx/nuxt");
12
+ const { resolve } = createResolver(import.meta.url);
11
13
  nuxt.options.postcss.plugins.cssnano = { preset: ["default", { calc: false }] };
12
14
  nuxt.options.css.push("sit-onyx/style.css");
15
+ if (!options.disableGlobalStyles) {
16
+ nuxt.options.css.push("sit-onyx/global.css");
17
+ }
13
18
  Object.keys(onyx).filter((namedExport) => namedExport.startsWith("Onyx")).forEach((component) => {
14
19
  addComponent({
15
20
  filePath: "sit-onyx",
@@ -17,7 +22,44 @@ const module = defineNuxtModule({
17
22
  export: component
18
23
  });
19
24
  });
25
+ const i18nModuleIndex = getModuleIndex(
26
+ nuxt.options.modules,
27
+ "@nuxtjs/i18n",
28
+ "@nuxtjs/i18n-edge"
29
+ );
30
+ const onyxModuleIndex = getModuleIndex(nuxt.options.modules, "@sit-onyx/nuxt");
31
+ if (onyxModuleIndex > i18nModuleIndex) {
32
+ logger.warn(
33
+ "The @nuxtjs/i18n module was registered before the @sit-onyx/nuxt module. The default translations of onyx won't be loaded, please register the @sit-onyx/nuxt module before @nuxtjs/i18n"
34
+ );
35
+ }
36
+ if (i18nModuleIndex >= 0) {
37
+ const registerOnyxLocales = (register) => {
38
+ register({
39
+ langDir: resolve("./runtime/locales"),
40
+ locales: [
41
+ // we need to use .js files instead of .ts because the .ts files would be compiled to .js in the build step, so
42
+ // when projects use this nuxt module, .ts files will throw a "can not find file" error
43
+ { code: "de-DE", file: "de-DE.js" },
44
+ { code: "en-US", file: "en-US.js" },
45
+ { code: "ko-KR", file: "ko-KR.js" }
46
+ ]
47
+ });
48
+ };
49
+ nuxt.hook("i18n:registerModule", registerOnyxLocales);
50
+ addPlugin({ src: resolve("./runtime/plugins/onyx") });
51
+ }
20
52
  }
21
53
  });
54
+ function getModuleIndex(modules, ...moduleNames) {
55
+ for (let i = 0; i < modules.length; i++) {
56
+ const module = modules[i];
57
+ if (typeof module === "string" && moduleNames.includes(module))
58
+ return i;
59
+ if (Array.isArray(module) && moduleNames.includes(module[0]))
60
+ return i;
61
+ }
62
+ return -1;
63
+ }
22
64
 
23
65
  export { module as default };
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ // @ts-check
2
+ import { defineI18nLocale } from "#i18n";
3
+ import deDE from "sit-onyx/locales/de-DE.json";
4
+
5
+ export default defineI18nLocale(() => {
6
+ return { onyx: deDE };
7
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ // @ts-check
2
+ import { defineI18nLocale } from "#i18n";
3
+ import enUS from "sit-onyx/locales/en-US.json";
4
+
5
+ export default defineI18nLocale(() => {
6
+ return { onyx: enUS };
7
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ // @ts-check
2
+ import { defineI18nLocale } from "#i18n";
3
+ import koKR from "sit-onyx/locales/ko-KR.json";
4
+
5
+ export default defineI18nLocale(() => {
6
+ return { onyx: koKR };
7
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,25 @@
1
+ import { computed, watchEffect } from "#imports";
2
+ import { defineNuxtPlugin, useNuxtApp } from "nuxt/app";
3
+ import { provideI18n, syncGlobalOptionalText } from "sit-onyx";
4
+ export default defineNuxtPlugin({
5
+ name: "onyx:plugin",
6
+ // @ts-ignore: dependency comes from @nuxtjs/i18n
7
+ dependsOn: ["i18n:plugin"],
8
+ setup: (app) => {
9
+ const { t: translate, localeProperties } = useNuxtApp().$i18n;
10
+ const t = computed(() => {
11
+ return (key, placeholders) => {
12
+ return translate(`onyx.${key}`, placeholders?.n ?? 1, { named: placeholders });
13
+ };
14
+ });
15
+ provideI18n(app.vueApp, {
16
+ locale: computed(() => localeProperties.value.iso ?? "en-US"),
17
+ t
18
+ });
19
+ app.hook("app:beforeMount", () => {
20
+ watchEffect(() => {
21
+ syncGlobalOptionalText(translate(`onyx.optional`));
22
+ });
23
+ });
24
+ }
25
+ });
package/dist/types.d.mts CHANGED
@@ -1,16 +1 @@
1
-
2
- import type { ModuleOptions } from './module.js'
3
-
4
-
5
- declare module '@nuxt/schema' {
6
- interface NuxtConfig { ['onyx']?: Partial<ModuleOptions> }
7
- interface NuxtOptions { ['onyx']?: ModuleOptions }
8
- }
9
-
10
- declare module 'nuxt/schema' {
11
- interface NuxtConfig { ['onyx']?: Partial<ModuleOptions> }
12
- interface NuxtOptions { ['onyx']?: ModuleOptions }
13
- }
14
-
15
-
16
- export type { ModuleOptions, default } from './module.js'
1
+ export { type ModuleOptions, default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1,16 +1 @@
1
-
2
- import type { ModuleOptions } from './module'
3
-
4
-
5
- declare module '@nuxt/schema' {
6
- interface NuxtConfig { ['onyx']?: Partial<ModuleOptions> }
7
- interface NuxtOptions { ['onyx']?: ModuleOptions }
8
- }
9
-
10
- declare module 'nuxt/schema' {
11
- interface NuxtConfig { ['onyx']?: Partial<ModuleOptions> }
12
- interface NuxtOptions { ['onyx']?: ModuleOptions }
13
- }
14
-
15
-
16
- export type { ModuleOptions, default } from './module'
1
+ export { type ModuleOptions, default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sit-onyx/nuxt",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.40",
4
4
  "description": "A Nuxt module to easily integrate onyx into Nuxt projects",
5
5
  "author": "Schwarz IT KG",
6
6
  "license": "Apache-2.0",
@@ -26,17 +26,19 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@nuxt/kit": "^3.11.2"
29
+ "@nuxt/kit": "^3.12.2"
30
30
  },
31
31
  "devDependencies": {
32
- "@nuxt/devtools": "^1.3.3",
33
- "@nuxt/module-builder": "~0.7.0",
34
- "@nuxt/schema": "^3.11.2",
32
+ "@nuxt/devtools": "^1.3.7",
33
+ "@nuxt/module-builder": "~0.8.0",
34
+ "@nuxt/schema": "^3.12.2",
35
35
  "@nuxt/test-utils": "^3.13.1",
36
- "nuxt": "^3.11.2"
36
+ "@nuxtjs/i18n": "^8.3.1",
37
+ "nuxt": "^3.12.2",
38
+ "vue-i18n": "^9.13.1"
37
39
  },
38
40
  "peerDependencies": {
39
- "sit-onyx": "^1.0.0-alpha.124"
41
+ "sit-onyx": "^1.0.0-alpha.159"
40
42
  },
41
43
  "scripts": {
42
44
  "dev": "nuxi dev playground",