@betterstore/sdk 0.3.22 → 0.3.23

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.23
4
+
5
+ ### Patch Changes
6
+
7
+ - currency formatting
8
+
3
9
  ## 0.3.22
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -318,11 +318,78 @@ var Helpers = class {
318
318
  this.proxy = proxy;
319
319
  }
320
320
  formatPrice(priceInCents, currency, exchangeRate) {
321
+ var _a;
321
322
  const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
322
323
  const isWhole = amount % 1 === 0;
323
- const formattedPrice = new Intl.NumberFormat(void 0, {
324
+ const currencyLocales = {
325
+ CZK: "cs-CZ",
326
+ // Czech Koruna
327
+ USD: "en-US",
328
+ // US Dollar
329
+ EUR: "de-DE",
330
+ // Euro (Germany locale)
331
+ GBP: "en-GB",
332
+ // British Pound
333
+ JPY: "ja-JP",
334
+ // Japanese Yen
335
+ AUD: "en-AU",
336
+ // Australian Dollar
337
+ CAD: "en-CA",
338
+ // Canadian Dollar
339
+ NZD: "en-NZ",
340
+ // New Zealand Dollar
341
+ SEK: "sv-SE",
342
+ // Swedish Krona
343
+ NOK: "nb-NO",
344
+ // Norwegian Krone
345
+ DKK: "da-DK",
346
+ // Danish Krone
347
+ CHF: "de-CH",
348
+ // Swiss Franc (German Switzerland)
349
+ HUF: "hu-HU",
350
+ // Hungarian Forint
351
+ PLN: "pl-PL",
352
+ // Polish Zloty
353
+ BGN: "bg-BG",
354
+ // Bulgarian Lev
355
+ RON: "ro-RO",
356
+ // Romanian Leu
357
+ RUB: "ru-RU",
358
+ // Russian Ruble
359
+ CNY: "zh-CN",
360
+ // Chinese Yuan
361
+ INR: "en-IN",
362
+ // Indian Rupee
363
+ BRL: "pt-BR",
364
+ // Brazilian Real
365
+ MXN: "es-MX",
366
+ // Mexican Peso
367
+ ZAR: "en-ZA",
368
+ // South African Rand
369
+ KRW: "ko-KR",
370
+ // South Korean Won
371
+ MYR: "ms-MY",
372
+ // Malaysian Ringgit
373
+ SGD: "en-SG",
374
+ // Singapore Dollar
375
+ TWD: "zh-TW",
376
+ // Taiwanese Dollar
377
+ THB: "th-TH",
378
+ // Thai Baht
379
+ IDR: "id-ID",
380
+ // Indonesian Rupiah
381
+ AED: "ar-AE",
382
+ // UAE Dirham
383
+ SAR: "ar-SA",
384
+ // Saudi Riyal
385
+ TRY: "tr-TR"
386
+ // Turkish Lira
387
+ };
388
+ const locale = (_a = currencyLocales[currency]) != null ? _a : void 0;
389
+ const formattedPrice = new Intl.NumberFormat(locale, {
324
390
  style: "currency",
325
391
  currency,
392
+ currencyDisplay: "symbol",
326
393
  minimumFractionDigits: isWhole ? 0 : 2,
327
394
  maximumFractionDigits: isWhole ? 0 : 2
328
395
  }).format(amount);
package/dist/index.mjs CHANGED
@@ -279,11 +279,78 @@ var Helpers = class {
279
279
  this.proxy = proxy;
280
280
  }
281
281
  formatPrice(priceInCents, currency, exchangeRate) {
282
+ var _a;
282
283
  const amount = priceInCents / 100 * (exchangeRate != null ? exchangeRate : 1);
283
284
  const isWhole = amount % 1 === 0;
284
- const formattedPrice = new Intl.NumberFormat(void 0, {
285
+ const currencyLocales = {
286
+ CZK: "cs-CZ",
287
+ // Czech Koruna
288
+ USD: "en-US",
289
+ // US Dollar
290
+ EUR: "de-DE",
291
+ // Euro (Germany locale)
292
+ GBP: "en-GB",
293
+ // British Pound
294
+ JPY: "ja-JP",
295
+ // Japanese Yen
296
+ AUD: "en-AU",
297
+ // Australian Dollar
298
+ CAD: "en-CA",
299
+ // Canadian Dollar
300
+ NZD: "en-NZ",
301
+ // New Zealand Dollar
302
+ SEK: "sv-SE",
303
+ // Swedish Krona
304
+ NOK: "nb-NO",
305
+ // Norwegian Krone
306
+ DKK: "da-DK",
307
+ // Danish Krone
308
+ CHF: "de-CH",
309
+ // Swiss Franc (German Switzerland)
310
+ HUF: "hu-HU",
311
+ // Hungarian Forint
312
+ PLN: "pl-PL",
313
+ // Polish Zloty
314
+ BGN: "bg-BG",
315
+ // Bulgarian Lev
316
+ RON: "ro-RO",
317
+ // Romanian Leu
318
+ RUB: "ru-RU",
319
+ // Russian Ruble
320
+ CNY: "zh-CN",
321
+ // Chinese Yuan
322
+ INR: "en-IN",
323
+ // Indian Rupee
324
+ BRL: "pt-BR",
325
+ // Brazilian Real
326
+ MXN: "es-MX",
327
+ // Mexican Peso
328
+ ZAR: "en-ZA",
329
+ // South African Rand
330
+ KRW: "ko-KR",
331
+ // South Korean Won
332
+ MYR: "ms-MY",
333
+ // Malaysian Ringgit
334
+ SGD: "en-SG",
335
+ // Singapore Dollar
336
+ TWD: "zh-TW",
337
+ // Taiwanese Dollar
338
+ THB: "th-TH",
339
+ // Thai Baht
340
+ IDR: "id-ID",
341
+ // Indonesian Rupiah
342
+ AED: "ar-AE",
343
+ // UAE Dirham
344
+ SAR: "ar-SA",
345
+ // Saudi Riyal
346
+ TRY: "tr-TR"
347
+ // Turkish Lira
348
+ };
349
+ const locale = (_a = currencyLocales[currency]) != null ? _a : void 0;
350
+ const formattedPrice = new Intl.NumberFormat(locale, {
285
351
  style: "currency",
286
352
  currency,
353
+ currencyDisplay: "symbol",
287
354
  minimumFractionDigits: isWhole ? 0 : 2,
288
355
  maximumFractionDigits: isWhole ? 0 : 2
289
356
  }).format(amount);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.3.22",
3
+ "version": "0.3.23",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {