@carbon/ibm-products
Version:
Carbon for IBM Products
84 lines (82 loc) • 2.85 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { __toESM } from "../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../node_modules/classnames/index.js";
import { pkg } from "../../settings.js";
import { getDevtoolsProps } from "../../global/js/utils/devtools.js";
import React from "react";
import PropTypes from "prop-types";
import { Button } from "@carbon/react";
import { Restart } from "@carbon/react/icons";
//#region src/components/StatusIndicator/StatusIndicator.jsx
/**
* Copyright IBM Corp. 2024, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ __toESM(require_classnames());
const blockClass = `${pkg.prefix}--status-indicator`;
const componentName = "StatusIndicator";
const defaults = {
retryLabel: "Retry",
showRetry: false
};
/**
* A list of icon/description pairs used to show multiple states of progress.
* @deprecated This component is deprecated
*/
let StatusIndicator = React.forwardRef(({ children, className, onRetry, retryLabel = defaults.retryLabel, showRetry = defaults.showRetry, title, ...rest }, ref) => {
return /* @__PURE__ */ React.createElement("div", {
...rest,
className: (0, import_classnames.default)(blockClass, className),
ref,
...getDevtoolsProps(componentName)
}, title && /* @__PURE__ */ React.createElement("h1", { className: `${blockClass}__title` }, title), /* @__PURE__ */ React.createElement("ul", { className: `${blockClass}__list` }, children), showRetry && onRetry && retryLabel && /* @__PURE__ */ React.createElement(Button, {
className: `${blockClass}__button`,
kind: "ghost",
onClick: onRetry,
onKeyUp: onRetry,
renderIcon: () => /* @__PURE__ */ React.createElement(Restart, { size: 16 })
}, retryLabel));
});
StatusIndicator.deprecated = {
level: "warn",
details: `This component is deprecated`
};
StatusIndicator = pkg.checkComponentEnabled(StatusIndicator, componentName);
StatusIndicator.displayName = componentName;
StatusIndicator.propTypes = {
/**
* Provide the contents of the StatusIndicator.
*/
children: PropTypes.node.isRequired,
/**
* Provide an optional class to be applied to the containing node.
*/
className: PropTypes.string,
/**
* Optional callback function for the retry button.
*/
onRetry: PropTypes.func,
/**
* The text for the retry button.
*/
retryLabel: PropTypes.string,
/**
* Set to `true` to show the retry button.
*
* `retryLabel` and `onRetry` must also be defined.
*/
showRetry: PropTypes.bool,
/**
* The title that appears at the top of the list.
*/
title: PropTypes.node
};
//#endregion
export { StatusIndicator };