UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

28 lines (27 loc) 931 B
"use client"; //#region packages/@mantine/core/src/components/Cascader/get-cascader-columns.ts function cascaderOptionHasChildren(option) { return Array.isArray(option.children) && option.children.length > 0; } function findCascaderOption(options, value) { return options.find((option) => option.value === value); } function getCascaderColumns(data, activePath) { const columns = [data]; let level = data; for (let index = 0; index < activePath.length; index += 1) { const node = findCascaderOption(level, activePath[index]); if (!node) break; const isLast = index === activePath.length - 1; if (Array.isArray(node.children) && node.children.length > 0) { if (!isLast) { columns.push(node.children); level = node.children; } } else break; } return columns; } //#endregion export { cascaderOptionHasChildren, findCascaderOption, getCascaderColumns }; //# sourceMappingURL=get-cascader-columns.mjs.map