gt-react 8.2.22 → 8.2.24

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 (117) hide show
  1. package/README.md +76 -9
  2. package/dist/branches/Branch.js +4 -4
  3. package/dist/branches/Branch.js.map +1 -1
  4. package/dist/branches/plurals/Plural.js +10 -10
  5. package/dist/branches/plurals/Plural.js.map +1 -1
  6. package/dist/branches/plurals/getPluralBranch.js +3 -3
  7. package/dist/branches/plurals/getPluralBranch.js.map +1 -1
  8. package/dist/client.cjs.min.cjs +19 -0
  9. package/dist/client.cjs.min.cjs.map +1 -0
  10. package/dist/client.d.ts +484 -5
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.esm.min.mjs +19 -0
  13. package/dist/client.esm.min.mjs.map +1 -0
  14. package/dist/client.js +3 -3
  15. package/dist/client.js.map +1 -1
  16. package/dist/hooks/useBrowserLocale.d.ts.map +1 -1
  17. package/dist/hooks/useBrowserLocale.js +8 -10
  18. package/dist/hooks/useBrowserLocale.js.map +1 -1
  19. package/dist/hooks/useDefaultLocale.js +1 -1
  20. package/dist/hooks/useDefaultLocale.js.map +1 -1
  21. package/dist/hooks/useElement.js +11 -14
  22. package/dist/hooks/useElement.js.map +1 -1
  23. package/dist/hooks/useGT.js +9 -12
  24. package/dist/hooks/useGT.js.map +1 -1
  25. package/dist/hooks/useLocale.js +1 -1
  26. package/dist/hooks/useLocale.js.map +1 -1
  27. package/dist/index.cjs.min.cjs +19 -0
  28. package/dist/index.cjs.min.cjs.map +1 -0
  29. package/dist/index.esm.min.mjs +19 -0
  30. package/dist/index.esm.min.mjs.map +1 -0
  31. package/dist/index.js +12 -12
  32. package/dist/index.js.map +1 -1
  33. package/dist/inline/T.d.ts +1 -1
  34. package/dist/inline/T.d.ts.map +1 -1
  35. package/dist/inline/T.js +38 -51
  36. package/dist/inline/T.js.map +1 -1
  37. package/dist/internal/addGTIdentifier.js +18 -32
  38. package/dist/internal/addGTIdentifier.js.map +1 -1
  39. package/dist/internal/flattenDictionary.js +8 -11
  40. package/dist/internal/flattenDictionary.js.map +1 -1
  41. package/dist/internal/writeChildrenAsObjects.js +22 -35
  42. package/dist/internal/writeChildrenAsObjects.js.map +1 -1
  43. package/dist/internal.cjs.min.cjs +2 -0
  44. package/dist/internal.cjs.min.cjs.map +1 -0
  45. package/dist/internal.d.ts +16 -17
  46. package/dist/internal.d.ts.map +1 -1
  47. package/dist/internal.esm.min.mjs +2 -0
  48. package/dist/internal.esm.min.mjs.map +1 -0
  49. package/dist/internal.js +15 -15
  50. package/dist/internal.js.map +1 -1
  51. package/dist/messages/createMessages.js +16 -38
  52. package/dist/messages/createMessages.js.map +1 -1
  53. package/dist/provider/ClientProvider.d.ts +23 -0
  54. package/dist/provider/ClientProvider.d.ts.map +1 -0
  55. package/dist/provider/GTContext.d.ts +1 -1
  56. package/dist/provider/GTContext.d.ts.map +1 -1
  57. package/dist/provider/GTContext.js +3 -4
  58. package/dist/provider/GTContext.js.map +1 -1
  59. package/dist/provider/GTProvider.d.ts +2 -2
  60. package/dist/provider/GTProvider.d.ts.map +1 -1
  61. package/dist/provider/GTProvider.js +95 -146
  62. package/dist/provider/GTProvider.js.map +1 -1
  63. package/dist/provider/helpers/extractEntryMetadata.d.ts +3 -3
  64. package/dist/provider/helpers/extractEntryMetadata.d.ts.map +1 -1
  65. package/dist/provider/helpers/getDictionaryEntry.js +5 -6
  66. package/dist/provider/helpers/getDictionaryEntry.js.map +1 -1
  67. package/dist/provider/helpers/isVariableObject.js +2 -2
  68. package/dist/provider/helpers/isVariableObject.js.map +1 -1
  69. package/dist/provider/rendering/defaultRenderSettings.js +2 -13
  70. package/dist/provider/rendering/defaultRenderSettings.js.map +1 -1
  71. package/dist/provider/rendering/renderDefaultChildren.d.ts +2 -2
  72. package/dist/provider/rendering/renderDefaultChildren.js +32 -44
  73. package/dist/provider/rendering/renderDefaultChildren.js.map +1 -1
  74. package/dist/provider/rendering/renderTranslatedChildren.js +97 -110
  75. package/dist/provider/rendering/renderTranslatedChildren.js.map +1 -1
  76. package/dist/provider/rendering/renderVariable.js +6 -7
  77. package/dist/provider/rendering/renderVariable.js.map +1 -1
  78. package/dist/provider/runtime/useRuntimeTranslation.d.ts +1 -1
  79. package/dist/provider/runtime/useRuntimeTranslation.d.ts.map +1 -1
  80. package/dist/provider/runtime/useRuntimeTranslation.js +171 -239
  81. package/dist/provider/runtime/useRuntimeTranslation.js.map +1 -1
  82. package/dist/types/types.d.ts +22 -8
  83. package/dist/types/types.d.ts.map +1 -1
  84. package/dist/utils/utils.js +5 -5
  85. package/dist/utils/utils.js.map +1 -1
  86. package/dist/variables/Currency.js +11 -23
  87. package/dist/variables/Currency.js.map +1 -1
  88. package/dist/variables/DateTime.js +10 -11
  89. package/dist/variables/DateTime.js.map +1 -1
  90. package/dist/variables/Num.js +9 -10
  91. package/dist/variables/Num.js.map +1 -1
  92. package/dist/variables/Var.js +3 -4
  93. package/dist/variables/Var.js.map +1 -1
  94. package/dist/variables/_getVariableProps.js +7 -18
  95. package/dist/variables/_getVariableProps.js.map +1 -1
  96. package/dist/variables/getVariableName.js +5 -7
  97. package/dist/variables/getVariableName.js.map +1 -1
  98. package/package.json +31 -14
  99. package/rollup.base.config.js +33 -0
  100. package/rollup.config.js +111 -0
  101. package/tsconfig.json +3 -2
  102. package/dist/errors/createErrors.d.ts +0 -13
  103. package/dist/errors/createErrors.d.ts.map +0 -1
  104. package/dist/errors/createErrors.js +0 -28
  105. package/dist/errors/createErrors.js.map +0 -1
  106. package/dist/provider/dynamic/useDynamicTranslation.d.ts +0 -28
  107. package/dist/provider/dynamic/useDynamicTranslation.d.ts.map +0 -1
  108. package/dist/provider/dynamic/useDynamicTranslation.js +0 -194
  109. package/dist/provider/dynamic/useDynamicTranslation.js.map +0 -1
  110. package/dist/provider/dynamic/useRuntimeTranslation.d.ts +0 -28
  111. package/dist/provider/dynamic/useRuntimeTranslation.d.ts.map +0 -1
  112. package/dist/provider/dynamic/useRuntimeTranslation.js +0 -194
  113. package/dist/provider/dynamic/useRuntimeTranslation.js.map +0 -1
  114. package/dist/translate/translateDictionaryStrings.d.ts +0 -3
  115. package/dist/translate/translateDictionaryStrings.d.ts.map +0 -1
  116. package/dist/translate/translateDictionaryStrings.js +0 -97
  117. package/dist/translate/translateDictionaryStrings.js.map +0 -1
