<script lang="ts" setup>
import { ref } from 'vue'

const props = defineProps<{
  value: [number, number]
  label: string
}>()

const emit = defineEmits<{
  (e: 'update:value', value: number[]): void
}>()

const time = ref<[number, number]>(props.value)

function onChange(value: [number, number]) {
  emit('update:value', value)
}
</script>

<template>
  <div class="wrapper">
    <n-collapse :default-expanded-names="['1']" arrow-placement="right">
      <n-collapse-item :title="label" name="1">
        <n-space>
          <n-date-picker v-model:value="time" type="daterange" clearable @update:value="onChange" />
        </n-space>
      </n-collapse-item>
    </n-collapse>
  </div>
</template>

<style lang="less" scoped>
.wrapper {
  padding: 10px;
}
</style>
