tdesign-react
Version:
TDesign Component for React
41 lines (33 loc) • 1.86 kB
JavaScript
/**
* tdesign v1.11.6
* (c) 2025 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var toConsumableArray = require('../../_chunks/dep-f500d2b7.js');
var React = require('react');
var menu__util_type = require('./type.js');
require('../../_chunks/dep-6b4846c3.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
function checkSubMenuChildExpanded(children, expanded, value) {
var _child$type, _expandedChild$type;
var resultExpanded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
var childValues = React__default["default"].Children.map(children, function (child2) {
return child2.props.value;
});
var index = childValues.indexOf(value);
var child = children[index];
if (index > -1 && (child === null || child === void 0 || (_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) === menu__util_type.MenuBlockType.SubMenu) {
return [].concat(toConsumableArray._toConsumableArray(resultExpanded), [value]);
}
var expandedIndex = childValues.indexOf(expanded[0]);
var expandedChild = children[expandedIndex];
if (expandedIndex > -1 && (expandedChild === null || expandedChild === void 0 || (_expandedChild$type = expandedChild.type) === null || _expandedChild$type === void 0 ? void 0 : _expandedChild$type.displayName) === menu__util_type.MenuBlockType.SubMenu) {
return checkSubMenuChildExpanded(expandedChild.props.children, expanded.slice(1), value, [].concat(toConsumableArray._toConsumableArray(resultExpanded), [expanded[0]]));
}
return [value];
}
exports["default"] = checkSubMenuChildExpanded;
//# sourceMappingURL=checkSubMenuChildExpanded.js.map