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

20 lines (19 loc) 1.45 kB
import { __assign } from "tslib"; import OptionsList from '../internal/components/options-list'; import AutosuggestOption from './autosuggest-option'; import React, { forwardRef, useImperativeHandle, useRef } from 'react'; var PlainList = function (_a, ref) { var handleLoadMore = _a.handleLoadMore, filteredItems = _a.filteredItems, value = _a.value, usingMouse = _a.usingMouse, highlightedOption = _a.highlightedOption, enteredTextLabel = _a.enteredTextLabel, dropdownStatus = _a.dropdownStatus, highlightedA11yProps = _a.highlightedA11yProps; var listRef = useRef(null); useImperativeHandle(ref, function () { return function (index) { var _a; var item = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-mouse-target=\"" + index + "\"]"); if (!usingMouse.current && item) { item.scrollIntoView({ block: 'nearest' }); } }; }, [usingMouse, listRef]); return (React.createElement(OptionsList, { onLoadMore: handleLoadMore, open: true, ref: listRef }, filteredItems.map(function (item, index) { return (React.createElement(AutosuggestOption, __assign({ highlightText: value, option: item, highlighted: item === highlightedOption, key: index, "data-mouse-target": index, enteredTextLabel: enteredTextLabel }, (item === highlightedOption ? highlightedA11yProps : {})))); }), dropdownStatus)); }; export default forwardRef(PlainList);