UNPKG

@carbon/ibm-products

Version:

Carbon for IBM Products

94 lines (86 loc) 2.85 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 PropTypes from '../../_virtual/index.js'; import React__default from 'react'; import cx from 'classnames'; import { getDevtoolsProps } from '../../global/js/utils/devtools.js'; import { pkg } from '../../settings.js'; import { Button } from '@carbon/react'; var _circle; // The block part of our conventional BEM class names (blockClass__E--M). const blockClass = `${pkg.prefix}--coachmark-beacon`; const componentName = 'CoachmarkBeacon'; const defaults = { kind: 'default' }; /** * Use beacon for the target prop of a Coachmark component. */ let CoachmarkBeacon = /*#__PURE__*/React__default.forwardRef((props, ref) => { const { label, className, kind = defaults.kind, buttonProps, ...rest } = props; return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, { className: cx(blockClass, `${blockClass}-${kind}`, className), ref: ref }, getDevtoolsProps(componentName), { role: "tooltip" }), /*#__PURE__*/React__default.createElement("button", _extends({ type: "button" }, buttonProps, { className: `${blockClass}__target` }), /*#__PURE__*/React__default.createElement("svg", { className: `${blockClass}__center`, "aria-label": label }, /*#__PURE__*/React__default.createElement("title", null, label), _circle || (_circle = /*#__PURE__*/React__default.createElement("circle", { r: 1, cx: 38, cy: 38 }))))); }); // Return a placeholder if not released and not enabled by feature flag CoachmarkBeacon = pkg.checkComponentEnabled(CoachmarkBeacon, componentName); // The display name of the component, used by React. Note that displayName // is used in preference to relying on function.name. CoachmarkBeacon.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. CoachmarkBeacon.propTypes = { /** * button props */ buttonProps: PropTypes.shape({ /**@ts-ignore*/ ...Button.propTypes, /**@ts-ignore*/ onClick: PropTypes.func, onDoubleClick: PropTypes.func, tabIndex: PropTypes.number, ['aria-expanded']: PropTypes.bool }), /** * Optional class name for this component. */ className: PropTypes.string, /** * What style of beacon. * BEACON_KIND is an exported enum from the Coachmark and can be used for this value. * @see {@link BEACON_KIND} */ kind: PropTypes.oneOf(['default']), /** * The aria label. */ label: PropTypes.string.isRequired }; export { CoachmarkBeacon };