@carbon/ibm-products
Version:
Carbon for IBM Products
59 lines (57 loc) • 2.56 kB
JavaScript
/**
* 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.
*/
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_index = require("../../node_modules/classnames/index.js");
const require_Toolbar = require("./Toolbar.js");
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
let _carbon_react = require("@carbon/react");
//#region src/components/Toolbar/ToolbarButton.tsx
/**
* Copyright IBM Corp. 2021, 2024
*
* 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 import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_Toolbar.blockClass}__button`;
/** Toolbar buttons are common functions performed as part of a products interface or an open window. */
const ToolbarButton = (0, react.forwardRef)(({ caret = false, children, className, renderIcon, iconDescription: deprecated_iconDescription = "", label, ...rest }, ref) => {
const Icon = renderIcon;
return /* @__PURE__ */ react.default.createElement(_carbon_react.IconButton, {
align: (0, react.useContext)(require_Toolbar.ToolbarContext)?.vertical ? "right" : "top",
...rest,
label: label ?? deprecated_iconDescription,
ref,
className: (0, import_classnames.default)(className, { [`${blockClass}--caret`]: caret }),
kind: "ghost",
size: "md"
}, /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, Icon ? /* @__PURE__ */ react.default.createElement(Icon, null) : null, children, caret && /* @__PURE__ */ react.default.createElement("span", { className: `${blockClass}__caret` })));
});
ToolbarButton.displayName = "ToolbarButton";
const deprecatedProps = {
/**
* **Deprecated**
* Specifies the label for the icon button
* */
iconDescription: prop_types.string };
ToolbarButton.propTypes = {
/** Determines whether the caret is rendered */
caret: prop_types.bool,
/** Provide the content of the `ToolbarButton` */
children: prop_types.node,
/** Provide an optional class to be applied to the containing node */
className: prop_types.string,
/** Specifies the label for the icon button */
label: prop_types.string.isRequired,
/** Specifies the icon to be used by the ToolbarButton component */
renderIcon: prop_types.func.isRequired,
...deprecatedProps
};
//#endregion
exports.ToolbarButton = ToolbarButton;