sanity 6.6.0-next.38 → 6.6.0-next.39

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.
@@ -5,7 +5,7 @@ import { useRef, useEffect, forwardRef, useState, useContext, useImperativeHandl
5
5
  import { ReviewChangesContext, CommentsEnabledContext, ReferenceInputOptionsContext, PaneLayoutContext, PaneContext, DocumentPaneContext, DocumentActionsStateContext, StructureToolContext, DocumentPaneInfoContext, PaneRouterContext, ResolvedPanesContext, EventsContext, DocumentChangeContext } from "sanity/_singletons";
6
6
  import { styled, css, keyframes } from "styled-components";
7
7
  import { motion, AnimatePresence } from "motion/react";
8
- import { isPublishedId, isDraftId, getReleaseIdFromReleaseDocumentId, getVersionFromId, useTranslation, useDocumentVersions, useActiveReleases, getPublishedId, useEditState, useWorkspace, isReleaseDocument, getReleaseTone, isReleaseScheduledOrScheduling, ReleaseAvatar, isSystemBundleName, PUBLISHED, LATEST, useFormatRelativeLocalePublishDate, getDraftId, getVersionId, ReleaseTitle, useMiddlewareComponents, ChangeIndicatorsTracker, VirtualizerScrollInstanceProvider, useDocumentForm, LoadingBlock, FormBuilder, isVersionId, createPatchChannel, getDocumentVariantType, LegacyLayerProvider, IsLastPaneProvider, useGetI18nText, useI18nText, TooltipOfDisabled, ContextMenuButton, StatusButton, isDev, CommentsEnabledProvider, useCommentsEnabled, usePerspective, getTargetScopeId, COMMENTS_INSPECTOR_NAME, CommentsProvider, GetHookCollectionState, EMPTY_ARRAY as EMPTY_ARRAY$2, getDocumentIdForCanvasLink, useCanvasCompanionDoc, useUnique, isPublishedPerspective, prepareForPreview, useValuePreview, useDocumentOperationEvent, useDocumentLimitsUpsellContext, isDocumentLimitError, Translate, isNewDocument, Resizable, useKeyValueStore, isRecord, isString, isDraftPerspective, useDocumentOperation, isDeprecatedSchemaType, useProjectId, useClient, useZIndex, useCurrentUser, useListFormat, useDocumentPreviewStore, isSystemBundle, useScheduledDraftDocument, useArchivedReleases, isCardinalityOneRelease, getVersionInlineBadge, useNavigateToCanvasDoc, isPerspectiveWriteable, ReleasesNav, useVersionOperations, useConditionalToast, isAgentBundleName, useVariantDocumentOperations, useGetDefaultPerspective, getVariantTitle, useOnlyHasVersions, useSetPerspective, VersionInlineBadge, isGoingToUnpublish, useDocumentStore, useDocumentPresence, FormRow, FormContainer, PresenceOverlay, fromMutationPatches, useDocumentPreviewValues, useManageFavorite, useActiveWorkspace, CapabilityGate, useFilteredReleases, usePausedScheduledDraft, isPausedCardinalityOneRelease, ScrollContainer, getPairTarget, useStudioUrl, ReleaseAvatarIcon, useSingleDocRelease, useSchema, useAllVariants, useAgentVersionDisplay, useSetVariant, getTargetDocument, VersionChip, Chip, useDateTimeFormat, useFieldActions, FieldPresenceInner, useDocumentVersionInfo, getPreviewStateObservable, DocumentPreviewPresence, DocumentStatusIndicator, DocumentStatus, getPreviewValueWithFallback, SanityDefaultPreview, PreviewCard, DEFAULT_STUDIO_CLIENT_OPTIONS, useDocumentVersionTypeSortedList, useDocumentPairPermissions, InsufficientPermissionsMessage, useValidationStatus, useSyncState, useRelativeTime, useSource, Hotkeys, isSanityDefinedAction, DocumentGroupInventoryAction, DocumentGroupInventory, UserAvatar, useUser, AvatarSkeleton, CommandList, TextWithTone, useTimelineSelector, useEvents, TIMELINE_ITEM_I18N_KEY_MAPPING as TIMELINE_ITEM_I18N_KEY_MAPPING$1, useGlobalCopyPasteElementHandler, useDocumentIdStack, FieldActionsResolver, GetFormValueProvider, FieldActionsProvider, ChangeConnectorRoot, useTemplates, useInitialValue, useCopyPaste, useTargetDocumentState, DivergencesProvider, selectUpstreamVersion, pathToString, ParseErrorsProvider, useDocumentDivergences, useEventsStore, PerspectiveProvider, EventsProvider, useTimelineStore, SingleDocReleaseProvider, CopyPasteProvider, SourceProvider, useDocumentType, useTemplatePermissions, ReferenceInputOptionsProvider, EMPTY_OBJECT, CrossDatasetReferencePreview, getPreviewPaths, isNonNullable as isNonNullable$1, getReferencePaths, ErrorActions, collate, getSearchableTypes, compileFieldPath, createSearch, createSWR, useSearchMaxFieldDepth, measureFirstMatch, catchWithCount, useReconnectingToast, ChangeFieldWrapper, NoChanges, ChangeList, isDeleteDocumentVersionEvent, isDeleteDocumentGroupEvent, isUnpublishDocumentEvent, isScheduleDocumentVersionEvent, isUnscheduleDocumentVersionEvent, Event, RELEASES_INTENT, isCreateDocumentVersionEvent, isEditDocumentVersionEvent, isPublishDocumentVersionEvent, ChangesError, isArray, useParseErrors, mergeParseErrors, isValidationError, isValidationWarning, definePlugin } from "sanity";
8
+ import { isPublishedId, isDraftId, getReleaseIdFromReleaseDocumentId, getVersionFromId, useTranslation, useDocumentVersions, useActiveReleases, getPublishedId, useEditState, useWorkspace, isReleaseDocument, getReleaseTone, isReleaseScheduledOrScheduling, ReleaseAvatar, isSystemBundleName, PUBLISHED, LATEST, useFormatRelativeLocalePublishDate, getDraftId, getVersionId, ReleaseTitle, useMiddlewareComponents, ChangeIndicatorsTracker, VirtualizerScrollInstanceProvider, useDocumentForm, LoadingBlock, FormBuilder, isVersionId, createPatchChannel, getDocumentVariantType, LegacyLayerProvider, IsLastPaneProvider, useGetI18nText, useI18nText, TooltipOfDisabled, ContextMenuButton, StatusButton, isDev, CommentsEnabledProvider, useCommentsEnabled, usePerspective, getTargetScopeId, COMMENTS_INSPECTOR_NAME, CommentsProvider, GetHookCollectionState, EMPTY_ARRAY as EMPTY_ARRAY$2, getDocumentIdForCanvasLink, useCanvasCompanionDoc, useUnique, isPublishedPerspective, prepareForPreview, useValuePreview, useDocumentOperationEvent, useDocumentLimitsUpsellContext, isDocumentLimitError, Translate, isNewDocument, Resizable, useKeyValueStore, isRecord, isString, isDraftPerspective, useDocumentOperation, isDeprecatedSchemaType, useProjectId, useClient, useZIndex, useCurrentUser, useListFormat, useDocumentPreviewStore, isSystemBundle, useScheduledDraftDocument, useArchivedReleases, isCardinalityOneRelease, getVersionInlineBadge, useNavigateToCanvasDoc, isPerspectiveWriteable, ReleasesNav, useVersionOperations, useConditionalToast, isAgentBundleName, useVariantDocumentOperations, useGetDefaultPerspective, getVariantTitle, useOnlyHasVersions, useSetPerspective, VersionInlineBadge, isGoingToUnpublish, useDocumentStore, useDocumentPresence, FormRow, FormContainer, PresenceOverlay, fromMutationPatches, useDocumentPreviewValues, useManageFavorite, useActiveWorkspace, CapabilityGate, useFilteredReleases, usePausedScheduledDraft, isPausedCardinalityOneRelease, ScrollContainer, getPairTarget, useTargetDocumentState, useStudioUrl, ReleaseAvatarIcon, useSingleDocRelease, useSchema, useAllVariants, useAgentVersionDisplay, useSetVariant, getTargetDocument, VersionChip, Chip, useDateTimeFormat, useFieldActions, FieldPresenceInner, useDocumentVersionInfo, getPreviewStateObservable, DocumentPreviewPresence, DocumentStatusIndicator, DocumentStatus, getPreviewValueWithFallback, SanityDefaultPreview, PreviewCard, DEFAULT_STUDIO_CLIENT_OPTIONS, useDocumentVersionTypeSortedList, useDocumentPairPermissions, InsufficientPermissionsMessage, useValidationStatus, useSyncState, useRelativeTime, useSource, Hotkeys, isSanityDefinedAction, DocumentGroupInventoryAction, DocumentGroupInventory, UserAvatar, useUser, AvatarSkeleton, CommandList, TextWithTone, useTimelineSelector, useEvents, TIMELINE_ITEM_I18N_KEY_MAPPING as TIMELINE_ITEM_I18N_KEY_MAPPING$1, useGlobalCopyPasteElementHandler, useDocumentIdStack, FieldActionsResolver, GetFormValueProvider, FieldActionsProvider, ChangeConnectorRoot, useTemplates, useInitialValue, useCopyPaste, DivergencesProvider, selectUpstreamVersion, pathToString, ParseErrorsProvider, useDocumentDivergences, useEventsStore, PerspectiveProvider, EventsProvider, useTimelineStore, SingleDocReleaseProvider, CopyPasteProvider, SourceProvider, useDocumentType, useTemplatePermissions, ReferenceInputOptionsProvider, EMPTY_OBJECT, CrossDatasetReferencePreview, getPreviewPaths, isNonNullable as isNonNullable$1, getReferencePaths, ErrorActions, collate, getSearchableTypes, compileFieldPath, createSearch, createSWR, useSearchMaxFieldDepth, measureFirstMatch, catchWithCount, useReconnectingToast, ChangeFieldWrapper, NoChanges, ChangeList, isDeleteDocumentVersionEvent, isDeleteDocumentGroupEvent, isUnpublishDocumentEvent, isScheduleDocumentVersionEvent, isUnscheduleDocumentVersionEvent, Event, RELEASES_INTENT, isCreateDocumentVersionEvent, isEditDocumentVersionEvent, isPublishDocumentVersionEvent, ChangesError, isArray, useParseErrors, mergeParseErrors, isValidationError, isValidationWarning, definePlugin } from "sanity";
9
9
  import { structureLocaleNamespace, structureUsEnglishLocaleBundle } from "./StructureToolProvider.js";
10
10
  import { MenuButton, Dialog, MenuItem as MenuItem$1, Button as Button$1, Tab, Popover, Tooltip, TooltipDelayGroupProvider, ErrorBoundary } from "./index.js";
11
11
  import isEqual from "lodash-es/isEqual.js";
@@ -4992,11 +4992,21 @@ const DocumentInitialLoadMeasured = defineEvent({
4992
4992
  description: "User switched off display of inline changes"
4993
4993
  });
4994
4994
  function CopyDocumentActions() {
4995
- const $ = c(41), {
4995
+ const $ = c(43), {
4996
4996
  documentId,
4997
4997
  documentType,
4998
4998
  schemaType
4999
4999
  } = useDocumentPaneInfo(), {
5000
+ editState
5001
+ } = useDocumentPane(), targetDocumentState = useTargetDocumentState(documentId);
5002
+ let t0;
5003
+ $[0] !== documentId ? (t0 = {
5004
+ documentId
5005
+ }, $[0] = documentId, $[1] = t0) : t0 = $[1];
5006
+ const {
5007
+ data: existingDocumentIds,
5008
+ loading: documentVersionsLoading
5009
+ } = useDocumentVersions(t0), {
5000
5010
  selectedReleaseId,
5001
5011
  selectedPerspectiveName
5002
5012
  } = usePerspective(), {
@@ -5011,24 +5021,24 @@ function CopyDocumentActions() {
5011
5021
  push: pushToast
5012
5022
  } = useToast(), scheduledDraft = params?.scheduledDraft;
5013
5023
  schemaType?.liveEdit;
5014
- let t0;
5024
+ let t1;
5015
5025
  bb0: {
5016
5026
  const versionReleaseId = scheduledDraft || selectedReleaseId;
5017
5027
  if (versionReleaseId) {
5018
- let t13;
5019
- $[0] !== documentId || $[1] !== versionReleaseId ? (t13 = getVersionId(documentId, versionReleaseId), $[0] = documentId, $[1] = versionReleaseId, $[2] = t13) : t13 = $[2], t0 = t13;
5028
+ let t23;
5029
+ $[2] !== documentId || $[3] !== versionReleaseId ? (t23 = getVersionId(documentId, versionReleaseId), $[2] = documentId, $[3] = versionReleaseId, $[4] = t23) : t23 = $[4], t1 = t23;
5020
5030
  break bb0;
5021
5031
  }
5022
5032
  if (selectedPerspectiveName === "published" || schemaType?.liveEdit) {
5023
- t0 = documentId;
5033
+ t1 = documentId;
5024
5034
  break bb0;
5025
5035
  }
5026
- let t12;
5027
- $[3] !== documentId ? (t12 = getDraftId(documentId), $[3] = documentId, $[4] = t12) : t12 = $[4], t0 = t12;
5036
+ let t22;
5037
+ $[5] !== documentId ? (t22 = getDraftId(documentId), $[5] = documentId, $[6] = t22) : t22 = $[6], t1 = t22;
5028
5038
  }
5029
- const contextAwareDocumentId = t0;
5030
- let t1;
5031
- $[5] !== buildIntentUrl || $[6] !== documentId || $[7] !== documentType || $[8] !== pushToast || $[9] !== resolveIntentLink || $[10] !== scheduledDraft || $[11] !== selectedReleaseId || $[12] !== t || $[13] !== telemetry ? (t1 = async () => {
5039
+ const contextAwareDocumentId = t1, selectedVariantMissing = targetDocumentState.status === "variant-missing" || targetDocumentState.status === "variant-definition-document-not-found", copiedVersionMissing = !!editState?.ready && !documentVersionsLoading && isVersionId(contextAwareDocumentId) && !isNewDocument(editState) && !existingDocumentIds.includes(contextAwareDocumentId), documentExists = !selectedVariantMissing && !copiedVersionMissing;
5040
+ let t2;
5041
+ $[7] !== buildIntentUrl || $[8] !== documentId || $[9] !== documentType || $[10] !== pushToast || $[11] !== resolveIntentLink || $[12] !== scheduledDraft || $[13] !== selectedReleaseId || $[14] !== t || $[15] !== telemetry ? (t2 = async () => {
5032
5042
  telemetry.log(DocumentURLCopied);
5033
5043
  const searchParams = selectedReleaseId && !scheduledDraft ? [["perspective", selectedReleaseId]] : [], intentParams = {
5034
5044
  id: documentId,
@@ -5042,43 +5052,45 @@ function CopyDocumentActions() {
5042
5052
  status: "info",
5043
5053
  title: t("panes.document-operation-results.operation-success_copy-url")
5044
5054
  });
5045
- }, $[5] = buildIntentUrl, $[6] = documentId, $[7] = documentType, $[8] = pushToast, $[9] = resolveIntentLink, $[10] = scheduledDraft, $[11] = selectedReleaseId, $[12] = t, $[13] = telemetry, $[14] = t1) : t1 = $[14];
5046
- const handleCopyLink = t1;
5047
- let t2;
5048
- $[15] !== contextAwareDocumentId || $[16] !== pushToast || $[17] !== t || $[18] !== telemetry ? (t2 = async () => {
5055
+ }, $[7] = buildIntentUrl, $[8] = documentId, $[9] = documentType, $[10] = pushToast, $[11] = resolveIntentLink, $[12] = scheduledDraft, $[13] = selectedReleaseId, $[14] = t, $[15] = telemetry, $[16] = t2) : t2 = $[16];
5056
+ const handleCopyLink = t2;
5057
+ let t3;
5058
+ $[17] !== contextAwareDocumentId || $[18] !== pushToast || $[19] !== t || $[20] !== telemetry ? (t3 = async () => {
5049
5059
  telemetry.log(DocumentIDCopied), await navigator.clipboard.writeText(contextAwareDocumentId), pushToast({
5050
5060
  id: "copy-document-id",
5051
5061
  status: "info",
5052
5062
  title: t("panes.document-operation-results.operation-success_copy-id")
5053
5063
  });
5054
- }, $[15] = contextAwareDocumentId, $[16] = pushToast, $[17] = t, $[18] = telemetry, $[19] = t2) : t2 = $[19];
5055
- const handleCopyId = t2;
5056
- let t3;
5057
- $[20] !== t ? (t3 = t("action.copy-document-url.label"), $[20] = t, $[21] = t3) : t3 = $[21];
5064
+ }, $[17] = contextAwareDocumentId, $[18] = pushToast, $[19] = t, $[20] = telemetry, $[21] = t3) : t3 = $[21];
5065
+ const handleCopyId = t3;
5066
+ if (!documentExists)
5067
+ return null;
5058
5068
  let t4;
5059
- $[22] !== t3 ? (t4 = /* @__PURE__ */ jsx(Button$1, { icon: ShareIcon, mode: "bleed", tooltipProps: {
5060
- content: t3
5061
- }, "data-testid": "copy-document-actions-button" }), $[22] = t3, $[23] = t4) : t4 = $[23];
5069
+ $[22] !== t ? (t4 = t("action.copy-document-url.label"), $[22] = t, $[23] = t4) : t4 = $[23];
5062
5070
  let t5;
5063
- $[24] !== t ? (t5 = t("action.copy-link-to-document.label"), $[24] = t, $[25] = t5) : t5 = $[25];
5071
+ $[24] !== t4 ? (t5 = /* @__PURE__ */ jsx(Button$1, { icon: ShareIcon, mode: "bleed", tooltipProps: {
5072
+ content: t4
5073
+ }, "data-testid": "copy-document-actions-button" }), $[24] = t4, $[25] = t5) : t5 = $[25];
5064
5074
  let t6;
5065
- $[26] !== handleCopyLink || $[27] !== t5 ? (t6 = /* @__PURE__ */ jsx(MenuItem$1, { icon: LinkIcon, onClick: handleCopyLink, text: t5, "data-testid": "copy-link-to-document" }), $[26] = handleCopyLink, $[27] = t5, $[28] = t6) : t6 = $[28];
5075
+ $[26] !== t ? (t6 = t("action.copy-link-to-document.label"), $[26] = t, $[27] = t6) : t6 = $[27];
5066
5076
  let t7;
5067
- $[29] !== t ? (t7 = t("action.copy-document-id.label"), $[29] = t, $[30] = t7) : t7 = $[30];
5077
+ $[28] !== handleCopyLink || $[29] !== t6 ? (t7 = /* @__PURE__ */ jsx(MenuItem$1, { icon: LinkIcon, onClick: handleCopyLink, text: t6, "data-testid": "copy-link-to-document" }), $[28] = handleCopyLink, $[29] = t6, $[30] = t7) : t7 = $[30];
5068
5078
  let t8;
5069
- $[31] !== handleCopyId || $[32] !== t7 ? (t8 = /* @__PURE__ */ jsx(MenuItem$1, { icon: TargetIcon, onClick: handleCopyId, text: t7, "data-testid": "copy-document-id" }), $[31] = handleCopyId, $[32] = t7, $[33] = t8) : t8 = $[33];
5079
+ $[31] !== t ? (t8 = t("action.copy-document-id.label"), $[31] = t, $[32] = t8) : t8 = $[32];
5070
5080
  let t9;
5071
- $[34] !== t6 || $[35] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Menu, { children: [
5072
- t6,
5073
- t8
5074
- ] }), $[34] = t6, $[35] = t8, $[36] = t9) : t9 = $[36];
5081
+ $[33] !== handleCopyId || $[34] !== t8 ? (t9 = /* @__PURE__ */ jsx(MenuItem$1, { icon: TargetIcon, onClick: handleCopyId, text: t8, "data-testid": "copy-document-id" }), $[33] = handleCopyId, $[34] = t8, $[35] = t9) : t9 = $[35];
5075
5082
  let t10;
5076
- $[37] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = {
5083
+ $[36] !== t7 || $[37] !== t9 ? (t10 = /* @__PURE__ */ jsxs(Menu, { children: [
5084
+ t7,
5085
+ t9
5086
+ ] }), $[36] = t7, $[37] = t9, $[38] = t10) : t10 = $[38];
5087
+ let t11;
5088
+ $[39] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t11 = {
5077
5089
  portal: !0,
5078
5090
  placement: "bottom-end"
5079
- }, $[37] = t10) : t10 = $[37];
5080
- let t11;
5081
- return $[38] !== t4 || $[39] !== t9 ? (t11 = /* @__PURE__ */ jsx(MenuButton, { id: "copy-document-actions", button: t4, menu: t9, popover: t10 }), $[38] = t4, $[39] = t9, $[40] = t11) : t11 = $[40], t11;
5091
+ }, $[39] = t11) : t11 = $[39];
5092
+ let t12;
5093
+ return $[40] !== t10 || $[41] !== t5 ? (t12 = /* @__PURE__ */ jsx(MenuButton, { id: "copy-document-actions", button: t5, menu: t10, popover: t11 }), $[40] = t10, $[41] = t5, $[42] = t12) : t12 = $[42], t12;
5082
5094
  }
5083
5095
  const DocumentGroupInventoryHintPressed = defineEvent({
5084
5096
  version: 1,