gt-react 9.2.8 → 9.2.10-alpha.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 (36) hide show
  1. package/dist/branches/Branch.d.ts +8 -4
  2. package/dist/branches/Branch.d.ts.map +1 -1
  3. package/dist/branches/plurals/Plural.d.ts +9 -5
  4. package/dist/branches/plurals/Plural.d.ts.map +1 -1
  5. package/dist/client.cjs.min.cjs +3 -3
  6. package/dist/client.d.ts +36 -64
  7. package/dist/client.esm.min.mjs +3 -3
  8. package/dist/index.cjs.min.cjs +3 -3
  9. package/dist/index.esm.min.mjs +3 -3
  10. package/dist/internal/addGTIdentifier.d.ts.map +1 -1
  11. package/dist/internal.cjs.min.cjs +1 -1
  12. package/dist/internal.d.ts +3 -3
  13. package/dist/internal.d.ts.map +1 -1
  14. package/dist/internal.esm.min.mjs +1 -1
  15. package/dist/provider/rendering/renderDefaultChildren.d.ts +3 -10
  16. package/dist/provider/rendering/renderDefaultChildren.d.ts.map +1 -1
  17. package/dist/provider/rendering/renderTranslatedChildren.d.ts +4 -12
  18. package/dist/provider/rendering/renderTranslatedChildren.d.ts.map +1 -1
  19. package/dist/provider/rendering/renderVariable.d.ts +3 -7
  20. package/dist/provider/rendering/renderVariable.d.ts.map +1 -1
  21. package/dist/types/types.d.ts +9 -0
  22. package/dist/types/types.d.ts.map +1 -1
  23. package/dist/utils/utils.d.ts.map +1 -1
  24. package/dist/variables/Currency.d.ts +2 -9
  25. package/dist/variables/Currency.d.ts.map +1 -1
  26. package/dist/variables/DateTime.d.ts +2 -8
  27. package/dist/variables/DateTime.d.ts.map +1 -1
  28. package/dist/variables/Num.d.ts +1 -6
  29. package/dist/variables/Num.d.ts.map +1 -1
  30. package/dist/variables/Var.d.ts +4 -25
  31. package/dist/variables/Var.d.ts.map +1 -1
  32. package/dist/variables/_getVariableProps.d.ts +2 -6
  33. package/dist/variables/_getVariableProps.d.ts.map +1 -1
  34. package/dist/variables/getVariableName.d.ts +0 -1
  35. package/dist/variables/getVariableName.d.ts.map +1 -1
  36. package/package.json +1 -1
package/dist/client.d.ts CHANGED
@@ -59,6 +59,15 @@ type InlineTranslationOptions = {
59
59
  context?: string;
60
60
  id?: string;
61
61
  } & DictionaryTranslationOptions;
62
+ type VariableProps = {
63
+ variableType: 'variable' | 'number' | 'datetime' | 'currency';
64
+ variableValue: any;
65
+ variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
66
+ variableName: string;
67
+ };
68
+ type RenderVariable = ({ variableType, variableValue, variableOptions, locales, }: Omit<VariableProps, 'variableName'> & {
69
+ locales: string[];
70
+ }) => React__default.JSX.Element;
62
71
 
