UNPKG

@carbon/ibm-products

Version:
84 lines (82 loc) 2.3 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 React from "react"; import PropTypes from "prop-types"; import { IconButton } from "@carbon/react"; //#region src/components/ActionBar/ActionBarItem.tsx var import_classnames = /* @__PURE__ */ __toESM(require_classnames()); const componentName = "ActionBarItem"; const blockClass = `${pkg.prefix}--action-bar-item`; /** * The ActionBarItem is used in the page header to populate the action bar */ const ActionBarItem = React.forwardRef(({ label, className, renderIcon, ...rest }, ref) => { const Icon = renderIcon; return /* @__PURE__ */ React.createElement(IconButton, { ...rest, ref, className: (0, import_classnames.default)(blockClass, className), kind: "ghost", size: "md", align: "bottom-end", type: "button", label }, Icon ? /* @__PURE__ */ React.createElement(Icon, null) : null); }); const reservedProps = [ "kind", "size", "align", "type" ]; const propTypes = { ...IconButton.propTypes }; reservedProps.forEach((prop) => { delete propTypes[prop]; }); ActionBarItem.displayName = componentName; ActionBarItem.propTypes = { /** * The ...propTypes are copies of those from Button minus the props reserved for use by this component */ ...propTypes, /** * Specify an optional className to be added to your Button * * (inherited from Carbon Button) */ className: PropTypes.string, /** * If specifying the `renderIcon` prop, provide a description for that icon that can * be read by screen readers * * (inherited from Carbon Button) */ label: PropTypes.string, /** * Optional click handler * * (inherited from Carbon Button) */ onClick: PropTypes.func, /** * Optional prop to allow overriding the icon rendering. * Can be a React component class * * (inherited from Carbon Button) */ /**@ts-ignore */ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), /** * Optional tab index */ tabIndex: PropTypes.number }; //#endregion export { ActionBarItem };