@finema/core 2.56.0 → 2.57.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 +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Form/InputDateTime/index.vue +10 -3
- package/dist/runtime/components/Form/InputDateTimeRange/index.vue +26 -11
- package/dist/runtime/components/Form/InputMonth/index.vue +1 -0
- package/dist/runtime/components/Form/InputSelect/index.vue +9 -1
- package/dist/runtime/components/Form/InputSelectMultiple/index.vue +20 -1
- package/dist/runtime/components/Form/InputTime/index.vue +1 -0
- package/dist/runtime/components/Table/ColumnText.d.vue.ts +5 -1
- package/dist/runtime/components/Table/ColumnText.vue.d.ts +5 -1
- package/dist/runtime/theme/selectMenu.js +2 -2
- package/dist/runtime/utils/TimeHelper.d.ts +15 -5
- package/dist/runtime/utils/TimeHelper.js +30 -6
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
:start-time="startTime"
|
|
17
17
|
:teleport="teleport"
|
|
18
18
|
:required="required"
|
|
19
|
+
:timezone="appConfig.core?.time_zone"
|
|
19
20
|
:flow="['calendar', 'time']"
|
|
20
21
|
@update:model-value="onInput"
|
|
21
22
|
>
|
|
@@ -119,13 +120,19 @@ onMounted(() => {
|
|
|
119
120
|
});
|
|
120
121
|
const format = (date) => {
|
|
121
122
|
if (props.disabledTime) {
|
|
122
|
-
return TimeHelper.displayDate(date
|
|
123
|
+
return TimeHelper.displayDate(date, {
|
|
124
|
+
autoTimezone: true
|
|
125
|
+
});
|
|
123
126
|
}
|
|
124
|
-
return TimeHelper.displayDateTime(date
|
|
127
|
+
return TimeHelper.displayDateTime(date, {
|
|
128
|
+
autoTimezone: true
|
|
129
|
+
});
|
|
125
130
|
};
|
|
126
131
|
const onInput = (_value) => {
|
|
127
132
|
if (props.disabledTime && !props.isReturnISO) {
|
|
128
|
-
value.value = TimeHelper.
|
|
133
|
+
value.value = TimeHelper.displayDate(_value, {
|
|
134
|
+
autoTimezone: true
|
|
135
|
+
}) ?? void 0;
|
|
129
136
|
} else {
|
|
130
137
|
value.value = _value;
|
|
131
138
|
}
|
|
@@ -64,9 +64,10 @@
|
|
|
64
64
|
<script setup>
|
|
65
65
|
import Datepicker from "@vuepic/vue-datepicker";
|
|
66
66
|
import FieldWrapper from "#core/components/Form/FieldWrapper.vue";
|
|
67
|
-
import {
|
|
67
|
+
import { ref, useFieldHOC, useAppConfig, computed, useUiConfig, watch, onMounted, TimeHelper } from "#imports";
|
|
68
68
|
import "@vuepic/vue-datepicker/dist/main.css";
|
|
69
69
|
import { dateTimeTheme } from "#core/theme/dateTime";
|
|
70
|
+
import { toZonedTime } from "date-fns-tz";
|
|
70
71
|
const emits = defineEmits(["change"]);
|
|
71
72
|
const props = defineProps({
|
|
72
73
|
isDisabledMultiCalendar: { type: Boolean, required: false },
|
|
@@ -103,18 +104,18 @@ const {
|
|
|
103
104
|
const innerValueRef = ref([]);
|
|
104
105
|
const initializeValue = () => {
|
|
105
106
|
const currentValue = value.value;
|
|
106
|
-
if (currentValue) {
|
|
107
|
-
const start =
|
|
108
|
-
const end =
|
|
107
|
+
if (currentValue && currentValue.start) {
|
|
108
|
+
const start = toZonedTime(new Date(currentValue.start), appConfig.core.time_zone);
|
|
109
|
+
const end = toZonedTime(new Date(currentValue.end || currentValue.start), appConfig.core.time_zone);
|
|
109
110
|
innerValueRef.value = [start, end];
|
|
110
111
|
} else {
|
|
111
112
|
innerValueRef.value = [];
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
115
|
watch(value, (newValue) => {
|
|
115
|
-
if (newValue &&
|
|
116
|
-
const start =
|
|
117
|
-
const end =
|
|
116
|
+
if (newValue && newValue.start) {
|
|
117
|
+
const start = toZonedTime(new Date(newValue.start), appConfig.core.time_zone);
|
|
118
|
+
const end = toZonedTime(new Date(newValue.end || newValue.start), appConfig.core.time_zone);
|
|
118
119
|
innerValueRef.value = [start, end];
|
|
119
120
|
} else if (!newValue) {
|
|
120
121
|
innerValueRef.value = [];
|
|
@@ -127,11 +128,25 @@ onMounted(() => {
|
|
|
127
128
|
});
|
|
128
129
|
const format = (date) => {
|
|
129
130
|
if (props.disabledTime) {
|
|
130
|
-
return date.length > 0
|
|
131
|
+
return date.length > 0 && date[0] ? TimeHelper.displayDate(date[0], {
|
|
132
|
+
autoTimezone: true
|
|
133
|
+
}) + " - " + TimeHelper.displayDate(date[1] || date[0], {
|
|
134
|
+
autoTimezone: true
|
|
135
|
+
}) : "";
|
|
131
136
|
}
|
|
132
|
-
return date.length > 0
|
|
137
|
+
return date.length > 0 && date[0] ? TimeHelper.displayDateTime(date[0], {
|
|
138
|
+
autoTimezone: true
|
|
139
|
+
}) + " - " + TimeHelper.displayDateTime(date[1] || date[0], {
|
|
140
|
+
autoTimezone: true
|
|
141
|
+
}) : "";
|
|
133
142
|
};
|
|
134
143
|
const onInput = (_value) => {
|
|
144
|
+
const formattedDates = _value.map((d) => {
|
|
145
|
+
const year = d.getFullYear();
|
|
146
|
+
const month = String(d.getMonth() + 1).padStart(2, "0");
|
|
147
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
148
|
+
return `${year}-${month}-${day}`;
|
|
149
|
+
});
|
|
135
150
|
if (_value === null || _value === void 0) {
|
|
136
151
|
value.value = void 0;
|
|
137
152
|
emits("change", void 0);
|
|
@@ -139,8 +154,8 @@ const onInput = (_value) => {
|
|
|
139
154
|
}
|
|
140
155
|
if (props.disabledTime && !props.isReturnISO) {
|
|
141
156
|
value.value = {
|
|
142
|
-
start:
|
|
143
|
-
end:
|
|
157
|
+
start: formattedDates[0],
|
|
158
|
+
end: formattedDates[1] || formattedDates[0]
|
|
144
159
|
};
|
|
145
160
|
} else {
|
|
146
161
|
value.value = {
|
|
@@ -17,7 +17,15 @@
|
|
|
17
17
|
@update:modelValue="onChange"
|
|
18
18
|
@update:searchTerm="onSearch"
|
|
19
19
|
>
|
|
20
|
-
<template #default="{ modelValue }">
|
|
20
|
+
<template #default="{ modelValue, ui: selectMenuUi }">
|
|
21
|
+
<Chip
|
|
22
|
+
v-if="options.find((item) => item.value === modelValue)?.chip"
|
|
23
|
+
v-bind="options.find((item) => item.value === modelValue)?.chip"
|
|
24
|
+
inset
|
|
25
|
+
standalone
|
|
26
|
+
:size="selectMenuUi.itemLeadingChipSize()"
|
|
27
|
+
:class="selectMenuUi.itemLeadingChip()"
|
|
28
|
+
/>
|
|
21
29
|
<div
|
|
22
30
|
v-if="value"
|
|
23
31
|
:class="theme.selectedWrapper({
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
@update:model-value="onChange"
|
|
18
18
|
@update:searchTerm="onSearch"
|
|
19
19
|
>
|
|
20
|
-
<template #default="{ modelValue }">
|
|
20
|
+
<template #default="{ modelValue, ui: selectMenuUi }">
|
|
21
21
|
<div
|
|
22
22
|
v-if="!ArrayHelper.isEmpty(value)"
|
|
23
23
|
:class="theme.tagsWrapper({
|
|
@@ -31,6 +31,25 @@
|
|
|
31
31
|
class: [ui?.tagsItem]
|
|
32
32
|
})"
|
|
33
33
|
>
|
|
34
|
+
<Chip
|
|
35
|
+
v-if="options.find((item) => item.value === _value)?.chip"
|
|
36
|
+
v-bind="options.find((item) => item.value === _value)?.chip"
|
|
37
|
+
inset
|
|
38
|
+
standalone
|
|
39
|
+
:size="selectMenuUi.itemLeadingChipSize()"
|
|
40
|
+
class="p-1"
|
|
41
|
+
/>
|
|
42
|
+
<Icon
|
|
43
|
+
v-if="options.find((item) => item.value === _value)?.icon"
|
|
44
|
+
:name="options.find((item) => item.value === _value)?.icon"
|
|
45
|
+
class="size-4"
|
|
46
|
+
/>
|
|
47
|
+
<Avatar
|
|
48
|
+
v-if="options.find((item) => item.value === _value)?.avatar"
|
|
49
|
+
v-bind="options.find((item) => item.value === _value)?.avatar"
|
|
50
|
+
:class="selectMenuUi.itemLeadingAvatar()"
|
|
51
|
+
size="2xs"
|
|
52
|
+
/>
|
|
34
53
|
<div
|
|
35
54
|
:class="theme.tagsItemText({
|
|
36
55
|
class: [ui?.tagsItemText]
|
|
@@ -2,7 +2,11 @@ import type { TableColumn } from '@nuxt/ui';
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
value: any;
|
|
4
4
|
row: any;
|
|
5
|
-
column: TableColumn<any
|
|
5
|
+
column: TableColumn<any> & {
|
|
6
|
+
meta: {
|
|
7
|
+
max: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
6
10
|
};
|
|
7
11
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
12
|
declare const _default: typeof __VLS_export;
|
|
@@ -2,7 +2,11 @@ import type { TableColumn } from '@nuxt/ui';
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
value: any;
|
|
4
4
|
row: any;
|
|
5
|
-
column: TableColumn<any
|
|
5
|
+
column: TableColumn<any> & {
|
|
6
|
+
meta: {
|
|
7
|
+
max: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
6
10
|
};
|
|
7
11
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
12
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,10 +7,10 @@ export const selectMenuTheme = {
|
|
|
7
7
|
clearIcon: "size-6 bg-gray-400 hover:bg-gray-400/75",
|
|
8
8
|
item: "cursor-pointer max-sm:h-14",
|
|
9
9
|
tagsWrapper: "flex flex-wrap gap-x-2 gap-y-1",
|
|
10
|
-
tagsItem: "px-1.5 py-0.5 rounded-sm inline-flex items-center gap-0.5
|
|
10
|
+
tagsItem: "px-1.5 py-0.5 rounded-sm inline-flex items-center gap-0.5 ring-1 ring-gray-300 bg-white data-disabled:cursor-not-allowed data-disabled:opacity-75",
|
|
11
11
|
tagsItemText: "flex items-center gap-x-1 text-sm",
|
|
12
12
|
tagsItemDelete: [
|
|
13
|
-
"inline-flex items-center text-
|
|
13
|
+
"inline-flex items-center hover:text-gray-500 disabled:pointer-events-none",
|
|
14
14
|
"transition-colors cursor-pointer"
|
|
15
15
|
],
|
|
16
16
|
tagsItemDeleteIcon: "ph:x"
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
export declare class TimeHelper {
|
|
2
2
|
static thaiFormat: (dateStr: Date, formatStr: string, forceThai?: boolean) => string;
|
|
3
|
-
static displayDate: (time: string | Date | null | undefined
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
static
|
|
7
|
-
|
|
3
|
+
static displayDate: (time: string | Date | null | undefined, options?: {
|
|
4
|
+
autoTimezone?: boolean;
|
|
5
|
+
}) => string | null;
|
|
6
|
+
static displayDateTime: (time: string | Date | null | undefined, options?: {
|
|
7
|
+
autoTimezone?: boolean;
|
|
8
|
+
}) => string | null;
|
|
9
|
+
static displayDateThai: (time: string | Date | null | undefined, options?: {
|
|
10
|
+
autoTimezone?: boolean;
|
|
11
|
+
}) => string | null;
|
|
12
|
+
static displayDateTimeThai: (time: string | Date | null | undefined, options?: {
|
|
13
|
+
autoTimezone?: boolean;
|
|
14
|
+
}) => string | null;
|
|
15
|
+
static displayDateRange: (startDate: Date | string | null | undefined, endDate: Date | string | null | undefined, options?: {
|
|
16
|
+
autoTimezone?: boolean;
|
|
17
|
+
}) => {
|
|
8
18
|
startDate: Date | string | null;
|
|
9
19
|
endDate: Date | string | null;
|
|
10
20
|
};
|
|
@@ -25,39 +25,55 @@ export class TimeHelper {
|
|
|
25
25
|
}
|
|
26
26
|
return formatInTimeZone(newDateStr, timeZone, formatStr, options);
|
|
27
27
|
};
|
|
28
|
-
static displayDate = (time) => {
|
|
28
|
+
static displayDate = (time, options) => {
|
|
29
29
|
if (!time) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
const parsedTime = getTime(time);
|
|
33
|
+
if (options?.autoTimezone) {
|
|
34
|
+
const newTime2 = format(parsedTime, dateFormatDisplay);
|
|
35
|
+
return isValid(parsedTime) ? newTime2 : time;
|
|
36
|
+
}
|
|
33
37
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateFormatDisplay);
|
|
34
38
|
return isValid(parsedTime) ? newTime : time;
|
|
35
39
|
};
|
|
36
|
-
static displayDateTime = (time) => {
|
|
40
|
+
static displayDateTime = (time, options) => {
|
|
37
41
|
if (!time) {
|
|
38
42
|
return null;
|
|
39
43
|
}
|
|
40
44
|
const parsedTime = getTime(time);
|
|
45
|
+
if (options?.autoTimezone) {
|
|
46
|
+
const newTime2 = format(parsedTime, dateTimeFormatDisplay);
|
|
47
|
+
return isValid(parsedTime) ? newTime2 : time;
|
|
48
|
+
}
|
|
41
49
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormatDisplay);
|
|
42
50
|
return isValid(parsedTime) ? newTime : time;
|
|
43
51
|
};
|
|
44
|
-
static displayDateThai = (time) => {
|
|
52
|
+
static displayDateThai = (time, options) => {
|
|
45
53
|
if (!time) {
|
|
46
54
|
return null;
|
|
47
55
|
}
|
|
48
56
|
const parsedTime = getTime(time);
|
|
57
|
+
if (options?.autoTimezone) {
|
|
58
|
+
const newTime2 = format(parsedTime, dateFormat);
|
|
59
|
+
return isValid(parsedTime) ? newTime2 : time;
|
|
60
|
+
}
|
|
49
61
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateFormat, true);
|
|
50
62
|
return isValid(parsedTime) ? newTime : time;
|
|
51
63
|
};
|
|
52
|
-
static displayDateTimeThai = (time) => {
|
|
64
|
+
static displayDateTimeThai = (time, options) => {
|
|
53
65
|
if (!time) {
|
|
54
66
|
return null;
|
|
55
67
|
}
|
|
56
68
|
const parsedTime = getTime(time);
|
|
69
|
+
if (options?.autoTimezone) {
|
|
70
|
+
const newTime2 = format(parsedTime, dateTimeFormat);
|
|
71
|
+
return isValid(parsedTime) ? newTime2 : time;
|
|
72
|
+
}
|
|
57
73
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormat, true);
|
|
58
74
|
return isValid(parsedTime) ? newTime : time;
|
|
59
75
|
};
|
|
60
|
-
static displayDateRange = (startDate, endDate) => {
|
|
76
|
+
static displayDateRange = (startDate, endDate, options) => {
|
|
61
77
|
if (!startDate || !endDate) {
|
|
62
78
|
return {
|
|
63
79
|
startDate: startDate || null,
|
|
@@ -66,6 +82,14 @@ export class TimeHelper {
|
|
|
66
82
|
}
|
|
67
83
|
const parsedStartDate = getTime(startDate);
|
|
68
84
|
const parsedEndDate = getTime(endDate);
|
|
85
|
+
if (options?.autoTimezone) {
|
|
86
|
+
const newTimeStartDate = format(parsedStartDate, dateFormatDisplay);
|
|
87
|
+
const newTimeEndDate = format(parsedEndDate, dateFormatDisplay);
|
|
88
|
+
return {
|
|
89
|
+
startDate: isValid(parsedStartDate) ? newTimeStartDate : startDate,
|
|
90
|
+
endDate: isValid(parsedEndDate) ? newTimeEndDate : endDate
|
|
91
|
+
};
|
|
92
|
+
}
|
|
69
93
|
const newStartDate = TimeHelper.thaiFormat(parsedStartDate, dateFormatDisplay);
|
|
70
94
|
const newEndDate = TimeHelper.thaiFormat(parsedEndDate, dateFormatDisplay);
|
|
71
95
|
return {
|
|
@@ -105,7 +129,7 @@ export class TimeHelper {
|
|
|
105
129
|
return null;
|
|
106
130
|
}
|
|
107
131
|
const parsedTime = getTime(time);
|
|
108
|
-
const newTime =
|
|
132
|
+
const newTime = formatInTimeZone(parsedTime, timeZone, customFormat);
|
|
109
133
|
return isValid(parsedTime) ? newTime : time;
|
|
110
134
|
};
|
|
111
135
|
static getDateFormTimeWithLocal = (time, customFormat = dateFormat) => {
|