<script setup lang="ts">
import { ref } from "vue";
import { useVModel } from "@vueuse/core";
import { httpVideoList } from "/@/api/components/remoteSelect";
import RemoteSelect from "../remote-select";

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

const remoteSelectRef = ref<any>(null);

const emit = defineEmits(["update:modelValue", "change"]);

const value = useVModel(props, "modelValue");

function initalData(data) {
  remoteSelectRef.value.initalData(data);
}

defineExpose({
  initalData
});
</script>

<template>
  <RemoteSelect
    v-model="value"
    :api="httpVideoList"
    :placeholder="placeholder"
    :showDisabled="true"
    ref="remoteSelectRef"
    response-label-prop="video_name"
    response-val-prop="id"
    request-prop="video_name"
    @item-change="val => emit('change', val)"
    @inital="unit => (value = unit)"
  />
</template>
