UNPKG

vue-antd-ui

Version:

An enterprise-class UI design language and Vue-based implementation

55 lines (51 loc) 1.44 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.noop = noop; exports.getKeyFromChildrenIndex = getKeyFromChildrenIndex; exports.loopMenuItem = loopMenuItem; exports.loopMenuItemRecusively = loopMenuItemRecusively; function noop() {} function getKeyFromChildrenIndex(child, menuEventKey, index) { var prefix = menuEventKey || ''; return child.key || prefix + 'item_' + index; } function loopMenuItem(children, cb) { var index = -1; children.forEach(function (c) { index++; if (c && c.type && c.type.isMenuItemGroup) { c.$slots['default'].forEach(function (c2) { index++; c.componentOptions && cb(c2, index); }); } else { c.componentOptions && cb(c, index); } }); } function loopMenuItemRecusively(children, keys, ret) { if (!children || ret.find) { return; } children.forEach(function (c) { if (ret.find) { return; } if (c.data && c.data.slot && c.data.slot !== 'default') { return; } if (c && c.componentOptions) { var options = c.componentOptions.Ctor.options; if (!options || !(options.isSubMenu || options.isMenuItem || options.isMenuItemGroup)) { return; } if (keys.indexOf(c.key) !== -1) { ret.find = true; } else if (c.componentOptions.children) { loopMenuItemRecusively(c.componentOptions.children, keys, ret); } } }); }