UNPKG

@awsui/components-react

Version:

On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en

32 lines 1.81 kB
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import React from 'react'; import { warnOnce } from '@awsui/component-toolkit/internal'; import InternalLiveRegion from '../../live-region/internal'; import { applyTrackBy } from '../utils'; import styles from './styles.css.js'; export function ItemsLoader({ item, trackBy, children }) { let parentTrackId = item && trackBy ? applyTrackBy(trackBy, item) : undefined; parentTrackId = typeof parentTrackId === 'string' ? parentTrackId : undefined; return (React.createElement("div", { "data-root": item ? 'false' : 'true', "data-parentrow": parentTrackId, className: styles['items-loader'] }, children)); } export function getLoaderContent({ item, loadingStatus, renderLoaderPending, renderLoaderLoading, renderLoaderError, renderLoaderEmpty, }) { let content = null; if (loadingStatus === 'pending' && renderLoaderPending) { content = renderLoaderPending({ item }); } else if (loadingStatus === 'loading' && renderLoaderLoading) { content = React.createElement(InternalLiveRegion, { tagName: "span" }, renderLoaderLoading({ item })); } else if (loadingStatus === 'error' && renderLoaderError) { content = React.createElement(InternalLiveRegion, { tagName: "span" }, renderLoaderError({ item })); } else if (loadingStatus === 'finished' && renderLoaderEmpty && item) { content = React.createElement(InternalLiveRegion, { tagName: "span" }, renderLoaderEmpty({ item })); } else { warnOnce('Table', 'Must define `renderLoaderPending`, `renderLoaderLoading`, `renderLoaderError`, or `renderLoaderEmpty` when using corresponding loading status.'); } return content; } //# sourceMappingURL=items-loader.js.map