<!-- eslint-disable vue/no-mutating-props -->
<script setup lang="ts">
import type { MjFormImageRenderOpts } from '.'
import type { RenderParams } from '../mj-form-plugin'

defineOptions({ name: 'MjFormImagePlugin' })

const props = withDefaults(
  defineProps<{
    renderOpts: MjFormImageRenderOpts
    // 表格、表单相关的一些数据
    renderParams: RenderParams
  }>(),
  {},
)

const value = computed({
  get() {
    return props.renderParams.data[props.renderParams.field]
  },
  set(val) {
    props.renderParams.data[props.renderParams.field] = val
  },
})
</script>

<template>
  <mj-form-image v-model="value" v-bind="renderOpts.props" />
</template>

<style lang="scss" scoped></style>
