kingdot
Version:
A UI Components Library For Vue
1,527 lines (1,371 loc) • 52 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 = 221);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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
}
}
/***/ }),
/***/ 221:
/***/ (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/CascaderPanel/cascaderPanel.vue?vue&type=template&id=429e5d54&
var cascaderPanelvue_type_template_id_429e5d54_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"kdCascaderPanel",staticClass:"kd-cascader-panel"},[(_vm.menus.length)?_c('div',{staticClass:"kd-cascader-menu"},_vm._l((_vm.menus),function(menu,index){return _c('ul',{key:index,ref:"menu",refInFor:true,staticClass:"kd-cascader-menu__list",attrs:{"index":index}},[(menu.length)?_vm._l((menu),function(node,idx){return _c('cascader-node',{key:node.uid,attrs:{"node":node,"node-id":("cascader-menu-" + (node.uid) + "-" + index + "-" + idx),"level":index}})}):_vm._e()],2)}),0):_c('div',{staticClass:"kd-cascader-menu_empty",style:({width: _vm.emptyWidth})},[_vm._v("\n 暂无数据\n ")])])}
var staticRenderFns = []
// CONCATENATED MODULE: ./components/CascaderPanel/cascaderPanel.vue?vue&type=template&id=429e5d54&
// EXTERNAL MODULE: ./node_modules/babel-helper-vue-jsx-merge-props/index.js
var babel_helper_vue_jsx_merge_props = __webpack_require__(97);
var babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(babel_helper_vue_jsx_merge_props);
// 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/CascaderPanel/cascaderNode.vue?vue&type=script&lang=js&
/* harmony default export */ var cascaderNodevue_type_script_lang_js_ = ({
name: 'KdCascaderNode',
inject: ['panel', 'expandTrigger', 'cascader', 'lazy', 'multiple', 'checkStrictly'],
props: {
nodeId: {
type: String
},
node: {
type: Object,
default: function _default() {
return {};
}
},
level: {
type: [Number, String],
default: 0
}
},
computed: {
isDisabled: function isDisabled() {
return this.node.isDisabled;
},
isLeaf: function isLeaf() {
return this.node.isLeaf;
},
pathValue: function pathValue() {
return this.node.pathValue;
},
isActive: function isActive() {
var node = this.node,
panel = this.panel,
pathValue = this.pathValue;
var activeNode = panel.activePath[node.level - 1] || {};
var isChecked = Object(utils["b" /* arrayEquals */])(pathValue, panel.checkedValue);
return activeNode.uid === node.uid || isChecked;
}
},
methods: {
renderPrefix: function renderPrefix() {
var multiple = this.multiple,
checkStrictly = this.checkStrictly;
if (multiple) {
return this.renderCheckbox();
} else if (checkStrictly) {
return this.renderRadio();
}
return null;
},
renderCheckbox: function renderCheckbox() {
var h = this.$createElement;
var node = this.node,
isDisabled = this.isDisabled;
var events = {
on: {
change: this.handleMultiCheckChange
},
nativeOn: {
// click: e => e.stopPropagation()
}
};
return h('kd-checkbox', babel_helper_vue_jsx_merge_props_default()([{
attrs: {
value: node.checked,
indeterminate: node.indeterminate,
disabled: isDisabled
}
}, events]));
},
renderRadio: function renderRadio() {
var _this = this;
var h = this.$createElement;
var panel = this.panel,
isDisabled = this.isDisabled,
pathValue = this.pathValue;
var checked = Object(utils["b" /* arrayEquals */])(panel.checkedValue, pathValue);
var events = {
on: {
click: function click() {
panel.checkedValue = pathValue;
_this.handleCheckChange();
}
}
};
return h(
'div',
{ 'class': 'kd-cascader-radio' },
[h(
'label',
{
'class': ['kd-radio', {
'kd-radio-checked': checked,
'kd-radio-disabled': isDisabled
}]
},
[h(
'span',
{ 'class': 'kd-radio-wrapper' },
[h('input', babel_helper_vue_jsx_merge_props_default()([{
ref: 'kd-cascader-radio-input',
attrs: { type: 'radio',
disabled: isDisabled
},
'class': 'kd-radio-input',
domProps: {
'value': panel.checkedValue
}
}, events]))]
)]
)]
);
},
labelNode: function labelNode() {
var h = this.$createElement;
var cascader = this.cascader,
node = this.node;
return cascader.$scopedSlots.default ? h(
'span',
{ 'class': 'kd-cascader-node__label' },
[cascader.$scopedSlots.default && cascader.$scopedSlots.default(node)]
) : h(
'span',
{ 'class': 'kd-cascader-node__label' },
[node.label]
);
},
// 右侧图标
iconNode: function iconNode() {
var h = this.$createElement;
var isLeaf = this.isLeaf,
node = this.node,
lazy = this.lazy;
if (!isLeaf) {
if (lazy && node.loading) return h('i', { 'class': 'kd-icon-loading1 kd-cascader-loading' });
return h('i', { 'class': 'kd-icon-arrow-right' });
}
},
// 展开面板
handleExpand: function handleExpand() {
var _this2 = this;
var panel = this.panel,
node = this.node,
isDisabled = this.isDisabled,
multiple = this.multiple,
lazy = this.lazy,
isLeaf = this.isLeaf;
if (isDisabled || node.loading) return;
// 开启懒加载且数据未被获取过
if (lazy && !node.loaded) {
panel.lazyLoadFn(node, function () {
if (!isLeaf) panel.handleExpand(node);
if (multiple) {
var checked = isLeaf ? node.checked : false;
_this2.handleMultiCheckChange(checked);
}
});
} else {
panel.handleExpand(node);
}
},
// 选中选项
handleCheckChange: function handleCheckChange() {
var panel = this.panel,
pathValue = this.pathValue,
node = this.node;
panel.handleClickNode(pathValue);
panel.handleExpand(node);
},
handleMultiCheckChange: function handleMultiCheckChange(checked) {
// 全选children
this.node.multiCheck(checked);
this.panel.calcMultiCheckedValue();
}
},
render: function render(h) {
var _this3 = this;
var expandTrigger = this.expandTrigger,
nodeId = this.nodeId,
isLeaf = this.isLeaf,
isDisabled = this.isDisabled,
checkStrictly = this.checkStrictly,
multiple = this.multiple,
isActive = this.isActive;
var events = { on: {} };
// 展开面板
if (expandTrigger === 'click') {
events.on.click = function (e) {
_this3.handleExpand();
};
} else if (expandTrigger === 'hover') {
events.on.mouseenter = function (e) {
_this3.handleExpand();
_this3.$emit('expand', e);
};
events.on.focus = function (e) {
_this3.handleExpand();
_this3.$emit('expand', e);
};
}
// 选中选项
if (isLeaf && !isDisabled && !checkStrictly && !multiple) {
events.on.click = this.handleCheckChange;
}
return h(
'li',
babel_helper_vue_jsx_merge_props_default()([{
'class': {
'kd-cascader-panel-node': true,
'is-active': isActive,
'is-disabled': this.isDisabled
},
attrs: { id: nodeId
}
}, events]),
[this.renderPrefix(), this.labelNode(), this.iconNode()]
);
}
});
// CONCATENATED MODULE: ./components/CascaderPanel/cascaderNode.vue?vue&type=script&lang=js&
/* harmony default export */ var CascaderPanel_cascaderNodevue_type_script_lang_js_ = (cascaderNodevue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/CascaderPanel/cascaderNode.vue
var cascaderNode_render, cascaderNode_staticRenderFns
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
CascaderPanel_cascaderNodevue_type_script_lang_js_,
cascaderNode_render,
cascaderNode_staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var cascaderNode = (component.exports);
// CONCATENATED MODULE: ./components/CascaderPanel/node.js
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var uid = 0;
var node_Node = function () {
function Node(data, config, parent) {
var _this = this;
_classCallCheck(this, Node);
this.data = data;
// 配置
this.config = config;
this.parent = parent || null;
this.uid = uid++;
this.level = this.parent ? this.parent.level + 1 : 1;
var _config = this.config,
labelName = _config.labelName,
valueName = _config.valueName;
this.value = this.data[valueName];
this.label = this.data[labelName];
// 路径
this.pathNodes = this.calculatePathNodes();
this.pathValue = this.pathNodes.map(function (node) {
return node.value;
});
this.pathLabels = this.pathNodes.map(function (node) {
return node.label;
});
this.labelText = this.pathLabels.join(' / ');
// lazy
this.loading = false;
this.loaded = false;
// 初始化子元素
var childrenData = this.data.children;
this.children = (childrenData || []).map(function (child) {
return new Node(child, config, _this);
});
}
_createClass(Node, [{
key: 'calculatePathNodes',
value: function calculatePathNodes() {
var nodes = [this];
var parent = this.parent;
while (parent) {
nodes.unshift(parent);
parent = parent.parent;
}
return nodes;
}
}, {
key: 'multiCheck',
// 多选
value: function multiCheck(checked) {
if (this.checked !== checked) {
if (this.config.checkStrictly) {
this.checked = checked;
} else {
// 先处理children
this.broadcast('check', checked);
this.setCheckState(checked);
// 处理parent
this.emit('check');
}
}
}
}, {
key: 'broadcast',
value: function broadcast(event, checked) {
this.children && this.children.forEach(function (child) {
if (child) {
child.broadcast(event, checked);
if (!child.isDisabled) {
child.setCheckState(checked);
}
}
});
}
}, {
key: 'emit',
value: function emit(event) {
var parent = this.parent;
if (parent) {
parent.childCheck && parent.childCheck();
parent.emit(event);
}
}
}, {
key: 'setCheckState',
value: function setCheckState(checked) {
var totalNum = this.children.length;
var checkedNum = this.children.reduce(function (c, p) {
var num = p.checked ? 1 : p.indeterminate ? 0.5 : 0;
return c + num;
}, 0);
this.indeterminate = checkedNum !== totalNum && checkedNum > 0;
this.checked = checked;
}
}, {
key: 'childCheck',
value: function childCheck() {
var children = this.children;
var validChildren = children.filter(function (child) {
return !child.isDisabled;
});
var checked = validChildren.length ? validChildren.every(function (child) {
return child.checked;
}) : false;
this.setCheckState(checked);
}
// 更新选中状态
}, {
key: 'syncCheckState',
value: function syncCheckState(checkedValue) {
var checked = this.isContainNode(checkedValue, this.pathValue);
this.multiCheck(checked);
}
}, {
key: 'isContainNode',
value: function isContainNode(checkedValue) {
var value = this.pathValue;
return this.config.multiple && checkedValue.length ? checkedValue.some(function (val) {
return Object(utils["b" /* arrayEquals */])(val, value);
}) : Object(utils["b" /* arrayEquals */])(checkedValue, value);
}
}, {
key: 'isLeaf',
get: function get() {
var loaded = this.loaded,
children = this.children,
data = this.data;
var lazy = this.config.lazy;
var len = children.length;
if (lazy) {
if (data.leaf !== undefined && data.leaf !== null) {
return data.leaf;
}
return loaded ? !len : false;
}
return !len;
}
}, {
key: 'isDisabled',
get: function get() {
var data = this.data,
parent = this.parent;
return data.disabled || parent && parent.isDisabled;
}
}]);
return Node;
}();
/* harmony default export */ var CascaderPanel_node = (node_Node);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/CascaderPanel/cascaderPanel.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var cascaderPanelvue_type_script_lang_js_ = ({
name: 'KdCascaderPanel',
components: {
CascaderNode: cascaderNode
},
mixins: [],
props: {
options: {
type: Array,
default: function _default() {
return [];
}
},
expandTrigger: {
type: String
},
value: {
type: Array,
default: function _default() {
return [];
}
},
cascader: {
type: Object
},
lazy: {
type: Boolean,
default: false
},
lazyMethod: {
type: Function
},
labelName: {
type: String,
default: 'label'
},
valueName: {
type: String,
default: 'value'
},
multiple: {
type: Boolean,
default: false
},
checkStrictly: {
type: Boolean,
default: false
}
},
provide: function provide() {
return {
panel: this,
cascader: this.cascader,
expandTrigger: this.expandTrigger,
lazy: this.lazy,
multiple: this.multiple,
checkStrictly: this.checkStrictly
};
},
data: function data() {
return {
nodeList: [],
checkedValue: [],
menus: [],
flatOpt: [],
activePath: [],
loadCount: 0
};
},
computed: {
emptyWidth: function emptyWidth() {
return this.cascader.$refs.kdCascader && this.cascader.$refs.kdCascader.clientWidth + 'px' || '300px';
},
config: function config() {
var lazy = this.lazy,
multiple = this.multiple,
checkStrictly = this.checkStrictly,
labelName = this.labelName,
valueName = this.valueName;
var conf = {
multiple: multiple,
lazy: lazy,
checkStrictly: checkStrictly,
labelName: labelName,
valueName: valueName
};
return conf;
}
},
watch: {
value: {
deep: true,
immediate: true,
handler: function handler(val) {
if (!Object(utils["b" /* arrayEquals */])(val, this.checkedValue)) {
this.activePath = [];
this.checkedValue = val;
this.calcMenuState();
}
}
},
checkedValue: {
deep: true,
handler: function handler(val) {
if (!Object(utils["b" /* arrayEquals */])(val, this.value)) {
this.$emit('input', val);
this.$emit('change', val);
}
}
},
options: {
deep: true,
immediate: true,
handler: function handler() {
this.initNodeList();
}
}
},
created: function created() {},
mounted: function mounted() {},
methods: {
// 初始化menulist, flatopt
initNodeList: function initNodeList() {
var lazy = this.lazy,
options = this.options,
config = this.config;
if (lazy && Object(utils["c" /* isEmpty */])(options)) {
this.lazyLoadFn();
} else {
this.nodeList = options.map(function (nodeData) {
return new CascaderPanel_node(nodeData, config);
});
this.menus = [this.nodeList];
this.flatOpt = this._flatNodes(this.nodeList);
this.calcMenuState();
}
},
// 计算activepath
calcMenuState: function calcMenuState() {
this.calcActivePath();
this.multiple && this.calcMultiCheckState();
},
// 计算activepath, menus
calcActivePath: function calcActivePath() {
var _this = this;
var multiple = this.multiple,
activePath = this.activePath,
checkedValue = this.checkedValue;
if (!Object(utils["c" /* isEmpty */])(activePath)) {
var nodes = activePath.map(function (node) {
return _this.getNodeByValue(node.value);
});
nodes.forEach(function (node) {
return _this.handleExpand(node);
});
} else if (!Object(utils["c" /* isEmpty */])(checkedValue)) {
var value = multiple ? checkedValue[0] : checkedValue;
// 当前选择的节点
var checkedNode = this.getNodeByValue(value) || {};
var _nodes = (checkedNode.pathNodes || []).slice(0, -1);
_nodes.forEach(function (node) {
return _this.handleExpand(node);
});
} else {
this.activePath = [];
this.menus = [this.nodeList];
}
},
calcMultiCheckState: function calcMultiCheckState() {
var menus = this.menus,
checkedValue = this.checkedValue;
if (!menus.length) return;
var nodes = this._flatNodes(menus[0]);
nodes.forEach(function (node) {
node.syncCheckState(checkedValue);
});
},
// 更新当前被选择列表(activePath), 更新面板(menus)
handleExpand: function handleExpand(node) {
var activePath = this.activePath;
var level = node.level;
var path = activePath.slice(0, level - 1);
var menus = this.menus.slice(0, level);
if (!node.isLeaf) {
path.push(node);
menus.push(node.children);
}
this.activePath = path;
this.menus = menus;
// 在更新面板时更新tooltip 的 updatePopper方法
this.$emit('handleExpand');
},
handleClickNode: function handleClickNode(pathValue) {
this.checkedValue = pathValue;
},
lazyLoadFn: function lazyLoadFn(node, fn) {
var _this2 = this;
if (!node) {
node = { root: true, level: 0 };
this.menus = [];
}
this.$set(node, 'loading', true);
var resolve = function resolve(list) {
if (list && list.length) {
var parent = node.root ? null : node;
var item = list.map(function (nodeData) {
return new CascaderPanel_node(nodeData, _this2.config, parent);
});
if (parent) {
parent.children = item;
} else {
_this2.menus.push(item);
}
if (_this2.menus.length) {
_this2.flatOpt = _this2._flatNodes(_this2.menus[0]);
}
node.loading = false;
node.loaded = true;
// 有默认值时的初始化
if (_this2.checkedValue && _this2.checkedValue.length) {
var nodeValue = _this2.checkedValue[_this2.loadCount];
var flatOpt = _this2._initMenus(_this2.menus[0]);
if (flatOpt[_this2.loadCount]) {
var _node = flatOpt[_this2.loadCount].find(function (i) {
return i[_this2.valueName] === nodeValue;
});
_this2.loadCount++;
if (_node && !_node.isLeaf) {
_this2.lazyLoadFn(_node, function () {
_this2.handleExpand(_node);
});
}
if (_this2.loadCount === _this2.checkedValue.length) {
_this2.$emit('setLabel');
}
}
}
fn && fn(list);
} else {
node.loading = false;
node.isLeaf = true;
node.loaded = true;
}
};
this.lazyMethod(node, resolve);
},
calcMultiCheckedValue: function calcMultiCheckedValue() {
var checkedArr = this.calcMultiCheckedNodes();
this.checkedValue = checkedArr.map(function (node) {
return node.pathValue;
});
},
calcMultiCheckedNodes: function calcMultiCheckedNodes() {
this.flatOpt = this._flatNodes(this.menus[0]);
return this.flatOpt.filter(function (node) {
return node.checked && node.isLeaf;
});
},
scrollToView: function scrollToView() {
var _this3 = this;
var menu = this.$refs.menu || [];
menu.forEach(function (item) {
var activeNode = item.querySelector('.kd-cascader-panel-node.is-active');
_this3.scrollToViewFn(item, activeNode);
});
},
scrollToViewFn: function scrollToViewFn(container, target) {
if (!target) {
container.scrollTop = 0;
return;
}
// 计算当前可视区的上下界限值;
var viewTop = container.scrollTop;
var viewBottom = viewTop + container.clientHeight;
// 计算当前选择元素的上下高度值
var top = target.offsetTop;
var bottom = top + target.offsetHeight;
if (top < viewTop) {
container.scrollTop = top;
} else if (bottom > viewBottom) {
container.scrollTop = bottom - container.clientHeight;
}
},
_flatNodes: function _flatNodes(data) {
var _this4 = this;
if (!data || data.length < 1) return [];
return data.reduce(function (res, node) {
res.push(node);
if (node.children && node.children.length) {
res = res.concat(_this4._flatNodes(node.children));
}
return res;
}, []);
},
getNodeByValue: function getNodeByValue(value) {
var nodes = this.flatOpt.filter(function (node) {
return Object(utils["b" /* arrayEquals */])(node.pathValue, value) || node.value === value;
});
return nodes && nodes.length ? nodes[0] : null;
},
_initMenus: function _initMenus() {
var _this5 = this;
var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var menus = [];
var options = option.slice();
menus.push(options);
if (this.value.length) {
this.value.forEach(function (item) {
var node = options.find(function (i) {
return i[_this5.valueName] === item;
});
options = node && node.children || [];
if (options.length) menus.push(options);
});
}
return menus;
}
}
});
// CONCATENATED MODULE: ./components/CascaderPanel/cascaderPanel.vue?vue&type=script&lang=js&
/* harmony default export */ var CascaderPanel_cascaderPanelvue_type_script_lang_js_ = (cascaderPanelvue_type_script_lang_js_);
// CONCATENATED MODULE: ./components/CascaderPanel/cascaderPanel.vue
/* normalize component */
var cascaderPanel_component = Object(componentNormalizer["a" /* default */])(
CascaderPanel_cascaderPanelvue_type_script_lang_js_,
cascaderPanelvue_type_template_id_429e5d54_render,
staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var cascaderPanel = (cascaderPanel_component.exports);
// CONCATENATED MODULE: ./components/CascaderPanel/index.js
cascaderPanel.install = function (Vue) {
Vue.component(cascaderPanel.name, cascaderPanel);
};
/* harmony default export */ var CascaderPanel = __webpack_exports__["default"] = (cascaderPanel);
/***/ }),
/***/ 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) {