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AAA;;AACP,YAAM,WAAW,0BAAY,OAAO,KAAK,MAAZ,CAAZ,EAAiC,GAAjC,CAAqC;AAAA,mBAAK,OAAK,OAAL,CAAa,CAAb,CAAL;AAAA,SAArC,CAAjB;AAEA,eAAO,EAAE,KAAF,EAAS;AACd,yBAAa,UADC;AAEd,mBAAO;AACL,sCAAsB,KAAK,QADtB;AAEL,mCAAmB,KAAK;AAFnB;AAFO,SAAT,EAMJ,QANI,CAAP;AAOD;AA7LM,CANM,C;AAzBf","sourcesContent":["// Styles\nimport '../../stylus/components/_rating.styl'\n\n// Components\nimport VIcon from '../VIcon'\n\n// Mixins\nimport Colorable from '../../mixins/colorable'\nimport Delayable from '../../mixins/delayable'\nimport Sizeable from '../../mixins/sizeable'\nimport Rippleable from '../../mixins/rippleable'\nimport Themeable from '../../mixins/themeable'\n\n// Utilities\nimport { createRange } from '../../util/helpers'\nimport mixins from '../../util/mixins'\n\n// Types\nimport { VNode, VNodeDirective, VNodeChildren } from 'vue'\n\ntype ItemSlotProps = {\n index: number\n value: number\n isFilled: boolean\n isHalfFilled?: boolean | undefined\n isHovered: boolean\n isHalfHovered?: boolean | undefined\n click: Function\n}\n\n/* @vue/component */\nexport default mixins(\n Colorable,\n Delayable,\n Rippleable,\n Sizeable,\n Themeable\n).extend({\n name: 'v-rating',\n\n props: {\n backgroundColor: {\n type: String,\n default: 'accent'\n },\n color: {\n type: String,\n default: 'primary'\n },\n dense: Boolean,\n emptyIcon: {\n type: String,\n default: '$vuetify.icons.ratingEmpty'\n },\n fullIcon: {\n type: String,\n default: '$vuetify.icons.ratingFull'\n },\n halfIcon: {\n type: String,\n default: '$vuetify.icons.ratingHalf'\n },\n halfIncrements: Boolean,\n length: {\n type: [Number, String],\n default: 5\n },\n clearable: Boolean,\n readonly: Boolean,\n hover: Boolean,\n value: {\n type: Number,\n default: 0\n }\n },\n\n data () {\n return {\n hoverIndex: -1,\n internalValue: this.value\n }\n },\n\n computed: {\n directives (): VNodeDirective[] {\n if (this.readonly || !this.ripple) return []\n\n return [{\n name: 'ripple',\n value: { circle: true }\n } as VNodeDirective]\n },\n iconProps (): object {\n const {\n dark,\n medium,\n large,\n light,\n small,\n size,\n xLarge\n } = this.$props\n\n return {\n dark,\n medium,\n large,\n light,\n size,\n small,\n xLarge\n }\n },\n isHovering (): boolean {\n return this.hover && this.hoverIndex >= 0\n }\n },\n\n watch: {\n internalValue (val) {\n val !== this.value && this.$emit('input', val)\n },\n value (val) {\n this.internalValue = val\n }\n },\n\n methods: {\n createClickFn (i: number): Function {\n return (e: MouseEvent) => {\n if (this.readonly) return\n\n const newValue = this.genHoverIndex(e, i)\n if (this.clearable && this.internalValue === newValue) {\n this.internalValue = 0\n } else {\n this.internalValue = newValue\n }\n }\n },\n createProps (i: number): ItemSlotProps {\n const props: ItemSlotProps = {\n index: i,\n value: this.internalValue,\n click: this.createClickFn(i),\n isFilled: Math.floor(this.internalValue) > i,\n isHovered: Math.floor(this.hoverIndex) > i\n }\n\n if (this.halfIncrements) {\n props.isHalfHovered = !props.isHovered && (this.hoverIndex - i) % 1 > 0\n props.isHalfFilled = !props.isFilled && (this.internalValue - i) % 1 > 0\n }\n\n return props\n },\n genHoverIndex (e: MouseEvent, i: number) {\n return i + (this.isHalfEvent(e) ? 0.5 : 1)\n },\n getIconName (props: ItemSlotProps): string {\n const isFull = this.isHovering ? props.isHovered : props.isFilled\n const isHalf = this.isHovering ? props.isHalfHovered : props.isHalfFilled\n\n return isFull ? this.fullIcon : isHalf ? this.halfIcon : this.emptyIcon\n },\n getColor (props: ItemSlotProps): string {\n if (this.isHovering) {\n if (props.isHovered || props.isHalfHovered) return this.color\n } else {\n if (props.isFilled || props.isHalfFilled) return this.color\n }\n\n return this.backgroundColor\n },\n isHalfEvent (e: MouseEvent): boolean {\n if (this.halfIncrements) {\n const rect = e.target && (e.target as HTMLElement).getBoundingClientRect()\n if (rect && (e.pageX - rect.left) < rect.width / 2) return true\n }\n\n return false\n },\n onMouseEnter (e: MouseEvent, i: number): void {\n this.runDelay('open', () => {\n this.hoverIndex = this.genHoverIndex(e, i)\n })\n },\n onMouseLeave (): void {\n this.runDelay('close', () => (this.hoverIndex = -1))\n },\n genItem (i: number): VNode | VNodeChildren | string {\n const props = this.createProps(i)\n\n if (this.$scopedSlots.item) return this.$scopedSlots.item(props)\n\n const listeners: Record<string, Function> = {\n click: props.click\n }\n\n if (this.hover) {\n listeners.mouseenter = (e: MouseEvent) => this.onMouseEnter(e, i)\n listeners.mouseleave = this.onMouseLeave\n\n if (this.halfIncrements) {\n listeners.mousemove = (e: MouseEvent) => this.onMouseEnter(e, i)\n }\n }\n\n return this.$createElement(VIcon, this.setTextColor(this.getColor(props), {\n directives: this.directives,\n props: this.iconProps,\n on: listeners\n }), [this.getIconName(props)])\n }\n },\n\n render (h): VNode {\n const children = createRange(Number(this.length)).map(i => this.genItem(i))\n\n return h('div', {\n staticClass: 'v-rating',\n class: {\n 'v-rating--readonly': this.readonly,\n 'v-rating--dense': this.dense\n }\n }, children)\n }\n})\n"],"sourceRoot":""}
|