<template>
<uni-shadow-root class="vant-rate-index"><view class="van-rate custom-class" @touchmove="onTouchMove">
  <view v-for="(item,index) in (count)" :key="item.index" class="van-rate__item" :style="'font-size: '+(size)+'px;'">
    <van-icon :name="index + 1 <= innerValue ? icon : voidIcon" class="van-rate__icon" custom-class="icon-class" :data-score="index" :color="disabled ? disabledColor : index + 1 <= innerValue ? color : voidColor" @click="onSelect"></van-icon>

    <van-icon v-if="allowHalf" :name="index + 0.5 <= innerValue ? icon : voidIcon" :class="utils.bem('rate__icon', ['half'])" custom-class="icon-class" :data-score="index - 0.5" :color="disabled ? disabledColor : index + 0.5 <= innerValue ? color : voidColor" @click="onSelect"></van-icon>
  </view>
</view></uni-shadow-root>
</template>
<wxs src="../wxs/utils.wxs" module="utils"></wxs>
<script>
import VanIcon from '../icon/index.vue'
global['__wxVueOptions'] = {components:{'van-icon': VanIcon}}

global['__wxRoute'] = 'vant/rate/index'
"use strict";

var __assign = undefined && undefined.__assign || function () {
    __assign = Object.assign || function (t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) {
                if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
            }
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require('./../common/component.js');
component_1.VantComponent({
    field: true,
    classes: ['icon-class'],
    props: {
        value: Number,
        readonly: Boolean,
        disabled: Boolean,
        allowHalf: Boolean,
        size: {
            type: Number,
            value: 20
        },
        icon: {
            type: String,
            value: 'star'
        },
        voidIcon: {
            type: String,
            value: 'star-o'
        },
        color: {
            type: String,
            value: '#ffd21e'
        },
        voidColor: {
            type: String,
            value: '#c7c7c7'
        },
        disabledColor: {
            type: String,
            value: '#bdbdbd'
        },
        count: {
            type: Number,
            value: 5
        }
    },
    data: {
        innerValue: 0
    },
    watch: {
        value: function value(_value) {
            if (_value !== this.data.innerValue) {
                this.set({ innerValue: _value });
            }
        }
    },
    methods: {
        onSelect: function onSelect(event) {
            var data = this.data;
            var score = event.currentTarget.dataset.score;
            if (!data.disabled && !data.readonly) {
                this.set({ innerValue: score + 1 });
                this.$emit('input', score + 1);
                this.$emit('change', score + 1);
            }
        },
        onTouchMove: function onTouchMove(event) {
            var _this = this;
            var _a = event.touches[0],
                clientX = _a.clientX,
                clientY = _a.clientY;
            this.getRect('.van-rate__icon', true).then(function (list) {
                var target = list.sort(function (item) {
                    return item.right - item.left;
                }).find(function (item) {
                    return clientX >= item.left && clientX <= item.right && clientY >= item.top && clientY <= item.bottom;
                });
                if (target != null) {
                    _this.onSelect(__assign({}, event, { currentTarget: target }));
                }
            });
        }
    }
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbIl9fYXNzaWduIiwiT2JqZWN0IiwiaSIsIm4iLCJhcmd1bWVudHMiLCJzIiwidCIsInZhbHVlIiwiY29tcG9uZW50XzEiLCJyZXF1aXJlIiwiZmllbGQiLCJjbGFzc2VzIiwicHJvcHMiLCJyZWFkb25seSIsImRpc2FibGVkIiwiYWxsb3dIYWxmIiwic2l6ZSIsInR5cGUiLCJpY29uIiwidm9pZEljb24iLCJjb2xvciIsInZvaWRDb2xvciIsImRpc2FibGVkQ29sb3IiLCJjb3VudCIsImRhdGEiLCJpbm5lclZhbHVlIiwid2F0Y2giLCJtZXRob2RzIiwib25TZWxlY3QiLCJzY29yZSIsImV2ZW50Iiwib25Ub3VjaE1vdmUiLCJfdGhpcyIsIl9hIiwiY2xpZW50WCIsImNsaWVudFkiLCJ0YXJnZXQiLCJpdGVtIiwiY3VycmVudFRhcmdldCJdLCJtYXBwaW5ncyI6Ijs7QUFDQSxJQUFJQSxXQUFZLGFBQVEsVUFBVCxRQUFDLElBQTBCLFlBQVk7QUFDbERBLGVBQVdDLE9BQUFBLE1BQUFBLElBQWlCLFVBQUEsQ0FBQSxFQUFZO0FBQ3BDLGFBQUssSUFBQ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BuID0gYXJndW1lbnRzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgcyA9IGFyZ3VtZW50c1tpXTtcbiAgICAgICAgICAgIGZvciAodmFyIHAgaW4gcykgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChzLCBwKSlcbiAgICAgICAgICAgICAgICB0W3BdID0gc1twXTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdDtcbiAgICB9O1xuICAgIHJldHVybiBfX2Fzc2lnbi5hcHBseSh0aGlzLCBhcmd1bWVudHMpO1xufTtcbk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCBcIl9fZXNNb2R1bGVcIiwgeyB2YWx1ZTogdHJ1ZSB9KTtcbnZhciBjb21wb25lbnRfMSA9IHJlcXVpcmUoXCIuLi9jb21tb24vY29tcG9uZW50XCIpO1xuY29tcG9uZW50XzEuVmFudENvbXBvbmVudCh7XG4gICAgZmllbGQ6IHRydWUsXG4gICAgY2xhc3NlczogWydpY29uLWNsYXNzJ10sXG4gICAgcHJvcHM6IHtcbiAgICAgICAgdmFsdWU6IE51bWJlcixcbiAgICAgICAgcmVhZG9ubHk6IEJvb2xlYW4sXG4gICAgICAgIGRpc2FibGVkOiBCb29sZWFuLFxuICAgICAgICBhbGxvd0hhbGY6IEJvb2xlYW4sXG4gICAgICAgIHNpemU6IHtcbiAgICAgICAgICAgIHR5cGU6IE51bWJlcixcbiAgICAgICAgICAgIHZhbHVlOiAyMFxuICAgICAgICB9LFxuICAgICAgICBpY29uOiB7XG4gICAgICAgICAgICB0eXBlOiBTdHJpbmcsXG4gICAgICAgICAgICB2YWx1ZTogJ3N0YXInXG4gICAgICAgIH0sXG4gICAgICAgIHZvaWRJY29uOiB7XG4gICAgICAgICAgICB0eXBlOiBTdHJpbmcsXG4gICAgICAgICAgICB2YWx1ZTogJ3N0YXItbydcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IHtcbiAgICAgICAgICAgIHR5cGU6IFN0cmluZyxcbiAgICAgICAgICAgIHZhbHVlOiAnI2ZmZDIxZSdcbiAgICAgICAgfSxcbiAgICAgICAgdm9pZENvbG9yOiB7XG4gICAgICAgICAgICB0eXBlOiBTdHJpbmcsXG4gICAgICAgICAgICB2YWx1ZTogJyNjN2M3YzcnXG4gICAgICAgIH0sXG4gICAgICAgIGRpc2FibGVkQ29sb3I6IHtcbiAgICAgICAgICAgIHR5cGU6IFN0cmluZyxcbiAgICAgICAgICAgIHZhbHVlOiAnI2JkYmRiZCdcbiAgICAgICAgfSxcbiAgICAgICAgY291bnQ6IHtcbiAgICAgICAgICAgIHR5cGU6IE51bWJlcixcbiAgICAgICAgICAgIHZhbHVlOiA1XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGRhdGE6IHtcbiAgICAgICAgaW5uZXJWYWx1ZTogMFxuICAgIH0sXG4gICAgd2F0Y2g6IHtcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgaWYgKHZhbHVlICE9PSB0aGlzLmRhdGEuaW5uZXJWYWx1ZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuc2V0KHsgaW5uZXJWYWx1ZTogdmFsdWUgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIG1ldGhvZHM6IHtcbiAgICAgICAgb25TZWxlY3Q6IGZ1bmN0aW9uIChldmVudCkge1xuICAgICAgICAgICAgdmFyIGRhdGEgPSB0aGlzLmRhdGE7XG4gICAgICAgICAgICB2YXIgc2NvcmUgPSBldmVudC5jdXJyZW50VGFyZ2V0LmRhdGFzZXQuc2NvcmU7XG4gICAgICAgICAgICBpZiAoIWRhdGEuZGlzYWJsZWQgJiYgIWRhdGEucmVhZG9ubHkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldCh7IGlubmVyVmFsdWU6IHNjb3JlICsgMSB9KTtcbiAgICAgICAgICAgICAgICB0aGlzLiRlbWl0KCdpbnB1dCcsIHNjb3JlICsgMSk7XG4gICAgICAgICAgICAgICAgdGhpcy4kZW1pdCgnY2hhbmdlJywgc2NvcmUgKyAxKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgb25Ub3VjaE1vdmU6IGZ1bmN0aW9uIChldmVudCkge1xuICAgICAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgICAgIHZhciBfYSA9IGV2ZW50LnRvdWNoZXNbMF0sIGNsaWVudFggPSBfYS5jbGllbnRYLCBjbGllbnRZID0gX2EuY2xpZW50WTtcbiAgICAgICAgICAgIHRoaXMuZ2V0UmVjdCgnLnZhbi1yYXRlX19pY29uJywgdHJ1ZSkudGhlbihmdW5jdGlvbiAobGlzdCkge1xuICAgICAgICAgICAgICAgIHZhciB0YXJnZXQgPSBsaXN0XG4gICAgICAgICAgICAgICAgICAgIC5zb3J0KGZ1bmN0aW9uIChpdGVtKSB7IHJldHVybiBpdGVtLnJpZ2h0IC0gaXRlbS5sZWZ0OyB9KVxuICAgICAgICAgICAgICAgICAgICAuZmluZChmdW5jdGlvbiAoaXRlbSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xpZW50WCA+PSBpdGVtLmxlZnQgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudFggPD0gaXRlbS5yaWdodCAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50WSA+PSBpdGVtLnRvcCAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50WSA8PSBpdGVtLmJvdHRvbTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0ICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMub25TZWxlY3QoX19hc3NpZ24oe30sIGV2ZW50LCB7IGN1cnJlbnRUYXJnZXQ6IHRhcmdldCB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG59KTtcbiJdLCJmaWxlIjoiaW5kZXguanMifQ==
export default global['__wxComponents']['vant/rate/index']
</script>
<style platform="mp-weixin">
@import '../common/index.css';.van-rate{-webkit-user-select:none;user-select:none}.van-rate__item{position:relative;display:inline-block;padding:0 2px}.van-rate__icon{display:block;height:1em}.van-rate__icon--half{position:absolute;top:0;left:2px;width:.5em;overflow:hidden}
</style>