@finema/core 2.42.2 → 2.43.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/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import * as lodash from 'lodash-es';
|
|
|
4
4
|
import * as theme from '../dist/runtime/theme/index.js';
|
|
5
5
|
|
|
6
6
|
const name = "@finema/core";
|
|
7
|
-
const version = "2.
|
|
7
|
+
const version = "2.43.0";
|
|
8
8
|
|
|
9
9
|
const nuxtAppOptions = {
|
|
10
10
|
head: {
|
|
@@ -54,9 +54,9 @@ const core = {
|
|
|
54
54
|
time_format: "HH:mm",
|
|
55
55
|
date_format: "dd-MMM-yyyy",
|
|
56
56
|
month_format: "MMM-yyyy",
|
|
57
|
-
date_time_format: "dd-MMM-yyyy HH:mm",
|
|
57
|
+
date_time_format: "dd-MMM-yyyy HH:mm:ss",
|
|
58
58
|
date_format_system: "yyyy-MM-dd",
|
|
59
|
-
date_time_format_system: "yyyy-MM-dd HH:mm",
|
|
59
|
+
date_time_format_system: "yyyy-MM-dd HH:mm:ss",
|
|
60
60
|
is_thai_year: false,
|
|
61
61
|
is_thai_month: false,
|
|
62
62
|
site_name: "",
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<Datepicker
|
|
4
|
-
v-model="innerValue"
|
|
5
|
-
:teleport="teleport"
|
|
6
|
-
:disabled="wrapperProps.disabled"
|
|
7
|
-
:cancel-text="appConfig.core?.locale === 'th' ? '\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01' : 'Cancel'"
|
|
8
|
-
:select-text="appConfig.core?.locale === 'th' ? '\u0E15\u0E01\u0E25\u0E07' : 'Select'"
|
|
9
|
-
:locale="appConfig.core?.locale"
|
|
10
|
-
time-picker
|
|
11
|
-
:placeholder="wrapperProps.placeholder"
|
|
12
|
-
:format="format"
|
|
13
|
-
:min-time="minTime"
|
|
14
|
-
:max-time="maxTime"
|
|
15
|
-
:start-time="startTime"
|
|
16
|
-
:required="required"
|
|
17
|
-
:enable-seconds="enableSeconds"
|
|
18
|
-
@update:model-value="onChange"
|
|
19
|
-
>
|
|
20
|
-
<template #dp-input="{ value: innerValue }">
|
|
21
|
-
<Input
|
|
22
|
-
:trailing-icon="innerValue ? void 0 : 'i-heroicons-clock'"
|
|
23
|
-
type="text"
|
|
24
|
-
:disabled="wrapperProps.disabled"
|
|
25
|
-
:model-value="innerValue"
|
|
26
|
-
:placeholder="wrapperProps.placeholder"
|
|
27
|
-
:readonly="true"
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<Datepicker
|
|
4
|
+
v-model="innerValue"
|
|
5
|
+
:teleport="teleport"
|
|
6
|
+
:disabled="wrapperProps.disabled"
|
|
7
|
+
:cancel-text="appConfig.core?.locale === 'th' ? '\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01' : 'Cancel'"
|
|
8
|
+
:select-text="appConfig.core?.locale === 'th' ? '\u0E15\u0E01\u0E25\u0E07' : 'Select'"
|
|
9
|
+
:locale="appConfig.core?.locale"
|
|
10
|
+
time-picker
|
|
11
|
+
:placeholder="wrapperProps.placeholder"
|
|
12
|
+
:format="format"
|
|
13
|
+
:min-time="minTime"
|
|
14
|
+
:max-time="maxTime"
|
|
15
|
+
:start-time="startTime"
|
|
16
|
+
:required="required"
|
|
17
|
+
:enable-seconds="enableSeconds"
|
|
18
|
+
@update:model-value="onChange"
|
|
19
|
+
>
|
|
20
|
+
<template #dp-input="{ value: innerValue }">
|
|
21
|
+
<Input
|
|
22
|
+
:trailing-icon="innerValue ? void 0 : 'i-heroicons-clock'"
|
|
23
|
+
type="text"
|
|
24
|
+
:disabled="wrapperProps.disabled"
|
|
25
|
+
:model-value="innerValue"
|
|
26
|
+
:placeholder="wrapperProps.placeholder"
|
|
27
|
+
:readonly="true"
|
|
28
28
|
:ui="{
|
|
29
29
|
base: 'cursor-pointer select-none',
|
|
30
30
|
trailingIcon: 'cursor-pointer'
|
|
31
|
-
}"
|
|
32
|
-
/>
|
|
33
|
-
</template>
|
|
34
|
-
<template #clear-icon="{ clear }">
|
|
35
|
-
<Icon
|
|
36
|
-
:name="clearIcon"
|
|
31
|
+
}"
|
|
32
|
+
/>
|
|
33
|
+
</template>
|
|
34
|
+
<template #clear-icon="{ clear }">
|
|
35
|
+
<Icon
|
|
36
|
+
:name="clearIcon"
|
|
37
37
|
:class="theme.clearIcon({
|
|
38
38
|
class: [ui?.clearIcon]
|
|
39
|
-
})"
|
|
40
|
-
@click.stop="clear"
|
|
41
|
-
/>
|
|
42
|
-
</template>
|
|
43
|
-
</Datepicker>
|
|
44
|
-
</FieldWrapper>
|
|
39
|
+
})"
|
|
40
|
+
@click.stop="clear"
|
|
41
|
+
/>
|
|
42
|
+
</template>
|
|
43
|
+
</Datepicker>
|
|
44
|
+
</FieldWrapper>
|
|
45
45
|
</template>
|
|
46
46
|
|
|
47
47
|
<script setup>
|
|
@@ -58,7 +58,7 @@ const props = defineProps({
|
|
|
58
58
|
startTime: { type: Object, required: false },
|
|
59
59
|
format: { type: String, required: false },
|
|
60
60
|
enableSeconds: { type: Boolean, required: false, default: false },
|
|
61
|
-
teleport: { type: [Boolean, String], required: false, skipCheck: true, default:
|
|
61
|
+
teleport: { type: [Boolean, String], required: false, skipCheck: true, default: true },
|
|
62
62
|
form: { type: Object, required: false },
|
|
63
63
|
name: { type: String, required: true },
|
|
64
64
|
errorMessage: { type: String, required: false },
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export declare class TimeHelper {
|
|
2
2
|
static thaiFormat: (dateStr: Date, formatStr: string, forceThai?: boolean) => string;
|
|
3
|
-
static displayDate: (time: string | Date) => string;
|
|
4
|
-
static displayDateTime: (time: string | Date) => string;
|
|
5
|
-
static displayDateThai: (time: string | Date) => string;
|
|
6
|
-
static displayDateTimeThai: (time: string | Date) => string;
|
|
7
|
-
static displayDateRange: (startDate: Date | string, endDate: Date | string) => {
|
|
8
|
-
startDate: Date | string;
|
|
9
|
-
endDate: Date | string;
|
|
3
|
+
static displayDate: (time: string | Date | null | undefined) => string | null;
|
|
4
|
+
static displayDateTime: (time: string | Date | null | undefined) => string | null;
|
|
5
|
+
static displayDateThai: (time: string | Date | null | undefined) => string | null;
|
|
6
|
+
static displayDateTimeThai: (time: string | Date | null | undefined) => string | null;
|
|
7
|
+
static displayDateRange: (startDate: Date | string | null | undefined, endDate: Date | string | null | undefined) => {
|
|
8
|
+
startDate: Date | string | null;
|
|
9
|
+
endDate: Date | string | null;
|
|
10
10
|
};
|
|
11
|
-
static toUTC: (time: string | Date) => string;
|
|
12
|
-
static toLocal: (time: string | Date) => string;
|
|
11
|
+
static toUTC: (time: string | Date | null | undefined) => string | null;
|
|
12
|
+
static toLocal: (time: string | Date | null | undefined) => string | null;
|
|
13
13
|
static getCurrentDate: (customFormat?: string) => string;
|
|
14
|
-
static getDateFormTime: (time: string | Date, customFormat?: string) => string;
|
|
15
|
-
static getDateFormTimeWithLocal: (time: string | Date, customFormat?: string) => string;
|
|
16
|
-
static getISODateTimeFormTime: (time: string | Date) => string;
|
|
17
|
-
static getDateTimeFormTime: (time: string | Date) => string;
|
|
18
|
-
static getTimeFormTime: (time: string | Date) => string;
|
|
14
|
+
static getDateFormTime: (time: string | Date | null | undefined, customFormat?: string) => string | null;
|
|
15
|
+
static getDateFormTimeWithLocal: (time: string | Date | null | undefined, customFormat?: string) => string | null;
|
|
16
|
+
static getISODateTimeFormTime: (time: string | Date | null | undefined) => string | null;
|
|
17
|
+
static getDateTimeFormTime: (time: string | Date | null | undefined) => string | null;
|
|
18
|
+
static getTimeFormTime: (time: string | Date | null | undefined) => string | null;
|
|
19
19
|
static getCurrentDateTime: () => string;
|
|
20
|
+
static toDate: (str: string | Date | null | undefined) => Date | null;
|
|
20
21
|
}
|
|
@@ -27,7 +27,7 @@ export class TimeHelper {
|
|
|
27
27
|
};
|
|
28
28
|
static displayDate = (time) => {
|
|
29
29
|
if (!time) {
|
|
30
|
-
return
|
|
30
|
+
return null;
|
|
31
31
|
}
|
|
32
32
|
const parsedTime = getTime(time);
|
|
33
33
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateFormatDisplay);
|
|
@@ -35,7 +35,7 @@ export class TimeHelper {
|
|
|
35
35
|
};
|
|
36
36
|
static displayDateTime = (time) => {
|
|
37
37
|
if (!time) {
|
|
38
|
-
return
|
|
38
|
+
return null;
|
|
39
39
|
}
|
|
40
40
|
const parsedTime = getTime(time);
|
|
41
41
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormatDisplay);
|
|
@@ -43,7 +43,7 @@ export class TimeHelper {
|
|
|
43
43
|
};
|
|
44
44
|
static displayDateThai = (time) => {
|
|
45
45
|
if (!time) {
|
|
46
|
-
return
|
|
46
|
+
return null;
|
|
47
47
|
}
|
|
48
48
|
const parsedTime = getTime(time);
|
|
49
49
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateFormat, true);
|
|
@@ -51,7 +51,7 @@ export class TimeHelper {
|
|
|
51
51
|
};
|
|
52
52
|
static displayDateTimeThai = (time) => {
|
|
53
53
|
if (!time) {
|
|
54
|
-
return
|
|
54
|
+
return null;
|
|
55
55
|
}
|
|
56
56
|
const parsedTime = getTime(time);
|
|
57
57
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormat, true);
|
|
@@ -60,8 +60,8 @@ export class TimeHelper {
|
|
|
60
60
|
static displayDateRange = (startDate, endDate) => {
|
|
61
61
|
if (!startDate || !endDate) {
|
|
62
62
|
return {
|
|
63
|
-
startDate,
|
|
64
|
-
endDate
|
|
63
|
+
startDate: startDate || null,
|
|
64
|
+
endDate: endDate || null
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
const parsedStartDate = getTime(startDate);
|
|
@@ -75,7 +75,7 @@ export class TimeHelper {
|
|
|
75
75
|
};
|
|
76
76
|
static toUTC = (time) => {
|
|
77
77
|
if (!time) {
|
|
78
|
-
return
|
|
78
|
+
return null;
|
|
79
79
|
}
|
|
80
80
|
try {
|
|
81
81
|
const parsedTime = getTime(time);
|
|
@@ -87,7 +87,7 @@ export class TimeHelper {
|
|
|
87
87
|
};
|
|
88
88
|
static toLocal = (time) => {
|
|
89
89
|
if (!time) {
|
|
90
|
-
return
|
|
90
|
+
return null;
|
|
91
91
|
}
|
|
92
92
|
try {
|
|
93
93
|
const parsedTime = getTime(time);
|
|
@@ -102,7 +102,7 @@ export class TimeHelper {
|
|
|
102
102
|
};
|
|
103
103
|
static getDateFormTime = (time, customFormat = dateFormat) => {
|
|
104
104
|
if (!time) {
|
|
105
|
-
return
|
|
105
|
+
return null;
|
|
106
106
|
}
|
|
107
107
|
const parsedTime = isDate(time) ? time : parse(time, dateTimeFormat, /* @__PURE__ */ new Date());
|
|
108
108
|
const newTime = format(parsedTime, customFormat);
|
|
@@ -110,16 +110,19 @@ export class TimeHelper {
|
|
|
110
110
|
};
|
|
111
111
|
static getDateFormTimeWithLocal = (time, customFormat = dateFormat) => {
|
|
112
112
|
if (!time) {
|
|
113
|
-
return
|
|
113
|
+
return null;
|
|
114
114
|
}
|
|
115
115
|
const localTime = TimeHelper.toLocal(time);
|
|
116
|
+
if (!localTime) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
116
119
|
const parsedTime = isDate(localTime) ? localTime : parse(localTime, dateTimeFormat, /* @__PURE__ */ new Date());
|
|
117
120
|
const newTime = format(parsedTime, customFormat);
|
|
118
121
|
return isValid(parsedTime) ? newTime : time;
|
|
119
122
|
};
|
|
120
123
|
static getISODateTimeFormTime = (time) => {
|
|
121
124
|
if (!time) {
|
|
122
|
-
return
|
|
125
|
+
return null;
|
|
123
126
|
}
|
|
124
127
|
try {
|
|
125
128
|
const parsedTime = isDate(time) ? time : parse(time, dateTimeFormat, /* @__PURE__ */ new Date());
|
|
@@ -134,7 +137,7 @@ export class TimeHelper {
|
|
|
134
137
|
};
|
|
135
138
|
static getDateTimeFormTime = (time) => {
|
|
136
139
|
if (!time) {
|
|
137
|
-
return
|
|
140
|
+
return null;
|
|
138
141
|
}
|
|
139
142
|
const parsedTime = isDate(time) ? time : parse(time, dateTimeFormat, /* @__PURE__ */ new Date());
|
|
140
143
|
const newTime = format(parsedTime, dateTimeFormat);
|
|
@@ -142,7 +145,7 @@ export class TimeHelper {
|
|
|
142
145
|
};
|
|
143
146
|
static getTimeFormTime = (time) => {
|
|
144
147
|
if (!time) {
|
|
145
|
-
return
|
|
148
|
+
return null;
|
|
146
149
|
}
|
|
147
150
|
const parsedTime = isDate(time) ? time : parse(time, dateTimeFormat, /* @__PURE__ */ new Date());
|
|
148
151
|
const newTime = format(parsedTime, timeFormat);
|
|
@@ -151,4 +154,14 @@ export class TimeHelper {
|
|
|
151
154
|
static getCurrentDateTime = () => {
|
|
152
155
|
return format(/* @__PURE__ */ new Date(), dateTimeFormat);
|
|
153
156
|
};
|
|
157
|
+
static toDate = (str) => {
|
|
158
|
+
if (!str) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
if (isDate(str)) {
|
|
162
|
+
return str;
|
|
163
|
+
}
|
|
164
|
+
const parsedTime = new Date(str);
|
|
165
|
+
return isValid(parsedTime) ? parsedTime : null;
|
|
166
|
+
};
|
|
154
167
|
}
|