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

<script>
export default {
  name: "PaasCheckbox",
  inheritAttrs: false,
  props: {
    modelValue: {
      type: Array,
      default: () => []
    },
    options: {
      type: Array,
      default: () => []
    },
    data: {
      type: Array,
      default: () => []
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    see() {
      return this.$store?.forms?.see || false;
    },
    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>