UNPKG

@awsui/components-react

Version:

On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en

20 lines 972 B
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // Flattens the items and assigns indices in ascending order for keyboard navigation export function getAllVisibleItemsIndices({ items, expandedItems, getItemId, getItemChildren, }) { const allIndicesByItemId = {}; let currentIndex = 0; const traverse = (item, index) => { const itemId = getItemId(item, index); const children = getItemChildren(item, index); allIndicesByItemId[itemId] = currentIndex; currentIndex += 1; const isExpanded = children && children.length > 0 && (expandedItems === null || expandedItems === void 0 ? void 0 : expandedItems.includes(itemId)); if (isExpanded) { children.forEach((child, index) => traverse(child, index)); } }; items.forEach((item, index) => traverse(item, index)); return allIndicesByItemId; } //# sourceMappingURL=utils.js.map