sanity 5.2.0-next.49 → 5.2.0-next.50

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.2.0-next.49+224c02f1b3", peerDependencies = {
1
+ var version = "5.2.0-next.50+9b405c23d7", 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.2.0-next.49+224c02f1b3";
10
+ "5.2.0-next.50+9b405c23d7";
11
11
  } catch {
12
12
  }
13
13
  const SANITY_VERSION = buildVersion || `${version}-dev`;
package/lib/index.js CHANGED
@@ -24339,7 +24339,7 @@ function shouldBeInBreadcrumb(itemPath, path, documentValue) {
24339
24339
  let currentValue = documentValue;
24340
24340
  for (const segment of itemPath)
24341
24341
  if (typeof segment == "string" ? currentValue = currentValue?.[segment] : typeof segment == "object" && isKeySegment(segment) && Array.isArray(currentValue) && (currentValue = currentValue.find((child) => child?._key === segment._key)), !currentValue) break;
24342
- return currentValue && typeof currentValue == "object" && "_type" in currentValue && hasSpanChildren(currentValue) ? !1 : itemPath.every((segment, index) => isArrayItemSelected(path[index], segment)) && isArrayItemPath(itemPath);
24342
+ return currentValue && typeof currentValue == "object" && "_type" in currentValue && hasSpanChildren(currentValue) ? !1 : itemPath.every((segment, index) => isArrayItemSelected(path[index], segment));
24343
24343
  }
24344
24344
  function shouldSkipSiblingCount(args) {
24345
24345
  const {
@@ -57044,7 +57044,7 @@ function resolveSchemaTypeForPath(baseType, path, documentValue) {
57044
57044
  }), currentField;
57045
57045
  }
