UNPKG

@carbon/ibm-products

Version:

Carbon for IBM Products

99 lines (95 loc) 3.64 kB
/** * Copyright IBM Corp. 2020, 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. */ import React__default from 'react'; import cx from 'classnames'; import { Button } from '@carbon/react'; import PropTypes from '../../_virtual/index.js'; import { pkg } from '../../settings.js'; import { Error } from '@carbon/react/icons'; var _Error; const componentName = 'CardFooter'; const defaults = { actions: Object.freeze([]), productive: false}; const CardFooter = _ref => { let { 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 } = _ref; const blockClass = `${pkg.prefix}--card`; const footerClass = `${pkg.prefix}--card__footer`; const footerClasses = cx(footerClass, { [`${footerClass}-no-button`]: !hasButton }); return /*#__PURE__*/React__default.createElement("div", { className: footerClasses }, secondaryButtonText && secondaryButtonPlacement === 'bottom' && /*#__PURE__*/React__default.createElement(Button, { kind: productive ? 'ghost' : secondaryButtonKind, onClick: onSecondaryButtonClick, size: "md", renderIcon: secondaryButtonIcon, href: secondaryButtonHref, disabled: secondaryButtonDisabled }, secondaryButtonText), primaryButtonText && primaryButtonPlacement === 'bottom' && /*#__PURE__*/React__default.createElement(Button, { kind: productive ? 'ghost' : primaryButtonKind, onClick: onPrimaryButtonClick, size: "md", renderIcon: primaryButtonIcon, href: primaryButtonHref, disabled: primaryButtonDisabled }, primaryButtonText), hasActions && /*#__PURE__*/React__default.createElement("div", { className: `${blockClass}__actions` }, actions), FooterActionIcon && /*#__PURE__*/React__default.createElement("div", { className: `${blockClass}__action-icon` }, disabled ? _Error || (_Error = /*#__PURE__*/React__default.createElement(Error, { size: 16 })) : /*#__PURE__*/React__default.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; export { CardFooter };