form icon indicating copy to clipboard operation
form copied to clipboard

feat(core): field meta API

Open harry-whorlow opened this issue 1 year ago β€’ 6 comments

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

  • [x] Meta available to Field.children
  • [ ] MetaFn available to form.Field
  • [ ] Tests
  • [ ] LGTM πŸš€

harry-whorlow avatar Jan 22 '25 09:01 harry-whorlow

View your CI Pipeline Execution β†— for commit 72cf93544684ff45fbec4000e54f03b930633e49.

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

nx-cloud[bot] avatar Jan 22 '25 09:01 nx-cloud[bot]

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

harry-whorlow avatar Jan 22 '25 09:01 harry-whorlow

@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 avatar Jan 29 '25 10:01 harry-whorlow

@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 🀟

harry-whorlow avatar Mar 03 '25 13:03 harry-whorlow

@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).

fulopkovacs avatar Mar 04 '25 19:03 fulopkovacs

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.

harry-whorlow avatar Mar 04 '25 20:03 harry-whorlow