57046
57046
  function useBreadcrumbPreview(itemPath, documentSchemaType, documentValue) {
57047
- const $ = c(7), value = useFormValue(itemPath);
57047
+ const $ = c(10), value = useFormValue(itemPath);
57048
57048
  let t0;
57049
57049
  $[0] !== documentSchemaType || $[1] !== documentValue || $[2] !== itemPath ? (t0 = resolveSchemaTypeForPath(documentSchemaType, itemPath, documentValue), $[0] = documentSchemaType, $[1] = documentValue, $[2] = itemPath, $[3] = t0) : t0 = $[3];
57050
57050
  const schemaType = t0;
@@ -57056,10 +57056,11 @@ function useBreadcrumbPreview(itemPath, documentSchemaType, documentValue) {
57056
57056
  const {
57057
57057
  value: preview
57058
57058
  } = useValuePreviewWithFallback(t1);
57059
- return preview.title;
57059
+ let t2;
57060
+ return $[7] !== preview || $[8] !== schemaType ? (t2 = isArraySchemaType(schemaType) ? schemaType.title : preview.title, $[7] = preview, $[8] = schemaType, $[9] = t2) : t2 = $[9], t2;
57060
57061
  }
57061
57062
  function useBreadcrumbSiblingInfo(itemPath, documentSchemaType, documentValue) {
57062
- const $ = c(9), lastKeySegmentIndex = itemPath.findLastIndex(isKeySegment);
57063
+ const $ = c(9), hasKeySegment = isKeySegment(itemPath[itemPath.length - 1]), lastKeySegmentIndex = itemPath.findLastIndex(isKeySegment);
57063
57064
  let t0;
57064
57065
  bb0: {
57065
57066
  if (lastKeySegmentIndex < 0) {
@@ -57086,6 +57087,10 @@ function useBreadcrumbSiblingInfo(itemPath, documentSchemaType, documentValue) {
57086
57087
  const isInsidePTEChildren = t1, itemSchemaType = resolveSchemaTypeForPath(documentSchemaType, itemPath, documentValue);
57087
57088
  let t2;
57088
57089
  bb2: {
57090
+ if (!hasKeySegment) {
57091
+ t2 = null;
57092
+ break bb2;
57093
+ }
57089
57094
  if (lastKeySegmentIndex < 0) {
57090
57095
  t2 = null;
57091
57096
  break bb2;
@@ -57198,7 +57203,7 @@ function BreadcrumbButton(t0) {
57198
57203
  return $[17] !== handleClick || $[18] !== t12 || $[19] !== t4 || $[20] !== title ? (t13 = /* @__PURE__ */ jsx(Button$1, { mode: "bleed", padding: 1, radius: 2, onClick: handleClick, style: t3, title, "aria-label": title, "aria-current": t4, children: t12 }), $[17] = handleClick, $[18] = t12, $[19] = t4, $[20] = title, $[21] = t13) : t13 = $[21], t13;
57199
57204
  }
57200
57205
  function BreadcrumbMenuItem(t0) {
57201
- const $ = c(20), {
57206
+ const $ = c(19), {
57202
57207
  itemPath,
57203
57208
  documentSchemaType,
57204
57209
  documentValue,
@@ -57215,38 +57220,35 @@ function BreadcrumbMenuItem(t0) {
57215
57220
  maxWidth: "250px"
57216
57221
  }, $[3] = t2) : t2 = $[3];
57217
57222
  let t3;
57218
- $[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(Box, { flex: "none", padding: 1, children: /* @__PURE__ */ jsx(Text$1, { size: 1, muted: !0, children: SEPARATOR }) }), $[4] = t3) : t3 = $[4];
57219
- let t4;
57220
- $[5] !== siblingInfo ? (t4 = siblingInfo && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsxs(Badge, { children: [
57223
+ $[4] !== siblingInfo ? (t3 = siblingInfo && /* @__PURE__ */ jsxs(Badge, { size: 1, children: [
57221
57224
  "#",
57222
57225
  siblingInfo.index
57223
- ] }) }), $[5] = siblingInfo, $[6] = t4) : t4 = $[6];
57224
- const t5 = siblingInfo?.index ? 1 : 0;
57225
- let t6;
57226
- $[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = {
57226
+ ] }), $[4] = siblingInfo, $[5] = t3) : t3 = $[5];
57227
+ const t4 = siblingInfo?.index ? 1 : 0;
57228
+ let t5;
57229
+ $[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = {
57227
57230
  minWidth: 0,
57228
57231
  overflow: "hidden"
57229
- }, $[7] = t6) : t6 = $[7];
57230
- let t7;
57231
- $[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = {
57232
+ }, $[6] = t5) : t5 = $[6];
57233
+ let t6;
57234
+ $[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = {
57232
57235
  whiteSpace: "nowrap",
57233
57236
  textTransform: "capitalize"
57234
- }, $[8] = t7) : t7 = $[8];
57237
+ }, $[7] = t6) : t6 = $[7];
57238
+ let t7;
57239
+ $[8] !== title ? (t7 = /* @__PURE__ */ jsx(Text$1, { size: 1, textOverflow: "ellipsis", style: t6, title, children: title }), $[8] = title, $[9] = t7) : t7 = $[9];
57235
57240
  let t8;
57236
- $[9] !== title ? (t8 = /* @__PURE__ */ jsx(Text$1, { size: 1, textOverflow: "ellipsis", style: t7, title, children: title }), $[9] = title, $[10] = t8) : t8 = $[10];
57241
+ $[10] !== t4 || $[11] !== t7 ? (t8 = /* @__PURE__ */ jsx(Box, { paddingLeft: t4, paddingY: 1, style: t5, children: t7 }), $[10] = t4, $[11] = t7, $[12] = t8) : t8 = $[12];
57237
57242
  let t9;
57238
- $[11] !== t5 || $[12] !== t8 ? (t9 = /* @__PURE__ */ jsx(Box, { paddingLeft: t5, paddingY: 1, style: t6, children: t8 }), $[11] = t5, $[12] = t8, $[13] = t9) : t9 = $[13];
57239
- let t10;
57240
- $[14] !== t4 || $[15] !== t9 ? (t10 = /* @__PURE__ */ jsxs(Flex, { align: "center", style: t2, children: [
57243
+ $[13] !== t3 || $[14] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Flex, { align: "center", style: t2, children: [
57241
57244
  t3,
57242
- t4,
57243
- t9
57244
- ] }), $[14] = t4, $[15] = t9, $[16] = t10) : t10 = $[16];
57245
- let t11;
57246
- return $[17] !== handleClick || $[18] !== t10 ? (t11 = /* @__PURE__ */ jsx(MenuItem$1, { padding: 1, onClick: handleClick, children: t10 }), $[17] = handleClick, $[18] = t10, $[19] = t11) : t11 = $[19], t11;
57245
+ t8
57246
+ ] }), $[13] = t3, $[14] = t8, $[15] = t9) : t9 = $[15];
57247
+ let t10;
57248
+ return $[16] !== handleClick || $[17] !== t9 ? (t10 = /* @__PURE__ */ jsx(MenuItem$1, { padding: 1, onClick: handleClick, children: t9 }), $[16] = handleClick, $[17] = t9, $[18] = t10) : t10 = $[18], t10;
57247
57249
  }
57248
57250
  function DialogBreadcrumbs(t0) {
57249
- const $ = c(43), {
57251
+ const $ = c(30), {
57250
57252
  currentPath
57251
57253
  } = t0, {
57252
57254
  onPathOpen
@@ -57257,9 +57259,25 @@ function DialogBreadcrumbs(t0) {
57257
57259
  $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
57258
57260
  const documentValue = useFormValue(t1), [rootElement, setRootElement] = useState(null), size = useElementSize(rootElement);
57259
57261
  let t2;
57260
- $[1] !== onPathOpen ? (t2 = (path) => {
57261
- onPathOpen(path);
57262
- }, $[1] = onPathOpen, $[2] = t2) : t2 = $[2];
57262
+ $[1] !== currentPath || $[2] !== documentSchemaType || $[3] !== documentValue || $[4] !== onPathOpen ? (t2 = (path) => {
57263
+ if (isKeySegment(path[path.length - 1])) {
57264
+ if (currentPath && currentPath.length > path.length && path.every((segment, index) => {
57265
+ const currentSegment = currentPath[index];
57266
+ return isKeySegment(segment) && isKeySegment(currentSegment) ? segment._key === currentSegment._key : segment === currentSegment;
57267
+ })) {
57268
+ const nextSegment = currentPath[path.length];
57269
+ if (!isKeySegment(nextSegment)) {
57270
+ const itemSchemaType = resolveSchemaTypeForPath(documentSchemaType, path, documentValue);
57271
+ if (isObjectSchemaType(itemSchemaType) && itemSchemaType.fields.some((field) => field.name === nextSegment)) {
57272
+ onPathOpen([...path, nextSegment]);
57273
+ return;
57274
+ }
57275
+ }
57276
+ }
57277
+ onPathOpen(path);
57278
+ } else
57279
+ onPathOpen(path);
57280
+ }, $[1] = currentPath, $[2] = documentSchemaType, $[3] = documentValue, $[4] = onPathOpen, $[5] = t2) : t2 = $[5];
57263
57281
  const handlePathSelect = t2;
57264
57282
  let t3;
57265
57283
  bb0: {
@@ -57269,11 +57287,11 @@ function DialogBreadcrumbs(t0) {
57269
57287
  break bb0;
57270
57288
  }
57271
57289
  if (w < 500) {
57272
- t3 = 3;
57290
+ t3 = 5;
57273
57291
  break bb0;
57274
57292
  }
57275
57293
  if (w < 700) {
57276
- t3 = 4;
57294
+ t3 = 6;
57277
57295
  break bb0;
57278
57296
  }
57279
57297
  t3 = MAX_LENGTH;
@@ -57283,18 +57301,16 @@ function DialogBreadcrumbs(t0) {
57283
57301
  bb1: {
57284
57302
  if (!currentPath || currentPath.length === 0) {
57285
57303
  let t52;
57286
- $[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t52 = [], $[3] = t52) : t52 = $[3], t4 = t52;
57304
+ $[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t52 = [], $[6] = t52) : t52 = $[6], t4 = t52;
57287
57305
  break bb1;
57288
57306
  }
57289
57307
  let result;
57290
- $[4] !== currentPath || $[5] !== documentValue ? (result = [], currentPath.forEach((segment, index) => {
57291
- if (isKeySegment(segment)) {
57292
- const itemPath = currentPath.slice(0, index + 1);
57293
- shouldBeInBreadcrumb(itemPath, currentPath, documentValue) && result.push({
57294
- path: itemPath
57295
- });
57296
- }
57297
- }), $[4] = currentPath, $[5] = documentValue, $[6] = result) : result = $[6], t4 = result;
57308
+ $[7] !== currentPath || $[8] !== documentValue ? (result = [], currentPath.forEach((segment_0, index_0) => {
57309
+ const itemPath = currentPath.slice(0, index_0 + 1);
57310
+ shouldBeInBreadcrumb(itemPath, currentPath, documentValue) && result.push({
57311
+ path: itemPath
57312
+ });
57313
+ }), $[7] = currentPath, $[8] = documentValue, $[9] = result) : result = $[9], t4 = result;
57298
57314
  }
57299
57315
  const rawItems = t4;
57300
57316
  let t5;
@@ -57302,70 +57318,47 @@ function DialogBreadcrumbs(t0) {
57302
57318
  const len = rawItems.length + 1, availableSlots = maxLength - 1, beforeLength = Math.ceil(availableSlots / 2), afterLength = Math.floor(availableSlots / 2);
57303
57319
  if (maxLength && len > maxLength) {
57304
57320
  let t62;
57305
- $[7] !== beforeLength || $[8] !== rawItems ? (t62 = rawItems.slice(0, beforeLength - 1), $[7] = beforeLength, $[8] = rawItems, $[9] = t62) : t62 = $[9];
57306
- let t72;
57307
- $[10] !== afterLength || $[11] !== beforeLength || $[12] !== rawItems ? (t72 = rawItems.slice(beforeLength - 1, rawItems.length - afterLength), $[10] = afterLength, $[11] = beforeLength, $[12] = rawItems, $[13] = t72) : t72 = $[13];
57308
- let t82;
57309
- $[14] !== afterLength || $[15] !== rawItems ? (t82 = rawItems.slice(rawItems.length - afterLength), $[14] = afterLength, $[15] = rawItems, $[16] = t82) : t82 = $[16];
57310
- let t92;
57311
- $[17] !== t62 || $[18] !== t72 || $[19] !== t82 ? (t92 = [...t62, t72, ...t82], $[17] = t62, $[18] = t72, $[19] = t82, $[20] = t92) : t92 = $[20], t5 = t92;
57321
+ $[10] !== beforeLength || $[11] !== rawItems ? (t62 = rawItems.slice(0, beforeLength - 1), $[10] = beforeLength, $[11] = rawItems, $[12] = t62) : t62 = $[12];
57322
+ let t7;
57323
+ $[13] !== afterLength || $[14] !== beforeLength || $[15] !== rawItems ? (t7 = rawItems.slice(beforeLength - 1, rawItems.length - afterLength), $[13] = afterLength, $[14] = beforeLength, $[15] = rawItems, $[16] = t7) : t7 = $[16];
57324
+ let t8;
57325
+ $[17] !== afterLength || $[18] !== rawItems ? (t8 = rawItems.slice(rawItems.length - afterLength), $[17] = afterLength, $[18] = rawItems, $[19] = t8) : t8 = $[19];
57326
+ let t9;
57327
+ $[20] !== t62 || $[21] !== t7 || $[22] !== t8 ? (t9 = [...t62, t7, ...t8], $[20] = t62, $[21] = t7, $[22] = t8, $[23] = t9) : t9 = $[23], t5 = t9;
57312
57328
  break bb2;
57313
57329
  }
57314
57330
  t5 = rawItems;
57315
57331
  }
57316
57332
  const items = t5;
57317
- let t6;
57318
- $[21] !== currentPath?.[0] ? (t6 = currentPath?.[0]?.toString(), $[21] = currentPath?.[0], $[22] = t6) : t6 = $[22];
57319
- const rootFieldName = t6;
57320
57333
  if (!currentPath || currentPath.length === 0)
57321
57334
  return null;
57322
- let t7;
57323
- $[23] !== currentPath || $[24] !== documentSchemaType || $[25] !== documentValue || $[26] !== handlePathSelect || $[27] !== items ? (t7 = items.map((item, index_0) => {
57324
- const key = `breadcrumb-${index_0}`, showSeparator = index_0 < items.length - 1;
57325
- if (Array.isArray(item))
57326
- return /* @__PURE__ */ jsxs(Inline, { children: [
57327
- /* @__PURE__ */ jsx(MenuButton, { id: "breadcrumb-overflow-menu-button", button: /* @__PURE__ */ jsx(Button$1, { mode: "bleed", padding: 1, style: overflowButtonStyle, children: /* @__PURE__ */ jsx(Flex, { overflow: "hidden", children: /* @__PURE__ */ jsx(Text$1, { size: 1, weight: "medium", textOverflow: "ellipsis", style: overflowTextStyle, "aria-label": "More breadcrumb items", children: "..." }) }) }), popover: {
57328
- placement: "bottom-start",
57329
- portal: !0
57330
- }, menu: /* @__PURE__ */ jsx(Menu, { children: item.map((overflowItem) => /* @__PURE__ */ jsx(BreadcrumbMenuItem, { itemPath: overflowItem.path, documentSchemaType, documentValue, onPathSelect: handlePathSelect }, overflowItem.path.toString())) }) }),
57335
+ let t6;
57336
+ if ($[24] !== currentPath || $[25] !== documentSchemaType || $[26] !== documentValue || $[27] !== handlePathSelect || $[28] !== items) {
57337
+ const nodes = items.map((item, index_1) => {
57338
+ const key = `breadcrumb-${index_1}`, showSeparator = index_1 < items.length - 1;
57339
+ if (Array.isArray(item))
57340
+ return /* @__PURE__ */ jsxs(Inline, { children: [
57341
+ /* @__PURE__ */ jsx(MenuButton, { id: "breadcrumb-overflow-menu-button", button: /* @__PURE__ */ jsx(Button$1, { mode: "bleed", padding: 1, style: overflowButtonStyle, children: /* @__PURE__ */ jsx(Flex, { overflow: "hidden", children: /* @__PURE__ */ jsx(Text$1, { size: 1, weight: "medium", textOverflow: "ellipsis", style: overflowTextStyle, "aria-label": "More breadcrumb items", children: "..." }) }) }), popover: {
57342
+ placement: "bottom-start",
57343
+ portal: !0
57344
+ }, menu: /* @__PURE__ */ jsx(Menu, { children: item.map((overflowItem) => /* @__PURE__ */ jsx(BreadcrumbMenuItem, { itemPath: overflowItem.path, documentSchemaType, documentValue, onPathSelect: handlePathSelect }, overflowItem.path.toString())) }) }),
57345
+ showSeparator && /* @__PURE__ */ jsx(SeparatorItem, { children: SEPARATOR })
57346
+ ] }, key);
57347
+ const isSelected = currentPath.length === item.path.length && item.path.every((seg, i) => {
57348
+ const currentSeg = currentPath[i];
57349
+ return isKeySegment(seg) && isKeySegment(currentSeg) ? seg._key === currentSeg._key : seg === currentSeg;
57350
+ }), isLast = index_1 === items.length - 1;
57351
+ return /* @__PURE__ */ jsxs(Inline, { flex: isLast ? 1 : void 0, style: {
57352
+ minWidth: 0
57353
+ }, children: [
57354
+ /* @__PURE__ */ jsx(BreadcrumbButton, { itemPath: item.path, documentSchemaType, documentValue, isSelected, onPathSelect: handlePathSelect }),
57331
57355
  showSeparator && /* @__PURE__ */ jsx(SeparatorItem, { children: SEPARATOR })
57332
57356
  ] }, key);
57333
- const isSelected = currentPath.length === item.path.length && item.path.every((seg, i) => {
57334
- const currentSeg = currentPath[i];
57335
- return isKeySegment(seg) && isKeySegment(currentSeg) ? seg._key === currentSeg._key : seg === currentSeg;
57336
- }), isLast = index_0 === items.length - 1;
57337
- return /* @__PURE__ */ jsxs(Inline, { flex: isLast ? 1 : void 0, style: {
57338
- minWidth: 0
57339
- }, children: [
57340
- /* @__PURE__ */ jsx(BreadcrumbButton, { itemPath: item.path, documentSchemaType, documentValue, isSelected, onPathSelect: handlePathSelect }),
57341
- showSeparator && /* @__PURE__ */ jsx(SeparatorItem, { children: SEPARATOR })
57342
- ] }, key);
57343
- }), $[23] = currentPath, $[24] = documentSchemaType, $[25] = documentValue, $[26] = handlePathSelect, $[27] = items, $[28] = t7) : t7 = $[28];
57344
- const nodes = t7;
57345
- let t8;
57346
- $[29] !== handlePathSelect ? (t8 = () => handlePathSelect([]), $[29] = handlePathSelect, $[30] = t8) : t8 = $[30];
57347
- let t9;
57348
- $[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = {
57349
- minWidth: 0,
57350
- maxWidth: "250px"
57351
- }, $[31] = t9) : t9 = $[31];
57352
- let t10;
57353
- $[32] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = {
57354
- whiteSpace: "nowrap",
57355
- textTransform: "capitalize"
57356
- }, $[32] = t10) : t10 = $[32];
57357
- let t11;
57358
- $[33] !== rootFieldName ? (t11 = /* @__PURE__ */ jsx(Text$1, { muted: !0, size: 1, textOverflow: "ellipsis", style: t10, children: rootFieldName }), $[33] = rootFieldName, $[34] = t11) : t11 = $[34];
57359
- let t12;
57360
- $[35] !== rootFieldName || $[36] !== t11 || $[37] !== t8 ? (t12 = /* @__PURE__ */ jsx(Button$1, { mode: "bleed", padding: 2, radius: 2, onClick: t8, style: t9, title: rootFieldName, "aria-label": rootFieldName, children: t11 }), $[35] = rootFieldName, $[36] = t11, $[37] = t8, $[38] = t12) : t12 = $[38];
57361
- let t13;
57362
- $[39] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t13 = /* @__PURE__ */ jsx(SeparatorItem, { children: SEPARATOR }), $[39] = t13) : t13 = $[39];
57363
- let t14;
57364
- return $[40] !== nodes || $[41] !== t12 ? (t14 = /* @__PURE__ */ jsxs(Inline, { ref: setRootElement, style: rootInlineStyle, children: [
57365
- t12,
57366
- t13,
57367
- nodes
57368
- ] }), $[40] = nodes, $[41] = t12, $[42] = t14) : t14 = $[42], t14;
57357
+ });
57358
+ t6 = /* @__PURE__ */ jsx(Inline, { ref: setRootElement, style: rootInlineStyle, children: nodes }), $[24] = currentPath, $[25] = documentSchemaType, $[26] = documentValue, $[27] = handlePathSelect, $[28] = items, $[29] = t6;
57359
+ } else
57360
+ t6 = $[29];
57361
+ return t6;
57369
57362
  }
57370
57363
  const StyledDialog$2 = styled(Dialog)`
57371
57364
  ${(props2) => props2.$isHidden && `