kingdot
Version:
A UI Components Library For Vue
1,187 lines (1,089 loc) • 38.2 kB
JavaScript
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 228);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
/* globals __VUE_SSR_CONTEXT__ */
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.
function normalizeComponent (
scriptExports,
render,
staticRenderFns,
functionalTemplate,
injectStyles,
scopeId,
moduleIdentifier, /* server only */
shadowMode /* vue-cli only */
) {
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (render) {
options.render = render
options.staticRenderFns = staticRenderFns
options._compiled = true
}
// functional template
if (functionalTemplate) {
options.functional = true
}
// scopedId
if (scopeId) {
options._scopeId = 'data-v-' + scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = shadowMode
? function () {
injectStyles.call(
this,
(options.functional ? this.parent : this).$root.$options.shadowRoot
)
}
: injectStyles
}
if (hook) {
if (options.functional) {
// for template-only hot-reload because in that case the render fn doesn't
// go through the normalizer
options._injectStyles = hook
// register for functional component in vue file
var originalRender = options.render
options.render = function renderWithStyleInjection (h, context) {
hook.call(context)
return originalRender(h, context)
}
} else {
// inject component registration as beforeCreate hook
var existing = options.beforeCreate
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
}
}
return {
exports: scriptExports,
options: options
}
}
/***/ }),
/***/ 228:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/Cascader/cascader.vue?vue&type=template&id=62848b20&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"kdCascader",staticClass:"kd-cascader",class:[{
'kd-cascader-disabled': _vm.disabled
}],style:({'width': _vm.inputWidth})},[_c('kd-tooltip',{ref:"kdCasacderTooltip",attrs:{"placement":"bottom-start","trigger":"click","showArrow":false,"content-class":_vm.tooltipClass,"width-limit":false,"disabled":_vm.disabled},model:{value:(_vm.dropDownVisible),callback:function ($$v) {_vm.dropDownVisible=$$v},expression:"dropDownVisible"}},[_c('div',{ref:"kdCascaderInput",staticClass:"kd-cascader-input",on:{"mouseenter":function($event){_vm.inputHovering = true},"mouseleave":function($event){_vm.inputHovering = false}}},[(_vm.clearBtnVisible)?_c('i',{key:"clear",staticClass:"kd-icon-close kd-cascader-clear-icon",on:{"click":function($event){$event.stopPropagation();return _vm.handleClear($event)}}}):_c('i',{key:"arrow-down",staticClass:"kd-icon-arrow-down kd-cascader-arrow-icon",class:{'kd-cascader-arrow-icon-rotate': _vm.dropDownVisible}}),(_vm.multiple)?_c('div',{staticClass:"kd-cascader-tags"},[_vm._l((_vm.presentTags),function(tag){return _c('kd-tag',{key:tag.key,attrs:{"size":"small","color":"#909399","backgroundColor":"#f0f2f5","borderColor":"#e9e9eb","isSolid":"","closable":tag.closable},on:{"close":function($event){$event.stopPropagation();return _vm.deleteTag(tag)}}},[_c('span',[_vm._v(_vm._s(tag.text))])])}),(_vm.filterable || _vm.presentTags.length === 0)?_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.inputLabel),expression:"inputLabel"}],ref:"kdCascaderInputInnerMulti",staticClass:"kd-cascader-multi-input-inner",class:{'kd-cascader-input-disabled': _vm.disabled},attrs:{"type":"text","placeholder":_vm.presentTags.length ? '' : _vm.inputPlaceholder,"readonly":!_vm.filterable,"disabled":_vm.disabled},domProps:{"value":(_vm.inputLabel)},on:{"input":[function($event){if($event.target.composing){ return; }_vm.inputLabel=$event.target.value},_vm.handleInput],"focus":_vm.handleFocus,"blur":_vm.handleBlur}}):_vm._e()],2):_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.inputLabel),expression:"inputLabel"}],ref:"kdCascaderInputInner",staticClass:"kd-cascader-input-inner",class:{'kd-cascader-input-disabled': _vm.disabled},attrs:{"type":"text","placeholder":_vm.presentTags.length ? '' : _vm.inputPlaceholder,"readonly":!_vm.filterable,"disabled":_vm.disabled},domProps:{"value":(_vm.inputLabel)},on:{"input":[function($event){if($event.target.composing){ return; }_vm.inputLabel=$event.target.value},_vm.handleInput],"focus":_vm.handleFocus,"blur":_vm.handleBlur}})]),_c('template',{slot:"content"},[(_vm.filterable)?_c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.filtering),expression:"filtering"}],ref:"kdCascaderSuggest",staticClass:"kd-cascader-suggest",style:({'width': _vm.suggestWidth})},[_vm._l((_vm.suggestions),function(item,index){return _c('li',{key:index,staticClass:"kd-cascader-suggest-li",class:[{
'is-active': item.checked,
'is-disabled': item.isDisabled
}],on:{"click":function($event){return _vm.handleClickSuggest(item)}}},[_c('span',[_vm._v(_vm._s(item.labelText))]),(item.checked)?_c('i',{staticClass:"kd-icon-success kd-cascader-checked-icon"}):_vm._e()])}),(_vm.suggestions.length==0)?_c('li',{staticClass:"kd-cascader-suggest-no-data"},[_vm._v("无数据")]):_vm._e()],2):_vm._e(),_c('kd-cascader-panel',{directives:[{name:"show",rawName:"v-show",value:(!_vm.filtering),expression:"!filtering"}],ref:"kdPopperPanel",attrs:{"options":_vm.options,"expandTrigger":_vm.expandTrigger,"cascader":this,"lazy":_vm.lazy,"lazyMethod":_vm.lazyMethod,"labelName":_vm.labelName,"valueName":_vm.valueName,"multiple":_vm.multiple,"checkStrictly":_vm.checkStrictly},on:{"setLabel":_vm.setLabel,"handleExpand":_vm.handleExpandChange},model:{value:(_vm.checkedValue),callback:function ($$v) {_vm.checkedValue=$$v},expression:"checkedValue"}})],1)],2)],1)}
var staticRenderFns = []
// CONCATENATED MODULE: ./components/Cascader/cascader.vue?vue&type=template&id=62848b20&
// EXTERNAL MODULE: ./src/utils/utils.js + 1 modules
var utils = __webpack_require__(3);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/Cascader/cascader.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var cascadervue_type_script_lang_js_ = ({
name: 'KdCascader',
components: {},
mixins: [],
props: {
value: {
type: Array,
default: function _default() {
return [];
}
},
options: {
type: Array
},
disabled: {
type: Boolean,
default: false
},
width: {
type: String,
default: ''
},
filterable: {
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: '请选择'
},
// 次级菜单的展开方式
expandTrigger: {
type: String,
default: 'click'
},
showAllLevels: {
type: Boolean,
default: true
},
lazy: {
type: Boolean,
default: false
},
lazyMethod: {
type: Function
},
filterMethod: {
type: Function
},
// 展示字段name
labelName: {
type: String,
default: 'label'
},
// 取值字段name
valueName: {
type: String,
default: 'value'
},
// 多选
multiple: {
type: Boolean,
default: false
},
// 多选时是否折叠展示
collapseTags: {
type: Boolean,
default: false
},
// 选择任意一级选项
checkStrictly: {
type: Boolean,
default: false
}
},
data: function data() {
return {
checkedValue: this.value,
inputLabel: null,
inputPlaceholder: this.placeholder,
dropDownVisible: false,
inputHovering: false,
filtering: false,
suggestions: [],
suggestWidth: '',
presentTags: [],
multiCheckedNodes: []
};
},
computed: {
tooltipClass: function tooltipClass() {
return 'kd-cascader-tooltip';
},
inputWidth: function inputWidth() {
var width = this.width;
if (width.indexOf('px') > -1 || width.indexOf('%') > -1) {
return width;
} else {
return width + 'px';
}
},
clearBtnVisible: function clearBtnVisible() {
return this.clearable && !Object(utils["c" /* isEmpty */])(this.checkedValue) && this.inputHovering;
},
panel: function panel() {
return this.$refs.kdPopperPanel;
}
},
watch: {
value: {
deep: true,
handler: function handler(val) {
if (!Object(utils["b" /* arrayEquals */])(val, this.checkedValue)) {
this.checkedValue = val;
this.setLabel();
}
}
},
checkedValue: {
deep: true,
handler: function handler(val) {
var value = this.value,
dropDownVisible = this.dropDownVisible,
checkStrictly = this.checkStrictly,
multiple = this.multiple;
if (val === void 0 || !Object(utils["b" /* arrayEquals */])(val, value)) {
this.setLabel();
if (!multiple && !checkStrictly && dropDownVisible) {
this.toggleDropDownVisible();
}
this.$emit('input', val);
this.$emit('change', val);
}
}
},
filtering: function filtering(val) {
if (val) {
this.suggestWidth = this.$refs.kdCascader.clientWidth + 'px';
this.updateSuggestList();
}
},
dropDownVisible: {
handler: function handler(val) {
var _this = this;
if (val) {
this.filtering = false;
this.$nextTick(function () {
_this.panel && _this.panel.scrollToView();
});
} else {
if (this.filterable && this.inputLabel && this.filtering) {
this.setLabel();
}
}
}
},
inputLabel: function inputLabel(val) {
if (!val && this.filterable) this.filtering = false;
},
options: {
handler: function handler() {
this.$nextTick(this.setLabel);
},
deep: true
}
},
mounted: function mounted() {
if (!Object(utils["c" /* isEmpty */])(this.value)) {
this.setLabel();
}
},
methods: {
setLabel: function setLabel() {
var _this2 = this;
this.$nextTick(function () {
if (_this2.multiple) {
_this2.computePresentTags();
_this2.inputLabel = _this2.presentTags.length ? '' : null;
} else {
_this2.getPresentLabel();
}
});
},
getPresentLabel: function getPresentLabel() {
var checkedValue = this.checkedValue,
checkStrictly = this.checkStrictly;
if (!Object(utils["c" /* isEmpty */])(checkedValue)) {
var node = this.panel && this.panel.getNodeByValue(checkedValue);
if (node && (checkStrictly || node.isLeaf)) {
this.inputLabel = this.showAllLevels ? node.labelText : node.label;
return;
}
}
this.inputLabel = null;
},
// 可清除
handleClear: function handleClear() {
if (this.multiple) {
this.presentTags = [];
this.checkedValue = [];
} else {
this.checkedValue.splice(0);
this.inputLabel = '';
this.suggestions = [];
}
this.$emit('input', this.checkedValue);
this.$emit('change', this.checkedValue);
},
toggleDropDownVisible: function toggleDropDownVisible() {
this.dropDownVisible = !this.dropDownVisible;
},
handleExpandChange: function handleExpandChange() {
if (this.dropDownVisible && this.$refs.kdCasacderTooltip) this.$refs.kdCasacderTooltip.updatePopper();
},
// 可搜索
handleInput: function handleInput() {
this.filtering = this.inputLabel || false;
},
updateSuggestList: function updateSuggestList() {
var _this3 = this;
var method = function method(node, label) {
return node.labelText.includes(label);
};
if (Object(utils["d" /* isFunction */])(this.filterMethod)) {
method = this.filterMethod;
}
var flatOpt = this.panel ? this.panel.flatOpt : [];
this.suggestions = flatOpt.filter(function (item) {
return method(item, _this3.inputLabel) && item.isLeaf;
});
if (!Object(utils["c" /* isEmpty */])(this.checkedValue)) {
this.suggestions.forEach(function (node) {
if (_this3.multiple) {
node.checked = node.isContainNode(_this3.checkedValue);
} else {
node.checked = Object(utils["b" /* arrayEquals */])(_this3.checkedValue, node.pathValue);
}
});
} else {
this.suggestions.forEach(function (node) {
node.checked = false;
});
}
},
handleClickSuggest: function handleClickSuggest(node) {
if (node.isDisabled) return;
if (this.multiple) {
var checked = node.checked;
if (checked) return;
node.multiCheck(!checked);
this.panel.calcMultiCheckedValue();
} else {
this.checkedValue = node.pathValue;
this.inputLabel = node.labelText;
}
this.filtering = false;
this.toggleDropDownVisible();
},
handleFocus: function handleFocus(e) {
this.$emit('focus', e);
},
handleBlur: function handleBlur(e) {
this.$emit('blur', e);
},
// 多选
computePresentTags: function computePresentTags() {
var tags = [];
var nodes = this.panel.calcMultiCheckedNodes();
var showAllLevels = this.showAllLevels,
collapseTags = this.collapseTags,
disabled = this.disabled;
var genTag = function genTag(node) {
return {
node: node,
key: node.uid,
text: showAllLevels ? node.labelText : node.label,
closable: !disabled && !node.isDisabled
};
};
var len = nodes.length;
if (len) {
tags.push(genTag(nodes[0]));
if (len > 1) {
if (collapseTags) {
tags.push({
key: -1,
text: '+ ' + (len - 1),
closable: false
});
} else {
nodes.slice(1).forEach(function (node) {
return tags.push(genTag(node));
});
}
}
}
this.multiCheckedNodes = nodes;
this.presentTags = tags;
},
deleteTag: function deleteTag(tag) {
var checkedValue = this.checkedValue;
this.checkedValue = checkedValue.filter(function (n) {
return !Object(utils["b" /* arrayEquals */])(n, tag.node.pathValue);
});
var node = checkedValue.find(function (n) {
return Object(utils["b" /* arrayEquals */])(n, tag.node.pathValue);
});
this.$emit('removeTag', node);
}
}
});
// CONCATENATED MODULE: ./components/Cascader/cascader.vue?vue&type=script&lang=js&
/* harmony default export */ var Cascader_cascadervue_type_script_lang_js_ = (cascadervue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/Cascader/cascader.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
Cascader_cascadervue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var cascader = (component.exports);
// CONCATENATED MODULE: ./components/Cascader/index.js
cascader.install = function (Vue) {
Vue.component(cascader.name, cascader);
};
/* harmony default export */ var Cascader = __webpack_exports__["default"] = (cascader);
/***/ }),
/***/ 27:
/***/ (function(module, exports) {
/***/ }),
/***/ 3:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXPORTS
__webpack_require__.d(__webpack_exports__, "g", function() { return /* binding */ utils_ulid; });
__webpack_require__.d(__webpack_exports__, "f", function() { return /* binding */ mouseDragBegin; });
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ animationFrame; });
__webpack_require__.d(__webpack_exports__, "e", function() { return /* binding */ isIe; });
__webpack_require__.d(__webpack_exports__, "c", function() { return /* binding */ isEmpty; });
__webpack_require__.d(__webpack_exports__, "d", function() { return /* binding */ isFunction; });
__webpack_require__.d(__webpack_exports__, "b", function() { return /* binding */ arrayEquals; });
// UNUSED EXPORTS: isNumber, _$, getElementInScroll, getScrollbarWidth, getStyle, stopPropagation
// CONCATENATED MODULE: ./node_modules/ulid/dist/index.esm.js
function createError(message) {
var err = new Error(message);
err.source = "ulid";
return err;
}
// These values should NEVER change. If
// they do, we're no longer making ulids!
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; // Crockford's Base32
var ENCODING_LEN = ENCODING.length;
var TIME_MAX = Math.pow(2, 48) - 1;
var TIME_LEN = 10;
var RANDOM_LEN = 16;
function replaceCharAt(str, index, char) {
if (index > str.length - 1) {
return str;
}
return str.substr(0, index) + char + str.substr(index + 1);
}
function incrementBase32(str) {
var done = undefined;
var index = str.length;
var char = void 0;
var charIndex = void 0;
var maxCharIndex = ENCODING_LEN - 1;
while (!done && index-- >= 0) {
char = str[index];
charIndex = ENCODING.indexOf(char);
if (charIndex === -1) {
throw createError("incorrectly encoded string");
}
if (charIndex === maxCharIndex) {
str = replaceCharAt(str, index, ENCODING[0]);
continue;
}
done = replaceCharAt(str, index, ENCODING[charIndex + 1]);
}
if (typeof done === "string") {
return done;
}
throw createError("cannot increment this string");
}
function randomChar(prng) {
var rand = Math.floor(prng() * ENCODING_LEN);
if (rand === ENCODING_LEN) {
rand = ENCODING_LEN - 1;
}
return ENCODING.charAt(rand);
}
function encodeTime(now, len) {
if (isNaN(now)) {
throw new Error(now + " must be a number");
}
if (now > TIME_MAX) {
throw createError("cannot encode time greater than " + TIME_MAX);
}
if (now < 0) {
throw createError("time must be positive");
}
if (Number.isInteger(now) === false) {
throw createError("time must be an integer");
}
var mod = void 0;
var str = "";
for (; len > 0; len--) {
mod = now % ENCODING_LEN;
str = ENCODING.charAt(mod) + str;
now = (now - mod) / ENCODING_LEN;
}
return str;
}
function encodeRandom(len, prng) {
var str = "";
for (; len > 0; len--) {
str = randomChar(prng) + str;
}
return str;
}
function decodeTime(id) {
if (id.length !== TIME_LEN + RANDOM_LEN) {
throw createError("malformed ulid");
}
var time = id.substr(0, TIME_LEN).split("").reverse().reduce(function (carry, char, index) {
var encodingIndex = ENCODING.indexOf(char);
if (encodingIndex === -1) {
throw createError("invalid character found: " + char);
}
return carry += encodingIndex * Math.pow(ENCODING_LEN, index);
}, 0);
if (time > TIME_MAX) {
throw createError("malformed ulid, timestamp too large");
}
return time;
}
function detectPrng() {
var allowInsecure = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var root = arguments[1];
if (!root) {
root = typeof window !== "undefined" ? window : null;
}
var browserCrypto = root && (root.crypto || root.msCrypto);
if (browserCrypto) {
return function () {
var buffer = new Uint8Array(1);
browserCrypto.getRandomValues(buffer);
return buffer[0] / 0xff;
};
} else {
try {
var nodeCrypto = __webpack_require__(27);
return function () {
return nodeCrypto.randomBytes(1).readUInt8() / 0xff;
};
} catch (e) {}
}
if (allowInsecure) {
try {
console.error("secure crypto unusable, falling back to insecure Math.random()!");
} catch (e) {}
return function () {
return Math.random();
};
}
throw createError("secure crypto unusable, insecure Math.random not allowed");
}
function factory(currPrng) {
if (!currPrng) {
currPrng = detectPrng();
}
return function ulid(seedTime) {
if (isNaN(seedTime)) {
seedTime = Date.now();
}
return encodeTime(seedTime, TIME_LEN) + encodeRandom(RANDOM_LEN, currPrng);
};
}
function monotonicFactory(currPrng) {
if (!currPrng) {
currPrng = detectPrng();
}
var lastTime = 0;
var lastRandom = void 0;
return function ulid(seedTime) {
if (isNaN(seedTime)) {
seedTime = Date.now();
}
if (seedTime <= lastTime) {
var incrementedRandom = lastRandom = incrementBase32(lastRandom);
return encodeTime(lastTime, TIME_LEN) + incrementedRandom;
}
lastTime = seedTime;
var newRandom = lastRandom = encodeRandom(RANDOM_LEN, currPrng);
return encodeTime(seedTime, TIME_LEN) + newRandom;
};
}
var ulid = factory();
// CONCATENATED MODULE: ./src/utils/utils.js
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; };
var utils_ulid = function () {
var crypto = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto
if (!crypto || !crypto.getRandomValues) {
return factory(Math.random);
} else {
return factory();
}
}();
function isNullOrUndefined(o) {
return o === null || o === undefined;
}
function isNumber(o) {
return typeof o === 'number';
}
var pathMap = {};
var i18n = {};
var hasOwn = Object.prototype.hasOwnProperty;
var charCodeOfDot = '.'.charCodeAt(0);
var rePropName = RegExp(
// Match anything that isn't a dot or bracket.
'[^.[\\]]+' + '|' +
// Or match property names within brackets.
'\\[(?:' +
// Match a non-string expression.
"([^\"'].*)" + '|' +
// Or match strings (supports escaping characters).
"([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2" + ')\\]' + '|' +
// Or match "" as the space between consecutive dots or empty brackets.
'(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))', 'g');
// eslint-disable-next-line no-useless-escape
var valueRegexp = /\{([^\}\s]+)\}/g;
function castPath(path) {
if (typeof path !== 'string') return path;
if (pathMap[path]) return pathMap[path];
var result = [];
if (path.charCodeAt(0) === charCodeOfDot) {
result.push('');
}
path.replace(rePropName, function (match, expression, quote, subString) {
var key = match;
if (quote) {
// eslint-disable-next-line no-undef
key = subString.replace(reEscapeChar, '$1');
} else if (expression) {
key = expression;
}
result.push(key);
});
pathMap[path] = result;
return result;
}
function get(object, path, defaultValue) {
if (hasOwn.call(object, path)) return object[path];
path = castPath(path);
var index = 0;
var length = path.length;
while (!isNullOrUndefined(object) && index < length) {
object = object[path[index++]];
}
return index && index === length && object !== undefined ? object : defaultValue;
}
function _$(key, data) {
var value = get(i18n, key);
if (isNullOrUndefined(value)) {
value = key;
}
if (data) {
value = value.replace(valueRegexp, function (nouse, variable) {
var suffix = void 0;
var index = variable.indexOf(':');
if (index > 0) {
suffix = variable.substr(0, index);
suffix = suffix.split('|');
variable = variable.substr(index + 1);
variable = get(data, variable);
if (variable > 1) {
return suffix.length > 1 ? suffix[1] : suffix[0];
} else {
return suffix.length > 1 ? suffix[0] : '';
}
} else {
variable = get(data, variable);
return isNullOrUndefined(variable) ? nouse : variable;
}
});
}
return value;
}
function getElementInScroll(e, eqValue) {
if (typeof eqValue !== 'number') {
eqValue = eqValue.offsetHeight;
}
var data = e.getBoundingClientRect();
var clientHeight = document.body.clientHeight;
var selfHeight = e.offsetHeight;
var result = void 0;
if (clientHeight - data.y - selfHeight - eqValue > 0) {
result = true;
} else if (data.y - eqValue > 0) {
result = false;
} else {
result = true;
}
return result;
}
var _scrollbarWdith = null;
var _getScrollbarWidth = function _getScrollbarWidth() {
var odiv = document.createElement('div'); // 创建一个div
var styles = {
width: '100px',
height: '100px',
overflowY: 'scroll' // 让他有滚动条
};
var i;
var scrollbarWidth;
for (i in styles) {
odiv.style[i] = styles[i];
}odiv.setAttribute('id', 'tet_scroll');
document.body.appendChild(odiv); // 把div添加到body中
scrollbarWidth = odiv.offsetWidth - odiv.clientWidth; // 相减
_removeNode(odiv); // 移除创建的div
return scrollbarWidth; // 返回滚动条宽度
};
function _removeNode(node) {
node.remove ? node.remove() : node.parentElement.removeChild(node);
}
function getScrollbarWidth() {
if (!_scrollbarWdith) {
_scrollbarWdith = _getScrollbarWidth();
}
return _scrollbarWdith;
}
function getStyle(obj, attr, getNumber) {
var _result;
if (obj.currentStyle) {
_result = obj.currentStyle[attr];
} else {
_result = document.defaultView.getComputedStyle(obj, null)[attr];
}
return getNumber ? Number.parseInt(_result) : _result;
}
var windowPaddingMin = 1;
function mouseDragBegin(_ref, dragFn, endFn) {
var x = _ref.x,
y = _ref.y,
target = _ref.target;
var outBraking = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var startPosition = {
x: x,
y: y
};
var prePosition = {
x: x,
y: y
};
var _target$getClientRect = target.getClientRects()[0],
top = _target$getClientRect.top,
left = _target$getClientRect.left,
width = _target$getClientRect.width,
height = _target$getClientRect.height;
var _document$body = document.body,
offsetHeight = _document$body.offsetHeight,
offsetWidth = _document$body.offsetWidth;
var minLeft = (outBraking.left || windowPaddingMin) + (startPosition.x - left);
var minTop = (outBraking.top || windowPaddingMin) + (startPosition.y - top);
var maxTop = offsetHeight - height;
var maxLeft = offsetWidth - (outBraking.right || windowPaddingMin) - (width - (startPosition.x - left));
var mouseMove = function mouseMove(e) {
e = window.event || e;
var _x, _y;
if (minLeft > e.x) {
_x = minLeft;
} else if (e.x > maxLeft) {
_x = maxLeft;
} else {
_x = e.x;
}
if (e.y < minTop) {
_y = minTop;
} else if (e.y > maxTop) {
_y = maxTop;
} else {
_y = e.y;
}
prePosition = { x: _x, y: _y };
dragFn(startPosition, prePosition);
e.preventDefault();
};
var mouseUp = function mouseUp() {
endFn && endFn(startPosition, prePosition);
document.removeEventListener('mousemove', mouseMove);
document.removeEventListener('mouseup', mouseUp);
};
document.addEventListener('mousemove', mouseMove);
document.addEventListener('mouseup', mouseUp);
}
var _requestAnimationFrame = window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
function animationFrame(fn) {
return _requestAnimationFrame(fn);
}
function stopPropagation(event) {
window.event ? window.event.cancelBubble = true : event.stopPropagation();
}
var userAgent = navigator.userAgent; // 取得浏览器的userAgent字符串
// eslint-disable-next-line no-unused-vars
var isIE = userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1;
function isIe() {
var result = false;
var userAgent = navigator.userAgent; // 取得浏览器的userAgent字符串
var isIE = userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1; // 判断是否IE<11浏览器
var isEdge = userAgent.indexOf('Edge') > -1 && !isIE; // 判断是否IE的Edge浏览器
var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf('rv:11.0') > -1;
if (isIE || isEdge || isIE11) {
result = true;
} else {
result = false;
}
return result;
}
function isEmpty(val) {
// val 为 null、undefined 时
if (val == null) return true;
if (typeof val === 'number') return isNaN(val);
if (typeof val === 'boolean' || val instanceof RegExp) return false;
if (typeof val === 'string') return val.trim().length === 0;
if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') {
if (Object.prototype.toString.call(val) === '[object Array]') return !val.length;
if (Object.prototype.toString.call(val) === '[object Object]') return !Object.keys(val).length;
}
return false;
}
function isFunction(fn) {
return fn && Object.toString.call(fn) === '[object Function]';
}
function arrayEquals(arr1, arr2) {
if (!(arr1 || arr2)) return false;
if (arr1.length !== arr2.length) return false;
for (var i = 0; i < arr1.length; i++) {
if (arr1[i] instanceof Array && arr2[i] instanceof Array) {
return arrayEquals(arr1[i], arr2[i]);
} else {
if (arr1[i] !== arr2[i]) return false;
}
}
return true;
}
/***/ })
/******/ })["default"];