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

26 lines (25 loc) 1.8 kB
import { __assign, __rest } from "tslib"; import React from 'react'; import clsx from 'clsx'; import styles from './styles.css.js'; import Option from '../../internal/components/option'; import SelectableItem from '../../internal/components/selectable-item'; import { getBaseProps } from '../../internal/base-component'; import CheckboxIcon from '../../internal/components/checkbox-icon'; var Item = function (_a, ref) { var _b; var option = _a.option, highlighted = _a.highlighted, selected = _a.selected, filteringValue = _a.filteringValue, hasCheckbox = _a.hasCheckbox, isKeyboard = _a.isKeyboard, virtualPosition = _a.virtualPosition, restProps = __rest(_a, ["option", "highlighted", "selected", "filteringValue", "hasCheckbox", "isKeyboard", "virtualPosition"]); var baseProps = getBaseProps(restProps); var isParent = option.type === 'parent'; var isChild = option.type === 'child'; var wrappedOption = option.option; var className = clsx(styles.item, (_b = {}, _b[styles.disabled] = option.disabled, _b)); return (React.createElement(SelectableItem, __assign({ selected: selected, highlighted: highlighted, disabled: option.disabled, isParent: isParent, isChild: isChild, isKeyboard: isKeyboard, ref: ref, virtualPosition: virtualPosition }, baseProps), React.createElement("div", { className: className }, hasCheckbox && !isParent && (React.createElement("div", { className: styles.checkbox }, React.createElement(CheckboxIcon, { checked: selected || false, disabled: option.disabled }))), isParent ? (wrappedOption.label || wrappedOption.value) : (React.createElement(Option, { option: wrappedOption, highlightText: filteringValue }))))); }; export default React.memo(React.forwardRef(Item));