@connectedxm/admin 6.1.9 → 6.1.11

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/dist/index.js CHANGED
@@ -782,15 +782,69 @@ function MergeInfinitePages(data) {
782
782
  }
783
783
 
784
784
  // src/utilities/TransformPrice.ts
785
- var TransformPrice = (value, currency) => {
785
+ var ZERO_DECIMAL_CURRENCIES = [
786
+ "BIF",
787
+ // Burundian Franc
788
+ "CLP",
789
+ // Chilean Peso
790
+ "DJF",
791
+ // Djiboutian Franc
792
+ "GNF",
793
+ // Guinean Franc
794
+ "JPY",
795
+ // Japanese Yen
796
+ "KMF",
797
+ // Comorian Franc
798
+ "KRW",
799
+ // South Korean Won
800
+ "MGA",
801
+ // Malagasy Ariary
802
+ "PYG",
803
+ // Paraguayan Guaraní
804
+ "RWF",
805
+ // Rwandan Franc
806
+ "UGX",
807
+ // Ugandan Shilling
808
+ "VND",
809
+ // Vietnamese Dong
810
+ "VUV",
811
+ // Vanuatu Vatu
812
+ "XAF",
813
+ // Central African CFA Franc
814
+ "XOF",
815
+ // West African CFA Franc
816
+ "XPF"
817
+ // CFP Franc
818
+ ];
819
+ var isZeroDecimalCurrency = (currencyCode) => {
820
+ return ZERO_DECIMAL_CURRENCIES.includes(currencyCode.toUpperCase());
821
+ };
822
+ var getCurrencySymbol = (currencyCode) => {
823
+ try {
824
+ const formatter = new Intl.NumberFormat("en-US", {
825
+ style: "currency",
826
+ currency: currencyCode,
827
+ minimumFractionDigits: 0,
828
+ maximumFractionDigits: 0
829
+ });
830
+ const parts = formatter.formatToParts(0);
831
+ const symbolPart = parts.find((part) => part.type === "currency");
832
+ return symbolPart?.value || currencyCode;
833
+ } catch {
834
+ return currencyCode;
835
+ }
836
+ };
837
+ var TransformPrice = (value, currency, freeText) => {
786
838
  if (typeof value !== "number") return void 0;
787
839
  const formatter = new Intl.NumberFormat(void 0, {
788
840
  style: "currency",
789
841
  currency,
790
- minimumFractionDigits: 2,
842
+ minimumFractionDigits: isZeroDecimalCurrency(currency) ? 0 : 2,
791
843
  maximumFractionDigits: 2
792
844
  });
793
- if (value === 0) return "--.--";
845
+ if (value === 0) return freeText || "--.--";
846
+ if (value < 0)
847
+ return formatter.format(-value / 100).replace(currency, `-${currency}`);
794
848
  return formatter.format(value / 100);
795
849
  };
796
850
 
@@ -38398,7 +38452,10 @@ export {
38398
38452
  VoidInvoice,
38399
38453
  WidgetCategory,
38400
38454
  WidgetType,
38455
+ ZERO_DECIMAL_CURRENCIES,
38456
+ getCurrencySymbol,
38401
38457
  isUUID,
38458
+ isZeroDecimalCurrency,
38402
38459
  setFirstPageData,
38403
38460
  useAcceptGroupRequest,
38404
38461
  useAddAccountFollower,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/admin",
3
- "version": "6.1.9",
3
+ "version": "6.1.11",
4
4
  "description": "Admin API javascript SDK",
5
5
  "author": "ConnectedXM Inc.",
6
6
  "type": "module",