package/dist/client.d.ts CHANGED
@@ -1,5 +1,484 @@
1
- import { GTContext } from "./provider/GTContext";
2
- import useBrowserLocale from "./hooks/useBrowserLocale";
3
- import useRuntimeTranslation from "./provider/runtime/useRuntimeTranslation";
4
- export { GTContext, useBrowserLocale, useRuntimeTranslation };
5
- //# sourceMappingURL=client.d.ts.map
1
+ import * as React$1 from 'react';
2
+ import React__default, { ReactElement } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type Child = React__default.ReactNode;
6
+ type Children = Child[] | Child;
7
+ type GTProp = {
8
+ id: number;
9
+ transformation?: string;
10
+ children?: Children;
11
+ } & Record<string, any>;
12
+ type TaggedChild = React__default.ReactNode | TaggedElement;
13
+ type TaggedChildren = TaggedChild[] | TaggedChild;
14
+ type TaggedElementProps = Record<string, any> & {
15
+ 'data-_gt': GTProp;
16
+ };
17
+ type TaggedElement = React__default.ReactElement<TaggedElementProps>;
18
+ type TaggedEntry = string | TaggedChildren;
19
+ type TaggedDictionaryEntry = TaggedEntry | [TaggedEntry] | [TaggedEntry, Metadata];
20
+ type FlattenedTaggedDictionary = {
21
+ [key: string]: TaggedDictionaryEntry;
22
+ };
23
+ type Entry = string | ReactElement;
24
+ type Metadata = {
25
+ singular?: Entry;
26
+ plural?: Entry;
27
+ zero?: Entry;
28
+ dual?: Entry;
29
+ one?: Entry;
30
+ two?: Entry;
31
+ few?: Entry;
32
+ many?: Entry;
33
+ other?: Entry;
34
+ context?: string;
35
+ variablesOptions?: Record<string, any>;
36
+ [key: string]: any;
37
+ };
38
+ type Variable = {
39
+ key: string;
40
+ id?: number;
41
+ variable?: 'variable' | 'number' | 'datetime' | 'currency';
42
+ };
43
+ type TranslatedElement = {
44
+ type: string;
45
+ props: {
46
+ 'data-_gt': {
47
+ id: number;
48
+ [key: string]: any;
49
+ };
50
+ children?: TranslatedChildren;
51
+ };
52
+ };
53
+ type TranslatedChild = TranslatedElement | string | Variable;
54
+ type TranslatedChildren = TranslatedChild | TranslatedChild[];
55
+ type TranslatedContent = string | (string | Variable)[];
56
+ type TranslationError = {
57
+ state: 'error';
58
+ error: string;
59
+ code?: number;
60
+ };
61
+ type TranslationSuccess = {
62
+ state: 'success';
63
+ target: TranslatedChildren | TranslatedContent;
64
+ };
65
+ type TranslationLoading = {
66
+ state: 'loading';
67
+ };
68
+ type TranslationsObject = {
69
+ [id: string]: {
70
+ [hash: string]: TranslationSuccess | TranslationLoading | TranslationError;
71
+ };
72
+ };
73
+ type RenderMethod = 'skeleton' | 'replace' | 'default';
74
+ type TranslateContentCallback = (params: {
75
+ source: any;
76
+ targetLocale: string;
77
+ metadata: {
78
+ hash: string;
79
+ context?: string;
80
+ } & Record<string, any>;
81
+ }) => Promise<void>;
82
+ type TranslateChildrenCallback = (params: {
83
+ source: any;
84
+ targetLocale: string;
85
+ metadata: {
86
+ hash: string;
87
+ context?: string;
88
+ } & Record<string, any>;
89
+ }) => Promise<void>;
90
+ type GTContextType = {
91
+ translateDictionaryEntry: (id: string, options?: Record<string, any>) => React__default.ReactNode;
92
+ translateContent: TranslateContentCallback;
93
+ translateChildren: TranslateChildrenCallback;
94
+ locale: string;
95
+ defaultLocale: string;
96
+ translations: TranslationsObject | null;
97
+ translationRequired: boolean;
98
+ dialectTranslationRequired: boolean;
99
+ renderSettings: {
100
+ method: RenderMethod;
101
+ timeout?: number;
102
+ };
103
+ projectId?: string;
104
+ translationEnabled?: boolean;
105
+ };
106
+
107
+ declare const GTContext: React$1.Context<GTContextType | undefined>;
108
+
109
+ /**
110
+ * Hook to retrieve the browser's default locale, with support for a fallback and locale stored in a cookie.
111
+ *
112
+ * @param {string} [defaultLocale=libraryDefaultLocale] - The default locale to use if the browser locale is not available.
113
+ * @param {string} [cookieName=localeCookieName] - The name of the cookie to check for a stored locale. If omitted, no cookie is used.
114
+ * @returns {string} The resolved browser locale, either from the cookie, browser settings, or the default locale.
115
+ *
116
+ * @example
117
+ * const browserLocale = useBrowserLocale('en-US');
118
+ * console.log(browserLocale); // Outputs the browser's locale, or 'en-US' if unavailable
119
+ *
120
+ * @example
121
+ * const browserLocale = useBrowserLocale('fr', 'localeCookie');
122
+ * console.log(browserLocale); // Outputs locale from cookie 'localeCookie' if available, or browser's locale otherwise
123
+ *
124
+ * @description
125
+ * This hook attempts to determine the browser's preferred locale. If a locale is stored in a cookie (specified by `cookieName`),
126
+ * it will take precedence. If not, it falls back to the `navigator.language` or `navigator.userLanguage`. If none of these are available,
127
+ * the provided `defaultLocale` is used.
128
+ */
129
+ declare function useBrowserLocale(defaultLocale?: string, locales?: string[]): string;
130
+
131
+ declare function useRuntimeTranslation({ targetLocale, projectId, devApiKey, runtimeUrl, defaultLocale, renderSettings, setTranslations, ...metadata }: {
132
+ targetLocale: string;
133
+ projectId?: string;
134
+ defaultLocale?: string;
135
+ devApiKey?: string;
136
+ runtimeUrl?: string;
137
+ renderSettings: {
138
+ method: RenderMethod;
139
+ timeout?: number;
140
+ };
141
+ setTranslations: React.Dispatch<React.SetStateAction<any>>;
142
+ [key: string]: any;
143
+ }): {
144
+ translationEnabled: boolean;
145
+ translateContent: TranslateContentCallback;
146
+ translateChildren: TranslateChildrenCallback;
147
+ };
148
+
149
+ declare function renderVariable({ variableType, variableName, variableValue, variableOptions, locales, }: {
150
+ variableType: "variable" | "number" | "datetime" | "currency";
151
+ variableName: string;
152
+ variableValue: any;
153
+ variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
154
+ locales: string[];
155
+ }): React.JSX.Element;
156
+
157
+ declare function ClientProvider({ children, dictionary, initialTranslations, translationPromises, locale, defaultLocale, translationRequired, dialectTranslationRequired, locales, requiredPrefix, renderSettings, projectId, devApiKey, runtimeUrl, runtimeTranslations, }: {
158
+ children: any;
159
+ dictionary: FlattenedTaggedDictionary;
160
+ initialTranslations: TranslationsObject;
161
+ translationPromises: Record<string, Promise<TranslatedChildren>>;
162
+ locale: string;
163
+ locales: string[];
164
+ defaultLocale: string;
165
+ translationRequired: boolean;
166
+ dialectTranslationRequired: boolean;
167
+ requiredPrefix: string | undefined;
168
+ renderSettings: {
169
+ method: RenderMethod;
170
+ timeout?: number;
171
+ };
172
+ projectId?: string;
173
+ devApiKey?: string;
174
+ runtimeUrl?: string;
175
+ runtimeTranslations?: boolean;
176
+ }): React__default.JSX.Element;
177
+
178
+ /**
179
+ * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.
180
+ * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).
181
+ * If the specified `branch` is present in the `branches` object, it renders the content of that branch.
182
+ * If the `branch` is not found, it renders the provided `children` as fallback content.
183
+ *
184
+ * @example
185
+ * ```jsx
186
+ * <Branch branch="summary" summary={<p>This is a summary</p>} details={<p>Details here</p>}>
187
+ * <p>Fallback content</p>
188
+ * </Branch>
189
+ * ```
190
+ * If the `branch` prop is set to `"summary"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.
191
+ *
192
+ * @param {any} [children] - Fallback content to render if no matching branch is found.
193
+ * @param {string} [name="branch"] - Optional name for the component, used for metadata or tracking purposes.
194
+ * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.
195
+ * @param {object} [branches] - An object containing possible branches as keys and their corresponding content as values.
196
+ * @returns {JSX.Element} The rendered branch or fallback content.
197
+ */
198
+ declare function Branch({ children, name, branch, ...props }: {
199
+ children?: any;
200
+ name?: string;
201
+ branch?: string;
202
+ [key: string]: any;
203
+ }): react_jsx_runtime.JSX.Element;
204
+ declare namespace Branch {
205
+ var gtTransformation: string;
206
+ }
207
+
208
+ /**
209
+ * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
210
+ * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
211
+ * based on the current locale or a default locale. If no matching plural branch is found, the component renders
212
+ * the fallback `children` content.
213
+ *
214
+ * @example
215
+ * ```jsx
216
+ * <Plural n={1} one="There is 1 item">
217
+ * There are {n} items
218
+ * </Plural>
219
+ * ```
220
+ * In this example, if `n` is 1, it renders `"There is 1 item"`. If `n` is a different number, it renders
221
+ * `"There are {n} items"`.
222
+ *
223
+ * @param {any} [children] - Fallback content to render if no matching plural branch is found.
224
+ * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
225
+ * @returns {JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
226
+ * @throws {Error} If `n` is not provided or not a valid number.
227
+ */
228
+ declare function Plural({ children, n, ...props }: {
229
+ children?: any;
230
+ n?: number;
231
+ [key: string]: any;
232
+ }): react_jsx_runtime.JSX.Element;
233
+ declare namespace Plural {
234
+ var gtTransformation: string;
235
+ }
236
+
237
+ /**
238
+ * Retrieves the application's default locale from the `<GTProvider>` context.
239
+ *
240
+ * If no default locale is passed to the `<GTProvider>`, it defaults to providing 'en'.
241
+ *
242
+ * @returns {string} The application's default locale, e.g., 'en-US'.
243
+ *
244
+ * @example
245
+ * const locale = useDefaultLocale();
246
+ * console.log(locale); // 'en-US'
247
+ */
248
+ declare function useDefaultLocale(): string;
249
+
250
+ /**
251
+ * `useElement()` hook which gets the translation function `t()` provided by `<GTProvider>`.
252
+ *
253
+ * **`t()` returns only JSX elements.** For returning strings as well, see `useGT()`.
254
+ *
255
+ * @param {string} [id] - Optional prefix to prepend to the translation keys.
256
+ * @returns {Function} A translation function that accepts a key string and returns the translated value.
257
+ *
258
+ * @example
259
+ * const t = useElement('user');
260
+ * console.log(t('name')); // Translates item 'user.name', returns it as a JSX element
261
+ *
262
+ * const t = useElement();
263
+ * console.log(t('hello')); // Translates item 'hello', returns it as a JSX element
264
+ */
265
+ declare function useElement(id?: string): (id: string, options?: Record<string, any>) => React__default.JSX.Element;
266
+
267
+ /**
268
+ * Gets the translation function `t` provided by `<GTProvider>`.
269
+ *
270
+ * @param {string} [id] - Optional prefix to prepend to the translation keys.
271
+ * @returns {Function} A translation function that accepts a key string and returns the translated value.
272
+ *
273
+ * @example
274
+ * const t = useGT('user');
275
+ * console.log(t('name')); // Translates item 'user.name'
276
+ *
277
+ * const t = useGT();
278
+ * console.log(t('hello')); // Translates item 'hello'
279
+ */
280
+ declare function useGT(id?: string): (id: string, options?: Record<string, any>) => React__default.ReactNode;
281
+
282
+ /**
283
+ * Retrieves the user's locale from the `<GTProvider>` context.
284
+ *
285
+ * @returns {string} The user's locale, e.g., 'en-US'.
286
+ *
287
+ * @example
288
+ * const locale = useLocale();
289
+ * console.log(locale); // 'en-US'
290
+ */
291
+ declare function useLocale(): string;
292
+
293
+ /**
294
+ * Translation component that handles rendering translated content, including plural forms.
295
+ * Used with the required `id` parameter instead of `const t = useGT()`.
296
+ *
297
+ * @param {string} [id] - Required identifier for the translation string.
298
+ * @param {React.ReactNode} children - The content to be translated or displayed.
299
+ * @param {any} [context] - Additional context used for translation.
300
+ * @param {Object} [props] - Additional props for the component.
301
+ * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.
302
+ *
303
+ * @throws {Error} If a plural translation is requested but the `n` option is not provided.
304
+ *
305
+ * @example
306
+ * ```jsx
307
+ * // Basic usage:
308
+ * <T id="welcome_message">
309
+ * Hello, <Var name="name">{name}</Var>!
310
+ * </T>
311
+ * ```
312
+ *
313
+ * @example
314
+ * ```jsx
315
+ * // Using plural translations:
316
+ * <T id="item_count">
317
+ * <Plural n={n} singular={<>You have <Num value={n}/> item</>}>
318
+ * You have <Num value={n}/> items
319
+ * </Plural>
320
+ * </T>
321
+ * ```
322
+ *
323
+ */
324
+ declare function T({ children, id, ...props }: {
325
+ children: any;
326
+ id: string;
327
+ context?: string;
328
+ [key: string]: any;
329
+ }): React__default.JSX.Element | undefined;
330
+ declare namespace T {
331
+ var gtTransformation: string;
332
+ }
333
+
334
+ /**
335
+ * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.
336
+ * Must be used inside a `<GTProvider>`.
337
+ *
338
+ * @example
339
+ * ```jsx
340
+ * <Currency
341
+ * name="price"
342
+ * currency="USD"
343
+ * >
344
+ * 1000
345
+ * </Currency>
346
+ * ```
347
+ *
348
+ * @param {any} [children] - Optional content to render inside the currency component.
349
+ * @param {string} [name] - Optional name for the currency field.
350
+ * @param {any} [value] - The default value to be used.
351
+ * @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).
352
+ * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.
353
+ * @returns {JSX.Element} The formatted currency component.
354
+ */
355
+ declare function Currency({ children, value, name, currency, locales, options, }: {
356
+ children?: any;
357
+ name?: string;
358
+ value?: any;
359
+ currency?: string;
360
+ locales?: string[];
361
+ options?: Intl.NumberFormatOptions;
362
+ }): React__default.JSX.Element;
363
+ declare namespace Currency {
364
+ var gtTransformation: string;
365
+ }
366
+
367
+ /**
368
+ * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.
369
+ * It utilizes the current locale and optional format settings to display the date.
370
+ * Must be used inside a `<GTProvider>`.
371
+ *
372
+ * @example
373
+ * ```jsx
374
+ * <DateTime
375
+ * name="createdAt"
376
+ * >
377
+ * {new Date()}
378
+ * </DateTime>
379
+ * ```
380
+ *
381
+ * @param {any} [children] - Optional content (typically a date) to render inside the component.
382
+ * @param {string} [name="date"] - Optional name for the date field, used for metadata purposes.
383
+ * @param {string|number|Date} [value] - The default value for the date. Can be a string, number (timestamp), or `Date` object.
384
+ * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
385
+ * @returns {JSX.Element} The formatted date or time component.
386
+ */
387
+ declare function DateTime({ children, value, name, locales, options, }: {
388
+ children?: any;
389
+ name?: string;
390
+ value?: any;
391
+ locales?: string[];
392
+ options?: Intl.DateTimeFormatOptions;
393
+ }): React__default.JSX.Element;
394
+ declare namespace DateTime {
395
+ var gtTransformation: string;
396
+ }
397
+
398
+ /**
399
+ * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.
400
+ * It formats the number according to the current locale and optionally passed formatting options.
401
+ * Must be used inside a `<GTProvider>`.
402
+ *
403
+ * @example
404
+ * ```jsx
405
+ * <Num
406
+ * name="quantity"
407
+ * options={{ style: "decimal", maximumFractionDigits: 2 }}
408
+ * >
409
+ * 1000
410
+ * </Num>
411
+ * ```
412
+ *
413
+ * @param {any} [children] - Optional content (typically a number) to render inside the component.
414
+ * @param {string} [name="n"] - Optional name for the number field, used for metadata purposes.
415
+ * @param {string|number} [value] - The default value for the number. Can be a string or number. Strings will be parsed to numbers.
416
+ * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
417
+ * @returns {JSX.Element} The formatted number component.
418
+ */
419
+ declare function Num({ children, value, name, locales, options, }: {
420
+ children?: any;
421
+ name?: string;
422
+ value?: any;
423
+ locales?: string[];
424
+ options?: Intl.NumberFormatOptions;
425
+ }): React__default.JSX.Element;
426
+ declare namespace Num {
427
+ var gtTransformation: string;
428
+ }
429
+
430
+ /**
431
+ * The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.
432
+ * If `children` is provided, it will be used; otherwise, the `value` is rendered.
433
+ *
434
+ * @example Inline usage:
435
+ * ```jsx
436
+ * function MyComponent() {
437
+ * return (
438
+ * <T id="user">
439
+ * <p>
440
+ * Hello, <Var> John </Var>!
441
+ * </p>
442
+ * </T>
443
+ * );
444
+ * }
445
+ * ```
446
+ *
447
+ * @example Dictionary Usage:
448
+ * ```jsx
449
+ * // dictionary.jsx
450
+ * const dictionary = {
451
+ * user: (
452
+ * <>
453
+ * Hello, <Var name="user-name" />! Your dog's name is <Var name="dog-name"/>.
454
+ * </>
455
+ * ),
456
+ * }
457
+ *
458
+ * // component.jsx
459
+ * function MyComponent() {
460
+ * const t = useGT();
461
+ * return (
462
+ * <p>
463
+ * { t('user', { 'user-name': 'John', 'dog-name': 'Rex' }) }
464
+ * </p>
465
+ * );
466
+ * }
467
+ * ```
468
+ *
469
+ *
470
+ * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.
471
+ * @param {string} [name] - Optional name for the variable, used for metadata purposes.
472
+ * @param {any} [value] - The default value to be displayed if `children` is not provided.
473
+ * @returns {JSX.Element} The rendered variable component with either `children` or `value`.
474
+ */
475
+ declare function Var({ children, name, value, }: {
476
+ children?: any;
477
+ name?: string;
478
+ value?: any;
479
+ }): React__default.JSX.Element;
480
+ declare namespace Var {
481
+ var gtTransformation: string;
482
+ }
483
+
484
+ export { Branch, ClientProvider, Currency, DateTime, GTContext, Num, Plural, T, Var, renderVariable, useBrowserLocale, useDefaultLocale, useElement, useGT, useLocale, useRuntimeTranslation };
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,qBAAqB,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,qBAAqB,MAAM,0CAA0C,CAAC;AAC7E,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,CAAC,MAAM,YAAY,CAAC;AAC3B,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,KAAK,EACL,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,CAAC,EACD,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,GACP,CAAC"}