@carbon/ibm-products
Version:
Carbon for IBM Products
171 lines (169 loc) • 5.82 kB
JavaScript
/**
* 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");
require("../../global/js/utils/props-helper.js");
const require_uuidv4 = require("../../global/js/utils/uuidv4.js");
const require_SidePanel = require("../SidePanel/SidePanel.js");
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@carbon/react");
//#region src/components/EditSidePanel/EditSidePanel.tsx
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_settings.pkg.prefix}--edit-side-panel`;
const componentName = "EditSidePanel";
/**
* **This component is deprecated.** <br>
* Use with medium complexity edits if the user needs page context.
* @deprecated
*/
const EditSidePanel = react.default.forwardRef(({ children, className, disableSubmit, id, formTitle, formDescription, onRequestClose, onRequestSubmit, open, placement = "right", primaryButtonText, secondaryButtonText, selectorPrimaryFocus, selectorPageContent, size = "md", slideIn, subtitle, title, ...rest }, ref) => {
const actions = [{
label: primaryButtonText,
onClick: (event) => {
event.preventDefault();
onRequestSubmit?.();
},
kind: "primary",
disabled: disableSubmit,
type: "submit"
}, {
label: secondaryButtonText,
onClick: onRequestClose,
kind: "secondary"
}];
const formTitleId = require_uuidv4.default();
return /* @__PURE__ */ react.default.createElement(require_SidePanel.SidePanel, {
...rest,
open,
ref,
selectorPageContent,
onRequestClose,
title,
subtitle,
selectorPrimaryFocus,
id,
...require_devtools.getDevtoolsProps(componentName),
placement,
slideIn,
animateTitle: false,
className: (0, import_classnames.default)(blockClass, className),
size,
preventCloseOnClickOutside: true,
actions
}, formTitle && /* @__PURE__ */ react.default.createElement("h3", {
id: formTitleId,
className: `${blockClass}__form-title-text ${blockClass}__content-text`
}, formTitle), formDescription && /* @__PURE__ */ react.default.createElement("p", { className: `${blockClass}__form-description-text ${blockClass}__content-text` }, formDescription), /* @__PURE__ */ react.default.createElement(_carbon_react.Form, {
className: `${blockClass}__form`,
"aria-labelledby": formTitleId
}, children));
});
/**@ts-ignore*/
EditSidePanel.deprecated = {
level: "warn",
details: `This component is deprecated and will be removed in the next major version.`
};
EditSidePanel.displayName = componentName;
EditSidePanel.propTypes = {
/**
* Sets the body content of the create side panel
*/
/**@ts-ignore*/
children: prop_types.default.oneOfType([prop_types.default.arrayOf(prop_types.default.node), prop_types.default.node]).isRequired,
/**
* Provide an optional class to be applied to the containing node.
*/
className: prop_types.default.string,
/**
* Specifies a boolean for disabling or enabling the primary button. This is important for form validation
* Returning `true` prevents the primary button from being clicked until required fields are completed.
*/
disableSubmit: prop_types.default.bool,
/**
* Specifies an optional field that provides a additional context for a form
*/
formDescription: prop_types.default.node,
/**
* Specifies a required field that provides a title for a form
*/
formTitle: prop_types.default.node.isRequired,
/**
* Unique identifier
*/
id: prop_types.default.string,
/**
* Specifies an optional handler which is called when the CreateSidePanel
* is closed.
*/
onRequestClose: prop_types.default.func,
/**
* Specifies an optional handler which is called when the CreateSidePanel
* primary button is pressed.
*/
onRequestSubmit: prop_types.default.func,
/**
* Specifies whether the CreateSidePanel is open or not.
*/
open: prop_types.default.bool.isRequired,
/**
* Determines if the side panel is on the right or left
*/
placement: prop_types.default.oneOf(["left", "right"]),
/**
* Specifies the primary button's text in the modal.
*/
primaryButtonText: prop_types.default.string.isRequired,
/**
* Specifies the secondary button's text in the modal.
*/
secondaryButtonText: prop_types.default.string.isRequired,
/**
* This is the selector to the element that contains all of the page content that will shrink if the panel is a slide in.
* This prop is required when using the `slideIn` variant of the side panel.
*/
/**@ts-ignore*/
selectorPageContent: prop_types.default.string,
/**
* Specifies which DOM element in the form should be focused.
*/
/**@ts-ignore*/
selectorPrimaryFocus: prop_types.default.node.isRequired,
/**
* Sets the size of the side panel
*/
size: prop_types.default.oneOf([
"xs",
"sm",
"md",
"lg",
"2xl"
]),
/**
* Specifies which DOM element in the form should be focused.
*/
slideIn: prop_types.default.bool,
/**
* **Experimental:** Provide a `Slug` component to be rendered inside the `SidePanel` component
*/
slug: prop_types.default.node,
/**
* The subtitle of the CreateSidePanel is optional and serves to provide more information about the modal.
*/
subtitle: prop_types.default.node,
/**
* The title of the CreateSidePanel is usually the product or service name.
*/
/**@ts-ignore*/
title: prop_types.default.node.isRequired
};
//#endregion
exports.EditSidePanel = EditSidePanel;