@cranberry-money/shared-utils 8.23.412 → 8.23.414

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 (45) hide show
  1. package/dist/address.d.ts +4 -6
  2. package/dist/address.d.ts.map +1 -1
  3. package/dist/address.js +6 -100
  4. package/dist/address.js.map +1 -1
  5. package/dist/formatting-labels.d.ts +3 -0
  6. package/dist/formatting-labels.d.ts.map +1 -0
  7. package/dist/formatting-labels.js +26 -0
  8. package/dist/formatting-labels.js.map +1 -0
  9. package/dist/formatting.d.ts +0 -130
  10. package/dist/formatting.d.ts.map +1 -1
  11. package/dist/formatting.js +4 -203
  12. package/dist/formatting.js.map +1 -1
  13. package/dist/index.d.ts +9 -11
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +9 -33
  16. package/dist/index.js.map +1 -1
  17. package/dist/phoneFormatting.d.ts +2 -20
  18. package/dist/phoneFormatting.d.ts.map +1 -1
  19. package/dist/phoneFormatting.js +11 -143
  20. package/dist/phoneFormatting.js.map +1 -1
  21. package/dist/user-validation.d.ts +1 -2
  22. package/dist/user-validation.d.ts.map +1 -1
  23. package/dist/user-validation.js +10 -59
  24. package/dist/user-validation.js.map +1 -1
  25. package/dist/user-verification.d.ts +2 -39
  26. package/dist/user-verification.d.ts.map +1 -1
  27. package/dist/user-verification.js +11 -58
  28. package/dist/user-verification.js.map +1 -1
  29. package/dist/validation.d.ts +1 -3
  30. package/dist/validation.d.ts.map +1 -1
  31. package/dist/validation.js +10 -47
  32. package/dist/validation.js.map +1 -1
  33. package/package.json +3 -3
  34. package/dist/badges.d.ts +0 -2
  35. package/dist/badges.d.ts.map +0 -1
  36. package/dist/badges.js +0 -2
  37. package/dist/badges.js.map +0 -1
  38. package/dist/portfolio.d.ts +0 -12
  39. package/dist/portfolio.d.ts.map +0 -1
  40. package/dist/portfolio.js +0 -37
  41. package/dist/portfolio.js.map +0 -1
  42. package/dist/user-preferences.d.ts +0 -28
  43. package/dist/user-preferences.d.ts.map +0 -1
  44. package/dist/user-preferences.js +0 -88
  45. package/dist/user-preferences.js.map +0 -1
