@carbon/react
Version:
React components for the Carbon Design System
74 lines (72 loc) • 1.99 kB
JavaScript
/**
* 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.
*/
import { usePrefix } from "../../internal/usePrefix.js";
import Button_default from "../Button/index.js";
import classNames from "classnames";
import React from "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
//#region src/components/ChatButton/ChatButton.tsx
/**
* Copyright IBM Corp. 2024, 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.
*/
const ChatButton = React.forwardRef(function ChatButton({ className, children, disabled, isQuickAction, isSelected, kind, renderIcon, size, ...other }, ref) {
const prefix = usePrefix();
const classNames$1 = classNames(className, {
[`${prefix}--chat-btn`]: true,
[`${prefix}--chat-btn--with-icon`]: renderIcon,
[`${prefix}--chat-btn--quick-action`]: isQuickAction,
[`${prefix}--chat-btn--quick-action--selected`]: isSelected
});
const allowedSizes = [
"sm",
"md",
"lg"
];
if (isQuickAction) {
kind = "ghost";
size = "sm";
} else if (size && !allowedSizes.includes(size)) {
console.error(`Invalid size "${size}" provided to ChatButton. Size must be one of: ${allowedSizes.join(", ")}. Defaulting to "lg".`);
size = "lg";
}
return /* @__PURE__ */ jsx(Button_default, {
disabled,
className: classNames$1,
kind,
ref,
size,
renderIcon,
...other,
children
});
});
ChatButton.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
disabled: PropTypes.bool,
isQuickAction: PropTypes.bool,
isSelected: PropTypes.bool,
kind: PropTypes.oneOf([
"primary",
"secondary",
"danger",
"ghost",
"tertiary"
]),
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
size: PropTypes.oneOf([
"sm",
"md",
"lg"
])
};
//#endregion
export { ChatButton as default };