sanity 5.7.0-next.16 → 5.7.0-next.19

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.16+a85174dcdc", peerDependencies = {
1
+ var version = "5.7.0-next.19+9d76742237", 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.16+a85174dcdc";
10
+ "5.7.0-next.19+9d76742237";
11
11
  } catch {
12
12
  }
13
13
  const SANITY_VERSION = buildVersion || `${version}-dev`;
package/lib/index.js CHANGED
@@ -84648,7 +84648,13 @@ function transformValueToText(value) {
84648
84648
  return value ? isString(value) ? value : Number.isFinite(value) ? value.toString() : Array.isArray(value) ? value.map(transformValueToText).filter(Boolean).join(", ") : typeof value == "object" ? Object.entries(value).map(([key, subValue]) => key.startsWith("_") ? "" : transformValueToText(subValue)).filter(Boolean).join(", ") : "" : "";
84649
84649
  }
84650
84650
  function isEmptyValue(value) {
84651
- return !!(value == null || Array.isArray(value) && value.length === 0);
84651
+ if (value == null) return !0;
84652
+ if (typeof value == "object") {
84653
+ const keys = Object.keys(value);
84654
+ if (keys.length === 1 && keys[0] === "_key")
84655
+ return !0;
84656
+ }
84657
+ return !!(Array.isArray(value) && value.length === 0);
84652
84658
  }
84653
84659
  function isNativeEditableElement(el) {
84654
84660
  return !!(el instanceof HTMLElement && el.isContentEditable || el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement);
@@ -84874,7 +84880,10 @@ async function collateObjectValue({
84874
84880
  errors
84875
84881
  };
84876
84882
  const targetValue = {
84877
- _type: targetSchemaType.name,
84883
+ // Only set _type if the source value had one (preserves anonymous objects)
84884
+ ...isTypedObject(sourceValue) ? {
84885
+ _type: targetSchemaType.name
84886
+ } : {},
84878
84887
  ...sourceValue && typeof sourceValue == "object" && "_key" in sourceValue ? {
84879
84888
  _key: keyGenerator2()
84880
84889
  } : {}
@@ -85073,6 +85082,10 @@ async function collateObjectValue({
85073
85082
  errors
85074
85083
  };
85075
85084
  }
85085
+ function findMatchingArrayMemberType(item, targetSchemaType) {
85086
+ const itemTypeName = resolveTypeName$1(item);
85087
+ return targetSchemaType.of.find((type) => type.name === itemTypeName);
85088
+ }
85076
85089
  async function collateArrayValue({
85077
85090
  sourceValue,
85078
85091
  targetSchemaType,
@@ -85115,10 +85128,10 @@ async function collateArrayValue({
85115
85128
  }), transferredItems.length > 0 && (targetValue = transferredItems);
85116
85129
  }
85117
85130
  if (isArrayOfObjectsMember) {
85118
- const value = sourceValue, transferredItems = value.filter((item) => targetSchemaType.of.some((type) => type.name === item._type)), nonTransferredItems = value.filter((item) => !targetSchemaType.of.some((type) => type.name === item._type));
85131
+ const value = sourceValue, transferredItems = value.filter((item) => findMatchingArrayMemberType(item, targetSchemaType) !== void 0), nonTransferredItems = value.filter((item) => findMatchingArrayMemberType(item, targetSchemaType) === void 0);
85119
85132
  transferredItems.length === 0 ? targetValue = void 0 : targetValue = (await Promise.all(transferredItems.map((item) => collateObjectValue({
85120
85133
  sourceValue: item,
85121
- targetSchemaType: targetSchemaType.of.find((type) => type.name === item._type),
85134
+ targetSchemaType: findMatchingArrayMemberType(item, targetSchemaType),
85122
85135
  targetPath: [],
85123
85136
  targetRootValue,
85124
85137
  targetRootPath,
@@ -85132,7 +85145,7 @@ async function collateArrayValue({
85132
85145
  i18n: {
85133
85146
  key: "copy-paste.on-paste.validation.array-value-incompatible.description",
85134
85147
  args: {
85135
- type: item._type || typeof item
85148
+ type: resolveTypeName$1(item)
85136
85149
  }
85137
85150
  }
85138
85151
  });