UNPKG

@carbon/react

Version:

React components for the Carbon Design System

80 lines (78 loc) 2.78 kB
/** * Copyright IBM Corp. 2016, 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_usePrefix = require("../../internal/usePrefix.js"); const require_index = require("../Button/index.js"); const require_AriaPropTypes = require("../../prop-types/AriaPropTypes.js"); let classnames = require("classnames"); classnames = require_runtime.__toESM(classnames); let react = require("react"); react = require_runtime.__toESM(react); let prop_types = require("prop-types"); prop_types = require_runtime.__toESM(prop_types); let react_jsx_runtime = require("react/jsx-runtime"); //#region src/components/UIShell/HeaderGlobalAction.tsx /** * Copyright IBM Corp. 2016, 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. */ /** * HeaderGlobalAction is used as a part of the `HeaderGlobalBar`. It is * essentially an Icon Button with an additional state to indicate whether it is * "active". The active state comes from when a user clicks on the global action * which should trigger a panel to appear. * * Note: children passed to this component should be an Icon. */ const HeaderGlobalAction = react.default.forwardRef(({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, className: customClassName, onClick, tooltipHighContrast = true, tooltipDropShadow, isActive, tooltipAlignment, ...rest }, ref) => { const prefix = require_usePrefix.usePrefix(); const className = (0, classnames.default)({ [customClassName]: !!customClassName, [`${prefix}--header__action`]: true, [`${prefix}--header__action--active`]: isActive }); const accessibilityLabel = { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, { ...rest, ...accessibilityLabel, className, onClick, type: "button", hasIconOnly: true, size: "lg", kind: "ghost", iconDescription: ariaLabel, tooltipPosition: "bottom", tooltipAlignment, tooltipDropShadow, tooltipHighContrast, ref, children }); }); HeaderGlobalAction.propTypes = { ...require_AriaPropTypes.AriaLabelPropType, children: prop_types.default.node.isRequired, className: prop_types.default.string, isActive: prop_types.default.bool, onClick: prop_types.default.func, tooltipAlignment: prop_types.default.oneOf([ "start", "center", "end" ]), tooltipDropShadow: prop_types.default.bool, tooltipHighContrast: prop_types.default.bool }; HeaderGlobalAction.displayName = "HeaderGlobalAction"; //#endregion exports.default = HeaderGlobalAction;