@cranberry-money/shared-utils 8.23.415 → 8.23.416

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.
@@ -1,3 +1,8 @@
1
- export declare function formatPhoneForDisplay(phoneNumber: string): string;
1
+ interface CountryInfo {
2
+ phoneCode: string;
3
+ code?: string;
4
+ }
5
+ export declare function formatPhoneForDisplay(phoneNumber: string, country?: CountryInfo): string;
2
6
  export declare function cleanPhoneNumber(phoneNumber: string): string;
7
+ export {};
3
8
  //# sourceMappingURL=phoneFormatting.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"phoneFormatting.d.ts","sourceRoot":"","sources":["../src/phoneFormatting.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQjE;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE5D"}
1
+ {"version":3,"file":"phoneFormatting.d.ts","sourceRoot":"","sources":["../src/phoneFormatting.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAaxF;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE5D"}
@@ -1,10 +1,14 @@
1
- export function formatPhoneForDisplay(phoneNumber) {
1
+ export function formatPhoneForDisplay(phoneNumber, country) {
2
2
  if (!phoneNumber)
3
3
  return '';
4
4
  const cleaned = phoneNumber.replace(/\D/g, '');
5
- if (cleaned.startsWith('61') && cleaned.length === 11) {
6
- const mobile = cleaned.slice(2);
7
- return `+61 ${mobile.slice(0, 3)} ${mobile.slice(3, 6)} ${mobile.slice(6)}`;
5
+ const phoneCode = country?.phoneCode?.replace('+', '') || '61';
6
+ if (phoneCode === '61' && cleaned.length >= 9) {
7
+ const digits = cleaned.slice(0, 10);
8
+ return `${digits.slice(0, 4)} ${digits.slice(4, 7)} ${digits.slice(7)}`;
9
+ }
10
+ if (phoneCode === '1' && cleaned.length >= 10) {
11
+ return `(${cleaned.slice(0, 3)}) ${cleaned.slice(3, 6)}-${cleaned.slice(6, 10)}`;
8
12
  }
9
13
  return phoneNumber.trim();
10
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"phoneFormatting.js","sourceRoot":"","sources":["../src/phoneFormatting.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,qBAAqB,CAAC,WAAmB;IACvD,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACtD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9E,CAAC;IACD,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC"}
1
+ {"version":3,"file":"phoneFormatting.js","sourceRoot":"","sources":["../src/phoneFormatting.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,qBAAqB,CAAC,WAAmB,EAAE,OAAqB;IAC9E,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC;IAE/D,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,CAAC;IACD,IAAI,SAAS,KAAK,GAAG,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QAC9C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IACnF,CAAC;IACD,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cranberry-money/shared-utils",
3
- "version": "8.23.415",
3
+ "version": "8.23.416",
4
4
  "description": "Shared utility functions for Blueberry platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,8 +29,8 @@
29
29
  "prepublishOnly": "npm run clean && npm run typecheck && npm test && npm run build"
30
30
  },
31
31
  "dependencies": {
32
- "@cranberry-money/shared-constants": "^8.15.440",
33
- "@cranberry-money/shared-types": "^8.22.415"
32
+ "@cranberry-money/shared-constants": "^8.15.441",
33
+ "@cranberry-money/shared-types": "^8.22.416"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/jest": "^30.0.0",