/**
 * 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 uuidv4 from "../../global/js/utils/uuidv4.js";
import { TearsheetNarrow } from "../Tearsheet/TearsheetNarrow.js";
import React from "react";
import PropTypes from "prop-types";
import { Form } from "@carbon/react";

//#region src/components/CreateTearsheetNarrow/CreateTearsheetNarrow.tsx
/**
* Copyright IBM Corp. 2021, 2021
*
* 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}--create-tearsheet-narrow`;
const componentName = "CreateTearsheetNarrow";
/**
* Use a narrow tearsheet as an alternative to a modal when there is scrolling.
* Use when the form fields can be broken down into sections using section headers.
*/
const CreateTearsheetNarrow = React.forwardRef(({ children, className, description, disableSubmit, formDescription, formTitle, label, open, onRequestClose, onRequestSubmit, primaryButtonText, secondaryButtonText, selectorPrimaryFocus, title, verticalPosition, ...rest }, ref) => {
	const actions = [{
		label: primaryButtonText,
		onClick: onRequestSubmit,
		kind: "primary",
		disabled: disableSubmit
	}, {
		label: secondaryButtonText,
		onClick: onRequestClose,
		kind: "secondary"
	}];
	const formTextClass = `${blockClass}__content-text`;
	const formTitleId = uuidv4();
	return /* @__PURE__ */ React.createElement(TearsheetNarrow, {
		...rest,
		title,
		description,
		className: (0, import_classnames.default)(blockClass, className),
		actions,
		open,
		ref,
		onClose: () => {
			onRequestClose?.();
			return false;
		},
		label,
		selectorPrimaryFocus,
		verticalPosition,
		role: "presentation",
		...getDevtoolsProps(componentName)
	}, /* @__PURE__ */ React.createElement("h3", {
		className: (0, import_classnames.default)(`${blockClass}__form-title-text`, formTextClass),
		id: formTitleId
	}, formTitle), /* @__PURE__ */ React.createElement("p", { className: (0, import_classnames.default)(`${blockClass}__form-description-text`, formTextClass) }, formDescription), /* @__PURE__ */ React.createElement(Form, {
		className: `${blockClass}__form`,
		"aria-labelledby": formTitleId,
		onSubmit: (e) => e.preventDefault()
	}, children));
});
CreateTearsheetNarrow.displayName = componentName;
CreateTearsheetNarrow.propTypes = {
	children: PropTypes.node.isRequired,
	className: PropTypes.string,
	description: PropTypes.node,
	disableSubmit: PropTypes.bool,
	formDescription: PropTypes.node,
	formTitle: PropTypes.node,
	label: PropTypes.node,
	onRequestClose: PropTypes.func,
	onRequestSubmit: PropTypes.func,
	open: PropTypes.bool,
	primaryButtonText: PropTypes.string.isRequired,
	secondaryButtonText: PropTypes.string.isRequired,
	selectorPrimaryFocus: PropTypes.node,
	title: PropTypes.node,
	verticalPosition: PropTypes.oneOf(["normal", "lower"])
};

//#endregion
export { CreateTearsheetNarrow };