feat: autocomplete subprops and allow string values for readOnly in resolveData #625
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates the TS types of resolveData such that:
readOnly
can now return a boolean OR a string. Supporting string is helpful when you have a 'custom' field defined for a level which contains multiple fields underneath, rather than using objectFields. resolveData can pass a string value of the subfield being set for readOnly.As an example, given this type:
and I want to create a custom Puck field at the
bar
level, I have id and value as subprops. resolveData works at the level ofbar
, so if you wanted to set value as readOnly, that is not possible withwe do this instead now
and then in the field's
render
function thereadOnly
prop would have a value of 'value'.The
readOnly
acceptable values now autocomplete to any valid subfield. Prior to this change only the top-level fields were enumerated by the type. Given the MyProps example above:HERE
would autocomplete as: 'foo'Now it autocompletes as : 'foo' | 'foo.bar' | 'foo.bar.id' | 'foo.bar.value'
More context around these changes can be found here.