UNPKG

@carbon/ibm-products

Version:
81 lines (79 loc) 2.69 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 { getDevtoolsProps } from "../../global/js/utils/devtools.js"; import { useCoachmark } from "./utils/context.js"; import React from "react"; import PropTypes from "prop-types"; import { Button } from "@carbon/react"; import { Close } from "@carbon/react/icons"; //#region src/components/Coachmark/CoachmarkHeader.tsx /** * Copyright IBM Corp. 2023, 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__ */ __toESM(require_classnames()); const blockClass = `${pkg.prefix}--coachmark-header`; const overlayBlockClass = `${pkg.prefix}--coachmark-overlay`; const componentName = "CoachmarkHeader"; const defaults = { onClose: () => {}, showCloseButton: true, theme: "light" }; /** * DO NOT USE. This component is for the exclusive use * of other Onboarding components. * @deprecated This component is deprecated. */ const CoachmarkHeader = React.forwardRef(({ onClose = defaults.onClose, showCloseButton = defaults.showCloseButton, theme = defaults.theme, ...rest }, ref) => { const closeIconDescription = useCoachmark()?.closeIconDescription; return /* @__PURE__ */ React.createElement("header", { ...rest, className: (0, import_classnames.default)(blockClass, `${blockClass}__${theme}`), ref, ...getDevtoolsProps(componentName) }, showCloseButton && /* @__PURE__ */ React.createElement("div", { className: `${overlayBlockClass}--close-btn-container` }, /* @__PURE__ */ React.createElement(Button, { kind: "ghost", size: "sm", renderIcon: Close, iconDescription: closeIconDescription, hasIconOnly: true, className: `${overlayBlockClass}--close-btn`, onClick: onClose }))); }); /**@ts-ignore*/ CoachmarkHeader.deprecated = { level: "warn", details: `${componentName} is deprecated.` }; CoachmarkHeader.displayName = componentName; CoachmarkHeader.propTypes = { /** * Tooltip text and aria label for the Close button icon. */ closeIconDescription: PropTypes.string, /** * Function to call when the close button is clicked. */ onClose: PropTypes.func, /** * Show/hide the "X" close button. */ showCloseButton: PropTypes.bool, /** * Determines the theme of the component. */ theme: PropTypes.oneOf(["light", "dark"]) }; //#endregion export { CoachmarkHeader };