<template>
  <a-radio-group v-model:value="innerValue" :options="processedOptions" :disabled="see || disabled" :style="style" v-bind="$attrs" />
</template>

<script>
export default {
  name: "PaasRadio",
  inheritAttrs: false,
  computed: {
    see() {
      return this.$store?.forms?.see || false;
    }
  },
  props: {
    modelValue: {
      type: [String, Number, Boolean],
      default: ""
    },
    options: {
      type: Array,
      default: () => []
    },
    data: {
      type: Array,
      default: () => []
    },
    disabled: {
      type: Boolean,
      default: false
    },
    style: { type: [String, Object], default: "width: 100%;" }
  },
  computed: {
    processedOptions() {
      const sourceOptions = this.options.length > 0 ? this.options : this.data;
      return sourceOptions.map(item => ({
        label: item.label,
        value: item.value
      }));
    },
    innerValue: {
      get() {
        return this.modelValue;
      },
      set(val) {
        this.$emit("update:modelValue", val);
      },
    },
  },
};
</script>