<template>
  <a-col :span="colSpan ? colSpan : defaultColSpan">
    <a-form-item :label="label" :name="name" :icon="icon"
      :label-col="{ style: { width: !!textWidth ? textWidth : labelWidth } }" :wrapper-col="{ style: { flex: 1 } }">
      <paas-radio :model-value="modelValue" @update:model-value="updateValue" :disabled="disabled"
        :options="options" :data="data" :style="style" v-bind="$attrs" />
    </a-form-item>
  </a-col>
</template>

<script>
export default {
  name: "FormRadio",
  inheritAttrs: false,
  inject: {
    labelWidth: {
      from: 'labelWidth',
      default: '90px'
    },
    defaultColSpan: {
      from: 'defaultColSpan',
      default: 12
    }
  },
  props: {
    label: {
      type: String,
      default: ""
    },
    name: {
      type: String,
      default: ""
    },
    modelValue: {
      type: [String, Number, Boolean],
      default: ""
    },
    options: {
      type: Array,
      default: () => []
    },
    data: {
      type: Array,
      default: () => []
    },
    textWidth: {
      type: String,
      default: ""
    },
    colSpan: { type: Number },
    icon: {
      type: String,
      default: ""
    },
    disabled: {
      type: Boolean,
      default: false
    },
    style: { type: [String, Object], default: "width: 100%;" }
  },
  emits: ["update:modelValue"],
  methods: {
    updateValue(val) {
      this.$emit("update:modelValue", val);
    }
  }
};
</script>
