Add form support to `RadioButton`
parent
c806a8c749
commit
2a63b3fdce
|
@ -1,30 +1,13 @@
|
|||
<script>
|
||||
import BaseComponent from '@primevue/core/basecomponent';
|
||||
import BaseInput from '@primevue/core/baseinput';
|
||||
import RadioButtonStyle from 'primevue/radiobutton/style';
|
||||
|
||||
export default {
|
||||
name: 'BaseRadioButton',
|
||||
extends: BaseComponent,
|
||||
extends: BaseInput,
|
||||
props: {
|
||||
value: null,
|
||||
modelValue: null,
|
||||
binary: Boolean,
|
||||
name: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
variant: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
invalid: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
readonly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
|
|
|
@ -33,7 +33,7 @@ export default {
|
|||
name: 'RadioButton',
|
||||
extends: BaseRadioButton,
|
||||
inheritAttrs: false,
|
||||
emits: ['update:modelValue', 'change', 'focus', 'blur'],
|
||||
emits: ['change', 'focus', 'blur'],
|
||||
methods: {
|
||||
getPTOptions(key) {
|
||||
const _ptm = key === 'root' ? this.ptmi : this.ptm;
|
||||
|
@ -49,7 +49,7 @@ export default {
|
|||
if (!this.disabled && !this.readonly) {
|
||||
const newModelValue = this.binary ? !this.checked : this.value;
|
||||
|
||||
this.$emit('update:modelValue', newModelValue);
|
||||
this.updateValue(newModelValue, event);
|
||||
this.$emit('change', event);
|
||||
}
|
||||
},
|
||||
|
@ -58,11 +58,12 @@ export default {
|
|||
},
|
||||
onBlur(event) {
|
||||
this.$emit('blur', event);
|
||||
this.formField.onBlur?.(event);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
checked() {
|
||||
return this.modelValue != null && (this.binary ? !!this.modelValue : equals(this.modelValue, this.value));
|
||||
return this.d_value != null && (this.binary ? !!this.d_value : equals(this.d_value, this.value));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -125,8 +125,8 @@ const classes = {
|
|||
{
|
||||
'p-radiobutton-checked': instance.checked,
|
||||
'p-disabled': props.disabled,
|
||||
'p-invalid': props.invalid,
|
||||
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled'
|
||||
'p-invalid': instance.$invalid,
|
||||
'p-variant-filled': instance.$variant === 'filled'
|
||||
}
|
||||
],
|
||||
box: 'p-radiobutton-box',
|
||||
|
|
Loading…
Reference in New Issue