@finema/core 1.4.217 → 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.
Files changed (67) hide show
  1. package/README.md +60 -60
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +1 -1
  4. package/dist/runtime/components/Alert.vue +48 -48
  5. package/dist/runtime/components/Avatar.vue +27 -27
  6. package/dist/runtime/components/Badge.vue +11 -11
  7. package/dist/runtime/components/Breadcrumb.vue +44 -44
  8. package/dist/runtime/components/Button/Group.vue +37 -37
  9. package/dist/runtime/components/Button/index.vue +75 -75
  10. package/dist/runtime/components/Card.vue +38 -38
  11. package/dist/runtime/components/Core.vue +45 -45
  12. package/dist/runtime/components/Dialog/index.vue +108 -108
  13. package/dist/runtime/components/Dropdown/index.vue +70 -70
  14. package/dist/runtime/components/Empty.vue +18 -18
  15. package/dist/runtime/components/FlexDeck/Base.vue +159 -159
  16. package/dist/runtime/components/FlexDeck/index.vue +68 -68
  17. package/dist/runtime/components/Form/FieldWrapper.vue +23 -23
  18. package/dist/runtime/components/Form/Fields.vue +230 -230
  19. package/dist/runtime/components/Form/InputCheckbox/index.vue +28 -28
  20. package/dist/runtime/components/Form/InputDateTime/index.vue +68 -68
  21. package/dist/runtime/components/Form/InputDateTimeRange/index.vue +91 -91
  22. package/dist/runtime/components/Form/InputNumber/index.vue +27 -27
  23. package/dist/runtime/components/Form/InputRadio/index.vue +27 -27
  24. package/dist/runtime/components/Form/InputSelect/index.vue +55 -55
  25. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +54 -54
  26. package/dist/runtime/components/Form/InputStatic/index.vue +16 -16
  27. package/dist/runtime/components/Form/InputTags/index.vue +141 -141
  28. package/dist/runtime/components/Form/InputText/index.vue +68 -68
  29. package/dist/runtime/components/Form/InputTextarea/index.vue +25 -25
  30. package/dist/runtime/components/Form/InputToggle/index.vue +27 -27
  31. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +206 -206
  32. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +362 -350
  33. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/ItemUpload.vue +241 -241
  34. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/ItemView.vue +110 -102
  35. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +171 -171
  36. package/dist/runtime/components/Form/InputUploadDropzoneImageAutoMultiple/ItemUpload.vue +161 -161
  37. package/dist/runtime/components/Form/InputUploadDropzoneImageAutoMultiple/ItemView.vue +64 -64
  38. package/dist/runtime/components/Form/InputUploadDropzoneImageAutoMultiple/index.vue +178 -178
  39. package/dist/runtime/components/Form/InputUploadFileClassic/index.vue +95 -95
  40. package/dist/runtime/components/Form/InputUploadFileClassicAuto/index.vue +151 -151
  41. package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +219 -219
  42. package/dist/runtime/components/Form/InputWYSIWYG/UploadImageForm.vue +55 -55
  43. package/dist/runtime/components/Form/InputWYSIWYG/index.vue +228 -228
  44. package/dist/runtime/components/Form/index.vue +6 -6
  45. package/dist/runtime/components/Icon.vue +23 -23
  46. package/dist/runtime/components/Image.vue +36 -36
  47. package/dist/runtime/components/Loader.vue +27 -27
  48. package/dist/runtime/components/Log.vue +22 -22
  49. package/dist/runtime/components/LogItem.vue +41 -41
  50. package/dist/runtime/components/Modal/index.vue +146 -146
  51. package/dist/runtime/components/OTPInput.vue +127 -127
  52. package/dist/runtime/components/QRCode.vue +22 -22
  53. package/dist/runtime/components/SimplePagination.vue +96 -96
  54. package/dist/runtime/components/Slideover/index.vue +110 -110
  55. package/dist/runtime/components/Table/Base.vue +161 -161
  56. package/dist/runtime/components/Table/ColumnDate.vue +16 -16
  57. package/dist/runtime/components/Table/ColumnDateTime.vue +18 -18
  58. package/dist/runtime/components/Table/ColumnImage.vue +15 -15
  59. package/dist/runtime/components/Table/ColumnNumber.vue +14 -14
  60. package/dist/runtime/components/Table/ColumnText.vue +29 -29
  61. package/dist/runtime/components/Table/Simple.vue +70 -70
  62. package/dist/runtime/components/Table/index.vue +65 -65
  63. package/dist/runtime/components/Tabs/index.vue +64 -64
  64. package/dist/runtime/components/TeleportSafe.vue +40 -40
  65. package/dist/runtime/helpers/componentHelper.d.ts +1 -0
  66. package/dist/runtime/helpers/componentHelper.mjs +5 -0
  67. package/package.json +100 -100
