v3.0.0-dev-preview.16/17 #3643
rexxars
announced in
Announcements
Replies: 3 comments 11 replies
-
Hi, when is the official release of v3? |
Beta Was this translation helpful? Give feedback.
4 replies
-
Updating both sanity and vision to
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Is there more work pending on the typings for A few examples:
This field generator util I made is basically unusable now :(
|
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
✨ Highlights
Less custom input boilerplate
This release introduces a new spreadable
elementProps
property to all input components.This currently includes things like
onFocus
/onBlur
event handlers,ref
,value
(for primitive inputs) and anonChange
that handles "native" React change events and emits the correct patches.The intention is that you can safely pass (or "spread") these on to any "native" input element. This reduces the amount of boilerplate needed for custom inputs - especially those dealing with primitive values, and handles things like unsetting the field if the value is empty, extracting the value from a change event and similar.
For inputs dealing with complex values (objects and arrays),
value
is not included inelementProps
, since it doesn't make sense to pass it to any native input.This change also includes moving the change indicator rendering from individual primitive input components to their corresponding field component instead. This means even less boilerplate is needed in order to render a simple input component. In the future, we will provide a way to opt-out of this behavior, should you wish to handle the rendering of the change indicator yourself.
These changes means that in essence, all you need for the most basic custom string input would be:
Note that this change means that input components will receive two "values" -
props.value
will now be of the "parsed" type defined in the schema (e.g. number), whileelementProps.value
will always be a string, since its intended to being forwarded as an attribute to the native HTML input element.Context improvements
Custom validation functions and initial value resolvers now gets an extended context parameter passed to them, which includes the schema, the current user and a
getClient()
function.Other features
layout: 'tags'
and a preconfigured list of optionssanity.config.ts
components.diff
propertylogo
can now be passed to the configuration and will be rendered in the navigation bar. Note that this property name might change in an upcoming release, but we are including it for people who want to start working on the rendering of their studio logos.BREAKING CHANGES
This release includes a few breaking changes:
Versioned client
The
useClient()
hook now requires you to pass an API version, for instance:useClient({apiVersion: '2022-09-14'})
. This allows us to upgrade the API version used throughout the studio without breaking any custom queries or other requests performed from user code.Similarily, the
client
property in various contexts (validation, config, initial value resolvers) is deprecated - instead there is agetClient()
method attached to the context which takes the same API version configuration.Router imports
Router imports have been moved from
sanity/_unstable
tosanity
.🐛 Notable bugfixes
@sanity/vision
potentially causing installs to failreadOnly
property📓 Full changelog
TagsArrayInput
beforeOptionsArray
ArrayItem
when the dialog is closedjsonc-parser
dependencytarget
of tsconfig filetarget
toES2019
@sanity/ui
updategetSchemaType
inListItemBuilder
diff
tocomponents
inBaseDefinitionOptions
andBaseSchemaType
components.diff
instead ofdiffComponent
inresolveDiffComponent
@sanity/tsdoc-to-portable-text
etl
scriptSanityPreview
indefaultResolvePreviewComponent
sinceSanityPreview
takes care of resolving the preview componentetl
exit code overrideetl
scriptetl
scriptuseTimeAgo
hookelementProps
(#3580)Geopoint
data type@sanity/client
to 3.4.1getClient
implementationThis discussion was created from the release v3.0.0-dev-preview.16.
Beta Was this translation helpful? Give feedback.
All reactions