sanity 5.7.0-next.19 → 5.7.0-next.21

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.
@@ -1,4 +1,4 @@
1
- var version = "5.7.0-next.19+9d76742237", peerDependencies = {
1
+ var version = "5.7.0-next.21+dc2bd872b2", peerDependencies = {
2
2
  "styled-components": "^6.1.15"
3
3
  };
4
4
  export {
@@ -7,7 +7,7 @@ try {
7
7
  try {
8
8
  buildVersion = buildVersion || // This is replaced by `@sanity/pkg-utils` at build time
9
9
  // and must always be references by its full static name, e.g. no optional chaining, no `if (process && process.env)` etc.
10
- "5.7.0-next.19+9d76742237";
10
+ "5.7.0-next.21+dc2bd872b2";
11
11
  } catch {
12
12
  }
13
13
  const SANITY_VERSION = buildVersion || `${version}-dev`;
package/lib/index.js CHANGED
@@ -16,7 +16,7 @@ import { Hotkeys } from "./_chunks-es/TooltipDelayGroupProvider.js";
16
16
  import { ResizeObserver as ResizeObserver$2 } from "@juggle/resize-observer";
17
17
  import createPubSub from "nano-pubsub";
18
18
  import { I18nextProvider, useTranslation as useTranslation$1, initReactI18next } from "react-i18next";
19
- import { isIndexSegment, isKeySegment, isIndexTuple, isKeyedObject, isReference as isReference$1, isArrayOfBlocksSchemaType, isSlug, isTypedObject, isGlobalDocumentReference, isObjectSchemaType, isArraySchemaType, isPortableTextSpan, isPortableTextTextBlock, isPrimitiveSchemaType, isBooleanSchemaType, isDateTimeSchemaType, isCrossDatasetReferenceSchemaType, isReferenceSchemaType, isStringSchemaType, isNumberSchemaType, isArrayOfObjectsSchemaType, isArrayOfPrimitivesSchemaType, isCrossDatasetReference, isTitledListValue, isImage, isValidationErrorMarker, isImageSchemaType, isSearchStrategy, searchStrategies as searchStrategies$1, defineType, defineField, defineArrayMember, isValidationWarningMarker, isValidationInfoMarker, isDeprecatedSchemaType, isFileSchemaType, isBlockSchemaType } from "@sanity/types";
19
+ import { isIndexSegment, isKeySegment, isIndexTuple, isKeyedObject, isReference as isReference$1, isArrayOfBlocksSchemaType, isSlug, isTypedObject, isGlobalDocumentReference, isObjectSchemaType, isArraySchemaType, isPortableTextSpan, isPortableTextTextBlock, isPrimitiveSchemaType, isBooleanSchemaType, isDateTimeSchemaType, isCrossDatasetReferenceSchemaType, isReferenceSchemaType, isStringSchemaType, isNumberSchemaType, isArrayOfObjectsSchemaType, isArrayOfPrimitivesSchemaType, isCrossDatasetReference, isTitledListValue, isImage, isValidationErrorMarker, isImageSchemaType, isSearchStrategy, searchStrategies as searchStrategies$1, defineType, defineField, defineArrayMember, isValidationWarningMarker, isValidationInfoMarker, isDeprecatedSchemaType, isBlockSchemaType, isSpanSchemaType, isFileSchemaType } from "@sanity/types";
20
20
  export * from "@sanity/types";
21
21
  import { COLOR_HUES, hues, white, red, gray, yellow, purple, black, green, blue } from "@sanity/color";
22
22
  import { of, concat, defer, EMPTY as EMPTY$5, map as map$1, defaultIfEmpty, catchError as catchError$1, switchMap as switchMap$1, take, concatMap, from, Observable, merge, Subject, fromEvent, throwError, timer, NEVER, pipe, distinctUntilChanged as distinctUntilChanged$1, shareReplay as shareReplay$1, BehaviorSubject, tap as tap$1, finalize, share as share$1, ReplaySubject, combineLatest, asyncScheduler, bufferTime, mergeMap as mergeMap$1, firstValueFrom, filter as filter$1, lastValueFrom, partition as partition$1, asapScheduler, using, repeat, iif, startWith as startWith$1, concatWith, scan as scan$1, count, isObservable, retry, expand, reduce as reduce$2, skip as skip$1, forkJoin, debounce as debounce$2, toArray as toArray$2, delay as delay$1, timeout as timeout$1, connect, debounceTime as debounceTime$1 } from "rxjs";
@@ -84656,6 +84656,9 @@ function isEmptyValue(value) {
84656
84656
  }
84657
84657
  return !!(Array.isArray(value) && value.length === 0);
84658
84658
  }
84659
+ function isPortableTextPreserveEmptyField(member, targetSchemaType) {
84660
+ return member.name === "markDefs" && isBlockSchemaType(targetSchemaType) || member.name === "marks" && isSpanSchemaType(targetSchemaType);
84661
+ }
84659
84662
  function isNativeEditableElement(el) {
84660
84663
  return !!(el instanceof HTMLElement && el.isContentEditable || el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement);
84661
84664
  }
@@ -85070,7 +85073,8 @@ async function collateObjectValue({
85070
85073
  });
85071
85074
  if (isPortableTextBlockWithMarkdefs && member.name === "markDefs" && !isEmptyValue(targetValue.markDefs))
85072
85075
  continue;
85073
- isEmptyValue(collated.targetValue) || (targetValue[member.name] = collated.targetValue);
85076
+ const shouldPreserveEmptyArray = Array.isArray(genericValue) && genericValue.length === 0 && isPortableTextPreserveEmptyField(member, targetSchemaType);
85077
+ isEmptyValue(collated.targetValue) ? shouldPreserveEmptyArray && (targetValue[member.name] = []) : targetValue[member.name] = collated.targetValue;
85074
85078
  }
85075
85079
  }
85076
85080
  const valueAtTargetPath = getValueAtPath(targetValue, targetPath), resultingValue = cleanObjectKeys(valueAtTargetPath);