@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
35 lines • 1.98 kB
JavaScript
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React, { forwardRef, useImperativeHandle } from 'react';
import OptionsList from '../../internal/components/options-list';
import { scrollElementIntoView } from '../../internal/utils/scrollable-containers';
import { renderOptions } from '../utils/render-options';
import styles from './styles.css.js';
const PlainList = ({ menuProps, getOptionProps, filteredOptions, filteringValue, highlightType, checkboxes, hasDropdownStatus, listBottom, useInteractiveGroups, screenReaderContent, }, ref) => {
const menuRef = menuProps.ref;
useImperativeHandle(ref, () => (index) => {
var _a, _b, _c;
const item = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-mouse-target="${index}"]`);
if (highlightType.moveFocus && item) {
// In edge case dropdown can be very small, scrolling can cause side effect AWSUI-60318
if (((_b = menuRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight) !== undefined && ((_c = menuRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight) > 15) {
/* istanbul ignore next: clientHeight always returns 0 in JSDOM, the line is covered by integ tests */
scrollElementIntoView(item);
}
}
}, [highlightType, menuRef]);
return (React.createElement(OptionsList, Object.assign({}, menuProps),
renderOptions({
options: filteredOptions,
getOptionProps,
filteringValue,
highlightType,
checkboxes,
hasDropdownStatus,
useInteractiveGroups,
screenReaderContent,
}),
listBottom ? (React.createElement("li", { role: "option", className: styles['list-bottom'] }, listBottom)) : null));
};
export default forwardRef(PlainList);
//# sourceMappingURL=plain-list.js.map