client: refactor radio.vue to composition api
Some checks failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed

This commit is contained in:
Norm 2022-09-08 02:02:29 -04:00
parent 058d414fff
commit 32512558b0
Signed by: norm
GPG key ID: 7123E30E441E80DE

View file

@ -18,34 +18,25 @@
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
props: {
modelValue: {
required: false,
},
value: {
required: false,
},
disabled: {
type: Boolean,
default: false,
},
},
computed: {
checked(): boolean {
return this.modelValue === this.value;
},
},
methods: {
toggle() {
if (this.disabled) return;
this.$emit('update:modelValue', this.value);
},
},
<script lang="ts" setup>
type ValueType = string | number | symbol;
const props = withDefaults(defineProps<{
modelValue?: ValueType;
value?: ValueType;
disabled?: boolean;
}>(), {
disabled: false,
});
const emit = defineEmits<{
(ev: 'update:modelValue', value?: ValueType): void;
}>();
const checked = $computed(() => props.modelValue === props.value);
function toggle(): void {
if (props.disabled) return;
emit('update:modelValue', props.value);
}
</script>
<style lang="scss" scoped>