gt-sanity 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,9 +1,11 @@
1
+ import { documentInternationalization } from "@sanity/document-internationalization";
2
+ import { DocumentInternationalizationMenu, documentInternationalization as documentInternationalization2, useDeleteTranslationAction, useDocumentInternationalizationContext, useDuplicateWithTranslationsAction } from "@sanity/document-internationalization";
1
3
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
4
  import { ThemeProvider, ToastProvider, Box, Flex, Spinner, Card, Text, useToast, Label, Grid, Button, Switch, Stack, Tooltip, Dialog, Container, Heading } from "@sanity/ui";
3
5
  import { buildTheme } from "@sanity/ui/theme";
4
6
  import o, { useState, useEffect, createContext, useCallback, useContext, useDebugValue, createElement, useRef, useMemo } from "react";
5
7
  import { useClient as useClient$1, useSchema, definePlugin } from "sanity";
6
- import { GT } from "generaltranslation";
8
+ import { GT, getLocaleProperties } from "generaltranslation";
7
9
  import { libraryDefaultLocale } from "generaltranslation/internal";
8
10
  import { htmlToBlocks } from "@portabletext/block-tools";
9
11
  import { Schema } from "@sanity/schema";
@@ -3712,10 +3714,12 @@ const WrapText = dt(Box)`
3712
3714
  additionalStopTypes = [],
3713
3715
  additionalSerializers = {},
3714
3716
  additionalDeserializers = {},
3715
- additionalBlockDeserializers = []
3717
+ additionalBlockDeserializers = [],
3718
+ showDocumentInternationalization = !0
3716
3719
  }) => {
3717
3720
  const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? libraryDefaultLocale;
3718
- return translateDocuments = translateDocuments?.filter((filter2) => !!(filter2.documentId || filter2.type)), pluginConfig.init(
3721
+ let normalizedTranslateDocuments;
3722
+ translateDocuments && (normalizedTranslateDocuments = translateDocuments.map((entry) => typeof entry == "string" ? { type: entry } : entry).filter((filter2) => filter2.documentId || filter2.type)), pluginConfig.init(
3719
3723
  secretsNamespace,
3720
3724
  languageField,
3721
3725
  resolvedSourceLocale,
@@ -3725,7 +3729,7 @@ const WrapText = dt(Box)`
3725
3729
  singletonMapping || ((sourceDocumentId, locale) => `${sourceDocumentId}-${locale}`),
3726
3730
  ignoreFields || [],
3727
3731
  skipFields || [],
3728
- translateDocuments || [],
3732
+ normalizedTranslateDocuments || [],
3729
3733
  additionalStopTypes,
3730
3734
  additionalSerializers,
3731
3735
  additionalDeserializers,
@@ -3735,8 +3739,27 @@ const WrapText = dt(Box)`
3735
3739
  customMapping,
3736
3740
  apiKey,
3737
3741
  projectId
3738
- }), {
3742
+ });
3743
+ const plugins = [];
3744
+ if (showDocumentInternationalization) {
3745
+ const schemaTypes = normalizedTranslateDocuments?.map((filter2) => filter2.type).filter((type) => !!type) ?? [];
3746
+ if (schemaTypes.length > 0) {
3747
+ const supportedLanguages = [resolvedSourceLocale, ...locales].map((locale) => {
3748
+ const props = getLocaleProperties(locale, resolvedSourceLocale);
3749
+ return { id: locale, title: props.name };
3750
+ });
3751
+ plugins.push(
3752
+ documentInternationalization({
3753
+ supportedLanguages,
3754
+ schemaTypes,
3755
+ languageField
3756
+ })
3757
+ );
3758
+ }
3759
+ }
3760
+ return {
3739
3761
  name: "gt-sanity",
3762
+ plugins,
3740
3763
  tools: [
3741
3764
  {
3742
3765
  name: "translations",
@@ -3755,13 +3778,18 @@ export {
3755
3778
  BaseDocumentDeserializer,
3756
3779
  BaseDocumentMerger,
3757
3780
  BaseDocumentSerializer,
3781
+ DocumentInternationalizationMenu,
3758
3782
  TranslationTab as TranslationsTab,
3759
3783
  attachGTData,
3760
3784
  customSerializers,
3761
3785
  defaultStopTypes,
3762
3786
  detachGTData,
3787
+ documentInternationalization2 as documentInternationalization,
3763
3788
  findLatestDraft,
3764
3789
  gtPlugin,
3765
- translateAction
3790
+ translateAction,
3791
+ useDeleteTranslationAction,
3792
+ useDocumentInternationalizationContext,
3793
+ useDuplicateWithTranslationsAction
3766
3794
  };
3767
3795
  //# sourceMappingURL=index.mjs.map