UNPKG

@awsui/components-react

Version:

AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A

23 lines (22 loc) 1.28 kB
import { __assign } from "tslib"; import OptionsList from '../../internal/components/options-list'; import React, { forwardRef, useImperativeHandle, useMemo } from 'react'; import { renderOptions } from '../utils/render-options'; var PlainList = function (_a, ref) { var menuProps = _a.menuProps, getOptionProps = _a.getOptionProps, filteredOptions = _a.filteredOptions, filteringValue = _a.filteringValue, isKeyboard = _a.isKeyboard, dropdownStatus = _a.dropdownStatus, checkboxes = _a.checkboxes; var menuRef = menuProps.ref; useImperativeHandle(ref, function () { return function (index) { var _a; var item = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-mouse-target=\"" + index + "\"]"); if (isKeyboard && item) { item.scrollIntoView({ block: 'nearest' }); } }; }, [isKeyboard, menuRef]); var finalOptions = useMemo(function () { return renderOptions(filteredOptions, getOptionProps, filteringValue, isKeyboard, checkboxes); }, [filteredOptions, getOptionProps, filteringValue, isKeyboard, checkboxes]); return (React.createElement(OptionsList, __assign({}, menuProps), finalOptions, dropdownStatus)); }; export default forwardRef(PlainList);