@sanity/document-internationalization 4.1.1 → 5.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.
Files changed (52) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +11 -35
  3. package/dist/_chunks-es/{resources.mjs → resources.js} +1 -1
  4. package/dist/{_chunks-cjs → _chunks-es}/resources.js.map +1 -1
  5. package/dist/index.d.ts +57 -88
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +997 -1305
  8. package/dist/index.js.map +1 -1
  9. package/package.json +32 -70
  10. package/dist/_chunks-cjs/resources.js +0 -8
  11. package/dist/_chunks-es/resources.mjs.map +0 -1
  12. package/dist/_legacy/resources.esm.js +0 -9
  13. package/dist/_legacy/resources.esm.js.map +0 -1
  14. package/dist/index.d.mts +0 -108
  15. package/dist/index.esm.js +0 -1625
  16. package/dist/index.esm.js.map +0 -1
  17. package/dist/index.mjs +0 -1625
  18. package/dist/index.mjs.map +0 -1
  19. package/sanity.json +0 -8
  20. package/src/actions/DeleteMetadataAction.tsx +0 -93
  21. package/src/actions/DeleteTranslationAction.tsx +0 -102
  22. package/src/actions/DuplicateWithTranslationsAction.tsx +0 -251
  23. package/src/badges/index.tsx +0 -27
  24. package/src/components/BulkPublish/DocumentCheck.tsx +0 -90
  25. package/src/components/BulkPublish/Info.tsx +0 -28
  26. package/src/components/BulkPublish/InfoIcon.tsx +0 -34
  27. package/src/components/BulkPublish/index.tsx +0 -181
  28. package/src/components/ConstrainedBox.tsx +0 -6
  29. package/src/components/DeleteTranslationDialog/DocumentPreview.tsx +0 -19
  30. package/src/components/DeleteTranslationDialog/index.tsx +0 -111
  31. package/src/components/DeleteTranslationDialog/separateReferences.ts +0 -23
  32. package/src/components/DeleteTranslationFooter.tsx +0 -28
  33. package/src/components/DocumentInternationalizationContext.tsx +0 -47
  34. package/src/components/DocumentInternationalizationMenu.tsx +0 -235
  35. package/src/components/LanguageManage.tsx +0 -108
  36. package/src/components/LanguageOption.tsx +0 -259
  37. package/src/components/LanguagePatch.tsx +0 -67
  38. package/src/components/OptimisticallyStrengthen/ReferencePatcher.tsx +0 -50
  39. package/src/components/OptimisticallyStrengthen/index.tsx +0 -34
  40. package/src/components/Warning.tsx +0 -18
  41. package/src/constants.ts +0 -16
  42. package/src/hooks/useLanguageMetadata.tsx +0 -26
  43. package/src/hooks/useOpenInNewPane.tsx +0 -33
  44. package/src/i18n/index.ts +0 -21
  45. package/src/i18n/resources.ts +0 -7
  46. package/src/index.ts +0 -6
  47. package/src/plugin.tsx +0 -239
  48. package/src/schema/translation/metadata.ts +0 -68
  49. package/src/types.ts +0 -97
  50. package/src/utils/createReference.ts +0 -20
  51. package/src/utils/excludePaths.ts +0 -123
  52. package/v2-incompatible.js +0 -11
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Sanity.io
3
+ Copyright (c) 2024-2026 Sanity.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # @sanity/document-internationalization
2
2
 
