@overgaming/valiform 0.4.1 → 0.4.2

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.
@@ -1,4 +1,7 @@
1
1
  import type { FormsPluginOptions } from '../src/types';
2
+ interface NuxtModuleOptions extends FormsPluginOptions {
3
+ rulesPath?: string;
4
+ }
2
5
  declare const _default: NuxtModule<TOptions, TOptions, false>;
3
6
  export default _default;
4
- export type ModuleOptions = FormsPluginOptions;
7
+ export type ModuleOptions = NuxtModuleOptions;
package/dist/nuxt.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";const e=require("@nuxt/kit");var t=typeof document<"u"?document.currentScript:null;const s=e.defineNuxtModule({meta:{name:"@overgaming/valiform",configKey:"valiform",compatibility:{nuxt:">=3.0.0"}},defaults:{},setup(n){const r=e.createResolver(typeof document>"u"?require("url").pathToFileURL(__filename).href:t&&t.tagName.toUpperCase()==="SCRIPT"&&t.src||new URL("nuxt.cjs",document.baseURI).href),{rules:o,...i}=n,m=o&&Object.keys(o).length>0?`{
2
- ${Object.entries(o).map(([a,l])=>` ${JSON.stringify(a)}: ${l.toString()}`).join(`,
1
+ "use strict";const e=require("@nuxt/kit");var r=typeof document<"u"?document.currentScript:null;const c=e.defineNuxtModule({meta:{name:"@overgaming/valiform",configKey:"valiform",compatibility:{nuxt:">=3.0.0"}},defaults:{},async setup(s){const m=e.createResolver(typeof document>"u"?require("url").pathToFileURL(__filename).href:r&&r.tagName.toUpperCase()==="SCRIPT"&&r.src||new URL("nuxt.cjs",document.baseURI).href),{rules:o,rulesPath:i,...a}=s,t=[`export const pluginOptions = ${JSON.stringify(a)};`];if(i){const n=await e.resolvePath(i);t.unshift(`import _customRules from ${JSON.stringify(n)};`),t.push("export const customRules = _customRules;")}else if(o&&Object.keys(o).length>0){const n=`{
2
+ ${Object.entries(o).map(([l,u])=>` ${JSON.stringify(l)}: ${u.toString()}`).join(`,
3
3
  `)}
4
- }`:"null";e.addTemplate({filename:"valiform/options.mjs",getContents:()=>[`export const pluginOptions = ${JSON.stringify(i)}`,`export const customRules = ${m}`].join(`
5
- `),write:!0}),e.addPlugin(r.resolve("./runtime/plugin")),e.addComponent({name:"Form",export:"Form",filePath:"@overgaming/valiform"}),e.addComponent({name:"Field",export:"Field",filePath:"@overgaming/valiform"}),e.addImports([{name:"useLocale",from:"@overgaming/valiform"},{name:"useFormContext",from:"@overgaming/valiform"},{name:"useFieldContext",from:"@overgaming/valiform"},{name:"useInputContext",from:"@overgaming/valiform"}])}});module.exports=s;
4
+ }`;t.push(`export const customRules = ${n};`)}else t.push("export const customRules = null;");e.addTemplate({filename:"valiform/options.mjs",getContents:()=>t.join(`
5
+ `),write:!0}),e.addPlugin(m.resolve("./runtime/plugin")),e.addComponent({name:"Form",export:"Form",filePath:"@overgaming/valiform"}),e.addComponent({name:"Field",export:"Field",filePath:"@overgaming/valiform"}),e.addImports([{name:"useLocale",from:"@overgaming/valiform"},{name:"useFormContext",from:"@overgaming/valiform"},{name:"useFieldContext",from:"@overgaming/valiform"},{name:"useInputContext",from:"@overgaming/valiform"}])}});module.exports=c;
package/dist/nuxt.js CHANGED
@@ -1,25 +1,30 @@
1
- import { defineNuxtModule as l, createResolver as s, addTemplate as g, addPlugin as u, addComponent as o, addImports as f } from "@nuxt/kit";
2
- const v = l({
1
+ import { defineNuxtModule as u, createResolver as f, resolvePath as p, addTemplate as g, addPlugin as c, addComponent as i, addImports as v } from "@nuxt/kit";
2
+ const x = u({
3
3
  meta: {
4
4
  name: "@overgaming/valiform",
5
5
  configKey: "valiform",
6
6
  compatibility: { nuxt: ">=3.0.0" }
7
7
  },
8
8
  defaults: {},
9
- setup(t) {
10
- const n = s(import.meta.url), { rules: e, ...r } = t, i = e && Object.keys(e).length > 0 ? `{
11
- ${Object.entries(e).map(([m, a]) => ` ${JSON.stringify(m)}: ${a.toString()}`).join(`,
9
+ async setup(r) {
10
+ const s = f(import.meta.url), { rules: o, rulesPath: n, ...m } = r, e = [`export const pluginOptions = ${JSON.stringify(m)};`];
11
+ if (n) {
12
+ const t = await p(n);
13
+ e.unshift(`import _customRules from ${JSON.stringify(t)};`), e.push("export const customRules = _customRules;");
14
+ } else if (o && Object.keys(o).length > 0) {
15
+ const t = `{
16
+ ${Object.entries(o).map(([a, l]) => ` ${JSON.stringify(a)}: ${l.toString()}`).join(`,
12
17
  `)}
13
- }` : "null";
18
+ }`;
19
+ e.push(`export const customRules = ${t};`);
20
+ } else
21
+ e.push("export const customRules = null;");
14
22
  g({
15
23
  filename: "valiform/options.mjs",
16
- getContents: () => [
17
- `export const pluginOptions = ${JSON.stringify(r)}`,
18
- `export const customRules = ${i}`
19
- ].join(`
24
+ getContents: () => e.join(`
20
25
  `),
21
26
  write: !0
22
- }), u(n.resolve("./runtime/plugin")), o({ name: "Form", export: "Form", filePath: "@overgaming/valiform" }), o({ name: "Field", export: "Field", filePath: "@overgaming/valiform" }), f([
27
+ }), c(s.resolve("./runtime/plugin")), i({ name: "Form", export: "Form", filePath: "@overgaming/valiform" }), i({ name: "Field", export: "Field", filePath: "@overgaming/valiform" }), v([
23
28
  { name: "useLocale", from: "@overgaming/valiform" },
24
29
  { name: "useFormContext", from: "@overgaming/valiform" },
25
30
  { name: "useFieldContext", from: "@overgaming/valiform" },
@@ -28,5 +33,5 @@ ${Object.entries(e).map(([m, a]) => ` ${JSON.stringify(m)}: ${a.toString()}`).j
28
33
  }
29
34
  });
30
35
  export {
31
- v as default
36
+ x as default
32
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overgaming/valiform",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Vue 3 form validation library",
5
5
  "keywords": [
6
6
  "form",