gt-next 5.2.37 → 5.2.39-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 (85) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/branches/Plural.d.ts +4 -4
  3. package/dist/branches/Plural.d.ts.map +1 -1
  4. package/dist/branches/Plural.js +7 -48
  5. package/dist/branches/Plural.js.map +1 -1
  6. package/dist/config-dir/DictionaryManager.js +2 -2
  7. package/dist/config-dir/DictionaryManager.js.map +1 -1
  8. package/dist/config-dir/I18NConfiguration.d.ts +1 -1
  9. package/dist/config-dir/I18NConfiguration.d.ts.map +1 -1
  10. package/dist/config-dir/I18NConfiguration.js +4 -5
  11. package/dist/config-dir/I18NConfiguration.js.map +1 -1
  12. package/dist/config-dir/TranslationManager.js +3 -3
  13. package/dist/config-dir/TranslationManager.js.map +1 -1
  14. package/dist/config.js +3 -3
  15. package/dist/config.js.map +1 -1
  16. package/dist/dictionary/getDictionary.d.ts.map +1 -1
  17. package/dist/dictionary/getDictionary.js +2 -2
  18. package/dist/dictionary/getDictionary.js.map +1 -1
  19. package/dist/errors/createErrors.js +5 -2
  20. package/dist/errors/createErrors.js.map +1 -1
  21. package/dist/index.client.d.ts +2 -2
  22. package/dist/index.client.d.ts.map +1 -1
  23. package/dist/index.client.js +1 -3
  24. package/dist/index.client.js.map +1 -1
  25. package/dist/index.server.d.ts +9 -2
  26. package/dist/index.server.d.ts.map +1 -1
  27. package/dist/index.server.js +25 -11
  28. package/dist/index.server.js.map +1 -1
  29. package/dist/index.types.d.ts +16 -35
  30. package/dist/index.types.d.ts.map +1 -1
  31. package/dist/index.types.js +16 -41
  32. package/dist/index.types.js.map +1 -1
  33. package/dist/middleware-dir/createNextMiddleware.d.ts.map +1 -1
  34. package/dist/middleware-dir/createNextMiddleware.js +10 -6
  35. package/dist/middleware-dir/createNextMiddleware.js.map +1 -1
  36. package/dist/middleware-dir/utils.d.ts.map +1 -1
  37. package/dist/middleware-dir/utils.js +13 -10
  38. package/dist/middleware-dir/utils.js.map +1 -1
  39. package/dist/next/getNextLocale.js +2 -2
  40. package/dist/next/getNextLocale.js.map +1 -1
  41. package/dist/provider/ClientProviderWrapper.js +6 -3
  42. package/dist/provider/ClientProviderWrapper.js.map +1 -1
  43. package/dist/provider/GTProvider.js +2 -2
  44. package/dist/provider/GTProvider.js.map +1 -1
  45. package/dist/request/getLocale.d.ts +2 -1
  46. package/dist/request/getLocale.d.ts.map +1 -1
  47. package/dist/request/getLocale.js +6 -1
  48. package/dist/request/getLocale.js.map +1 -1
  49. package/dist/server-dir/buildtime/T.js +2 -2
  50. package/dist/server-dir/buildtime/T.js.map +1 -1
  51. package/dist/server-dir/buildtime/getGT.d.ts +11 -1
  52. package/dist/server-dir/buildtime/getGT.d.ts.map +1 -1
  53. package/dist/server-dir/buildtime/getGT.js +37 -27
  54. package/dist/server-dir/buildtime/getGT.js.map +1 -1
  55. package/dist/server-dir/buildtime/getTranslations.d.ts +16 -2
  56. package/dist/server-dir/buildtime/getTranslations.d.ts.map +1 -1
  57. package/dist/server-dir/buildtime/getTranslations.js +43 -18
  58. package/dist/server-dir/buildtime/getTranslations.js.map +1 -1
  59. package/dist/server-dir/runtime/_Tx.js +2 -2
  60. package/dist/server-dir/runtime/_Tx.js.map +1 -1
  61. package/dist/server-dir/runtime/tx.d.ts +1 -1
  62. package/dist/server-dir/runtime/tx.d.ts.map +1 -1
  63. package/dist/server-dir/runtime/tx.js +18 -16
  64. package/dist/server-dir/runtime/tx.js.map +1 -1
  65. package/dist/server.d.ts +5 -4
  66. package/dist/server.d.ts.map +1 -1
  67. package/dist/server.js +11 -7
  68. package/dist/server.js.map +1 -1
  69. package/dist/utils/use.d.ts +4 -0
  70. package/dist/utils/use.d.ts.map +1 -0
  71. package/dist/utils/use.js +73 -0
  72. package/dist/utils/use.js.map +1 -0
  73. package/dist/variables/Currency.d.ts +20 -3
  74. package/dist/variables/Currency.d.ts.map +1 -1
  75. package/dist/variables/Currency.js +29 -58
  76. package/dist/variables/Currency.js.map +1 -1
  77. package/dist/variables/DateTime.d.ts +20 -3
  78. package/dist/variables/DateTime.d.ts.map +1 -1
  79. package/dist/variables/DateTime.js +26 -70
  80. package/dist/variables/DateTime.js.map +1 -1
  81. package/dist/variables/Num.d.ts +6 -4
  82. package/dist/variables/Num.d.ts.map +1 -1
  83. package/dist/variables/Num.js +15 -59
  84. package/dist/variables/Num.js.map +1 -1
  85. package/package.json +4 -4
