@anweb/nuxt-ancore 1.3.5 → 1.4.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.d.mts +3 -2
- package/dist/module.d.ts +3 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +18 -4
- package/dist/runtime/components/An/Tab.d.ts +22 -0
- package/dist/runtime/components/An/Tab.js +39 -0
- package/dist/runtime/composables/{useData.d.ts → useAnData.d.ts} +2 -2
- package/dist/runtime/composables/{useData.js → useAnData.js} +1 -1
- package/dist/runtime/composables/useAnI18n.d.ts +6 -0
- package/dist/runtime/composables/useAnI18n.js +11 -0
- package/dist/runtime/plugins/i18n.d.ts +2 -0
- package/dist/runtime/plugins/i18n.js +7 -0
- package/dist/runtime/types/{ancore.d.ts → global.d.ts} +6 -2
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/types/index.js +1 -1
- package/dist/runtime/utils/userApi.d.ts +1 -1
- package/dist/runtime/utils/userApi.js +3 -4
- package/package.json +3 -2
- /package/dist/runtime/composables/{useForm.d.ts → useAnForm.d.ts} +0 -0
- /package/dist/runtime/composables/{useForm.js → useAnForm.js} +0 -0
- /package/dist/runtime/composables/{useList.d.ts → useAnList.d.ts} +0 -0
- /package/dist/runtime/composables/{useList.js → useAnList.js} +0 -0
package/dist/module.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import {
|
|
2
|
+
import { InitOptions } from 'i18next';
|
|
3
3
|
|
|
4
4
|
interface ModuleOptions {
|
|
5
|
-
api?:
|
|
5
|
+
api?: string;
|
|
6
|
+
i18n?: InitOptions<unknown>;
|
|
6
7
|
}
|
|
7
8
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
8
9
|
|
package/dist/module.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import {
|
|
2
|
+
import { InitOptions } from 'i18next';
|
|
3
3
|
|
|
4
4
|
interface ModuleOptions {
|
|
5
|
-
api?:
|
|
5
|
+
api?: string;
|
|
6
|
+
i18n?: InitOptions<unknown>;
|
|
6
7
|
}
|
|
7
8
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
8
9
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addPlugin } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const module = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
@@ -7,13 +7,27 @@ const module = defineNuxtModule({
|
|
|
7
7
|
},
|
|
8
8
|
defaults: {},
|
|
9
9
|
async setup(_options, _nuxt) {
|
|
10
|
-
const { resolve } = createResolver(import.meta.url);
|
|
11
|
-
_nuxt.options.runtimeConfig.public
|
|
12
|
-
|
|
10
|
+
const { resolve, resolvePath } = createResolver(import.meta.url);
|
|
11
|
+
_nuxt.options.runtimeConfig.public = {
|
|
12
|
+
i18n: _options.i18n
|
|
13
13
|
};
|
|
14
14
|
_nuxt.options.alias["#ancore/types"] = resolve("./runtime/types");
|
|
15
|
+
if (_options.api) {
|
|
16
|
+
_nuxt.options.alias["#ancore/customApi"] = await resolvePath(_options.api);
|
|
17
|
+
}
|
|
18
|
+
addComponentsDir({
|
|
19
|
+
path: resolve("./runtime/components")
|
|
20
|
+
});
|
|
15
21
|
addImportsDir(resolve("./runtime/composables"));
|
|
16
22
|
addImportsDir(resolve("./runtime/utils"));
|
|
23
|
+
if (_options.i18n) {
|
|
24
|
+
for (const lng in _options.i18n.resources) {
|
|
25
|
+
if (!_options.i18n.resources[lng]) continue;
|
|
26
|
+
const path = await resolvePath(_options.i18n.resources[lng].translation);
|
|
27
|
+
_options.i18n.resources[lng].translation = structuredClone((await import(path)).default);
|
|
28
|
+
}
|
|
29
|
+
addPlugin(resolve("./runtime/plugins/i18n.ts"));
|
|
30
|
+
}
|
|
17
31
|
}
|
|
18
32
|
});
|
|
19
33
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type TabExposed = {
|
|
2
|
+
reset: () => void;
|
|
3
|
+
};
|
|
4
|
+
declare const Tab: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
|
+
show: {
|
|
6
|
+
type: BooleanConstructor;
|
|
7
|
+
required: true;
|
|
8
|
+
};
|
|
9
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}>[] | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
+
show: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
19
|
+
declare const _default: typeof Tab & {
|
|
20
|
+
new (): TabExposed;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineComponent, h, Fragment, watch, ref } from "vue";
|
|
2
|
+
const Tab = defineComponent({
|
|
3
|
+
name: "Tab",
|
|
4
|
+
props: {
|
|
5
|
+
show: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
required: true
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
setup(props, { slots, expose }) {
|
|
11
|
+
const created = ref(false);
|
|
12
|
+
const reset = () => {
|
|
13
|
+
created.value = false;
|
|
14
|
+
};
|
|
15
|
+
watch(() => props.show, () => {
|
|
16
|
+
if (props.show) created.value = true;
|
|
17
|
+
}, { immediate: true });
|
|
18
|
+
expose({ reset });
|
|
19
|
+
return () => {
|
|
20
|
+
if (!created.value) return null;
|
|
21
|
+
const content = slots.default?.() ?? [];
|
|
22
|
+
if (props.show) return h(Fragment, {}, content);
|
|
23
|
+
return content.map(
|
|
24
|
+
(vnode) => h(
|
|
25
|
+
vnode.type,
|
|
26
|
+
{
|
|
27
|
+
...vnode.props,
|
|
28
|
+
style: {
|
|
29
|
+
...vnode.props?.style || {},
|
|
30
|
+
display: "none"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
vnode.children
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export default Tab;
|
|
@@ -4,7 +4,7 @@ import { useAsyncData } from '#app';
|
|
|
4
4
|
interface TConfig {
|
|
5
5
|
request: NitroFetchRequest;
|
|
6
6
|
}
|
|
7
|
-
interface
|
|
7
|
+
interface TUseAnData<TData, TError> {
|
|
8
8
|
init: () => Promise<void>;
|
|
9
9
|
loading: ComputedRef<boolean>;
|
|
10
10
|
request: Ref<NitroFetchRequest>;
|
|
@@ -12,5 +12,5 @@ interface TUseData<TData, TError> {
|
|
|
12
12
|
error: ComputedRef<TError>;
|
|
13
13
|
status: ReturnType<typeof useAsyncData>['status'];
|
|
14
14
|
}
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const useAnData: <TData = unknown, TError = unknown>(config: TConfig) => TUseAnData<TData, TError>;
|
|
16
16
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, ref } from "vue";
|
|
2
2
|
import { useAsyncData } from "#app";
|
|
3
3
|
import { userApi } from "../utils/index.js";
|
|
4
|
-
export const
|
|
4
|
+
export const useAnData = (config) => {
|
|
5
5
|
const request = ref(config.request);
|
|
6
6
|
const loading = computed(() => {
|
|
7
7
|
return status.value === "pending";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import i18next from "i18next";
|
|
2
|
+
export default (resources, ns) => {
|
|
3
|
+
if (!ns) return { t: i18next.t };
|
|
4
|
+
for (const lang in resources) {
|
|
5
|
+
if (!i18next.hasResourceBundle(lang, ns)) {
|
|
6
|
+
i18next.addResourceBundle(lang, ns, resources[lang]);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const t = (key, options = {}) => i18next.t(key, { ns: [ns, "translation"], ...options });
|
|
10
|
+
return { t };
|
|
11
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { InitOptions } from 'i18next'
|
|
1
2
|
import type { ModuleOptions } from '../../module'
|
|
3
|
+
import type { TApi } from '#ancore/types'
|
|
2
4
|
|
|
3
5
|
|
|
4
6
|
declare module 'nuxt/schema' {
|
|
@@ -10,8 +12,10 @@ declare module 'nuxt/schema' {
|
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
interface PublicRuntimeConfig {
|
|
13
|
-
|
|
15
|
+
i18n?: InitOptions<unknown>
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
declare module '#ancore/customApi' {
|
|
20
|
+
export const api: TApi
|
|
21
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { NitroFetchOptions, NitroFetchRequest } from 'nitropack';
|
|
2
|
-
export declare const userApi: <TData = unknown, TError = unknown>(request: NitroFetchRequest, opts: NitroFetchOptions<string>) =>
|
|
2
|
+
export declare const userApi: <TData = unknown, TError = unknown>(request: NitroFetchRequest, opts: NitroFetchOptions<string>) => any;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#app";
|
|
2
1
|
import { coreApi } from "./index.js";
|
|
2
|
+
import { api as customApi } from "#ancore/customApi";
|
|
3
3
|
export const userApi = (request, opts) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return runtimeConfig.api(request, opts);
|
|
4
|
+
if (customApi) {
|
|
5
|
+
return customApi(request, opts);
|
|
7
6
|
} else {
|
|
8
7
|
return coreApi(request, opts);
|
|
9
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anweb/nuxt-ancore",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "AnCore Nuxt module",
|
|
5
5
|
"repository": "https://github.com/ANLTD/ancore",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"@nuxt/kit": "^4.0.1",
|
|
36
36
|
"@vueuse/core": "^13.5.0",
|
|
37
37
|
"@vueuse/integrations": "^13.5.0",
|
|
38
|
-
"async-validator": "^4.2.5"
|
|
38
|
+
"async-validator": "^4.2.5",
|
|
39
|
+
"i18next": "^25.3.2"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@nuxt/devtools": "^2.6.2",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|