Skip to content

Commit

Permalink
🛠️: refactor FormInput to composition API and typeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
itisAliRH committed Apr 5, 2024
1 parent 193d58f commit ff07413
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions client/src/components/Form/Elements/FormInput.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
<script setup lang="ts">
import { computed } from "vue";
interface Props {
id: string;
value?: string;
area?: boolean;
}
const props = defineProps<Props>();
const emit = defineEmits<{
(e: "input", value: string | undefined): void;
}>();
const currentValue = computed({
get() {
return props.value;
},
set(val) {
emit("input", val);
},
});
</script>

<template>
<textarea v-if="area" :id="id" v-model="currentValue" class="ui-textarea" />

<input v-else :id="id" v-model="currentValue" class="ui-input" />
</template>
<script>
export default {
props: {
id: {
type: String,
required: true,
},
value: {
type: String,
default: "",
},
area: {
type: Boolean,
default: false,
},
},
computed: {
currentValue: {
get() {
return this.value;
},
set(val) {
this.$emit("input", val);
},
},
},
};
</script>

0 comments on commit ff07413

Please sign in to comment.