@sanity/document-internationalization 0.0.1-beta.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.
- package/LICENSE +7 -0
- package/README.md +30 -0
- package/config.dist.json +4 -0
- package/lib/actions/DeleteWithi18nAction.d.ts +16 -0
- package/lib/actions/DuplicateWithi18nAction.d.ts +8 -0
- package/lib/actions/PublishWithi18nAction.d.ts +9 -0
- package/lib/actions/index.d.ts +8 -0
- package/lib/actions/index.js +19549 -0
- package/lib/actions/index.js.map +1 -0
- package/lib/badges/LanguageBadge.d.ts +5 -0
- package/lib/badges/index.d.ts +5 -0
- package/lib/badges/index.js +17324 -0
- package/lib/badges/index.js.map +1 -0
- package/lib/constants/I18nDelimiter.d.ts +1 -0
- package/lib/constants/I18nPrefix.d.ts +1 -0
- package/lib/constants/IdStructure.d.ts +4 -0
- package/lib/constants/LanguageCultures.d.ts +4 -0
- package/lib/constants/ReferenceBehavior.d.ts +5 -0
- package/lib/constants/UiMessages.d.ts +34 -0
- package/lib/constants/index.d.ts +6 -0
- package/lib/constants/index.js +736 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/structure/IDefaultDocumentNodeStructureProps.d.ts +4 -0
- package/lib/structure/components/Flag/Flag.d.ts +6 -0
- package/lib/structure/components/Flag/allEmojiFlagCodes.d.ts +1 -0
- package/lib/structure/components/Flag/index.d.ts +1 -0
- package/lib/structure/components/MaintenanceTab/MaintenanceTab.d.ts +2 -0
- package/lib/structure/components/MaintenanceTab/index.d.ts +1 -0
- package/lib/structure/components/MaintenanceTabResult/MaintenanceTabResult.d.ts +10 -0
- package/lib/structure/components/MaintenanceTabResult/index.d.ts +1 -0
- package/lib/structure/components/MaintenanceTabTypeSelector/MaintenanceTabTypeSelector.d.ts +8 -0
- package/lib/structure/components/MaintenanceTabTypeSelector/index.d.ts +1 -0
- package/lib/structure/components/TranslationLink/TranslationLink.d.ts +12 -0
- package/lib/structure/components/TranslationLink/index.d.ts +1 -0
- package/lib/structure/components/TranslationsComponentFactory/TranslationsComponentFactory.d.ts +5 -0
- package/lib/structure/components/TranslationsComponentFactory/index.d.ts +1 -0
- package/lib/structure/hooks/index.d.ts +1 -0
- package/lib/structure/hooks/useDocumentsInformation.d.ts +20 -0
- package/lib/structure/index.d.ts +13 -0
- package/lib/structure/index.js +20464 -0
- package/lib/structure/index.js.map +1 -0
- package/lib/structure/utils/fixBaseDocumentRefs.d.ts +2 -0
- package/lib/structure/utils/fixBaseLanguageMismatch.d.ts +2 -0
- package/lib/structure/utils/fixIdStructureMismatchDocuments.d.ts +2 -0
- package/lib/structure/utils/fixLanguageFields.d.ts +2 -0
- package/lib/structure/utils/fixOrphanedDocuments.d.ts +2 -0
- package/lib/structure/utils/fixReferenceBehaviorMismatch.d.ts +2 -0
- package/lib/structure/utils/fixTranslationRefs.d.ts +2 -0
- package/lib/structure/utils/index.d.ts +6 -0
- package/lib/types/IEditState.d.ts +5 -0
- package/lib/types/ILanguageObject.d.ts +6 -0
- package/lib/types/ILanguageQuery.d.ts +10 -0
- package/lib/types/IResolverProps.d.ts +9 -0
- package/lib/types/ITranslationRef.d.ts +6 -0
- package/lib/types/IType.d.ts +38 -0
- package/lib/types/IUseDocumentOperationResult.d.ts +11 -0
- package/lib/types/TFieldNamesConfig.d.ts +5 -0
- package/lib/types/TLanguage.d.ts +2 -0
- package/lib/types/TLanguagesOption.d.ts +3 -0
- package/lib/types/TSchema.d.ts +6 -0
- package/lib/types/Ti18nConfig.d.ts +10 -0
- package/lib/types/Ti18nDocument.d.ts +13 -0
- package/lib/types/Ti18nSchema.d.ts +5 -0
- package/lib/types/index.d.ts +14 -0
- package/lib/utils/baseToTop.d.ts +1 -0
- package/lib/utils/batch.d.ts +1 -0
- package/lib/utils/buildDocId.d.ts +1 -0
- package/lib/utils/createSanityReference.d.ts +5 -0
- package/lib/utils/getAllSchemas.d.ts +2 -0
- package/lib/utils/getBaseIdFromId.d.ts +1 -0
- package/lib/utils/getBaseLanguage.d.ts +2 -0
- package/lib/utils/getConfig.d.ts +6 -0
- package/lib/utils/getFlag.d.ts +2 -0
- package/lib/utils/getLanguageFromId.d.ts +1 -0
- package/lib/utils/getLanguagesFromOption.d.ts +3 -0
- package/lib/utils/getSanityClient.d.ts +1 -0
- package/lib/utils/getSchema.d.ts +2 -0
- package/lib/utils/getTranslationsForId.d.ts +2 -0
- package/lib/utils/index.d.ts +16 -0
- package/lib/utils/index.js +18425 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/makeObjectKey.d.ts +1 -0
- package/lib/utils/normalizeLanguageList.d.ts +6 -0
- package/lib/utils/serializePath.d.ts +2 -0
- package/lib/utils/updateIntlFieldsForDocument.d.ts +2 -0
- package/lib/validators/index.d.ts +1 -0
- package/lib/validators/index.js +17309 -0
- package/lib/validators/index.js.map +1 -0
- package/lib/validators/isSlugUnique.d.ts +2 -0
- package/package.json +151 -0
- package/sanity.json +28 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TLanguagesOption } from './TLanguagesOption';
|
|
2
|
+
import { ObjectSchemaTypeWithOptions } from '@sanity/types';
|
|
3
|
+
export interface IField {
|
|
4
|
+
name: string;
|
|
5
|
+
type: IType;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface IFieldSet {
|
|
9
|
+
name: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
single: boolean;
|
|
13
|
+
options: ObjectSchemaTypeWithOptions['options'];
|
|
14
|
+
field: IField;
|
|
15
|
+
fields: IField[];
|
|
16
|
+
}
|
|
17
|
+
export interface IType {
|
|
18
|
+
name: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
hidden?: boolean;
|
|
22
|
+
level: number;
|
|
23
|
+
type: string;
|
|
24
|
+
jsonType: string;
|
|
25
|
+
fields: IField[];
|
|
26
|
+
fieldsets: IFieldSet[];
|
|
27
|
+
options: ObjectSchemaTypeWithOptions['options'] & {
|
|
28
|
+
base?: string;
|
|
29
|
+
i18n?: boolean;
|
|
30
|
+
languages?: TLanguagesOption;
|
|
31
|
+
css?: (classNames: Record<string, string>) => string;
|
|
32
|
+
messages?: {
|
|
33
|
+
loading?: string;
|
|
34
|
+
missingTranslations?: string;
|
|
35
|
+
};
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare type ExecutablAction = {
|
|
2
|
+
disabled?: string;
|
|
3
|
+
execute: (...args: any[]) => void;
|
|
4
|
+
};
|
|
5
|
+
export interface IUseDocumentOperationResult {
|
|
6
|
+
patch: ExecutablAction;
|
|
7
|
+
publish: ExecutablAction;
|
|
8
|
+
duplicate: ExecutablAction;
|
|
9
|
+
delete: ExecutablAction;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TLanguagesOption } from './TLanguagesOption';
|
|
2
|
+
import { TFieldNamesConfig } from './TFieldNamesConfig';
|
|
3
|
+
import { IdStructure, ReferenceBehavior } from '../constants';
|
|
4
|
+
export declare type Ti18nConfig = {
|
|
5
|
+
base?: string;
|
|
6
|
+
languages?: TLanguagesOption;
|
|
7
|
+
idStructure?: IdStructure;
|
|
8
|
+
referenceBehavior?: ReferenceBehavior;
|
|
9
|
+
fieldNames?: TFieldNamesConfig;
|
|
10
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SanityDocument } from '@sanity/client';
|
|
2
|
+
export declare type Ti18nDocument<D = any> = SanityDocument<D> & {
|
|
3
|
+
__i18n_lang?: string;
|
|
4
|
+
__i18n_refs?: {
|
|
5
|
+
_key: string;
|
|
6
|
+
lang: string;
|
|
7
|
+
ref: {
|
|
8
|
+
_type: 'reference';
|
|
9
|
+
_ref: string;
|
|
10
|
+
_weak: boolean;
|
|
11
|
+
};
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './ILanguageObject';
|
|
2
|
+
export * from './ILanguageQuery';
|
|
3
|
+
export * from './IType';
|
|
4
|
+
export * from './TLanguage';
|
|
5
|
+
export * from './IResolverProps';
|
|
6
|
+
export * from './TLanguagesOption';
|
|
7
|
+
export * from './TSchema';
|
|
8
|
+
export * from './Ti18nSchema';
|
|
9
|
+
export * from './Ti18nConfig';
|
|
10
|
+
export * from './Ti18nDocument';
|
|
11
|
+
export * from './TFieldNamesConfig';
|
|
12
|
+
export * from './IUseDocumentOperationResult';
|
|
13
|
+
export * from './ITranslationRef';
|
|
14
|
+
export * from './IEditState';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const baseToTop: (a: any, b: any) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function batch<R>(input: R[], fn: (input: R[]) => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const buildDocId: (id: string, lang: string | null) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getBaseIdFromId: (id: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getLanguageFromId: (id: string) => string | null;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SanityDocument } from '@sanity/client';
|
|
2
|
+
import { ILanguageObject, TLanguagesOption } from '../types';
|
|
3
|
+
export declare const getLanguagesFromOption: <D extends SanityDocument<Record<string, any>>>(langs: TLanguagesOption, document?: D | null | undefined) => Promise<ILanguageObject[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getSanityClient: () => import('@sanity/client').SanityClient;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './getConfig';
|
|
2
|
+
export * from './buildDocId';
|
|
3
|
+
export * from './normalizeLanguageList';
|
|
4
|
+
export * from './getBaseLanguage';
|
|
5
|
+
export * from './getSanityClient';
|
|
6
|
+
export * from './getLanguagesFromOption';
|
|
7
|
+
export * from './getSchema';
|
|
8
|
+
export * from './getLanguageFromId';
|
|
9
|
+
export * from './getBaseIdFromId';
|
|
10
|
+
export * from './getAllSchemas';
|
|
11
|
+
export * from './getTranslationsForId';
|
|
12
|
+
export * from './makeObjectKey';
|
|
13
|
+
export * from './createSanityReference';
|
|
14
|
+
export * from './updateIntlFieldsForDocument';
|
|
15
|
+
export * from './serializePath';
|
|
16
|
+
export * from './batch';
|