@sanity/assist 1.2.6 → 1.2.8

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/dist/index.esm.js CHANGED
@@ -166,7 +166,7 @@ function isUnsupportedType(type) {
166
166
  }
167
167
  const inlineTypes = ["document", "object", "image", "file"];
168
168
  function serializeSchema(schema, options) {
169
- const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t => !t.hidden && !t.readOnly).map(t => getSchemaStub(t, schema, options)).filter(t => {
169
+ const list = schema.getTypeNames().filter(t => !(hiddenTypes.includes(t) || t.startsWith("sanity."))).map(t => schema.get(t)).filter(t => !!t).filter(t => isAssistSupported(t)).filter(t => !t.hidden && !t.readOnly).map(t => getSchemaStub(t, schema, options)).filter(t => {
170
170
  if ("to" in t && t.to && !t.to.length) {
171
171
  return false;
172
172
  }
@@ -210,7 +210,7 @@ function getBaseFields(schema, type, typeName, options) {
210
210
  options: imagePromptField ? {
211
211
  imagePromptField
212
212
  } : void 0,
213
- values: ((_b = type == null ? void 0 : type.options) == null ? void 0 : _b.list) ? (_c = type == null ? void 0 : type.options) == null ? void 0 : _c.list.map(v => {
213
+ values: Array.isArray((_b = type == null ? void 0 : type.options) == null ? void 0 : _b.list) ? (_c = type == null ? void 0 : type.options) == null ? void 0 : _c.list.map(v => {
214
214
  var _a2;
215
215
  return typeof v === "string" ? v : (_a2 = v.value) != null ? _a2 : "".concat(v.title);
216
216
  }) : void 0,
@@ -4422,7 +4422,7 @@ const assistFieldActions = {
4422
4422
  isDocAssistable: documentIsAssistable != null ? documentIsAssistable : false
4423
4423
  });
4424
4424
  const isSelectable = !!useSelectedField(documentSchemaType, typePath);
4425
- const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable;
4425
+ const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType);
4426
4426
  const fieldAssist = useMemo(() => {
4427
4427
  var _a;
4428
4428
  return ((_a = assistDocument == null ? void 0 : assistDocument.fields) != null ? _a : []).find(f => f.path === typePath || pathKey === documentRootKey && f.path === pathKey);
@@ -4714,7 +4714,10 @@ const assist = definePlugin(config => {
4714
4714
  schemaType
4715
4715
  } = _ref17;
4716
4716
  const docSchema = schema.get(schemaType);
4717
- return [...prev, createAssistDocumentPresence(documentId, docSchema)];
4717
+ if (isSchemaAssistEnabled(docSchema)) {
4718
+ return [...prev, createAssistDocumentPresence(documentId, docSchema)];
4719
+ }
4720
+ return prev;
4718
4721
  }
4719
4722
  },
4720
4723
  studio: {