@@ -10,50 +10,13 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
15
  };
52
16
  Object.defineProperty(exports, "__esModule", { value: true });
53
17
  var jsx_runtime_1 = require("react/jsx-runtime");
54
- var generaltranslation_1 = require("generaltranslation");
55
18
  var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
56
- var getLocale_1 = __importDefault(require("../request/getLocale"));
19
+ var getLocale_1 = require("../request/getLocale");
57
20
  /**
58
21
  * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.
59
22
  * It formats the number according to the current locale and optionally passed formatting options.
@@ -67,31 +30,24 @@ var getLocale_1 = __importDefault(require("../request/getLocale"));
67
30
  * </Num>
68
31
  * ```
69
32
  *
70
- * @param {any} [children] - Optional content (typically a number) to render inside the component.
33
+ * @param {number | string} children - Content to render inside the number component.
34
+ * @param {string[]} [locales] - Optional locales to use for number formatting. If not provided, the library will default to the user's locale.
71
35
  * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
72
36
  * @returns {Promise<React.JSX.Element>} The formatted number component.
73
37
  */
74
38
  function Num(_a) {
75
- return __awaiter(this, arguments, void 0, function (_b) {
76
- var renderedValue, formattedValue;
77
- var children = _b.children, name = _b.name, locales = _b.locales, _c = _b.options, options = _c === void 0 ? {} : _c;
78
- return __generator(this, function (_d) {
79
- switch (_d.label) {
80
- case 0:
81
- if (!!locales) return [3 /*break*/, 2];
82
- return [4 /*yield*/, (0, getLocale_1.default)()];
83
- case 1:
84
- locales = [_d.sent(), (0, getI18NConfig_1.default)().getDefaultLocale()];
85
- _d.label = 2;
86
- case 2:
87
- renderedValue = typeof children === 'string' ? parseFloat(children) : children;
88
- formattedValue = typeof renderedValue === 'number'
89
- ? (0, generaltranslation_1.formatNum)(renderedValue, __assign({ locales: locales }, options))
90
- : renderedValue;
91
- return [2 /*return*/, (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: formattedValue })];
92
- }
93
- });
94
- });
39
+ var children = _a.children, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
40
+ if (!locales) {
41
+ locales = [(0, getLocale_1.useLocale)(), (0, getI18NConfig_1.default)().getDefaultLocale()];
42
+ }
43
+ var gt = (0, getI18NConfig_1.default)().getGTClass();
44
+ // Determine the value to be used
45
+ var renderedValue = typeof children === 'string' ? parseFloat(children) : children;
46
+ // Format the number according to the locale
47
+ var formattedValue = typeof renderedValue === 'number'
48
+ ? gt.formatNum(renderedValue, __assign({ locales: locales }, options))
49
+ : renderedValue;
50
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: formattedValue });
95
51
  }
96
52
  Num.gtTransformation = 'variable-number';
97
53
  exports.default = Num;
@@ -1 +1 @@
1
- {"version":3,"file":"Num.js","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA+C;AAC/C,8EAAwD;AACxD,mEAA6C;AAE7C;;;;;;;;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AAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEjE,4CAA4C;IAC5C,IAAM,cAAc,GAClB,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,aAAI,OAAO,SAAA,IAAK,OAAO,EAAG;QACtD,CAAC,CAAC,aAAa,CAAC;IAEpB,OAAO,2DAAG,cAAc,GAAI,CAAC;AAC/B,CAAC;AAED,GAAG,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;AAEzC,kBAAe,GAAG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt-next",
3
- "version": "5.2.37",
3
+ "version": "5.2.39-alpha.0",
4
4
  "description": "A Next.js library for automatic internationalization.",
5
5
  "main": "dist/index.server.js",
6
6
  "peerDependencies": {
@@ -13,9 +13,9 @@
13
13
  "CHANGELOG.md"
14
14
  ],
15
15
  "dependencies": {
16
- "@generaltranslation/supported-locales": "^2.0.10",
17
- "generaltranslation": "^6.3.2",
18
- "gt-react": "^9.2.27"
16
+ "@generaltranslation/supported-locales": "^2.0.11-alpha.0",
17
+ "generaltranslation": "^7.0.0-alpha.0",
18
+ "gt-react": "^9.2.29-alpha.0"
19
19
  },
20
20
  "scripts": {
21
21
  "patch": "npm version patch",