@carbon/ibm-products
Version:
Carbon for IBM Products
116 lines (114 loc) • 3.81 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 { EmptyStateContent } from "../EmptyStateContent.js";
import { defaults } from "../EmptyState.js";
import { NoDataIllustration } from "../assets/NoDataIllustration.js";
import React from "react";
import PropTypes from "prop-types";
import { Button } from "@carbon/react";
//#region src/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.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 = "NoDataEmptyState";
/**
* The `EmptyState` component follows the Carbon guidelines for empty states with some added specifications around illustration usage. For additional usage guidelines and documentation please refer to the links above.
*/
const NoDataEmptyState = React.forwardRef(({ action, className, illustrationPosition = defaults.position, illustrationTheme, illustrationDescription, link, size = defaults.size, headingAs, subtitle, title, ...rest }, ref) => {
return /* @__PURE__ */ React.createElement("div", {
...rest,
className: (0, import_classnames.default)(blockClass, className, `${blockClass}-position--${illustrationPosition}`, `${blockClass}-type--noData`),
ref,
...getDevtoolsProps(componentName)
}, /* @__PURE__ */ React.createElement(NoDataIllustration, {
theme: illustrationTheme,
size,
alt: illustrationDescription || title
}), /* @__PURE__ */ React.createElement(EmptyStateContent, {
action,
link,
size,
headingAs,
subtitle,
title: title || ""
}));
});
NoDataEmptyState.displayName = componentName;
NoDataEmptyState.propTypes = {
/**
* Empty state action button
*/
action: PropTypes.shape({
/**@ts-ignore */
...Button.propTypes,
kind: PropTypes.oneOf([
"primary",
"secondary",
"tertiary"
]),
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
/**@ts-ignore */
onClick: Button.propTypes.onClick,
text: PropTypes.string
}),
/**
* Provide an optional class to be applied to the containing node.
*/
className: PropTypes.string,
/**
* Empty state headingAs allows you to customize the type of heading element
*/
headingAs: PropTypes.elementType,
/**
* The alt text for empty state svg images. If not provided , title will be used.
*/
illustrationDescription: PropTypes.string,
/**
* Designates the position of the illustration relative to the content
*/
illustrationPosition: PropTypes.oneOf([
"top",
"right",
"bottom",
"left"
]),
/**
* Empty state illustration theme variations.
* To ensure you use the correct themed illustrations, you can conditionally specify light or dark
* based on your app's current theme value. Example:
* `illustrationTheme={appTheme === ('carbon--g100' || 'carbon--g90') ? 'dark' : 'light'}`
*/
illustrationTheme: PropTypes.oneOf(["light", "dark"]),
/**
* Empty state link object
*/
/**@ts-ignore */
link: PropTypes.any,
/**
* Empty state size
*/
size: PropTypes.oneOf(["lg", "sm"]),
/**
* Empty state subtitle
*/
subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
/**
* Empty state title
*/
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired
};
//#endregion
export { NoDataEmptyState };