UNPKG

@carbon/ibm-products

Version:
71 lines (69 loc) 3.7 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 { Button } from "@carbon/react"; import { Error } from "@carbon/react/icons"; //#region src/components/Card/CardFooter.tsx var import_classnames = /* @__PURE__ */ __toESM(require_classnames()); const componentName = "CardFooter"; const defaults = { actions: Object.freeze([]), primaryButtonKind: "primary", productive: false, secondaryButtonKind: "secondary" }; const CardFooter = ({ actions = defaults.actions, disabled, footerActionIcon: FooterActionIcon, hasActions, hasButton, onPrimaryButtonClick, onSecondaryButtonClick, primaryButtonDisabled, primaryButtonHref, primaryButtonIcon, primaryButtonKind = "primary", primaryButtonPlacement, primaryButtonText, productive = defaults.productive, secondaryButtonDisabled, secondaryButtonHref, secondaryButtonIcon, secondaryButtonKind = "secondary", secondaryButtonPlacement, secondaryButtonText }) => { const blockClass = `${pkg.prefix}--card`; const footerClass = `${pkg.prefix}--card__footer`; const footerClasses = (0, import_classnames.default)(footerClass, { [`${footerClass}-no-button`]: !hasButton }); return /* @__PURE__ */ React.createElement("div", { className: footerClasses }, secondaryButtonText && secondaryButtonPlacement === "bottom" && /* @__PURE__ */ React.createElement(Button, { kind: productive ? "ghost" : secondaryButtonKind, onClick: onSecondaryButtonClick, size: "md", renderIcon: secondaryButtonIcon, href: secondaryButtonHref, disabled: secondaryButtonDisabled }, secondaryButtonText), primaryButtonText && primaryButtonPlacement === "bottom" && /* @__PURE__ */ React.createElement(Button, { kind: productive ? "ghost" : primaryButtonKind, onClick: onPrimaryButtonClick, size: "md", renderIcon: primaryButtonIcon, href: primaryButtonHref, disabled: primaryButtonDisabled }, primaryButtonText), hasActions && /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__actions` }, actions), FooterActionIcon && /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__action-icon` }, disabled ? /* @__PURE__ */ React.createElement(Error, { size: 16 }) : /* @__PURE__ */ React.createElement(FooterActionIcon, null))); }; /**@ts-ignore */ CardFooter.propTypes = { actions: PropTypes.oneOfType([PropTypes.array, PropTypes.node]), disabled: PropTypes.bool, footerActionIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), hasActions: PropTypes.bool, hasButton: PropTypes.bool, onPrimaryButtonClick: PropTypes.func, onSecondaryButtonClick: PropTypes.func, primaryButtonDisabled: PropTypes.bool, primaryButtonHref: PropTypes.string, primaryButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), primaryButtonKind: PropTypes.oneOf(["primary", "ghost"]), primaryButtonPlacement: PropTypes.oneOf(["top", "bottom"]), primaryButtonText: PropTypes.string, productive: PropTypes.bool, secondaryButtonDisabled: PropTypes.bool, secondaryButtonHref: PropTypes.string, secondaryButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), secondaryButtonKind: PropTypes.oneOf(["secondary", "ghost"]), secondaryButtonPlacement: PropTypes.oneOf(["top", "bottom"]), secondaryButtonText: PropTypes.string }; /**@ts-ignore */ CardFooter.displayName = componentName; //#endregion export { CardFooter };