@finema/core 1.4.3 → 1.4.6
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 +3 -0
- package/dist/module.d.ts +3 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Form/Fields.vue +10 -10
- package/dist/runtime/components/Form/InputDateTime/date_time_field.types.d.ts +8 -0
- package/dist/runtime/components/Form/InputDateTime/index.vue +6 -2
- package/dist/runtime/composables/useConfig.mjs +1 -1
- package/dist/runtime/core.config.d.ts +3 -0
- package/dist/runtime/core.config.mjs +4 -1
- package/dist/runtime/utils/TimeHelper.mjs +4 -3
- package/dist/runtime/utils/TimeHelper.spec.mjs +61 -52
- package/package.json +82 -79
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -9,63 +9,63 @@
|
|
|
9
9
|
v-on="option.on ?? {}"
|
|
10
10
|
/>
|
|
11
11
|
<FormInputText
|
|
12
|
-
v-if="option.type === INPUT_TYPES.TEXT"
|
|
12
|
+
v-else-if="option.type === INPUT_TYPES.TEXT"
|
|
13
13
|
:form="form"
|
|
14
14
|
v-bind="option.props"
|
|
15
15
|
v-on="option.on ?? {}"
|
|
16
16
|
/>
|
|
17
17
|
<FormInputText
|
|
18
|
-
v-if="option.type === INPUT_TYPES.PASSWORD"
|
|
18
|
+
v-else-if="option.type === INPUT_TYPES.PASSWORD"
|
|
19
19
|
type="password"
|
|
20
20
|
:form="form"
|
|
21
21
|
v-bind="option.props"
|
|
22
22
|
v-on="option.on ?? {}"
|
|
23
23
|
/>
|
|
24
24
|
<FormInputText
|
|
25
|
-
v-if="option.type === INPUT_TYPES.EMAIL"
|
|
25
|
+
v-else-if="option.type === INPUT_TYPES.EMAIL"
|
|
26
26
|
type="email"
|
|
27
27
|
:form="form"
|
|
28
28
|
v-bind="option.props"
|
|
29
29
|
v-on="option.on ?? {}"
|
|
30
30
|
/>
|
|
31
31
|
<FormInputTextarea
|
|
32
|
-
v-if="option.type === INPUT_TYPES.TEXTAREA"
|
|
32
|
+
v-else-if="option.type === INPUT_TYPES.TEXTAREA"
|
|
33
33
|
:form="form"
|
|
34
34
|
v-bind="option.props"
|
|
35
35
|
v-on="option.on ?? {}"
|
|
36
36
|
/>
|
|
37
37
|
<FormInputToggle
|
|
38
|
-
v-if="option.type === INPUT_TYPES.TOGGLE"
|
|
38
|
+
v-else-if="option.type === INPUT_TYPES.TOGGLE"
|
|
39
39
|
:form="form"
|
|
40
40
|
v-bind="option.props"
|
|
41
41
|
v-on="option.on ?? {}"
|
|
42
42
|
/>
|
|
43
43
|
<FormInputSelect
|
|
44
|
-
v-if="option.type === INPUT_TYPES.SELECT"
|
|
44
|
+
v-else-if="option.type === INPUT_TYPES.SELECT"
|
|
45
45
|
:form="form"
|
|
46
46
|
v-bind="option.props"
|
|
47
47
|
v-on="option.on ?? {}"
|
|
48
48
|
/>
|
|
49
49
|
<FormInputRadio
|
|
50
|
-
v-if="option.type === INPUT_TYPES.RADIO"
|
|
50
|
+
v-else-if="option.type === INPUT_TYPES.RADIO"
|
|
51
51
|
:form="form"
|
|
52
52
|
v-bind="option.props"
|
|
53
53
|
v-on="option.on ?? {}"
|
|
54
54
|
/>
|
|
55
55
|
<FormInputCheckbox
|
|
56
|
-
v-if="option.type === INPUT_TYPES.CHECKBOX"
|
|
56
|
+
v-else-if="option.type === INPUT_TYPES.CHECKBOX"
|
|
57
57
|
:form="form"
|
|
58
58
|
v-bind="option.props"
|
|
59
59
|
v-on="option.on ?? {}"
|
|
60
60
|
/>
|
|
61
61
|
<FormInputDateTime
|
|
62
|
-
v-if="option.type === INPUT_TYPES.DATE_TIME"
|
|
62
|
+
v-else-if="option.type === INPUT_TYPES.DATE_TIME"
|
|
63
63
|
:form="form"
|
|
64
64
|
v-bind="option.props"
|
|
65
65
|
v-on="option.on ?? {}"
|
|
66
66
|
/>
|
|
67
67
|
<FormInputDateTime
|
|
68
|
-
v-if="option.type === INPUT_TYPES.DATE"
|
|
68
|
+
v-else-if="option.type === INPUT_TYPES.DATE"
|
|
69
69
|
:form="form"
|
|
70
70
|
v-bind="option.props"
|
|
71
71
|
:disabled-time="true"
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { type IFieldProps, type IFormFieldBase, type INPUT_TYPES } from '#core/components/Form/types';
|
|
2
|
+
export interface ITimeOption {
|
|
3
|
+
hours?: number | string;
|
|
4
|
+
minutes?: number | string;
|
|
5
|
+
seconds?: number | string;
|
|
6
|
+
}
|
|
2
7
|
export interface IDateTimeFieldProps extends IFieldProps {
|
|
3
8
|
disabledTime?: boolean;
|
|
4
9
|
minDate?: Date | string;
|
|
5
10
|
maxDate?: Date | string;
|
|
11
|
+
startTime?: ITimeOption;
|
|
12
|
+
minTime?: ITimeOption;
|
|
13
|
+
maxTime?: ITimeOption;
|
|
6
14
|
}
|
|
7
15
|
export type IDateTimeField = IFormFieldBase<INPUT_TYPES.DATE_TIME | INPUT_TYPES.DATE, IDateTimeFieldProps, {
|
|
8
16
|
change: (value: string) => void;
|
|
@@ -11,13 +11,17 @@
|
|
|
11
11
|
:format="format"
|
|
12
12
|
:min-date="minDate"
|
|
13
13
|
:max-date="maxDate"
|
|
14
|
+
:min-time="minTime"
|
|
15
|
+
:max-time="maxTime"
|
|
16
|
+
:start-time="startTime"
|
|
14
17
|
:required="isRequired"
|
|
18
|
+
time-picker-inline
|
|
15
19
|
>
|
|
16
|
-
<template #dp-input="{ value }">
|
|
20
|
+
<template #dp-input="{ value: innerValue }">
|
|
17
21
|
<UInput
|
|
18
22
|
icon="i-heroicons-calendar-days"
|
|
19
23
|
type="text"
|
|
20
|
-
:value="
|
|
24
|
+
:value="innerValue"
|
|
21
25
|
:placeholder="wrapperProps.placeholder"
|
|
22
26
|
:readonly="true"
|
|
23
27
|
input-class="cursor-pointer select-none"
|
|
@@ -2,7 +2,7 @@ import { mergeConfig } from "#ui/utils";
|
|
|
2
2
|
import { core } from "#core/core.config";
|
|
3
3
|
import appConfig from "#build/app.config";
|
|
4
4
|
export const useCoreConfig = () => {
|
|
5
|
-
return mergeConfig(
|
|
5
|
+
return mergeConfig("override", appConfig.core, core);
|
|
6
6
|
};
|
|
7
7
|
export const useUiConfig = (config, name) => {
|
|
8
8
|
return mergeConfig(appConfig.ui.strategy, appConfig.ui[name], config);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { addHours, format, formatISO, isDate, isValid, parse, subHours } from "date-fns";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
2
|
+
import { useCoreConfig } from "#core/composables/useConfig";
|
|
3
|
+
const dateFormat = useCoreConfig().date_format;
|
|
4
|
+
const dateTimeFormat = useCoreConfig().date_time_format;
|
|
5
|
+
const timeFormat = useCoreConfig().time_format;
|
|
5
6
|
export class TimeHelper {
|
|
6
7
|
static toUTC = (time) => {
|
|
7
8
|
if (!time) {
|
|
@@ -1,54 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assert, describe, it, vi } from "vitest";
|
|
2
2
|
import { TimeHelper } from "./TimeHelper.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
+
})
|
|
9
|
+
}));
|
|
10
|
+
describe("TimeHelper", async () => {
|
|
11
|
+
it("toUTC should convert time to UTC format", () => {
|
|
12
|
+
const inputTime = "2023-12-19 12:00";
|
|
13
|
+
const expectedOutput = "2023-12-19 05:00";
|
|
14
|
+
const result = TimeHelper.toUTC(inputTime);
|
|
15
|
+
assert.equal(result, expectedOutput);
|
|
16
|
+
});
|
|
17
|
+
it("toLocal should convert time to local format", () => {
|
|
18
|
+
const inputTime = "2023-12-19 12:00";
|
|
19
|
+
const expectedOutput = "2023-12-19 19:00";
|
|
20
|
+
const result = TimeHelper.toLocal(inputTime);
|
|
21
|
+
assert.equal(result, expectedOutput);
|
|
22
|
+
});
|
|
23
|
+
it("getCurrentDate should return the current date in yyyy-MM-dd format", () => {
|
|
24
|
+
const expectedOutputRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
25
|
+
const result = TimeHelper.getCurrentDate();
|
|
26
|
+
assert.match(result, expectedOutputRegex);
|
|
27
|
+
});
|
|
28
|
+
it("getDateFormTime should convert time to date format", () => {
|
|
29
|
+
const inputTime = "2023-12-19 12:00";
|
|
30
|
+
const expectedOutput = "2023-12-19";
|
|
31
|
+
const result = TimeHelper.getDateFormTime(inputTime);
|
|
32
|
+
assert.equal(result, expectedOutput);
|
|
33
|
+
});
|
|
34
|
+
it("getDateFormTimeWithLocal should convert time to date format with local time", () => {
|
|
35
|
+
const inputTime = "2023-12-19 12:00";
|
|
36
|
+
const expectedOutputRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
37
|
+
const result = TimeHelper.getDateFormTimeWithLocal(inputTime);
|
|
38
|
+
assert.match(result, expectedOutputRegex);
|
|
39
|
+
});
|
|
40
|
+
it("getISODateTimeFormTime should convert time to ISO date-time format", () => {
|
|
41
|
+
const inputTime = "2023-12-19 14:30";
|
|
42
|
+
const expectedOutput = "2023-12-19T14:30:00+07:00";
|
|
43
|
+
const result = TimeHelper.getISODateTimeFormTime(inputTime);
|
|
44
|
+
assert.equal(result, expectedOutput);
|
|
45
|
+
});
|
|
46
|
+
it("getDateTimeFormTime should convert time to date-time format", () => {
|
|
47
|
+
const inputTime = "2023-12-19 12:00";
|
|
48
|
+
const expectedOutputRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
|
|
49
|
+
const result = TimeHelper.getDateTimeFormTime(inputTime);
|
|
50
|
+
assert.match(result, expectedOutputRegex);
|
|
51
|
+
});
|
|
52
|
+
it("getTimeFormTime should convert time to time format", () => {
|
|
53
|
+
const inputTime = "2023-12-19 12:00";
|
|
54
|
+
const expectedOutputRegex = /^\d{2}:\d{2}$/;
|
|
55
|
+
const result = TimeHelper.getTimeFormTime(inputTime);
|
|
56
|
+
assert.match(result, expectedOutputRegex);
|
|
57
|
+
});
|
|
58
|
+
it("getCurrentDateTime should return the current date and time in yyyy-MM-dd HH:mm format", () => {
|
|
59
|
+
const expectedOutputRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
|
|
60
|
+
const result = TimeHelper.getCurrentDateTime();
|
|
61
|
+
assert.match(result, expectedOutputRegex);
|
|
62
|
+
});
|
|
54
63
|
});
|
package/package.json
CHANGED
|
@@ -1,79 +1,82 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@finema/core",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Finema Dev Core Team",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/types.d.ts",
|
|
11
|
-
"import": "./dist/module.mjs",
|
|
12
|
-
"require": "./dist/module.cjs"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"main": "./dist/module.cjs",
|
|
16
|
-
"types": "./dist/types.d.ts",
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"engines": {
|
|
21
|
-
"node": ">=18.0.0"
|
|
22
|
-
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"prepack": "nuxt-module-build build",
|
|
25
|
-
"dev": "nuxi dev playground",
|
|
26
|
-
"dev:build": "nuxi build playground",
|
|
27
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
28
|
-
"lint": "eslint .",
|
|
29
|
-
"lint:fix": "eslint . --fix",
|
|
30
|
-
"test": "vitest run",
|
|
31
|
-
"test:watch": "vitest watch",
|
|
32
|
-
"release": "release-it --ci",
|
|
33
|
-
"prepare": "husky install"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@nuxt/kit": "^3.7.4",
|
|
37
|
-
"@nuxt/ui": "^2.11.1",
|
|
38
|
-
"@pinia/nuxt": "^0.5.1",
|
|
39
|
-
"@vee-validate/nuxt": "^4.12.3",
|
|
40
|
-
"@vee-validate/zod": "^4.12.3",
|
|
41
|
-
"@vuepic/vue-datepicker": "^7.4.0",
|
|
42
|
-
"axios": "^1.6.2",
|
|
43
|
-
"date-fns": "^3.0.6",
|
|
44
|
-
"i18next": "^23.7.11",
|
|
45
|
-
"lodash-es": "^4.17.21",
|
|
46
|
-
"nuxt-security": "^1.0.0",
|
|
47
|
-
"pinia": "^2.1.7",
|
|
48
|
-
"url-join": "^5.0.0",
|
|
49
|
-
"zod": "^3.22.4",
|
|
50
|
-
"zod-i18n-map": "^2.23.0"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@finema/eslint-config": "^1.2.0",
|
|
54
|
-
"@nuxt/devtools": "latest",
|
|
55
|
-
"@nuxt/eslint-config": "^0.2.0",
|
|
56
|
-
"@nuxt/module-builder": "^0.5.4",
|
|
57
|
-
"@nuxt/schema": "^3.7.4",
|
|
58
|
-
"@nuxt/test-utils": "^3.9.0",
|
|
59
|
-
"@release-it/conventional-changelog": "^8.0.1",
|
|
60
|
-
"@types/lodash-es": "^4.17.12",
|
|
61
|
-
"@types/node": "^18.18.1",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@finema/core",
|
|
3
|
+
"version": "1.4.6",
|
|
4
|
+
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Finema Dev Core Team",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types.d.ts",
|
|
11
|
+
"import": "./dist/module.mjs",
|
|
12
|
+
"require": "./dist/module.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/module.cjs",
|
|
16
|
+
"types": "./dist/types.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"prepack": "nuxt-module-build build",
|
|
25
|
+
"dev": "nuxi dev playground",
|
|
26
|
+
"dev:build": "nuxi build playground",
|
|
27
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"lint:fix": "eslint . --fix",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest watch",
|
|
32
|
+
"release": "release-it --ci",
|
|
33
|
+
"prepare": "husky install"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@nuxt/kit": "^3.7.4",
|
|
37
|
+
"@nuxt/ui": "^2.11.1",
|
|
38
|
+
"@pinia/nuxt": "^0.5.1",
|
|
39
|
+
"@vee-validate/nuxt": "^4.12.3",
|
|
40
|
+
"@vee-validate/zod": "^4.12.3",
|
|
41
|
+
"@vuepic/vue-datepicker": "^7.4.0",
|
|
42
|
+
"axios": "^1.6.2",
|
|
43
|
+
"date-fns": "^3.0.6",
|
|
44
|
+
"i18next": "^23.7.11",
|
|
45
|
+
"lodash-es": "^4.17.21",
|
|
46
|
+
"nuxt-security": "^1.0.0",
|
|
47
|
+
"pinia": "^2.1.7",
|
|
48
|
+
"url-join": "^5.0.0",
|
|
49
|
+
"zod": "^3.22.4",
|
|
50
|
+
"zod-i18n-map": "^2.23.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@finema/eslint-config": "^1.2.0",
|
|
54
|
+
"@nuxt/devtools": "latest",
|
|
55
|
+
"@nuxt/eslint-config": "^0.2.0",
|
|
56
|
+
"@nuxt/module-builder": "^0.5.4",
|
|
57
|
+
"@nuxt/schema": "^3.7.4",
|
|
58
|
+
"@nuxt/test-utils": "^3.9.0",
|
|
59
|
+
"@release-it/conventional-changelog": "^8.0.1",
|
|
60
|
+
"@types/lodash-es": "^4.17.12",
|
|
61
|
+
"@types/node": "^18.18.1",
|
|
62
|
+
"@vue/test-utils": "^2.4.3",
|
|
63
|
+
"changelogen": "^0.5.5",
|
|
64
|
+
"eslint": "^8.56.0",
|
|
65
|
+
"happy-dom": "^12.10.3",
|
|
66
|
+
"husky": "^8.0.3",
|
|
67
|
+
"lint-staged": "^15.2.0",
|
|
68
|
+
"nuxt": "^3.8.2",
|
|
69
|
+
"playwright-core": "^1.40.1",
|
|
70
|
+
"prettier": "^3.1.1",
|
|
71
|
+
"release-it": "^17.0.1",
|
|
72
|
+
"sass": "^1.69.5",
|
|
73
|
+
"stylelint": "^16.0.2",
|
|
74
|
+
"stylelint-config-prettier-scss": "^1.0.0",
|
|
75
|
+
"stylelint-config-standard-scss": "^12.0.0",
|
|
76
|
+
"vitest": "^1.1.0"
|
|
77
|
+
},
|
|
78
|
+
"lint-staged": {
|
|
79
|
+
"*.{ts,vue,tsx,js}": "eslint --fix",
|
|
80
|
+
"*.{html,json}": "prettier --write"
|
|
81
|
+
}
|
|
82
|
+
}
|