3
- All new rewrite exclusively for Sanity Studio v3
4
-
5
3
  - [@sanity/document-internationalization](#sanitydocument-internationalization)
6
4
  - [What this plugin solves](#what-this-plugin-solves)
7
5
  - [Many projects use both](#many-projects-use-both)
@@ -18,10 +16,6 @@ All new rewrite exclusively for Sanity Studio v3
18
16
  - [Note on document quotas](#note-on-document-quotas)
19
17
  - [Documentation](#documentation)
20
18
  - [License](#license)
21
- - [Develop \& test](#develop--test)
22
- - [Release new version](#release-new-version)
23
-
24
- ![v3 Studio with @sanity/document-internationalization v1 Installed](./docs/img/sanity-document-internationalization-v2.png)
25
19
 
26
20
  ## What this plugin solves
27
21
 
@@ -42,7 +36,7 @@ This plugin adds features to the Studio to improve handling **document-level tra
42
36
  - Hooks and components to use throughout your custom components to handle translations
43
37
  - Document Badges to highlight the language version of a document
44
38
 
45
- For **field-level translations** you should use the [sanity-plugin-internationalized-array](https://github.com/sanity-io/sanity-plugin-internationalized-array).
39
+ For **field-level translations** you should use the [sanity-plugin-internationalized-array](https://github.com/sanity-io/plugins/tree/main/plugins/sanity-plugin-internationalized-array).
46
40
 
47
41
  ### Many projects use both
48
42
 
@@ -52,7 +46,7 @@ A good use of **field-level** translation could be a `person` schema. It could h
52
46
 
53
47
  ## Upgrade
54
48
 
55
- [See the upgrade guide](./docs/00-upgrade-from-v1.md) for instructions on how to upgrade from the previous version of Document Internationalization.
49
+ If upgrading from a previous version (v1), please see the [upgrade documentation](https://github.com/sanity-io/document-internationalization/blob/main/docs/00-upgrade-from-v1.md) in the original repository.
56
50
 
57
51
  ## Install
58
52
 
@@ -234,10 +228,7 @@ Fortunately, the Sanity GraphQL API contains a similar filter for document refer
234
228
  ```graphql
235
229
  # In this example we retrieve a lesson by its `slug.current` field value
236
230
  query GetLesson($language: String!, $slug: String!) {
237
- allLesson(
238
- limit: 1
239
- where: {language: {eq: $language}, slug: {current: {eq: $slug}}}
240
- ) {
231
+ allLesson(limit: 1, where: {language: {eq: $language}, slug: {current: {eq: $slug}}}) {
241
232
  _id
242
233
  title
243
234
  language
@@ -273,31 +264,16 @@ This means if you have 100 documents and they are all translated into 3 language
273
264
 
274
265
  ## Documentation
275
266
 
276
- For more advanced topics see the documentation. For installation see [Usage](#usage).
267
+ For more advanced topics see the [original repository documentation](https://github.com/sanity-io/document-internationalization/tree/main/docs).
277
268
 
278
- - [Upgrade from v1](./docs/00-upgrade-from-v1.md)
279
- - [Creating translations of singleton documents](./docs/01-singleton-documents.md)
280
- - [Importing and creating documents](./docs/02-importing-and-creating-documents.md)
281
- - [Deleting translated documents](./docs/03-deleting-translated-documents.md)
282
- - [Importing plugin components](./docs/04-importing-plugin-components.md)
283
- - [Allowing the same slug on different language versions](./docs/05-allowing-the-same-slug-for-translations.md)
284
- - [Remove default new document template](./docs/06-remove-default-new-document-template.md)
269
+ - [Upgrade from v1](https://github.com/sanity-io/document-internationalization/blob/main/docs/00-upgrade-from-v1.md)
270
+ - [Creating translations of singleton documents](https://github.com/sanity-io/document-internationalization/blob/main/docs/01-singleton-documents.md)
271
+ - [Importing and creating documents](https://github.com/sanity-io/document-internationalization/blob/main/docs/02-importing-and-creating-documents.md)
272
+ - [Deleting translated documents](https://github.com/sanity-io/document-internationalization/blob/main/docs/03-deleting-translated-documents.md)
273
+ - [Importing plugin components](https://github.com/sanity-io/document-internationalization/blob/main/docs/04-importing-plugin-components.md)
274
+ - [Allowing the same slug on different language versions](https://github.com/sanity-io/document-internationalization/blob/main/docs/05-allowing-the-same-slug-for-translations.md)
275
+ - [Remove default new document template](https://github.com/sanity-io/document-internationalization/blob/main/docs/06-remove-default-new-document-template.md)
285
276
 
286
277
  ## License
287
278
 
288
279
  [MIT](LICENSE) © Sanity.io
289
-
290
- ## Develop & test
291
-
292
- This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
293
- with default configuration for build & watch scripts.
294
-
295
- See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
296
- on how to run this plugin with hot reload in the studio.
297
-
298
- ### Release new version
299
-
300
- Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-workflow/actions/workflows/main.yml).
301
- Make sure to select the main branch and check "Release new version".
302
-
303
- Semantic release will only release on configured branches, so it is safe to run the release on any branch.
@@ -6,4 +6,4 @@ var resources = {
6
6
  export {
7
7
  resources as default
8
8
  };
9
- //# sourceMappingURL=resources.mjs.map
9
+ //# sourceMappingURL=resources.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resources.js","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":";AAAA,IAAA,YAAe;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;;"}
1
+ {"version":3,"file":"resources.js","sources":["../../src/i18n/resources.ts"],"sourcesContent":["export default {\n 'action.duplicate.label': 'Duplicate with translations',\n 'action.duplicate.disabled.missing-metadata':\n 'The document cannot be duplicated because the metadata document is missing',\n 'action.duplicate.disabled.multiple-metadata':\n 'The document cannot be duplicated because there are multiple metadata documents',\n}\n"],"names":[],"mappings":"AAAA,IAAA,YAAe;AAAA,EACb,0BAA0B;AAAA,EAC1B,8CACE;AAAA,EACF,+CACE;AACJ;"}
package/dist/index.d.ts CHANGED
@@ -1,92 +1,56 @@
1
- /// <reference types="react" />
2
-
3
- import {DocumentActionComponent} from 'sanity'
4
- import type {FieldDefinition} from 'sanity'
5
- import {JSX} from 'react'
6
- import type {KeyedObject} from 'sanity'
7
- import type {ObjectSchemaType} from 'sanity'
8
- import {Plugin as Plugin_2} from 'sanity'
9
- import type {Reference} from 'sanity'
10
- import type {SanityClient} from 'sanity'
11
- import type {SanityDocument} from 'sanity'
12
- import type {SanityDocumentLike} from 'sanity'
13
-
14
- export declare const DeleteTranslationAction: DocumentActionComponent
15
-
16
- export declare const documentInternationalization: Plugin_2<PluginConfig>
17
-
18
- export declare function DocumentInternationalizationMenu(
19
- props: DocumentInternationalizationMenuProps
20
- ): JSX.Element | null
21
-
22
- export declare type DocumentInternationalizationMenuProps = {
23
- schemaType: ObjectSchemaType
24
- documentId: string
25
- }
26
-
27
- export declare interface DocumentInternationalizationSchemaOpts {
1
+ import * as sanity0 from "sanity";
2
+ import { DocumentActionComponent, FieldDefinition, KeyedObject, ObjectSchemaType, Reference, SanityClient, SanityDocument, SanityDocumentLike } from "sanity";
3
+ declare const DeleteTranslationAction: DocumentActionComponent;
4
+ declare const DuplicateWithTranslationsAction: DocumentActionComponent;
5
+ type Language = {
6
+ id: Intl.UnicodeBCP47LocaleIdentifier;
7
+ title: string;
8
+ };
9
+ type SupportedLanguages = Language[] | ((client: SanityClient) => Promise<Language[]>);
10
+ type PluginCallbackArgs = {
11
+ sourceDocument: SanityDocument;
12
+ newDocument: SanityDocument;
13
+ sourceLanguageId: string;
14
+ destinationLanguageId: string;
15
+ metaDocumentId: string;
16
+ client: SanityClient;
17
+ };
18
+ type PluginConfig = {
19
+ supportedLanguages: SupportedLanguages;
20
+ schemaTypes: string[];
21
+ languageField?: string;
22
+ weakReferences?: boolean;
23
+ bulkPublish?: boolean;
24
+ metadataFields?: FieldDefinition[];
25
+ apiVersion?: string;
26
+ allowCreateMetaDoc?: boolean;
27
+ callback?: ((args: PluginCallbackArgs) => Promise<void>) | null;
28
+ };
29
+ type PluginConfigContext = Required<PluginConfig> & {
30
+ supportedLanguages: Language[];
31
+ };
32
+ type TranslationReference = KeyedObject & {
33
+ _type: 'internationalizedArrayReferenceValue';
34
+ value: Reference;
35
+ };
36
+ type Metadata = {
37
+ _id: string;
38
+ _createdAt: string;
39
+ translations: TranslationReference[];
40
+ };
41
+ type MetadataDocument = SanityDocumentLike & {
42
+ schemaTypes: string[];
43
+ translations: TranslationReference[];
44
+ };
45
+ type DocumentInternationalizationMenuProps = {
46
+ schemaType: ObjectSchemaType;
47
+ documentId: string;
48
+ };
49
+ interface DocumentInternationalizationSchemaOpts {
28
50
  documentInternationalization?: {
29
- /** Set to true to disable duplication of this field or type */
30
- exclude?: boolean
31
- }
32
- }
33
-
34
- export declare const DuplicateWithTranslationsAction: DocumentActionComponent
35
-
36
- export declare type Language = {
37
- id: Intl.UnicodeBCP47LocaleIdentifier
38
- title: string
39
- }
40
-
41
- export declare type Metadata = {
42
- _id: string
43
- _createdAt: string
44
- translations: TranslationReference[]
45
- }
46
-
47
- export declare type MetadataDocument = SanityDocumentLike & {
48
- schemaTypes: string[]
49
- translations: TranslationReference[]
50
- }
51
-
52
- export declare type PluginCallbackArgs = {
53
- sourceDocument: SanityDocument
54
- newDocument: SanityDocument
55
- sourceLanguageId: string
56
- destinationLanguageId: string
57
- metaDocumentId: string
58
- client: SanityClient
51
+ /** Set to true to disable duplication of this field or type */exclude?: boolean;
52
+ };
59
53
  }
60
-
61
- export declare type PluginConfig = {
62
- supportedLanguages: SupportedLanguages
63
- schemaTypes: string[]
64
- languageField?: string
65
- weakReferences?: boolean
66
- bulkPublish?: boolean
67
- metadataFields?: FieldDefinition[]
68
- apiVersion?: string
69
- allowCreateMetaDoc?: boolean
70
- callback?: ((args: PluginCallbackArgs) => Promise<void>) | null
71
- }
72
-
73
- export declare type PluginConfigContext = Required<PluginConfig> & {
74
- supportedLanguages: Language[]
75
- }
76
-
77
- export declare type SupportedLanguages =
78
- | Language[]
79
- | ((client: SanityClient) => Promise<Language[]>)
80
-
81
- export declare type TranslationReference = KeyedObject & {
82
- _type: 'internationalizedArrayReferenceValue'
83
- value: Reference
84
- }
85
-
86
- export declare function useDocumentInternationalizationContext(): PluginConfigContext
87
-
88
- export {}
89
-
90
54
  declare module 'sanity' {
91
55
  interface ArrayOptions extends DocumentInternationalizationSchemaOpts {}
92
56
  interface BlockOptions extends DocumentInternationalizationSchemaOpts {}
@@ -105,4 +69,9 @@ declare module 'sanity' {
105
69
  interface TextOptions extends DocumentInternationalizationSchemaOpts {}
106
70
  interface UrlOptions extends DocumentInternationalizationSchemaOpts {}
107
71
  interface EmailOptions extends DocumentInternationalizationSchemaOpts {}
108
- }
72
+ } //# sourceMappingURL=types.d.ts.map
73
+ declare function useDocumentInternationalizationContext(): PluginConfigContext;
74
+ declare function DocumentInternationalizationMenu(props: DocumentInternationalizationMenuProps): React.JSX.Element | null;
75
+ declare const documentInternationalization: sanity0.Plugin<PluginConfig>;
76
+ export { DeleteTranslationAction, DocumentInternationalizationMenu, DocumentInternationalizationMenuProps, DocumentInternationalizationSchemaOpts, DuplicateWithTranslationsAction, Language, Metadata, MetadataDocument, PluginCallbackArgs, PluginConfig, PluginConfigContext, SupportedLanguages, TranslationReference, documentInternationalization, useDocumentInternationalizationContext };
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/actions/DeleteTranslationAction.tsx","../src/actions/DuplicateWithTranslationsAction.tsx","../src/types.ts","../src/components/DocumentInternationalizationContext.tsx","../src/components/DocumentInternationalizationMenu.tsx","../src/plugin.tsx"],"mappings":";;cAUa,uBAAA,EAAyB,uBAAA;AAAA,cCiCzB,+BAAA,EAAiC,uBAAA;AAAA,KCjClC,QAAA;EACV,EAAA,EAAI,IAAA,CAAK,4BAAA;EACT,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,QAAA,OAAe,MAAA,EAAQ,YAAA,KAAiB,OAAA,CAAQ,QAAA;AAAA,KAErE,kBAAA;EACV,cAAA,EAAgB,cAAA;EAChB,WAAA,EAAa,cAAA;EACb,gBAAA;EACA,qBAAA;EACA,cAAA;EACA,MAAA,EAAQ,YAAA;AAAA;AAAA,KAGE,YAAA;EACV,kBAAA,EAAoB,kBAAA;EACpB,WAAA;EACA,aAAA;EACA,cAAA;EACA,WAAA;EACA,cAAA,GAAiB,eAAA;EACjB,UAAA;EACA,kBAAA;EACA,QAAA,KAAa,IAAA,EAAM,kBAAA,KAAuB,OAAA;AAAA;AAAA,KAMhC,mBAAA,GAAsB,QAAA,CAAS,YAAA;EACzC,kBAAA,EAAoB,QAAA;AAAA;AAAA,KAGV,oBAAA,GAAuB,WAAA;EACjC,KAAA;EACA,KAAA,EAAO,SAAA;AAAA;AAAA,KAGG,QAAA;EACV,GAAA;EACA,UAAA;EACA,YAAA,EAAc,oBAAA;AAAA;AAAA,KAGJ,gBAAA,GAAmB,kBAAA;EAC7B,WAAA;EACA,YAAA,EAAc,oBAAA;AAAA;AAAA,KAGJ,qCAAA;EACV,UAAA,EAAY,gBAAA;EACZ,UAAA;AAAA;AAAA,UAIe,sCAAA;EACf,4BAAA;IA7CoB,+DA+ClB,OAAA;EAAA;AAAA;AAAA;EAAA,UAKQ,YAAA,SAAqB,sCAAA;EAAA,UACrB,YAAA,SAAqB,sCAAA;EAAA,UACrB,cAAA,SAAuB,sCAAA;EAAA,UACvB,4BAAA,SAAqC,sCAAA;EAAA,UACrC,WAAA,SAAoB,sCAAA;EAAA,UACpB,eAAA,SAAwB,sCAAA;EAAA,UACxB,WAAA,SAAoB,sCAAA;EAAA,UACpB,eAAA,SAAwB,sCAAA;EAAA,UACxB,YAAA,SAAqB,sCAAA;EAAA,UACrB,aAAA,SAAsB,sCAAA;EAAA,UACtB,aAAA,SAAsB,sCAAA;EAAA,UACtB,oBAAA,SAA6B,sCAAA;EAAA,UAC7B,WAAA,SAAoB,sCAAA;EAAA,UACpB,aAAA,SAAsB,sCAAA;EAAA,UACtB,WAAA,SAAoB,sCAAA;EAAA,UACpB,UAAA,SAAmB,sCAAA;EAAA,UACnB,YAAA,SAAqB,sCAAA;AAAA;AAAA,iBChFjB,sCAAA,CAAA,GAA0C,mBAAA;AAAA,iBCM1C,gCAAA,CACd,KAAA,EAAO,qCAAA,GACN,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,cCHA,4BAAA,EAA4B,OAAA,CAAA,MAAA,CAAA,YAAA"}