@cranberry-money/shared-utils 8.23.390 → 8.23.395
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/formatting.d.ts +79 -15
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +102 -29
- package/dist/formatting.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/formatting.d.ts
CHANGED
|
@@ -10,27 +10,39 @@ export declare const NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED: {
|
|
|
10
10
|
readonly maximumFractionDigits: 2;
|
|
11
11
|
};
|
|
12
12
|
export declare function parseCurrencyInput(value: string): number;
|
|
13
|
-
export declare function formatCurrencyWithCode(value: number, currencyCode?: string, locale?: string, minimumFractionDigits?: number, maximumFractionDigits?: number): string;
|
|
14
|
-
export declare function formatDefaultCurrency(value: number, minimumFractionDigits?: number, maximumFractionDigits?: number): string;
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @param value - The numeric value to format
|
|
18
|
-
* @param currency - Currency code (defaults to AUD)
|
|
19
|
-
* @returns Formatted currency string
|
|
20
|
-
*/
|
|
21
|
-
export declare function formatCurrency(value?: number, currency?: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Advanced currency formatting with full control over options
|
|
24
|
-
* @param value - The numeric value to format
|
|
25
|
-
* @param options - Formatting options
|
|
26
|
-
* @returns Formatted currency string
|
|
14
|
+
* Currency formatting options
|
|
27
15
|
*/
|
|
28
|
-
export
|
|
16
|
+
export interface FormatCurrencyOptions {
|
|
17
|
+
/** Currency code (default: AUD) */
|
|
29
18
|
currency?: string;
|
|
19
|
+
/** Locale for formatting (default: en-AU) */
|
|
30
20
|
locale?: string;
|
|
21
|
+
/** Number of decimal places (default: 2) */
|
|
22
|
+
decimals?: number;
|
|
23
|
+
/** Minimum decimal places - overrides decimals if set */
|
|
31
24
|
minimumFractionDigits?: number;
|
|
25
|
+
/** Maximum decimal places - overrides decimals if set */
|
|
32
26
|
maximumFractionDigits?: number;
|
|
33
|
-
}
|
|
27
|
+
}
|
|
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
|
+
export declare function formatCurrency(value?: number, options?: FormatCurrencyOptions): string;
|
|
34
46
|
export declare function formatQuantityWithSuffix(quantity: number, decimals?: number): string;
|
|
35
47
|
export declare function truncateText(text: string, maxLength?: number): string;
|
|
36
48
|
export declare const formatTransactionAmount: (amount: string | number) => string;
|
|
@@ -75,4 +87,56 @@ export declare function formatCryptoBalance(balance: string | number, symbol: st
|
|
|
75
87
|
* getBlockchainShortName('arbitrum') // "ETH" (uses ETH as native token)
|
|
76
88
|
*/
|
|
77
89
|
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
|
+
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;
|
|
78
142
|
//# sourceMappingURL=formatting.d.ts.map
|
package/dist/formatting.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"
|
|
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,CAAC;IAC/B,yDAAyD;IACzD,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAkB1F;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAavF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAW,GAAG,MAAM,CAGzE;AAED,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,GAAG,MAAM,KAAG,MAMjE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAahE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAapF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAM1G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAK3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGrD;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAG5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhE"}
|
package/dist/formatting.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUD, DECIMAL_PLACES, getChainShortCode, LOCALE_AUSTRALIA } from '@cranberry-money/shared-constants';
|
|
1
|
+
import { AUD, DECIMAL_PLACES, getChainShortCode, LOCALE_AUSTRALIA, SOURCE_OF_FUNDS_LABELS, INTENDED_USE_LABELS, } from '@cranberry-money/shared-constants';
|
|
2
2
|
export const NUMBER_FORMAT_OPTIONS_CURRENCY = {
|
|
3
3
|
style: 'currency',
|
|
4
4
|
minimumFractionDigits: DECIMAL_PLACES,
|
|
@@ -14,39 +14,35 @@ export function parseCurrencyInput(value) {
|
|
|
14
14
|
const formattedValue = parts[0] + (parts.length > 1 && parts[1] ? '.' + parts[1].slice(0, 2) : '');
|
|
15
15
|
return parseFloat(formattedValue) || 0;
|
|
16
16
|
}
|
|
17
|
-
export function formatCurrencyWithCode(value, currencyCode = AUD, locale = 'en-AU', minimumFractionDigits = 0, maximumFractionDigits = 0) {
|
|
18
|
-
if (value == null || isNaN(value))
|
|
19
|
-
return '';
|
|
20
|
-
return new Intl.NumberFormat(locale, {
|
|
21
|
-
style: 'currency',
|
|
22
|
-
currency: currencyCode,
|
|
23
|
-
minimumFractionDigits,
|
|
24
|
-
maximumFractionDigits,
|
|
25
|
-
}).format(value);
|
|
26
|
-
}
|
|
27
|
-
export function formatDefaultCurrency(value, minimumFractionDigits = 0, maximumFractionDigits = 0) {
|
|
28
|
-
return formatCurrencyWithCode(value, AUD, 'en-AU', minimumFractionDigits, maximumFractionDigits);
|
|
29
|
-
}
|
|
30
17
|
/**
|
|
31
|
-
* Main currency formatting function - use this for
|
|
18
|
+
* Main currency formatting function - use this for ALL currency display needs.
|
|
19
|
+
*
|
|
32
20
|
* @param value - The numeric value to format
|
|
33
|
-
* @param
|
|
34
|
-
* @returns Formatted currency string
|
|
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"
|
|
35
33
|
*/
|
|
36
|
-
export function formatCurrency(value,
|
|
34
|
+
export function formatCurrency(value, options = {}) {
|
|
37
35
|
if (value === undefined || value === null)
|
|
38
36
|
return '—';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const { currency = AUD, locale = 'en-AU', minimumFractionDigits = 2, maximumFractionDigits = 2 } = options;
|
|
49
|
-
return formatCurrencyWithCode(value, currency, locale, minimumFractionDigits, maximumFractionDigits);
|
|
37
|
+
if (isNaN(value))
|
|
38
|
+
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);
|
|
50
46
|
}
|
|
51
47
|
export function formatQuantityWithSuffix(quantity, decimals = 1) {
|
|
52
48
|
const million = 1000000;
|
|
@@ -147,4 +143,81 @@ export function formatCryptoBalance(balance, symbol, decimals = 4) {
|
|
|
147
143
|
export function getBlockchainShortName(chainName) {
|
|
148
144
|
return getChainShortCode(chainName);
|
|
149
145
|
}
|
|
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
|
+
export function formatPercentage(value, decimals = 2) {
|
|
201
|
+
if (value === undefined || value === null || isNaN(value))
|
|
202
|
+
return '—';
|
|
203
|
+
return `${value.toFixed(decimals)}%`;
|
|
204
|
+
}
|
|
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
|
+
}
|
|
150
223
|
//# sourceMappingURL=formatting.js.map
|
package/dist/formatting.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.js","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,GAAG;IAC5C,KAAK,EAAE,UAAU;IACjB,qBAAqB,EAAE,cAAc;IACrC,qBAAqB,EAAE,cAAc;CAC7B,CAAC;AAEX,MAAM,CAAC,MAAM,qCAAqC,GAAG;IACnD,GAAG,8BAA8B;IACjC,WAAW,EAAE,QAAiB;CACtB,CAAC;AAEX,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,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CAAC;QAAE,OAAO,EAAE,CAAC;IAC5C,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAA2C,CAAC,IAAI,IAAI,CAAC;SAC1F,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,OAAO,mBAAmB,CAAC,GAAuC,CAAC,IAAI,GAAG,CAAC;AAC7E,CAAC;AAED,+CAA+C;AAC/C,wBAAwB;AACxB,+CAA+C;AAE/C;;;;;;;;;;;;GAYG;AACH,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;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAa;IACtD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAClD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AAClC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { truncateText } from './formatting';
|
|
2
2
|
export { parseAddress, getAddressDisplayLines } from './address';
|
|
3
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,
|
|
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
5
|
export { formatPortfolioValue, calculateReturnPercentage, parseNumericValue, validateAllocations } from './portfolio';
|
|
6
6
|
export { isNumericOnly, validatePassword, formatVerificationToken, validateEmailConfirmation, isValidPhoneFormat, isValidFullName, formatPhoneNumber, isValidSourceOfFunds, isValidOccupation, } from './validation';
|
|
7
7
|
export { isValidEthereumAddress, isValidBitcoinAddress, validateWalletAddress, detectChainFromAddress, formatWalletAddress, formatWalletAddressShort, formatWalletAddressMedium, formatWalletAddressLong, getBlockchainExplorerUrl, getTransactionExplorerUrl, isEVMCompatible, isBitcoinBased, } from './validation/wallets';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAGjE,OAAO,EACL,UAAU,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,KAAK,SAAS,GACf,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,EACrC,kBAAkB,EAClB,
|
|
1
|
+
{"version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AAM,wBAAwB,CAAC;AAGpE,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,+BAA+B,EAC/B,gCAAgC,EAChC,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAGpG,OAAO,EAEL,YAAY,EACZ,mBAAmB,EAEnB,wBAAwB,EACxB,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EAEpB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,11 @@ export { parseAddress, getAddressDisplayLines } from './address';
|
|
|
5
5
|
// Date formatting utilities
|
|
6
6
|
export { formatDate, formatFullDate, formatShortDate, formatNumericDate, formatTime, formatDateTime, formatFullDateTime, formatMemberSince, getDateRange, } from './date';
|
|
7
7
|
// Currency and number formatting utilities
|
|
8
|
-
export { NUMBER_FORMAT_OPTIONS_CURRENCY, NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED, parseCurrencyInput,
|
|
8
|
+
export { NUMBER_FORMAT_OPTIONS_CURRENCY, NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED, parseCurrencyInput, formatCurrency, formatQuantityWithSuffix, formatTransactionAmount, formatBSB, formatAccountNumber, formatCryptoBalance, getBlockchainShortName,
|
|
9
|
+
// Label formatting
|
|
10
|
+
formatSourceOfFunds, formatIntendedUse,
|
|
11
|
+
// Percentage formatting
|
|
12
|
+
formatPercentage, formatAllocationPercentage, } from './formatting';
|
|
9
13
|
// Portfolio utilities
|
|
10
14
|
export { formatPortfolioValue, calculateReturnPercentage, parseNumericValue, validateAllocations } from './portfolio';
|
|
11
15
|
// Validation utilities
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,oBAAoB;AACpB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEjE,4BAA4B;AAC5B,OAAO,EACL,UAAU,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GAEb,MAAM,QAAQ,CAAC;AAEhB,2CAA2C;AAC3C,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,EACrC,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,oBAAoB;AACpB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEjE,4BAA4B;AAC5B,OAAO,EACL,UAAU,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GAEb,MAAM,QAAQ,CAAC;AAEhB,2CAA2C;AAC3C,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,EACrC,kBAAkB,EAClB,cAAc,EAEd,wBAAwB,EACxB,uBAAuB,EACvB,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB;AACtB,mBAAmB;AACnB,mBAAmB,EACnB,iBAAiB;AACjB,wBAAwB;AACxB,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AAEtB,sBAAsB;AACtB,OAAO,EAAE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BAAqB,EACrB,sBAAsB,GAGvB,MAAM,qBAAqB,CAAC;AAE7B,sFAAsF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cranberry-money/shared-utils",
|
|
3
|
-
"version": "8.23.
|
|
3
|
+
"version": "8.23.395",
|
|
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.
|
|
33
|
-
"@cranberry-money/shared-types": "^8.22.
|
|
32
|
+
"@cranberry-money/shared-constants": "^8.15.420",
|
|
33
|
+
"@cranberry-money/shared-types": "^8.22.395"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/jest": "^30.0.0",
|