UNPKG

@carbon/ibm-products

Version:
171 lines (169 loc) 6.4 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. */ const require_runtime = require("../../_virtual/_rolldown/runtime.js"); const require_index = require("../../node_modules/classnames/index.js"); const require_settings = require("../../settings.js"); const require_devtools = require("../../global/js/utils/devtools.js"); const require_ProductiveCard = require("../ProductiveCard/ProductiveCard.js"); let react = require("react"); react = require_runtime.__toESM(react); let prop_types = require("prop-types"); prop_types = require_runtime.__toESM(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__ */ require_runtime.__toESM(require_index.default); const blockClass = `${require_settings.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.default.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.default.createElement("div", { ...rest, className: (0, import_classnames.default)(blockClass, className, { [`${blockClass}__actions-bottom`]: actionsPlacement === "bottom" }), ref, ...require_devtools.getDevtoolsProps(componentName) }, /* @__PURE__ */ react.default.createElement(require_ProductiveCard.ProductiveCard, { actionIcons, actionsPlacement, className, description, label, title, titleSize, ...editMode && conditionalProps }, editMode === false && /* @__PURE__ */ react.default.createElement("div", null, previewChildren), editMode && /* @__PURE__ */ react.default.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: prop_types.default.arrayOf(prop_types.default.shape({ id: prop_types.default.string, icon: prop_types.default.oneOfType([prop_types.default.func, prop_types.default.object]), onKeyDown: prop_types.default.func, onClick: prop_types.default.func, iconDescription: prop_types.default.string, /** * @deprecated please use the `link.href` instead */ href: prop_types.default.string, link: prop_types.default.shape({ href: prop_types.default.string.isRequired }) })), /** * Determines if the action icons are on the top or bottom of the card */ actionsPlacement: prop_types.default.oneOf(["top", "bottom"]), /** * Optional label for the top of the card. */ className: prop_types.default.string, /** * Optional header description */ description: prop_types.default.string, /** * Edit mode children */ editChildren: prop_types.default.node, /** * Edit mode */ editMode: prop_types.default.bool, /** * Optional label for the top of the card */ label: prop_types.default.string, /** * Function that's called from the primary button or action icon */ onPrimaryButtonClick: prop_types.default.func, /** * Function that's called from the secondary button or action icon */ onSecondaryButtonClick: prop_types.default.func, /** * Preview mode children */ previewChildren: prop_types.default.node, /** * Optional prop to allow overriding the icon rendering. Can be a React component class */ /**@ts-ignore */ primaryButtonIcon: prop_types.default.oneOfType([prop_types.default.func, prop_types.default.object]), /** * Establishes the kind of button displayed for the primary button */ primaryButtonKind: prop_types.default.oneOf(["primary", "ghost"]), /** * Determines if the primary button is on the top or bottom of the card */ primaryButtonPlacement: prop_types.default.oneOf(["top", "bottom"]), /** * The text that's displayed in the primary button */ primaryButtonText: prop_types.default.string, /** * Optionally specify an href for your Button to become an <a> element */ secondaryButtonHref: prop_types.default.string, /** * Optional prop to allow overriding the icon rendering. Can be a React component class */ /**@ts-ignore */ secondaryButtonIcon: prop_types.default.oneOfType([prop_types.default.func, prop_types.default.object]), /** * Establishes the kind of button displayed for the secondary button */ secondaryButtonKind: prop_types.default.oneOf(["secondary", "ghost"]), /** * Determines if the secondary button is on the top or bottom of the card */ secondaryButtonPlacement: prop_types.default.oneOf(["top", "bottom"]), /** * The text that's displayed in the secondary button */ secondaryButtonText: prop_types.default.string, /** * Title that's displayed at the top of the card */ title: prop_types.default.string, /** * Determines title size */ titleSize: prop_types.default.oneOf(["default", "large"]) }; //#endregion exports.EditUpdateCards = EditUpdateCards;