<template>
  <div class="kintoneplugin-input-container flex-row">
    <plugin-label v-if="label" :label="label" />
    <kuc-text :placeholder="placeholder" className="kuc-text-input" :value="modelValue" @change="updateValue" />
  </div>
</template>

<script setup lang="ts">
import type { KucEvent } from '@/types/my-kintone';
import type { TextInputEventDetail } from 'kintone-ui-component';
import { defineProps, defineEmits } from 'vue';

const props = defineProps<{
  label: string;
  modelValue: string;
  placeholder: string;
}>();

const emit = defineEmits<{
  (e: 'update:modelValue', value: string): void;
}>();

const updateValue = ({ detail }: KucEvent<TextInputEventDetail>) => {
  emit('update:modelValue', detail.value || '');
};
</script>
