tdesign-react
Version:
TDesign Component for React
33 lines (29 loc) • 1.51 kB
JavaScript
/**
* tdesign v1.11.6
* (c) 2025 tdesign
* @license MIT
*/
import { _ as _toConsumableArray } from '../../_chunks/dep-7a114245.js';
import React from 'react';
import { MenuBlockType } from './type.js';
import '../../_chunks/dep-901cf2d8.js';
function checkSubMenuChildExpanded(children, expanded, value) {
var _child$type, _expandedChild$type;
var resultExpanded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
var childValues = React.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) === MenuBlockType.SubMenu) {
return [].concat(_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) === MenuBlockType.SubMenu) {
return checkSubMenuChildExpanded(expandedChild.props.children, expanded.slice(1), value, [].concat(_toConsumableArray(resultExpanded), [expanded[0]]));
}
return [value];
}
export { checkSubMenuChildExpanded as default };
//# sourceMappingURL=checkSubMenuChildExpanded.js.map