@hostlink/nuxt-light 1.9.2 → 1.10.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/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.9.2"
4
+ "version": "1.10.0"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addComponentsDir, addImports, addPlugin, addVitePlugin } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addComponentsDir, addImports, addVitePlugin, resolveFiles, addPlugin } from '@nuxt/kit';
2
2
  import { quasar } from '@quasar/vite-plugin';
3
3
 
4
4
  const module = defineNuxtModule({
@@ -8,7 +8,7 @@ const module = defineNuxtModule({
8
8
  },
9
9
  // Default configuration options of the Nuxt module
10
10
  defaults: {},
11
- setup(options, nuxt) {
11
+ async setup(options, nuxt) {
12
12
  const resolver = createResolver(import.meta.url);
13
13
  nuxt.options.css.push("quasar/dist/quasar.prod.css");
14
14
  nuxt.options.css.push("@quasar/extras/material-icons/material-icons.css");
@@ -20,7 +20,7 @@ const module = defineNuxtModule({
20
20
  rel: "stylesheet",
21
21
  href: "https://fonts.googleapis.com/css2?family=Noto+Sans&family=Noto+Sans+HK&family=Noto+Sans+TC&family=Material+Symbols+Outlined"
22
22
  });
23
- addComponentsDir({
23
+ await addComponentsDir({
24
24
  path: resolver.resolve("./runtime/components")
25
25
  });
26
26
  const from = resolver.resolve("./runtime/lib");
@@ -52,13 +52,28 @@ const module = defineNuxtModule({
52
52
  { name: "getModelField", from },
53
53
  { name: "getGQLFields", from },
54
54
  { name: "model", from },
55
- { name: "notify", from }
55
+ { name: "notify", from },
56
+ { name: "defineLightModel", from },
57
+ { name: "LightModelField", from, type: true },
58
+ { name: "LightModel", from, type: true }
56
59
  ]);
60
+ addVitePlugin(quasar());
61
+ const files = await resolveFiles(process.cwd() + "/models", ["*"]);
62
+ nuxt.options.runtimeConfig.public.light = {
63
+ model: []
64
+ };
65
+ for (const file of files) {
66
+ const n1 = "Model_" + file.match(/([a-zA-Z0-9]+)\.ts$/)?.[1];
67
+ addPlugin({
68
+ src: file,
69
+ mode: "client",
70
+ name: n1
71
+ });
72
+ }
57
73
  addPlugin({
58
74
  src: resolver.resolve("./runtime/plugin"),
59
75
  mode: "client"
60
76
  });
61
- addVitePlugin(quasar());
62
77
  }
63
78
  });
64
79
 
@@ -0,0 +1,16 @@
1
+ export interface LightModelField {
2
+ label: string;
3
+ sortable?: boolean;
4
+ searchable?: boolean;
5
+ autoWidth?: boolean;
6
+ searchType?: string;
7
+ }
8
+ export interface LightModelFields {
9
+ [key: string]: LightModelField;
10
+ }
11
+ export interface LightModel {
12
+ name: string;
13
+ fields: LightModelFields;
14
+ }
15
+ declare const _default: (model: LightModel) => any;
16
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { defineNuxtPlugin } from "#app";
2
+ import { defineModel } from "@hostlink/light";
3
+ export default (model) => {
4
+ return defineNuxtPlugin((nuxtApp) => {
5
+ defineModel(model.name, model.fields);
6
+ });
7
+ };
@@ -16,6 +16,8 @@ export { default as getModelFields } from "./getModelFields";
16
16
  export { default as getModelColumns } from "./getModelColumns";
17
17
  export { default as sv } from "./sv";
18
18
  export { default as model } from "./model";
19
+ export { default as defineLightModel } from "./defineLightModel";
20
+ export { type LightModelField, type LightModel } from "./defineLightModel";
19
21
  export declare const notify: (message: string, color?: string) => void;
20
22
  export { default as getID } from "./getID";
21
23
  export { default as id } from "./getID";
@@ -18,6 +18,7 @@ export { default as getModelFields } from "./getModelFields.mjs";
18
18
  export { default as getModelColumns } from "./getModelColumns.mjs";
19
19
  export { default as sv } from "./sv.mjs";
20
20
  export { default as model } from "./model.mjs";
21
+ export { default as defineLightModel } from "./defineLightModel.mjs";
21
22
  export const notify = function(message, color = "positive") {
22
23
  Notify.create({
23
24
  message,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",