@finema/core 2.20.0 → 2.21.1
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.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/FlexDeck/index.vue +5 -5
- package/dist/runtime/components/FlexDeck/types.d.ts +1 -1
- package/dist/runtime/components/Form/Fields.vue +4 -1
- package/dist/runtime/components/Table/Base.vue +2 -3
- package/dist/runtime/components/Table/ColumnNumber.vue +2 -2
- package/dist/runtime/components/Table/index.vue +3 -3
- package/dist/runtime/components/Table/types.d.ts +1 -1
- package/dist/runtime/composables/useFlexDeck.js +1 -1
- package/dist/runtime/composables/useTable.js +1 -1
- package/dist/runtime/helpers/componentHelper.js +3 -11
- package/dist/runtime/types/index.d.ts +0 -1
- package/dist/runtime/utils/NumberHelper.d.ts +6 -0
- package/dist/runtime/utils/NumberHelper.js +25 -0
- package/dist/runtime/utils/StringHelper.d.ts +0 -2
- package/dist/runtime/utils/StringHelper.js +0 -9
- package/package.json +27 -27
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
{{ pageBetween }} รายการ จากทั้งหมด {{ totalCountWithComma }} รายการ
|
|
54
54
|
</p>
|
|
55
55
|
<Pagination
|
|
56
|
-
v-if="options.pageOptions.totalPage > 1
|
|
57
|
-
:to="options.
|
|
56
|
+
v-if="options.pageOptions.totalPage > 1"
|
|
57
|
+
:to="options.isRouteChange ? to : void 0"
|
|
58
58
|
:default-page="options.pageOptions?.currentPage || 1"
|
|
59
59
|
:items-per-page="options.pageOptions.limit"
|
|
60
60
|
:total="options.pageOptions.totalCount"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
<script setup>
|
|
68
68
|
import { computed, ref, watch } from "vue";
|
|
69
69
|
import { useElementVisibility } from "@vueuse/core";
|
|
70
|
-
import {
|
|
70
|
+
import { NumberHelper } from "#core/utils/NumberHelper";
|
|
71
71
|
import { _debounce, useRouter, useWatchChange, useWatchTrue } from "#imports";
|
|
72
72
|
import { useCoreConfig } from "#core/composables/useConfig";
|
|
73
73
|
import Empty from "#core/components/Empty.vue";
|
|
@@ -108,7 +108,7 @@ const to = (page2) => {
|
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
useWatchChange(() => props.options?.pageOptions?.request?.params, () => {
|
|
111
|
-
if (props.options?.
|
|
111
|
+
if (props.options?.isRouteChange) return;
|
|
112
112
|
router.replace({
|
|
113
113
|
query: props.options?.pageOptions?.request?.params || {}
|
|
114
114
|
});
|
|
@@ -123,7 +123,7 @@ const pageBetween = computed(() => {
|
|
|
123
123
|
return `${start} - ${end}`;
|
|
124
124
|
});
|
|
125
125
|
const totalCountWithComma = computed(() => {
|
|
126
|
-
return !props.options.pageOptions.totalCount ? "0" :
|
|
126
|
+
return !props.options.pageOptions.totalCount ? "0" : NumberHelper.withComma(props.options.pageOptions.totalCount);
|
|
127
127
|
});
|
|
128
128
|
const totalInnerRawData = computed(() => {
|
|
129
129
|
return innerRawData.value?.length || 0;
|
|
@@ -6,7 +6,7 @@ export interface IFlexDeckOptions<T = object> {
|
|
|
6
6
|
pageOptions: IPageOptions;
|
|
7
7
|
isEnabledSearch?: boolean;
|
|
8
8
|
searchPlaceholder?: string;
|
|
9
|
-
|
|
9
|
+
isRouteChange: boolean;
|
|
10
10
|
isHidePagination?: boolean;
|
|
11
11
|
isEnableInfiniteScroll?: boolean;
|
|
12
12
|
}
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
:key="option.props.name"
|
|
11
11
|
:class="option.class"
|
|
12
12
|
:form="form"
|
|
13
|
-
v-bind="{
|
|
13
|
+
v-bind="{
|
|
14
|
+
...getFieldBinding(option),
|
|
15
|
+
...componentMap[option.type]?.props
|
|
16
|
+
}"
|
|
14
17
|
v-on="option.on ?? {}"
|
|
15
18
|
/>
|
|
16
19
|
</div>
|
|
@@ -76,7 +76,7 @@ import { computed } from "vue";
|
|
|
76
76
|
import { COLUMN_TYPES } from "#core/components/Table/types";
|
|
77
77
|
import ColumnNumber from "#core/components/Table/ColumnNumber.vue";
|
|
78
78
|
import ColumnImage from "#core/components/Table/ColumnImage.vue";
|
|
79
|
-
import {
|
|
79
|
+
import { NumberHelper } from "#core/utils/NumberHelper";
|
|
80
80
|
import { ref, watch } from "#imports";
|
|
81
81
|
import ColumnDateTime from "#core/components/Table/ColumnDateTime.vue";
|
|
82
82
|
import Empty from "#core/components/Empty.vue";
|
|
@@ -118,7 +118,6 @@ const uTableCompatibleColumns = computed(
|
|
|
118
118
|
...col,
|
|
119
119
|
key: col.accessorKey
|
|
120
120
|
// Use accessorKey for UTable's key property
|
|
121
|
-
// label: col.label || col.accessorKey // Optional: ensure label if not present, UTable uses key as fallback for header
|
|
122
121
|
}))
|
|
123
122
|
);
|
|
124
123
|
const columnTypeComponents = {
|
|
@@ -148,7 +147,7 @@ const transformValue = (column, row) => {
|
|
|
148
147
|
return column.transform ? column.transform(value, row, column) : value;
|
|
149
148
|
};
|
|
150
149
|
const totalCountWithComma = computed(() => {
|
|
151
|
-
return !props.pageOptions?.totalCount ? "0" :
|
|
150
|
+
return !props.pageOptions?.totalCount ? "0" : NumberHelper.withComma(props.pageOptions.totalCount);
|
|
152
151
|
});
|
|
153
152
|
watch(page, () => {
|
|
154
153
|
emits("pageChange", page.value);
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
<script setup>
|
|
6
6
|
import { computed } from "vue";
|
|
7
|
-
import {
|
|
7
|
+
import { NumberHelper } from "#core/utils/NumberHelper";
|
|
8
8
|
const props = defineProps({
|
|
9
9
|
value: { type: null, required: true },
|
|
10
10
|
row: { type: null, required: true },
|
|
11
11
|
column: { type: null, required: true }
|
|
12
12
|
});
|
|
13
|
-
const getValue = computed(() =>
|
|
13
|
+
const getValue = computed(() => NumberHelper.withComma(props.value));
|
|
14
14
|
</script>
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
:default-page="options.pageOptions?.currentPage || 1"
|
|
91
91
|
:items-per-page="options.pageOptions.limit"
|
|
92
92
|
:total="options.pageOptions.totalCount"
|
|
93
|
-
:to="options.
|
|
93
|
+
:to="options.isRouteChange ? to : void 0"
|
|
94
94
|
@update:page="onPageChange"
|
|
95
95
|
/>
|
|
96
96
|
</div>
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
import { computed } from "vue";
|
|
102
102
|
import { COLUMN_TYPES } from "#core/components/Table/types";
|
|
103
103
|
import { _debounce, ref, useUiConfig, watch, useWatchChange, useRouter } from "#imports";
|
|
104
|
-
import {
|
|
104
|
+
import { NumberHelper } from "#core/utils/NumberHelper";
|
|
105
105
|
import ColumnDate from "#core/components/Table/ColumnDate.vue";
|
|
106
106
|
import ColumnDateTime from "#core/components/Table/ColumnDateTime.vue";
|
|
107
107
|
import ColumnImage from "#core/components/Table/ColumnImage.vue";
|
|
@@ -170,7 +170,7 @@ const totalCountWithComma = computed(() => {
|
|
|
170
170
|
if (!total || total <= 0) {
|
|
171
171
|
return "0";
|
|
172
172
|
}
|
|
173
|
-
return
|
|
173
|
+
return NumberHelper.withComma(total);
|
|
174
174
|
});
|
|
175
175
|
const transformValue = (column, row) => {
|
|
176
176
|
return column.cell ? column.cell({
|
|
@@ -28,7 +28,7 @@ export interface ITableOptions<T extends Record<string, any> = Record<string, an
|
|
|
28
28
|
isHideToolbar?: boolean;
|
|
29
29
|
isEnabledSearch?: boolean;
|
|
30
30
|
searchPlaceholder?: string;
|
|
31
|
-
|
|
31
|
+
isRouteChange: boolean;
|
|
32
32
|
}
|
|
33
33
|
export interface ISimpleTableOptions<T extends Record<string, any> = Record<string, any>> extends IBaseTableOptions<T> {
|
|
34
34
|
limit?: number;
|
|
@@ -7,7 +7,7 @@ export const createFlexDeckOptions = (repo, options) => {
|
|
|
7
7
|
pageOptions: get(repo.fetch.options),
|
|
8
8
|
status: get(repo.fetch.status),
|
|
9
9
|
primary: get(repo.fetch.options).primary || config.default_primary_key,
|
|
10
|
-
|
|
10
|
+
isRouteChange: false,
|
|
11
11
|
...options
|
|
12
12
|
};
|
|
13
13
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, ref
|
|
1
|
+
import { computed, ref } from "#imports";
|
|
2
2
|
export const checkMaxSize = (file, acceptFileSize = 0) => {
|
|
3
3
|
if (acceptFileSize) {
|
|
4
4
|
return file.size / 1e3 <= acceptFileSize;
|
|
@@ -90,22 +90,14 @@ export const useFileProgress = () => {
|
|
|
90
90
|
percent.value = 100;
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
percent.value =
|
|
94
|
-
StringHelper.withFixed(
|
|
95
|
-
(Math.floor(progressEvent.loaded * 100 / progressEvent.total) || 0) * 0.8
|
|
96
|
-
)
|
|
97
|
-
);
|
|
93
|
+
percent.value = (Math.floor(progressEvent.loaded * 100 / progressEvent.total) || 0) * 0.8;
|
|
98
94
|
};
|
|
99
95
|
const onDownloadProgress = (progressEvent) => {
|
|
100
96
|
if (!progressEvent.total || progressEvent.total === 0) {
|
|
101
97
|
percent.value = 100;
|
|
102
98
|
return;
|
|
103
99
|
}
|
|
104
|
-
percent.value =
|
|
105
|
-
StringHelper.withFixed(
|
|
106
|
-
Math.floor(progressEvent.loaded * 100 / progressEvent.total) * 0.2 + 80
|
|
107
|
-
)
|
|
108
|
-
);
|
|
100
|
+
percent.value = Math.floor(progressEvent.loaded * 100 / progressEvent.total) * 0.2 + 80;
|
|
109
101
|
};
|
|
110
102
|
return {
|
|
111
103
|
percent,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare class NumberHelper {
|
|
2
|
+
static withComma: (value?: number | string) => string;
|
|
3
|
+
static withFixed: (value?: number | string) => string;
|
|
4
|
+
static toCurrency: (value?: number | string, currency?: string) => string;
|
|
5
|
+
static toNumber: (value: any) => number;
|
|
6
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class NumberHelper {
|
|
2
|
+
static withComma = (value = 0) => {
|
|
3
|
+
return (+(value || 0)).toLocaleString();
|
|
4
|
+
};
|
|
5
|
+
static withFixed = (value = 0) => {
|
|
6
|
+
return (+(value || 0)).toLocaleString(void 0, {
|
|
7
|
+
minimumFractionDigits: 0,
|
|
8
|
+
maximumFractionDigits: 2
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
static toCurrency = (value = 0, currency = "") => {
|
|
12
|
+
const options = {
|
|
13
|
+
minimumFractionDigits: 2,
|
|
14
|
+
maximumFractionDigits: 2
|
|
15
|
+
};
|
|
16
|
+
if (currency) {
|
|
17
|
+
options.style = "currency";
|
|
18
|
+
options.currency = currency;
|
|
19
|
+
}
|
|
20
|
+
return (+(value || 0)).toLocaleString(void 0, options);
|
|
21
|
+
};
|
|
22
|
+
static toNumber = (value) => {
|
|
23
|
+
return Number(value) || 0;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export declare class StringHelper {
|
|
2
2
|
static genString: (length?: number) => string;
|
|
3
|
-
static withComma: (value?: number | string) => string;
|
|
4
|
-
static withFixed: (value?: number | string) => string;
|
|
5
3
|
static split: (str: string | null | undefined, separator: string | RegExp) => string[];
|
|
6
4
|
static joinURL: (...parts: string[]) => string;
|
|
7
5
|
static truncate: (str: any, num?: number) => any;
|
|
@@ -9,15 +9,6 @@ export class StringHelper {
|
|
|
9
9
|
}
|
|
10
10
|
return result;
|
|
11
11
|
};
|
|
12
|
-
static withComma = (value = 0) => {
|
|
13
|
-
return (+(value || 0)).toLocaleString();
|
|
14
|
-
};
|
|
15
|
-
static withFixed = (value = 0) => {
|
|
16
|
-
return (+(value || 0)).toLocaleString(void 0, {
|
|
17
|
-
minimumFractionDigits: 0,
|
|
18
|
-
maximumFractionDigits: 2
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
12
|
static split = (str, separator) => {
|
|
22
13
|
return `${str || ""}`.split(separator).filter((item) => item).map((item) => item.trim());
|
|
23
14
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Finema Dev Core Team",
|
|
@@ -32,37 +32,37 @@
|
|
|
32
32
|
"dev:build": "nuxi build playground",
|
|
33
33
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
34
34
|
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
35
|
-
"lint": "eslint .",
|
|
36
|
-
"lint:fix": "eslint --fix .",
|
|
35
|
+
"lint": "eslint . --quiet",
|
|
36
|
+
"lint:fix": "eslint --fix . --quiet",
|
|
37
37
|
"test": "vitest run",
|
|
38
38
|
"test:watch": "vitest watch",
|
|
39
39
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
40
40
|
"prepare": "husky"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@nuxt/kit": "^3.17.
|
|
44
|
-
"@nuxt/ui": "^3.
|
|
43
|
+
"@nuxt/kit": "^3.17.5",
|
|
44
|
+
"@nuxt/ui": "^3.2.0",
|
|
45
45
|
"@pinia/nuxt": "^0.11.0",
|
|
46
|
-
"@tiptap/extension-image": "^2.
|
|
47
|
-
"@tiptap/extension-link": "^2.
|
|
48
|
-
"@tiptap/extension-text-align": "^2.
|
|
49
|
-
"@tiptap/extension-text-style": "^2.
|
|
50
|
-
"@tiptap/extension-underline": "^2.
|
|
51
|
-
"@tiptap/extension-youtube": "^2.
|
|
52
|
-
"@tiptap/pm": "^2.
|
|
53
|
-
"@tiptap/starter-kit": "^2.
|
|
54
|
-
"@tiptap/vue-3": "^2.
|
|
55
|
-
"@vee-validate/nuxt": "^4.15.
|
|
56
|
-
"@vee-validate/valibot": "^4.15.
|
|
46
|
+
"@tiptap/extension-image": "^2.23.0",
|
|
47
|
+
"@tiptap/extension-link": "^2.23.0",
|
|
48
|
+
"@tiptap/extension-text-align": "^2.23.0",
|
|
49
|
+
"@tiptap/extension-text-style": "^2.23.0",
|
|
50
|
+
"@tiptap/extension-underline": "^2.23.0",
|
|
51
|
+
"@tiptap/extension-youtube": "^2.23.0",
|
|
52
|
+
"@tiptap/pm": "^2.23.0",
|
|
53
|
+
"@tiptap/starter-kit": "^2.23.0",
|
|
54
|
+
"@tiptap/vue-3": "^2.23.0",
|
|
55
|
+
"@vee-validate/nuxt": "^4.15.1",
|
|
56
|
+
"@vee-validate/valibot": "^4.15.1",
|
|
57
57
|
"@vuepic/vue-datepicker": "^11.0.2",
|
|
58
58
|
"@vueuse/components": "^13.2.0",
|
|
59
|
-
"@vueuse/core": "^13.
|
|
59
|
+
"@vueuse/core": "^13.4.0",
|
|
60
60
|
"@wdns/vue-code-block": "^2.3.5",
|
|
61
|
-
"axios": "^1.
|
|
61
|
+
"axios": "^1.10.0",
|
|
62
62
|
"date-fns": "^4.1.0",
|
|
63
63
|
"date-fns-tz": "^3.2.0",
|
|
64
64
|
"defu": "^6.1.4",
|
|
65
|
-
"maska": "^3.
|
|
65
|
+
"maska": "^3.1.1",
|
|
66
66
|
"nuxt-lodash": "^2.5.3",
|
|
67
67
|
"@iconify-json/heroicons": "^1.2.2",
|
|
68
68
|
"@iconify-json/ph": "^1.2.2",
|
|
@@ -72,25 +72,25 @@
|
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@eslint/js": "^9.26.0",
|
|
75
|
-
"@nuxt/devtools": "^2.
|
|
76
|
-
"@nuxt/eslint-config": "^1.
|
|
75
|
+
"@nuxt/devtools": "^2.6.0",
|
|
76
|
+
"@nuxt/eslint-config": "^1.4.1",
|
|
77
77
|
"@nuxt/module-builder": "^1.0.1",
|
|
78
|
-
"@nuxt/schema": "^3.17.
|
|
78
|
+
"@nuxt/schema": "^3.17.5",
|
|
79
79
|
"@nuxt/test-utils": "^3.19.0",
|
|
80
80
|
"@types/node": "latest",
|
|
81
|
-
"changelogen": "^0.
|
|
81
|
+
"changelogen": "^0.6.1",
|
|
82
82
|
"eslint": "^9.26.0",
|
|
83
83
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
84
|
-
"eslint-plugin-better-tailwindcss": "^3.
|
|
84
|
+
"eslint-plugin-better-tailwindcss": "^3.3.0",
|
|
85
85
|
"husky": "^9.1.7",
|
|
86
86
|
"lint-staged": "^16.0.0",
|
|
87
|
-
"nuxt": "3.17.
|
|
87
|
+
"nuxt": "^3.17.5",
|
|
88
88
|
"typescript": "~5.6.3",
|
|
89
89
|
"typescript-eslint": "^8.18.0",
|
|
90
90
|
"vitest": "^3.1.3",
|
|
91
91
|
"vue-tsc": "^2.2.10"
|
|
92
92
|
},
|
|
93
93
|
"lint-staged": {
|
|
94
|
-
"*": "eslint --fix"
|
|
94
|
+
"*": "eslint --fix --quiet"
|
|
95
95
|
}
|
|
96
|
-
}
|
|
96
|
+
}
|