2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-06-05 13:45:43 +00:00
|
|
|
<div :class="cx('radiobuttonWrapper')" @click="onClick" v-bind="getColumnPT('radiobuttonWrapper')">
|
|
|
|
<div :class="cx('hiddenInputWrapper')" :style="sx('hiddenAccessible', isUnstyled)" v-bind="getColumnPT('hiddenInputWrapper')" :data-p-hidden-accessible="true">
|
|
|
|
<input ref="input" type="radio" :checked="checked" :disabled="$attrs.disabled" :name="name" tabindex="0" @focus="onFocus($event)" @blur="onBlur($event)" @keydown.space.prevent="onClick" v-bind="getColumnPT('hiddenInput')" />
|
2022-12-08 11:04:25 +00:00
|
|
|
</div>
|
2023-06-05 13:45:43 +00:00
|
|
|
<div ref="box" :class="cx('radiobutton')" v-bind="getColumnPT('radiobutton')">
|
|
|
|
<div :class="cx('radiobuttonIcon')" v-bind="getColumnPT('radiobuttonIcon')"></div>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-08 14:08:06 +00:00
|
|
|
import BaseComponent from 'primevue/basecomponent';
|
2022-12-08 11:04:25 +00:00
|
|
|
import { DomHandler } from 'primevue/utils';
|
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
export default {
|
|
|
|
name: 'RowRadioButton',
|
2023-05-08 14:08:06 +00:00
|
|
|
extends: BaseComponent,
|
2022-09-06 12:03:37 +00:00
|
|
|
inheritAttrs: false,
|
|
|
|
emits: ['change'],
|
|
|
|
props: {
|
2022-09-14 11:26:01 +00:00
|
|
|
value: null,
|
2022-12-08 11:04:25 +00:00
|
|
|
checked: null,
|
2023-05-09 14:57:31 +00:00
|
|
|
name: null,
|
2023-06-05 13:45:43 +00:00
|
|
|
column: null,
|
|
|
|
index: {
|
|
|
|
type: Number,
|
|
|
|
default: null
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
focused: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2023-06-05 13:45:43 +00:00
|
|
|
getColumnPT(key) {
|
2023-05-09 14:57:31 +00:00
|
|
|
return this.ptmo(this.getColumnProp(), key, {
|
|
|
|
props: this.column.props,
|
|
|
|
parent: {
|
|
|
|
props: this.$props,
|
|
|
|
state: this.$data
|
|
|
|
},
|
2023-05-08 14:08:06 +00:00
|
|
|
context: {
|
2023-06-05 13:45:43 +00:00
|
|
|
index: this.index,
|
2023-05-08 14:08:06 +00:00
|
|
|
checked: this.checked,
|
|
|
|
focused: this.focused,
|
|
|
|
disabled: this.$attrs.disabled
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2023-05-09 14:57:31 +00:00
|
|
|
getColumnProp() {
|
|
|
|
return this.column.props && this.column.props.pt ? this.column.props.pt : undefined; //@todo:
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
onClick(event) {
|
|
|
|
if (!this.disabled) {
|
|
|
|
if (!this.checked) {
|
|
|
|
this.$emit('change', {
|
|
|
|
originalEvent: event,
|
|
|
|
data: this.value
|
|
|
|
});
|
2022-12-08 11:04:25 +00:00
|
|
|
|
|
|
|
DomHandler.focus(this.$refs.input);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onFocus() {
|
|
|
|
this.focused = true;
|
|
|
|
},
|
|
|
|
onBlur() {
|
|
|
|
this.focused = false;
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|