@finema/core 1.4.100 → 1.4.101
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/Fields.vue +15 -0
- package/dist/runtime/components/Form/InputDateTimeRange/date_range_time_field.types.d.ts +17 -0
- package/dist/runtime/components/Form/InputDateTimeRange/date_range_time_field.types.mjs +0 -0
- package/dist/runtime/components/Form/InputDateTimeRange/index.vue +83 -0
- package/dist/runtime/components/Form/types.d.ts +4 -1
- package/dist/runtime/components/Form/types.mjs +2 -0
- package/dist/runtime/composables/useForm.d.ts +1 -1
- package/dist/runtime/helpers/apiPageHelper.d.ts +1 -1
- package/dist/runtime/utils/TimeHelper.d.ts +4 -0
- package/dist/runtime/utils/TimeHelper.mjs +16 -0
- package/package.json +6 -7
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -93,6 +93,21 @@
|
|
|
93
93
|
:disabled-time="true"
|
|
94
94
|
v-on="option.on ?? {}"
|
|
95
95
|
/>
|
|
96
|
+
<FormInputDateTimeRange
|
|
97
|
+
v-else-if="option.type === INPUT_TYPES.DATE_TIME_RANGE"
|
|
98
|
+
:class="option.class"
|
|
99
|
+
:form="form"
|
|
100
|
+
v-bind="getFieldBinding(option)"
|
|
101
|
+
v-on="option.on ?? {}"
|
|
102
|
+
/>
|
|
103
|
+
<FormInputDateTimeRange
|
|
104
|
+
v-else-if="option.type === INPUT_TYPES.DATE_RANGE"
|
|
105
|
+
:class="option.class"
|
|
106
|
+
:form="form"
|
|
107
|
+
:disabled-time="true"
|
|
108
|
+
v-bind="getFieldBinding(option)"
|
|
109
|
+
v-on="option.on ?? {}"
|
|
110
|
+
/>
|
|
96
111
|
<FormInputUploadFileClassic
|
|
97
112
|
v-else-if="option.type === INPUT_TYPES.UPLOAD_FILE_CLASSIC"
|
|
98
113
|
:class="option.class"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type IFormFieldBase, type INPUT_TYPES } from '#core/components/Form/types';
|
|
2
|
+
import type { IDateTimeFieldProps } from '../InputDateTime/date_time_field.types';
|
|
3
|
+
export interface ITimeOption {
|
|
4
|
+
hours?: number | string;
|
|
5
|
+
minutes?: number | string;
|
|
6
|
+
seconds?: number | string;
|
|
7
|
+
}
|
|
8
|
+
export interface IDateTimeRangeResponse {
|
|
9
|
+
start: Date | string;
|
|
10
|
+
end: Date | string;
|
|
11
|
+
}
|
|
12
|
+
export interface IDateTimeRangeFieldProps extends IDateTimeFieldProps {
|
|
13
|
+
isDisabledMultiCalendar?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type IDateTimeRangeField = IFormFieldBase<INPUT_TYPES.DATE_RANGE | INPUT_TYPES.DATE_TIME_RANGE, IDateTimeRangeFieldProps, {
|
|
16
|
+
change: (value: IDateTimeRangeResponse) => void;
|
|
17
|
+
}>;
|
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<Datepicker
|
|
4
|
+
v-model="innerValueRef"
|
|
5
|
+
:disabled="wrapperProps.isDisabled"
|
|
6
|
+
cancel-text="ยกเลิก"
|
|
7
|
+
select-text="เลือก"
|
|
8
|
+
locale="th"
|
|
9
|
+
:format="format"
|
|
10
|
+
:enable-time-picker="!disabledTime"
|
|
11
|
+
:placeholder="wrapperProps.placeholder"
|
|
12
|
+
:min-date="minDate"
|
|
13
|
+
:max-date="maxDate"
|
|
14
|
+
:min-time="minTime"
|
|
15
|
+
:max-time="maxTime"
|
|
16
|
+
:start-time="startTime"
|
|
17
|
+
:multi-calendars="!isDisabledMultiCalendar"
|
|
18
|
+
:required="isRequired"
|
|
19
|
+
time-picker-inline
|
|
20
|
+
range
|
|
21
|
+
@update:model-value="onInput"
|
|
22
|
+
>
|
|
23
|
+
<template #dp-input="{ value: innerValue }">
|
|
24
|
+
<UInput
|
|
25
|
+
:trailing-icon="innerValue ? undefined : 'i-heroicons-calendar-days'"
|
|
26
|
+
type="text"
|
|
27
|
+
:value="innerValue"
|
|
28
|
+
:placeholder="wrapperProps.placeholder"
|
|
29
|
+
:readonly="true"
|
|
30
|
+
input-class="cursor-pointer select-none"
|
|
31
|
+
/>
|
|
32
|
+
</template>
|
|
33
|
+
</Datepicker>
|
|
34
|
+
</FieldWrapper>
|
|
35
|
+
</template>
|
|
36
|
+
<script lang="ts" setup>
|
|
37
|
+
import Datepicker from '@vuepic/vue-datepicker'
|
|
38
|
+
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
39
|
+
import { TimeHelper, ref, useFieldHOC } from '#imports'
|
|
40
|
+
import '@vuepic/vue-datepicker/dist/main.css'
|
|
41
|
+
import type {
|
|
42
|
+
IDateTimeRangeFieldProps,
|
|
43
|
+
IDateTimeRangeResponse,
|
|
44
|
+
} from './date_range_time_field.types'
|
|
45
|
+
|
|
46
|
+
const props = withDefaults(defineProps<IDateTimeRangeFieldProps>(), {})
|
|
47
|
+
|
|
48
|
+
const { value, wrapperProps } = useFieldHOC<IDateTimeRangeResponse | null>(props)
|
|
49
|
+
|
|
50
|
+
const innerValueRef = ref<Date[]>([])
|
|
51
|
+
|
|
52
|
+
const format = (date: Date[]) => {
|
|
53
|
+
if (props.disabledTime) {
|
|
54
|
+
return date.length > 0
|
|
55
|
+
? TimeHelper.displayDate(date[0]) + ' - ' + TimeHelper.displayDate(date[1] ?? '')
|
|
56
|
+
: ''
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return date.length > 0
|
|
60
|
+
? TimeHelper.displayDateTime(date[0]) + ' - ' + TimeHelper.displayDateTime(date[1] ?? '')
|
|
61
|
+
: ''
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const onInput = (_value: Date[]) => {
|
|
65
|
+
if (_value === null) {
|
|
66
|
+
value.value = null
|
|
67
|
+
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (props.disabledTime && !props.isReturnISO) {
|
|
72
|
+
value.value = <IDateTimeRangeResponse>{
|
|
73
|
+
start: TimeHelper.getDateFormTime(_value[0]),
|
|
74
|
+
end: TimeHelper.getDateFormTime(_value[1]),
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
value.value = <IDateTimeRangeResponse>{
|
|
78
|
+
start: _value[0],
|
|
79
|
+
end: _value[1],
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
@@ -8,6 +8,7 @@ import { type ISelectField } from '#core/components/Form/InputSelect/types';
|
|
|
8
8
|
import { type IToggleField } from '#core/components/Form/InputToggle/types';
|
|
9
9
|
import { type ITextareaField } from '#core/components/Form/InputTextarea/types';
|
|
10
10
|
import { type IDateTimeField } from '#core/components/Form/InputDateTime/date_time_field.types';
|
|
11
|
+
import { type IDateTimeRangeField } from '~/src/runtime/components/Form/InputDateTimeRange/date_range_time_field.types';
|
|
11
12
|
import { type IUploadFileClassicField } from '#core/components/Form/InputUploadFileClassic/types';
|
|
12
13
|
import { type IUploadFileField } from '#core/components/Form/InputUploadFileClassicAuto/types';
|
|
13
14
|
import { type IUploadDropzoneField } from '#core/components/Form/InputUploadDropzone/types';
|
|
@@ -28,6 +29,8 @@ export declare const enum INPUT_TYPES {
|
|
|
28
29
|
CHECKBOX = "CHECKBOX",
|
|
29
30
|
DATE_TIME = "DATE_TIME",
|
|
30
31
|
DATE = "DATE",
|
|
32
|
+
DATE_RANGE = "DATE_RANGE",
|
|
33
|
+
DATE_TIME_RANGE = "DATE_TIME_RANGE",
|
|
31
34
|
UPLOAD_FILE_CLASSIC = "UPLOAD_FILE_CLASSIC",
|
|
32
35
|
UPLOAD_FILE_CLASSIC_AUTO = "UPLOAD_FILE_CLASSIC_AUTO",
|
|
33
36
|
UPLOAD_DROPZONE = "UPLOAD_DROPZONE",
|
|
@@ -62,4 +65,4 @@ export interface IFormFieldBase<I extends INPUT_TYPES, P extends IFieldProps, O>
|
|
|
62
65
|
props: P;
|
|
63
66
|
on?: O;
|
|
64
67
|
}
|
|
65
|
-
export type IFormField = ITextField | INumberField | IStaticField | ICheckboxField | IRadioField | ISelectField | IToggleField | ITextareaField | IDateTimeField | IUploadFileClassicField | IUploadFileField | IUploadDropzoneField | IUploadDropzoneAutoField | IUploadDropzoneAutoMultipleField | IUploadDropzoneImageAutoMultipleField;
|
|
68
|
+
export type IFormField = ITextField | INumberField | IStaticField | ICheckboxField | IRadioField | ISelectField | IToggleField | ITextareaField | IDateTimeField | IDateTimeRangeField | IUploadFileClassicField | IUploadFileField | IUploadDropzoneField | IUploadDropzoneAutoField | IUploadDropzoneAutoMultipleField | IUploadDropzoneImageAutoMultipleField;
|
|
@@ -11,6 +11,8 @@ export var INPUT_TYPES = /* @__PURE__ */ ((INPUT_TYPES2) => {
|
|
|
11
11
|
INPUT_TYPES2["CHECKBOX"] = "CHECKBOX";
|
|
12
12
|
INPUT_TYPES2["DATE_TIME"] = "DATE_TIME";
|
|
13
13
|
INPUT_TYPES2["DATE"] = "DATE";
|
|
14
|
+
INPUT_TYPES2["DATE_RANGE"] = "DATE_RANGE";
|
|
15
|
+
INPUT_TYPES2["DATE_TIME_RANGE"] = "DATE_TIME_RANGE";
|
|
14
16
|
INPUT_TYPES2["UPLOAD_FILE_CLASSIC"] = "UPLOAD_FILE_CLASSIC";
|
|
15
17
|
INPUT_TYPES2["UPLOAD_FILE_CLASSIC_AUTO"] = "UPLOAD_FILE_CLASSIC_AUTO";
|
|
16
18
|
INPUT_TYPES2["UPLOAD_DROPZONE"] = "UPLOAD_DROPZONE";
|
|
@@ -4,6 +4,6 @@ import { type IFieldProps, type IFormField } from '../components/Form/types';
|
|
|
4
4
|
interface IFieldContext<TValue> extends FieldContext<TValue> {
|
|
5
5
|
wrapperProps: ComputedRef<IFieldProps>;
|
|
6
6
|
}
|
|
7
|
-
export declare const useFieldHOC: <TValue = unknown>(newFormProps: IFieldProps, opts?: Partial<FieldOptions<TValue>>
|
|
7
|
+
export declare const useFieldHOC: <TValue = unknown>(newFormProps: IFieldProps, opts?: Partial<FieldOptions<TValue>>) => IFieldContext<TValue>;
|
|
8
8
|
export declare const createFormFields: (fields: () => IFormField[]) => any;
|
|
9
9
|
export {};
|
|
@@ -85,5 +85,5 @@ export interface IUsePageLoader<T> {
|
|
|
85
85
|
export declare const apiAddHelper: <T>(state: () => IAPIAddState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: any) => void, onUpdateItems: (data: any[]) => void, data: any, opts: IPageLoaderOptions<any> & IPageFetchLoaderOptions) => Promise<void>;
|
|
86
86
|
export declare const apiDeleteHelper: <T>(state: () => IAPIDeleteState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, _onUpdateData: (data: T) => void, onUpdateItems: (data: T[]) => void, id: string | number, opts: IPageLoaderOptions<any> & IPageDeleteLoaderOptions) => Promise<void>;
|
|
87
87
|
export declare const apiFetchHelper: <T>(state: () => IAPIFetchState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IPageOptions) => void, onUpdateItems: (items: T[]) => void, page: number, query: string, opts: IPageLoaderOptions<T> & IPageFetchLoaderOptions<any>) => Promise<void>;
|
|
88
|
-
export declare const apiFindHelper: <T>(state: () => IAPIFindState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: any) => void, id: string | number, opts: IPageLoaderOptions<T> & IPageFindLoaderOptions
|
|
88
|
+
export declare const apiFindHelper: <T>(state: () => IAPIFindState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: any) => void, id: string | number, opts: IPageLoaderOptions<T> & IPageFindLoaderOptions) => Promise<void>;
|
|
89
89
|
export declare const updateHelper: <T>(state: () => IAPIUpdateState<T>, onUpdateStatus: (status: IStatus) => void, onUpdateOptions: (options: IAPIOptions) => void, onUpdateData: (data: T) => void, _onUpdateItems: (data: T[]) => void, onUpdateOldData: (data: T) => void, id: string | number, data: any, opts: IPageLoaderOptions<any> & IPageUpdateLoaderOptions) => Promise<void>;
|
|
@@ -2,6 +2,10 @@ export declare class TimeHelper {
|
|
|
2
2
|
static thaiFormat: (dateStr: Date, formatStr: string) => string;
|
|
3
3
|
static displayDate: (time: string | Date) => string;
|
|
4
4
|
static displayDateTime: (time: string | Date) => string;
|
|
5
|
+
static displayDateRange: (startDate: Date | string, endDate: Date | string) => {
|
|
6
|
+
startDate: Date | string;
|
|
7
|
+
endDate: Date | string;
|
|
8
|
+
};
|
|
5
9
|
static toUTC: (time: string | Date) => string;
|
|
6
10
|
static toLocal: (time: string | Date) => string;
|
|
7
11
|
static getCurrentDate: () => string;
|
|
@@ -36,6 +36,22 @@ export class TimeHelper {
|
|
|
36
36
|
const newTime = TimeHelper.thaiFormat(parsedTime, dateTimeFormatDisplay);
|
|
37
37
|
return isValid(parsedTime) ? newTime : time;
|
|
38
38
|
};
|
|
39
|
+
static displayDateRange = (startDate, endDate) => {
|
|
40
|
+
if (!startDate || !endDate) {
|
|
41
|
+
return {
|
|
42
|
+
startDate,
|
|
43
|
+
endDate
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const parsedStartDate = isDate(startDate) ? startDate : new Date(startDate);
|
|
47
|
+
const parsedEndDate = isDate(endDate) ? endDate : new Date(endDate);
|
|
48
|
+
const newStartDate = TimeHelper.thaiFormat(parsedStartDate, dateFormatDisplay);
|
|
49
|
+
const newEndDate = TimeHelper.thaiFormat(parsedEndDate, dateFormatDisplay);
|
|
50
|
+
return {
|
|
51
|
+
startDate: isValid(parsedStartDate) ? newStartDate : startDate,
|
|
52
|
+
endDate: isValid(parsedEndDate) ? newEndDate : endDate
|
|
53
|
+
};
|
|
54
|
+
};
|
|
39
55
|
static toUTC = (time) => {
|
|
40
56
|
if (!time) {
|
|
41
57
|
return time;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.101",
|
|
4
4
|
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Finema Dev Core Team",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"prepack": "nuxt-module-build build",
|
|
25
|
-
"docs": "nuxi dev docs",
|
|
26
25
|
"dev": "nuxi dev playground",
|
|
27
26
|
"dev:build": "nuxi build playground",
|
|
28
27
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
"prepare": "husky install"
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@nuxt/kit": "^3.
|
|
36
|
+
"@nuxt/kit": "^3.11.0",
|
|
38
37
|
"@nuxt/ui": "^2.14.2",
|
|
39
38
|
"@pinia/nuxt": "^0.5.1",
|
|
40
39
|
"@vee-validate/nuxt": "^4.12.5",
|
|
@@ -54,11 +53,11 @@
|
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@finema/eslint-config": "^1.2.0",
|
|
57
|
-
"@nuxt/devtools": "
|
|
56
|
+
"@nuxt/devtools": "^1.0.8",
|
|
58
57
|
"@nuxt/eslint-config": "^0.2.0",
|
|
59
58
|
"@nuxt/module-builder": "^0.5.5",
|
|
60
|
-
"@nuxt/schema": "^3.
|
|
61
|
-
"@nuxt/test-utils": "^3.
|
|
59
|
+
"@nuxt/schema": "^3.11.0",
|
|
60
|
+
"@nuxt/test-utils": "^3.12.0",
|
|
62
61
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
63
62
|
"@types/node": "^20.10.17",
|
|
64
63
|
"@vue/test-utils": "^2.4.3",
|
|
@@ -67,7 +66,7 @@
|
|
|
67
66
|
"happy-dom": "^13.0.0",
|
|
68
67
|
"husky": "^9.0.11",
|
|
69
68
|
"lint-staged": "^15.2.0",
|
|
70
|
-
"nuxt": "^3.
|
|
69
|
+
"nuxt": "^3.11.0",
|
|
71
70
|
"playwright-core": "^1.42.1",
|
|
72
71
|
"prettier": "^3.1.1",
|
|
73
72
|
"release-it": "^17.0.1",
|