Skip to content

feat(core): field meta API #1125

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

Closed
wants to merge 6 commits into from
Closed

Conversation

harry-whorlow
Copy link
Contributor

@harry-whorlow harry-whorlow commented Jan 22, 2025

Field.meta

From issue #1111 and discussion #709, this pr Introduces the Field.meta api to allow for extensible and easily accessible meta data to the field component.

example api

<form.Field
  name="foo"
  meta={({ values }) => ({
    disabled: values.someOtherField == null,
    ...
  })}
>
  {(field, meta) => 
  <Comp
    disabled={meta.disabled}
    ... >
  </Comp>

Tasks

  • Meta available to Field.children
  • MetaFn available to form.Field
  • Tests
  • LGTM 🚀

@harry-whorlow harry-whorlow marked this pull request as draft January 22, 2025 09:02
Copy link

nx-cloud bot commented Jan 22, 2025

View your CI Pipeline Execution ↗ for commit 72cf935.

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ❌ Failed 2m 2s View ↗
nx run-many --target=build --exclude=examples/** ❌ Failed 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-18 08:00:44 UTC

@harry-whorlow
Copy link
Contributor Author

harry-whorlow commented Jan 22, 2025

@fulopkovacs PR draft, to get my ideas on paper, and some initial feedback.

Copy link
Contributor

@fulopkovacs fulopkovacs left a comment

Choose a reason for hiding this comment

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

Thanks for the work, I think I answered all the questions in the first round! ☺️

@harry-whorlow
Copy link
Contributor Author

harry-whorlow commented Jan 29, 2025

@fulopkovacs Looking for insight... Should the fields meta be inferable from form? or should it be a "local" meta?

Currently implementation is as follows

(taken from my test)
Screenshot 2025-01-29 at 11 02 25

Looking at formApi if it should be global, I would imagine it'll be a lot of work. So I figured I'd get conformation first, before attempting it, though it might be beyond my capabilities as theres a lot of internal stuff I'm not familiar with. 🤟

Either way I'll give it a shot.

[edit] so after working onSubmitMeta I kinda got a little better idea of how to go about this. I'd still be keen to hear your opinion but, I've got an idea now.

[edit edit] thinking about this more it need to be globally typed.

@harry-whorlow
Copy link
Contributor Author

harry-whorlow commented Mar 3, 2025

@fulopkovacs, I'm going to open a new branch after the v1 update.... jumping through all the conflicts is breaking my brain, I'll ping you when it's ready

I'll leave this open for now as it makes it easier to see what I did. I'll be sure to close it when the new branch is open for cr 🤟

@fulopkovacs
Copy link
Contributor

@fulopkovacs, I'm going to open a new branch after the v1 update.... jumping through all the conflicts is breaking my brain, I'll ping you when it's ready

I'll leave this open for now as it makes it easier to see what I did. I'll be sure to close it when the new branch is open for cr 🤟

Awesome, thanks for the note! Sorry for not being active in this thread for so long, I'll make sure to pay more attention to the new branch! 😅 I can do a review when you ping me if you want (or answer any questions).

@harry-whorlow
Copy link
Contributor Author

hey @fulopkovacs check out #1216, if you’re about I'd really appreciate some input. I've kinda hit a wall figuring out how to infer the user defined field meta from the form and could really use someone to bounce some ideas off.

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