Refactor code for improved performance and readability

This commit is contained in:
kur0nek-o
2024-02-27 16:21:54 +07:00
parent 55da1410e2
commit d898014726
19 changed files with 1711 additions and 866 deletions

View File

@@ -1,6 +1,4 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
const props = defineProps({
placeholder: {
type: String,
@@ -18,25 +16,25 @@ const props = defineProps({
type: String,
default: '1 Menit'
}
})
const handleInput = (e :any) => {
e.value = e.value.replace(/[^0-9.]/g, '')
const handleInput = (e: any) => {
e.target.value = e.target.value.replace(/[^0-9.]/g, '')
}
const handleBlur = (e :any) => {
e.value = e.value ? e.value + ' Menit' : ''
const handleBlur = (e: any) => {
e.target.value = e.target.value ? e.target.value + ' Menit' : ''
}
const handleFocus = (e:any) => {
e.value = e.value.replace(/[^0-9.]/g, '')
const handleFocus = (e: any) => {
e.target.value = e.target.value.replace(/[^0-9.]/g, '')
}
</script>
<template>
<div
class="relative w-full overflow-hidden rounded-lg bg-gray-200">
<div class="relative w-full overflow-hidden rounded-lg bg-gray-200">
<input
:value="props.value"
:value="props.value"
autocomplete="off"
type="text"
:placeholder="placeholder"
@@ -44,9 +42,9 @@ const handleFocus = (e:any) => {
inputmode="numeric"
pattern="[0-9.]*"
:disabled="disabled"
@oninput="handleInput($event)"
@onblur="handleBlur($event)"
@onfocus="handleFocus($event)"
@input="handleInput($event)"
@blur="handleBlur($event)"
@focus="handleFocus($event)"
class="w-full px-4 py-2 text-sm leading-6 placeholder:text-gray-400 text-gray-900 border-0 border-transparent rounded-lg outline-0 bg-gray-200 focus:outline-0 focus:border-0 focus:ring-0"
/>
</div>