Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Narrow the type prop returned from the getCollectionProps helper #562

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/conform-react/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export function getTextareaProps<Schema>(
* Derives the properties of a collection of checkboxes or radio buttons based on the field metadata,
* including common form control attributes like `key`, `id`, `name`, `form`, `autoFocus`, `aria-invalid`, `aria-describedby` and `required`.
*
* @see https://conform.guide/api/react/getTextareaProps
* @see https://conform.guide/api/react/getCollectionProps
* @example
* ```tsx
* <fieldset>
Expand All @@ -363,9 +363,7 @@ export function getCollectionProps<
| boolean
| undefined
| unknown,
>(
metadata: FieldMetadata<Schema, any, any>,
options: Pretty<
Options extends Pretty<
FormControlOptions & {
/**
* The input type. Use `checkbox` for multiple selection or `radio` for single selection.
Expand All @@ -381,7 +379,12 @@ export function getCollectionProps<
value?: boolean;
}
>,
): Array<InputProps & Pick<Required<InputProps>, 'type' | 'value'>> {
>(
metadata: FieldMetadata<Schema, any, any>,
options: Options,
): Array<
InputProps & Pick<Options, 'type'> & Pick<Required<InputProps>, 'value'>
> {
return options.options.map((value) =>
simplify({
...getFormControlProps(metadata, options),
Expand Down
Loading