@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
22 lines (21 loc) • 1.36 kB
JavaScript
import { __assign } from "tslib";
import React, { useCallback } from 'react';
import styles from './styles.css.js';
import Icon from '../../../../icon';
import useFocusVisible from '../../../hooks/focus-visible';
import { fireNonCancelableEvent } from '../../../events';
var SelectToggle = function (_a) {
var controlId = _a.controlId, allHidden = _a.allHidden, expanded = _a.expanded, numberOfHiddenOptions = _a.numberOfHiddenOptions, onClick = _a.onClick, _b = _a.i18nStrings, i18nStrings = _b === void 0 ? {} : _b;
var focusVisible = useFocusVisible();
var numberOfHiddenOptionLabel = allHidden ? numberOfHiddenOptions : "+" + numberOfHiddenOptions;
var description = expanded
? i18nStrings.tokenLimitShowFewer
: (i18nStrings.tokenLimitShowMore || '') + " (" + numberOfHiddenOptionLabel + ")";
var handleClick = useCallback(function () {
fireNonCancelableEvent(onClick, null);
}, [onClick]);
return (React.createElement("button", __assign({ type: "button", className: styles.toggle, onClick: handleClick, "aria-controls": controlId, "aria-expanded": expanded }, focusVisible),
React.createElement(Icon, { name: expanded ? 'treeview-collapse' : 'treeview-expand', variant: "link" }),
React.createElement("span", { className: styles.description }, description)));
};
export default SelectToggle;