gt-react 10.12.1 → 10.14.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 (41) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/browser-types.d.ts +5 -62
  3. package/dist/browser-types.d.ts.map +1 -1
  4. package/dist/browser.cjs.min.cjs +2 -2
  5. package/dist/browser.cjs.min.cjs.map +1 -1
  6. package/dist/browser.d.ts +6 -126
  7. package/dist/browser.d.ts.map +1 -1
  8. package/dist/browser.esm.min.mjs +5 -5
  9. package/dist/browser.esm.min.mjs.map +1 -1
  10. package/dist/client.cjs.min.cjs +1 -1
  11. package/dist/client.cjs.min.cjs.map +1 -1
  12. package/dist/client.d.ts +2 -2
  13. package/dist/client.d.ts.map +1 -1
  14. package/dist/client.esm.min.mjs +2 -2
  15. package/dist/client.esm.min.mjs.map +1 -1
  16. package/dist/i18n-context/functions/translation/t.d.ts +5 -2
  17. package/dist/i18n-context/functions/translation/t.d.ts.map +1 -1
  18. package/dist/i18n-context/functions/translation/types.d.ts +21 -0
  19. package/dist/i18n-context/functions/translation/types.d.ts.map +1 -0
  20. package/dist/i18n-context/functions/versionId.d.ts +10 -0
  21. package/dist/i18n-context/functions/versionId.d.ts.map +1 -0
  22. package/dist/index.cjs.min.cjs +5 -5
  23. package/dist/index.cjs.min.cjs.map +1 -1
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.esm.min.mjs +1 -1
  27. package/dist/index.esm.min.mjs.map +1 -1
  28. package/dist/internal.cjs.min.cjs +1 -1
  29. package/dist/internal.cjs.min.cjs.map +1 -1
  30. package/dist/internal.esm.min.mjs +1 -1
  31. package/dist/internal.esm.min.mjs.map +1 -1
  32. package/dist/macros.cjs.min.cjs +19 -0
  33. package/dist/macros.cjs.min.cjs.map +1 -0
  34. package/dist/macros.d.ts +22 -0
  35. package/dist/macros.d.ts.map +1 -0
  36. package/dist/macros.esm.min.mjs +19 -0
  37. package/dist/macros.esm.min.mjs.map +1 -0
  38. package/dist/react-context/provider/ClientProvider.d.ts.map +1 -1
  39. package/dist/shared/messages.d.ts +1 -1
  40. package/dist/shared/messages.d.ts.map +1 -1
  41. package/package.json +16 -5
package/dist/browser.d.ts CHANGED
@@ -1,126 +1,6 @@
1
- import { GTConfig, TranslationsLoader } from 'gt-i18n/internal/types';
2
- import { SyncResolutionFunction } from 'gt-i18n/types';
3
- import React from 'react';
4
- import { CustomMapping } from 'generaltranslation/types';
5
-
6
- /**
7
- * Type for custom getLocale function
8
- */
9
- type GetLocale = () => string;
10
-
11
- /**
12
- * Parameters for the initializing GT
13
- * @param {string} params.defaultLocale - The default locale to use
14
- * @param {string[]} params.locales - The locales to support
15
- * @param {GetLocale} params.getLocale - The function to get the locale
16
- * @param {TranslationsLoader} params.loadTranslations - The custom translation loader to use
17
- */
18
- type InitializeGTParams = GTConfig & {
19
- loadTranslations?: TranslationsLoader;
20
- getLocale?: GetLocale;
21
- };
22
-
23
- /**
24
- * Initialization function for react-core library invoked to enable synchronous resolution
25
- * @param {InitializeGTParams} params - The parameters for the initialization
26
- * @returns {Promise<void>} A promise that resolves when the bootstrap is complete
27
- *
28
- * @example
29
- * import gtConfig from '../gt.config.json';
30
- *
31
- * function getTranslations(locale: string) {
32
- * return import(`./_gt/${locale}.json`);
33
- * }
34
- *
35
- * await bootstrap({
36
- * ...gtConfig,
37
- * getTranslations,
38
- * });
39
- *
40
- * await import('./main.tsx')
41
- */
42
- declare function bootstrap(params: InitializeGTParams): Promise<void>;
43
-
44
- /**
45
- * Configure GT for browser runtime. This must be called to setup GT for browser runtime.
46
- * @param {InitializeGTParams} config - The configuration for the GT instance
47
- */
48
- declare function initializeGT(params: InitializeGTParams): void;
49
-
50
- /**
51
- * Returns the user's current locale.
52
- * @returns {string} The user's current locale.
53
- *
54
- * @example
55
- * const locale = getLocale();
56
- * console.log(locale); // 'en-US'
57
- */
58
- declare function getLocale(): string;
59
- /**
60
- * Returns the locales that are supported by the application.
61
- * @returns {string[]} The locales that are supported by the application.
62
- *
63
- * @example
64
- * const locales = getLocales();
65
- * console.log(locales); // ['en-US', 'es-ES']
66
- */
67
- declare function getLocales(): string[];
68
- /**
69
- * Returns the user's current locales.
70
- * @returns {string[]} The user's current locales.
71
- *
72
- * @note This function causes a page reload
73
- *
74
- * @example
75
- * const locales = getLocales();
76
- * console.log(locales); // ['en-US', 'es-ES']
77
- */
78
- declare function setLocale(locale: string): void;
79
- /**
80
- * Returns the user's current default locale.
81
- * @returns {string} The user's current default locale.
82
- *
83
- * @example
84
- * const defaultLocale = getDefaultLocale();
85
- * console.log(defaultLocale); // 'en-US'
86
- */
87
- declare function getDefaultLocale(): string;
88
-
89
- /**
90
- * NOTE: t() is the only function exported from the 'gt-react' entry point.
91
- * All other functions in i18n-context are exported from the 'gt-react/browser' entry point.
92
- */
93
- /**
94
- * Translate a message
95
- * @param {string} message - The message to translate.
96
- * @param {InlineTranslationOptions} [options] - The options for the translation.
97
- * @returns {string} The translated message.
98
- *
99
- * This is a BROWSER ONLY function.
100
- *
101
- * @example
102
- * t('Hello, world!'); // Translates 'Hello, world!'
103
- *
104
- * @example
105
- * t('Hello, {name}!', { name: 'John' }); // Translates 'Hello, John!'
106
- *
107
- */
108
- declare const t: SyncResolutionFunction;
109
-
110
- /**
111
- * A dropdown component that allows users to select a locale.
112
- * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.
113
- * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.
114
- * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.
115
- * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.
116
- */
117
- declare function LocaleSelector({ locales, ...props }: {
118
- locales?: string[];
119
- customNames?: {
120
- [key: string]: string;
121
- };
122
- customMapping?: CustomMapping;
123
- [key: string]: any;
124
- }): React.JSX.Element | null;
125
-
126
- export { LocaleSelector, bootstrap, getDefaultLocale, getLocale, getLocales, initializeGT, setLocale, t };
1
+ export * from './i18n-context/setup/index';
2
+ export * from './i18n-context/functions/locale-operations';
3
+ export * from './i18n-context/functions/versionId';
4
+ export { t } from './i18n-context/functions/translation/t';
5
+ export { LocaleSelector } from './i18n-context/ui/LocaleSelector';
6
+ //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAMA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4CAA4C,CAAC;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,wCAAwC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAMA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oCAAoC,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,wCAAwC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}