@finema/core 2.1.1 → 2.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 +79 -79
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/App.vue +7 -7
- package/dist/runtime/components/DevToolsWindow/index.vue +95 -95
- package/dist/runtime/components/Dialog/index.vue +61 -50
- package/dist/runtime/components/Empty.vue +12 -12
- package/dist/runtime/components/FlexDeck/Base.vue +67 -67
- package/dist/runtime/components/FlexDeck/index.vue +33 -33
- package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
- package/dist/runtime/components/Form/Fields.vue +13 -13
- package/dist/runtime/components/Form/InputCheckbox/index.vue +18 -18
- package/dist/runtime/components/Form/InputDateTime/index.vue +44 -44
- package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
- package/dist/runtime/components/Form/InputSelect/index.vue +38 -38
- package/dist/runtime/components/Form/InputSelectMultiple/index.vue +43 -43
- package/dist/runtime/components/Form/InputText/index.vue +48 -48
- package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
- package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
- package/dist/runtime/components/Form/index.vue +5 -5
- package/dist/runtime/components/Image.vue +28 -28
- package/dist/runtime/components/Loader.vue +10 -10
- package/dist/runtime/components/Log/index.vue +17 -17
- package/dist/runtime/components/Table/Base.vue +76 -76
- package/dist/runtime/components/Table/ColumnDate.vue +1 -1
- package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
- package/dist/runtime/components/Table/ColumnImage.vue +4 -4
- package/dist/runtime/components/Table/ColumnNumber.vue +1 -1
- package/dist/runtime/components/Table/ColumnText.vue +1 -1
- package/dist/runtime/components/Table/Simple.vue +21 -21
- package/dist/runtime/components/Table/index.vue +100 -100
- package/dist/runtime/helpers/apiPageHelper.js +2 -1
- package/dist/runtime/server/tsconfig.json +3 -3
- package/dist/runtime/types/common.d.ts +1 -1
- package/dist/runtime/utils/ArrayHelper.js +1 -1
- package/dist/runtime/utils/ObjectHelper.js +1 -2
- package/dist/runtime/utils/ParamHelper.js +1 -1
- package/dist/runtime/utils/lodash.d.ts +15 -0
- package/dist/runtime/utils/lodash.js +27 -0
- package/package.json +1 -1
|
@@ -1,116 +1,116 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div
|
|
4
|
-
v-if="options.isEnabledSearch"
|
|
2
|
+
<div>
|
|
3
|
+
<div
|
|
4
|
+
v-if="options.isEnabledSearch"
|
|
5
5
|
:class="theme.searchContainer({
|
|
6
6
|
class: [ui?.searchContainer]
|
|
7
|
-
})"
|
|
8
|
-
>
|
|
9
|
-
<Input
|
|
10
|
-
v-model="q"
|
|
11
|
-
icon="i-heroicons-magnifying-glass"
|
|
12
|
-
:placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
|
|
13
|
-
/>
|
|
14
|
-
</div>
|
|
15
|
-
<div
|
|
16
|
-
v-if="!options.isHideCaption || !options.isHideBottomPagination"
|
|
7
|
+
})"
|
|
8
|
+
>
|
|
9
|
+
<Input
|
|
10
|
+
v-model="q"
|
|
11
|
+
icon="i-heroicons-magnifying-glass"
|
|
12
|
+
:placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
<div
|
|
16
|
+
v-if="!options.isHideCaption || !options.isHideBottomPagination"
|
|
17
17
|
:class="theme.captionContainer({
|
|
18
18
|
class: [ui?.captionContainer]
|
|
19
|
-
})"
|
|
20
|
-
>
|
|
21
|
-
<span
|
|
19
|
+
})"
|
|
20
|
+
>
|
|
21
|
+
<span
|
|
22
22
|
:class="theme.captionBoldText({
|
|
23
23
|
class: [ui?.captionBoldText]
|
|
24
|
-
})"
|
|
25
|
-
>
|
|
26
|
-
ผลลัพธ์ทั้งหมด:</span>
|
|
27
|
-
จำนวน
|
|
28
|
-
<span
|
|
24
|
+
})"
|
|
25
|
+
>
|
|
26
|
+
ผลลัพธ์ทั้งหมด:</span>
|
|
27
|
+
จำนวน
|
|
28
|
+
<span
|
|
29
29
|
:class="theme.captionBoldText({
|
|
30
30
|
class: [ui?.captionBoldText]
|
|
31
|
-
})"
|
|
32
|
-
>{{ options.pageOptions?.totalCount || 0 }}</span>
|
|
33
|
-
รายการ
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<UTable
|
|
37
|
-
v-bind="$attrs"
|
|
38
|
-
:loading="options.status.isLoading"
|
|
39
|
-
:data="options.rawData"
|
|
40
|
-
:columns="options.columns"
|
|
41
|
-
>
|
|
42
|
-
<template #empty>
|
|
43
|
-
<slot
|
|
44
|
-
v-if="options.status.isLoading"
|
|
45
|
-
name="loading"
|
|
46
|
-
>
|
|
47
|
-
<Loader
|
|
48
|
-
:loading="true"
|
|
49
|
-
/>
|
|
50
|
-
</slot>
|
|
51
|
-
<slot
|
|
52
|
-
v-else-if="options.status.isError"
|
|
53
|
-
name="error"
|
|
54
|
-
>
|
|
55
|
-
<div
|
|
56
|
-
class="text-error-400 text-2xl h-[200px] flex justify-center items-center"
|
|
57
|
-
>
|
|
58
|
-
{{ StringHelper.getError(options.status.errorData) }}
|
|
59
|
-
</div>
|
|
60
|
-
</slot>
|
|
61
|
-
|
|
62
|
-
<slot
|
|
63
|
-
v-else
|
|
64
|
-
name="error"
|
|
65
|
-
>
|
|
66
|
-
<Empty />
|
|
67
|
-
</slot>
|
|
68
|
-
</template>
|
|
69
|
-
<template
|
|
70
|
-
v-for="column in options.columns.filter((item) => !!item.type)"
|
|
71
|
-
#[`${column.accessorKey}-cell`]="{ row }"
|
|
72
|
-
:key="column.accessorKey"
|
|
73
|
-
>
|
|
74
|
-
<component
|
|
75
|
-
:is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
|
|
76
|
-
v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
|
|
77
|
-
:value="transformValue(column, row)"
|
|
78
|
-
:column="column"
|
|
79
|
-
:row="row"
|
|
80
|
-
/>
|
|
81
|
-
</template>
|
|
82
|
-
<template
|
|
83
|
-
v-for="(_, slotName) of $slots"
|
|
84
|
-
#[slotName]="slotProps"
|
|
85
|
-
>
|
|
86
|
-
<slot
|
|
87
|
-
:name="slotName"
|
|
88
|
-
v-bind="slotProps || {}"
|
|
89
|
-
/>
|
|
90
|
-
</template>
|
|
91
|
-
</UTable>
|
|
92
|
-
|
|
93
|
-
<div
|
|
31
|
+
})"
|
|
32
|
+
>{{ options.pageOptions?.totalCount || 0 }}</span>
|
|
33
|
+
รายการ
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<UTable
|
|
37
|
+
v-bind="$attrs"
|
|
38
|
+
:loading="options.status.isLoading"
|
|
39
|
+
:data="options.rawData"
|
|
40
|
+
:columns="options.columns"
|
|
41
|
+
>
|
|
42
|
+
<template #empty>
|
|
43
|
+
<slot
|
|
44
|
+
v-if="options.status.isLoading"
|
|
45
|
+
name="loading"
|
|
46
|
+
>
|
|
47
|
+
<Loader
|
|
48
|
+
:loading="true"
|
|
49
|
+
/>
|
|
50
|
+
</slot>
|
|
51
|
+
<slot
|
|
52
|
+
v-else-if="options.status.isError"
|
|
53
|
+
name="error"
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
class="text-error-400 text-2xl h-[200px] flex justify-center items-center"
|
|
57
|
+
>
|
|
58
|
+
{{ StringHelper.getError(options.status.errorData) }}
|
|
59
|
+
</div>
|
|
60
|
+
</slot>
|
|
61
|
+
|
|
62
|
+
<slot
|
|
63
|
+
v-else
|
|
64
|
+
name="error"
|
|
65
|
+
>
|
|
66
|
+
<Empty />
|
|
67
|
+
</slot>
|
|
68
|
+
</template>
|
|
69
|
+
<template
|
|
70
|
+
v-for="column in options.columns.filter((item) => !!item.type)"
|
|
71
|
+
#[`${column.accessorKey}-cell`]="{ row }"
|
|
72
|
+
:key="column.accessorKey"
|
|
73
|
+
>
|
|
74
|
+
<component
|
|
75
|
+
:is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
|
|
76
|
+
v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
|
|
77
|
+
:value="transformValue(column, row)"
|
|
78
|
+
:column="column"
|
|
79
|
+
:row="row"
|
|
80
|
+
/>
|
|
81
|
+
</template>
|
|
82
|
+
<template
|
|
83
|
+
v-for="(_, slotName) of $slots"
|
|
84
|
+
#[slotName]="slotProps"
|
|
85
|
+
>
|
|
86
|
+
<slot
|
|
87
|
+
:name="slotName"
|
|
88
|
+
v-bind="slotProps || {}"
|
|
89
|
+
/>
|
|
90
|
+
</template>
|
|
91
|
+
</UTable>
|
|
92
|
+
|
|
93
|
+
<div
|
|
94
94
|
:class="theme.paginationContainer({
|
|
95
95
|
class: [ui?.paginationContainer]
|
|
96
|
-
})"
|
|
97
|
-
>
|
|
98
|
-
<p
|
|
96
|
+
})"
|
|
97
|
+
>
|
|
98
|
+
<p
|
|
99
99
|
:class="theme.paginationInfo({
|
|
100
100
|
class: [ui?.paginationInfo]
|
|
101
|
-
})"
|
|
102
|
-
>
|
|
103
|
-
ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
|
|
104
|
-
</p>
|
|
105
|
-
<Pagination
|
|
106
|
-
v-model:page="page"
|
|
107
|
-
:default-page="options.pageOptions?.currentPage || 1"
|
|
108
|
-
:items-per-page="options.pageOptions.limit"
|
|
109
|
-
:total="options.pageOptions.totalCount"
|
|
110
|
-
@update:page="emits('pageChange', $event)"
|
|
111
|
-
/>
|
|
112
|
-
</div>
|
|
113
|
-
</div>
|
|
101
|
+
})"
|
|
102
|
+
>
|
|
103
|
+
ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
|
|
104
|
+
</p>
|
|
105
|
+
<Pagination
|
|
106
|
+
v-model:page="page"
|
|
107
|
+
:default-page="options.pageOptions?.currentPage || 1"
|
|
108
|
+
:items-per-page="options.pageOptions.limit"
|
|
109
|
+
:total="options.pageOptions.totalCount"
|
|
110
|
+
@update:page="emits('pageChange', $event)"
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
114
|
</template>
|
|
115
115
|
|
|
116
116
|
<script setup>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCoreConfig } from "../composables/useConfig.js";
|
|
2
|
+
import { _get } from "../utils/lodash.js";
|
|
2
3
|
import { bindParamsToUrl } from "./apiBaseHelper.js";
|
|
3
4
|
import {
|
|
4
5
|
checkExpiration,
|
|
@@ -6,7 +7,7 @@ import {
|
|
|
6
7
|
prepareRequestOptions,
|
|
7
8
|
updateLoaderState
|
|
8
9
|
} from "./apiBaseHelper.js";
|
|
9
|
-
import { _findIndex,
|
|
10
|
+
import { _findIndex, _shuffle } from "#imports";
|
|
10
11
|
export const apiAddHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateData, onUpdateItems, data, opts) => {
|
|
11
12
|
onUpdateStatus(updateLoaderState.setLoading(state().status));
|
|
12
13
|
onUpdateOptions({});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../.nuxt/tsconfig.server.json",
|
|
3
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../.nuxt/tsconfig.server.json",
|
|
3
|
+
}
|
|
@@ -1 +1,16 @@
|
|
|
1
1
|
export declare const _isEmpty: (value: any) => boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Gets the value at path of object. If the resolved value is undefined,
|
|
4
|
+
* the defaultValue is returned in its place.
|
|
5
|
+
*/
|
|
6
|
+
type PathKeys<T> = {
|
|
7
|
+
[K in keyof T]: T[K] extends object ? K extends string | number ? `${K}` | `${K}.${PathKeys<T[K]>}` : never : K extends string | number ? `${K}` : never;
|
|
8
|
+
}[keyof T];
|
|
9
|
+
interface GetFunction {
|
|
10
|
+
<T extends object, K extends PathKeys<T>>(object: T, path: K): any;
|
|
11
|
+
<T extends object, K extends PathKeys<T>, D>(object: T, path: K, defaultValue: D): D;
|
|
12
|
+
<T>(object: any, path: string | (string | number)[], defaultValue: T): T;
|
|
13
|
+
<T = any>(object: any, path: string | (string | number)[]): T | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare const _get: GetFunction;
|
|
16
|
+
export {};
|
|
@@ -10,3 +10,30 @@ export const _isEmpty = (value) => {
|
|
|
10
10
|
}
|
|
11
11
|
return false;
|
|
12
12
|
};
|
|
13
|
+
export const _get = (object, path, defaultValue) => {
|
|
14
|
+
if (object == null) {
|
|
15
|
+
return defaultValue;
|
|
16
|
+
}
|
|
17
|
+
const pathArray = Array.isArray(path) ? path : stringToPath(path);
|
|
18
|
+
let current = object;
|
|
19
|
+
for (let i = 0; i < pathArray.length; i++) {
|
|
20
|
+
if (current == null) {
|
|
21
|
+
return defaultValue;
|
|
22
|
+
}
|
|
23
|
+
current = current[pathArray[i]];
|
|
24
|
+
}
|
|
25
|
+
return current === void 0 ? defaultValue : current;
|
|
26
|
+
};
|
|
27
|
+
const stringToPath = (path) => {
|
|
28
|
+
if (typeof path !== "string") {
|
|
29
|
+
return [path];
|
|
30
|
+
}
|
|
31
|
+
const normalizedPath = path.replace(/\[(\d+)\]/g, ".$1").replace(/\[['"]([^'"]*)['"]\]/g, ".$1").replace(/^\./, "");
|
|
32
|
+
if (normalizedPath === "") {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
return normalizedPath.split(".").map((key) => {
|
|
36
|
+
const numKey = Number(key);
|
|
37
|
+
return !Number.isNaN(numKey) && key === numKey.toString() ? numKey : key;
|
|
38
|
+
});
|
|
39
|
+
};
|