2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-05-29 09:19:55 +00:00
|
|
|
<div :class="cx('root')" @click="onClick($event)" v-bind="ptm('root')" data-pc-name="radiobutton">
|
2023-07-03 22:20:35 +00:00
|
|
|
<div class="p-hidden-accessible" v-bind="ptm('hiddenInputWrapper')" :data-p-hidden-accessible="true">
|
2023-05-24 12:29:06 +00:00
|
|
|
<input ref="input" :id="inputId" type="radio" :name="name" :checked="checked" :disabled="disabled" :value="value" :aria-labelledby="ariaLabelledby" :aria-label="ariaLabel" @focus="onFocus" @blur="onBlur" v-bind="ptm('hiddenInput')" />
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
2023-05-24 12:29:06 +00:00
|
|
|
<div ref="box" :class="[cx('input'), inputClass]" :style="inputStyle" v-bind="{ ...inputProps, ...ptm('input') }" :data-p-highlight="checked" :data-p-disabled="disabled" :data-p-focused="focused">
|
|
|
|
<div :class="cx('icon')" v-bind="ptm('icon')"></div>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-09-14 11:26:01 +00:00
|
|
|
import { ObjectUtils } from 'primevue/utils';
|
2023-05-24 12:29:06 +00:00
|
|
|
import BaseRadioButton from './BaseRadioButton.vue';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'RadioButton',
|
2023-05-24 12:29:06 +00:00
|
|
|
extends: BaseRadioButton,
|
2022-09-06 12:03:37 +00:00
|
|
|
emits: ['click', 'update:modelValue', 'change', 'focus', 'blur'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
focused: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick(event) {
|
|
|
|
if (!this.disabled) {
|
|
|
|
this.$emit('click', event);
|
|
|
|
this.$emit('update:modelValue', this.value);
|
|
|
|
this.$refs.input.focus();
|
|
|
|
|
|
|
|
if (!this.checked) {
|
|
|
|
this.$emit('change', event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onFocus(event) {
|
|
|
|
this.focused = true;
|
|
|
|
this.$emit('focus', event);
|
|
|
|
},
|
|
|
|
onBlur(event) {
|
|
|
|
this.focused = false;
|
|
|
|
this.$emit('blur', event);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
checked() {
|
|
|
|
return this.modelValue != null && ObjectUtils.equals(this.modelValue, this.value);
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|