"use client"; import { useTranslations } from "next-intl"; import { isValidElement, ReactElement, ReactNode, useCallback, useEffect, useRef } from "react"; import { FieldValues, UseFormReturn } from "react-hook-form"; import { PencilIcon } from "lucide-react"; import { ModuleWithPermissions } from "../../permissions/types"; import { usePageUrlGenerator } from "../../hooks/usePageUrlGenerator"; import { Button, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, } from "../../shadcnui"; import { Form } from "../../shadcnui/ui/form"; import { CommonEditorButtons } from "./CommonEditorButtons"; import { CommonEditorDiscardDialog } from "./CommonEditorDiscardDialog"; import { useEditorDialog } from "./useEditorDialog"; import { errorToast } from "../errors/errorToast"; type EditorSheetSize = "sm" | "md" | "lg" | "xl" | "2xl"; /** * Resolve the `nativeButton` contract for a caller-supplied `trigger`. * * Base UI checks `nativeButton` against the element the trigger ACTUALLY puts in * the DOM and logs an error when the two disagree — in BOTH directions (see * `@base-ui/react/internals/use-button/useButton`: "expected a native ) : ( )} ))} {actions ? ( // pr-10 clears the SheetContent close button (absolute top-4 right-4).
{headerTitle} {headerDescription}
{actions}
) : ( <> {headerTitle} {headerDescription} )}
{ // The Sheet content is portaled, but React synthetic events still // bubble up the React tree — so without stopPropagation an inner // EditorSheet's submit also triggers the outer form's submit // (e.g. a create dialog opened from within another editor). e.stopPropagation(); return form.handleSubmit(wrappedOnSubmit)(e); }} className="flex min-h-0 flex-1 flex-col" >
{children}
{renderFooter ? ( renderFooter({ form, isEdit, setOpen: handleOpenChange, closeWithoutConfirm: setOpen }) ) : ( )}
); }