UNPKG

@carbon/ibm-products

Version:

Carbon for IBM Products

86 lines (79 loc) 2.87 kB
/** * 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. */ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js'; import React__default from 'react'; import PropTypes from '../../_virtual/index.js'; import cx from 'classnames'; import { Close } from '@carbon/react/icons'; import { Button } from '@carbon/react'; import { getDevtoolsProps } from '../../global/js/utils/devtools.js'; import { pkg } from '../../settings.js'; // The block part of our conventional BEM class names (blockClass__E--M). const blockClass = `${pkg.prefix}--coachmark-header`; const overlayBlockClass = `${pkg.prefix}--coachmark-overlay`; const componentName = 'CoachmarkHeader'; const defaults = { closeIconDescription: 'Close', onClose: () => {}, showCloseButton: true, theme: 'light' }; /** * DO NOT USE. This component is for the exclusive use * of other Onboarding components. */ let CoachmarkHeader = /*#__PURE__*/React__default.forwardRef((_ref, ref) => { let { closeIconDescription = defaults.closeIconDescription, onClose = defaults.onClose, showCloseButton = defaults.showCloseButton, theme = defaults.theme, // Collect any other property values passed in. ...rest } = _ref; return /*#__PURE__*/React__default.createElement("header", _extends({}, rest, { className: cx(blockClass, `${blockClass}__${theme}`), ref: ref }, getDevtoolsProps(componentName)), showCloseButton && /*#__PURE__*/React__default.createElement("div", { className: `${overlayBlockClass}--close-btn-container` }, /*#__PURE__*/React__default.createElement(Button, { kind: "ghost", size: "sm", renderIcon: Close, iconDescription: closeIconDescription, hasIconOnly: true, className: `${overlayBlockClass}--close-btn`, onClick: onClose }))); }); // Return a placeholder if not released and not enabled by feature flag CoachmarkHeader = pkg.checkComponentEnabled(CoachmarkHeader, componentName); // The display name of the component, used by React. Note that displayName // is used in preference to relying on function.name. CoachmarkHeader.displayName = componentName; // The types and DocGen commentary for the component props, // in alphabetical order (for consistency). // See https://www.npmjs.com/package/prop-types#usage. 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']) }; export { CoachmarkHeader };