app模板、应用模板、组件模板、widget模板
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.

1089 lines
29 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 = 522);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 10:
  90. /***/ (function(module, exports) {
  91. module.exports = require("tis-ui/lib/utils/util");
  92. /***/ }),
  93. /***/ 108:
  94. /***/ (function(module, exports) {
  95. module.exports = require("throttle-debounce/throttle");
  96. /***/ }),
  97. /***/ 2:
  98. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99. "use strict";
  100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  101. /* globals __VUE_SSR_CONTEXT__ */
  102. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  103. // This module is a runtime utility for cleaner component module output and will
  104. // be included in the final webpack user bundle.
  105. function normalizeComponent (
  106. scriptExports,
  107. render,
  108. staticRenderFns,
  109. functionalTemplate,
  110. injectStyles,
  111. scopeId,
  112. moduleIdentifier, /* server only */
  113. shadowMode /* vue-cli only */
  114. ) {
  115. // Vue.extend constructor export interop
  116. var options = typeof scriptExports === 'function'
  117. ? scriptExports.options
  118. : scriptExports
  119. // render functions
  120. if (render) {
  121. options.render = render
  122. options.staticRenderFns = staticRenderFns
  123. options._compiled = true
  124. }
  125. // functional template
  126. if (functionalTemplate) {
  127. options.functional = true
  128. }
  129. // scopedId
  130. if (scopeId) {
  131. options._scopeId = 'data-v-' + scopeId
  132. }
  133. var hook
  134. if (moduleIdentifier) { // server build
  135. hook = function (context) {
  136. // 2.3 injection
  137. context =
  138. context || // cached call
  139. (this.$vnode && this.$vnode.ssrContext) || // stateful
  140. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  141. // 2.2 with runInNewContext: true
  142. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  143. context = __VUE_SSR_CONTEXT__
  144. }
  145. // inject component styles
  146. if (injectStyles) {
  147. injectStyles.call(this, context)
  148. }
  149. // register component module identifier for async chunk inferrence
  150. if (context && context._registeredComponents) {
  151. context._registeredComponents.add(moduleIdentifier)
  152. }
  153. }
  154. // used by ssr in case component is cached and beforeCreate
  155. // never gets called
  156. options._ssrRegister = hook
  157. } else if (injectStyles) {
  158. hook = shadowMode
  159. ? function () {
  160. injectStyles.call(
  161. this,
  162. (options.functional ? this.parent : this).$root.$options.shadowRoot
  163. )
  164. }
  165. : injectStyles
  166. }
  167. if (hook) {
  168. if (options.functional) {
  169. // for template-only hot-reload because in that case the render fn doesn't
  170. // go through the normalizer
  171. options._injectStyles = hook
  172. // register for functional component in vue file
  173. var originalRender = options.render
  174. options.render = function renderWithStyleInjection (h, context) {
  175. hook.call(context)
  176. return originalRender(h, context)
  177. }
  178. } else {
  179. // inject component registration as beforeCreate hook
  180. var existing = options.beforeCreate
  181. options.beforeCreate = existing
  182. ? [].concat(existing, hook)
  183. : [hook]
  184. }
  185. }
  186. return {
  187. exports: scriptExports,
  188. options: options
  189. }
  190. }
  191. /***/ }),
  192. /***/ 38:
  193. /***/ (function(module, exports) {
  194. module.exports = require("tis-ui/lib/mixins/locale");
  195. /***/ }),
  196. /***/ 522:
  197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  198. "use strict";
  199. // ESM COMPAT FLAG
  200. __webpack_require__.r(__webpack_exports__);
  201. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/image/src/main.vue?vue&type=template&id=44d84a7c&
  202. var render = function() {
  203. var _vm = this
  204. var _h = _vm.$createElement
  205. var _c = _vm._self._c || _h
  206. return _c(
  207. "div",
  208. { staticClass: "el-image" },
  209. [
  210. _vm.loading
  211. ? _vm._t("placeholder", [
  212. _c("div", { staticClass: "el-image__placeholder" })
  213. ])
  214. : _vm.error
  215. ? _vm._t("error", [
  216. _c("div", { staticClass: "el-image__error" }, [
  217. _vm._v(_vm._s(_vm.t("el.image.error")))
  218. ])
  219. ])
  220. : _c(
  221. "img",
  222. _vm._g(
  223. _vm._b(
  224. {
  225. staticClass: "el-image__inner",
  226. class: {
  227. "el-image__inner--center": _vm.alignCenter,
  228. "el-image__preview": _vm.preview
  229. },
  230. style: _vm.imageStyle,
  231. attrs: { src: _vm.src },
  232. on: { click: _vm.clickHandler }
  233. },
  234. "img",
  235. _vm.$attrs,
  236. false
  237. ),
  238. _vm.$listeners
  239. )
  240. ),
  241. _vm.preview
  242. ? [
  243. _vm.showViewer
  244. ? _c("image-viewer", {
  245. attrs: {
  246. "z-index": _vm.zIndex,
  247. "initial-index": _vm.imageIndex,
  248. "on-close": _vm.closeViewer,
  249. "url-list": _vm.previewSrcList
  250. }
  251. })
  252. : _vm._e()
  253. ]
  254. : _vm._e()
  255. ],
  256. 2
  257. )
  258. }
  259. var staticRenderFns = []
  260. render._withStripped = true
  261. // CONCATENATED MODULE: ./packages/image/src/main.vue?vue&type=template&id=44d84a7c&
  262. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/image/src/image-viewer.vue?vue&type=template&id=5e73b307&
  263. var image_viewervue_type_template_id_5e73b307_render = function() {
  264. var _vm = this
  265. var _h = _vm.$createElement
  266. var _c = _vm._self._c || _h
  267. return _c("transition", { attrs: { name: "viewer-fade" } }, [
  268. _c(
  269. "div",
  270. {
  271. ref: "el-image-viewer__wrapper",
  272. staticClass: "el-image-viewer__wrapper",
  273. style: { "z-index": _vm.zIndex },
  274. attrs: { tabindex: "-1" }
  275. },
  276. [
  277. _c("div", { staticClass: "el-image-viewer__mask" }),
  278. _c(
  279. "span",
  280. {
  281. staticClass: "el-image-viewer__btn el-image-viewer__close",
  282. on: { click: _vm.hide }
  283. },
  284. [_c("i", { staticClass: "el-icon-circle-close" })]
  285. ),
  286. !_vm.isSingle
  287. ? [
  288. _c(
  289. "span",
  290. {
  291. staticClass: "el-image-viewer__btn el-image-viewer__prev",
  292. class: { "is-disabled": !_vm.infinite && _vm.isFirst },
  293. on: { click: _vm.prev }
  294. },
  295. [_c("i", { staticClass: "el-icon-arrow-left" })]
  296. ),
  297. _c(
  298. "span",
  299. {
  300. staticClass: "el-image-viewer__btn el-image-viewer__next",
  301. class: { "is-disabled": !_vm.infinite && _vm.isLast },
  302. on: { click: _vm.next }
  303. },
  304. [_c("i", { staticClass: "el-icon-arrow-right" })]
  305. )
  306. ]
  307. : _vm._e(),
  308. _c(
  309. "div",
  310. { staticClass: "el-image-viewer__btn el-image-viewer__actions" },
  311. [
  312. _c("div", { staticClass: "el-image-viewer__actions__inner" }, [
  313. _c("i", {
  314. staticClass: "el-icon-zoom-out",
  315. on: {
  316. click: function($event) {
  317. _vm.handleActions("zoomOut")
  318. }
  319. }
  320. }),
  321. _c("i", {
  322. staticClass: "el-icon-zoom-in",
  323. on: {
  324. click: function($event) {
  325. _vm.handleActions("zoomIn")
  326. }
  327. }
  328. }),
  329. _c("i", { staticClass: "el-image-viewer__actions__divider" }),
  330. _c("i", { class: _vm.mode.icon, on: { click: _vm.toggleMode } }),
  331. _c("i", { staticClass: "el-image-viewer__actions__divider" }),
  332. _c("i", {
  333. staticClass: "el-icon-refresh-left",
  334. on: {
  335. click: function($event) {
  336. _vm.handleActions("anticlocelise")
  337. }
  338. }
  339. }),
  340. _c("i", {
  341. staticClass: "el-icon-refresh-right",
  342. on: {
  343. click: function($event) {
  344. _vm.handleActions("clocelise")
  345. }
  346. }
  347. })
  348. ])
  349. ]
  350. ),
  351. _c(
  352. "div",
  353. { staticClass: "el-image-viewer__canvas" },
  354. _vm._l(_vm.urlList, function(url, i) {
  355. return i === _vm.index
  356. ? _c("img", {
  357. key: url,
  358. ref: "img",
  359. refInFor: true,
  360. staticClass: "el-image-viewer__img",
  361. style: _vm.imgStyle,
  362. attrs: { src: _vm.currentImg },
  363. on: {
  364. load: _vm.handleImgLoad,
  365. error: _vm.handleImgError,
  366. mousedown: _vm.handleMouseDown
  367. }
  368. })
  369. : _vm._e()
  370. }),
  371. 0
  372. )
  373. ],
  374. 2
  375. )
  376. ])
  377. }
  378. var image_viewervue_type_template_id_5e73b307_staticRenderFns = []
  379. image_viewervue_type_template_id_5e73b307_render._withStripped = true
  380. // CONCATENATED MODULE: ./packages/image/src/image-viewer.vue?vue&type=template&id=5e73b307&
  381. // EXTERNAL MODULE: external "tis-ui/lib/utils/dom"
  382. var dom_ = __webpack_require__(7);
  383. // EXTERNAL MODULE: external "tis-ui/lib/utils/util"
  384. var util_ = __webpack_require__(10);
  385. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/image/src/image-viewer.vue?vue&type=script&lang=js&
  386. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  387. //
  388. //
  389. //
  390. //
  391. //
  392. //
  393. //
  394. //
  395. //
  396. //
  397. //
  398. //
  399. //
  400. //
  401. //
  402. //
  403. //
  404. //
  405. //
  406. //
  407. //
  408. //
  409. //
  410. //
  411. //
  412. //
  413. //
  414. //
  415. //
  416. //
  417. //
  418. //
  419. //
  420. //
  421. //
  422. //
  423. //
  424. //
  425. //
  426. //
  427. //
  428. //
  429. //
  430. //
  431. //
  432. //
  433. //
  434. //
  435. //
  436. //
  437. //
  438. //
  439. //
  440. var Mode = {
  441. CONTAIN: {
  442. name: 'contain',
  443. icon: 'el-icon-full-screen'
  444. },
  445. ORIGINAL: {
  446. name: 'original',
  447. icon: 'el-icon-c-scale-to-original'
  448. }
  449. };
  450. var mousewheelEventName = Object(util_["isFirefox"])() ? 'DOMMouseScroll' : 'mousewheel';
  451. /* harmony default export */ var image_viewervue_type_script_lang_js_ = ({
  452. name: 'elImageViewer',
  453. props: {
  454. urlList: {
  455. type: Array,
  456. default: function _default() {
  457. return [];
  458. }
  459. },
  460. zIndex: {
  461. type: Number,
  462. default: 2000
  463. },
  464. onSwitch: {
  465. type: Function,
  466. default: function _default() {}
  467. },
  468. onClose: {
  469. type: Function,
  470. default: function _default() {}
  471. },
  472. initialIndex: {
  473. type: Number,
  474. default: 0
  475. }
  476. },
  477. data: function data() {
  478. return {
  479. index: this.initialIndex,
  480. isShow: false,
  481. infinite: true,
  482. loading: false,
  483. mode: Mode.CONTAIN,
  484. transform: {
  485. scale: 1,
  486. deg: 0,
  487. offsetX: 0,
  488. offsetY: 0,
  489. enableTransition: false
  490. }
  491. };
  492. },
  493. computed: {
  494. isSingle: function isSingle() {
  495. return this.urlList.length <= 1;
  496. },
  497. isFirst: function isFirst() {
  498. return this.index === 0;
  499. },
  500. isLast: function isLast() {
  501. return this.index === this.urlList.length - 1;
  502. },
  503. currentImg: function currentImg() {
  504. return this.urlList[this.index];
  505. },
  506. imgStyle: function imgStyle() {
  507. var _transform = this.transform,
  508. scale = _transform.scale,
  509. deg = _transform.deg,
  510. offsetX = _transform.offsetX,
  511. offsetY = _transform.offsetY,
  512. enableTransition = _transform.enableTransition;
  513. var style = {
  514. transform: 'scale(' + scale + ') rotate(' + deg + 'deg)',
  515. transition: enableTransition ? 'transform .3s' : '',
  516. 'margin-left': offsetX + 'px',
  517. 'margin-top': offsetY + 'px'
  518. };
  519. if (this.mode === Mode.CONTAIN) {
  520. style.maxWidth = style.maxHeight = '100%';
  521. }
  522. return style;
  523. }
  524. },
  525. watch: {
  526. index: {
  527. handler: function handler(val) {
  528. this.reset();
  529. this.onSwitch(val);
  530. }
  531. },
  532. currentImg: function currentImg(val) {
  533. var _this = this;
  534. this.$nextTick(function (_) {
  535. var $img = _this.$refs.img[0];
  536. if (!$img.complete) {
  537. _this.loading = true;
  538. }
  539. });
  540. }
  541. },
  542. methods: {
  543. hide: function hide() {
  544. this.deviceSupportUninstall();
  545. this.onClose();
  546. },
  547. deviceSupportInstall: function deviceSupportInstall() {
  548. var _this2 = this;
  549. this._keyDownHandler = Object(util_["rafThrottle"])(function (e) {
  550. var keyCode = e.keyCode;
  551. switch (keyCode) {
  552. // ESC
  553. case 27:
  554. _this2.hide();
  555. break;
  556. // SPACE
  557. case 32:
  558. _this2.toggleMode();
  559. break;
  560. // LEFT_ARROW
  561. case 37:
  562. _this2.prev();
  563. break;
  564. // UP_ARROW
  565. case 38:
  566. _this2.handleActions('zoomIn');
  567. break;
  568. // RIGHT_ARROW
  569. case 39:
  570. _this2.next();
  571. break;
  572. // DOWN_ARROW
  573. case 40:
  574. _this2.handleActions('zoomOut');
  575. break;
  576. }
  577. });
  578. this._mouseWheelHandler = Object(util_["rafThrottle"])(function (e) {
  579. var delta = e.wheelDelta ? e.wheelDelta : -e.detail;
  580. if (delta > 0) {
  581. _this2.handleActions('zoomIn', {
  582. zoomRate: 0.015,
  583. enableTransition: false
  584. });
  585. } else {
  586. _this2.handleActions('zoomOut', {
  587. zoomRate: 0.015,
  588. enableTransition: false
  589. });
  590. }
  591. });
  592. Object(dom_["on"])(document, 'keydown', this._keyDownHandler);
  593. Object(dom_["on"])(document, mousewheelEventName, this._mouseWheelHandler);
  594. },
  595. deviceSupportUninstall: function deviceSupportUninstall() {
  596. Object(dom_["off"])(document, 'keydown', this._keyDownHandler);
  597. Object(dom_["off"])(document, mousewheelEventName, this._mouseWheelHandler);
  598. this._keyDownHandler = null;
  599. this._mouseWheelHandler = null;
  600. },
  601. handleImgLoad: function handleImgLoad(e) {
  602. this.loading = false;
  603. },
  604. handleImgError: function handleImgError(e) {
  605. this.loading = false;
  606. e.target.alt = '加载失败';
  607. },
  608. handleMouseDown: function handleMouseDown(e) {
  609. var _this3 = this;
  610. if (this.loading || e.button !== 0) return;
  611. var _transform2 = this.transform,
  612. offsetX = _transform2.offsetX,
  613. offsetY = _transform2.offsetY;
  614. var startX = e.pageX;
  615. var startY = e.pageY;
  616. this._dragHandler = Object(util_["rafThrottle"])(function (ev) {
  617. _this3.transform.offsetX = offsetX + ev.pageX - startX;
  618. _this3.transform.offsetY = offsetY + ev.pageY - startY;
  619. });
  620. Object(dom_["on"])(document, 'mousemove', this._dragHandler);
  621. Object(dom_["on"])(document, 'mouseup', function (ev) {
  622. Object(dom_["off"])(document, 'mousemove', _this3._dragHandler);
  623. });
  624. e.preventDefault();
  625. },
  626. reset: function reset() {
  627. this.transform = {
  628. scale: 1,
  629. deg: 0,
  630. offsetX: 0,
  631. offsetY: 0,
  632. enableTransition: false
  633. };
  634. },
  635. toggleMode: function toggleMode() {
  636. if (this.loading) return;
  637. var modeNames = Object.keys(Mode);
  638. var modeValues = Object.values(Mode);
  639. var index = modeValues.indexOf(this.mode);
  640. var nextIndex = (index + 1) % modeNames.length;
  641. this.mode = Mode[modeNames[nextIndex]];
  642. this.reset();
  643. },
  644. prev: function prev() {
  645. if (this.isFirst && !this.infinite) return;
  646. var len = this.urlList.length;
  647. this.index = (this.index - 1 + len) % len;
  648. },
  649. next: function next() {
  650. if (this.isLast && !this.infinite) return;
  651. var len = this.urlList.length;
  652. this.index = (this.index + 1) % len;
  653. },
  654. handleActions: function handleActions(action) {
  655. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  656. if (this.loading) return;
  657. var _zoomRate$rotateDeg$e = _extends({
  658. zoomRate: 0.2,
  659. rotateDeg: 90,
  660. enableTransition: true
  661. }, options),
  662. zoomRate = _zoomRate$rotateDeg$e.zoomRate,
  663. rotateDeg = _zoomRate$rotateDeg$e.rotateDeg,
  664. enableTransition = _zoomRate$rotateDeg$e.enableTransition;
  665. var transform = this.transform;
  666. switch (action) {
  667. case 'zoomOut':
  668. if (transform.scale > 0.2) {
  669. transform.scale = parseFloat((transform.scale - zoomRate).toFixed(3));
  670. }
  671. break;
  672. case 'zoomIn':
  673. transform.scale = parseFloat((transform.scale + zoomRate).toFixed(3));
  674. break;
  675. case 'clocelise':
  676. transform.deg += rotateDeg;
  677. break;
  678. case 'anticlocelise':
  679. transform.deg -= rotateDeg;
  680. break;
  681. }
  682. transform.enableTransition = enableTransition;
  683. }
  684. },
  685. mounted: function mounted() {
  686. this.deviceSupportInstall();
  687. // add tabindex then wrapper can be focusable via Javascript
  688. // focus wrapper so arrow key can't cause inner scroll behavior underneath
  689. this.$refs['el-image-viewer__wrapper'].focus();
  690. }
  691. });
  692. // CONCATENATED MODULE: ./packages/image/src/image-viewer.vue?vue&type=script&lang=js&
  693. /* harmony default export */ var src_image_viewervue_type_script_lang_js_ = (image_viewervue_type_script_lang_js_);
  694. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  695. var componentNormalizer = __webpack_require__(2);
  696. // CONCATENATED MODULE: ./packages/image/src/image-viewer.vue
  697. /* normalize component */
  698. var component = Object(componentNormalizer["a" /* default */])(
  699. src_image_viewervue_type_script_lang_js_,
  700. image_viewervue_type_template_id_5e73b307_render,
  701. image_viewervue_type_template_id_5e73b307_staticRenderFns,
  702. false,
  703. null,
  704. null,
  705. null
  706. )
  707. /* hot reload */
  708. if (false) { var api; }
  709. component.options.__file = "packages/image/src/image-viewer.vue"
  710. /* harmony default export */ var image_viewer = (component.exports);
  711. // EXTERNAL MODULE: external "tis-ui/lib/mixins/locale"
  712. var locale_ = __webpack_require__(38);
  713. var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
  714. // EXTERNAL MODULE: external "tis-ui/lib/utils/types"
  715. var types_ = __webpack_require__(89);
  716. // EXTERNAL MODULE: external "throttle-debounce/throttle"
  717. var throttle_ = __webpack_require__(108);
  718. var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle_);
  719. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/image/src/main.vue?vue&type=script&lang=js&
  720. //
  721. //
  722. //
  723. //
  724. //
  725. //
  726. //
  727. //
  728. //
  729. //
  730. //
  731. //
  732. //
  733. //
  734. //
  735. //
  736. //
  737. //
  738. //
  739. //
  740. //
  741. //
  742. //
  743. var isSupportObjectFit = function isSupportObjectFit() {
  744. return document.documentElement.style.objectFit !== undefined;
  745. };
  746. var ObjectFit = {
  747. NONE: 'none',
  748. CONTAIN: 'contain',
  749. COVER: 'cover',
  750. FILL: 'fill',
  751. SCALE_DOWN: 'scale-down'
  752. };
  753. var prevOverflow = '';
  754. /* harmony default export */ var mainvue_type_script_lang_js_ = ({
  755. name: 'TisImage',
  756. mixins: [locale_default.a],
  757. inheritAttrs: false,
  758. components: {
  759. ImageViewer: image_viewer
  760. },
  761. props: {
  762. src: String,
  763. fit: String,
  764. lazy: Boolean,
  765. scrollContainer: {},
  766. previewSrcList: {
  767. type: Array,
  768. default: function _default() {
  769. return [];
  770. }
  771. },
  772. zIndex: {
  773. type: Number,
  774. default: 2000
  775. }
  776. },
  777. data: function data() {
  778. return {
  779. loading: true,
  780. error: false,
  781. show: !this.lazy,
  782. imageWidth: 0,
  783. imageHeight: 0,
  784. showViewer: false
  785. };
  786. },
  787. computed: {
  788. imageStyle: function imageStyle() {
  789. var fit = this.fit;
  790. if (!this.$isServer && fit) {
  791. return isSupportObjectFit() ? { 'object-fit': fit } : this.getImageStyle(fit);
  792. }
  793. return {};
  794. },
  795. alignCenter: function alignCenter() {
  796. return !this.$isServer && !isSupportObjectFit() && this.fit !== ObjectFit.FILL;
  797. },
  798. preview: function preview() {
  799. var previewSrcList = this.previewSrcList;
  800. return Array.isArray(previewSrcList) && previewSrcList.length > 0;
  801. },
  802. imageIndex: function imageIndex() {
  803. var previewIndex = 0;
  804. var srcIndex = this.previewSrcList.indexOf(this.src);
  805. if (srcIndex >= 0) {
  806. previewIndex = srcIndex;
  807. }
  808. return previewIndex;
  809. }
  810. },
  811. watch: {
  812. src: function src(val) {
  813. this.show && this.loadImage();
  814. },
  815. show: function show(val) {
  816. val && this.loadImage();
  817. }
  818. },
  819. mounted: function mounted() {
  820. if (this.lazy) {
  821. this.addLazyLoadListener();
  822. } else {
  823. this.loadImage();
  824. }
  825. },
  826. beforeDestroy: function beforeDestroy() {
  827. this.lazy && this.removeLazyLoadListener();
  828. },
  829. methods: {
  830. loadImage: function loadImage() {
  831. var _this = this;
  832. if (this.$isServer) return;
  833. // reset status
  834. this.loading = true;
  835. this.error = false;
  836. var img = new Image();
  837. img.onload = function (e) {
  838. return _this.handleLoad(e, img);
  839. };
  840. img.onerror = this.handleError.bind(this);
  841. // bind html attrs
  842. // so it can behave consistently
  843. Object.keys(this.$attrs).forEach(function (key) {
  844. var value = _this.$attrs[key];
  845. img.setAttribute(key, value);
  846. });
  847. img.src = this.src;
  848. },
  849. handleLoad: function handleLoad(e, img) {
  850. this.imageWidth = img.width;
  851. this.imageHeight = img.height;
  852. this.loading = false;
  853. this.error = false;
  854. },
  855. handleError: function handleError(e) {
  856. this.loading = false;
  857. this.error = true;
  858. this.$emit('error', e);
  859. },
  860. handleLazyLoad: function handleLazyLoad() {
  861. if (Object(dom_["isInContainer"])(this.$el, this._scrollContainer)) {
  862. this.show = true;
  863. this.removeLazyLoadListener();
  864. }
  865. },
  866. addLazyLoadListener: function addLazyLoadListener() {
  867. if (this.$isServer) return;
  868. var scrollContainer = this.scrollContainer;
  869. var _scrollContainer = null;
  870. if (Object(types_["isHtmlElement"])(scrollContainer)) {
  871. _scrollContainer = scrollContainer;
  872. } else if (Object(types_["isString"])(scrollContainer)) {
  873. _scrollContainer = document.querySelector(scrollContainer);
  874. } else {
  875. _scrollContainer = Object(dom_["getScrollContainer"])(this.$el);
  876. }
  877. if (_scrollContainer) {
  878. this._scrollContainer = _scrollContainer;
  879. this._lazyLoadHandler = throttle_default()(200, this.handleLazyLoad);
  880. Object(dom_["on"])(_scrollContainer, 'scroll', this._lazyLoadHandler);
  881. this.handleLazyLoad();
  882. }
  883. },
  884. removeLazyLoadListener: function removeLazyLoadListener() {
  885. var _scrollContainer = this._scrollContainer,
  886. _lazyLoadHandler = this._lazyLoadHandler;
  887. if (this.$isServer || !_scrollContainer || !_lazyLoadHandler) return;
  888. Object(dom_["off"])(_scrollContainer, 'scroll', _lazyLoadHandler);
  889. this._scrollContainer = null;
  890. this._lazyLoadHandler = null;
  891. },
  892. /**
  893. * simulate object-fit behavior to compatible with IE11 and other browsers which not support object-fit
  894. */
  895. getImageStyle: function getImageStyle(fit) {
  896. var imageWidth = this.imageWidth,
  897. imageHeight = this.imageHeight;
  898. var _$el = this.$el,
  899. containerWidth = _$el.clientWidth,
  900. containerHeight = _$el.clientHeight;
  901. if (!imageWidth || !imageHeight || !containerWidth || !containerHeight) return {};
  902. var vertical = imageWidth / imageHeight < 1;
  903. if (fit === ObjectFit.SCALE_DOWN) {
  904. var isSmaller = imageWidth < containerWidth && imageHeight < containerHeight;
  905. fit = isSmaller ? ObjectFit.NONE : ObjectFit.CONTAIN;
  906. }
  907. switch (fit) {
  908. case ObjectFit.NONE:
  909. return { width: 'auto', height: 'auto' };
  910. case ObjectFit.CONTAIN:
  911. return vertical ? { width: 'auto' } : { height: 'auto' };
  912. case ObjectFit.COVER:
  913. return vertical ? { height: 'auto' } : { width: 'auto' };
  914. default:
  915. return {};
  916. }
  917. },
  918. clickHandler: function clickHandler() {
  919. // don't show viewer when preview is false
  920. if (!this.preview) {
  921. return;
  922. }
  923. // prevent body scroll
  924. prevOverflow = document.body.style.overflow;
  925. document.body.style.overflow = 'hidden';
  926. this.showViewer = true;
  927. },
  928. closeViewer: function closeViewer() {
  929. document.body.style.overflow = prevOverflow;
  930. this.showViewer = false;
  931. }
  932. }
  933. });
  934. // CONCATENATED MODULE: ./packages/image/src/main.vue?vue&type=script&lang=js&
  935. /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
  936. // CONCATENATED MODULE: ./packages/image/src/main.vue
  937. /* normalize component */
  938. var main_component = Object(componentNormalizer["a" /* default */])(
  939. src_mainvue_type_script_lang_js_,
  940. render,
  941. staticRenderFns,
  942. false,
  943. null,
  944. null,
  945. null
  946. )
  947. /* hot reload */
  948. if (false) { var main_api; }
  949. main_component.options.__file = "packages/image/src/main.vue"
  950. /* harmony default export */ var main = (main_component.exports);
  951. // CONCATENATED MODULE: ./packages/image/index.js
  952. /* istanbul ignore next */
  953. main.install = function (Vue) {
  954. Vue.component(main.name, main);
  955. };
  956. /* harmony default export */ var packages_image = __webpack_exports__["default"] = (main);
  957. /***/ }),
  958. /***/ 7:
  959. /***/ (function(module, exports) {
  960. module.exports = require("tis-ui/lib/utils/dom");
  961. /***/ }),
  962. /***/ 89:
  963. /***/ (function(module, exports) {
  964. module.exports = require("tis-ui/lib/utils/types");
  965. /***/ })
  966. /******/ });