@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
36 lines (35 loc) • 1.73 kB
JavaScript
import StatusIndicator from '../../../status-indicator/internal';
import React, { useCallback } from 'react';
import styles from './styles.css.js';
import { fireNonCancelableEvent } from '../../events';
var DropdownStatus = function (props) {
var statusType = props.statusType, empty = props.empty, loadingText = props.loadingText, finishedText = props.finishedText, errorText = props.errorText, recoveryText = props.recoveryText, isEmpty = props.isEmpty, isNoMatch = props.isNoMatch, noMatch = props.noMatch, onRecoveryClick = props.onRecoveryClick;
var statusContent = null;
var handleRecoveryClick = useCallback(function (e) {
e.preventDefault();
fireNonCancelableEvent(onRecoveryClick);
}, [onRecoveryClick]);
if (statusType === 'loading') {
statusContent = React.createElement(StatusIndicator, { type: 'loading' }, loadingText);
}
else if (statusType === 'error') {
statusContent = (React.createElement(React.Fragment, null,
React.createElement(StatusIndicator, { type: 'error', uxdgInverted: true }, errorText),
' ',
recoveryText && (React.createElement("a", { role: "button", tabIndex: -1, className: styles.recovery, onClick: handleRecoveryClick }, recoveryText))));
}
else if (isEmpty && empty) {
statusContent = empty;
}
else if (isNoMatch && noMatch) {
statusContent = noMatch;
}
else if (statusType === 'finished' && finishedText) {
statusContent = finishedText;
}
if (statusContent === null) {
return null;
}
return (React.createElement("div", { "aria-hidden": true, className: styles.root }, statusContent));
};
export default DropdownStatus;