63
72
  type TranslateContentCallback = (params: {
64
73
  source: any;
@@ -143,13 +152,7 @@ declare function useRuntimeTranslation({ projectId, devApiKey, locale, versionId
143
152
  registerJsxForTranslation: TranslateChildrenCallback;
144
153
  };
145
154
 
146
- declare function renderVariable({ variableType, variableName, variableValue, variableOptions, locales, }: {
147
- variableType: 'variable' | 'number' | 'datetime' | 'currency';
148
- variableName: string;
149
- variableValue: any;
150
- variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
151
- locales: string[];
152
- }): React.JSX.Element;
155
+ declare const renderVariable: RenderVariable;
153
156
 
154
157
  declare function ClientProvider({ children, dictionary, initialTranslations, dictionaryTranslations, locale: _locale, _versionId, defaultLocale, translationRequired, dialectTranslationRequired, locales, renderSettings, projectId, devApiKey, runtimeUrl, runtimeTranslationEnabled, onLocaleChange, cookieName, }: ClientProviderProps): React__default.JSX.Element;
155
158
 
@@ -161,7 +164,11 @@ declare function ClientProvider({ children, dictionary, initialTranslations, dic
161
164
  *
162
165
  * @example
163
166
  * ```jsx
164
- * <Branch branch="summary" summary={<p>This is a summary</p>} details={<p>Details here</p>}>
167
+ * <Branch
168
+ * branch="summary"
169
+ * summary={<p>This is a summary</p>}
170
+ * details={<p>Details here</p>}
171
+ * >
165
172
  * <p>Fallback content</p>
166
173
  * </Branch>
167
174
  * ```
@@ -170,10 +177,10 @@ declare function ClientProvider({ children, dictionary, initialTranslations, dic
170
177
  * @param {any} [children] - Fallback content to render if no matching branch is found.
171
178
  * @param {string} [name="branch"] - Optional name for the component, used for metadata or tracking purposes.
172
179
  * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.
173
- * @param {object} [branches] - An object containing possible branches as keys and their corresponding content as values.
174
- * @returns {JSX.Element} The rendered branch or fallback content.
180
+ * @param {...{[key: string]: any}} [branches] - A spread object containing possible branches as keys and their corresponding content as values.
181
+ * @returns {React.JSX.Element} The rendered branch or fallback content.
175
182
  */
176
- declare function Branch({ children, name, branch, ...props }: {
183
+ declare function Branch({ children, branch, ...branches }: {
177
184
  children?: any;
178
185
  name?: string;
179
186
  branch?: string;
@@ -191,9 +198,11 @@ declare namespace Branch {
191
198
  *
192
199
  * @example
193
200
  * ```jsx
194
- * <Plural n={1} one="There is 1 item">
195
- * There are {n} items
196
- * </Plural>
201
+ * <Plural
202
+ * n={1}
203
+ * one="There is 1 item"
204
+ * other="There are {n} items"
205
+ * />
197
206
  * ```
198
207
  * In this example, if `n` is 1, it renders `"There is 1 item"`. If `n` is a different number, it renders
199
208
  * `"There are {n} items"`.
@@ -203,10 +212,12 @@ declare namespace Branch {
203
212
  * @param {string} [locale] - Optional parameter, the locale to use for pluralization format. If not provided and wrapped
204
213
  * in <GTProvider> will automatically populate this value as user's current locale. If not provided and not wrapped in
205
214
  * <GTProvider>, will use the library default locale (en-US).
206
- * @returns {JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
215
+ * @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular
216
+ * and `other` for plural forms, but it may vary depending on the locale.
217
+ * @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
207
218
  * @throws {Error} If `n` is not provided or not a valid number.
208
219
  */
209
- declare function Plural({ children, n, locale, ...props }: {
220
+ declare function Plural({ children, n, locale, ...branches }: {
210
221
  children?: any;
211
222
  n?: number;
212
223
  locale?: string;
@@ -319,26 +330,19 @@ declare namespace T {
319
330
  *
320
331
  * @example
321
332
  * ```jsx
322
- * <Currency
323
- * name="price"
324
- * currency="USD"
325
- * >
333
+ * <Currency currency="USD">
326
334
  * 1000
327
335
  * </Currency>
328
336
  * ```
329
337
  *
330
338
  * @param {any} [children] - Optional content to render inside the currency component.
331
- * @param {string} [name] - Optional name for the currency field.
332
- * @param {any} [value] - The default value to be used.
333
339
  * @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).
334
340
  * @param {string[]} [locales] - Optional locales to use for currency formatting. If not provided, the library default locale (en-US) is used. If wrapped in a `<GTProvider>`, the user's locale is used.
335
341
  * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.
336
342
  * @returns {JSX.Element} The formatted currency component.
337
343
  */
338
- declare function Currency({ children, value, name, currency, locales, options, }: {
344
+ declare function Currency({ children, currency, locales, options, }: {
339
345
  children?: any;
340
- name?: string;
341
- value?: any;
342
346
  currency?: string;
343
347
  locales?: string[];
344
348
  options?: Intl.NumberFormatOptions;
@@ -354,24 +358,18 @@ declare namespace Currency {
354
358
  *
355
359
  * @example
356
360
  * ```jsx
357
- * <DateTime
358
- * name="createdAt"
359
- * >
361
+ * <DateTime>
360
362
  * {new Date()}
361
363
  * </DateTime>
362
364
  * ```
363
365
  *
364
366
  * @param {any} [children] - Optional content (typically a date) to render inside the component.
365
- * @param {string} [name="date"] - Optional name for the date field, used for metadata purposes.
366
- * @param {string|number|Date} [value] - The default value for the date. Can be a string, number (timestamp), or `Date` object.
367
367
  * @param {string[]} [locales] - Optional locales to use for date formatting. If not provided, the library default locale (en-US) is used. If wrapped in a `<GTProvider>`, the user's locale is used.
368
368
  * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
369
369
  * @returns {JSX.Element} The formatted date or time component.
370
370
  */
371
- declare function DateTime({ children, value, name, locales, options, }: {
371
+ declare function DateTime({ children, locales, options, }: {
372
372
  children?: any;
373
- name?: string;
374
- value?: any;
375
373
  locales?: string[];
376
374
  options?: Intl.DateTimeFormatOptions;
377
375
  }): React__default.JSX.Element;
@@ -387,7 +385,6 @@ declare namespace DateTime {
387
385
  * @example
388
386
  * ```jsx
389
387
  * <Num
390
- * name="quantity"
391
388
  * options={{ style: "decimal", maximumFractionDigits: 2 }}
392
389
  * >
393
390
  * 1000
@@ -395,15 +392,11 @@ declare namespace DateTime {
395
392
  * ```
396
393
  *
397
394
  * @param {any} [children] - Optional content (typically a number) to render inside the component.
398
- * @param {string} [name="n"] - Optional name for the number field, used for metadata purposes.
399
- * @param {string|number} [value] - The default value for the number. Can be a string or number. Strings will be parsed to numbers.
400
395
  * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
401
396
  * @returns {JSX.Element} The formatted number component.
402
397
  */
403
- declare function Num({ children, value, name, locales, options, }: {
398
+ declare function Num({ children, locales, options, }: {
404
399
  children?: any;
405
- name?: string;
406
- value?: any;
407
400
  locales?: string[];
408
401
  options?: Intl.NumberFormatOptions;
409
402
  }): React__default.JSX.Element;
@@ -418,44 +411,23 @@ declare namespace Num {
418
411
  * @example Inline usage:
419
412
  * ```jsx
420
413
  * function MyComponent() {
414
+ * const name = 'Archie';
421
415
  * return (
422
- * <T id="user">
416
+ * <T>
423
417
  * <p>
424
- * Hello, <Var> John </Var>!
418
+ * Hello, <Var> {name} </Var>!
425
419
  * </p>
426
420
  * </T>
427
421
  * );
428
422
  * }
429
423
  * ```
430
424
  *
431
- * @example Dictionary Usage:
432
- * ```jsx
433
- * // dictionary.js
434
- * const dictionary = {
435
- * user: "Hello {user-name}! Your dog's name is {dog-name}",
436
- * }
437
- *
438
- * // component.jsx
439
- * function MyComponent() {
440
- * const t = useGT();
441
- * return (
442
- * <p>
443
- * { t('user', { 'user-name': 'John', 'dog-name': 'Rex' }) }
444
- * </p>
445
- * );
446
- * }
447
- * ```
448
- *
449
425
  *
450
426
  * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.
451
- * @param {string} [name] - Optional name for the variable, used for metadata purposes.
452
- * @param {any} [value] - The default value to be displayed if `children` is not provided.
453
427
  * @returns {JSX.Element} The rendered variable component with either `children` or `value`.
454
428
  */
455
- declare function Var({ children, name, value, }: {
429
+ declare function Var({ children }: {
456
430
  children?: any;
457
- name?: string;
458
- value?: any;
459
431
  }): React__default.JSX.Element;
460
432
  declare namespace Var {
461
433
  var gtTransformation: string;