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

defineOptions({ name: 'MjFormInputPlugin' })

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

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

<template>
  <mj-form-input v-model="text" v-bind="renderOpts.props" />
</template>

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