@finema/core 1.2.2 → 1.3.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/README.md +32 -38
- package/dist/module.d.mts +30 -0
- package/dist/module.d.ts +30 -0
- package/dist/module.json +2 -2
- package/dist/module.mjs +151 -4
- package/dist/runtime/components/Button/Group.vue +31 -0
- package/dist/runtime/components/Button/index.vue +17 -0
- package/dist/runtime/components/Dialog/index.vue +63 -0
- package/dist/runtime/components/Form/FieldWrapper.vue +10 -0
- package/dist/runtime/components/Form/Fields.vue +41 -0
- package/dist/runtime/components/Form/InputSelect/SelectMenu.vue +11 -0
- package/dist/runtime/components/Form/InputSelect/index.vue +11 -0
- package/dist/runtime/components/Form/InputStatic/index.vue +16 -0
- package/dist/runtime/components/Form/InputStatic/types.d.ts +4 -0
- package/dist/runtime/components/Form/InputText/index.vue +28 -0
- package/dist/runtime/components/Form/InputText/types.d.ts +10 -0
- package/dist/runtime/components/Form/InputText/types.mjs +0 -0
- package/dist/runtime/components/Form/InputToggle/index.vue +14 -0
- package/dist/runtime/components/Form/InputToggle/types.d.ts +6 -0
- package/dist/runtime/components/Form/InputToggle/types.mjs +0 -0
- package/dist/runtime/components/Form/index.vue +6 -0
- package/dist/runtime/components/Form/types.d.ts +47 -0
- package/dist/runtime/components/Form/types.mjs +8 -0
- package/dist/runtime/components/Icon.vue +11 -0
- package/dist/runtime/components/Loader.vue +6 -0
- package/dist/runtime/components/Modal/index.vue +145 -0
- package/dist/runtime/components/Slideover/index.vue +109 -0
- package/dist/runtime/components/Table/ColumnImage.vue +13 -0
- package/dist/runtime/components/Table/ColumnNumber.vue +14 -0
- package/dist/runtime/components/Table/index.vue +84 -0
- package/dist/runtime/components/Table/types.d.ts +57 -0
- package/dist/runtime/components/Table/types.mjs +10 -0
- package/dist/runtime/{lib/api → composables}/loaderList.d.ts +0 -1
- package/dist/runtime/{lib/api → composables}/loaderList.mjs +2 -2
- package/dist/runtime/{lib/api → composables}/loaderObject.d.ts +0 -1
- package/dist/runtime/{lib/api → composables}/loaderObject.mjs +2 -2
- package/dist/runtime/{lib/api → composables}/loaderPage.d.ts +4 -2
- package/dist/runtime/{lib/api → composables}/loaderPage.mjs +17 -8
- package/dist/runtime/composables/useConfig.d.ts +3 -0
- package/dist/runtime/composables/useConfig.mjs +9 -0
- package/dist/runtime/composables/useDialog.d.ts +26 -0
- package/dist/runtime/composables/useDialog.mjs +81 -0
- package/dist/runtime/composables/useForm.d.ts +24 -0
- package/dist/runtime/composables/useForm.mjs +44 -0
- package/dist/runtime/composables/useTable.d.ts +18 -0
- package/dist/runtime/composables/useTable.mjs +35 -0
- package/dist/runtime/composables/useWatch.d.ts +3 -0
- package/dist/runtime/composables/useWatch.mjs +22 -0
- package/dist/runtime/core.config.d.ts +4 -0
- package/dist/runtime/core.config.mjs +4 -0
- package/dist/runtime/{lib/api → helpers}/apiListHelper.d.ts +3 -3
- package/dist/runtime/{lib/api → helpers}/apiListHelper.mjs +3 -3
- package/dist/runtime/{lib/api → helpers}/apiObjectHelper.d.ts +3 -3
- package/dist/runtime/{lib/api → helpers}/apiObjectHelper.mjs +3 -3
- package/dist/runtime/{lib/api → helpers}/apiPageHelper.d.ts +4 -4
- package/dist/runtime/{lib/api → helpers}/apiPageHelper.mjs +7 -6
- package/dist/runtime/plugin.mjs +1 -1
- package/dist/runtime/types/common.d.ts +6 -8
- package/dist/runtime/types/common.mjs +0 -0
- package/dist/runtime/types/config.d.ts +1 -0
- package/dist/runtime/types/config.mjs +0 -0
- package/dist/runtime/types/lib.d.ts +63 -76
- package/dist/runtime/types/lib.mjs +0 -0
- package/dist/runtime/{lib/api → types}/loaderTypes.d.ts +1 -1
- package/dist/runtime/types/loaderTypes.mjs +0 -0
- package/dist/runtime/types/utils.d.ts +9 -0
- package/dist/runtime/ui.config.d.ts +2 -0
- package/dist/runtime/ui.config.mjs +44 -0
- package/dist/runtime/ui.css +14 -0
- package/dist/runtime/utils/StringHelper.mjs +1 -1
- package/dist/runtime/utils/lodash.d.ts +7 -0
- package/dist/runtime/utils/lodash.mjs +1 -0
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +13 -12
- package/dist/runtime/composables/useLibs.d.ts +0 -24
- package/dist/runtime/composables/useLibs.mjs +0 -4
- package/dist/runtime/composables/useUtils.d.ts +0 -10
- package/dist/runtime/composables/useUtils.mjs +0 -12
- package/dist/runtime/lib/api/config.d.ts +0 -4
- package/dist/runtime/lib/api/config.mjs +0 -4
- package/dist/runtime/lib/index.d.ts +0 -8
- package/dist/runtime/lib/index.mjs +0 -8
- /package/dist/runtime/{lib/api/loaderTypes.mjs → components/Form/InputStatic/types.mjs} +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { ref, useWatchFalse } from "#imports";
|
|
3
|
+
export var DialogType = /* @__PURE__ */ ((DialogType2) => {
|
|
4
|
+
DialogType2["ERROR"] = "error";
|
|
5
|
+
DialogType2["INFO"] = "info";
|
|
6
|
+
DialogType2["SUCCESS"] = "success";
|
|
7
|
+
DialogType2["WARNING"] = "warning";
|
|
8
|
+
return DialogType2;
|
|
9
|
+
})(DialogType || {});
|
|
10
|
+
export const useDialog = defineStore("_dialog", () => {
|
|
11
|
+
const isShow = ref(false);
|
|
12
|
+
const meta = ref(void 0);
|
|
13
|
+
const isReject = ref(false);
|
|
14
|
+
const proceed = ref(void 0);
|
|
15
|
+
const cancel = ref(void 0);
|
|
16
|
+
const openDialog = async (payload) => {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
isShow.value = true;
|
|
19
|
+
meta.value = payload;
|
|
20
|
+
proceed.value = resolve;
|
|
21
|
+
cancel.value = reject;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const closeDialogProceed = () => {
|
|
25
|
+
isShow.value = false;
|
|
26
|
+
meta.value = void 0;
|
|
27
|
+
};
|
|
28
|
+
const closeDialogCancel = () => {
|
|
29
|
+
isShow.value = false;
|
|
30
|
+
meta.value = void 0;
|
|
31
|
+
isReject.value = true;
|
|
32
|
+
};
|
|
33
|
+
const error = async (payload) => {
|
|
34
|
+
return openDialog({
|
|
35
|
+
...payload,
|
|
36
|
+
type: "error" /* ERROR */
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const success = async (payload) => {
|
|
40
|
+
return openDialog({
|
|
41
|
+
...payload,
|
|
42
|
+
type: "success" /* SUCCESS */
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const info = async (payload) => {
|
|
46
|
+
return openDialog({
|
|
47
|
+
...payload,
|
|
48
|
+
type: "info" /* INFO */
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const warning = async (payload) => {
|
|
52
|
+
return openDialog({
|
|
53
|
+
...payload,
|
|
54
|
+
type: "warning" /* WARNING */
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
useWatchFalse(
|
|
58
|
+
() => isShow.value,
|
|
59
|
+
(val) => {
|
|
60
|
+
if (isReject.value) {
|
|
61
|
+
cancel.value();
|
|
62
|
+
} else {
|
|
63
|
+
proceed.value();
|
|
64
|
+
}
|
|
65
|
+
proceed.value = void 0;
|
|
66
|
+
cancel.value = void 0;
|
|
67
|
+
isReject.value = false;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
return {
|
|
71
|
+
isShow,
|
|
72
|
+
meta,
|
|
73
|
+
openDialog,
|
|
74
|
+
closeDialogCancel,
|
|
75
|
+
closeDialogProceed,
|
|
76
|
+
error,
|
|
77
|
+
success,
|
|
78
|
+
info,
|
|
79
|
+
warning
|
|
80
|
+
};
|
|
81
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DefineComponent, type ComputedRef } from 'vue';
|
|
2
|
+
import { type FieldContext, type FieldOptions } from 'vee-validate';
|
|
3
|
+
import { type IFormField } from '#core/components/Form/types';
|
|
4
|
+
export interface IFieldWrapperProps {
|
|
5
|
+
errorMessage?: string;
|
|
6
|
+
label?: string | any;
|
|
7
|
+
className?: any;
|
|
8
|
+
classInner?: any;
|
|
9
|
+
classInputInner?: any;
|
|
10
|
+
isRequired?: boolean;
|
|
11
|
+
isHideLabel?: boolean;
|
|
12
|
+
customErrorMessage?: string | DefineComponent;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
interface IFieldContext<TValue> extends FieldContext<TValue> {
|
|
16
|
+
isRequired: ComputedRef<boolean>;
|
|
17
|
+
onChange: (e: InputEvent) => void;
|
|
18
|
+
fieldClassName: ComputedRef<any[]>;
|
|
19
|
+
disabled: ComputedRef<boolean>;
|
|
20
|
+
wrapperProps: ComputedRef<IFieldWrapperProps>;
|
|
21
|
+
}
|
|
22
|
+
export declare const useFieldHOC: <TValue = unknown>(newFormProps: IFieldProps, opts?: Partial<FieldOptions<TValue>> | undefined) => IFieldContext<TValue>;
|
|
23
|
+
export declare const createFormFields: (fields: () => IFormField[]) => any;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useField } from "vee-validate";
|
|
2
|
+
import { toTypedSchema } from "@vee-validate/zod";
|
|
3
|
+
import { computed, toRef } from "#imports";
|
|
4
|
+
export const useFieldHOC = (newFormProps, opts) => {
|
|
5
|
+
const field = useField(toRef(newFormProps, "name"), toTypedSchema(newFormProps.rules), {
|
|
6
|
+
form: newFormProps.form,
|
|
7
|
+
...opts
|
|
8
|
+
});
|
|
9
|
+
const isRequired = computed(() => false);
|
|
10
|
+
const onChange = (e) => {
|
|
11
|
+
const target = e.target;
|
|
12
|
+
const newValue = newFormProps.transform ? newFormProps.transform(target.value, field.value, e) : target.value;
|
|
13
|
+
target.value = newValue;
|
|
14
|
+
field.handleChange(newValue);
|
|
15
|
+
};
|
|
16
|
+
const fieldClassName = computed(() => {
|
|
17
|
+
return [
|
|
18
|
+
"form-control peer",
|
|
19
|
+
{
|
|
20
|
+
"input-error": !field.meta.valid && field.meta.dirty,
|
|
21
|
+
"input-success": field.meta.valid && field.meta.dirty
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
...field,
|
|
27
|
+
isRequired,
|
|
28
|
+
onChange,
|
|
29
|
+
fieldClassName,
|
|
30
|
+
disabled: computed(() => newFormProps.isDisabled ?? newFormProps.isReadOnly ?? false),
|
|
31
|
+
wrapperProps: computed(() => ({
|
|
32
|
+
label: newFormProps.label,
|
|
33
|
+
errorMessage: field.errorMessage.value,
|
|
34
|
+
className: newFormProps.class,
|
|
35
|
+
classInner: newFormProps.classInner,
|
|
36
|
+
classInputInner: newFormProps.classInputInner,
|
|
37
|
+
isRequired: isRequired.value,
|
|
38
|
+
isHideLabel: newFormProps.isHideLabel,
|
|
39
|
+
customErrorMessage: newFormProps.customErrorMessage,
|
|
40
|
+
name: newFormProps.name
|
|
41
|
+
}))
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export const createFormFields = (fields) => computed(fields);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ComputedRef } from 'vue';
|
|
2
|
+
import { type Store } from 'pinia';
|
|
3
|
+
import { type IStatus, type IUsePageLoader } from '#imports';
|
|
4
|
+
import { type IColumn, type IRow, type ISimpleTableOptions, type ITableOptions } from '#core/components/Table/types';
|
|
5
|
+
export interface IUseTable<T = object> {
|
|
6
|
+
repo: IUsePageLoader<T> | Store<any, any>;
|
|
7
|
+
columns: () => IColumn[];
|
|
8
|
+
options?: (() => Partial<ITableOptions<T>>) | Partial<ITableOptions<T>>;
|
|
9
|
+
}
|
|
10
|
+
export interface IUseSimpleTable<T = object> {
|
|
11
|
+
items: () => T[];
|
|
12
|
+
status?: () => IStatus;
|
|
13
|
+
columns: () => IColumn[];
|
|
14
|
+
options?: (() => Partial<ISimpleTableOptions<T>>) | Partial<ISimpleTableOptions<T>>;
|
|
15
|
+
}
|
|
16
|
+
export declare const useTable: <T = object>(options: IUseTable<T>) => ComputedRef<ITableOptions<T>>;
|
|
17
|
+
export declare const useSimpleTable: <T = object>(options: IUseSimpleTable<T>) => ComputedRef<ISimpleTableOptions<T>>;
|
|
18
|
+
export declare const createTableOptions: <T = object>(repo: IUsePageLoader<T>, columns: IColumn[], rows: IRow[], options: ITableOptions<T>) => ITableOptions<T>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { get } from "@vueuse/core";
|
|
2
|
+
import { computed, ObjectHelper } from "#imports";
|
|
3
|
+
import { useCoreConfig } from "./useConfig.mjs";
|
|
4
|
+
export const useTable = (options) => computed(() => {
|
|
5
|
+
return createTableOptions(
|
|
6
|
+
options.repo,
|
|
7
|
+
options.columns(),
|
|
8
|
+
get(options.repo.fetchItems),
|
|
9
|
+
typeof options.options === "function" ? options.options() : options.options ?? {}
|
|
10
|
+
);
|
|
11
|
+
});
|
|
12
|
+
export const useSimpleTable = (options) => computed(() => {
|
|
13
|
+
const config = useCoreConfig();
|
|
14
|
+
return {
|
|
15
|
+
items: options.items(),
|
|
16
|
+
columns: options.columns(),
|
|
17
|
+
rawData: options.items(),
|
|
18
|
+
status: options.status ? options.status() : ObjectHelper.createStatus(),
|
|
19
|
+
primary: config.default_primary_key,
|
|
20
|
+
...typeof options.options === "function" ? options.options() : options.options ?? {}
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
export const createTableOptions = (repo, columns, rows, options) => {
|
|
24
|
+
const config = useCoreConfig();
|
|
25
|
+
return {
|
|
26
|
+
rawData: get(repo.fetchItems),
|
|
27
|
+
pageOptions: get(repo.fetchOptions),
|
|
28
|
+
columns,
|
|
29
|
+
status: get(repo.fetchStatus),
|
|
30
|
+
deleteStatus: get(repo.deleteStatus),
|
|
31
|
+
primary: get(repo.fetchOptions).primary ?? config.default_primary_key,
|
|
32
|
+
isNotChangeRoute: false,
|
|
33
|
+
...options
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const useWatchTrue: (source: () => boolean, cb: (v: boolean, o: boolean) => any) => void;
|
|
2
|
+
export declare const useWatchFalse: (source: () => boolean, cb: (v: boolean, o: boolean) => any) => void;
|
|
3
|
+
export declare const useWatchChange: (source: () => any, cb: (v: any, o: any) => any) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ParamHelper, watch } from "#imports";
|
|
2
|
+
export const useWatchTrue = (source, cb) => {
|
|
3
|
+
watch(source, (value, oldVal) => {
|
|
4
|
+
if (ParamHelper.isChangeWithTrue(value, oldVal)) {
|
|
5
|
+
cb(value, oldVal);
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export const useWatchFalse = (source, cb) => {
|
|
10
|
+
watch(source, (value, oldVal) => {
|
|
11
|
+
if (ParamHelper.isChangeWithFalse(value, oldVal)) {
|
|
12
|
+
cb(value, oldVal);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export const useWatchChange = (source, cb) => {
|
|
17
|
+
watch(source, (value, oldVal) => {
|
|
18
|
+
if (value !== oldVal) {
|
|
19
|
+
cb(value, oldVal);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type IAPIListState, type IAPIOptions, type IStatus } from '
|
|
2
|
-
import { type IListLoaderOptions, type IListRunLoaderOptions } from '
|
|
3
|
-
export declare const apiListHelper: <T, O>(state: () => IAPIListState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateItems: (data: T[]) => void, opts:
|
|
1
|
+
import { type IAPIListState, type IAPIOptions, type IStatus } from '#core/types/lib';
|
|
2
|
+
import { type IListLoaderOptions, type IListRunLoaderOptions } from '#core/types/loaderTypes';
|
|
3
|
+
export declare const apiListHelper: <T, O>(state: () => IAPIListState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateItems: (data: T[]) => void, opts: any) => Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ObjectHelper } from "../utils/ObjectHelper.mjs";
|
|
2
|
+
import { ParamHelper } from "#imports";
|
|
3
|
+
import { NewRequester } from "#core/lib/Requester";
|
|
4
4
|
export const apiListHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateItems, opts) => {
|
|
5
5
|
const timestamp = state().options._timestamp;
|
|
6
6
|
if (opts.expire && timestamp) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type IAPIObjectState, type IAPIOptions, type IStatus } from '
|
|
2
|
-
import { type IObjectLoaderOptions, type IObjectRunLoaderOptions } from '
|
|
3
|
-
export declare const apiObjectHelper: <T, B, O>(state: () => IAPIObjectState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: any) => void, data: B | undefined, opts:
|
|
1
|
+
import { type IAPIObjectState, type IAPIOptions, type IStatus } from '#core/types/lib';
|
|
2
|
+
import { type IObjectLoaderOptions, type IObjectRunLoaderOptions } from '#core/types/loaderTypes';
|
|
3
|
+
export declare const apiObjectHelper: <T, B, O>(state: () => IAPIObjectState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: any) => void, data: B | undefined, opts: any) => Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ObjectHelper } from "../utils/ObjectHelper.mjs";
|
|
2
|
+
import { ParamHelper } from "#core/utils/ParamHelper";
|
|
3
|
+
import { NewRequester } from "#core/lib/Requester";
|
|
4
4
|
export const apiObjectHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateData, data, opts) => {
|
|
5
5
|
const timestamp = state().options._timestamp;
|
|
6
6
|
if (opts.expire && timestamp) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type IPageDeleteLoaderOptions, type IPageFetchLoaderOptions, type IPageFindLoaderOptions, type IPageLoaderOptions, type IPageUpdateLoaderOptions } from '#core/types/loaderTypes';
|
|
2
|
+
import { type IAPIAddState, type IAPIDeleteState, type IAPIFetchState, type IAPIFindState, type IAPIOptions, type IAPIUpdateState, type IPageOptions, type IStatus } from '#core/types/lib';
|
|
3
3
|
export declare const apiAddHelper: <T>(state: () => IAPIAddState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: any) => void, onUpdateItems: (data: any[]) => void, data: any, opts: IPageLoaderOptions<any> & IPageFetchLoaderOptions) => Promise<void>;
|
|
4
4
|
export declare const apiDeleteHelper: <T>(state: () => IAPIDeleteState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, _onUpdateData: (data: T) => void, onUpdateItems: (data: T[]) => void, id: string | number, opts: IPageLoaderOptions<any> & IPageDeleteLoaderOptions) => Promise<void>;
|
|
5
|
-
export declare const apiFetchHelper: <T>(state: () => IAPIFetchState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IPageOptions) => void, onUpdateItems: (items: T[]) => void, page: number, query: string, opts:
|
|
6
|
-
export declare const apiFindHelper: <T>(state: () => IAPIFindState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: any) => void, id: string | number, opts:
|
|
5
|
+
export declare const apiFetchHelper: <T>(state: () => IAPIFetchState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IPageOptions) => void, onUpdateItems: (items: T[]) => void, page: number, query: string, opts: any) => Promise<void>;
|
|
6
|
+
export declare const apiFindHelper: <T>(state: () => IAPIFindState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: any) => void, id: string | number, opts: any) => Promise<void>;
|
|
7
7
|
export declare const updateHelper: <T>(state: () => IAPIUpdateState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: T) => void, _onUpdateItems: (data: T[]) => void, onUpdateOldData: (data: T) => void, id: string | number, data: any, opts: IPageLoaderOptions<any> & IPageUpdateLoaderOptions) => Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { ObjectHelper } from "../utils/ObjectHelper.mjs";
|
|
2
|
+
import { ParamHelper } from "#core/utils/ParamHelper";
|
|
3
|
+
import { NewRequester } from "#core/lib/Requester";
|
|
4
|
+
import { _findIndex, _get, _shuffle } from "#core/utils/lodash";
|
|
5
|
+
import { useCoreConfig } from "../composables/useConfig.mjs";
|
|
6
6
|
export const apiAddHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateData, onUpdateItems, data, opts) => {
|
|
7
7
|
onUpdateStatus(ObjectHelper.toLoadingStatus(state().status));
|
|
8
8
|
onUpdateOptions({});
|
|
@@ -88,6 +88,7 @@ export const apiDeleteHelper = async (state, onUpdateStatus, onUpdateOptions, _o
|
|
|
88
88
|
onUpdateStatus(ObjectHelper.toCompleteStatus(state().status));
|
|
89
89
|
};
|
|
90
90
|
export const apiFetchHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateItems, page, query, opts) => {
|
|
91
|
+
const config = useCoreConfig();
|
|
91
92
|
const timestamp = state().options._timestamp;
|
|
92
93
|
if (opts.expire && timestamp) {
|
|
93
94
|
if (timestamp + opts.expire > Date.now()) {
|
|
@@ -117,7 +118,7 @@ export const apiFetchHelper = async (state, onUpdateStatus, onUpdateOptions, onU
|
|
|
117
118
|
...opts.getBaseRequestOptions?.() || {},
|
|
118
119
|
...opts.fetch?.getRequestOptions?.(page, query, opts) ?? {}
|
|
119
120
|
};
|
|
120
|
-
const limit = reqOptions.params?.limit ||
|
|
121
|
+
const limit = reqOptions.params?.limit || config.limit_per_page;
|
|
121
122
|
reqOptions.params = {
|
|
122
123
|
limit,
|
|
123
124
|
page,
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
export interface IError {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
code: string;
|
|
3
|
+
message: any;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
export interface IOption {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
value: any;
|
|
7
|
+
label: string;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
params?: Record<string, any>
|
|
9
|
+
export interface IGetParams {
|
|
10
|
+
params?: Record<string, any>;
|
|
13
11
|
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type UIComponentList = 'modal' | 'slideover';
|
|
File without changes
|
|
@@ -1,102 +1,89 @@
|
|
|
1
|
-
import { type AxiosRequestConfig } from 'axios'
|
|
2
|
-
|
|
1
|
+
import { type AxiosRequestConfig } from 'axios';
|
|
3
2
|
export interface IAPIOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
_status?: number;
|
|
4
|
+
_timestamp?: number;
|
|
5
|
+
request?: Partial<AxiosRequestConfig>;
|
|
6
|
+
[key: string]: any;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
export interface IPageOptions extends IAPIOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
currentPageCount: number;
|
|
10
|
+
currentPage: number;
|
|
11
|
+
totalPage: number;
|
|
12
|
+
totalCount: number;
|
|
13
|
+
limit: number;
|
|
14
|
+
search?: string;
|
|
15
|
+
primary?: string;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
export interface IStatus {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
isError: boolean;
|
|
19
|
+
isSuccess: boolean;
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
isLoaded: boolean;
|
|
22
|
+
errorData: any | null;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
export interface IAPIFetchState<T> {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
items: T[];
|
|
26
|
+
status: IStatus;
|
|
27
|
+
options: IPageOptions;
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
export interface IAPIFindState<T> {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
data: T;
|
|
31
|
+
status: IStatus;
|
|
32
|
+
options: IAPIOptions;
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
export interface IAPIAddState<T> {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
data: T;
|
|
36
|
+
items: T[];
|
|
37
|
+
status: IStatus;
|
|
38
|
+
options: IAPIOptions;
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
export interface IAPIObjectState<T> {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
data: T | null;
|
|
42
|
+
status: IStatus;
|
|
43
|
+
options: IAPIOptions;
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
export interface IAPIListState<T> {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
items: T[];
|
|
47
|
+
status: IStatus;
|
|
48
|
+
options: IAPIOptions;
|
|
57
49
|
}
|
|
58
|
-
|
|
59
50
|
export interface IAPIDeleteState<T> {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
data: T;
|
|
52
|
+
items: T[];
|
|
53
|
+
status: IStatus;
|
|
54
|
+
options: IAPIOptions;
|
|
64
55
|
}
|
|
65
|
-
|
|
66
56
|
export interface IAPIUpdateState<T> {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
data: T;
|
|
58
|
+
oldData: T;
|
|
59
|
+
items: T[] | undefined | null;
|
|
60
|
+
status: IStatus;
|
|
61
|
+
options: IAPIOptions;
|
|
72
62
|
}
|
|
73
|
-
|
|
74
63
|
export interface IPageState<T> {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
64
|
+
deleteStatus: IStatus;
|
|
65
|
+
updateStatus: IStatus;
|
|
66
|
+
addStatus: IStatus;
|
|
67
|
+
findStatus: IStatus;
|
|
68
|
+
fetchStatus: IStatus;
|
|
69
|
+
fetchItems: T[];
|
|
70
|
+
findItem: null | T;
|
|
71
|
+
addItem: null | T;
|
|
72
|
+
updateItem: null | T;
|
|
73
|
+
deleteItem: null | T | any;
|
|
74
|
+
findOptions: object;
|
|
75
|
+
addOptions: object;
|
|
76
|
+
deleteOptions: object;
|
|
77
|
+
updateOptions: object;
|
|
78
|
+
fetchOptions: IPageOptions;
|
|
90
79
|
}
|
|
91
|
-
|
|
92
80
|
export interface IObjectState<T> {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
data: T | null;
|
|
82
|
+
status: IStatus;
|
|
83
|
+
options: IAPIOptions;
|
|
96
84
|
}
|
|
97
|
-
|
|
98
85
|
export interface IListState<T> {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
items: T[];
|
|
87
|
+
status: IStatus;
|
|
88
|
+
options: IAPIOptions;
|
|
102
89
|
}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AxiosRequestConfig, type Method } from 'axios';
|
|
2
2
|
import { type Ref, type UnwrapRef } from 'vue';
|
|
3
|
-
import { type IAPIOptions, type IPageOptions, type IStatus } from '
|
|
3
|
+
import { type IAPIOptions, type IPageOptions, type IStatus } from '~/src/runtime/types/lib';
|
|
4
4
|
export interface IPageFetchLoaderOptions<D = Record<string, any>> {
|
|
5
5
|
isMock?: boolean;
|
|
6
6
|
params?: Record<string, any>;
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Strategy = 'merge' | 'override'
|
|
2
|
+
|
|
3
|
+
export type NestedKeyOf<ObjectType extends object> = {
|
|
4
|
+
[Key in keyof ObjectType]: ObjectType[Key] extends object ? NestedKeyOf<ObjectType[Key]> : Key
|
|
5
|
+
}[keyof ObjectType]
|
|
6
|
+
|
|
7
|
+
export type DeepPartial<T> = Partial<{
|
|
8
|
+
[P in keyof T]: DeepPartial<T[P]> | Record<string, string>
|
|
9
|
+
}>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { modal as inheritModal, slideover as inheritSlideover } from "#ui/ui.config";
|
|
2
|
+
export const modal = {
|
|
3
|
+
...inheritModal,
|
|
4
|
+
header: "px-4 py-2 border-b",
|
|
5
|
+
innerWrapper: "p-4",
|
|
6
|
+
size: {
|
|
7
|
+
sm: "sm:max-w-sm",
|
|
8
|
+
md: "sm:max-w-lg",
|
|
9
|
+
lg: "sm:max-w-2xl",
|
|
10
|
+
xl: "sm:max-w-4xl"
|
|
11
|
+
},
|
|
12
|
+
position: {
|
|
13
|
+
top: "flex min-h-full items-end sm:items-start justify-center text-center",
|
|
14
|
+
center: "flex min-h-full items-end sm:items-center justify-center text-center",
|
|
15
|
+
bottom: "flex min-h-full items-end sm:items-end justify-center text-center"
|
|
16
|
+
},
|
|
17
|
+
fixHeightSize: {
|
|
18
|
+
default: "max-h-[calc(100vh-4rem)]",
|
|
19
|
+
sm: "max-h-[256px]",
|
|
20
|
+
md: "max-h-[512px]",
|
|
21
|
+
lg: "max-h-[768px]",
|
|
22
|
+
xl: "max-h-[1024px]"
|
|
23
|
+
},
|
|
24
|
+
default: {
|
|
25
|
+
size: "md",
|
|
26
|
+
position: "center",
|
|
27
|
+
fixHeightSize: "default"
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export const slideover = {
|
|
31
|
+
...inheritSlideover,
|
|
32
|
+
bodyWrapper: "p-4",
|
|
33
|
+
size: {
|
|
34
|
+
sm: "w-screen max-w-xs",
|
|
35
|
+
md: "w-screen max-w-md",
|
|
36
|
+
lg: "w-screen max-w-xl",
|
|
37
|
+
xl: "w-screen max-w-2xl",
|
|
38
|
+
half: "w-screen max-w-[calc(100vw/2)]",
|
|
39
|
+
full: "w-screen max-w-full"
|
|
40
|
+
},
|
|
41
|
+
default: {
|
|
42
|
+
size: "md"
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--color-primary-50: 248 248 255;
|
|
3
|
+
--color-primary-100: 232 239 253;
|
|
4
|
+
--color-primary-200: 190 227 248;
|
|
5
|
+
--color-primary-300: 144 205 244;
|
|
6
|
+
--color-primary-400: 99 179 237;
|
|
7
|
+
--color-primary-500: 54 117 251;
|
|
8
|
+
--color-primary-600: 0 104 254;
|
|
9
|
+
--color-primary-700: 43 108 176;
|
|
10
|
+
--color-primary-800: 44 82 130;
|
|
11
|
+
--color-primary-900: 32 36 62;
|
|
12
|
+
--color-primary-950: 32 36 62;
|
|
13
|
+
--color-primary-DEFAULT: 54 117 251;
|
|
14
|
+
}
|
|
@@ -33,7 +33,7 @@ export class StringHelper {
|
|
|
33
33
|
if (errorData.code !== "INVALID_PARAMS" && !errorData.fields) {
|
|
34
34
|
return msg;
|
|
35
35
|
}
|
|
36
|
-
for (const [
|
|
36
|
+
for (const [, value] of Object.entries(errorData.fields)) {
|
|
37
37
|
msg = value.message;
|
|
38
38
|
}
|
|
39
39
|
return msg;
|
|
@@ -43,6 +43,13 @@ export declare const _map: {
|
|
|
43
43
|
<T_5>(collection: lodash.Dictionary<T_5> | lodash.NumericDictionary<T_5> | null | undefined, iteratee?: string | undefined): any[];
|
|
44
44
|
<T_6>(collection: lodash.Dictionary<T_6> | lodash.NumericDictionary<T_6> | null | undefined, iteratee?: object | undefined): boolean[];
|
|
45
45
|
};
|
|
46
|
+
export declare const _merge: {
|
|
47
|
+
<TObject, TSource>(object: TObject, source: TSource): TObject & TSource;
|
|
48
|
+
<TObject_1, TSource1, TSource2>(object: TObject_1, source1: TSource1, source2: TSource2): TObject_1 & TSource1 & TSource2;
|
|
49
|
+
<TObject_2, TSource1_1, TSource2_1, TSource3>(object: TObject_2, source1: TSource1_1, source2: TSource2_1, source3: TSource3): TObject_2 & TSource1_1 & TSource2_1 & TSource3;
|
|
50
|
+
<TObject_3, TSource1_2, TSource2_2, TSource3_1, TSource4>(object: TObject_3, source1: TSource1_2, source2: TSource2_2, source3: TSource3_1, source4: TSource4): TObject_3 & TSource1_2 & TSource2_2 & TSource3_1 & TSource4;
|
|
51
|
+
(object: any, ...otherArgs: any[]): any;
|
|
52
|
+
};
|
|
46
53
|
export declare const _flatDeep: <T>(array: lodash.ListOfRecursiveArraysOrValues<T> | null | undefined) => lodash.Flat<T>[];
|
|
47
54
|
export declare const _uniq: <T>(array: lodash.List<T> | null | undefined) => T[];
|
|
48
55
|
export declare const _sortBy: {
|