gt-sanity 2.1.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -0
- package/dist/index.cjs +627 -1807
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -76
- package/dist/index.d.ts +95 -76
- package/dist/index.js +582 -1775
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/adapter/core.ts +2 -10
- package/src/components/TranslationsProvider.tsx +2 -2
- package/src/components/page/ImportAllDialog.tsx +1 -1
- package/src/components/page/ImportMissingDialog.tsx +1 -5
- package/src/components/page/TranslateAllDialog.tsx +1 -5
- package/src/components/page/TranslationsTable.tsx +91 -58
- package/src/components/page/TranslationsTool.tsx +156 -209
- package/src/components/shared/BaseTranslationWrapper.tsx +10 -1
- package/src/components/shared/LanguageStatus.tsx +34 -34
- package/src/components/shared/LocaleCheckbox.tsx +5 -13
- package/src/components/shared/LocaleLabel.tsx +38 -0
- package/src/components/shared/ProgressBar.tsx +34 -20
- package/src/components/shared/SingleDocumentView.tsx +1 -1
- package/src/components/tab/TranslationView.tsx +45 -26
- package/src/index.ts +86 -31
- package/src/schema/__tests__/fieldLevelConfig.test.ts +115 -0
- package/src/schema/__tests__/schemaOptions.test.ts +17 -0
- package/src/schema/fieldLevelConfig.ts +126 -0
- package/src/schema/schemaOptions.ts +32 -0
- package/src/serialization/__tests__/BaseDocumentSerializer/optionsExclusion.test.ts +294 -0
- package/src/serialization/internationalizedArray/__tests__/internationalizedArray.test.ts +9 -17
- package/src/serialization/internationalizedArray/__tests__/serializeRoundTrip.test.ts +26 -6
- package/src/serialization/internationalizedArray/detect.ts +6 -18
- package/src/serialization/serialize/fieldFilters.ts +82 -11
- package/src/serialization/serialize/index.ts +140 -38
- package/src/utils/localeDisplay.ts +78 -0
- package/src/schema/InternationalizedArrayInput.tsx +0 -278
- package/src/schema/__tests__/createInternationalizedArrayTypes.test.ts +0 -169
- package/src/schema/createInternationalizedArrayTypes.ts +0 -209
- package/src/schema/types.ts +0 -84
package/dist/index.cjs
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var generaltranslation = require("generaltranslation"), internal = require("generaltranslation/internal"), sanity = require("sanity"), router = require("sanity/router"), jsxRuntime = require("react/jsx-runtime"),
|
|
3
|
+
var generaltranslation = require("generaltranslation"), internal = require("generaltranslation/internal"), sanity = require("sanity"), router = require("sanity/router"), jsxRuntime = require("react/jsx-runtime"), React = require("react"), icons = require("@sanity/icons"), ui = require("@sanity/ui"), theme$1 = require("@sanity/ui/theme"), mutator = require("@sanity/mutator"), jsonpathPlus = require("jsonpath-plus"), JSONPointer = require("jsonpointer"), blockTools = require("@portabletext/block-tools"), schema = require("@sanity/schema"), toHtml = require("@portabletext/to-html"), merge = require("lodash.merge"), sanityPluginInternationalizedArray = require("sanity-plugin-internationalized-array"), documentInternationalization = require("@sanity/document-internationalization");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
7
|
-
var
|
|
8
|
-
const useClient = () => sanity.useClient({ apiVersion: "2025-09-15" });
|
|
9
|
-
function useSecrets(id) {
|
|
10
|
-
const [loading, setLoading] = o.useState(!0), [secrets, setSecrets] = o.useState(null), client = useClient();
|
|
11
|
-
return o.useEffect(() => {
|
|
12
|
-
function fetchData() {
|
|
13
|
-
client.fetch("* [_id == $id][0]", { id }).then((doc) => {
|
|
14
|
-
const result = {};
|
|
15
|
-
for (const key in doc)
|
|
16
|
-
key[0] !== "_" && (result[key] = doc[key]);
|
|
17
|
-
setSecrets(result), setLoading(!1);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
fetchData();
|
|
21
|
-
}, [id, client]), { loading, secrets };
|
|
22
|
-
}
|
|
7
|
+
var React__default = /* @__PURE__ */ _interopDefaultCompat(React), JSONPointer__default = /* @__PURE__ */ _interopDefaultCompat(JSONPointer), merge__default = /* @__PURE__ */ _interopDefaultCompat(merge);
|
|
23
8
|
const SECRETS_NAMESPACE = "generaltranslation.secrets", gt = new generaltranslation.GT();
|
|
24
9
|
function overrideConfig(secrets) {
|
|
25
10
|
gt.setConfig({
|
|
@@ -44,10 +29,9 @@ class GTConfig {
|
|
|
44
29
|
additionalBlockDeserializers;
|
|
45
30
|
translationLevel;
|
|
46
31
|
fieldLevelDocuments;
|
|
47
|
-
fieldLevelTypePrefix;
|
|
48
32
|
static instance;
|
|
49
|
-
constructor(secretsNamespace, languageField, sourceLocale, locales, singletons, singletonMapping, ignoreFields, dedupeFields, skipFields, translateDocuments, additionalStopTypes = [], additionalSerializers = {}, additionalDeserializers = { types: {} }, additionalBlockDeserializers = [], translationLevel = "document", fieldLevelDocuments = []
|
|
50
|
-
this.secretsNamespace = secretsNamespace, this.languageField = languageField, this.sourceLocale = sourceLocale, this.locales = locales, this.singletons = singletons, this.singletonMapping = singletonMapping, this.ignoreFields = ignoreFields, this.dedupeFields = dedupeFields, this.skipFields = skipFields, this.translateDocuments = translateDocuments, this.additionalStopTypes = additionalStopTypes, this.additionalSerializers = additionalSerializers, this.additionalDeserializers = additionalDeserializers, this.additionalBlockDeserializers = additionalBlockDeserializers, this.translationLevel = translationLevel, this.fieldLevelDocuments = fieldLevelDocuments
|
|
33
|
+
constructor(secretsNamespace, languageField, sourceLocale, locales, singletons, singletonMapping, ignoreFields, dedupeFields, skipFields, translateDocuments, additionalStopTypes = [], additionalSerializers = {}, additionalDeserializers = { types: {} }, additionalBlockDeserializers = [], translationLevel = "document", fieldLevelDocuments = []) {
|
|
34
|
+
this.secretsNamespace = secretsNamespace, this.languageField = languageField, this.sourceLocale = sourceLocale, this.locales = locales, this.singletons = singletons, this.singletonMapping = singletonMapping, this.ignoreFields = ignoreFields, this.dedupeFields = dedupeFields, this.skipFields = skipFields, this.translateDocuments = translateDocuments, this.additionalStopTypes = additionalStopTypes, this.additionalSerializers = additionalSerializers, this.additionalDeserializers = additionalDeserializers, this.additionalBlockDeserializers = additionalBlockDeserializers, this.translationLevel = translationLevel, this.fieldLevelDocuments = fieldLevelDocuments;
|
|
51
35
|
}
|
|
52
36
|
static getInstance() {
|
|
53
37
|
return this.instance || (this.instance = new GTConfig(
|
|
@@ -67,8 +51,8 @@ class GTConfig {
|
|
|
67
51
|
[]
|
|
68
52
|
)), this.instance;
|
|
69
53
|
}
|
|
70
|
-
init(secretsNamespace, languageField, sourceLocale, locales, singletons, singletonMapping, ignoreFields, dedupeFields, skipFields, translateDocuments, additionalStopTypes = [], additionalSerializers = {}, additionalDeserializers = { types: {} }, additionalBlockDeserializers = [], translationLevel = "document", fieldLevelDocuments = []
|
|
71
|
-
this.secretsNamespace = secretsNamespace, this.languageField = languageField, this.sourceLocale = sourceLocale, this.locales = locales, this.singletons = singletons, this.singletonMapping = singletonMapping, this.ignoreFields = ignoreFields, this.dedupeFields = dedupeFields, this.skipFields = skipFields, this.translateDocuments = translateDocuments, this.additionalStopTypes = additionalStopTypes, this.additionalSerializers = additionalSerializers, this.additionalDeserializers = additionalDeserializers, this.additionalBlockDeserializers = additionalBlockDeserializers, this.translationLevel = translationLevel, this.fieldLevelDocuments = fieldLevelDocuments
|
|
54
|
+
init(secretsNamespace, languageField, sourceLocale, locales, singletons, singletonMapping, ignoreFields, dedupeFields, skipFields, translateDocuments, additionalStopTypes = [], additionalSerializers = {}, additionalDeserializers = { types: {} }, additionalBlockDeserializers = [], translationLevel = "document", fieldLevelDocuments = []) {
|
|
55
|
+
this.secretsNamespace = secretsNamespace, this.languageField = languageField, this.sourceLocale = sourceLocale, this.locales = locales, this.singletons = singletons, this.singletonMapping = singletonMapping, this.ignoreFields = ignoreFields, this.dedupeFields = dedupeFields, this.skipFields = skipFields, this.translateDocuments = translateDocuments, this.additionalStopTypes = additionalStopTypes, this.additionalSerializers = additionalSerializers, this.additionalDeserializers = additionalDeserializers, this.additionalBlockDeserializers = additionalBlockDeserializers, this.translationLevel = translationLevel, this.fieldLevelDocuments = fieldLevelDocuments;
|
|
72
56
|
}
|
|
73
57
|
getSecretsNamespace() {
|
|
74
58
|
return this.secretsNamespace;
|
|
@@ -118,11 +102,54 @@ class GTConfig {
|
|
|
118
102
|
getFieldLevelDocuments() {
|
|
119
103
|
return this.fieldLevelDocuments;
|
|
120
104
|
}
|
|
121
|
-
getFieldLevelTypePrefix() {
|
|
122
|
-
return this.fieldLevelTypePrefix;
|
|
123
|
-
}
|
|
124
105
|
}
|
|
125
|
-
const pluginConfig = GTConfig.getInstance()
|
|
106
|
+
const pluginConfig = GTConfig.getInstance();
|
|
107
|
+
function capitalize(value) {
|
|
108
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
109
|
+
}
|
|
110
|
+
function localeDisplayFromProperties(code, properties, mapping) {
|
|
111
|
+
return typeof mapping == "string" ? { code, name: mapping, emoji: "", verbatim: !0 } : {
|
|
112
|
+
code,
|
|
113
|
+
name: capitalize(properties.languageName || properties.name || code),
|
|
114
|
+
emoji: properties.emoji || "",
|
|
115
|
+
verbatim: !1
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function getLocaleDisplay(localeId) {
|
|
119
|
+
return localeDisplayFromProperties(
|
|
120
|
+
localeId,
|
|
121
|
+
gt.getLocaleProperties(localeId),
|
|
122
|
+
gt.customMapping?.[localeId]
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
function formatLocalePropertiesLabel(code, properties, mapping) {
|
|
126
|
+
const { emoji, name, verbatim } = localeDisplayFromProperties(
|
|
127
|
+
code,
|
|
128
|
+
properties,
|
|
129
|
+
mapping
|
|
130
|
+
);
|
|
131
|
+
return verbatim ? name : [emoji, `${name} (${code})`].filter(Boolean).join(" ");
|
|
132
|
+
}
|
|
133
|
+
const useClient = () => sanity.useClient({ apiVersion: "2025-09-15" });
|
|
134
|
+
function useSecrets(id) {
|
|
135
|
+
const [loading, setLoading] = React.useState(!0), [secrets, setSecrets] = React.useState(null), client = useClient();
|
|
136
|
+
return React.useEffect(() => {
|
|
137
|
+
function fetchData() {
|
|
138
|
+
client.fetch("* [_id == $id][0]", { id }).then((doc) => {
|
|
139
|
+
const result = {};
|
|
140
|
+
for (const key in doc)
|
|
141
|
+
key[0] !== "_" && (result[key] = doc[key]);
|
|
142
|
+
setSecrets(result), setLoading(!1);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
fetchData();
|
|
146
|
+
}, [id, client]), { loading, secrets };
|
|
147
|
+
}
|
|
148
|
+
const gtRadius = [0, 4, 6, 8, 12, 16, 24], baseTheme = theme$1.buildTheme(), theme = {
|
|
149
|
+
...baseTheme,
|
|
150
|
+
radius: gtRadius,
|
|
151
|
+
v2: baseTheme.v2 && { ...baseTheme.v2, radius: gtRadius }
|
|
152
|
+
}, BaseTranslationWrapper = ({
|
|
126
153
|
children,
|
|
127
154
|
secretsNamespace = pluginConfig.getSecretsNamespace(),
|
|
128
155
|
padding = 4,
|
|
@@ -170,12 +197,12 @@ const pluginConfig = GTConfig.getInstance(), theme = theme$1.buildTheme(), BaseT
|
|
|
170
197
|
const merged = {};
|
|
171
198
|
return ["_rev", "_id", "_type"].forEach((metaKey) => {
|
|
172
199
|
translatedFields[metaKey] && (merged[metaKey] = translatedFields[metaKey]);
|
|
173
|
-
}), mutator.extractWithPath(`..${baseLang}`, translatedFields).forEach((
|
|
200
|
+
}), mutator.extractWithPath(`..${baseLang}`, translatedFields).forEach((match) => {
|
|
174
201
|
const origVal = mutator.extractWithPath(
|
|
175
|
-
mutator.arrayToJSONMatchPath(
|
|
202
|
+
mutator.arrayToJSONMatchPath(match.path),
|
|
176
203
|
baseDoc
|
|
177
204
|
)[0].value, translatedVal = mutator.extractWithPath(
|
|
178
|
-
mutator.arrayToJSONMatchPath(
|
|
205
|
+
mutator.arrayToJSONMatchPath(match.path),
|
|
179
206
|
translatedFields
|
|
180
207
|
)[0].value;
|
|
181
208
|
let valToPatch;
|
|
@@ -187,7 +214,7 @@ const pluginConfig = GTConfig.getInstance(), theme = theme$1.buildTheme(), BaseT
|
|
|
187
214
|
translatedVal
|
|
188
215
|
));
|
|
189
216
|
const destinationPath = [
|
|
190
|
-
...
|
|
217
|
+
...match.path.slice(0, match.path.length - 1),
|
|
191
218
|
//cut off the "en"
|
|
192
219
|
localeId.replace("-", "_")
|
|
193
220
|
// replace it with our locale
|
|
@@ -501,13 +528,9 @@ const documentLevelPatch = async (docInfo, translatedFields, localeId, client, l
|
|
|
501
528
|
languageField
|
|
502
529
|
);
|
|
503
530
|
}
|
|
504
|
-
},
|
|
505
|
-
function hasRecognizedTypePrefix(type) {
|
|
506
|
-
return type.startsWith(DEFAULT_TYPE_PREFIX$1) || type.startsWith(pluginConfig.getFieldLevelTypePrefix());
|
|
507
|
-
}
|
|
508
|
-
const isRecord$4 = (value) => typeof value == "object" && value !== null && !Array.isArray(value);
|
|
531
|
+
}, TYPE_PREFIX = "internationalizedArray", isRecord$4 = (value) => typeof value == "object" && value !== null && !Array.isArray(value);
|
|
509
532
|
function isInternationalizedArrayItem(item) {
|
|
510
|
-
return isRecord$4(item) && typeof item._type == "string" &&
|
|
533
|
+
return isRecord$4(item) && typeof item._type == "string" && item._type.startsWith(TYPE_PREFIX) && item._type.endsWith("Value") && typeof item.language == "string" && "value" in item;
|
|
511
534
|
}
|
|
512
535
|
function isInternationalizedArrayField(value) {
|
|
513
536
|
return Array.isArray(value) && value.length > 0 && value.every(isInternationalizedArrayItem);
|
|
@@ -709,13 +732,13 @@ const isRecord$3 = (value) => typeof value == "object" && value !== null && !Arr
|
|
|
709
732
|
}, customDeserializers = { types: {} }, customBlockDeserializers = [
|
|
710
733
|
// handle marks with data-gt-internal
|
|
711
734
|
{
|
|
712
|
-
deserialize(
|
|
713
|
-
if (
|
|
735
|
+
deserialize(node, next) {
|
|
736
|
+
if (node.nodeType !== 1)
|
|
714
737
|
return;
|
|
715
|
-
const el =
|
|
738
|
+
const el = node;
|
|
716
739
|
if (!el.hasChildNodes() || !el.getAttribute("data-gt-internal"))
|
|
717
740
|
return;
|
|
718
|
-
const { html, data } = detachGTData(el.outerHTML), block = blockTools.htmlToBlocks(html, blockContentType)[0], children =
|
|
741
|
+
const { html, data } = detachGTData(el.outerHTML), block = blockTools.htmlToBlocks(html, blockContentType)[0], children = next(el.childNodes);
|
|
719
742
|
let markDefs = [];
|
|
720
743
|
return "markDefs" in block && (markDefs = block.markDefs ?? []), data?.markDef && markDefs.push(data.markDef), Array.isArray(children) && children.forEach((child) => {
|
|
721
744
|
if (!isRecord$3(child))
|
|
@@ -731,26 +754,26 @@ const isRecord$3 = (value) => typeof value == "object" && value !== null && !Arr
|
|
|
731
754
|
},
|
|
732
755
|
//handle undeclared styles
|
|
733
756
|
{
|
|
734
|
-
deserialize(
|
|
735
|
-
if (
|
|
757
|
+
deserialize(node, next) {
|
|
758
|
+
if (node.nodeType !== 1)
|
|
736
759
|
return;
|
|
737
|
-
const el =
|
|
760
|
+
const el = node;
|
|
738
761
|
if (!el.hasChildNodes() || el.getAttribute("data-type") !== "unknown-block-style")
|
|
739
762
|
return;
|
|
740
763
|
const style = el.getAttribute("data-style") ?? "";
|
|
741
764
|
return {
|
|
742
765
|
...blockTools.htmlToBlocks(el.outerHTML, blockContentType)[0],
|
|
743
766
|
style,
|
|
744
|
-
children:
|
|
767
|
+
children: next(el.childNodes)
|
|
745
768
|
};
|
|
746
769
|
}
|
|
747
770
|
},
|
|
748
771
|
//handle list items
|
|
749
772
|
{
|
|
750
|
-
deserialize(
|
|
751
|
-
if (
|
|
773
|
+
deserialize(node, next) {
|
|
774
|
+
if (node.nodeType !== 1)
|
|
752
775
|
return;
|
|
753
|
-
const el =
|
|
776
|
+
const el = node;
|
|
754
777
|
if (!el.hasChildNodes() || el.tagName.toLowerCase() !== "li")
|
|
755
778
|
return;
|
|
756
779
|
const tagsToStyle = {
|
|
@@ -780,7 +803,7 @@ const isRecord$3 = (value) => typeof value == "object" && value !== null && !Arr
|
|
|
780
803
|
level,
|
|
781
804
|
_key,
|
|
782
805
|
listItem,
|
|
783
|
-
children:
|
|
806
|
+
children: next(el.childNodes)
|
|
784
807
|
};
|
|
785
808
|
}
|
|
786
809
|
}
|
|
@@ -914,12 +937,34 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
914
937
|
return filteredObj;
|
|
915
938
|
};
|
|
916
939
|
return findBaseLang(obj);
|
|
917
|
-
},
|
|
940
|
+
}, isFieldExcludedByOptions = (options) => {
|
|
941
|
+
if (!isRecord$2(options)) return !1;
|
|
942
|
+
const exclusionOptions = options;
|
|
943
|
+
return exclusionOptions.gt?.exclude === !0 || exclusionOptions.documentInternationalization?.exclude === !0 || exclusionOptions.aiAssist?.exclude === !0;
|
|
944
|
+
}, getFieldTypeName = (field) => {
|
|
945
|
+
const fieldType = field.type;
|
|
946
|
+
return typeof fieldType == "string" ? fieldType : fieldType?.name;
|
|
947
|
+
}, isTypeExcludedByOptions = (typeName, resolveType) => {
|
|
948
|
+
if (!resolveType) return !1;
|
|
949
|
+
const seen = /* @__PURE__ */ new Set();
|
|
950
|
+
let current = typeName;
|
|
951
|
+
for (; current && !seen.has(current); ) {
|
|
952
|
+
seen.add(current);
|
|
953
|
+
const typeDef = resolveType(current);
|
|
954
|
+
if (!typeDef) return !1;
|
|
955
|
+
if (isFieldExcludedByOptions(typeDef.options)) return !0;
|
|
956
|
+
current = typeof typeDef.type == "string" ? typeDef.type : void 0;
|
|
957
|
+
}
|
|
958
|
+
return !1;
|
|
959
|
+
}, isFieldExcludedFromTranslation = (field, resolveType) => {
|
|
960
|
+
const fieldMetadata = field;
|
|
961
|
+
return fieldMetadata.localize === !1 || isFieldExcludedByOptions(fieldMetadata.options) || isTypeExcludedByOptions(getFieldTypeName(field), resolveType);
|
|
962
|
+
}, fieldFilter = (obj, objFields, stopTypes, resolveType) => {
|
|
918
963
|
const filteredObj = {
|
|
919
964
|
_type: typeof obj._type == "string" ? obj._type : ""
|
|
920
965
|
}, fieldFilterFunc = (field) => {
|
|
921
|
-
const
|
|
922
|
-
return
|
|
966
|
+
const fieldType = getFieldTypeName(field);
|
|
967
|
+
return isFieldExcludedFromTranslation(field, resolveType) ? !1 : fieldType === "string" || fieldType === "text" || Array.isArray(obj[field.name]) ? !0 : !!(fieldType && !stopTypes.includes(fieldType));
|
|
923
968
|
};
|
|
924
969
|
return [
|
|
925
970
|
...META_FIELDS$1,
|
|
@@ -928,8 +973,18 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
928
973
|
obj[field] && (filteredObj[field] = obj[field]);
|
|
929
974
|
}), filteredObj;
|
|
930
975
|
}, META_FIELDS = ["_key", "_type", "_id", "_weak"], isRecord$1 = (value) => typeof value == "object" && value !== null && !Array.isArray(value), BaseDocumentSerializer = (schemas) => {
|
|
931
|
-
const getSchema = (name) => schemas?._original?.types.find((s) => s.name === name),
|
|
932
|
-
|
|
976
|
+
const getSchema = (name) => schemas?._original?.types.find((s) => s.name === name), resolveSchemaFields = (typeName) => {
|
|
977
|
+
const seen = /* @__PURE__ */ new Set();
|
|
978
|
+
let current = typeName;
|
|
979
|
+
for (; current && !seen.has(current); ) {
|
|
980
|
+
seen.add(current);
|
|
981
|
+
const typeDef = getSchema(current);
|
|
982
|
+
if (!typeDef) return;
|
|
983
|
+
if (typeDef.fields) return typeDef.fields;
|
|
984
|
+
current = typeof typeDef.type == "string" ? typeDef.type : void 0;
|
|
985
|
+
}
|
|
986
|
+
}, serializeObject = (obj, stopTypes, serializers, declaredFields) => {
|
|
987
|
+
if (stopTypes.includes(obj._type) || isTypeExcludedByOptions(obj._type, getSchema))
|
|
933
988
|
return "";
|
|
934
989
|
const typeSerializers = isRecord$1(serializers.types) ? serializers.types : {};
|
|
935
990
|
if (Object.keys(typeSerializers).includes(obj._type))
|
|
@@ -937,36 +992,59 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
937
992
|
if (obj._type === "span" || obj._type === "block")
|
|
938
993
|
return toHtml.toHTML(obj, { components: serializers });
|
|
939
994
|
let fieldNames = Object.keys(obj).filter((key) => key !== "_type");
|
|
940
|
-
const
|
|
941
|
-
|
|
995
|
+
const resolvedFields = resolveSchemaFields(obj._type);
|
|
996
|
+
if (resolvedFields)
|
|
997
|
+
fieldNames = resolvedFields.filter((field) => !isFieldExcludedFromTranslation(field, getSchema)).map((field) => field.name).filter((schemaKey) => Object.keys(obj).includes(schemaKey));
|
|
998
|
+
else if (declaredFields) {
|
|
999
|
+
const excludedNames = new Set(
|
|
1000
|
+
declaredFields.filter((field) => isFieldExcludedFromTranslation(field, getSchema)).map((field) => field.name)
|
|
1001
|
+
);
|
|
1002
|
+
fieldNames = fieldNames.filter((name) => !excludedNames.has(name));
|
|
1003
|
+
}
|
|
1004
|
+
const knownFields = resolvedFields ?? declaredFields;
|
|
1005
|
+
typeof obj == "object" && !obj._type && (obj._type = "");
|
|
942
1006
|
const newSerializationMethods = {}, tempType = `${obj._type}__temp_type__${Math.random().toString(36).substring(7)}`, objToSerialize = { _type: tempType };
|
|
943
|
-
META_FIELDS.filter((
|
|
1007
|
+
META_FIELDS.filter((f) => f !== "_type").forEach((field) => {
|
|
944
1008
|
objToSerialize[field] = obj[field];
|
|
945
1009
|
});
|
|
946
1010
|
let innerHTML = "";
|
|
947
1011
|
if (fieldNames.forEach((fieldName) => {
|
|
948
1012
|
let htmlField = "";
|
|
949
1013
|
if (!META_FIELDS.includes(fieldName)) {
|
|
950
|
-
const value = obj[fieldName]
|
|
1014
|
+
const value = obj[fieldName], fieldDef = knownFields?.find(
|
|
1015
|
+
(field) => field.name === fieldName
|
|
1016
|
+
);
|
|
951
1017
|
if (typeof value == "string")
|
|
952
1018
|
new RegExp(/<("[^"]*"|'[^']*'|[^'">])*>/).test(value) ? htmlField = value : htmlField = `<span class="${fieldName}">${value}</span>`;
|
|
953
1019
|
else if (Array.isArray(value))
|
|
954
|
-
htmlField = serializeArray(
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1020
|
+
htmlField = serializeArray(
|
|
1021
|
+
value,
|
|
1022
|
+
fieldName,
|
|
1023
|
+
stopTypes,
|
|
1024
|
+
{
|
|
1025
|
+
...serializers,
|
|
1026
|
+
types: { ...typeSerializers }
|
|
1027
|
+
},
|
|
1028
|
+
fieldDef?.of
|
|
1029
|
+
);
|
|
958
1030
|
else if (isRecord$1(value)) {
|
|
959
|
-
const embeddedObject = value,
|
|
1031
|
+
const embeddedObject = value, embeddedFields = resolveSchemaFields(embeddedObject._type);
|
|
960
1032
|
let toTranslate = embeddedObject;
|
|
961
|
-
|
|
1033
|
+
embeddedFields && (toTranslate = fieldFilter(
|
|
962
1034
|
toTranslate,
|
|
963
|
-
|
|
964
|
-
stopTypes
|
|
1035
|
+
embeddedFields,
|
|
1036
|
+
stopTypes,
|
|
1037
|
+
getSchema
|
|
965
1038
|
));
|
|
966
|
-
const objHTML = serializeObject(
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1039
|
+
const objHTML = serializeObject(
|
|
1040
|
+
toTranslate,
|
|
1041
|
+
stopTypes,
|
|
1042
|
+
{
|
|
1043
|
+
...serializers,
|
|
1044
|
+
types: { ...typeSerializers }
|
|
1045
|
+
},
|
|
1046
|
+
fieldDef?.fields
|
|
1047
|
+
);
|
|
970
1048
|
htmlField = `<div class="${fieldName}" data-level="field">${objHTML}</div>`;
|
|
971
1049
|
}
|
|
972
1050
|
innerHTML += htmlField;
|
|
@@ -994,28 +1072,43 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
994
1072
|
);
|
|
995
1073
|
}
|
|
996
1074
|
return serializedBlock;
|
|
997
|
-
}, serializeArray = (fieldContent, fieldName, stopTypes, serializers) => {
|
|
998
|
-
const
|
|
1075
|
+
}, serializeArray = (fieldContent, fieldName, stopTypes, serializers, memberDefs) => {
|
|
1076
|
+
const validBlocks = fieldContent.filter(
|
|
999
1077
|
(block) => typeof block == "string" || typeof block._type != "string" || !stopTypes.includes(block._type)
|
|
1000
|
-
)
|
|
1078
|
+
), declaredMemberFields = (blockType) => {
|
|
1079
|
+
if (!memberDefs?.length) return;
|
|
1080
|
+
const byName = memberDefs.find(
|
|
1081
|
+
(def) => def.name === blockType || def.type === blockType
|
|
1082
|
+
);
|
|
1083
|
+
if (byName?.fields) return byName.fields;
|
|
1084
|
+
if (!blockType && memberDefs.length === 1) return memberDefs[0].fields;
|
|
1085
|
+
}, output = validBlocks.map((block) => {
|
|
1001
1086
|
if (typeof block == "string")
|
|
1002
|
-
return block
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1087
|
+
return `<span>${block}</span>`;
|
|
1088
|
+
const blockType = typeof block._type == "string" ? block._type : void 0, memberFields = resolveSchemaFields(blockType), filtered = memberFields ? fieldFilter(block, memberFields, stopTypes, getSchema) : block;
|
|
1089
|
+
return serializeObject(
|
|
1090
|
+
filtered,
|
|
1091
|
+
stopTypes,
|
|
1092
|
+
serializers,
|
|
1093
|
+
declaredMemberFields(blockType)
|
|
1005
1094
|
);
|
|
1006
|
-
|
|
1007
|
-
}).map((obj) => typeof obj == "string" ? `<span>${obj}</span>` : serializeObject(obj, stopTypes, serializers));
|
|
1095
|
+
});
|
|
1008
1096
|
return `<div class="${fieldName}" data-type="array">${output.join("")}</div>`;
|
|
1009
1097
|
};
|
|
1010
1098
|
return {
|
|
1011
1099
|
serializeDocument: (doc, translationLevel = "document", baseLang = internal.libraryDefaultLocale, stopTypes = defaultStopTypes, serializers = customSerializers) => {
|
|
1012
1100
|
const schema2 = getSchema(doc._type);
|
|
1013
1101
|
let filteredObj = {};
|
|
1014
|
-
translationLevel === "field" ? filteredObj = languageObjectFieldFilter(doc, baseLang) : filteredObj = fieldFilter(
|
|
1102
|
+
translationLevel === "field" ? filteredObj = languageObjectFieldFilter(doc, baseLang) : filteredObj = fieldFilter(
|
|
1103
|
+
doc,
|
|
1104
|
+
schema2?.fields ?? [],
|
|
1105
|
+
stopTypes,
|
|
1106
|
+
getSchema
|
|
1107
|
+
);
|
|
1015
1108
|
const serializedFields = {};
|
|
1016
1109
|
for (const key in filteredObj) {
|
|
1017
1110
|
if (filteredObj.hasOwnProperty(key) === !1) continue;
|
|
1018
|
-
const value = filteredObj[key];
|
|
1111
|
+
const value = filteredObj[key], fieldDef = schema2?.fields?.find((field) => field.name === key);
|
|
1019
1112
|
if (typeof value == "string")
|
|
1020
1113
|
serializedFields[key] = value;
|
|
1021
1114
|
else if (Array.isArray(value))
|
|
@@ -1025,13 +1118,15 @@ const deserializeArray = (arrayHTML, deserializers = customDeserializers, blockD
|
|
|
1025
1118
|
),
|
|
1026
1119
|
key,
|
|
1027
1120
|
stopTypes,
|
|
1028
|
-
serializers
|
|
1121
|
+
serializers,
|
|
1122
|
+
fieldDef?.of
|
|
1029
1123
|
);
|
|
1030
1124
|
else if (value && isRecord$1(value) && !stopTypes.find((stopType) => stopType == value?._type)) {
|
|
1031
1125
|
const serialized = serializeObject(
|
|
1032
1126
|
value,
|
|
1033
1127
|
stopTypes,
|
|
1034
|
-
serializers
|
|
1128
|
+
serializers,
|
|
1129
|
+
fieldDef?.fields
|
|
1035
1130
|
);
|
|
1036
1131
|
serializedFields[key] = `<div class="${key}" data-level='field'>${serialized}</div>`;
|
|
1037
1132
|
}
|
|
@@ -1143,7 +1238,7 @@ const documentAdapter = {
|
|
|
1143
1238
|
patch: (docInfo, deserialized, localeId, client) => internationalizedArrayPatch(docInfo, deserialized, localeId, client)
|
|
1144
1239
|
};
|
|
1145
1240
|
function matchesFieldLevel(type) {
|
|
1146
|
-
return type ? pluginConfig.getFieldLevelDocuments().some((
|
|
1241
|
+
return type ? pluginConfig.getFieldLevelDocuments().some((filter) => filter.type === type) : !1;
|
|
1147
1242
|
}
|
|
1148
1243
|
function getTranslationStrategyForType(type) {
|
|
1149
1244
|
const level = pluginConfig.getTranslationLevel();
|
|
@@ -1488,7 +1583,7 @@ const getLocales = async (_secrets) => pluginConfig.getLocales().map((locale) =>
|
|
|
1488
1583
|
localeId: locale,
|
|
1489
1584
|
description: gt.getLocaleProperties(locale).name,
|
|
1490
1585
|
enabled: !0
|
|
1491
|
-
})), TranslationsContext =
|
|
1586
|
+
})), TranslationsContext = React.createContext(null), getUploadedVersionsStorageKey = (projectId, dataset) => `gt-sanity:uploadedVersions:${projectId ?? ""}:${dataset ?? ""}`;
|
|
1492
1587
|
function readUploadedVersions(storageKey) {
|
|
1493
1588
|
try {
|
|
1494
1589
|
const raw = window.sessionStorage.getItem(storageKey);
|
|
@@ -1516,7 +1611,7 @@ function isPlainRecord(value) {
|
|
|
1516
1611
|
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
1517
1612
|
}
|
|
1518
1613
|
const useTranslations = () => {
|
|
1519
|
-
const context =
|
|
1614
|
+
const context = React.useContext(TranslationsContext);
|
|
1520
1615
|
if (!context)
|
|
1521
1616
|
throw new Error("useTranslations must be used within TranslationsProvider");
|
|
1522
1617
|
return context;
|
|
@@ -1524,40 +1619,40 @@ const useTranslations = () => {
|
|
|
1524
1619
|
children,
|
|
1525
1620
|
singleDocument
|
|
1526
1621
|
}) => {
|
|
1527
|
-
const [isBusy, setIsBusy] =
|
|
1622
|
+
const [isBusy, setIsBusy] = React.useState(!1), [documents, setDocuments] = React.useState([]), [locales, setLocales] = React.useState([]), [autoRefresh, setAutoRefresh] = React.useState(!0), [autoImport, setAutoImport] = React.useState(!1), [autoPatchReferences, setAutoPatchReferences] = React.useState(!1), [autoPublish, setAutoPublish] = React.useState(!1), [loadingDocuments, setLoadingDocuments] = React.useState(!1), [importProgress, setImportProgress] = React.useState({
|
|
1528
1623
|
current: 0,
|
|
1529
1624
|
total: 0,
|
|
1530
1625
|
isImporting: !1
|
|
1531
|
-
}), [importedTranslations, setImportedTranslations] =
|
|
1626
|
+
}), [importedTranslations, setImportedTranslations] = React.useState(
|
|
1532
1627
|
/* @__PURE__ */ new Set()
|
|
1533
|
-
), [existingTranslations, setExistingTranslations] =
|
|
1628
|
+
), [existingTranslations, setExistingTranslations] = React.useState(
|
|
1534
1629
|
/* @__PURE__ */ new Set()
|
|
1535
|
-
), [downloadStatus, setDownloadStatus] =
|
|
1630
|
+
), [downloadStatus, setDownloadStatus] = React.useState({
|
|
1536
1631
|
downloaded: /* @__PURE__ */ new Set(),
|
|
1537
1632
|
failed: /* @__PURE__ */ new Set(),
|
|
1538
1633
|
skipped: /* @__PURE__ */ new Set()
|
|
1539
|
-
}), downloadStatusRef =
|
|
1634
|
+
}), downloadStatusRef = React.useRef(downloadStatus), [translationStatuses, setTranslationStatuses] = React.useState(/* @__PURE__ */ new Map()), [isRefreshing, setIsRefreshing] = React.useState(!1), client = useClient(), { projectId, dataset } = client.config(), uploadedVersionsStorageKey = getUploadedVersionsStorageKey(
|
|
1540
1635
|
projectId,
|
|
1541
1636
|
dataset
|
|
1542
|
-
), [uploadedVersions, setUploadedVersions] =
|
|
1637
|
+
), [uploadedVersions, setUploadedVersions] = React.useState(
|
|
1543
1638
|
() => readUploadedVersions(uploadedVersionsStorageKey)
|
|
1544
1639
|
), schema2 = sanity.useSchema(), translationContext = { client, schema: schema2 }, toast = ui.useToast(), { loading: loadingSecrets, secrets } = useSecrets(
|
|
1545
1640
|
pluginConfig.getSecretsNamespace()
|
|
1546
|
-
), [branchId, setBranchId] =
|
|
1547
|
-
|
|
1641
|
+
), [branchId, setBranchId] = React.useState(void 0);
|
|
1642
|
+
React.useEffect(() => {
|
|
1548
1643
|
downloadStatusRef.current = downloadStatus;
|
|
1549
1644
|
}, [downloadStatus]);
|
|
1550
|
-
const getVersionId =
|
|
1645
|
+
const getVersionId = React.useCallback(
|
|
1551
1646
|
(document2) => uploadedVersions.get(getDocumentPublishedId(document2)) ?? document2._rev,
|
|
1552
1647
|
[uploadedVersions]
|
|
1553
|
-
), fetchDocuments =
|
|
1648
|
+
), fetchDocuments = React.useCallback(async () => {
|
|
1554
1649
|
setLoadingDocuments(!0);
|
|
1555
1650
|
try {
|
|
1556
1651
|
if (singleDocument) {
|
|
1557
1652
|
setDocuments([singleDocument]);
|
|
1558
1653
|
return;
|
|
1559
1654
|
}
|
|
1560
|
-
const filterConditions = pluginConfig.getTranslateDocuments().map((
|
|
1655
|
+
const filterConditions = pluginConfig.getTranslateDocuments().map((filter) => filter.type && filter.documentId ? `(_type == "${filter.type}" && _id == "${filter.documentId}")` : filter.type ? `_type == "${filter.type}"` : filter.documentId ? `_id == "${filter.documentId}"` : null).filter(Boolean), languageField = pluginConfig.getLanguageField(), sourceLocale = pluginConfig.getSourceLocale(), languageFilter = `(!defined(${languageField}) || ${languageField} == "${sourceLocale}")`;
|
|
1561
1656
|
let query;
|
|
1562
1657
|
filterConditions.length === 0 ? query = `*[!(_type in ["system.group"]) && !(_id in path("_.**")) && ${languageFilter}]` : query = `*[!(_type in ["system.group"]) && !(_id in path("_.**")) && (${filterConditions.join(" || ")}) && ${languageFilter}]`;
|
|
1563
1658
|
const docs = await client.fetch(query);
|
|
@@ -1571,7 +1666,7 @@ const useTranslations = () => {
|
|
|
1571
1666
|
} finally {
|
|
1572
1667
|
setLoadingDocuments(!1);
|
|
1573
1668
|
}
|
|
1574
|
-
}, [client, singleDocument]), fetchLocales =
|
|
1669
|
+
}, [client, singleDocument]), fetchLocales = React.useCallback(async () => {
|
|
1575
1670
|
if (secrets)
|
|
1576
1671
|
try {
|
|
1577
1672
|
const availableLocales = await getLocales(secrets);
|
|
@@ -1583,7 +1678,7 @@ const useTranslations = () => {
|
|
|
1583
1678
|
closable: !0
|
|
1584
1679
|
});
|
|
1585
1680
|
}
|
|
1586
|
-
}, [secrets]), fetchExistingTranslations =
|
|
1681
|
+
}, [secrets]), fetchExistingTranslations = React.useCallback(async () => {
|
|
1587
1682
|
if (!(!documents.length || !locales.length))
|
|
1588
1683
|
try {
|
|
1589
1684
|
const sourceLocale = pluginConfig.getSourceLocale(), availableLocaleIds = locales.filter((locale) => locale.enabled !== !1).map((locale) => locale.localeId), documentIds = documents.map(getDocumentPublishedId), existingMetadata = await client.fetch(`*[
|
|
@@ -1615,12 +1710,12 @@ const useTranslations = () => {
|
|
|
1615
1710
|
closable: !0
|
|
1616
1711
|
});
|
|
1617
1712
|
}
|
|
1618
|
-
}, [documents, locales, client]), handleTranslateAll =
|
|
1713
|
+
}, [documents, locales, client]), handleTranslateAll = React.useCallback(async () => {
|
|
1619
1714
|
if (!(!secrets || documents.length === 0)) {
|
|
1620
1715
|
setIsBusy(!0);
|
|
1621
1716
|
try {
|
|
1622
1717
|
const availableLocaleIds = locales.filter((locale) => locale.enabled !== !1).map((locale) => locale.localeId), transformedDocuments = documents.map((doc) => {
|
|
1623
|
-
const { [pluginConfig.getLanguageField()]:
|
|
1718
|
+
const { [pluginConfig.getLanguageField()]: _, ...cleanDoc } = doc, baseLanguage = pluginConfig.getSourceLocale();
|
|
1624
1719
|
try {
|
|
1625
1720
|
const serialized = getTranslationStrategy(doc).serialize(
|
|
1626
1721
|
cleanDoc,
|
|
@@ -1665,7 +1760,7 @@ const useTranslations = () => {
|
|
|
1665
1760
|
schema2,
|
|
1666
1761
|
uploadedVersions,
|
|
1667
1762
|
uploadedVersionsStorageKey
|
|
1668
|
-
]), handleImportAll =
|
|
1763
|
+
]), handleImportAll = React.useCallback(async () => {
|
|
1669
1764
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1670
1765
|
setIsBusy(!0);
|
|
1671
1766
|
try {
|
|
@@ -1696,14 +1791,14 @@ const useTranslations = () => {
|
|
|
1696
1791
|
});
|
|
1697
1792
|
},
|
|
1698
1793
|
onImportSuccess: (key) => {
|
|
1699
|
-
setImportedTranslations((
|
|
1794
|
+
setImportedTranslations((prev) => /* @__PURE__ */ new Set([...prev, key]));
|
|
1700
1795
|
}
|
|
1701
1796
|
}
|
|
1702
1797
|
);
|
|
1703
|
-
result.successfulImports.length > 0 && setDownloadStatus((
|
|
1704
|
-
...
|
|
1798
|
+
result.successfulImports.length > 0 && setDownloadStatus((prev) => ({
|
|
1799
|
+
...prev,
|
|
1705
1800
|
downloaded: /* @__PURE__ */ new Set([
|
|
1706
|
-
...
|
|
1801
|
+
...prev.downloaded,
|
|
1707
1802
|
...result.successfulImports
|
|
1708
1803
|
])
|
|
1709
1804
|
})), toast.push({
|
|
@@ -1728,7 +1823,7 @@ const useTranslations = () => {
|
|
|
1728
1823
|
downloadStatus,
|
|
1729
1824
|
translationContext,
|
|
1730
1825
|
branchId
|
|
1731
|
-
]), getExistingTranslations =
|
|
1826
|
+
]), getExistingTranslations = React.useCallback(
|
|
1732
1827
|
async (documentIds, localeIds, branchId2) => {
|
|
1733
1828
|
const sourceLocale = pluginConfig.getSourceLocale(), existingMetadata = await client.fetch(`*[
|
|
1734
1829
|
_type == 'translation.metadata' &&
|
|
@@ -1755,7 +1850,7 @@ const useTranslations = () => {
|
|
|
1755
1850
|
}), existing;
|
|
1756
1851
|
},
|
|
1757
1852
|
[client]
|
|
1758
|
-
), handleImportMissing =
|
|
1853
|
+
), handleImportMissing = React.useCallback(async () => {
|
|
1759
1854
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1760
1855
|
setIsBusy(!0);
|
|
1761
1856
|
try {
|
|
@@ -1798,14 +1893,14 @@ const useTranslations = () => {
|
|
|
1798
1893
|
});
|
|
1799
1894
|
},
|
|
1800
1895
|
onImportSuccess: (key) => {
|
|
1801
|
-
setImportedTranslations((
|
|
1896
|
+
setImportedTranslations((prev) => /* @__PURE__ */ new Set([...prev, key])), setExistingTranslations((prev) => /* @__PURE__ */ new Set([...prev, key]));
|
|
1802
1897
|
}
|
|
1803
1898
|
}
|
|
1804
1899
|
);
|
|
1805
|
-
result.successfulImports.length > 0 && setDownloadStatus((
|
|
1806
|
-
...
|
|
1900
|
+
result.successfulImports.length > 0 && setDownloadStatus((prev) => ({
|
|
1901
|
+
...prev,
|
|
1807
1902
|
downloaded: /* @__PURE__ */ new Set([
|
|
1808
|
-
...
|
|
1903
|
+
...prev.downloaded,
|
|
1809
1904
|
...result.successfulImports
|
|
1810
1905
|
])
|
|
1811
1906
|
})), toast.push({
|
|
@@ -1832,7 +1927,7 @@ const useTranslations = () => {
|
|
|
1832
1927
|
translationContext,
|
|
1833
1928
|
getExistingTranslations,
|
|
1834
1929
|
branchId
|
|
1835
|
-
]), handleGetBranchId =
|
|
1930
|
+
]), handleGetBranchId = React.useCallback(
|
|
1836
1931
|
async (secrets2) => {
|
|
1837
1932
|
overrideConfig(secrets2);
|
|
1838
1933
|
const defaultBranch = await gt.createBranch({
|
|
@@ -1842,7 +1937,7 @@ const useTranslations = () => {
|
|
|
1842
1937
|
setBranchId(defaultBranch.branch.id);
|
|
1843
1938
|
},
|
|
1844
1939
|
[secrets]
|
|
1845
|
-
), handleRefreshAll =
|
|
1940
|
+
), handleRefreshAll = React.useCallback(async () => {
|
|
1846
1941
|
if (!(!secrets || documents.length === 0 || !branchId)) {
|
|
1847
1942
|
setIsRefreshing(!0);
|
|
1848
1943
|
try {
|
|
@@ -1895,7 +1990,7 @@ const useTranslations = () => {
|
|
|
1895
1990
|
}
|
|
1896
1991
|
return newStatuses;
|
|
1897
1992
|
}), toast.push({
|
|
1898
|
-
title: `Refreshed status for ${documents.length}
|
|
1993
|
+
title: `Refreshed status for ${documents.length} document(s)`,
|
|
1899
1994
|
status: "success",
|
|
1900
1995
|
closable: !0
|
|
1901
1996
|
});
|
|
@@ -1909,7 +2004,7 @@ const useTranslations = () => {
|
|
|
1909
2004
|
setIsRefreshing(!1);
|
|
1910
2005
|
}
|
|
1911
2006
|
}
|
|
1912
|
-
}, [secrets, documents, locales, branchId, getVersionId]), handleImportDocument =
|
|
2007
|
+
}, [secrets, documents, locales, branchId, getVersionId]), handleImportDocument = React.useCallback(
|
|
1913
2008
|
async (documentId, versionId, localeId) => {
|
|
1914
2009
|
if (!secrets) return;
|
|
1915
2010
|
const key = createTranslationStatusKey(
|
|
@@ -1961,12 +2056,12 @@ const useTranslations = () => {
|
|
|
1961
2056
|
downloadedFiles[0].data,
|
|
1962
2057
|
translationContext,
|
|
1963
2058
|
!1
|
|
1964
|
-
), setDownloadStatus((
|
|
1965
|
-
...
|
|
1966
|
-
downloaded: /* @__PURE__ */ new Set([...
|
|
1967
|
-
})), setImportedTranslations((
|
|
1968
|
-
(
|
|
1969
|
-
...
|
|
2059
|
+
), setDownloadStatus((prev) => ({
|
|
2060
|
+
...prev,
|
|
2061
|
+
downloaded: /* @__PURE__ */ new Set([...prev.downloaded, key])
|
|
2062
|
+
})), setImportedTranslations((prev) => /* @__PURE__ */ new Set([...prev, key])), setExistingTranslations(
|
|
2063
|
+
(prev) => /* @__PURE__ */ new Set([
|
|
2064
|
+
...prev,
|
|
1970
2065
|
createStableTranslationKey(branchId, documentId, localeId)
|
|
1971
2066
|
])
|
|
1972
2067
|
), toast.push({
|
|
@@ -1996,7 +2091,7 @@ const useTranslations = () => {
|
|
|
1996
2091
|
}
|
|
1997
2092
|
},
|
|
1998
2093
|
[secrets, documents, translationContext, translationStatuses, branchId]
|
|
1999
|
-
), handlePatchDocumentReferences =
|
|
2094
|
+
), handlePatchDocumentReferences = React.useCallback(async () => {
|
|
2000
2095
|
if (!secrets || documents.length === 0) return 0;
|
|
2001
2096
|
setIsBusy(!0);
|
|
2002
2097
|
try {
|
|
@@ -2070,7 +2165,7 @@ const useTranslations = () => {
|
|
|
2070
2165
|
} finally {
|
|
2071
2166
|
setIsBusy(!1), setImportProgress({ current: 0, total: 0, isImporting: !1 });
|
|
2072
2167
|
}
|
|
2073
|
-
}, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations =
|
|
2168
|
+
}, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations = React.useCallback(async () => {
|
|
2074
2169
|
if (!secrets || documents.length === 0) return 0;
|
|
2075
2170
|
setIsBusy(!0);
|
|
2076
2171
|
try {
|
|
@@ -2126,13 +2221,13 @@ const useTranslations = () => {
|
|
|
2126
2221
|
setIsBusy(!1);
|
|
2127
2222
|
}
|
|
2128
2223
|
}, [secrets, documents, client, branchId]);
|
|
2129
|
-
|
|
2224
|
+
React.useEffect(() => {
|
|
2130
2225
|
fetchDocuments();
|
|
2131
|
-
}, [fetchDocuments]),
|
|
2226
|
+
}, [fetchDocuments]), React.useEffect(() => {
|
|
2132
2227
|
secrets && fetchLocales();
|
|
2133
|
-
}, [fetchLocales, secrets]),
|
|
2228
|
+
}, [fetchLocales, secrets]), React.useEffect(() => {
|
|
2134
2229
|
documents.length > 0 && locales.length > 0 && fetchExistingTranslations();
|
|
2135
|
-
}, [fetchExistingTranslations]),
|
|
2230
|
+
}, [fetchExistingTranslations]), React.useEffect(() => {
|
|
2136
2231
|
documents.length > 0 && locales.length > 0 && secrets && !loadingDocuments && branchId && handleRefreshAll();
|
|
2137
2232
|
}, [
|
|
2138
2233
|
documents,
|
|
@@ -2141,15 +2236,15 @@ const useTranslations = () => {
|
|
|
2141
2236
|
loadingDocuments,
|
|
2142
2237
|
branchId,
|
|
2143
2238
|
handleRefreshAll
|
|
2144
|
-
]),
|
|
2239
|
+
]), React.useEffect(() => {
|
|
2145
2240
|
if (!autoRefresh || documents.length === 0 || !secrets) return;
|
|
2146
2241
|
const interval = setInterval(async () => {
|
|
2147
2242
|
await handleRefreshAll();
|
|
2148
2243
|
}, 1e4);
|
|
2149
2244
|
return () => clearInterval(interval);
|
|
2150
|
-
}, [autoRefresh, documents.length, secrets, handleRefreshAll]),
|
|
2245
|
+
}, [autoRefresh, documents.length, secrets, handleRefreshAll]), React.useEffect(() => {
|
|
2151
2246
|
setImportedTranslations(new Set(downloadStatus.downloaded));
|
|
2152
|
-
}, [downloadStatus.downloaded]),
|
|
2247
|
+
}, [downloadStatus.downloaded]), React.useEffect(() => {
|
|
2153
2248
|
secrets && handleGetBranchId(secrets);
|
|
2154
2249
|
}, [secrets, handleGetBranchId]);
|
|
2155
2250
|
const contextValue = {
|
|
@@ -2189,49 +2284,74 @@ const useTranslations = () => {
|
|
|
2189
2284
|
return /* @__PURE__ */ jsxRuntime.jsx(TranslationsContext.Provider, { value: contextValue, children });
|
|
2190
2285
|
};
|
|
2191
2286
|
function ProgressBar({ progress }) {
|
|
2192
|
-
return typeof progress > "u" ? (console.warn("No progress prop passed to ProgressBar"), null) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2287
|
+
return typeof progress > "u" ? (console.warn("No progress prop passed to ProgressBar"), null) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2288
|
+
ui.Card,
|
|
2289
|
+
{
|
|
2290
|
+
radius: 2,
|
|
2291
|
+
overflow: "hidden",
|
|
2292
|
+
style: { width: "100%", position: "relative" },
|
|
2293
|
+
children: [
|
|
2294
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2295
|
+
ui.Card,
|
|
2296
|
+
{
|
|
2297
|
+
tone: "positive",
|
|
2298
|
+
style: {
|
|
2299
|
+
position: "absolute",
|
|
2300
|
+
inset: 0,
|
|
2301
|
+
transform: `scaleX(${progress / 100})`,
|
|
2302
|
+
transformOrigin: "left",
|
|
2303
|
+
transition: "transform .2s ease"
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
),
|
|
2307
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2308
|
+
"div",
|
|
2309
|
+
{
|
|
2310
|
+
style: {
|
|
2311
|
+
position: "absolute",
|
|
2312
|
+
inset: 0,
|
|
2313
|
+
borderRadius: "inherit",
|
|
2314
|
+
boxShadow: "inset 0 0 0 1px var(--card-border-color)",
|
|
2315
|
+
pointerEvents: "none",
|
|
2316
|
+
zIndex: 2
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
),
|
|
2320
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2321
|
+
ui.Flex,
|
|
2322
|
+
{
|
|
2323
|
+
align: "center",
|
|
2324
|
+
justify: "center",
|
|
2325
|
+
padding: 2,
|
|
2326
|
+
style: { position: "relative", zIndex: 1 },
|
|
2327
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, weight: "medium", children: [
|
|
2328
|
+
progress,
|
|
2329
|
+
"%"
|
|
2330
|
+
] })
|
|
2331
|
+
}
|
|
2332
|
+
)
|
|
2333
|
+
]
|
|
2334
|
+
}
|
|
2335
|
+
);
|
|
2227
2336
|
}
|
|
2228
|
-
const
|
|
2229
|
-
|
|
2337
|
+
const LocaleLabel = ({
|
|
2338
|
+
localeId,
|
|
2339
|
+
size = 1,
|
|
2340
|
+
weight = "medium"
|
|
2341
|
+
}) => {
|
|
2342
|
+
const { emoji, name, code, verbatim } = getLocaleDisplay(localeId);
|
|
2343
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, children: [
|
|
2344
|
+
emoji && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size, "aria-hidden": !0, children: emoji }),
|
|
2345
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size, weight, children: name }),
|
|
2346
|
+
!verbatim && /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { fontSize: 0, radius: 2, children: code })
|
|
2347
|
+
] });
|
|
2348
|
+
}, LanguageStatus = ({
|
|
2349
|
+
localeId,
|
|
2230
2350
|
progress,
|
|
2231
2351
|
importFile,
|
|
2232
2352
|
isImported = !1
|
|
2233
2353
|
}) => {
|
|
2234
|
-
const [isBusy, setIsBusy] =
|
|
2354
|
+
const [isBusy, setIsBusy] = React.useState(!1), displayedProgress = isImported && progress < 100 ? 100 : progress, handleImport = React.useCallback(async () => {
|
|
2235
2355
|
setIsBusy(!0);
|
|
2236
2356
|
try {
|
|
2237
2357
|
await importFile();
|
|
@@ -2239,1180 +2359,33 @@ const LanguageStatus = ({
|
|
|
2239
2359
|
setIsBusy(!1);
|
|
2240
2360
|
}
|
|
2241
2361
|
}, [importFile, setIsBusy]);
|
|
2242
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
2243
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { columnStart: 1, columnEnd: 3, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2362
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { columns: 5, gap: 3, paddingX: 3, paddingY: 2, children: [
|
|
2363
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { columnStart: 1, columnEnd: 3, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(LocaleLabel, { localeId }) }),
|
|
2244
2364
|
typeof displayedProgress == "number" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { columnStart: 3, columnEnd: 5, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { progress: displayedProgress }) }) : null,
|
|
2245
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.
|
|
2365
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { columnStart: 5, columnEnd: 6, align: "center", justify: "flex-end", children: isImported ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { tone: "positive", fontSize: 0, radius: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 1, children: [
|
|
2246
2366
|
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckmarkCircleIcon, {}),
|
|
2247
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.
|
|
2248
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2367
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: "Imported" })
|
|
2368
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2249
2369
|
ui.Button,
|
|
2250
2370
|
{
|
|
2251
2371
|
style: { width: "100%" },
|
|
2252
2372
|
mode: "ghost",
|
|
2373
|
+
fontSize: 1,
|
|
2374
|
+
padding: 2,
|
|
2253
2375
|
onClick: handleImport,
|
|
2254
|
-
text:
|
|
2255
|
-
|
|
2376
|
+
text: "Import",
|
|
2377
|
+
loading: isBusy,
|
|
2378
|
+
icon: icons.DownloadIcon,
|
|
2256
2379
|
disabled: isBusy || !progress || progress < 100
|
|
2257
2380
|
}
|
|
2258
2381
|
) })
|
|
2259
|
-
] })
|
|
2260
|
-
}
|
|
2261
|
-
var __assign = function() {
|
|
2262
|
-
return __assign = Object.assign || function(t) {
|
|
2263
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2264
|
-
s = arguments[i];
|
|
2265
|
-
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
2266
|
-
}
|
|
2267
|
-
return t;
|
|
2268
|
-
}, __assign.apply(this, arguments);
|
|
2269
|
-
};
|
|
2270
|
-
function __spreadArray(to, from2, pack) {
|
|
2271
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++)
|
|
2272
|
-
(ar || !(i in from2)) && (ar || (ar = Array.prototype.slice.call(from2, 0, i)), ar[i] = from2[i]);
|
|
2273
|
-
return to.concat(ar || Array.prototype.slice.call(from2));
|
|
2274
|
-
}
|
|
2275
|
-
function memoize(fn) {
|
|
2276
|
-
var cache = /* @__PURE__ */ Object.create(null);
|
|
2277
|
-
return function(arg) {
|
|
2278
|
-
return cache[arg] === void 0 && (cache[arg] = fn(arg)), cache[arg];
|
|
2279
|
-
};
|
|
2280
|
-
}
|
|
2281
|
-
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/, isPropValid = /* @__PURE__ */ memoize(
|
|
2282
|
-
function(prop) {
|
|
2283
|
-
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
|
|
2284
|
-
}
|
|
2285
|
-
/* Z+1 */
|
|
2286
|
-
), MS = "-ms-", MOZ = "-moz-", WEBKIT = "-webkit-", COMMENT = "comm", RULESET = "rule", DECLARATION = "decl", IMPORT = "@import", KEYFRAMES = "@keyframes", LAYER = "@layer", abs = Math.abs, from = String.fromCharCode, assign = Object.assign;
|
|
2287
|
-
function hash(value, length2) {
|
|
2288
|
-
return charat(value, 0) ^ 45 ? (((length2 << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3) : 0;
|
|
2289
|
-
}
|
|
2290
|
-
function trim(value) {
|
|
2291
|
-
return value.trim();
|
|
2292
|
-
}
|
|
2293
|
-
function match(value, pattern) {
|
|
2294
|
-
return (value = pattern.exec(value)) ? value[0] : value;
|
|
2295
|
-
}
|
|
2296
|
-
function replace(value, pattern, replacement) {
|
|
2297
|
-
return value.replace(pattern, replacement);
|
|
2298
|
-
}
|
|
2299
|
-
function indexof(value, search, position2) {
|
|
2300
|
-
return value.indexOf(search, position2);
|
|
2301
|
-
}
|
|
2302
|
-
function charat(value, index) {
|
|
2303
|
-
return value.charCodeAt(index) | 0;
|
|
2304
|
-
}
|
|
2305
|
-
function substr(value, begin, end) {
|
|
2306
|
-
return value.slice(begin, end);
|
|
2307
|
-
}
|
|
2308
|
-
function strlen(value) {
|
|
2309
|
-
return value.length;
|
|
2310
|
-
}
|
|
2311
|
-
function sizeof(value) {
|
|
2312
|
-
return value.length;
|
|
2313
|
-
}
|
|
2314
|
-
function append(value, array) {
|
|
2315
|
-
return array.push(value), value;
|
|
2316
|
-
}
|
|
2317
|
-
function combine(array, callback) {
|
|
2318
|
-
return array.map(callback).join("");
|
|
2319
|
-
}
|
|
2320
|
-
function filter(array, pattern) {
|
|
2321
|
-
return array.filter(function(value) {
|
|
2322
|
-
return !match(value, pattern);
|
|
2323
|
-
});
|
|
2324
|
-
}
|
|
2325
|
-
var line = 1, column = 1, length = 0, position = 0, character = 0, characters = "";
|
|
2326
|
-
function node(value, root, parent, type, props, children, length2, siblings) {
|
|
2327
|
-
return { value, root, parent, type, props, children, line, column, length: length2, return: "", siblings };
|
|
2328
|
-
}
|
|
2329
|
-
function copy(root, props) {
|
|
2330
|
-
return assign(node("", null, null, "", null, null, 0, root.siblings), root, { length: -root.length }, props);
|
|
2331
|
-
}
|
|
2332
|
-
function lift(root) {
|
|
2333
|
-
for (; root.root; )
|
|
2334
|
-
root = copy(root.root, { children: [root] });
|
|
2335
|
-
append(root, root.siblings);
|
|
2336
|
-
}
|
|
2337
|
-
function char() {
|
|
2338
|
-
return character;
|
|
2339
|
-
}
|
|
2340
|
-
function prev() {
|
|
2341
|
-
return character = position > 0 ? charat(characters, --position) : 0, column--, character === 10 && (column = 1, line--), character;
|
|
2342
|
-
}
|
|
2343
|
-
function next() {
|
|
2344
|
-
return character = position < length ? charat(characters, position++) : 0, column++, character === 10 && (column = 1, line++), character;
|
|
2345
|
-
}
|
|
2346
|
-
function peek() {
|
|
2347
|
-
return charat(characters, position);
|
|
2348
|
-
}
|
|
2349
|
-
function caret() {
|
|
2350
|
-
return position;
|
|
2351
|
-
}
|
|
2352
|
-
function slice(begin, end) {
|
|
2353
|
-
return substr(characters, begin, end);
|
|
2354
|
-
}
|
|
2355
|
-
function token(type) {
|
|
2356
|
-
switch (type) {
|
|
2357
|
-
// \0 \t \n \r \s whitespace token
|
|
2358
|
-
case 0:
|
|
2359
|
-
case 9:
|
|
2360
|
-
case 10:
|
|
2361
|
-
case 13:
|
|
2362
|
-
case 32:
|
|
2363
|
-
return 5;
|
|
2364
|
-
// ! + , / > @ ~ isolate token
|
|
2365
|
-
case 33:
|
|
2366
|
-
case 43:
|
|
2367
|
-
case 44:
|
|
2368
|
-
case 47:
|
|
2369
|
-
case 62:
|
|
2370
|
-
case 64:
|
|
2371
|
-
case 126:
|
|
2372
|
-
// ; { } breakpoint token
|
|
2373
|
-
case 59:
|
|
2374
|
-
case 123:
|
|
2375
|
-
case 125:
|
|
2376
|
-
return 4;
|
|
2377
|
-
// : accompanied token
|
|
2378
|
-
case 58:
|
|
2379
|
-
return 3;
|
|
2380
|
-
// " ' ( [ opening delimit token
|
|
2381
|
-
case 34:
|
|
2382
|
-
case 39:
|
|
2383
|
-
case 40:
|
|
2384
|
-
case 91:
|
|
2385
|
-
return 2;
|
|
2386
|
-
// ) ] closing delimit token
|
|
2387
|
-
case 41:
|
|
2388
|
-
case 93:
|
|
2389
|
-
return 1;
|
|
2390
|
-
}
|
|
2391
|
-
return 0;
|
|
2392
|
-
}
|
|
2393
|
-
function alloc(value) {
|
|
2394
|
-
return line = column = 1, length = strlen(characters = value), position = 0, [];
|
|
2395
|
-
}
|
|
2396
|
-
function dealloc(value) {
|
|
2397
|
-
return characters = "", value;
|
|
2398
|
-
}
|
|
2399
|
-
function delimit(type) {
|
|
2400
|
-
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)));
|
|
2401
|
-
}
|
|
2402
|
-
function whitespace(type) {
|
|
2403
|
-
for (; (character = peek()) && character < 33; )
|
|
2404
|
-
next();
|
|
2405
|
-
return token(type) > 2 || token(character) > 3 ? "" : " ";
|
|
2406
|
-
}
|
|
2407
|
-
function escaping(index, count) {
|
|
2408
|
-
for (; --count && next() && !(character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97); )
|
|
2409
|
-
;
|
|
2410
|
-
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32));
|
|
2411
|
-
}
|
|
2412
|
-
function delimiter(type) {
|
|
2413
|
-
for (; next(); )
|
|
2414
|
-
switch (character) {
|
|
2415
|
-
// ] ) " '
|
|
2416
|
-
case type:
|
|
2417
|
-
return position;
|
|
2418
|
-
// " '
|
|
2419
|
-
case 34:
|
|
2420
|
-
case 39:
|
|
2421
|
-
type !== 34 && type !== 39 && delimiter(character);
|
|
2422
|
-
break;
|
|
2423
|
-
// (
|
|
2424
|
-
case 40:
|
|
2425
|
-
type === 41 && delimiter(type);
|
|
2426
|
-
break;
|
|
2427
|
-
// \
|
|
2428
|
-
case 92:
|
|
2429
|
-
next();
|
|
2430
|
-
break;
|
|
2431
|
-
}
|
|
2432
|
-
return position;
|
|
2433
|
-
}
|
|
2434
|
-
function commenter(type, index) {
|
|
2435
|
-
for (; next() && type + character !== 57; )
|
|
2436
|
-
if (type + character === 84 && peek() === 47)
|
|
2437
|
-
break;
|
|
2438
|
-
return "/*" + slice(index, position - 1) + "*" + from(type === 47 ? type : next());
|
|
2439
|
-
}
|
|
2440
|
-
function identifier(index) {
|
|
2441
|
-
for (; !token(peek()); )
|
|
2442
|
-
next();
|
|
2443
|
-
return slice(index, position);
|
|
2444
|
-
}
|
|
2445
|
-
function compile(value) {
|
|
2446
|
-
return dealloc(parse("", null, null, null, [""], value = alloc(value), 0, [0], value));
|
|
2447
|
-
}
|
|
2448
|
-
function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
|
|
2449
|
-
for (var index = 0, offset = 0, length2 = pseudo, atrule = 0, property = 0, previous = 0, variable = 1, scanning = 1, ampersand = 1, character2 = 0, type = "", props = rules, children = rulesets, reference = rule, characters2 = type; scanning; )
|
|
2450
|
-
switch (previous = character2, character2 = next()) {
|
|
2451
|
-
// (
|
|
2452
|
-
case 40:
|
|
2453
|
-
if (previous != 108 && charat(characters2, length2 - 1) == 58) {
|
|
2454
|
-
indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f", abs(index ? points[index - 1] : 0)) != -1 && (ampersand = -1);
|
|
2455
|
-
break;
|
|
2456
|
-
}
|
|
2457
|
-
// " ' [
|
|
2458
|
-
case 34:
|
|
2459
|
-
case 39:
|
|
2460
|
-
case 91:
|
|
2461
|
-
characters2 += delimit(character2);
|
|
2462
|
-
break;
|
|
2463
|
-
// \t \n \r \s
|
|
2464
|
-
case 9:
|
|
2465
|
-
case 10:
|
|
2466
|
-
case 13:
|
|
2467
|
-
case 32:
|
|
2468
|
-
characters2 += whitespace(previous);
|
|
2469
|
-
break;
|
|
2470
|
-
// \
|
|
2471
|
-
case 92:
|
|
2472
|
-
characters2 += escaping(caret() - 1, 7);
|
|
2473
|
-
continue;
|
|
2474
|
-
// /
|
|
2475
|
-
case 47:
|
|
2476
|
-
switch (peek()) {
|
|
2477
|
-
case 42:
|
|
2478
|
-
case 47:
|
|
2479
|
-
append(comment(commenter(next(), caret()), root, parent, declarations), declarations);
|
|
2480
|
-
break;
|
|
2481
|
-
default:
|
|
2482
|
-
characters2 += "/";
|
|
2483
|
-
}
|
|
2484
|
-
break;
|
|
2485
|
-
// {
|
|
2486
|
-
case 123 * variable:
|
|
2487
|
-
points[index++] = strlen(characters2) * ampersand;
|
|
2488
|
-
// } ; \0
|
|
2489
|
-
case 125 * variable:
|
|
2490
|
-
case 59:
|
|
2491
|
-
case 0:
|
|
2492
|
-
switch (character2) {
|
|
2493
|
-
// \0 }
|
|
2494
|
-
case 0:
|
|
2495
|
-
case 125:
|
|
2496
|
-
scanning = 0;
|
|
2497
|
-
// ;
|
|
2498
|
-
case 59 + offset:
|
|
2499
|
-
ampersand == -1 && (characters2 = replace(characters2, /\f/g, "")), property > 0 && strlen(characters2) - length2 && append(property > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1, declarations) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2, declarations), declarations);
|
|
2500
|
-
break;
|
|
2501
|
-
// @ ;
|
|
2502
|
-
case 59:
|
|
2503
|
-
characters2 += ";";
|
|
2504
|
-
// { rule/at-rule
|
|
2505
|
-
default:
|
|
2506
|
-
if (append(reference = ruleset(characters2, root, parent, index, offset, rules, points, type, props = [], children = [], length2, rulesets), rulesets), character2 === 123)
|
|
2507
|
-
if (offset === 0)
|
|
2508
|
-
parse(characters2, root, reference, reference, props, rulesets, length2, points, children);
|
|
2509
|
-
else
|
|
2510
|
-
switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) {
|
|
2511
|
-
// d l m s
|
|
2512
|
-
case 100:
|
|
2513
|
-
case 108:
|
|
2514
|
-
case 109:
|
|
2515
|
-
case 115:
|
|
2516
|
-
parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length2, children), children), rules, children, length2, points, rule ? props : children);
|
|
2517
|
-
break;
|
|
2518
|
-
default:
|
|
2519
|
-
parse(characters2, reference, reference, reference, [""], children, 0, points, children);
|
|
2520
|
-
}
|
|
2521
|
-
}
|
|
2522
|
-
index = offset = property = 0, variable = ampersand = 1, type = characters2 = "", length2 = pseudo;
|
|
2523
|
-
break;
|
|
2524
|
-
// :
|
|
2525
|
-
case 58:
|
|
2526
|
-
length2 = 1 + strlen(characters2), property = previous;
|
|
2527
|
-
default:
|
|
2528
|
-
if (variable < 1) {
|
|
2529
|
-
if (character2 == 123)
|
|
2530
|
-
--variable;
|
|
2531
|
-
else if (character2 == 125 && variable++ == 0 && prev() == 125)
|
|
2532
|
-
continue;
|
|
2533
|
-
}
|
|
2534
|
-
switch (characters2 += from(character2), character2 * variable) {
|
|
2535
|
-
// &
|
|
2536
|
-
case 38:
|
|
2537
|
-
ampersand = offset > 0 ? 1 : (characters2 += "\f", -1);
|
|
2538
|
-
break;
|
|
2539
|
-
// ,
|
|
2540
|
-
case 44:
|
|
2541
|
-
points[index++] = (strlen(characters2) - 1) * ampersand, ampersand = 1;
|
|
2542
|
-
break;
|
|
2543
|
-
// @
|
|
2544
|
-
case 64:
|
|
2545
|
-
peek() === 45 && (characters2 += delimit(next())), atrule = peek(), offset = length2 = strlen(type = characters2 += identifier(caret())), character2++;
|
|
2546
|
-
break;
|
|
2547
|
-
// -
|
|
2548
|
-
case 45:
|
|
2549
|
-
previous === 45 && strlen(characters2) == 2 && (variable = 0);
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
return rulesets;
|
|
2553
|
-
}
|
|
2554
|
-
function ruleset(value, root, parent, index, offset, rules, points, type, props, children, length2, siblings) {
|
|
2555
|
-
for (var post = offset - 1, rule = offset === 0 ? rules : [""], size = sizeof(rule), i = 0, j2 = 0, k2 = 0; i < index; ++i)
|
|
2556
|
-
for (var x2 = 0, y2 = substr(value, post + 1, post = abs(j2 = points[i])), z2 = value; x2 < size; ++x2)
|
|
2557
|
-
(z2 = trim(j2 > 0 ? rule[x2] + " " + y2 : replace(y2, /&\f/g, rule[x2]))) && (props[k2++] = z2);
|
|
2558
|
-
return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length2, siblings);
|
|
2559
|
-
}
|
|
2560
|
-
function comment(value, root, parent, siblings) {
|
|
2561
|
-
return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings);
|
|
2562
|
-
}
|
|
2563
|
-
function declaration(value, root, parent, length2, siblings) {
|
|
2564
|
-
return node(value, root, parent, DECLARATION, substr(value, 0, length2), substr(value, length2 + 1, -1), length2, siblings);
|
|
2565
|
-
}
|
|
2566
|
-
function prefix(value, length2, children) {
|
|
2567
|
-
switch (hash(value, length2)) {
|
|
2568
|
-
// color-adjust
|
|
2569
|
-
case 5103:
|
|
2570
|
-
return WEBKIT + "print-" + value + value;
|
|
2571
|
-
// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
|
|
2572
|
-
case 5737:
|
|
2573
|
-
case 4201:
|
|
2574
|
-
case 3177:
|
|
2575
|
-
case 3433:
|
|
2576
|
-
case 1641:
|
|
2577
|
-
case 4457:
|
|
2578
|
-
case 2921:
|
|
2579
|
-
// text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
|
|
2580
|
-
case 5572:
|
|
2581
|
-
case 6356:
|
|
2582
|
-
case 5844:
|
|
2583
|
-
case 3191:
|
|
2584
|
-
case 6645:
|
|
2585
|
-
case 3005:
|
|
2586
|
-
// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
|
|
2587
|
-
case 6391:
|
|
2588
|
-
case 5879:
|
|
2589
|
-
case 5623:
|
|
2590
|
-
case 6135:
|
|
2591
|
-
case 4599:
|
|
2592
|
-
case 4855:
|
|
2593
|
-
// background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
|
|
2594
|
-
case 4215:
|
|
2595
|
-
case 6389:
|
|
2596
|
-
case 5109:
|
|
2597
|
-
case 5365:
|
|
2598
|
-
case 5621:
|
|
2599
|
-
case 3829:
|
|
2600
|
-
return WEBKIT + value + value;
|
|
2601
|
-
// tab-size
|
|
2602
|
-
case 4789:
|
|
2603
|
-
return MOZ + value + value;
|
|
2604
|
-
// appearance, user-select, transform, hyphens, text-size-adjust
|
|
2605
|
-
case 5349:
|
|
2606
|
-
case 4246:
|
|
2607
|
-
case 4810:
|
|
2608
|
-
case 6968:
|
|
2609
|
-
case 2756:
|
|
2610
|
-
return WEBKIT + value + MOZ + value + MS + value + value;
|
|
2611
|
-
// writing-mode
|
|
2612
|
-
case 5936:
|
|
2613
|
-
switch (charat(value, length2 + 11)) {
|
|
2614
|
-
// vertical-l(r)
|
|
2615
|
-
case 114:
|
|
2616
|
-
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value;
|
|
2617
|
-
// vertical-r(l)
|
|
2618
|
-
case 108:
|
|
2619
|
-
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value;
|
|
2620
|
-
// horizontal(-)tb
|
|
2621
|
-
case 45:
|
|
2622
|
-
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value;
|
|
2623
|
-
}
|
|
2624
|
-
// flex, flex-direction, scroll-snap-type, writing-mode
|
|
2625
|
-
case 6828:
|
|
2626
|
-
case 4268:
|
|
2627
|
-
case 2903:
|
|
2628
|
-
return WEBKIT + value + MS + value + value;
|
|
2629
|
-
// order
|
|
2630
|
-
case 6165:
|
|
2631
|
-
return WEBKIT + value + MS + "flex-" + value + value;
|
|
2632
|
-
// align-items
|
|
2633
|
-
case 5187:
|
|
2634
|
-
return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value;
|
|
2635
|
-
// align-self
|
|
2636
|
-
case 5443:
|
|
2637
|
-
return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/g, "") + (match(value, /flex-|baseline/) ? "" : MS + "grid-row-" + replace(value, /flex-|-self/g, "")) + value;
|
|
2638
|
-
// align-content
|
|
2639
|
-
case 4675:
|
|
2640
|
-
return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/g, "") + value;
|
|
2641
|
-
// flex-shrink
|
|
2642
|
-
case 5548:
|
|
2643
|
-
return WEBKIT + value + MS + replace(value, "shrink", "negative") + value;
|
|
2644
|
-
// flex-basis
|
|
2645
|
-
case 5292:
|
|
2646
|
-
return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value;
|
|
2647
|
-
// flex-grow
|
|
2648
|
-
case 6060:
|
|
2649
|
-
return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value;
|
|
2650
|
-
// transition
|
|
2651
|
-
case 4554:
|
|
2652
|
-
return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value;
|
|
2653
|
-
// cursor
|
|
2654
|
-
case 6187:
|
|
2655
|
-
return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value;
|
|
2656
|
-
// background, background-image
|
|
2657
|
-
case 5495:
|
|
2658
|
-
case 3959:
|
|
2659
|
-
return replace(value, /(image-set\([^]*)/, WEBKIT + "$1$`$1");
|
|
2660
|
-
// justify-content
|
|
2661
|
-
case 4968:
|
|
2662
|
-
return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value;
|
|
2663
|
-
// justify-self
|
|
2664
|
-
case 4200:
|
|
2665
|
-
if (!match(value, /flex-|baseline/)) return MS + "grid-column-align" + substr(value, length2) + value;
|
|
2666
|
-
break;
|
|
2667
|
-
// grid-template-(columns|rows)
|
|
2668
|
-
case 2592:
|
|
2669
|
-
case 3360:
|
|
2670
|
-
return MS + replace(value, "template-", "") + value;
|
|
2671
|
-
// grid-(row|column)-start
|
|
2672
|
-
case 4384:
|
|
2673
|
-
case 3616:
|
|
2674
|
-
return children && children.some(function(element, index) {
|
|
2675
|
-
return length2 = index, match(element.props, /grid-\w+-end/);
|
|
2676
|
-
}) ? ~indexof(value + (children = children[length2].value), "span", 0) ? value : MS + replace(value, "-start", "") + value + MS + "grid-row-span:" + (~indexof(children, "span", 0) ? match(children, /\d+/) : +match(children, /\d+/) - +match(value, /\d+/)) + ";" : MS + replace(value, "-start", "") + value;
|
|
2677
|
-
// grid-(row|column)-end
|
|
2678
|
-
case 4896:
|
|
2679
|
-
case 4128:
|
|
2680
|
-
return children && children.some(function(element) {
|
|
2681
|
-
return match(element.props, /grid-\w+-start/);
|
|
2682
|
-
}) ? value : MS + replace(replace(value, "-end", "-span"), "span ", "") + value;
|
|
2683
|
-
// (margin|padding)-inline-(start|end)
|
|
2684
|
-
case 4095:
|
|
2685
|
-
case 3583:
|
|
2686
|
-
case 4068:
|
|
2687
|
-
case 2532:
|
|
2688
|
-
return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value;
|
|
2689
|
-
// (min|max)?(width|height|inline-size|block-size)
|
|
2690
|
-
case 8116:
|
|
2691
|
-
case 7059:
|
|
2692
|
-
case 5753:
|
|
2693
|
-
case 5535:
|
|
2694
|
-
case 5445:
|
|
2695
|
-
case 5701:
|
|
2696
|
-
case 4933:
|
|
2697
|
-
case 4677:
|
|
2698
|
-
case 5533:
|
|
2699
|
-
case 5789:
|
|
2700
|
-
case 5021:
|
|
2701
|
-
case 4765:
|
|
2702
|
-
if (strlen(value) - 1 - length2 > 6)
|
|
2703
|
-
switch (charat(value, length2 + 1)) {
|
|
2704
|
-
// (m)ax-content, (m)in-content
|
|
2705
|
-
case 109:
|
|
2706
|
-
if (charat(value, length2 + 4) !== 45)
|
|
2707
|
-
break;
|
|
2708
|
-
// (f)ill-available, (f)it-content
|
|
2709
|
-
case 102:
|
|
2710
|
-
return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3$1" + MOZ + (charat(value, length2 + 3) == 108 ? "$3" : "$2-$3")) + value;
|
|
2711
|
-
// (s)tretch
|
|
2712
|
-
case 115:
|
|
2713
|
-
return ~indexof(value, "stretch", 0) ? prefix(replace(value, "stretch", "fill-available"), length2, children) + value : value;
|
|
2714
|
-
}
|
|
2715
|
-
break;
|
|
2716
|
-
// grid-(column|row)
|
|
2717
|
-
case 5152:
|
|
2718
|
-
case 5920:
|
|
2719
|
-
return replace(value, /(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/, function(_2, a, b, c, d, e, f2) {
|
|
2720
|
-
return MS + a + ":" + b + f2 + (c ? MS + a + "-span:" + (d ? e : +e - +b) + f2 : "") + value;
|
|
2721
|
-
});
|
|
2722
|
-
// position: sticky
|
|
2723
|
-
case 4949:
|
|
2724
|
-
if (charat(value, length2 + 6) === 121)
|
|
2725
|
-
return replace(value, ":", ":" + WEBKIT) + value;
|
|
2726
|
-
break;
|
|
2727
|
-
// display: (flex|inline-flex|grid|inline-grid)
|
|
2728
|
-
case 6444:
|
|
2729
|
-
switch (charat(value, charat(value, 14) === 45 ? 18 : 11)) {
|
|
2730
|
-
// (inline-)?fle(x)
|
|
2731
|
-
case 120:
|
|
2732
|
-
return replace(value, /(.+:)([^;\s!]+)(;|(\s+)?!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3$1" + WEBKIT + "$2$3$1" + MS + "$2box$3") + value;
|
|
2733
|
-
// (inline-)?gri(d)
|
|
2734
|
-
case 100:
|
|
2735
|
-
return replace(value, ":", ":" + MS) + value;
|
|
2736
|
-
}
|
|
2737
|
-
break;
|
|
2738
|
-
// scroll-margin, scroll-margin-(top|right|bottom|left)
|
|
2739
|
-
case 5719:
|
|
2740
|
-
case 2647:
|
|
2741
|
-
case 2135:
|
|
2742
|
-
case 3927:
|
|
2743
|
-
case 2391:
|
|
2744
|
-
return replace(value, "scroll-", "scroll-snap-") + value;
|
|
2745
|
-
}
|
|
2746
|
-
return value;
|
|
2747
|
-
}
|
|
2748
|
-
function serialize(children, callback) {
|
|
2749
|
-
for (var output = "", i = 0; i < children.length; i++)
|
|
2750
|
-
output += callback(children[i], i, children, callback) || "";
|
|
2751
|
-
return output;
|
|
2752
|
-
}
|
|
2753
|
-
function stringify(element, index, children, callback) {
|
|
2754
|
-
switch (element.type) {
|
|
2755
|
-
case LAYER:
|
|
2756
|
-
if (element.children.length) break;
|
|
2757
|
-
case IMPORT:
|
|
2758
|
-
case DECLARATION:
|
|
2759
|
-
return element.return = element.return || element.value;
|
|
2760
|
-
case COMMENT:
|
|
2761
|
-
return "";
|
|
2762
|
-
case KEYFRAMES:
|
|
2763
|
-
return element.return = element.value + "{" + serialize(element.children, callback) + "}";
|
|
2764
|
-
case RULESET:
|
|
2765
|
-
if (!strlen(element.value = element.props.join(","))) return "";
|
|
2766
|
-
}
|
|
2767
|
-
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : "";
|
|
2768
|
-
}
|
|
2769
|
-
function middleware(collection) {
|
|
2770
|
-
var length2 = sizeof(collection);
|
|
2771
|
-
return function(element, index, children, callback) {
|
|
2772
|
-
for (var output = "", i = 0; i < length2; i++)
|
|
2773
|
-
output += collection[i](element, index, children, callback) || "";
|
|
2774
|
-
return output;
|
|
2775
|
-
};
|
|
2776
|
-
}
|
|
2777
|
-
function rulesheet(callback) {
|
|
2778
|
-
return function(element) {
|
|
2779
|
-
element.root || (element = element.return) && callback(element);
|
|
2780
|
-
};
|
|
2781
|
-
}
|
|
2782
|
-
function prefixer(element, index, children, callback) {
|
|
2783
|
-
if (element.length > -1 && !element.return)
|
|
2784
|
-
switch (element.type) {
|
|
2785
|
-
case DECLARATION:
|
|
2786
|
-
element.return = prefix(element.value, element.length, children);
|
|
2787
|
-
return;
|
|
2788
|
-
case KEYFRAMES:
|
|
2789
|
-
return serialize([copy(element, { value: replace(element.value, "@", "@" + WEBKIT) })], callback);
|
|
2790
|
-
case RULESET:
|
|
2791
|
-
if (element.length)
|
|
2792
|
-
return combine(children = element.props, function(value) {
|
|
2793
|
-
switch (match(value, callback = /(::plac\w+|:read-\w+)/)) {
|
|
2794
|
-
// :read-(only|write)
|
|
2795
|
-
case ":read-only":
|
|
2796
|
-
case ":read-write":
|
|
2797
|
-
lift(copy(element, { props: [replace(value, /:(read-\w+)/, ":" + MOZ + "$1")] })), lift(copy(element, { props: [value] })), assign(element, { props: filter(children, callback) });
|
|
2798
|
-
break;
|
|
2799
|
-
// :placeholder
|
|
2800
|
-
case "::placeholder":
|
|
2801
|
-
lift(copy(element, { props: [replace(value, /:(plac\w+)/, ":" + WEBKIT + "input-$1")] })), lift(copy(element, { props: [replace(value, /:(plac\w+)/, ":" + MOZ + "$1")] })), lift(copy(element, { props: [replace(value, /:(plac\w+)/, MS + "input-$1")] })), lift(copy(element, { props: [value] })), assign(element, { props: filter(children, callback) });
|
|
2802
|
-
break;
|
|
2803
|
-
}
|
|
2804
|
-
return "";
|
|
2805
|
-
});
|
|
2806
|
-
}
|
|
2807
|
-
}
|
|
2808
|
-
var unitlessKeys = {
|
|
2809
|
-
animationIterationCount: 1,
|
|
2810
|
-
aspectRatio: 1,
|
|
2811
|
-
borderImageOutset: 1,
|
|
2812
|
-
borderImageSlice: 1,
|
|
2813
|
-
borderImageWidth: 1,
|
|
2814
|
-
boxFlex: 1,
|
|
2815
|
-
boxFlexGroup: 1,
|
|
2816
|
-
boxOrdinalGroup: 1,
|
|
2817
|
-
columnCount: 1,
|
|
2818
|
-
columns: 1,
|
|
2819
|
-
flex: 1,
|
|
2820
|
-
flexGrow: 1,
|
|
2821
|
-
flexPositive: 1,
|
|
2822
|
-
flexShrink: 1,
|
|
2823
|
-
flexNegative: 1,
|
|
2824
|
-
flexOrder: 1,
|
|
2825
|
-
gridRow: 1,
|
|
2826
|
-
gridRowEnd: 1,
|
|
2827
|
-
gridRowSpan: 1,
|
|
2828
|
-
gridRowStart: 1,
|
|
2829
|
-
gridColumn: 1,
|
|
2830
|
-
gridColumnEnd: 1,
|
|
2831
|
-
gridColumnSpan: 1,
|
|
2832
|
-
gridColumnStart: 1,
|
|
2833
|
-
msGridRow: 1,
|
|
2834
|
-
msGridRowSpan: 1,
|
|
2835
|
-
msGridColumn: 1,
|
|
2836
|
-
msGridColumnSpan: 1,
|
|
2837
|
-
fontWeight: 1,
|
|
2838
|
-
lineHeight: 1,
|
|
2839
|
-
opacity: 1,
|
|
2840
|
-
order: 1,
|
|
2841
|
-
orphans: 1,
|
|
2842
|
-
tabSize: 1,
|
|
2843
|
-
widows: 1,
|
|
2844
|
-
zIndex: 1,
|
|
2845
|
-
zoom: 1,
|
|
2846
|
-
WebkitLineClamp: 1,
|
|
2847
|
-
// SVG-related properties
|
|
2848
|
-
fillOpacity: 1,
|
|
2849
|
-
floodOpacity: 1,
|
|
2850
|
-
stopOpacity: 1,
|
|
2851
|
-
strokeDasharray: 1,
|
|
2852
|
-
strokeDashoffset: 1,
|
|
2853
|
-
strokeMiterlimit: 1,
|
|
2854
|
-
strokeOpacity: 1,
|
|
2855
|
-
strokeWidth: 1
|
|
2856
|
-
}, f = typeof process < "u" && process.env !== void 0 && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled", m = "active", y = "data-styled-version", v = "6.1.19", g = `/*!sc*/
|
|
2857
|
-
`, S = typeof window < "u" && typeof document < "u", w = !!(typeof SC_DISABLE_SPEEDY == "boolean" ? SC_DISABLE_SPEEDY : typeof process < "u" && process.env !== void 0 && process.env.REACT_APP_SC_DISABLE_SPEEDY !== void 0 && process.env.REACT_APP_SC_DISABLE_SPEEDY !== "" ? process.env.REACT_APP_SC_DISABLE_SPEEDY !== "false" && process.env.REACT_APP_SC_DISABLE_SPEEDY : typeof process < "u" && process.env !== void 0 && process.env.SC_DISABLE_SPEEDY !== void 0 && process.env.SC_DISABLE_SPEEDY !== "" ? process.env.SC_DISABLE_SPEEDY !== "false" && process.env.SC_DISABLE_SPEEDY : process.env.NODE_ENV !== "production"), E = /invalid hook call/i, N = /* @__PURE__ */ new Set(), P = function(t, n) {
|
|
2858
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2859
|
-
var o$1 = n ? ' with the id of "'.concat(n, '"') : "", s = "The component ".concat(t).concat(o$1, ` has been created dynamically.
|
|
2860
|
-
`) + `You may see this warning because you've called styled inside another component.
|
|
2861
|
-
To resolve this only create new StyledComponents outside of any render method and function component.
|
|
2862
|
-
See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
|
|
2863
|
-
`, i = console.error;
|
|
2864
|
-
try {
|
|
2865
|
-
var a = !0;
|
|
2866
|
-
console.error = function(t2) {
|
|
2867
|
-
for (var n2 = [], o2 = 1; o2 < arguments.length; o2++) n2[o2 - 1] = arguments[o2];
|
|
2868
|
-
E.test(t2) ? (a = !1, N.delete(s)) : i.apply(void 0, __spreadArray([t2], n2, !1));
|
|
2869
|
-
}, o.useRef(), a && !N.has(s) && (console.warn(s), N.add(s));
|
|
2870
|
-
} catch (e) {
|
|
2871
|
-
E.test(e.message) && N.delete(s);
|
|
2872
|
-
} finally {
|
|
2873
|
-
console.error = i;
|
|
2874
|
-
}
|
|
2875
|
-
}
|
|
2876
|
-
}, _ = Object.freeze([]), C = Object.freeze({});
|
|
2877
|
-
function I(e, t, n) {
|
|
2878
|
-
return n === void 0 && (n = C), e.theme !== n.theme && e.theme || t || n.theme;
|
|
2879
|
-
}
|
|
2880
|
-
var A = /* @__PURE__ */ new Set(["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "u", "ul", "use", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"]), O = /[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g, D = /(^-|-$)/g;
|
|
2881
|
-
function R(e) {
|
|
2882
|
-
return e.replace(O, "-").replace(D, "");
|
|
2883
|
-
}
|
|
2884
|
-
var T = /(a)(d)/gi, k = 52, j = function(e) {
|
|
2885
|
-
return String.fromCharCode(e + (e > 25 ? 39 : 97));
|
|
2886
|
-
};
|
|
2887
|
-
function x(e) {
|
|
2888
|
-
var t, n = "";
|
|
2889
|
-
for (t = Math.abs(e); t > k; t = t / k | 0) n = j(t % k) + n;
|
|
2890
|
-
return (j(t % k) + n).replace(T, "$1-$2");
|
|
2891
|
-
}
|
|
2892
|
-
var V, F = 5381, z = function(e, t) {
|
|
2893
|
-
for (var n = t.length; n; ) e = 33 * e ^ t.charCodeAt(--n);
|
|
2894
|
-
return e;
|
|
2895
|
-
}, M = function(e) {
|
|
2896
|
-
return z(F, e);
|
|
2897
|
-
};
|
|
2898
|
-
function $(e) {
|
|
2899
|
-
return x(M(e) >>> 0);
|
|
2900
|
-
}
|
|
2901
|
-
function B(e) {
|
|
2902
|
-
return process.env.NODE_ENV !== "production" && typeof e == "string" && e || e.displayName || e.name || "Component";
|
|
2903
|
-
}
|
|
2904
|
-
function G(e) {
|
|
2905
|
-
return typeof e == "string" && (process.env.NODE_ENV === "production" || e.charAt(0) === e.charAt(0).toLowerCase());
|
|
2906
|
-
}
|
|
2907
|
-
var L = typeof Symbol == "function" && Symbol.for, Y = L ? /* @__PURE__ */ Symbol.for("react.memo") : 60115, q = L ? /* @__PURE__ */ Symbol.for("react.forward_ref") : 60112, W = { childContextTypes: !0, contextType: !0, contextTypes: !0, defaultProps: !0, displayName: !0, getDefaultProps: !0, getDerivedStateFromError: !0, getDerivedStateFromProps: !0, mixins: !0, propTypes: !0, type: !0 }, H = { name: !0, length: !0, prototype: !0, caller: !0, callee: !0, arguments: !0, arity: !0 }, U = { $$typeof: !0, compare: !0, defaultProps: !0, displayName: !0, propTypes: !0, type: !0 }, J = ((V = {})[q] = { $$typeof: !0, render: !0, defaultProps: !0, displayName: !0, propTypes: !0 }, V[Y] = U, V);
|
|
2908
|
-
function X(e) {
|
|
2909
|
-
return ("type" in (t = e) && t.type.$$typeof) === Y ? U : "$$typeof" in e ? J[e.$$typeof] : W;
|
|
2910
|
-
var t;
|
|
2911
|
-
}
|
|
2912
|
-
var Z = Object.defineProperty, K = Object.getOwnPropertyNames, Q = Object.getOwnPropertySymbols, ee = Object.getOwnPropertyDescriptor, te = Object.getPrototypeOf, ne = Object.prototype;
|
|
2913
|
-
function oe(e, t, n) {
|
|
2914
|
-
if (typeof t != "string") {
|
|
2915
|
-
if (ne) {
|
|
2916
|
-
var o2 = te(t);
|
|
2917
|
-
o2 && o2 !== ne && oe(e, o2, n);
|
|
2918
|
-
}
|
|
2919
|
-
var r = K(t);
|
|
2920
|
-
Q && (r = r.concat(Q(t)));
|
|
2921
|
-
for (var s = X(e), i = X(t), a = 0; a < r.length; ++a) {
|
|
2922
|
-
var c = r[a];
|
|
2923
|
-
if (!(c in H || n && n[c] || i && c in i || s && c in s)) {
|
|
2924
|
-
var l = ee(t, c);
|
|
2925
|
-
try {
|
|
2926
|
-
Z(e, c, l);
|
|
2927
|
-
} catch {
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2932
|
-
return e;
|
|
2933
|
-
}
|
|
2934
|
-
function re(e) {
|
|
2935
|
-
return typeof e == "function";
|
|
2936
|
-
}
|
|
2937
|
-
function se(e) {
|
|
2938
|
-
return typeof e == "object" && "styledComponentId" in e;
|
|
2939
|
-
}
|
|
2940
|
-
function ie(e, t) {
|
|
2941
|
-
return e && t ? "".concat(e, " ").concat(t) : e || t || "";
|
|
2942
|
-
}
|
|
2943
|
-
function ae(e, t) {
|
|
2944
|
-
if (e.length === 0) return "";
|
|
2945
|
-
for (var n = e[0], o2 = 1; o2 < e.length; o2++) n += e[o2];
|
|
2946
|
-
return n;
|
|
2947
|
-
}
|
|
2948
|
-
function ce(e) {
|
|
2949
|
-
return e !== null && typeof e == "object" && e.constructor.name === Object.name && !("props" in e && e.$$typeof);
|
|
2950
|
-
}
|
|
2951
|
-
function le(e, t, n) {
|
|
2952
|
-
if (n === void 0 && (n = !1), !n && !ce(e) && !Array.isArray(e)) return t;
|
|
2953
|
-
if (Array.isArray(t)) for (var o2 = 0; o2 < t.length; o2++) e[o2] = le(e[o2], t[o2]);
|
|
2954
|
-
else if (ce(t)) for (var o2 in t) e[o2] = le(e[o2], t[o2]);
|
|
2955
|
-
return e;
|
|
2956
|
-
}
|
|
2957
|
-
function ue(e, t) {
|
|
2958
|
-
Object.defineProperty(e, "toString", { value: t });
|
|
2959
|
-
}
|
|
2960
|
-
var pe = process.env.NODE_ENV !== "production" ? { 1: `Cannot create styled-component for component: %s.
|
|
2961
|
-
|
|
2962
|
-
`, 2: `Can't collect styles once you've consumed a \`ServerStyleSheet\`'s styles! \`ServerStyleSheet\` is a one off instance for each server-side render cycle.
|
|
2963
|
-
|
|
2964
|
-
- Are you trying to reuse it across renders?
|
|
2965
|
-
- Are you accidentally calling collectStyles twice?
|
|
2966
|
-
|
|
2967
|
-
`, 3: `Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.
|
|
2968
|
-
|
|
2969
|
-
`, 4: `The \`StyleSheetManager\` expects a valid target or sheet prop!
|
|
2970
|
-
|
|
2971
|
-
- Does this error occur on the client and is your target falsy?
|
|
2972
|
-
- Does this error occur on the server and is the sheet falsy?
|
|
2973
|
-
|
|
2974
|
-
`, 5: `The clone method cannot be used on the client!
|
|
2975
|
-
|
|
2976
|
-
- Are you running in a client-like environment on the server?
|
|
2977
|
-
- Are you trying to run SSR on the client?
|
|
2978
|
-
|
|
2979
|
-
`, 6: `Trying to insert a new style tag, but the given Node is unmounted!
|
|
2980
|
-
|
|
2981
|
-
- Are you using a custom target that isn't mounted?
|
|
2982
|
-
- Does your document not have a valid head element?
|
|
2983
|
-
- Have you accidentally removed a style tag manually?
|
|
2984
|
-
|
|
2985
|
-
`, 7: 'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n', 8: `ThemeProvider: Please make your "theme" prop an object.
|
|
2986
|
-
|
|
2987
|
-
`, 9: "Missing document `<head>`\n\n", 10: `Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021
|
|
2988
|
-
|
|
2989
|
-
`, 11: `_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.
|
|
2990
|
-
|
|
2991
|
-
`, 12: "It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n", 13: `%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.
|
|
2992
|
-
|
|
2993
|
-
`, 14: `ThemeProvider: "theme" prop is required.
|
|
2994
|
-
|
|
2995
|
-
`, 15: "A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n", 16: `Reached the limit of how many styled components may be created at group %s.
|
|
2996
|
-
You may only create up to 1,073,741,824 components. If you're creating components dynamically,
|
|
2997
|
-
as for instance in your render method then you may be running into this limitation.
|
|
2998
|
-
|
|
2999
|
-
`, 17: `CSSStyleSheet could not be found on HTMLStyleElement.
|
|
3000
|
-
Has styled-components' style tag been unmounted or altered by another script?
|
|
3001
|
-
`, 18: "ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`" } : {};
|
|
3002
|
-
function de() {
|
|
3003
|
-
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
|
|
3004
|
-
for (var n = e[0], o2 = [], r = 1, s = e.length; r < s; r += 1) o2.push(e[r]);
|
|
3005
|
-
return o2.forEach(function(e2) {
|
|
3006
|
-
n = n.replace(/%[a-z]/, e2);
|
|
3007
|
-
}), n;
|
|
3008
|
-
}
|
|
3009
|
-
function he(t) {
|
|
3010
|
-
for (var n = [], o2 = 1; o2 < arguments.length; o2++) n[o2 - 1] = arguments[o2];
|
|
3011
|
-
return process.env.NODE_ENV === "production" ? new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t, " for more information.").concat(n.length > 0 ? " Args: ".concat(n.join(", ")) : "")) : new Error(de.apply(void 0, __spreadArray([pe[t]], n, !1)).trim());
|
|
3012
|
-
}
|
|
3013
|
-
var fe = (function() {
|
|
3014
|
-
function e(e2) {
|
|
3015
|
-
this.groupSizes = new Uint32Array(512), this.length = 512, this.tag = e2;
|
|
3016
|
-
}
|
|
3017
|
-
return e.prototype.indexOfGroup = function(e2) {
|
|
3018
|
-
for (var t = 0, n = 0; n < e2; n++) t += this.groupSizes[n];
|
|
3019
|
-
return t;
|
|
3020
|
-
}, e.prototype.insertRules = function(e2, t) {
|
|
3021
|
-
if (e2 >= this.groupSizes.length) {
|
|
3022
|
-
for (var n = this.groupSizes, o2 = n.length, r = o2; e2 >= r; ) if ((r <<= 1) < 0) throw he(16, "".concat(e2));
|
|
3023
|
-
this.groupSizes = new Uint32Array(r), this.groupSizes.set(n), this.length = r;
|
|
3024
|
-
for (var s = o2; s < r; s++) this.groupSizes[s] = 0;
|
|
3025
|
-
}
|
|
3026
|
-
for (var i = this.indexOfGroup(e2 + 1), a = (s = 0, t.length); s < a; s++) this.tag.insertRule(i, t[s]) && (this.groupSizes[e2]++, i++);
|
|
3027
|
-
}, e.prototype.clearGroup = function(e2) {
|
|
3028
|
-
if (e2 < this.length) {
|
|
3029
|
-
var t = this.groupSizes[e2], n = this.indexOfGroup(e2), o2 = n + t;
|
|
3030
|
-
this.groupSizes[e2] = 0;
|
|
3031
|
-
for (var r = n; r < o2; r++) this.tag.deleteRule(n);
|
|
3032
|
-
}
|
|
3033
|
-
}, e.prototype.getGroup = function(e2) {
|
|
3034
|
-
var t = "";
|
|
3035
|
-
if (e2 >= this.length || this.groupSizes[e2] === 0) return t;
|
|
3036
|
-
for (var n = this.groupSizes[e2], o2 = this.indexOfGroup(e2), r = o2 + n, s = o2; s < r; s++) t += "".concat(this.tag.getRule(s)).concat(g);
|
|
3037
|
-
return t;
|
|
3038
|
-
}, e;
|
|
3039
|
-
})(), me = 1 << 30, ye = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ new Map(), ge = 1, Se = function(e) {
|
|
3040
|
-
if (ye.has(e)) return ye.get(e);
|
|
3041
|
-
for (; ve.has(ge); ) ge++;
|
|
3042
|
-
var t = ge++;
|
|
3043
|
-
if (process.env.NODE_ENV !== "production" && ((0 | t) < 0 || t > me)) throw he(16, "".concat(t));
|
|
3044
|
-
return ye.set(e, t), ve.set(t, e), t;
|
|
3045
|
-
}, we = function(e, t) {
|
|
3046
|
-
ge = t + 1, ye.set(e, t), ve.set(t, e);
|
|
3047
|
-
}, be = "style[".concat(f, "][").concat(y, '="').concat(v, '"]'), Ee = new RegExp("^".concat(f, '\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')), Ne = function(e, t, n) {
|
|
3048
|
-
for (var o2, r = n.split(","), s = 0, i = r.length; s < i; s++) (o2 = r[s]) && e.registerName(t, o2);
|
|
3049
|
-
}, Pe = function(e, t) {
|
|
3050
|
-
for (var n, o2 = ((n = t.textContent) !== null && n !== void 0 ? n : "").split(g), r = [], s = 0, i = o2.length; s < i; s++) {
|
|
3051
|
-
var a = o2[s].trim();
|
|
3052
|
-
if (a) {
|
|
3053
|
-
var c = a.match(Ee);
|
|
3054
|
-
if (c) {
|
|
3055
|
-
var l = 0 | parseInt(c[1], 10), u = c[2];
|
|
3056
|
-
l !== 0 && (we(u, l), Ne(e, u, c[3]), e.getTag().insertRules(l, r)), r.length = 0;
|
|
3057
|
-
} else r.push(a);
|
|
3058
|
-
}
|
|
3059
|
-
}
|
|
3060
|
-
}, _e = function(e) {
|
|
3061
|
-
for (var t = document.querySelectorAll(be), n = 0, o2 = t.length; n < o2; n++) {
|
|
3062
|
-
var r = t[n];
|
|
3063
|
-
r && r.getAttribute(f) !== m && (Pe(e, r), r.parentNode && r.parentNode.removeChild(r));
|
|
3064
|
-
}
|
|
3065
|
-
};
|
|
3066
|
-
function Ce() {
|
|
3067
|
-
return typeof __webpack_nonce__ < "u" ? __webpack_nonce__ : null;
|
|
3068
|
-
}
|
|
3069
|
-
var Ie = function(e) {
|
|
3070
|
-
var t = document.head, n = e || t, o2 = document.createElement("style"), r = (function(e2) {
|
|
3071
|
-
var t2 = Array.from(e2.querySelectorAll("style[".concat(f, "]")));
|
|
3072
|
-
return t2[t2.length - 1];
|
|
3073
|
-
})(n), s = r !== void 0 ? r.nextSibling : null;
|
|
3074
|
-
o2.setAttribute(f, m), o2.setAttribute(y, v);
|
|
3075
|
-
var i = Ce();
|
|
3076
|
-
return i && o2.setAttribute("nonce", i), n.insertBefore(o2, s), o2;
|
|
3077
|
-
}, Ae = (function() {
|
|
3078
|
-
function e(e2) {
|
|
3079
|
-
this.element = Ie(e2), this.element.appendChild(document.createTextNode("")), this.sheet = (function(e3) {
|
|
3080
|
-
if (e3.sheet) return e3.sheet;
|
|
3081
|
-
for (var t = document.styleSheets, n = 0, o2 = t.length; n < o2; n++) {
|
|
3082
|
-
var r = t[n];
|
|
3083
|
-
if (r.ownerNode === e3) return r;
|
|
3084
|
-
}
|
|
3085
|
-
throw he(17);
|
|
3086
|
-
})(this.element), this.length = 0;
|
|
3087
|
-
}
|
|
3088
|
-
return e.prototype.insertRule = function(e2, t) {
|
|
3089
|
-
try {
|
|
3090
|
-
return this.sheet.insertRule(t, e2), this.length++, !0;
|
|
3091
|
-
} catch {
|
|
3092
|
-
return !1;
|
|
3093
|
-
}
|
|
3094
|
-
}, e.prototype.deleteRule = function(e2) {
|
|
3095
|
-
this.sheet.deleteRule(e2), this.length--;
|
|
3096
|
-
}, e.prototype.getRule = function(e2) {
|
|
3097
|
-
var t = this.sheet.cssRules[e2];
|
|
3098
|
-
return t && t.cssText ? t.cssText : "";
|
|
3099
|
-
}, e;
|
|
3100
|
-
})(), Oe = (function() {
|
|
3101
|
-
function e(e2) {
|
|
3102
|
-
this.element = Ie(e2), this.nodes = this.element.childNodes, this.length = 0;
|
|
3103
|
-
}
|
|
3104
|
-
return e.prototype.insertRule = function(e2, t) {
|
|
3105
|
-
if (e2 <= this.length && e2 >= 0) {
|
|
3106
|
-
var n = document.createTextNode(t);
|
|
3107
|
-
return this.element.insertBefore(n, this.nodes[e2] || null), this.length++, !0;
|
|
3108
|
-
}
|
|
3109
|
-
return !1;
|
|
3110
|
-
}, e.prototype.deleteRule = function(e2) {
|
|
3111
|
-
this.element.removeChild(this.nodes[e2]), this.length--;
|
|
3112
|
-
}, e.prototype.getRule = function(e2) {
|
|
3113
|
-
return e2 < this.length ? this.nodes[e2].textContent : "";
|
|
3114
|
-
}, e;
|
|
3115
|
-
})(), De = (function() {
|
|
3116
|
-
function e(e2) {
|
|
3117
|
-
this.rules = [], this.length = 0;
|
|
3118
|
-
}
|
|
3119
|
-
return e.prototype.insertRule = function(e2, t) {
|
|
3120
|
-
return e2 <= this.length && (this.rules.splice(e2, 0, t), this.length++, !0);
|
|
3121
|
-
}, e.prototype.deleteRule = function(e2) {
|
|
3122
|
-
this.rules.splice(e2, 1), this.length--;
|
|
3123
|
-
}, e.prototype.getRule = function(e2) {
|
|
3124
|
-
return e2 < this.length ? this.rules[e2] : "";
|
|
3125
|
-
}, e;
|
|
3126
|
-
})(), Re = S, Te = { isServer: !S, useCSSOMInjection: !w }, ke = (function() {
|
|
3127
|
-
function e(e2, n, o2) {
|
|
3128
|
-
e2 === void 0 && (e2 = C), n === void 0 && (n = {});
|
|
3129
|
-
var r = this;
|
|
3130
|
-
this.options = __assign(__assign({}, Te), e2), this.gs = n, this.names = new Map(o2), this.server = !!e2.isServer, !this.server && S && Re && (Re = !1, _e(this)), ue(this, function() {
|
|
3131
|
-
return (function(e3) {
|
|
3132
|
-
for (var t = e3.getTag(), n2 = t.length, o3 = "", r2 = function(n3) {
|
|
3133
|
-
var r3 = (function(e4) {
|
|
3134
|
-
return ve.get(e4);
|
|
3135
|
-
})(n3);
|
|
3136
|
-
if (r3 === void 0) return "continue";
|
|
3137
|
-
var s2 = e3.names.get(r3), i = t.getGroup(n3);
|
|
3138
|
-
if (s2 === void 0 || !s2.size || i.length === 0) return "continue";
|
|
3139
|
-
var a = "".concat(f, ".g").concat(n3, '[id="').concat(r3, '"]'), c = "";
|
|
3140
|
-
s2 !== void 0 && s2.forEach(function(e4) {
|
|
3141
|
-
e4.length > 0 && (c += "".concat(e4, ","));
|
|
3142
|
-
}), o3 += "".concat(i).concat(a, '{content:"').concat(c, '"}').concat(g);
|
|
3143
|
-
}, s = 0; s < n2; s++) r2(s);
|
|
3144
|
-
return o3;
|
|
3145
|
-
})(r);
|
|
3146
|
-
});
|
|
3147
|
-
}
|
|
3148
|
-
return e.registerId = function(e2) {
|
|
3149
|
-
return Se(e2);
|
|
3150
|
-
}, e.prototype.rehydrate = function() {
|
|
3151
|
-
!this.server && S && _e(this);
|
|
3152
|
-
}, e.prototype.reconstructWithOptions = function(n, o2) {
|
|
3153
|
-
return o2 === void 0 && (o2 = !0), new e(__assign(__assign({}, this.options), n), this.gs, o2 && this.names || void 0);
|
|
3154
|
-
}, e.prototype.allocateGSInstance = function(e2) {
|
|
3155
|
-
return this.gs[e2] = (this.gs[e2] || 0) + 1;
|
|
3156
|
-
}, e.prototype.getTag = function() {
|
|
3157
|
-
return this.tag || (this.tag = (e2 = (function(e3) {
|
|
3158
|
-
var t = e3.useCSSOMInjection, n = e3.target;
|
|
3159
|
-
return e3.isServer ? new De(n) : t ? new Ae(n) : new Oe(n);
|
|
3160
|
-
})(this.options), new fe(e2)));
|
|
3161
|
-
var e2;
|
|
3162
|
-
}, e.prototype.hasNameForId = function(e2, t) {
|
|
3163
|
-
return this.names.has(e2) && this.names.get(e2).has(t);
|
|
3164
|
-
}, e.prototype.registerName = function(e2, t) {
|
|
3165
|
-
if (Se(e2), this.names.has(e2)) this.names.get(e2).add(t);
|
|
3166
|
-
else {
|
|
3167
|
-
var n = /* @__PURE__ */ new Set();
|
|
3168
|
-
n.add(t), this.names.set(e2, n);
|
|
3169
|
-
}
|
|
3170
|
-
}, e.prototype.insertRules = function(e2, t, n) {
|
|
3171
|
-
this.registerName(e2, t), this.getTag().insertRules(Se(e2), n);
|
|
3172
|
-
}, e.prototype.clearNames = function(e2) {
|
|
3173
|
-
this.names.has(e2) && this.names.get(e2).clear();
|
|
3174
|
-
}, e.prototype.clearRules = function(e2) {
|
|
3175
|
-
this.getTag().clearGroup(Se(e2)), this.clearNames(e2);
|
|
3176
|
-
}, e.prototype.clearTag = function() {
|
|
3177
|
-
this.tag = void 0;
|
|
3178
|
-
}, e;
|
|
3179
|
-
})(), je = /&/g, xe = /^\s*\/\/.*$/gm;
|
|
3180
|
-
function Ve(e, t) {
|
|
3181
|
-
return e.map(function(e2) {
|
|
3182
|
-
return e2.type === "rule" && (e2.value = "".concat(t, " ").concat(e2.value), e2.value = e2.value.replaceAll(",", ",".concat(t, " ")), e2.props = e2.props.map(function(e3) {
|
|
3183
|
-
return "".concat(t, " ").concat(e3);
|
|
3184
|
-
})), Array.isArray(e2.children) && e2.type !== "@keyframes" && (e2.children = Ve(e2.children, t)), e2;
|
|
3185
|
-
});
|
|
3186
|
-
}
|
|
3187
|
-
function Fe(e) {
|
|
3188
|
-
var t, n, o2, r = C, s = r.options, i = s === void 0 ? C : s, a = r.plugins, c = a === void 0 ? _ : a, l = function(e2, o3, r2) {
|
|
3189
|
-
return r2.startsWith(n) && r2.endsWith(n) && r2.replaceAll(n, "").length > 0 ? ".".concat(t) : e2;
|
|
3190
|
-
}, u = c.slice();
|
|
3191
|
-
u.push(function(e2) {
|
|
3192
|
-
e2.type === RULESET && e2.value.includes("&") && (e2.props[0] = e2.props[0].replace(je, n).replace(o2, l));
|
|
3193
|
-
}), i.prefix && u.push(prefixer), u.push(stringify);
|
|
3194
|
-
var p = function(e2, r2, s2, a2) {
|
|
3195
|
-
r2 === void 0 && (r2 = ""), s2 === void 0 && (s2 = ""), a2 === void 0 && (a2 = "&"), t = a2, n = r2, o2 = new RegExp("\\".concat(n, "\\b"), "g");
|
|
3196
|
-
var c2 = e2.replace(xe, ""), l2 = compile(s2 || r2 ? "".concat(s2, " ").concat(r2, " { ").concat(c2, " }") : c2);
|
|
3197
|
-
i.namespace && (l2 = Ve(l2, i.namespace));
|
|
3198
|
-
var p2 = [];
|
|
3199
|
-
return serialize(l2, middleware(u.concat(rulesheet(function(e3) {
|
|
3200
|
-
return p2.push(e3);
|
|
3201
|
-
})))), p2;
|
|
3202
|
-
};
|
|
3203
|
-
return p.hash = c.length ? c.reduce(function(e2, t2) {
|
|
3204
|
-
return t2.name || he(15), z(e2, t2.name);
|
|
3205
|
-
}, F).toString() : "", p;
|
|
3206
|
-
}
|
|
3207
|
-
var ze = new ke(), Me = Fe(), $e = o__default.default.createContext({ shouldForwardProp: void 0, styleSheet: ze, stylis: Me });
|
|
3208
|
-
o__default.default.createContext(void 0);
|
|
3209
|
-
function Le() {
|
|
3210
|
-
return o.useContext($e);
|
|
3211
|
-
}
|
|
3212
|
-
var qe = (function() {
|
|
3213
|
-
function e(e2, t) {
|
|
3214
|
-
var n = this;
|
|
3215
|
-
this.inject = function(e3, t2) {
|
|
3216
|
-
t2 === void 0 && (t2 = Me);
|
|
3217
|
-
var o2 = n.name + t2.hash;
|
|
3218
|
-
e3.hasNameForId(n.id, o2) || e3.insertRules(n.id, o2, t2(n.rules, o2, "@keyframes"));
|
|
3219
|
-
}, this.name = e2, this.id = "sc-keyframes-".concat(e2), this.rules = t, ue(this, function() {
|
|
3220
|
-
throw he(12, String(n.name));
|
|
3221
|
-
});
|
|
3222
|
-
}
|
|
3223
|
-
return e.prototype.getName = function(e2) {
|
|
3224
|
-
return e2 === void 0 && (e2 = Me), this.name + e2.hash;
|
|
3225
|
-
}, e;
|
|
3226
|
-
})(), We = function(e) {
|
|
3227
|
-
return e >= "A" && e <= "Z";
|
|
3228
|
-
};
|
|
3229
|
-
function He(e) {
|
|
3230
|
-
for (var t = "", n = 0; n < e.length; n++) {
|
|
3231
|
-
var o2 = e[n];
|
|
3232
|
-
if (n === 1 && o2 === "-" && e[0] === "-") return e;
|
|
3233
|
-
We(o2) ? t += "-" + o2.toLowerCase() : t += o2;
|
|
3234
|
-
}
|
|
3235
|
-
return t.startsWith("ms-") ? "-" + t : t;
|
|
3236
|
-
}
|
|
3237
|
-
var Ue = function(e) {
|
|
3238
|
-
return e == null || e === !1 || e === "";
|
|
3239
|
-
}, Je = function(t) {
|
|
3240
|
-
var n, o2, r = [];
|
|
3241
|
-
for (var s in t) {
|
|
3242
|
-
var i = t[s];
|
|
3243
|
-
t.hasOwnProperty(s) && !Ue(i) && (Array.isArray(i) && i.isCss || re(i) ? r.push("".concat(He(s), ":"), i, ";") : ce(i) ? r.push.apply(r, __spreadArray(__spreadArray(["".concat(s, " {")], Je(i), !1), ["}"], !1)) : r.push("".concat(He(s), ": ").concat((n = s, (o2 = i) == null || typeof o2 == "boolean" || o2 === "" ? "" : typeof o2 != "number" || o2 === 0 || n in unitlessKeys || n.startsWith("--") ? String(o2).trim() : "".concat(o2, "px")), ";")));
|
|
3244
|
-
}
|
|
3245
|
-
return r;
|
|
3246
|
-
};
|
|
3247
|
-
function Xe(e, t, n, o2) {
|
|
3248
|
-
if (Ue(e)) return [];
|
|
3249
|
-
if (se(e)) return [".".concat(e.styledComponentId)];
|
|
3250
|
-
if (re(e)) {
|
|
3251
|
-
if (!re(s = e) || s.prototype && s.prototype.isReactComponent || !t) return [e];
|
|
3252
|
-
var r = e(t);
|
|
3253
|
-
return process.env.NODE_ENV === "production" || typeof r != "object" || Array.isArray(r) || r instanceof qe || ce(r) || r === null || console.error("".concat(B(e), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")), Xe(r, t, n, o2);
|
|
3254
|
-
}
|
|
3255
|
-
var s;
|
|
3256
|
-
return e instanceof qe ? n ? (e.inject(n, o2), [e.getName(o2)]) : [e] : ce(e) ? Je(e) : Array.isArray(e) ? Array.prototype.concat.apply(_, e.map(function(e2) {
|
|
3257
|
-
return Xe(e2, t, n, o2);
|
|
3258
|
-
})) : [e.toString()];
|
|
3259
|
-
}
|
|
3260
|
-
function Ze(e) {
|
|
3261
|
-
for (var t = 0; t < e.length; t += 1) {
|
|
3262
|
-
var n = e[t];
|
|
3263
|
-
if (re(n) && !se(n)) return !1;
|
|
3264
|
-
}
|
|
3265
|
-
return !0;
|
|
3266
|
-
}
|
|
3267
|
-
var Ke = M(v), Qe = (function() {
|
|
3268
|
-
function e(e2, t, n) {
|
|
3269
|
-
this.rules = e2, this.staticRulesId = "", this.isStatic = process.env.NODE_ENV === "production" && (n === void 0 || n.isStatic) && Ze(e2), this.componentId = t, this.baseHash = z(Ke, t), this.baseStyle = n, ke.registerId(t);
|
|
3270
|
-
}
|
|
3271
|
-
return e.prototype.generateAndInjectStyles = function(e2, t, n) {
|
|
3272
|
-
var o2 = this.baseStyle ? this.baseStyle.generateAndInjectStyles(e2, t, n) : "";
|
|
3273
|
-
if (this.isStatic && !n.hash) if (this.staticRulesId && t.hasNameForId(this.componentId, this.staticRulesId)) o2 = ie(o2, this.staticRulesId);
|
|
3274
|
-
else {
|
|
3275
|
-
var r = ae(Xe(this.rules, e2, t, n)), s = x(z(this.baseHash, r) >>> 0);
|
|
3276
|
-
if (!t.hasNameForId(this.componentId, s)) {
|
|
3277
|
-
var i = n(r, ".".concat(s), void 0, this.componentId);
|
|
3278
|
-
t.insertRules(this.componentId, s, i);
|
|
3279
|
-
}
|
|
3280
|
-
o2 = ie(o2, s), this.staticRulesId = s;
|
|
3281
|
-
}
|
|
3282
|
-
else {
|
|
3283
|
-
for (var a = z(this.baseHash, n.hash), c = "", l = 0; l < this.rules.length; l++) {
|
|
3284
|
-
var u = this.rules[l];
|
|
3285
|
-
if (typeof u == "string") c += u, process.env.NODE_ENV !== "production" && (a = z(a, u));
|
|
3286
|
-
else if (u) {
|
|
3287
|
-
var p = ae(Xe(u, e2, t, n));
|
|
3288
|
-
a = z(a, p + l), c += p;
|
|
3289
|
-
}
|
|
3290
|
-
}
|
|
3291
|
-
if (c) {
|
|
3292
|
-
var d = x(a >>> 0);
|
|
3293
|
-
t.hasNameForId(this.componentId, d) || t.insertRules(this.componentId, d, n(c, ".".concat(d), void 0, this.componentId)), o2 = ie(o2, d);
|
|
3294
|
-
}
|
|
3295
|
-
}
|
|
3296
|
-
return o2;
|
|
3297
|
-
}, e;
|
|
3298
|
-
})(), et = o__default.default.createContext(void 0), rt = {}, st = /* @__PURE__ */ new Set();
|
|
3299
|
-
function it(e, r, s) {
|
|
3300
|
-
var i = se(e), a = e, c = !G(e), p = r.attrs, d = p === void 0 ? _ : p, h = r.componentId, f2 = h === void 0 ? (function(e2, t) {
|
|
3301
|
-
var n = typeof e2 != "string" ? "sc" : R(e2);
|
|
3302
|
-
rt[n] = (rt[n] || 0) + 1;
|
|
3303
|
-
var o2 = "".concat(n, "-").concat($(v + n + rt[n]));
|
|
3304
|
-
return t ? "".concat(t, "-").concat(o2) : o2;
|
|
3305
|
-
})(r.displayName, r.parentComponentId) : h, m2 = r.displayName, y2 = m2 === void 0 ? (function(e2) {
|
|
3306
|
-
return G(e2) ? "styled.".concat(e2) : "Styled(".concat(B(e2), ")");
|
|
3307
|
-
})(e) : m2, g2 = r.displayName && r.componentId ? "".concat(R(r.displayName), "-").concat(r.componentId) : r.componentId || f2, S2 = i && a.attrs ? a.attrs.concat(d).filter(Boolean) : d, w2 = r.shouldForwardProp;
|
|
3308
|
-
if (i && a.shouldForwardProp) {
|
|
3309
|
-
var b = a.shouldForwardProp;
|
|
3310
|
-
if (r.shouldForwardProp) {
|
|
3311
|
-
var E2 = r.shouldForwardProp;
|
|
3312
|
-
w2 = function(e2, t) {
|
|
3313
|
-
return b(e2, t) && E2(e2, t);
|
|
3314
|
-
};
|
|
3315
|
-
} else w2 = b;
|
|
3316
|
-
}
|
|
3317
|
-
var N2 = new Qe(s, g2, i ? a.componentStyle : void 0);
|
|
3318
|
-
function O2(e2, r2) {
|
|
3319
|
-
return (function(e3, r3, s2) {
|
|
3320
|
-
var i2 = e3.attrs, a2 = e3.componentStyle, c2 = e3.defaultProps, p2 = e3.foldedComponentIds, d2 = e3.styledComponentId, h2 = e3.target, f3 = o__default.default.useContext(et), m3 = Le(), y3 = e3.shouldForwardProp || m3.shouldForwardProp;
|
|
3321
|
-
process.env.NODE_ENV !== "production" && o.useDebugValue(d2);
|
|
3322
|
-
var v2 = I(r3, f3, c2) || C, g3 = (function(e4, n, o2) {
|
|
3323
|
-
for (var r4, s3 = __assign(__assign({}, n), { className: void 0, theme: o2 }), i3 = 0; i3 < e4.length; i3 += 1) {
|
|
3324
|
-
var a3 = re(r4 = e4[i3]) ? r4(s3) : r4;
|
|
3325
|
-
for (var c3 in a3) s3[c3] = c3 === "className" ? ie(s3[c3], a3[c3]) : c3 === "style" ? __assign(__assign({}, s3[c3]), a3[c3]) : a3[c3];
|
|
3326
|
-
}
|
|
3327
|
-
return n.className && (s3.className = ie(s3.className, n.className)), s3;
|
|
3328
|
-
})(i2, r3, v2), S3 = g3.as || h2, w3 = {};
|
|
3329
|
-
for (var b2 in g3) g3[b2] === void 0 || b2[0] === "$" || b2 === "as" || b2 === "theme" && g3.theme === v2 || (b2 === "forwardedAs" ? w3.as = g3.forwardedAs : y3 && !y3(b2, S3) || (w3[b2] = g3[b2], y3 || process.env.NODE_ENV !== "development" || isPropValid(b2) || st.has(b2) || !A.has(S3) || (st.add(b2), console.warn('styled-components: it looks like an unknown prop "'.concat(b2, '" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));
|
|
3330
|
-
var E3 = (function(e4, t) {
|
|
3331
|
-
var n = Le(), o$1 = e4.generateAndInjectStyles(t, n.styleSheet, n.stylis);
|
|
3332
|
-
return process.env.NODE_ENV !== "production" && o.useDebugValue(o$1), o$1;
|
|
3333
|
-
})(a2, g3);
|
|
3334
|
-
process.env.NODE_ENV !== "production" && e3.warnTooManyClasses && e3.warnTooManyClasses(E3);
|
|
3335
|
-
var N3 = ie(p2, d2);
|
|
3336
|
-
return E3 && (N3 += " " + E3), g3.className && (N3 += " " + g3.className), w3[G(S3) && !A.has(S3) ? "class" : "className"] = N3, s2 && (w3.ref = s2), o.createElement(S3, w3);
|
|
3337
|
-
})(D2, e2, r2);
|
|
3338
|
-
}
|
|
3339
|
-
O2.displayName = y2;
|
|
3340
|
-
var D2 = o__default.default.forwardRef(O2);
|
|
3341
|
-
return D2.attrs = S2, D2.componentStyle = N2, D2.displayName = y2, D2.shouldForwardProp = w2, D2.foldedComponentIds = i ? ie(a.foldedComponentIds, a.styledComponentId) : "", D2.styledComponentId = g2, D2.target = i ? a.target : e, Object.defineProperty(D2, "defaultProps", { get: function() {
|
|
3342
|
-
return this._foldedDefaultProps;
|
|
3343
|
-
}, set: function(e2) {
|
|
3344
|
-
this._foldedDefaultProps = i ? (function(e3) {
|
|
3345
|
-
for (var t = [], n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
|
|
3346
|
-
for (var o2 = 0, r2 = t; o2 < r2.length; o2++) le(e3, r2[o2], !0);
|
|
3347
|
-
return e3;
|
|
3348
|
-
})({}, a.defaultProps, e2) : e2;
|
|
3349
|
-
} }), process.env.NODE_ENV !== "production" && (P(y2, g2), D2.warnTooManyClasses = /* @__PURE__ */ (function(e2, t) {
|
|
3350
|
-
var n = {}, o2 = !1;
|
|
3351
|
-
return function(r2) {
|
|
3352
|
-
if (!o2 && (n[r2] = !0, Object.keys(n).length >= 200)) {
|
|
3353
|
-
var s2 = t ? ' with the id of "'.concat(t, '"') : "";
|
|
3354
|
-
console.warn("Over ".concat(200, " classes were generated for component ").concat(e2).concat(s2, `.
|
|
3355
|
-
`) + `Consider using the attrs method, together with a style object for frequently changed styles.
|
|
3356
|
-
Example:
|
|
3357
|
-
const Component = styled.div.attrs(props => ({
|
|
3358
|
-
style: {
|
|
3359
|
-
background: props.background,
|
|
3360
|
-
},
|
|
3361
|
-
}))\`width: 100%;\`
|
|
3362
|
-
|
|
3363
|
-
<Component />`), o2 = !0, n = {};
|
|
3364
|
-
}
|
|
3365
|
-
};
|
|
3366
|
-
})(y2, g2)), ue(D2, function() {
|
|
3367
|
-
return ".".concat(D2.styledComponentId);
|
|
3368
|
-
}), c && oe(D2, e, { attrs: !0, componentStyle: !0, displayName: !0, foldedComponentIds: !0, shouldForwardProp: !0, styledComponentId: !0, target: !0 }), D2;
|
|
3369
|
-
}
|
|
3370
|
-
function at(e, t) {
|
|
3371
|
-
for (var n = [e[0]], o2 = 0, r = t.length; o2 < r; o2 += 1) n.push(t[o2], e[o2 + 1]);
|
|
3372
|
-
return n;
|
|
3373
|
-
}
|
|
3374
|
-
var ct = function(e) {
|
|
3375
|
-
return Object.assign(e, { isCss: !0 });
|
|
3376
|
-
};
|
|
3377
|
-
function lt(t) {
|
|
3378
|
-
for (var n = [], o2 = 1; o2 < arguments.length; o2++) n[o2 - 1] = arguments[o2];
|
|
3379
|
-
if (re(t) || ce(t)) return ct(Xe(at(_, __spreadArray([t], n, !0))));
|
|
3380
|
-
var r = t;
|
|
3381
|
-
return n.length === 0 && r.length === 1 && typeof r[0] == "string" ? Xe(r) : ct(Xe(at(r, n)));
|
|
3382
|
-
}
|
|
3383
|
-
function ut(n, o2, r) {
|
|
3384
|
-
if (r === void 0 && (r = C), !o2) throw he(1, o2);
|
|
3385
|
-
var s = function(t) {
|
|
3386
|
-
for (var s2 = [], i = 1; i < arguments.length; i++) s2[i - 1] = arguments[i];
|
|
3387
|
-
return n(o2, r, lt.apply(void 0, __spreadArray([t], s2, !1)));
|
|
3388
|
-
};
|
|
3389
|
-
return s.attrs = function(e) {
|
|
3390
|
-
return ut(n, o2, __assign(__assign({}, r), { attrs: Array.prototype.concat(r.attrs, e).filter(Boolean) }));
|
|
3391
|
-
}, s.withConfig = function(e) {
|
|
3392
|
-
return ut(n, o2, __assign(__assign({}, r), e));
|
|
3393
|
-
}, s;
|
|
3394
|
-
}
|
|
3395
|
-
var pt = function(e) {
|
|
3396
|
-
return ut(it, e);
|
|
3397
|
-
}, dt = pt;
|
|
3398
|
-
A.forEach(function(e) {
|
|
3399
|
-
dt[e] = pt(e);
|
|
3400
|
-
});
|
|
3401
|
-
process.env.NODE_ENV !== "production" && typeof navigator < "u" && navigator.product === "ReactNative" && console.warn(`It looks like you've imported 'styled-components' on React Native.
|
|
3402
|
-
Perhaps you're looking to import 'styled-components/native'?
|
|
3403
|
-
Read more about this at https://www.styled-components.com/docs/basics#react-native`);
|
|
3404
|
-
var wt = "__sc-".concat(f, "__");
|
|
3405
|
-
process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && typeof window < "u" && (window[wt] || (window[wt] = 0), window[wt] === 1 && console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
|
|
3406
|
-
|
|
3407
|
-
See https://s-c.sh/2BAXzed for more info.`), window[wt] += 1);
|
|
3408
|
-
const WrapText = dt(ui.Box)`
|
|
3409
|
-
white-space: normal;
|
|
3410
|
-
`, LocaleCheckbox = ({
|
|
2382
|
+
] });
|
|
2383
|
+
}, LocaleCheckbox = ({
|
|
3411
2384
|
locale,
|
|
3412
2385
|
toggle,
|
|
3413
2386
|
checked
|
|
3414
2387
|
}) => {
|
|
3415
|
-
const onClick =
|
|
2388
|
+
const onClick = React.useCallback(
|
|
3416
2389
|
() => toggle(locale.localeId, !checked),
|
|
3417
2390
|
[locale.localeId, toggle, checked]
|
|
3418
2391
|
);
|
|
@@ -3422,17 +2395,17 @@ const WrapText = dt(ui.Box)`
|
|
|
3422
2395
|
mode: "ghost",
|
|
3423
2396
|
onClick,
|
|
3424
2397
|
style: { cursor: "pointer" },
|
|
3425
|
-
|
|
2398
|
+
padding: 3,
|
|
3426
2399
|
children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 3, children: [
|
|
3427
2400
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3428
|
-
ui.
|
|
2401
|
+
ui.Checkbox,
|
|
3429
2402
|
{
|
|
3430
2403
|
style: { pointerEvents: "none" },
|
|
3431
2404
|
onChange: onClick,
|
|
3432
2405
|
checked
|
|
3433
2406
|
}
|
|
3434
2407
|
),
|
|
3435
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2408
|
+
/* @__PURE__ */ jsxRuntime.jsx(LocaleLabel, { localeId: locale.localeId })
|
|
3436
2409
|
] })
|
|
3437
2410
|
}
|
|
3438
2411
|
);
|
|
@@ -3460,20 +2433,23 @@ const WrapText = dt(ui.Box)`
|
|
|
3460
2433
|
autoPublish,
|
|
3461
2434
|
setAutoPublish,
|
|
3462
2435
|
getVersionId
|
|
3463
|
-
} = useTranslations(), [isImporting, setIsImporting] =
|
|
2436
|
+
} = useTranslations(), [isImporting, setIsImporting] = React.useState(!1), [isPublishing, setIsPublishing] = React.useState(!1), toast = ui.useToast(), document2 = documents[0], currentDocumentLanguage = React.useMemo(() => {
|
|
3464
2437
|
if (!document2) return null;
|
|
3465
2438
|
const languageField = pluginConfig.getLanguageField();
|
|
3466
2439
|
return document2[languageField] || pluginConfig.getSourceLocale();
|
|
3467
|
-
}, [document2]), shouldShowTranslationComponents =
|
|
2440
|
+
}, [document2]), shouldShowTranslationComponents = React.useMemo(() => currentDocumentLanguage ? currentDocumentLanguage === pluginConfig.getSourceLocale() : !1, [currentDocumentLanguage]), availableLocales = React.useMemo(() => {
|
|
3468
2441
|
const sourceLocale = pluginConfig.getSourceLocale();
|
|
3469
2442
|
return locales.filter(
|
|
3470
2443
|
(locale) => locale.enabled !== !1 && locale.localeId !== sourceLocale
|
|
3471
2444
|
);
|
|
3472
|
-
}, [locales]),
|
|
2445
|
+
}, [locales]), statusLocales = React.useMemo(() => {
|
|
2446
|
+
const sourceLocale = pluginConfig.getSourceLocale();
|
|
2447
|
+
return locales.filter((locale) => locale.localeId !== sourceLocale);
|
|
2448
|
+
}, [locales]), documentId = React.useMemo(() => document2 ? getDocumentPublishedId(document2) : null, [document2]), versionId = React.useMemo(() => document2 ? getVersionId(document2) : null, [document2, getVersionId]), handleImportTranslations = React.useCallback(
|
|
3473
2449
|
async (options = {}) => {
|
|
3474
2450
|
const { autoOnly = !1 } = options;
|
|
3475
2451
|
if (isImporting || !documentId || !versionId || autoOnly && !autoImport) return;
|
|
3476
|
-
const readyTranslations =
|
|
2452
|
+
const readyTranslations = statusLocales.filter((locale) => {
|
|
3477
2453
|
const key = createTranslationStatusKey(
|
|
3478
2454
|
branchId,
|
|
3479
2455
|
documentId,
|
|
@@ -3498,7 +2474,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3498
2474
|
isImporting,
|
|
3499
2475
|
documentId,
|
|
3500
2476
|
versionId,
|
|
3501
|
-
|
|
2477
|
+
statusLocales,
|
|
3502
2478
|
translationStatuses,
|
|
3503
2479
|
importedTranslations,
|
|
3504
2480
|
handleImportDocument,
|
|
@@ -3509,12 +2485,12 @@ const WrapText = dt(ui.Box)`
|
|
|
3509
2485
|
toast
|
|
3510
2486
|
]
|
|
3511
2487
|
);
|
|
3512
|
-
|
|
2488
|
+
React.useEffect(() => {
|
|
3513
2489
|
handleImportTranslations({ autoOnly: !0 });
|
|
3514
|
-
}, [handleImportTranslations]),
|
|
2490
|
+
}, [handleImportTranslations]), React.useEffect(() => {
|
|
3515
2491
|
setAutoRefresh(!0), setAutoPatchReferences(!0), setAutoPublish(!0);
|
|
3516
2492
|
}, [setAutoRefresh, setAutoPatchReferences, setAutoPublish]);
|
|
3517
|
-
const toggleLocale =
|
|
2493
|
+
const toggleLocale = React.useCallback(
|
|
3518
2494
|
(localeId, shouldEnable) => {
|
|
3519
2495
|
const updatedLocales = locales.map(
|
|
3520
2496
|
(locale) => locale.localeId === localeId ? { ...locale, enabled: shouldEnable } : locale
|
|
@@ -3522,7 +2498,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3522
2498
|
setLocales(updatedLocales);
|
|
3523
2499
|
},
|
|
3524
2500
|
[locales, setLocales]
|
|
3525
|
-
), toggleAllLocales =
|
|
2501
|
+
), toggleAllLocales = React.useCallback(() => {
|
|
3526
2502
|
const sourceLocale = pluginConfig.getSourceLocale(), allEnabled = locales.filter(
|
|
3527
2503
|
(locale) => locale.localeId !== sourceLocale
|
|
3528
2504
|
).every(
|
|
@@ -3534,7 +2510,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3534
2510
|
}, [locales, setLocales]);
|
|
3535
2511
|
return shouldShowTranslationComponents ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 6, padding: 4, children: [
|
|
3536
2512
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
3537
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "h2", weight: "semibold", size: 2, children: "
|
|
2513
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "h2", weight: "semibold", size: 2, children: "Translate" }),
|
|
3538
2514
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3539
2515
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", children: [
|
|
3540
2516
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", size: 1, children: availableLocales.length === 1 ? "Select locale" : "Select locales" }),
|
|
@@ -3543,6 +2519,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3543
2519
|
{
|
|
3544
2520
|
fontSize: 1,
|
|
3545
2521
|
padding: 2,
|
|
2522
|
+
mode: "ghost",
|
|
3546
2523
|
text: "Toggle All",
|
|
3547
2524
|
onClick: toggleAllLocales
|
|
3548
2525
|
}
|
|
@@ -3567,12 +2544,13 @@ const WrapText = dt(ui.Box)`
|
|
|
3567
2544
|
setAutoImport(!0), handleTranslateAll();
|
|
3568
2545
|
},
|
|
3569
2546
|
disabled: isBusy || !availableLocales.length,
|
|
3570
|
-
|
|
3571
|
-
text:
|
|
2547
|
+
icon: icons.TranslateIcon,
|
|
2548
|
+
text: "Translate",
|
|
2549
|
+
loading: isBusy
|
|
3572
2550
|
}
|
|
3573
2551
|
)
|
|
3574
2552
|
] }),
|
|
3575
|
-
documentId && versionId &&
|
|
2553
|
+
documentId && versionId && statusLocales.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
3576
2554
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", children: [
|
|
3577
2555
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "h2", weight: "semibold", size: 2, children: "Translation Status" }),
|
|
3578
2556
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", children: [
|
|
@@ -3591,14 +2569,17 @@ const WrapText = dt(ui.Box)`
|
|
|
3591
2569
|
{
|
|
3592
2570
|
fontSize: 1,
|
|
3593
2571
|
padding: 2,
|
|
3594
|
-
|
|
2572
|
+
mode: "ghost",
|
|
2573
|
+
icon: icons.RefreshIcon,
|
|
2574
|
+
text: "Refresh",
|
|
2575
|
+
loading: isRefreshing,
|
|
3595
2576
|
onClick: handleRefreshAll,
|
|
3596
2577
|
disabled: isRefreshing || isBusy
|
|
3597
2578
|
}
|
|
3598
2579
|
)
|
|
3599
2580
|
] })
|
|
3600
2581
|
] }),
|
|
3601
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.
|
|
2582
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, radius: 3, paddingY: 1, children: statusLocales.map((locale) => {
|
|
3602
2583
|
const key = createTranslationStatusKey(
|
|
3603
2584
|
branchId,
|
|
3604
2585
|
documentId,
|
|
@@ -3608,7 +2589,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3608
2589
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3609
2590
|
LanguageStatus,
|
|
3610
2591
|
{
|
|
3611
|
-
|
|
2592
|
+
localeId: locale.localeId,
|
|
3612
2593
|
progress,
|
|
3613
2594
|
isImported,
|
|
3614
2595
|
importFile: async () => {
|
|
@@ -3629,11 +2610,11 @@ const WrapText = dt(ui.Box)`
|
|
|
3629
2610
|
ui.Button,
|
|
3630
2611
|
{
|
|
3631
2612
|
mode: "ghost",
|
|
3632
|
-
tone: "primary",
|
|
3633
2613
|
onClick: () => handleImportTranslations(),
|
|
3634
|
-
text:
|
|
2614
|
+
text: "Import All",
|
|
2615
|
+
loading: isImporting,
|
|
3635
2616
|
icon: icons.DownloadIcon,
|
|
3636
|
-
disabled: isImporting ||
|
|
2617
|
+
disabled: isImporting || statusLocales.every((locale) => {
|
|
3637
2618
|
const key = createTranslationStatusKey(
|
|
3638
2619
|
branchId,
|
|
3639
2620
|
documentId,
|
|
@@ -3660,7 +2641,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3660
2641
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, children: [
|
|
3661
2642
|
"Imported",
|
|
3662
2643
|
" ",
|
|
3663
|
-
|
|
2644
|
+
statusLocales.filter((locale) => {
|
|
3664
2645
|
const key = createTranslationStatusKey(
|
|
3665
2646
|
branchId,
|
|
3666
2647
|
documentId,
|
|
@@ -3670,7 +2651,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3670
2651
|
return importedTranslations.has(key);
|
|
3671
2652
|
}).length,
|
|
3672
2653
|
"/",
|
|
3673
|
-
|
|
2654
|
+
statusLocales.filter((locale) => {
|
|
3674
2655
|
const key = createTranslationStatusKey(
|
|
3675
2656
|
branchId,
|
|
3676
2657
|
documentId,
|
|
@@ -3691,12 +2672,12 @@ const WrapText = dt(ui.Box)`
|
|
|
3691
2672
|
ui.Button,
|
|
3692
2673
|
{
|
|
3693
2674
|
mode: "ghost",
|
|
3694
|
-
tone: "caution",
|
|
3695
2675
|
onClick: async () => {
|
|
3696
2676
|
await handlePatchDocumentReferences();
|
|
3697
2677
|
},
|
|
3698
|
-
text:
|
|
3699
|
-
|
|
2678
|
+
text: "Patch References",
|
|
2679
|
+
loading: isBusy,
|
|
2680
|
+
icon: icons.LinkIcon,
|
|
3700
2681
|
disabled: isBusy || isImporting,
|
|
3701
2682
|
style: { minWidth: "180px" }
|
|
3702
2683
|
}
|
|
@@ -3725,7 +2706,6 @@ const WrapText = dt(ui.Box)`
|
|
|
3725
2706
|
ui.Button,
|
|
3726
2707
|
{
|
|
3727
2708
|
mode: "ghost",
|
|
3728
|
-
tone: "positive",
|
|
3729
2709
|
onClick: async () => {
|
|
3730
2710
|
setIsPublishing(!0);
|
|
3731
2711
|
try {
|
|
@@ -3734,8 +2714,9 @@ const WrapText = dt(ui.Box)`
|
|
|
3734
2714
|
setIsPublishing(!1);
|
|
3735
2715
|
}
|
|
3736
2716
|
},
|
|
3737
|
-
text:
|
|
3738
|
-
|
|
2717
|
+
text: "Publish Translations",
|
|
2718
|
+
loading: isPublishing,
|
|
2719
|
+
icon: icons.PublishIcon,
|
|
3739
2720
|
disabled: isBusy || isPublishing || isImporting,
|
|
3740
2721
|
style: { minWidth: "180px" }
|
|
3741
2722
|
}
|
|
@@ -3763,7 +2744,7 @@ const WrapText = dt(ui.Box)`
|
|
|
3763
2744
|
" documents."
|
|
3764
2745
|
] }) });
|
|
3765
2746
|
}, translateAction = (props) => {
|
|
3766
|
-
const [dialogOpen, setDialogOpen] =
|
|
2747
|
+
const [dialogOpen, setDialogOpen] = React.useState(!1), document2 = props.draft || props.published;
|
|
3767
2748
|
return {
|
|
3768
2749
|
label: "Translate",
|
|
3769
2750
|
icon: icons.TranslateIcon,
|
|
@@ -3777,259 +2758,89 @@ const WrapText = dt(ui.Box)`
|
|
|
3777
2758
|
} : null
|
|
3778
2759
|
};
|
|
3779
2760
|
};
|
|
3780
|
-
function readGTOptions(schemaType) {
|
|
3781
|
-
return schemaType?.options?.gtInternationalizedArray;
|
|
3782
|
-
}
|
|
3783
|
-
function toneFromValidation(validation) {
|
|
3784
|
-
if (validation?.length) {
|
|
3785
|
-
if (validation.some((marker) => marker.level === "error")) return "critical";
|
|
3786
|
-
if (validation.some((marker) => marker.level === "warning")) return "caution";
|
|
3787
|
-
}
|
|
3788
|
-
}
|
|
3789
|
-
function RemoveLocaleButton(props) {
|
|
3790
|
-
const { isSource, readOnly, onRemove } = props, button = (
|
|
3791
|
-
// The span keeps the tooltip working when the button is disabled
|
|
3792
|
-
// (disabled buttons don't emit pointer events).
|
|
3793
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { paddingBottom: "2px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3794
|
-
ui.Button,
|
|
3795
|
-
{
|
|
3796
|
-
mode: "bleed",
|
|
3797
|
-
icon: icons.RemoveCircleIcon,
|
|
3798
|
-
tone: "critical",
|
|
3799
|
-
disabled: readOnly || isSource,
|
|
3800
|
-
onClick: onRemove
|
|
3801
|
-
}
|
|
3802
|
-
) })
|
|
3803
|
-
);
|
|
3804
|
-
return isSource ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3805
|
-
ui.Tooltip,
|
|
3806
|
-
{
|
|
3807
|
-
animate: !0,
|
|
3808
|
-
portal: !0,
|
|
3809
|
-
placement: "top",
|
|
3810
|
-
fallbackPlacements: ["right", "left"],
|
|
3811
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: "Can't remove the source language" }),
|
|
3812
|
-
children: button
|
|
3813
|
-
}
|
|
3814
|
-
) : button;
|
|
3815
|
-
}
|
|
3816
|
-
function InternationalizedValueItem(props) {
|
|
3817
|
-
const { inputProps, parentSchemaType, schemaType, validation } = props, value = props.value, { onChange } = inputProps, gtOptions = readGTOptions(schemaType) ?? readGTOptions(parentSchemaType), language = value?.language, languageLabel = language ? gtOptions?.titles?.[language] ?? language : "Unknown language", isSource = !!language && language === gtOptions?.sourceLocale, wrappedOnChange = o.useCallback(
|
|
3818
|
-
(patch) => {
|
|
3819
|
-
if (!Array.isArray(patch)) {
|
|
3820
|
-
onChange(patch);
|
|
3821
|
-
return;
|
|
3822
|
-
}
|
|
3823
|
-
const currentValue = value?.value;
|
|
3824
|
-
if (!((currentValue == null || Array.isArray(currentValue) && currentValue.length === 0) && patch.some(
|
|
3825
|
-
(p) => p.type === "insert" && Array.isArray(p.path) && p.path.length > 0 && (p.path[0] === "value" || typeof p.path[0] == "number")
|
|
3826
|
-
))) {
|
|
3827
|
-
onChange(patch);
|
|
3828
|
-
return;
|
|
3829
|
-
}
|
|
3830
|
-
const rerooted = patch.map(
|
|
3831
|
-
(p) => p.type === "insert" && Array.isArray(p.path) && p.path[0] !== "value" ? { ...p, path: ["value", ...p.path] } : p
|
|
3832
|
-
);
|
|
3833
|
-
onChange(
|
|
3834
|
-
currentValue === void 0 ? [sanity.setIfMissing([], ["value"]), ...rerooted] : rerooted
|
|
3835
|
-
);
|
|
3836
|
-
},
|
|
3837
|
-
[onChange, value?.value]
|
|
3838
|
-
), members = o.useMemo(
|
|
3839
|
-
() => inputProps.members.filter(
|
|
3840
|
-
(member) => member.kind === "field" && member.name === "value"
|
|
3841
|
-
).map((member) => ({
|
|
3842
|
-
...member,
|
|
3843
|
-
field: {
|
|
3844
|
-
...member.field,
|
|
3845
|
-
schemaType: {
|
|
3846
|
-
...member.field.schemaType,
|
|
3847
|
-
title: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, size: 1, children: languageLabel })
|
|
3848
|
-
}
|
|
3849
|
-
}
|
|
3850
|
-
})),
|
|
3851
|
-
[inputProps.members, languageLabel]
|
|
3852
|
-
), handleRemove = o.useCallback(() => {
|
|
3853
|
-
onChange(sanity.unset());
|
|
3854
|
-
}, [onChange]);
|
|
3855
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { paddingTop: 2, tone: toneFromValidation(validation), children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "flex-end", gap: 2, children: [
|
|
3856
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: inputProps.renderInput({
|
|
3857
|
-
...inputProps,
|
|
3858
|
-
members,
|
|
3859
|
-
onChange: wrappedOnChange
|
|
3860
|
-
// renderInput's parameter is typed as the base InputProps, which
|
|
3861
|
-
// doesn't know about object members.
|
|
3862
|
-
}) }),
|
|
3863
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3864
|
-
RemoveLocaleButton,
|
|
3865
|
-
{
|
|
3866
|
-
isSource,
|
|
3867
|
-
readOnly: !!inputProps.readOnly,
|
|
3868
|
-
onRemove: handleRemove
|
|
3869
|
-
}
|
|
3870
|
-
)
|
|
3871
|
-
] }) });
|
|
3872
|
-
}
|
|
3873
|
-
function InternationalizedArrayInput(props) {
|
|
3874
|
-
const { members, schemaType, value, readOnly, onItemAppend } = props, gtOptions = readGTOptions(schemaType), itemType = schemaType.of[0]?.name, handleAdd = o.useCallback(
|
|
3875
|
-
(language) => {
|
|
3876
|
-
const item = { _key: randomKey(), _type: itemType, language };
|
|
3877
|
-
onItemAppend(item);
|
|
3878
|
-
},
|
|
3879
|
-
[onItemAppend, itemType]
|
|
3880
|
-
);
|
|
3881
|
-
if (!gtOptions)
|
|
3882
|
-
return props.renderDefault(props);
|
|
3883
|
-
const allLocales = [gtOptions.sourceLocale, ...gtOptions.locales], existing = new Set(
|
|
3884
|
-
(value ?? []).map((item) => item.language).filter(Boolean)
|
|
3885
|
-
), missing = allLocales.filter((locale) => !existing.has(locale));
|
|
3886
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3887
|
-
members.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: members.map(
|
|
3888
|
-
(member) => member.kind === "item" ? /* @__PURE__ */ jsxRuntime.jsx(sanity.ArrayOfObjectsItem, { ...props, member }, member.key) : /* @__PURE__ */ jsxRuntime.jsx(sanity.MemberItemError, { member }, member.key)
|
|
3889
|
-
) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, tone: "transparent", padding: 3, radius: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "This internationalized field currently has no translations." }) }),
|
|
3890
|
-
!readOnly && missing.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ui.Grid, { columns: Math.min(missing.length, 4), gap: 1, children: missing.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3891
|
-
ui.Button,
|
|
3892
|
-
{
|
|
3893
|
-
icon: icons.AddIcon,
|
|
3894
|
-
mode: "ghost",
|
|
3895
|
-
text: gtOptions.titles?.[locale] ?? locale,
|
|
3896
|
-
onClick: () => handleAdd(locale)
|
|
3897
|
-
},
|
|
3898
|
-
locale
|
|
3899
|
-
)) }) : null
|
|
3900
|
-
] });
|
|
3901
|
-
}
|
|
3902
|
-
const DEFAULT_TYPE_PREFIX = "internationalizedArray";
|
|
3903
|
-
function resolveComponents(overrides) {
|
|
3904
|
-
const input = overrides?.input === !1 ? void 0 : overrides?.input ?? InternationalizedArrayInput, item = overrides?.item === !1 ? void 0 : overrides?.item ?? InternationalizedValueItem, defaultField = input === InternationalizedArrayInput ? (
|
|
3905
|
-
// Reset the field level so inline per-locale inputs don't inherit
|
|
3906
|
-
// nested-object indentation.
|
|
3907
|
-
((fieldProps) => fieldProps.renderDefault({ ...fieldProps, level: 0 }))
|
|
3908
|
-
) : void 0, field = overrides?.field === !1 ? void 0 : overrides?.field ?? defaultField;
|
|
3909
|
-
return { input, item, field };
|
|
3910
|
-
}
|
|
3911
|
-
function capitalize(value) {
|
|
3912
|
-
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
3913
|
-
}
|
|
3914
|
-
function fieldTypeName(fieldType) {
|
|
3915
|
-
return typeof fieldType == "string" ? fieldType : fieldType.name;
|
|
3916
|
-
}
|
|
3917
|
-
function valueField(fieldType) {
|
|
3918
|
-
if (fieldType === "string" || fieldType === "text")
|
|
3919
|
-
return { name: "value", type: fieldType, title: "Value" };
|
|
3920
|
-
if (fieldType === "block")
|
|
3921
|
-
return {
|
|
3922
|
-
name: "value",
|
|
3923
|
-
type: "array",
|
|
3924
|
-
title: "Value",
|
|
3925
|
-
of: [{ type: "block" }]
|
|
3926
|
-
};
|
|
3927
|
-
const { name: _name, ...rest } = fieldType;
|
|
3928
|
-
return { name: "value", title: "Value", ...rest };
|
|
3929
|
-
}
|
|
3930
|
-
function makeLanguageTitle(options) {
|
|
3931
|
-
const { languageTitles, getLanguageTitle, sourceLocale } = options;
|
|
3932
|
-
return (locale) => getLanguageTitle?.(locale) ?? languageTitles?.[locale] ?? generaltranslation.getLocaleProperties(locale, sourceLocale).name ?? locale;
|
|
3933
|
-
}
|
|
3934
|
-
function buildTypesForPrefix(prefix2, options) {
|
|
3935
|
-
const { sourceLocale, locales, fieldTypes } = options, languageTitle = makeLanguageTitle(options), components = resolveComponents(options.components);
|
|
3936
|
-
return fieldTypes.map((fieldType) => {
|
|
3937
|
-
const typeName = `${prefix2}${capitalize(fieldTypeName(fieldType))}`, valueTypeName = `${typeName}Value`, gtInternationalizedArray = {
|
|
3938
|
-
sourceLocale,
|
|
3939
|
-
locales,
|
|
3940
|
-
titles: Object.fromEntries(
|
|
3941
|
-
[sourceLocale, ...locales].map((locale) => [
|
|
3942
|
-
locale,
|
|
3943
|
-
languageTitle(locale)
|
|
3944
|
-
])
|
|
3945
|
-
)
|
|
3946
|
-
}, valueObject = {
|
|
3947
|
-
type: "object",
|
|
3948
|
-
name: valueTypeName,
|
|
3949
|
-
...components.item ? { components: { item: components.item } } : {},
|
|
3950
|
-
fields: [
|
|
3951
|
-
{
|
|
3952
|
-
name: "language",
|
|
3953
|
-
type: "string",
|
|
3954
|
-
title: "Language",
|
|
3955
|
-
readOnly: !0,
|
|
3956
|
-
// GT's inline item shows the locale as the value field's label;
|
|
3957
|
-
// with a custom or detached item, keep the field visible so the
|
|
3958
|
-
// locale is still discoverable in default/dialog rendering.
|
|
3959
|
-
hidden: components.item === InternationalizedValueItem
|
|
3960
|
-
},
|
|
3961
|
-
valueField(fieldType)
|
|
3962
|
-
],
|
|
3963
|
-
options: { gtInternationalizedArray },
|
|
3964
|
-
preview: {
|
|
3965
|
-
select: { language: "language", value: "value" },
|
|
3966
|
-
prepare(selection) {
|
|
3967
|
-
const localeLabel = selection.language ? languageTitle(selection.language) : "Unknown";
|
|
3968
|
-
return {
|
|
3969
|
-
title: typeof selection.value == "string" ? selection.value : localeLabel,
|
|
3970
|
-
subtitle: localeLabel
|
|
3971
|
-
};
|
|
3972
|
-
}
|
|
3973
|
-
}
|
|
3974
|
-
}, arrayComponents = {
|
|
3975
|
-
...components.input ? { input: components.input } : {},
|
|
3976
|
-
...components.field ? { field: components.field } : {}
|
|
3977
|
-
};
|
|
3978
|
-
return {
|
|
3979
|
-
name: typeName,
|
|
3980
|
-
type: "array",
|
|
3981
|
-
...Object.keys(arrayComponents).length ? { components: arrayComponents } : {},
|
|
3982
|
-
of: [valueObject],
|
|
3983
|
-
options: { gtInternationalizedArray }
|
|
3984
|
-
};
|
|
3985
|
-
});
|
|
3986
|
-
}
|
|
3987
|
-
function createInternationalizedArrayTypes(options) {
|
|
3988
|
-
const prefix2 = options.typePrefix ?? DEFAULT_TYPE_PREFIX, includeCompatibilityTypes = options.includeCompatibilityTypes ?? !0, types = buildTypesForPrefix(prefix2, options);
|
|
3989
|
-
return includeCompatibilityTypes && prefix2 !== DEFAULT_TYPE_PREFIX && types.push(...buildTypesForPrefix(DEFAULT_TYPE_PREFIX, options)), types;
|
|
3990
|
-
}
|
|
3991
2761
|
function resolveFieldLevelConfig(config) {
|
|
3992
2762
|
return {
|
|
3993
2763
|
enabled: !1,
|
|
3994
2764
|
fieldTypes: ["string", "text"],
|
|
3995
|
-
typePrefix: DEFAULT_TYPE_PREFIX,
|
|
3996
|
-
includeCompatibilityTypes: !0,
|
|
3997
2765
|
...config
|
|
3998
2766
|
};
|
|
3999
2767
|
}
|
|
4000
|
-
|
|
2768
|
+
function toNativeFieldType(fieldType) {
|
|
2769
|
+
return fieldType === "block" ? {
|
|
2770
|
+
name: "block",
|
|
2771
|
+
type: "array",
|
|
2772
|
+
of: [{ type: "block" }]
|
|
2773
|
+
} : fieldType;
|
|
2774
|
+
}
|
|
2775
|
+
function buildInternationalizedArrayPlugin(config, sourceLocale, locales, customMapping) {
|
|
2776
|
+
const languageTitle = (locale) => config.getLanguageTitle?.(locale) ?? config.languageTitles?.[locale] ?? formatLocalePropertiesLabel(
|
|
2777
|
+
locale,
|
|
2778
|
+
generaltranslation.getLocaleProperties(locale, sourceLocale, customMapping),
|
|
2779
|
+
customMapping?.[locale]
|
|
2780
|
+
), allLocales = Array.from(/* @__PURE__ */ new Set([sourceLocale, ...locales]));
|
|
2781
|
+
return sanityPluginInternationalizedArray.internationalizedArray({
|
|
2782
|
+
languages: allLocales.map((id) => ({ id, title: languageTitle(id) })),
|
|
2783
|
+
defaultLanguages: config.defaultLanguages ?? [sourceLocale],
|
|
2784
|
+
fieldTypes: config.fieldTypes.map(toNativeFieldType),
|
|
2785
|
+
...config.apiVersion !== void 0 && { apiVersion: config.apiVersion },
|
|
2786
|
+
...config.buttonLocations !== void 0 && {
|
|
2787
|
+
buttonLocations: config.buttonLocations
|
|
2788
|
+
},
|
|
2789
|
+
...config.buttonAddAll !== void 0 && {
|
|
2790
|
+
buttonAddAll: config.buttonAddAll
|
|
2791
|
+
},
|
|
2792
|
+
...config.languageDisplay !== void 0 && {
|
|
2793
|
+
languageDisplay: config.languageDisplay
|
|
2794
|
+
}
|
|
2795
|
+
});
|
|
2796
|
+
}
|
|
2797
|
+
const DocumentRow = ({ document: document2 }) => {
|
|
4001
2798
|
const {
|
|
4002
|
-
documents,
|
|
4003
2799
|
locales,
|
|
4004
|
-
loadingDocuments,
|
|
4005
2800
|
translationStatuses,
|
|
4006
2801
|
downloadStatus,
|
|
4007
2802
|
importedTranslations,
|
|
4008
2803
|
handleImportDocument,
|
|
4009
2804
|
branchId,
|
|
4010
2805
|
getVersionId
|
|
4011
|
-
} = useTranslations()
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
2806
|
+
} = useTranslations(), schemaType = sanity.useSchema().get(document2._type), publishedId = getDocumentPublishedId(document2), editLink = router.useIntentLink({
|
|
2807
|
+
intent: "edit",
|
|
2808
|
+
params: { id: publishedId, type: document2._type }
|
|
2809
|
+
}), enabledLocales = locales.filter((locale) => locale.enabled !== !1);
|
|
2810
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Card, { border: !0, radius: 3, overflow: "hidden", children: [
|
|
2811
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2812
|
+
ui.Card,
|
|
2813
|
+
{
|
|
2814
|
+
as: "a",
|
|
2815
|
+
href: editLink.href,
|
|
2816
|
+
onClick: editLink.onClick,
|
|
2817
|
+
padding: 2,
|
|
2818
|
+
radius: 0,
|
|
2819
|
+
borderBottom: !0,
|
|
2820
|
+
style: { textDecoration: "none", color: "inherit" },
|
|
2821
|
+
title: "Open document",
|
|
2822
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 3, children: [
|
|
2823
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: schemaType ? /* @__PURE__ */ jsxRuntime.jsx(sanity.Preview, { value: document2, schemaType }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", size: 1, children: publishedId }) }),
|
|
2824
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { fontSize: 0, radius: 2, children: schemaType?.title ?? document2._type })
|
|
2825
|
+
] })
|
|
2826
|
+
}
|
|
2827
|
+
),
|
|
2828
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingY: 1, children: enabledLocales.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 1, children: enabledLocales.map((locale) => {
|
|
2829
|
+
const versionId = getVersionId(document2), key = createTranslationStatusKey(
|
|
4019
2830
|
branchId,
|
|
4020
|
-
|
|
2831
|
+
publishedId,
|
|
4021
2832
|
versionId,
|
|
4022
2833
|
locale.localeId
|
|
4023
2834
|
), status = translationStatuses.get(key), isDownloaded = downloadStatus.downloaded.has(key), isImported = importedTranslations.has(key);
|
|
4024
2835
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4025
2836
|
LanguageStatus,
|
|
4026
2837
|
{
|
|
4027
|
-
|
|
2838
|
+
localeId: locale.localeId,
|
|
4028
2839
|
progress: status?.progress || 0,
|
|
4029
2840
|
isImported: isImported || isDownloaded,
|
|
4030
2841
|
importFile: async () => {
|
|
4031
2842
|
await handleImportDocument(
|
|
4032
|
-
|
|
2843
|
+
publishedId,
|
|
4033
2844
|
versionId,
|
|
4034
2845
|
locale.localeId
|
|
4035
2846
|
);
|
|
@@ -4037,8 +2848,11 @@ const TranslationsTable = () => {
|
|
|
4037
2848
|
},
|
|
4038
2849
|
`${document2._id}-${versionId}-${locale.localeId}`
|
|
4039
2850
|
);
|
|
4040
|
-
}) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "No locales configured" }) })
|
|
4041
|
-
] })
|
|
2851
|
+
}) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "No locales configured" }) }) })
|
|
2852
|
+
] });
|
|
2853
|
+
}, TranslationsTable = () => {
|
|
2854
|
+
const { documents, loadingDocuments } = useTranslations();
|
|
2855
|
+
return loadingDocuments ? /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", justify: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { maxHeight: "60vh", overflowY: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: documents.map((document2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentRow, { document: document2 }, document2._id)) }) });
|
|
4042
2856
|
}, TranslateAllDialog = ({
|
|
4043
2857
|
isOpen,
|
|
4044
2858
|
onClose
|
|
@@ -4054,14 +2868,7 @@ const TranslationsTable = () => {
|
|
|
4054
2868
|
onClose,
|
|
4055
2869
|
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
4056
2870
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
4057
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4058
|
-
ui.Button,
|
|
4059
|
-
{
|
|
4060
|
-
text: "Translate All",
|
|
4061
|
-
tone: "critical",
|
|
4062
|
-
onClick: handleConfirm
|
|
4063
|
-
}
|
|
4064
|
-
)
|
|
2871
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Translate All", onClick: handleConfirm })
|
|
4065
2872
|
] }) }),
|
|
4066
2873
|
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
4067
2874
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { children: [
|
|
@@ -4089,7 +2896,7 @@ const TranslationsTable = () => {
|
|
|
4089
2896
|
onClose,
|
|
4090
2897
|
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
4091
2898
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
4092
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Import All", tone: "
|
|
2899
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Import All", tone: "caution", onClick: handleConfirm })
|
|
4093
2900
|
] }) }),
|
|
4094
2901
|
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
4095
2902
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { children: [
|
|
@@ -4117,14 +2924,7 @@ const TranslationsTable = () => {
|
|
|
4117
2924
|
onClose,
|
|
4118
2925
|
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
4119
2926
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Cancel", mode: "ghost", onClick: onClose }),
|
|
4120
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4121
|
-
ui.Button,
|
|
4122
|
-
{
|
|
4123
|
-
text: "Import Missing",
|
|
4124
|
-
tone: "primary",
|
|
4125
|
-
onClick: handleConfirm
|
|
4126
|
-
}
|
|
4127
|
-
)
|
|
2927
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Import Missing", onClick: handleConfirm })
|
|
4128
2928
|
] }) }),
|
|
4129
2929
|
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
4130
2930
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Import only the missing translations (translations that are ready but haven't been imported to Sanity yet)?" }),
|
|
@@ -4148,7 +2948,7 @@ const TranslationsTable = () => {
|
|
|
4148
2948
|
"..."
|
|
4149
2949
|
] })
|
|
4150
2950
|
] }) : null, TranslationsToolContent = () => {
|
|
4151
|
-
const [isTranslateAllDialogOpen, setIsTranslateAllDialogOpen] =
|
|
2951
|
+
const [isTranslateAllDialogOpen, setIsTranslateAllDialogOpen] = React.useState(!1), [isImportAllDialogOpen, setIsImportAllDialogOpen] = React.useState(!1), [isImportMissingDialogOpen, setIsImportMissingDialogOpen] = React.useState(!1), {
|
|
4152
2952
|
isBusy,
|
|
4153
2953
|
documents,
|
|
4154
2954
|
locales,
|
|
@@ -4161,29 +2961,13 @@ const TranslationsTable = () => {
|
|
|
4161
2961
|
handleRefreshAll,
|
|
4162
2962
|
handlePatchDocumentReferences,
|
|
4163
2963
|
handlePublishAllTranslations
|
|
4164
|
-
} = useTranslations(), [currentOperation, setCurrentOperation] =
|
|
4165
|
-
if (!isProcessing || !operationName) return operationName;
|
|
4166
|
-
switch (operationName) {
|
|
4167
|
-
case "Translate All":
|
|
4168
|
-
return "Translating...";
|
|
4169
|
-
case "Import All":
|
|
4170
|
-
return "Importing...";
|
|
4171
|
-
case "Import Missing":
|
|
4172
|
-
return "Importing...";
|
|
4173
|
-
case "Patch Document References":
|
|
4174
|
-
return "Patching...";
|
|
4175
|
-
case "Publish Translations":
|
|
4176
|
-
return "Publishing...";
|
|
4177
|
-
default:
|
|
4178
|
-
return "Processing...";
|
|
4179
|
-
}
|
|
4180
|
-
}, getProgressOperationName = () => {
|
|
2964
|
+
} = useTranslations(), [currentOperation, setCurrentOperation] = React.useState(null), getProgressOperationName = () => {
|
|
4181
2965
|
switch (currentOperation) {
|
|
4182
2966
|
case "Import All":
|
|
4183
2967
|
return "Importing";
|
|
4184
2968
|
case "Import Missing":
|
|
4185
2969
|
return "Importing missing";
|
|
4186
|
-
case "Patch
|
|
2970
|
+
case "Patch References":
|
|
4187
2971
|
return "Patching";
|
|
4188
2972
|
case "Publish Translations":
|
|
4189
2973
|
return "Publishing";
|
|
@@ -4191,181 +2975,176 @@ const TranslationsTable = () => {
|
|
|
4191
2975
|
return "Processing";
|
|
4192
2976
|
}
|
|
4193
2977
|
};
|
|
4194
|
-
|
|
2978
|
+
React__default.default.useEffect(() => {
|
|
4195
2979
|
!isBusy && !importProgress.isImporting && setCurrentOperation(null);
|
|
4196
|
-
}, [isBusy, importProgress.isImporting])
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
2980
|
+
}, [isBusy, importProgress.isImporting]);
|
|
2981
|
+
const enabledLocaleCount = locales.filter((l) => l.enabled !== !1).length, totalTranslations = documents.length * enabledLocaleCount, actionsDisabled = isBusy || loadingDocuments || documents.length === 0;
|
|
2982
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { width: 2, children: [
|
|
2983
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 5, children: [
|
|
2984
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "flex-start", justify: "space-between", gap: 4, children: [
|
|
2985
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
4200
2986
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { as: "h2", size: 3, children: "Translations" }),
|
|
4201
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size:
|
|
2987
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "Manage your document translations from this centralized location." })
|
|
4202
2988
|
] }),
|
|
4203
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4204
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
4205
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Auto-refresh" }),
|
|
4206
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4207
|
-
ui.Switch,
|
|
4208
|
-
{
|
|
4209
|
-
checked: autoRefresh,
|
|
4210
|
-
onChange: () => setAutoRefresh(!autoRefresh)
|
|
4211
|
-
}
|
|
4212
|
-
)
|
|
4213
|
-
] }),
|
|
4214
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4215
|
-
ui.Button,
|
|
4216
|
-
{
|
|
4217
|
-
fontSize: 1,
|
|
4218
|
-
padding: 2,
|
|
4219
|
-
text: isRefreshing ? "Refreshing..." : "Refresh Status",
|
|
4220
|
-
onClick: handleRefreshAll,
|
|
4221
|
-
disabled: isRefreshing || isBusy || loadingDocuments || documents.length === 0
|
|
4222
|
-
}
|
|
4223
|
-
)
|
|
4224
|
-
] })
|
|
4225
|
-
] }),
|
|
4226
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
4227
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: loadingDocuments ? "Loading documents..." : `Found ${documents.length} documents available for translation` }) }),
|
|
4228
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2989
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4229
2990
|
ui.Button,
|
|
4230
2991
|
{
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
"Translate All",
|
|
4235
|
-
isBusy && currentOperation === "Translate All"
|
|
4236
|
-
),
|
|
2992
|
+
icon: icons.TranslateIcon,
|
|
2993
|
+
text: "Translate All",
|
|
2994
|
+
loading: isBusy && currentOperation === "Translate All",
|
|
4237
2995
|
onClick: () => {
|
|
4238
2996
|
setCurrentOperation("Translate All"), setIsTranslateAllDialogOpen(!0);
|
|
4239
2997
|
},
|
|
4240
|
-
disabled:
|
|
2998
|
+
disabled: actionsDisabled
|
|
4241
2999
|
}
|
|
4242
|
-
)
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
3000
|
+
)
|
|
3001
|
+
] }),
|
|
3002
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3003
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", gap: 3, children: [
|
|
3004
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: loadingDocuments ? "Loading documents..." : `${documents.length} ${documents.length === 1 ? "document" : "documents"} available for translation` }),
|
|
3005
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", children: [
|
|
4246
3006
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
|
|
3007
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "Auto-refresh" }),
|
|
4247
3008
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4248
|
-
ui.
|
|
4249
|
-
{
|
|
4250
|
-
placement: "top",
|
|
4251
|
-
content: "Imports and overrides all translations",
|
|
4252
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4253
|
-
ui.Button,
|
|
4254
|
-
{
|
|
4255
|
-
mode: "ghost",
|
|
4256
|
-
onClick: () => {
|
|
4257
|
-
setCurrentOperation("Import All"), setIsImportAllDialogOpen(!0);
|
|
4258
|
-
},
|
|
4259
|
-
text: getOperationText(
|
|
4260
|
-
"Import All",
|
|
4261
|
-
isBusy && currentOperation === "Import All"
|
|
4262
|
-
),
|
|
4263
|
-
icon: isBusy && currentOperation === "Import All" ? null : icons.DownloadIcon,
|
|
4264
|
-
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
4265
|
-
}
|
|
4266
|
-
)
|
|
4267
|
-
}
|
|
4268
|
-
),
|
|
4269
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4270
|
-
ui.Tooltip,
|
|
4271
|
-
{
|
|
4272
|
-
placement: "top",
|
|
4273
|
-
content: "Imports all translations that are not yet imported (according to the source document's translation.metadata document)",
|
|
4274
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4275
|
-
ui.Button,
|
|
4276
|
-
{
|
|
4277
|
-
mode: "ghost",
|
|
4278
|
-
tone: "primary",
|
|
4279
|
-
onClick: () => {
|
|
4280
|
-
setCurrentOperation("Import Missing"), setIsImportMissingDialogOpen(!0);
|
|
4281
|
-
},
|
|
4282
|
-
text: getOperationText(
|
|
4283
|
-
"Import Missing",
|
|
4284
|
-
isBusy && currentOperation === "Import Missing"
|
|
4285
|
-
),
|
|
4286
|
-
icon: isBusy && currentOperation === "Import Missing" ? null : icons.DownloadIcon,
|
|
4287
|
-
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
4288
|
-
}
|
|
4289
|
-
)
|
|
4290
|
-
}
|
|
4291
|
-
),
|
|
4292
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4293
|
-
ui.Tooltip,
|
|
4294
|
-
{
|
|
4295
|
-
placement: "top",
|
|
4296
|
-
content: "Replaces references in documents with the corresponding translated document reference",
|
|
4297
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4298
|
-
ui.Button,
|
|
4299
|
-
{
|
|
4300
|
-
mode: "ghost",
|
|
4301
|
-
tone: "caution",
|
|
4302
|
-
onClick: () => {
|
|
4303
|
-
setCurrentOperation("Patch Document References"), handlePatchDocumentReferences();
|
|
4304
|
-
},
|
|
4305
|
-
text: getOperationText(
|
|
4306
|
-
"Patch Document References",
|
|
4307
|
-
isBusy && currentOperation === "Patch Document References"
|
|
4308
|
-
),
|
|
4309
|
-
icon: isBusy && currentOperation === "Patch Document References" ? null : icons.LinkIcon,
|
|
4310
|
-
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
4311
|
-
}
|
|
4312
|
-
)
|
|
4313
|
-
}
|
|
4314
|
-
),
|
|
4315
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4316
|
-
ui.Tooltip,
|
|
3009
|
+
ui.Switch,
|
|
4317
3010
|
{
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4321
|
-
ui.Button,
|
|
4322
|
-
{
|
|
4323
|
-
mode: "ghost",
|
|
4324
|
-
tone: "positive",
|
|
4325
|
-
onClick: () => {
|
|
4326
|
-
setCurrentOperation("Publish Translations"), handlePublishAllTranslations();
|
|
4327
|
-
},
|
|
4328
|
-
text: getOperationText(
|
|
4329
|
-
"Publish Translations",
|
|
4330
|
-
isBusy && currentOperation === "Publish Translations"
|
|
4331
|
-
),
|
|
4332
|
-
icon: isBusy && currentOperation === "Publish Translations" ? null : icons.PublishIcon,
|
|
4333
|
-
disabled: isBusy || loadingDocuments || documents.length === 0
|
|
4334
|
-
}
|
|
4335
|
-
)
|
|
3011
|
+
checked: autoRefresh,
|
|
3012
|
+
onChange: () => setAutoRefresh(!autoRefresh)
|
|
4336
3013
|
}
|
|
4337
|
-
)
|
|
4338
|
-
importedTranslations.size === documents.length * locales.filter((l) => l.enabled !== !1).length && documents.length > 0 && locales.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", style: { color: "green" }, children: [
|
|
4339
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckmarkCircleIcon, {}),
|
|
4340
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "All translations imported" })
|
|
4341
|
-
] }),
|
|
4342
|
-
importedTranslations.size > 0 && importedTranslations.size < documents.length * locales.filter((l) => l.enabled !== !1).length && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, style: { color: "#666" }, children: [
|
|
4343
|
-
importedTranslations.size,
|
|
4344
|
-
"/",
|
|
4345
|
-
documents.length * locales.filter((l) => l.enabled !== !1).length,
|
|
4346
|
-
" ",
|
|
4347
|
-
"imported"
|
|
4348
|
-
] })
|
|
3014
|
+
)
|
|
4349
3015
|
] }),
|
|
4350
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3016
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3017
|
+
ui.Button,
|
|
3018
|
+
{
|
|
3019
|
+
fontSize: 1,
|
|
3020
|
+
padding: 2,
|
|
3021
|
+
mode: "ghost",
|
|
3022
|
+
icon: icons.RefreshIcon,
|
|
3023
|
+
text: "Refresh",
|
|
3024
|
+
loading: isRefreshing,
|
|
3025
|
+
onClick: handleRefreshAll,
|
|
3026
|
+
disabled: isRefreshing || actionsDisabled
|
|
3027
|
+
}
|
|
3028
|
+
)
|
|
3029
|
+
] })
|
|
3030
|
+
] }),
|
|
3031
|
+
/* @__PURE__ */ jsxRuntime.jsx(TranslationsTable, {})
|
|
3032
|
+
] }),
|
|
3033
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
3034
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", justify: "space-between", children: [
|
|
3035
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", wrap: "wrap", children: [
|
|
3036
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3037
|
+
ui.Tooltip,
|
|
3038
|
+
{
|
|
3039
|
+
placement: "top",
|
|
3040
|
+
content: "Imports and overrides all translations",
|
|
3041
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3042
|
+
ui.Button,
|
|
3043
|
+
{
|
|
3044
|
+
mode: "ghost",
|
|
3045
|
+
fontSize: 1,
|
|
3046
|
+
onClick: () => {
|
|
3047
|
+
setCurrentOperation("Import All"), setIsImportAllDialogOpen(!0);
|
|
3048
|
+
},
|
|
3049
|
+
text: "Import All",
|
|
3050
|
+
loading: isBusy && currentOperation === "Import All",
|
|
3051
|
+
icon: icons.DownloadIcon,
|
|
3052
|
+
disabled: actionsDisabled
|
|
3053
|
+
}
|
|
3054
|
+
)
|
|
3055
|
+
}
|
|
3056
|
+
),
|
|
3057
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3058
|
+
ui.Tooltip,
|
|
3059
|
+
{
|
|
3060
|
+
placement: "top",
|
|
3061
|
+
content: "Imports all translations that are not yet imported (according to the source document's translation.metadata document)",
|
|
3062
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3063
|
+
ui.Button,
|
|
3064
|
+
{
|
|
3065
|
+
mode: "ghost",
|
|
3066
|
+
fontSize: 1,
|
|
3067
|
+
onClick: () => {
|
|
3068
|
+
setCurrentOperation("Import Missing"), setIsImportMissingDialogOpen(!0);
|
|
3069
|
+
},
|
|
3070
|
+
text: "Import Missing",
|
|
3071
|
+
loading: isBusy && currentOperation === "Import Missing",
|
|
3072
|
+
icon: icons.DownloadIcon,
|
|
3073
|
+
disabled: actionsDisabled
|
|
3074
|
+
}
|
|
3075
|
+
)
|
|
3076
|
+
}
|
|
3077
|
+
),
|
|
3078
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3079
|
+
ui.Tooltip,
|
|
3080
|
+
{
|
|
3081
|
+
placement: "top",
|
|
3082
|
+
content: "Replaces references in documents with the corresponding translated document reference",
|
|
3083
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3084
|
+
ui.Button,
|
|
3085
|
+
{
|
|
3086
|
+
mode: "ghost",
|
|
3087
|
+
fontSize: 1,
|
|
3088
|
+
onClick: () => {
|
|
3089
|
+
setCurrentOperation("Patch References"), handlePatchDocumentReferences();
|
|
3090
|
+
},
|
|
3091
|
+
text: "Patch References",
|
|
3092
|
+
loading: isBusy && currentOperation === "Patch References",
|
|
3093
|
+
icon: icons.LinkIcon,
|
|
3094
|
+
disabled: actionsDisabled
|
|
3095
|
+
}
|
|
3096
|
+
)
|
|
3097
|
+
}
|
|
3098
|
+
),
|
|
3099
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3100
|
+
ui.Tooltip,
|
|
3101
|
+
{
|
|
3102
|
+
placement: "top",
|
|
3103
|
+
content: "Publishes all translations whose source document is published",
|
|
3104
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3105
|
+
ui.Button,
|
|
3106
|
+
{
|
|
3107
|
+
mode: "ghost",
|
|
3108
|
+
fontSize: 1,
|
|
3109
|
+
onClick: () => {
|
|
3110
|
+
setCurrentOperation("Publish Translations"), handlePublishAllTranslations();
|
|
3111
|
+
},
|
|
3112
|
+
text: "Publish Translations",
|
|
3113
|
+
loading: isBusy && currentOperation === "Publish Translations",
|
|
3114
|
+
icon: icons.PublishIcon,
|
|
3115
|
+
disabled: actionsDisabled
|
|
3116
|
+
}
|
|
3117
|
+
)
|
|
3118
|
+
}
|
|
3119
|
+
)
|
|
4351
3120
|
] }),
|
|
4352
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4353
|
-
|
|
4354
|
-
{
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
3121
|
+
totalTranslations > 0 && importedTranslations.size === totalTranslations && /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { tone: "positive", fontSize: 0, radius: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 1, children: [
|
|
3122
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.CheckmarkCircleIcon, {}),
|
|
3123
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: "All translations imported" })
|
|
3124
|
+
] }) }),
|
|
3125
|
+
importedTranslations.size > 0 && importedTranslations.size < totalTranslations && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, children: [
|
|
3126
|
+
importedTranslations.size,
|
|
3127
|
+
"/",
|
|
3128
|
+
totalTranslations,
|
|
3129
|
+
" imported"
|
|
3130
|
+
] })
|
|
3131
|
+
] }),
|
|
3132
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3133
|
+
BatchProgress,
|
|
3134
|
+
{
|
|
3135
|
+
isActive: importProgress.isImporting,
|
|
3136
|
+
current: importProgress.current,
|
|
3137
|
+
total: importProgress.total,
|
|
3138
|
+
operationName: getProgressOperationName()
|
|
3139
|
+
}
|
|
3140
|
+
)
|
|
4362
3141
|
] }),
|
|
4363
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size:
|
|
3142
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { borderTop: !0, paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, children: [
|
|
4364
3143
|
"For more information, see the",
|
|
4365
3144
|
" ",
|
|
4366
3145
|
/* @__PURE__ */ jsxRuntime.jsx(router.Link, { href: "https://dash.generaltranslation.com", children: "General Translation Dashboard" }),
|
|
4367
3146
|
"."
|
|
4368
|
-
] })
|
|
3147
|
+
] }) })
|
|
4369
3148
|
] }) }),
|
|
4370
3149
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4371
3150
|
TranslateAllDialog,
|
|
@@ -4413,14 +3192,14 @@ const TranslationsTable = () => {
|
|
|
4413
3192
|
additionalDeserializers = {},
|
|
4414
3193
|
additionalBlockDeserializers = [],
|
|
4415
3194
|
showDocumentInternationalization = !0,
|
|
4416
|
-
internationalizedArray,
|
|
3195
|
+
internationalizedArray: internationalizedArray2,
|
|
4417
3196
|
fieldLevelLocalization,
|
|
4418
3197
|
translationLevel = "document",
|
|
4419
3198
|
fieldLevelDocuments
|
|
4420
3199
|
}) => {
|
|
4421
|
-
const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? internal.libraryDefaultLocale, normalizeFilters = (entries) => entries?.map((entry) => typeof entry == "string" ? { type: entry } : entry).filter((
|
|
4422
|
-
|
|
4423
|
-
);
|
|
3200
|
+
const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? internal.libraryDefaultLocale, normalizeFilters = (entries) => entries?.map((entry) => typeof entry == "string" ? { type: entry } : entry).filter((filter) => filter.documentId || filter.type), normalizedTranslateDocuments = normalizeFilters(translateDocuments), normalizedFieldLevelDocuments = normalizeFilters(fieldLevelDocuments) ?? [], rawFieldLevelConfig = internationalizedArray2 ?? fieldLevelLocalization;
|
|
3201
|
+
warnOnRemovedFieldLevelOptions(rawFieldLevelConfig);
|
|
3202
|
+
const fieldLevelConfig = resolveFieldLevelConfig(rawFieldLevelConfig);
|
|
4424
3203
|
pluginConfig.init(
|
|
4425
3204
|
secretsNamespace,
|
|
4426
3205
|
languageField,
|
|
@@ -4438,8 +3217,7 @@ const TranslationsTable = () => {
|
|
|
4438
3217
|
additionalDeserializers,
|
|
4439
3218
|
additionalBlockDeserializers,
|
|
4440
3219
|
translationLevel,
|
|
4441
|
-
normalizedFieldLevelDocuments
|
|
4442
|
-
fieldLevelConfig.typePrefix
|
|
3220
|
+
normalizedFieldLevelDocuments
|
|
4443
3221
|
), gt.setConfig({
|
|
4444
3222
|
sourceLocale: resolvedSourceLocale,
|
|
4445
3223
|
customMapping,
|
|
@@ -4447,40 +3225,45 @@ const TranslationsTable = () => {
|
|
|
4447
3225
|
projectId
|
|
4448
3226
|
});
|
|
4449
3227
|
const arrayLocalizedTypes = /* @__PURE__ */ new Set();
|
|
4450
|
-
translationLevel === "internationalizedArray" ? normalizedTranslateDocuments?.map((
|
|
3228
|
+
translationLevel === "internationalizedArray" ? normalizedTranslateDocuments?.map((filter) => filter.type).filter((type) => !!type).forEach((type) => arrayLocalizedTypes.add(type)) : translationLevel === "mixed" && normalizedFieldLevelDocuments.map((filter) => filter.type).filter((type) => !!type).forEach((type) => arrayLocalizedTypes.add(type));
|
|
4451
3229
|
const plugins = [];
|
|
4452
3230
|
if (showDocumentInternationalization) {
|
|
4453
|
-
const
|
|
4454
|
-
if (
|
|
3231
|
+
const schemaTypes = normalizedTranslateDocuments?.map((filter) => filter.type).filter((type) => !!type).filter((type) => !arrayLocalizedTypes.has(type)) ?? [];
|
|
3232
|
+
if (schemaTypes.length > 0) {
|
|
4455
3233
|
const supportedLanguages = [resolvedSourceLocale, ...locales].map((locale) => {
|
|
4456
|
-
const props = generaltranslation.getLocaleProperties(
|
|
4457
|
-
|
|
3234
|
+
const props = generaltranslation.getLocaleProperties(
|
|
3235
|
+
locale,
|
|
3236
|
+
resolvedSourceLocale,
|
|
3237
|
+
customMapping
|
|
3238
|
+
);
|
|
3239
|
+
return {
|
|
3240
|
+
id: locale,
|
|
3241
|
+
title: formatLocalePropertiesLabel(
|
|
3242
|
+
locale,
|
|
3243
|
+
props,
|
|
3244
|
+
customMapping?.[locale]
|
|
3245
|
+
)
|
|
3246
|
+
};
|
|
4458
3247
|
});
|
|
4459
3248
|
plugins.push(
|
|
4460
3249
|
documentInternationalization.documentInternationalization({
|
|
4461
3250
|
supportedLanguages,
|
|
4462
|
-
schemaTypes
|
|
3251
|
+
schemaTypes,
|
|
4463
3252
|
languageField
|
|
4464
3253
|
})
|
|
4465
3254
|
);
|
|
4466
3255
|
}
|
|
4467
3256
|
}
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
components: fieldLevelConfig.components
|
|
4477
|
-
}) : [];
|
|
4478
|
-
return {
|
|
3257
|
+
return fieldLevelConfig.enabled && plugins.push(
|
|
3258
|
+
buildInternationalizedArrayPlugin(
|
|
3259
|
+
fieldLevelConfig,
|
|
3260
|
+
resolvedSourceLocale,
|
|
3261
|
+
locales,
|
|
3262
|
+
customMapping
|
|
3263
|
+
)
|
|
3264
|
+
), {
|
|
4479
3265
|
name: "gt-sanity",
|
|
4480
3266
|
plugins,
|
|
4481
|
-
schema: {
|
|
4482
|
-
types: schemaTypes
|
|
4483
|
-
},
|
|
4484
3267
|
tools: [
|
|
4485
3268
|
{
|
|
4486
3269
|
name: "translations",
|
|
@@ -4490,11 +3273,49 @@ const TranslationsTable = () => {
|
|
|
4490
3273
|
}
|
|
4491
3274
|
],
|
|
4492
3275
|
document: {
|
|
4493
|
-
actions: (
|
|
3276
|
+
actions: (prev) => [...prev, translateAction]
|
|
4494
3277
|
}
|
|
4495
3278
|
};
|
|
4496
3279
|
}
|
|
4497
|
-
)
|
|
3280
|
+
), REMOVED_FIELD_LEVEL_OPTIONS = [
|
|
3281
|
+
"typePrefix",
|
|
3282
|
+
"includeCompatibilityTypes",
|
|
3283
|
+
"components"
|
|
3284
|
+
];
|
|
3285
|
+
function warnOnRemovedFieldLevelOptions(config) {
|
|
3286
|
+
if (!config) return;
|
|
3287
|
+
const removed = REMOVED_FIELD_LEVEL_OPTIONS.filter(
|
|
3288
|
+
(key) => config[key] !== void 0
|
|
3289
|
+
);
|
|
3290
|
+
removed.length !== 0 && console.warn(
|
|
3291
|
+
internal.createDiagnosticMessage({
|
|
3292
|
+
source: "gt-sanity",
|
|
3293
|
+
severity: "Warning",
|
|
3294
|
+
whatHappened: `Ignored unsupported field-level localization ${removed.length === 1 ? "option" : "options"}`,
|
|
3295
|
+
why: "field-level localization is now provided by sanity-plugin-internationalized-array, which has no equivalent for these options",
|
|
3296
|
+
fix: "Remove them from the gtPlugin configuration",
|
|
3297
|
+
details: removed
|
|
3298
|
+
})
|
|
3299
|
+
);
|
|
3300
|
+
}
|
|
3301
|
+
Object.defineProperty(exports, "internationalizedArray", {
|
|
3302
|
+
enumerable: !0,
|
|
3303
|
+
get: function() {
|
|
3304
|
+
return sanityPluginInternationalizedArray.internationalizedArray;
|
|
3305
|
+
}
|
|
3306
|
+
});
|
|
3307
|
+
Object.defineProperty(exports, "internationalizedArrayLanguageFilter", {
|
|
3308
|
+
enumerable: !0,
|
|
3309
|
+
get: function() {
|
|
3310
|
+
return sanityPluginInternationalizedArray.internationalizedArrayLanguageFilter;
|
|
3311
|
+
}
|
|
3312
|
+
});
|
|
3313
|
+
Object.defineProperty(exports, "isInternationalizedArrayItemType", {
|
|
3314
|
+
enumerable: !0,
|
|
3315
|
+
get: function() {
|
|
3316
|
+
return sanityPluginInternationalizedArray.isInternationalizedArrayItemType;
|
|
3317
|
+
}
|
|
3318
|
+
});
|
|
4498
3319
|
Object.defineProperty(exports, "DocumentInternationalizationMenu", {
|
|
4499
3320
|
enumerable: !0,
|
|
4500
3321
|
get: function() {
|
|
@@ -4530,7 +3351,6 @@ exports.BaseDocumentMerger = BaseDocumentMerger;
|
|
|
4530
3351
|
exports.BaseDocumentSerializer = BaseDocumentSerializer;
|
|
4531
3352
|
exports.TranslationsTab = TranslationTab;
|
|
4532
3353
|
exports.attachGTData = attachGTData;
|
|
4533
|
-
exports.createInternationalizedArrayTypes = createInternationalizedArrayTypes;
|
|
4534
3354
|
exports.customSerializers = customSerializers;
|
|
4535
3355
|
exports.defaultStopTypes = defaultStopTypes;
|
|
4536
3356
|
exports.detachGTData = detachGTData;
|