@sanity/document-internationalization 2.1.2 → 3.0.1

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 (34) hide show
  1. package/dist/index.d.mts +90 -0
  2. package/dist/index.d.ts +3 -1
  3. package/dist/index.esm.js +768 -1166
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +753 -1176
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +1048 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +34 -38
  10. package/src/actions/DeleteMetadataAction.tsx +5 -5
  11. package/src/actions/DeleteTranslationAction.tsx +6 -2
  12. package/src/badges/index.tsx +1 -1
  13. package/src/components/BulkPublish/DocumentCheck.tsx +1 -1
  14. package/src/components/BulkPublish/InfoIcon.tsx +4 -3
  15. package/src/components/BulkPublish/index.tsx +3 -2
  16. package/src/components/ConstrainedBox.tsx +1 -1
  17. package/src/components/DeleteTranslationDialog/index.tsx +1 -1
  18. package/src/components/DeleteTranslationDialog/separateReferences.ts +1 -1
  19. package/src/components/DocumentInternationalizationContext.tsx +2 -2
  20. package/src/components/DocumentInternationalizationMenu.tsx +3 -2
  21. package/src/components/LanguageManage.tsx +1 -0
  22. package/src/components/LanguageOption.tsx +28 -4
  23. package/src/components/LanguagePatch.tsx +2 -2
  24. package/src/components/OptimisticallyStrengthen/ReferencePatcher.tsx +2 -2
  25. package/src/components/OptimisticallyStrengthen/index.tsx +1 -1
  26. package/src/components/Warning.tsx +1 -1
  27. package/src/constants.ts +1 -1
  28. package/src/hooks/useLanguageMetadata.tsx +1 -1
  29. package/src/hooks/useOpenInNewPane.tsx +2 -2
  30. package/src/plugin.tsx +4 -4
  31. package/src/schema/translation/metadata.ts +2 -4
  32. package/src/utils/createReference.ts +1 -1
  33. package/src/utils/excludePaths.ts +4 -4
  34. package/dist/index.cjs.mjs +0 -7
@@ -0,0 +1,90 @@
1
+ /// <reference types="react" />
2
+
3
+ import {DocumentActionComponent} from 'sanity'
4
+ import type {FieldDefinition} from 'sanity'
5
+ import {JSX as JSX_2} 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
+
12
+ export declare const DeleteTranslationAction: DocumentActionComponent
13
+
14
+ export declare const documentInternationalization: Plugin_2<PluginConfig>
15
+
16
+ export declare function DocumentInternationalizationMenu(
17
+ props: DocumentInternationalizationMenuProps
18
+ ): JSX_2.Element | null
19
+
20
+ export declare type DocumentInternationalizationMenuProps = {
21
+ schemaType: ObjectSchemaType
22
+ documentId: string
23
+ }
24
+
25
+ export declare interface DocumentInternationalizationSchemaOpts {
26
+ documentInternationalization?: {
27
+ /** Set to true to disable duplication of this field or type */
28
+ exclude?: boolean
29
+ }
30
+ }
31
+
32
+ export declare type Language = {
33
+ id: Intl.UnicodeBCP47LocaleIdentifier
34
+ title: string
35
+ }
36
+
37
+ export declare type Metadata = {
38
+ _id: string
39
+ _createdAt: string
40
+ translations: TranslationReference[]
41
+ }
42
+
43
+ export declare type PluginConfig = {
44
+ supportedLanguages: SupportedLanguages
45
+ schemaTypes: string[]
46
+ languageField?: string
47
+ weakReferences?: boolean
48
+ bulkPublish?: boolean
49
+ metadataFields?: FieldDefinition[]
50
+ apiVersion?: string
51
+ }
52
+
53
+ export declare type PluginConfigContext = Required<PluginConfig> & {
54
+ supportedLanguages: Language[]
55
+ }
56
+
57
+ export declare type SupportedLanguages =
58
+ | Language[]
59
+ | ((client: SanityClient) => Promise<Language[]>)
60
+
61
+ export declare type TranslationReference = KeyedObject & {
62
+ _type: 'internationalizedArrayReferenceValue'
63
+ value: Reference
64
+ }
65
+
66
+ export declare function useDocumentInternationalizationContext(): PluginConfigContext
67
+
68
+ export {}
69
+
70
+ declare module 'sanity' {
71
+ interface ArrayOptions extends DocumentInternationalizationSchemaOpts {}
72
+ interface BlockOptions extends DocumentInternationalizationSchemaOpts {}
73
+ interface BooleanOptions extends DocumentInternationalizationSchemaOpts {}
74
+ interface CrossDatasetReferenceOptions
75
+ extends DocumentInternationalizationSchemaOpts {}
76
+ interface DateOptions extends DocumentInternationalizationSchemaOpts {}
77
+ interface DatetimeOptions extends DocumentInternationalizationSchemaOpts {}
78
+ interface FileOptions extends DocumentInternationalizationSchemaOpts {}
79
+ interface GeopointOptions extends DocumentInternationalizationSchemaOpts {}
80
+ interface ImageOptions extends DocumentInternationalizationSchemaOpts {}
81
+ interface NumberOptions extends DocumentInternationalizationSchemaOpts {}
82
+ interface ObjectOptions extends DocumentInternationalizationSchemaOpts {}
83
+ interface ReferenceBaseOptions
84
+ extends DocumentInternationalizationSchemaOpts {}
85
+ interface SlugOptions extends DocumentInternationalizationSchemaOpts {}
86
+ interface StringOptions extends DocumentInternationalizationSchemaOpts {}
87
+ interface TextOptions extends DocumentInternationalizationSchemaOpts {}
88
+ interface UrlOptions extends DocumentInternationalizationSchemaOpts {}
89
+ interface EmailOptions extends DocumentInternationalizationSchemaOpts {}
90
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
+ /// <reference types="react" />
2
+
1
3
  import {DocumentActionComponent} from 'sanity'
2
4
  import type {FieldDefinition} from 'sanity'
3
- import {JSX as JSX_2} from 'react/jsx-runtime'
5
+ import {JSX as JSX_2} from 'react'
4
6
  import type {KeyedObject} from 'sanity'
5
7
  import type {ObjectSchemaType} from 'sanity'
6
8
  import {Plugin as Plugin_2} from 'sanity'