<!-- @format -->

<template>
  <a-modal v-bind="getBindValue" centered>
    <template #[item]="data" v-for="item in Object.keys($slots)" :key="item">
      <slot :name="item" v-bind="data || {}"></slot>
    </template>
  </a-modal>
</template>

<script lang="ts">
  import { computed, defineComponent, toRefs } from 'vue';
  import { useModalDrag } from '/nerv-lib/component/modal/useModalDrag';
  import { modalProps } from 'ant-design-vue/es/modal/Modal';

  export default defineComponent({
    name: 'NsModal',
    props: {
      ...modalProps(),
      draggable: {
        type: Boolean,
        default: true,
      },
      searchData: {
        type: Object,
        default: () => ({}),
      },
    },
    setup(props, { attrs, emit }) {
      const { visible, draggable, destroyOnClose } = toRefs(props);
      useModalDrag({
        visible,
        destroyOnClose,
        draggable,
      });
      const getBindValue = computed(() => ({
        ...attrs,
        ...props,
      }));
      return { getBindValue };
    },
  });
</script>
<style lang="less" scoped></style>
