@sanity/document-internationalization 6.2.13 → 6.2.15
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/dist/index.d.ts +25 -51
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1321 -1274
- package/dist/index.js.map +1 -1
- package/dist/resources.js +8 -0
- package/dist/resources.js.map +1 -0
- package/package.json +8 -8
- package/dist/_chunks-es/resources.js +0 -9
- package/dist/_chunks-es/resources.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { c } from "react/compiler-runtime";
|
|
3
2
|
import { TrashIcon } from "@sanity/icons/Trash";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { Badge, Box, Button, Card, Dialog, Flex, Grid, Inline, Popover, Spinner, Stack, Text, TextInput, Tooltip, useClickOutsideEvent, useToast } from "@sanity/ui";
|
|
4
|
+
import { createContext, use, useContext, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { DEFAULT_STUDIO_CLIENT_OPTIONS, InsufficientPermissionsMessage, PatchEvent, Preview, TextWithTone, defineField, defineLocaleResourceBundle, definePlugin, defineType, getDraftId, getVersionFromId, getVersionId, isDocumentSchemaType, isSanityDocument, isVersionId, pathToString, unset, useClient, useCurrentUser, useDocumentOperation, useDocumentPairPermissions, useDocumentStore, useEditState, usePerspective, useSchema, useTranslation, useValidationStatus, useWorkspace } from "sanity";
|
|
7
6
|
import { LANGUAGE_FIELD_NAME, internationalizedArray } from "sanity-plugin-internationalized-array";
|
|
8
7
|
import { Feedback, useListeningQuery } from "sanity-plugin-utils";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { CopyIcon } from "@sanity/icons/Copy";
|
|
10
10
|
import { uuid } from "@sanity/uuid";
|
|
11
|
-
import {
|
|
11
|
+
import { filter, firstValueFrom } from "rxjs";
|
|
12
12
|
import { useRouter } from "sanity/router";
|
|
13
|
-
import { structureLocaleNamespace,
|
|
13
|
+
import { structureLocaleNamespace, useDocumentPane, usePaneRouter } from "sanity/structure";
|
|
14
14
|
import { TranslateIcon } from "@sanity/icons/Translate";
|
|
15
15
|
import { CogIcon } from "@sanity/icons/Cog";
|
|
16
16
|
import { randomKey } from "@sanity/util/content";
|
|
@@ -21,1364 +21,1411 @@ import { Mutation, extractWithPath } from "@sanity/mutator";
|
|
|
21
21
|
import { EditIcon } from "@sanity/icons/Edit";
|
|
22
22
|
import { InfoOutlineIcon } from "@sanity/icons/InfoOutline";
|
|
23
23
|
function DocumentPreview(props) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
let $ = c(7), schema = useSchema(), t0;
|
|
25
|
+
$[0] !== props.type || $[1] !== schema ? (t0 = schema.get(props.type), $[0] = props.type, $[1] = schema, $[2] = t0) : t0 = $[2];
|
|
26
|
+
let schemaType = t0;
|
|
27
|
+
if (!schemaType) {
|
|
28
|
+
let t1;
|
|
29
|
+
return $[3] === Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx(Feedback, {
|
|
30
|
+
tone: "critical",
|
|
31
|
+
title: "Schema type not found"
|
|
32
|
+
}), $[3] = t1) : t1 = $[3], t1;
|
|
33
|
+
}
|
|
34
|
+
let t1;
|
|
35
|
+
return $[4] !== props.value || $[5] !== schemaType ? (t1 = /* @__PURE__ */ jsx(Preview, {
|
|
36
|
+
value: props.value,
|
|
37
|
+
schemaType
|
|
38
|
+
}), $[4] = props.value, $[5] = schemaType, $[6] = t1) : t1 = $[6], t1;
|
|
34
39
|
}
|
|
35
40
|
const METADATA_SCHEMA_NAME = "translation.metadata", TRANSLATIONS_ARRAY_NAME = "translations", API_VERSION = "2025-02-19", DEFAULT_CONFIG = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
supportedLanguages: [],
|
|
42
|
+
schemaTypes: [],
|
|
43
|
+
languageField: "language",
|
|
44
|
+
weakReferences: !1,
|
|
45
|
+
bulkPublish: !1,
|
|
46
|
+
metadataFields: [],
|
|
47
|
+
apiVersion: API_VERSION,
|
|
48
|
+
allowCreateMetaDoc: !1,
|
|
49
|
+
callback: null,
|
|
50
|
+
hideLanguageFilter: !1,
|
|
51
|
+
metadataOmnisearchVisibility: !0,
|
|
52
|
+
addTemplates: !0
|
|
48
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Splits an array of referring documents into two groups: translation metadata
|
|
56
|
+
* documents (whose `_type` matches the metadata schema name) and all other
|
|
57
|
+
* references. Used by the delete-translation dialog to show which metadata
|
|
58
|
+
* entries will be patched versus which external references may block deletion.
|
|
59
|
+
*/
|
|
49
60
|
function separateReferences(data = []) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
let translations = [], otherReferences = [];
|
|
62
|
+
return data && data.length > 0 && data.forEach((doc) => {
|
|
63
|
+
doc._type === METADATA_SCHEMA_NAME ? translations.push(doc) : otherReferences.push(doc);
|
|
64
|
+
}), {
|
|
65
|
+
translations,
|
|
66
|
+
otherReferences
|
|
67
|
+
};
|
|
57
68
|
}
|
|
58
69
|
function DeleteTranslationDialog(props) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
70
|
+
let $ = c(33), { doc, documentId, setTranslations } = props, t0;
|
|
71
|
+
$[0] === documentId ? t0 = $[1] : (t0 = { id: documentId }, $[0] = documentId, $[1] = t0);
|
|
72
|
+
let t1;
|
|
73
|
+
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[2] = t1) : t1 = $[2];
|
|
74
|
+
let t2;
|
|
75
|
+
$[3] === t0 ? t2 = $[4] : (t2 = {
|
|
76
|
+
params: t0,
|
|
77
|
+
initialValue: t1
|
|
78
|
+
}, $[3] = t0, $[4] = t2);
|
|
79
|
+
let { data, loading } = useListeningQuery("*[references($id)]{_id, _type, translations}", t2), t3;
|
|
80
|
+
$[5] === data ? t3 = $[6] : (t3 = separateReferences(data), $[5] = data, $[6] = t3);
|
|
81
|
+
let { translations, otherReferences } = t3, t4, t5;
|
|
82
|
+
if ($[7] !== setTranslations || $[8] !== translations ? (t4 = () => {
|
|
83
|
+
setTranslations(translations);
|
|
84
|
+
}, t5 = [setTranslations, translations], $[7] = setTranslations, $[8] = translations, $[9] = t4, $[10] = t5) : (t4 = $[9], t5 = $[10]), useEffect(t4, t5), loading) {
|
|
85
|
+
let t6;
|
|
86
|
+
return $[11] === Symbol.for("react.memo_cache_sentinel") ? (t6 = /* @__PURE__ */ jsx(Flex, {
|
|
87
|
+
padding: 4,
|
|
88
|
+
align: "center",
|
|
89
|
+
justify: "center",
|
|
90
|
+
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
91
|
+
}), $[11] = t6) : t6 = $[11], t6;
|
|
92
|
+
}
|
|
93
|
+
let t6;
|
|
94
|
+
$[12] === translations ? t6 = $[13] : (t6 = translations && translations.length > 0 ? /* @__PURE__ */ jsx(Text, { children: "This document is a language-specific version which other translations depend on." }) : /* @__PURE__ */ jsx(Text, { children: "This document does not have connected translations." }), $[12] = translations, $[13] = t6);
|
|
95
|
+
let t7;
|
|
96
|
+
$[14] === translations ? t7 = $[15] : (t7 = /* @__PURE__ */ jsx(Text, {
|
|
97
|
+
size: 1,
|
|
98
|
+
weight: "semibold",
|
|
99
|
+
children: translations && translations.length > 0 ? /* @__PURE__ */ jsx(Fragment, { children: "Before this document can be deleted" }) : /* @__PURE__ */ jsx(Fragment, { children: "This document can now be deleted" })
|
|
100
|
+
}), $[14] = translations, $[15] = t7);
|
|
101
|
+
let t8;
|
|
102
|
+
$[16] === doc ? t8 = $[17] : (t8 = /* @__PURE__ */ jsx(DocumentPreview, {
|
|
103
|
+
value: doc,
|
|
104
|
+
type: doc._type
|
|
105
|
+
}), $[16] = doc, $[17] = t8);
|
|
106
|
+
let t9;
|
|
107
|
+
$[18] === translations ? t9 = $[19] : (t9 = translations && translations.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
108
|
+
/* @__PURE__ */ jsx(Card, { borderTop: !0 }),
|
|
109
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
110
|
+
size: 1,
|
|
111
|
+
weight: "semibold",
|
|
112
|
+
children: [
|
|
113
|
+
"The reference in",
|
|
114
|
+
" ",
|
|
115
|
+
translations.length === 1 ? "this translations document" : "these translations documents",
|
|
116
|
+
" ",
|
|
117
|
+
"must be removed"
|
|
118
|
+
]
|
|
119
|
+
}),
|
|
120
|
+
translations.map(_temp$5)
|
|
121
|
+
] }) : null, $[18] = translations, $[19] = t9);
|
|
122
|
+
let t10;
|
|
123
|
+
$[20] === otherReferences ? t10 = $[21] : (t10 = otherReferences && otherReferences.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
124
|
+
/* @__PURE__ */ jsx(Card, { borderTop: !0 }),
|
|
125
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
126
|
+
size: 1,
|
|
127
|
+
weight: "semibold",
|
|
128
|
+
children: [
|
|
129
|
+
otherReferences.length === 1 ? "There is an additional reference" : "There are additional references",
|
|
130
|
+
" ",
|
|
131
|
+
"to this document"
|
|
132
|
+
]
|
|
133
|
+
}),
|
|
134
|
+
otherReferences.map(_temp2$3)
|
|
135
|
+
] }) : null, $[20] = otherReferences, $[21] = t10);
|
|
136
|
+
let t11;
|
|
137
|
+
$[22] !== t10 || $[23] !== t7 || $[24] !== t8 || $[25] !== t9 ? (t11 = /* @__PURE__ */ jsx(Card, {
|
|
138
|
+
border: !0,
|
|
139
|
+
padding: 3,
|
|
140
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
141
|
+
gap: 4,
|
|
142
|
+
children: [
|
|
143
|
+
t7,
|
|
144
|
+
t8,
|
|
145
|
+
t9,
|
|
146
|
+
t10
|
|
147
|
+
]
|
|
148
|
+
})
|
|
149
|
+
}), $[22] = t10, $[23] = t7, $[24] = t8, $[25] = t9, $[26] = t11) : t11 = $[26];
|
|
150
|
+
let t12;
|
|
151
|
+
$[27] === otherReferences.length ? t12 = $[28] : (t12 = otherReferences.length === 0 ? /* @__PURE__ */ jsx(Text, { children: "This document has no other references." }) : /* @__PURE__ */ jsx(Text, { children: "You may not be able to delete this document because other documents refer to it." }), $[27] = otherReferences.length, $[28] = t12);
|
|
152
|
+
let t13;
|
|
153
|
+
return $[29] !== t11 || $[30] !== t12 || $[31] !== t6 ? (t13 = /* @__PURE__ */ jsxs(Stack, {
|
|
154
|
+
gap: 4,
|
|
155
|
+
children: [
|
|
156
|
+
t6,
|
|
157
|
+
t11,
|
|
158
|
+
t12
|
|
159
|
+
]
|
|
160
|
+
}), $[29] = t11, $[30] = t12, $[31] = t6, $[32] = t13) : t13 = $[32], t13;
|
|
135
161
|
}
|
|
136
162
|
function _temp2$3(reference) {
|
|
137
|
-
|
|
163
|
+
return /* @__PURE__ */ jsx(DocumentPreview, {
|
|
164
|
+
value: reference,
|
|
165
|
+
type: reference._type
|
|
166
|
+
}, reference._id);
|
|
138
167
|
}
|
|
139
168
|
function _temp$5(translation) {
|
|
140
|
-
|
|
169
|
+
return /* @__PURE__ */ jsx(DocumentPreview, {
|
|
170
|
+
value: translation,
|
|
171
|
+
type: translation._type
|
|
172
|
+
}, translation._id);
|
|
141
173
|
}
|
|
142
174
|
function DeleteTranslationFooter(props) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
175
|
+
let $ = c(8), { translations, onClose, onProceed } = props, t0;
|
|
176
|
+
$[0] === onClose ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Button, {
|
|
177
|
+
text: "Cancel",
|
|
178
|
+
onClick: onClose,
|
|
179
|
+
mode: "ghost"
|
|
180
|
+
}), $[0] = onClose, $[1] = t0);
|
|
181
|
+
let t1 = translations && translations.length > 0 ? "Unset translation reference" : "Delete document", t2;
|
|
182
|
+
$[2] !== onProceed || $[3] !== t1 ? (t2 = /* @__PURE__ */ jsx(Button, {
|
|
183
|
+
text: t1,
|
|
184
|
+
onClick: onProceed,
|
|
185
|
+
tone: "critical"
|
|
186
|
+
}), $[2] = onProceed, $[3] = t1, $[4] = t2) : t2 = $[4];
|
|
187
|
+
let t3;
|
|
188
|
+
return $[5] !== t0 || $[6] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Grid, {
|
|
189
|
+
gridTemplateColumns: 2,
|
|
190
|
+
gap: 2,
|
|
191
|
+
children: [t0, t2]
|
|
192
|
+
}), $[5] = t0, $[6] = t2, $[7] = t3) : t3 = $[7], t3;
|
|
158
193
|
}
|
|
159
194
|
const DocumentInternationalizationContext = createContext(DEFAULT_CONFIG);
|
|
160
195
|
function useDocumentInternationalizationContext() {
|
|
161
|
-
|
|
196
|
+
return useContext(DocumentInternationalizationContext);
|
|
162
197
|
}
|
|
163
198
|
const promiseCache = /* @__PURE__ */ new Map();
|
|
164
199
|
function createCacheKey(workspaceId) {
|
|
165
|
-
|
|
200
|
+
return `languages-${workspaceId}`;
|
|
166
201
|
}
|
|
167
202
|
function createOrGetPromise(fn, cacheKey) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return promiseCache.set(cacheKey, promise), promise;
|
|
203
|
+
let cached = promiseCache.get(cacheKey);
|
|
204
|
+
if (cached) return cached;
|
|
205
|
+
let promise = fn();
|
|
206
|
+
return promiseCache.set(cacheKey, promise), promise;
|
|
173
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* This Provider wraps the Studio and provides the DocumentInternationalization context to document actions and components.
|
|
210
|
+
*/
|
|
174
211
|
function DocumentInternationalizationProvider(props) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}, $[10] = pluginConfig, $[11] = supportedLanguages, $[12] = t3) : t3 = $[12];
|
|
203
|
-
const contextValue = t3;
|
|
204
|
-
let t4;
|
|
205
|
-
$[13] !== props ? (t4 = props.renderDefault(props), $[13] = props, $[14] = t4) : t4 = $[14];
|
|
206
|
-
let t5;
|
|
207
|
-
return $[15] !== contextValue || $[16] !== t4 ? (t5 = /* @__PURE__ */ jsx(DocumentInternationalizationContext.Provider, { value: contextValue, children: t4 }), $[15] = contextValue, $[16] = t4, $[17] = t5) : t5 = $[17], t5;
|
|
212
|
+
let $ = c(18), { pluginConfig } = props, t0;
|
|
213
|
+
$[0] === pluginConfig.apiVersion ? t0 = $[1] : (t0 = { apiVersion: pluginConfig.apiVersion }, $[0] = pluginConfig.apiVersion, $[1] = t0);
|
|
214
|
+
let client = useClient(t0), workspaceId = useWorkspace().name ?? "", t1;
|
|
215
|
+
$[2] === workspaceId ? t1 = $[3] : (t1 = createCacheKey(workspaceId), $[2] = workspaceId, $[3] = t1);
|
|
216
|
+
let cacheKey = t1, t2;
|
|
217
|
+
bb0: {
|
|
218
|
+
if (Array.isArray(pluginConfig.supportedLanguages)) {
|
|
219
|
+
t2 = null;
|
|
220
|
+
break bb0;
|
|
221
|
+
}
|
|
222
|
+
let t3;
|
|
223
|
+
$[4] !== client || $[5] !== pluginConfig ? (t3 = async () => typeof pluginConfig.supportedLanguages == "function" ? pluginConfig.supportedLanguages(client) : pluginConfig.supportedLanguages, $[4] = client, $[5] = pluginConfig, $[6] = t3) : t3 = $[6];
|
|
224
|
+
let t4;
|
|
225
|
+
$[7] !== cacheKey || $[8] !== t3 ? (t4 = createOrGetPromise(t3, cacheKey), $[7] = cacheKey, $[8] = t3, $[9] = t4) : t4 = $[9], t2 = t4;
|
|
226
|
+
}
|
|
227
|
+
let languagesPromise = t2, supportedLanguages = languagesPromise ? use(languagesPromise) : pluginConfig.supportedLanguages, t3;
|
|
228
|
+
$[10] !== pluginConfig || $[11] !== supportedLanguages ? (t3 = {
|
|
229
|
+
...pluginConfig,
|
|
230
|
+
supportedLanguages
|
|
231
|
+
}, $[10] = pluginConfig, $[11] = supportedLanguages, $[12] = t3) : t3 = $[12];
|
|
232
|
+
let contextValue = t3, t4;
|
|
233
|
+
$[13] === props ? t4 = $[14] : (t4 = props.renderDefault(props), $[13] = props, $[14] = t4);
|
|
234
|
+
let t5;
|
|
235
|
+
return $[15] !== contextValue || $[16] !== t4 ? (t5 = /* @__PURE__ */ jsx(DocumentInternationalizationContext.Provider, {
|
|
236
|
+
value: contextValue,
|
|
237
|
+
children: t4
|
|
238
|
+
}), $[15] = contextValue, $[16] = t4, $[17] = t5) : t5 = $[17], t5;
|
|
208
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Optional Document action that removes a single translation from the metadata document
|
|
242
|
+
* and optionally deletes the translation document. Opens a confirmation dialog
|
|
243
|
+
* showing which metadata entries reference the document and any other references
|
|
244
|
+
* that may exist. When the document has translation references, those references
|
|
245
|
+
* are unset; otherwise the document is deleted directly.
|
|
246
|
+
*
|
|
247
|
+
* To use it, you need to add it to the document actions config
|
|
248
|
+
* ```
|
|
249
|
+
* const translatedSchemaTypes = ['lesson', 'article'];
|
|
250
|
+
* document: {
|
|
251
|
+
* actions: (prev, {schemaType}) => {
|
|
252
|
+
* if (translatedSchemaTypes.includes(schemaType)) {
|
|
253
|
+
* return [...prev, useDeleteTranslationAction]
|
|
254
|
+
* }
|
|
255
|
+
* return prev
|
|
256
|
+
* },
|
|
257
|
+
* },
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
209
260
|
const useDeleteTranslationAction = (props) => {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
disabled: t4,
|
|
265
|
-
icon: TrashIcon,
|
|
266
|
-
tone: "critical",
|
|
267
|
-
onHandle: t5,
|
|
268
|
-
dialog: t6
|
|
269
|
-
}, $[16] = t4, $[17] = t6, $[18] = t7) : t7 = $[18], t7;
|
|
261
|
+
let $ = c(19), { id: documentId, published, draft } = props, doc = draft || published, { languageField } = useDocumentInternationalizationContext(), [isDialogOpen, setDialogOpen] = useState(!1), t0;
|
|
262
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
|
|
263
|
+
let [translations, setTranslations] = useState(t0), t1;
|
|
264
|
+
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setDialogOpen(!1), $[1] = t1) : t1 = $[1];
|
|
265
|
+
let onClose = t1, rawDocumentLanguage = doc ? doc[languageField] : null, documentLanguage = typeof rawDocumentLanguage == "string" ? rawDocumentLanguage : null, toast = useToast(), t2;
|
|
266
|
+
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { apiVersion: API_VERSION }, $[2] = t2) : t2 = $[2];
|
|
267
|
+
let client = useClient(t2), t3;
|
|
268
|
+
$[3] !== client || $[4] !== documentId || $[5] !== documentLanguage || $[6] !== toast || $[7] !== translations ? (t3 = () => {
|
|
269
|
+
let tx = client.transaction(), operation = "DELETE";
|
|
270
|
+
documentLanguage && translations.length > 0 ? (operation = "UNSET", translations.forEach((translation) => {
|
|
271
|
+
tx.patch(translation._id, (patch) => patch.unset([`${TRANSLATIONS_ARRAY_NAME}[${LANGUAGE_FIELD_NAME} == "${documentLanguage}"]`]));
|
|
272
|
+
})) : (tx.delete(documentId), tx.delete(`drafts.${documentId}`)), tx.commit().then(() => {
|
|
273
|
+
operation === "DELETE" && onClose(), toast.push({
|
|
274
|
+
status: "success",
|
|
275
|
+
title: operation === "UNSET" ? "Translation reference unset" : "Document deleted",
|
|
276
|
+
description: operation === "UNSET" ? "The document can now be deleted" : null
|
|
277
|
+
});
|
|
278
|
+
}).catch((err) => {
|
|
279
|
+
toast.push({
|
|
280
|
+
status: "error",
|
|
281
|
+
title: operation === "UNSET" ? "Failed to unset translation reference" : "Failed to delete document",
|
|
282
|
+
description: err.message
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
}, $[3] = client, $[4] = documentId, $[5] = documentLanguage, $[6] = toast, $[7] = translations, $[8] = t3) : t3 = $[8];
|
|
286
|
+
let onProceed = t3, t4 = !doc || !documentLanguage, t5;
|
|
287
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
|
288
|
+
setDialogOpen(!0);
|
|
289
|
+
}, $[9] = t5) : t5 = $[9];
|
|
290
|
+
let t6;
|
|
291
|
+
$[10] !== doc || $[11] !== documentId || $[12] !== isDialogOpen || $[13] !== onProceed || $[14] !== translations ? (t6 = isDialogOpen && {
|
|
292
|
+
type: "dialog",
|
|
293
|
+
onClose,
|
|
294
|
+
header: "Delete translation",
|
|
295
|
+
content: doc ? /* @__PURE__ */ jsx(DeleteTranslationDialog, {
|
|
296
|
+
doc,
|
|
297
|
+
documentId,
|
|
298
|
+
setTranslations
|
|
299
|
+
}) : null,
|
|
300
|
+
footer: /* @__PURE__ */ jsx(DeleteTranslationFooter, {
|
|
301
|
+
onClose,
|
|
302
|
+
onProceed,
|
|
303
|
+
translations
|
|
304
|
+
})
|
|
305
|
+
}, $[10] = doc, $[11] = documentId, $[12] = isDialogOpen, $[13] = onProceed, $[14] = translations, $[15] = t6) : t6 = $[15];
|
|
306
|
+
let t7;
|
|
307
|
+
return $[16] !== t4 || $[17] !== t6 ? (t7 = {
|
|
308
|
+
label: "Delete translation...",
|
|
309
|
+
disabled: t4,
|
|
310
|
+
icon: TrashIcon,
|
|
311
|
+
tone: "critical",
|
|
312
|
+
onHandle: t5,
|
|
313
|
+
dialog: t6
|
|
314
|
+
}, $[16] = t4, $[17] = t6, $[18] = t7) : t7 = $[18], t7;
|
|
270
315
|
};
|
|
271
|
-
useDeleteTranslationAction.action = "deleteTranslation";
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}`;
|
|
316
|
+
useDeleteTranslationAction.action = "deleteTranslation", useDeleteTranslationAction.displayName = "DeleteTranslationAction";
|
|
317
|
+
/**
|
|
318
|
+
* @deprecated use useDeleteTranslationAction instead
|
|
319
|
+
* Will be removed in the next major version
|
|
320
|
+
*/
|
|
321
|
+
const DeleteTranslationAction = (props) => useDeleteTranslationAction(props);
|
|
278
322
|
function useTranslationMetadata(id) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
error
|
|
291
|
-
} = useListeningQuery(query, t0);
|
|
292
|
-
let t1;
|
|
293
|
-
return $[2] !== data || $[3] !== error || $[4] !== loading ? (t1 = {
|
|
294
|
-
data,
|
|
295
|
-
loading,
|
|
296
|
-
error
|
|
297
|
-
}, $[2] = data, $[3] = error, $[4] = loading, $[5] = t1) : t1 = $[5], t1;
|
|
323
|
+
let $ = c(6), t0;
|
|
324
|
+
$[0] === id ? t0 = $[1] : (t0 = { params: {
|
|
325
|
+
id,
|
|
326
|
+
translationSchema: METADATA_SCHEMA_NAME
|
|
327
|
+
} }, $[0] = id, $[1] = t0);
|
|
328
|
+
let { data, loading, error } = useListeningQuery("*[_type == $translationSchema && $id in translations[].value._ref]{\n _id,\n _createdAt,\n translations\n}", t0), t1;
|
|
329
|
+
return $[2] !== data || $[3] !== error || $[4] !== loading ? (t1 = {
|
|
330
|
+
data,
|
|
331
|
+
loading,
|
|
332
|
+
error
|
|
333
|
+
}, $[2] = data, $[3] = error, $[4] = loading, $[5] = t1) : t1 = $[5], t1;
|
|
298
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* The locale namespace for the document internationalization plugin.
|
|
337
|
+
*
|
|
338
|
+
* @public
|
|
339
|
+
*/
|
|
299
340
|
const documenti18nLocaleNamespace = "document-internationalization", documentInternationalizationUsEnglishLocaleBundle = defineLocaleResourceBundle({
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
341
|
+
locale: "en-US",
|
|
342
|
+
namespace: documenti18nLocaleNamespace,
|
|
343
|
+
resources: () => import("./resources.js")
|
|
303
344
|
}), DISABLED_REASON_KEY = {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
345
|
+
METADATA_NOT_FOUND: "action.duplicate.disabled.missing-metadata",
|
|
346
|
+
MULTIPLE_METADATA: "action.duplicate.disabled.multiple-metadata",
|
|
347
|
+
NOTHING_TO_DUPLICATE: "action.duplicate.disabled.nothing-to-duplicate",
|
|
348
|
+
NOT_READY: "action.duplicate.disabled.not-ready"
|
|
308
349
|
}, useDuplicateWithTranslationsAction = (t0) => {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
$[25] !== d ? (t42 = d("action.duplicate.label"), $[25] = d, $[26] = t42) : t42 = $[26];
|
|
414
|
-
let t52;
|
|
415
|
-
$[27] !== d ? (t52 = d(DISABLED_REASON_KEY.MULTIPLE_METADATA), $[27] = d, $[28] = t52) : t52 = $[28];
|
|
416
|
-
let t62;
|
|
417
|
-
$[29] !== t42 || $[30] !== t52 ? (t62 = {
|
|
418
|
-
icon: CopyIcon,
|
|
419
|
-
disabled: !0,
|
|
420
|
-
label: t42,
|
|
421
|
-
title: t52
|
|
422
|
-
}, $[29] = t42, $[30] = t52, $[31] = t62) : t62 = $[31], t3 = t62;
|
|
423
|
-
break bb0;
|
|
424
|
-
}
|
|
425
|
-
const t4 = isDuplicating || !!duplicate.disabled || isPermissionsLoading || isMetadataDocumentLoading;
|
|
426
|
-
let t5;
|
|
427
|
-
$[32] !== d || $[33] !== isDuplicating || $[34] !== s ? (t5 = isDuplicating ? s("action.duplicate.running.label") : d("action.duplicate.label"), $[32] = d, $[33] = isDuplicating, $[34] = s, $[35] = t5) : t5 = $[35];
|
|
428
|
-
let t6;
|
|
429
|
-
$[36] !== duplicate.disabled || $[37] !== s ? (t6 = duplicate.disabled ? s(DISABLED_REASON_KEY[duplicate.disabled]) : "", $[36] = duplicate.disabled, $[37] = s, $[38] = t6) : t6 = $[38];
|
|
430
|
-
let t7;
|
|
431
|
-
$[39] !== handle || $[40] !== t4 || $[41] !== t5 || $[42] !== t6 ? (t7 = {
|
|
432
|
-
icon: CopyIcon,
|
|
433
|
-
disabled: t4,
|
|
434
|
-
label: t5,
|
|
435
|
-
title: t6,
|
|
436
|
-
onHandle: handle
|
|
437
|
-
}, $[39] = handle, $[40] = t4, $[41] = t5, $[42] = t6, $[43] = t7) : t7 = $[43], t3 = t7;
|
|
438
|
-
}
|
|
439
|
-
return t3;
|
|
350
|
+
let $ = c(44), { id, type, onComplete } = t0, documentStore = useDocumentStore(), { duplicate } = useDocumentOperation(id, type), { navigateIntent } = useRouter(), [isDuplicating, setDuplicating] = useState(!1), t1;
|
|
351
|
+
$[0] !== id || $[1] !== type ? (t1 = {
|
|
352
|
+
id,
|
|
353
|
+
type,
|
|
354
|
+
permission: "duplicate"
|
|
355
|
+
}, $[0] = id, $[1] = type, $[2] = t1) : t1 = $[2];
|
|
356
|
+
let [permissions, isPermissionsLoading] = useDocumentPairPermissions(t1), { data, loading: isMetadataDocumentLoading } = useTranslationMetadata(id), hasOneMetadataDocument = Array.isArray(data) && data.length <= 1, metadataDocument = Array.isArray(data) && data.length ? data[0] : null, client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS), toast = useToast(), { t: s } = useTranslation(structureLocaleNamespace), { t: d } = useTranslation(documenti18nLocaleNamespace), currentUser = useCurrentUser(), t2;
|
|
357
|
+
$[3] !== client || $[4] !== documentStore.pair || $[5] !== metadataDocument || $[6] !== navigateIntent || $[7] !== onComplete || $[8] !== toast || $[9] !== type ? (t2 = () => {
|
|
358
|
+
setDuplicating(!0), (async function() {
|
|
359
|
+
if (!metadataDocument) return Promise.reject(/* @__PURE__ */ Error("Metadata document not found"));
|
|
360
|
+
let translationsArray = metadataDocument[TRANSLATIONS_ARRAY_NAME];
|
|
361
|
+
if (!translationsArray || translationsArray.length === 0) return Promise.reject(/* @__PURE__ */ Error("No translations found in metadata document"));
|
|
362
|
+
let translations = /* @__PURE__ */ new Map();
|
|
363
|
+
await Promise.all(translationsArray.map(async (translation) => {
|
|
364
|
+
let dupeId = uuid(), locale = translation[LANGUAGE_FIELD_NAME], docId = translation.value?._ref;
|
|
365
|
+
if (typeof locale != "string" || locale.trim().length === 0) return Promise.reject(/* @__PURE__ */ Error("Invalid locale for translation"));
|
|
366
|
+
if (!docId) return Promise.reject(/* @__PURE__ */ Error("Translation document not found"));
|
|
367
|
+
let { duplicate: duplicateTranslation } = await firstValueFrom(documentStore.pair.editOperations(docId, type).pipe(filter(_temp$4)));
|
|
368
|
+
if (duplicateTranslation.disabled) return Promise.reject(/* @__PURE__ */ Error("Cannot duplicate document"));
|
|
369
|
+
let duplicateTranslationSuccess = firstValueFrom(documentStore.pair.operationEvents(docId, type).pipe(filter(_temp2$2)));
|
|
370
|
+
duplicateTranslation.execute(dupeId), await duplicateTranslationSuccess, translations.set(locale, dupeId);
|
|
371
|
+
}));
|
|
372
|
+
let { duplicate: duplicateMetadata } = await firstValueFrom(documentStore.pair.editOperations(metadataDocument._id, METADATA_SCHEMA_NAME).pipe(filter(_temp3)));
|
|
373
|
+
if (duplicateMetadata.disabled) return Promise.reject(/* @__PURE__ */ Error("Cannot duplicate document"));
|
|
374
|
+
let duplicateMetadataSuccess = firstValueFrom(documentStore.pair.operationEvents(metadataDocument._id, METADATA_SCHEMA_NAME).pipe(filter(_temp4))), dupeId_0 = uuid();
|
|
375
|
+
duplicateMetadata.execute(dupeId_0), await duplicateMetadataSuccess;
|
|
376
|
+
let patch = { set: Object.fromEntries(Array.from(translations.entries()).map(_temp5)) };
|
|
377
|
+
await client.transaction().patch(dupeId_0, patch).commit(), navigateIntent("edit", {
|
|
378
|
+
id: Array.from(translations.values()).at(0),
|
|
379
|
+
type
|
|
380
|
+
}), onComplete();
|
|
381
|
+
})().catch((error) => {
|
|
382
|
+
console.error(error), toast.push({
|
|
383
|
+
status: "error",
|
|
384
|
+
title: "Error duplicating document",
|
|
385
|
+
description: error instanceof Error ? error.message : "Failed to duplicate document"
|
|
386
|
+
});
|
|
387
|
+
}).finally(() => {
|
|
388
|
+
setDuplicating(!1);
|
|
389
|
+
});
|
|
390
|
+
}, $[3] = client, $[4] = documentStore.pair, $[5] = metadataDocument, $[6] = navigateIntent, $[7] = onComplete, $[8] = toast, $[9] = type, $[10] = t2) : t2 = $[10];
|
|
391
|
+
let handle = t2;
|
|
392
|
+
permissions?.granted;
|
|
393
|
+
let t3;
|
|
394
|
+
bb0: {
|
|
395
|
+
if (!isPermissionsLoading && !permissions?.granted) {
|
|
396
|
+
let t4;
|
|
397
|
+
$[11] === d ? t4 = $[12] : (t4 = d("action.duplicate.label"), $[11] = d, $[12] = t4);
|
|
398
|
+
let t5;
|
|
399
|
+
$[13] === currentUser ? t5 = $[14] : (t5 = /* @__PURE__ */ jsx(InsufficientPermissionsMessage, {
|
|
400
|
+
context: "duplicate-document",
|
|
401
|
+
currentUser
|
|
402
|
+
}), $[13] = currentUser, $[14] = t5);
|
|
403
|
+
let t6;
|
|
404
|
+
$[15] !== t4 || $[16] !== t5 ? (t6 = {
|
|
405
|
+
icon: CopyIcon,
|
|
406
|
+
disabled: !0,
|
|
407
|
+
label: t4,
|
|
408
|
+
title: t5
|
|
409
|
+
}, $[15] = t4, $[16] = t5, $[17] = t6) : t6 = $[17], t3 = t6;
|
|
410
|
+
break bb0;
|
|
411
|
+
}
|
|
412
|
+
if (!isMetadataDocumentLoading && !metadataDocument) {
|
|
413
|
+
let t4;
|
|
414
|
+
$[18] === d ? t4 = $[19] : (t4 = d("action.duplicate.label"), $[18] = d, $[19] = t4);
|
|
415
|
+
let t5;
|
|
416
|
+
$[20] === d ? t5 = $[21] : (t5 = d(DISABLED_REASON_KEY.METADATA_NOT_FOUND), $[20] = d, $[21] = t5);
|
|
417
|
+
let t6;
|
|
418
|
+
$[22] !== t4 || $[23] !== t5 ? (t6 = {
|
|
419
|
+
icon: CopyIcon,
|
|
420
|
+
disabled: !0,
|
|
421
|
+
label: t4,
|
|
422
|
+
title: t5
|
|
423
|
+
}, $[22] = t4, $[23] = t5, $[24] = t6) : t6 = $[24], t3 = t6;
|
|
424
|
+
break bb0;
|
|
425
|
+
}
|
|
426
|
+
if (!hasOneMetadataDocument) {
|
|
427
|
+
let t4;
|
|
428
|
+
$[25] === d ? t4 = $[26] : (t4 = d("action.duplicate.label"), $[25] = d, $[26] = t4);
|
|
429
|
+
let t5;
|
|
430
|
+
$[27] === d ? t5 = $[28] : (t5 = d(DISABLED_REASON_KEY.MULTIPLE_METADATA), $[27] = d, $[28] = t5);
|
|
431
|
+
let t6;
|
|
432
|
+
$[29] !== t4 || $[30] !== t5 ? (t6 = {
|
|
433
|
+
icon: CopyIcon,
|
|
434
|
+
disabled: !0,
|
|
435
|
+
label: t4,
|
|
436
|
+
title: t5
|
|
437
|
+
}, $[29] = t4, $[30] = t5, $[31] = t6) : t6 = $[31], t3 = t6;
|
|
438
|
+
break bb0;
|
|
439
|
+
}
|
|
440
|
+
let t4 = isDuplicating || !!duplicate.disabled || isPermissionsLoading || isMetadataDocumentLoading, t5;
|
|
441
|
+
$[32] !== d || $[33] !== isDuplicating || $[34] !== s ? (t5 = isDuplicating ? s("action.duplicate.running.label") : d("action.duplicate.label"), $[32] = d, $[33] = isDuplicating, $[34] = s, $[35] = t5) : t5 = $[35];
|
|
442
|
+
let t6;
|
|
443
|
+
$[36] !== duplicate.disabled || $[37] !== s ? (t6 = duplicate.disabled ? s(DISABLED_REASON_KEY[duplicate.disabled]) : "", $[36] = duplicate.disabled, $[37] = s, $[38] = t6) : t6 = $[38];
|
|
444
|
+
let t7;
|
|
445
|
+
$[39] !== handle || $[40] !== t4 || $[41] !== t5 || $[42] !== t6 ? (t7 = {
|
|
446
|
+
icon: CopyIcon,
|
|
447
|
+
disabled: t4,
|
|
448
|
+
label: t5,
|
|
449
|
+
title: t6,
|
|
450
|
+
onHandle: handle
|
|
451
|
+
}, $[39] = handle, $[40] = t4, $[41] = t5, $[42] = t6, $[43] = t7) : t7 = $[43], t3 = t7;
|
|
452
|
+
}
|
|
453
|
+
return t3;
|
|
440
454
|
};
|
|
441
|
-
useDuplicateWithTranslationsAction.action = "duplicate";
|
|
442
|
-
|
|
455
|
+
useDuplicateWithTranslationsAction.action = "duplicate", useDuplicateWithTranslationsAction.displayName = "DuplicateWithTranslationsAction";
|
|
456
|
+
/**
|
|
457
|
+
* @deprecated use useDuplicateWithTranslationsAction instead
|
|
458
|
+
* Will be removed in the next major version
|
|
459
|
+
*/
|
|
443
460
|
const DuplicateWithTranslationsAction = (props) => useDuplicateWithTranslationsAction(props);
|
|
444
|
-
DuplicateWithTranslationsAction.action = "duplicate";
|
|
445
|
-
DuplicateWithTranslationsAction.displayName = "DuplicateWithTranslationsAction";
|
|
461
|
+
DuplicateWithTranslationsAction.action = "duplicate", DuplicateWithTranslationsAction.displayName = "DuplicateWithTranslationsAction";
|
|
446
462
|
function _temp$4(op) {
|
|
447
|
-
|
|
463
|
+
return op.duplicate.disabled !== "NOT_READY";
|
|
448
464
|
}
|
|
449
465
|
function _temp2$2(e) {
|
|
450
|
-
|
|
466
|
+
return e.op === "duplicate" && e.type === "success";
|
|
451
467
|
}
|
|
452
468
|
function _temp3(op_0) {
|
|
453
|
-
|
|
469
|
+
return op_0.duplicate.disabled !== "NOT_READY";
|
|
454
470
|
}
|
|
455
471
|
function _temp4(e_0) {
|
|
456
|
-
|
|
472
|
+
return e_0.op === "duplicate" && e_0.type === "success";
|
|
457
473
|
}
|
|
458
474
|
function _temp5(t0) {
|
|
459
|
-
|
|
460
|
-
|
|
475
|
+
let [locale_0, documentId] = t0;
|
|
476
|
+
return [`${TRANSLATIONS_ARRAY_NAME}[${LANGUAGE_FIELD_NAME} == "${locale_0}"].value._ref`, documentId];
|
|
461
477
|
}
|
|
462
478
|
function useOpenInNewPane(id, type) {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
params: {
|
|
482
|
-
type
|
|
483
|
-
}
|
|
484
|
-
}]);
|
|
485
|
-
const href = router.resolvePathFromState({
|
|
486
|
-
panes
|
|
487
|
-
});
|
|
488
|
-
router.navigateUrl({
|
|
489
|
-
path: href
|
|
490
|
-
});
|
|
491
|
-
}, $[0] = groupIndex, $[1] = id, $[2] = router, $[3] = routerPanesState, $[4] = type, $[5] = t0) : t0 = $[5], t0;
|
|
479
|
+
let $ = c(6), router = useRouter(), { routerPanesState, groupIndex } = usePaneRouter(), t0;
|
|
480
|
+
return $[0] !== groupIndex || $[1] !== id || $[2] !== router || $[3] !== routerPanesState || $[4] !== type ? (t0 = () => {
|
|
481
|
+
if (!id || !type) return;
|
|
482
|
+
if (!routerPanesState.length) {
|
|
483
|
+
router.navigateIntent("edit", {
|
|
484
|
+
id,
|
|
485
|
+
type
|
|
486
|
+
});
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
let panes = [...routerPanesState];
|
|
490
|
+
panes.splice(groupIndex + 1, 0, [{
|
|
491
|
+
id,
|
|
492
|
+
params: { type }
|
|
493
|
+
}]);
|
|
494
|
+
let href = router.resolvePathFromState({ panes });
|
|
495
|
+
router.navigateUrl({ path: href });
|
|
496
|
+
}, $[0] = groupIndex, $[1] = id, $[2] = router, $[3] = routerPanesState, $[4] = type, $[5] = t0) : t0 = $[5], t0;
|
|
492
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* Creates a translation reference object used in metadata documents to link
|
|
500
|
+
* a language key to a document. References are created as weak by default,
|
|
501
|
+
* with optional strengthen-on-publish metadata so the reference becomes
|
|
502
|
+
* strong once the referenced document is published.
|
|
503
|
+
*/
|
|
493
504
|
function createReference(language, ref, type, strengthenOnPublish = !0) {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
type
|
|
506
|
-
}
|
|
507
|
-
} : {}
|
|
508
|
-
}
|
|
509
|
-
};
|
|
505
|
+
return {
|
|
506
|
+
[LANGUAGE_FIELD_NAME]: language,
|
|
507
|
+
_key: randomKey(),
|
|
508
|
+
_type: "internationalizedArrayReferenceValue",
|
|
509
|
+
value: {
|
|
510
|
+
_type: "reference",
|
|
511
|
+
_ref: ref,
|
|
512
|
+
_weak: !0,
|
|
513
|
+
...strengthenOnPublish ? { _strengthenOnPublish: { type } } : {}
|
|
514
|
+
}
|
|
515
|
+
};
|
|
510
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Button component for opening or creating the translation metadata document.
|
|
519
|
+
* When metadata already exists, clicking opens it in a new pane. When no
|
|
520
|
+
* metadata exists and creation is allowed, clicking creates a new metadata
|
|
521
|
+
* document with the source language reference and then opens it.
|
|
522
|
+
*/
|
|
511
523
|
function LanguageManage(props) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
524
|
+
let $ = c(21), { id, metadataId, schemaType, documentId, sourceLanguageId } = props, open = useOpenInNewPane(id, METADATA_SCHEMA_NAME), openCreated = useOpenInNewPane(metadataId, METADATA_SCHEMA_NAME), { allowCreateMetaDoc, apiVersion, weakReferences } = useDocumentInternationalizationContext(), t0;
|
|
525
|
+
$[0] === apiVersion ? t0 = $[1] : (t0 = { apiVersion }, $[0] = apiVersion, $[1] = t0);
|
|
526
|
+
let client = useClient(t0), [userHasClicked, setUserHasClicked] = useState(!1), canCreate = !id && !!metadataId && allowCreateMetaDoc, t1;
|
|
527
|
+
$[2] !== client || $[3] !== documentId || $[4] !== id || $[5] !== metadataId || $[6] !== open || $[7] !== openCreated || $[8] !== schemaType.name || $[9] !== sourceLanguageId || $[10] !== weakReferences ? (t1 = () => {
|
|
528
|
+
if (!id && metadataId && sourceLanguageId) {
|
|
529
|
+
setUserHasClicked(!0);
|
|
530
|
+
let transaction = client.transaction(), sourceReference = createReference(sourceLanguageId, documentId, schemaType.name, !weakReferences), newMetadataDocument = {
|
|
531
|
+
_id: metadataId,
|
|
532
|
+
_type: METADATA_SCHEMA_NAME,
|
|
533
|
+
schemaTypes: [schemaType.name],
|
|
534
|
+
translations: [sourceReference]
|
|
535
|
+
};
|
|
536
|
+
transaction.createIfNotExists(newMetadataDocument), transaction.commit().then(() => {
|
|
537
|
+
setUserHasClicked(!1), openCreated();
|
|
538
|
+
}).catch((err) => {
|
|
539
|
+
console.error(err), setUserHasClicked(!1);
|
|
540
|
+
});
|
|
541
|
+
} else open();
|
|
542
|
+
}, $[2] = client, $[3] = documentId, $[4] = id, $[5] = metadataId, $[6] = open, $[7] = openCreated, $[8] = schemaType.name, $[9] = sourceLanguageId, $[10] = weakReferences, $[11] = t1) : t1 = $[11];
|
|
543
|
+
let handleClick = t1, disabled = !id && !canCreate || canCreate && !sourceLanguageId || userHasClicked, t2, t3;
|
|
544
|
+
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Box, {
|
|
545
|
+
padding: 2,
|
|
546
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
547
|
+
muted: !0,
|
|
548
|
+
size: 1,
|
|
549
|
+
children: "Document has no other translations"
|
|
550
|
+
})
|
|
551
|
+
}), t3 = ["right", "left"], $[12] = t2, $[13] = t3) : (t2 = $[12], t3 = $[13]);
|
|
552
|
+
let t4 = !!id || canCreate, t5;
|
|
553
|
+
$[14] !== disabled || $[15] !== handleClick || $[16] !== userHasClicked ? (t5 = /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(Button, {
|
|
554
|
+
disabled,
|
|
555
|
+
mode: "ghost",
|
|
556
|
+
text: "Manage Translations",
|
|
557
|
+
icon: CogIcon,
|
|
558
|
+
loading: userHasClicked,
|
|
559
|
+
onClick: handleClick
|
|
560
|
+
}) }), $[14] = disabled, $[15] = handleClick, $[16] = userHasClicked, $[17] = t5) : t5 = $[17];
|
|
561
|
+
let t6;
|
|
562
|
+
return $[18] !== t4 || $[19] !== t5 ? (t6 = /* @__PURE__ */ jsx(Tooltip, {
|
|
563
|
+
animate: !0,
|
|
564
|
+
content: t2,
|
|
565
|
+
fallbackPlacements: t3,
|
|
566
|
+
placement: "top",
|
|
567
|
+
portal: !0,
|
|
568
|
+
disabled: t4,
|
|
569
|
+
children: t5
|
|
570
|
+
}), $[18] = t4, $[19] = t5, $[20] = t6) : t6 = $[20], t6;
|
|
554
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Removes fields from a document that are marked with the
|
|
574
|
+
* `documentInternationalization.exclude` schema option. This is used when
|
|
575
|
+
* duplicating a source document to create a translation, so that
|
|
576
|
+
* language-specific or non-translatable fields are stripped from the copy.
|
|
577
|
+
* Returns the document with excluded paths unset, or `null` if the input is null.
|
|
578
|
+
*/
|
|
555
579
|
function removeExcludedPaths(doc, schemaType) {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
id: doc._id,
|
|
563
|
-
unset: pathsToExclude
|
|
564
|
-
}
|
|
565
|
-
}]
|
|
566
|
-
}).apply(doc);
|
|
580
|
+
if (!isDocumentSchemaType(schemaType) || !doc) return doc;
|
|
581
|
+
let pathsToExclude = extractPaths(doc, schemaType, []).filter((field) => field.schemaType?.options?.documentInternationalization?.exclude === !0).map((field) => pathToString(field.path));
|
|
582
|
+
return new Mutation({ mutations: [{ patch: {
|
|
583
|
+
id: doc._id,
|
|
584
|
+
unset: pathsToExclude
|
|
585
|
+
} }] }).apply(doc);
|
|
567
586
|
}
|
|
568
587
|
function extractPaths(doc, schemaType, path) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
schemaType: itemSchema,
|
|
601
|
-
value: item
|
|
602
|
-
};
|
|
603
|
-
result.push(arrayMember, ...innerFields);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
} else
|
|
607
|
-
result.push(thisFieldWithPath);
|
|
608
|
-
}
|
|
609
|
-
return result;
|
|
588
|
+
let result = [];
|
|
589
|
+
for (let field of schemaType.fields) {
|
|
590
|
+
let fieldPath = [...path, field.name], fieldSchema = field.type, { value } = extractWithPath(pathToString(fieldPath), doc)[0] ?? {};
|
|
591
|
+
if (value == null) continue;
|
|
592
|
+
let thisFieldWithPath = {
|
|
593
|
+
path: fieldPath,
|
|
594
|
+
name: field.name,
|
|
595
|
+
schemaType: fieldSchema,
|
|
596
|
+
value
|
|
597
|
+
};
|
|
598
|
+
if (fieldSchema.jsonType === "object") {
|
|
599
|
+
let innerFields = extractPaths(doc, fieldSchema, fieldPath);
|
|
600
|
+
result.push(thisFieldWithPath, ...innerFields);
|
|
601
|
+
} else if (fieldSchema.jsonType === "array" && fieldSchema.of.length && fieldSchema.of.some((item) => "fields" in item)) {
|
|
602
|
+
let { value: arrayValue } = extractWithPath(pathToString(fieldPath), doc)[0] ?? {};
|
|
603
|
+
if (result.push(thisFieldWithPath), arrayValue?.length) for (let item of arrayValue) {
|
|
604
|
+
if (!item._key) continue;
|
|
605
|
+
let itemPath = [...fieldPath, { _key: item._key }], itemSchema = fieldSchema.of.find((t) => t.name === item._type);
|
|
606
|
+
if (item._type || (itemSchema = fieldSchema.of[0]), itemSchema) {
|
|
607
|
+
let innerFields = extractPaths(doc, itemSchema, itemPath), arrayMember = {
|
|
608
|
+
path: itemPath,
|
|
609
|
+
name: item._key,
|
|
610
|
+
schemaType: itemSchema,
|
|
611
|
+
value: item
|
|
612
|
+
};
|
|
613
|
+
result.push(arrayMember, ...innerFields);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
} else result.push(thisFieldWithPath);
|
|
617
|
+
}
|
|
618
|
+
return result;
|
|
610
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
* Button component representing a single language in the translations menu.
|
|
622
|
+
* Displays the language name, an ID badge, and a contextual icon: checkmark
|
|
623
|
+
* for the current language, split-vertical for existing translations, or add
|
|
624
|
+
* for new translations. Clicking opens an existing translation in a new pane,
|
|
625
|
+
* or creates a new translation document via a Sanity transaction.
|
|
626
|
+
*/
|
|
611
627
|
function LanguageOption(props) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
628
|
+
let $ = c(45), { language, schemaType, documentId, current, source, sourceLanguageId, metadata, metadataId } = props, [userHasClicked, setUserHasClicked] = useState(!1), disabled = props.disabled || userHasClicked || current || !source || !sourceLanguageId || !metadataId, t0;
|
|
629
|
+
$[0] !== language.id || $[1] !== metadata ? (t0 = metadata?.translations.length ? metadata.translations.find((t) => t[LANGUAGE_FIELD_NAME] === language.id) : void 0, $[0] = language.id, $[1] = metadata, $[2] = t0) : t0 = $[2];
|
|
630
|
+
let translation = t0, { apiVersion, languageField, weakReferences, callback } = useDocumentInternationalizationContext(), t1;
|
|
631
|
+
$[3] === apiVersion ? t1 = $[4] : (t1 = { apiVersion }, $[3] = apiVersion, $[4] = t1);
|
|
632
|
+
let client = useClient(t1), toast = useToast(), open = useOpenInNewPane(translation?.value?._ref, schemaType.name), t2;
|
|
633
|
+
$[5] === open ? t2 = $[6] : (t2 = () => open(), $[5] = open, $[6] = t2);
|
|
634
|
+
let handleOpen = t2, t3;
|
|
635
|
+
$[7] !== callback || $[8] !== client || $[9] !== documentId || $[10] !== language.id || $[11] !== language.title || $[12] !== languageField || $[13] !== metadata?._createdAt || $[14] !== metadataId || $[15] !== schemaType || $[16] !== source || $[17] !== sourceLanguageId || $[18] !== toast || $[19] !== weakReferences ? (t3 = async () => {
|
|
636
|
+
if (!source) throw Error("Cannot create translation without source document");
|
|
637
|
+
if (!sourceLanguageId) throw Error("Cannot create translation without source language ID");
|
|
638
|
+
if (!metadataId) throw Error("Cannot create translation without a metadata ID");
|
|
639
|
+
setUserHasClicked(!0);
|
|
640
|
+
let transaction = client.transaction(), newTranslationDocumentId = uuid(), sourceReleaseId = isVersionId(source._id) ? getVersionFromId(source._id) : void 0, newTranslationDocument = {
|
|
641
|
+
...source,
|
|
642
|
+
_id: sourceReleaseId ? getVersionId(newTranslationDocumentId, sourceReleaseId) : getDraftId(newTranslationDocumentId),
|
|
643
|
+
[languageField]: language.id
|
|
644
|
+
};
|
|
645
|
+
newTranslationDocument = removeExcludedPaths(newTranslationDocument, schemaType), transaction.create(newTranslationDocument);
|
|
646
|
+
let sourceReference = createReference(sourceLanguageId, documentId, schemaType.name, !weakReferences), newTranslationReference = createReference(language.id, newTranslationDocumentId, schemaType.name, !weakReferences), newMetadataDocument = {
|
|
647
|
+
_id: metadataId,
|
|
648
|
+
_type: METADATA_SCHEMA_NAME,
|
|
649
|
+
schemaTypes: [schemaType.name],
|
|
650
|
+
translations: [sourceReference]
|
|
651
|
+
};
|
|
652
|
+
transaction.createIfNotExists(newMetadataDocument);
|
|
653
|
+
let metadataPatch = client.patch(metadataId).setIfMissing({ translations: [sourceReference] }).insert("after", "translations[-1]", [newTranslationReference]);
|
|
654
|
+
transaction.patch(metadataPatch), transaction.commit().then(() => {
|
|
655
|
+
let metadataExisted = !!metadata?._createdAt;
|
|
656
|
+
if (toast.push({
|
|
657
|
+
status: "success",
|
|
658
|
+
title: `Created "${language.title}" translation`,
|
|
659
|
+
description: metadataExisted ? "Updated Translations Metadata" : "Created Translations Metadata"
|
|
660
|
+
}), setUserHasClicked(!1), callback) return callback({
|
|
661
|
+
client,
|
|
662
|
+
sourceLanguageId,
|
|
663
|
+
sourceDocument: source,
|
|
664
|
+
newDocument: newTranslationDocument,
|
|
665
|
+
destinationLanguageId: language.id,
|
|
666
|
+
metaDocumentId: metadataId
|
|
667
|
+
});
|
|
668
|
+
}).catch((err) => (console.error(err), setUserHasClicked(!1), toast.push({
|
|
669
|
+
status: "error",
|
|
670
|
+
title: "Error creating translation",
|
|
671
|
+
description: err.message
|
|
672
|
+
})));
|
|
673
|
+
}, $[7] = callback, $[8] = client, $[9] = documentId, $[10] = language.id, $[11] = language.title, $[12] = languageField, $[13] = metadata?._createdAt, $[14] = metadataId, $[15] = schemaType, $[16] = source, $[17] = sourceLanguageId, $[18] = toast, $[19] = weakReferences, $[20] = t3) : t3 = $[20], metadata?._createdAt;
|
|
674
|
+
let handleCreate = t3, message;
|
|
675
|
+
current ? message = "Current document" : translation ? message = `Open ${language.title} translation` : translation || (message = `Create new ${language.title} translation`);
|
|
676
|
+
let t4;
|
|
677
|
+
$[21] === message ? t4 = $[22] : (t4 = /* @__PURE__ */ jsx(Box, {
|
|
678
|
+
padding: 2,
|
|
679
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
680
|
+
muted: !0,
|
|
681
|
+
size: 1,
|
|
682
|
+
children: message
|
|
683
|
+
})
|
|
684
|
+
}), $[21] = message, $[22] = t4);
|
|
685
|
+
let t5;
|
|
686
|
+
$[23] === Symbol.for("react.memo_cache_sentinel") ? (t5 = ["right", "left"], $[23] = t5) : t5 = $[23];
|
|
687
|
+
let t6 = translation ? handleOpen : handleCreate, t7 = current && disabled ? "default" : "bleed", t8;
|
|
688
|
+
$[24] !== current || $[25] !== disabled || $[26] !== translation ? (t8 = disabled && !current ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(Text, {
|
|
689
|
+
size: 2,
|
|
690
|
+
children: jsx(translation ? SplitVerticalIcon : current ? CheckmarkIcon : AddIcon, {})
|
|
691
|
+
}), $[24] = current, $[25] = disabled, $[26] = translation, $[27] = t8) : t8 = $[27];
|
|
692
|
+
let t9;
|
|
693
|
+
$[28] === language.title ? t9 = $[29] : (t9 = /* @__PURE__ */ jsx(Box, {
|
|
694
|
+
flex: 1,
|
|
695
|
+
children: /* @__PURE__ */ jsx(Text, { children: language.title })
|
|
696
|
+
}), $[28] = language.title, $[29] = t9);
|
|
697
|
+
let t10 = disabled || current ? "default" : "primary", t11;
|
|
698
|
+
$[30] !== language.id || $[31] !== t10 ? (t11 = /* @__PURE__ */ jsx(Badge, {
|
|
699
|
+
tone: t10,
|
|
700
|
+
children: language.id
|
|
701
|
+
}), $[30] = language.id, $[31] = t10, $[32] = t11) : t11 = $[32];
|
|
702
|
+
let t12;
|
|
703
|
+
$[33] !== t11 || $[34] !== t8 || $[35] !== t9 ? (t12 = /* @__PURE__ */ jsxs(Flex, {
|
|
704
|
+
gap: 3,
|
|
705
|
+
align: "center",
|
|
706
|
+
children: [
|
|
707
|
+
t8,
|
|
708
|
+
t9,
|
|
709
|
+
t11
|
|
710
|
+
]
|
|
711
|
+
}), $[33] = t11, $[34] = t8, $[35] = t9, $[36] = t12) : t12 = $[36];
|
|
712
|
+
let t13;
|
|
713
|
+
$[37] !== disabled || $[38] !== t12 || $[39] !== t6 || $[40] !== t7 ? (t13 = /* @__PURE__ */ jsx(Button, {
|
|
714
|
+
onClick: t6,
|
|
715
|
+
mode: t7,
|
|
716
|
+
disabled,
|
|
717
|
+
children: t12
|
|
718
|
+
}), $[37] = disabled, $[38] = t12, $[39] = t6, $[40] = t7, $[41] = t13) : t13 = $[41];
|
|
719
|
+
let t14;
|
|
720
|
+
return $[42] !== t13 || $[43] !== t4 ? (t14 = /* @__PURE__ */ jsx(Tooltip, {
|
|
721
|
+
animate: !0,
|
|
722
|
+
content: t4,
|
|
723
|
+
fallbackPlacements: t5,
|
|
724
|
+
placement: "top",
|
|
725
|
+
portal: !0,
|
|
726
|
+
children: t13
|
|
727
|
+
}), $[42] = t13, $[43] = t4, $[44] = t14) : t14 = $[44], t14;
|
|
710
728
|
}
|
|
729
|
+
/**
|
|
730
|
+
* Button component that patches the current document's language field to
|
|
731
|
+
* the selected language. Displays the language name and ID badge, and shows
|
|
732
|
+
* a success or error toast after the patch operation completes.
|
|
733
|
+
*/
|
|
711
734
|
function LanguagePatch(props) {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
735
|
+
let $ = c(21), { language, source } = props, { apiVersion, languageField } = useDocumentInternationalizationContext(), disabled = props.disabled || !source, t0;
|
|
736
|
+
$[0] === apiVersion ? t0 = $[1] : (t0 = { apiVersion }, $[0] = apiVersion, $[1] = t0);
|
|
737
|
+
let client = useClient(t0), toast = useToast(), t1;
|
|
738
|
+
$[2] !== client || $[3] !== language.id || $[4] !== language.title || $[5] !== languageField || $[6] !== source || $[7] !== toast ? (t1 = () => {
|
|
739
|
+
if (!source) throw Error("Cannot patch missing document");
|
|
740
|
+
let currentId = source._id;
|
|
741
|
+
client.patch(currentId).set({ [languageField]: language.id }).commit().then(() => {
|
|
742
|
+
toast.push({
|
|
743
|
+
title: `Set document language to ${language.title}`,
|
|
744
|
+
status: "success"
|
|
745
|
+
});
|
|
746
|
+
}).catch((err) => (console.error(err), toast.push({
|
|
747
|
+
title: `Failed to set document language to ${language.title}`,
|
|
748
|
+
status: "error"
|
|
749
|
+
})));
|
|
750
|
+
}, $[2] = client, $[3] = language.id, $[4] = language.title, $[5] = languageField, $[6] = source, $[7] = toast, $[8] = t1) : t1 = $[8];
|
|
751
|
+
let handleClick = t1, t2;
|
|
752
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Text, {
|
|
753
|
+
size: 2,
|
|
754
|
+
children: /* @__PURE__ */ jsx(EditIcon, {})
|
|
755
|
+
}), $[9] = t2) : t2 = $[9];
|
|
756
|
+
let t3;
|
|
757
|
+
$[10] === language.title ? t3 = $[11] : (t3 = /* @__PURE__ */ jsx(Box, {
|
|
758
|
+
flex: 1,
|
|
759
|
+
children: /* @__PURE__ */ jsx(Text, { children: language.title })
|
|
760
|
+
}), $[10] = language.title, $[11] = t3);
|
|
761
|
+
let t4;
|
|
762
|
+
$[12] === language.id ? t4 = $[13] : (t4 = /* @__PURE__ */ jsx(Badge, { children: language.id }), $[12] = language.id, $[13] = t4);
|
|
763
|
+
let t5;
|
|
764
|
+
$[14] !== t3 || $[15] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Flex, {
|
|
765
|
+
gap: 3,
|
|
766
|
+
align: "center",
|
|
767
|
+
children: [
|
|
768
|
+
t2,
|
|
769
|
+
t3,
|
|
770
|
+
t4
|
|
771
|
+
]
|
|
772
|
+
}), $[14] = t3, $[15] = t4, $[16] = t5) : t5 = $[16];
|
|
773
|
+
let t6;
|
|
774
|
+
return $[17] !== disabled || $[18] !== handleClick || $[19] !== t5 ? (t6 = /* @__PURE__ */ jsx(Button, {
|
|
775
|
+
mode: "bleed",
|
|
776
|
+
onClick: handleClick,
|
|
777
|
+
disabled,
|
|
778
|
+
justify: "flex-start",
|
|
779
|
+
children: t5
|
|
780
|
+
}), $[17] = disabled, $[18] = handleClick, $[19] = t5, $[20] = t6) : t6 = $[20], t6;
|
|
756
781
|
}
|
|
757
782
|
function ConstrainedBox(t0) {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
let t2;
|
|
766
|
-
return $[1] !== children ? (t2 = /* @__PURE__ */ jsx(Box, { style: t1, children }), $[1] = children, $[2] = t2) : t2 = $[2], t2;
|
|
783
|
+
let $ = c(3), { children } = t0, t1;
|
|
784
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = { maxWidth: 280 }, $[0] = t1) : t1 = $[0];
|
|
785
|
+
let t2;
|
|
786
|
+
return $[1] === children ? t2 = $[2] : (t2 = /* @__PURE__ */ jsx(Box, {
|
|
787
|
+
style: t1,
|
|
788
|
+
children
|
|
789
|
+
}), $[1] = children, $[2] = t2), t2;
|
|
767
790
|
}
|
|
791
|
+
/**
|
|
792
|
+
* Presentational component that renders a caution-toned card with centered
|
|
793
|
+
* text inside a constrained-width box. Used to display warning messages
|
|
794
|
+
* in the internationalization UI.
|
|
795
|
+
*/
|
|
768
796
|
function Warning(t0) {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
797
|
+
let $ = c(2), { children } = t0, t1;
|
|
798
|
+
return $[0] === children ? t1 = $[1] : (t1 = /* @__PURE__ */ jsx(Card, {
|
|
799
|
+
tone: "caution",
|
|
800
|
+
padding: 3,
|
|
801
|
+
children: /* @__PURE__ */ jsx(Flex, {
|
|
802
|
+
justify: "center",
|
|
803
|
+
children: /* @__PURE__ */ jsx(ConstrainedBox, { children: /* @__PURE__ */ jsx(Text, {
|
|
804
|
+
size: 1,
|
|
805
|
+
align: "center",
|
|
806
|
+
children
|
|
807
|
+
}) })
|
|
808
|
+
})
|
|
809
|
+
}), $[0] = children, $[1] = t1), t1;
|
|
774
810
|
}
|
|
775
811
|
function DocumentInternationalizationMenu(props) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
812
|
+
let $ = c(36), { documentId } = props, schemaType = props.schemaType, { languageField, supportedLanguages } = useDocumentInternationalizationContext(), [query, setQuery] = useState(""), t0;
|
|
813
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (event) => {
|
|
814
|
+
event.currentTarget.value ? setQuery(event.currentTarget.value) : setQuery("");
|
|
815
|
+
}, $[0] = t0) : t0 = $[0];
|
|
816
|
+
let handleQuery = t0, [open, setOpen] = useState(!1), t1;
|
|
817
|
+
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setOpen(_temp$3), $[1] = t1) : t1 = $[1];
|
|
818
|
+
let handleClick = t1, buttonRef = useRef(null), popoverRef = useRef(null), t2;
|
|
819
|
+
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(!1), $[2] = t2) : t2 = $[2];
|
|
820
|
+
let handleClickOutside = t2, t3;
|
|
821
|
+
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => [buttonRef.current, popoverRef.current], $[3] = t3) : t3 = $[3], useClickOutsideEvent(handleClickOutside, t3);
|
|
822
|
+
let { data, loading, error } = useTranslationMetadata(documentId), metadata = Array.isArray(data) && data.length ? data[0] : null;
|
|
823
|
+
metadata?._id;
|
|
824
|
+
let t4;
|
|
825
|
+
bb0: {
|
|
826
|
+
if (loading) {
|
|
827
|
+
t4 = null;
|
|
828
|
+
break bb0;
|
|
829
|
+
}
|
|
830
|
+
let t5;
|
|
831
|
+
$[4] === metadata?._id ? t5 = $[5] : (t5 = metadata?._id ?? uuid(), $[4] = metadata?._id, $[5] = t5), t4 = t5;
|
|
832
|
+
}
|
|
833
|
+
let metadataId = t4, { selectedReleaseId } = usePerspective(), { draft, published, version } = useEditState(documentId, schemaType.name, "default", selectedReleaseId), source = version || draft || published, documentIsInOneMetadataDocument = Array.isArray(data) && data.length <= 1, rawLanguageValue = source?.[languageField], sourceLanguageId = typeof rawLanguageValue == "string" ? rawLanguageValue : void 0, t5;
|
|
834
|
+
if ($[6] !== sourceLanguageId || $[7] !== supportedLanguages) {
|
|
835
|
+
let t6;
|
|
836
|
+
$[9] === sourceLanguageId ? t6 = $[10] : (t6 = (l) => l.id === sourceLanguageId, $[9] = sourceLanguageId, $[10] = t6), t5 = supportedLanguages.some(t6), $[6] = sourceLanguageId, $[7] = supportedLanguages, $[8] = t5;
|
|
837
|
+
} else t5 = $[8];
|
|
838
|
+
let sourceLanguageIsValid = t5, t6;
|
|
839
|
+
$[11] === supportedLanguages ? t6 = $[12] : (t6 = supportedLanguages.every(_temp2$1), $[11] = supportedLanguages, $[12] = t6);
|
|
840
|
+
let valid = t6;
|
|
841
|
+
valid || console.warn("Not all languages are valid. It should be an array of objects with an \"id\" and \"title\" property. Or a function that returns an array of objects with an \"id\" and \"title\" property.", supportedLanguages);
|
|
842
|
+
let allLanguagesAreValid = valid, t7;
|
|
843
|
+
$[13] !== allLanguagesAreValid || $[14] !== data || $[15] !== documentId || $[16] !== documentIsInOneMetadataDocument || $[17] !== error || $[18] !== loading || $[19] !== metadata || $[20] !== metadataId || $[21] !== query || $[22] !== schemaType || $[23] !== source || $[24] !== sourceLanguageId || $[25] !== sourceLanguageIsValid || $[26] !== supportedLanguages ? (t7 = /* @__PURE__ */ jsx(Box, {
|
|
844
|
+
padding: 1,
|
|
845
|
+
children: error ? /* @__PURE__ */ jsx(Card, {
|
|
846
|
+
tone: "critical",
|
|
847
|
+
padding: 1,
|
|
848
|
+
children: /* @__PURE__ */ jsx(Text, { children: "There was an error returning translations metadata" })
|
|
849
|
+
}) : /* @__PURE__ */ jsxs(Stack, {
|
|
850
|
+
gap: 1,
|
|
851
|
+
children: [
|
|
852
|
+
/* @__PURE__ */ jsx(LanguageManage, {
|
|
853
|
+
id: metadata?._id,
|
|
854
|
+
documentId,
|
|
855
|
+
metadataId,
|
|
856
|
+
schemaType,
|
|
857
|
+
sourceLanguageId
|
|
858
|
+
}),
|
|
859
|
+
supportedLanguages.length > 4 ? /* @__PURE__ */ jsx(TextInput, {
|
|
860
|
+
onChange: handleQuery,
|
|
861
|
+
value: query,
|
|
862
|
+
placeholder: "Filter languages"
|
|
863
|
+
}) : null,
|
|
864
|
+
supportedLanguages.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [loading ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
865
|
+
data && documentIsInOneMetadataDocument ? null : /* @__PURE__ */ jsx(Warning, { children: "This document has been found in more than one Translations Metadata document" }),
|
|
866
|
+
allLanguagesAreValid ? null : /* @__PURE__ */ jsx(Warning, { children: "Not all language objects are valid. See the console." }),
|
|
867
|
+
sourceLanguageId ? null : /* @__PURE__ */ jsxs(Warning, { children: ["Choose a language to apply to ", /* @__PURE__ */ jsx("strong", { children: "this Document" })] }),
|
|
868
|
+
sourceLanguageId && !sourceLanguageIsValid ? /* @__PURE__ */ jsxs(Warning, { children: [
|
|
869
|
+
"Select a supported language. Current language value:",
|
|
870
|
+
" ",
|
|
871
|
+
/* @__PURE__ */ jsx("code", { children: sourceLanguageId })
|
|
872
|
+
] }) : null
|
|
873
|
+
] }), supportedLanguages.filter((language) => query ? language.title.toLowerCase().includes(query.toLowerCase()) : !0).map((language_0) => !loading && sourceLanguageId && sourceLanguageIsValid ? /* @__PURE__ */ jsx(LanguageOption, {
|
|
874
|
+
language: language_0,
|
|
875
|
+
schemaType,
|
|
876
|
+
documentId,
|
|
877
|
+
disabled: !allLanguagesAreValid,
|
|
878
|
+
current: language_0.id === sourceLanguageId,
|
|
879
|
+
metadata,
|
|
880
|
+
metadataId,
|
|
881
|
+
source,
|
|
882
|
+
sourceLanguageId
|
|
883
|
+
}, language_0.id) : /* @__PURE__ */ jsx(LanguagePatch, {
|
|
884
|
+
source,
|
|
885
|
+
language: language_0,
|
|
886
|
+
disabled: (loading || !allLanguagesAreValid || metadata?.translations.filter((t) => t?.value?._ref !== documentId).some((t_0) => t_0[LANGUAGE_FIELD_NAME] === language_0.id)) ?? !1
|
|
887
|
+
}, language_0.id))] }) : null
|
|
888
|
+
]
|
|
889
|
+
})
|
|
890
|
+
}), $[13] = allLanguagesAreValid, $[14] = data, $[15] = documentId, $[16] = documentIsInOneMetadataDocument, $[17] = error, $[18] = loading, $[19] = metadata, $[20] = metadataId, $[21] = query, $[22] = schemaType, $[23] = source, $[24] = sourceLanguageId, $[25] = sourceLanguageIsValid, $[26] = supportedLanguages, $[27] = t7) : t7 = $[27];
|
|
891
|
+
let content = t7, issueWithTranslations = !loading && sourceLanguageId && !sourceLanguageIsValid;
|
|
892
|
+
if (!documentId || !schemaType || !schemaType.name) return null;
|
|
893
|
+
let t8 = !source, t9 = !source || loading || !issueWithTranslations ? void 0 : "caution", t10;
|
|
894
|
+
$[28] !== open || $[29] !== t8 || $[30] !== t9 ? (t10 = /* @__PURE__ */ jsx(Button, {
|
|
895
|
+
text: "Translations",
|
|
896
|
+
mode: "bleed",
|
|
897
|
+
disabled: t8,
|
|
898
|
+
tone: t9,
|
|
899
|
+
icon: TranslateIcon,
|
|
900
|
+
onClick: handleClick,
|
|
901
|
+
ref: buttonRef,
|
|
902
|
+
selected: open
|
|
903
|
+
}), $[28] = open, $[29] = t8, $[30] = t9, $[31] = t10) : t10 = $[31];
|
|
904
|
+
let t11;
|
|
905
|
+
return $[32] !== content || $[33] !== open || $[34] !== t10 ? (t11 = /* @__PURE__ */ jsx(Popover, {
|
|
906
|
+
animate: !0,
|
|
907
|
+
constrainSize: !0,
|
|
908
|
+
content,
|
|
909
|
+
open,
|
|
910
|
+
portal: !0,
|
|
911
|
+
ref: popoverRef,
|
|
912
|
+
overflow: "auto",
|
|
913
|
+
tone: "default",
|
|
914
|
+
children: t10
|
|
915
|
+
}), $[32] = content, $[33] = open, $[34] = t10, $[35] = t11) : t11 = $[35], t11;
|
|
858
916
|
}
|
|
859
917
|
function _temp2$1(l_0) {
|
|
860
|
-
|
|
918
|
+
return l_0.id && l_0.title;
|
|
861
919
|
}
|
|
862
920
|
function _temp$3(o) {
|
|
863
|
-
|
|
921
|
+
return !o;
|
|
864
922
|
}
|
|
923
|
+
/**
|
|
924
|
+
* Document action that deletes a translation metadata document along with all
|
|
925
|
+
* its referenced translation documents. Opens a confirmation dialog showing
|
|
926
|
+
* how many translations will be deleted. Executes a single transaction that
|
|
927
|
+
* unsets the translations array, deletes each referenced document (both
|
|
928
|
+
* published and draft), and finally deletes the metadata document itself.
|
|
929
|
+
*/
|
|
865
930
|
const useDeleteMetadataAction = (props) => {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
message: translations.length === 1 ? "Delete 1 translation and this document" : `Delete all ${translations.length} translations and this document`
|
|
914
|
-
}, $[10] = isDialogOpen, $[11] = onProceed, $[12] = translations, $[13] = t6) : t6 = $[13];
|
|
915
|
-
let t7;
|
|
916
|
-
return $[14] !== t4 || $[15] !== t6 ? (t7 = {
|
|
917
|
-
label: "Delete all translations",
|
|
918
|
-
disabled: t4,
|
|
919
|
-
icon: TrashIcon,
|
|
920
|
-
tone: "critical",
|
|
921
|
-
onHandle: t5,
|
|
922
|
-
dialog: t6
|
|
923
|
-
}, $[14] = t4, $[15] = t6, $[16] = t7) : t7 = $[16], t7;
|
|
931
|
+
let $ = c(17), { id: documentId, published, draft } = props, doc = draft || published, [isDialogOpen, setDialogOpen] = useState(!1), t0;
|
|
932
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setDialogOpen(!1), $[0] = t0) : t0 = $[0];
|
|
933
|
+
let onClose = t0, t1;
|
|
934
|
+
$[1] === doc ? t1 = $[2] : (t1 = doc && Array.isArray(doc[TRANSLATIONS_ARRAY_NAME]) ? doc[TRANSLATIONS_ARRAY_NAME] : [], $[1] = doc, $[2] = t1);
|
|
935
|
+
let translations = t1, toast = useToast(), t2;
|
|
936
|
+
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { apiVersion: API_VERSION }, $[3] = t2) : t2 = $[3];
|
|
937
|
+
let client = useClient(t2), t3;
|
|
938
|
+
$[4] !== client || $[5] !== documentId || $[6] !== toast || $[7] !== translations ? (t3 = () => {
|
|
939
|
+
let tx = client.transaction();
|
|
940
|
+
tx.patch(documentId, _temp$2), translations.length > 0 && translations.forEach((translation) => {
|
|
941
|
+
tx.delete(translation.value._ref), tx.delete(`drafts.${translation.value._ref}`);
|
|
942
|
+
}), tx.delete(documentId), tx.delete(`drafts.${documentId}`), tx.commit().then(() => {
|
|
943
|
+
onClose(), toast.push({
|
|
944
|
+
status: "success",
|
|
945
|
+
title: "Deleted document and translations"
|
|
946
|
+
});
|
|
947
|
+
}).catch((err) => {
|
|
948
|
+
toast.push({
|
|
949
|
+
status: "error",
|
|
950
|
+
title: "Failed to delete document and translations",
|
|
951
|
+
description: err.message
|
|
952
|
+
});
|
|
953
|
+
});
|
|
954
|
+
}, $[4] = client, $[5] = documentId, $[6] = toast, $[7] = translations, $[8] = t3) : t3 = $[8];
|
|
955
|
+
let onProceed = t3, t4 = !doc || !translations.length, t5;
|
|
956
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
|
957
|
+
setDialogOpen(!0);
|
|
958
|
+
}, $[9] = t5) : t5 = $[9];
|
|
959
|
+
let t6;
|
|
960
|
+
$[10] !== isDialogOpen || $[11] !== onProceed || $[12] !== translations ? (t6 = isDialogOpen && {
|
|
961
|
+
type: "confirm",
|
|
962
|
+
onCancel: onClose,
|
|
963
|
+
onConfirm: () => {
|
|
964
|
+
onProceed(), onClose();
|
|
965
|
+
},
|
|
966
|
+
tone: "critical",
|
|
967
|
+
message: translations.length === 1 ? "Delete 1 translation and this document" : `Delete all ${translations.length} translations and this document`
|
|
968
|
+
}, $[10] = isDialogOpen, $[11] = onProceed, $[12] = translations, $[13] = t6) : t6 = $[13];
|
|
969
|
+
let t7;
|
|
970
|
+
return $[14] !== t4 || $[15] !== t6 ? (t7 = {
|
|
971
|
+
label: "Delete all translations",
|
|
972
|
+
disabled: t4,
|
|
973
|
+
icon: TrashIcon,
|
|
974
|
+
tone: "critical",
|
|
975
|
+
onHandle: t5,
|
|
976
|
+
dialog: t6
|
|
977
|
+
}, $[14] = t4, $[15] = t6, $[16] = t7) : t7 = $[16], t7;
|
|
924
978
|
};
|
|
925
979
|
function _temp$2(patch) {
|
|
926
|
-
|
|
980
|
+
return patch.unset([TRANSLATIONS_ARRAY_NAME]);
|
|
927
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* Document badge that displays the language identifier of a document.
|
|
984
|
+
* Reads the configured `languageField` from the version, draft or published
|
|
985
|
+
* document, looks up the matching language in `supportedLanguages` to resolve
|
|
986
|
+
* the title, and returns a badge descriptor with `primary` color. Returns
|
|
987
|
+
* `null` when no document exists or the language field is empty/non-string.
|
|
988
|
+
*/
|
|
928
989
|
function LanguageBadge(props) {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
label: language?.id ?? languageId,
|
|
938
|
-
title: language?.title ?? void 0,
|
|
939
|
-
color: "primary"
|
|
940
|
-
};
|
|
990
|
+
let source = props?.version || props?.draft || props?.published, { languageField, supportedLanguages } = useDocumentInternationalizationContext(), languageId = source?.[languageField];
|
|
991
|
+
if (!languageId || typeof languageId != "string") return null;
|
|
992
|
+
let language = Array.isArray(supportedLanguages) ? supportedLanguages.find((l) => l.id === languageId) : null;
|
|
993
|
+
return {
|
|
994
|
+
label: language?.id ?? languageId,
|
|
995
|
+
title: language?.title ?? void 0,
|
|
996
|
+
color: "primary"
|
|
997
|
+
};
|
|
941
998
|
}
|
|
942
999
|
function DocumentCheck(props) {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1000
|
+
let $ = c(25), { id, onCheckComplete, addInvalidId, removeInvalidId, addDraftId, removeDraftId } = props, editState = useEditState(id, ""), { isValidating, validation: t0 } = useValidationStatus(id, editState.draft?._type ?? editState.published?._type ?? "", !1), t1;
|
|
1001
|
+
$[0] === t0 ? t1 = $[1] : (t1 = t0 === void 0 ? [] : t0, $[0] = t0, $[1] = t1);
|
|
1002
|
+
let validation = t1, schema = useSchema(), t2;
|
|
1003
|
+
$[2] !== isValidating || $[3] !== validation ? (t2 = !isValidating && validation.some(_temp$1), $[2] = isValidating, $[3] = validation, $[4] = t2) : t2 = $[4];
|
|
1004
|
+
let validationHasErrors = t2, t3, t4;
|
|
1005
|
+
if ($[5] !== addDraftId || $[6] !== addInvalidId || $[7] !== editState.draft || $[8] !== id || $[9] !== isValidating || $[10] !== onCheckComplete || $[11] !== removeDraftId || $[12] !== removeInvalidId || $[13] !== validationHasErrors ? (t3 = () => {
|
|
1006
|
+
validationHasErrors ? addInvalidId(id) : removeInvalidId(id), editState.draft ? addDraftId(id) : removeDraftId(id), isValidating || onCheckComplete(id);
|
|
1007
|
+
}, t4 = [
|
|
1008
|
+
addDraftId,
|
|
1009
|
+
addInvalidId,
|
|
1010
|
+
editState.draft,
|
|
1011
|
+
id,
|
|
1012
|
+
isValidating,
|
|
1013
|
+
onCheckComplete,
|
|
1014
|
+
removeDraftId,
|
|
1015
|
+
removeInvalidId,
|
|
1016
|
+
validationHasErrors
|
|
1017
|
+
], $[5] = addDraftId, $[6] = addInvalidId, $[7] = editState.draft, $[8] = id, $[9] = isValidating, $[10] = onCheckComplete, $[11] = removeDraftId, $[12] = removeInvalidId, $[13] = validationHasErrors, $[14] = t3, $[15] = t4) : (t3 = $[14], t4 = $[15]), useEffect(t3, t4), !editState.draft) return null;
|
|
1018
|
+
let t5;
|
|
1019
|
+
$[16] !== editState.draft._type || $[17] !== schema ? (t5 = schema.get(editState.draft._type), $[16] = editState.draft._type, $[17] = schema, $[18] = t5) : t5 = $[18];
|
|
1020
|
+
let schemaType = t5, t6 = validationHasErrors ? "critical" : "positive", t7;
|
|
1021
|
+
$[19] !== editState.draft || $[20] !== schemaType ? (t7 = editState.draft && schemaType ? /* @__PURE__ */ jsx(Preview, {
|
|
1022
|
+
layout: "default",
|
|
1023
|
+
value: editState.draft,
|
|
1024
|
+
schemaType
|
|
1025
|
+
}) : /* @__PURE__ */ jsx(Spinner, {}), $[19] = editState.draft, $[20] = schemaType, $[21] = t7) : t7 = $[21];
|
|
1026
|
+
let t8;
|
|
1027
|
+
return $[22] !== t6 || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsx(Card, {
|
|
1028
|
+
border: !0,
|
|
1029
|
+
padding: 2,
|
|
1030
|
+
tone: t6,
|
|
1031
|
+
children: t7
|
|
1032
|
+
}), $[22] = t6, $[23] = t7, $[24] = t8) : t8 = $[24], t8;
|
|
972
1033
|
}
|
|
973
1034
|
function _temp$1(item) {
|
|
974
|
-
|
|
1035
|
+
return item.level === "error";
|
|
975
1036
|
}
|
|
976
1037
|
function InfoIcon(props) {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1038
|
+
let $ = c(11), { text, icon, tone, children } = props, Icon = icon, t0;
|
|
1039
|
+
$[0] !== children || $[1] !== text ? (t0 = children ? /* @__PURE__ */ jsx(Fragment, { children }) : /* @__PURE__ */ jsx(Box, {
|
|
1040
|
+
padding: 2,
|
|
1041
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
1042
|
+
size: 1,
|
|
1043
|
+
children: text
|
|
1044
|
+
})
|
|
1045
|
+
}), $[0] = children, $[1] = text, $[2] = t0) : t0 = $[2];
|
|
1046
|
+
let t1;
|
|
1047
|
+
$[3] === Icon ? t1 = $[4] : (t1 = /* @__PURE__ */ jsx(Icon, {}), $[3] = Icon, $[4] = t1);
|
|
1048
|
+
let t2;
|
|
1049
|
+
$[5] !== t1 || $[6] !== tone ? (t2 = /* @__PURE__ */ jsx(TextWithTone, {
|
|
1050
|
+
tone,
|
|
1051
|
+
size: 1,
|
|
1052
|
+
children: t1
|
|
1053
|
+
}), $[5] = t1, $[6] = tone, $[7] = t2) : t2 = $[7];
|
|
1054
|
+
let t3;
|
|
1055
|
+
return $[8] !== t0 || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsx(Tooltip, {
|
|
1056
|
+
animate: !0,
|
|
1057
|
+
portal: !0,
|
|
1058
|
+
content: t0,
|
|
1059
|
+
children: t2
|
|
1060
|
+
}), $[8] = t0, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
|
|
991
1061
|
}
|
|
992
1062
|
function Info() {
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1063
|
+
let $ = c(4), t0;
|
|
1064
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { maxWidth: 250 }, $[0] = t0) : t0 = $[0];
|
|
1065
|
+
let t1;
|
|
1066
|
+
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, {
|
|
1067
|
+
size: 1,
|
|
1068
|
+
children: "Bulk publishing uses the Scheduling API."
|
|
1069
|
+
}) }), $[1] = t1) : t1 = $[1];
|
|
1070
|
+
let t2;
|
|
1071
|
+
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, {
|
|
1072
|
+
size: 1,
|
|
1073
|
+
children: "Customized Document Actions in the Studio will not execute. Webhooks will execute."
|
|
1074
|
+
}) }), $[2] = t2) : t2 = $[2];
|
|
1075
|
+
let t3;
|
|
1076
|
+
return $[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(InfoIcon, {
|
|
1077
|
+
icon: InfoOutlineIcon,
|
|
1078
|
+
tone: "primary",
|
|
1079
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1080
|
+
padding: 3,
|
|
1081
|
+
gap: 4,
|
|
1082
|
+
style: t0,
|
|
1083
|
+
children: [
|
|
1084
|
+
t1,
|
|
1085
|
+
t2,
|
|
1086
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, {
|
|
1087
|
+
size: 1,
|
|
1088
|
+
children: "Validation is checked before rendering the button below, but the Scheduling API will not check for – or enforce – validation."
|
|
1089
|
+
}) })
|
|
1090
|
+
]
|
|
1091
|
+
})
|
|
1092
|
+
}), $[3] = t3) : t3 = $[3], t3;
|
|
1008
1093
|
}
|
|
1009
1094
|
function BulkPublish(props) {
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1095
|
+
let $ = c(23), { translations } = props, t0;
|
|
1096
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: API_VERSION }, $[0] = t0) : t0 = $[0];
|
|
1097
|
+
let client = useClient(t0), { projectId, dataset } = useWorkspace(), toast = useToast(), [invalidIds, setInvalidIds] = useState(null), t1;
|
|
1098
|
+
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[1] = t1) : t1 = $[1];
|
|
1099
|
+
let [checkedIds, setCheckedIds] = useState(t1), t2;
|
|
1100
|
+
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = (id) => {
|
|
1101
|
+
setCheckedIds((ids) => Array.from(/* @__PURE__ */ new Set([...ids, id])));
|
|
1102
|
+
}, $[2] = t2) : t2 = $[2];
|
|
1103
|
+
let onCheckComplete = t2, [open, setOpen] = useState(!1), t3;
|
|
1104
|
+
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setOpen(!0), $[3] = t3) : t3 = $[3];
|
|
1105
|
+
let onOpen = t3, t4;
|
|
1106
|
+
$[4] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setOpen(!1), $[4] = t4) : t4 = $[4];
|
|
1107
|
+
let onClose = t4, t5;
|
|
1108
|
+
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t5 = (id_0) => {
|
|
1109
|
+
setInvalidIds((ids_0) => ids_0 ? Array.from(/* @__PURE__ */ new Set([...ids_0, id_0])) : [id_0]);
|
|
1110
|
+
}, $[5] = t5) : t5 = $[5];
|
|
1111
|
+
let addInvalidId = t5, t6;
|
|
1112
|
+
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t6 = (id_1) => {
|
|
1113
|
+
setInvalidIds((ids_1) => ids_1 ? ids_1.filter((i) => i !== id_1) : []);
|
|
1114
|
+
}, $[6] = t6) : t6 = $[6];
|
|
1115
|
+
let removeInvalidId = t6, t7;
|
|
1116
|
+
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t7 = [], $[7] = t7) : t7 = $[7];
|
|
1117
|
+
let [draftIds, setDraftIds] = useState(t7), t8;
|
|
1118
|
+
$[8] === Symbol.for("react.memo_cache_sentinel") ? (t8 = (id_2) => {
|
|
1119
|
+
setDraftIds((ids_2) => Array.from(/* @__PURE__ */ new Set([...ids_2, id_2])));
|
|
1120
|
+
}, $[8] = t8) : t8 = $[8];
|
|
1121
|
+
let addDraftId = t8, t9;
|
|
1122
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t9 = (id_3) => {
|
|
1123
|
+
setDraftIds((ids_3) => ids_3.filter((i_0) => i_0 !== id_3));
|
|
1124
|
+
}, $[9] = t9) : t9 = $[9];
|
|
1125
|
+
let removeDraftId = t9, t10;
|
|
1126
|
+
$[10] !== client || $[11] !== dataset || $[12] !== projectId || $[13] !== toast || $[14] !== translations ? (t10 = () => {
|
|
1127
|
+
let body = translations.map(_temp);
|
|
1128
|
+
client.request({
|
|
1129
|
+
uri: `/publish/${projectId}/${dataset}`,
|
|
1130
|
+
method: "POST",
|
|
1131
|
+
body
|
|
1132
|
+
}).then(() => {
|
|
1133
|
+
toast.push({
|
|
1134
|
+
status: "success",
|
|
1135
|
+
title: "Success",
|
|
1136
|
+
description: "Bulk publish complete"
|
|
1137
|
+
});
|
|
1138
|
+
}).catch((err) => {
|
|
1139
|
+
console.error(err), toast.push({
|
|
1140
|
+
status: "error",
|
|
1141
|
+
title: "Error",
|
|
1142
|
+
description: "Bulk publish failed"
|
|
1143
|
+
});
|
|
1144
|
+
});
|
|
1145
|
+
}, $[10] = client, $[11] = dataset, $[12] = projectId, $[13] = toast, $[14] = translations, $[15] = t10) : t10 = $[15];
|
|
1146
|
+
let handleBulkPublish = t10, disabled = checkedIds.length !== translations.length || !!(invalidIds && invalidIds?.length > 0) || !draftIds.length, t11;
|
|
1147
|
+
return $[16] !== disabled || $[17] !== draftIds || $[18] !== handleBulkPublish || $[19] !== invalidIds || $[20] !== open || $[21] !== translations ? (t11 = translations?.length > 0 ? /* @__PURE__ */ jsx(Card, {
|
|
1148
|
+
padding: 4,
|
|
1149
|
+
border: !0,
|
|
1150
|
+
radius: 2,
|
|
1151
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1152
|
+
gap: 3,
|
|
1153
|
+
children: [
|
|
1154
|
+
/* @__PURE__ */ jsxs(Inline, {
|
|
1155
|
+
gap: 3,
|
|
1156
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
1157
|
+
weight: "bold",
|
|
1158
|
+
size: 1,
|
|
1159
|
+
children: "Bulk publishing"
|
|
1160
|
+
}), /* @__PURE__ */ jsx(Info, {})]
|
|
1161
|
+
}),
|
|
1162
|
+
/* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(Button, {
|
|
1163
|
+
onClick: onOpen,
|
|
1164
|
+
text: "Prepare bulk publishing",
|
|
1165
|
+
mode: "ghost"
|
|
1166
|
+
}) }),
|
|
1167
|
+
open && /* @__PURE__ */ jsx(Dialog, {
|
|
1168
|
+
animate: !0,
|
|
1169
|
+
header: "Bulk publishing",
|
|
1170
|
+
id: "bulk-publish-dialog",
|
|
1171
|
+
onClose,
|
|
1172
|
+
zOffset: 1e3,
|
|
1173
|
+
width: 3,
|
|
1174
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1175
|
+
gap: 4,
|
|
1176
|
+
padding: 4,
|
|
1177
|
+
children: [
|
|
1178
|
+
draftIds.length > 0 ? /* @__PURE__ */ jsxs(Stack, {
|
|
1179
|
+
gap: 2,
|
|
1180
|
+
children: [/* @__PURE__ */ jsxs(Text, {
|
|
1181
|
+
size: 1,
|
|
1182
|
+
children: [
|
|
1183
|
+
"There",
|
|
1184
|
+
" ",
|
|
1185
|
+
draftIds.length === 1 ? "is 1 draft document" : `are ${draftIds.length} draft documents`,
|
|
1186
|
+
"."
|
|
1187
|
+
]
|
|
1188
|
+
}), invalidIds && invalidIds.length > 0 ? /* @__PURE__ */ jsxs(TextWithTone, {
|
|
1189
|
+
tone: "critical",
|
|
1190
|
+
size: 1,
|
|
1191
|
+
children: [
|
|
1192
|
+
invalidIds.length === 1 ? "1 draft document has" : `${invalidIds.length} draft documents have`,
|
|
1193
|
+
" ",
|
|
1194
|
+
"validation issues that must be addressed first"
|
|
1195
|
+
]
|
|
1196
|
+
}) : /* @__PURE__ */ jsx(TextWithTone, {
|
|
1197
|
+
tone: "positive",
|
|
1198
|
+
size: 1,
|
|
1199
|
+
children: "All drafts are valid and can be bulk published"
|
|
1200
|
+
})]
|
|
1201
|
+
}) : null,
|
|
1202
|
+
/* @__PURE__ */ jsx(Stack, {
|
|
1203
|
+
gap: 1,
|
|
1204
|
+
children: translations.filter(_temp2).map((translation_1) => /* @__PURE__ */ jsx(DocumentCheck, {
|
|
1205
|
+
id: translation_1.value._ref,
|
|
1206
|
+
onCheckComplete,
|
|
1207
|
+
addInvalidId,
|
|
1208
|
+
removeInvalidId,
|
|
1209
|
+
addDraftId,
|
|
1210
|
+
removeDraftId
|
|
1211
|
+
}, translation_1._key))
|
|
1212
|
+
}),
|
|
1213
|
+
draftIds.length > 0 ? /* @__PURE__ */ jsx(Button, {
|
|
1214
|
+
mode: "ghost",
|
|
1215
|
+
tone: invalidIds && invalidIds?.length > 0 ? "caution" : "positive",
|
|
1216
|
+
text: draftIds.length === 1 ? "Publish draft document" : `Bulk publish ${draftIds.length} draft documents`,
|
|
1217
|
+
onClick: handleBulkPublish,
|
|
1218
|
+
disabled
|
|
1219
|
+
}) : /* @__PURE__ */ jsx(Text, {
|
|
1220
|
+
muted: !0,
|
|
1221
|
+
size: 1,
|
|
1222
|
+
children: "No draft documents to publish"
|
|
1223
|
+
})
|
|
1224
|
+
]
|
|
1225
|
+
})
|
|
1226
|
+
})
|
|
1227
|
+
]
|
|
1228
|
+
})
|
|
1229
|
+
}) : null, $[16] = disabled, $[17] = draftIds, $[18] = handleBulkPublish, $[19] = invalidIds, $[20] = open, $[21] = translations, $[22] = t11) : t11 = $[22], t11;
|
|
1105
1230
|
}
|
|
1106
1231
|
function _temp2(translation_0) {
|
|
1107
|
-
|
|
1232
|
+
return translation_0?.value?._ref;
|
|
1108
1233
|
}
|
|
1109
1234
|
function _temp(translation) {
|
|
1110
|
-
|
|
1111
|
-
documentId: translation.value._ref
|
|
1112
|
-
};
|
|
1235
|
+
return { documentId: translation.value._ref };
|
|
1113
1236
|
}
|
|
1114
1237
|
function ReferencePatcher(props) {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
let t2;
|
|
1137
|
-
return $[8] !== client || $[9] !== editState || $[10] !== metadataId || $[11] !== onChange || $[12] !== translation ? (t2 = [translation, editState, metadataId, client, onChange], $[8] = client, $[9] = editState, $[10] = metadataId, $[11] = onChange, $[12] = translation, $[13] = t2) : t2 = $[13], useEffect(t1, t2), null;
|
|
1238
|
+
let $ = c(14), { translation, documentType, metadataId } = props, editState = useEditState(translation.value._ref, documentType), t0;
|
|
1239
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: API_VERSION }, $[0] = t0) : t0 = $[0];
|
|
1240
|
+
let client = useClient(t0), { onChange } = useDocumentPane(), t1;
|
|
1241
|
+
$[1] !== editState || $[2] !== onChange || $[3] !== translation._key || $[4] !== translation.value._ref || $[5] !== translation.value._strengthenOnPublish || $[6] !== translation.value._weak ? (t1 = () => {
|
|
1242
|
+
if (translation.value._ref && translation.value._weak && translation.value._strengthenOnPublish && !editState.draft && editState.published && editState.ready) {
|
|
1243
|
+
let referencePathBase = [
|
|
1244
|
+
"translations",
|
|
1245
|
+
{ _key: translation._key },
|
|
1246
|
+
"value"
|
|
1247
|
+
];
|
|
1248
|
+
onChange(new PatchEvent([unset([...referencePathBase, "_weak"]), unset([...referencePathBase, "_strengthenOnPublish"])]));
|
|
1249
|
+
}
|
|
1250
|
+
}, $[1] = editState, $[2] = onChange, $[3] = translation._key, $[4] = translation.value._ref, $[5] = translation.value._strengthenOnPublish, $[6] = translation.value._weak, $[7] = t1) : t1 = $[7];
|
|
1251
|
+
let t2;
|
|
1252
|
+
return $[8] !== client || $[9] !== editState || $[10] !== metadataId || $[11] !== onChange || $[12] !== translation ? (t2 = [
|
|
1253
|
+
translation,
|
|
1254
|
+
editState,
|
|
1255
|
+
metadataId,
|
|
1256
|
+
client,
|
|
1257
|
+
onChange
|
|
1258
|
+
], $[8] = client, $[9] = editState, $[10] = metadataId, $[11] = onChange, $[12] = translation, $[13] = t2) : t2 = $[13], useEffect(t1, t2), null;
|
|
1138
1259
|
}
|
|
1139
1260
|
function OptimisticallyStrengthen(props) {
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
let t3;
|
|
1156
|
-
return $[7] !== t2 ? (t3 = /* @__PURE__ */ jsx(Fragment, { children: t2 }), $[7] = t2, $[8] = t3) : t3 = $[8], t3;
|
|
1261
|
+
let $ = c(9), { translations: t0, metadataId } = props, t1;
|
|
1262
|
+
$[0] === t0 ? t1 = $[1] : (t1 = t0 === void 0 ? [] : t0, $[0] = t0, $[1] = t1);
|
|
1263
|
+
let translations = t1;
|
|
1264
|
+
if (!translations.length) return null;
|
|
1265
|
+
let t2;
|
|
1266
|
+
if ($[2] !== metadataId || $[3] !== translations) {
|
|
1267
|
+
let t3;
|
|
1268
|
+
$[5] === metadataId ? t3 = $[6] : (t3 = (translation) => translation.value._strengthenOnPublish?.type ? /* @__PURE__ */ jsx(ReferencePatcher, {
|
|
1269
|
+
translation,
|
|
1270
|
+
documentType: translation.value._strengthenOnPublish.type,
|
|
1271
|
+
metadataId
|
|
1272
|
+
}, translation._key) : null, $[5] = metadataId, $[6] = t3), t2 = translations.map(t3), $[2] = metadataId, $[3] = translations, $[4] = t2;
|
|
1273
|
+
} else t2 = $[4];
|
|
1274
|
+
let t3;
|
|
1275
|
+
return $[7] === t2 ? t3 = $[8] : (t3 = /* @__PURE__ */ jsx(Fragment, { children: t2 }), $[7] = t2, $[8] = t3), t3;
|
|
1157
1276
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1277
|
+
/**
|
|
1278
|
+
* Creates the `translation.metadata` document schema definition. This schema
|
|
1279
|
+
* type stores the array of translation references linking all language versions
|
|
1280
|
+
* of a document together, along with the allowed schema types and any custom
|
|
1281
|
+
* metadata fields provided by the plugin consumer. The document uses `liveEdit`
|
|
1282
|
+
* so changes are published immediately without drafts.
|
|
1283
|
+
*/
|
|
1284
|
+
var metadata_default = (schemaTypes, metadataFields, omnisearchVisibility = !0) => defineType({
|
|
1285
|
+
type: "document",
|
|
1286
|
+
name: METADATA_SCHEMA_NAME,
|
|
1287
|
+
title: "Translation metadata",
|
|
1288
|
+
icon: TranslateIcon,
|
|
1289
|
+
liveEdit: !0,
|
|
1290
|
+
__experimental_omnisearch_visibility: omnisearchVisibility,
|
|
1291
|
+
fields: [
|
|
1292
|
+
defineField({
|
|
1293
|
+
name: TRANSLATIONS_ARRAY_NAME,
|
|
1294
|
+
type: "internationalizedArrayReference"
|
|
1295
|
+
}),
|
|
1296
|
+
defineField({
|
|
1297
|
+
name: "schemaTypes",
|
|
1298
|
+
description: "Optional: Used to filter the reference fields above so all translations share the same types.",
|
|
1299
|
+
type: "array",
|
|
1300
|
+
of: [{ type: "string" }],
|
|
1301
|
+
options: { list: schemaTypes },
|
|
1302
|
+
readOnly: ({ value }) => !!value
|
|
1303
|
+
}),
|
|
1304
|
+
...metadataFields
|
|
1305
|
+
],
|
|
1306
|
+
preview: {
|
|
1307
|
+
select: {
|
|
1308
|
+
translations: TRANSLATIONS_ARRAY_NAME,
|
|
1309
|
+
documentSchemaTypes: "schemaTypes"
|
|
1310
|
+
},
|
|
1311
|
+
prepare(selection) {
|
|
1312
|
+
let { translations = [], documentSchemaTypes = [] } = selection, title = translations.length === 1 ? "1 Translation" : `${translations.length} Translations`, languageKeys = translations.length ? translations.map((t) => t[LANGUAGE_FIELD_NAME].toUpperCase()).join(", ") : "";
|
|
1313
|
+
return {
|
|
1314
|
+
title,
|
|
1315
|
+
subtitle: [languageKeys ? `(${languageKeys})` : null, documentSchemaTypes?.length ? documentSchemaTypes.map((s) => s).join(", ") : ""].filter(Boolean).join(" ")
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1198
1319
|
});
|
|
1199
1320
|
const documentInternationalization = definePlugin((config) => {
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
value: {
|
|
1308
|
-
[languageField]: language.id
|
|
1309
|
-
}
|
|
1310
|
-
})));
|
|
1311
|
-
return [...prev, ...parameterizedTemplates, ...staticTemplates];
|
|
1312
|
-
}
|
|
1313
|
-
},
|
|
1314
|
-
// Uses:
|
|
1315
|
-
// - `sanity-plugin-internationalized-array` to maintain the translations array
|
|
1316
|
-
plugins: [
|
|
1317
|
-
// Translation metadata stores its references using this plugin
|
|
1318
|
-
// It cuts down on attribute usage and gives UI conveniences to add new translations
|
|
1319
|
-
internationalizedArray({
|
|
1320
|
-
...metadataInternationalization,
|
|
1321
|
-
apiVersion: pluginConfig.apiVersion,
|
|
1322
|
-
languages: supportedLanguages,
|
|
1323
|
-
includeForDocumentType: (documentType) => documentType === METADATA_SCHEMA_NAME,
|
|
1324
|
-
fieldTypes: [defineField({
|
|
1325
|
-
name: "reference",
|
|
1326
|
-
type: "reference",
|
|
1327
|
-
to: schemaTypes.map((type) => ({
|
|
1328
|
-
type
|
|
1329
|
-
})),
|
|
1330
|
-
weak: pluginConfig.weakReferences,
|
|
1331
|
-
// Reference filters don't actually enforce validation!
|
|
1332
|
-
validation: (Rule) => (
|
|
1333
|
-
// @ts-expect-error - fix typings
|
|
1334
|
-
Rule.custom(async (item, context) => {
|
|
1335
|
-
if (!item?.value?._ref || !item?.[LANGUAGE_FIELD_NAME])
|
|
1336
|
-
return !0;
|
|
1337
|
-
const valueLanguage = await context.getClient({
|
|
1338
|
-
apiVersion: API_VERSION
|
|
1339
|
-
}).fetch(`*[_id in [$ref, $draftRef]][0].${languageField}`, {
|
|
1340
|
-
ref: item.value._ref,
|
|
1341
|
-
draftRef: `drafts.${item.value._ref}`
|
|
1342
|
-
});
|
|
1343
|
-
return valueLanguage && valueLanguage === item[LANGUAGE_FIELD_NAME] ? !0 : "Referenced document does not have the correct language value";
|
|
1344
|
-
})
|
|
1345
|
-
),
|
|
1346
|
-
options: {
|
|
1347
|
-
// @ts-expect-error - Update type once it knows the values of this filter
|
|
1348
|
-
filter: ({
|
|
1349
|
-
parent,
|
|
1350
|
-
document
|
|
1351
|
-
}) => {
|
|
1352
|
-
if (!parent) return null;
|
|
1353
|
-
const language = (Array.isArray(parent) ? parent : [parent]).find((p) => p[LANGUAGE_FIELD_NAME]);
|
|
1354
|
-
return language?.[LANGUAGE_FIELD_NAME] ? document.schemaTypes ? {
|
|
1355
|
-
filter: `_type in $schemaTypes && ${languageField} == $language`,
|
|
1356
|
-
params: {
|
|
1357
|
-
schemaTypes: document.schemaTypes,
|
|
1358
|
-
language: language[LANGUAGE_FIELD_NAME]
|
|
1359
|
-
}
|
|
1360
|
-
} : {
|
|
1361
|
-
filter: `${languageField} == $language`,
|
|
1362
|
-
params: {
|
|
1363
|
-
language: language[LANGUAGE_FIELD_NAME]
|
|
1364
|
-
}
|
|
1365
|
-
} : null;
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
}, {
|
|
1369
|
-
strict: !1
|
|
1370
|
-
})]
|
|
1371
|
-
})
|
|
1372
|
-
]
|
|
1373
|
-
};
|
|
1321
|
+
let pluginConfig = {
|
|
1322
|
+
...DEFAULT_CONFIG,
|
|
1323
|
+
...config
|
|
1324
|
+
}, { supportedLanguages, schemaTypes, languageField, bulkPublish, metadataFields, hideLanguageFilter, metadataOmnisearchVisibility, metadataInternationalization, addTemplates } = pluginConfig;
|
|
1325
|
+
if (schemaTypes.length === 0) throw Error("You must specify at least one schema type on which to enable document internationalization. Update the `schemaTypes` option in the documentInternationalization() configuration.");
|
|
1326
|
+
return {
|
|
1327
|
+
name: "@sanity/document-internationalization",
|
|
1328
|
+
studio: { components: { layout: (props) => /* @__PURE__ */ jsx(DocumentInternationalizationProvider, {
|
|
1329
|
+
...props,
|
|
1330
|
+
pluginConfig
|
|
1331
|
+
}) } },
|
|
1332
|
+
i18n: { bundles: [documentInternationalizationUsEnglishLocaleBundle] },
|
|
1333
|
+
form: { components: { input: (props) => {
|
|
1334
|
+
if (props.id === "root" && props.schemaType.name === METADATA_SCHEMA_NAME && isSanityDocument(props?.value)) {
|
|
1335
|
+
let metadataId = props?.value?._id, translations = props?.value?.translations ?? [], weakAndTypedTranslations = translations.filter(({ value }) => value?._weak && value._strengthenOnPublish);
|
|
1336
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
1337
|
+
gap: 5,
|
|
1338
|
+
children: [
|
|
1339
|
+
bulkPublish ? /* @__PURE__ */ jsx(BulkPublish, { translations }) : null,
|
|
1340
|
+
weakAndTypedTranslations.length > 0 ? /* @__PURE__ */ jsx(OptimisticallyStrengthen, {
|
|
1341
|
+
metadataId,
|
|
1342
|
+
translations: weakAndTypedTranslations
|
|
1343
|
+
}) : null,
|
|
1344
|
+
props.renderDefault(props)
|
|
1345
|
+
]
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
return props.renderDefault(props);
|
|
1349
|
+
} } },
|
|
1350
|
+
document: {
|
|
1351
|
+
unstable_languageFilter: (prev, ctx) => {
|
|
1352
|
+
let { schemaType, documentId } = ctx;
|
|
1353
|
+
if (typeof hideLanguageFilter == "function") {
|
|
1354
|
+
if (hideLanguageFilter(ctx)) return prev;
|
|
1355
|
+
} else if (Array.isArray(hideLanguageFilter)) {
|
|
1356
|
+
if (hideLanguageFilter.includes(schemaType)) return prev;
|
|
1357
|
+
} else if (hideLanguageFilter) return prev;
|
|
1358
|
+
return schemaTypes.includes(schemaType) && documentId ? [...prev, (props) => DocumentInternationalizationMenu({
|
|
1359
|
+
...props,
|
|
1360
|
+
documentId
|
|
1361
|
+
})] : prev;
|
|
1362
|
+
},
|
|
1363
|
+
badges: (prev, { schemaType }) => schemaTypes.includes(schemaType) ? [(props) => LanguageBadge(props), ...prev] : prev,
|
|
1364
|
+
actions: (prev, { schemaType }) => schemaType === METADATA_SCHEMA_NAME ? [...prev, useDeleteMetadataAction] : prev
|
|
1365
|
+
},
|
|
1366
|
+
schema: {
|
|
1367
|
+
types: [metadata_default(schemaTypes, metadataFields, metadataOmnisearchVisibility)],
|
|
1368
|
+
templates: (prev, { schema }) => {
|
|
1369
|
+
if (!addTemplates || !Array.isArray(supportedLanguages)) return prev;
|
|
1370
|
+
let parameterizedTemplates = schemaTypes.map((schemaType) => ({
|
|
1371
|
+
id: `${schemaType}-parameterized`,
|
|
1372
|
+
title: `${schema?.get(schemaType)?.title ?? schemaType}: with Language`,
|
|
1373
|
+
schemaType,
|
|
1374
|
+
parameters: [{
|
|
1375
|
+
name: "languageId",
|
|
1376
|
+
title: "Language ID",
|
|
1377
|
+
type: "string"
|
|
1378
|
+
}],
|
|
1379
|
+
value: ({ languageId }) => ({ [languageField]: languageId })
|
|
1380
|
+
})), staticTemplates = schemaTypes.flatMap((schemaType) => supportedLanguages.map((language) => ({
|
|
1381
|
+
id: `${schemaType}-${language.id}`,
|
|
1382
|
+
title: `${language.title} ${schema?.get(schemaType)?.title ?? schemaType}`,
|
|
1383
|
+
schemaType,
|
|
1384
|
+
value: { [languageField]: language.id }
|
|
1385
|
+
})));
|
|
1386
|
+
return [
|
|
1387
|
+
...prev,
|
|
1388
|
+
...parameterizedTemplates,
|
|
1389
|
+
...staticTemplates
|
|
1390
|
+
];
|
|
1391
|
+
}
|
|
1392
|
+
},
|
|
1393
|
+
plugins: [internationalizedArray({
|
|
1394
|
+
...metadataInternationalization,
|
|
1395
|
+
apiVersion: pluginConfig.apiVersion,
|
|
1396
|
+
languages: supportedLanguages,
|
|
1397
|
+
includeForDocumentType: (documentType) => documentType === METADATA_SCHEMA_NAME,
|
|
1398
|
+
fieldTypes: [defineField({
|
|
1399
|
+
name: "reference",
|
|
1400
|
+
type: "reference",
|
|
1401
|
+
to: schemaTypes.map((type) => ({ type })),
|
|
1402
|
+
weak: pluginConfig.weakReferences,
|
|
1403
|
+
validation: (Rule) => Rule.custom(async (item, context) => {
|
|
1404
|
+
if (!item?.value?._ref || !item?.[LANGUAGE_FIELD_NAME]) return !0;
|
|
1405
|
+
let valueLanguage = await context.getClient({ apiVersion: API_VERSION }).fetch(`*[_id in [$ref, $draftRef]][0].${languageField}`, {
|
|
1406
|
+
ref: item.value._ref,
|
|
1407
|
+
draftRef: `drafts.${item.value._ref}`
|
|
1408
|
+
});
|
|
1409
|
+
return valueLanguage && valueLanguage === item[LANGUAGE_FIELD_NAME] ? !0 : "Referenced document does not have the correct language value";
|
|
1410
|
+
}),
|
|
1411
|
+
options: { filter: ({ parent, document }) => {
|
|
1412
|
+
if (!parent) return null;
|
|
1413
|
+
let language = (Array.isArray(parent) ? parent : [parent]).find((p) => p[LANGUAGE_FIELD_NAME]);
|
|
1414
|
+
return language?.[LANGUAGE_FIELD_NAME] ? document.schemaTypes ? {
|
|
1415
|
+
filter: `_type in $schemaTypes && ${languageField} == $language`,
|
|
1416
|
+
params: {
|
|
1417
|
+
schemaTypes: document.schemaTypes,
|
|
1418
|
+
language: language[LANGUAGE_FIELD_NAME]
|
|
1419
|
+
}
|
|
1420
|
+
} : {
|
|
1421
|
+
filter: `${languageField} == $language`,
|
|
1422
|
+
params: { language: language[LANGUAGE_FIELD_NAME] }
|
|
1423
|
+
} : null;
|
|
1424
|
+
} }
|
|
1425
|
+
}, { strict: !1 })]
|
|
1426
|
+
})]
|
|
1427
|
+
};
|
|
1374
1428
|
});
|
|
1375
|
-
export {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
DuplicateWithTranslationsAction,
|
|
1379
|
-
documentInternationalization,
|
|
1380
|
-
useDeleteTranslationAction,
|
|
1381
|
-
useDocumentInternationalizationContext,
|
|
1382
|
-
useDuplicateWithTranslationsAction
|
|
1383
|
-
};
|
|
1384
|
-
//# sourceMappingURL=index.js.map
|
|
1429
|
+
export { DeleteTranslationAction, DocumentInternationalizationMenu, DuplicateWithTranslationsAction, documentInternationalization, useDeleteTranslationAction, useDocumentInternationalizationContext, useDuplicateWithTranslationsAction };
|
|
1430
|
+
|
|
1431
|
+
//# sourceMappingURL=index.js.map
|