@anweb/nuxt-ancore 1.3.6 → 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 +2 -0
- package/dist/module.d.ts +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +15 -2
- 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} +2 -0
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/types/index.js +1 -1
- 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
package/dist/module.d.ts
CHANGED
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: {
|
|
@@ -8,13 +8,26 @@ const module = defineNuxtModule({
|
|
|
8
8
|
defaults: {},
|
|
9
9
|
async setup(_options, _nuxt) {
|
|
10
10
|
const { resolve, resolvePath } = createResolver(import.meta.url);
|
|
11
|
-
_nuxt.options.runtimeConfig.public = {
|
|
11
|
+
_nuxt.options.runtimeConfig.public = {
|
|
12
|
+
i18n: _options.i18n
|
|
13
|
+
};
|
|
12
14
|
_nuxt.options.alias["#ancore/types"] = resolve("./runtime/types");
|
|
13
15
|
if (_options.api) {
|
|
14
16
|
_nuxt.options.alias["#ancore/customApi"] = await resolvePath(_options.api);
|
|
15
17
|
}
|
|
18
|
+
addComponentsDir({
|
|
19
|
+
path: resolve("./runtime/components")
|
|
20
|
+
});
|
|
16
21
|
addImportsDir(resolve("./runtime/composables"));
|
|
17
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
|
+
}
|
|
18
31
|
}
|
|
19
32
|
});
|
|
20
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,3 +1,4 @@
|
|
|
1
|
+
import type { InitOptions } from 'i18next'
|
|
1
2
|
import type { ModuleOptions } from '../../module'
|
|
2
3
|
import type { TApi } from '#ancore/types'
|
|
3
4
|
|
|
@@ -11,6 +12,7 @@ declare module 'nuxt/schema' {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
interface PublicRuntimeConfig {
|
|
15
|
+
i18n?: InitOptions<unknown>
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
|
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
|