import * as React from "react";
import type { ReactNode } from "react";
import { Children } from "react";
import type { FormProps } from "ra-core";
import { Form } from "ra-core";
import { cn } from "@/lib/utils";
import { CancelButton } from "@/components/admin/cancel-button";
import { SaveButton } from "@/components/admin/form";
/**
* A simple form layout with vertical stacking, validation, and default toolbar.
*
* Automatically includes a toolbar with Cancel and Save buttons unless you provide a custom toolbar.
*
* @see {@link https://marmelab.com/shadcn-admin-kit/docs/simpleform/ SimpleForm documentation}
*
* @example
* import { Create, SimpleForm, TextInput } from '@/components/admin';
*
* const PostCreate = () => (
*
*
*
*
*
*
* );
*/
export const SimpleForm = ({
children,
className,
toolbar = defaultFormToolbar,
...rest
}: SimpleFormProps) => (
);
/**
* A sticky form toolbar with default Cancel and Save buttons.
*
* Provides a consistent action bar for forms that sticks to the bottom of the viewport. By default,
* renders Cancel and Save buttons, but you can provide custom buttons as children.
*
* @example
* import { FormToolbar, CancelButton, SaveButton } from '@/components/admin';
*
* const CustomToolbar = () => (
*
*
*
*
* );
*/
export const FormToolbar = ({
children,
className,
...rest
}: FormToolbarProps) => (
{Children.count(children) === 0 ? (
) : (
children
)}
);
export type SimpleFormProps = {
children: ReactNode;
className?: string;
toolbar?: ReactNode;
} & FormProps;
export interface FormToolbarProps extends React.HTMLAttributes {
children?: ReactNode;
className?: string;
}
const defaultFormToolbar = ;