@carbon/ibm-products
Version:
Carbon for IBM Products
84 lines (82 loc) • 3.19 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.
*/
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_index = require("../../node_modules/classnames/index.js");
const require_settings = require("../../settings.js");
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@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__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_settings.pkg.prefix}--empty-state`;
const componentName = "EmptyStateContent";
const EmptyStateContent = (props) => {
const { action, link, headingAs, size, subtitle, title } = props;
const HeadingComponent = headingAs ?? _carbon_react.Heading;
return /* @__PURE__ */ react.default.createElement(_carbon_react.Section, { className: `${blockClass}__content` }, /* @__PURE__ */ react.default.createElement(HeadingComponent, { className: (0, import_classnames.default)(`${blockClass}__header`, { [`${blockClass}__header--small`]: size === "sm" }) }, title), subtitle && /* @__PURE__ */ react.default.createElement("div", { className: (0, import_classnames.default)(`${blockClass}__subtitle`, { [`${blockClass}__subtitle--small`]: size === "sm" }) }, subtitle), action?.text && action?.onClick && /* @__PURE__ */ react.default.createElement(_carbon_react.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.default.createElement(_carbon_react.Link, {
...link,
className: `${blockClass}__link`,
href: link.href
}, link.text));
};
EmptyStateContent.displayName = componentName;
EmptyStateContent.propTypes = {
/**
* Empty state action button
*/
action: prop_types.default.shape({
/**@ts-ignore*/
..._carbon_react.Button.propTypes,
iconDescription: prop_types.default.string,
kind: prop_types.default.oneOf([
"primary",
"secondary",
"tertiary"
]),
renderIcon: prop_types.default.oneOfType([prop_types.default.func, prop_types.default.object]),
/**@ts-ignore*/
onClick: _carbon_react.Button.propTypes.onClick,
text: prop_types.default.string
}),
/**
* Empty state headingAs allows you to customize the type of heading element
*/
headingAs: prop_types.default.elementType,
/**
* Empty state link object
*/
link: prop_types.default.any,
/**
* Empty state size
*/
size: prop_types.default.oneOf(["lg", "sm"]),
/**
* Empty state subtitle
*/
subtitle: prop_types.default.node,
/**
* Empty state title
*/
title: prop_types.default.node.isRequired
};
//#endregion
exports.EmptyStateContent = EmptyStateContent;