element-nice-ui
Version:
A Component Library for Vue.js.
1,396 lines (1,288 loc) • 42.1 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 = 186);
/******/ })
/************************************************************************/
/******/ ({
/***/ 119:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/radio");
/***/ }),
/***/ 186:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib??vue-loader-options!./packages/cascader-panel/src/cascader-panel.vue?vue&type=template&id=14958a28
var render = function render() {
var _vm = this,
_c = _vm._self._c
return _c(
"div",
{
class: ["el-cascader-panel", _vm.border && "is-bordered"],
on: { keydown: _vm.handleKeyDown },
},
_vm._l(_vm.menus, function (menu, index) {
return _c("cascader-menu", {
key: index,
ref: "menu",
refInFor: true,
attrs: { index: index, nodes: menu },
})
}),
1
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-panel.vue?vue&type=template&id=14958a28
// EXTERNAL MODULE: external "@vue/babel-helper-vue-jsx-merge-props"
var babel_helper_vue_jsx_merge_props_ = __webpack_require__(30);
var babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(babel_helper_vue_jsx_merge_props_);
// EXTERNAL MODULE: external "element-nice-ui/lib/scrollbar"
var scrollbar_ = __webpack_require__(32);
var scrollbar_default = /*#__PURE__*/__webpack_require__.n(scrollbar_);
// EXTERNAL MODULE: external "element-nice-ui/lib/checkbox"
var checkbox_ = __webpack_require__(26);
var checkbox_default = /*#__PURE__*/__webpack_require__.n(checkbox_);
// EXTERNAL MODULE: external "element-nice-ui/lib/radio"
var radio_ = __webpack_require__(119);
var radio_default = /*#__PURE__*/__webpack_require__.n(radio_);
// EXTERNAL MODULE: external "element-nice-ui/lib/utils/util"
var util_ = __webpack_require__(5);
// CONCATENATED MODULE: ./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.28.0_webpack@4.47.0/node_modules/babel-loader/lib!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib??vue-loader-options!./packages/cascader-panel/src/cascader-node.vue?vue&type=script&lang=js
const stopPropagation = e => e.stopPropagation();
/* harmony default export */ var cascader_nodevue_type_script_lang_js = ({
inject: ['panel'],
components: {
ElCheckbox: checkbox_default.a,
ElRadio: radio_default.a
},
props: {
node: {
required: true
},
nodeId: String
},
computed: {
config() {
return this.panel.config;
},
isLeaf() {
return this.node.isLeaf;
},
isDisabled() {
return this.node.isDisabled;
},
checkedValue() {
return this.panel.checkedValue;
},
isChecked() {
return this.node.isSameNode(this.checkedValue);
},
inActivePath() {
return this.isInPath(this.panel.activePath);
},
inCheckedPath() {
if (!this.config.checkStrictly) return false;
return this.panel.checkedNodePaths.some(checkedPath => this.isInPath(checkedPath));
},
value() {
return this.node.getValueByOption();
}
},
methods: {
handleExpand() {
const {
panel,
node,
isDisabled,
config
} = this;
const {
multiple,
checkStrictly
} = config;
if (!checkStrictly && isDisabled || node.loading) return;
if (config.lazy && !node.loaded) {
panel.lazyLoad(node, () => {
// do not use cached leaf value here, invoke this.isLeaf to get new value.
const {
isLeaf
} = this;
if (!isLeaf) this.handleExpand();
if (multiple) {
// if leaf sync checked state, else clear checked state
const checked = isLeaf ? node.checked : false;
this.handleMultiCheckChange(checked);
}
});
} else {
panel.handleExpand(node);
}
},
handleCheckChange() {
const {
panel,
value,
node
} = this;
panel.handleCheckChange(value);
panel.handleExpand(node);
},
handleMultiCheckChange(checked) {
this.node.doCheck(checked);
this.panel.calculateMultiCheckedValue();
},
isInPath(pathNodes) {
const {
node
} = this;
const selectedPathNode = pathNodes[node.level - 1] || {};
return selectedPathNode.uid === node.uid;
},
renderPrefix(h) {
const {
isLeaf,
isChecked,
config
} = this;
const {
checkStrictly,
multiple
} = config;
if (multiple) {
return this.renderCheckbox(h);
} else if (checkStrictly) {
return this.renderRadio(h);
} else if (isLeaf && isChecked) {
return this.renderCheckIcon(h);
}
return null;
},
renderPostfix(h) {
const {
node,
isLeaf
} = this;
if (node.loading) {
return this.renderLoadingIcon(h);
} else if (!isLeaf) {
return this.renderExpandIcon(h);
}
return null;
},
renderCheckbox(h) {
const {
node,
config,
isDisabled
} = this;
const events = {
on: {
change: this.handleMultiCheckChange
},
nativeOn: {}
};
if (config.checkStrictly) {
// when every node is selectable, click event should not trigger expand event.
events.nativeOn.click = stopPropagation;
}
return h("el-checkbox", babel_helper_vue_jsx_merge_props_default()([{
"attrs": {
"value": node.checked,
"indeterminate": node.indeterminate,
"disabled": isDisabled
}
}, events]));
},
renderRadio(h) {
let {
checkedValue,
value,
isDisabled
} = this;
// to keep same reference if value cause radio's checked state is calculated by reference comparision;
if (Object(util_["isEqual"])(value, checkedValue)) {
value = checkedValue;
}
return h("el-radio", {
"attrs": {
"value": checkedValue,
"label": value,
"disabled": isDisabled
},
"on": {
"change": this.handleCheckChange
},
"nativeOn": {
"click": stopPropagation
}
}, [h("span")]);
},
renderCheckIcon(h) {
return h("i", {
"class": "el-icon-check el-cascader-node__prefix"
});
},
renderLoadingIcon(h) {
return h("i", {
"class": "el-icon-loading el-cascader-node__postfix"
});
},
renderExpandIcon(h) {
return h("i", {
"class": "el-icon-arrow-right el-cascader-node__postfix"
});
},
renderContent(h) {
const {
panel,
node
} = this;
const render = panel.renderLabelFn;
const vnode = render ? render({
node,
data: node.data
}) : null;
return h("span", {
"class": "el-cascader-node__label"
}, [vnode || node.label]);
}
},
render(h) {
const {
inActivePath,
inCheckedPath,
isChecked,
isLeaf,
isDisabled,
config,
nodeId
} = this;
const {
expandTrigger,
checkStrictly,
multiple
} = config;
const disabled = !checkStrictly && isDisabled;
const events = {
on: {}
};
if (expandTrigger === 'click') {
events.on.click = this.handleExpand;
} else {
events.on.mouseenter = e => {
this.handleExpand();
this.$emit('expand', e);
};
events.on.focus = e => {
this.handleExpand();
this.$emit('expand', e);
};
}
if (isLeaf && !isDisabled && !checkStrictly && !multiple) {
events.on.click = this.handleCheckChange;
}
return h("li", babel_helper_vue_jsx_merge_props_default()([{
"attrs": {
"role": "menuitem",
"id": nodeId,
"aria-expanded": inActivePath,
"tabindex": disabled ? null : -1
},
"class": {
'el-cascader-node': true,
'is-selectable': checkStrictly,
'in-active-path': inActivePath,
'in-checked-path': inCheckedPath,
'is-active': isChecked,
'is-disabled': disabled
}
}, events]), [this.renderPrefix(h), this.renderContent(h), this.renderPostfix(h)]);
}
});
// CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-node.vue?vue&type=script&lang=js
/* harmony default export */ var src_cascader_nodevue_type_script_lang_js = (cascader_nodevue_type_script_lang_js);
// EXTERNAL MODULE: ./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(2);
// CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-node.vue
var cascader_node_render, cascader_node_staticRenderFns
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
src_cascader_nodevue_type_script_lang_js,
cascader_node_render,
cascader_node_staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var cascader_node = (component.exports);
// EXTERNAL MODULE: external "element-nice-ui/lib/mixins/locale"
var locale_ = __webpack_require__(19);
var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
// CONCATENATED MODULE: ./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.28.0_webpack@4.47.0/node_modules/babel-loader/lib!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib??vue-loader-options!./packages/cascader-panel/src/cascader-menu.vue?vue&type=script&lang=js
/* harmony default export */ var cascader_menuvue_type_script_lang_js = ({
name: 'ElCascaderMenu',
mixins: [locale_default.a],
inject: ['panel'],
components: {
ElScrollbar: scrollbar_default.a,
CascaderNode: cascader_node
},
props: {
nodes: {
type: Array,
required: true
},
index: Number
},
data() {
return {
activeNode: null,
hoverTimer: null,
id: Object(util_["generateId"])()
};
},
computed: {
isEmpty() {
return !this.nodes.length;
},
menuId() {
return "cascader-menu-".concat(this.id, "-").concat(this.index);
}
},
methods: {
handleExpand(e) {
this.activeNode = e.target;
},
handleMouseMove(e) {
const {
activeNode,
hoverTimer
} = this;
const {
hoverZone
} = this.$refs;
if (!activeNode || !hoverZone) return;
if (activeNode.contains(e.target)) {
clearTimeout(hoverTimer);
const {
left
} = this.$el.getBoundingClientRect();
const startX = e.clientX - left;
const {
offsetWidth,
offsetHeight
} = this.$el;
const top = activeNode.offsetTop;
const bottom = top + activeNode.offsetHeight;
hoverZone.innerHTML = "\n <path style=\"pointer-events: auto;\" fill=\"transparent\" d=\"M".concat(startX, " ").concat(top, " L").concat(offsetWidth, " 0 V").concat(top, " Z\" />\n <path style=\"pointer-events: auto;\" fill=\"transparent\" d=\"M").concat(startX, " ").concat(bottom, " L").concat(offsetWidth, " ").concat(offsetHeight, " V").concat(bottom, " Z\" />\n ");
} else if (!hoverTimer) {
this.hoverTimer = setTimeout(this.clearHoverZone, this.panel.config.hoverThreshold);
}
},
clearHoverZone() {
const {
hoverZone
} = this.$refs;
if (!hoverZone) return;
hoverZone.innerHTML = '';
},
renderEmptyText(h) {
return h("div", {
"class": "el-cascader-menu__empty-text"
}, [this.t('el.cascader.noData')]);
},
renderNodeList(h) {
const {
menuId
} = this;
const {
isHoverMenu
} = this.panel;
const events = {
on: {}
};
if (isHoverMenu) {
events.on.expand = this.handleExpand;
}
const nodes = this.nodes.map((node, index) => {
const {
hasChildren
} = node;
return h("cascader-node", babel_helper_vue_jsx_merge_props_default()([{
"key": node.uid,
"attrs": {
"node": node,
"node-id": "".concat(menuId, "-").concat(index),
"aria-haspopup": hasChildren,
"aria-owns": hasChildren ? menuId : null
}
}, events]));
});
return [...nodes, isHoverMenu ? h("svg", {
"ref": 'hoverZone',
"class": 'el-cascader-menu__hover-zone'
}) : null];
}
},
render(h) {
const {
isEmpty,
menuId
} = this;
const events = {
nativeOn: {}
};
// optimize hover to expand experience (#8010)
if (this.panel.isHoverMenu) {
events.nativeOn.mousemove = this.handleMouseMove;
// events.nativeOn.mouseleave = this.clearHoverZone;
}
return h("el-scrollbar", babel_helper_vue_jsx_merge_props_default()([{
"attrs": {
"tag": "ul",
"role": "menu",
"id": menuId,
"wrap-class": "el-cascader-menu__wrap",
"view-class": {
'el-cascader-menu__list': true,
'is-empty': isEmpty
}
},
"class": "el-cascader-menu"
}, events]), [isEmpty ? this.renderEmptyText(h) : this.renderNodeList(h)]);
}
});
// CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-menu.vue?vue&type=script&lang=js
/* harmony default export */ var src_cascader_menuvue_type_script_lang_js = (cascader_menuvue_type_script_lang_js);
// CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-menu.vue
var cascader_menu_render, cascader_menu_staticRenderFns
/* normalize component */
var cascader_menu_component = Object(componentNormalizer["a" /* default */])(
src_cascader_menuvue_type_script_lang_js,
cascader_menu_render,
cascader_menu_staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var cascader_menu = (cascader_menu_component.exports);
// EXTERNAL MODULE: external "element-nice-ui/lib/utils/shared"
var shared_ = __webpack_require__(31);
// CONCATENATED MODULE: ./packages/cascader-panel/src/node.js
let uid = 0;
class node_Node {
constructor(data, config, parentNode) {
this.data = data;
this.config = config;
this.parent = parentNode || null;
this.level = !this.parent ? 1 : this.parent.level + 1;
this.uid = uid++;
this.initState();
this.initChildren();
}
initState() {
const {
value: valueKey,
label: labelKey
} = this.config;
this.value = this.data[valueKey];
this.label = this.data[labelKey];
this.pathNodes = this.calculatePathNodes();
this.path = this.pathNodes.map(node => node.value);
this.pathLabels = this.pathNodes.map(node => node.label);
// lazy load
this.loading = false;
this.loaded = false;
}
initChildren() {
const {
config
} = this;
const childrenKey = config.children;
const childrenData = this.data[childrenKey];
this.hasChildren = Array.isArray(childrenData);
this.children = (childrenData || []).map(child => new node_Node(child, config, this));
}
get isDisabled() {
const {
data,
parent,
config
} = this;
const disabledKey = config.disabled;
const {
checkStrictly
} = config;
return data[disabledKey] || !checkStrictly && parent && parent.isDisabled;
}
get isLeaf() {
const {
data,
loaded,
hasChildren,
children
} = this;
const {
lazy,
leaf: leafKey
} = this.config;
if (lazy) {
const isLeaf = Object(shared_["isDef"])(data[leafKey]) ? data[leafKey] : loaded ? !children.length : false;
this.hasChildren = !isLeaf;
return isLeaf;
}
return !hasChildren;
}
calculatePathNodes() {
const nodes = [this];
let parent = this.parent;
while (parent) {
nodes.unshift(parent);
parent = parent.parent;
}
return nodes;
}
getPath() {
return this.path;
}
getValue() {
return this.value;
}
getValueByOption() {
return this.config.emitPath ? this.getPath() : this.getValue();
}
getText(allLevels, separator) {
return allLevels ? this.pathLabels.join(separator) : this.label;
}
isSameNode(checkedValue) {
const value = this.getValueByOption();
return this.config.multiple && Array.isArray(checkedValue) ? checkedValue.some(val => Object(util_["isEqual"])(val, value)) : Object(util_["isEqual"])(checkedValue, value);
}
broadcast(event) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
const handlerName = "onParent".concat(Object(util_["capitalize"])(event));
this.children.forEach(child => {
if (child) {
// bottom up
child.broadcast(event, ...args);
child[handlerName] && child[handlerName](...args);
}
});
}
emit(event) {
const {
parent
} = this;
const handlerName = "onChild".concat(Object(util_["capitalize"])(event));
if (parent) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
parent[handlerName] && parent[handlerName](...args);
parent.emit(event, ...args);
}
}
onParentCheck(checked) {
if (!this.isDisabled) {
this.setCheckState(checked);
}
}
onChildCheck() {
const {
children
} = this;
const validChildren = children.filter(child => !child.isDisabled);
const checked = validChildren.length ? validChildren.every(child => child.checked) : false;
this.setCheckState(checked);
}
setCheckState(checked) {
const totalNum = this.children.length;
const checkedNum = this.children.reduce((c, p) => {
const num = p.checked ? 1 : p.indeterminate ? 0.5 : 0;
return c + num;
}, 0);
this.checked = checked;
this.indeterminate = checkedNum !== totalNum && checkedNum > 0;
}
syncCheckState(checkedValue) {
const value = this.getValueByOption();
const checked = this.isSameNode(checkedValue, value);
this.doCheck(checked);
}
doCheck(checked) {
if (this.checked !== checked) {
if (this.config.checkStrictly) {
this.checked = checked;
} else {
// bottom up to unify the calculation of the indeterminate state
this.broadcast('check', checked);
this.setCheckState(checked);
this.emit('check');
}
}
}
}
// CONCATENATED MODULE: ./packages/cascader-panel/src/store.js
const flatNodes = (data, leafOnly) => {
return data.reduce((res, node) => {
if (node.isLeaf) {
res.push(node);
} else {
!leafOnly && res.push(node);
res = res.concat(flatNodes(node.children, leafOnly));
}
return res;
}, []);
};
class store_Store {
constructor(data, config) {
this.config = config;
this.initNodes(data);
}
initNodes(data) {
data = Object(util_["coerceTruthyValueToArray"])(data);
this.nodes = data.map(nodeData => new node_Node(nodeData, this.config));
this.flattedNodes = this.getFlattedNodes(false, false);
this.leafNodes = this.getFlattedNodes(true, false);
}
appendNode(nodeData, parentNode) {
const node = new node_Node(nodeData, this.config, parentNode);
const children = parentNode ? parentNode.children : this.nodes;
children.push(node);
}
appendNodes(nodeDataList, parentNode) {
nodeDataList = Object(util_["coerceTruthyValueToArray"])(nodeDataList);
nodeDataList.forEach(nodeData => this.appendNode(nodeData, parentNode));
}
getNodes() {
return this.nodes;
}
getFlattedNodes(leafOnly) {
let cached = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
const cachedNodes = leafOnly ? this.leafNodes : this.flattedNodes;
return cached ? cachedNodes : flatNodes(this.nodes, leafOnly);
}
getNodeByValue(value) {
if (value) {
const nodes = this.getFlattedNodes(false, !this.config.lazy).filter(node => Object(util_["valueEquals"])(node.path, value) || node.value === value);
return nodes && nodes.length ? nodes[0] : null;
}
return null;
}
}
// EXTERNAL MODULE: external "element-nice-ui/lib/utils/merge"
var merge_ = __webpack_require__(23);
var merge_default = /*#__PURE__*/__webpack_require__.n(merge_);
// EXTERNAL MODULE: external "element-nice-ui/lib/utils/aria-utils"
var aria_utils_ = __webpack_require__(72);
var aria_utils_default = /*#__PURE__*/__webpack_require__.n(aria_utils_);
// EXTERNAL MODULE: external "element-nice-ui/lib/utils/scroll-into-view"
var scroll_into_view_ = __webpack_require__(70);
var scroll_into_view_default = /*#__PURE__*/__webpack_require__.n(scroll_into_view_);
// CONCATENATED MODULE: ./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.28.0_webpack@4.47.0/node_modules/babel-loader/lib!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.18_css-loader@5.2.7_webpack@4.47.0__lodash@4.1_bb9a19950a80e648dc95ba33c71fa343/node_modules/vue-loader/lib??vue-loader-options!./packages/cascader-panel/src/cascader-panel.vue?vue&type=script&lang=js
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
const {
keys: KeyCode
} = aria_utils_default.a;
const DefaultProps = {
expandTrigger: 'click',
// or hover
multiple: false,
checkStrictly: false,
// whether all nodes can be selected
emitPath: true,
// wether to emit an array of all levels value in which node is located
lazy: false,
lazyLoad: util_["noop"],
value: 'value',
label: 'label',
children: 'children',
leaf: 'leaf',
disabled: 'disabled',
hoverThreshold: 500
};
const cascader_panelvue_type_script_lang_js_isLeaf = el => !el.getAttribute('aria-owns');
const getSibling = (el, distance) => {
const {
parentNode
} = el;
if (parentNode) {
const siblings = parentNode.querySelectorAll('.el-cascader-node[tabindex="-1"]');
const index = Array.prototype.indexOf.call(siblings, el);
return siblings[index + distance] || null;
}
return null;
};
const getMenuIndex = (el, distance) => {
if (!el) return;
const pieces = el.id.split('-');
return Number(pieces[pieces.length - 2]);
};
const focusNode = el => {
if (!el) return;
el.focus();
!cascader_panelvue_type_script_lang_js_isLeaf(el) && el.click();
};
const checkNode = el => {
if (!el) return;
const input = el.querySelector('input');
if (input) {
input.click();
} else if (cascader_panelvue_type_script_lang_js_isLeaf(el)) {
el.click();
}
};
/* harmony default export */ var cascader_panelvue_type_script_lang_js = ({
name: 'ElCascaderPanel',
components: {
CascaderMenu: cascader_menu
},
props: {
value: {},
options: Array,
props: Object,
border: {
type: Boolean,
default: true
},
renderLabel: Function
},
provide() {
return {
panel: this
};
},
data() {
return {
checkedValue: null,
checkedNodePaths: [],
store: [],
menus: [],
activePath: [],
loadCount: 0
};
},
computed: {
config() {
return merge_default()(_objectSpread({}, DefaultProps), this.props || {});
},
multiple() {
return this.config.multiple;
},
checkStrictly() {
return this.config.checkStrictly;
},
leafOnly() {
return !this.checkStrictly;
},
isHoverMenu() {
return this.config.expandTrigger === 'hover';
},
renderLabelFn() {
return this.renderLabel || this.$scopedSlots.default;
}
},
watch: {
options: {
handler: function handler() {
this.initStore();
},
immediate: true,
deep: true
},
value() {
this.syncCheckedValue();
this.checkStrictly && this.calculateCheckedNodePaths();
},
checkedValue(val) {
if (!Object(util_["isEqual"])(val, this.value)) {
this.checkStrictly && this.calculateCheckedNodePaths();
this.$emit('input', val);
this.$emit('change', val);
}
}
},
mounted() {
if (!Object(util_["isEmpty"])(this.value)) {
this.syncCheckedValue();
}
},
methods: {
initStore() {
const {
config,
options
} = this;
if (config.lazy && Object(util_["isEmpty"])(options)) {
this.lazyLoad();
} else {
this.store = new store_Store(options, config);
this.menus = [this.store.getNodes()];
this.syncMenuState();
}
},
syncCheckedValue() {
const {
value,
checkedValue
} = this;
if (!Object(util_["isEqual"])(value, checkedValue)) {
this.checkedValue = value;
this.syncMenuState();
}
},
syncMenuState() {
const {
multiple,
checkStrictly
} = this;
this.syncActivePath();
multiple && this.syncMultiCheckState();
checkStrictly && this.calculateCheckedNodePaths();
this.$nextTick(this.scrollIntoView);
},
syncMultiCheckState() {
const nodes = this.getFlattedNodes(this.leafOnly);
nodes.forEach(node => {
node.syncCheckState(this.checkedValue);
});
},
syncActivePath() {
const {
store,
multiple,
activePath,
checkedValue
} = this;
if (!Object(util_["isEmpty"])(activePath)) {
const nodes = activePath.map(node => this.getNodeByValue(node.getValue()));
this.expandNodes(nodes);
} else if (!Object(util_["isEmpty"])(checkedValue)) {
const value = multiple ? checkedValue[0] : checkedValue;
const checkedNode = this.getNodeByValue(value) || {};
const nodes = (checkedNode.pathNodes || []).slice(0, -1);
this.expandNodes(nodes);
} else {
this.activePath = [];
this.menus = [store.getNodes()];
}
},
expandNodes(nodes) {
nodes.forEach(node => this.handleExpand(node, true /* silent */));
},
calculateCheckedNodePaths() {
const {
checkedValue,
multiple
} = this;
const checkedValues = multiple ? Object(util_["coerceTruthyValueToArray"])(checkedValue) : [checkedValue];
this.checkedNodePaths = checkedValues.map(v => {
const checkedNode = this.getNodeByValue(v);
return checkedNode ? checkedNode.pathNodes : [];
});
},
handleKeyDown(e) {
const {
target,
keyCode
} = e;
switch (keyCode) {
case KeyCode.up:
const prev = getSibling(target, -1);
focusNode(prev);
break;
case KeyCode.down:
const next = getSibling(target, 1);
focusNode(next);
break;
case KeyCode.left:
const preMenu = this.$refs.menu[getMenuIndex(target) - 1];
if (preMenu) {
const expandedNode = preMenu.$el.querySelector('.el-cascader-node[aria-expanded="true"]');
focusNode(expandedNode);
}
break;
case KeyCode.right:
const nextMenu = this.$refs.menu[getMenuIndex(target) + 1];
if (nextMenu) {
const firstNode = nextMenu.$el.querySelector('.el-cascader-node[tabindex="-1"]');
focusNode(firstNode);
}
break;
case KeyCode.enter:
checkNode(target);
break;
case KeyCode.esc:
case KeyCode.tab:
this.$emit('close');
break;
default:
return;
}
},
handleExpand(node, silent) {
const {
activePath
} = this;
const {
level
} = node;
const path = activePath.slice(0, level - 1);
const menus = this.menus.slice(0, level);
if (!node.isLeaf) {
path.push(node);
menus.push(node.children);
}
this.activePath = path;
this.menus = menus;
if (!silent) {
const pathValues = path.map(node => node.getValue());
const activePathValues = activePath.map(node => node.getValue());
if (!Object(util_["valueEquals"])(pathValues, activePathValues)) {
this.$emit('active-item-change', pathValues); // Deprecated
this.$emit('expand-change', pathValues);
}
}
},
handleCheckChange(value) {
this.checkedValue = value;
},
lazyLoad(node, onFullfiled) {
const {
config
} = this;
if (!node) {
node = node || {
root: true,
level: 0
};
this.store = new store_Store([], config);
this.menus = [this.store.getNodes()];
}
node.loading = true;
const resolve = dataList => {
const parent = node.root ? null : node;
dataList && dataList.length && this.store.appendNodes(dataList, parent);
node.loading = false;
node.loaded = true;
// dispose default value on lazy load mode
if (Array.isArray(this.checkedValue)) {
const nodeValue = this.checkedValue[this.loadCount++];
const valueKey = this.config.value;
const leafKey = this.config.leaf;
if (Array.isArray(dataList) && dataList.filter(item => item[valueKey] === nodeValue).length > 0) {
const checkedNode = this.store.getNodeByValue(nodeValue);
if (!checkedNode.data[leafKey]) {
this.lazyLoad(checkedNode, () => {
this.handleExpand(checkedNode);
});
}
if (this.loadCount === this.checkedValue.length) {
this.$parent.computePresentText();
}
}
}
onFullfiled && onFullfiled(dataList);
};
config.lazyLoad(node, resolve);
},
/**
* public methods
*/
calculateMultiCheckedValue() {
this.checkedValue = this.getCheckedNodes(this.leafOnly).map(node => node.getValueByOption());
},
scrollIntoView() {
if (this.$isServer) return;
const menus = this.$refs.menu || [];
menus.forEach(menu => {
const menuElement = menu.$el;
if (menuElement) {
const container = menuElement.querySelector('.el-scrollbar__wrap');
const activeNode = menuElement.querySelector('.el-cascader-node.is-active') || menuElement.querySelector('.el-cascader-node.in-active-path');
scroll_into_view_default()(container, activeNode);
}
});
},
getNodeByValue(val) {
return this.store.getNodeByValue(val);
},
getFlattedNodes(leafOnly) {
const cached = !this.config.lazy;
return this.store.getFlattedNodes(leafOnly, cached);
},
getCheckedNodes(leafOnly) {
const {
checkedValue,
multiple
} = this;
if (multiple) {
const nodes = this.getFlattedNodes(leafOnly);
return nodes.filter(node => node.checked);
} else {
return Object(util_["isEmpty"])(checkedValue) ? [] : [this.getNodeByValue(checkedValue)];
}
},
clearCheckedNodes() {
const {
config,
leafOnly
} = this;
const {
multiple,
emitPath
} = config;
if (multiple) {
this.getCheckedNodes(leafOnly).filter(node => !node.isDisabled).forEach(node => node.doCheck(false));
this.calculateMultiCheckedValue();
} else {
this.checkedValue = emitPath ? [] : null;
}
}
}
});
// CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-panel.vue?vue&type=script&lang=js
/* harmony default export */ var src_cascader_panelvue_type_script_lang_js = (cascader_panelvue_type_script_lang_js);
// CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-panel.vue
/* normalize component */
var cascader_panel_component = Object(componentNormalizer["a" /* default */])(
src_cascader_panelvue_type_script_lang_js,
render,
staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var cascader_panel = (cascader_panel_component.exports);
// CONCATENATED MODULE: ./packages/cascader-panel/index.js
/* istanbul ignore next */
cascader_panel.install = function (Vue) {
Vue.component(cascader_panel.name, cascader_panel);
};
/* harmony default export */ var packages_cascader_panel = __webpack_exports__["default"] = (cascader_panel);
/***/ }),
/***/ 19:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/mixins/locale");
/***/ }),
/***/ 2:
/***/ (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
}
}
/***/ }),
/***/ 23:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/utils/merge");
/***/ }),
/***/ 26:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/checkbox");
/***/ }),
/***/ 30:
/***/ (function(module, exports) {
module.exports = require("@vue/babel-helper-vue-jsx-merge-props");
/***/ }),
/***/ 31:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/utils/shared");
/***/ }),
/***/ 32:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/scrollbar");
/***/ }),
/***/ 5:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/utils/util");
/***/ }),
/***/ 70:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/utils/scroll-into-view");
/***/ }),
/***/ 72:
/***/ (function(module, exports) {
module.exports = require("element-nice-ui/lib/utils/aria-utils");
/***/ })
/******/ });