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

chore: expose fieldset metadata #781

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lifeiscontent
Copy link
Contributor

@lifeiscontent lifeiscontent commented Sep 20, 2024

This PR exposes a FieldsetMetadata type so that people who use the react package don't need to drop into @conform-to/dom to get the Combine type to reconstruct this type.

Copy link

changeset-bot bot commented Sep 20, 2024

⚠️ No Changeset found

Latest commit: 94f905f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Sep 20, 2024

Open in Stackblitz

More templates

@conform-to/dom

pnpm add https://pkg.pr.new/@conform-to/dom@781

@conform-to/react

pnpm add https://pkg.pr.new/@conform-to/react@781

@conform-to/validitystate

pnpm add https://pkg.pr.new/@conform-to/validitystate@781

@conform-to/yup

pnpm add https://pkg.pr.new/@conform-to/yup@781

@conform-to/zod

pnpm add https://pkg.pr.new/@conform-to/zod@781

commit: 94f905f

Copy link
Owner

@edmundhung edmundhung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Can you help adding a changeset? I think this should be considered a feature.

Comment on lines +63 to +73
export type FieldsetMetadata<
Schema extends Record<string, unknown> = Record<string, unknown>,
FormError = string[],
> = Required<{
[Key in keyof Combine<Schema>]: FieldMetadata<
Combine<Schema>[Key],
Schema,
FormError
>;
}>;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should reuse this for the return type of getFieldset() on SubfieldMetadata well. Meaning Schema and FormSchema could be different. Maybe something like this?

export type FieldsetMetadata<
	Schema extends Record<string, unknown> = Record<string, unknown>,
	FormSchema extends Record<string, any> = Schema,
	FormError = string[],
> = Required<{
	[Key in keyof Combine<Schema>]: FieldMetadata<
		Combine<Schema>[Key],
		FormSchema,
		FormError
	>;
}>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants