@finema/core 1.4.15 → 1.4.17
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 +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Modal/index.vue +3 -3
- package/dist/runtime/core.config.d.ts +1 -0
- package/dist/runtime/core.config.mjs +2 -1
- package/dist/runtime/ui.config/modal.mjs +11 -9
- package/dist/runtime/utils/TimeHelper.d.ts +3 -0
- package/dist/runtime/utils/TimeHelper.mjs +25 -1
- package/dist/runtime/utils/TimeHelper.spec.mjs +8 -1
- package/dist/runtime/utils/TimeHelper.thai.spec.d.ts +1 -0
- package/dist/runtime/utils/TimeHelper.thai.spec.mjs +30 -0
- package/package.json +18 -18
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
v-if="title"
|
|
16
16
|
:class="[ui.header, { 'flex items-center justify-between': !isHideCloseBtn }]"
|
|
17
17
|
>
|
|
18
|
-
<h1 class="text-
|
|
18
|
+
<h1 class="text-lg font-semibold">{{ title }}</h1>
|
|
19
19
|
<Icon
|
|
20
20
|
v-if="!isHideCloseBtn"
|
|
21
21
|
name="i-heroicons-x-mark"
|
|
22
|
-
class="h-6 w-6 cursor-pointer"
|
|
22
|
+
class="h-6 w-6 cursor-pointer opacity-50"
|
|
23
23
|
@click="close"
|
|
24
24
|
/>
|
|
25
25
|
</div>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<Icon
|
|
32
32
|
v-if="!isHideCloseBtn"
|
|
33
33
|
name="i-heroicons-x-mark"
|
|
34
|
-
class="h-6 w-6 cursor-pointer"
|
|
34
|
+
class="h-6 w-6 cursor-pointer opacity-50"
|
|
35
35
|
@click="close"
|
|
36
36
|
/>
|
|
37
37
|
</div>
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { modal as inheritModal } from "#ui/ui.config";
|
|
2
2
|
export const modal = {
|
|
3
3
|
...inheritModal,
|
|
4
|
-
header: "px-
|
|
5
|
-
innerWrapper: "
|
|
4
|
+
header: "px-6 py-4 border-b",
|
|
5
|
+
innerWrapper: "px-6 py-4",
|
|
6
|
+
padding: "p-6",
|
|
7
|
+
margin: "my-0",
|
|
6
8
|
size: {
|
|
7
|
-
sm: "
|
|
8
|
-
md: "
|
|
9
|
-
lg: "
|
|
10
|
-
xl: "
|
|
9
|
+
sm: "w-full lg:max-w-sm",
|
|
10
|
+
md: "w-full lg:max-w-lg",
|
|
11
|
+
lg: "w-full lg:max-w-2xl",
|
|
12
|
+
xl: "w-full lg:max-w-4xl"
|
|
11
13
|
},
|
|
12
14
|
position: {
|
|
13
|
-
top: "flex min-h-full items-
|
|
14
|
-
center: "flex min-h-full items-
|
|
15
|
-
bottom: "flex min-h-full items-
|
|
15
|
+
top: "flex min-h-full items-start justify-center text-center",
|
|
16
|
+
center: "flex min-h-full items-start lg:items-center justify-center text-center",
|
|
17
|
+
bottom: "flex min-h-full items-start lg:items-end justify-center text-center"
|
|
16
18
|
},
|
|
17
19
|
overlay: {
|
|
18
20
|
background: "bg-gray-500/75 dark:bg-gray-800/75 backdrop-blur-sm"
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare class TimeHelper {
|
|
2
|
+
static thaiFormat: (dateStr: Date, formatStr: string) => string;
|
|
3
|
+
static displayDate: (time: string | Date) => string;
|
|
4
|
+
static displayDateTime: (time: string | Date) => string;
|
|
2
5
|
static toUTC: (time: string | Date) => string;
|
|
3
6
|
static toLocal: (time: string | Date) => string;
|
|
4
7
|
static getCurrentDate: () => string;
|
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
import { addHours, format, formatISO, isDate, isValid, parse, subHours } from "date-fns";
|
|
1
|
+
import { addHours, format, formatISO, isDate, isValid, parse, subHours, addYears } from "date-fns";
|
|
2
2
|
import { useCoreConfig } from "#core/composables/useConfig";
|
|
3
3
|
const dateFormat = useCoreConfig().date_format;
|
|
4
4
|
const dateTimeFormat = useCoreConfig().date_time_format;
|
|
5
5
|
const timeFormat = useCoreConfig().time_format;
|
|
6
|
+
const isThaiYear = useCoreConfig().is_thai_year;
|
|
6
7
|
export class TimeHelper {
|
|
8
|
+
static thaiFormat = (dateStr, formatStr) => {
|
|
9
|
+
let newDateStr = dateStr;
|
|
10
|
+
if (isThaiYear) {
|
|
11
|
+
newDateStr = addYears(dateStr, 543);
|
|
12
|
+
}
|
|
13
|
+
return format(newDateStr, formatStr);
|
|
14
|
+
};
|
|
15
|
+
static displayDate = (time) => {
|
|
16
|
+
if (!time) {
|
|
17
|
+
return time;
|
|
18
|
+
}
|
|
19
|
+
const parsedTime = isDate(time) ? time : new Date(time);
|
|
20
|
+
const newTime = TimeHelper.thaiFormat(parsedTime, dateFormat);
|
|
21
|
+
return isValid(parsedTime) ? newTime : time;
|
|
22
|
+
};
|
|
23
|
+
static displayDateTime = (time) => {
|
|
24
|
+
if (!time) {
|
|
25
|
+
return time;
|
|
26
|
+
}
|
|
27
|
+
const parsedTime = isDate(time) ? time : new Date(time);
|
|
28
|
+
const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormat);
|
|
29
|
+
return isValid(parsedTime) ? newTime : time;
|
|
30
|
+
};
|
|
7
31
|
static toUTC = (time) => {
|
|
8
32
|
if (!time) {
|
|
9
33
|
return time;
|
|
@@ -4,7 +4,8 @@ vi.mock("#core/composables/useConfig", () => ({
|
|
|
4
4
|
useCoreConfig: () => ({
|
|
5
5
|
date_format: "yyyy-MM-dd",
|
|
6
6
|
date_time_format: "yyyy-MM-dd HH:mm",
|
|
7
|
-
time_format: "HH:mm"
|
|
7
|
+
time_format: "HH:mm",
|
|
8
|
+
is_thai_year: false
|
|
8
9
|
})
|
|
9
10
|
}));
|
|
10
11
|
describe("TimeHelper", async () => {
|
|
@@ -20,6 +21,12 @@ describe("TimeHelper", async () => {
|
|
|
20
21
|
const result = TimeHelper.toLocal(inputTime);
|
|
21
22
|
assert.equal(result, expectedOutput);
|
|
22
23
|
});
|
|
24
|
+
it("[thai year ]toLocal should convert time to local format", () => {
|
|
25
|
+
const inputTime = "2023-12-19 12:00";
|
|
26
|
+
const expectedOutput = "2023-12-19 19:00";
|
|
27
|
+
const result = TimeHelper.toLocal(inputTime);
|
|
28
|
+
assert.equal(result, expectedOutput);
|
|
29
|
+
});
|
|
23
30
|
it("getCurrentDate should return the current date in yyyy-MM-dd format", () => {
|
|
24
31
|
const expectedOutputRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
25
32
|
const result = TimeHelper.getCurrentDate();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { assert, describe, it, vi } from "vitest";
|
|
2
|
+
import { TimeHelper } from "./TimeHelper.mjs";
|
|
3
|
+
vi.mock("#core/composables/useConfig", () => ({
|
|
4
|
+
useCoreConfig: () => ({
|
|
5
|
+
date_format: "yyyy-MM-dd",
|
|
6
|
+
date_time_format: "yyyy-MM-dd HH:mm",
|
|
7
|
+
time_format: "HH:mm",
|
|
8
|
+
is_thai_year: true
|
|
9
|
+
})
|
|
10
|
+
}));
|
|
11
|
+
describe("TimeHelper", async () => {
|
|
12
|
+
it("displayDate", () => {
|
|
13
|
+
const inputTime = "2023-12-19 12:00";
|
|
14
|
+
const expectedOutput = "2566-12-19";
|
|
15
|
+
const result = TimeHelper.displayDate(inputTime);
|
|
16
|
+
assert.equal(result, expectedOutput);
|
|
17
|
+
});
|
|
18
|
+
it("displayDateTime", () => {
|
|
19
|
+
const inputTime = "2023-12-19 12:00";
|
|
20
|
+
const expectedOutput = "2566-12-19 12:00";
|
|
21
|
+
const result = TimeHelper.displayDateTime(inputTime);
|
|
22
|
+
assert.equal(result, expectedOutput);
|
|
23
|
+
});
|
|
24
|
+
it("displayDateTime - iso", () => {
|
|
25
|
+
const inputTime = "2023-01-16T22:00:00Z";
|
|
26
|
+
const expectedOutput = "2566-01-17 05:00";
|
|
27
|
+
const result = TimeHelper.displayDateTime(inputTime);
|
|
28
|
+
assert.equal(result, expectedOutput);
|
|
29
|
+
});
|
|
30
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.17",
|
|
4
4
|
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Finema Dev Core Team",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dev": "nuxi dev playground",
|
|
26
26
|
"dev:build": "nuxi build playground",
|
|
27
27
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
28
|
-
"lint": "eslint .",
|
|
29
|
-
"lint:fix": "eslint . --fix",
|
|
28
|
+
"lint": "eslint . --cache",
|
|
29
|
+
"lint:fix": "eslint . --fix --cache",
|
|
30
30
|
"test": "vitest run",
|
|
31
31
|
"test:watch": "vitest watch",
|
|
32
32
|
"release": "release-it --ci",
|
|
@@ -34,21 +34,21 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@nuxt/kit": "^3.7.4",
|
|
37
|
-
"@nuxt/ui": "^2.
|
|
37
|
+
"@nuxt/ui": "^2.12.0",
|
|
38
38
|
"@pinia/nuxt": "^0.5.1",
|
|
39
|
-
"@vee-validate/nuxt": "^4.12.
|
|
40
|
-
"@vee-validate/zod": "^4.12.
|
|
41
|
-
"@vuepic/vue-datepicker": "^7.4.
|
|
42
|
-
"axios": "^1.6.
|
|
43
|
-
"date-fns": "^3.0
|
|
44
|
-
"i18next": "^23.7.
|
|
39
|
+
"@vee-validate/nuxt": "^4.12.4",
|
|
40
|
+
"@vee-validate/zod": "^4.12.4",
|
|
41
|
+
"@vuepic/vue-datepicker": "^7.4.1",
|
|
42
|
+
"axios": "^1.6.5",
|
|
43
|
+
"date-fns": "^3.2.0",
|
|
44
|
+
"i18next": "^23.7.16",
|
|
45
45
|
"lodash-es": "^4.17.21",
|
|
46
46
|
"nuxt-security": "^1.0.0",
|
|
47
47
|
"pinia": "^2.1.7",
|
|
48
48
|
"qrcode.vue": "^3.4.1",
|
|
49
49
|
"url-join": "^5.0.0",
|
|
50
50
|
"zod": "^3.22.4",
|
|
51
|
-
"zod-i18n-map": "^2.
|
|
51
|
+
"zod-i18n-map": "^2.25.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@finema/eslint-config": "^1.2.0",
|
|
@@ -59,25 +59,25 @@
|
|
|
59
59
|
"@nuxt/test-utils": "^3.9.0",
|
|
60
60
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
61
61
|
"@types/lodash-es": "^4.17.12",
|
|
62
|
-
"@types/node": "^
|
|
62
|
+
"@types/node": "^20.10.8",
|
|
63
63
|
"@vue/test-utils": "^2.4.3",
|
|
64
64
|
"changelogen": "^0.5.5",
|
|
65
65
|
"eslint": "^8.56.0",
|
|
66
|
-
"happy-dom": "^
|
|
66
|
+
"happy-dom": "^13.0.0",
|
|
67
67
|
"husky": "^8.0.3",
|
|
68
68
|
"lint-staged": "^15.2.0",
|
|
69
|
-
"nuxt": "^3.
|
|
69
|
+
"nuxt": "^3.9.1",
|
|
70
70
|
"playwright-core": "^1.40.1",
|
|
71
71
|
"prettier": "^3.1.1",
|
|
72
72
|
"release-it": "^17.0.1",
|
|
73
73
|
"sass": "^1.69.5",
|
|
74
|
-
"stylelint": "^16.0
|
|
74
|
+
"stylelint": "^16.1.0",
|
|
75
75
|
"stylelint-config-prettier-scss": "^1.0.0",
|
|
76
|
-
"stylelint-config-standard-scss": "^
|
|
77
|
-
"vitest": "^1.1.
|
|
76
|
+
"stylelint-config-standard-scss": "^13.0.0",
|
|
77
|
+
"vitest": "^1.1.3"
|
|
78
78
|
},
|
|
79
79
|
"lint-staged": {
|
|
80
|
-
"*.{ts,vue,tsx,js}": "eslint --fix",
|
|
80
|
+
"*.{ts,vue,tsx,js}": "eslint --fix --cache",
|
|
81
81
|
"*.{html,json}": "prettier --write"
|
|
82
82
|
}
|
|
83
83
|
}
|