@sanity/assist 4.4.2 → 4.4.4
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 +24 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/assistDocument/components/AssistDocumentForm.tsx +15 -1
- package/src/assistDocument/hooks/useAssistDocumentContextValue.tsx +11 -3
package/dist/index.js
CHANGED
|
@@ -1017,7 +1017,13 @@ function useAssistDocumentContextValue(documentId, documentType) {
|
|
|
1017
1017
|
if (!schemaType)
|
|
1018
1018
|
throw new Error(`Schema type "${documentType}" not found`);
|
|
1019
1019
|
return schemaType;
|
|
1020
|
-
}, [documentType, schema]), {
|
|
1020
|
+
}, [documentType, schema]), { fieldRefs, fieldRefsByTypePath } = react.useMemo(() => {
|
|
1021
|
+
const fieldRefs2 = getFieldRefs(documentSchemaType), fieldRefsByTypePath2 = asFieldRefsByTypePath(fieldRefs2);
|
|
1022
|
+
return {
|
|
1023
|
+
fieldRefs: fieldRefs2,
|
|
1024
|
+
fieldRefsByTypePath: fieldRefsByTypePath2
|
|
1025
|
+
};
|
|
1026
|
+
}, [documentSchemaType]), {
|
|
1021
1027
|
openInspector,
|
|
1022
1028
|
closeInspector,
|
|
1023
1029
|
inspector,
|
|
@@ -1029,7 +1035,7 @@ function useAssistDocumentContextValue(documentId, documentType) {
|
|
|
1029
1035
|
} = structure.useDocumentPane(), { draft, published, version } = editState || {}, assistableDocumentId = selectedReleaseId ? sanity.getVersionId(documentId, selectedReleaseId) : documentSchemaType.liveEdit ? documentId : sanity.getDraftId(documentId), documentIsNew = selectedReleaseId ? !version?._id : !draft?._id && !published?._id, documentIsAssistable = selectedReleaseId ? !!version : isDocAssistable(documentSchemaType, published, draft), { params } = useAiPaneRouter(), selectedPath = params[fieldPathParam], assistDocument = useStudioAssistDocument({
|
|
1030
1036
|
documentId: assistableDocumentId,
|
|
1031
1037
|
schemaType: documentSchemaType
|
|
1032
|
-
}), { syntheticTasks, addSyntheticTask, removeSyntheticTask } = useSyntheticTasks(assistableDocumentId)
|
|
1038
|
+
}), { syntheticTasks, addSyntheticTask, removeSyntheticTask } = useSyntheticTasks(assistableDocumentId);
|
|
1033
1039
|
return react.useMemo(() => {
|
|
1034
1040
|
const base = {
|
|
1035
1041
|
assistableDocumentId,
|
|
@@ -1065,7 +1071,9 @@ function useAssistDocumentContextValue(documentId, documentType) {
|
|
|
1065
1071
|
selectedPath,
|
|
1066
1072
|
syntheticTasks,
|
|
1067
1073
|
addSyntheticTask,
|
|
1068
|
-
removeSyntheticTask
|
|
1074
|
+
removeSyntheticTask,
|
|
1075
|
+
fieldRefs,
|
|
1076
|
+
fieldRefsByTypePath
|
|
1069
1077
|
]);
|
|
1070
1078
|
}
|
|
1071
1079
|
function useSyntheticTasks(assistableDocumentId) {
|
|
@@ -3208,9 +3216,17 @@ function AssistDocumentFormEditable(props) {
|
|
|
3208
3216
|
}),
|
|
3209
3217
|
[formCallbacks, onPathOpen, params, setParams, instruction2]
|
|
3210
3218
|
);
|
|
3211
|
-
|
|
3219
|
+
react.useEffect(() => {
|
|
3212
3220
|
activePath && !instruction2 && onPathOpen([]);
|
|
3213
|
-
}, [activePath, instruction2, onPathOpen])
|
|
3221
|
+
}, [activePath, instruction2, onPathOpen]);
|
|
3222
|
+
const fieldError = react.useMemo(() => {
|
|
3223
|
+
const fieldError2 = props.members.find(
|
|
3224
|
+
(m) => m.kind === "error" && m.fieldName === "fields"
|
|
3225
|
+
);
|
|
3226
|
+
if (fieldError2)
|
|
3227
|
+
return /* @__PURE__ */ jsxRuntime.jsx(sanity.MemberFieldError, { member: fieldError2 });
|
|
3228
|
+
}, [props.members]);
|
|
3229
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedFieldContextProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 5, children: [
|
|
3214
3230
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3215
3231
|
FieldsInitializer,
|
|
3216
3232
|
{
|
|
@@ -3223,7 +3239,8 @@ function AssistDocumentFormEditable(props) {
|
|
|
3223
3239
|
typePath
|
|
3224
3240
|
),
|
|
3225
3241
|
instruction2 && /* @__PURE__ */ jsxRuntime.jsx(BackToInstructionListLink, {}),
|
|
3226
|
-
activePath && /* @__PURE__ */ jsxRuntime.jsx(sanity.FormCallbacksProvider, { ...newCallbacks, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { lineHeight: "1.25em" }, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.FormInput, { ...props, absolutePath: activePath }) }) }),
|
|
3242
|
+
activePath && !fieldError && /* @__PURE__ */ jsxRuntime.jsx(sanity.FormCallbacksProvider, { ...newCallbacks, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { lineHeight: "1.25em" }, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.FormInput, { ...props, absolutePath: activePath }) }) }),
|
|
3243
|
+
fieldError,
|
|
3227
3244
|
!activePath && props.renderDefault(props)
|
|
3228
3245
|
] }) });
|
|
3229
3246
|
}
|