<script>
export default {
  name: 'SchemaTable',
  props: {
    value: {
      type: Array,
      default() {
        return [];
      },
    },
    schema: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      model: this.value,
    };
  },
  watch: {
    value(val = []) {
      this.model = val;
    },
    model: {
      handler(val) {
        this.$emit('input', val);
      },
      deep: true,
    },
  },
  render(h) {
    const schema = this.schema || {};
    const _props = schema.props || {};
    const _on = schema.on || {};
    return h('z-table', { props: { value: this.model, columns: schema.items, ..._props }, on: _on, scopedSlots: this.$scopedSlots });
  },
};
</script>
