@sanity/assist 4.4.2 → 4.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/assist",
3
- "version": "4.4.2",
3
+ "version": "4.4.3",
4
4
  "description": "You create the instructions; Sanity AI Assist does the rest.",
5
5
  "keywords": [
6
6
  "sanity",
@@ -1,11 +1,13 @@
1
1
  import {Card, Stack, Text} from '@sanity/ui'
2
2
  import {useContext, useEffect, useMemo, useRef} from 'react'
3
3
  import {
4
+ FieldError,
4
5
  FormCallbacksProvider,
5
6
  FormCallbacksValue,
6
7
  FormInput,
7
8
  insert,
8
9
  KeyedSegment,
10
+ MemberFieldError,
9
11
  ObjectInputProps,
10
12
  ObjectSchemaType,
11
13
  PatchEvent,
@@ -127,6 +129,16 @@ function AssistDocumentFormEditable(props: ObjectInputProps) {
127
129
  }
128
130
  }, [activePath, instruction, onPathOpen])
129
131
 
132
+ const fieldError = useMemo(() => {
133
+ const fieldError = props.members.find(
134
+ (m): m is FieldError => m.kind === 'error' && m.fieldName === 'fields',
135
+ )
136
+ if (fieldError) {
137
+ return <MemberFieldError member={fieldError} />
138
+ }
139
+ return undefined
140
+ }, [props.members])
141
+
130
142
  return (
131
143
  <SelectedFieldContextProvider value={context}>
132
144
  <Stack space={5}>
@@ -140,7 +152,7 @@ function AssistDocumentFormEditable(props: ObjectInputProps) {
140
152
  />
141
153
  {instruction && <BackToInstructionListLink />}
142
154
 
143
- {activePath && (
155
+ {activePath && !fieldError && (
144
156
  <FormCallbacksProvider {...newCallbacks}>
145
157
  <div style={{lineHeight: '1.25em'}}>
146
158
  <FormInput {...props} absolutePath={activePath} />
@@ -148,6 +160,8 @@ function AssistDocumentFormEditable(props: ObjectInputProps) {
148
160
  </FormCallbacksProvider>
149
161
  )}
150
162
 
163
+ {fieldError}
164
+
151
165
  {!activePath && props.renderDefault(props)}
152
166
  </Stack>
153
167
  </SelectedFieldContextProvider>