@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
25 lines • 3.41 kB
JavaScript
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import { useMobile } from '../internal/hooks/use-mobile';
import CategoryElement from './category-elements/category-element';
import ExpandableCategoryElement from './category-elements/expandable-category-element';
import MobileExpandableCategoryElement from './category-elements/mobile-expandable-category-element';
import ItemElement from './item-element';
import { isItemGroup } from './utils/utils';
export default function ItemsList({ items, onItemActivate, onGroupToggle, targetItem, isHighlighted, isKeyboardHighlight, isExpanded, lastInDropdown, highlightItem, categoryDisabled = false, hasExpandableGroups = false, hasCategoryHeader = false, expandToViewport = false, variant = 'normal', analyticsMetadataTransformer, position, linkStyle, }) {
const isMobile = useMobile();
const elements = items.map((item, index) => {
var _a, _b, _c, _d;
if (!isItemGroup(item)) {
const showDivider = (index === items.length - 1 && !lastInDropdown) || isItemGroup(items[index + 1]);
return (React.createElement(ItemElement, { key: index, item: item, onItemActivate: onItemActivate, disabled: (_a = item.disabled) !== null && _a !== void 0 ? _a : categoryDisabled, highlighted: isHighlighted(item), isKeyboardHighlighted: isKeyboardHighlight(item), highlightItem: highlightItem, showDivider: showDivider, hasCategoryHeader: hasCategoryHeader, variant: variant, position: `${position ? `${position},` : ''}${index + 1}`, analyticsMetadataTransformer: analyticsMetadataTransformer, linkStyle: linkStyle }));
}
if (hasExpandableGroups) {
return item.text ? (isMobile ? (React.createElement(MobileExpandableCategoryElement, { key: index, item: item, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isKeyboardHighlight: isKeyboardHighlight, isExpanded: isExpanded, lastInDropdown: lastInDropdown && index === items.length - 1, highlightItem: highlightItem, disabled: (_b = item.disabled) !== null && _b !== void 0 ? _b : false, variant: variant, position: `${position ? `${position},` : ''}${index + 1}` })) : (React.createElement(ExpandableCategoryElement, { key: index, item: item, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isKeyboardHighlight: isKeyboardHighlight, isExpanded: isExpanded, lastInDropdown: true, highlightItem: highlightItem, disabled: (_c = item.disabled) !== null && _c !== void 0 ? _c : false, expandToViewport: expandToViewport, variant: variant, position: `${position ? `${position},` : ''}${index + 1}` }))) : null;
}
return (React.createElement(CategoryElement, { key: index, item: item, onItemActivate: onItemActivate, onGroupToggle: onGroupToggle, targetItem: targetItem, isHighlighted: isHighlighted, isKeyboardHighlight: isKeyboardHighlight, isExpanded: isExpanded, lastInDropdown: lastInDropdown && index === items.length - 1, highlightItem: highlightItem, disabled: (_d = item.disabled) !== null && _d !== void 0 ? _d : false, variant: variant, position: `${position ? `${position},` : ''}${index + 1}` }));
});
return React.createElement(React.Fragment, null, elements);
}
//# sourceMappingURL=items-list.js.map