refactor: #7090 for Rating

pull/7007/merge
Mert Sincan 2025-01-14 11:43:27 +00:00
parent b70064cb0c
commit cfdee00127
1 changed files with 6 additions and 11 deletions

View File

@ -6,7 +6,7 @@
<input <input
type="radio" type="radio"
:value="value" :value="value"
:name="d_name" :name="namex"
:checked="d_value === value" :checked="d_value === value"
:disabled="disabled" :disabled="disabled"
:readonly="readonly" :readonly="readonly"
@ -30,7 +30,6 @@
<script> <script>
import { focus, getFirstFocusableElement } from '@primeuix/utils/dom'; import { focus, getFirstFocusableElement } from '@primeuix/utils/dom';
import { UniqueComponentId } from '@primevue/core/utils';
import BanIcon from '@primevue/icons/ban'; import BanIcon from '@primevue/icons/ban';
import StarIcon from '@primevue/icons/star'; import StarIcon from '@primevue/icons/star';
import StarFillIcon from '@primevue/icons/starfill'; import StarFillIcon from '@primevue/icons/starfill';
@ -43,19 +42,10 @@ export default {
emits: ['change', 'focus', 'blur'], emits: ['change', 'focus', 'blur'],
data() { data() {
return { return {
d_name: this.name,
focusedOptionIndex: -1, focusedOptionIndex: -1,
isFocusVisibleItem: true isFocusVisibleItem: true
}; };
}, },
watch: {
name: function (newValue) {
this.d_name = newValue || UniqueComponentId();
}
},
mounted() {
this.d_name = this.d_name || UniqueComponentId();
},
methods: { methods: {
getPTOptions(key, value) { getPTOptions(key, value) {
return this.ptm(key, { return this.ptm(key, {
@ -104,6 +94,11 @@ export default {
return value === 1 ? this.$primevue.config.locale.aria.star : this.$primevue.config.locale.aria.stars.replace(/{star}/g, value); return value === 1 ? this.$primevue.config.locale.aria.star : this.$primevue.config.locale.aria.stars.replace(/{star}/g, value);
} }
}, },
computed: {
namex() {
return this.name || `${this.$attrSelector}_name`;
}
},
components: { components: {
StarFillIcon, StarFillIcon,
StarIcon, StarIcon,