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

39 lines (38 loc) 2.17 kB
import React, { useCallback, useMemo } from 'react'; import { fireNonCancelableEvent } from '../../events'; import StatusIndicator from '../../../status-indicator'; import Link from '../../../link'; import styles from './styles.css.js'; export function getChartStatus(_a) { var externalData = _a.externalData, visibleData = _a.visibleData, statusType = _a.statusType; var isEmpty = !visibleData || visibleData.length === 0; var isNoMatch = isEmpty && visibleData.length !== externalData.length; var showChart = statusType === 'finished' && !isEmpty; return { isEmpty: isEmpty, isNoMatch: isNoMatch, showChart: showChart }; } var ChartStatusContainer = function (_a) { var statusType = _a.statusType, errorText = _a.errorText, loadingText = _a.loadingText, recoveryText = _a.recoveryText, noMatch = _a.noMatch, empty = _a.empty, onRecoveryClick = _a.onRecoveryClick, isNoMatch = _a.isNoMatch, isEmpty = _a.isEmpty, showChart = _a.showChart; var handleRecoveryClick = useCallback(function (e) { e.preventDefault(); fireNonCancelableEvent(onRecoveryClick); }, [onRecoveryClick]); var statusContainer = useMemo(function () { if (statusType === 'error') { return (React.createElement("span", null, React.createElement(StatusIndicator, { type: "error" }, errorText), ' ', recoveryText && React.createElement(Link, { onFollow: handleRecoveryClick }, recoveryText))); } if (statusType === 'loading') { return React.createElement(StatusIndicator, { type: "loading" }, loadingText); } if (isNoMatch) { return React.createElement("div", { className: styles.empty }, noMatch); } if (isEmpty) { return React.createElement("div", { className: styles.empty }, empty); } }, [statusType, handleRecoveryClick, isEmpty, isNoMatch, recoveryText, loadingText, errorText, empty, noMatch]); return (React.createElement("div", { className: styles.root, "aria-live": "polite", "aria-atomic": "true" }, !showChart && statusContainer)); }; export default ChartStatusContainer;