UNPKG

@carbon/react

Version:

React components for the Carbon Design System

74 lines (72 loc) 2.23 kB
/** * Copyright IBM Corp. 2016, 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 { usePrefix } from "../../internal/usePrefix.js"; import { deprecate } from "../../prop-types/deprecate.js"; import classNames from "classnames"; import "react"; import PropTypes from "prop-types"; import { jsx, jsxs } from "react/jsx-runtime"; //#region src/components/Loading/Loading.tsx /** * Copyright IBM Corp. 2016, 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. */ function Loading({ active = true, className: customClassName, withOverlay = true, small = false, description = "loading", ...rest }) { const prefix = usePrefix(); const loadingClassName = classNames(customClassName, { [`${prefix}--loading`]: true, [`${prefix}--loading--small`]: small, [`${prefix}--loading--stop`]: !active }); const overlayClassName = classNames({ [`${prefix}--loading-overlay`]: true, [`${prefix}--loading-overlay--stop`]: !active }); const loading = /* @__PURE__ */ jsx("div", { ...rest, "aria-atomic": "true", "aria-live": active ? "assertive" : "off", className: loadingClassName, children: /* @__PURE__ */ jsxs("svg", { className: `${prefix}--loading__svg`, viewBox: "0 0 100 100", role: "img", "aria-label": description, children: [ /* @__PURE__ */ jsx("title", { children: description }), small ? /* @__PURE__ */ jsx("circle", { className: `${prefix}--loading__background`, cx: "50%", cy: "50%", r: "42" }) : null, /* @__PURE__ */ jsx("circle", { className: `${prefix}--loading__stroke`, cx: "50%", cy: "50%", r: small ? "42" : "44" }) ] }) }); return withOverlay ? /* @__PURE__ */ jsx("div", { className: overlayClassName, children: loading }) : loading; } Loading.propTypes = { active: PropTypes.bool, className: PropTypes.string, description: PropTypes.string, id: deprecate(PropTypes.string, `\nThe prop \`id\` is no longer needed.`), small: PropTypes.bool, withOverlay: PropTypes.bool }; //#endregion export { Loading as default };