UNPKG

vant-fork

Version:

Lightweight Mobile UI Components built on Vue

95 lines (86 loc) 2.32 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.default = void 0; var _create = _interopRequireDefault(require("../utils/create")); var _default = (0, _create.default)({ render: function render() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('div', { class: _vm.b() }, _vm._l(_vm.list, function (isFull, index) { return _c('svg', { class: _vm.b('item'), style: _vm.style, attrs: { "fill": _vm.disabled ? _vm.disabledColor : isFull ? _vm.color : _vm.voidColor, "viewBox": "0 0 32 32" }, on: { "click": function click($event) { _vm.onSelect(index); } } }, [_c('path', { attrs: { "d": isFull ? 'M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z' : 'M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798zM16 23.547l-6.983 3.671 1.334-7.776-5.65-5.507 7.808-1.134 3.492-7.075 3.492 7.075 7.807 1.134-5.65 5.507 1.334 7.776-6.983-3.671z' } })]); })); }, name: 'rate', props: { readonly: Boolean, disabled: Boolean, size: { type: Number, default: 20 }, color: { type: String, default: '#ffd21e' }, voidColor: { type: String, default: '#c7c7c7' }, disabledColor: { type: String, default: '#bdbdbd' }, count: { type: Number, default: 5 }, value: { type: Number, default: 0 } }, computed: { style: function style() { return { width: this.size + 'px' }; }, list: function list() { var _this = this; return Array.apply(null, { length: this.count }).map(function (value, index) { return index < _this.value; }); } }, methods: { onSelect: function onSelect(index) { if (!this.disabled && !this.readonly) { this.$emit('input', index + 1); this.$emit('change', index + 1); } } } }); exports.default = _default;