import { defineComponent, PropType, ref } from 'vue';
import './index.less';
export default defineComponent({
  props: {
    options: {
      type: Array as PropType<any[]>,
      default: [],
    },
    modelValue: String,
  },
  emits: ['update:modelValue'],
  setup(props, { emit }) {
    const curbtn = ref(props.modelValue);
    const CurrentChange = (value: string) => {
      curbtn.value = value;
      emit('update:modelValue', value);
    };
    return () => (
      <div class="custom-radio-group">
        {props.options.map((item: any) => (
          <button
            class={[
              'radio-group-button',
              item.value == curbtn.value ? 'radio-group-active' : '',
            ]}
            onClick={CurrentChange.bind(this, item.value)}
          >
            {item.label}
          </button>
        ))}
      </div>
    );
  },
});
