669 lines
18 KiB
JavaScript
669 lines
18 KiB
JavaScript
module.exports =
|
|
/******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/
|
|
/******/ // Check if module is in cache
|
|
/******/ if(installedModules[moduleId]) {
|
|
/******/ return installedModules[moduleId].exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = installedModules[moduleId] = {
|
|
/******/ i: moduleId,
|
|
/******/ l: false,
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __webpack_require__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __webpack_require__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/
|
|
/******/ // create a fake namespace object
|
|
/******/ // mode & 1: value is a module id, require it
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
/******/ // mode & 4: return value when already ns object
|
|
/******/ // mode & 8|1: behave like require
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
/******/ if(mode & 8) return value;
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
/******/ var ns = Object.create(null);
|
|
/******/ __webpack_require__.r(ns);
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
/******/ return ns;
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __webpack_require__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __webpack_require__.p = "/dist/";
|
|
/******/
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __webpack_require__(__webpack_require__.s = 98);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ({
|
|
|
|
/***/ 0:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
|
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
|
|
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
|
|
// This module is a runtime utility for cleaner component module output and will
|
|
// be included in the final webpack user bundle.
|
|
|
|
function normalizeComponent (
|
|
scriptExports,
|
|
render,
|
|
staticRenderFns,
|
|
functionalTemplate,
|
|
injectStyles,
|
|
scopeId,
|
|
moduleIdentifier, /* server only */
|
|
shadowMode /* vue-cli only */
|
|
) {
|
|
// Vue.extend constructor export interop
|
|
var options = typeof scriptExports === 'function'
|
|
? scriptExports.options
|
|
: scriptExports
|
|
|
|
// render functions
|
|
if (render) {
|
|
options.render = render
|
|
options.staticRenderFns = staticRenderFns
|
|
options._compiled = true
|
|
}
|
|
|
|
// functional template
|
|
if (functionalTemplate) {
|
|
options.functional = true
|
|
}
|
|
|
|
// scopedId
|
|
if (scopeId) {
|
|
options._scopeId = 'data-v-' + scopeId
|
|
}
|
|
|
|
var hook
|
|
if (moduleIdentifier) { // server build
|
|
hook = function (context) {
|
|
// 2.3 injection
|
|
context =
|
|
context || // cached call
|
|
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
|
|
// 2.2 with runInNewContext: true
|
|
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
context = __VUE_SSR_CONTEXT__
|
|
}
|
|
// inject component styles
|
|
if (injectStyles) {
|
|
injectStyles.call(this, context)
|
|
}
|
|
// register component module identifier for async chunk inferrence
|
|
if (context && context._registeredComponents) {
|
|
context._registeredComponents.add(moduleIdentifier)
|
|
}
|
|
}
|
|
// used by ssr in case component is cached and beforeCreate
|
|
// never gets called
|
|
options._ssrRegister = hook
|
|
} else if (injectStyles) {
|
|
hook = shadowMode
|
|
? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
|
|
: injectStyles
|
|
}
|
|
|
|
if (hook) {
|
|
if (options.functional) {
|
|
// for template-only hot-reload because in that case the render fn doesn't
|
|
// go through the normalizer
|
|
options._injectStyles = hook
|
|
// register for functioal component in vue file
|
|
var originalRender = options.render
|
|
options.render = function renderWithStyleInjection (h, context) {
|
|
hook.call(context)
|
|
return originalRender(h, context)
|
|
}
|
|
} else {
|
|
// inject component registration as beforeCreate hook
|
|
var existing = options.beforeCreate
|
|
options.beforeCreate = existing
|
|
? [].concat(existing, hook)
|
|
: [hook]
|
|
}
|
|
}
|
|
|
|
return {
|
|
exports: scriptExports,
|
|
options: options
|
|
}
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 11:
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = require("element-ui/lib/mixins/migrating");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2:
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = require("element-ui/lib/utils/dom");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 20:
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = require("element-ui/lib/utils/types");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 98:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/rate/src/main.vue?vue&type=template&id=ada57782&
|
|
var render = function() {
|
|
var _vm = this
|
|
var _h = _vm.$createElement
|
|
var _c = _vm._self._c || _h
|
|
return _c(
|
|
"div",
|
|
{
|
|
staticClass: "el-rate",
|
|
attrs: {
|
|
role: "slider",
|
|
"aria-valuenow": _vm.currentValue,
|
|
"aria-valuetext": _vm.text,
|
|
"aria-valuemin": "0",
|
|
"aria-valuemax": _vm.max,
|
|
tabindex: "0"
|
|
},
|
|
on: { keydown: _vm.handleKey }
|
|
},
|
|
[
|
|
_vm._l(_vm.max, function(item, key) {
|
|
return _c(
|
|
"span",
|
|
{
|
|
key: key,
|
|
staticClass: "el-rate__item",
|
|
style: { cursor: _vm.rateDisabled ? "auto" : "pointer" },
|
|
on: {
|
|
mousemove: function($event) {
|
|
_vm.setCurrentValue(item, $event)
|
|
},
|
|
mouseleave: _vm.resetCurrentValue,
|
|
click: function($event) {
|
|
_vm.selectValue(item)
|
|
}
|
|
}
|
|
},
|
|
[
|
|
_c(
|
|
"i",
|
|
{
|
|
staticClass: "el-rate__icon",
|
|
class: [
|
|
_vm.classes[item - 1],
|
|
{ hover: _vm.hoverIndex === item }
|
|
],
|
|
style: _vm.getIconStyle(item)
|
|
},
|
|
[
|
|
_vm.showDecimalIcon(item)
|
|
? _c("i", {
|
|
staticClass: "el-rate__decimal",
|
|
class: _vm.decimalIconClass,
|
|
style: _vm.decimalStyle
|
|
})
|
|
: _vm._e()
|
|
]
|
|
)
|
|
]
|
|
)
|
|
}),
|
|
_vm.showText || _vm.showScore
|
|
? _c(
|
|
"span",
|
|
{ staticClass: "el-rate__text", style: { color: _vm.textColor } },
|
|
[_vm._v(_vm._s(_vm.text))]
|
|
)
|
|
: _vm._e()
|
|
],
|
|
2
|
|
)
|
|
}
|
|
var staticRenderFns = []
|
|
render._withStripped = true
|
|
|
|
|
|
// CONCATENATED MODULE: ./packages/rate/src/main.vue?vue&type=template&id=ada57782&
|
|
|
|
// EXTERNAL MODULE: external "element-ui/lib/utils/dom"
|
|
var dom_ = __webpack_require__(2);
|
|
|
|
// EXTERNAL MODULE: external "element-ui/lib/utils/types"
|
|
var types_ = __webpack_require__(20);
|
|
|
|
// EXTERNAL MODULE: external "element-ui/lib/mixins/migrating"
|
|
var migrating_ = __webpack_require__(11);
|
|
var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_);
|
|
|
|
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/rate/src/main.vue?vue&type=script&lang=js&
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var mainvue_type_script_lang_js_ = ({
|
|
name: 'ElRate',
|
|
|
|
mixins: [migrating_default.a],
|
|
|
|
inject: {
|
|
elForm: {
|
|
default: ''
|
|
}
|
|
},
|
|
|
|
data: function data() {
|
|
return {
|
|
pointerAtLeftHalf: true,
|
|
currentValue: this.value,
|
|
hoverIndex: -1
|
|
};
|
|
},
|
|
|
|
|
|
props: {
|
|
value: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
lowThreshold: {
|
|
type: Number,
|
|
default: 2
|
|
},
|
|
highThreshold: {
|
|
type: Number,
|
|
default: 4
|
|
},
|
|
max: {
|
|
type: Number,
|
|
default: 5
|
|
},
|
|
colors: {
|
|
type: [Array, Object],
|
|
default: function _default() {
|
|
return ['#F7BA2A', '#F7BA2A', '#F7BA2A'];
|
|
}
|
|
},
|
|
voidColor: {
|
|
type: String,
|
|
default: '#C6D1DE'
|
|
},
|
|
disabledVoidColor: {
|
|
type: String,
|
|
default: '#EFF2F7'
|
|
},
|
|
iconClasses: {
|
|
type: [Array, Object],
|
|
default: function _default() {
|
|
return ['el-icon-star-on', 'el-icon-star-on', 'el-icon-star-on'];
|
|
}
|
|
},
|
|
voidIconClass: {
|
|
type: String,
|
|
default: 'el-icon-star-off'
|
|
},
|
|
disabledVoidIconClass: {
|
|
type: String,
|
|
default: 'el-icon-star-on'
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
allowHalf: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
showText: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
showScore: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
textColor: {
|
|
type: String,
|
|
default: '#1f2d3d'
|
|
},
|
|
texts: {
|
|
type: Array,
|
|
default: function _default() {
|
|
return ['极差', '失望', '一般', '满意', '惊喜'];
|
|
}
|
|
},
|
|
scoreTemplate: {
|
|
type: String,
|
|
default: '{value}'
|
|
}
|
|
},
|
|
|
|
computed: {
|
|
text: function text() {
|
|
var result = '';
|
|
if (this.showScore) {
|
|
result = this.scoreTemplate.replace(/\{\s*value\s*\}/, this.rateDisabled ? this.value : this.currentValue);
|
|
} else if (this.showText) {
|
|
result = this.texts[Math.ceil(this.currentValue) - 1];
|
|
}
|
|
return result;
|
|
},
|
|
decimalStyle: function decimalStyle() {
|
|
var width = '';
|
|
if (this.rateDisabled) {
|
|
width = this.valueDecimal + '%';
|
|
} else if (this.allowHalf) {
|
|
width = '50%';
|
|
}
|
|
return {
|
|
color: this.activeColor,
|
|
width: width
|
|
};
|
|
},
|
|
valueDecimal: function valueDecimal() {
|
|
return this.value * 100 - Math.floor(this.value) * 100;
|
|
},
|
|
classMap: function classMap() {
|
|
var _ref;
|
|
|
|
return Array.isArray(this.iconClasses) ? (_ref = {}, _ref[this.lowThreshold] = this.iconClasses[0], _ref[this.highThreshold] = { value: this.iconClasses[1], excluded: true }, _ref[this.max] = this.iconClasses[2], _ref) : this.iconClasses;
|
|
},
|
|
decimalIconClass: function decimalIconClass() {
|
|
return this.getValueFromMap(this.value, this.classMap);
|
|
},
|
|
voidClass: function voidClass() {
|
|
return this.rateDisabled ? this.disabledVoidIconClass : this.voidIconClass;
|
|
},
|
|
activeClass: function activeClass() {
|
|
return this.getValueFromMap(this.currentValue, this.classMap);
|
|
},
|
|
colorMap: function colorMap() {
|
|
var _ref2;
|
|
|
|
return Array.isArray(this.colors) ? (_ref2 = {}, _ref2[this.lowThreshold] = this.colors[0], _ref2[this.highThreshold] = { value: this.colors[1], excluded: true }, _ref2[this.max] = this.colors[2], _ref2) : this.colors;
|
|
},
|
|
activeColor: function activeColor() {
|
|
return this.getValueFromMap(this.currentValue, this.colorMap);
|
|
},
|
|
classes: function classes() {
|
|
var result = [];
|
|
var i = 0;
|
|
var threshold = this.currentValue;
|
|
if (this.allowHalf && this.currentValue !== Math.floor(this.currentValue)) {
|
|
threshold--;
|
|
}
|
|
for (; i < threshold; i++) {
|
|
result.push(this.activeClass);
|
|
}
|
|
for (; i < this.max; i++) {
|
|
result.push(this.voidClass);
|
|
}
|
|
return result;
|
|
},
|
|
rateDisabled: function rateDisabled() {
|
|
return this.disabled || (this.elForm || {}).disabled;
|
|
}
|
|
},
|
|
|
|
watch: {
|
|
value: function value(val) {
|
|
this.currentValue = val;
|
|
this.pointerAtLeftHalf = this.value !== Math.floor(this.value);
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
getMigratingConfig: function getMigratingConfig() {
|
|
return {
|
|
props: {
|
|
'text-template': 'text-template is renamed to score-template.'
|
|
}
|
|
};
|
|
},
|
|
getValueFromMap: function getValueFromMap(value, map) {
|
|
var matchedKeys = Object.keys(map).filter(function (key) {
|
|
var val = map[key];
|
|
var excluded = Object(types_["isObject"])(val) ? val.excluded : false;
|
|
return excluded ? value < key : value <= key;
|
|
}).sort(function (a, b) {
|
|
return a - b;
|
|
});
|
|
var matchedValue = map[matchedKeys[0]];
|
|
return Object(types_["isObject"])(matchedValue) ? matchedValue.value : matchedValue || '';
|
|
},
|
|
showDecimalIcon: function showDecimalIcon(item) {
|
|
var showWhenDisabled = this.rateDisabled && this.valueDecimal > 0 && item - 1 < this.value && item > this.value;
|
|
/* istanbul ignore next */
|
|
var showWhenAllowHalf = this.allowHalf && this.pointerAtLeftHalf && item - 0.5 <= this.currentValue && item > this.currentValue;
|
|
return showWhenDisabled || showWhenAllowHalf;
|
|
},
|
|
getIconStyle: function getIconStyle(item) {
|
|
var voidColor = this.rateDisabled ? this.disabledVoidColor : this.voidColor;
|
|
return {
|
|
color: item <= this.currentValue ? this.activeColor : voidColor
|
|
};
|
|
},
|
|
selectValue: function selectValue(value) {
|
|
if (this.rateDisabled) {
|
|
return;
|
|
}
|
|
if (this.allowHalf && this.pointerAtLeftHalf) {
|
|
this.$emit('input', this.currentValue);
|
|
this.$emit('change', this.currentValue);
|
|
} else {
|
|
this.$emit('input', value);
|
|
this.$emit('change', value);
|
|
}
|
|
},
|
|
handleKey: function handleKey(e) {
|
|
if (this.rateDisabled) {
|
|
return;
|
|
}
|
|
var currentValue = this.currentValue;
|
|
var keyCode = e.keyCode;
|
|
if (keyCode === 38 || keyCode === 39) {
|
|
// left / down
|
|
if (this.allowHalf) {
|
|
currentValue += 0.5;
|
|
} else {
|
|
currentValue += 1;
|
|
}
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
} else if (keyCode === 37 || keyCode === 40) {
|
|
if (this.allowHalf) {
|
|
currentValue -= 0.5;
|
|
} else {
|
|
currentValue -= 1;
|
|
}
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
}
|
|
currentValue = currentValue < 0 ? 0 : currentValue;
|
|
currentValue = currentValue > this.max ? this.max : currentValue;
|
|
|
|
this.$emit('input', currentValue);
|
|
this.$emit('change', currentValue);
|
|
},
|
|
setCurrentValue: function setCurrentValue(value, event) {
|
|
if (this.rateDisabled) {
|
|
return;
|
|
}
|
|
/* istanbul ignore if */
|
|
if (this.allowHalf) {
|
|
var target = event.target;
|
|
if (Object(dom_["hasClass"])(target, 'el-rate__item')) {
|
|
target = target.querySelector('.el-rate__icon');
|
|
}
|
|
if (Object(dom_["hasClass"])(target, 'el-rate__decimal')) {
|
|
target = target.parentNode;
|
|
}
|
|
this.pointerAtLeftHalf = event.offsetX * 2 <= target.clientWidth;
|
|
this.currentValue = this.pointerAtLeftHalf ? value - 0.5 : value;
|
|
} else {
|
|
this.currentValue = value;
|
|
}
|
|
this.hoverIndex = value;
|
|
},
|
|
resetCurrentValue: function resetCurrentValue() {
|
|
if (this.rateDisabled) {
|
|
return;
|
|
}
|
|
if (this.allowHalf) {
|
|
this.pointerAtLeftHalf = this.value !== Math.floor(this.value);
|
|
}
|
|
this.currentValue = this.value;
|
|
this.hoverIndex = -1;
|
|
}
|
|
},
|
|
|
|
created: function created() {
|
|
if (!this.value) {
|
|
this.$emit('input', 0);
|
|
}
|
|
}
|
|
});
|
|
// CONCATENATED MODULE: ./packages/rate/src/main.vue?vue&type=script&lang=js&
|
|
/* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
|
|
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
var componentNormalizer = __webpack_require__(0);
|
|
|
|
// CONCATENATED MODULE: ./packages/rate/src/main.vue
|
|
|
|
|
|
|
|
|
|
|
|
/* normalize component */
|
|
|
|
var component = Object(componentNormalizer["a" /* default */])(
|
|
src_mainvue_type_script_lang_js_,
|
|
render,
|
|
staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
|
|
)
|
|
|
|
/* hot reload */
|
|
if (false) { var api; }
|
|
component.options.__file = "packages/rate/src/main.vue"
|
|
/* harmony default export */ var main = (component.exports);
|
|
// CONCATENATED MODULE: ./packages/rate/index.js
|
|
|
|
|
|
/* istanbul ignore next */
|
|
main.install = function (Vue) {
|
|
Vue.component(main.name, main);
|
|
};
|
|
|
|
/* harmony default export */ var rate = __webpack_exports__["default"] = (main);
|
|
|
|
/***/ })
|
|
|
|
/******/ }); |