<!--
/**
 * author: vformAdmin
 * email: vdpadmin@163.com
 * website: https://www.vform666.com
 * date: 2021.08.18
 * remark: 如果要分发VForm源码，需在本文件顶部保留此文件头信息！！
 */
-->

<template>
  <div>
    <template v-for="(subWidget, swIdx) in widget.widgetList">
      <template v-if="'container' === subWidget.category">
        <component :is="subWidget.type + '-item'" :widget="subWidget" :key="swIdx" :parent-list="widget.widgetList"
                   :index-of-parent-list="swIdx" :parent-widget="widget">
          <!-- 递归传递插槽！！！ -->
          <template v-for="slot in Object.keys($scopedSlots)" v-slot:[slot]="scope">
            <slot :name="slot" v-bind="scope"/>
          </template>
        </component>
      </template>
      <template v-else>
        <component :is="subWidget.type + '-widget'" :field="subWidget" :key="swIdx" :parent-list="widget.widgetList"
                   :index-of-parent-list="swIdx" :parent-widget="widget">
          <!-- 递归传递插槽！！！ -->
          <template v-for="slot in Object.keys($scopedSlots)" v-slot:[slot]="scope">
            <slot :name="slot" v-bind="scope"/>
          </template>
        </component>
      </template>
    </template>
  </div>

</template>

<script>
import emitter from '../../../../components/xform/utils/emitter'
import i18n from "../../../../components/xform/utils/i18n"
import refMixin from "../../../../components/xform/form-render/refMixin"
import containerItemMixin from "./containerItemMixin"
import FieldComponents from '../../../../components/xform/form-designer/form-widget/field-widget/index'
import FormItemWrapper from "../../../../components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue";


export default {
  name: 'tableColumnItem',
  componentName: 'ContainerItem',
  mixins: [emitter, i18n, refMixin, containerItemMixin],
  inject: ['refList'],
  components: {
    FormItemWrapper,
    ...FieldComponents
  },
  props: {
    widget: Object,
    parentWidget: Object,
    parentList: Array,
    indexOfParentList: Number,
    subFormRowIndex: { /* 子表单组件行索引，从0开始计数 */
      type: Number,
      default: -1
    }
  },
  data() {
    return {
      rules: [],
    }
  },
  computed: {
    customClass() {
      return this.widget.options.customClass || '';
    }
  },
  created() {
    this.initRefList();
  },
  methods: {}
};
</script>

<style lang="scss" scoped>

</style>
