mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Refactor #5437 - For Rating
This commit is contained in:
parent
8efb1a5eea
commit
aedd31e8e6
6 changed files with 12 additions and 66 deletions
|
@ -24,7 +24,7 @@ export default {
|
|||
},
|
||||
cancel: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: false
|
||||
},
|
||||
onIcon: {
|
||||
type: String,
|
||||
|
|
3
components/lib/rating/Rating.d.ts
vendored
3
components/lib/rating/Rating.d.ts
vendored
|
@ -181,7 +181,8 @@ export interface RatingProps {
|
|||
stars?: number | undefined;
|
||||
/**
|
||||
* When specified a cancel icon is displayed to allow clearing the value.
|
||||
* @defaultValue true
|
||||
* @deprecated since v4.0.0-beta.1
|
||||
* @defaultValue false
|
||||
*/
|
||||
cancel?: boolean | undefined;
|
||||
/**
|
||||
|
|
|
@ -106,8 +106,13 @@ export default {
|
|||
this.isFocusVisibleItem = true;
|
||||
},
|
||||
onOptionSelect(event, value) {
|
||||
this.focusedOptionIndex = value;
|
||||
this.updateModel(event, value || null);
|
||||
if (this.focusedOptionIndex === value || this.modelValue === value) {
|
||||
this.focusedOptionIndex = -1;
|
||||
this.updateModel(event, null);
|
||||
} else {
|
||||
this.focusedOptionIndex = value;
|
||||
this.updateModel(event, value || null);
|
||||
}
|
||||
},
|
||||
updateModel(event, value) {
|
||||
this.$emit('update:modelValue', value);
|
||||
|
|
|
@ -11,7 +11,7 @@ const classes = {
|
|||
cancelItem: ({ instance }) => [
|
||||
'p-rating-item p-rating-cancel-item',
|
||||
{
|
||||
'p-focus': instance.focusedOptionIndex === 0 && instance.isFocusVisibleItem
|
||||
'p-focus-visible': instance.focusedOptionIndex === 0 && instance.isFocusVisibleItem
|
||||
}
|
||||
],
|
||||
cancelIcon: 'p-rating-icon p-rating-cancel',
|
||||
|
@ -19,7 +19,7 @@ const classes = {
|
|||
'p-rating-item',
|
||||
{
|
||||
'p-rating-item-active': value <= props.modelValue,
|
||||
'p-focus': value === instance.focusedOptionIndex && instance.isFocusVisibleItem
|
||||
'p-focus-visible': value === instance.focusedOptionIndex && instance.isFocusVisibleItem
|
||||
}
|
||||
],
|
||||
onIcon: 'p-rating-icon',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue