@connectedxm/admin 6.1.9 → 6.1.10

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.cjs CHANGED
@@ -4046,15 +4046,54 @@ function MergeInfinitePages(data) {
4046
4046
  }
4047
4047
 
4048
4048
  // src/utilities/TransformPrice.ts
4049
- var TransformPrice = (value, currency) => {
4049
+ var ZERO_DECIMAL_CURRENCIES = [
4050
+ "BIF",
4051
+ // Burundian Franc
4052
+ "CLP",
4053
+ // Chilean Peso
4054
+ "DJF",
4055
+ // Djiboutian Franc
4056
+ "GNF",
4057
+ // Guinean Franc
4058
+ "JPY",
4059
+ // Japanese Yen
4060
+ "KMF",
4061
+ // Comorian Franc
4062
+ "KRW",
4063
+ // South Korean Won
4064
+ "MGA",
4065
+ // Malagasy Ariary
4066
+ "PYG",
4067
+ // Paraguayan Guaraní
4068
+ "RWF",
4069
+ // Rwandan Franc
4070
+ "UGX",
4071
+ // Ugandan Shilling
4072
+ "VND",
4073
+ // Vietnamese Dong
4074
+ "VUV",
4075
+ // Vanuatu Vatu
4076
+ "XAF",
4077
+ // Central African CFA Franc
4078
+ "XOF",
4079
+ // West African CFA Franc
4080
+ "XPF"
4081
+ // CFP Franc
4082
+ ];
4083
+ var TransformPrice = (value, currency, freeText) => {
4050
4084
  if (typeof value !== "number") return void 0;
4085
+ const isZeroDecimal = ZERO_DECIMAL_CURRENCIES.includes(
4086
+ currency.toUpperCase()
4087
+ );
4051
4088
  const formatter = new Intl.NumberFormat(void 0, {
4052
4089
  style: "currency",
4053
4090
  currency,
4054
- minimumFractionDigits: 2,
4091
+ minimumFractionDigits: isZeroDecimal ? 0 : 2,
4055
4092
  maximumFractionDigits: 2
4056
4093
  });
4057
- if (value === 0) return "--.--";
4094
+ if (value === 0) return freeText || "--.--";
4095
+ if (value < 0)
4096
+ return formatter.format(-value / 100).replace(currency, `-${currency}`);
4058
4097
  return formatter.format(value / 100);
4059
4098
  };
4060
4099
 
package/dist/index.d.cts CHANGED
@@ -6544,7 +6544,7 @@ declare const isUUID: (id: string) => boolean;
6544
6544
 
6545
6545
  declare function MergeInfinitePages<TData>(data: InfiniteData<ConnectedXMResponse<TData[]>>): TData[];
6546
6546
 
6547
- declare const TransformPrice: (value: number, currency: string) => string | undefined;
6547
+ declare const TransformPrice: (value: number, currency: string, freeText?: string) => string | undefined;
6548
6548
 
6549
6549
  interface AdminApiParams {
6550
6550
  apiUrl: "https://admin-api.connected.dev" | "https://staging-admin-api.connected.dev" | "http://localhost:4001";
package/dist/index.d.ts CHANGED
@@ -6544,7 +6544,7 @@ declare const isUUID: (id: string) => boolean;
6544
6544
 
6545
6545
  declare function MergeInfinitePages<TData>(data: InfiniteData<ConnectedXMResponse<TData[]>>): TData[];
6546
6546
 
6547
- declare const TransformPrice: (value: number, currency: string) => string | undefined;
6547
+ declare const TransformPrice: (value: number, currency: string, freeText?: string) => string | undefined;
6548
6548
 
6549
6549
  interface AdminApiParams {
6550
6550
  apiUrl: "https://admin-api.connected.dev" | "https://staging-admin-api.connected.dev" | "http://localhost:4001";
package/dist/index.js CHANGED
@@ -782,15 +782,54 @@ 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 TransformPrice = (value, currency, freeText) => {
786
820
  if (typeof value !== "number") return void 0;
821
+ const isZeroDecimal = ZERO_DECIMAL_CURRENCIES.includes(
822
+ currency.toUpperCase()
823
+ );
787
824
  const formatter = new Intl.NumberFormat(void 0, {
788
825
  style: "currency",
789
826
  currency,
790
- minimumFractionDigits: 2,
827
+ minimumFractionDigits: isZeroDecimal ? 0 : 2,
791
828
  maximumFractionDigits: 2
792
829
  });
793
- if (value === 0) return "--.--";
830
+ if (value === 0) return freeText || "--.--";
831
+ if (value < 0)
832
+ return formatter.format(-value / 100).replace(currency, `-${currency}`);
794
833
  return formatter.format(value / 100);
795
834
  };
796
835
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/admin",
3
- "version": "6.1.9",
3
+ "version": "6.1.10",
4
4
  "description": "Admin API javascript SDK",
5
5
  "author": "ConnectedXM Inc.",
6
6
  "type": "module",