@depup/sanity 5.17.1-depup.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.
- package/LICENSE +21 -0
- package/README.md +57 -0
- package/bin/sanity +209 -0
- package/changes.json +114 -0
- package/lib/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +16164 -0
- package/lib/_chunks-dts/index.d.ts +780 -0
- package/lib/_chunks-dts/types.d.ts +2765 -0
- package/lib/_chunks-dts/types2.d.ts +656 -0
- package/lib/_chunks-dts/types3.d.ts +303 -0
- package/lib/_chunks-es/BroadcastDisplayedDocument.js +20 -0
- package/lib/_chunks-es/BroadcastDisplayedDocument.js.map +1 -0
- package/lib/_chunks-es/DisplayedDocumentBroadcaster.js +32 -0
- package/lib/_chunks-es/DisplayedDocumentBroadcaster.js.map +1 -0
- package/lib/_chunks-es/LiveQueries.js +339 -0
- package/lib/_chunks-es/LiveQueries.js.map +1 -0
- package/lib/_chunks-es/MenuGroup.js +106 -0
- package/lib/_chunks-es/MenuGroup.js.map +1 -0
- package/lib/_chunks-es/PostMessageDocuments.js +72 -0
- package/lib/_chunks-es/PostMessageDocuments.js.map +1 -0
- package/lib/_chunks-es/PostMessagePerspective.js +23 -0
- package/lib/_chunks-es/PostMessagePerspective.js.map +1 -0
- package/lib/_chunks-es/PostMessagePreviewSnapshots.js +69 -0
- package/lib/_chunks-es/PostMessagePreviewSnapshots.js.map +1 -0
- package/lib/_chunks-es/PostMessageRefreshMutations.js +74 -0
- package/lib/_chunks-es/PostMessageRefreshMutations.js.map +1 -0
- package/lib/_chunks-es/PostMessageSchema.js +502 -0
- package/lib/_chunks-es/PostMessageSchema.js.map +1 -0
- package/lib/_chunks-es/PostMessageTelemetry.js +21 -0
- package/lib/_chunks-es/PostMessageTelemetry.js.map +1 -0
- package/lib/_chunks-es/PresentationToolGrantsCheck.js +3848 -0
- package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -0
- package/lib/_chunks-es/QRCodeSVG.js +692 -0
- package/lib/_chunks-es/QRCodeSVG.js.map +1 -0
- package/lib/_chunks-es/StructureToolProvider.js +2360 -0
- package/lib/_chunks-es/StructureToolProvider.js.map +1 -0
- package/lib/_chunks-es/VideoPlayer.js +22 -0
- package/lib/_chunks-es/VideoPlayer.js.map +1 -0
- package/lib/_chunks-es/ViteDevServerStopped.js +52 -0
- package/lib/_chunks-es/ViteDevServerStopped.js.map +1 -0
- package/lib/_chunks-es/index.js +285 -0
- package/lib/_chunks-es/index.js.map +1 -0
- package/lib/_chunks-es/index2.js +105 -0
- package/lib/_chunks-es/index2.js.map +1 -0
- package/lib/_chunks-es/index3.js +139 -0
- package/lib/_chunks-es/index3.js.map +1 -0
- package/lib/_chunks-es/index4.js +1020 -0
- package/lib/_chunks-es/index4.js.map +1 -0
- package/lib/_chunks-es/pane.js +5 -0
- package/lib/_chunks-es/pane.js.map +1 -0
- package/lib/_chunks-es/pane2.js +5 -0
- package/lib/_chunks-es/pane2.js.map +1 -0
- package/lib/_chunks-es/presentation.js +549 -0
- package/lib/_chunks-es/presentation.js.map +1 -0
- package/lib/_chunks-es/resources.js +303 -0
- package/lib/_chunks-es/resources.js.map +1 -0
- package/lib/_chunks-es/resources2.js +459 -0
- package/lib/_chunks-es/resources2.js.map +1 -0
- package/lib/_chunks-es/resources3.js +281 -0
- package/lib/_chunks-es/resources3.js.map +1 -0
- package/lib/_chunks-es/resources4.js +184 -0
- package/lib/_chunks-es/resources4.js.map +1 -0
- package/lib/_chunks-es/resources5.js +161 -0
- package/lib/_chunks-es/resources5.js.map +1 -0
- package/lib/_chunks-es/resources6.js +141 -0
- package/lib/_chunks-es/resources6.js.map +1 -0
- package/lib/_chunks-es/resources7.js +24 -0
- package/lib/_chunks-es/resources7.js.map +1 -0
- package/lib/_chunks-es/resources8.js +603 -0
- package/lib/_chunks-es/resources8.js.map +1 -0
- package/lib/_chunks-es/resources9.js +126 -0
- package/lib/_chunks-es/resources9.js.map +1 -0
- package/lib/_chunks-es/structureTool.js +13673 -0
- package/lib/_chunks-es/structureTool.js.map +1 -0
- package/lib/_chunks-es/version.js +17 -0
- package/lib/_chunks-es/version.js.map +1 -0
- package/lib/_createContext.d.ts +12 -0
- package/lib/_createContext.js +38 -0
- package/lib/_createContext.js.map +1 -0
- package/lib/_internal.d.ts +9 -0
- package/lib/_internal.js +12 -0
- package/lib/_internal.js.map +1 -0
- package/lib/_singletons.d.ts +951 -0
- package/lib/_singletons.js +284 -0
- package/lib/_singletons.js.map +1 -0
- package/lib/cli.d.ts +3 -0
- package/lib/cli.js +9 -0
- package/lib/cli.js.map +1 -0
- package/lib/desk.d.ts +910 -0
- package/lib/desk.js +71 -0
- package/lib/desk.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +92934 -0
- package/lib/index.js.map +1 -0
- package/lib/media-library.d.ts +85 -0
- package/lib/media-library.js +11 -0
- package/lib/media-library.js.map +1 -0
- package/lib/migrate.d.ts +1 -0
- package/lib/migrate.js +2 -0
- package/lib/migrate.js.map +1 -0
- package/lib/presentation.d.ts +28 -0
- package/lib/presentation.js +10 -0
- package/lib/presentation.js.map +1 -0
- package/lib/router.d.ts +560 -0
- package/lib/router.js +777 -0
- package/lib/router.js.map +1 -0
- package/lib/structure.d.ts +3 -0
- package/lib/structure.js +639 -0
- package/lib/structure.js.map +1 -0
- package/mock-browser-env-stub-loader.mjs +27 -0
- package/package.json +383 -0
- package/static/favicons/apple-touch-icon.png +0 -0
- package/static/favicons/favicon-192.png +0 -0
- package/static/favicons/favicon-512.png +0 -0
- package/static/favicons/favicon-96.png +0 -0
- package/static/favicons/favicon.ico +0 -0
- package/static/favicons/favicon.svg +12 -0
package/lib/structure.js
ADDED
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import { getCrossDatasetIncomingReferences, INITIAL_STATE, IncomingReferencesListContainer, INCOMING_REFERENCES_ITEM_HEIGHT, CrossDatasetIncomingReferenceDocumentPreview, usePaneRouter, useDocumentPane, getIncomingReferences, IncomingReferenceDocument } from "./_chunks-es/structureTool.js";
|
|
2
|
+
import { ConfirmDeleteDialogContainer, DocumentInspectorHeader, PaneContainer, DocumentPane, DocumentPaneProviderWrapper, Pane, PaneContent, PaneLayout, structureTool, useDocumentTitle, usePaneOptions, useStructureTool } from "./_chunks-es/structureTool.js";
|
|
3
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { useState, useEffect } from "react";
|
|
6
|
+
import { useClient, DEFAULT_STUDIO_CLIENT_OPTIONS, useDocumentPreviewStore, useSchema, useTranslation, CommandList, LoadingBlock, useReferenceInputOptions, isNonNullable, CreateReferenceButton, getPublishedId, useActiveReleases, getPreviewStateObservable, isDraftId, getReleaseTone, isPublishedId, isVersionId, getVersionFromId, getPreviewValueWithFallback, PreviewCard, getReleaseIdFromReleaseDocumentId, ReleaseTitle, VersionInlineBadge, SanityDefaultPreview, useSource, createSearch, ReferenceAutocomplete, getDraftId } from "sanity";
|
|
7
|
+
import { structureLocaleNamespace } from "./_chunks-es/StructureToolProvider.js";
|
|
8
|
+
import { ComponentBuilder, ComponentViewBuilder, DEFAULT_INTENT_HANDLER, DocumentBuilder, DocumentListBuilder, DocumentListItemBuilder, DocumentTypeListBuilder, FormViewBuilder, GenericListBuilder, GenericViewBuilder, HELP_URL, InitialValueTemplateItemBuilder, ListBuilder, ListItemBuilder, MenuItemBuilder, MenuItemGroupBuilder, SerializeError, StructureToolProvider, component, createStructureBuilder, defaultInitialValueTemplateItems, defaultIntentChecker, documentFromEditor, documentFromEditorWithInitialValue, form, getOrderingMenuItem, getOrderingMenuItemsForSchemaType, getTypeNamesFromFilter, isDocumentListItem, maybeSerializeInitialValueTemplateItem, maybeSerializeMenuItem, maybeSerializeMenuItemGroup, maybeSerializeView, menuItemsFromInitialValueTemplateItems, shallowIntentChecker } from "./_chunks-es/StructureToolProvider.js";
|
|
9
|
+
import { Flex, Text, Stack, Box, Card, useToast, Grid } from "@sanity/ui";
|
|
10
|
+
import { Button } from "./_chunks-es/index.js";
|
|
11
|
+
import "react-i18next";
|
|
12
|
+
import { PaneRouterContext } from "sanity/_singletons";
|
|
13
|
+
import { AddIcon } from "@sanity/icons";
|
|
14
|
+
import { useRouter } from "sanity/router";
|
|
15
|
+
import "@sanity/util/paths";
|
|
16
|
+
import "lodash-es/omit.js";
|
|
17
|
+
import startCase from "lodash-es/startCase.js";
|
|
18
|
+
import { useObservable, useObservableEvent } from "react-rx";
|
|
19
|
+
import { DEFAULT_MAX_FIELD_DEPTH } from "@sanity/schema/_internal";
|
|
20
|
+
import { map, filter, switchMap, concat, of, catchError, scan, tap } from "rxjs";
|
|
21
|
+
import { uuid } from "@sanity/uuid";
|
|
22
|
+
function CrossDatasetIncomingReferenceType(t0) {
|
|
23
|
+
const $ = c(41), {
|
|
24
|
+
type,
|
|
25
|
+
referenced,
|
|
26
|
+
shouldRenderTitle
|
|
27
|
+
} = t0, client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS), documentPreviewStore = useDocumentPreviewStore();
|
|
28
|
+
let t1;
|
|
29
|
+
$[0] !== client || $[1] !== documentPreviewStore || $[2] !== referenced.id || $[3] !== type ? (t1 = getCrossDatasetIncomingReferences({
|
|
30
|
+
documentId: referenced.id,
|
|
31
|
+
client,
|
|
32
|
+
type,
|
|
33
|
+
documentPreviewStore
|
|
34
|
+
}), $[0] = client, $[1] = documentPreviewStore, $[2] = referenced.id, $[3] = type, $[4] = t1) : t1 = $[4];
|
|
35
|
+
const references$ = t1, {
|
|
36
|
+
documents,
|
|
37
|
+
loading
|
|
38
|
+
} = useObservable(references$, INITIAL_STATE), schema = useSchema(), {
|
|
39
|
+
t
|
|
40
|
+
} = useTranslation(structureLocaleNamespace);
|
|
41
|
+
let T0, T1, t10, t2, t3, t4, t5, t6, t7, t8, t9;
|
|
42
|
+
if ($[5] !== documents || $[6] !== loading || $[7] !== schema || $[8] !== shouldRenderTitle || $[9] !== t || $[10] !== type) {
|
|
43
|
+
t10 = /* @__PURE__ */ Symbol.for("react.early_return_sentinel");
|
|
44
|
+
bb0: {
|
|
45
|
+
const schemaType = schema.get(type.type);
|
|
46
|
+
let t112;
|
|
47
|
+
$[22] !== type ? (t112 = (document) => /* @__PURE__ */ jsx(CrossDatasetIncomingReferenceDocumentPreview, { document, type }), $[22] = type, $[23] = t112) : t112 = $[23];
|
|
48
|
+
const renderItem = t112;
|
|
49
|
+
if (!schemaType) {
|
|
50
|
+
t10 = null;
|
|
51
|
+
break bb0;
|
|
52
|
+
}
|
|
53
|
+
if (loading) {
|
|
54
|
+
let t122;
|
|
55
|
+
$[24] !== t ? (t122 = t("incoming-references-input.types-loading"), $[24] = t, $[25] = t122) : t122 = $[25];
|
|
56
|
+
let t13;
|
|
57
|
+
$[26] !== t122 ? (t13 = /* @__PURE__ */ jsx(LoadingBlock, { showText: !0, title: t122 }), $[26] = t122, $[27] = t13) : t13 = $[27], t10 = t13;
|
|
58
|
+
break bb0;
|
|
59
|
+
}
|
|
60
|
+
T1 = Stack, t7 = 2, t8 = 2, t9 = shouldRenderTitle && /* @__PURE__ */ jsx(Box, { paddingY: 2, paddingX: 0, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: type.title || schemaType?.title }) }), T0 = Card, t2 = 2, t3 = 1, t4 = !0, t5 = "default", t6 = documents && documents.length > 0 ? /* @__PURE__ */ jsx(IncomingReferencesListContainer, { $itemCount: documents.length, children: /* @__PURE__ */ jsx(CommandList, { activeItemDataAttr: "data-hovered", ariaLabel: t("incoming-references-input.list-label", {
|
|
61
|
+
type: type.title || schemaType?.title
|
|
62
|
+
}), canReceiveFocus: !0, fixedHeight: !0, getItemKey: (index) => documents[index].id, itemHeight: INCOMING_REFERENCES_ITEM_HEIGHT, items: documents, onlyShowSelectionWhenActive: !0, overscan: 5, renderItem, wrapAround: !1 }) }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", padding: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: t("incoming-references-input.no-items") }) }) });
|
|
63
|
+
}
|
|
64
|
+
$[5] = documents, $[6] = loading, $[7] = schema, $[8] = shouldRenderTitle, $[9] = t, $[10] = type, $[11] = T0, $[12] = T1, $[13] = t10, $[14] = t2, $[15] = t3, $[16] = t4, $[17] = t5, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = t9;
|
|
65
|
+
} else
|
|
66
|
+
T0 = $[11], T1 = $[12], t10 = $[13], t2 = $[14], t3 = $[15], t4 = $[16], t5 = $[17], t6 = $[18], t7 = $[19], t8 = $[20], t9 = $[21];
|
|
67
|
+
if (t10 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel"))
|
|
68
|
+
return t10;
|
|
69
|
+
let t11;
|
|
70
|
+
$[28] !== T0 || $[29] !== t2 || $[30] !== t3 || $[31] !== t4 || $[32] !== t5 || $[33] !== t6 ? (t11 = /* @__PURE__ */ jsx(T0, { radius: t2, padding: t3, border: t4, tone: t5, children: t6 }), $[28] = T0, $[29] = t2, $[30] = t3, $[31] = t4, $[32] = t5, $[33] = t6, $[34] = t11) : t11 = $[34];
|
|
71
|
+
let t12;
|
|
72
|
+
return $[35] !== T1 || $[36] !== t11 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9 ? (t12 = /* @__PURE__ */ jsxs(T1, { space: t7, marginBottom: t8, children: [
|
|
73
|
+
t9,
|
|
74
|
+
t11
|
|
75
|
+
] }), $[35] = T1, $[36] = t11, $[37] = t7, $[38] = t8, $[39] = t9, $[40] = t12) : t12 = $[40], t12;
|
|
76
|
+
}
|
|
77
|
+
function CreateNewIncomingReference(t0) {
|
|
78
|
+
const $ = c(21), {
|
|
79
|
+
type,
|
|
80
|
+
referenceToId,
|
|
81
|
+
referenceToType,
|
|
82
|
+
onCreateNewReference,
|
|
83
|
+
fieldName,
|
|
84
|
+
creationAllowed
|
|
85
|
+
} = t0, {
|
|
86
|
+
initialValueTemplateItems
|
|
87
|
+
} = useReferenceInputOptions(), {
|
|
88
|
+
navigate
|
|
89
|
+
} = useRouter(), {
|
|
90
|
+
routerPanesState,
|
|
91
|
+
groupIndex
|
|
92
|
+
} = usePaneRouter();
|
|
93
|
+
let t1;
|
|
94
|
+
$[0] !== fieldName || $[1] !== groupIndex || $[2] !== navigate || $[3] !== onCreateNewReference || $[4] !== referenceToId || $[5] !== referenceToType || $[6] !== routerPanesState || $[7] !== type ? (t1 = (option) => {
|
|
95
|
+
const id = uuid();
|
|
96
|
+
navigate({
|
|
97
|
+
panes: [...routerPanesState.slice(0, groupIndex + 1), [{
|
|
98
|
+
id: getPublishedId(id),
|
|
99
|
+
params: {
|
|
100
|
+
type,
|
|
101
|
+
template: option.template.id
|
|
102
|
+
},
|
|
103
|
+
payload: {
|
|
104
|
+
reference: {
|
|
105
|
+
_type: "reference",
|
|
106
|
+
_ref: referenceToId,
|
|
107
|
+
_weak: !0,
|
|
108
|
+
_strengthenOnPublish: {
|
|
109
|
+
type: referenceToType
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
from: {
|
|
113
|
+
fieldName,
|
|
114
|
+
type: referenceToType
|
|
115
|
+
},
|
|
116
|
+
__internal_isIncomingReferenceCreation: !0
|
|
117
|
+
}
|
|
118
|
+
}]]
|
|
119
|
+
}), onCreateNewReference(id);
|
|
120
|
+
}, $[0] = fieldName, $[1] = groupIndex, $[2] = navigate, $[3] = onCreateNewReference, $[4] = referenceToId, $[5] = referenceToType, $[6] = routerPanesState, $[7] = type, $[8] = t1) : t1 = $[8];
|
|
121
|
+
const handleCreate = t1;
|
|
122
|
+
let t2;
|
|
123
|
+
bb0: {
|
|
124
|
+
if (!creationAllowed) {
|
|
125
|
+
let t33;
|
|
126
|
+
$[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t33 = [], $[9] = t33) : t33 = $[9], t2 = t33;
|
|
127
|
+
break bb0;
|
|
128
|
+
}
|
|
129
|
+
let t32;
|
|
130
|
+
if ($[10] !== creationAllowed || $[11] !== initialValueTemplateItems || $[12] !== type) {
|
|
131
|
+
let t42;
|
|
132
|
+
$[14] !== creationAllowed || $[15] !== type ? (t42 = (i) => {
|
|
133
|
+
const typeMatch = type === i.template?.schemaType;
|
|
134
|
+
return Array.isArray(creationAllowed) ? typeMatch && creationAllowed.includes(i.template.id) : typeMatch;
|
|
135
|
+
}, $[14] = creationAllowed, $[15] = type, $[16] = t42) : t42 = $[16], t32 = (initialValueTemplateItems || []).filter(t42).map(_temp$2).filter(isNonNullable), $[10] = creationAllowed, $[11] = initialValueTemplateItems, $[12] = type, $[13] = t32;
|
|
136
|
+
} else
|
|
137
|
+
t32 = $[13];
|
|
138
|
+
t2 = t32;
|
|
139
|
+
}
|
|
140
|
+
const createOptions = t2;
|
|
141
|
+
if (!creationAllowed)
|
|
142
|
+
return null;
|
|
143
|
+
const t3 = `create-new-incoming-reference-${type}`;
|
|
144
|
+
let t4;
|
|
145
|
+
return $[17] !== createOptions || $[18] !== handleCreate || $[19] !== t3 ? (t4 = /* @__PURE__ */ jsx(CreateReferenceButton, { id: t3, createOptions, onCreate: handleCreate }), $[17] = createOptions, $[18] = handleCreate, $[19] = t3, $[20] = t4) : t4 = $[20], t4;
|
|
146
|
+
}
|
|
147
|
+
function _temp$2(item) {
|
|
148
|
+
return item.template?.schemaType ? {
|
|
149
|
+
id: item.id,
|
|
150
|
+
title: item.title || `${item.template.schemaType} from template ${item.template?.id}`,
|
|
151
|
+
i18n: item.i18n,
|
|
152
|
+
type: item.template.schemaType,
|
|
153
|
+
icon: item.icon,
|
|
154
|
+
template: {
|
|
155
|
+
id: item.template?.id,
|
|
156
|
+
params: item.parameters
|
|
157
|
+
},
|
|
158
|
+
permission: {
|
|
159
|
+
granted: item.granted,
|
|
160
|
+
reason: item.reason
|
|
161
|
+
}
|
|
162
|
+
} : void 0;
|
|
163
|
+
}
|
|
164
|
+
const getPerspective = (id) => isDraftId(id) ? ["drafts"] : isVersionId(id) ? [getVersionFromId(id)] : isPublishedId(id) ? ["published"] : ["raw"];
|
|
165
|
+
function LinkToExistingPreview(props) {
|
|
166
|
+
const $ = c(37), {
|
|
167
|
+
schemaType,
|
|
168
|
+
value,
|
|
169
|
+
onLinkToDocument
|
|
170
|
+
} = props, {
|
|
171
|
+
data: releases
|
|
172
|
+
} = useActiveReleases(), {
|
|
173
|
+
t
|
|
174
|
+
} = useTranslation();
|
|
175
|
+
let t0;
|
|
176
|
+
$[0] !== props.documentPreviewStore || $[1] !== schemaType || $[2] !== value._id ? (t0 = getPreviewStateObservable(props.documentPreviewStore, schemaType, value._id, getPerspective(value._id)), $[0] = props.documentPreviewStore, $[1] = schemaType, $[2] = value._id, $[3] = t0) : t0 = $[3];
|
|
177
|
+
const previewStateObservable = t0;
|
|
178
|
+
let t1;
|
|
179
|
+
$[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
180
|
+
snapshot: null,
|
|
181
|
+
isLoading: !0,
|
|
182
|
+
original: null
|
|
183
|
+
}, $[4] = t1) : t1 = $[4];
|
|
184
|
+
const {
|
|
185
|
+
snapshot,
|
|
186
|
+
original,
|
|
187
|
+
isLoading
|
|
188
|
+
} = useObservable(previewStateObservable, t1);
|
|
189
|
+
let t2;
|
|
190
|
+
if ($[5] !== releases || $[6] !== t || $[7] !== value._id) {
|
|
191
|
+
bb0: {
|
|
192
|
+
const id = value._id;
|
|
193
|
+
if (isDraftId(id)) {
|
|
194
|
+
let t32;
|
|
195
|
+
$[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t32 = getReleaseTone("drafts"), $[9] = t32) : t32 = $[9];
|
|
196
|
+
let t42;
|
|
197
|
+
$[10] !== t ? (t42 = t("release.chip.draft"), $[10] = t, $[11] = t42) : t42 = $[11];
|
|
198
|
+
let t52;
|
|
199
|
+
$[12] !== t42 ? (t52 = {
|
|
200
|
+
kind: "static",
|
|
201
|
+
tone: t32,
|
|
202
|
+
text: t42
|
|
203
|
+
}, $[12] = t42, $[13] = t52) : t52 = $[13], t2 = t52;
|
|
204
|
+
break bb0;
|
|
205
|
+
}
|
|
206
|
+
if (isPublishedId(id)) {
|
|
207
|
+
let t32;
|
|
208
|
+
$[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t32 = getReleaseTone("published"), $[14] = t32) : t32 = $[14];
|
|
209
|
+
let t42;
|
|
210
|
+
$[15] !== t ? (t42 = t("release.chip.published"), $[15] = t, $[16] = t42) : t42 = $[16];
|
|
211
|
+
let t52;
|
|
212
|
+
$[17] !== t42 ? (t52 = {
|
|
213
|
+
kind: "static",
|
|
214
|
+
tone: t32,
|
|
215
|
+
text: t42
|
|
216
|
+
}, $[17] = t42, $[18] = t52) : t52 = $[18], t2 = t52;
|
|
217
|
+
break bb0;
|
|
218
|
+
}
|
|
219
|
+
if (isVersionId(id)) {
|
|
220
|
+
let t32;
|
|
221
|
+
$[19] !== id ? (t32 = getVersionFromId(id), $[19] = id, $[20] = t32) : t32 = $[20];
|
|
222
|
+
const releaseId = t32;
|
|
223
|
+
let t42;
|
|
224
|
+
$[21] !== releaseId ? (t42 = (r) => getReleaseIdFromReleaseDocumentId(r._id) === releaseId, $[21] = releaseId, $[22] = t42) : t42 = $[22];
|
|
225
|
+
const release = releases.find(t42);
|
|
226
|
+
if (release) {
|
|
227
|
+
t2 = {
|
|
228
|
+
kind: "release",
|
|
229
|
+
tone: getReleaseTone(release),
|
|
230
|
+
releaseTitle: release.metadata.title,
|
|
231
|
+
releaseFallback: release._id
|
|
232
|
+
};
|
|
233
|
+
break bb0;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
t2 = null;
|
|
237
|
+
}
|
|
238
|
+
$[5] = releases, $[6] = t, $[7] = value._id, $[8] = t2;
|
|
239
|
+
} else
|
|
240
|
+
t2 = $[8];
|
|
241
|
+
const badgeProps = t2;
|
|
242
|
+
if (!snapshot && !isLoading)
|
|
243
|
+
return null;
|
|
244
|
+
let t3;
|
|
245
|
+
$[23] !== original || $[24] !== snapshot || $[25] !== value ? (t3 = getPreviewValueWithFallback({
|
|
246
|
+
snapshot,
|
|
247
|
+
original,
|
|
248
|
+
fallback: value
|
|
249
|
+
}), $[23] = original, $[24] = snapshot, $[25] = value, $[26] = t3) : t3 = $[26];
|
|
250
|
+
let t4;
|
|
251
|
+
$[27] !== badgeProps ? (t4 = badgeProps ? /* @__PURE__ */ jsx(Text, { size: 0, children: badgeProps.kind === "release" ? /* @__PURE__ */ jsx(ReleaseTitle, { title: badgeProps.releaseTitle, fallback: badgeProps.releaseFallback, children: (t52) => {
|
|
252
|
+
const {
|
|
253
|
+
displayTitle
|
|
254
|
+
} = t52;
|
|
255
|
+
return /* @__PURE__ */ jsx(VersionInlineBadge, { $tone: badgeProps.tone, children: displayTitle });
|
|
256
|
+
} }) : /* @__PURE__ */ jsx(VersionInlineBadge, { $tone: badgeProps.tone, children: badgeProps.text }) }) : void 0, $[27] = badgeProps, $[28] = t4) : t4 = $[28];
|
|
257
|
+
let t5;
|
|
258
|
+
$[29] !== isLoading || $[30] !== schemaType.icon || $[31] !== t3 || $[32] !== t4 ? (t5 = /* @__PURE__ */ jsx(SanityDefaultPreview, { ...t3, isPlaceholder: isLoading, icon: schemaType.icon, layout: "default", status: t4 }), $[29] = isLoading, $[30] = schemaType.icon, $[31] = t3, $[32] = t4, $[33] = t5) : t5 = $[33];
|
|
259
|
+
let t6;
|
|
260
|
+
return $[34] !== onLinkToDocument || $[35] !== t5 ? (t6 = /* @__PURE__ */ jsx(PreviewCard, { __unstable_focusRing: !0, onClick: onLinkToDocument, as: "button", radius: 2, children: t5 }), $[34] = onLinkToDocument, $[35] = t5, $[36] = t6) : t6 = $[36], t6;
|
|
261
|
+
}
|
|
262
|
+
const INITIAL_SEARCH_STATE = {
|
|
263
|
+
hits: [],
|
|
264
|
+
isLoading: !1
|
|
265
|
+
}, NO_FILTER = () => !0, incomingReferenceSearch = (client, schemaType, searchStrategy) => {
|
|
266
|
+
const search = createSearch([schemaType], client, {
|
|
267
|
+
maxDepth: DEFAULT_MAX_FIELD_DEPTH,
|
|
268
|
+
strategy: searchStrategy,
|
|
269
|
+
tag: "search.incoming-reference"
|
|
270
|
+
});
|
|
271
|
+
return (textTerm) => search(textTerm, {
|
|
272
|
+
perspective: "raw"
|
|
273
|
+
}).pipe(map(({
|
|
274
|
+
hits
|
|
275
|
+
}) => hits.map(({
|
|
276
|
+
hit
|
|
277
|
+
}) => hit)), map((docs) => {
|
|
278
|
+
const byId = /* @__PURE__ */ new Map();
|
|
279
|
+
return docs.forEach((doc) => {
|
|
280
|
+
if (isVersionId(doc._id)) {
|
|
281
|
+
byId.set(doc._id, doc);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const publishedId = getPublishedId(doc._id), entry = byId.get(publishedId);
|
|
285
|
+
entry ? isDraftId(doc._id) && isPublishedId(entry._id) && byId.set(publishedId, doc) : byId.set(publishedId, doc);
|
|
286
|
+
}), Array.from(byId.values());
|
|
287
|
+
}), map((collated) => collated.map((entry) => ({
|
|
288
|
+
_id: entry._id,
|
|
289
|
+
_type: entry._type
|
|
290
|
+
}))), map((docs) => docs.slice(0, 100)));
|
|
291
|
+
};
|
|
292
|
+
function AddIncomingReference(t0) {
|
|
293
|
+
const $ = c(52), {
|
|
294
|
+
type,
|
|
295
|
+
referenced,
|
|
296
|
+
onCreateNewReference,
|
|
297
|
+
onLinkDocument,
|
|
298
|
+
fieldName,
|
|
299
|
+
creationAllowed
|
|
300
|
+
} = t0, {
|
|
301
|
+
t
|
|
302
|
+
} = useTranslation(structureLocaleNamespace), {
|
|
303
|
+
push
|
|
304
|
+
} = useToast(), schema = useSchema();
|
|
305
|
+
let t1;
|
|
306
|
+
$[0] !== schema || $[1] !== type ? (t1 = schema.get(type), $[0] = schema, $[1] = type, $[2] = t1) : t1 = $[2];
|
|
307
|
+
const schemaType = t1, client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS), source = useSource(), {
|
|
308
|
+
strategy: searchStrategy
|
|
309
|
+
} = source.search, documentPreviewStore = useDocumentPreviewStore();
|
|
310
|
+
let t2;
|
|
311
|
+
$[3] !== client || $[4] !== schemaType || $[5] !== searchStrategy ? (t2 = incomingReferenceSearch(client, schemaType, searchStrategy), $[3] = client, $[4] = schemaType, $[5] = searchStrategy, $[6] = t2) : t2 = $[6];
|
|
312
|
+
const handleSearch = t2, [searchState, setSearchState] = useState(INITIAL_SEARCH_STATE);
|
|
313
|
+
let t3;
|
|
314
|
+
$[7] !== handleSearch || $[8] !== push || $[9] !== type ? (t3 = (inputValue$) => inputValue$.pipe(filter(isNonNullable), switchMap((searchString) => concat(of({
|
|
315
|
+
isLoading: !0,
|
|
316
|
+
hits: []
|
|
317
|
+
}), handleSearch(searchString).pipe(map((hits) => ({
|
|
318
|
+
hits,
|
|
319
|
+
searchString,
|
|
320
|
+
isLoading: !1
|
|
321
|
+
})), catchError((error) => (push({
|
|
322
|
+
title: "Reference search failed",
|
|
323
|
+
description: error.message,
|
|
324
|
+
status: "error",
|
|
325
|
+
id: `reference-search-fail-${type}`
|
|
326
|
+
}), console.error(error), of({
|
|
327
|
+
hits: [],
|
|
328
|
+
isLoading: !1
|
|
329
|
+
})))))), scan(_temp$1, INITIAL_SEARCH_STATE), tap(setSearchState)), $[7] = handleSearch, $[8] = push, $[9] = type, $[10] = t3) : t3 = $[10];
|
|
330
|
+
const handleQueryChange = useObservableEvent(t3);
|
|
331
|
+
let t4;
|
|
332
|
+
$[11] !== searchState.hits ? (t4 = searchState.hits.map(_temp2), $[11] = searchState.hits, $[12] = t4) : t4 = $[12];
|
|
333
|
+
const options = t4;
|
|
334
|
+
let t5;
|
|
335
|
+
$[13] !== handleQueryChange ? (t5 = () => {
|
|
336
|
+
handleQueryChange("");
|
|
337
|
+
}, $[13] = handleQueryChange, $[14] = t5) : t5 = $[14];
|
|
338
|
+
const handleAutocompleteOpenButtonClick = t5;
|
|
339
|
+
let t6;
|
|
340
|
+
$[15] !== documentPreviewStore || $[16] !== onLinkDocument || $[17] !== schemaType ? (t6 = (option) => /* @__PURE__ */ jsx(LinkToExistingPreview, { onLinkToDocument: () => onLinkDocument(option.value), documentPreviewStore, schemaType, value: option.hit }), $[15] = documentPreviewStore, $[16] = onLinkDocument, $[17] = schemaType, $[18] = t6) : t6 = $[18];
|
|
341
|
+
const renderOption = t6;
|
|
342
|
+
let t7;
|
|
343
|
+
$[19] !== t || $[20] !== type ? (t7 = t("incoming-references-input.reference-from", {
|
|
344
|
+
type
|
|
345
|
+
}), $[19] = t, $[20] = type, $[21] = t7) : t7 = $[21];
|
|
346
|
+
let t8;
|
|
347
|
+
$[22] !== t7 ? (t8 = /* @__PURE__ */ jsx(Box, { paddingY: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t7 }) }), $[22] = t7, $[23] = t8) : t8 = $[23];
|
|
348
|
+
const t9 = creationAllowed ? 2 : 0;
|
|
349
|
+
let t10;
|
|
350
|
+
$[24] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = {
|
|
351
|
+
gridTemplateColumns: "1fr min-content"
|
|
352
|
+
}, $[24] = t10) : t10 = $[24];
|
|
353
|
+
const t11 = `${type}-autocomplete`;
|
|
354
|
+
let t12;
|
|
355
|
+
$[25] !== t ? (t12 = t("incoming-references-input.type-to-search"), $[25] = t, $[26] = t12) : t12 = $[26];
|
|
356
|
+
let t13;
|
|
357
|
+
$[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t13 = [], $[27] = t13) : t13 = $[27];
|
|
358
|
+
let t14;
|
|
359
|
+
$[28] !== handleAutocompleteOpenButtonClick ? (t14 = {
|
|
360
|
+
onClick: handleAutocompleteOpenButtonClick
|
|
361
|
+
}, $[28] = handleAutocompleteOpenButtonClick, $[29] = t14) : t14 = $[29];
|
|
362
|
+
let t15;
|
|
363
|
+
$[30] !== handleQueryChange || $[31] !== options || $[32] !== renderOption || $[33] !== searchState.isLoading || $[34] !== t11 || $[35] !== t12 || $[36] !== t14 ? (t15 = /* @__PURE__ */ jsx(ReferenceAutocomplete, { id: t11, radius: 2, autoFocus: !0, options, placeholder: t12, onQueryChange: handleQueryChange, filterOption: NO_FILTER, path: t13, renderOption, openButton: t14, referenceElement: null, loading: searchState.isLoading }), $[30] = handleQueryChange, $[31] = options, $[32] = renderOption, $[33] = searchState.isLoading, $[34] = t11, $[35] = t12, $[36] = t14, $[37] = t15) : t15 = $[37];
|
|
364
|
+
let t16;
|
|
365
|
+
$[38] !== creationAllowed || $[39] !== fieldName || $[40] !== onCreateNewReference || $[41] !== referenced.id || $[42] !== referenced.type || $[43] !== type ? (t16 = /* @__PURE__ */ jsx(CreateNewIncomingReference, { type, referenceToId: referenced.id, referenceToType: referenced.type, creationAllowed, onCreateNewReference, fieldName }), $[38] = creationAllowed, $[39] = fieldName, $[40] = onCreateNewReference, $[41] = referenced.id, $[42] = referenced.type, $[43] = type, $[44] = t16) : t16 = $[44];
|
|
366
|
+
let t17;
|
|
367
|
+
$[45] !== t15 || $[46] !== t16 || $[47] !== t9 ? (t17 = /* @__PURE__ */ jsxs(Grid, { gap: t9, style: t10, children: [
|
|
368
|
+
t15,
|
|
369
|
+
t16
|
|
370
|
+
] }), $[45] = t15, $[46] = t16, $[47] = t9, $[48] = t17) : t17 = $[48];
|
|
371
|
+
let t18;
|
|
372
|
+
return $[49] !== t17 || $[50] !== t8 ? (t18 = /* @__PURE__ */ jsxs(Stack, { space: 2, padding: 2, children: [
|
|
373
|
+
t8,
|
|
374
|
+
t17
|
|
375
|
+
] }), $[49] = t17, $[50] = t8, $[51] = t18) : t18 = $[51], t18;
|
|
376
|
+
}
|
|
377
|
+
function _temp2(hit) {
|
|
378
|
+
return {
|
|
379
|
+
value: hit._id,
|
|
380
|
+
hit
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function _temp$1(prevState, nextState) {
|
|
384
|
+
return {
|
|
385
|
+
...prevState,
|
|
386
|
+
...nextState
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
function IncomingReferencesType(t0) {
|
|
390
|
+
const $ = c(69), {
|
|
391
|
+
type,
|
|
392
|
+
referenced,
|
|
393
|
+
onLinkDocument,
|
|
394
|
+
actions,
|
|
395
|
+
shouldRenderTitle,
|
|
396
|
+
fieldName,
|
|
397
|
+
creationAllowed,
|
|
398
|
+
filter: filter2,
|
|
399
|
+
filterParams
|
|
400
|
+
} = t0, documentPreviewStore = useDocumentPreviewStore(), {
|
|
401
|
+
displayed
|
|
402
|
+
} = useDocumentPane(), {
|
|
403
|
+
getClient
|
|
404
|
+
} = useSource(), displayedId = displayed?._id;
|
|
405
|
+
let t1;
|
|
406
|
+
$[0] !== displayedId || $[1] !== documentPreviewStore || $[2] !== filter2 || $[3] !== filterParams || $[4] !== getClient || $[5] !== type.type ? (t1 = getIncomingReferences({
|
|
407
|
+
documentId: displayedId,
|
|
408
|
+
documentPreviewStore,
|
|
409
|
+
type: type.type,
|
|
410
|
+
filter: filter2,
|
|
411
|
+
filterParams,
|
|
412
|
+
getClient
|
|
413
|
+
}), $[0] = displayedId, $[1] = documentPreviewStore, $[2] = filter2, $[3] = filterParams, $[4] = getClient, $[5] = type.type, $[6] = t1) : t1 = $[6];
|
|
414
|
+
const references$ = t1, {
|
|
415
|
+
documents,
|
|
416
|
+
loading
|
|
417
|
+
} = useObservable(references$, INITIAL_STATE), schema = useSchema(), {
|
|
418
|
+
t
|
|
419
|
+
} = useTranslation(structureLocaleNamespace);
|
|
420
|
+
let t2;
|
|
421
|
+
$[7] !== schema || $[8] !== type.type ? (t2 = schema.get(type.type), $[7] = schema, $[8] = type.type, $[9] = t2) : t2 = $[9];
|
|
422
|
+
const schemaType = t2, client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS), [isAdding, setIsAdding] = useState(!1), [newReferenceId, setNewReferenceId] = useState(null), {
|
|
423
|
+
editState
|
|
424
|
+
} = useDocumentPane(), toast = useToast();
|
|
425
|
+
let t3;
|
|
426
|
+
$[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = () => {
|
|
427
|
+
setIsAdding(_temp);
|
|
428
|
+
}, $[10] = t3) : t3 = $[10];
|
|
429
|
+
const handleAdd = t3, publishedExists = !!editState?.published;
|
|
430
|
+
let t4;
|
|
431
|
+
$[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = async (documentId) => {
|
|
432
|
+
setIsAdding(!1), setNewReferenceId(documentId);
|
|
433
|
+
}, $[11] = t4) : t4 = $[11];
|
|
434
|
+
const handleCreateNewReference = t4;
|
|
435
|
+
let t5;
|
|
436
|
+
$[12] !== client || $[13] !== onLinkDocument || $[14] !== publishedExists || $[15] !== referenced.id || $[16] !== referenced.type || $[17] !== schemaType?.liveEdit || $[18] !== toast ? (t5 = async (documentId_0) => {
|
|
437
|
+
setIsAdding(!1), setNewReferenceId(documentId_0);
|
|
438
|
+
const liveEdit = !!schemaType?.liveEdit, document = await client.fetch("*[_id == $id][0]", {
|
|
439
|
+
id: documentId_0
|
|
440
|
+
}), linkedDocument = onLinkDocument?.(document, {
|
|
441
|
+
_type: "reference",
|
|
442
|
+
_ref: getPublishedId(referenced.id),
|
|
443
|
+
...publishedExists ? {} : {
|
|
444
|
+
_weak: !0,
|
|
445
|
+
_strengthenOnPublish: {
|
|
446
|
+
type: referenced.type
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
if (!linkedDocument) {
|
|
451
|
+
setNewReferenceId(null), toast.push({
|
|
452
|
+
title: "Not possible to link to document",
|
|
453
|
+
description: "The document you are trying to link cannot be linked to",
|
|
454
|
+
status: "error"
|
|
455
|
+
});
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
isPublishedId(documentId_0) && !liveEdit && (linkedDocument._id = getDraftId(documentId_0)), await client.createOrReplace(linkedDocument);
|
|
459
|
+
}, $[12] = client, $[13] = onLinkDocument, $[14] = publishedExists, $[15] = referenced.id, $[16] = referenced.type, $[17] = schemaType?.liveEdit, $[18] = toast, $[19] = t5) : t5 = $[19];
|
|
460
|
+
const handleLinkDocument = t5;
|
|
461
|
+
let t6, t7;
|
|
462
|
+
$[20] !== documents || $[21] !== newReferenceId ? (t6 = () => {
|
|
463
|
+
documents.length > 0 && newReferenceId && documents.find((document_0) => getPublishedId(document_0._id) === getPublishedId(newReferenceId)) && setNewReferenceId(null);
|
|
464
|
+
}, t7 = [documents, newReferenceId], $[20] = documents, $[21] = newReferenceId, $[22] = t6, $[23] = t7) : (t6 = $[22], t7 = $[23]), useEffect(t6, t7);
|
|
465
|
+
let t8;
|
|
466
|
+
$[24] !== actions || $[25] !== referenced.id ? (t8 = (document_1) => /* @__PURE__ */ jsx(IncomingReferenceDocument, { document: document_1, referenceToId: referenced.id, actions }), $[24] = actions, $[25] = referenced.id, $[26] = t8) : t8 = $[26];
|
|
467
|
+
const renderItem = t8;
|
|
468
|
+
if (!schemaType)
|
|
469
|
+
return null;
|
|
470
|
+
if (loading) {
|
|
471
|
+
let t92;
|
|
472
|
+
$[27] !== t ? (t92 = t("incoming-references-input.types-loading"), $[27] = t, $[28] = t92) : t92 = $[28];
|
|
473
|
+
let t102;
|
|
474
|
+
return $[29] !== t92 ? (t102 = /* @__PURE__ */ jsx(LoadingBlock, { showText: !0, title: t92 }), $[29] = t92, $[30] = t102) : t102 = $[30], t102;
|
|
475
|
+
}
|
|
476
|
+
let t9;
|
|
477
|
+
$[31] !== schemaType?.title || $[32] !== shouldRenderTitle || $[33] !== type.title ? (t9 = shouldRenderTitle && /* @__PURE__ */ jsx(Box, { paddingY: 2, paddingX: 0, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: type.title || schemaType?.title }) }), $[31] = schemaType?.title, $[32] = shouldRenderTitle, $[33] = type.title, $[34] = t9) : t9 = $[34];
|
|
478
|
+
let t10;
|
|
479
|
+
$[35] !== documents || $[36] !== isAdding || $[37] !== newReferenceId || $[38] !== renderItem || $[39] !== schemaType?.title || $[40] !== t || $[41] !== type.title ? (t10 = documents.length > 0 ? /* @__PURE__ */ jsx(IncomingReferencesListContainer, { $itemCount: documents.length, children: /* @__PURE__ */ jsx(CommandList, { activeItemDataAttr: "data-hovered", ariaLabel: t("incoming-references-input.list-label", {
|
|
480
|
+
type: type.title || schemaType?.title
|
|
481
|
+
}), canReceiveFocus: !0, fixedHeight: !0, getItemKey: (index) => documents[index]._id, itemHeight: INCOMING_REFERENCES_ITEM_HEIGHT, items: documents, onlyShowSelectionWhenActive: !0, overscan: 5, renderItem, wrapAround: !1 }) }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", padding: 2, hidden: isAdding || !!newReferenceId, children: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: t("incoming-references-input.no-items") }) }) }), $[35] = documents, $[36] = isAdding, $[37] = newReferenceId, $[38] = renderItem, $[39] = schemaType?.title, $[40] = t, $[41] = type.title, $[42] = t10) : t10 = $[42];
|
|
482
|
+
let t11;
|
|
483
|
+
$[43] !== newReferenceId || $[44] !== schemaType ? (t11 = newReferenceId && /* @__PURE__ */ jsx(SanityDefaultPreview, { icon: schemaType.icon, layout: "default", isPlaceholder: !0 }), $[43] = newReferenceId, $[44] = schemaType, $[45] = t11) : t11 = $[45];
|
|
484
|
+
let t12;
|
|
485
|
+
$[46] !== creationAllowed || $[47] !== fieldName || $[48] !== handleLinkDocument || $[49] !== isAdding || $[50] !== referenced || $[51] !== type.type ? (t12 = isAdding && /* @__PURE__ */ jsx(AddIncomingReference, { type: type.type, referenced, onCreateNewReference: handleCreateNewReference, onLinkDocument: handleLinkDocument, creationAllowed, fieldName }), $[46] = creationAllowed, $[47] = fieldName, $[48] = handleLinkDocument, $[49] = isAdding, $[50] = referenced, $[51] = type.type, $[52] = t12) : t12 = $[52];
|
|
486
|
+
let t13;
|
|
487
|
+
$[53] !== t10 || $[54] !== t11 || $[55] !== t12 ? (t13 = /* @__PURE__ */ jsxs(Card, { radius: 2, padding: 1, border: !0, tone: "default", children: [
|
|
488
|
+
t10,
|
|
489
|
+
t11,
|
|
490
|
+
t12
|
|
491
|
+
] }), $[53] = t10, $[54] = t11, $[55] = t12, $[56] = t13) : t13 = $[56];
|
|
492
|
+
let t14;
|
|
493
|
+
$[57] !== creationAllowed || $[58] !== fieldName || $[59] !== onLinkDocument || $[60] !== referenced.id || $[61] !== referenced.type || $[62] !== t || $[63] !== type.type ? (t14 = onLinkDocument ? /* @__PURE__ */ jsx(Button, { size: "large", disabled: !1, icon: AddIcon, mode: "ghost", onClick: handleAdd, text: t("incoming-references-input.add-reference-item") }) : /* @__PURE__ */ jsx(CreateNewIncomingReference, { type: type.type, referenceToId: referenced.id, referenceToType: referenced.type, creationAllowed, onCreateNewReference: handleCreateNewReference, fieldName }), $[57] = creationAllowed, $[58] = fieldName, $[59] = onLinkDocument, $[60] = referenced.id, $[61] = referenced.type, $[62] = t, $[63] = type.type, $[64] = t14) : t14 = $[64];
|
|
494
|
+
let t15;
|
|
495
|
+
return $[65] !== t13 || $[66] !== t14 || $[67] !== t9 ? (t15 = /* @__PURE__ */ jsxs(Stack, { space: 2, marginBottom: 2, children: [
|
|
496
|
+
t9,
|
|
497
|
+
t13,
|
|
498
|
+
t14
|
|
499
|
+
] }), $[65] = t13, $[66] = t14, $[67] = t9, $[68] = t15) : t15 = $[68], t15;
|
|
500
|
+
}
|
|
501
|
+
function _temp(p) {
|
|
502
|
+
return !p;
|
|
503
|
+
}
|
|
504
|
+
function isCrossDatasetIncomingReference(type) {
|
|
505
|
+
return !!type.dataset;
|
|
506
|
+
}
|
|
507
|
+
function IncomingReferencesList(t0) {
|
|
508
|
+
const $ = c(26), {
|
|
509
|
+
types,
|
|
510
|
+
onLinkDocument,
|
|
511
|
+
actions,
|
|
512
|
+
filter: filter2,
|
|
513
|
+
filterParams,
|
|
514
|
+
name,
|
|
515
|
+
creationAllowed
|
|
516
|
+
} = t0, {
|
|
517
|
+
documentId,
|
|
518
|
+
documentType
|
|
519
|
+
} = useDocumentPane(), {
|
|
520
|
+
t
|
|
521
|
+
} = useTranslation(structureLocaleNamespace);
|
|
522
|
+
if (!types || types?.length === 0) {
|
|
523
|
+
let t12;
|
|
524
|
+
$[0] !== t ? (t12 = t("incoming-references-input.types-not-defined"), $[0] = t, $[1] = t12) : t12 = $[1];
|
|
525
|
+
let t22;
|
|
526
|
+
return $[2] !== t12 ? (t22 = /* @__PURE__ */ jsx(Card, { border: !0, radius: 2, padding: 3, tone: "critical", children: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", children: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: t12 }) }) }), $[2] = t12, $[3] = t22) : t22 = $[3], t22;
|
|
527
|
+
}
|
|
528
|
+
let t1;
|
|
529
|
+
if ($[4] !== actions || $[5] !== creationAllowed || $[6] !== documentId || $[7] !== documentType || $[8] !== filter2 || $[9] !== filterParams || $[10] !== name || $[11] !== onLinkDocument || $[12] !== types) {
|
|
530
|
+
let t22;
|
|
531
|
+
$[14] !== actions || $[15] !== creationAllowed || $[16] !== documentId || $[17] !== documentType || $[18] !== filter2 || $[19] !== filterParams || $[20] !== name || $[21] !== onLinkDocument || $[22] !== types.length ? (t22 = (type) => isCrossDatasetIncomingReference(type) ? /* @__PURE__ */ jsx(CrossDatasetIncomingReferenceType, { type, referenced: {
|
|
532
|
+
id: documentId,
|
|
533
|
+
type: documentType
|
|
534
|
+
}, shouldRenderTitle: types.length > 1 }, `${type.type}-${type.dataset || ""}`) : /* @__PURE__ */ jsx(IncomingReferencesType, { type, referenced: {
|
|
535
|
+
id: documentId,
|
|
536
|
+
type: documentType
|
|
537
|
+
}, onLinkDocument, actions, shouldRenderTitle: types.length > 1, fieldName: name, creationAllowed, filter: filter2, filterParams }, type.type), $[14] = actions, $[15] = creationAllowed, $[16] = documentId, $[17] = documentType, $[18] = filter2, $[19] = filterParams, $[20] = name, $[21] = onLinkDocument, $[22] = types.length, $[23] = t22) : t22 = $[23], t1 = types.map(t22), $[4] = actions, $[5] = creationAllowed, $[6] = documentId, $[7] = documentType, $[8] = filter2, $[9] = filterParams, $[10] = name, $[11] = onLinkDocument, $[12] = types, $[13] = t1;
|
|
538
|
+
} else
|
|
539
|
+
t1 = $[13];
|
|
540
|
+
let t2;
|
|
541
|
+
return $[24] !== t1 ? (t2 = /* @__PURE__ */ jsx(Stack, { space: 3, children: t1 }), $[24] = t1, $[25] = t2) : t2 = $[25], t2;
|
|
542
|
+
}
|
|
543
|
+
function IncomingReferencesDecoration(props) {
|
|
544
|
+
const $ = c(21), {
|
|
545
|
+
onLinkDocument,
|
|
546
|
+
actions,
|
|
547
|
+
filter: filter2,
|
|
548
|
+
filterParams,
|
|
549
|
+
name,
|
|
550
|
+
creationAllowed: t0,
|
|
551
|
+
types,
|
|
552
|
+
title,
|
|
553
|
+
description
|
|
554
|
+
} = props, creationAllowed = t0 === void 0 ? !0 : t0;
|
|
555
|
+
let t1;
|
|
556
|
+
$[0] !== name || $[1] !== title ? (t1 = title || startCase(name), $[0] = name, $[1] = title, $[2] = t1) : t1 = $[2];
|
|
557
|
+
let t2;
|
|
558
|
+
$[3] !== t1 ? (t2 = /* @__PURE__ */ jsx(Flex, { align: "center", paddingY: 1, children: /* @__PURE__ */ jsx(Text, { as: "label", weight: "medium", size: 1, children: t1 }) }), $[3] = t1, $[4] = t2) : t2 = $[4];
|
|
559
|
+
let t3;
|
|
560
|
+
$[5] !== description ? (t3 = description && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: description }), $[5] = description, $[6] = t3) : t3 = $[6];
|
|
561
|
+
let t4;
|
|
562
|
+
$[7] !== t2 || $[8] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { paddingY: 2, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
563
|
+
t2,
|
|
564
|
+
t3
|
|
565
|
+
] }) }), $[7] = t2, $[8] = t3, $[9] = t4) : t4 = $[9];
|
|
566
|
+
let t5;
|
|
567
|
+
$[10] !== actions || $[11] !== creationAllowed || $[12] !== filter2 || $[13] !== filterParams || $[14] !== name || $[15] !== onLinkDocument || $[16] !== types ? (t5 = /* @__PURE__ */ jsx(IncomingReferencesList, { name, types, onLinkDocument, actions, filter: filter2, filterParams, creationAllowed }), $[10] = actions, $[11] = creationAllowed, $[12] = filter2, $[13] = filterParams, $[14] = name, $[15] = onLinkDocument, $[16] = types, $[17] = t5) : t5 = $[17];
|
|
568
|
+
let t6;
|
|
569
|
+
return $[18] !== t4 || $[19] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
570
|
+
t4,
|
|
571
|
+
t5
|
|
572
|
+
] }), $[18] = t4, $[19] = t5, $[20] = t6) : t6 = $[20], t6;
|
|
573
|
+
}
|
|
574
|
+
function defineIncomingReferenceDecoration(options) {
|
|
575
|
+
return {
|
|
576
|
+
kind: "decoration",
|
|
577
|
+
key: options.name,
|
|
578
|
+
component: /* @__PURE__ */ jsx(IncomingReferencesDecoration, { ...options })
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function isIncomingReferenceCreation(initialValue) {
|
|
582
|
+
return typeof initialValue == "object" && initialValue !== null && "__internal_isIncomingReferenceCreation" in initialValue;
|
|
583
|
+
}
|
|
584
|
+
export {
|
|
585
|
+
ComponentBuilder,
|
|
586
|
+
ComponentViewBuilder,
|
|
587
|
+
ConfirmDeleteDialogContainer as ConfirmDeleteDialog,
|
|
588
|
+
DEFAULT_INTENT_HANDLER,
|
|
589
|
+
DocumentBuilder,
|
|
590
|
+
DocumentInspectorHeader,
|
|
591
|
+
DocumentListBuilder,
|
|
592
|
+
DocumentListItemBuilder,
|
|
593
|
+
PaneContainer as DocumentListPane,
|
|
594
|
+
DocumentPane,
|
|
595
|
+
DocumentPaneProviderWrapper as DocumentPaneProvider,
|
|
596
|
+
DocumentTypeListBuilder,
|
|
597
|
+
FormViewBuilder,
|
|
598
|
+
GenericListBuilder,
|
|
599
|
+
GenericViewBuilder,
|
|
600
|
+
HELP_URL,
|
|
601
|
+
InitialValueTemplateItemBuilder,
|
|
602
|
+
ListBuilder,
|
|
603
|
+
ListItemBuilder,
|
|
604
|
+
MenuItemBuilder,
|
|
605
|
+
MenuItemGroupBuilder,
|
|
606
|
+
Pane,
|
|
607
|
+
PaneContent,
|
|
608
|
+
PaneLayout,
|
|
609
|
+
PaneRouterContext,
|
|
610
|
+
SerializeError,
|
|
611
|
+
StructureToolProvider,
|
|
612
|
+
component,
|
|
613
|
+
createStructureBuilder,
|
|
614
|
+
defaultInitialValueTemplateItems,
|
|
615
|
+
defaultIntentChecker,
|
|
616
|
+
defineIncomingReferenceDecoration,
|
|
617
|
+
documentFromEditor,
|
|
618
|
+
documentFromEditorWithInitialValue,
|
|
619
|
+
form,
|
|
620
|
+
getOrderingMenuItem,
|
|
621
|
+
getOrderingMenuItemsForSchemaType,
|
|
622
|
+
getTypeNamesFromFilter,
|
|
623
|
+
isDocumentListItem,
|
|
624
|
+
isIncomingReferenceCreation,
|
|
625
|
+
maybeSerializeInitialValueTemplateItem,
|
|
626
|
+
maybeSerializeMenuItem,
|
|
627
|
+
maybeSerializeMenuItemGroup,
|
|
628
|
+
maybeSerializeView,
|
|
629
|
+
menuItemsFromInitialValueTemplateItems,
|
|
630
|
+
shallowIntentChecker,
|
|
631
|
+
structureLocaleNamespace,
|
|
632
|
+
structureTool,
|
|
633
|
+
useDocumentPane,
|
|
634
|
+
useDocumentTitle,
|
|
635
|
+
usePaneOptions,
|
|
636
|
+
usePaneRouter,
|
|
637
|
+
useStructureTool
|
|
638
|
+
};
|
|
639
|
+
//# sourceMappingURL=structure.js.map
|