tdesign-mobile-vue
Version:
tdesign-mobile-vue
41 lines (37 loc) • 1.33 kB
JavaScript
/**
* tdesign v1.9.3
* (c) 2025 TDesign Group
* @license MIT
*/
import { _ as _toConsumableArray } from '../../../_chunks/dep-fb4113ef.mjs';
import { _ as _typeof } from '../../../_chunks/dep-4915223e.mjs';
import '../../../_chunks/dep-a953013f.mjs';
function findParentValues(options, targetValue, realValue, realChildren) {
var currentTargetValue = targetValue;
if (currentTargetValue != null && _typeof(currentTargetValue) === "object") {
var _currentTargetValue;
currentTargetValue = (_currentTargetValue = currentTargetValue) === null || _currentTargetValue === void 0 ? void 0 : _currentTargetValue[realValue];
}
if (currentTargetValue == null) return [];
function findPath(nodes, parentPath) {
var result = null;
nodes.some(function (node) {
var newPath = [].concat(_toConsumableArray(parentPath), [node[realValue]]);
if (node[realValue] === currentTargetValue) {
result = parentPath;
return true;
}
if (Array.isArray(node[realChildren]) && node[realChildren].length) {
result = findPath(node[realChildren], newPath);
if (result !== null) {
return true;
}
}
return false;
});
return result;
}
return findPath(options, []) || [];
}
export { findParentValues };
//# sourceMappingURL=utils.mjs.map