import type { HTMLAttributes, HTMLFieldsetAttributes, HTMLLabelAttributes } from "svelte/elements"; import type { FormPath, FormPathLeaves, SuperForm } from "sveltekit-superforms"; import type { Snippet } from "svelte"; import type { Expand, WithChild, Without } from "svelte-toolbelt"; import type { ControlAttrs } from "../attrs.types.js"; import type { Primitive } from "../internal/types.js"; type PrimitiveFieldSetAttributes = Primitive; type PrimitiveDivAttributes = Primitive>; type PrimitiveLabelAttributes = Primitive; type PrimitiveLegendAttributes = Primitive>; export type FsSuperForm, M = any> = Omit, "validate" | "validateForm" | "enhance" | "isTainted" | "reset" | "options" | "restore"> & { validate?: any; validateForm?: any; enhance?: any; isTainted?: any; reset?: any; options?: any; restore?: any; }; /** * Props for the [Description](https://formsnap.dev/docs/components/description) component. */ export type DescriptionPropsWithoutHTML = WithChild<{}>; export type DescriptionProps = DescriptionPropsWithoutHTML & Without; /** * Props for the [Field](https://formsnap.dev/docs/components/field) component. */ export type FieldProps, U extends FormPath, M = any> = { /** * The form object returned from calling `superForm` in your component. */ form: FsSuperForm; /** * The path to the field in the form object. * * @required */ name: U; /** * The children of the field. */ children?: Snippet<[ { value: T[U]; errors: string[]; tainted: boolean; constraints: Record; } ]>; }; /** * Props for the [ElementField](https://formsnap.dev/docs/components/element-field) component. * * @category ElementField */ export type ElementFieldProps, U extends FormPathLeaves, M = any> = { /** * The form object returned from calling `superForm` in your component. */ form: FsSuperForm; /** * The path to the field in the form object. * * @required */ name: U; /** * The children of the field. */ children?: Snippet<[ { value: T[U]; errors: string[]; tainted: boolean; constraints: Record; } ]>; }; /** * Props for the [Fieldset](https://formsnap.dev/docs/components/fieldset) component. * This component is used to group form controls together and if used, should always * have a child [Legend](https://formsnap.dev/docs/components/legend) component to provide * an accessible title for the group. * * @see {@link https://www.w3.org/WAI/tutorials/forms/grouping/ W3C Grouping} */ export type FieldsetPropsWithoutHTML, U extends FormPath, M = any> = WithChild<{ /** * The form object returned from calling `superForm` in your component. */ form: FsSuperForm; /** * The path to the field in the form object. */ name: U; }, { value: T[U]; errors: string[]; tainted: boolean; constraints: Record; }>; export type FieldsetProps, U extends FormPath, M = any> = FieldsetPropsWithoutHTML & Without>; /** * Props for the [Control](https://formsnap.dev/docs/components/control) component. */ export type ControlProps = { /** * Optionally provide a unique id for the form control. * If not provided, a unique ID will be generated for you. */ id?: string; children?: Snippet<[{ props: Expand; }]>; }; export type LabelPropsWithoutHTML = WithChild<{}>; /** * Props for the [Label](https://formsnap.dev/docs/components/label) component. */ export type LabelProps = LabelPropsWithoutHTML & Without; export type LegendPropsWithoutHTML = WithChild; /** * Props for the [Legend](https://formsnap.dev/docs/components/legend) component. * This component is used to provide an accessible title for a group of form controls. * * @see {@link https://www.w3.org/WAI/tutorials/forms/grouping/ W3C Grouping} */ export type LegendProps = LegendPropsWithoutHTML & Without; /** * Props for the [FieldErrors](https://formsnap.dev/docs/components/field-errors) component. */ export type FieldErrorsPropsWithoutHTML = WithChild<{}, { errors: string[]; errorProps: Record; }>; export type FieldErrorsProps = FieldErrorsPropsWithoutHTML & Without; export {};