@carbon/react
Version:
React components for the Carbon Design System
95 lines (93 loc) • 2.93 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.
*/
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_usePrefix = require("../../internal/usePrefix.js");
const require_noopFn = require("../../internal/noopFn.js");
const require_deprecateValuesWithin = require("../../prop-types/deprecateValuesWithin.js");
const require_mapPopoverAlign = require("../../tools/mapPopoverAlign.js");
const require_index = require("../Copy/index.js");
const require_index$1 = require("../Layout/index.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");
let _carbon_icons_react = require("@carbon/icons-react");
//#region src/components/CopyButton/CopyButton.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.
*/
function CopyButton({ align = "bottom", autoAlign = false, feedback = "Copied!", feedbackTimeout = 2e3, iconDescription = "Copy to clipboard", className, onClick = require_noopFn.noopFn, ...other }) {
const prefix = require_usePrefix.usePrefix();
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.LayoutConstraint, {
size: {
default: "md",
max: "lg"
},
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
feedback,
feedbackTimeout,
onClick,
align,
autoAlign,
className: (0, classnames.default)(className, `${prefix}--copy-btn`),
"aria-label": iconDescription,
...other,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.Copy, { className: `${prefix}--snippet__icon` })
})
});
}
CopyButton.propTypes = {
align: require_deprecateValuesWithin.deprecateValuesWithin(prop_types.default.oneOf([
"top",
"top-left",
"top-right",
"bottom",
"bottom-left",
"bottom-right",
"left",
"left-bottom",
"left-top",
"right",
"right-bottom",
"right-top",
"top-start",
"top-end",
"bottom-start",
"bottom-end",
"left-end",
"left-start",
"right-end",
"right-start"
]), [
"top",
"top-start",
"top-end",
"bottom",
"bottom-start",
"bottom-end",
"left",
"left-start",
"left-end",
"right",
"right-start",
"right-end"
], require_mapPopoverAlign.mapPopoverAlign),
autoAlign: prop_types.default.bool,
className: prop_types.default.string,
feedback: prop_types.default.string,
feedbackTimeout: prop_types.default.number,
iconDescription: prop_types.default.string,
onClick: prop_types.default.func
};
//#endregion
exports.default = CopyButton;