@sheet-i18n/react-client 0.2.2 → 0.2.3

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 CHANGED
@@ -1,29 +1,25 @@
1
+ import { MessageDescriptor, IntlShape } from 'react-intl';
1
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
  import { I18nStore } from '@sheet-i18n/react-core';
3
- import { MessageDescriptor, IntlShape } from 'react-intl';
4
-
5
- type IntlProviderProps<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>> = {
6
- i18nStore: I18nStore<TSupportedLocales, TLocaleSet>;
7
- currentLocale: TSupportedLocales[number];
8
- children: React.ReactNode;
9
- };
10
4
 
11
5
  type UseIntlParams<D = MessageDescriptor> = Parameters<IntlShape['$t']> extends [D, ...infer R] ? [...R, Omit<D, 'id'>] : never;
12
6
  type $TParams = Partial<UseIntlParams>;
13
7
  type BigIntExcludedReactNode = Exclude<React.ReactNode, bigint>;
14
- interface UseTranslationParams<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TSheetTitle = keyof TLocaleSet[TSupportedLocales[number]]> {
15
- sheetTitle: TSheetTitle;
16
- i18nStore: I18nStore<TSupportedLocales, TLocaleSet>;
17
- }
18
- declare function useTranslation<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TSheetTitle extends keyof TLocaleSet[TSupportedLocales[number]], TMessageId extends keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle]>({ sheetTitle, }: UseTranslationParams<TSupportedLocales, TLocaleSet, TSheetTitle>): {
19
- t: <TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => BigIntExcludedReactNode | BigIntExcludedReactNode[];
8
+ type UseTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean, TSheetTitle extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] : string> = {
9
+ t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => BigIntExcludedReactNode;
10
+ };
11
+
12
+ type IntlProviderProps<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean = true> = {
13
+ i18nStore: I18nStore<TSupportedLocales, TLocaleSet, TTypeSafe>;
14
+ currentLocale: TSupportedLocales[number];
15
+ children: React.ReactNode;
20
16
  };
21
17
 
22
- declare function createI18nContext<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>>(i18nStore: I18nStore<TSupportedLocales, TLocaleSet>): {
18
+ declare function createI18nContext<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean = true>(i18nStore: I18nStore<TSupportedLocales, TLocaleSet, TTypeSafe>): {
23
19
  IntlProvider: ({ currentLocale, children, }: Omit<IntlProviderProps<TSupportedLocales, TLocaleSet>, "currentLocale" | "i18nStore"> & {
24
20
  currentLocale?: string;
25
21
  }) => react_jsx_runtime.JSX.Element;
26
- useTranslation: <SheetTitle extends keyof TLocaleSet[TSupportedLocales[number]]>(sheetTitle: SheetTitle) => ReturnType<typeof useTranslation<TSupportedLocales, TLocaleSet, SheetTitle, keyof TLocaleSet[TSupportedLocales[number]][SheetTitle]>>;
22
+ useTranslation: <TSheetTitle extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] : string>(sheetTitle: TSheetTitle) => UseTranslationReturn<TSupportedLocales, TLocaleSet, TTypeSafe, TSheetTitle>;
27
23
  };
28
24
 
29
25
  export { createI18nContext };
package/dist/index.d.ts CHANGED
@@ -1,29 +1,25 @@
1
+ import { MessageDescriptor, IntlShape } from 'react-intl';
1
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
  import { I18nStore } from '@sheet-i18n/react-core';
3
- import { MessageDescriptor, IntlShape } from 'react-intl';
4
-
5
- type IntlProviderProps<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>> = {
6
- i18nStore: I18nStore<TSupportedLocales, TLocaleSet>;
7
- currentLocale: TSupportedLocales[number];
8
- children: React.ReactNode;
9
- };
10
4
 
11
5
  type UseIntlParams<D = MessageDescriptor> = Parameters<IntlShape['$t']> extends [D, ...infer R] ? [...R, Omit<D, 'id'>] : never;
12
6
  type $TParams = Partial<UseIntlParams>;
13
7
  type BigIntExcludedReactNode = Exclude<React.ReactNode, bigint>;
14
- interface UseTranslationParams<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TSheetTitle = keyof TLocaleSet[TSupportedLocales[number]]> {
15
- sheetTitle: TSheetTitle;
16
- i18nStore: I18nStore<TSupportedLocales, TLocaleSet>;
17
- }
18
- declare function useTranslation<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TSheetTitle extends keyof TLocaleSet[TSupportedLocales[number]], TMessageId extends keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle]>({ sheetTitle, }: UseTranslationParams<TSupportedLocales, TLocaleSet, TSheetTitle>): {
19
- t: <TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => BigIntExcludedReactNode | BigIntExcludedReactNode[];
8
+ type UseTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean, TSheetTitle extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] : string> = {
9
+ t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams[0], TOpts extends $TParams[1], TDescriptor extends $TParams[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => BigIntExcludedReactNode;
10
+ };
11
+
12
+ type IntlProviderProps<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean = true> = {
13
+ i18nStore: I18nStore<TSupportedLocales, TLocaleSet, TTypeSafe>;
14
+ currentLocale: TSupportedLocales[number];
15
+ children: React.ReactNode;
20
16
  };
21
17
 
22
- declare function createI18nContext<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>>(i18nStore: I18nStore<TSupportedLocales, TLocaleSet>): {
18
+ declare function createI18nContext<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean = true>(i18nStore: I18nStore<TSupportedLocales, TLocaleSet, TTypeSafe>): {
23
19
  IntlProvider: ({ currentLocale, children, }: Omit<IntlProviderProps<TSupportedLocales, TLocaleSet>, "currentLocale" | "i18nStore"> & {
24
20
  currentLocale?: string;
25
21
  }) => react_jsx_runtime.JSX.Element;
26
- useTranslation: <SheetTitle extends keyof TLocaleSet[TSupportedLocales[number]]>(sheetTitle: SheetTitle) => ReturnType<typeof useTranslation<TSupportedLocales, TLocaleSet, SheetTitle, keyof TLocaleSet[TSupportedLocales[number]][SheetTitle]>>;
22
+ useTranslation: <TSheetTitle extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] : string>(sheetTitle: TSheetTitle) => UseTranslationReturn<TSupportedLocales, TLocaleSet, TTypeSafe, TSheetTitle>;
27
23
  };
28
24
 
29
25
  export { createI18nContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheet-i18n/react-client",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
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",
@@ -27,14 +27,14 @@
27
27
  "dependencies": {
28
28
  "react": "^19.0.0",
29
29
  "react-intl": "^7.0.4",
30
- "@sheet-i18n/react-core": "0.2.1",
31
- "@sheet-i18n/shared-utils": "1.1.1",
32
- "@sheet-i18n/errors": "1.1.1"
30
+ "@sheet-i18n/shared-utils": "1.1.2",
31
+ "@sheet-i18n/react-core": "0.2.2",
32
+ "@sheet-i18n/errors": "1.1.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/react": "^19.0.2",
36
36
  "@types/react-dom": "^19.0.2",
37
- "@sheet-i18n/typescript-config": "1.1.1"
37
+ "@sheet-i18n/typescript-config": "1.1.2"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsup",