UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

26 lines (25 loc) 803 B
"use client"; //#region packages/@mantine/core/src/components/Cascader/flatten-cascader-paths.ts function flattenCascaderPaths(data) { const result = []; const walk = (nodes, parentPath, parentOptions, parentDisabled) => { for (const node of nodes) { const path = [...parentPath, node.value]; const options = [...parentOptions, node]; const disabled = parentDisabled || !!node.disabled; const hasChildren = Array.isArray(node.children) && node.children.length > 0; result.push({ path, options, leaf: !hasChildren, disabled }); if (hasChildren) walk(node.children, path, options, disabled); } }; walk(data, [], [], false); return result; } //#endregion exports.flattenCascaderPaths = flattenCascaderPaths; //# sourceMappingURL=flatten-cascader-paths.cjs.map