@antify/ui-module 1.8.4 → 1.9.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 +10 -4
- package/dist/module.d.ts +10 -4
- package/dist/module.json +6 -2
- package/dist/module.mjs +5 -22
- package/dist/runtime/composables/useUiClient.d.ts +58 -13
- package/dist/runtime/composables/useUiClient.js +131 -0
- package/dist/runtime/plugins/ui-module.d.ts +45 -1
- package/dist/runtime/{tailwind.config.mjs → tailwindConfig.js} +3 -3
- package/dist/runtime/types.d.ts +1 -0
- package/dist/runtime/types.js +0 -0
- package/dist/types.d.mts +4 -5
- package/dist/types.d.ts +4 -5
- package/package.json +18 -15
- package/dist/runtime/composables/useUiClient.mjs +0 -60
- /package/dist/runtime/plugins/{ui-module.mjs → ui-module.js} +0 -0
- /package/dist/runtime/{tailwind.config.d.ts → tailwindConfig.d.ts} +0 -0
package/dist/module.d.mts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export * from '../dist/runtime/types.js';
|
|
2
3
|
|
|
3
|
-
type ModuleOptions = {
|
|
4
|
-
|
|
4
|
+
type ModuleOptions = {
|
|
5
|
+
tailwindcss?: {
|
|
6
|
+
content?: string[];
|
|
7
|
+
};
|
|
8
|
+
};
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
11
|
+
|
|
12
|
+
export { _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export * from '../dist/runtime/types.js';
|
|
2
3
|
|
|
3
|
-
type ModuleOptions = {
|
|
4
|
-
|
|
4
|
+
type ModuleOptions = {
|
|
5
|
+
tailwindcss?: {
|
|
6
|
+
content?: string[];
|
|
7
|
+
};
|
|
8
|
+
};
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
11
|
+
|
|
12
|
+
export { _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
import tailwindConfig from '
|
|
1
|
+
import tailwindConfig from '../dist/runtime/tailwindConfig.js';
|
|
2
2
|
import { defineNuxtModule, createResolver, addPlugin, addImportsDir, addComponent } from '@nuxt/kit';
|
|
3
|
-
|
|
4
|
-
tailwindConfig.content = [
|
|
5
|
-
// For module dev
|
|
6
|
-
"./src/runtime/**/*.{vue,js,ts,jsx,tsx}",
|
|
7
|
-
"./src/runtime/**/*.stories.ts",
|
|
8
|
-
"./playground/app.vue",
|
|
9
|
-
"./playground/components/**/*.{vue,js,ts,jsx,tsx}",
|
|
10
|
-
"./playground/pages/**/*.{vue,js,ts,jsx,tsx}",
|
|
11
|
-
"./playground/layouts/**/*.{vue,js,ts,jsx,tsx}",
|
|
12
|
-
"../ui-module/src/**/*.{vue,js,ts,jsx,tsx}",
|
|
13
|
-
// For project dev
|
|
14
|
-
"./app.vue",
|
|
15
|
-
"./components/**/*.{vue,js,ts,jsx,tsx}",
|
|
16
|
-
"./pages/**/*.{vue,js,ts,jsx,tsx}",
|
|
17
|
-
"./layouts/**/*.{vue,js,ts,jsx,tsx}",
|
|
18
|
-
// If this config is used in a project
|
|
19
|
-
"./node_modules/@antify/*/dist/**/*.{js,vue,ts}",
|
|
20
|
-
"./node_modules/@antify/*/src/**/*.{js,vue,ts}"
|
|
21
|
-
];
|
|
3
|
+
import { defu } from 'defu';
|
|
22
4
|
|
|
23
5
|
const uiComponents = [
|
|
24
6
|
"AntActionButton",
|
|
@@ -70,6 +52,7 @@ const uiComponents = [
|
|
|
70
52
|
"AntAccordion",
|
|
71
53
|
"AntAccordionItem",
|
|
72
54
|
"AntAlert",
|
|
55
|
+
"AntCard",
|
|
73
56
|
"AntContent",
|
|
74
57
|
"AntDropdown",
|
|
75
58
|
"AntIcon",
|
|
@@ -90,7 +73,7 @@ const uiComponents = [
|
|
|
90
73
|
const moduleKey = "uiModule";
|
|
91
74
|
const module = defineNuxtModule({
|
|
92
75
|
meta: {
|
|
93
|
-
name: "ui-module",
|
|
76
|
+
name: "@antify/ui-module",
|
|
94
77
|
configKey: moduleKey
|
|
95
78
|
},
|
|
96
79
|
defaults: {},
|
|
@@ -108,7 +91,7 @@ const module = defineNuxtModule({
|
|
|
108
91
|
filePath: "@antify/ui/components"
|
|
109
92
|
});
|
|
110
93
|
});
|
|
111
|
-
nuxt.options.postcss.plugins.tailwindcss = tailwindConfig;
|
|
94
|
+
nuxt.options.postcss.plugins.tailwindcss = defu(tailwindConfig, options.tailwindcss);
|
|
112
95
|
nuxt.options.css.push(resolve(runtimeDir, "assets/tailwind.css"));
|
|
113
96
|
nuxt.options.runtimeConfig.public[moduleKey] = options;
|
|
114
97
|
}
|
|
@@ -2,24 +2,40 @@
|
|
|
2
2
|
* Set of helper functions for client side
|
|
3
3
|
*/
|
|
4
4
|
import type { FetchResponse, FetchError } from 'ofetch';
|
|
5
|
-
import { type LocationQuery, type RouteLocationRaw } from '#vue-router';
|
|
5
|
+
import { type LocationQuery, type RouteLocationRaw, type LocationQueryRaw, type RouteParams } from '#vue-router';
|
|
6
6
|
import { type Ref } from '#imports';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { InputState } from '@antify/ui';
|
|
8
|
+
declare function handleNotFoundResponse(response: FetchResponse, fallbackUrl: RouteLocationRaw): Promise<void>;
|
|
9
|
+
declare function handleResponseError(error: Ref<FetchError | null>): void;
|
|
9
10
|
declare function isFormDisabled(status: Ref | Ref[]): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a skeleton ref with flicker protection by prevent switching to fast from true to false.
|
|
12
|
-
*
|
|
13
|
-
* Important, it only watches the pending ref once, because a skeleton should be shown only one time
|
|
14
|
-
* on initial loading.
|
|
15
|
-
*
|
|
16
|
-
* @param pending
|
|
17
|
-
*/
|
|
18
|
-
declare function createSkeleton(pending: Ref<boolean>): Ref<boolean>;
|
|
19
11
|
/**
|
|
20
12
|
* Detect if the given queryToWatch changed.
|
|
21
13
|
*/
|
|
22
14
|
declare function queryChanged(from: LocationQuery, to: LocationQuery, queryToWatch: string | string[]): boolean;
|
|
15
|
+
export type CrudRoutingOptions = {
|
|
16
|
+
detailRouteName: string;
|
|
17
|
+
listingRouteName: string;
|
|
18
|
+
getDetailRouteParams?: () => RouteParams;
|
|
19
|
+
getListingRouteParams?: () => RouteParams;
|
|
20
|
+
entityIdentifier?: string;
|
|
21
|
+
createEntityIdentifier?: string;
|
|
22
|
+
};
|
|
23
|
+
export type FormFieldType = {
|
|
24
|
+
errors: string[];
|
|
25
|
+
state: InputState;
|
|
26
|
+
validate: () => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Yup validation throws an error if the value expect not the given schema.
|
|
30
|
+
* This function creates a wrapper around it, to easily use it with antify ui components.
|
|
31
|
+
*/
|
|
32
|
+
export declare function useFormField(validationFn: () => Promise<void>): {
|
|
33
|
+
errors: never[];
|
|
34
|
+
state: InputState;
|
|
35
|
+
validate: () => Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
type GroupedForm = Record<string, FormFieldType[]>;
|
|
38
|
+
export declare function useGroupedForm<T extends GroupedForm>(form: T): {};
|
|
23
39
|
export declare const useUiClient: () => {
|
|
24
40
|
handler: {
|
|
25
41
|
handleNotFoundResponse: typeof handleNotFoundResponse;
|
|
@@ -27,8 +43,37 @@ export declare const useUiClient: () => {
|
|
|
27
43
|
};
|
|
28
44
|
utils: {
|
|
29
45
|
isFormDisabled: typeof isFormDisabled;
|
|
30
|
-
createSkeleton: typeof createSkeleton;
|
|
31
46
|
queryChanged: typeof queryChanged;
|
|
47
|
+
useCrudRouting: (detailRouteName: string, listingRouteName: string, getDetailRouteParams?: () => RouteParams, getListingRouteParams?: () => RouteParams, entityIdentifier?: string, createEntityIdentifier?: string) => {
|
|
48
|
+
isListingPage: import("vue").ComputedRef<boolean>;
|
|
49
|
+
isDetailPage: import("vue").ComputedRef<boolean>;
|
|
50
|
+
isUpdatePage: import("vue").ComputedRef<boolean>;
|
|
51
|
+
isCreatePage: import("vue").ComputedRef<boolean>;
|
|
52
|
+
getDetailRoute(entityId: string | string[], query?: LocationQueryRaw): {
|
|
53
|
+
name: string;
|
|
54
|
+
params: {
|
|
55
|
+
[x: string]: string | string[] | string[];
|
|
56
|
+
};
|
|
57
|
+
query: LocationQueryRaw;
|
|
58
|
+
};
|
|
59
|
+
getDetailSubRoute(entityId: string | string[], subRouteNameExtension: string, query?: LocationQueryRaw): {
|
|
60
|
+
name: string;
|
|
61
|
+
params: {
|
|
62
|
+
[x: string]: string | string[] | string[];
|
|
63
|
+
};
|
|
64
|
+
query: LocationQueryRaw;
|
|
65
|
+
};
|
|
66
|
+
getListingRoute(query?: LocationQueryRaw): {
|
|
67
|
+
name: string;
|
|
68
|
+
params: import("vue-router").RouteParamsGeneric;
|
|
69
|
+
query: LocationQueryRaw;
|
|
70
|
+
};
|
|
71
|
+
getEntityId(): string | string[];
|
|
72
|
+
goToListingPage(query?: LocationQueryRaw): Promise<void | import("vue-router").NavigationFailure | undefined>;
|
|
73
|
+
goToDetailPage(entityId?: string | string[], query?: LocationQuery): Promise<void | import("vue-router").NavigationFailure | undefined>;
|
|
74
|
+
goToDetailSubPage(subRouteNameExtension: string, query?: LocationQueryRaw): Promise<void | import("vue-router").NavigationFailure | undefined>;
|
|
75
|
+
};
|
|
76
|
+
useFormField: typeof useFormField;
|
|
32
77
|
};
|
|
33
78
|
};
|
|
34
79
|
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useNuxtApp,
|
|
3
|
+
navigateTo,
|
|
4
|
+
createError,
|
|
5
|
+
useRouter,
|
|
6
|
+
useRoute,
|
|
7
|
+
computed,
|
|
8
|
+
reactive
|
|
9
|
+
} from "#imports";
|
|
10
|
+
import { InputState } from "@antify/ui";
|
|
11
|
+
async function handleNotFoundResponse(response, fallbackUrl) {
|
|
12
|
+
if (response._data?.notFound) {
|
|
13
|
+
useNuxtApp().$uiModule.toaster.toastError("Entity not found. Maybe an other user deleted it.");
|
|
14
|
+
await navigateTo(fallbackUrl);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function handleResponseError(error) {
|
|
18
|
+
if (error.value) {
|
|
19
|
+
throw createError({ ...error.value?.data, statusCode: 500, fatal: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function isFormDisabled(status) {
|
|
23
|
+
if (Array.isArray(status)) {
|
|
24
|
+
return status.some((status2) => isFormDisabled(status2));
|
|
25
|
+
}
|
|
26
|
+
return status.value === "pending";
|
|
27
|
+
}
|
|
28
|
+
function queryChanged(from, to, queryToWatch) {
|
|
29
|
+
const _queryToWatch = Array.isArray(queryToWatch) ? queryToWatch : [queryToWatch];
|
|
30
|
+
const changes = Object.keys(to).reduce((acc, key) => {
|
|
31
|
+
if (to[key] !== from[key]) {
|
|
32
|
+
acc[key] = to[key];
|
|
33
|
+
}
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
return _queryToWatch.some((key) => changes[key] !== void 0);
|
|
37
|
+
}
|
|
38
|
+
const useCrudRouting = (detailRouteName, listingRouteName, getDetailRouteParams = () => ({}), getListingRouteParams = () => ({}), entityIdentifier = "entityId", createEntityIdentifier = "create") => {
|
|
39
|
+
const route = useRoute();
|
|
40
|
+
const router = useRouter();
|
|
41
|
+
const isDetailPage = computed(() => {
|
|
42
|
+
return route.name?.includes(detailRouteName || "") || false;
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
isListingPage: computed(() => route.name === listingRouteName),
|
|
46
|
+
isDetailPage,
|
|
47
|
+
isUpdatePage: computed(() => isDetailPage.value && route.params[entityIdentifier] !== createEntityIdentifier),
|
|
48
|
+
isCreatePage: computed(() => isDetailPage.value && route.params[entityIdentifier] === createEntityIdentifier),
|
|
49
|
+
getDetailRoute(entityId, query = route.query) {
|
|
50
|
+
return {
|
|
51
|
+
name: detailRouteName,
|
|
52
|
+
params: {
|
|
53
|
+
...getDetailRouteParams(),
|
|
54
|
+
[entityIdentifier]: entityId
|
|
55
|
+
},
|
|
56
|
+
query
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
getDetailSubRoute(entityId, subRouteNameExtension, query = route.query) {
|
|
60
|
+
return {
|
|
61
|
+
name: `${detailRouteName}-${subRouteNameExtension}`,
|
|
62
|
+
params: {
|
|
63
|
+
...getDetailRouteParams(),
|
|
64
|
+
[entityIdentifier]: entityId
|
|
65
|
+
},
|
|
66
|
+
query
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
getListingRoute(query = route.query) {
|
|
70
|
+
return {
|
|
71
|
+
name: listingRouteName,
|
|
72
|
+
params: getListingRouteParams(),
|
|
73
|
+
query
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
getEntityId() {
|
|
77
|
+
const entityId = route.params[entityIdentifier];
|
|
78
|
+
if (entityId === void 0) {
|
|
79
|
+
throw new Error(`Entity identifier "${entityIdentifier}" is not set in route.params. Make sure you set it in route and this function is called on a detail page.`);
|
|
80
|
+
}
|
|
81
|
+
return entityId;
|
|
82
|
+
},
|
|
83
|
+
// TODO:: use the given query and merge it into route.query
|
|
84
|
+
goToListingPage(query = route.query) {
|
|
85
|
+
return router.push(this.getListingRoute(query));
|
|
86
|
+
},
|
|
87
|
+
goToDetailPage(entityId = "create", query = route.query) {
|
|
88
|
+
return router.push(this.getDetailRoute(entityId, query));
|
|
89
|
+
},
|
|
90
|
+
goToDetailSubPage(subRouteNameExtension, query = route.query) {
|
|
91
|
+
return router.push(this.getDetailSubRoute(subRouteNameExtension, query));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export function useFormField(validationFn) {
|
|
96
|
+
const _reactive = reactive({
|
|
97
|
+
errors: [],
|
|
98
|
+
state: InputState.base,
|
|
99
|
+
async validate() {
|
|
100
|
+
try {
|
|
101
|
+
await validationFn();
|
|
102
|
+
_reactive.errors = [];
|
|
103
|
+
_reactive.state = InputState.base;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
if (e?.name !== "ValidationError") {
|
|
106
|
+
throw e;
|
|
107
|
+
}
|
|
108
|
+
_reactive.errors = e?.errors || [];
|
|
109
|
+
_reactive.state = InputState.danger;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return _reactive;
|
|
114
|
+
}
|
|
115
|
+
export function useGroupedForm(form) {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
export const useUiClient = () => {
|
|
119
|
+
return {
|
|
120
|
+
handler: {
|
|
121
|
+
handleNotFoundResponse,
|
|
122
|
+
handleResponseError
|
|
123
|
+
},
|
|
124
|
+
utils: {
|
|
125
|
+
isFormDisabled,
|
|
126
|
+
queryChanged,
|
|
127
|
+
useCrudRouting,
|
|
128
|
+
useFormField
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
};
|
|
@@ -1,2 +1,46 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<{
|
|
2
|
+
uiModule: {
|
|
3
|
+
toaster: {
|
|
4
|
+
getToasts(): {
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
title: string;
|
|
7
|
+
content?: string | undefined;
|
|
8
|
+
type: import("@antify/ui").InputState;
|
|
9
|
+
hasIcon?: boolean | undefined;
|
|
10
|
+
}[];
|
|
11
|
+
toast(toast: import("@antify/ui").Toast): void;
|
|
12
|
+
removeToast(toast: import("@antify/ui").Toast): void;
|
|
13
|
+
toastSuccess(message: string): void;
|
|
14
|
+
toastError(message: string): void;
|
|
15
|
+
toastWarning(message: string): void;
|
|
16
|
+
toastInfo(message: string): void;
|
|
17
|
+
toastDeleted(): void;
|
|
18
|
+
toastCreated(): void;
|
|
19
|
+
toastUpdated(): void;
|
|
20
|
+
toastDuplicated(): void;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}> & import("nuxt/app").ObjectPlugin<{
|
|
24
|
+
uiModule: {
|
|
25
|
+
toaster: {
|
|
26
|
+
getToasts(): {
|
|
27
|
+
id?: string | undefined;
|
|
28
|
+
title: string;
|
|
29
|
+
content?: string | undefined;
|
|
30
|
+
type: import("@antify/ui").InputState;
|
|
31
|
+
hasIcon?: boolean | undefined;
|
|
32
|
+
}[];
|
|
33
|
+
toast(toast: import("@antify/ui").Toast): void;
|
|
34
|
+
removeToast(toast: import("@antify/ui").Toast): void;
|
|
35
|
+
toastSuccess(message: string): void;
|
|
36
|
+
toastError(message: string): void;
|
|
37
|
+
toastWarning(message: string): void;
|
|
38
|
+
toastInfo(message: string): void;
|
|
39
|
+
toastDeleted(): void;
|
|
40
|
+
toastCreated(): void;
|
|
41
|
+
toastUpdated(): void;
|
|
42
|
+
toastDuplicated(): void;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
2
46
|
export default _default;
|
|
@@ -7,14 +7,14 @@ tailwindConfig.content = [
|
|
|
7
7
|
"./playground/components/**/*.{vue,js,ts,jsx,tsx}",
|
|
8
8
|
"./playground/pages/**/*.{vue,js,ts,jsx,tsx}",
|
|
9
9
|
"./playground/layouts/**/*.{vue,js,ts,jsx,tsx}",
|
|
10
|
-
|
|
10
|
+
// '../ui-module/src/**/*.{vue,js,ts,jsx,tsx}',
|
|
11
11
|
// For project dev
|
|
12
12
|
"./app.vue",
|
|
13
13
|
"./components/**/*.{vue,js,ts,jsx,tsx}",
|
|
14
14
|
"./pages/**/*.{vue,js,ts,jsx,tsx}",
|
|
15
15
|
"./layouts/**/*.{vue,js,ts,jsx,tsx}",
|
|
16
16
|
// If this config is used in a project
|
|
17
|
-
"./node_modules/@antify/*/dist/**/*.{js,vue,ts}"
|
|
18
|
-
|
|
17
|
+
"./node_modules/@antify/*/dist/**/*.{js,vue,ts}"
|
|
18
|
+
// './node_modules/@antify/*/src/**/*.{js,vue,ts}',
|
|
19
19
|
];
|
|
20
20
|
export default tailwindConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type CrudRoutingOptions, type FormFieldType } from './composables/useUiClient.js';
|
|
File without changes
|
package/dist/types.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
1
2
|
|
|
2
|
-
import type {
|
|
3
|
+
import type { default as Module } from './module.js'
|
|
3
4
|
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type { default } from './module.js'
|
|
7
|
+
export { default } from './module.js'
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
1
2
|
|
|
2
|
-
import type {
|
|
3
|
+
import type { default as Module } from './module'
|
|
3
4
|
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type { default } from './module'
|
|
7
|
+
export { default } from './module'
|
package/package.json
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antify/ui-module",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"type": "module",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
10
|
+
"types": "./dist/module.d.ts",
|
|
9
11
|
"import": "./dist/module.mjs",
|
|
10
|
-
"require": "./dist/module.cjs"
|
|
11
|
-
"types": "./dist/types.d.ts"
|
|
12
|
+
"require": "./dist/module.cjs"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
15
|
+
"main": "./dist/module.mjs",
|
|
16
|
+
"types": "./dist/module.d.ts",
|
|
14
17
|
"files": [
|
|
15
18
|
"dist"
|
|
16
19
|
],
|
|
17
|
-
"main": "./dist/module.cjs",
|
|
18
|
-
"types": "./dist/types.d.ts",
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@antify/ui": "^1.0.
|
|
21
|
+
"@antify/ui": "^1.0.4",
|
|
21
22
|
"@fortawesome/vue-fontawesome": "^3.0.8",
|
|
22
|
-
"@nuxt/kit": "^3.
|
|
23
|
+
"@nuxt/kit": "^3.13.1",
|
|
23
24
|
"@vueuse/core": "^10.7.2",
|
|
24
25
|
"tailwindcss": "^3.4.10",
|
|
25
26
|
"vue": "^3.4.29"
|
|
@@ -27,23 +28,25 @@
|
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@faker-js/faker": "^8.3.1",
|
|
29
30
|
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
|
30
|
-
"@nuxt/eslint-config": "
|
|
31
|
+
"@nuxt/eslint-config": "^0.4.0",
|
|
31
32
|
"@nuxt/module-builder": "latest",
|
|
32
33
|
"autoprefixer": "^10.4.16",
|
|
33
34
|
"defu": "^6.1.4",
|
|
34
|
-
"eslint": "
|
|
35
|
-
"eslint-plugin-storybook": "
|
|
36
|
-
"nuxt": "^3.
|
|
35
|
+
"eslint": "^8.0.0",
|
|
36
|
+
"eslint-plugin-storybook": "^0.8.0",
|
|
37
|
+
"nuxt": "^3.13.1",
|
|
37
38
|
"ofetch": "^1.3.3",
|
|
38
39
|
"standard-version": "latest",
|
|
39
|
-
"typescript": "^5.
|
|
40
|
-
|
|
40
|
+
"typescript": "^5.5.4"
|
|
41
|
+
},
|
|
42
|
+
"resolutions": {
|
|
43
|
+
"@antify/ui-module": "workspace:*"
|
|
41
44
|
},
|
|
42
45
|
"scripts": {
|
|
43
|
-
"build": "nuxt-module-build",
|
|
46
|
+
"build": "nuxt-module-build build",
|
|
44
47
|
"dev": "nuxi dev playground",
|
|
45
48
|
"dev:build": "nuxi build playground",
|
|
46
|
-
"dev:prepare": "
|
|
49
|
+
"dev:prepare": "nuxi prepare playground",
|
|
47
50
|
"release": "standard-version && git push --follow-tags && pnpm publish --access public"
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { useNuxtApp, navigateTo, createError, ref } from "#imports";
|
|
2
|
-
import { watchOnce } from "@vueuse/core";
|
|
3
|
-
export async function handleNotFoundResponse(response, fallbackUrl) {
|
|
4
|
-
if (response._data?.notFound) {
|
|
5
|
-
useNuxtApp().$uiModule.toaster.toastError("Entity not found. Maybe an other user deleted it.");
|
|
6
|
-
await navigateTo(fallbackUrl);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export function handleResponseError(error) {
|
|
10
|
-
if (error.value) {
|
|
11
|
-
throw createError({ ...error.value?.data, statusCode: 500, fatal: true });
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function isFormDisabled(status) {
|
|
15
|
-
if (Array.isArray(status)) {
|
|
16
|
-
return status.some((status2) => isFormDisabled(status2));
|
|
17
|
-
}
|
|
18
|
-
return status.value === "pending";
|
|
19
|
-
}
|
|
20
|
-
function createSkeleton(pending) {
|
|
21
|
-
const skeleton = ref(true);
|
|
22
|
-
const initialTimestamp = Date.now();
|
|
23
|
-
const minShowTime = 500;
|
|
24
|
-
watchOnce(pending, () => {
|
|
25
|
-
const timeShowed = Date.now() - (initialTimestamp || Date.now());
|
|
26
|
-
const restTimeToShow = minShowTime - timeShowed > 0 ? minShowTime - timeShowed : 0;
|
|
27
|
-
if (restTimeToShow === 0) {
|
|
28
|
-
skeleton.value = false;
|
|
29
|
-
} else {
|
|
30
|
-
setTimeout(() => {
|
|
31
|
-
skeleton.value = false;
|
|
32
|
-
}, restTimeToShow);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return skeleton;
|
|
36
|
-
}
|
|
37
|
-
function queryChanged(from, to, queryToWatch) {
|
|
38
|
-
const _queryToWatch = Array.isArray(queryToWatch) ? queryToWatch : [queryToWatch];
|
|
39
|
-
const changes = Object.keys(to).reduce((acc, key) => {
|
|
40
|
-
if (to[key] !== from[key]) {
|
|
41
|
-
acc[key] = to[key];
|
|
42
|
-
}
|
|
43
|
-
return acc;
|
|
44
|
-
}, {});
|
|
45
|
-
return _queryToWatch.some((key) => changes[key] !== void 0);
|
|
46
|
-
}
|
|
47
|
-
export const useUiClient = () => {
|
|
48
|
-
return {
|
|
49
|
-
handler: {
|
|
50
|
-
handleNotFoundResponse,
|
|
51
|
-
handleResponseError
|
|
52
|
-
},
|
|
53
|
-
utils: {
|
|
54
|
-
isFormDisabled,
|
|
55
|
-
createSkeleton,
|
|
56
|
-
queryChanged
|
|
57
|
-
// createFlickerProtectRef
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
};
|
|
File without changes
|
|
File without changes
|