primevue-mirror/components/lib/rating/BaseRating.vue

101 lines
2.1 KiB
Vue
Raw Normal View History

2023-05-24 12:46:10 +00:00
<script>
import BaseComponent from 'primevue/basecomponent';
import { useStyle } from 'primevue/usestyle';
const styles = `
2023-09-26 09:14:27 +00:00
@layer primevue {
2023-09-25 19:11:55 +00:00
.p-rating {
position: relative;
display: flex;
align-items: center;
}
.p-rating-item {
display: inline-flex;
align-items: center;
cursor: pointer;
}
.p-rating.p-readonly .p-rating-item {
cursor: default;
}
2023-05-24 12:46:10 +00:00
}
`;
const classes = {
root: ({ props }) => [
'p-rating',
{
'p-readonly': props.readonly,
'p-disabled': props.disabled
}
],
cancelItem: ({ instance }) => [
'p-rating-item p-rating-cancel-item',
{
'p-focus': instance.focusedOptionIndex === 0 && instance.isFocusVisibleItem
2023-05-24 12:46:10 +00:00
}
],
cancelIcon: 'p-rating-icon p-rating-cancel',
item: ({ instance, props, value }) => [
'p-rating-item',
{
'p-rating-item-active': value <= props.modelValue,
'p-focus': value === instance.focusedOptionIndex && instance.isFocusVisibleItem
2023-05-24 12:46:10 +00:00
}
],
onIcon: 'p-rating-icon',
offIcon: 'p-rating-icon'
};
2023-09-20 18:25:10 +00:00
const { load: loadStyle } = useStyle(styles, { name: 'rating', manual: true });
2023-05-24 12:46:10 +00:00
export default {
name: 'BaseRating',
extends: BaseComponent,
props: {
modelValue: {
type: Number,
default: null
},
disabled: {
type: Boolean,
default: false
},
readonly: {
type: Boolean,
default: false
},
stars: {
type: Number,
default: 5
},
cancel: {
type: Boolean,
default: true
},
onIcon: {
type: String,
default: undefined
},
offIcon: {
type: String,
default: undefined
},
cancelIcon: {
type: String,
default: undefined
}
},
css: {
classes,
loadStyle
2023-05-24 12:46:10 +00:00
},
provide() {
return {
$parentInstance: this
};
2023-05-24 12:46:10 +00:00
}
};
</script>