@cranberry-money/shared-utils 8.18.0 → 8.19.1
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/README.md +16 -9
- package/package.json +4 -2
- package/dist/allocations.d.ts +0 -18
- package/dist/allocations.d.ts.map +0 -1
- package/dist/allocations.js +0 -20
- package/dist/auth.d.ts +0 -54
- package/dist/auth.js +0 -135
- package/dist/badge-status.d.ts +0 -65
- package/dist/badge-status.d.ts.map +0 -1
- package/dist/badge-status.js +0 -170
- package/dist/badge.d.ts +0 -41
- package/dist/badge.d.ts.map +0 -1
- package/dist/badge.js +0 -72
- package/dist/cash-account.d.ts +0 -43
- package/dist/cash-account.d.ts.map +0 -1
- package/dist/cash-account.js +0 -52
- package/dist/collections.d.ts +0 -80
- package/dist/collections.js +0 -127
- package/dist/country.d.ts +0 -107
- package/dist/country.js +0 -116
- package/dist/currency.d.ts +0 -99
- package/dist/currency.d.ts.map +0 -1
- package/dist/currency.js +0 -128
- package/dist/dashboard.d.ts +0 -72
- package/dist/dashboard.d.ts.map +0 -1
- package/dist/dashboard.js +0 -121
- package/dist/date.d.ts +0 -64
- package/dist/date.d.ts.map +0 -1
- package/dist/date.js +0 -91
- package/dist/document.d.ts +0 -37
- package/dist/document.js +0 -57
- package/dist/downloads.d.ts +0 -12
- package/dist/downloads.d.ts.map +0 -1
- package/dist/downloads.js +0 -20
- package/dist/filters.d.ts +0 -82
- package/dist/filters.d.ts.map +0 -1
- package/dist/filters.js +0 -109
- package/dist/formatting.d.ts +0 -58
- package/dist/formatting.js +0 -81
- package/dist/holdings.d.ts +0 -16
- package/dist/holdings.d.ts.map +0 -1
- package/dist/holdings.js +0 -23
- package/dist/index.d.ts +0 -26
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -46
- package/dist/industry.d.ts +0 -127
- package/dist/industry.js +0 -152
- package/dist/instruments.d.ts +0 -17
- package/dist/instruments.d.ts.map +0 -1
- package/dist/instruments.js +0 -36
- package/dist/investment-preference.d.ts +0 -24
- package/dist/investment-preference.js +0 -33
- package/dist/numbers.d.ts +0 -16
- package/dist/numbers.d.ts.map +0 -1
- package/dist/numbers.js +0 -27
- package/dist/portfolio-template.d.ts +0 -57
- package/dist/portfolio-template.d.ts.map +0 -1
- package/dist/portfolio-template.js +0 -61
- package/dist/portfolio-validation.d.ts +0 -35
- package/dist/portfolio-validation.d.ts.map +0 -1
- package/dist/portfolio-validation.js +0 -40
- package/dist/portfolio.d.ts +0 -68
- package/dist/portfolio.d.ts.map +0 -1
- package/dist/portfolio.js +0 -87
- package/dist/sector.d.ts +0 -123
- package/dist/sector.js +0 -134
- package/dist/stock-exchange.d.ts +0 -88
- package/dist/stock-exchange.js +0 -101
- package/dist/tax-residency.d.ts +0 -66
- package/dist/tax-residency.js +0 -70
- package/dist/text.d.ts +0 -22
- package/dist/text.d.ts.map +0 -1
- package/dist/text.js +0 -25
- package/dist/validation.d.ts +0 -93
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -143
- package/dist/withdrawal-status.d.ts +0 -68
- package/dist/withdrawal-status.d.ts.map +0 -1
- package/dist/withdrawal-status.js +0 -127
- package/dist/withdrawal.d.ts +0 -48
- package/dist/withdrawal.d.ts.map +0 -1
- package/dist/withdrawal.js +0 -62
package/README.md
CHANGED
|
@@ -11,12 +11,7 @@ npm install @myportfolio/shared-utils
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
15
|
-
formatCurrency,
|
|
16
|
-
formatDate,
|
|
17
|
-
hasActiveFilters,
|
|
18
|
-
truncateText
|
|
19
|
-
} from '@myportfolio/shared-utils';
|
|
14
|
+
import { formatCurrency, formatDate, hasActiveFilters, truncateText } from '@myportfolio/shared-utils';
|
|
20
15
|
|
|
21
16
|
// Currency formatting
|
|
22
17
|
const amount = formatCurrency(1234.56); // "1,234.56"
|
|
@@ -36,34 +31,40 @@ const short = truncateText('This is a very long text', 10); // "This is a..."
|
|
|
36
31
|
### Formatters
|
|
37
32
|
|
|
38
33
|
#### Currency (`formatters/currency.ts`)
|
|
34
|
+
|
|
39
35
|
- `formatCurrency(value)` - Format number with commas and 2 decimals
|
|
40
36
|
- `parseCurrencyInput(value)` - Parse currency string to number
|
|
41
37
|
- `formatCurrencyWithCode(value, code, locale, minDigits, maxDigits)` - Format with currency code
|
|
42
38
|
- `formatDefaultCurrency(value, minDigits, maxDigits)` - Format with default currency (AUD)
|
|
43
39
|
|
|
44
40
|
#### Dates (`formatters/dates.ts`)
|
|
41
|
+
|
|
45
42
|
- `formatDate(dateString, fallback)` - Format ISO date to localized date
|
|
46
43
|
- `formatShortDate(dateString, locale)` - Format to short date (e.g., "Jan 15")
|
|
47
44
|
- `formatTime(dateString, locale)` - Format to 24-hour time
|
|
48
45
|
- `formatDateTime(dateString, locale)` - Format to "Jan 15 14:30"
|
|
49
46
|
|
|
50
47
|
#### Numbers (`formatters/numbers.ts`)
|
|
48
|
+
|
|
51
49
|
- `formatShares(shares, locale)` - Format share quantities (no decimals)
|
|
52
50
|
|
|
53
51
|
### Helpers
|
|
54
52
|
|
|
55
53
|
#### Filters (`helpers/filters.ts`)
|
|
54
|
+
|
|
56
55
|
- `hasActiveFilters<T>(filters, excludeFields)` - Check if any filters are active
|
|
57
56
|
- `countActiveFilters<T>(filters, excludeFields)` - Count active filters
|
|
58
57
|
- `clearAllFilters<T>(filters, preserveFields)` - Clear all filter values
|
|
59
58
|
- `updateFilters<T>(currentFilters, updates)` - Type-safe filter updates
|
|
60
59
|
|
|
61
60
|
#### Text (`helpers/text.ts`)
|
|
61
|
+
|
|
62
62
|
- `truncateText(text, maxLength)` - Truncate text with ellipsis
|
|
63
63
|
|
|
64
64
|
## Platform Compatibility
|
|
65
65
|
|
|
66
66
|
This package is designed to work across:
|
|
67
|
+
|
|
67
68
|
- Web applications (React) - Direct use of utility functions
|
|
68
69
|
- Mobile applications (React Native) - Platform-agnostic implementations
|
|
69
70
|
- Node.js environments - For server-side utility needs
|
|
@@ -71,23 +72,27 @@ This package is designed to work across:
|
|
|
71
72
|
### Platform-Specific Considerations
|
|
72
73
|
|
|
73
74
|
#### Date Formatting
|
|
75
|
+
|
|
74
76
|
The date formatters use `Intl.DateTimeFormat` and `toLocaleDateString` which work consistently across web and React Native platforms.
|
|
75
77
|
|
|
76
78
|
#### Currency Formatting
|
|
79
|
+
|
|
77
80
|
Currency formatters use `Intl.NumberFormat` which provides consistent formatting across platforms with proper locale support.
|
|
78
81
|
|
|
79
82
|
#### Filter Utilities
|
|
83
|
+
|
|
80
84
|
Filter utilities are completely platform-agnostic and work with any TypeScript object structure.
|
|
81
85
|
|
|
82
86
|
## Examples
|
|
83
87
|
|
|
84
88
|
### Currency Formatting
|
|
89
|
+
|
|
85
90
|
```typescript
|
|
86
91
|
import { formatCurrency, formatCurrencyWithCode } from '@myportfolio/shared-utils';
|
|
87
92
|
|
|
88
93
|
// Basic formatting
|
|
89
94
|
formatCurrency(1234.56); // "1,234.56"
|
|
90
|
-
formatCurrency(
|
|
95
|
+
formatCurrency('1234.56'); // "1,234.56"
|
|
91
96
|
|
|
92
97
|
// With currency code
|
|
93
98
|
formatCurrencyWithCode(1234.56, 'USD', 'en-US', 2, 2); // "$1,234.56"
|
|
@@ -95,6 +100,7 @@ formatCurrencyWithCode(1234.56, 'AUD', 'en-AU', 0, 0); // "A$1,235"
|
|
|
95
100
|
```
|
|
96
101
|
|
|
97
102
|
### Filter Management
|
|
103
|
+
|
|
98
104
|
```typescript
|
|
99
105
|
import { hasActiveFilters, countActiveFilters, clearAllFilters } from '@myportfolio/shared-utils';
|
|
100
106
|
|
|
@@ -118,13 +124,14 @@ const cleared = clearAllFilters(filters, ['searchQuery']);
|
|
|
118
124
|
```
|
|
119
125
|
|
|
120
126
|
### Date Formatting
|
|
127
|
+
|
|
121
128
|
```typescript
|
|
122
129
|
import { formatDate, formatDateTime, formatShortDate } from '@myportfolio/shared-utils';
|
|
123
130
|
|
|
124
131
|
const isoDate = '2024-01-15T14:30:00Z';
|
|
125
132
|
|
|
126
133
|
formatDate(isoDate); // "1/15/2024"
|
|
127
|
-
formatShortDate(isoDate); // "Jan 15"
|
|
134
|
+
formatShortDate(isoDate); // "Jan 15"
|
|
128
135
|
formatDateTime(isoDate); // "Jan 15 14:30"
|
|
129
136
|
```
|
|
130
137
|
|
|
@@ -147,4 +154,4 @@ npm run typecheck
|
|
|
147
154
|
|
|
148
155
|
## License
|
|
149
156
|
|
|
150
|
-
MIT
|
|
157
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cranberry-money/shared-utils",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.19.1",
|
|
4
4
|
"description": "Shared utility functions for MyPortfolio platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"typecheck": "tsc --noEmit",
|
|
22
22
|
"dev": "tsc --watch",
|
|
23
23
|
"lint": "eslint src",
|
|
24
|
-
"lint:fix": "eslint src --fix"
|
|
24
|
+
"lint:fix": "eslint src --fix",
|
|
25
|
+
"format": "prettier --write 'src/**/*.{ts,tsx}'",
|
|
26
|
+
"format:check": "prettier --check 'src/**/*.{ts,tsx}'"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
29
|
"@cranberry-money/shared-constants": "^8.0.0",
|
package/dist/allocations.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AssetAllocation } from '@cranberry-money/shared-types';
|
|
2
|
-
/**
|
|
3
|
-
* Validates if allocation percentages sum to 100%
|
|
4
|
-
* Allows for small floating point errors (e.g., 99.99 or 100.01)
|
|
5
|
-
*
|
|
6
|
-
* @param allocations - Array of asset allocations to validate
|
|
7
|
-
* @returns true if allocations sum to approximately 100%, false otherwise
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const allocations = [
|
|
11
|
-
* { percentage: '50.00' },
|
|
12
|
-
* { percentage: '30.00' },
|
|
13
|
-
* { percentage: '20.00' }
|
|
14
|
-
* ];
|
|
15
|
-
* validateAllocations(allocations); // returns true
|
|
16
|
-
*/
|
|
17
|
-
export declare const validateAllocations: (allocations: readonly AssetAllocation[]) => boolean;
|
|
18
|
-
//# sourceMappingURL=allocations.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"allocations.d.ts","sourceRoot":"","sources":["../src/allocations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,GAAI,aAAa,SAAS,eAAe,EAAE,KAAG,OAK7E,CAAC"}
|
package/dist/allocations.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates if allocation percentages sum to 100%
|
|
3
|
-
* Allows for small floating point errors (e.g., 99.99 or 100.01)
|
|
4
|
-
*
|
|
5
|
-
* @param allocations - Array of asset allocations to validate
|
|
6
|
-
* @returns true if allocations sum to approximately 100%, false otherwise
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const allocations = [
|
|
10
|
-
* { percentage: '50.00' },
|
|
11
|
-
* { percentage: '30.00' },
|
|
12
|
-
* { percentage: '20.00' }
|
|
13
|
-
* ];
|
|
14
|
-
* validateAllocations(allocations); // returns true
|
|
15
|
-
*/
|
|
16
|
-
export const validateAllocations = (allocations) => {
|
|
17
|
-
const totalPercentage = allocations.reduce((sum, allocation) => sum + parseFloat(allocation.percentage), 0);
|
|
18
|
-
// Allow for small floating point errors (e.g., 99.99 or 100.01)
|
|
19
|
-
return Math.abs(totalPercentage - 100) < 0.01;
|
|
20
|
-
};
|
package/dist/auth.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication and token management utilities
|
|
3
|
-
*/
|
|
4
|
-
import type { DeviceInfo, TokenRefreshResponse, TokenRefreshError, AutoRefreshHandler } from '@cranberry-money/shared-types';
|
|
5
|
-
/**
|
|
6
|
-
* Check if a token has expired based on its expiration timestamp
|
|
7
|
-
* @param expiresAt - The expiration timestamp
|
|
8
|
-
* @returns true if token is expired, false otherwise
|
|
9
|
-
*/
|
|
10
|
-
export declare function isTokenExpired(expiresAt: string): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Check if a token will expire within a specified number of minutes
|
|
13
|
-
* @param expiresAt - The expiration timestamp
|
|
14
|
-
* @param minutesBeforeExpiry - Minutes before expiry to consider as "expiring soon"
|
|
15
|
-
* @returns true if token is expiring soon, false otherwise
|
|
16
|
-
*/
|
|
17
|
-
export declare function isTokenExpiringSoon(expiresAt: string, minutesBeforeExpiry?: number): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Get the remaining time until token expiry in minutes
|
|
20
|
-
* @param expiresAt - The expiration timestamp
|
|
21
|
-
* @returns Number of minutes until expiry
|
|
22
|
-
*/
|
|
23
|
-
export declare function getTimeUntilExpiry(expiresAt: string): number;
|
|
24
|
-
/**
|
|
25
|
-
* Format the time until expiry in a human-readable format
|
|
26
|
-
* @param expiresAt - The expiration timestamp
|
|
27
|
-
* @returns Formatted time string
|
|
28
|
-
*/
|
|
29
|
-
export declare function formatTimeUntilExpiry(expiresAt: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Parse device information from user agent string
|
|
32
|
-
* @param userAgent - The user agent string
|
|
33
|
-
* @returns Parsed device info
|
|
34
|
-
*/
|
|
35
|
-
export declare function parseDeviceInfo(userAgent: string): DeviceInfo;
|
|
36
|
-
/**
|
|
37
|
-
* Check if token refresh was successful
|
|
38
|
-
* @param response - The refresh response
|
|
39
|
-
* @returns true if refresh was successful, false otherwise
|
|
40
|
-
*/
|
|
41
|
-
export declare function isRefreshSuccess(response: TokenRefreshResponse): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Get error message from token refresh error
|
|
44
|
-
* @param error - The refresh error
|
|
45
|
-
* @returns Error message string
|
|
46
|
-
*/
|
|
47
|
-
export declare function getRefreshErrorMessage(error: TokenRefreshError): string;
|
|
48
|
-
/**
|
|
49
|
-
* Create an auto-refresh handler for tokens
|
|
50
|
-
* @param refreshCallback - Callback function to refresh token
|
|
51
|
-
* @param checkInterval - Interval in milliseconds to check for refresh
|
|
52
|
-
* @returns Auto refresh handler with start/stop methods
|
|
53
|
-
*/
|
|
54
|
-
export declare function createAutoRefreshHandler(refreshCallback: () => Promise<void>, checkInterval?: number): AutoRefreshHandler;
|
package/dist/auth.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication and token management utilities
|
|
3
|
-
*/
|
|
4
|
-
import { DEFAULT_TOKEN_REFRESH_BUFFER_MINUTES, MILLISECONDS_PER_MINUTE, MINUTES_PER_HOUR, HOURS_PER_DAY, TIME_LABEL_EXPIRED, TIME_LABEL_MINUTE, TIME_LABEL_MINUTES, TIME_LABEL_HOUR, TIME_LABEL_HOURS, TIME_LABEL_DAY, TIME_LABEL_DAYS, DEFAULT_UNKNOWN_VALUE, DEFAULT_ERROR_MESSAGE, } from '@cranberry-money/shared-constants';
|
|
5
|
-
/**
|
|
6
|
-
* Check if a token has expired based on its expiration timestamp
|
|
7
|
-
* @param expiresAt - The expiration timestamp
|
|
8
|
-
* @returns true if token is expired, false otherwise
|
|
9
|
-
*/
|
|
10
|
-
export function isTokenExpired(expiresAt) {
|
|
11
|
-
const expirationTime = new Date(expiresAt).getTime();
|
|
12
|
-
const currentTime = Date.now();
|
|
13
|
-
return currentTime >= expirationTime;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Check if a token will expire within a specified number of minutes
|
|
17
|
-
* @param expiresAt - The expiration timestamp
|
|
18
|
-
* @param minutesBeforeExpiry - Minutes before expiry to consider as "expiring soon"
|
|
19
|
-
* @returns true if token is expiring soon, false otherwise
|
|
20
|
-
*/
|
|
21
|
-
export function isTokenExpiringSoon(expiresAt, minutesBeforeExpiry = DEFAULT_TOKEN_REFRESH_BUFFER_MINUTES) {
|
|
22
|
-
const expirationTime = new Date(expiresAt).getTime();
|
|
23
|
-
const currentTime = Date.now();
|
|
24
|
-
const bufferTime = minutesBeforeExpiry * MILLISECONDS_PER_MINUTE;
|
|
25
|
-
return currentTime + bufferTime >= expirationTime;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get the remaining time until token expiry in minutes
|
|
29
|
-
* @param expiresAt - The expiration timestamp
|
|
30
|
-
* @returns Number of minutes until expiry
|
|
31
|
-
*/
|
|
32
|
-
export function getTimeUntilExpiry(expiresAt) {
|
|
33
|
-
const expirationTime = new Date(expiresAt).getTime();
|
|
34
|
-
const currentTime = Date.now();
|
|
35
|
-
const remainingTime = expirationTime - currentTime;
|
|
36
|
-
if (remainingTime <= 0) {
|
|
37
|
-
return 0;
|
|
38
|
-
}
|
|
39
|
-
return Math.floor(remainingTime / MILLISECONDS_PER_MINUTE);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Format the time until expiry in a human-readable format
|
|
43
|
-
* @param expiresAt - The expiration timestamp
|
|
44
|
-
* @returns Formatted time string
|
|
45
|
-
*/
|
|
46
|
-
export function formatTimeUntilExpiry(expiresAt) {
|
|
47
|
-
const minutesRemaining = getTimeUntilExpiry(expiresAt);
|
|
48
|
-
if (minutesRemaining <= 0) {
|
|
49
|
-
return TIME_LABEL_EXPIRED;
|
|
50
|
-
}
|
|
51
|
-
if (minutesRemaining < MINUTES_PER_HOUR) {
|
|
52
|
-
return minutesRemaining === 1 ? `1 ${TIME_LABEL_MINUTE}` : `${minutesRemaining} ${TIME_LABEL_MINUTES}`;
|
|
53
|
-
}
|
|
54
|
-
const hoursRemaining = Math.floor(minutesRemaining / MINUTES_PER_HOUR);
|
|
55
|
-
if (hoursRemaining < HOURS_PER_DAY) {
|
|
56
|
-
return hoursRemaining === 1 ? `1 ${TIME_LABEL_HOUR}` : `${hoursRemaining} ${TIME_LABEL_HOURS}`;
|
|
57
|
-
}
|
|
58
|
-
const daysRemaining = Math.floor(hoursRemaining / HOURS_PER_DAY);
|
|
59
|
-
return daysRemaining === 1 ? `1 ${TIME_LABEL_DAY}` : `${daysRemaining} ${TIME_LABEL_DAYS}`;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Parse device information from user agent string
|
|
63
|
-
* @param userAgent - The user agent string
|
|
64
|
-
* @returns Parsed device info
|
|
65
|
-
*/
|
|
66
|
-
export function parseDeviceInfo(userAgent) {
|
|
67
|
-
const browser = userAgent.includes('Chrome')
|
|
68
|
-
? 'Chrome'
|
|
69
|
-
: userAgent.includes('Firefox')
|
|
70
|
-
? 'Firefox'
|
|
71
|
-
: userAgent.includes('Safari')
|
|
72
|
-
? 'Safari'
|
|
73
|
-
: userAgent.includes('Edge')
|
|
74
|
-
? 'Edge'
|
|
75
|
-
: DEFAULT_UNKNOWN_VALUE;
|
|
76
|
-
const os = userAgent.includes('Windows')
|
|
77
|
-
? 'Windows'
|
|
78
|
-
: userAgent.includes('Mac')
|
|
79
|
-
? 'macOS'
|
|
80
|
-
: userAgent.includes('Linux')
|
|
81
|
-
? 'Linux'
|
|
82
|
-
: userAgent.includes('Android')
|
|
83
|
-
? 'Android'
|
|
84
|
-
: userAgent.includes('iOS')
|
|
85
|
-
? 'iOS'
|
|
86
|
-
: DEFAULT_UNKNOWN_VALUE;
|
|
87
|
-
return { browser, os };
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Check if token refresh was successful
|
|
91
|
-
* @param response - The refresh response
|
|
92
|
-
* @returns true if refresh was successful, false otherwise
|
|
93
|
-
*/
|
|
94
|
-
export function isRefreshSuccess(response) {
|
|
95
|
-
return !!(response?.status === 200 && response?.data?.access && response?.data?.refresh);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get error message from token refresh error
|
|
99
|
-
* @param error - The refresh error
|
|
100
|
-
* @returns Error message string
|
|
101
|
-
*/
|
|
102
|
-
export function getRefreshErrorMessage(error) {
|
|
103
|
-
if (error.response?.data?.detail) {
|
|
104
|
-
return error.response.data.detail;
|
|
105
|
-
}
|
|
106
|
-
if (error.response?.data?.message) {
|
|
107
|
-
return error.response.data.message;
|
|
108
|
-
}
|
|
109
|
-
if (error.message) {
|
|
110
|
-
return error.message;
|
|
111
|
-
}
|
|
112
|
-
return DEFAULT_ERROR_MESSAGE;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Create an auto-refresh handler for tokens
|
|
116
|
-
* @param refreshCallback - Callback function to refresh token
|
|
117
|
-
* @param checkInterval - Interval in milliseconds to check for refresh
|
|
118
|
-
* @returns Auto refresh handler with start/stop methods
|
|
119
|
-
*/
|
|
120
|
-
export function createAutoRefreshHandler(refreshCallback, checkInterval = 60000 // 1 minute
|
|
121
|
-
) {
|
|
122
|
-
let intervalId = null;
|
|
123
|
-
const start = () => {
|
|
124
|
-
if (intervalId)
|
|
125
|
-
return;
|
|
126
|
-
intervalId = setInterval(refreshCallback, checkInterval);
|
|
127
|
-
};
|
|
128
|
-
const stop = () => {
|
|
129
|
-
if (intervalId) {
|
|
130
|
-
clearInterval(intervalId);
|
|
131
|
-
intervalId = null;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
return { start, stop };
|
|
135
|
-
}
|
package/dist/badge-status.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Badge Status Utilities - Status-specific badge functions
|
|
3
|
-
*
|
|
4
|
-
* This module provides pre-configured badge functions for common status types
|
|
5
|
-
* in the MyPortfolio platform. It builds on top of the core badge system.
|
|
6
|
-
*/
|
|
7
|
-
import type { StatusBadgeStyle, TradeStatus, WithdrawalStatus, LiquidationStatus, TargetTradeStatus } from '@cranberry-money/shared-types';
|
|
8
|
-
import type { BadgeSize } from '@cranberry-money/shared-types';
|
|
9
|
-
/**
|
|
10
|
-
* Creates a badge for trade status
|
|
11
|
-
*
|
|
12
|
-
* @param status - Trade status constant
|
|
13
|
-
* @param size - Badge size (default: 'md')
|
|
14
|
-
* @returns Badge style with display text and accessibility attributes
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const badge = getTradeStatusBadge(TRADE_STATUS_SETTLED);
|
|
19
|
-
* // Returns badge with success variant and "Settled" display text
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare function getTradeStatusBadge(status: TradeStatus, size?: BadgeSize): StatusBadgeStyle;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a badge for withdrawal status
|
|
25
|
-
*
|
|
26
|
-
* @param status - Withdrawal status constant
|
|
27
|
-
* @param size - Badge size (default: 'md')
|
|
28
|
-
* @returns Badge style with display text and accessibility attributes
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const badge = getWithdrawalStatusBadge(WITHDRAWAL_STATUS_APPROVED);
|
|
33
|
-
* // Returns badge with success variant and "Approved" display text
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function getWithdrawalStatusBadge(status: WithdrawalStatus, size?: BadgeSize): StatusBadgeStyle;
|
|
37
|
-
/**
|
|
38
|
-
* Creates a badge for liquidation status
|
|
39
|
-
*
|
|
40
|
-
* @param status - Liquidation status constant
|
|
41
|
-
* @param size - Badge size (default: 'md')
|
|
42
|
-
* @returns Badge style with display text and accessibility attributes
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const badge = getLiquidationStatusBadge(LIQUIDATION_STATUS_SETTLED);
|
|
47
|
-
* // Returns badge with success variant and "Settled" display text
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare function getLiquidationStatusBadge(status: LiquidationStatus, size?: BadgeSize): StatusBadgeStyle;
|
|
51
|
-
/**
|
|
52
|
-
* Creates a badge for target trade status
|
|
53
|
-
*
|
|
54
|
-
* @param status - Target trade status constant
|
|
55
|
-
* @param size - Badge size (default: 'md')
|
|
56
|
-
* @returns Badge style with display text and accessibility attributes
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* const badge = getTargetTradeStatusBadge(TARGET_TRADE_STATUS_PENDING);
|
|
61
|
-
* // Returns badge with warning variant and "Pending" display text
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export declare function getTargetTradeStatusBadge(status: TargetTradeStatus, size?: BadgeSize): StatusBadgeStyle;
|
|
65
|
-
//# sourceMappingURL=badge-status.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"badge-status.d.ts","sourceRoot":"","sources":["../src/badge-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAmDvC,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAiF7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE,SAAgB,GAAG,gBAAgB,CAUjG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,GAAE,SAAgB,GAAG,gBAAgB,CAU3G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,GAAE,SAAgB,GAAG,gBAAgB,CAU7G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,GAAE,SAAgB,GAAG,gBAAgB,CAU7G"}
|
package/dist/badge-status.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Badge Status Utilities - Status-specific badge functions
|
|
3
|
-
*
|
|
4
|
-
* This module provides pre-configured badge functions for common status types
|
|
5
|
-
* in the MyPortfolio platform. It builds on top of the core badge system.
|
|
6
|
-
*/
|
|
7
|
-
import { TRADE_STATUS_EXECUTED, TRADE_STATUS_SETTLED, TRADE_STATUS_CANCELLED, TRADE_STATUS_FAILED, TRADE_STATUS_LABEL_EXECUTED, TRADE_STATUS_LABEL_SETTLED, TRADE_STATUS_LABEL_CANCELLED, TRADE_STATUS_LABEL_FAILED, TARGET_TRADE_STATUS_PENDING, TARGET_TRADE_STATUS_APPROVED, TARGET_TRADE_STATUS_SUBMITTED, TARGET_TRADE_STATUS_CANCELLED, TARGET_TRADE_STATUS_EXPIRED, TARGET_TRADE_STATUS_LABEL_PENDING, TARGET_TRADE_STATUS_LABEL_APPROVED, TARGET_TRADE_STATUS_LABEL_SUBMITTED, TARGET_TRADE_STATUS_LABEL_CANCELLED, TARGET_TRADE_STATUS_LABEL_EXPIRED, WITHDRAWAL_STATUS_PENDING_REVIEW, WITHDRAWAL_STATUS_APPROVED, WITHDRAWAL_STATUS_REJECTED, WITHDRAWAL_STATUS_PROCESSING, WITHDRAWAL_STATUS_AWAITING_LIQUIDATION, WITHDRAWAL_STATUS_LIQUIDATION_IN_PROGRESS, WITHDRAWAL_STATUS_COMPLETED, WITHDRAWAL_STATUS_CANCELLED, WITHDRAWAL_STATUS_FAILED, WITHDRAWAL_STATUS_LABEL_PENDING_REVIEW, WITHDRAWAL_STATUS_LABEL_APPROVED, WITHDRAWAL_STATUS_LABEL_REJECTED, WITHDRAWAL_STATUS_LABEL_PROCESSING, WITHDRAWAL_STATUS_LABEL_AWAITING_LIQUIDATION, WITHDRAWAL_STATUS_LABEL_LIQUIDATION_IN_PROGRESS, WITHDRAWAL_STATUS_LABEL_COMPLETED, WITHDRAWAL_STATUS_LABEL_CANCELLED, WITHDRAWAL_STATUS_LABEL_FAILED, LIQUIDATION_STATUS_PENDING, LIQUIDATION_STATUS_TRADES_CREATED, LIQUIDATION_STATUS_EXECUTED, LIQUIDATION_STATUS_SETTLED, LIQUIDATION_STATUS_FAILED, LIQUIDATION_STATUS_LABEL_PENDING, LIQUIDATION_STATUS_LABEL_TRADES_CREATED, LIQUIDATION_STATUS_LABEL_EXECUTED, LIQUIDATION_STATUS_LABEL_SETTLED, LIQUIDATION_STATUS_LABEL_FAILED, } from '@cranberry-money/shared-constants';
|
|
8
|
-
import { createBadge } from './badge';
|
|
9
|
-
// Status to variant mappings
|
|
10
|
-
const TRADE_STATUS_MAPPING = {
|
|
11
|
-
[TRADE_STATUS_EXECUTED]: 'primary',
|
|
12
|
-
[TRADE_STATUS_SETTLED]: 'success',
|
|
13
|
-
[TRADE_STATUS_CANCELLED]: 'error',
|
|
14
|
-
[TRADE_STATUS_FAILED]: 'error',
|
|
15
|
-
[TARGET_TRADE_STATUS_PENDING]: 'warning',
|
|
16
|
-
[TARGET_TRADE_STATUS_SUBMITTED]: 'primary',
|
|
17
|
-
[TARGET_TRADE_STATUS_EXPIRED]: 'neutral',
|
|
18
|
-
};
|
|
19
|
-
const WITHDRAWAL_STATUS_MAPPING = {
|
|
20
|
-
[WITHDRAWAL_STATUS_PENDING_REVIEW]: 'warning',
|
|
21
|
-
[WITHDRAWAL_STATUS_APPROVED]: 'success',
|
|
22
|
-
[WITHDRAWAL_STATUS_REJECTED]: 'error',
|
|
23
|
-
[WITHDRAWAL_STATUS_PROCESSING]: 'primary',
|
|
24
|
-
[WITHDRAWAL_STATUS_AWAITING_LIQUIDATION]: 'warning',
|
|
25
|
-
[WITHDRAWAL_STATUS_LIQUIDATION_IN_PROGRESS]: 'primary',
|
|
26
|
-
[WITHDRAWAL_STATUS_COMPLETED]: 'success',
|
|
27
|
-
[WITHDRAWAL_STATUS_CANCELLED]: 'neutral',
|
|
28
|
-
[WITHDRAWAL_STATUS_FAILED]: 'error',
|
|
29
|
-
};
|
|
30
|
-
const LIQUIDATION_STATUS_MAPPING = {
|
|
31
|
-
[LIQUIDATION_STATUS_PENDING]: 'warning',
|
|
32
|
-
[LIQUIDATION_STATUS_TRADES_CREATED]: 'primary',
|
|
33
|
-
[LIQUIDATION_STATUS_EXECUTED]: 'primary',
|
|
34
|
-
[LIQUIDATION_STATUS_SETTLED]: 'success',
|
|
35
|
-
[LIQUIDATION_STATUS_FAILED]: 'error',
|
|
36
|
-
};
|
|
37
|
-
const TARGET_TRADE_STATUS_MAPPING = {
|
|
38
|
-
[TARGET_TRADE_STATUS_PENDING]: 'warning',
|
|
39
|
-
[TARGET_TRADE_STATUS_APPROVED]: 'success',
|
|
40
|
-
[TARGET_TRADE_STATUS_SUBMITTED]: 'primary',
|
|
41
|
-
[TARGET_TRADE_STATUS_CANCELLED]: 'error',
|
|
42
|
-
[TARGET_TRADE_STATUS_EXPIRED]: 'neutral',
|
|
43
|
-
};
|
|
44
|
-
// Status to label mappings
|
|
45
|
-
const TRADE_STATUS_LABELS = {
|
|
46
|
-
[TRADE_STATUS_EXECUTED]: TRADE_STATUS_LABEL_EXECUTED,
|
|
47
|
-
[TRADE_STATUS_SETTLED]: TRADE_STATUS_LABEL_SETTLED,
|
|
48
|
-
[TRADE_STATUS_CANCELLED]: TRADE_STATUS_LABEL_CANCELLED,
|
|
49
|
-
[TRADE_STATUS_FAILED]: TRADE_STATUS_LABEL_FAILED,
|
|
50
|
-
[TARGET_TRADE_STATUS_PENDING]: TARGET_TRADE_STATUS_LABEL_PENDING,
|
|
51
|
-
[TARGET_TRADE_STATUS_SUBMITTED]: TARGET_TRADE_STATUS_LABEL_SUBMITTED,
|
|
52
|
-
[TARGET_TRADE_STATUS_EXPIRED]: TARGET_TRADE_STATUS_LABEL_EXPIRED,
|
|
53
|
-
};
|
|
54
|
-
const WITHDRAWAL_STATUS_LABELS = {
|
|
55
|
-
[WITHDRAWAL_STATUS_PENDING_REVIEW]: WITHDRAWAL_STATUS_LABEL_PENDING_REVIEW,
|
|
56
|
-
[WITHDRAWAL_STATUS_APPROVED]: WITHDRAWAL_STATUS_LABEL_APPROVED,
|
|
57
|
-
[WITHDRAWAL_STATUS_REJECTED]: WITHDRAWAL_STATUS_LABEL_REJECTED,
|
|
58
|
-
[WITHDRAWAL_STATUS_PROCESSING]: WITHDRAWAL_STATUS_LABEL_PROCESSING,
|
|
59
|
-
[WITHDRAWAL_STATUS_AWAITING_LIQUIDATION]: WITHDRAWAL_STATUS_LABEL_AWAITING_LIQUIDATION,
|
|
60
|
-
[WITHDRAWAL_STATUS_LIQUIDATION_IN_PROGRESS]: WITHDRAWAL_STATUS_LABEL_LIQUIDATION_IN_PROGRESS,
|
|
61
|
-
[WITHDRAWAL_STATUS_COMPLETED]: WITHDRAWAL_STATUS_LABEL_COMPLETED,
|
|
62
|
-
[WITHDRAWAL_STATUS_CANCELLED]: WITHDRAWAL_STATUS_LABEL_CANCELLED,
|
|
63
|
-
[WITHDRAWAL_STATUS_FAILED]: WITHDRAWAL_STATUS_LABEL_FAILED,
|
|
64
|
-
};
|
|
65
|
-
const LIQUIDATION_STATUS_LABELS = {
|
|
66
|
-
[LIQUIDATION_STATUS_PENDING]: LIQUIDATION_STATUS_LABEL_PENDING,
|
|
67
|
-
[LIQUIDATION_STATUS_TRADES_CREATED]: LIQUIDATION_STATUS_LABEL_TRADES_CREATED,
|
|
68
|
-
[LIQUIDATION_STATUS_EXECUTED]: LIQUIDATION_STATUS_LABEL_EXECUTED,
|
|
69
|
-
[LIQUIDATION_STATUS_SETTLED]: LIQUIDATION_STATUS_LABEL_SETTLED,
|
|
70
|
-
[LIQUIDATION_STATUS_FAILED]: LIQUIDATION_STATUS_LABEL_FAILED,
|
|
71
|
-
};
|
|
72
|
-
const TARGET_TRADE_STATUS_LABELS = {
|
|
73
|
-
[TARGET_TRADE_STATUS_PENDING]: TARGET_TRADE_STATUS_LABEL_PENDING,
|
|
74
|
-
[TARGET_TRADE_STATUS_APPROVED]: TARGET_TRADE_STATUS_LABEL_APPROVED,
|
|
75
|
-
[TARGET_TRADE_STATUS_SUBMITTED]: TARGET_TRADE_STATUS_LABEL_SUBMITTED,
|
|
76
|
-
[TARGET_TRADE_STATUS_CANCELLED]: TARGET_TRADE_STATUS_LABEL_CANCELLED,
|
|
77
|
-
[TARGET_TRADE_STATUS_EXPIRED]: TARGET_TRADE_STATUS_LABEL_EXPIRED,
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Creates a badge for trade status
|
|
81
|
-
*
|
|
82
|
-
* @param status - Trade status constant
|
|
83
|
-
* @param size - Badge size (default: 'md')
|
|
84
|
-
* @returns Badge style with display text and accessibility attributes
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* const badge = getTradeStatusBadge(TRADE_STATUS_SETTLED);
|
|
89
|
-
* // Returns badge with success variant and "Settled" display text
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export function getTradeStatusBadge(status, size = 'md') {
|
|
93
|
-
const variant = TRADE_STATUS_MAPPING[status] || 'neutral';
|
|
94
|
-
const badge = createBadge({ variant, size });
|
|
95
|
-
const displayText = TRADE_STATUS_LABELS[status] || status.charAt(0) + status.slice(1).toLowerCase();
|
|
96
|
-
return {
|
|
97
|
-
...badge,
|
|
98
|
-
displayText,
|
|
99
|
-
ariaLabel: `Trade status: ${displayText}`,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Creates a badge for withdrawal status
|
|
104
|
-
*
|
|
105
|
-
* @param status - Withdrawal status constant
|
|
106
|
-
* @param size - Badge size (default: 'md')
|
|
107
|
-
* @returns Badge style with display text and accessibility attributes
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```typescript
|
|
111
|
-
* const badge = getWithdrawalStatusBadge(WITHDRAWAL_STATUS_APPROVED);
|
|
112
|
-
* // Returns badge with success variant and "Approved" display text
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
export function getWithdrawalStatusBadge(status, size = 'md') {
|
|
116
|
-
const variant = WITHDRAWAL_STATUS_MAPPING[status] || 'neutral';
|
|
117
|
-
const badge = createBadge({ variant, size });
|
|
118
|
-
const displayText = WITHDRAWAL_STATUS_LABELS[status] || status;
|
|
119
|
-
return {
|
|
120
|
-
...badge,
|
|
121
|
-
displayText,
|
|
122
|
-
ariaLabel: `Withdrawal status: ${displayText}`,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Creates a badge for liquidation status
|
|
127
|
-
*
|
|
128
|
-
* @param status - Liquidation status constant
|
|
129
|
-
* @param size - Badge size (default: 'md')
|
|
130
|
-
* @returns Badge style with display text and accessibility attributes
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```typescript
|
|
134
|
-
* const badge = getLiquidationStatusBadge(LIQUIDATION_STATUS_SETTLED);
|
|
135
|
-
* // Returns badge with success variant and "Settled" display text
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
export function getLiquidationStatusBadge(status, size = 'md') {
|
|
139
|
-
const variant = LIQUIDATION_STATUS_MAPPING[status] || 'neutral';
|
|
140
|
-
const badge = createBadge({ variant, size });
|
|
141
|
-
const displayText = LIQUIDATION_STATUS_LABELS[status] || status;
|
|
142
|
-
return {
|
|
143
|
-
...badge,
|
|
144
|
-
displayText,
|
|
145
|
-
ariaLabel: `Liquidation status: ${displayText}`,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Creates a badge for target trade status
|
|
150
|
-
*
|
|
151
|
-
* @param status - Target trade status constant
|
|
152
|
-
* @param size - Badge size (default: 'md')
|
|
153
|
-
* @returns Badge style with display text and accessibility attributes
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```typescript
|
|
157
|
-
* const badge = getTargetTradeStatusBadge(TARGET_TRADE_STATUS_PENDING);
|
|
158
|
-
* // Returns badge with warning variant and "Pending" display text
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
|
-
export function getTargetTradeStatusBadge(status, size = 'md') {
|
|
162
|
-
const variant = TARGET_TRADE_STATUS_MAPPING[status] || 'neutral';
|
|
163
|
-
const badge = createBadge({ variant, size });
|
|
164
|
-
const displayText = TARGET_TRADE_STATUS_LABELS[status] || status;
|
|
165
|
-
return {
|
|
166
|
-
...badge,
|
|
167
|
-
displayText,
|
|
168
|
-
ariaLabel: `Target trade status: ${displayText}`,
|
|
169
|
-
};
|
|
170
|
-
}
|
package/dist/badge.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Badge System Core - Type definitions and factory function
|
|
3
|
-
*
|
|
4
|
-
* This module provides a standardized way to create and style badges.
|
|
5
|
-
* It ensures consistency in colors, typography, and semantic meaning
|
|
6
|
-
* while maintaining accessibility standards.
|
|
7
|
-
*
|
|
8
|
-
* Note: The actual style classes are designed to work with Tailwind CSS
|
|
9
|
-
* and assume a specific color system is in place.
|
|
10
|
-
*/
|
|
11
|
-
import type { BadgeVariant, BadgeSize, BadgeConfig, BadgeStyle } from '@cranberry-money/shared-types';
|
|
12
|
-
/**
|
|
13
|
-
* Creates a badge style configuration with appropriate CSS classes
|
|
14
|
-
*
|
|
15
|
-
* @param config - Badge configuration options
|
|
16
|
-
* @param variantStyles - Optional custom variant styles (defaults to DEFAULT_BADGE_VARIANTS)
|
|
17
|
-
* @param sizeStyles - Optional custom size styles (defaults to DEFAULT_BADGE_SIZES)
|
|
18
|
-
* @returns Badge style object with className and accessibility attributes
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* // Create a success badge
|
|
23
|
-
* const successBadge = createBadge({ variant: 'success' });
|
|
24
|
-
* // Returns: { className: 'inline-flex items-center rounded-md font-medium whitespace-nowrap transition-colors bg-success-900/80 text-success-300 text-xs px-2 py-1', ariaLabel: 'success status' }
|
|
25
|
-
*
|
|
26
|
-
* // Create a large warning badge with custom class
|
|
27
|
-
* const warningBadge = createBadge({ variant: 'warning', size: 'lg', className: 'ml-2' });
|
|
28
|
-
*
|
|
29
|
-
* // Use custom variant styles
|
|
30
|
-
* const customVariants = { primary: 'bg-blue-500 text-white', ... };
|
|
31
|
-
* const customBadge = createBadge({ variant: 'primary' }, customVariants);
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare function createBadge({ variant, size, className }: BadgeConfig, variantStyles?: Record<BadgeVariant, string>, sizeStyles?: Record<BadgeSize, string>): BadgeStyle;
|
|
35
|
-
/**
|
|
36
|
-
* Export the default style mappings for consumers who want to use them directly
|
|
37
|
-
* or extend them with their own styles
|
|
38
|
-
*/
|
|
39
|
-
export declare const BADGE_VARIANTS: Record<BadgeVariant, string>;
|
|
40
|
-
export declare const BADGE_SIZES: Record<BadgeSize, string>;
|
|
41
|
-
//# sourceMappingURL=badge.d.ts.map
|
package/dist/badge.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../src/badge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AA+BtG;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,EAAE,OAAO,EAAE,IAAW,EAAE,SAAc,EAAE,EAAE,WAAW,EACrD,aAAa,GAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAA0B,EACpE,UAAU,GAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAuB,GAC1D,UAAU,CAQZ;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,8BAAyB,CAAC;AACrD,eAAO,MAAM,WAAW,2BAAsB,CAAC"}
|