@sheet-i18n/react-client 1.3.0 → 1.4.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/dist/index.d.mts +19 -9
- package/dist/index.d.ts +19 -9
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -5,31 +5,41 @@ import { I18nStore } from '@sheet-i18n/react-core';
|
|
|
5
5
|
type UseIntlParams<D = MessageDescriptor> = Parameters<IntlShape['$t']> extends [D, ...infer R] ? [...R, Omit<D, 'id'>] : never;
|
|
6
6
|
type ExtendedUseIntlParams<D = MessageDescriptor> = UseIntlParams<D> extends [infer A, infer B, ...infer Rest] ? A extends Record<string, infer V> ? [Record<string, V | React.ReactNode>, B, ...Rest] : [A, B, ...Rest] : UseIntlParams<D>;
|
|
7
7
|
type $TParams = Partial<ExtendedUseIntlParams>;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves to keys of a specific sheet title in a localized set,
|
|
10
|
+
* or falls back to `string` if not type-safe or keys resolve to `never`.
|
|
11
|
+
*/
|
|
12
|
+
type SafeMessageId<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TSheetTitle extends SafeSheetTitle<TSupportedLocales, TLocaleSet, TTypeSafe>, TTypeSafe extends boolean> = TTypeSafe extends true ? keyof NonNullable<TLocaleSet[TSupportedLocales[number]]>[TSheetTitle] extends never ? string : keyof NonNullable<TLocaleSet[TSupportedLocales[number]]>[TSheetTitle] : string;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves to valid sheet titles from the locale set
|
|
15
|
+
* or defaults to string if type safety is off or keys are not available.
|
|
16
|
+
*/
|
|
17
|
+
type SafeSheetTitle<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TTypeSafe extends boolean> = TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] extends never ? string : keyof TLocaleSet[TSupportedLocales[number]] : string;
|
|
8
18
|
|
|
9
|
-
type GetTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any
|
|
10
|
-
t: <TMessageId extends
|
|
19
|
+
type GetTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TTypeSafe extends boolean, TSheetTitle extends SafeSheetTitle<TSupportedLocales, TLocaleSet, TTypeSafe>> = {
|
|
20
|
+
t: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? TMessageId : any;
|
|
11
21
|
} & {
|
|
12
22
|
t: {
|
|
13
|
-
dynamic: <TMessageId extends
|
|
14
|
-
promise: <TMessageId extends
|
|
23
|
+
dynamic: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? string : any;
|
|
24
|
+
promise: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? Promise<TMessageId> : any;
|
|
15
25
|
};
|
|
16
26
|
};
|
|
17
27
|
|
|
18
|
-
type UseTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any
|
|
19
|
-
t: <TMessageId extends
|
|
28
|
+
type UseTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Partial<Record<TSupportedLocales[number], Record<string, any>>>>, TTypeSafe extends boolean, TSheetTitle extends SafeSheetTitle<TSupportedLocales, TLocaleSet, TTypeSafe>> = {
|
|
29
|
+
t: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? TMessageId : any;
|
|
20
30
|
} & {
|
|
21
31
|
t: {
|
|
22
|
-
dynamic: <TMessageId extends
|
|
32
|
+
dynamic: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? string : any;
|
|
23
33
|
};
|
|
24
34
|
};
|
|
25
35
|
|
|
26
|
-
type IntlProviderProps<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any
|
|
36
|
+
type IntlProviderProps<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TTypeSafe extends boolean = false> = {
|
|
27
37
|
i18nStore: I18nStore<TSupportedLocales, TLocaleSet, TTypeSafe>;
|
|
28
38
|
currentLocale: TSupportedLocales[number];
|
|
29
39
|
children: React.ReactNode;
|
|
30
40
|
};
|
|
31
41
|
|
|
32
|
-
declare function createI18nContext<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any
|
|
42
|
+
declare function createI18nContext<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TTypeSafe extends boolean = false>(i18nStore: I18nStore<TSupportedLocales, TLocaleSet, TTypeSafe>): {
|
|
33
43
|
IntlProvider: ({ currentLocale, children, }: Omit<IntlProviderProps<TSupportedLocales, TLocaleSet>, "currentLocale" | "i18nStore"> & {
|
|
34
44
|
currentLocale?: string;
|
|
35
45
|
children?: React.ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,31 +5,41 @@ import { I18nStore } from '@sheet-i18n/react-core';
|
|
|
5
5
|
type UseIntlParams<D = MessageDescriptor> = Parameters<IntlShape['$t']> extends [D, ...infer R] ? [...R, Omit<D, 'id'>] : never;
|
|
6
6
|
type ExtendedUseIntlParams<D = MessageDescriptor> = UseIntlParams<D> extends [infer A, infer B, ...infer Rest] ? A extends Record<string, infer V> ? [Record<string, V | React.ReactNode>, B, ...Rest] : [A, B, ...Rest] : UseIntlParams<D>;
|
|
7
7
|
type $TParams = Partial<ExtendedUseIntlParams>;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves to keys of a specific sheet title in a localized set,
|
|
10
|
+
* or falls back to `string` if not type-safe or keys resolve to `never`.
|
|
11
|
+
*/
|
|
12
|
+
type SafeMessageId<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TSheetTitle extends SafeSheetTitle<TSupportedLocales, TLocaleSet, TTypeSafe>, TTypeSafe extends boolean> = TTypeSafe extends true ? keyof NonNullable<TLocaleSet[TSupportedLocales[number]]>[TSheetTitle] extends never ? string : keyof NonNullable<TLocaleSet[TSupportedLocales[number]]>[TSheetTitle] : string;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves to valid sheet titles from the locale set
|
|
15
|
+
* or defaults to string if type safety is off or keys are not available.
|
|
16
|
+
*/
|
|
17
|
+
type SafeSheetTitle<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TTypeSafe extends boolean> = TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] extends never ? string : keyof TLocaleSet[TSupportedLocales[number]] : string;
|
|
8
18
|
|
|
9
|
-
type GetTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any
|
|
10
|
-
t: <TMessageId extends
|
|
19
|
+
type GetTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TTypeSafe extends boolean, TSheetTitle extends SafeSheetTitle<TSupportedLocales, TLocaleSet, TTypeSafe>> = {
|
|
20
|
+
t: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? TMessageId : any;
|
|
11
21
|
} & {
|
|
12
22
|
t: {
|
|
13
|
-
dynamic: <TMessageId extends
|
|
14
|
-
promise: <TMessageId extends
|
|
23
|
+
dynamic: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? string : any;
|
|
24
|
+
promise: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? Promise<TMessageId> : any;
|
|
15
25
|
};
|
|
16
26
|
};
|
|
17
27
|
|
|
18
|
-
type UseTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any
|
|
19
|
-
t: <TMessageId extends
|
|
28
|
+
type UseTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Partial<Record<TSupportedLocales[number], Record<string, any>>>>, TTypeSafe extends boolean, TSheetTitle extends SafeSheetTitle<TSupportedLocales, TLocaleSet, TTypeSafe>> = {
|
|
29
|
+
t: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? TMessageId : any;
|
|
20
30
|
} & {
|
|
21
31
|
t: {
|
|
22
|
-
dynamic: <TMessageId extends
|
|
32
|
+
dynamic: <TMessageId extends SafeMessageId<TSupportedLocales, TLocaleSet, TSheetTitle, TTypeSafe>, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? string : any;
|
|
23
33
|
};
|
|
24
34
|
};
|
|
25
35
|
|
|
26
|
-
type IntlProviderProps<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any
|
|
36
|
+
type IntlProviderProps<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TTypeSafe extends boolean = false> = {
|
|
27
37
|
i18nStore: I18nStore<TSupportedLocales, TLocaleSet, TTypeSafe>;
|
|
28
38
|
currentLocale: TSupportedLocales[number];
|
|
29
39
|
children: React.ReactNode;
|
|
30
40
|
};
|
|
31
41
|
|
|
32
|
-
declare function createI18nContext<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any
|
|
42
|
+
declare function createI18nContext<TSupportedLocales extends readonly string[], TLocaleSet extends Partial<Record<TSupportedLocales[number], Record<string, any>>>, TTypeSafe extends boolean = false>(i18nStore: I18nStore<TSupportedLocales, TLocaleSet, TTypeSafe>): {
|
|
33
43
|
IntlProvider: ({ currentLocale, children, }: Omit<IntlProviderProps<TSupportedLocales, TLocaleSet>, "currentLocale" | "i18nStore"> & {
|
|
34
44
|
currentLocale?: string;
|
|
35
45
|
children?: React.ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheet-i18n/react-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "a client package for react modules used by sheet-i18n",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@sheet-i18n/
|
|
29
|
-
"@sheet-i18n/
|
|
30
|
-
"@sheet-i18n/
|
|
28
|
+
"@sheet-i18n/errors": "1.7.1",
|
|
29
|
+
"@sheet-i18n/shared-utils": "1.7.1",
|
|
30
|
+
"@sheet-i18n/react-core": "1.4.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/react": "^19.0.2",
|
|
34
34
|
"@types/react-dom": "^19.0.2",
|
|
35
35
|
"react": "^18.2.0",
|
|
36
36
|
"react-intl": "^7.0.4",
|
|
37
|
-
"@sheet-i18n/typescript-config": "1.
|
|
37
|
+
"@sheet-i18n/typescript-config": "1.7.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^18 || ^19",
|