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