tdesign-mobile-vue
Version:
tdesign-mobile-vue
49 lines (41 loc) • 1.69 kB
JavaScript
/**
* tdesign v1.9.3
* (c) 2025 TDesign Group
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
var _typeof = require('@babel/runtime/helpers/typeof');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
function findParentValues(options, targetValue, realValue, realChildren) {
var currentTargetValue = targetValue;
if (currentTargetValue != null && _typeof__default["default"](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__default["default"](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, []) || [];
}
exports.findParentValues = findParentValues;
//# sourceMappingURL=utils.js.map