UNPKG

yk-smart-ui-test

Version:

A Component Library for Vue.js.

591 lines (500 loc) 19.1 kB
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 = 171); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports) { module.exports = require("vue"); /***/ }), /***/ 1: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return on; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return off; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return once; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return hasClass; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return addClass; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return removeClass; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getStyle; }); /* unused harmony export setStyle */ /* unused harmony export isScroll */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getScrollContainer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return isInContainer; }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* istanbul ignore next */ var isServer = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer; var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; var MOZ_HACK_REGEXP = /^moz([A-Z])/; var ieVersion = isServer ? 0 : Number(document.documentMode); /* istanbul ignore next */ var trim = function trim(string) { return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, ''); }; /* istanbul ignore next */ var camelCase = function camelCase(name) { return name.replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) { return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, 'Moz$1'); }; /* istanbul ignore next */ var on = function () { if (!isServer && document.addEventListener) { return function (element, event, handler) { if (element && event && handler) { element.addEventListener(event, handler, false); } }; } else { return function (element, event, handler) { if (element && event && handler) { element.attachEvent('on' + event, handler); } }; } }(); /* istanbul ignore next */ var off = function () { if (!isServer && document.removeEventListener) { return function (element, event, handler) { if (element && event) { element.removeEventListener(event, handler, false); } }; } else { return function (element, event, handler) { if (element && event) { element.detachEvent('on' + event, handler); } }; } }(); /* istanbul ignore next */ var once = function once(el, event, fn) { var listener = function listener() { if (fn) { fn.apply(this, arguments); } off(el, event, listener); }; on(el, event, listener); }; /* istanbul ignore next */ function hasClass(el, cls) { if (!el || !cls) return false; if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.'); if (el.classList) { return el.classList.contains(cls); } else { return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1; } }; /* istanbul ignore next */ function addClass(el, cls) { if (!el) return; var curClass = el.className; var classes = (cls || '').split(' '); for (var i = 0, j = classes.length; i < j; i++) { var clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.add(clsName); } else if (!hasClass(el, clsName)) { curClass += ' ' + clsName; } } if (!el.classList) { el.setAttribute('class', curClass); } }; /* istanbul ignore next */ function removeClass(el, cls) { if (!el || !cls) return; var classes = cls.split(' '); var curClass = ' ' + el.className + ' '; for (var i = 0, j = classes.length; i < j; i++) { var clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.remove(clsName); } else if (hasClass(el, clsName)) { curClass = curClass.replace(' ' + clsName + ' ', ' '); } } if (!el.classList) { el.setAttribute('class', trim(curClass)); } }; /* istanbul ignore next */ var getStyle = ieVersion < 9 ? function (element, styleName) { if (isServer) return; if (!element || !styleName) return null; styleName = camelCase(styleName); if (styleName === 'float') { styleName = 'styleFloat'; } try { switch (styleName) { case 'opacity': try { return element.filters.item('alpha').opacity / 100; } catch (e) { return 1.0; } default: return element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null; } } catch (e) { return element.style[styleName]; } } : function (element, styleName) { if (isServer) return; if (!element || !styleName) return null; styleName = camelCase(styleName); if (styleName === 'float') { styleName = 'cssFloat'; } try { var computed = document.defaultView.getComputedStyle(element, ''); return element.style[styleName] || computed ? computed[styleName] : null; } catch (e) { return element.style[styleName]; } }; /* istanbul ignore next */ function setStyle(element, styleName, value) { if (!element || !styleName) return; if ((typeof styleName === 'undefined' ? 'undefined' : _typeof(styleName)) === 'object') { for (var prop in styleName) { if (styleName.hasOwnProperty(prop)) { setStyle(element, prop, styleName[prop]); } } } else { styleName = camelCase(styleName); if (styleName === 'opacity' && ieVersion < 9) { element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')'; } else { element.style[styleName] = value; } } }; var isScroll = function isScroll(el, vertical) { if (isServer) return; var determinedDirection = vertical !== null && vertical !== undefined; var overflow = determinedDirection ? vertical ? getStyle(el, 'overflow-y') : getStyle(el, 'overflow-x') : getStyle(el, 'overflow'); return overflow.match(/(scroll|auto|overlay)/); }; var getScrollContainer = function getScrollContainer(el, vertical) { if (isServer) return; var parent = el; while (parent) { if ([window, document, document.documentElement].includes(parent)) { return window; } if (isScroll(parent, vertical)) { return parent; } parent = parent.parentNode; } return parent; }; var isInContainer = function isInContainer(el, container) { if (isServer || !el || !container) return false; var elRect = el.getBoundingClientRect(); var containerRect = void 0; if ([window, document, document.documentElement, null, undefined].includes(container)) { containerRect = { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0 }; } else { containerRect = container.getBoundingClientRect(); } return elRect.top < containerRect.bottom && elRect.bottom > containerRect.top && elRect.right > containerRect.left && elRect.left < containerRect.right; }; /***/ }), /***/ 171: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXTERNAL MODULE: external "throttle-debounce/debounce" var debounce_ = __webpack_require__(21); var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce_); // EXTERNAL MODULE: ./src/utils/types.js var types = __webpack_require__(5); // EXTERNAL MODULE: ./src/utils/dom.js var dom = __webpack_require__(1); // CONCATENATED MODULE: ./packages/infinite-scroll/src/main.js var getStyleComputedProperty = function getStyleComputedProperty(element, property) { if (element === window) { element = document.documentElement; } if (element.nodeType !== 1) { return []; } // NOTE: 1 DOM access here var css = window.getComputedStyle(element, null); return property ? css[property] : css; }; var entries = function entries(obj) { return Object.keys(obj || {}).map(function (key) { return [key, obj[key]]; }); }; var getPositionSize = function getPositionSize(el, prop) { return el === window || el === document ? document.documentElement[prop] : el[prop]; }; var getOffsetHeight = function getOffsetHeight(el) { return getPositionSize(el, 'offsetHeight'); }; var getClientHeight = function getClientHeight(el) { return getPositionSize(el, 'clientHeight'); }; var scope = 'YkInfiniteScroll'; var attributes = { delay: { type: Number, default: 200 }, distance: { type: Number, default: 0 }, disabled: { type: Boolean, default: false }, immediate: { type: Boolean, default: true } }; var main_getScrollOptions = function getScrollOptions(el, vm) { if (!Object(types["c" /* isHtmlElement */])(el)) return {}; return entries(attributes).reduce(function (map, _ref) { var key = _ref[0], option = _ref[1]; var type = option.type, defaultValue = option.default; var value = el.getAttribute('infinite-scroll-' + key); value = Object(types["f" /* isUndefined */])(vm[value]) ? value : vm[value]; switch (type) { case Number: value = Number(value); value = Number.isNaN(value) ? defaultValue : value; break; case Boolean: value = Object(types["a" /* isDefined */])(value) ? value === 'false' ? false : Boolean(value) : defaultValue; break; default: value = type(value); } map[key] = value; return map; }, {}); }; var getElementTop = function getElementTop(el) { return el.getBoundingClientRect().top; }; var main_handleScroll = function handleScroll(cb) { var _scope = this[scope], el = _scope.el, vm = _scope.vm, container = _scope.container, observer = _scope.observer; var _getScrollOptions = main_getScrollOptions(el, vm), distance = _getScrollOptions.distance, disabled = _getScrollOptions.disabled; if (disabled) return; var containerInfo = container.getBoundingClientRect(); if (!containerInfo.width && !containerInfo.height) return; var shouldTrigger = false; if (container === el) { // be aware of difference between clientHeight & offsetHeight & window.getComputedStyle().height var scrollBottom = container.scrollTop + getClientHeight(container); shouldTrigger = container.scrollHeight - scrollBottom <= distance; } else { var heightBelowTop = getOffsetHeight(el) + getElementTop(el) - getElementTop(container); var offsetHeight = getOffsetHeight(container); var borderBottom = Number.parseFloat(getStyleComputedProperty(container, 'borderBottomWidth')); shouldTrigger = heightBelowTop - offsetHeight + borderBottom <= distance; } if (shouldTrigger && Object(types["b" /* isFunction */])(cb)) { cb.call(vm); } else if (observer) { observer.disconnect(); this[scope].observer = null; } }; /* harmony default export */ var main = ({ name: 'InfiniteScroll', inserted: function inserted(el, binding, vnode) { var cb = binding.value; var vm = vnode.context; // only include vertical scroll var container = Object(dom["b" /* getScrollContainer */])(el, true); var _getScrollOptions2 = main_getScrollOptions(el, vm), delay = _getScrollOptions2.delay, immediate = _getScrollOptions2.immediate; var onScroll = debounce_default()(delay, main_handleScroll.bind(el, cb)); el[scope] = { el: el, vm: vm, container: container, onScroll: onScroll }; if (container) { container.addEventListener('scroll', onScroll); if (immediate) { var observer = el[scope].observer = new MutationObserver(onScroll); observer.observe(container, { childList: true, subtree: true }); onScroll(); } } }, unbind: function unbind(el) { var _el$scope = el[scope], container = _el$scope.container, onScroll = _el$scope.onScroll; if (container) { container.removeEventListener('scroll', onScroll); } } }); // CONCATENATED MODULE: ./packages/infinite-scroll/index.js /* istanbul ignore next */ main.install = function (Vue) { Vue.directive(main.name, main); }; /* harmony default export */ var infinite_scroll = __webpack_exports__["default"] = (main); /***/ }), /***/ 21: /***/ (function(module, exports) { module.exports = require("throttle-debounce/debounce"); /***/ }), /***/ 5: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return isString; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return isObject; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isHtmlElement; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isFunction; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return isUndefined; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isDefined; }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; function isString(obj) { return Object.prototype.toString.call(obj) === '[object String]'; } function isObject(obj) { return Object.prototype.toString.call(obj) === '[object Object]'; } function isHtmlElement(node) { return node && node.nodeType === Node.ELEMENT_NODE; } /** * - Inspired: * https://github.com/jashkenas/underscore/blob/master/modules/isFunction.js */ var isFunction = function isFunction(functionToCheck) { var getType = {}; return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; }; if ( true && (typeof Int8Array === 'undefined' ? 'undefined' : _typeof(Int8Array)) !== 'object' && (vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer || typeof document.childNodes !== 'function')) { isFunction = function isFunction(obj) { return typeof obj === 'function' || false; }; } var isUndefined = function isUndefined(val) { return val === void 0; }; var isDefined = function isDefined(val) { return val !== undefined && val !== null; }; /***/ }) /******/ });