@@ -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,146 +1,146 @@
1
- <template>
2
- <UModal
3
- v-bind="attrs"
4
- :model-value="modelValue"
5
- :class="$props.class"
6
- :overlay="overlay"
7
- :transition="transition"
8
- :prevent-close="preventClose"
9
- :fullscreen="fullscreen"
10
- :initial-focus="modalWrapper"
11
- :ui="ui"
12
- @update:model-value="$emit('update:modelValue', $event)"
13
- >
14
- <div
15
- v-if="title"
16
- :class="[ui.header, { 'flex items-center justify-between': !isHideCloseBtn }]"
17
- >
18
- <h1 class="text-lg font-semibold">{{ title }}</h1>
19
- <Icon
20
- v-if="!isHideCloseBtn"
21
- name="i-heroicons-x-mark"
22
- class="size-6 cursor-pointer opacity-50"
23
- @click="close"
24
- />
25
- </div>
26
-
27
- <div
28
- v-if="(!title && !isHideCloseBtn && preventClose) || fullscreen"
29
- class="absolute right-0 m-4"
30
- >
31
- <Icon
32
- v-if="!isHideCloseBtn"
33
- name="i-heroicons-x-mark"
34
- class="size-6 cursor-pointer opacity-50"
35
- @click="close"
36
- />
37
- </div>
38
-
39
- <div ref="modalWrapper" :class="[ui.innerWrapper]">
40
- <slot />
41
- </div>
42
- </UModal>
43
- </template>
44
-
45
- <script lang="ts" setup>
46
- import { type PropType, defineShortcuts, ref, toRef, watch } from '#imports'
47
- import { useUI } from '#ui/composables/useUI'
48
- import { modal } from '#core/ui.config'
49
- import { useUiConfig } from '#core/composables/useConfig'
50
- import type { Strategy } from '#ui/types'
51
-
52
- const config = useUiConfig<typeof modal>(modal, 'modal')
53
-
54
- const props = defineProps({
55
- modelValue: {
56
- type: Boolean,
57
- default: false,
58
- },
59
- overlay: {
60
- type: Boolean,
61
- default: true,
62
- },
63
- transition: {
64
- type: Boolean,
65
- default: true,
66
- },
67
- preventClose: {
68
- type: Boolean,
69
- default: false,
70
- },
71
- fullscreen: {
72
- type: Boolean,
73
- default: false,
74
- },
75
- scrollable: {
76
- type: Boolean,
77
- default: false,
78
- },
79
- title: {
80
- type: String,
81
- default: '',
82
- },
83
- isHideCloseBtn: {
84
- type: Boolean,
85
- default: false,
86
- },
87
- size: {
88
- type: String as PropType<keyof typeof modal.size>,
89
- default: () => modal.default.size,
90
- },
91
- position: {
92
- type: String as PropType<keyof typeof modal.position>,
93
- default: () => modal.default.position,
94
- },
95
- fixHeightSize: {
96
- type: String as PropType<keyof typeof modal.fixHeightSize>,
97
- default: () => modal.default.fixHeightSize,
98
- },
99
- class: {
100
- type: [String, Array, Object] as PropType<any>,
101
- default: undefined,
102
- },
103
- ui: {
104
- type: Object as PropType<Partial<typeof config & { strategy?: Strategy }>>,
105
- default: undefined,
106
- },
107
- })
108
-
109
- const emits = defineEmits(['update:modelValue'])
110
-
111
- defineShortcuts({
112
- escape: {
113
- usingInput: true,
114
- handler: () => {
115
- if (props.preventClose) return
116
- emits('update:modelValue', false)
117
- },
118
- },
119
- })
120
-
121
- const modalWrapper = ref<HTMLElement | null>(null)
122
-
123
- const close = () => {
124
- emits('update:modelValue', false)
125
- }
126
-
127
- const { ui, attrs } = useUI('modal', toRef(props, 'ui'), config, toRef(props, 'class'))
128
-
129
- watch(
130
- () => props.modelValue,
131
- () => {
132
- if (props.modelValue) {
133
- const size = config.size[props.size]
134
- const fixHeightSize = config.fixHeightSize[props.fixHeightSize]
135
- const position = config.position[props.position]
136
-
137
- ui.value.width = size
138
- ui.value.container = position
139
-
140
- if (props.scrollable) {
141
- ui.value.height = fixHeightSize
142
- }
143
- }
144
- }
145
- )
146
- </script>
1
+ <template>
2
+ <UModal
3
+ v-bind="attrs"
4
+ :model-value="modelValue"
5
+ :class="$props.class"
6
+ :overlay="overlay"
7
+ :transition="transition"
8
+ :prevent-close="preventClose"
9
+ :fullscreen="fullscreen"
10
+ :initial-focus="modalWrapper"
11
+ :ui="ui"
12
+ @update:model-value="$emit('update:modelValue', $event)"
13
+ >
14
+ <div
15
+ v-if="title"
16
+ :class="[ui.header, { 'flex items-center justify-between': !isHideCloseBtn }]"
17
+ >
18
+ <h1 class="text-lg font-semibold">{{ title }}</h1>
19
+ <Icon
20
+ v-if="!isHideCloseBtn"
21
+ name="i-heroicons-x-mark"
22
+ class="size-6 cursor-pointer opacity-50"
23
+ @click="close"
24
+ />
25
+ </div>
26
+
27
+ <div
28
+ v-if="(!title && !isHideCloseBtn && preventClose) || fullscreen"
29
+ class="absolute right-0 m-4"
30
+ >
31
+ <Icon
32
+ v-if="!isHideCloseBtn"
33
+ name="i-heroicons-x-mark"
34
+ class="size-6 cursor-pointer opacity-50"
35
+ @click="close"
36
+ />
37
+ </div>
38
+
39
+ <div ref="modalWrapper" :class="[ui.innerWrapper]">
40
+ <slot />
41
+ </div>
42
+ </UModal>
43
+ </template>
44
+
45
+ <script lang="ts" setup>
46
+ import { type PropType, defineShortcuts, ref, toRef, watch } from '#imports'
47
+ import { useUI } from '#ui/composables/useUI'
48
+ import { modal } from '#core/ui.config'
49
+ import { useUiConfig } from '#core/composables/useConfig'
50
+ import type { Strategy } from '#ui/types'
51
+
52
+ const config = useUiConfig<typeof modal>(modal, 'modal')
53
+
54
+ const props = defineProps({
55
+ modelValue: {
56
+ type: Boolean,
57
+ default: false,
58
+ },
59
+ overlay: {
60
+ type: Boolean,
61
+ default: true,
62
+ },
63
+ transition: {
64
+ type: Boolean,
65
+ default: true,
66
+ },
67
+ preventClose: {
68
+ type: Boolean,
69
+ default: false,
70
+ },
71
+ fullscreen: {
72
+ type: Boolean,
73
+ default: false,
74
+ },
75
+ scrollable: {
76
+ type: Boolean,
77
+ default: false,
78
+ },
79
+ title: {
80
+ type: String,
81
+ default: '',
82
+ },
83
+ isHideCloseBtn: {
84
+ type: Boolean,
85
+ default: false,
86
+ },
87
+ size: {
88
+ type: String as PropType<keyof typeof modal.size>,
89
+ default: () => modal.default.size,
90
+ },
91
+ position: {
92
+ type: String as PropType<keyof typeof modal.position>,
93
+ default: () => modal.default.position,
94
+ },
95
+ fixHeightSize: {
96
+ type: String as PropType<keyof typeof modal.fixHeightSize>,
97
+ default: () => modal.default.fixHeightSize,
98
+ },
99
+ class: {
100
+ type: [String, Array, Object] as PropType<any>,
101
+ default: undefined,
102
+ },
103
+ ui: {
104
+ type: Object as PropType<Partial<typeof config & { strategy?: Strategy }>>,
105
+ default: undefined,
106
+ },
107
+ })
108
+
109
+ const emits = defineEmits(['update:modelValue'])
110
+
111
+ defineShortcuts({
112
+ escape: {
113
+ usingInput: true,
114
+ handler: () => {
115
+ if (props.preventClose) return
116
+ emits('update:modelValue', false)
117
+ },
118
+ },
119
+ })
120
+
121
+ const modalWrapper = ref<HTMLElement | null>(null)
122
+
123
+ const close = () => {
124
+ emits('update:modelValue', false)
125
+ }
126
+
127
+ const { ui, attrs } = useUI('modal', toRef(props, 'ui'), config, toRef(props, 'class'))
128
+
129
+ watch(
130
+ () => props.modelValue,
131
+ () => {
132
+ if (props.modelValue) {
133
+ const size = config.size[props.size]
134
+ const fixHeightSize = config.fixHeightSize[props.fixHeightSize]
135
+ const position = config.position[props.position]
136
+
137
+ ui.value.width = size
138
+ ui.value.container = position
139
+
140
+ if (props.scrollable) {
141
+ ui.value.height = fixHeightSize
142
+ }
143
+ }
144
+ }
145
+ )
146
+ </script>
@@ -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>