package/dist/address.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import type { ParsedAddress } from '@cranberry-money/shared-types';
2
- export declare function parseAddress(address: string): ParsedAddress;
3
- export declare function getAddressDisplayLines(parsed: ParsedAddress): Array<{
4
- label: string;
5
- value: string;
6
- }>;
1
+ export declare function parseAddress(address: string): {
2
+ lines: string[];
3
+ };
4
+ export declare function getAddressDisplayLines(address: string): string[];
7
5
  //# sourceMappingURL=address.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAoF3D;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAwBrG"}
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAIjE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhE"}
package/dist/address.js CHANGED
@@ -1,104 +1,10 @@
1
1
  export function parseAddress(address) {
2
- if (!address || !address.trim()) {
3
- return {};
4
- }
5
- const trimmed = address.trim();
6
- const parts = trimmed
7
- .split(',')
8
- .map((part) => part.trim())
9
- .filter((part) => part.length > 0);
10
- if (parts.length === 0) {
11
- return { formatted: trimmed };
12
- }
13
- const result = {};
14
- const firstPart = parts[0];
15
- if (firstPart) {
16
- const unitMatch = firstPart.match(/^(unit|apt|apartment|suite|ste|#)\s*(\d+[a-z]?)/i);
17
- if (unitMatch) {
18
- result.unit = unitMatch[2];
19
- const remainingFirstPart = firstPart.replace(unitMatch[0], '').trim();
20
- if (remainingFirstPart) {
21
- const streetMatch = remainingFirstPart.match(/^(\d+)\s+(.+)/);
22
- if (streetMatch) {
23
- result.streetNumber = streetMatch[1];
24
- result.streetName = streetMatch[2];
25
- }
26
- else {
27
- result.streetName = remainingFirstPart;
28
- }
29
- }
30
- }
31
- else {
32
- const streetMatch = firstPart.match(/^(\d+)\s+(.+)/);
33
- if (streetMatch) {
34
- result.streetNumber = streetMatch[1];
35
- result.streetName = streetMatch[2];
36
- }
37
- else {
38
- result.streetName = firstPart;
39
- }
40
- }
41
- }
42
- if (parts.length >= 2) {
43
- result.neighborhood = parts[1];
44
- }
45
- if (parts.length >= 3) {
46
- result.city = parts[2];
47
- }
48
- if (parts.length >= 4) {
49
- const fourthPart = parts[3];
50
- if (fourthPart) {
51
- const zipcodeMatch = fourthPart.match(/\b(\d{4,5})\b/);
52
- if (zipcodeMatch) {
53
- result.zipcode = zipcodeMatch[1];
54
- result.state = fourthPart.replace(zipcodeMatch[0], '').trim();
55
- }
56
- else {
57
- result.state = fourthPart;
58
- }
59
- }
60
- }
61
- if (parts.length >= 5) {
62
- result.country = parts[4];
63
- }
64
- if (parts.length >= 6) {
65
- result.country = parts[parts.length - 1];
66
- if (parts.length === 6) {
67
- result.state = parts[4];
68
- }
69
- }
70
- const componentParts = [];
71
- if (result.unit)
72
- componentParts.push(`Unit ${result.unit}`);
73
- if (result.streetNumber)
74
- componentParts.push(result.streetNumber);
75
- if (result.streetName)
76
- componentParts.push(result.streetName);
77
- if (result.neighborhood)
78
- componentParts.push(result.neighborhood);
79
- result.formatted = componentParts.join(' ');
80
- return result;
2
+ if (!address)
3
+ return { lines: [] };
4
+ const lines = address.split(',').map(s => s.trim()).filter(Boolean);
5
+ return { lines };
81
6
  }
82
- export function getAddressDisplayLines(parsed) {
83
- const lines = [];
84
- if (parsed.formatted) {
85
- lines.push({ label: 'Street:', value: parsed.formatted });
86
- }
87
- if (parsed.city) {
88
- lines.push({ label: 'City:', value: parsed.city });
89
- }
90
- if (parsed.zipcode && parsed.state) {
91
- lines.push({ label: 'Postal:', value: `${parsed.zipcode}, ${parsed.state}` });
92
- }
93
- else if (parsed.zipcode) {
94
- lines.push({ label: 'Postal:', value: parsed.zipcode });
95
- }
96
- else if (parsed.state) {
97
- lines.push({ label: 'State:', value: parsed.state });
98
- }
99
- if (parsed.country) {
100
- lines.push({ label: 'Country:', value: parsed.country });
101
- }
102
- return lines;
7
+ export function getAddressDisplayLines(address) {
8
+ return parseAddress(address).lines;
103
9
  }
104
10
  //# sourceMappingURL=address.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"address.js","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,OAAO;SAClB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAErC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,SAAS,GAAG,SAAS,C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,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpE,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;AACrC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function formatSourceOfFunds(funds: string[]): string;
2
+ export declare function formatIntendedUse(use: string): string;
3
+ //# sourceMappingURL=formatting-labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting-labels.d.ts","sourceRoot":"","sources":["../src/formatting-labels.ts"],"names":[],"mappings":"AAiBA,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAG3D;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGrD"}
@@ -0,0 +1,26 @@
1
+ const SOURCE_OF_FUNDS_LABELS = {
2
+ employment_income: 'Employment income',
3
+ savings: 'Savings',
4
+ investment_income: 'Investment income',
5
+ sale_of_assets: 'Sale of assets',
6
+ inheritance: 'Inheritance',
7
+ gift: 'Gift',
8
+ other: 'Other',
9
+ };
10
+ const INTENDED_USE_LABELS = {
11
+ long_term_investment: 'Long-term investment',
12
+ trading_crypto: 'Trading crypto currencies',
13
+ savings: 'Savings',
14
+ other: 'Other',
15
+ };
16
+ export function formatSourceOfFunds(funds) {
17
+ if (!funds || funds.length === 0)
18
+ return '';
19
+ return funds.map(fund => SOURCE_OF_FUNDS_LABELS[fund] || fund).join(', ');
20
+ }
21
+ export function formatIntendedUse(use) {
22
+ if (!use)
23
+ return '';
24
+ return INTENDED_USE_LABELS[use] || use;
25
+ }
26
+ //# sourceMappingURL=formatting-labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting-labels.js","sourceRoot":"","sources":["../src/formatting-labels.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAA2B;IACrD,iBAAiB,EAAE,mBAAmB;IACtC,OAAO,EAAE,SAAS;IAClB,iBAAiB,EAAE,mBAAmB;IACtC,cAAc,EAAE,gBAAgB;IAChC,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,mBAAmB,GAA2B;IAClD,oBAAoB,EAAE,sBAAsB;IAC5C,cAAc,EAAE,2BAA2B;IAC3C,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,KAAe;IACjD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5C,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,OAAO,mBAAmB,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;AACzC,CAAC"}
@@ -1,142 +1,12 @@
1
- export declare const NUMBER_FORMAT_OPTIONS_CURRENCY: {
2
- readonly style: "currency";
3
- readonly minimumFractionDigits: 2;
4
- readonly maximumFractionDigits: 2;
5
- };
6
- export declare const NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED: {
7
- readonly signDisplay: "always";
8
- readonly style: "currency";
9
- readonly minimumFractionDigits: 2;
10
- readonly maximumFractionDigits: 2;
11
- };
12
- export declare function parseCurrencyInput(value: string): number;
13
- /**
14
- * Currency formatting options
15
- */
16
1
  export interface FormatCurrencyOptions {
17
- /** Currency code (default: AUD) */
18
2
  currency?: string;
19
- /** Locale for formatting (default: en-AU) */
20
3
  locale?: string;
21
- /** Number of decimal places (default: 2) */
22
4
  decimals?: number;
23
- /** Minimum decimal places - overrides decimals if set */
24
5
  minimumFractionDigits?: number;
25
- /** Maximum decimal places - overrides decimals if set */
26
6
  maximumFractionDigits?: number;
27
7
  }
28
- /**
29
- * Main currency formatting function - use this for ALL currency display needs.
30
- *
31
- * @param value - The numeric value to format
32
- * @param options - Optional formatting options
33
- * @returns Formatted currency string (e.g., "$29.50")
34
- *
35
- * @example
36
- * // Standard usage (most cases)
37
- * formatCurrency(29.50) // "$29.50"
38
- * formatCurrency(0.29) // "$0.29"
39
- *
40
- * // With options
41
- * formatCurrency(29.50, { decimals: 0 }) // "$30"
42
- * formatCurrency(29.50, { currency: 'USD' }) // "US$29.50"
43
- * formatCurrency(1234.5, { decimals: 0 }) // "$1,235"
44
- */
45
8
  export declare function formatCurrency(value?: number, options?: FormatCurrencyOptions): string;
46
- export declare function formatQuantityWithSuffix(quantity: number, decimals?: number): string;
47
- export declare function truncateText(text: string, maxLength?: number): string;
48
- export declare const formatTransactionAmount: (amount: string | number) => string;
49
- /**
50
- * Formats a BSB number with a hyphen for better readability (e.g., "123456" -> "123-456")
51
- * @param bsb - The BSB number as a string
52
- * @returns Formatted BSB string with hyphen, or original string if invalid format
53
- */
54
- export declare function formatBSB(bsb: string | null | undefined): string;
55
- /**
56
- * Formats an account number with spaces for better readability
57
- * For account numbers, we'll add spaces every 4 digits from the right (e.g., "12345678" -> "1234 5678")
58
- * @param accountNumber - The account number as a string
59
- * @returns Formatted account number with spaces
60
- */
61
- export declare function formatAccountNumber(accountNumber: string | null | undefined): string;
62
- /**
63
- * Formats cryptocurrency balance with appropriate precision
64
- * @param balance - The balance amount (string or number)
65
- * @param symbol - The crypto symbol (e.g., 'BTC', 'ETH')
66
- * @param decimals - Number of decimal places (default: 4)
67
- * @returns Formatted balance string
68
- *
69
- * @example
70
- * formatCryptoBalance(1.23456789, 'BTC') // "1.2346 BTC"
71
- * formatCryptoBalance(0, 'ETH') // "0 ETH"
72
- * formatCryptoBalance(0.0001, 'BTC') // "<0.001 BTC"
73
- * formatCryptoBalance('2.5', 'ETH', 6) // "2.500000 ETH"
74
- */
75
9
  export declare function formatCryptoBalance(balance: string | number, symbol: string, decimals?: number): string;
76
- /**
77
- * Maps blockchain chain names to their native asset symbols.
78
- * Uses getChainShortCode from shared-constants to ensure consistency.
79
- *
80
- * @param chainName - The chain name (case-insensitive)
81
- * @returns Native asset symbol (e.g., 'ETH', 'BTC', 'MATIC')
82
- *
83
- * @example
84
- * getBlockchainShortName('ethereum') // "ETH"
85
- * getBlockchainShortName('ETHEREUM') // "ETH"
86
- * getBlockchainShortName('polygon') // "MATIC"
87
- * getBlockchainShortName('arbitrum') // "ETH" (uses ETH as native token)
88
- */
89
10
  export declare function getBlockchainShortName(chainName: string): string;
90
- /**
91
- * Formats source of funds codes into human-readable labels.
92
- * Converts an array of source of funds codes (e.g., ['employment_income', 'savings'])
93
- * into a comma-separated string of labels (e.g., "Employment income, Savings")
94
- *
95
- * @param funds - Array of source of funds codes
96
- * @returns Comma-separated string of formatted labels
97
- *
98
- * @example
99
- * formatSourceOfFunds(['employment_income', 'savings']) // "Employment income, Savings"
100
- * formatSourceOfFunds(['investment_income']) // "Investment income"
101
- */
102
- export declare function formatSourceOfFunds(funds: string[]): string;
103
- /**
104
- * Formats an intended use code into a human-readable label.
105
- * Converts a code (e.g., 'long_term') into a label (e.g., "Long-term investment")
106
- *
107
- * @param use - The intended use code
108
- * @returns Human-readable label
109
- *
110
- * @example
111
- * formatIntendedUse('long_term') // "Long-term investment"
112
- * formatIntendedUse('trading') // "Active trading"
113
- */
114
- export declare function formatIntendedUse(use: string): string;
115
- /**
116
- * Formats a number as a percentage string.
117
- *
118
- * @param value - The numeric value to format (e.g., 45.5 for 45.5%)
119
- * @param decimals - Number of decimal places (default: 2)
120
- * @returns Formatted percentage string (e.g., "45.50%")
121
- *
122
- * @example
123
- * formatPercentage(45.5) // "45.50%"
124
- * formatPercentage(100) // "100.00%"
125
- * formatPercentage(33.333, 1) // "33.3%"
126
- * formatPercentage(0) // "0.00%"
127
- */
128
11
  export declare function formatPercentage(value: number, decimals?: number): string;
129
- /**
130
- * Formats a number as an allocation percentage (always shows 2 decimals, no negative).
131
- * Specialized for asset allocation displays.
132
- *
133
- * @param value - The allocation percentage value
134
- * @returns Formatted allocation string (e.g., "45.50%")
135
- *
136
- * @example
137
- * formatAllocationPercentage(45.5) // "45.50%"
138
- * formatAllocationPercentage(-5) // "0.00%" (clamps to 0)
139
- * formatAllocationPercentage(150) // "100.00%" (clamps to 100)
140
- */
141
- export declare function formatAllocationPercentage(value: number): string;
142
12
  //# sourceMappingURL=formatting.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,8BAA8B;;;;CAIjC,CAAC;AAEX,eAAO,MAAM,qCAAqC;;;;;CAGxC,CAAC;AAEX,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOxD;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,qBAAqB,CAAC,EAAE,MAAM,CAA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,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhE"}
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAI1F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAK1G;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAG5E"}
@@ -1,124 +1,10 @@
1
- import { AUD, DECIMAL_PLACES, getChainShortCode, LOCALE_AUSTRALIA, SOURCE_OF_FUNDS_LABELS, INTENDED_USE_LABELS, } from '@cranberry-money/shared-constants';
2
- export const NUMBER_FORMAT_OPTIONS_CURRENCY = {
3
- style: 'currency',
4
- minimumFractionDigits: DECIMAL_PLACES,
5
- maximumFractionDigits: DECIMAL_PLACES,
6
- };
7
- export const NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED = {
8
- ...NUMBER_FORMAT_OPTIONS_CURRENCY,
9
- signDisplay: 'always',
10
- };
11
- export function parseCurrencyInput(value) {
12
- const cleanValue = value.replace(/[^0-9.]/g, '');
13
- const parts = cleanValue.split('.');
14
- const formattedValue = parts[0] + (parts.length > 1 && parts[1] ? '.' + parts[1].slice(0, 2) : '');
15
- return parseFloat(formattedValue) || 0;
16
- }
17
- /**
18
- * Main currency formatting function - use this for ALL currency display needs.
19
- *
20
- * @param value - The numeric value to format
21
- * @param options - Optional formatting options
22
- * @returns Formatted currency string (e.g., "$29.50")
23
- *
24
- * @example
25
- * // Standard usage (most cases)
26
- * formatCurrency(29.50) // "$29.50"
27
- * formatCurrency(0.29) // "$0.29"
28
- *
29
- * // With options
30
- * formatCurrency(29.50, { decimals: 0 }) // "$30"
31
- * formatCurrency(29.50, { currency: 'USD' }) // "US$29.50"
32
- * formatCurrency(1234.5, { decimals: 0 }) // "$1,235"
33
- */
1
+ import { AUD, getChainShortCode } from '@cranberry-money/shared-constants';
34
2
  export function formatCurrency(value, options = {}) {
35
- if (value === undefined || value === null)
36
- return '—';
37
- if (isNaN(value))
3
+ if (value === undefined || value === null || isNaN(value))
38
4
  return '—';
39
- const { currency = AUD, locale = 'en-AU', decimals = 2, minimumFractionDigits = decimals, maximumFractionDigits = decimals, } = options;
40
- return new Intl.NumberFormat(locale, {
41
- style: 'currency',
42
- currency,
43
- minimumFractionDigits,
44
- maximumFractionDigits,
45
- }).format(value);
46
- }
47
- export function formatQuantityWithSuffix(quantity, decimals = 1) {
48
- const million = 1000000;
49
- const thousand = 1000;
50
- const absQuantity = Math.abs(quantity);
51
- const sign = quantity < 0 ? '-' : '';
52
- if (absQuantity >= million) {
53
- return `${sign}${(absQuantity / million).toFixed(decimals)}M`;
54
- }
55
- else if (absQuantity >= thousand) {
56
- return `${sign}${(absQuantity / thousand).toFixed(decimals)}K`;
57
- }
58
- else {
59
- return quantity.toString();
60
- }
61
- }
62
- export function truncateText(text, maxLength = 30) {
63
- if (text.length <= maxLength)
64
- return text;
65
- return `${text.substring(0, maxLength)}...`;
66
- }
67
- export const formatTransactionAmount = (amount) => {
68
- const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
69
- return new Intl.NumberFormat(LOCALE_AUSTRALIA, {
70
- ...NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED,
71
- currency: AUD,
72
- }).format(numAmount);
73
- };
74
- /**
75
- * Formats a BSB number with a hyphen for better readability (e.g., "123456" -> "123-456")
76
- * @param bsb - The BSB number as a string
77
- * @returns Formatted BSB string with hyphen, or original string if invalid format
78
- */
79
- export function formatBSB(bsb) {
80
- if (!bsb)
81
- return 'N/A';
82
- // Remove any existing hyphens and whitespace
83
- const cleanBsb = bsb.replace(/[-\s]/g, '');
84
- // Check if it's a valid 6-digit BSB
85
- if (!/^\d{6}$/.test(cleanBsb)) {
86
- return bsb; // Return original if not valid format
87
- }
88
- // Format as XXX-XXX
89
- return `${cleanBsb.substring(0, 3)}-${cleanBsb.substring(3, 6)}`;
5
+ const { currency = AUD, locale = 'en-AU', decimals = 2, minimumFractionDigits = decimals, maximumFractionDigits = decimals } = options;
6
+ return new Intl.NumberFormat(locale, { style: 'currency', currency, minimumFractionDigits, maximumFractionDigits }).format(value);
90
7
  }
91
- /**
92
- * Formats an account number with spaces for better readability
93
- * For account numbers, we'll add spaces every 4 digits from the right (e.g., "12345678" -> "1234 5678")
94
- * @param accountNumber - The account number as a string
95
- * @returns Formatted account number with spaces
96
- */
97
- export function formatAccountNumber(accountNumber) {
98
- if (!accountNumber)
99
- return 'N/A';
100
- // Remove any existing spaces
101
- const cleanNumber = accountNumber.replace(/\s/g, '');
102
- // Check if it's a valid account number (digits only, 4-10 chars)
103
- if (!/^\d{4,10}$/.test(cleanNumber)) {
104
- return accountNumber; // Return original if not valid format
105
- }
106
- // Add space every 4 digits from the right
107
- return cleanNumber.replace(/(\d{4})/g, '$1 ').trim();
108
- }
109
- /**
110
- * Formats cryptocurrency balance with appropriate precision
111
- * @param balance - The balance amount (string or number)
112
- * @param symbol - The crypto symbol (e.g., 'BTC', 'ETH')
113
- * @param decimals - Number of decimal places (default: 4)
114
- * @returns Formatted balance string
115
- *
116
- * @example
117
- * formatCryptoBalance(1.23456789, 'BTC') // "1.2346 BTC"
118
- * formatCryptoBalance(0, 'ETH') // "0 ETH"
119
- * formatCryptoBalance(0.0001, 'BTC') // "<0.001 BTC"
120
- * formatCryptoBalance('2.5', 'ETH', 6) // "2.500000 ETH"
121
- */
122
8
  export function formatCryptoBalance(balance, symbol, decimals = 4) {
123
9
  const balanceNum = typeof balance === 'string' ? parseFloat(balance) : balance;
124
10
  if (balanceNum === 0)
@@ -127,97 +13,12 @@ export function formatCryptoBalance(balance, symbol, decimals = 4) {
127
13
  return `<0.001 ${symbol}`;
128
14
  return `${balanceNum.toFixed(decimals)} ${symbol}`;
129
15
  }
130
- /**
131
- * Maps blockchain chain names to their native asset symbols.
132
- * Uses getChainShortCode from shared-constants to ensure consistency.
133
- *
134
- * @param chainName - The chain name (case-insensitive)
135
- * @returns Native asset symbol (e.g., 'ETH', 'BTC', 'MATIC')
136
- *
137
- * @example
138
- * getBlockchainShortName('ethereum') // "ETH"
139
- * getBlockchainShortName('ETHEREUM') // "ETH"
140
- * getBlockchainShortName('polygon') // "MATIC"
141
- * getBlockchainShortName('arbitrum') // "ETH" (uses ETH as native token)
142
- */
143
16
  export function getBlockchainShortName(chainName) {
144
17
  return getChainShortCode(chainName);
145
18
  }
146
- // ============================================
147
- // Label Formatting Utilities
148
- // ============================================
149
- /**
150
- * Formats source of funds codes into human-readable labels.
151
- * Converts an array of source of funds codes (e.g., ['employment_income', 'savings'])
152
- * into a comma-separated string of labels (e.g., "Employment income, Savings")
153
- *
154
- * @param funds - Array of source of funds codes
155
- * @returns Comma-separated string of formatted labels
156
- *
157
- * @example
158
- * formatSourceOfFunds(['employment_income', 'savings']) // "Employment income, Savings"
159
- * formatSourceOfFunds(['investment_income']) // "Investment income"
160
- */
161
- export function formatSourceOfFunds(funds) {
162
- if (!funds || funds.length === 0)
163
- return '';
164
- return funds
165
- .map((fund) => SOURCE_OF_FUNDS_LABELS[fund] || fund)
166
- .join(', ');
167
- }
168
- /**
169
- * Formats an intended use code into a human-readable label.
170
- * Converts a code (e.g., 'long_term') into a label (e.g., "Long-term investment")
171
- *
172
- * @param use - The intended use code
173
- * @returns Human-readable label
174
- *
175
- * @example
176
- * formatIntendedUse('long_term') // "Long-term investment"
177
- * formatIntendedUse('trading') // "Active trading"
178
- */
179
- export function formatIntendedUse(use) {
180
- if (!use)
181
- return '';
182
- return INTENDED_USE_LABELS[use] || use;
183
- }
184
- // ============================================
185
- // Percentage Formatting
186
- // ============================================
187
- /**
188
- * Formats a number as a percentage string.
189
- *
190
- * @param value - The numeric value to format (e.g., 45.5 for 45.5%)
191
- * @param decimals - Number of decimal places (default: 2)
192
- * @returns Formatted percentage string (e.g., "45.50%")
193
- *
194
- * @example
195
- * formatPercentage(45.5) // "45.50%"
196
- * formatPercentage(100) // "100.00%"
197
- * formatPercentage(33.333, 1) // "33.3%"
198
- * formatPercentage(0) // "0.00%"
199
- */
200
19
  export function formatPercentage(value, decimals = 2) {
201
20
  if (value === undefined || value === null || isNaN(value))
202
21
  return '—';
203
22
  return `${value.toFixed(decimals)}%`;
204
23
  }
205
- /**
206
- * Formats a number as an allocation percentage (always shows 2 decimals, no negative).
207
- * Specialized for asset allocation displays.
208
- *
209
- * @param value - The allocation percentage value
210
- * @returns Formatted allocation string (e.g., "45.50%")
211
- *
212
- * @example
213
- * formatAllocationPercentage(45.5) // "45.50%"
214
- * formatAllocationPercentage(-5) // "0.00%" (clamps to 0)
215
- * formatAllocationPercentage(150) // "100.00%" (clamps to 100)
216
- */
217
- export function formatAllocationPercentage(value) {
218
- if (value === undefined || value === null || isNaN(value))
219
- return '0.00%';
220
- const clamped = Math.max(0, Math.min(100, value));
221
- return `${clamped.toFixed(2)}%`;
222
- }
223
24
  //# sourceMappingURL=formatting.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatting.js","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,mCAAmC,CAAC;AAE3C,MAAM,CAAC,MAAM,8BAA8B,GAA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,GAAG,KAAK;QAAE,OAAO,UAAU,MAAM,EAAE,CAAC;IAClD,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,MAAM,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,SAAiB;IACtD,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,WAAmB,CAAC;IAClE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACtE,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;AACvC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,14 +1,12 @@
1
- export { truncateText } from './formatting';
1
+ export { formatFullDate, formatShortDate, formatTime, formatFullDateTime, getDateRange, type DateRange } from './date';
2
+ export { formatCurrency, type FormatCurrencyOptions, formatCryptoBalance, formatPercentage, getBlockchainShortName } from './formatting';
3
+ export { isNumericOnly, validatePassword, formatVerificationToken, validateEmailConfirmation, isValidFullName, isValidPhoneFormat, formatPhoneNumber } from './validation';
4
+ export { validateWalletAddress, detectChainFromAddress, formatWalletAddressShort, formatWalletAddressMedium } from './validation/wallets';
5
+ export { hasActiveFilters, countActiveFilters } from './filters';
6
+ export { getAssetType, getAssetTypeVariant } from './assets';
2
7
  export { parseAddress, getAddressDisplayLines } from './address';
3
- export { formatDate, formatFullDate, formatShortDate, formatNumericDate, formatTime, formatDateTime, formatFullDateTime, formatMemberSince, getDateRange, type DateRange, } from './date';
4
- export { NUMBER_FORMAT_OPTIONS_CURRENCY, NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED, parseCurrencyInput, formatCurrency, type FormatCurrencyOptions, formatQuantityWithSuffix, formatTransactionAmount, formatBSB, formatAccountNumber, formatCryptoBalance, getBlockchainShortName, formatSourceOfFunds, formatIntendedUse, formatPercentage, formatAllocationPercentage, } from './formatting';
5
- export { formatPortfolioValue, calculateReturnPercentage, parseNumericValue, validateAllocations } from './portfolio';
6
- export { isNumericOnly, validatePassword, formatVerificationToken, validateEmailConfirmation, isValidPhoneFormat, isValidFullName, formatPhoneNumber, isValidSourceOfFunds, isValidOccupation, } from './validation';
7
- export { isValidEthereumAddress, isValidBitcoinAddress, validateWalletAddress, detectChainFromAddress, formatWalletAddress, formatWalletAddressShort, formatWalletAddressMedium, formatWalletAddressLong, getBlockchainExplorerUrl, getTransactionExplorerUrl, isEVMCompatible, isBitcoinBased, } from './validation/wallets';
8
+ export { formatPhoneForDisplay, cleanPhoneNumber } from './phoneFormatting';
9
+ export { formatSourceOfFunds, formatIntendedUse } from './formatting-labels';
8
10
  export { validateUserProfileField } from './user-validation';
9
- export { hasActiveFilters, countActiveFilters, hasActiveTransactionFilters, countActiveTransactionFilters, } from './filters';
10
- export { validateUserPreferences, hasUserPreferences, getUserPreferencesSummary, formatUserPreferencesForDisplay, getAvailablePortfoliosForAccount, isValidUserPreferencesUpdate, getUserPreferencesCacheKey, sanitizeUserPreferencesInput, } from './user-preferences';
11
- export { formatPhoneForDisplay, cleanPhoneNumber, getExpectedPhoneLength } from './phoneFormatting';
12
- export { getAssetType, getAssetTypeVariant, ASSET_TYPE_NATIVE_CRYPTO, ASSET_TYPE_STABLECOIN, ASSET_TYPE_TOKENIZED_SECURITY, ASSET_TYPE_TOKENIZED_RWA, ASSET_TYPE_SYNTHETIC, type AllAssetTypes, } from './assets';
13
- export { getUserVerificationStatus, isUserVerified, isVerificationPending, isVerificationRejected, type VerificationStatusType, type VerificationStatus, } from './user-verification';
11
+ export { getUserVerificationStatus, type VerificationStatusType } from './user-verification';
14
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;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