@finema/core 1.4.216 → 1.4.218
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/Empty.vue +18 -18
- package/dist/runtime/components/Form/InputDateTime/index.vue +8 -1
- package/dist/runtime/components/Form/InputDateTimeRange/index.vue +8 -1
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +14 -2
- package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/ItemView.vue +9 -1
- package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +1 -0
- package/dist/runtime/components/Log.vue +22 -22
- package/dist/runtime/components/LogItem.vue +41 -41
- package/dist/runtime/components/OTPInput.vue +127 -127
- package/dist/runtime/helpers/componentHelper.d.ts +1 -0
- package/dist/runtime/helpers/componentHelper.mjs +5 -0
- package/package.json +2 -2
- package/dist/runtime/components/Form/InputDateTime/index.vue~ +0 -61
- package/dist/runtime/ui.config/table.ts~ +0 -48
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex flex-col items-center justify-center py-6 text-gray-400">
|
|
3
|
-
<Icon :name="icon!" class="text-[72px]" />
|
|
4
|
-
<p class="mt-2" v-html="message!" />
|
|
5
|
-
</div>
|
|
6
|
-
</template>
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
withDefaults(
|
|
9
|
-
defineProps<{
|
|
10
|
-
message?: any
|
|
11
|
-
icon?: string
|
|
12
|
-
}>(),
|
|
13
|
-
{
|
|
14
|
-
message: 'ไม่พบข้อมูล!',
|
|
15
|
-
icon: 'ph:table-thin',
|
|
16
|
-
}
|
|
17
|
-
)
|
|
18
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex flex-col items-center justify-center py-6 text-gray-400">
|
|
3
|
+
<Icon :name="icon!" class="text-[72px]" />
|
|
4
|
+
<p class="mt-2" v-html="message!" />
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
withDefaults(
|
|
9
|
+
defineProps<{
|
|
10
|
+
message?: any
|
|
11
|
+
icon?: string
|
|
12
|
+
}>(),
|
|
13
|
+
{
|
|
14
|
+
message: 'ไม่พบข้อมูล!',
|
|
15
|
+
icon: 'ph:table-thin',
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
</script>
|
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
time-picker-inline
|
|
19
19
|
@update:model-value="onInput"
|
|
20
20
|
>
|
|
21
|
+
<template v-if="appConfig.core?.is_thai_year" #year="{ value }">
|
|
22
|
+
{{ value + 543 }}
|
|
23
|
+
</template>
|
|
24
|
+
<template v-if="appConfig.core?.is_thai_year" #year-overlay-value="{ value }">
|
|
25
|
+
{{ value + 543 }}
|
|
26
|
+
</template>
|
|
21
27
|
<template #dp-input="{ value: innerValue }">
|
|
22
28
|
<UInput
|
|
23
29
|
:trailing-icon="innerValue ? undefined : 'i-heroicons-calendar-days'"
|
|
@@ -36,11 +42,12 @@
|
|
|
36
42
|
import Datepicker from '@vuepic/vue-datepicker'
|
|
37
43
|
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
38
44
|
import { type IDateTimeFieldProps } from '#core/components/Form/InputDateTime/date_time_field.types'
|
|
39
|
-
import { TimeHelper, useFieldHOC } from '#imports'
|
|
45
|
+
import { TimeHelper, useFieldHOC, useAppConfig } from '#imports'
|
|
40
46
|
import '@vuepic/vue-datepicker/dist/main.css'
|
|
41
47
|
|
|
42
48
|
const props = withDefaults(defineProps<IDateTimeFieldProps>(), {})
|
|
43
49
|
|
|
50
|
+
const appConfig = useAppConfig()
|
|
44
51
|
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
45
52
|
|
|
46
53
|
const format = (date: Date) => {
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
range
|
|
22
22
|
@update:model-value="onInput"
|
|
23
23
|
>
|
|
24
|
+
<template v-if="appConfig.core?.is_thai_year" #year="{ value }">
|
|
25
|
+
{{ value + 543 }}
|
|
26
|
+
</template>
|
|
27
|
+
<template v-if="appConfig.core?.is_thai_year" #year-overlay-value="{ value }">
|
|
28
|
+
{{ value + 543 }}
|
|
29
|
+
</template>
|
|
24
30
|
<template #dp-input="{ value: innerValue }">
|
|
25
31
|
<UInput
|
|
26
32
|
:trailing-icon="innerValue ? undefined : 'i-heroicons-calendar-days'"
|
|
@@ -37,7 +43,7 @@
|
|
|
37
43
|
<script lang="ts" setup>
|
|
38
44
|
import Datepicker from '@vuepic/vue-datepicker'
|
|
39
45
|
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
40
|
-
import { TimeHelper, ref, useFieldHOC } from '#imports'
|
|
46
|
+
import { TimeHelper, ref, useFieldHOC, useAppConfig } from '#imports'
|
|
41
47
|
import '@vuepic/vue-datepicker/dist/main.css'
|
|
42
48
|
import type {
|
|
43
49
|
IDateTimeRangeFieldProps,
|
|
@@ -46,6 +52,7 @@ import type {
|
|
|
46
52
|
|
|
47
53
|
const props = withDefaults(defineProps<IDateTimeRangeFieldProps>(), {})
|
|
48
54
|
|
|
55
|
+
const appConfig = useAppConfig()
|
|
49
56
|
const { value, wrapperProps } = useFieldHOC<IDateTimeRangeResponse | null>(props)
|
|
50
57
|
|
|
51
58
|
const innerValueRef = ref<Date[]>([])
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
/>
|
|
100
100
|
</a>
|
|
101
101
|
<Icon
|
|
102
|
-
v-if="isImageFromPath(value.path)"
|
|
102
|
+
v-if="isImageFromPath(value.path) || isVideoFromPath(value.path)"
|
|
103
103
|
:name="ui.action.previewIcon"
|
|
104
104
|
:class="[ui.action.iconClass]"
|
|
105
105
|
title="ดูตัวอย่าง"
|
|
@@ -119,7 +119,18 @@
|
|
|
119
119
|
@click="handleDeleteFile"
|
|
120
120
|
/>
|
|
121
121
|
<Modal v-model="isPreviewOpen" :title="value.name">
|
|
122
|
-
<img
|
|
122
|
+
<img
|
|
123
|
+
v-if="isImageFromPath(value.path)"
|
|
124
|
+
:src="value.url"
|
|
125
|
+
alt="img-preview"
|
|
126
|
+
class="mx-auto max-w-full rounded-lg"
|
|
127
|
+
/>
|
|
128
|
+
<video
|
|
129
|
+
v-else-if="isVideoFromPath(value.path)"
|
|
130
|
+
:src="value.url"
|
|
131
|
+
controls
|
|
132
|
+
class="mx-auto max-w-full"
|
|
133
|
+
/>
|
|
123
134
|
</Modal>
|
|
124
135
|
</div>
|
|
125
136
|
</div>
|
|
@@ -180,6 +191,7 @@ import {
|
|
|
180
191
|
isImageFromPath,
|
|
181
192
|
useFileSize,
|
|
182
193
|
isPDFFromPath,
|
|
194
|
+
isVideoFromPath,
|
|
183
195
|
} from '#core/helpers/componentHelper'
|
|
184
196
|
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
185
197
|
import { useFieldHOC } from '#core/composables/useForm'
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
</div>
|
|
32
32
|
<div :class="[ui.action.wrapper]">
|
|
33
33
|
<Icon
|
|
34
|
-
v-if="isImageFromPath(selectedFile.path)"
|
|
34
|
+
v-if="isImageFromPath(selectedFile.path) || isVideoFromPath(selectedFile.path)"
|
|
35
35
|
:name="ui.action.previewIcon"
|
|
36
36
|
:class="[ui.action.iconClass]"
|
|
37
37
|
title="ดูตัวอย่าง"
|
|
@@ -59,10 +59,17 @@
|
|
|
59
59
|
/>
|
|
60
60
|
<Modal v-model="isPreviewOpen" :title="selectedFile?.name">
|
|
61
61
|
<img
|
|
62
|
+
v-if="isImageFromPath(selectedFile.path)"
|
|
62
63
|
:src="selectedFile.url"
|
|
63
64
|
alt="image-preview"
|
|
64
65
|
class="mx-auto max-w-full rounded-lg"
|
|
65
66
|
/>
|
|
67
|
+
<video
|
|
68
|
+
v-else-if="isVideoFromPath(selectedFile.path)"
|
|
69
|
+
:src="selectedFile.url"
|
|
70
|
+
controls
|
|
71
|
+
class="mx-auto max-w-full"
|
|
72
|
+
/>
|
|
66
73
|
</Modal>
|
|
67
74
|
</div>
|
|
68
75
|
</div>
|
|
@@ -74,6 +81,7 @@ import {
|
|
|
74
81
|
downloadFileFromURL,
|
|
75
82
|
isImageFromPath,
|
|
76
83
|
isPDFFromPath,
|
|
84
|
+
isVideoFromPath,
|
|
77
85
|
useFileSize,
|
|
78
86
|
} from '#core/helpers/componentHelper'
|
|
79
87
|
import { type uploadFileDropzone } from '#core/ui.config'
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<TeleportSafe v-if="isDevEnv" to="#dev-logs">
|
|
3
|
-
<LogItem v-if="typeof data !== 'undefined'" :data="data" :title="title" />
|
|
4
|
-
<LogItem
|
|
5
|
-
v-for="(item, index) in dataItems"
|
|
6
|
-
:key="index"
|
|
7
|
-
:data="item"
|
|
8
|
-
:title="`${title} #${index + 1}`"
|
|
9
|
-
/>
|
|
10
|
-
</TeleportSafe>
|
|
11
|
-
</template>
|
|
12
|
-
<script lang="ts" setup>
|
|
13
|
-
import LogItem from './LogItem.vue'
|
|
14
|
-
|
|
15
|
-
defineProps<{
|
|
16
|
-
data?: any
|
|
17
|
-
dataItems?: any[]
|
|
18
|
-
title?: string
|
|
19
|
-
}>()
|
|
20
|
-
|
|
21
|
-
const isDevEnv = process.env.NODE_ENV === 'development'
|
|
22
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<TeleportSafe v-if="isDevEnv" to="#dev-logs">
|
|
3
|
+
<LogItem v-if="typeof data !== 'undefined'" :data="data" :title="title" />
|
|
4
|
+
<LogItem
|
|
5
|
+
v-for="(item, index) in dataItems"
|
|
6
|
+
:key="index"
|
|
7
|
+
:data="item"
|
|
8
|
+
:title="`${title} #${index + 1}`"
|
|
9
|
+
/>
|
|
10
|
+
</TeleportSafe>
|
|
11
|
+
</template>
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import LogItem from './LogItem.vue'
|
|
14
|
+
|
|
15
|
+
defineProps<{
|
|
16
|
+
data?: any
|
|
17
|
+
dataItems?: any[]
|
|
18
|
+
title?: string
|
|
19
|
+
}>()
|
|
20
|
+
|
|
21
|
+
const isDevEnv = process.env.NODE_ENV === 'development'
|
|
22
|
+
</script>
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div class="mb-2 flex items-center justify-between">
|
|
4
|
-
<p v-if="title" class="font-semibold">{{ title }}</p>
|
|
5
|
-
<Icon
|
|
6
|
-
class="cursor-pointer"
|
|
7
|
-
:name="isShow ? 'heroicons:minus' : 'heroicons:plus'"
|
|
8
|
-
@click="isShow = !isShow"
|
|
9
|
-
/>
|
|
10
|
-
</div>
|
|
11
|
-
<VCodeBlock
|
|
12
|
-
v-show="isShow"
|
|
13
|
-
:code="getCode"
|
|
14
|
-
max-height="500"
|
|
15
|
-
:browser-window="true"
|
|
16
|
-
:indent="2"
|
|
17
|
-
lang="json"
|
|
18
|
-
highlightjs
|
|
19
|
-
/>
|
|
20
|
-
</div>
|
|
21
|
-
</template>
|
|
22
|
-
<script lang="ts" setup>
|
|
23
|
-
import { computed, ref } from 'vue'
|
|
24
|
-
import { VCodeBlock } from '@wdns/vue-code-block'
|
|
25
|
-
|
|
26
|
-
const props = defineProps<{
|
|
27
|
-
data?: any
|
|
28
|
-
title?: string
|
|
29
|
-
}>()
|
|
30
|
-
|
|
31
|
-
const isShow = ref(true)
|
|
32
|
-
|
|
33
|
-
const getCode = computed(() => {
|
|
34
|
-
try {
|
|
35
|
-
return JSON.stringify(props.data)
|
|
36
|
-
} catch (e) {
|
|
37
|
-
return JSON.stringify('{}')
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="mb-2 flex items-center justify-between">
|
|
4
|
+
<p v-if="title" class="font-semibold">{{ title }}</p>
|
|
5
|
+
<Icon
|
|
6
|
+
class="cursor-pointer"
|
|
7
|
+
:name="isShow ? 'heroicons:minus' : 'heroicons:plus'"
|
|
8
|
+
@click="isShow = !isShow"
|
|
9
|
+
/>
|
|
10
|
+
</div>
|
|
11
|
+
<VCodeBlock
|
|
12
|
+
v-show="isShow"
|
|
13
|
+
:code="getCode"
|
|
14
|
+
max-height="500"
|
|
15
|
+
:browser-window="true"
|
|
16
|
+
:indent="2"
|
|
17
|
+
lang="json"
|
|
18
|
+
highlightjs
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import { computed, ref } from 'vue'
|
|
24
|
+
import { VCodeBlock } from '@wdns/vue-code-block'
|
|
25
|
+
|
|
26
|
+
const props = defineProps<{
|
|
27
|
+
data?: any
|
|
28
|
+
title?: string
|
|
29
|
+
}>()
|
|
30
|
+
|
|
31
|
+
const isShow = ref(true)
|
|
32
|
+
|
|
33
|
+
const getCode = computed(() => {
|
|
34
|
+
try {
|
|
35
|
+
return JSON.stringify(props.data)
|
|
36
|
+
} catch (e) {
|
|
37
|
+
return JSON.stringify('{}')
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
</script>
|
|
41
41
|
<style>
|
|
42
42
|
.hljs-string{white-space:break-spaces}
|
|
43
|
-
</style>
|
|
43
|
+
</style>
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="containerClass">
|
|
3
|
-
<input
|
|
4
|
-
v-for="(_, index) in length"
|
|
5
|
-
:key="index"
|
|
6
|
-
:ref="(el) => setInputRef(index, el)"
|
|
7
|
-
v-model="otp[index]"
|
|
8
|
-
:type="isPassword ? 'password' : 'text'"
|
|
9
|
-
:class="inputClass"
|
|
10
|
-
maxlength="1"
|
|
11
|
-
:autofocus="autoFocus && index === 0"
|
|
12
|
-
@input="handleInput(index)"
|
|
13
|
-
@focus="handleFocus($event)"
|
|
14
|
-
@paste="handlePaste"
|
|
15
|
-
@keydown="handleKeydown(index, $event)"
|
|
16
|
-
/>
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
<script lang="ts" setup>
|
|
20
|
-
import { type Ref, ref } from 'vue'
|
|
21
|
-
import { watch } from '#imports'
|
|
22
|
-
|
|
23
|
-
const emits = defineEmits(['update:modelValue'])
|
|
24
|
-
const props = defineProps({
|
|
25
|
-
length: {
|
|
26
|
-
type: Number,
|
|
27
|
-
required: true,
|
|
28
|
-
},
|
|
29
|
-
autoFocus: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
default: false,
|
|
32
|
-
},
|
|
33
|
-
isPassword: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: false,
|
|
36
|
-
},
|
|
37
|
-
isOnlyNumber: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: false,
|
|
40
|
-
},
|
|
41
|
-
modelValue: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: '',
|
|
44
|
-
},
|
|
45
|
-
containerClass: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: 'flex space-x-3',
|
|
48
|
-
},
|
|
49
|
-
inputClass: {
|
|
50
|
-
type: String,
|
|
51
|
-
default:
|
|
52
|
-
'h-12 w-12 relative flex flex-col items-center justify-center text-center ' +
|
|
53
|
-
'disabled:cursor-not-allowed disabled:opacity-75 focus:outline-none border-0 form-input ' +
|
|
54
|
-
'rounded-md placeholder-gray-400 text-sm px-3.5 py-2.5 shadow-sm bg-white text-gray-900 ' +
|
|
55
|
-
'ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-primary-500',
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const otp: Ref<string[]> = ref(Array(props.length).fill(''))
|
|
60
|
-
const inputRefs: Ref<HTMLInputElement[]> = ref([])
|
|
61
|
-
|
|
62
|
-
const setInputRef = (index: number, el: HTMLInputElement) => {
|
|
63
|
-
if (el) {
|
|
64
|
-
inputRefs.value[index] = el
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const focusNext = (index: number): void => {
|
|
69
|
-
if (index < props.length - 1) {
|
|
70
|
-
inputRefs.value[index + 1].focus()
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const focusPrevious = (index: number): void => {
|
|
75
|
-
if (index > 0) {
|
|
76
|
-
inputRefs.value[index - 1].focus()
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const isNumeric = (str: string): boolean => {
|
|
81
|
-
return /^\d+$/.test(str)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const handleInput = (index: number): void => {
|
|
85
|
-
if (props.isOnlyNumber && !isNumeric(otp.value[index])) {
|
|
86
|
-
otp.value[index] = ''
|
|
87
|
-
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (otp.value[index].length === 1) {
|
|
92
|
-
focusNext(index)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const handleFocus = (event: FocusEvent): void => {
|
|
97
|
-
const target = event.target as HTMLInputElement
|
|
98
|
-
|
|
99
|
-
target.select()
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const handlePaste = (event: ClipboardEvent): void => {
|
|
103
|
-
const paste = event.clipboardData?.getData('text') || ''
|
|
104
|
-
|
|
105
|
-
if (paste.length === props.length) {
|
|
106
|
-
paste.split('').forEach((char, idx) => {
|
|
107
|
-
otp.value[idx] = char
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
focusNext(paste.length - 2)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const handleKeydown = (index: number, event: KeyboardEvent): void => {
|
|
115
|
-
// Focus the previous field if backspace is pressed on an empty field
|
|
116
|
-
if (event.key === 'Backspace' && otp.value[index] === '') {
|
|
117
|
-
focusPrevious(index)
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
watch(
|
|
122
|
-
() => otp.value.join(''),
|
|
123
|
-
(newValue) => {
|
|
124
|
-
emits('update:modelValue', newValue)
|
|
125
|
-
}
|
|
126
|
-
)
|
|
127
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="containerClass">
|
|
3
|
+
<input
|
|
4
|
+
v-for="(_, index) in length"
|
|
5
|
+
:key="index"
|
|
6
|
+
:ref="(el) => setInputRef(index, el)"
|
|
7
|
+
v-model="otp[index]"
|
|
8
|
+
:type="isPassword ? 'password' : 'text'"
|
|
9
|
+
:class="inputClass"
|
|
10
|
+
maxlength="1"
|
|
11
|
+
:autofocus="autoFocus && index === 0"
|
|
12
|
+
@input="handleInput(index)"
|
|
13
|
+
@focus="handleFocus($event)"
|
|
14
|
+
@paste="handlePaste"
|
|
15
|
+
@keydown="handleKeydown(index, $event)"
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<script lang="ts" setup>
|
|
20
|
+
import { type Ref, ref } from 'vue'
|
|
21
|
+
import { watch } from '#imports'
|
|
22
|
+
|
|
23
|
+
const emits = defineEmits(['update:modelValue'])
|
|
24
|
+
const props = defineProps({
|
|
25
|
+
length: {
|
|
26
|
+
type: Number,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
autoFocus: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
isPassword: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
37
|
+
isOnlyNumber: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
modelValue: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: '',
|
|
44
|
+
},
|
|
45
|
+
containerClass: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: 'flex space-x-3',
|
|
48
|
+
},
|
|
49
|
+
inputClass: {
|
|
50
|
+
type: String,
|
|
51
|
+
default:
|
|
52
|
+
'h-12 w-12 relative flex flex-col items-center justify-center text-center ' +
|
|
53
|
+
'disabled:cursor-not-allowed disabled:opacity-75 focus:outline-none border-0 form-input ' +
|
|
54
|
+
'rounded-md placeholder-gray-400 text-sm px-3.5 py-2.5 shadow-sm bg-white text-gray-900 ' +
|
|
55
|
+
'ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-primary-500',
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const otp: Ref<string[]> = ref(Array(props.length).fill(''))
|
|
60
|
+
const inputRefs: Ref<HTMLInputElement[]> = ref([])
|
|
61
|
+
|
|
62
|
+
const setInputRef = (index: number, el: HTMLInputElement) => {
|
|
63
|
+
if (el) {
|
|
64
|
+
inputRefs.value[index] = el
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const focusNext = (index: number): void => {
|
|
69
|
+
if (index < props.length - 1) {
|
|
70
|
+
inputRefs.value[index + 1].focus()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const focusPrevious = (index: number): void => {
|
|
75
|
+
if (index > 0) {
|
|
76
|
+
inputRefs.value[index - 1].focus()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const isNumeric = (str: string): boolean => {
|
|
81
|
+
return /^\d+$/.test(str)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const handleInput = (index: number): void => {
|
|
85
|
+
if (props.isOnlyNumber && !isNumeric(otp.value[index])) {
|
|
86
|
+
otp.value[index] = ''
|
|
87
|
+
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (otp.value[index].length === 1) {
|
|
92
|
+
focusNext(index)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const handleFocus = (event: FocusEvent): void => {
|
|
97
|
+
const target = event.target as HTMLInputElement
|
|
98
|
+
|
|
99
|
+
target.select()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const handlePaste = (event: ClipboardEvent): void => {
|
|
103
|
+
const paste = event.clipboardData?.getData('text') || ''
|
|
104
|
+
|
|
105
|
+
if (paste.length === props.length) {
|
|
106
|
+
paste.split('').forEach((char, idx) => {
|
|
107
|
+
otp.value[idx] = char
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
focusNext(paste.length - 2)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const handleKeydown = (index: number, event: KeyboardEvent): void => {
|
|
115
|
+
// Focus the previous field if backspace is pressed on an empty field
|
|
116
|
+
if (event.key === 'Backspace' && otp.value[index] === '') {
|
|
117
|
+
focusPrevious(index)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
watch(
|
|
122
|
+
() => otp.value.join(''),
|
|
123
|
+
(newValue) => {
|
|
124
|
+
emits('update:modelValue', newValue)
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
</script>
|
|
@@ -4,6 +4,7 @@ export declare const checkFileType: (file: File, acceptFileType: string | string
|
|
|
4
4
|
export declare const generateURL: (file: File) => string;
|
|
5
5
|
export declare const isImage: (file: File) => boolean;
|
|
6
6
|
export declare const isImageFromPath: (path?: string) => boolean;
|
|
7
|
+
export declare const isVideoFromPath: (path?: string) => boolean;
|
|
7
8
|
export declare const isPDFFromPath: (path?: string) => boolean;
|
|
8
9
|
export declare const useFileAllocate: (selectedFile: Ref<File | undefined | null>, props: {
|
|
9
10
|
accept?: string | string[];
|
|
@@ -41,6 +41,11 @@ export const isImageFromPath = (path = "") => {
|
|
|
41
41
|
const extension = path.toLowerCase().substring(path.lastIndexOf("."));
|
|
42
42
|
return imageExtensions.includes(extension);
|
|
43
43
|
};
|
|
44
|
+
export const isVideoFromPath = (path = "") => {
|
|
45
|
+
const imageExtensions = [".mp4"];
|
|
46
|
+
const extension = path.toLowerCase().substring(path.lastIndexOf("."));
|
|
47
|
+
return imageExtensions.includes(extension);
|
|
48
|
+
};
|
|
44
49
|
export const isPDFFromPath = (path = "") => {
|
|
45
50
|
const imageExtensions = [".pdf"];
|
|
46
51
|
const extension = path.toLowerCase().substring(path.lastIndexOf("."));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.218",
|
|
4
4
|
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Finema Dev Core Team",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@nuxt/kit": "^3.13.1",
|
|
39
|
-
"@nuxt/ui": "2.
|
|
39
|
+
"@nuxt/ui": "2.20.0",
|
|
40
40
|
"@pinia/nuxt": "^0.7.0",
|
|
41
41
|
"@tiptap/extension-image": "^2.8.0",
|
|
42
42
|
"@tiptap/extension-link": "^2.8.0",
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<Datepicker
|
|
4
|
-
:model-value="value"
|
|
5
|
-
:disabled="wrapperProps.isDisabled"
|
|
6
|
-
cancel-text="ยกเลิก"
|
|
7
|
-
select-text="เลือก"
|
|
8
|
-
locale="th"
|
|
9
|
-
:enable-time-picker="!disabledTime"
|
|
10
|
-
:placeholder="wrapperProps.placeholder"
|
|
11
|
-
:format="format"
|
|
12
|
-
:min-date="minDate"
|
|
13
|
-
:max-date="maxDate"
|
|
14
|
-
:min-time="minTime"
|
|
15
|
-
:max-time="maxTime"
|
|
16
|
-
:start-time="startTime"
|
|
17
|
-
:required="isRequired"
|
|
18
|
-
time-picker-inline
|
|
19
|
-
@update:model-value="onInput"
|
|
20
|
-
>
|
|
21
|
-
<template #dp-input="{ value: innerValue }">
|
|
22
|
-
<UInput
|
|
23
|
-
:trailing-icon="innerValue ? undefined : 'i-heroicons-calendar-days'"
|
|
24
|
-
type="text"
|
|
25
|
-
:disabled="wrapperProps.isDisabled"
|
|
26
|
-
:value="innerValue"
|
|
27
|
-
:placeholder="wrapperProps.placeholder"
|
|
28
|
-
:readonly="true"
|
|
29
|
-
input-class="cursor-pointer select-none"
|
|
30
|
-
/>
|
|
31
|
-
</template>
|
|
32
|
-
</Datepicker>
|
|
33
|
-
</FieldWrapper>
|
|
34
|
-
</template>
|
|
35
|
-
<script lang="ts" setup>
|
|
36
|
-
import Datepicker from '@vuepic/vue-datepicker'
|
|
37
|
-
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
38
|
-
import { type IDateTimeFieldProps } from '#core/components/Form/InputDateTime/date_time_field.types'
|
|
39
|
-
import { TimeHelper, useFieldHOC } from '#imports'
|
|
40
|
-
import '@vuepic/vue-datepicker/dist/main.css'
|
|
41
|
-
|
|
42
|
-
const props = withDefaults(defineProps<IDateTimeFieldProps>(), {})
|
|
43
|
-
|
|
44
|
-
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
45
|
-
|
|
46
|
-
const format = (date: Date) => {
|
|
47
|
-
if (props.disabledTime) {
|
|
48
|
-
return TimeHelper.displayDate(date)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return TimeHelper.displayDateTime(date)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const onInput = (_value: any) => {
|
|
55
|
-
if (props.disabledTime && !props.isReturnISO) {
|
|
56
|
-
value.value = TimeHelper.getDateFormTime(_value)
|
|
57
|
-
} else {
|
|
58
|
-
value.value = _value
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
</script>
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { DeepPartial } from '#ui/types'
|
|
2
|
-
import type * as config from '#ui/ui.config'
|
|
3
|
-
|
|
4
|
-
export const table: DeepPartial<(typeof config)['table']> = {
|
|
5
|
-
wrapper: 'relative overflow-x-auto bg-white rounded-lg',
|
|
6
|
-
base: 'min-w-full table-fixed',
|
|
7
|
-
divide: 'divide-y divide-y-2 divide-gray-300 dark:divide-gray-700',
|
|
8
|
-
thead: '',
|
|
9
|
-
tbody: 'divide-y divide-gray-200 dark:divide-gray-800',
|
|
10
|
-
tr: {
|
|
11
|
-
base: 'even:bg-gray-50',
|
|
12
|
-
selected: 'bg-gray-50 dark:bg-gray-800/50',
|
|
13
|
-
active: 'hover:bg-gray-50 dark:hover:bg-gray-800/50 cursor-pointer',
|
|
14
|
-
},
|
|
15
|
-
th: {
|
|
16
|
-
base: 'text-left rtl:text-right',
|
|
17
|
-
padding: 'px-3 py-3.5',
|
|
18
|
-
color: 'text-gray-700 dark:text-white',
|
|
19
|
-
font: 'font-normal',
|
|
20
|
-
size: 'text-sm',
|
|
21
|
-
},
|
|
22
|
-
td: {
|
|
23
|
-
base: 'whitespace-nowrap',
|
|
24
|
-
padding: 'px-3 py-4',
|
|
25
|
-
color: 'text-gray-500 dark:text-gray-400',
|
|
26
|
-
font: '',
|
|
27
|
-
size: 'text-base',
|
|
28
|
-
},
|
|
29
|
-
progress: {
|
|
30
|
-
wrapper: 'absolute inset-x-0 p-0',
|
|
31
|
-
},
|
|
32
|
-
default: {
|
|
33
|
-
sortButton: {
|
|
34
|
-
icon: 'i-heroicons-arrows-up-down-20-solid',
|
|
35
|
-
trailing: true,
|
|
36
|
-
square: true,
|
|
37
|
-
color: 'gray',
|
|
38
|
-
variant: 'ghost',
|
|
39
|
-
class: '-m-1.5 text-gray-700 font-normal',
|
|
40
|
-
},
|
|
41
|
-
loadingState: {
|
|
42
|
-
label: 'กำลังโหลด...',
|
|
43
|
-
},
|
|
44
|
-
emptyState: {
|
|
45
|
-
label: 'ไม่พบข้อมูล',
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
}
|