AmRadioGroup.vue
84 lines
| 1 | <template> |
| 2 | <div class="am-radio-group-wrapper"> |
| 3 | <el-radio-group |
| 4 | ref="amRadioGroup" |
| 5 | v-model="model" |
| 6 | class="am-radio-group" |
| 7 | v-bind="$props" |
| 8 | :text-color="textColor" |
| 9 | :fill="fill" |
| 10 | @change="(eventLabel) => $emit('change', eventLabel)" |
| 11 | > |
| 12 | <slot /> |
| 13 | </el-radio-group> |
| 14 | </div> |
| 15 | </template> |
| 16 | |
| 17 | <script setup> |
| 18 | import { computed, ref, toRefs } from 'vue' |
| 19 | |
| 20 | const props = defineProps({ |
| 21 | modelValue: { |
| 22 | type: [String, Number, Boolean], |
| 23 | }, |
| 24 | size: { |
| 25 | type: String, |
| 26 | default: 'default', |
| 27 | validator(value) { |
| 28 | return ['default', 'medium', 'small'].includes(value) |
| 29 | }, |
| 30 | }, |
| 31 | disabled: { |
| 32 | type: Boolean, |
| 33 | default: false, |
| 34 | }, |
| 35 | textColor: { |
| 36 | type: String, |
| 37 | }, |
| 38 | fill: { |
| 39 | type: String, |
| 40 | }, |
| 41 | validateEvent: { |
| 42 | type: Boolean, |
| 43 | default: true, |
| 44 | }, |
| 45 | ariaLabel: { |
| 46 | type: String, |
| 47 | }, |
| 48 | id: { |
| 49 | type: String, |
| 50 | }, |
| 51 | }) |
| 52 | |
| 53 | /** |
| 54 | * Component Emits |
| 55 | **/ |
| 56 | const emits = defineEmits(['change', 'update:modelValue']) |
| 57 | |
| 58 | /** |
| 59 | * Component model |
| 60 | */ |
| 61 | let { modelValue } = toRefs(props) |
| 62 | |
| 63 | let model = computed({ |
| 64 | get: () => modelValue.value, |
| 65 | set: (val) => { |
| 66 | emits('update:modelValue', val) |
| 67 | }, |
| 68 | }) |
| 69 | |
| 70 | /** |
| 71 | * Component reference |
| 72 | */ |
| 73 | const amRadioGroup = ref() |
| 74 | </script> |
| 75 | |
| 76 | <style lang="scss"> |
| 77 | .am-radio-group-wrapper { |
| 78 | .el-radio-group { |
| 79 | display: flex; |
| 80 | flex-direction: column; |
| 81 | } |
| 82 | } |
| 83 | </style> |
| 84 |