diff --git a/src/components/shared/InputNumber.vue b/src/components/shared/InputNumber.vue index ef157f85..60b7d1a4 100644 --- a/src/components/shared/InputNumber.vue +++ b/src/components/shared/InputNumber.vue @@ -2,26 +2,22 @@ import { ref, onMounted } from 'vue' interface Props { - modelValue: number required?: boolean placeholder?: string min?: number autoFocus?: boolean } +const model = defineModel({ required: true }) const props = withDefaults(defineProps(), { required: false, placeholder: '', min: 0, autoFocus: false }) -const emit = defineEmits<{ - (e: 'input', value: number): void - (e: 'update:modelValue', modelValue: number): void -}>() const inputRef = ref(null) function handleInput(value: string) { - emit('update:modelValue', Number(value)) + model.value = Number(value) } onMounted(() => { @@ -40,6 +36,6 @@ onMounted(() => { :placeholder="props.placeholder" :required="props.required" type="number" - :value="props.modelValue" + :value="model" @input="handleInput(($event.target as HTMLInputElement).value)" /> diff --git a/src/components/shared/InputRadioButton.vue b/src/components/shared/InputRadioButton.vue index 0dd683d4..538e77db 100644 --- a/src/components/shared/InputRadioButton.vue +++ b/src/components/shared/InputRadioButton.vue @@ -1,29 +1,19 @@ diff --git a/src/components/shared/MarkdownTextarea.vue b/src/components/shared/MarkdownTextarea.vue index 2b9667ae..ccdec77d 100644 --- a/src/components/shared/MarkdownTextarea.vue +++ b/src/components/shared/MarkdownTextarea.vue @@ -10,16 +10,15 @@ type TabType = 'input' | 'preview' interface Props { placeholder?: string - modelValue: string templates?: readonly { name: string; value: string }[] autoFocus?: boolean } +const model = defineModel({ required: true }) const props = withDefaults(defineProps(), { placeholder: '', autoFocus: false }) -const emit = defineEmits<{ (e: 'update:modelValue', value: string): void }>() const currentTab = ref('input') const selectedTemplate = ref('') @@ -34,10 +33,14 @@ const templateOptions = computed( }) ?? [] ) -function setTemplate(template: string) { +// eslint-disable-next-line @typescript-eslint/no-explicit-any -- FIXME: InputSelectSingleを直す +function setTemplate(template: Record | string | null) { + if (typeof template !== 'string') { + return + } const foundTemplate = props.templates?.find(t => t.name === template) if (foundTemplate !== undefined) { - emit('update:modelValue', foundTemplate.value) + model.value = foundTemplate.value } } @@ -72,11 +75,11 @@ function changeCurrentTab(tab: TabType) { + @update:model-value="setTemplate($event)">
@@ -84,13 +87,13 @@ function changeCurrentTab(tab: TabType) { v-if="currentTab === 'input'" :auto-focus="autoFocus" class="min-h-40 w-full" - :model-value="modelValue" + :model-value="model" :placeholder="placeholder" - @update:model-value="emit('update:modelValue', $event)" /> + @update:model-value="model = $event" /> + :text="model" />