UNPKG

@carbon/ibm-products

Version:
82 lines (80 loc) 2.81 kB
/** * 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 React from "react"; import PropTypes from "prop-types"; import { Button, Heading, Link, Section } from "@carbon/react"; //#region src/components/EmptyStates/EmptyStateContent.tsx /** * Copyright IBM Corp. 2020, 2021 * * 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}--empty-state`; const componentName = "EmptyStateContent"; const EmptyStateContent = (props) => { const { action, link, headingAs, size, subtitle, title } = props; const HeadingComponent = headingAs ?? Heading; return /* @__PURE__ */ React.createElement(Section, { className: `${blockClass}__content` }, /* @__PURE__ */ React.createElement(HeadingComponent, { className: (0, import_classnames.default)(`${blockClass}__header`, { [`${blockClass}__header--small`]: size === "sm" }) }, title), subtitle && /* @__PURE__ */ React.createElement("div", { className: (0, import_classnames.default)(`${blockClass}__subtitle`, { [`${blockClass}__subtitle--small`]: size === "sm" }) }, subtitle), action?.text && action?.onClick && /* @__PURE__ */ React.createElement(Button, { ...action, className: `${blockClass}__action-button`, kind: action.kind || "tertiary", onClick: action.onClick, renderIcon: action.renderIcon ?? void 0, size: "sm" }, action.text), link?.text && link?.href && /* @__PURE__ */ React.createElement(Link, { ...link, className: `${blockClass}__link`, href: link.href }, link.text)); }; EmptyStateContent.displayName = componentName; EmptyStateContent.propTypes = { /** * Empty state action button */ action: PropTypes.shape({ /**@ts-ignore*/ ...Button.propTypes, iconDescription: PropTypes.string, kind: PropTypes.oneOf([ "primary", "secondary", "tertiary" ]), renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), /**@ts-ignore*/ onClick: Button.propTypes.onClick, text: PropTypes.string }), /** * Empty state headingAs allows you to customize the type of heading element */ headingAs: PropTypes.elementType, /** * Empty state link object */ link: PropTypes.any, /** * Empty state size */ size: PropTypes.oneOf(["lg", "sm"]), /** * Empty state subtitle */ subtitle: PropTypes.node, /** * Empty state title */ title: PropTypes.node.isRequired }; //#endregion export { EmptyStateContent };