sanity 5.27.0-next.9 → 5.27.0

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.
@@ -29,6 +29,7 @@ import { CSSProperties as CSSProperties$1, ExecutionProps } from "styled-compone
29
29
  import { ThrottleSettings } from "lodash-es/throttle.js";
30
30
  import { DEFAULT_ANNOTATIONS, DEFAULT_DECORATORS } from "@sanity/schema";
31
31
  import * as _$styled_components_dist_types0 from "/home/runner/work/sanity/sanity/node_modules/.pnpm/@sanity+styled-components@6.1.24_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@sanity/styled-components/dist/types.js";
32
+ import { SanityImageSource } from "@sanity/asset-utils";
32
33
  import { PortableTextMemberSchemaTypes } from "@portabletext/sanity-bridge";
33
34
  import { ImageUrlBuilder, ImageUrlBuilder as ImageUrlBuilder$1 } from "@sanity/image-url";
34
35
  import { MarkdownShortcutsPluginProps } from "@portabletext/plugin-markdown-shortcuts";
@@ -9901,7 +9902,7 @@ interface PreviewProps<TLayoutKey = PreviewLayoutKey> {
9901
9902
  imageUrl?: string;
9902
9903
  isPlaceholder?: boolean;
9903
9904
  layout?: TLayoutKey;
9904
- media?: ReactNode | ComponentType<{
9905
+ media?: ReactNode | SanityImageSource | ComponentType<{
9905
9906
  dimensions: PreviewMediaDimensions;
9906
9907
  layout: TLayoutKey;
9907
9908
  }>;
@@ -1,4 +1,4 @@
1
- var version = "5.27.0-next.9+c78ec37786";
1
+ var version = "5.27.0";
2
2
  let buildVersion;
3
3
  try {
4
4
  buildVersion = process.env.PKG_BUILD_VERSION;
@@ -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.27.0-next.9+c78ec37786";
10
+ "5.27.0";
11
11
  } catch {
12
12
  }
13
13
  const SANITY_VERSION = buildVersion || `${version}-dev`;
package/lib/index.js CHANGED
@@ -58,7 +58,7 @@ import orderBy from "lodash-es/orderBy.js";
58
58
  import { nanoid, customAlphabet } from "nanoid";
59
59
  import * as legacyDateFormat from "@sanity/util/legacyDateFormat";
60
60
  import { sanitizeLocale, format as format$1, DEFAULT_DATE_FORMAT, parse as parse$2, isValidTimeZoneString, DEFAULT_TIME_FORMAT } from "@sanity/util/legacyDateFormat";
61
- import { getImageDimensions, isDefaultCrop, isDefaultHotspot, isImageSource, isFileSource, isSanityImageUrl, parseImageAssetUrl, isAssetObjectStub, isImageAssetId, isFileAssetId } from "@sanity/asset-utils";
61
+ import { getImageDimensions, isDefaultCrop, isDefaultHotspot, isImageSource, isFileSource, tryGetImageDimensions, isSanityImageUrl, parseImageAssetUrl, isAssetObjectStub, isImageAssetId, isFileAssetId } from "@sanity/asset-utils";
62
62
  import { createImageUrlBuilder } from "@sanity/image-url";
63
63
  import uniq from "lodash-es/uniq.js";
64
64
  import xor from "lodash-es/xor.js";
@@ -92,6 +92,7 @@ import { differenceInSeconds } from "date-fns/differenceInSeconds";
92
92
  import { differenceInWeeks } from "date-fns/differenceInWeeks";
93
93
  import { differenceInYears } from "date-fns/differenceInYears";
94
94
  import { mergeMapArray } from "rxjs-mergemap-array";
95
+ import { useDevicePixelRatio, getDevicePixelRatio } from "use-device-pixel-ratio";
95
96
  import { useSyncExternalStore as useSyncExternalStore$1 } from "use-sync-external-store/shim/index.js";
96
97
  import DataLoader from "dataloader";
97
98
  import { createNode } from "@sanity/comlink";
@@ -103,7 +104,6 @@ import partition from "lodash-es/partition.js";
103
104
  import { diffInput, wrap as wrap$1 } from "@sanity/diff";
104
105
  import { applyPatch as applyPatch$1, incremental } from "mendoza";
105
106
  import pick from "lodash-es/pick.js";
106
- import { useDevicePixelRatio, getDevicePixelRatio } from "use-device-pixel-ratio";
107
107
  import classNames from "classnames";
108
108
  import debounce from "lodash-es/debounce.js";
109
109
  import sortBy from "lodash-es/sortBy.js";
@@ -45398,6 +45398,75 @@ function Preview$1(props2) {
45398
45398
  let t0;
45399
45399
  return $[0] !== PreviewComponent || $[1] !== props2 ? (t0 = /* @__PURE__ */ jsx(PreviewLoader, { ...props2, component: PreviewComponent }), $[0] = PreviewComponent, $[1] = props2, $[2] = t0) : t0 = $[2], t0;
45400
45400
  }
45401
+ const PREVIEW_SIZES = {
45402
+ block: {
45403
+ icon: 25,
45404
+ media: {
45405
+ width: 33,
45406
+ height: 33
45407
+ }
45408
+ },
45409
+ blockImage: {
45410
+ icon: 25,
45411
+ media: {
45412
+ width: 600,
45413
+ height: 400
45414
+ }
45415
+ },
45416
+ compact: {
45417
+ icon: 21,
45418
+ media: {
45419
+ width: 25,
45420
+ height: 25
45421
+ }
45422
+ },
45423
+ default: {
45424
+ icon: 21,
45425
+ media: {
45426
+ width: 33,
45427
+ height: 33
45428
+ }
45429
+ },
45430
+ detail: {
45431
+ icon: 25,
45432
+ media: {
45433
+ width: 73,
45434
+ height: 73
45435
+ }
45436
+ },
45437
+ inline: {
45438
+ icon: 15,
45439
+ media: {
45440
+ width: 15,
45441
+ height: 15
45442
+ }
45443
+ },
45444
+ media: {
45445
+ icon: 25,
45446
+ media: {
45447
+ width: 160,
45448
+ height: 160
45449
+ }
45450
+ }
45451
+ };
45452
+ function renderPreviewMedia(value, layout, dimensions) {
45453
+ return isValidElementType(value) ? /* @__PURE__ */ jsx(value, { layout, dimensions }) : typeof value == "string" ? /* @__PURE__ */ jsx("div", { children: value }) : isValidElement(value) || value === null || typeof value == "number" || typeof value == "boolean" ? value : null;
45454
+ }
45455
+ function renderPreviewNode(value, layout, fallbackNode) {
45456
+ return typeof value == "string" ? value : isValidElementType(value) ? /* @__PURE__ */ jsx(value, { layout }) : value || fallbackNode;
45457
+ }
45458
+ function resolveBlockImageDimensions(source) {
45459
+ const sourceDimensions = tryGetImageDimensions(source);
45460
+ if (typeof sourceDimensions > "u")
45461
+ return;
45462
+ const max2 = PREVIEW_SIZES.blockImage.media, scale = Math.min(max2.width / sourceDimensions.width, 1);
45463
+ return {
45464
+ width: Math.round(sourceDimensions.width * scale),
45465
+ height: Math.round(sourceDimensions.height * scale),
45466
+ fit: "max",
45467
+ dpr: getDevicePixelRatio()
45468
+ };
45469
+ }
45401
45470
  const _previewComponents = {
45402
45471
  block: BlockPreview,
45403
45472
  blockImage: BlockImagePreview,
@@ -45475,7 +45544,7 @@ function SanityDefaultMedia(t0) {
45475
45544
  return $[14] !== t5 || $[15] !== url ? (t6 = /* @__PURE__ */ jsx("img", { alt: t5, onError: handleError, referrerPolicy: "strict-origin-when-cross-origin", src: url }), $[14] = t5, $[15] = url, $[16] = t6) : t6 = $[16], t6;
45476
45545
  }
45477
45546
  const SanityDefaultPreview = memo(function(props2) {
45478
- const $ = c(34);
45547
+ const $ = c(37);
45479
45548
  let Icon2, imageUrl, layout, mediaProp, restProps, title, tooltip;
45480
45549
  $[0] !== props2 ? ({
45481
45550
  icon: Icon2,
@@ -45535,25 +45604,44 @@ const SanityDefaultPreview = memo(function(props2) {
45535
45604
  }
45536
45605
  t3 = renderIcon;
45537
45606
  }
45538
- const t4 = t3;
45607
+ const media = t3;
45608
+ let t4;
45609
+ bb1: {
45610
+ if (props2.mediaDimensions) {
45611
+ t4 = props2.mediaDimensions;
45612
+ break bb1;
45613
+ }
45614
+ if (layout !== "blockImage") {
45615
+ t4 = void 0;
45616
+ break bb1;
45617
+ }
45618
+ if (!isImageSource(mediaProp)) {
45619
+ t4 = void 0;
45620
+ break bb1;
45621
+ }
45622
+ let t52;
45623
+ $[20] !== mediaProp ? (t52 = resolveBlockImageDimensions(mediaProp), $[20] = mediaProp, $[21] = t52) : t52 = $[21], t4 = t52;
45624
+ }
45625
+ const resolvedMediaDimensions = t4;
45539
45626
  let t5;
45540
- $[20] !== restProps || $[21] !== t4 || $[22] !== title ? (t5 = {
45627
+ $[22] !== media || $[23] !== resolvedMediaDimensions || $[24] !== restProps || $[25] !== title ? (t5 = {
45541
45628
  ...restProps,
45542
- media: t4,
45629
+ media,
45630
+ mediaDimensions: resolvedMediaDimensions,
45543
45631
  title
45544
- }, $[20] = restProps, $[21] = t4, $[22] = title, $[23] = t5) : t5 = $[23];
45632
+ }, $[22] = media, $[23] = resolvedMediaDimensions, $[24] = restProps, $[25] = title, $[26] = t5) : t5 = $[26];
45545
45633
  const previewProps = t5, LayoutComponent = _previewComponents[layout || "default"];
45546
45634
  let t6;
45547
- $[24] !== LayoutComponent || $[25] !== previewProps ? (t6 = /* @__PURE__ */ jsx(LayoutComponent, { ...previewProps }), $[24] = LayoutComponent, $[25] = previewProps, $[26] = t6) : t6 = $[26];
45635
+ $[27] !== LayoutComponent || $[28] !== previewProps ? (t6 = /* @__PURE__ */ jsx(LayoutComponent, { ...previewProps }), $[27] = LayoutComponent, $[28] = previewProps, $[29] = t6) : t6 = $[29];
45548
45636
  const children = t6;
45549
45637
  if (tooltip) {
45550
45638
  const t7 = !tooltip;
45551
45639
  let t8;
45552
- $[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = ["top-end", "bottom-end"], $[27] = t8) : t8 = $[27];
45640
+ $[30] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = ["top-end", "bottom-end"], $[30] = t8) : t8 = $[30];
45553
45641
  let t9;
45554
- $[28] !== children ? (t9 = /* @__PURE__ */ jsx("div", { children }), $[28] = children, $[29] = t9) : t9 = $[29];
45642
+ $[31] !== children ? (t9 = /* @__PURE__ */ jsx("div", { children }), $[31] = children, $[32] = t9) : t9 = $[32];
45555
45643
  let t10;
45556
- return $[30] !== t7 || $[31] !== t9 || $[32] !== tooltip ? (t10 = /* @__PURE__ */ jsx(Tooltip, { content: tooltip, disabled: t7, fallbackPlacements: t8, placement: "right", children: t9 }), $[30] = t7, $[31] = t9, $[32] = tooltip, $[33] = t10) : t10 = $[33], t10;
45644
+ return $[33] !== t7 || $[34] !== t9 || $[35] !== tooltip ? (t10 = /* @__PURE__ */ jsx(Tooltip, { content: tooltip, disabled: t7, fallbackPlacements: t8, placement: "right", children: t9 }), $[33] = t7, $[34] = t9, $[35] = tooltip, $[36] = t10) : t10 = $[36], t10;
45557
45645
  }
45558
45646
  return children;
45559
45647
  });
@@ -57268,56 +57356,6 @@ const ReleaseDocumentsCounter = (t0) => {
57268
57356
  } = t0, t1 = documentCount || "-";
57269
57357
  let t2;
57270
57358
  return $[0] !== t1 ? (t2 = /* @__PURE__ */ jsx(Text$1, { muted: !0, size: 1, children: t1 }), $[0] = t1, $[1] = t2) : t2 = $[1], t2;
57271
- }, PREVIEW_SIZES = {
57272
- block: {
57273
- icon: 25,
57274
- media: {
57275
- width: 33,
57276
- height: 33
57277
- }
57278
- },
57279
- blockImage: {
57280
- icon: 25,
57281
- media: {
57282
- width: 600,
57283
- height: 400
57284
- }
57285
- },
57286
- compact: {
57287
- icon: 21,
57288
- media: {
57289
- width: 25,
57290
- height: 25
57291
- }
57292
- },
57293
- default: {
57294
- icon: 21,
57295
- media: {
57296
- width: 33,
57297
- height: 33
57298
- }
57299
- },
57300
- detail: {
57301
- icon: 25,
57302
- media: {
57303
- width: 73,
57304
- height: 73
57305
- }
57306
- },
57307
- inline: {
57308
- icon: 15,
57309
- media: {
57310
- width: 15,
57311
- height: 15
57312
- }
57313
- },
57314
- media: {
57315
- icon: 25,
57316
- media: {
57317
- width: 160,
57318
- height: 160
57319
- }
57320
- }
57321
57359
  }, RootFlex$2 = styled(Flex).attrs({
57322
57360
  align: "center"
57323
57361
  }).withConfig({
@@ -93641,12 +93679,6 @@ function renderMedia(props2) {
93641
93679
  } = props2;
93642
93680
  return typeof media == "string" ? /* @__PURE__ */ jsx(Text$1, { as: "span", className: styles?.mediaString, size: 1, children: media }) : isValidElementType(media) ? /* @__PURE__ */ jsx(media, { dimensions, layout }) : isValidElement(media) ? media : null;
93643
93681
  }
93644
- function renderPreviewMedia(value, layout, dimensions) {
93645
- return isValidElementType(value) ? /* @__PURE__ */ jsx(value, { layout, dimensions }) : typeof value == "string" ? /* @__PURE__ */ jsx("div", { children: value }) : value;
93646
- }
93647
- function renderPreviewNode(value, layout, fallbackNode) {
93648
- return typeof value == "string" ? value : isValidElementType(value) ? /* @__PURE__ */ jsx(value, { layout }) : value || fallbackNode;
93649
- }
93650
93682
  const DEFAULT_MEDIA_DIMENSIONS$6 = {
93651
93683
  ...PREVIEW_SIZES.compact.media,
93652
93684
  aspect: 1,