UNPKG

@carbon/ibm-products

Version:
130 lines (128 loc) 4.67 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. */ const require_runtime = require("../../_virtual/_rolldown/runtime.js"); const require_index = require("../../node_modules/classnames/index.js"); const require_settings = require("../../settings.js"); const require_devtools = require("../../global/js/utils/devtools.js"); require("../../global/js/utils/props-helper.js"); const require_EmptyStateV2_deprecated = require("./EmptyStateV2.deprecated.js"); const require_EmptyStateContent = require("./EmptyStateContent.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/EmptyState.tsx /** * Copyright IBM Corp. 2020, 2025 * * 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 = "EmptyState"; const defaults = { position: "top", size: "lg" }; /** * 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 EmptyState = react.default.forwardRef(({ v2 = false, ...props }, ref) => { if (v2) return /* @__PURE__ */ react.default.createElement(require_EmptyStateV2_deprecated.EmptyStateV2, props); const { action, className, illustration, illustrationDescription, illustrationPosition = defaults.position, link, size = defaults.size, headingAs, subtitle, title, ...rest } = props; return /* @__PURE__ */ react.default.createElement("div", { ...rest, className: (0, import_classnames.default)(blockClass, `${blockClass}-type--default`, className, { [`${blockClass}-position--${illustrationPosition}`]: !!illustration }), ref, ...require_devtools.getDevtoolsProps(componentName) }, illustration && /* @__PURE__ */ react.default.createElement("img", { src: illustration, alt: illustrationDescription, className: (0, import_classnames.default)([`${blockClass}__illustration`, `${blockClass}__illustration--${size}`]), "aria-hidden": "true" }), /* @__PURE__ */ react.default.createElement(require_EmptyStateContent.EmptyStateContent, { action, link, size, headingAs, subtitle, title: title ?? "" })); }); EmptyState.propTypes = { /** * Empty state action button */ action: prop_types.default.shape({ /**@ts-ignore*/ ..._carbon_react.Button.propTypes, 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 }), /** * Provide an optional class to be applied to the containing node. */ className: prop_types.default.string, /** * Empty state headingAs allows you to customize the type of heading element */ headingAs: prop_types.default.elementType, /** * Empty state illustration, specify the `src` for a provided illustration to be displayed. In the case of requiring a light and dark illustration of your own, simply pass the corresponding illustration based on the current theme of your application. * For example: `illustration={appTheme === 'dark' ? darkIllustration : lightIllustration}` */ illustration: prop_types.default.string, /** * The alt text for custom provided illustrations */ /**@ts-ignore*/ illustrationDescription: prop_types.default.string, /** * Designates the position of the illustration relative to the content */ illustrationPosition: prop_types.default.oneOf([ "top", "right", "bottom", "left" ]), /** * Empty state link object */ /**@ts-ignore*/ link: prop_types.default.any, /** * Empty state size */ size: prop_types.default.oneOf(["lg", "sm"]), /** * Empty state subtext */ subtitle: prop_types.default.node, /** * Empty state heading */ title: prop_types.default.node.isRequired, /** * **Deprecated:** Designates which version of the EmptyState component is being used. Refer to V2 documentation separately. * @deprecated */ v2: prop_types.default.bool }; EmptyState.displayName = componentName; //#endregion exports.EmptyState = EmptyState; exports.defaults = defaults;