@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/README.md +0 -2
- package/dist/index.esm.js +13 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/assistDocument/components/AssistDocumentForm.tsx +15 -1
package/package.json
CHANGED
|
@@ -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>
|