feat(core): field meta API
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 π
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
@fulopkovacs PR draft, to get my ideas on paper, and some initial feedback.
@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)
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.
@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, 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).
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.