框架源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

702 lines
20 KiB

4 years ago
  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 = 562);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 108:
  90. /***/ (function(module, exports) {
  91. module.exports = require("throttle-debounce/throttle");
  92. /***/ }),
  93. /***/ 2:
  94. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95. "use strict";
  96. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  97. /* globals __VUE_SSR_CONTEXT__ */
  98. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  99. // This module is a runtime utility for cleaner component module output and will
  100. // be included in the final webpack user bundle.
  101. function normalizeComponent (
  102. scriptExports,
  103. render,
  104. staticRenderFns,
  105. functionalTemplate,
  106. injectStyles,
  107. scopeId,
  108. moduleIdentifier, /* server only */
  109. shadowMode /* vue-cli only */
  110. ) {
  111. // Vue.extend constructor export interop
  112. var options = typeof scriptExports === 'function'
  113. ? scriptExports.options
  114. : scriptExports
  115. // render functions
  116. if (render) {
  117. options.render = render
  118. options.staticRenderFns = staticRenderFns
  119. options._compiled = true
  120. }
  121. // functional template
  122. if (functionalTemplate) {
  123. options.functional = true
  124. }
  125. // scopedId
  126. if (scopeId) {
  127. options._scopeId = 'data-v-' + scopeId
  128. }
  129. var hook
  130. if (moduleIdentifier) { // server build
  131. hook = function (context) {
  132. // 2.3 injection
  133. context =
  134. context || // cached call
  135. (this.$vnode && this.$vnode.ssrContext) || // stateful
  136. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  137. // 2.2 with runInNewContext: true
  138. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  139. context = __VUE_SSR_CONTEXT__
  140. }
  141. // inject component styles
  142. if (injectStyles) {
  143. injectStyles.call(this, context)
  144. }
  145. // register component module identifier for async chunk inferrence
  146. if (context && context._registeredComponents) {
  147. context._registeredComponents.add(moduleIdentifier)
  148. }
  149. }
  150. // used by ssr in case component is cached and beforeCreate
  151. // never gets called
  152. options._ssrRegister = hook
  153. } else if (injectStyles) {
  154. hook = shadowMode
  155. ? function () {
  156. injectStyles.call(
  157. this,
  158. (options.functional ? this.parent : this).$root.$options.shadowRoot
  159. )
  160. }
  161. : injectStyles
  162. }
  163. if (hook) {
  164. if (options.functional) {
  165. // for template-only hot-reload because in that case the render fn doesn't
  166. // go through the normalizer
  167. options._injectStyles = hook
  168. // register for functional component in vue file
  169. var originalRender = options.render
  170. options.render = function renderWithStyleInjection (h, context) {
  171. hook.call(context)
  172. return originalRender(h, context)
  173. }
  174. } else {
  175. // inject component registration as beforeCreate hook
  176. var existing = options.beforeCreate
  177. options.beforeCreate = existing
  178. ? [].concat(existing, hook)
  179. : [hook]
  180. }
  181. }
  182. return {
  183. exports: scriptExports,
  184. options: options
  185. }
  186. }
  187. /***/ }),
  188. /***/ 44:
  189. /***/ (function(module, exports) {
  190. module.exports = require("tis-ui/lib/utils/resize-event");
  191. /***/ }),
  192. /***/ 562:
  193. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  194. "use strict";
  195. // ESM COMPAT FLAG
  196. __webpack_require__.r(__webpack_exports__);
  197. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/carousel/src/main.vue?vue&type=template&id=5d5d1482&
  198. var render = function() {
  199. var _vm = this
  200. var _h = _vm.$createElement
  201. var _c = _vm._self._c || _h
  202. return _c(
  203. "div",
  204. {
  205. class: _vm.carouselClasses,
  206. on: {
  207. mouseenter: function($event) {
  208. $event.stopPropagation()
  209. return _vm.handleMouseEnter($event)
  210. },
  211. mouseleave: function($event) {
  212. $event.stopPropagation()
  213. return _vm.handleMouseLeave($event)
  214. }
  215. }
  216. },
  217. [
  218. _c(
  219. "div",
  220. {
  221. staticClass: "el-carousel__container",
  222. style: { height: _vm.height }
  223. },
  224. [
  225. _vm.arrowDisplay
  226. ? _c("transition", { attrs: { name: "carousel-arrow-left" } }, [
  227. _c(
  228. "button",
  229. {
  230. directives: [
  231. {
  232. name: "show",
  233. rawName: "v-show",
  234. value:
  235. (_vm.arrow === "always" || _vm.hover) &&
  236. (_vm.loop || _vm.activeIndex > 0),
  237. expression:
  238. "(arrow === 'always' || hover) && (loop || activeIndex > 0)"
  239. }
  240. ],
  241. staticClass: "el-carousel__arrow el-carousel__arrow--left",
  242. attrs: { type: "button" },
  243. on: {
  244. mouseenter: function($event) {
  245. _vm.handleButtonEnter("left")
  246. },
  247. mouseleave: _vm.handleButtonLeave,
  248. click: function($event) {
  249. $event.stopPropagation()
  250. _vm.throttledArrowClick(_vm.activeIndex - 1)
  251. }
  252. }
  253. },
  254. [_c("i", { staticClass: "el-icon-arrow-left" })]
  255. )
  256. ])
  257. : _vm._e(),
  258. _vm.arrowDisplay
  259. ? _c("transition", { attrs: { name: "carousel-arrow-right" } }, [
  260. _c(
  261. "button",
  262. {
  263. directives: [
  264. {
  265. name: "show",
  266. rawName: "v-show",
  267. value:
  268. (_vm.arrow === "always" || _vm.hover) &&
  269. (_vm.loop || _vm.activeIndex < _vm.items.length - 1),
  270. expression:
  271. "(arrow === 'always' || hover) && (loop || activeIndex < items.length - 1)"
  272. }
  273. ],
  274. staticClass: "el-carousel__arrow el-carousel__arrow--right",
  275. attrs: { type: "button" },
  276. on: {
  277. mouseenter: function($event) {
  278. _vm.handleButtonEnter("right")
  279. },
  280. mouseleave: _vm.handleButtonLeave,
  281. click: function($event) {
  282. $event.stopPropagation()
  283. _vm.throttledArrowClick(_vm.activeIndex + 1)
  284. }
  285. }
  286. },
  287. [_c("i", { staticClass: "el-icon-arrow-right" })]
  288. )
  289. ])
  290. : _vm._e(),
  291. _vm._t("default")
  292. ],
  293. 2
  294. ),
  295. _vm.indicatorPosition !== "none"
  296. ? _c(
  297. "ul",
  298. { class: _vm.indicatorsClasses },
  299. _vm._l(_vm.items, function(item, index) {
  300. return _c(
  301. "li",
  302. {
  303. key: index,
  304. class: [
  305. "el-carousel__indicator",
  306. "el-carousel__indicator--" + _vm.direction,
  307. { "is-active": index === _vm.activeIndex }
  308. ],
  309. on: {
  310. mouseenter: function($event) {
  311. _vm.throttledIndicatorHover(index)
  312. },
  313. click: function($event) {
  314. $event.stopPropagation()
  315. _vm.handleIndicatorClick(index)
  316. }
  317. }
  318. },
  319. [
  320. _c("button", { staticClass: "el-carousel__button" }, [
  321. _vm.hasLabel
  322. ? _c("span", [_vm._v(_vm._s(item.label))])
  323. : _vm._e()
  324. ])
  325. ]
  326. )
  327. }),
  328. 0
  329. )
  330. : _vm._e()
  331. ]
  332. )
  333. }
  334. var staticRenderFns = []
  335. render._withStripped = true
  336. // CONCATENATED MODULE: ./packages/carousel/src/main.vue?vue&type=template&id=5d5d1482&
  337. // EXTERNAL MODULE: external "throttle-debounce/throttle"
  338. var throttle_ = __webpack_require__(108);
  339. var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle_);
  340. // EXTERNAL MODULE: external "tis-ui/lib/utils/resize-event"
  341. var resize_event_ = __webpack_require__(44);
  342. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/carousel/src/main.vue?vue&type=script&lang=js&
  343. //
  344. //
  345. //
  346. //
  347. //
  348. //
  349. //
  350. //
  351. //
  352. //
  353. //
  354. //
  355. //
  356. //
  357. //
  358. //
  359. //
  360. //
  361. //
  362. //
  363. //
  364. //
  365. //
  366. //
  367. //
  368. //
  369. //
  370. //
  371. //
  372. //
  373. //
  374. //
  375. //
  376. //
  377. //
  378. //
  379. //
  380. //
  381. //
  382. //
  383. //
  384. //
  385. //
  386. //
  387. //
  388. //
  389. //
  390. //
  391. //
  392. //
  393. //
  394. //
  395. //
  396. //
  397. //
  398. //
  399. /* harmony default export */ var mainvue_type_script_lang_js_ = ({
  400. name: 'TisCarousel',
  401. props: {
  402. initialIndex: {
  403. type: Number,
  404. default: 0
  405. },
  406. height: String,
  407. trigger: {
  408. type: String,
  409. default: 'hover'
  410. },
  411. autoplay: {
  412. type: Boolean,
  413. default: true
  414. },
  415. interval: {
  416. type: Number,
  417. default: 3000
  418. },
  419. indicatorPosition: String,
  420. indicator: {
  421. type: Boolean,
  422. default: true
  423. },
  424. arrow: {
  425. type: String,
  426. default: 'hover'
  427. },
  428. type: String,
  429. loop: {
  430. type: Boolean,
  431. default: true
  432. },
  433. direction: {
  434. type: String,
  435. default: 'horizontal',
  436. validator: function validator(val) {
  437. return ['horizontal', 'vertical'].indexOf(val) !== -1;
  438. }
  439. }
  440. },
  441. data: function data() {
  442. return {
  443. items: [],
  444. activeIndex: -1,
  445. containerWidth: 0,
  446. timer: null,
  447. hover: false
  448. };
  449. },
  450. computed: {
  451. arrowDisplay: function arrowDisplay() {
  452. return this.arrow !== 'never' && this.direction !== 'vertical';
  453. },
  454. hasLabel: function hasLabel() {
  455. return this.items.some(function (item) {
  456. return item.label.toString().length > 0;
  457. });
  458. },
  459. carouselClasses: function carouselClasses() {
  460. var classes = ['el-carousel', 'el-carousel--' + this.direction];
  461. if (this.type === 'card') {
  462. classes.push('el-carousel--card');
  463. }
  464. return classes;
  465. },
  466. indicatorsClasses: function indicatorsClasses() {
  467. var classes = ['el-carousel__indicators', 'el-carousel__indicators--' + this.direction];
  468. if (this.hasLabel) {
  469. classes.push('el-carousel__indicators--labels');
  470. }
  471. if (this.indicatorPosition === 'outside' || this.type === 'card') {
  472. classes.push('el-carousel__indicators--outside');
  473. }
  474. return classes;
  475. }
  476. },
  477. watch: {
  478. items: function items(val) {
  479. if (val.length > 0) this.setActiveItem(this.initialIndex);
  480. },
  481. activeIndex: function activeIndex(val, oldVal) {
  482. this.resetItemPosition(oldVal);
  483. if (oldVal > -1) {
  484. this.$emit('change', val, oldVal);
  485. }
  486. },
  487. autoplay: function autoplay(val) {
  488. val ? this.startTimer() : this.pauseTimer();
  489. },
  490. loop: function loop() {
  491. this.setActiveItem(this.activeIndex);
  492. }
  493. },
  494. methods: {
  495. handleMouseEnter: function handleMouseEnter() {
  496. this.hover = true;
  497. this.pauseTimer();
  498. },
  499. handleMouseLeave: function handleMouseLeave() {
  500. this.hover = false;
  501. this.startTimer();
  502. },
  503. itemInStage: function itemInStage(item, index) {
  504. var length = this.items.length;
  505. if (index === length - 1 && item.inStage && this.items[0].active || item.inStage && this.items[index + 1] && this.items[index + 1].active) {
  506. return 'left';
  507. } else if (index === 0 && item.inStage && this.items[length - 1].active || item.inStage && this.items[index - 1] && this.items[index - 1].active) {
  508. return 'right';
  509. }
  510. return false;
  511. },
  512. handleButtonEnter: function handleButtonEnter(arrow) {
  513. var _this = this;
  514. if (this.direction === 'vertical') return;
  515. this.items.forEach(function (item, index) {
  516. if (arrow === _this.itemInStage(item, index)) {
  517. item.hover = true;
  518. }
  519. });
  520. },
  521. handleButtonLeave: function handleButtonLeave() {
  522. if (this.direction === 'vertical') return;
  523. this.items.forEach(function (item) {
  524. item.hover = false;
  525. });
  526. },
  527. updateItems: function updateItems() {
  528. this.items = this.$children.filter(function (child) {
  529. return child.$options.name === 'TisCarouselItem';
  530. });
  531. },
  532. resetItemPosition: function resetItemPosition(oldIndex) {
  533. var _this2 = this;
  534. this.items.forEach(function (item, index) {
  535. item.translateItem(index, _this2.activeIndex, oldIndex);
  536. });
  537. },
  538. playSlides: function playSlides() {
  539. if (this.activeIndex < this.items.length - 1) {
  540. this.activeIndex++;
  541. } else if (this.loop) {
  542. this.activeIndex = 0;
  543. }
  544. },
  545. pauseTimer: function pauseTimer() {
  546. if (this.timer) {
  547. clearInterval(this.timer);
  548. this.timer = null;
  549. }
  550. },
  551. startTimer: function startTimer() {
  552. if (this.interval <= 0 || !this.autoplay || this.timer) return;
  553. this.timer = setInterval(this.playSlides, this.interval);
  554. },
  555. setActiveItem: function setActiveItem(index) {
  556. if (typeof index === 'string') {
  557. var filteredItems = this.items.filter(function (item) {
  558. return item.name === index;
  559. });
  560. if (filteredItems.length > 0) {
  561. index = this.items.indexOf(filteredItems[0]);
  562. }
  563. }
  564. index = Number(index);
  565. if (isNaN(index) || index !== Math.floor(index)) {
  566. console.warn('[Tis Warn][Carousel]index must be an integer.');
  567. return;
  568. }
  569. var length = this.items.length;
  570. var oldIndex = this.activeIndex;
  571. if (index < 0) {
  572. this.activeIndex = this.loop ? length - 1 : 0;
  573. } else if (index >= length) {
  574. this.activeIndex = this.loop ? 0 : length - 1;
  575. } else {
  576. this.activeIndex = index;
  577. }
  578. if (oldIndex === this.activeIndex) {
  579. this.resetItemPosition(oldIndex);
  580. }
  581. },
  582. prev: function prev() {
  583. this.setActiveItem(this.activeIndex - 1);
  584. },
  585. next: function next() {
  586. this.setActiveItem(this.activeIndex + 1);
  587. },
  588. handleIndicatorClick: function handleIndicatorClick(index) {
  589. this.activeIndex = index;
  590. },
  591. handleIndicatorHover: function handleIndicatorHover(index) {
  592. if (this.trigger === 'hover' && index !== this.activeIndex) {
  593. this.activeIndex = index;
  594. }
  595. }
  596. },
  597. created: function created() {
  598. var _this3 = this;
  599. this.throttledArrowClick = throttle_default()(300, true, function (index) {
  600. _this3.setActiveItem(index);
  601. });
  602. this.throttledIndicatorHover = throttle_default()(300, function (index) {
  603. _this3.handleIndicatorHover(index);
  604. });
  605. },
  606. mounted: function mounted() {
  607. var _this4 = this;
  608. this.updateItems();
  609. this.$nextTick(function () {
  610. Object(resize_event_["addResizeListener"])(_this4.$el, _this4.resetItemPosition);
  611. if (_this4.initialIndex < _this4.items.length && _this4.initialIndex >= 0) {
  612. _this4.activeIndex = _this4.initialIndex;
  613. }
  614. _this4.startTimer();
  615. });
  616. },
  617. beforeDestroy: function beforeDestroy() {
  618. if (this.$el) Object(resize_event_["removeResizeListener"])(this.$el, this.resetItemPosition);
  619. this.pauseTimer();
  620. }
  621. });
  622. // CONCATENATED MODULE: ./packages/carousel/src/main.vue?vue&type=script&lang=js&
  623. /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
  624. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  625. var componentNormalizer = __webpack_require__(2);
  626. // CONCATENATED MODULE: ./packages/carousel/src/main.vue
  627. /* normalize component */
  628. var component = Object(componentNormalizer["a" /* default */])(
  629. src_mainvue_type_script_lang_js_,
  630. render,
  631. staticRenderFns,
  632. false,
  633. null,
  634. null,
  635. null
  636. )
  637. /* hot reload */
  638. if (false) { var api; }
  639. component.options.__file = "packages/carousel/src/main.vue"
  640. /* harmony default export */ var main = (component.exports);
  641. // CONCATENATED MODULE: ./packages/carousel/index.js
  642. /* istanbul ignore next */
  643. main.install = function (Vue) {
  644. Vue.component(main.name, main);
  645. };
  646. /* harmony default export */ var carousel = __webpack_exports__["default"] = (main);
  647. /***/ })
  648. /******/ });