관리자 미디어 필터 입력 공통화
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
const props = defineProps({
|
||||
/** 선택 입력 값 */
|
||||
modelValue: {
|
||||
type: String,
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
/** 선택 옵션 목록 */
|
||||
@@ -34,13 +34,22 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
/**
|
||||
* option에 전달할 실제 값을 반환한다.
|
||||
* @param {Object} option - 선택 옵션
|
||||
* @returns {string|number} 선택 값
|
||||
*/
|
||||
const getOptionValue = (option) => option.value
|
||||
|
||||
/**
|
||||
* 선택 값을 상위 컴포넌트에 전달한다.
|
||||
* @param {Event} event - 변경 이벤트
|
||||
* @returns {void}
|
||||
*/
|
||||
const updateValue = (event) => {
|
||||
emit('update:modelValue', event.target?.value || '')
|
||||
const selectedValue = event.target?.value || ''
|
||||
const selectedOption = props.options.find((option) => String(option.value) === selectedValue)
|
||||
emit('update:modelValue', selectedOption ? selectedOption.value : selectedValue)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -55,7 +64,7 @@ const updateValue = (event) => {
|
||||
:aria-label="label"
|
||||
@change="updateValue"
|
||||
>
|
||||
<option v-for="option in options" :key="option.value" :value="option.value">
|
||||
<option v-for="option in options" :key="option.value" :value="getOptionValue(option)">
|
||||
{{ option.label }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user