项目原始demo,不改动
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.
 
 
 
 

1205 rindas
32 KiB

  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "/dist/";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 59);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 0:
  90. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91. "use strict";
  92. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  93. /* globals __VUE_SSR_CONTEXT__ */
  94. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  95. // This module is a runtime utility for cleaner component module output and will
  96. // be included in the final webpack user bundle.
  97. function normalizeComponent (
  98. scriptExports,
  99. render,
  100. staticRenderFns,
  101. functionalTemplate,
  102. injectStyles,
  103. scopeId,
  104. moduleIdentifier, /* server only */
  105. shadowMode /* vue-cli only */
  106. ) {
  107. // Vue.extend constructor export interop
  108. var options = typeof scriptExports === 'function'
  109. ? scriptExports.options
  110. : scriptExports
  111. // render functions
  112. if (render) {
  113. options.render = render
  114. options.staticRenderFns = staticRenderFns
  115. options._compiled = true
  116. }
  117. // functional template
  118. if (functionalTemplate) {
  119. options.functional = true
  120. }
  121. // scopedId
  122. if (scopeId) {
  123. options._scopeId = 'data-v-' + scopeId
  124. }
  125. var hook
  126. if (moduleIdentifier) { // server build
  127. hook = function (context) {
  128. // 2.3 injection
  129. context =
  130. context || // cached call
  131. (this.$vnode && this.$vnode.ssrContext) || // stateful
  132. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  133. // 2.2 with runInNewContext: true
  134. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  135. context = __VUE_SSR_CONTEXT__
  136. }
  137. // inject component styles
  138. if (injectStyles) {
  139. injectStyles.call(this, context)
  140. }
  141. // register component module identifier for async chunk inferrence
  142. if (context && context._registeredComponents) {
  143. context._registeredComponents.add(moduleIdentifier)
  144. }
  145. }
  146. // used by ssr in case component is cached and beforeCreate
  147. // never gets called
  148. options._ssrRegister = hook
  149. } else if (injectStyles) {
  150. hook = shadowMode
  151. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  152. : injectStyles
  153. }
  154. if (hook) {
  155. if (options.functional) {
  156. // for template-only hot-reload because in that case the render fn doesn't
  157. // go through the normalizer
  158. options._injectStyles = hook
  159. // register for functioal component in vue file
  160. var originalRender = options.render
  161. options.render = function renderWithStyleInjection (h, context) {
  162. hook.call(context)
  163. return originalRender(h, context)
  164. }
  165. } else {
  166. // inject component registration as beforeCreate hook
  167. var existing = options.beforeCreate
  168. options.beforeCreate = existing
  169. ? [].concat(existing, hook)
  170. : [hook]
  171. }
  172. }
  173. return {
  174. exports: scriptExports,
  175. options: options
  176. }
  177. }
  178. /***/ }),
  179. /***/ 29:
  180. /***/ (function(module, exports) {
  181. module.exports = require("element-ui/lib/tooltip");
  182. /***/ }),
  183. /***/ 4:
  184. /***/ (function(module, exports) {
  185. module.exports = require("element-ui/lib/mixins/emitter");
  186. /***/ }),
  187. /***/ 49:
  188. /***/ (function(module, exports) {
  189. module.exports = require("element-ui/lib/input-number");
  190. /***/ }),
  191. /***/ 59:
  192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  193. "use strict";
  194. __webpack_require__.r(__webpack_exports__);
  195. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/slider/src/main.vue?vue&type=template&id=32708644&
  196. var render = function() {
  197. var _vm = this
  198. var _h = _vm.$createElement
  199. var _c = _vm._self._c || _h
  200. return _c(
  201. "div",
  202. {
  203. staticClass: "el-slider",
  204. class: {
  205. "is-vertical": _vm.vertical,
  206. "el-slider--with-input": _vm.showInput
  207. },
  208. attrs: {
  209. role: "slider",
  210. "aria-valuemin": _vm.min,
  211. "aria-valuemax": _vm.max,
  212. "aria-orientation": _vm.vertical ? "vertical" : "horizontal",
  213. "aria-disabled": _vm.sliderDisabled
  214. }
  215. },
  216. [
  217. _vm.showInput && !_vm.range
  218. ? _c("el-input-number", {
  219. ref: "input",
  220. staticClass: "el-slider__input",
  221. attrs: {
  222. step: _vm.step,
  223. disabled: _vm.sliderDisabled,
  224. controls: _vm.showInputControls,
  225. min: _vm.min,
  226. max: _vm.max,
  227. debounce: _vm.debounce,
  228. size: _vm.inputSize
  229. },
  230. on: {
  231. change: function($event) {
  232. _vm.$nextTick(_vm.emitChange)
  233. }
  234. },
  235. model: {
  236. value: _vm.firstValue,
  237. callback: function($$v) {
  238. _vm.firstValue = $$v
  239. },
  240. expression: "firstValue"
  241. }
  242. })
  243. : _vm._e(),
  244. _c(
  245. "div",
  246. {
  247. ref: "slider",
  248. staticClass: "el-slider__runway",
  249. class: { "show-input": _vm.showInput, disabled: _vm.sliderDisabled },
  250. style: _vm.runwayStyle,
  251. on: { click: _vm.onSliderClick }
  252. },
  253. [
  254. _c("div", { staticClass: "el-slider__bar", style: _vm.barStyle }),
  255. _c("slider-button", {
  256. ref: "button1",
  257. attrs: {
  258. vertical: _vm.vertical,
  259. "tooltip-class": _vm.tooltipClass
  260. },
  261. model: {
  262. value: _vm.firstValue,
  263. callback: function($$v) {
  264. _vm.firstValue = $$v
  265. },
  266. expression: "firstValue"
  267. }
  268. }),
  269. _vm.range
  270. ? _c("slider-button", {
  271. ref: "button2",
  272. attrs: {
  273. vertical: _vm.vertical,
  274. "tooltip-class": _vm.tooltipClass
  275. },
  276. model: {
  277. value: _vm.secondValue,
  278. callback: function($$v) {
  279. _vm.secondValue = $$v
  280. },
  281. expression: "secondValue"
  282. }
  283. })
  284. : _vm._e(),
  285. _vm._l(_vm.stops, function(item, key) {
  286. return _vm.showStops
  287. ? _c("div", {
  288. key: key,
  289. staticClass: "el-slider__stop",
  290. style: _vm.getStopStyle(item)
  291. })
  292. : _vm._e()
  293. }),
  294. _vm.markList.length > 0
  295. ? [
  296. _c(
  297. "div",
  298. _vm._l(_vm.markList, function(item, key) {
  299. return _c("div", {
  300. key: key,
  301. staticClass: "el-slider__stop el-slider__marks-stop",
  302. style: _vm.getStopStyle(item.position)
  303. })
  304. }),
  305. 0
  306. ),
  307. _c(
  308. "div",
  309. { staticClass: "el-slider__marks" },
  310. _vm._l(_vm.markList, function(item, key) {
  311. return _c("slider-marker", {
  312. key: key,
  313. style: _vm.getStopStyle(item.position),
  314. attrs: { mark: item.mark }
  315. })
  316. }),
  317. 1
  318. )
  319. ]
  320. : _vm._e()
  321. ],
  322. 2
  323. )
  324. ],
  325. 1
  326. )
  327. }
  328. var staticRenderFns = []
  329. render._withStripped = true
  330. // CONCATENATED MODULE: ./packages/slider/src/main.vue?vue&type=template&id=32708644&
  331. // EXTERNAL MODULE: external "element-ui/lib/input-number"
  332. var input_number_ = __webpack_require__(49);
  333. var input_number_default = /*#__PURE__*/__webpack_require__.n(input_number_);
  334. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/slider/src/button.vue?vue&type=template&id=e72d2ad2&
  335. var buttonvue_type_template_id_e72d2ad2_render = function() {
  336. var _vm = this
  337. var _h = _vm.$createElement
  338. var _c = _vm._self._c || _h
  339. return _c(
  340. "div",
  341. {
  342. ref: "button",
  343. staticClass: "el-slider__button-wrapper",
  344. class: { hover: _vm.hovering, dragging: _vm.dragging },
  345. style: _vm.wrapperStyle,
  346. attrs: { tabindex: "0" },
  347. on: {
  348. mouseenter: _vm.handleMouseEnter,
  349. mouseleave: _vm.handleMouseLeave,
  350. mousedown: _vm.onButtonDown,
  351. touchstart: _vm.onButtonDown,
  352. focus: _vm.handleMouseEnter,
  353. blur: _vm.handleMouseLeave,
  354. keydown: [
  355. function($event) {
  356. if (
  357. !("button" in $event) &&
  358. _vm._k($event.keyCode, "left", 37, $event.key, [
  359. "Left",
  360. "ArrowLeft"
  361. ])
  362. ) {
  363. return null
  364. }
  365. if ("button" in $event && $event.button !== 0) {
  366. return null
  367. }
  368. return _vm.onLeftKeyDown($event)
  369. },
  370. function($event) {
  371. if (
  372. !("button" in $event) &&
  373. _vm._k($event.keyCode, "right", 39, $event.key, [
  374. "Right",
  375. "ArrowRight"
  376. ])
  377. ) {
  378. return null
  379. }
  380. if ("button" in $event && $event.button !== 2) {
  381. return null
  382. }
  383. return _vm.onRightKeyDown($event)
  384. },
  385. function($event) {
  386. if (
  387. !("button" in $event) &&
  388. _vm._k($event.keyCode, "down", 40, $event.key, [
  389. "Down",
  390. "ArrowDown"
  391. ])
  392. ) {
  393. return null
  394. }
  395. $event.preventDefault()
  396. return _vm.onLeftKeyDown($event)
  397. },
  398. function($event) {
  399. if (
  400. !("button" in $event) &&
  401. _vm._k($event.keyCode, "up", 38, $event.key, ["Up", "ArrowUp"])
  402. ) {
  403. return null
  404. }
  405. $event.preventDefault()
  406. return _vm.onRightKeyDown($event)
  407. }
  408. ]
  409. }
  410. },
  411. [
  412. _c(
  413. "el-tooltip",
  414. {
  415. ref: "tooltip",
  416. attrs: {
  417. placement: "top",
  418. "popper-class": _vm.tooltipClass,
  419. disabled: !_vm.showTooltip
  420. }
  421. },
  422. [
  423. _c("span", { attrs: { slot: "content" }, slot: "content" }, [
  424. _vm._v(_vm._s(_vm.formatValue))
  425. ]),
  426. _c("div", {
  427. staticClass: "el-slider__button",
  428. class: { hover: _vm.hovering, dragging: _vm.dragging }
  429. })
  430. ]
  431. )
  432. ],
  433. 1
  434. )
  435. }
  436. var buttonvue_type_template_id_e72d2ad2_staticRenderFns = []
  437. buttonvue_type_template_id_e72d2ad2_render._withStripped = true
  438. // CONCATENATED MODULE: ./packages/slider/src/button.vue?vue&type=template&id=e72d2ad2&
  439. // EXTERNAL MODULE: external "element-ui/lib/tooltip"
  440. var tooltip_ = __webpack_require__(29);
  441. var tooltip_default = /*#__PURE__*/__webpack_require__.n(tooltip_);
  442. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/slider/src/button.vue?vue&type=script&lang=js&
  443. //
  444. //
  445. //
  446. //
  447. //
  448. //
  449. //
  450. //
  451. //
  452. //
  453. //
  454. //
  455. //
  456. //
  457. //
  458. //
  459. //
  460. //
  461. //
  462. //
  463. //
  464. //
  465. //
  466. //
  467. //
  468. //
  469. //
  470. //
  471. //
  472. /* harmony default export */ var buttonvue_type_script_lang_js_ = ({
  473. name: 'ElSliderButton',
  474. components: {
  475. ElTooltip: tooltip_default.a
  476. },
  477. props: {
  478. value: {
  479. type: Number,
  480. default: 0
  481. },
  482. vertical: {
  483. type: Boolean,
  484. default: false
  485. },
  486. tooltipClass: String
  487. },
  488. data: function data() {
  489. return {
  490. hovering: false,
  491. dragging: false,
  492. isClick: false,
  493. startX: 0,
  494. currentX: 0,
  495. startY: 0,
  496. currentY: 0,
  497. startPosition: 0,
  498. newPosition: null,
  499. oldValue: this.value
  500. };
  501. },
  502. computed: {
  503. disabled: function disabled() {
  504. return this.$parent.sliderDisabled;
  505. },
  506. max: function max() {
  507. return this.$parent.max;
  508. },
  509. min: function min() {
  510. return this.$parent.min;
  511. },
  512. step: function step() {
  513. return this.$parent.step;
  514. },
  515. showTooltip: function showTooltip() {
  516. return this.$parent.showTooltip;
  517. },
  518. precision: function precision() {
  519. return this.$parent.precision;
  520. },
  521. currentPosition: function currentPosition() {
  522. return (this.value - this.min) / (this.max - this.min) * 100 + '%';
  523. },
  524. enableFormat: function enableFormat() {
  525. return this.$parent.formatTooltip instanceof Function;
  526. },
  527. formatValue: function formatValue() {
  528. return this.enableFormat && this.$parent.formatTooltip(this.value) || this.value;
  529. },
  530. wrapperStyle: function wrapperStyle() {
  531. return this.vertical ? { bottom: this.currentPosition } : { left: this.currentPosition };
  532. }
  533. },
  534. watch: {
  535. dragging: function dragging(val) {
  536. this.$parent.dragging = val;
  537. }
  538. },
  539. methods: {
  540. displayTooltip: function displayTooltip() {
  541. this.$refs.tooltip && (this.$refs.tooltip.showPopper = true);
  542. },
  543. hideTooltip: function hideTooltip() {
  544. this.$refs.tooltip && (this.$refs.tooltip.showPopper = false);
  545. },
  546. handleMouseEnter: function handleMouseEnter() {
  547. this.hovering = true;
  548. this.displayTooltip();
  549. },
  550. handleMouseLeave: function handleMouseLeave() {
  551. this.hovering = false;
  552. this.hideTooltip();
  553. },
  554. onButtonDown: function onButtonDown(event) {
  555. if (this.disabled) return;
  556. event.preventDefault();
  557. this.onDragStart(event);
  558. window.addEventListener('mousemove', this.onDragging);
  559. window.addEventListener('touchmove', this.onDragging);
  560. window.addEventListener('mouseup', this.onDragEnd);
  561. window.addEventListener('touchend', this.onDragEnd);
  562. window.addEventListener('contextmenu', this.onDragEnd);
  563. },
  564. onLeftKeyDown: function onLeftKeyDown() {
  565. if (this.disabled) return;
  566. this.newPosition = parseFloat(this.currentPosition) - this.step / (this.max - this.min) * 100;
  567. this.setPosition(this.newPosition);
  568. this.$parent.emitChange();
  569. },
  570. onRightKeyDown: function onRightKeyDown() {
  571. if (this.disabled) return;
  572. this.newPosition = parseFloat(this.currentPosition) + this.step / (this.max - this.min) * 100;
  573. this.setPosition(this.newPosition);
  574. this.$parent.emitChange();
  575. },
  576. onDragStart: function onDragStart(event) {
  577. this.dragging = true;
  578. this.isClick = true;
  579. if (event.type === 'touchstart') {
  580. event.clientY = event.touches[0].clientY;
  581. event.clientX = event.touches[0].clientX;
  582. }
  583. if (this.vertical) {
  584. this.startY = event.clientY;
  585. } else {
  586. this.startX = event.clientX;
  587. }
  588. this.startPosition = parseFloat(this.currentPosition);
  589. this.newPosition = this.startPosition;
  590. },
  591. onDragging: function onDragging(event) {
  592. if (this.dragging) {
  593. this.isClick = false;
  594. this.displayTooltip();
  595. this.$parent.resetSize();
  596. var diff = 0;
  597. if (event.type === 'touchmove') {
  598. event.clientY = event.touches[0].clientY;
  599. event.clientX = event.touches[0].clientX;
  600. }
  601. if (this.vertical) {
  602. this.currentY = event.clientY;
  603. diff = (this.startY - this.currentY) / this.$parent.sliderSize * 100;
  604. } else {
  605. this.currentX = event.clientX;
  606. diff = (this.currentX - this.startX) / this.$parent.sliderSize * 100;
  607. }
  608. this.newPosition = this.startPosition + diff;
  609. this.setPosition(this.newPosition);
  610. }
  611. },
  612. onDragEnd: function onDragEnd() {
  613. var _this = this;
  614. if (this.dragging) {
  615. /*
  616. * 防止在 mouseup 后立即触发 click,导致滑块有几率产生一小段位移
  617. * 不使用 preventDefault 是因为 mouseup 和 click 没有注册在同一个 DOM 上
  618. */
  619. setTimeout(function () {
  620. _this.dragging = false;
  621. _this.hideTooltip();
  622. if (!_this.isClick) {
  623. _this.setPosition(_this.newPosition);
  624. _this.$parent.emitChange();
  625. }
  626. }, 0);
  627. window.removeEventListener('mousemove', this.onDragging);
  628. window.removeEventListener('touchmove', this.onDragging);
  629. window.removeEventListener('mouseup', this.onDragEnd);
  630. window.removeEventListener('touchend', this.onDragEnd);
  631. window.removeEventListener('contextmenu', this.onDragEnd);
  632. }
  633. },
  634. setPosition: function setPosition(newPosition) {
  635. var _this2 = this;
  636. if (newPosition === null || isNaN(newPosition)) return;
  637. if (newPosition < 0) {
  638. newPosition = 0;
  639. } else if (newPosition > 100) {
  640. newPosition = 100;
  641. }
  642. var lengthPerStep = 100 / ((this.max - this.min) / this.step);
  643. var steps = Math.round(newPosition / lengthPerStep);
  644. var value = steps * lengthPerStep * (this.max - this.min) * 0.01 + this.min;
  645. value = parseFloat(value.toFixed(this.precision));
  646. this.$emit('input', value);
  647. this.$nextTick(function () {
  648. _this2.displayTooltip();
  649. _this2.$refs.tooltip && _this2.$refs.tooltip.updatePopper();
  650. });
  651. if (!this.dragging && this.value !== this.oldValue) {
  652. this.oldValue = this.value;
  653. }
  654. }
  655. }
  656. });
  657. // CONCATENATED MODULE: ./packages/slider/src/button.vue?vue&type=script&lang=js&
  658. /* harmony default export */ var src_buttonvue_type_script_lang_js_ = (buttonvue_type_script_lang_js_);
  659. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  660. var componentNormalizer = __webpack_require__(0);
  661. // CONCATENATED MODULE: ./packages/slider/src/button.vue
  662. /* normalize component */
  663. var component = Object(componentNormalizer["a" /* default */])(
  664. src_buttonvue_type_script_lang_js_,
  665. buttonvue_type_template_id_e72d2ad2_render,
  666. buttonvue_type_template_id_e72d2ad2_staticRenderFns,
  667. false,
  668. null,
  669. null,
  670. null
  671. )
  672. /* hot reload */
  673. if (false) { var api; }
  674. component.options.__file = "packages/slider/src/button.vue"
  675. /* harmony default export */ var src_button = (component.exports);
  676. // CONCATENATED MODULE: ./packages/slider/src/marker.js
  677. /* harmony default export */ var marker = ({
  678. name: 'ElMarker',
  679. props: {
  680. mark: {
  681. type: [String, Object]
  682. }
  683. },
  684. render: function render() {
  685. var h = arguments[0];
  686. var label = typeof this.mark === 'string' ? this.mark : this.mark.label;
  687. return h(
  688. 'div',
  689. { 'class': 'el-slider__marks-text', style: this.mark.style || {} },
  690. [label]
  691. );
  692. }
  693. });
  694. // EXTERNAL MODULE: external "element-ui/lib/mixins/emitter"
  695. var emitter_ = __webpack_require__(4);
  696. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  697. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/slider/src/main.vue?vue&type=script&lang=js&
  698. //
  699. //
  700. //
  701. //
  702. //
  703. //
  704. //
  705. //
  706. //
  707. //
  708. //
  709. //
  710. //
  711. //
  712. //
  713. //
  714. //
  715. //
  716. //
  717. //
  718. //
  719. //
  720. //
  721. //
  722. //
  723. //
  724. //
  725. //
  726. //
  727. //
  728. //
  729. //
  730. //
  731. //
  732. //
  733. //
  734. //
  735. //
  736. //
  737. //
  738. //
  739. //
  740. //
  741. //
  742. //
  743. //
  744. //
  745. //
  746. //
  747. //
  748. //
  749. //
  750. //
  751. //
  752. //
  753. //
  754. //
  755. //
  756. //
  757. //
  758. //
  759. //
  760. //
  761. //
  762. //
  763. //
  764. //
  765. //
  766. //
  767. //
  768. //
  769. //
  770. //
  771. //
  772. //
  773. /* harmony default export */ var mainvue_type_script_lang_js_ = ({
  774. name: 'ElSlider',
  775. mixins: [emitter_default.a],
  776. inject: {
  777. elForm: {
  778. default: ''
  779. }
  780. },
  781. props: {
  782. min: {
  783. type: Number,
  784. default: 0
  785. },
  786. max: {
  787. type: Number,
  788. default: 100
  789. },
  790. step: {
  791. type: Number,
  792. default: 1
  793. },
  794. value: {
  795. type: [Number, Array],
  796. default: 0
  797. },
  798. showInput: {
  799. type: Boolean,
  800. default: false
  801. },
  802. showInputControls: {
  803. type: Boolean,
  804. default: true
  805. },
  806. inputSize: {
  807. type: String,
  808. default: 'small'
  809. },
  810. showStops: {
  811. type: Boolean,
  812. default: false
  813. },
  814. showTooltip: {
  815. type: Boolean,
  816. default: true
  817. },
  818. formatTooltip: Function,
  819. disabled: {
  820. type: Boolean,
  821. default: false
  822. },
  823. range: {
  824. type: Boolean,
  825. default: false
  826. },
  827. vertical: {
  828. type: Boolean,
  829. default: false
  830. },
  831. height: {
  832. type: String
  833. },
  834. debounce: {
  835. type: Number,
  836. default: 300
  837. },
  838. label: {
  839. type: String
  840. },
  841. tooltipClass: String,
  842. marks: Object
  843. },
  844. components: {
  845. ElInputNumber: input_number_default.a,
  846. SliderButton: src_button,
  847. SliderMarker: marker
  848. },
  849. data: function data() {
  850. return {
  851. firstValue: null,
  852. secondValue: null,
  853. oldValue: null,
  854. dragging: false,
  855. sliderSize: 1
  856. };
  857. },
  858. watch: {
  859. value: function value(val, oldVal) {
  860. if (this.dragging || Array.isArray(val) && Array.isArray(oldVal) && val.every(function (item, index) {
  861. return item === oldVal[index];
  862. })) {
  863. return;
  864. }
  865. this.setValues();
  866. },
  867. dragging: function dragging(val) {
  868. if (!val) {
  869. this.setValues();
  870. }
  871. },
  872. firstValue: function firstValue(val) {
  873. if (this.range) {
  874. this.$emit('input', [this.minValue, this.maxValue]);
  875. } else {
  876. this.$emit('input', val);
  877. }
  878. },
  879. secondValue: function secondValue() {
  880. if (this.range) {
  881. this.$emit('input', [this.minValue, this.maxValue]);
  882. }
  883. },
  884. min: function min() {
  885. this.setValues();
  886. },
  887. max: function max() {
  888. this.setValues();
  889. }
  890. },
  891. methods: {
  892. valueChanged: function valueChanged() {
  893. var _this = this;
  894. if (this.range) {
  895. return ![this.minValue, this.maxValue].every(function (item, index) {
  896. return item === _this.oldValue[index];
  897. });
  898. } else {
  899. return this.value !== this.oldValue;
  900. }
  901. },
  902. setValues: function setValues() {
  903. if (this.min > this.max) {
  904. console.error('[Element Error][Slider]min should not be greater than max.');
  905. return;
  906. }
  907. var val = this.value;
  908. if (this.range && Array.isArray(val)) {
  909. if (val[1] < this.min) {
  910. this.$emit('input', [this.min, this.min]);
  911. } else if (val[0] > this.max) {
  912. this.$emit('input', [this.max, this.max]);
  913. } else if (val[0] < this.min) {
  914. this.$emit('input', [this.min, val[1]]);
  915. } else if (val[1] > this.max) {
  916. this.$emit('input', [val[0], this.max]);
  917. } else {
  918. this.firstValue = val[0];
  919. this.secondValue = val[1];
  920. if (this.valueChanged()) {
  921. this.dispatch('ElFormItem', 'el.form.change', [this.minValue, this.maxValue]);
  922. this.oldValue = val.slice();
  923. }
  924. }
  925. } else if (!this.range && typeof val === 'number' && !isNaN(val)) {
  926. if (val < this.min) {
  927. this.$emit('input', this.min);
  928. } else if (val > this.max) {
  929. this.$emit('input', this.max);
  930. } else {
  931. this.firstValue = val;
  932. if (this.valueChanged()) {
  933. this.dispatch('ElFormItem', 'el.form.change', val);
  934. this.oldValue = val;
  935. }
  936. }
  937. }
  938. },
  939. setPosition: function setPosition(percent) {
  940. var targetValue = this.min + percent * (this.max - this.min) / 100;
  941. if (!this.range) {
  942. this.$refs.button1.setPosition(percent);
  943. return;
  944. }
  945. var button = void 0;
  946. if (Math.abs(this.minValue - targetValue) < Math.abs(this.maxValue - targetValue)) {
  947. button = this.firstValue < this.secondValue ? 'button1' : 'button2';
  948. } else {
  949. button = this.firstValue > this.secondValue ? 'button1' : 'button2';
  950. }
  951. this.$refs[button].setPosition(percent);
  952. },
  953. onSliderClick: function onSliderClick(event) {
  954. if (this.sliderDisabled || this.dragging) return;
  955. this.resetSize();
  956. if (this.vertical) {
  957. var sliderOffsetBottom = this.$refs.slider.getBoundingClientRect().bottom;
  958. this.setPosition((sliderOffsetBottom - event.clientY) / this.sliderSize * 100);
  959. } else {
  960. var sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left;
  961. this.setPosition((event.clientX - sliderOffsetLeft) / this.sliderSize * 100);
  962. }
  963. this.emitChange();
  964. },
  965. resetSize: function resetSize() {
  966. if (this.$refs.slider) {
  967. this.sliderSize = this.$refs.slider['client' + (this.vertical ? 'Height' : 'Width')];
  968. }
  969. },
  970. emitChange: function emitChange() {
  971. var _this2 = this;
  972. this.$nextTick(function () {
  973. _this2.$emit('change', _this2.range ? [_this2.minValue, _this2.maxValue] : _this2.value);
  974. });
  975. },
  976. getStopStyle: function getStopStyle(position) {
  977. return this.vertical ? { 'bottom': position + '%' } : { 'left': position + '%' };
  978. }
  979. },
  980. computed: {
  981. stops: function stops() {
  982. var _this3 = this;
  983. if (!this.showStops || this.min > this.max) return [];
  984. if (this.step === 0) {
  985. false && false;
  986. return [];
  987. }
  988. var stopCount = (this.max - this.min) / this.step;
  989. var stepWidth = 100 * this.step / (this.max - this.min);
  990. var result = [];
  991. for (var i = 1; i < stopCount; i++) {
  992. result.push(i * stepWidth);
  993. }
  994. if (this.range) {
  995. return result.filter(function (step) {
  996. return step < 100 * (_this3.minValue - _this3.min) / (_this3.max - _this3.min) || step > 100 * (_this3.maxValue - _this3.min) / (_this3.max - _this3.min);
  997. });
  998. } else {
  999. return result.filter(function (step) {
  1000. return step > 100 * (_this3.firstValue - _this3.min) / (_this3.max - _this3.min);
  1001. });
  1002. }
  1003. },
  1004. markList: function markList() {
  1005. var _this4 = this;
  1006. if (!this.marks) {
  1007. return [];
  1008. }
  1009. var marksKeys = Object.keys(this.marks);
  1010. return marksKeys.map(parseFloat).sort(function (a, b) {
  1011. return a - b;
  1012. }).filter(function (point) {
  1013. return point <= _this4.max && point >= _this4.min;
  1014. }).map(function (point) {
  1015. return {
  1016. point: point,
  1017. position: (point - _this4.min) * 100 / (_this4.max - _this4.min),
  1018. mark: _this4.marks[point]
  1019. };
  1020. });
  1021. },
  1022. minValue: function minValue() {
  1023. return Math.min(this.firstValue, this.secondValue);
  1024. },
  1025. maxValue: function maxValue() {
  1026. return Math.max(this.firstValue, this.secondValue);
  1027. },
  1028. barSize: function barSize() {
  1029. return this.range ? 100 * (this.maxValue - this.minValue) / (this.max - this.min) + '%' : 100 * (this.firstValue - this.min) / (this.max - this.min) + '%';
  1030. },
  1031. barStart: function barStart() {
  1032. return this.range ? 100 * (this.minValue - this.min) / (this.max - this.min) + '%' : '0%';
  1033. },
  1034. precision: function precision() {
  1035. var precisions = [this.min, this.max, this.step].map(function (item) {
  1036. var decimal = ('' + item).split('.')[1];
  1037. return decimal ? decimal.length : 0;
  1038. });
  1039. return Math.max.apply(null, precisions);
  1040. },
  1041. runwayStyle: function runwayStyle() {
  1042. return this.vertical ? { height: this.height } : {};
  1043. },
  1044. barStyle: function barStyle() {
  1045. return this.vertical ? {
  1046. height: this.barSize,
  1047. bottom: this.barStart
  1048. } : {
  1049. width: this.barSize,
  1050. left: this.barStart
  1051. };
  1052. },
  1053. sliderDisabled: function sliderDisabled() {
  1054. return this.disabled || (this.elForm || {}).disabled;
  1055. }
  1056. },
  1057. mounted: function mounted() {
  1058. var valuetext = void 0;
  1059. if (this.range) {
  1060. if (Array.isArray(this.value)) {
  1061. this.firstValue = Math.max(this.min, this.value[0]);
  1062. this.secondValue = Math.min(this.max, this.value[1]);
  1063. } else {
  1064. this.firstValue = this.min;
  1065. this.secondValue = this.max;
  1066. }
  1067. this.oldValue = [this.firstValue, this.secondValue];
  1068. valuetext = this.firstValue + '-' + this.secondValue;
  1069. } else {
  1070. if (typeof this.value !== 'number' || isNaN(this.value)) {
  1071. this.firstValue = this.min;
  1072. } else {
  1073. this.firstValue = Math.min(this.max, Math.max(this.min, this.value));
  1074. }
  1075. this.oldValue = this.firstValue;
  1076. valuetext = this.firstValue;
  1077. }
  1078. this.$el.setAttribute('aria-valuetext', valuetext);
  1079. // label screen reader
  1080. this.$el.setAttribute('aria-label', this.label ? this.label : 'slider between ' + this.min + ' and ' + this.max);
  1081. this.resetSize();
  1082. window.addEventListener('resize', this.resetSize);
  1083. },
  1084. beforeDestroy: function beforeDestroy() {
  1085. window.removeEventListener('resize', this.resetSize);
  1086. }
  1087. });
  1088. // CONCATENATED MODULE: ./packages/slider/src/main.vue?vue&type=script&lang=js&
  1089. /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
  1090. // CONCATENATED MODULE: ./packages/slider/src/main.vue
  1091. /* normalize component */
  1092. var main_component = Object(componentNormalizer["a" /* default */])(
  1093. src_mainvue_type_script_lang_js_,
  1094. render,
  1095. staticRenderFns,
  1096. false,
  1097. null,
  1098. null,
  1099. null
  1100. )
  1101. /* hot reload */
  1102. if (false) { var main_api; }
  1103. main_component.options.__file = "packages/slider/src/main.vue"
  1104. /* harmony default export */ var main = (main_component.exports);
  1105. // CONCATENATED MODULE: ./packages/slider/index.js
  1106. /* istanbul ignore next */
  1107. main.install = function (Vue) {
  1108. Vue.component(main.name, main);
  1109. };
  1110. /* harmony default export */ var slider = __webpack_exports__["default"] = (main);
  1111. /***/ })
  1112. /******/ });