@carbon/ibm-products
Version:
Carbon for IBM Products
86 lines (79 loc) • 2.94 kB
JavaScript
/**
* 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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var index = require('../../_virtual/index.js');
var cx = require('classnames');
var icons = require('@carbon/react/icons');
var react = require('@carbon/react');
var devtools = require('../../global/js/utils/devtools.js');
var settings = require('../../settings.js');
// The block part of our conventional BEM class names (blockClass__E--M).
const blockClass = `${settings.pkg.prefix}--coachmark-header`;
const overlayBlockClass = `${settings.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.
*/
exports.CoachmarkHeader = /*#__PURE__*/React.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.createElement("header", _rollupPluginBabelHelpers.extends({}, rest, {
className: cx(blockClass, `${blockClass}__${theme}`),
ref: ref
}, devtools.getDevtoolsProps(componentName)), showCloseButton && /*#__PURE__*/React.createElement("div", {
className: `${overlayBlockClass}--close-btn-container`
}, /*#__PURE__*/React.createElement(react.Button, {
kind: "ghost",
size: "sm",
renderIcon: icons.Close,
iconDescription: closeIconDescription,
hasIconOnly: true,
className: `${overlayBlockClass}--close-btn`,
onClick: onClose
})));
});
// Return a placeholder if not released and not enabled by feature flag
exports.CoachmarkHeader = settings.pkg.checkComponentEnabled(exports.CoachmarkHeader, componentName);
// The display name of the component, used by React. Note that displayName
// is used in preference to relying on function.name.
exports.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.
exports.CoachmarkHeader.propTypes = {
/**
* Tooltip text and aria label for the Close button icon.
*/
closeIconDescription: index.default.string,
/**
* Function to call when the close button is clicked.
*/
onClose: index.default.func,
/**
* Show/hide the "X" close button.
*/
showCloseButton: index.default.bool,
/**
* Determines the theme of the component.
*/
theme: index.default.oneOf(['light', 'dark'])
};