UNPKG

@carbon/ibm-products

Version:
169 lines (167 loc) 5.82 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 { getDevtoolsProps } from "../../global/js/utils/devtools.js"; import { ProductiveCard } from "../ProductiveCard/ProductiveCard.js"; import React from "react"; import PropTypes from "prop-types"; //#region src/components/EditUpdateCards/EditUpdateCards.tsx /** * Copyright IBM Corp. 2022, 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__ */ __toESM(require_classnames()); const blockClass = `${pkg.prefix}--edit-update-cards`; const componentName = "EditUpdateCards"; /** * **This component is deprecated.** <br> Editable cards allow a user to view, modify, and save the content contained within the card. These cards are generally used in instances where a user needs to make changes to a resource instances (ex. configuration details), account plan, etc. Editable cards allow a user to edit something within context. @deprecated */ const EditUpdateCards = React.forwardRef(({ actionIcons, actionsPlacement, className, description, editChildren, editMode, label, onPrimaryButtonClick, onSecondaryButtonClick, previewChildren, title, titleSize, primaryButtonIcon, primaryButtonText, secondaryButtonIcon, secondaryButtonText, ...rest }, ref) => { const conditionalProps = { onPrimaryButtonClick, onSecondaryButtonClick, primaryButtonIcon, primaryButtonKind: "ghost", primaryButtonPlacement: "top", primaryButtonText, secondaryButtonIcon, secondaryButtonKind: "ghost", secondaryButtonPlacement: "top", secondaryButtonText }; return /* @__PURE__ */ React.createElement("div", { ...rest, className: (0, import_classnames.default)(blockClass, className, { [`${blockClass}__actions-bottom`]: actionsPlacement === "bottom" }), ref, ...getDevtoolsProps(componentName) }, /* @__PURE__ */ React.createElement(ProductiveCard, { actionIcons, actionsPlacement, className, description, label, title, titleSize, ...editMode && conditionalProps }, editMode === false && /* @__PURE__ */ React.createElement("div", null, previewChildren), editMode && /* @__PURE__ */ React.createElement("div", null, editChildren))); }); /**@ts-ignore*/ EditUpdateCards.deprecated = { level: "warn", details: `This component is deprecated and will be removed in the next major version.` }; EditUpdateCards.displayName = componentName; EditUpdateCards.propTypes = { /** * Icons that are displayed on the card. Refer to design documentation for implementation guidelines. Note: href is deprecated. Set link.href for href functionality. If you are setting link object, href is a required property. link object supports all anchor element properties. Precedence: link.href > href. If link.href or href is set => anchor element, else button. */ /**@ts-ignore */ actionIcons: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.string, icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), onKeyDown: PropTypes.func, onClick: PropTypes.func, iconDescription: PropTypes.string, /** * @deprecated please use the `link.href` instead */ href: PropTypes.string, link: PropTypes.shape({ href: PropTypes.string.isRequired }) })), /** * Determines if the action icons are on the top or bottom of the card */ actionsPlacement: PropTypes.oneOf(["top", "bottom"]), /** * Optional label for the top of the card. */ className: PropTypes.string, /** * Optional header description */ description: PropTypes.string, /** * Edit mode children */ editChildren: PropTypes.node, /** * Edit mode */ editMode: PropTypes.bool, /** * Optional label for the top of the card */ label: PropTypes.string, /** * Function that's called from the primary button or action icon */ onPrimaryButtonClick: PropTypes.func, /** * Function that's called from the secondary button or action icon */ onSecondaryButtonClick: PropTypes.func, /** * Preview mode children */ previewChildren: PropTypes.node, /** * Optional prop to allow overriding the icon rendering. Can be a React component class */ /**@ts-ignore */ primaryButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), /** * Establishes the kind of button displayed for the primary button */ primaryButtonKind: PropTypes.oneOf(["primary", "ghost"]), /** * Determines if the primary button is on the top or bottom of the card */ primaryButtonPlacement: PropTypes.oneOf(["top", "bottom"]), /** * The text that's displayed in the primary button */ primaryButtonText: PropTypes.string, /** * Optionally specify an href for your Button to become an <a> element */ secondaryButtonHref: PropTypes.string, /** * Optional prop to allow overriding the icon rendering. Can be a React component class */ /**@ts-ignore */ secondaryButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), /** * Establishes the kind of button displayed for the secondary button */ secondaryButtonKind: PropTypes.oneOf(["secondary", "ghost"]), /** * Determines if the secondary button is on the top or bottom of the card */ secondaryButtonPlacement: PropTypes.oneOf(["top", "bottom"]), /** * The text that's displayed in the secondary button */ secondaryButtonText: PropTypes.string, /** * Title that's displayed at the top of the card */ title: PropTypes.string, /** * Determines title size */ titleSize: PropTypes.oneOf(["default", "large"]) }; //#endregion export { EditUpdateCards };